Protection against Webshell attacks is an important issue in the field of network security. Attackers often design various anti-virus techniques when writing Webshell to bypass firewalls and evade detection. Therefore, existing methods have problems with low accuracy and high false positives in Webshell detection. To address these issues, this paper proposes a Webshell detection method based on CodeBERT and deep learning. Firstly, the sample is analyzed and preprocessed by Antlr4 syntax analysis. Then, the preprocessed sample is encoded by CodeBERT model, and the sample is converted into feature vector. Finally, the BiGRU-Attention model is used for training and classification, so as to complete the detection of the sample. The method used in this paper is compared with the mainstream method. The experimental results show that the method proposed in this paper has better effect for Webshell detection and lower false positive rate.