-
Notifications
You must be signed in to change notification settings - Fork 0
/
atf.cs
60 lines (54 loc) · 1.85 KB
/
atf.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using Microsoft.Win32;
namespace ATF
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listBox1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
}
private void listBox1_DragDrop(object sender, DragEventArgs e)
{
// take dropped items and store them
string[] droppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop);
// loop through all droppped items and display/add them to the listbox
foreach (string file in droppedFiles)
if(Path.GetExtension(file).ToLower() == ".exe")
{
listBox1.Items.Add(file);
}
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
private void button1_Click(object sender, EventArgs e)
{
foreach (string item in listBox1.Items)
{
string addToFirewall = "/C netsh advfirewall firewall add rule name=" + Path.GetFileName(item) + " dir=out action=block program=\"" + item + "\"";
System.Diagnostics.Process proc2 = new System.Diagnostics.Process();
proc2.StartInfo.CreateNoWindow = false;
proc2.StartInfo.Verb = "runas";
proc2.StartInfo.FileName = "cmd";
proc2.StartInfo.Arguments = "/env /user:" + "Administrator" + " cmd" + addToFirewall;
proc2.Start();
}
}
}
}