Browse Source

Fixed TELNET to work with windows clients

qam 10 years ago
parent
commit
aaa3de0bcf

+ 150 - 150
gen/de/tudarmstadt/informatik/hostage/R.java

@@ -1,150 +1,150 @@
-/* AUTO-GENERATED FILE.  DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found.  It
- * should not be modified by hand.
- */
-
-package de.tudarmstadt.informatik.hostage;
-
-public final class R {
-    public static final class anim {
-        public static final int in_left_to_right=0x7f040000;
-        public static final int in_right_to_left=0x7f040001;
-        public static final int out_left_to_right=0x7f040002;
-        public static final int out_right_to_left=0x7f040003;
-    }
-    public static final class array {
-        public static final int protocols=0x7f070002;
-        public static final int upload_entries=0x7f070000;
-        public static final int upload_values=0x7f070001;
-    }
-    public static final class attr {
-    }
-    public static final class dimen {
-        /**  Default screen margins, per the Android Design guidelines. 
-
-         Customize dimensions originally defined in res/values/dimens.xml (such as
-         screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
-    
-         */
-        public static final int activity_horizontal_margin=0x7f060000;
-        public static final int activity_vertical_margin=0x7f060001;
-    }
-    public static final class drawable {
-        public static final int ic_launcher=0x7f020000;
-        public static final int light_green=0x7f020001;
-        public static final int light_green_large=0x7f020002;
-        public static final int light_grey=0x7f020003;
-        public static final int light_grey_large=0x7f020004;
-        public static final int light_red=0x7f020005;
-        public static final int light_red_large=0x7f020006;
-        public static final int light_yellow=0x7f020007;
-        public static final int light_yellow_large=0x7f020008;
-    }
-    public static final class id {
-        public static final int TextViewServices=0x7f0b000f;
-        public static final int action_settings=0x7f0b001e;
-        public static final int buttonDeleteLog=0x7f0b001a;
-        public static final int buttonExportDatabase=0x7f0b0018;
-        public static final int buttonShowLog=0x7f0b0005;
-        public static final int buttonUploadLog=0x7f0b0019;
-        public static final int checkBoxParanoid=0x7f0b0003;
-        public static final int imageViewLight=0x7f0b0002;
-        public static final int layoutContainer=0x7f0b0012;
-        public static final int listViewProtocols=0x7f0b0010;
-        public static final int textFirstAttack=0x7f0b0013;
-        public static final int textFirstAttackValue=0x7f0b0014;
-        public static final int textLastAttack=0x7f0b0015;
-        public static final int textLastAttackValue=0x7f0b0016;
-        public static final int textLogFile=0x7f0b0017;
-        public static final int textStatistics=0x7f0b0011;
-        public static final int textViewBSSID=0x7f0b0009;
-        public static final int textViewBSSIDValue=0x7f0b000a;
-        public static final int textViewConnections=0x7f0b001c;
-        public static final int textViewConnectionsValue=0x7f0b001d;
-        public static final int textViewDetails=0x7f0b0006;
-        public static final int textViewExternalIP=0x7f0b000d;
-        public static final int textViewExternalIPValue=0x7f0b000e;
-        public static final int textViewInternalIP=0x7f0b000b;
-        public static final int textViewInternalIPValue=0x7f0b000c;
-        public static final int textViewProtocol=0x7f0b001b;
-        public static final int textViewSSID=0x7f0b0007;
-        public static final int textViewSSIDValue=0x7f0b0008;
-        public static final int textViewStatus=0x7f0b0001;
-        public static final int toggleButtonOnOff=0x7f0b0004;
-        public static final int viewAnimator=0x7f0b0000;
-    }
-    public static final class layout {
-        public static final int activity_main=0x7f030000;
-        public static final int activity_viewlog=0x7f030001;
-        public static final int list_view_protocols_row=0x7f030002;
-    }
-    public static final class menu {
-        public static final int main=0x7f0a0000;
-    }
-    public static final class string {
-        public static final int action_settings=0x7f080001;
-        public static final int app_name=0x7f080000;
-        public static final int bssid=0x7f080008;
-        public static final int capital_off=0x7f080003;
-        public static final int capital_on=0x7f080002;
-        public static final int connections=0x7f08000c;
-        public static final int details=0x7f080006;
-        public static final int external_ip=0x7f08000a;
-        public static final int firstAttack=0x7f08000f;
-        public static final int internal_ip=0x7f080009;
-        public static final int lastAttack=0x7f080010;
-        public static final int logFile=0x7f08000e;
-        public static final int paranoid=0x7f080005;
-        public static final int pref_alarm=0x7f080012;
-        public static final int pref_alarm_default=0x7f080013;
-        public static final int pref_external_storage_summ=0x7f080016;
-        public static final int pref_external_storage_title=0x7f080015;
-        public static final int pref_notification=0x7f080017;
-        public static final int pref_storage=0x7f080014;
-        public static final int pref_tracing=0x7f08001a;
-        public static final int pref_upload=0x7f08001b;
-        public static final int pref_upload_connection=0x7f08001d;
-        public static final int pref_upload_connection_summ=0x7f08001e;
-        public static final int pref_upload_summ=0x7f08001c;
-        public static final int pref_vibration=0x7f080018;
-        public static final int pref_vibration_summ=0x7f080019;
-        public static final int services=0x7f08000b;
-        public static final int settings=0x7f080011;
-        public static final int ssid=0x7f080007;
-        public static final int statistics=0x7f08000d;
-        public static final int status=0x7f080004;
-    }
-    public static final class style {
-        /** 
-        Base application theme, dependent on API level. This theme is replaced
-        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-    
-
-            Theme customizations available in newer API levels can go in
-            res/values-vXX/styles.xml, while customizations related to
-            backward-compatibility can go here.
-        
-
-        Base application theme for API 11+. This theme completely replaces
-        AppBaseTheme from res/values/styles.xml on API 11+ devices.
-    
- API 11 theme customizations can go here. 
-
-        Base application theme for API 14+. This theme completely replaces
-        AppBaseTheme from BOTH res/values/styles.xml and
-        res/values-v11/styles.xml on API 14+ devices.
-    
- API 14 theme customizations can go here. 
-         */
-        public static final int AppBaseTheme=0x7f090000;
-        /**  Application theme. 
- All customizations that are NOT specific to a particular API-level can go here. 
-         */
-        public static final int AppTheme=0x7f090001;
-    }
-    public static final class xml {
-        public static final int preferences=0x7f050000;
-    }
-}
+/* AUTO-GENERATED FILE.  DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found.  It
+ * should not be modified by hand.
+ */
+
+package de.tudarmstadt.informatik.hostage;
+
+public final class R {
+    public static final class anim {
+        public static final int in_left_to_right=0x7f040000;
+        public static final int in_right_to_left=0x7f040001;
+        public static final int out_left_to_right=0x7f040002;
+        public static final int out_right_to_left=0x7f040003;
+    }
+    public static final class array {
+        public static final int protocols=0x7f070002;
+        public static final int upload_entries=0x7f070000;
+        public static final int upload_values=0x7f070001;
+    }
+    public static final class attr {
+    }
+    public static final class dimen {
+        /**  Default screen margins, per the Android Design guidelines. 
+
+         Customize dimensions originally defined in res/values/dimens.xml (such as
+         screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+    
+         */
+        public static final int activity_horizontal_margin=0x7f060000;
+        public static final int activity_vertical_margin=0x7f060001;
+    }
+    public static final class drawable {
+        public static final int ic_launcher=0x7f020000;
+        public static final int light_green=0x7f020001;
+        public static final int light_green_large=0x7f020002;
+        public static final int light_grey=0x7f020003;
+        public static final int light_grey_large=0x7f020004;
+        public static final int light_red=0x7f020005;
+        public static final int light_red_large=0x7f020006;
+        public static final int light_yellow=0x7f020007;
+        public static final int light_yellow_large=0x7f020008;
+    }
+    public static final class id {
+        public static final int TextViewServices=0x7f0b000f;
+        public static final int action_settings=0x7f0b001e;
+        public static final int buttonDeleteLog=0x7f0b001a;
+        public static final int buttonExportDatabase=0x7f0b0018;
+        public static final int buttonShowLog=0x7f0b0005;
+        public static final int buttonUploadLog=0x7f0b0019;
+        public static final int checkBoxParanoid=0x7f0b0003;
+        public static final int imageViewLight=0x7f0b0002;
+        public static final int layoutContainer=0x7f0b0012;
+        public static final int listViewProtocols=0x7f0b0010;
+        public static final int textFirstAttack=0x7f0b0013;
+        public static final int textFirstAttackValue=0x7f0b0014;
+        public static final int textLastAttack=0x7f0b0015;
+        public static final int textLastAttackValue=0x7f0b0016;
+        public static final int textLogFile=0x7f0b0017;
+        public static final int textStatistics=0x7f0b0011;
+        public static final int textViewBSSID=0x7f0b0009;
+        public static final int textViewBSSIDValue=0x7f0b000a;
+        public static final int textViewConnections=0x7f0b001c;
+        public static final int textViewConnectionsValue=0x7f0b001d;
+        public static final int textViewDetails=0x7f0b0006;
+        public static final int textViewExternalIP=0x7f0b000d;
+        public static final int textViewExternalIPValue=0x7f0b000e;
+        public static final int textViewInternalIP=0x7f0b000b;
+        public static final int textViewInternalIPValue=0x7f0b000c;
+        public static final int textViewProtocol=0x7f0b001b;
+        public static final int textViewSSID=0x7f0b0007;
+        public static final int textViewSSIDValue=0x7f0b0008;
+        public static final int textViewStatus=0x7f0b0001;
+        public static final int toggleButtonOnOff=0x7f0b0004;
+        public static final int viewAnimator=0x7f0b0000;
+    }
+    public static final class layout {
+        public static final int activity_main=0x7f030000;
+        public static final int activity_viewlog=0x7f030001;
+        public static final int list_view_protocols_row=0x7f030002;
+    }
+    public static final class menu {
+        public static final int main=0x7f0a0000;
+    }
+    public static final class string {
+        public static final int action_settings=0x7f080001;
+        public static final int app_name=0x7f080000;
+        public static final int bssid=0x7f080008;
+        public static final int capital_off=0x7f080003;
+        public static final int capital_on=0x7f080002;
+        public static final int connections=0x7f08000c;
+        public static final int details=0x7f080006;
+        public static final int external_ip=0x7f08000a;
+        public static final int firstAttack=0x7f08000f;
+        public static final int internal_ip=0x7f080009;
+        public static final int lastAttack=0x7f080010;
+        public static final int logFile=0x7f08000e;
+        public static final int paranoid=0x7f080005;
+        public static final int pref_alarm=0x7f080012;
+        public static final int pref_alarm_default=0x7f080013;
+        public static final int pref_external_storage_summ=0x7f080016;
+        public static final int pref_external_storage_title=0x7f080015;
+        public static final int pref_notification=0x7f080017;
+        public static final int pref_storage=0x7f080014;
+        public static final int pref_tracing=0x7f08001a;
+        public static final int pref_upload=0x7f08001b;
+        public static final int pref_upload_connection=0x7f08001d;
+        public static final int pref_upload_connection_summ=0x7f08001e;
+        public static final int pref_upload_summ=0x7f08001c;
+        public static final int pref_vibration=0x7f080018;
+        public static final int pref_vibration_summ=0x7f080019;
+        public static final int services=0x7f08000b;
+        public static final int settings=0x7f080011;
+        public static final int ssid=0x7f080007;
+        public static final int statistics=0x7f08000d;
+        public static final int status=0x7f080004;
+    }
+    public static final class style {
+        /** 
+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+    
+
+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.
+        
+
+        Base application theme for API 11+. This theme completely replaces
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
+    
+ API 11 theme customizations can go here. 
+
+        Base application theme for API 14+. This theme completely replaces
+        AppBaseTheme from BOTH res/values/styles.xml and
+        res/values-v11/styles.xml on API 14+ devices.
+    
+ API 14 theme customizations can go here. 
+         */
+        public static final int AppBaseTheme=0x7f090000;
+        /**  Application theme. 
+ All customizations that are NOT specific to a particular API-level can go here. 
+         */
+        public static final int AppTheme=0x7f090001;
+    }
+    public static final class xml {
+        public static final int preferences=0x7f050000;
+    }
+}

