0
votes

I know it sound crazy but I need it.

I found code that gets the public IP address:

<script type="application/javascript">
    function getip(json){
      alert(json.ip); // alerts the ip address
    } </script>

<script type="application/javascript" src="http://jsonip.appspot.com/?callback=getip"></script>

But that code can't help me here. I do even know if this is possible. But I am looking for the 192.168.42.123 address. How can I found this IP from javascript ?

$ ifconfig

usb0 Link encap:Ethernet HWaddr 6b:fe:56:15:6b:33
inet addr:192.168.42.123 Bcast:192.168.42.255 Mask:255.255.255.0 inet6 addr: fe80::68fe:96ff:fe15:6b49/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1802 errors:0 dropped:0 overruns:0 frame:0 TX packets:2041 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1513563 (1.5 MB) TX bytes:318292 (318.2 KB)

1
I doubt that possible, JS doesn't have access to the hardware / file system. Would be a wee-bit of a security issuetymeJV
Your WAN address is possible, see this question.Jokester
this used to work: var ip=java.net.InetAddress.getLocalHost(); ip.getHostAddress(); still might on a custom setup with old firefox, if IP is make or break... you can probably sniff an img file from the router config from 192.168.0.1 or 192.168.1.1, that's a fun little timing/error attack that's easy to launch from js, but won't get you the full IP...dandavis

1 Answers

0
votes

You can't. Whenever he's running your script, the user is on the public network (Internet), and therefore the IP address you'll get through javascript will always be the public one. But you may be taking the problem from the wrong side and doesn't actually need this IP address... there's nothing in it that a remote user could use...