-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
492 lines (472 loc) · 20.2 KB
/
Form1.cs
File metadata and controls
492 lines (472 loc) · 20.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
/**
* Program Overflow 2.1 coded by Lumito.
* (C) 2020, Lumito Luma.
* Please use this tool responsibly.
* I'm not responsible of any damage this tool can make to your PC.
* Website: www.lumito.net
*/
using System;
using System.IO;
using System.Windows.Forms;
namespace ProgramOverflow
{
public partial class Form1 : Form
{
byte counterRipPc, counterRunPrograms, ischk, ischk2, RunPrograms;
short x;
int i, ProgressBar1Value;
public void CopyFiles()
{
button1.Enabled = false;
button2.Enabled = false;
richTextBox1.Clear();
progressBar1.Value = 0;
string domainupdowntext = numericUpDown1.Text;
int NumberOfCopies = int.Parse(domainupdowntext);
if (!Directory.Exists("C:\\ProgramOverflow"))
{
Directory.CreateDirectory("C:\\ProgramOverflow");
}
progressBar1.Maximum = NumberOfCopies * 100;
ProgressBar1Value = progressBar1.Maximum / NumberOfCopies;
for (i = 1; i <= NumberOfCopies; i++)
{
progressBar1.Value += ProgressBar1Value;
string destinationFile = "C:\\ProgramOverflow\\Program" + i + ".exe";
var process = System.Diagnostics.Process.GetCurrentProcess();
string fullPath = process.MainModule.FileName;
richTextBox1.AppendText("Copying Program" + i + ".exe...");
try
{
if (!File.Exists(destinationFile))
{
File.Copy(fullPath, destinationFile, true);
}
if (RunPrograms == 1)
{
richTextBox1.AppendText(" Done!\nRunning Program" + i + ".exe...");
System.Diagnostics.Process.Start(destinationFile);
}
richTextBox1.AppendText(" Done!\n");
}
catch
{
richTextBox1.AppendText(" Error!\n-- Error while deleting files --");
}
}
progressBar1.Value = progressBar1.Maximum;
button1.Enabled = true;
button2.Enabled = true;
richTextBox1.AppendText("-- " + (i - 1) + " Files successfully copied! --");
}
public void CopyArg(int argnumber)
{
if (argnumber <= 999999)
{
if (!Directory.Exists("C:\\ProgramOverflow"))
{
Directory.CreateDirectory("C:\\ProgramOverflow");
}
for (i = 1; i <= argnumber; i++)
{
string destinationFile = "C:\\ProgramOverflow\\Program" + i + ".exe";
var process = System.Diagnostics.Process.GetCurrentProcess();
string fullPath = process.MainModule.FileName;
if (!File.Exists(destinationFile))
{
File.Copy(fullPath, destinationFile, true);
}
if (RunPrograms == 1)
{
System.Diagnostics.Process.Start(destinationFile);
}
}
MessageBox.Show("Copied " + argnumber.ToString() + " files correctly!", "Program Overflow 2.1");
Environment.Exit(0);
}
else
{
MessageBox.Show("Please specify a number between 1 and 999999. 0 yields error", "Program Overflow 2.1");
Environment.Exit(0);
}
}
public static void Clean()
{
if (Directory.Exists("C:\\ProgramOverflow"))
{
string msg = "This will delete the whole C:\\ProgramOverflow directory.\nAre you sure that you want to continue?";
string titlemsg = "Program Overflow 2.1";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
MessageBoxDefaultButton dbutton = MessageBoxDefaultButton.Button2;
DialogResult result = MessageBox.Show(msg, titlemsg, buttons, MessageBoxIcon.Warning, dbutton);
if (result == DialogResult.Yes)
{
DirectoryInfo podir = new DirectoryInfo("C:\\ProgramOverflow");
int fc = 0;
foreach (FileInfo file in podir.EnumerateFiles())
{
file.Delete(); //Deletes all the files in C:\ProgramOverflow directory
fc++;
}
foreach (DirectoryInfo dir in podir.EnumerateDirectories())
{
dir.Delete(true); //Deletes all the directories in C:\ProgramOverflow directory
}
podir.Delete(); //Deletes C:\ProgramOverflow directory
if (fc == 1) //Checks if there was only a file in C:\ProgramOverflow directory
{
MessageBox.Show("1 file successfully cleaned!", "Program Overflow 2.1");
}
else
{
MessageBox.Show(fc + " files successfully cleaned!", "Program Overflow 2.1");
}
}
Environment.Exit(0); //Exits the program
}
else
{
MessageBox.Show("No need to clean", "Program Overflow 2.1");
Environment.Exit(0);
}
}
public Form1()
{
InitializeComponent();
counterRipPc = 0;
counterRunPrograms = 0;
ischk = 0;
ischk2 = 0;
RunPrograms = 0;
}
private void Button1_Click(object sender, EventArgs e)
{
CopyFiles();
}
private void Button2_Click(object sender, EventArgs e)
{
int cno = 0;
button1.Enabled = false;
button2.Enabled = false;
richTextBox1.Clear();
progressBar1.Value = 0;
if (Directory.Exists("C:\\ProgramOverflow"))
{
string msg = "This will delete the whole C:\\ProgramOverflow directory.\nAre you sure that you want to continue?";
string titlemsg = "Program Overflow 2.1";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
MessageBoxDefaultButton dbutton = MessageBoxDefaultButton.Button2;
DialogResult result = MessageBox.Show(msg, titlemsg, buttons, MessageBoxIcon.Warning, dbutton);
if (result == DialogResult.Yes)
{
DirectoryInfo podir = new DirectoryInfo("C:\\ProgramOverflow");
int fc = 0;
int nfiles = podir.GetFiles().Length;
progressBar1.Maximum = nfiles * 100;
ProgressBar1Value = progressBar1.Maximum / nfiles;
try
{
foreach (FileInfo file in podir.EnumerateFiles())
{
progressBar1.Value += ProgressBar1Value;
richTextBox1.AppendText("Deleting " + file + "...");
file.Delete(); //Deletes all the files in C:\ProgramOverflow directory
richTextBox1.AppendText(" Done!\n");
fc++;
}
foreach (DirectoryInfo dir in podir.EnumerateDirectories())
{
dir.Delete(true); //Deletes all the directories in C:\ProgramOverflow directory
}
podir.Delete(); //Deletes C:\ProgramOverflow directory
if (fc == 1) //Checks if there was only a file in C:\ProgramOverflow directory
{
richTextBox1.AppendText("-- 1 file successfully cleaned! -- ");
}
else
{
richTextBox1.AppendText("-- " + fc + " files successfully cleaned! --");
}
}
catch
{
richTextBox1.AppendText(" Error!\n-- Error while deleting files --");
}
}
else
{
cno = 1;
}
}
else
{
richTextBox1.AppendText("-- No need to clean --");
}
if(cno == 0)
{
progressBar1.Value = progressBar1.Maximum;
}
button1.Enabled = true;
button2.Enabled = true;
}
private void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
if (ischk == 0)
{
string msg = "Are you sure that you want to enable this feature?";
string titlemsg = "Program Overflow 2.1";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
MessageBoxDefaultButton dbutton = MessageBoxDefaultButton.Button2;
DialogResult result = MessageBox.Show(msg, titlemsg, buttons, MessageBoxIcon.Warning, dbutton);
if (result == DialogResult.Yes)
{
checkBox1.Enabled = true;
checkBox2.Enabled = true;
}
else
{
ischk = 1;
radioButton1.Checked = false;
}
}
else
{
ischk = 0;
}
}
private void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (counterRipPc == 0)
{
numericUpDown1.Maximum = 999999;
label6.Text = "Nº of copies: (Max 999999)";
counterRipPc = 1;
}
else
{
numericUpDown1.Maximum = 9999;
label6.Text = "Nº of copies: (Max 9999)";
label10.Text = " ";
counterRipPc = 0;
}
}
private void CheckBox2_CheckedChanged(object sender, EventArgs e)
{
if (ischk2 == 0)
{
if (counterRunPrograms == 0)
{
string msg = "This feature may DESTROY your PC.\nAre you highly sure that you want to enable it?";
string titlemsg = "Program Overflow 2.1";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
MessageBoxDefaultButton dbutton = MessageBoxDefaultButton.Button2;
DialogResult result = MessageBox.Show(msg, titlemsg, buttons, MessageBoxIcon.Stop, dbutton);
if (result == DialogResult.Yes)
{
RunPrograms = 1;
counterRunPrograms = 1;
button1.Text = "Destroy computer";
button1.ForeColor = System.Drawing.Color.Red;
}
else
{
ischk2 = 1;
checkBox2.Checked = false;
}
}
else
{
RunPrograms = 0;
counterRunPrograms = 0;
button1.Text = "Start";
button1.ForeColor = System.Drawing.Color.Black;
}
}
else
{
ischk2 = 0;
}
}
private void Label7_Click(object sender, EventArgs e)
{
if (counterRipPc == 1 && x == 0)
{
x = 1;
}
else
{
x = 0;
}
}
private void Label8_Click(object sender, EventArgs e)
{
if (x == 1)
{
x = 2;
}
else
{
x = 0;
}
}
private void Label9_Click(object sender, EventArgs e)
{
if (x == 2)
{
x = 3;
}
else
{
x = 0;
}
}
private void Label10_Click(object sender, EventArgs e)
{
if (x == 3)
{
x = 0;
numericUpDown1.Maximum = 9999999;
label6.Text = "Nº of copies: (Max 9999999)";
label10.Text = "Enjoy!";
}
else
{
x = 0;
}
}
private void Form1_Load(object sender, EventArgs e)
{
string[] passedInArgs = Environment.GetCommandLineArgs();
int argnumber;
try
{
argnumber = int.Parse(passedInArgs[1]);
try
{
string IsSilent = passedInArgs[2];
if (IsSilent == "/S" || IsSilent == "/s" || IsSilent == "-S" || IsSilent == "-s"
|| IsSilent == "/Silent" || IsSilent == "/silent" || IsSilent == "/silent" || IsSilent == "-silent"
|| IsSilent == "--Silent" || IsSilent == "--silent" || IsSilent == "--S" || IsSilent == "--s")
{
if (argnumber <= 999999)
{
if (!Directory.Exists("C:\\ProgramOverflow"))
{
Directory.CreateDirectory("C:\\ProgramOverflow");
}
for (i = 1; i <= argnumber; i++)
{
string destinationFile = "C:\\ProgramOverflow\\Program" + i + ".exe";
var process = System.Diagnostics.Process.GetCurrentProcess();
string fullPath = process.MainModule.FileName;
if (!File.Exists(destinationFile))
{
File.Copy(fullPath, destinationFile, true);
}
if (RunPrograms == 1)
{
System.Diagnostics.Process.Start(destinationFile);
}
}
Environment.Exit(0);
}
else
{
Environment.Exit(0);
}
}
else
{
CopyArg(argnumber);
}
}
catch
{
CopyArg(argnumber);
}
}
catch
{
try
{
string argstring = passedInArgs[1];
if (argstring == "Clean" || argstring == "clean" || argstring == "/Clean" || argstring == "/clean"
|| argstring == "-Clean" || argstring == "-clean" || argstring == "--Clean" || argstring == "--clean")
{
try
{
string IsSilent = passedInArgs[2];
if (IsSilent == "/S" || IsSilent == "/s" || IsSilent == "-S" || IsSilent == "-s"
|| IsSilent == "/Silent" || IsSilent == "/silent" || IsSilent == "/silent" || IsSilent == "-silent"
|| IsSilent == "--Silent" || IsSilent == "--silent" || IsSilent == "--S" || IsSilent == "--s")
{
if (Directory.Exists("C:\\ProgramOverflow"))
{
DirectoryInfo podir = new DirectoryInfo("C:\\ProgramOverflow");
foreach (FileInfo file in podir.EnumerateFiles())
{
file.Delete(); // Deletes all the files in C:\ProgramOverflow directory
}
foreach (DirectoryInfo dir in podir.EnumerateDirectories())
{
dir.Delete(true); // Deletes all the directories in C:\ProgramOverflow directory
}
podir.Delete(); // Deletes C:\ProgramOverflow directory
Environment.Exit(0); // Exits the program
}
else
{
Environment.Exit(0);
}
}
else
{
Clean();
}
}
catch
{
Clean();
}
}
else if (argstring == "Help" || argstring == "help" || argstring == "h" || argstring == "H"
|| argstring == "/Help" || argstring == "/help" || argstring == "/h" || argstring == "/H"
|| argstring == "-Help" || argstring == "-help" || argstring == "-h" || argstring == "-H"
|| argstring == "--Help" || argstring == "--help" || argstring == "--h" || argstring == "--H")
{
var progname = System.Diagnostics.Process.GetCurrentProcess();
string programname = progname.ProcessName;
MessageBox.Show("Usage:\n\n" +
"\"" + programname + ".exe [number of copies | /clean | /help] [/S]\"\n\n" +
"Number of copies:\n" +
" If you don't specify a number of copies, the program will run normally.\n" +
" If number of copies isn't a number the program will start normally unless it's /help.\n" +
" The number of copies must be between 1 and 999999. 0 yields error.\n\n" +
"/clean:\n" +
" Deletes all the files in C:\\ProgramOverflow directory.\n\n" +
"/help:\n" +
" Shows this message.\n" +
" /S flag does not work with /help.\n\n" +
"/S:\n" +
" Use this flag after \"Number of copies\" or \"/clean\".\n" +
" \"/S\" flag suppress any message that the program will show, so the execution is silent.\n\n" +
"© 2020, Lumito - www.lumito.net", "Program Overflow 2.1");
Environment.Exit(0);
}
}
catch
{
// Starts the app normally
}
}
}
private void NumericUpDown1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
CopyFiles();
e.SuppressKeyPress = true;
}
}
}
}