~scripts
55 itemsDownload ./*

55 itemsDownload ./*

..
dzen2
tiling
vosh
4cdl
4trips
alarm
ambient
ana-wall.sh
battery-monitor
brightness.sh
checkit
cleverbot.py
clock
color-gen
colors-hex
colorscheme.sh
compton
dailywall
dmenu
ffthumb
grid
gridmacro
gridmacro.kde
help
importw
indexer
install-all.sh
install-twily.sh
installng
keep-on
mp3ogg
orage
pipes
pipes.x
pipewire_bt.sh
ports
rain
randwall
rotate.sh
scan.sh
screen-dim
screencast
screencast2
scrot
scrotw
search
skull
slocker
starwars
streamit
sumnum
tty-colorize
usrmount
ytp
ytplay


scriptsports
1 351•  5 years ago•  DownloadRawClose
5 years ago•  1 351

{}
#!/bin/bash
#
# Script by Amalie
# Do not edit
# This file require root

ERROR=0
CMD=""
MESSAGE=""

echo ""
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Ports listening (netstat -plnt) v"
sudo netstat -plnt
echo ""
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Ports forwarded (iptables -L -n) v"
sudo iptables -L -n
echo ""
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Modify ports below:"
echo "Script for adding or removing ports in Iptables:"
echo ""
echo "Type 'add' or 'drop' or 'cancel':"
read addordrop
echo ""

if [ "$addordrop" == "add" ]; then
    echo "type 'tcp' or 'udp':"
    read tcporudp
    echo ""
    echo "Enter port number:"
    read portnumber
    echo ""

    if [ "$portnumber" -le 65535 ] && [ "$portnumber" -ge 0 ]; then
        if [ "$tcporudp" == "tcp" ]; then
            CMD="iptables -A TCP -p tcp --dport $portnumber -j ACCEPT"
            MESSAGE="Added TCP port $portnumber"
        elif [ "$tcporudp" == "udp" ]; then
            CMD="iptables -A UDP -p udp --dport $portnumber -j ACCEPT"
            MESSAGE="Added UDP port $portnumber"
        else
            echo "Error: Unknown parameter."
            ERROR=1
        fi
    else
        echo "Error: Port out of range."
        ERROR=1	
    fi

elif [ "$addordrop" == "drop" ]; then
    echo "type 'tcp' or 'udp':"
    read tcporudp
    echo ""
    echo "Enter port number:"
    read portnumber
    echo ""

    if [ "$portnumber" -le 65535 ] && [ "$portnumber" -ge 0 ]; then
        if [ "$tcporudp" == "tcp" ]; then
            CMD="iptables -D TCP -p tcp --dport $portnumber -j ACCEPT"
            MESSAGE="Dropped TCP port $portnumber"
        elif [ "$tcporudp" == "udp" ]; then
            CMD="iptables -D UDP -p udp --dport $portnumber -j ACCEPT"
            MESSAGE="Dropped UDP port $portnumber"
        else
            echo "Error: Unknown parameter."
            ERROR=1
        fi
    else
        echo "Error: Port out of range."
        ERROR=1	
    fi
elif [ "$addordrop" == "cancel" ]; then
    echo "Cancelling script..."
    ERROR=1
else
    echo "Error: Unknown parameter."
    ERROR=1
fi

if [ "$ERROR" -eq 0 ]; then
    eval $CMD
    iptables-save > /etc/iptables/rules.v4
    ip6tables-save > /etc/iptables/rules.v6
    echo "$CMD" >> /root/changeiptables-DONOTTOUCH.sh
    echo "Success: $MESSAGE."
fi

exit

Top
©twily.info 2013 - 2024
twily at twily dot info



2 030 992 visits
... ^ v