From 6dc33e31b6b5458e7d08597f2d0f2badebf527e3 Mon Sep 17 00:00:00 2001 From: Duncan Woosley <115438340+d-woosley@users.noreply.github.com> Date: Thu, 8 Aug 2024 06:30:41 -0500 Subject: [PATCH] Added support for MFA to login method of API.py (#3) Added support to pass TOTP token to API.login method. The default is still to not use a null token unless a token is passed. Also, fixed the output error message for the login to show the error "datas" instead of the "status" which seemed to be a mistake. --- pwndocapi/API.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pwndocapi/API.py b/pwndocapi/API.py index 146e87d..d146873 100755 --- a/pwndocapi/API.py +++ b/pwndocapi/API.py @@ -40,10 +40,10 @@ def __init__(self, host, port=443, ssl=True, verbose=True): self.verbose = verbose self.user = {"token": "", "refreshToken": ""} - def login(self, username, password): + def login(self, username, password, totp=""): r = self.session.post( self.target + "/api/users/token", - json={"username": username, "password": password, "totpToken": ""}, + json={"username": username, "password": password, "totpToken": totp}, verify=False ) if r.json()["status"] == "success": @@ -57,7 +57,7 @@ def login(self, username, password): self.loggedin = True elif r.json()["status"] == "error": if self.verbose: - print("[!] Login error. (%s)" % r.json()["status"]) + print("[!] Login error. (%s)" % r.json()["datas"]) self.loggedin = False return self.loggedin