-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsonder.py
121 lines (114 loc) · 4.33 KB
/
sonder.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
import subprocess
import sys
from termcolor import colored
# Function to print the rainbow banner
def print_banner():
banner = """
██████ ▒█████ ███▄ █ ▓█████▄ ▓█████ ██▀███
▒██ ▒ ▒██▒ ██▒ ██ ▀█ █ ▒██▀ ██▌▓█ ▀ ▓██ ▒ ██▒
░ ▓██▄ ▒██░ ██▒▓██ ▀█ ██▒░██ █▌▒███ ▓██ ░▄█ ▒
▒ ██▒▒██ ██░▓██▒ ▐▌██▒░▓█▄ ▌▒▓█ ▄ ▒██▀▀█▄
▒██████▒▒░ ████▓▒░▒██░ ▓██░░▒████▓ ░▒████▒░██▓ ▒██▒
▒ ▒▓▒ ▒ ░░ ▒░▒░▒░ ░ ▒░ ▒ ▒ ▒▒▓ ▒ ░░ ▒░ ░░ ▒▓ ░▒▓░
░ ░▒ ░ ░ ░ ▒ ▒░ ░ ░░ ░ ▒░ ░ ▒ ▒ ░ ░ ░ ░▒ ░ ▒░
░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░░ ░
░ ░ ░ ░ ░ ░ ░ ░
"""
version_author = "Version: 1.0.0 | Author: H3CATE"
quote = "\"Hack the Planet\""
colors = ['red', 'yellow', 'green', 'cyan', 'blue', 'magenta']
for i, line in enumerate(banner.split('\n')):
print(colored(line, colors[i % len(colors)]))
print(colored(version_author, 'white'))
print(colored(quote, 'white'))
print()
# Liste des chemins de flux RTSP courants (étendue)
common_paths = [
"/stream1",
"/stream2",
"/video1",
"/video2",
"/live.sdp",
"/cam1/mpeg4",
"/cam1/h264",
"/0",
"/1",
"/1.avi",
"/2.avi",
"/3.avi",
"/4.avi",
"/live/ch00_0",
"/ch1/main/av_stream",
"/ch1/sub/av_stream",
"/axis-media/media.amp",
"/h264",
"/h264.sdp",
"/mpeg4",
"/mpeg4.sdp",
"/mp4",
"/mp4.sdp",
"/live",
"/live.sdp",
"/streaming/channels/1",
"/streaming/channels/2",
"/streaming/channels/101",
"/streaming/channels/102",
"/streaming/channels/201",
"/streaming/channels/202",
"/onvif1",
"/onvif2",
"/onvif/profile2/media.smp",
"/media.smp",
"/media/video1",
"/media/video2",
"/media/video3",
"/media/video4",
"/media/video5",
"/media/video6",
"/videoMain",
"/videoSub",
"/cam/realmonitor",
"/live1.sdp",
"/live2.sdp",
"/live3.sdp",
"/live4.sdp",
"/live5.sdp"
]
# Fonction pour tester les URL de flux RTSP courantes avec un timeout
def test_rtsp_stream(ip_port):
for path in common_paths:
rtsp_url = f"rtsp://{ip_port}{path}"
print(colored(f"Testing: {rtsp_url}", 'cyan'))
sys.stdout.flush() # Ensure proper flushing of output before progress bar update
try:
result = subprocess.run(
["ffmpeg", "-rtsp_transport", "tcp", "-t", "5", "-i", rtsp_url, "-f", "null", "-"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
timeout=30
)
stderr_output = result.stderr.decode('utf-8')
print() # Add a line between the ongoing test and result
if result.returncode == 0:
print(colored("#########################################", 'green'))
print(colored("# Success #", 'green'))
print(colored("#########################################", 'green'))
# Ouvrir le flux avec ffplay avec des paramètres supplémentaires
subprocess.Popen(["ffplay", "-rtsp_transport", "tcp", "-analyzeduration", "1000000000", "-probesize", "500000000", rtsp_url])
return True
else:
print(colored(f"Failed: {stderr_output.splitlines()[-1]}", 'red'))
except subprocess.TimeoutExpired:
print(colored("Timeout", 'yellow'))
print(colored(f"No valid stream found for {ip_port}.", 'red'))
return False
if __name__ == "__main__":
print_banner()
if len(sys.argv) < 2 or len(sys.argv) > 3:
print(f"Usage: {sys.argv[0]} <ip> [port]")
sys.exit(1)
ip = sys.argv[1]
port = sys.argv[2] if len(sys.argv) == 3 else "554"
ip_port = f"{ip}:{port}"
# Test des flux RTSP pour l'IP fournie
test_rtsp_stream(ip_port)