Comments (3)
def oui_lookup(mac_addr='00:00:00:00:00:00', nmap_os_db='/usr/local/share/nmap/nmap-mac-prefixes'):
"""
Lookup a vendor from the Nmap MAC Prefixes file
>>> oui_lookup('00:00:00:00:00:00')
'Xerox'
>>> oui_lookup('00-00-00-00-00-00')
'Xerox'
>>> oui_lookup(-1)
'Unknown'
>>> oui_lookup('00:00:00:00:00:00', nmap_os_db='/zxvkjaiwe/9234123/zxcvzxvsadf')
'Unknown'
"""
import os
import mmap
try:
oui_fs = open(nmap_os_db, "r")
except IOError, err:
return dict(mac_addr='Unknown')
oui_data = mmap.mmap(oui_fs.fileno(), 0, access=mmap.ACCESS_READ)
def _lookup(mac_addr, oui_data):
oui_result = 'Unknown'
# remove : or - or just accept it as is and be lucky
if mac_addr.find(':') > -1:
mac_lookup = "".join(mac_addr.split(':')[:3])
else:
mac_lookup = "".join(mac_addr.split('-')[:3])
if len(mac_lookup) == 6:
# MAC addresses in nmap db are in upper case and we want start of line (post \n)
location = oui_data.find('\n' + mac_lookup.upper())
location += 1 # remove leading \n
if location > 0:
oui_result = oui_data[location+7:location+oui_data[location:].find('\n')]
return oui_result
result = {}
if isinstance(mac_addr, list):
for addr in mac_addr:
result[addr] = _lookup(addr, oui_data)
if isinstance(mac_addr, str):
result[mac_addr] = _lookup(mac_addr, oui_data)
return result
from kvasir.
In controllers/hosts.py:detail():
if record.f_macaddr:
oui_res = oui_lookup(record.f_macaddr)
oui_vendor = oui_res.get(record.f_macaddr, oui_res.get('error', 'None'))
else:
oui_vendor = 'None'
add oui_vendor to return dict() and {{=oui_vendor}} to views/hosts/detail.html page.
from kvasir.
added in 50ad129
from kvasir.
Related Issues (20)
- Severity mappings are wicked wrong
- Host lookup in service formatting fails HOT 3
- Memory Leak Issue HOT 4
- pyDal changes Row() HOT 2
- Host doesn't get updated with vulns
- Nexpose import Install/Update VulnData fails everytime HOT 7
- Support Evidence without a file
- default/redirect should be default/url_redirect
- AttributeError: 'NoneType' object has no attribute 'isdigit' HOT 5
- Metasploit xml import does not make any change
- Nessun controller issue: ImportError: Cannot import module 'applications.test.modules.requests' HOT 1
- Hash import error
- tasks sticking at Queued
- Vulnerabilities import to Kvasir
- nmap.py node.hostscripts not working
- NexposeAPI SiteSaveRequest failure
- CANVAS exploit provenance? HOT 5
- kvasir not working
- kvsair name 'settings' is not defined
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kvasir.