rapid7 / metasploit-framework

Metasploit Framework
https://www.metasploit.com/
Other
34.29k stars 14.01k forks source link

support utf-8 conversion in ADSI meterpreter code #5232

Open Meatballs1 opened 9 years ago

Meatballs1 commented 9 years ago

Using enum_ad_computers I get the following error. Looks like it dislikes the Windows Server(R) in a comment?

msf post(enum_ad_computers) > run -j
[*] Post module running as background job
[*] Resolving IP addresses...
[-] Post failed: ActiveRecord::StatementInvalid PG::CharacterNotInRepertoire: ERROR:  invalid byte sequence for encoding "UTF8": 0xae
: INSERT INTO "hosts" ("address", "arch", "comm", "comments", "created_at", "cred_count", "exploit_attempt_count", "host_detail_count", "info", "mac", "name", "note_count", "os_flavor", "os_lang", "os_name", "os_sp", "purpose", "scope", "service_count", "state", "updated_at", "virtual_host", "vuln_count", "workspace_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24) RETURNING "id"
[-] Call stack:
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1176:in `get_last_result'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1176:in `exec_cache'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:661:in `block in exec_query'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
[-]   /var/lib/gems/1.9.1/gems/activesupport-3.2.14/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:659:in `exec_query'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/database_statements.rb:63:in `exec_insert'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/relation.rb:66:in `insert'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/persistence.rb:367:in `create'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/timestamp.rb:58:in `create'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/callbacks.rb:268:in `block in create'
[-]   /var/lib/gems/1.9.1/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:403:in `_run__4264701056075533851__create__172958994904926905__callbacks'
[-]   /var/lib/gems/1.9.1/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:405:in `__run_callback'
[-]   /var/lib/gems/1.9.1/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
[-]   /var/lib/gems/1.9.1/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:81:in `run_callbacks'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/callbacks.rb:268:in `create'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/persistence.rb:348:in `create_or_update'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/callbacks.rb:264:in `block in create_or_update'
[-]   /var/lib/gems/1.9.1/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:425:in `_run__4264701056075533851__save__172958994904926905__callbacks'
[-]   /var/lib/gems/1.9.1/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:405:in `__run_callback'
[-]   /var/lib/gems/1.9.1/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
[-]   /var/lib/gems/1.9.1/gems/activesupport-3.2.14/lib/active_support/callbacks.rb:81:in `run_callbacks'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/callbacks.rb:264:in `create_or_update'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/persistence.rb:104:in `save!'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/validations.rb:56:in `save!'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/transactions.rb:264:in `block in save!'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/transactions.rb:208:in `transaction'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/transactions.rb:264:in `save!'
[-]   /opt/metasploit/msf3/lib/msf/core/db.rb:377:in `block in report_host'
[-]   /var/lib/gems/1.9.1/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
[-]   /opt/metasploit/msf3/lib/msf/core/db.rb:323:in `report_host'
[-]   /opt/metasploit/msf3/lib/msf/core/auxiliary/report.rb:58:in `report_host'
[-]   /opt/metasploit/msf3/modules/post/windows/gather/enum_ad_computers.rb:138:in `block (2 levels) in run'
[-]   /opt/metasploit/msf3/modules/post/windows/gather/enum_ad_computers.rb:134:in `each'
[-]   /opt/metasploit/msf3/modules/post/windows/gather/enum_ad_computers.rb:134:in `block in run'
[-]   /opt/metasploit/msf3/modules/post/windows/gather/enum_ad_computers.rb:133:in `each'
[-]   /opt/metasploit/msf3/modules/post/windows/gather/enum_ad_computers.rb:133:in `run'
bcook-r7 commented 9 years ago

Sounds reasonable to assume that ADSI in extapi needs to be converted to return UTF-8 strings.

Meatballs1 commented 9 years ago

and/or that db_manager should somehow ensure strings are encoded/escaped correctly?

OJ commented 9 years ago

Adsi in extapi definitely needs Unicode work done. Badly :)

Meatballs1 commented 9 years ago

TheColonial I choose you:

image

OJ commented 9 years ago

I feel special.

jlee-r7 commented 9 years ago

The best that dbmanager can hope to do is mangle the bytes so things don't explode. It will never be able to guess the correct encoding because character encoding is fucking stupid. ><

bcook-r7 commented 9 years ago

I would be happy to take this on time permitting.

bcoles commented 4 years ago

5 years later. Has this been fixed? I think this has been fixed, but I can't be bothered setting up a domain to test.