用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. 20190215面试-C#操作外设-多线程-shocket

    百度了下,ic卡读卡器 文章;C# 读IC卡程序这个文章还不错. 从北京金木雨电子有限公司下载了,兼容IC卡 身份证阅读器的SDK资料,里面有介绍如何连接ic读卡器,对卡进行一些操作. MasterR ...

  2. RYU 灭龙战 first day

    RYU 灭龙战 first day 前言 由于RYU翻译过来是龙的意思,此次主题就叫灭龙战吧 灵感来源 恶龙的三位真火-问题所在 参照了官方文档的基本操作 笔者以此执行 一个终端里 sudo mn - ...

  3. Linux 系统目录

    / 根目录 /bin 存放必要的命令 /boot 存放内核以及启动所需的文件等 /dev 存放设备文件 /etc 存放系统的配置文件 /home 用户文件的主目录,用户数据存放在其主目录中 /lib ...

  4. 对比网络模拟器软件——Cisco Packet Tracer、华为eNSP、H3C Cloud Lab

    1.软件介绍 1.1 Cisco Packet Tracer Cisco Packet Tracer(以下简称PT)是一款由思科公司开发的,为网络课程的初学者提供辅助教学的实验模拟器.使用者可以在该模 ...

  5. Android控件第2类——ImageView

    1.ImageView不仅仅可以显示图片,ImageView可以显示任何Drawable对象. adjustViewBounds:设置ImageView是否调整自己的边界来保证图片的长宽比. crop ...

  6. spirngcloud文件

    https://blog.csdn.net/liumiaocn/article/details/54309866

  7. SpringBoot(十四)_springboot使用内置定时任务Scheduled的使用(一)

    为什么使用定时? 日常工作中,经常会用到定时任务,比如各种统计,并不要求实时性.此时可以通过提前设置定时任务先把数据跑出来,后续处理起来更方便. 本篇文章主要介绍 springboot内置定时任务. ...

  8. Oracle VirtualBox添加虚拟机

    Oracle VirtualBox添加虚拟机 我的台式机是毁灭者,主板是华硕主板:安装的系统是win7 64bit.本来默认打算在该机器上面安装virtualBox,然后在virtualBox上面安装 ...

  9. jmeter测试soap协议时候 路径不需要添加

  10. bzoj1214 [HNOI2004]FTP服务器

    题目挺复杂的. 但有一点好,就是这题没数据,交个空程序就好了. begin end.