@apocaliss92/scrypted-reolink-native 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -1,178 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Simple script to find BCUDP packets in pcapng files by searching for magic numbers.
4
- This doesn't parse the full pcapng format, just searches for BCUDP magic bytes.
5
- """
6
- import sys
7
- import struct
8
-
9
- BCUDP_MAGIC_DISCOVERY = b'\x3a\xcf\x87\x2a'
10
- BCUDP_MAGIC_DATA = b'\x10\xcf\x87\x2a'
11
- BCUDP_MAGIC_ACK = b'\x20\xcf\x87\x2a'
12
-
13
- def find_bcudp_packets(filename):
14
- """Find BCUDP packets by searching for magic numbers."""
15
- with open(filename, 'rb') as f:
16
- data = f.read()
17
-
18
- packets = []
19
- offset = 0
20
-
21
- while True:
22
- # Search for any BCUDP magic
23
- found_discovery = data.find(BCUDP_MAGIC_DISCOVERY, offset)
24
- found_data = data.find(BCUDP_MAGIC_DATA, offset)
25
- found_ack = data.find(BCUDP_MAGIC_ACK, offset)
26
-
27
- positions = []
28
- if found_discovery >= 0:
29
- positions.append((found_discovery, 'discovery'))
30
- if found_data >= 0:
31
- positions.append((found_data, 'data'))
32
- if found_ack >= 0:
33
- positions.append((found_ack, 'ack'))
34
-
35
- if not positions:
36
- break
37
-
38
- # Get the earliest position
39
- positions.sort()
40
- pos, pkt_type = positions[0]
41
- offset = pos + 4
42
-
43
- # Extract packet info
44
- if pkt_type == 'data' and len(data) >= pos + 20:
45
- connection_id = struct.unpack('<i', data[pos+4:pos+8])[0]
46
- packet_id = struct.unpack('<I', data[pos+12:pos+16])[0]
47
- payload_len = struct.unpack('<I', data[pos+16:pos+20])[0]
48
- hex_data = data[pos:pos+40].hex()
49
- packets.append({
50
- 'type': 'data',
51
- 'offset': pos,
52
- 'connection_id': connection_id,
53
- 'packet_id': packet_id,
54
- 'payload_len': payload_len,
55
- 'hex': hex_data
56
- })
57
- elif pkt_type == 'ack' and len(data) >= pos + 28:
58
- connection_id = struct.unpack('<i', data[pos+4:pos+8])[0]
59
- group_id = struct.unpack('<I', data[pos+12:pos+16])[0]
60
- packet_id = struct.unpack('<I', data[pos+16:pos+20])[0]
61
- hex_data = data[pos:pos+56].hex()
62
- packets.append({
63
- 'type': 'ack',
64
- 'offset': pos,
65
- 'connection_id': connection_id,
66
- 'group_id': group_id,
67
- 'packet_id': packet_id,
68
- 'hex': hex_data
69
- })
70
- elif pkt_type == 'discovery':
71
- hex_data = data[pos:pos+100].hex()
72
- packets.append({
73
- 'type': 'discovery',
74
- 'offset': pos,
75
- 'hex': hex_data
76
- })
77
-
78
- return packets
79
-
80
- def main():
81
- if len(sys.argv) < 3:
82
- print("Usage: python3 simple_compare.py <neolink.pcapng> <scrypted.pcapng>")
83
- sys.exit(1)
84
-
85
- neolink_file = sys.argv[1]
86
- scrypted_file = sys.argv[2]
87
-
88
- print("Searching for BCUDP packets in neolink.pcapng...")
89
- neolink_packets = find_bcudp_packets(neolink_file)
90
-
91
- print("Searching for BCUDP packets in scrypted.pcapng...")
92
- scrypted_packets = find_bcudp_packets(scrypted_file)
93
-
94
- print(f"\n{'='*80}")
95
- print(f"NEOLINK: Found {len(neolink_packets)} BCUDP packets")
96
- print(f"{'='*80}")
97
-
98
- data_packets = [p for p in neolink_packets if p['type'] == 'data']
99
- ack_packets = [p for p in neolink_packets if p['type'] == 'ack']
100
- discovery_packets = [p for p in neolink_packets if p['type'] == 'discovery']
101
-
102
- print(f" Discovery: {len(discovery_packets)}")
103
- print(f" Data: {len(data_packets)}")
104
- print(f" ACK: {len(ack_packets)}")
105
-
106
- if data_packets:
107
- print(f"\nFirst DATA packet:")
108
- first_data = data_packets[0]
109
- print(f" conn={first_data['connection_id']}, pid={first_data['packet_id']}, len={first_data['payload_len']}")
110
- print(f" Hex: {first_data['hex']}")
111
- if len(data_packets) > 1:
112
- print(f"\nSecond DATA packet:")
113
- second_data = data_packets[1]
114
- print(f" conn={second_data['connection_id']}, pid={second_data['packet_id']}, len={second_data['payload_len']}")
115
- print(f" Hex: {second_data['hex']}")
116
-
117
- if ack_packets:
118
- print(f"\nFirst ACK packet:")
119
- first_ack = ack_packets[0]
120
- print(f" conn={first_ack['connection_id']}, pid={first_ack['packet_id']}, gid={first_ack['group_id']}")
121
- print(f" Hex: {first_ack['hex']}")
122
-
123
- print(f"\n{'='*80}")
124
- print(f"SCRYPTED: Found {len(scrypted_packets)} BCUDP packets")
125
- print(f"{'='*80}")
126
-
127
- scrypted_data_packets = [p for p in scrypted_packets if p['type'] == 'data']
128
- scrypted_ack_packets = [p for p in scrypted_packets if p['type'] == 'ack']
129
- scrypted_discovery_packets = [p for p in scrypted_packets if p['type'] == 'discovery']
130
-
131
- print(f" Discovery: {len(scrypted_discovery_packets)}")
132
- print(f" Data: {len(scrypted_data_packets)}")
133
- print(f" ACK: {len(scrypted_ack_packets)}")
134
-
135
- if scrypted_data_packets:
136
- print(f"\nFirst DATA packet:")
137
- first_data = scrypted_data_packets[0]
138
- print(f" conn={first_data['connection_id']}, pid={first_data['packet_id']}, len={first_data['payload_len']}")
139
- print(f" Hex: {first_data['hex']}")
140
- if len(scrypted_data_packets) > 1:
141
- print(f"\nSecond DATA packet:")
142
- second_data = scrypted_data_packets[1]
143
- print(f" conn={second_data['connection_id']}, pid={second_data['packet_id']}, len={second_data['payload_len']}")
144
- print(f" Hex: {second_data['hex']}")
145
-
146
- if scrypted_ack_packets:
147
- print(f"\nFirst ACK packet:")
148
- first_ack = scrypted_ack_packets[0]
149
- print(f" conn={first_ack['connection_id']}, pid={first_ack['packet_id']}, gid={first_ack['group_id']}")
150
- print(f" Hex: {first_ack['hex']}")
151
-
152
- # Compare first DATA packets
153
- print(f"\n{'='*80}")
154
- print("COMPARISON")
155
- print(f"{'='*80}")
156
-
157
- if data_packets and scrypted_data_packets:
158
- nl_first = data_packets[0]
159
- sc_first = scrypted_data_packets[0]
160
- print(f"\nFirst DATA packet comparison:")
161
- print(f" Neolink: conn={nl_first['connection_id']}, pid={nl_first['packet_id']}, len={nl_first['payload_len']}")
162
- print(f" Scrypted: conn={sc_first['connection_id']}, pid={sc_first['packet_id']}, len={sc_first['payload_len']}")
163
- print(f" Neolink hex: {nl_first['hex']}")
164
- print(f" Scrypted hex: {sc_first['hex']}")
165
-
166
- if nl_first['hex'] == sc_first['hex']:
167
- print(f" ✓ Packets are IDENTICAL")
168
- else:
169
- print(f" ⚠️ Packets are DIFFERENT")
170
- # Find first difference
171
- for i in range(0, min(len(nl_first['hex']), len(sc_first['hex'])), 2):
172
- if nl_first['hex'][i:i+2] != sc_first['hex'][i:i+2]:
173
- print(f" First difference at byte {i//2}: neolink={nl_first['hex'][i:i+2]}, scrypted={sc_first['hex'][i:i+2]}")
174
- break
175
-
176
- if __name__ == '__main__':
177
- main()
178
-