Giter VIP home page Giter VIP logo

impacket_static_binaries's Introduction

Impacket Static Binaries

CircleCI Get Latest Binaries Here

Description

This repository is a fork of the amazing Impacket project available here: https://github.com/SecureAuthCorp/impacket

This fork has a CircleCI pipeline to create stand-alone executables for both Windows and Linux x64 of all the Impacket example scripts and upload the binaries to this project's github releases.

It's using PyInstaller to create both the Windows and Linux executables. The Windows binaries are built with Wine using cdrx's docker image: https://github.com/cdrx/docker-pyinstaller

For maximum compatibility, the Linux binaries are built with the oldest version of glibc I could find - CentOS 5 running Glibc 2.5: https://github.com/ropnop/centos5_python27_docker. These binaries should work with any version of glibc newer than 2.5.

I've also compiled all the Linux binaries against musl instead of glibc in case you land in a lightweight container (e.g. Alpine) that doesn't use glibc. These are all bundled up in a file on the releases page called impacket_musl_binaries.tar.gz.

Usage

If you are operating in a restricted environment that either doesn't have Python (or you don't want to disturb any existing python packages), you should be able to download and execute the Impacket examples from the releases page.

For example, it's possible to run wmiexec.py inside a barebones Ubuntu container that doesn't even have Python installed:

$ python
bash: python: command not found
$ curl -s -o wmiexec -L https://github.com/ropnop/impacket_static_binaries/releases/download/0.9.19-dev-binaries/wmiexec_linux_x86_64
$ chmod +x wmiexec
$ ./wmiexec LAB/[email protected]
Impacket v0.9.19-dev - Copyright 2018 SecureAuth Corporation

Password:
[*] SMBv2.1 dialect used
[!] Launching semi-interactive shell - Careful what you execute
[!] Press help for extra shell commands
C:\>whoami
lab\agreen

Building

If you'd like to build the binaries locally, I've included a Makefile and build scripts that essentially do the exact same thing CircleCI does. You need to run the build scripts inside the correct Dockerimage (the make targets take care of that for you).

$ make help
help:	 Show this help
all: linux musl windows  (Build everything)
linux:  Build linux_x64 Binaries in Docker
musl:  Build linux_x64 binaries against musl in Alpine Linux Docker
windows:  Build Windows_x64 binaries
clean: cleanspec  Remove all build artifacts
cleanspec:  Remove spec files

To build all the Linux binaries for example: make linux. This will output all the binaries in the ./dist directory for you.

Known issues

ntlmrelayx and smbrelayx aren't working properly yet. They do some custom loading that PyInstaller doesn't like. Still working on that...

Currently, wmiexec.py, psexec.py and dcomexec.py are hardcoded to use UTF-8 in the built binaries. There's some issues with Pyinstaller and calling sys.stdout.encoding. If you need something other than UTF-8, you'll have to rebuild on your own for now. Still working on this....

Currently glibc >= 2.5 is required. Eventually I'd like to look at building against musl (so they could work in Alpine linux for example)

I also haven't fully tested every example, so no guarantees. If you discover something that's not working as intended, please file an issue and let me know.

Enjoy! -ropnop

PS shout out to maaaaz for the inspiration! https://github.com/maaaaz/impacket-examples-windows

impacket_static_binaries's People

Contributors

0xdeaddood avatar 0xsauby avatar asolino avatar c0d3z3r0 avatar cclauss avatar cnotin avatar contactr2m avatar cube0x0 avatar derunbekannt avatar dirkjanm avatar exploide avatar franferrax avatar fuzzkitty avatar g0ldengunsec avatar kacpern avatar machosec avatar martingalloar avatar martinuy avatar mgeeky avatar mlefebvre avatar mohemiv avatar mrande7son avatar mrtchuss avatar mubix avatar rcarnus avatar rdubourguais avatar real-datagram avatar rmaksimov avatar ropnop avatar skelsec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

impacket_static_binaries's Issues

Binaries for Windows are not compiled correctly

