<?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 Rob Harrand on Medium]]></title>
        <description><![CDATA[Stories by Rob Harrand on Medium]]></description>
        <link>https://medium.com/@tentotheminus9?source=rss-8b08ce01a167------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*lm0-PIT7orMTEBML.jpeg</url>
            <title>Stories by Rob Harrand on Medium</title>
            <link>https://medium.com/@tentotheminus9?source=rss-8b08ce01a167------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 22:00:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tentotheminus9/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[Python & MITRE ATT&CK: Part 15/15]]></title>
            <link>https://infosecwriteups.com/python-mitre-att-ck-part-15-15-8f631bc20499?source=rss-8b08ce01a167------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f631bc20499</guid>
            <category><![CDATA[mitre-attack]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cybercrime]]></category>
            <dc:creator><![CDATA[Rob Harrand]]></dc:creator>
            <pubDate>Fri, 25 Apr 2025 08:20:05 GMT</pubDate>
            <atom:updated>2025-04-25T08:20:05.498Z</atom:updated>
            <content:encoded><![CDATA[<h4>Wrap-up</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2jPjP_FW3m9bXDRx" /><figcaption>Photo by <a href="https://unsplash.com/@lg17?utm_source=medium&amp;utm_medium=referral">Lance Grandahl</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>(🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-14-15-eb6dfdbca34b"><strong>&lt;- Link to back to Part 14</strong></a><strong> 🔗)</strong></p><h3>Wrap-up</h3><p>In this blog series we’ve seen examples from an imaginary attack on a healthcare company. We began with the attackers discussing their target in a dark web discussion, followed by the creation of resources, a phishing attack, through the discovery of the network, the finding of data, and leading to its eventual exfiltration and destruction.</p><p>Specifically, we’ve covered the following stages and techniques,</p><ul><li><strong>Reconnaissance:</strong> Gather Victim Network Information: Network Topology (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1590%2F004%2F">ID: T1590.004</a>)</li><li><strong>Resource Development:</strong> Acquire Infrastructure: Domains (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1583%2F001%2F">ID: T1583.001</a>)</li><li><strong>Initial Access: ID:</strong> Phishing: Spearphishing Link (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1566%2F002%2F">ID: T1566.002</a>)</li><li><strong>Execution: </strong>Command and Scripting Interpreter: PowerShell (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1059%2F001%2F">ID: T1059.001</a>)</li><li><strong>Persistence:</strong> Scheduled Task/Job: Scheduled Task (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1053%2F005%2F">ID: T1053.005</a>)</li><li><strong>Privilege Escalation:</strong> Hijack Execution Flow: Path Interception by Unquoted Path (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1574%2F009%2F">ID: T1574.009</a>)</li><li><strong>Defense Evasion:</strong> Indicator Removal: Clear Windows Event Logs (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1070%2F001%2F">ID: T1070.001</a>)</li><li><strong>Credential Access:</strong> Unsecured Credentials: Credentials In Files (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1552%2F001%2F">ID: T1552.001</a>)</li><li><strong>Discovery:</strong> System Network Connections Discovery (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1049%2F">ID: T1049</a>)</li><li><strong>Lateral Movement:</strong> Remote Services: Remote Desktop Protocol (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1021%2F001%2F">ID: T1021.001</a>)</li><li><strong>Collection:</strong> Data from Network Shared Drive (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1039%2F">ID: T1039</a>)</li><li><strong>Command and Control:</strong> Application Layer Protocol: Web Protocols (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1071%2F001%2F">ID: T1071.001</a>)</li><li><strong>Exfiltration:</strong> Exfiltration Over Web Service: Exfiltration to Cloud Storage (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1567%2F002%2F">ID: T1567.002</a>)</li><li><strong>Impact:</strong> Data Destruction (<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1485%2F">ID: T1485</a>)</li></ul><p>At each stage, we saw examples of how Python could be applied, along with real-life examples of the technique in question, plus security mitigation suggestions.</p><p>Each specific journey through the MITRE ATT&amp;CK framework differs from one attack to another, and depends heavily on the configuration of the system under attack, and the nature of the group that’s doing the attacking. However, groups such as Advanced Persistent Threats (APTs) will tend to demonstrate trends over time, as they deploy the tactics and techniques that they’re familiar with against their victims. As the author of <a href="https://www.halborn.com/blog/post/what-is-an-apt-attack">this article</a> states, “<em>APT attacks are commonly attributed to a particular group based on the combination of the malware used and the techniques used to deploy it</em>”.</p><p>A useful tool for visualising these patterns is the <a href="https://www.google.com/url?q=https%3A%2F%2Fmitre-attack.github.io%2Fattack-navigator%2F">MITRE ATT&amp;CK navigator</a>. This allows the particular techniques to be selected and highlighted. Below is how this looks for our imaginary healthcare hack,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BZfW92aAqljIWjLXYdRiBw.png" /></figure><p>Note that this is showing the top-level techniques, but most of these can be expanded and their sub-techniques also highlighted.</p><p>We can also compare two attacks against each other, for example, to see how much overlap exists between a new attack and that of an existing APT.</p><p>Below is the attack overview of an APT that we’ve mentioned in part 9, Lazarus group,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1J3b2JFNDSnhUMOR-GmW5A.png" /></figure><h3>Conclusion</h3><p>The key takeaways for me, having plotting this imaginary journey through the MITRE ATT&amp;CK framework, are as follows (in no particular order),</p><ul><li><strong>Defence is possible at every step: </strong>There are many points in this attack where it&#39;s easy to think “<em>if only such-and-such control was in place</em>” or “<em>if only that aspect was locked down</em>”. In most cases, defences are very simple, like having robust passwords, allowing access to certain areas of the network to only those who absolutely need it, or blocking non-trusted domains at the firewall. For many organisations, this is where a cyber-security framework can be hugely beneficial. For example, for a smaller organisation without any formal framework in place, the UK’s <a href="https://www.ncsc.gov.uk/cyberessentials/overview">Cyber Essentials</a> program can be an excellent stepping stone, offering a straightforward way to effectively conduct a gap analysis</li><li><strong>The attackers only need to be right once:</strong> Having said the above, we’ve seen that at every step, the attackers have a long list of techniques at their disposal, and they only need one of them to be successful. As mentioned, this depends on the exact details of the systems under attack, and the skills and expertise of the attackers. But even taking this into account, each stage offers more than one route through. Defenders, however, much be vigilant across the board, 100% of the time</li><li><strong>MITRE ATT&amp;CK is extremely useful:</strong> Where would we be in the world of cyberattacks without the landscape of MITRE? Instead of being able to plot the journey of an attack against the backdrop of possibilities, we’d be lost in an overflowing bucket of disconnected techniques. Note that other such frameworks exist, such as Lockheed Martin’s <a href="https://www.lockheedmartin.com/en-us/capabilities/cyber/cyber-kill-chain.html">Cyber Kill Chain</a></li><li><strong>Python is powerful:</strong> We’ve seen numerous examples of how Python can be used to detect and investigate related activity, from Natural Language Processing (NPL) and interacting with the ChatGPT API, to running PowerShell commands and handling the output, to plotting network traffic and performing simple anomaly detection</li><li><strong>These techniques are real: </strong>The techniques we’ve seen are not theoretical exercises, but examples (albeit simple ones) of how actual hackers operate</li><li><strong>Things evolve quickly:</strong> It should also be noted that this blog series used MITRE ATT&amp;CK version 16, with version 1 <a href="https://attack.mitre.org/resources/versions/">having been published in 2018</a>. That gives an indication of the rate of change in the techniques used by cybercriminals, and this is set to accelerate in part due to advances in Artificial Intelligence. In a report by the National Cyber Security Centre (NCSC) titled ‘<a href="https://www.ncsc.gov.uk/report/impact-of-ai-on-cyber-threat">The near-term impact of AI on the cyber threat</a>’, they state that “<em>AI will almost certainly increase the volume and heighten the impact of cyber attacks over the next two years</em>” and that “<em>The threat to 2025 comes from evolution and enhancement of existing tactics, techniques and procedures (TTPs)</em>”. They go on to explain that AI offers advances in reconnaissance, social engineering, the analysis of exfiltrated data, the design of ransomware, and generally lowers the barrier of entry for would-be cybercriminals</li></ul><h3>Closing</h3><p>I hope this series has been interesting and useful. I’m not an expert in these topics, but I’ve learnt a lot whilst exploring the MITRE ATT&amp;CK framework and researching the selected topics. For a more formal approach, and to learn more about the techniques in this series, see the following links for training suggestions (of which there are many),</p><ul><li><a href="https://mad20.io/">MAD20 MITRE ATT&amp;CK training</a></li><li><a href="https://www.codecademy.com/catalog/language/python">Python training</a></li><li><a href="https://www.isc2.org/certifications/cc">General Cyber Security training</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f631bc20499" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/python-mitre-att-ck-part-15-15-8f631bc20499">Python &amp; MITRE ATT&amp;CK: Part 15/15</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python & MITRE ATT&CK: Part 14/15]]></title>
            <link>https://infosecwriteups.com/python-mitre-att-ck-part-14-15-eb6dfdbca34b?source=rss-8b08ce01a167------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb6dfdbca34b</guid>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[mitre-attack]]></category>
            <dc:creator><![CDATA[Rob Harrand]]></dc:creator>
            <pubDate>Thu, 24 Apr 2025 07:37:25 GMT</pubDate>
            <atom:updated>2025-04-25T08:20:27.522Z</atom:updated>
            <content:encoded><![CDATA[<h4>Impact</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a2SS28x1PxbC9_RP" /><figcaption>Photo by <a href="https://unsplash.com/@lazycreekimages?utm_source=medium&amp;utm_medium=referral">Michael Dziedzic</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>(🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-13-15-27c7bf0cacf1"><strong>&lt;- Link to back to Part 13</strong></a><strong> 🔗)</strong></p><h3>Introduction</h3><p>We’ve reached the final stage of the attack, that of <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftactics%2FTA0040%2F">Impact</a> from the MITRE ATT&amp;CK framework. At this point, an attacker may try to stay under the radar, quietly exfiltrating data for many years. Alternatively, they may wish to cause disruption via encryption, deletion, or something more subtle, like data changes within files.</p><p>For our scenario, we’ll assume the attacker wishes to delete the original files. We’ll also assume that there are no obvious indications of a backup process. This may seem far-fetched, but in <a href="https://www.infosecurity-magazine.com/news/british-smes-lost-data-five-years/">an article by Infosecurity Magazine</a>, they report that (according to a survey by <em>Beaming</em>), “<em>48% of the UK’s small and medium-sized enterprises (SMEs) have lost access to data since 2019</em>” and that “<em>…the report also highlighted that poor backup practices are widespread. Around half of respondents were assessed to be relying on flawed backup processes, with a further quarter not backing up corporate data at all</em>”.</p><p>With the originals gone, the hacker with have the only copies. This is then an example of <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1485%2F">Data Destruction</a> from MITRE.</p><p>One way they may do this is to first overwrite the files with junk data, and then delete them, using a command such as the below (assuming that the crucial files are <em>Confidential.docx</em> and <em>results.zip</em>),</p><pre># Overwrite with junk data<br>Set-Content -Path &quot;\\SERVER\Shared\R&amp;D\Clinical\Confidential.docx&quot; -Value (Get-Random -Minimum 0 -Maximum 255) * 100000<br>Set-Content -Path &quot;\\SERVER\Shared\R&amp;D\Clinical\results.zip&quot; -Value (Get-Random -Minimum 0 -Maximum 255) * 500000<br><br># Delete the files<br>Remove-Item &quot;\\SERVER\Shared\R&amp;D\Clinical\Confidential.docx&quot; -Force<br>Remove-Item &quot;\\SERVER\Shared\R&amp;D\Clinical\results.zip&quot; -Force</pre><h3>Python Analysis</h3><p>This would generate the following event entries, similar to what we’ve seen previously, that we could use Python to look for,</p><ul><li>Event ID 4104 (PowerShell Script Block Logging)</li><li>Event ID 4663 (File Delete Attempt)</li><li>Event ID 4660 (File Deleted)</li></ul><p>For example,</p><pre>Log Name: Security<br>Source: Microsoft-Windows-Security-Auditing<br>Event ID: 4660<br>Level: Information<br>User: attacker_account<br>Description:<br>An object was deleted.<br>Object Name: \\SERVER\Shared\R&amp;D\Clinical\Confidential.docx<br>Handle ID: 0x00000000000f</pre><p>Another use of Python to mention is that MITRE ATT&amp;CK have their own Python package available, called <a href="https://github.com/mitre-attack/mitreattack-python">mitreattack-python</a>. This allows MITRE ATT&amp;CK content to be accessed easily from within Python, for use in CTI analysis. Below is a small amount of code to demonstrate its use (specifically, loading the module, loading the enterprise json file that can be downloaded from the library’s website, and then displaying a specific attack’s details),</p><pre>from mitreattack.stix20 import MitreAttackData<br><br>#Load the json file<br>mitre_attack_data = MitreAttackData(&quot;enterprise-attack.json&quot;) <br><br>#Get the details for T1485 (Data Destruction),<br>technique = mitre_attack_data.get_object_by_attack_id(&#39;T1485&#39;, &#39;attack-pattern&#39;) <br><br>print(f&quot;Name: {technique.name}&quot;)<br>print(f&quot;Description: {technique.description}&quot;)<br><br>#Plot some of the details,<br>for ref in technique.external_references:<br>    print(f&quot;MITRE ID: {ref.get(&#39;external_id&#39;)}&quot;)<br>    print(f&quot;Reference: {ref.get(&#39;url&#39;)}&quot;)</pre><p>Output,</p><pre>Name: Data Destruction<br>Description: Adversaries may destroy data and files on specific systems or in large numbers on a network to interrupt availability to systems, services, and network resources. Data destruction is likely to render stored data irrecoverable by forensic techniques through overwriting files or data on local and remote drives.(Citation: Symantec Shamoon 2012)(Citation: FireEye Shamoon Nov 2016)(Citation: Palo Alto Shamoon Nov 2016)(Citation: Kaspersky StoneDrill 2017)(Citation: Unit 42 Shamoon3 2018)(Citation: Talos Olympic Destroyer 2018) Common operating system file deletion commands such as &lt;code&gt;del&lt;/code&gt; and &lt;code&gt;rm&lt;/code&gt; often only remove pointers to files without wiping the contents of the files themselves, making the files recoverable by proper forensic methodology. This behavior is distinct from [Disk Content Wipe](https://attack.mitre.org/techniques/T1561/001) and [Disk Structure Wipe](https://attack.mitre.org/techniques/T1561/002) because individual files are destroyed rather than sections of a storage disk or the disk&#39;s logical structure.<br><br>Adversaries may attempt to overwrite files and directories with randomly generated data to make it irrecoverable.(Citation: Kaspersky StoneDrill 2017)(Citation: Unit 42 Shamoon3 2018) In some cases politically oriented image files have been used to overwrite data.(Citation: FireEye Shamoon Nov 2016)(Citation: Palo Alto Shamoon Nov 2016)(Citation: Kaspersky StoneDrill 2017)<br><br>To maximize impact on the target organization in operations where network-wide availability interruption is the goal, malware designed for destroying data may have worm-like features to propagate across a network by leveraging additional techniques like [Valid Accounts](https://attack.mitre.org/techniques/T1078), [OS Credential Dumping](https://attack.mitre.org/techniques/T1003), and [SMB/Windows Admin Shares](https://attack.mitre.org/techniques/T1021/002).(Citation: Symantec Shamoon 2012)(Citation: FireEye Shamoon Nov 2016)(Citation: Palo Alto Shamoon Nov 2016)(Citation: Kaspersky StoneDrill 2017)(Citation: Talos Olympic Destroyer 2018).<br><br>In cloud environments, adversaries may leverage access to delete cloud storage objects, machine images, database instances, and other infrastructure crucial to operations to damage an organization or their customers.(Citation: Data Destruction - Threat Post)(Citation: DOJ  - Cisco Insider)<br>MITRE ID: T1485<br>Reference: https://attack.mitre.org/techniques/T1485<br>MITRE ID: None<br>Reference: https://www.justice.gov/usao-ndca/pr/san-jose-man-pleads-guilty-damaging-cisco-s-network<br>MITRE ID: None<br>Reference: https://unit42.paloaltonetworks.com/shamoon-3-targets-oil-gas-organization/<br>MITRE ID: None<br>Reference: http://researchcenter.paloaltonetworks.com/2016/11/unit42-shamoon-2-return-disttrack-wiper/<br>MITRE ID: None<br>Reference: https://www.fireeye.com/blog/threat-research/2016/11/fireeye_respondsto.html<br>MITRE ID: None<br>Reference: https://media.kasperskycontenthub.com/wp-content/uploads/sites/43/2018/03/07180722/Report_Shamoon_StoneDrill_final.pdf<br>MITRE ID: None<br>Reference: https://blog.talosintelligence.com/2018/02/olympic-destroyer.html<br>MITRE ID: None<br>Reference: https://threatpost.com/hacker-puts-hosting-service-code-spaces-out-of-business/106761/<br>MITRE ID: None<br>Reference: https://www.symantec.com/connect/blogs/shamoon-attacks</pre><h3>Real-world Example</h3><p><a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Fgroups%2FG0034%2F">Sandworm</a>, the widely-known group responsible for attacks on Ukraine’s power grid, the 2017 French presidential election, and the 2018 Winter Olympics, regularly use data destruction in their campaigns. MITRE describes them as follows: “<em>Sandworm Team is a destructive threat group that has been attributed to Russia’s General Staff Main Intelligence Directorate (GRU) Main Center for Special Technologies (GTsST) military unit 74455. This group has been active since at least 2009.</em>”</p><p>In <a href="https://www.google.com/url?q=https%3A%2F%2Fcloud.google.com%2Fblog%2Ftopics%2Fthreat-intelligence%2Fsandworm-disrupts-power-ukraine-operational-technology%2F">a report by Mandiant</a>, Sandworm were seen to use specialist data destruction malware called <a href="https://www.google.com/url?q=https%3A%2F%2Fmalpedia.caad.fkie.fraunhofer.de%2Fdetails%2Fwin.caddywiper">CaddyWiper</a>. This malware, amongst other things, overwrites data with NULL values, in a similar way to the code above.</p><h3>Security Measures</h3><p>Data backups are a critical aspect of preventing both accidental and malicious data destruction. Backups should be performed on a regular basis and stored off-site, for example in a secure cloud-system or air-gapped facility.</p><p>The number of guides on this subject is large, but for further details, here is one by <em>ConnectWise </em>titled <a href="https://www.connectwise.com/blog/business-continuity/backup-strategy-best-practices">Best Practices and Strategy for Data Backups</a>.</p><h3>What’s Next?</h3><p>The attackers have now completed their mission. Let’s summarise this journey and wrap things up in the final part of this series.</p><p><strong>🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-15-15-8f631bc20499"><strong>Link to Part 15 -&gt;</strong></a><strong> 🔗</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb6dfdbca34b" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/python-mitre-att-ck-part-14-15-eb6dfdbca34b">Python &amp; MITRE ATT&amp;CK: Part 14/15</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python & MITRE ATT&CK: Part 13/15]]></title>
            <link>https://infosecwriteups.com/python-mitre-att-ck-part-13-15-27c7bf0cacf1?source=rss-8b08ce01a167------2</link>
            <guid isPermaLink="false">https://medium.com/p/27c7bf0cacf1</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[mitre-attack]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Rob Harrand]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 19:23:01 GMT</pubDate>
            <atom:updated>2025-04-24T07:37:50.593Z</atom:updated>
            <content:encoded><![CDATA[<h4>Exfiltration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ui6pfo6Euc0GrZSR" /><figcaption>Photo by <a href="https://unsplash.com/@thsateles?utm_source=medium&amp;utm_medium=referral">Thiago Teles</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>(🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-12-15-84d3a2b25da1"><strong>&lt;- Link to back to Part 12</strong></a><strong> 🔗)</strong></p><h3>Introduction</h3><p>We now come to the part where the attackers reach their primary objective and transmit the data of interest to Dropbox. This is <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1567%2F002%2F">Exfiltration Over Web Service: Exfiltration to Cloud Storage</a> from MITRE.</p><p>Data exfiltration is often the ultimate goal of hackers, along with encryption via ransomware. Both methods can be crippling to an organisation, leading to financial loss and reputational damage. However, data exfiltration may lead to more subtle consequences. Demands from criminals in the wake of data encryption reveals the underlying intrusion, where-as data exfiltration may be done silently, with the perpetrators simply using the data for clandestine means, such as selling IP to a rival organisation.</p><p>A <a href="https://www.allianz.co.uk/news-and-insight/insight-and-expertise/allianz-risk-barometer-2023.html">report by Allianz</a> from 2023 describes the results a of survey of businesses covering 2,700 experts in 94 countries and territories. In it they cited cyberthreats as the number one concern, with data exfiltration and ransomware at the top of the list of risks.</p><p>In<a href="https://thehackernews.com/2022/08/the-rise-of-data-exfiltration-and-why.html"> an article by Hacker News</a> in 2022, the author argues that due to the devaluation of crypto-currencies, data exfiltration rates are on the rise, and that by staying under the radar (possibly for months, if not years), they explain that <em>“Competitors can use trade secrets to produce copies of products or aid in their R&amp;D efforts or information that could lead to a costly public relations disaster”.</em></p><h3>Python Analysis</h3><p>We can repeat the analysis performed in part 12 for the network logs, and compare the command and control activity to what data exfiltration might look like. Again, we’ll load example data from a CSV file and create a simple plot,</p><pre>import pandas as pd<br><br>traffic = pd.read_csv(&#39;simulated_data_exfiltration.csv&#39;)<br>traffic[&#39;Time&#39;] = pd.to_datetime(traffic[&#39;Time&#39;]) #Convert the Time column to datetime<br>traffic.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*7DzowNxInk2lRbIGMfOnGQ.png" /></figure><pre>#Plot of Info vs Time,<br>traffic.plot(kind=&#39;scatter&#39;, x=&#39;Time&#39;, y=&#39;Info&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*X0-hgn2jh21YRsQe5Ht-Jg.png" /></figure><p>We now see a concentrated amount of Dropbox activity along with typical network traffic, but there’s also some activity on its own (the isolated points on the right), suggesting that some of the data exfiltration has occurred out of hours, such as over a weekend. This is a good indication of suspicious behaviour. Next, let’s check the length column, as before,</p><pre>import pandas as pd<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br><br># Create scatter plot<br>plt.figure(figsize=(8, 6))<br>sns.scatterplot(data=traffic, x=&#39;Time&#39;, y=&#39;Length&#39;, hue=&#39;Info&#39;, palette=&#39;Set1&#39;, s=100)<br><br># Labels and title<br>plt.xlabel(&quot;X Axis&quot;)<br>plt.ylabel(&quot;Y Axis&quot;)<br>plt.title(&quot;Scatter Plot Colored by Category&quot;)<br>plt.legend(title=&quot;Category&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*2rvP91id0SNTOPSPLNg9nA.png" /></figure><p>So much for ‘staying under the radar’. This looks like our hacker has seen enough to know that security is so lax at this company that even brazen activity such as this will go undetected. Of course a more cautious attacker could make efforts to hide the size and timing of the exfiltration.</p><p>Let’s see what a more subtle data exfiltration might look like,</p><pre>traffic.loc[traffic[&#39;Info&#39;] == &#39;Dropbox API&#39;, &#39;Length&#39;] = np.random.randint(1800, 2200, size=len(traffic[traffic[&#39;Info&#39;] == &#39;Dropbox API&#39;]))</pre><p>In the above code, all the entries for ‘Dropbox API’ have had their lengths changed to a random number between 1800 and 2200. We’ll see how this could be detected in the section below.</p><h3><strong>Anomaly Detection</strong></h3><p>Let’s do something a little different, and see if we can highlight the suspicious behaviour via code, and not just by eye.</p><p>We can now work out the <a href="https://www.google.com/url?q=https%3A%2F%2Fwww.statisticshowto.com%2Fprobability-and-statistics%2Fz-score%2F">Z-score</a> for each data point, which is a measure of a point’s number of standard deviations from the mean. We can set a threshold for this, and classify anything above this threshold as being an outlier. We’ll use threshold of 2, which should cover 95% of the ‘normal’ data points,</p><pre>zscore_threshold = 2<br><br># Calculate mean and standard deviation for selected features<br>mean = traffic[&#39;Length&#39;].mean()<br>std = traffic[&#39;Length&#39;].std()<br><br># Calculate Z-scores for selected features<br>traffic[&#39;Z_score&#39;] = ((traffic[&#39;Length&#39;] - mean) / std)<br>traffic[&#39;Outlier&#39;] = (np.abs(traffic[&#39;Z_score&#39;]) &gt; zscore_threshold)<br><br>#Rearrange the Z-score equation to get a threshold data Length,<br>threshold_length = (zscore_threshold * std) + mean<br><br># Create scatter plot<br>plt.figure(figsize=(8, 6))<br>custom_palette = [&#39;cornflowerblue&#39;, &#39;red&#39;]<br>sns.set_palette(custom_palette)<br>sns.scatterplot(data=traffic, x=&#39;Time&#39;, y=&#39;Length&#39;, hue=&#39;Outlier&#39;, s=100)<br><br># Labels and title<br>plt.axhline(y=threshold_length, color=&#39;orange&#39;, linestyle=&#39;--&#39;)<br>plt.xlabel(&quot;X Axis&quot;)<br>plt.ylabel(&quot;Y Axis&quot;)<br>plt.title(&quot;Scatter Plot Colored by Category&quot;)<br>plt.legend(title=&quot;Outlier&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*4b-fabJB53E5_c-cCM5Mvw.png" /></figure><p>We can now see the more subtle exfiltration data (the points randomly distributed between 1800 and 2200), which the Z-score approach has managed to detect. These have been highlighted, and the threshold length indicated with the dashed orange line.</p><p>Other anomaly detection methods include <a href="https://www.google.com/url?q=https%3A%2F%2Fwww.geeksforgeeks.org%2Finterquartile-range-to-detect-outliers-in-data%2F">Interquartile range (IQR)</a> and <a href="https://www.google.com/url?q=https%3A%2F%2Fwww.geeksforgeeks.org%2Fanomaly-detection-using-isolation-forest%2F">Isolation Forests</a>.</p><h3>Real-world Example</h3><p>As mentioned in part 12, a group called <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Fgroups%2FG0010%2F">Turla</a> has used software called ‘<a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Fsoftware%2FS0538%2F">Crutch</a>’ to deploy Dropbox in its campaigns. From MITRE: “<em>Turla is a cyber espionage threat group that has been attributed to Russia’s Federal Security Service (FSB). They have compromised victims in over 50 countries since at least 2004, spanning a range of industries including government, embassies, military, education, research and pharmaceutical companies.</em>”.</p><p>In <a href="https://www.google.com/url?q=https%3A%2F%2Fwww.bleepingcomputer.com%2Fnews%2Fsecurity%2Frussian-hacking-group-uses-dropbox-to-store-malware-stolen-data%2F">a report by Bleeping Computer</a> on Turla’s activity, the use of Dropbox as a storage repository for stolen files is detailed.</p><p>Another example comes from an Iranian group called ‘MalKamak’. In <a href="https://www.cybereason.com/blog/research/operation-ghostshell-novel-rat-targets-global-aerospace-and-telecoms-firms">a report by CyberReason</a>, they comment that “<em>The traditional C2 communications were replaced with a Dropbox built-in client, abusing the popular online platform to send commands to ShellClient as well as storing the stolen data exfiltrated to a designated Dropbox account</em>”. MalKamak have been seen to target companies in the aerospace and telecoms sectors.</p><h3>Security Measures</h3><p>As with the mitigation for ‘command and control’, network monitoring is crucial here. The restriction of web-based content is also a key mitigation approach, where certain services can be either blacklisted (known to be malicious or potentially risky) or whitelisted (absolutely necessary and believed to be safe).</p><p>In general, allowing staff to use services such as Dropbox can easily lead to data leaks, and is discouraged.</p><h3>What’s Next?</h3><p>At this point, our attackers may sit quietly and maintain their presence over an extended period. However, they may also perform actions from the final stage of the MITRE ATT&amp;CK framework, which we’ll see next.</p><p><strong>🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-14-15-eb6dfdbca34b"><strong>Link to Part 14 -&gt;</strong></a><strong> 🔗</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27c7bf0cacf1" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/python-mitre-att-ck-part-13-15-27c7bf0cacf1">Python &amp; MITRE ATT&amp;CK: Part 13/15</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python & MITRE ATT&CK: Part 12/15]]></title>
            <link>https://infosecwriteups.com/python-mitre-att-ck-part-12-15-84d3a2b25da1?source=rss-8b08ce01a167------2</link>
            <guid isPermaLink="false">https://medium.com/p/84d3a2b25da1</guid>
            <category><![CDATA[mitre-attack]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Rob Harrand]]></dc:creator>
            <pubDate>Tue, 22 Apr 2025 09:25:32 GMT</pubDate>
            <atom:updated>2025-04-23T19:23:37.648Z</atom:updated>
            <content:encoded><![CDATA[<h4>Command &amp; Control</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4XIMhcciPhhMsRkH" /><figcaption>Photo by <a href="https://unsplash.com/@wbayreuther?utm_source=medium&amp;utm_medium=referral">William Bayreuther</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>(🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-11-15-7b8b8beead2f"><strong>&lt;- Link to back to Part 11</strong></a><strong> 🔗)</strong></p><h3>Introduction</h3><p>Sophisticated hackers tend not to quickly steal data and then flee the scene. Instead, they will remain hidden on a compromised environment for months, if not years. In doing so, they can keep a watchful eye over the environment, extracting any new data that becomes available, and at a pace that should avoid suspicion. It also offers the opportunity to spread additional malware, and to infiltrate deeper into parts of the network. This all reinforces the concept of persistence, which we saw back in part 5.</p><p>In order to achieve this, a <a href="https://fidelissecurity.com/cybersecurity-101/learn/command-and-control-attacks/#:~:text=Command%20and%20control%20(C2)%20attack,reputational%20damage%2C%20and%20regulatory%20penalties.">Command and Control</a>, or ‘C2’ server is used, which establishes periodic communication with a compromised device. See the <a href="https://attack.mitre.org/tactics/TA0011/">MITRE ATT&amp;CK section</a> on this for more detail.</p><p>This server could be one that they have created, or it might be based upon a legitimate service such as a cloud-storage platform. Let’s assume that our attacker spotted that the company in question allows its staff to use Dropbox. Perhaps they spotted that it’s an existing running service in one of their many scans, or maybe they read a policy that they found that states that staff can use it. It may even have been mentioned by the insider that they have access to, mentioned in the dark web conversation from part 1. They decide to therefore employ Dropbox for their C2 activities, as this approach would offer the attackers a way to hide their activities amongst legitimate behaviour.</p><p>This would be an example of <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1071%2F001%2F">Application Layer Protocol: Web Protocols</a>.</p><h3>Python Analysis</h3><p>Let’s have a look at a mock network log that shows activity on the company’s firewall. For this, I’m loading a CSV file containing the mock data,</p><pre>import pandas as pd #load pandas<br><br>traffic = pd.read_csv(&#39;simulated_network_traffic.csv&#39;) #load the file<br>traffic[&#39;Time&#39;] = pd.to_datetime(traffic[&#39;Time&#39;]) #Convert the Time column to datetime<br>traffic.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*gOGm146SnwibuhiBXrwSaA.png" /></figure><p>We can see various fields that show the traffic on the network. Let’s do a quick plot showing the ‘Time’ column vs the ‘Info’ column,</p><pre>#Plot of Info vs Time,<br>traffic.plot(kind=&#39;scatter&#39;, x=&#39;Time&#39;, y=&#39;Info&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*OLZeKRhDAFaqb9ckjp0_3w.png" /></figure><p>In this simplistic example, we have three types from the ‘Info’ column: <a href="https://www.avast.com/c-tcp-vs-udp-difference#:~:text=FAQ-,TCP%20vs%20UDP%3A%20Differences%20between%20the%20protocols,reliable%20but%20works%20more%20quickly.">UDP, TCP</a>, and Dropbox API. UDP and TCP are data protocols commonly used, with UDP being faster, and TCP offering better security and integrity.</p><p>What’s interesting here is that the ‘Dropbox API’ rows appear to be very regular in time. Let’s next plot ‘Time’ vs ‘Length’ (the size of the data being transmitted). We’ll also colour-code the points by the ‘Info’ column,</p><pre>import pandas as pd<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br><br># Create scatter plot<br>plt.figure(figsize=(8, 6))<br>sns.scatterplot(data=traffic, x=&#39;Time&#39;, y=&#39;Length&#39;, hue=&#39;Info&#39;, palette=&#39;Set1&#39;, s=100)<br><br># Labels and title<br>plt.xlabel(&quot;Time&quot;)<br>plt.ylabel(&quot;Length&quot;)<br>plt.title(&quot;Scatter Plot Colored by Category&quot;)<br>plt.legend(title=&quot;Category&quot;, loc=&quot;upper right&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*yqPxqKNtc6tnnz2a8QCtPA.png" /></figure><p>We can now see that the ‘Dropbox API’ has a constant length, too.</p><p>Realistically, a sophisticated hacker may introduce random jitter on the timing and/or size, to disguise such behaviour. However, such activity may still stand out with such plots.</p><h3><strong>PCAP Files</strong></h3><p>It should be noted that data like the above is more likely to come in the form of a packet capture, or <a href="https://www.solarwinds.com/resources/it-glossary/pcap">PCAP file</a>, rather than CSV, compiled using software such as <a href="https://www.wireshark.org/">Wireshark</a>. In that case, you would use a dedicated Python library such as <a href="https://github.com/KimiNewt/pyshark/">pyshark </a>or <a href="https://scapy.net/">scapy</a>. For reference, here is some example code to load a PCAP file into a Pandas data-frame using scapy,</p><pre>from scapy.all import rdpcap<br>import pandas as pd<br><br># Load PCAP file<br>packets = rdpcap(&quot;simulated_network_traffic.pcap&quot;)<br># Extract packet details<br>data = []<br>for packet in packets:<br>    if packet.haslayer(&quot;IP&quot;):  # Filter only IP packets<br>        data.append({<br>            &quot;timestamp&quot;: packet.time,<br>            &quot;src_ip&quot;: packet[&quot;IP&quot;].src,<br>            &quot;dst_ip&quot;: packet[&quot;IP&quot;].dst,<br>            &quot;protocol&quot;: packet[&quot;IP&quot;].proto<br>        })<br># Convert to DataFrame<br>df = pd.DataFrame(data)</pre><h3>Real-world Example</h3><p>A relatively new group that targets Russian government agencies, dubbed ‘CloudSorcerer’ by <em>Kaspersky</em>, is thought to use Dropbox for C2 operations.</p><p>In <a href="https://www.google.com/url?q=https%3A%2F%2Fsecurelist.com%2Fcloudsorcerer-new-apt-cloud-actor%2F113056%2F">a report by Kaspersky</a>, they state that “<em>Its use of cloud services such as Microsoft Graph, Yandex Cloud, and Dropbox for C2 infrastructure, along with GitHub for initial C2 communications, demonstrates a well-planned approach to cyberespionage.</em>”</p><p>In another example, there is a piece of malware called ‘Crutch’ that is described as “<em>a backdoor and document stealer</em>”, attributed to the cyberespionage APT ‘<a href="https://attack.mitre.org/groups/G0010/">Turla</a>’. In <a href="https://www.welivesecurity.com/2020/12/02/turla-crutch-keeping-back-door-open/">a report on the group’s activity</a>, it states that “<em>Turla used the Crutch toolset against several machines of the Ministry of Foreign Affairs in a country of the European Union. These tools were designed to exfiltrate sensitive documents and other files to Dropbox accounts Turla operators controlled</em>”.</p><h3>Security Measures</h3><p>The key here, like in so many stages of an attack, is network traffic monitoring. This could be a straightforward Python script that analyses PCAP files, or something more sophisticated such as using a <a href="https://www.google.com/url?q=https%3A%2F%2Fwww.redhat.com%2Fen%2Ftopics%2Fsecurity%2Fwhat-is-an-IDPS">network intrusion detection and prevention system (IDPS)</a>. Such systems are designed to analyse network traffic and check for network <a href="https://www.google.com/url?q=https%3A%2F%2Fcorelight.com%2Fresources%2Fglossary%2Fsignature-based-detection">signatures</a>.</p><p>As stated above, our imaginary company allows its staff to use Dropbox, which not only offers a method for our attacker to blend in with legitimate traffic, but also highly increases the risk of data leaks by employees, accidental or intended. Far safer would be to ban such systems in the company’s IT policy, block all access at the firewall, and instead use a system such as Microsoft’s <a href="https://www.microsoft.com/en-gb/microsoft-365/onedrive/online-cloud-storage">Onedrive</a>, which can be monitored and controlled easily by the security team.</p><h3>What’s Next?</h3><p>With the command and control system in place, the attackers can finally exfiltrate the data, which from the dark web discussion in part 1 is their primary goal.</p><p><strong>🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-13-15-27c7bf0cacf1"><strong>Link to Part 13 -&gt;</strong></a><strong> 🔗</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84d3a2b25da1" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/python-mitre-att-ck-part-12-15-84d3a2b25da1">Python &amp; MITRE ATT&amp;CK: Part 12/15</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python & MITRE ATT&CK: Part 11/15]]></title>
            <link>https://infosecwriteups.com/python-mitre-att-ck-part-11-15-7b8b8beead2f?source=rss-8b08ce01a167------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b8b8beead2f</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[mitre-attack]]></category>
            <dc:creator><![CDATA[Rob Harrand]]></dc:creator>
            <pubDate>Mon, 21 Apr 2025 10:00:56 GMT</pubDate>
            <atom:updated>2025-04-22T09:26:19.205Z</atom:updated>
            <content:encoded><![CDATA[<h4>Collection</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9uFYRLjxJfknDxEU" /><figcaption>Photo by <a href="https://unsplash.com/@priscilladupreez?utm_source=medium&amp;utm_medium=referral">Priscilla Du Preez 🇨🇦</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>(🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-10-15-cf3d1029fc8f"><strong>&lt;- Link to back to Part 10</strong></a><strong> 🔗)</strong></p><h3>Introduction</h3><p>Our attackers are now on the ‘R&amp;D’ system, remoting in from their newly established admin account thanks to various factors, including a plaintext password. On this new system, they find numerous shared drives and thousands of files. The majority look to be of little interest, including large files of raw data from scientific instrumentation. What’s of more interest, however, is a folder called ‘Clinical’, where sensitive IP appears to reside.</p><p>This is the <a href="https://attack.mitre.org/tactics/TA0009/">Collection</a> stage of the MITRE ATT&amp;CK framework, and is where a hacker collects information on the target material. The number of data repositories on modern computer systems is huge, but common techniques could include <a href="https://attack.mitre.org/techniques/T1114/">Email Collection</a> or data from <a href="https://attack.mitre.org/techniques/T1213/002/">SharePoint</a>. More elaborate approaches may include <a href="https://attack.mitre.org/techniques/T1123/">Audio</a> or <a href="https://attack.mitre.org/techniques/T1125/">Video Capture</a> (hijacking device peripherals), or even techniques such as <a href="https://attack.mitre.org/techniques/T1557/004/">Evil Twin</a>, where Wi-Fi points are established that appear to be legitimate, but are actually being used to collect information. This latter technique is a significant risk in public places, here a hacker may create a Wi-Fi point called, for example, ‘Costa_free’ near a Costa Coffee branch, when the legitimate point is actually called ‘Costa_WiFi’. This could easily trick unsuspecting customers.</p><p>In our scenario, we have an example of <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1039%2F">Data from Network Shared Drive</a>.</p><h3>Python Analysis</h3><p>When browsing a network share like in this example, the <a href="https://www.digitalguardian.com/blog/what-server-message-block-protocol">Server Message Block (SMB)</a> network protocol will generate Event ID 5145 in Windows security logs. This shows that a network share object (file or folder) was checked to see if a client can be granted desired access, i.e. a file was accessed on a network share.</p><p>As before, we could use Python to look for Event IDs of 5145. This could return too many results, so limiting this to specific files may be a better approach (such as those that are particularly sensitive).</p><p>Note that as before, certain types of logging must be active. In this case, we need ‘Audit Object Access’ to be active for this to work. To check to see if this is configured, run the following at the command line,</p><pre>auditpol /get /category:&quot;Object Access&quot;</pre><p>‘File System’ and ‘Removable Storage’ need to be active. If they aren’t, go to <em>Group Policy Editor -&gt; Windows Settings -&gt; Security Settings -&gt; Advanced Audit Policy Configuration &gt; System Audit Policies &gt; Object Access</em>. Double-click ‘<em>Audit File Share</em>’ and select auditing for ‘Success and Failure’.</p><p>Then update with,</p><pre>gpupdate /force</pre><p>Now we can run the Python code,</p><pre>import subprocess<br><br>powershell_command = r&quot;&quot;&quot;<br>Get-WinEvent -LogName Security | Where-Object <br>{ $_.Id -eq 5145 -and $_.Message -match &quot;C:\\R&amp;D\Clinical\Confidential.docx&quot; }<br> | Select-Object TimeCreated, Id, Message<br>&quot;&quot;&quot;<br><br>result = subprocess.run(<br>    [&quot;powershell&quot;, &quot;-Command&quot;, powershell_command],<br>    capture_output=True,<br>    text=True<br>)<br><br>if result.stdout:<br>  print(&quot;Sensitive file accessed:&quot;)<br>  print(result.stdout)<br>else:<br>  print(&quot;No instances of sensitive file access detected.&quot;)</pre><p>When logging is active, the output will be something like as follows,</p><pre>Sensitive file accessed:<br><br>TimeCreated         Id   Message<br>------------        ---  -------<br>2/4/2025 10:15:23  5145 A network share object was accessed.<br><br>Subject:<br>    Security ID: S-1-5-21-123456789-123456789-123456789-1001<br>    Account Name: new_bd<br>    Account Domain: fh3000<br>    Logon ID: 0x3E7<br><br>Network Information:<br>    Object Type: File<br>    Source Address: 192.168.1.10<br>    Source Port: 51023<br><br>Share Information:<br>    Share Name: \\SERVER\Shared<br>    Share Path: C:\Shared<br>    Relative Target Name: R&amp;D\Clinical\Confidential.docx</pre><h3>Real-world Example</h3><p><a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Fgroups%2FG0007%2F">APT28</a> have been shown to obtain data from network shares. From MITRE: “<em>APT28 is a threat group that has been attributed to Russia’s General Staff Main Intelligence Directorate (GRU) 85th Main Special Service Center (GTsSS) military unit 26165. This group has been active since at least 2004</em>”.</p><p>In a report <a href="https://www.google.com/url?q=https%3A%2F%2Fmedia.defense.gov%2F2021%2FJul%2F01%2F2002753896%2F-1%2F-1%2F1%2FCSA_GRU_GLOBAL_BRUTE_FORCE_CAMPAIGN_UOO158036-21.PDF">by multiple security agencies</a>, ‘Data from Network Shared Drive’ is cited as an approach used by the group in their attacks. In <a href="https://odessa-journal.com/from-expanding-the-list-of-targets-to-changing-tactics-how-the-hacker-group-apt28-linked-to-the-gru-operates">a more recent report</a> on the group, it is described that “<em>…the group shifted from traditional espionage to a hybrid model, including active cyber warfare, to achieve political influence and undermine international cooperation</em>”. This seems to have started around the same time as the beginning of the Russian invasion of Ukraine, with 37% of their attacks targeting the country.</p><p>Another example is the Chimera group, described by MITRE as “<em>a suspected China-based threat group that has been active since at least 2018 targeting the semiconductor industry in Taiwan as well as data from the airline industry</em>”. In <a href="https://web.archive.org/web/20230218064220/https://research.nccgroup.com/2021/01/12/abusing-cloud-services-to-fly-under-the-radar/">one report</a> on the group, it is reported that they initially searched for things like remote desktop services, domain controllers, and network shares. Their targets are varied, including those from the semiconductor industry and the airline industry, and are said to have a dwell time of up to three years.</p><h3>Security Measures</h3><p>As we’ve seen in this post, the monitoring of logs is a key tool in detecting suspicious behaviour on a network. None of the log entries found may amount to being clear red-flags, but suspicions can be then followed-up and investigated. Actions such as innocent commands being run or files being accessed can be highlighted further by accompanying information, such as who and when. In this scenario, we saw ‘new_bd’ accessing the ‘Confidential.docx’ file, which they were permitted to do. However, is this expected? Should they be opening this file, really? And what if they accessed it every day, or downloaded it, or editted it, or accessed it at 2am on a Saturday morning? Rules to flag any of this could be established (in Python code or a third-party product).</p><p>Beyond log monitoring, the control of permissions is on obvious one. Perhaps only a much smaller group should be allowed to access this file, or maybe the file shouldn’t even be on the general network (for clinical trial data, if that’s what this contains, there are dedicated, secure cloud-systems for such files, called <a href="https://www.simpletrials.com/what-is-an-etmf#:~:text=The%20electronic%20Trial%20Master%20File,of%20essential%20clinical%20study%20documents.">electronic Trial Master File (eTMF)</a> systems).</p><p>Finally, one interesting approach could be to create a <a href="https://www.kaspersky.com/resource-center/threats/what-is-a-honeypot">Honeypot</a>, which is a controlled environment used to lure and trick hackers. This could be a network share such as <em>\\Server\Clinical_master_data\</em>, that contains dummy files. These files could in turn contain tracking beacons such as a <a href="https://canarytokens.org/nest/">CanaryTokens</a>, which are files that act as ‘digital tripwires’. If such a file gets opened, an alert would be immediately triggered.</p><h3>What’s Next?</h3><p>Now that collection is complete, the attackers are nearing the end-game of acquiring the data that they’re found. But before transmitting the files, they’re likely to establish something called a Command and Control capability, which we’ll see next.</p><p><strong>🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-12-15-84d3a2b25da1"><strong>Link to Part 12 -&gt;</strong></a><strong> 🔗</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b8b8beead2f" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/python-mitre-att-ck-part-11-15-7b8b8beead2f">Python &amp; MITRE ATT&amp;CK: Part 11/15</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python & MITRE ATT&CK: Part 10/15]]></title>
            <link>https://infosecwriteups.com/python-mitre-att-ck-part-10-15-cf3d1029fc8f?source=rss-8b08ce01a167------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf3d1029fc8f</guid>
            <category><![CDATA[dats-science]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[mitre-attack]]></category>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Rob Harrand]]></dc:creator>
            <pubDate>Sun, 20 Apr 2025 08:51:39 GMT</pubDate>
            <atom:updated>2025-04-21T10:01:21.618Z</atom:updated>
            <content:encoded><![CDATA[<h4>Lateral Movement</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5_kfrgEN1QXBUFYh" /><figcaption>Photo by <a href="https://unsplash.com/@b_randy?utm_source=medium&amp;utm_medium=referral">Randy</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>(🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-9-15-666c1401fae9"><strong>&lt;- Link to back to Part 9</strong></a><strong> 🔗)</strong></p><h3>Introduction</h3><p>When gaining unauthorised access to a system, there are no doubt situations where everything that the attacker desires is immediately at their fingertips. This may be especially true for smaller companies that have very flat networks without segmentation, or for companies with a general lack of controls over permissions or data management. For example, if the entirety of a company’s data is stored on a single file-server that any member of staff can access, then life becomes extremely easy for a hacker.</p><p>However, if this is not the case (which it really shouldn’t be for any modern organisation), then they’ll need to explore and move around the network. This is the <a href="https://attack.mitre.org/tactics/TA0008/">Lateral Movement</a> stage of the MITRE ATT&amp;CK framework.</p><p>As with every stage in the attack, there are numerous options open to the attacker, and which ones are selected will depend on their skills and the details of the system. For example, the hackers may use the fact that they have access to a legitimate account to send a phishing email <em>internally</em>, which would appear to be genuine given that it’s from a legitimate account. This would be a case of <a href="https://attack.mitre.org/techniques/T1534/">Internal Spearphishing</a> from the Lateral Movement stage.</p><p>In our scenario, let’s assume that the attacker uses Window’s <a href="https://www.google.com/url?q=https%3A%2F%2Fwww.techtarget.com%2Fsearchenterprisedesktop%2Fdefinition%2FRemote-Desktop-Protocol-RDP%23%3A%7E%3Atext%3DRemote%2520desktop%2520protocol%2520%28RDP%29%2520is%2Ctheir%2520physical%2520work%2520desktop%2520computers.">Remote Desktop Protocol (RDP)</a>, along with the discovered IP address and found credentials, to access another system on the network. This is an example of <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1021%2F001%2F">Remote Services: Remote Desktop Protocol</a> from MITRE ATT&amp;CK.</p><p>Our attacker loads RDP from the command line (by running ‘mstsc’), adds the IP address from the password file and network scans, and tries the password labelled as ‘newer’). This fails, but they succeed when trying the password labelled as ‘new’. We can imagine that this newer one was never implemented, possibly because it was too difficult to remember.</p><h3>Python Analysis</h3><p>Once again, log-monitoring is an extremely useful tool here. The failed attempt, followed by the successful attempt, would generate entries into the security logs on the remote machine. Namely,</p><ul><li>Event ID 4625: Failed Logon</li><li>Event ID 4624: Successful Logon</li></ul><p>For example, an entry for 4625 (failure) would look like the following,</p><pre>og Name:      Security<br>Source:        Microsoft-Windows-Security-Auditing<br>Event ID:      4625<br>Level:         Audit Failure<br>Keywords:      Audit Failure<br>User:          N/A<br>Computer:      BOBS-PC<br>Logon Type:    10 (Remote Desktop)<br><br>Account For Which Logon Failed:<br>    Security ID:        NULL SID<br>    Account Name:       new_bd<br>    Account Domain:     BOBS-PC<br><br>Failure Information:<br>    Failure Reason:     Unknown user name or bad password<br>    Status:             0xC000006D<br>    Sub Status:         0xC000006A<br><br>Process Information:<br>    Caller Process Name: C:\Windows\System32\winlogon.exe<br><br>Network Information:<br>    Source Network Address: 192.168.1.50<br>    Source Port: 49736<br><br>Detailed Authentication Information:<br>    Authentication Package: NTLM<br>    Logon Process:       User32</pre><p>The entry for 4624 (success) would look similar.</p><p>We could use Python to check for such entries as in previous sections,</p><pre>import subprocess<br><br>powershell_command = r&quot;&quot;&quot;<br>Get-WinEvent -LogName Security | Where-Object { $_.Id -in 4624, 4625 } | <br>Select-Object TimeCreated, Id, Message<br>&quot;&quot;&quot;<br><br>result = subprocess.run(<br>    [&quot;powershell&quot;, &quot;-Command&quot;, powershell_command],<br>    capture_output=True,<br>    text=True<br>)<br><br>if result.stdout:<br>  print(&quot;RDP success/failure Command Executions Found:&quot;)<br>  print(result.stdout)<br>else:<br>  print(&quot;No instances of RDP success/failure found in Windows Event Logs.&quot;)</pre><p>Output,</p><pre>No instances of RDP success/failure found in Windows Event Logs</pre><h3>Real-world Example</h3><p>Exploiting RDP is a very common technique amongst hackers. For example, the group <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Fgroups%2FG0108%2F">Blue Mockingbird</a> (described by MITRE as “<em>a cluster of observed activity</em>”) have been shown to use this technique. The group used malware to mine the cryptocurrency ‘Monero’ on victim’s machines circa 2020. In a <a href="https://www.google.com/url?q=https%3A%2F%2Fredcanary.com%2Fblog%2Fthreat-intelligence%2Fblue-mockingbird-cryptominer%2F">report by Red Canary</a> on this activity, RDP was used in order to move laterally and distribute the mining malware across devices.</p><p>In another example, the group known as <a href="https://attack.mitre.org/groups/G0035/">Dragonfly</a> were also reported to have used RDP in an attack. MITRE ATT&amp;CK describe them as “<em>…a cyber espionage group that has been attributed to Russia’s Federal Security Service (FSB) Center 16. Active since at least 2010, Dragonfly has targeted defense and aviation companies, government entities, companies related to industrial control systems, and critical infrastructure sectors worldwide through supply chain, spearphishing, and drive-by compromise attacks</em>”.</p><p>In <a href="https://www.cisa.gov/news-events/alerts/2018/03/15/russian-government-cyber-activity-targeting-energy-and-other-critical-infrastructure-sectors">the report by CISA</a>, a script used by Dragonfly in their attacks contained a number of commands which attempted to conduct a range of actions. They described it as follows: “<em>The script “enu.cmd” created an administrator account, disabled the host-based firewall, and globally opened port 3389 for Remote Desktop Protocol (RDP) access. The script then attempted to add the newly created account to the administrators group to gain elevated privileges. This script contained hard-coded values for the group name “administrator” in Spanish, Italian, German, French, and English.</em>”</p><p>Here we can see different elements of MITRE ATT&amp;CK occurring together. The creation of the administrator account is <a href="https://attack.mitre.org/tactics/TA0004/">Privilege Escalation</a>, the disabling of the host firewall is <a href="https://attack.mitre.org/tactics/TA0005/">Defense Evasion</a>, and the opening of port 3389 is preparing for <a href="https://attack.mitre.org/tactics/TA0008/">Lateral Movement</a>.</p><h3>Security Measures</h3><p>A number of measures can be employed to mitigate the risk of RDP. First is the auditing of group memberships, ensuring that such memberships are up-to-date and only include members who still require access. Another is to disable RDP functionality anywhere it is not needed. Enabling multi-factor authentication would be a third effective measure, as too would blocking the RDP service externally and internally (between network segments) using firewall rules. We saw something related to this in the Dragonfly attack above, where port 3389 was presumedly blocked, and the hackers then attempted to open it.</p><p>If RDP is essential for multiple users, it may be prudent to establish a <a href="https://www.splashtop.com/blog/remote-desktop-gateway?srsltid=AfmBOoq-xeakKg9TefCG5lDosCYAj4jaYACyhmW54vfttis2sH0wken9">Remote Desktop Gateway</a>, which is a dedicated server for handling RDP connections in a safe manner.</p><h3>What’s Next?</h3><p>Thanks to their efforts leading to this point, the attackers have now successfully remoted into another device on the network. This was made possible in part by the finding of an IP address and password, stored in plaintext, a network scan, and their use of RDP. Now that they find themselves on a system of interest, they’ll commence to the next phase of Collection.</p><p><strong>🔗 </strong><a href="https://medium.com/@tentotheminus9/7b8b8beead2f"><strong>Link to Part 11 -&gt;</strong></a><strong> 🔗</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf3d1029fc8f" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/python-mitre-att-ck-part-10-15-cf3d1029fc8f">Python &amp; MITRE ATT&amp;CK: Part 10/15</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python & MITRE ATT&CK: Part 9/15]]></title>
            <link>https://infosecwriteups.com/python-mitre-att-ck-part-9-15-666c1401fae9?source=rss-8b08ce01a167------2</link>
            <guid isPermaLink="false">https://medium.com/p/666c1401fae9</guid>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[mitre-attack]]></category>
            <dc:creator><![CDATA[Rob Harrand]]></dc:creator>
            <pubDate>Fri, 18 Apr 2025 08:14:39 GMT</pubDate>
            <atom:updated>2025-04-20T08:52:15.365Z</atom:updated>
            <content:encoded><![CDATA[<h4>Discovery</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6ym6n7nvJ3llbyEg" /><figcaption>Photo by <a href="https://unsplash.com/@victor_g?utm_source=medium&amp;utm_medium=referral">Victor</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>(🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-8-45b9abc4124b"><strong>&lt;- Link to back to Part 8</strong></a><strong>🔗)</strong></p><h3>Introduction</h3><p>So far, our attacker will have explored the available systems to a small extent, working methodically and patiently, limiting activity until defense evasion techniques had been employed. At this point, they’re likely to expand their efforts, and ask questions such as,</p><ul><li>What accounts are present? (Windows, email, cloud, etc.)</li><li>What is the network architecture?</li><li>What applications are running?</li><li>What sites have been visited using the browser?</li><li>What directories and files are available?</li><li>What <a href="https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/group-policy/group-policy-overview">Group policies</a> are in place?</li><li>What peripherals are attached?</li><li>What remote systems are available?</li><li>What Internet and Wi-Fi connections are in place?</li></ul><p>In our scenario, having found a list of passwords, the attacker is likely to try and find out where and how to use them. As before, this is likely to involve the running of commands in PowerShell, which could then be analysed in Python. This is the <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftactics%2FTA0007%2F">Discovery</a> phase of the MITRE ATT&amp;CK framework.</p><p>For example, the attacker may run the following,</p><pre># List active network connections<br>Get-NetTCPConnection | Where-Object { $_.State -eq &quot;Established&quot; }<br><br># Find domain controllers (if on an AD network)<br>nltest /dclist:&lt;DOMAIN_NAME&gt;<br><br># Get network configuration (IP, DNS, gateway)<br>ipconfig /all<br><br># Display active TCP connections, ports on which the computer is listening, , etc.<br>netstat -a</pre><p>These are common commands to explore some aspects of the system. For a comprehensive list, see this ‘<a href="https://github.com/kobs0N/Hacking-Cheatsheet">hackers cheat-sheet</a>’ on <em>GitHub</em>.</p><h3>Python Analysis</h3><p>A use of Python could be to search log-files for instances of users running commands such as <em>netstat. </em>Such an occurrence may not be untypical for IT staff, but less likely from general employees. Code such as the following could be used,</p><pre>import subprocess<br><br>powershell_command = r&quot;&quot;&quot;<br>Get-WinEvent -LogName Security | Where-Object {<br>    $_.Message -match &quot;netstat&quot;<br>} | Select-Object -Property TimeCreated, Id, Message<br>&quot;&quot;&quot;<br><br>result = subprocess.run(<br>    [&quot;powershell&quot;, &quot;-Command&quot;, powershell_command],<br>    capture_output=True,<br>    text=True<br>)<br><br>if result.stdout:<br>  print(&quot;Netstat Command Executions Found:&quot;)<br>  print(result.stdout)<br>else:<br>  print(&quot;No instances of &#39;netstat&#39; found in Windows Event Logs.&quot;)</pre><p>This uses a PowerShell command via the subprocess library to look for entries of ‘netstat’, displaying the results to the screen. Note that ‘Process Creation Logging’ needs to be active for this to work. To check to see if this is configured, run the following,</p><pre>auditpol /get /category:&quot;Detailed Tracking&quot;</pre><p>If it isn’t, go to <em>Group Policy Editor -&gt; Windows Settings -&gt; Security Settings -&gt; Advanced Audit Policy Configuration &gt; System Audit Policies &gt; Detailed Tracking</em>. Double-click ‘<em>Audit Process Creation</em>’ and select auditing for ‘Success and Failure’,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x0Eq6E1h_Rr3iDYjr3qEtg.png" /></figure><p>Then update with,</p><pre>gpupdate /force</pre><p>When logging is active, the output will be something like as follows,</p><pre>Netstat Command Executions Found:<br><br>TimeCreated           Id Message<br>-----------           -- -------<br>05/02/2025 15:09:20 4688 A new process has been created....</pre><p>Let’s assume that there was a line in the password file (see part 8) that read,</p><ul><li><strong><em>R&amp;D (192[.]168[.]68[.]133):</em></strong><em> rnd (new: Rnd123!, newer: fJif84Tu9F&amp;ejo!)</em></li></ul><p>We can imagine that our attacker ran ‘netstat -a’ and spotted this same IP address on the network. This discovery makes for a highly tempting target for the next phase.</p><p>Notice that there are actually three passwords in the line above. The first (“<em>rnd”</em>) is clearly incredibly weak. It looks like there’s then been an attempt to improve it with a capital letter, numbers, and a special character (“<em>Rnd123!”</em>), and then finally onto a more complex one still (“<em>fJif84Tu9F&amp;ejo!”</em>). The ‘evolution’ of a password file is likely in an organisation such as this one (i.e. one lacking in robust security policies and procedures).</p><p>This is all an example of <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1049%2F">System Network Connections Discovery</a> from MITRE ATT&amp;CK.</p><h3>Real-world Example</h3><p>A group that has used <em>netstat</em> for discovering network connections is <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Fgroups%2FG0138%2F">Andariel</a>. From MITRE: “<em>Andariel is a North Korean state-sponsored threat group that has been active since at least 2009. Andariel has primarily focused its operations — which have included destructive attacks — against South Korean government agencies, military organizations, and a variety of domestic companies; they have also conducted cyber financial operations against ATMs, banks, and cryptocurrency exchanges.’</em>”.</p><p>Note that Andariel is believed to be a sub-group of <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Fgroups%2FG0032%2F">Lazarus Group</a>, the infamous APT that was behind the <a href="https://www.google.com/url?q=https%3A%2F%2Fwww.secureops.com%2Fwp-content%2Fuploads%2F2021%2F06%2FSony-Breach-Analysis-v4.pdf">2014 Sony Pictures attack</a>, described by SecureOps as “<em>One of the Most Devastating Attacks in History</em>”</p><p>In a detailed report by <a href="https://www.google.com/url?q=https%3A%2F%2Fsecurelist.com%2Fandariel-evolves-to-target-south-korea-with-ransomware%2F102811%2F">Kaspersky</a>, the netstat commands used by Andrial in their attacks are detailed.</p><p>Another example can be seen in <a href="https://www.cisa.gov/news-events/cybersecurity-advisories/aa22-277a">a report by CISA</a> in 2022. In this report they document the activities of multiple APTs on a ‘Defense Industrial Base’ system, where the netstat command was detected. They summarised this stage by commenting that “<em>The actors used Command Shell to learn about the organization’s environment</em>”.</p><h3>Security Measures</h3><p>Mitigation approaches are difficult when attackers are using built-in system features to perform what could be legitimate actions. However, some techniques could be used.</p><p>The first are preventative measures, such as restricting command execution. For example, a feature of Windows called <a href="https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/applocker/applocker-overview">AppLocker</a> can be used to restrict certain users from running commands such as netstat. As we’ve seen before, this ‘principle of least privilege’ offers a solution, by limiting not just access to data, but also permissions on what can and cannot be run, to only those who absolutely need it. In the case of netstat, this is likely to only be members of the IT team.</p><p>Second would be detective measures, i.e. regular log checks as per the approach shown above. For a more robust approach, <a href="https://www.microsoft.com/en-gb/security/business/security-101/what-is-siem#:~:text=Security%20information%20and%20event%20management%2C%20SIEM%20for%20short%2C%20is%20a,before%20they%20harm%20business%20operations.">SIEM tools</a> such as <a href="https://www.fortinet.com/uk/resources/cyberglossary/what-is-splunk">Splunk</a> could be used. From the <em>Splunk </em>website, there is a <a href="https://research.splunk.com/endpoint/2cf5cc25-f39a-436d-a790-4857e5995ede/">dedicated detection command</a> for netstat execution.</p><h3>What’s Next?</h3><p>Now that the attackers have additional sets of credentials, coupled with the knowledge of other areas of the network, they will next attempt to access them. This is known as ‘lateral movement’, which we’ll learn more about in part 10.</p><p><strong>🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-10-15-cf3d1029fc8f"><strong>Link to Part 10 -&gt;</strong></a><strong> 🔗</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=666c1401fae9" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/python-mitre-att-ck-part-9-15-666c1401fae9">Python &amp; MITRE ATT&amp;CK: Part 9/15</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python & MITRE ATT&CK: Part 8/15]]></title>
            <link>https://infosecwriteups.com/python-mitre-att-ck-part-8-45b9abc4124b?source=rss-8b08ce01a167------2</link>
            <guid isPermaLink="false">https://medium.com/p/45b9abc4124b</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[mitre-attack]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Rob Harrand]]></dc:creator>
            <pubDate>Tue, 15 Apr 2025 07:47:13 GMT</pubDate>
            <atom:updated>2025-04-18T08:15:09.615Z</atom:updated>
            <content:encoded><![CDATA[<h4>Credential Access</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AXmIqdYkeCtjkbLF" /><figcaption>Photo by <a href="https://unsplash.com/@moneyphotos?utm_source=medium&amp;utm_medium=referral">rc.xyz NFT gallery</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>(🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-7-15-7e2357178dd5"><strong>&lt;- Link to back to Part 7</strong></a><strong>🔗)</strong></p><h3>Introduction</h3><p>Our attackers are in a member of staff’s system, they have admin rights, and they’ve started to cover their tracks. Their next task will be to obtain additional credentials that they can then use to access other parts of the network.</p><p>There are numerous methods to do this, ranging from simple to complex. At the simpler end of the spectrum there is the <a href="https://www.fortinet.com/uk/resources/cyberglossary/brute-force-attack#:~:text=A%20brute%20force%20attack%20is,and%20organizations&#39;%20systems%20and%20networks.">brute force</a> approach, which involves trying an exhaustive combination of password permutations sequentially, trying to find one that works. The chance of success of such an approach is often increased thanks to people using weak passwords, such as ‘password123’, which hackers will likely prioritise in their attempts. ‘Dictionary attacks’ are similar, but instead uses a pre-defined list of possible passwords. Another variant is that of ‘credential stuffing’, where username and password combinations from one website are tried on another. This exploits that fact that people often reuse the same password in multiple places, potentially resulting in a password used on an easily hacked website ultimately granting access to a much more sensitive system. For example, if someone used a strong password for ‘<em>Joe Blogg’s Gardening online marketplace</em>’, and then used the same password for their work account. The password may be a good one, but it may be easily discovered by hackers.</p><p>At the other end of the spectrum in terms of complexity are techniques such as using <a href="https://www.fortinet.com/uk/resources/cyberglossary/what-is-keyloggers#:~:text=A%20keylogger%20is%20a%20form,your%20keystrokes%20as%20you%20type.">keyloggers</a>, which are pieces of software that can record every key pressed by a (legitimate) user, and <a href="https://www.crowdstrike.com/en-us/cybersecurity-101/cyberattacks/kerberoasting/">Kerberoasting</a>, where encrypted passwords are obtained from a <a href="https://www.varonis.com/blog/kerberos-authentication-explained">Kerberos ticket</a> (part of a common authentication process in Windows), which are then decrypted offline.</p><p>In our scenario, we’ll go even simpler than techniques such as Brute force, and simply use the approach that relies on credentials being available in plain text, such as when stored in a file, email, chat history, or transmitted traffic over the network in an unencrypted form (i.e. <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1040%2F">Network sniffing</a>).</p><p>To this end, we’ll assume that our user has access to a file that contains passwords. Perhaps the user himself always had access to this file, or maybe our hacker with admin rights can now access an area that the standard user account couldn’t. Whatever the case, the file is located and is a goldmine for the attacker. As with other security laxes in previous sections of this blog series, do not doubt that such a poor practices still exist. A <a href="https://onmsft.com/news/survey-says-40-of-organizations-store-admin-passwords-in-a-word-document/">report from 2016</a> revealed that 40% of organisations surveyed stored admin passwords in plaintext, and in 2019 <a href="https://krebsonsecurity.com/2019/03/facebook-stored-hundreds-of-millions-of-user-passwords-in-plain-text-for-years/#:~:text=Renfro%20said%20the%20issue%20first,statement%20about%20this%20incident%20here.">it was discovered</a> that hundreds of millions of users had their passwords stored in plaintext at Facebook.</p><p>This is a case of <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1552%2F001%2F">Unsecured Credentials: Credentials In Files</a> from MITRE ATT&amp;CK.</p><h3>Python Analysis</h3><p>We can use Python to check common areas for common filenames, and common terms within any readable files that are suspicious. The code below starts by setting the directories of interest (in this case, ‘Desktop’, ‘Documents’, and ‘Downloads’), and then searches for any files in these locations with the terms ‘password’, ‘cred’, ‘secret’ or ‘pw’ in them. Of course, these locations and terms can be set to anything you wish. Next, a regular expression is created to search for common password patterns. For any files found in the filename search, access is attempted, and if successful, the keywords are searched for <em>within </em>the file. Finally, if a sensitive keyword is found within a given file, a password pattern is searched for, using the regular expression,</p><pre>import os<br>import re<br><br># Directories to search (modify as needed)<br>directories = [<br>    os.path.expanduser(&quot;~/Desktop&quot;),<br>    os.path.expanduser(&quot;~/Documents&quot;),<br>    os.path.expanduser(&quot;~/Downloads&quot;),<br>]<br><br># Suspicious filenames<br>suspicious_terms = [&#39;password&#39;, &#39;cred&#39;, &#39;secret&#39;, &#39;pw&#39;]<br><br>for directory in directories:<br>  for root, _, files in os.walk(directory):<br>    for file in files:<br>      file_path = os.path.join(root, file)<br>      for i in suspicious_terms:<br>        if i in file:<br>          print(f&quot;[ALERT] Suspicious file found: {file_path}&quot;)<br><br># Keywords to search for inside files<br>keywords = [&quot;password&quot;, &quot;pass&quot;, &quot;secret&quot;, &quot;token&quot;, &quot;key&quot;, &quot;cred&quot;]<br><br># Regex pattern for finding potential passwords<br>password_pattern = re.compile(r&quot;(password|pass|token|key)\s*=\s*[&#39;\&quot;]?(\S+?)<br>[&#39;\&quot;]?&quot;, re.IGNORECASE)<br><br>for directory in directories:<br>  for root, _, files in os.walk(directory):<br>    for file in files:<br>      file_path = os.path.join(root, file)<br>      for i in suspicious_terms:<br>        if i in file:<br>          print(f&quot;[ALERT] Suspicious file found: {file_path}&quot;)<br><br>          # Try to open and read the file<br>          try:<br>            with open(file_path, &quot;r&quot;, encoding=&quot;utf-8&quot;, errors=&quot;ignore&quot;) as f:<br>              content = f.read()<br>              # Search for keywords<br>              if any(keyword in content for keyword in keywords):<br>                print(f&quot;[ALERT] Sensitive content in {file_path}&quot;)<br><br>                # Search for password patterns<br>                matches = password_pattern.findall(content)<br>                if matches:<br>                  for match in matches:<br>                    print(f&quot;[WARNING] Possible password found in {file_path}: {match[1]}&quot;)<br>          except Exception as e:<br>            pass  # Ignore files we can&#39;t read</pre><p>This gives an output like below,</p><pre>[ALERT] Suspicious file found: C:\Users\example/Desktop\passwords.txt<br>[ALERT] Suspicious file found: C:\Users\example/Desktop\pws.txt<br>[ALERT] Sensitive content in C:\Users\example/Desktop\pws.txt<br>[WARNING] Possible password found in C:\Users\example/Desktop\pws.txt</pre><p>Of course, our attacker could also run a script like this, to save time and find any obvious password files.</p><p>Let’s assume that’s exactly what they did, and they found a password text-file containing dozens of passwords for various systems. Let’s imagine that the file is a bit of a mess, and it appears that it’s been added to over the years. Some of it may not be relevant, but some of it may be. We’ll see more on this in the next post.</p><h3>Real-world Example</h3><p>The group <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Fgroups%2FG0119%2F">Indrik Spider</a> has been shown to hunt for plaintext credentials on compromised devices. From MITRE: “<em>Indrik Spider is a Russia-based cybercriminal group that has been active since at least 2014. Indrik Spider initially started with the Dridex banking Trojan, and then by 2017 they began running ransomware operations using BitPaymer, WastedLocker, and Hades ransomware. Following U.S. sanctions and an indictment in 2019, Indrik Spider changed their tactics and diversified their toolset</em>”</p><p>For further details, a <a href="https://www.google.com/url?q=https%3A%2F%2Fcloud.google.com%2Fblog%2Ftopics%2Fthreat-intelligence%2Func2165-shifts-to-evade-sanctions%2F">report by Mandiant</a> discusses the group ‘UNC2165’ (the same group as Indrik Spider), mentioning these searches, amongst many other tactics, techniques, and procedures.</p><h3>Security Measures</h3><p>Having plaintext passwords littering an environment is a symptom of poor staff training and a lack of password polices. A combination of training with an emphasis on password best practices, coupled with an effective policy would help to mitigate this risk. Beyond this, a password vault such as <a href="https://www.google.com/url?q=https%3A%2F%2Fbitwarden.com%2F">Bitwarden</a> would help, as this encourages the use of complex passwords that are not shared amongst different systems and services. Business-level accounts can even detect weak and repeated passwords across an organisation, which is extremely useful for security administrators to be aware of.</p><p>In terms of some of the other credential access techniques mentioned such as the Brute force approach, an easy measure here is to place some sort of limit or throttle on the number of attempts that are allowed, either overall, or in a give time period. For example, in Active Directory, an <a href="https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/security-policy-settings/account-lockout-policy">account lockout policy</a> can be configured that will lock a user’s account if too many attempts at a password are attempted. This at first feels like a watertight measure, but be aware of an attack called ‘<a href="https://www.crowdstrike.com/en-us/cybersecurity-101/cyberattacks/password-spraying/">password spraying</a>’, where hackers will limit the number of guessed passwords to below a common lockout threshold (e.g. 10 attempts), but will ‘spray’ the top 5 (for example) most common passwords at hundreds of accounts, hoping that someone will have used one of them. This can allow them to gain access via a simple approach, without triggering alarms of this type. The solution here is a strong password policy, and monitoring of attempted logins across all devices.</p><h3>What’s Next?</h3><p>Armed with additional credentials, a hacker is likely to further explore the environment and see what options are available for advancing the attack. We’ll see this in the Discovery phase next.</p><p><strong>🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-9-15-666c1401fae9"><strong>Link to Part 9 -&gt;</strong></a><strong> 🔗</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45b9abc4124b" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/python-mitre-att-ck-part-8-45b9abc4124b">Python &amp; MITRE ATT&amp;CK: Part 8/15</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python & MITRE ATT&CK: Part 7/15]]></title>
            <link>https://infosecwriteups.com/python-mitre-att-ck-part-7-15-7e2357178dd5?source=rss-8b08ce01a167------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e2357178dd5</guid>
            <category><![CDATA[mitre-attack]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Rob Harrand]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 08:27:19 GMT</pubDate>
            <atom:updated>2025-04-15T07:47:40.268Z</atom:updated>
            <content:encoded><![CDATA[<h4>Defence Evasion</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Gu8vWTjj09IJKZEE" /><figcaption>Photo by <a href="https://unsplash.com/@hannes_wolf?utm_source=medium&amp;utm_medium=referral">Hannes Wolf</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>(🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-6-53f5cea7a05c"><strong>&lt;- Link to back to Part 6</strong></a><strong> 🔗)</strong></p><h3>Introduction</h3><p>A key step in a cyberattack is the next part of the MITRE ATT&amp;CK framework: <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftactics%2FTA0005%2F">Defence Evasion</a>.</p><p>Earlier (in part 4), we used the analogy of a security guard patrolling a physical premises when discussing the monitoring of logs on a device. Now, we can imagine a thief who had gained access to such a property and is now employing techniques to avoid the security guard and other such controls. For example, they might operate as quietly as possible, ensuring they don’t leave obvious signs of their presence like open doors. They may also use objects that they find on the scene, such as a landline telephone to contact their accomplices, or even go as far as disabling the CCTV system.</p><p>Similarly, hackers wish to fly under the radar when present on a compromised device, especially if they intend on their attack lasting a long time. For example, according to IBM as noted in <a href="https://www.alliedcybersecurity.net/blog/how-long-do-hackers-stay-in-your-network">this article</a> from 2023, the average time for a hacker to be present on a system before advancing their attack is 206 days. It is therefore crucial that any activity during such a long period goes undetected.</p><p>The types of techniques employed in this area is broad, ranging from using fileless malware that only operates in memory, to the use of ‘rootkits’ that intercept application calls in order to quietly run other commands. Another common technique, touched upon in part 5, is ‘living off the land’ (LOTL). This is where hackers use built-in, legitimate tools to progress their attack, thus avoiding certain obvious signs of intrusion. For more on this, take a look at the article ‘<a href="https://www.aquasec.com/cloud-native-academy/cloud-attacks/defense-evasion/">Defense Evasion: Advanced Techniques Undermining Cybersecurity</a>’ from <em>aqua</em>.</p><h3>Python Analysis</h3><p>For our scenario, we’ll use a very simple example, which is the clearing of Windows logs, which an attacker may do using the following commands,</p><pre>wevtutil cl Security  # Clear Security logs<br>wevtutil cl System  # Clear System logs<br>wevtutil cl Microsoft-Windows-PowerShell/Operational  # Clear PowerShell logs</pre><p>Such an act would have the benefit of evading our previous tactics of monitoring certain logs for signs of suspicious behaviour. However, a problem for our attacker is that this action in turn will generate an <a href="https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-1102">Event ID of 1102</a>, which we can check for using the following code within Python,</p><pre>powershell_script = r&quot;wevtutil qe Security /c:100 /f:text&quot;<br>result = subprocess.run([&quot;powershell&quot;, &quot;-Command&quot;, powershell_script], <br>capture_output=True, text=True)<br><br>if re.search(r&quot;Event ID:\s+1102&quot;, result.stdout):<br>  print(&quot;[ALERT] Possible event log clearing detected! (Event ID 1102)&quot;)<br>else:<br>  print(&quot;[INFO] No event log clearing detected.&quot;)</pre><p>Output,</p><pre>[ALERT] Possible event log clearing detected! (Event ID 1102)</pre><p>This is an example of <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1070%2F001%2F">Indicator Removal: Clear Windows Event Logs</a> from the MITRE ATT&amp;CK framework.</p><p>Note that the clearing of logs does not only have the immediate effect of removing signs of certain activities. There are other possible repercussions, such as hampering future investigations (e.g. incident response or forensic investigations), limiting transparency and accountability (possibly leading to a damaging of company reputation), and falling foul of legal and regulatory compliance. For more on such factors, see <a href="https://www.eccouncil.org/cybersecurity-exchange/ethical-hacking/clearing-logs/">this report</a> by the <em>EC Council</em>.</p><p>Attackers may also check to see what anti-virus software is running (recall that this was advised during the reconnaissance dark web conversation in part 1). One way to do that would be to run the following PowerShell command,</p><pre>Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct</pre><p>This would give a result similar to the below,</p><pre>displayName              : Windows Defender<br>instanceGuid             : {12345678-ABCD-1234-5678-ABCDEFGHIJKL}<br>pathToSignedProductExe   : windowsdefender://<br>pathToSignedReportingExe : %ProgramFiles%\Windows Defender\MsMpeng.exe<br>productState             : 393216<br>timestamp                : Tue, 26 Nov 2024 08:18:57 GMT<br>PSComputerName           :</pre><p>Here we can see Windows Defender, and typically, there would also be a third-party antivirus software application present. Thankfully for our attackers, no such application is detected.</p><h3>Real-world Example</h3><p>Many APT groups have been shown to use this simple approach to defence evasion. For example, the ransomware <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Fsoftware%2FS1068%2F">Blackcat</a>, used by multiple APTs, has functionality that uses wevtutil, similar to the above examples. From MITRE: “<em>BlackCat is ransomware written in Rust that has been offered via the Ransomware-as-a-Service (RaaS) model. First observed November 2021, BlackCat has been used to target multiple sectors and organizations in various countries and regions in Africa, the Americas, Asia, Australia, and Europe</em>”.</p><p>For an in-depth look at Blackcat, including the command it uses to clear logs, see the article ‘<a href="https://www.microsoft.com/en-us/security/blog/2022/06/13/the-many-lives-of-blackcat-ransomware/">The many lives of BlackCat ransomware</a>’ by <em>Microsoft</em>.</p><p>One such group to use Blackcat is <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Fgroups%2FG1015%2F">Scattered Spider</a>, who in the past have targeted several large organisations and their associated, contracted IT helpdesk. In 2024, <a href="https://www.google.com/url?q=https%3A%2F%2Fwww.reuters.com%2Ftechnology%2Fcybersecurity%2Fus-charges-five-scattered-spider-hacking-scheme-2024-11-20%2F">five members of the group were charged</a> for their hacking offences.</p><h3>Security Measures</h3><p>An effective approach here would be to automatically copy any important logs to a remote and secure location (with minimal delay). For example, using a scheduled off-site or cloud copying process. In addition, write-permissions to local log files should be restricted.</p><p>The organisation should also invest in additional antivirus software. Despite Windows Defender being an effective defence in certain areas, it lacks some key functionality found in other products. For example, in the article ‘<a href="https://www.security.org/antivirus/windows-10/#:~:text=Windows%20Defender%20scans%20a%20user&#39;s,more%20antivirus%20software%20is%20necessary.">Does Windows 10 Come With Antivirus?</a>’ by <em>Security.org</em>, the author comments that “<em>Windows Defender lacks endpoint protection and response, as well as automated investigation and remediation, so more antivirus software is necessary</em>”.</p><p>In a business environment, there are other factors to consider, beyond preventing viruses from infecting machines. One might be the ability to have an overview of all devices on the network from the standpoint of malware protection, such as that offered by a dashboard. Others might be the ability to investigate incidents across multiple devices, activate the rapid quarantining of a device, or even to have an external security team monitor and take action on behalf of an organisation, using a <a href="https://www.sophos.com/en-us/products/managed-detection-and-response">Managed Detection and Response service</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9QvkP58yK1qw-951.png" /><figcaption>An example of a security dashboard (<a href="https://www.sophos.com/en-us/products/mobile-control">source</a>)</figcaption></figure><h3>What’s Next?</h3><p>The attackers have taken a simple approach to defense evasion and are now aware of the lack of a third-party antivirus application. They can now confidently progress to the next stage of their attack, which is Credential Access.</p><p><strong>🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-8-45b9abc4124b"><strong>Link to Part 8 -&gt;</strong></a><strong> 🔗</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e2357178dd5" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/python-mitre-att-ck-part-7-15-7e2357178dd5">Python &amp; MITRE ATT&amp;CK: Part 7/15</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python & MITRE ATT&CK: Part 6/15]]></title>
            <link>https://infosecwriteups.com/python-mitre-att-ck-part-6-53f5cea7a05c?source=rss-8b08ce01a167------2</link>
            <guid isPermaLink="false">https://medium.com/p/53f5cea7a05c</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[mitre-attack]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Rob Harrand]]></dc:creator>
            <pubDate>Sun, 13 Apr 2025 08:13:59 GMT</pubDate>
            <atom:updated>2025-04-14T08:27:46.714Z</atom:updated>
            <content:encoded><![CDATA[<h4>Privilege Escalation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NhopLeMJpPIyk2Aj" /><figcaption>Photo by <a href="https://unsplash.com/@claybanks?utm_source=medium&amp;utm_medium=referral">Clay Banks</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>(🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-5-15-66e639a31885"><strong>&lt;- Link to back to Part 5</strong></a><strong>🔗)</strong></p><h3>Introduction</h3><p>What’s next for our attackers? They now have a ‘backdoor’ account that’s persistent, and will proceed towards their ultimate goal of stealing sensitive IP from the company.</p><p>It’s important to note that not all cyberattacks are linear, nor do they all involve every step of the MITRE ATT&amp;CK framework. At this point in the attack, it’s possible that the perpetrators can access everything they need in order to achieve their goals. However, in our scenario, let’s assume they currently have no access to the data of interest, or even know where it’s stored. If that were the case, they’re likely to next explore the network and try and gain additional credentials.</p><p>For this section of the blog, let’s go back a step and assume that the local account that the attackers have compromised did <em>not </em>have admin rights. They would need to gain these rights first, in order to create their backdoor account.</p><p>One method they could use is known as an ‘Unquoted Service Path’ exploit. Although this issue is increasingly fixed in modern systems, a quick Google search revealed that it is still present in older systems, or newer ones that are poorly configured. For example, in the article ‘<a href="https://www.zdnet.com/article/bug-that-grants-admin-rights-to-malware-found-in-maxthon-chinas-favorite-browser/">Bug that grants admin rights to malware found in Maxthon, China’s favorite browser</a>’ from 2019, this vulnerability was found that have potentially affected hundreds of millions of users, with the author commenting that “<em>programmers continue to make the same mistake, decades after unquoted service path vulnerabilities have first been documented</em>” and that “<em>Some of the world’s biggest tech companies and open-source projects have shipped software vulnerable to unquoted service path vulnerabilities in the past few years. From </em><a href="https://www.dell.com/support/article/ro/ro/robsdt1/sln313398/dell-wyse-management-suite-multiple-unquoted-service-path-vulnerabilities?lang=en"><em>Dell</em></a><em> to </em><a href="https://www.vulnerability-lab.com/get_content.php?id=1981"><em>Intel</em></a><em>, and from </em><a href="https://support.forcepoint.com/KBArticle?id=000017525"><em>Forcepoint</em></a><em> to </em><a href="https://www.exploit-db.com/exploits/42121"><em>BIND</em></a><em>; they’ve all done it</em>”.</p><p>The exploit works by tricking the <a href="https://www.google.com/url?q=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fwindows%2Fsecurity%2Fidentity-protection%2Faccess-control%2Flocal-accounts%23system">SYSTEM account</a> (which is used by Windows to run background tasks and has the highest permission level) to execute code that otherwise couldn’t be run (by the lower-privileged local user).</p><p>This occurs when the SYSTEM service runs the <em>CreateProcess</em> function, which crucially takes a file path and filename as a parameter. If this path and filename string contains spaces and is wrapped in quotation marks, then there is no issue. However, if not, then Windows will attempt to ‘find’ the file by trying a number of different options.</p><p>For example, let’s say that the path and filename are,</p><ul><li>C:\Program Files\My App\ServiceExecutable.exe</li></ul><p>If the path is unquoted (as shown), Windows will attempt to execute the file in the following order (trying each time there is a space in the path),</p><ul><li>C:\Program.exe</li><li>C:\Program Files\My.exe</li><li>C:\Program Files\My App\ServiceExecutable.exe</li></ul><p>This could be devastating. The SYSTEM service, which has the highest level of permissions and access on Windows, will try to run ‘C:\Program.exe’ (for example), regardless of whether that is what the IT admins wanted, or even if the file exists. What this means is that if our attacker places a malicious file called Program.exe on the drive (i.e. in C:\), the system will happily run it with SYSTEM privileges.</p><p>Let’s assume that this is the approach that they’ve taken. We could imagine that perhaps they found this unquoted service path themselves, or maybe the disgruntled IT staff member that we heard about in part 1 mentioned it to them.</p><h3>Python Analysis</h3><p>As before, one thing we could do is to look at log entries to detect this sort of activity. For example, the event ID 4688 may be logged, which refers to a new process creation.</p><p>Instead, let’s use Python to directly detect this vulnerability on a system. Rather than run a command and export the results to a text file (like in some of the previous sections), let’s use a PowerShell command (taken from <a href="https://github.com/v4resk/red-book/blob/main/redteam/privilege-escalation/windows/services/unquoted-service-path.md">this source</a>) and run it <em>within </em>Python using the <a href="https://www.google.com/url?q=https%3A%2F%2Fwww.geeksforgeeks.org%2Fpython-subprocess-module%2F">subprocess</a> library,</p><pre>import subprocess<br><br># PowerShell command<br>powershell_script = r&quot;&quot;&quot;<br>Get-WmiObject win32_service | select Name,PathName,StartMode,StartName | <br>where {$_.StartMode -ne &quot;Disabled&quot; -and $_.PathName -notmatch &quot;`&quot;&quot; -and <br>$_.PathName -notmatch &quot;C:\\Windows&quot;} | Format-List<br>&quot;&quot;&quot;<br># Run the PowerShell command using subprocess<br>result = subprocess.run([&quot;powershell&quot;, &quot;-Command&quot;, powershell_script], <br>capture_output=True, text=True)<br><br># Print the output<br>print(result.stdout)</pre><p>This specifically searches for any examples of unquoted paths. For example, it may give an output like below,</p><pre>Name      : Program name<br>PathName  : C:\ProgramData\Example Folder\Example File.exe<br>StartMode : Manual<br>StartName : LocalSystem</pre><p>This could then be fixed by a security team, or exploited by a hacker.</p><p>We’ll assume that our attacker found and exploited such an example, and now has administrator access. This is <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Ftechniques%2FT1574%2F009%2F">Hijack Execution Flow: Path Interception by Unquoted Path</a> as described on the MITRE ATT&amp;CK site.</p><h3>Real-world Example</h3><p>Several groups have been shown to use a piece of software called <a href="https://www.google.com/url?q=https%3A%2F%2Fattack.mitre.org%2Fsoftware%2FS0363%2F">Empire</a>, which from MITRE is “<em>an open source, cross-platform remote administration and post-exploitation framework that is publicly available on GitHub</em>”. The code is written in Python, but uses PowerShell for the post-exploitation functionality. Empire has specific modules that can search for and then exploit unquoted path vulnerabilities.</p><p>Although not specifically cited as targeting this vulnerability, one group that is know to use Empire is FIN13. According to MITRE: “<em>FIN13 is a financially motivated cyber threat group that has targeted the financial, retail, and hospitality industries in Mexico and Latin America, as early as 2016. FIN13 achieves its objectives by stealing intellectual property, financial data, mergers and acquisition information, or PII</em>”. Mandiant published <a href="https://cloud.google.com/blog/topics/threat-intelligence/fin13-cybercriminal-mexico">a report</a> on this group in 2021, revealing an array of techniques used in their attacks.</p><p>Another example of this vulnerability, although from a patching point of view rather an a case of exploitation, can be found in a 2022 update by <a href="https://www.sap.com/uk/about/company.html">SAP</a>, a leading global IT company. An unquoted path was detected and patched, deemed to be a critical and high priority vulnerability. For more details, see <a href="https://www.theregister.com/2022/09/13/microsoft_patch_tuesday_september_2022/">this summary</a> by <em>The Register</em>.</p><h3>Security Measures</h3><p>Searching for and fixing unquoted paths is the best fix for this issue, as outlined above. In addition, measures such as restricting executable paths would help (even for the SYSTEM account), as the attackers would be prevented from running their executable files in the locations where they drop them.</p><h3>What’s Next?</h3><p>A common next step according to the MITRE ATT&amp;CK framework involves actions that evade the defences of the system. We’ll see how this might be done in the next blog.</p><p><strong>🔗 </strong><a href="https://medium.com/@tentotheminus9/python-mitre-att-ck-part-7-15-7e2357178dd5"><strong>Link to Part 7 -&gt;</strong></a><strong> 🔗</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53f5cea7a05c" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/python-mitre-att-ck-part-6-53f5cea7a05c">Python &amp; MITRE ATT&amp;CK: Part 6/15</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>