[Android Apps and Games] jcase:
ex87,

Awesome work bro, life got too busy for me to work more on AndroShark, I really didn't drop it on purpose. But with a busy life, and me still really new at java, it was just too much. I am really glad you picked up the idea and ran with it.

Do you have any plans to opensource it at all (no worries if you dont)? I would like to be a contributor if you do decide to open source it.

I really doubt this is of any use. It was the second java app I ever worked on, and was really just a front end. Below is androshark source code. Like I said, this was my second attempt at writing an app, so please don't laugh :) If I were to do it today, I would completely change how it worked. /res/raw/sharktap was just tcpdump.

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
/**
* ToDo:
* Check for root
* Check for first run
*	Install Binaries on first run
* Check for sdcard mount
* Display file stats
* Name pcap based on file name
* Insert License
* kill sharktap on die
*
* @author jcase
*
*/

public class androshark extends Activity implements /*RadioGroup.OnCheckedChangeListener,*/ Button.OnClickListener {
Button btnStart, btnStop;
RadioButton radAll, rad3g, radWifi; //http://java.dzone.com/articles/google-android-tutorial?page=0,4
RadioGroup grpRadio;
TextView txtStatus, txtFilename, txtFilesize;

/** Called when the activity is first created. */
@Override

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnStart = (Button)this.findViewById(R.id.btnStart);
btnStart.setOnClickListener(this);
btnStop = (Button)this.findViewById(R.id.btnStop);
btnStop.setOnClickListener(this);
long epoch = System.currentTimeMillis()/1000;

boolean exists = (new File("/data/data/net.andirc.androshark/files/sharktap")).exists();
if (exists) {
} else {
Process myproc = null;
try
{
try{
String strDirectoy ="/data/data/net.andirc.androshark/files";
new File(strDirectoy).mkdir();

}
finally {}
InputStream ins = getResources().openRawResource(R.raw.sharktap);
int size = ins.available();
byte[] buffer = new byte[size];
ins.read(buffer);
ins.close();
FileOutputStream fos = new FileOutputStream("/data/data/net.andirc.androshark/files/sharktap");
fos.write(buffer);
fos.close();

}

catch (Exception ex)
{
Log.e("yourTag", "Oops something happened: " + ex.getMessage(), ex);
}

finally {}

}

boolean exists2 = (new File("/sdcard/androshark/")).exists();
if (exists2) {

} else {
if (android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED)) {

Process myproc = null;

try
{
myproc = Runtime.getRuntime().exec(new String[] {"su", "-c","chmod 755 /data/data/net.andirc.androshark/files/sharktap && mkdir /sdcard/androshark/"});
new AlertDialog.Builder(this)
.setMessage("This is a beta trial version of androshark and will expire on May 15th 2010. This app can potentially consume a lot of sdcard space, depending on how long you allow it to sniff traffic and how much bandwidth you are using.")
.setPositiveButton("OK", null)
.show();
}

catch (Exception ex)
{
Log.e("yourTag", "Oops something happened: " + ex.getMessage(), ex);
}

finally {}
} else {
new AlertDialog.Builder(this)
.setMessage("Error sd01: sdCard not found!")
.setPositiveButton("OK", null)
.show();
}
}

if (epoch >= 1273990849) { // May 15th 2010 1273990849
System.exit(0);
}

}

public void onClick(View v) {

Process myproc = null;

try
{

if (v == btnStart) {
if (android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED)) {

myproc = Runtime.getRuntime().exec(new String[] {"su", "-c", "kill $(ps | grep sharktap | tr -s ' ' | cut -d ' ' -f2) && /data/data/net.andirc.androshark/files/sharktap -vv -s 0 -w /sdcard/androshark/dump.pcap"});

TextView txtStatus =
(TextView) this.findViewById(R.id.txtStatus);
txtStatus.setText("Status: Running");

TextView txtFilename =
(TextView) this.findViewById(R.id.txtFilename);
txtFilename.setText("Filename: /sdcard/androshark/dump.pcap");

/* int running = 1;
do {
File file = new File("/sdcard/androshark/dump.pcap");
long length = file.length();
TextView txtFilesize =
(TextView) this.findViewById(R.id.txtFilesize);
txtFilesize.setText("File Size: " + length/1024 + "KB");
} while (running <= 1); */
} else {
new AlertDialog.Builder(this)
.setMessage("Error sd02: sdCard not found!")
.setPositiveButton("OK", null)
.show();
}

} else if (v == btnStop) {

myproc = Runtime.getRuntime().exec(new String[] {"su", "-c", "kill $(ps | grep sharktap | tr -s ' ' | cut -d ' ' -f2)"});
myproc.waitFor();

File file = new File("/sdcard/androshark/dump.pcap");
long length = file.length();

TextView txtStatus =
(TextView) this.findViewById(R.id.txtStatus);
txtStatus.setText("Status: Stopped");
TextView txtFilesize =
(TextView) this.findViewById(R.id.txtFilesize);
txtFilesize.setText("File Size: " + length/1024 + "KB");
}

}

catch (Exception ex)
{
Log.e("yourTag", "Oops something happened: " + ex.getMessage(), ex);
}

finally {}

}

}