Wireless Sensor Networks present a significant issue for data routing because of the potential use of obtaining data from far locations with greater energy efficiency. Networks have become essential to modern concepts of the Internet of Things. The primary foundation for supporting diverse service-centric applications has continued to be the sensor node activity of both sensing phenomena in their local environs and relaying their results to centralized Base Stations. Malware detection and inadequate Cluster Heads node selection are issues with the current technology, resulting in a drastic decrease in the total Internet of Things-based performance of sensor networks. The paper proposes an Enhanced Lion Swarm Optimization (ELSO) and Elliptic Curve Cryptography (ECC) scheme for secure cluster head selection and malware detection in IoT-based Wireless Sensor Networks (WSNs). The paper includes network models, choice of Cluster Head (CH) and attack detection procedures. The proposed method chooses the Cluster Head with the best fitness function values, increasing data transmission speeds and energy efficiencies. Minimum Hop Detection has been implemented to provide the best routing paths against attack nodes. Security level for quick data transmissions via the Internet of Things using Wireless Sensor Networks strengthen sinkhole attacks and black hole nodes, which are successfully removed using this method. The proposed method integrates the use of Lion Swarm Optimization and Elliptic Curve Cryptography (ECC) enhances network security by ensuring secure data transmission and preventing unauthorized access, which is particularly important in IoT-WSN environments. The proposed method achieves less End delay, increased throughput of 93%, lower energy utilization of 4%, increased network lifetime of up to 96%, Packet Delivery Ratio of up to 98% and 97% of malicious node detection efficiently compared to existing methods.