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)

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 )
parse out the username/password from an http request .