コード例 #1
0
def usage():
	global th, hp, nPath, rAddr, memList, mapList, listing,lstList,runtime, path, jvm, jvm2
	if len(sys.argv) == 2 and sys.argv[1]=="-h":
		help()
	elif len(sys.argv) < 3:
		print "Insufficient arguments. Try -h for usage and command options"
	else:
		import artThread as tSelf
		import artHeap as heap
		import artField as fld
		import artJVM as jvm
		import artJVM2 as jvm2
		from collections import OrderedDict
		import struct
		path = sys.argv[1] 		
		if (sys.argv[2]=="Runtime"):#Option to print the Runtime offset
			getRuntime()
		else:
			[nPath, rAddr, memList, mapList, listing,lstList,runtime]=art.main(path)
			th = tSelf.android_threads() # Global Thread Object
			hp = heap.android_heap()	# Global Heap Object
			if (sys.argv[2] == "Threads"): #Option to print threads names and tids
				getThreads()
			elif (sys.argv[2] == "Heap"):#Option to print Heap meta data - offset, regions and number of objects in regions
				getHeap()
			elif (sys.argv[2] == "HeapDump"): #Option to dump ALL Heap data
				getHeapDump()	
			else:
				print "Invalid Option"
コード例 #2
0
def getRuntime():
	try:
		runtime_ = art.getRuntime(art.path)
		print "_ZN3art7Runtime9instance_E offset = "+ runtime_
		[nPath, rAddr, memList, mapList,listing, lstList,runtime] = art.main(art.path)
		print "Runtime Base Address = "+ runtime
	except:
		print "libart.so not in path"
コード例 #3
0
def usage():
    global th, hp, nPath, rAddr, memList, mapList, listing, lstList, runtime, path, jvm, jvm2, jni
    if len(sys.argv) == 2 and sys.argv[1] == "-h":
        help()
    elif len(sys.argv) < 3:
        print "Insufficient arguments. Try -h for usage and command options"
    else:
        import artThread as tSelf
        import artHeap as heap
        import artField as fld
        import artJVM as jvm
        import artJVM2 as jvm2
        from collections import OrderedDict
        import struct
        #import os, subprocess
        #pid = os.getpid()
        #procs = subprocess.check_output([ "lsof", '-w', '-Ff', "-p", str(pid)]).split('\n')
        #print len(procs)
        #system.exit()
        path = sys.argv[1]
        if (sys.argv[2] == "Runtime"):  #Option to print the Runtime offset
            getRuntime()
        else:
            [nPath, rAddr, memList, mapList, listing, lstList,
             runtime] = art.main(path)
            th = tSelf.android_threads()  # Global Thread Object
            hp = heap.android_heap()  # Global Heap Object
            if (sys.argv[2] == "Threads"
                ):  #Option to print threads names and tids
                if len(sys.argv) > 3:
                    getThreads('o')  #print opeer threads
                else:
                    getThreads('t')  #Option to print threads names and tids
            elif (
                    sys.argv[2] == "Heap"
            ):  #Option to print Heap meta data - offset, regions and number of objects in regions
                getHeap()
            elif (sys.argv[2] == "HeapDump"):  #Option to dump ALL Heap data
                getHeapDump()
            elif (sys.argv[2] == "IndirectRefs"):
                import artJNI as jni
                getIRefs()
            #elif (sys.argv[2]=="Monitor"):
            #	addr = '0x84f6d4d2'
            #	getThreadFromMon(addr)
            elif (sys.argv[2] == "GetGlobs"):
                [TLAB, NonTLAB, threads, bitmap_size_,
                 heapBegin_] = getGlobals()
                return [
                    threads, hp, bitmap_size_, heapBegin_, nPath, rAddr,
                    memList, mapList, listing, lstList, runtime
                ]
            else:
                print "Invalid Option"
コード例 #4
0
'''path = art.path
nPath = art.nPath
rAddr = art.rAddr
memList = art.memList
mapList = art.mapList
listing = art.listing
lstList = art.lstList
runtime = art.runtime'''

if os.path.isdir(sys.argv[1]):
    path = sys.argv[1]
    print path
else:
    path = sys.argv[2]
#art.path = path
[nPath, rAddr, memList, mapList, listing, lstList, runtime] = art.main(path)


def getNFPath(name):
    old = name[name.index("-") + 1:name.index(".")]
    new = str(int(name[name.index("-") + 1:name.index(".")]) + 1)
    return name.replace(old, new)


def getJVMPointer(nPath, rAddr):
    k = art.getFhandle(nPath)
    index = art.getIndex('Runtime', 'java_vm_')
    k.seek(rAddr + index)
    return hex(unpack_int(k.read(4))[0])