From 206efa55992ab72cb3e384f0b24f46c767770c2f Mon Sep 17 00:00:00 2001 From: cynic Date: Mon, 31 Oct 2022 21:53:31 -0400 Subject: [PATCH] add linux auth module --- auth.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/auth.py b/auth.py index e69de29..c7c0bf5 100644 --- a/auth.py +++ b/auth.py @@ -0,0 +1,12 @@ +import crypt + +def authenticate(u, p): + f = [i.split(":") for i in open("/etc/shadow").read().split("\n")] + d = dict(zip([i[0] for i in f], [i[1:] for i in f])) + if u not in d: + return False + return d[u][0] == crypt.crypt(p, d[u][0]) + +def get_real_users(): + f = [i.split(":") for i in open("/etc/shadow").read().split("\n")] + return [i[0] for i in filter(lambda a: len(a) > 1, f) if not(i[1] in ["*", "!"])] \ No newline at end of file