Monday, February 12, 2018

OWASP Omaha Feb 2018 - 001 - Deserialization with the JS for the lulz

On Feb 16th, I'm going to present a discussion of deserialization attacks in a JavaScript based web application at the OWASP Omaha chapter meeting. My slides will cover a lot of the material below, but I won't spend too much time per slide. The purpose of these blog entries will be to show each step of the way as a reference for the upcoming talk.

We will start with preparing the environment. We're going to use CentOS 7 for the OS and the OWASP Juice Shop project for the web app to exploit. This series assumes you already have VirtualBox installed, but I would imagine that VMware would also work fine as well.

  1. Go to the downloads page for CentOS here

  2. Click on "DVD ISO" and download the ISO which should automatically pick a download mirror closest to you. At the time of this writing, CentOS 7, x86_64 1708 was used.

  3. Start VirtualBox and click "New"

  4. Type in "JuiceShop" as the name, change the type to "Linux", and select "Red Hat (64-bit)" as the Version.

  5. Click "Continue"

  6. Change the RAM to 2048 (or higher if you can) and click "Continue"

  7. Leave the default option of "Create ..." and click "Continue"

  8. Leave the default option of "VDI" and click "Continue"

  9. Leave the default option of "Dynamic" and click "Continue"

  10. Change the hard drive size to 30GB and click "Create"

  11. Click "Settings" for JuiceShop

  12. On the "General" tab, click "Advanced", and change both "Shared Clipboard" and "Drag n drop" to "Bidirectional"

  13. On the "System" tab, click "Processor", and increase the number of CPUs up to 2 if possible

  14. On the "Storage" tab, click "Empty" under "Controller: IDE", and click the CD icon

  15. Click "Choose Virtual Optical Disk File"

  16. Select the ISO from step 2

  17. Click Ok

  18. Click "Start" on the JuiceShop VM

  19. Press the up arrow to select "Install CentOS 7" and press Enter

  20. Once the GUI install screen appears, select the appropriate language and click "Continue"

  21. Let's start with configuring the system from the top. Click "Date & Time".

  22. Change the timezone as appropriate and click "Done"

  23. Click "Software Selection"

  24. Choose "GNOME Desktop", check "Development Tools", and click "Done"

  25. Click "Installation Destination"

  26. Review the disk options and click "Done" when complete

  27. Click "Network & Host Name"

  28. Click "Configure"

  29. Click "General"

  30. Check "Automatically connect..."

  31. Click "Save"

  32. The ethernet adapter should now have automatically flipped to "On"

  33. Click "Done"

  34. Click "Begin Installation"

  35. While the system begins installation, you get the option to set a root password and a user. Click "Root password".

  36. Set a root password and click "Done"

  37. Click "User creation"

  38. Set the full name, user name (should automatically populate), check the box for "Make this user administrator", and matching passwords. When done, click "Done".

  39. Wait for the installation process to finish

  40. Click "Reboot"

  41. Once you're back into the GUI configuration screen, click "License information"

  42. Review the EULA, check the box to accept the terms, and click "Done"

  43. Click "Finish configuration"

  44. Log into the system!

  45. In the gnome-initial-setup screen, choose your language and click "Next" in the upper right

  46. Review the keyboard selection and click "Next"

  47. Review the privacy option and click "Next"

  48. Connect accounts that'd you like and click "Skip" if you choose none of them

  49. Click "Start using CentOS Linux"

  50. Review the help information and close when finished

  51. Move the mouse cursor to the top left of the screen to "Applications"

  52. Click "Applications" and click on "Terminal"

  53. In Terminal, type in, "sudo yum update" and press Enter. Review the warning, enter your password, and press Enter.

  54. I had an issue with PackageKit locking yum in two different instances. Move the cursor to the top right of the screen, click the power icon, and click on the "Power button" icon.

  55. Click "Restart"

  56. Enter the password and click "Authenticate". The system will be rebooted.

  57. Log back in!

  58. Open up a Terminal client (Applications > Favorites > Terminal)

  59. Type in, "sudo yum update", press Enter, enter in your password, and press Enter

  60. A bunch of text will scroll by, eventually it'll stop asking if you want to download updates. Type in, "y" and press Enter.

  61. Next you may get a prompt to update a key. Type in "y" at the prompt and press Enter.

  62. Once that completes, move the mouse to the upper right, click on the power icon, and click the wrenches

  63. Click "Power"

  64. Click the dropdown for "Power Saving" and change it to "Never"

  65. Click the back button to go to the previous screen

  66. Click "Privacy"

  67. Click on "Screen Lock"

  68. Click on "On" to turn it off

  69. Click on the "x" to close out

  70. Click on the "x" to close out of Privacy

  71. We now want to install the VirtualBox Guest Additions. If you click out of the VM (pressing Right Control in Windows or Left Command in macOS), you get options for the VM if you click the title bar of the VM window. These instructions are based on Mac, so click on "Devices" at the top and select, "Insert Guest Additions CD image".

  72. In your VM, you should see a CD icon automatically popup and an auto-run box asking if you want to run the software. Click "Run".

  73. Enter in your password and click "Authenticate" or press Enter

  74. If all goes well, you'll be able to freely move your mouse in and out of the VM. Yay! Press the Enter key.

  75. We now need the Node.js package manager to run the Juice Shop. If we type in "npm" at the prompt, we see that it's not installed.

  76. We will refer to these official instructions from Node to install what we need

  77. In Terminal, type in, "curl --silent --location https://rpm.nodesource.com/setup_9.x | sudo bash -" and press Enter


  78. Enter in your password and it should do it's magic

  79. Like the instructions on the website and in the window, we need to now install node v9. We are using v9 since that is what is officially recommended by Juice Shop as the preferred version.

  80. In Terminal, type in, "sudo yum install -y nodejs" and press Enter

  81. It should complete pretty fast! We now have nodejs v9.5 installed at the time of this writing.

  82. Now we need to get the latest version of the OWASP Juice Shop. In our VM, go to Applications and open up Firefox.

  83. In Firefox, browse to https://github.com/bkimminich/juice-shop

  84. You should see a "releases" link. At the time of this writing, there are 106 releases. Click on that.

  85. We want the latest linux, x64, node9 package. In this case, its juice-shop-6.4.2_node9_linux_x64.tgz. Click on that.

  86. Click on "Save File" and click "Ok"

  87. Once it's done, Firefox should show you a helpful mini-window and a folder icon so you can browse to where the file was saved. Click on the folder icon.

  88. Right click on the archived file and click "Open With Archive Manager"

  89. Click on "Extract"

  90. Click on the new folder icon

  91. Give the new folder some kind of meaningful name. I chose, "js642". After you enter in a name, click "Create"

  92. Click on "Extract"

  93. Click "Close"

  94. "X" out of the Archive Manager

  95. You can close the file browser window now too along with Firefox

  96. Go back to the Terminal window

  97. Browse to the folder we extracted the Juice Shop contents into

  98. Type in, "npm start" and press Enter. If all goes well, we should have the Juice Shop listening on port 3000!

  99. Open up Firefox, and browse to http://127.0.0.1:3000

  100. Welcome to the OWASP Juice Shop!


No comments:

Post a Comment