The flour and sugar attract the cockroaches, while the boric acid acts as a lethal agent, efficiently eliminating them.