Sponsored Content
Top Forums Shell Programming and Scripting Automating BitTorrent traffic detection via bash Post 303018538 by ShrewNet on Saturday 9th of June 2018 04:04:55 PM
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.
 

7 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

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. 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

6. 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

7. 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
IDL2WRS(1)						  The Wireshark Network Analyzer						IDL2WRS(1)

NAME
idl2wrs - CORBA IDL to Wireshark Plugin Generator SYNOPSIS
idl2wrs filename DESCRIPTION
idl2wrs is a program that takes a user specified CORBA IDL file and generates "C" source code for a Wireshark "plugin". This resulting file can be compiled as a Wireshark plugin, and used to monitor GIOP/IIOP traffic that is using this IDL. idl2wrs is actually a shell script wrapper for two Python programs. These programs are: wireshark_be.py - Contains the main IDL Visitor Class wireshark_gen.py - Contains the Source Code Generator Class idl2wrs supports heuristic dissection of GIOP/IIOP traffic, and some experimental code for explicit dissection, based on Object Key <-> Repository Id mapping. However, code for heuristic based plugins is generated by default, and users should consider this the preferred method unless you have some namespace collisions. OPTIONS
Currently there are no options. idl2wrs can be invoked as follows. 1. To write the C code to stdout. idl2wrs <your_file.idl> eg: idl2wrs echo.idl 2. To write to a file, just redirect the output. idl2wrs echo.idl > packet-test.c ENVIRONMENT
idl2wrs will look for wireshark_be.py and wireshark_gen.py in $PYTHONPATH/site-packages/ and if not found, will try the current directory ./ The -p option passed to omniidl (inside idl2wrs) indicates where wireshark_be.py and wireshark_gen.py will be searched. This may need tweaking if you place these files somewhere else. If it complains about being unable to find some modules (eg tempfile.py), you may want to check if PYTHONPATH is set correctly. eg: PYTHONPATH=/usr/lib/python1.5/ SEE ALSO
wireshark(1), tshark(1) NOTES
idl2wrs (including wireshark_be.py and wireshark_gen.py) are part of the Wireshark distribution. The latest version of Wireshark can be found at <http://www.wireshark.org>. idl2wrs uses omniidl, an IDL parser, and can be found at <http://omniorb.sourceforge.net/> TODO
Some of the more important things to do are: o Improve Explicit dissection code. o Improve command line options. o Improve decode algorithm when we have operation name collision. AUTHORS
Original Author -------- ------ Frank Singleton <frank.singleton[AT]ericsson.com> Contributors ------------ 1.8.2 2012-06-05 IDL2WRS(1)
All times are GMT -4. The time now is 08:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy