adding other files
This commit is contained in:
parent
6657605f94
commit
3c28023519
10
add_ipset
Executable file
10
add_ipset
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
#echo "opening File"
|
||||
#echo "/home/brickman/scripts/block_ips/xa${1}"
|
||||
|
||||
for net in `cat "/home/brickman/scripts/block_ips/xa${1}"`
|
||||
do
|
||||
sudo ipset -A usa_state $net
|
||||
done
|
||||
|
42
change_ip_block
Executable file
42
change_ip_block
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo ""
|
||||
|
||||
NUM=$(sudo iptables -L --line-numbers | grep 'usa_state' | head -n 1 | cut -c1)
|
||||
|
||||
if [ -z "$NUM" ]
|
||||
then
|
||||
if [ $@ == "enable" ]
|
||||
then
|
||||
echo "Enabling IP White Listing"
|
||||
|
||||
sudo iptables -A INPUT -m set ! --match-set usa_state src -j DROP &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Success"
|
||||
else
|
||||
echo "Error"
|
||||
fi
|
||||
else
|
||||
echo "Already Disabled"
|
||||
fi
|
||||
else
|
||||
if [ $@ == "disable" ]
|
||||
then
|
||||
echo "Disabling IP White Listing"
|
||||
|
||||
NUM=`iptables -L --line-numbers | grep 'usa_state' | head -n 1 | cut -c1`
|
||||
sudo iptables -D INPUT $NUM &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Sucess"
|
||||
else
|
||||
echo "Error"
|
||||
fi
|
||||
else
|
||||
echo "Already Enabled"
|
||||
fi
|
||||
|
||||
fi
|
11
log.txt
Normal file
11
log.txt
Normal file
@ -0,0 +1,11 @@
|
||||
###### WHITELIST USA ######
|
||||
root
|
||||
Waiting 2 minutes
|
||||
Creating ipset table
|
||||
0
|
||||
0
|
||||
Download Finished!
|
||||
Adding Networks to ipset ...
|
||||
Whitelisting USA with iptables...
|
||||
0
|
||||
Done
|
32
other/block_china
Executable file
32
other/block_china
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
echo "###### BLOCKING CHINA ######"
|
||||
echo
|
||||
|
||||
ipset -N china hash:net -exist
|
||||
ipset -F china
|
||||
|
||||
if [ -f "cn-aggregated.zone" ]
|
||||
then
|
||||
rm cn-aggregated.zone
|
||||
fi
|
||||
|
||||
wget http://ipdeny.com/ipblocks/data/aggregated/cn-aggregated.zone
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Download Finished!"
|
||||
fi
|
||||
|
||||
echo "Adding Networks to ipset ..."
|
||||
|
||||
for net in `cat cn-aggregated.zone`
|
||||
do
|
||||
ipset -A china $net
|
||||
done
|
||||
|
||||
echo "Blocking CN with iptables..."
|
||||
iptables -I INPUT -m set --match-set china src -j DROP
|
||||
echo "Done"
|
||||
|
11
other/log.txt
Normal file
11
other/log.txt
Normal file
@ -0,0 +1,11 @@
|
||||
###### WHITELIST USA ######
|
||||
root
|
||||
Waiting 2 minutes
|
||||
Creating ipset table
|
||||
0
|
||||
0
|
||||
Download Failed: 1
|
||||
Adding Networks to ipset ...
|
||||
Whitelisting USA with iptables...
|
||||
0
|
||||
Done
|
43
other/toggle_block
Executable file
43
other/toggle_block
Executable file
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
if [ ! -z $@ ]
|
||||
then
|
||||
echo "Checking Current Block State"
|
||||
NUM=`iptables -L --line-numbers | grep 'usa_state' | head -n 1 | cut -c1`
|
||||
echo
|
||||
echo "/----------------------------\\"
|
||||
if [ -z "$NUM" ]
|
||||
then
|
||||
echo "| iptable Rule Disabled |"
|
||||
else
|
||||
echo "| iptables Rule Enabled |"
|
||||
fi
|
||||
echo "\\----------------------------/"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
echo "Checking Current Block State"
|
||||
NUM=$(iptables -L --line-numbers | grep 'usa_state' | head -n 1 |cut -c1)
|
||||
|
||||
|
||||
if [ -z "$NUM" ]
|
||||
then
|
||||
echo "Enabling iptables Rule"
|
||||
sudo iptables -A INPUT -m set ! --match-set usa_state src -j DROP &>/dev/null
|
||||
else
|
||||
echo "Disabling iptables Rule"
|
||||
sudo iptables -D INPUT $NUM &>/dev/null
|
||||
fi
|
||||
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Success"
|
||||
exit 0
|
||||
else
|
||||
echo "Error"
|
||||
exit 1
|
||||
fi
|
||||
|
0
toggle_errors
Normal file
0
toggle_errors
Normal file
23504
us-aggregated.zone
Normal file
23504
us-aggregated.zone
Normal file
File diff suppressed because it is too large
Load Diff
62
whitelist_us
Executable file
62
whitelist_us
Executable file
@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
echo "###### WHITELIST USA ######"
|
||||
echo $(whoami)
|
||||
|
||||
echo "Waiting 2 minutes"
|
||||
sleep "120"
|
||||
echo "Creating ipset table"
|
||||
|
||||
sudo ipset -N usa_state hash:net -exist
|
||||
echo $?
|
||||
sudo ipset -F usa_state
|
||||
echo $?
|
||||
|
||||
if [ -f "/tmp/us-aggregated.zone" ]
|
||||
then
|
||||
sudo rm /tmp/us-aggregated.zone
|
||||
echo "Removing old ip list"
|
||||
fi
|
||||
|
||||
sudo wget http://ipdeny.com/ipblocks/data/aggregated/us-aggregated.zone -O us-aggregated.zone
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Download Finished!"
|
||||
else
|
||||
echo "Download Failed: $?"
|
||||
fi
|
||||
|
||||
|
||||
echo "Adding Networks to ipset ..."
|
||||
# add local networks
|
||||
sudo ipset -A usa_state 192.168.0.0/16
|
||||
sudo ipset -A usa_state 127.0.0.0/8
|
||||
sudo ipset -A usa_state 10.0.0.0/8
|
||||
sudo ipset -A usa_state 172.16.0.0/12
|
||||
# add usa
|
||||
#for net in `cat /tmp/us-aggregated.zone`
|
||||
#do
|
||||
# sudo ipset -A usa_state $net
|
||||
#done
|
||||
|
||||
# Split File
|
||||
split -l 6250 us-aggregated.zone
|
||||
|
||||
# Run Threads
|
||||
/home/brickman/scripts/block_ips/add_ipset a &
|
||||
/home/brickman/scripts/block_ips/add_ipset b &
|
||||
/home/brickman/scripts/block_ips/add_ipset c &
|
||||
/home/brickman/scripts/block_ips/add_ipset d &
|
||||
/home/brickman/scripts/block_ips/add_ipset c &
|
||||
|
||||
wait
|
||||
|
||||
|
||||
|
||||
echo "Whitelisting USA with iptables..."
|
||||
sudo iptables -A INPUT -m set ! --match-set usa_state src -j DROP
|
||||
echo $?
|
||||
echo "Done"
|
||||
|
Loading…
Reference in New Issue
Block a user