Hi ropnop,

thank you very much for this awesome work.
Unfortunately I have discovered, that the compiled Windows binaries are not working as intended, since the last 4 to 5 releases.
I think this is due to the used python version you use to compile the binaries.

###This is the output on a Windows system, when running your compiled impacket Windows binaries:

wmiexec_windows.exe
Traceback (most recent call last):
File "wmiexec.py", line 32, in
File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 391, in load_module
File "impacket\version.py", line 11, in
File "site-packages\pkg_resources_init_.py", line 535, in get_distribution
File "site-packages\pkg_resources_init_.py", line 415, in get_provider
File "site-packages\pkg_resources_init_.py", line 943, in require
File "site-packages\pkg_resources_init_.py", line 829, in resolve
pkg_resources.DistributionNotFound: The 'impacket' distribution was not found and is required by the application
[3576] Failed to execute script wmiexec

I have compiled the most actual impacket build (v0.9.22.dev1+20200804.145312.110b886c) myself via PyInstaller and explicitely using Python3 as follows:

python3 -O -m PyInstaller --clean --onefile wmiexec.py

Did this on a Windows OS natively with installed Python and impacket distribution. You have to add a hook for PyInstaller still, if you compile this way. The hook must contain the following:

from PyInstaller.utils.hooks import copy_metadata
datas = copy_metadata('impacket')

When compiled via the method described above, all binaries seem to work well.

[-] SCMR SessionError: code: 0x431 - ERROR_SERVICE_EXISTS - The specified service already exists.

After the first success, I hit Ctrl+ C and run the prompt again

smbexec_windows.exe -hashes :ae···························· rootkit/[email protected]
Cannot determine Impacket version. If running from source you should at least run "python setup.py egg_info"
Impacket v? - Copyright 2020 SecureAuth Corporation

[-] SCMR SessionError: code: 0x431 - ERROR_SERVICE_EXISTS - The specified service already exists.

How can I solve this problem and hope for an early reply
edf437bf4913154ad758aa8bea9312d

Single ZIP for releases

First of all good work on this! Downloading all binaries would be much easier if they were inside a single zip though

Setup and build instructions?

Hi,

for anyone wondering it's;

python ./setup.py install, I had issues with virtualenv

not sure what's needed to build, will have a poke around

when I run ntlmrelayx.exe ,something is wrong?

Impacket v0.9.17 - Copyright 2002-2018 Core Security Technologies

Traceback (most recent call last):
File "ntlmrelayx.py", line 271, in
File "c:\users\admin\appdata\local\temp\pip-install-7erh71\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
File "build\bdist.win32\egg\impacket\examples\ntlmrelayx\clients_init_.py", line 79, in
File "site-packages\pkg_resources_init_.py", line 1154, in resource_listdir
File "site-packages\pkg_resources_init_.py", line 1416, in resource_listdir
File "site-packages\pkg_resources_init_.py", line 1458, in _listdir
NotImplementedError: Can't perform this operation for unregistered loader type
[8872] Failed to execute script ntlmrelayx

run error

C:\Tools>mssqlclient_windows.exe test/webadm:@192.168.151.131 -port 1433 -db master -windows-auth
Traceback (most recent call last):
File "mssqlclient.py", line 25, in
File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 391, in load_module
exec(bytecode, module.dict)
File "impacket\version.py", line 11, in
File "site-packages\pkg_resources_init_.py", line 535, in get_distribution
File "site-packages\pkg_resources_init_.py", line 415, in get_provider
File "site-packages\pkg_resources_init_.py", line 943, in require
File "site-packages\pkg_resources_init_.py", line 829, in resolve
pkg_resources.DistributionNotFound: The 'impacket' distribution was not found and is required by the application
[5204] Failed to execute script mssqlclient

Not an issue

Hello dear @ropnop,

Thanks for the shout out, and great job for broadening the concept by providing the whole build chain and even support Linux :)

Keep up that awesome work !

Best regards,
Thomas.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.