Living Inside the Command Line
Introduction
This post is to document the usage of Linux command line tools. Normal command line tools not security tools since security tools will have separate post.
Tools list:
- lsof
- ps
- tar
- socat (I’m really confused if this should be security or normal tool)
Socat
Socat is a unix tool, used for bidirectional communication, taking a simple look at man socat you will see a mountain of options, so lets keep it simple and compare it to something like netcat
TCP client
netcat
nc localhost 80
socat
socat TCP4:localhost:80
socat STDIN TCP4:localhost:80
TCP client with SSL
openssl
openssl s_client -connect server:443
socat
socat - OPENSSL:localhost:443
TCP server
netcat
nc -lp localhost 700
socat
socat TCP4-LISTEN:700 STDOUT
Spawn a Shell
netcat
nc -lp localhost 700 -e /bin/bash
socat
socat TCP4-LISTEN:700 EXEC:/bin/bash
TCP server with SSL
Generate certificate
openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.key
OpenSSL
openssl s_server -accept 8080 -key key.pem -cert cert.pem
socat
socat OPENSSL-LISTEN:443,cert=/cert.pem -
socat TCP4-LISTEN:5000,fork OPENSSL:localhost:443
Reverse proxy
Assuming there is a service listing on 127.0.0.1:8080 Acting as reverse proxy, redirecting all traffic hitting port 5000 to local connection 127.0.0.1:8080
socat TCP4-LISTEN:5000,fork TCP4:127.0.0.1:8080