In every day English these two sentences are used the same way. However, technically, they mean something slightly different.
Do you ever buy second-hand books? asks if you regularly buy second-hand books or if buying second hand books is your habit or custom.
Have you ever bought second-had books? asks if you bought second-hand books in some general time in the past.