Moon is relatively easy inasmuch as the proper exposure is typically very short, Sunny 16 will get you in the ballpark (e.g. 1/60th @f/22 on ISO 100 in clear conditions if the moon isn't sitting right on the horizon where the atmosphere is thickest). Stars are tough to get with the moon in the frame as only a few of the bright ones will show up on such a short exposure. Telescope tracking is needed to keep them pinpoint beyond a few seconds. For these reasons many if not the majority of such scenes are and have always been multi-exposures and/or composites-- long predating Photoshop