dshield-parser 0.1.0__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/PKG-INFO +13 -13
- dshield_parser-0.1.3/README.md +14 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/utils/enrichment.py +99 -28
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/utils/file_io.py +3 -1
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/utils/json.py +98 -6
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser.egg-info/PKG-INFO +13 -13
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser.egg-info/SOURCES.txt +2 -0
- dshield_parser-0.1.3/pyproject.toml +3 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/setup.cfg +4 -4
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/setup.py +18 -18
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/__init__.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/__main__.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/cowrie_processor/__init__.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/cowrie_processor/__main__.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/cowrie_processor/reports.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/firewall_processor/__init__.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/firewall_processor/__main__.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/firewall_processor/reports.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/test/__init__.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/test/test_json.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/utils/__init__.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/utils/__main__.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/utils/graphs.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/utils/ml.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/utils/sql.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/utils/ssh.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/web_processor/__init__.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/web_processor/__main__.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser/web_processor/reports.py +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser.egg-info/dependency_links.txt +0 -0
- {dshield_parser-0.1.0 → dshield_parser-0.1.3}/dshield_parser.egg-info/top_level.txt +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name: dshield_parser
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: This program has utilities to download, parse and enrich DSHield honeypot data
|
|
5
|
-
Home-page: https://github.com/jslagrew/dshield-parser
|
|
6
|
-
Author: Jesse La Grew
|
|
7
|
-
Author-email: jlagrew.github@proton.me
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dshield_parser
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: This program has utilities to download, parse and enrich DSHield honeypot data
|
|
5
|
+
Home-page: https://github.com/jslagrew/dshield-parser
|
|
6
|
+
Author: Jesse La Grew
|
|
7
|
+
Author-email: jlagrew.github@proton.me
|
|
8
|
+
Requires-Python: >3.12.7
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: author-email
|
|
11
|
+
Dynamic: home-page
|
|
12
|
+
Dynamic: requires-python
|
|
13
|
+
Dynamic: summary
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# dshield-parser
|
|
2
|
+
Python scripts to parse DShield honeypot (cowrie, web honeypot, iptables firewall) logs
|
|
3
|
+
|
|
4
|
+
# Installing
|
|
5
|
+
The easiest way to install is using pip.
|
|
6
|
+
```
|
|
7
|
+
# it is recommended to use a virtual environment
|
|
8
|
+
# python -m venv /path/to/new/venv
|
|
9
|
+
# /path/to/new/venv/scripts/activate
|
|
10
|
+
|
|
11
|
+
# depending on your system, you may need to replace "pip" with "pip3"
|
|
12
|
+
pip install dshield-parser
|
|
13
|
+
pip install -r https://raw.githubusercontent.com/jslagrew/dshield-parser/main/requirements.txt
|
|
14
|
+
```
|
|
@@ -32,9 +32,9 @@ def get_spur_data(log_source, input, session, api):
|
|
|
32
32
|
while True:
|
|
33
33
|
try:
|
|
34
34
|
response = session.get(url)
|
|
35
|
-
except:
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
except Exception as e:
|
|
36
|
+
logging.error(f"Exception hit for SPUR query: '{e}'. Pausing for 15 seconds before trying again.")
|
|
37
|
+
time.sleep(15)
|
|
38
38
|
continue
|
|
39
39
|
break
|
|
40
40
|
json_data = json.loads(response.text)
|
|
@@ -61,7 +61,15 @@ def get_vt_data(input, input_type, api):
|
|
|
61
61
|
else:
|
|
62
62
|
logging.error("Invalid input type given for VirusTotal to process.")
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
while True:
|
|
65
|
+
try:
|
|
66
|
+
response = requests.get(url, headers=headers)
|
|
67
|
+
except Exception as e:
|
|
68
|
+
logging.error(f"Exception hit for VirusTotal query: '{e}'. Pausing for 15 seconds before trying again.")
|
|
69
|
+
time.sleep(15)
|
|
70
|
+
continue
|
|
71
|
+
break
|
|
72
|
+
|
|
65
73
|
json_response = json.loads(response.text)
|
|
66
74
|
logging.debug(response.text)
|
|
67
75
|
if "error" in json_response:
|
|
@@ -165,7 +173,16 @@ def isc_cloudapis(email):
|
|
|
165
173
|
headers = {
|
|
166
174
|
'User-Agent': f'Request from {email}',
|
|
167
175
|
}
|
|
168
|
-
|
|
176
|
+
|
|
177
|
+
while True:
|
|
178
|
+
try:
|
|
179
|
+
response = requests.get(url, headers=headers)
|
|
180
|
+
except Exception as e:
|
|
181
|
+
logging.error(f"Exception hit for Could IP SANS ISC query: '{e}'. Pausing for 15 seconds before trying again.")
|
|
182
|
+
time.sleep(15)
|
|
183
|
+
continue
|
|
184
|
+
break
|
|
185
|
+
|
|
169
186
|
xml = response.text
|
|
170
187
|
root = ET.fromstring(xml)
|
|
171
188
|
ips = []
|
|
@@ -193,7 +210,15 @@ def isc_cloudcidrs(email):
|
|
|
193
210
|
headers = {
|
|
194
211
|
'User-Agent': f'Request from {email}',
|
|
195
212
|
}
|
|
196
|
-
|
|
213
|
+
while True:
|
|
214
|
+
try:
|
|
215
|
+
response = requests.get(url, headers=headers)
|
|
216
|
+
except Exception as e:
|
|
217
|
+
logging.error(f"Exception hit for Cloud CIDR SANS ISC query: '{e}'. Pausing for 15 seconds before trying again.")
|
|
218
|
+
time.sleep(15)
|
|
219
|
+
continue
|
|
220
|
+
break
|
|
221
|
+
|
|
197
222
|
xml = response.text
|
|
198
223
|
root = ET.fromstring(xml)
|
|
199
224
|
ips = []
|
|
@@ -217,7 +242,16 @@ def isc_intelfeed(email):
|
|
|
217
242
|
headers = {
|
|
218
243
|
f'User-Agent': 'Request from {email}',
|
|
219
244
|
}
|
|
220
|
-
|
|
245
|
+
|
|
246
|
+
while True:
|
|
247
|
+
try:
|
|
248
|
+
response = requests.get(url, headers=headers)
|
|
249
|
+
except Exception as e:
|
|
250
|
+
logging.error(f"Exception hit for SANS ISC Intel Feed query: '{e}'. Pausing for 15 seconds before trying again.")
|
|
251
|
+
time.sleep(15)
|
|
252
|
+
continue
|
|
253
|
+
break
|
|
254
|
+
|
|
221
255
|
xml = response.text
|
|
222
256
|
root = ET.fromstring(xml)
|
|
223
257
|
|
|
@@ -231,7 +265,16 @@ def isc_ipinfo(ip, email):
|
|
|
231
265
|
headers = {
|
|
232
266
|
'User-Agent': f'Request from {email}',
|
|
233
267
|
}
|
|
234
|
-
|
|
268
|
+
|
|
269
|
+
while True:
|
|
270
|
+
try:
|
|
271
|
+
response = requests.get(url, headers=headers)
|
|
272
|
+
except Exception as e:
|
|
273
|
+
logging.error(f"Exception hit for SANS ISC IP info query: '{e}'. Pausing for 15 seconds before trying again.")
|
|
274
|
+
time.sleep(15)
|
|
275
|
+
continue
|
|
276
|
+
break
|
|
277
|
+
|
|
235
278
|
while response.status_code != 200:
|
|
236
279
|
delay = 5
|
|
237
280
|
if response.status_code == 429:
|
|
@@ -289,7 +332,16 @@ def isc_research_threats(email, start_date=None, end_date=None):
|
|
|
289
332
|
headers = {
|
|
290
333
|
'User-Agent': f'Request from {email}',
|
|
291
334
|
}
|
|
292
|
-
|
|
335
|
+
|
|
336
|
+
while True:
|
|
337
|
+
try:
|
|
338
|
+
response = requests.get(url, headers=headers)
|
|
339
|
+
except Exception as e:
|
|
340
|
+
logging.error(f"Exception hit for SANS ISC Research Threats query: '{e}'. Pausing for 15 seconds before trying again.")
|
|
341
|
+
time.sleep(15)
|
|
342
|
+
continue
|
|
343
|
+
break
|
|
344
|
+
|
|
293
345
|
xml = response.text
|
|
294
346
|
logging.debug(f"XML Data: {xml}")
|
|
295
347
|
root = ET.fromstring(xml)
|
|
@@ -307,12 +359,24 @@ def isc_research_threats(email, start_date=None, end_date=None):
|
|
|
307
359
|
return pd.DataFrame(threat_intel)
|
|
308
360
|
|
|
309
361
|
def binary_edge_minions(email):
|
|
310
|
-
|
|
362
|
+
# bad URL as of 7/6/2025
|
|
363
|
+
# url = f"https://api.binaryedge.io/krang/v1/minions"
|
|
364
|
+
url = f"https://api.binaryedge.io/v1/minions"
|
|
311
365
|
|
|
312
366
|
headers = {
|
|
313
367
|
'User-Agent': f'Request from {email}',
|
|
314
368
|
}
|
|
315
|
-
|
|
369
|
+
|
|
370
|
+
while True:
|
|
371
|
+
try:
|
|
372
|
+
#this gave error 404 on 7/6/2025
|
|
373
|
+
response = requests.get(url, headers=headers)
|
|
374
|
+
except Exception as e:
|
|
375
|
+
logging.error(f"Exception hit for Binary Edge query: '{e}'. Pausing for 15 seconds before trying again.")
|
|
376
|
+
time.sleep(15)
|
|
377
|
+
continue
|
|
378
|
+
break
|
|
379
|
+
|
|
316
380
|
scanners = json.loads(response.text)['scanners']
|
|
317
381
|
|
|
318
382
|
#return a list of binary edge minions (scanning agents)
|
|
@@ -324,7 +388,16 @@ def censys_networks(email):
|
|
|
324
388
|
headers = {
|
|
325
389
|
'User-Agent': f'Request from {email}',
|
|
326
390
|
}
|
|
327
|
-
|
|
391
|
+
|
|
392
|
+
while True:
|
|
393
|
+
try:
|
|
394
|
+
response = requests.get(url, headers=headers)
|
|
395
|
+
except Exception as e:
|
|
396
|
+
logging.error(f"Exception hit for Censys query: '{e}'. Pausing for 15 seconds before trying again.")
|
|
397
|
+
time.sleep(15)
|
|
398
|
+
continue
|
|
399
|
+
break
|
|
400
|
+
|
|
328
401
|
scanners = response.text.split("\n")
|
|
329
402
|
|
|
330
403
|
#return a list of binary edge minions (scanning agents)
|
|
@@ -336,7 +409,10 @@ def get_reverse_dns(ipaddress):
|
|
|
336
409
|
try:
|
|
337
410
|
response = socket.gethostbyaddr(f"{ipaddress}")
|
|
338
411
|
except Exception as e:
|
|
339
|
-
|
|
412
|
+
if "host not found" in e:
|
|
413
|
+
logging.info(f"Lookup failed for {ipaddress}: {e}")
|
|
414
|
+
else:
|
|
415
|
+
logging.error(f"Lookup failed for {ipaddress}: {e}")
|
|
340
416
|
if len(response) == 0:
|
|
341
417
|
return response
|
|
342
418
|
else:
|
|
@@ -348,7 +424,15 @@ def isc_webhoneypot_useragents(user_agent, day, email):
|
|
|
348
424
|
headers = {
|
|
349
425
|
'User-Agent': f'Request from {email}',
|
|
350
426
|
}
|
|
351
|
-
|
|
427
|
+
while True:
|
|
428
|
+
try:
|
|
429
|
+
response = requests.get(url, headers=headers)
|
|
430
|
+
except Exception as e:
|
|
431
|
+
logging.error(f"Exception hit for SANS ISC web honeypot user agent query: '{e}'. Pausing for 15 seconds before trying again.")
|
|
432
|
+
time.sleep(15)
|
|
433
|
+
continue
|
|
434
|
+
break
|
|
435
|
+
|
|
352
436
|
return json.loads(response.text)
|
|
353
437
|
|
|
354
438
|
def extract_ips(data):
|
|
@@ -371,17 +455,4 @@ def extract_subnets(data):
|
|
|
371
455
|
return_networks.append(each_network)
|
|
372
456
|
except:
|
|
373
457
|
logging.error(f"Error trying to create network object from {each_network}")
|
|
374
|
-
return return_networks
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
#cloudips = isc_cloudapis()
|
|
378
|
-
#insert_df(f"{date}_iscdata.sqlite", cloudips, "cloudips")
|
|
379
|
-
|
|
380
|
-
#cloudcidr = isc_cloudcidrs()
|
|
381
|
-
#insert_df(f"{date}_iscdata.sqlite", cloudcidr, "cloudcidrs")
|
|
382
|
-
|
|
383
|
-
#ipdata = isc_ipinfo("70.91.145.10")
|
|
384
|
-
#insert_dict(f"{date}_iscdata.sqlite", ipdata, "70.91.145.10")
|
|
385
|
-
|
|
386
|
-
#research_data = isc_research_threats()
|
|
387
|
-
#insert_df(f"{date}_iscdata.sqlite", research_data, "research_ip")
|
|
458
|
+
return return_networks
|
|
@@ -32,7 +32,7 @@ def read_file_json_generator(filename):
|
|
|
32
32
|
for line in file:
|
|
33
33
|
if line[:1] =="{":
|
|
34
34
|
try:
|
|
35
|
-
yield json.loads(line)
|
|
35
|
+
yield json.loads(line) #.replace('\x00','') # added .replace('\x00','') on 8/17/24 to replace null bytes for pandas merge issues
|
|
36
36
|
except Exception as e:
|
|
37
37
|
logging.error(f"Exception hit for file '{filename}': {e}")
|
|
38
38
|
logging.error(f"Text of line with error (limted to first 40 characters): '{line[0:40]}'")
|
|
@@ -62,6 +62,8 @@ def get_file_lists(path):
|
|
|
62
62
|
cowrie_files.append(each_item)
|
|
63
63
|
elif "webhoneypot-" in str(each_item):
|
|
64
64
|
web_honeypot_files.append(each_item)
|
|
65
|
+
elif "webhoneypot_" in str(each_item):
|
|
66
|
+
web_honeypot_files.append(each_item)
|
|
65
67
|
cowrie_files = sorted(cowrie_files, key=os.path.getmtime)
|
|
66
68
|
web_honeypot_files = sorted(web_honeypot_files, key=os.path.getmtime)
|
|
67
69
|
firewall_files = sorted(firewall_files, key=os.path.getmtime)
|
|
@@ -11,6 +11,7 @@ import dshield_parser
|
|
|
11
11
|
import dshield_parser.firewall_processor
|
|
12
12
|
import dshield_parser.firewall_processor.reports
|
|
13
13
|
import dshield_parser.utils.file_io as file_io
|
|
14
|
+
import pandas as pd
|
|
14
15
|
|
|
15
16
|
default_datespan={'start_date': '1970-01-01', 'end_date': '3000-01-01'}
|
|
16
17
|
default_timespan={"start_time": 0, "end_time": 32516881838}
|
|
@@ -68,7 +69,18 @@ def print_list(list):
|
|
|
68
69
|
for each_item in list:
|
|
69
70
|
print(each_item)
|
|
70
71
|
|
|
71
|
-
def
|
|
72
|
+
def sizeof_fmt(num, suffix='B'):
|
|
73
|
+
''' by Fred Cirera, https://stackoverflow.com/a/1094933/1870254, modified'''
|
|
74
|
+
for unit in ['','Ki','Mi','Gi','Ti','Pi','Ei','Zi']:
|
|
75
|
+
if abs(num) < 1024.0:
|
|
76
|
+
return "%3.1f %s%s" % (num, unit, suffix)
|
|
77
|
+
num /= 1024.0
|
|
78
|
+
return "%.1f %s%s" % (num, 'Yi', suffix)
|
|
79
|
+
|
|
80
|
+
def get_json_values(key, incoming_data, timespan=default_timespan, exclusions=None, compress_dates=False):
|
|
81
|
+
day_count = 0
|
|
82
|
+
df = pd.DataFrame()
|
|
83
|
+
#new_df = pd.DataFrame()
|
|
72
84
|
if "start_time" in timespan and "end_time" in timespan:
|
|
73
85
|
start_date = convert_to_date(timespan["start_time"])
|
|
74
86
|
end_date = convert_to_date(timespan["end_time"])
|
|
@@ -108,9 +120,50 @@ def get_json_values(key, incoming_data, timespan=default_timespan, exclusions=No
|
|
|
108
120
|
else:
|
|
109
121
|
if each_key in yielded_json:
|
|
110
122
|
#values.append(yielded_json[each_key])
|
|
111
|
-
|
|
123
|
+
if isinstance(yielded_json[each_key], str):
|
|
124
|
+
log_data[each_key] = yielded_json[each_key].replace('\x00','') # added .replace('\x00','') on 8/17/24 to replace null bytes for pandas merge issues
|
|
125
|
+
elif isinstance(yielded_json[each_key], dict):
|
|
126
|
+
log_data[each_key] = json.dumps(yielded_json[each_key])
|
|
127
|
+
else:
|
|
128
|
+
log_data[each_key] = yielded_json[each_key]
|
|
112
129
|
if len(log_data) > 0:
|
|
113
|
-
|
|
130
|
+
if compress_dates == True:
|
|
131
|
+
#dates = [dshield_parser.utils.json.time_to_day(timestamp) for timestamp in df["time"]
|
|
132
|
+
try:
|
|
133
|
+
# different time field for cowrie honeypot data
|
|
134
|
+
log_data["dates"] = dshield_parser.utils.json.time_to_day(log_data["timestamp"])
|
|
135
|
+
log_data.pop("timestamp")
|
|
136
|
+
except Exception as e:
|
|
137
|
+
# different time field for web or firewall honeypot data
|
|
138
|
+
log_data["dates"] = dshield_parser.utils.json.time_to_day(log_data["time"])
|
|
139
|
+
log_data.pop("time")
|
|
140
|
+
values.append(log_data)
|
|
141
|
+
#df = pd.concat([df, pd.DataFrame([log_data])], ignore_index=True)
|
|
142
|
+
##new_df = pd.DataFrame([log_data])
|
|
143
|
+
#new_df = pd.concat([new_df, temp_df])
|
|
144
|
+
##new_df = new_df.groupby(new_df.columns.tolist(),as_index=False, dropna=False).size()
|
|
145
|
+
##df = pd.concat([df, new_df]).groupby(new_df.columns.tolist(),as_index=False, dropna=False)['size'].sum()
|
|
146
|
+
#new_df = new_df.groupby(new_df.columns.tolist(),as_index=False, dropna=False).size()
|
|
147
|
+
#df = pd.concat([df, new_df]).groupby(new_df.columns.tolist(),as_index=False, dropna=False)['size'].sum()
|
|
148
|
+
#new_df = pd.DataFrame()
|
|
149
|
+
|
|
150
|
+
#summarization will be run at the end of every file processed
|
|
151
|
+
if compress_dates == True:
|
|
152
|
+
if day_count % 50 == 0 or len(values) > 500000: #compress if 50 days of data or more than 500k records
|
|
153
|
+
logging.info(f"50 days of data processed or more than 500k records found. Collapsing dataframe by date (grouping by).")
|
|
154
|
+
file_df = pd.DataFrame(values)
|
|
155
|
+
file_df = file_df.groupby(file_df.columns.tolist(),as_index=False, dropna=False).size()
|
|
156
|
+
df = pd.concat([df, file_df]).groupby(file_df.columns.tolist(),as_index=False, dropna=False)['size'].sum()
|
|
157
|
+
values = []
|
|
158
|
+
elif end_date in file.name or (file.name == incoming_data[-1].name):
|
|
159
|
+
logging.info(f"Last day being processed: {date}")
|
|
160
|
+
file_df = pd.DataFrame(values)
|
|
161
|
+
file_df = file_df.groupby(file_df.columns.tolist(),as_index=False, dropna=False).size()
|
|
162
|
+
df = pd.concat([df, file_df]).groupby(file_df.columns.tolist(),as_index=False, dropna=False)['size'].sum()
|
|
163
|
+
values = []
|
|
164
|
+
day_count += 1
|
|
165
|
+
|
|
166
|
+
|
|
114
167
|
else:
|
|
115
168
|
for yielded_json in file_io.read_file_json_generator(file):
|
|
116
169
|
if "logs" in yielded_json:
|
|
@@ -132,12 +185,51 @@ def get_json_values(key, incoming_data, timespan=default_timespan, exclusions=No
|
|
|
132
185
|
else:
|
|
133
186
|
logging.debug(f"Filtered out data since {each_item['time']} is not between {timespan['start_time']} and {timespan['end_time']}")
|
|
134
187
|
if len(log_data) > 0:
|
|
135
|
-
|
|
188
|
+
if compress_dates == True:
|
|
189
|
+
#dates = [dshield_parser.utils.json.time_to_day(timestamp) for timestamp in df["time"]
|
|
190
|
+
try:
|
|
191
|
+
# different time field for cowrie honeypot data
|
|
192
|
+
log_data["dates"] = dshield_parser.utils.json.time_to_day(log_data["timestamp"])
|
|
193
|
+
log_data.pop("timestamp")
|
|
194
|
+
except Exception as e:
|
|
195
|
+
# different time field for web or firewall honeypot data
|
|
196
|
+
log_data["dates"] = dshield_parser.utils.json.time_to_day(log_data["time"])
|
|
197
|
+
log_data.pop("time")
|
|
198
|
+
values.append(log_data)
|
|
199
|
+
#end of processing firewall log
|
|
200
|
+
logging.info(f"Undated data file finished processing: {file}")
|
|
201
|
+
file_df = pd.DataFrame(values)
|
|
202
|
+
file_df = file_df.groupby(file_df.columns.tolist(),as_index=False, dropna=False).size()
|
|
203
|
+
df = pd.concat([df, file_df]).groupby(file_df.columns.tolist(),as_index=False, dropna=False)['size'].sum()
|
|
204
|
+
values = []
|
|
205
|
+
|
|
136
206
|
else:
|
|
137
207
|
for each_item in file:
|
|
138
208
|
if key in each_item:
|
|
139
|
-
|
|
140
|
-
|
|
209
|
+
if compress_dates == True:
|
|
210
|
+
#dates = [dshield_parser.utils.json.time_to_day(timestamp) for timestamp in df["time"]
|
|
211
|
+
try:
|
|
212
|
+
# different time field for cowrie honeypot data
|
|
213
|
+
log_data["dates"] = dshield_parser.utils.json.time_to_day(log_data["timestamp"])
|
|
214
|
+
log_data.pop("timestamp")
|
|
215
|
+
except Exception as e:
|
|
216
|
+
# different time field for web or firewall honeypot data
|
|
217
|
+
log_data["dates"] = dshield_parser.utils.json.time_to_day(log_data["time"])
|
|
218
|
+
log_data.pop("time")
|
|
219
|
+
values.append(log_data)
|
|
220
|
+
logging.info(f"Firewall log finished processing: {file}")
|
|
221
|
+
file_df = pd.DataFrame(values)
|
|
222
|
+
file_df = file_df.groupby(file_df.columns.tolist(),as_index=False, dropna=False).size()
|
|
223
|
+
df = pd.concat([df, file_df]).groupby(file_df.columns.tolist(),as_index=False, dropna=False)['size'].sum()
|
|
224
|
+
values = []
|
|
225
|
+
|
|
226
|
+
# print out variable memory usage
|
|
227
|
+
for name, size in sorted(((name, sys.getsizeof(value)) for name, value in list(
|
|
228
|
+
locals().items())), key= lambda x: -x[1])[:10]:
|
|
229
|
+
print("{:>30}: {:>8}".format(name, sizeof_fmt(size)))
|
|
230
|
+
|
|
231
|
+
df = df.groupby(df.columns.tolist(),as_index=False, dropna=False)['size'].sum()
|
|
232
|
+
return df
|
|
141
233
|
|
|
142
234
|
def summarize_values(list):
|
|
143
235
|
summary = {}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: This program has utilities to download, parse and enrich DSHield honeypot data
|
|
5
|
-
Home-page: https://github.com/jslagrew/dshield-parser
|
|
6
|
-
Author: Jesse La Grew
|
|
7
|
-
Author-email: jlagrew.github@proton.me
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dshield_parser
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: This program has utilities to download, parse and enrich DSHield honeypot data
|
|
5
|
+
Home-page: https://github.com/jslagrew/dshield-parser
|
|
6
|
+
Author: Jesse La Grew
|
|
7
|
+
Author-email: jlagrew.github@proton.me
|
|
8
|
+
Requires-Python: >3.12.7
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: author-email
|
|
11
|
+
Dynamic: home-page
|
|
12
|
+
Dynamic: requires-python
|
|
13
|
+
Dynamic: summary
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[egg_info]
|
|
2
|
-
tag_build =
|
|
3
|
-
tag_date = 0
|
|
4
|
-
|
|
1
|
+
[egg_info]
|
|
2
|
+
tag_build =
|
|
3
|
+
tag_date = 0
|
|
4
|
+
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import setuptools
|
|
2
|
-
|
|
3
|
-
setuptools.setup(
|
|
4
|
-
name="dshield_parser",
|
|
5
|
-
version="0.1.
|
|
6
|
-
author="Jesse La Grew",
|
|
7
|
-
author_email="jlagrew.github@proton.me",
|
|
8
|
-
description="This program has utilities to download, parse and enrich DSHield honeypot data",
|
|
9
|
-
url="https://github.com/jslagrew/dshield-parser",
|
|
10
|
-
packages=setuptools.find_packages(),
|
|
11
|
-
#entry_points = {
|
|
12
|
-
# 'console_scripts':
|
|
13
|
-
# ['summarize_urls=utils.json:summarize_urls',
|
|
14
|
-
# 'summarize_urls=utils.json:summarize_commands']
|
|
15
|
-
#},
|
|
16
|
-
python_requires='>3.
|
|
17
|
-
#install_requires=['matplotlib', 'numpy', 'pandas', 'Requests', 'scikit_learn', 'shodan', 'SQLAlchemy']
|
|
18
|
-
)
|
|
1
|
+
import setuptools
|
|
2
|
+
|
|
3
|
+
setuptools.setup(
|
|
4
|
+
name="dshield_parser",
|
|
5
|
+
version="0.1.3",
|
|
6
|
+
author="Jesse La Grew",
|
|
7
|
+
author_email="jlagrew.github@proton.me",
|
|
8
|
+
description="This program has utilities to download, parse and enrich DSHield honeypot data",
|
|
9
|
+
url="https://github.com/jslagrew/dshield-parser",
|
|
10
|
+
packages=setuptools.find_packages(),
|
|
11
|
+
#entry_points = {
|
|
12
|
+
# 'console_scripts':
|
|
13
|
+
# ['summarize_urls=utils.json:summarize_urls',
|
|
14
|
+
# 'summarize_urls=utils.json:summarize_commands']
|
|
15
|
+
#},
|
|
16
|
+
python_requires='>3.12.7'
|
|
17
|
+
#install_requires=['matplotlib', 'numpy', 'pandas', 'Requests', 'scikit_learn', 'shodan', 'SQLAlchemy']
|
|
18
|
+
)
|
|
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
|