Browse Source

Implemented Upload Data to Tracing(Not tested)

lp-tu 10 years ago
parent
commit
bf5729ca78

BIN
bin/classes.dex


BIN
bin/classes/de/tudarmstadt/informatik/hostage/HoneyListener.class


BIN
bin/hostage.apk


BIN
bin/resources.ap_


+ 1 - 0
res/layout/activity_viewlog.xml

@@ -99,6 +99,7 @@
             android:id="@+id/buttonUploadLog"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:onClick="uploadDatabase"
             android:text="Upload Log" />
 
         <Button

+ 1 - 4
src/de/tudarmstadt/informatik/hostage/HoneyListener.java

@@ -71,7 +71,6 @@ public class HoneyListener implements Runnable {
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
-
 	}
 
 	public void stop() {
@@ -85,7 +84,6 @@ public class HoneyListener implements Runnable {
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
-
 	}
 
 	public String getProtocolName() {
@@ -98,8 +96,7 @@ public class HoneyListener implements Runnable {
 			if (handler.isTerminated()) {
 				iterator.remove();
 			}
-		}
-		
+		}		
 	}
 
 	private void addHandler() {

+ 117 - 67
src/de/tudarmstadt/informatik/hostage/commons/HelperUtils.java

@@ -1,17 +1,29 @@
 package de.tudarmstadt.informatik.hostage.commons;
 
-import java.io.File;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.security.KeyStore;
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
+import org.apache.http.HttpVersion;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.protocol.HTTP;
 import org.apache.http.util.EntityUtils;
 import org.json.JSONObject;
 
+import de.tudarmstadt.informatik.hostage.net.MySSLSocketFactory;
 import android.content.Context;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
@@ -19,88 +31,126 @@ import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.os.Environment;
 import android.text.TextUtils;
-import android.util.Log;
 
 public final class HelperUtils {
 
-	
 	public static String getSSID(Context context) {
-		  String ssid = null;
-		  ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
-		  NetworkInfo networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
-		  if (networkInfo != null && networkInfo.isConnected()) {
-		    final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
-		    final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
-		    if (connectionInfo != null && !TextUtils.isEmpty(connectionInfo.getSSID())) {
-		      ssid = connectionInfo.getSSID();
-		    }
-		  }
-		  return ssid;
+		String ssid = null;
+		ConnectivityManager connManager = (ConnectivityManager) context
+				.getSystemService(Context.CONNECTIVITY_SERVICE);
+		NetworkInfo networkInfo = connManager
+				.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+		if (networkInfo != null && networkInfo.isConnected()) {
+			final WifiManager wifiManager = (WifiManager) context
+					.getSystemService(Context.WIFI_SERVICE);
+			final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
+			if (connectionInfo != null
+					&& !TextUtils.isEmpty(connectionInfo.getSSID())) {
+				ssid = connectionInfo.getSSID();
+			}
 		}
-	
+		return ssid;
+	}
+
 	public static String getBSSID(Context context) {
-		  String bssid = null;
-		  ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
-		  NetworkInfo networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
-		  if (networkInfo != null && networkInfo.isConnected()) {
-		    final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
-		    final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
-		    if (connectionInfo != null && !TextUtils.isEmpty(connectionInfo.getSSID())) {
-		      bssid = connectionInfo.getBSSID();
-		    }
-		  }
-		  return bssid;
+		String bssid = null;
+		ConnectivityManager connManager = (ConnectivityManager) context
+				.getSystemService(Context.CONNECTIVITY_SERVICE);
+		NetworkInfo networkInfo = connManager
+				.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+		if (networkInfo != null && networkInfo.isConnected()) {
+			final WifiManager wifiManager = (WifiManager) context
+					.getSystemService(Context.WIFI_SERVICE);
+			final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
+			if (connectionInfo != null
+					&& !TextUtils.isEmpty(connectionInfo.getSSID())) {
+				bssid = connectionInfo.getBSSID();
+			}
+		}
+		return bssid;
+	}
+
+	public static String getInternalIP(Context context) {
+		String ipAddress = null;
+		ConnectivityManager connManager = (ConnectivityManager) context
+				.getSystemService(Context.CONNECTIVITY_SERVICE);
+		NetworkInfo networkInfo = connManager
+				.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+		if (networkInfo != null && networkInfo.isConnected()) {
+			final WifiManager wifiManager = (WifiManager) context
+					.getSystemService(Context.WIFI_SERVICE);
+			final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
+			if (connectionInfo != null) {
+				try {
+					ipAddress = InetAddress.getByAddress(
+							unpackInetAddress(connectionInfo.getIpAddress()))
+							.getHostAddress();
+				} catch (UnknownHostException e) {
+				}
+			}
 		}
-	
-	public static String getInternalIP(Context context){
-		  String ipAddress = null;
-		  ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
-		  NetworkInfo networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
-		  if (networkInfo != null && networkInfo.isConnected()) {
-			    final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
-			    final WifiInfo connectionInfo = wifiManager.getConnectionInfo();	
-			    if(connectionInfo != null){
-					try {
-						ipAddress = InetAddress.getByAddress(unpackInetAddress(connectionInfo.getIpAddress())).getHostAddress();
-					} catch (UnknownHostException e) {
-					}
-			    }
-		  }
-		  return ipAddress;
+		return ipAddress;
 	}
-	
+
 	private static byte[] unpackInetAddress(int bytes) {
 		return new byte[] { (byte) ((bytes) & 0xff),
 				(byte) ((bytes >>> 8) & 0xff), (byte) ((bytes >>> 16) & 0xff),
 				(byte) ((bytes >>> 24) & 0xff) };
 	}
-	
-	public static String getExternalIP (Context context) {
+
+	public static String getExternalIP(Context context) {
 		String ipAddress = null;
-		   try {
-		        HttpClient httpclient = new DefaultHttpClient();
-		        HttpGet httpget = new HttpGet("http://ip2country.sourceforge.net/ip2c.php?format=JSON");
-		        HttpResponse response;
-
-		        response = httpclient.execute(httpget);
-
-		        HttpEntity entity = response.getEntity();
-		        entity.getContentLength();
-		        String str = EntityUtils.toString(entity);
-		        JSONObject json_data = new JSONObject(str);
-		        ipAddress = json_data.getString("ip");		        
-		    }
-		    catch (Exception e){}
-
-		   return ipAddress;
+		try {
+			HttpClient httpclient = new DefaultHttpClient();
+			HttpGet httpget = new HttpGet(
+					"http://ip2country.sourceforge.net/ip2c.php?format=JSON");
+			HttpResponse response;
+
+			response = httpclient.execute(httpget);
+
+			HttpEntity entity = response.getEntity();
+			entity.getContentLength();
+			String str = EntityUtils.toString(entity);
+			JSONObject json_data = new JSONObject(str);
+			ipAddress = json_data.getString("ip");
+		} catch (Exception e) {
+		}
+		return ipAddress;
 	}
 
 	/* Checks if external storage is available for read and write */
 	public boolean isExternalStorageWritable() {
-	    String state = Environment.getExternalStorageState();
-	    if (Environment.MEDIA_MOUNTED.equals(state)) {
-	        return true;
-	    }
-	    return false;
-	}	
+		String state = Environment.getExternalStorageState();
+		if (Environment.MEDIA_MOUNTED.equals(state)) {
+			return true;
+		}
+		return false;
+	}
+
+	public static HttpClient createHttpClient() {
+		try {
+			KeyStore trustStore = KeyStore.getInstance(KeyStore
+					.getDefaultType());
+			trustStore.load(null, null);
+
+			SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
+			sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+
+			HttpParams params = new BasicHttpParams();
+			HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+			HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
+
+			SchemeRegistry registry = new SchemeRegistry();
+			registry.register(new Scheme("http", PlainSocketFactory
+					.getSocketFactory(), 80));
+			registry.register(new Scheme("https", sf, 443));
+
+			ClientConnectionManager ccm = new ThreadSafeClientConnManager(
+					params, registry);
+
+			return new DefaultHttpClient(ccm, params);
+		} catch (Exception e) {
+			return new DefaultHttpClient();
+		}
+	}
 }

+ 41 - 51
src/de/tudarmstadt/informatik/hostage/logging/DatabaseHandler.java

@@ -91,18 +91,8 @@ public class DatabaseHandler extends SQLiteOpenHelper {
 		db.insert(TABLE_RECORDS, null, values);
 		db.close(); // Closing database connection
 	}
-
-	// Getting single record
-	public Record getRecord(int id) {
-		SQLiteDatabase db = this.getReadableDatabase();
-
-		Cursor cursor = db.query(TABLE_RECORDS, null,
-				KEY_ID + "=?", new String[] { String.valueOf(id) }, null, null,
-				null, null);
-		if (cursor != null)
-			cursor.moveToFirst();
-
-		
+	
+	private Record createRecord(Cursor cursor){
 		Record record = new Record();
 		try {
 		record.setID(Integer.parseInt(cursor.getString(0)));
@@ -121,6 +111,20 @@ public class DatabaseHandler extends SQLiteOpenHelper {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
+		return record;
+	}
+
+	// Getting single record
+	public Record getRecord(int id) {
+		SQLiteDatabase db = this.getReadableDatabase();
+
+		Cursor cursor = db.query(TABLE_RECORDS, null,
+				KEY_ID + "=?", new String[] { String.valueOf(id) }, null, null,
+				null, null);
+		if (cursor != null)
+			cursor.moveToFirst();
+
+		Record record = createRecord(cursor);
 		
         cursor.close();
 		db.close();
@@ -140,25 +144,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
 		// looping through all rows and adding to list
 		if (cursor.moveToFirst()) {
 			do {
-				Record record = new Record();
-				try {
-				record.setID(Integer.parseInt(cursor.getString(0)));
-				record.setAttack_id(cursor.getLong(1));
-				record.setProtocol(cursor.getString(2));
-				record.setType(cursor.getString(3).equals("SEND") ? TYPE.SEND : TYPE.RECEIVE);
-				record.setTimestamp(cursor.getLong(4));
-				record.setLocalIP(InetAddress.getByAddress(cursor.getString(6), cursor.getBlob(5)));
-				record.setLocalPort(Integer.parseInt(cursor.getString(7)));
-				record.setRemoteIP(InetAddress.getByAddress(cursor.getString(9), cursor.getBlob(8)));
-				record.setRemotePort(Integer.parseInt(cursor.getString(10)));
-				record.setBSSID(cursor.getString(11));
-				record.setSSID(cursor.getString(12));
-				record.setPacket(cursor.getString(13));
-				} catch (UnknownHostException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
-				
+				Record record = createRecord(cursor);				
 				// Adding record to list
 				recordList.add(record);
 			} while (cursor.moveToNext());
@@ -211,32 +197,14 @@ public class DatabaseHandler extends SQLiteOpenHelper {
 	// Getting first Record for each AttackId
     public ArrayList<Record> getRecordOfEachAtack() {
     	ArrayList<Record> recordList = new ArrayList<Record>();
-        String selectQuery = "SELECT  * FROM " + TABLE_RECORDS + " WHERE " + " GROUP BY " + KEY_ATTACK_ID;
+        String selectQuery = "SELECT  * FROM " + TABLE_RECORDS + " GROUP BY " + KEY_ATTACK_ID;
         SQLiteDatabase db = this.getReadableDatabase();
         Cursor cursor = db.rawQuery(selectQuery, null);
 		
         // looping through all rows and adding to list
 		if (cursor.moveToFirst()) {
 			do {
-				Record record = new Record();
-				try {
-				record.setID(Integer.parseInt(cursor.getString(0)));
-				record.setAttack_id(cursor.getLong(1));
-				record.setProtocol(cursor.getString(2));
-				record.setType(cursor.getString(3).equals("SEND") ? TYPE.SEND : TYPE.RECEIVE);
-				record.setTimestamp(cursor.getLong(4));
-				record.setLocalIP(InetAddress.getByAddress(cursor.getString(6), cursor.getBlob(5)));
-				record.setLocalPort(Integer.parseInt(cursor.getString(7)));
-				record.setRemoteIP(InetAddress.getByAddress(cursor.getString(9), cursor.getBlob(8)));
-				record.setRemotePort(Integer.parseInt(cursor.getString(10)));
-				record.setBSSID(cursor.getString(11));
-				record.setSSID(cursor.getString(12));
-				record.setPacket(cursor.getString(13));
-				} catch (UnknownHostException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
-				
+				Record record = createRecord(cursor);
 				// Adding record to list
 				recordList.add(record);
 			} while (cursor.moveToNext());
@@ -248,6 +216,28 @@ public class DatabaseHandler extends SQLiteOpenHelper {
         return recordList;
     }
     
+	// Getting first Record for each AttackId
+    public ArrayList<Record> getRecordOfEachAtack(int id) {
+    	ArrayList<Record> recordList = new ArrayList<Record>();
+        String selectQuery = "SELECT  * FROM " + TABLE_RECORDS + " WHERE " + KEY_ATTACK_ID + " > " + id + " GROUP BY " + KEY_ATTACK_ID;
+        SQLiteDatabase db = this.getReadableDatabase();
+        Cursor cursor = db.rawQuery(selectQuery, null);
+		
+        // looping through all rows and adding to list
+		if (cursor.moveToFirst()) {
+			do {
+				Record record = createRecord(cursor);
+				// Adding record to list
+				recordList.add(record);
+			} while (cursor.moveToNext()); 
+		}       
+        cursor.close();
+ 
+        // return count
+        db.close();
+        return recordList;
+    }
+    
     public boolean bssidSeen(String protocol, String BSSID){
         String countQuery = "SELECT  * FROM " + TABLE_RECORDS + " WHERE " + KEY_PROTOCOL + " = " + "'" + protocol + "'" + " AND " + KEY_BSSID + " = " + "'" + BSSID + "'";
         SQLiteDatabase db = this.getReadableDatabase();

+ 44 - 0
src/de/tudarmstadt/informatik/hostage/logging/SQLLogger.java

@@ -2,12 +2,22 @@ package de.tudarmstadt.informatik.hostage.logging;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+
+import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
 import android.content.Context;
 import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
 import android.os.Environment;
 import android.preference.PreferenceManager;
+import android.widget.Toast;
 
 public class SQLLogger implements Logger{
 	Context context;
@@ -49,6 +59,40 @@ public class SQLLogger implements Logger{
 		}	
 	}	
 	
+	public void uploadDatabase(){
+		SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
+		Editor editor = pref.edit();
+		int lastUploadedAttackId = pref.getInt("LAST_UPLOADED_ATTACK_ID", -1);
+		int currentAttackCount = dbh.getAttackCount();
+		if(lastUploadedAttackId == currentAttackCount || currentAttackCount == 0){
+			return;
+		}
+
+		HttpClient httpclient = HelperUtils.createHttpClient();
+		ArrayList<Record> recordList = dbh.getRecordOfEachAtack(lastUploadedAttackId + 1);
+		try {
+			HttpPost httppost;
+			for(Record record: recordList){
+				httppost = new HttpPost("https://ssi.cased.de");
+				StringEntity se = new StringEntity(record.toStringJson());
+				httppost.setEntity(se);
+				httpclient.execute(httppost);
+			}
+		} catch (UnsupportedEncodingException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (ClientProtocolException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}		
+		editor.putInt("LAST_UPLOADED_ATTACK_ID",currentAttackCount - 1);
+		editor.commit();
+	}
+	
 	public int getAttackCount(){
 		return dbh.getAttackCount();
 	}

+ 0 - 214
src/de/tudarmstadt/informatik/hostage/logging/SQLRecord.java

@@ -1,214 +0,0 @@
-package de.tudarmstadt.informatik.hostage.logging;
-
-import java.net.InetAddress;
-
-public class SQLRecord {
-	// private variables
-	private int id;
-	private int attack_id;
-	private String protocol;
-	private String type;
-	private String timestamp;
-	private String localIP;
-	private int localPort;
-	private String remoteIP;
-	private int remotePort;
-	private String packet;
-
-	// Empty constructor
-	public SQLRecord() {
-
-	}
-
-	// constructor
-	public SQLRecord(int id, int attack_id, String protocol,  String type, String timestamp,
-			String localIP, int localPort, String remoteIP, int remotePort,
-			String packet) {
-		this.id = id;
-		this.attack_id = attack_id;
-		this.setProtocol(protocol);
-		this.type = type;
-		this.timestamp = timestamp;
-		this.localIP = localIP;
-		this.localPort = localPort;
-		this.remoteIP = remoteIP;
-		this.remotePort = remotePort;
-		this.packet = packet;
-	}
-
-	// constructor
-	public SQLRecord(int attack_id, String protocol, String type, String timestamp, String localIP,
-			int localPort, String remoteIP, int remotePort, String packet) {
-		this.attack_id = attack_id;
-		this.setProtocol(protocol);
-		this.type = type;
-		this.timestamp = timestamp;
-		this.localIP = localIP;
-		this.localPort = localPort;
-		this.remoteIP = remoteIP;
-		this.remotePort = remotePort;
-		this.packet = packet;
-	}
-
-	/**
-	 * @return the id
-	 */
-	public int getID() {
-		return id;
-	}
-
-	/**
-	 * @param id
-	 *            the id to set
-	 */
-	public void setID(int id) {
-		this.id = id;
-	}
-
-	/**
-	 * @return the attack_id
-	 */
-	public int getAttack_id() {
-		return attack_id;
-	}
-
-	/**
-	 * @param attack_id
-	 *            the attack_id to set
-	 */
-	public void setAttack_id(int attack_id) {
-		this.attack_id = attack_id;
-	}
-
-	/**
-	 * @return the protocol
-	 */
-	public String getProtocol() {
-		return protocol;
-	}
-
-	/**
-	 * @param protocol the protocol to set
-	 */
-	public void setProtocol(String protocol) {
-		this.protocol = protocol;
-	}
-
-	/**
-	 * @return the type
-	 */
-	public String getType() {
-		return type;
-	}
-
-	/**
-	 * @param type
-	 *            the type to set
-	 */
-	public void setType(String type) {
-		this.type = type;
-	}
-
-	/**
-	 * @return the timestamp
-	 */
-	public String getTimestamp() {
-		return timestamp;
-	}
-
-	/**
-	 * @param timestamp
-	 *            the timestamp to set
-	 */
-	public void setTimestamp(String timestamp) {
-		this.timestamp = timestamp;
-	}
-
-	/**
-	 * @return the localIP
-	 */
-	public String getLocalIP() {
-		return localIP;
-	}
-
-	/**
-	 * @param localIP
-	 *            the localIP to set
-	 */
-	public void setLocalIP(String localIP) {
-		this.localIP = localIP;
-	}
-
-	/**
-	 * @return the localPort
-	 */
-	public int getLocalPort() {
-		return localPort;
-	}
-
-	/**
-	 * @param localPort
-	 *            the localPort to set
-	 */
-	public void setLocalPort(int localPort) {
-		this.localPort = localPort;
-	}
-
-	/**
-	 * @return the remoteIP
-	 */
-	public String getRemoteIP() {
-		return remoteIP;
-	}
-
-	/**
-	 * @param remoteIP
-	 *            the remoteIP to set
-	 */
-	public void setRemoteIP(String remoteIP) {
-		this.remoteIP = remoteIP;
-	}
-
-	/**
-	 * @return the remotePort
-	 */
-	public int getRemotePort() {
-		return remotePort;
-	}
-
-	/**
-	 * @param remotePort
-	 *            the remotePort to set
-	 */
-	public void setRemotePort(int remotePort) {
-		this.remotePort = remotePort;
-	}
-
-	/**
-	 * @return the packet
-	 */
-	public String getPacket() {
-		return packet;
-	}
-
-	/**
-	 * @param packet
-	 *            the packet to set
-	 */
-	public void setPacket(String packet) {
-		this.packet = packet;
-	}
-
-	@Override
-	public String toString() {
-		return String.format("%d %s [%s,%s:%d,%s:%d,%s]", attack_id, type, timestamp,
-				localIP, localPort, remoteIP, remotePort, packet);
-	}
-
-	public String toJson() {
-		return String
-				.format("{ \"src\":{\"IP\": %s, \"Port\": %d} \"dst\": {\"IP\": %s, \"Port\": %d} \"type\": 0 \"name\": \"HOsTaGe\" }",
-						localIP, localPort, remoteIP, remotePort);
-	}
-
-}

+ 49 - 0
src/de/tudarmstadt/informatik/hostage/net/MySSLSocketFactory.java

@@ -0,0 +1,49 @@
+package de.tudarmstadt.informatik.hostage.net;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.http.conn.ssl.SSLSocketFactory;
+public class MySSLSocketFactory extends SSLSocketFactory {
+    SSLContext sslContext = SSLContext.getInstance("TLS");
+
+    public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
+        super(truststore);
+
+        TrustManager tm = new X509TrustManager() {
+            public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+            }
+
+            public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+            }
+
+            public X509Certificate[] getAcceptedIssuers() {
+                return null;
+            }
+        };
+
+        sslContext.init(null, new TrustManager[] { tm }, null);
+    }
+
+    @Override
+    public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
+        return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
+    }
+
+    @Override
+    public Socket createSocket() throws IOException {
+        return sslContext.getSocketFactory().createSocket();
+    }
+}

+ 16 - 2
src/de/tudarmstadt/informatik/hostage/ui/ViewLog.java

@@ -1,22 +1,33 @@
 package de.tudarmstadt.informatik.hostage.ui;
 
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
 
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+
 import de.tudarmstadt.informatik.hostage.R;
+import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
 import de.tudarmstadt.informatik.hostage.logging.DatabaseHandler;
+import de.tudarmstadt.informatik.hostage.logging.Record;
 import de.tudarmstadt.informatik.hostage.logging.SQLLogger;
 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
+import android.util.Log;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.LinearLayout;
 import android.widget.TextView;
+import android.widget.Toast;
 
 public class ViewLog extends Activity {
 
@@ -53,6 +64,11 @@ public class ViewLog extends Activity {
 		log.exportDatabase("DEFAULT");
 	}
 	
+	public void uploadDatabase(View view){
+		SQLLogger log = new SQLLogger(this);
+		log.uploadDatabase();
+	}
+	
 	public void showLog(View view){
 		startActivity(new Intent(this, ViewLogTable.class));
 	}
@@ -103,7 +119,5 @@ public class ViewLog extends Activity {
 	        text = (TextView) findViewById(R.id.textLastAttackValue);
 	        text.setText("-");
 		}
-
-
 	}
 }