Skip to content

Commit

Permalink
Improve style, remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Gascon committed May 2, 2016
1 parent b08926e commit a0b5672
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 43 deletions.
66 changes: 33 additions & 33 deletions adagio/common/pz.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,42 @@
import gzip


def save(object, filename, bin = 1):
"""Saves a compressed object to disk
"""
file = gzip.GzipFile(filename, 'wb')
file.write(pickle.dumps(object, bin))
file.close()
def save(object, filename, bin=1):
"""Saves a compressed object to disk
"""
file = gzip.GzipFile(filename, 'wb')
file.write(pickle.dumps(object, bin))
file.close()


def load(filename):
"""Loads a compressed object from disk
"""
file = gzip.GzipFile(filename, 'rb')
buffer = ""
while 1:
data = file.read()
if data == "":
break
buffer += data
object = pickle.loads(buffer)
file.close()
return object
"""Loads a compressed object from disk
"""
file = gzip.GzipFile(filename, 'rb')
buffer = ""
while 1:
data = file.read()
if data == "":
break
buffer += data
object = pickle.loads(buffer)
file.close()
return object


if __name__ == "__main__":
import sys
import os.path
class Object:
x = 7
y = "This is an object."
filename = sys.argv[1]
if os.path.isfile(filename):
o = load(filename)
print "Loaded %s" % o
else:
o = Object()
save(o, filename)
print "Saved %s" % o
import sys
import os.path

class Object:
x = 7
y = "This is an object."

filename = sys.argv[1]
if os.path.isfile(filename):
o = load(filename)
print "Loaded %s" % o
else:
o = Object()
save(o, filename)
print "Saved %s" % o
20 changes: 10 additions & 10 deletions adagio/core/apicalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import os
from progressbar import *
from modules.androguard import *
from modules.androguard.core.analysis import *
from modules.androlyze import *
from modules.androguard.androguard.core.analysis import *
from modules.androguard.androlyze import *
from pandas import DataFrame

########################################################################
# Android API Calls related functions #
Expand All @@ -29,11 +30,11 @@ def list_calls(file):
for method in d.get_methods():
for i in method.get_instructions():
if i.get_name()[:6] == "invoke":
#get method desc
# get method desc
call = i.get_output(0).split(',')[-1].strip()
#remove return value
# remove return value
call = call[:call.index(')')+1]
#split in class and method
# split in class and method
call = call.split('->')
method_class = get_type(call[0])
ins_method, params = call[1].split('(')
Expand All @@ -56,11 +57,11 @@ def list_calls_with_permissions(file, permission_map_file):
for method in d.get_methods():
for i in method.get_instructions():
if i.get_name()[:6] == "invoke":
#get method desc
# get method desc
call = i.get_output(0).split(',')[-1].strip()
#remove return value
# remove return value
call = call[:call.index(')')+1]
#split in class and method
# split in class and method
call = call.split('->')
method_class = get_type(call[0])
ins_method, params = call[1].split('(')
Expand Down Expand Up @@ -106,11 +107,10 @@ def list_XREF(file):
try:
a, d, dx = AnalyzeAPK(file)
except zipfile.BadZipfile:
#if file is not an APK, may be a dex object
# if file is not an APK, may be a dex object
d, dx = AnalyzeDex(file)

for method in d.get_methods():
print get_node_name(method)
print "XREFfrom:", [get_node_name(m[0]) for m in method.XREFfrom.items]
print "XREFto:", [get_node_name(m[0]) for m in method.XREFto.items]

0 comments on commit a0b5672

Please sign in to comment.