Pidcat android script is an android app logging script alternative script of android ADB Logcat, but with lots of new features like filtering with specific apps or packages, colored output, etc.
When I was working with one of my android application testings projects, I faced many types of issues like logcat throws many system-level error messages, stack traces that don’t matter to me. Moreover, I didn’t need all messages, I want to observe only logs from only one app on which I am testing. Unfortunately, because the process ID changes every time for the apps so, it becomes a challenge to grep the right thing.
So when I was trying to find such a tool that solves my problem, I found pidcat script from Github that developed by Jeff Sharkey.
Using pidcat script we can filter the logs for some specific app. Pidcat script can also make this output colorful for our better convenience. The logs will be colored by their adb logcat filter tags.
Table of Contents
Pidcat Installation
I am using kali Linux for my security testing work, so I will install this script in Kali Linux, but you can choose a method for your specific OS and distribution from its pidcat Github repository.
Requirements
- Python
- Android SDK platform-tools
- ADB
pidcat for Ubuntu & Kali Linux
Just navigate to the pidcat github repository and clone it.
git clone https://github.com/JakeWharton/pidcat.git
Now we can directly run pidcat.py
file or you can place this file on your environment path variable to globally access it.
Arch Linux
Install the package called pidcat-git from the AUR.
OS X
Use Homebrew.
brew install pidcat
If you need to install the latest development version
brew unlink pidcat
brew install --HEAD pidcat
Note: Make sure that adb
from the Android SDK is on your PATH. This script will not work unless this is the case. That means when you type adb
and press enter into your terminal something actually happens.
To include adb
and other android tools on your path:
export PATH=$PATH:/platform-tools
export PATH=$PATH:/tools
Using pidcat Script
To get the help command use --help
option with pidcat.py
.
pidcat Help Manual
# Use python2.7 to run pidcat.py
# python2.7 pidcat.py [options]
$ ./pidcat.py --help
usage: pidcat.py [-h] [-w N] [-l {V,D,I,W,E,F,v,d,i,w,e,f}] [--color-gc] [--always-display-tags] [--current] [-s DEVICE_SERIAL] [-d] [-e] [-c] [-t TAG]
[-i IGNORED_TAG] [-v] [-a]
[package [package ...]]
Filter logcat by package name
positional arguments:
package Application package name(s)
optional arguments:
-h, --help show this help message and exit
-w N, --tag-width N Width of log tag
-l {V,D,I,W,E,F,v,d,i,w,e,f}, --min-level {V,D,I,W,E,F,v,d,i,w,e,f}
Minimum level to be displayed
--color-gc Color garbage collection
--always-display-tags
Always display the tag name
--current Filter logcat by current running app
-s DEVICE_SERIAL, --serial DEVICE_SERIAL
Device serial number (adb -s option)
-d, --device Use first device for log input (adb -d option)
-e, --emulator Use first emulator for log input (adb -e option)
-c, --clear Clear the entire log before running
-t TAG, --tag TAG Filter output by specified tag(s)
-i IGNORED_TAG, --ignore-tag IGNORED_TAG
Filter output by ignoring specified tag(s)
-v, --version Print the version number and exit
-a, --all Print all log messages
Note: Use python2.7
to run pidcat.py
script. It throws error for me when I used python3
.
pidcat Verbose System Logs
To start monitoring with pidcat, just enter the following command to capture the full system logs verbosely.
$ ./pidcat.py #if you are using python2.7 on system
or
$ python2.7 pidcat.py

Filtering Logs for Specific Package in pidcat.
To filter the logs for specific package, we need to specify the application package name,
we can get the package name with the help of adb command,
Use the following command to get all the apps or packages installed on the android device or emulator.
$ adb shell pm list packages
package:com.example.android.livecubes
package:com.android.providers.telephony
package:com.android.providers.calendar
package:com.android.providers.media
package:com.android.wallpapercropper
package:com.android.documentsui
package:jakhar.aseem.diva
Here I am testing with Diva application, so selecting jakhar.aseem.diva
.

To start monitoring with diva application use pidcat with the package name.
$ python2.7 pidcat.py jakhar.aseem.diva

As we can observe, pidcat is showing the colorful logging for the Diva app.
pidcat Logging for Current running app
To monitor logs for current running app use --current
option.
$ python2.7 pidcat.py --current

Specify pidcat Android device
If you are using multiple devices with your PC, then you have to specify one specific device from multiple devices. Use -s
with the serial number of the specific android device or emulator.
$ python2.7 pidcat.py -s 192.168.56.115:5555

You can use other filters with this command from help menu to get targeted results.
pidcat Minimum level to be displayed
Use an option with -l {V,D,I,W,E,F,v,d,i,w,e,f}
to show minimum level to be displayed
$ python2.7 pidcat.py jakhar.aseem.diva -l V

Save pidcat Output
To store pidcat android logs, we have multiple methods,
- One method is, we can use the bash redirection operator to store the output of pidcat android script.
$ python pidcat.py jakhar.aseem.diva > pidcat_output.txt
- Another method is you can use the bash
tee
command to continuously monitor and save the pidcat output.
$ python pidcat.py jakhar.aseem.diva | tee pidcat_output.txt
Hope!! this script will help you in your android security testing work. Thanks!!!!