Skip to content

Commit 058ea49

Browse files
committed
Updated Message due localhost bug
1 parent 53156cf commit 058ea49

File tree

9 files changed

+75
-38
lines changed

9 files changed

+75
-38
lines changed

Form1.Designer.cs

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

Form1.cs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,40 @@
44
using System.Data;
55
using System.Drawing;
66
using System.Linq;
7+
using System.Net;
8+
using System.Net.Sockets;
79
using System.Text;
810
using System.Threading;
911
using System.Threading.Tasks;
1012
using System.Windows.Forms;
1113

12-
namespace MS17010Test
13-
{
14-
public partial class Form1 : Form
15-
{
16-
public Form1()
17-
{
14+
namespace MS17010Test {
15+
public partial class Form1 : Form {
16+
public Form1() {
1817
InitializeComponent();
1918
}
19+
private IPAddress LocalIPAddress() {
20+
if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) {
21+
return null;
22+
}
23+
24+
IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
25+
26+
return host
27+
.AddressList
28+
.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork);
29+
}
2030

2131
private void button1_Click(object sender, EventArgs e) {
2232
button1.Enabled = false;
2333
button2.Enabled = false;
2434
progressBar1.Visible = true;
2535
resultLabel.Text = strings.pleaseWait;
2636
resultLabel.ForeColor = Color.AliceBlue;
37+
testIpBox.Text = LocalIPAddress().ToString();
2738
ThreadPool.QueueUserWorkItem((t) => {
2839
try {
29-
var res = Tester.TestIP("127.0.0.1");
40+
var res = Tester.TestIP(LocalIPAddress().ToString());
3041
UpdateWithResults(res);
3142
} catch (Exception ex) {
3243
ResultError(ex);
@@ -39,16 +50,21 @@ private void UpdateWithResults(TestResult res) {
3950
var self = new Action<TestResult>(UpdateWithResults);
4051
BeginInvoke(self, res);
4152
} else {
42-
var msg = string.Format(strings.resultString, res.OSName, res.OSBuild, res.Workgroup, res.IsVulnerable ? strings.yes : strings.no);
53+
var msg = string.Format(strings.resultString, res.OSName, res.OSBuild, res.Workgroup, res.IsVulnerable ? strings.yes : strings.no, res.error);
4354
resultLabel.Text = msg;
44-
if (res.IsVulnerable) {
55+
if (res.hadError) {
56+
resultLabel.ForeColor = Color.PaleVioletRed;
57+
} else if (res.IsVulnerable) {
4558
resultLabel.ForeColor = Color.Red;
4659
} else {
4760
resultLabel.ForeColor = Color.Green;
4861
}
4962
button1.Enabled = true;
5063
button2.Enabled = true;
5164
progressBar1.Visible = false;
65+
if (res.hadError) {
66+
MessageBox.Show(strings.executionError);
67+
}
5268
}
5369
}
5470

@@ -78,7 +94,7 @@ private void button2_Click(object sender, EventArgs e) {
7894
} catch (Exception ex) {
7995
ResultError(ex);
8096
}
81-
});
97+
});
8298
}
8399
}
84100
}

Form1.resx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@
121121
<value>That application is for checking if your computer is vulnerable to the flaw MS17-010 that the Ransonware WannaCry exploits.
122122
The first versions of that ransomware exploits that flaw to be able to spread over network using the protocol SMB.
123123

124-
Worth note that this application only verifies if your computer is vulnerable to this flaw, and does not guarante that new versions of the ransomware wouldn't exploit other flaws on the system.</value>
124+
Worth note that this application only verifies if your computer is vulnerable to this flaw, and does not guarante that new versions of the ransomware wouldn't exploit other flaws on the system.
125+
126+
For better test execute this application in another machine and execute with your IP Address.</value>
125127
</data>
126128
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
127129
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">

README.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,15 @@ Tester for MS017-010 Exploit Vulnearbility. Based on https://github.com/nixawk/l
66
## References
77

88
https://blogs.technet.microsoft.com/msrc/2017/04/14/protecting-customers-and-evaluating-risk/
9-
109
https://www.rapid7.com/db/modules/auxiliary/scanner/smb/smb_ms17_010
11-
1210
https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/smb/smb_ms17_010.rb
13-
1411
https://www.symantec.com/security_response/vulnerability.jsp?bid=96707
15-
1612
https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-SMB2/[MS-SMB2]-151016.pdf
17-
1813
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365233(v=vs.85).aspx
19-
2014
https://technet.microsoft.com/en-us/library/security/ms17-010.aspx
21-
2215
https://community.rapid7.com/community/metasploit/blog/2017/04/03/introducing-rubysmb-the-protocol-library-nobody-else-wanted-to-write
23-
2416
https://msdn.microsoft.com/en-us/library/ee441741.aspx
25-
2617
https://github.com/countercept/doublepulsar-detection-script/blob/master/detect_doublepulsar_smb.py
27-
2818
http://stackoverflow.com/questions/38735421/packing-an-integer-number-to-3-bytes-in-python
29-
3019
https://zerosum0x0.blogspot.com/2017/04/doublepulsar-initial-smb-backdoor-ring.html
3120

