xbase-util 0.9.0__tar.gz → 0.9.1__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {xbase_util-0.9.0 → xbase_util-0.9.1}/PKG-INFO +1 -1
- {xbase_util-0.9.0 → xbase_util-0.9.1}/setup.py +1 -1
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/common_util.py +9 -9
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/pcap_util.py +7 -18
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/test.py +1 -1
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util.egg-info/PKG-INFO +1 -1
- {xbase_util-0.9.0 → xbase_util-0.9.1}/README.md +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/setup.cfg +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/__init__.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/add_column_util.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/dangerous_util.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/db/__init__.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/db/bean/ConfigBean.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/db/bean/CurrentConfigBean.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/db/bean/FlowBean.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/db/bean/TaskTemplateBean.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/db/bean/__init__.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/db/dao/ConfigDao.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/db/dao/CurrentConfigDao.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/db/dao/FlowDao.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/db/dao/TaskTemplateDao.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/db/dao/__init__.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/db/initsqlite3.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/es_db_util.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/esreq.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/geo_util.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/handle_features_util.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/packet_util.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util/xbase_constant.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util.egg-info/SOURCES.txt +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util.egg-info/dependency_links.txt +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util.egg-info/not-zip-safe +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util.egg-info/top_level.txt +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util_assets/GeoLite2-City.mmdb +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.1}/xbase_util_assets/arkimeparse.js +0 -0
@@ -26,7 +26,7 @@ def filter_visible_chars(data):
|
|
26
26
|
return ''.join(chr(b) for b in data if 32 <= b <= 126 or b in (9, 10, 13))
|
27
27
|
|
28
28
|
|
29
|
-
def parse_chunked_body(data: bytes,
|
29
|
+
def parse_chunked_body(data: bytes,session_id="none",skey='') -> bytes:
|
30
30
|
try:
|
31
31
|
body = b''
|
32
32
|
while True:
|
@@ -41,17 +41,17 @@ def parse_chunked_body(data: bytes, need_un_gzip=False,session_id="none") -> byt
|
|
41
41
|
chunk_end = chunk_start + chunk_size
|
42
42
|
body += data[chunk_start:chunk_end]
|
43
43
|
data = data[chunk_end + 2:]
|
44
|
-
if need_un_gzip:
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
else:
|
44
|
+
# if need_un_gzip:
|
45
|
+
# try:
|
46
|
+
# return gzip.decompress(body)
|
47
|
+
# except gzip.BadGzipFile:
|
48
|
+
# print(f"解压错误:{session_id}")
|
49
|
+
# return body
|
50
|
+
# else:
|
51
51
|
return body
|
52
52
|
except Exception as e:
|
53
53
|
traceback.print_exc()
|
54
|
-
print(f"其他错误:session:{session_id}")
|
54
|
+
print(f"其他错误:session:{skey} {session_id}")
|
55
55
|
return b''
|
56
56
|
|
57
57
|
|
@@ -274,7 +274,7 @@ def process_session_id_disk_simple(id, node, packet_pos, esdb, pcap_path_prefix)
|
|
274
274
|
return get_file_and_read_pos(id, file, pos_list)
|
275
275
|
|
276
276
|
|
277
|
-
def parse_body(data,session_id='none'):
|
277
|
+
def parse_body(data,skey='',session_id='none'):
|
278
278
|
if data.find(b"\r\n\r\n") != -1:
|
279
279
|
res = data.split(b"\r\n\r\n", 1)
|
280
280
|
header = res[0]
|
@@ -284,31 +284,25 @@ def parse_body(data,session_id='none'):
|
|
284
284
|
body = b''
|
285
285
|
chunked_pattern = pattern_chuncked.search(header)
|
286
286
|
gzip_pattern = pattern_gzip.search(header)
|
287
|
-
need_gzip = gzip_pattern and b'gzip' in gzip_pattern.group()
|
288
287
|
if chunked_pattern and b'chunked' in chunked_pattern.group():
|
289
|
-
body = parse_chunked_body(body,
|
290
|
-
|
288
|
+
body = parse_chunked_body(body,session_id=session_id,skey=skey)
|
289
|
+
if gzip_pattern and b'gzip' in gzip_pattern.group():
|
291
290
|
try:
|
292
291
|
body = gzip.decompress(body)
|
293
292
|
except:
|
294
|
-
print(f"解压失败:{session_id}")
|
295
|
-
|
296
|
-
result_body_str = filter_visible_chars(body)
|
297
|
-
return filter_visible_chars(header), result_body_str
|
293
|
+
print(f"解压失败:{skey} {session_id}")
|
294
|
+
return filter_visible_chars(header), filter_visible_chars(body)
|
298
295
|
|
299
296
|
|
300
297
|
def reassemble_session_pcap(reassemble_tcp_res, skey, session_id='none'):
|
301
298
|
my_map = None # 初始化为 None
|
302
299
|
packet_list = []
|
303
300
|
for packet in reassemble_tcp_res:
|
304
|
-
header, body = parse_body(packet['data'], session_id=session_id)
|
301
|
+
header, body = parse_body(packet['data'],skey=skey, session_id=session_id)
|
305
302
|
# 如果当前数据包是请求
|
306
303
|
if packet['key'] == skey:
|
307
|
-
# 如果 my_map 已经存在(即已经有一个未完成的请求-响应对),先将其添加到 packet_list
|
308
304
|
if my_map is not None:
|
309
305
|
packet_list.append(copy.deepcopy(my_map))
|
310
|
-
|
311
|
-
# 初始化一个新的 my_map,并填充请求数据
|
312
306
|
my_map = {
|
313
307
|
'key': packet['key'],
|
314
308
|
'req_header': header,
|
@@ -320,19 +314,14 @@ def reassemble_session_pcap(reassemble_tcp_res, skey, session_id='none'):
|
|
320
314
|
'res_time': 0,
|
321
315
|
'res_size': 0,
|
322
316
|
}
|
323
|
-
# 如果当前数据包是响应
|
324
317
|
else:
|
325
|
-
# 如果 my_map 存在(即已经有一个请求),则填充响应数据
|
326
318
|
if my_map is not None:
|
327
319
|
my_map['res_header'] = header
|
328
320
|
my_map['res_body'] = body
|
329
321
|
my_map['res_time'] = packet['ts']
|
330
322
|
my_map['res_size'] = len(packet['data'])
|
331
|
-
|
332
|
-
# 将完整的请求-响应对添加到 packet_list
|
333
323
|
packet_list.append(copy.deepcopy(my_map))
|
334
|
-
my_map = None
|
335
|
-
# 如果最后一个 my_map 未完成(只有请求没有响应),也将其添加到 packet_list
|
324
|
+
my_map = None
|
336
325
|
if my_map is not None:
|
337
326
|
packet_list.append(copy.deepcopy(my_map))
|
338
327
|
return packet_list
|
@@ -4,6 +4,6 @@ from xbase_util.pcap_util import reassemble_tcp_pcap, reassemble_session_pcap
|
|
4
4
|
|
5
5
|
if __name__ == '__main__':
|
6
6
|
packets_scapy = reassemble_tcp_pcap(rdpcap("test.pcap"))
|
7
|
-
skey = '10.28.7.
|
7
|
+
skey = '10.28.7.6:53867'
|
8
8
|
all_packets = reassemble_session_pcap(packets_scapy, skey=skey,session_id='enn')
|
9
9
|
print(all_packets)
|
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
|