OPSEC Fundamentals For Remote Red Teams
OPSEC Fundamentals For Remote Red Teams
OPSEC Fundamentals For Remote Red Teams
Fundamentals for
Remote Red Teams
Who am I?
• Michael Allen
• Also go by Wh1t3Rh1n0 or just "Rhino"
• Professional penetration tester/red teamer since 2014
• Security Analyst at Black Hills Information Security since 2019
• Certifications: OSCE, MLSE, CISSP, ...
• No formal training in OPSEC
• Still make lots of mistakes. Just sharing some lessons I've learned.
What is this talk about?
• OPSEC Fundamentals for Remote Red Teams
What is this talk about?
• OPSEC Fundamentals for Remote Red Teams
• "Operations security (OPSEC) is a process that
identifies critical information to determine if
friendly actions can be observed by enemy
intelligence, determines if information obtained
by adversaries could be interpreted to be useful
to them, and then executes selected measures
that eliminate or reduce adversary exploitation
of friendly critical information."
-- Wikipedia (highlighting added)
What is this talk about?
• OPSEC Fundamentals for Remote Red Teams
• Red Team Exercises
• Perform a cyberattack against the target organization.
• Attack success demonstrates business impact. Examples:
• Theft of intellectual property/confidential data
• Unauthorized financial transactions
• Unauthorized access to systems, accounts, or other assets
• Unannounced to the organization's security team
• The security team (Blue Team) of the target organization actively identifies
and responds to suspicious activity - just like a real attack.
What is this talk about?
• OPSEC Fundamentals for Remote Red Teams
• OPSEC for remote red teams will be different than for teams that are on-site.
• No physical or wireless security components.
• Not plugging any devices into the network.
• Other limitations:
• This talk will focus on red team OPSEC up to the initial breach.
• Additional OPSEC considerations are introduced once the red team starts
post-exploitation and lateral movement in the target environment.
Why is OPSEC important for red teams?
• Indicators of suspicious activity are well known
• Open sharing of information is how InfoSec works
• Modern blue teams have many sources to inform them of suspicious
activity:
• Logs on Internet-facing systems/services
• Logging on systems and connections that make egress from the internal
network (e.g. workstations)
• Various of third-party "threat intelligence" services
• Analysis and correllation of information collected from those sources
Red doesn't want blue to connect the dots
• Each time the red team interacts with
the target organization, it leaves a "dot".
Red doesn't want blue to connect the dots
• Each time the red team interacts with
the target organization, it leaves a "dot".
• With enough dots, the blue team can
identify red team tools and
infrastructure, and prevent attacks
before they occur.
• This is especially frustrating if the blue
team connects the dots before the red
team knows it.
Possible countermeasures
How can the red team keep the blue team
from connecting the dots?
Possible countermeasures
How can the red team keep the blue team
from connecting the dots?
• Edge ------->
User-Agent header
• Example: Nmap default User-Agent
User-Agent header
• Example: WPScan default User-Agent
User-Agent header
• Example: EyeWitness default User-Agent
Changing the default User-Agent
• Pick a user agent that isn't the default value for a hacking tool
• Consider matching with the type and/or amount of traffic the site receives
• You may not want to use the same user agent string for every tool
• Examples:
• Google Chrome on Windows 10
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/87.0.4280.88 Safari/537.36
• Inspect each source IP for "tells" and build your own vetted list
Make your VPN connection fail safe
• If your VPN connection drops unexpectedly, subsequent connections
may come from your real IP address.
• Not ideal in the middle of suspicious activity (e.g. password spraying)
openvpn --script-security 2 --down vpn-down.sh --config <OPEN VPN FILE>
#!/bin/bash
echo 'Disabling network interfaces...'
systemctl stop network-manager
killall -9 dhclient
for i in $(ifconfig | grep -iEo '^[a-z0-9]+:' | grep -v '^lo:$' | cut -d ':' -f 1)
do
ifconfig $i 0.0.0.0 down
done
3. Other third-party services
Third-party services
• Assess whether red team actions are likely to violate TOS
• Modify identity, credit card number, and source IP for repeat sign-ups
• "Identity": Name, email address, billing address, phone number
• Assess whether your registration information is likely to be exposed
• Example: Domain registration/WHOIS info
• Assess whether use of the same account across multiple projects is
likely to leak information about the red team or its customers
• Can the resource owner be identified by outsiders?
• Can relationships between multiple resources be associated with each other?
• Is there a reasonable level of trust with the resource provider?
Domain names
• Avoid typosquatting the target domain or company name
• Subdomains may be detected too
Domain names
• Use private registration/WHOIS privacy
• Make sure it is enabled at the time of registration
• Consider fake registration information?
• One red team action per domain name - same as source IPs
• Domain A sends email
• Domain B serves payload files
• Domain C receives C2 callbacks
• ...
SSL/TLS certificates and CAs
• Watch out for data leaks in certificate transparency logs
• Customer names (e.g. in subdomain names)
• Email addresses
certbot --apache --register-unsafely-without-email
• Indicator: TCP Port 50050 - Default Cobalt Strike Team Server port
• Don't expose services to the Internet that aren't required
• Use SSH port forwarding for access from the red team
• Indicator: Cobalt Strike DNS server responds to requests with IP 0.0.0.0
• Change all the default settings on hacking tools that listen on an Internet-facing port
• Indicator: Web root: 404 Not Found, no content, Content-Type: text/plain
• Default response without content explicitly hosted at / or a web redirector.
• Indicator: JA3S service fingerprinting
• Use common web services (Apache, Nginx) to redirect HTTP/S traffic to servers run by
hacking tools
* https://blog.cobaltstrike.com/2019/02/19/cobalt-strike-team-server-population-study/
Executable payloads - Metadata
• Commonly used by red teams to gather names, user names, and
other details of the target organization
• Can also be used against the red team
• Common phishing payloads: MS Office documents, PDF, others...
Executable payload testing
1. Make sure the payload works - execute in the "Attack" VM
2. Test keying and antivirus-bypass
a. Make Test VM match the target environment (domain/host/user names)
b. Install and update relevant defensive software on the Test VM - Online
c. Disconnect the Test VM from the Internet
d. Take a snapshot
e. Execute the payload file to confirm keying and AV-bypass are working
3. Revert Test VM to the snapshot created in step "d", connect to the
Internet, and perform final testing
Payload hosting
• Filter incoming web requests by User-Agent
• Redirect User-Agents: "bot", "google", "crawl", "search", "curl", "wget"
• Stage 1 redirect with JavaScript - may help to weed out non-browser traffic
• Stage 2 redirect - server-side scripts/mod_rewrite rules*
• Desktop browsers -> payload file download
• Mobile browsers -> credential harvesting page
• Redirect all others to content that supports the domain's
categorization
* https://bluescreenofjeff.com/2016-04-05-operating-system-based-redirection-with-apache-mod_rewrite/
5. Testing new tools
Vet the tool
• Read the source code
• Understand the configuration options
• Run the tool in a VM
• Observe the traffic the tool generates:
• Packet capture - WireShark
• Intercepting proxy - Burp Suite
• Simulated target - Ncat/Netcat or target application/service
Vet the tool - Goals:
1. Confirm that the tool isn't harming you.
2. Confirm that how the tool/attack looks from the defender
perspective isn't suspicious.
3. Confirm that the attack looks believable from the perspective of the
target user.
Example: Evilginx
Me, running EvilGinx for the first time:
1. Download the latest precompiled
release from GitHub
2. Configure a phishlet to target
Office 365
3. Generate a "lure" (landing URL)
4. Visit the lure in the browser
5. Everything looks ok -->
Me, pasting the lure URL into Google Chat:
• Everything does NOT look ok
Me, pasting the lure URL into Google Chat:
• Everything does NOT look ok
• Easy fix:
config redirect_url "https://www.office.com"
• Lesson learned:
• Read the source code
• Understand the configuration options
But wait, there's more...
Inspecting Evilginx traffic with Burp:
Removing the X-Evilginx header
• No settings found to change/disable the header
• No mention in the documentation
• No references found when searching the source-code
Looking more closelier...
Final result
1. Remove all source code lines that set the X-Evilginx header
2. Compile the modified source code
3. Inspect the outgoing traffic again
4. No more X-Evilginx
header! :)
• Lesson learned:
Always inspect the
network traffic