Skip to content

Instantly share code, notes, and snippets.

@chadmando
chadmando / README.md
Created May 6, 2017 14:01 — forked from ovarunendra/README.md
rest-api using node.js and sqlite3
@chadmando
chadmando / submit-to-urlscan.ps1
Last active January 13, 2020 21:20
PowerShell snippet for submitting to urlscan.io - By Nicholas Gipson -- Modified
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$uri = "https://urlscan.io/api/v1/scan/"
$apikey = #insert secure method to retreive api key
$url = #insert suspect url here
$header = @{
"API-Key" = $apikey
}
$body = @{
"url"=$url
@chadmando
chadmando / ConnectingToAzureSQLFromPython
Created April 20, 2021 22:04 — forked from timmyreilly/ConnectingToAzureSQLFromPython
Using Flask_SQLAlchemy to connect to Azure SQL
#!/usr/bin/env python
import os
import urllib.parse
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
# Configure Database URI:
params = urllib.parse.quote_plus("DRIVER={SQL Server};SERVER=sqlhost.database.windows.net;DATABASE=pythonSQL;UID=username@sqldb;PWD=password56789")
@chadmando
chadmando / ohmyposhv3-v2.json
Created September 2, 2021 14:17 — forked from shanselman/ohmyposhv3-v2.json
ohmyposhv3-v2
{
"final_space": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,
@chadmando
chadmando / brew-install-script.sh
Last active September 17, 2021 17:33 — forked from CliffordAnderson/brew-install-script.sh
Brew script for installing packages and applications on OSX
#!/bin/sh
# Homebrew Script for OSX
# To execute: save and `chmod +x ./brew-install-script.sh` then `./brew-install-script.sh`
echo "Installing brew..."
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo "Installing brew cask..."
brew tap homebrew/cask
@chadmando
chadmando / powershell-web-server.ps1
Created February 28, 2022 22:30 — forked from 19WAS85/powershell-web-server.ps1
A simple web server built with powershell.
# This is a super **SIMPLE** example of how to create a very basic powershell webserver
# 2019-05-18 UPDATE — Created by me and and evalued by @jakobii and the comunity.
# Http Server
$http = [System.Net.HttpListener]::new()
# Hostname and port to listen on
$http.Prefixes.Add("http://localhost:8080/")
# Start the Http Server
@chadmando
chadmando / Test-SelectStringExamples.ps1
Created April 12, 2022 20:50 — forked from markwragg/Test-SelectStringExamples.ps1
Powershell uses of Select-String to filter a log file and example Regular Expressions for identifying IP addresses and IP spaces
#This regex matches anything that's like an IP address (even invalid ones)
$regexIPAddress = '\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b'
#This regex matches anything like an IP address that starts 10, 172 or 192
$regexIPSpace = '(10|172|192).\d{1,3}\.\d{1,3}\.\d{1,3}\b'
#Returns the first IP address in each line of the log file/s then sorts and removes duplicates.
Select-String -Path *.log -Pattern $regexIPAddress | ForEach-Object { $_.Matches } | % { $_.Value } | Sort-Object -Unique | Out-File 'UniqueIPs.txt'
#Returns from a selection of Log files any lines which match a certain string pattern
@chadmando
chadmando / SimulateInternetZoneTest.ps1
Created April 20, 2022 19:06 — forked from mgraeber-rc/SimulateInternetZoneTest.ps1
Example highlighting why attackers likely choose ISO/IMG as a delivery mechanism - it evades SmartScreen because Mark-of-the-Web (MOTW) cannot be applied to non NTFS volumes
Add-Type -OutputAssembly hello.exe -TypeDefinition @'
using System;
public class Hello {
public static void Main(string[] Args) {
System.Console.WriteLine("Hello, world!");
System.Console.Read();
}
}
'@
@chadmando
chadmando / About Batch and PowerShell.md
Created June 21, 2022 18:35 — forked from Jaykul/About Batch and PowerShell.md
Executable PowerShell (wrap a ps1 and name it cmd)

This is always my answer to all those "compile your .ps1" solutions that are floating around. Why would you wrap your PowerShell in an exe and some custom host?

Just paste this header on the top of your PowerShell script, and then before you share it, rename it with the .cmd extension. While you're writing, it's a nice syntax-highlighted PowerShell script, and when you rename it, *poof* it's double-clickable. Drop it in the PATH and you can execute it from the Run dialog or from PowerShell, batch, whatever.

Because there are still people around who actually use CMD, I've updated it to show how to handle passing parameters.

A couple of notes:

  1. It runs with ExecutionPolicy unrestricted because if you're still using CMD you probably haven't configured your ExecutionPolicy
  2. It uses -NoProfile to make sure the environment is the same on everyone's PC...
  3. It only creates function :: {} because that allows us to ignore the :: on the first line
@chadmando
chadmando / New-EXOPSSession.ps1
Created September 20, 2022 19:05 — forked from jborean93/New-EXOPSSession.ps1
Cross platform function that can connect to Exchange Online using modern auth
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
#Requires -Module MSAL.PS
Function New-EXOPSSession {
<#
.SYNOPSIS
Will open a PSSession to Exchange Online.