Mobile ad hoc networks communicate in a self-organized way without depending on any fixed infrastructure. The issue of selfish nodes, which may refuse to cooperate, is a great challenge in such networks and may cause network throughput to drastically reduce. Energy-based selfishness is a category of selfishness in which a selfish node shows nondeterministic and probabilistic selfishness behaviors based on level of its energy. In this paper, we propose a mechanism for coping with this kind of selfishness. This mechanism called CEMDEEM not only detects and isolates energy-based and traditional selfish nodes, but also malicious behaviors like spoofing. We also evaluate performance of Dynamic Source Routing (DSR) protocol fortified by CEMDEEM in the presence of different percentages of selfish nodes. Results show that CEMDEEM noticeably improves network performance with a reasonable additional packet overhead and network delay especially when percentage of selfish nodes is not more than 40.