Skip to content

Instantly share code, notes, and snippets.

@zippy1981
zippy1981 / SqlScan.ps1
Last active Aug 29, 2015
Powersploit + OrcaMDF hacking.
View SqlScan.ps1
Import-Module PowerSploit
$vssPath = Join-Path $env:TEMP ([Guid]::NewGuid())
#TODO: Magical nuget stuff I talked to Matt about
$orcaMdfCorePath = 'C:\Users\Justin\Documents\Visual Studio 2013\Projects\OrcaMDF\src\OrcaMDF.Core\bin\Debug\OrcaMDF.Core.dll'
$orcaMdfFrameworkPath = 'C:\Users\Justin\Documents\Visual Studio 2013\Projects\OrcaMDF\src\OrcaMDF.Core\bin\Debug\OrcaMDF.Framework.dll'
mkdir $vssPath
Write-Host "Vss Path $vssPath"
@zippy1981
zippy1981 / Program.cs
Created May 2, 2014
Interface implementation
View Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
interface IDependency
View IIS_Log_Tmp_Load.sql
--
-- Ad Hoc IIS Log analysis
-- Based on code from http://support.microsoft.com/kb/296085
-- Updated to work with the IIS log column config from my
-- particular inherited Windows 2008 server.
--
DROP TABLE #IISLogs
GO
@zippy1981
zippy1981 / LoginToSysadmin.sql
Created Feb 8, 2011
Script to make a windows user a sql server sysadmin
View LoginToSysadmin.sql
--- First we create a login from our user
CREATE LOGIN [domain\justin.dearing] FROM WINDOWS;
GO
-- Now we make him sysadmin
EXEC sp_addsrvrolemember
@rolename='sysadmin',
@loginame='domain\justin.dearing'
GO
@zippy1981
zippy1981 / States.Table.sql
Created Feb 17, 2011
Creates a table that lists state names and abbreviations.
View States.Table.sql
-- Created a simple table for storing state names and postal abbreviations.
SET NOCOUNT ON;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[States]') AND type in (N'U'))
DROP TABLE [dbo].[States]
GO
CREATE TABLE States (
Name varchar(30) NOT NULL, --The largest "state" name is 'FEDERATED STATES OF MICRONESIA' which is exactly 30 characters long
@zippy1981
zippy1981 / gist:841433
Created Feb 23, 2011
Using powershell to list particular files in svn.
View gist:841433
Add-Type -AssemblyName "System.Web"
# Powershell function to iterate through all the branches of a
# Visual Studio Solution in SVN, and return the file names in particular subfolders of the database project
# Assumes the command line svn client is in the system path
function Get-ReleaseScripts (
[string] $branchRoot,
[string] $subProject,
[string[]] $scriptFolders = ('Ad Hoc Scripts', 'Release Scripts')
) {
@zippy1981
zippy1981 / DEPLOY_SCRIPT.sql
Created Feb 24, 2011
T-SQL Script that adds CLR UDFs and Stored procs which do .NET config file editing in SQL server.
View DEPLOY_SCRIPT.sql
USE [master]
GO
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'TestAssembly')
BEGIN
ALTER DATABASE [TestAssembly] SET OFFLINE WITH ROLLBACK IMMEDIATE;
ALTER DATABASE [TestAssembly] SET ONLINE;
DROP DATABASE [TestAssembly];
END
GO
@zippy1981
zippy1981 / Atlantis.SchemaEngine.ps1
Created Feb 24, 2011
Experiments with he newly open sourced Atlantis.SchemaEngine.dll
View Atlantis.SchemaEngine.ps1
# Adjust these per your environment
[string] $AtlantisSchemaEngineBaseDir = 'F:\src\Atlantis.SchemaEngine\';
[string] $SqlServerInstance = 'localhost\SQLEXPRESS2k8R2';
[string] $dbName = 'master'
# This line works:
Add-Type -Path "$($AtlantisSchemaEngineBaseDir)\Atlantis.SchemaEngine\bin\Debug\Atlantis.SchemaEngine.dll"
[string] $cnStr = "Data Source=$SqlServerInstance;Initial Catalog=$dbName;Integrated Security=SSPI;";
@zippy1981
zippy1981 / 7zPath.pl
Created Mar 12, 2011
demonstrates how to get the path of 7zip from the registry
View 7zPath.pl
#!/usr/bin/perl
use strict;
use DateTime;
my $dt = DateTime->now();
# We can't call it $7zip because variable names can't begin with a number.
#my $lzexe;
my $lzexe = get7Zip();
View EnsureIndexBug.ps1
[string] $mongoDriverPath;
# Check to see if we are running the 64 bit version of Powershell.
# See http://stackoverflow.com/questions/2897569/visual-studio-deployment-project-error-when-writing-to-registry
if ([intptr]::size -eq 8) {
$mongoDriverPath = (Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v3.5\AssemblyFoldersEx\MongoDB CSharpDriver 1.0").'(default)';
}
else {
$mongoDriverPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\.NETFramework\v3.5\AssemblyFoldersEx\MongoDB CSharpDriver 1.0").'(default)';
}