Distributed tracking problem for complex dynamical networks with Lipschitz-type nonlinear dynamics under the framework of cyber-physical systems is investigated. Due to practical limitations in some circumstances, the states of the agents are usually unavailable for controllers, so distributed observers used to reconstruct the states of nodes are needed, which will be first designed. Differing from other studies of observer-based control problems for complex dynamical networks and multi-agent systems, it considers here the scenario that the communication channels for controllers and observers may be subjected to frequently malicious attacks, which will destroy the communication links and result in disconnected topologies of the communication networks. It is assumed that the impacts of attacks on different communication networks are different and independent. New security control strategies are proposed and analyzed. An algorithm to properly select the feedback gain matrices and coupling strengths is presented. By utilizing the Lyapunov stability theory, sufficient conditions are derived to check whether final consensus tracking can be achieved against such attacks. Finally, a simulation example comparing the security control and uncontrolled scenarios is demonstrated to show the effectiveness of the theoretical results.