Skip to main content

Shell

find exposed ports:
netstat -lntu
ss -lntu
find process on port
lsof -nP -iTCP -sTCP:LISTEN | grep <port-number>
try to find error logs of some running process
#find PID
ps aux | grep httpd
#PID -> 1234
#then find open log files with lsof
lsof -p 1234 | grep log
apply command to several items
echo {1..4} | xargs -n1 -I{} ssh root@www{}.example.com hostname
recursive search in files
grep -r "searchterm"
# recursive search with maxdepth
find . -maxdepth 5 -type d | grep "searchterm"
OpenSSL
#generate private key
openssl genrsa -out key.pem 4096
#generate key and self-signed cert
openssl req -x509 -newkey rsa:4096 -keyout demo_ca_key.pem -out demo_ca_cert.pem -nodes -days 365
#generate key and certificate signing request
openssl req -x509 -newkey rsa:4096 -keyout demo_ca_key.pem -out demo_ca_cert.pem -nodes -days 365
#sign certificate
openssl x509 -req -in demo_csr.pem -CA demo_ca_cert.pem -CAkey demo_ca_key.pem -out demo_cert.pem -set_serial 01 -days 365