Skip to content

Commit 236e2fd

Browse files
Merge pull request #2215 from certtools/fix-2169
FIX: Added check if cymru hostname is an ip address
2 parents 2d7b9ca + 5e47e4e commit 236e2fd

File tree

4 files changed

+72
-53
lines changed

4 files changed

+72
-53
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ CHANGELOG
7474
- `intelmq.bots.parsers.shadowserver._config`:
7575
- Added support for `Accessible AMQP`, `Device Identification Report` (IPv4 and IPv6) (PR#2134 by Mateo Durante).
7676
- Added file name mapping for `SSL-POODLE-Vulnerable-Servers IPv6` (file name `scan6_ssl_poodle`) (PR#2134 by Mateo Durante).
77+
- `intelmq.bots.parsers.cymru.parser_cap_program`: The parser mapped the hostname into `source.fqdn` which is not allowed by the IntelMQ Data Format. Added a check (PR#2215 by Sebastian Waldbauer, fixes #2169)
7778
- `intelmq.bots.parsers.generic.parser_csv`: Use RewindableFileHandle to use the original current line for line recovery (PR#2192 by Sebastian Wagner).
7879

7980
#### Experts

intelmq/bots/parsers/cymru/parser_cap_program.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from intelmq.lib import utils
99
from intelmq.lib.bot import ParserBot
10+
from intelmq.lib.harmonization import FQDN
1011

1112
MAPPING_STATIC = {'bot': {
1213
'classification.type': 'infected-system'},
@@ -320,6 +321,8 @@ def parse_line_new(self, line, report):
320321
raise ValueError('Unknown protocol %r, please report a bug'
321322
'' % value)
322323
elif key == 'hostname':
324+
if not FQDN.is_valid(value=value) and value == ip:
325+
continue
323326
event['source.fqdn'] = value
324327
elif key == 'proxy_type':
325328
if '-' in value:

intelmq/tests/bots/parsers/cymru/certname_20190327.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ scanner|172.16.0.21|64496|2020-07-09 03:40:15|username: pm;|Example AS Name, AT
3333
darknet|172.16.0.21|64496|2020-10-08 02:21:26|protocol: 47;|Example AS Name, AT
3434
darknet|172.16.0.21|64496|2020-10-15 09:22:10|protocol: 59;|Example AS Name, AT
3535
proxy|172.16.0.21|64496|2020-12-14 08:28:01|httpconnect-51915; additional_asns: 212682;|Example AS Name, AT
36-
bruteforce|172.16.0.21|64496|2021-03-09 00:11:21|destination_port_numbers: 22;port: 16794;protocol: 6;|Example AS Name, AT
36+
bruteforce|172.16.0.21|64496|2021-03-09 00:11:21|destination_port_numbers: 22;port: 16794;protocol: 6;|Example AS Name, AT
37+
bot|172.16.0.21|64496|2019-03-22 18:18:52|family: Conficker;hostname: 172.16.0.21|Example AS Name, AT
38+
bot|172.16.0.21|64496|2019-03-22 20:18:52|family: Conficker;hostname: 21-0-16-172.example.tld|Example AS Name, AT

intelmq/tests/bots/parsers/cymru/test_cap_program_new.py

Lines changed: 65 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -181,61 +181,74 @@
181181
'protocol.transport': 'udp',
182182
} for destport in [17875, 24526, 54449, 9314, 4903,
183183
1568, 20749, 30524, 59316, 60704]] + [
184-
{'classification.type': 'spam',
185-
'classification.identifier': 'spam',
186-
'time.source': '2019-10-02T23:00:17+00:00',
187-
},
188-
{'time.source': '2019-10-23T12:46:18+00:00',
189-
'classification.type': 'phishing',
190-
'classification.identifier': 'phishing',
191-
},
192-
{'classification.type': 'scanner',
193-
'classification.identifier': 'darknet',
194-
'protocol.transport': 'nvp-ii',
195-
'destination.port': 0,
196-
'time.source': '2020-01-10T09:17:17+00:00',
197-
},
198-
{'classification.type': 'infected-system',
199-
'classification.identifier': 'conficker',
200-
'malware.name': 'conficker',
201-
'source.port': 1997,
202-
'destination.ip': '172.16.0.22',
203-
'time.source': '2020-05-08T09:13:34+00:00',
204-
},
205-
{'classification.type': 'scanner',
206-
'classification.identifier': 'scanner',
207-
'time.source': '2020-07-09T03:40:15+00:00',
208-
'source.account': 'pm',
209-
},
210-
{'classification.type': 'scanner',
211-
'classification.identifier': 'darknet',
212-
'time.source': '2020-10-08T02:21:26+00:00',
213-
'protocol.transport': 'gre',
214-
},
215-
{'classification.type': 'scanner',
216-
'classification.identifier': 'darknet',
217-
'time.source': '2020-10-15T09:22:10+00:00',
218-
'protocol.transport': 'ipv6-nonxt',
219-
},
220-
{
221-
'classification.type': 'proxy',
222-
'classification.identifier': 'openproxy',
223-
'time.source': '2020-12-14T08:28:01+00:00',
224-
'extra.source.asns': [64496, 212682],
225-
'protocol.application': 'httpconnect',
226-
'source.port': 51915,
227-
},
228-
{'classification.type': 'brute-force',
229-
'protocol.transport': 'tcp',
230-
'destination.port': 22,
231-
'source.port': 16794,
232-
'time.source': '2021-03-09T00:11:21+00:00',
233-
},
234-
]
184+
{'classification.type': 'spam',
185+
'classification.identifier': 'spam',
186+
'time.source': '2019-10-02T23:00:17+00:00',
187+
},
188+
{'time.source': '2019-10-23T12:46:18+00:00',
189+
'classification.type': 'phishing',
190+
'classification.identifier': 'phishing',
191+
},
192+
{'classification.type': 'scanner',
193+
'classification.identifier': 'darknet',
194+
'protocol.transport': 'nvp-ii',
195+
'destination.port': 0,
196+
'time.source': '2020-01-10T09:17:17+00:00',
197+
},
198+
{'classification.type': 'infected-system',
199+
'classification.identifier': 'conficker',
200+
'malware.name': 'conficker',
201+
'source.port': 1997,
202+
'destination.ip': '172.16.0.22',
203+
'time.source': '2020-05-08T09:13:34+00:00',
204+
},
205+
{'classification.type': 'scanner',
206+
'classification.identifier': 'scanner',
207+
'time.source': '2020-07-09T03:40:15+00:00',
208+
'source.account': 'pm',
209+
},
210+
{'classification.type': 'scanner',
211+
'classification.identifier': 'darknet',
212+
'time.source': '2020-10-08T02:21:26+00:00',
213+
'protocol.transport': 'gre',
214+
},
215+
{'classification.type': 'scanner',
216+
'classification.identifier': 'darknet',
217+
'time.source': '2020-10-15T09:22:10+00:00',
218+
'protocol.transport': 'ipv6-nonxt',
219+
},
220+
{
221+
'classification.type': 'proxy',
222+
'classification.identifier': 'openproxy',
223+
'time.source': '2020-12-14T08:28:01+00:00',
224+
'extra.source.asns': [64496, 212682],
225+
'protocol.application': 'httpconnect',
226+
'source.port': 51915,
227+
},
228+
{'classification.type': 'brute-force',
229+
'protocol.transport': 'tcp',
230+
'destination.port': 22,
231+
'source.port': 16794,
232+
'time.source': '2021-03-09T00:11:21+00:00',
233+
},
234+
{'time.source': '2019-03-22T18:18:52+00:00',
235+
'classification.type': 'infected-system',
236+
'classification.identifier': 'conficker',
237+
'malware.name': 'conficker',
238+
'source.geolocation.cc': 'AT',
239+
},
240+
{'time.source': '2019-03-22T20:18:52+00:00',
241+
'classification.type': 'infected-system',
242+
'classification.identifier': 'conficker',
243+
'malware.name': 'conficker',
244+
'source.fqdn': '21-0-16-172.example.tld',
245+
'source.geolocation.cc': 'AT',
246+
},
247+
]
235248

236249
# The number of events a single line in the raw data produces
237250
NUM_EVENTS = (1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
238-
1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1)
251+
1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
239252
RAWS = []
240253
for i, line in enumerate(RAW_LINES[3:]):
241254
for count in range(NUM_EVENTS[i]):

0 commit comments

Comments
 (0)