当前位置:网站首页>JS reverse case: cracking login password
JS reverse case: cracking login password
2022-06-26 00:55:00 【Algorithm channel】
I am not a professional IT personnel , But yes. python Reptiles are of great interest , I read it on Tiktok zhen The teacher's python Full stack live course , Decisively choose to join zhen The teacher's VIP big family , to zhen Teachers can also make money by submitting articles ,50 element .
I don't say much nonsense , Get into the subject . Studying recently JS reverse Knowledge of , Because I've done it before 12306 Automatic ticket grabbing Software , So right. 12306 show special preference to 🤭, Next, I'd like to introduce you 12306 Parameter cracking method for user login password .
First let's open up 12306 Login interface of , Open grab tool , Enter the user name and an incorrect password ( example :123456), Click the login button and slide the verification code to verify , stay Ajax In the package, we can click login This package goes into view , We can find out password This parameter is encrypted , So we need to find the corresponding encryption js Code , Analyze the encryption mechanism , And use python Realization .

First, click the arrow in the upper right corner of the developer tool to indicate the location , The second step is to find search And click the , A search box will pop up below , Step 3 enter... In the search box password, Step 4 Click the search button next to it , Contains password All the files of keywords are in here , We click in every file from top to bottom to find , look down password The location of the encryption algorithm in the file .

After query and analysis ,password In the second file , We find the corresponding JS Code , And hit a breakpoint .


After hitting the breakpoint , Here we enter the user name and password , Click login , At this point, it is found that the browser stops at the breakpoint , As shown in the figure below

At this point, let's analyze this line carefully JS Code , It is found that the last generated parameter is "@" Plus the result returned by an encryption function , The first parameter of this function is obviously the plaintext password we entered (123456), The second parameter is our public key , It is fixed as SM4_key ="tiekeyuankp12306", So we can finally encapsulate a JS function , The code is as follows :
function getpwd(p){
var SM4_key = 'tiekeyuankp12306';
return '@' + encrypt_ecb(p, SM4_key)
}
console.log(getpwd('123456'))Now we need to find encrypt_ecb The specific implementation of this function , We place the mouse over the function , And click the encryption function pointed by the arrow , We found that we entered an encrypted function file , There are all encryption algorithms .

Through the analysis of , There are specific encryption and decryption algorithms we need , And the code of this file is only 300 Multiple lines , So we can dig it all out , Put it into the top of the function we just encapsulated for debugging , After running the code , We found a bug in the program , Tips :base64js Undefined , Therefore, the principle of "what is missing, what is missing" is implemented to supplement the principle of "what is missing" base64js The relevant code section of .

At this point, we continue to search in the way just now base64js part , Found a file named base64js Of , And only 100 Many lines of code , At this point, we will copy it all to the top of the code we just ran , Run again , We found that we still reported an error , Tips :base64js Undefined .
Now I have a little friend to ask , I will all base64js It's all in , Why not ? Actually base64js This object is complex , After we dug it out JS Not recognized in the code . We are carefully analyzing the errors reported , Find out base64js Of fromByteArray The method is the function P, But let's just replace it all with P Function is not feasible , The same will be reported P Function undefined error .
At this time, we are analyzing carefully , We found that it can completely replace base64js This thing , First we will P Function is copied to the top of the code , And then base64js.fromByteArray(outArray) Replace with P(outArray), Operation tips l Function undefined , Look for l Copy the part of the function to the top of the code , Debug in this run , According to the principle of what is missing and what is missing in the program , Make corresponding supplement .

Last , Add the completed code to debug and run , give the result as follows :

Will be JS The code is packaged into a JS file , utilize python Of execjs The package can run js Code , Call directly JS In the document getpwd Function ,python The code is as follows :
import execjs
f = open(r"test2.js", encoding='utf-8').read()
ctx = execjs.compile(f)
FuncName = 'getpwd'
password = ctx.call(FuncName, '123456')
print(password)It's going on JS In the beginning of reverse learning , Don't just skim the code , Still learn to analyze JS Code , Then start with simplicity , Accumulate experience , Gradually, it will become more and more handy when encountering encryption parameters .
边栏推荐
- [OEM special event] in the summer of "core cleaning", there are prize papers
- Final review [machine learning]
- mysql
- Should group by be used whenever aggregate functions are used in SQL?
- Methods of modifying elements in JS array
- Is camkiia the same as gcamp6f?
- 1-9network configuration in VMWare
- Wireshark's analysis of IMAP packet capturing
- "Seamless" deployment of paddlenlp model based on openvinotm development kit
- 213. house raiding II
猜你喜欢

ADC acquisition noise and comparison between RMS filter and Kalman filter

Vscode shortcut

Atlas200dk刷机

11.1.1 overview of Flink_ Flink overview

FPGA notes -- implementation of FPGA floating point operation

Explain from a process perspective what happens to the browser after entering a URL?

How product managers control the progress of product development

Msp430f5529lp official board (red) can not debug the problem

ciscn_ 2019_ en_ two

Web學習之TypeScript
随机推荐
Flink报错:Error: A JNI error has occurred, please check your installation and try again
[image detection] vascular tracking and diameter estimation based on Gaussian process and Radon transform with matlab code
4 key points to help the product manage the project well
Performance leads the cloud native database market! Intel and Tencent jointly build cloud technology ecology
mongodb
How product managers control the progress of product development
jarvisoj_level2_x64
Motor monitoring system based on MCGS and stm32
Blob
Web學習之TypeScript
Analyze the five root causes of product development failure
Compiler Telegram Desktop end (tdesktop) en utilisant vs2022
Chapter V exercises (124, 678, 15, 19, 22) [microcomputer principles] [exercises]
CXF
Preordered clue binary tree
Redisson 3.17.4 发布
debezium
继承--圣杯模式
FPGA notes -- implementation of FPGA floating point operation
AD20(Altium Designer) PCB 高亮网络