anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
enc_none.cpp (1775B)
1 /* Module for plain text encryption. 2 * 3 * (C) 2003-2022 Anope Team 4 * Contact us at team@anope.org 5 * 6 * This program is free but copyrighted software; see the file COPYING for 7 * details. 8 */ 9 10 #include "module.h" 11 12 class ENone : public Module 13 { 14 public: 15 ENone(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR) 16 { 17 18 } 19 20 EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_override 21 { 22 Anope::string buf = "plain:"; 23 Anope::string cpass; 24 Anope::B64Encode(src, cpass); 25 buf += cpass; 26 Log(LOG_DEBUG_2) << "(enc_none) hashed password from [" << src << "] to [" << buf << "]"; 27 dest = buf; 28 return EVENT_ALLOW; 29 } 30 31 EventReturn OnDecrypt(const Anope::string &hashm, const Anope::string &src, Anope::string &dest) anope_override 32 { 33 if (!hashm.equals_cs("plain")) 34 return EVENT_CONTINUE; 35 size_t pos = src.find(':'); 36 Anope::string buf = src.substr(pos + 1); 37 Anope::B64Decode(buf, dest); 38 return EVENT_ALLOW; 39 } 40 41 void OnCheckAuthentication(User *, IdentifyRequest *req) anope_override 42 { 43 const NickAlias *na = NickAlias::Find(req->GetAccount()); 44 if (na == NULL) 45 return; 46 NickCore *nc = na->nc; 47 48 size_t pos = nc->pass.find(':'); 49 if (pos == Anope::string::npos) 50 return; 51 Anope::string hash_method(nc->pass.begin(), nc->pass.begin() + pos); 52 if (!hash_method.equals_cs("plain")) 53 return; 54 55 Anope::string buf; 56 this->OnEncrypt(req->GetPassword(), buf); 57 if (nc->pass.equals_cs(buf)) 58 { 59 /* if we are NOT the first module in the list, 60 * we want to re-encrypt the pass with the new encryption 61 */ 62 if (ModuleManager::FindFirstOf(ENCRYPTION) != this) 63 Anope::Encrypt(req->GetPassword(), nc->pass); 64 req->Success(this); 65 } 66 } 67 }; 68 69 MODULE_INIT(ENone)