4 Replies - 411 Views - Last Post: 28 September 2011 - 08:48 PM Rate Topic: -----

#1 frieling  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 34
  • Joined: 27-February 09

Using UserAgents

Posted 28 September 2011 - 01:02 PM

Well i am trying to code a simple program to check this .cfg file for a certain set of words that the user inputs. Well when it tries to search the file(and it is on the web btw, and ill show you that when i show you my code). It gives me a 403 forbidden error in Microsoft visual C#. So i talked to my friend and he told me that his server blocks all Blank UserAgents. So I have looked up how to send a useragent and all of that stuff, but i cannot figure out how to implament it into my code. So here is what I have so far:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Web;

namespace _ACI__AA_Protect_Tag_Search
{
    class Program
    {
        static void Main(string[] args)
        {

            //Declare Variables
            string sTag = "";
            string sPageCon = "";

            Console.Write("Please enter the tag you would like to search: ");
            sTag = Console.ReadLine();

            HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://www.anticheatinc.com/public/protecttag.cfg");
            HttpWebResponse myres = (HttpWebResponse)myReq.GetResponse();

            using (StreamReader sr = new StreamReader(myres.GetResponseStream()))
            {
                sPageCon = sr.ReadToEnd();
            }
            if (sPageCon.Contains(sTag))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}



Ideas?

Is This A Good Question/Topic? 0
  • +

Replies To: Using UserAgents

#2 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Using UserAgents

Posted 28 September 2011 - 01:22 PM

Start with the MSDN:

http://msdn.microsof...webrequest.aspx

See how the HttpWebRequest has a UserAgent property.

Next, search for "UserAgent string" on google.

Here's a good resource that came up:

http://www.useragent...net%20Explorer/

Pick the user agent string that most closely matches the browser you want to emulate. Copy it, and then set the UserAgent property on the HttpWebRequest you created to it.

Done.
Was This Post Helpful? 2
  • +
  • -

#3 frieling  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 34
  • Joined: 27-February 09

Re: Using UserAgents

Posted 28 September 2011 - 01:33 PM

Sounds pretty easy. Ill work on it when i get home from work. So i will let you know then.
Was This Post Helpful? 0
  • +
  • -

#4 frieling  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 34
  • Joined: 27-February 09

Re: Using UserAgents

Posted 28 September 2011 - 08:37 PM

Well it works like a charm. Now I would like to put some extra stuff in it.

Here is a line for example from the cfg file:

pb_sv_protecttag 1 -{IC}- ;Expires 2011-05-30

Where is a good reference to figureing out how to get the expired date from that line?
Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Using UserAgents

Posted 28 September 2011 - 08:48 PM

Well, you could use string.Split to split up the string. Then you can use DateTime.Parse. Search both of those on the MSDN.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1