Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some little GUI improvement #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
963 changes: 488 additions & 475 deletions console/PAIMEIconsole.pyw

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion console/modules/PAIMEIpeek.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def on_button_select_module (self, event):

mysql = self.main_frame.mysql

if not mysql:
if (not mysql) or (mysql is None):
self.err("No available connection to MySQL server.")
return

Expand Down
101 changes: 54 additions & 47 deletions console/modules/_PAIMEIpeek/ProcessListCtrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#

'''
@author: Pedram Amini
@license: GNU General Public License 2.0 or later
@contact: [email protected]
@author: Pedram Amini
@license: GNU General Public License 2.0 or later
@contact: [email protected]
@organization: www.openrce.org
'''

Expand All @@ -32,65 +32,72 @@
import utils

class ProcessListCtrl (wx.ListCtrl, ListCtrlAutoWidthMixin, ColumnSorterMixin):
'''
Our custom list control containing a sortable list of PIDs and process names.
'''
'''
Our custom list control containing a sortable list of PIDs and process names.
'''

FUNCTIONS = utils.process_stalker.FUNCTIONS
BASIC_BLOCKS = utils.process_stalker.BASIC_BLOCKS
FUNCTIONS = utils.process_stalker.FUNCTIONS
BASIC_BLOCKS = utils.process_stalker.BASIC_BLOCKS

def __init__(self, parent, id, pos=None, size=None, style=None, top=None):
wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT | wx.SIMPLE_BORDER | wx.LC_HRULES )
self.top = top
self.selected_pid = 0
self.selected_proc = None
def __init__(self, parent, id, pos=None, size=None, style=None, top=None):
wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT | wx.SIMPLE_BORDER | wx.LC_HRULES )
self.top = top
self.selected_pid = 0
self.selected_proc = None

ListCtrlAutoWidthMixin.__init__(self)
ListCtrlAutoWidthMixin.__init__(self)

self.items_sort_map = {}
self.itemDataMap = self.items_sort_map
self.items_sort_map = {}
self.itemDataMap = self.items_sort_map

ColumnSorterMixin.__init__(self, 2)
ColumnSorterMixin.__init__(self, 3)

self.InsertColumn(0, "PID")
self.InsertColumn(1, "Process")
self.InsertColumn(0, "PID")
self.InsertColumn(1, "Process")
self.InsertColumn(2, "Ports")


####################################################################################################################
def GetListCtrl (self):
'''
Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
'''
####################################################################################################################
def GetListCtrl (self):
'''
Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
'''

return self
return self


####################################################################################################################
def on_retrieve_list (self, event):
pydbg = self.top.main_frame.pydbg
####################################################################################################################
def on_retrieve_list (self, event):
pydbg = self.top.main_frame.pydbg

self.DeleteAllItems()
self.DeleteAllItems()

idx = 0
for (pid, proc) in pydbg.enumerate_processes():
# ignore system processes.
if pid < 10:
continue
idx = 0
for (pid, proc) in pydbg.enumerate_processes():
# ignore system processes.
if pid < 10:
continue

self.InsertStringItem(idx, "")
self.SetStringItem(idx, 0, "%d" % pid)
self.SetStringItem(idx, 1, proc)
self.InsertStringItem(idx, "")
self.SetStringItem(idx, 0, "%d" % pid)
self.SetStringItem(idx, 1, proc)

portslist = pydbg.pid_to_port(pid)
ports = ""
for (lport, addr, proto) in portslist:
ports += addr + ":" + lport + "/" + proto + " "

self.SetStringItem(idx, 2, ports)

self.items_sort_map[idx] = (pid, proc)
self.SetItemData(idx, idx)
self.items_sort_map[idx] = (pid, proc, ports)
self.SetItemData(idx, idx)

idx += 1
idx += 1

####################################################################################################################
def on_select (self, event):
'''
'''

####################################################################################################################
def on_select (self, event):
'''
'''

self.selected_pid = int(self.GetItem(event.m_itemIndex, 0).GetText())
self.selected_proc = self.GetItem(event.m_itemIndex, 1).GetText()
self.selected_pid = int(self.GetItem(event.m_itemIndex, 0).GetText())
self.selected_proc = self.GetItem(event.m_itemIndex, 1).GetText()
140 changes: 70 additions & 70 deletions console/modules/_PAIMEIpeek/PyDbgDlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#

'''
@author: Pedram Amini
@license: GNU General Public License 2.0 or later
@contact: [email protected]
@author: Pedram Amini
@license: GNU General Public License 2.0 or later
@contact: [email protected]
@organization: www.openrce.org
'''

Expand All @@ -29,70 +29,70 @@

########################################################################################################################
class PyDbgDlg(wx.Dialog):
def __init__(self, *args, **kwds):
self.parent = kwds["parent"]

# begin wxGlade: PyDbgDialog.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)

