Skip to content

Commit 31dcf30

Browse files
committed
Added error checks for iptables rule modifications. Updated success message.
1 parent b8d7257 commit 31dcf30

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

stop.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ iptables -nL INPUT | egrep "ACCEPT +tcp +-- +0\.0\.0\.0/0 +0\.0\.0\.0/0 +tcp dpt
5151
if [[ $? == 0 ]]; then
5252
echo "Executing: iptables -D INPUT -p tcp --dport 2222 -j ACCEPT"
5353
iptables -D INPUT -p tcp --dport 2222 -j ACCEPT
54+
if [[ $? != 0 ]]; then
55+
echo "ERROR: failed to remove iptables rule!"
56+
exit -1
57+
fi
5458
fi
5559

5660
# Check if the PREROUTING table has a REDIRECT for port 22 to 2222. If so,
@@ -59,7 +63,11 @@ iptables -t nat -nL PREROUTING | egrep "REDIRECT +tcp +-- +0\.0\.0\.0/0 +0\.0\.0
5963
if [[ $? == 0 ]]; then
6064
echo "Executing: iptables -t nat -D PREROUTING -p tcp --dport 22 -j REDIRECT --to-ports 2222"
6165
iptables -t nat -D PREROUTING -p tcp --dport 22 -j REDIRECT --to-ports 2222
66+
if [[ $? != 0 ]]; then
67+
echo "ERROR: failed to remove iptables rule!"
68+
exit -1
69+
fi
6270
fi
6371

64-
echo -e "\nDone!\n"
72+
echo -e "\nSuccessfully stopped sshd_mitm daemon and disabled forwarding rules.\n"
6573
exit 0

0 commit comments

Comments
 (0)