xbase-util 0.4.7__tar.gz → 0.4.9__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. {xbase_util-0.4.7 → xbase_util-0.4.9}/PKG-INFO +1 -1
  2. {xbase_util-0.4.7 → xbase_util-0.4.9}/setup.py +1 -1
  3. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/packet_util.py +14 -12
  4. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util.egg-info/PKG-INFO +1 -1
  5. {xbase_util-0.4.7 → xbase_util-0.4.9}/README.md +0 -0
  6. {xbase_util-0.4.7 → xbase_util-0.4.9}/setup.cfg +0 -0
  7. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/__init__.py +0 -0
  8. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/add_column_util.py +0 -0
  9. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/dangerous_util.py +0 -0
  10. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/db/__init__.py +0 -0
  11. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/db/bean/ConfigBean.py +0 -0
  12. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/db/bean/CurrentConfigBean.py +0 -0
  13. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/db/bean/FlowBean.py +0 -0
  14. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/db/bean/TaskTemplateBean.py +0 -0
  15. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/db/bean/__init__.py +0 -0
  16. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/db/dao/ConfigDao.py +0 -0
  17. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/db/dao/CurrentConfigDao.py +0 -0
  18. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/db/dao/FlowDao.py +0 -0
  19. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/db/dao/TaskTemplateDao.py +0 -0
  20. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/db/dao/__init__.py +0 -0
  21. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/db/initsqlite3.py +0 -0
  22. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/es_db_util.py +0 -0
  23. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/esreq.py +0 -0
  24. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/geo_util.py +0 -0
  25. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/handle_features_util.py +0 -0
  26. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/pcap_util.py +0 -0
  27. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/xbase_constant.py +0 -0
  28. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util/xbase_util.py +0 -0
  29. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util.egg-info/SOURCES.txt +0 -0
  30. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util.egg-info/dependency_links.txt +0 -0
  31. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util.egg-info/not-zip-safe +0 -0
  32. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util.egg-info/top_level.txt +0 -0
  33. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util_assets/GeoLite2-City.mmdb +0 -0
  34. {xbase_util-0.4.7 → xbase_util-0.4.9}/xbase_util_assets/arkimeparse.js +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xbase_util
3
- Version: 0.4.7
3
+ Version: 0.4.9
4
4
  Summary: 网络安全基础工具
5
5
  Home-page: https://gitee.com/jimonik/xbase_util.git
6
6
  Author: xyt
@@ -3,7 +3,7 @@ from distutils.core import setup
3
3
  from setuptools import find_packages
4
4
 
5
5
  setup(name="xbase_util",
6
- version="0.4.7",
6
+ version="0.4.9",
7
7
  description="网络安全基础工具",
8
8
  long_description="包含提取,预测,训练的基础工具",
9
9
  author="xyt",
@@ -59,12 +59,10 @@ def get_all_columns(
59
59
 
60
60
 
61
61
  def get_all_packets_by_reg(packets):
62
- req_pattern = re.compile(r"(GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH) \/[^\s]* HTTP\/\d\.\d[\s\S]*?\r\n\r\n",
63
- re.DOTALL)
62
+ req_pattern = re.compile(r"(GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH) \/[^\s]* HTTP\/\d\.\d[\s\S]*?\r\n\r\n",re.DOTALL)
64
63
  req_res_pattern = re.compile(
65
- r"(GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH) \/[^\s]* HTTP\/\d\.\d[\s\S]*?(?=HTTP/\d\.\d \d{3} [a-zA-Z]+|$)",
66
- re.DOTALL)
67
- res_pattern = re.compile(r"HTTP/\d\.\d \d{3} [a-zA-Z]+.*", re.DOTALL)
64
+ r"(GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH) \/[^\s]* HTTP\/\d\.\d[\s\S]*?(?=HTTP/\d\.\d \d{3} [a-zA-Z]+|$)",re.DOTALL)
65
+ res_pattern = re.compile(r"HTTP/\d\.\d \d{3} [a-zA-Z]+.*",re.DOTALL)
68
66
  tcp_packet_map = {}
69
67
  for packet in packets:
70
68
  if packet.haslayer(TCP) and packet.haslayer(Raw):
@@ -97,6 +95,7 @@ def get_all_packets_by_reg(packets):
97
95
  next_ack = f"{data_set['last_len'] + data_set['last_seq']}"
98
96
  packet_data = data_set['data']
99
97
  request_time = data_set['time']
98
+ response_time=[]
100
99
  req_len = len(packet_data)
101
100
  res_len = 0
102
101
  while True:
@@ -111,15 +110,18 @@ def get_all_packets_by_reg(packets):
111
110
  res_match = re.search(res_pattern, filter_visible_chars(new_packet['data']))
112
111
  if res_match is None:
113
112
  req_len += len(new_packet['data'])
113
+ request_time += new_packet['time']
114
114
  else:
115
115
  print("匹配到响应")
116
116
  res_len += len(new_packet['data'])
117
+ response_time += new_packet['time']
118
+
117
119
  # 判断新的包是不是第二个请求包
118
120
  if re.search(req_pattern, new_packet['data'].decode("utf-8", errors="ignore")):
119
121
  print("这个包是个新的请求包的开头,停止查找")
120
122
  break
121
123
  packet_data += new_packet['data']
122
- request_time += new_packet['time']
124
+ # request_time += new_packet['time']
123
125
  next_ack = f"{new_packet['last_len'] + new_packet['last_seq']}"
124
126
  map = {}
125
127
  data = filter_visible_chars(packet_data)
@@ -130,15 +132,15 @@ def get_all_packets_by_reg(packets):
130
132
  map['data'] = packet_data
131
133
  map['req_len'] = req_len
132
134
  map['res_len'] = res_len
133
- map['time'] = request_time
135
+ map['request_time'] = request_time
136
+ map['response_time'] = response_time
134
137
  map['req'] = match_req.group() if match_req is not None else ""
135
138
  map['res'] = match_res.group() if match_res is not None else ""
136
139
  packet_list.append(map)
137
140
  return packet_list
138
141
 
139
-
140
- def get_body(param, is_src):
141
- body = param.split("\r\n\r\n")[1].strip()
142
+ def get_body(param):
143
+ body = "".join([item.strip() for item in param.split("\r\n\r\n") if item.strip() != "" and "HTTP/" not in param])
142
144
  return "" if body is None else body
143
145
 
144
146
 
@@ -186,9 +188,9 @@ def get_detail_by_package(packets_from_pcap, publicField, use_regx):
186
188
  res_field['plain_body_src'] = ""
187
189
  res_field['plain_body_dst'] = ""
188
190
  if content_type_is_plain(req):
189
- res_field['plain_body_src'] = get_body(req, is_src=True)
191
+ res_field['plain_body_src'] = get_body(req)
190
192
  if content_type_is_plain(res):
191
- res_field['plain_body_dst'] = get_body(res, is_src=False)
193
+ res_field['plain_body_dst'] = get_body(res)
192
194
 
193
195
  response_lines = res.strip().split("\n")
194
196
  http_response_lines = [item for item in response_lines if "HTTP" in item]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xbase-util
3
- Version: 0.4.7
3
+ Version: 0.4.9
4
4
  Summary: 网络安全基础工具
5
5
  Home-page: https://gitee.com/jimonik/xbase_util.git
6
6
  Author: xyt
File without changes
File without changes