(pkt)
return (usr, pswd)
Parse out the username/password from an HTTP request.
        This will also parse out any basic authorization requests.
Parse out the username/password from an HTTP request.
        This will also parse out any basic authorization requests.
Parse out the username / password from an HTTP request . This will also parse out any basic authorization requests .
def parse_http(pkt):
    """ Parse out the username/password from an HTTP request.
        This will also parse out any basic authorization requests.
    """
    payload = pkt.getlayer(Raw).load
    usr, pswd = None, None
    if 'username' in payload or 'password' in payload:
        usr = re.search('username=(.*?)(&|$| )', payload)
        pswd = re.search('password=(.*?)(&|$| )', payload)
        if usr is not None:
            usr = usr.groups(0)[0]
        if pswd is not None:
            pswd = pswd.groups(0)[0]
    elif 'Authorization:' in payload:
        pw = re.search('Authorization: Basic (.*)', payload)
        if pw.groups(0) is not None:
            usr = b64decode(pw.groups(0)[0])

    return (usr, pswd)
def parse_http ( pkt ) : payload = pkt . getlayer ( Raw ) . load usr , pswd = None , None if 'username' in payload or 'password' in payload : usr = re . search ( 'username=(.*?)(&|$| )' , payload ) pswd = re . search ( 'password=(.*?)(&|$| )' , payload ) if usr is not None : usr = usr . groups ( 0 ) [ 0 ] if pswd is not None : pswd = pswd . groups ( 0 ) [ 0 ] elif 'Authorization:' in payload : pw = re . search ( 'Authorization: Basic (.*)' , payload ) if pw . groups ( 0 ) is not None : usr = b64decode ( pw . groups ( 0 ) [ 0 ] ) return ( usr , pswd )