Wikipedia:Requests for adminship/TawkerbotTorA/code: Difference between revisions
Appearance
Content deleted Content added
Recent changes to the code |
okay, implementing OH NOES STOP TEH BOT function |
||
Line 28: | Line 28: | ||
MatchCollection matches = RouterRegex.Matches(TorDirectory); |
MatchCollection matches = RouterRegex.Matches(TorDirectory); |
||
Random rand = new Random(); |
|||
foreach (Match m in matches) |
foreach (Match m in matches) |
||
{ |
{ |
||
if (rand.Next(0,10) == 3) { |
|||
if (ed.GetWikiText("User:Werdna/StopTBTA").Contains("Stop")) |
|||
return; //Shit hit the fan |
|||
} |
|||
string IP; |
string IP; |
||
string AccessPolicy = ""; |
string AccessPolicy = ""; |
Revision as of 16:39, 5 October 2006
using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Text.RegularExpressions; using WikiFunctions; namespace TorList { class Program { static void Main(string[] args) { string TorDirectory = ""; WebClient wc = new WebClient(); string Output = ""; Editor ed = new Editor(); //path to the wiki :) ed.IndexPath = "http://wiki.wikipedia.org/wiki"; ed.LogIn("TawkerbotTorA", "GUESSWHAT - A PASSWORD GOES HERE......."); TorDirectory = wc.DownloadString("http://tor.noreply.org/tor/"); Regex RouterRegex = new Regex(@"router\ [^\s]+\ ([12]?\d?\d.[12]?\d?\d.[12]?\d?\d.[12]?\d?\d)\ \d+\ " + @"\d+ \d+\r?\n.+?(\r?\n(accept|reject)\ (([12]?\d?\d.[12]?\d?\d.[12]?\d?\d.[12]?\d?\d)|\*)\:(\d+" + @"(-\d+)?|\*))+", RegexOptions.Singleline); MatchCollection matches = RouterRegex.Matches(TorDirectory); Random rand = new Random(); foreach (Match m in matches) { if (rand.Next(0,10) == 3) { if (ed.GetWikiText("User:Werdna/StopTBTA").Contains("Stop")) return; //Shit hit the fan } string IP; string AccessPolicy = ""; //Steal the access policy and IP. Regex ServerIPRegex = new Regex(@"router\ [^\s]+\ ([12]?\d?\d.[12]?\d?\d.[12]?\d?\d.[12]?\d?\d)"); Regex ExitPolicyRegex = new Regex(@"(accept|reject)\ (([12]?\d?\d.[12]?\d?\d.[12]?\d?\d.[12]?\d?\d)|\*)" + @":(\d+(-\d+)?|\*)"); Match ServerIPMatch; MatchCollection ExitPolicyMatches; ServerIPMatch = ServerIPRegex.Match(m.Value); ExitPolicyMatches = ExitPolicyRegex.Matches(m.Value); foreach (Match p in ExitPolicyMatches) { AccessPolicy += "*" + p.Value + "\r\n"; } IP = ServerIPMatch.Groups[1].Value; if ( (AccessPolicy.Contains("accept *:*") || AccessPolicy.Contains("accept *:80") ) && !AccessPolicy.Contains("reject *:80")) { Output += "==Tor Server {{subst:vandal|" + IP + "}}==\r\n;Access Policy:\r\n"; Output += AccessPolicy; ed.Unblock(IP, "Automatically unblocking Tor node" + " for migration to AnonOnly NoCreate" + "."); ed.Block(IP, "1 month", true, true, "Tor ''(Anonymous only, with account creation disabled)''"); } } ed.EditPage("User:Werdna/Tor List", Output, "Automatically listing current Tor nodes", false); } } }