This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

VPN Hunter

Help for those learning Tcl or writing their own scripts.
Post Reply
V
Valentin
Voice
Posts: 14
Joined: Sun Sep 04, 2022 12:54 am
Location: London
Contact:

VPN Hunter

Post by Valentin »

Hello, all.
I have this script, that make the bot to add gline to all vpns if is !on and show all vpns connection if is !off.
But something doesn`t work properly. The bot show me all connections in that channel, doesn`t matter are they vpn or not.
I need a help to fix it.

Code: Select all

package require http
package require json

namespace eval pchecker {

	# proxycheck.io api key
	variable pckey "xxxxx xxxxx xxxxx xxxxx"

	# min score to ban
	variable score 10

	# gzline message
	variable gmsg "VPN is not allowed at the moment!"

	# 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 {}

	# Control channel
	set cchan #vpn

	# internal variable : status of VPN search
	set onoff 0

	bind raw - NOTICE ::pchecker::ipcheck
	bind pub - "!on" ::pchecker::on
	bind pub - "!off" ::pchecker::off

	proc on {nick uhost handle chan text} {
		if {$chan ne $::pchecker::cchan} { return }
		if {$::pchecker::onoff == 1} {
			putserv "PRIVMSG $::pchecker::cchan :\00303VPN HUNTER is tutn ON"
			return
		}
		set ::pchecker::onoff 1
	}

	proc off {nick uhost handle chan text} {
		if {$chan ne $::pchecker::cchan} { return }
		if {$::pchecker::onoff == 0} {
			putserv "PRIVMSG $::pchecker::cchan :\00304VPN HUNTER is turn OFF\003"
			return
		}
		set ::pchecker::onoff 0
	}

	proc ipcheck {frm key text} {
		if {[string match *!*@* $frm] || ![string match -nocase "*client connecting*" $text]} { return }
		regexp {:\s.*?:\s(.*?)!(.*?)@(.*?)\s\((.*?)\)} $text - unick ident host ip
		putserv "PRIVMSG $::pchecker::cchan :\00304VPN Detected\003 : \00303$unick\003 \00307is connecting with ip\003 $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
		}
		if {$::pchecker::onoff == 1 } { ::pchecker::isvpn $ip }
	}


	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 [::json::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
	}

}

if there's a will, there's a way.
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

That is exactly what you asked me:
2022-08-29 16:03:04 Valentin so the bot is VPNSErv
2022-08-29 16:03:18 Valentin I want the same bot to show me any connection
2022-08-29 16:03:26 Valentin and if I set !on
2022-08-29 16:03:42 Valentin to add gline to every vpn connection
2022-08-29 16:04:00 Valentin but still show me who from where is connected
2022-08-29 16:04:33 CrazyCat So, if I summarize: all connections are alway showed and the gline is done only if the script is set to on ?
2022-08-29 16:05:00 CrazyCat if !off command has ben set, the connection is showed, nothing else
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

IMHO if u tackle the abuse rather than using all kinds of databases for vpn proxy and what not its rather more effiecient i assume u are running your own irc server since u opered your eggdrops IRCDs like unrealircd 6 and inspircd 3 have all kinds of modules and protections to handle almost any kind of abuse without having to set any ban or keep databases to gline vpn ranges , proxy or other.

I manage several irc networks as well and we had issues with vpn ranges too but we used a zillion modules and now abuse is of the past regardless of them using vpn ranges or proxy IP's.
V
Valentin
Voice
Posts: 14
Joined: Sun Sep 04, 2022 12:54 am
Location: London
Contact:

Post by Valentin »

Hey CrazyCat, My idea been to show me ip and country from connection.
For example CrazyCat is connected with ip 1.1.1.1 from France.
May be I didn`t explaned you better. So that is what I want, and is more better if show me only vpn connections.
if there's a will, there's a way.
Post Reply