当前位置:网站首页>Yyds dry goods inventory # look up at the sky | talk about the way and principle of capturing packets on the mobile terminal and how to prevent mitm
Yyds dry goods inventory # look up at the sky | talk about the way and principle of capturing packets on the mobile terminal and how to prevent mitm
2022-07-02 16:33:00 【Petterpx】
Capturing packages is for every developer , It should be said that it is one of the most basic skills , Recently, due to the needs of the company, I came into contact with some bag grabbing related , Also encountered some strange problems , So make a simple record , Hope to help you .
Commonly used packet capturing tools on mobile terminals
A good workman does his work well , You must sharpen your tools first , Grab the bag , How can there be no good tools , For ordinary bag grabbing , We have the following tools
Fiddler
stay windows The environment is very good , It provides a series of packet capturing methods and subsequent scripts , Focus on , Script , This is also the reason why many people like .
Be careful : stay mac Poor support , The new version of the software lacks core function scripts , Experience is very poor .
Charles
Experience nice, stay Mac,windows Experience is ok , Support scheduled storage , Related scripts are not supported .( That's why it's not as good as fiddler The cause of the fire , stay mac It was a good experience )
AnyProxy
Alibaba's packet capturing tool , Use... On the web , Easy to use , Support js Script . Batch packet capturing can be considered .
summary
The following experiences are personal experience .
If it is windows user , I just want to practice my hand casually ,fiddler Bad choice ,mac user choice Charles.
If you want to analyze the data after catching it , Write to database , that AnyProxy and fiddler Can meet the needs ,mac Users directly consider AnyProxy that will do , Don't ask why , Asking is fiddler stay mac It's a lump of porridge .
Related use tutorials , A handful , I won't narrate here .
reminder : Remember to install the certificate , Remember Android7.0 following ( Above use xp frame , Or something else )
Principle of common bag capturing tools
It seems that it's a bit off the subject , Next, get back on track , What is the principle of the above packet capturing software ?
MITM, It's the middleman [Gong Ji],Ps: These two words involve violations
What is? MITM?
A picture is worth a thousand words ( Small gray figure )
In short , Little red and little green need to communicate , As a result, Xiao Hei, the middleman, overheard and forwarded them respectively .
Not having https Do you ?
Many people think that , use https No, that's fine , I have a certificate for verification , But ordinary https Still equivalent to streaking , Allied The above tools can still crawl through proxy plus forged root certificates https, See the following analysis for the specific principle .
Principle analysis
We use charles give an example .charles Equivalent to an intermediary agent . When the client communicates with the server , charles Receive the certificate of the server , Then dynamically generate a certificate and send it to the client , then charles As an intermediate agent on the client and The server Communication between , So relevant communication data Can be Charles Intercept .
As described in the figure below :
The specific steps are as follows :
- client To the server launch HTTPS request
- Charles Intercept client requests , Masquerading as a client making a request to the server
- The server towards client Back to the server CA certificate . ( In fact, it has been Charles Intercept )
- Charles Intercept the server's response , Get server certificate public key , Then make a certificate of your own , Replace the certificate of the server and send it to client .
- client Received The server ( It's actually Charles Certificate ) After the certificate , Generate a symmetric secret key , And use Charles The certificate sent back is encrypted with public key , Send to The server ( Actually sent to Charles)
- Charles Intercept the response from the client , Decrypt the symmetric secret key with your own private key ( Here we have got the symmetric key ), Then use the server certificate public key to encrypt , Send to the server .
- The server decrypts the symmetric secret key with its own private key , Client side ( the truth is that Charles) send out Respond to
- Charles Intercept server response , Replace it with your own certificate and send it to the client .
- thus , Link building , Charles Got it The public key of the server certificate and Symmetric secret key negotiated by client and server , Then you can decrypt or modify the encrypted message .
That's why we catch https You need to install the corresponding certificate , Because we have to make the client think the certificate is valid , That is, our certificate is also the root certificate , however Android7.0 in the future , Certificates manually installed by users will not be trusted , So we usually use xp Framework or other ways
How to prevent MITM?
Determine whether to set the proxy
When the network requests , Determine whether the client currently sets a proxy , If you set a proxy , It is forbidden to visit .
Client local certificate validation
The client does certificate verification locally , And setting not only verifies the public key , Set complete formal verification mode . In this case , The certificate will not only verify the domain name when verifying the request , The public key and other information in the certificate will also be verified , In this case , Certificates forged by intermediaries cannot be verified , Unable to capture packets .
Https Request and corresponding data are encrypted
Encrypt the data encrypted by the certificate again , In this way, even if the other party has replaced the certificate , Then the data we see is still a pile of data after chaos .
Last , The above are my true understanding and actual feelings , There are risks in catching bags , Just practice your hands , Don't be a black and gray industry
Reference blog
I am a Petterp , If you think my article is helpful to you , Welcome to thumb up , If you have any thoughts and questions , Feel free to discuss in the comment area .
边栏推荐
- Practice of traffic recording and playback in vivo
- In memory of becoming the first dayu200 tripartite demo contributor
- Unity使用UGUI设置一个简单多级水平方向下拉菜单(不需要代码)
- Solve * * warning * *: your ApplicationContext is unlikely to start due to a @componentscan of the defau
- 结构体的内存对齐
- (practice C language every day) the sum of the nearest three numbers
- Summary of monthly report | list of major events of moonbeam in June
- Unity Json 编写
- 忆当年高考|成为程序员的你,后悔了吗?
- Best practices for building multi architecture images
猜你喜欢
Mobile web development learning notes - Layout
Maui learning road (III) -- in depth discussion of winui3
Rock PI Development Notes (II): start with rock PI 4B plus (based on Ruixing micro rk3399) board and make system operation
SSM integration exception handler and project exception handling scheme
End time processing method of wechat v3native payment settings
Foreign enterprise executives, continuous entrepreneurs, yoga and skiing masters, and a program life of continuous iteration and reconstruction
JS learning notes - variables
JS learning notes - process control
头条 | 亚控科技产品入选中纺联《纺织服装行业数字化转型解决方案重点推广名录》
TypeScript数组乱序输出
随机推荐
Data security industry series Salon (III) | data security industry standard system construction theme Salon
JS learning notes - data types
Set the background picture in the idea (ultra detailed)
源码look me
Mathematical analysis_ Notes_ Chapter 5: univariate differential calculus
数学分析_笔记_第6章:一元函数的Riemann积分
After the win10 system is upgraded for a period of time, the memory occupation is too high
台积电全球员工薪酬中位数约46万,CEO约899万;苹果上调日本的 iPhone 售价 ;Vim 9.0 发布|极客头条...
Idea public method extraction shortcut key
Typescript array out of order output
Vscode设置标签页多行显示
由ASP.NET Core根据路径下载文件异常引发的探究
Aujourd'hui dans l'histoire: Alipay lance le paiement par code à barres; La naissance du père du système de partage du temps; La première publicité télévisée au monde...
day4
Unity Json 编写
What is Amazon keyword index? The consequences of not indexing are serious
How to use stustr function in Oracle view
Song of cactus - throwing stones to ask the way (2)
day4
HMS core machine learning service helps zaful users to shop conveniently