Computer virus attacks result in significant losses each year, drawing considerable attention from enterprises, governments, academic institutions, and various other sectors. Researchers have proposed various approaches to fight against computer viruses, including antivirus software and internet firewalls. In this paper, we focus on investigating computer virus transmission from the perspective of mathematical modeling. Our main contributions in this paper are threefold: (1) we improve the classical SLBRS model by incorporating cure rates, effectively capturing the dynamics of computer network maintenance; (2) we introduce an optimal control system within the SLBRS framework, with the dual objectives of minimizing network detoxification costs and reducing the proportion of broken-out nodes; and (3) by employing Pontryagin’s Maximum Principle, we establish the existence and uniqueness of an optimal control strategy for the proposed control system. Furthermore, we perform numerical simulations to demonstrate the effectiveness of our theoretical analyses.