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.

scan ip from a proxy scanner site

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
P
PeLL
Voice
Posts: 28
Joined: Fri Mar 04, 2011 10:59 am
Location: spain
Contact:

Post by PeLL »

Honestly, it turned out very well.
Again I want to ask if it is possible to generate a file to add ips to exception.
example : !add IP
that can add ips to exception from the same channel.
Thank you very much and I hope it is possible.
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

If you want to add complete IP and not range (or mask), it's quite simple.
Confirm that point and I'll make the addition to the script.
P
PeLL
Voice
Posts: 28
Joined: Fri Mar 04, 2011 10:59 am
Location: spain
Contact:

Post by PeLL »

Currently if I add any IP, eg: 80.20.10.*
other ips yes 80.10.20.30
I currently use both ways.
If it is difficult for you, let's put only the entire IP.
Thank you very much for answering
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Here is a small modification of the script:

Code: Select all

package require http

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
	variable whitelist {"192.168.0.1" "10.0.0.*"}

	# List of blacklisted IP
	variable blacklist {}

	# To enable on a chan, think to do
	# .chanset #chan +scanip
	setudef flag scanip

	bind join - * ::pchecker::whois
	bind raw - 378 ::pchecker::ipcheck
	bind pub - !add ::pchecker::ipadd
	bind pub - !rem ::pchecker::iprem

	proc whois {nick uhost handle chan} {
		if {![channel get $chan scanip]} { return }
		if {[isbotnick $nick]} { return }
		putquick "WHOIS $nick"
	}

	proc ipadd {nick uhost handle chan text} {
		if {[lsearch $::rpchecker::whitelist $text] == -1} {
			lappend ::rpchecker::whitelist $text
		}
	}
	
	proc iprem {nick uhost handle chan text} {
		set n [lsearch $::rpchecker::whitelist $text]
		if {$n == -1} {
			set ::rpchecker::whitelist [lreplace $::rpchecker::whitelist $n $n]
		}
	}
	
	proc ipcheck {frm key text} {
		set ip [lindex [split $text " "] end]
		foreach w $::pchecker::whitelist {
			if {[string match $w $text]} { return }
		}
		foreach b $::rpchecker::blacklist {
			if {[string match $w $text]} {
				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://api.isproxyip.com/v1/check.php?key=$::pchecker::pckey&ip=${ip}&format=json]
		set data [json2dict [::http::data $pcheck]]
		if {[dict get $data status] eq "success"} {
			set proxy [dict get $data proxy]
			if {$proxy == 1 } {
				lappend $::pchecker::blacklist $ip
				putquick "GLINE *@$ip +7d :$::pchecker::gmsg"
			}
		}
		::http::cleanup $pcheck
	}
	
}
Note that ips (whitelist and blacklist) are stored only in eggdrop memory, but you can easily add a save to file (or DB)
P
PeLL
Voice
Posts: 28
Joined: Fri Mar 04, 2011 10:59 am
Location: spain
Contact:

Post by PeLL »

again I thank you.
It works but I had to edit a detail.

you:

Code: Select all

  proc ipadd {nick uhost handle chan text} {
      if {[lsearch $::rpchecker::whitelist $text] == -1} {
         lappend ::rpchecker::whitelist $text
      }
   }
   
   proc iprem {nick uhost handle chan text} {
      set n [lsearch $::rpchecker::whitelist $text]
      if {$n == -1} {
         set ::rpchecker::whitelist [lreplace $::rpchecker::whitelist $n $n]
      }
i edit :

Code: Select all

  proc ipadd {nick uhost handle chan text} {
      if {[lsearch $::pchecker::whitelist $text] == -1} {
         lappend ::pchecker::whitelist $text
      }
   }
   
   proc iprem {nick uhost handle chan text} {
      set n [lsearch $::pchecker::whitelist $text]
      if {$n == -1} {
         set ::pchecker::whitelist [lreplace $::pchecker::whitelist $n $n]
      }
thist "r" the rpcheker no works ,remove the "r" if works .

it is true that it is better to create a .txt or .db to better see the ips added to review what happened in the future.
Right now I can't see the added ips but it works.
can you add to add ips in a .txt (for example) and see the ips when added?

again I tell you that thank you very much for the work.
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I don't know why I added the "r".
You have other occurences, replace all rpchecker with pchecker :

Code: Select all

	proc ipadd {nick uhost handle chan text} {
		if {[lsearch $::pchecker::whitelist $text] == -1} {
			lappend ::pchecker::whitelist $text
		}
	}
	
	proc iprem {nick uhost handle chan text} {
		set n [lsearch $::pchecker::whitelist $text]
		if {$n == -1} {
			set ::pchecker::whitelist [lreplace $::pchecker::whitelist $n $n]
		}
	}
	
	proc ipcheck {frm key text} {
		set ip [lindex [split $text " "] end]
		foreach w $::pchecker::whitelist {
			if {[string match $w $text]} { return }
		}
		foreach b $::pchecker::blacklist {
			if {[string match $w $text]} {
				putquick "GLINE *@$ip +7d :$::pchecker::gmsg"
				return
			}
		}
		::pchecker::isvpn $ip
	}
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Not tested (the write/read file come from another of my scripts):

Code: Select all

package require http

namespace eval pchecker {

	# proxycheck.io api key
	variable pckey "xxxxxx-xxxxxx-xxxxxx-xxxxxxxx"

	# gzline message
	variable gmsg "Sorry, VPN are not allowed"

	# List of IP not checked
	variable whitelist {}

	# List of blacklisted IP
	variable blacklist {}
	
	variable wlfile "scripts/pcheckerwl.txt"

	# To enable on a chan, think to do
	# .chanset #chan +scanip
	setudef flag scanip

	bind join - * ::pchecker::whois
	bind raw - 378 ::pchecker::ipcheck
	bind pub - !add ::pchecker::ipadd
	bind pub - !rem ::pchecker::iprem

	proc whois {nick uhost handle chan} {
		if {![channel get $chan scanip]} { return }
		if {[isbotnick $nick]} { return }
		putquick "WHOIS $nick"
	}

	proc ipadd {nick uhost handle chan text} {
		if {[lsearch $::pchecker::whitelist $text] == -1} {
			lappend ::pchecker::whitelist $text
		}
		::pchecker::l2file $::pchecker::whitelist $::pchecker::pcheckerwl
	}
	
	proc iprem {nick uhost handle chan text} {
		set n [lsearch $::pchecker::whitelist $text]
		if {$n == -1} {
			set ::pchecker::whitelist [lreplace $::pchecker::whitelist $n $n]
			::pchecker::l2file $::pchecker::whitelist $::pchecker::pcheckerwl
		}
	}
	
	proc ipcheck {frm key text} {
		set ip [lindex [split $text " "] end]
		foreach w $::pchecker::whitelist {
			if {[string match $w $text]} { return }
		}
		foreach b $::pchecker::blacklist {
			if {[string match $w $text]} {
				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://api.isproxyip.com/v1/check.php?key=$::pchecker::pckey&ip=${ip}&format=json]
		set data [json2dict [::http::data $pcheck]]
		if {[dict get $data status] eq "success"} {
			set proxy [dict get $data proxy]
			if {$proxy == 1 } {
				lappend $::pchecker::blacklist $ip
				putquick "GLINE *@$ip +7d :$::pchecker::gmsg"
			}
		}
		::http::cleanup $pcheck
	}

	proc l2file {olist dfile} {
		set fo [open $dfile w]
		puts $fo [join $olist "\n"]
		close $fo
	}
	
	proc f2list {dfile} {
		set fi [open $dfile r]
		set olist [split [read -nonewline $fi] "\n"]
		close $fi
		return $olist
	}
	
	set ::pchecker::whitelist [::pchecker::f2list $::pchecker::pcheckerwl]
	
}
P
PeLL
Voice
Posts: 28
Joined: Fri Mar 04, 2011 10:59 am
Location: spain
Contact:

Post by PeLL »

Ok, I have modified the wlfile variable
It gave an error and I put: pcheckerwl
variable wlfile "scripts/pcheckerwl.txt"
modify:
variable pcheckerwl "scripts/pcheckerwl.txt"
right now I add ip and it works.
But delete doesn't work.
thank you very much again for your time.
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Coding too fast...
Find:

Code: Select all

if {$n == -1} { 
Replace with:

Code: Select all

if {$n != -1} { 
P
PeLL
Voice
Posts: 28
Joined: Fri Mar 04, 2011 10:59 am
Location: spain
Contact:

Post by PeLL »

I just tried everything again, and now everything works perfectly.
the bot is a bit laggy but that's another topic :D
thank you very much really .
User avatar
TimeRider
Voice
Posts: 28
Joined: Tue Jul 07, 2020 3:46 pm
Contact:

Post by TimeRider »

Thanks, CrazyCat for the more detailed script.

However, I was curious to know if the script could be made not to ban a specific geo-location or country. The reason for this is due to false positives with the scanner.

Actually, If you could make the TCL exclude the scan from the geolocation from Nepal as there is no VPN connection in this country? Also, I would like to exclude Nepal from scans for my chat room.

So, is it possible to do it?

Thank you!
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Hi,
It's impossible with this script as isproxyip.com doesn't returns the country
User avatar
TimeRider
Voice
Posts: 28
Joined: Tue Jul 07, 2020 3:46 pm
Contact:

Post by TimeRider »

Hi CrazyCat, is it possible to do this with ip-api.com, I am currently using that.
Thank you!
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

It's totally possible, paste your actual code on https://tools.eggdrop.fr/privatebin/ and give us the link to it, I'll modify the script
User avatar
TimeRider
Voice
Posts: 28
Joined: Tue Jul 07, 2020 3:46 pm
Contact:

Post by TimeRider »

Hey CrazyCat,

Here is the link to the tcl script
https://tools.eggdrop.fr/privatebin/?58 ... W3bby91pMg
Post Reply