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

"IOError: File name too long " when call ROP #1180

Closed
kato-megumi opened this issue Jul 31, 2018 · 0 comments
Closed

"IOError: File name too long " when call ROP #1180

kato-megumi opened this issue Jul 31, 2018 · 0 comments

Comments

@kato-megumi
Copy link

kato-megumi commented Jul 31, 2018

Error log:

Traceback (most recent call last):
File "vortex12.py", line 46, in
rop = ROP(libs)
File "/usr/local/lib/python2.7/dist-packages/pwnlib/rop/rop.py", line 466, in init
self.__load()
File "/usr/local/lib/python2.7/dist-packages/pwnlib/rop/rop.py", line 1090, in __load
self.__cache_save(elf, elf_gadgets)
File "/usr/local/lib/python2.7/dist-packages/pwnlib/rop/rop.py", line 1009, in __cache_save
file(self.__get_cachefile_name(elf), 'w+').write(repr(data))
IOError: [Errno 36] File name too long: '/tmp/pwntools-rop-cache/2af3321088068fd0fabfbc8c938b47aa2a22e3876b39aa0f9c894f02f1c5edf6_e79282760fb8d4fd9c7310515c6d9617c28f95fc9562a9058cb69cd861c534be_331321edfc0b8c9b643600ce1b5bf7348b2a635cd04b1ec631cf65b8128afe12_066e2be587ae87d77cf03fd5a2155f1a203c8e3d2d405ca89f006c81c7145e58'

This probably what cause problem:

def __get_cachefile_name(self, files):
        """Given an ELF or list of ELF objects, return a cache file for the set of files"""
        cachedir = os.path.join(tempfile.gettempdir(), 'pwntools-rop-cache')
        if not os.path.exists(cachedir):
            os.mkdir(cachedir)

        if isinstance(files, ELF):
            files = [files]

        hashes = []

        for elf in self.elfs:
            sha256 = hashlib.sha256(elf.get_data()).hexdigest()
            hashes.append(sha256)

        return os.path.join(cachedir, '_'.join(hashes))

Linux max filename length only 255 so instead of join hash files name, dont better should hash the join file name ?

xtrm0 added a commit to xtrm0/pwntools that referenced this issue Oct 5, 2018
xtrm0 added a commit to xtrm0/pwntools that referenced this issue Oct 5, 2018
@Arusekk Arusekk closed this as completed in 215b2e6 Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants