All pastes #744938 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-10-21 22:17 UTC
rendered paste body
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-
  }
  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 {
    /msg %channel Info Invalid ip, host or nickname.
  }
  .disable #DNS
  halt
}
#DNS end

on *:sockopen:whois: {
  if ($sockerr) { 
    /msg %channel 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 
    }
    if (% $+ * !iswm %data) { 
      /msg %channel %data 
    }
  }
}
on $*:text:/^[!@.`](trace|whois)/Si:#: {
  /whoisip $2-
}


alias -l c1 return $+($chr(3),%color1,$1-)
alias -l c2 return $+($chr(3),%color2,$1-)
ON *:DNS:{
  if ($dns(0) == 0) {
    /msg %channel $c1(Unable To Resolve) $iif($iaddress,$iaddress,$dns(0).addr)
  }
  else {
    var %numhosts $dns(0), %host = 0
    var %hosts
    while (%host < %numhosts) {
      inc %host 1
      set %hosts %hosts $iif($dns(1) == $dns(1).ip,$dns(%host).addr,$dns(%host).ip) $+ $chr(44)
    }
    /msg %channel $dns(1) 
    /msg %channel $left(%hosts,$calc($len(%hosts)-1)) 
  }
  halt
}
on $*:text:/^[~.@!`](dns|DNS)/Si:#: {
    /set %channel $chan
    /dns $2-
}  




on *:sockopen:getip:{
  if ($sockerr) { echo -s Could not get your external IP address. }
  else {
    sockwrite -n $sockname GET / HTTP/1.1
    sockwrite -n $sockname Host: www.whatsmyipaddress.com
    sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8)
    sockwrite -n $sockname
  }
}
on *:sockread:getip: {
  if ($sockerr) { echo -s Could not get your external IP address. }
  else {
    var %r
    sockread -f %r
    if ($regex($sockname,%r,/<title>Your IP (.+)</title>/gi)) {
      set %getip.do $iif($regml(getip,2),$v1,$iif($host,$host,$me)) $gettok($regml(getip,1),3,32)
      var %x = $gettok($regml(getip,1),3,32)
      /msg %channel External IP updated: $iif($host,%x /  $v1,%x)
      scon -a getip.do
      sockclose $sockname
    }
  }
}
alias -l nohtml {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x)
  return $remove(%x,&nbsp;,$chr(9))
}
alias getip.do { .localinfo %getip.do }
on $*:text:/^[~.@!`](external|local)/Si:#: { sockopen getip www.whatsmyipaddress.com 80 } 
raw 001:*: .signal -n connect
on *:SIGNAL:connect: getip