OSCP Day1
OSCP Day1
Table of Contents
• Command Line Fun
• Practical Tools
BASIC LINUX & WINDOWS
COMMANDS
Linux Commands
The Shell – Bash
The shell, or the terminal is a really useful tool. Bash is the standard shell on most Linux distros.
• Navigating
pwd - Print working directory
cd - Change directory
cd ~ - Change directory to your home directory
Linux Commands
• Looking at files
ls - List files in directory
ls -ltr - Sort list by last modified. -time -reverse
file - Show info about file. What type of file it is. If it is a binary or text file for example.
cat - Output content of file.
more - Output file but just little bit at a time. less is better.
Linux Commands
• A little bit of everything
history - Show commands history
sudo
List what rights the sudo user has.
sudo -l
rm - Remove file
Linux Commands
• Find
Find is slower than locate but a lot more thorough. You can search for files recursively and with regex
and a lot of other features.
Linux Commands
• Locate
Locate is really fast because it relies on an internal database. So in order to have it updated you need to
run:
uniq
grep
head
tail
tr
Linux Commands
• cut
Cut by column
This is a useful command to cut in text.
Let's say that we have the following text, and we want to cut out the ip-address.
Example
Remove character
cat file.txt | tr –d “.”
Linux Commands
• awk
So awk is an advanced tool for editing text-files. It is its own programming language to it can become
quite complex. Awk iterates over the whole file line by line.
This is the basic structure of an awk command
awk '/search_pattern/ { action_to_take_on_matches; another_action; }' file_to_parse
Now we want to print out the fourth column of that file, we can just pipe this to cut, but we can also use
awk for it, like this:
Shows all the files and directories and their permission settings.
Here we have 10 letters in the beginning. The first one d shows that it is a directory.
The next three letters are for read, w for write and x for execute. The first three belong to the owner,
the second three to the group, and the last three to all users.
→ https://linuxjourney.com/lesson/file-permissions
Windows Commands
• Show hidden files
• grep files
Windows Commands
• Processes
List processes
tracert
Kill a process
taskkill /PID 1532 /F
Windows Commands
• Users
PRACTICAL TOOLS
Practical Tools
• Netcat
• Socat
• PowerShell and Powercat
• Tcpdump
Practical Tools - netcat
• netcat
Listening on TCP/UDP Port
Windows → nc.exe –nlvp 4444
Linux → nc –nlvp 4444
Practical Tools - netcat
• netcat
Netcat Bind Shell
Practical Tools - netcat
• netcat
Netcat reverse Shell
Practical Tools - netcat
• Transferring Files with Netcat
C:\Users\offsec> nc -nlvp 4444 > incoming.exe
kali@kali:~$ nc -nv 10.11.0.22 4444 < /usr/share/windows-resources/binaries/wget.exe
Practical Tools - socat
• Netcat vs Socat
First, let’s connect to a remote server on port 80 using both Netcat and socat:
kali@kali:~$ nc <remote server's ip address> 80
kali@kali:~$ socat - TCP4:<remote server's ip address>:80