Zum Inhalt springen

MarioKuschel

Mitglieder
  • Gesamte Inhalte

    3
  • Benutzer seit

  • Letzter Besuch

  1. Ja das sieht sehr interessant aus. Danke Lupo Hab das Ding ja au nur gemacht um Pyhton zu lernen Ne super mächtige Scriptsprache, die einfach zu lernen ist Solltet ihr euch bei Gelegenheit mal rauf schaffen
  2. Kennt ihr BootMyISO ? Das gibs unter anderem auch als Windows exe und macht ungefähr genau das gleiche wie du vor hast Syslinux -> Grub -> OS ... dead simple ... Kennt ihr Darren von Hak5? Der hat vor ner Weile sowas ähnliches gemacht in der Episode
  3. Nice catch, t3quill4b0y Komplizierter Weg: Du machst das über nen Python Script, welches /var/log/auth.log durchwühlt und nen Iptables Script schreibt um die bösen Leute wegzuschließen. Allerdings nur die bösen Leute, welche versucht haben sich per SSH mit nem User anzumelden, den es nicht gibt. "Failed password for invalid user userxy from 61.178.14.112 port 49549 ssh2" Ich weiß das Ding hat noch Macken Z.B. dass mein Server abschmiert, wenn ich zuviele Iptables regeln reinballer xD (meine auth.log is > 120MB groß und gibt mir 520 einzigartige IP Adresse von bösen Leuten Oo) iptables: Memory allocation problem iptables: Memory allocation problem iptables: Memory allocation problem iptables: Memory allocation problem iptables: Memory allocation problem iptables: Memory allocation problem iptables: Memory allocation problem iptables: Memory allocation problem iptables: Memory allocation problem Python Script #!/usr/bin/python -tt import re import sys import os import stat def main(): file = open("/var/log/auth.log","r") text = file.read() file.close() liste = re.findall(r"Failed password for invalid user \w+ from (\d+.\d+.\d+.\d+) port \d+",text) #Zu filternder String: Sep 16 16:24:54 pv321 sshd[5236]: Failed password for invalid user userxy from 61.178.14.112 port 49549 ssh2 unique_liste = [] for i in range (0,len(liste)): if liste[i] not in unique_liste: unique_liste.append(liste[i]) outputfile = open("/skripte/iptables.sh","w") outputfile.write("#!/bin/sh" + "\n") outputfile.write("IPTABLES=/sbin/iptables" + "\n") outputfile.write("$IPTABLES -F" + "\n") outputfile.write("$IPTABLES -P INPUT ACCEPT" + "\n") outputfile.write("$IPTABLES -P OUTPUT ACCEPT" + "\n") outputfile.write("$IPTABLES -P FORWARD ACCEPT" + "\n") #Automatisch erzeugte Regeln outputfile.write("#---- Automatisch erzeugte Regeln ----" + "\n") for i in range (0,len(unique_liste)): outputfile.write("$IPTABLES -I INPUT -s " + unique_liste[i] + " -i venet -j DROP" + '\n') outputfile.write("#-------------------------------------" + "\n") outputfile.write("###### forwarding ######" + "\n") outputfile.write("echo 1 > /proc/sys/net/ipv4/ip_forward" + "\n") outputfile.write("exit" + "\n") outputfile.close() #Dateirechte vergeben -rwx------ os.chmod("/skripte/iptables.sh", 448) if __name__ == '__main__': main() Durch das Python Script erstelltes Iptables Script #!/bin/sh IPTABLES=/sbin/iptables $IPTABLES -F $IPTABLES -P INPUT ACCEPT $IPTABLES -P OUTPUT ACCEPT $IPTABLES -P FORWARD ACCEPT #---- Automatisch erzeugte Regeln ---- $IPTABLES -I INPUT -s 77.39.19.67 -i venet -j DROP $IPTABLES -I INPUT -s 72.252.208.230 -i venet -j DROP $IPTABLES -I INPUT -s 94.229.71.27 -i venet -j DROP $IPTABLES -I INPUT -s 211.38.137.44 -i venet -j DROP $IPTABLES -I INPUT -s 62.166.203.250 -i venet -j DROP $IPTABLES -I INPUT -s 203.125.118.252 -i venet -j DROP $IPTABLES -I INPUT -s 60.250.38.179 -i venet -j DROP #------------------------------------- ###### forwarding ###### echo 1 > /proc/sys/net/ipv4/ip_forward exit Iptables -L Ausgabe root@pv321:/skripte# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination DROP 0 -- 60-250-38-179.HINET-IP.hinet.net anywhere DROP 0 -- 203.125.118.252 anywhere DROP 0 -- cust203-250.dsl.as47377.net anywhere DROP 0 -- 211.38.137.44 anywhere DROP 0 -- no.rdns-yet.ukservers.com anywhere DROP 0 -- 72.252.208.230 anywhere DROP 0 -- 77.39.19.67 anywhere Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination Zu kompliziert? Zieht auch die Pyhton Classes von Google rein..fängt an.

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...