Linux shellcode sample

HelloWorld.nasm

;HelloWorld.asm
;Author: Kul Subedi global _start section .text
_start:
; print HelloWorld! in screen
mov eax, 0x4
mov ebx, 0x1
mov ecx, message
;mov edx, 12
mov edx, mlen
int 0x80 ; exit program gracefully
mov eax, 0x1
mov ebx, 0x5
int 0x80 section .data
message: db "Welcome to Assembly!"
mlen equ $-message

abc.nasm

;hello.asm
[SECTION .text] global _start _start: jmp short call_shellcode shellcode: 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 ;length of the string
int 0x80 xor eax, eax
mov al, 1 ;exit the shellcode
xor ebx,ebx
int 0x80 call_shellcode:
call shellcode ;put the address of the string on the stack
db 'milu'

compile.sh

#!/usr/bin/env bash

echo '[+] Assembling with Nasm .. '
nasm -f elf32 -o $1.o $1.nasm
echo '[+] Linking ... '
ld -o $1 $1.o
echo '[+] Done!'

shel.sh

#!/usr/bin/env bash

objdump -d $1 | grep '[0-9a-f]:' | grep -v 'file' | cut -d: -f2|cut -d' ' -f1-6 | tr -s ' ' | tr '\t' ' ' | sed 's/ $//g' | sed 's/ /\\x/g' | paste -d '' -s | sed 's/^/"/' | sed 's/$/"/g'

abctxt.txt

"\xeb\x19\x31\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\x6d\x69\x6c\x75"

shellcode.c

#include <stdio.h>
#include <string.h> unsigned char code[] ="\xeb\x19\x31\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\x6d\x69\x6c\x75"; main(){
printf("Shellcode Length: %d\n", strlen(code)); int (*ret)() = (int(*)())code; ret();
}

gcc_compile.sh

#!/usr/bin/env bash

echo '[+] Compiling....'

gcc -fno-stack-protector -z execstack $1.c -o $1

echo '[+] Done...'

============== End

Linux shellcode sample的更多相关文章

  1. Linux Rootkit Sample && Rootkit Defenser Analysis

    目录 . 引言 . LRK5 Rootkit . knark Rootkit . Suckit(super user control kit) . adore-ng . WNPS . Sample R ...

  2. 二进制入门-打造Linux shellcode基础篇

    0x01 前言   本文的目的不是为了介绍如何进行恶意的破坏性活动,而是为了教会你如何去防御此类破坏性活动,以帮助你扩大知识范围,完善自己的技能,如有读者运用本文所学技术从事破坏性活动,本人概不负责. ...

  3. linux ps sample

    ps -ef|grep "myswooleserver.php"| grep -v "grep" | wc -l cpc@cpc-Aspire-:~/Downl ...

  4. Linux下shellcode的编写

    Linux下shellcode的编写 来源  https://xz.aliyun.com/t/2052 EdvisonV / 2018-02-14 22:00:42 / 浏览数 6638 技术文章 技 ...

  5. 使用MSF打造各种ShellCode

    MSF 生成各种后门 Windows: 生成Windows后门. msfvenom -a x86 --platform Windows -p windows/meterpreter/reverse_t ...

  6. 写一个简单的shellcode

    0x00 前言 漏洞利用中必不可缺的部分就是shellcode,不会编写shellcode和咸鱼有什么区别,跳出咸鱼第一步. 0x01 系统调用 通过系统调用execve函数返回shell C语言实现 ...

  7. shellcode编写

    shellcode编写 shellcode是一段用于利用软件漏洞而执行的代码,通常使用机器语言编写,其目的往往是让攻击者获得目标机器的命令行shell而得名,其他有类似功能的代码也可以称为shellc ...

  8. Linux 驱动开发

    linux驱动开发总结(一) 基础性总结 1, linux驱动一般分为3大类: * 字符设备 * 块设备 * 网络设备 2, 开发环境构建: * 交叉工具链构建 * NFS和tftp服务器安装 3, ...

  9. 3.10.17 procfs示例

    /* *    wesley *    the linux module sample of procfs *     *    wesley for testing *    2013-12-23 ...

随机推荐

  1. 邻居子系统 之 更新neigh_update

    概述 neigh_update函数用来更新指定的邻居项,更新内容是硬件地址和状态,更新之后,会根据新状态设置其输出函数,CONNECTED状态则使用快速输出,否则使用慢速输出:如果是由原来的无效状态变 ...

  2. 高效C++无锁队列实现-moodycamel::ConcurrentQueue

    国外一牛人做的,支持多平台,支持多线程写.多线程读,并可指定读写token,转载过来. 感觉作者也时刻维护着他这个项目,我提了一些问题,每次都会及时得到答复,而且回复得非常认真仔细,非常赞! 链接地址 ...

  3. Ubuntu——配置JDK

    在Ubuntu下配置JDK环境 检查是否已经安装了JDK,执行以下命令: java -v 如果出现以下内容则说明没有安装: 程序 'java' 已包含在下列软件包中: * default-jre * ...

  4. Android studio 下 NDK Jni 开发 简单例子

    1. 创建一个新的工程 2. 创建一个新的类 JniText.java  点击Build--Make Project  后     选中工程 点击F4键 sdk location 中 Android ...

  5. Json文件删除元素

    方法1:delete 注意,该方法删除之后的元素会变为null,并非真正的删除!!! 举例: 原json: { "front" : { "image" : [ ...

  6. 理解MQ

    1.定义 2.消息队列比较 参考文章:https://www.jianshu.com/p/068b8d1610ee

  7. Android百分比支持布局库的使用和源码分析

    Android-percent-support这个库 描述下这个support-lib. 这个库提供了: 两种布局供大家使用: PercentRelativeLayout.PercentFrameLa ...

  8. Java-获取当前IP归属地

    知道IP,获取当前IP归属地的Java程序: package Main; import java.io.BufferedReader; import java.io.DataOutputStream; ...

  9. 小D课堂 - 新版本微服务springcloud+Docker教程_1_02技术选型

    笔记 2.技术选型和学后水平     简介:课程所需基础和技术选型讲解,学完课程可以到达怎样的程度,          1.IDEA JDK8 Maven SpringBoot基础 Linux 2.理 ...

  10. Redis 高级应用

    Redis SAVE 命令用于创建当前数据库的备份 该命令将在 redis 安装目录中创建dump.rdb文件. 如果需要恢复数据,只需将备份文件 (dump.rdb) 移动到 redis 安装目录并 ...