+ 7 - 7
src/de/tudarmstadt/informatik/hostage/protocol/SMB.java

@@ -122,7 +122,7 @@ public final class SMB implements Protocol<ByteArray> {
 		return "SMB";
 	}
 
-	public byte[] concat(byte[]... bytes) {
+	private byte[] concat(byte[]... bytes) {
 		int newSize = 0;
 		for (byte[] b : bytes)
 			newSize += b.length;
@@ -138,7 +138,7 @@ public final class SMB implements Protocol<ByteArray> {
 		return dst;
 	}
 
-	public byte[] getTimeInBytes() {
+	private byte[] getTimeInBytes() {
 		long time = System.currentTimeMillis();
 		Calendar calend = Calendar.getInstance();
 		calend.setTimeZone(TimeZone.getTimeZone("UTC"));
@@ -156,18 +156,18 @@ public final class SMB implements Protocol<ByteArray> {
 		return b;
 	}
 
-	public byte[] randomBytes(int size) {
+	private byte[] randomBytes(int size) {
 		byte[] bytes = new byte[size];
 		Random rdm = new Random();
 		rdm.nextBytes(bytes);
 		return bytes;
 	}
 
-	public String byteToStr(byte[] bytes) {
+	private String byteToStr(byte[] bytes) {
 		return charToString(byteToChar(bytes));
 	}
 	
-	public String charToString(char[] chars) {
+	private String charToString(char[] chars) {
 		char[] newChars = new char[chars.length];
 		for (int i = 0, j = 0; i < chars.length && j < newChars.length; i++) {
 			if (isLetter(chars[i])) {
@@ -178,14 +178,14 @@ public final class SMB implements Protocol<ByteArray> {
 		return new String(newChars);
 	}
 
-	public byte[] charToByte(char[] chars) {
+	private byte[] charToByte(char[] chars) {
 		byte[] bytes = new byte[chars.length];
 		for (int i = 0; i < chars.length; i++)
 			bytes[i] = (byte) chars[i];
 		return bytes;
 	}
 
-	public char[] byteToChar(byte[] bytes) {
+	private char[] byteToChar(byte[] bytes) {
 		char[] chars = new char[bytes.length];
 		for (int i = 0; i < bytes.length; i++)
 			chars[i] = (char) bytes[i];

+ 94 - 61
src/de/tudarmstadt/informatik/hostage/protocol/TELNET.java

@@ -15,6 +15,8 @@ public final class TELNET implements Protocol<ByteArray> {
 
 	private byte[] usr;
 	private byte[] cmd;
+	private String machine = "raspberrypi";
+	private byte[] session = null;
 
 	@Override
 	public int getPort() {
@@ -23,58 +25,88 @@ public final class TELNET implements Protocol<ByteArray> {
 
 	@Override
 	public TALK_FIRST whoTalksFirst() {
-		return TALK_FIRST.CLIENT;
+		return TALK_FIRST.SERVER;
 	}
 
 	@Override
 	public List<ByteArray> processMessage(ByteArray message) {
+		byte[] request = message.get();
 		List<ByteArray> response = new ArrayList<ByteArray>();
 		switch (state) {
 		case NONE:
 			response.add(new ByteArray(cmdRequests));
-			response.add(new ByteArray(getCmdResponses(message.get())));
 			state = STATE.OPEN;
 			break;
 		case OPEN:
-			response.add(new ByteArray("Debian GNU/Linux 7.0\r\n".getBytes()));
-			response.add(new ByteArray("raspberrypi login: ".getBytes()));
-			state = STATE.LOGIN;
+			if(request != null) {
+				response.add(new ByteArray(getCmdResponses(request)));
+				response.add(new ByteArray("Debian GNU/Linux 7.0\r\n"));
+				response.add(new ByteArray(machine + "login: "));
+				state = STATE.LOGIN;
+			}
 			break;
 		case LOGIN:
-			if(message.get()[0] == (byte) 0xff && message.get()[1] == (byte) 0xf4) {
-				state = STATE.CLOSED;
+			if(request == null) break;
+			else if(request[0] == 0x0d) {
+				response.add(new ByteArray("\r\n"));
+				response.add(new ByteArray("Password: "));
+				state = STATE.AUTHENTICATE;
+				session = concat(sessionPrefix, "@".getBytes(), machine.getBytes(), sessionMiddle, "@".getBytes(), machine.getBytes(), sessionSuffix);
 				break;
+			} else if (request[0] == 0x7f) {
+				byte[] tmp = new byte[usr.length - 1];
+				System.arraycopy(usr, 0, tmp, 0, usr.length - 1);
+				usr = tmp;
+				response.add(new ByteArray("\b \b"));
+			} else if (request[0] != (byte) 0xff){
+				if(usr == null)
+					usr = request;
+				else
+					usr = concat(usr, request);
+				response.add(message);
 			}
-			usr = new byte[message.size()-2];
-			System.arraycopy(message.get(), 0, usr, 0, message.size() - 2);
-			response.add(new ByteArray("Password: ".getBytes()));
-			state = STATE.AUTHENTICATE;
 			break;
 		case AUTHENTICATE:
-			if(message.get()[0] == 0xff && message.get()[1] == 0xf4) {
-				state = STATE.CLOSED;
-				break;
-			}
-			response.add(new ByteArray("Last Login: \r\nLinux raspberrypi 3.6.11+\r\n".getBytes()));
-			response.add(new ByteArray(concatenate(a, usr, b, usr, c)));
-			state = STATE.LOGGED_IN;
+			if(request == null) break;
+			else if(request[0] == 0x0d) {
+				response.add(new ByteArray("Last Login: \r\nLinux" + machine + " 3.6.11+\r\n"));
+				response.add(new ByteArray(session));
+				state = STATE.LOGGED_IN;
+			} else if (request[0] == 0x7f) {
+				response.add(new ByteArray("\b \b"));
+			}			
 			break;
 		case LOGGED_IN:
-			 cmd = new byte[message.size()-2];
-			System.arraycopy(message.get(), 0, cmd, 0, message.size() - 2);
-			if (new String(cmd).contains("exit")) {
-				response.add(new ByteArray("logout\r\n".getBytes()));
-				state = STATE.CLOSED;
-			} else {
-				String bash = "-bash: " + new String(cmd)
-						+ ": command not found";
-				response.add(new ByteArray(bash.getBytes()));
-				response.add(new ByteArray("\r\n".getBytes()));
-				response.add(new ByteArray(concatenate(a, usr, b, usr, c)));
+			if(request == null) break;
+			else if(request[0] == 0x0d) {
+				if(cmd == null) {
+					response.add(new ByteArray("\r\n"));
+					response.add(new ByteArray(session));
+				} else if (new String(cmd).contains("exit")) {
+					response.add(new ByteArray("\r\nlogout\r\n"));
+					state = STATE.CLOSED;
+				} else {
+					String bash = "\r\n-bash: " + new String(cmd)+ ": command not found";
+					response.add(new ByteArray(bash));
+					response.add(new ByteArray("\r\n"));
+					response.add(new ByteArray(session));
+					cmd = null;
+				}
+			} else if (request[0] == 0x7f) {
+				byte[] tmp = new byte[cmd.length - 1];
+				System.arraycopy(cmd, 0, tmp, 0, cmd.length - 1);
+				cmd = tmp;
+				response.add(new ByteArray("\b \b"));
+			} else if (request[0] != (byte) 0xff){
+				if(cmd == null)
+					cmd = request;
+				else
+					cmd = concat(cmd, request);
+				response.add(message);
 			}
 			break;
 		default:
-			response.add(new ByteArray("\r\nlogout\r\n".getBytes()));
+			response.add(new ByteArray("\r\nlogout\r\n"));
 			state = STATE.CLOSED;
 			break;
 		}
@@ -90,45 +122,46 @@ public final class TELNET implements Protocol<ByteArray> {
 	public boolean isSecure() {
 		return false;
 	}
-
-	@Override
-	public Class<ByteArray> getType() {
-		return ByteArray.class;
-	}
-
 	@Override
 	public String toString() {
 		return "TELNET";
 	}
+	
+	@Override
+	public Class<ByteArray> getType() {
+		return ByteArray.class;
+	}
 
 	private byte[] getCmdResponses(byte[] request) {
-		byte[] resp = new byte[request.length];
-		for (int i = 0; i < resp.length - 2; i += 3) { // respond to all
-														// requests with no
-			resp[i] = (byte) 0xff;
-			if (request[i + 1] == (byte) 0xfb)
-				resp[i + 1] = (byte) 0xfe;
-			else if (request[i + 1] == (byte) 0xfd)
-				resp[i + 1] = (byte) 0xfc;
-			else
-				resp[i + 1] = (byte) 0xfe;
-			resp[i + 2] = request[i + 2];
+		List<byte[]> respList = new ArrayList<byte[]>();
+		byte[] cmdResp;
+		for(int i = 0; i < request.length - 2; i += 3) {
+			if(request[i] == (byte) 0xff && request[i+2] != 0x03 && request[i+2] != 0x01) {
+				cmdResp = new byte[3];
+				cmdResp[0] = request[i];
+				cmdResp[1] = request[i + 1] == (byte) 0xfd ? (byte) 0xfc : (byte) 0xfe; 
+				cmdResp[2] = request[i+2];
+				respList.add(cmdResp);
+			}			
 		}
-		return resp;
+		byte[] response = new byte[0];
+		for(byte[] resp : respList) {
+			response = concat(response, resp);
+		}
+		return response;
 	}
 
-	private final byte[] cmdRequests = { (byte) 0xff, (byte) 0xfd, 0x18,
-			(byte) 0xff, (byte) 0xfd, 0x20, (byte) 0xff, (byte) 0xfd, 0x27 };
-	private final byte[] a = { 0x1b, 0x5d, 0x30, 0x3b };
-	private final byte[] b = { 0x40, 0x72, 0x61, 0x73, 0x70, 0x62, 0x65, 0x72,
-			0x72, 0x79, 0x70, 0x69, 0x3a, 0x20, 0x7e, 0x07, 0x1b, 0x5b, 0x30,
-			0x31, 0x3b, 0x33, 0x32, 0x6d };
-	private final byte[] c = { 0x40, 0x72, 0x61, 0x73, 0x70, 0x62, 0x65, 0x72,
-			0x72, 0x79, 0x70, 0x69, 0x1b, 0x5b, 0x30, 0x30, 0x6d, 0x20, 0x1b,
-			0x5b, 0x30, 0x31, 0x3b, 0x33, 0x34, 0x6d, 0x7e, 0x20, 0x24, 0x1b,
-			0x5b, 0x30, 0x30, 0x6d, 0x20 };
-
-	public byte[] concatenate(byte[]... bytes) {
+	private final byte[] cmdRequests = {(byte) 0xff, (byte) 0xfb, 0x03,
+										(byte) 0xff, (byte) 0xfb, 0x01};
+
+	private final byte[] sessionPrefix = {0x1b, 0x5d, 0x30, 0x3b};
+	private final byte[] sessionMiddle = {0x40, 0x72, 0x61, 0x73, 
+			0x70, 0x62, 0x65, 0x72, 0x72, 0x79, 0x70, 0x69, 0x3a, 0x20, 0x7e, 0x07, 0x1b, 0x5b, 0x30, 0x31, 
+			0x3b, 0x33, 0x32, 0x6d};	
+	private final byte[] sessionSuffix = {0x1b, 0x5b, 0x30, 0x30, 0x6d, 0x20, 0x1b, 0x5b, 0x30, 0x31, 
+			0x3b, 0x33, 0x34, 0x6d, 0x7e, 0x20, 0x24, 0x1b, 0x5b, 0x30, 0x30, 0x6d, 0x20};
+
+	private byte[] concat(byte[]... bytes) {
 		int newSize = 0;
 		for (byte[] b : bytes)
 			newSize += b.length;
@@ -144,4 +177,4 @@ public final class TELNET implements Protocol<ByteArray> {
 		return dst;
 	}
 
-}
+}

+ 4 - 0
src/de/tudarmstadt/informatik/hostage/wrapper/ByteArray.java

@@ -11,6 +11,10 @@ public class ByteArray {
 	public ByteArray(byte[] array) {
 		this.array = array;
 	}
+	
+	public ByteArray(String string) {
+		this.array = string.getBytes();
+	}
 
 	public byte[] get() {
 		return array;