From 78b691e113e7e48fca0eb918591a17437fa0b96d Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Thu, 27 Apr 2017 02:52:51 +0100 Subject: Fix WEBIRC not rejecting invalid IP addresses. --- src/modules/m_cgiirc.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index cce2e7855..d26c0bca1 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -73,6 +73,7 @@ class CommandWebirc : public Command realhost("cgiirc_realhost", Creator), realip("cgiirc_realip", Creator), webirc_hostname("cgiirc_webirc_hostname", Creator), webirc_ip("cgiirc_webirc_ip", Creator) { + allow_empty_last_param = false; works_before_reg = true; this->syntax = "password client hostname ip"; } @@ -81,6 +82,13 @@ class CommandWebirc : public Command if(user->registered == REG_ALL) return CMD_FAILURE; + irc::sockets::sockaddrs ipaddr; + if (!irc::sockets::aptosa(parameters[3], 0, ipaddr)) + { + ServerInstance->SNO->WriteGlobalSno('a', "Connecting user %s tried to use WEBIRC but gave an invalid IP address.", user->GetFullRealHost().c_str()); + return CMD_FAILURE; + } + for(CGIHostlist::iterator iter = Hosts.begin(); iter != Hosts.end(); iter++) { if(InspIRCd::Match(user->host, iter->hostmask, ascii_case_insensitive_map) || InspIRCd::MatchCIDR(user->GetIPString(), iter->hostmask, ascii_case_insensitive_map)) -- cgit v1.2.3 From fefb6235cd8398408f92f93b9009718b6bed4cd7 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Thu, 27 Apr 2017 02:56:59 +0100 Subject: Penalise clients that use WEBIRC incorrectly. --- src/modules/m_cgiirc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index d26c0bca1..09f6a4659 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -85,6 +85,7 @@ class CommandWebirc : public Command irc::sockets::sockaddrs ipaddr; if (!irc::sockets::aptosa(parameters[3], 0, ipaddr)) { + IS_LOCAL(user)->CommandFloodPenalty += 5000; ServerInstance->SNO->WriteGlobalSno('a', "Connecting user %s tried to use WEBIRC but gave an invalid IP address.", user->GetFullRealHost().c_str()); return CMD_FAILURE; } @@ -116,6 +117,7 @@ class CommandWebirc : public Command } } + IS_LOCAL(user)->CommandFloodPenalty += 5000; ServerInstance->SNO->WriteGlobalSno('a', "Connecting user %s tried to use WEBIRC, but didn't match any configured webirc blocks.", user->GetFullRealHost().c_str()); return CMD_FAILURE; } -- cgit v1.2.3