White Papers
November 11, 2023 . 16 min read

Demystifying Bring Your Own Reputation (BYOR) technique for fun and profit

Preface


BYOR"

Crafting resilient defenses is essential in protecting against a growing number of malicious threats. Organizations across the globe invest significantly in defensive solutions, relying on their capabilities to detect and block adversaries. Adversaries and defenders are engaged in an ongoing cat-and-mouse game and as defenders devise new protection strategies, attackers simultaneously innovate novel ways to circumvent these defenses. At P.I.V.O.T Security, we believe that understanding the intricacies of these bypass techniques is essential for maintaining robust defense.

Alright, straight from the P.I.V.O.T's R&D red team labs:

We've brainstormed and conceptualized an intriguing new technique - Bring Your Own Reputation (BYOR). A recent demonstration of this was made on our LinkedIn post where we showcased a video of BYOR technique.

POC in Action:

POC - With BYOR Bypass: This technique ensured there were no SmartScreen prompts and Windows Defender (WD) remained silent to our exploitation attempts.

To begin the process, we first set up a Havoc Command & Control server on a VPS, which enabled us to access it remotely using a Team server to access the GUI. Once Havoc was set up, we created a custom payload that would allow us to get the callback inside Havoc, which paves the way for our BYOR technique.

Background


A foundational understanding of any system is the key to navigating its complexities and Microsoft's SmartScreen is no exception. Let's take a closer look at how SmartScreen operates. According to Microsoft Microsoft Defender SmartScreen identifies potentially malicious downloaded apps or installers in two primary ways:

Smartscreen warning
Smartscreen warning report
  1. It carefully inspects downloaded files, comparing them against an extensive list of reported malicious software sites and programs. If there's any match then a warning pops up which signals the user about the potential harm.

  2. Parallelly, it evaluates these files against a list of popular and frequently downloaded items. If a particular file hasn't made its mark on this list, the SmartScreen raises an alert which suggests the user to proceed with care.

Windows, like many operating systems has multiple lines of defense to protect its users. One notable feature is SmartScreen which uses cloud-based anti-phishing and anti-malware components to check web pages and files against a list of reported malicious sites and files. To enhance this security feature, any file downloaded from the internet is tagged with the Mark of the Web (MOTW), acting as a footprint of the file's origin.

MOTW flag captured from a file downloaded from internet!

This system is mostly reputation-based which means that well-known files with a positive track record are less likely to be flagged or restricted. Windows' reputation-based system, as mentioned, will generally trust files that are well-known and have previously been deemed safe. The potential loophole could arise in how this "reputation" is determined or manipulated.

To shed some light on the current exploitation techniques used by threat actors, lets look at them first.

Common Vectors Used by Threat Actors

To fully appreciate the potential of the BYOR technique, it's essential to understand the current strategies threat actors employ to bypass systems like SmartScreen:

  • Signed Executables: Files like Exe, MSI, MSIX, APPX, or even 'click once' applications are often signed to help bypass security measures. However, many of these methods require an extra EV certificate to bypass SmartScreen, making it a restrictive path for numerous threat actors.

  • Containerizing the Initial Infection: Some adversaries use containers such as zip, iso, vhdx, vhd, or 7z to wrap the payload, intending to bypass browser protection. But this method still faces challenges with MOTW/SmartScreen.

  • ISO with Sideloading: Using ISO sideloading can effectively bypass SmartScreen checks and execute payloads. Yet, this method's popularity means it's more likely to be detected by EDR systems.

    • Inspecting the PlugX Technique: While testing ISO + Sideloading, issues have arisen, especially with the planned Windows security update intending to block loading of unsigned DLLs within signed EXEs. Now, with sideloading, if you run an executable that Microsoft's given the thumbs up, you can sneak in an unsigned DLL. Crafty, right? But will this trick hold up in the long haul? Who knows!

This brings us to the core question:

Can BYOR truly overcome these challenges ?

But here's where things get interesting. What if hypothetically, one could manipulate or make use of files already in Microsoft's "good list"? Could we then be able to trick SmartScreen and bypass the security checklist?

