1

I need to login to a webpage daily for my project work. This is basically an application front-end url where I need to enter credentials and check if the application is accessible or not.

I tried using curl & wget options but none of them worked for me.

Also when i checked curl and wget syntax, almost all of them used http. My application url is https://xyz/login.jspx

It would be a big help if someone could advise how can I get this login process automated using bash script.

Thanks

  • https is http just with encryption. What curl and wget did you try and how did they not work? – jesse_b Jun 23 '21 at 18:52
  • curl http://username:password@website.com/url -- gave me error couldn't resolve host. curl -d 'username=abc&password=abc' https://url -- gave me error Peer certificate cannot be authenticated with known CA certificates – Aayush Jain Jun 23 '21 at 18:53
  • what about curl --user username:password https://website.com/uri? – jesse_b Jun 23 '21 at 18:55
  • @jesse_b Above command also returns same error -- Peer certificate cannot be authenticated with known CA certificates – Aayush Jain Jun 23 '21 at 18:58
  • What about curl -k --user username:password https://website.com/uri? – jesse_b Jun 23 '21 at 18:59
  • This one returned some html syntax ( not sure what's the purpose of it). When i checked the exit status, it was 0 which means command did executed successfully but when i tried to check the application, it didn't got logged in – Aayush Jain Jun 23 '21 at 19:05

2 Answers2

0

username:password@website is not how you log into web services at all; that's the good old HTTP basic auth and practically never used.

You'll have to figure out which data your browser sends to the server when you click on "log in". Luckily, standard browsers like firefox show that when you go into their integrated web developer tools and click on the "network" tab.

Mine even has a context menu on a request that allows me to copy and paste a curl command line that executes exactly the same request.

0

I think you've got a long journey ahead of you - even longer if bash is the only tool in your toolkit.

If you can program in Perl, then www::mechanize can replay actions and can therefore be interlaced with code to test outcomes.

If javascript is involved in the logon process (try disabling it in your browser and logging in) then you have a much more complicated task. You'll need to use a browser and webdriver or selenium.

You will need to have a solid understanding of how session state is managed in web applications.

symcbean
  • 5,540