Git Product home page Git Product logo

andbug's Introduction

AndBug -- A Scriptable Android Debugger

AndBug is a debugger targeting the Android platform's Dalvik virtual machine intended for reverse engineers and developers. It uses the same interfaces as Android's Eclipse debugging plugin, the Java Debug Wire Protocol (JDWP) and Dalvik Debug Monitor (DDM) to permit users to hook Dalvik methods, examine process state, and even perform changes.

Unlike Google's own Android Software Development Kit debugging tools, AndBug does not require or expect source code. It does, however, require that you have some level of comfort with Python, as it uses a concept of scripted breakpoints, called "hooks", for most nontrivial tasks. (If you just want to dump loaded classes, methods, or threads, there are example scripts for that.)

-- Scott Dunlop <[email protected]>

Installation

AndBug is very much a program in flux, as I seperate one-off scripts I have written at IOActive for various tasks from customer and IOActive-proprietary contexts. I do not recommend installation at this time, as you will want to update it frequently afterwards. AndBug runs very nicely from its own source directory with very little setup.

  1. Install the Android Software Development Kit from https://developer.android.com/sdk/index.html

  2. Ensure the Android Debugging Bridge is in your $PATH and usable.

    which adb adb devices

  3. Ensure you have a good Python and GNU toolchain for your platform. You will need GCC, and Make. You may also want Pyrex, if you want to make changes at the primitive layer.

  4. Pull the latest AndBug code from https://github.com/swdunlop/AndBug.git

    git clone https://github.com/swdunlop/AndBug.git

  5. Build using Make

    make

  6. Adjust $PYTHONPATH

    export PYTHONPATH=`pwd`/lib

Examples

Examples can be found in the sample directory, but the easiest way to find prepackaged functionality in AndBug is using the "andbug" command directly.

./andbug

This command does not currently have the intelligence to automatically detect when it is running from the source directory and update the PYTHONPATH on the fly to match. You will want to make sure that PYTHONPATH includes your andbug/lib directory.

Common Problems

Q: I get "Permission Denied" when trying to use AndBug, but "adb shell" works.

A: Your adbd is probably running as another user, blocking the effective use of ADB forward. Use "adb kill-server" then "adb start-server" with the correct effective user.

Q: I get "Shell Exception" when trying to use AndBug.

A: Verify that your ADB setup is working using "adb devices" -- AndBug relies on ADB for a JDWP transport.

Q: Does AndBug work on Windows?

A: I think so; but since AndBug is unsupported software, you may experience less hand holding than Windows users are accustomed to. Patches are welcome.

Q: Does AndBug work on Mac OS X?

A: Yes, but see the snarkiness about Windows users. You didn't find this in an app store..

Q: Navi gives me an RequestError 13.

A: You have resumed the process; Navi can only safely interact with suspended processes. Use "suspend" again.

Q: I get "EOF in read" when sending a commmand.

A: Ensure that no other debuggers are connected, such as DDMS.

License

Copyright 2011, IOActive All rights reserved.

AndBug is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation.

AndBug is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with AndBug. If not, see <http://www.gnu.org/licenses/>.

andbug's People

Contributors

czbix avatar mrbrutti avatar ncalexan avatar swdunlop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

andbug's Issues

No module named andbug

When I excute "./andbug shell -p 19680"
it hint the error:
File "./andbug", line 66, in
main(args)
File "./andbug", line 28, in main
import andbug, andbug.cmd, andbug.command
ImportError: No module named andbug

ParseError: could not determine if path is a JNI or logical class path

when break on method, Error as the title showed .

and below is the error stack:

-- File "/usr/local/lib/python2.7/dist-packages/andbug/command.py", line 152, in perform
act(self, _args, *_kwargs)
-- File "/usr/local/lib/python2.7/dist-packages/andbug/cmd/break.py", line 69, in cmd_break
cpath, mname, mjni = andbug.options.parse_mquery(cpath, mquery)
-- File "/usr/local/lib/python2.7/dist-packages/andbug/options.py", line 43, in parse_mquery
cp = parse_cpath(cp)
-- File "/usr/local/lib/python2.7/dist-packages/andbug/options.py", line 27, in parse_cpath
raise ParseError('could not determine if path is a JNI or logical class path', path)

andbug shell crashes on shlex exception

## AndBug (C) 2011 Scott W. Dunlop <[email protected]>
>> navi\
## ValueError: No escaped character
   -- File "/home/scott/andbug/lib/andbug/command.py", line 152, in perform
      act(self, *args, **kwargs)
   -- File "/home/scott/andbug/lib/andbug/cmd/shell.py", line 50, in shell
      cmd = shlex.split(input())

vm unpackString does not tolerate invalid unicode

Due to how Python handles unicode, vm.unpackString can fail with decoding errors when invalid codepoints are received from Dalvik. For forensic use, this is terrible behavior.

To support this, a wrapper class should be written that preserves this data as a bytestring and presents Python unicode strings with omitted invalid codepoints as a str to prevent dependent functions from throwing exceptions when operating on derived data.

