Clan x86

Technical (Development, Security, etc.) => General Programming => Topic started by: abc on August 01, 2008, 09:38:06 PM

Title: HTTP Stuff
Post by: abc on August 01, 2008, 09:38:06 PM
hey uh, I'm trying to setup an automated login for a website and I've been packet logging the login I've been coming across some problems.

I see

Host: secure.somesite.com\r\n
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1\r\n
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n
Accept-Language: en-us,en;q=0.5\r\n
Accept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n
Keep-Alive: 300\r\n
Connection: keep-alive\r\n
Referer: http://www.somesite.com
Content-Type: application/x-www-form-urlencoded\r\n
Content-Length: 682


My question is, when sending this information, do I have to send it in the exact order for it to work?

I'm programming in C# using the HttpWebRequest

Title: Re: HTTP Stuff
Post by: Sidoh on August 01, 2008, 10:34:55 PM
These are HTTP headers, so order isn't important.

Use HttpWebRequest.Headers.Add(string name, string value) before you send the request.
Title: Re: HTTP Stuff
Post by: abc on August 01, 2008, 11:52:48 PM
thanks for the clarification Sidoh.  :)
Title: Re: HTTP Stuff
Post by: MyndFyre on August 02, 2008, 12:04:42 AM
Using HttpWebRequest, you don't need to worry about all that.  You just need to manage the Content-Type and the contents.  You can also hack User-Agent if you want to spoof a browser.
Title: Re: HTTP Stuff
Post by: abc on August 02, 2008, 12:06:42 AM
Quote from: MyndFyre on August 02, 2008, 12:04:42 AM
Using HttpWebRequest, you don't need to worry about all that.  You just need to manage the Content-Type and the contents.  You can also hack User-Agent if you want to spoof a browser.

alright cool, that's what I've been doing

        req.Method = "POST";
            req.UserAgent = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1";
            req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
            req.Headers.Add("Accept-Language: en-us,en;q=0.5");
            req.Headers.Add("Accept-Encoding: gzip,deflate");
            req.Headers.Add("Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7");
            req.KeepAlive = true;
            req.Connection = "300";
            req.Referer = "somesite.com/whatever";
            req.ContentType = "application/x-www-form-urlencoded";
Title: Re: HTTP Stuff
Post by: MyndFyre on August 02, 2008, 03:07:43 AM
so that would wned up having stuff like:

User-Agent: User-Agent: Mozilla/5.0

Don't be silly ;)
Title: Re: HTTP Stuff
Post by: abc on August 02, 2008, 03:50:49 AM
Quote from: MyndFyre on August 02, 2008, 03:07:43 AM
so that would wned up having stuff like:

User-Agent: User-Agent: Mozilla/5.0

Don't be silly ;)

ah, silly me!  :D