davidbombal / red-python-scripts

MIT License
1.99k stars 1.58k forks source link

I have done small correction in the script #46

Open abidmaria opened 1 year ago

abidmaria commented 1 year ago

I have done small correction on David Bombal's script ( to fetch all the adapters [ if they available] not only the first adapter e.g wlan0 ) below is the correction :

pattern = r'^wlan[0-9]+' check_wifi_result = subprocess.run(["iwconfig"], capture_output=True).stdout.decode()

wifi_adapters = re.findall(pattern,check_wifi_result,re.MULTILINE)

if len(wifi_adapters) == 0: print("Please connect a WiFi adapter and try again.") exit()

print("The following WiFi interfaces are available:") for index, item in enumerate(wifi_adapters): print(f"{index} - {item}")