Skip to content

Instantly share code, notes, and snippets.

@alexander-hanel
Created October 16, 2020 21:02
Show Gist options
  • Save alexander-hanel/08af74b4d8f9b46e116f39e7312d9b2e to your computer and use it in GitHub Desktop.
Save alexander-hanel/08af74b4d8f9b46e116f39e7312d9b2e to your computer and use it in GitHub Desktop.
# pip3 install pygore
# modified version of code from https://go-re.tk/pygore/
import glob
import pygore
from hashlib import md5
def go_hash(data):
return md5(b','.join(data)).hexdigest()
for _file in glob.glob("*"):
if _file.endswith(".py") or _file.endswith(".txt"):
continue
try:
f = pygore.GoFile(_file)
c = f.get_compiler_version()
print("File:", _file)
print('Compiler: {}\nTimestamp: {}\nSHA {}'.
format(c.name, c.timestamp, c.sha))
pkgs = f.get_packages()
types = f.get_types()
f.close()
for p in pkgs:
temp = []
for f in p.functions:
temp.append(f.name.encode())
print('Package Hash: {}'.format(go_hash(temp)))
temp = []
for m in p.methods:
tt = m.receiver + m.name
temp.append(tt.encode())
print('Mathods Hash: {}'.format(go_hash(temp)))
temp = []
for t in types:
temp.append(t.name.encode())
print('Mathods Hash: {}'.format(go_hash(temp)))
except Exception as e:
print("ERROR", _file, e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment