Advertisement
Techman

m_hunter2.cpp

Jan 7th, 2018
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. /*
  2.  * InspIRCd -- Internet Relay Chat Daemon
  3.  *
  4.  *   Copyright (C) 2014 Peter Powell <[email protected]>
  5.  *
  6.  * This file is part of InspIRCd.  InspIRCd is free software: you can
  7.  * redistribute it and/or modify it under the terms of the GNU General Public
  8.  * License as published by the Free Software Foundation, version 2.
  9.  *
  10.  * This program is distributed in the hope that it will be useful, but WITHOUT
  11.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12.  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  13.  * details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19.  
  20. /* $ModAuthor: Peter "SaberUK" Powell */
  21. /* $ModAuthorMail: [email protected] */
  22. /* $ModDesc: Fixes the BASH-244321 password leakage vulnerability. */
  23. /* $ModDepends: core 2.0 */
  24.  
  25. #include "inspircd.h"
  26.  
  27. class ModuleHunter2 : public Module
  28. {
  29.  private:
  30.      void CensorPassword(std::string& text)
  31.      {
  32.          size_t position;
  33.          while ((position = text.find("hunter2")) != std::string::npos)
  34.          {
  35.              text.replace(position, 7, "*******");
  36.          }
  37.      }
  38.  
  39.  public:
  40.     void init()
  41.     {
  42.         Implementation eventList[] = { I_OnUserPreMessage, I_OnUserPreNotice };
  43.         ServerInstance->Modules->Attach(eventList, this, sizeof(eventList)/sizeof(Implementation));
  44.     }
  45.  
  46.     ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list)
  47.     {
  48.         if (IS_LOCAL(user))
  49.             CensorPassword(text);
  50.         return MOD_RES_PASSTHRU;
  51.     }
  52.  
  53.     ModResult OnUserPreNotice(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list)
  54.     {
  55.         if (IS_LOCAL(user))
  56.             CensorPassword(text);
  57.         return MOD_RES_PASSTHRU;
  58.     }
  59.  
  60.     Version GetVersion()
  61.     {
  62.         return Version("Fixes the BASH-244321 password leakage vulnerability.");
  63.     }
  64. };
  65.  
  66. MODULE_INIT(ModuleHunter2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement