Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbrute committed Mar 27, 2019
0 parents commit c38d609
Show file tree
Hide file tree
Showing 25 changed files with 1,357 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Python byte translated files
__pycache__/
*.py[cod]

# Python specific
venv/
dist/
build/
eggs/
*.egg-info

# VisualStudio Code
.vscode/
*.code-workspace
Empty file added CHANGELOG
Empty file.
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 bitbrute

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<p align="center"><img src="https://i.imgur.com/8M1LJMx.jpg" /></p>

# Evil Limiter

[![License Badge](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Compatibility](https://img.shields.io/badge/python-3-brightgreen.svg)](PROJECT)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity)
[![HitCount](http://hits.dwyl.io/bitbrute/evillimiter.svg)](http://hits.dwyl.io/bitbrute/evillimiter)
[![Open Source Love](https://badges.frapsoft.com/os/v3/open-source.svg?v=102)](https://github.com/ellerbrock/open-source-badge/)

A tool to limit the bandwidth (upload/download) of devices connected to your network without physical or administrative access.<br>
```evillimiter``` employs [ARP spoofing](https://en.wikipedia.org/wiki/ARP_spoofing) and [traffic shaping](https://en.wikipedia.org/wiki/Traffic_shaping) to throttle the bandwidth of hosts on the network. This is explained in detail below.

## Requirements
- Linux distribution
- Python 3 or greater

Possibly missing python packages will be installed during the installation process.

## Installation

```bash
git clone https://github.com/bitbrute/evillimiter.git
cd evillimiter
sudo python3 setup.py install
```

Alternatively, you can download a desired version from the [Release page](https://github.com/bitbrute/evillimiter/releases).<br>

## Usage

Type ```evillimiter``` or ```python3 bin/evillimiter``` to run the tool.

```evillimiter``` will try to resolve required information (network interface, netmask, gateway address, ...) on its own, automatically.

#### Command-Line Arguments

| Argument | Explanation |
| -------- | ----------- |
| ```-h``` | Displays help message listing all command-line arguments |
| ```-i [Interface Name]``` | Specifies network interface (resolved if not specified)|
| ```-g [Gateway Address]``` | Specifies gateway IP address (resolved if not specified)|
| ```-n [Netmask Address]``` | Specifies netmask (resolved if not specified)|
| ```-f``` | Flushes current iptables and tc configuration. Ensures that packets are dealt with correctly.|
| ```--colorless``` | Disables colored output |

#### ```evillimiter``` Commands

| Command | Explanation |
| ------- | ----------- |
| ```scan``` | Scans your network for online hosts. One of the first things to do after start.
| ```hosts``` | Displays all the hosts/devices previously scanned and basic information. Shows ID for each host that is required for interaction.
| ```limit [ID] [Rate]``` | Limits bandwidth of host associated to specified ID. Rate determines the internet speed.<br>Valid rates: ```bit```, ```kbit```, ```mbit```, ```gbit```, ```tbit```<br>For example: ```limit 4 200kbit``` or ```limit 2 1gbit```
| ```block [ID]``` | Blocks internet connection of host associated to specified ID.
| ```free [ID]``` | Unlimits/Unblocks host associated to specified ID. Removes all further restrictions.
| ```clear``` | Clears the terminal window.
| ```?```, ```help``` | Displays command information similar to this one.

## Restrictions

- **Limits IPv4 connctions only**, since [ARP spoofing](https://en.wikipedia.org/wiki/ARP_spoofing) requires the ARP packet that is only present on IPv4 networks.

## Disclaimer
[Evil Limiter](https://github.com/bitbrute/evillimiter) is provided by [bitbrute](https://github.com/bitbrute) "as is" and "with all faults". The provider makes no representations or warranties of any kind concerning the safety, suitability, lack of viruses, inaccuracies, typographical errors, or other harmful components of this software. There are inherent dangers in the use of any software, and you are solely responsible for determining whether Evil Limiter is compatible with your equipment and other software installed on your equipment. You are also solely responsible for the protection of your equipment and backup of your data, and the provider will not be liable for any damages you may suffer in connection with using, modifying, or distributing this software.

## License

Copyright (c) 2019 by [bitbrute](https://github.com/bitbrute). Some rights reserved.<br>
[Evil Limiter](https://github.com/bitbrute/evillimiter) is licensed under the MIT License as stated in the [LICENSE file](LICENSE).
15 changes: 15 additions & 0 deletions bin/evillimiter
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import sys


if __name__ == '__main__':
dir_of_executable = os.path.dirname(__file__)
path_to_project_root = os.path.abspath(os.path.join(dir_of_executable, '..'))
sys.path.insert(0, path_to_project_root)
os.chdir(path_to_project_root)

from evillimiter.evillimiter import run # pylint: disable=no-name-in-module
sys.exit(run())
2 changes: 2 additions & 0 deletions evillimiter/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__version__ = '1.0.0'
__description__ = 'Limits bandwidth of devices on the same network'
Empty file added evillimiter/common/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions evillimiter/common/globals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os


DEVNULL = open(os.devnull, 'w')
BROADCAST = 'ff:ff:ff:ff:ff:ff'

BIN_TC = '/sbin/tc'
BIN_IPTABLES = '/sbin/iptables'
BIN_SYSCTL = '/sbin/sysctl'

IP_FORWARD_LOC = 'net.ipv4.ip_forward'
Empty file added evillimiter/console/__init__.py
Empty file.
18 changes: 18 additions & 0 deletions evillimiter/console/banner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from .io import IO


_MAIN_BANNER = rf"""{IO.Fore.LIGHTRED_EX}
███████╗██╗ ██╗██╗██╗ ██╗ ██╗███╗ ███╗██╗████████╗███████╗██████╗
██╔════╝██║ ██║██║██║ ██║ ██║████╗ ████║██║╚══██╔══╝██╔════╝██╔══██╗
█████╗ ██║ ██║██║██║ ██║ ██║██╔████╔██║██║ ██║ █████╗ ██████╔╝
██╔══╝ ╚██╗ ██╔╝██║██║ ██║ ██║██║╚██╔╝██║██║ ██║ ██╔══╝ ██╔══██╗
███████╗ ╚████╔╝ ██║███████╗ ███████╗██║██║ ╚═╝ ██║██║ ██║ ███████╗██║ ██║
╚══════╝ ╚═══╝ ╚═╝╚══════╝ ╚══════╝╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
{IO.Style.RESET_ALL + IO.Style.BRIGHT}by bitbrute ~ limit devices on your network :3
v[_V_]
"""


def get_main_banner(version):
return _MAIN_BANNER.replace('[_V_]', version)
81 changes: 81 additions & 0 deletions evillimiter/console/io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import re
import colorama

from . import shell


class IO(object):
_ANSI_CSI_RE = re.compile('\001?\033\\[((?:\\d|;)*)([a-zA-Z])\002?')

Back = colorama.Back
Fore = colorama.Fore
Style = colorama.Style

colorless = False

@staticmethod
def initialize(colorless=False):
"""
Initializes console input and output.
"""
IO.colorless = colorless
if not colorless:
colorama.init(autoreset=True)

@staticmethod
def print(text, end='\n', flush=False):
"""
Writes a given string to the console.
"""
if IO.colorless:
text = IO._remove_colors(text)

print(text, end=end, flush=flush)

@staticmethod
def ok(text, end='\n'):
"""
Print a success status message
"""
IO.print(f'{IO.Style.BRIGHT + IO.Fore.LIGHTGREEN_EX}OK{IO.Style.RESET_ALL} {text}', end=end)

@staticmethod
def error(text):
"""
Print an error status message
"""
IO.print(f'{IO.Style.BRIGHT + IO.Fore.LIGHTRED_EX}ERR{IO.Style.RESET_ALL} {text}')

@staticmethod
def spacer():
"""
Prints a blank line for attraction purposes
"""
IO.print('')

@staticmethod
def input(prompt):
"""
Prompts the user for input.
"""
if IO.colorless:
prompt = IO._remove_colors(prompt)

return input(prompt)

@staticmethod
def clear():
"""
Clears the terminal screen
"""
shell.execute('clear')

@staticmethod
def _remove_colors(text):
edited = text

for match in IO._ANSI_CSI_RE.finditer(text):
s, e = match.span()
edited = edited.replace(text[s:e], '')

return edited
11 changes: 11 additions & 0 deletions evillimiter/console/shell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import subprocess

from evillimiter.common.globals import DEVNULL


def execute(command, root=True):
return subprocess.call('sudo ' + command if root else command, shell=True)


def execute_suppressed(command, root=True):
return subprocess.call('sudo ' + command if root else command, shell=True, stdout=DEVNULL, stderr=DEVNULL)
Loading

0 comments on commit c38d609

Please sign in to comment.