示例#1
0
文件: whore.cs 项目: b1tninja/whore
        static int Main(string[] args)
        {
            if(args.Length < 2){
                Console.WriteLine("You should provide:\n\t1) The database connection string\n\t2) The location of your Tor executable");
                Environment.Exit(1);
            }
            string dbstring = args[0];
            string torloc = args[1];
            System.Console.WriteLine(string.Format("DBSTRING: {0} | TORLOC: {1}", dbstring, torloc));
            DB db = new DB(dbstring);

            W***e w***e = new W***e(db, torloc);
            //  Dns.readRootHints();

            #region StaticTasks
            // Assign some tasks
            //            w***e.queue(new WhoisTask("example.com"));
            //            w***e.queue(new DnsTask(new DnsTransaction.QuestionRecord("example.com", DnsTransaction.QTYPE.A, DnsTransaction.RCLASS.IN)));
            //            w***e.queue(new DnsTask(new DnsTransaction.QuestionRecord("gungo.com", DnsTransaction.QTYPE.A, DnsTransaction.RCLASS.IN)));
            #endregion

            Thread requesthandler = new Thread(new ThreadStart(w***e.clientListener));
            requesthandler.IsBackground = true;
            requesthandler.Start();

            // Main loop
            while (true)
            {
                w***e.doWork();
            }
        }
示例#2
0
文件: whore.cs 项目: b1tninja/whore
        // <summary>
        // Constructor. Initialises data directory if necessary and creates the
        // required number of TorInstance objects. </summary>
        // <param name="_db">The database object to cache results with</param>
        // <param name="torloc">The location of the Tor executable to be used by
        // the TorInstances </param>
        // <param name="basePort">The port number to be used as the basis of Tor
        // communications. basePort +-<paramref>threads</paramref> should all be free.
        // <param name="threads"> The number of TorInstance objects to use.
        public W***e(DB _db, string torloc, int basePort = 9049, byte threads = 1)
        {
            db = _db;
            // Create data subdirectory if it doesn't already exist.
            if (!System.IO.Directory.Exists("./data"))
            {
                try
                {
                    System.IO.Directory.CreateDirectory("./data");
                }
                catch
                {
                    Console.WriteLine("Failed to create data directory.");
                }
            }

            int controlPort = 0;
            int socksPort = 0;
            // Create TorInstances
            for (int i = 1; i <= threads; i++)
            {
                controlPort = basePort - i;
                socksPort = basePort + i;
                // useExisting?
                torInstances.Add(new TorInstance(torloc, controlPort, socksPort));
            }

            try{
                listener = new TcpListener(IPAddress.Any, socksPort+1);
                Console.WriteLine("W***e server listening on port: "+(socksPort+1));
                listener.Start();
            } catch (SocketException se) {
                Console.WriteLine(se.ErrorCode + ": "+se.Message);
                Environment.Exit(1);
            }
        }