Esempio n. 1
0
def stream_logs(arg_vars, project_root):
    config = ConfigParser.ConfigParser()
    engraver_profile = expanduser("~") + "/.engraver"
    config.read(engraver_profile)
    pem_file_path = config.get('aws', 'pem_file_name', 0)
    remote_user = config.get('aws', 'remote_user', 0)
    service = arg_vars['service']
    container_name = service + "_container_name"

    f = util.service_path(project_root, service)
    if util.verify_cluster_exists(arg_vars, project_root):
        if exists(f):
            with open(f + "/defaults/main.yml", "r") as stream:
                content = yaml.load(stream)
                if content.get(container_name):
                    container = content[container_name]
                    call([
                        "ssh", "-t", "-i", pem_file_path,
                        remote_user + "@" + arg_vars['host'],
                        "docker logs -f " + container
                    ])
                else:
                    base = "Service does not define {0}_container_name in defaults/main.yml of its Ansible role. Cannot stream logs."
                    print_fail(base.format(service))
        else:
            print_fail("Service not found.")
Esempio n. 2
0
def zip_brute_banner():
    clear_screen()
    colors.print_fail("""
                                                    ____                      ,
                                                   /---.'.__             ____//
                                                        '--.\           /.---'
                                                   _______  \\\\         //
                                                 /.------.\  \|      .'/  ______
                                                //  ___  \ \ ||/|\  //  _/_----.\__
                                               |/  /.-.\  \ \:|< >|// _/.'..\   '--'
                                                  //   \'. | \'.|.'/ /_/ /  \\\\
                                                 //     \ \_\/" ' ~\-'.-'    \\\\
                                                //       '-._| :H: |'-.__     \\\\
                                               //           (/'==='\)'-._\     ||
                                               ||                        \\\\    \|
                                               ||                         \\\\    '
                                               |/                          \\\\
     ███████╗██╗██████╗     ██████╗ ██████╗ ██╗   ██╗████████╗███████╗      ||
     ╚══███╔╝██║██╔══██╗    ██╔══██╗██╔══██╗██║   ██║╚══██╔══╝██╔════╝      ||
       ███╔╝ ██║██████╔╝    ██████╔╝██████╔╝██║   ██║   ██║   █████╗        \\\\
      ███╔╝  ██║██╔═══╝     ██╔══██╗██╔══██╗██║   ██║   ██║   ██╔══╝         '
     ███████╗██║██║         ██████╔╝██║  ██║╚██████╔╝   ██║   ███████╗
     ╚══════╝╚═╝╚═╝         ╚═════╝ ╚═╝  ╚═╝ ╚═════╝    ╚═╝   ╚══════╝

                                                                      
    """)
Esempio n. 3
0
def machines_list(arg_vars, project_root, hint=True):
    if hint:
        print_ok(
            "Hint: Displaying cached contents. Refresh status with: engraver machines cache"
        )
        print("")

    path = project_root + "/.engraver/clusters/" + arg_vars[
        'cluster_id'] + ".json"
    if exists(path):
        t = PrettyTable(['', 'ID', 'Profile', 'Public DNS Name', 'Private IP'])
        t.align = "l"
        contents = open(path, 'r').read()
        machines = sorted(json.loads(contents),
                          key=lambda k: k.get('tags').get('ProfileId'))
        for index, m in enumerate(machines):
            t.add_row([
                index + 1,
                m.get('id'),
                m.get('tags').get('ProfileId'),
                m.get('public_dns_name'),
                m.get('private_ip_address')
            ])
        print t
    else:
        print_fail("No cached contents found.")
