5 Replies - 3545 Views - Last Post: 19 December 2011 - 06:11 AM Rate Topic: -----

#1 electronic-ltd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 18-December 11

C# - Log in to Website

Posted 18 December 2011 - 11:56 AM

im need to login this website
http://adsl.tch.ir/Authenticate.aspx

im using tamper data but no answer this method.
http://www.dreaminco...ogrammatically/

please help me.

Is This A Good Question/Topic? 0
  • +

Replies To: C# - Log in to Website

#2 RexGrammer  Icon User is offline

  • Coding Dynamo
  • member icon

Reputation: 182
  • View blog
  • Posts: 783
  • Joined: 27-October 11

Re: C# - Log in to Website

Posted 18 December 2011 - 11:58 AM

What isn't working for you? Describe your problem more precisely...
And please show your effort into doing that. :tt2:

This post has been edited by RexGrammer: 18 December 2011 - 11:58 AM

Was This Post Helpful? 0
  • +
  • -

#3 electronic-ltd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 18-December 11

Re: C# - Log in to Website

Posted 18 December 2011 - 12:04 PM

View PostRexGrammer, on 18 December 2011 - 11:58 AM, said:

What isn't working for you? Describe your problem more precisely...
And please show your effort into doing that. :tt2:


im using microsoft visual studio 2010 lan:c#
Was This Post Helpful? 0
  • +
  • -

#4 RexGrammer  Icon User is offline

  • Coding Dynamo
  • member icon

Reputation: 182
  • View blog
  • Posts: 783
  • Joined: 27-October 11

Re: C# - Log in to Website

Posted 18 December 2011 - 12:08 PM

OK. But I'm not asking you what are you using, but what is going wrong in your project?
And to post your efforts into solving that problem (like some source code, or event pseudo-code).
Was This Post Helpful? 0
  • +
  • -

#5 electronic-ltd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 18-December 11

Re: C# - Log in to Website

Posted 18 December 2011 - 12:12 PM

View PostRexGrammer, on 18 December 2011 - 11:58 AM, said:

What isn't working for you? Describe your problem more precisely...
And please show your effort into doing that. :tt2:


using this topic code:
http://www.dreaminco...ogrammatically/
when start tamper data for this parameters:

authenticity_token
session[username_or_email]
session[password]
commit

do'nt find in this tamper post page.

code:
namespace log_in_to_website
{
    public partial class login_form : Form
   {
        public login_form()
        {
            InitializeComponent();
        }


        private void btn_login_Click(object sender, EventArgs e)
        {
            Login();
        }

        private void Login()
        {
            string url = "http://adsl.tch.ir/Authenticate.aspx";
             WebBrowser b = new WebBrowser();
             b.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(b_DocumentCompleted);
             b.Navigate(url);
        }

        private void b_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            string username = txb_username.Text;
            string password = txb_password.Text;
            string commit = "Sign+In"; //this matches the data from Tamper Data

             WebBrowser b = sender as WebBrowser;
             string response = b.DocumentText;
             // looks in the page source to find the authenticity token.
             // could also use regular exp<b></b>ressions here.
             int index = response.IndexOf("authenticity_token");
             int startIndex = index + 41;
             string authenticityToken = response.Substring(startIndex, 40);
             // unregisters the first event handler
             // adds a second event handler
             b.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(b_DocumentCompleted);
             b.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(b_DocumentCompleted2);
             // format our data that we are going to post to the server
             // this will include our post parameters.  They do not need to be in a specific
             // order, as long as they are concatenated together using an ampersand ( & )
             string postData = string.Format("authenticity_token={2}&session[username_or_email]={0}&session[password]={1}&commit={3}", username, password, authenticityToken, commit);
             ASCIIEncoding enc = new ASCIIEncoding();
             //  we are encoding the postData to a byte array
             b.Navigate("http://adsl.tch.ir/sessions", "", enc.GetBytes(postData), "Content-Type: application/x-www-form-urlencoded\r\n");
        }

        private void b_DocumentCompleted2(object sender, WebBrowserDocumentCompletedEventArgs e)
        {

             WebBrowser b = sender as WebBrowser;
             string response = b.DocumentText;
             if (response.Contains("Sign out"))
             {
                 MessageBox.Show("Login Successful");
             }
             else
             {
                 MessageBox.Show("Don't Login to Website");
             }

This post has been edited by CodingSup3rnatur@l-360: 18 December 2011 - 12:24 PM
Reason for edit:: Please use [code]CODE TAGS[/code] when posting code

Was This Post Helpful? 0
  • +
  • -

#6 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: C# - Log in to Website

Posted 19 December 2011 - 06:11 AM

These parameters...

authenticity_token
session[username_or_email]
session[password]
commit

are for TWITTER!!! Not for every site on the internet.

When I used Fiddler to look at the POST paramaters(Tamper Data wasn't working in Firefox 8), I got these as the POST parameters...

Attached Image

The username and password I used was 'sdf' for both.

Please READ the tutorial. It states that it logs into Twitter. POST parameters are specific and different for every site on the internet.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1