PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Kann vielleicht jemand mir diesen Skript als ausführbare Textdatei machen?



Seiten : [1] 2

ThugLuv
05.01.03, 17:15
Hi
kann jemand diesen Iptables Skript mir als Ausführbares Textdatei machen?Gut wär firewall.sh
Danke.Ich konnte ees selbst nicht machen da kommt immer dieser fehler:
wenn ich schreibe:
./firewall.sh
MeinName tty1 Jan 5 12:56
./firewall.sh: line 155: syntax error near unexpected token `newline'
./firewall.sh: line 155: ` for i in /proc/sys/net/ipv4/conf/*; do echo 1 > $i/log_martians 2>'


Also hier der Skript:
#!/bin/bash
# ---------------------------------------------------------------------
# Linux-iptables-Firewallskript, Copyright (c) 2003 under the GPL
# Autogenerated by iptables Generator v1.12 (c) 2002 by Harald Bertram
# Please visit http://www.harry.homelinux.org for new versions of
# the iptables Generator (c).
#
# This Script was generated by request from:
# tolga@genion.de on: 2003-1-5 15:52.25 MET.
#
# If you have questions about the iptables Generator or about
# your Firewall-Skript feel free to take a look at out website or
# send me an E-Mail to webmaster@harry.homelinux.org.
#
# My special thanks are going to Lutz Heinrich (trinitywork@hotmail.com)
who
# made lots of Beta-Testing and gave me lots of well qualified
# Feedback that made me able to improve the iptables Generator.
# --------------------------------------------------------------------

case "$1" in
start)
echo "Starte IP-Paketfilter"

# iptables-Modul
modprobe ip_tables
# Connection-Tracking-Module
modprobe ip_conntrack
# Das Modul ip_conntrack_irc ist erst bei Kerneln >= 2.4.19 verfuegbar
modprobe ip_conntrack_irc
modprobe ip_conntrack_ftp

# Tabelle flushen
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X
iptables -t nat -X
iptables -t mangle -X

# Default-Policies setzen
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

# MY_REJECT-Chain
iptables -N MY_REJECT

# MY_REJECT fuellen
iptables -A MY_REJECT -p tcp -m limit --limit 7200/h -j LOG --log-prefix
"REJECT TCP "
iptables -A MY_REJECT -p tcp -j REJECT --reject-with tcp-reset
iptables -A MY_REJECT -p udp -m limit --limit 7200/h -j LOG --log-prefix
"REJECT UDP "
iptables -A MY_REJECT -p udp -j REJECT --reject-with icmp-port-unreachable
iptables -A MY_REJECT -p icmp -m limit --limit 7200/h -j LOG --log-prefix
"DROP ICMP "
iptables -A MY_REJECT -p icmp -j DROP
iptables -A MY_REJECT -m limit --limit 7200/h -j LOG --log-prefix
"REJECT OTHER "
iptables -A MY_REJECT -j REJECT --reject-with icmp-proto-unreachable

# MY_DROP-Chain
iptables -N MY_DROP
iptables -A MY_DROP -m limit --limit 7200/h -j LOG --log-prefix "PORTSCAN
DROP "
iptables -A MY_DROP -j DROP

# Alle verworfenen Pakete protokollieren
iptables -A INPUT -m state --state INVALID -m limit --limit 7200/h
-j LOG --log-prefix "INPUT INVALID "
iptables -A OUTPUT -m state --state INVALID -m limit --limit 7200/h
-j LOG --log-prefix "OUTPUT INVALID "

# Korrupte Pakete zurueckweisen
iptables -A INPUT -m state --state INVALID -j DROP
iptables -A OUTPUT -m state --state INVALID -j DROP

# Stealth Scans etc. DROPpen
# Keine Flags gesetzt
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j MY_DROP

# SYN und FIN gesetzt
iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j MY_DROP

# SYN und RST gleichzeitig gesetzt
iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j MY_DROP

# FIN und RST gleichzeitig gesetzt
iptables -A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j MY_DROP

# FIN ohne ACK
iptables -A INPUT -p tcp --tcp-flags ACK,FIN FIN -j MY_DROP

# PSH ohne ACK
iptables -A INPUT -p tcp --tcp-flags ACK,PSH PSH -j MY_DROP

# URG ohne ACK
iptables -A INPUT -p tcp --tcp-flags ACK,URG URG -j MY_DROP

# Loopback-Netzwerk-Kommunikation zulassen
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

# Connection-Tracking aktivieren
iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# HTTP
iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 80
-j ACCEPT

# HTTPS
iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 443
-j ACCEPT

# POP3
iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 110
-j ACCEPT

# IRC
iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 6667
-j ACCEPT

# EDONKEY
iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 4661
-j ACCEPT
iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 4662
-j ACCEPT
iptables -A INPUT -i ppp0 -m state --state NEW -p tcp --dport 4663
-j ACCEPT
iptables -A INPUT -i ppp0 -m state --state NEW -p udp --dport 4665
-j ACCEPT

# Default-Policies mit REJECT
iptables -A INPUT -j MY_REJECT
iptables -A OUTPUT -j MY_REJECT

# SYN-Cookies
echo 1 > /proc/sys/net/ipv4/tcp_syncookies 2> /dev/null

# Stop Source-Routing
for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/accept_source_route
2> /dev/null; done

# Stop Redirecting
for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/accept_redirects
2> /dev/null; done

# Reverse-Path-Filter
for i in /proc/sys/net/ipv4/conf/*; do echo 2 > $i/rp_filter 2> /dev/null;
done

# Log Martians
for i in /proc/sys/net/ipv4/conf/*; do echo 1 > $i/log_martians 2>
/dev/null; done

# BOOTP-Relaying ausschalten
for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/bootp_relay 2>
/dev/null; done

# Proxy-ARP ausschalten
for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/proxy_arp 2> /dev/null;
done

# Ungültige ICMP-Antworten ignorieren
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses 2>
/dev/null

;;

stop)
echo "Stoppe IP-Paketfilter"
# Tabelle flushen
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X
iptables -t nat -X
iptables -t mangle -X
echo "Deaktiviere IP-Routing"
echo 0 > /proc/sys/net/ipv4/ip_forward

# Default-Policies setzen
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
;;

status)
echo "Tabelle filter"
iptables -L -vn
echo "Tabelle nat"
iptables -t nat -L -vn
echo "Tabelle mangle"
iptables -t mangle -L -vn
;;

*)
echo "Fehlerhafter Aufruf"
echo "Syntax: $0 {start|stop|status}"
exit 1
;;

esac

HangLoose
05.01.03, 17:31
hi

ausführbar ist das script schon, du kannst es ja starten. allerdings bricht es wegen einem syntaxfehler im script ab.


./firewall.sh: line 155: syntax error near unexpected token `newline' ./firewall.sh: line 155: ` for i in /proc/sys/net/ipv4/conf/*; do echo 1 > $i/log_martians 2>'

ich weiß aber nicht genau, weswegen er dort rummault.


Gruß HL

tomes
05.01.03, 18:21
wirklich so aus wie in dem Beitrag ? --> z.B.


# Log Martians
for i in /proc/sys/net/ipv4/conf/*; do echo 1 > $i/log_martians 2>
/dev/null; done
Das muesste so aussehen -->
# Log Martians
for i in /proc/sys/net/ipv4/conf/*; do echo 1 > $i/log_martians 2> /dev/null; done
oder so -->
# Log Martians
for i in /proc/sys/net/ipv4/conf/*; do echo 1 > $i/log_martians 2> \
/dev/null; done
Also alles im einer Line oder am Ende ein Backslash
Bei allen deiner Zeilen !!!

T;o)Mes

ThugLuv
05.01.03, 19:08
Dann dachte ich es hat geklappt(danke für den Tipp)
und schrieb:
als root
./firewall.sh
dann kam
MeinName tty1 Jan 5 12:56
Fehlerhafter Aufruf
Syntax: ./firewall.sh {start|stop|status}
Okey schireb ich dann:
./firewall.sh start aber dann:
MeinName tty1 Jan 5 12:56
Starte IP-Paketfilter
./firewall.sh: line 26: modprobe: command not found
./firewall.sh: line 28: modprobe: command not found
./firewall.sh: line 30: modprobe: command not found
./firewall.sh: line 31: modprobe: command not found
./firewall.sh: line 34: iptables: command not found
./firewall.sh: line 35: iptables: command not found
./firewall.sh: line 36: iptables: command not found
./firewall.sh: line 37: iptables: command not found
./firewall.sh: line 38: iptables: command not found
./firewall.sh: line 39: iptables: command not found
./firewall.sh: line 42: iptables: command not found
./firewall.sh: line 43: iptables: command not found
./firewall.sh: line 44: iptables: command not found
./firewall.sh: line 47: iptables: command not found
./firewall.sh: line 50: iptables: command not found
./firewall.sh: line 51: REJECT TCP : command not found
./firewall.sh: line 52: iptables: command not found
./firewall.sh: line 53: iptables: command not found
./firewall.sh: line 54: REJECT UDP : command not found
./firewall.sh: line 55: iptables: command not found
./firewall.sh: line 56: iptables: command not found
./firewall.sh: line 57: DROP ICMP : command not found
./firewall.sh: line 58: iptables: command not found
./firewall.sh: line 59: iptables: command not found
./firewall.sh: line 60: REJECT OTHER : command not found
./firewall.sh: line 61: iptables: command not found
./firewall.sh: line 64: iptables: command not found
./firewall.sh: line 65: iptables: command not found
./firewall.sh: line 67: iptables: command not found
./firewall.sh: line 70: iptables: command not found
./firewall.sh: line 71: -j: command not found
./firewall.sh: line 72: iptables: command not found
./firewall.sh: line 73: -j: command not found
./firewall.sh: line 76: iptables: command not found
./firewall.sh: line 77: iptables: command not found
./firewall.sh: line 81: iptables: command not found
./firewall.sh: line 84: iptables: command not found
./firewall.sh: line 87: iptables: command not found
./firewall.sh: line 90: iptables: command not found
./firewall.sh: line 93: iptables: command not found
./firewall.sh: line 96: iptables: command not found
./firewall.sh: line 99: iptables: command not found
./firewall.sh: line 102: iptables: command not found
./firewall.sh: line 103: iptables: command not found
./firewall.sh: line 106: iptables: command not found
./firewall.sh: line 107: iptables: command not found
./firewall.sh: line 110: iptables: command not found
./firewall.sh: line 111: -j: command not found
./firewall.sh: line 114: iptables: command not found
./firewall.sh: line 115: -j: command not found
./firewall.sh: line 118: iptables: command not found
./firewall.sh: line 119: -j: command not found
./firewall.sh: line 122: iptables: command not found
./firewall.sh: line 123: -j: command not found
./firewall.sh: line 126: iptables: command not found
./firewall.sh: line 127: -j: command not found
./firewall.sh: line 128: iptables: command not found
./firewall.sh: line 129: -j: command not found
./firewall.sh: line 130: iptables: command not found
./firewall.sh: line 131: -j: command not found
./firewall.sh: line 132: iptables: command not found
./firewall.sh: line 133: -j: command not found
./firewall.sh: line 136: iptables: command not found
./firewall.sh: line 137: iptables: command not found

:-(
Bitet brauche jetzt Hilfe...
Danke

HackThor
05.01.03, 19:11
1) Hast du die "iptables" installiert? Wenn nein, machen.
2) wie machst du dich zum root? "su"? Nimm "su -", dann werden auch die Pfade (inkl. /sbin, /usr/sbin) richtig gesetzt.

ciao

Michael

ThugLuv
05.01.03, 19:15
ich glaube schon das ich Iptables hab:
locate iptables ergab das es bei /sbin/iptables ist

und ich gabe diesen Befehl als Root ein:
./firewall.sh start

HangLoose
05.01.03, 19:28
und wie sieht's mit modprobe aus?

ThugLuv
05.01.03, 19:29
was ist das?
Sorry aber weiss echt nicht:-(

HangLoose
05.01.03, 19:34
tipp mal whereis modprobe in die konsole

ThugLuv
05.01.03, 19:35
dann kommt das:

modprobe: /sbin/modprobe /usr/share/man/man8/modprobe.8.gz

Jinto
05.01.03, 19:35
Tipp einfach mal:
which iptables modprobe

locate liefert dir die Informationen aus der DB und nicht anhand der PATH Variablen.

HTH

HangLoose
05.01.03, 19:37
und jetzt nochmal als root echo $PATH

ThugLuv
05.01.03, 19:41
@HangLoose:
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/Tolga/bin
@Jinto:
/usr/bin/which: no iptables in (/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/Tolga/bin)
/usr/bin/which: no modprobe in (/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/Tolga/bin)

tomes
05.01.03, 19:42
1. Ueberpruefe dein Script nocheinmal
Stichwort --> Fehler in line 26
und -->


#
# My special thanks are going to Lutz Heinrich (trinitywork@hotmail.com)
who
# made lots of Beta-Testing and gave me lots of well qualified

Sonst "einfach" im Script -->
ersetzen von
iptables in $iptables
und
modprobe in $modprobe
dann
modrobe="/sbin/modprobe"
iptables="/sbin/iptables"
Am Anfang des Scripts.

Automatisch suchen und ersetzen kann jeder gute Editor ;)

T;o)Mes
P.S.: Oder einfach ein -->
export PATH=$PATH:/sbin
am Anfang des Scripts ;)

HangLoose
05.01.03, 19:46
hi


/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/Tolga/bin

das ist aber nicht der root PATH. kann es sein, das du das script auch nicht als root gestartet hast?

tomes
05.01.03, 19:50
Original geschrieben von HangLoose
hi



das ist aber nicht der root PATH. kann es sein, das du das script auch nicht als root gestartet hast?
Bestimmt nicht :D siehe Beitrag von @HackThor

T;o)Mes

ThugLuv
05.01.03, 19:50
nee,auch mit export PATH=$PATH:/sbin immer noch nicht:-(
Könnte denn keiner von euch irgendwie die Skript datei verändern?
Ich lade sie mla trotzdem hoch als .Txt datei
@HangLoose
hab ich nochmal zur Sicherheit als Root ausgeführt:

/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/Tolga/bin

HackThor
05.01.03, 19:56
ARGH
Mach doch bitte einfach in deiner Root-Shell ein CONTROL+D (shell beenden), dann "su -" (s, u, leerzeichen, minus), Root-Password, wieder in das Verzeichnis mit dem Script wechseln und dann "./firewall start". Durch das "su" (ohne das Minus) hast du keine Login-Shell erzeugt sonder nur eine "interaktive". Bei der wird aber die /etc/profile nicht ausgefürt und damit der Root-Pfad (also mit /sbin und /usr/sbin) nicht gesetzt. Durch das "su -" machst du eine neue Login-Shell (du stehst dann in /root, deshalb das Wechseln der Verzeichnisses), da sind dann alle Pfade im $PATH vorhanden und modprobe und iptables werden auch gefunden.

ciao

Michael

PS: Sorry, das ARGH ist nicht persönlich gemeit. Aber mir war so danach :)

RTC
05.01.03, 19:57
Der Variablenteil "/home/*" zeigt, dass PATH nicht die Variable von root ist. Das passiert immer, wenn die gerade aktive Shell keine Login-Shell ist. Ich kann mir auch nur vorstellen, dass du "su" ausgeführt und dann das Skript gestartet hast!
Wie oben beschrieben "su -" oder "su -l" eingeben, dann das Root-Passwort und dann das Skript ausführen!

ThugLuv
05.01.03, 20:00
Dann kommt dies: :-(

[root@localhost Tolga]# ./firewall.sh start
Tolga tty1 Jan 5 12:56
Starte IP-Paketfilter
iptables v1.2.6a: Unknown arg `--log-prefix'
Try `iptables -h' or 'iptables --help' for more information.
./firewall.sh: line 51: REJECT TCP : command not found
iptables v1.2.6a: Unknown arg `--log-prefix'
Try `iptables -h' or 'iptables --help' for more information.
./firewall.sh: line 54: REJECT UDP : command not found
iptables v1.2.6a: Unknown arg `--log-prefix'
Try `iptables -h' or 'iptables --help' for more information.
./firewall.sh: line 57: DROP ICMP : command not found
iptables v1.2.6a: Unknown arg `--log-prefix'
Try `iptables -h' or 'iptables --help' for more information.
./firewall.sh: line 60: REJECT OTHER : command not found
./firewall.sh: line 71: -j: command not found
./firewall.sh: line 73: -j: command not found
./firewall.sh: line 111: -j: command not found
./firewall.sh: line 115: -j: command not found
./firewall.sh: line 119: -j: command not found
./firewall.sh: line 123: -j: command not found
./firewall.sh: line 127: -j: command not found
./firewall.sh: line 129: -j: command not found
./firewall.sh: line 131: -j: command not found
./firewall.sh: line 133: -j: command not found

HangLoose
05.01.03, 20:00
hi

entweder hast du dein system ein wenig vermurkst, denn das sieht wie der PATH vom user tolga aus


/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/Tolga/bin

oder du bist wirklich nicht root, beim aufruf des scriptes. hast du mal su - wie von HackThor vorgeschlagen, gemacht? obwohl ich mich auch immer mit einem einfachen su zum root mache.

ps: bin erstmal offline


Gruß HL

RTC
05.01.03, 20:02
Wieso antworten hier alle so schnell *g*.
Wenn du das Skript umschreiben willst, musst du nur immer vor "modprobe" und "iptables" "/sbin/" setzen, ok?!

ThugLuv
05.01.03, 20:02
ja habs mit su - versucht wieder das selbe mit dem Command Not Found .-(

RTC
05.01.03, 20:05
Kein Wunder, dass es die Befehle nicht kennt - es gibt sie ja auch nicht und sie sind nur ein Teil eines iptables-Aufrufs!
D.h. dass die zeilen, bei denen ein Fehler auftaucht, noch zu der vorangegangenen Zeile gehören!
Entweder du lädst dir das Skript mal ordentlich runter, ohne es nur irgendwoher rauszukopieren oder du setzt am Ende einer Zeile, die eigentlich dann weitergeht "\" oder du rückst die Fehlerzeilen um eine Zeiel zurück...

ThugLuv
05.01.03, 20:08
@RTC
1.Wo lade ich mir den Skrip ordentich runter?Also als .sh datei?
2.es ist fast bei jeder Zeile ei fehler...Das würde zu lange dauern.und morgen hab ich Schule:-(
Gehts nicht irgendwie auto.?

HangLoose
05.01.03, 20:08
Original geschrieben von RTC
Wieso antworten hier alle so schnell *g*.

das war mal so'n schönes ruhiges forum (sicherheit) :D

RTC
05.01.03, 20:19
Original geschrieben von HangLoose
das war mal so'n schönes ruhiges forum (sicherheit) :D

Oh Gott, bin ja auch erst neu hier, aber muss wohl lange her gewesen sein :D
Nach dem Motto: "Und was nicht hätte in Vergessenheit geraten dürfen, ging verloren", hm?!

@ThugLuv: na du hast das Skript doch mittels iptables-Generator oder so erstellen lassen. Nur der hat die Zeilen umgebrochen, so dass die Teilbefehle auf einer neuen Zeile stehen. Am besten generierst du es nochmal und wenns immernoch nicht klappt, musst du es wohl per Hand machen...
Frage: dieser Generator, macht der das Skript automatisch in die Datei oder kopierst du es per Hand?

ThugLuv
05.01.03, 20:21
er schickt es mir als email ohne Anhang aber direkt in die Email so das ich kopiert habe und im texteditor eingefügt haben müsste.Wie mache ich es denn ohne Zeilenumbruch?
Danke

Jinto
05.01.03, 20:22
Der Generator befindet sich unter http://harry.homelinux.org und schickt dir das Script per Mail zu.

Wenn du also deinem Mailclient beibringst ausnahmsweise auf den Zeilenumbruch zu verzichten, dann kannst du es ganz normalmit Copy&Paste kopieren.

HTH

Jinto
05.01.03, 20:23
Das geht hier ja zu wie im Taubenschlag ;)
Welchen Mailclient verwendest du denn?

NACHTRAG:
Bei mir wird das Script als Attachment angezeigt, kann es sein das mit deinem Mailclient etwas nicht stimmt?