The Book of Secret Knowledge
repository·master·Indexed 11 days ago
https://github.com/trimstray/the-book-of-secret-knowledgeA community-driven repository of technical resources, including cheatsheets, manuals, and tools for DevOps, Security, and System Administration. It provides curated lists of shells, terminal managers, network diagnostics, DNS tools, HTTP benchmarking, SSL/TLS management, and system hardening utilities.
What's inside The Book of Secret Knowledge
- The Book of Secret Knowledge is a curated collection of inspiring lists, manuals, cheatsheets, blogs, hacks, one-liners, CLI/web tools, and other technical resources. It is designed as a centralized knowledge base for professionals in fields such as System and Network administration, DevOps, Penetration Testing, and Security Research.
Explore Curated Learning Resources
masterThe Book of Secret Knowledge provides a collection of external links and resources categorized by domain to help developers and security professionals deepen their knowledge. These include:
- CTF & Security: Vulnerable machine steps, CTF writeups, low-level challenge archives, and guides for Reverse Engineering/Malware analysis.
- Networking & Web: Explanations of the C10K problem, MTU (Maximum Transmission Unit), HTTPS implementation, BGP (Border Gateway Protocol), DNS, and the 'What happens when you type a URL' flow.
- Systems & Low-Level: CPU operation costs, building a simple database (SQLite clone), computer simulation, and SHA-256 algorithm visualizations.
- Troubleshooting & Postmortems: Linux troubleshooting guides, the 'Five Whys' process for root cause analysis, and real-world postmortems of database and NFS outages.
Make HTTP requests with `curl`
masterBasic Request with Headers
Show response headers only, silently, ignoring SSL errors:
curl -Iks https://www.google.com-I: Show response headers only.-k: Insecure connection (ignore SSL).-s: Silent mode.
Advanced Request with Redirects and User-Agent
curl -Iks --location -X GET -A "x-agent" https://www.google.com--location: Follow redirects.-X: Set HTTP method.-A: Set User-Agent.
Request with Proxy
curl -Iks --location -X GET -A "x-agent" --proxy http://127.0.0.1:16379 https://www.google.com--proxy [socks5://|http://]: Set proxy server.
Resume a download
curl -o file.pdf -C - https://example.com/Aiju2goo0Ja2.pdf-o: Write output to file.-C: Resume the transfer.
Find external IP address
curl ipinfo.io curl ipinfo.io/ip curl icanhazip.com curl ifconfig.me/ip ; echoRepeat URL requests
Using brace expansion:
curl -ks https://example.com/?[1-20]Using a shell loop:
for i in {1..20} ; do curl -ks https://example.com/ ; doneSterilize Bash history to remove credentials
masterUse the following function to clean your bash history of sensitive information like
curltokens, passwords, and proxy credentials. You can export it to run automatically viaPROMPT_COMMAND.function sterile() { history | awk '$2 != "history" { $1=""; print $0 }' | egrep -vi "\ curl\b+.*(-E|--cert)\b+.*\b*|\ curl\b+.*--pass\b+.*\b*|\ curl\b+.*(-U|--proxy-user).*:.*\b*|\ curl\b+.*(-u|--user).*:.*\b*\ .*(-H|--header).*(token|auth.*)\b+.*|\ wget\b+.*--.*password\b+.*|\ http.?://.+:.+@.*\ " > $HOME/histbuff; history -r $HOME/histbuff; } export PROMPT_COMMAND="sterile"Test network connectivity and sockets
masterTest remote connection to a port
Use
timeoutto check if a TCP or UDP port is reachable:timeout 1 bash -c "</dev/<proto>/<host>/<port>" >/dev/null 2>&1 ; echo $?<proto>:tcporudp.
Read/Write to sockets using Bash
exec 5<>/dev/tcp/<host>/<port>; cat <&5 & cat >&5; exec 5>&-timeout 1 bash -c "</dev/tcp/google.com/80" >/dev/null 2>&1 ; echo $?Subscribe to updates via RSS
masterTo stay informed about changes and new additions to the repository, you can subscribe to the GitHub commit RSS/Atom feed:https://github.com/trimstray/the-book-of-secret-knowledge/commits.atomManipulate stdout and stderr in Bash
masterUse process substitution to pipe
stdoutandstderrto different commands simultaneously.To redirect both to separate files while still printing both to the screen, use a combination of
teeand file descriptor redirection.# Pipe stdout and stderr to separate commands some_command > >(/bin/cmd_for_stdout) 2> >(/bin/cmd_for_stderr) # Redirect stdout and stderr each to separate files and print both to the screen (some_command 2>&1 1>&3 | tee errorlog ) 3>&1 1>&2 | tee stdoutlogUse `dd` for data copying and redirection
masterShow progress during
ddoperationsSince
ddis often silent, you can view progress by sending aUSR1signal to the process:dd <dd_params> status=progress watch --interval 5 killall -USR1 ddRedirect output to a file
echo "string" | dd of=filenamedd <dd_params> status=progressCommon Bash file and directory operations
masterQuick snippets for common filesystem tasks:
- Backup a file:
cp filename{,.orig} - Empty/Truncate a file:
>filename - Delete files not matching an extension:
rm !(*.foo|*.bar|*.baz) - Pass multi-line string to a file: Use
cat << __EOF__(overwrites) orcat >> filename << __EOF__(appends). - Edit remote file via vim:
vim scp://user@host//etc/fstab - Create and enter directory:
mkd() { mkdir -p "$@" && cd "$@"; } - Rename uppercase to lowercase:
rename 'y/A-Z/a-z/' *
# Quickly backup a file cp filename{,.orig} # Empty a file (truncate to 0 size) >filename # Delete all files in a folder that don't match a certain file extension rm !(*.foo|*.bar|*.baz) # Pass multi-line string to a file cat > filename << __EOF__ data data data __EOF__ # Edit a file on a remote host using vim vim scp://user@host//etc/fstab # Create a directory and change into it at the same time mkd() { mkdir -p "$@" && cd "$@"; } # Convert uppercase files to lowercase files rename 'y/A-Z/a-z/' *- Backup a file:
Manage SSH connections and authentication
masterSSH Escape Sequences
While in an active session, use
~followed by a character:~.: Terminate connection.~B: Send a BREAK to the remote system.~C: Open a command line.~R: Request rekey (SSH protocol 2 only).~^Z: Suspend SSH.~#: List forwarded connections.~&: Background SSH.~~: Send the escape character itself.
Compare remote and local files
ssh user@host cat /path/to/remotefile | diff /path/to/localfile -SSH through a jump host
ssh -t reachable_host ssh unreachable_hostRun a command on a remote host via file input
cat > cmd.txt << __EOF__ cat /etc/hosts __EOF__ ssh host -l user $(<cmd.txt)Key Management
- Get public key from private key:
ssh-keygen -y -f ~/.ssh/id_rsa - List all fingerprints in known_hosts:
ssh-keygen -l -f .ssh/known_hosts
Explicit Authentication Methods
- Password only:
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no user@remote_host - Publickey only:
ssh -o PreferredAuthentications=publickey -o PubkeyAuthentication=yes -i id_rsa user@remote_host
Port Forwarding
Local Port Forwarding (Access remote service via local port):
# Forward local 2250 to remote nmap.org:443 ssh -L 2250:nmap.org:443 localhostRemote Port Forwarding (Expose local service to remote host):
# Forward local 9051 to remote db.d.x:5432 through node.d.y ssh -nNT -R 9051:db.d.x:5432 node.d.y-n: Redirect stdin from/dev/null.-N: Do not execute a remote command.-T: Disable pseudo-terminal allocation.
ssh -L 2250:nmap.org:443 localhostBuild your own System or Virtual Machine
masterResources for low-level systems programming and OS development:
- OS Development: Tutorials on creating an OS from scratch and the 'little book' about OS development.
- Virtual Machines: Guides on how to write your own virtual machine (VM).
- x86 Bare Metal: Minimal operating system examples for learning x86 system programming.
- CPU Architecture: Implementation of the Scott CPU from "But How Do It Know?".
Build your own Certificate Authority
masterMethods for creating your own Certificate Authority (CA):
- OpenSSL: Use OpenSSL tools to build a custom CA.
- step-ca: Use the open-source
step-caproject to build a custom CA.