Skip to content
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
23 changes: 17 additions & 6 deletions sources/assets/desktop/bin/desktop-start
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
#!/bin/bash

# Function to find the first available display ID
# Function to find the first available display ID.
# A bind-mounted /tmp/.X11-unix lists the host's servers as socket files, which
# `ss` cannot see from another network namespace. Abstract X sockets live in
# the network namespace, so on host network another container's server shows
# up in `ss` and not in this container's /tmp. Both have to be consulted: the
# image build leaves an empty /tmp/.X11-unix behind, and trusting that
# directory alone makes every host-network container pick :2.
find_available_display() {
# Search for available socket if the X11 socket directory is not available
local -a x11_sockets=()
local id

if [ -d /tmp/.X11-unix/ ]; then
readarray -t x11_sockets < <(find "/tmp/.X11-unix/" -type s -printf "%f\n" | cut -d 'X' -f2)
else
# X11 not shared, need to check socket
readarray -t x11_sockets < <(ss -x | grep X11| cut -d 'X' -f3 | cut -d ' ' -f 1 | sort -u)
while IFS= read -r id; do
[ -n "$id" ] && x11_sockets+=("$id")
done < <(find /tmp/.X11-unix/ -type s -printf '%f\n' 2>/dev/null | grep -oE '[0-9]+$')
fi

while IFS= read -r id; do
[ -n "$id" ] && x11_sockets+=("$id")
done < <(ss -lx 2>/dev/null | grep -oE 'X11-unix/X[0-9]+' | grep -oE '[0-9]+$' | sort -u)

local max_num=1

# Find the maximum number
Expand Down
44 changes: 35 additions & 9 deletions sources/assets/shells/exegol_command_not_found.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,60 @@
# Hint for a command Exegol does not ship. Sourced from exegol_shells_rc.
# Runs only after PATH lookup fails, so a later install of the real command wins.
# Bash and zsh. Print the hint on stderr and leave the command status at 127.
# Table: /opt/.exegol_missing_commands (CSV: command,suggestion).
# Table: /opt/.exegol_missing_commands (CSV: command,suggestion), one line per old name.
# Written by add-suggestions. Several lines for one command are joined in order.

exegol_missing_command_hint() {
local cmd="$1"
local file="/opt/.exegol_missing_commands"
local suggestion green="" reset=""
local suggestions available suggestion red="" green="" reset=""
local count=0 index=0

case "$cmd" in
""|*/*) return 1 ;;
esac
[ -f "$file" ] || return 1

suggestion=$(awk -F ',' -v c="$cmd" '
suggestions=$(awk -F ',' -v c="$cmd" '
$0 ~ /^[[:space:]]*#/ { next }
$1 == "command" { next }
$1 == c && $2 != "" { print $2; found = 1; exit }
$1 == c {
for (i = 2; i <= NF; i++) if ($i != "" && !seen[$i]++) print $i
found = 1
}
END { exit !found }
' "$file") || return 1

# Smaller images do not ship every suggestion. Name only the ones on PATH.
# If none are installed, stay quiet so the shell prints "command not found".
available=$(printf '%s\n' "$suggestions" | while IFS= read -r suggestion; do
[ -n "$suggestion" ] || continue
command -v "$suggestion" >/dev/null 2>&1 || continue
printf '%s\n' "$suggestion"
done)
[ -n "$available" ] || return 1

if [ -t 2 ]; then
red=$'\033[31m'
green=$'\033[32m'
reset=$'\033[0m'
fi
printf "%s isn't installed. Try %s%s%s instead." "$cmd" "$green" "$suggestion" "$reset" >&2
if ! command -v "$suggestion" >/dev/null 2>&1; then
printf " %s%s%s is not in this container." "$green" "$suggestion" "$reset" >&2
fi
printf "\n" >&2

count=$(printf '%s\n' "$available" | grep -c .)
printf "%s%s%s isn't installed. Try " "$red" "$cmd" "$reset" >&2
printf '%s\n' "$available" | while IFS= read -r suggestion; do
[ -n "$suggestion" ] || continue
index=$((index + 1))
if [ "$index" -gt 1 ]; then
if [ "$index" -eq "$count" ]; then
printf " or " >&2
else
printf ", " >&2
fi
fi
printf "%s%s%s" "$green" "$suggestion" "$reset" >&2
done
printf " instead.\n" >&2
return 0
}

Expand Down
6 changes: 6 additions & 0 deletions sources/assets/shells/history.d/snafflepy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
snafflepy --stdout --domain "$DOMAIN" --domaincontroller "$DC_HOST" --user "$USER" --password "$PASSWORD" --html report.html
snafflepy --stdout --comptarget "$TARGET" --user "$USER" --hashes ":$NT_HASH" --domain "$DOMAIN"
KRB5CCNAME="$CCACHE_PATH" snafflepy --stdout --comptarget "$TARGET" --kerberos --domain "$DOMAIN" --dc-ip "$DC_IP"
snafflepy --stdout --dirtarget "\\\\$TARGET\\Share" --user "$USER" --password "$PASSWORD" --domain "$DOMAIN"
snafflepy --stdout --domain "$DOMAIN" --user "$USER" --password "$PASSWORD" --plus --interest 3 --snaffle ./snaffled --html report.html
snafflepy --stdout --domain "$DOMAIN" --user "$USER" --password "$PASSWORD" --maxthreads 30 --sharesonly --snaffle ./snaffled --html report.html
4 changes: 0 additions & 4 deletions sources/assets/shells/history.d/snaffler

This file was deleted.

4 changes: 4 additions & 0 deletions sources/assets/shells/history.d/snaffler-ng
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
snaffler-ng --username "$USER" --password "$PASSWORD" --domain "$DOMAIN"
snaffler-ng --username "$USER" --hash "$NT_HASH" --domain "$DOMAIN" --dc-host "$DC_HOST"
KRB5CCNAME="$CCACHE_PATH" snaffler-ng --kerberos --use-kcache --domain "$DOMAIN" --dc-host "$DC_HOST"
snaffler-ng --username "$USER" --password "$PASSWORD" --unc "//$TARGET/Share"
48 changes: 0 additions & 48 deletions sources/assets/shells/missing-commands.csv

This file was deleted.

28 changes: 28 additions & 0 deletions sources/install/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,34 @@ function add-test-command() {
echo "$*" >> "/.exegol/unit_tests_all_commands.txt"
}

# add-suggestions "installed,old[,old...]"
# One quoted CSV record. First field is the command this function installs.
# Every field after it is a name a user might type. Each old name is stored as
# its own "old,installed" line. Two installs can list the same old name.
function add-suggestions() {
local record="${1:-}"
local installed name
local -a fields
local -i i
if [[ $# -ne 1 || "$record" != *,* ]]; then
criticalecho "add-suggestions expects \"installed,old[,old...]\""
fi
IFS=',' read -r -a fields <<< "$record"
installed="${fields[0]:-}"
if [[ -z "$installed" || ${#fields[@]} -lt 2 ]]; then
criticalecho "add-suggestions expects \"installed,old[,old...]\""
fi
for name in "${fields[@]}"; do
if [[ -z "$name" || "$name" == *"/"* || "$name" == *" "* ]]; then
criticalecho "add-suggestions name must be one command token: ${name}"
fi
done
colorecho "Adding suggestions for ${installed}: ${record#*,}"
for ((i = 1; i < ${#fields[@]}; i++)); do
echo "${fields[i]},${installed}" >> /opt/.exegol_missing_commands
done
}

function add-test-gui-command() {
colorecho "Adding build pipeline test gui command: $*"
echo "$*" >> "/.exegol/unit_tests_gui_commands.txt"
Expand Down
54 changes: 51 additions & 3 deletions sources/install/package_ad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ function install_pypykatz() {
local version
version="$(git_version /opt/tools/pypykatz)"
add-to-list "pypykatz,${version},https://github.com/skelsec/pypykatz,a Python library for mimikatz-like functionality"
add-suggestions "pypykatz,mimikatz"
}

function install_krbjack() {
Expand Down Expand Up @@ -661,6 +662,7 @@ function install_enum4linux-ng() {
local version
version="$(pipx_version enum4linux-ng)"
add-to-list "enum4linux-ng,${version},https://github.com/cddmp/enum4linux-ng,Tool for enumerating information from Windows and Samba systems."
add-suggestions "enum4linux-ng,enum4linux"
}

function install_zerologon() {
Expand Down Expand Up @@ -1283,7 +1285,21 @@ function install_rusthound() {
# CODE-CHECK-WHITELIST=add-aliases
colorecho "Installing RustHound"
fapt gcc clang libclang-dev libgssapi-krb5-2 libkrb5-dev libsasl2-modules-gssapi-mit musl-tools gcc-mingw-w64-x86-64
cargo install rusthound
# cargo install rusthound (crates.io 1.1.69) resolves/locks time 0.3.30, which
# fails on modern rustc: E0282 in time-0.3.30/src/format_description/parse/*.rs.
# Clone upstream, bump the transitive time crate, install from path.
# Wait for fix: https://github.com/NH-RED-TEAM/RustHound/issues/40
# When fixed: remove the temp_fix_limit block and restore `cargo install rusthound`.
local temp_fix_limit="2027-03-21"
if check_temp_fix_expiry "$temp_fix_limit"; then
git -C /tmp clone --depth 1 https://github.com/NH-RED-TEAM/RustHound.git
cd /tmp/RustHound || exit
cargo update -p time
cargo install --path .
# Must leave before rm: a deleted cwd breaks later steps (getcwd).
cd /tmp || exit
rm -rf /tmp/RustHound
fi
add-history rusthound
add-test-command "rusthound --help"
local version
Expand Down Expand Up @@ -1399,6 +1415,8 @@ function install_relayinformer() {
local version
version="$(git_version /opt/tools/RelayInformer)"
add-to-list "RelayInformer,${version},https://github.com/zyn3rgy/RelayInformer,Determine EPA enforcement levels of popular NTLM relay targets from a Linux host."
add-suggestions "relayinformer,LdapRelayScan.py"
add-test-command "bash -c 'source /opt/.exegol_command_not_found.sh && exegol_missing_command_hint LdapRelayScan.py' 2>&1 | grep -q relayinformer"
}

function install_wsuks() {
Expand Down Expand Up @@ -1588,6 +1606,7 @@ function install_netexec() {
local version
version="$(git_version /opt/tools/NetExec)"
add-to-list "netexec,${version},https://github.com/Pennyw0rth/NetExec,Enumerate and attack network services. Successor to CrackMapExec."
add-suggestions "netexec,crackmapexec,cme"
}

function install_extractbitlockerkeys() {
Expand Down Expand Up @@ -1693,6 +1712,7 @@ function install_bloodyAD() {
local version
version="$(pipx_version bloodyAD)"
add-to-list "bloodyAD,${version},https://github.com/CravateRouge/bloodyAD,bloodyAD is an Active Directory privilege escalation swiss army knife."
add-suggestions "bloodyAD,aclpwn"
}

function install_autobloody() {
Expand Down Expand Up @@ -1896,17 +1916,44 @@ function install_pysnaffler() {
local version
version="$(git_version /opt/tools/pysnaffler)"
add-to-list "pysnaffler,${version},https://github.com/skelsec/pysnaffler,Snaffler. But in python."
add-suggestions "pysnaffler,snaffler"
add-test-command "bash -c 'shopt -s expand_aliases; source /opt/.exegol_aliases && source /opt/.exegol_command_not_found.sh && exegol_missing_command_hint snaffler' 2>&1 | grep -q pysnaffler"
}

function install_snaffler-ng() {
# CODE-CHECK-WHITELIST=add-aliases
colorecho "Installing snaffler-ng"
pipx install --system-site-packages 'snaffler-ng[socks]'
add-history snaffler
add-test-command "snaffler --help"
# pipx ships the console script as "snaffler". Keep that name free for the suggester.
mv -v /root/.local/bin/snaffler /root/.local/bin/snaffler-ng
add-history snaffler-ng
add-test-command "snaffler-ng --help"
add-test-command "bash -c '! command -v snaffler'"
local version
version="$(pipx_version 'snaffler-ng[socks]')"
add-to-list "snaffler-ng,${version},https://github.com/totekuh/snaffler-ng,Python port of Snaffler using Impacket. Finds credentials and sensitive files on SMB shares."
add-suggestions "snaffler-ng,snaffler"
add-test-command "bash -c 'source /opt/.exegol_command_not_found.sh && exegol_missing_command_hint snaffler' 2>&1 | grep -q snaffler-ng"
}

function install_snafflepy() {
# CODE-CHECK-WHITELIST=add-aliases
colorecho "Installing SnafflePy"
# Upstream console script is "snaffler". Expose this one as snafflepy so that name stays free for the suggester.
git -C /opt/tools/ clone --depth 1 https://github.com/S3cur3Th1sSh1t/SnafflePy
cd /opt/tools/SnafflePy || exit
python3 -m venv --system-site-packages ./venv
source ./venv/bin/activate
pip3 install .
deactivate
ln -sv /opt/tools/SnafflePy/venv/bin/snaffler /opt/tools/bin/snafflepy
add-history snafflepy
add-test-command "snafflepy --help"
local version
version="$(git_version /opt/tools/SnafflePy)"
add-to-list "snafflepy,${version},https://github.com/S3cur3Th1sSh1t/SnafflePy,Python port of Snaffler with the upstream rules and an HTML report"
add-suggestions "snafflepy,snaffler"
add-test-command "bash -c 'source /opt/.exegol_command_not_found.sh && exegol_missing_command_hint snaffler' 2>&1 | grep -q snafflepy"
}

function install_pygoldengmsa() {
Expand Down Expand Up @@ -2130,6 +2177,7 @@ function package_ad() {
install_remotemonologue # A tool to coerce NTLM authentications via DCOM
install_godap # A complete terminal user interface (TUI) for LDAP
install_powerview # Powerview Python implementation
install_snafflepy # Before the other Snaffler ports so `snaffler` suggests it first
install_pysnaffler # Snaffler, but in Python
install_snaffler-ng # Snaffler rules on SMB from Linux (Impacket)
install_evil-winrm-py # Evil-Winrm, but in Python
Expand Down
2 changes: 0 additions & 2 deletions sources/install/package_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,6 @@ function package_base() {
install_locales
cp -v /root/sources/assets/shells/exegol_shells_rc /opt/.exegol_shells_rc
cp -v /root/sources/assets/shells/exegol_command_not_found.sh /opt/.exegol_command_not_found.sh
cp -v /root/sources/assets/shells/missing-commands.csv /opt/.exegol_missing_commands
add-test-command "bash -c 'source /opt/.exegol_command_not_found.sh && exegol_missing_command_hint LdapRelayScan.py' 2>&1 | grep -q relayinformer"
cp -v /root/sources/assets/shells/bashrc ~/.bashrc
# Add /etc/zsh.d directory to import dynamically any script after /etc/zsh/zshrc
mkdir /etc/zsh.d && echo "test -d /etc/zsh.d && for f in \$(find -L /etc/zsh.d -maxdepth 1 -type f | sort); do source \$f; done" >> /etc/zsh/zshrc
Expand Down
5 changes: 5 additions & 0 deletions sources/install/package_c2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function install_pwncat() {
local version
version="$(pipx_version pwncat-vl)"
add-to-list "pwncat-vl,${version},https://github.com/Chocapikk/pwncat-vl,Maintained fork of pwncat-cs with recent fixes and enhancements."
add-suggestions "pwncat-vl,pwncat,pwncat-cs"
}

function install_metasploit() {
Expand Down Expand Up @@ -52,6 +53,9 @@ function install_metasploit() {
chown -R postgres:postgres /var/lib/postgresql/.bundle
chmod -R o+rx /opt/tools/metasploit-framework/
chmod 444 /opt/tools/metasploit-framework/.git/index # fatal: .git/index: index file open failed: Permission denied
# Rails 8+ (railties secret_key_base) mkdir's tmp/ during msfdb init as postgres
mkdir -p /opt/tools/metasploit-framework/tmp
chown postgres:postgres /opt/tools/metasploit-framework/tmp
sudo -u postgres sh -c "git config --global --add safe.directory /opt/tools/metasploit-framework && /usr/local/rvm/gems/ruby-3.3.8@metasploit-framework/wrappers/bundle exec /opt/tools/metasploit-framework/msfdb init"
cp -r /var/lib/postgresql/.msf4 /root

Expand Down Expand Up @@ -109,6 +113,7 @@ function install_sliver() {
local version
version="$(cli_version sliver --version)"
add-to-list "sliver,${version},https://github.com/BishopFox/sliver,Open source / cross-platform and extensible C2 framework"
add-suggestions "sliver-client,havoc,mythic,covenant,merlin"
}

function install_empire() {
Expand Down
2 changes: 2 additions & 0 deletions sources/install/package_cracking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function install_cracking_apt_tools() {
local version
version="$(apt_version hashcat)"
add-to-list "hashcat,${version},https://hashcat.net/hashcat,A tool for advanced password recovery"
add-suggestions "hashcat,pyrit,ophcrack"
version="$(apt_version fcrackzip)"
add-to-list "fcrackzip,${version},https://github.com/hyc/fcrackzip,Password cracker for zip archives."
version="$(apt_version pdfcrack)"
Expand Down Expand Up @@ -84,6 +85,7 @@ function install_haiti() {
local version
version="$(gem_version haiti-hash)"
add-to-list "haiti,${version},https://github.com/noraj/haiti,haiti is a A CLI tool (and library) to identify hash types (hash type identifier)."
add-suggestions "haiti,hashid,hash-identifier"
}

function install_geowordlists() {
Expand Down
3 changes: 3 additions & 0 deletions sources/install/package_desktop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ function install_xfce() {
sleep 6
# Remove log files of temp vncserver run ## TODO check if more
rm -f ~/.config/tigervnc/*.log ~/.xsession-errors
# The temporary server leaves /tmp/.X11-unix in the image. An empty
# directory must not be what desktop-start treats as "no X server".
rm -rf /tmp/.X11-unix /tmp/.X*-lock
[[ -d "/root/.config/xfce4/" ]] || echo "Directory /root/.config/xfce4/ does not exist."

# Binaries
Expand Down
1 change: 1 addition & 0 deletions sources/install/package_forensic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function install_volatility3() {
local version
version="$(pipx_version volatility3)"
add-to-list "volatility3,${version},https://github.com/volatilityfoundation/volatility3,Advanced memory forensics framework"
add-suggestions "vol,volatility,volatility2,vol2"
}

function install_trid() {
Expand Down
1 change: 1 addition & 0 deletions sources/install/package_misc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function install_aliasr() {
local version
version="$(pipx_version aliasr)"
add-to-list "aliasr,${version},https://github.com/Mojo8898/aliasr,Aliasr is a modern and feature-rich TUI launcher for penetration testing commands inspired by Arsenal but with significantly improved functionality."
add-suggestions "aliasr,arsenal"
}

function install_whatportis() {
Expand Down
Loading