<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Cracking on Gill.Singh.A</title>
        <link>https://Gill-Singh-A.github.io/tags/cracking/</link>
        <description>Recent content in Cracking on Gill.Singh.A</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-us</language>
        <lastBuildDate>Fri, 21 Mar 2025 23:30:23 +0530</lastBuildDate><atom:link href="https://Gill-Singh-A.github.io/tags/cracking/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>Cracking Linux Hashes and Expanding Access</title>
        <link>https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/</link>
        <pubDate>Fri, 21 Mar 2025 23:30:23 +0530</pubDate>
        
        <guid>https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/</guid>
        <description>&lt;img src="https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/attack_path.png" alt="Featured image of post Cracking Linux Hashes and Expanding Access" /&gt;&lt;h2 id=&#34;initial-entry-point&#34;&gt;Initial Entry Point
&lt;/h2&gt;&lt;p&gt;During a routine exploration of vulnerable servers on the internet, I successfully gained root access to several machines. While the specific method used to achieve root access is beyond the scope of this blog, I’ll focus on how I expanded my access to other servers within the same organization.&lt;/p&gt;
&lt;h2 id=&#34;extracting-linux-user-hashes&#34;&gt;Extracting Linux User Hashes
&lt;/h2&gt;&lt;p&gt;Once inside the compromised machine, I noticed multiple user accounts. With root privileges, I accessed the &lt;em&gt;/etc/shadow&lt;/em&gt; file, which stores password hashes for all users on the system.&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/shadow_file.png&#34;
	width=&#34;841&#34;
	height=&#34;841&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/shadow_file_hu3672731679349725699.png 480w, https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/shadow_file_hu5329670692442262125.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Shadow File&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;100&#34;
		data-flex-basis=&#34;240px&#34;
	
&gt;&lt;br /&gt;
I copied the contents of the shadow file to my local machine and extracted the hashes using the following command:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cat shadow_file &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; cut -d &lt;span class=&#34;s1&#34;&gt;&amp;#39;:&amp;#39;&lt;/span&gt; -f2 &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; sort &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; uniq &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; grep -v &lt;span class=&#34;s1&#34;&gt;&amp;#39;[!-*]&amp;#39;&lt;/span&gt; &amp;gt; hashes
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;&lt;img src=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/hashes.png&#34;
	width=&#34;1156&#34;
	height=&#34;268&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/hashes_hu9024913798855049347.png 480w, https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/hashes_hu8052994993040619573.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Hashes&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;431&#34;
		data-flex-basis=&#34;1035px&#34;
	
&gt;&lt;br /&gt;
This command isolates the hashes, removes unnecessary characters, and saves them to a file named &lt;code&gt;hashes&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;identifying-the-hash-type&#34;&gt;Identifying the Hash Type
&lt;/h2&gt;&lt;p&gt;The next step was to determine the type of hash used. I referenced &lt;a class=&#34;link&#34; href=&#34;https://hashcat.net/wiki/doku.php?id=example_hashes&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Hashcat’s Example Hashes&lt;/a&gt; to identify the hash format. In this case, the hashes were of type &lt;strong&gt;sha512crypt&lt;/strong&gt;, which includes salting for added security.&lt;/p&gt;
&lt;h2 id=&#34;selecting-a-wordlist&#34;&gt;Selecting a Wordlist
&lt;/h2&gt;&lt;blockquote&gt;
&lt;p&gt;&amp;ldquo;Hacking is about patience. If you rush, you lose. If you’re too slow, you lose. Timing is everything.&amp;rdquo; - Mr. Robot&lt;/p&gt;
&lt;/blockquote&gt;
&lt;!-- --&gt;
&lt;p&gt;With the hash type identified, I needed a suitable wordlist for a dictionary attack. Given the presence of salting, using an excessively large wordlist would be inefficient. I opted for the &lt;a class=&#34;link&#34; href=&#34;https://github.com/danielmiessler/SecLists/blob/master/Passwords/Leaked-Databases/rockyou.txt.tar.gz&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;rockyou&lt;/a&gt; wordlist, a popular choice for password cracking due to its manageable size and effectiveness. You can explore other useful wordlists on platforms like &lt;a class=&#34;link&#34; href=&#34;https://github.com/danielmiessler/SecLists&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;SecLists&lt;/a&gt; and &lt;a class=&#34;link&#34; href=&#34;https://weakpass.com/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;WeakPass&lt;/a&gt;.&lt;br /&gt;
For more advanced scenarios, tools like &lt;a class=&#34;link&#34; href=&#34;https://github.com/Mebus/cupp&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;CUPP (Common User Passwords Profiler)&lt;/a&gt; can generate custom wordlists tailored to specific users or organizations. Additionally, leveraging GPU resources can significantly speed up the cracking process. For a deeper dive into password cracking techniques, check out this &lt;a class=&#34;link&#34; href=&#34;https://gill-singh-a.github.io/p/password-cracking/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Password Cracking Blog&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;cracking-the-hashes&#34;&gt;Cracking the Hashes
&lt;/h2&gt;&lt;p&gt;I used &lt;strong&gt;Hashcat&lt;/strong&gt;, a powerful password-cracking tool, to crack the extracted hashes. The command I used was:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;hashcat -a &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt; -m &lt;span class=&#34;m&#34;&gt;1800&lt;/span&gt; path_to_hashes_file path_to_wordlist
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h3 id=&#34;explanation-of-arguments&#34;&gt;Explanation of Arguments:
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-a 0&lt;/code&gt;: Specifies a dictionary attack.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-m 1800&lt;/code&gt;: Indicates the hash type (sha512crypt).&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- --&gt;
&lt;p&gt;After running the command, Hashcat successfully cracked two of the hashes. Below is an example of one of the cracked hashes:&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/hash_cracking.png&#34;
	width=&#34;989&#34;
	height=&#34;874&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/hash_cracking_hu2398366856187407432.png 480w, https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/hash_cracking_hu5949150121733445545.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Cracked Hash&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;113&#34;
		data-flex-basis=&#34;271px&#34;
	
