Pages

Sunday, August 28, 2011

port check.tcl


##############
## COMMANDS ##
##########################################################
## DCC ## !port <host/ip> <port> (Can be changed) ##
######### Checks weather or not the specified port is ##
######### open on the specified host or ip. ##
######### --------------------------------------------- ##
######### .chanset <channel> +port ##
######### Enables on-join port checking for a channel. ##
##########################################################
## PUB ## !port <host/ip> <port> (Can be changed) ##
######### Checks weather or not the specified port is ##
######### open on the specified host or ip. ##
##########################################################

##########################################################
## Just load the script, set the variables, and rehash. ##
##########################################################

########################################################
# Set flag required for checking the status of a port. #
########################################################

set port_setting(flag) "-|-"

###############################################################
# Set the pub command for checking the status of a port here. #
###############################################################

set port_setting(cmd_pub) ".port"

###############################################################
# Set the dcc command for checking the status of a port here. #
###############################################################

set port_setting(cmd_dcc) "port"

####################################
# Show all data from a connection? #
####################################

set port_setting(read) 1

########################################################################
# Enable on-join scanning? (If you don't wish to enable it, ignore any #
# further settings) Scanning for a channel is enabled via .chanset     #
# <channel> +port.       #
########################################################################

set port_setting(onjoin) 0

#########################################################################
# Set the open ports to scan for when a user joins a monitored channel. #
#########################################################################

set port_setting(ports) "1080 21 23"

#####################################################################
# Set the flag that makes a user exempt from on-join scanning here. #
#####################################################################

set port_setting(exemptflag) "+E"

####################################################################
# Place a server ban when on a user that joins a monitored channel #
# if a banned port is found?   #
####################################################################

set port_setting(autoban_svr) 0

################################################################
# Place a ban on the bot's banlist when on a user that joins a #
# monitored channel if a banned port is found?       #
################################################################

set port_setting(autoban_list) 0

########################
# Make the ban global? #
########################

set port_setting(global) 0

################################################################
# Set the time to ban users for here. Set to 0 for a perm ban. #
################################################################

set port_setting(bantime) 5

############################################################
# Send an op notice when a banned port is found on a user? #
############################################################

set port_setting(onotice) 1

###################################
# Enable use of bold in DCC chat? #
###################################

set port_setting(bold) 1

#############################################
# Prefix "port:" in DCC chat messages? #
#############################################

set port_setting(port:) 1

####################
# Code begins here #
####################

if {![string match 1.6.* $version]} {
putlog "\002port:\002 \002CRITICAL ERROR\002 port.tcl requires eggdrop 1.6.x to run."
die "\002port:\002 \002CRITICAL ERROR\002 port.tcl requires eggdrop 1.6.x to run."
}
bind pub $port_setting(flag) $port_setting(cmd_pub) port_scan_pub
bind dcc $port_setting(flag) $port_setting(cmd_dcc) port_scan_dcc
bind join - * port_onjoin_scan
setudef flag port

