xbase-util 0.8.8__tar.gz → 0.8.9__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {xbase_util-0.8.8 → xbase_util-0.8.9}/PKG-INFO +1 -1
- {xbase_util-0.8.8 → xbase_util-0.8.9}/setup.py +1 -1
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/common_util.py +1 -1
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/pcap_util.py +35 -35
- xbase_util-0.8.9/xbase_util/test.py +11 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util.egg-info/PKG-INFO +1 -1
- xbase_util-0.8.8/xbase_util/test.py +0 -15
- {xbase_util-0.8.8 → xbase_util-0.8.9}/README.md +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/setup.cfg +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/__init__.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/add_column_util.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/dangerous_util.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/db/__init__.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/db/bean/ConfigBean.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/db/bean/CurrentConfigBean.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/db/bean/FlowBean.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/db/bean/TaskTemplateBean.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/db/bean/__init__.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/db/dao/ConfigDao.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/db/dao/CurrentConfigDao.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/db/dao/FlowDao.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/db/dao/TaskTemplateDao.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/db/dao/__init__.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/db/initsqlite3.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/es_db_util.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/esreq.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/geo_util.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/handle_features_util.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/packet_util.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util/xbase_constant.py +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util.egg-info/SOURCES.txt +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util.egg-info/dependency_links.txt +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util.egg-info/not-zip-safe +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util.egg-info/top_level.txt +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util_assets/GeoLite2-City.mmdb +0 -0
- {xbase_util-0.8.8 → xbase_util-0.8.9}/xbase_util_assets/arkimeparse.js +0 -0
@@ -297,46 +297,46 @@ def parse_body(data,session_id='none'):
|
|
297
297
|
return filter_visible_chars(header), result_body_str
|
298
298
|
|
299
299
|
|
300
|
-
def reassemble_session_pcap(reassemble_tcp_res, skey,session_id='none'):
|
301
|
-
my_map =
|
302
|
-
'key': '',
|
303
|
-
'req_header': '',
|
304
|
-
'req_body': '',
|
305
|
-
'req_time': 0,
|
306
|
-
'req_size': 0,
|
307
|
-
'res_header': '',
|
308
|
-
'res_body': '',
|
309
|
-
'res_time': 0,
|
310
|
-
'res_size': 0,
|
311
|
-
}
|
300
|
+
def reassemble_session_pcap(reassemble_tcp_res, skey, session_id='none'):
|
301
|
+
my_map = None # 初始化为 None
|
312
302
|
packet_list = []
|
313
|
-
|
303
|
+
|
304
|
+
for packet in reassemble_tcp_res:
|
314
305
|
header, body = parse_body(packet['data'], session_id=session_id)
|
315
|
-
|
316
|
-
|
306
|
+
|
307
|
+
# 如果当前数据包是请求
|
317
308
|
if packet['key'] == skey:
|
318
|
-
|
309
|
+
# 如果 my_map 已经存在(即已经有一个未完成的请求-响应对),先将其添加到 packet_list
|
310
|
+
if my_map is not None:
|
319
311
|
packet_list.append(copy.deepcopy(my_map))
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
my_map["req_size"] = len(packet['data'])
|
312
|
+
|
313
|
+
# 初始化一个新的 my_map,并填充请求数据
|
314
|
+
my_map = {
|
315
|
+
'key': packet['key'],
|
316
|
+
'req_header': header,
|
317
|
+
'req_body': body,
|
318
|
+
'req_time': packet['ts'],
|
319
|
+
'req_size': len(packet['data']),
|
320
|
+
'res_header': '',
|
321
|
+
'res_body': b'',
|
322
|
+
'res_time': 0,
|
323
|
+
'res_size': 0,
|
324
|
+
}
|
325
|
+
# 如果当前数据包是响应
|
335
326
|
else:
|
336
|
-
my_map
|
337
|
-
my_map
|
338
|
-
|
339
|
-
|
327
|
+
# 如果 my_map 存在(即已经有一个请求),则填充响应数据
|
328
|
+
if my_map is not None:
|
329
|
+
my_map['res_header'] = header
|
330
|
+
my_map['res_body'] = body
|
331
|
+
my_map['res_time'] = packet['ts']
|
332
|
+
my_map['res_size'] = len(packet['data'])
|
333
|
+
|
334
|
+
# 将完整的请求-响应对添加到 packet_list
|
335
|
+
packet_list.append(copy.deepcopy(my_map))
|
336
|
+
my_map = None # 重置 my_map
|
337
|
+
# 如果最后一个 my_map 未完成(只有请求没有响应),也将其添加到 packet_list
|
338
|
+
if my_map is not None:
|
339
|
+
packet_list.append(copy.deepcopy(my_map))
|
340
340
|
return packet_list
|
341
341
|
|
342
342
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
from scapy.packet import Raw
|
2
|
+
from scapy.utils import rdpcap
|
3
|
+
|
4
|
+
from xbase_util.pcap_util import reassemble_tcp_pcap, reassemble_session_pcap
|
5
|
+
|
6
|
+
if __name__ == '__main__':
|
7
|
+
packets_scapy = reassemble_tcp_pcap(rdpcap("test.pcap"))
|
8
|
+
skey = '10.28.7.1:57266'
|
9
|
+
all_packets = reassemble_session_pcap(packets_scapy, skey=skey,session_id='enn')
|
10
|
+
|
11
|
+
print(all_packets)
|
@@ -1,15 +0,0 @@
|
|
1
|
-
from scapy.packet import Raw
|
2
|
-
from scapy.utils import rdpcap
|
3
|
-
|
4
|
-
from xbase_util.pcap_util import reassemble_tcp_pcap, reassemble_session_pcap
|
5
|
-
|
6
|
-
if __name__ == '__main__':
|
7
|
-
packets_scapy = reassemble_tcp_pcap(rdpcap("gzip2.pcap"))
|
8
|
-
skey = '10.28.7.16:54398'
|
9
|
-
streams = b""
|
10
|
-
for pkt in packets_scapy:
|
11
|
-
if Raw in pkt:
|
12
|
-
streams += pkt[Raw].load
|
13
|
-
text_data = streams.decode('ascii', errors='ignore')
|
14
|
-
all_packets = reassemble_session_pcap(packets_scapy, skey=skey,session_id='enn')
|
15
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|