byt3bl33d3r / CrackMapExec

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

cmedb hosts #449

Closed s0i37 closed 3 years ago

s0i37 commented 3 years ago

Describe the bug cmedb hosts doesn't provide comportable use. It must be like a hosts for all entries. hosts CIDR for range, hosts SOMENAME for hostname matching. And also more additional keys for getting hosts without creds and etc.

To Reproduce cmedb proto smb hosts

Expected behavior I just want to see all hosts

Screenshots

cmedb (default)(smb) > hosts

Traceback (most recent call last):
  File "/usr/local/bin/cmedb", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/cme/cmedb.py", line 293, in main
    cmedbnav = CMEDBMenu(config_path)
  File "/usr/local/lib/python3.9/dist-packages/cme/cmedb.py", line 207, in __init__
    self.do_proto(self.db)
  File "/usr/local/lib/python3.9/dist-packages/cme/cmedb.py", line 233, in do_proto
    proto_menu.cmdloop()
  File "/usr/lib/python3.9/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python3.9/cmd.py", line 217, in onecmd
    return func(arg)
  File "/usr/local/lib/python3.9/dist-packages/cme/protocols/smb/db_navigator.py", line 111, in do_hosts
    self.display_hosts(hosts)
  File "/usr/local/lib/python3.9/dist-packages/cme/protocols/smb/db_navigator.py", line 56, in display_hosts
    self.print_table(data, title='Hosts')
  File "/usr/local/lib/python3.9/dist-packages/cme/cmedb.py", line 45, in print_table
    print(table.table)
  File "/usr/lib/python3/dist-packages/terminaltables/base_table.py", line 216, in table
    dimensions = max_dimensions(self.table_data, self.padding_left, self.padding_right)[:3]
  File "/usr/lib/python3/dist-packages/terminaltables/width_and_alignment.py", line 106, in max_dimensions
    inner_heights[j] = max(inner_heights[j], cell.count('\n') + 1)
TypeError: argument should be integer or bytes-like object, not 'str'

Crackmapexec info

Additional context BTW:

~ » cme --version
usage: cme [-h] [-t THREADS] [--timeout TIMEOUT] [--jitter INTERVAL] [--darrell]
           [--verbose]
           {mssql,ssh,smb,winrm,ldap} ...
cme: error: unrecognized arguments: --version
-------------------------------------------------------------------------------------
~ » cme -v
usage: cme [-h] [-t THREADS] [--timeout TIMEOUT] [--jitter INTERVAL] [--darrell]
           [--verbose]
           {mssql,ssh,smb,winrm,ldap} ...
cme: error: unrecognized arguments: -v
-------------------------------------------------------------------------------------
~ » cme -version
usage: cme [-h] [-t THREADS] [--timeout TIMEOUT] [--jitter INTERVAL] [--darrell]
           [--verbose]
           {mssql,ssh,smb,winrm,ldap} ...
cme: error: unrecognized arguments: -version
mpgn commented 3 years ago

Ok, it's a duplicate of #439

Will fix, thanks for the report ! :)

s0i37 commented 3 years ago

I have found the root cause. It is non ascii characters in PC name.

mpgn commented 3 years ago

yep :)