proc port_dopre {} {
global port_setting
if {!$port_setting(port:)} {
return ""
} elseif {!$port_setting(bold)} {
return "port: "
} else {
return "\002port:\002 "
}
}
proc port_onjoin_scan {nick uhost hand chan} {
global port_setting port_chans
if {($port_setting(onjoin)) && ($port_setting(ports) != "") && (![matchattr $hand $port_setting(exemptflag)])} {
foreach i [channel info $chan] {
if {([string match "+port" $i]) && ([botisop $chan])} {
set host [lindex [split $uhost @] 1]
foreach p $port_setting(ports) {
if {![catch {set sock [socket -async $host $p]} error]} {
set timerid [utimer 15 [list port_timeout_join $sock]]
fileevent $sock writable [list port_connected_join $nick $chan $sock $host $p $timerid]
}
}
break
}
}
}
}
proc port_scan_pub {nick uhost hand chan text} {
global port_setting
set host [lindex $text 0]
set port [lindex $text 1]
if {$port == ""} {
putquick "NOTICE $nick :Gunakan: $port_setting(cmd_pub) <host> <port>"
} else {
if {[catch {set sock [socket -async $host $port]} error]} {
putquick "PRIVMSG $chan :4« 14koneksi ke $host \($port\) 14tidak bisa bos 4»"
} else {
set timerid [utimer 15 [list port_timeout_pub $chan $sock $host $port]]
fileevent $sock writable [list port_connected_pub $chan $sock $host $port $timerid]
}
}
}
proc port_scan_dcc {hand idx text} {
global port_setting
set host [lindex $text 0]
set port [lindex $text 1]
if {$port == ""} {
putdcc $idx "[port_dopre]Usage: .$port_setting(cmd_dcc) <host> <port>"
} else {
if {[catch {set sock [socket -async $host $port]} error]} {
putdcc $idx "[port_dopre]Connection to $host \($port\) was refused."
} else {
set timerid [utimer 15 [list port_timeout $idx $sock $host $port]]
fileevent $sock writable [list port_connected $idx $sock $host $port $timerid]
}
}
}
proc port_connected {idx sock host port timerid} {
killutimer $timerid
if {[set error [fconfigure $sock -error]] != ""} {
close $sock
putdcc $idx "[port_dopre]Connection to $host \($port\) failed. \([string totitle $error]\)"
} else {
fileevent $sock writable {}
fileevent $sock readable [list port_read $idx $sock $host $port]
putdcc $idx "[port_dopre]Connection to $host \($port\) accepted."
}
}
proc port_timeout {idx sock host port} {
close $sock
putdcc $idx "[port_dopre]Connection to $host \($port\) timed out."
}
proc port_read {idx sock host port} {
global port_setting
if {$port_setting(read)} {
if {[gets $sock read] == -1} {
putdcc $idx "[port_dopre]EOF On Connection To $host \($port\). Socket Closed."
close $sock
} else {
putdcc $idx "[port_dopre]$host \($port\) > $read"
}
} else {
close $sock
}
}
proc port_connected_pub {chan sock host port timerid} {
killutimer $timerid
if {[set error [fconfigure $sock -error]] != ""} {
close $sock
putquick "PRIVMSG $chan :4« 14koneksi ke $host \($port\) tidak bisa bos \([string totitle $error]\) 4»"
} else {
fileevent $sock writable {}
fileevent $sock readable [list port_read_pub $chan $sock $host $port]
putquick "PRIVMSG $chan :03« 14koneksi ke $host \($port\) manstrabs bos 03»"
}
}
proc port_timeout_pub {chan sock host port} {
close $sock
putquick "PRIVMSG $chan :05«14 koneksi ke $host \($port\) sekarang timed out bos 5»"
}
proc port_connected_join {nick chan sock host port timerid} {
global port_setting botnick
killutimer $timerid
if {[set error [fconfigure $sock -error]] != ""} {
close $sock
} else {
fileevent $sock writable {}
fileevent $sock readable [list port_read_join $sock]
if {$port_setting(onotice)} {
foreach i [chanlist $chan] {
if {([isop $i $chan]) && ($i != $botnick)} {
putserv "NOTICE $i :Port $port was found open on $nick's host. \($host\)"
}
}
}
if {$port_setting(autoban_svr)} {
putserv "MODE $chan +b *!*@$host"
putserv "KICK $chan $nick :One of the ports open on your host is banned."
timer $port_setting(bantime) [list port_unsvrban $chan $host]
} elseif {$port_setting(autoban_list)} {
if {$port_setting(global)} {
newban *!*@$host port "One of the ports open on your machine is banned." $port_setting(bantime)
} else {
newchanban $chan *!*@$host port "One of the ports open on your machine is banned." $port_setting(bantime)
}
}
}
}
proc port_timeout_join {sock} {
close $sock
}
proc port_read_join {sock} {
close $sock
}
proc port_read_pub {sock} {
global port_setting
if {!$port_setting(read)} {
close $sock
} elseif {[gets $sock read] == -1} {
putquick "PRIVMSG $chan :12«09 koneksi ke EOF On Connection To $host \($port\). socket sudah ditutup bos 12»"
close $sock
}
}
proc port_unsvrban {chan host} {
putserv "MODE $chan -b *!*@$host"
}
putlog "\002port:\002 port.tcl Version 2.0 by g0eZ egGo Loaded.."

No comments:

Post a Comment