Skip to content

Instantly share code, notes, and snippets.

@mrjk
Last active January 9, 2024 03:38
Show Gist options
  • Save mrjk/93b923ba97b71ca4226ac13048318685 to your computer and use it in GitHub Desktop.
Save mrjk/93b923ba97b71ca4226ac13048318685 to your computer and use it in GitHub Desktop.
Bash oneliners
# Other
# =========
# See .bashrc config: https://gist.github.com/mrjk/fdb73dc33cbc1c23e21010efc451cbdd
# See: .vimrc config: https://gist.github.com/mrjk/1d146a701b201e77279ea4e7c5d075a5
# See: bash library utils: https://gist.github.com/mrjk/31a2fb90c445fe516b0ae41eea7297ea
# Shell/Bash
# =========
# List all files by last modified
find . -printf "%T@ %Tc %p\n" | sort -n
# SSH
# =========
alias ssh_unsecure='ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null'
alias ssh_unsafe='ssh -oKexAlgorithms=+diffie-hellman-group1-sha1'
# Docker
# =========
# List all containers and their IPs
docker ps -q | xargs -n 1 docker inspect --format '{{ .Name }} {{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' | sed 's#^/##';
# Networking
# =========
# Webservers
python3 -m http.server 8000
python2 -m SimpleHTTPServer 8000
php -S 127.0.0.1:8000
busybox httpd -f -p 8000
ruby -run -ehttpd . -p8000
# Dhcp server on specific interface
sudo dnsmasq --interface=enp0s20f0u2 --dhcp-range=192.168.199.50,192.168.199.150,15m --port 5300 --no-daemon --log-debug
# TCP connection
nc ...
# Nmap
# =========
# Debug DHCP server
sudo nmap --script broadcast-dhcp-discover
# List offered SSH auth methods and keys
nmap --script ssh-auth-methods 192.168.1.2
nmap --script ssh-hostkey 192.168.1.2
# Show SSL certificate
nmap --script ssl-cert 8.8.8.8
nmap --script ssl-enum-ciphers 8.8.8.8
# All other available scripts:
nmap --script-help all
# Converters
# =========
# yaml2json
python3 -c 'import sys, yaml; yaml.dump(yaml.safe_load(sys.stdin), sys.stdout)'
# Ideas/TODO:
# =========
# https://www.digitalocean.com/community/tutorials/how-to-use-netcat-to-establish-and-test-tcp-and-udp-connections
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment