Skip to content
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
4 changes: 2 additions & 2 deletions GO_Utils/Firstmoduledata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Utils
from . import Utils
import idautils
import struct

Expand Down Expand Up @@ -155,4 +155,4 @@ def getTypeinfo(addr, bt):

next *moduledata
}
"""
"""
4 changes: 2 additions & 2 deletions GO_Utils/GoStrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def is_this_a_real_string(next_pos, instr, size_data):
return False, 0

def make_string(addr, siz):
print "Creating string at %x %d size" % (addr, siz)
print("Creating string at %x %d size" % (addr, siz))
idc.MakeUnknown(addr, siz, idc.DOUNK_SIMPLE)
ida_bytes.create_strlit(addr, siz, -1)

Expand All @@ -60,7 +60,7 @@ def stringify():
while position < f.endEA:
instr = idautils.DecodeInstruction(position)
if instr is None:
print "%x: Not and instruction found" % position
print("%x: Not and instruction found" % position)
break
mnem = instr.get_canon_mnem()
if mnem == "mov":
Expand Down
4 changes: 2 additions & 2 deletions GO_Utils/Gopclntab.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import ida_funcs
import ida_search
import ida_segment
import Utils
from . import Utils

info = idaapi.get_inf_structure()
try:
Expand Down Expand Up @@ -43,7 +43,7 @@ def rename(beg, ptr, make_funcs = True):
size = ptr.ptr(pos)
pos += ptr.size
end = pos + (size * ptr.size * 2)
print "%x" % end
print("%x" % end)
while pos < end:
offset = ptr.ptr(pos + ptr.size)
ptr.maker(pos) #in order to get xrefs
Expand Down
20 changes: 10 additions & 10 deletions GO_Utils/Types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Utils
from . import Utils
import ida_bytes
import ida_struct
import idc
Expand Down Expand Up @@ -315,7 +315,7 @@ def handle_offset(self, offset):
#Check if we already parse this
if offset in self.type_addr:
return
print "Processing: %x" % offset
print("Processing: %x" % offset)
self.type_addr.append(offset)

#Set type and get name
Expand All @@ -325,7 +325,7 @@ def handle_offset(self, offset):

#get kind name
kind_name = self.getKindEnumName(offset)
print kind_name
print(kind_name)
if name[0] == "*" and kind_name != "PTR":
name = name[1:]
name = Utils.relaxName(name)
Expand Down Expand Up @@ -427,7 +427,7 @@ def createUserTypeStruct(self, addr, name, size, self_size):
fieldname = "unused_"+Utils.id_generator()
offset = self.getStructFieldOffset(sid, addr+i*sz)
if offset != curr_offset:
print "Offset missmatch.Got %d expected %d. Adding padding..." % (curr_offset, offset)
print("Offset missmatch.Got %d expected %d. Adding padding..." % (curr_offset, offset))
if offset < curr_offset:
raise("Too many bytes already")
while offset != curr_offset:
Expand All @@ -437,14 +437,14 @@ def createUserTypeStruct(self, addr, name, size, self_size):
if size != 0:
offset_kind = idc.get_member_offset(sid_type, "kind")
kind_of_type = self.getKindEnumName(type_addr)
print kind_of_type
print(kind_of_type)
if kind_of_type == "STRUCT_": #Disabled for now
name_type = self.getName(type_addr)
while name_type[0] == "*":
name_type = name_type[1:]
name_type = Utils.relaxName(name_type)
name_type = "ut_" + name_type
#print "setting type %s" % name_type
#print("setting type %s" % name_type)
fields.append((fieldname, name_type))
elif kind_of_type == "STRING":
fields.append((fieldname, "string"))
Expand All @@ -455,7 +455,7 @@ def createUserTypeStruct(self, addr, name, size, self_size):
else:
fields.append((fieldname, "char [%d]" % size))
if curr_offset != self_size:
print "%x: Structure size mismatch: %x" % (addr, curr_offset)
print("%x: Structure size mismatch: %x" % (addr, curr_offset))
if self_size < curr_offset:
raise("Too many bytes already")
while self_size != curr_offset:
Expand All @@ -466,11 +466,11 @@ def createUserTypeStruct(self, addr, name, size, self_size):
new_type_sid = ida_struct.get_struc_id(name)
sz = ida_struct.get_struc_size(new_type_sid)
if sz != self_size:
print "%x" % addr
print("%x" % addr )
raise("Error at creating structure")

