It seems to be from the pea family (Fabaceae) due to the zygomorphic flowers and the pods. It also has stipules at the base of the composite leaves. It's quite high (~ 80 cm). Photographed in spring in Morocco. It was photographed in a dry riverbed.
This is a difficult one to identify down to the species from the photos. It very much looks like a member of the genus Ononis in the pea family. The leaves, flowers, and seed pods are all characteristic of Ononis. It might be Ononis spinosa, but that is a guess. The bright sunlight make it difficult to discern many morphological details. I can't see any visible spines on the plant to be certain. Links provided: