Skip to content

Commit 2426f20

Browse files
committed
added an option set a static ip for access-point
1 parent f76d486 commit 2426f20

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ChangeLog
22

3+
### 0.7.17
4+
- ADDED: Added a static IP option for access point
5+
36
### 0.7.16
47
- ADDED: Added option to create Hotspot for proxy (AP)
58

mpt/config.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
from os.path import expanduser
55

6+
import netifaces
67
from simple_term_menu import TerminalMenu
78

89
from mpt import logger
@@ -16,6 +17,7 @@
1617
CONFIG_ITEMS = {'pentest-dir', 'app', 'package-name', 'proxy', 'install-dir', 'access-point'}
1718
PROXY_PORT = '8080'
1819
PROXY_SERVER = '127.0.0.1'
20+
ACCESS_POINT_IP = '192.168.75.1'
1921

2022

2123
def singleton(cls):
@@ -152,6 +154,7 @@ def load(self):
152154
self.config_dict.update({conf: ""})
153155

154156
self.config_dict.update({'proxy': {'host': PROXY_SERVER, 'port': PROXY_PORT}})
157+
# access point configuration is set in console.configure_access_point()
155158

156159
self.__write_config(self.config_dict)
157160
self.log.debug(f'Configuration file {self.config_path} created')
@@ -212,3 +215,28 @@ def get_custom_tool_dir(self, tool_dir):
212215
return tmp_tool_dir
213216
else:
214217
return self.get_custom_tool_dir(tmp_tool_dir)
218+
219+
def get_uniq_ip_for_ap(self, ip, interface_ips):
220+
if ip not in interface_ips:
221+
return ip
222+
else:
223+
# generate a new ip 192.168. <int>+1 .1
224+
ip_new_inc = ip.split('.')
225+
ip_new_inc[2] = str(int(ip_new_inc[2]) + 1)
226+
ip_new = '.'.join(ip_new_inc)
227+
return self.get_uniq_ip_for_ap(ip_new, interface_ips)
228+
229+
def get_default_access_point_ip(self):
230+
231+
interfaces = netifaces.interfaces()
232+
interfaces.remove('lo')
233+
234+
interface_ips = []
235+
for interface in interfaces:
236+
addrs = netifaces.ifaddresses(interface)
237+
238+
if netifaces.AF_INET in addrs.keys():
239+
interface_ips.append(addrs[netifaces.AF_INET][0]['addr'])
240+
241+
return self.get_uniq_ip_for_ap(ACCESS_POINT_IP, interface_ips)
242+

mpt/console.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from mpt import functions
1616

17-
__version__ = '0.7.16'
17+
__version__ = '0.7.17'
1818

1919
from mpt import settings, logger
2020
from mpt.config import Config
@@ -722,11 +722,14 @@ def configure_access_point():
722722

723723
ap_name = functions.generate_funny_wifi_name()
724724
ap_password = functions.generate_wifi_password()
725+
ap_ip = conf.get_default_access_point_ip()
725726

726-
conf.update('access-point', {'internet-interface': internet_interface, 'ap-interface': ap_interface, 'name': ap_name, 'password': ap_password})
727+
conf.update('access-point', {'internet-interface': internet_interface, 'ap-interface': ap_interface, 'ap-ip': ap_ip, 'name': ap_name, 'password': ap_password})
727728
log.info(f"* WiFi SSID: {ap_name}")
728729
log.info(f"* AP Interface: {ap_interface}")
729730
log.info(f"* Default Gateway: {internet_interface}")
731+
log.info(f"* IP: {ap_ip}")
732+
log.warn(f"Configure Burp to set a proxy listener on the IP: {ap_ip}")
730733
log.success('Access point configured')
731734

732735

@@ -742,10 +745,18 @@ def access_point():
742745
log.warn("sudo ./lnxrouter -o <WiFi-Internet> --ap <AP-WiFi> <SSID> -p <Password> --qr")
743746
log.info(f"AP WiFi SSID: {access_point_conf['name']}")
744747
log.info(f"Connect your device to {access_point_conf['name']} with password {access_point_conf['password']}")
745-
functions.run_command(command=
746-
f'{linux_router_bin} -o {access_point_conf['internet-interface']} '
747-
f'--ap {access_point_conf['ap-interface']} {access_point_conf['name']} -p "{access_point_conf['password']}" --qr',
748-
print_output=True)
748+
log.warn(f"Configure Burp to set a proxy listener on the IP: {Fore.CYAN}{access_point_conf['ap-ip']}{Style.RESET_ALL}")
749+
try:
750+
log.info("Press Ctrl+C to interrupt this script.")
751+
functions.run_command(command=
752+
f'{linux_router_bin} -g {access_point_conf['ap-ip']} -o {access_point_conf['internet-interface']} '
753+
f'--ap {access_point_conf['ap-interface']} {access_point_conf['name']} -p "{access_point_conf['password']}" --qr',
754+
print_output=True)
755+
756+
except KeyboardInterrupt:
757+
log.warn('Canceled by user')
758+
log.warn('Access point deactivated')
759+
749760
else:
750761
configure_access_point()
751762

0 commit comments

Comments
 (0)