eset / ipyida

IPython console integration for IDA Pro

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Console Startup

fritzr opened this issue · comments

Both when running jupyter console --existing and from the Qt console (via Edit -> Plugins -> IPyIDA) I seem to need to run from idc import * and from idaapi import * the first time I connect to the kernel. This is incredibly annoying and of course there may be other startup things I want to do. However it seems that if I disconnect and reconnect to the kernel, any global names I defined in a previous connection remain, which is nice.

Is there any way to hook a startup file so that I can perform such imports when the kernel starts? The jupyter/ipython documentation leaves much to be desired. I've tried putting my import statements in the following files to no effect, even though I can verify with print statements that they are all run at various times (except $PYTHONSTARTUP, which I can't get to run):

  • ~/.ipython/profile_default/ipython_kernel_config.py
  • ~/.ipython/profile_default/startup/*.py
  • ~/.jupyter/jupyter_console_config.py
  • ~/.idapro/idapythonrc.py
  • $PYTHONSTARTUP

I even tried modifying the IPyIDA distribution files and adding the imports to the top of ida_plugin.py, ida_plugin_stub.py, ida_qtconsole.py, and kernel.py with identical results. Help!!

I seem to need to run from idc import * and from idaapi import * the first time I connect to the kernel.

Yes, new IPyIDA kernel starts with an empty namespace since 11808f6. Before it used to copy the context from idapythonrc.py but with the new IDA 7.0 namespace aware plugins it didn't work as intended.

Is there any way to hook a startup file so that I can perform such imports when the kernel starts?

I think adding feature where ~/.idapro/ipyidarc.py is loaded on kernel launch would makes sense. It would also give the users the imports they prefer (from * import idaapi?, import idaapi?).

I'm keeping this one open and I'll look into it when I have a bit more time (few weeks at least).

Good to know. Glad I’m not just missing something obvious.

Thanks a lot!

Here's a PR (0ff25bc) which loads ~/.idapro/ipyidarc.py on kernel startup if it exists using the IPKernelApp.exec_files property. I use it to import idaapi and idc, and setup some global variables and it works great for me. Hopefully this is helpful!

v1.4 is now out. ipyidarc.py is now supported.