How to Hack Into a Website 
Tags: hacking, webdev
Published: 2021-12-05 12:12:37

Hacking into websites is one of the most fundamental skills a hacker can learn. As a developer, you should be aware of the risks. 

Many [websites get hacked](https://haveibeenpwned.com/PwnedWebsites)! So how can you prevent your website or web app from being hacked? You should learn how a hacker thinks.

Once you learn how to hack into a website, you will be able to test the security of your website (or web app) and also know how others can hack into your website. 

There are many tools available for hacking, but for beginners, I suggest Burp Suite or hydra.  Burp Suite is a GUI tool and hydra is a terminal tool.

These tools are included in [Kali Linux](https://www.kali.org/), a computer system for hacking. You should have some knowledge of the [Linux command line](https://bsdnerds.org/what-is-linux-shell/).

### Wait.. roll my own tools?

As a developer, you may be inclined to roll your own hacking tools. That is possible, but why reinvent the wheel?

If your goal is to test the security of your website, you wouldn't start with writing an operating system and designing a CPU. Instead, just use the tools that exist.

But.. how does the coding work? 

Create a script in your favorite editor like [VSCode](https://code.visualstudio.com/) or [vim](https://www.vim.org/) ([learn vim](vim.is/)). For example, to brute force you could intercept a curl request and run it through a [Python](https://pythonprogramminglanguage.com/) [for loop](https://python-commandments.org/python-for-loop/) with a password text file to brute force. 

### hydra

Hydra lets you brute force passwords of any server. You do by having a password word list. This is a let of millions of passwords that Hydra will automatically try.

You can let it automatically bruteforce, with any protocol

The syntax is:

```bash
hydra -L <USERNAME_LIST> -P <PASSWORD_LIST> <TARGET_IP> <PROTOCOL>
```

You can brute force ssh, mysql, ftp and many other protocols.

```bash
hydra -L users.txt -P passwords.txt 192.168.0.1 ssh -u -V
```

It will output the passwords in the terminal:

![hydra can also hack login forms](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o1cf5tvu2irp4cnm6vgu.jpeg)

Affirmative, this is a low level tool. For more high level attacks you can use a tool called burp suite.

### Burp Suite

The way [Burp Suite](https://portswigger.net/burp) works is by intercepting your browser traffic. It then lets you modify the requests, so you can for instance brute force passwords on a login form. In the browser, you can set the Proxy to Burp Suite.

Step 1. Run Burp Suite
Step 2. Open Firefox and navigate to the login form
Step 3. Navigate to the Proxy tab in Burp Suite
Step 4. Press "Intercept On" in "Proxy -> Intercept"
Step 5. Set Burp in FoxyProxy

![foxy proxy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4l3kt03k4nv8wn8ysok0.png)

Step 6. Submit dummy data by clicking login with the dummy username and password in Firefox
Step 7. In Proxy Intercept -> Right click and Send to Intruder

![burp forward to intruder](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2zoeumws92s7mccflk9s.png)

Step 8. Click "Clear $" and add "$" around the username nad password
Step 9. Select "Cluster Bomb"
Step 10. In "Intruder -> Payloads" set a wordlist (password list) to try. You can set the payload for both parameter 1 and 2 (username and password)

![burp payload](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rp42may2nsbmph75fdid.png)

Step 11. Click Start Attack and wait for credentials

Whew, this was quite a setup. Main difference is that with Burp Suite you only have to click, with hydra you have to use the command line. Burp Suite has more features than hydra.

More on web hacking? You may like: [Ethical Hacking: Web App hacking
](https://www.udemy.com/course/ethical-hacking-web-app-hacking/)