tuvok81

AntiProxy.tcl for Eggdrop

May 2nd, 2022 (edited)
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 13.21 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.efnetrbl.org" "rbl.efnet.org" "dnsbl.tornevall.org" "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.  
  80.  # /* Don't edit anything below these lines. If you break it, don't expect me to fix it for you. */
  81.  bind JOIN -|- *                  [namespace current]::checkuser
  82.  bind PUB  m|n ${trigger}proxy    [namespace current]::toggle
  83.  
  84.  variable proxy
  85.  array set proxy ""
  86. }
  87.  
  88. proc proxy::toggle {nickname hostname handle channel arguments} {
  89.  set command [lindex [split $arguments] 0]
  90.  switch -exact -- [string tolower $command] {
  91.   enable {
  92.   if {![channel get $channel antiproxy]} {
  93.     channel set $channel +antiproxy
  94.     putquick "NOTICE $nickname :Done. Anti-Proxy was enabled."
  95.   } else {
  96.     putquick "NOTICE $nickname :Error: Anti-Proxy is already enabled."
  97.   }
  98.   }
  99.   disable {
  100.   if {[channel get $channel antiproxy]} {
  101.     channel set $channel -antiproxy
  102.     putquick "NOTICE $nickname :Done. Anti-Proxy was disabled."
  103.   } else {
  104.     putquick "NOTICE $nickname :Error: Anti-Proxy is already disabled."
  105.   }
  106.   }
  107.   stats {
  108.   if {([channel get $channel antijoins] != "") || ([channel get $channel antidetected] != "") || ([channel get $channel antikicked] != "")} {
  109.     putquick "NOTICE $nickname :Stats for $channel: [statistics $channel]"
  110.   } else {
  111.     putquick "NOTICE $nickname :No statistics available for $channel."
  112.   }
  113.   }
  114.   default {
  115.   if {[channel get $channel antiproxy]} {
  116.     putquick "NOTICE $nickname :Anti-Proxy is currently enabled for $channel. Statistic: [statistics $channel]"
  117.   } else {
  118.     putquick "NOTICE $nickname :Anti-Proxy is currently disabled for $channel."
  119.   }
  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.   dnslookup $hostname [namespace current]::check $nickname $hostname $channel
  134.   }
  135.  }
  136. }
  137.  
  138. proc proxy::check  {ip hostname status nickname originalhost channel } {
  139.   variable source
  140.   if {$status} {
  141.     regexp {([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})} $ip -> part1 part2 part3 part4
  142.     set newip "$part4.$part3.$part2.$part1"
  143.  
  144.     foreach proxylist $source {
  145.       dnslookup "$newip.$proxylist" [namespace current]::check2 $nickname $ip $originalhost $hostname $channel $proxylist
  146.     }
  147.   } else {
  148.     putlog "AntiProxy: Couldn't dns resolve $originalhost."
  149.   }
  150. }
  151.  
  152. proc proxy::check2 {ip hostname status nickname oip realhost originalhost channel rbl } {
  153.   variable proxy
  154.   variable bantime
  155.   variable close
  156.   if {[info exists proxy($channel,$nickname)]} { return 0 }
  157.   set closemode [modes $channel]
  158.   if {$status} {
  159.     set proxy($channel,$nickname) 1
  160.     utimer 10 [list unset [namespace current]::proxy($channel,$nickname)]
  161.     channel set $channel antidetected "[expr [channel get $channel antidetected] + 1]"
  162.     if {[floodjoin $channel]} {
  163.     putquick "MODE $channel +b *!*@$realhost" -next
  164.     set ::close($channel) 1
  165.     utimer $close [list [namespace current]::open "$channel" "$closemode"]
  166.     }
  167. #    pushmode $channel +b *!*@$realhost
  168.     if [regexp {[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$} $originalhost] {
  169.     putquick "KICK $channel $nickname :\<$oip\> is in the DNSBL \[$rbl\]] \(ID: [expr [channel get $channel antikicked] + 1]\)"
  170.     } else {
  171.     putquick "KICK $channel $nickname :\<$oip\> \[$originalhost\] is in the DNSBL \[$rbl\]] \(ID: [expr [channel get $channel antikicked] + 1]\)"
  172.     }
  173.     channel set $channel antikicked "[expr [channel get $channel antikicked] + 1]"
  174.     utimer 3 [list flushmode $channel]
  175.   }
  176. }
  177.  
  178. proc proxy::open {channel modes} {
  179.  if {[info exists ::close($channel)]} {
  180.   putserv "MODE $channel -$modes"
  181.   unset ::close($channel)
  182.  } else {
  183.   return 0
  184.  }
  185. }
  186.  
  187. proc proxy::modes {channel} {
  188.  variable modes
  189.  set end ""
  190.  set chanmode [lindex [getchanmode $channel] 0]
  191.  foreach mode [split $modes ""] {
  192.   if {![string match *$mode* $chanmode]} {
  193.   append end $mode
  194.   }
  195.  }
  196.  return "[join $end]"
  197. }
  198.  
  199. proc proxy::unsetflood {channel} {
  200.  if {[info exists ::flood($channel)]} {
  201.   unset ::flood($channel)
  202.  }
  203. }
  204.  
  205. proc proxy::statistics {channel} {
  206.  set joins    [channel get $channel antijoins]
  207.  set detected [channel get $channel antidetected]
  208.  set kicked  [channel get $channel antikicked]
  209.  if {$joins == "" || $joins == "0"} {
  210.   return "Statistic Unavailable"
  211.  } elseif {$detected == "" || $detected == "0"} {
  212.   return "Statistic Unavailable"
  213.  } elseif {$kicked == "" || $kicked == "0"} {
  214.   return "Statistic Unavailable"
  215.  } else {
  216.   return "Scanned: $joins, Detected: $detected, Kicked: $kicked  \[[format %.2f [expr ($kicked * 100.0) / $joins]]%\]"
  217.  }
  218. }
  219.  
  220. proc proxy::checkstats {channel} {
  221. # /* This is set to 1 to prevent the bot from crashing. (for some people this appears to be a problem) */
  222.  if {[channel get $channel antijoins] == ""} { channel set $channel antijoins "1" }
  223.  if {[channel get $channel antidetected] == ""} { channel set $channel antidetected "1" }
  224.  if {[channel get $channel antikicked] == ""} { channel set $channel antikicked "1" }
  225. }
  226.  
  227. proc proxy::floodjoin {channel} {
  228.  variable flood
  229.  set split [split $flood :]
  230.  set user [lindex $split 0]
  231.  set seconds [lindex $split 1]
  232.  if {![info exists ::flood($channel)]} {
  233.   set ::flood($channel) 1
  234.  } else {
  235.   incr ::flood($channel)
  236.  }
  237.   if {$::flood($channel) >= $user} {
  238.   set ::flood($channel) 0
  239.   return 1
  240.   } else {
  241.     utimer $seconds [list [namespace current]::unsetflood $channel]
  242.   }
  243.   return 0
  244. }
  245.  
  246. proc proxy::credits {} {
  247.   variable file [lindex [split [info script] "/"] end];
  248.   variable version;
  249.   variable owner "metroid (#development)";
  250.   variable modified [clock format [file mtime [info script]] -format "%Y/%m/%d %H:%M:%S"];
  251.   set channels 0; set total 0; set end ""
  252.   foreach chan [channels] {;
  253.   checkstats $chan
  254.   incr total
  255.   if {[channel get $chan antiproxy]} { incr channels ; lappend end $chan }
  256.   };
  257.  putlog "$file v$version by $owner - Last modified: $modified"
  258.  putlog "$file active on $channels/$total ([format %.2f [expr ($channels.0 * 100.0) / $total.0]]%) channels: [join $end ", "]"
  259.  putlog "$file was successfully loaded!"
  260. }
  261.  
  262. #proxy::credits
  263.  
  264. # // Copyright: This script was made by metroid (#development). This means, YOU DIDNT MAKE IT! I DID! :p
  265. # // Don't break my copyright because it's lame and i'll sue you ass if you do. Have fun!
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283. ------------------
  284. Botnet Bot join the channel and he will kicked the Bot "tackle" is a spambot
  285. -------------------
  286.  
  287. [20:43] * bIoS (~bios@2a03:e2c0:c9c:0:0:0:0:3) Quit (Connection timed out)
  288. [20:44] * bIoS (bios@2a03:e2c0:c9c:0:0:0:0:3) has joined #phoenix-shells
  289. [20:44] * BB-8 sets mode: +o bIoS
  290. [20:44] * WC sets mode: +o bIoS
  291. [20:44] * DummEr sets mode: +o bIoS
  292. [20:44] * HanSolo sets mode: +o bIoS
  293. [20:44] * DummEr sets mode: +b *!*@2a03:e2c0:c9c:0:0:0:0:3
  294. [20:44] * WC sets mode: -b *!*@2a03:e2c0:c9c:0:0:0:0:3
  295. [20:44] * Portrait2 sets mode: -b *!*@2a03:e2c0:c9c:0:0:0:0:3
  296. [20:44] * KES sets mode: -b *!*@2a03:e2c0:c9c:0:0:0:0:3
  297. [20:44] * Windu sets mode: -b *!*@2a03:e2c0:c9c:0:0:0:0:3
  298. [20:44] * BB-8 sets mode: -b *!*@2a03:e2c0:c9c:0:0:0:0:3
  299. [20:44] * HanSolo sets mode: -b *!*@2a03:e2c0:c9c:0:0:0:0:3
  300. [20:44] * bIoS was kicked by DummEr (<2a03:e2c0:c9c:0:0:0:0:3> is in the DNSBL [dnsbl.tornevall.org]] (ID: 2))
  301. [20:45] <tuvok> oh man
  302. [20:45] * bIoS (bios@2a03:e2c0:c9c:0:0:0:0:3) has joined #phoenix-shells
  303. [20:45] * HanSolo sets mode: +o bIoS
  304. [20:45] * Portrait2 sets mode: +o bIoS
  305. [20:45] <tuvok> nich schon wieder
  306. [20:45] * DummEr sets mode: +b *!*@2a03:e2c0:c9c:0:0:0:0:3
  307. [20:45] * BB-8 sets mode: -b *!*@2a03:e2c0:c9c:0:0:0:0:3
  308. [20:45] * KES sets mode: -b *!*@2a03:e2c0:c9c:0:0:0:0:3
  309. [20:45] * WC sets mode: -b *!*@2a03:e2c0:c9c:0:0:0:0:3
  310. [20:45] * HanSolo sets mode: -b *!*@2a03:e2c0:c9c:0:0:0:0:3
  311. [20:45] * Windu sets mode: -b *!*@2a03:e2c0:c9c:0:0:0:0:3
  312. [20:45] * Portrait2 sets mode: -b *!*@2a03:e2c0:c9c:0:0:0:0:3
  313. [20:45] * DummEr sets mode: +o bIoS
  314. [20:45] * bIoS was kicked by DummEr (<2a03:e2c0:c9c:0:0:0:0:3> is in the DNSBL [zen.spamhaus.org]] (ID: 3))
  315. [20:45] * tackle (~bottom@91.205.72.103) has joined #phoenix-shells
  316. [20:45] * DummEr sets mode: +b *!*@91.205.72.103
  317. [20:45] * tackle was kicked by DummEr (<91.205.72.103> is in the DNSBL [dnsbl.dronebl.org]] (ID: 4))
  318. [20:45] * bIoS (bios@2a03:e2c0:c9c:0:0:0:0:3) has joined #phoenix-shells
  319. [20:45] * DummEr sets mode: +o bIoS
  320. [20:45] * BB-8 sets mode: +o bIoS
  321. [20:45] * WC sets mode: +o bIoS
  322. [20:45] * DummEr (doof@2a01:4f8:231:482b:0:0:0:2) Quit (EOF From client)
Add Comment
Please, Sign In to add comment