mIRC Homepage
Posted By: raZOR help pls - 17/04/05 12:07 AM
i need a lil help in this script:
*************************************


; IP WHOIS INFORMATION v0.2 by magic <magic@mirc.net>
; ---------------------------------------------------
; To use the addon load it in your copy of mirc: /load -rs whoisip.mrc
; and to use the addon type /whoisip IP/HOST/NICKNAME in any window and
; the result should echo into yoru active window.
; You are free to use this code any way you want aslong you give me credit for it.
; A special thanks to tidy_trax for his recomendations and $regex help.

alias whoisip {
sockclose whois
if ($regex($1,/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/)) {
sockopen whois whois.cyberabuse.org 43
set %whois.ip $1-
}


why does this calls WHOIS toward cyberabuse
if it didnt resolved any ip or host... ???


******************************************************
if (!$regex($1,/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/)) {
.enable #DNS
.dns $1-
}
}

#DNS off
on *:DNS:{
if ($dns(0).ip) {
set %whois.ip $dns(0).ip
sockopen whois whois.cyberabuse.org 43
}
else {
echo -ac Info Invalid ip, host or nickname.
}
.disable #DNS
halt
}
#DNS end

on *:sockopen:whois: {
if ($sockerr) {
echo -a Unable to connect to whois server.
sockclose whois
}
else {
sockwrite -nt whois %whois.ip
}
}

on *:sockread:whois: {
sockread %data
if %data {
if (%data == % http://www.cyberabuse.org/whois/) {
sockclose $sockname
echo -a 
echo -a Data from the CyberAbuse Whois Server
echo -a Copyright 2003-2004, Philippe Bourcier
echo -a http://www.cyberabuse.org/whois/
}
if (% $+ * !iswm %data) {
echo -a %data
}
}
}



********************
and if i replace all links to ripe.net exept 1st one (that stays cyberabuse) why do i again get result only from cyberabuse ?
Posted By: DaveC Re: help pls - 17/04/05 12:20 AM
Quote:
why does this calls WHOIS toward cyberabuse
if it didnt resolved any ip or host... ???


becuase if $1 wasnt an IP (not that they used the best method to see if it was) then if it wasnt they call whois, reason I dont know, maybe to see what the address becomes?

Quote:
and if i replace all links to ripe.net exept 1st one (that stays cyberabuse) why do i again get result only from cyberabuse ?


Well duh, If i call pizzahut, and ask for a bigmac and fries do you think I well get a bigmac and fries?
Posted By: raZOR Re: help pls - 17/04/05 12:32 AM
:tongue:

ok nvm then, try help me in this...

LAST script section

on *:sockread:whois: {
sockread %data
if %data {
if (%data == % http://www.cyberabuse.org/whois/) {
sockclose $sockname
}
if (Source $+ * iswm %data) {
.echo -a %data
}
elseif (Error $+ * iswm %data) {
.echo -a %data
}
}
}

i remaded it in this coz when it calls IP info there is always 1 line that says:

Source: (info here like RIPE, ARIN, APNIC...)
or Error: (messeage here)

what should i do so i get only that lines in %data
coz this mine re-make doesnt work at all...
Posted By: tidy_trax Re: help pls - 17/04/05 12:33 AM
At the time I wasn't aware of a better method.
You could just use $longip instead of a regex:

Code:
if ($longip(&lt;ip&gt;)) { 
  ; &lt;ip&gt; is valid.
}
else {
  ; &lt;ip&gt; is invalid.
}
Posted By: FiberOPtics Re: help pls - 17/04/05 12:35 AM
Not really,

$longip(4) returns 0.0.0.4,
$longip(555) returns 0.0.2.43

What I mean it isn't fullproof at all to use $longip to check if an input has the syntax of an ip.
Posted By: raZOR Re: help pls - 17/04/05 12:39 AM
ehm... any help on my 2nd question ?

btw.. i suck at sockets so... i am noob to that :tongue:
Posted By: tidy_trax Re: help pls - 17/04/05 12:45 AM
I forgot $longip also turns a longip into a shortip.
Something like this should work:

Code:
if (. !isin $$longip(&lt;ip&gt;)) {
  ; &lt;ip&gt; is valid
}
Posted By: FiberOPtics Re: help pls - 17/04/05 12:49 AM
That's better smile

Wait it isn't, $longip is bugged, I'll post a bug report in half an hour and then reference it.
Posted By: Sigh Re: help pls - 17/04/05 02:23 AM
Also things like $longip(255.255) would get through, add a $numtok check and it could be perfect
Posted By: FiberOPtics Re: help pls - 17/04/05 02:32 AM
$longip(0350.12.55.88) also returns a longip, where it shouldn't.

I'm afraid $longip just isn't going to cut it.
Posted By: DaveC Re: help pls - 17/04/05 02:43 AM
if ($1 == $longip($longip($1))) { ... }

Thats what i use, never encountered the $longip problem before but did see what it was, not how to fix it frown lol

[edit]
now i look at it i dont know why i just didnt use IF ($longip) { ... }, just lucky i guess
Posted By: DaveC Re: help pls - 17/04/05 02:47 AM
sorry didnt mean to be jibbing your code, i didnt even notice it was credited to you at the time. And as it appears $longip has odd behavours anyway, so i wasnt so "right" as it stands.
Posted By: FiberOPtics Re: help pls - 17/04/05 02:48 AM
Hehe yeah.

(thanks for the reply on the bug report)

Actually, that work around is also going to fail, but not due to a bug in $longip.

$longip strips the zeropadding from the input ip, so 01.01.01.01 != $longip($longip(01.01.01.01))

But anyway, because of the bugs, it doesn't matter anymore, he'll have to use other methods (and there are multiple) to check for a valid ip.

Greets
© mIRC Discussion Forums