-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLinuxWifi.py
26 lines (20 loc) · 943 Bytes
/
LinuxWifi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
#importing sys module
import sys
#importing module named subprocess
import subprocess
#function to display custom error message if there is wrong usage
def my_except_hook(exctype, value, traceback):
print('Usage: python3', args[0] + ' <SSID>')
sys.excepthook = my_except_hook
#The sys module in Python has the argv functionality. This functionality returns a list of all command-line arguments provided to the python file when triggering an execution of it through terminal.
args = sys.argv
#ACII art
a = '''
+-++-++-++-+ +-++-+ +-++-++-++-++-++-++-+ +-++-++-++-++-+
|c||o||d||e| |b||y| |M||a||n||s||o||o||r| |B||a||r||r||i|
+-++-++-++-+ +-++-+ +-++-++-++-++-++-++-+ +-++-++-++-++-+
'''
print(a)
#running the command to show password for the given wifi ssid
subprocess.run("cd /etc/NetworkManager/system-connections/ && sudo cat " + args[1] + " | grep 'psk=' | awk '{print substr($1,5)}'" , shell=True)