See also how vm unpacks chr's:

9ae4bd2#commitcomment-1426109

!! [Errno 32] Broken pipe

Does this tool only works on rooted device? I tried this on rooted device and it works fine ,but on one unrooted device, it reported errors like below:

! [Errno 32] Broken pipe
Traceback (most recent call last):
File "./andbug", line 34, in main
andbug.command.run_command(args)
File "/usr/local/lib/python2.7/dist-packages/andbug/command.py", line 220, in run_command
return ctxt.perform(args[0], args[1:])
File "/usr/local/lib/python2.7/dist-packages/andbug/command.py", line 150, in perform
if act.proc: self.connect()
File "/usr/local/lib/python2.7/dist-packages/andbug/command.py", line 60, in connect
self.sess = andbug.vm.connect(self.pid, self.dev)
File "/usr/local/lib/python2.7/dist-packages/andbug/vm.py", line 1157, in connect
conn = andbug.proto.connect(andbug.proto.forward(pid, dev))
File "/usr/local/lib/python2.7/dist-packages/andbug/proto.py", line 97, in connect
p.start()
File "/usr/local/lib/python2.7/dist-packages/andbug/proto.py", line 277, in start
self.writeHandshake()
File "/usr/local/lib/python2.7/dist-packages/andbug/proto.py", line 168, in writeHandshake
return self.write(HANDSHAKE_MSG)
File "/usr/local/lib/python2.7/dist-packages/andbug/proto.py", line 94, in write
raise EOF(exc)
EOF: [Errno 32] Broken pipe

Failed when debug android 6.0 devices, due to oat?

./andbug shell -p 8861
!! [Errno 104] Connection reset by peer
Traceback (most recent call last):
File "./andbug", line 34, in main
andbug.command.run_command(args)
File "/home/tonywu/andebug/AndBug/lib/andbug/command.py", line 220, in run_command
return ctxt.perform(args[0], args[1:])
File "/home/tonywu/andebug/AndBug/lib/andbug/command.py", line 150, in perform
if act.proc: self.connect()
File "/home/tonywu/andebug/AndBug/lib/andbug/command.py", line 60, in connect
self.sess = andbug.vm.connect(self.pid, self.dev)
File "/home/tonywu/andebug/AndBug/lib/andbug/vm.py", line 1157, in connect
conn = andbug.proto.connect(andbug.proto.forward(pid, dev))
File "/home/tonywu/andebug/AndBug/lib/andbug/proto.py", line 97, in connect
p.start()
File "/home/tonywu/andebug/AndBug/lib/andbug/proto.py", line 278, in start
self.readHandshake()
File "/home/tonywu/andebug/AndBug/lib/andbug/proto.py", line 162, in readHandshake
data = self.read(len(HANDSHAKE_MSG))
File "/home/tonywu/andebug/AndBug/lib/andbug/proto.py", line 132, in read
pkt = self._read(sz)
File "/home/tonywu/andebug/AndBug/lib/andbug/proto.py", line 79, in read
pkt = conn.recv(req)
error: [Errno 104] Connection reset by peer

error on multiple device

andbug give error if adb connect to multiple devices.

$ ./andbug classes org.owasp.goatdroid.fourgoats -d 192.168.56.101:5555 -p 1648
!!
Traceback (most recent call last):
File "./andbug", line 34, in main
andbug.command.run_command(args)
File "/opt/tools/android/AndBug/lib/andbug/command.py", line 220, in run_command
return ctxt.perform(args[0], args[1:])
File "/opt/tools/android/AndBug/lib/andbug/command.py", line 150, in perform
if act.proc: self.connect()
File "/opt/tools/android/AndBug/lib/andbug/command.py", line 60, in connect
self.sess = andbug.vm.connect(self.pid, self.dev)
File "/opt/tools/android/AndBug/lib/andbug/vm.py", line 1157, in connect
conn = andbug.proto.connect(andbug.proto.forward(pid, dev))
File "/opt/tools/android/AndBug/lib/andbug/proto.py", line 57, in forward
pid = andbug.util.find_pid(pid)
File "/opt/tools/android/AndBug/lib/andbug/util.py", line 123, in find_pid
ps = adb(*ps)
File "/opt/tools/android/AndBug/lib/andbug/util.py", line 96, in adb
return sh(seq("adb", *args))
File "/opt/tools/android/AndBug/lib/andbug/util.py", line 61, in sh
if not no_fail: raise ShellException( command, output, status )
ShellException

Add Q/A to "Common Problems" in Readme

Q: I get this error:

