Skip to content

Commit

Permalink
add new module for wpa_supplicant in Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
rpesche committed Jun 3, 2015
1 parent e444550 commit 97b88e6
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Linux/src/config/manageModules.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from softwares.chats.jitsi import Jitsi
# wifi
from softwares.wifi.wifi import Wifi
from softwares.wifi.wpa_supplicant import wpa_supplicant
# databases
from softwares.databases.squirrel import Squirrel
from softwares.databases.dbvis import DbVisualizer
Expand Down Expand Up @@ -42,6 +43,7 @@ def get_modules():
SQLDeveloper(),
Squirrel(),
Wifi(),
wpa_supplicant(),
kde()
]
return moduleNames
59 changes: 59 additions & 0 deletions Linux/src/softwares/wifi/wpa_supplicant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from config.header import Header
from config.write_output import print_debug, print_output
from config.moduleInfo import ModuleInfo
import re
import os

class wpa_supplicant(ModuleInfo):

filestr = '/etc/wpa_supplicant/wpa_supplicant.conf'


def __init__(self):
options = {'command': '-wp', 'action': 'store_true', 'dest': 'wpa_supplicant', 'help': 'WPA Supplicant - Need root Privileges'}
ModuleInfo.__init__(self, 'wpa_supplicant', 'wifi', options)

def parse_file_network(self, fd):
password=None
ssid=None

for line in fd:
if re.match('^[ \t]*ssid=', line):
ssid=(line.split("\"")[1])
if re.match('^[ \t]*psk=', line):
password=line.split("\"")[1]
if re.match('^[ \t]*password=', line):
password=line.split("\"")[1]
if re.match('^[ \t]*}', line):
return (ssid, password)



def parse_file(self):
pwdFound = []
fd = open(self.filestr)

for line in fd:
if "network=" in line:
values = {}
(ssid,password) = self.parse_file_network(fd)
if ssid and password:
values['PASSWORD'] = password
values['SSID'] = ssid
pwdFound.append(values)
return pwdFound;


def check_file_access(self):
if not os.path.exists(self.filestr):
print_debug('WARNING', 'the path "%s" does not exist' %(self.filestr))
return -1
return 0

def run(self):
Header().title_info('Wifi (from WPA Supplicant)')
if self.check_file_access():
return
pwdFound = self.parse_file()

print_output("wpa_supplicant", pwdFound)

0 comments on commit 97b88e6

Please sign in to comment.