Sponsored Content
Top Forums Shell Programming and Scripting Automating BitTorrent traffic detection via bash Post 303018570 by Chubler_XL on Sunday 10th of June 2018 04:55:16 PM
Old 06-10-2018
I'm not really familiar with tshark or wondershaper so I've commented them and replaced with a testing string that you can edit/test to get the functionality of your bash script proven.

Have a play around with this (you should be able to run it directly from a bash login):

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')
TSOUTPUT="some random output

Result: 10 packets captured
done"

# Get the output of running the tshark command
if [[ $TSOUTPUT =~ " 0 packets captured" ]]
then
        # No BitTorrent detected - reset any previously throttled speeds back to full speed
        #wondershaper clear eth0
    echo "None Found - unshape"
else
        # BitTorrent detected - slow down upload/download speed to 0.5 Mbps
        # wondershaper eth0 512 512
    echo "Found traffic - shape connection now"
fi

 

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
Match-all classifier in tc(8)                                          Linux                                         Match-all classifier in tc(8)

NAME
matchall - traffic control filter that matches every packet SYNOPSIS
tc filter ... matchall [ skip_sw | skip_hw ] [ action ACTION_SPEC ] [ classid CLASSID ] DESCRIPTION
The matchall filter allows to classify every packet that flows on the port and run a action on it. OPTIONS
action ACTION_SPEC Apply an action from the generic actions framework on matching packets. classid CLASSID Push matching packets into the class identified by CLASSID. skip_sw Do not process filter by software. If hardware has no offload support for this filter, or TC offload is not enabled for the inter- face, operation will fail. skip_hw Do not process filter by hardware. EXAMPLES
To create ingress mirroring from port eth1 to port eth2: tc qdisc add dev eth1 handle ffff: ingress tc filter add dev eth1 parent ffff: matchall skip_sw action mirred egress mirror dev eth2 The first command creats an ingress qdisc with handle ffff: on device eth1 where the second command attaches a matchall filters on it that mirrors the packets to device eth2. To create egress mirroring from port eth1 to port eth2: tc qdisc add dev eth1 handle 1: root prio tc filter add dev eth1 parent 1: matchall skip_sw action mirred egress mirror dev eth2 The first command creats an egress qdisc with handle 1: that replaces the root qdisc on device eth1 where the second command attaches a matchall filters on it that mirrors the packets to device eth2. To sample one of every 100 packets flowing into interface eth0 to psample group 12: tc qdisc add dev eth0 handle ffff: ingress tc filter add dev eth0 parent ffff: matchall action sample rate 100 group 12 SEE ALSO
tc(8), iproute2 21 Oct 2015 Match-all classifier in tc(8)
All times are GMT -4. The time now is 11:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy