Indicator Removal: Очистка истории команд
Other sub-techniques of Indicator Removal (10)
In addition to clearing system logs, an adversary may clear the command history of a compromised account to conceal the actions undertaken during an intrusion. Various command interpreters keep track of the commands users type in their terminal so that users can retrace what they've done.
On Linux and macOS, these command histories can be accessed in a few different ways. While logged in, this command history is tracked in a file pointed to by the environment variable HISTFILE
. When a user logs off a system, this information is flushed to a file in the user's home directory called ~/.bash_history
. The benefit of this is that it allows users to go back to commands they've used before in different sessions.
Adversaries may delete their commands from these logs by manually clearing the history (history -c
) or deleting the bash history file rm ~/.bash_history
.
Adversaries may also leverage a Network Device CLI on network devices to clear command history data (clear logging
and/or clear history
).(Citation: US-CERT-TA18-106A)
On Windows hosts, PowerShell has two different command history providers: the built-in history and the command history managed by the PSReadLine
module. The built-in history only tracks the commands used in the current session. This command history is not available to other sessions and is deleted when the session ends.
The PSReadLine
command history tracks the commands used in all PowerShell sessions and writes them to a file ($env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
by default). This history file is available to all sessions and contains all past history since the file is not deleted when the session ends.(Citation: Microsoft PowerShell Command History)
Adversaries may run the PowerShell command Clear-History
to flush the entire command history from a current PowerShell session. This, however, will not delete/flush the ConsoleHost_history.txt
file. Adversaries may also delete the ConsoleHost_history.txt
file or edit its contents to hide PowerShell commands they have run.(Citation: Sophos PowerShell command audit)(Citation: Sophos PowerShell Command History Forensics)
Примеры процедур |
|
Название | Описание |
---|---|
Aquatic Panda |
Aquatic Panda cleared command history in Linux environments to remove traces of activity after operations.(Citation: Crowdstrike HuntReport 2022) |
TeamTNT |
TeamTNT has cleared command history with |
Kobalos |
Kobalos can remove all command history on compromised hosts.(Citation: ESET Kobalos Feb 2021) |
Hildegard |
Hildegard has used history -c to clear script shell logs.(Citation: Unit 42 Hildegard Malware) |
menuPass |
menuPass has used Wevtutil to remove PowerShell execution logs.(Citation: Securelist APT10 March 2021) |
Magic Hound |
Magic Hound has removed mailbox export requests from compromised Exchange servers.(Citation: DFIR Report APT35 ProxyShell March 2022) |
Lazarus Group |
Lazarus Group has routinely deleted log files on a compromised router, including automatic log deletion through the use of the logrotate utility.(Citation: Kaspersky ThreatNeedle Feb 2021) |
APT5 |
APT5 has cleared the command history on targeted ESXi servers.(Citation: Mandiant Pulse Secure Update May 2021) |
APT41 |
APT41 attempted to remove evidence of some of its activity by deleting Bash histories.(Citation: FireEye APT41 Aug 2019) |
Контрмеры |
|
Контрмера | Описание |
---|---|
Remote Data Storage |
Use remote security log and sensitive file storage where access can be controlled better to prevent exposure of intrusion detection log data or sensitive information. |
Clear Command History Mitigation |
Preventing users from deleting or writing to certain files can stop adversaries from maliciously altering their |
Restrict File and Directory Permissions |
Restrict access by setting directory and file permissions that are not specific to users or privileged accounts. |
Environment Variable Permissions |
Prevent modification of environment variables by unauthorized users and groups. |
Обнаружение
User authentication, especially via remote terminal services like SSH, without new entries in that user's ~/.bash_history
is suspicious. Additionally, the removal/clearing of the ~/.bash_history
file can be an indicator of suspicious activity.
Monitor for suspicious modifications or deletion of ConsoleHost_history.txt
and use of the Clear-History
command.
Ссылки
- Vikas, S. (2020, August 26). PowerShell Command History Forensics. Retrieved September 4, 2020.
- US-CERT. (2018, April 20). Alert (TA18-106A) Russian State-Sponsored Cyber Actors Targeting Network Infrastructure Devices. Retrieved October 19, 2020.
- Microsoft. (2020, May 13). About History. Retrieved September 4, 2020.
- jak. (2020, June 27). Live Discover - PowerShell command audit. Retrieved August 21, 2020.
- CrowdStrike. (2023). 2022 Falcon OverWatch Threat Hunting Report. Retrieved May 20, 2024.
- Fiser, D. Oliveira, A. (n.d.). Tracking the Activities of TeamTNT A Closer Look at a Cloud-Focused Malicious Actor Group. Retrieved September 22, 2021.
- Darin Smith. (2022, April 21). TeamTNT targeting AWS, Alibaba. Retrieved August 4, 2022.
- M.Leveille, M., Sanmillan, I. (2021, February 2). Kobalos – A complex Linux threat to high performance computing infrastructure. Retrieved August 24, 2021.
- Chen, J. et al. (2021, February 3). Hildegard: New TeamTNT Cryptojacking Malware Targeting Kubernetes. Retrieved April 5, 2021.
- GREAT. (2021, March 30). APT10: sophisticated multi-layered loader Ecipekac discovered in A41APT campaign. Retrieved June 17, 2021.
- DFIR Report. (2022, March 21). APT35 Automates Initial Access Using ProxyShell. Retrieved May 25, 2022.
- Vyacheslav Kopeytsev and Seongsu Park. (2021, February 25). Lazarus targets defense industry with ThreatNeedle. Retrieved October 27, 2021.
- Mathew Branwell. (2012, March 21). Securing .bash_history file. Retrieved July 8, 2017.
- Perez, D. et al. (2021, May 27). Re-Checking Your Pulse: Updates on Chinese APT Actors Compromising Pulse Secure VPN Devices. Retrieved February 5, 2024.
- Fraser, N., et al. (2019, August 7). Double DragonAPT41, a dual espionage and cyber crime operation APT41. Retrieved September 23, 2019.
Связанные риски
Каталоги
Мы используем cookie-файлы, чтобы получить статистику, которая помогает нам улучшить сервис для вас с целью персонализации сервисов и предложений. Вы может прочитать подробнее о cookie-файлах или изменить настройки браузера. Продолжая пользоваться сайтом, вы даёте согласие на использование ваших cookie-файлов и соглашаетесь с Политикой обработки персональных данных.