Metasploit mailing list archives

Meterpreter x ASCII ISO 8859-1


From: metasploit at backstep.net (Lukas Kuzmiak)
Date: Sat, 17 Jan 2009 01:27:24 +0100

glad to hear that, its  just a workaround however, it would be nice to
have it in metasploit tree by default but it requires some better
charset specification and so :)

On Fri, Jan 16, 2009 at 10:17 PM, Danilo Nascimento
<danilo.nascimento.c at gmail.com> wrote:
Works fine!

Thank you =)

[]'s Danilo Nascimento



On Fri, Jan 16, 2009 at 4:23 PM, Lukas Kuzmiak <metasploit at backstep.net> wrote:
Hi,

I've used this (email from here, few months ago), I use it for cp1250
(I'm from czech rep.) and it works perfectly..

When you explit non-English Windows, some text appear in wrong charset.
On russain Windows cmd.exe runs in cp866, meterpeter in cp1251. My
Linux box run on UTF-8.
So i needed recode cp866->UTF-8 in bindshell, and cp1251->UTF-8 in meterpeter.
To cd/download/... non-english dirs all commands must be transcoded back.
So whai is my patch. Charsets are hardcoded. Good idea is place
charsets in config, or autodetect from windows version.
svn diff

Index: lib/rex/ui/interactive.rb
===================================================================
--- lib/rex/ui/interactive.rb    (revision 5886)
+++ lib/rex/ui/interactive.rb    (working copy)
@@ -147,7 +147,7 @@
    #
    def _stream_read_remote_write_local(stream)
        data = stream.get
-
+        data=Iconv.iconv("utf-8","cp866", data).join(" ")
        user_output.print(data)
    end

@@ -156,7 +156,7 @@
    #
    def _stream_read_local_write_remote(stream)
        data = user_input.gets
-
+        data=Iconv.iconv("cp866","utf-8", data).join(" ")
        stream.put(data)
    end

Index: lib/rex/ui/text/dispatcher_shell.rb
===================================================================
--- lib/rex/ui/text/dispatcher_shell.rb    (revision 5886)
+++ lib/rex/ui/text/dispatcher_shell.rb    (working copy)
@@ -62,7 +62,7 @@
        # Wrapps shell.print
        #
        def print(msg = '')
-            shell.print(msg)
+            shell.print(Iconv.iconv("utf-8","cp1251", msg).join(" "))
        end

        #
@@ -178,6 +178,7 @@
    # Run a single command line.
    #
    def run_single(line)
+        line=Iconv.iconv("cp1251","utf-8", line).join(" ")
        arguments = parse_line(line)
        method    = arguments.shift
        found     = false
@@ -361,4 +362,4 @@

 end
 end
-end
\ No newline at end of file
+end

On Fri, Jan 16, 2009 at 6:16 PM, Danilo Nascimento
<danilo.nascimento.c at gmail.com> wrote:
For instance, i have an folder which the name is "?" (Hexadecimal E1)
http://www.calstatela.edu/faculty/jchen13/Docs/CS120/Lectures/ASCIITable_with_HTML_Entity_Names.htm

How can i access this folder from Meterpreter?


ls

Listing: c:\test
=================

Mode             Size  Type  Last modified                   Name
----             ----  ----  -------------                   ----
40777/rwxrwxrwx  0     dir   Wed Dec 31 22:00:00 -0200 1969  .
40777/rwxrwxrwx  0     dir   Wed Dec 31 22:00:00 -0200 1969  ..
40777/rwxrwxrwx  0     dir   Wed Dec 31 22:00:00 -0200 1969  ?

cd \xE1
[-] stdapi_fs_chdir: Operation failed: 2


mkdir \xe1
Creating directory: xe1



ls

Listing: c:\teste
=================

Mode             Size  Type  Last modified                   Name
----             ----  ----  -------------                   ----
40777/rwxrwxrwx  0     dir   Wed Dec 31 22:00:00 -0200 1969  .
40777/rwxrwxrwx  0     dir   Wed Dec 31 22:00:00 -0200 1969  ..
40777/rwxrwxrwx  0     dir   Wed Dec 31 22:00:00 -0200 1969  xe1
40777/rwxrwxrwx  0     dir   Wed Dec 31 22:00:00 -0200 1969  ?


Regards,
Danilo Nascimento
_______________________________________________
http://spool.metasploit.com/mailman/listinfo/framework




--
Only wimps use tape backup: _real_ men just upload their important
stuff on ftp, and let the rest of the world mirror it ;). Torvalds,
Linus (1996-07-20).





-- 
Only wimps use tape backup: _real_ men just upload their important
stuff on ftp, and let the rest of the world mirror it ;). Torvalds,
Linus (1996-07-20).



Current thread: