Exemplo n.º 1
0
    def __init__(self):
        self.pty_pid = ""
        self.pty_fd = ""
        self.session_id = 0
        self.cs_name = socket.gethostname()
        self.hostname = self.cs_name
        self.winsize = self.get_current_win_size()
        self.log_fd = ""
        self.log_file = ""
        self.vim_flag = False
        self.vim_data = ""
        self.err_log_f = ""
        self.vim_end_pattern = re.compile(r'\x1b\[\?1049', re.X)
        self.ps1_pattern = re.compile("[@a-zA-Z0-9-_\.*]+\@[a-zA-Z0-9-_\.]+")
        self.__init_screen_stream()

        try:
            self.pty_pid, self.pty_fd = os.forkpty()

            if self.pty_pid != 0:
                ts = threading.Thread(target=self.wait_child, args=())
                ts.setDaemon(True)
                ts.start()
        except OSError, e:
            print "Open Bash Error! (contact %s)" % (",".join(ADMINS), )
            os.Exit(1)
Exemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser(
        description='Parse must gather assets from CI run')
    parser.add_argument('artifacts_url',
                        metavar='ARTIFACTS_URL',
                        help='artifacts url with must gather data')
    parser.add_argument('--output-dir',
                        type=str,
                        default="/tmp",
                        help='Base directory to create output artifacts')
    parser.add_argument('--refetch',
                        type=bool,
                        default=False,
                        help='Re-download artifacts for processing')
    args = parser.parse_args()

    artifacts_url = args.artifacts_url
    output_dir = args.output_dir
    refetch = args.refetch

    if not os.path.exists(output_dir) or not os.path.isdir(output_dir):
        print("output-dir invalid, need existing directory. exiting")
        os.Exit(1)

    artifact_pathstring = create_artifact_pathstring(output_dir, artifacts_url)
    print("Using directory {} for artifacts".format(artifact_pathstring))

    op = OP(artifact_pathstring, artifacts_url, refetch)
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("image_folder")
    parser.add_argument("csv_file")
    parser.add_argument("result_file")
    args = parser.parse_args()
    if not args.image_folder or not args.csv_file or not args.result_file:
        print("Invalid args/")
        os.Exit(-1)
    image_ids = walk_directory(args.image_folder)
    full_dataset = pd.read_csv(args.csv_file)
    new_df = full_dataset.loc[full_dataset['imageName'].isin(image_ids), :]
    print(full_dataset.shape)
    print(new_df.shape)
    print(len(image_ids))
    new_df.to_csv(args.result_file, index=False)
Exemplo n.º 4
0
def main():
    if args.sample is not "":
        nanocore_sample = pefile.PE(args.sample)
        for rsrc in nanocore_sample.DIRECTORY_ENTRY_RESOURCE.entries:
            for entry in rsrc.directory.entries:
                if entry.id:
                    offset = entry.directory.entries[
                        0].data.struct.OffsetToData
                    size = entry.directory.entries[0].data.struct.Size
                    raw_config_data = nanocore_sample.get_memory_mapped_image(
                    )[offset:offset + size]
                    print("[+] extracted encrypted config from PE resource")

    elif args.config_rsrc is not "":
        if parser.guid is "":
            print(
                "[!] if a raw resource is being passed the PE guid must be passed as well"
            )
        raw_config_data = open(args.config_rsrc, 'rb').read()

    if args.guid == "":
        print("[!] a GUID is required for the nanocore sample")
        os.Exit(1)

    guid = uuid.UUID(args.guid).bytes_le

    # AES encrypted key
    encrypted_key = raw_config_data[4:20]

    # rfc2898 derive IV and key
    div, dkey = derive_pbkdf2(guid, guid, 16, 16, 8)

    # init new rijndael cipher
    rjn = new(dkey, MODE_CBC, div, blocksize=len(encrypted_key))

    # decrypt the config encryption key
    final_key = rjn.decrypt(encrypted_key)

    # decrypt the config
    decrypted_conf = decrypt_config(raw_config_data, final_key)
    config_dict = parse_config(decrypted_conf)
    for v, k in config_dict.items():
        print("[+] Config param {}: {}".format(v, k))

    with open('config_out.bin', 'wb') as out:
        out.write(decrypted_conf)
