用python写这类程序真简洁,要是用C++又不知道得多写多少行代码了。

exe2shellcode

#! /usr/bin/env python
# -*- coding: utf-8 -*- import os
import sys def payload(files):
shellcode = ""
ctr = 1
maxlen = 15 #to create rows
try:
for b in open(files, "rb").read():
shellcode +=b.encode("hex")
if ctr == maxlen:
ctr = 0
ctr += 1
print "Code length: " + str(len(shellcode))
return shellcode
except:
print "转换失败,请检查!" f = open('messagebox.txt','w')
files = "messagebox.exe"
a = payload(files)
f.write(a)
f.close()

shellcode2exe

#! /usr/bin/env python
# -*- coding: utf-8 -*- # 计算messagebox大小
c = open('messagebox.txt','r')
r = c.read()
print len(r) # 将cmd.exe中的opcode再转换为HEX数据
s = open('messagebox.txt','rb')
b = s.read()
bb = b[-len(r):]
cb = bb.decode("hex")
f = open('mess.exe','wb')
f.write(cb)

参考

分解型后门构想初探

https://mp.weixin.qq.com/s/KLR2s9PkHqy97eZjYTeM2w

【Python】exe2shellcode,shellcode2exe的更多相关文章

  1. 【Python】xlrd,NotImplementedError-formatting_info=True not yet implemented

    前言 Python需要读取Excel(.xls..xlsx)时通常使用xlrd模块:如果要对其内容进行编辑的话稍稍有些麻烦,通常的做法是使用xlutils的copy模块对原文件进行复制,然后保存成新的 ...

  2. 【python】坑,坑,折腾一个下午python 3.5中 ImportError: No module named BeautifulSoup

    将语句 from bs4 import BeautifulSoup4 改成 from bs4 import BeautifulSoup 通过 尼玛------------------------! 总 ...

  3. 【python】发送邮件,含附件

    def send_mail(_user,_pwd,_to): # f = open(file_new,'rb') # mail_body = f.read() # f.close() # 读取最新测试 ...

  4. 【Python】无须numpy,利用map函数与zip(*)函数对数组转置(转)

    http://blog.csdn.net/yongh701/article/details/50283689 在Python的numpy中,对类似array=[[1,2,3],[4,5,6],[7,8 ...

  5. 【Python②】python之首秀

       第一个python程序 再次说明:后面所有代码均为Python 3.3.2版本(运行环境:Windows7)编写. 安装配置好python后,我们先来写第一个python程序.打开IDLE (P ...

  6. 【python】多进程锁multiprocess.Lock

    [python]多进程锁multiprocess.Lock 2013-09-13 13:48 11613人阅读 评论(2) 收藏 举报  分类: Python(38)  同步的方法基本与多线程相同. ...

  7. 【python】SQLAlchemy

    来源:廖雪峰 对比:[python]在python中调用mysql 注意连接数据库方式和数据操作方式! 今天发现了个处理数据库的好东西:SQLAlchemy 一般python处理mysql之类的数据库 ...

  8. 【python】getopt使用

    来源:http://blog.chinaunix.net/uid-21566578-id-438233.html 注意对比:[python]argparse模块 作者:limodou版权所有limod ...

  9. 【Python】如何安装easy_install?

    [Python]如何安装easy_install? http://jingyan.baidu.com/article/b907e627e78fe146e7891c25.html easy_instal ...

随机推荐

  1. navicat连接mysql报10061错

    可能原因:mysql服务未启动 解决办法:进入到计算机管理,找到服务,然后找到mysql服务,并启动该服务

  2. 实训一(cocos2d-x相关)

    实训内容简介: 大四开始前系里安排的的集中实践环节,根据要求,开发app应用软件. 目标app:Stick_mxj 目的:继续对cocos2d-x的学习,完成实践环节,解决现在对引擎不是很清楚的一些问 ...

  3. classpath与clsspath*

    classpath是指 WEB-INF文件夹下的classes目录 classes含义: 1.存放各种资源配置文件 eg.init.properties log4j.properties struts ...

  4. Day Three

    站立式会议 站立式会议内容总结 442 今天:从本地导入电子书页面编写以及部分逻辑代码 遇到的问题:界面适配问题 明天:具体计划界面的编写,解决上面问题 331 今天:监听webview滑动底端事件 ...

  5. final 140字评论II

    1.约跑app: 从性能上讲,着重修改了其他组找出的bug,性能上有了很大的提高,增强了实用性. 从功能上讲,该app可以增加用户之间的互动性,有较多的客户群,适合人群不限于青少年和成年人. 从UI上 ...

  6. Tether USDT 节点钱包的安装与使用-omni layer

    1 什么是Omni Layer Omni Layer是一种通信协议,它使用比特币区块链实现智能合约,用户货币和分散式点对点交换等功能. Omni Core是基于比特币核心代码库的快速,便携式Omni层 ...

  7. 等价类计数(Polya定理/Burnside引理)学习笔记

    参考:刘汝佳<算法竞赛入门经典训练指南> 感觉是非常远古的东西了,几乎从来没有看到过需要用这个的题,还是学一发以防翻车. 置换:排列的一一映射.置换乘法相当于函数复合.满足结合律,不满足交 ...

  8. HTTTP及TCP的超时以及KEEP-ALIVE机制小结

    一.HTTP的超时和Keep Alive HTTP Keepalive 机制是http 1.1中增加的一个功能. 在HTTP 1.0中,客户端每发起一个http 请求,等收到接收方的应答之后就断开TC ...

  9. Hello 2018 A,B,C,D

    A. Modular Exponentiation time limit per test 1 second memory limit per test 256 megabytes input sta ...

  10. hdwiki 前后台版权信息在哪修改

    hdwiki 前台copyright 信息在 view/default/footer.htm 搜索footer-phdwiki 后台copyright 信息在 view/default/admin_m ...