js加密(七)steam登陸

1. url: https://store.steampowered.com/login/?redir=&redir_ssl=1python

2. target: 登陸json

 

 3. 分析dom

3.1 老樣子,抓包,找js。函數

隨便輸入一個賬號密碼,點擊登陸,看看發送了哪些請求。post

 

 一次登陸,發送了兩次請求,第一次的請求結果是一個json,裏面有兩個參數,是第二次請求中須要的,這個直接添加用戶名和一個時間戳發送post就能夠了,無論它。看dologin。學習

3.2 有一個password參數是加密的,其他兩個看起來不是很重要。下面就對這個參數進行解密。加密

 

 3.3 複製加密參數,去尋找哪裏出現了這個參數,這裏看起來比較像。url

 

 那就打上斷點調試,找依賴函數,變量,最終扣出可運行js代碼。spa

4. python代碼:調試

from afterWork.config import proxies, userAgent
import requests
import json
import time
import re
import execjs

def getModExp(data):
    res = requests.post(url='https://store.steampowered.com/login/getrsakey/',
                        data=data,
                        headers={'User-Agent': userAgent.random()})
    # print(res.text)
    jsonInfo = json.loads(res.text)
    mod = jsonInfo['publickey_mod']
    exp = jsonInfo['publickey_exp']
    return mod, exp

def getData(userName, donotcache):
    data = {
        'donotcache': donotcache,
        'username': userName
    }
    return json.loads(json.dumps(data))

def accountInfo():
    userName = '你的用戶名'
    pw = '你的密碼'
    donotcache = re.sub(r'\.', '', str(time.time()))[:-4]
    # print(donotcache)
    # print('1577238990888')

    return userName, pw, donotcache

def getJsCode():
    with open('jsCode.js', 'r') as f:
        jsCode = f.read()
        return jsCode

def getLoginData(username, pw, donotcache):
    loginData = {
                'donotcache': donotcache,
                'password': pw,
                'username': username,
                'twofactorcode': '',
                'emailauth': '',
                'loginfriendlyname': '',
                'captchagid': '-1',
                'captcha_text': '',
                'emailsteamid': '',
                'rsatimestamp': '111645050000',
                'remember_login': 'false'
                }
    print(loginData)
    return json.loads(json.dumps(loginData))

def login(loginData):
    res = requests.post(url='https://store.steampowered.com/login/dologin/',
                        data=loginData,
                        headers={'User-Agent': userAgent.random()})
    print(res.text)
    return

def mainFun():
    userName, pw, donotcache = accountInfo()
    data = getData(userName, donotcache)
    # print(type(data))
    mod, exp = getModExp(data)
    jsCode = getJsCode()
    ctx = execjs.compile(jsCode)
    result = ctx.call('getPW', pw, mod, exp)
    # print(result)
    loginData = getLoginData(userName, result, donotcache)
    # print(type(loginData))
    login(loginData)

if __name__ == '__main__':
    mainFun()

結果,登陸成功返回這些東西:

 

 學習交流,勿做他用。

相關文章
相關標籤/搜索