def os_detection_exec(exec_method):
 try:
  linux1 = exec_method('echo -n w3af')
  linux2 = exec_method('head -n 1 /etc/passwd')
 except BaseFrameworkException:
  pass
 else:
  if (('w3af' in linux1) and (linux2.count(':') > 3)):
   om.out.debug('Identified remote OS as Linux, returning "linux".')
   return 'linux'
 try:
  win1 = exec_method('type %SYSTEMROOT%\\win.ini')
  win2 = exec_method('echo /?')
 except BaseFrameworkException:
  pass
 else:
  if (('[fonts]' in win1) and ('ECHO' in win2)):
   om.out.debug('Identified remote OS as Windows, returning "windows".')
   return 'windows'
 raise BaseFrameworkException('Failed to get/identify the remote OS.')

def os_detection_exec ( exec_method ) : try : linux1 = exec_method ( 'echo -n w3af' ) linux2 = exec_method ( 'head -n 1 /etc/passwd' ) except BaseFrameworkException : pass else : if ( ( 'w3af' in linux1 ) and ( linux2 . count ( ':' ) > 3 ) ) : om . out . debug ( 'Identified remote OS as Linux, returning "linux".' ) return 'linux' try : win1 = exec_method ( 'type %SYSTEMROOT%\\win.ini' ) win2 = exec_method ( 'echo /?' ) except BaseFrameworkException : pass else : if ( ( '[fonts]' in win1 ) and ( 'ECHO' in win2 ) ) : om . out . debug ( 'Identified remote OS as Windows, returning "windows".' ) return 'windows' raise BaseFrameworkException ( 'Failed to get/identify the remote OS.' )
uses the exec_method to run remote commands and determine whats the remote os is and returns a string with windows or linux or raises a baseframeworkexception if unknown .