JavaScript逆向分析instagram登入過程
一、流程分析
分析發(fā)現(xiàn)密碼加密,且發(fā)送POST請求時header必須攜帶x-csrftoken,否則是報403。
而x-csrftoken是在第一次訪問主頁的時候設置的。
二、逆向分析
通過查看請求堆棧找到生成處,當然也可以直接采用搜索大法,白貓黑貓抓到耗子就是好貓。
通過逐步下斷點分析函數(shù)作用及各種參數(shù)傳入返回,慢慢溯源最終找到生成處。
其中 i(d[1]).encrypt(t, c, u, f) 是主要邏輯,放到Node中缺啥補啥跑起來就ok,當然也可以用其他語言重寫。
s = { encrypt: async function(s, c, h, l) { const u = o + h.length; if (64 !== c.length) throw new Error('public key is not a valid hex sting'); const w = n(c); if (!w) throw new Error('public key is not a valid hex string'); const y = new Uint8Array(u); let f = 0; y[f] = 1, y[f += 1] = s, f += 1; const p = { name: 'AES-GCM', iv: new Uint8Array(12), additionalData: l, tagLen: 16 } , A = window.crypto || window.msCrypto; return A.subtle.generateKey({ name: 'AES-GCM', length: 256 }, !0, ['encrypt', 'decrypt']).then(function(t) { const n = A.subtle.exportKey('raw', t) , o = A.subtle.encrypt(p, t, h.buffer); return Promise.all([n, o]) }).then(function(n) { const o = t(new Uint8Array(n[0]), w); if (y[f] = 255 & o.length, y[f + 1] = o.length >> 8 & 255, f += 2, y.set(o, f), f += 32, f += r(d[0]).overheadLength, o.length !== 32 + r(d[0]).overheadLength) throw new Error('encrypted key is the wrong length'); const s = new Uint8Array(n[1]) , c = s.slice(-16) , h = s.slice(0, -16); return y.set(c, f), f += 16, y.set(h, f), y }).catch(function(t) { throw t }) } };
三、模擬請求
首先訪問主頁,獲取到csrftoken,然后把加密后的密碼還有csrftoken組裝起來,POST即可,因為賬號密碼是我瞎填的所以user和authenticated都是false,試了下提交正常賬號也是完美沒有問題滴。
import requests def get_proxy(): return { "http":"http://"+ip, "https": "https://" + ip, } headers = { 'authority': 'www.instagram.com', 'origin': 'https://www.instagram.com', 'referer': 'https://www.instagram.com/', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36', } cookie = requests.get('https://www.instagram.com/',headers=headers, proxies=get_proxy()).cookies headers['x-csrftoken']= cookie.get('csrftoken') # node服務 enc_password = requests.get('http://localhost:23346/instagram?password=1111111111111111111111').text print(enc_password) data = { 'enc_password': enc_password, 'username': '15566678899', 'queryParams': '{}', 'optIntoOneTap': 'false', 'stopDeletionNonce': '', 'trustedDeviceRecords': '{}' } response = requests.post('https://www.instagram.com/accounts/login/ajax/', headers=headers, data=data, proxies=get_proxy()) print(response.status_code) print(response.text) # 運行結果 #PWD_INSTAGRAM_BROWSER:10:1658217374:AVtQAGM39dHHEHtO7U0tFDVnhUk+Wg2VMRNtL+jtmdLx5fpegdgNyMnTmBPfBWUP0lBNGBK9rrAyX4PZfdVMEf0ksXa5s98X/SlIVF78g92WU4w0JnQHArjoIlNzLNcb+wyuy1SBDRsN92Wy5dw+ghaBC7hSUNpVrmE= 200 {"user":false,"authenticated":false,"status":"ok"}
到此這篇關于JavaScript逆向分析instagram登入過程的文章就介紹到這了,更多相關js逆向分析instagram登入內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
JavaScript創(chuàng)建對象的七種方式(推薦)
JavaScript創(chuàng)建對象的方式有很多,通過Object構造函數(shù)或對象字面量的方式也可以創(chuàng)建單個對象,顯然這兩種方式會產(chǎn)生大量的重復代碼,并不適合量產(chǎn)。接下來介紹七種非常經(jīng)典的創(chuàng)建對象的方式,他們也各有優(yōu)缺點2017-06-06如何利用 JS 腳本實現(xiàn)網(wǎng)頁全自動秒殺搶購功能
這篇文章主要介紹了如何利用 JS 腳本實現(xiàn)網(wǎng)頁全自動秒殺搶購功能,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-10-10JavaScript中for..in循環(huán)陷阱介紹
for...in循環(huán)中的循環(huán)計數(shù)器是字符串,而不是數(shù)字它包含當前屬性的名稱或當前數(shù)組元素的索引,下面有個不錯的示例大家可以參考下2013-11-11JavaScript中windows.open()、windows.close()方法詳解
這篇文章主要介紹了JavaScript中windows.open()、windows.close()方法詳解 的相關資料,需要的朋友可以參考下2016-07-07