-
-
Save aliafshany/4fba5e7dd89ba5f4a619704f476aee02 to your computer and use it in GitHub Desktop.
Block BitTorrent via iptabls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Applying Torrent blocking rules..." | |
# Block Torrent algo string using Boyer-Moore (bm) | |
BLOCK_STRINGS_BM=( | |
"BitTorrent" | |
"BitTorrent protocol" | |
"peer_id=" | |
".torrent" | |
"announce.php?passkey=" | |
"torrent" | |
"announce" | |
"info_hash" | |
"/default.ida?" | |
".exe?/c+dir" | |
".exe?/c_tftp" | |
) | |
# Block Torrent keys using Knuth-Morris-Pratt (kmp) | |
BLOCK_STRINGS_KMP=( | |
"peer_id" | |
"BitTorrent" | |
"BitTorrent protocol" | |
"bittorrent-announce" | |
"announce.php?passkey=" | |
"find_node" | |
"info_hash" | |
"get_peers" | |
"announce" | |
"announce_peers" | |
) | |
# Apply rules for Boyer-Moore algorithm | |
for STRING in "${BLOCK_STRINGS_BM[@]}"; do | |
echo "Blocking (BM): $STRING" | |
iptables -A FORWARD -m string --algo bm --string "$STRING" -j DROP | |
done | |
# Apply rules for Knuth-Morris-Pratt algorithm | |
for STRING in "${BLOCK_STRINGS_KMP[@]}"; do | |
echo "Blocking (KMP): $STRING" | |
iptables -A FORWARD -m string --algo kmp --string "$STRING" -j DROP | |
done | |
echo "All BitTorrent blocking rules applied successfully!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment