Created
February 21, 2019 23:27
-
-
Save alexander-hanel/b86f26085af6565b68626afc1a5199ed to your computer and use it in GitHub Desktop.
IDA Batch Mode
This file contains hidden or 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
import os | |
import subprocess | |
import glob | |
import pefile | |
IMAGE_FILE_MACHINE_I386 = 0x014c | |
IMAGE_FILE_MACHINE_AMD64 = 0x8664 | |
paths = glob.glob("*") | |
ida_path = os.path.join(r'C:\Program Files\IDA 7.0',"idat.exe") | |
ida_path_64 = os.path.join(r'C:\Program Files\IDA 7.0',"idat64.exe") | |
def pe_bit(file_path): | |
with open(file_path, "rb") as outfile: | |
pe_data = outfile.read() | |
pe = pefile.PE(data=pe_data) | |
if pe.FILE_HEADER.Machine == IMAGE_FILE_MACHINE_I386: | |
return 32 | |
else: | |
return 64 | |
for file_path in paths: | |
if file_path.endswith(".py"): | |
continue | |
bit = pe_bit(file_path) | |
if bit == 32: | |
subprocess.call([ida_path, "-B", file_path]) | |
else: | |
subprocess.call([ida_path_64, "-B", file_path]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment