Exemplo n.º 1
0
def main():
    global droplet
    global token
    global fingerprint

    name = 'burner-' + str(uuid.uuid1())
    keyfile = 'auth/burnerkey'

    try:
        secrets = json.load(open('auth/secrets.json', 'r'))
        token = secrets['user_token']
    except IOError:
        print_error('secrets.json not found')
        return 1

    keys = SSH_Keys(keyfile)
    keys.init()
    fingerprint = keys.get_pubkey_fingerprint()
    pubkey = keys.get_pubkey_ssh()

    account = Account(token)
    droplet = Droplet(token, name, 'nyc3', keyfile, fingerprint)

    print("> Adding SSH key...")
    account.add_ssh_key(name, pubkey)

    print("> Creating Droplet...")
    droplet.create()

    print("> Waiting for server to come online...")
    while not droplet.is_online():
        print('> Server offline. Trying again...')
        time.sleep(3)

    print("> Starting Instance...")
    init_wg(droplet)

    input(
        "> Press any key to nuke instance. (DISABLE VPN ON CLINET BEFORE NUKING)"
    )

    print("> Removing Droplet...")
    droplet.destroy()

    print("> Removing SSH key...")
    account.del_ssh_key(fingerprint)