-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
inet_info.py
24 lines (19 loc) Β· 891 Bytes
/
inet_info.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
from colorama import Fore, Style
import subprocess
import re
from file_handler import FileHandler
class InetInfo:
@staticmethod
def get_info(listener_file_path):
def get_ip(info_raw):
match = re.search(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', info_raw)
return match.group() if match else "π΄"
eth0_info_raw = subprocess.getoutput("ifconfig eth0")
wlan0_info_raw = subprocess.getoutput("ifconfig wlan0")
eth0_info = get_ip(eth0_info_raw)
wlan0_info = get_ip(wlan0_info_raw)
listener_info = FileHandler.read_file(listener_file_path)
print(Fore.MAGENTA + " Network πΆ" + Style.RESET_ALL)
print(Fore.GREEN + " eth0: " + Style.RESET_ALL, eth0_info)
print(Fore.YELLOW + " wlan0: " + Style.RESET_ALL, wlan0_info)
print(Fore.CYAN + " Listener: " + Style.RESET_ALL, listener_info)