A prevalent myth exists that for an .exe, .dll, or even an .msi to gain Microsoft's stamp of approval, it needs to bear a EV signature. But our hands-on research paints a different picture. In our studies, we've encountered numerous executable files .exe, .msi etc. that successfully evaded SmartScreen's checks, despite lacking a valid digital signature.

When software accumulates a substantial number of downloads, it steadily establishes a positive Smartscreen reputation. And this very reputation mechanism is what we're keen on exploring further with BYOR technique.

BYOR (Bring Your Own Reputation)


Bring Your Own Reputation (BYOR) is old and lesser known bypass technique which is being conceptualized to exploit the inherent reputation-based system of defenses such as Microsoft's SmartScreen. The core philosophy behind BYOR stems from understanding that many modern protective measures notably SmartScreen, lean on the reputation of files to determine their safety.

Fundamental Principles of BYOR:

  1. Exploitation of Reputation Mechanism: At its heart, BYOR is about understanding and manipulating the reputation mechanism.

  2. Beyond Signatures: Unlike some other bypass methods which require files to have a digital signature, BYOR operates beyond this. In the BYOR approach, files that lack a valid digital signature but have an established reputation can still bypass checks.

Microsoft's Smartscreen is designed to swiftly verify whether a downloaded executable or a browsed site is recognized as safe or harmful. Our main aim is centered on optimizing our initial access delivery.

When Smartscreen scans a file before saving it to disk, it checks if the downloaded file is recognized as safe. If it's identified as a widely downloaded and safe file, it allows the download. However, if the file is unfamiliar or has been flagged as malicious, the user sees a stringent Smartscreen warning.

With bypass techniques like CVE-2022-44698 emerging, threat actors consistently devise new methods. The term "Bring Your Own Reputation" (BYOR) defines a category of files (both signed and unsigned) that are whitelisted by SmartScreen and can be manipulated to evade security measures.

BYOR encompasses various file types including .bat, .jscript, .vbscript, .msi, and .exe, which can be leveraged to bypass checks.

How BYOR Bypasses the Need for Signatures

While digital signatures are a standard method for establishing trust, they're not the only one. Remember, reputation-based systems, by their nature, lean on the historical behavior of files. If a file has been widely circulated, used, and hasn't been flagged as malicious over time, it could gain a positive reputation.

The Basic Structure of BYOR:

  1. Selecting the File: Identify a file that's been around for a significant period. My top choice is a .bat file due to its readable and open nature, allowing us to directly view and understand the code within. In this context, I'll delve into exploiting a .bat file that's been around for over a decade.
  2. Exploiting the Code: Probe the insecure code segments within the selected file to perform unintended actions.
  3. Abusing for Malicious Intent: Abuse that file to initiate something malicious. Considering SmartScreen doesn’t cascade checks to all sideloaded files, our payload neither requires signing nor a position on SmartScreen's approved list.

Applying BYOR in Operations

Wondering how to implement BYOR to your advantage? If we mirror the strategies utilized in DLL sideloading, we can curate a similar sequence via BYOR which opens the door for unsigned sideloading as well. Let's illustrate the process we showcased in our LinkedIn post with a straightforward flowchart for better clarity:

BYOR working flowchart

Leveraging the BYOR Approach for Initial Access Chain Creation


