Automating BitTorrent traffic detection via bash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automating BitTorrent traffic detection via bash
Prev   Next
# 1  
Old 06-09-2018
Hammer & Screwdriver Automating BitTorrent traffic detection via bash

Hi all,

Earlier today, I read an article on how to detect BitTorrent traffic using tshark (the cli version of Wireshark).

I wanted to have a go at creating a simple script, that when BitTorrent packets are detected the network connection will be throttled. The thing is that I am not great at bash scripting and would like some assistance with my script (see below).
Code:
#!/bin/bash
# Sample network stream for 10 seconds and filter for uTP and/or BitTorrent traffic that does not originate on port 80 (HTTP), 443 (HTTPS), 22 (SSH)
TSOUTPUT=$(sudo tshark -a "duration:10" -Y 'udp[8:5] == "\x64\x32\x3A\x69\x70" or bittorrent' -f 'not port 80 and not port 22 and not port 443')

# Get the output of running the tshark command
if [[ $TSOUTPUT != "0 packets captured" ]] then
	# BitTorrent detected - slow down upload/download speed to 0.5 Mbps
	wondershaper eth0 512 512
else
	# Not BitTorrent detected - reset any previously throttled speeds back to full speed
	wondershaper clear eth0
fi

The bash script should be designed to run in cron every minute or two.

I really would appreciate any help with this.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with automating a bash script

Hi Guys, There are some emails going deferred as we got some new IP's from our ISP. So I was trying to manually copy the deferred mail and forward it to our sales team so that they can contact our client. I am new to this script thing, but luckily I was able to write the code to extract the data... (1 Reply)
Discussion started by: linuxrulz
1 Replies

2. Programming

Parallel Processing Detection and Program Return Value Detection

Hey, for the purpose of a research project I need to know if a specific type of parallel processing is being utilized by any user-run programs. Is there a way to detect whether a program either returns a value to another program at the end of execution, or just utilizes any form of parallel... (4 Replies)
Discussion started by: azar.zorn
4 Replies

3. Shell Programming and Scripting

need bash script Intrusion Detection on Linux

Hello all I have a script but I failed on the creation of Script is any is carried out in the shell sends the owner of the server, the message is has been implemented For example, functioned as a detection system intruders but in smaller Is it possible to help if you allow I want the... (4 Replies)
Discussion started by: x-zer0
4 Replies

4. Programming

Bittorrent program

Hi everyone, I'm trying to replicate a bittorrent program using Linux client/server programming. I have a few questions on how to approach this.. 1) If I write a client/server program, can it be merged together? Usually bittorrent programs can send/receive files 2) Doing it step by step, I... (1 Reply)
Discussion started by: Shiroi98
1 Replies

5. IP Networking

Unknown open port: "6881/tcp open bittorrent-tracker" found with nmap

Hi. I ran nmap on my server, and I get the following: Starting Nmap 4.76 ( http://nmap.org ) at 2009-03-19 16:33 EDT Interesting ports on -------- (-----): Not shown: 997 closed ports PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 6881/tcp open bittorrent-tracker The... (0 Replies)
Discussion started by: Rledley
0 Replies

6. UNIX for Dummies Questions & Answers

Bittorrent over SSH

Hi, I'm behind a university firewall where nearly all ports are blocked. Therefore I've set up a ssh tunnel to my comp at home so that I can bypass the uni firewall and use bittorrent. I used mainly these 3 guides to setup the tunnel: http://freebsdcluster.org/~lasse/sshazureustunnel/ , Whalesalad... (1 Reply)
Discussion started by: bizso
1 Replies

7. IP Networking

modem detection

How to get information that where is my modem configured in /dev. I have two modems configured in my device .. one is USB and other is PCI modem.. USB is detected as /dev/USB0. but how to see about PCI modem? (0 Replies)
Discussion started by: s123.radha
0 Replies
Login or Register to Ask a Question
transmission-remote-cli(1)				      transmission-remote-cli					transmission-remote-cli(1)

NAME
transmission-remote-cli - a console client for the Transmission BitTorrent client SYNOPSIS
transmission-remote-cli [options] [filename-or-URL] DESCRIPTION
transmission-remote-cli is a curses interface for the daemon of the BitTorrent client Transmission. OPTIONS
--version Show version number and exit -h --help Show usage information and a list of options -c CONNECTION --connect=CONNECTION Point to the server. CONNECTION must match the following pattern: [username:password@]host[:port][path] Default: localhost:9091 -s --ssl Use SSL to connect to the server. Default: don't use SSL --create-config Create configuration file with default values. NOTE: A config file won't be created unless you provide this option at least once. After that, it is rewritten whenever transmis- sion-remote-cli exits. -f CONFIGFILE --config=CONFIGFILE Set path to configuration file. Default: ~/.config/transmission-remote-cli/settings.cfg -n --netrc Get authentication info from ~/.netrc. -- OPTIONS Use the known server connection to pass OPTIONS on to transmission-remote. FILES
transmission-remote-cli overwrites the configuration file on exit. Keep that in mind if you edit it manually. SEE ALSO
transmission-create(1), transmission-daemon(1), transmission-edit(1), transmission-gtk(1), transmission-qt(1), transmission-remote(1), transmission-show(1). April 22, 2012 transmission-remote-cli(1)