Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empire: fix issues #4307

Merged
merged 11 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lists/to-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
empire
python-md2pdf
python-obfuscator
python-secretsocks
99 changes: 53 additions & 46 deletions packages/empire/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,58 @@
# See COPYING for license details.

pkgname=empire
pkgver=3470.5aeb6336
pkgrel=4
epoch=2
pkgver=v5.12.0.r0.g5aeb633
pkgrel=1
epoch=3
pkgdesc='A PowerShell and Python post-exploitation agent.'
groups=('blackarch' 'blackarch-automation')
arch=('any')
groups=('blackarch' 'blackarch-automation')
url='https://github.com/BC-SECURITY/Empire'
license=('BSD')
depends=('python' 'python-urllib3' 'python-requests' 'python-iptools' 'tk'
'python-pydispatcher' 'python-flask' 'python-macholib' 'python-dropbox'
'python-zlib_wrapper' 'python-netifaces' 'python-m2crypto'
'python-jinja' 'python-cryptography' 'python-pefile' 'python-xlutils'
'python-pyminifier' 'python-pycryptodome' 'python-simplejson'
'python-xlrd' 'python-xlwt' 'python-bcrypt' 'java-environment'
'python-flask-socketio' 'python-setuptools' 'pyinstaller' 'python-jq'
'python-pycryptodomex' 'python-pyparsing' 'python-sqlalchemy'
'python-pyaml' 'python-prompt_toolkit' 'python-sqlalchemy-utc'
'python-pymysql' 'python-poetry' 'python-docopt' 'python-humanize'
'python-pydantic' 'python-socketio' 'python-terminaltables' 'donut'
'python-pyperclip' 'python-jose' 'python-aiofiles' 'python-altgraph'
'python-anyio' 'python-asgiref' 'python-atomicwrites' 'python-attrs'
'python-bidict' 'python-black' 'python-certifi' 'python-cffi'
'python-charset-normalizer' 'python-click' 'python-colorama'
'python-constantly' 'python-ecdsa' 'python-fastapi' 'python-greenlet'
'python-h11' 'python-hyperlink' 'python-idna' 'python-iniconfig'
'python-importlib-metadata' 'python-incremental' 'python-isort'
'python-itsdangerous' 'python-markupsafe' 'python-mypy_extensions'
'python-numpy' 'python-packaging' 'python-passlib' 'python-pathspec'
'python-platformdirs' 'python-pluggy' 'python-ply' 'python-pyasn1'
'python-pyasn1-modules' 'python-pycparser' 'python-pycryptodome'
'python-pygame' 'python-engineio' 'python-python-multipart'
'python-pyvnc' 'python-rsa' 'python-ruff' 'python-secretsocks'
'python-service-identity' 'python-sniffio' 'python-starlette'
'python-stone' 'python-toml' 'python-tomli' 'python-twisted'
'python-typing_extensions' 'python-wcwidth' 'python-websocket-client'
'python-websockets' 'python-werkzeug' 'python-zipp' 'websockify'
'python-zope-interface' 'uvicorn')
makedepends=('git')
source=("$pkgname::git+https://github.com/BC-SECURITY/Empire.git"
'https://files.pythonhosted.org/packages/35/d3/d6a9610f19d943e198df502ae660c6b5acf84cc3bc421a2aa3c0fb6b21d1/pyOpenSSL-22.0.0.tar.gz'
'setup_database.py.patch')
sha512sums=('SKIP'
'3d7695f27b7909eb82f05527ab7551fe90a85a70f20ea980293b59672a62f9b015966180407fa0786e94b01ad1d1acfaa7d40426bb63410efd24a144e559e2f0'
'9ffc3dc5d6a1dfd5b71cd22a0878a0231958938cb939e5fda5467c301fb4837ff96a299c2cbf2b2cc232fd8dd340c9086130e1067870c8c4272d7cc05e3954b4')
license=('BSD-3-Clause')
depends=('python' 'mariadb' 'openssl' 'powershell')
#depends=('python' 'mariadb' 'openssl' 'powershell' 'python-urllib3'
# 'python-requests' 'python-iptools' 'python-macholib' 'python-dropbox'
# 'python-pyopenssl' 'python-zlib_wrapper' 'python-jinja'
# 'python-xlutils' 'python-pyparsing' 'python-pymysql'
# 'python-sqlalchemy' 'python-pyaml' 'python-sqlalchemy-utc'
# 'python-prompt_toolkit' 'python-terminaltables' 'python-humanize'
# 'python-pycryptodome' 'python-cryptography' 'python-fastapi' 'uvicorn'
# 'python-jq' 'python-aiofiles' 'python-python-multipart' 'python-jose'
# 'python-passlib' 'python-websockify' 'python-websockets'
# 'python-pyperclip' 'python-pyvnc' 'python-socketio' 'python-flask'
# 'python-secretsocks' 'donut' 'python-obfuscator' 'pyinstaller'
# 'python-md2pdf' 'python-tabulate' 'python-stix2' 'python-docopt-ng'
# 'python-packaging' 'python-bcrypt')
makedepends=('git' 'python-setuptools' 'python-pip')
optdepends=(
'xar: enables generating .dmg stagers'
'bomutils: enables generating .dmg stagers'
'jdk-openjdk: enables generating .jar stager'
'nim: enables generating nim stagers'
)
install="empire.install"
source=("$pkgname::git+https://github.com/BC-SECURITY/Empire.git")
sha512sums=('SKIP')

