Skip to content

Commit c8f1154

Browse files
committed
show device info in a table
1 parent c560ef8 commit c8f1154

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

anzu/templates/public/alerts.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<h1 class="mt-5">Current Alerts</h1>
66
{% for alert in alerts %}
77
<div class="row">
8-
<p class="lead">{{ alert }}</p>
8+
<p class="lead">{{ alert.timestamp }}</p>
99
</div>
1010
{% endfor %}
1111
</div>

anzu/templates/public/devices.html

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,25 @@
33
{% block content %}
44
<div class="container">
55
<h1 class="mt-5">Devices running in your network</h1>
6-
{% for device in devices %}
76
<div class="row">
8-
<p class="lead">{{ device }}</p>
9-
</div>
10-
{% endfor %}
7+
<table class="table">
8+
<thead>
9+
<tr>
10+
<th scope="col">MAC</th>
11+
<th scope="col">IP</th>
12+
<th scope="col">Manufacturer</th>
13+
</tr>
14+
</thead>
15+
<tbody>
16+
{% for device in devices %}
17+
<tr>
18+
<th scope="row">{{ device.mac }}</th>
19+
<td>{{ device.ip }}</td>
20+
<td>{{ device.manuf }}</td>
21+
</tr>
22+
{% endfor %}
23+
</tbody>
24+
</table>
25+
</div>
1126
</div>
1227
{% endblock %}

anzu/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def detect_devices():
6262
packet = ether/arp
6363
result = scapy.srp(packet, timeout=3, verbose=False)[0]
6464
for sent, received in result:
65-
device_type = get_device_info_by_mac(received.hwsrc)
66-
devices.append({'ip': received.psrc, 'mac': received.hwsrc, 'device manufacturer': device_type if device_type is not None else "Unknown"})
65+
manuf = get_device_info_by_mac(received.hwsrc)
66+
devices.append({'ip': received.psrc, 'mac': received.hwsrc, 'device manufacturer': manuf if manuf is not None else "Unknown"})
6767
return devices
6868

6969
# def detect_devices():
@@ -77,11 +77,11 @@ def detect_devices():
7777
# mac_address = received.hwsrc
7878
# existing_device = Device.query.filter_by(mac_address=mac_address).first()
7979
# if not existing_device:
80-
# device_type = get_device_info_by_mac(mac_address)
81-
# new_device = Device(mac_address=mac_address, device_type=device_type if device_type else "Unknown")
80+
# manuf = get_device_info_by_mac(mac_address)
81+
# new_device = Device(mac_address=mac_address, manuf=manuf if manuf else "Unknown")
8282
# db.session.add(new_device)
8383
# db.session.commit()
84-
# devices.append({'ip': received.psrc, 'mac': mac_address, 'device manufacturer': device_type if device_type else "Unknown"})
84+
# devices.append({'ip': received.psrc, 'mac': mac_address, 'device manufacturer': manuf if manuf else "Unknown"})
8585
# return devices
8686

8787
def read_suricata_alerts():

0 commit comments

Comments
 (0)