Exemplo n.º 5
0
 def loop_query(obj, nickname, begin, count, limits=None):
     if limits is None:
         limits = 100
     try:
         data = obj.complete_info(nickname=nickname,
                                  begin=begin,
                                  count=count)
     except Exception as e:
         print("-----")
         print(e)
         print("-----")
         if limits == 0:
             print("爬取已完成或者出现了其他错误。")
             os.Exit(0)
         print("delay %d seconds" % time_delay)
         limits = limits - 1
         print("time limits: %d" % limits)
         time.sleep(time_delay)
         return loop_query(obj, nickname, begin, count, limits=limits)
     return data
Exemplo n.º 6
0
if size_1 != size_2 or new_hash != current_hash or not running:
    if not running:
        for line in os.popen(
                'go get github.com/brotherlogic/buildserver/buildserver_cli'):
            pass
        for line in os.popen(
                'buildserver_cli crash gobuildslave version out.txt'):
            pass
    else:
        try:
            os.popen(
                'go get github.com/brotherlogic/versionserver/versionserver_cli'
            )
            os.popen('versionserver_cli guard ' + name)
        except IOError:
            os.Exit(0)
        for line in os.popen("cp out.txt oldout.txt").readline():
            pass
        for line in os.popen('echo "" > out.txt').readlines():
            pass
        for line in os.popen('killall ' + name).readlines():
            pass
    if socket.gethostname() == "stationone" or socket.gethostname(
    ) == "natframe" or socket.gethostname(
    ) == 'framethree' or socket.gethostname() == "printer":
        subprocess.Popen(['./' + name, '--builds=false'])
    else:
        if socket.gethostname() == "argon":
            subprocess.Popen(['./' + name, '--max_jobs=50'])
        else:
            subprocess.Popen(['./' + name])
Exemplo n.º 7
0
import os
import urllib.parse

import pymysql

args = {}

args['host'] = os.environ.get('VT_HOST')
if (args['host'] is None):
    print('VT_HOST must be set')
    os.Exit(1)

port = os.environ.get('VT_PORT')
if (port is None):
    args['port'] = 3306
else:
    args['port'] = int(port)

args['user'] = os.environ.get('VT_USERNAME')
if (args['user'] is None):
    print('VT_USERNAME must be set')
    os.Exit(2)

password = os.environ.get('VT_PASSWORD')
if (password is not None):
    args['password'] = password

args['db'] = os.environ.get('VT_DATABASE')
if (args['db'] is None):
    print('VT_DATABASE must be set')
    os.Exit(3)
Exemplo n.º 8
0
now = datetime.datetime.now()

handles = {'YEAR': now.year}

try:
    handles['REPO_TITLE'] = os.environ['REPO_TITLE']
    handles['REPO_NAME'] = os.environ['REPO_NAME']
    handles['RELEASE'] = os.environ['RELEASE']
    handles['MINOR'] = os.environ['MINOR']
    handles['PATCH'] = os.environ['PATCH']
    handles['REPO_PATH'] = os.environ['REPO_PATH']
    handles['DEVELOPER'] = os.environ['DEVELOPER']
except:
    print("Error: %s\n" % sys.exc_info()[0])
    print("Is direnv working correctly?\n")
    os.Exit(1)


def load_snippets():
    res = subprocess.getoutput(
        "cd / && find %s/repo/snippets -type f -not -path '*/\.*'" %
        handles['REPO_PATH'])
    overlay = str.split(res, '\n')

    for file in overlay:
        # Reverse the full path, cut the short name off, reverse back
        v = str.split(file[::-1], '/')[0][::-1]
        handles[v] = Path(file).read_text()


def load_commit_count():