Exemplo n.º 1
0
def test_speed_1024():
    start_time = time.perf_counter()
    agent = CAgent("stallman.org", 443)
    agent.uri = "/"
    agent.make_header()
    agent.buffer_size = 1024
    resp = agent.request()
    end_time = time.perf_counter()
    print("Time for buffer size 1024: " + str(end_time - start_time))
Exemplo n.º 2
0
def get_stallman():
    agent = CAgent("stallman.org", 443)
    agent.uri = "/"
    agent.make_header()
    start_time = time.perf_counter()
    resp = agent.request()
    end_time = time.perf_counter()
    #agent.check_redirect(resp)
    print("Time: " + str(end_time - start_time))
Exemplo n.º 3
0
def test_redirect():
    start_time = time.perf_counter()
    agent = CAgent("cutt.ly", 443)
    agent.uri = "/FeyXNVr"
    agent.make_header()
    agent.buffer_size = 16384
    resp = agent.request()
    #print(resp)
    end_time = time.perf_counter()
    print("Time for redirect: " + str(end_time - start_time))
Exemplo n.º 4
0
def get_wiki():
    agent = CAgent("wikipedia.org", 443)
    agent.uri = "/"
    agent.make_header()
    start_time = time.perf_counter()
    resp = agent.request()
    end_time = time.perf_counter()
    #agent.check_redirect(resp)
    print("Time (wiki): " + str(end_time - start_time))
    print(resp)
Exemplo n.º 5
0
def act_1():
    """
	act_1:	runs the required actions to get the act 1 flag
		then prints out the flag
	It just makes a POST request to csec380-core.csec.rit.edu
	:return: Nothing
	"""
    print("Act 1")
    agent = CAgent(HOST, PORT)
    agent.make_header(method="POST", uri="/")
    resp = agent.single_request()
    print(resp.split('"')[1])
Exemplo n.º 6
0
def act_2():
    """
	act_2:	runs the required acts to get the act 2 flag
		then prints out the flag
	It gets a security token, puts that token in the body,
		then makes another POST request
	:return: Nothing
	"""
    print("Act 2")
    token = get_security_token(HOST, PORT)
    tok = "token=%s" % token
    agent = CAgent(HOST, PORT)
    agent.set_body(tok)
    agent.make_header(method="POST", uri="/getFlag2")
    response_2 = agent.single_request()
    print(response_2.split('"')[1])
Exemplo n.º 7
0
def act_4():
    """
	act_4:	runs the required acts to get the act 4 flag
		then prints out the flag
	It gets a security token, makes a request to create an
		account, gets a password, and sends all three
		in another POST request for the forth flag
	:return: Nothing
	"""
    print("Act 4")
    token = get_security_token(HOST, PORT)
    agent = CAgent(HOST, PORT)
    agent.set_body(("token=%s&username=%s" % (token, USERNAME)))
    agent.create_socket()
    agent.make_header(method="POST", uri="/createAccount")
    response = agent.request()
    password = response.split("password is ")[1]
    agent.set_body(("token=%s&username=%s&password=%s" %
                    (token, USERNAME, urllib.parse.quote(password))))
    agent.make_header(method="POST", uri="/login")
    response_2 = agent.request()
    print(response_2.split('"')[1])
Exemplo n.º 8
0
def act_3():
    """
	act_3:	runs the required acts to get the act 3 flag
		then prints out the flag
	It gets a security token, puts that token in the body,
		makes a request for a captcha, solves the captcha,
		then returns the token and the solution in
		another POST request
	:return: Nothing
	"""
    print("Act 3")
    token = get_security_token(HOST, PORT)
    agent = CAgent(HOST, PORT)
    agent.set_body(("token=%s" % token))
    agent.make_header(method="POST", uri="/getFlag3Challenge")
    agent.create_socket()
    response = agent.request()
    challenge = (response.split("solve the following: ")[1]).strip('"')
    answer = eval(challenge)
    agent.set_body("token=%s&solution=%d" % (token, answer))
    agent.make_header(method="POST", uri="/getFlag3Challenge")
    response_2 = agent.request()
    agent.socket.close()
    print(response_2.split('"')[1])