Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Martinez Portantier committed Aug 18, 2017
0 parents commit 649933e
Show file tree
Hide file tree
Showing 52 changed files with 59,751 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject
10 changes: 10 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test:
script:
- apt-get update -qy
- apt-get install -y python3-dev python3-pip
- pip3 install virtualenv
- virtualenv --python=/usr/bin/python3 venv
- venv/bin/pip install -r requirements.txt
- venv/bin/pip install -r dev-requirements.txt
- venv/bin/pip install -e .
- venv/bin/python setup.py pytest
Empty file added LICENSE
Empty file.
25 changes: 25 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Habu: Ethical Hacking utilities / library
=========================================

These are basic functions that help with some tasks for Ethical Hacking and Penetration Testing.

I'm developing Habu to teach (and learn) some concepts about Python and Hacking.

Much of the functions are really basic (like get our public IP address), but are really useful in some cases.

Installation
------------

To install Habu, simply:

.. code-block:: bash
$ pip install habu
Dependencies
------------
Habu requires:

- Python (3.x),
- Requests (2.x),
- Click (6.x).
4 changes: 4 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
flake8
pytest
pytest-runner
pyroma
Empty file added habu/__init__.py
Empty file.
Empty file added habu/cli/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions habu/cli/cmd_arpoison.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import click
from habu.lib.arpoison import arpoison


@click.command()
@click.argument('target1')
@click.argument('target2')
def cmd_arpoison(target1, target2):
"""ARP cache poison"""
arpoison(target1, target2)

if __name__ == '__main__':
cmd_arpoison()
40 changes: 40 additions & 0 deletions habu/cli/cmd_arpsniff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from time import time
import click
import habu.lib.manuf
from scapy.all import ARP, IP, TCP, sniff

hosts = {}

mac2vendor = habu.lib.manuf.MacParser()

def procpkt(pkt):

now = time()
output = '{seconds}\t{ip}\t{hwaddr}\t{vendor}'

if 'ARP' in pkt:
hosts[pkt[ARP].psrc] = {}
hosts[pkt[ARP].psrc]['hwaddr'] = pkt[ARP].hwsrc
hosts[pkt[ARP].psrc]['vendor'] = mac2vendor.get_comment(pkt[ARP].hwsrc)
hosts[pkt[ARP].psrc]['time'] = time()

click.clear()

for ip in sorted(hosts):
print(output.format(
seconds = int(now - hosts[ip]['time']),
ip = ip,
hwaddr = hosts[ip]['hwaddr'],
vendor = hosts[ip]['vendor']
))


@click.command()
def cmd_arpsniff():
""" ARP Sniffer """
sniff(filter="arp", store=False, prn=procpkt)


if __name__ == '__main__':
cmd_arpsniff()

12 changes: 12 additions & 0 deletions habu/cli/cmd_contest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import click
from habu.lib import contest


@click.command()
def cmd_contest():
"""Example script."""
print("IP: %s" % contest.check_ip())
print("DNS: %s" % contest.check_dns())
print("FTP: %s" % contest.check_ftp())
print("HTTP: %s" % contest.check_http())
print("HTTPS: %s" % contest.check_https())
10 changes: 10 additions & 0 deletions habu/cli/cmd_eicar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import click
from habu.lib.eicar import eicar

@click.command()
def cmd_eicar():
"""EICAR test data"""
print(eicar())

if __name__ == '__main__':
cmd_eicar()
15 changes: 15 additions & 0 deletions habu/cli/cmd_extract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import click
from habu.lib import extract


@click.command()
@click.option('-k', default='0', help='Encryption key')
@click.option('-i', type=click.File('rb'), required=True, help='Input file')
@click.option('-o', type=click.File('wb'), required=True, help='Output file')
def cmd_extract(k, i, o):
"""XOR cipher"""
o.write(xor(i.read(), k.encode()))


if __name__ == '__main__':
cmd_xor()
13 changes: 13 additions & 0 deletions habu/cli/cmd_forkbomb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import click
from habu.lib.forkbomb import bombs, get_bomb


