Skip to content

Commit 3db301e

Browse files
authored
Add MFA handling script in Selenium (#438)
Add selenium script to fill in fixed OTP. Signed-off-by: Najam Ul Saqib <[email protected]>
1 parent d30953b commit 3db301e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
99
to find and add subdomains to the Sites Tree.
1010
- passive/JavaDisclosure.js - Passive scan for Java error messages leaks
1111
- httpsender/RsaEncryptPayloadForZap.py - A script that encrypts requests using RSA
12+
- selenium/FillOTPInMFA.js - A script that fills the OTP in MFA
1213

1314
## [18] - 2024-01-29
1415
### Added

selenium/FillOTPInMFA.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
This script will fill the OTP if MFA is configured on web-app. Browser-based auth is the pre-requisite for this script.
3+
You need to analyze DOM of the web app this script needs to run on and modify the parameters accordingly.
4+
This script assumes that the web app has fixed OTP for testing which can be stored in the variable below.
5+
*/
6+
7+
function browserLaunched(utils) {
8+
var By = Java.type("org.openqa.selenium.By");
9+
var Thread = Java.type("java.lang.Thread");
10+
var url = utils.waitForURL(5000);
11+
var wd = utils.getWebDriver();
12+
var OTP = "123456";
13+
14+
wd.get(url + "#/login");
15+
Thread.sleep(30000); //Wait for ZAP to handle the auth.
16+
wd.findElement(By.id("one-time-code")).sendKeys(OTP); //Replace the input field as per your web-app's DOM
17+
Thread.sleep(1000);
18+
wd.executeScript("document.querySelector('[aria-label=\"Verify Code\"]').click()"); //Replace the submit label as per your web-app's DOM
19+
}

0 commit comments

Comments
 (0)