|
@@ -17,10 +17,12 @@ import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Random;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import de.tudarmstadt.informatik.hostage.Hostage;
|
|
|
import de.tudarmstadt.informatik.hostage.Listener;
|
|
@@ -477,22 +479,46 @@ public class ProfileManager {
|
|
|
return mProfiles.size();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Pick n numbers between 0 (inclusive) and k (inclusive)
|
|
|
+ * While there are very deterministic ways to do this,
|
|
|
+ * for large k and small n, this could be easier than creating
|
|
|
+ * an large array and sorting, i.e. k = 10,000
|
|
|
+ */
|
|
|
+ public Set<Integer> pickRandom(int n, int s, int k) {
|
|
|
+ Random random = new Random(); // if this method is used often, perhaps define random at class level
|
|
|
+ Set<Integer> picked = new HashSet<Integer>();
|
|
|
+ while(picked.size() < n) {
|
|
|
+ picked.add(random.nextInt(k-s) + s);
|
|
|
+ }
|
|
|
+ return picked;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Fills the profiles manager with default profiles
|
|
|
*/
|
|
|
public void fillWithDefaultData(){
|
|
|
- Profile windowsVista = new Profile(
|
|
|
+ Profile windowsSeven = new Profile(
|
|
|
0,
|
|
|
- "Windows Vista",
|
|
|
- MainActivity.getInstance().getString(R.string.profile_vista_desc),
|
|
|
+ "Windows 7",
|
|
|
+ MainActivity.getInstance().getString(R.string.profile_seven_desc),
|
|
|
R.drawable.ic_profile_vista,
|
|
|
false
|
|
|
);
|
|
|
|
|
|
- windowsVista.mActiveProtocols.put("ECHO", true);
|
|
|
- windowsVista.mActiveProtocols.put("TELNET", true);
|
|
|
+ windowsSeven.mActiveProtocols.put("SMB", true);
|
|
|
+ windowsSeven.mGhostActive = true;
|
|
|
+ windowsSeven.mGhostPorts = "135,5357";
|
|
|
|
|
|
- this.addProfile(windowsVista, false);
|
|
|
+ for(int i: pickRandom(3, 49152, 70000)){
|
|
|
+ windowsSeven.mGhostPorts += "," + i;
|
|
|
+ }
|
|
|
+
|
|
|
+ windowsSeven.mActiveProtocols.put("ECHO", true);
|
|
|
+
|
|
|
+ this.addProfile(windowsSeven, false);
|
|
|
|
|
|
Profile windowsXP = new Profile(
|
|
|
1,
|
|
@@ -502,62 +528,71 @@ public class ProfileManager {
|
|
|
false
|
|
|
);
|
|
|
|
|
|
+ windowsXP.mActiveProtocols.put("SMB", true);
|
|
|
+ windowsXP.mGhostActive = true;
|
|
|
+ windowsXP.mGhostPorts = "135";
|
|
|
+
|
|
|
+ for(int i: pickRandom(3, 49152, 80000)){
|
|
|
+ windowsXP.mGhostPorts += "," + i;
|
|
|
+ }
|
|
|
+
|
|
|
windowsXP.mActiveProtocols.put("ECHO", true);
|
|
|
- windowsXP.mActiveProtocols.put("TELNET", true);
|
|
|
- windowsXP.mActiveProtocols.put("MySQL", true);
|
|
|
|
|
|
this.addProfile(windowsXP, false);
|
|
|
|
|
|
Profile serverHTTP = new Profile(
|
|
|
2,
|
|
|
- "Webserver HTTP",
|
|
|
- MainActivity.getInstance().getString(R.string.profile_webserv_http_desc),
|
|
|
+ "Web Server Apache",
|
|
|
+ MainActivity.getInstance().getString(R.string.profile_webserv_apache_desc),
|
|
|
R.drawable.ic_profile_apache,
|
|
|
false
|
|
|
);
|
|
|
|
|
|
serverHTTP.mActiveProtocols.put("HTTP", true);
|
|
|
+ serverHTTP.mActiveProtocols.put("HTTPS", true);
|
|
|
+ serverHTTP.mActiveProtocols.put("MYSQL", true);
|
|
|
|
|
|
this.addProfile(serverHTTP, false);
|
|
|
|
|
|
Profile serverWeb = new Profile(
|
|
|
3,
|
|
|
- "Webserver",
|
|
|
- MainActivity.getInstance().getString(R.string.profile_webserv_desc),
|
|
|
+ "Web Server IIS",
|
|
|
+ MainActivity.getInstance().getString(R.string.profile_webserv_iis_desc),
|
|
|
R.drawable.ic_profile_apache,
|
|
|
false
|
|
|
);
|
|
|
|
|
|
serverWeb.mActiveProtocols.put("HTTP", true);
|
|
|
serverWeb.mActiveProtocols.put("HTTPS", true);
|
|
|
+ serverWeb.mActiveProtocols.put("FTP", true);
|
|
|
|
|
|
this.addProfile(serverWeb, false);
|
|
|
|
|
|
Profile unixMachine = new Profile(
|
|
|
4,
|
|
|
- "Unix",
|
|
|
- MainActivity.getInstance().getString(R.string.profile_unix_desc),
|
|
|
+ "\"Hardened\" Linux system ",
|
|
|
+ MainActivity.getInstance().getString(R.string.profile_linux_hard_desc),
|
|
|
R.drawable.ic_profile_unix,
|
|
|
false
|
|
|
);
|
|
|
|
|
|
unixMachine.mActiveProtocols.put("SSH", true);
|
|
|
- unixMachine.mActiveProtocols.put("ECHO", true);
|
|
|
|
|
|
this.addProfile(unixMachine, false);
|
|
|
|
|
|
Profile linuxMachine = new Profile(
|
|
|
5,
|
|
|
- "Linux",
|
|
|
+ "Linux system",
|
|
|
MainActivity.getInstance().getString(R.string.profile_linux_desc),
|
|
|
R.drawable.ic_profile_linux,
|
|
|
false
|
|
|
);
|
|
|
|
|
|
- linuxMachine.mActiveProtocols.put("SSH", true);
|
|
|
+ linuxMachine.mActiveProtocols.put("FTP", true);
|
|
|
linuxMachine.mActiveProtocols.put("TELNET", true);
|
|
|
- linuxMachine.mActiveProtocols.put("ECHO", true);
|
|
|
- linuxMachine.mActiveProtocols.put("SMB", true);
|
|
|
+ linuxMachine.mActiveProtocols.put("HTTP", true);
|
|
|
+ linuxMachine.mActiveProtocols.put("HTTPS", true);
|
|
|
+ linuxMachine.mActiveProtocols.put("MYSQL", true);
|
|
|
|
|
|
this.addProfile(linuxMachine, false);
|
|
|
|