Endophytic fungus BS002 was isolated and characterized from Sophora flavescens by plate method, which has broad antimicrobial activity. Isolation and trace of a new bioactive compound from the fungus’ culture extracts with the method of column chromatography and TLC biological autoradiography was conducted. Finally, it was identified as 6,7-(2′E) dibutenyl-5,8-dihydroxy-(Z)-cyclooct-2-ene-1,4-dione by nuclear magnetic resonance, infrared and liquid chromatography–mass spectrometry. The compound presented strong antifungal activities for example: Botryosphaeria berengriana f.sp. piricola, Physalospora piricola, Cladosporium cucumerinum Ell. Arthur., Fusarium oxysporum f.sp. cucumerinum, Fusarium moniliforme. The inhibition to Physalospora piricola was the strongest with an antibacterial diameter of 45 mm. This paper is the first report of the antimicrobial activity of endophytic fungi BS002 that was the secondary metabolites extracted from the seeds of Sophora flavescens. The results provide a broad foreground for biopharmaceuticals and biopesticide.