8000 Fix ELF argv encoding by elicn · Pull Request #1303 · qilingframework/qiling · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix ELF argv encoding #1303

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

Merged
merged 1 commit into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qiling/loader/elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def __push_str(top: int, s: str) -> int:
Top of stack remains aligned to pointer size
"""

data = s.encode('utf-8') + b'\x00'
data = s.encode('latin') + b'\x00'
top = self.ql.mem.align(top - len(data), self.ql.arch.pointersize)
self.ql.mem.write(top, data)

Expand Down
6 changes: 3 additions & 3 deletions qiling/os/linux/procfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def self_auxv(os: 'QlOsLinux') -> QlFsMappedObject:

@staticmethod
def self_cmdline(os: 'QlOsLinux') -> QlFsMappedObject:
entries = (arg.encode('utf-8') for arg in os.ql.argv)
entries = (arg.encode('latin') for arg in os.ql.argv)
cmdline = b'\x00'.join(entries) + b'\x00'

return FsMappedStream(r'/proc/self/cmdline', cmdline)
Expand All @@ -51,7 +51,7 @@ def self_cmdline(os: 'QlOsLinux') -> QlFsMappedObject:
def self_environ(os: 'QlOsLinux') -> QlFsMappedObject:
def __to_bytes(s: AnyStr) -> bytes:
if isinstance(s, str):
return s.encode('utf-8')
return s.encode('latin')

return s

Expand All @@ -73,6 +73,6 @@ def self_map(mem: 'QlMemoryManager') -> QlFsMappedObject:
mapinfo = mem.get_mapinfo()

for lbound, ubound, perms, label, container in mapinfo:
content += f"{lbound:x}-{ubound:x}\t{perms}p\t0\t00:00\t0\t{container if container else label}\n".encode("utf-8")
content += f"{lbound:x}-{ubound:x}\t{perms}p\t0\t00:00\t0\t{container if container else label}\n".encode("latin")

return FsMappedStream(r'/proc/self/map', content)
0