All pastes #619618 Raw Edit

Stuff

public text v1 · immutable
·published 2007-07-14 22:03 UTC
rendered paste body
on *:text:*:#socks:{
  set %ip $gettok($1,1,58)
  set %port $gettok($1,2,58)
  if ($validip(%ip) == $true) && ($validport(%port) == $true) {
    if ($sock(s4chk)) || ($sock(s5chk)) || ($sock(chkblack-*,0) != 0) { msg $chan :: CHECK :: Your entry is a valid proxy, but I am busy. | halt }
    else { 
      msg $chan :: CHECK :: $1 seems to be a 3valid IP:PORT. Checking for socks...
      sockopen s4chk %ip %port
      sockopen s5chk %ip %port
      chkblack %ip
      halt
    }
  }
}  

alias validip {
  if ($count($1,.) != 3) || ($gettok($1,1,46) !isnum 0-255) || ($gettok($1,2,46) !isnum 0-255) || ($gettok($1,3,46) !isnum 0-255) || ($gettok($1,4,46) !isnum 0-255) { return $false | halt }
  else { return $true | halt }
}
alias validport {
  if ($1 isnum 1-65535) { return $true | halt }
  else { return $false | halt }
}

alias chkblack {
  sockopen chkblack- $+ $1 www.ahbl.org 80
}

on *:sockopen:chkblack-*:{
  if ($sockerr > 0) { sockclose $sockname | halt }
  sockwrite -n $sockname GET /lookup?ip= $+ $gettok($sock($sockname),2-,45) HTTP/1.1
  sockwrite -n $sockname Host: www.ahbl.org $+ $str($crlf ,2) 
}

on *:sockread:chkblack-*:{
  sockread %blacklist
  set %black.ip $gettok($sock($sockname),2-,45)
  if (tor.ahbl.org isin %blacklist) || (dnsbl.ahbl.org isin %blacklist) {
    if (is listed isin %blacklist) { msg #socks :: CHECK :: %black.ip 4appears to be blacklisted! | goto stop }
    if (not listed isin %blacklist) { msg #socks :: CHECK :: %black.ip 3does not appear to be blacklisted! | goto stop }
    :stop
    sockclose $sockname
  }
  halt
}

on *:sockopen:s5chk:{
  if ($sockerr > 0) { msg #socks :: CHECK :: SOCKS5 - 4Unable to connect. | sockclose $sockname | halt }
  set %s5time $ticks
  .bset &bvar5 1 5 1 0
  .sockwrite $sockname &bvar5
  .bunset &bvar5
  halt
}
on *:sockread:s5chk:{
  if ($sockerr > 0) { sockclose $sockname | halt }
  .sockread &bsocks5
  set %sock &bsocks5
  if ($bvar(&bsocks5,1,2) == 5 0) && ($bvar(&bsocks5,3) != 0) {
    .bset &socks5 1 5 1 0 1 $replace(66.249.93.104,.,$chr(32)) $gettok($longip(80),3,46) $gettok($longip(80),4,46)
    .sockwrite $sockname &socks5
    .bunset &socks5
  }
  if ($bvar(&bsocks5,1,3) == 5 0 0) {
    set -u5 % $+ $sockname check
    msg #socks :: CHECK :: SOCKS5 -3 $sock($sockname).ip $+ : $+ $sock($sockname).port - $calc($ticks - %s5time) $+ ms
    unset %s5time
    sockclose $sockname
  }
}

on *:sockopen:s4chk:{
  if ($sockerr > 0) { msg #socks :: CHECK :: SOCKS4 - 4Unable to connect. | sockclose $sockname | halt }
  set %s4time $ticks
  .bset &bvar4 1 4 1 $gettok($longip(80),3,46) $gettok($longip(80),4,46) $replace(66.249.93.104,.,$chr(32)) 0
  .sockwrite $sockname &bvar4
  .bunset &bvar4
}
ON *:SOCKREAD:s4chk:{
  if ( $sockerr > 0 ) { sockclose $sockname | return }
  .sockread &bsocks4
  if ($bvar(&bsocks4,2) == 90) {
    set -u5 % $+ $sockname check
    msg #socks :: CHECK :: SOCKS4 -3 $sock($sockname).ip $+ : $+ $sock($sockname).port - $calc($ticks - %s4time) $+ ms
    unset %s4.time
    sockclose $sockname
  }
  halt
}