Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fportantier committed Jan 19, 2019
1 parent 46b0517 commit 18dbb2a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 142 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ Usage: habu.crack.snmp [OPTIONS] IP
Options:
-p INTEGER Port to use
-c TEXT Community (default: list of most used)
-s Stop after first match
-v Verbose
--help Show this message and exit.
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ habu.crack.snmp
Options:
-p INTEGER Port to use
-c TEXT Community (default: list of most used)
-s Stop after first match
-v Verbose
--help Show this message and exit.
Expand Down
35 changes: 21 additions & 14 deletions habu/cli/cmd_crack_snmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
@click.command()
@click.argument('ip')
@click.option('-p', 'port', default=161, help='Port to use')
@click.option('-c', 'community', default=None, help='Community (default: list of most used)')
@click.option('-s', 'stop', is_flag=True, default=False, help='Stop after first match')
@click.option('-v', 'verbose', is_flag=True, default=False, help='Verbose')
def cmd_crack_snmp(ip, port, stop, verbose):
def cmd_crack_snmp(ip, community, port, stop, verbose):
"""Launches snmp-get queries against an IP, and tells you when
finds a valid community string (is a simple SNMP cracker).
Expand All @@ -40,26 +41,32 @@ def cmd_crack_snmp(ip, port, stop, verbose):
DATADIR = os.path.abspath(os.path.join(FILEDIR, '../data'))
COMMFILE = Path(os.path.abspath(os.path.join(DATADIR, 'dict_snmp.txt')))

with COMMFILE.open() as cf:
communities = cf.read().split('\n')
if community:
communities = [community]
else:
with COMMFILE.open() as cf:
communities = cf.read().split('\n')

conf.verb = False

pkt = IP(dst=ip)/UDP(sport=port, dport=port)/SNMP(community="public", PDU=SNMPget(varbindlist=[SNMPvarbind(oid=ASN1_OID("1.3.6.1"))]))

for community in communities:
for pkt in IP(dst=ip)/UDP(sport=port, dport=port)/SNMP(community="public", PDU=SNMPget(varbindlist=[SNMPvarbind(oid=ASN1_OID("1.3.6.1"))])):

if verbose:
print('.', end='')
sys.stdout.flush()
print(pkt[IP].dst)

for community in communities:

if verbose:
print('.', end='')
sys.stdout.flush()

pkt[SNMP].community=community
ans = sr1(pkt, timeout=0.5, verbose=0)
pkt[SNMP].community=community
ans = sr1(pkt, timeout=0.5, verbose=0)

if ans and UDP in ans:
print('\nCommunity found:', community)
if stop:
break
if ans and UDP in ans:
print('\n{} - Community found: {}'.format(pkt[IP].dst, community))
if stop:
break

return True

Expand Down
127 changes: 0 additions & 127 deletions habu/lib/ScanNetworkForSMB.py

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='habu',
version='0.0.97',
version='0.0.98',
description='Python Network Hacking Toolkit',
long_description=readme,
long_description_content_type='text/x-rst',
Expand Down

0 comments on commit 18dbb2a

Please sign in to comment.