def meta_autodetect_platform(cls):
"""
Dark magic to autodetect the platform for built-in shellcodes.
User-defined shellcodes must define *arch* and *os*.
"""
abspath = path.abspath
join = path.join
split = path.split
splitext = path.splitext
sep = path.sep
module = cls.__module__
if module != '__main__':
tokens = cls.__module__.split('.')
if len(tokens) < 2 or tokens[0] != base_package or \
tokens[1] == base_file:
return
tokens.insert(-1, 'any')
tokens = tokens[1:3]
else:
module = abspath(sys.modules[module].__file__)
if not module.startswith(base_dir):
return
tokens = module.split(sep)
tokens = tokens[len(base_dir.split(sep)):-1]
while len(tokens) < 2:
tokens.append('any')
cls.arch, cls.os = tokens
评论列表
文章目录