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