mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Add a interactive configuration installer
This commit is contained in:
@ -133,6 +133,8 @@ if __name__ == '__main__':
|
||||
help="Print the configuration.")
|
||||
|
||||
# Jayofelony added these
|
||||
parser.add_argument('--install', dest="install", action="store_true", default=False,
|
||||
help="Interactive installation of your personal configuration.")
|
||||
parser.add_argument('--check-update', dest="check_update", action="store_true", default=False,
|
||||
help="Check for updates on Pwnagotchi. And tells current version.")
|
||||
parser.add_argument('--donate', dest="donate", action="store_true", default=False,
|
||||
@ -157,6 +159,71 @@ if __name__ == '__main__':
|
||||
print(pwnagotchi.__version__)
|
||||
sys.exit(0)
|
||||
|
||||
if args.install:
|
||||
pwn_check = input("This will create a new configuration file and backup your current one, are you sure? [y/n]")
|
||||
if pwn_check.lower() in ('y', 'yes'):
|
||||
pwn_restore = input("Do you want to restore the previous configuration? [y/n]")
|
||||
if pwn_restore in ('y', 'yes'):
|
||||
os.system("mv -f /etc/pwnagotchi/config.toml.bak /etc/pwnagotchi.config.toml")
|
||||
else:
|
||||
os.system("mv -f /etc/pwnagotchi/config.toml /etc/pwnagotchi/config.toml.bak")
|
||||
with open("/etc/pwnagotchi/config.toml", "a+") as f:
|
||||
# Set pwnagotchi name
|
||||
print("Welcome to the interactive installation of your personal Pwnagotchi configuration!\n"
|
||||
"My name is Jayofelony, how may I call you? ")
|
||||
pwn_name = input("Pwnagotchi name (no spaces):")
|
||||
if pwn_name == "":
|
||||
pwn_name = "Pwnagotchi"
|
||||
print("I shall go by Pwnagotchi from now on!")
|
||||
pwn_name = ("# Do not edit this file if you do not know what you are doing!!!\n\n"
|
||||
"main.name = \"") + pwn_name + "\"\n"
|
||||
f.write(pwn_name)
|
||||
else:
|
||||
print("I shall go by %s from now on!", pwn_name)
|
||||
pwn_name = "main.name = " + pwn_name + "\"\n"
|
||||
f.write(pwn_name)
|
||||
pwn_whitelist = input("How many networks do you want to whitelist? "
|
||||
"We will also ask a MAC for each network?\n"
|
||||
"Each SSID and BSSID count as 1 network. \n\n"
|
||||
"Be sure to use digits as your answer.")
|
||||
if int(pwn_whitelist) > 0:
|
||||
f.write("main.whitelist = [\n")
|
||||
for x in range(int(pwn_whitelist)):
|
||||
ssid = input("SSID (Name):")
|
||||
bssid = input("BSSID (MAC):")
|
||||
f.write("\t\"" + ssid + "\"\n")
|
||||
f.write("\t\"" + bssid + "\"\n")
|
||||
f.write("]\n")
|
||||
# set bluetooth tether
|
||||
pwn_bluetooth = input("Do you want to enable BT-Tether? [y/n]")
|
||||
if pwn_bluetooth.lower() in ('y', 'yes'):
|
||||
f.write("main.plugins.bt-tether.enabled = true\n\n")
|
||||
pwn_bluetooth_device = input("What device do you use? Android or iOS?")
|
||||
if pwn_bluetooth_device.lower() == "android":
|
||||
f.write("main.plugins.bt-tether.devices.android-phone.enabled = true\n")
|
||||
pwn_bluetooth_mac = input("What is the Bluetooth MAC of your device?")
|
||||
if pwn_bluetooth_mac is not "":
|
||||
f.write("main.plugins.bt-tether.devices.android-phone.mac = \""+pwn_bluetooth_mac+"\"\n")
|
||||
elif pwn_bluetooth_device.lower() == "ios":
|
||||
f.write("main.plugins.bt-tether.devices.ios-phone.enabled = true\n")
|
||||
pwn_bluetooth_mac = input("What is the Bluetooth MAC of your device?")
|
||||
if pwn_bluetooth_mac is not "":
|
||||
f.write("main.plugins.bt-tether.devices.android-phone.mac = \"" + pwn_bluetooth_mac + "\"\n")
|
||||
# set up display settings
|
||||
pwn_display_enabled = input("Do you use a display? [y/n]")
|
||||
if pwn_display_enabled.lower() in ('y,', 'yes'):
|
||||
f.write("ui.display.enabled = true\n")
|
||||
pwn_display_type = input("What display do you use?\n\n"
|
||||
"Be sure to check for the correct display type @ \n"
|
||||
"https://github.com/jayofelony/pwnagotchi/blob/master/pwnagotchi/utils.py#L240-L431")
|
||||
if pwn_display_type is not "":
|
||||
f.write("ui.display.type = \""+pwn_display_type+"\"\n")
|
||||
f.close()
|
||||
print("Your configuration is done, and I will restart in 5 seconds.")
|
||||
time.sleep(5)
|
||||
os.system("service pwnagotchi restart")
|
||||
sys.exit(0)
|
||||
|
||||
if args.donate:
|
||||
print("Donations can made @ \n "
|
||||
"https://www.patreon.com/pwnagotchi_torch \n "
|
||||
@ -172,7 +239,7 @@ if __name__ == '__main__':
|
||||
local = version_to_tuple(pwnagotchi.__version__)
|
||||
remote = version_to_tuple(latest_ver)
|
||||
if remote > local:
|
||||
user_input = input("There is a new version available! Update from v%s to v%s?\n[y(es)/n(o)]"
|
||||
user_input = input("There is a new version available! Update from v%s to v%s?\n[y/n]"
|
||||
% (pwnagotchi.__version__, latest_ver))
|
||||
# input validation
|
||||
if user_input.lower() in ('y', 'yes'):
|
||||
|
Reference in New Issue
Block a user