wtorek, 3 marca 2020

Lock python-requests and other bots in htaccess

Enable mod_version

## Automated HTTP libraries
RewriteCond %{HTTP_USER_AGENT} ^.*(dav.pm/v|libwww-perl|urllib|python-requests|python-httplib2|winhttp.winhttprequest|lwp-request|lwp-trivial|fasthttp|Go-http-client|Java|httplib|httpclient|Zend_Http_Client).*$ [NC]
RewriteRule .* - [F,L]

## Commonly seen in DDoS attacks
RewriteCond %{HTTP_USER_AGENT} ^.*(CtrlFunc|w00tw00t|Apachebench).*$ [NC]
RewriteRule .* - [F,L]

czwartek, 23 stycznia 2020

Sed: remove javascript from files

grep -Ril same.js | xargs sed -i "s/<script type='text\/javascript' src='https:\/\/localhost\/same.js'><\/script>//g"