|
| 1 | +# encoding: binary |
1 | 2 | require 'rex/parser/group_policy_preferences'
|
2 | 3 |
|
3 | 4 | xml_group = '
|
|
76 | 77 | </Groups>
|
77 | 78 | '
|
78 | 79 |
|
| 80 | +# Win2k8 appears to append some junk padding in some cases |
| 81 | +cpassword_win2k8 = [] |
| 82 | +# Win2k8R2 - EqWFlA4kn2T6PHvGi09M7seHuqCYK/slkJWIl7mK+wEMON8tIIslS6707RU1F7Bh |
| 83 | +cpassword_win2k8 << ['EqWFlA4kn2T6PHvGi09M7seHuqCYK/slkJWIl7mK+wEMON8tIIslS6707RU1F7BhTµkp', 'N3v3rGunnaG!veYo'] |
| 84 | +cpassword_win2k8 << ['EqWFlA4kn2T6PHvGi09M7seHuqCYK/slkJWIl7mK+wGSwOI7Be//GJdxd5YYXUQHTµkp', 'N3v3rGunnaG!veYou'] |
| 85 | +# Win2k8R2 - EqWFlA4kn2T6PHvGi09M7seHuqCYK/slkJWIl7mK+wFSuDccBEp/4l5EuKnwF0WS |
| 86 | +cpassword_win2k8 << ['EqWFlA4kn2T6PHvGi09M7seHuqCYK/slkJWIl7mK+wFSuDccBEp/4l5EuKnwF0WS»YÂVAA', 'N3v3rGunnaG!veYouUp'] |
79 | 87 | cpassword_normal = "j1Uyj3Vx8TY9LtLZil2uAuZkFQA/4latT76ZwgdHdhw"
|
80 | 88 | cpassword_bad = "blah"
|
81 | 89 |
|
82 | 90 | describe Rex::Parser::GPP do
|
83 |
| - GPP = Rex::Parser::GPP |
84 |
| - |
85 |
| - ## |
86 |
| - # Decrypt |
87 |
| - ## |
88 |
| - it "Decrypt returns Local*P4ssword! for normal cpassword" do |
89 |
| - result = GPP.decrypt(cpassword_normal) |
90 |
| - result.should eq("Local*P4ssword!") |
91 |
| - end |
92 |
| - |
93 |
| - it "Decrypt returns blank for bad cpassword" do |
94 |
| - result = GPP.decrypt(cpassword_bad) |
95 |
| - result.should eq("") |
96 |
| - end |
97 |
| - |
98 |
| - it "Decrypt returns blank for nil cpassword" do |
99 |
| - result = GPP.decrypt(nil) |
100 |
| - result.should eq("") |
101 |
| - end |
102 |
| - |
103 |
| - ## |
104 |
| - # Parse |
105 |
| - ## |
106 |
| - |
107 |
| - it "Parse returns empty [] for nil" do |
108 |
| - GPP.parse(nil).should be_empty |
109 |
| - end |
110 |
| - |
111 |
| - it "Parse returns results for xml_ms and password is empty" do |
112 |
| - results = GPP.parse(xml_ms) |
113 |
| - results.should_not be_empty |
114 |
| - results[0][:PASS].should be_empty |
115 |
| - end |
116 |
| - |
117 |
| - it "Parse returns results for xml_datasrc, and attributes, and password is test1" do |
118 |
| - results = GPP.parse(xml_datasrc) |
119 |
| - results.should_not be_empty |
120 |
| - results[0].include?(:ATTRIBUTES).should be_true |
121 |
| - results[0][:ATTRIBUTES].should_not be_empty |
122 |
| - results[0][:PASS].should eq("test") |
123 |
| - end |
124 |
| - |
125 |
| - xmls = [] |
126 |
| - xmls << xml_group |
127 |
| - xmls << xml_drive |
128 |
| - xmls << xml_schd |
129 |
| - xmls << xml_serv |
130 |
| - xmls << xml_datasrc |
131 |
| - |
132 |
| - it "Parse returns results for all good xmls and passwords" do |
133 |
| - xmls.each do |xml| |
134 |
| - results = GPP.parse(xml) |
135 |
| - results.should_not be_empty |
136 |
| - results[0][:PASS].should_not be_empty |
137 |
| - end |
138 |
| - end |
139 |
| - |
140 |
| - ## |
141 |
| - # Create_Tables |
142 |
| - ## |
143 |
| - it "Create_tables returns tables for all good xmls" do |
144 |
| - xmls.each do |xml| |
145 |
| - results = GPP.parse(xml) |
146 |
| - tables = GPP.create_tables(results, "test") |
147 |
| - tables.should_not be_empty |
148 |
| - end |
149 |
| - end |
| 91 | + GPP = Rex::Parser::GPP |
| 92 | + |
| 93 | + ## |
| 94 | + # Decrypt |
| 95 | + ## |
| 96 | + it "Decrypt returns Local*P4ssword! for normal cpassword" do |
| 97 | + result = GPP.decrypt(cpassword_normal) |
| 98 | + result.should eq("Local*P4ssword!") |
| 99 | + end |
| 100 | + |
| 101 | + it "Decrypt returns blank for bad cpassword" do |
| 102 | + result = GPP.decrypt(cpassword_bad) |
| 103 | + result.should eq("") |
| 104 | + end |
| 105 | + |
| 106 | + it "Decrypt returns blank for nil cpassword" do |
| 107 | + result = GPP.decrypt(nil) |
| 108 | + result.should eq("") |
| 109 | + end |
| 110 | + |
| 111 | + it 'Decrypts a cpassword containing junk padding' do |
| 112 | + cpassword_win2k8.each do |encrypted, expected| |
| 113 | + result = GPP.decrypt(encrypted) |
| 114 | + result.should eq(expected) |
| 115 | + end |
| 116 | + end |
| 117 | + |
| 118 | + ## |
| 119 | + # Parse |
| 120 | + ## |
| 121 | + |
| 122 | + it "Parse returns empty [] for nil" do |
| 123 | + GPP.parse(nil).should be_empty |
| 124 | + end |
| 125 | + |
| 126 | + it "Parse returns results for xml_ms and password is empty" do |
| 127 | + results = GPP.parse(xml_ms) |
| 128 | + results.should_not be_empty |
| 129 | + results[0][:PASS].should be_empty |
| 130 | + end |
| 131 | + |
| 132 | + it "Parse returns results for xml_datasrc, and attributes, and password is test1" do |
| 133 | + results = GPP.parse(xml_datasrc) |
| 134 | + results.should_not be_empty |
| 135 | + results[0].include?(:ATTRIBUTES).should be_true |
| 136 | + results[0][:ATTRIBUTES].should_not be_empty |
| 137 | + results[0][:PASS].should eq("test") |
| 138 | + end |
| 139 | + |
| 140 | + xmls = [] |
| 141 | + xmls << xml_group |
| 142 | + xmls << xml_drive |
| 143 | + xmls << xml_schd |
| 144 | + xmls << xml_serv |
| 145 | + xmls << xml_datasrc |
| 146 | + |
| 147 | + it "Parse returns results for all good xmls and passwords" do |
| 148 | + xmls.each do |xml| |
| 149 | + results = GPP.parse(xml) |
| 150 | + results.should_not be_empty |
| 151 | + results[0][:PASS].should_not be_empty |
| 152 | + end |
| 153 | + end |
| 154 | + |
| 155 | + ## |
| 156 | + # Create_Tables |
| 157 | + ## |
| 158 | + it "Create_tables returns tables for all good xmls" do |
| 159 | + xmls.each do |xml| |
| 160 | + results = GPP.parse(xml) |
| 161 | + tables = GPP.create_tables(results, "test") |
| 162 | + tables.should_not be_empty |
| 163 | + end |
| 164 | + end |
150 | 165 | end
|
0 commit comments