pwn
ソケットを使用する代わりにas Client
/を使用して ( ) メッセージServer
を受信する方が快適なため、リバース シェル プロジェクトに取り組んでいます。エラーが発生した場合、最初にコンソールでこのプログラムをテストしました。recvuntil
EXE
pyinstaller
onefile
それで、それを機能させる方法、または自分で作成する方法はありpyinstaller
ますか(必要な場合)?
これ以上のタイトルが思い浮かばないので、よろしければコメントしてください
私のvenv conda pythonバージョンは3.9.7です
ここに小さなServer
コードがあります (これはテスト用です):
import threading
from pwn import *
def tryThreading():
l=listen(5005)
client=l.wait_for_connection()
def tryRecv():
while True:
if client.can_recv():
print('\n-Bob: '+client.recv().decode())
recv=threading.Thread(target=tryRecv)
recv.start()
while True:
client.send(input('-Sam: ').encode())
tryThreading()
上記のプログラムのテスト実行は次のとおりです。
(pyins) C:\Users\YCS\Desktop>python tryPwn.py
[x] Trying to bind to :: on port 5005
[x] Trying to bind to :: on port 5005: Trying ::
[+] Trying to bind to :: on port 5005: Done
[x] Waiting for connections on :::5005
[+] Waiting for connections on :::5005: Got connection from ::1 on port 60340
-Sam: Hello
-Sam:
-Bob: Hello World
pyinstaller
出力は次のとおりです。
(pyins) C:\Users\YCS\Desktop>pyinstaller --onefile --noconfirm tryPwn.py
344 INFO: PyInstaller: 4.5.1
344 INFO: Python: 3.9.7 (conda)
712 INFO: Platform: Windows-10-10.0.19042-SP0
714 INFO: wrote C:\Users\YCS\Desktop\tryPwn.spec
720 INFO: UPX is not available.
728 INFO: Extending PYTHONPATH with paths
['C:\\Users\\YCS\\Desktop', 'C:\\Users\\YCS\\Desktop']
1044 INFO: checking Analysis
1044 INFO: Building Analysis because Analysis-00.toc is non existent
1045 INFO: Initializing module dependency graph...
1049 INFO: Caching module graph hooks...
1084 INFO: Analyzing base_library.zip ...
4147 INFO: Processing pre-find module path hook distutils from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
4150 INFO: distutils: retargeting to non-venv dir 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib'
6770 INFO: Caching module dependency graph...
7030 INFO: running Analysis Analysis-00.toc
7051 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by C:\ProgramData\Anaconda3\envs\pyins\python.exe
7126 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of C:\ProgramData\Anaconda3\envs\pyins\python39.dll
7350 INFO: Analyzing C:\Users\YCS\Desktop\tryPwn.py
7569 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.packages.six.moves.py'.
9896 INFO: Processing pre-find module path hook site from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
9898 INFO: site: retargeting to fake-dir 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\fake-modules'
16082 INFO: Processing pre-safe import module hook six.moves from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-six.moves.py'.
20863 INFO: Processing module hooks...
20863 INFO: Loading module hook 'hook-bcrypt.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
20865 INFO: Loading module hook 'hook-certifi.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
20874 INFO: Loading module hook 'hook-cryptography.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
21219 INFO: Loading module hook 'hook-mako.codegen.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
21222 INFO: Loading module hook 'hook-nacl.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
21256 INFO: Loading module hook 'hook-pycparser.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
21258 INFO: Loading module hook 'hook-pywintypes.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
47967 INFO: Loading module hook 'hook-difflib.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
47973 INFO: Loading module hook 'hook-distutils.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
47975 INFO: Loading module hook 'hook-distutils.util.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
47981 INFO: Loading module hook 'hook-encodings.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
48088 INFO: Loading module hook 'hook-heapq.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
48093 INFO: Loading module hook 'hook-lib2to3.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
48158 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
48164 INFO: Loading module hook 'hook-numpy.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
48277 WARNING: Conda distribution 'numpy', dependency of 'numpy', was not found. If you installed this distribution with pip then you may ignore this warning.
48279 INFO: Import to be excluded not found: 'f2py'
48318 INFO: Loading module hook 'hook-numpy._pytesttester.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
48322 INFO: Loading module hook 'hook-pickle.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
48327 INFO: Loading module hook 'hook-PIL.Image.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
48670 INFO: Loading module hook 'hook-PIL.ImageFilter.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
48676 INFO: Loading module hook 'hook-PIL.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
48697 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
48702 INFO: Loading module hook 'hook-pkg_resources.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
49362 INFO: Processing pre-safe import module hook win32com from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py'.
49452 WARNING: Hidden import "pkg_resources.py2_warn" not found!
49751 WARNING: Hidden import "pkg_resources.markers" not found!
49757 INFO: Loading module hook 'hook-pygments.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
51370 INFO: Loading module hook 'hook-setuptools.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
65132 INFO: Loading module hook 'hook-sysconfig.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
65135 INFO: Loading module hook 'hook-win32ctypes.core.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
65331 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
65333 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
65334 INFO: Loading module hook 'hook-xml.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
65335 INFO: Loading module hook 'hook-_tkinter.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
65502 INFO: checking Tree
65502 INFO: Building Tree because Tree-00.toc is non existent
65502 INFO: Building Tree Tree-00.toc
65661 INFO: checking Tree
65662 INFO: Building Tree because Tree-01.toc is non existent
65662 INFO: Building Tree Tree-01.toc
65769 INFO: checking Tree
65769 INFO: Building Tree because Tree-02.toc is non existent
65769 INFO: Building Tree Tree-02.toc
65780 INFO: Loading module hook 'hook-pythoncom.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
91530 INFO: Loading module hook 'hook-win32com.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
92036 INFO: Loading module hook 'hook-packaging.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
92039 INFO: Loading module hook 'hook-setuptools.msvc.py' from 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks'...
92118 INFO: Looking for ctypes DLLs
92237 INFO: Analyzing run-time hooks ...
92249 INFO: Including run-time hook 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
92253 INFO: Including run-time hook 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
92258 INFO: Including run-time hook 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
92264 INFO: Including run-time hook 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py'
92271 INFO: Including run-time hook 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_win32api.py'
92273 INFO: Including run-time hook 'C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\rthooks\\pyi_rth_certifi.py'
92300 INFO: Looking for dynamic libraries
92819 INFO: Looking for eggs
92819 INFO: Using Python library C:\ProgramData\Anaconda3\envs\pyins\python39.dll
92820 INFO: Found binding redirects:
[]
92834 INFO: Warnings written to C:\Users\YCS\Desktop\build\tryPwn\warn-tryPwn.txt
93034 INFO: Graph cross-reference written to C:\Users\YCS\Desktop\build\tryPwn\xref-tryPwn.html
93088 INFO: checking PYZ
93088 INFO: Building PYZ because PYZ-00.toc is non existent
93089 INFO: Building PYZ (ZlibArchive) C:\Users\YCS\Desktop\build\tryPwn\PYZ-00.pyz
95011 INFO: Building PYZ (ZlibArchive) C:\Users\YCS\Desktop\build\tryPwn\PYZ-00.pyz completed successfully.
95064 INFO: checking PKG
95065 INFO: Building PKG because PKG-00.toc is non existent
95065 INFO: Building PKG (CArchive) PKG-00.pkg
103176 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
103182 INFO: Bootloader C:\ProgramData\Anaconda3\envs\pyins\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
103182 INFO: checking EXE
103183 INFO: Building EXE because EXE-00.toc is non existent
103183 INFO: Building EXE from EXE-00.toc
103187 INFO: Copying icons from ['C:\\ProgramData\\Anaconda3\\envs\\pyins\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
103341 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
103342 INFO: Writing RT_ICON 1 resource with 3752 bytes
103342 INFO: Writing RT_ICON 2 resource with 2216 bytes
103342 INFO: Writing RT_ICON 3 resource with 1384 bytes
103342 INFO: Writing RT_ICON 4 resource with 37019 bytes
103342 INFO: Writing RT_ICON 5 resource with 9640 bytes
103343 INFO: Writing RT_ICON 6 resource with 4264 bytes
103343 INFO: Writing RT_ICON 7 resource with 1128 bytes
103347 INFO: Updating manifest in C:\Users\YCS\Desktop\build\tryPwn\run.exe.33xsdso9
103420 INFO: Updating resource type 24 name 1 language 0
103423 INFO: Appending archive to EXE C:\Users\YCS\Desktop\dist\tryPwn.exe
111875 INFO: Building EXE from EXE-00.toc completed successfully.
そして、ここにtryPwn
(ターゲットプログラム)出力があります:
(pyins) C:\Users\YCS\Desktop\dist>tryPwn.exe
Traceback (most recent call last):
File "tryPwn.py", line 2, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "pwn\__init__.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "pwn\toplevel.py", line 24, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "pwnlib\asm.py", line 58, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "pwnlib\shellcraft\__init__.py", line 171, in <module>
File "pwnlib\shellcraft\__init__.py", line 37, in __init__
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\YCS\\AppData\\Local\\Temp\\_MEI10682\\pwnlib\\shellcraft\\templates\\__doc__'
[13272] Failed to execute script 'tryPwn' due to unhandled exception!
何が起こったのかについての詳細はこちら