<?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: rootshellace</title>
    <description>The latest articles on DEV Community by rootshellace (@rootshellace).</description>
    <link>https://dev.to/rootshellace</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%2F1228442%2F37707ff2-af7a-41f4-ad81-102fd552523f.png</url>
      <title>DEV Community: rootshellace</title>
      <link>https://dev.to/rootshellace</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rootshellace"/>
    <language>en</language>
    <item>
      <title>3 PowerShell commands to use in hacking</title>
      <dc:creator>rootshellace</dc:creator>
      <pubDate>Wed, 10 Jan 2024 17:27:08 +0000</pubDate>
      <link>https://dev.to/rootshellace/3-powershell-commands-to-use-in-hacking-4a9l</link>
      <guid>https://dev.to/rootshellace/3-powershell-commands-to-use-in-hacking-4a9l</guid>
      <description>&lt;p&gt;Sometimes, when you get access to a vulnerable machine, you might want to immediately run some predefined popular scripts, written in languages as Python. But you might have the surprise to not have it installed. This is why it’s important to be used to the command line, like &lt;em&gt;PowerShell&lt;/em&gt; or &lt;em&gt;Bash&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Today, I will present you 3 cmdlets which can help in hacking. We make the assumption that you obtained an admin shell on the target machine. Let’s see how we can use PowerShell!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;● Set-NetFirewallProfile&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will use this cmdlet to disable the firewall on the Windows machine where we obtained admin permissions. But first, we should see its status.&lt;/p&gt;

&lt;p&gt;To perform this, we will use a similar command, &lt;strong&gt;Get-NetFirewallProfile&lt;/strong&gt;, to retrieve the values for &lt;em&gt;Domain&lt;/em&gt;, &lt;em&gt;Private&lt;/em&gt; and &lt;em&gt;Public&lt;/em&gt;. You can simply run it without any other parameters and you will get the result. I added some things for a better formatted output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Get-NetFirewallProfile | Select-Object Name, Enabled | Format-Table
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On your screen, you should see a similar outcome:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name    Enabled
----    -------
Domain     True
Private    True
Public     True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means you have your firewall enabled for all 3. Now, let’s change it. We must add 2 parameters: &lt;em&gt;Profile&lt;/em&gt; and &lt;em&gt;Enabled&lt;/em&gt;. The first is to know which one you want to set, and the second one is for the status. So, in case we need to disable the public firewall, we will execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-NetFirewallProfile -Profile Public -Enabled False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;● Set-ItemProperty&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For our next example, we will alter the value of a specific registry key. This cmdlet can be used for various things; however, in this case, I am going to show how to disable &lt;strong&gt;UAC&lt;/strong&gt; (&lt;strong&gt;U&lt;/strong&gt;ser &lt;strong&gt;A&lt;/strong&gt;ccess &lt;strong&gt;C&lt;/strong&gt;ontrol). Keep in mind that this procedure requires a computer restart to take effect.&lt;/p&gt;

&lt;p&gt;The key’s name is &lt;em&gt;EnableLUA&lt;/em&gt;. Normally, its expected value is 1. To get UAC deactivated, it must be changed to 0.&lt;/p&gt;

&lt;p&gt;Three parameters are required in this situation: &lt;em&gt;Path&lt;/em&gt;, &lt;em&gt;Name&lt;/em&gt; and &lt;em&gt;Value&lt;/em&gt;. Our registry key is found in a specific path (check it on your computer! 😉), for the other two, I think you already know what it takes 😄.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA -Value 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once it’s executed, only a restart stands between you and the desired effect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;● Add-MpPreference&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our final instance will show us how to add an exception in &lt;em&gt;Windows Defender&lt;/em&gt;. This is quite simple, we only need one parameter, the &lt;em&gt;path&lt;/em&gt; we want to exclude from scanning. Let’s consider a case where you want to ignore directory &lt;em&gt;C:\MyPrivateTools&lt;/em&gt;. Just run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Add-MpPreference -ExclusionPath C:\MyPrivateTools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it! As simple as that! If, after a while, you change your mind and want this exception removed, you must execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Remove-MpPreference -ExclusionPath C:\MyPrivateTools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In case you want to see a demo on how these 3 cmdlets are executed and what is their effect, for instance, allowing you to run malicious programs, check my video below! 👇&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/UEaH89if9FE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;● Disclaimer&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This article is for educational purposes only. Attacking targets without prior mutual consent is illegal. I take no responsibility for any misuse or damage caused due to the usage of the information provided here.&lt;/p&gt;




