Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
dehoisted authored Nov 17, 2021
1 parent 2ee64c7 commit 5915747
Show file tree
Hide file tree
Showing 20 changed files with 5,832 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Source/BEncoder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.IO;

namespace Bat2Exe
{
class BEncoder
{
public string encoded_output = "";
protected readonly string batch_code = "", encoded_bat_file = "encoded_source.bat";
// More encoding methods coming soon
public enum Methods
{
bom = 1,
}

public string SortCode1(string batch_code)
{
string code = "";
var sr = new StringReader(batch_code);
string codeLine;
while ((codeLine = sr.ReadLine()) != null)
code = "&" + codeLine;
return code;
}

public byte[] GetBOM()
{
byte[] data = { 0xFF, 0xFE };
return data;
}

private string BomM1()
{
File.WriteAllBytes("Source\\" + encoded_bat_file, GetBOM());
File.AppendAllText("Source\\" + encoded_bat_file, batch_code);
string encoded = File.ReadAllText("Source\\" + encoded_bat_file);
return encoded;
}

public BEncoder() { }
public BEncoder(string batch_code, Methods method)
{
this.batch_code = batch_code;
switch (method)
{
case Methods.bom:
this.encoded_output = this.BomM1();
break;
default:
throw new Exception("Invalid encoding method was chosen.");
}
}
}
}
192 changes: 192 additions & 0 deletions Source/BObfuscator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
using System;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;

namespace Bat2Exe
{
class BObfuscator
{
public string ObfOutput = "";
protected readonly string batch_code = "";
protected readonly string alphabet = "abcdefghijklmnopqrstuvwxyz";
protected int random_str_length = 10;

public enum Methods
{
alphabet = 1,
junk = 2,
}
protected string RandomStr()
{
VBMath.Randomize();
string randstr = "";
short max = 1;
short amt = checked((short)this.random_str_length);
for (short i = max; i <= amt; i += 1)
{
int start = checked((int)Math.Round(Math.Floor(unchecked(26f * VBMath.Rnd()))) + 1);
randstr += Strings.Mid(this.alphabet, start, 1);
}
return randstr;
}

private string AlphabetM1()
{
string code = "";
string tempC = "";
string randstr_1 = Conversions.ToString(this.RandomStr());
string randstr_2 = Conversions.ToString(this.RandomStr());
string randstr_3 = Conversions.ToString(this.RandomStr());
string str = Conversions.ToString(this.RandomStr());
string[] array = new string[27];
tempC = tempC + "set " + randstr_1 + "=s\r\n";
tempC = string.Concat(new string[]
{
tempC,
"%",
randstr_1,
"%et ",
randstr_2,
"=e\r\n"
});
tempC = string.Concat(new string[]
{
tempC,
"%",
randstr_1,
"%%",
randstr_2,
"%t ",
randstr_3,
"=t\r\n"
});
int max = 0;
checked
{
do
{
string str2 = Strings.StrConv(Conversions.ToString(this.RandomStr()), VbStrConv.Uppercase, 0);
array[max] = Conversions.ToString(this.RandomStr());
tempC = string.Concat(new string[]
{
tempC,
"%",
randstr_1,
"%%",
randstr_2,
"%%",
randstr_3,
"% ",
array[max],
"=",
Strings.Mid(this.alphabet, max + 1, 1),
"\r\n"
});
tempC = tempC + "goto " + str2 + "\r\n";
tempC = Conversions.ToString(Operators.ConcatenateObject(tempC,
Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(
Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("%" + str + "%%", this.RandomStr()), "%%"), this.RandomStr()),
"% "), this.RandomStr()), "="), Strings.Mid(this.alphabet, max + 1, 1)), "\r\n")));

