Linux / WindowsMain commands
Linux main commands in OSCP
Find:
find / -name file 2>/dev/null
ls -ltr - Sort list by last modified. -time -reverse
# Remove recursively and its content. Very dangerous command!
rm -rf ./directory
List what rights the sudo user has.
sudo -l
# This will send all permissions denied outputs to dev/null.
find / -name file 2>/dev/null
Which
Outputs the path of the binary that you are looking for. It searches through the directories that are defined in your $PATH variable.
which bash
# Usually outputs: /bin/bash
Filters
#sort
sort test.txt
#uniq
sort -u test.txt
sort test.txt | uniq
cat filename | sort -u > newFileName
grep
head
tail
tr
sed
sed "1d"
#cut :
64 bytes from 192.168.0.1: icmp_req=1 ttl=255 time=4.86 ms
cut -d" " -f4
-d stands for delimiter. and -f for field.
tr - Translate
Transform all letter into capital letters
tr "[:lower:]" "[:upper:]" < file1 > file2
Remove character
# Remove characters
cat file.txt | tr -d "."
# Remove all dots and replace them with underscore.
cat file.txt | tr "." "_"
awk
awk '/search_pattern/ { action_to_take_on_matches; another_action; }' file_to_parse
awk '/172.16.40.10.81/' error.log
awk '{print}' filename
We can use the -F flag to add a custom delimiter. : awk -F ':' '{print $1}' test.txt
So if you are manipulating some text you might want to start the output with some info about the columns or something like that. To do that we can use the BEGIN-keyword.
awk 'BEGIN {printf "IP-address \tPort\n"} /nop/ {print $3}' test.txt | head
awk 'BEGIN{printf "IP-address \tPort\n"} /nop/ {print $3} END {printf "End of the file\n"}' test.txt | tail
# list cronjobs
crontab -l
# Edit or create new cronjobs
crontab -e
#List all devices
fdisk -l
#Systemctl
systemctl start ssh
systemctl status ssh
systemctl stop ssh
Netstat - Find outgoing and incoming connections
Netstat is a multiplatform tool. So it works on both mac, windows and linux.
$ netstat -antlp
netstat -anpt
iptables -L
# Remove one specific rule
iptables -D INPUT 2
Iteration over a file
Another Way
For Loops
VI Operators
Password Creation
Windows Commands
Scripts for fun
Add RDP User
Enable RDP via Registry
Last updated
Was this helpful?