Skip to content

Instantly share code, notes, and snippets.

@zcutlip
Created July 15, 2021 20:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zcutlip/9309f96602ec9fbc3d8c13c70d3380f3 to your computer and use it in GitHub Desktop.
Save zcutlip/9309f96602ec9fbc3d8c13c70d3380f3 to your computer and use it in GitHub Desktop.
IDA python script that prints to console in batch mode
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