mIRC Home    About    Download    Register    News    Help

Print Thread
#100473 12/10/04 09:09 PM
Joined: Jan 2003
Posts: 13
B
bleah Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Jan 2003
Posts: 13
I already have this easy script where when you whois someone, it grabs the $4 info from raw 311, checks the last token which represents the country, reads a text file and returns the country name.

I'm trying to script it so it could do the job for "unresolved" IP addresses. I have this text file with entries like that:
[10]
10.0.0.0/8=Some Country
[192]
192.168.60.0/24=Some Other Country
192.170.123.0/20=Somewhere On This Planet

The idea is to check the text file, if the returned IP is included in some range, return the result...

Looks good on paper, but the problem is, AFAIK, mIRC doesn't know how to handle those classless IP ranges.
I know I could simply return a long list of /24 and compare the first 3 tokens in the IP (x.y.z.0), but the text file would get too repetitive and heavy.

I'm looking for suggestions on how I should trick this script.


Show me the steps to somewhere in the sky...
#100474 12/10/04 09:24 PM
Joined: Mar 2004
Posts: 457
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Mar 2004
Posts: 457
IP addresses can be in totally different countries with little change of the numbers themselves. You would be better off with a socket script to check the IP address. There is a script on www.mircscripts.org that does it but i can't find it.

[Edit] Made one, not perfect but it works:

Code:
alias checkIP {
  set %danthemandoo.IP $1
  if ($sock(ipcheck)) { sockclose ipcheck }
  sockopen ipcheck www.dnsstuff.com 80
}
on *:sockopen:ipcheck:{
  if (!$sockerr) { 
    sockwrite -n ipcheck GET /tools/whois.ch?ip= $+ %danthemandoo.ip HTTP/1.1
    sockwrite -n ipcheck Host: www.dnsstuff.com
    sockwrite -n ipcheck User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)
    sockwrite -n ipcheck Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1..
    sockwrite -n ipcheck Accept-Language: en-us,en;q=0.50..
    sockwrite -n ipcheck Accept-Encoding: gzip, deflate,compress;q=0.9..
    sockwrite -n ipcheck Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66
    sockwrite -n ipcheck Keep-Alive: 300
    sockwrite -n ipcheck Connection: keep-alive
    sockwrite -n ipcheck Referer: http://www.dnsstuff.com
    sockwrite -n ipcheck $crlf
  }
  else { echo -a It Broke... } 
}
on *:sockread:ipcheck:{
  var %b
  sockread %b
  if (Country:* iswm %b) { 
    echo -a %danthemandoo.ip = $gettok(%b,2,58)
    sockclose ipcheck
  }
}


Usage is /checkip <ip>

Last edited by Danthemandoo; 12/10/04 09:54 PM.

Link Copied to Clipboard