With the development of wireless rechargeable sensor networks (WRSNs ), security issues of WRSNs have attracted more attention from scholars around the world. In this paper, a novel epidemic model, SILS(Susceptible, Infected, Low-energy, Susceptible), considering the removal, charging and reinfection process of WRSNs is proposed. Subsequently, the local and global stabilities of disease-free and epidemic equilibrium points are analyzed and simulated after obtaining the basic reproductive number R0. Detailedly, the simulations further reveal the unique characteristics of SILS when it tends to being stable, and the relationship between the charging rate and R0. Furthermore, the attack-defense game between malware and WRSNs is constructed and the optimal strategies of both players are obtained. Consequently, in the case of R0<1 and R0>1, the validity of the optimal strategies is verified by comparing with the non-optimal control group in the evolution of sensor nodes and accumulated cost.