CTF-WEB-babyphp #assert#git泄露

babyphp——61dctf{8e_careful_when_us1ng_ass4rt}

描述:

http://web.jarvisoj.com:32798/
昨儿做梦的时候我在梦里写了这个网站,印象中我用了这些东西:PHP,GIT,Bootstrap

分析:

  1. 猜测是git文件泄露但是不知道怎么找!扫描了一下目录看到http://web.jarvisoj.com:32798/.git,自己是肯定搞不定的还好我们有李姐姐!
    git clone https://github.com/lijiejie/GitHack
    python GitHack.py http://web.jarvisoj.com:32798/.git/
    注意前面一定要有http,结尾也必须加上/。下下来后我们cat index.php看到:
    

分析代码可以得到:

  • 需要传个page参数
  • file = "templates/" . $page . ".php"
  • 通过assert函数进行了两次友好()的判断回显,如果不符合假定,就执行or后面的语句
  1. 好的卡住了!搜了下发现这里的考点是assert,bool assert(mixed $assertion[,string $description]),如果assertion是字符串,他会被assert()当做php代码执行。
    会!执!行!啊!

    也是……人家都判断strpos和file_exists了,为什么不能执行phpinfo()!大家都是php函数,有谁比谁高贵()
    思路是通过可控变量file传入恶意参数,构造闭合 file_exists(),使assert()执行恶意代码。于是我们试探性的……
  • ') or phpinfo();# ——即变成file_exists('') or phpinfo();# ,结果为执行phpinfo(),注意要url编码,本处为了方便阅读,以编码前显示
  • ') or print_r(file_get_contents('templates/flag.php');# ——然后在源代码里(临门一脚不要被坑了)
    即最终payload:?page=')%20or%20print_r(file_get_contents('templates%2fflag.php'))%3b%23
image.png

总结

今天的两个点我都不会!但是现在我都会了!谢谢李姐姐!()

你可能感兴趣的:(CTF-WEB-babyphp #assert#git泄露)