Disclosed an extract that is effective in treating drug addiction and a preparation method therefor. An effective component of the extract has the following chemical structural characteristics: a cholestenol compound with hydroxyl (OH) at position 3 and a double bond between position 5 and position 6, or a cholestenol compound with hydroxyl (OH) at position 3, a double bond between position 5 and position 6 and a double bond between position 22 and position 23. The extract can be extracted from the traditional Chinese medicine Agriolima agrestis. The extract of the present invention is safe in acute toxicity, sedative and hypnotic without physical and psychic dependence, has an inhibitory effect on excitability in mouse caused by morphine and benzedrine and a detoxification treatment effect on the withdrawal symptoms in morphine-dependent rats, and is useful in the development of medications or food for treating drug addiction.