Skip to content

Instantly share code, notes, and snippets.

@bandrel
Created April 22, 2026 15:35
Show Gist options
  • Select an option

  • Save bandrel/f5522442e8c20a1904eae8e6ea99f0ad to your computer and use it in GitHub Desktop.

Select an option

Save bandrel/f5522442e8c20a1904eae8e6ea99f0ad to your computer and use it in GitHub Desktop.
April2026 Nightly update causing segfault
#!/bin/bash
# Fix msfconsole segfault caused by bundled libpq ABI mismatch with OpenSSL 3
# in metasploit-framework 6.4.126+ (April 2026 nightly).
# Patches /usr/bin/msfconsole to preload the system libpq instead.
set -euo pipefail
SYSTEM_LIBPQ="/usr/lib/x86_64-linux-gnu/libpq.so.5"
MSF_WRAPPER="/usr/bin/msfconsole"
if [ ! -f "$SYSTEM_LIBPQ" ]; then
echo "ERROR: system libpq not found at $SYSTEM_LIBPQ"
exit 1
fi
if [ ! -f "$MSF_WRAPPER" ]; then
echo "ERROR: msfconsole wrapper not found at $MSF_WRAPPER"
exit 1
fi
if grep -q 'LD_PRELOAD' "$MSF_WRAPPER"; then
echo "Already patched."
exit 0
fi
sed -i "s|^unset GEM_HOME|export LD_PRELOAD=${SYSTEM_LIBPQ}\nunset GEM_HOME|" "$MSF_WRAPPER"
echo "Patched $MSF_WRAPPER — msfconsole should work now."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment