Hack Forums
[Python] Duplicating website form login via Python HTTPS PUT requests? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Duplicating website form login via Python HTTPS PUT requests? (/showthread.php?tid=6061653)



Duplicating website form login via Python HTTPS PUT requests? - SIM-4604643 - Mar 30, 2020

deleteddeleteddeleteddeleteddeleteddeleted


RE: Duplicating website form login via Python HTTPS PUT requests? - Charger - Mar 30, 2020

Use requests or curl to post the data. You’ll have to solve the captcha to get that variable as well as scrape the csrf field


RE: Duplicating website form login via Python HTTPS PUT requests? - Charger - Mar 30, 2020

(Mar 30, 2020 10:49 AM)SirRad0x Wrote:  Hey thanks for the reply.

Sorry is requests and curl a python library? How would I do this? Also what do you mean scrape the csrf field? Do you mind just explaining a bit more? Thanks.

Yes.

csrf is going to be a form field or JavaScript variable that you’ll need to get the value of to submit your request.


RE: Duplicating website form login via Python HTTPS PUT requests? - Mohinder - Mar 30, 2020

I think you should use two libraries: requests and bs4.

Use requests to make a request to the page, scrape with bs4 and send the captcha to your handler. I've been using anticaptcha for a while, and it suits my needs.
If you want help hit me up with your telegram name in a PM.


RE: Duplicating website form login via Python HTTPS PUT requests? - Mohinder - Mar 30, 2020

(Mar 30, 2020 11:13 AM)SirRad0x Wrote:  So what's the difference between curl and requests. Any recommendations? How do you know what the csrf is before you submit the form?


Never heard of bs4 thanks I'll look it up. How would you fill out the REQUESTS form? Thanks for your offer of help on the anticaptcha will definitely hit you up for some coaching on that.

Cheers

If you use requests you could post data to a url easily.

Let's say you have a form:

127.0.0.1/index.html
PHP Code

<?php 
<form action="/register" method="POST">
 
   <input type="text" name="_token" value="ce30ek21le03" hidden />
 
   <input type="text" name="username" />
</
form> 

With Python you can visit the index, grab the page source and scrape the token.

PHP Code

<?php 
from requests import post
, get
from bs4 import BeautifulSoup

req 
= get('http://127.0.0.1/index.html')
soup = BeautifulSoup(str(req.content), 'html.parser')
elem = soup.find('input', {'name': '_token'})
token = elem['value']

data = {
 
   'username': 'example',
 
   '_token': token
}
post_req = post('http://127.0.0.1/register', data=data)