&lt;p&gt;If you got here, I want to thank you for the time you took to read my article. I hope you enjoyed it and also learned something from it. Why not take a look at some of my other articles? Or, maybe, watch one of my YouTube videos?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Alternate Data Streams - Good or Bad?</title>
      <dc:creator>rootshellace</dc:creator>
      <pubDate>Fri, 08 Dec 2023 15:09:14 +0000</pubDate>
      <link>https://dev.to/rootshellace/alternate-data-streams-good-or-bad-38of</link>
      <guid>https://dev.to/rootshellace/alternate-data-streams-good-or-bad-38of</guid>
      <description>&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%2F1zy4fznjk9lujtpikau3.jpg" 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%2F1zy4fznjk9lujtpikau3.jpg" alt="Alternate Data Stream"&gt;&lt;/a&gt;&lt;br&gt;
Some people might say it’s good, others would consider it a bad thing. Well, as many elements in this world, it depends on its usage.&lt;/p&gt;

&lt;p&gt;● &lt;strong&gt;&lt;em&gt;What is an ADS?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you have a pair of jeans, and it has a pocket in your front-left size. You go to a tailor and he creates another one in the same place, but on the inside. The new one is attached to the existing compartment, but when it was created, the original wasn’t changed in any way. The shape, capacity or content remained the same.&lt;/p&gt;

&lt;p&gt;If somebody looks at your jeans, he will only see the front pocket, but he won’t notice the one on the inside, unless he already knows about its existence.&lt;/p&gt;

&lt;p&gt;Now, let’s try to correlate the terms. Assuming we have a file, &lt;em&gt;pizza_recipe.txt&lt;/em&gt;, we could say it represents the pair of jeans. The front pocket would be the content of the file, basically, ingredients and instructions for pizza. This is considered &lt;em&gt;the default stream&lt;/em&gt;. However, you might want to add a secret item. For instance, having another file, &lt;em&gt;secret.txt&lt;/em&gt;, attached to the original, where you say &lt;em&gt;“add extra mozzarella”&lt;/em&gt;. Your secret pocket would be &lt;em&gt;secret.txt&lt;/em&gt;, and its content, the data in this document.&lt;/p&gt;

&lt;p&gt;Each file comes with a default data stream, &lt;strong&gt;&lt;em&gt;$DATA&lt;/em&gt;&lt;/strong&gt;. This is illustrated by the actual data the file incorporates. In our previous example, it is the recipe itself. &lt;em&gt;&lt;strong&gt;MFT&lt;/strong&gt;&lt;/em&gt; (&lt;strong&gt;&lt;em&gt;M&lt;/em&gt;&lt;/strong&gt;aster &lt;strong&gt;&lt;em&gt;F&lt;/em&gt;&lt;/strong&gt;ile &lt;strong&gt;&lt;em&gt;T&lt;/em&gt;&lt;/strong&gt;able) contains a list of all streams a file has, as well as their location on the disk. Comparing to our case, we could consider MFT as our brain, because it knows about the hidden pocket and its location.&lt;/p&gt;

&lt;p&gt;● &lt;strong&gt;&lt;em&gt;How are they created?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before we begin with this part, I must mention one thing. Alternate Data Streams are specific to &lt;strong&gt;NTFS&lt;/strong&gt; &lt;em&gt;file system&lt;/em&gt;. If you copy a file which contains ADSs to a different type of file system, those ADSs will be lost.&lt;/p&gt;

&lt;p&gt;I will use the previous example and explain how to perform this action with PowerShell. However, this is not the only way to do it.&lt;/p&gt;

&lt;p&gt;First, we will create the standard file, in the current directory. In our case, &lt;em&gt;pizza_recipe.txt&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-Content -Value "Dough, toppings, bake" -Path .\pizza_recipe.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To read the content of this newly created document, we will use the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Get-Content -Path .\pizza_recipe.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we will create the ADS. The command is almost the same with the one used initially to create the normal file, the only difference being an extra parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-Content -Value "Mozzarella" -Path .\pizza_recipe.txt -Stream secret.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, to read the content of the ADS, just add Stream parameter to the command used earlier.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Get-Content -Path .\pizza_recipe.txt -Stream secret.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below, you can see a screenshot with all these commands executed and the corresponding result:&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%2Foeq6nb03oenwjr0pya2n.jpg" 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%2Foeq6nb03oenwjr0pya2n.jpg" alt="Create Alternate Data Stream"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;● &lt;strong&gt;&lt;em&gt;What are they used for?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The initial purpose for NTFS ADS was to be compatible with the file system from Apple.&lt;/p&gt;

