-
Notifications
You must be signed in to change notification settings - Fork 681
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
add 'AMD64' arch in get_system_arch()
#555
add 'AMD64' arch in get_system_arch()
#555
Conversation
python/meterpreter/meterpreter.py
Outdated
@@ -483,7 +483,7 @@ def get_system_arch(): | |||
ctypes.windll.kernel32.GetNativeSystemInfo(ctypes.byref(sysinfo)) | |||
values = {0:'x86', 5:'armle', 6:'IA64', 9:'x64'} | |||
arch = values.get(sysinfo.wProcessorArchitecture, uname_info[4]) | |||
if arch == 'x86_64': | |||
if arch == 'x86_64' or arch == 'AMD64': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this should be a case insensitive test instead? I'm not sure about the exact output of platform.uname()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's worth calling arch.lower() see https://github.com/rapid7/metasploit-payloads/pull/530/files and https://github.com/rapid7/metasploit-framework/blob/master/lib/msf/core/post/linux/kernel.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, I'll update it, thanks!
Mac:
Linux:
Windows vm with python 3.1.1 installed via choco
Potentially relevant issue was raised on Python itself platform.uname()[4] returns 'amd64' on Windows and 'x86-64' on Linux:
|
@@ -483,7 +483,7 @@ def get_system_arch(): | |||
ctypes.windll.kernel32.GetNativeSystemInfo(ctypes.byref(sysinfo)) | |||
values = {0:'x86', 5:'armle', 6:'IA64', 9:'x64'} | |||
arch = values.get(sysinfo.wProcessorArchitecture, uname_info[4]) | |||
if arch == 'x86_64': | |||
if arch == 'x86_64' or arch.lower() == 'amd64': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In particular:
Cygwin on Windows uses "x86_64", FreeBSD uses "amd64", Linux uses "x86_64". Mac OS X uses "x86_64" for Intels (and ppc64" for PowerPCs).
Should we add those values too? 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the edgecases are only really around powerpc, which isn't a super relevant target these days
From the freebsd uname man pages:
EXAMPLES
The hardware platform (-m) can be different from the machine's processor
architecture (-p), e.g., on 64-bit PowerPC, -m would return powerpc and
-p would return powerpc64
Summary
This PR appends a condition in the method
get_system_arch()
which returns the value ofplatform.uname()[4]
whenctypes
module is not present. The value can bex86_64
andAMD64
based on the processor type. But for consistency it should returnx64
in both the cases.Before
After