Skip to content

Commit aa6686e

Browse files
committed
update20181125
修复计算总数错误,性能优化
1 parent e7b719b commit aa6686e

File tree

4 files changed

+63
-18
lines changed

4 files changed

+63
-18
lines changed

SNETCracker/Main.Designer.cs

Lines changed: 24 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SNETCracker/Main.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public partial class Main : Form
4444
public string[] servicesName = { };
4545
public string[] servicesPort = { };
4646

47+
public long scanPortsSumCount = 0;
48+
4749
private Dictionary<string, ServiceModel> services = new Dictionary<string, ServiceModel>();//服务列表
4850
private Dictionary<string, HashSet<string>> dics = new Dictionary<string, HashSet<string>>();//字典列表
4951
public ConcurrentBag<string> list_cracker = new ConcurrentBag<string>();
@@ -92,7 +94,7 @@ public void LogAppend(Color color, string text)
9294
}
9395
this.txt_log.SelectionColor = color;
9496
this.txt_log.HideSelection = false;
95-
this.txt_log.AppendText(text+"\r\n");
97+
this.txt_log.AppendText(text+Environment.NewLine);
9698
}
9799
/// <summary>
98100
/// 显示错误日志
@@ -161,7 +163,7 @@ private void updateStatus() {
161163
}
162164
this.stxt_crackerSuccessCount.Text = successCount + "";
163165
this.stxt_useTime.Text = runTime + "";
164-
166+
this.tssl_notScanPortsSumCount.Text = this.scanPortsSumCount+"";
165167
}
166168
catch (Exception e) {
167169
LogWarning(e.Message);
@@ -221,6 +223,7 @@ public void ScanPort(string ip,string serviceName,int port) {
221223
tc.Close();
222224

223225
}
226+
Interlocked.Decrement(ref scanPortsSumCount);
224227
}
225228

226229
private void crackerService(string crakerstring,string username,string password)
@@ -412,16 +415,21 @@ private void cracker()
412415
stp =new SmartThreadPool();
413416
stp.MaxThreads = maxThread;
414417
creackerSumCount = 0;
415-
//计算总数
418+
scanPortsSumCount = 0;
419+
420+
421+
//计算端口扫描总数
416422
if (isScanport)
417423
{
418424
foreach (string serviceName in this.services_list.CheckedItems)
419425
{
420426
string[] ports = this.services[serviceName].Port.Split(',');
421-
creackerSumCount += this.list_target.Count * ports.Length;
427+
scanPortsSumCount += this.list_target.Count * ports.Length;
422428
}
423429
}
424-
430+
//更新状态
431+
this.Invoke(new update(updateStatus));
432+
425433
foreach (string serviceName in this.services_list.CheckedItems) {
426434
string[] ports = this.services[serviceName].Port.Split(',');
427435
foreach (string sport in ports)
@@ -455,7 +463,7 @@ private void cracker()
455463
{
456464
foreach (string serviceName in this.services_list.CheckedItems)
457465
{
458-
creackerSumCount += list_cracker.Count*this.services_list.CheckedItems.Count*this.services[serviceName].ListUserName.Count*this.services[serviceName].ListPassword.Count;
466+
creackerSumCount += list_cracker.Count*this.services[serviceName].ListUserName.Count*this.services[serviceName].ListPassword.Count;
459467
}
460468
}
461469
else
@@ -756,6 +764,7 @@ private Server addRDPClient(String ip,int port,String username,String password,i
756764
catch (Exception e)
757765
{
758766
FileTool.log(ip + ":" + port + "-RDP操作异常-" + e.Message);
767+
LogWarning(ip + ":" + port + "-RDP操作异常-" + e.Message);
759768
server.isDisConnected = true;
760769
server.isEndMRE.Set();
761770
}
@@ -767,14 +776,16 @@ private Server addRDPClient(String ip,int port,String username,String password,i
767776
private void ClearRDP(RdpClient rdp){
768777
try
769778
{
770-
this.rdp_panle.Controls.Remove(rdp);
771779
if (rdp.IsDisposed == false)
772780
{
773781
rdp.Dispose();
774782
}
783+
this.rdp_panle.Controls.Remove(rdp);
784+
775785
}
776786
catch (Exception e) {
777787
FileTool.log("RDP资源清理异常-" + e.Message);
788+
LogWarning("RDP资源清理异常-" + e.Message);
778789
}
779790
}
780791

@@ -1073,7 +1084,7 @@ public static String getSid()
10731084
return sid;
10741085
}
10751086

1076-
private static int version = 20181113;
1087+
private static int version = 20181125;
10771088
public static string versionURL = "http://www.shack2.org/soft/getNewVersion?ENNAME=SNETCracker&NO="+ Uri.EscapeDataString(getSid())+ "&VERSION="+ version;
10781089
private void tsmi_help_version_Click(object sender, EventArgs e)
10791090
{

SNETCracker/Model/CrackMySQL.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public CrackMySQL()
1717
public override Server creack(String ip, int port, String username, String password, int timeOut)
1818
{
1919
MySqlConnection conn = new MySqlConnection();
20-
20+
MySqlConnectionStringBuilder ms = new MySqlConnectionStringBuilder();
2121
Server server = new Server();
2222

2323
try
@@ -27,7 +27,7 @@ public override Server creack(String ip, int port, String username, String passw
2727
password = "";
2828
}
2929
conn.ConnectionString = "server=" + ip + ";user id=" + username + ";password=" + password + ";pooling=false;ConnectionTimeout=" + timeOut;
30-
30+
3131
conn.Open();
3232

3333
server.isSuccess = ConnectionState.Open.Equals(conn.State);

SNETCracker/rdp/RdpClient.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public RdpClient(Server cserver)
2424
this.OnLogonError += Rdp_OnLogonError;
2525
this.OnFatalError += Rdp_OnFatalError;
2626
this.OnDisconnected += Rdp_OnDisconnected;
27+
this.OnAuthenticationWarningDisplayed += Rdp_OnAuthenticationWarningDisplayed;
28+
this.OnAuthenticationWarningDismissed += Rdp_OnAuthenticationWarningDismissed;
29+
2730

2831
}
2932

@@ -44,11 +47,11 @@ public void Connect(string ip,int port,string user,string pass)
4447
try
4548
{
4649
this.timeOutLog.Start();
47-
this.AdvancedSettings4.Compress = 1;
50+
this.AdvancedSettings.Compress = 1;
4851
this.Height =1;
4952
this.Width = 1;
5053
this.Password = pass;
51-
this.ColorDepth =8 ;
54+
this.ColorDepth =4 ;
5255
this.Server = ip;
5356
this.UserName = user;
5457
this.AdvancedSettings4.EnableMouse = 0;
@@ -57,6 +60,7 @@ public void Connect(string ip,int port,string user,string pass)
5760
IMsTscNonScriptable secured = (IMsTscNonScriptable)this.GetOcx();
5861
secured.ClearTextPassword = pass;
5962
this.Connect();
63+
6064
}
6165
catch (Exception e)
6266
{
@@ -91,5 +95,17 @@ private void Rdp_OnConnected(object sender, EventArgs e)
9195
this.server.isConnected = true;
9296

9397
}
98+
99+
private void Rdp_OnAuthenticationWarningDismissed(object sender, EventArgs e)
100+
{
101+
Finished();
102+
103+
}
104+
105+
private void Rdp_OnAuthenticationWarningDisplayed(object sender, EventArgs e)
106+
{
107+
Finished();
108+
109+
}
94110
}
95111
}

0 commit comments

Comments
 (0)