  Entangled states play a fundamental role in Quantum Mechanics and are at the
core of many contemporary applications, such as quantum communication and
quantum computing. Therefore, determining whether a state is entangled or not
is an important task. Here, we propose a method to detect the entanglement of
unknown two-qubit quantum states. Our method is based on the violation of the
Clauser-Horne-Shimony-Holt inequality. This maximizes the value of the
inequality even when \lp{it} contains an unknown quantum state. The method
iteratively generates local measurement settings that lead to increasing values
of the inequality. We show by numerical simulations for pure and mixed states
that our algorithm exceeds the classical limit of 2 after a few iterations.
