# Kernel Exploits

Kernel exploits can leave the system in an unstable state, which is why you should only run them as a last resort.

Run the Linux [Exploit Suggester 2](https://github.com/jondonas/linux-exploit-suggester-2) tool to identify potential kernel exploits on the current system:

`perl /[path]/linux-exploit-suggester-2/linux-exploit-suggester-2.pl`

The popular Linux kernel exploit "[Dirty COW](https://dirtycow.ninja/)" should be listed. Exploit code for Dirty COW can be found at /home/user/tools/kernel-exploits/dirtycow/c0w\.c. It replaces the SUID file /usr/bin/passwd with one that spawns a shell.

Compile the code and run it (note that it may take several minutes to complete):

`gcc -pthread /[path]/dirtycow/c0w.c -o c0w`\
`./c0w`

Once the exploit completes, run /usr/bin/passwd to gain a root shell:

`/usr/bin/passwd`


---

# Agent Instructions: 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://shafagh.gitbook.io/try-hack-me/complete-begginer/privilege-esclation/examples/kernel-exploits.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.
