jakesylvestre / androguard

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

get_fields() does not work #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Thanks for taking care of my previous issue so quickly. Unfortunately the next 
two steps I tried also produce unexpected errors:

What steps will reproduce the problem?
Run
a = androguard.AndroguardS("attached jar file")

for i in a.get_fields() :
    print i.get_access(), i.get_name(), i.get_descriptor()

What is the expected output? What do you see instead?

raceback (most recent call last):
  File "./bla.py", line 19, in <module>
    for i in a.get_fields() :
  File "/home/spjsschl/androguard/androguard.py", line 474, in __getattr__
    return getattr(self.__a, value)
AttributeError: 'NoneType' object has no attribute 'get_fields'

What version of the product are you using? On what operating system?
Current mercury androguard on ubuntu oneiric

Johannes

Original issue reported on code.google.com by spjss...@gmail.com on 29 Nov 2011 at 11:55

Attachments:

GoogleCodeExporter commented 9 years ago
The second issue is probably related. Same applet, same code, except I am 
calling a.get_methods()

Traceback (most recent call last):
  File "./bla.py", line 23, in <module>
    for i in a.get_methods() :
  File "/home/spjsschl/androguard/androguard.py", line 474, in __getattr__
    return getattr(self.__a, value)
AttributeError: 'NoneType' object has no attribute 'get_methods'

Original comment by spjss...@gmail.com on 29 Nov 2011 at 11:56

GoogleCodeExporter commented 9 years ago
Ok I'm on it :)

Original comment by anthony....@gmail.com on 30 Nov 2011 at 8:08

GoogleCodeExporter commented 9 years ago
Can you try on the latest revision ?

Original comment by anthony....@gmail.com on 1 Dec 2011 at 7:51

GoogleCodeExporter commented 9 years ago
Sorry, seems my email from last week got lost. Thanks for working  on this.

I have tried the new version and both problems persist, there is no visible 
effect for the changes on my system.
Johannes

Original comment by spjss...@gmail.com on 5 Dec 2011 at 7:13

GoogleCodeExporter commented 9 years ago
Uhm not on my side:

ACC_PROTECTED json/Parser r Ljavax/swing/JList;
ACC_STATIC json/Parser exp [Ljava/lang/String;
ACC_PRIVATE json/Parser jsonData Ljava/lang/String;
ACC_PROTECTED json/Parser d Ljava/util/HashSet;
ACC_PRIVATE json/Parser postfix Ljava/lang/String;
ACC_PROTECTED ACC_STATIC json/Parser dc Ljava/lang/String;
ACC_PUBLIC ACC_STATIC json/Parser v Ljava/lang/String;
ACC_PROTECTED ACC_STATIC json/Parser pt Ljava/lang/String;
ACC_PROTECTED ACC_STATIC json/Parser pfx Ljava/lang/String;
ACC_PUBLIC ACC_STATIC ACC_FINAL json/SmartyPointer e Ljava/lang/String;
ACC_PUBLIC ACC_STATIC ACC_FINAL json/SmartyPointer c Ljava/lang/Class;
ACC_PUBLIC ACC_STATIC ACC_FINAL json/SmartyPointer g Ljava/lang/String;
ACC_PUBLIC ACC_STATIC ACC_FINAL json/SmartyPointer n S
ACC_PUBLIC ACC_STATIC json/ThreadParser m Ljava/lang/reflect/Method;
ACC_PROTECTED ACC_STATIC json/ThreadParser ctr I
ACC_PUBLIC ACC_STATIC json/ThreadParser rw [B
ACC_PRIVATE json/ThreadParser s Ljava/lang/String;
ACC_PRIVATE json/XML j Ljava/util/HashSet;
ACC_PRIVATE ACC_STATIC json/XML i [S
ACC_PUBLIC ACC_STATIC json/XML e Ljava/lang/String;
ACC_FINAL json/XML database Ljson/Parser;

#!/usr/bin/env python

import sys, hashlib

PATH_INSTALL = "./"
sys.path.append(PATH_INSTALL + "/core")
sys.path.append(PATH_INSTALL + "/core/bytecodes")
sys.path.append(PATH_INSTALL + "/core/bytecodes/libdvm/")
sys.path.append(PATH_INSTALL + "/core/analysis")
sys.path.append(PATH_INSTALL + "/core/analysis/libsign")
sys.path.append(PATH_INSTALL + "/classification")

import androguard, jvm

TEST = "./field.jar"

x = jvm.JAR( TEST )                                                             

bc = x.get_classes()

for j in bc :
    vm = jvm.JVMFormat(j[1])

    for i in vm.get_fields() :
        print i.get_access(), i.get_class_name(), i.get_name(), i.get_descriptor()

Original comment by anthony....@gmail.com on 6 Dec 2011 at 7:09

GoogleCodeExporter commented 9 years ago
Your program works even though it has shorter output compared yo your example 
run:

ACC_PRIVATE json/XML j Ljava/util/HashSet;
ACC_PRIVATE ACC_STATIC json/XML i [S
ACC_PUBLIC ACC_STATIC json/XML e Ljava/lang/String;
ACC_FINAL json/XML database Ljson/Parser;

The program that I sent to you initially (and that I used for my testing) still 
does not work:
#!/usr/bin/env python

import sys

PATH_INSTALL = "/home/spjsschl/androguard/"
sys.path.append(PATH_INSTALL)
sys.path.append(PATH_INSTALL + "/core")
sys.path.append(PATH_INSTALL + "/core/bytecodes")
sys.path.append(PATH_INSTALL + "/core/analysis")

import androguard

a = androguard.AndroguardS(sys.argv[1])

# SHOW CLASS (verbose)
#a.show()

# SHOW FIELDS
for i in a.get_fields() :
    print i.get_access(), i.get_name(), i.get_descriptor()

## SHOW METHODS
#for i in a.get_methods() :
#   print i.get_access(), i.get_name(), i.get_descriptor()

output:
Traceback (most recent call last):
  File "./bla.py", line 19, in <module>
    for i in a.get_fields() :
  File "/home/spjsschl/androguard/androguard.py", line 474, in __getattr__
    return getattr(self.__a, value)
AttributeError: 'NoneType' object has no attribute 'get_fields'

Original comment by spjss...@gmail.com on 6 Dec 2011 at 8:16

GoogleCodeExporter commented 9 years ago
Yes I know, could you try with mine ?

Original comment by anthony....@gmail.com on 7 Dec 2011 at 7:16

GoogleCodeExporter commented 9 years ago
I ran your code, see the output in my previous mail.

It is somehow shorter than your example output.

Original comment by spjss...@gmail.com on 8 Dec 2011 at 7:09

GoogleCodeExporter commented 9 years ago
Could you try by changing AndroguardS with JAR + JavaVMFormat ?

Original comment by anthony....@gmail.com on 9 Dec 2011 at 12:21

GoogleCodeExporter commented 9 years ago
any news ?

Original comment by anthony....@gmail.com on 3 Feb 2012 at 6:18

GoogleCodeExporter commented 9 years ago

Original comment by anthony....@gmail.com on 5 Aug 2012 at 9:40