Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/lib/rex/parser/group_policy_preferences_spec.rb
Views: 11655
# encoding: binary12xml_group = '3<?xml version="1.0" encoding="utf-8"?>4<Groups clsid="{3125E937-EB16-4b4c-9934-544FC6D24D26}"><User clsid="{DF5F1855-51E5-4d24-8B1A-D9BDE98BA1D1}" name="SuperSecretBackdoor" image="0" changed="2013-04-25 18:36:07" uid="{B5EDB865-34F5-4BD7-9C59-3AEB1C7A68C3}"><Properties action="C" fullName="" description="" cpassword="VBQUNbDhuVti3/GHTGHPvcno2vH3y8e8m1qALVO1H3T0rdkr2rub1smfTtqRBRI3" changeLogon="0" noChange="0" neverExpires="1" acctDisabled="0" userName="SuperSecretBackdoor"/></User>5</Groups>6'78xml_datasrc = '9<?xml version="1.0" encoding="utf-8"?>10<DataSources clsid="{380F820F-F21B-41ac-A3CC-24D4F80F067B}"><DataSource clsid="{5C209626-D820-4d69-8D50-1FACD6214488}" userContext="1" name="test" image="0" changed="2013-04-25 20:39:08" uid="{3513F923-9661-4819-9995-91A63C7D7A65}"><Properties action="C" userDSN="0" dsn="test" driver="test" description="" username="test" cpassword="eYbbv1GZI4DZEgTXPUDspw"><Attributes><Attribute name="test" value="test"/><Attribute name="test2" value="test2"/></Attributes></Properties></DataSource>11</DataSources>12'1314xml_drive = '15<?xml version="1.0" encoding="utf-8"?>16<Drives clsid="{8FDDCC1A-0C3C-43cd-A6B4-71A6DF20DA8C}"><Drive clsid="{935D1B74-9CB8-4e3c-9914-7DD559B7A417}" name="E:" status="E:" image="0" changed="2013-04-25 20:33:02" uid="{016E2095-EAB5-43C0-8BCF-4C2655F709F5}"><Properties action="C" thisDrive="NOCHANGE" allDrives="NOCHANGE" userName="drivemap" path="drivemap" label="" persistent="0" useLetter="1" letter="E" cpassword="Lj3fkZ8E3AFAJPTSoBitKw"/></Drive>17</Drives>18'1920xml_schd = '21<?xml version="1.0" encoding="utf-8"?>22<ScheduledTasks clsid="{CC63F200-7309-4ba0-B154-A71CD118DBCC}"><Task clsid="{2DEECB1C-261F-4e13-9B21-16FB83BC03BD}" name="test1" image="2" changed="2013-04-25 20:30:13" uid="{41059D76-C7B4-4D05-9679-AE7510247B1F}"><Properties action="U" name="test1" appName="notepad.exe" args="" startIn="" comment="" runAs="test1" cpassword="DdGgLn/bpUNU/QjjcNvn4A" enabled="0"><Triggers><Trigger type="DAILY" startHour="8" startMinutes="0" beginYear="2013" beginMonth="4" beginDay="25" hasEndDate="0" repeatTask="0" interval="1"/></Triggers></Properties></Task>23</ScheduledTasks>24'2526xml_serv = '27<?xml version="1.0" encoding="utf-8"?>28<NTServices clsid="{2CFB484A-4E96-4b5d-A0B6-093D2F91E6AE}"><NTService clsid="{AB6F0B67-341F-4e51-92F9-005FBFBA1A43}" name="Blah" image="0" changed="2013-04-25 20:29:49" uid="{C6AE4201-9F99-46AB-93C2-9D734D87D343}"><Properties startupType="NOCHANGE" serviceName="Blah" timeout="30" accountName="bob" cpassword="OQWR9sf5FTlGgh8SJX31ug"/></NTService>29</NTServices>30'3132xml_ms = '33<?xml version="1.0" encoding="utf-8"?>34<Groups clsid="{3125E937-EB16-4b4c-9934-544FC6D24D26}"35disabled="1">36<User clsid="{DF5F1855-51E5-4d24-8B1A-D9BDE98BA1D1}"37name="DbAdmin"38image="2"39changed="2007-07-06 20:45:20"40uid="{253F4D90-150A-4EFB-BCC8-6E894A9105F7}">41<Properties42action="U"43newName=""44fullName="Database Admin"45description="Local Database Admin"46cpassword="demo"47changeLogon="0"48noChange="0"49neverExpires="0"50acctDisabled="1"51userName="DbAdmin"/>52</User>53<Group clsid="{6D4A79E4-529C-4481-ABD0-F5BD7EA93BA7}"54name="Database Admins"55image="2"56changed="2007-07-06 20:46:21"57uid="{C5FB3901-508A-4A9E-9171-60D4FC2B404B}">58<Properties59action="U"60newName=""61description="Local Database Admins"62userAction="REMOVE"63deleteAllUsers="1"64deleteAllGroups="1"65removeAccounts="0"66groupName="Database Admins">67<Members>68<Member69name="domain\sampleuser"70action="ADD"71sid=""/>72</Members>73</Properties>74</Group>75</Groups>76'7778# Win2k8 appears to append some junk padding in some cases79cpassword_win2k8 = []80# Win2k8R2 - EqWFlA4kn2T6PHvGi09M7seHuqCYK/slkJWIl7mK+wEMON8tIIslS6707RU1F7Bh81cpassword_win2k8 << ['EqWFlA4kn2T6PHvGi09M7seHuqCYK/slkJWIl7mK+wEMON8tIIslS6707RU1F7BhTµkp', 'N3v3rGunnaG!veYo']82cpassword_win2k8 << ['EqWFlA4kn2T6PHvGi09M7seHuqCYK/slkJWIl7mK+wGSwOI7Be//GJdxd5YYXUQHTµkp', 'N3v3rGunnaG!veYou']83# Win2k8R2 - EqWFlA4kn2T6PHvGi09M7seHuqCYK/slkJWIl7mK+wFSuDccBEp/4l5EuKnwF0WS84cpassword_win2k8 << ['EqWFlA4kn2T6PHvGi09M7seHuqCYK/slkJWIl7mK+wFSuDccBEp/4l5EuKnwF0WS»YÂVAA', 'N3v3rGunnaG!veYouUp']85cpassword_normal = "j1Uyj3Vx8TY9LtLZil2uAuZkFQA/4latT76ZwgdHdhw"86cpassword_bad = "blah"8788RSpec.describe Rex::Parser::GPP do89GPP = Rex::Parser::GPP9091##92# Decrypt93##94it "Decrypt returns Local*P4ssword! for normal cpassword" do95result = GPP.decrypt(cpassword_normal)96expect(result).to eq("Local*P4ssword!")97end9899it "Decrypt returns blank for bad cpassword" do100result = GPP.decrypt(cpassword_bad)101expect(result).to eq("")102end103104it "Decrypt returns blank for nil cpassword" do105result = GPP.decrypt(nil)106expect(result).to eq("")107end108109it 'Decrypts a cpassword containing junk padding' do110cpassword_win2k8.each do |encrypted, expected|111result = GPP.decrypt(encrypted)112expect(result).to eq(expected)113end114end115116##117# Parse118##119120it "Parse returns empty [] for nil" do121expect(GPP.parse(nil)).to be_empty122end123124it "Parse returns results for xml_ms and password is empty" do125results = GPP.parse(xml_ms)126expect(results).not_to be_empty127expect(results[0][:PASS]).to be_empty128end129130it "Parse returns results for xml_datasrc, and attributes, and password is test1" do131results = GPP.parse(xml_datasrc)132expect(results).not_to be_empty133expect(results[0].include?(:ATTRIBUTES)).to be_truthy134expect(results[0][:ATTRIBUTES]).not_to be_empty135expect(results[0][:PASS]).to eq("test")136end137138xmls = []139xmls << xml_group140xmls << xml_drive141xmls << xml_schd142xmls << xml_serv143xmls << xml_datasrc144145it "Parse returns results for all good xmls and passwords" do146xmls.each do |xml|147results = GPP.parse(xml)148expect(results).not_to be_empty149expect(results[0][:PASS]).not_to be_empty150end151end152153##154# Create_Tables155##156it "Create_tables returns tables for all good xmls" do157xmls.each do |xml|158results = GPP.parse(xml)159tables = GPP.create_tables(results, "test")160expect(tables).not_to be_empty161end162end163end164165166