IPTV抓包简易教程

1.使用Openwrt抓包

网络结构

graph LR
C(光猫)
C --> D(op路由器)
D --> E(电视盒子)

1.1 Openwrt 安装 Tcpdump

1
2
opkg update
opkg install tcpdump

1.2 Wireshark使用ssh抓包

选项拉到底,直接选择ssh dump抓包即可

  • 如下图,填写完ip端口,然后用户和密码填写后即可直接开始抓包了
    pZxtCSf.png

    抓包过程
    pZxtPl8.png

2.抓包

电视盒子开始开机,然后把所有的节目直播切换一遍,然后直接在Wireshark结束抓包然后保存,进行本地分析

3.抓包数据分析

3.1选择导出http对象

pZxtap6.jpg

3.2过滤出list,选择内容类型为text/html的进行保存

pZxtNfx.png

4.处理并生成直播源

4.1 使用python进行处理上一步保存的文件

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
import re

def extract_channel_info_and_generate_files():
# 定义输入输出文件路径
input_file = "getchannellistHWCU.jsp"
m3u_output_file = "index2.m3u"
txt_output_file = "channel_list.txt" # 新增txt输出文件

# 定义正则表达式,匹配ChannelName、UserChannelID、ChannelURL的内容
pattern = r'ChannelName="([^"]+)",UserChannelID="\d+",ChannelURL="igmp://([^"]+)"'

try:
# 以文本模式读取jsp文件
with open(input_file, 'r', encoding='utf-8') as f:
content = f.read()

# 查找所有匹配的频道信息
matches = re.findall(pattern, content)

if not matches:
print("未找到任何频道信息,请检查文件内容或正则表达式!")
return

# ========== 生成m3u文件 ==========
with open(m3u_output_file, 'w', encoding='utf-8') as f_m3u:
# 写入m3u文件头
f_m3u.write("#EXTM3U\n")

# 遍历每个匹配结果,按格式写入
for channel_name, ip_port in matches:
extinf_line = f"#EXTINF:-1,{channel_name}\n"
url_line = f"http://192.168.6.1:4022/udp/{ip_port}\n"
f_m3u.write(extinf_line)
f_m3u.write(url_line)

# ========== 生成txt文件 ==========
with open(txt_output_file, 'w', encoding='utf-8') as f_txt:
for channel_name, ip_port in matches:
# 拼接txt格式的行:频道名,完整URL
full_url = f"http://192.168.6.1:4022/udp/{ip_port}"
txt_line = f"{channel_name},{full_url}\n"
f_txt.write(txt_line)

print(f"处理完成!共提取到 {len(matches)} 个频道信息")
print(f"- M3U文件已保存至:{m3u_output_file}")
print(f"- TXT文件已保存至:{txt_output_file}")

except FileNotFoundError:
print(f"错误:未找到文件 {input_file},请检查文件路径是否正确!")
except Exception as e:
print(f"处理过程中出现错误:{str(e)}")

# 执行函数
if __name__ == "__main__":
extract_channel_info_and_generate_files()

4.2将处理后得到的m3u文件和txt文件上传到码云等平台即可

5.op开启udpxy

5.1安装udpxy

直接在op web管理面板下载即可

5.2开启udpxy

pZxtfc8.md.png

6.电视使用

李宅自用IPTV软件

直接在设置中的节目单中填写第四步txt文件的链接即可

7.电脑和手机

使用vlc播放第四步得到的m3u文件即可