From cab96801c1ec9b7dc7b851b32be1ea7861ac6572 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Thu, 29 May 2014 21:11:28 -0500 Subject: [PATCH] adding scripts --- disableping.py | 19 +++++++++++++++++++ enableping.py | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 disableping.py create mode 100644 enableping.py diff --git a/disableping.py b/disableping.py new file mode 100644 index 0000000..f08e624 --- /dev/null +++ b/disableping.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +import pexpect +import sys + +pobj = pexpect.spawn("ssh root@192.168.128.1") +pobj.expect(".*password:.*") +pobj.sendline(strpass) +pobj.expect(".*#.*") +pobj.sendline('nvram set rc_firewall="insmod ipt_mark') +pobj.sendline('insmod xt_mark') +pobj.sendline('iptables -t mangle -A PREROUTING -i ! `get_wanface` -d `nvram get wan_ipaddr` -j MARK --set-mark 0xd001') +pobj.sendline('iptables -t nat -A POSTROUTING -m mark --mark 0xd001 -j MASQUERADE') +pobj.sendline('iptables -A INPUT -p icmp --icmp-type 8 -j DROP"') +pobj.expect(".*#.*") +pobj.sendline("nvram commit") +pobj.expect(".*#.*") +pobj.sendline("startservice firewall") +pobj.expect(".*#.*") +pobj.close() \ No newline at end of file diff --git a/enableping.py b/enableping.py new file mode 100644 index 0000000..872548c --- /dev/null +++ b/enableping.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +import pexpect +import sys + +pobj = pexpect.spawn("ssh root@192.168.128.1") +#pobj.logfile = open("enlog.txt", "a+") +pobj.expect(".*password:.*") +pobj.sendline(strpass) +pobj.expect(".*#.*") +pobj.sendline('nvram set rc_firewall="insmod ipt_mark') +pobj.sendline('insmod xt_mark') +pobj.sendline('iptables -t mangle -A PREROUTING -i ! `get_wanface` -d `nvram get wan_ipaddr` -j MARK --set-mark 0xd001') +pobj.sendline('iptables -t nat -A POSTROUTING -m mark --mark 0xd001 -j MASQUERADE"') +pobj.expect(".*#.*") +pobj.sendline("nvram commit") +pobj.expect(".*#.*") +pobj.sendline("startservice firewall") +pobj.expect(".*#.*") +pobj.close()