#!/usr/bin/env python2
"""A basic exploit example.

Input:
    An IP address as first argument:
Output:
    A string composed of the service name, target IP
    address, flag and a timestamp in the following format:
    $service|$ip|$flag|$timestamp"""
import random
import string
import sys
import time
service = 'crasher'

if len(sys.argv)<2:
    sys.stderr.write('Please provide an IP/Host as argument.')
    sys.exit(1)

ip = sys.argv[1]

if __name__ == '__main__':
    choice = random.randint(1,5)

    if choice is 1:
        print('useless stuff')
    elif choice is 2:
        sys.exit(-1)
    elif choice is 3:
        raise Exception
    elif choice is 4:
        time.sleep(random.randint(120,160))
    elif choice is 5:
        time.sleep(random.randrange(5))
        flag = ''.join(random.choice('0123456789abcdefghijklmnopqrstuvwxyz') for x in range(31))
        flag += '='
        print(flag)
        raise IndexError
    else:
        time.sleep(random.randrange(5))
        flag = ''.join(random.choice('0123456789abcdefghijklmnopqrstuvwxyz') for x in range(31))
        flag += '='
        print(flag)