Traceback (most recent call last):
File "./andbug", line 28, in main
andbug.command.run_command(args)
File "/home/felipe/AndBug/lib/andbug/command.py", line 220, in run_command
return ctxt.perform(args[0], args[1:])
File "/home/felipe/AndBug/lib/andbug/command.py", line 150, in perform
if act.proc: self.connect()
File "/home/felipe/AndBug/lib/andbug/command.py", line 60, in connect
self.sess = andbug.vm.connect(self.pid, self.dev)
File "/home/felipe/AndBug/lib/andbug/vm.py", line 921, in connect
conn = andbug.proto.connect(andbug.proto.forward(pid, dev))
File "/home/felipe/AndBug/lib/andbug/proto.py", line 97, in connect
p.start()
File "/home/felipe/AndBug/lib/andbug/proto.py", line 278, in start
self.readHandshake()
File "/home/felipe/AndBug/lib/andbug/proto.py", line 162, in readHandshake
data = self.read(len(HANDSHAKE_MSG))
File "/home/felipe/AndBug/lib/andbug/proto.py", line 132, in read
pkt = self._read(sz)
File "/home/felipe/AndBug/lib/andbug/proto.py", line 80, in read
if not pkt: raise EOF()
EOF: EOF

A: You can't run AndBug with DDMS running. Try shutting it down first.

error constant in code?

in andbug.vm.Thread.suspend
...
conn.request(0x0B01, buf.data())
why it's not 0x0B02? mistake?

Same problem with rising EOF

It runs on MAC, no other known debuggers running, target is Android 4.3 tablet, adb shell works, debugging support in settings enabled.

./andbug shell -d C5OKCT042449 -p com.android.settings
!! EOF
Traceback (most recent call last):
File "./andbug", line 34, in main
andbug.command.run_command(args)
File "/Users/matlas/cvc/AndBug/lib/andbug/command.py", line 220, in run_command
return ctxt.perform(args[0], args[1:])
File "/Users/matlas/cvc/AndBug/lib/andbug/command.py", line 150, in perform
if act.proc: self.connect()
File "/Users/matlas/cvc/AndBug/lib/andbug/command.py", line 60, in connect
self.sess = andbug.vm.connect(self.pid, self.dev)
File "/Users/matlas/cvc/AndBug/lib/andbug/vm.py", line 1157, in connect
conn = andbug.proto.connect(andbug.proto.forward(pid, dev))
File "/Users/matlas/cvc/AndBug/lib/andbug/proto.py", line 97, in connect
p.start()
File "/Users/matlas/cvc/AndBug/lib/andbug/proto.py", line 278, in start
self.readHandshake()
File "/Users/matlas/cvc/AndBug/lib/andbug/proto.py", line 162, in readHandshake
data = self.read(len(HANDSHAKE_MSG))
File "/Users/matlas/cvc/AndBug/lib/andbug/proto.py", line 132, in read
pkt = self._read(sz)
File "/Users/matlas/cvc/AndBug/lib/andbug/proto.py", line 80, in read
if not pkt: raise EOF()
EOF: EOF

andbug erro

Hello ! When I first use Andbug , I get some error . The fellow is the description of the erros:
~$ andbug shell -p 2785
!! [Errno 104] Connection reset by peer
Traceback (most recent call last):
File "/home/tiankai/git-hub/AndBug/andbug", line 34, in main
andbug.command.run_command(args)
File "/usr/local/lib/python2.7/dist-packages/andbug/command.py", line 220, in run_command
return ctxt.perform(args[0], args[1:])
File "/usr/local/lib/python2.7/dist-packages/andbug/command.py", line 150, in perform
if act.proc: self.connect()
File "/usr/local/lib/python2.7/dist-packages/andbug/command.py", line 60, in connect
self.sess = andbug.vm.connect(self.pid, self.dev)
File "/usr/local/lib/python2.7/dist-packages/andbug/vm.py", line 1157, in connect
conn = andbug.proto.connect(andbug.proto.forward(pid, dev))
File "/usr/local/lib/python2.7/dist-packages/andbug/proto.py", line 97, in connect
p.start()
File "/usr/local/lib/python2.7/dist-packages/andbug/proto.py", line 278, in start
self.readHandshake()
File "/usr/local/lib/python2.7/dist-packages/andbug/proto.py", line 162, in readHandshake
data = self.read(len(HANDSHAKE_MSG))
File "/usr/local/lib/python2.7/dist-packages/andbug/proto.py", line 132, in read
pkt = self._read(sz)
File "/usr/local/lib/python2.7/dist-packages/andbug/proto.py", line 79, in read
pkt = conn.recv(req)
error: [Errno 104] Connection reset by peer

I don know how to fix it. So I want get your help ! thank!

ImportError shirom dahanet

ریده ای بد ریدی این چیه اخه
Traceback (most recent call last):
File "setup.py", line 20, in
from os.path import splitext, basename, join as pjoin, walk
ImportError: cannot import name 'walk' from 'posixpath' (/usr/lib/python3.8/posixpath.py)

what can i do with this?

ImportError shirom dahanet

ریده ای بد ریدی این چیه اخه
Traceback (most recent call last):
File "setup.py", line 20, in
from os.path import splitext, basename, join as pjoin, walk
ImportError: cannot import name 'walk' from 'posixpath' (/usr/lib/python3.8/posixpath.py)

what can i do with this?

request failed, code 13

No matter how I follow the instructions, I will always see request failed, code 13 when I visit 127.0.0.1:8080.
qq20190223-190228 2x

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.