Skip to content

Commit

Permalink
added an option set a static ip for access-point
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteSnipers committed Dec 29, 2024
1 parent f76d486 commit 2426f20
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
28 changes: 28 additions & 0 deletions mpt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
from os.path import expanduser

import netifaces
from simple_term_menu import TerminalMenu

from mpt import logger
Expand All @@ -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):
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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. <int>+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)

23 changes: 17 additions & 6 deletions mpt/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')


Expand All @@ -742,10 +745,18 @@ def access_point():
log.warn("sudo ./lnxrouter -o <WiFi-Internet> --ap <AP-WiFi> <SSID> -p <Password> --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()

Expand Down

0 comments on commit 2426f20

Please sign in to comment.