c语言实现shellcode转换工具

shellcode是一种小型内嵌代码,一般用于入侵,和修补漏洞的。

这种代码是非常简洁的而且跨平台性能高,因为后面博主要写关于shellcode的文章,所以今天这里给大家介绍如何使用c语言写一个能够实现汇编到机器码的转换程序

首先你需要一个汇编解释器:

这里博主已经上传到网盘:

链接:https://pan.baidu.com/s/1TuF1OeBJzAwcwVrlR4d4BQ

提取码: dptv

主要是对工具进行了封装,没有技术难点,所以这里就不做额外的说明了

// ConsoleApplication11.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <windows.h>
#define ASSEM "mov ax,bx\r\nmov ax,bx\0"
int _tmain(int argc, _TCHAR* argv[])
{
	//构造汇编代码
	char _assem[1024] = {0};
	strcat_s(_assem, "bits 32\n");	//汇编头,代表多少位的编译
	//汇编体
	strcat_s(_assem, "mov ax,bx\r\n");	//汇编代码,每行汇编需要一个换行
	strcat_s(_assem, "mov ax,bx\0");		//末尾不需要换行


	//将汇编代码写到本地
	FILE* _fp = NULL;
	fopen_s(&_fp,"_asm", "w");
	fwrite(_assem, strlen(_assem), 1, _fp);
	fclose(_fp);


	//调用eax_asm汇编编译器编译
	system("eax_asm _asm -o hex");


	//编译完成后将编译好的二进制hex文件读入
	fopen_s(&_fp, "hex", "rb+");


	//获取文件大小
	fseek(_fp, 0, SEEK_END);  
	int _size = ftell(_fp); 


	//移动回来
	fseek(_fp, 0, SEEK_SET);


	//读入时必须是存放到字节集里
	unsigned char hex[256] = { 0 };
	fread(hex, _size, 1, _fp);
	fclose(_fp);
	
	//打印
	printf("汇编代码:\n%s\n\n", ASSEM);
	printf("机器码:\n");
	for (int i = 0; i < _size; ++i){
		printf("%d ", hex[i]);
	}
	//机器码到汇编
	printf("\n\n机器码转汇编:\n");

	//调用ecx_asm汇编编译器编译
	system("ecx_asm -b 32 hex");
	getchar();
	return 0;
}

实现效果:

其中 00000开头是代表文件内的偏移地址,6689d8是代表十六进制的汇编机器码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Shellcode Helper v1.62 Coded by TeLeMan (c) 2008-2013 Usage: schelper.exe [options] Options: -i [input file] input file (Default: stdin) -o [output file] output file (Default: stdout) -s input file format (Default: Auto-Detection) -sb input file format is Binary -sp the input file format's parameters -d output file format (Default: C format) -db output file format is Binary -dp the output file format's parameters -search get the start offset by the pattern: e.g. PK\x03\x04 -soff fix the match offset after searching (Default: 0) -off convert the input file from the offset (Default: 0) -len convert the input file with the length (Default: 0 - MAX) -en [encoder] encode shellcode (Default: XorDword) -de [encoder] decode shellcode (Default: Auto-Detection) -ex exclude characters: e.g. 0x00,0x01-0x1F,0xFF (Default: 0x00) -in incude characters only -ep the encoder's parameters -t [pid] execute or inject shellcode into process for testing -td [pid] execute or inject shellcode into process for debugging -stack put shellcode into stack and execute it (ESP is the shellcode start) -noinfo display no normal messages except error messages Available formats: 0 - C 1 - C(HexArray) 2 - Perl 3 - Python 4 - Ruby 5 - JavaScript(Escape) 6 - VBScript(Escape) 7 - Pascal 8 - MASM(Data) 9 - HexDump 10 - BitString 11 - HexString 12 - HexArray(C like) 13 - Base64 14 - Binary 15 - HexString(C like) 16 - HexString(Escape) 17 - HexString(JavaScript,UNICODE) 18 - URI(ISO-8859-1) 19 - XML(PCDATA) 20 - BigNumber 21 - BigNumber(Hex) 22 - BigNumber(BaseX) 23 - FloatPoint 24 - UnixTimestamp 25 - GUID 26 - MASM(ASM) 27 - NASM 28 - YASM(ASM) 29 - FASM(ASM) 30 - JWASM(ASM) 31 - POASM(ASM) 32 - GOASM(ASM) 33 - GNU ASM Available encoders:

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

17岁boy想当攻城狮

感谢打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值