xbase-util 0.7.4__tar.gz → 0.7.6__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {xbase_util-0.7.4 → xbase_util-0.7.6}/PKG-INFO +1 -1
- {xbase_util-0.7.4 → xbase_util-0.7.6}/setup.py +1 -1
- xbase_util-0.7.6/test/test.py +36 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/packet_util.py +10 -18
- xbase_util-0.7.6/xbase_util/pcap_util.py +835 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/xbase_constant.py +8 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util.egg-info/PKG-INFO +1 -1
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util.egg-info/SOURCES.txt +1 -1
- xbase_util-0.7.4/xbase_util/pcap_util.py +0 -246
- xbase_util-0.7.4/xbase_util/segment.py +0 -170
- {xbase_util-0.7.4 → xbase_util-0.7.6}/README.md +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/setup.cfg +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/__init__.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/add_column_util.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/dangerous_util.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/db/__init__.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/db/bean/ConfigBean.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/db/bean/CurrentConfigBean.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/db/bean/FlowBean.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/db/bean/TaskTemplateBean.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/db/bean/__init__.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/db/dao/ConfigDao.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/db/dao/CurrentConfigDao.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/db/dao/FlowDao.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/db/dao/TaskTemplateDao.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/db/dao/__init__.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/db/initsqlite3.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/es_db_util.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/esreq.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/geo_util.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/handle_features_util.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util/xbase_util.py +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util.egg-info/dependency_links.txt +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util.egg-info/not-zip-safe +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util.egg-info/top_level.txt +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util_assets/GeoLite2-City.mmdb +0 -0
- {xbase_util-0.7.4 → xbase_util-0.7.6}/xbase_util_assets/arkimeparse.js +0 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
import copy
|
2
|
+
import gzip
|
3
|
+
import pickle
|
4
|
+
import re
|
5
|
+
import traceback
|
6
|
+
|
7
|
+
from xbase_util.packet_util import filter_visible_chars
|
8
|
+
from xbase_util.pcap_util import reassemble_tcp, reassemble_session
|
9
|
+
|
10
|
+
if __name__ == '__main__':
|
11
|
+
# req = EsReq("http://127.0.0.1:9200")
|
12
|
+
# exp=build_es_expression(size="1",
|
13
|
+
# start_time=None,
|
14
|
+
# end_time=None,
|
15
|
+
# arkime_expression='id == 250106-lKoC7T_SwbNAe4xDQQx7KTOd')
|
16
|
+
# session=req.search(body=exp,index="arkime_sessions3-*").json()['hits']['hits'][0]
|
17
|
+
# packetPos=session['_source']['packetPos']
|
18
|
+
# stream,packet_objs=process_session_id_disk_simple(id=session['_id'], node=session['_source']['node'],
|
19
|
+
# packet_pos=packetPos, esdb=EsDb(req, multiprocessing.Manager()),
|
20
|
+
# pcap_path_prefix="origin")
|
21
|
+
#
|
22
|
+
# with open('stream.pkl', 'wb') as f:
|
23
|
+
# pickle.dump(stream, f)
|
24
|
+
# with open('packet_objs.pkl', 'wb') as f:
|
25
|
+
# pickle.dump(packet_objs, f)
|
26
|
+
|
27
|
+
with open('stream.pkl', 'rb') as f:
|
28
|
+
stream = pickle.load(f)
|
29
|
+
with open('packet_objs.pkl', 'rb') as f:
|
30
|
+
packet_objs = pickle.load(f)
|
31
|
+
skey = f"10.28.7.16:54398"
|
32
|
+
reassemble_tcp_res = reassemble_tcp(packet_objs, skey)
|
33
|
+
all_packets = reassemble_session(reassemble_tcp_res, skey)
|
34
|
+
time_period = [( abs(item['res_time']-item['req_time'])) for item in
|
35
|
+
all_packets if item['res_time'] != 0 and item['req_time'] != 0]
|
36
|
+
print(all_packets)
|
@@ -1,11 +1,8 @@
|
|
1
1
|
import copy
|
2
2
|
import re
|
3
3
|
|
4
|
-
from scapy.layers.inet import TCP
|
5
|
-
from scapy.packet import Raw
|
6
|
-
|
7
4
|
from xbase_util.xbase_constant import plain_content_type_columns, packetKeyname, src_dst_header, statisticHeader, \
|
8
|
-
features_key, plain_body_columns
|
5
|
+
features_key, plain_body_columns, http_version_pattern, http_req_method_pattern, http_req_path_pattern, res_status_code_pattern
|
9
6
|
from xbase_util.xbase_util import firstOrZero
|
10
7
|
|
11
8
|
|
@@ -59,16 +56,11 @@ def get_all_columns(
|
|
59
56
|
return result_columns
|
60
57
|
|
61
58
|
|
62
|
-
req_pattern = re.compile(r"(GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH) \/[^\s]* HTTP\/\d\.\d[\s\S]*?\r\n\r\n",
|
63
|
-
|
64
|
-
res_pattern = re.compile(r"HTTP/\d\.\d \d{3}.*", re.DOTALL)
|
65
|
-
req_body_pattern = re.compile(
|
66
|
-
|
67
|
-
|
68
|
-
http_version = re.compile(r"HTTP\/(\d\.\d)")
|
69
|
-
http_req_method = re.compile(r"(GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH) \/[^\s]* HTTP\/\d\.\d")
|
70
|
-
http_req_path = re.compile(r"(?:GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH)\s+(\/[^\s]*)\s+HTTP\/\d\.\d")
|
71
|
-
res_status_code_pattern = re.compile(r"HTTP\/\d\.\d\s+(\d{3})\s+.*")
|
59
|
+
# req_pattern = re.compile(r"(GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH) \/[^\s]* HTTP\/\d\.\d[\s\S]*?\r\n\r\n",
|
60
|
+
# re.DOTALL)
|
61
|
+
# res_pattern = re.compile(r"HTTP/\d\.\d \d{3}.*", re.DOTALL)
|
62
|
+
# req_body_pattern = re.compile(
|
63
|
+
# r"(GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH) \/[^\s]* HTTP\/\d\.\d[\s\S]*?(?=HTTP/\d\.\d)", re.DOTALL)
|
72
64
|
|
73
65
|
def get_header_value(header_set, value):
|
74
66
|
result = [item for item in header_set if value in item]
|
@@ -92,10 +84,10 @@ def get_detail_by_package(publicField, req_header, req_body, res_header, res_bod
|
|
92
84
|
res_field["initRTT"] = firstOrZero(res_field.get("initRTT", 0))
|
93
85
|
res_field["length"] = firstOrZero(res_field.get("length", 0))
|
94
86
|
|
95
|
-
http_version_res =
|
87
|
+
http_version_res = http_version_pattern.findall(req_header)
|
96
88
|
res_field['http.clientVersion'] = http_version_res[0] if len(http_version_res) > 0 else ""
|
97
|
-
http_method =
|
98
|
-
http_path =
|
89
|
+
http_method = http_req_method_pattern.findall(req_header)
|
90
|
+
http_path = http_req_path_pattern.findall(req_header)
|
99
91
|
res_field['http.clientVersion'] = http_version_res[0] if len(http_version_res) > 0 else ""
|
100
92
|
res_field['http.method'] = http_method[0] if len(http_method) > 0 else ""
|
101
93
|
res_field['http.path'] = http_path[0] if len(http_path) > 0 else ""
|
@@ -112,7 +104,7 @@ def get_detail_by_package(publicField, req_header, req_body, res_header, res_bod
|
|
112
104
|
if content_type_is_plain(res_header):
|
113
105
|
res_field['plain_body_dst'] = res_body
|
114
106
|
|
115
|
-
http_server_version_res =
|
107
|
+
http_server_version_res = http_version_pattern.findall(res_header)
|
116
108
|
res_field['http.serverVersion'] = http_server_version_res[0] if len(http_server_version_res) > 0 else ""
|
117
109
|
|
118
110
|
status_code = res_status_code_pattern.findall(res_header)
|