Given a bitstring generate all bitstring with n flipped bits
Let your initial bit string be x.

For all numbers b with k bits set (i.e. where k bits are 1), output x xor b.

Finding all numbers with k bits set is described elsewhere, for example here