Get results from PHP pages after login [closed]

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I have 10 php files like

0.php , 1.php, 2.php etc

All those files contains an auth form which send two inputs username and password to itself via post.

After login there is a message displayed.

I am trying to write a script which fills out the login form for each page and then echo the message from each page on a new line.

I know that I can fill the form using wget or curl but I am not so sure how.

I tried with curl -u username:password /host/files/0.php but seems that it just displays the html output of that file.

I am thinking of writing a shell script which does the followind:

pages = [0.php; 1.php; etc...]
foreach page in pages
        access page via curl or wget, fill in the form with username and password    which are the same for all files
        echo respons
        newline

How can I achieve this?

profilepic.png
manpreet 2 years ago

 What you were doing "-u username:password" is as far as I know a HTTP https://forum.tuteehub.com/tag/basic">basic authentication which is different from filling out a https://forum.tuteehub.com/tag/form">form and sending it via POST. This should work:

#!/bin/bash
pages="0.php 1.php 2.php"

for page in ${pages}; do
  wget -q --post-data 'user=username&password=password' --save-cookies cookies "http://server/${page}"
  wget -O- --load-cookies cookies -p "http://server/${page}"
done

0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.