Add new workflow for Github Action

- makefile deleted
- cme and cmedb compiled from a py script with shiv
- add windows compatibility
- remove double dependency lsassy inside setup.py file
main
mpgn 2020-09-11 16:35:55 -04:00
parent 6885d9fd30
commit 5256060767
4 changed files with 84 additions and 41 deletions

View File

@ -9,7 +9,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
os: [ubuntu-latest, macOS-latest]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v2
@ -19,18 +19,10 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
run: |
pip install flake8
make tests
- name: Build binaries with Shiv
run: |
pip install shiv
make build
python build_collector.py
- name: Upload cme binary
uses: actions/upload-artifact@master
with:

View File

@ -1,29 +0,0 @@
.PHONY: tests
default: build
clean:
rm -f -r build/
rm -f -r bin/
rm -f -r dist/
rm -f -r *.egg-info
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -rf {} +
find . -name '.pytest_cache' -exec rm -rf {} +
build:
mkdir build/
mkdir bin/
cp -r cme build/
python3 -m pip install -r requirements.txt -t build
rm -rf build/__pycache__ build/*.dist-info
shiv --site-packages build -E --compressed -e 'cme.crackmapexec:main' -o bin/cme -p "/usr/bin/env -S python3 -sE"
shiv --site-packages build -E --compressed -e 'cme.cmedb:main' -o bin/cmedb -p "/usr/bin/env -S python3 -sE"
rebuild: clean build
tests:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=cme/data,cme/thirdparty
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=cme/data,cme/thirdparty

81
build_collector.py Normal file
View File

@ -0,0 +1,81 @@
# -*- coding: latin-1 -*-
import os
import shutil
import subprocess
import sys
import time
import zipfile
from datetime import datetime
from pathlib import Path
from shiv.bootstrap import Environment
# from distutils.ccompiler import new_compiler
from shiv.builder import create_archive
from shiv.cli import __version__ as VERSION
def build_cme():
try:
os.mkdir("build")
shutil.copytree("cme", "build/cme")
except:
shutil.rmtree("build")
shutil.copytree("stormcollector", "app/stormcollector")
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "-r", "requirements.txt" ,"-t", "build"],
stdout=sys.stdout,
stderr=subprocess.STDOUT,
)
#[shutil.rmtree(p) for p in Path("build").glob("**/__pycache__")]
[shutil.rmtree(p) for p in Path("build").glob("**/*.dist-info")]
env = Environment(
built_at=datetime.utcfromtimestamp(int(time.time())).strftime(
"%Y-%m-%d %H:%M:%S"
),
entry_point="cme.crackmapexec:main",
script=None,
compile_pyc=False,
extend_pythonpath=True,
shiv_version=VERSION,
)
create_archive(
[Path("build").absolute()],
Path("bin/cme"),
"/usr/bin/env -S python3 -sE",
"_bootstrap:bootstrap",
env,
True,
)
def build_cmedb():
env = Environment(
built_at=datetime.utcfromtimestamp(int(time.time())).strftime(
"%Y-%m-%d %H:%M:%S"
),
entry_point="cme.cmedb:main",
script=None,
compile_pyc=False,
extend_pythonpath=True,
shiv_version=VERSION,
)
create_archive(
[Path("build").absolute()],
Path("bin/cmedb"),
"/usr/bin/env -S python3 -sE",
"_bootstrap:bootstrap",
env,
True,
)
if __name__ == "__main__":
try:
build_cme()
build_cmedb()
except:
pass
finally:
shutil.rmtree("build")

View File

@ -33,8 +33,7 @@ setup(name='crackmapexec',
'paramiko',
'impacket',
'xmltodict',
'terminaltables',
'lsassy'
'terminaltables'
],
entry_points={
'console_scripts': ['crackmapexec=cme.crackmapexec:main', 'cme=cme.crackmapexec:main', 'cmedb=cme.cmedb:main'],