Skip to content

Instantly share code, notes, and snippets.

@bricewge
Created June 26, 2017 12:08
Show Gist options
  • Save bricewge/09d692d65ba96d50106302fa9652601b to your computer and use it in GitHub Desktop.
Save bricewge/09d692d65ba96d50106302fa9652601b to your computer and use it in GitHub Desktop.
piscine_php
#!/usr/bin/env sh
export PS4='\e[37m❯ \e[0m'
host=`hostname`
port="8080"
echo "\n==== ex00 ====\n"
set -o xtrace
curl -v -c cook.txt "http://$host:$port/j04/ex00/index.php"
curl -v -b cook.txt "http://$host:$port/j04/ex00/index.php?login=sb&passwd=beeone&submit=OK"
curl -v -b cook.txt "http://$host:$port/j04/ex00/index.php"
curl -v "http://$host:$port/j04/ex00/index.php"
set +x
echo "\n==== ex01 ====\n"
set -o xtrace
rm "./private/passwd"
curl -d login=toto1 -d passwd=titi1 -d submit=OK "http://$host:$port/j04/ex01/create.php"
curl -d login=foo -d passwd=bar -d submit=OK "http://$host:$port/j04/ex01/create.php"
more "./private/passwd"
curl -d login=toto1 -d passwd=titi1 -d submit=OK "http://$host:$port/j04/ex01/create.php"
curl -d login=toto2 -d passwd= -d submit=OK "http://$host:$port/j04/ex01/create.php"
curl -d login= -d passwd=titi1 -d submit=OK "http://$host:$port/j04/ex01/create.php"
set +x
echo "\n==== ex02 ====\n"
set -o xtrace
rm "./private/passwd"
curl -d login=x -d passwd=21 -d submit=OK "http://$host:$port/j04/ex01/create.php"
curl -d login=x -d oldpw=21 -d newpw=42 -d submit=OK "http://$host:$port/j04/ex02/modif.php"
curl -d login=y -d passwd=ab -d submit=OK "http://$host:$port/j04/ex01/create.php"
curl -d login=y -d oldpw=ab -d newpw=cd -d submit=OK "http://$host:$port/j04/ex02/modif.php"
more "./private/passwd"
# ERROR: Oldpw is not correct
curl -d login=x -d oldpw=21 -d newpw=42 -d submit=OK "http://$host:$port/j04/ex02/modif.php"
# ERROR: Newpw is empty
curl -d login=x -d oldpw=42 -d newpw= -d submit=OK "http://$host:$port/j04/ex02/modif.php"
# ERROR: User doesn't exist
curl -d login=z -d oldpw=21 -d newpw=42 -d submit=OK "http://$host:$port/j04/ex02/modif.php"
set +x
echo "\n==== ex03 ====\n"
set -o xtrace
rm "./private/passwd"
curl -d login=toto -d passwd=titi -d submit=OK "http://$host:$port/j04/ex01/create.php"
curl -c cook.txt "http://$host:$port/j04/ex03/login.php?login=toto&passwd=titi"
# ERROR: Invalid login
curl -c cook.txt "http://$host:$port/j04/ex03/login.php?login=abcd&passwd=titi"
# ERROR: Invalid password
curl -c cook.txt "http://$host:$port/j04/ex03/login.php?login=toto&passwd=abcd"
# ERROR: Empty password
curl -c cook.txt "http://$host:$port/j04/ex03/login.php?login=toto&passwd="
curl -b cook.txt "http://$host:$port/j04/ex03/whoami.php"
curl -c cook.txt "http://$host:$port/j04/ex03/login.php?login=toto&passwd=titi"
curl -b cook.txt "http://$host:$port/j04/ex03/whoami.php"
curl -b cook.txt "http://$host:$port/j04/ex03/logout.php"
# ERROR: Not loggued in
curl -b cook.txt "http://$host:$port/j04/ex03/whoami.php"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment