Привет! Наша команда ИБ задетектировала инцидент! Злоумышленники смогли проникнуть в надежно защищенный сегмент. Эксперты нашли подозрительный ldap трафик, который вызвал у них особый интерес. Они предоставили его вам и ждут, что именно вы сможете разобраться в этом происшествии.
Provide pcap file: public/tasmystery_ldap.pcap.
В pcap файле находится одна большая ldap сессия от пользователя fragger. Беглый анализ показывает, что сначала пользователь начинает вычитывать все объекты из домена, затем поочередно запрашивать и пытаться менять собственные атрибуты.
Запрос объектов из домена от пользователя fragger
Попытки модификации значений атрибутов пользователя fragger:
Также в дампе содержатся запросы к некоторым атрибутам другого пользователя домена с уз cobalt. Значения атрибута mSMQSignCertificates содержат base64.
Base64 в атрибуте mSMQSignCertificates пользователя cobalt
Декодированный base64 из атрибута mSMQSignCertificates
Гугление приводит к утилите https://github.com/fox-it/LDAPFragger
Анализ утилиты LDAPFragger показывает, что клиентская часть коммуницирует с серверной частью через протокол ldap посредством записи и считывания данных в различные атрибуты. Серверная часть при первой установке связи следует на С2 сервер Cobalt Strike, выгружает кастомный стейджер и передает его на клиента через запись в атрибуты.
Загрузка стейджера и передача на клиента
Находим в трафике загрузку стейджера
После декодирования видим, что сообщение поделено на 6 частей
Декодированное сообщение с первой частью
Сделаем еще декод внутреннего сообщения.
Извлечем все 6 частей, сложим вместе и отправимся анализировать полученный файл. Гугление приводит к различным инструментам анализа. Попробуем достать конфиг с помощью утилиты https://github.com/Sentinel-One/CobaltStrikeParser В конфиге находится заветный флаг
The pcap file contains one large ldap session from the fragger user. A cursory analysis shows that the user first starts reading all objects from the domain, then alternately querying and trying to change his own attributes.
Querying objects from the domain from user fragger
Attempts to modify attribute values of the fragger user:
The dump also contains requests for some attributes of another domain user with the node cobalt. The values of the mSMQSignCertificates attribute contain base64.
Base64 in the mSMQSignCertificates attribute of user cobalt
Decoded base64 from the mSMQSignCertificates attribute
Googling leads to the utility https://github.com/fox-it/LDAPFragger
Analysis of the LDAPFragger utility shows that the client part communicates with the server part via the ldap protocol by writing and reading data to various attributes. The server part, when first establishing communication, follows the C2 server Cobalt Strike, unloads the custom stager and passes it to the client via writing to attributes.
Loading the steager and passing it to the client
Find the steager load in the traffic
The first piece of the steager in ldap
After decoding we see that the message is divided into 6 parts
Decoded message with the first part
Let's do some more decoding of the internal message.
Let's extract all 6 parts, put them together and go analyze the resulting file. Googling leads to various analysis tools. Let's try to get the config using the utility https://github.com/Sentinel-One/CobaltStrikeParser. And config contains our flag.
ctfcup{c0balt_hunt1ng_m@st3r}