Exemple #1
0
        public override bool Run()
        {
            // Check mongo
            XploitMongoRepository <HttpCredential> cHttpCredential = new XploitMongoRepository <HttpCredential>(Repository);

            CreateJob(new Task(DoJob));
            return(true);
        }
Exemple #2
0
        void DoJob()
        {
            XploitMongoRepository <TelnetCredential> cTelnetCredential = new XploitMongoRepository <TelnetCredential>(Repository);
            XploitMongoRepository <HttpAttack>       cHttpAttack       = new XploitMongoRepository <HttpAttack>(Repository);
            XploitMongoRepository <Pop3Credential>   cPop3Credential   = new XploitMongoRepository <Pop3Credential>(Repository);
            XploitMongoRepository <HttpCredential>   cHttpCredential   = new XploitMongoRepository <HttpCredential>(Repository);
            XploitMongoRepository <FTPCredential>    cFTPCredential    = new XploitMongoRepository <FTPCredential>(Repository);

            using (MySqlConnection con = new MySqlConnection(ConnectionString))
            {
                con.Open();

                using (MySqlCommand cmd = con.CreateCommand())
                {
                    // Watch collections
                    Task t1 = Task.Run(() => { foreach (RemovableValue <TelnetCredential> r in cTelnetCredential.Watch())
                                               {
                                                   r.Remove = Run(r.Value, cmd);
                                               }
                                       });
                    Task t2 = Task.Run(() => { foreach (RemovableValue <HttpAttack> r in cHttpAttack.Watch())
                                               {
                                                   r.Remove = Run(r.Value, cmd);
                                               }
                                       });
                    Task t3 = Task.Run(() => { foreach (RemovableValue <Pop3Credential> r in cPop3Credential.Watch())
                                               {
                                                   r.Remove = Run(r.Value, cmd);
                                               }
                                       });
                    Task t4 = Task.Run(() => { foreach (RemovableValue <HttpCredential> r in cHttpCredential.Watch())
                                               {
                                                   r.Remove = Run(r.Value, cmd);
                                               }
                                       });
                    Task t5 = Task.Run(() => { foreach (RemovableValue <FTPCredential> r in cFTPCredential.Watch())
                                               {
                                                   r.Remove = Run(r.Value, cmd);
                                               }
                                       });

                    Task.WaitAll(t1, t2, t3, t4, t5);
                }
            }
        }
