xbase-util 0.4.3__tar.gz → 0.4.4__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.3 → xbase_util-0.4.4}/PKG-INFO +1 -1
  2. {xbase_util-0.4.3 → xbase_util-0.4.4}/setup.py +1 -1
  3. xbase_util-0.4.4/xbase_util/dangerous_util.py +101 -0
  4. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/es_db_util.py +0 -1
  5. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util.egg-info/PKG-INFO +1 -1
  6. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util.egg-info/SOURCES.txt +1 -0
  7. {xbase_util-0.4.3 → xbase_util-0.4.4}/README.md +0 -0
  8. {xbase_util-0.4.3 → xbase_util-0.4.4}/setup.cfg +0 -0
  9. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/__init__.py +0 -0
  10. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/add_column_util.py +0 -0
  11. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/__init__.py +0 -0
  12. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/bean/ConfigBean.py +0 -0
  13. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/bean/CurrentConfigBean.py +0 -0
  14. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/bean/FlowBean.py +0 -0
  15. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/bean/TaskTemplateBean.py +0 -0
  16. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/bean/__init__.py +0 -0
  17. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/dao/ConfigDao.py +0 -0
  18. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/dao/CurrentConfigDao.py +0 -0
  19. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/dao/FlowDao.py +0 -0
  20. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/dao/TaskTemplateDao.py +0 -0
  21. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/dao/__init__.py +0 -0
  22. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/initsqlite3.py +0 -0
  23. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/esreq.py +0 -0
  24. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/geo_util.py +0 -0
  25. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/handle_features_util.py +0 -0
  26. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/packet_util.py +0 -0
  27. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/pcap_util.py +0 -0
  28. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/xbase_constant.py +0 -0
  29. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/xbase_util.py +0 -0
  30. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util.egg-info/dependency_links.txt +0 -0
  31. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util.egg-info/not-zip-safe +0 -0
  32. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util.egg-info/top_level.txt +0 -0
  33. {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util_assets/GeoLite2-City.mmdb +0 -0
  34. {xbase_util-0.4.3 → xbase_util-0.4.4}/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.3
3
+ Version: 0.4.4
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.3",
6
+ version="0.4.4",
7
7
  description="网络安全基础工具",
8
8
  long_description="包含提取,预测,训练的基础工具",
9
9
  author="xyt",
@@ -0,0 +1,101 @@
1
+ import splunklib.client as client
2
+ from splunklib import results
3
+
4
+
5
+ def get_splunk_pa(start_time, end_time, splunk_host,
6
+ splunk_port,
7
+ splunk_username,
8
+ splunk_password,
9
+ splunk_scheme="https",
10
+ splunk_filter="THREAT AND NOT informational"):
11
+ """
12
+ 获取PA威胁信息
13
+ :param splunk_filter:
14
+ :param start_time:
15
+ :param end_time:
16
+ :param splunk_host:
17
+ :param splunk_port:
18
+ :param splunk_username:
19
+ :param splunk_password:
20
+ :param splunk_scheme:
21
+ :return:
22
+ """
23
+ service = client.connect(
24
+ host=splunk_host,
25
+ port=splunk_port,
26
+ scheme=splunk_scheme,
27
+ username=splunk_username,
28
+ password=splunk_password
29
+ )
30
+ job = service.jobs.oneshot(
31
+ """search index=idx_pa
32
+ FILTER_TEXT
33
+ | rex field=_raw "THREAT,(?P<LOG_TYPE>.+?),.*?,(?P<PA_DATE>.*?),(?P<SIP>.*?),(?P<DIP>.*?),(?:.*?,.*?,.*?){7},(?P<S_PORT>.*?),(?P<D_PORT>.*?),.*?,.*?,.*?,(?P<PROTOCOL>.*?),(?P<DENY_METHOD>.*?),(?P<THREAT_SUMMARY>.*?),(?P<SEVERITY>medium|high|critical|low),"
34
+ | eval RAW_BAK=_raw
35
+ | eval THREAT_TIME = strftime(strptime(PA_DATE, "%Y/%m/%d %H:%M:%S"), "%Y-%m-%d %H:%M:%S")
36
+ | rex mode=sed field=_raw "s/.*?,\w{8}-\w{4}-\w{4}-\w{4}-\w{12},/start_ama_flag,/g"
37
+ | rex field=_raw "start_ama_flag,.*?,.*?,(?<XFF_IP>.*?),"
38
+ | eval _raw=RAW_BAK
39
+ | table THREAT_TIME,SIP,S_PORT, DIP, D_PORT,XFF_IP,PROTOCOL, DENY_METHOD, THREAT_SUMMARY, SEVERITY
40
+ | dedup THREAT_TIME,SIP,S_PORT, DIP, D_PORT,XFF_IP,PROTOCOL
41
+ """.replace("FILTER_TEXT", splunk_filter), **{
42
+ "earliest_time": start_time.strftime('%Y-%m-%dT%H:%M:%S'),
43
+ "latest_time": end_time.strftime('%Y-%m-%dT%H:%M:%S'),
44
+ "output_mode": "json",
45
+ "count": 20000
46
+ })
47
+ return [item for item in results.JSONResultsReader(job) if isinstance(item, dict)]
48
+
49
+
50
+ def get_splunk_waf(start_time, end_time, splunk_host,
51
+ splunk_port,
52
+ splunk_username,
53
+ splunk_password,
54
+ splunk_scheme="https"):
55
+ # splunk里面用这个
56
+ """
57
+ sourcetype=changting:waf
58
+ | rex field=_raw (?P<THREAT_TIME>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2})
59
+ | rex field=_raw "\"src_ip\":\"(?<SIP>[^\"]+)\""
60
+ | rex field=_raw "\"protocol\":\"(?<PROTOCOL>[^\"]+)\""
61
+ | rex field=_raw "\"src_port\":(?<S_PORT>\d+)"
62
+ | rex field=_raw "\"dest_ip\":\"(?<DIP>[^\"]+)\""
63
+ | rex field=_raw "\"dest_port\":(?<D_PORT>\d+)"
64
+ | rex field=_raw "\"risk_level\":\"(?<SEVERITY>[^\"]+)\""
65
+ | rex field=_raw "\"action\":\"(?<DENY_METHOD>[^\"]+)\""
66
+ | rex field=_raw "\"reason\":\"(?<THREAT_SUMMARY>[^\"]+)\""
67
+ | rex field=_raw "\"x_forwarded_for\":\"(?<XFF_IP>[^\"]+)\""
68
+ | table THREAT_TIME,SIP,S_PORT,DIP,D_PORT,XFF_IP,PROTOCOL,DENY_METHOD,THREAT_SUMMARY,SEVERITY
69
+ | dedup THREAT_TIME,SIP,S_PORT,DIP,D_PORT,XFF_IP,PROTOCOL
70
+ """
71
+ service = client.connect(
72
+ host=splunk_host,
73
+ port=splunk_port,
74
+ scheme=splunk_scheme,
75
+ username=splunk_username,
76
+ password=splunk_password
77
+ )
78
+ # | rex field=_raw "\\"src_port\\":(?<S_PORT>\d+)"
79
+ # | rex field=_raw "\\"dest_port\\":(?<D_PORT>\d+)"
80
+ exp = """search sourcetype=changting:waf
81
+ | rex field=_raw "(?P<THREAT_TIME>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+\\d{2}:\\d{2})"
82
+ | rex field=_raw "\\"dest_ip\\":\\"(?<DIP>[^\\"]+)\\""
83
+ | rex field=_raw "\\"src_ip\\":\\"(?<SIP>[^\\"]+)\\""
84
+ | rex field=_raw "\\"src_port\\":(?<S_PORT>\\d+)"
85
+ | rex field=_raw "\\"dest_port\\":(?<D_PORT>\\d+)"
86
+ | rex field=_raw "\\"protocol\\":\\"(?<PROTOCOL>[^\\"]+)\\""
87
+ | rex field=_raw "\\"x_forwarded_for\\":\\"(?<XFF_IP>[^\\"]+)\\""
88
+ | rex field=_raw "\\"action\\":\\"(?<DENY_METHOD>[^\\"]+)\\""
89
+ | rex field=_raw "\\"reason\\":\\"(?<THREAT_SUMMARY>[^\\"]+)\\""
90
+ | rex field=_raw "\\"risk_level\\":\\"(?<SEVERITY>[^\\"]+)\\""
91
+ | dedup THREAT_TIME,SIP,S_PORT,DIP,D_PORT,XFF_IP,PROTOCOL
92
+ | table THREAT_TIME,SIP,S_PORT,DIP,D_PORT,XFF_IP,PROTOCOL,DENY_METHOD,THREAT_SUMMARY,SEVERITY
93
+ """
94
+ job = service.jobs.oneshot(
95
+ exp, **{
96
+ "earliest_time": start_time.strftime('%Y-%m-%dT%H:%M:%S'),
97
+ "latest_time": end_time.strftime('%Y-%m-%dT%H:%M:%S'),
98
+ "output_mode": "json",
99
+ "count": 20000
100
+ })
101
+ return [item for item in results.JSONResultsReader(job) if isinstance(item, dict)]
@@ -5,7 +5,6 @@ class EsDb:
5
5
  def __init__(self, req, manager):
6
6
  self.req = req
7
7
  self.internals = manager.dict()
8
- print("初始化:Elasticsearch DB")
9
8
 
10
9
  def get_file_by_file_id(self, node, num, prefix=None):
11
10
  key = f'{node}!{num}'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xbase-util
3
- Version: 0.4.3
3
+ Version: 0.4.4
4
4
  Summary: 网络安全基础工具
5
5
  Home-page: https://gitee.com/jimonik/xbase_util.git
6
6
  Author: xyt
@@ -2,6 +2,7 @@ README.md
2
2
  setup.py
3
3
  xbase_util/__init__.py
4
4
  xbase_util/add_column_util.py
5
+ xbase_util/dangerous_util.py
5
6
  xbase_util/es_db_util.py
6
7
  xbase_util/esreq.py
7
8
  xbase_util/geo_util.py
File without changes
File without changes