Skip to content

Commit

Permalink
v0.2.1
Browse files Browse the repository at this point in the history
+ print from future
+ send errors message to stderr
+ updated README.md
+ updated package description and keywords
  • Loading branch information
matricali committed Jun 6, 2017
1 parent d66f5f5 commit 453f2eb
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
[![PyPI](https://img.shields.io/pypi/dm/brutekrag.svg)](https://pypi.python.org/pypi/brutekrag)

# brutekrag
SSH brute force using dictionary attack. Written in _Python_.
_brute krag_ means "brute force" in afrikáans
Penetration tests on SSH servers using brute force or dictionary attacks. Written in _Python_.

> _brute krag_ means "brute force" in afrikáans
## Disclaimer
>This tool is for ethical testing purpose only.
Expand All @@ -12,6 +13,7 @@ _brute krag_ means "brute force" in afrikáans
## Requeriments
* Python 2.7
* see [requeriments.txt](requeriments.txt)

## Installation
It can be easily installed using _pip_
Expand All @@ -33,7 +35,7 @@ usage: brutekrag [-h] [-t TARGET] [-T TARGETS] [-pF PASSWORDS] [-uF USERS]
| '_ \| '__| | | | __/ _ \ |/ / '__/ _` |/ _` |
| |_) | | | |_| | || __/ <| | | (_| | (_| |
|_.__/|_| \__,_|\__\___|_|\_\_| \__,_|\__, |
OpenSSH Brute forcer tool 0.2.0 __/ |
OpenSSH Brute force tool 0.2.1 __/ |
(c) Copyright 2014 Jorge Matricali |___/
Expand Down
21 changes: 11 additions & 10 deletions bin/brutekrag
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

from __future__ import print_function
import sys
import brutekrag
import argparse
from argparse import RawTextHelpFormatter


def print_error(message):
print '\033[91m\033[1mERROR:\033[0m %s' % message
def print_error(message, *args):
print('\033[91m\033[1mERROR:\033[0m %s' % message, *args, file=sys.stderr)


banner = ('''\033[92m _ _ _
Expand All @@ -39,7 +40,7 @@ banner = ('''\033[92m _ _ _
| '_ \| '__| | | | __/ _ \ |/ / '__/ _` |/ _` |
| |_) | | | |_| | || __/ <| | | (_| | (_| |
|_.__/|_| \__,_|\__\___|_|\_\_| \__,_|\__, |
\033[0m\033[1mOpenSSH Brute forcer tool 0.2.0\033[92m __/ |
\033[0m\033[1mOpenSSH Brute force tool 0.2.1\033[92m __/ |
\033[0m(c) Copyright 2014 Jorge Matricali\033[92m |___/\033[0m
\n''')

Expand All @@ -63,7 +64,7 @@ except TypeError:
parser.print_help()
parser.exit()

print banner
print(banner)

'''
PARSE TARGETS
Expand All @@ -76,7 +77,7 @@ elif args.targets is not None:
for target in targetsFile:
targets.append(target)
targetsFile.close()
print 'Loaded %d targets from %s' % (len(targets), args.targets)
print('Loaded %d targets from %s' % (len(targets), args.targets))
else:
print_error('You must specify al most one target.')
sys.exit(255)
Expand All @@ -92,7 +93,7 @@ elif args.users is not None:
for user in usersFile:
users.append(user)
usersFile.close()
print 'Loaded %d users from %s' % (len(users), args.users)
print('Loaded %d users from %s' % (len(users), args.users))
elif args.single is None:
print_error('You must specify al most one username.')
sys.exit(255)
Expand All @@ -108,7 +109,7 @@ elif args.passwords is not None:
for password in passwordsFile:
passwords.append(password)
passwordsFile.close()
print 'Loaded %d passwords from %s\n' % (len(passwords), args.passwords)
print('Loaded %d passwords from %s\n' % (len(passwords), args.passwords))
elif args.single is None:
print_error('You must specify a password dictionary.')
sys.exit(255)
Expand All @@ -122,7 +123,7 @@ if args.single is not None:
for line in dictionaryFile:
dictionary.append(line)
dictionaryFile.close()
print 'Loaded %d passwords from %s\n' % (len(dictionary), args.single)
print('Loaded %d passwords from %s\n' % (len(dictionary), args.single))

for line in dictionary:
username, password = line.split(args.separator)
Expand All @@ -135,7 +136,7 @@ if args.single is not None:
print_error(str(ex))
else:
# Separated 1n1 username passwords
print ''
print('')
for username in users:
for password in passwords:
password = password.strip('$BLANKPASS')
Expand All @@ -146,4 +147,4 @@ else:
except Exception as ex:
print_error(str(ex))

print 'Bye...'
print('Bye...')
19 changes: 14 additions & 5 deletions brutekrag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
from __future__ import print_function
import sys
import paramiko
from paramiko import AutoAddPolicy
Expand All @@ -35,6 +36,14 @@ def __init__(self, host, port=22, timeout=1):
self.list_passwords = []
self.timeout = timeout

def print_error(self, message, *args):
print('\033[91m%s\033[0m' % message, *args, file=sys.stderr)


def print_debug(self, message, *args):
print('\033[37m%s\033[0m' % message, *args, file=sys.stderr)


def connect(self, username, password):
try:
client = paramiko.SSHClient()
Expand All @@ -50,22 +59,22 @@ def connect(self, username, password):
)

except paramiko.AuthenticationException:
print '[%s:%d] Password %s for user %s failed' % (self.host, self.port, password, username)
self.print_debug('[%s:%d] Password %s for user %s failed' % (self.host, self.port, password, username))
client.close()
return 255
except (paramiko.ssh_exception.BadHostKeyException) as error:
print '[%s:%d] BadHostKeyException: %s' % (self.host, self.port, error.message)
self.print_error('[%s:%d] BadHostKeyException: %s' % (self.host, self.port, error.message))
return 255
except (paramiko.ssh_exception.SSHException, socket.error) as se:
print '[%s:%d] Connection error: %s' % (self.host, self.port, se.message)
self.print_error('[%s:%d] Connection error: %s' % (self.host, self.port, str(se)))
return 255

except paramiko.ssh_exception.SSHException as error:
print '[%s:%d] An error occured: %s' % (self.host, self.port, error.message)
self.print_error('[%s:%d] An error occured: %s' % (self.host, self.port, error.message))
return 255

finally:
client.close()

print '[%s:%d] The password for user \033[1m%s\033[0m is \033[1m%s\033[0m' % (self.host, self.port, username, password)
print('\033[37m[%s:%d]\033[0m The password for user \033[1m%s\033[0m is \033[37m\033[1m%s\033[0m' % (self.host, self.port, username, password))
return 0
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
setup(
name='brutekrag',
packages=['brutekrag'],
version='0.2.0',
description='brute force OpenSSH using dictionary attack',
version='0.2.1',
description='Penetration tests on SSH servers using brute force or dictionary attacks',
author='Jorge Matricali',
author_email='[email protected]',
license='MIT',
url='https://github.com/jorge-matricali/brutekrag',
download_url='https://github.com/jorge-matricali/brutekrag/archive/v0.2.0.tar.gz',
download_url='https://github.com/jorge-matricali/brutekrag/archive/v0.2.1.tar.gz',
scripts=['bin/brutekrag'],
keywords=['ssh', 'brute force', 'ethical hacking', 'pentesting'],
keywords=['ssh', 'brute force', 'ethical hacking', 'pentesting', 'dictionary attack', 'penetration test'],
classifiers=(
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
Expand Down

0 comments on commit 453f2eb

Please sign in to comment.