Esempio n. 4
0
def brute_banner():
    clear_screen()
    colors.print_fail("""
                            ____                      ,      . . . . . . . . . . . . . . .
                           /---.'.__             ____//      . . . . . . . . . . . . . . .
                                '--.\           /.---'      . . . . . . . . . . . . . . .
                           _______  \\\\         //      . . . . . . . . . . . . . . .
                         /.------.\  \|      .'/  ______      . . . . . . . . . . . . . . .
                        //  ___  \ \ ||/|\  //  _/_----.\__      . . . . . . . . . . . . . . .
                       |/  /.-.\  \ \:|< >|// _/.'..\   '--'      . . . . . . . . . . . . . . .
                          //   \'. | \'.|.'/ /_/ /  \\\\      . . . . . . . . . . . . . . .
                         //     \ \_\/" ' ~\-'.-'    \\\\      . . . . . . . . . . . . . . .
                        //       '-._| :H: |'-.__     \\\\      . . . . . . . . . . . . . . .
                       //           (/'==='\)'-._\     ||      . . . . . . . . . . . . . . .
                       ||                        \\\\    \|      . . . . . . . . . . . . . . .
                       ||                         \\\\    '      . . . . . . . . . . . . . . .
                       |/                          \\\\      . . . . . . . . . . . . . . .
    ██████╗ ██████╗ ██╗   ██╗████████╗███████╗      ||      . . . . . . . . . . . . . . .
    ██╔══██╗██╔══██╗██║   ██║╚══██╔══╝██╔════╝      ||      . . . . . . . . . . . . . . .
    ██████╔╝██████╔╝██║   ██║   ██║   █████╗        \\\\      . . . . . . . . . . . . . . .
    ██╔══██╗██╔══██╗██║   ██║   ██║   ██╔══╝         '      . . . . . . . . . . . . . . .
    ██████╔╝██║  ██║╚██████╔╝   ██║   ███████╗      . . . . . . . . . . . . . . .
    ╚═════╝ ╚═╝  ╚═╝ ╚═════╝    ╚═╝   ╚══════╝      . . . . . . . . . . . . . . .

                                                                      
    """)
Esempio n. 5
0
def verify_cluster_exists(arg_vars, project_root):
  cluster_id = arg_vars['cluster_id']
  f = cluster_file(project_root, cluster_id)
  r = exists(f)

  if not r:
    print_fail("Cluster {0} does not exist.".format(cluster_id))
  return r
Esempio n. 6
0
def verify_profile_exists(arg_vars, project_root):
  cluster_id = arg_vars['cluster_id']
  profile_id = arg_vars['profile_id']
  f = machine_profile_file(project_root, cluster_id, profile_id)
  r = exists(f)

  if not r:
    print_fail("Profile {0} does not exist".format(profile_id))
  return r
Esempio n. 7
0
def start_brute(path, extract_to):
    for password in password_checker.passwords:
        try:
            colors.print_warning(f"[*] Attempting to extract with password: {password}")
            if(unzip(path, extract_to, password)):
                return
        except Exception as err:
            msg = str(err)
            if(msg.find("Bad password") == -1):
                print(msg)
                raise err

    colors.print_fail("[!] Unable to extract files, password not found")
Esempio n. 8
0
def check_hash(hash):
    try:
        res = vtotal.file_report([hash])
        data = res.get('json_resp')
        if (data.get('response_code') == 0):
            colors.print_header('  [~] No threat found')
            return
        positives = int(data.get("positives"))
        if (positives >= 3):
            colors.print_fail(f'  [!] {positives} Threats found ')
        else:
            colors.print_warning(f'  [!] {positives} Potential threats found')
    except Exception as err:
        colors.print_info("  [!] MAX REQUESTS EXCEEDED")
Esempio n. 9
0
def machines_describe(arg_vars, project_root):
  cluster_id = arg_vars['cluster_id']
  path = util.machine_profiles_path(project_root, cluster_id)

  if exists(path):
    files = [f for f in listdir(path) if isfile(join(path, f))]
    t = PrettyTable(['Profile ID', 'Size', 'Services', 'Desired Count'])
    t.align = "l"
    t.align["Desired Count"] = "c"
    for f in files:
      with open(path + "/" + f, 'r') as stream:
        content = yaml.load(stream)
        t.add_row([content['profile_id'],
                   content['ec2_instance_type'],
                   ", ".join(content.get('machine_services', [])),
                   content['n_machine_instances']])
    print t
  else:
    print_fail("No machine profiles were found for this cluster.")
