-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathviewer.py
54 lines (45 loc) · 1.01 KB
/
viewer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
## this isn't a live updating viewer. i might write one eventually, but use this for now
from scapy.all import *
import sqlite3
import config
from analyzers import util
conn = sqlite3.connect(config.DATABASE)
def disp_host(mac):
c = conn.cursor()
mac = util.standardize_mac(mac)
manuf = None
c.execute("SELECT manuf FROM macaddrs WHERE mac=?",(mac,))
r = c.fetchall()
if r:
manuf = r[0][0]
ip = None
c.execute("SELECT ip FROM ipaddrs WHERE mac=?",(mac,))
r = c.fetchall()
if r:
ip = r[0][0]
hn = None
if ip:
c.execute("SELECT hostname FROM hostnames WHERE ip=?",(ip,))
r = c.fetchall()
if r:
hn = r[0][0]
os = None
c.execute("SELECT os FROM opsys WHERE mac=?",(mac,))
r = c.fetchall()
if r:
os = r[0][0]
if not hn:
return
print '-='*30 + '-'
print "mac:",util.pprint_mac(mac)
print "manuf:",manuf
print "ip:",ip
print "hostname:",hn
print "os:",os
def disp_all():
c = conn.cursor()
c.execute("SELECT mac FROM macaddrs")
for m in c.fetchall():
disp_host(m[0])
disp_all()
conn.close()