Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to block CURL to fetch data on my site?

Tags:

php

curl

I currentyly use this code to block wget and libwww

Options +FollowSymlinks  
RewriteEngine On  
RewriteBase /  
SetEnvIfNoCase User-Agent "^Wget" bad_user
SetEnvIfNoCase User-Agent "^libwww-perl" bad_user
Deny from env=bad_user

is there one for curl?

like image 722
eric Avatar asked Nov 13 '11 19:11

eric


People also ask

Can websites block cURL?

Servers cannot block cURL requests per se, but they can block any request that they do not like. If the server checks for some parameters that your cURL request does not satisfy, it could decide to respond differently.

What is cURL get request?

GET Request with cURL -v is used to get verbose output. This will give the following output. The verbose result has details like status code, Content Type, Content Length and so on. It can be used to get a better idea of what happened during the HTTP request.

How do cURL requests work?

The client, curl, sends an HTTP request. The request contains a method (like GET, POST, HEAD etc), a number of request headers and sometimes a request body. The HTTP server responds with a status line (indicating if things went well), response headers and most often also a response body.

How to write a cURL request?

To make a GET request using Curl, run the curl command followed by the target URL. Curl automatically selects the HTTP GET request method unless you use the -X, --request, or -d command-line option. The target URL is passed as the first command-line option.


2 Answers

Yes, I am sure curl has a default User-Agent, but that is obviously something that can be changed as easily as -H 'User-Agent=Poop'

In fact, I think there is a switch specifically for setting the user agent. -A

like image 64
sberry Avatar answered Oct 26 '22 22:10

sberry


curl user agents can be changed at any time. The reason curl exists is that you can change pretty much everything on your query.

You can block them, but once they change the use agent, they will have access again.

I recommend you block the IP address instead or the whole subnet just to be sure.

Example:

deny from aa.bb.cc.dd  ff.gg.hh.0/24
like image 44
Dimme Avatar answered Oct 26 '22 22:10

Dimme