Compiling SSLProxy statically (including cross compiling arm64 from chroot) #90
GhostNaix
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm leaving this here in case someone wants to compile SSLProxy and have it statically linked (IOT Pentesting or portability).
Prerequisites:
After discovering this I have not had time to thoroughly test the static build of SSLProxy against all situations thus I advise some due diligence before posting an issue. You may have notice the following warnings when building statically.
Which leads me to believe that some functionality may break during runtime (even if you've adhered to the prequisites above), If you do encounter a bug, an error or unexpected behaviour, please attempt to replicate it on a dynamic build first to verify that it's caused by statically building SSLProxy before posting an issue. I believe it is imperative that when encountering a bug you should assume that due to static linking unless you find evidence otherwise.
Building statically linked SSLProxy on x86-64 systems
Installing and Standard SSLProxy dependencies (Used for both Dynamic and Static linking)
This step is self explanatory, we need this packages whether we are building SSLProxy statically or dynamically, at the time of writing this these packages come with both dynamic and static libraries, but that could change in the future.
sudo apt updatesudo apt install -y libevent-dev libpcap-dev libnet-dev libsqlite3-dev libssl-dev libcap-devBuilding Systemd libraries statically
So, most linux distros for whatever reason don't include a static version of systemd library so we will need to build it ourselves.
sudo apt build-dep -y systemdsudo apt-get source systemdrm systemd_*cd systemd-*meson setup build/meson configure --default-library static --strip -Dstatic-libsystemd=pic -Dstatic-libudev=pic build/ninja -C build/Compiling SSLProxy
At this point we would have all the dependencies to build SSLProxy Statically (I will assume that you are still using the same terminal window which it's working directory is in the systemd source code folder)
cd ..git clone https://github.com/sonertari/SSLproxy.gitcd SSLProxysed -i 's/LIBS+= $(PKG_LIBS)/LIBS+= $(PKG_LIBS) -lcap/g' Mk/main.mkPCFLAGS='-static' CFLAGS='-static' LDFLAGS='-static' make -j$(nproc)file -s src/sslproxyShould return something like this (Build ID would differ)
src/sslproxy: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=587018efc21d9a8ecc6fb9da459ef4cb71292e11, for GNU/Linux 3.2.0, with debug_info, not strippedstrip -s src/sslproxyCross Compiling statically linked SSLProxy on x86-64 systems for arm64 Systems
Now there is a method to cross-compile a statically linked SSLProxy targeted for arm64 from an x86-64 system, however I recommend a Debian Chroot as it needs to install arm64 libraries and some of them refuses to live with x86-64 libraries on the same system.
Additional prerequisites
Making the Chroot
We need to make the chroot environment to safely install the required arm64 packages required to build SSLProxy.
sudo apt updatesudo apt install debootstrap/Debian_chroot)sudo debootstrap --arch=amd64 bookworm /Debian_chrootor
sudo debootstrap --arch=amd64 <Release codename of your choice> <Directory of you choice>or
Dropping into your Chroot Shell

At this point your chroot environment should be setup however we need to drop into the chroot shell which is covered in this section.
A word of warning, Some linux distros break when chrooting as shown below and is only solvable via a reboot amke sure you are ready to reboot after building.
or
chroot "/Debian_chroot" "/bin/bash"or
chroot "<Directory of you choice>" "/bin/bash"Configuring the chroot
At this point I am assuming you are in the chroot shell, commands executed in this shell should not affect your main system.
dpkg --add-architecture arm64apt updateapt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gitInstalling and Standard SSLProxy dependencies (Used for both Dynamic and Static linking)
This step is self explanatory, we need this packages whether we are building SSLProxy statically or dynamically, at the time of writing this these packages come with both dynamic and static libraries, but that could change in the future.
(Optional) Changing to a suitable Working Directroy
By default when you drop into a chroot shell you will be at the root of the file system (
/) which is not ideal for building so we will change our working directory to/usr/srchowever you may change to whatever directroy you desire or fancy,or even create directories dedicated to this and adapt the guide.cd usr/srcBuilding Systemd libraries statically for arm64
apt build-dep --host-architecture arm64 systemdapt-get source systemdrm systemd_*cd systemd-*nano "Systemd-cross.ini"and paste the following
Save the file and proceed.
meson setup build/ --cross-file Systemd-cross.inimeson configure --default-library static --strip -Dstatic-libsystemd=pic -Dstatic-libudev=pic build/ninja -C build/Compiling SSLProxy
At this point we would have all the dependencies to build SSLProxy Statically (I will assume that you are still using the same terminal window which it's working directory is in the systemd source code folder)
cd ..git clone https://github.com/sonertari/SSLproxy.gitcd SSLProxysed -i 's/LIBS+= $(PKG_LIBS)/LIBS+= $(PKG_LIBS) -lcap/g' Mk/main.mkCC='aarch64-linux-gnu-gcc' PCFLAGS='--static' CFLAGS='-static' LDFLAGS='-static' make -j$(nproc)aarch64-linux-gnu-strip -s src/sslproxyBeta Was this translation helpful? Give feedback.
All reactions