作者:仙果
注:版权归原作者所有,虽然本人讨厌日本人,转载请注明出处,谢谢合作
题记:买了一本《Python 灰帽子》,书虽不足200页,但其中知识确是非常多,得益不少,又因最近在研究Fuzzing的相关问题,需要搭建Fuzzing进行测试,
随按照书上的例子进行实验。网上搜集资料时搜索到了这篇文章,虽然买这本书的人挺多(今日在中关村图书大厦还看到某位安全爱好者买了这本书),
但却是没有看到谁把Python环境搭建的文章发表出来,本着方便自己的想法把这篇文章翻译下,抱砖引玉,有些问题想请教一下。Go go Let's go!
发现自己很罗嗦。
正文:
昨天试着在自己的笔记本上安装Pydbg和Pydasm。Pydasm是常用且非常受欢迎的反汇编机器码(字节码)的库。Pydbg同样也是非常受欢迎windows 平台
下轻量级可扩展的Python 库。
实际上,Pydbg是Windows平台下PaiMei(白眉)的调试框架。
整个过程却是非常困难的,使用Python distutils充满了挣扎和陷阱。
记录了如下的文档,把遇到的问题作为备忘录,方便其他人(包括我)安装这些使用C语言和Python编写非常好的反汇编引擎工具。
我的笔记本配置如下:
CPU : Intel Pentium M (Centrino) 1.2GHz
RAM : 1GB
OS : Windows XP Professional SP3 (Japanese)
Python: Python 2.5 (install from MSI installer)
Install Dir : C:\Python25
Visual Studio : Visual C++ 2008 Express Edision (SP1)
Subversion: TortoiseSVN 1.6.x
libdasm-1.5\
libdasm.c
README.txt
...
bin\
pydasm\
...
> setup.py build_ext
running build_ext
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.
> cl
Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
...
> link
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Python25\Lib\distutils\msvccompiler.py
msvccompiler.py:
...
class MSVCCompiler (CCompiler) :
...
def __init__ (self, verbose=0, dry_run=0, force=0):
...
# comment out here!!
self.__macros = MacroExpander(self.__version)
> set DISTUTILS_USE_SDK=1
> set MSSdk=1
> setup.py build_ext
running build_ext
building 'pydasm' extension
creating build
creating build\temp.win32-2.5
creating build\temp.win32-2.5\Release
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe \
/c /nologo /Ox /MD /W3 /GX /DNDEBUG \
-IC:\Python25\include -IC:\Python25\include -IC:\Python25\PC \
/Tc../libdasm.c /Fobuild\temp.win32-2.5\Release\../libdasm.obj
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe \
/c /nologo /Ox /MD /W3 /GX /DNDEBUG \
-IC:\Python25\include -IC:\Python25\include -IC:\Python25\PC \
/Tcpydasm.c /Fobuild\temp.win32-2.5\Release\pydasm.obj
creating build\lib.win32-2.5
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe \
/DLL /nologo /INCREMENTAL:NO \
/LIBPATH:C:\Python25\libs /LIBPATH:C:\Python25\PCBuild /EXPORT:initpydasm \
build\temp.win32-2.5\Release\../libdasm.obj build\temp.win32-2.5\Release\pydasm.obj \
/OUT:build\lib.win32-2.5\pydasm.pyd \
/IMPLIB:build\temp.win32-2.5\Release\..\pydasm.lib
libdasm-1.5\pydasm\build\lib.win32-2.5\pydasm.pyd
> setup.py install
running install
running build
running build_ext
running install_lib
copying build\lib.win32-2.5\pydasm.pyd -> C:\Python25\Lib\site-packages
copying build\lib.win32-2.5\pydasm.pyd.manifest -> C:\Python25\Lib\site-packages
running install_egg_info
Removing C:\Python25\Lib\site-packages\pydasm-1.5-py2.5.egg-info
Writing C:\Python25\Lib\site-packages\pydasm-1.5-py2.5.egg-info
> C:\Python25\python.exe
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydasm
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: 指定されたモジュールが見つかりません。(中文是“找不到指定的模块”,译者注)
>>> quit()
> dumpbin /dependents C:\Python25\python.exe
...
python25.dll
MSVCR71.dll <-- Python25 depends on MSVCR71.dll
KERNEL32.dll
...
> dumpbin /dependents build\lib.win32-2.5\pydasm.pyd
...
MSVCR90.dll <-- pydasm depends on MSVCR90.dll !!
python25.dll
KERNEL32.dll
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
上传的附件: