Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python meterpreter ls command large files are not supported. #281

Closed
uyid opened this issue Apr 23, 2018 · 5 comments
Closed

python meterpreter ls command large files are not supported. #281

uyid opened this issue Apr 23, 2018 · 5 comments

Comments

@uyid
Copy link

uyid commented Apr 23, 2018

In python meterpreter,if you dir exist a large file(>4GB?), Unable to display directories with ls.

in python:

Traceback (most recent call last):
File "/payload.py", line 1254, in create_response
    result = handler(request, resp)
File "", line 1304, in stdapi_fs_ls
File "", line 673, in get_stat_buffer
    error: integer out of range for 'I' format code

in msf console:
meterpreter > ls i:
[-] stdapi_fs_ls: Operation failed: Unknown error

because:

in ext_server_stdapi.py line 660
def get_stat_buffer(path):
    si = os.stat(path)
    rdev = 0
    if hasattr(si, 'st_rdev'):
        rdev = si.st_rdev
        blksize = 0
    if hasattr(si, 'st_blksize'):
        blksize = si.st_blksize
        blocks = 0
    if hasattr(si, 'st_blocks'):
        blocks = si.st_blocks
        st_buf = struct.pack('<IHHH', si.st_dev, max(min(0xffff, si.st_ino), 0), si.st_mode, si.st_nlink)
        st_buf += struct.pack('<HHHI', si.st_uid & 0xffff, si.st_gid & 0xffff, 0, rdev)
        st_buf += struct.pack('<IIII', si.st_size, long(si.st_atime), long(si.st_mtime), long(si.st_ctime))
        #                                     👆 max file size is 4GB ,int32 max value limit file size
        st_buf += struct.pack('<II', blksize, blocks)
@zeroSteiner
Copy link
Contributor

Does this issue not affect the other meterpreters? I thought the structure format was standard across all of them (i.e. using a 32-bit width field).

@bwatters-r7
Copy link
Contributor

bwatters-r7 commented Dec 10, 2018

Oh crap..... I forgot I assigned this to myself. @zeroSteiner I'll try to take a look today, but several months ago, the C meterpreter had this same issue. At fault was that the Windows stat object was returning 64-bit file sizes, but the meterpreter stat object only had 32 bits. We upped the C meterpreter stat struct to have a 64 bit value.

@bwatters-r7
Copy link
Contributor

FYI: #195

@OJ
Copy link
Contributor

OJ commented Dec 10, 2018 via email

@bwatters-r7
Copy link
Contributor

I think this is as fixed as we can do so on the python side after landing #322 and #327. If this remains an issue, please reopen the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants