Created
July 15, 2021 20:58
-
-
Save zcutlip/9309f96602ec9fbc3d8c13c70d3380f3 to your computer and use it in GitHub Desktop.
IDA python script that prints to console in 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 idc | |
import os | |
# you won't see this on the console | |
print("hello") | |
class Log: | |
def __init__(self, logfile): | |
self.logfile = logfile | |
self.logfh = None | |
def log(self, msg): | |
if self.logfh is None: | |
if self.logfile is None: | |
self.logfh = os.fdopen(1, "w") | |
else: | |
self.logfh = open(self.logfile, "a") | |
# sys.stderr = self.logfh | |
self.logfh.write(f"{msg}\n") | |
self.logfh.flush() | |
# log = Log("./log.txt") | |
log = Log(None) | |
log.log("Test") | |
def main(): | |
idc.auto_wait() | |
log.log("Hello from IDAPython") | |
for i, arg in enumerate(idc.ARGV): | |
log.log(f"ARGV[{i}]={arg}") | |
return 0 | |
main() | |
idc.qexit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment