-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForm1.cs
More file actions
890 lines (737 loc) · 31.2 KB
/
Form1.cs
File metadata and controls
890 lines (737 loc) · 31.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Diagnostics;
using System.Security.Principal;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Mail;
namespace JustScan
{
public partial class Form1 : Form
{
int dot = DateTime.Now.TimeOfDay.ToString().IndexOf(".");
//WHOIS------------------------------
TcpClient tcpWhois;
NetworkStream nsWhois;
BufferedStream bfWhois;
StreamWriter strmSend;
StreamReader strmRecive;
//WHOIS------------------------------
//PORT SCANNER START-----------------
protected int StartPort;
protected int EndPort;
protected int StartIP;
protected int EndIP;
//PORT SCANNER STOP------------------
//WIFI START----------------
bool connect = false;
bool PScanning = false;
//WIFI END------------------
//void Add(string m)
//{
// add.Items.Add(m);
//}
/// <summary>
/// The main entry point for the application.
/// </summary
//WIFI START-------------------------------------------
public static bool IsAdmin()
{
WindowsIdentity id = WindowsIdentity.GetCurrent();
WindowsPrincipal p = new WindowsPrincipal(id);
return p.IsInRole(WindowsBuiltInRole.Administrator);
}
public void RestartElevated()
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = true;
startInfo.CreateNoWindow = true;
startInfo.WorkingDirectory = Environment.CurrentDirectory;
startInfo.FileName = System.Windows.Forms.Application.ExecutablePath;
startInfo.Verb = "runas";
try
{
Process p = Process.Start(startInfo);
}
catch
{
}
System.Windows.Forms.Application.Exit();
}
//WIFI END---------------------------------------------------
public Form1()
{
InitializeComponent();
LoadMe();
progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
}
void LoadMe()
{
hostName.Text = Dns.GetHostName();
//MessageBox.Show(Dns.GetHostEntry());
IPHostEntry ip = Dns.GetHostEntry(Dns.GetHostName());
if (ip.AddressList.Count() > 1)
{
int Nip = ip.AddressList.Count();
// MessageBox.Show(Nip.ToString());
IPMenu.Items.Add("127.0.0.1");//*Added
while (Nip != 0)
{
// MessageBox.Show(ip.AddressList[Nip - 1].AddressFamily.ToString());
//Here InterNetwork=IPv4 and InterNetworkV6=IPv6
if (ip.AddressList[Nip - 1].AddressFamily.ToString() == "InterNetwork")
{ //*Added
IPMenu.Items.Add(ip.AddressList[Nip - 1].ToString());
}
Nip--;
}
}
}
private void btnUse_Click(object sender, EventArgs e)
{
//When pressing the use use button
try
{
// IPHostEntry ip = Dns.GetHostByName(Dns.GetHostName());
IPHostEntry ip = Dns.GetHostEntry(Dns.GetHostName());
//ipFrom.Text = ip.AddressList[1].ToString();
//ipTo.Text = ip.AddressList[1].ToString();
ipFrom.Text = IPMenu.SelectedItem.ToString();
ipTo.Text = IPMenu.SelectedItem.ToString();
}
catch { MessageBox.Show("Please Choose an IP"); }
}
Thread sercher;
private void btnStart_Click(object sender, EventArgs e)
{
try
{
if (ScanType.SelectedItem.ToString() == "Dns Entries")
{
sercher = new Thread(new ThreadStart(FindUsingDns));
// add.Items.Clear();
try
{
IPAddress from = IPAddress.Parse(ipFrom.Text);
IPAddress to = IPAddress.Parse(ipTo.Text);
}
catch (FormatException fe)
{
MessageBox.Show(fe.Message);
return;
}
sercher.Name = "Network searching thread";
sercher.Start();
//add.Items.Add(" -->> >>> Please wait while processing is done <<< <<--");
IPScan.AppendText(" -->> >>> Please wait while processing is done <<< <<--" + "\n");
//Thread.Sleep(1);
}
else if (ScanType.SelectedItem.ToString() == "Ping Scan")
{
// MessageBox.Show("You Chose Ping Scan");
sercher = new Thread(new ThreadStart(FindUsingPing));
// add.Items.Clear();
try
{
IPAddress from = IPAddress.Parse(ipFrom.Text);
IPAddress to = IPAddress.Parse(ipTo.Text);
}
catch (FormatException fe)
{
MessageBox.Show(fe.Message);
return;
}
sercher.Name = "Network searching thread";
sercher.Start();
// add.Items.Add(" -->> >>> Please wait while processing is done <<< <<--");
IPScan.AppendText(" -->> >>> Please wait while processing is done <<< <<--" + "\n");
//Thread.Sleep(1);
}
// else { MessageBox.Show("Please Choose The Scan Type"); }
}
catch { MessageBox.Show("Please Choose The Scan Type"); }
}
/// <summary>
///
/// </summary>
void FindUsingDns() //
{
// add.Items.Add(" -- >>> >> >>> Found station <<< << <<< -- ");
// add.Items.Add("Host Name IP Address");
IPScan.AppendText(" -- >>> >> >>> Found station <<< << <<< -- " + "\n");
IPScan.AppendText("Host Name IP Address" + "\n");
int lastF = ipFrom.Text.LastIndexOf(".");
int lastT = ipTo.Text.LastIndexOf(".");
string frm = ipFrom.Text.Substring(lastF + 1);
string tto = ipTo.Text.Substring(lastT + 1);
int result = 0;
// Store values from the NumericUpDown to variables
StartIP = int.Parse(frm);
EndIP = int.Parse(tto);
// Reset the progress bar
prgIPScanning.Value = 0;
// Set the max value of the progress bar
prgIPScanning.Maximum = EndIP - StartIP + 1;
MessageBox.Show("From" + frm + "To " + tto + " Maximum" + (EndIP - StartIP + 1));
// Let the user know the application is busy
Cursor.Current = Cursors.WaitCursor;
System.Diagnostics.Debug.WriteLine(frm + " " + tto);
for (int i = int.Parse(frm); i <= int.Parse(tto); i++)
{
try
{
string address = ipTo.Text.Substring(0, lastT + 1);
System.Diagnostics.Debug.WriteLine(ipTo.Text.Substring(0, lastT + 1) + i);
IPHostEntry he = Dns.GetHostByAddress(address + i);
// IPHostEntry Ipe = Dns.GetHostEntry();
// add.Items.Add(he.HostName+" "+address+i);
IPScan.AppendText(he.HostName + " " + address + i + "\n");
//foreach (DataGridView row in ScanGrid.Rows)
//{
// // ScanGrid.UpdateCellValue(0,0) = address + i;
//}
// add.Items.Add(he.HostName+" "+address+i.ToString());
result += 1;
}
catch (SocketException)
{
// in cazul unei erori
}
catch (Exception)
{
// previne bloacarea programului
}
prgIPScanning.PerformStep();
}
// Set the cursor back to normal
Cursor.Current = Cursors.Arrow;
}
void FindUsingPing()
{
string host = null; int attempts = 1;
//int timeout=0; //Time to wait for replies In Milliseconds
//add.Items.Add(" -- >>> >> >>> Found station <<< << <<< -- ");
//add.Items.Add("Host Name IP Address");
IPScan.AppendText(" -- >>> >> >>> Found station <<< << <<< -- " + "\n");
IPScan.AppendText("Host Name IP Address" + "\n");
int lastF = ipFrom.Text.LastIndexOf(".");
int lastT = ipTo.Text.LastIndexOf(".");
string frm = ipFrom.Text.Substring(lastF + 1);
string tto = ipTo.Text.Substring(lastT + 1);
int result = 0;
// Store values from the NumericUpDown to variables
StartIP = int.Parse(frm);
EndIP = int.Parse(tto); ;
// Reset the progress bar
prgIPScanning.Value = 0;
// Set the max value of the progress bar
prgIPScanning.Maximum = EndIP - StartIP + 1;
//MessageBox.Show("From"+frm+"To "+tto+" Maximum"+(EndIP-StartIP+1));
// Let the user know the application is busy
Cursor.Current = Cursors.WaitCursor;
Ping ping = new Ping();
PingReply pingReply;
//-----------------------------------------------------------------------------------
System.Diagnostics.Debug.WriteLine(frm + " " + tto);
for (int i = int.Parse(frm); i <= int.Parse(tto); i++)
{
try
{
string address = ipTo.Text.Substring(0, lastT + 1);
System.Diagnostics.Debug.WriteLine(ipTo.Text.Substring(0, lastT + 1) + i);
IPHostEntry he = Dns.GetHostByAddress(address + i);
// IPHostEntry Ipe = Dns.GetHostEntry();
////add.Items.Add(he.HostName + " " + address + i);
host = address + i.ToString();
for (int j = 0; j < attempts; j++)
{
try
{
// pingReply = ping.Send(host, timeout);
pingReply = ping.Send(host);
// If there is a successful ping then return true.
if (pingReply != null &&
pingReply.Status == System.Net.NetworkInformation.IPStatus.Success)
{
//return true;
// add.Items.Add(he.HostName + " " + address + i);
IPScan.AppendText(he.HostName + " " + address + i + "\n");
}
}
catch
{
// Do nothing and let it try again until the attempts are exausted.
// Exceptions are thrown for normal ping failurs like address lookup
// failed. For this reason we are supressing errors.
}
}
// Return false if we can't successfully ping the server after several attempts.
// return false;
// add.Items.Add(he.HostName+" "+address+i.ToString());
result += 1;
}
catch (SocketException)
{
// in cazul unei erori
}
catch (Exception)
{
// previne bloacarea programului
}
prgIPScanning.PerformStep();
}
MessageBox.Show("IP Scanning Done..!");
// Set the cursor back to normal
Cursor.Current = Cursors.Arrow;
//-----------------------------------------------------------------------------------------------------------
}
private void wifi_Click(object sender, EventArgs e)
{
// MessageBox.Show(IsAdmin().ToString());
string ssid = textBox1.Text, key = textBox2.Text;
if (!connect)
{
if (String.IsNullOrEmpty(textBox1.Text))
{
MessageBox.Show("SSID cannot be left blank !",
"Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (textBox2.Text == null || textBox2.Text == "")
{
MessageBox.Show("Key value cannot be left blank !",
"Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (key.Length >= 8)
{
Hotspot(ssid, key, true);
textBox1.Enabled = false;
textBox2.Enabled = false;
wifi.Text = "Stop";
connect = true;
}
else
{
MessageBox.Show("Key should be more then or Equal to 8 Characters !",
"Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
else
{
Hotspot(null, null, false);
textBox1.Enabled = true;
textBox2.Enabled = true;
wifi.Text = "Start";
connect = false;
}
}
private void Hotspot(string ssid, string key, bool status)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe");
processStartInfo.RedirectStandardInput = true;
processStartInfo.RedirectStandardOutput = true;
processStartInfo.CreateNoWindow = true;
processStartInfo.UseShellExecute = false;
Process process = Process.Start(processStartInfo);
if (process != null)
{
if (status)
{
process.StandardInput.WriteLine("netsh wlan set hostednetwork mode=allow ssid=" + ssid + " key=" + key);
process.StandardInput.WriteLine("netsh wlan start hosted network");
process.StandardInput.Close();
}
else
{
process.StandardInput.WriteLine("netsh wlan stop hostednetwork");
process.StandardInput.Close();
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
if (!IsAdmin())
{
RestartElevated();
}
cmbServer.SelectedIndex = 0;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Hotspot(null, null, false);
sercher.Abort();
PScan.Abort();
Application.Exit();
}
Thread PScan;
private void btnScan_Click(object sender, EventArgs e)
{
if (!PScanning)
{
PScan = new Thread(new ThreadStart(PortScan));
PScan.Name = "Port Scanning Thread";
txtIP.Enabled = false;
numEnd.Enabled = false;
numStart.Enabled = false;
btnScan.Text = "Stop";
PScan.Start();
PScanning = true;
// while (PScan.IsAlive) { };
//MessageBox.Show("Done..!");
}
else
{
PScan.Abort();
txtIP.Enabled = true;
numEnd.Enabled = true;
numStart.Enabled = true;
btnScan.Text = "Start";
PScanning = false;
}
//if (PScan.IsAlive)
//{
// PScan.Abort();
// MessageBox.Show("Done..!");
//}
}
void PortScan()
{
// Store values from the NumericUpDown to variables
StartPort = Convert.ToInt32(numStart.Value);
EndPort = Convert.ToInt32(numEnd.Value);
// Reset the progress bar
prgScanning.Value = 0;
// Set the max value of the progress bar
prgScanning.Maximum = EndPort - StartPort + 1;
// Let the user know the application is busy
Cursor.Current = Cursors.WaitCursor;
// Loop through the ports between start port and end port
for (int CurrPort = StartPort; CurrPort <= EndPort; CurrPort++)
{
TcpClient TcpScan = new TcpClient();
if (CurrPort == StartPort)
{
txtLog.AppendText("For The IP " + txtIP.Text + " :-\r\n");
txtLog.AppendText("---------------------------------------------\r\n");
}
try
{
// Try to connect
TcpScan.Connect(txtIP.Text, CurrPort);
// If there's no exception, we can say the port is open
txtLog.AppendText("Port " + CurrPort + " open\r\n");
}
catch
{
// An exception occured, thus the port is probably closed
txtLog.AppendText("Port " + CurrPort + " closed\r\n");
}
// Increase the progress on the progress bar
prgScanning.PerformStep();
}
txtIP.Enabled = true;
numEnd.Enabled = true;
numStart.Enabled = true;
btnScan.Text = "Start";
PScanning = false;
// Set the cursor back to normal
Cursor.Current = Cursors.Arrow;
}
private void btnLookUp_Click(object sender, EventArgs e)
{
Thread WhoIs = new Thread(new ThreadStart(WhoIS));
WhoIs.Name = "WhoIs Thread";
WhoIs.Start();
}
void WhoIS()
{
if (txtHostName.Text == null)
{
label6.Visible = true;
}
try
{
//CONNECT TO TCP CLIENT OF WHOIS
tcpWhois = new TcpClient(cmbServer.SelectedItem.ToString(), 43);
//SETUP THE NETWORK STREAM
nsWhois = tcpWhois.GetStream();
//GET THE DATA IN THE BUFFER FROM THE NETWORK STREAM
bfWhois = new BufferedStream(nsWhois);
strmSend = new StreamWriter(bfWhois);
strmSend.WriteLine(txtHostName.Text);
strmSend.Flush();
txtxResponse.Clear();
try
{
strmRecive = new StreamReader(bfWhois);
string response;
while ((response = strmRecive.ReadLine()) != null)
{
txtxResponse.Text += response + "\r\n";
if (progressBar1.Value < 100)
progressBar1.Value += 10;
}
}
catch
{
MessageBox.Show("WHOis Server Error :x");
}
}
catch
{
MessageBox.Show("No Internet Connection or Any other Fault", "Error");
}
//SEND THE WHO_IS SERVER ABOUT THE HOSTNAME
finally
{
try
{
tcpWhois.Close();
}
catch
{
}
}
}
private void label7_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (UsrName.Text.Contains("@gmail.com"))
{
MailThroughGMail();
// MessageBox.Show( txtLog.Text);
}
}
void MailThroughGMail()
{
String from, to, pass, text, subject;
string Time = DateTime.Now.TimeOfDay.ToString().Substring(0, dot);
//MessageBox.Show(MailPro.SelectedItem.ToString());
try
{
// Attachment a = new Attachment("d:\\one.docx");
from = UsrName.Text;
pass = Pass.Text;
to = To.Text;
subject = "SharpScan Network Scan Report";
text = "Hello Sir/Mam, \nThis is an Autogenerated Network Scan Report By SharpScan \nThe Scan Was Conducted On: "
+ DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " At: " + Time + " From the Host: "
+ Dns.GetHostName() + " \nFollowing is the Summary of Obtained Results:-\nList Of Live Hosts: \n"
+ IPScan.Text + "\nResults of Port Scan:\n "
+ txtLog.Text + " \n\nWhoIs Report:\n " + txtxResponse.Text + "\nThanks for Using SharpScan. ";
// MessageBox.Show(text);
MailMessage Report = new MailMessage(from, to, subject, text);
Report.From = new MailAddress(UsrName.Text.ToString());
//MessageBox.Show(UsrName.Text.ToString() + "@" + MailPro.SelectedItem.ToString());
// Report.Sender.DisplayName.Equals("SharpScan Report");
Report.Subject = subject;
Report.Body = text;
foreach (string s in To.Text.Split(','))
Report.To.Add(s);
//Report.Attachments.Add(a);
SmtpClient Client;
Client = new SmtpClient("smtp.gmail.com", 587);
NetworkCredential c = new NetworkCredential(from, pass);
Client.UseDefaultCredentials = false;
Client.Credentials = c;
Client.EnableSsl = true;
Client.Send(Report);
MessageBox.Show("Report Sent");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
private void tabPage7_Click(object sender, EventArgs e)
{
}
private void ipFrom_MouseEnter(object sender, EventArgs e)
{
this.ipFrom.BackColor = System.Drawing.Color.GreenYellow;
}
private void ipFrom_MouseLeave(object sender, EventArgs e)
{
this.ipFrom.BackColor = System.Drawing.Color.White;
}
private void ipTo_MouseEnter(object sender, EventArgs e)
{
this.ipTo.BackColor = System.Drawing.Color.GreenYellow;
}
private void ipTo_MouseLeave(object sender, EventArgs e)
{
this.ipTo.BackColor = System.Drawing.Color.White;
}
private void hostName_MouseEnter(object sender, EventArgs e)
{
this.hostName.BackColor = System.Drawing.Color.GreenYellow;
}
private void hostName_MouseLeave(object sender, EventArgs e)
{
this.hostName.BackColor = System.Drawing.Color.White;
}
private void textBox1_MouseEnter(object sender, EventArgs e)
{
this.textBox1.BackColor = System.Drawing.Color.GreenYellow;
}
private void textBox1_MouseLeave(object sender, EventArgs e)
{
this.textBox1.BackColor = System.Drawing.Color.White;
}
private void txtIP_MouseEnter(object sender, EventArgs e)
{
this.txtIP.BackColor = System.Drawing.Color.GreenYellow;
}
private void txtIP_MouseLeave(object sender, EventArgs e)
{
this.txtIP.BackColor = System.Drawing.Color.White;
}
private void txtHostName_MouseEnter(object sender, EventArgs e)
{
this.txtHostName.BackColor = System.Drawing.Color.GreenYellow;
}
private void txtHostName_MouseLeave(object sender, EventArgs e)
{
this.txtHostName.BackColor = System.Drawing.Color.White;
}
private void UsrName_MouseEnter(object sender, EventArgs e)
{
this.UsrName.BackColor = System.Drawing.Color.GreenYellow;
}
private void UsrName_MouseLeave(object sender, EventArgs e)
{
this.UsrName.BackColor = System.Drawing.Color.White;
}
private void Pass_MouseEnter(object sender, EventArgs e)
{
this.Pass.BackColor = System.Drawing.Color.GreenYellow;
}
private void To_MouseEnter(object sender, EventArgs e)
{
this.To.BackColor = System.Drawing.Color.GreenYellow;
}
private void To_MouseLeave(object sender, EventArgs e)
{
this.To.BackColor = System.Drawing.Color.White;
}
private void Pass_MouseLeave(object sender, EventArgs e)
{
this.Pass.BackColor = System.Drawing.Color.White;
}
private void textBox2_MouseEnter(object sender, EventArgs e)
{
this.textBox2.BackColor = System.Drawing.Color.GreenYellow;
}
private void textBox2_MouseLeave(object sender, EventArgs e)
{
this.textBox2.BackColor = System.Drawing.Color.White;
}
private void IPScan_MouseEnter(object sender, EventArgs e)
{
this.textBox2.BackColor = System.Drawing.Color.GreenYellow;
}
private void IPScan_MouseLeave(object sender, EventArgs e)
{
this.textBox2.BackColor = System.Drawing.Color.White;
}
private void txtLog_MouseEnter(object sender, EventArgs e)
{
this.textBox2.BackColor = System.Drawing.Color.GreenYellow;
}
private void txtLog_MouseLeave(object sender, EventArgs e)
{
this.textBox2.BackColor = System.Drawing.Color.White;
}
private void numStart_Enter(object sender, EventArgs e)
{
this.numStart.BackColor = System.Drawing.Color.GreenYellow;
}
private void numStart_Leave(object sender, EventArgs e)
{
this.numStart.BackColor = System.Drawing.Color.White;
}
private void numEnd_Enter(object sender, EventArgs e)
{
this.numEnd.BackColor = System.Drawing.Color.GreenYellow;
}
private void numEnd_Leave(object sender, EventArgs e)
{
this.numEnd.BackColor = System.Drawing.Color.White;
}
private void tabPage4_Click(object sender, EventArgs e)
{
//Report.AppendText("Hello Sir/Mam,\n ");
//Report.AppendText("This is an Autogenerated Network Scan Report By SharpScan \nThe Scan Was Conducted On: "
// + DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " At: " + Time + " From the Host: "
// + Dns.GetHostName() );
//Report.AppendText("Following is the Summary of Obtained Results:-\nList Of Live Hosts: \n");
//Report.AppendText(IPScan.Text);
//Report.AppendText("\nResults of Port Scan:\n ");
//Report.AppendText(txtLog.Text);
//Report.AppendText("WhoIs Report:\n ");
//Report.AppendText(txtxResponse.Text );
//Report.AppendText( "Thanks for Using SharpScan. ");
}
string text, Time, path;
private void SaveFile_Click(object sender, EventArgs e)
{
try
{
text = "Hello Sir/Mam, \nThis is an Autogenerated Network Scan Report By SharpScan \nThe Scan Was Conducted On: "
+ DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + " At: " + Time + " From the Host: "
+ Dns.GetHostName() + " \nFollowing is the Summary of Obtained Results:-\nList Of Live Hosts: \n"
+ IPScan.Text + "\nResults of Port Scan:\n "
+ txtLog.Text + " \n\nWhoIs Report:\n " + txtxResponse.Text + "\nThanks for Using SharpScan. ";
Time = DateTime.Now.TimeOfDay.ToString().Substring(0, dot);
//SaveFileDialog ofd = new SaveFileDialog();
// if (ofd.ShowDialog() == DialogResult.OK)
// path = ofd.FileName;
//else { MessageBox.Show("Please Choose a file location."); }
// StreamWriter sw = new StreamWriter(File.Create(text));
// sw.WriteLine(path);
// sw.Dispose();
//}
//catch (Exception efd){
// MessageBox.Show(efd.ToString());
SaveFileDialog ofd = new SaveFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
path = ofd.FileName;
else { MessageBox.Show("Please Choose a file location."); }
StreamWriter sw = new StreamWriter(File.Create(path));
sw.WriteLine(text);
sw.Dispose();
}
catch (Exception efd)
{
MessageBox.Show(efd.ToString());
}
}
//private void MouseIn(object sender, EventArgs e)
//{
// this.ipFrom.BackColor = System.Drawing.Color.GreenYellow;
//}
//private void MouseOut(object sender, EventArgs e)
//{
// this.ipFrom.BackColor = System.Drawing.Color.GreenYellow;
//}
}
}