New icon and some minor reformattings

Signed-off-by: Balint Kovacs <blint@blint.hu>
This commit is contained in:
Balint Kovacs 2011-03-24 20:59:48 +01:00
parent 484d940be9
commit 99fb986ac4
10 changed files with 288 additions and 231 deletions

View File

@ -1,23 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hu.blint.ssldroid"
android:versionCode="1"
package="hu.blint.ssldroid" android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER"></uses-permission>
<application android:label="@string/app_name" android:icon="@drawable/icon">
<activity android:name=".SSLDroidGui"
android:label="@string/app_name">
<activity android:name=".SSLDroidGui" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:enabled="true" android:name=".SSLDroid"/>
<service android:enabled="true" android:name=".SSLDroid" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<receiver android:name=".BootStartupReceiver"
android:enabled="true" android:exported="false" android:label="StartServiceAtBootReceiver">
<intent-filter>
<action android:name="android.intent.action._BOOT_COMPLETED" />
</intent-filter>
</receiver>
</manifest>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -2,6 +2,8 @@ package hu.blint.ssldroid;
import hu.blint.ssldroid.TcpProxy;
import android.app.*;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
@ -14,8 +16,9 @@ public class SSLDroid extends Service {
@Override
public void onCreate() {
Toast.makeText(this, "SSLDroid Service Started", Toast.LENGTH_LONG).show();
Log.d(TAG, "onStart");
// Toast.makeText(this, "SSLDroid Service Started",
// Toast.LENGTH_LONG).show();
// Log.d(TAG, "onStart");
}
@Override
@ -23,11 +26,11 @@ public class SSLDroid extends Service {
int listenPort = 9999; // port to listen on
int targetPort = 443; // port to connect to
String targetHost = "sogo.balabit.com"; //remote host
String targetHost = "sogo.balabit.com"; // remote host
String keyFile = "/mnt/sdcard/blint-imaps.p12";
String keyPass = "titkos";
Toast.makeText(this, "SSLDroid Service Created", Toast.LENGTH_LONG).show();
Toast.makeText(this, "SSLDroid Service Started", Toast.LENGTH_LONG).show();
Log.d(TAG, "onCreate");
tp = new TcpProxy();
@ -45,6 +48,22 @@ public class SSLDroid extends Service {
@Override
public void onDestroy() {
try {
tp.stop();
} catch (Exception e) {
Log.d("SSLDroid", "Error stopping service: " + e.getMessage());
}
}
}
/*
public class MyStartupIntentReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
}
Intent serviceIntent = new Intent();
serviceIntent.setAction("hu.blint.ssldroid");
context.startService(serviceIntent);
}
*/

View File

@ -17,9 +17,8 @@ import android.util.Log;
import android.widget.Toast;
/**
* This is a modified version of the TcpTunnelGui utility
* borrowed from the xml.apache.org project.
* @author Balint Kovacs (blint@blint.hu)
* This is a modified version of the TcpTunnelGui utility borrowed from the
* xml.apache.org project.
*/
public class TcpProxy {
int listenPort;
@ -32,7 +31,8 @@ public class TcpProxy {
public TcpProxy() {
}
public TcpProxy(int listenPort, String tunnelHost, int tunnelPort, String keyFile, String keyPass) {
public TcpProxy(int listenPort, String tunnelHost, int tunnelPort,
String keyFile, String keyPass) {
this.listenPort = listenPort;
this.tunnelHost = tunnelHost;
this.tunnelPort = tunnelPort;
@ -55,12 +55,15 @@ public class TcpProxy {
public String getKeyFile() {
return keyFile;
}
public String getKeyPass() {
return keyPass;
}
private static SSLSocketFactory sslSocketFactory;
public static final SSLSocketFactory getSocketFactory(String pkcsFile, String pwd) {
public static final SSLSocketFactory getSocketFactory(String pkcsFile,
String pwd) {
if (sslSocketFactory == null) {
try {
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("X509");
@ -68,31 +71,45 @@ public class TcpProxy {
keyStore.load(new FileInputStream(pkcsFile), pwd.toCharArray());
keyManagerFactory.init(keyStore, pwd.toCharArray());
SSLContext context = SSLContext.getInstance("TLS");
context.init(keyManagerFactory.getKeyManagers(), null, new SecureRandom());
sslSocketFactory = (SSLSocketFactory) context.getSocketFactory();
context.init(keyManagerFactory.getKeyManagers(), null,
new SecureRandom());
sslSocketFactory = (SSLSocketFactory) context
.getSocketFactory();
} catch (FileNotFoundException e) {
Log.d("SSLDroid","Error loading the client certificate file:" + e.getMessage());
//Toast.makeText(none, "SSLDroid Sulyos Errorhiba" + e.getMessage(), Toast.LENGTH_LONG).show();
Log.d("SSLDroid", "Error loading the client certificate file:"
+ e.getMessage());
// Toast.makeText(none, "SSLDroid Sulyos Errorhiba" +
// e.getMessage(), Toast.LENGTH_LONG).show();
} catch (KeyManagementException e) {
Log.d("SSLDroid","No SSL algorithm support: " + e.getMessage());
Log
.d("SSLDroid", "No SSL algorithm support: "
+ e.getMessage());
} catch (NoSuchAlgorithmException e) {
Log.d("SSLDroid","No common SSL algorithm found: " + e.getMessage());
Log.d("SSLDroid", "No common SSL algorithm found: "
+ e.getMessage());
} catch (KeyStoreException e) {
Log.d("SSLDroid","Error setting up keystore:" + e.getMessage());
Log
.d("SSLDroid", "Error setting up keystore:"
+ e.getMessage());
} catch (java.security.cert.CertificateException e) {
Log.d("SSLDroid","Error loading the client certificate:" + e.getMessage());
Log.d("SSLDroid", "Error loading the client certificate:"
+ e.getMessage());
} catch (IOException e) {
Log.d("SSLDroid","Error loading the client certificate file:" + e.getMessage());
Log.d("SSLDroid", "Error loading the client certificate file:"
+ e.getMessage());
} catch (UnrecoverableKeyException e) {
Log.d("SSLDroid","Error loading the client certificate:" + e.getMessage());
Log.d("SSLDroid", "Error loading the client certificate:"
+ e.getMessage());
}
}
return sslSocketFactory;
}
public void serve(int listenPort, String tunnelHost, int tunnelPort, String keyFile, String keyPass) throws IOException {
final TcpProxy ttg = new TcpProxy(listenPort, tunnelHost, tunnelPort, keyFile, keyPass);
public void serve(int listenPort, String tunnelHost, int tunnelPort,
String keyFile, String keyPass) throws IOException {
final TcpProxy ttg = new TcpProxy(listenPort, tunnelHost, tunnelPort,
keyFile, keyPass);
// create the server thread
server = new Thread() {
@ -100,10 +117,12 @@ public class TcpProxy {
ServerSocket ss = null;
try {
ss = new ServerSocket(ttg.getListenPort());
Log.d("SSLDroid","Listening for connections on port " + ttg.getListenPort() + " ...");
Log.d("SSLDroid", "Listening for connections on port "
+ ttg.getListenPort() + " ...");
} catch (Exception e) {
Log.d("SSLDroid", "Error setting up listening socket: " + e.getMessage());
//e.printStackTrace();
Log.d("SSLDroid", "Error setting up listening socket: "
+ e.getMessage());
// e.printStackTrace();
System.exit(1);
}
while (true) {
@ -113,28 +132,39 @@ public class TcpProxy {
Socket st;
try {
st = (SSLSocket) getSocketFactory(ttg.getKeyFile(), ttg.getKeyPass()).createSocket(ttg.getTunnelHost(), ttg.getTunnelPort());
((SSLSocket)st).startHandshake();
st = (SSLSocket) getSocketFactory(ttg.getKeyFile(),
ttg.getKeyPass()).createSocket(
ttg.getTunnelHost(), ttg.getTunnelPort());
((SSLSocket) st).startHandshake();
} catch (Exception e) {
Log.d("SSLDroid","SSL failure: " + e.toString());
st = new Socket(ttg.getTunnelHost(),ttg.getTunnelPort());
Log.d("SSLDroid", "SSL failure: " + e.toString());
st = new Socket(ttg.getTunnelHost(), ttg.getTunnelPort());
}
Log.d("SSLDroid","Tunnelling port " + ttg.getListenPort() + " to port " + ttg.getTunnelPort() + " on host " + ttg.getTunnelHost() + " ...");
Log.d("SSLDroid", "Tunnelling port "
+ ttg.getListenPort() + " to port "
+ ttg.getTunnelPort() + " on host "
+ ttg.getTunnelHost() + " ...");
// relay the stuff thru
Thread fromBrowserToServer = new Relay(sc.getInputStream(), st.getOutputStream(), "<<< B2S <<<");
Thread fromServerToBrowser = new Relay(st.getInputStream(), sc.getOutputStream(), ">>> S2B >>>");
Thread fromBrowserToServer = new Relay(sc
.getInputStream(), st.getOutputStream(),
"<<< B2S <<<");
Thread fromServerToBrowser = new Relay(st
.getInputStream(), sc.getOutputStream(),
">>> S2B >>>");
fromBrowserToServer.start();
fromServerToBrowser.start();
if (server.isInterrupted())
if (server.isInterrupted()) {
ss.close();
return;
}
} catch (Exception ee) {
Log.d("SSLDroid","Ouch: "+ ee.getMessage());
//ee.printStackTrace();
Log.d("SSLDroid", "Ouch: " + ee.getMessage());
// ee.printStackTrace();
}
}
}
@ -142,9 +172,10 @@ public class TcpProxy {
server.start();
}
public void stop(){
public void stop() {
if (server != null)
server.interrupt();
Log.d("SSLDroid", "Stopping service");
}
public static class Relay extends Thread {
@ -172,7 +203,7 @@ public class TcpProxy {
}
if (Thread.interrupted()) {
//We've been interrupted: no more serving.
// We've been interrupted: no more serving.
return;
}
}