The outbreak of pneumonia caused by the novel coronavirus (SARS-CoV-2) has presented a challenge to public health. The identification and development of effective antiviral drugs is essential. The main protease (3CLpro) plays an important role in the viral replication of SARS-CoV-2 and is considered to be an effective therapeutic target. In this study, according to the principle of drug repurposing, a variety of antiviral drugs commonly used were studied by molecular docking and molecular dynamics (MD) simulations to obtain potential inhibitors of main proteases. 24 antiviral drugs were docked with 5 potential action sites of 3CLpro, and the drugs with high binding strength were further simulated by MD and the molecular mechanics Poisson–Boltzmann surface area (MM-PBSA) binding free energy calculations. The results showed that the drugs with high flexibility could bind to 3CLpro better than those with low flexibility. The interaction mechanism between antiviral drugs and main protease was analyzed in detail by calculating the root mean square displacement (RMSD), root mean square fluctuation (RMSF) and interaction residues properties. The results showed that the six drugs with high flexibility (Remdesivir, Simnotrelvir, Sofosbuvir, Ledipasvir, Indinavir and Raltegravir) had strong binding strength with 3CLpro, and the last four antiviral drugs can be used as potential candidates for main protease inhibitors.