Scan Linux System for Malware and Rootkits

Gerade auf HowToForge einen guten Artikel über 3 Werkzeuge gefunden, mit dem man sein Linux-System auf Schädlingsbefall in Form von Malware und Rootkits überprüfen kann.

chkrootkit – der Linux rootkit scanner – ist der Klassiker unter den Scannern und prüft auf bestimmte Prozesse und Dateien, die bei RK Befall vorhanden sein können.
Aufruf: „~# chkrootkit“ – die Ausgabe auf der Console erklärt sich von selbst.

lynis – ehemals rkhunter – ist ein universelles Rootkit Scanner Tool, welches neben den Infektionsstatus auch noch eine Menge nützlicher Informationen zum Verbessern der Systemstabilität ausgibt. Die Konsolenausgabe ist hier ebenfalls sehr umfangreich und detailliert.
Mit „~# lynis update info“ wird die Definition aktualisisiert.
Den Check startet man mit „~# lynis audit system“.

ISPProtect ist ein Website Malware Scanner, mit dem Schwachstellen in den installierten Systemen aufgedeckt und Infektionen erkannt werden können. Veraltete oder unsichere Versionen von WordPress, MySQL etc werden erkannt.
ISPProtect ist keine freie Software, es gibt aber eine kostenlose Trial-Version.

Zum HowTo-Forge-Artikel: https://www.howtoforge.com/tutorial/how-to-scan-linux-for-malware-and-rootkits/

curl: show header only / http get

If you only want to show the headers of your http response, you may want to use the following switches:

  • -D = dump headers
  • -s = silent mode
  • -o /dev/null = send all output do dev null

The curl request looks like this:

$ curl -s -D - https://www.path.to/my.file -o /dev/null

The output should looks like this:

HTTP/2 200
last-modified: Tue, 13 Dec 2016 12:08:30 GMT
etag: W/"183836-1481630910000"
server: Apache
x-magnolia-registration: Registered
pragma: no-cache
content-type: application/x-font-otf;charset=UTF-8
content-length: 183836
accept-ranges: bytes
cache-control: public, max-age=8236
expires: Mon, 02 Jan 2017 13:11:32 GMT
date: Mon, 02 Jan 2017 10:54:16 GMT

Piwik – open source web analytics software

Piwik is a downloadable, open source (GPL licensed) web analytics software program. It provides you with detailed reports on your website visitors: the search engines and keywords they used, the language they speak, your popular pages… and so much more.

Piwik aims to be an open source alternative to Google Analytics.

Piwik is a PHP MySQL software program that you download and install on your own webserver. At the end of the five minute installation process you will be given a JavaScript tag. Simply copy and paste this tag on websites you wish to track (or use an existing plugin to do it automatically for you).

URL: piwik.org

Search engine friendly rewrite rule

In case of you want to map multiple domains to one web site, or you changed your domain, and you wand to avoid Google indexing issues, you need to permanent redirect with HTTP 301 code.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.old-domain.de$ [NC]
RewriteRule ^.*$ http://www.new-domain.de%{REQUEST_URI} [R=301,L]

Rewriting URL’s without a leading „www“ to the same URL with www-prefix is possible on the same way:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^my-domain.de$ [NC]
RewriteRule ^.*$ http://www.my-domain.de%{REQUEST_URI} [R=301,L]

Note: mod_rewrite must be enabled to make this code work.

Apache Tomcat und mod_jk / ajp13 auf SuSE Linux

Nach wie vor ist der Apache Httpd schneller als ein Apache Tomcat, wenn es um die Auslieferung von statischen Inhalten geht. Gerade in Verbindung mit Tomcat bietet der Apache Httpd noch weitere Vorteile: durch das Modul mod_jk kann eine ganze Farm an Tomcat-Servern per Load Balancer angeschlossen werden!

Für den Betrieb benötigt man:

  • einen funktionierenden Apache Httpd-Server
  • einen funktionierenden Apache Tomcat-Server
  • das Modul mod_jk, welches auf der Tomcat-Webseite zum download erhältlich ist

Das Modul habe ich zur Vereinfachung nach dem Download in „mod_jk.so“ umbenannt und im Lib-Verzeichnis des Apache Httpd abgelegt (auf SuSE Linux 10.2: /usr/lib/apache2).

Der Apache Httpd ist auf SuSE Linux so konfiguriert, dass alle Dateien, die auf *.conf enden und in /etc/apache2/conf.d liegen, automatisch zu httpd.conf (bzw default-server.conf) included werden. Das macht die weitere Konfiguration einfach, denn nun müssen in dem o.g. Verzeichnis nur zwei Konfigurationsdateien abgelegt werden.

Die Datei tomcat.conf bindet mod_jk ein:

# Load mod_jk module
# Update this path to match your modules location
LoadModule jk_module /usr/lib/apache2/mod_jk.so
# Declare the module for <IfModule directive> (remove this line on Apache 2.x)
#AddModule mod_jk.c

# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /etc/apache2/conf.d/workers.properties

# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile /var/log/apache2/mod_jk.shm

# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/apache2/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel debug

# Select the timestamp log format
JkLogStampFormat „[%a %b %d %H:%M:%S %Y] “

# Send everything for context /examples to worker named worker1 (ajp13)
JkMount /application/* worker1

In der Datei müssen ggf. die Pfade zu mod_jk.so sowie zu den Log-Files angepasst werden.
Mit JkWorkersFile wird auf die Konfigurationsdatei des mod_jk referenziert. Alle Anfragen im Format http://www.domain.tld/application werden nun an mod_jk übergeben.

Die Datei workers.properties ist – sofern nur ein einziger Tomcat-Server angebunden werden muss, sehr kurz:

# Define 1 real worker using ajp13
# this coud be al list in the format
# worker.list=worker1, worker2, worker3, worker4
worker.list=worker1

# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

Das Format zum Konfigurieren der einzelnen Worker ist also worker.<workername>.<property> . In der Beispielkonfiguration wird also nur ein Worker mit dem Namen „worker1“ genutzt, der auf dem gleichen Host läuft und mittels dem Protokoll ajp13 angesprochen wird.

Über die URL http://www.<domain>.<tld>/application erreicht man nun also direkt die Application auf dem Tomcat.

Quellen & weiterführende Links:

Weiterleiten mit .htaccess

Auf über 60% aller Webserver läuft ein Apache Httpd-Server. Zu Recht, denn der Apache-Server beweist immer wieder seine vielfältigen Fähigkeiten und hohe Zuverlässigkeit.

Ein wichtiges Feature ist die .htaccess-Datei, mit der sich Zugriffe auf Verzeichnisse „umdefinieren“ lassen können – so zum Beispiel auch Weiterleitungen realisieren lassen:

Redirect /verzeichnis http://www.my-container.de

… leitet alle Anfragen an http://www.my-container.de/verzeichnis direkt an http://www.my-container.de weiter.

Das funktioniert auch mit einzelnen Dateien, als Ziel ist natürlich auch ein anderes Verzeichnis gültig:

Redirect testdatei.html http://www.my-container.de
Redirect /verzeichnis /anderesVerzeichnis

Und auf die gleiche Weise kann auch eine ganze Domain umgeleitet werden:

Redirect / http://www.my-container.de

Diese Umleitungsfunktionen sind unabhängig vom verwendeten Browser und werden nur vom Server gesteuert. Somit funkltioniert diese Technik auch bei Browsern, die z.B. die Meta-Angabe „meta redirect“ nicht interpretieren.