ropnop / impacket_static_binaries

Standalone binaries for Linux/Windows of Impacket's examples
Other
702 stars 92 forks source link

Setup and build instructions? #4

Closed hook-s3c closed 4 years ago

hook-s3c commented 5 years ago

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

hook-s3c commented 5 years ago

ok, so you have to have docker and circleci installed, then run this;

circleci local execute --job build_linux for the linux build

hook-s3c commented 5 years ago

Missing git dependency in the docker container.

====>> Checkout code
  #!/bin/bash -eo pipefail
mkdir -p /root/impacket && cd /tmp/_circleci_local_build_repo && git ls-files -z | xargs -0 tar -c | tar -x -C /root/impacket
/bin/bash: git: command not found
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.
tar: This does not look like a tar archive
tar: Error exit delayed from previous errors
Error: Exited with code 2
Step failed
hook-s3c commented 5 years ago

Ok, got a fix in for this, just building now - will fork and send a PR

hook-s3c commented 5 years ago

build has failed;

38 INFO: PyInstaller: 3.4
38 INFO: Python: 2.7.12
39 INFO: Platform: Linux-4.15.0-45-generic-x86_64-with-redhat-5.11-Final
39 INFO: wrote /root/impacket/goldenPac.spec
46 INFO: UPX is not available.
48 INFO: Extending PYTHONPATH with paths
['/root/impacket/examples', '/root/impacket']
48 INFO: checking Analysis
48 INFO: Building Analysis because Analysis-00.toc is non existent
49 INFO: Initializing module dependency graph...
51 INFO: Initializing module graph hooks...
138 INFO: running Analysis Analysis-00.toc
161 INFO: Caching module hooks...
168 INFO: Analyzing /root/impacket/examples/goldenPac.py
3769 INFO: Processing pre-safe import module hook   _xmlplus
5403 INFO: Processing pre-find module path hook   distutils
7301 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
10962 INFO: Processing pre-find module path hook   site
10962 INFO: site: retargeting to fake-dir '/opt/python27/lib/python2.7/site-packages/PyInstaller/fake-modules'
16916 INFO: Loading module hooks...
16916 INFO: Loading module hook "hook-distutils.py"...
16917 INFO: Loading module hook "hook-sysconfig.py"...
16918 INFO: Loading module hook "hook-xml.py"...
17054 INFO: Loading module hook "hook-Cryptodome.py"...
17059 INFO: Loading module hook "hook-encodings.py"...
17950 INFO: Loading module hook "hook-pkg_resources.py"...
18292 INFO: Processing pre-safe import module hook   win32com
18823 INFO: Loading module hook "hook-pycparser.py"...
19257 INFO: Loading module hook "hook-httplib.py"...
19257 INFO: Loading module hook "hook-setuptools.py"...
20223 INFO: Looking for ctypes DLLs
20589 INFO: Analyzing run-time hooks ...
20605 INFO: Including run-time hook 'pyi_rth_pkgres.py'
20625 INFO: Looking for dynamic libraries
21947 INFO: Looking for eggs
21947 INFO: Using Python library /opt/python27/lib/libpython2.7.so.1.0
21963 INFO: Warnings written to /root/impacket/build/goldenPac/warn-goldenPac.txt
22061 INFO: Graph cross-reference written to /root/impacket/build/goldenPac/xref-goldenPac.html
22267 INFO: checking PYZ
22267 INFO: Building PYZ because PYZ-00.toc is non existent
22267 INFO: Building PYZ (ZlibArchive) /root/impacket/build/goldenPac/PYZ-00.pyz
23561 INFO: Building PYZ (ZlibArchive) /root/impacket/build/goldenPac/PYZ-00.pyz completed successfully.
23738 INFO: checking PKG
23739 INFO: Building PKG because PKG-00.toc is non existent
23739 INFO: Building PKG (CArchive) PKG-00.pkg
Error: runner failed
{"Runner":true,"level":"error","msg":"runner failed","task-id":"localbuild-1549786361","time":"2019-02-10Txx:37:12Z"}
Task failed
Error: task failed
hook-s3c commented 5 years ago

here's the circleci task I fiddled with;

   steps:
      - run:
          name: install git
          command: |
            yum update -y
            rpm -Uvh http://archives.fedoraproject.org/pub/archive/epel/5/i386/epel-release-5-4.noarch.rpm
            yum install git-all -y 
      - checkout
      - run: ...
hook-s3c commented 5 years ago

ok, got the builds passing and also added UPX support - I need to figure out how to get the build artifacts (binaries) out of the box, or is this not possible without circleci ?

ropnop commented 5 years ago

Hey - thanks for digging in on this!

My intention with this repo was to not have to build these locally - you should be able to always access the pre-built binaries on the releases page. But I see the value in doing it yourself too so I added some build steps in this commit: 5809e31a070b583052bc17c666a12838b7a2cfa4

You were definitely going down the right path, but the steps are designed to run in pre-made Docker images that have the correct versions of Python and the other required build tools. You can see in the Makefile how you need to run the build scripts in Docker images. You can get the binaries back out by volume mounting a directory when you run Docker and copying them there.

Anyways, try out the Makefile and let me know if it works for you. You should be able to just run make linux or make windows and see the binaries in the dist/ directory when it's completed (~15mins)

hook-s3c commented 5 years ago

Sure, I'm keen to get this working inside the docker containers for the sake of consistency - but I don't think it's possible to copy out build artifacts or mount volumes from the circleci platform?

I could give this a go with just Docker, but perhaps you know what's missing and might be a quick fix.

Please advise, as I'd like to extend this to include ARM and MIPS builds

hook-s3c commented 5 years ago

Hey dude, I checked docker hub, do you have a Dockerfile for that container?

ropnop commented 5 years ago

I don't think its possible to pull out artifacts when you're running CircleCI jobs locally with the circleci client. When you run it on the CircleCI platform, you have to persist_to_workspace between jobs and then push them somewhere (e.g. here, or define a build artifact (which is available in the CircleCI UI, e.g. here )

If you want to play around, CircleCI is free and you can start building on their platform. It'd be awesome to get ARM and MIPS if you can figure it out!

And sorry, I'm bad at keeping my Dockerfiles in version control :) Here you go: https://github.com/ropnop/dockerfiles/blob/master/alpine34_pyinstaller/Dockerfile

ropnop commented 4 years ago

Closing this. Let me know if you're still having any issues!