From 5669e93f5f362a0d70eeca856f8fb3cdaa9930f8 Mon Sep 17 00:00:00 2001 From: Husky <39809509+Huskydog9988@users.noreply.github.com> Date: Tue, 29 Jul 2025 12:19:44 -0400 Subject: [PATCH 1/3] use maintained proxy list --- ansible/files/paper-config/plugins/BanStick/config.yml | 2 +- ansible/files/pvp-config/plugins/BanStick/config.yml | 2 +- plugins/banstick-paper/src/main/resources/config.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ansible/files/paper-config/plugins/BanStick/config.yml b/ansible/files/paper-config/plugins/BanStick/config.yml index 870eab9035..fa7148fe26 100644 --- a/ansible/files/paper-config/plugins/BanStick/config.yml +++ b/ansible/files/paper-config/plugins/BanStick/config.yml @@ -99,7 +99,7 @@ proxy: ban: length: 163800000 message: 'VPS / VPN Proxy use is generally prohibited. Issue a ticket at support in the CivMC Discord to discuss: https://discord.gg/nDnsU6vJqg' - url: https://raw.githubusercontent.com/client9/ipcat/master/datacenters.csv + url: https://raw.githubusercontent.com/growlfm/ipcat/refs/heads/main/datacenters.csv period: 576000 delay: 4200 # Configure the tor check source; set autoban to true to not only track tor usage but also pre-set bans for tor users diff --git a/ansible/files/pvp-config/plugins/BanStick/config.yml b/ansible/files/pvp-config/plugins/BanStick/config.yml index 870eab9035..fa7148fe26 100644 --- a/ansible/files/pvp-config/plugins/BanStick/config.yml +++ b/ansible/files/pvp-config/plugins/BanStick/config.yml @@ -99,7 +99,7 @@ proxy: ban: length: 163800000 message: 'VPS / VPN Proxy use is generally prohibited. Issue a ticket at support in the CivMC Discord to discuss: https://discord.gg/nDnsU6vJqg' - url: https://raw.githubusercontent.com/client9/ipcat/master/datacenters.csv + url: https://raw.githubusercontent.com/growlfm/ipcat/refs/heads/main/datacenters.csv period: 576000 delay: 4200 # Configure the tor check source; set autoban to true to not only track tor usage but also pre-set bans for tor users diff --git a/plugins/banstick-paper/src/main/resources/config.yml b/plugins/banstick-paper/src/main/resources/config.yml index fb92f6a576..0a5f21c13c 100644 --- a/plugins/banstick-paper/src/main/resources/config.yml +++ b/plugins/banstick-paper/src/main/resources/config.yml @@ -97,7 +97,7 @@ proxy: ban: length: 163800000 message: VPS / VPN Proxy use is generally prohibited. Modmail to www.reddit.com/r/Devoted to discuss - url: https://raw.githubusercontent.com/client9/ipcat/master/datacenters.csv + url: https://raw.githubusercontent.com/growlfm/ipcat/refs/heads/main/datacenters.csv period: 576000 delay: 4200 # Configure the tor check source; set autoban to true to not only track tor usage but also pre-set bans for tor users From c54d701fe1ab9197da9ecea941a8e2eba818969d Mon Sep 17 00:00:00 2001 From: Husky <39809509+Huskydog9988@users.noreply.github.com> Date: Tue, 29 Jul 2025 21:15:14 -0400 Subject: [PATCH 2/3] feed banstick list of public proxies --- .../paper-config/plugins/BanStick/config.yml | 12 ++ .../pvp-config/plugins/BanStick/config.yml | 12 ++ .../minecraft/banstick/data/BSIPData.java | 3 +- .../banstick/proxy/PROXYListLoader.java | 137 ++++++++++++++++++ .../src/main/resources/config.yml | 13 ++ 5 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/proxy/PROXYListLoader.java diff --git a/ansible/files/paper-config/plugins/BanStick/config.yml b/ansible/files/paper-config/plugins/BanStick/config.yml index fa7148fe26..f7b32af4f8 100644 --- a/ansible/files/paper-config/plugins/BanStick/config.yml +++ b/ansible/files/paper-config/plugins/BanStick/config.yml @@ -102,6 +102,18 @@ proxy: url: https://raw.githubusercontent.com/growlfm/ipcat/refs/heads/main/datacenters.csv period: 576000 delay: 4200 + proxylist: + enable: true + defaultScore: 3.0 + ban: + length: 86400000 + message: VPS / VPN Proxy use is generally prohibited. Modmail to www.reddit.com/r/CivMC to discuss + urls: + - https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/socks5.txt + - https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/socks4.txt + - https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/http.txt + period: 576000 + delay: 4200 # Configure the tor check source; set autoban to true to not only track tor usage but also pre-set bans for tor users tor: check: true diff --git a/ansible/files/pvp-config/plugins/BanStick/config.yml b/ansible/files/pvp-config/plugins/BanStick/config.yml index fa7148fe26..f7b32af4f8 100644 --- a/ansible/files/pvp-config/plugins/BanStick/config.yml +++ b/ansible/files/pvp-config/plugins/BanStick/config.yml @@ -102,6 +102,18 @@ proxy: url: https://raw.githubusercontent.com/growlfm/ipcat/refs/heads/main/datacenters.csv period: 576000 delay: 4200 + proxylist: + enable: true + defaultScore: 3.0 + ban: + length: 86400000 + message: VPS / VPN Proxy use is generally prohibited. Modmail to www.reddit.com/r/CivMC to discuss + urls: + - https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/socks5.txt + - https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/socks4.txt + - https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/http.txt + period: 576000 + delay: 4200 # Configure the tor check source; set autoban to true to not only track tor usage but also pre-set bans for tor users tor: check: true diff --git a/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/data/BSIPData.java b/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/data/BSIPData.java index ae0a3ef366..0e4ab44ee4 100644 --- a/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/data/BSIPData.java +++ b/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/data/BSIPData.java @@ -302,7 +302,8 @@ public static BSIPData byExactIP(BSIP ip) { allIPDataID.put(data.idid, data); return data; } else { - BanStick.getPlugin().warning("Failed to retrieve IP Data by exact IP: {0} - not found", ip); + // No reason to log here, just spams console, especially on import + // BanStick.getPlugin().warning("Failed to retrieve IP Data by exact IP: {0} - not found", ip); } } } catch (SQLException se) { diff --git a/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/proxy/PROXYListLoader.java b/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/proxy/PROXYListLoader.java new file mode 100644 index 0000000000..2c08f4bd1f --- /dev/null +++ b/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/proxy/PROXYListLoader.java @@ -0,0 +1,137 @@ +package com.programmerdan.minecraft.banstick.proxy; + +import com.programmerdan.minecraft.banstick.BanStick; +import com.programmerdan.minecraft.banstick.data.BSBan; +import com.programmerdan.minecraft.banstick.data.BSIP; +import com.programmerdan.minecraft.banstick.data.BSIPData; +import com.programmerdan.minecraft.banstick.handler.ProxyLoader; +import inet.ipaddr.IPAddress; +import inet.ipaddr.IPAddressString; +import org.bukkit.configuration.ConfigurationSection; +import org.jetbrains.annotations.NotNull; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URI; +import java.net.URL; +import java.util.*; + +public final class PROXYListLoader extends ProxyLoader { + + private @NotNull List urls; + private float proxyScore; + private boolean autoBan; + private long banLength; + private String banMessage; + + public PROXYListLoader(ConfigurationSection config) { + super(config); + } + + @Override + public void run() { + BanStick.getPlugin().info("Running proxylist loader: {0}", name()); + for (String url : this.urls) { + try { + URL connection = new URI(url).toURL(); + InputStream readIn = connection.openStream(); + BufferedReader in = new BufferedReader(new InputStreamReader(readIn)); + String line = in.readLine(); + int errors = 0; + long lines = 0; + while (line != null) { + lines++; + if (lines % 50 == 0) { + BanStick.getPlugin().info("Checked {0} entries from proxylist so far", lines); + } + if (errors > 10) { + break; + } + + String[] parts = line.split(":"); + if (parts.length != 2) { + errors++; + continue; + } + String ip = parts[0]; + IPAddressString ipAddressString = new IPAddressString(ip); + ipAddressString.validate(); + IPAddress ipAddress = ipAddressString.toAddress(); + + BSIP found = BSIP.byIPAddress(ipAddress); + if (found == null) { + found = BSIP.create(ipAddress); + } + + BSIPData data = BSIPData.byExactIP(found); + if (data == null) { + data = BSIPData.create(found, null, null, null, null, null, null, null, + null, null, null, null, proxyScore, "proxylist Proxy Loader", null); + } + + if (autoBan) { + boolean wasmatch = false; + + List ban = BSBan.byProxy(data, true); + if (!(ban == null || ban.isEmpty())) { + // look for match; if unexpired, extend. + for (int i = ban.size() - 1; i >= 0; i--) { + BSBan pickOne = ban.get(i); + if (pickOne.isAdminBan()) { + continue; // skip admin entered bans. + } + if (pickOne.getBanEndTime() != null && pickOne.getBanEndTime().after(new Date())) { + if (this.banLength < 0) { // endless + pickOne.clearBanEndTime(); + } else { + pickOne.setBanEndTime(new Date(System.currentTimeMillis() + + this.banLength)); + } + wasmatch = true; + break; + } + } + } + if (!wasmatch) { + BSBan.create(data, this.banMessage, + this.banLength < 0 ? null : new Date(System.currentTimeMillis() + + this.banLength), false); + } + } + + line = in.readLine(); + } + if (errors > 10) { + BanStick.getPlugin().warning("Cancelled proxylist load due to too many errors."); + } + BanStick.getPlugin().info("Finished loading {0} entries from proxylist: {1}", lines, url); + } catch (Exception e) { + BanStick.getPlugin().warning("Failed reading from proxylist: " + url); + BanStick.getPlugin().warning(" Failure message: ", e); + } + } + } + + @Override + public void setup(ConfigurationSection config) { + this.proxyScore = (float) config.getDouble("defaultScore", 3.0d); + this.autoBan = config.isConfigurationSection("ban"); + if (this.autoBan) { + this.banLength = config.getLong("ban.length", -1L); + this.banMessage = config.getString("ban.message", null); + } + + if (config.isList("urls")) { + this.urls = config.getStringList("urls"); + BanStick.getPlugin().info("Loaded {0} proxylist URLs", this.urls.size()); + } else { + this.urls = new ArrayList<>(); + BanStick.getPlugin().warning("No proxylist URLs configured, loader will not run."); + } + } + + @Override + public String name() { + return "proxylist"; + } +} diff --git a/plugins/banstick-paper/src/main/resources/config.yml b/plugins/banstick-paper/src/main/resources/config.yml index 0a5f21c13c..8e7aa6c449 100644 --- a/plugins/banstick-paper/src/main/resources/config.yml +++ b/plugins/banstick-paper/src/main/resources/config.yml @@ -100,6 +100,19 @@ proxy: url: https://raw.githubusercontent.com/growlfm/ipcat/refs/heads/main/datacenters.csv period: 576000 delay: 4200 + proxylist: + enable: true + defaultScore: 3.0 + ban: + length: 86400000 + message: VPS / VPN Proxy use is generally prohibited. Modmail to www.reddit.com/r/CivMC to discuss + urls: + - https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/socks5.txt + - https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/socks4.txt + - https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/http.txt + period: 576000 + delay: 4200 + # Configure the tor check source; set autoban to true to not only track tor usage but also pre-set bans for tor users tor: check: true From f23528ab2ef209a7ab37360b9a175b4926c347f0 Mon Sep 17 00:00:00 2001 From: Husky <39809509+Huskydog9988@users.noreply.github.com> Date: Tue, 29 Jul 2025 22:24:07 -0400 Subject: [PATCH 3/3] fix ScrapeFreeProxyList not pulling ips --- .../banstick/proxy/PROXYListLoader.java | 6 ++- .../banstick/scraper/ScrapeFreeProxyList.java | 40 ++++++++++++------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/proxy/PROXYListLoader.java b/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/proxy/PROXYListLoader.java index 2c08f4bd1f..f4def3a228 100644 --- a/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/proxy/PROXYListLoader.java +++ b/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/proxy/PROXYListLoader.java @@ -30,9 +30,10 @@ public PROXYListLoader(ConfigurationSection config) { @Override public void run() { - BanStick.getPlugin().info("Running proxylist loader: {0}", name()); for (String url : this.urls) { try { + BanStick.getPlugin().debug("Scraping {0}", url); + URL connection = new URI(url).toURL(); InputStream readIn = connection.openStream(); BufferedReader in = new BufferedReader(new InputStreamReader(readIn)); @@ -54,6 +55,7 @@ public void run() { continue; } String ip = parts[0]; + String port = parts[1]; IPAddressString ipAddressString = new IPAddressString(ip); ipAddressString.validate(); IPAddress ipAddress = ipAddressString.toAddress(); @@ -66,7 +68,7 @@ public void run() { BSIPData data = BSIPData.byExactIP(found); if (data == null) { data = BSIPData.create(found, null, null, null, null, null, null, null, - null, null, null, null, proxyScore, "proxylist Proxy Loader", null); + null, null, null, null, proxyScore, "proxylist Proxy Loader", "Anon Proxy on Port: " + port); } if (autoBan) { diff --git a/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/scraper/ScrapeFreeProxyList.java b/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/scraper/ScrapeFreeProxyList.java index 84fdbd829a..3df534a05f 100644 --- a/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/scraper/ScrapeFreeProxyList.java +++ b/plugins/banstick-paper/src/main/java/com/programmerdan/minecraft/banstick/scraper/ScrapeFreeProxyList.java @@ -29,12 +29,13 @@ public class ScrapeFreeProxyList extends ScraperWorker { private long banLength; private String[] urls = new String[]{ - "https://free-proxy-list.net", - "http://www.sslproxies.org/", - "http://www.us-proxy.org/", - "http://free-proxy-list.net/uk-proxy.html", - "http://www.socks-proxy.net/", - "http://free-proxy-list.net/anonymous-proxy.html" + "https://free-proxy-list.net/en/", + "https://free-proxy-list.net/en/socks-proxy.html", + "https://free-proxy-list.net/en/us-proxy.html", + "https://free-proxy-list.net/en/uk-proxy.html", + "https://free-proxy-list.net/en/ssl-proxy.html", + "https://free-proxy-list.net/en/anonymous-proxy.html", + "https://free-proxy-list.net/en/google-proxy.html", }; public ScrapeFreeProxyList(ConfigurationSection config) { @@ -66,31 +67,36 @@ public void scrape() { */ public void scrapeOne(String url) { try { + int count = 0; BanStick.getPlugin().debug("Scraping {0}", url); Document doc = Jsoup.connect(url).userAgent( "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0").get(); - Elements iptable = doc.select("table#proxylisttable"); - Elements body = iptable.select("tbody"); - Elements trs = body.select("tr"); - BanStick.getPlugin().debug("Found {0} proxy IPs to scrape", trs.size()); - for (Element tr : trs) { - Elements tds = tr.select("td"); + Element table = doc.selectXpath("//*[@id=\"list\"]/div/div[2]/div/table").first(); + if (table == null) { + BanStick.getPlugin().warning("No table found at " + url); + return; + } + + Elements rows = table.select("tbody > tr"); + BanStick.getPlugin().debug("Found {0} proxy IPs to scrape", rows.size()); + for (Element row : rows) { + Elements cell = row.select("td"); String ip = null; try { - ip = tds.first().text(); + ip = cell.first().text(); } catch (Exception e) { continue; } String country = null; try { - country = tds.get(3).text(); + country = cell.get(3).text(); } catch (Exception e) { // intentionally ignore errors. } String port = null; try { - port = tds.get(1).text(); + port = cell.get(1).text(); } catch (Exception e) { // intentionally ignore errors. } @@ -136,10 +142,14 @@ public void scrapeOne(String url) { : new Date(System.currentTimeMillis() + this.banLength), false); } } + + count++; } catch (IPAddressStringException iase) { continue; } } + + BanStick.getPlugin().info("Scraped {0} proxy IPs from {1}", count, url); } catch (IOException ioe) { BanStick.getPlugin().warning("Failure during scrape of " + url, ioe); this.registerError();