From 206da60f0ff22556aae063aa76e2da021bbf9ff4 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 19 Jun 2017 13:19:56 +0000 Subject: [PATCH] added a library for challenge authentication using CRC32 as the hash. will be improved to use better stuff later --- modules/library/chauth.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 modules/library/chauth.lua diff --git a/modules/library/chauth.lua b/modules/library/chauth.lua new file mode 100644 index 0000000..70070d0 --- /dev/null +++ b/modules/library/chauth.lua @@ -0,0 +1,23 @@ +function chauths(cA,nP,pW) + C.yield() + C.yield() + local rs="" + for i = 1, 16 do rs=rs..string.char(math.random(33,126)) end + ns(cA,nP,"char,"..rs) + while true do + if ev[1] == "net_msg" and ev[2] == cA and ev[3] == nP then + return (ev[4] == "chaa,"..string.format("%x",crc32.hash(pW..rs))) + end + C.yield() + end +end + +function chauthc(sA,nP,pW) + while true do + if ev[1] == "net_msg" and ev[2] == sA and ev[3] == nP and ev[4]:sub(1,5) == "char," then + ns(sA,nP,"chaa,"..string.format("%x",crc32.hash(pW..ev[4]:sub(6)))) + break + end + C.yield() + end +end