multicast checker
1.0.0
研究項目
您使用腳本的風險由您自行承擔
該項目包含2個腳本:
這兩個腳本都相容於 python3 並使用 FFprobe 和 FFmpeg
使用前請先安裝:
您可以簡單地運行以下範例來查看它是如何運作的:
python3 multicast-checker.py --playlist playlist.m3u
其中playlist.m3u是一個 M3U 文件,其中列出了所有 UDP 頻道
M3U 檔案範例:
#EXTM3U
#EXTINF:2,Info channel #1
udp://@233.99.65.1:1234
#EXTINF:2,Info channel #2
udp://@233.99.65.2:5500
#EXTINF:2,Info channel #3
udp://@233.99.65.3:1234
#EXTINF:2,Info channel #4
udp://@233.99.65.4:5500
#EXTINF:2,Info channel #5
udp://@233.99.65.5:1234
該腳本將使用多線程掃描 playlist.m3u 中的所有 schannel 並傳回結果。
輸出範例:
[*] Email parameters are not defined.
[*] Run the script with -h parameter for the details.
[*] Channel Info channel #2 is not working
[*] Channel Info channel #4 is not working
[*] Channel Info channel #3 is not working
[*] Channel Info channel #5 is not working
[*] OK >>> Channel is working! >>> "Info channel #1" >>> No stream name found
[*] The following channel(s) are not working:
233.99.65.2:5500 - Info channel #2
233.99.65.4:5500 - Info channel #4
233.99.65.3:1234 - Info channel #3
233.99.65.5:1234 - Info channel #5
[*] Finished in 7.0 second(s)
python3 multicast-scanner.py --range 233.99.65.1/30
該腳本將使用多線程掃描給定的 UDP IP 範圍並傳回結果。如果找不到 service_name,則會擷取 10 秒樣本。
輸出範例:
[*] IP range to scan: 233.99.65.0/30
[*] IPs to scan: 4
[*] Ports to scan for each IP: 1
[*] List of the port(s) to scan: 1234
[*] Timeout for UDP stream reply: 5 sec(s)
[*] Timeout for stream data collection: 10 sec(s)
[*] Sample lenght in seconds: 60 sec(s)
[*] Totals:
[*] Total items to scan: 4
[*] Total number of /32 subnets to scan (# of threads): 4
[*] Total number of hosts for each subnet to scan: 1
[*] Estimated maximum time to complete the task: 50 seconds
[*] 0 day(s) 0 hour(s) 0 minute(s) 50 second(s)
[*] Found opened port 1234 for 233.99.65.1
[*] Scanning for 233.99.65.0/32 completed!
[*] Scanning for 233.99.65.2/32 completed!
[*] Scanning for 233.99.65.3/32 completed!
[*] !!! No channel name found for 233.99.65.1:1234 !!!
[*] !!! Channel added to the playlist. 233.99.65.1:1234 >>> 1 !!!
[*] Scanning for 233.99.65.1/32 completed!
[*] Recording the samples for unnamed channels...
[*] !!! Sample for 233.99.65.1:1234 captured !!!
[*] Finished in 14.0 second(s)
[*] 0.0 day(s) 0.0 hour(s) 0.0 minute(s) 14.0 second(s)
[*] Channels found: 1
[*] Resulting file: scan_results_range_233.99.65.0-30.m3u
腳本在 Linux (Ubuntu 20.04) 和 MacOS (Big Sur, 11.2.2) 上進行了測試
您可以使用以下命令找到腳本的所有參數:
python3 multicast-checker.py -h
--playlist "Playlist *.m3u file with UDP streams" required: True
--nic "network interface IP address with UDP stream" required: False default: '0.0.0.0'
--udp_timeout "Time to wait in seconds for the UPD port reply" required: False default: 5
--info_timeout "Time to wait in seconds for the stream's info" required: False default: 10
--smtp_server "SMTP server to send an email" required: False
--smtp_port "Port for SMTP server" required: False default: 25
--sender "email address for email sender" required: False
--receivers "emails of the receivers (space separated)" required: False
python3 multicast-scanner.py -h
--range "Range of IPs to scan." required: True
--size "Size of the subnets to divide." required: False default: '32'
--playlist "Playlist *.m3u file with UDP streams" required: False
--nic "network interface IP address with UDP stream" required: False default: '0.0.0.0'
--udp_timeout "Time to wait in seconds for the UPD port reply" required: False default: 5
--port "addtional UDP port to scan. Default: 1234" required: False default: '1234'
--sample_sec "Sample lenght in seconds" required: False default: 60
--info_timeout "Time to wait in seconds for the stream's info" required: False default: 10
--smtp_server "SMTP server to send an email" required: False
--smtp_port "Port for SMTP server" required: False default: 25
--sender "email address for email sender" required: False
--receivers "emails of the receivers (space separated)" required: False
multicast-checker.py專案是作為監控 ISP IPTV 網路並在頻道中斷時發送警報的工具而創建的。
multicast-scanner.py專案是作為一個工具創建的,用於發現 ISP 網路中所有可用的 IPTV 頻道。
請隨意評論/指責/建議進一步的發展
使用的數據:
該專案中的程式碼已獲得 MIT 許可