decalage2 / oletools

oletools - python tools to analyze MS OLE2 files (Structured Storage, Compound File Binary Format) and MS Office documents, for malware analysis, forensics and debugging.
http://www.decalage.info/python/oletools
Other
2.81k stars 560 forks source link

Offline installation without active internet connection crashes on windows #835

Open testtomat opened 6 months ago

testtomat commented 6 months ago

Affected tool: pip install oletool

Describe the bug Can not install oletool offline, because installation process tries to load dependent files from internet

File/Malware sample to reproduce the bug

How To Reproduce the bug 1.) Download https://github.com/decalage2/oletools/releases/download/v0.60.1/oletools-0.60.1.zip 2.) run pip3.xx.exe install -U "\oletools-0.60.1.zip" WITHOUT active internet connection

Expected behavior under offline installation I don't expect to have an active internet connection

Console output / Screenshots

pip3.10.exe install -U "\oletools-0.60.1.zip" Processing \oletools-0.60.1.zip Installing build dependencies ... error error: subprocess-exited-with-error × pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> [7 lines of output] WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000018F29FC78E0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/setuptools/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000018F29FC7BE0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/setuptools/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000018F29FC7F40>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/setuptools/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000018F2A008280>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/setuptools/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000018F2A0082B0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/setuptools/ ERROR: Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: none) ERROR: No matching distribution found for setuptools>=40.8.0 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip.

Version information:

Additional context Add any other context about the problem here.

decalage2 commented 6 months ago

Indeed a normal pip installation will not work offline, because it needs to download a number of dependencies (listed in requirements.txt and setup.py). To install offline, you need to get every dependency first, and then install them one by one in the correct order, with oletools at the end. This would need to be added to the documentation.

testtomat commented 6 months ago

Okay, thanks.

Is this the only way or is it possible to make a Copy 'n Paste deployment of all installed packages from a development machine to a production machine? Sorry, I'm a C#-developer and not familar with Python environment.

decalage2 commented 6 months ago

In theory yes, you could copy the site-packages directory where Python stores all external packages, assuming you have the same python version on both machines. But you need to pay attention how external packages have been installed in the first place:

More info: https://www.quora.com/How-can-I-copy-the-Python-folder-with-all-its-libraries-and-modules-from-one-computer-to-another

But all in all, I would recommend to download all dependencies locally and install them with pip (with a script, to automate things). It's probably a bit more work, but it would avoid any install glitches.