xbase-util 0.9.0__tar.gz → 0.9.2__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.2}/PKG-INFO +1 -1
- {xbase_util-0.9.0 → xbase_util-0.9.2}/setup.py +1 -1
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/common_util.py +2 -2
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/pcap_util.py +13 -23
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/test.py +2 -2
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util.egg-info/PKG-INFO +1 -1
- {xbase_util-0.9.0 → xbase_util-0.9.2}/README.md +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/setup.cfg +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/__init__.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/add_column_util.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/dangerous_util.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/db/__init__.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/db/bean/ConfigBean.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/db/bean/CurrentConfigBean.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/db/bean/FlowBean.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/db/bean/TaskTemplateBean.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/db/bean/__init__.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/db/dao/ConfigDao.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/db/dao/CurrentConfigDao.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/db/dao/FlowDao.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/db/dao/TaskTemplateDao.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/db/dao/__init__.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/db/initsqlite3.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/es_db_util.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/esreq.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/geo_util.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/handle_features_util.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/packet_util.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util/xbase_constant.py +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util.egg-info/SOURCES.txt +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util.egg-info/dependency_links.txt +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util.egg-info/not-zip-safe +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util.egg-info/top_level.txt +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/xbase_util_assets/GeoLite2-City.mmdb +0 -0
- {xbase_util-0.9.0 → xbase_util-0.9.2}/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,need_un_gzip=False,session_id="none",skey='') -> bytes:
|
30
30
|
try:
|
31
31
|
body = b''
|
32
32
|
while True:
|
@@ -51,7 +51,7 @@ def parse_chunked_body(data: bytes, need_un_gzip=False,session_id="none") -> byt
|
|
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
|
|
@@ -4,6 +4,7 @@ import math
|
|
4
4
|
import os
|
5
5
|
import struct
|
6
6
|
import time
|
7
|
+
import traceback
|
7
8
|
import zlib
|
8
9
|
from functools import cmp_to_key
|
9
10
|
|
@@ -274,7 +275,7 @@ def process_session_id_disk_simple(id, node, packet_pos, esdb, pcap_path_prefix)
|
|
274
275
|
return get_file_and_read_pos(id, file, pos_list)
|
275
276
|
|
276
277
|
|
277
|
-
def parse_body(data,session_id='none'):
|
278
|
+
def parse_body(data, skey='', session_id='none'):
|
278
279
|
if data.find(b"\r\n\r\n") != -1:
|
279
280
|
res = data.split(b"\r\n\r\n", 1)
|
280
281
|
header = res[0]
|
@@ -284,31 +285,27 @@ def parse_body(data,session_id='none'):
|
|
284
285
|
body = b''
|
285
286
|
chunked_pattern = pattern_chuncked.search(header)
|
286
287
|
gzip_pattern = pattern_gzip.search(header)
|
287
|
-
|
288
|
+
need_unzip = gzip_pattern and b'gzip' in gzip_pattern.group()
|
288
289
|
if chunked_pattern and b'chunked' in chunked_pattern.group():
|
289
|
-
body = parse_chunked_body(body, need_un_gzip=
|
290
|
-
elif
|
290
|
+
body = parse_chunked_body(body, need_un_gzip=need_unzip, session_id=session_id, skey=skey)
|
291
|
+
elif need_unzip:
|
291
292
|
try:
|
292
293
|
body = gzip.decompress(body)
|
293
|
-
except:
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
return filter_visible_chars(header),
|
294
|
+
except Exception as e:
|
295
|
+
traceback.print_exc()
|
296
|
+
print(f"解压失败:{skey} {session_id}")
|
297
|
+
body = b''
|
298
|
+
return filter_visible_chars(header), filter_visible_chars(body)
|
298
299
|
|
299
300
|
|
300
301
|
def reassemble_session_pcap(reassemble_tcp_res, skey, session_id='none'):
|
301
|
-
my_map = None
|
302
|
+
my_map = None
|
302
303
|
packet_list = []
|
303
304
|
for packet in reassemble_tcp_res:
|
304
|
-
header, body = parse_body(packet['data'], session_id=session_id)
|
305
|
-
# 如果当前数据包是请求
|
305
|
+
header, body = parse_body(packet['data'], skey=skey, session_id=session_id)
|
306
306
|
if packet['key'] == skey:
|
307
|
-
# 如果 my_map 已经存在(即已经有一个未完成的请求-响应对),先将其添加到 packet_list
|
308
307
|
if my_map is not None:
|
309
308
|
packet_list.append(copy.deepcopy(my_map))
|
310
|
-
|
311
|
-
# 初始化一个新的 my_map,并填充请求数据
|
312
309
|
my_map = {
|
313
310
|
'key': packet['key'],
|
314
311
|
'req_header': header,
|
@@ -320,19 +317,14 @@ def reassemble_session_pcap(reassemble_tcp_res, skey, session_id='none'):
|
|
320
317
|
'res_time': 0,
|
321
318
|
'res_size': 0,
|
322
319
|
}
|
323
|
-
# 如果当前数据包是响应
|
324
320
|
else:
|
325
|
-
# 如果 my_map 存在(即已经有一个请求),则填充响应数据
|
326
321
|
if my_map is not None:
|
327
322
|
my_map['res_header'] = header
|
328
323
|
my_map['res_body'] = body
|
329
324
|
my_map['res_time'] = packet['ts']
|
330
325
|
my_map['res_size'] = len(packet['data'])
|
331
|
-
|
332
|
-
# 将完整的请求-响应对添加到 packet_list
|
333
326
|
packet_list.append(copy.deepcopy(my_map))
|
334
|
-
my_map = None
|
335
|
-
# 如果最后一个 my_map 未完成(只有请求没有响应),也将其添加到 packet_list
|
327
|
+
my_map = None
|
336
328
|
if my_map is not None:
|
337
329
|
packet_list.append(copy.deepcopy(my_map))
|
338
330
|
return packet_list
|
@@ -411,8 +403,6 @@ def reassemble_tcp_pcap(p):
|
|
411
403
|
return a_ack - (b_seq + len(b_data) - 1)
|
412
404
|
|
413
405
|
packets2.sort(key=cmp_to_key(compare_packets))
|
414
|
-
# del packets[num_packets:]
|
415
|
-
# Now divide up conversation
|
416
406
|
clientSeq = 0
|
417
407
|
hostSeq = 0
|
418
408
|
previous = 0
|
@@ -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.
|
8
|
-
all_packets = reassemble_session_pcap(packets_scapy, skey=skey,session_id='
|
7
|
+
skey = '10.28.7.6:53867'
|
8
|
+
all_packets = reassemble_session_pcap(packets_scapy, skey=skey,session_id='emmmmm')
|
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
|