Metasploit هو إطار الاستغلال الأكثر استخدامًا. Metasploit هي أداة قوية يمكنها دعم جميع مراحل مشاركة اختبار الاختراق ، من جمع المعلومات إلى ما بعد الاستغلال.
الدرس الثاني
msfconsole
الأمر الموجود على محطة AttackBox أو أي نظام تم تثبيت Metasploit Framework عليه.msfconsole
root@ip-10-10-220-191:~# msfconsole
_---------.
.' ####### ;."
.---,. ;@ @@`; .---,..
." @@@@@'.,'@@ @@@@@',.'@@@@ ".
'-.@@@@@@@@@@@@@ @@@@@@@@@@@@@ @;
`.@@@@@@@@@@@@ @@@@@@@@@@@@@@ .'
"--'.@@@ -.@ @ ,'- .'--"
".@' ; @ @ `. ;'
|@@@@ @@@ @ .
' @@@ @@ @@ ,
`.@@@@ @@ .
',@@ @ ; _____________
( 3 C ) /|___ / Metasploit! \
;@'. __*__,." \|--- \_____________/
'(.,...."/
=[ metasploit v5.0.101-dev ]
+ -- --=[ 2048 exploits - 1105 auxiliary - 344 post ]
+ -- --=[ 562 payloads - 45 encoders - 10 nops ]
+ -- --=[ 7 evasion ]
Metasploit tip: Search can apply complex filters such as search cve:2009 type:exploit, see all the filters with help search
msf6 >
msf6 >
بمجرد بدء التشغيل ، سترى تغيير سطر الأوامر إلى msf5 (أو msf6 اعتمادًا على الإصدار المثبت من Metasploit). يمكن استخدام وحدة التحكم Metasploit (msfconsole) تمامًا مثل غلاف سطر الأوامر العادي ، كما ترى أدناه. الأمر الأول هو
ls
الذي يسرد محتويات المجلد الذي تم إطلاق Metasploit منه باستخدام msfconsole
الأمر.ويليه
ping
إرسال إلى عنوان IP DNS الخاص بـ Google (8.8.8.8). نظرًا لأننا نعمل من AttackBox ، وهو نظام Linux ، فقد كان علينا إضافة -c 1
الخيار ، لذلك تم إرسال ping واحد فقط. خلاف ذلك ، ستستمر عملية ping حتى يتم إيقاف استخدامها CTRL+C
.أوامر Linux في Metasploit
msf6 > ls
[*] exec: ls
burpsuite_community_linux_v2021_8_1.sh Instructions Scripts
Desktop Pictures thinclient_drives
Downloads Postman Tools
msf6 > ping -c 1 8.8.8.8
[*] exec: ping -c 1 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=109 time=1.33 ms
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.335/1.335/1.335/0.000 ms
msf6 >
سيدعم معظم أوامر Linux ، بما في ذلك
clear
(لمسح شاشة الجهاز) ، لكنه لن يسمح لك باستخدام بعض ميزات سطر الأوامر العادي (على سبيل المثال لا يدعم إعادة توجيه الإخراج) ، كما هو موضح أدناه.فشل إعادة توجيه الإخراج
msf6 > help > help.txt
[-] No such command
msf6 >
أثناء الحديث عن الموضوع ، يمكن استخدام أمر المساعدة بمفرده أو لأمر محدد. فيما يلي قائمة المساعدة لأمر المجموعة التي سنغطيها قريبًا.
ميزة المساعدة
msf6 > help set
Usage: set [option] [value]
Set the given option to value. If value is omitted, print the current value.
If both are omitted, print options that are currently set.
If run from a module context, this will set the value in the module's
datastore. Use -g to operate on the global datastore.
If setting a PAYLOAD, this command can take an index from `show payloads'.
msf6 >
msf6 >
يمكنك استخدام أمر history لمشاهدة الأوامر التي كتبتها سابقًا.
أمر التاريخ
msf6 > history
1 use exploit/multi/http/nostromo_code_exec
2 set lhost 10.10.16.17
3 set rport 80
4 options
5 set rhosts 10.10.29.187
6 run
7 exit
8 exit -y
9 version
10 use exploit/multi/script/web_delivery
ميزة مهمة في msfconsole هي دعم إكمال علامة التبويب. سيكون هذا مفيدًا لاحقًا عند استخدام أوامر Metasploit أو التعامل مع الوحدات. على سبيل المثال ، إذا بدأت في الكتابة
he
والضغط على مفتاح علامة التبويب ، فسترى أنه يكتمل تلقائيًا إلى help
.تتم إدارة Msfconsole حسب السياق ؛ هذا يعني أنه ما لم يتم تعيينها كمتغير عام ، فستفقد جميع إعدادات المعلمات إذا قمت بتغيير الوحدة التي قررت استخدامها. في المثال أدناه ، استخدمنا استغلال ms17_010_eternalblue ، وقمنا بتعيين معلمات مثل
RHOSTS
. إذا أردنا التبديل إلى وحدة نمطية أخرى (مثل ماسح المنافذ) ، فسنحتاج إلى تعيين قيمة RHOSTS مرة أخرى حيث ظلت جميع التغييرات التي أجريناها في سياق استغلال ms17_010_eternalblue. دعونا نلقي نظرة على المثال أدناه للحصول على فهم أفضل لهذه الميزة. سوف نستخدم استغلال MS17-010 “Eternalblue” لأغراض التوضيح.
بمجرد كتابة
use exploit/windows/smb/ms17_010_eternalblue
الأمر ، سترى تغيير موجه سطر الأوامر من msf6 إلى "استغلال msf6 (windows / smb / ms17_010_eternalblue)". "EternalBlue" هو استغلال تم تطويره من قبل وكالة الأمن القومي الأمريكية (NSA) لثغرة تؤثر على خادم SMBv1 على العديد من أنظمة Windows. يستخدم SMB (Server Message Block) على نطاق واسع في شبكات Windows لمشاركة الملفات وحتى لإرسال الملفات إلى الطابعات. تم تسريب EternalBlue من قبل مجموعة مجرمي الإنترنت "Shadow Brokers" في أبريل 2017. في مايو 2017 ، تم استغلال هذه الثغرة الأمنية في جميع أنحاء العالم في هجوم WannaCry ransomware.باستخدام استغلال
msf6 > use exploit/windows/smb/ms17_010_eternalblue
[*] No payload configured, defaulting to windows/x64/meterpreter/reverse_tcp
msf6 exploit(windows/smb/ms17_010_eternalblue) >
يمكن أيضًا تحديد الوحدة النمطية التي سيتم استخدامها باستخدام
use
الأمر متبوعًا بالرقم في بداية سطر نتيجة البحث.بينما تم تغيير الموجه ، ستلاحظ أنه لا يزال بإمكاننا تشغيل الأوامر المذكورة سابقًا. هذا يعني أننا لم "ندخل" مجلدًا كما تتوقع عادةً في سطر أوامر نظام التشغيل.
أوامر لينكس ضمن سياق
msf6 exploit(windows/smb/ms17_010_eternalblue) > ls
[*] exec: ls
burpsuite_community_linux_v2021_8_1.sh Instructions Scripts
Desktop Pictures thinclient_drives
Downloads Postman Tools
msf6 exploit(windows/smb/ms17_010_eternalblue) >
يخبرنا الموجه أن لدينا الآن مجموعة سياق سنعمل فيها. يمكنك رؤية هذا عن طريق كتابة أمر إظهار الخيارات.
عرض الخيارات
msf6 exploit(windows/smb/ms17_010_eternalblue) > show options
Module options (exploit/windows/smb/ms17_010_eternalblue):
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
RPORT 445 yes The target port (TCP)
SMBDomain . no (Optional) The Windows domain to use for authentication
SMBPass no (Optional) The password for the specified username
SMBUser no (Optional) The username to authenticate as
VERIFY_ARCH true yes Check if remote architecture matches exploit Target.
VERIFY_TARGET true yes Check if remote OS matches exploit Target.
Payload options (windows/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC thread yes Exit technique (Accepted: '', seh, thread, process, none)
LHOST 10.10.220.191 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Windows 7 and Server 2008 R2 (x64) All Service Packs
msf6 exploit(windows/smb/ms17_010_eternalblue) >
سيؤدي هذا إلى طباعة الخيارات المتعلقة بالاستغلال الذي اخترناه سابقًا. سيكون للأمر show options مخرجات مختلفة اعتمادًا على السياق المستخدم فيه. يوضح المثال أعلاه أن هذا الاستغلال سيتطلب منا تعيين متغيرات مثل RHOSTS و RPORT. من ناحية أخرى ، قد تحتاج وحدة ما بعد الاستغلال منا فقط إلى تعيين معرف الجلسة (انظر لقطة الشاشة أدناه). الجلسة عبارة عن اتصال موجود بالنظام المستهدف الذي ستستخدمه وحدة ما بعد الاستغلال.
خيارات لوحدة ما بعد الاستغلال
msf6 post(windows/gather/enum_domain_users) > show options
Module options (post/windows/gather/enum_domain_users):
Name Current Setting Required Description
---- --------------- -------- -----------
HOST no Target a specific host
SESSION yes The session to run this module on.
USER no Target User for NetSessionEnum
msf6 post(windows/gather/enum_domain_users) >
msf6 post(windows/gather/enum_domain_users) >
يمكن
show
استخدام الأمر في أي سياق متبوعًا بنوع وحدة (مساعدة ، حمولة ، استغلال ، إلخ) لسرد الوحدات المتاحة. يسرد المثال أدناه الحمولات التي يمكن استخدامها مع استغلال MS17-010 Eternalblue.الأمر show payloads
msf6 exploit(windows/smb/ms17_010_eternalblue) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 generic/custom manual No Custom Payload
1 generic/shell_bind_tcp manual No Generic Command Shell, Bind TCP Inline
2 generic/shell_reverse_tcp manual No Generic Command Shell, Reverse TCP Inline
3 windows/x64/exec manual No Windows x64 Execute Command
4 windows/x64/loadlibrary manual No Windows x64 LoadLibrary Path
5 windows/x64/messagebox manual No Windows MessageBox x64
6 windows/x64/meterpreter/bind_ipv6_tcp manual No Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager
7 windows/x64/meterpreter/bind_ipv6_tcp_uuid manual No Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager with UUID Support
إذا تم استخدامه من موجه msfconsole ، فسيسرد
show
الأمر جميع الوحدات.الأوامر
use
و show options
التي رأيناها حتى الآن متطابقة لجميع الوحدات في Metasploit.يمكنك ترك السياق باستخدام
back
الأمر.الأمر الخلفي
msf6 exploit(windows/smb/ms17_010_eternalblue) > back
msf6 >
يمكن الحصول على مزيد من المعلومات حول أي وحدة عن طريق كتابة
info
الأمر في سياقها.أمر المعلومات
msf6 exploit(windows/smb/ms17_010_eternalblue) > info
Name: MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
Module: exploit/windows/smb/ms17_010_eternalblue
Platform: Windows
Arch:
Privileged: Yes
License: Metasploit Framework License (BSD)
Rank: Average
Disclosed: 2017-03-14
Provided by:
Sean Dillon
Dylan Davis
Equation Group
Shadow Brokers
thelightcosine
Available targets:
Id Name
-- ----
0 Windows 7 and Server 2008 R2 (x64) All Service Packs
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
RPORT 445 yes The target port (TCP)
SMBDomain . no (Optional) The Windows domain to use for authentication
SMBPass no (Optional) The password for the specified username
SMBUser no (Optional) The username to authenticate as
VERIFY_ARCH true yes Check if remote architecture matches exploit Target.
VERIFY_TARGET true yes Check if remote OS matches exploit Target.
Payload information:
Space: 2000
Description:
This module is a port of the Equation Group ETERNALBLUE exploit,
part of the FuzzBunch toolkit released by Shadow Brokers. There is a
buffer overflow memmove operation in Srv!SrvOs2FeaToNt. The size is
calculated in Srv!SrvOs2FeaListSizeToNt, with mathematical error
where a DWORD is subtracted into a WORD. The kernel pool is groomed
so that overflow is well laid-out to overwrite an SMBv1 buffer.
Actual RIP hijack is later completed in
srvnet!SrvNetWskReceiveComplete. This exploit, like the original may
not trigger 100% of the time, and should be run continuously until
triggered. It seems like the pool will get hot streaks and need a
cool down period before the shells rain in again. The module will
attempt to use Anonymous login, by default, to authenticate to
perform the exploit. If the user supplies credentials in the
SMBUser, SMBPass, and SMBDomain options it will use those instead.
On some systems, this module may cause system instability and
crashes, such as a BSOD or a reboot. This may be more likely with
some payloads.
References:
https://docs.microsoft.com/en-us/security-updates/SecurityBulletins/2017/MS17-010
https://cvedetails.com/cve/CVE-2017-0143/
https://cvedetails.com/cve/CVE-2017-0144/
https://cvedetails.com/cve/CVE-2017-0145/
https://cvedetails.com/cve/CVE-2017-0146/
https://cvedetails.com/cve/CVE-2017-0147/
https://cvedetails.com/cve/CVE-2017-0148/
https://github.com/RiskSense-Ops/MS17-010
Also known as:
ETERNALBLUE
msf6 exploit(windows/smb/ms17_010_eternalblue) >
msf6 exploit(windows/smb/ms17_010_eternalblue) >
بدلاً من ذلك ، يمكنك استخدام
info
الأمر متبوعًا بمسار الوحدة من موجه msfconsole (على سبيل المثال info exploit/windows/smb/ms17_010_eternalblue
). المعلومات ليست قائمة مساعدة ؛ سيعرض معلومات مفصلة عن الوحدة مثل مؤلفها والمصادر ذات الصلة وما إلى ذلك.يبحث
أحد أكثر الأوامر المفيدة في msfconsole هو
search
. سيبحث هذا الأمر في قاعدة بيانات Metasploit Framework عن الوحدات ذات الصلة بمعامل البحث المحدد. يمكنك إجراء عمليات بحث باستخدام أرقام مكافحة التطرف العنيف ، أو استغلال الأسماء (الأزرق الخالد ، أو الحسناء ، وما إلى ذلك) ، أو النظام المستهدف.أمر البحث
msf6 > search ms17-010
Matching Modules
================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 auxiliary/admin/smb/ms17_010_command 2017-03-14 normal No MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Command Execution
1 auxiliary/scanner/smb/smb_ms17_010 normal No MS17-010 SMB RCE Detection
2 exploit/windows/smb/ms17_010_eternalblue 2017-03-14 average Yes MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
3 exploit/windows/smb/ms17_010_psexec 2017-03-14 normal Yes MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Code Execution
4 exploit/windows/smb/smb_doublepulsar_rce 2017-04-14 great Yes SMB DOUBLEPULSAR Remote Code Execution
Interact with a module by name or index, for example use 4 or use exploit/windows/smb/smb_doublepulsar_rce
msf6 >
msf6 >
يوفر إخراج
search
الأمر نظرة عامة على كل وحدة تم إرجاعها. قد تلاحظ أن عمود "الاسم" يعطي بالفعل معلومات أكثر من مجرد اسم الوحدة. يمكنك رؤية نوع الوحدة (مساعدة ، استغلال ، إلخ) وفئة الوحدة (ماسح ضوئي ، مسؤول ، نوافذ ، يونكس ، إلخ). يمكنك استخدام أي وحدة يتم إرجاعها في نتيجة البحث باستخدام الأمر متبوعًا بالرقم في بداية سطر النتيجة. (على سبيل المثال use 0
بدلاً من use auxiliary/admin/smb/ms17_010_command
)يتم إرجاع جزء أساسي آخر من المعلومات في عمود "الترتيب". يتم تصنيف برامج إكسبلويت بناءً على موثوقيتها. يقدم الجدول أدناه أوصاف كل منهما.

المصدر: هنا
يمكنك توجيه وظيفة البحث باستخدام كلمات رئيسية مثل النوع والنظام الأساسي.
على سبيل المثال ، إذا أردنا أن تتضمن نتائج البحث لدينا وحدات مساعدة فقط ، فيمكننا تعيين النوع إلى مساعد. تُظهر لقطة الشاشة أدناه إخراج نوع البحث: أمر telnet الإضافي.
البحث حسب نوع الوحدة
msf6 > search type:auxiliary telnet
Matching Modules
================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 auxiliary/admin/http/dlink_dir_300_600_exec_noauth 2013-02-04 normal No D-Link DIR-600 / DIR-300 Unauthenticated Remote Command Execution
1 auxiliary/admin/http/netgear_r6700_pass_reset 2020-06-15 normal Yes Netgear R6700v3 Unauthenticated LAN Admin Password Reset
2 auxiliary/dos/cisco/ios_telnet_rocem 2017-03-17 normal No Cisco IOS Telnet Denial of Service
3 auxiliary/dos/windows/ftp/iis75_ftpd_iac_bof 2010-12-21 normal No Microsoft IIS FTP Server Encoded Response Overflow Trigger
4 auxiliary/scanner/ssh/juniper_backdoor 2015-12-20 normal No Juniper SSH Backdoor Scanner
5 auxiliary/scanner/telnet/brocade_enable_login normal No Brocade Enable Login Check Scanner
6 auxiliary/scanner/telnet/lantronix_telnet_password normal No Lantronix Telnet Password Recovery
7 auxiliary/scanner/telnet/lantronix_telnet_version normal No Lantronix Telnet Service Banner Detection
8 auxiliary/scanner/telnet/satel_cmd_exec 2017-04-07 normal No Satel Iberia SenNet Data Logger and Electricity Meters Command Injection Vulnerability
9 auxiliary/scanner/telnet/telnet_encrypt_overflow normal No Telnet Service Encryption Key ID Overflow Detection
10 auxiliary/scanner/telnet/telnet_login normal No Telnet Login Check Scanner
11 auxiliary/scanner/telnet/telnet_ruggedcom normal No RuggedCom Telnet Password Generator
12 auxiliary/scanner/telnet/telnet_version normal No Telnet Service Banner Detection
13 auxiliary/server/capture/telnet normal No Authentication Capture: Telnet
Interact with a module by name or index, for example use 13 or use auxiliary/server/capture/telnet
msf6 >
msf6 >
يرجى تذكر أن عمليات الاستغلال تستفيد من ثغرة أمنية في النظام المستهدف وقد تظهر دائمًا سلوكًا غير متوقع. قد تعمل الثغرة ذات التصنيف المنخفض بشكل مثالي ، وقد لا تؤدي الثغرة ذات التصنيف الممتاز إلى تعطل النظام المستهدف أو ما هو أسوأ.
أجب على الأسئلة التالية في التعليقات
- كيف تبحث عن وحدة ذات صلة بـ Apache؟
- من قدم الوحدة المساعدة / الماسح / ssh / ssh_login؟
يتبع...
تعليقات: (0) إضافة تعليق