|
|
| Author |
Message |
m33p none

Joined: 19 Feb 2004 Posts: 1
|
Posted: Jan 26, 2005 3:53pm Post subject: Reversing a ip with mIRC script |
|
|
I want to know how I could reverse an ip like
127.0.0.1 to 1.0.0.127
or
192.168.1.12 to 12.1.168.192
any help? |
|
| Back to top |
|
 |
zeke Idler

Joined: 04 Oct 2003 Posts: 334
|
Posted: Jan 27, 2005 12:06am Post subject: |
|
|
i would imagine you would probably use tokens, (this is likely buggy)
/revip 192.168.1.65
| Code: | alias revip {
var %toks = $numtoks($1-,46)
var %toks2 = $null
while (%toks > 0) {
var %toks2 = $gettok($1-,%toks,46) $+ . $+ %toks2
dec %toks
}
return %toks2
} |
|
|
| Back to top |
|
 |
W-Unit Newbie

Joined: 29 Jul 2004 Posts: 83
|
Posted: Jan 27, 2005 8:23pm Post subject: |
|
|
Yeah, that script is buggy lol. First of all, $numtoks is not an identifier; it should be $numtok. Second, using $numtok($1-,46) will confuse the script greatly because using $1- causes it to possibly return spaces, which are not valid tokens since you have chosen character 46 (the period) as your token seperator, therefore they are treated as normal text in the tokens and the output will be messed up. It is possible to make one that does as many reversed IPs as you specify, but he didn't ask for that so I'm not going to take the extra time to code it.
| Code: | alias revip {
if ( !$1 ) {
echo $colour(info) -a * Syntax: /revip <IP Address>
halt
}
var %x = 1,%f = $gettok($1,$wildtok($1,*,0,46),46)
while ( %x < $wildtok($1,*,0,46) ) {
%f = $addtok(%f,$gettok($1,$calc($wildtok($1,*,0,46) - %x),46),46)
inc %x 1
}
echo $colour(info) -a * Reversed IP: %f
} |
Despite my playing with it, I cant get it to return repetitive numbers (/revip 127.0.0.1 will for some reason return 1.0.127) but other than that (and since real IPs other than the localhost IP never have repeated numbers) it works fine. |
|
| Back to top |
|
 |
phrozen77 Newbie

Joined: 13 Jul 2004 Posts: 98 Location: There!! A 3-headed monkey, right behind you!
|
Posted: Jan 28, 2005 5:59am Post subject: |
|
|
| Quote: | | (and since real IPs other than the localhost IP never have repeated numbers) |
how comes that my server has two same numbers in the middle of it? (like a.b.b.c) |
|
| Back to top |
|
 |
Cobi Lurker

Joined: 30 Dec 2003 Posts: 120 Location: IRC
|
Posted: Feb 08, 2005 6:42pm Post subject: |
|
|
| Code: | | alias revip { return $+($gettok($1,4,46),.,$gettok($1,3,46),.,$gettok($1,2,46),.,$gettok($1,1,46)) } |
usage:
$revip(ip.add.re.ss) |
|
| Back to top |
|
 |
EqualSlashed_Brian Lurker

Joined: 29 Aug 2004 Posts: 221 Location: IRC
|
Posted: Feb 09, 2005 4:13am Post subject: |
|
|
| You are wrong about the same numbers thing. Now is a good time to read the RFC. |
|
| Back to top |
|
 |
W-Unit Newbie

Joined: 29 Jul 2004 Posts: 83
|
Posted: Feb 14, 2005 9:13am Post subject: |
|
|
OK, I just never saw an IP with repeated digits. I assumed they didn't exist.
Anyway, here's code that will work with repeated digits as an alternative to Cobi's. It echoes it, and is not an identifier, unlike his.
| Code: | alias revip {
if ( !$1 ) {
echo $colour(info) -a * Syntax: /revip <IP Address>
halt
}
var %x = 1,%f = $gettok($1,$numtok($1,0,46),46)
while ( %x < $numtok($1,46) ) {
%f = $addtok(%f,$gettok($1,$calc($numtok($1,46) - %x),46),46)
inc %x 1
}
echo $colour(info) -a * Reversed IP: %f
} |
|
|
| Back to top |
|
 |
|
|
| |