AUTHENTICATION REQUESTS
HTTP AUTHENTICATION (GET)
root@oco:~$ curl -u {username}:{password} {targetSite:port}
* the -u option is used to directly provide credentials through the URLHTTP AUTHENTICATION (POST)
root@oco:~$ curl -X POST -d 'username=admin&password=admin' http://{targetSite:port} -L -i
* the -X is used to specify the method {GET, POST, ect}
* the -d option is used to add data to the method, specifically POST method
- it defines the data being sent in the body of the request.
- The data will be sent in URL-encoded format, which is the same as what HTML forms use.
* the -L option is used to tell curl to follow redirection which
usually happens after successful authentication to a site
* the -i option is used to view the server response, which may contain the Set-Cookie header
with the authenticated cookie
* after successfuly authentication, cookies could be received to persist and to not
be needing to login every time the page is visited
root@oco:~$ curl -X POST -d "username=user&password=user&submit=Login" http://MACHINE_IP/post.php
* this second post authentication cmd is used if the application expects additional fields,
like a "Login" button or a CSRF token
MODIFICATION: AUTHORIZATION HEADER (GET)
AUTHENTICATION W/ COOKIE
Once logged in, web applications use cookies to keep a session active. When you make another request with a browser, the cookie gets sent automatically, but with cURL, it need to be handled manually.
Last updated