A near-infrared fluorescent probe, CyAc, is synthesized for accurately diagnosing cancer in vivo by sequential detection of Cys and H+. CyAc can not only achieve a good distinction between normal cells and cancer cells, but also distinguish normal mice from tumor mice.