Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'getSourceIndex' #1

Open
salomon1184 opened this issue Jul 30, 2015 · 2 comments
Open

Comments

@salomon1184
Copy link

AttributeError: 'NoneType' object has no attribute 'getSourceIndex'

@salomon1184
Copy link
Author

author = 'flanker'
'''
Util to extract Source info from dex and restore class name from proguard
'''
from jeb.api import IScript
from jeb.api.ui import View
from collections import defaultdict

class sourceinfofucker(IScript):

def run(self, j):
    self.instance = j
    self.dex = j.getDex()

    pool = defaultdict(list)

    #ignore invalid source, i.e. "proguard" and other self-defined string
    for i in self.dex.getClassSignatures(True):
        cls = self.dex.getClass(i)
        #self.instance.print("Log: %s"%cls.getData())
        if cls is None:
            continue
        sourceIdx = cls.getSourceIndex()
        if sourceIdx != -1:
            source = self.dex.getString(sourceIdx)
            if source == "" or source.lower() == "proguard":
                continue
            if source.endswith(".java"):
                source = source[:-5]
            pool[source].append(i)

    if len(pool.keys()) == 0:
        self.instance.print("fuck! no class source info found.")
    elif len(pool.keys()) <= 2:
        #less than two distinct keys, we're fooled
        self.instance.print("fuck! we're fooled by %s. Stopping now" % pool.keys()[0])
    else:
        self.instance.print("renaming %d classes"%(len(pool.keys())))
        for k, v in pool.iteritems():
            for origin in v:
                #notice some inner class may share same Source Info
                self.instance.print("renaming from %s to %s" % (origin,k))
                self.instance.renameClass(origin, k)
        self.instance.print("renaming done")

        self.instance.getUI().getView(View.Type.JAVA).refresh()
        self.instance.getUI().getView(View.Type.ASSEMBLY).refresh()
        self.instance.getUI().getView(View.Type.CLASS_HIERARCHY).refresh()

@flankerhqd
Copy link
Owner

Thanks for the report, can you provide test APK that can reproduce this issue? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants