Beispiel #1
0
def session_replay(input, proxy, result_queue):
    global bSTOP
    ''' Replay all transactions in session 
    
    This entire session will be replayed in one requests.Session (so one socket / TCP connection)'''
    # if timing_control:
    #    time.sleep(float(session._timestamp))  # allow other threads to run
    while bSTOP == False:
        for session in iter(input.get, 'STOP'):
            # print(bSTOP)
            if session == 'STOP':
                print("Queue is empty")
                bSTOP = True
                break
            with requests.Session() as request_session:
                request_session.proxies = proxy
                for txn in session.getTransactionIter():
                    type = random.randint(1, 1000)
                    try:
                        if type % 3 == 0:
                            NonSSL.txn_replay(session._filename, txn, proxy, result_queue, request_session)
                        elif type % 3 == 1:
                            SSLReplay.txn_replay(session._filename, txn, proxy, result_queue, request_session)
                        elif type % 3 == 2:
                            h2Replay.txn_replay(session._filename, txn, proxy, result_queue, request_session)
                    except:
                        e = sys.exc_info()
                        print("ERROR in replaying: ", e, txn.getRequest().getHeaders())
        bSTOP = True
        #print("Queue is empty")
        input.put('STOP')
        break
Beispiel #2
0
def worker(input, output, proxy, replay_type, nThread):
    #progress_bar = Bar(" Replaying sessions {0}".format(current_process().name), max=input.qsize())
    #print("playing {0}=>{1}:{2}".format(current_process().name,session._timestamp,proxy))
    if replay_type == 'random':
        RandomReplay.client_replay(input, proxy, output, nThread)
    elif replay_type == 'ssl':
        SSLReplay.client_replay(input, proxy, output, nThread)
    elif replay_type == 'h2':
        h2Replay.client_replay(input, proxy, output, nThread)
        # progress_bar.next()
    # progress_bar.finish()
    print("process{0} has exited".format(current_process().name))
Beispiel #3
0
def worker(input, output, proxy, replay_type, nThread):
    #progress_bar = Bar(" Replaying sessions {0}".format(current_process().name), max=input.qsize())
        #print("playing {0}=>{1}:{2}".format(current_process().name,session._timestamp,proxy))
    if replay_type == 'nossl':
        NonSSL.client_replay(input, proxy, output, nThread)
    elif replay_type == 'ssl':
        SSLReplay.client_replay(input, proxy, output, nThread)
    elif replay_type == 'h2':
        h2Replay.client_replay(input, proxy, output, nThread)
    elif replay_type == 'random':
        RandomReplay.client_replay(input, proxy, output, nThread)

        # progress_bar.next()
    # progress_bar.finish()
    print("process{0} has exited".format(current_process().name))