&gt;&lt;/p&gt;
&lt;h2 id=&#34;discovering-additional-machines&#34;&gt;Discovering Additional Machines
&lt;/h2&gt;&lt;p&gt;With the cracked credentials in hand, my next goal was to identify other machines within the same organization. I began by gathering information about the compromised server’s owner or organization. Using tools like &lt;strong&gt;Shodan&lt;/strong&gt;, I extracted details such as the organization name, ISP (Internet Service Provider), ASN (Autonomous System Number), and subnet associated with the server’s IP address.&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/shodan_host_information.png&#34;
	width=&#34;948&#34;
	height=&#34;431&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/shodan_host_information_hu14698924062869139471.png 480w, https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/shodan_host_information_hu4208050796426702305.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Server Details&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;219&#34;
		data-flex-basis=&#34;527px&#34;
	
&gt;&lt;br /&gt;
Using this information, I filtered Shodan search results to compile a list of IP addresses belonging to the same organization, ISP, or subnet.&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/shodan_search.png&#34;
	width=&#34;1920&#34;
	height=&#34;951&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/shodan_search_hu18008454021057110726.png 480w, https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/shodan_search_hu3654070958966295453.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Filtered Shodan Search&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;201&#34;
		data-flex-basis=&#34;484px&#34;
	
&gt;&lt;/p&gt;
&lt;h2 id=&#34;gaining-access-to-other-machines&#34;&gt;Gaining Access to Other Machines
&lt;/h2&gt;&lt;blockquote&gt;
&lt;p&gt;&amp;ldquo;Credentials are the keys to the kingdom. Once you have them, you can go anywhere.&amp;rdquo; - Mr. Robot&lt;/p&gt;
&lt;/blockquote&gt;
&lt;!-- --&gt;
&lt;p&gt;Armed with a list of IP addresses and valid credentials, I launched a SSH brute-force attack using the &lt;a class=&#34;link&#34; href=&#34;https://github.com/Gill-Singh-A/SSH-Brute-Force&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Gill-Singh-A/SSH-Brute-Force&lt;/a&gt; tool. This allowed me to authenticate successfully on several other machines within the organization.&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/ssh_brute_force.png&#34;
	width=&#34;785&#34;
	height=&#34;223&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/ssh_brute_force_hu7351718088844256057.png 480w, https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/ssh_brute_force_hu2408174159892381674.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;SSH Brute-Force Logs of 1 pair of Credential&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;352&#34;
		data-flex-basis=&#34;844px&#34;
	
&gt;&lt;/p&gt;
&lt;h2 id=&#34;attack-path-visualization&#34;&gt;Attack Path Visualization
&lt;/h2&gt;&lt;p&gt;Below is a visual representation of the attack path, created using &lt;a class=&#34;link&#34; href=&#34;https://www.maltego.com/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Maltego&lt;/a&gt;:&lt;br /&gt;
&lt;img src=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/attack_path.png&#34;
	width=&#34;1148&#34;
	height=&#34;719&#34;
	srcset=&#34;https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/attack_path_hu13275239387980571932.png 480w, https://Gill-Singh-A.github.io/p/cracking-linux-hashes-and-expanding-access/assets/images/attack_path_hu9965436999406051511.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Attack Path&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;159&#34;
		data-flex-basis=&#34;383px&#34;
	
&gt;&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion
&lt;/h2&gt;&lt;p&gt;This exercise highlights how a single compromised machine can serve as a gateway to an entire network. By extracting and cracking Linux user hashes, identifying related machines using Shodan, and leveraging brute-force techniques, I was able to expand my access across multiple servers within the organization.&lt;/p&gt;
&lt;h2 id=&#34;mitigations&#34;&gt;Mitigations
&lt;/h2&gt;&lt;p&gt;To prevent such attacks, organizations should implement the following security measures:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Strong Password Policies&lt;/strong&gt;: Enforce the use of complex, unique passwords and mandate regular password changes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multi-Factor Authentication (MFA)&lt;/strong&gt;: Implement MFA for SSH and other critical services to add an extra layer of security.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Regular Audits&lt;/strong&gt;: Conduct regular security audits to identify and address vulnerabilities, including weak passwords and misconfigurations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Limit SSH Access&lt;/strong&gt;: Restrict SSH access to specific IP addresses or networks and disable root login.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Monitor Logs&lt;/strong&gt;: Continuously monitor system logs for suspicious activity, such as repeated failed login attempts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Patch Management&lt;/strong&gt;: Keep all systems and software up to date with the latest security patches.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Segmentation&lt;/strong&gt;: Segment networks to limit lateral movement in case of a breach.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Educate Users&lt;/strong&gt;: Train employees and system administrators on security best practices, including password hygiene and phishing awareness.&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- --&gt;
&lt;p&gt;By adopting these measures, organizations can significantly reduce the risk of unauthorized access and lateral movement within their networks.&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
