LOGGED!
This commit is contained in:
parent
36b9ca18c9
commit
cae3848490
1 changed files with 16 additions and 7 deletions
|
@ -58,19 +58,23 @@ let rec _inject_password session_id creds try_count =
|
||||||
send_keys session_id input creds.password;
|
send_keys session_id input creds.password;
|
||||||
Unix.sleep 1;
|
Unix.sleep 1;
|
||||||
send_keys session_id input Keys.return;
|
send_keys session_id input Keys.return;
|
||||||
Unix.sleep 5
|
Unix.sleep 3
|
||||||
| None -> ()
|
| None -> ()
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let inject_password session_id creds = _inject_password session_id creds 1
|
let inject_password session_id creds = _inject_password session_id creds 1
|
||||||
|
|
||||||
let inject_2fa _session_id secret _entry =
|
let inject_2fa session_id secret input =
|
||||||
let _code =
|
let code =
|
||||||
match secret with
|
match secret with
|
||||||
| Some seed -> Twostep.TOTP.code ~secret:seed ()
|
| Some seed -> Twostep.TOTP.code ~secret:seed ()
|
||||||
| None -> raise (Any "No TOTP code given, but TOTP required")
|
| None -> raise (Any "No TOTP code given, but TOTP required")
|
||||||
in
|
in
|
||||||
()
|
(* Insert 2FA code *)
|
||||||
|
send_keys session_id input code;
|
||||||
|
Unix.sleep 1;
|
||||||
|
send_keys session_id input Keys.return;
|
||||||
|
Unix.sleep 5
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let login_twitter ctx username password secret =
|
let login_twitter ctx username password secret =
|
||||||
|
@ -83,10 +87,15 @@ let login_twitter ctx username password secret =
|
||||||
(* Find password input *)
|
(* Find password input *)
|
||||||
inject_password ctx.session_id creds;
|
inject_password ctx.session_id creds;
|
||||||
(* Detection of 2FA *)
|
(* Detection of 2FA *)
|
||||||
match find ctx.session_id (XPath "XPATH_TOTP") with
|
match
|
||||||
| [] -> ()
|
find
|
||||||
|
ctx.session_id
|
||||||
|
(XPath
|
||||||
|
"/html/body/div[1]/div/div/div[1]/div/div/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div[1]/div/div[2]/label/div/div[2]/div/input")
|
||||||
|
with
|
||||||
|
| [] -> print_endline "Don't use 2FA input as input not found"
|
||||||
| _ as l ->
|
| _ as l ->
|
||||||
if List.length l > 1
|
if List.length l > 1
|
||||||
then raise (Any "Too many element found as the username input")
|
then raise (Any "Too many element found as 2FA input")
|
||||||
else inject_2fa ctx.session_id secret (List.nth l 0)
|
else inject_2fa ctx.session_id secret (List.nth l 0)
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue