|
@@ -1,195 +0,0 @@
|
|
|
-package de.tudarmstadt.informatik.hostage.protocol;
|
|
|
-
|
|
|
-import java.security.SecureRandom;
|
|
|
-
|
|
|
-import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
|
|
|
-
|
|
|
-/**
|
|
|
- * This class holds informations for all protocols, e.g. server name, version etc.
|
|
|
- * It provides getters and setters.
|
|
|
- * @author Wulf Pfeiffer
|
|
|
- */
|
|
|
-public class ProtocolSettings {
|
|
|
- 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"}
|
|
|
- };
|
|
|
- private static String[][][] possibleSshTypes = {
|
|
|
- {{"3."},{"4","5","6","7","8","9"}},
|
|
|
- {{"4."},{"0","1","2","3","4","5","6","7","9"}},
|
|
|
- {{"5."},{"0","1","2","3","4","5","6","7","8","9"}},
|
|
|
- {{"6."},{"0","1","2","3","4"}}
|
|
|
- };
|
|
|
- //Custom Echo
|
|
|
- private static int customPort = initCustomPort();
|
|
|
- //HTTP
|
|
|
- private static String httpQotd ; //is initialized by honeyservice
|
|
|
- private static String httpVersion = initHttpVersion();
|
|
|
- private static boolean useHttpQotd = true;
|
|
|
- //MySQL
|
|
|
- private static String mysqlVersion = initMysqlVersion();
|
|
|
- //SMB
|
|
|
- private static byte[] smbName = initSmbName();
|
|
|
- private static String[] smbVersion = initSmbVersion();
|
|
|
- //TELNET
|
|
|
- private static String telnetName = initTelnetName();
|
|
|
- //SSH
|
|
|
- private static String sshVersion = initSshVersion();
|
|
|
- private static String sshType = initSshType();
|
|
|
- private static String sshName = initSshName();
|
|
|
-
|
|
|
- //~~~ Initialize methods ~~~//
|
|
|
-
|
|
|
- public static void initForLinux() {
|
|
|
- smbVersion = possibleSmbVersions[1];
|
|
|
- }
|
|
|
-
|
|
|
- public static void initForWindows() {
|
|
|
- smbVersion = possibleSmbVersions[4];
|
|
|
- }
|
|
|
-
|
|
|
- private static int initCustomPort() {
|
|
|
- return 1433; //MsSQL Port
|
|
|
- }
|
|
|
-
|
|
|
- private static String initHttpVersion() {
|
|
|
- int majorVersion = rndm.nextInt(possibleHttpVersions.length);
|
|
|
- return possibleHttpVersions[majorVersion][0][0] + possibleHttpVersions[majorVersion][1][rndm.nextInt(possibleHttpVersions[majorVersion][1].length)];
|
|
|
- }
|
|
|
-
|
|
|
- private static String initMysqlVersion() {
|
|
|
- int majorVersion = rndm.nextInt(possibleMysqlVersions.length);
|
|
|
- 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 initSshVersion() {
|
|
|
- return "SSH-2.0-";
|
|
|
- }
|
|
|
-
|
|
|
- private static String initSshType() {
|
|
|
- int majorVersion = rndm.nextInt(possibleSshTypes.length);
|
|
|
- return "OpenSSH_" + possibleSshTypes[majorVersion][0][0] + possibleSshTypes[majorVersion][1][rndm.nextInt(possibleSshTypes[majorVersion][1].length)];
|
|
|
- }
|
|
|
-
|
|
|
- private static String initSshName() {
|
|
|
- return HelperUtils.getRandomString(16, false);
|
|
|
- }
|
|
|
-
|
|
|
- //~~~ Getters and Setters ~~//
|
|
|
-
|
|
|
- public static int getCustomPort() {
|
|
|
- return customPort;
|
|
|
- }
|
|
|
-
|
|
|
- public static void setCustomPort(int customPort) {
|
|
|
- ProtocolSettings.customPort = customPort;
|
|
|
- }
|
|
|
-
|
|
|
- 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 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;
|
|
|
- }
|
|
|
-
|
|
|
- public static String getSshName() {
|
|
|
- return sshName;
|
|
|
- }
|
|
|
-
|
|
|
- public static void setSsh(String sshName) {
|
|
|
- ProtocolSettings.sshName = sshName;
|
|
|
- }
|
|
|
-
|
|
|
-}
|