To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


EIT Planet's Security News
 Security Vulnerabilities Prove Increasingly Costly
 IPS Market Approaches $1 Billion
 U.S. Named Top Spammer

Security Products
 Family Keylogger (Family Keylogger)
 modusGate (Vircom Inc.)
 Kernel Hotmail MSN Password Recovery (Nucleus Data Recovery)
 Outlook 2003 PST Password Recovery (PST Password Recovery)
 PST Password Remove (PST Password Remove)
 Zemana Anti Keylogger (Vickit, Inc.)


Go Back   Antionline Forums - Maximum Security for a Connected World > General Technology Forums > Web Development

Web Development Talk about technologies used to develop cool websites like AntiOnline.

Reply
 
Thread Tools Display Modes
Old July 12th, 2009, 10:08 PM   #1
CSharpGuy
Junior Member
 
Join Date: Jul 2009
Posts: 2
CSharpGuy is on a distinguished road
Finding Login URL of a Web Page

Hey guys,
I've recently been developing a C# application for myself and a friend of mine and I've basically managed to code everything except one feature that basically gets the amount of credits that you have on your account from a site called getref.com.

To do this I need to either login the account via a Login URL by means of the WebClient Object in the .Net Framework which would look something like:

Code:
WebClient myClient = new WebClient();

string strRes = myClient.DownloadString("http://ww.getref.com/processlogin.asp?&txtUsername=<username>&txtPassword=<password>&login=Logon");
I can then simply parse the string strRes to find the amount of credits.

I can also try to login via an HttpWebRequest:

Code:
string User = "******";
string Pass = "******";

string url = "http://ww.getref.com/processlogin.asp";
string pdata = "&txtusername=" + User + "&txtpassword=" + Pass + "&login=Logon";

string strRes = SendWebRequest(url, pdata, 8, "");


private static string SendWebRequest(string Url, string PData, int Interval, string Referer)
{
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);
    if (PData != "")
    {
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        byte[] arrbytes = Encoding.ASCII.GetBytes(PData);
        req.ContentLength = arrbytes.Length;
        Stream reqStream = req.GetRequestStream();
        reqStream.Write(arrbytes, 0, arrbytes.Length);
        reqStream.Close();
    }
    if (Referer != "")
    {
        req.Referer = Referer;
    }
    req.Timeout = Interval * 0x3e8;
    HttpWebResponse httpresponse = (HttpWebResponse)req.GetResponse();
    StreamReader _streamreader = new StreamReader(httpresponse.GetResponseStream());

    return _streamreader.ReadToEnd().ToString();
}
Just like the other example I can then simply parse the string strRes to find the amount of credits as well.

My problem is that of finding the correct login Url to login or that of creating the right HttpWebRequest for logging in. :/

Does anyone know what I'm doing wrong?
Are my HTTP Headers incorrect?
Am I crafting my query properly?

Sorry if I'm doing a lot of stupid mistakes. I'm very inexperienced when it comes to web dev thats why I decided to ask the pros xD.

Thanks a lot.

Regards,
CSharpGuy.
CSharpGuy is offline   Reply With Quote
Old July 14th, 2009, 07:16 PM   #2
MicroBurn
Developer Extraordinar
 
Join Date: Jul 2002
Location: Internets
Posts: 564
MicroBurn has a reputation beyond reputeMicroBurn has a reputation beyond reputeMicroBurn has a reputation beyond reputeMicroBurn has a reputation beyond reputeMicroBurn has a reputation beyond reputeMicroBurn has a reputation beyond reputeMicroBurn has a reputation beyond reputeMicroBurn has a reputation beyond reputeMicroBurn has a reputation beyond reputeMicroBurn has a reputation beyond reputeMicroBurn has a reputation beyond repute
I can't speak much for the C#. It's been awhile.

Quote:
Does anyone know what I'm doing wrong?
Firstly, you're passing the password in plain text. That's a no-no, at least for me. Generally passing a username and password in the URL via a GET request is a bad thing, and it's frowned upon (at least, it is by me).

It looks to me like the SendwebRequest is sending the username and password via POST, but the processLogin.asp wants it via GET.

But, first things first. Encrypt the password before you send it. I'll help you out some more when I'm not at work... :/
__________________
AnotherLAMEsite || Unerror IRC (Leapnode)
MicroBurn is offline   Reply With Quote
Old July 14th, 2009, 10:21 PM   #3
oofki
Senior Member
 
Join Date: Oct 2003
Location: MA
Posts: 1,040
oofki has a reputation beyond reputeoofki has a reputation beyond reputeoofki has a reputation beyond reputeoofki has a reputation beyond reputeoofki has a reputation beyond reputeoofki has a reputation beyond reputeoofki has a reputation beyond reputeoofki has a reputation beyond reputeoofki has a reputation beyond reputeoofki has a reputation beyond reputeoofki has a reputation beyond repute
- The plain password is fine if you are making a request to the https page not the http one.

- Use a cookie container that is attached to every request you make

- Request the login page before you post to it (in order to get the cookies it sets on visit) using GET

- Use the same cookie container you used in the GET and post the user/pass but encode it in ascii first.

- Take the & off of the first argument aka &txtusername= should be just txtusername=

- You may need to spoof the browser because they do not want automated requests.
oofki is offline   Reply With Quote
Old July 14th, 2009, 10:49 PM   #4
CSharpGuy
Junior Member
 
Join Date: Jul 2009
Posts: 2
CSharpGuy is on a distinguished road
Thank a lot guys your post have been a tremendous amount of help.

Am kind of understanding how these things work.
Gonna do some more research/thinking to hopefully create this feature...
Till then any advise will be greatly appreciated.
CSharpGuy is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
http login page and tcpdump.. k_tech Newbie Security Questions 2 March 27th, 2008 12:16 PM
Genral Windows Tips Nokia Tips and Tricks 0 June 12th, 2004 05:36 PM
Tutorial Index page LarrySmith Site Suggestions 1 October 17th, 2003 06:51 PM
Solaris Hardening R0n1n *nix Security Discussions 3 November 20th, 2002 01:20 PM
The Worlds Longest Thread! Noble Hamlet AntiOnline's General Chit Chat 1100 March 17th, 2002 08:38 AM


All times are GMT +1. The time now is 12:01 PM.












Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.