<?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 Madhukar Raina on Medium]]></title>
        <description><![CDATA[Stories by Madhukar Raina on Medium]]></description>
        <link>https://medium.com/@madhukarraina?source=rss-26084ccc464b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fTnP-kstPNmUzgagFug6Yg.jpeg</url>
            <title>Stories by Madhukar Raina on Medium</title>
            <link>https://medium.com/@madhukarraina?source=rss-26084ccc464b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 00:38:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@madhukarraina/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[Decoding encoded Powershell commands using Securonix SNYPR]]></title>
            <link>https://medium.com/securonix-tech-blog/decoding-encoded-powershell-commands-using-securonix-snypr-bfd7eeb0dab9?source=rss-26084ccc464b------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfd7eeb0dab9</guid>
            <category><![CDATA[securonix]]></category>
            <category><![CDATA[dfir]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[lol-script]]></category>
            <category><![CDATA[incident-response]]></category>
            <dc:creator><![CDATA[Madhukar Raina]]></dc:creator>
            <pubDate>Wed, 11 Aug 2021 09:08:46 GMT</pubDate>
            <atom:updated>2021-08-11T09:08:46.653Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why decode PowerShell commands?</h3><p><a href="https://en.wikipedia.org/wiki/PowerShell">PowerShell</a> is a powerful scripting language and shell framework that comes built-in in Windows systems and is used by system administrators to automate their work and for legitimate administration tasks. However, threat actors are increasingly leveraging tools that are already there on the targeted systems and PowerShell is heavily used by them to download executables from the Internet and to execute in memory (for example — Mimikatz).</p><p><a href="https://attack.mitre.org/techniques/T1059/001/">Adversaries use PowerShell</a> for obfuscation and execution and to create new tasks on remote hosts, identify misconfigurations, exfiltrate data, and execute other commands. While performing hunts on endpoint logs in <a href="https://www.securonix.com/products/next-generation-siem/">SNYPR</a>, our security analytics platform, we see a high number of PowerShell commands in logs that are encoded and require an analyst to decode them to see what’s behind them. In this blog, we’ll see how we can use SNYPR to decode a lot of the encoded PowerShell commands in Spotter.</p><p>Let’s look into the process creation logs, where we see the source process name, destination process name, command-line, and other important fields. In windows, Process creation is logged into the Security events as event ID 4688 or in the case of Sysinternals tool Sysmon, Process Creation is logged as event ID 1.</p><p>There are cases where the destination process is powershell.exe and the command-line contains encoded commands. To manually decode the PowerShell encoded commands and understand the command, an analyst usually copies the encoded part of the command and decode it using base64 utility in Linux:</p><pre> echo &lt;ENCODED-POWERSHELL-STRING&gt; | base64 -d </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jid7fVktGf895ya4" /><figcaption>Fig 1: PowerShell command decoded from base64</figcaption></figure><p>Or it can also be done using the below command in PowerShell:</p><pre>[System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String(‘ENCODED-POWERSHELL-STRING’))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/0*GG8Fc10AuHK-OdNx" /><figcaption>Fig 2: PowerShell command decoded using PowerShell</figcaption></figure><p>The problem here is that we have a lot of PowerShell encoded strings in logs, so it becomes difficult to decode all the encoded commands manually. Let’s see how we can do it in SNYPR using the existing functions.</p><h3>Finding PowerShell encoded commands</h3><p>In SNYPR, while performing hunting on endpoint logs, we usually see a high number of PowerShell commands in the logs that are encoded and require an analyst to decode those to see what’s the actual command. Let’s take an example of Crowdstrike logs where we have encoded PowerShell commands.</p><p>For the resource group “Crowdstrike Falcon”, the field that has the command line arguments is “resourcecustomfield1”, so we’ll apply a filter for “resourcecustomfield1” with *EncodedCommand* string and it’ll show results with PowerShell encoded commands like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tS1XjbnNO6wDl9mx" /><figcaption>Fig 3: Crowdstrike alerts with encoded PowerShell commands</figcaption></figure><p>In this scenario, the PowerShell commands displayed in the results are encoded; and an analyst would have to go and decode the commands manually to find what’s happening.</p><h3>Decoding the commands</h3><p>Instead of manually decoding each command and getting the results to find out what’s happening, we’ll use SNYPR to decode the commands for us. To do that, we’ll need to know below:</p><ol><li>The field containing the encoded command</li><li>The length of the field</li><li>The length of the non-encoded string</li></ol><p>We’ll use the EVAL operator to evaluate the above.</p><p>Our objective is to extract the encoded PowerShell command from the command-line field (mapped to <strong>resourcecustomfield1</strong>). Let’s first calculate the total length of the command-line using SNYPR’s <strong>LEN </strong>function, and then subtract the non-encoded initial part (using <strong>SUBSTR </strong>function) to get only the encoded command. We’ll store it in a new field and decode it later using SNYPR’s inbuilt function <strong>UNBASE64</strong>.</p><h3>Get the length of the field having encoded PowerShell command</h3><p>Consider the following example which shows the command-line parameters of PowerShell execution using encoded PowerShell commands:</p><pre>powershell.exe -NoProfile -EncodedCommand VwByAGkAdABlAC0ASABvAHMAdAAgACgARwBlAHQALQBXAG0AaQBPAGIAagBlAGMAdAAgAC0ATgBhAG0AZQBzAHAAYQBjAGUAIAByAG8AbwB0AFwAdwBtAGkAIAAtAEMAbABhAHMAcwAgAE0AUwBpAFMAQwBTAEkASQBuAGkAdABpAGEAdABvAHIAXwBNAGUAdABoAG8AZABDAGwAYQBzAHMAK</pre><p>We shall use the <strong>EVAL </strong>operator with the LEN() function to calculate the overall length of the command line:</p><pre>EVAL x=LEN(resourcecustomfield1)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DzNYU3bcOGt7Z3np" /><figcaption>Fig 4: Using the EVAL operator with LEN()</figcaption></figure><p>The total length of the command-line field is now stored in new field <strong>x</strong>.</p><h3>Subtract the part which is not encoded string</h3><p>Now that we have the total length of the command-line in <strong>x</strong>, the next step is to subtract the non-encoded part from the whole string.</p><p>To do this, we’ll use the <strong>SUBSTR </strong>function of the <strong>EVAL </strong>operator to extract only the encoded string:</p><pre>EVAL &lt;store-field&gt; = &lt;SUBSTR&gt; &lt; field &gt; &lt; start-position &gt; &lt;endposition&gt;</pre><p>Let’s name the store field as <strong>y </strong>and use the <strong>SUBSTR</strong> function on the command-line field:</p><pre>EVAL y=SUBSTR(resourcecustomfield1,42,x)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KJWAHEc22Z2B0lES" /><figcaption>Fig 5: Using SUBSTR with EVAL to extract the encoded string</figcaption></figure><p>We added 42 in the start position because 42 is the count of the non-encoded characters in the PowerShell command i.e. “powershell -NoProfile -Encodedcommand “ (including the space before the encoded part). In cases where the non-encoded part is different i.e. its PowerShell -enc or -e or other parameters are added, then this value will change.</p><p>This will return the substring of the actual field value which is encoded and store it in <strong>y</strong>, which contains the encoded command. Let’s see how to decode it further in SYNPR.</p><h3>Decode the encoded string</h3><p>Now that we have the encoded string in the variable <strong>y</strong>, we can use the <strong>UNBASE64 </strong>function to decode the encoded string to plain text.</p><pre> EVAL (store-field) = (UNBASE64) ( field )</pre><p>Let’s name the store-field as <strong>decodedcmd</strong> and pass <strong>y </strong>to it to decode the encoded command:</p><pre> EVAL decodedcmd = UNBASE64(y)</pre><p>This will result in adding a new field <strong>decodedcmd</strong> in the results, which will show the decoded PowerShell command as shown in the screenshot below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_q3Yk9gdtHVDFVVc" /><figcaption>Fig 6: Adding the decoded PowerShell command as a new field</figcaption></figure><p>Once the encoded string is decoded, we can do a <strong>STATS </strong>on the new field that we created along with the other important fields that are required to correlate it with the important data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Wegxua8liGI5avy0" /><figcaption>Fig 7: Using STATS for correlation with important data</figcaption></figure><h3>Conclusion</h3><p>SNYPR can be really helpful in decoding the bulk of encoded PowerShell commands by making use of the built-in functionalities (i.e. EVAL, UNBASE64 function) which come in handy while dealing with bulk encoded commands in the threat hunting programs. For visibility over the PowerShell activity, the best practice is to always turn on the Module logging, Script Block logging for PowerShell, which records the deobfuscated commands and outputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/0*lEO1ricPvwD6x3y2" /><figcaption>Fig 8: Turning on Module Logging for PowerShell</figcaption></figure><p>These events with decoded commands and script blocks are logged under event ID 4103 and 4104.</p><p><em>Securonix Threats Labs researches cutting-edge security topics to drive our industry-leading security analytics and operations platform. Check out </em><a href="https://www.securonix.com/securonix-threat-research-lab/"><em>Securonix </em></a>Threat Labs <em>for up to date advisories and alerts for emerging threats</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfd7eeb0dab9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/securonix-tech-blog/decoding-encoded-powershell-commands-using-securonix-snypr-bfd7eeb0dab9">Decoding encoded Powershell commands using Securonix SNYPR</a> was originally published in <a href="https://medium.com/securonix-tech-blog">Securonix Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Detecting LDAP enumeration and Bloodhound‘s Sharphound collector using Active Directory Decoys]]></title>
            <link>https://medium.com/securonix-tech-blog/detecting-ldap-enumeration-and-bloodhound-s-sharphound-collector-using-active-directory-decoys-dfc840f2f644?source=rss-26084ccc464b------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfc840f2f644</guid>
            <category><![CDATA[threat-intelligence]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[deception]]></category>
            <category><![CDATA[threat-research]]></category>
            <category><![CDATA[active-directory]]></category>
            <dc:creator><![CDATA[Madhukar Raina]]></dc:creator>
            <pubDate>Wed, 28 Jul 2021 07:09:50 GMT</pubDate>
            <atom:updated>2021-07-28T16:46:09.438Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Detecting LDAP enumeration and </strong>Bloodhound‘s Sharphound collector <strong>using AD Decoys</strong></h3><p><strong>Introduction</strong></p><p>In this blog post, we’ll discuss how to detect enumeration done by Bloodhound’s SharpHound collector and LDAP Reconnaissance activities in an Active Directory environment. We’ll be using deception to detect this by creating a few decoy accounts (or honey accounts) and mixing them with the real accounts. Decoy accounts are the ones that are created for deceptive purposes and are also used in defense to detect malicious actions. MITRE has covered <a href="https://attack.mitre.org/software/S0521/">Bloodhound</a> and <a href="https://attack.mitre.org/techniques/T1482/">Domain enumeration</a> in their tools and techniques.</p><p>Active Directory is a centralized database that describes a company’s structure and contains information about different objects like users, computers, groups and. and their relation to each other in the environment. In active directory, decoy accounts can be created in the form of user accounts, group accounts, service accounts, computer accounts, etc. Relevant details can be added to make a system, service, groups, etc. look more realistic. And when the Active Directory objects data is enumerated, it also enumerates the decoy accounts and can be used to raise an alert when the reconnaissance activity happens.</p><p><strong>Bloodhound</strong></p><p>Bloodhound is a tool that is generally used by adversaries to visually map an organization’s Active Directory structure and analyze it to find its weaknesses. Being able to analyze the Active Directory is very useful to attackers to identify which objects are worth targeting in an organization. Any user within an active directory domain can interrogate their organization’s Active Directory which runs on the domain controllers.</p><p>Bloodhound uses the collector which is called as SharpHound to collect various kinds of data by running a ton of LDAP queries to collect information within Active Directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Dp2YDCGUT1SDUEsRjrg2w.png" /><figcaption>Fig.1 Sharphound querying the Active Directory</figcaption></figure><p>In the above screenshot, we can see that the Sharphound has enumerated 222 objects in the Active Directory and saved the results in compressed files. Once the zipped files with the results of all the Active Directory objects, groups, sessions, trusts, etc. are collected and imported into Bloodhound, it uses graph theory for data visualization running the Neo4j graph database in the backend. The output after importing the collected data into Bloodhound looks similar to the data shown in the below screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*29KtMttbk7vCVlBBqsymMA.png" /><figcaption>Fig.2 Bloodhound showing the Attack path</figcaption></figure><p>Now the information gathered from Active Directory (using SharpHound) is used by attackers to make sense out of the AD data and analyze it to understand the target organization’s AD structure and find out various interesting facts and shortcut paths to get to a Domain Admin and the permissions of users on different hosts etc.</p><p>In the backend, Sharphound uses LDAP queries to collect data from Active Directory as you can see in the code:</p><p><a href="https://github.com/BloodHoundAD/SharpHound/blob/41516e778ea186e144e4494f2e070cdb9aa878b9/Sharphound2/Enumeration/LdapFilter.cs#L58">https://github.com/BloodHoundAD/SharpHound/blob/41516e778ea186e144e4494f2e070cdb9aa878b9/Sharphound2/Enumeration/LdapFilter.cs#L58</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AvNRHI_rclvkUdGm" /><figcaption>Fig.3 Sharphound LDAP queries</figcaption></figure><p>Sharphound collector queries for the details like all the AD objects including all enabled accounts, disabled accounts, accounts with SPN, all the organisational units, group policy objects, all the security and non-security groups in AD, groups in the Builtin container, etc.</p><p>We’ll take a look at the LDAP queries that it runs in the backend and will try to detect both the Sharphound enumeration and if the LDAP queries are sent without sharphound.</p><p><strong>LDAP Queries</strong></p><p>Let’s see the kind of LDAP queries that Sharphound runs in the backend:</p><pre>(|(|(samaccounttype=268435457)(samaccounttype=268435456)(samaccounttype=536870913)(samaccounttype=536870912)(primarygroupid=*))(&amp;(sAMAccountType=805306369)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))(|(samAccountType=805306368)(samAccountType=805306369)(samAccountType=268435456)(samAccountType=268435457)(samAccountType=536870913)(samAccountType=536870912)(objectClass=domain)(&amp;(objectcategory=groupPolicyContainer)(flags=*))(objectcategory=organizationalUnit))(objectclass=domain)(|(samaccounttype=268435456)(samaccounttype=268435457)(samaccounttype=536870913)(samaccounttype=536870912)(samaccounttype=805306368)(samaccounttype=805306369)(objectclass=domain)(objectclass=organizationalUnit)(&amp;(objectcategory=groupPolicyContainer)(flags=*)))(|(&amp;(&amp;(objectcategory=groupPolicyContainer)(flags=*))(name=*)(gpcfilesyspath=*))(objectClass=domain)(objectcategory=organizationalUnit))(&amp;(serviceprincipalname=*)(samaccounttype=805306368)))</pre><p>If we run these LDAP queries without SharpHound and using tools like ADFind, it also returns the data that is requested:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/0*ne_sG-agNB1cA4zP" /><figcaption>Fig.4 Performing LDAP enumeration</figcaption></figure><p>In the result, we can see that 222 objects have been enumerated (same as Sharphound) and we have all the details in the output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/0*HBg2TXD0bqABi4DH" /><figcaption>Fig.5 LDAP enumeration results</figcaption></figure><p><strong>Configuring the AD Environment</strong></p><p>Below are the tasks that we’ll perform:</p><ol><li>Create a few Active Directory Decoy accounts</li><li>Enable auditing on those accounts</li><li>Run Bloodhound’s Sharphound tool</li><li>Perform LDAP Reconnaissance activities within the active directory environment</li><li>Detect the activities in Windows event logs.</li></ol><p>The reason for creating decoys to detect this kind of activity is that when the domain enumeration is done and Active Directory objects data is enumerated, it also includes the decoy accounts. Decoys accounts are created to make sure that we enable audit logging only on a few decoy accounts and not for all the objects to minimize the noise.</p><p>First of all, let’s make sure that the AD environment is configured properly with the advanced logging policies enabled, that are required to accomplish this task. The only policy that is required to detect this enumeration process is the Directory service Access Audit policy. On the domain controllers, it is enabled by default. If it is disabled, we can enable it on the domain controller by using the auditpol command as shown below:</p><p>Below is the command to enable the advanced auditing required for this:</p><pre>auditpol /set /subcategory:”Directory Service Access” /Success:Enable</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/0*2zGdV2yQxizOIoYm" /><figcaption>Fig.6 Enable Advanced Audit Logging</figcaption></figure><p>We should see the Success once the policy is enabled:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/0*mUBuZsAJQMPPVqzi" /><figcaption>Fig.7 Verify Advanced Audit Logging</figcaption></figure><p>Now that the required audit policy is enabled, we’ll create decoy objects now. Let’s start first with the decoy user object.</p><p><strong>Create Decoy User Objects</strong></p><p>We’ll create decoy user objects from the Active Directory Users and Computers MMC (Microsoft Management Console) and enable auditing for them. To do this, below are the steps:</p><ul><li>Right-click the user object- Properties — Go to Security&gt;Advanced&gt;Auditing and add a new audit entry</li><li>Add a new Principal “Everyone”</li><li>From “Applies to” dropdown, choose “This object only”</li><li>Uncheck all main permissions.</li><li>Select Read all properties, Read permissions.</li><li>Click OK to save the changes.</li></ul><p>Below is the graphical representation of how it can be done using the GUI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*MWSXmpKU9iKzNcDT" /><figcaption>Fig.8 Create Decoy User Account</figcaption></figure><p>This can also be done using PowerShell:</p><pre>New-ADUser -Name “Josh Austin” -GivenName “Josh” -Surname “Austin” -SamAccountName “Josh.Austin” -UserPrincipalName “Josh.Austin@threatlab.corp” -Path “OU=Managers,DC=threatlab,DC=corp” -AccountPassword(Read-Host -AsSecureString “Please enter password”) -Enabled $true</pre><p><strong>Note: </strong>The Read-Host parameter will ask you to input a new password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cctJZzzJyM1u4zU2IGBsKA.png" /><figcaption>Fig.9 Create Decoy User Account using PowerShell</figcaption></figure><p><strong>Creating Decoy Computer Object</strong></p><p>We’ll create decoy computer objects from the AD Users and Computers MMC Snap-in. To do this, below are the steps from the AD Users and Computers MMC:</p><ul><li>Right-click the computer object — Properties — Go to Security&gt;Advanced&gt;Auditing and add a new audit entry</li><li>Add a new Principal “Everyone”</li><li>From “Applies to” dropdown, choose “This object only”</li><li>Uncheck all main permissions. Select Read all properties, Read permissions.</li><li>Click OK to save the changes.</li></ul><p>Below is the graphical representation of how it can be done using the GUI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/0*P8zMs17vHysWNq0o" /><figcaption>Fig.10 Create Decoy Computer Account</figcaption></figure><p>This can also be done using PowerShell:</p><pre>New-ADComputer -Name “THL-SRV2” -SamAccountName “THL-SRV2” -Path “OU=ApplicationServers,DC=THREATLAB,DC=CORP”</pre><p>After the computer account is created, you can view its properties using Get-ADcomputer command as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/0*I0Y4Tk15Xmct6Q1Y" /><figcaption>Fig.11 Create Decoy Computer Account using PowerShell</figcaption></figure><p><strong>Creating Decoy Group Object</strong></p><p>We’ll also create decoy Group objects from the AD Users and Computers MMC and enable auditing for them:</p><ul><li>Right-Click IT Helpdesk — Properties — Go to Security&gt;Advanced&gt;Auditing and add a new audit entry</li><li>Add a new Principal “Everyone”</li><li>From “Applies to” dropdown, choose “This object only”</li><li>Uncheck all main permissions.</li><li>Select Read all properties, Read permissions.</li><li>Click OK to save the changes.</li></ul><p>Below is the graphical representation of how it can be done using the GUI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G0Kxd4NEPsjXkXlL" /><figcaption>Fig.12 Create Decoy Group Account</figcaption></figure><p>This can also be done using Powershell:</p><pre>New-ADGroup -name “IT Helpdesk” -GroupScope Global</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/0*rHSnQiSLErbEwG1D" /><figcaption>Fig.13 Create Decoy Group Account using PowerShell</figcaption></figure><p><strong>Configuring Decoy User, Group, and computer Objects</strong></p><p>It’s important to mimic the decoy accounts to look as realistic as the other Active Directory objects. The naming convention of decoy objects should match the normal Active Directory accounts. We’ll also add details in the common attributes of the objects as follows:</p><ul><li>Add details in the description, organisation attributes of the decoy user objects</li><li>Add details in the operating system name, version, and DNS name attributes for computer accounts</li><li>In the case of groups, make sure to add the group information, add members and make it look legitimate.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/0*FSs-zij8-R1U77qQ" /><figcaption>Fig.14 Add details to make decoys accounts look more real</figcaption></figure><p><strong>Run Bloodhound’s Sharphound Collector</strong></p><p>After configuring the environment and creating decoy accounts, we’ll run SharpHound now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*azVN_aR4HQ_cP5nI" /><figcaption>Fig.15 Running Blodhound’s Sharphound collector</figcaption></figure><p><strong>Performing the LDAP Enumeration</strong></p><p>We’ll also perform the normal LDAP enumeration using the <a href="https://attack.mitre.org/software/S0552/">ADFind </a>tool. AdFind is a free command-line query tool that can be used for performing LDAP enumeration to gather information from Active Directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/0*B2xm77Se6kEdaVIV" /><figcaption>Fig.16 Performing LDAP enumeration using ADFind</figcaption></figure><p><strong>Detections (Event 4662)</strong></p><p>Any activities related to enumeration of the Active Directory environment by using Bloodhound’s SharpHound and also the LDAP enumeration performed by tools like ADFind for the Decoy accounts will be logged under event ID <strong>4662 </strong>in Windows Security events.</p><p><strong>Enumeration attempt on the Decoy Group Account:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/0*POocFPFhKGNh6aHA" /><figcaption>Fig.17 Detecting LDAP enumeration on the decoy group account</figcaption></figure><p><strong>Enumeration attempt on the Decoy Computer Account:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/0*sYnNPFuGPo-gwg0H" /><figcaption>Fig.18 Detecting LDAP enumeration on the decoy computer account</figcaption></figure><p><strong>Enumeration attempt on the Decoy User Account:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/0*ab6GgykBTCniNcHG" /><figcaption>Fig.19 Detecting LDAP enumeration on a decoy user account</figcaption></figure><p><strong>Note</strong>: As you can see in the above screenshot, Event Viewer shows the values of Object Name and Object type, but while forwarding the events, windows doesn’t forward the Object Name value in the logs. Instead, it forwards the object GUID value for the Object Name and object Type which looks like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/0*gFNAjuMFyrWKJKS7" /><figcaption>Fig.20 Object GUID in Windows Event log forwarding</figcaption></figure><p>So while creating detection rules, it’s important to include the object GUID value of the decoy objects in the use cases to alert only for the events and not for other 4662 events in the environment.</p><p><strong>Example Spotter Query:</strong></p><pre>resourcegroupname = “ms_windows-security” and baseeventid = 4662 and devicecustomstring1 = “Read Property” and filename = “%{afd7a537–221e-42bd-8063–29c751a32734}”</pre><p>This kind of rule will result in the events when there is a “Read Property” type access attempt on the AD object with GUID “%{afd7a537–221e-42bd-8063–29c751a32734}” which means the decoy account only.</p><p><strong>Conclusion</strong></p><p>Our goal as a defender is to disrupt the adversary activity in the network. And using deception, it is possible to detect the presence of adversaries. More deception content can be added to strengthen the defense strategy like decoy network shares etc.</p><p>Some of the best practices while designing the deception are :</p><ul><li>Add Decoy Groups with *Admin* in the group name. Because adversaries usually search for *Admin* in LDAP queries to enumerate the high privilege accounts</li><li>Create Decoys in important protected as well like Domain Admins</li><li>Create decoy network shares and enable auditing</li><li>Place users and computers in different OUs</li><li>Create Computer objects as Decoys and assign unconstrained delegation as adversaries would like those accounts as interesting</li><li>Always create long and difficult passwords for Decoy accounts</li><li>And if more decoy accounts are sitting in different places, we have more information when reconnaissance activities are going on</li></ul><p><em>Securonix Threats Labs researches cutting-edge security topics to drive our industry-leading security analytics and operations platform. Check out the </em><a href="https://www.securonix.com/blog/"><em>Securonix blog</em></a><em> for up to date advisories and alerts for emerging threats</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfc840f2f644" width="1" height="1" alt=""><hr><p><a href="https://medium.com/securonix-tech-blog/detecting-ldap-enumeration-and-bloodhound-s-sharphound-collector-using-active-directory-decoys-dfc840f2f644">Detecting LDAP enumeration and Bloodhound‘s Sharphound collector using Active Directory Decoys</a> was originally published in <a href="https://medium.com/securonix-tech-blog">Securonix Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>