最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to obtain user's public IPv4 address using WebRTC? - Stack Overflow

programmeradmin1浏览0评论

I tried many different codes, But all of them only returned local IP address of the user. (e.g. 192.168.1.2).

How may I obtain user's public IPv4 address using WebRTC? (e.g. 104.200.21.83)

I know it's possible because a website could show my leaked public IPv4 address even when I used VPN.

I tried many different codes, But all of them only returned local IP address of the user. (e.g. 192.168.1.2).

How may I obtain user's public IPv4 address using WebRTC? (e.g. 104.200.21.83)

I know it's possible because a website could show my leaked public IPv4 address even when I used VPN.

Share Improve this question edited Mar 15, 2018 at 21:07 Deve10per asked Mar 15, 2018 at 20:59 Deve10perDeve10per 331 silver badge5 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

Here's a popular proof-of-concept:

https://github./diafygi/webrtc-ips

For me, it was only sending back my private IP. It appears you can get around this by changing the server IP:

https://github./diafygi/webrtc-ips/issues/33

The site you linked to uses the server address stun:stun.l.google.:19302, which returned my public address as expected.

Here a small Powershell sample that gives you want you want:

# get public IP via WebRTC-Protocol in Chrome-browser (even if VPN has another IP)
# [email protected]

$tmpFile = New-TemporaryFile
Start-Process -FilePath 'C:\Program Files\Google\Chrome\Application\chrome.exe' "--no-first-run --headless --disable-gpu --dump-dom https://www.expressvpn./webrtc-leak-test" -RedirectStandardOutput $tmpFile -wait
$result = Get-Content $tmpFile
Remove-Item $tmpFile -Force -ea 0
$ip = [regex]::Match($result, '(?ms)(?<=<th class="ip">).*?(?=</th>)').value

cls
write-host "Your public IP as reported by WebRTC: $ip" -f y

Of course it would be way smarter to execute Chrome in the background and run only the required Java-function as mentioned above. But I was not able to get that solved.

Don't get me wrong but the client (where the browser is running) might not know his public IP. I would somehow host a small php on a server in the internet which prints the $_SERVER['REMOTE_ADDR'], call it from JS, gather the address back into a JS var...sounds dirty!

Edit: WRONG ANSWER, got the asking user wrong, somehow.

发布评论

评论列表(0)

  1. 暂无评论