F
F
freshcot2015-10-28 15:10:35
linux
freshcot, 2015-10-28 15:10:35

How to remove multiple lines from a file?

Hello, I need a bash command that can remove this from .htaccess files:

RewriteEngine On
RewriteBase /
RewriteRule \.(jpg|png|gif|jpeg|bmp)$ - [L]
RewriteCond %{HTTP_USER_AGENT} android|bb\d+...

But leave the WordPress rules:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /crystal/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /crystal/index.php [L]
</IfModule>

# END WordPress

At the same time, the necessary lines can be located both at the beginning and at the end of the file.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
NO_GLITCH, 2015-10-28
@NO_GLITCH

You should change the owner of the file to root and give read-only access so that no one steals traffic from you.

V
Victor Taran, 2015-10-30
@shambler81

1. option to remove the virus, as far as I understand the problem is that you constantly have to remove its consequences. Try ai-bolit.php
2. It's really easier for you to install a php proger, since there are more possibilities in pregmatch than in the console.
3. If you want to use bash, then sed is in your hands, and regular expressions, by the way, too.
You only need to remove two lines

RewriteRule \.(jpg|png|gif|jpeg|bmp)$ - [L]
RewriteCond %{HTTP_USER_AGENT} android|bb\d+...

The rest won't bother you.
4. Disable just do htaccess on the site and move the necessary configs to the virtual host
5. Go to nginx and do the same thing but in nginx
But it's better to find the vulnerability and remove the virus.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question