Networked control systems have advantages such as flexibility, efficiency, but at the same time they are exposed to cyberattacks. Among many lethal attacks, the zero-dynamics attack is a model based attack and it is very hard to detect. In this paper, a new strategy for intrusion detection and defense against zero-dynamics attack is proposed, and it is based on the generalized sampler that takes a weighted average of multiple samples obtained during one sampling interval. By using the generalized sampler instead of the simple sampler, the zeros of the sampled-data system can be placed at arbitrary locations, and if all zeros are placed inside the unit circle, the attack signal becomes no longer effective. This strategy still works even if all the information is exposed to hackers and it is considerably insensitive to the shift of intrinsic zeros. A design procedure for the generalized sampler is provided under mild assumptions. Furthermore, optimal designs for the selection of desired zeros are formulated considering practical issues. Theoretical findings are validated through numerical simulations.