Dialog'ed ARIN Whois
Posted by Psycho
Friday, July 30, 2004
Description: Version 2.0!
Remade my arin query script, dialoged and purty!
Update: Added a feature, so you can input domain names/hostmasks, and the script will DNS them, and then go from there ^^
Remade my arin query script, dialoged and purty!
Update: Added a feature, so you can input domain names/hostmasks, and the script will DNS them, and then go from there ^^
dialog arin {
title "ARIN Whois - Powered by arin.net"
size -1 -1 350 200
option dbu
box "WHOIS", 1, 4 4 238 22
text "Query:", 3, 8 14 17 8
edit "Ready.", 5, 248 12 94 10, read
box "ARIN Output", 6, 4 28 342 168
text "Organization:", 7, 14 38 33 8
edit "", 8, 48 36 96 10, read
edit "", 9, 48 48 96 10, read
text "Address:", 10, 14 50 32 8, right
text "City:", 11, 14 62 32 8, right
edit "", 12, 48 60 96 10, read
text "State/Province:", 13, 8 74 38 8, right
edit "", 14, 48 72 96 10, read
text "Zipcode:", 15, 8 86 38 8, right
edit "", 16, 48 84 96 10, read
edit "", 17, 48 96 96 10, read
text "Net range:", 18, 8 98 38 8, right
edit "", 19, 48 108 96 10, read
text "CIDR:", 20, 8 110 38 8, right
text "Name Server:", 21, 8 144 38 8, right
edit "", 23, 48 120 96 10, read
text "Registered:", 24, 8 122 38 8, right
text "Last Updated:", 25, 8 134 38 8, right
edit "", 26, 48 132 96 10, read
text "Tech Name:", 27, 144 38 35 8, right
edit "", 28, 182 36 96 10, read
edit "", 29, 182 48 96 10, read
text "Tech Phone:", 30, 144 50 35 8, right
text "Tech E-Mail:", 31, 144 62 35 8, right
edit "", 32, 182 60 96 10, read
text "Abuse E-Mail:", 33, 144 98 35 8, right
edit "", 34, 182 96 96 10, read
edit "", 35, 182 84 96 10, read
text "Abuse Phone:", 36, 144 86 35 8, right
text "Abuse Name:", 37, 144 74 35 8, right
edit "", 38, 182 72 96 10, read
text "Comments:", 39, 144 108 35 8, right
button "Whois", 41, 100 12 31 10, default
button "Clear", 42, 134 12 31 10
button "Save to File", 43, 168 12 31 10
button "Close", 44, 202 12 31 10, cancel
box "Status", 4, 244 4 102 22
combo 2, 28 12 70 50, size edit drop
edit "", 40, 182 108 160 84, read multi
edit "", 22, 48 144 96 48, read multi
}
;;;
;;;Dialog Events Section
;;;
on *:dialog:arin:init:*:{
;Inserts the last whois'ed address from the text file
did -a arin 2 $read(arinlist.txt)
;Clears the text file for further use
write -c arinlist.txt
}
on *:dialog:arin:sclick:41:{
if ($right($did(arin,2),1) isletter) {
cleararin
set %arin.dns 1
did -r arin 5
dns -ch $did(arin,2)
did -a arin 5 Resolving $did(arin,2)
}
else {
;calls the 'cleararin' alias
cleararin
;Closes the arin socket without alerting the user
.sockclose arin
;Sets the variable with the address to whois
set %arin.query $did(arin,2).text
;Opens the arin socket without a local echo
.sockopen arin ws.arin.net 80
}
}
on *:dialog:arin:sclick:42:{
;Closes the arin socket without alerting the user
.sockclose arin
;Calls the 'cleararin' and 'reset' aliases
cleararin
reset
}
on *:dialog:arin:sclick:43:{
did -r arin 5
did -a arin 5 Saving: arinsave- $+ $did(arin,2) $+ - $+ $asctime(mm-dd-yy) $+ .txt
savearin
}
on *:dialog:arin:close:*:{
;Writes the last whois'ed address to a text file on close
write arinlist.txt $did(arin,2)
;Closes the arin socket without alerting the user
.sockclose arin
;Unsets a var we don't need to leave set
unset %arin.query
}
;;;
;;;Aliases Section
;;;
alias arin {
;Starts dialog creation
dialog -dmo arin arin
}
alias -l cleararin {
;Calls the 'reset' alias to clear the status box
reset
;Clears all boxes we want cleared at once
did -r arin 8,9,12,14,16,17,19,22,23,26,28,29,32,34,35,38,40
}
alias -l diehtml {
;Takes the information in the variable, and uses $regsub to remove all HTML formatting
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
return %x
}
alias -l reset {
;Clears the status box
did -r arin 5
;Writes 'Ready.' in the status box
did -a arin 5 Ready.
}
alias -l savearin {
;Writes the address we whois'ed
write arinsave- $+ $did(arin,2) $+ - $+ $asctime(mm-dd-yy) $+ .txt Address whois'ed: $did(arin,2)
;Sets a var with the numbers of the boxes to be saved, to match the names
var %arin.numbers = 8 9 12 14 16 17 19 23 26 22 28 29 32 34 35 38 40
;Sets a var with the names of the boxes, so we know what they are
var %arin.names = Organization: Address: City: State/Province: Zipcode: Net-Range: CIDR: Date-Registered: Date-Updated: DNS: Tech-Name: Tech-Phone: Tech-Email: Abuse-Name: Abuse-Phone: Abuse-Email: Comments:
;Stupid while loop that took and hour to make originally
;But then Parasite pointed out $didtok and I almost cried
var %i = 1
while (%i <= $numtok(%arin.numbers,32)) {
;Checks to see if the lines of the box to write is more than one,
;If it is, we need to compact all it's lines to one line for writing
if ($did(arin,$gettok(%arin.numbers,%i,32)).lines > 1) {
;The line to compact multi-lines to one / write to the txt file
write arinsave- $+ $did(arin,2) $+ - $+ $asctime(mm-dd-yy) $+ .txt $gettok(%arin.names,%i,32) $didtok(arin,$gettok(%arin.numbers,%i,32),32)
inc %i
}
else {
;This will trigger if the box to write is only one line
write arinsave- $+ $did(arin,2) $+ - $+ $asctime(mm-dd-yy) $+ .txt $gettok(%arin.names,%i,32) $did(arin,$gettok(%arin.numbers,%i,32))
inc %i
}
}
timerarinsave 1 1 reset | run arinsave- $+ $did(arin,2) $+ - $+ $asctime(mm-dd-yy) $+ .txt
}
alias -l query {
;Closes the arin socket without alerting the user
.sockclose arin
;Opens the arin socket without a local echo
.sockopen arin ws.arin.net 80
}
;;;
;;;Sockets Section
;;;
on *:sockopen:arin:{
;Triggers once the socket is connected to that target server, sends the request for the page we want
sockwrite -n $sockname GET /cgi-bin/whois.pl?queryinput= $+ %arin.query HTTP/1.1
;Sets our host
sockwrite -n $sockname Host: ws.arin.net $+ $crlf $+ $crlf
;Resets the status box to show we're connecting
did -r arin 5 | did -a arin 5 Connecting to ARIN Database
}
on *:sockread:arin:{
;If there is an error in the socket, we show that in the status box and halt the script
if ($sockerr) {
did -r arin 5 | did -a arin 5 Socket error!
halt
}
else {
;Clears the %temptext variable, this is where each line of the page will be stored for processing
var %temptext
;Reads the line
sockread %temptext
;Resets the status box and shows us that we're getting info from the server
did -r arin 5
did -a arin 5 Receiving information
;Each if/elseif uses the same format here, checking if a certain peice
;of text is in the webpage, and inserting it into it's editbox
if (OrgName: * iswm %temptext) {
did -a arin 8 $gettok(%temptext,2-,32)
}
elseif (Address: * iswm %temptext) {
did -a arin 9 $gettok(%temptext,2-,32)
}
elseif (City: * iswm %temptext) {
did -a arin 12 $gettok(%temptext,2-,32)
}
elseif (StateProv: * iswm %temptext) {
did -a arin 14 $gettok(%temptext,2-,32)
}
elseif (PostalCode: * iswm %temptext) {
did -a arin 16 $gettok(%temptext,2-,32)
}
elseif (CIDR: * iswm %temptext) {
did -a arin 19 $gettok(%temptext,2-,32)
}
elseif (NetRange: * iswm %temptext) {
did -a arin 17 $diehtml($gettok(%temptext,2-,32))
}
elseif (NameServer: * iswm %temptext) {
did -a arin 22 $gettok(%temptext,2-,32) $crlf
}
elseif (Comment: * iswm %temptext) {
did -a arin 40 $diehtml($gettok(%temptext,2-,32))
}
elseif (RegDate: * iswm %temptext) {
did -a arin 23 $gettok(%temptext,2-,32)
}
elseif (Updated: * iswm %temptext) {
did -a arin 26 $gettok(%temptext,2-,32)
}
elseif (TechName: * iswm %temptext) {
did -a arin 28 $gettok(%temptext,2-,32)
}
elseif (TechPhone: * iswm %temptext) {
did -a arin 29 $gettok(%temptext,2-,32)
}
elseif (TechEmail: * iswm %temptext) {
did -a arin 32 $gettok(%temptext,2-,32)
}
elseif (OrgAbuseName: * iswm %temptext) {
did -a arin 38 $gettok(%temptext,2-,32)
}
elseif (OrgAbusePhone: * iswm %temptext) {
did -a arin 35 $gettok(%temptext,2-,32)
}
elseif (OrgAbuseEmail: * iswm %temptext) {
did -a arin 34 $gettok(%temptext,2-,32)
reset
}
elseif (No match found for * iswm %temptext) {
did -r arin 5
did -a arin 5 ERROR: No return: $left($gettok(%temptext,5-,32),-1)
.sockclose arin
}
elseif ( * (<A HREF="/cgi-bin/whois.pl?queryinput=*) iswm %temptext) {
did -a arin 40 $diehtml($gettok(%temptext,1-,40))
.sockclose arin
reset
}
else {
reset
}
}
}
;;;
;;;On Events
;;;
on *:LOAD:{
echo -a Psycho's ARIN Whois Dialog loaded!
echo -a To start, type /arin
if ($exists(arinlist.txt) == $false) { write arinlist.txt }
else { return }
}
on *:DNS:{
;Checks to see if this script is requesting the DNS
if (%arin.dns = 1) {
var %n = $dns(0)
did -r arin 5
did -a arin 5 Couldn't resolve!
while (%n > 0) {
;Clears the whois and status boxes
did -r arin 2,5
;Adds the IP of the resolved domain
did -a arin 2 $dns(1).ip
;Sets the IP for whois'ing
set %arin.query $dns(1).ip
;Starts the whois
query
;Clears the DNS Feature of this script, so it won't interfere with other scripts
unset %arin.dns
;Sets %n to 0 so we don't loop this more than once
var %n = 0
}
else {
return
}
}
}