Esempio n. 1
0
def try_password(options, password, output=None, k=0):

    p = SAPRouter(type=SAPRouter.SAPROUTER_ADMIN,
                  version=options.router_version)
    p.adm_command = 2
    p.adm_password = password
    p = str(SAPNI() / p)

    import fau_timer
    fau_timer.init()
    fau_timer.send_request(options.remote_host, options.remote_port, p, len(p))
    fau_timer.calculate_time()
    cpuSpeed = fau_timer.get_speed()
    cpuTicks = fau_timer.get_cpu_ticks()
    time = fau_timer.get_time()

    if options.verbose:
        print("Request time: CPU Speed: %s Hz CPU Ticks: %s Time: %s nanosec" %
              (cpuSpeed, cpuTicks, time))

    # Write the time to the output file
    if output:
        output.write("%i,%s,%s\n" % (k, password, time))

    return time
Esempio n. 2
0
def try_password(options, password, output=None, k=0):

    p = SAPRouter(type=SAPRouter.SAPROUTER_ADMIN, version=options.router_version)
    p.adm_command = 2
    p.adm_password = password
    p = str(SAPNI() / p)

    fau_timer.init()
    fau_timer.send_request(options.remote_host, options.remote_port, p, len(p))
    fau_timer.calculate_time()
    cpu_peed = fau_timer.get_speed()
    cpu_ticks = fau_timer.get_cpu_ticks()
    time = fau_timer.get_time()

    if options.verbose:
        print("Request time: CPU Speed: %s Hz CPU Ticks: %s Time: %s nanosec" % (cpu_peed, cpu_ticks, time))

    # Write the time to the output file
    if output:
        output.write("%i,%s,%s\n" % (k, password, time))

    return time
Esempio n. 3
0
def main():
    args = parse_args()
    if args.list is False and args.help_modules is None:
        if not args.target_ip:
            print 'Target IP is required: -ti'
            sys.exit(6)
        if not args.target_port:
            print 'Target port is required: -tp'
            sys.exit(7)

    if args.logfile is not None:
        try:
            args.logfile = open(args.logfile, 'a', 0)  # unbuffered
        except Exception as ex:
            print 'Error opening logfile'
            print ex
            sys.exit(4)

    if args.listen_ip != '0.0.0.0' and not is_valid_ip4(args.listen_ip):
        try:
            ip = socket.gethostbyname(args.listen_ip)
        except socket.gaierror:
            ip = False
        if ip is False:
            print '%s is not a valid IP address or host name' % args.listen_ip
            sys.exit(1)
        else:
            args.listen_ip = ip

    if not is_valid_ip4(args.target_ip):
        try:
            ip = socket.gethostbyname(args.target_ip)
        except socket.gaierror:
            ip = False
        if ip is False:
            print '%s is not a valid IP address or host name' % args.target_ip
            sys.exit(2)
        else:
            args.target_ip = ip

    if args.in_modules is not None:  #modules for communication from client (incoming)
        in_modules = generate_module_list(args.in_modules,
                                          incoming=True,
                                          verbose=args.verbose)
    else:
        in_modules = None

    if args.out_modules is not None:  #modules for communication from server (outgoing)
        out_modules = generate_module_list(args.out_modules,
                                           incoming=False,
                                           verbose=args.verbose)
    else:
        out_modules = None

    # this is the socket we will listen on for incoming connections
    proxy_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    proxy_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

    try:
        proxy_socket.bind((args.listen_ip, args.listen_port))
    except socket.error as e:
        print e.strerror
        sys.exit(5)

    fau_timer.init()
    timeLog = open("timeLog", 'a', 0)
    delta_6 = 0  #1
    delta_7 = 1  #0
    L = 4
    counter = 0
    global time_array
    proxy_socket.listen(10)
    log(args.logfile, str(args))
    # endless loop until ctrl+c
    try:
        while True:

            in_socket, in_addrinfo = proxy_socket.accept(
            )  #this method waits for an incoming connection - returns when this happens, o.w. waits

            if counter == L:
                counter = 0
                errorTime = median(time_array)
                log(timeLog,
                    str(delta_6) + "," + str(delta_7) + "-",
                    message_only=True)
                log(timeLog, str(errorTime) + '\n', message_only=True)
                delta_6, delta_7 = update_delta(delta_6, delta_7)
                time_array = []
            else:
                counter = counter + 1

            if args.verbose:
                print 'Connection from %s:%d' % in_addrinfo
            log(args.logfile, 'Connection from %s:%d' % in_addrinfo)
            #proxy_thread = threading.Thread(target=handle_connection,
            # args=(in_socket, args, in_modules,
            #      out_modules, delta_6, delta_7))
            #log(args.logfile, "Starting proxy thread " + proxy_thread.name)
            #proxy_thread.start()

            handle_connection(in_socket, args, in_modules, out_modules,
                              delta_6, delta_7)
    except KeyboardInterrupt:
        log(args.logfile, 'Ctrl+C detected, exiting...')
        print '\nCtrl+C detected, exiting...'
        sys.exit(0)
Esempio n. 4
0
import fau_timer

# The request we send to the server
host = "localhost"
request_a = "GET /example2/index.php?q=0 HTTP/1.1\r\nHost: " + host + "\r\n\r\n"
request_b = "GET /example2/index.php?q=1 HTTP/1.1\r\nHost: " + host + "\r\n\r\n"

# Warmup to fill caches etc...
print "Warmup: send 10 requests\r"
for i in range(10):
        fau_timer.init()
        fau_timer.send_request(host, 80, request_a)

times = 100 # number of request send to the server

# Open file for output
f = open('output.csv', 'w')

# Do the request "times" times
for i in range(times):
        # initialize fau_timer
        fau_timer.init()

        # Send the request and measure the response time
        if i%2 == 0:
                fau_timer.send_request(host, 80, request_a)
        else:
                fau_timer.send_request(host, 80, request_b)

        # Now get the ticks and the time from fau_timer
        fau_timer.calculate_time()
import fau_timer

# The request we send to the server
host = "localhost"
request_a = "GET /example1/index.php?q=Apache HTTP/1.1\r\nHost: " + host + "\r\n\r\n"
request_b = "GET /example1/index.php?q=ADDENDUM HTTP/1.1\r\nHost: " + host + "\r\n\r\n"

# Warmup to fill caches etc...
print "Warmup: send 10 requests\r"
for i in range(10):
    fau_timer.init()
    fau_timer.send_request(host, 80, request_a)

times = 100  # number of request send to the server

# Open file for output
f = open('output.csv', 'w')

# Do the request "times" times
for i in range(times):
    # initialize fau_timer
    fau_timer.init()

    # Send the request and measure the response time
    if i % 2 == 0:
        fau_timer.send_request(host, 80, request_a)
    else:
        fau_timer.send_request(host, 80, request_b)

    # Now get the ticks and the time from fau_timer
    fau_timer.calculate_time()