Skip to content

Commit 18dbb2a

Browse files
committed
fixes
1 parent 46b0517 commit 18dbb2a

File tree

5 files changed

+24
-142
lines changed

5 files changed

+24
-142
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ Usage: habu.crack.snmp [OPTIONS] IP
436436
437437
Options:
438438
-p INTEGER Port to use
439+
-c TEXT Community (default: list of most used)
439440
-s Stop after first match
440441
-v Verbose
441442
--help Show this message and exit.

README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ habu.crack.snmp
436436
437437
Options:
438438
-p INTEGER Port to use
439+
-c TEXT Community (default: list of most used)
439440
-s Stop after first match
440441
-v Verbose
441442
--help Show this message and exit.

habu/cli/cmd_crack_snmp.py

+21-14
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
@click.command()
1616
@click.argument('ip')
1717
@click.option('-p', 'port', default=161, help='Port to use')
18+
@click.option('-c', 'community', default=None, help='Community (default: list of most used)')
1819
@click.option('-s', 'stop', is_flag=True, default=False, help='Stop after first match')
1920
@click.option('-v', 'verbose', is_flag=True, default=False, help='Verbose')
20-
def cmd_crack_snmp(ip, port, stop, verbose):
21+
def cmd_crack_snmp(ip, community, port, stop, verbose):
2122
"""Launches snmp-get queries against an IP, and tells you when
2223
finds a valid community string (is a simple SNMP cracker).
2324
@@ -40,26 +41,32 @@ def cmd_crack_snmp(ip, port, stop, verbose):
4041
DATADIR = os.path.abspath(os.path.join(FILEDIR, '../data'))
4142
COMMFILE = Path(os.path.abspath(os.path.join(DATADIR, 'dict_snmp.txt')))
4243

43-
with COMMFILE.open() as cf:
44-
communities = cf.read().split('\n')
44+
if community:
45+
communities = [community]
46+
else:
47+
with COMMFILE.open() as cf:
48+
communities = cf.read().split('\n')
4549

4650
conf.verb = False
4751

48-
pkt = IP(dst=ip)/UDP(sport=port, dport=port)/SNMP(community="public", PDU=SNMPget(varbindlist=[SNMPvarbind(oid=ASN1_OID("1.3.6.1"))]))
49-
50-
for community in communities:
52+
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"))])):
5153

5254
if verbose:
53-
print('.', end='')
54-
sys.stdout.flush()
55+
print(pkt[IP].dst)
56+
57+
for community in communities:
58+
59+
if verbose:
60+
print('.', end='')
61+
sys.stdout.flush()
5562

56-
pkt[SNMP].community=community
57-
ans = sr1(pkt, timeout=0.5, verbose=0)
63+
pkt[SNMP].community=community
64+
ans = sr1(pkt, timeout=0.5, verbose=0)
5865

59-
if ans and UDP in ans:
60-
print('\nCommunity found:', community)
61-
if stop:
62-
break
66+
if ans and UDP in ans:
67+
print('\n{} - Community found: {}'.format(pkt[IP].dst, community))
68+
if stop:
69+
break
6370

6471
return True
6572

habu/lib/ScanNetworkForSMB.py

-127
This file was deleted.

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='habu',
8-
version='0.0.97',
8+
version='0.0.98',
99
description='Python Network Hacking Toolkit',
1010
long_description=readme,
1111
long_description_content_type='text/x-rst',

0 commit comments

Comments
 (0)