ARIN Whois
Posted by Psycho
Sunday, July 25, 2004
Description: Script to use arin.net to whois domains

made a crummy little snippet to query arin.net because I was bored. It's poorly coded and shoddy, but I'm also operatining on 2 days w/o sleep, so go me. BTW: ONLY INPUT IP'S, NOT HOSTMASKS


alias arin {
  .window -aez @arin
  set %arin.query $1
  set %arin.open 1
  sockopen arin ws.arin.net 80
  timerclosearin 1 3 closearin
}
on *:sockopen:arin:{
  sockwrite -n $sockname GET /cgi-bin/whois.pl?queryinput= $+ %arin.query HTTP/1.1
  sockwrite -n $sockname Host: ws.arin.net $+ $crlf $+ $crlf
}
on *:sockread:arin:{
  if ($sockerr) {
    aline @arin [^K]4Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    if (*Search results for: * iswm %temptext) {
      aline @arin -
      aline @arin $str($+ $chr(160),50) [^B] $+ $diehtml($gettok(%temptext,7,32)) $+ [^B]
    }
    elseif (OrgName: * iswm %temptext) {
      .timerarin 1 2 unset %returned
      aline @arin [^B]Organization:[^B] $str($+ $chr(45),22) $gettok(%temptext,2-,32)
    }
    elseif (Address: * iswm %temptext) {
      aline @arin [^B]Address:[^B] $str($+ $chr(45),28) $gettok(%temptext,2-,32)
    }
    elseif (City: * iswm %temptext) {
      aline @arin [^B]City:[^B] $str($+ $chr(45),34) $gettok(%temptext,2-,32)
    }
    elseif (StateProv: * iswm %temptext) {
      aline @arin [^B]State/Province:[^B] $str($+ $chr(45),19) $gettok(%temptext,2-,32)
    }
    elseif (PostalCode: * iswm %temptext) {
      aline @arin [^B]Postal Code:[^B] $str($+ $chr(45),24) $gettok(%temptext,2-,32)
    }
    elseif (CIDR: * iswm %temptext) {
      aline @arin [^B]Classless InterDomain Routing:[^B] $gettok(%temptext,2-,32)
    }
    elseif (NetType: * iswm %temptext) {
      aline @arin [^B]Net Type:[^B] $str($+ $chr(45),27) $gettok(%temptext,2-,32)
    }
    elseif (NameServer: * iswm %temptext) {
      aline @arin [^B]NameServer:[^B] $str($+ $chr(45),23) $gettok(%temptext,2-,32)
    }
    elseif (Comment: * iswm %temptext) {
      aline @arin [^B]Comment:[^B] $str($+ $chr(45),27) $gettok(%temptext,2-,32)
    }
    elseif (RegDate: * iswm %temptext) {
      aline @arin [^B]Date Registered:[^B] $str($+ $chr(45),19) $gettok(%temptext,2-,32)
    }
    elseif (Updated: * iswm %temptext) {
      aline @arin [^B]Last Updated:[^B] $str($+ $chr(45),23) $gettok(%temptext,2-,32)
    }
    elseif (TechName: * iswm %temptext) {
      aline @arin [^B]TechName:[^B] $str($+ $chr(45),26) $gettok(%temptext,2-,32)
    }
    elseif (TechPhone: * iswm %temptext) {
      aline @arin [^B]TechPhone:[^B] $str($+ $chr(45),25) $gettok(%temptext,2-,32)
    }
    elseif (TechEmail: * iswm %temptext) {
      aline @arin [^B]TechEmail:[^B] $str($+ $chr(45),26) $gettok(%temptext,2-,32)
    }
    elseif (OrgAbuseName: * iswm %temptext) {
      aline @arin [^B]Organization Abuse Name:[^B] $str($+ $chr(45),6) $gettok(%temptext,2-,32)
    }
    elseif (OrgAbusePhone: * iswm %temptext) {
      aline @arin [^B]Organization Abuse Phone:[^B] $str($+ $chr(45),5) $gettok(%temptext,2-,32)
    }
    elseif (OrgAbuseEmail: * iswm %temptext) {
      aline @arin [^B]Organization Abuse Email:[^B] $str($+ $chr(45),7) $gettok(%temptext,2-,32)
    }
    elseif (OrgTechPhone: * iswm %temptext) {
      aline @arin [^B]Organization TechPhone:[^B] $str($+ $chr(45),8) $gettok(%temptext,2-,32)
    }
    elseif (OrgTechEmail: * iswm %temptext) {
      aline @arin [^B]Organization TechEmail:[^B] $str($+ $chr(45),9) $gettok(%temptext,2-,32)
    }
    elseif (No match found for * iswm %temptext) {
      aline @arin [^B]No match found for:[^B] $str($+ $chr(45),13) $gettok(%temptext,5-,32)
      aline @arin $str($+ $chr(160),50) [^K]4[^B]Closed connection with ARIN Servers.
      sockclose arin
    }
    elseif ( * (<A HREF="/cgi-bin/whois.pl?queryinput=*) iswm %temptext) {
      aline @arin [^B]ARIN Return:[^B] $str($+ $chr(45),22) $diehtml($gettok(%temptext,1-,40))
    }
  }
}

on *:sockclose:arin:{
  aline @arin $str($+ $chr(160),50) [^K]4[^B]ARIN Servers closed connection.
  unset %arin.open
}
alias -l diehtml {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
  return %x
}
alias -l closearin {
  if (%arin.open != $null) {
    aline @arin $str($+ $chr(160),50) [^K]4[^B]Closed connection with ARIN Servers.
    sockclose arin
  }
}
menu status,query,channel,menubar {
  ARIN Query: .arin $$?="What IP Address would you like to look up?"
}
on *:INPUT:@arin:{
  if (/* iswm $1-) { return }
  else { .arin $1 }
}
on *:LOAD:{
  echo -a Loaded [^B]ARIN Query Script[^B] by Psycho
  echo -a To use, type /arin <ip address> or use the menu in the status window, Query Window, Channel Window or Menu Bar.
}

holy shit.
Posted by variant
Sunday, July 25, 2004 07:50am PDT
psycho CODED and RELEASED something.. im proud of you mister eli witt.
:o
Posted by Psycho
Sunday, July 25, 2004 02:12pm PDT
^^
Updated
Posted by Psycho
Sunday, July 25, 2004 02:18pm PDT
Yeah, I forgot to add in a fuct to see if arin didn't return a result, if you downloaded it, update it.
Update, again.
Posted by Psycho
Monday, July 26, 2004 11:38pm PDT
If you've downloaded this at all before this post, delete it all and use the new code above, I had way too many errors in it, I guess 3 days w/o sleep let me find the errors :)
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world