Practical-Malware-Analysis Index.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
INDEX Symbols and Numbers administrator privileges, for malware launchers, 254 ! (bang symbol), 305 Adobe Reader -- operation, 112 CVE-2010-0188 critical % operation, 112 vulnerability, 424 % symbol, 423 overflow in, 705 | (pipe symbol), in Snort, 304 ADS (Alternate Data Streams) ++ operation, 112 010 Editor, 468 feature, 139 32-bit applications, WOW64 and, 448 Advanced Encryption Standard 32-bit rotate-right-additive hash, 418 (AES), 618 64-bit malware, 441–449 decrypting, 625–626 clues to functionality, 448 advapi32.dll, 17 labs, 450–451 imports from, 20, 480, 481 solutions, 723–732 obtaining handle to, 237 advertisements, pop-up, 560–561 A AES (Advanced Encryption Standard), 618 A, at end of Windows function decrypting, 625–626 name, 17 Agobot, 376 absolute addresses, 443 air-gapped networks, 29 vs. relative addresses, in OllyDbg, _alloca_probe function, 522 184–185 alphabetic encoding, shellcode abstraction levels, in x86 disassembly, decoder with, 697 66–67 Alternate Data Streams (ADS) accept function, 143, 144, 454 feature, 139 access token, 246 ALU (arithmetic logic unit), 68 accuracy, vs. expediency, 304 AMD64 architecture, 441 active window, logging, 239 “Analysis of the Intel Pentium’s ADD encoding algorithm, 276 Ability to Support a Secure add instruction, 74, 349 Virtual Machine Monitor” AddCodeXref function (IDC), 342 (Robin and Irvine), 373 address space, loading executable AND logical operator, in x86 into another process’s, 595 architecture, 75 address space layout randomization anti-debugging, 351–366 (ASLR), 184 checks, 656 AddressOfNameOrdinals array, 416 defeating techniques, 660 AddressOfNames array, 416 labs, 367–368 AdjustTokenPrivileges function, 246, solutions, 655–669 247, 454, 730 Practical Malware Analysis © 2012 Michael Sikorski and Andrew Honig anti-debugging, continued labs, 381–382 NTGlobalFlag flag, 659–660 solutions, 670–684 PhantOm protection from checks, process replacement, 683–684 658, 659 tweaking settings, 379–380 ProcessHeap flag, 658–659 VMware artifacts, 370–373 timing checks, 665–669 vulnerable instructions, 373–379, GetTickCount function, 668–669 678–679 with QueryPerformanceCounter, No Pill technique, 375 667–668 querying I/O communication rdtsc function, 669 port, 375–377 anti-disassembly, 327–349 Red Pill anti-VM technique, basics, 328–329 374–375 defeating disassembly algorithms, antivirus programs, and kernel 329–334 patching, 227 flow-oriented disassembly, antivirus scanning, 10 331–334 antivirus signatures, scan against, 478 linear disassembly, 329–331 Anubis, 40 false conditional branch, 336, 645, ApateDNS, 51–52, 57, 465, 483, 485 647, 653 malware DNS requests and, 489 labs, 350 APC (asynchronous procedure solutions, 645–655 call), 263 malware awareness of APC injection, 262–265 debugger, 351 AppInit_DLLs, 241–242, 572 manually repaired code, 648–649 for persistence, 575 obscuring flow control, 340–346 applications, access to device adding missing code cross- objects, 206 references in IDA Pro, 342 arguments in malware, OllyDbg to function pointer problem, debug, 532 340–341 arithmetic instruction, 74–76 misusing structured exception arithmetic logic unit (ALU), 68 handlers, 344–346 arithmetic operations return pointer abuse, 342–343 disassembly, 112–113 signs of, 645–646 in WinDbg, 211 techniques, 334–340 arrays, disassembling, 127–128 impossible disassembly, 337–340 arrows window, in IDA Pro, 90 jump instruction with constant The Art of Assembly Language condition, 336 (Hyde), 68 jump instructions with same ASCII strings, 11 target, 334–335 loading on stack, 724–725 NOP-ing out instructions with ASLR (address space layout IDA Pro, 340 randomization), 184 thwarting stack-frame analysis, ASPack, 398 347–349 assembly code, for process anti-virtual machine (anti-VM) tech- replacement, 258 niques, 369–380, 500, 678 assembly language, 67. See also C code finding using strings, 679–683 constructs in assembly highlighting anti-VM in IDA Pro, if statement, 113–114 377–378 for loop, 117 impact on malware analysis, switch statement, 124 673–677 while loop, 118 734 INDEX Practical Malware Analysis © 2012 Michael Sikorski and Andrew Honig assembly-level debuggers, vs. packet structure, 643 source-level, 168 request from initial malware run, asynchronous procedure call 627–628 (APC), 263 sending by malware, 633–634, AT_INFO structure, 547–548 639–640 AttachThreadInput function, 454 string decoding, 636 attackers beep driver, 214 identifying investigative activity, 299 behavior of malware. See malware safely investigating online, 300–302 behavior Autoruns tool, 140, 241, 465–466 BeingDebugged flag, 354, 657–658 checking, 353–354 B Berkeley compatible sockets, 143–144 BFK DNS logger, 302 backdoor, 3, 121, 232–234, 479, BHOs (Browser Helper Objects), 157 519, 538 big-endian, 70 analysis, 537–538 binary data CreateProcess and Sleep functions Base64-encoding conversion, 277 for, 479 static analysis, 503–507 evading detection, 308–311 Binary File option, in IDA Pro, 88 HTTP reverse, 539 binary translation by VMware, in implementing, 524 kernel mode, 373 indications of, 493 bind function, 143, 144, 454 reading configuration file, 723 BinDiff, 466 sandbox and, 41 BinNavi, 466 backup images, of operating BitBlaze, 40 systems, 30 BitBlt function, 454 “Bad or Unknown 32-bit Executable blacklists, of IP addresses, 301 File” error, 363 Blink pointers, 414 bang symbol (!), 305 block cryptography algorithms, 626 base addresses blue screen, in Windows, 158 finding with PEview, 545 Bochs (debugger), 467 of kernel32.dll, finding with Bookmarks plug-in, in OllyDbg, assembly code, 415 199–200 for PE files in Windows, 184 boot.ini file, 207–208, 226 Base64 cipher, 277–280, 622 botnet controller, 234 custom substitution cipher, 280 botnets, 3, 234, 376 identifying and decoding, 278–280 bp command, in WinDbg, 211 Base64 encoding branching, in x86 architecture, 80–81 decoding, 624–625 breakpoints identifying in URL, 611 in debuggers, 171–175 padding, 610, 630 conditional, 175 Python program to decode hardware execution, 174–175 string, 289 software execution, 173–174 static pattern within, 631 deferred, 212–213, 554 base64_encode function, 610 hardware vs. software, 687 basename, 535 for kernel activity, 548 BCDEdit, 227 in OllyDbg, 188–191, 391 beaconing, 309, 611 command-line to set, 199 client-initiated, 311 scanning code for, 357 determining generation, 628–629 and self-decoding, 289 Practical Malware Analysis INDEX 735 © 2012 Michael Sikorski and Andrew Honig breakpoints, continued object-oriented programming, setting, 357 427–432 setting on stack, 690 inheritance and function in WinDbg, 211–212 overriding, 432 bridged network adapter, 34 overloading and mangling, Browser Helper Objects (BHOs), 157 430–431 brute-force XOR encoding, 271–273 this pointer, 428–430 bu command, in WinDbg, 212 objects creation and bu $iment command, in WinDbg, destruction, 437 213, 554 virtual vs. nonvirtual functions, buffer, malware placement of 432–436 value in, 538 Caesar cipher, 270 buffer-overflow attack, 421 call instruction, 119, 333, 386, 409 Burp Suite, 467 and finding OEP, 391–392 Buster Sandbox Analyzer, 473 position dependence, 408 byte array initialization, 680–681 for quick analysis, 521–522 bytecode, 67 with target based on DWORD pointer, 396 C call memory_location, 77 call stack trace, in OllyDbg, 193 C code constructs in assembly, callback type, 136 109–132 calling conventions, x64 architecture arithmetic operations disassembly, 112–113 differences, 443–447 array disassembly, 127–128 CallNextHookEx function, 260, 261, 454 function call conventions, 119–121 Canvas penetration-testing tool, 380 global vs. local variables, 110–112 Capture BAT, 467 capturing events if statements, 113–116 labs, 133–134 network traffic, 580 solutions, 501–513 stopping procmon from, 44 linked list traversal, 130–132 capturing screen, function for, 615 loops, 116–118 CBC (Cipher Block Chaining), 626 for loops, 116–118 cdecl calling convention, 119–120 while loops, 118 cell phone malware, 88 structures, identifying, 128–130 central processing unit (CPU) switch statements, 121–126 threads and, 149 if style for, 122–123, 124 in x86 architecture, 68 jump table, 123–126 CertOpenSystemStore function, 454 C programming language, 110 CF (carry) flag, 72 function pointers in, 340 CFB (Cipher Feedback), 626 main method and offsets, in x86 CFF Explorer, 467 architecture, 83–84 cfile.read command, 293 pseudocode for process chained encoding algorithm, 277 replacement, 258 CheckRemoteDebuggerPresent function, standard library, IDA Pro catalog 352, 454 of named constants, 102 child classes in C++, 432 The C Programming Language functions from parent class, 436 (Kernighan and Ritchie), 110 chunk size, dependency with entropy C++ analysis, 427–438 score, 284 labs, 439–440 Cipher Block Chaining (CBC), 626 solutions, 712–723 Cipher Feedback (CFB), 626 736 INDEX Practical Malware Analysis © 2012 Michael Sikorski and Andrew Honig ciphers, 270–280 check for arguments, 525–529 Base 64, 277–280 encoded, 636 Caesar cipher, 270 option analysis, 535–537 other encoding schemes, 276–277 running malware from, 493 XOR cipher, 271–276 Command Line plug-in, for OllyDbg, cisvc.exe 198–199, 657–658 PEview of original and trojanized launching, 660 versions, 584–585 command processing, and malware writing shellcode into, 583–584 signature, 644 class identifiers (CLSIDs), 155 command shell, thread input to, 636 and COM functionality, 518 comments classes, in object-oriented code, 428 in HTML, 506 classtype keyword, in Snort, 304 command character parsed client