Let's delve into how this method can be utilized for creating an initial access chain using a simple yet effective example.

  1. Find a Reputed file which is badly coded.

    • It's common for cyber attackers to search for reputed files with poor coding practices. This approach works because such files have established trust but are vulnerable to attacks due to their coding flaws.
  2. Locate A Source to Download Such Files

    • Websites like exefiles.com are often hunt by cyber professionals. They offer files that have existed for a long time, some of which may have known vulnerabilities.
  3. Choosing the Right File

    • For example purposes, we'll use a .CMD file: [ps2pdf14.cmd/ps2pdf13.cmd/ ps2pdf12.cmd]. This file can be found at the provided link. Ps2pdf.cmd (exefiles.com) Also, note that there is no Chrome warning while downloading it. So we're already on the right path.
  4. Exploitation Strategy

    • Dive deep into the existing functionality and code of the file.
    • Always be on the lookout for loopholes. This might include a file calling another batch file or a file calling another using functions like ‘call’.
    • The objective is to pinpoint a piece of code that calls another file or executable. This allows us to manipulate the execution.
  5. Diving into the Chosen File

    • Our chosen file contains this specific line of code: call 'ps2pdf' '-dCompatibilityLevel=1.3' params. Here, the file calls 'ps2pdf' situated in the same directory. However, no file extension is specified in this function. ps2pdf open"
    • This thing is interesting to say the least. When you run the process monitor on Windows, you'd notice that it tries to find all possible file extensions located in the PATHEXT path variable. The 'call' function initiates a search of all extensions in the PATHEXT variable. Something similar to below image. Here, it is looking for ps2pdf.js, but it's checking all type of file extension before hand pathext finds"
    • This essentially means this code will attempt to execute any file with a matching name, regardless of its extension, in the current directory. Got your head spinning yet ?
  6. Taking Advantage of the Flaw

    • This is where we put on our hacker hat. Given the file's code flaw, it's ripe for a BYOR attack.
    • Here's a simple strategy: Create another file named ps2pdf.exe which triggers a Havoc C2 remote callback when executed on the system. We will also rename the downloaded ps2pdf14.cmd to something else, say payload.bat.
    • What happens next is fascinating. By manipulating the code, we can sideload a .exe file. This means, irrespective of SmartScreen filters or other security protocols, we can run a js, vbs, jse, wsf, vbe, exe, bat, com, or even a py file (provided Python is installed).
  7. Crafting the Initial Access Chain & Testing It

    • Though the original ps2pdf14.cmd/payload.bat (now) has a reputation, the file it calls might not have it. The workaround? Pack both files inside a container that can be delivered directly inside a browser.
    • For this example, we containerized the payloads which creates a .zip out of the package.
    • As demonstrated in the POC, sideloading another unsigned EXE file bypasses any SmartScreen prompt.

    BYOR zip!"

    • Note: There's no prompt when downloading the byor.zip file.

For delivery purposes, we created a .zip file using our in-house (in-research) OCA (Offensive Chain by Astra) framework. With OCA we are automatically able to create a BYOR payload with just a few clicks, saving us a huge amount of time and making the jobs of red teamers more efficient to test their organization infrastructure with new kill chains. A standout feature includes the ability to auto-deploy the crafted payload to a designated VPS for hosting as demo'ed in this post. Within the zip which is stored securely on VPS, there are two crucial files: a BYOR-driven batch file capable of evading both MOTW (Mark of the Web) and SmartScreen, along with an unsigned sideloaded executable. We are excited to share that the initial version v0.1 will soon be available, providing red teamers with a powerful tool to assess their organization's defenses.

We plan to release a more comprehensive version focusing on evasive loaders in an upcoming post.

Sideloading Techniques: Advancing the BYOR Tradecraft


Advancing the BYOR Tradecraft:

BYOR offers unique advantages in sideloading. Some innovative techniques to enhance outcomes include:

  • Utilizing Vhdx/iso/img file extensions with BYOR for even better outcome. These file types can further obfuscate the payload making it even harder for security tools to detect.
  • There is a potential for Direct Downloads via Google Chrome(and browsers alike) even without implementing containerization to remove MOTW for payloads. Though a topic that needs its own further discussion, it broadens the attack vector from what we've seen in our R&D. (I guess we will talk about this someday in another blog). Here's a small gist: a strategic approach can be taken where a user clicks a link which subsequently drops two files:
    • Installer.bat - This serves as the BYOR payload bypassing Smartscreen and Windows Defender (WD) in-place.
    • A VBS file tasked with calling the Havoc command and control (C2).

Merging Techniques Using the OCA Framework:

The OCA (Offensive Chains by Astra) framework offers a unique methodology to bypass browser security policies and advanced endpoint defenses. By integrating the above sideloading technique with the OCA framework, we can successfully pwn most of the Endpoint Detection and Response (EDR) backed host. In our tests, we enhanced the sideloading approach using the OCA framework by combining it with various other methods (BYOR gadgeting :D), resulting in a more powerful attack simulation strategy.

