0x00 前言
有时候在渗透测试的时候,会遇到很多前端参数加密,当遇到特殊的一些加密方式时,爆破会比较麻烦,前段时间了解到jsrpc,但觉得配置两次比较麻烦,这里提供一下新的发现
0x01 selenium简介
Selenium 是一个开源的自动化测试工具,专门用于Web应用程序的测试。它允许测试脚本直接在浏览器中运行,模拟真实用户的操作。Selenium支持多种浏览器,包括IE、Firefox、Chrome、Safari等,并且可以在不同的操作系统上运行。它的主要功能包括测试与浏览器的兼容性,以及创建回归测试来检验软件功能和用户需求。此外,Selenium支持多种编程语言,如Java、Python、C#等,可以自动生成不同语言的测试脚本
0x01selenium配置及使用
Selenium可以通过封装函数和批量处理的方式来自动化和简化对JavaScript函数的调用,以chrome为例,需要配置webdriver(需要与chrome版本一致)
https://googlechromelabs.github.io/chrome-for-testing/#stable
假设有一个网站,这个网站没有验证码或验证码失效(可复用),该网站对登录请求处理进行了加密
对前端页面进行简单的分析,找到加密函数为encryptPwd(pwd)
可以通过selenium来进行批量调用encryptPwd方法将字典进行加密,然后使用burp进行爆破
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
def encrypt_password(driver, password):
"""调用页面的encryptPwd函数并返回结果"""
try:
#这里是修改加密函数以及参数的地方,多个参数修改函数的形参
return driver.execute_script('return encryptPwd(arguments[0]);', password)
except Exception as e:
print(f"Error executing script: {e}")
return None
# 将映射关系打印到终端
def mapping(passwords,encrypted_passwords):
for original, encrypted in zip(passwords, encrypted_passwords):
print(f"{original} -> {encrypted}")
if __name__ == '__main__':
# 启动Chrome浏览器
service = Service('/Users/xx/xx/xx/chromedriver-mac-x64/chromedriver')
# 配置无头浏览器选项
chrome_options = Options()
chrome_options.add_argument('--headless') # 启用无头模式
chrome_options.add_argument('--no-sandbox') # 针对某些环境的配置
chrome_options.add_argument('--disable-dev-shm-usage') # 解决共享内存不足
# 启动Chrome浏览器
driver = webdriver.Chrome(service=service,options=chrome_options)
# 替换为实际的网站地址
driver.get('https://xx.xx.xx.xx:port/xx/xx.jsp')
# 示例批量处理
passwords = [123456, 654321, 111111, 'abcdef']
encrypted_passwords = []
for pwd in passwords:
encrypted = encrypt_password(driver, pwd)
if encrypted is not None:
encrypted_passwords.append(encrypted)
mapping(passwords,encrypted_passwords)
# 关闭浏览器
driver.quit()
0x01selenium-js 联动AutoDecoder
联动autodecoder可以更好方便进行爆破处理,测试发现比jsrpc速率更快,配置也非常简单
首先搭建好selenium-js,使用autodecoder进行测试,成功进行加密,配置好options就可以使用了
0x02 selenium-js完整代码
https://github.com/xiaoabai/selenium-js/blob/main/selenium-web.py
0x02 免责声明
文章所涉及内容,仅供安全研究与教学之用,由于传播、利用本文所提供的信息而造成的任何直接或者间接的后果及损失,均由使用者本人负责,作者不为此承担任何责任。
原文始发于微信公众号(小白安全):加密暴力破解与selenium
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论