Skip to content

Instantly share code, notes, and snippets.

View sunnamed434's full-sized avatar
👀
Keep things simple

sunnamed434

👀
Keep things simple
View GitHub Profile
@sunnamed434
sunnamed434 / UnturnedSteamAuthTicket.cs
Last active June 5, 2024 11:50
Usage example for new thing in Unturned SteamPlayer.OnSteamAuthTicketForWebApiReceived
// Sharing this because I didn't found a use case for it for UnturnedGuard, so instead of removing it in trash I decided to share it with everyone, feel free to use that
// You will also need to integrate UniTask in you plugin, but you can remove it and make it different ways, doesn't matter (you can check openmod how it work)
// Warning!: No Help/Support/Guarantees that it work or something. I'd recommend to just use it as learning thing, to understand how this new feature work actually. But yeah if you want to criticize my shit code then why not
// AsyncHelper is the same thing as Task.Run() (you can check openmod how it work)
using RocketLogger = Rocket.Core.Logging.Logger;
using UnityTime = UnityEngine.Time;
public delegate void SteamAuthTicketReceiveFail(ulong steamId, SteamAuthTicketFailReason reason);
@sunnamed434
sunnamed434 / releasescleanup.yml
Created November 16, 2023 11:05
Delets all old releases
name: 'Delete old Releases'
on: push
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@master
@sunnamed434
sunnamed434 / artifactscleanup.yml
Created November 8, 2023 14:03
Delete all artifacts
name: 'artifacts cleanup'
on: push
jobs:
delete-artifacts:
permissions: write-all
environment: dev
runs-on: ubuntu-latest
steps:
- uses: kolpav/purge-artifacts-action@v1
@sunnamed434
sunnamed434 / example.cs
Created August 26, 2023 11:13
ASP.NET ProblemDetails application/problem+json
services.AddControllers(configure =>
{
configure.Filters.Add<ProblemResultFilter>();
});
[UsedImplicitly]
public class ProblemResultFilter : IResultFilter
{
[SuppressMessage("ReSharper", "MergeIntoPattern")]
public void OnResultExecuting(ResultExecutingContext context)
@sunnamed434
sunnamed434 / BitMono.cs
Created February 7, 2023 14:57
PackerPacker
public Task ExecuteAsync(ProtectionContext context, ProtectionParameters parameters)
{
using (var stream = File.Open(context.BitMonoContext.OutputFile, FileMode.Open, FileAccess.ReadWrite, FileSha
using (var reader = new BinaryReader(stream))
using (var writer = new BinaryWriter(stream))
{
stream.Position = 0x3C;
var peHeader = reader.ReadUInt32();
stream.Position = peHeader;
stream.Position += 0x18;
@sunnamed434
sunnamed434 / SerilogContextCallerExtensions.cs
Last active January 29, 2023 20:02
Serilog bypass ForContext<T>()
public static class SerilogContextCallerExtensions
{
private const string CsharpFileExtension = ".cs";
public static ILogger ForContextFile(this ILogger source, [CallerFilePath] string caller = "")
{
caller = caller
.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
.Last()
.Replace(CsharpFileExtension, string.Empty);
return source.ForContext(Constants.SourceContextPropertyName, caller);
var currentAssemblyDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var fileFormat = string.Format(Path.Combine(currentAssemblyDirectory, "logs", "bitmono-{0:yyyy-MM-dd-HH-mm-ss}.log"), DateTime.Now).Replace("\\", "/");
var loggerConfiguration = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.Async(configure =>
{
configure.File(fileFormat, rollingInterval: RollingInterval.Infinite, restrictedToMinimumLevel: LogEventLevel.Information,
outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}][{SourceContext}] {Message:lj}{NewLine}{Exception}");
});
@sunnamed434
sunnamed434 / README.md
Last active October 19, 2022 15:39
TypeLoadException after obfuscation

The problem

Getting exception after obfuscation when running obfuscated app.

Unhandled Exception: System.TypeLoadException: Could not load type 'ManagedHook' from assembly 'NETFrameConsoleApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because the parent does not exist. at NETFrameConsoleApp.Program.Main(String[] args)

app.cs - program which was obfuscated by obfuscation.cs

What does obfuscation do after error occurs?

@sunnamed434
sunnamed434 / CLI.cs
Created October 13, 2022 12:41
CLI + GUI Injecting Serilog through Host with Autofac
var container = new BitMonoApplication().RegisterModule(new BitMonoModule(configureLogger =>
{
configureLogger.WriteTo.Async(configureSinkConfiguration =>
{
configureSinkConfiguration.Console();
});
})).Build();