Staphysec
  • StaphySec
  • Resources
  • Tricks
  • Brute Force - CheatSheet
  • File Transfer
    • Windows File Transfer
    • Linux File Transfer
    • HTTP/SMB/Nginx/Web Servers/Netcat
  • Hashcat
  • Cheatsheet
  • Curl
  • Tools
    • Cracking
    • Information Gathering
    • XSS
    • Obfuscation
    • Credentials Theft/ Win
    • Content Management Systems (CMS)
  • Programming and Scripting
    • Virtualenv & Switching Versions
    • Python
  • SHELLS
    • Shells (Linux, Windows, Msfvenom)
  • Linux
    • CheatSheet
    • EOP Linux Tools and Resources
    • Blogs
  • Windows
    • CheatSheet
    • EOP Windows Tools and Resources
    • Useful commands and Modules
    • Active Directory
      • Tools
  • Blogs
    • Miscellaneous resources
  • PENTESTING
    • 21 - Pentesting FTP
    • 22 - Pentesting SSH
    • 25,465,587 - Pentesting SMTP
    • 53 - Pentesting DNS
    • 110,995 - Pentesting POP
    • 135 - Pentesting WMI
    • 139,445 - SMB Pentesting
    • 143,993 - Pentesting IMAP
    • 161,162,10161,10162/udp - Pentesting SNMP
    • 623/UDP/TCP - IPMI
    • 1433 - Pentesting mssql
    • 2049 - NFS Pentesting
    • 3306 - Pentesting Mysql
    • 3389 - Pentesting RDP
    • 5985,5986 - WinRm
  • Pentesting Web
    • SQL Injections
      • MySQL injection
      • SQLmap Cheatsheet
    • Command injections
    • File Uploads
    • Abusing Intermediary Applications
    • HTTP Verb Tampering
    • IDOR
    • File Inclusion / Directory Traversal
    • XXE - XEE - XML External Entity
    • SSRF
    • SSI/ESI
    • SSTI (Server Side Template Injection)
    • XSLT Server Side Injection (Extensible Stylesheet Languaje Transformations)
Powered by GitBook
On this page

Curl

curl http://dada.com -output - #to tell its not binary file
#GET Request
#-v for verbose output
Staphy$ curl http://staphysce.com/ -v 

# cURL - Basic AUTH Login
Staphy$  curl http://admin:password@staphysec.com/ -vvv

#Alternately, the "`-u`" flag can be used to specify credentials as well.
Staphy$  curl -u admin:password  http://staphysec.com/ -vvv

#cURL - Basic AUTH Login & Follow Redirections
Staphy$ curl -u admin:password -L http://staphysec.com/

#cURL - GET Request With Parameter
Staphy$ curl -u admin:password 'http://staphysec.com/search.php?port_code=us'

#POST Method
The "`-L`" flag instructs curl to follow redirections.
The default "`Content-Type`" used by `cURL` is "`application/x-www-form-urlencoded`


Staphy$ curl -d 'username=admin&password=password' -L http://staphysce.com/login.php

#### cURL - Debug

The "`-L`" flag instructs curl to follow redirections.
`cURL` automatically sends a POST request when the "`-d`" flag is used. It's found that we're still on the login page even after specifying valid credentials. Let's use the "`-v`" switch to debug this.

```shell-session
Staphy@htb[/htb]$ curl -d 'username=admin&password=password' -L  http://staphysec.com/login.php -v
```
The "`--cookie`" or "`--cookie-jar`" option can be used to specify cookie usage in `cURL`. This can point to `/dev/null` or a file on the disk, where the cookies will be saved.
#cURL - Cookie
Staphy$ curl -d 'username=admin&password=password' -L --cookie-jar /dev/null  http://staphysec.com/login.php -v

#cURL - Cookie File
Staphy$ curl -d 'username=admin&password=password' -L --cookie-jar cookies.txt  http://staphysec.com/login.php

Specifying a file name as the argument saves the cookies to a file, which can be used to access the page later directly.
Staphy$ curl --cookie cookies.txt http://staphysec.com/admin/dashboard.php -v


#Content-Type header
#It's also possible to send JSON data using `cURL`. This can be done by specifying the "`application/json`" header with the "`-H`" flag.
Staphy$ curl -H 'Content-Type: application/json' -d '{ "username" : "admin", "password" : "password" }' --cookie-jar /dev/null -L  http://staphysec.com/login.php

#PUT and DELETE Methods
#The "`-X`" option can be used to specify the request method to use.
Staphy$ curl -X OPTIONS http://staphysec.com/ -vv


#cuRL - File Upload
Staphy$ curl -X PUT -d @test.txt http://staphysec.com/test.txt -vv

#cURL - DELETE Method
Staphy$ curl -X DELETE http://staphysec.com/test.txt -vv
PreviousCheatsheetNextCracking

Last updated 3 years ago