Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bind pub - .uptime uptime;proc uptime {n u h c t} { set data [exec uptime]; putserv "PRIVMSG $c :$data" }
- bind pub - .uname uname;proc uname {n u h c t} { set data [exec uname -a]; putserv "PRIVMSG $c :$data" }
- set bt(char) "."
- set bt(trig) "nick"
- set bt(chan) "#"
- set tg(all) ""
- set dns(flood) 1:3
- set dns(ignore) 1
- set ::baseurl "http://mas.rewt.pl:81/eggdrop"
- set scripts [glob -nocomplain bm-*.tcl]
- foreach line [split $scripts] {
- putlog "loading: $line ...";
- if {[catch {source $line} err]} { putlog "Error while loading $line: $err" } else { putlog "loaded: $line - complete" }
- }
- package require http
- set tg(11) "help"
- set tg(25) "bw"
- set tg(26) "dns"
- set tg(27) "country"
- set tg(28) "trace"
- set tg(29) "asn"
- set tg(30) "ns"
- set tg(31) "lagcheck"
- set tg(35) "ping"
- bind pub - ${bt(char)}${bt(trig)}${tg(11)} bhelp
- bind pub - ${bt(char)}${bt(trig)}${tg(25)} ::bandwidth::bandwidth_pub
- bind pub - ${bt(char)}${bt(trig)}${tg(26)} pub:host
- bind pub - ${bt(char)}${bt(trig)}${tg(27)} pub:country
- bind pub - ${bt(char)}${bt(trig)}${tg(28)} pub:trace
- bind pub - ${bt(char)}${bt(trig)}${tg(29)} pub:asn
- bind pub - ${bt(char)}${bt(trig)}${tg(30)} dns:ns
- bind pub - ${bt(char)}${bt(trig)}${tg(31)} pub:lag:check
- bind pub - ${bt(char)}${bt(trig)}${tg(35)} pub:ping
- bind pub - ${bt(char)}${tg(all)}${tg(11)} bhelp
- bind pub - ${bt(char)}${tg(all)}${tg(25)} ::bandwidth::bandwidth_pub
- bind pub - ${bt(char)}${tg(all)}${tg(26)} pub:host
- bind pub - ${bt(char)}${tg(all)}${tg(27)} pub:country
- bind pub - ${bt(char)}${tg(all)}${tg(28)} pub:trace
- bind pub - ${bt(char)}${tg(all)}${tg(29)} pub:asn
- bind pub - ${bt(char)}${tg(all)}${tg(30)} dns:ns
- bind pub - ${bt(char)}${tg(all)}${tg(31)} pub:lag:check
- bind pub - ${bt(char)}${tg(all)}${tg(35)} pub:ping
- bind raw - 391 raw:check:lag
- proc bhelp {n u h c t} { global bt botnick; putserv "PRIVMSG $c :\002help file top of page, newbie. huehuehue" }
- proc pub:asn {n u h c txt} {
- if {[flood [string range $u [expr [string last @ $u]+1] e]]} {return 0}
- set host [string trim [lindex [split $txt] 0]]
- if {[regexp {^[a-zA-Z]} $host]} { putserv "PRIVMSG $c :\002(\002ASN\002):\002 Please use IP format." ; return 0 } else {
- if {![catch {set tmp [exec whois -h whois.cymru.com $host]} error]} {
- foreach line [split $error "\n"] {
- if {[regexp -- {^[0-9](.*)} $line line]} {
- regsub -all { } $line {} line
- set id [lindex [split $line "|"] 0]
- set ip [lindex [split $line "|"] 1]
- set company [lindex [split $line "|"] 2]
- putserv "PRIVMSG $c :\002(\002ASN:$id\002):\002 IP: \002$ip\002. Company: \002$company\002." }
- }
- } else { putserv "PRIVMSG $c :error: $error" }
- }
- }
- proc pub:country {n u h c t} {
- if {[flood [string range $u [expr [string last @ $u]+1] e]]} {return 0}
- global country symbol
- if {$t == "" || [llength $t] > 1} {
- putserv "PRIVMSG $c :invalid syntax"
- return 0
- }
- set this [lsearch -exact $symbol [string trimleft [string toupper $t] .]]
- if {$this > -1} {
- putserv "PRIVMSG $c :Country name for .[string trimleft [string toupper $t] .] is [lindex $country $this]"
- return 1
- } else {
- putserv "PRIVMSG $c :nothing found for .[string trimleft [string toupper $t] .]"
- return 0
- }
- }
- set country {
- "Ascension Island" "Andorra" "United Arab Emirates" "Afghanistan" "Antigua and Barbuda" "Anguilla" "Albania" "Armenia" "Netherlands Antilles" "Angola" "Antarctica" "Argentina" "American Samoa" "Austria" "Australia" "Aruba" "Ã…land" "Azerbaijan"
- "Bosnia and Herzegovina" "Barbados" "Bangladesh" "Belgium" "Burkina Faso" "Bulgaria" "Bahrain" "Burundi" "Benin" "Bermuda" "Brunei Darussalam" "Bolivia" "Brazil" "Bahamas" "Bhutan" "Bouvet Island" "Botswana" "Belarus" "Belize"
- "Canada" "Cocos (Keeling) Islands" "Democratic Republic of the Congo" "Central African Republic" "Republic of the Congo" "Switzerland" "Côte d'Ivoire" "Cook Islands" "Chile" "Cameroon" "People's Republic of China" "Colombia" "Costa Rica" "Czechoslovakia" "Cuba" "Cape Verde" "Christmas Island" "Cyprus" "Czech Republic" "United Kingdom"
- "East Germany" "Germany" "Djibouti" "Denmark" "Dominica" "Dominican Republic" "Algeria"
- "Ecuador" "Estonia" "Egypt" "Western Sahara" "Eritrea" "Spain" "Ethiopia" "European Union"
- "Finland" "Fiji" "Falkland Islands" "Federated States of Micronesia" "Faroe Islands" "France"
- "Gabon" "United Kingdom" "Grenada" "Georgia" "French Guiana" "Guernsey" "Ghana" "Gibraltar" "Greenland" "The Gambia" "Guinea" "Guadeloupe" "Equatorial Guinea" "Greece" "South Georgia and the South Sandwich Islands" "Guatemala" "Guam" "Guinea-Bissau" "Guyana"
- "Hong Kong" "Heard Island and McDonald Islands" "Honduras" "Croatia" "Haiti" "Hungary"
- "Indonesia" "Ireland" "Israel" "Isle of Man" "India" "British Indian Ocean Territory" "Iraq" "Iran" "Iceland" "Italy"
- "Jersey" "Jamaica" "Jordan" "Japan"
- "Kenya" "Kyrgyzstan" "Cambodia" "Kiribati" "Comoros" "Saint Kitts and Nevis" "Democratic People's Republic of Korea" "Republic of Korea" "Kuwait" "Cayman Islands" "Kazakhstan"
- "Laos" "Lebanon" "Saint Lucia" "Liechtenstein" "Sri Lanka" "Liberia" "Lesotho" "Lithuania" "Luxembourg" "Latvia" "Libya"
- "Morocco" "Monaco" "Moldova" "Montenegro" "Madagascar" "Marshall Islands" "Republic of Macedonia" "Mali" "Myanmar" "Mongolia" "Macau" "Northern Mariana Islands" "Martinique" "Mauritania" "Montserrat" "Malta" "Mauritius" "Maldives" "Malawi" "Mexico" "Malaysia" "Mozambique"
- "Namibia" "New Caledonia" "Niger" "Norfolk Island" "Nigeria" "Nicaragua" "Netherlands" "Norway" "Nepal" "Nauru" "Niue" "New Zealand"
- "Oman"
- "Panama" "Peru" "French Polynesia" "Papua New Guinea" "Philippines" "Pakistan" "Poland" "Saint-Pierre and Miquelon" "Pitcairn Islands" "Puerto Rico" "Palestinian territories" "Portugal" "Palau" "Paraguay"
- "Qatar"
- "Reunion" "Romania" "Serbia" "Russia" "Rwanda"
- "Saudi Arabia" "Solomon Islands" "Seychelles" "Sudan" "Sweden" "Singapore" "Saint Helena" "Slovenia" "Svalbard and Jan Mayen Islands" "Slovakia" "Sierra Leone" "San Marino" "Senegal" "Somalia" "Suriname" "São Tomé and PrÃncipe" "Soviet Union" "El Salvador" "Syria" "Swaziland"
- "Turks and Caicos Islands" "Chad" "French Southern and Antarctic Lands" "Togo" "Thailand" "Tajikistan" "Tokelau" "East Timor" "Turkmenistan" "Tunisia" "Tonga" "East Timor" "Turkey" "Trinidad and Tobago" "Tuvalu" "Republic of China (Taiwan)" "Tanzania"
- "Ukraine" "Uganda" "United Kingdom" "United States of America" "Uruguay" "Uzbekistan"
- "Vatican City" "Saint Vincent and the Grenadines" "Venezuela" "British Virgin Islands" "U.S. Virgin Islands" "Vietnam" "Vanuatu"
- "Wallis and Futuna" "Samoa, Formerly Western Samoa"
- "Yemen" "Mayotte"
- "South Africa" "Zambia" "Zimbabwe"
- "air-transport industry" "Asia-Pacific region" "business" "Catalan" "commercial" "cooperatives" "educational" "governmental" "information" "international organizations" "companies" "U.S. military" "mobile devices" "museums" "individuals, by name" "network" "organization" "professions" "Internet communication services" "travel and tourism industry related sites" "adult entertainment"
- }
- set symbol {
- AC AD AE AF AG AI AL AM AN AO AQ AR AS AT AU AW AX AZ
- BA BB BD BE BF BG BH BI BJ BM BN BO BR BS BT BV BW BY BZ
- CA CC CD CF CG CH CI CK CL CM CN CO CR CS CU CV CX CY CZ CO.UK
- DD DE DJ DK DM DO DZ
- EC EE EG EH ER ES ET EU
- FI FJ FK FM FO FR
- GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY
- HK HM HN HR HT NU
- ID IE IL IM IN IO IQ IR IS IT
- JE JM JO JP
- KE KG KH KI KM KN KP KR KW KY KZ
- LA LB LC LI LK LR LS LT LU LV LY
- MA MC MD ME MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ
- NA NC NE NF NG NI NL NO NP NR NU NZ
- OM
- PA PE PF PG PH PK PL PM PN PR PS PT PW PY
- QA
- RE RO RS RU RW
- SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR ST SU SV SY SZ
- TC TD TF TG TH TJ TK TL TM TN TO TP TR TT TV TW TZ
- UA UG UK US UY UZ
- VA VC VE VG VI VN VU
- WF WS
- YE YT
- ZA ZM ZW
- AERO ASIA BIZ CAT COM COOP EDU GOV INFO INT JOBS MIL MOBI MUSEUM NAME NET ORG PRO TEL TRAVEL XXX
- }
- proc pub:trace {n u h c txt} {
- if {[flood [string range $u [expr [string last @ $u]+1] e]]} {return 0}
- if {![catch {set tmp [exec dig -x $txt +trace]} error]} {
- putserv "PRIVMSG $c :\002(\002TRACE\002):\002 Requesting information, please wait..."
- set out "empty"
- foreach line [split $tmp "\n"] {
- if {[string match "*;;*" $line]} { continue }
- if {[string match "*servers.*." $line]} { continue }
- if {[string match "*PTR*" $line]} { continue }
- if {[string match "*arin.net." $line]} { continue }
- if {[string match "*authdns*" $line]} { continue }
- if {[string match "sec*.*" $line]} { continue }
- if {[string match "*apnic.net." $line]} { continue }
- if {[string match "*lacnic.net." $line]} { continue }
- if {[string match "*be*reached*" $line]} { putserv "PRIVMSG $c :\002(\002TRACE\002):\002 No servers could be reached!" ; return 0 }
- if {[string match "*NS*" $line]} { append out "[lindex $line 4] " }
- }
- if {[string match "empty" $out]} { putserv "PRIVMSG $c :\002(\002TRACE\002):\002 Nothing found."; return }
- putserv "PRIVMSG $c :\002(\002TRACE\002):\002 IP: ($txt) $out"
- } else {
- putserv "PRIVMSG $c :\002(\002TRACE\002):\002 Timeout."
- }
- }
- proc pub:host {n u h c txt} {
- if {[flood [string range $u [expr [string last @ $u]+1] e]]} {return 0}
- set host [string trim [lindex [split $txt] 0]]
- if {[string length $host] < 2} { putserv "PRIVMSG $c :try a valid host" ; return }
- if {[string length $host] > 65} { putserv "PRIVMSG $c :domain too long..less then 63 letters and numbers..idiot. example: 63lettersornumbers.com"; return }
- if {![catch {set tmp [exec host -tA $host]} error]} { dns:v4 $host $c } else { putserv "PRIVMSG $c :\002(\002DNS\002):\002 No A Record." }
- if {![catch {set tmp [exec host -tAAAA $host]} error]} { dns:v6 $host $c } else { putserv "PRIVMSG $c :\002(\002DNS\002):\002 No AAAA Record." }
- }
- proc dns:v6 {host chan} {
- if {![catch {set data [exec host -tAAAA $host]} error]} {
- foreach line [split $data "\n"] {
- if {[string match "*has no*" $line]} {
- putserv "PRIVMSG $chan :\002(\002DNS\002):\002 No AAAA record found."
- return
- }
- if {[regexp {(.*) has IPv6 address (.*)} $line match rHost6 output]} {
- putserv "PRIVMSG $chan :\002(\002DNS\002):\002 \002$rHost6\002 resolves to: \002$output\002, reverse: \002[dns:rv6 $output]"
- }
- if {[regexp {(.*) domain name pointer (.*)} $line match rHost6 output]} {
- putserv "PRIVMSG $chan :\002(\002DNS\002):\002 \002$rHost6\002 resolves to: \002$output\002"
- }
- }
- }
- }
- proc dns:rv6 {host} {
- if {![catch {set result [exec host -tAAAA $host]} error]} {
- foreach line [split $result "\n"] {
- if {[regexp {(.*) domain name pointer (.*)} $line found host result]} { return $result }
- }
- } else { return "\002none!" }
- }
- proc dns:ns {n u h c t} {
- if {[flood [string range $u [expr [string last @ $u]+1] e]]} {return 0}
- set host [lindex $t 0]
- if {![catch {set data [exec host -tNS $host]} error]} {
- foreach line [split $data "\n"] {
- if {[regexp {(.*) name server (.*)} $line match rHost4 output]} {
- putserv "PRIVMSG $c :\002(\002NS\002):\002 \002$rHost4\002 NS->: \002$output\002"
- }
- }
- }
- if {[string match "*NXDOMAIN*" $error]} {
- putserv "PRIVMSG $c :\002(\002NS\002):\002 No NS record found."
- return
- }
- }
- proc dns:v4 {host chan} {
- if {![catch {set data [exec host -tA $host]} error]} {
- foreach line [split $data "\n"] {
- if {[string match "*has no*" $line]} {
- putserv "PRIVMSG $chan :\002(\002DNS\002):\002 No A record found."
- return
- }
- if {[regexp {(.*) has address (.*)} $line match rHost4 output]} {
- putserv "PRIVMSG $chan :\002(\002DNS\002):\002 \002$rHost4\002 resolves to: \002$output\002, reverse: \002[dns:rv4 $output]"
- }
- }
- }
- }
- proc dns:rv4 {host} {
- if {![catch {set result [exec host -tPTR $host]} error]} {
- foreach line [split $result "\n"] {
- if {[regexp {(.*) domain name pointer (.*)} $line found host result]} { return $result }
- }
- } else { return "\002none!" }
- }
- proc flood {uhost} {
- global lastbind dns_f dns
- set a [lindex [split $dns(flood) :] 0] ; set b [lindex [split $dns(flood) :] 1]
- if {[info exists dns_f($uhost)]} {
- incr dns_f($uhost) 1
- if {$dns_f($uhost) > $a} {
- newignore *!*@${uhost} BOXINFO Flood $dns(ignore)
- return 1
- }
- } {set dns_f($uhost) 1}
- if {![string match "*unset dns_f($uhost)*" [utimers]]} {
- utimer $b "catch {unset dns_f($uhost)}"
- } ; return 0
- }
- namespace eval bandwidth {
- variable api "/proc/net/dev"
- # %IFN% : example eth0 # %IFA% : example WAN # %INC% : Incomming traffic # %OUT% : Outgoing traffic
- variable template "Incoming: \002(\002%INC%\002)\002 kb/s Outgoing: \002(\002%OUT%\002)\002 kb/s."
- # 0: privmsg to channel # 1: privmsg to nick # 2: notice to nick
- variable msgtype "0"
- variable version 0.2
- switch -regexp [string tolower $::tcl_platform(platform)] {
- "win" {
- variable switch 1
- }
- "unix" {
- variable switch 2
- }
- ".*" {
- variable switch 0
- }
- }
- switch -exact $msgtype {
- "0" { variable msg "PRIVMSG %CHAN%" }
- "1" { variable msg "PRIVMSG %NICK%" }
- "2" { variable msg "NOTICE %NICK%" }
- }
- proc f {value} {
- set test $value ; set unit 0
- while {[set test [expr {$test / 1024}]] > 0} {
- incr unit
- }
- return [format "%.2f %s" [expr {$value / pow(1024,$unit)}] [lindex [list B KB MB GB TB PB EB ZB YB] $unit]]
- }
- proc totals {n u h c t} {
- set ifacelist [exec cat /proc/net/dev]
- foreach line [split $ifacelist "\n"] {
- if {[string match "*:*" $line]} {
- regsub -all {:} $line { } line
- set iface "[lindex $line 0]"
- set network "$iface:NET"
- catch {exec cut \-d. \-f1 /proc/uptime} reply; set secs [expr $reply % 60]; set mins [expr $reply / 60 % 60]; set hours [expr $reply / 3600 % 24]; set days [expr $reply / 86400]
- set uptime "${days}d ${hours}h ${mins}m ${secs}s"
- if {![catch {set data [exec /sbin/ifconfig $iface]} error]} {
- foreach line [split $data "\n"] {
- if {[string match "*RX bytes*" $line]} {
- set rxb [lindex [split [lindex $line 1] ":"] 1]
- set txb [lindex [split [lindex $line 5] ":"] 1]
- if {![string match "0" $rxb] && ![string match "0" $txb]} {
- putserv "PRIVMSG $c :\002\[\002$network\002\]\002: total of [f $rxb] incoming, total of [f $txb] outgoing in $uptime."
- }
- }
- }
- }
- }
- }
- }
- proc bandwidth_pub {nick host hand chan arg} {
- if {[string match "-t" $arg]} { totals $nick $host $hand $chan $arg ; return 1 } else {
- variable switch; variable template; variable ::interface; variable msg; variable api
- set ifacelist [exec cat /proc/net/dev]
- foreach line [split $ifacelist "\n"] {
- if {[string match "*:*" $line]} {
- regsub -all {:} $line { } line
- set ::interface "[lindex $line 0]"
- set ifl "\002\[\002${::interface}:BW\002\]\002"
- if {[string equal 0 $switch]} {
- putlog "Error unknown operating system."
- } elseif {[string equal "1" $switch]} {
- if {[regexp -nocase {^(win):([a-zA-Z0-9\-]{1,100})$} $::interface -> ifn ifa]} {
- set s_inc 0; set s_out 0; set e_inc 0; set e_out 0
- foreach {x} [split [exec netstat -e] \n] {
- if {[string equal -nocase -length 4 byte $x]} {
- set s_inc [lindex $x 1]
- set s_out [lindex $x 2]
- }
- }
- after 500
- foreach {x} [split [exec netstat -e] \n] {
- if {[string equal -nocase -length 4 byte $x]} {
- set e_inc [lindex $x 1]
- set e_out [lindex $x 2]
- }
- }
- putserv "[string map [list %NICK% $nick %CHAN% $chan] $msg] :$ifn [string map [list %IFN% $ifn %IFA% $ifa %INC% [format %.2f [expr ($e_inc - $s_inc) / 512.0]] %OUT% [format %.2f [expr ($e_out - $s_out) / 512.0]]] $template]"
- } else {
- putlog "Script misconfiguration, check your settings."
- }
- } elseif {[string equal "2" $switch]} {
- if {[file exists $api]} {
- if {[file readable $api]} {
- if {[regexp {win:} $::interface]} {
- putlog "Script misconfiguration, check your settings."
- } else {
- if {[catch {open $api} rf]} {
- putlog "Error couldn't open $api for an unknown reason."
- } else {
- while {![eof $rf]} {
- gets $rf x
- foreach {ifn ifa} [split $::interface \x3a\x2c] {
- regexp "$ifn:\[\x20\t\]{0,100}(\[0-9\]{1,100})\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}(\[0-9\]{1,100})\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}" $x -> s_inc($ifn) s_out($ifn)
- }
- }
- close $rf
- }
- after 500
- if {[catch {open $api} rf]} {
- putlog "Error couldn't open $api for an unknown reason."
- } else {
- while {![eof $rf]} {
- gets $rf x
- foreach {ifn ifa} [split $::interface \x3a\x2c] {
- if {[regexp "$ifn:\[\x20\t\]{0,100}(\[0-9\]{1,100})\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}(\[0-9\]{1,100})\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}\[\x20\t\]{1,100}\[0-9\]{1,100}" $x -> e_inc($ifn) e_out($ifn)]} {
- if {![string match "0.00" [format %.2f [expr ($e_inc($ifn) - $s_inc($ifn)) / 512.0]]] && ![string match "0.00" [format %.2f [expr ($e_inc($ifn) - $s_inc($ifn)) / 512.0]]]} {
- putserv "[string map [list %NICK% $nick %CHAN% $chan] $msg] :$ifl [string map [list %IFN% $ifn %IFA% $ifa %INC% [format %.2f [expr ($e_inc($ifn) - $s_inc($ifn)) / 512.0]] %OUT% [format %.2f [expr ($e_out($ifn) - $s_out($ifn)) / 512.0]]] $template]"
- }
- }
- }
- }
- close $rf
- }
- }
- } else { putlog "Error $api is not readable." }
- } else { putlog "Error $api does not exist." }
- } else { putlog "Error unknown operating system." }
- }
- }
- }
- }
- }
- proc pub:lag:check {nick host hand chan test} {
- set ::lag "[clock clicks]";set ::lagchan $chan
- putquick "TIME"
- }
- proc raw:check:lag {from key text} {
- putmsg $::lagchan "\273\273 Current Networklag: [expr (([clock clicks] - $::lag)/2)/1000.] ms"
- unset ::lagchan;unset ::lag
- }
- proc pub:ping {n u h c t} {
- if {[flood [string range $u [expr [string last @ $u]+1] e]]} {return 0}
- if {[string match "*:*" $t]} { set pingexec "/bin/ping6" } else { set pingexec "/bin/ping" }
- if {![catch {set data [exec $pingexec -c4 $t]} error]} {
- foreach line [split $data "\n"] {
- if {[string match "*64 bytes from*" $line]} {
- regexp -- {from (.*?): } $line -> ip
- regexp -- {time=(.*?)ms} $line -> tim
- if {[string match "*packets transmitted*" $line]} {
- set footer "$line"
- }
- }
- }
- putserv "PRIVMSG $c :\002(\002IP\002):\002 $ip \002${tim}\002ms"
- }
- foreach l [split $error "\n"] {
- if {[string match "*packet loss*" $l]} { putserv "PRIVMSG $c :\002(\002IP\002):\002 stats: $l" }
- }
- }
- putlog "dns.tcl loaded."
- set portcheck_setting(flag) "-|-"
- set portcheck_setting(cmd_pub) ".port"
- set portcheck_setting(cmd_dcc) "portcheck"
- set portcheck_setting(read) 1
- set portcheck_setting(onjoin) 0
- set portcheck_setting(ports) "1080 21 23"
- set portcheck_setting(exemptflag) "+E"
- set portcheck_setting(autoban_svr) 0
- set portcheck_setting(autoban_list) 0
- set portcheck_setting(global) 0
- set portcheck_setting(bantime) 5
- set portcheck_setting(onotice) 1
- set portcheck_setting(bold) 1
- set portcheck_setting(PORTCHECK:) 1
- bind pub $portcheck_setting(flag) $portcheck_setting(cmd_pub) portcheck_scan_pub
- bind dcc $portcheck_setting(flag) $portcheck_setting(cmd_dcc) portcheck_scan_dcc
- bind join - * portcheck_onjoin_scan
- setudef flag portcheck
- proc portcheck_dopre {} {
- global portcheck_setting
- if {!$portcheck_setting(PORTCHECK:)} {
- return ""
- } elseif {!$portcheck_setting(bold)} {
- return "PORTCHECK: "
- } else {
- return "\002PORTCHECK:\002 "
- }
- }
- proc portcheck_onjoin_scan {nick uhost hand chan} {
- global portcheck_setting portcheck_chans
- if {($portcheck_setting(onjoin)) && ($portcheck_setting(ports) != "") && (![matchattr $hand $portcheck_setting(exemptflag)])} {
- foreach i [channel info $chan] {
- if {([string match "+portcheck" $i]) && ([botisop $chan])} {
- set host [lindex [split $uhost @] 1]
- foreach p $portcheck_setting(ports) {
- if {![catch {set sock [socket -async $host $p]} error]} {
- set timerid [utimer 15 [list portcheck_timeout_join $sock]]
- fileevent $sock writable [list portcheck_connected_join $nick $chan $sock $host $p $timerid]
- }
- }
- break
- }
- }
- }
- }
- proc portcheck_scan_pub {nick uhost hand chan text} {
- global portcheck_setting
- set host [lindex $text 0]
- set port [lindex $text 1]
- if {$port == ""} {
- # putquick "NOTICE $nick :Usage: $portcheck_setting(cmd_pub) <host> <port>"
- putquick "PRIVMSG $chan :Usage: $portcheck_setting(cmd_pub) <host> <port>"
- } else {
- if {[catch {set sock [socket -async $host $port]} error]} {
- putquick "PRIVMSG $chan :\002(\002Port\002)\002: Connection to $host:$port was motherfucking refused "
- } else {
- set timerid [utimer 15 [list portcheck_timeout_pub $chan $sock $host $port]]
- fileevent $sock writable [list portcheck_connected_pub $chan $sock $host $port $timerid]
- }
- }
- }
- proc portcheck_scan_dcc {hand idx text} {
- global portcheck_setting
- set host [lindex $text 0]
- set port [lindex $text 1]
- if {$port == ""} {
- putdcc $idx "[portcheck_dopre]Usage: .$portcheck_setting(cmd_dcc) <host> <port>"
- } else {
- if {[catch {set sock [socket -async $host $port]} error]} {
- putdcc $idx "[portcheck_dopre]Connection to $host \($port\) was refused "
- } else {
- set timerid [utimer 15 [list portcheck_timeout $idx $sock $host $port]]
- fileevent $sock writable [list portcheck_connected $idx $sock $host $port $timerid]
- }
- }
- }
- proc portcheck_connected {idx sock host port timerid} {
- killutimer $timerid
- if {[set error [fconfigure $sock -error]] != ""} {
- close $sock
- putdcc $idx "[portcheck_dopre]Connection to $host \($port\) failed \([string totitle $error]\)"
- } else {
- fileevent $sock writable {}
- fileevent $sock readable [list portcheck_read $idx $sock $host $port]
- putdcc $idx "[portcheck_dopre]Connection to $host \($port\) accepted "
- }
- }
- proc portcheck_timeout {idx sock host port} {
- close $sock
- putdcc $idx "[portcheck_dopre]Connection to $host \($port\) timed out "
- }
- proc portcheck_read {idx sock host port} {
- global portcheck_setting
- if {$portcheck_setting(read)} {
- if {[gets $sock read] == -1} {
- putdcc $idx "[portcheck_dopre]EOF On Connection To $host \($port\). Socket Closed."
- close $sock
- } else {
- putdcc $idx "[portcheck_dopre]$host \($port\) > $read"
- }
- } else {
- close $sock
- }
- }
- proc portcheck_connected_pub {chan sock host port timerid} {
- killutimer $timerid
- if {[set error [fconfigure $sock -error]] != ""} {
- close $sock
- putquick "PRIVMSG $chan :\002(\002Port\002)\002: Connection to $host:$port motherfucking failed. \([string totitle $error]\)"
- } else {
- fileevent $sock writable {}
- fileevent $sock readable [list portcheck_read_pub $chan $sock $host $port]
- putquick "PRIVMSG $chan :\002(\002Port\002)\002: Connection to $host:$port accepted. :D "
- }
- }
- proc portcheck_timeout_pub {chan sock host port} {
- close $sock
- putquick "PRIVMSG $chan :\002(\002Port\002)\002: Connection to $host:$port timed out. :-( "
- }
- proc portcheck_connected_join {nick chan sock host port timerid} {
- global portcheck_setting botnick
- killutimer $timerid
- if {[set error [fconfigure $sock -error]] != ""} {
- close $sock
- } else {
- fileevent $sock writable {}
- fileevent $sock readable [list portcheck_read_join $sock]
- if {$portcheck_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 {$portcheck_setting(autoban_svr)} {
- putserv "MODE $chan +b *!*@$host"
- putserv "KICK $chan $nick :One of the ports open on your host is banned."
- timer $portcheck_setting(bantime) [list portcheck_unsvrban $chan $host]
- } elseif {$portcheck_setting(autoban_list)} {
- if {$portcheck_setting(global)} {
- newban *!*@$host PortCheck "One of the ports open on your machine is banned." $portcheck_setting(bantime)
- } else {
- newchanban $chan *!*@$host PortCheck "One of the ports open on your machine is banned." $portcheck_setting(bantime)
- }
- }
- }
- }
- proc portcheck_timeout_join {sock} {
- close $sock
- }
- proc portcheck_read_join {sock} {
- close $sock
- }
- proc portcheck_read_pub {sock} {
- global portcheck_setting
- if {!$portcheck_setting(read)} {
- close $sock
- } elseif {[gets $sock read] == -1} {
- putquick "PRIVMSG $chan :\002(\002Port\002)\002: EOF On Connection To $host:$port. Socket Closed."
- close $sock
- }
- }
- proc portcheck_unsvrban {chan host} {
- putserv "MODE $chan -b *!*@$host"
- }
- putlog "port.tcl loaded."
- bind pub - .os oscheck
- proc oscheck {nick host handle chan text} {
- set server [lindex $text 0]
- set port 80
- set x 1
- set sock [socket $server $port]
- puts $sock "GET / HTTP/1.0"
- puts $sock "User.Agent:Mozilla"
- puts $sock "Host: $server"
- puts $sock ""
- flush $sock
- while {$x < 10} {
- gets $sock line
- if {[string match "*erver: *" $line]} {
- putserv "PRIVMSG $chan :$line"
- }
- if {[string match "*ate: *" $line]} {
- putserv "PRIVMSG $chan :$line"
- }
- incr x
- }
- close $sock
- }
- putlog "os.tcl loaded."
- bind pub - .nmap port_scan
- proc port_scan {nick uhost handle chan text} {
- if {[flood [string range $uhost [expr [string last @ $uhost]+1] e]]} {return 0}
- set h [lindex $text 0]; set flags [lrange $text 1 end]; set nmap [exec which nmap]; set f ""
- if {![catch {set data [exec $nmap \-sT ${h}]} error]} { foreach line [split $data "\n"] { regexp -all {(\d+)/tcp.*open} $line -> found; if {[info exists found]} { if {![string match "*$found*" $f]} { append f "$found " } } } }
- putserv "PRIVMSG $chan :\002(\002nmap\002)\002: $h: (\002TCP\002) $f"
- }
- package require http
- package require json
- bind pub * .ip fetch:geo
- proc fetch:geo {nick uhost hand chan text} {
- if {[scan $text {%s} lookup] != 1} {
- puthelp "PRIVMSG $chan :Error, syntax is: !geo <ip>"
- return
- }
- if {![regexp {([0-9]+\.)([0-9]+\.)([0-9]+\.)([0-9]+)} $lookup]} {
- puthelp "PRIVMSG $chan :Error, the IP you mentioned is not valid."
- return
- }
- catch {set http [::http::geturl http://ipinfo.io/$lookup/json -timeout 6000]} error
- set data [::http::data $http]
- set json [::json::json2dict $data]
- ::http::cleanup $http
- set keys [dict keys $json]
- foreach ele {ip hostname city region country loc postal phone org} {
- set $ele [expr {[lsearch $keys $ele] > -1 ? [dict get $json $ele] : "n/a"}]
- }
- puthelp "PRIVMSG $chan :IP: $ip - Hostname: $hostname - City: $city - Region: $region - Country: $country - Location: $loc - Organization: $org"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement