package de.tudarmstadt.informatik.hostage.commons; import java.security.SecureRandom; public class ProtocolSettings { //TODO documentation //TODO all decisions here private static SecureRandom rndm = new SecureRandom(); private static String[][][] possibleHttpVersions = { {{"Apache/2.0."},{"28","32","35","36","39","40","42","43","44","45","46","47","48","49","50","51","52","53","54","55","58","59","61","63","64","65"}}, {{"Apache/2.2."},{"0","2","3","4","6","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25"}}, {{"Apache/2.3."},{"4","5","6","8","10","11","12","14","15","16"}}, {{"Apache/2.4."},{"1","2","3","4","6"}} }; private static String[][][] possibleMysqlVersions = { {{"5.7."},{"1","2"}}, {{"5.6."},{"2","3","4","5","6","7","8","9","10","11","12","13","14"}}, {{"5.5."},{"27","28","29","30","31","32","33","34"}} }; private static String[][] possibleSmbVersions = { {"Windows Server 2008 R2 Enterprise 7600","Windows Server 2008 R2 Enterprise 6.1"}, {"Windows 7 Professional 7600","Windows 7 Professional 6.1"}, {"Windows 8 Enterprise 9200", "Windows 8 Enterprise 9200"}, {"Windows Server 2012 Standard 6.2", "Windows Server 2012 Standard 6.2"}, {"Unix", "Samba"} }; //HTTP private static String httpQotd ; //is initialized by honeyservice private static String httpVersion = initHttpVersion(); private static boolean useHttpQotd = true; //TODO //MySQL private static String mysqlVersion = initMysqlVersion(); //SMB private static byte[] smbName = initSmbName(); private static String[] smbVersion = initSmbVersion(); //TELNET private static String telnetName = initTelnetName(); private static String telnetVersion = initTelnetVersion(); //SSH private static String sshVersion = initSshVersion(); private static String sshType = initSshType(); private static String initHttpVersion() { int majorVersion = rndm.nextInt(3); return possibleHttpVersions[majorVersion][0][0] + possibleHttpVersions[majorVersion][1][rndm.nextInt(possibleHttpVersions[majorVersion][1].length)]; } private static String initMysqlVersion() { int majorVersion = rndm.nextInt(3); return possibleMysqlVersions[majorVersion][0][0] + possibleMysqlVersions[majorVersion][1][rndm.nextInt(possibleMysqlVersions[majorVersion][1].length)]; } private static byte[] initSmbName() { return HelperUtils.fillWithZero(HelperUtils.getRandomString(16, true).getBytes()); } private static String[] initSmbVersion() { return possibleSmbVersions[rndm.nextInt(possibleSmbVersions.length)]; } private static String initTelnetName() { return HelperUtils.getRandomString(16, false); } private static String initTelnetVersion() { //TODO return "ToBeDone"; } private static String initSshVersion() { return "SSH-2.0-"; } private static String initSshType() { //TODO return "OpenSSH_6.0p1"; } //~~~ Getters and Setters ~~// public static String getHttpQotd() { return httpQotd; } public static void setHttpQotd(String httpQotd) { ProtocolSettings.httpQotd = httpQotd; } public static String getHttpVersion() { return httpVersion; } public static void setHttpVersion(String httpVersion) { ProtocolSettings.httpVersion = httpVersion; } public static boolean isUseHttpQotd() { return useHttpQotd; } public static void setUseHttpQotd(boolean useHttpQotd) { ProtocolSettings.useHttpQotd = useHttpQotd; } public static String getMysqlVersion() { return mysqlVersion; } public static void setMysqlVersion(String mysqlVersion) { ProtocolSettings.mysqlVersion = mysqlVersion; } public static byte[] getSmbName() { return smbName; } public static void setSmbName(byte[] smbName) { ProtocolSettings.smbName = smbName; } public static String[] getSmbVersion() { return smbVersion; } public static void setSmbVersion(String[] smbVersion) { ProtocolSettings.smbVersion = smbVersion; } public static String getTelnetName() { return telnetName; } public static void setTelnetName(String telnetName) { ProtocolSettings.telnetName = telnetName; } public static String getTelnetVersion() { return telnetVersion; } public static void setTelnetVersion(String telnetVersion) { ProtocolSettings.telnetVersion = telnetVersion; } public static String getSshVersion() { return sshVersion; } public static void setSshVersion(String sshVersion) { ProtocolSettings.sshVersion = sshVersion; } public static String getSshType() { return sshType; } public static void setSshType(String sshType) { ProtocolSettings.sshType = sshType; } }