Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”
This article also participated in the “Digitalstar Project” to win a creative gift package and creative incentive money
Code shrimp is a sand carving and funny boy who likes listening to music, playing games and writing as well as most of his friends. The days are still very long, let’s refuel our efforts together 🌈
If you feel well written, ball ball a concern oh 😉
Open Baidu Translate
Reverse analysis
Open the control bar, input a word in the input box, you can see the corresponding request on the right, request the translation result
Let’s examine this request
The first thing you notice is that this request is a POST request, so there must be a request body
As you can see below is the request body, let’s analyze it individually
From: en to: en # query: love transtype: realtime simple_means_flag: 3 # Token: 198772.518981 e8ee595fdb9a062d2d41124d778ebd79 domain: commonCopy the code
Change one to translate, compare the above and the following can be found,token
The values are the same, butsign
Changed the
Try a few more, you can make sure that sign changes with the translation stability, token is sure to remain unchanged
Analysis of the sign
Search v2TransAPI, because this request is made every time to get the translation result, so we search for this keyword
Break point, refresh request to see
And you can see that we’re stopping here, which means we’re on the right track
As you can see, the data in the request body comes from above, so let’s break the point at sign and see how sign is generated
You can see that it is the result of JS encryption and so on, but there is a key value involved, and that iswindow[l]
, we temporarily do not look, to analyze the token
Analysis of the token
Visible, the token is passedwindow.common.token
Acquired? How do we know what it is
It’s okay. Just search if you need to
As you can see, the token is originally generated when the page is accessed, no wonder it is fixed
If you search the page for tokens, you’ll also find this onewindow.gtk
Do you remember when there was awindow[l]
, I directly take the picture comparison, see the following picture understand it
Train of thought to sort out
- First, we need to get the token value and GTK, which will be used later
- Generate sign, you can copy JS, use Python libraries to manipulate JS, pass parameters to generate sign
- Simulate the initial POST request to get the translation result
- The end of the
Video teaching
Life is too good? Hardcore works: [Baidu translation JS reverse], nanny level tutorials, you deserve it! _bilibili bilibili
Line does not change the name, sit does not change the surname, the whole network is Code shrimp, feel good, ball ball has a key three even oh, ha ha 😁
💖 finally
I am aCode pipi shrimp, a prawns lover who loves to share knowledge, will update useful blog posts in the future, looking forward to your attention!!
Creation is not easy, if this blog is helpful to you, I hope you can key three even oh! Thank you for your support. See you next time