|
| 1 | +#!/usr/bin/env python2 |
| 2 | +# coding: utf-8 |
| 3 | + |
| 4 | +#-:-:-:-:-:-:-:-:-:-:-:-:# |
| 5 | +# TIDoS Framework # |
| 6 | +#-:-:-:-:-:-:-:-:-:-:-:-:# |
| 7 | + |
| 8 | +#Author: @_tID |
| 9 | +#This module requires TIDoS Framework |
| 10 | +#https://github.com/the-Infected-Drake/TIDoS-Framework |
| 11 | + |
| 12 | +import os |
| 13 | +import time |
| 14 | +import requests |
| 15 | +from colors import * |
| 16 | +from requests.packages.urllib3.exceptions import InsecureRequestWarning |
| 17 | + |
| 18 | +requests.packages.urllib3.disable_warnings(InsecureRequestWarning) |
| 19 | + |
| 20 | +def getFile0x00(fi): |
| 21 | + |
| 22 | + global payloads |
| 23 | + payloads = [] |
| 24 | + print GR+' [*] Importing payloads...' |
| 25 | + time.sleep(0.7) |
| 26 | + with open(fi,'r') as payl: |
| 27 | + for pay in payl: |
| 28 | + c = pay.replace('\n','') |
| 29 | + payloads.append(c) |
| 30 | + print G+' [+] Loaded '+O+str(len(payloads))+G+' payloads...' |
| 31 | + |
| 32 | +def check0x00(web000, headers): |
| 33 | + |
| 34 | + errors = [ |
| 35 | + "supplied argument is not a valid ldap", |
| 36 | + "javax.naming.NameNotFoundException", |
| 37 | + "javax.naming.directory.InvalidSearchFilterException", |
| 38 | + "Invalid DN syntax", |
| 39 | + "LDAPException|com.sun.jndi.ldap", |
| 40 | + "Search: Bad search filter", |
| 41 | + "Protocol error occurred", |
| 42 | + "Size limit has exceeded", |
| 43 | + "The alias is invalid", |
| 44 | + "Module Products.LDAPMultiPlugins", |
| 45 | + "Object does not exist", |
| 46 | + "The syntax is invalid", |
| 47 | + "A constraint violation occurred", |
| 48 | + "An inappropriate matching occurred", |
| 49 | + "Unknown error occurred", |
| 50 | + "Unknown exception encountered", |
| 51 | + "The search filter is incorrect", |
| 52 | + "Local error occurred", |
| 53 | + "The search filter is invalid", |
| 54 | + "The search filter cannot be recognized", |
| 55 | + "IPWorksASP.LDAP" |
| 56 | + ] |
| 57 | + print GR+' [*] Starting enumeration...' |
| 58 | + time.sleep(0.7) |
| 59 | + for payload in payloads: |
| 60 | + gotcha = False |
| 61 | + print B+'\n [+] Using Payload : '+C+payload |
| 62 | + web0x00 = web000 + payload |
| 63 | + print O+' [+] Url : '+C+web0x00 |
| 64 | + print GR+' [*] Making the request...' |
| 65 | + try: |
| 66 | + req = requests.get(web0x00, headers=headers, allow_redirects=False, timeout=7, verify=False).text |
| 67 | + print O+' [!] Searching through error database...' |
| 68 | + for err in errors: |
| 69 | + if err.lower() in req.lower(): |
| 70 | + print G+' [+] Possible LDAP Injection Found : '+O+web0x00 |
| 71 | + gotcha=True |
| 72 | + print O+' [+] Response : ' |
| 73 | + print P+req |
| 74 | + else: |
| 75 | + pass |
| 76 | + |
| 77 | + if gotcha == False: |
| 78 | + print R+' [-] No error reflection found in response!' |
| 79 | + time.sleep(0.4) |
| 80 | + print R+' [-] Payload '+O+payload+R+' not working!' |
| 81 | + pass |
| 82 | + |
| 83 | + except Exception as e: |
| 84 | + print R+' [-] Query Exception : '+str(e) |
| 85 | + |
| 86 | +def ldap(web): |
| 87 | + |
| 88 | + print GR+' [*] Loading module...' |
| 89 | + time.sleep(0.5) |
| 90 | + print R+'\n =============================' |
| 91 | + print R+' L D A P I N J E C T I O N' |
| 92 | + print R+' =============================\n' |
| 93 | + try: |
| 94 | + web0 = raw_input(O+' [#] Parameter path to test (eg. /lmao.php?foo=bar) :> ') |
| 95 | + if "?" in web0 and '=' in web0: |
| 96 | + if web0.startswith('/'): |
| 97 | + m = raw_input(GR+'\n [!] Your path starts with "/".\n [#] Do you mean root directory? (Y/n) :> ') |
| 98 | + if m.lower() == 'y': |
| 99 | + web00 = web + web0 |
| 100 | + elif m.lower() == 'n': |
| 101 | + web00 = web + web0 |
| 102 | + else: |
| 103 | + print R+' [-] U mad?' |
| 104 | + else: |
| 105 | + web00 = web + '/' + web0 |
| 106 | + print B+' [+] Parameterised Url : '+C+web00 |
| 107 | + |
| 108 | + input_cookie = raw_input("\n [*] Enter cookies if needed (Enter if none) :> ") |
| 109 | + print GR+' [*] Setting headers...' |
| 110 | + time.sleep(0.6) |
| 111 | + gen_headers = {'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201', |
| 112 | + 'Accept-Language':'en-US;', |
| 113 | + 'Accept-Encoding': 'gzip, deflate', |
| 114 | + 'Accept': 'text/html,application/xhtml+xml,application/xml;', |
| 115 | + 'Connection':'close'} |
| 116 | + |
| 117 | + if(len(input_cookie) > 0): |
| 118 | + gen_headers['Cookie'] = input_cookie |
| 119 | + print O+' [#] Enter the payloads file '+R+'(Default: files/payload-db/ldap_payloads.lst)...' |
| 120 | + fi = raw_input(O+' [#] Your input (Press Enter for default) :> ') |
| 121 | + if fi == '': |
| 122 | + fi = 'files/payload-db/ldap_payloads.lst' |
| 123 | + getFile0x00(fi) |
| 124 | + else: |
| 125 | + if os.path.exists(fi) == True: |
| 126 | + print G+' [+] File under '+fi+' found!' |
| 127 | + getFile0x00(fi) |
| 128 | + else: |
| 129 | + print R+' [-] Invalid input... Using default...' |
| 130 | + fi = 'files/payload-db/ldap_payloads.lst' |
| 131 | + getFile0x00(fi) |
| 132 | + print O+' [!] Parsing url...' |
| 133 | + time.sleep(0.7) |
| 134 | + web000 = web00.split('=')[0] + '=' |
| 135 | + check0x00(web000, gen_headers) |
| 136 | + |
| 137 | + except KeyboardInterrupt: |
| 138 | + print R+' [-] Aborting module...' |
| 139 | + pass |
| 140 | + except Exception as e: |
| 141 | + print R+' [-] Exception : '+str(e) |
| 142 | + print G+'\n [+] LDAP Injection module completed!\n' |
| 143 | + |
0 commit comments