FreshRSS

πŸ”’
❌ Secure Planet Training Courses Updated For 2019 - Click Here
There are new available articles, click to refresh the page.
Before yesterdayYour RSS feeds

LOLSpoof - An Interactive Shell To Spoof Some LOLBins Command Line

By: Zion3R


LOLSpoof is a an interactive shell program that automatically spoof the command line arguments of the spawned process. Just call your incriminate-looking command line LOLBin (e.g. powershell -w hidden -enc ZwBlAHQALQBwAHIAbwBjAGUA....) and LOLSpoof will ensure that the process creation telemetry appears legitimate and clear.


Why

Process command line is a very monitored telemetry, being thoroughly inspected by AV/EDRs, SOC analysts or threat hunters.

How

  1. Prepares the spoofed command line out of the real one: lolbin.exe " " * sizeof(real arguments)
  2. Spawns that suspended LOLBin with the spoofed command line
  3. Gets the remote PEB address
  4. Gets the address of RTL_USER_PROCESS_PARAMETERS struct
  5. Gets the address of the command line unicode buffer
  6. Overrides the fake command line with the real one
  7. Resumes the main thread

Opsec considerations

Although this simple technique helps to bypass command line detection, it may introduce other suspicious telemetry: 1. Creation of suspended process 2. The new process has trailing spaces (but it's really easy to make it a repeated character or even random data instead) 3. Write to the spawned process with WriteProcessMemory

Build

Built with Nim 1.6.12 (compiling with Nim 2.X yields errors!)

nimble install winim

Known issue

Programs that clear or change the previous printed console messages (such as timeout.exe 10) breaks the program. when such commands are employed, you'll need to restart the console. Don't know how to fix that, open to suggestions.



Zero-Day Alert: Critical Palo Alto Networks PAN-OS Flaw Under Active Attack

Palo Alto Networks is warning that a critical flaw impacting PAN-OS software used in its GlobalProtect gateways is being actively exploited in the wild. Tracked as CVE-2024-3400, the issue has a CVSS score of 10.0, indicating maximum severity. "A command injection vulnerability in the GlobalProtect feature of Palo Alto Networks PAN-OS software for specific PAN-OS versions and distinct

New BIFROSE Linux Malware Variant Using Deceptive VMware Domain for Evasion

Cybersecurity researchers have discovered a new Linux variant of a remote access trojan (RAT) called BIFROSE (aka Bifrost) that uses a deceptive domain mimicking VMware. "This latest version of Bifrost aims to bypass security measures and compromise targeted systems," Palo Alto Networks Unit 42 researchers Anmol Maurya and Siddharth Sharma said. BIFROSE is one of the long-standing

Trawler - PowerShell Script To Help Incident Responders Discover Adversary Persistence Mechanisms

By: Zion3R


Dredging Windows for Persistence

What is it?

Trawler is a PowerShell script designed to help Incident Responders discover potential indicators of compromise on Windows hosts, primarily focused on persistence mechanisms including Scheduled Tasks, Services, Registry Modifications, Startup Items, Binary Modifications and more.

Currently, trawler can detect most of the persistence techniques specifically called out by MITRE and Atomic Red Team with more detections being added on a regular basis.


Main Features

  • Scanning Windows OS for a variety of persistence techniques (Listed below)
  • CSV Output with MITRE Technique and Investigation Jumpstart Metadata
  • Analysis and Remediation Guidance Documentation (https://github.com/joeavanzato/Trawler/wiki/Analysis-and-Remediation-Guidance)
  • Dynamic Risk Assignment for each detection
  • Built-in Allow Lists for common Windows configurations spanning Windows 10/Server 2012|2016|2019|2022 to reduce noise
  • Capture persistence metadata from 'golden' enterprise image for use as a dynamic allow-list at runtime
  • Analyze mounted disk images via drive re-targeting

How do I use it?

Just download and run trawler.ps1 from an Administrative PowerShell/cmd prompt - any detections will be displayed in the console as well as written to a CSV ('detections.csv') in the current working directory. The generated CSV will contain Detection Name, Source, Risk, Metadata and the relevant MITRE Technique.

Or use this one-liner from an Administrative PowerShell terminal:

iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/joeavanzato/Trawler/main/trawler.ps1'))

Certain detections have allow-lists built-in to help remove noise from default Windows configurations (10/2016/2019/2022) - expected Scheduled Tasks, Services, etc. Of course, it is always possible for attackers to hijack these directly and masquerade with great detail as a default OS process - take care to use multiple forms of analysis and detection when dealing with skillful adversaries.

If you have examples or ideas for additional detections, please feel free to submit an Issue or PR with relevant technical details/references - the code-base is a little messy right now and will be cleaned up over time.

Additionally, if you identify obvious false positives, please let me know by opening an issue or PR on GitHub! The obvious culprits for this will be non-standard COMs, Services or Tasks.

CLI Parameters

-scanoptions : Tab-through possible detections and select a sub-set using comma-delimited terms (eg. .\trawler.ps1 -scanoptions Services,Processes)
-hide : Suppress Detection output to console
-snapshot : Capture a "persistence snapshot" of the current system, defaulting to "$PSScriptRoot\snapshot.csv"
-snapshotpath : Define a custom file-path for saving snapshot output to.
-outpath : Define a custom file-path for saving detection output to (defaults to "$PSScriptRoot\detections.csv")
-loadsnapshot : Define the path for an existing snapshot file to load as an allow-list reference
-drivetarget : Define the variable for a mounted target drive (eg. .\trawler.ps1 -targetdrive "D:") - using this alone leads to an 'assumed homedrive' variable of C: for analysis purposes

What separates this from PersistenceSniper?

PersistenceSniper is an awesome tool - I've used it heavily in the past - but there are a few key points that differentiate these utilities

  • trawler is (currently) a local utility - it would be pretty straight-forward to wrap it in a loop and use WinRM/PowerShell Sessions to execute it on remote hosts though
  • trawler implements allow-listing for many 'noisy' detections to help remove expected detections from default configurations of Windows (10/2016/2019/2022) and these are constantly being updated
    • PersistenceSniper (for the most part) does not contain any type of allow-listing - therefore, there is more noise generated when considering items such as Services, Scheduled Tasks, general COM DLL scanning, etc.
  • trawler's output is much more simplified - Name, Risk, Source, MITRE Technique and Metadata are the only items provided for each detection to help analysts jump-start their persistence hunting efforts
  • Regex is used in many checks to help detect 'suspicious' keywords or patterns in various critical areas including scanned file contents, registry values, etc.
  • trawler supports 'snapshotting' a system (for example, an enterprise golden image) then using the generated snapshot as an allow-list to reduce noise.
  • trawler supports 'drive-retargeting' to check dead-boxes mounted to an analysis machine.

Overall, these tools are extremely similar but approach the problem from slightly different angles - PersistenceSniper provides all information back to the analyst for review while Trawler tries to limit what is returned to only results that are likely to be potential adversary persistence mechanisms. As such, there is a possibility for false-negatives with trawler if an adversary completely mimics an allow-listed item.

Tuning to your environment

Trawler supports loading an allow-list from a 'snapshot' - to do this requires two steps.

  1. Run '.\trawler.ps1 -snapshot' on a "Golden Image" representing the servers in your environment - once complete, in addition to the standard 'detections.csv' a file named 'snapshots.csv' will be generated
  2. This file can then be used as input to trawler when running on other hosts and the data will be loaded dynamically as an allow-list for each appropriate detection
    1. '.\trawler.ps1' -loadsnapshot "path\to\snapshot.csv"

That's it - all relevant detections will then draw from the snapshot file as an allow-list to reduce noise and identify any potential changes to the base image that may have occurred.

(Allow-listing is implemented for most of the checks but not all - still being actively implemented)

Drive ReTargeting

Often during an investigation, analysts may end up mounting a new drive that represents an imaged Windows device - Trawler now partially supports scanning these mounted drives through the use of the '-drivetarget' parameter.

At runtime, Trawler will re-target temporary script-level variables for use in checking file-based artifacts and also will attempt to load relevant Registry Hives (HKLM\SOFTWARE, HKLM\SYSTEM, NTUSER.DATs, USRCLASS.DATs) underneath HKLM/HKU and prefixed by 'ANALYSIS_'. Trawler will also attempt to unload these temporarily loaded hives upon script completion.

As an example, if you have an image mounted at a location such as 'F:\Test' which contains the NTFS file system ('F:\Test\Windows', 'F:\Test\User', etc) then you can invoke trawler like below;

.\trawler.ps1 -drivetarget "F:\Test"

Please note that since trawler attempts to load the registry hive files from the drive in question, mapping a UNC path to a live remote device will NOT work as those files will not be accessible due to system locks. I am working on an approach which will handle live remote devices, stay tuned.

What is not inspected when drive retargeting?

  • Running Processes
  • Network Connections
  • 'Phantom' DLLs
  • WMI Consumers (Being worked on)
  • BITS Jobs (Being worked on)
  • Certificate Parsing (Being worked on)

Most other checks will function fine because they are based entirely on reading registry hives or file-based artifacts (or can be converted to do so, such as directly reading Task XML as opposed to using built-in command-lets.)

Any limitations in checks when doing drive-retargeting will be discussed more fully in the GitHub Wiki.

Example ImagesΒ 



Β 

What is inspected?

  • Scheduled Tasks
  • Users
  • Services
  • Running Processes
  • Network Connections
  • WMI Event Consumers (CommandLine/Script)
  • Startup Item Discovery
  • BITS Jobs Discovery
  • Windows Accessibility Feature Modifications
  • PowerShell Profile Existence
  • Office Addins from Trusted Locations
  • SilentProcessExit Monitoring
  • Winlogon Helper DLL Hijacking
  • Image File Execution Option Hijacking
  • RDP Shadowing
  • UAC Setting for Remote Sessions
  • Print Monitor DLLs
  • LSA Security and Authentication Package Hijacking
  • Time Provider DLLs
  • Print Processor DLLs
  • Boot/Logon Active Setup
  • User Initialization Logon Script Hijacking
  • ScreenSaver Executable Hijacking
  • Netsh DLLs
  • AppCert DLLs
  • AppInit DLLs
  • Application Shimming
  • COM Object Hijacking
  • LSA Notification Hijacking
  • 'Office test' Usage
  • Office GlobalDotName Usage
  • Terminal Services DLL Hijacking
  • Autodial DLL Hijacking
  • Command AutoRun Processor Abuse
  • Outlook OTM Hijacking
  • Trust Provider Hijacking
  • LNK Target Scanning (Suspicious Terms, Multiple Extensions, Multiple EXEs)
  • 'Phantom' Windows DLL Names loaded into running process (eg. un-signed WptsExtensions.dll)
  • Scanning Critical OS Directories for Unsigned EXEs/DLLs
  • Un-Quoted Service Path Hijacking
  • PATH Binary Hijacking
  • Common File Association Hijacks and Suspicious Keywords
  • Suspicious Certificate Hunting
  • GPO Script Discovery/Scanning
  • NLP Development Platform DLL Overrides
  • AeDebug/.NET/Script/Process/WER Debug Replacements
  • Explorer 'Load'
  • Windows Terminal startOnUserLogin Hijacks
  • App Path Mismatches
  • Service DLL/ImagePath Mismatches
  • GPO Extension DLLs
  • Potential COM Hijacks
  • Non-Standard LSA Extensions
  • DNSServerLevelPluginDll Presence
  • Explorer\MyComputer Utility Hijack
  • Terminal Services InitialProgram Check
  • RDP Startup Programs
  • Microsoft Telemetry Commands
  • Non-Standard AMSI Providers
  • Internet Settings LUI Error DLL
  • PeerDist\Extension DLL
  • ErrorHandler.CMD Checks
  • Built-In Diagnostics DLL
  • MiniDumpAuxiliary DLLs
  • KnownManagedDebugger DLLs
  • WOW64 Compatibility Layer DLLs
  • EventViewer MSC Hijack
  • Uninstall Strings Scan
  • PolicyManager DLLs
  • SEMgr Wallet DLL
  • WER Runtime Exception Handlers
  • HTML Help (.CHM)
  • Remote Access Tool Artifacts (Files, Directories, Registry Keys)
  • ContextMenuHandler DLL Checks
  • Office AI.exe Presence
  • Notepad++ Plugins
  • MSDTC Registry Hijacks
  • Narrator DLL Hijack (MSTTSLocEnUS.DLL)
  • Suspicious File Location Checks

TODO

MITRE Techniques Evaluated

Please be aware that some of these are (of course) more detected than others - for example, we are not detecting all possible registry modifications but rather inspecting certain keys for obvious changes and using the generic MITRE technique "Modify Registry" where no other technique is applicable. For other items such as COM hijacking, we are inspecting all entries in the relevant registry section, checking against 'known-good' patterns and bubbling up unknown or mismatched values, resulting in a much more complete detection surface for that particular technique.

  • T1037: Boot or Logon Initialization Scripts
  • T1037.001: Boot or Logon Initialization Scripts: Logon Script (Windows)
  • T1037.005: Boot or Logon Initialization Scripts: Startup Items
  • T1055.001: Process Injection: Dynamic-link Library Injection
  • T1059: Command and Scripting Interpreter
  • T1071: Application Layer Protocol
  • T1098: Account Manipulation
  • T1112: Modify Registry
  • T1053: Scheduled Task/Job
  • T1136: Create Account
  • T1137.001: Office Application Office Template Macros
  • T1137.002: Office Application Startup: Office Test
  • T1137.006: Office Application Startup: Add-ins
  • T1197: BITS Jobs
  • T1505.005: Server Software Component: Terminal Services DLL
  • T1543.003: Create or Modify System Process: Windows Service
  • T1546: Event Triggered Execution
  • T1546.001: Event Triggered Execution: Change Default File Association
  • T1546.002: Event Triggered Execution: Screensaver
  • T1546.003: Event Triggered Execution: Windows Management Instrumentation Event Subscription
  • T1546.007: Event Triggered Execution: Netsh Helper DLL
  • T1546.008: Event Triggered Execution: Accessibility Features
  • T1546.009: Event Triggered Execution: AppCert DLLs
  • T1546.010: Event Triggered Execution: AppInit DLLs
  • T1546.011: Event Triggered Execution: Application Shimming
  • T1546.012: Event Triggered Execution: Image File Execution Options Injection
  • T1546.013: Event Triggered Execution: PowerShell Profile
  • T1546.015: Event Triggered Execution: Component Object Model Hijacking
  • T1547.002: Boot or Logon Autostart Execution: Authentication Packages
  • T1547.003: Boot or Logon Autostart Execution: Time Providers
  • T1547.004: Boot or Logon Autostart Execution: Winlogon Helper DLL
  • T1547.005: Boot or Logon Autostart Execution: Security Support Provider
  • T1547.009: Boot or Logon Autostart Execution: Shortcut Modification
  • T1547.012: Boot or Logon Autostart Execution: Print Processors
  • T1547.014: Boot or Logon Autostart Execution: Active Setup
  • T1553: Subvert Trust Controls
  • T1553.004: Subvert Trust Controls: Install Root Certificate
  • T1556.002: Modify Authentication Process: Password Filter DLL
  • T1574: Hijack Execution Flow
  • T1574.007: Hijack Execution Flow: Path Interception by PATH Environment Variable
  • T1574.009: Hijack Execution Flow: Path Interception by Unquoted Path

References

This tool would not exist without the amazing InfoSec community - the most notable references I used are provided below.

More References



Mangle - Tool That Manipulates Aspects Of Compiled Executables (.Exe Or DLL) To Avoid Detection From EDRs


Authored By Tyl0us

Featured at Source Zero Con 2022

Mangle is a tool that manipulates aspects of compiled executables (.exe or DLL). Mangle can remove known Indicators of Compromise (IoC) based strings and replace them with random characters, change the file by inflating the size to avoid EDRs, and can clone code-signing certs from legitimate files. In doing so, Mangle helps loaders evade on-disk and in-memory scanners.


Contributing

Mangle was developed in Golang.

Install

The first step, as always, is to clone the repo. Before you compile Mangle, you'll need to install the dependencies. To install them, run the following commands:

go get github.com/Binject/debug/pe

Then build it

go build Mangle.go

Important

While Mangle is written in Golang, a lot of the features are designed to work on executable files from other languages. At the time of release, the only feature that is Golang specific is the string manipulation part.

Usage

./mangle -h

_____ .__
/ \ _____ ____ ____ | | ____
/ \ / \\__ \ / \ / ___\| | _/ __ \
/ Y \/ __ \| | \/ /_/ > |_\ ___/
\____|__ (____ /___| /\___ /|____/\___ >
\/ \/ \//_____/ \/
(@Tyl0us)
Usage of ./Mangle:
-C string
Path to the file containing the certificate you want to clone
-I string
Path to the orginal file
-M Edit the PE file to strip out Go indicators
-O string
The new file name
-S int
How many MBs to increase the file by

Strings

Mangle takes the input executable and looks for known strings that security products look for or alert on. These strings alone are not the sole point of detection. Often, these strings are in conjunction with other data points and pieces of telemetry for detection and prevention. Mangle finds these known strings and replaces the hex values with random ones to remove them. IMPORTANT: Mangle replaces the exact size of the strings it’s manipulating. It doesn’t add any more or any less, as this would create misalignments and instabilities in the file. Mangle does this using the -M command-line option.

Currently, Mangle only does Golang files but as time goes on other languages will be added. If you know of any for other languages, please open an issue ticket and submit them.

Before

Β 

After


Inflate

Pretty much all EDRs can’t scan both on disk or in memory files beyond a certain size. This simply stems from the fact that large files take longer to review, scan, or monitor. EDRs do not want to impact performance by slowing down the user's productivity. Mangle inflates files by creating a padding of Null bytes (Zeros) at the end of the file. This ensures that nothing inside the file is impacted. To inflate an executable, use the -S command-line option along with the number of bytes you want to add to the file. Large payloads are really not an issue anymore with how fast Internet speeds are, that being said, it's not recommended to make a 2 gig file.

Based on test cases across numerous userland and kernel EDRs, it is recommended to increase the size by either 95-100 megabytes. Because vendors do not check large files, the activity goes unnoticed, resulting in the successful execution of shellcode.

Example:


Certificate

Mangle also contains the ability to take the full chain and all attributes from a legitimate code-signing certificate from a file and copy it onto another file. This includes the signing date, counter signatures, and other measurable attributes.

While this feature may sound similar to another tool I developed, Limelighter, the major difference between the two is that Limelighter makes a fake certificate based off a domain and signs it with the current date and time, versus using valid attributes where the timestamp is taken from when the original file. This option can use DLL or .exe files to copy using the -C command-line option, along with the path to the file you want to copy the certificate from.


Credit

  • Special thanks to Jessica of SuperNovasStore for creating the logo.
  • Special thanks to Binject for his repo


❌