Skip to content

Instantly share code, notes, and snippets.

@tclancy
tclancy / expire_all_sessions.py
Last active May 9, 2022 12:07 — forked from playpauseandstop/gist:1818351
Django management command to expire all sessions
import datetime
from django.conf import settings
from django.contrib.auth import logout
from django.contrib.auth.models import User
from django.contrib.sessions.models import Session
from django.core.management.base import NoArgsCommand
from django.http import HttpRequest
from django.utils.importlib import import_module
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@NickTyrer
NickTyrer / fsharp.fsscript
Created September 3, 2017 09:19
fsi.exe inline execution
#r @"C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll"
open System.Management.Automation
open System.Management.Automation.Runspaces
open System
let runSpace = RunspaceFactory.CreateRunspace()
runSpace.Open()
let pipeline = runSpace.CreatePipeline()
@curi0usJack
curi0usJack / .htaccess
Last active July 9, 2024 18:38
FYI THIS IS NO LONGER AN .HTACCESS FILE. SEE COMMENTS BELOW. DON'T WORRY, IT'S STILL EASY.
#
# TO-DO: set |DESTINATIONURL| below to be whatever you want e.g. www.google.com. Do not include "http(s)://" as a prefix. All matching requests will be sent to that url. Thanks @Meatballs__!
#
# Note this version requires Apache 2.4+
#
# Save this file into something like /etc/apache2/redirect.rules.
# Then in your site's apache conf file (in /etc/apache2/sites-avaiable/), put this statement somewhere near the bottom
#
# Include /etc/apache2/redirect.rules
#
@xpn
xpn / clr_via_native.c
Created April 11, 2018 21:34
A quick example showing loading CLR via native code
#include "stdafx.h"
int main()
{
ICLRMetaHost *metaHost = NULL;
IEnumUnknown *runtime = NULL;
ICLRRuntimeInfo *runtimeInfo = NULL;
ICLRRuntimeHost *runtimeHost = NULL;
IUnknown *enumRuntime = NULL;
LPWSTR frameworkName = NULL;
@khr0x40sh
khr0x40sh / Get-VBACHRObfuscatedString.ps1
Created November 19, 2019 15:36
Takes a string and applies CHR(ascii int) & for each character in string
Param([string]$string = "C:\windows\syswow64\windowspowershell\v1.0\powershell.exe -exec Bypass -nop ping 127.0.0.1"
);
$result = ""
$strA = $string.ToCharArray()
for($i = 0; $i -lt $strA.Length; $i++)
{
$x = [byte]$strA[$i]
$result += "Chr (" + $x.ToString() + ") & "
}
@rxwx
rxwx / offver.py
Created April 15, 2020 10:23
Get Office version that last saved the file
import re
import sys
versions = {
0x00: 'Excel 97',
0x01: 'Excel 2000',
0x02: 'Excel 2002',
0x03: 'Office Excel 2003',
0x04: 'Office Excel 2007',
0x06: 'Excel 2010',
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
namespace InjectionTest
{
public class DELEGATES
{
@med0x2e
med0x2e / steps.txt
Last active September 18, 2021 19:58
Steps to run GadgetToJScript on linux (wine)
Steps:
1- apt-get install mono-complete
2- apt-get install wine winetricks -y
3- winetricks dotnet35
4- winetricks dotnet48
5- dpkg --add-architecture i386 && apt-get update && apt-get install wine32
6- rm -Rf ~/.wine
7- WINEPREFIX=~/.wine32 WINEARCH=win32 wineboot
8- wine GadgetToJScript.NET3.5.exe -r -c helloworld.cs -d System.Windows.Forms.dll -w hta -o hello
@kafkaesqu3
kafkaesqu3 / microsoft-wordlist.txt
Last active September 15, 2023 22:09
microsoft auth endpoint wordlist
/_windows/default.aspx?ReturnUrl=/
/abs
/abs/
/adfs/ls
/adfs/ls/wia
/adfs/services/trust/13/windows
/adfs/services/trust/13/windowsmixed
/adfs/services/trust/13/windowstransport
/adfs/services/trust/2005/windows
/adfs/services/trust/2005/windowsmixed