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.
- {xbase_util-0.4.3 → xbase_util-0.4.4}/PKG-INFO +1 -1
- {xbase_util-0.4.3 → xbase_util-0.4.4}/setup.py +1 -1
- xbase_util-0.4.4/xbase_util/dangerous_util.py +101 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/es_db_util.py +0 -1
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util.egg-info/PKG-INFO +1 -1
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util.egg-info/SOURCES.txt +1 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/README.md +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/setup.cfg +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/__init__.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/add_column_util.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/__init__.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/bean/ConfigBean.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/bean/CurrentConfigBean.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/bean/FlowBean.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/bean/TaskTemplateBean.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/bean/__init__.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/dao/ConfigDao.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/dao/CurrentConfigDao.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/dao/FlowDao.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/dao/TaskTemplateDao.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/dao/__init__.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/db/initsqlite3.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/esreq.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/geo_util.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/handle_features_util.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/packet_util.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/pcap_util.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/xbase_constant.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util/xbase_util.py +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util.egg-info/dependency_links.txt +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util.egg-info/not-zip-safe +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util.egg-info/top_level.txt +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util_assets/GeoLite2-City.mmdb +0 -0
- {xbase_util-0.4.3 → xbase_util-0.4.4}/xbase_util_assets/arkimeparse.js +0 -0
@@ -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)]
|
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
|