The traditional star sensor uses the pupil function of the lens to produce circular aperture Fraunhofer diffraction to form the diffuse spot, then enlarges the diffuse diameter by defocusing, and finally uses Gaussian fitting to determine the centroid of the star point. Compared with the traditional star sensor, this paper designs a new star location method based on rectangular hole Fraunhofer diffraction. The method first changes the optical system structure of the star sensor, so that the pupil function produces Fraunhofer diffraction image on the focal plane of the optical lens at infinite distance, and then directly determines the centroid of the star point through Gaussian fitting. Finally, the reliability of this method is verified by simulating random error. The Gaussian fitting algorithm of the new star sensor has higher accuracy, less computation burden and higher accurate reliability. Experiments show that the localization accuracy of this method can reach 0.007 pixels.