Skip to content

Commit e1dbdf7

Browse files
Merge pull request #206 from obsidianforensics/issue-195
Switch package for MAC address lookups to an offline one.
2 parents f2542b4 + 54f02f3 commit e1dbdf7

File tree

5 files changed

+15
-20
lines changed

5 files changed

+15
-20
lines changed

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ keywords=["unfurl", "forensics", "dfir", "reverse-engineering", "security", "osi
2222
dependencies = { file = ["requirements.txt"] }
2323
version = { attr = "unfurl.__version__" }
2424
optional-dependencies.ui = { file = ["requirements-ui.txt"] }
25-
optional-dependencies.lookups = { file = ["requirements-lookups.txt"] }
2625
optional-dependencies.all = { file = ["requirements-all.txt"] }
2726

2827
[project.scripts]

requirements-all.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dfir-unfurl[ui,lookups]
1+
dfir-unfurl[ui]

requirements-lookups.txt

-1
This file was deleted.

requirements.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
bbpb
12
dnslib
3+
mac-vendor-lookup>=0.1.12
24
networkx
35
protobuf==4.*
46
publicsuffix2
57
pycountry
68
pymispwarninglists>=1.5
79
requests
810
torf
9-
ulid-py
10-
bbpb
11+
ulid-py

unfurl/parsers/parse_mac_addr.py

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019 Google LLC
1+
# Copyright 2024 Ryan Benson
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,8 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import maclookup
16-
import re
15+
import mac_vendor_lookup
1716
from unfurl import utils
1817

1918
uuid_edge = {
@@ -26,28 +25,25 @@
2625

2726

2827
def run(unfurl, node):
29-
if not node.data_type == 'mac-address':
28+
if node.data_type == 'mac-address':
29+
vendor_lookup = mac_vendor_lookup.MacLookup().lookup(node.value)
30+
if vendor_lookup:
31+
unfurl.add_to_queue(
32+
data_type="mac-address.vendor", key=None, value=vendor_lookup, label=f'Vendor: {vendor_lookup}',
33+
parent_id=node.node_id, incoming_edge_config=uuid_edge)
34+
35+
else:
3036
long_int = utils.long_int_re.fullmatch(str(node.value))
3137
m = utils.mac_addr_re.fullmatch(str(node.value))
3238
if m and not long_int:
3339
u = m.group('mac_addr')
3440

3541
# Check if we need to add colons
3642
if len(u) == 12:
37-
pretty_mac = ':'.join([u[i]+u[i+1] for i in range(0, 12, 2)])
38-
43+
pretty_mac = ':'.join([u[i] + u[i + 1] for i in range(0, 12, 2)])
3944
else:
4045
pretty_mac = u.upper()
4146

4247
unfurl.add_to_queue(
4348
data_type='mac-address', key=None, value=pretty_mac, label=f'MAC address: {pretty_mac}',
4449
parent_id=node.node_id, incoming_edge_config=uuid_edge)
45-
46-
elif node.data_type == 'mac-address' and unfurl.api_keys.get('macaddress_io') and unfurl.remote_lookups:
47-
client = maclookup.ApiClient(unfurl.api_keys.get('macaddress_io'))
48-
vendor_lookup = client.get_vendor(node.value).decode('utf-8')
49-
50-
if vendor_lookup:
51-
unfurl.add_to_queue(
52-
data_type="mac-address.vendor", key=None, value=vendor_lookup, label=f'Vendor: {vendor_lookup}',
53-
parent_id=node.node_id, incoming_edge_config=uuid_edge)

0 commit comments

Comments
 (0)