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

Restore 'androguard cg' callgraph generation #985

Merged
merged 18 commits into from Jan 3, 2024
Merged

Conversation

ehrenb
Copy link
Contributor

@ehrenb ehrenb commented Dec 31, 2023

  • Readded several dependencies, such as networkx, matplotlib, pyyaml, and pyqt5 to generate and render callgraphs
  • Readded previous get_call_graph() function and made a few fixes
  • fixed some docstring inaccuracies with MethodAnalysis xref_from/to
  • Can export callgraphs to gml, gexf, graphml, and net (pajek), but not gpickel or yaml because there are embedded attributes that are not serializable in EncodedMethod objects (BufferedReader in EncodedMethod.buff).

Tested with the following commands:

androguard --verbose cg --show --classname "Ltests/androguard/*" ~/projects/androguard/tests/data/APK/TestActivity.apk

ex1

androguard --verbose cg --show --methodname "Test*" ~/projects/androguard/tests/data/APK/TestActivity.apk

ex2

androguard --verbose cg --show --descriptor '\(LTestDefaultPackage;\sI\sI\sLTestDefaultPackage\$TestInnerClass;\)V' ~/projects/androguard/tests/data/APK/TestActivity.apk

ex3

…displaying them with matplotlib. still need to save raw graph formats
…ajek) formats. document current limitation that is preventing yaml and gpickle due to BufferedReader attributes not being serializable. created --output-type option for specifying graph format to export
…include the callee method EncodedMethod attribute instead of the the MethodAnalysis
…odAnalysis object, not an EncodedMethod or ExternalMethod
…thodAnalysis object, not an EncodedMethod or ExternalMethod
@erev0s
Copy link
Collaborator

erev0s commented Jan 1, 2024

@ehrenb thank you very much for this!!

  • There seems to be an error while installing the dependencies Unable to find installation candidates for pyqt5-qt5 (5.15.12).
  • Could you also please generate a few tests (test_callGraph.py) in the corresponding directory. I believe it is essential in making sure any future changes dont break things.

@ehrenb
Copy link
Contributor Author

ehrenb commented Jan 1, 2024

@ehrenb thank you very much for this!!

* There seems to be an error while installing the dependencies `Unable to find installation candidates for pyqt5-qt5 (5.15.12)`.

* Could you also please generate a few tests (test_callGraph.py) in the corresponding directory. I believe it is essential in making sure any future changes dont break things.

Yes, I'll have this done in a couple of days hopefully. When it's done I'll let you know here.

@ehrenb ehrenb marked this pull request as draft January 1, 2024 21:33
…hl files for other platforms. For some reason, recent version of the subpackage are only marked for macos. Pip does not have this issue, only Poetry. see python-poetry/poetry#8540 and corrscope/corrscope@060f044
@erev0s
Copy link
Collaborator

erev0s commented Jan 2, 2024

i see also the note for installing :

apt-get install libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev

if i am not mistaken these are required only for opening the exported formats, right?
Then, maybe i can add that info along with the examples you shared above in the wiki page (which needs to be updated anyway)

@ehrenb
Copy link
Contributor Author

ehrenb commented Jan 2, 2024

i see also the note for installing :

apt-get install libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev

if i am not mistaken these are required only for opening the exported formats, right? Then, maybe i can add that info along with the examples you shared above in the wiki page (which needs to be updated anyway)

Those dependencies were required for using the '--show' flag which uses matplotlib + qt5 to render. I had to install them on Ubuntu 22.04, but did not test other OS's or Ubuntu versions. Feel free to add them in where you'd like, for now I've put them in the README.

@ehrenb ehrenb marked this pull request as ready for review January 3, 2024 03:57
@ehrenb
Copy link
Contributor Author

ehrenb commented Jan 3, 2024

Please take another look at the latest. The QT dependency issue was specific to Poetry, and is fixed by locking it to a specific subpackage of PyQt5 (subpackage PyQt5-Q5, which is confusing). I also added test_callgraph.py with tests that validate number of nodes and edges in various scenarios within TestActivity.apk.

@erev0s erev0s merged commit 4dcdd81 into androguard:master Jan 3, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants