用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. 20135337朱荟潼 Linux第五周学习总结——扒开系统调用的三层皮(下)

    朱荟潼 + 原创作品转载请注明出处 + <Linux内核分析>MOOC课http://mooc.study.163.com/course/USTC 1000029000 一.学习内容 (一 ...

  2. Python Pandas read_csv报错

    为实现文本去重(将前面采集的数据进行两两对比删除重复),写了以下代码. #-*- coding: utf-8 -*-import pandas as pd inputfile = 'e:/data/H ...

  3. Map Wiki -- proposed by Shuo Ren

    Map Wiki —— 基于Bing地图的生活百科 在旅游.逛街或是闲逛的时,很多时候,我们往往想要对于身边的美食.医院.旅馆.购物.学习.景点等信息有进一步认识.在这时,我们大多会再打开百度或者大众 ...

  4. 实现项目WC

    软件的需求分析 程序处理用户需求的模式为: wc.exe [parameter][filename] 在[parameter]中,用户通过输入参数与程序交互,需实现的功能如下: 1.基本功能 支持 - ...

  5. [转帖]linux namespace 和cgroup lxc

    https://blog.csdn.net/xiaoliuliu2050/article/details/53443863 5.1 linux namespace 和cgroup lxc 2016年1 ...

  6. Android GridView数据绑定

    java代码构造个泛型数组用于存放item,作为title        List<Map<String, Object>> items = new ArrayList< ...

  7. div文本垂直居中(div text vertical aligan)

    .box{ width: 135px;height: 84px;display: block; overflow: hidden; } .container { background:darkcyan ...

  8. C#委托的介绍(delegate、Action、Func、predicate)ga

    转载:http://www.cnblogs.com/akwwl/p/3232679.html 感觉写的很好.例子也很简单明了.赞一个 委托是一个类,它定义了方法的类型,使得可以将方法当作另一个方法的参 ...

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

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

  10. sniffer 和 debug flow

    sniffer 和 debug flow sniffer 和 debug flow 复制模板,直接修改IP即可使用: diagnose sys session filter clear diagnos ...