Skip to content

Commit

Permalink
Create temporary copy of cached file
Browse files Browse the repository at this point in the history
  • Loading branch information
peace-maker committed Feb 25, 2024
1 parent 4c42d77 commit b13f56b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pwnlib/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,13 @@ def asm(shellcode, vma = 0, extract = True, shared = False):
if extract:
with open(cache_file, 'rb') as f:
return f.read()
else:
return cache_file

# Create a temporary copy of the cached file to avoid modification.
tmpdir = tempfile.mkdtemp(prefix = 'pwn-asm-')
atexit.register(shutil.rmtree, tmpdir)
step3 = os.path.join(tmpdir, 'step3')
shutil.copy(cache_file, step3)
return step3

assembler = _assembler()
linker = _linker()
Expand Down

0 comments on commit b13f56b

Please sign in to comment.