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

Multiple function implementations #227

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

stonerhash
Copy link
Contributor

Implementations for:

  • ZwTerminateProcess

  • ZwOpenProcess

  • ZwDuplicateObject

  • ShellExecuteExW

  • copies of strstr, towlow, tolow, wstrstr from msvcrt to ntdll (since often are being called directly by ntdll)

[in] NTSTATUS ExitStatus
);
'''
#Copied from TerminateProcess
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#Copied from TerminateProcess
# Copied from TerminateProcess

oProc = emu.get_object_from_id(cid_obj.UniqueProcess)
hProc = emu.get_object_handle(oProc)
if hProc:
emu.mem_write(hnd,(hProc).to_bytes(4, "little"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
emu.mem_write(hnd,(hProc).to_bytes(4, "little"))
emu.mem_write(hnd, (hProc).to_bytes(4, "little"))

emu.mem_write(hnd,(hProc).to_bytes(4, "little"))
rv = ddk.STATUS_SUCCESS
else:
emu.mem_write(hnd,(0).to_bytes(4, "little"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
emu.mem_write(hnd,(0).to_bytes(4, "little"))
emu.mem_write(hnd, (0).to_bytes(4, "little"))

const wchar_t *strSearch
);
"""
#Copied from msvcrt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than copying the implementation, could we reuse the one in msvcrt somehow?

[in, out] SHELLEXECUTEINFOW *pExecInfo
);
'''
#Based on ShellExecute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#Based on ShellExecute
# Based on ShellExecute

Comment on lines +285 to +297
print(op)
p_fn = int.from_bytes(self.mem_read(pExecInfo + 0x10, 4), "little")
if p_fn:
fn = self.read_mem_string(p_fn, cw)
print(fn)
p_param = int.from_bytes(self.mem_read(pExecInfo + 0x14, 4),"little")
if p_param:
param = self.read_mem_string(p_param, cw)
print(param)
p_dn = int.from_bytes(self.mem_read(pExecInfo + 0x18,4), "little")
if p_dn:
dn = self.read_mem_string(p_dn, cw)
print(dn)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these old debugging statements?

proc = emu.create_process(path=fn, cmdline=param)
self.log_process_event(proc, PROC_CREATE)

return 33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this return value mean? maybe its left over from testing?

@stonerhash
Copy link
Contributor Author

@williballenthin I would suggest to close the pull request and not merge anything yet. I will address your comments and fix some additional bugs I have found and then I will reopen. I am actually working on couple of malware samples and try to implement the functions to be as real as possible. I dont want them to by just dummy ones. Thanks

@williballenthin williballenthin marked this pull request as draft February 21, 2023 08:31
@williballenthin
Copy link
Contributor

i've converted the PR to a "draft" so that its clear its not ready yet. feel free to keep working here (or, close it if you'd prefer, no problem). once its ready, just comment and press the "Ready for review" button.

@michaellrowley
Copy link

Has any progress been made on these definitions?

Great work on them, by the way!

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

Successfully merging this pull request may close these issues.

3 participants