def getType(self, addr):
print "%x" % addr
print("%x" % addr)
sid = ida_struct.get_struc_id("type")
name = self.getName(addr)
if self.getKindEnumName(addr) != "PTR":
Expand Down Expand Up @@ -627,4 +627,4 @@ def __init__(self, pos, endpos, step, settings, base_type):
self.robase = base_type

def getStructFieldOffset(self, sid, addr):
return (self.getPtr(sid, addr, "offset") >> 1)
return (self.getPtr(sid, addr, "offset") >> 1)
12 changes: 6 additions & 6 deletions GO_Utils/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def rename(offset, name):


def relaxName(name):
name = name.replace('.', '_').replace("<-", '_chan_left_').replace('*', '_ptr_').replace('-', '_').replace(';','').replace('"', '').replace('\\', '')
name = name.replace('(', '').replace(')', '').replace('/', '_').replace(' ', '_').replace(',', 'comma').replace('{','').replace('}', '').replace('[', '').replace(']', '')
return name
name = name.replace(b'.', b'_').replace(b"<-", b'_chan_left_').replace(b'*', b'_ptr_').replace(b'-', b'_').replace(b';', b'').replace(b'"', b'').replace(b'\\', b'')
name = name.replace(b'(', b'').replace(b')', b'').replace(b'/', b'_').replace(b' ', b'_').replace(b',', b'comma').replace(b'{', b'').replace(b'}', b'').replace(b'[', b'').replace(b']', b'')
return name.decode(encoding = "ISO-8859-1")


def get_bitness(addr):
Expand Down Expand Up @@ -86,16 +86,16 @@ def fillStruct(self, sid, data):
res = idc.add_struc_member(sid, i[0], -1, i1, i2, i3)
use_name = i[0]
if res == -1: #Bad name
#print "Bad name %s for struct member" % i[0]
#print("Bad name %s for struct member" % i[0])
use_name = i[0] + "_autogen_"+id_generator()
idc.add_struc_member(sid, use_name, -1, i1, i2, i3)
if new_type is not None:
offset = idc.get_member_offset(sid, use_name)
#print "Setting %s as %s" % (i[0], new_type)
#print("Setting %s as %s" % (i[0], new_type))
idc.SetType(idc.get_member_id(sid, offset), new_type)

def makeStruct(self, i):
print "Creating structure %s" % (i[0])
print("Creating structure %s" % (i[0]))
sid = self.createStruct(i[0])
self.fillStruct(sid, i[1])

Expand Down
16 changes: 8 additions & 8 deletions GO_Utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import idaapi
import Gopclntab
import Utils
import Firstmoduledata
import Types
from . import Gopclntab
from . import Utils
from . import Firstmoduledata
from . import Types
import idc
import idautils
import ida_ida
Expand Down Expand Up @@ -125,7 +125,7 @@ def typesModuleData(self, typ):
else:
beg, end = Firstmoduledata.getTypeinfo(fmd, self.bt_obj)
self.processor = Types.TypeProcessing(beg, end, self.bt_obj, self)
print "%x %x %x" % (beg, end, robase)
for i in self.processor:
pass
return
print("%x %x %x" % (beg, end, robase))
# for i in self.processor:
# pass
return
6 changes: 3 additions & 3 deletions go_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def __init__(self):

def OnButton1(self, code=0):
GO_SETTINGS.findModuleData()
print GO_SETTINGS.tryFindGoVersion()
print(GO_SETTINGS.tryFindGoVersion())


def OnButton3(self, code=0):
GO_SETTINGS.renameFunctions()

def OnButton2(self, code=0):
print GO_SETTINGS.getVersionByString()
print(GO_SETTINGS.getVersionByString())

def OnButton4(self, code=0):
typ = self.GetControlValue(self.cGoVers)
Expand Down Expand Up @@ -97,4 +97,4 @@ def ida_main():


# --------------------------------------------------------------------------
ida_main()
ida_main()