Se colocaran ejercios para practicar de codigobit
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

87 строки
2.6 KiB

  1. <?php
  2. namespace App\Commands;
  3. use Illuminate\Console\Scheduling\Schedule;
  4. use LaravelZero\Framework\Commands\Command;
  5. use Illuminate\Support\Facades\Process;
  6. class Redes_wifi extends Command
  7. {
  8. /**
  9. * The signature of the command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'wifi {essid?} {--list}';
  14. /**
  15. * The description of the command.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'Muestra las contraseñas guardadas de wifi';
  20. /**
  21. * Execute the console command.
  22. *
  23. * @return mixed
  24. */
  25. public function handle()
  26. {
  27. $essid = $this->argument('essid');
  28. $profiles = $this->getProfiles();
  29. if (isset($essid) && (!$this->option('list'))) {
  30. $this->line("[{$essid}] ".$this->getPassword($essid));
  31. return 0;
  32. }
  33. foreach ($profiles as $profile) {
  34. $linea = "[{$profile}] ";
  35. if (!$this->option('list'))
  36. $linea .= $this->getPassword($profile);
  37. $this->line($linea);
  38. }
  39. }
  40. public function getProfiles()
  41. {
  42. $result = Process::run('netsh wlan show profile');
  43. $salidaprofiles = $result->output();
  44. //$salidaprofiles = file_get_contents('profiles.txt');
  45. $parseprofiles = explode("-------------------", $salidaprofiles);
  46. $parseprofiles = end($parseprofiles);
  47. $parseprofiles = explode("\n", trim($parseprofiles, "\n\r"));
  48. $profiles = [];
  49. foreach ($parseprofiles as $profile) {
  50. $profiles[] = trim(str_replace(' Perfil de todos los usuarios : ', '', $profile));
  51. }
  52. return $profiles;
  53. }
  54. public function getPassword($profile)
  55. {
  56. $result = Process::run("netsh wlan show profile \"{$profile}\" key=clear");
  57. $salidapassword = $result->output();
  58. //$salidapassword = file_get_contents('prueba.txt');
  59. $parsepassword = explode('--------------------------', $salidapassword);
  60. $parsepassword = end($parsepassword);
  61. $parsepassword = explode("Configuraci", trim($parsepassword, "\n"));
  62. $parsepassword = current($parsepassword);
  63. $parsepassword = trim($parsepassword);
  64. $parsepassword = explode("\n", $parsepassword);
  65. $parsepassword = str_replace(' Contenido de la clave : ', '', end($parsepassword));
  66. return $parsepassword;
  67. }
  68. /**
  69. * Define the command's schedule.
  70. *
  71. * @param \Illuminate\Console\Scheduling\Schedule $schedule
  72. * @return void
  73. */
  74. public function schedule(Schedule $schedule): void
  75. {
  76. // $schedule->command(static::class)->everyMinute();
  77. }
  78. }