Outsmarting cyberattacks on microgrids