diff --git a/SNETCracker/Main.Designer.cs b/SNETCracker/Main.Designer.cs index 316c9a4..1b8e83c 100644 --- a/SNETCracker/Main.Designer.cs +++ b/SNETCracker/Main.Designer.cs @@ -540,7 +540,7 @@ private void InitializeComponent() // rdp_panle // this.rdp_panle.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.rdp_panle.Location = new System.Drawing.Point(110, 14); + this.rdp_panle.Location = new System.Drawing.Point(208, 12); this.rdp_panle.Name = "rdp_panle"; this.rdp_panle.Size = new System.Drawing.Size(1, 1); this.rdp_panle.TabIndex = 12; @@ -764,7 +764,6 @@ private void InitializeComponent() this.groupBox3.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.groupBox3.Controls.Add(this.rdp_panle); this.groupBox3.Controls.Add(this.splitContainer1); this.groupBox3.Location = new System.Drawing.Point(8, 25); this.groupBox3.Name = "groupBox3"; @@ -808,6 +807,7 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(875, 677); + this.Controls.Add(this.rdp_panle); this.Controls.Add(this.groupBox3); this.Controls.Add(this.bt_status); this.Controls.Add(this.groupBox2); @@ -815,7 +815,7 @@ private void InitializeComponent() this.MainMenuStrip = this.menuStrip1; this.Name = "Main"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "超级弱口令检查工具 V1.0 测试版 Beta24 by shack2"; + this.Text = "超级弱口令检查工具 V1.0 测试版 Beta25 by shack2"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing); this.Shown += new System.EventHandler(this.Main_Shown); this.groupBox1.ResumeLayout(false); diff --git a/SNETCracker/Main.cs b/SNETCracker/Main.cs index 36d2c3a..bc3939a 100644 --- a/SNETCracker/Main.cs +++ b/SNETCracker/Main.cs @@ -32,9 +32,6 @@ public partial class Main : Form private int retryCount = 0; private int maxThread = 50; private int timeOut = 5; - private string dic_username_path = ""; - private string dic_password_path = ""; - private string dic_target_path = ""; private Boolean crackerOneCount = true;//只检查一个账户 public int successCount = 0; @@ -89,7 +86,7 @@ public Main() /// 显示文本 public void LogAppend(Color color, string text) { - if (this.txt_log.Text.Length > 100000) { + if (this.txt_log.Text.Length > 10000) { this.txt_log.Clear(); } this.txt_log.SelectionColor = color; @@ -449,7 +446,7 @@ private void cracker() } else { stp.QueueWorkItem(ScanPort, ip, serviceName, port); - stp.WaitFor(1000); + stp.WaitFor(1); } } } @@ -516,7 +513,7 @@ private void cracker() if (cracker.EndsWith(serviceName)) { stp.QueueWorkItem(crackerService, cracker, username, pass); - stp.WaitFor(1000); + stp.WaitFor(1); } } } @@ -537,8 +534,8 @@ private void cracker() public void stopCraker() { if (stp != null&& !stp.IsShuttingdown&&this.crackerThread!=null) { LogWarning("等待线程结束..."); - this.crackerThread.Abort(); stp.Shutdown(); + this.crackerThread.Abort(); while (stp.InUseThreads>0) { Thread.Sleep(50); } @@ -553,7 +550,7 @@ public void stopCraker() { } private Boolean initDic() { - if ("".Equals(this.txt_target.Text) && "".Equals(this.dic_target_path)) + if ("".Equals(this.txt_target.Text)) { MessageBox.Show("请设置需要检查的目标的IP地址或域名!"); return false; @@ -649,25 +646,30 @@ private Boolean initDic() { //加载自定义字典字典 if (notAutoSelectDic) { - if (!"".Equals(this.dic_username_path)) + if (this.txt_username.Text.EndsWith(".txt")) { - this.list_username = FileTool.readFileToList(this.dic_username_path); + this.list_username = FileTool.readFileToList(this.txt_username.Text); } - - if (!"".Equals(this.dic_password_path)) - { - this.list_password = FileTool.readFileToList(this.dic_password_path); + else { + if (this.txt_username.Text.Length > 0) + { + this.list_username.Clear(); + this.list_username.Add(this.txt_username.Text); + } } - if (this.txt_username.Text.Length > 0) + + if (this.txt_password.Text.EndsWith(".txt")) { - this.list_username.Clear(); - this.list_username.Add(this.txt_username.Text); + this.list_password = FileTool.readFileToList(this.txt_password.Text); } - if (this.txt_password.Text.Length > 0) - { - this.list_password.Clear(); - this.list_password.Add(this.txt_password.Text); + else { + if (this.txt_password.Text.Length > 0) + { + this.list_password.Clear(); + this.list_password.Add(this.txt_password.Text); + } } + if (this.list_username.Count <= 0) { MessageBox.Show("请设置需要检查的用户名!"); @@ -675,7 +677,7 @@ private Boolean initDic() { } else if (this.list_password.Count <= 0) { - MessageBox.Show("请设置检查的密码字典!"); + MessageBox.Show("请设置检查的密码!"); return false; } } @@ -747,8 +749,8 @@ public void rdpResult(ResponseType type, Server rdp) { } } + delegate Server addRDPdelegate(String ip, int port,String username, String password,int timeout); - private Server addRDPClient(String ip,int port,String username,String password,int timeout) { Server server = new Server(); RdpClient rdp = null; @@ -761,6 +763,7 @@ private Server addRDPClient(String ip,int port,String username,String password,i server.username = username; server.password = password; rdp = new RdpClient(server); + rdp.Location = new Point(this.rdp_panle.Location.X+new Random().Next(50), this.rdp_panle.Location.Y+new Random().Next(100)); server.client = rdp; this.rdp_panle.Controls.Add(rdp); rdp.OnResponse += rdpResult; @@ -781,12 +784,8 @@ private Server addRDPClient(String ip,int port,String username,String password,i private void ClearRDP(RdpClient rdp){ try { - if (rdp.IsDisposed == false) - { - rdp.Dispose(); - } + rdp.Dispose(); this.rdp_panle.Controls.Remove(rdp); - } catch (Exception e) { FileTool.log("RDP资源清理异常-" + e.Message); @@ -800,21 +799,25 @@ private Server creackRDP(String ip, int port,String username, String password, i try { server = (Server)this.rdp_panle.Invoke(new addRDPdelegate(addRDPClient), ip, port, username, password, timeout); server.isEndMRE.WaitOne(); - server.client.Disconnect(); - this.rdp_panle.Invoke(new deleteClearRDP(ClearRDP), server.client); + this.rdp_panle.BeginInvoke(new deleteClearRDP(ClearRDP), server.client); }catch(Exception e){ FileTool.log("creackRDP错误:" + e.Message); } return server; } - + + + + private void btn_cracker_Click(object sender, EventArgs e) { this.btn_cracker.Enabled = false; this.list_success_username.Clear(); this.services_list.Enabled = false; + crackerThread = new Thread(cracker); - crackerThread.Start(); + crackerThread.Start(); + } private void initStatusCount() @@ -870,7 +873,7 @@ private void btn_importUername_Click(object sender, EventArgs e) if (ofd.ShowDialog() == DialogResult.OK) { if (!string.IsNullOrEmpty(ofd.FileName)) { - this.dic_username_path = ofd.FileName; + this.txt_username.Text = ofd.FileName; LogInfo("导入用户名成功!"); } } @@ -884,7 +887,7 @@ private void btn_importPassword_Click(object sender, EventArgs e) if (!string.IsNullOrEmpty(ofd.FileName)) { - this.dic_password_path = ofd.FileName; + this.txt_password.Text = ofd.FileName; LogInfo("导入密码字典成功!"); } } @@ -1101,7 +1104,7 @@ public static String getSid() return sid; } - private static int version = 20190323; + private static int version = 20190324; public static string versionURL = "http://www.shack2.org/soft/getNewVersion?ENNAME=SNETCracker&NO="+ Uri.EscapeDataString(getSid())+ "&VERSION="+ version; private void tsmi_help_version_Click(object sender, EventArgs e) { diff --git a/SNETCracker/Model/Server.cs b/SNETCracker/Model/Server.cs index 41a33b8..c7c92db 100644 --- a/SNETCracker/Model/Server.cs +++ b/SNETCracker/Model/Server.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading; +using System.Windows.Forms; namespace SNETCracker.Model { @@ -22,5 +23,7 @@ public class Server public Boolean isConnected = false; public RdpClient client = null; public long userTime = 0; + public TabPage tp = null; + public TabControl tc = null; } } diff --git a/SNETCracker/SmartThread/WorkItemsQueue.cs b/SNETCracker/SmartThread/WorkItemsQueue.cs index e0bc916..69e818e 100644 --- a/SNETCracker/SmartThread/WorkItemsQueue.cs +++ b/SNETCracker/SmartThread/WorkItemsQueue.cs @@ -633,7 +633,7 @@ private void ValidateNotDisposed() { if(_isDisposed) { - throw new ObjectDisposedException(GetType().ToString(), "The SmartThreadPool has been shutdown"); + //throw new ObjectDisposedException(GetType().ToString(), "The SmartThreadPool has been shutdown"); } } diff --git a/SNETCracker/rdp/RdpClient.cs b/SNETCracker/rdp/RdpClient.cs index 5c980aa..172196b 100644 --- a/SNETCracker/rdp/RdpClient.cs +++ b/SNETCracker/rdp/RdpClient.cs @@ -10,6 +10,7 @@ namespace MyRDP public class RdpClient : AxMsRdpClient7NotSafeForScripting { private Server server = null; + public String name = ""; public delegate void OnResponseDelegate(ResponseType type, Server server); public event OnResponseDelegate OnResponse; public System.Timers.Timer timeOutLog = new System.Timers.Timer(); @@ -36,7 +37,19 @@ public RdpClient(Server cserver) private void Finished() { + try + { + if (this.Connected != 0) + { + this.Disconnect(); + } + } + catch (Exception ce) + { + FileTool.log("Finished:" + ce.Message); + } OnResponse(ResponseType.Finished, server); + } private void TimeOut(object sender, ElapsedEventArgs e) { @@ -44,6 +57,9 @@ private void TimeOut(object sender, ElapsedEventArgs e) Finished(); } + + + public delegate void deConnect(string ip, int port, string user, string pass); public void Connect(string ip, int port, string user, string pass) { @@ -54,21 +70,17 @@ public void Connect(string ip, int port, string user, string pass) this.timeOutLog.Start(); this.Server = ip; this.ColorDepth = 1; - this.AdvancedSettings.Compress = 1; this.Password = pass; - this.ColorDepth = 1; - this.Server = ip; this.UserName = user; - this.AdvancedSettings7.Compress = 1; - this.AdvancedSettings7.EnableMouse = 0; - this.AdvancedSettings7.EnableWindowsKey = 0; this.AdvancedSettings7.RDPPort = port; this.AdvancedSettings7.ClearTextPassword = pass; - this.AdvancedSettings7.EncryptionEnabled = 0; this.AdvancedSettings7.EnableCredSspSupport = true; - this.AdvancedSettings7.ConnectToAdministerServer=true; + this.AdvancedSettings7.ConnectToAdministerServer = true; + this.AdvancedSettings7.EnableMouse = 0; + this.AdvancedSettings7.EnableWindowsKey = 0; + this.AdvancedSettings7.EncryptionEnabled = 0; this.AdvancedSettings7.AuthenticationLevel = 0; this.AdvancedSettings7.RedirectClipboard = false; this.AdvancedSettings7.overallConnectionTimeout = server.timeout; @@ -84,8 +96,9 @@ public void Connect(string ip, int port, string user, string pass) sc.WarnAboutSendingCredentials = false; sc.WarnAboutClipboardRedirection = false; sc.ShowRedirectionWarningDialog = false; + this.Connect(); - + } catch (Exception e) { @@ -108,13 +121,16 @@ private void Rdp_OnLoginComplete(object sender, EventArgs e) { this.server.isSuccess = true; this.server.banner = this.Version; + Finished(); } private void Rdp_OnLoginError(object sender, IMsTscAxEvents_OnLogonErrorEvent e) { this.server.isSuccess = false; + Finished(); + } private void Rdp_OnWaring(object sender, IMsTscAxEvents_OnWarningEvent e)