tempC = tempC + ":" + str2 + "\r\n";
max++;
}
while (max <= 25);
int num2 = 1;
int num3 = Strings.Len(this.batch_code);
for (int i = num2; i <= num3; i++)
{
string left = Strings.Mid(this.batch_code, i, 1);
if (Operators.CompareString(left, "a", false) == 0)
code = code + "%" + array[0] + "%";
else if (Operators.CompareString(left, "b", false) == 0)
code = code + "%" + array[1] + "%";
else if (Operators.CompareString(left, "c", false) == 0)
code = code + "%" + array[2] + "%";
else if (Operators.CompareString(left, "d", false) == 0)
code = code + "%" + array[3] + "%";
else if (Operators.CompareString(left, "e", false) == 0)
code = code + "%" + array[4] + "%";
else if (Operators.CompareString(left, "f", false) == 0)
code = code + "%" + array[5] + "%";
else if (Operators.CompareString(left, "g", false) == 0)
code = code + "%" + array[6] + "%";
else if (Operators.CompareString(left, "h", false) == 0)
code = code + "%" + array[7] + "%";
else if (Operators.CompareString(left, "i", false) == 0)
code = code + "%" + array[8] + "%";
else if (Operators.CompareString(left, "j", false) == 0)
code = code + "%" + array[9] + "%";
else if (Operators.CompareString(left, "k", false) == 0)
code = code + "%" + array[10] + "%";
else if (Operators.CompareString(left, "l", false) == 0)
code = code + "%" + array[11] + "%";
else if (Operators.CompareString(left, "m", false) == 0)
code = code + "%" + array[12] + "%";
else if (Operators.CompareString(left, "n", false) == 0)
code = code + "%" + array[13] + "%";
else if (Operators.CompareString(left, "o", false) == 0)
code = code + "%" + array[14] + "%";
else if (Operators.CompareString(left, "p", false) == 0)
code = code + "%" + array[15] + "%";
else if (Operators.CompareString(left, "q", false) == 0)
code = code + "%" + array[16] + "%";
else if (Operators.CompareString(left, "r", false) == 0)
code = code + "%" + array[17] + "%";
else if (Operators.CompareString(left, "s", false) == 0)
code = code + "%" + array[18] + "%";
else if (Operators.CompareString(left, "t", false) == 0)
code = code + "%" + array[19] + "%";
else if (Operators.CompareString(left, "u", false) == 0)
code = code + "%" + array[20] + "%";
else if (Operators.CompareString(left, "v", false) == 0)
code = code + "%" + array[21] + "%";
else if (Operators.CompareString(left, "w", false) == 0)
code = code + "%" + array[22] + "%";
else if (Operators.CompareString(left, "x", false) == 0)
code = code + "%" + array[23] + "%";
else if (Operators.CompareString(left, "y", false) == 0)
code = code + "%" + array[24] + "%";
else if (Operators.CompareString(left, "z", false) == 0)
code = code + "%" + array[25] + "%";
else
code += Strings.Mid(this.batch_code, i, 1);
}
return tempC + code;
}
}

private string JunkM2()
{
string code = "";
checked {
int max = 1;
int len = Strings.Len(this.batch_code);
for (int k = max; k <= len; k++)
code = Conversions.ToString(Operators.ConcatenateObject(code,
Operators.AddObject(Strings.Mid(this.batch_code, k, 1),
Operators.AddObject(Operators.AddObject("%",
this.RandomStr()), "%"))));
}
return code;
}

public BObfuscator() { }

public BObfuscator(string batch_code, Methods method)
{
this.batch_code = batch_code;
switch (method)
{
case Methods.alphabet:
this.ObfOutput = this.AlphabetM1();
break;
case Methods.junk:
this.ObfOutput = this.JunkM2();
break;
default:
throw new Exception("Invalid obfuscation method was chosen.");
}
}
}
}
117 changes: 117 additions & 0 deletions Source/Bat2Exe.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{355FD640-6299-41EA-9E9F-6D10A24EFFD8}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Bat2Exe</RootNamespace>
<AssemblyName>Bat2Exe</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>batch_image.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<ItemGroup>
<Reference Include="Guna.UI2, Version=2.0.1.9, Culture=neutral, PublicKeyToken=e4b9cdd7b4cde4b4, processorArchitecture=MSIL">
<HintPath>packages\Guna.UI2.WinForms.2.0.1.9\lib\net40\Guna.UI2.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BEncoder.cs" />
<Compile Include="CMethods.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="BObfuscator.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="batch_image.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
13 changes: 13 additions & 0 deletions Source/Bat2Exe.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>
Loading

0 comments on commit 5915747

Please sign in to comment.