<<

Index

%PDF-1.X magic string, 148 -assembling techniques, 142–144 220 error response code, 32 anti-attaching techniques, for debugger, 360AntiHacker driver, disabling, 22–23 147 anti-emulation techniques, 137–142 anti-exploiting features of operating A systems, 12–13 Abstract Syntax Tree (AST), 20 antivirus evasion techniques, 105–115 access control lists (ACLs) basics, 106–107 danger of errors, 195 writing tool for automatic, 160–162 fi nding invalid, 274–279 antivirus kernels incorrect, 187–194 disabling, 154–156 ActiveX, 201 porting to Unix, 243–244 ActonScript support for emulators, 10 emulators, 304 antivirus killers, 207 for remote exploitation, 303–304 antivirus scanners, 5–6 add-ons. See plug-ins antivirus software AddressOfEntryPoint, in portable analysis with command-line tools, 27–28 executable fi les, 125 auditing, 338 Address Space Layout Randomization automatic of, 239–248 (ASLR), 176, 190–191 auto-updating feature for, 87 exploiting at fi xed addresses, 298–299, basics, 3–4 318 bugs in, 333 administration COPYRIGHTEDpanels, remote attack consumerMATERIAL target audience for, 323 surfaces and, 199–200 core. See kernel Albertini, Ange, 125 determining what is supported, 304–306 Allebrahim, Arish, 188 diversity, 324–325 Alternate Streams (ADS) scanner, 63 exploiting, 339–340 AMD x86_64 CPU features, 7–13 fi nding weaknesses in emulator, 303 history, 4–5 instruction set support, 142–143 limitations, 332 American Fuzzy Lop (AFL), 253 linker in, 58–59 Android DEX fi les, 8 use of, 332–335 anti-analysis, code analyzer disruption, misconceptions about, 6–7 144–146 number of potential bugs in, 65

347 348 Index ■ B–B

privileges for, 341 , 27 recommendations for users, 331–338 applications, 202 recommendations for vendors, 338–344 of strings in plug-in DLLs, 58 and SSL/TLS, 100–101 kernel, 20 trends, 323–329 scancl tool, 21 vulnerabilities in, 343–344 antivirus vendors, improving update B services safety, 342–343 backdoors, 196 API emulations, implementing, 137–140 and confi guration settings, 21–28 API hooks in local exploitation, 270–274 bugs, 188 Bahrain government, 5 undoing, 175 banking details, monitoring home AppInit_Dll registry key, 174 for, 325 applications, memory management basic_avast_client1.py, 33–34 functions, 224 Bayesian networks, and variables, 66–67 archive fi les, exploiting, 302–303 BCCF (Blind Code Coverage Fuzzer), archives, for AV kernel, 9 253–254 ARM emulator, fi nding weaknesses in, using, 254–259 303 bcdedit tool, for kernel debugging, 24 ARP (Address Resolution Protocol) bcf.py tool, 257 spoofi ng, 307, 312 Beanstalkd, for Nightmare, 259 Ettercap tool for, 313 Berkeley Software Distribution (BSD), 143 ARP poisoning, 307 beta signatures, 97 ASLR. See Address Space Layout big companies, targeting, 326–328 Randomization (ASLR) binary audit, 338 Assar, Walied, 147 manual, 219–233 AST (Abstract Syntax Tree), 20 third-party, 340 attack surface of software, 183–194 binary diffi ng products, porting symbols local, 185–187 from, 18 remote, 197–203 binary instrumentation, 113–114 attack vector, emulator as, 301 BinDiff (Zynamics), 59–60 auditing /bin/ls executable, 82 importance for antivirus vendors, 340 Antivirus for , 17, 55–56, products, 338 100–101 checks, for AVG Admin fuzzer for, 237 Console, 199–200 fuzzer output when used with, 242–243 authentication of updates, 308 maximizing code covered by, 257–258 automatic antivirus evasion, writing tool Bitdefender Security Service, 191–192 for, 160–162 blackbox audit, 338 auto-updating feature, for antivirus Blind Code Coverage Fuzzer (BCCF), software, 87 253–254 av_close function, disassembly of call, using, 254–259 32–33 blind trust, 332–336 Core Security for Linux, installing, bloom fi lters, 67–68 150–151 blue screen of death (BSOD), 213 Avast for Linux, 16, 32 Böck, Hanno, 100 minimal class to communicate with, BOPS ( Buffer Overfl ow Protection 33–34 System), 13 security vulnerabilities, 100–101 breakpoints, change in, 62 writing Python bindings for, 29–37 broker, for sandbox processes, 298 .avc extension, 58–59, 119 browser AvcUnpacker.EXE, 119 automatic scanning of fi les retrieved by, AVG 198 installing, 151–152 plug-ins, 201 vulnerabilities in, 199 vulnerabilities in, 335 Index ■ C–C 349

