diff --git a/CHANGELOG.md b/CHANGELOG.md index b41bf7b..b565571 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # ChangeLog +### 0.7.17 +- ADDED: Added a static IP option for access point + ### 0.7.16 - ADDED: Added option to create Hotspot for proxy (AP) diff --git a/mpt/config.py b/mpt/config.py index 078739a..ee21119 100644 --- a/mpt/config.py +++ b/mpt/config.py @@ -3,6 +3,7 @@ import sys from os.path import expanduser +import netifaces from simple_term_menu import TerminalMenu from mpt import logger @@ -16,6 +17,7 @@ CONFIG_ITEMS = {'pentest-dir', 'app', 'package-name', 'proxy', 'install-dir', 'access-point'} PROXY_PORT = '8080' PROXY_SERVER = '127.0.0.1' +ACCESS_POINT_IP = '192.168.75.1' def singleton(cls): @@ -152,6 +154,7 @@ def load(self): self.config_dict.update({conf: ""}) self.config_dict.update({'proxy': {'host': PROXY_SERVER, 'port': PROXY_PORT}}) + # access point configuration is set in console.configure_access_point() self.__write_config(self.config_dict) self.log.debug(f'Configuration file {self.config_path} created') @@ -212,3 +215,28 @@ def get_custom_tool_dir(self, tool_dir): return tmp_tool_dir else: return self.get_custom_tool_dir(tmp_tool_dir) + + def get_uniq_ip_for_ap(self, ip, interface_ips): + if ip not in interface_ips: + return ip + else: + # generate a new ip 192.168. +1 .1 + ip_new_inc = ip.split('.') + ip_new_inc[2] = str(int(ip_new_inc[2]) + 1) + ip_new = '.'.join(ip_new_inc) + return self.get_uniq_ip_for_ap(ip_new, interface_ips) + + def get_default_access_point_ip(self): + + interfaces = netifaces.interfaces() + interfaces.remove('lo') + + interface_ips = [] + for interface in interfaces: + addrs = netifaces.ifaddresses(interface) + + if netifaces.AF_INET in addrs.keys(): + interface_ips.append(addrs[netifaces.AF_INET][0]['addr']) + + return self.get_uniq_ip_for_ap(ACCESS_POINT_IP, interface_ips) + diff --git a/mpt/console.py b/mpt/console.py index 991941b..f8bf1a0 100644 --- a/mpt/console.py +++ b/mpt/console.py @@ -14,7 +14,7 @@ from mpt import functions -__version__ = '0.7.16' +__version__ = '0.7.17' from mpt import settings, logger from mpt.config import Config @@ -722,11 +722,14 @@ def configure_access_point(): ap_name = functions.generate_funny_wifi_name() ap_password = functions.generate_wifi_password() + ap_ip = conf.get_default_access_point_ip() - conf.update('access-point', {'internet-interface': internet_interface, 'ap-interface': ap_interface, 'name': ap_name, 'password': ap_password}) + conf.update('access-point', {'internet-interface': internet_interface, 'ap-interface': ap_interface, 'ap-ip': ap_ip, 'name': ap_name, 'password': ap_password}) log.info(f"* WiFi SSID: {ap_name}") log.info(f"* AP Interface: {ap_interface}") log.info(f"* Default Gateway: {internet_interface}") + log.info(f"* IP: {ap_ip}") + log.warn(f"Configure Burp to set a proxy listener on the IP: {ap_ip}") log.success('Access point configured') @@ -742,10 +745,18 @@ def access_point(): log.warn("sudo ./lnxrouter -o --ap -p --qr") log.info(f"AP WiFi SSID: {access_point_conf['name']}") log.info(f"Connect your device to {access_point_conf['name']} with password {access_point_conf['password']}") - functions.run_command(command= - f'{linux_router_bin} -o {access_point_conf['internet-interface']} ' - f'--ap {access_point_conf['ap-interface']} {access_point_conf['name']} -p "{access_point_conf['password']}" --qr', - print_output=True) + log.warn(f"Configure Burp to set a proxy listener on the IP: {Fore.CYAN}{access_point_conf['ap-ip']}{Style.RESET_ALL}") + try: + log.info("Press Ctrl+C to interrupt this script.") + functions.run_command(command= + f'{linux_router_bin} -g {access_point_conf['ap-ip']} -o {access_point_conf['internet-interface']} ' + f'--ap {access_point_conf['ap-interface']} {access_point_conf['name']} -p "{access_point_conf['password']}" --qr', + print_output=True) + + except KeyboardInterrupt: + log.warn('Canceled by user') + log.warn('Access point deactivated') + else: configure_access_point()