forked from AlessandroZ/LaZagne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wifi - System privileges not require anymore
- Loading branch information
1 parent
2990642
commit 71ae178
Showing
5 changed files
with
199 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
|
||
class constant(): | ||
folder_name = 'results' | ||
MAX_HELP_POSITION = 27 | ||
CURRENT_VERSION = 0.1 | ||
output = None | ||
file_logger = None | ||
|
||
# jitsi options | ||
jitsi_masterpass = None | ||
|
||
# mozilla options | ||
isInteractive = False | ||
manually = None | ||
path = None | ||
bruteforce = None | ||
defaultpass = None | ||
specific_path = None | ||
mozilla_software = '' | ||
|
||
# ie options | ||
ie_historic = None | ||
|
||
# total password found | ||
nbPasswordFound = 0 | ||
|
||
class constant(): | ||
folder_name = 'results' | ||
MAX_HELP_POSITION = 27 | ||
CURRENT_VERSION = 0.2 | ||
output = None | ||
file_logger = None | ||
|
||
# jitsi options | ||
jitsi_masterpass = None | ||
|
||
# mozilla options | ||
isInteractive = False | ||
manually = None | ||
path = None | ||
bruteforce = None | ||
defaultpass = None | ||
specific_path = None | ||
mozilla_software = '' | ||
|
||
# ie options | ||
ie_historic = None | ||
|
||
# total password found | ||
nbPasswordFound = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,119 @@ | ||
from constant import constantfrom time import gmtime, strftimeimport os, getpass, socketimport loggingimport WConiofrom config.header import Header# --------------------------- Functions used to write ---------------------------def write_header(): time = strftime("%Y-%m-%d %H:%M:%S", gmtime()) header = '''|====================================================================|\r\n| |\r\n| Credentsials discovery |\r\n| |\r\n| ! BANG BANG ! |\r\n| |\r\n|====================================================================|\r\n\r\n- Date: ''' + time + '''\n\r- Username: ''' + getpass.getuser() + ''' \r\n- Hostname: ''' + socket.gethostname() + ''' \r\n\r\n------------------------------ Results ------------------------------\r\n\r\n''' open(constant.folder_name + os.sep + 'credentials.txt',"a+b").write(header)def write_footer(): footer = '\n[+] %s passwords have been found.\nFor more information launch it again with the -v option\n\n' % str(constant.nbPasswordFound) open(constant.folder_name + os.sep + 'credentials.txt',"a+b").write(footer) def write_credentials(pwdFound, category): tmp = "############ %s passwords ############\r\n\r\n" % category for pwd in pwdFound: for p in pwd.keys(): tmp = str(tmp) + str(p) + ": " + str(pwd[p]) + "\r\n" tmp = str(tmp) + "\r\n" open(constant.folder_name + os.sep + 'credentials.txt',"a+b").write(tmp) def checks_write(values, category): if values: if constant.output == 'txt': try: write_credentials(values, category) logging.info('[+] Credentials stored successfully on the file: %s\\credentials.txt\n' % constant.folder_name) except: logging.info('Couldn\'t write the results file\n')# --------------------------- End of functions used to write ---------------------------# --------------------------- Output functions ---------------------------def print_footer(): footer = '\n[+] %s passwords have been found.\nFor more information launch it again with the -v option\n' % str(constant.nbPasswordFound) logging.info(footer)# print output if passwords have been founddef print_output(software_name, pwdFound): if pwdFound: # if the debug logging level is not apply => print the title if logging.getLogger().isEnabledFor(logging.DEBUG) == False: Header().title_info(software_name) toWrite = [] for pwd in pwdFound: lower_list = [s.lower() for s in pwd.keys()] password = [s for s in lower_list if "password" in s] key = [s for s in lower_list if "key" in s] # for the wifi # No password found if not password and not key: print_debug("FAILED", "Password not found !!!") else: print_debug("OK", "Password found !!!") toWrite.append(pwd) constant.nbPasswordFound += 1 for p in pwd.keys(): logging.info("%s: %s" % (p, pwd[p])) print # write credentials into a text file checks_write(toWrite, software_name) else: logging.debug("[!] No passwords found\n")def print_error(message): WConio.textcolor(WConio.LIGHTRED) logging.debug('[!] %s\n' % message) WConio.textcolor(WConio.LIGHTGREY)# def print_debug(message): # logging.debug('[!] %s\n' % message) def print_debug(error_level, message): if error_level == 'ERROR': WConio.textcolor(WConio.LIGHTRED) logging.debug('[ERROR] %s\n' % message) WConio.textcolor(WConio.LIGHTGREY) elif error_level == 'INFO': logging.debug('[INFO] %s\n' % message) # print when password is not found elif error_level == 'FAILED': WConio.textcolor(WConio.LIGHTRED) logging.info(message) WConio.textcolor(WConio.LIGHTGREY) # print when password is found elif error_level == 'OK': WConio.textcolor(WConio.GREEN) logging.info(message) WConio.textcolor(WConio.LIGHTGREY) elif error_level == 'DEBUG': logging.debug('%s\n' % message) else: logging.debug('[%s] %s' % (error_level, message))# --------------------------- End of output functions --------------------------- | ||
from constant import constant | ||
from time import gmtime, strftime | ||
import os, getpass, socket | ||
import logging | ||
import WConio | ||
from config.header import Header | ||
|
||
# --------------------------- Functions used to write --------------------------- | ||
|
||
def write_header(): | ||
time = strftime("%Y-%m-%d %H:%M:%S", gmtime()) | ||
header = '''|====================================================================|\r\n | ||
| |\r\n | ||
| Credentsials discovery |\r\n | ||
| |\r\n | ||
| ! BANG BANG ! |\r\n | ||
| |\r\n | ||
|====================================================================|\r\n\r\n | ||
- Date: ''' + time + '''\n\r | ||
- Username: ''' + getpass.getuser() + ''' \r\n | ||
- Hostname: ''' + socket.gethostname() + ''' \r\n\r\n | ||
------------------------------ Results ------------------------------\r\n\r\n''' | ||
|
||
open(constant.folder_name + os.sep + 'credentials.txt',"a+b").write(header) | ||
|
||
def write_footer(): | ||
footer = '\n[+] %s passwords have been found.\r\nFor more information launch it again with the -v option\r\n\r\n' % str(constant.nbPasswordFound) | ||
open(constant.folder_name + os.sep + 'credentials.txt',"a+b").write(footer) | ||
|
||
def write_credentials(pwdFound, category): | ||
tmp = "############ %s passwords ############\r\n\r\n" % category | ||
for pwd in pwdFound: | ||
for p in pwd.keys(): | ||
tmp = str(tmp) + str(p) + ": " + str(pwd[p]) + "\r\n" | ||
tmp = str(tmp) + "\r\n" | ||
open(constant.folder_name + os.sep + 'credentials.txt',"a+b").write(tmp) | ||
|
||
def checks_write(values, category): | ||
if values: | ||
if constant.output == 'txt': | ||
try: | ||
write_credentials(values, category) | ||
logging.info('[+] Credentials stored successfully on the file: %s\\credentials.txt\n' % constant.folder_name) | ||
except: | ||
logging.info('Couldn\'t write the results file\n') | ||
|
||
# --------------------------- End of functions used to write --------------------------- | ||
|
||
# --------------------------- Output functions --------------------------- | ||
def print_footer(): | ||
footer = '\n[+] %s passwords have been found.\nFor more information launch it again with the -v option\n' % str(constant.nbPasswordFound) | ||
logging.info(footer) | ||
|
||
# print output if passwords have been found | ||
def print_output(software_name, pwdFound): | ||
if pwdFound: | ||
# if the debug logging level is not apply => print the title | ||
if logging.getLogger().isEnabledFor(logging.DEBUG) == False: | ||
Header().title_info(software_name) | ||
|
||
toWrite = [] | ||
for pwd in pwdFound: | ||
lower_list = [s.lower() for s in pwd.keys()] | ||
password = [s for s in lower_list if "password" in s] | ||
key = [s for s in lower_list if "key" in s] # for the wifi | ||
|
||
# No password found | ||
if not password and not key: | ||
print_debug("FAILED", "Password not found !!!") | ||
else: | ||
print_debug("OK", "Password found !!!") | ||
toWrite.append(pwd) | ||
constant.nbPasswordFound += 1 | ||
|
||
for p in pwd.keys(): | ||
logging.info("%s: %s" % (p, pwd[p])) | ||
|
||
# write credentials into a text file | ||
checks_write(toWrite, software_name) | ||
else: | ||
logging.debug("[!] No passwords found\n") | ||
|
||
def print_error(message): | ||
WConio.textcolor(WConio.LIGHTRED) | ||
logging.debug('[!] %s\n' % message) | ||
WConio.textcolor(WConio.LIGHTGREY) | ||
|
||
# def print_debug(message): | ||
# logging.debug('[!] %s\n' % message) | ||
|
||
def print_debug(error_level, message): | ||
if error_level == 'ERROR': | ||
WConio.textcolor(WConio.LIGHTRED) | ||
logging.debug('[ERROR] %s\n' % message) | ||
WConio.textcolor(WConio.LIGHTGREY) | ||
|
||
elif error_level == 'INFO': | ||
logging.debug('[INFO] %s\n' % message) | ||
|
||
# print when password is not found | ||
elif error_level == 'FAILED': | ||
WConio.textcolor(WConio.LIGHTRED) | ||
logging.info(message) | ||
WConio.textcolor(WConio.LIGHTGREY) | ||
|
||
# print when password is found | ||
elif error_level == 'OK': | ||
WConio.textcolor(WConio.GREEN) | ||
logging.info(message) | ||
WConio.textcolor(WConio.LIGHTGREY) | ||
|
||
elif error_level == 'DEBUG': | ||
logging.debug('%s\n' % message) | ||
|
||
else: | ||
logging.debug('[%s] %s' % (error_level, message)) | ||
|
||
# --------------------------- End of output functions --------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,58 @@ | ||
import xml.etree.cElementTree as ET | ||
import os, win32crypt | ||
import binascii | ||
from config.write_output import print_output, print_debug | ||
from config.constant import * | ||
from config.header import Header | ||
from config.get_system_priv import get_system_priv | ||
from ctypes import * | ||
import time, tempfile | ||
from ConfigParser import RawConfigParser | ||
import os | ||
|
||
class Wifi(): | ||
|
||
def retrieve_password(self): | ||
|
||
# print title | ||
Header().title_debug('Wifi') | ||
|
||
if 'ALLUSERSPROFILE' in os.environ: | ||
directory = os.environ['ALLUSERSPROFILE'] + os.sep + 'Microsoft\Wlansvc\Profiles\Interfaces' | ||
else: | ||
print_debug('ERROR', 'Environment variable (ALLUSERSPROFILE) has not been found.') | ||
if not windll.Shell32.IsUserAnAdmin(): | ||
print_debug('ERROR', '[!] This script should be run as admin!') | ||
return | ||
|
||
# for windows Vista or higher | ||
if os.path.exists(directory): | ||
rep = [] | ||
pwdFound = [] | ||
for repository in os.listdir(directory): | ||
if os.path.isdir(directory + os.sep + repository): | ||
|
||
rep = directory + os.sep + repository | ||
for file in os.listdir(rep): | ||
values = {} | ||
if os.path.isfile(rep + os.sep + file): | ||
f = rep + os.sep + file | ||
tree = ET.ElementTree(file=f) | ||
root = tree.getroot() | ||
xmlns = root.tag.split("}")[0] + '}' | ||
|
||
iterate = False | ||
for elem in tree.iter(): | ||
if elem.tag.endswith('SSID'): | ||
for w in elem: | ||
if w.tag == xmlns + 'name': | ||
values['SSID'] = w.text | ||
|
||
if elem.tag.endswith('authentication'): | ||
values['Authentication'] = elem.text | ||
|
||
if elem.tag.endswith('protected'): | ||
values['Protected'] = elem.text | ||
|
||
if elem.tag.endswith('keyMaterial'): | ||
key = elem.text | ||
try: | ||
binary_string = binascii.unhexlify(key) | ||
password = win32crypt.CryptUnprotectData(binary_string, None, None, None, 0)[1] | ||
values['Password'] = password | ||
except: | ||
values['INFO'] = '[!] Password not found. Try with System privileges' | ||
|
||
# store credentials | ||
if len(values) != 0: | ||
pwdFound.append(values) | ||
|
||
# print the results | ||
print_output("Wifi", pwdFound) | ||
else: | ||
print_debug('INFO', 'No credentials found.\nFile containing passwords not found:\n%s' % directory) | ||
|
||
|
||
if 'ALLUSERSPROFILE' in os.environ: | ||
directory = os.environ['ALLUSERSPROFILE'] + os.sep + 'Microsoft\Wlansvc\Profiles\Interfaces' | ||
else: | ||
print_debug('ERROR', 'Environment variable (ALLUSERSPROFILE) has not been found.') | ||
return | ||
|
||
if not os.path.exists(directory): | ||
print_debug('INFO', 'No credentials found.\nFile containing passwords not found:\n%s' % directory) | ||
return | ||
|
||
try: | ||
print_debug('INFO', '[!] Trying to elevate our privilege') | ||
get_system_priv() | ||
print_debug('INFO', '[!] Elevation ok - Passwords decryption is in progress') | ||
except: | ||
print_debug('ERROR', '[!] An error occurs during the privilege elevation process. Wifi passwords have not been decrypted') | ||
|
||
time.sleep(5) | ||
|
||
# read temp file containing all passwords found | ||
pwdFound = [] | ||
filepath = tempfile.gettempdir() + os.sep + 'TEMP123A.txt' | ||
if os.path.exists(filepath): | ||
cp = RawConfigParser() | ||
cp.read(filepath) | ||
for section in cp.sections(): | ||
values = {} | ||
for c in cp.items(section): | ||
values[str(c[0])] = str(c[1]) | ||
pwdFound.append(values) | ||
|
||
# remove file on the temporary directory | ||
os.remove(filepath) | ||
|
||
# print the results | ||
print_output("Wifi", pwdFound) | ||
else: | ||
print_debug('INFO', 'No passwords found') |
Binary file not shown.