self.retrieve_list = wx.Button(self, -1, "Retrieve List")
self.process_list = _PAIMEIpeek.ProcessListCtrl.ProcessListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER, top=self.parent)
self.load_target = filebrowse.FileBrowseButton(self, -1, labelText="", fileMask="*.exe", fileMode=wx.OPEN, toolTip="Specify the target executable to load")
self.attach_or_load = wx.Button(self, -1, "Attach / Load")
self.cancel = wx.Button(self, wx.ID_CANCEL)

self.__set_properties()
self.__do_layout()
# end wxGlade

# event bindings.
self.Bind(wx.EVT_BUTTON, self.process_list.on_retrieve_list, self.retrieve_list)
self.Bind(wx.EVT_BUTTON, self.on_attach_or_load, self.attach_or_load)
self.process_list.Bind(wx.EVT_LIST_ITEM_SELECTED, self.process_list.on_select)


####################################################################################################################
def __set_properties(self):
# begin wxGlade: PyDbgDialog.__set_properties
self.SetTitle("Select Target")
self.SetSize((300, 500))
self.retrieve_list.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "MS Shell Dlg 2"))
self.process_list.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "MS Shell Dlg 2"))
self.attach_or_load.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "MS Shell Dlg 2"))
# end wxGlade


####################################################################################################################
def __do_layout(self):
# begin wxGlade: PyDbgDialog.__do_layout
overall = wx.BoxSizer(wx.VERTICAL)
overall.Add(self.retrieve_list, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
overall.Add(self.process_list, 1, wx.EXPAND, 0)
overall.Add(self.load_target, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
button_bar = wx.BoxSizer(wx.HORIZONTAL)
button_bar.Add(self.attach_or_load, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
button_bar.Add(self.cancel, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
overall.Add(button_bar, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
self.SetAutoLayout(True)
self.SetSizer(overall)
self.Layout()
# end wxGlade


####################################################################################################################
def on_attach_or_load (self, event):
'''
Bubble up the attach or load target to the main PAIMEIpeek module.
'''

self.parent.load = self.load_target.GetValue()
self.parent.pid = self.process_list.selected_pid
self.parent.proc = self.process_list.selected_proc
if not self.parent.load and not self.parent.pid and not self.parent.proc:
dlg = wx.MessageDialog(self, "You haven't selected a process to load or attach to.", "Error", wx.OK | wx.ICON_WARNING)
dlg.ShowModal()
return

self.Destroy()
def __init__(self, *args, **kwds):
self.parent = kwds["parent"]

# begin wxGlade: PyDbgDialog.__init__
kwds["style"] = (wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
wx.Dialog.__init__(self, *args, **kwds)

self.retrieve_list = wx.Button(self, -1, "Retrieve List")
self.process_list = _PAIMEIpeek.ProcessListCtrl.ProcessListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER, top=self.parent)
self.load_target = filebrowse.FileBrowseButton(self, -1, labelText="", fileMask="*.exe", fileMode=wx.OPEN, toolTip="Specify the target executable to load")
self.attach_or_load = wx.Button(self, -1, "Attach / Load")
self.cancel = wx.Button(self, wx.ID_CANCEL)

self.__set_properties()
self.__do_layout()
# end wxGlade

# event bindings.
self.Bind(wx.EVT_BUTTON, self.process_list.on_retrieve_list, self.retrieve_list)
self.Bind(wx.EVT_BUTTON, self.on_attach_or_load, self.attach_or_load)
self.process_list.Bind(wx.EVT_LIST_ITEM_SELECTED, self.process_list.on_select)


####################################################################################################################
def __set_properties(self):
# begin wxGlade: PyDbgDialog.__set_properties
self.SetTitle("Select Target")
self.SetSize((300, 500))
self.retrieve_list.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "MS Shell Dlg 2"))
self.process_list.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "MS Shell Dlg 2"))
self.attach_or_load.SetFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "MS Shell Dlg 2"))
# end wxGlade


####################################################################################################################
def __do_layout(self):
# begin wxGlade: PyDbgDialog.__do_layout
overall = wx.BoxSizer(wx.VERTICAL)
overall.Add(self.retrieve_list, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
overall.Add(self.process_list, 1, wx.EXPAND, 0)
overall.Add(self.load_target, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
button_bar = wx.BoxSizer(wx.HORIZONTAL)
button_bar.Add(self.attach_or_load, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
button_bar.Add(self.cancel, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
overall.Add(button_bar, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
self.SetAutoLayout(True)
self.SetSizer(overall)
self.Layout()
# end wxGlade


####################################################################################################################
def on_attach_or_load (self, event):
'''
Bubble up the attach or load target to the main PAIMEIpeek module.
'''

self.parent.load = self.load_target.GetValue()
self.parent.pid = self.process_list.selected_pid
self.parent.proc = self.process_list.selected_proc
if not self.parent.load and not self.parent.pid and not self.parent.proc:
dlg = wx.MessageDialog(self, "You haven't selected a process to load or attach to.", "Error", wx.OK | wx.ICON_WARNING)
dlg.ShowModal()
return

self.Destroy()
Loading