| @@ -40,19 +40,33 @@ class Redes_wifi extends Command | |||||
| foreach ($profiles as $profile) { | foreach ($profiles as $profile) { | ||||
| $linea = "[{$profile}] "; | $linea = "[{$profile}] "; | ||||
| if (!$this->option('list')) | if (!$this->option('list')) | ||||
| $linea .= $this->getPassword($profile); | |||||
| $linea .= $this->getPasswordRegex($profile); | |||||
| $this->line($linea); | $this->line($linea); | ||||
| } | } | ||||
| } | } | ||||
| public function getProfilesRegex() | public function getProfilesRegex() | ||||
| { | { | ||||
| $result = Process::run('netsh wlan show profile'); | |||||
| $salidaprofiles = $result->output(); | |||||
| //$salidaprofiles = file_get_contents('profiles.txt'); | |||||
| /*$result = Process::run('netsh wlan show profile'); | |||||
| $salidaprofiles = $result->output();*/ | |||||
| $salidaprofiles = file_get_contents('profiles.txt'); | |||||
| preg_match_all("/: \s*(.*)/", $salidaprofiles, $profiles); | preg_match_all("/: \s*(.*)/", $salidaprofiles, $profiles); | ||||
| return $profiles[1]; | return $profiles[1]; | ||||
| } | } | ||||
| public function getPasswordRegex($profile) | |||||
| { | |||||
| $result = Process::run("netsh wlan show profile \"{$profile}\" key=clear"); | |||||
| $salidapassword = $result->output(); | |||||
| if (str_contains($salidapassword, "No hay ninguna interfaz inalámbrica en el sistema.")) { //Esto evita que ejecute regex si hay fallo | |||||
| $this->error("Fallo al ejecutar comando de password"); | |||||
| die(); | |||||
| } | |||||
| //$salidapassword = file_get_contents('prueba.txt'); | |||||
| preg_match_all("/Contenido de la clave\s*:\s*(\S+)/", $salidapassword, $password); | |||||
| return $password[1][0]; | |||||
| } | |||||
| public function getProfiles() | public function getProfiles() | ||||
| { | { | ||||
| $result = Process::run('netsh wlan show profile'); | $result = Process::run('netsh wlan show profile'); | ||||