mIRC Home    About    Download    Register    News    Help

Print Thread
#117560 17/04/05 12:07 AM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
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 ?


IceCapped
#117561 17/04/05 12:20 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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?

#117562 17/04/05 12:32 AM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
: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...


IceCapped
#117563 17/04/05 12:33 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
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.
}


New username: hixxy
#117564 17/04/05 12:35 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.


Gone.
#117565 17/04/05 12:39 AM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
ehm... any help on my 2nd question ?

btw.. i suck at sockets so... i am noob to that :tongue:

Last edited by raZOR; 17/04/05 12:40 AM.

IceCapped
#117566 17/04/05 12:45 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
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
}


New username: hixxy
#117567 17/04/05 12:49 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.


Gone.
#117568 17/04/05 02:23 AM
Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
Also things like $longip(255.255) would get through, add a $numtok check and it could be perfect

#117569 17/04/05 02:32 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
$longip(0350.12.55.88) also returns a longip, where it shouldn't.

I'm afraid $longip just isn't going to cut it.


Gone.
#117570 17/04/05 02:43 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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

Last edited by DaveC; 17/04/05 02:45 AM.
#117571 17/04/05 02:47 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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.

#117572 17/04/05 02:48 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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


Gone.

Link Copied to Clipboard