LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-28-2017, 01:10 PM   #1
pradeepspa
Member
 
Registered: Oct 2015
Posts: 79

Rep: Reputation: Disabled
Get Webpage Cookies - Wget/Curl


Hello Folks,

I am trying to get a cookie of the webpage using wget. Below is the command I used,

Quote:
wget --save-cookies cookies.txt --keep-session-cookies --post-data 'username=xxxx&password=xxxx' http://ip/ --no-check-certificate
--2017-09-28 18:06:28-- http://ip/
but this doesnt give me the right cookie value. I believe its not even login to the webpage. Could anyone guide me what am I missing in this please?
 
Old 09-28-2017, 01:14 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 25,829

Rep: Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761
Quote:
Originally Posted by pradeepspa View Post
Hello Folks,
I am trying to get a cookie of the webpage using wget. Below is the command I used,
Code:
wget --save-cookies cookies.txt --keep-session-cookies --post-data 'username=xxxx&password=xxxx' http://ip/ --no-check-certificate
--2017-09-28 18:06:28-- http://ip/
but this doesnt give me the right cookie value. I believe its not even login to the webpage. Could anyone guide me what am I missing in this please?
Your other thread gives you good direction:
https://www.linuxquestions.org/quest...se-4175613667/

cURL is used to log in..until you do that, nothing else is going to work.
 
Old 09-28-2017, 02:16 PM   #3
pradeepspa
Member
 
Registered: Oct 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
Thanks for responding. I tried curl call but it wasnt logging in.

Quote:
curl -k -L -v -u xxxx:xxxx https://xxxx/login.cgi
From the above command , I am getting the html of the index page but it couldnt login.
 
Old 09-28-2017, 02:34 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 25,829

Rep: Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761
Quote:
Originally Posted by pradeepspa View Post
Thanks for responding. I tried curl call but it wasnt logging in.
Code:
curl -k -L -v -u xxxx:xxxx https://xxxx/login.cgi
From the above command , I am getting the html of the index page but it couldnt login.
Ok...so as you were told in your other thread and here, you need to research what's going on and why. Have you tried putting "how to login to website using curl" into Google??? Some of the very first hits have examples and explanations.

https://unix.stackexchange.com/quest...ite-using-curl
https://superuser.com/questions/6408...x-command-line
https://askubuntu.com/questions/1837...gin-to-webpage
 
Old 09-29-2017, 08:58 AM   #5
pradeepspa
Member
 
Registered: Oct 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
Yes I did. Tried different curl calls as suggested in the forums/post but nothing seems to be working.
 
Old 09-29-2017, 12:10 PM   #6
pradeepspa
Member
 
Registered: Oct 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
One more thing. When I used below command,

Quote:
wget -v --no-check-certificate --no-cache --keep-session-cookies --save-headers --save-cookies /dev/stdout --post-data 'username=unbt&password=xxxx' https://xxxx/login.cgi
--2017-09-29 17:02:52-- https://xxxx/login.cgi
Connecting to 10.9.1.3:443... connected.

WARNING: cannot verify 10.9.1.3's certificate, issued by ‘/C=US/ST=CA/L=San Jose/O=Ubiquiti Networks Inc./OU=Technical Support/CN=UBNT/emailAddress=support@ubnt.com’:
Self-signed certificate encountered.
WARNING: certificate common name ‘UBNT’ doesn't match requested host name ‘xxxxx’.
HTTP request sent, awaiting response...
200 OK
Length: unspecified [text/html]
Saving to: ‘login.cgi’

[ <=> ] 3,621 --.-K/s in 0.08s

2017-09-29 17:02:53 (42.2 KB/s) - ‘login.cgi’ saved [3621]

# HTTP cookie file.
# Generated by Wget on 2017-09-29 17:02:53.
# Edit at your own risk.

x.x.x.x FALSE / FALSE 0 AIROS_SESSIONID 7bc8bab145c81e06d4f8c1f6319ee478


Looking into the index file the above command generated,

Quote:
<table border="0" cellpadding="0" cellspacing="0" class="logintable" align="center">
<tr>
<td colspan="2" align="center">
<div id="errmsg" class="error">
Invalid credentials.
</div>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
I see Invalid credentials error. I used the same username and password through browser where it works.Is there something wrong the way I pass the credentials?
 
Old 09-29-2017, 12:37 PM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 25,829

Rep: Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761Reputation: 7761
Quote:
Originally Posted by pradeepspa View Post
One more thing. When I used below command, Looking into the index file the above command generated,

I see Invalid credentials error. I used the same username and password through browser where it works.Is there something wrong the way I pass the credentials?
I suggest you, AGAIN, go back and look at the examples. What you're doing doesn't match..can't be more plain. You're not saving the cookie somewhere, you're not putting the URL into double-quotes, etc.

You were given numerous examples...we cannot force you to read them.
 
Old 09-29-2017, 02:27 PM   #8
pradeepspa
Member
 
Registered: Oct 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
Thanks for your guidance. I am doing my research and tried most of the examples suggested online. I thought someone would shed light on what I am missing. ANyways I will keep trying. Thanks for you effort.

Below is the modified command I am using incase you like to see.

Quote:
wget --no-check-certificate --auth-no-challenge --keep-session-cookies --save-cookies cookie104.txt --post-data="username=unbt&password=Xpl0rn3+" "https://10.9.1.3/login.cgi"
I know there are some mistakes in that command and that's the reason it doesnt work. I will try to figure that out.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using the cookies.sqlite from Firefox 3 in wget jimbo1708 Linux - Software 18 06-28-2014 11:32 AM
[SOLVED] curl not downloading full webpage BeaverusIV Programming 2 01-02-2012 06:04 AM
wget with the user firefox cookies? Xeratul Linux - General 2 10-11-2011 09:41 AM
getting curl to destroy cookies pendal Programming 2 12-04-2009 11:25 AM
Wget and Session Cookies mortrek Linux - Software 0 10-20-2006 04:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration