Skip to content

Instantly share code, notes, and snippets.

@Alives
Alives / rdp_10_yr.ps1
Created April 15, 2022 14:23
Set a 10 year self-signed RDP (Remote Desktop) cert
$date_now = Get-Date
$extended_date = $date_now.AddYears(10)
$cert = New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -notafter $extended_date -dnsname <your dns name> -KeyAlgorithm RSA -KeyLength 4096
Get-ChildItem -Path Cert:LocalMachine\MY | Select-Object FriendlyName, Thumbprint, Subject, NotBefore, NotAfter
wmic /namespace:\\root\cimv2\TerminalServices PATH Win32_TSGeneralSetting Set SSLCertificateSHA1Hash="<your thumbprint>"
@Alives
Alives / 256colors.py
Created February 11, 2022 17:34
Generate all 256 Foreground and Background terminal colors with codes
#!/usr/bin/env python
# Original Author of the perl script: Todd Larason <[email protected]>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
import sys
RESET = "\x1b[0m"
LAYERS = {38: 'foreground', 48: 'background'}
def bg(layer, color):
#!/usr/bin/python3
import json
import os
import subprocess
import sys
import time
def get_container_name():
@Alives
Alives / pfsense_backup.sh
Created January 7, 2019 21:04
pfsense backup script - Change constants at the top
#!/bin/bash
set -eo pipefail
PFSENSE_HOSTNAME=pfsense
DIR=/var/run/user/$(/usr/bin/id -u)/pfsense_backup
FILENAME=/root/backup/pfsense/config-pfsense-$(/bin/date +%Y%m%d_%H%M%S).xml
URL=https://pfsense.eyyit.com/diag_backup.php
CREDS=/root/creds/pfsense
LOGIN=$(/usr/bin/awk -F= '/login/ {print $NF}' $CREDS)
PASSWORD=$(/usr/bin/awk -F= '/password/ {print $NF}' $CREDS)
@Alives
Alives / lsyncd.service
Created August 28, 2017 19:49 — forked from sunsongxp/lsyncd.service
systemd-service file for lsyncd
[Unit]
Description=Live Syncing (Mirror) Daemon
After=network.target
[Service]
Restart=always
Type=simple
Nice=19
#EnvironmentFile=-/etc/default/lsyncd
#ExecStart=/usr/bin/sh -c 'eval `/usr/bin/lsyncd -nodaemon $LSYNCD_OPTIONS /etc/lsyncd/lsyncd.conf.lua`'
@Alives
Alives / multi
Last active October 7, 2016 22:27
function multi {
cmd=$1
shift
while [[ $cmd = "ssh" ]]; do
pre_check="$(echo $@ | tr ' ' '\n' | sed -e 's/^.*@//g' | \
xargs nmap -p 22 -PN -oG - | grep Port | grep -v open)"
test "${pre_check}x" != "x" && (clear; echo "$pre_check") || break
done
tmux send-keys -t 0 "$cmd ${@[1]}"
for ((pane = 1; pane < ${#@[@]}; pane++)); do