Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
Project publication
Browse files Browse the repository at this point in the history
  • Loading branch information
ttwizz authored Feb 11, 2024
1 parent 4ccbd55 commit 7568ab4
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 0 deletions.
99 changes: 99 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;

main();

static byte[] GenerateByte()
{
int length = new Random().Next(2, 7);
byte[] numArray = new byte[length];
for (int index = 0; index < length; ++index)
numArray[index] = 0;
return numArray;
}

static string GenerateRandomString(int length)
{
Random random = new Random();
StringBuilder stringBuilder = new StringBuilder(length);
for (int index = 0; index < length; ++index)
stringBuilder.Append("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"[random.Next("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz".Length)]);
return stringBuilder.ToString();
}

static void ShuffleMD5(string file)
{
int num = new FileInfo(file).Length > 1048576L ? 1048576 : 4096;
byte[] numArray = GenerateByte();
using (FileStream fileStream = new FileStream(file, (FileMode)6))
(fileStream).Write(numArray, 0, numArray.Length);
using (MD5 md5 = MD5.Create())
{
using (FileStream fileStream = new FileStream(file, (FileMode)3, (FileAccess)1, (FileShare)1, num))
Console.WriteLine("New MD5 hash: " + BitConverter.ToString((md5).ComputeHash(fileStream)).Replace("-", ""));
}
}

static string ShuffleName(string currentDirectory, string oldFilePath)
{
Path.GetFileNameWithoutExtension(oldFilePath);
string randomString = GenerateRandomString(8);
string str = Path.Combine(currentDirectory, randomString + ".exe");
try
{
File.Move(oldFilePath, str);
DefaultInterpolatedStringHandler interpolatedStringHandler = new DefaultInterpolatedStringHandler(17, 2);
interpolatedStringHandler.AppendLiteral("Renamed '");
interpolatedStringHandler.AppendFormatted(oldFilePath);
interpolatedStringHandler.AppendLiteral("' to '");
interpolatedStringHandler.AppendFormatted(str);
interpolatedStringHandler.AppendLiteral("'.");
Console.WriteLine(interpolatedStringHandler.ToStringAndClear());
}
catch (IOException ex)
{
Console.WriteLine("An error occurred: " + ex.Message);
}
return str;
}

static void main()
{
try
{
string baseDirectory = AppContext.BaseDirectory;
string processName = Process.GetCurrentProcess().ProcessName;
List<string> list = Enumerable.ToList(Enumerable.Where((IEnumerable<string>)Directory.GetFiles(baseDirectory, "*.exe"), (file => !string.Equals(Path.GetFileName(file), processName + ".exe"))));
if (list.Count == 1)
{
Console.WriteLine("Found exe, obscuring.");
Console.WriteLine(list[0]);
Console.WriteLine("Shuffling Hash, one moment..");
ShuffleMD5(list[0]);
Console.WriteLine("Shuffling exe name, one moment..");
string str = ShuffleName(baseDirectory, list[0]);
Console.WriteLine("Shuffling complete, launching exe.");
Process.Start(new ProcessStartInfo()
{
FileName = str,
UseShellExecute = true
});
}
else
{
Console.WriteLine("Couldn't find exe or too many exe files in folder.");
Console.ReadLine();
}
Thread.Sleep(5000);
}
catch (Exception ex)
{
DefaultInterpolatedStringHandler interpolatedStringHandler = new DefaultInterpolatedStringHandler(20, 1);
interpolatedStringHandler.AppendLiteral("There was an error: ");
interpolatedStringHandler.AppendFormatted(ex);
Console.WriteLine(interpolatedStringHandler.ToStringAndClear());
Console.ReadLine();
}
}
10 changes: 10 additions & 0 deletions SecureLauncher.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
25 changes: 25 additions & 0 deletions SecureLauncher.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureLauncher", "SecureLauncher.csproj", "{6C8F1516-95C1-4D25-8F3B-3447109EEE7D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6C8F1516-95C1-4D25-8F3B-3447109EEE7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C8F1516-95C1-4D25-8F3B-3447109EEE7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C8F1516-95C1-4D25-8F3B-3447109EEE7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C8F1516-95C1-4D25-8F3B-3447109EEE7D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A72BF84F-DB99-44EB-AECB-53A00AF37F5E}
EndGlobalSection
EndGlobal

0 comments on commit 7568ab4

Please sign in to comment.