diff options
| author | William Bruneau <william.bruneau@epfedu.fr> | 2019-12-02 10:54:02 +0100 |
|---|---|---|
| committer | William Bruneau <william.bruneau@epfedu.fr> | 2019-12-02 18:38:29 +0100 |
| commit | b4f573d849e8469a40e0161097151b2b3d5249b4 (patch) | |
| tree | 989cbaef3a4be66e996e20ce63a45a6b1fda1b18 /example/loader/sc2pe.py | |
| parent | c37cec913ac7724f20b0da3e2ef66ae45bbb54c4 (diff) | |
| download | focaccia-miasm-b4f573d849e8469a40e0161097151b2b3d5249b4.tar.gz focaccia-miasm-b4f573d849e8469a40e0161097151b2b3d5249b4.zip | |
Example: add sc2pe.py
Diffstat (limited to 'example/loader/sc2pe.py')
| -rw-r--r-- | example/loader/sc2pe.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/example/loader/sc2pe.py b/example/loader/sc2pe.py new file mode 100644 index 00000000..95359419 --- /dev/null +++ b/example/loader/sc2pe.py @@ -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)) |