With Industry 4.0, industrial systems and IoT are converging as industries become more distributed and connected. IoT has expanded beyond smart home devices, reaching critical sectors like healthcare and transportation, facing cyber attacks and malware threats in an era of connected complexity. In this presentation, we will discuss several vulnerabilities and countermeasures at different scales. We will first study host-based intrusion detection systems in the context of embedded IoT. We will then discuss automatic protocol verification in the context of IoT networks and present an approach allowing to generation of C code from proven models. Finally, we will propose a methodology allowing to produce attack scenarios aiming at violating the safety properties consequently to malicious actions of the attackers.