xbase-util 0.9.1__tar.gz → 0.9.3__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {xbase_util-0.9.1 → xbase_util-0.9.3}/PKG-INFO +1 -1
- {xbase_util-0.9.1 → xbase_util-0.9.3}/setup.py +1 -1
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/common_util.py +8 -8
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/pcap_util.py +11 -12
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/test.py +3 -3
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util.egg-info/PKG-INFO +1 -1
- {xbase_util-0.9.1 → xbase_util-0.9.3}/README.md +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/setup.cfg +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/__init__.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/add_column_util.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/dangerous_util.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/db/__init__.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/db/bean/ConfigBean.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/db/bean/CurrentConfigBean.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/db/bean/FlowBean.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/db/bean/TaskTemplateBean.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/db/bean/__init__.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/db/dao/ConfigDao.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/db/dao/CurrentConfigDao.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/db/dao/FlowDao.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/db/dao/TaskTemplateDao.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/db/dao/__init__.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/db/initsqlite3.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/es_db_util.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/esreq.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/geo_util.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/handle_features_util.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/packet_util.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util/xbase_constant.py +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util.egg-info/SOURCES.txt +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util.egg-info/dependency_links.txt +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util.egg-info/not-zip-safe +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util.egg-info/top_level.txt +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/xbase_util_assets/GeoLite2-City.mmdb +0 -0
- {xbase_util-0.9.1 → xbase_util-0.9.3}/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,session_id="none",skey='') -> 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:
|
@@ -41,13 +41,13 @@ def parse_chunked_body(data: bytes,session_id="none",skey='') -> bytes:
|
|
41
41
|
chunk_end = chunk_start + chunk_size
|
42
42
|
body += data[chunk_start:chunk_end]
|
43
43
|
data = data[chunk_end + 2:]
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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()
|
@@ -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
|
|
@@ -246,9 +247,7 @@ def get_file_and_read_pos(session_id, file, pos_list):
|
|
246
247
|
packets[i] = packet_bytes
|
247
248
|
while next_packet in packets:
|
248
249
|
buffer = packets[next_packet]
|
249
|
-
|
250
|
-
next_packet += 1
|
251
|
-
# del packets[next_packet]
|
250
|
+
del packets[next_packet]
|
252
251
|
next_packet = next_packet + 1
|
253
252
|
if b_offset + len(buffer) > len(byte_array):
|
254
253
|
res.extend(byte_array[:b_offset])
|
@@ -274,7 +273,7 @@ def process_session_id_disk_simple(id, node, packet_pos, esdb, pcap_path_prefix)
|
|
274
273
|
return get_file_and_read_pos(id, file, pos_list)
|
275
274
|
|
276
275
|
|
277
|
-
def parse_body(data,skey='',session_id='none'):
|
276
|
+
def parse_body(data, skey='', session_id='none'):
|
278
277
|
if data.find(b"\r\n\r\n") != -1:
|
279
278
|
res = data.split(b"\r\n\r\n", 1)
|
280
279
|
header = res[0]
|
@@ -284,22 +283,24 @@ def parse_body(data,skey='',session_id='none'):
|
|
284
283
|
body = b''
|
285
284
|
chunked_pattern = pattern_chuncked.search(header)
|
286
285
|
gzip_pattern = pattern_gzip.search(header)
|
286
|
+
need_unzip = gzip_pattern and b'gzip' in gzip_pattern.group()
|
287
287
|
if chunked_pattern and b'chunked' in chunked_pattern.group():
|
288
|
-
body = parse_chunked_body(body,session_id=session_id,skey=skey)
|
289
|
-
|
288
|
+
body = parse_chunked_body(body, need_un_gzip=need_unzip, session_id=session_id, skey=skey)
|
289
|
+
elif need_unzip:
|
290
290
|
try:
|
291
291
|
body = gzip.decompress(body)
|
292
|
-
except:
|
292
|
+
except Exception as e:
|
293
|
+
traceback.print_exc()
|
293
294
|
print(f"解压失败:{skey} {session_id}")
|
295
|
+
body = b''
|
294
296
|
return filter_visible_chars(header), filter_visible_chars(body)
|
295
297
|
|
296
298
|
|
297
299
|
def reassemble_session_pcap(reassemble_tcp_res, skey, session_id='none'):
|
298
|
-
my_map = None
|
300
|
+
my_map = None
|
299
301
|
packet_list = []
|
300
302
|
for packet in reassemble_tcp_res:
|
301
|
-
header, body = parse_body(packet['data'],skey=skey, session_id=session_id)
|
302
|
-
# 如果当前数据包是请求
|
303
|
+
header, body = parse_body(packet['data'], skey=skey, session_id=session_id)
|
303
304
|
if packet['key'] == skey:
|
304
305
|
if my_map is not None:
|
305
306
|
packet_list.append(copy.deepcopy(my_map))
|
@@ -400,8 +401,6 @@ def reassemble_tcp_pcap(p):
|
|
400
401
|
return a_ack - (b_seq + len(b_data) - 1)
|
401
402
|
|
402
403
|
packets2.sort(key=cmp_to_key(compare_packets))
|
403
|
-
# del packets[num_packets:]
|
404
|
-
# Now divide up conversation
|
405
404
|
clientSeq = 0
|
406
405
|
hostSeq = 0
|
407
406
|
previous = 0
|
@@ -3,7 +3,7 @@ from scapy.utils import rdpcap
|
|
3
3
|
from xbase_util.pcap_util import reassemble_tcp_pcap, reassemble_session_pcap
|
4
4
|
|
5
5
|
if __name__ == '__main__':
|
6
|
-
packets_scapy = reassemble_tcp_pcap(rdpcap("
|
7
|
-
skey = '10.28.7.
|
8
|
-
all_packets = reassemble_session_pcap(packets_scapy, skey=skey,session_id='
|
6
|
+
packets_scapy = reassemble_tcp_pcap(rdpcap("test1.pcap"))
|
7
|
+
skey = '10.28.7.53:58598'
|
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
|