Skip to content

Instantly share code, notes, and snippets.

import binascii
import re
def rtf_to_text(rtf):
def clear_cmd(rtf_parsed):
if rtf_parsed.get("cmd") == "f" and rtf_parsed.get("lvl") == 1:
encoding = rtf_parsed.get("fonts").get(rtf_parsed.get("cmd") + rtf_parsed.get("arg"), {}).get("encoding", "1252")
rtf_parsed["encoding"] = encoding
elif rtf_parsed.get("cmd") == "ansicpg":
import hashlib
import lxml.etree as ET
import olefile
import magic
from io import BytesIO
from oletools import oleobj
from oletools.olevba3 import VBA_Parser
from operator import itemgetter
from zipfile import ZipFile
import hashlib
from io import BytesIO
from zipfile import ZipFile
from operator import itemgetter
def read_zip(contentBytes):
zip_metadata = dict()
file_list = None
errors = None
import magic
def read_magic(contentBytes):
magicType = None
try:
with magic.Magic() as m:
magicType = m.from_buffer(contentBytes)
except Exception as e:
print("libmagic")
print(str(e))
def parse_chunked(data):
result = b""
state = "header"
while data:
if state == "header":
chunk, data = data.split(b"\r\n", 1)
length = int(chunk.strip(), 16)
if length == 0:
state = "finished"
else:
import pathlib
import cgi
def parse_multipart(data, headers):
result = list()
content_type, options = cgi.parse_header(headers.get("Content-Type"))
if options.get("boundary") is not None:
result = data.split(b"--" + options.get("boundary").encode())
for r in result[1:]:
$CaView = New-Object -Com CertificateAuthority.View.1
[void]$CaView.OpenConnection("SERVER\CA")
$templates = @{}
Get-ADObject -SearchBase (Get-ADRootDSE).ConfigurationNamingContext -filter {objectclass -eq "pKICertificateTemplate"} -Properties "CN", "DisplayName", "msPKI-Cert-Template-OID" | %{ $templates.add($_."msPKI-Cert-Template-OID",$_."DisplayName") }
$columns = @(
"Binary Certificate",
"Certificate Effective Date",
"Certificate Expiration Date",
Verifying that "ctkirkman.id" is my Blockstack ID. https://onename.com/ctkirkman

Keybase proof

I hereby claim:

  • I am ctkirkman on github.
  • I am ctkirkman (https://keybase.io/ctkirkman) on keybase.
  • I have a public key whose fingerprint is A8A3 C930 7CB1 C2E9 B956 6E83 1F60 624E 8725 25D6

To claim this, I am signing this object:

function Get-SPSiteList {
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)][ValidateNotNullOrEmpty()]
[String]$WebAppUrl
)
process {
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($WebAppUrl)
$q = new-object Microsoft.SharePoint.Client.Search.Query.KeywordQuery($ctx)
$q.QueryText = "ContentClass=STS_Site"
$se = new-object Microsoft.SharePoint.Client.Search.Query.SearchExecutor($ctx)