-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c37cec9
commit b4f573d
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sys | ||
|
||
from argparse import ArgumentParser | ||
from miasm.loader import pe_init | ||
|
||
|
||
parser = ArgumentParser(description="Create a PE from a shellcode") | ||
parser.add_argument("filename", | ||
help="x86 shellcode filename") | ||
parser.add_argument("-p", "--pename", | ||
help="new PE filename (default is 'sc_pe.exe')", | ||
default="sc_pe.exe") | ||
parser.add_argument("-w", "--word-size", | ||
help="word size (default is 32 bits)", | ||
choices=[32, 64], | ||
type=int, | ||
default=32) | ||
args = parser.parse_args() | ||
|
||
|
||
data = open(args.filename, 'rb').read() | ||
pe = pe_init.PE(wsize=args.word_size) | ||
s_text = pe.SHList.add_section(name="text", addr=0x1000, data=data) | ||
pe.Opthdr.AddressOfEntryPoint = s_text.addr | ||
open(args.pename, 'wb').write(bytes(pe)) |