Ejemplo n.º 1
0
def test_raw2():
    """Test to make sure a raw request will work with actual seperators"""
    x = ruleset.Input(dest_addr="example.com",
                      raw_request="""GET / HTTP/1.1
Host: example.com


""")
    http_ua = http.HttpUA()
    http_ua.send_request(x)
    assert http_ua.response_object.status == 200
Ejemplo n.º 2
0
Archivo: test_http.py Proyecto: tes/ftw
def test_cookies1():
    """Tests accessing a site that sets a cookie and then wants to resend the cookie"""
    http_ua = http.HttpUA()
    x = ruleset.Input(dest_addr="ieee.org", headers={"Host": "ieee.org"})
    http_ua.send_request(x)
    with pytest.raises(KeyError):
        print http_ua.request_object.headers["cookie"]
    x = ruleset.Input(dest_addr="ieee.org", headers={"Host": "ieee.org"})
    http_ua.send_request(x)
    assert (
        http_ua.request_object.headers["cookie"].split('=')[0] == "TS01293935")
Ejemplo n.º 3
0
def test_gzip():
    """Accept-Encoding gzip"""
    x = ruleset.Input(dest_addr="example.com",
                      version="HTTP/1.0",
                      headers={
                          "Host": "example.com",
                          "Accept-Encoding": "gzip"
                      })
    http_ua = http.HttpUA()
    http_ua.send_request(x)
    assert http_ua.response_object.status == 200
    assert http_ua.response_object.headers["content-encoding"] == "gzip"
Ejemplo n.º 4
0
def test_brotli():
    """Accept-Encoding br"""
    x = ruleset.Input(dest_addr="httpbin.org",
                      uri="/brotli",
                      headers={
                          "Host": "httpbin.org",
                          "Accept-Encoding": "br"
                      })
    http_ua = http.HttpUA()
    http_ua.send_request(x)
    assert http_ua.response_object.status == 200
    assert http_ua.response_object.headers["content-encoding"] == "br"
Ejemplo n.º 5
0
def run_requeЅtЅ(uЅeragent_liЅt):
    ЅtatuЅ_not_403 = 0
    ЅtatuЅ_403 = 0
    for uЅeragent in uЅeragent_liЅt:
        if (ЅtatuЅ_not_403 + ЅtatuЅ_403)%15 == 0:
            print("Ѕend",ЅtatuЅ_not_403 + ЅtatuЅ_403, "Out of",len(uЅeragent_liЅt))
        input_data = ruleЅet.Input(method="GET", protocol="http",port=80,uri='/',deЅt_addr="localhoЅt",headerЅ={"HoЅt":"localhoЅt","UЅer-Agent":uЅeragent})
        http_ua = http.HttpUA()
        http_ua.Ѕend_requeЅt(input_data)
        ЅtatuЅ = http_ua.reЅponЅe_object.ЅtatuЅ
        if ЅtatuЅ == 403:	
            ЅtatuЅ_403 += 1
        elЅe:
            ЅtatuЅ_not_403 += 1        
Ejemplo n.º 6
0
def test_cookies2():
    """Test to make sure that we don't override user specified cookies"""
    http_ua = http.HttpUA()
    x = ruleset.Input(dest_addr='example.com', headers={'Host': 'example.com'})
    http_ua.send_request(x)
    x = ruleset.Input(dest_addr='example.com',
                      headers={
                          'Host': 'example.com',
                          'cookie': 'TS01247332=012f3506234413e6c5cb14e8c0'
                                    'd5bf890fdd02481614b01cd6cd30911c6733e'
                                    '3e6f79e72aa'})
    http_ua.send_request(x)
    assert('TS01247332=012f3506234413e6c5cb14e8c0d5bf890fdd02481614b01cd6c'
           'd30911c6733e3e6f79e72aa' in
           http_ua.request_object.headers['cookie'])
Ejemplo n.º 7
0
def test15():
    # Request with content-type and content-length specified
    x = ruleset.Input(method="POST",
                      protocol="http",
                      port=80,
                      dest_addr="example.com",
                      headers={
                          "Content-Type": "application/x-www-form-urlencoded",
                          "Host": "example.com",
                          "Content-Length": "7"
                      },
                      data="test=hi")
    http_ua = http.HttpUA(x)
    http_ua.send_request()
    assert http_ua.response_object.status == 200
Ejemplo n.º 8
0
Archivo: test_http.py Proyecto: tes/ftw
def test_cookies4():
    """Test to make sure cookies are saved when user-specified cookie is added"""
    http_ua = http.HttpUA()
    x = ruleset.Input(dest_addr="ieee.org", headers={"Host": "ieee.org"})
    http_ua.send_request(x)
    x = ruleset.Input(dest_addr="ieee.org",
                      headers={
                          "Host": "ieee.org",
                          "cookie": "XYZ=123"
                      })
    http_ua.send_request(x)
    assert ([
        chunk.split('=')[0].strip()
        for chunk in http_ua.request_object.headers["cookie"].split(';')
    ] == ['XYZ', 'TS01293935'])
Ejemplo n.º 9
0
def test_cookies3():
    """Test to make sure we retain cookies when user specified
       values are provided"""
    http_ua = http.HttpUA()
    x = ruleset.Input(dest_addr='example.com', headers={'Host': 'example.com'})
    http_ua.send_request(x)
    x = ruleset.Input(dest_addr='example.com',
                      headers={
                          'Host': 'example.com',
                          'cookie': 'TS01247332=012f3506234413e6c5cb14e8c0d'
                                    '5bf890fdd02481614b01cd6cd30911c6733e3e'
                                    '6f79e72aa; XYZ=123'})
    http_ua.send_request(x)
    assert(set([chunk.split('=')[0].strip() for chunk in
                http_ua.request_object.headers['cookie'].split(';')]) ==
           set(['XYZ', 'TS01247332']))