1

Is there a way to send username and password to a url of a login web page? For example, if the login web page contains 2 textboxes : user name and password and a login button, is there a way to send to the url the credential in order to go directly to the next page coming after the login?

The url for the login page looks like:

http://[ip address]/jsp/login.xhtml

I tried to send the username and passord as following:

http://[username:password]/[ip address]/jsp/login.xhtml

http://[ip address]/jsp/login.xhtml?[username:password]

If there is a way to do it by sending the command through a batch file? If it can be done using c# or javascript it is also fine.

ehh
  • 3,114
  • 2
  • 29
  • 71
  • this depends on how the page processes the credentials. Most likely, this wil be through a 'post'. If so, you should look into how to send your credentials directly to the script verifying your credentials. – Anthony Dekimpe Feb 07 '16 at 08:09
  • I looked at the view source and I saw: method="post" action="/jsp/login.xhtml" enctype="application/x-www-form-urlencoded" – ehh Feb 07 '16 at 08:14
  • 1
    this means the data gets sent to 'http://[ip address]/jsp/login.xhtml' in 'post', now you need to find out how you want to do it. I suggest using javascript (more info on how to do this: http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit), This can be run by a plugin Like 'Custom Javascript for Websites' plugin for chrome. – Anthony Dekimpe Feb 07 '16 at 08:24
  • @ Anthony Dekimpe, I liked the javascript solution however I am not really clear how to write it. Could you add it as answer and help a little more with this solution? – ehh Feb 07 '16 at 08:34

2 Answers2

2

The best option is Javascript. It can easily run from a plugin of your browser. (I'm using 'Custom Javascript for Websites', a chrome plugin: https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija)

Firstly you navigate to the login page and check the source code for the following ID's: - Username-inputbox - Password-inputbox - Submit button

Knowing these things, we can add this to our plugin: (Fill in the id's at the right places)

// First we check if we're on the right page
if (window.location.href == "URL")
{
    // Find the ID's of the corresponding inputs
    document.getElementById("username").value = "user0";
    document.getElementById("password").value = "user0scode";

    // Then click the submit button, just as we do
    document.getElementById("btnSubmit").click();
}
Anthony Dekimpe
  • 327
  • 2
  • 14
  • It works fine for me. Is it possible to inject this piece of code from a batch file or a C# directly to the cjs extension for the requested url? – ehh Feb 07 '16 at 09:44
  • 1
    You can accomplish this with the webbrowser control in Windows.Forms in C#: Create a webbrowser ('wb') and navigate to the page, Then catch the event 'OnDocumentCompleted', and use the build-in functions: `wb.Navigate("URL");` `wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);` Then put this in the DocumentCompleted handler: `wb.Document.GetElementById("username").InnerText = "user0"; wb.Document.GetElementById("password").InnerText = "user0scode"; wb.Document.GetElementById("submitButton").InvokeMember("click");` – Anthony Dekimpe Feb 07 '16 at 09:50
1

There is free tool called Fiddler. It monitors/debugs all the traffic on your machine i.e. using browsers or any other medium. You can try capturing the action/request behind the login button using Fiddler, and then mutate the same action/request and you will be able to change the username/password for that action/request.

Download from here, and read this.

Super Coder
  • 848
  • 1
  • 10
  • 22