proxycheck.tcl 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # open proxy checker for eggdrop
  2. # (c) James Seward 2003-6
  3. # version 1.12
  4. # http://www.jamesoff.net/site/projects/eggdrop-scripts/proxycheck
  5. # james@jamesoff.net
  6. # Released under the GPL
  7. ## INSTRUCTIONS
  8. ###############################################################################
  9. # This script will check the hosts of people joining channels against one or
  10. # RBLs. Choose your RBLs wisely, some of them list DIALUP SPACE and that would
  11. # be a bad thing to be matching your IRC users against :P
  12. #
  13. # Enable the 'proxycheck' flag for channels you want the script active on
  14. # --> .chanset #somechannel +proxycheck
  15. #
  16. # Users who are +o, +v, or +f in your bot (local or global) won't be checked.
  17. #
  18. # Turn on console level d on the partyline to see some debug from the script
  19. # --> .console +d (to enable)
  20. # --> .console -d (to disable)
  21. ## CONFIG
  22. ###############################################################################
  23. # space-separated list of RBLs to look in
  24. set proxycheck_rbls {
  25. "cbl.abuseat.org"
  26. "opm.blitzed.org"
  27. }
  28. # time in minutes to ban for
  29. set proxycheck_bantime 15
  30. # stop editing here unless you're TCL-proof
  31. ## CODE
  32. ###############################################################################
  33. #add our channel flag
  34. setudef flag proxycheck
  35. #bind our events
  36. bind join - *!*@* proxycheck_join
  37. #cache
  38. set proxycheck_lastip ""
  39. #swing your pants
  40. # catch joins
  41. proc proxycheck_join { nick host handle channel } {
  42. #check we're active
  43. if {![channel get $channel proxycheck]} {
  44. return 0
  45. }
  46. #don't apply to friends, voices, ops
  47. if {[matchattr $handle fov|fov $channel]} {
  48. return 0
  49. }
  50. #get the actual host
  51. regexp ".+@(.+)" $host matches newhost
  52. if [regexp {[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$} $newhost] {
  53. #it's a numeric host, skip the lookup
  54. proxycheck_check2 $newhost $newhost 1 $nick $newhost $channel
  55. } else {
  56. putloglev d * "proxycheck: doing dns lookup on $newhost to get IP"
  57. dnslookup $newhost proxycheck_check2 $nick $newhost $channel
  58. }
  59. }
  60. # first callback (runs RBL checks)
  61. proc proxycheck_check2 { ip host status nick orighost channel } {
  62. global proxycheck_rbls proxylookup_rbls
  63. if {$status == 1} {
  64. putloglev d * "proxycheck: $host resolves to $ip"
  65. # reverse the IP
  66. regexp {([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})} $ip matches a b c d
  67. set newip "$d.$c.$b.$a"
  68. # look it up in the rbls
  69. foreach rbl $proxycheck_rbls {
  70. putloglev d * "proxycheck: looking up $newip.$rbl"
  71. dnslookup "$newip.$rbl" proxycheck_check3 $nick $host $channel $rbl
  72. }
  73. } else {
  74. putlog "proxycheck: Couldn't resolve $host. (No further action taken.)"
  75. }
  76. }
  77. # second callback (catches RBL results)
  78. proc proxycheck_check3 { ip host status nick orighost channel rbl } {
  79. global proxycheck_bantime proxycheck_lastip
  80. if {$status} {
  81. if {$ip == $proxycheck_lastip} {
  82. putloglev d * "proxycheck: $host = $ip appears in RBL $ip, but I've already seen this one."
  83. return 0
  84. }
  85. set proxycheck_lastip $ip
  86. putloglev d * "proxycheck: got host $host = ip $ip from RBL $rbl ... banning"
  87. putlog "proxycheck: $nick ($orighost) is listed in $rbl ... banning from $channel"
  88. newchanban $channel "*@$orighost" "proxychk" "proxycheck: $rbl" $proxycheck_bantime
  89. }
  90. #if we didn't get a host, they're not in RBL
  91. }
  92. putlog "proxycheck 1.11 by JamesOff loaded (checking [llength $proxycheck_rbls] RBLs)"