BSOD (blue screen of death), 213 removing old, 343–344 bugs security implications of duplication, 64 in antivirus software, 333 code analyzer, disrupting through anti- API hooking, 188 analysis, 144–146 in disinfection routines, 64 code coverage, maximizing, 252–259 exotic, 188 technique, 174–175 in fi le format parsers, 212 COFF. See Common Object File Format fuzzing to fi nd, 235 (COFF) , 325 command injections, fi ltering based on business logic, 196 shell escape characters, 231–232 bytecode format, 8 command-line tools byte-stream, signatures as, 78 for AV software analysis, 27–28 creating for exporting internal C information, 45–46 CAEEngineDispatch_ for fuzzer automation, 240–243 GetBaseComponent, 41 reverse engineering tools, vs. GUI, 16 CAEHeurScanner class (C++), 167 scanners, 4 callbacks, setting, 42 Common Object File Format (COFF), call graph, 83 62, 121 Capstone Python bindings, for Nightmare, for Kaspersky updates, 58 259 Common Vulnerabilities and Exposures cast-to-function pointer, 282 (CVEs), 65 catalog fi les Comodo Antivirus for antivirus update, 88 ActiveX control, 202 Dr.Web request for LZMA-compressed, C/C++ to interface, 45–55 310–312 check for updates, 97 CBasicFuzzer class, 238 compiling command-line scanner, 51 C/C++ languages creating instance, 40–41 for antivirus kernels, 70–72 GUI, 93 vs. managed languages, 342 heuristic engine of, 166–173 certifi cate, need to verify, 90 installing, 153 CFrameWork_CreateEngine, 41 libMACH32.so library, 134–135 CFrameWork_LoadScanners, 41 library disassembly, 20 Charlie Miller multiple engine, 261 support for JavaScript and VBScript, check_user function, 232 306 checksums (CRCs), 52, 78–79 update protocol used by, 92–100 for update fi le, 311–312 writing C/C++ tools for, 37–55 child processes, broker and, 298 Comodo database, C/C++ interface fi nal ClamAV, 6, 65, 73 version, 55 installing, 150 companies PE parser module, 136 targeting big, 326–328 signatures in, 80 targeting small to medium-sized, 326 starting daemon, 150 complex payloads, 300–307 test fi les from, 250–251 using JavaScript, VBScript, or clamscan tool, 6, 108, 112 ActionScript, 303–304 ClientLibraryName parameter, 200 compressed fi les for plug-ins, 61 client-side exploitation, 297–317 compression bombs, 208–212 sandboxing weaknesses, 297–298 remote, 214 vs. server-side, 317–318 compressors, for AV kernel, 9 cloning GIT Repository, 254 computers, isolating to improve cmdscan (Comodo), 153 protection, 337 main function disassembly, 37–39 confi guration settings, and backdoors, CmRegisterCallback function, 179 21–28 code connection 350 Index ■ D–D

