#!/usr/bin/perl use warnings; while(1){ system ( "dialog --menu Customize 30 80 60 " . "'Show rules' 'Show all the current rules' " . "'Flush rules' 'Flush all the tables' " . "Allow IP' 'Block all except one IP' " . "'Block IP' 'Block all the packets from an IP' " . "'Block MAC' 'Block using the hardware address' " . "'Private networking' 'Allow only one network and block other networks' " . "'Allow lo' 'Allow local network interface' " . "'Save' 'Save customized rules' " . "'Exit' 'Close the program' " . "'more options' '........' 2> /tmp/customize.txt"); open FILE4,"/tmp/customize.txt" or die $!; chomp(my $customize = <FILE4>); #SHOW RULES if($customize =~ /Show rules/){ `iptables -nvL | tee /tmp/nvl.txt`; system ("dialog --textBox /tmp/nvl.txt 22 70"); } #FLUSH RULES elsif($customize =~ /Flush rules/){ `iptables -F`; system ("dialog --infoBox 'All tables have been flushed.' 05 35"); sleep 2; } #ALLOW IP elsif($customize =~ /Allow IP/){ system ("dialog --inputBox 'Enter the IP address of the sysetm which you want to allow:' 15 40 2> /tmp/allowIP.txt"); open FILE7,"/tmp/allowIP.txt" or die $!; chomp(my $aip = <FILE7>); `iptables -I INPUT -s $aip -j DROP`; system ("dialog --infoBox 'IP address $aip is allowed and rest are blocked' 05 45"); sleep 2; } #BLOCK IP elsif($customize =~ /Block IP/){ system ("dialog --inputBox 'Enter the IP address of the system which you want to block:' 15 40 2> /tmp/blockIP.txt"); open FILE5,"/tmp/blockIP.txt" or die $!; chomp(my $ip = <FILE5>); `iptables -A INPUT -s $ip -j DROP`; system ("dialog --infoBox 'IP address $ip has been blocked!' 05 35"); sleep 2; } #PRIVATE NETWORK elsif($customize =~ /Private networking/){ system ("dialog --inputBox 'Enter the network address which you want to allow (eg. 192.168.0.0/24)' 15 40 2> /tmp/network.txt"); open FILE6,"/tmp/network.txt" or die $!; chomp(my $network = <FILE6>); `iptables -I INPUT -s $network -j ACCEPT`; system ("dialog --infoBox 'Network $network is allowed and rest networks are blocked' 05 35"); sleep 2; } #ALLOW LO elsif($customize =~ /Allow lo/){ `iptables -I INPUT -i lo -j ACCEPT`; system ("dialog --infoBox 'Local interface is allowed.' 05 35"); sleep 2; } #SAVE elsif($customize =~ /Save/){ `service iptables save`; system ("dialog --infoBox 'All rules have been saved successfully' 05 45"); sleep 2; } #EXIT elsif($customize =~ /Exit/){ system ("dialog --infoBox 'Closing application.' 05 35"); sleep 2; exit 0; } else{ exit; } }
perl file.plx
错误 :
sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: Syntax error: unexpected end of file
mod_rewrite $ _GET
在Bash脚本中的正则expression式
什么是最有效的不区分大小写的grep用法?
如何使用Linux中的查找指定名为“abc”或“def”的删除子目录
从string中提取分辨率
registry项和值名称的有效字符是什么?
为什么BASH_REMATCH不能用于引用正则expression式?
正则expression式只用egrep来捕捉整个单词
在C中parsing正则expression式
缺少'这里: "Allow IP'
你忘了'
. "Allow IP' 'Block all except one IP' "
在Perl代码的第7行Allow IP'之前。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。