I am trying to install the latest v7 malware script. I am not great with unix commands, but am very persistent. My head hurts, Little help?
I'm Just trying to get into the cd /opt
Please don't tear my head off, I know there has to be a simple command to allow
admin@HOMES:/# cd /opt
-sh: cd: can't cd to /opt
Thanks for the response, I tried to attach the code but got blocked by the forum's filters. opt shows up. Trying to post a jpg of it since forum filters are blocking me.The /opt directory probably doesn't exist. Try cd / to get to the root directory and then ls -trl which will list the directories and files. You can place the script in another directory such as /jffs/scripts, but if so.. would need to modify the path in the script. If you want to make a directory the command is mkdir directoryname
Jan 17 21:58:13 kernel: net/ipv4/netfilter/ip_set_iphash.c: iphash_retry: rehashing of set malware-update triggered: hashsize grows from 88573 to 132859
Jan 17 21:59:24 system: Malware Filter loaded 33069 unique ip addresses.
ipset v4.5: -T requires setname and IP
Try `ipset -H' or 'ipset --help' for more information.
admin@HOMES:/jffs/scripts# ipset -T malware-filter 74.82.47.14
74.82.47.14 is in set malware-filter.
admin@HOMES:/jffs/scripts# ipset -T malware-filter 2.178.244.64
2.178.244.64 is NOT in set malware-filter.
admin@HOMES:/jffs/scripts#
/usr/sbin/iptables -L FORWARD -v -n
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
1 40 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 set malware-filter src,dst reject-with icmp-port-unreachable
1527K 2017M ipttolan all -- * br0 0.0.0.0/0 0.0.0.0/0
777K 70M iptfromlan all -- br0 * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT udp -- * * 0.0.0.0/0 224.0.0.0/4
2287K 2085M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 logdrop all -- !br0 eth0 0.0.0.0/0 0.0.0.0/0
0 0 logdrop all -- eth0 * 0.0.0.0/0 0.0.0.0/0 state INVALID
0 0 ACCEPT all -- br0 br0 0.0.0.0/0 0.0.0.0/0
630 51065 SECURITY all -- eth0 * 0.0.0.0/0 0.0.0.0/0
16782 1512K NSFW all -- * * 0.0.0.0/0 0.0.0.0/0
614 50105 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate DNAT
16168 1462K ACCEPT all -- br0 * 0.0.0.0/0 0.0.0.0/0
admin@HOMES:/jffs/scripts#
Hello everyone,
When I try and run the latest script off the wiki (v7), it appears to just hang after the wgets. This is what I see:
As of now, it has been sitting there for about 20 minutes and top does not show any relevant activity. Any suggestions to point me in the right direction would be greatly appreciated.
sometimes the host of these files have timeouts it happned to me too cant control it the only thing you can do is to try again but im gonna investigate if there is a possability to have timeout via wget if that happens so it skips lists.
#!/bin/sh
# Author: Toast
# Contributers: Octopus, Tomsk, Neurophile
# Testers: shooter40sw
# Revision 8
path=/opt/var/cache/malware-filter # Set your path here
timeout=60 # Set your timeout value here (seconds)
regexp=`echo "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"` # Dont change this value
case $(ipset -v | grep -oE "ipset v[0-9]") in
*v6) # Value for ARM Routers
MATCH_SET='--match-set'
HASH='hash:ip'
SYNTAX='add'
SWAPPED='swap'
DESTROYED='destroy'
OPTIONAL='family inet hashsize 2048 maxelem 65536'
ipsetv=6
lsmod | grep "xt_set" > /dev/null 2>&1 || \
for module in ip_set ip_set_hash_net ip_set_hash_ip xt_set
do
insmod $module
done
;;
*v4) # Value for Mips Routers
MATCH_SET='--set'
HASH='iphash'
SYNTAX='-q -A'
SWAPPED='-W'
DESTROYED='--destroy'
OPTIONAL=''
ipsetv=4
lsmod | grep "ipt_set" > /dev/null 2>&1 || \
for module in ip_set ip_set_nethash ip_set_iphash ipt_set
do
insmod $module
done
;;
esac
get_list () {
mkdir -p $path
wget -q --timeout=$timeout --show-progress -i $path/malware-filter.list -O $path/malware-list.pre
cat $path/malware-list.pre | grep -oE "$regexp" | sort -u >$path/malware-filter.txt
}
run_ipset () {
get_list
echo "adding ipset rule to firewall this will take time."
ipset -L malware-filter >/dev/null 2>&1
if [ $? -ne 0 ]; then
if [ "$(ipset --swap malware-filter malware-filter 2>&1 | grep -E 'Unknown set|The set with the given name does not exist')" != "" ]; then
nice -n 2 ipset -N malware-filter $HASH $OPTIONAL
for i in `cat $path/malware-filter.txt`; do nice -n 2 ipset $SYNTAX malware-filter $i ; done
fi
else
nice -n 2 ipset -N malware-update $HASH $OPTIONAL
for i in `cat $path/malware-filter.txt`; do nice ipset $SYNTAX malware-update $i ; done
nice -n 2 ipset $SWAPPED malware-update malware-filter
nice -n 2 ipset $DESTROYED malware-update
fi
iptables -L | grep malware-filter > /dev/null 2>&1
if [ $? -ne 0 ]; then
nice -n 2 iptables -I FORWARD -m set $MATCH_SET malware-filter src,dst -j REJECT
else
nice -n 2 iptables -D FORWARD -m set $MATCH_SET malware-filter src,dst -j REJECT
nice -n 2 iptables -I FORWARD -m set $MATCH_SET malware-filter src,dst -j REJECT
fi
}
run_ipset
logger -s -t system "Malware Filter loaded $(cat $path/malware-filter.txt | wc -l) unique ip addresses."
exit $?
#!/bin/sh
# Author: Toast
# Contributers: Octopus, Tomsk, Neurophile, jimf
# Testers: shooter40sw
# Revision 9
path=/opt/var/cache/malware-filter # Set your path here
retries=3 # Set number of tries here
timeout=60 # Set timeot value here
regexp=`echo "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"` # Dont change this value
case $(ipset -v | grep -oE "ipset v[0-9]") in
*v6) # Value for ARM Routers
MATCH_SET='--match-set'
HASH='hash:ip'
SYNTAX='add'
SWAPPED='swap'
DESTROYED='destroy'
OPTIONAL='family inet hashsize 2048 maxelem 65536'
ipsetv=6
lsmod | grep "xt_set" > /dev/null 2>&1 || \
for module in ip_set ip_set_hash_net ip_set_hash_ip xt_set
do
insmod $module
done
;;
*v4) # Value for Mips Routers
MATCH_SET='--set'
HASH='iphash'
SYNTAX='-q -A'
SWAPPED='-W'
DESTROYED='--destroy'
OPTIONAL=''
ipsetv=4
lsmod | grep "ipt_set" > /dev/null 2>&1 || \
for module in ip_set ip_set_nethash ip_set_iphash ipt_set
do
insmod $module
done
;;
esac
get_list () {
mkdir -p $path
wget -q --tries=$retries --timeout=$timeout --show-progress -i $path/malware-filter.list -O $path/malware-list.pre
cat $path/malware-list.pre | grep -oE "$regexp" | sort -u >$path/malware-filter.txt
}
run_ipset () {
get_list
echo "adding ipset rule to firewall this will take time."
ipset -L malware-filter >/dev/null 2>&1
if [ $? -ne 0 ]; then
if [ "$(ipset --swap malware-filter malware-filter 2>&1 | grep -E 'Unknown set|The set with the given name does not exist')" != "" ]; then
nice -n 2 ipset -N malware-filter $HASH $OPTIONAL
for i in `cat $path/malware-filter.txt`; do nice -n 2 ipset $SYNTAX malware-filter $i ; done
fi
else
nice -n 2 ipset -N malware-update $HASH $OPTIONAL
for i in `cat $path/malware-filter.txt`; do nice ipset $SYNTAX malware-update $i ; done
nice -n 2 ipset $SWAPPED malware-update malware-filter
nice -n 2 ipset $DESTROYED malware-update
fi
iptables -L | grep malware-filter > /dev/null 2>&1
if [ $? -ne 0 ]; then
nice -n 2 iptables -I FORWARD -m set $MATCH_SET malware-filter src,dst -j REJECT
else
nice -n 2 iptables -D FORWARD -m set $MATCH_SET malware-filter src,dst -j REJECT
nice -n 2 iptables -I FORWARD -m set $MATCH_SET malware-filter src,dst -j REJECT
fi
}
run_ipset
logger -s -t system "Malware Filter loaded $(cat $path/malware-filter.txt | wc -l) unique ip addresses."
exit $?
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!