zoukankan      html  css  js  c++  java
  • Python exe2shellcode,shellcode2exe

    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)
  • 相关阅读:
    开发进度二
    开发进度一
    大道至简阅读笔记01
    用户模板和用户评价
    第九周总结
    第八周总结
    NABCD项目分析
    第七周总结
    第六周总结
    构建之法阅读笔记03
  • 原文地址:https://www.cnblogs.com/hjbf/p/10670959.html
Copyright © 2011-2022 走看看