PHPの配列でそのまま使えるような形でTorのアドレスを出す（bash)

torからのアクセスを別ページに案内させたりブロックしたい時に使うかも（？）
#デデドン！
```bash:tor-ip.sh
#!/bin/bash

tor_ip_list=`curl https://check.torproject.org/exit-addresses --tlsv1`

if [ $? -ne 0 ]; then
  exit 1
fi

echo "${tor_ip_list}" | grep "ExitAddress" | while read line; do
  ip=`echo "${line}" | sed -e "s/^ExitAddress \([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/g"`
  print=`echo '"'"${ip}"'"' | tr '\n' ','`
  echo $print | tr '\n' ' '
done
```
#実行結果
```bash
uuparupa@orange-fs:/var/www/html$ sudo bash test.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  157k  100  157k    0     0   203k      0 --:--:-- --:--:-- --:--:--  203k
"162.247.74.201", "178.17.170.116", "104.218.63.73", "199.249.230.103", "176.10.104.240", "95.143.193.125", "178.17.170.135", "93.174.93.133", "193.171.202.150", "79.172.193.32", "185.100.85.61", "82.221.131.71", "96.66.15.147", "72.210.252.137", "123.30.128.138", "187.20.201.20", "78.142.175.70", "216.218.134.12", "199.249.230.79", "178.175.143.166", "192.42.116.17", "209.141.51.150", "176.10.99.200", "195.254.134.194", "91.177.41.3", "176.123.26.99", "193.201.225.45", "193.36.119.17", "160.119.249.24", "23.129.64.180", "85.93.218.204", "49.50.107.221", "185.165.168.168", "109.70.100.23", "45.76.115.159", "185.56.171.94", "195.189.96.147", "195.176.3.20", "178.17.170.194", "54.37.16.241", "23.129.64.100", "59.115.192.22", "95.165.133.22", "104.217.248.58", "109.236.90.209", "185.220.101.60", "162.247.74.216", "82.221.141.96", "87.118.116.90", "122.16.183.5", "23.129.64.165", "216.158.98.38", "109.70.100.26", "195.176.3.20", "194.71.109.44", "185.193.126.161", "62.102.148.68", "62.219.3.48", "185.100.86.100", "185.222.202.12", "23.129.64.213", "185.220.101.29", "23.129.64.196", "31.31.74.47", "220.218.70.141", "185.220.101.5", "185.227.68.78", "167.86.94.107", "23.129.64.188", "31.131.4.171", "193.148.69.176", "80.127.116.96", "193.169.255.102", "185.4.132.135", "92.222.180.10", "37.9.231.195", "216.186.250.53", "185.220.101.70", "199.249.230.108", "104.140.100.46", "178.175.132.225", "193.169.145.194", "141.136.44.11", "91.146.121.3", "23.239.23.104", "23.129.64.157", "51.75.71.123", "171.25.193.25", "204.11.50.131", "210.140.10.35", "74.82.47.194", "51.68.139.151", "45.33.43.215", "87.118.122.51", "209.141.61.45", "103.75.190.11", "178.17.170.196", "178.175.132.227", "128.199.213.157", "199.249.230.85", "160.119.253.114", "91.203.146.126", "193.169.145.202", "87.120.36.157", "82.94.251.227", "94.230.208.148", "51.83.76.139", "104.244.76.13", "185.220.102.4", "185.220.101.62", "199.249.230.104", "192.42.116.28", "23.129.64.194", "195.123.216.32", "199.249.230.66", "185.227.68.102", "160.202.162.186", "220.135.203.167", "158.69.217.248", "104.218.63.75", "79.143.186.17", "23.129.64.200", "51.15.7.60", "66.146.193.33", "77.247.181.162", "85.25.44.141", "210.3.102.152", "194.88.143.66", "92.243.8.127", "195.123.217.153", "23.129.64.210", "5.79.113.168", "51.15.59.9", "89.31.96.168", "178.17.170.164", "200.98.161.148", "67.215.255.140", "205.185.121.209", "193.9.114.139", "151.74.133.191", "37.228.129.2", "70.168.93.214", "46.182.19.15", "185.220.101.69", "185.220.101.46", "178.17.174.196", "66.155.4.213", "46.165.254.160", "31.31.72.24", "82.221.139.190", "87.118.116.103", "50.116.37.141", "185.86.150.52", "173.14.173.227", "23.129.64.215", "198.58.107.53", "185.220.101.1", "185.195.237.25", "46.182.18.29", "176.152.45.213", "163.172.41.228", "178.17.171.102", "185.113.128.30", "185.165.168.229", "37.128.222.30", "23.129.64.162", "91.203.145.116", "189.84.21.44", "184.105.220.24", "160.119.249.240", "185.165.168.77", "195.123.237.251", "178.17.170.81", "23.129.64.216", "185.104.121.6", "176.10.99.200", "91.250.242.12", "199.249.230.80", "178.18.83.215", "46.182.19.219", "97.74.237.196", "200.98.137.240", "64.113.32.29", "94.230.208.147", "92.222.127.232", "46.182.19.219", "209.141.45.212", "144.217.60.211", "199.195.251.84", "87.120.254.114", "130.185.250.76", "162.247.74.74", "178.17.170.105", "37.134.165.205", "198.98.57.155", "98.128.172.233", "185.220.101.21", "82.118.242.113", "118.163.74.160", "205.168.84.133", "199.249.230.113", "144.217.164.104", "199.249.230.89", "23.129.64.211", "23.129.64.153", "193.148.69.145", "23.129.64.168", "204.17.56.42", "174.18.107.149", "178.175.135.100", "185.107.70.202", "46.182.106.190", "51.68.214.45", "178.17.170.117", "223.26.48.248", "178.165.72.177", "62.210.116.201", "179.48.251.188", "185.165.169.160", "192.195.80.10", "23.129.64.203", "92.222.22.113", "195.228.45.176", "185.65.206.154", "104.218.63.76", "176.10.99.200", "173.82.154.45", "199.249.230.83", "38.39.192.78", "87.118.110.27", "51.15.224.0", "178.17.166.150", "50.247.195.124", "185.220.102.7", "210.140.10.24", "37.48.115.62", "185.220.101.67", "178.17.171.78", "195.206.105.217", "200.98.146.219", "185.220.101.68", "185.100.85.101", "199.249.230.102", "149.202.170.60", "46.98.203.186", "71.19.148.20", "217.12.221.131", "209.126.101.29", "5.34.183.105", "176.10.99.200", "217.70.189.203", "206.248.184.127", "162.247.73.192", "199.249.230.116", "145.239.93.33", "89.41.173.191", "185.112.146.138", "95.216.145.1", "185.104.121.5", "198.98.61.88", "5.39.217.14", "198.98.61.249", "185.165.169.71", "89.144.12.17", "176.10.99.200", "54.36.108.162", "109.236.90.209", "85.248.227.165", "23.129.64.195", "195.176.3.23", "178.175.135.99", "71.19.144.106", "94.248.6.148", "185.220.101.34", "162.247.74.202", "157.157.87.22", "87.120.37.79", "162.213.0.243", "31.31.74.131", "185.220.101.27", "83.135.109.169", "23.129.64.183", "51.38.150.104", "95.130.10.69", "62.102.148.67", "158.69.212.107", "87.118.116.12", "54.39.151.167", "212.21.66.6", "207.180.224.17", "193.150.121.66", "158.255.7.61", "167.114.181.152", "109.70.100.20", "198.98.53.79", "199.127.226.150", "46.246.49.134", "45.114.130.4", "37.220.36.240", "185.195.237.117", "23.129.64.189", "79.174.12.138", "178.175.148.165", "51.38.134.189", "18.184.251.194", "51.38.150.126", "51.15.123.230", "185.248.160.231", "195.123.212.132", "95.130.12.33", "80.79.23.7", "23.129.64.163", "65.181.122.48", "162.247.74.204", "178.175.148.224", "103.234.220.195", "212.81.199.159", "46.38.235.14", "185.107.47.215", "51.38.64.136", "54.36.222.37", "109.248.11.42", "158.69.212.109", "103.236.201.88", "116.203.130.127", "144.217.90.68", "50.99.193.144", "191.114.108.134", "192.160.102.166", "199.249.230.75", "92.62.139.103", "82.221.131.5", "173.212.244.116", "192.160.102.170", "84.19.190.178", "179.48.248.17", "91.92.109.43", "217.70.191.220", "185.127.25.192", "103.1.14.76", "199.249.230.122", "89.234.157.254", "91.219.236.127", "196.41.123.180", "185.227.82.9", "77.247.181.163", "198.98.56.149", "185.112.146.55", "104.244.78.233", "37.200.98.117", "35.0.127.52", "192.34.80.176", "109.70.100.24", "158.69.217.87", "46.182.18.40", "185.11.146.159", "23.129.64.207", "18.18.248.17", "37.187.129.166", "185.42.170.203", "164.77.133.220", "158.69.192.200", "207.244.70.35", "213.252.140.118", "65.181.123.254", "200.86.90.194", "185.62.57.91", "54.37.157.229", "205.185.113.210", "172.98.193.43", "139.162.7.42", "208.12.90.101", "185.225.16.146", "199.249.230.118", "45.56.100.84", "203.78.103.37", "46.182.18.29", "190.216.2.136", "185.220.101.28", "199.249.230.117", "5.135.158.101", "95.128.43.164", "185.220.101.20", "23.129.64.158", "213.61.215.54", "176.10.99.200", "23.129.64.156", "144.217.166.59", "91.207.174.75", "192.42.116.15", "65.19.167.131", "185.221.172.60", "176.123.26.176", "51.15.95.234", "91.203.144.194", "104.131.206.23", "91.121.19.195", "212.16.104.33", "176.10.99.200", "41.100.126.166", "198.98.58.135", "23.129.64.184", "37.187.129.166", "199.249.230.86", "104.244.78.124", "185.220.101.15", "185.10.68.126", "45.79.144.222", "5.165.66.255", "23.129.64.212", "195.123.228.161", "192.155.95.222", "72.221.196.141", "213.108.105.71", "5.189.146.133", "198.167.223.100", "176.126.70.240", "23.129.64.150", "51.15.37.97", "178.17.170.13", "198.98.50.201", "185.220.100.252", "46.29.248.238", "23.129.64.214", "185.220.100.252", "23.129.64.206", "46.194.166.254", "162.247.74.27", "51.15.125.181", "185.220.101.50", "23.129.64.159", "89.187.143.31", "209.141.41.125", "94.102.51.78", "217.12.221.196", "185.220.101.0", "23.129.64.205", "41.77.137.114", "178.239.176.73", "185.10.68.123", "162.247.74.206", "185.4.132.183", "51.15.117.50", "195.154.179.3", "46.98.199.114", "62.210.37.82", "185.100.87.129", "23.129.64.151", "37.139.8.104", "104.244.74.194", "131.255.4.188", "87.120.254.98", "192.42.116.22", "185.220.100.252", "185.220.101.13", "185.220.101.30", "217.170.197.89", "158.69.193.32", "92.63.173.28", "178.17.174.229", "45.125.65.45", "185.220.100.255", "199.87.154.255", "51.254.208.245", "178.17.170.23", "192.42.116.26", "46.29.248.238", "62.210.105.116", "185.34.33.2", "104.244.78.39", "144.217.60.211", "37.134.165.205", "213.95.149.22", "109.70.100.28", "199.249.230.68", "167.114.185.246", "77.247.181.162", "178.17.166.149", "209.141.34.95", "162.247.74.217", "144.217.60.239", "80.68.92.225", "79.134.234.247", "116.203.91.122", "204.194.29.4", "104.200.20.46", "164.132.51.91", "213.160.32.233", "107.174.206.26", "139.162.10.72", "176.31.208.193", "199.249.230.88", "185.104.121.4", "87.81.148.61", "87.120.254.105", "51.15.209.128", "141.98.254.225", "185.125.33.242", "176.58.89.182", "46.194.166.254", "77.247.181.162", "204.85.191.8", "209.141.58.114", "178.175.148.227", "185.220.101.31", "46.98.208.201", "89.31.57.5", "176.10.99.200", "185.220.101.48", "104.244.77.171", "199.249.230.71", "149.56.44.47", "185.150.44.22", "23.129.64.154", "199.249.230.110", "50.7.151.127", "23.129.64.161", "192.42.116.16", "185.86.78.228", "104.244.72.99", "104.40.73.53", "192.160.102.164", "185.65.135.180", "37.187.12.100", "18.85.192.253", "217.115.10.132", "209.95.51.11", "185.147.80.155", "125.212.241.131", "185.4.132.183", "162.247.74.213", "23.129.64.191", "104.244.74.78", "195.254.134.242", "38.117.96.154", "65.19.167.132", "193.169.145.66", "80.241.60.207", "185.104.121.7", "51.15.122.200", "77.153.244.115", "185.185.25.55", "95.216.107.148", "137.74.169.241", "185.220.101.66", "167.88.7.134", "104.244.74.97", "195.135.194.134", "41.77.136.114", "78.130.128.106", "41.215.241.146", "62.102.148.68", "169.197.97.34", "204.17.56.42", "142.44.133.83", "199.249.230.84", "23.129.64.169", "198.98.50.112", "94.168.35.70", "195.176.3.24", "23.129.64.202", "178.17.174.198", "109.70.100.22", "176.10.99.200", "128.14.136.158", "82.94.132.34", "185.4.132.135", "80.67.172.162", "23.129.64.208", "185.220.101.25", "178.175.132.230", "77.247.181.163", "179.43.149.44", "62.219.3.47", "185.193.125.140", "5.79.68.161", "185.220.101.33", "23.129.64.204", "23.129.64.182", "89.234.157.254", "46.101.61.36", "185.72.244.24", "194.99.106.147", "18.85.192.253", "185.220.101.26", "51.15.106.67", "103.28.53.138", "91.219.237.244", "199.249.230.73", "185.220.100.253", "45.79.73.22", "142.93.168.48", "185.10.68.30", "198.167.223.190", "23.129.64.167", "77.8.152.14", "204.8.156.142", "185.193.125.42", "93.115.241.194", "185.10.68.184", "185.220.101.65", "82.221.131.102", "87.118.92.43", "178.17.170.149", "109.70.100.21", "145.239.91.37", "109.70.100.27", "185.100.86.154", "109.201.133.100", "46.182.19.15", "172.96.118.14", "185.220.101.35", "190.10.8.50", "198.50.200.131", "195.123.227.106", "185.220.100.255", "185.65.205.10", "185.61.138.43", "185.220.100.254", "185.220.100.253", "91.244.181.85", "162.213.3.221", "192.42.116.23", "94.230.208.147", "18.184.251.194", "51.89.3.99", "46.182.18.40", "185.100.86.128", "185.222.202.104", "95.42.126.41", "185.220.101.49", "145.239.214.38", "95.142.161.63", "37.48.120.196", "193.110.157.151", "199.249.230.74", "94.156.77.24", "82.223.14.245", "195.176.3.23", "114.32.35.232", "199.249.230.106", "98.174.90.43", "144.217.166.19", "192.42.116.14", "199.249.230.70", "86.104.15.15", "192.42.116.27", "72.14.179.10", "92.50.105.150", "54.36.189.105", "31.185.104.19", "31.131.2.19", "199.249.230.105", "77.81.104.124", "185.100.85.190", "66.175.208.248", "91.121.192.154", "139.99.123.88", "178.175.132.228", "199.249.230.82", "46.165.230.5", "171.25.193.77", "163.172.11.200", "51.15.59.9", "185.220.102.6", "185.220.102.6", "23.129.64.155", "171.25.193.78", "199.249.230.67", "185.216.32.170", "128.31.0.13", "51.77.62.52", "138.59.18.110", "144.217.80.80", "104.244.73.65", "91.219.236.136", "185.46.57.39", "192.42.116.25", "203.78.103.152", "178.17.174.232", "162.247.74.200", "191.96.145.141", "185.225.69.52", "200.52.55.54", "85.159.237.210", "195.123.212.75", "144.217.7.154", "192.42.116.18", "23.129.64.193", "176.10.107.180", "192.68.11.219", "84.209.51.186", "5.34.181.34", "185.231.245.244", "185.129.62.62", "51.15.49.134", "104.244.77.199", "198.50.200.129", "24.3.111.78", "54.39.148.234", "185.35.138.92", "62.212.95.51", "176.10.104.240", "217.12.223.56", "31.185.104.20", "149.202.238.204", "104.218.63.74", "91.203.5.165", "83.136.106.153", "173.199.70.185", "23.129.64.181", "185.191.204.254", "52.167.231.173", "5.196.66.162", "176.53.90.26", "199.249.230.123", "178.17.174.14", "199.249.230.111", "103.208.220.226", "176.10.99.200", "104.244.78.231", "51.158.166.175", "193.9.115.24", "185.117.215.9", "199.249.230.64", "139.99.98.191", "109.70.100.18", "199.195.248.177", "23.129.64.166", "162.247.72.199", "54.39.148.232", "180.150.226.99", "51.255.106.85", "103.208.220.122", "103.236.201.110", "51.38.150.105", "178.175.131.194", "185.177.151.34", "158.69.192.239", "144.217.60.239", "178.17.174.10", "195.176.3.19", "37.28.154.68", "95.141.36.127", "199.249.230.100", "23.129.64.187", "179.43.146.230", "199.249.230.101", "88.99.85.235", "185.222.202.65", "108.85.99.10", "185.220.101.3", "188.127.224.234", "185.220.101.32", "91.219.238.95", "5.79.68.161", "51.77.201.37", "85.248.227.164", "192.99.245.235", "103.234.220.197", "198.211.122.191", "185.100.85.132", "156.54.63.235", "173.255.192.219", "54.39.181.229", "185.127.25.68", "178.17.170.91", "162.244.81.196", "94.140.116.189", "192.42.116.19", "144.217.255.89", "119.236.50.147", "178.17.170.88", "198.96.155.3", "195.176.3.23", "185.244.149.218", "176.107.179.147", "87.120.254.204", "95.141.35.15", "5.252.176.20", "163.172.11.200", "71.19.148.20", "144.217.166.65", "195.176.3.19", "172.107.92.18", "65.19.167.132", "199.195.251.251", "185.220.101.56", "192.160.102.169", "187.178.75.109", "185.86.148.211", "23.129.64.195", "185.220.101.6", "91.92.109.52", "178.17.171.39", "51.255.45.144", "89.187.143.81", "5.199.130.188", "217.170.197.83", "178.17.170.194", "51.75.162.53", "109.70.100.19", "31.185.104.21", "185.175.208.180", "87.101.92.157", "67.163.131.76", "204.85.191.9", "199.249.230.107", "103.28.52.93", "171.244.33.189", "185.83.214.121", "178.20.55.18", "216.239.90.19", "163.172.66.247", "185.175.208.179", "191.34.119.244", "95.211.118.194", "51.15.1.221", "199.249.230.69", "107.181.161.182", "185.100.87.207", "109.70.100.25", "192.160.102.165", "79.137.79.167", "65.181.124.115", "23.129.64.190", "195.254.135.76", "185.220.101.22", "203.78.103.113", "185.255.112.112", "185.220.102.8", "51.38.162.232", "144.217.165.133", "178.17.171.197", "163.172.160.182", "54.37.234.66", "199.249.230.78", "163.172.151.47", "217.100.113.174", "5.34.181.35", "199.249.230.87", "199.249.230.115", "195.123.213.211", "124.109.1.207", "95.130.9.90", "107.181.174.66", "178.17.174.68", "185.86.148.90", "104.194.228.240", "185.222.202.133", "185.220.101.58", "185.220.101.7", "178.17.174.211", "176.126.83.211", "51.15.43.205", "5.135.65.145", "43.251.159.144", "82.118.242.128", "143.202.161.75", "178.175.143.165", "23.129.64.214", "213.136.92.52", "51.77.52.216", "185.125.33.114", "199.249.230.112", "176.10.99.200", "209.141.41.103", "40.124.44.53", "81.171.29.146", "185.195.237.24", "199.249.230.121", "69.164.207.234", "144.217.165.223", "185.195.237.118", "23.129.64.170", "188.214.104.146", "82.221.128.191", "217.115.10.131", "104.244.73.189", "23.140.160.28", "209.141.56.103", "158.174.122.199", "144.217.7.33", "163.172.151.47", "144.217.64.46", "160.119.249.239", "198.71.81.66", "185.220.102.8", "199.249.230.81", "62.102.148.69", "192.42.116.20", "37.187.129.166", "45.76.179.27", "185.130.44.108", "91.203.5.146", "198.27.77.134", "96.70.31.155", "104.244.76.26", "66.110.216.10", "37.187.239.8", "94.140.116.217", "51.15.53.83", "104.196.43.128", "205.185.117.149", "85.248.227.165", "158.69.201.47", "84.200.12.61", "180.149.125.139", "162.244.81.196", "87.118.122.30", "77.120.113.64", "107.155.49.126", "109.169.33.163", "171.25.193.20", "173.244.209.5", "178.17.170.112", "178.175.132.229", "167.114.34.150", "92.222.38.67", "178.175.143.163", "46.166.162.53", "199.249.230.109", "178.17.166.146", "195.176.3.24", "185.220.101.57", "178.175.143.164", "198.98.60.40", "178.175.135.101", "178.175.148.34", "192.42.116.13", "111.69.49.124", "144.217.166.26", "51.15.53.83", "166.70.207.2", "94.32.66.15", "185.220.102.7", "199.249.230.114", "162.247.74.7", "185.100.86.182", "185.121.168.254", "178.17.166.147", "185.10.68.76", "77.73.69.90", "149.202.208.203", "95.216.143.188", "185.220.101.44", "51.38.113.64", "176.58.100.98", "185.10.68.52", "59.127.163.155", "83.136.106.136", "23.129.64.186", "185.220.100.254", "130.149.80.199", "185.242.113.224", "205.185.120.227", "199.249.230.72", "178.175.135.102", "199.249.230.119", "185.220.101.12", "178.175.132.226", "171.25.193.235", "178.17.170.196", "107.173.58.166", "46.98.201.179", "185.220.101.61", "58.96.107.246", "66.70.228.168", "178.17.166.148", "198.167.223.38", "109.69.67.17", "23.129.64.209", "178.20.55.16", "27.122.59.100", "205.185.127.219", "185.61.149.193", "149.202.238.204", "199.249.230.76", "23.129.64.160", "185.169.42.133", "23.129.64.152", "51.75.71.123", "167.71.56.222", "109.70.100.29", "23.129.64.206", "94.32.66.48", "5.2.64.194", "188.68.45.180", "185.233.100.23", "192.227.147.100", "23.129.64.185", "185.248.100.224", "51.77.136.82", "198.98.59.161", "82.228.252.20", "134.255.234.55", "81.171.24.199", "192.160.102.168", "192.42.116.24", "199.249.230.120", "5.150.254.67", "46.98.209.135", "46.165.254.166", "51.15.48.204", "49.50.66.209", "51.15.80.14", "31.220.42.86", "50.7.176.2", "195.228.45.176", "185.220.101.45", "5.2.77.146", "51.15.235.211", "104.218.63.72", "45.56.103.80", "23.129.64.192", "89.236.34.117", "51.15.68.66", "185.248.160.21", "185.220.101.24", "185.220.102.4", "199.249.230.77", "199.249.230.65", "23.129.64.201", "77.250.227.202", "45.64.186.102", "66.42.224.235", "5.2.67.138", "195.123.224.108",
```
#備考
- たまにcurlがエラー返す

#参考(ほぼ元）
####orleika/tor_ip_list.sh
https://gist.github.com/orleika/3601ad992505dcc0f7d0cf937cfe3737
（感謝！）
#使う時
####PHPで簡単なBANをする
https://qiita.com/Orangelinux/items/1c50bd68ffcc5e6829d2
これとかの配列のところに組み込むとtorからのアクセスをブロックできます。

#あとがき
torからのアクセスを本来ブロックしたり迂回させるべきではないと思うけど悪用するユーザーがいるのも事実なのでうーん....