Advertisement
tuvok81

AntiProxy Script TCL

May 9th, 2022
1,489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 13.88 KB | None | 0 0
  1.     #  __ __        __                          ___                                              __
  2.     #  _\ \\ \__    /\ \                        /\_ \                                            /\ \__
  3.     # /\__  _  _\  \_\ \    __  __  __    __\//\ \    ___  _____    ___ ___      __    ___\ \ ,_\
  4.     # \/__\ \\ \__  /'_` \  /'__`\/\ \/\ \  /'__`\\ \ \  / __`\/\ '__`\ /' __` __`\  /'__`\/' _ `\ \ \/
  5.     #  /\_  _  _\/\ \_\ \/\  __/\ \ \_/ |/\  __/ \_\ \_/\ \_\ \ \ \_\ \/\ \/\ \/\ \/\  __//\ \/\ \ \ \_
  6.     #  \/_/\_\\_\/\ \___,_\ \____\\ \___/ \ \____\/\____\ \____/\ \ ,__/\ \_\ \_\ \_\ \____\ \_\ \_\ \__\
  7.     #      \/_//_/  \/__,_ /\/____/ \/__/  \/____/\/____/\/___/  \ \ \/  \/_/\/_/\/_/\/____/\/_/\/_/\/__/
  8.     #                                                              \ \_\
  9.     #                                                              \/_/
  10.     #
  11.     #                        /\ \                /\ \__  __
  12.     #  _____  _ __  ___    \_\ \  __  __    ___\ \ ,_\/\_\    ___    ___    ____
  13.     # /\ '__`\/\`'__\/ __`\  /'_` \/\ \/\ \  /'___\ \ \/\/\ \  / __`\ /' _ `\  /',__\
  14.     # \ \ \_\ \ \ \//\ \_\ \/\ \_\ \ \ \_\ \/\ \__/\ \ \_\ \ \/\ \_\ \/\ \/\ \/\__, `\
  15.     #  \ \ ,__/\ \_\\ \____/\ \___,_\ \____/\ \____\\ \__\\ \_\ \____/\ \_\ \_\/\____/
  16.     #  \ \ \/  \/_/ \/___/  \/__,_ /\/___/  \/____/ \/__/ \/_/\/___/  \/_/\/_/\/___/
  17.     #    \ \_\
  18.     #    \/_/
  19.     #
  20.     # Anti proxy scan script.
  21.  
  22.     # /* This is an anti proxy script written for eggdrop. It's been tested on eggdrop1.6.17 with TCL version 8.4
  23.     # *  Unlike other anti proxy scripts i've seen around.
  24.     # *  This script works just as well on a windrop as it does on a windrop
  25.     # *  I've been testing it with a few proxies myself and it clears about 5 proxies in a few seconds without a problem
  26.     # *  If it detects a floodjoin happening it will set the modes you choose
  27.     # *  (Default mir = moderated, invite only, registered only) These modes are for Quakenet though.
  28.     # *  The script will first check what modes you already have set so it won't be unsetting a mode you already had before the floodjoin
  29.     # */
  30.  
  31.     # /* Author info
  32.     # *  I made this script because i was sick of all the proxies that were joining my channel and spamming it
  33.     # *  It's based off the proxycheck.tcl made by James. I rewrote the entire script but kept the basics in.
  34.     # *  This script is generally alot faster than that script. But it's still in beta form!
  35.     # *  I release this script to http://development.woosah.org
  36.     # *  and no other websites are allowed to release this without my explicit authorisation.
  37.     # *  If you have an eggdrop website with scripts and you'd like to put this script on your webpage,
  38.     # *  Send me an email at metroid at gmail.com replacing at with @
  39.     # */
  40.  
  41.     # /* Installing the anti-proxy script
  42.     # *  First, put the script into your /scripts folder.
  43.     # *  Then at the end of your eggdrop.conf, Put:
  44.     # *  source scripts/anti-proxy.tcl
  45.     # *  Or if you are using the #development configuration file, you won't have to do anything.
  46.     # *  Just rehash the bot after you've done this and it should work.
  47.     # *  Read the next part about using it.
  48.     # */
  49.  
  50.     # /* Using the anti-proxy script
  51.     # *  The script itself pretty much does everything automaticly once it's activated.
  52.     # *  You can activate it by typing: <trigger>proxy enable
  53.     # *  You can deactivate it by typing: <trigger>proxy disable
  54.     # *  If you want some statistics about how many people it has scanned, detected or kicked,
  55.     # *  you can use <trigger>proxy stats
  56.     # *  Just typing <trigger>proxy will tell you if the check is enabled or disabled, and possibly statistics about it.
  57.     # */
  58.  
  59.     namespace eval proxy {
  60.         variable version "0.75"
  61.         variable author  "metroid - #development on irc.quakenet.org"
  62.  
  63.         variable trigger ","
  64.         ### The sources we dns to find out if a user is a proxy
  65.         #variable source { "spambot.bls.digibase.ca" "rbl.efnet.org" "bl.spamcop.net" "dnsbl.dronebl.org"}
  66.         variable source { "dnsbl.dronebl.org" "rbl.efnet.org" "spambot.bls.digibase.ca" "zen.spamhaus.org" "truncate.gbudb.net" }
  67.         setudef flag antiproxy
  68.  
  69.         setudef str  antijoins
  70.         setudef str  antidetected
  71.         setudef str  antikicked
  72.  
  73.         # /* Settings! */
  74.         variable flood "0:0" ;# 4 proxies that join in 8 seconds and the channel gets closed
  75.         variable close "0"  ;# This is in seconds! It will keep the channel closed for 30 seconds
  76.         variable modes ""  ;# the modes it will set when the channel gets flooded.
  77.         # /* End of settings */
  78.  
  79.         # /* Don't edit anything below these lines. If you break it, don't expect me to fix it for you. */
  80.         bind JOIN -|- *                  [namespace current]::checkuser
  81.         bind PUB  m|n ${trigger}proxy    [namespace current]::toggle
  82.  
  83.         variable proxy
  84.         array set proxy ""
  85.     }
  86.  
  87.     package require ip
  88.  
  89.     proc proxy::toggle {nickname hostname handle channel arguments} {
  90.         set command [lindex [split $arguments] 0]
  91.         switch -exact -- [string tolower $command] {
  92.                 enable {
  93.                         if {![channel get $channel antiproxy]} {
  94.                                 channel set $channel +antiproxy
  95.                                 putquick "NOTICE $nickname :Done. Anti-Proxy was enabled."
  96.                         } else {
  97.                                 putquick "NOTICE $nickname :Error: Anti-Proxy is already enabled."
  98.                         }
  99.                 }
  100.                 disable {
  101.                         if {[channel get $channel antiproxy]} {
  102.                                 channel set $channel -antiproxy
  103.                                 putquick "NOTICE $nickname :Done. Anti-Proxy was disabled."
  104.                         } else {
  105.                                 putquick "NOTICE $nickname :Error: Anti-Proxy is already disabled."
  106.                         }
  107.                 }
  108.                 stats {
  109.                         if {([channel get $channel antijoins] != "") || ([channel get $channel antidetected] != "") || ([channel get $channel antikicked] != "")} {
  110.                                 putquick "NOTICE $nickname :Stats for $channel: [statistics $channel]"
  111.                         } else {
  112.                                 putquick "NOTICE $nickname :No statistics available for $channel."
  113.                         }
  114.                 }
  115.                 default {
  116.                         if {[channel get $channel antiproxy]} {
  117.                                 putquick "NOTICE $nickname :Anti-Proxy is currently enabled for $channel. Statistic: [statistics $channel]"
  118.                         } else {
  119.                                 putquick "NOTICE $nickname :Anti-Proxy is currently disabled for $channel."
  120.                         }
  121.                 }
  122.         }
  123.     }
  124.  
  125.     proc proxy::checkuser {nickname hostname handle channel} {
  126.         checkstats $channel
  127.         if {[channel get $channel antiproxy] && [botisop $channel] && ![string match *users.quakenet.org* $hostname] && ![matchattr $handle m|m $channel] && ![isbotnick $nickname]} {
  128.                 channel set $channel antijoins "[expr [channel get $channel antijoins] + 1]"
  129.                 regexp {.*\@(.*)} $hostname -> hostname
  130.                 if [regexp {[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$} $hostname] {
  131.                         [namespace current]::check $hostname $hostname 1 $nickname $hostname $channel
  132.                 } else {
  133.                         if {[string first : $hostname]>-1} {
  134.                                 [namespace current]::check6 $nickname $hostname $channel
  135.                         } else {
  136.                         putlog "--> Checking $hostname with $proxylist"
  137.                                 dnslookup $hostname [namespace current]::check $nickname $hostname $channel
  138.                         }
  139.                 }
  140.         }
  141.     }
  142.  
  143.     proc proxy::check {ip hostname status nickname originalhost channel } {
  144.         variable source
  145.         if {$status} {
  146.                 regexp {([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})} $ip -> part1 part2 part3 part4
  147.                 set newip "$part4.$part3.$part2.$part1"
  148.                 foreach proxylist $source {
  149.                 putlog "--> Checking $ip with $proxylist"
  150.                         dnslookup "$newip.$proxylist" [namespace current]::check2 $nickname $ip $originalhost $hostname $channel $proxylist
  151.                 }
  152.         } else {
  153.                 putlog "AntiProxy: Couldn't dns resolve $originalhost."
  154.         }
  155.     }
  156.  
  157.     proc proxy::check6 {nickname ip channel } {
  158.         variable source
  159.         set ip [::ip::normalize $ip]
  160.         regsub -all -- {:} $ip {} tip
  161.         set iip {}
  162.         for {set i 0} {$i<[string length $tip]} {incr i} {
  163.                 lappend iip [string index $tip end-$i]
  164.         }
  165.         set ip2 [join $iip .]
  166.         foreach proxylist $source {
  167.                 putlog "--> Checking $ip with $proxylist"
  168.                 dnslookup "$ip2.$proxylist" [namespace current]::check2 $nickname $ip $ip $ip $channel $proxylist
  169.         }
  170.     }
  171.  
  172.     proc proxy::check2 {ip hostname status nickname oip realhost originalhost channel rbl } {
  173.         variable proxy
  174.         variable bantime
  175.         variable close
  176.         if {[info exists proxy($channel,$nickname)]} { return 0 }
  177.         set closemode [modes $channel]
  178.         putlog "<-- $rbl gives $ip for $oip"
  179.         if {!$status || $status==0 } { return }
  180.         set proxy($channel,$nickname) 1
  181.         utimer 10 [list unset [namespace current]::proxy($channel,$nickname)]
  182.         channel set $channel antidetected "[expr [channel get $channel antidetected] + 1]"
  183.         if {[floodjoin $channel]} {
  184.                 putquick "MODE $channel +b *!*@$realhost" -next
  185.                 set ::close($channel) 1
  186.                 utimer $close [list [namespace current]::open "$channel" "$closemode"]
  187.         }
  188.         #    pushmode $channel +b *!*@$realhost
  189.         if [regexp {[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$} $originalhost] {
  190.                 putquick "KICK $channel $nickname :\<$oip\> is in the DNSBL \[$rbl\]] \(ID: [expr [channel get $channel antikicked] + 1]\)"
  191.         } else {
  192.                 putquick "KICK $channel $nickname :\<$oip\> \[$originalhost\] is in the DNSBL \[$rbl\]] \(ID: [expr [channel get $channel antikicked] + 1]\)"
  193.         }
  194.         channel set $channel antikicked "[expr [channel get $channel antikicked] + 1]"
  195.         utimer 3 [list flushmode $channel]
  196.     }
  197.  
  198.     proc proxy::open {channel modes} {
  199.         if {[info exists ::close($channel)]} {
  200.                 putserv "MODE $channel -$modes"
  201.                 unset ::close($channel)
  202.         } else {
  203.                 return 0
  204.         }
  205.     }
  206.  
  207.     proc proxy::modes {channel} {
  208.         variable modes
  209.         set end ""
  210.         set chanmode [lindex [getchanmode $channel] 0]
  211.         foreach mode [split $modes ""] {
  212.                 if {![string match *$mode* $chanmode]} {
  213.                         append end $mode
  214.                 }
  215.         }
  216.         return "[join $end]"
  217.     }
  218.     proc proxy::unsetflood {channel} {
  219.         if {[info exists ::flood($channel)]} {
  220.                 unset ::flood($channel)
  221.         }
  222.     }
  223.  
  224.     proc proxy::statistics {channel} {
  225.         set joins    [channel get $channel antijoins]
  226.         set detected [channel get $channel antidetected]
  227.         set kicked  [channel get $channel antikicked]
  228.         if {$joins == "" || $joins == "0"} {
  229.                 return "Statistic Unavailable"
  230.         } elseif {$detected == "" || $detected == "0"} {
  231.                 return "Statistic Unavailable"
  232.         } elseif {$kicked == "" || $kicked == "0"} {
  233.                 return "Statistic Unavailable"
  234.         } else {
  235.                 return "Scanned: $joins, Detected: $detected, Kicked: $kicked  \[[format %.2f [expr ($kicked * 100.0) / $joins]]%\]"
  236.         }
  237.     }
  238.  
  239.     proc proxy::checkstats {channel} {
  240.         # /* This is set to 1 to prevent the bot from crashing. (for some people this appears to be a problem) */
  241.         if {[channel get $channel antijoins] == ""} { channel set $channel antijoins "1" }
  242.         if {[channel get $channel antidetected] == ""} { channel set $channel antidetected "1" }
  243.         if {[channel get $channel antikicked] == ""} { channel set $channel antikicked "1" }
  244.     }
  245.  
  246.     proc proxy::floodjoin {channel} {
  247.         variable flood
  248.         set split [split $flood :]
  249.         set user [lindex $split 0]
  250.         set seconds [lindex $split 1]
  251.         if {![info exists ::flood($channel)]} {
  252.                 set ::flood($channel) 1
  253.         } else {
  254.                 incr ::flood($channel)
  255.         }
  256.         if {$::flood($channel) >= $user} {
  257.                 set ::flood($channel) 0
  258.                 return 1
  259.         } else {
  260.                 utimer $seconds [list [namespace current]::unsetflood $channel]
  261.         }
  262.         return 0
  263.     }
  264.  
  265.     proc proxy::credits {} {
  266.         variable file [lindex [split [info script] "/"] end];
  267.         variable version;
  268.         variable owner "metroid (#development)";
  269.         variable modified [clock format [file mtime [info script]] -format "%Y/%m/%d %H:%M:%S"];
  270.         set channels 0; set total 0; set end ""
  271.         foreach chan [channels] {;
  272.                 checkstats $chan
  273.                 incr total
  274.                 if {[channel get $chan antiproxy]} { incr channels ; lappend end $chan }
  275.         };
  276.         putlog "$file v$version by $owner - Last modified: $modified"
  277.         putlog "$file active on $channels/$total ([format %.2f [expr ($channels.0 * 100.0) / $total.0]]%) channels: [join $end ", "]"
  278.         putlog "$file was successfully loaded!"
  279.     }
  280.  
  281.     #proxy::credits
  282.  
  283.     # // Copyright: This script was made by metroid (#development). This means, YOU DIDNT MAKE IT! I DID! :p
  284.     # // Don't break my copyright because it's lame and i'll sue you ass if you do. Have fun!
  285.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement