IDA pro Imports - python

i have been delving into ida Pro for the last couple of weeks to get a bit of a background.
Something that has been bugging me for a long time though is the seemingly lack of support for pulling out the imported functions.
All i want is a script that can copy the entire imports window and paste into a text file, but I am having serious trouble finding anything in the API's that can help me do this. It should be very simple, yet I find it impossible. I have managed to find things to pull out the library's from this window, but nothing to pull out everything.
any help or direction would be much appreciated.

I agree with the assertion that you should use Ctrl+Ins or dumpbin.
However, what you ask has been solved already by the IDAPython project and I suggest you head over and look at their examples (here and here), especially this one.
The relevant idaapi functions are:
idaapi.get_import_module_qty
idaapi.enum_import_names

GUI Solution:
You can copy the entire contents of the imports window by placing focus on that window and hitting Ctrl+Ins.
IDAPython Solution:
This may need to be tweaked to your liking, but this should hopefully get you started:
text = ""
seg = SegByName(".idata")
for i in xrange(seg, SegEnd(seg), 4):
text += "%08x %s\r\n" % (i, Name(i))
open(r"c:\imports.txt", "wb").write(text)

Related

How do I optimize imports in Python using PyCharm?

Wanting to expand my horizons I decided to pick up programming and I've read that python is very beginner-friendly, knowing this I downloaded the program in addition to the PyCharm text editor and started to write some small stuff like print commands and the like. However, I wanted to start doing more and embarked on a mission to replicate a game off the internet, more specifically snake just to see how it all functions together in a cohesive manner. Every tutorial begins with "import" commands in addition to something like "math" and "random" directly after, turning red every single time. But for me, it just turns grey with the original orange "import" text also turning grey with a help icon saying to optimize my imports but just deleting my text altogether when I click it. I can find anything on the web to help me with what I'm dealing with leading me to believe that its probably an easy fix that I, for whatever reason can't seem to find. I really don't have a clue as to what to do and im increasingly becoming more and more frustrated.
That is okay, PyCharm is only signaling you that you haven't used that module yet. This can help Developers in large programs to save code and memory. Don't worry about it just ignore it and continue.

Condensing python code for creating tkinter widgets

I have a program that I'm designing to teach myself Python but have gotten stuck. I've run across a way to condense python code using % and a list of arguments to have it run as code and looping through the list of arguments until it's done, but can't seem to find it in the documentation or with Google, mostly because I can't figure out how to search for it (sadly it's pretty vague I know).
Mostly what I'm trying to do is prevent having to write approx. 300 lines simply for GUI buttons, labels, frames, ect. with very few changes between them.
Obviously the code is huge so it's all available at Github, github.com/kari-fox/MixxMaster. I'm looking for any kind of recommendations for condensing all of the GUI elements, mostly because I find myself copy/pasting any time I need to make minor changes to any of the similar pieces.
Thanks to Steven Summers in the comments for mentioning classes. I had no idea they were so powerful! I found this guide (https://jeffknupp.com/blog/2014/06/18/improve-your-python-python-classes-and-object-oriented-programming/) and it made understanding and implementing classes work perfectly! That helped me cut out almost 100 lines of purely window-building code and let me do a few sneaky things besides. If anyone wants to see the full implementation check out the github link in the question.

Sending multiple python lines with ConqueTerm

I'm using vim with ConqueTerm and ipython (--pylab if it matters) on Ubuntu 14.04. When I select multiple lines and send them using F9, everything pastes in the same line, as in this question. I could try remapping as the poster did for that question, but I don't have this issue with matlab on the same machine or with ConqueTerm+ipython on mac. Is there a way to fix this so I can continue using F9? Thanks!
The solution
It was my first experience using vimscript, but I was able to modify the plugin so it can send the selected lines properly.
I changed the send_selected function in the conque.vim(or another mirror)\autoload\conque_term.vim to this: https://gist.github.com/freencis/28e351e3bb267a8522e1dff53436fb8d
The function name is the same, just go there and replace it.
What I did
I will skip the "explaing what was wrong" part, mostly because I didn't fully grasp the original implementation.
So, after searching a bit on the internet about how I could access the file's text from a plugin, I ended up finding a way to get the text from specific lines from the file: using the getline function. Luckly there were already a Conque's function to send the line to the terminal and execute it (used by the 's send_file), so I just used it.
Then It was just a matter of knowing which lines were selected and get those. Which led me to the line function, which returns the line number in a different ways. One of these was by marker, in this case the '<, '> markers from the visual selection. Unfortunately I also don't know how to explain these, but calling line("'<") and line("'>") returned me the selection's start and end lines respectively.
And that was the vimscript programming part, the :help is really a life saver. The traditional programming was just looping through the line numbers, getting the text from those and sending them to the terminal.
Notes
It was my first ever experience with vimscript (I've only been using vim for a month), so I'm sure it might not the proper way to do it, plus I replaced a functionality, so I'm just sharing it as a quick hack. Any feedback is appreciated.
Props to http://learnvimscriptthehardway.stevelosh.com/, it helped me a lot with the language, I never expected it to be that accessible
And sorry for any bad English. peace

Keep getting error displaying Image

I'm working on adding an image to a GUI interface using Tkinter. In order to eliminate as many factors as possible, I have stripped out everything but the parts relevant to adding an image, yet it still errors out with "tclError:image "pyimageX" doesn't exist" (where X a number). I have followed directly from a tutorial, and I've checked and double checked the file name, and that the file is directly inside the same folder as the program. I have no other ideas to check, and thus, here I am. Thanks for any help you can provide, I'm really hoping I'm not missing anything obvious.
Here's the snippet that's not working:
from tkinter import *
root =Tk()
versionNumRaw = PhotoImage(file="versionNum.gif")
versionNum = Label(root,image=versionNumRaw)
versionNum.pack()
root.mainloop()
Forgive me, as I know this sort of error has been posted before, with answers that have worked for others, but me, still being not having much experience with programming, cant figure out how to apply the answers others have gotten to my own case.

Code Assist in RopeVim...how do you use it?

It is not obvious to me how to use RopeVim's code assist feature.
I was using Vim at the terminal in mac os x.
I moved to MacVim and the GUI does help b/c I do see a Ropevim menu option now.
I have Ropevim set up correctly I'm fairly sure.
I want to test the code assist feature out, so I type in self.asser
and nothing happens. I've tried tab and control + space.
I sometimes see basically a history of what I've typed, more along the lines of auto-complete, b/c I have a plugin for that, but I want to see that code assist shows me what possible options are.
When I type in from django.contrib.
I want to know if code assist will be able to show me things like mail, syndication, etc, modules that I've never even typed in this project before.
Of course pycharm certainly does this flawlessly, but I am still partial to vim. Can't quite let it go, but most definitely can not afford the time to continue to fiddle with this tinkering b/c I need to get coding. The Rope library seems like it can do what I need: code assist and basic refactoring, but how?
I use jedi-vim and code assist works perfectly. https://github.com/davidhalter/jedi-vim.
Update:
I uploaded a short video. http://youtu.be/5lgbV8iY8-Q
Did you look at the code? Code assist seems to be mapped to <M-/>.

Categories