qBitTorrent ban xunlei

Xunlei never upload even one byte to BitTorrent public network. Let's fuck it.

This script allow you to ban other peers basing on its client name. And you can customize your own regex to ban more clients.

bash script

PLEASE download latest version from github: https://github.com/recolic/daily-scripts/blob/one/mybin/ban-xunlei-d.sh

Just save this script on your machine, enable qBitTorrent WebUI, and run it with bash!

#!/bin/bash

# Configure your qBitTorrent API endpoint. 
#   Enable it in Tools->Web UI->Web User Interface. By default, it's 127.0.0.1:8080. 
#   Usually, you want to enable 'bypass authentication for clients on localhost'. If you still want to set a 
#     password, just add `-u username:password` option to the curl command. 
api_endpoint="http://127.0.0.1:8080/api/v2"
# You can customize the blacklist keywords. 
blacklists=(
    "Xunlei"
    "XL00"
    "^7\."
)

##############################################################

function curl_wrapped () {
    curl -s "$@" || echo "Warning: CURL $@ failed with error code $?" 1>&2
}

echo "Checking all peers every 5 seconds..."
while true; do
    tasks=`curl_wrapped "$api_endpoint/sync/maindata?rid=0" | grep -oE '"[0-9a-f]{40}"' | tr -d '"' | sort | uniq`
    echo "$tasks" | while read -r line; do
        peers=`curl_wrapped "$api_endpoint/sync/torrentPeers?hash=$line&rid=0" | grep -o '"[^"]*":{"client":"[^"]*"'`
        echo "$peers" | while read -r peer; do
            ua=`echo "$peer" | sed 's/^.*"client":"//g' | sed 's/"$//g'`
            addr=`echo "$peer" | sed 's/":{"client.*$//g' | tr -d '"'`
            # echo "Checking $ua $addr"
            hit=0
            for pattern in "${blacklists[@]}"; do
                echo "$ua" | grep "$pattern" > /dev/null && hit=1
            done
            [[ $hit = 1 ]] && echo "[$(date)] Banning $addr because of his client '$ua'" || continue
            # Ban a peer
            # For qBitTorrent 4.5.x. Should be working for all versions
            curl_wrapped --data "peers=$addr" "$api_endpoint/transfer/banPeers"
            # For qBitTorrent 4.4.x
            # curl_wrapped "$api_endpoint/transfer/banPeers?peers=$addr"
        done
    done

    sleep 5
done

You can easily catch so many fucking shitheads in 2 hours

Banning 1.207.115.34 because of his client '-XL0012-_̛_Ζ___'
Banning 110.52.194.182 because of his client '-XL0012-u0014_-_EۗD_'
Banning 171.113.2.6 because of his client '7.10.31.338'
Banning 110.52.194.182 because of his client '-XL0012-u0014_-_EۗD_'
Banning 171.113.2.6 because of his client 'Xunlei 0.1.0'
Banning 110.52.194.182 because of his client '-XL0012-u0014_-_EۗD_'
Banning 171.113.2.6 because of his client '7.10.31.338'
Banning 110.52.194.182 because of his client '-XL0012-u0014_-_EۗD_'
Banning 171.113.2.6 because of his client '7.10.31.338'
Banning 110.52.194.182 because of his client 'Xunlei 0.0.1.2'
Banning 171.113.2.6 because of his client '7.10.31.338'
Banning 110.52.194.182 because of his client '-XL0012-u0014_-_EۗD_'
Banning 171.113.2.6 because of his client '7.10.31.338'
Banning 110.52.194.182 because of his client '-XL0012-u0014_-_EۗD_'
Banning 171.113.2.6 because of his client 'Xunlei 0.1.0'
Banning 110.52.194.182 because of his client '-XL0012-u0014_-_EۗD_'
Banning 171.113.2.6 because of his client '7.10.31.338'
Banning 110.52.194.182 because of his client '-XL0012-u0014_-_EۗD_'
Banning 171.113.2.6 because of his client '7.10.31.338'
Banning 110.52.194.182 because of his client 'Xunlei 0.0.1.2'
Banning 171.113.2.6 because of his client '7.10.31.338'
Banning 110.52.194.182 because of his client '-XL0012-u0014_-_EۗD_'
Banning 171.113.2.6 because of his client '7.10.31.338'
Banning 110.52.194.182 because of his client '-XL0012-u0014_-_EۗD_'
Banning 171.113.2.6 because of his client '7.10.31.338'
Banning 110.52.194.182 because of his client '-XL0012-u0014_-_EۗD_'
Banning 171.113.2.6 because of his client '7.10.31.338'
Banning 110.52.194.182 because of his client 'Xunlei 0.0.1.2'
Banning 171.113.2.6 because of his client '7.10.31.338'
Banning 110.52.194.182 because of his client '-XL0012-u0014_-_EۗD_'
Banning 171.113.2.6 because of his client '7.10.31.338'

If you want to ban it temporarily instead of permanently, use curl_wrapped "$api_endpoint/app/setPreferences" --data "json={"banned_IPs":"$ipn"}"

Python script

@EchterAlsFake converted the bash script into a Python script and also compiled it to binary for Windows and Linux. You can find EchterAlsFake's project here: https://github.com/EchterAlsFake/qbittorrent_peer_ban