egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

scan ip from a proxy scanner site
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
PeLL
Voice


Joined: 04 Mar 2011
Posts: 14
Location: spain

PostPosted: Fri Apr 29, 2022 2:40 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Fri Apr 29, 2022 3:58 pm    Post subject: Reply with quote

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.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
PeLL
Voice


Joined: 04 Mar 2011
Posts: 14
Location: spain

PostPosted: Fri Apr 29, 2022 4:07 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Sat Apr 30, 2022 7:49 am    Post subject: Reply with quote

Here is a small modification of the script:
Code:
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)
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
PeLL
Voice


Joined: 04 Mar 2011
Posts: 14
Location: spain

PostPosted: Sat Apr 30, 2022 9:36 am    Post subject: Reply with quote

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

you:
Code:
  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:
  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.
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Sat Apr 30, 2022 9:49 am    Post subject: Reply with quote

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

Code:
   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
   }

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Sat Apr 30, 2022 10:42 am    Post subject: Reply with quote

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

Code:
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]
   
}

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
PeLL
Voice


Joined: 04 Mar 2011
Posts: 14
Location: spain

PostPosted: Sat Apr 30, 2022 4:07 pm    Post subject: Reply with quote

Ok, I have modified the wlfile variable
It gave an error and I put: pcheckerwl

Quote:
variable wlfile "scripts/pcheckerwl.txt"


modify:

Quote:
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.
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Sat Apr 30, 2022 6:28 pm    Post subject: Reply with quote

Coding too fast...
Find:
Code:
if {$n == -1} {


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

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
PeLL
Voice


Joined: 04 Mar 2011
Posts: 14
Location: spain

PostPosted: Sun May 01, 2022 1:56 pm    Post subject: Reply with quote

I just tried everything again, and now everything works perfectly.
the bot is a bit laggy but that's another topic Very Happy
thank you very much really .
Back to top
View user's profile Send private message Visit poster's website
TimeRider
Voice


Joined: 07 Jul 2020
Posts: 27

PostPosted: Mon Dec 19, 2022 9:51 am    Post subject: Reply with quote

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!
_________________
Online chat
Nepal chat
Pakistan chat
Indian chat
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Wed Dec 21, 2022 7:10 am    Post subject: Reply with quote

Hi,
It's impossible with this script as isproxyip.com doesn't returns the country
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
TimeRider
Voice


Joined: 07 Jul 2020
Posts: 27

PostPosted: Wed Dec 21, 2022 11:14 am    Post subject: Reply with quote

Hi CrazyCat, is it possible to do this with ip-api.com, I am currently using that.
Thank you!
_________________
Online chat
Nepal chat
Pakistan chat
Indian chat
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Wed Dec 21, 2022 11:28 am    Post subject: Reply with quote

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
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
TimeRider
Voice


Joined: 07 Jul 2020
Posts: 27

PostPosted: Sat Dec 24, 2022 11:51 am    Post subject: Reply with quote

Hey CrazyCat,

Here is the link to the tcl script
https://tools.eggdrop.fr/privatebin/?58fe87a24b21549f#B11twQqv5j3Q4DCunES7CijFYHShoKYJXBW3bby91pMg
_________________
Online chat
Nepal chat
Pakistan chat
Indian chat
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber