Make yourself rich by hacking this juice shop 💵
Tags: javascript, security, webdev, testing
Published: 2020-06-29 02:38:08

As a business owner or as a professional, getting your website hacked is no fun. How do hackers do this?
 
Through this article, I would like to bring your attention to an exciting topic - Web Application Security.

Knowing some of the techniques will help you design a reasonably "secure" web application. Before a release, attacking your own application will help mitigate some of the vulnerabilities. 

## 📖 Learn the techniques

Pay attention to the screenshot below. You may have placed eCommerce orders for 1 or more items. Have you thought what would happen when an order is placed with a quantity of -100 items? This order will **return money to the shopper's credit card**!

![Final](https://dev-to-uploads.s3.amazonaws.com/i/9qzg60y4nmqai9qa68sz.png)

Do you want to be that devastated owner of a business that "pays" money for no juice sold?

You may have read or heard about _SQL injection_, _Cross-site scripting_, _Cross-site Request Forgery_, and other popular attacks. 

Let's learn swimming, by actually being in the water.

## 🥤 Set up your juice shop

Before we start, we need an online juice shop - an insecure vulnerable web application to learn some basic and advanced attacks. Luckily there is one that exists.

Assuming you have NodeJS installed:

1. Clone the repository 
1. Install the project dependencies
1. Start the server.

```
git clone https://github.com/bkimminich/juice-shop.git
npm install
npm start
```

Your juice shop is up and running.

Navigate to http://localhost:3000

## 💵 Make yourself rich

The user interface will let you pick only 1 juice. 

![UI](https://dev-to-uploads.s3.amazonaws.com/i/eh92rr76gtbfd8xtacy6.gif)

_mmmmm... What about the API?_

Open the browser developer tools, firefox will let you resend a request quite easily.


![Dev Tools](https://dev-to-uploads.s3.amazonaws.com/i/478yki0ej4kfy17bk473.gif)


That works 🎉. 


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vp65sqk76a26uamnfas5.png)

Wait, what just happened? We used the API to post the quantity of juice as -100. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0thz3x7cay3a4gy7193q.png)

Placing this order will pay you $198.01 from the juice vendor!

Obviously, this is a hypothetical situation. The web application is mindfully crafted to be insecure to show the point.

## 🧊 The tip of the iceberg

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2plkmyk9okzzozy47chb.jpg)

"OWASP Juice Shop" is an application that provides awareness for security risks that potentially exist in modern web applications. 

This is **only one of the many** challenges in the set of OWASP Juice Shop exercises. See all the challenges and work through each of them. You will be delighted to learn some of the popular techniques to

* **Access confidential files on the server**
* Decrypt coupon codes and **get an 80% off an order**
* Login as a different user **without knowing their password**

Start here: https://bkimminich.gitbooks.io/pwning-owasp-juice-shop/content

This is definitely one of the best free security training for you out there. Let's create secure web applications together. 

## 🙏 Credits

Björn Kimminich for creating and maintaining this project for the world to learn.

--------------------------------------

Please find my other writings here:

1. [One side rounded rectangle using SVG](https://medium.com/@dennismphil/one-side-rounded-rectangle-using-svg-fb31cf318d90)
1. [What makes these borders beautiful?](https://dev.to/dennismphil/what-makes-these-borders-beautiful-2loj)
1. [Automated End to End tests made easy](https://dev.to/dennismphil/automated-end-to-end-tests-made-easy-180m)
1. [Automate your node dependency update](https://dev.to/dennismphil/automate-your-node-dependency-updates-4aga)
1. [Visual Studio Code — Debug Mode](https://medium.com/@dennismphil/debugging-node-js-using-visual-studio-code-c30e5eeb9e38)
1. [I want TypeScript to succeed.](https://medium.com/@dennismphil/i-want-typescript-to-succeed-d421d00fd856)
1. [What’s in my laptop?](https://medium.com/@dennismphil/whats-on-my-laptop-2cc2619aa55f)
1. [CoffeeScript’s most loved feature soon in JavaScript](https://medium.com/@dennismphil/coffeescripts-most-loved-feature-soon-in-javascript-b2f6740c2dc7)
1. [Extend your wireless signal with an old router](https://dev.to/dennismphil/extend-your-wireless-signal-with-an-old-router-2lfd)