In this paper, intelligent reflecting surface (IRS) is proposed to enhance the physical layer security in the Rician fading channel where the angular direction of the eavesdropper is aligned with a legitimate user. In this scenario, we consider a two-phase communication system under the active attacks and passive eavesdropping. Particularly, in the first phase, the base station avoids direct transmission to the attacked user. While, in the second phase, other users cooperate to forward signals to the attacked user with the help of IRS and energy harvesting technology. Under the active attacks, we investigate an outage constrained beamforming design problem under the statistical cascaded channel error model, which is solved by using the Bernstein-type inequality. As for the passive eavesdropping, an average secrecy rate maximization problem is formulated, which is addressed by a low complexity algorithm. Numerical results show that the negative effect of the eavesdroppers channel error is greater than that of the legitimate user.