Skip to the content.

Handcrafted guides for doing infosec and things

zsh < command line interpreter CLI

Environment variables in Unix-like shell

Environment is any given [shell] and variable name eg. ´PATH´

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/system/Library/
echo $PATH
/Users/username/.nvm/versions/node/v16.13.2/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/...

~/.ssh/config

GNU Core Utilities

brew install coreutils #macos

shred -uvz ~/Downloads/export.xml

-u -> remove file after overwriting
-v -> verbose output
-z -> add a final pass of zeros

Windows Terminal

|clip #copy to clipboard

wsl2

Azure Cloudshell setup

Goal

PS /home/contoso> Connect-AzureAD
PS /home/contoso> Get-AzureADUser -ObjectId 'first.last@domain.com'

Cloudshell profile

followed a reputable guide

#returns False because no profile exists
$profile
Test-Path $profile

Create profile.ps1 to GitHub repo

function Show-HelloWorld {
    Write-Host "hello, world!"
}

Loading the profile with Set-Profile.ps1

# $profilePath contains URL to profile.ps1
$profilePath = 'https://raw.githubusercontent.com/joll3/azure/master/profile.ps1'
# New random GUID to prevent web client from caching file
$downloadString = '{0}?{1}' -f $profilePath, (New-Guid)
# Download profile.ps1 as string and execute to load into runspace
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString($profilePath))

Download Set-Profile.ps1 and pipe to Set-Content cmdlet to override profile

(New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/joll3/azure/Set-Profile.ps1') | Set-Content $profile -Force
. $profile

markdown formatting

Git(hub)

Tldr. Gitlab and Github are competitors, with open source code manager Git as part of their offering. Interview with Git creator Linus Torvalds, who used BitKeeper before creating the first “useful for him” build in 10 days. BitKeeper had open source license disagreements and controversies which lead Linus to create git.

Two decades of Git: A conversation with creator Linus Torvalds

Github guides

Git Magic Guide - recommended reading to learn git

macOS Git setup

git --version

git version 2.39.3 (Apple Git-145)

which git

/usr/bin/git < executable run from this location

brew install git and update symlinks/files with brew link --overwrite git
which git to confirm executable

/opt/homebrew/bin/git

Adding global .gitignore file with git config --global core.excludesFile '~/.gitignore' > create file and append .DS_Store as new line. This changes settings in user specific ~/.gitconfig file.

git config --global user.email "5497641+joll3@users.noreply.github.com"

git config --global user.name "joll3"

Github guide for SSH authentication

  1. generate keypair
  2. ssh-add add keys to ssh-agent and passphrase to keychain
  3. verify connection

Check for existing SSH keys ls -al ~/.ssh if none are usable generate new SSH key pair ssh-keygen -t ed25519 -C "your_email@example.com", add public key to target service (github.com).

Starting SSH agent in shell session with eval "$(ssh-agent -s)" prints out PID of SSH agent. SSH agent is background process that manages and provides SSH keys to SSH client programs. This helps avoid having to enter SSH passphrase repeatedly.

Adding SSH private key to ssh-agent and store passphrase in keychain ssh-add --apple-use-keychain ~/.ssh/id_ed25519

and then appending ~/.ssh/config with settings for each host.

Host github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519

Changing passphrase for existing private key ssh-keygen -p -f ~/.ssh/id_ed25519 requires current passphrase.

New cryptographically secure passphrase generation straight to clipboard env LC_CTYPE=C tr -dc "a-zA-Z0-9-_\$\?" < /dev/urandom | head -c 22 | pbcopy for easy entry.

Verify connection with ssh -T git@github.com

Github CLI not useful or installed

gh --version`  - outputs executable for `GitHub CLI`
> `zsh: command not found: gh

Git Credential Manager

Provides consistent and secure authentication experience, including multi-factor auth, to every source control hosting service. Not required, not used. Storing SSH keys locally for persistent connection.

Secure Git credential helper built on .NET that runs on Windows, macOS, and Linux. It aims to provide a consistent and secure authentication experience, including multi-factor auth, to every major source control hosting service and platform.

BFG Repo-Cleaner - #Github secrets leak

  1. copy/download bfg-x.yy.z.jar to working directory

  2. Create strings.txt which lists sensitive strings

  3. java -jar ./bfg-1.14.0.jar --replace-text strings.txt
    

Background

Git free open source distributed version control, with a branching model. Other alternative source code manager (SCM) tools (version control systems (VCS)) exist but are not relevant. Git is inherently local and can be hosted by anyone, since its open source.

Github is a company bought by Microsoft for $7.5 billion worth of Microsoft stock in 2018.

GitLab is a 1600 person software company, first unicorn company from Ukraine 🇺🇦. Featured in the Gartner® “DevOps Platforms report”. Offerings include www.gitlab.com SaaS and Self-Managed subscription

DuckDuckGo email protection

Favicon .svg icons

Workflow for importing proper custom favicons to RaivoOTP (deprecated) application.

to see and edit .svg XML source in browser view-source:file:///{path}sf_mark_primary.svg

Favicon

AdoptOpenJDK - opensource JDK

Microsoft / Azure administrator

Microsoft Remote Connectivity Analyzer

SIEM for homelab

LAN networking

Local device configuration or router settings (e.g. multicast DNS, local DNS Record) will determine if LAN devices are able to network together.

What is the difference between hostname.local || hostname.localdomain?

E.g. raspberrypi.local is controlled by the Raspberry Pi client itself through mDNS (multicast DNS) with built-in avahi-daemon.

Avahi is GNU implementation for zeroconf networking (multicast DNS, DNS Service Discovery). Apple has implemented mDNSResponder as Bonjour. Apple uses less open Apache License compared to LGPL (GNU Lesser General Public License).

Avahi implements the Apple Zeroconf specification, mDNS, DNS-SD and RFC 3927/IPv4LL. Other implementations include Apple’s Bonjour framework (the mDNSResponder component of which is licensed under the Apache License).

Avahi provides a set of language bindings (Python, Mono, etc.) and ships with most Linux and BSD distributions. Because of its modularized architecture, major desktop components like GNOME Virtual file system and KDE input/output architecture already integrate Avahi.

DNS

Everything that can affect DNS:

Operating System Settings -> network adapter, SSID, wifi -> iCloud Private Relay -> VPN -> Browser

Pandoc markdown > pdf

pandoc file1.md -o fil1.pdf

WSL Ubuntu Docker

sudo dockerd #start docker daemon with sudo priviledges

Chromium

chrome://flags

QUIC

Created by Google in 2012. QUIC is a transport layer protocol, using HTTP/3 multiplexed connections over UDP. In contrast HTTP/2 is based on stateful TCP connections. Supports encrypted HTTP traffic in a similar role to TCP, with reduced latency and more efficient loss recovery.

Blocking Google QUIC traffic with firewall e.g. Little Snitch is almost impossible. Created blocklist.txt which had no effect on QUIC connections to youtube.com.

certificates

openssl x509 -in /path/to/certificate.crt -text -noout - check certificate details

certificates for ZScaler

regex

Sharepoint admin

test