Exemple #3
0
        public override ECheck Check()
        {
            bool ok1 = false, ok2 = false, ok3 = false, ok4 = false;

            using (MySqlConnection con = new MySqlConnection(ConnectionString))
            {
                con.Open();
                using (MySqlCommand cmd = con.CreateCommand())
                {
                    cmd.CommandText = @"
CREATE TABLE IF NOT EXISTS `hosts` (
  `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `IP` varchar(40) NOT NULL DEFAULT '',
  `CONTINENT` char(2) NOT NULL DEFAULT '',
  `COUNTRY` char(2) NOT NULL DEFAULT '',
  PRIMARY KEY (`ID`),
  UNIQUE KEY `IP_UNIQUE` (`IP`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
";

                    cmd.ExecuteNonQuery();
                    ok1 = ExistTable(cmd, "hosts");
                    WriteInfo("Creating hosts table", ok1 ? "OK" : "ERROR", ok1 ? ConsoleColor.Green : ConsoleColor.Red);

                    cmd.CommandText = @"
CREATE TABLE IF NOT EXISTS `credentials_http` (
  `HOST` bigint(20) NOT NULL,
  `PORT` smallint(5) unsigned NOT NULL,
  `PROTOCOL` enum('TCP','UDP') NOT NULL,
  `TYPE` varchar(100) NOT NULL DEFAULT '',
  `HTTP_HOST` varchar(1000) NOT NULL DEFAULT '',
  `HTTP_URL` varchar(1000) NOT NULL DEFAULT '',
  `USER` varchar(1000) NOT NULL DEFAULT '',
  `PASS` varchar(1000) NOT NULL DEFAULT '',
  PRIMARY KEY (`HOST`,`PORT`,`PROTOCOL`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
";
                    cmd.ExecuteNonQuery();
                    ok2 = ExistTable(cmd, "credentials_http");
                    WriteInfo("Creating credentials_http table", ok2 ? "OK" : "ERROR", ok2 ? ConsoleColor.Green : ConsoleColor.Red);

                    cmd.CommandText = @"
CREATE TABLE IF NOT EXISTS `attacks_http` (
  `HOST` bigint(20) NOT NULL,
  `PORT` smallint(5) unsigned NOT NULL,
  `PROTOCOL` enum('TCP','UDP') NOT NULL,
  `TYPE` varchar(100) NOT NULL DEFAULT '',
  `HTTP_HOST` varchar(1000) NOT NULL DEFAULT '',
  `HTTP_URL` varchar(1000) NOT NULL DEFAULT '',
  `GET` json NOT NULL,
  `POST` json NOT NULL,
  PRIMARY KEY (`HOST`,`PORT`,`PROTOCOL`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
";
                    cmd.ExecuteNonQuery();
                    ok3 = ExistTable(cmd, "attacks_http");
                    WriteInfo("Creating attacks_http table", ok3 ? "OK" : "ERROR", ok3 ? ConsoleColor.Green : ConsoleColor.Red);
                }
            }

            try
            {
                XploitMongoRepository <HttpCredential> cHttpCredential = new XploitMongoRepository <HttpCredential>(Repository);
                WriteInfo("Creating mongo connection", "OK", ConsoleColor.Green);
                ok4 = true;
            }
            catch (Exception e)
            {
                WriteError(e.ToString());
            }

            return(ok1 && ok2 && ok3 && ok4 ? ECheck.Ok : ECheck.Error);
        }
        public override ECheck Check()
        {
            bool ok1 = false, ok2 = false, ok3 = false, ok4 = false;

            using (MySqlConnection con = new MySqlConnection(ConnectionString))
            {
                con.Open();
                using (MySqlCommand cmd = con.CreateCommand())
                {
                    // -----
                    cmd.CommandText = @"
CREATE TABLE IF NOT EXISTS  `hosts` (
  `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `IP` varchar(40) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `CONTINENT` char(2) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `COUNTRY` char(2) NOT NULL DEFAULT '',
  `DATE_INS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`),
  UNIQUE KEY `IP_UNIQUE` (`IP`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";

                    cmd.ExecuteNonQuery();
                    ok1 = ExistTable(cmd, "hosts");
                    WriteInfo("Creating hosts table", ok1 ? "OK" : "ERROR", ok1 ? ConsoleColor.Green : ConsoleColor.Red);
                    // -----
                    cmd.CommandText = @"
CREATE TABLE IF NOT EXISTS  `credentials_http` (
  `HOST` bigint(20) NOT NULL,
  `PORT` smallint(5) unsigned NOT NULL,
  `TYPE` varchar(20) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `USER` varchar(100) NOT NULL DEFAULT '',
  `PASS` varchar(100) NOT NULL DEFAULT '',
  `VALID` tinyint(4) NOT NULL DEFAULT '0',
  `DATE` date NOT NULL,
  `HOUR` char(5) CHARACTER SET latin1 NOT NULL DEFAULT '00:00',
  `HTTP_CRC` char(32) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `HTTP_HOST` varchar(1000) NOT NULL DEFAULT '',
  `HTTP_URL` varchar(1000) NOT NULL DEFAULT '',
  PRIMARY KEY (`HTTP_CRC`,`HOUR`,`DATE`,`VALID`,`PASS`,`USER`,`TYPE`,`PORT`,`HOST`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";
                    cmd.ExecuteNonQuery();

                    ok2 = ExistTable(cmd, "credentials_http");
                    WriteInfo("Creating credentials_http table", ok2 ? "OK" : "ERROR", ok2 ? ConsoleColor.Green : ConsoleColor.Red);// -----
                    // -----
                    cmd.CommandText = @"
CREATE TABLE IF NOT EXISTS  `credentials_telnet` (
  `HOST` bigint(20) NOT NULL,
  `PORT` smallint(5) unsigned NOT NULL,
  `TYPE` varchar(20) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `USER` varchar(100) NOT NULL DEFAULT '',
  `PASS` varchar(100) NOT NULL DEFAULT '',
  `VALID` tinyint(4) NOT NULL DEFAULT '0',
  `DATE` date NOT NULL,
  `HOUR` char(5) CHARACTER SET latin1 NOT NULL DEFAULT '00:00',
  PRIMARY KEY (`HOST`,`PORT`,`TYPE`,`USER`,`PASS`,`VALID`,`DATE`,`HOUR`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";
                    cmd.ExecuteNonQuery();

                    ok2 = ExistTable(cmd, "credentials_telnet");
                    WriteInfo("Creating credentials_telnet table", ok2 ? "OK" : "ERROR", ok2 ? ConsoleColor.Green : ConsoleColor.Red);
                    // -----
                    cmd.CommandText = @"
CREATE TABLE IF NOT EXISTS  `credentials_ftp` (
  `HOST` bigint(20) NOT NULL,
  `PORT` smallint(5) unsigned NOT NULL,
  `TYPE` varchar(20) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `USER` varchar(100) NOT NULL DEFAULT '',
  `PASS` varchar(100) NOT NULL DEFAULT '',
  `VALID` tinyint(4) NOT NULL DEFAULT '0',
  `DATE` date NOT NULL,
  `HOUR` char(5) CHARACTER SET latin1 NOT NULL DEFAULT '00:00',
  PRIMARY KEY (`HOST`,`PORT`,`TYPE`,`USER`,`PASS`,`VALID`,`DATE`,`HOUR`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";
                    cmd.ExecuteNonQuery();

                    ok2 = ExistTable(cmd, "credentials_ftp");
                    WriteInfo("Creating credentials_ftp table", ok2 ? "OK" : "ERROR", ok2 ? ConsoleColor.Green : ConsoleColor.Red);
                    // -----
                    cmd.CommandText = @"
CREATE TABLE IF NOT EXISTS  `credentials_pop3` (
  `HOST` bigint(20) NOT NULL,
  `PORT` smallint(5) unsigned NOT NULL,
  `TYPE` varchar(20) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `AUTH_TYPE` varchar(20) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `USER` varchar(100) NOT NULL DEFAULT '',
  `PASS` varchar(100) NOT NULL DEFAULT '',
  `VALID` tinyint(4) NOT NULL DEFAULT '0',
  `DATE` date NOT NULL,
  `HOUR` char(5) CHARACTER SET latin1 NOT NULL DEFAULT '00:00',
  PRIMARY KEY (`DATE`,`HOUR`,`VALID`,`USER`,`PASS`,`AUTH_TYPE`,`TYPE`,`PORT`,`HOST`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
;";
                    cmd.ExecuteNonQuery();

                    ok2 = ExistTable(cmd, "credentials_pop3");
                    WriteInfo("Creating credentials_pop3 table", ok2 ? "OK" : "ERROR", ok2 ? ConsoleColor.Green : ConsoleColor.Red);
                    // -----

                    cmd.CommandText = @"
CREATE TABLE IF NOT EXISTS `attacks_http` (
  `HOST` bigint(20) NOT NULL,
  `PORT` smallint(5) unsigned NOT NULL,
  `TYPE` varchar(20) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `DATE` date NOT NULL,
  `HOUR` char(5) CHARACTER SET latin1 NOT NULL DEFAULT '00:00',
  `HTTP_CRC` char(32) CHARACTER SET latin1 NOT NULL,
  `HTTP_HOST` varchar(200) NOT NULL DEFAULT '',
  `HTTP_URL` varchar(1000) NOT NULL DEFAULT '',
  `HTTP_QUERY` json NOT NULL,
  PRIMARY KEY (`HOST`,`PORT`,`TYPE`,`DATE`,`HOUR`,`HTTP_CRC`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
                    ";
                    cmd.ExecuteNonQuery();
                    ok3 = ExistTable(cmd, "attacks_http");
                    WriteInfo("Creating attacks_http table", ok3 ? "OK" : "ERROR", ok3 ? ConsoleColor.Green : ConsoleColor.Red);
                    // -----
                }
            }

            try
            {
                XploitMongoRepository <HttpCredential> cHttpCredential = new XploitMongoRepository <HttpCredential>(Repository);
                WriteInfo("Creating mongo connection", "OK", ConsoleColor.Green);
                ok4 = true;
            }
            catch (Exception e)
            {
                WriteError(e.ToString());
            }

            return(ok1 && ok2 && ok3 && ok4 ? ECheck.Ok : ECheck.Error);
        }