With the development of information and communication technology (ICT), the observability and controllability of smart grid have been greatly enhanced. The smart grid is gradually evolving into cyber-physical-power systems (CPPS). The influence of communication network and control device on power system stability becomes more obvious. Thus, it is essential to set up the real-time co-simulation platform with hardware-in-loop to reflect cyber-attack process. In this paper, a co-simulation platform is designed based on RT-LAB, OPNET and real security and stability control device. The modeling and implementation methods of man-in-the-middle (MITM) attack in the communication network are elaborated. The simulation results validate the capability of the co-simulation platform.