Skip to content

Commit

Permalink
fixed error from #902
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Nov 8, 2022
1 parent ea8273b commit ec83f44
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions gef.py
Expand Up @@ -1298,7 +1298,7 @@ def malloc_state_t() -> Type[ctypes.Structure]:
# https://elixir.bootlin.com/glibc/glibc-2.23/source/malloc/malloc.c#L1719
fields += [
("attached_threads", pointer)
]
]
fields += [
("system_mem", pointer),
("max_system_mem", pointer),
Expand Down Expand Up @@ -1586,7 +1586,7 @@ def get_next_chunk(self, allow_unaligned: bool = False) -> "GlibcChunk":

def get_next_chunk_addr(self) -> int:
return self.data_address + self.size

def has_p_bit(self) -> bool:
return bool(self.flags & GlibcChunk.ChunkFlags.PREV_INUSE)

Expand Down Expand Up @@ -1683,7 +1683,7 @@ def reveal_ptr(self, pointer: int) -> int:
return gef.memory.read_integer(pointer) ^ (pointer >> 12)

class GlibcTcacheChunk(GlibcFastChunk):

pass


Expand Down Expand Up @@ -6797,13 +6797,11 @@ def get_shellcode(self, sid: int) -> None:
return

ok("Downloaded, written to disk...")
tempdir = gef.config["gef.tempdir"]
fd, fname = tempfile.mkstemp(suffix=".txt", prefix="sc-", text=True, dir=tempdir)
shellcode = res.split("<pre>")[1].split("</pre>")[0]
shellcode = b"\n".join(shellcode).replace(b"&quot;", b'"')
os.write(fd, shellcode)
os.close(fd)
ok(f"Shellcode written to '{fname}'")
with tempfile.NamedTemporaryFile(prefix="sc-", suffix=".txt", mode='w+b', delete=False, dir=gef.config["gef.tempdir"]) as fd:
shellcode = res.split(b"<pre>")[1].split(b"</pre>")[0]
shellcode = shellcode.replace(b"&quot;", b'"')
fd.write(shellcode)
ok(f"Shellcode written to '{fd.name}'")
return


Expand Down

0 comments on commit ec83f44

Please sign in to comment.