In this paper, we approach the problem of a set of network agents reaching resilient consensus in the presence of a subset of attacked nodes. We devise a generalized method, with polynomial time complexity, which receives as input a discrete-time, synchronous-communication consensus algorithm, a dynamic network of agents, and the maximum number of attacked nodes. The distributed algorithm enables each normal node to detect and discard the values of the attacked agents while reaching the consensus of normal agents for the input consensus algorithm. Hence, the proposed method adds an extra layer of resilience to a given discrete-time and synchronous-communication consensus algorithm. Finally, we demonstrate the effectiveness of the method with experimental results, showing some attack circumstances which we can counter, where the state-of-the-art methods fail.