Advertisement
Seb

TOR & DNSbl Script

Seb
May 7th, 2011
1,289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 29.16 KB | None | 0 0
  1. ; -------------------------------------
  2. ; ---          Tor-Be-Gone          ---
  3. ; --- By WTSh4rK @ irc.undernet.org ---
  4. ; ---         Version 1.1.1         ---
  5. ; -------------------------------------
  6. ;
  7. ; --- Change Log ---
  8. ;
  9. ; 20.02.2010:  The script no longer reads from the csv file, all IP addresses are stored in a hash table.
  10. ; 20.02.2010:  Update routine added, csv file can now be downloaded in mirc and added to hash more easily.
  11. ; 20.02.2010:  Old IP's are kept in the hash table for 2 weeks and will be removed if not updated, new IP's are added.
  12. ; 24.02.2010:  GUI Added
  13. ; 24.02.2010:  Now multi channel
  14. ; 24.02.2010:  Update now uses mirc socks to get ip list so no download of files are needed, 1 hour auto update added.
  15. ; 09.03.2010:  IP's are now kept for 2 days only due to the use of dynamic IP's (too many IP's in the hash)
  16. ; 26.03.2010:  Multi site updates added.
  17. ; 20.11.2010:  Added a que system, users are added to a scan que and scanned one at a time, no more timers.
  18. ; 20.11.2010:  Added DNS cache, no need to lookup addresses that have already been looked up now.
  19. ; 22.11.2010:  dronebl.org DNSBL lookup added.
  20. ; 02.01.2011:  Added Global Ignore List
  21. ; 08.02.2011:  /who channel when addresses are not found in mirc IAL hidden, stops pnp whois window poping up.
  22. ; 08.02.2011:  Other bug fixes and tidy up.
  23. ; 10.03.2011:  Multi DNSBL lookup added.
  24. ;
  25. ; ------------------
  26.  
  27. on 1:START: {
  28.   unset %TBG*
  29.   set %tbg.ini $shortfn($mircdir $+ torips\) $+ tbg.ini
  30.   if (!$hget(tor.ips)) {
  31.     if (!$exists(torips)) { .mkdir torips }
  32.     if (!$exists(torips\tns_list.txt)) {
  33.       write torips\tns_list.txt torstat.xenobite.eu
  34.       write torips\tns_list.txt torstatus.all.de
  35.       write torips\tns_list.txt torstatus.asprion.org
  36.       write torips\tns_list.txt torstatus.blutmagie.de
  37.       write torips\tns_list.txt torstatus.cyberphunk.org
  38.       write torips\tns_list.txt torstatus.rueckgr.at
  39.     }
  40.     if (!$exists(torips\tor_ips.hash)) { .hmake tor.ips 1000 }
  41.     else { .hmake tor.ips 1000 | .hload -b tor.ips torips\tor_ips.hash }
  42.     If (!$window(@Tor-Be-Gone)) { window -k0nz @Tor-Be-Gone | .log on @Tor-Be-Gone -f Tor-Be-Gone.log }
  43.     echo 2 -st *** Tor-Be-Gone 1.1.1 By Skxawng (WTSh4rK @ irc.Undernet.org) http://spontan-you-us.net23.net 
  44.     echo 2 -st *** Loaded IP Address Hash, $hget(tor.ips,0).item IP's in Hash, Running Update...
  45.     .timertbgQ 0 0.5 do.tbgQ
  46.     tbgupdate
  47.   }
  48. }
  49.  
  50. on 1:DISCONNECT: {
  51.   If ($window(@tbgQ)) { window -c @tbgQ }
  52. }
  53.  
  54. on 1:JOIN:#: {
  55.   if (($nick != $me) && ($istok($readini(torips\tbg.ini,lists,chans),$chan,172))) { addto.tbgQ $nick $chan }
  56. }
  57.  
  58. on 1:OP:#: {
  59.   if (($opnick == $me) && ($istok($readini(torips\tbg.ini,lists,chans),$chan,172)) && ($readini(torips\tbg.ini,$chan,scan))) { tbgscan $chan }
  60. }
  61.  
  62. on 1:SERVEROP:#: {
  63.   if (($opnick == $me) && ($istok($readini(torips\tbg.ini,lists,chans),$chan,172)) && ($readini(torips\tbg.ini,$chan,scan))) { tbgscan $chan }
  64. }
  65.  
  66. alias addto.tbgQ {
  67.   if ($1 == $me) return
  68.   if (!%tbg.ini) set %tbg.ini $shortfn($mircdir $+ torips\) $+ tbg.ini
  69.   If (!$window(@tbgQ)) { window -h @tbgQ }
  70.   if (!$timer(tbgQ)) .timertbgQ 0 0.5 do.tbgQ
  71.   if (($1 == ¬StartScanChan) || ($1 == ¬FinishScanChan)) { aline @tbgQ $1 $2 $3 $4 $5 | return }
  72.   else aline @tbgQ $1 $2 ~ Waiting
  73.   if ($window(@TBG-Status)) aline @TBG-Status $timestamp Added $1 from $2 to the Scan Que...
  74. }
  75.  
  76. alias do.tbgQ {
  77.   if ($line(@tbgQ,0)) {
  78.     if ($gettok($line(@tbgQ,1),1,32) == ¬StartScanChan) {
  79.       echo 6 -t $gettok($line(@tbgQ,1),2,32) *** [TBG] Starting to scan $iif($gettok($line(@tbgQ,1),3,32),$gettok($line(@tbgQ,1),3,32),$gettok($line(@tbgQ,1),2,32)) for TOR $iif($readini(%tbg.ini,$gettok($line(@tbgQ,1),2,32),dnsbl),and DNSBL) please wait...
  80.       dline @tbgQ 1 | return
  81.     }
  82.     if ($gettok($line(@tbgQ,1),1,32) == ¬FinishScanChan) {
  83.       echo 6 -t $gettok($line(@tbgQ,1),2,32) *** [TBG] The TOR $iif($readini(%tbg.ini,$gettok($line(@tbgQ,1),2,32),dnsbl),and DNSBL) scan of $iif($gettok($line(@tbgQ,1),5,32),$gettok($line(@tbgQ,1),5,32),$gettok($line(@tbgQ,1),2,32)) has finished, Scanned $gettok($line(@tbgQ,1),3,32) users in $duration($calc($ctime - $gettok($line(@tbgQ,1),4,32)))
  84.       dline @tbgQ 1 | return
  85.     }
  86.     if (!$address($gettok($line(@tbgQ,1),1,32),5)) {
  87.       if ($chan($gettok($line(@tbgQ,1),2,32)).inwho) return
  88.       else {
  89.         .who $gettok($line(@tbgQ,1),2,32)
  90.         set %tbg.who $gettok($line(@tbgQ,1),2,32) %tbg.who
  91.       }
  92.     }
  93.     if ($gettok($line(@tbgQ,1),1,32) !ison $gettok($line(@tbgQ,1),2,32)) {
  94.       if ($window(@TBG-Status)) aline @TBG-Status $timestamp Removed $gettok($line(@tbgQ,1),1,32) from the Scan Que (not on channel)
  95.       dline @tbgQ 1 | .dns -c | return
  96.     }
  97.     if ($address($gettok($line(@tbgQ,1),1,32),5)) {
  98.       if ($gettok($line(@tbgQ,1),4,32) == Waiting) {
  99.         rline @tbgQ 1 $puttok($line(@tbgQ,1),Checking $ctime,4,32)
  100.         ;echo -s $line(@tbgQ,1)
  101.         inc %¬tbg.scans
  102.         if ($window(@TBG-Status)) aline @TBG-Status $timestamp Sending $gettok($line(@tbgQ,1),1,32) ( $+ $address($gettok($line(@tbgQ,1),1,32),5) $+ ) from $gettok($line(@tbgQ,1),2,32) for Check... [# $+ %¬tbg.scans $+ ]
  103.         torchk $gettok($line(@tbgQ,1),1,32) $gettok($line(@tbgQ,1),2,32)
  104.       }
  105.       if (($gettok($line(@tbgQ,1),4,32) == Checking) && ($calc($ctime - $gettok($line(@tbgQ,1),5,32)) > 10)) {
  106.         if ($window(@TBG-Status)) aline @TBG-Status $timestamp Removed $gettok($line(@tbgQ,1),1,32) from the Scan Que (timeout)
  107.         echo 2 -t @Tor-Be-Gone *** WARNING: Removed $gettok($line(@tbgQ,1),1,32) from the Scan Que (timeout)
  108.         dline @tbgQ 1 | .dns -c | return
  109.       }
  110.     }
  111.   }
  112. }
  113.  
  114. alias TBGmakeDNSBL {
  115.   ;$1 = IP address only
  116.   if ($remove($1,.) isnum) {
  117.     ; ************************ DNSBL Scan List ************************
  118.     ; ****** Add your rbl lists here with a space between each ********
  119.     ; *****************************************************************
  120.  
  121.     var %tbg.dnsbl_list = dnsbl.dronebl.org rbl.efnetrbl.org ircbl.ahbl.org dnsbl.swiftbl.org
  122.  
  123.     ; *****************************************************************
  124.     ; *****************************************************************
  125.     ; *****************************************************************
  126.     var %tbg.dnsbl_c = 1
  127.     while ($gettok(%tbg.dnsbl_list,%tbg.dnsbl_c,32)) {
  128.       if (%tbg.dnsbl) var %tbg.dnsbl = %tbg.dnsbl $+ ¬ $+ $gettok($1,4,46) $+ . $+ $gettok($1,3,46) $+ . $+ $gettok($1,2,46) $+ . $+ $gettok($1,1,46) $+ . $+ $gettok(%tbg.dnsbl_list,%tbg.dnsbl_c,32)
  129.       else var %tbg.dnsbl = $gettok($1,4,46) $+ . $+ $gettok($1,3,46) $+ . $+ $gettok($1,2,46) $+ . $+ $gettok($1,1,46) $+ . $+ $gettok(%tbg.dnsbl_list,%tbg.dnsbl_c,32)
  130.       ;if ($window(@TBG-Status)) aline @TBG-Status $timestamp DNSBL Sent > $gettok($1,4,46) $+ . $+ $gettok($1,3,46) $+ . $+ $gettok($1,2,46) $+ . $+ $gettok($1,1,46) $+ . $+ $gettok(%tbg.dnsbl_list,%tbg.dnsbl_c,32)
  131.       .dns $gettok($1,4,46) $+ . $+ $gettok($1,3,46) $+ . $+ $gettok($1,2,46) $+ . $+ $gettok($1,1,46) $+ . $+ $gettok(%tbg.dnsbl_list,%tbg.dnsbl_c,32)
  132.       inc %tbg.dnsbl_c
  133.     }
  134.     return %tbg.dnsbl
  135.   }
  136.   else { echo -ts [TBG makeDNSBL Error] IP Address ONLY! | halt }
  137. }
  138.  
  139. alias torchk {
  140.   ;$1 = nick $2 = chan
  141.   if (($1 == $null) || ($2 == $null)) {
  142.     echo -t torchk error: incorrect argument
  143.     halt
  144.   }
  145.   if (!$timer(TBG.update)) { .timerTBG.update 0 3600 TBGupdate }
  146.   if (!$hget(tor.ips)) {
  147.     if (!$exists(torips\tor_ips.hash)) { hmake -s tor.ips 1000 }
  148.     else { .hmake -s tor.ips 1000 | .hload -bs tor.ips torips\tor_ips.hash }
  149.   }
  150.   if (!$hget(tbg_dns_cache)) {
  151.     hmake tbg_dns_cache 1000
  152.     if ($exists(torips\tbg_dns_cache.hash)) { hload tbg_dns_cache torips\tbg_dns_cache.hash }
  153.   }
  154.   if ($1 !ison $2) { dline @tbgQ 1 | halt }
  155.   set %tbg.ignore 1
  156.   var %tbg.ignore.list = $readini(%tbg.ini,lists,ignore)
  157.   while ($gettok(%tbg.ignore.list,%tbg.ignore,172)) {
  158.     if ($gettok(%tbg.ignore.list,%tbg.ignore,172) iswm $address($1,5)) {
  159.       dline @tbgQ 1
  160.       if ($window(@TBG-Status)) aline 3 @TBG-Status $timestamp On Ignore List, Removed $1 from the Tor Scan Que
  161.       halt
  162.     }
  163.     inc %tbg.ignore
  164.   }
  165.   if (($address($1,4) == *!*@*.users.undernet.org) || ($1 == X)) { dline @tbgQ 1 | if ($window(@TBG-Status)) aline 3 @TBG-Status $timestamp Undernet User... Removed $1 from the Tor Scan Que | halt }
  166.   if (($hget(tbg_dns_cache)) && ($hfind(tbg_dns_cache,$gettok($address($1,2),2,64)))) {
  167.     var %toraddress = $gettok($hget(tbg_dns_cache,$gettok($address($1,2),2,64)),1,32))
  168.     if ($window(@TBG-Status)) aline 7 @TBG-Status $timestamp $1 Address found $gettok($hget(tbg_dns_cache,$gettok($address($1,2),2,64)),1,32)) in DNS cache...
  169.   }
  170.   else { var %toraddress = $gettok($address($1,2),2,64) }
  171.   If (!$window(@Tor-Be-Gone)) { window -k0nz @Tor-Be-Gone | .log on @Tor-Be-Gone -f Tor-Be-Gone.log }
  172.   if ($remove(%toraddress,.) isnum) {
  173.     hadd -m torchk %toraddress $1 $+ ¬ $+ $2
  174.     if ($hfind(tor.ips,%toraddress,1)) {
  175.       set %tbg.type 1
  176.       kicktor $1 $2 %toraddress
  177.       hdel torchk %toraddress
  178.       if ($window(@TBG-Status)) aline 4 @TBG-Status $timestamp Tor Address found: ( $+ $1 $+ ) %toraddress in $2 
  179.       dline @tbgQ 1
  180.       if ($window(@TBG-Status)) aline @TBG-Status $timestamp Removed $1 from the Tor Scan Que
  181.       halt
  182.     }
  183.     else {
  184.       hdel torchk %toraddress
  185.       if ($window(@TBG-Status)) aline 3 @TBG-Status $timestamp Not a Tor address ( $+ $1 $+ ) %toraddress in $2
  186.       if (!$readini(%tbg.ini,$2,dnsbl)) {
  187.         if ($window(@TBG-Status)) aline @TBG-Status $timestamp Removed $gettok($line(@tbgQ,1),1,32) from the Tor Scan Que
  188.         dline @tbgQ 1
  189.         halt
  190.       }
  191.       if (!$hget(TBG_DNSBL,$address($gettok($line(@tbgQ,1),1,32),2))) {
  192.         rline @tbgQ 1 $addtok($line(@tbgQ,1),$TBGmakeDNSBL(%toraddress),32)
  193.         if ($window(@TBG-Status)) aline @TBG-Status $timestamp Sending $1 for DNSBL lookup...
  194.         halt
  195.       }
  196.       if ($gettok($hget(TBG_DNSBL,$address($gettok($line(@tbgQ,1),1,32),2)),1,32) == good) {
  197.         if ($window(@TBG-Status)) aline 3 @TBG-Status $timestamp $gettok($line(@tbgQ,1),1,32) not listed in DNSBL... (cached)
  198.         if ($window(@TBG-Status)) aline @TBG-Status $timestamp Removed $gettok($line(@tbgQ,1),1,32) from the Tor Scan Que
  199.         dline @tbgQ 1
  200.         halt
  201.       }
  202.       if ($gettok($hget(TBG_DNSBL,$address($gettok($line(@tbgQ,1),1,32),2)),1,32) == bad) {
  203.         if ($window(@TBG-Status)) aline 4 @TBG-Status $timestamp $gettok($line(@tbgQ,1),1,32) from $gettok($line(@tbgQ,1),2,32) listed in DNSBL (cached)
  204.         set %tbg.type 0
  205.         kicktor $gettok($line(@tbgQ,1),1,32) $gettok($line(@tbgQ,1),2,32) %toraddress [DNSBL] Your host is listed in a DNSBL
  206.         if ($window(@TBG-Status)) aline @TBG-Status $timestamp Removed $gettok($line(@tbgQ,1),1,32) from the Tor Scan Que
  207.         dline @tbgQ 1
  208.         halt
  209.       }
  210.     }
  211.   }
  212.   if (!$hget(torchk).size) hmake torchk 100  
  213.   hadd -m torchk %toraddress $1 $+ ¬ $+ $2
  214.   .dns %toraddress
  215.   if ($window(@TBG-Status)) aline 7 @TBG-Status $timestamp $1 sent for DNS Lookup...
  216. }
  217.  
  218. on 1:dns: {
  219.   if (($line(@tbgQ,0)) && ($dns(0).addr == $gettok($address($gettok($line(@tbgQ,1),1,32),2),2,64))) {
  220.     if (!$dns(1).ip) {
  221.       echo -t @Tor-Be-Gone DNS Error: Could not look up IP for ( $+ $gettok($hget(torchk,$dns(0).addr),1,172) $+ ) $dns(0).addr in $gettok($hget(torchk,$dns(0).addr),2,172)
  222.       echo 7 -t $gettok($hget(torchk,$dns(0).addr),2,172) *** DNS Error: Could not look up IP for ( $+ $gettok($hget(torchk,$dns(0).addr),1,172) $+ ) $dns(0).addr in $gettok($hget(torchk,$dns(0).addr),2,172)
  223.       if ($window(@TBG-Status)) aline 12 @TBG-Status $timestamp DNS Error: Could not look up IP for ( $+ $gettok($hget(torchk,$dns(0).addr),1,172) $+ ) $dns(0).addr in $gettok($hget(torchk,$dns(0).addr),2,172)
  224.       hdel torchk $dns(0).addr
  225.       dline @tbgQ 1
  226.       if ($window(@TBG-Status)) aline @TBG-Status $timestamp Removed $gettok($hget(torchk,$dns(1).addr),1,172) from the Tor Scan Que
  227.       halt
  228.     }
  229.     if (!$hget(tbg_dns_cache)) {
  230.       hmake tbg_dns_cache 1000
  231.       if ($exists(torips\tbg_dns_cache.hash)) { hload tbg_dns_cache torips\tbg_dns_cache.hash }
  232.     }
  233.     hadd tbg_dns_cache $dns(1).addr $dns(1).ip $ctime
  234.     hsave -o tbg_dns_cache torips\tbg_dns_cache.hash
  235.     if ($window(@TBG-Status)) aline @TBG-Status $timestamp Adding $dns(1).addr $dns(1).ip to DNS cache...
  236.     if (($hfind(tor.ips,$dns(1).ip,1)) && ($gettok($hget(torchk,$dns(1).addr),1,172))) {
  237.       if ($window(@TBG-Status)) aline 4 @TBG-Status $timestamp Tor Address found: ( $+ $gettok($hget(torchk,$dns(1).addr),1,172) $+ ) $dns(1).addr ( $+ $dns(1).ip $+ )
  238.       set %tbg.type 1
  239.       kicktor $gettok($hget(torchk,$dns(1).addr),1,172) $gettok($hget(torchk,$dns(1).addr),2,172) $dns(1).ip
  240.       if ($window(@TBG-Status)) aline 4 @TBG-Status $timestamp Kicking and Banning $gettok($hget(torchk,$dns(1).addr),1,172) $gettok($hget(torchk,$dns(1).addr),2,172) $dns(1).ip
  241.       hdel torchk $dns(1)
  242.       dline @tbgQ 1
  243.       if ($window(@TBG-Status)) aline @TBG-Status $timestamp Removed $gettok($hget(torchk,$dns(1).addr),1,172) from the Tor Scan Que
  244.     }
  245.     else {
  246.       if ($window(@TBG-Status)) aline 3 @TBG-Status $timestamp Not a Tor address ( $+ $gettok($hget(torchk,$dns(1).addr),1,172) $+ ) $dns(1).addr ( $+ $dns(1).ip $+ )
  247.       hdel torchk $dns(0).addr
  248.       if (!$readini(%tbg.ini,$gettok($line(@tbgQ,1),2,32),dnsbl)) {
  249.         dline @tbgQ 1
  250.         halt
  251.       }
  252.       if (!$hget(TBG_DNSBL,$address($gettok($line(@tbgQ,1),1,32),2))) {
  253.         rline @tbgQ 1 $addtok($line(@tbgQ,1),$TBGmakeDNSBL($dns(1).ip),32)
  254.         if ($window(@TBG-Status)) aline @TBG-Status $timestamp Sending $gettok($line(@tbgQ,1),1,32) for DNSBL lookup...
  255.         halt
  256.       }
  257.       if ($gettok($hget(TBG_DNSBL,$address($gettok($line(@tbgQ,1),1,32),2)),1,32) == good) {
  258.         if ($window(@TBG-Status)) aline 3 @TBG-Status $timestamp $gettok($line(@tbgQ,1),1,32) not listed in DNSBL... (cached)
  259.         if ($window(@TBG-Status)) aline @TBG-Status $timestamp Removed $gettok($line(@tbgQ,1),1,32) from the Tor Scan Que
  260.         dline @tbgQ 1
  261.         halt
  262.       }
  263.       if ($gettok($hget(TBG_DNSBL,$address($gettok($line(@tbgQ,1),1,32),2)),1,32) == bad) {
  264.         if ($window(@TBG-Status)) aline 4 @TBG-Status $timestamp Listed in DNSBL, Kicking and Banning $gettok($line(@tbgQ,1),1,32) from $gettok($line(@tbgQ,1),2,32) (cached)
  265.         set %tbg.type 0
  266.         kicktor $gettok($line(@tbgQ,1),1,32) $gettok($line(@tbgQ,1),2,32) $dns(1).ip) [DNSBL] Your host is listed in a DNSBL ( $+ $dns(0).addr $+ )
  267.         if ($window(@TBG-Status)) aline @TBG-Status $timestamp Removed $gettok($line(@tbgQ,1),1,32) from the Tor Scan Que
  268.         dline @tbgQ 1
  269.         halt
  270.       }
  271.     }
  272.   }
  273.   var %tbg.qdnsbl = $gettok($line(@tbgQ,1),6,32)
  274.   if (($line(@tbgQ,0)) && ($dns(0).addr isin %tbg.qdnsbl)) {
  275.     if (!$dns(1).ip) {
  276.       if ($window(@TBG-Status)) aline 3 @TBG-Status $timestamp $gettok($line(@tbgQ,1),1,32) not listed in DNSBL... ( $+ $dns(0).addr $+ )
  277.       if ($hget(TBG_DNSBL,$address($gettok($line(@tbgQ,1),1,32),2)) != bad) .hadd -mn1800 TBG_DNSBL $address($gettok($line(@tbgQ,1),1,32),2) good $ctime
  278.       var %tbg.qdnsbl = $remtok(%tbg.qdnsbl,$dns(0).addr,1,172)
  279.       if (%tbg.qdnsbl) rline @tbgQ 1 $puttok($line(@tbgQ,1),%tbg.qdnsbl,6,32)
  280.       if (!%tbg.qdnsbl) {
  281.         if ($window(@TBG-Status)) aline @TBG-Status $timestamp Removed $gettok($line(@tbgQ,1),1,32) from the Tor Scan Que
  282.         dline @tbgQ 1
  283.       }
  284.     }
  285.     else {
  286.       if ($window(@TBG-Status)) aline 4 @TBG-Status $timestamp $gettok($line(@tbgQ,1),1,32) from $gettok($line(@tbgQ,1),2,32) listed in DNSBL! ( $+ $dns(0).addr $+ )
  287.       set %tbg.type 0
  288.       kicktor $gettok($line(@tbgQ,1),1,32) $gettok($line(@tbgQ,1),2,32) $dns(0).addr [DNSBL] Your host is listed in a DNSBL ( $+ $dns(0).addr $+ )
  289.       .hadd -mn1800 TBG_DNSBL $address($gettok($line(@tbgQ,1),1,32),2) bad
  290.       if ($window(@TBG-Status)) aline @TBG-Status $timestamp Removed $gettok($line(@tbgQ,1),1,32) from the Tor Scan Que
  291.       dline @tbgQ 1
  292.     }
  293.   }
  294. }
  295.  
  296. alias kicktor {
  297.   ;$1 = Nick $2 = chan $3 = IP [$4- = Alt Kick Msg Over Ride]
  298.   var %tbg.cc = 1
  299.   var %tbg.chan.list = $readini(torips\tbg.ini,lists,chans)
  300.   If (!$window(@Tor-Be-Gone)) { window -k0nzg1 @Tor-Be-Gone | .log on @Tor-Be-Gone -f Tor-Be-Gone.log }
  301.   else window -g1 @Tor-Be-Gone
  302.   echo 4 -t @Tor-Be-Gone *** $iif(%tbg.type,Tor Address:,DNSBL Address:) $address($1,5) ( $+ $3 $+ ) found in $2 
  303.   echo 4 -t $2 *** [# $+ %¬tbg.scans $+ ] $iif(%tbg.type,Tor Address:,DNSBL Address:) $address($1,5) ( $+ $3 $+ ) found in $2 
  304.   while ($chan(%tbg.cc)) {
  305.     if ($istok(%tbg.chan.list,$chan(%tbg.cc),172)) {
  306.       if ((!%tbg.type) && (!$readini(torips\tbg.ini,$chan(%tbg.cc),dnsbl))) { goto tbgbypass }
  307.       if ($4-) { set %tbg.kick.msg [TBG $asctime(d mmm yyyy) $+ ] $4- }
  308.       else { set %tbg.kick.msg [TBG $asctime(d mmm yyyy) $+ ] [TOR] $replace($readini(torips\tbg.ini,$chan(%tbg.cc),banmsg),[ip],$3,[addr],$address($1,2),[chan],$chan(%tbg.cc),[nick],$1) }
  309.       if ($me isop $chan(%tbg.cc)) {
  310.         if ($1 ison $chan(%tbg.cc)) {
  311.           if (($network == undernet) && (r !isincs $chan($chan(%tbg.cc)).mode)) { var %tbg.mode = +rb | .timer 1 60 mode $chan(%tbg.cc) -r }
  312.           else var %tbg.mode = +b
  313.           raw -q mode $chan(%tbg.cc) %tbg.mode $address($1,2) $+ $crlf $+ kick $chan(%tbg.cc) $1 : %tbg.kick.msg
  314.           If (!$window(@Tor-Be-Gone)) { window -k0nzg1 @Tor-Be-Gone | .log on @Tor-Be-Gone -f Tor-Be-Gone.log }
  315.           else window -g1 @Tor-Be-Gone
  316.           echo 4 -t @Tor-Be-Gone *** $iif(%tbg.type,TOR Address:,DNSBL Address:) $address($1,5) ( $+ $3 $+ ) was kicked and banned from $chan(%tbg.cc) ( $+ %tbg.kick.msg $+ ) 
  317.         }
  318.         if (($readini(torips\tbg.ini,$chan(%tbg.cc),x)) && (X ison $chan(%tbg.cc)) && ($chan(%tbg.cc) == $2)) {
  319.           .msg X ban $chan(%tbg.cc) $address($1,2) $readini(torips\tbg.ini,$chan(%tbg.cc),xdays) $+ d 75 $left(%tbg.kick.msg,124) $+ $iif($len(%tbg.kick.msg) > 124,...)
  320.         }
  321.       }
  322.       if ($me !isop $chan(%tbg.cc)) {
  323.         if (($readini(torips\tbg.ini,$chan(%tbg.cc),x)) && (X ison $chan(%tbg.cc)) && ($chan(%tbg.cc) == $2)) {
  324.           .msg X ban $chan(%tbg.cc) $address($1,2) $readini(torips\tbg.ini,$chan(%tbg.cc),xdays) $+ d 75 $left(%tbg.kick.msg,124) $+ $iif($len(%tbg.kick.msg) > 124,...)
  325.         }
  326.       }
  327.     }
  328.     :tbgbypass
  329.     inc %tbg.cc
  330.   }
  331. }
  332.  
  333. alias tbgscan {
  334.   if ((!$chan) && ($1)) { var %tbgscan = $1 }
  335.   elseif ($chan) { var %tbgscan $chan }
  336.   else { echo 4 -at TBGScan: Need to know what channel you want to scan. | halt }
  337.   set %tbgscan.count 1
  338.   var %tbg.scantime = $ctime
  339.   addto.tbgQ ¬StartScanChan %tbgscan
  340.   while ($nick(%tbgscan,%tbgscan.count,rv)) {
  341.     addto.tbgQ $nick(%tbgscan,%tbgscan.count,rv) %tbgscan
  342.     inc %tbgscan.count
  343.   }
  344.   addto.tbgQ ¬FinishScanChan %tbgscan %tbgscan.count %tbg.scantime
  345.   unset %tbgscan.count
  346. }
  347.  
  348. alias TBGupdate {
  349.   if (!$exists(torips\tns_list.txt)) { echo 4 -st *** TBGupdate Error: $mircdir $+ torips\tns_list.txt is missing | halt }
  350.   if (!$1) { set %TBG.site $read(torips\tns_list.txt) }
  351.   else { set %TBG.site $1 }
  352.   if (!$hget(tor.ips)) {
  353.     if (!$exists(torips)) { .mkdir torips }
  354.     if (!$exists(torips\tor_ips.hash)) { .hmake tor.ips 1000 }
  355.     else { .hmake tor.ips 1000 | .hload -b tor.ips torips\tor_ips.hash }
  356.   }
  357.   if (!%TBG.site) { TBGupdate | halt }
  358.   set %TBG.b4 $hget(tor.ips,0).item
  359.   if (!$sock(TBG)) { sockopen TBG %TBG.site 80 }
  360. }
  361.  
  362.  
  363. on *:sockread:TBG:{
  364.   if (!%TBG_csv.bytes) { set %TBG_csv.bytes 0 }
  365.   var %stext
  366.   sockread %stext
  367.   if (($remove(%stext,.) isnum) && ($numtok(%stext,46) == 4)) { hadd tor.ips %stext $ctime }
  368.   set %TBG_csv.bytes $calc(%TBG_csv.bytes + $sockbr)
  369. }
  370.  
  371. on *:sockopen:TBG:{
  372.   if ($sockerr) {
  373.     sockclose $sockname
  374.     echo 2 -t @Tor-Be-Gone ---
  375.     echo 2 -t @Tor-Be-Gone *** Tor-Be-Gone: Err there was some error connecting to %TBG.site
  376.     tbgupdate
  377.   }
  378.   else {
  379.     echo 2 -t @Tor-Be-Gone ---
  380.     echo 2 -t @Tor-Be-Gone *** Connected to %TBG.site $+ , Downloading update IP list...
  381.     sockwrite -n $sockname GET /ip_list_all.php/Tor_ip_list_ALL.csv HTTP/1.1
  382.     sockwrite -n $sockname Host: %TBG.site $+ $crlf $+ $crlf
  383.   }
  384. }
  385.  
  386. on *:sockclose:TBG: {
  387.   set %TBG_csv 1  
  388.   set %TBG_csv.remove 0
  389.   while ($hget(tor.ips,%TBG_csv).item) {
  390.     if ($calc($ctime - $hget(tor.ips,%TBG_csv).data) > 86400) { hdel tor.ips $hget(tor.ips,%TBG_csv).item | inc %TBG_csv.remove }
  391.     inc %TBG_csv
  392.   }
  393.   hsave -bo tor.ips torips\tor_ips.hash
  394.   If (!$window(@Tor-Be-Gone)) { window -k0nz @Tor-Be-Gone | .log on @Tor-Be-Gone -f Tor-Be-Gone.log }
  395.   echo 2 -t @Tor-Be-Gone *** IP's Added:3 $calc($hget(tor.ips,0).item - %TBG.b4 + %TBG_csv.remove) $+ , Removed:4 %TBG_csv.remove $+ , Now in Hash:3 $hget(tor.ips,0).item 15( $+ $bytes(%TBG_csv.bytes,k) $+ kb dl from %TBG.site $+ )
  396.   unset %TBG.b4 | unset %TBG_csv* | unset %TBG.site
  397.   tbg_cleandns
  398. }
  399.  
  400. alias tbg_cleandns {
  401.   set %TBG_csv1 1
  402.   set %TBG_csv.remove 0
  403.   while ($hget(tbg_dns_cache,%TBG_csv1).item) {
  404.     if ($calc($ctime - $gettok($hget(tbg_dns_cache,%TBG_csv1).data,2,32)) > 172800) { hdel tbg_dns_cache $hget(tbg_dns_cache,%TBG_csv1).item | inc %TBG_csv.remove }
  405.     inc %TBG_csv1
  406.   }
  407.   echo 2 -t @Tor-Be-Gone *** Addresses Removed from DNS cache:4 %TBG_csv.remove 
  408.   set %TBG_csv1 1
  409.   set %TBG_csv.remove 0
  410.   while ($hget(TBG_DNSBL,%TBG_csv1).item) {
  411.     if (($gettok($hget(TBG_DNSBL,%TBG_csv1).data,1,32) == good) && ($calc($ctime - $gettok($hget(TBG_DNSBL,%TBG_csv1).data,2,32)) > 7200)) { hdel TBG_DNSBL $hget(TBG_DNSBL,%TBG_csv1).item | inc %TBG_csv.remove }
  412.     if (($gettok($hget(TBG_DNSBL,%TBG_csv1).data,1,32) == bad) && ($calc($ctime - $gettok($hget(TBG_DNSBL,%TBG_csv1).data,2,32)) > 172800)) { hdel TBG_DNSBL $hget(TBG_DNSBL,%TBG_csv1).item | inc %TBG_csv.remove }
  413.     inc %TBG_csv1
  414.   }
  415.   echo 2 -t @Tor-Be-Gone *** Addresses Removed from DNSBL cache:4 %TBG_csv.remove 
  416.   unset %TBG_csv*
  417. }
  418.  
  419. dialog tbg {
  420.   title "TBG+DNSBL 1.1.1 Settings"
  421.   size -1 -1 300 120
  422.   option dbu
  423.  
  424.   button "Okay",1,200 107 25 11,ok
  425.   button "Discard",2,270 107 25 11,cancel
  426.   button "Apply",5,235 107 25 11
  427.   text "TBG+DNSBL 1.1.1 By Skxawng (Undernet User: WTSh4rK)",3,5 105 80 13
  428.   button "Update IP List",4,90 107 40 11
  429.  
  430.   box "Channel:",10,5 3 190 20
  431.   text "Settings for:",11,10 11 40 10
  432.   combo 12,45 9 80 10,drop edit
  433.   button "Add",13,133 9 25 11
  434.   button "Remove",14,165 9 25 11
  435.  
  436.   box "Settings:",20,5 25 190 80
  437.   text "Use [nick] [chan] [ip] [addr] to get nick, channel, IP and address in your kick.",21,8 33 185 10
  438.   text "Ban Messsage:",22,8 44 45 12
  439.   combo 23,47 42 145 10,drop edit
  440.   check "Scan channel when you OP to check for Tor IP's already in channel?",24,8 55 180 10
  441.   check "Use X to Kick and Ban Tor Addresses for",25,8 70 110 10
  442.   combo 26,118 70 30 10, drop
  443.   text "days.",27,155 71 30 10
  444.   check "Send users for DNSBL lookup?",28,8 85 110 10
  445.  
  446.   box "Addresses to ignore (Global)",30,200 3 95 102
  447.   text "",31,205 12 85 70, edit vsbar
  448.   combo 32,205 22 85 70, edit vsbar
  449.   button "Add",33,220 90 25 11
  450.   button "Remove",34,252 90 25 11
  451. }
  452.  
  453. on 1:dialog:tbg:init:0: {
  454.   ;echo - %tbg.ini
  455.   did -o tbg 31 1 $iif($len(e.g. $address($me,8)) >= 30,$left(e.g. $address($me,8),30) $+ ...,e.g. $address($me,8))
  456.   if (!$exists($shortfn($mircdir $+ torips\) $+ tbg.ini)) { mkdir torips | writeini $shortfn($mircdir $+ torips\) $+ tbg.ini lists banmsg [nick], Anonymity online is great just not here... BANNED: [ip] ([addr])¬The Onion Router is Banned, Tor Exit Node IP: [ip] ([addr])¬BANNED: Tor Exit Node IP: [ip] ([addr]) | TBGupdate }
  457.   set %tbg.ini $shortfn($mircdir $+ torips\) $+ tbg.ini
  458.   didtok tbg 23 172 $readini(%tbg.ini,lists,banmsg)
  459.   did -c tbg 23 1
  460.   didtok tbg 12 172 $readini(%tbg.ini,lists,chans)
  461.   didtok tbg 32 172 $readini(%tbg.ini,lists,ignore)
  462.   var %tbg.xdays = 1
  463.   while (%tbg.xdays < 101) {
  464.     did -a tbg 26 %tbg.xdays
  465.     if (%tbg.xdays = 1) did -c tbg 26 1
  466.     inc %tbg.xdays
  467.   }
  468.   did -b tbg 14,23,24,25,26,33,34
  469.  
  470.   if ($didwm(tbg,12,$active)) {
  471.     set %tbg.chan $didwm(tbg,12,$active)
  472.     did -c tbg 12 $didwm(tbg,12,$active)
  473.     did -e tbg 14,23,24,25,26
  474.     did -b tbg 13
  475.     if ($readini(%tbg.ini,$active,banmsg)) { did -ac tbg 23 $readini(%tbg.ini,$active,banmsg) }
  476.     if ($readini(%tbg.ini,$active,scan)) { did -c tbg 24 }
  477.     if ($readini(%tbg.ini,$active,x)) { did -c tbg 25 }
  478.     if ($readini(%tbg.ini,$active,xdays)) { did -c tbg 26 $readini(%tbg.ini,$active,xdays) }
  479.     if ($readini(%tbg.ini,$active,dnsbl)) { did -c tbg 28 }
  480.   }
  481.   else { did -o tbg 12 0 $active | set %tbg.chan $didwm(tbg,12,$active) }
  482. }
  483.  
  484. on 1:dialog:tbg:sclick:*: {
  485.   if (($did == 1) || ($did == 5)) {
  486.     writeini %tbg.ini lists chans $didtok(tbg,12,172)
  487.     writeini %tbg.ini $did(tbg,12).seltext banmsg $did(tbg,23,0).text
  488.     writeini %tbg.ini $did(tbg,12).seltext scan $did(tbg,24).state
  489.     writeini %tbg.ini $did(tbg,12).seltext x $did(tbg,25).state
  490.     writeini %tbg.ini $did(tbg,12).seltext xdays $did(tbg,26).seltext
  491.     writeini %tbg.ini $did(tbg,12).seltext dnsbl $did(tbg,28).state
  492.     if ($didtok(tbg,32,172)) writeini %tbg.ini lists ignore $didtok(tbg,32,172)
  493.     else remini %tbg.ini lists ignore
  494.   }
  495.   if ($did == 12) {
  496.     did -e tbg 1,14,23,24,25,26
  497.     did -b tbg 13
  498.     did -d tbg 23 3
  499.     if ($readini(%tbg.ini,$did(tbg,12).seltext,banmsg)) { did -ac tbg 23 $readini(%tbg.ini,$did(tbg,12).seltext,banmsg) }
  500.     if ($readini(%tbg.ini,$did(tbg,12).seltext,scan)) { did -c tbg 24 }
  501.     else { did -u tbg 24 }
  502.     if ($readini(%tbg.ini,$did(tbg,12).seltext,x)) { did -c tbg 25 }
  503.     else { did -u tbg 25 }
  504.     if ($readini(%tbg.ini,$did(tbg,12).seltext,xdays)) { did -c tbg 26 $readini(%tbg.ini,$did(tbg,12).seltext,xdays) }
  505.     if ($readini(%tbg.ini,$did(tbg,12).seltext,dnsbl)) { did -c tbg 28 }
  506.     else { did -u tbg 28 }
  507.   }
  508.   if ($did == 13) {
  509.     if ($did(tbg,12,0).text) {
  510.       did -a tbg 12 $did(tbg,12,0).text
  511.       did -c tbg 12 $didwm(tbg,12,$did(tbg,12,0).text)
  512.       did -e tbg 1,14,23,24,25,26
  513.       did -b tbg 13
  514.       if ($readini(%tbg.ini,$did(tbg,12,0).text,banmsg)) { did -i1c 24 $readini(%tbg.ini,$did(tbg,12,0).text,banmsg) }
  515.       if ($readini(%tbg.ini,$did(tbg,12,0).text,scan)) { did -c tbg 24 }
  516.       if ($readini(%tbg.ini,$did(tbg,12,0).text,x)) { did -c tbg 25 }
  517.     }
  518.   }
  519.   if ($did == 14) {
  520.     if ($?!"Are you sure you want to remove $did(tbg,12).seltext $+ ?") {
  521.       did -b tbg 1,14,23,24,25,26
  522.       did -u tbg 24,25
  523.       did -c tbg 26 14
  524.       did -d tbg 23 3
  525.       did -c tbg 23 1
  526.       did -e tbg 13
  527.       remini %tbg.ini $did(tbg,12).seltext
  528.       did -d tbg 12 $did(tbg,12).sel
  529.       writeini %tbg.ini lists chans $didtok(tbg,12,172)
  530.       did -o tbg 12 0 $null
  531.     }
  532.   }
  533.   if ($did == 4) {
  534.     dialog -x tbg
  535.     window -r @Tor-Be-Gone
  536.     tbgupdate
  537.   }
  538.   if ($did = 33) {
  539.     did -a tbg 32 $did(tbg,32).text
  540.     did -b tbg 33
  541.   }
  542.   if ($did == 32) {
  543.     did -e tbg 34
  544.   }
  545.   if ($did == 34) {
  546.     did -d tbg 32 $did(tbg,32).sel
  547.     did -b tbg 34
  548.   }
  549. }
  550.  
  551. on 1:dialog:tbg:edit:*: {
  552.   if ($did == 12) {
  553.     did -b tbg 1,14,23,24,25,26
  554.     did -u tbg 24,25
  555.     did -c tbg 26 14
  556.     did -d tbg 23 3
  557.     did -c tbg 23 1
  558.     did -e tbg 13
  559.   }
  560.   if ($did == 32) {
  561.     if ($did(tbg,32).text) did -e tbg 33
  562.     else did -b tbg 33
  563.   }
  564. }
  565.  
  566. menu channel {
  567.   TBG+DNSBL
  568.   .TBG Settings:dialog -m tbg tbg
  569.   .Show TBG Status Window:window -rd @TBG-Status
  570.   .Maintenance
  571.   ..Clear The Scan Que (Que $line(@tbgQ,0) $+ ): {
  572.     if ($input(Are you sure you want to clear the scan que?,y)) { window -c @tbgQ | if ($input(Scan Que Cleared.,o)) { } }
  573.   }
  574.   ..Clear The DNS cache (Cached $hget(tbg_dns_cache,0).item $+ ): {
  575.     if ($input(Are you sure you want $hget(tor.tbg_dns_cache,0).item IP's deleted from the DNS IP cache?,y)) { .hfree tbg_dns_cache | .hmake tbg_dns_cache 1000 | hsave -o tbg_dns_cache torips\tbg_dns_cache.hash | if ($input(DNS IP's Cleared.,o)) { } }
  576.   }
  577.   ..Clear The Tor IP cache (Cached $hget(tor.ips,0).item $+ ): {
  578.     if ($input(Are you sure you want $hget(tor.ips,0).item IP's deleted from the Tor IP cache?,y)) { .hfree tor.ips | .hmake tor.ips 1000 | hsave -bo tor.ips torips\tor_ips.hash | if ($input(Tor IP's Cleared. You will now need to update the Tor Exit Node IP List,o)) { } }
  579.   }
  580.   ..Clear The DNSBL cache (Cached $hget(TBG_DNSBL,0).item $+ ): {
  581.     if ($input(Are you sure you want $hget(TBG_DNSBL,0).item IP's deleted from the DNSBL IP cache?,y)) { .hfree TBG_DNSBL | if ($input(DNSBL IP's Cleared,o)) { } }
  582.   }
  583.   .-
  584.   . $+ $iif($istok($readini(torips\tbg.ini,lists,chans),$chan,172),Scan the channel for Tor $iif($readini(%tbg.ini,$chan,dnsbl),and DNSBL),) :tbgscan $chan
  585.   .-
  586.   .Update Tor exit node IP list: { window -r @Tor-Be-Gone | tbgupdate }
  587. }
  588.  
  589. menu nicklist {
  590.   -
  591.   Check with TBG : {
  592.     set %tbgscan.count 1
  593.     var %tbg.scantime = $ctime
  594.     addto.tbgQ ¬StartScanChan $chan $1 ~
  595.     addto.tbgQ $1 $chan
  596.     addto.tbgQ ¬FinishScanChan $chan %tbgscan.count %tbg.scantime $1
  597.   }
  598.   -
  599. }
  600.  
  601. raw 315:*: { if ($2 isin %tbg.who) { set %tbg.who $remtok(%tbg.who,$2,1,32) | haltdef } }
  602. raw 352:*: { if ($2 isin %tbg.who) { haltdef } }
  603.  
  604. on 1:unload: {
  605.   unset %tbg*
  606.   timerTBG.update off
  607.   timertbgq off
  608.   hfree tor.ips
  609.   hfree torchk
  610.   hfree TBG_DNSBL
  611.   hfree tbg_dns_cache
  612.   echo -ts *** Tor-Be-Gone has been unloaded.
  613. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement