byt3bl33d3r / CrackMapExec

A swiss army knife for pentesting networks
BSD 2-Clause "Simplified" License
8.45k stars 1.64k forks source link

configparser.NoSectionError: No section: 'BloodHound' #563

Closed noraj closed 2 years ago

noraj commented 2 years ago

No it's not the same as #519.

Describe the bug

Parsing the config fails.

To Reproduce

➜ cme smb 10.0.x.x -u user -H hash
...
Traceback (most recent call last):
  File "/usr/bin/cme", line 33, in <module>
    sys.exit(load_entry_point('crackmapexec==5.2.3', 'console_scripts', 'cme')())
  File "/usr/lib/python3.10/site-packages/cme/crackmapexec.py", line 254, in main
    asyncio.run(
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/usr/lib/python3.10/site-packages/cme/crackmapexec.py", line 102, in start_threadpool
    await asyncio.gather(*jobs)
  File "/usr/lib/python3.10/site-packages/cme/crackmapexec.py", line 68, in run_protocol
    await asyncio.wait_for(
  File "/usr/lib/python3.10/asyncio/tasks.py", line 408, in wait_for
    return await fut
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.10/site-packages/cme/protocols/smb.py", line 126, in __init__
    connection.__init__(self, args, db, host)
  File "/usr/lib/python3.10/site-packages/cme/connection.py", line 62, in __init__
    self.proto_flow()
  File "/usr/lib/python3.10/site-packages/cme/connection.py", line 98, in proto_flow
    if self.login() or (self.username == '' and self.password == ''):
  File "/usr/lib/python3.10/site-packages/cme/connection.py", line 259, in login
    if self.hash_login(self.domain, user, ntlm_hash.strip()): return True
  File "/usr/lib/python3.10/site-packages/cme/protocols/smb.py", line 428, in hash_login
    add_user_bh(self.username, self.domain, self.logger, self.config)
  File "/usr/lib/python3.10/site-packages/cme/helpers/bloodhound.py", line 7, in add_user_bh
    if config.get('BloodHound', 'bh_enabled') != "False":
  File "/usr/lib/python3.10/configparser.py", line 782, in get
    d = self._unify_values(section, vars)
  File "/usr/lib/python3.10/configparser.py", line 1153, in _unify_values
    raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'BloodHound'

In #519 the workaround was to disable bloodhound by setting bh_enabled = False but here I have the default config file where it's already disabled.

/usr/lib/python3.10/site-packages/cme/data/cme.conf

[CME]
workspace = default
last_used_db = smb
pwn3d_label = Pwn3d!

[BloodHound]
bh_enabled = False
bh_uri = 127.0.0.1
bh_port = 7687
bh_user = neo4j
bh_pass = neo4j

[Empire]
api_host = 127.0.0.1
api_port = 1337
username = empireadmin
password = Password123!

[Metasploit]
rpc_host = 127.0.0.1
rpc_port = 55552
password = abc123

yet the config parser says the BloodHound section doesn't exist when it's is and the config file is at the right place.

Crackmapexec info

Solution

~/.cme/cme.conf was set too but without [BloodHound] and have precedence over /usr/lib/python3.10/site-packages/cme/data/cme.conf

PS : I log this just as knowledge base.

mpgn commented 2 years ago

~/.cme/cme.conf is the one and only one :)

/usr/lib/python3.10/site-packages/cme/data/cme.conf is the default config when you install cme and you don't have a conf in ~/.cme/cme.conf the conf will be copied in to ~/.cme/cme.conf. So if you modify /usr/lib/python3.10/site-packages/cme/data/cme.conf, just delete the ~/.cme/cme.conf and relaunch cme