DNA-binding drugs have numerous applications in the engineered gene regulation. However, the drug-DNA recognition mechanism is poorly understood. Drugs can recognize specific DNA sequences not only through direct contacts but also indirectly through sequence-dependent conformation, in a similar manner to the indirect readout mechanism in protein-DNA recognition. We used a knowledge-based technique that takes advantage of known DNA structures to evaluate the conformational energies. We built a dataset of non-redundant free B-DNA crystal structures to calculate the distributions of adjacent base-step and base-pair conformations, and estimated the effective harmonic potentials of mean force (PMF). These PMFs were used to calculate the conformational energy of drug-DNA complexes, and the Z-score as a measure of the binding specificity. Comparing the Z-scores for drug-DNA complexes with those for free DNA structures with the same sequence, we observed that in several cases the Z-scores became more negative upon drug binding. Furthermore, the specificity is position-dependent within the drug-bound region of DNA. These results suggest that DNA conformation plays an important role in the drug-DNA recognition. The presented method provides a tool for the analysis of drug-DNA recognition and can facilitate the development of drugs for targeting a specific DNA sequence.