about summary refs log tree commit diff stats
path: root/example/loader/test_pe.py
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2019-05-09 10:40:26 +0200
committerAjax <commial@gmail.com>2019-05-09 10:40:26 +0200
commit639abbe623a5d04d173495f29aff698e80577d8a (patch)
tree34983d32c30aa54e3e918fe2c0602682dc609940 /example/loader/test_pe.py
parent82ec0ab9b24553c894540bb1f560df2cf062679b (diff)
downloadmiasm-639abbe623a5d04d173495f29aff698e80577d8a.tar.gz
miasm-639abbe623a5d04d173495f29aff698e80577d8a.zip
Example: rename elfesteem -> loader
Diffstat (limited to 'example/loader/test_pe.py')
-rw-r--r--example/loader/test_pe.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/example/loader/test_pe.py b/example/loader/test_pe.py
new file mode 100644
index 00000000..543cbea5
--- /dev/null
+++ b/example/loader/test_pe.py
@@ -0,0 +1,31 @@
+#! /usr/bin/env python
+
+import miasm.loader.pe as pe
+from miasm.loader.pe_init import PE
+import rlcompleter
+import readline
+import pdb
+import sys
+from pprint import pprint as pp
+readline.parse_and_bind("tab: complete")
+
+
+e_ = PE()
+mysh = b"\xc3"
+s_text = e_.SHList.add_section(
+    name="text", addr=0x1000, rawsize=0x1000, data=mysh)
+e_.Opthdr.AddressOfEntryPoint = s_text.addr
+new_dll = [({"name": "kernel32.dll",
+             "firstthunk": s_text.addr + 0x100},
+            ["CreateFileA", "SetFilePointer", "WriteFile", "CloseHandle"]
+            ),
+           ({"name": "USER32.dll",
+             "firstthunk": None},
+            ["SetDlgItemInt", "GetMenu", "HideCaret"]
+            )
+           ]
+e_.DirImport.add_dlldesc(new_dll)
+
+s_myimp = e_.SHList.add_section(name="myimp", rawsize=0x1000)
+e_.DirImport.set_rva(s_myimp.addr)
+open('uu.bin', 'wb').write(bytes(e_))