Skip to content

Commit

Permalink
Scan based on interface (#29)
Browse files Browse the repository at this point in the history
* Scan based on interface

* pylint

* Fix show info glitch
  • Loading branch information
rllola authored Dec 24, 2020
1 parent 61e49d5 commit ceb033b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion airbnb-scanner.pdy

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions src/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from about import AboutWidget
from device_info import DeviceInfoWidget
from utils import get_ip_mask

# pylint: disable=too-many-instance-attributes
class Application(QApplication):
Expand All @@ -23,6 +24,9 @@ def __init__(self, *args, **kwargs):
self.about_window = AboutWidget()
self.device_info = DeviceInfoWidget()

# Get Ip mask to scan on
self.ip_mask = get_ip_mask()

print("Creating menu...")
# TODO: Create a menu class
# BODY: Create a menu class to make Application class lighter.
Expand All @@ -34,8 +38,6 @@ def __init__(self, *args, **kwargs):
self.quit_action = self.menu.addAction("Quit")
self.quit_action.triggered.connect(self.quit)

self.keks = []

prefix_path = "."

if ":/" in sys.path:
Expand Down Expand Up @@ -68,15 +70,16 @@ def __init__(self, *args, **kwargs):
self.tray.show()

# We are scanning local IP
self.scan('192.168.1.0/24')
self.scan(self.ip_mask)

def rescan(self):
"""
rescan the network
"""
self.device_menu.clear()
self.scan('192.168.1.0/24')
self.scan(self.ip_mask)

# pylint: disable=too-many-locals
def scan(self, ip_mask):
"""
scan local network
Expand Down Expand Up @@ -112,11 +115,19 @@ def scan(self, ip_mask):
if warning:
device_action.setIcon(self.warning_icon)

def triggered_info(client_ip, client_mac, company):
self.device_info.show_info(
client_ip,
client_mac,
company)

device_action.triggered.connect(
lambda: self.device_info.show_info(
client_dict["ip"],
client_dict["mac"],
company_name))
lambda x,
client_ip=client_dict["ip"],
client_mac=client_dict["mac"],
company=company_name:
triggered_info(client_ip, client_mac, company)
)


clients_list.append(client_dict)
Expand Down
2 changes: 1 addition & 1 deletion src/info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.2.0"
__version__ = "0.3.0"
__author__ = "Lola Rigaut-Luczak"
__email__ = "[email protected]"
__github__ = "https://github.com/rllola/airbnb-scanner"
10 changes: 10 additions & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# pylint: disable=import-error
import scapy.all as scapy

def get_ip_mask():
"""Get the ip mask to scan on"""
ip_interface = scapy.get_if_addr(scapy.conf.iface).split('.')
ip_interface[3] = "0"
ip_mask = '.'.join(ip_interface) + '/24'

return ip_mask

0 comments on commit ceb033b

Please sign in to comment.