JavaScript逆向分析instagram登入过程
作者:ZRocket 时间:2023-09-08 19:51:52
一、流程分析
分析发现密码加密,且发送POST请求时header必须携带x-csrftoken,否则是报403。
而x-csrftoken是在第一次访问主页的时候设置的。
二、逆向分析
通过查看请求堆栈找到生成处,当然也可以直接采用搜索 * ,白猫黑猫抓到耗子就是好猫。
通过逐步下断点分析函数作用及各种参数传入返回,慢慢溯源最终找到生成处。
其中 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"}
来源:https://blog.csdn.net/qq_41179280/article/details/125872984?
标签:js,逆向分析,instagram,登入
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
深入理解vue中的slot与slot-scope
2024-05-05 09:07:18
![](https://img.aspxhome.com/file/2023/0/130850_0s.png)
Ranorex通过Python将报告发送到邮箱的方法
2021-08-17 03:57:43
![](https://img.aspxhome.com/file/2023/4/97654_0s.png)
ASP中的面向对象类
2011-04-11 10:34:00
ASP链接Mysql数据库 非DSN连接的方法
2009-03-09 18:24:00
使用typescript类型来实现快排详情
2024-06-05 09:13:15
Ubuntu16安装Python3.9的实现步骤
2021-01-23 14:04:53
![](https://img.aspxhome.com/file/2023/7/92397_0s.jpg)
python3爬虫怎样构建请求header
2023-04-17 19:01:45
![](https://img.aspxhome.com/file/2023/7/68857_0s.png)
学生如何注册Pycharm专业版以及pycharm的安装
2023-01-20 15:43:40
![](https://img.aspxhome.com/file/2023/5/133655_0s.png)
python计算日期之间的放假日期
2021-08-14 00:02:42
Python 中的装饰器实现函数的缓存(场景分析)
2022-07-30 01:37:08
MySQL如何修改账号的IP限制条件详解
2024-01-14 19:41:59
![](https://img.aspxhome.com/file/2023/0/124880_0s.png)
Linux下修改MySQL编码的方法
2024-01-27 02:36:15
![](https://img.aspxhome.com/file/2023/2/112892_0s.jpg)
python打包压缩、读取指定目录下的指定类型文件
2021-01-19 08:23:26
ubuntu 安装pyqt5和卸载pyQt5的方法
2021-08-25 07:18:41
python基于 Web 实现 m3u8 视频播放的实例
2022-06-15 22:16:40
Python:通配符查找、拷贝文件的操作
2021-09-05 13:05:03
![](https://img.aspxhome.com/file/2023/2/127922_0s.png)
Python中生成器和yield语句的用法详解
2022-06-04 16:56:19
mysql密码中有特殊字符&在命令行下登录的操作
2024-01-17 22:29:18
![](https://img.aspxhome.com/file/2023/9/71799_0s.jpg)
PHP采集静态页面并把页面css,img,js保存的方法
2023-10-22 19:44:22
Oracle 安装和卸载问题收集(集合篇)第1/6页
2009-07-02 12:20:00