mirror of
https://github.com/moparisthebest/SSLDroid
synced 2025-02-21 05:21:46 -05:00
New icon and some minor reformattings
Signed-off-by: Balint Kovacs <blint@blint.hu>
This commit is contained in:
parent
484d940be9
commit
99fb986ac4
@ -1,13 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="hu.blint.ssldroid"
|
package="hu.blint.ssldroid" android:versionCode="1"
|
||||||
android:versionCode="1"
|
|
||||||
android:versionName="1.0">
|
android:versionName="1.0">
|
||||||
<uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER"></uses-permission>
|
<uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER"></uses-permission>
|
||||||
|
|
||||||
<application android:label="@string/app_name" android:icon="@drawable/icon">
|
<application android:label="@string/app_name" android:icon="@drawable/icon">
|
||||||
<activity android:name=".SSLDroidGui"
|
<activity android:name=".SSLDroidGui" android:label="@string/app_name">
|
||||||
android:label="@string/app_name">
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
@ -20,4 +18,13 @@
|
|||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<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>
|
</manifest>
|
BIN
bin/SSLDroid.apk
BIN
bin/SSLDroid.apk
Binary file not shown.
BIN
bin/classes.dex
BIN
bin/classes.dex
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 |
@ -2,6 +2,8 @@ package hu.blint.ssldroid;
|
|||||||
|
|
||||||
import hu.blint.ssldroid.TcpProxy;
|
import hu.blint.ssldroid.TcpProxy;
|
||||||
import android.app.*;
|
import android.app.*;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -14,8 +16,9 @@ public class SSLDroid extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
Toast.makeText(this, "SSLDroid Service Started", Toast.LENGTH_LONG).show();
|
// Toast.makeText(this, "SSLDroid Service Started",
|
||||||
Log.d(TAG, "onStart");
|
// Toast.LENGTH_LONG).show();
|
||||||
|
// Log.d(TAG, "onStart");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -27,7 +30,7 @@ public class SSLDroid extends Service {
|
|||||||
String keyFile = "/mnt/sdcard/blint-imaps.p12";
|
String keyFile = "/mnt/sdcard/blint-imaps.p12";
|
||||||
String keyPass = "titkos";
|
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");
|
Log.d(TAG, "onCreate");
|
||||||
|
|
||||||
tp = new TcpProxy();
|
tp = new TcpProxy();
|
||||||
@ -45,6 +48,22 @@ public class SSLDroid extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
try {
|
||||||
tp.stop();
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
@ -17,9 +17,8 @@ import android.util.Log;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a modified version of the TcpTunnelGui utility
|
* This is a modified version of the TcpTunnelGui utility borrowed from the
|
||||||
* borrowed from the xml.apache.org project.
|
* xml.apache.org project.
|
||||||
* @author Balint Kovacs (blint@blint.hu)
|
|
||||||
*/
|
*/
|
||||||
public class TcpProxy {
|
public class TcpProxy {
|
||||||
int listenPort;
|
int listenPort;
|
||||||
@ -32,7 +31,8 @@ public class TcpProxy {
|
|||||||
public 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.listenPort = listenPort;
|
||||||
this.tunnelHost = tunnelHost;
|
this.tunnelHost = tunnelHost;
|
||||||
this.tunnelPort = tunnelPort;
|
this.tunnelPort = tunnelPort;
|
||||||
@ -55,12 +55,15 @@ public class TcpProxy {
|
|||||||
public String getKeyFile() {
|
public String getKeyFile() {
|
||||||
return keyFile;
|
return keyFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKeyPass() {
|
public String getKeyPass() {
|
||||||
return keyPass;
|
return keyPass;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SSLSocketFactory sslSocketFactory;
|
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) {
|
if (sslSocketFactory == null) {
|
||||||
try {
|
try {
|
||||||
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("X509");
|
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("X509");
|
||||||
@ -68,31 +71,45 @@ public class TcpProxy {
|
|||||||
keyStore.load(new FileInputStream(pkcsFile), pwd.toCharArray());
|
keyStore.load(new FileInputStream(pkcsFile), pwd.toCharArray());
|
||||||
keyManagerFactory.init(keyStore, pwd.toCharArray());
|
keyManagerFactory.init(keyStore, pwd.toCharArray());
|
||||||
SSLContext context = SSLContext.getInstance("TLS");
|
SSLContext context = SSLContext.getInstance("TLS");
|
||||||
context.init(keyManagerFactory.getKeyManagers(), null, new SecureRandom());
|
context.init(keyManagerFactory.getKeyManagers(), null,
|
||||||
sslSocketFactory = (SSLSocketFactory) context.getSocketFactory();
|
new SecureRandom());
|
||||||
|
sslSocketFactory = (SSLSocketFactory) context
|
||||||
|
.getSocketFactory();
|
||||||
|
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
Log.d("SSLDroid","Error loading the client certificate file:" + e.getMessage());
|
Log.d("SSLDroid", "Error loading the client certificate file:"
|
||||||
//Toast.makeText(none, "SSLDroid Sulyos Errorhiba" + e.getMessage(), Toast.LENGTH_LONG).show();
|
+ e.getMessage());
|
||||||
|
// Toast.makeText(none, "SSLDroid Sulyos Errorhiba" +
|
||||||
|
// e.getMessage(), Toast.LENGTH_LONG).show();
|
||||||
} catch (KeyManagementException e) {
|
} catch (KeyManagementException e) {
|
||||||
Log.d("SSLDroid","No SSL algorithm support: " + e.getMessage());
|
Log
|
||||||
|
.d("SSLDroid", "No SSL algorithm support: "
|
||||||
|
+ e.getMessage());
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} 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) {
|
} 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) {
|
} 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) {
|
} 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) {
|
} 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;
|
return sslSocketFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serve(int listenPort, String tunnelHost, int tunnelPort, String keyFile, String keyPass) throws IOException {
|
public void serve(int listenPort, String tunnelHost, int tunnelPort,
|
||||||
final TcpProxy ttg = new TcpProxy(listenPort, tunnelHost, tunnelPort, keyFile, keyPass);
|
String keyFile, String keyPass) throws IOException {
|
||||||
|
final TcpProxy ttg = new TcpProxy(listenPort, tunnelHost, tunnelPort,
|
||||||
|
keyFile, keyPass);
|
||||||
|
|
||||||
// create the server thread
|
// create the server thread
|
||||||
server = new Thread() {
|
server = new Thread() {
|
||||||
@ -100,9 +117,11 @@ public class TcpProxy {
|
|||||||
ServerSocket ss = null;
|
ServerSocket ss = null;
|
||||||
try {
|
try {
|
||||||
ss = new ServerSocket(ttg.getListenPort());
|
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) {
|
} catch (Exception e) {
|
||||||
Log.d("SSLDroid", "Error setting up listening socket: " + e.getMessage());
|
Log.d("SSLDroid", "Error setting up listening socket: "
|
||||||
|
+ e.getMessage());
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
@ -113,24 +132,35 @@ public class TcpProxy {
|
|||||||
Socket st;
|
Socket st;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
st = (SSLSocket) getSocketFactory(ttg.getKeyFile(), ttg.getKeyPass()).createSocket(ttg.getTunnelHost(), ttg.getTunnelPort());
|
st = (SSLSocket) getSocketFactory(ttg.getKeyFile(),
|
||||||
|
ttg.getKeyPass()).createSocket(
|
||||||
|
ttg.getTunnelHost(), ttg.getTunnelPort());
|
||||||
((SSLSocket) st).startHandshake();
|
((SSLSocket) st).startHandshake();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d("SSLDroid", "SSL failure: " + e.toString());
|
Log.d("SSLDroid", "SSL failure: " + e.toString());
|
||||||
st = new Socket(ttg.getTunnelHost(), ttg.getTunnelPort());
|
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
|
// relay the stuff thru
|
||||||
Thread fromBrowserToServer = new Relay(sc.getInputStream(), st.getOutputStream(), "<<< B2S <<<");
|
Thread fromBrowserToServer = new Relay(sc
|
||||||
Thread fromServerToBrowser = new Relay(st.getInputStream(), sc.getOutputStream(), ">>> S2B >>>");
|
.getInputStream(), st.getOutputStream(),
|
||||||
|
"<<< B2S <<<");
|
||||||
|
Thread fromServerToBrowser = new Relay(st
|
||||||
|
.getInputStream(), sc.getOutputStream(),
|
||||||
|
">>> S2B >>>");
|
||||||
|
|
||||||
fromBrowserToServer.start();
|
fromBrowserToServer.start();
|
||||||
fromServerToBrowser.start();
|
fromServerToBrowser.start();
|
||||||
|
|
||||||
if (server.isInterrupted())
|
if (server.isInterrupted()) {
|
||||||
ss.close();
|
ss.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
Log.d("SSLDroid", "Ouch: " + ee.getMessage());
|
Log.d("SSLDroid", "Ouch: " + ee.getMessage());
|
||||||
@ -145,6 +175,7 @@ public class TcpProxy {
|
|||||||
public void stop() {
|
public void stop() {
|
||||||
if (server != null)
|
if (server != null)
|
||||||
server.interrupt();
|
server.interrupt();
|
||||||
|
Log.d("SSLDroid", "Stopping service");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Relay extends Thread {
|
public static class Relay extends Thread {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user