Skip to content

Commit 7ca68ae

Browse files
Merge pull request #30 from Srinivas11789/bigRevamp
The Revamp - Phase 1
2 parents de860a5 + 0aeb5db commit 7ca68ae

28 files changed

+1803
-85
lines changed

.DS_Store

-6 KB
Binary file not shown.

.travis.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
language: python
2+
3+
os:
4+
- linux
5+
6+
addons:
7+
apt:
8+
packages:
9+
- graphviz
10+
- python-tk
11+
- tshark
12+
213
python:
314
- "2.7"
415
- "3.6"
16+
517
matrix:
618
allow_failures:
7-
- python: "3.6"
19+
- python: "2.7"
20+
821
before_install:
9-
- pip install -U pytest pytest-cov
10-
- pip install codecov
11-
- pip install flake8
22+
- pip install -U pytest pytest-cov
23+
- pip install codecov
24+
- pip install flake8
25+
1226
install:
1327
- pip install -r requirements.txt
28+
1429
before_script:
1530
# stop the build if there are Python syntax errors or undefined names
1631
- flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

LICENSE

Lines changed: 339 additions & 21 deletions
Large diffs are not rendered by default.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import memory
2+
3+
# Library Import
4+
import ipwhois
5+
from dns import reversename, resolver
6+
import socket
7+
# Module Import
8+
import pcap_reader
9+
import netaddr
10+
11+
# Class Communication or Traffic Details Fetch
12+
13+
class trafficDetailsFetch():
14+
15+
def __init__(self, option):
16+
for host in memory.destination_hosts:
17+
if not memory.destination_hosts[host]:
18+
if option == "whois":
19+
memory.destination_hosts[host] = self.whois_info_fetch(host)
20+
else:
21+
memory.destination_hosts[host] = self.dns(host)
22+
23+
def whois_info_fetch(self, ip):
24+
try:
25+
whois_info = ipwhois.IPWhois(ip).lookup_rdap()
26+
except:
27+
whois_info = "NoWhoIsInfo"
28+
return whois_info
29+
30+
def dns(self, ip):
31+
try:
32+
dns_info = socket.gethostbyaddr(ip)[0]
33+
except:
34+
dns_info = "NotResolvable"
35+
return dns_info
36+
37+
def main():
38+
capture = pcap_reader.PcapEngine('examples/test.pcap', "scapy")
39+
details = trafficDetailsFetch("sock")
40+
print(memory.destination_hosts)
41+
print("\n")
42+
43+
#main()
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"""
2+
Module device_details
3+
"""
4+
# Library Import
5+
import urllib#.request
6+
import json
7+
import logging
8+
# Module Import
9+
import pcap_reader
10+
import memory
11+
import threading
12+
from netaddr import *
13+
14+
class fetchDeviceDetails:
15+
16+
def __init__(self, option="ieee"):
17+
"""
18+
Init
19+
"""
20+
self.target_oui_database = option
21+
22+
def fetch_info(self):
23+
for ip in memory.lan_hosts:
24+
if self.target_oui_database == "api":
25+
memory.lan_hosts[ip]["device_vendor"] = self.oui_identification_via_api(memory.lan_hosts[ip]["mac"])
26+
else:
27+
memory.lan_hosts[ip]["device_vendor"], memory.lan_hosts[ip]["vendor_address"] = self.oui_identification_via_ieee(memory.lan_hosts[ip]["mac"])
28+
mac = memory.lan_hosts[ip]["mac"].replace(":",".")
29+
if ":" in ip:
30+
ip_san = ip.replace(":",".")
31+
else:
32+
ip_san = ip
33+
memory.lan_hosts[ip]["node"] = ip_san+"\n"+mac+"\n"+memory.lan_hosts[ip]['device_vendor']
34+
35+
def oui_identification_via_api(self, mac):
36+
url = "http://macvendors.co/api/" + mac
37+
api_request = urllib.request.Request(url, headers={'User-Agent':'PcapXray'})
38+
try:
39+
apiResponse = urllib.request.urlopen(api_request)
40+
details = json.loads(apiResponse.read())
41+
#reportThread = threading.Thread(target=reportGen.reportGen().deviceDetailsReport,args=(details,))
42+
#reportThread.start()
43+
return details["result"]["company"], details["result"]["address"]
44+
except Exception as e:
45+
logging.info("device_details module: oui identification failure via api" + str(e))
46+
return "Unknown", "Unknown"
47+
48+
def oui_identification_via_ieee(self, mac):
49+
try:
50+
mac_obj = EUI(mac)
51+
mac_oui = mac_obj.oui
52+
return mac_oui.registration().org, mac_oui.registration().address
53+
except Exception as e:
54+
logging.info("device_details module: oui identification failure via ieee " + str(e))
55+
return "Unknown", "Unknown"
56+
57+
def main():
58+
filename = "test.pcap"
59+
pcap_reader.PcapEngine('examples/test.pcap', "scapy")
60+
fetchDeviceDetails("ieee").fetch_info()
61+
print(memory.lan_hosts)
62+
63+
#main()
64+
65+
# MAC Oui Identification Module
66+
# LAN IP and Getway Identification
6.86 MB
Binary file not shown.
6.86 MB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)