Skip to content

Instantly share code, notes, and snippets.

@NicholasLeader
NicholasLeader / ExternalipIpyifyAPI.py
Created November 22, 2023 17:18
Return External IP via Ipify API python example
# returns your current public / external IP via querying API
# Adapted from code ipify code samples: https://www.ipify.org/
# May need to install 'requests' manully via PIP etc, as 'requests' isn't install by default with python
# console clear method - avoids another import https://stackoverflow.com/questions/72105595/clearing-console-in-python
import requests
ip = requests.get('https://api.ipify.org').text
# clearing the console output
print("\033c", end='')
@NicholasLeader
NicholasLeader / RoomRandomPickup.py
Created November 13, 2023 21:10
Randomly return an item from an array / list in Python
import secrets
import datetime
today = datetime.date.today()
roomcleantasks = ["trash","books","stuffies","coloringbooks/magazines","clothes"]
print("")
print("For" + " " + str(today) + ", " + "Please pick-up" + " " + secrets.choice(roomcleantasks) + "!")
print("")
@NicholasLeader
NicholasLeader / ADuser.cross.lookup.ps1
Created October 3, 2022 17:07
PowerShell to look up details between 2 user accounts that are similarly named / contains same substring - using split & calculated property
<#
Nicholas Leader
10.03.2022
script to:
pull AD accounts with a preceding 'a-', that are enabled
@NicholasLeader
NicholasLeader / ADgroup_random_sort.ps1
Created October 27, 2021 17:31
PowerShell get an AD group and random sort it by name
# Nicholas Leader
# 10.27.2021
# AD group random sort
(Get-ADGroupMember 'Name_of_AD_group).name | sort-object -property {get-random}
@NicholasLeader
NicholasLeader / ADusersMemberOfFilteredGroup.ps1
Created June 9, 2020 16:26
PowerShell example of script to determine details of a set of AD users, given an AD group filter
<# Nicholas Leader
6.9.2020
Report on AD users that belong to certain AD groups
Including manager details
#>
#date stamp in string
$DateStamp = get-date -Format MM.dd.yyyy.mm
#What group you're looking for
@NicholasLeader
NicholasLeader / Lamda_Python_Push_HTTP_header_PoC.tf
Created September 3, 2019 15:58
Terraform PoC to deploy AWS Lamda Python function and API
### Nicholas Leader
### 8.19.2019
### Terraform main config for Lamda function with API
### see Python file for details on the actual function
### requires the API Terrform config as well.
### Terraform script expects Python file to be in S3 bucket
# Configure the AWS Provider
# credential reference https://www.terraform.io/docs/providers/aws/index.html#authentication
# API / Lamda reference https://learn.hashicorp.com/terraform/aws/lambda-api-gateway
@NicholasLeader
NicholasLeader / SSL_TLS_cert_CN_pull_via_NMAP.ps1
Last active September 3, 2019 12:47
PowerShell PoC to grab the 'CN' common name of the SSL/TLS cert of an IP - leveraging NMAP SSL-cert script
<#
Nicholas Leader
9.3.2019
PowerShell PoC to grab the 'CN' common name of the SSL/TLS cert of an IP
Script takes an array of IPs as input in the script, but could be modified to pull from a CSV, etc
Script is leveraging 'Invoke-Command' to run an NMAP script
Using 'Select-string' to pull the relevent line of the NMAP script output
Requires:
@NicholasLeader
NicholasLeader / HTTP_Security_Header_check_Python_AWS_Lamda_PoC.py
Created August 15, 2019 18:54
This Python AWS Lamda function, returns True / False if a given AWS API query parameter (URL) has an HTTP security CSP header present
### Nicholas Leader
### Python PoC given AWS API query parameter of URL, return if HTTP security header CSP policy is present
### Written as AWS Lamda (serverless) function
### 8.14.2019
###
import json
def lambda_handler(event, context):
import urllib.request
input = event["queryStringParameters"]['URL']
###
# Nicholas Leader
# 8.9.2019
# Check for the presence of HTTP Security headers - CSP or Content-Security-Policy in this example
#
# Dictionary calling idea from: https://stackoverflow.com/questions/39090323/how-to-check-if-response-header-contains-certain-headers-powershell
#
###
### set Connection to use TLS 1.2
<#
Nicholas Leader
09.08.2018
Merging 2 sets of data with compare-object lookup.
List of servers and adding columns to the CSV from a AV CSV
This script returns *all* data elements from both CSVs, rather than just from 1 CSV with compare-object
#>
#date stamp in string