Code: Select all
bind raw - NOTICE ipcheck
proc ipcheck {frm key text} {
if {[string match *!*@* $frm] || ![string match -nocase "*client connecting*" $text]} { return }
regexp {:\ ([^ ]+)\s\(([^@]+)@([^\)])+\)\s\[([^\]]+)} $text - unick ident host ip
set data [getipdatas $ip]
if {[dict get $data status] eq "success"} {
logip $data
}
}
proc json2dict {JSONtext} {
string range [string trim [string trimleft [string map {\t {} \n {} \r {} , { } : { } \[ \{ \] \}} $JSONtext] {\uFEFF}]] 1 end-1
}
proc getipdatas { ip } {
::http::config -useragent "lynx"
set ipq [http::geturl http://ip-api.com/json/$ip?fields=status,proxy,query&lang=fr]
set data [json2dict [http::data $ipq]]
::http::cleanup $ipq
return $data
}
proc logip { data } {
set ip [dict get $data query]
if { [dict get $data proxy] eq "true"} {
putlog "$ip is a proxy"
}
}
Code: Select all
blacklist dronebl {
dns {
name dnsbl.dronebl.org;
type record;
reply { 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21; 22; 23; 24; 25; 100; 213; 255; };
};
action gzline;
ban-time 30d;
reason " 4Proxy14/4VPN ";
};
blacklist efnetrbl {
dns {
name rbl.efnetrbl.org;
type record;
reply { 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; };
};
action gzline;
ban-time 30d;
reason " 4Proxy14/4VPN ";
};
Code: Select all
package require http
package require json
namespace eval pchecker {
# proxycheck.io api key
variable pckey "xxxxxx-xxxxxx-xxxxxx-xxxxxxxx"
# min score to ban
variable score 10
# gzline message
variable gmsg "Sorry, VPN are not allowed"
# List of IP not checked
# they are regexp style
variable whitelist {"192\.168\.0\.1" "10\.0\.0\.*"}
# List of blacklisted IP
# regexp too :)
variable blacklist {}
bind raw - NOTICE ::pchecker::ipcheck
proc ipcheck {frm key text} {
if {[string match *!*@* $frm] || ![string match -nocase "*client connecting*" $text]} { return }
regexp {:\ ([^ ]+)\s\(([^@]+)@([^\)])+\)\s\[([^\]]+)} $text - unick ident host ip
if {[lsearch -regexp $::pchecker::whitelist $ip] ne -1} { return }
if {[lsearch -regexp $::pchecker::blacklist $ip] ne -1} {
putquick "GLINE *@$ip +7d :$::pchecker::gmsg"
return
}
::pchecker::isvpn $ip
}
proc json2dict {JSONtext} {
string range [string trim [string trimleft [string map {\t {} \n {} \r {} , { } : { } \[ \{ \] \}} $JSONtext] {\uFEFF}]] 1 end-1
}
proc isvpn {ip} {
::http::config -useragent "lynx"
set pcheck [::http::geturl http://proxycheck.io/v2/${ip}?key=$::pchecker::pckey&vpn=1&risk=1]
set data [json2dict [::http::data $pcheck]]
if {[dict get $data status] == "ok"} {
set proxy [dict get [dict get $data $ip] proxy]
set risk [dict get [dict get $data $ip] risk]
if {[expr $risk - $::pchecker::score] >= 0 } {
lappend $::pchecker::blacklist [string map {\. \\\.} $ip]
putquick "GLINE *@$ip +7d :$::pchecker::gmsg"
}
}
::http::cleanup $pcheck
}
}
Tcl error [::pchecker::ipcheck]: can't read "ip": no such variable
May be not 1000 unique VPN connections but yeah, 1000 connections per day (with/without proxies connecting). Since the other eggdrop's proxy scanner tcl I used had 500 to 1000 queries limit regardless of if they scan VPN/Proxy connection or not. Since, Eggdrop as IRCop scans every connection.CrazyCat wrote: Do you really have 1000 unique VPN connecting your network a day ?