pkgver() {
cd $pkgname

echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
( set -o pipefail
git describe --long --tags --abbrev=7 2>/dev/null |
sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
printf "%s.%s" "$(git rev-list --count HEAD)" \
"$(git rev-parse --short=7 HEAD)"
)
}

prepare() {
cd $pkgname

# need by empire
cp -r "$srcdir/pyOpenSSL-22.0.0/src/OpenSSL" OpenSSL
git submodule update --init --recursive

# grab openssl certs
cd setup
bash ./cert.sh
}

package() {
Expand All @@ -66,16 +62,26 @@ package() {
install -dm 755 "$pkgdir/usr/bin/"
install -dm 755 "$pkgdir/usr/share/$pkgname"

install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md changelog
install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md
install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

rm changelog LICENSE README.md
rm changelog LICENSE CHANGELOG.md

cp -a * "$pkgdir/usr/share/$pkgname/"

cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
source /usr/share/$pkgname/venv/bin/activate
exec python empire.py "\$@"
EOF

chmod +x "$pkgdir/usr/bin/$pkgname"

cat > "$pkgdir/usr/bin/$pkgname-server" << EOF
#!/bin/sh
cd /usr/share/$pkgname
source /usr/share/$pkgname/venv/bin/activate
exec python empire.py server "\$@"
EOF

Expand All @@ -84,6 +90,7 @@ EOF
cat > "$pkgdir/usr/bin/$pkgname-client" << EOF
#!/bin/sh
cd /usr/share/$pkgname
source /usr/share/$pkgname/venv/bin/activate
exec python empire.py client "\$@"
EOF

Expand Down
36 changes: 36 additions & 0 deletions packages/empire/empire.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

post_install() {
set -e
cd /usr/share/empire
python -m venv venv
source venv/bin/activate &&
pip install --isolated --root="/usr/share/empire" --prefix='venv' .

# Check if the directory does NOT exist OR is empty
MYSQL_DATA_DIR="/var/lib/mysql"
if [ ! -d "$MYSQL_DATA_DIR" ] || [ -z "$(ls -A "$MYSQL_DATA_DIR" 2>/dev/null)" ]; then
echo "MySQL data directory is missing or empty. Initializing MariaDB..."

# Initialize MariaDB
mariadb-install-db --user=mysql --basedir=/usr --datadir="$MYSQL_DATA_DIR"
fi

systemctl restart mysql
mysql -u root -e "CREATE USER IF NOT EXISTS 'empire_user'@'localhost' IDENTIFIED BY 'empire_password';" || true
mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'empire_user'@'localhost' WITH GRANT OPTION;" || true
mysql -u root -e "FLUSH PRIVILEGES;" || true
systemctl restart mysql
}

post_upgrade() {
post_install "$@"
}

post_remove() {
# Check if the directory exists to avoid errors if it doesn't
if [[ -d /usr/share/empire ]]; then
rm -rf /usr/share/empire
echo "Removed /usr/share/empire"
fi
}
11 changes: 0 additions & 11 deletions packages/empire/setup_database.py.patch

This file was deleted.

35 changes: 35 additions & 0 deletions packages/python-md2pdf/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=python-md2pdf
_pkgname=${pkgname#python-}
pkgver=1.0.1
pkgrel=1
pkgdesc='Python-based Markdown to PDF converter.'
arch=('any')
url='https://pypi.org/project/md2pdf'
license=('MIT')
depends=('python' 'python-weasyprint' 'python-docopt' 'python-markdown2')
makedepends=('python-setuptools' 'python-pip')
options=(!emptydirs)
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('6e86dabb235f35e572b08cf5fcec02b9e2afce70f63ce40e53b4222782a6245df00b75af0b17c6000651dddda66d4bb03a9a8b5350d82d9967aa36ec6af9d8bd')

prepare() {
cd "$_pkgname-$pkgver"

sed -i 's/find_packages()/find_packages(exclude=["tests*"])/g' setup.py
}

build() {
cd "$_pkgname-$pkgver"

python setup.py build
}

package() {
cd "$_pkgname-$pkgver"

python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

29 changes: 29 additions & 0 deletions packages/python-obfuscator/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=python-obfuscator
_pkgname=${pkgname//-/_}
pkgver=0.0.2
pkgrel=1
pkgdesc='Python-based obfuscator.'
arch=('any')
url='https://github.com/davidteather/python-obfuscator'
license=('MIT')
depends=('python' 'python-regex')
makedepends=('python-setuptools')
options=(!emptydirs)
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('fb709bd3817444f3ab8a087b0db5e592285e738f96521974d69af833919b0531a0f3f63b3bae78fccff1928af7cedd768b7c2117d895fd5dab13553c8008e714')

build() {
cd "$_pkgname-$pkgver"

python setup.py build
}

package() {
cd "$_pkgname-$pkgver"

python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

9 changes: 7 additions & 2 deletions packages/python-secretsocks/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pkgdesc='A Python socks server for tunneling a connection over another channel.'
arch=('any')
url='https://github.com/BC-SECURITY/PySecretSOCKS'
license=('MIT')
depends=('python')
depends=('python' 'python-asyncore')
makedepends=('git' 'python-setuptools')
options=(!emptydirs)
source=("$pkgname::git+https://github.com/BC-SECURITY/$_pkgname")
Expand All @@ -18,7 +18,12 @@ sha512sums=('SKIP')
pkgver() {
cd $pkgname

echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
( set -o pipefail
git describe --long --tags --abbrev=7 2>/dev/null |
sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
printf "%s.%s" "$(git rev-list --count HEAD)" \
"$(git rev-parse --short=7 HEAD)"
)
}

build() {
Expand Down
Loading