Faking your cURL User Agent

cURL is an amazing command line utility to connect to a plethora of online protocols. Expect many tutorials on this incredible tool in the near future πŸ™‚

What is this?

For now we are going to discuss faking cURLs user agent. Faking your user agent simply means you are pretending to be something you are not πŸ˜‰. This can be useful if you are using cURL to access an internet resource and don’t want to identify you are using cURL. You can preform this by the following three different ways:

  • curl -A "user-agent-name-here" <url>
  • curl --user-agent "user-agent-name-here" <url>
  • curl -H "User-Agent: user-Agent-Name-Here" <url>

Testing Your User Agent

When faking your user agent you will want to make sure it’s working. I created a handy web page HERE to help you out. To run the test, run the following command:

curl -sSL -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36" https://geekalicious.club/ip

If your useragent comes back as curl you will see the results formatted in readable text. If you have a browser as your useragent it will spit back html formatted text.

Using Lynx to Read HTML

You can decipher formatted html on the command line with the help of lynx:

curl -sSL -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36" https://geekalicious.club/ip | lynx -stdin -dump

.curlrc

BONUS: Use the one-liner below to permanently masquerade as a Mozilla browser (Added to your .curlrc file).

echo 'user-agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"' | tee -a ${HOME}/.curlrc

More User Agents

Here is a listing of different user agents. Have fun!

πŸ‘ Get Blog Updates

πŸ“ Latest Posts

0Shares
0

Leave a Reply