This paper investigates the attack detection of complex cyber-physical networks (CCPNs) based on the set-membership theory and moving-target defense strategy. Firstly, a moving-target defense (MTD) strategy is proposed to prevent attackers from stealing the system model, which can improve the security of systems. Secondly, a robust observer based on the MTD strategy is designed to estimate the system states without attacks. Meanwhile, we combine the set-membership and interval hull theorem to calculate the reachable set of the states and dynamic thresholds of the residual system in the absence of attacks. Then, an attack detector is established to give an alarm of false data injection (FDI) attacks by comparing the actual residual signal under attacks and the dynamic thresholds. Finally, two examples are given to illustrate the effectiveness of the proposed method.