forked from p15670423/monkey
Bugfix in dropper.py, handle gracefully failure in cleanup
This commit is contained in:
parent
cc4ad05be8
commit
558fa749ca
|
@ -133,22 +133,25 @@ class MonkeyDrops(object):
|
||||||
LOG.warn("Seems like monkey died too soon")
|
LOG.warn("Seems like monkey died too soon")
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
if (self._config['source_path'].lower() != self._config['destination_path'].lower()) and \
|
try:
|
||||||
os.path.exists(self._config['source_path']) and \
|
if (self._config['source_path'].lower() != self._config['destination_path'].lower()) and \
|
||||||
WormConfiguration.dropper_try_move_first:
|
os.path.exists(self._config['source_path']) and \
|
||||||
|
WormConfiguration.dropper_try_move_first:
|
||||||
|
|
||||||
# try removing the file first
|
# try removing the file first
|
||||||
try:
|
try:
|
||||||
os.remove(self._config['source_path'])
|
os.remove(self._config['source_path'])
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
LOG.debug("Error removing source file '%s': %s", self._config['source_path'], exc)
|
LOG.debug("Error removing source file '%s': %s", self._config['source_path'], exc)
|
||||||
|
|
||||||
# mark the file for removal on next boot
|
# mark the file for removal on next boot
|
||||||
dropper_source_path_ctypes = c_char_p(self._config['source_path'])
|
dropper_source_path_ctypes = c_char_p(self._config['source_path'])
|
||||||
if 0 == ctypes.windll.kernel32.MoveFileExA(dropper_source_path_ctypes, None,
|
if 0 == ctypes.windll.kernel32.MoveFileExA(dropper_source_path_ctypes, None,
|
||||||
MOVEFILE_DELAY_UNTIL_REBOOT):
|
MOVEFILE_DELAY_UNTIL_REBOOT):
|
||||||
LOG.debug("Error marking source file '%s' for deletion on next boot (error %d)",
|
LOG.debug("Error marking source file '%s' for deletion on next boot (error %d)",
|
||||||
self._config['source_path'], ctypes.windll.kernel32.GetLastError())
|
self._config['source_path'], ctypes.windll.kernel32.GetLastError())
|
||||||
else:
|
else:
|
||||||
LOG.debug("Dropper source file '%s' is marked for deletion on next boot",
|
LOG.debug("Dropper source file '%s' is marked for deletion on next boot",
|
||||||
self._config['source_path'])
|
self._config['source_path'])
|
||||||
|
except AttributeError:
|
||||||
|
LOG.error("Invalid configuration options. Failing")
|
||||||
|
|
Loading…
Reference in New Issue