I am facing trouble with a code that I am working on.
#1 code
#! /usr/bin/python3 import os import time CardNme = input("Enter name: ") print("Changing " + CardNme + " to monitor mode") time.sleep(0.05) os.system("ifconfig " + CardNme + " down && airmon-ng check kill && iwconfig " + CardNme + " mode monitor && ifconfig " + CardNme + " up") exit(0)
#2 code
#!/usr/bin/python3 import os import sys import time print("Enabling Moniter mode") time.sleep(0.5) os.system("./start.py") os.system("wlan0")
Now like the situation is that I want to use #1 code in #2 code, but as the #1 code doesn’t have arguments, i cant do ./start.py -i wlan0
or anything like that. Is there any other way round? Or just arguments.
Note: I lack the knowledge to use arguments in python
Advertisement
Answer
Change the first script to get the interface name from sys.argv
. If that’s not supplied, it can prompt.
#! /usr/bin/python3 import os import time import sys if len(sys.argv) > 1: CardNme = sys.argv[1] else: CardNme = input("Enter name: ") print("Changing " + CardNme + " to monitor mode") time.sleep(0.05) os.system("ifconfig " + CardNme + " down && airmon-ng check kill && iwconfig " + CardNme + " mode monitor && ifconfig " + CardNme + " up")
Then change the second script to supply wlan0
as an argument
#!/usr/bin/python3 import os import sys import time print("Enabling Moniter mode") time.sleep(0.5) os.system("./start.py wlan0")