Nytro Posted August 4, 2012 Report Posted August 4, 2012 Understanding Windows Shellcodeskapemmiller a hick.orgLast modified: 12/06/2003Contents1 Foreword 32 Introduction 43 Shellcode Basics 53.1 System Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.2 Finding kernel32.dll . . . . . . . . . . . . . . . . . . . . . . . . . 63.2.1 PEB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.2.2 SEH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2.3 TOPSTACK . . . . . . . . . . . . . . . . . . . . . . . . . 103.3 Resolving Symbol Addresses . . . . . . . . . . . . . . . . . . . . . 113.3.1 Export Directory Table . . . . . . . . . . . . . . . . . . . 113.3.2 Import Address Table (IAT) . . . . . . . . . . . . . . . . 134 Common Shellcode 154.1 Connectback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.2 Portbind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 Advanced Shellcode 295.1 Download/Execute . . . . . . . . . . . . . . . . . . . . . . . . . . 296 Staged Loading Shellcode 396.1 Dynamic File Descriptor Re-use . . . . . . . . . . . . . . . . . . . 396.2 Static File Descriptor Re-use . . . . . . . . . . . . . . . . . . . . 426.3 Egghunt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436.4 Egghunt (syscall) . . . . . . . . . . . . . . . . . . . . . . . . . . . 446.5 Connectback IAT . . . . . . . . . . . . . . . . . . . . . . . . . . . 467 Conclusion 498 Detailed Shellcode Analysis 508.1 Finding kernel32.dll . . . . . . . . . . . . . . . . . . . . . . . . . 508.1.1 PEB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508.1.2 SEH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518.1.3 TOPSTACK . . . . . . . . . . . . . . . . . . . . . . . . . 5318.2 Resolving Symbol Addresses . . . . . . . . . . . . . . . . . . . . . 548.2.1 Export Table Enumeration . . . . . . . . . . . . . . . . . 548.3 Common Shellcode . . . . . . . . . . . . . . . . . . . . . . . . . . 568.3.1 Connectback . . . . . . . . . . . . . . . . . . . . . . . . . 568.3.2 Portbind . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638.4 Advanced Shellcode . . . . . . . . . . . . . . . . . . . . . . . . . 718.4.1 Download/Execute . . . . . . . . . . . . . . . . . . . . . . 718.5 Staged Loading Shellcode . . . . . . . . . . . . . . . . . . . . . . 818.5.1 Dynamic File Descriptor Re-use . . . . . . . . . . . . . . 818.5.2 Egghunt . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858.5.3 Egghunt (syscall) . . . . . . . . . . . . . . . . . . . . . . . 88Download:http://www.hick.org/code/skape/papers/win32-shellcode.pdfhttp://projectshellcode.com/downloads/http___www.hick.org_code_skape_papers_win32-shellcode.pdf Quote