At its core, BYOR Gadgeting refers to the strategic use of trusted and legitimate code or functionalities ("gadgets") within reputable software. Inside an organization red teamers can harness these gadgets to simulate potential attack vectors, highlighting that even trustworthy software can be manipulated. This method can be more stealthy and harder to detect because security systems are often designed to detect and block known malicious code or suspicious behaviors but they may not be as effective in spotting the misuse of legitimate functionalities.

BYOR"

Our in-house developed OST called "Offensive Chains by Astra" demonstration can be seen below utilizing BYOR technique: If you are interested in watching the PoC for the BYOR generated payload, you can skip to the end of the article.

For the time being we are only supporting windows, but we plan to release and support other operating system like linux and macOS in near future.

Elevating Red Team Assessments with the OCA Framework

The primary aim is to mimic a real-world attack and emulate the tools, techniques, and procedures (TTPs) of actual threat actors to expose weaknesses. With our innovative OCA (Offensive Chains by Astra), we’re not just meeting the industry standards but taking a leap forward.

The Traditional Approach: Assessing with Known Kill Chains

Conventionally, when assessing an organization's security posture, it's common to simulate known attacks or kill chains. The idea is simple: by understanding how defenses hold up against recognized threats organizations can design strategies to stop them. This simulation results in creating a 'playbook' which serves as a defense manual against such known cyber-attacks.

The OCA Framework: Going Beyond the Known

However, we believe that for truly robust security, we must go beyond what's already known. Here's where the OCA Framework stands out. While it's beneficial to have a playbook against recognized attacks it's equally important to acknowledge that in real-world scenarios, when an organization comes under a targeted attack, these playbooks might not work as expected.

So it's crucial to test infrastructure defenses against the latest cyber offense techniques that are not yet in the limelight. These lesser-known vectors which may not be widely abused yet have the potential to be the next large-scale breach.

Our OST deeply integrate this principle. We prioritize researching such understudied vectors, understanding their potential risks and incorporating them into our simulation techniques.

Further Thoughts on BYOR and Evolving Cybersecurity Threats:

BYOR, as a concept carries vast implications for the world of cybersecurity. It indicates that even software considered safe might have its own flaws. As the digital landscape grows, the list of trusted software also expands which gives attackers more opportunities to exploit. This means that one should evaluate their infrastructure defenses using the most recent cyber-attack techniques including those that are not widely recognized or exploited.

  • Detection Challenges: Defending against such evolving threats is not an easy task. Traditional methods that rely merely on file checks might struggle to counter such sophisticated attacks. What's required is a more holistic approach to detection that doesn't solely rely on historical reputation.
  • OST and Organizational Defense: We have recognized these challenges and have formulated an Offensive Security Tool (OST) called OCA (Offensive Chains by Astra) specifically tailored to exploit these grey areas. However its intent isn't malicious. By enabling red teamers to simulate these advanced threats, we allow blue teams with the necessary knowledge to strengthen their defenses in-place.

Our Commitment to the Community

The trajectory of cybersecurity is determined by the community. Depending on the direction the community wishes to pursue regarding BYOR and similar tactics ... we're determined to share further insights, detection mechanisms and offensive techniques.

The insights we've provided here are just the tip of the iceberg. At P.I.V.O.T Security we possess a wide range of strategies and we're excited to uncover them in our future articles.

In essence, Cybersecurity is about staying ahead of the curve. With challenges like BYOR popping up we also discover new defenses. As we continue this path - teamwork, innovation and knowledge sharing are key. And as always remember:

The best way to predict the threat landscape is to create it.


Proof of Concept (POC) for above infection chain utilizing OCA framework + BYOR technique

BYOR technique POC shared in LinkedIn post utilizing other extensions.

Like what you read? Share with your community.
Sign Up for Our Security Newsletter
Get the information you need conveniently delivered to your email, saving you time and effort.
logo
startupindia
Let’s Connect
We are on a mission to bridge the gap between offense and defense
© 2024 P.I.V.O.T Security Private Limited | Sitemap
youtube
linkedin
twitter