tomliamlynch / androguard

Automatically exported from code.google.com/p/androguard
Apache License 2.0
0 stars 0 forks source link

dvm modify get_string #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
modify get_string method to return string matching a specific criteria (e.g. a 
substring)

Original issue reported on code.google.com by liadalex82@gmail.com on 12 Jan 2012 at 2:46

GoogleCodeExporter commented 8 years ago
implementations proposed (both):
    def get_regex_strings(self, regular_expressions) :
        """
            Return all taget strings matched the regex uin input
        """
        str_list = []
        if regular_expressions.count == None :
            return str_list
        for i in self.strings :
            cur_str = i.get()
            for j in expressions.string :
                expr = j.get())
                if re.search(expr, cur_str) :
                    str_list.append(cur_str)
                    break;
        return str_list 

    def get_matched_strings(self, substr) :
        """
            Return all taget strings containing the substr in input
        """
        str_list = []
        if (sustr == None)
            return str_list
        for i in self.strings :
            cur_str = i.get()
            if cur_str.find(substr) != -1 :
                str_list.append(cur_str)
        return str_list 

Original comment by liadalex82@gmail.com on 12 Jan 2012 at 3:09

GoogleCodeExporter commented 8 years ago
Sorry, the previous post contained some syntax errors...I copied the code from 
a wrong version    
def get_regex_strings(self, regular_expressions) :
        """
            Return all taget strings matched the regex uin input
        """
        str_list = []
        if regular_expressions.count is None :
            return None
        for i in self.strings :
            cur_str = i.get()
            for j in expressions.string :
                expr = j.get()
                if re.search(expr, cur_str) :
                    str_list.append(cur_str)
                    break;
        return str_list 

    def get_matched_strings(self, substr) :
        """
            Return all taget strings containing the substr in input
        """
        str_list = []
        if (sustr is None):
            return None
        for i in self.strings :
            cur_str = i.get()
            if cur_str.find(substr) != -1 :
                str_list.append(cur_str)
        return str_list 

Original comment by liadalex82@gmail.com on 19 Jan 2012 at 11:27

GoogleCodeExporter commented 8 years ago
Thx, it will be added :)

Original comment by anthony....@gmail.com on 29 Jan 2012 at 3:15

GoogleCodeExporter commented 8 years ago
Hi,

can you test with the latest mercurial version ?

I added only one function get_regex_strings and you can search a regexp, substr 
...

Original comment by anthony....@gmail.com on 23 Mar 2012 at 9:00

GoogleCodeExporter commented 8 years ago
ok, tested.
It seems ok.

Original comment by liadalex82@gmail.com on 29 Mar 2012 at 1:31

GoogleCodeExporter commented 8 years ago

Original comment by anthony....@gmail.com on 29 Mar 2012 at 3:08