From 51717219c3db6265ff74893a8bc3154eac07f30f Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 21 Oct 2024 13:53:23 +0200 Subject: [PATCH 1/6] empire: fix issues --- packages/empire/PKGBUILD | 49 +++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/packages/empire/PKGBUILD b/packages/empire/PKGBUILD index 84aa4e04e5a..eaa835a9261 100644 --- a/packages/empire/PKGBUILD +++ b/packages/empire/PKGBUILD @@ -2,9 +2,9 @@ # See COPYING for license details. pkgname=empire -pkgver=3443.ee6526b1 +pkgver=v5.11.5.r0.gee6526b pkgrel=1 -epoch=2 +epoch=3 pkgdesc='A PowerShell and Python post-exploitation agent.' groups=('blackarch' 'blackarch-automation') arch=('any') @@ -28,36 +28,51 @@ depends=('python' 'python-urllib3' 'python-requests' 'python-iptools' 'tk' '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-itsdangerous' 'python-markupsafe' 'python-md2pdf' 'python-mypy_extensions' + 'python-numpy' 'python-obfuscator' 'python-packaging' 'python-passlib' + 'python-pathspec' 'python-platformdirs' 'python-pluggy' 'python-ply' + 'python-pyasyncore' '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-service-identity' 'python-sniffio' 'python-starlette' 'python-stix2' + 'python-stone' 'python-tabulate' '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') + 'python-zope-interface' 'mariadb' 'uvicorn') makedepends=('git') +install='empire.install' 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') + 'setup_database.py.patch' + 'empire.install') sha512sums=('SKIP' '3d7695f27b7909eb82f05527ab7551fe90a85a70f20ea980293b59672a62f9b015966180407fa0786e94b01ad1d1acfaa7d40426bb63410efd24a144e559e2f0' - '9ffc3dc5d6a1dfd5b71cd22a0878a0231958938cb939e5fda5467c301fb4837ff96a299c2cbf2b2cc232fd8dd340c9086130e1067870c8c4272d7cc05e3954b4') + '9ffc3dc5d6a1dfd5b71cd22a0878a0231958938cb939e5fda5467c301fb4837ff96a299c2cbf2b2cc232fd8dd340c9086130e1067870c8c4272d7cc05e3954b4' + '22eae94614fa5fee5effb9c03160b307d1d43f0dbd4a68011cdc66c2437119c94e80f3efa98fa92b9fb061a12b960f6d0598c9f9420714ad3c16c18f54ce88e6') 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 + # Prevent invoking git submodule update on install directory since no git dir + sed -i "s/auto_update: true/auto_update: false/g" ./empire/server/config.yaml + # Prevent invoking git clone on install directory due to permission denied + sed -i '/starkiller:/,/enabled:/s/enabled: true/enabled: false/' ./empire/server/config.yaml + # need by empire cp -r "$srcdir/pyOpenSSL-22.0.0/src/OpenSSL" OpenSSL + + git submodule update --init --recursive } package() { @@ -73,6 +88,14 @@ package() { cp -a * "$pkgdir/usr/share/$pkgname/" + cat > "$pkgdir/usr/bin/$pkgname" << EOF +#!/bin/sh +cd /usr/share/$pkgname +exec python empire.py "\$@" +EOF + + chmod +x "$pkgdir/usr/bin/$pkgname" + cat > "$pkgdir/usr/bin/$pkgname-server" << EOF #!/bin/sh cd /usr/share/$pkgname From ca02cfb2bf868851c30fae199bfe850e44cb0b3a Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 21 Oct 2024 13:54:29 +0200 Subject: [PATCH 2/6] Update to-release --- lists/to-release | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lists/to-release b/lists/to-release index e69de29bb2d..24df3b7ed5f 100644 --- a/lists/to-release +++ b/lists/to-release @@ -0,0 +1,3 @@ +empire +python-md2pdf +python-obfuscator From 8409fdf41a2e314d0de28a436069f924a443da6c Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 21 Oct 2024 13:56:11 +0200 Subject: [PATCH 3/6] python-obfuscator: add package --- packages/python-obfuscator/PKGBUILD | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 packages/python-obfuscator/PKGBUILD diff --git a/packages/python-obfuscator/PKGBUILD b/packages/python-obfuscator/PKGBUILD new file mode 100644 index 00000000000..5f501160007 --- /dev/null +++ b/packages/python-obfuscator/PKGBUILD @@ -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 +} + From 3da8c4a9ce391b9ecb92d93131374177975c27de Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 21 Oct 2024 13:57:09 +0200 Subject: [PATCH 4/6] python-md2pdf: add package --- packages/python-md2pdf/PKGBUILD | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 packages/python-md2pdf/PKGBUILD diff --git a/packages/python-md2pdf/PKGBUILD b/packages/python-md2pdf/PKGBUILD new file mode 100644 index 00000000000..efab3838aff --- /dev/null +++ b/packages/python-md2pdf/PKGBUILD @@ -0,0 +1,36 @@ +# 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') +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 + cat 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 +} + From 387115d6c57ae82994d3eee84a60bb1e3635ae40 Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 21 Oct 2024 13:58:01 +0200 Subject: [PATCH 5/6] Create empire.install --- packages/empire/empire.install | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 packages/empire/empire.install diff --git a/packages/empire/empire.install b/packages/empire/empire.install new file mode 100644 index 00000000000..0ee64f73a9f --- /dev/null +++ b/packages/empire/empire.install @@ -0,0 +1,34 @@ +#!/bin/sh + +post_install() { + set -e + echo " +=================================================================== + POWERSHELL EMPIRE DATABASE INITIALIZATION +=================================================================== +" +# Find the PIDs of processes using port 3306, and remove duplicates +pids=$(sudo ss -tulnp | grep ':3306' | awk '{print $7}' | cut -d',' -f2 | cut -d'=' -f2 | sort -u) + +# Check if any PIDs were found +if [ -n "$pids" ]; then + echo "Found processes using port 3306: $pids" + for pid in $pids; do + echo "Killing process with PID $pid..." + sudo kill -9 "$pid" + echo "Process $pid has been killed." + done +fi +echo "Initializing MariaDB..." +sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql +echo "Enabling mariadb systemctl service..." +sudo systemctl enable --now mariadb +echo "Creating empire_user..." +sudo mariadb -u root -e "CREATE USER IF NOT EXISTS 'empire_user'@'localhost' IDENTIFIED BY 'empire_password';" || true +sudo mariadb -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'empire_user'@'localhost' WITH GRANT OPTION;" || true +sudo mariadb -u root -e "FLUSH PRIVILEGES;" || true +} + +post_upgrade() { + post_install "$@" +} From 92a049689f72b8d6f179990dc9a00b46b3c9be75 Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 21 Oct 2024 14:02:56 +0200 Subject: [PATCH 6/6] Update PKGBUILD --- packages/empire/PKGBUILD | 17 +++++--------- packages/empire/empire.install | 39 ++++++--------------------------- packages/python-md2pdf/PKGBUILD | 5 ++--- 3 files changed, 14 insertions(+), 47 deletions(-) diff --git a/packages/empire/PKGBUILD b/packages/empire/PKGBUILD index eaa835a9261..3d059490081 100644 --- a/packages/empire/PKGBUILD +++ b/packages/empire/PKGBUILD @@ -2,12 +2,12 @@ # See COPYING for license details. pkgname=empire -pkgver=v5.11.5.r0.gee6526b +pkgver=v5.11.7.r0.g8f41087 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' @@ -40,15 +40,13 @@ depends=('python' 'python-urllib3' 'python-requests' 'python-iptools' 'tk' 'python-websockets' 'python-werkzeug' 'python-zipp' 'websockify' 'python-zope-interface' 'mariadb' 'uvicorn') makedepends=('git') -install='empire.install' +install="empire.install" 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' - 'empire.install') + 'setup_database.py.patch') sha512sums=('SKIP' '3d7695f27b7909eb82f05527ab7551fe90a85a70f20ea980293b59672a62f9b015966180407fa0786e94b01ad1d1acfaa7d40426bb63410efd24a144e559e2f0' - '9ffc3dc5d6a1dfd5b71cd22a0878a0231958938cb939e5fda5467c301fb4837ff96a299c2cbf2b2cc232fd8dd340c9086130e1067870c8c4272d7cc05e3954b4' - '22eae94614fa5fee5effb9c03160b307d1d43f0dbd4a68011cdc66c2437119c94e80f3efa98fa92b9fb061a12b960f6d0598c9f9420714ad3c16c18f54ce88e6') + '9ffc3dc5d6a1dfd5b71cd22a0878a0231958938cb939e5fda5467c301fb4837ff96a299c2cbf2b2cc232fd8dd340c9086130e1067870c8c4272d7cc05e3954b4') pkgver() { cd $pkgname @@ -64,11 +62,6 @@ pkgver() { prepare() { cd $pkgname - # Prevent invoking git submodule update on install directory since no git dir - sed -i "s/auto_update: true/auto_update: false/g" ./empire/server/config.yaml - # Prevent invoking git clone on install directory due to permission denied - sed -i '/starkiller:/,/enabled:/s/enabled: true/enabled: false/' ./empire/server/config.yaml - # need by empire cp -r "$srcdir/pyOpenSSL-22.0.0/src/OpenSSL" OpenSSL diff --git a/packages/empire/empire.install b/packages/empire/empire.install index 0ee64f73a9f..2875c5c4483 100644 --- a/packages/empire/empire.install +++ b/packages/empire/empire.install @@ -1,34 +1,9 @@ #!/bin/sh -post_install() { - set -e - echo " -=================================================================== - POWERSHELL EMPIRE DATABASE INITIALIZATION -=================================================================== -" -# Find the PIDs of processes using port 3306, and remove duplicates -pids=$(sudo ss -tulnp | grep ':3306' | awk '{print $7}' | cut -d',' -f2 | cut -d'=' -f2 | sort -u) - -# Check if any PIDs were found -if [ -n "$pids" ]; then - echo "Found processes using port 3306: $pids" - for pid in $pids; do - echo "Killing process with PID $pid..." - sudo kill -9 "$pid" - echo "Process $pid has been killed." - done -fi -echo "Initializing MariaDB..." -sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql -echo "Enabling mariadb systemctl service..." -sudo systemctl enable --now mariadb -echo "Creating empire_user..." -sudo mariadb -u root -e "CREATE USER IF NOT EXISTS 'empire_user'@'localhost' IDENTIFIED BY 'empire_password';" || true -sudo mariadb -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'empire_user'@'localhost' WITH GRANT OPTION;" || true -sudo mariadb -u root -e "FLUSH PRIVILEGES;" || true -} - -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 +} \ No newline at end of file diff --git a/packages/python-md2pdf/PKGBUILD b/packages/python-md2pdf/PKGBUILD index efab3838aff..daf6ae52b2b 100644 --- a/packages/python-md2pdf/PKGBUILD +++ b/packages/python-md2pdf/PKGBUILD @@ -10,16 +10,15 @@ arch=('any') url='https://pypi.org/project/md2pdf' license=('MIT') depends=('python' 'python-weasyprint' 'python-docopt' 'python-markdown2') -makedepends=('python-setuptools') +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 - cat setup.py } build() {