&lt;p&gt;Anyway, this is not the only purpose. Sometimes, specific data is contained in an alternate data stream. I downloaded a simple .jpg photo from the internet, which has some info in an ADS.&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%2F3i281wa8hccj25s86tze.jpg" 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%2F3i281wa8hccj25s86tze.jpg" alt="ADS for a photo from the internet"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see above, that photo has 2 streams: the default one, &lt;em&gt;$DATA&lt;/em&gt;, and an extra ADS, called &lt;em&gt;Zone.Identifier&lt;/em&gt;. If we take a look at the content inside, we are able to see what kind of info it retains. A value for &lt;em&gt;HostUrl&lt;/em&gt; and another one for &lt;em&gt;ReferrerUrl&lt;/em&gt; are available.&lt;/p&gt;

&lt;p&gt;The previously presented example is harmless, its purpose is legitimate. But it’s not the unique usage. It can also be applied in steganography. Who says only secrets with extra mozzarella can be added there? It can include passwords, sensitive files, and so on. Is steganography good or bad? As I mentioned in the beginning of this article, it depends on how it’s used.&lt;/p&gt;

&lt;p&gt;However, not only text files can be embedded in alternate data streams. Other type of files might be carried as well. Photos, videos, or even executables. Well, a such situation can lead to the dark side. Malicious software can be incorporated in an ADS and bad things can happen, having various consequences.&lt;/p&gt;

&lt;p&gt;In my new video about ADS, among some info about this topic, I made a demo on how I create a backdoor by abusing alternate data streams. Don’t miss it!&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/9O6i0cIrCSk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;● &lt;strong&gt;&lt;em&gt;How to identify alternate data streams?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To detect the presence of an ADS, there are several possibilities. You can use standard Windows tools or external specialized software. Let’s see a couple of them.&lt;/p&gt;

&lt;p&gt;1) Run &lt;em&gt;dir&lt;/em&gt; command in &lt;em&gt;cmd&lt;/em&gt;, with &lt;em&gt;/r&lt;/em&gt; option&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%2Fj524vj33xksn5g4a5b32.jpg" 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%2Fj524vj33xksn5g4a5b32.jpg" alt="Detect ADS with dir command"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see in this screenshot that both streams were detected when the command was executed with &lt;em&gt;/r&lt;/em&gt; flag.&lt;/p&gt;

&lt;p&gt;2) Run &lt;em&gt;Get-Item&lt;/em&gt; cmdlet in &lt;em&gt;PowerShell&lt;/em&gt;, with &lt;em&gt;-Stream&lt;/em&gt; parameter&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%2Ff2u05a2zzm4xi8q9hb6x.jpg" 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%2Ff2u05a2zzm4xi8q9hb6x.jpg" alt="Detect ADS with Get-Item cmdlet"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, I extended a bit the command, just to format the output in a nicer way. However, it is enough to run only the first part to get the info you want. In this case also, both streams were found.&lt;/p&gt;

&lt;p&gt;3) Use &lt;em&gt;streams&lt;/em&gt; tool from &lt;em&gt;SysinternalsSuite&lt;/em&gt;&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%2F6f8pwz8hnd4euralxavm.jpg" 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%2F6f8pwz8hnd4euralxavm.jpg" alt="Detect ADS with streams tool"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using this software, all the hidden streams are revealed. The default stream is not shown.&lt;/p&gt;

&lt;p&gt;● &lt;strong&gt;&lt;em&gt;Disclaimer&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This article is for educational purposes only. Attacking targets without prior mutual consent is illegal. I take no responsibility for any misuse or damage caused due to the usage of the information provided here.&lt;/p&gt;




&lt;p&gt;If you got here, I want to thank you for the time you took to read my article. I hope you enjoyed it and also learned something from it. Why not take a look at some of my other articles? Or, maybe, watch one of my YouTube videos?&lt;/p&gt;

</description>
      <category>alternate</category>
      <category>data</category>
      <category>stream</category>
      <category>cybersecurity</category>
    </item>
  </channel>
</rss>
