Created
November 19, 2021 23:55
-
-
Save caiorn/a86dce07cc3474cc63c4125681f63d52 to your computer and use it in GitHub Desktop.
see wifi windows (sww2i) code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Diagnostics; | |
| using System.Text; | |
| using System.Text.RegularExpressions; | |
| using System.Windows.Forms; | |
| /* | |
| --Para mostrar--- | |
| netsh wlan show profiles | |
| netsh wlan show profiles "nome do wifi" key=clear | |
| --Para exportar todos profile de Wifi--- | |
| netsh wlan export profile folder=%userprofile%\desktop\ key=clear | |
| */ | |
| namespace sww2i | |
| { | |
| public partial class Form1 : Form | |
| { | |
| public Form1() | |
| { | |
| InitializeComponent(); | |
| } | |
| private void Form1_Load(object sender, EventArgs e) | |
| { | |
| ColumnHeader columnHeader1 = new ColumnHeader(); | |
| ColumnHeader columnHeader2 = new ColumnHeader(); | |
| columnHeader1.Text = "SID"; | |
| columnHeader2.Text = "PASS"; | |
| int largura = listView1.Width / 2 -2;//-2 é as bordas das linhas | |
| columnHeader1.Width = largura; | |
| columnHeader2.Width = largura; | |
| listView1.Columns.Add(columnHeader1); | |
| listView1.Columns.Add(columnHeader2); | |
| listView1.View = View.Details; | |
| //executa comando no cmd | |
| string output = RunCommand("netsh wlan show profiles", true); | |
| string pattern = @"(?<=:\s).*\b"; | |
| Match m = Regex.Match(output, pattern, RegexOptions.IgnoreCase); | |
| while (m.Success) { | |
| string nameSid = m.Value; | |
| string output2 = RunCommand("netsh wlan show profiles \""+nameSid+"\" key=clear", true); | |
| string pattern_pt = @"(?<=(Conteúdo da Chave\s*:\s)).*\b"; | |
| string pattern_en = @"(?<=(Key Content\s*:\s)).*\b"; | |
| Match m2 = Regex.Match(output2, pattern_pt); | |
| if (!m2.Success) | |
| { | |
| m2 = Regex.Match(output2, pattern_en); | |
| } | |
| if (m2.Success) { | |
| string password = m2.Value; | |
| string[] items = { nameSid, password }; | |
| ListViewItem lvi = new ListViewItem(items); | |
| listView1.Items.Add(lvi); | |
| } | |
| m = m.NextMatch(); | |
| } | |
| } | |
| public static string RunCommand(string arguments, bool readOutput) | |
| { | |
| var output = string.Empty; | |
| try | |
| { | |
| var startInfo = new ProcessStartInfo | |
| { | |
| StandardOutputEncoding = Encoding.GetEncoding(850), | |
| Verb = "runas", | |
| FileName = "cmd.exe", | |
| Arguments = "/C " + arguments, | |
| WindowStyle = ProcessWindowStyle.Hidden, | |
| UseShellExecute = false, | |
| CreateNoWindow = true, | |
| RedirectStandardOutput = true, | |
| RedirectStandardError = false | |
| }; | |
| var proc = Process.Start(startInfo); | |
| if (readOutput) | |
| { | |
| output = proc.StandardOutput.ReadToEnd(); | |
| } | |
| proc.StandardInput.Flush(); | |
| proc.StandardInput.Close(); | |
| proc.WaitForExit(); | |
| return output; | |
| } | |
| catch (Exception) | |
| { | |
| return output; | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace sww2i | |
| { | |
| partial class Form1 | |
| { | |
| /// <summary> | |
| /// Variável de designer necessária. | |
| /// </summary> | |
| private System.ComponentModel.IContainer components = null; | |
| /// <summary> | |
| /// Limpar os recursos que estão sendo usados. | |
| /// </summary> | |
| /// <param name="disposing">true se for necessário descartar os recursos gerenciados; caso contrário, false.</param> | |
| protected override void Dispose(bool disposing) | |
| { | |
| if (disposing && (components != null)) | |
| { | |
| components.Dispose(); | |
| } | |
| base.Dispose(disposing); | |
| } | |
| #region Código gerado pelo Windows Form Designer | |
| /// <summary> | |
| /// Método necessário para suporte ao Designer - não modifique | |
| /// o conteúdo deste método com o editor de código. | |
| /// </summary> | |
| private void InitializeComponent() | |
| { | |
| System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); | |
| this.listView1 = new System.Windows.Forms.ListView(); | |
| this.SuspendLayout(); | |
| // | |
| // listView1 | |
| // | |
| this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | |
| | System.Windows.Forms.AnchorStyles.Left) | |
| | System.Windows.Forms.AnchorStyles.Right))); | |
| this.listView1.HideSelection = false; | |
| this.listView1.Location = new System.Drawing.Point(12, 12); | |
| this.listView1.MultiSelect = false; | |
| this.listView1.Name = "listView1"; | |
| this.listView1.Size = new System.Drawing.Size(272, 139); | |
| this.listView1.TabIndex = 0; | |
| this.listView1.UseCompatibleStateImageBehavior = false; | |
| this.listView1.View = System.Windows.Forms.View.Details; | |
| // | |
| // Form1 | |
| // | |
| this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); | |
| this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | |
| this.ClientSize = new System.Drawing.Size(296, 163); | |
| this.Controls.Add(this.listView1); | |
| this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); | |
| this.MaximizeBox = false; | |
| this.Name = "Form1"; | |
| this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; | |
| this.Text = "See Wifi Windows by:Caio S."; | |
| this.Load += new System.EventHandler(this.Form1_Load); | |
| this.ResumeLayout(false); | |
| } | |
| #endregion | |
| private System.Windows.Forms.ListView listView1; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment