def outputBinaryPackageList(self):
     f = pygore.GoFile(self.binaryPath)
     gopkgs_1 = f.get_packages()
     gopkgs_2 = f.get_vendor_packages()
     gopkgs_3 = f.get_std_lib_packages()
     gopkgs_4 = f.get_unknown_packages()
     f.close()
     pkg_file = codecs.open(self.binaryPath + "_packages.txt",
                            "w",
                            encoding="utf-8")
     pkg_file.write("Current Package:\n")
     for i in gopkgs_1:
         pkg_file.write(i.name + "\n")
     pkg_file.write("\n\nVendor Packages:\n")
     for i in gopkgs_2:
         pkg_file.write(i.name + "\n")
     pkg_file.write("\n\nStandard Libraries:\n")
     for i in gopkgs_3:
         pkg_file.write(i.name + "\n")
     pkg_file.write("\n\nUnclassified Packages:\n")
     for i in gopkgs_4:
         pkg_file.write(i.name + "\n")
     pkg_file.close()
     print "Package info saved to " + self.binaryPath + "_packages.txt"
     return
Ejemplo n.º 2
0
    def renameStructs(self):
        f = pygore.GoFile(self.binaryPath)
        c = f.get_compiler_version()
        print('Compiler: {}\nTimestamp: {}\nSHA {}\n'.format(
            c.name, c.timestamp, c.sha))

        #pkgs = f.get_packages()
        types = f.get_types()
        f.close()
        for t in types:
            Utils.rename(t.addr, t.name)

            self.structsDef[t.addr] = self._getStructDef(t)
            print t.addr, t.name
    def renameStructs(self):
        f = pygore.GoFile(self.binaryPath)
        c = f.get_compiler_version()
        print('Compiler: {}\nTimestamp: {}\nSHA {}\n'.format(
            c.name, c.timestamp, c.sha))

        #pkgs = f.get_packages()
        types = f.get_types()
        f.close()
        struct_file = codecs.open(self.binaryPath + "_struct.txt",
                                  "w",
                                  encoding="utf-8")
        for t in types:
            Utils.rename(t.addr, t.name)
            self.structsDef[t.addr] = self._getStructDef(t)
            struct_file.write(str(t.addr) + " " + str(t.name) + "\n")
        print "Struct info saved to " + self.binaryPath + "_struct.txt"
        struct_file.close()
Ejemplo n.º 4
0
 def tryFindGoVersion(self):
     f = pygore.GoFile(self.binaryPath)
     v = f.get_compiler_version()
     f.close()
     return "Go Compiler Version should be %s" % (v.name)
Ejemplo n.º 5
0
 def setUp(self):
     self.file = pygore.GoFile(golden_file)
Ejemplo n.º 6
0
import pygore

testfile = '/path/to/file'

f = pygore.GoFile(testfile)
c = f.get_compiler_version()

print('Compiler: {}\nTimestamp: {}\nSHA {}\n'.format(c.name, c.timestamp,
                                                     c.sha))

pkgs = f.get_packages()
types = f.get_types()
f.close()
for p in pkgs:
    print('Package: {}'.format(p.name))
    print("Functions:")
    for f in p.functions:
        print('{} from {} to {}'.format(f.name, hex(f.offset), hex(f.end)))
    print("Methods:")
    for m in p.methods:
        print('{} {} from {} to {}'.format(m.receiver, m.name, hex(m.offset),
                                           hex(m.end)))

    print("Types:")
    for t in types:
        print('Package path: {} | Type name: {}'.format(t.packagePath, t.name))
Ejemplo n.º 7
0
 def setUp(self):
     golden_file = os.path.dirname(__file__) + '/' + 'resources/bettercap'
     self.file = pygore.GoFile(golden_file)