A method for treating a virus infection in a subject is provided. The method comprising administering to the subject in need an effective amount of a derivative of aniline selected from the group consisting of a compound of formula (I), a pharmaceutically acceptable salt of the compound of formula (I), a pharmaceutically acceptable ester of the compound of formula (I), and combinations thereof: wherein, R1 is C1 to C10 alkyl; R2 is H or C1 to C4 alkyl; and R3, R4, R5, R6 and R7 are independently H, —OH, halogen, C1 to C10 alkyl, C1 to C10 alkoxyl, or (C1 to C10 alkylene)-O—O—(C1 to C10 alkyl).