Page 1 of 1

c3284d Virus automatisch entfernen

Posted: 2012-09-09 17:53
by tj051069
Habe das Problem das von einem Kunden mehrere Seiten durch einen Virus verunreinigt wurden.
Ich habe einen sehr guten Lösungsansatz gefunden um infizierte Dateien zu bereinigen.

Code: Select all

awk 'BEGIN { clean=1 } /#c3284d#/ { clean=0 } /#\/c3284d#/ { clean=1 } { if (clean==1 && match($0,"#\/c3284d#") == 0) { print $0 } }' dirty-file > clean-file
Von dieser Webseite: http://stackoverflow.com/questions/1149 ... new-answer
Gibt es jemanden der dieses Script so erweitern kann dass infizierte Dateien gesucht werden und zur Sicherheit einmal als .xy-Infiziert anlegt und die bereinigte Version mit Orginalnamen wieder anlegt.

Gruß
Thomas

Re: c3284d Virus automatisch entfernen

Posted: 2012-09-09 18:49
by Joe User
Du suchst diese Lösungen: http://stackoverflow.com/questions/1104 ... place-html
Dazu kommt dann dieser Parameter:

Code: Select all

-i [SUFFIX]
--in-place[=SUFFIX]
    This option specifies that files are to be edited in-place. GNU sed does this by creating a temporary file and sending output to this file rather than to the standard output.1.

    This option implies -s.

    When the end of the file is reached, the temporary file is renamed to the output file's original name. The extension, if supplied, is used to modify the name of the old file before renaming the temporary file, thereby making a backup copy2).

    This rule is followed: if the extension doesn't contain a *, then it is appended to the end of the current filename as a suffix; if the extension does contain one or more * characters, then each asterisk is replaced with the current filename. This allows you to add a prefix to the backup file, instead of (or in addition to) a suffix, or even to place backup copies of the original files into another directory (provided the directory already exists).

    If no extension is supplied, the original file is overwritten without making a backup.
Siehe: http://www.gnu.org/software/sed/manual/sed.html

Re: c3284d Virus automatisch entfernen

Posted: 2012-09-09 19:48
by tj051069
Hi Joe,

ja genau. Das Problem ist das ich nichts mit programmieren am Hut habe.
Es müsste zum Schluss qasi ein Skript sein das mit der obigen Skript
Und

Code: Select all

find -R "#c3284d#" /var/www/
Dateien sucht.

Re: c3284d Virus automatisch entfernen

Posted: 2012-09-09 23:03
by Joe User
Ungetestet, daher bitte zuerst mit Testdaten testen:

Code: Select all

find /var/www -type f -name *.html -print0 | xargs -0 sed 's/#c3284d#.*#c3284d#/malware removed/ig' -i .infected
Findet alle Dateien mit der Dateiendung .html und ersetzt darin zeilenweise Alles zwischen und inklusive der zwei #c3284d# oder #C3284D# mit dem Text malware removed und legt gleichzeitig ein Backup der originalen Dateien mit der Dateiendung .infected an.

Das lässt sich natürlich noch nahezu beliebig erweitern, dazu muss man aber exaktere Angaben zum Ist-Zustand und Soll-Zustand haben.