Impact craters are the most prominent topographic feature on the lunar surface, which will play a significant role in constructing lunar bases and lunar surface activities in the future. Traditional meteorite crater recognition methods are mainly based on artificial interpretation, usually combined with classical image processing methods. However, due to the different diameters and shapes of impact craters, the traditional crater identification methods have significant errors and low efficiency for small or overlapping impact craters. This paper proposes an automated algorithm termed nested attention-aware U-Net (NAU-Net) for crater detection using a lunar's digital elevation model (DEM). It then uses template matching to effectively calculate the longitude, latitude, and radius of the crater. It is worth mentioning that NAU-Net is primarily based on UNet++ and attention networks and applies a sequence of nested dense convolution blocks, preferably of classical convolution, which combines U-Net++ and Attention Gates advantages. Since our network uses nested intensive attentional aware connections and in-depth supervision, the training process of the NAU-Net is simple, which can achieve more accurate detection and recognition. In fact, the network can recognize smaller or overlapping impact craters and larger and more complex ones. In honor of lunar impact craters, compared with U-Net, UNet++, Dense-Unet, Attention-Unet, R2-Unet, our model achieved recall rates and accuracy of 0.791 and 0.856, better than other improved U-Net models. The experimental results show that the NAU-Net model can be used to extract impact craters.