X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=fba%2Fcsrf.py;h=4602c284910c243294866bd0c8cff7316caf7305;hb=b4b7a362cf34916fccecded268a717f6263c2d84;hp=00ec0f32122693257cdd6d77119ce86e9e8b17e4;hpb=cf97879ab67e9bf53c15d0c7aae3b7d00503c81f;p=fba.git diff --git a/fba/csrf.py b/fba/csrf.py index 00ec0f3..4602c28 100644 --- a/fba/csrf.py +++ b/fba/csrf.py @@ -21,7 +21,7 @@ from fba import config from fba import network def determine(domain: str, headers: dict) -> dict: - print(f"DEBUG: domain='{domain}',headers()={len(headers)} - CALLED!") + # DEBUG: print(f"DEBUG: domain='{domain}',headers()={len(headers)} - CALLED!") if not isinstance(domain, str): raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'") elif domain == "": @@ -33,26 +33,26 @@ def determine(domain: str, headers: dict) -> dict: reqheaders = headers # Fetch / to check for meta tag indicating csrf - print(f"DEBUG: Fetching / from domain='{domain}' for CSRF check ...") + # DEBUG: print(f"DEBUG: Fetching / from domain='{domain}' for CSRF check ...") response = reqto.get( f"https://{domain}/", headers=network.web_headers, timeout=(config.get("connection_timeout"), config.get("read_timeout")) ) - print(f"DEBUG: response.ok='{response.ok}',response.status_code={response.status_code},response.text()={len(response.text)}") + # DEBUG: print(f"DEBUG: response.ok='{response.ok}',response.status_code={response.status_code},response.text()={len(response.text)}") if response.ok and len(response.text) > 0: meta = bs4.BeautifulSoup( response.text, "html.parser" ) - print(f"DEBUG: meta[]='{type(meta)}'") + # DEBUG: print(f"DEBUG: meta[]='{type(meta)}'") tag = meta.find("meta", attrs={"name": "csrf-token"}) - print(f"DEBUG: tag={tag}") + # DEBUG: print(f"DEBUG: tag={tag}") if tag is not None: - print(f"DEBUG: Adding CSRF token='{tag['content']}' for domain='{domain}'") + # DEBUG: print(f"DEBUG: Adding CSRF token='{tag['content']}' for domain='{domain}'") reqheaders["X-CSRF-Token"] = tag["content"] - print(f"DEBUG: reqheaders()={len(reqheaders)} - EXIT!") + # DEBUG: print(f"DEBUG: reqheaders()={len(reqheaders)} - EXIT!") return reqheaders