Esempio n. 10
0
def machines_describe(arg_vars, project_root):
    cluster_id = arg_vars['cluster_id']
    path = util.machine_profiles_path(project_root, cluster_id)

    if exists(path):
        files = [f for f in listdir(path) if isfile(join(path, f))]
        t = PrettyTable(['Profile ID', 'Size', 'Services', 'Desired Count'])
        t.align = "l"
        t.align["Desired Count"] = "c"
        for f in files:
            with open(path + "/" + f, 'r') as stream:
                content = yaml.load(stream)
                t.add_row([
                    content['profile_id'], content['ec2_instance_type'],
                    ", ".join(content.get('machine_services',
                                          [])), content['n_machine_instances']
                ])
        print t
    else:
        print_fail("No machine profiles were found for this cluster.")
Esempio n. 11
0
def machines_list(arg_vars, project_root, hint=True):
  if hint:
    print_ok("Hint: Displaying cached contents. Refresh status with: engraver machines cache")
    print("")

  path = project_root + "/.engraver/clusters/" + arg_vars['cluster_id'] + ".json"
  if exists(path):
    t = PrettyTable(['', 'ID', 'Profile', 'Public DNS Name', 'Private IP'])
    t.align = "l"
    contents = open(path, 'r').read()
    machines = sorted(json.loads(contents), key=lambda k: k.get('tags').get('ProfileId'))
    for index, m in enumerate(machines):
        t.add_row([index + 1,
                   m.get('id'),
                   m.get('tags').get('ProfileId'),
                   m.get('public_dns_name'),
                   m.get('private_ip_address')])
    print t
  else:
    print_fail("No cached contents found.")
Esempio n. 12
0
def stream_logs(arg_vars, project_root):
  config = ConfigParser.ConfigParser()
  engraver_profile = expanduser("~") + "/.engraver"
  config.read(engraver_profile)
  pem_file_path = config.get('aws', 'pem_file_name', 0)
  remote_user = config.get('aws', 'remote_user', 0)
  service = arg_vars['service']
  container_name = service + "_container_name"

  f = util.service_path(project_root, service)
  if util.verify_cluster_exists(arg_vars, project_root):
    if exists(f):
      with open(f + "/defaults/main.yml", "r") as stream:
        content = yaml.load(stream)
        if content.get(container_name):
          container = content[container_name]
          call(["ssh", "-t", "-i", pem_file_path, remote_user + "@" + arg_vars['host'], "docker logs -f " + container])
        else:
          base = "Service does not define {0}_container_name in defaults/main.yml of its Ansible role. Cannot stream logs."
          print_fail(base.format(service))
    else:
      print_fail("Service not found.")
Esempio n. 13
0
def connect_ssh(hostname, username, password):
    client = paramiko.SSHClient()
    try:
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    except:
        pass
    try:
        colors.print_warning(
            f"[ATTEMPTING CONNECTION] || {hostname} || {username}:{password}")
        client.connect(hostname=hostname,
                       username=username,
                       password=password,
                       timeout=3)
    except socket.timeout as err:
        colors.print_fail(f"[!] Invalid Host: {hostname}")
        raise err
    except paramiko.AuthenticationException:
        return None
    except paramiko.SSHException as err:
        timeout_attempts += 1
        if (timeout_attempts < 5):
            colors.print_info(f"Time Locked retrying... {timeout_attempts}/5")
            time.sleep(60)
            return connect_ssh(hostname, username, password)
        else:
            raise err
    except Exception as err:
        raise err

    colors.print_success("[+] CONNECTION ESTABLISHED:")

    print(f"""
    {colors.colors.ENDC}HOSTNAME: {colors.colors.HEADER}{hostname}
    {colors.colors.ENDC}USERNAME: {colors.colors.HEADER}{username}
    {colors.colors.ENDC}PASSWORD: {colors.colors.HEADER}{password}
    {colors.colors.ENDC}
    """)
    return client