intercepting, 307 VirtualBox setup for, 24–25 to socket from Python prompt, 32–36 debugging symbols, 17–20 to TCP listening services inside VM, 149 importing debugging symbols from consoles, remote attack surfaces and, Linux to, 19 199–200 decoder plug-ins, complexity, 65 container fi le, for plug-ins, 59, 60 decompression, 64 copying compiled fi le to different DeepToad, 81, 83 directory, 51 DefCon conference, “Race to Zero” core of antivirus software contest, 106 porting, 28–29 denial of service attacks, 207–216 . See also kernel local, 208–213 Corkami project, wiki page, 125 remote, 214–215 Corkami wiki, 148 DEP. See Data Execution Prevention (DEP) corpus distillation, 248 Detours hooking engine, 174 CPU emulator, 10 device_handler function, 280–281 CPU instructions, emulating, 140–142 DeviceIoControl function (Windows API), CR0 register, 141–142 273 crashes, in Unix, information about, 240 device names, taking advantage of old CRCs. See checksums (CRCs) features, 140 CRCs (checksums), 52, 78–79 DGBMS2 function, 122–123 for update fi le, 311–312 Diaphora (Open Source IDA plug-in), CreateFilaA function, hooking, 175 20, 59 CreateFilaW function, hooking, 175 directory privileges, fi nding weaknesses CreateInstance function, 40 in, 185–186 CreateProcessInternal function, 174 disinfection routines, bugs in, 64 CreateRemoteThread API call, 277 distorm disassembler, 143 cryptographic hashes, 80 dlclose_framework function, 49 custom checksums (CRCs), 79 DLLs. See Dynamic Link Libraries (DLLs) CVEs (Common Vulnerabilities and DNS record, attacker change of, 89 Exposures), 65 DNS spoofi ng, 312 cyber-attacks, 323 Ettercap tool for, 313 matching attack technique with target, downloaded update fi les, verifi cation 324–326 process, 88 Cyclic Redundancy Check (CRC) DR0 x86 register, eforts to change, 141 algorithm, 78–79, 105 DrCov, 254, 255 drweb32.fl g fi le, 309 D Dr.Web antivirus products, 91, 129 Dabah, Gil, 143 launching attack against update services, database 312 C/C++ interface fi nal version, 55 Python exploit, 314–316 for F-Secure, 221 request for LZMA-compressed catalog, of MD5 hashes, fi lter for, 67–68 310–312 signatures for virus database fi les, 343 update system exploitation, 308 Data Execution Prevention (DEP), 190–191 drweb-escan.real binary, 189 exploiting at fi xed addresses, 298–300, dual extensions, 173 318 dynamic analysis, 235–267 dd command, 209 fuzzing, 235–265 DEB packages, installing in Debian-based of reverse engineering, 20 Linux, 228 dynamic evasion techniques, 105 debugging dynamic heuristic engine, 66, 165, 173–180 anti-attaching techniques for, 147 Dynamic Link Libraries (DLLs) kernel, 23–25 injecting, 276 tricks for, 20–28 plug-ins as, 58 user-mode processes with kernel-mode dynamic loading, for antivirus plug-ins, debugger, 25–27 59–60 Index ■ E–F 351

