# Match and Replace

Burp Suite allows you to configure match and replace rules which will automagically modify reuqests and responses made while exploring the target application. This can be used to automate testing for a specific vulnerability and/or ease interaction with the application.

1. Go to **Tools** > **Proxy**.
2. Under **Match and Replace**, click **Add**.
3. Leave the **Match** field empty. This ensures that Burp will append a new header to requests rather than replacing an existing one.
4. In the **Replace** field, enter the following:
5. `X-Custom-IP-Authorization: 127.0.0.1`
6. Click **OK**.
7. Burp Proxy will now add this header to every request you make in Burp's browser.

<figure><img src="https://1676354979-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRLSjRQh9klei94RhxhvW%2Fuploads%2FDpLGQJg7ADGmKnf0JfSb%2Fimage.png?alt=media&#x26;token=3e2e0822-5271-42ae-83b7-775cb3029cee" alt=""><figcaption></figcaption></figure>

### Cross-site Scripting

Create a match and replace rule like above to match a random string such as `P4rz1v4L` and replace it with the following:

```
'"><script src="https://collaborator"></script><h1>test
```

<figure><img src="https://1676354979-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRLSjRQh9klei94RhxhvW%2Fuploads%2FeSgngB8pVG89ctldImyX%2Fimage.png?alt=media&#x26;token=f4f04f33-73b3-4465-841e-5e87b9e9c3dc" alt=""><figcaption><p>Source: <a href="https://twitter.com/xnl_h4ck3r/status/1602402711231676421">https://twitter.com/xnl_h4ck3r/status/1602402711231676421</a></p></figcaption></figure>

### References

{% embed url="<https://portswigger.net/burp/documentation/desktop/tutorials/using-match-and-replace>" %}
