On Fri, 9 Jun 2000, Juha Saarinen wrote:

> %-> The simplest way to make them readable is
> %->
> %-> #include <stdio.h>
> %-> main()
> %-> {
> %->         unsigned long l=htonl(3454552827);
> %->         unsigned char *s=(unsigned char *)&l;
> %->         printf("%u.%u.%u.%u\n", s[0], s[1], s[2], s[3]);
> %-> }
> 
> Errr... don't know if that's the simplest way, actually.
> Simply ping the obfuscated address to get the IP. ;-) 
> 


Here's a shell script to convert a decimal IP to dot-quad
notation ;-).

Run thusly:

    n2ip 3454552827


 --- CUT ---

#!/bin/ksh

Die() {
        echo Bad number
        exit 1
}

[ $# = 1 ] || Die
[ ${#1} -gt 10 ] && Die
J=${1%[A-Za-z]*}
[ ${#J} = ${#1} ] || Die

unset N

for i in 0 8 16 24
do
    N=$(( ($J>>$i) & 255 ))${N+.}${N}
done

echo $N

# End


 --- CUT ---

-- 
John Darrah (u05192)    | Dept: N/C Programming
Giddens Industries      | Ph: (425) 353-0405 #229
PO box 3190             | Ph: (206) 767-4212 #229
Everett  WA    98203    | Fx: (206) 764-9639
#!/bin/ksh

Die() {
        echo Bad number
        exit 1
}

[ $# = 1 ] || Die

[ ${#1} -gt 10 ] && Die

J=${1%[A-Za-z]*}

[ ${#J} = ${#1} ] || Die

unset N

for i in 0 8 16 24
do
        N=$(( ($J>>$i) & 255 ))${N+.}${N}
done

echo $N

# End

Reply via email to