32-

TestResult.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@ namespace MS17010Test {
88
public class TestResult {
99
public bool IsVulnerable;
1010
public bool VulnerabilityOK;
11+
public bool hadError;
12+
public string error;
1113
public string OSName;
1214
public string OSBuild;
1315
public string Workgroup;
1416

1517
public TestResult() {
1618
IsVulnerable = false;
1719
VulnerabilityOK = false;
20+
hadError = false;
1821
OSName = strings.unknown;
1922
OSBuild = strings.unknown;
2023
Workgroup = strings.unknown;
24+
error = "";
2125
}
2226
}
2327
}

Tester.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ public static TestResult TestIP(string ip) {
7777
res.IsVulnerable = (smb.error_class == 0x05 && smb.reserved1 == 0x02 && smb.error_code == 0xC000);
7878
res.VulnerabilityOK = (smb.error_class == 0x08 && smb.reserved1 == 0x00 && smb.error_code == 0xC000) ||
7979
(smb.error_class == 0x22 && smb.reserved1 == 0x00 && smb.error_code == 0xC000);
80-
80+
res.error = $"{smb.error_class:X2} {smb.reserved1:X2} {smb.error_code:X4}";
8181
client.Close();
8282
return res;
8383
} catch (SocketException e) {
8484
if (e.SocketErrorCode == SocketError.ConnectionReset) {
8585
res.IsVulnerable = false;
8686
res.VulnerabilityOK = false;
87+
res.hadError = true;
88+
res.error = e.Message;
8789
return res;
8890
} else {
8991
throw e;

strings.Designer.cs

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

strings.pt-BR.resx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@
123123
<data name="buttonTestOtherIP" xml:space="preserve">
124124
<value>Teste outro IP</value>
125125
</data>
126+
<data name="executionError" xml:space="preserve">
127+
<value>Houve um erro na execução do teste. Isso provavelmente significa que o seu computador não está vulnerável, porém o resultado não é tão confiável.</value>
128+
</data>
126129
<data name="no" xml:space="preserve">
127130
<value>Não</value>
128131
</data>
@@ -131,7 +134,9 @@
131134

132135
As primeiras versões do Ransonware usam uma falha no protocolo SMB do windows para poder se espalhar pela rede.
133136

134-
Vale notar que este aplicativo apenas verifica se o computador está vulnerável a essa falha, sendo que existe ainda a possibilidade de versões futuras do ransomware se aproveitarem de outras falhas.</value>
137+
Vale notar que este aplicativo apenas verifica se o computador está vulnerável a essa falha, sendo que existe ainda a possibilidade de versões futuras do ransomware se aproveitarem de outras falhas.
138+
139+
Para melhor confiança no resultado, execute esse aplicativo em outra máquina e use o seu IP</value>
135140
</data>
136141
<data name="pleaseWait" xml:space="preserve">
137142
<value>Por favor aguarde...</value>
@@ -146,7 +151,8 @@ Vale notar que este aplicativo apenas verifica se o computador está vulnerável
146151
<value>OS: {0}
147152
Build: {1}
148153
Workgroup: {2}
149-
É vulnerável: {3}</value>
154+
É vulnerável: {3}
155+
Message: {4}</value>
150156
</data>
151157
<data name="unknown" xml:space="preserve">
152158
<value>Desconhecido</value>

strings.resx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,19 @@
123123
<data name="buttonTestOtherIP" xml:space="preserve">
124124
<value>Test Other IP</value>
125125
</data>
126+
<data name="executionError" xml:space="preserve">
127+
<value>There was an execution error. This may mean it is not vulnerable, but the results are not reliable.</value>
128+
</data>
126129
<data name="no" xml:space="preserve">
127130
<value>No</value>
128131
</data>
129132
<data name="notice" xml:space="preserve">
130133
<value>That application is for checking if your computer is vulnerable to the flaw MS17-010 that the Ransonware WannaCry exploits.
131134
The first versions of that ransomware exploits that flaw to be able to spread over network using the protocol SMB.
132135

133-
Worth note that this application only verifies if your computer is vulnerable to this flaw, and does not guarante that new versions of the ransomware wouldn't exploit other flaws on the system.</value>
136+
Worth note that this application only verifies if your computer is vulnerable to this flaw, and does not guarante that new versions of the ransomware wouldn't exploit other flaws on the system.
137+
138+
For better test execute this application in another machine and execute with your IP Address.</value>
134139
</data>
135140
<data name="pleaseWait" xml:space="preserve">
136141
<value>Please wait ...</value>
@@ -145,7 +150,8 @@ Worth note that this application only verifies if your computer is vulnerable to
145150
<value>OS: {0}
146151
Build: {1}
147152
Workgroup: {2}
148-
Is Vulnerable: {3}</value>
153+
Is Vulnerable: {3}
154+
Message {4}</value>
149155
</data>
150156
<data name="unknown" xml:space="preserve">
151157
<value>Unknown</value>

0 commit comments

Comments
 (0)