掛了代理之后竟然仍可以輕易找到真實ip
VSole2023-03-13 10:44:59
通過WEBRTC結合stun服務器實現獲取真實主機IP
測試:
真實IP:

掛代理之后的ip

保存以下代碼到本地:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
head>
<body>
<h3>你的代理IP是:<div id=1>div>
h3
>
<h3>你的真實IP是:<div id=2>div>
h3
> <script>
// turn 配置
const config = {
iceServers: [{
urls: "stun:stun.l.google.com:19302" // stun.voippro.com stun.voipraider.com 這里使用谷歌,線上部署直接替換
}]
};
// 構建
let pc = new RTCPeerConnection(config);
pc.onicecandidate = function(event) {
if(event.candidate)
handleCandidate(event.candidate.candidate);
}
function handleCandidate(candidate) {
if (candidate.indexOf("srflx") != -1) {
console.log(candidate)
var regex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/
var ip_addr = regex.exec(candidate)[0];
//alert("Your public network ip: "+ ip_addr)
document.getElementById('2').innerHTML = ip_addr;
}
}
pc.createDataChannel("");
pc.createOffer(function(result){
pc.setLocalDescription(result);
}, function(){});
script>
<script src='http://pv.sohu.com/cityjson?ie=utf-8'>script>
<script>
var ip=returnCitySN["cip"];
//var city=returnCitySN["cname"];
document.getElementById('1').innerHTML = ip;
script>
body>
html>
在掛代理的條件下,訪問,即可獲得 代理后面的真實IP:

具體WEBRTC、STUN的原理,感興趣的自行google
VSole
網絡安全專家