DynamoRIO (binary instrumentation for fuzzy hashing signature, 81 toolkit), 113, 254, 255 “Fast Library Identifi cation and for Nightmare, 260 Recognition Technology” (IDA), 220 Ferguson, Paul, 106–107 E fi le format parsers, 198 EasyHook hooking engine, 174 for binary audit, 220–228 egas tool, 253 bugs in, 212, 215 EICAR (European Institute for fi le formats, 64–65 Anti-Virus Research), 78 antivirus software support of, 118 eicar.com.txt testing fi le, 151 confusion from, 148 Electronic Code Book (ECB) mode, 200 evasion tips for specifi c, 124–131 ELF (Executable and Linkable Format), 301 miscellaneous, and AV kernel, 11 email client, compression bombs and, 214 taking advantages for evasion, 136–137 email credentials, theft of, 4 fi le infector, 336 EMET. See Enhanced Mitigation fi le length, of portable executable fi les, 126 Experience Toolkit (EMET) fi le privileges, fi nding weaknesses in, Emu_ConnectNamedPipe function, 135 185–186 emulators, 10–11, 73–74, 301–302 fi les limitations, 302 disinfection routines, 199 encrypted fi les for plug-ins, 61 splitting for determining malware encryption keys, static, 200 detection, 107–112 engineering, vs. security, 339 fi le size limits, and scanner evasion, err local variable, code checks on, 44 133–134 eScan Antivirus for Linux, 228 FinFisher, 5 installing DEB packages, 228 fi ngerprints, 215 eScan Malware Admin software, 189 emulators for evading scanners, 134–136 escape function, 127 fi rewalls, 4, 11–12, 200–201 Ettercap tool, 312, 313 malware, 92 European Institute for Computer Anti- FLIRT (“Fast Library Identifi cation and Virus Research (EICAR), antivirus Recognition Technology”), 220 testing fi le, 78 fl ow graph, 83 eval function, emulator triggered by, FlyStudio malware 306–307 disassembly from, 145 EVP_VerifyFinal function, 308 fl ow graph, 146 Executable and Linkable Format (ELF), FMAlloc function 301 analysis, 225 executables determining unsanitized input, 227 graph-based hashes for, 83–85 fm library (fm4av.dll), 17, 18 malware as packed, 10 F-Prot for Linux, installing, 152–153 signing, 92 frame-based functions, prologue of, 175 exotic bugs, 188 FreeLibrary function, 177 expert system, 166 F-Secure Anti-Virus, 6, 17, 19, 26, 202, expired certifi cates, 91 220–228 exploitation. See local exploitation; remote InnoSetup installer fi les analyzer code, exploitation 227 exploit-db.com website, 213 functions Exploit.HTML.IFrame-6 malware, 108, 117 forward declarations of, 50–51 Exploit.MSWord.CVE-2010- 3333.cp fi le, human-readable names for, 196 121–122 fuzzer (fuzz-testing tool), 28 extensions lists, checking, 172–173 based on protocol format, 36 fi nding template fi les, 250–252 output, 242–243 F problems, 247–248 false positive, 9, 66 template fi les for, 248–249 check of known, 169 fuzzers/bcf.cfg fi le, 255 for CRC32hash, 79 fuzzing, 235–265 352 Index ■ G–I

automatic of antivirus products, 239–248 home users, targeting, Gika basics, 236 hooks command-line tools for, 238–243 for dynamic heuristic engine, 173 by developers, 340–341 kernel-land, 178–179 Ikarus command-line scanner, 246–247 undoing, 175 results, 264 userland, 173–175 simple, 237–239 Host Intrusion Prevention Systems (HIPS), statistics, 264–265 165–166, 173 with Wine, 244–247 bypassing userland, 176–178 fuzz method, 238 HPKP (HTTP Public Key Pinning), 100 fuzzy hashing signatures, 81–83 HTTP (Hypertext Transfer Protocol) fuzzy logic-based signatures, 9 for downloading signatures, 88 for downloading updates, 89–90 G HTTP Public Key Pinning (HPKP), 100 g_Func_0056 function, 273 HTTPS (Hypertext Transfer Protocol GCC, 20 Secure) GCluster, 84–85 check for malware inside, 100 GDB, 15 for downloading signatures, 88 generic routines, as plug-ins, 64 for downloading updates, 89–90 getopt function, 38 human-readable names, for functions, 196 GIT Repository, cloning, 254 Global Object Table (GOT), 224–225 I , 90 i386.DEB package fi le, 151 government networks icacls command-line tool, 185 spying on, 5 IDA targeting, 326–328 “Fast Library Identifi cation and governments, targets of, 327–328 Recognition Technology,” 220 graphical user interface (GUI) scanners, 4 Functions window, 224 grep tool, for searching for patterns, 304 and program jumps, 144–146 Guest Additions, 149 IDA database, scanner name enumerated Guest Virtual Machines (GVMs), 61, 71 to, 54–55 GUI tools, vs. command-line for reverse IDA dissassembler, 15, 196 engineering, 16 fi le analysis with, 30–32