/
usr
/
sbin
/
/usr/sbin
mkdir
upload
Name
Size
Mode
Actions
aa-remove-unknown
3068
0755
edit
dl
rm
aa-status
8839
0755
edit
dl
rm
aa-teardown
139
0755
edit
dl
rm
accessdb
14728
0755
edit
dl
rm
add-shell
860
0755
edit
dl
rm
addgnupghome
3075
0755
edit
dl
rm
addgroup
37785
0755
edit
dl
rm
adduser
37785
0755
edit
dl
rm
agetty
69000
0755
edit
dl
rm
apparmor_parser
1526368
0755
edit
dl
rm
apparmor_status
8839
0755
edit
dl
rm
applygnupgdefaults
2217
0755
edit
dl
rm
arpd
80144
0755
edit
dl
rm
arptables
220488
0755
edit
dl
rm
arptables-nft
220488
0755
edit
dl
rm
arptables-nft-restore
220488
0755
edit
dl
rm
arptables-nft-save
220488
0755
edit
dl
rm
arptables-restore
220488
0755
edit
dl
rm
arptables-save
220488
0755
edit
dl
rm
atd
30728
0755
edit
dl
rm
badblocks
35144
0755
edit
dl
rm
bcache-super-show
14488
0755
edit
dl
rm
biosdecode
27856
0755
edit
dl
rm
blkdeactivate
14837
0755
edit
dl
rm
blkdiscard
35048
0755
edit
dl
rm
blkid
121096
0755
edit
dl
rm
blkzone
71912
0755
edit
dl
rm
blockdev
67816
0755
edit
dl
rm
bridge
104760
0755
edit
dl
rm
cache_check
1352288
0755
edit
dl
rm
cache_dump
1352288
0755
edit
dl
rm
cache_metadata_size
1352288
0755
edit
dl
rm
cache_repair
1352288
0755
edit
dl
rm
cache_restore
1352288
0755
edit
dl
rm
cache_writeback
1352288
0755
edit
dl
rm
capsh
31032
0755
edit
dl
rm
cfdisk
105048
0755
edit
dl
rm
cgdisk
211432
0755
edit
dl
rm
chcpu
47336
0755
edit
dl
rm
chgpasswd
67792
0755
edit
dl
rm
chmem
63720
0755
edit
dl
rm
chpasswd
59600
0755
edit
dl
rm
chroot
43352
0755
edit
dl
rm
cpgr
61784
0755
edit
dl
rm
cppw
61784
0755
edit
dl
rm
cron
55944
0755
edit
dl
rm
cryptdisks_start
1544
0755
edit
dl
rm
cryptdisks_stop
844
0755
edit
dl
rm
cryptsetup
138792
0755
edit
dl
rm
cryptsetup-reencrypt
107848
0755
edit
dl
rm
ctrlaltdel
39144
0755
edit
dl
rm
debugfs
231224
0755
edit
dl
rm
delgroup
16495
0755
edit
dl
rm
deluser
16495
0755
edit
dl
rm
depmod
174424
0755
edit
dl
rm
devlink
154080
0755
edit
dl
rm
dhclient
521200
0755
edit
dl
rm
dhclient-script
16304
0755
edit
dl
rm
dmeventd
51440
0755
edit
dl
rm
dmidecode
121856
0755
edit
dl
rm
dmsetup
175128
0755
edit
dl
rm
dmstats
175128
0755
edit
dl
rm
dosfsck
59472
0755
edit
dl
rm
dosfslabel
55376
0755
edit
dl
rm
dpkg-preconfigure
3663
0755
edit
dl
rm
dpkg-reconfigure
4448
0755
edit
dl
rm
dumpe2fs
31112
0755
edit
dl
rm
e2freefrag
18816
0755
edit
dl
rm
e2fsck
335064
0755
edit
dl
rm
e2image
43400
0755
edit
dl
rm
e2label
109112
0755
edit
dl
rm
e2mmpstatus
31112
0755
edit
dl
rm
e2scrub
7296
0755
edit
dl
rm
e2scrub_all
5395
0755
edit
dl
rm
e2undo
22912
0755
edit
dl
rm
e4crypt
31104
0755
edit
dl
rm
e4defrag
35128
0755
edit
dl
rm
ebtables
220488
0755
edit
dl
rm
ebtables-nft
220488
0755
edit
dl
rm
ebtables-nft-restore
220488
0755
edit
dl
rm
ebtables-nft-save
220488
0755
edit
dl
rm
ebtables-restore
220488
0755
edit
dl
rm
ebtables-save
220488
0755
edit
dl
rm
era_check
1352288
0755
edit
dl
rm
era_dump
1352288
0755
edit
dl
rm
era_invalidate
1352288
0755
edit
dl
rm
era_restore
1352288
0755
edit
dl
rm
ethtool
384048
0755
edit
dl
rm
faillock
14488
0755
edit
dl
rm
fatlabel
55376
0755
edit
dl
rm
fdformat
35048
0755
edit
dl
rm
fdisk
153880
0755
edit
dl
rm
filefrag
18768
0755
edit
dl
rm
findfs
14568
0755
edit
dl
rm
fixparts
76264
0755
edit
dl
rm
fsadm
24108
0755
edit
dl
rm
fsck
55576
0755
edit
dl
rm
fsck.btrfs
1185
0755
edit
dl
rm
fsck.cramfs
39176
0755
edit
dl
rm
fsck.ext2
335064
0755
edit
dl
rm
fsck.ext3
335064
0755
edit
dl
rm
fsck.ext4
335064
0755
edit
dl
rm
fsck.fat
59472
0755
edit
dl
rm
fsck.minix
125184
0755
edit
dl
rm
fsck.msdos
59472
0755
edit
dl
rm
fsck.vfat
59472
0755
edit
dl
rm
fsck.xfs
1968
0755
edit
dl
rm
fsfreeze
14568
0755
edit
dl
rm
fstab-decode
14648
0755
edit
dl
rm
fstrim
71912
0755
edit
dl
rm
gdisk
215528
0755
edit
dl
rm
genl
84264
0755
edit
dl
rm
getcap
14648
0755
edit
dl
rm
getpcaps
14648
0755
edit
dl
rm
getty
69000
0755
edit
dl
rm
groupadd
93136
0755
edit
dl
rm
groupdel
88848
0755
edit
dl
rm
groupmems
63736
0755
edit
dl
rm
groupmod
97136
0755
edit
dl
rm
grpck
63672
0755
edit
dl
rm
grpconv
59448
0755
edit
dl
rm
grpunconv
59448
0755
edit
dl
rm
grub-bios-setup
931168
0755
edit
dl
rm
grub-install
1162992
0755
edit
dl
rm
grub-macbless
918560
0755
edit
dl
rm
grub-mkconfig
8750
0755
edit
dl
rm
grub-mkdevicemap
220880
0755
edit
dl
rm
grub-probe
927008
0755
edit
dl
rm
grub-reboot
4843
0755
edit
dl
rm
grub-set-default
3558
0755
edit
dl
rm
halt
996584
0755
edit
dl
rm
hdparm
143704
0755
edit
dl
rm
hwclock
104808
0755
edit
dl
rm
iconvconfig
31128
0755
edit
dl
rm
init
1620224
0755
edit
dl
rm
insmod
174424
0755
edit
dl
rm
installkernel
2638
0755
edit
dl
rm
integritysetup
61672
0755
edit
dl
rm
invoke-rc.d
17042
0755
edit
dl
rm
ip
611960
0755
edit
dl
rm
ip6tables
99296
0755
edit
dl
rm
ip6tables-apply
7057
0755
edit
dl
rm
ip6tables-legacy
99296
0755
edit
dl
rm
ip6tables-legacy-restore
99296
0755
edit
dl
rm
ip6tables-legacy-save
99296
0755
edit
dl
rm
ip6tables-nft
220488
0755
edit
dl
rm
ip6tables-nft-restore
220488
0755
edit
dl
rm
ip6tables-nft-save
220488
0755
edit
dl
rm
ip6tables-restore
99296
0755
edit
dl
rm
ip6tables-restore-translate
220488
0755
edit
dl
rm
ip6tables-save
99296
0755
edit
dl
rm
ip6tables-translate
220488
0755
edit
dl
rm
iptables
99296
0755
edit
dl
rm
iptables-apply
7057
0755
edit
dl
rm
iptables-legacy
99296
0755
edit
dl
rm
iptables-legacy-restore
99296
0755
edit
dl
rm
iptables-legacy-save
99296
0755
edit
dl
rm
iptables-nft
220488
0755
edit
dl
rm
iptables-nft-restore
220488
0755
edit
dl
rm
iptables-nft-save
220488
0755
edit
dl
rm
iptables-restore
99296
0755
edit
dl
rm
iptables-restore-translate
220488
0755
edit
dl
rm
iptables-save
99296
0755
edit
dl
rm
iptables-translate
220488
0755
edit
dl
rm
irqbalance
64432
0755
edit
dl
rm
irqbalance-ui
35200
0755
edit
dl
rm
iscsi-iname
18584
0755
edit
dl
rm
iscsiadm
403560
0755
edit
dl
rm
iscsid
420152
0755
edit
dl
rm
iscsistart
375080
0755
edit
dl
rm
iscsi_discovery
5285
0755
edit
dl
rm
isosize
30952
0755
edit
dl
rm
kbdrate
14328
0755
edit
dl
rm
killall5
27016
0755
edit
dl
rm
kpartx
47272
0755
edit
dl
rm
ldattach
35048
0755
edit
dl
rm
ldconfig
387
0755
edit
dl
rm
ldconfig.real
1053768
0755
edit
dl
rm
locale-gen
4399
0755
edit
dl
rm
logrotate
84056
0755
edit
dl
rm
logsave
14496
0755
edit
dl
rm
losetup
112992
0755
edit
dl
rm
lsmod
174424
0755
edit
dl
rm
luksformat
3401
0755
edit
dl
rm
lvchange
2862872
0755
edit
dl
rm
lvconvert
2862872
0755
edit
dl
rm
lvcreate
2862872
0755
edit
dl
rm
lvdisplay
2862872
0755
edit
dl
rm
lvextend
2862872
0755
edit
dl
rm
lvm
2862872
0755
edit
dl
rm
lvmconfig
2862872
0755
edit
dl
rm
lvmdiskscan
2862872
0755
edit
dl
rm
lvmdump
10312
0755
edit
dl
rm
lvmpolld
237624
0755
edit
dl
rm
lvmsadc
2862872
0755
edit
dl
rm
lvmsar
2862872
0755
edit
dl
rm
lvreduce
2862872
0755
edit
dl
rm
lvremove
2862872
0755
edit
dl
rm
lvrename
2862872
0755
edit
dl
rm
lvresize
2862872
0755
edit
dl
rm
lvs
2862872
0755
edit
dl
rm
lvscan
2862872
0755
edit
dl
rm
make-bcache
22760
0755
edit
dl
rm
mdadm
603800
0755
edit
dl
rm
mdmon
333304
0755
edit
dl
rm
mkdosfs
35328
0755
edit
dl
rm
mke2fs
137848
0755
edit
dl
rm
mkfs
14568
0755
edit
dl
rm
mkfs.bfs
35048
0755
edit
dl
rm
mkfs.btrfs
462368
0755
edit
dl
rm
mkfs.cramfs
43168
0755
edit
dl
rm
mkfs.ext2
137848
0755
edit
dl
rm
mkfs.ext3
137848
0755
edit
dl
rm
mkfs.ext4
137848
0755
edit
dl
rm
mkfs.fat
35328
0755
edit
dl
rm
mkfs.minix
108784
0755
edit
dl
rm
mkfs.msdos
35328
0755
edit
dl
rm
mkfs.ntfs
88336
0755
edit
dl
rm
mkfs.vfat
35328
0755
edit
dl
rm
mkfs.xfs
375032
0755
edit
dl
rm
mkhomedir_helper
22704
0755
edit
dl
rm
mkinitramfs
11792
0755
edit
dl
rm
mklost+found
14648
0755
edit
dl
rm
mkntfs
88336
0755
edit
dl
rm
mkswap
108784
0755
edit
dl
rm
modinfo
174424
0755
edit
dl
rm
modprobe
174424
0755
edit
dl
rm
mount.fuse
14488
0755
edit
dl
rm
mount.lowntfs-3g
121712
0755
edit
dl
rm
mount.ntfs
162704
0755
edit
dl
rm
mount.ntfs-3g
162704
0755
edit
dl
rm
mount.vmhgfs
47592
0755
edit
dl
rm
mpathpersist
31800
0755
edit
dl
rm
multipath
34968
0755
edit
dl
rm
multipathd
129224
0755
edit
dl
rm
mysqld
67496848
0755
edit
dl
rm
netplan
798
0755
edit
dl
rm
newusers
101168
0755
edit
dl
rm
nfnl_osf
18736
0755
edit
dl
rm
nginx
1195152
0755
edit
dl
rm
nologin
14640
0755
edit
dl
rm
ntfsclone
59672
0755
edit
dl
rm
ntfscp
43272
0755
edit
dl
rm
ntfslabel
35080
0755
edit
dl
rm
ntfsresize
80152
0755
edit
dl
rm
ntfsundelete
55560
0755
edit
dl
rm
on_ac_power
2228
0755
edit
dl
rm
overlayroot-chroot
2510
0755
edit
dl
rm
ownership
14792
0755
edit
dl
rm
pam-auth-update
20335
0755
edit
dl
rm
pam_extrausers_chkpwd
43168
2755
edit
dl
rm
pam_extrausers_update
43168
0755
edit
dl
rm
pam_getenv
2890
0755
edit
dl
rm
pam_tally
14504
0755
edit
dl
rm
pam_tally2
18600
0755
edit
dl
rm
pam_timestamp_check
14488
0755
edit
dl
rm
parted
88320
0755
edit
dl
rm
partprobe
14568
0755
edit
dl
rm
pdata_tools
1352288
0755
edit
dl
rm
php-fpm7.4
4767320
0755
edit
dl
rm
phpdismod
7278
0755
edit
dl
rm
phpenmod
7278
0755
edit
dl
rm
phpquery
6389
0755
edit
dl
rm
pivot_root
14568
0755
edit
dl
rm
plymouthd
149920
0755
edit
dl
rm
popcon-largest-unused
543
0755
edit
dl
rm
popularity-contest
5353
0755
edit
dl
rm
poweroff
996584
0755
edit
dl
rm
pvchange
2862872
0755
edit
dl
rm
pvck
2862872
0755
edit
dl
rm
pvcreate
2862872
0755
edit
dl
rm
pvdisplay
2862872
0755
edit
dl
rm
pvmove
2862872
0755
edit
dl
rm
pvremove
2862872
0755
edit
dl
rm
pvresize
2862872
0755
edit
dl
rm
pvs
2862872
0755
edit
dl
rm
pvscan
2862872
0755
edit
dl
rm
pwck
59568
0755
edit
dl
rm
pwconv
55344
0755
edit
dl
rm
pwunconv
55352
0755
edit
dl
rm
raw
14568
0755
edit
dl
rm
readprofile
22792
0755
edit
dl
rm
reboot
996584
0755
edit
dl
rm
remove-shell
904
0755
edit
dl
rm
resize2fs
67968
0755
edit
dl
rm
rmmod
174424
0755
edit
dl
rm
rmt
59952
0755
edit
dl
rm
rmt-tar
59952
0755
edit
dl
rm
rsyslogd
727248
0755
edit
dl
rm
rtacct
49448
0755
edit
dl
rm
rtcwake
47336
0755
edit
dl
rm
rtmon
80120
0755
edit
dl
rm
runlevel
996584
0755
edit
dl
rm
runuser
67816
0755
edit
dl
rm
service
9262
0755
edit
dl
rm
setcap
14648
0755
edit
dl
rm
setvesablank
14408
0755
edit
dl
rm
setvtrgb
14472
0755
edit
dl
rm
sfdisk
141544
0755
edit
dl
rm
sgdisk
195048
0755
edit
dl
rm
shadowconfig
885
0755
edit
dl
rm
shutdown
996584
0755
edit
dl
rm
sshd
884520
0755
edit
dl
rm
start-stop-daemon
48456
0755
edit
dl
rm
sulogin
51432
0755
edit
dl
rm
swaplabel
18664
0755
edit
dl
rm
swapoff
22760
0755
edit
dl
rm
swapon
51432
0755
edit
dl
rm
switch_root
14568
0755
edit
dl
rm
sysctl
30960
0755
edit
dl
rm
tarcat
936
0755
edit
dl
rm
tc
542160
0755
edit
dl
rm
tcpdump
1044232
0755
edit
dl
rm
telinit
996584
0755
edit
dl
rm
thin_check
1352288
0755
edit
dl
rm
thin_delta
1352288
0755
edit
dl
rm
thin_dump
1352288
0755
edit
dl
rm
thin_ls
1352288
0755
edit
dl
rm
thin_metadata_size
1352288
0755
edit
dl
rm
thin_repair
1352288
0755
edit
dl
rm
thin_restore
1352288
0755
edit
dl
rm
thin_rmap
1352288
0755
edit
dl
rm
thin_trim
1352288
0755
edit
dl
rm
tipc
129264
0755
edit
dl
rm
tune2fs
109112
0755
edit
dl
rm
tzconfig
106
0755
edit
dl
rm
ufw
4936
0755
edit
dl
rm
unix_chkpwd
43160
2755
edit
dl
rm
unix_update
43160
0755
edit
dl
rm
update-ca-certificates
5418
0755
edit
dl
rm
update-grub
64
0755
edit
dl
rm
update-grub-gfxpayload
301
0755
edit
dl
rm
update-grub2
64
0755
edit
dl
rm
update-info-dir
1700
0755
edit
dl
rm
update-initramfs
7419
0755
edit
dl
rm
update-locale
3063
0755
edit
dl
rm
update-mime
9402
0755
edit
dl
rm
update-passwd
35392
0755
edit
dl
rm
update-pciids
1749
0755
edit
dl
rm
update-rc.d
17161
0755
edit
dl
rm
update-secureboot-policy
7605
0755
edit
dl
rm
upgrade-from-grub-legacy
1524
0755
edit
dl
rm
useradd
147160
0755
edit
dl
rm
userdel
101264
0755
edit
dl
rm
usermod
142840
0755
edit
dl
rm
uuidd
43320
0755
edit
dl
rm
validlocale
1773
0755
edit
dl
rm
vcstime
14328
0755
edit
dl
rm
veritysetup
53064
0755
edit
dl
rm
vgcfgbackup
2862872
0755
edit
dl
rm
vgcfgrestore
2862872
0755
edit
dl
rm
vgchange
2862872
0755
edit
dl
rm
vgck
2862872
0755
edit
dl
rm
vgconvert
2862872
0755
edit
dl
rm
vgcreate
2862872
0755
edit
dl
rm
vgdisplay
2862872
0755
edit
dl
rm
vgexport
2862872
0755
edit
dl
rm
vgextend
2862872
0755
edit
dl
rm
vgimport
2862872
0755
edit
dl
rm
vgimportclone
2862872
0755
edit
dl
rm
vgmerge
2862872
0755
edit
dl
rm
vgmknodes
2862872
0755
edit
dl
rm
vgreduce
2862872
0755
edit
dl
rm
vgremove
2862872
0755
edit
dl
rm
vgrename
2862872
0755
edit
dl
rm
vgs
2862872
0755
edit
dl
rm
vgscan
2862872
0755
edit
dl
rm
vgsplit
2862872
0755
edit
dl
rm
vigr
70200
0755
edit
dl
rm
vipw
70200
0755
edit
dl
rm
visudo
223432
0755
edit
dl
rm
vpddecode
19024
0755
edit
dl
rm
wipefs
47336
0755
edit
dl
rm
xfs_admin
1415
0755
edit
dl
rm
xfs_bmap
695
0755
edit
dl
rm
xfs_copy
92448
0755
edit
dl
rm
xfs_db
634976
0755
edit
dl
rm
xfs_estimate
14344
0755
edit
dl
rm
xfs_freeze
800
0755
edit
dl
rm
xfs_fsr
43032
0755
edit
dl
rm
xfs_growfs
34960
0755
edit
dl
rm
xfs_info
1294
0755
edit
dl
rm
xfs_io
191832
0755
edit
dl
rm
xfs_logprint
75928
0755
edit
dl
rm
xfs_mdrestore
30736
0755
edit
dl
rm
xfs_metadump
782
0755
edit
dl
rm
xfs_mkfile
1040
0755
edit
dl
rm
xfs_ncheck
685
0755
edit
dl
rm
xfs_quota
88072
0755
edit
dl
rm
xfs_repair
576664
0755
edit
dl
rm
xfs_rtcp
18424
0755
edit
dl
rm
xfs_scrub
104560
0755
edit
dl
rm
xfs_scrub_all
6005
0755
edit
dl
rm
xfs_spaceman
43160
0755
edit
dl
rm
xtables-legacy-multi
99296
0755
edit
dl
rm
xtables-monitor
220488
0755
edit
dl
rm
xtables-nft-multi
220488
0755
edit
dl
rm
zerofree
10232
0755
edit
dl
rm
zic
63784
0755
edit
dl
rm
zramctl
117088
0755
edit
dl
rm
Edit:
/usr/sbin/iptables-apply
(7057B)
#!/bin/bash # iptables-apply -- a safer way to update iptables remotely # # Usage: # iptables-apply [-hV] [-t timeout] [-w savefile] {[rulesfile]|-c [runcmd]} # # Versions: # * 1.0 Copyright 2006 Martin F. Krafft <madduck@madduck.net> # Original version # * 1.1 Copyright 2010 GW <gw.2010@tnode.com or http://gw.tnode.com/> # Added parameter -c (run command) # Added parameter -w (save successfully applied rules to file) # Major code cleanup # # Released under the terms of the Artistic Licence 2.0 # set -eu PROGNAME="${0##*/}" VERSION=1.1 ### Default settings DEF_TIMEOUT=10 MODE=0 # apply rulesfile mode # MODE=1 # run command mode case "$PROGNAME" in (*6*) SAVE=ip6tables-save RESTORE=ip6tables-restore DEF_RULESFILE="/etc/network/ip6tables.up.rules" DEF_SAVEFILE="$DEF_RULESFILE" DEF_RUNCMD="/etc/network/ip6tables.up.run" ;; (*) SAVE=iptables-save RESTORE=iptables-restore DEF_RULESFILE="/etc/network/iptables.up.rules" DEF_SAVEFILE="$DEF_RULESFILE" DEF_RUNCMD="/etc/network/iptables.up.run" ;; esac ### Functions function blurb() { cat <<-__EOF__ $PROGNAME $VERSION -- a safer way to update iptables remotely __EOF__ } function copyright() { cat <<-__EOF__ $PROGNAME has been published under the terms of the Artistic Licence 2.0. Original version - Copyright 2006 Martin F. Krafft <madduck@madduck.net>. Version 1.1 - Copyright 2010 GW <gw.2010@tnode.com or http://gw.tnode.com/>. __EOF__ } function about() { blurb echo copyright } function usage() { blurb echo cat <<-__EOF__ Usage: $PROGNAME [-hV] [-t timeout] [-w savefile] {[rulesfile]|-c [runcmd]} The script will try to apply a new rulesfile (as output by iptables-save, read by iptables-restore) or run a command to configure iptables and then prompt the user whether the changes are okay. If the new iptables rules cut the existing connection, the user will not be able to answer affirmatively. In this case, the script rolls back to the previous working iptables rules after the timeout expires. Successfully applied rules can also be written to savefile and later used to roll back to this state. This can be used to implement a store last good configuration mechanism when experimenting with an iptables setup script: $PROGNAME -w $DEF_SAVEFILE -c $DEF_RUNCMD When called as ip6tables-apply, the script will use ip6tables-save/-restore and IPv6 default values instead. Default value for rulesfile is '$DEF_RULESFILE'. Options: -t seconds, --timeout seconds Specify the timeout in seconds (default: $DEF_TIMEOUT). -w savefile, --write savefile Specify the savefile where successfully applied rules will be written to (default if empty string is given: $DEF_SAVEFILE). -c runcmd, --command runcmd Run command runcmd to configure iptables instead of applying a rulesfile (default: $DEF_RUNCMD). -h, --help Display this help text. -V, --version Display version information. __EOF__ } function checkcommands() { for cmd in "${COMMANDS[@]}"; do if ! command -v "$cmd" >/dev/null; then echo "Error: needed command not found: $cmd" >&2 exit 127 fi done } function revertrules() { echo -n "Reverting to old iptables rules... " "$RESTORE" <"$TMPFILE" echo "done." } ### Parsing and checking parameters TIMEOUT="$DEF_TIMEOUT" SAVEFILE="" SHORTOPTS="t:w:chV"; LONGOPTS="timeout:,write:,command,help,version"; OPTS=$(getopt -s bash -o "$SHORTOPTS" -l "$LONGOPTS" -n "$PROGNAME" -- "$@") || exit $? for opt in $OPTS; do case "$opt" in (-*) unset OPT_STATE ;; (*) case "${OPT_STATE:-}" in (SET_TIMEOUT) eval TIMEOUT=$opt;; (SET_SAVEFILE) eval SAVEFILE=$opt [ -z "$SAVEFILE" ] && SAVEFILE="$DEF_SAVEFILE" ;; esac ;; esac case "$opt" in (-t|--timeout) OPT_STATE="SET_TIMEOUT";; (-w|--write) OPT_STATE="SET_SAVEFILE";; (-c|--command) MODE=1;; (-h|--help) usage >&2; exit 0;; (-V|--version) about >&2; exit 0;; (--) break;; esac shift done # Validate parameters if [ "$TIMEOUT" -ge 0 ] 2>/dev/null; then TIMEOUT=$(($TIMEOUT)) else echo "Error: timeout must be a positive number" >&2 exit 1 fi if [ -n "$SAVEFILE" -a -e "$SAVEFILE" -a ! -w "$SAVEFILE" ]; then echo "Error: savefile not writable: $SAVEFILE" >&2 exit 8 fi case "$MODE" in (1) # Treat parameter as runcmd (run command mode) RUNCMD="${1:-$DEF_RUNCMD}" if [ ! -x "$RUNCMD" ]; then echo "Error: runcmd not executable: $RUNCMD" >&2 exit 6 fi # Needed commands COMMANDS=(mktemp "$SAVE" "$RESTORE" "$RUNCMD") checkcommands ;; (*) # Treat parameter as rulesfile (apply rulesfile mode) RULESFILE="${1:-$DEF_RULESFILE}"; if [ ! -r "$RULESFILE" ]; then echo "Error: rulesfile not readable: $RULESFILE" >&2 exit 2 fi # Needed commands COMMANDS=(mktemp "$SAVE" "$RESTORE") checkcommands ;; esac ### Begin work # Store old iptables rules to temporary file TMPFILE=`mktemp /tmp/$PROGNAME-XXXXXXXX` trap "rm -f $TMPFILE" EXIT HUP INT QUIT ILL TRAP ABRT BUS \ FPE USR1 SEGV USR2 PIPE ALRM TERM if ! "$SAVE" >"$TMPFILE"; then # An error occured if ! grep -q ipt /proc/modules 2>/dev/null; then echo "Error: iptables support lacking from the kernel" >&2 exit 3 else echo "Error: unknown error saving old iptables rules: $TMPFILE" >&2 exit 4 fi fi # Legacy to stop the fail2ban daemon if present [ -x /etc/init.d/fail2ban ] && /etc/init.d/fail2ban stop # Configure iptables case "$MODE" in (1) # Run command in background and kill it if it times out echo -n "Running command '$RUNCMD'... " "$RUNCMD" & CMD_PID=$! ( sleep "$TIMEOUT"; kill "$CMD_PID" 2>/dev/null; exit 0 ) & CMDTIMEOUT_PID=$! if ! wait "$CMD_PID"; then echo "failed." echo "Error: unknown error running command: $RUNCMD" >&2 revertrules exit 7 else echo "done." fi ;; (*) # Apply iptables rulesfile echo -n "Applying new iptables rules from '$RULESFILE'... " if ! "$RESTORE" <"$RULESFILE"; then echo "failed." echo "Error: unknown error applying new iptables rules: $RULESFILE" >&2 revertrules exit 5 else echo "done." fi ;; esac # Prompt user for confirmation echo -n "Can you establish NEW connections to the machine? (y/N) " read -n1 -t "$TIMEOUT" ret 2>&1 || : case "${ret:-}" in (y*|Y*) # Success echo if [ ! -z "$SAVEFILE" ]; then # Write successfully applied rules to the savefile echo "Writing successfully applied rules to '$SAVEFILE'..." if ! "$SAVE" >"$SAVEFILE"; then echo "Error: unknown error writing successfully applied rules: $SAVEFILE" >&2 exit 9 fi fi echo "... then my job is done. See you next time." ;; (*) # Failed echo if [ -z "${ret:-}" ]; then echo "Timeout! Something happened (or did not). Better play it safe..." else echo "No affirmative response! Better play it safe..." fi revertrules exit 255 ;; esac # Legacy to start the fail2ban daemon again [ -x /etc/init.d/fail2ban ] && /etc/init.d/fail2ban start exit 0 # vim:noet:sw=8
Save
cmd:
run