The invention provides an aniline compound represented by a formula I shown in a drawing or pharmaceutically acceptable salts thereof, wherein X is independently selected from COOH and SO2NH2, R1 and R2 are independently selected from H, C1-C3alkyl or alkoxy, CF3, F, Cl, Br, I, NH2 and NO2 respectively, m and n are respectively integers of 0-5, and y is 0 or 1. The compound and the pharmaceutically acceptable salts thereof, provided by the invention, can be used as farnesyltransferase inhibitors or can be used for preparing drugs for preventing or treating diseases related to farnesyltransferase, thereby having good medicine preparation prospects.