"Python" Exe2shellcode,shellcode2exe

Source: Internet
Author: User

Writing this kind of program in Python is very concise, if you don't know how many lines of code to write in C + +.

Exe2shellcode
#! /usr/bin/env python# -*- coding: utf-8 -*-import osimport sysdef 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)
Reference

Discussion on the concept of decomposition type backdoor
https://mp.weixin.qq.com/s/KLR2s9PkHqy97eZjYTeM2w

"Python" Exe2shellcode,shellcode2exe

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.