Skip to content

Instantly share code, notes, and snippets.

View nullbind's full-sized avatar

Scott Sutherland nullbind

View GitHub Profile
@nullbind
nullbind / SQL Server - Flag custom proc as Microsoft shipped
Last active November 9, 2016 02:08
How to set the "is_ms_shipped" flag to one for custom stored procedures in SQL Server.
This outlines how to set the "is_ms_shipped" flag to one for custom stored procedures in SQL Server.
Note: The following has to be executed as a sysadmin
-- Create stored procedure
CREATE PROCEDURE sp_example
AS
BEGIN
SELECT @@VERSION
END
@nullbind
nullbind / convertopenportformat
Last active December 1, 2016 20:17
hacky ps script to convert ip,openport to ip, allopenports
# hacky ps script to convert ip,openport to ip,allopenports
# Container for final list
$FullList = New-Object System.Data.DataTable
$FullList.Columns.Add("Dest") | Out-Null
$FullList.Columns.Add("Port") | Out-Null
# import full list of open ports – one per line (dest,port)
$ImportList = import-csv C:\temp\open-ports-by-line.csv
@nullbind
nullbind / enumerat_all_database_users_at_once.sql
Last active February 13, 2017 22:10
This script with enumerate all database users for the selected database. The SQL login must have a database user mapping or guest access. No other privileges are required.
select n [id], USER_NAME(n) [user_name]
from (
select top 10000 row_number() over(order by t1.number) as N
from master..spt_values t1
cross join master..spt_values t2
) a
where USER_NAME(n) is not null
@nullbind
nullbind / funwithtasks.ps1
Created March 17, 2017 20:55
Fun with Tasks
$schedule = new-object -com("Schedule.Service")
$schedule.connect()
$tasks = $schedule.getfolder("\").gettasks(0)
$entries = New-Object System.Collections.Generic.List[System.Management.Automation.PSObject]
$tasks |
ForEach-Object {
# Get task information
@nullbind
nullbind / sqlserver_cmdexec_oleautomation.txt
Last active June 7, 2017 15:52
This is a TSQL template for executing OS commands through SQL Server using OLE Automation Procedures
-- This is a TSQL template for executing OS commands through SQL Server using OLE Automation Procedures.
-- Enable Show Advanced Options
sp_configure 'Show Advanced Options',1
RECONFIGURE
GO
-- Enable OLE Automation Procedures
sp_configure 'Ole Automation Procedures',1
RECONFIGURE
@nullbind
nullbind / Find-DbaSqlInstance Mock Up
Last active August 15, 2017 14:17
Find-DbaSqlInstance Mock Up
Function Find-DbaSqlInstance
{
<#
.SYNOPSIS
This function can be used to enumerate SQL Server instances using common methods.
.EXAMPLE
Check if the provided computer(s) or instance(s) respond to ping.
@nullbind
nullbind / Invoke-SQLOSCmdCLRWMIProvider.ps1
Last active September 18, 2017 23:31
PowerUpSQL Function - Invoke-SQLOSCmdCLRWMIProvider- PoC. Working but not stable.
# todo
<#
- Note: dependant on PowerUpSQL.
1 - have script accept command or source script as string
--- have that get bake into the wmi provider method
--- update the wmi method to execute the provided string as a script block
--- mod the clr to return the output of the wmi command
- roll into clone of the invoke-sqloscmdclr function so it can scale
- remove wmi cs and dll on client
- remove sql dll cs and dll on client
@nullbind
nullbind / Find-DbaSqlInstance.ps1
Last active February 12, 2018 07:32
Find-DbaSqlInstance
# Script: Find-DbaSqlInstance
# version 0.14.5
# Author: Scott Sutherland, 2018 NetSPI
# Contributions from: Warren F. (Invoke-Parallel), https://gallery.technet.microsoft.com/scriptcenter/List-the-IP-addresses-in-a-60c5bb6b
# ------------------------
# Current feature summary
# ------------------------
# 1 - Import list of IP addresses, computer names, or SQL instances from a file via "-SqlInstanceFile" param - works
@nullbind
nullbind / PowerUpSQL_GUI2
Last active February 19, 2018 15:17
PowerUpSQL_GUI2
# --------------------------------------------
# Create Form
# --------------------------------------------
# Create primary form
Add-Type -AssemblyName System.Windows.Forms
$Form = New-Object system.Windows.Forms.Form
$Form.Text = ""
#$Form.Opacity = 0.98 # 1.0 is fully opaque; 0.0 is invisible
@nullbind
nullbind / lsasecretsdump-csharp.cs
Last active March 1, 2018 12:31
lsasecretsdump-csharp-workinprogress
using System;
using System.Text;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace lsautil
{
// https://msdn.microsoft.com/en-us/library/microsoft.win32.registry(v=vs.110).aspx