@click.command()
@click.argument('bomb', type=click.Choice(bombs))
def cmd_forkbomb(bomb):
"""Fork Bombs"""
print(get_bomb(bomb))


if __name__ == '__main__':
cmd_forkbomb()
20 changes: 20 additions & 0 deletions habu/cli/cmd_hasher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import click
from habu.lib.hasher import hasher


@click.command()
@click.argument('f', type=click.File('rb'))
def cmd_hasher(f):
"""Hasher"""

data = f.read()

if not data:
print("Empty file or string!")
else:
for algo, result in hasher(data).items():
print("%s: %s" %(algo, result))


if __name__ == '__main__':
cmd_hasher()
28 changes: 28 additions & 0 deletions habu/cli/cmd_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import click

help_text = [
('habu.arpoison', 'ARP cache poisoner *'),
('habu.arpsniff', 'ARP sniffer *'),
('habu.contest', 'Check internet connection capabilities'),
('habu.eicar', 'Print EICAR antimalware test data'),
('habu.forkbomb', 'Show various forkbomb examples'),
('habu.hasher', 'Calculate hashes using various algorithms'),
('habu.help', 'Print this help message'),
('habu.ip', 'Show your public IP'),
('habu.update', 'Update data files'),
('habu.xor', 'XOR cipher'),

]

@click.command()
def cmd_help():
"""Habu help"""

print('* = Need root privileges')

for c, h in help_text:
print('%-20s%-12s' % (c, h))

if __name__ == '__main__':
cmd_help()

8 changes: 8 additions & 0 deletions habu/cli/cmd_ip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import click
from habu.lib.ip import get_ip


@click.command()
def cmd_ip():
"""Example script."""
print(get_ip())
12 changes: 12 additions & 0 deletions habu/cli/cmd_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import click
import habu.lib.manuf

@click.command()
def cmd_update():
""" Data files updater """
m = habu.lib.manuf.MacParser()
m.update()

if __name__ == '__main__':
cmd_update()

15 changes: 15 additions & 0 deletions habu/cli/cmd_xor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import click
from habu.lib.xor import xor


@click.command()
@click.option('-k', default='0', help='Encryption key')
@click.option('-i', type=click.File('rb'), required=True, help='Input file')
@click.option('-o', type=click.File('wb'), required=True, help='Output file')
def cmd_xor(k, i, o):
"""XOR cipher"""
o.write(xor(i.read(), k.encode()))


if __name__ == '__main__':
cmd_xor()
10 changes: 10 additions & 0 deletions habu/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os

FILEDIR = os.path.dirname(os.path.abspath(__file__))
DATADIR = os.path.abspath(os.path.join(FILEDIR, '../data'))
workspace = '/tmp/habu-workspace'

SERVICES_FILE_TCP = os.path.abspath(os.path.join(DATADIR, 'services-tcp'))
SERVICES_FILE_UDP = os.path.abspath(os.path.join(DATADIR, 'services-udp'))


1 change: 1 addition & 0 deletions habu/data/forkbomb/bash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:(){ :|:& };:
1 change: 1 addition & 0 deletions habu/data/forkbomb/batch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
%0|%0
10 changes: 10 additions & 0 deletions habu/data/forkbomb/c.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <unistd.h>

int main()
{
while(1)
{
fork();
}
return 0;
}
4 changes: 4 additions & 0 deletions habu/data/forkbomb/haskell.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Control.Monad
import System.Posix.Process

forkBomb = forever $ forkProcess forkBomb
1 change: 1 addition & 0 deletions habu/data/forkbomb/perl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fork while fork
1 change: 1 addition & 0 deletions habu/data/forkbomb/php.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
while(pcntl_fork()|1);
4 changes: 4 additions & 0 deletions habu/data/forkbomb/python.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os

while True:
os.fork()
3 changes: 3 additions & 0 deletions habu/data/forkbomb/ruby.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def forkbomb
loop { fork { forkbomb } }
end; forkbomb
Loading

0 comments on commit 649933e

Please sign in to comment.