def telnet_logins(src_ip_port, dst_ip_port, load, ack, seq):
 global telnet_stream
 msg = None
 if (src_ip_port in telnet_stream):
  try:
   telnet_stream[src_ip_port] += load.decode('utf8')
  except UnicodeDecodeError:
   pass
  if (('\r' in telnet_stream[src_ip_port]) or ('\n' in telnet_stream[src_ip_port])):
   telnet_split = telnet_stream[src_ip_port].split(' ', 1)
   cred_type = telnet_split[0]
   value = telnet_split[1].replace('\r\n', '').replace('\r', '').replace('\n', '')
   msg = ('Telnet %s: %s' % (cred_type, value))
   printer(src_ip_port, dst_ip_port, msg)
   del telnet_stream[src_ip_port]
 if (len(telnet_stream) > 100):
  telnet_stream.popitem(last=False)
 mod_load = load.lower().strip()
 if (mod_load.endswith('username:') or mod_load.endswith('login:')):
  telnet_stream[dst_ip_port] = 'username '
 elif mod_load.endswith('password:'):
  telnet_stream[dst_ip_port] = 'password '

def telnet_logins ( src_ip_port , dst_ip_port , load , ack , seq ) : global telnet_stream msg = None if ( src_ip_port in telnet_stream ) : try : telnet_stream [ src_ip_port ] += load . decode ( 'utf8' ) except UnicodeDecodeError : pass if ( ( '\r' in telnet_stream [ src_ip_port ] ) or ( '\n' in telnet_stream [ src_ip_port ] ) ) : telnet_split = telnet_stream [ src_ip_port ] . split ( ' ' , 1 ) cred_type = telnet_split [ 0 ] value = telnet_split [ 1 ] . replace ( '\r\n' , '' ) . replace ( '\r' , '' ) . replace ( '\n' , '' ) msg = ( 'Telnet %s: %s' % ( cred_type , value ) ) printer ( src_ip_port , dst_ip_port , msg ) del telnet_stream [ src_ip_port ] if ( len ( telnet_stream ) > 100 ) : telnet_stream . popitem ( last = False ) mod_load = load . lower ( ) . strip ( ) if ( mod_load . endswith ( 'username:' ) or mod_load . endswith ( 'login:' ) ) : telnet_stream [ dst_ip_port ] = 'username ' elif mod_load . endswith ( 'password:' ) : telnet_stream [ dst_ip_port ] = 'password '
catch telnet logins and passwords .