Prime1_解法一:cms渗透 & 内核漏洞提权
目录
信息收集
主机发现
nmap扫描
tcp扫描
- sudo nmap -sT --min-rate 10000 -oA tcpscan 192.168.236.134
复制代码- sudo nmap -sT -sV -O --min-rate 10000 -p80,22 -oA tcpscan_detail 192.168.236.134
复制代码 tcp详细扫描22,80端口
得到了openssh的版本号,apache的版本号,得知目标主机为一台linux
udp扫描
漏洞脚本扫描
唯一有用的提示是这里有一个wordpress的后台登岸页面,但这个目录爆破的过程应该也可以得到
目录爆破
dirsearch
- sudo dirsearch -u "http://192.168.236.134"
复制代码 得到这几个目录
/dev
/image.php
/wordpress/wp-login.php
/wordpress/
Web渗透
对信息收集的分析:
通过信息收集得到的信息,开放了22和80端口,目录爆破拿到了一些200的目录,那最感兴趣的就是先去看看一下80端口以及上面的各种目录有没有袒露给我们更多的信息
那就先访问ip:80端口只给了一张图片,检察源码也没有什么信息袒露出来
访问ip/dev ,给了如许一段文本- hello,
- now you are at level 0 stage.
- In real life pentesting we should use our tools to dig on a web very hard.
- Happy hacking.
复制代码 大概意思就是你在level 0阶段,在真实的渗透中我们应该用我们的工具更努力地去挖web(信息/漏洞)
我们用目录爆破得到的/dev,只爆破了80端口的路由,还并没有爆破指定文件,如果指定txt,zip,php,等后缀大概会得到新的发现- sudo dirb http://192.168.236.134/ -X .zip,.php,.html,.txt
复制代码 扫描效果- ┌──(㉿kali)-[~/prime1]
- └─$ sudo dirb http://192.168.236.134/ -X .zip,.php,.html,.txt
- -----------------
- DIRB v2.22
- By The Dark Raver
- -----------------
- START_TIME: Fri Nov 29 16:51:48 2024
- URL_BASE: http://192.168.236.134/
- WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt
- EXTENSIONS_LIST: (.zip,.php,.html,.txt) | (.zip)(.php)(.html)(.txt) [NUM = 4]
- -----------------
- GENERATED WORDS: 4612
- ---- Scanning URL: http://192.168.236.134/ ----
- + http://192.168.236.134/image.php (CODE:200|SIZE:147)
- + http://192.168.236.134/index.php (CODE:200|SIZE:136)
- + http://192.168.236.134/secret.txt (CODE:200|SIZE:412)
-
- -----------------
- END_TIME: Fri Nov 29 16:51:59 2024
- DOWNLOADED: 18448 - FOUND: 3
复制代码 得到了
/image.php
/index.php
/secret.txt
新发现一个/secret.txt
不会用的时候就去看help 这是dirb的help- -----------------
- DIRB v2.22
- By The Dark Raver
- dirb <url_base> [<wordlist_file(s)>] [options]
- ========================= NOTES =========================
- <url_base> : Base URL to scan. (Use -resume for session resuming)
- <wordlist_file(s)> : List of wordfiles. (wordfile1,wordfile2,wordfile3...)
- ======================== HOTKEYS ========================
- 'n' -> Go to next directory.
- 'q' -> Stop scan. (Saving state for resume)
- 'r' -> Remaining scan stats.
- ======================== OPTIONS ========================
- -a <agent_string> : Specify your custom USER_AGENT.
- -b : Use path as is.
- -c <cookie_string> : Set a cookie for the HTTP request.
- -E <certificate> : path to the client certificate.
- -f : Fine tunning of NOT_FOUND (404) detection.
- -H <header_string> : Add a custom header to the HTTP request.
- -i : Use case-insensitive search.
- -l : Print "Location" header when found.
- -N <nf_code>: Ignore responses with this HTTP code.
- -o <output_file> : Save output to disk.
- -p <proxy[:port]> : Use this proxy. (Default port is 1080)
- -P <proxy_username:proxy_password> : Proxy Authentication.
- -r : Don't search recursively.
- -R : Interactive recursion. (Asks for each directory)
- -S : Silent Mode. Don't show tested words. (For dumb terminals)
- -t : Don't force an ending '/' on URLs.
- -u <username:password> : HTTP Authentication.
- -v : Show also NOT_FOUND pages.
- -w : Don't stop on WARNING messages.
- -X <extensions> / -x <exts_file> : Append each word with this extensions.
- -z <millisecs> : Add a milliseconds delay to not cause excessive Flood.
- ======================== EXAMPLES =======================
- dirb http://url/directory/ (Simple Test)
- dirb http://url/ -X .html (Test files with '.html' extension)
- dirb http://url/ /usr/share/dirb/wordlists/vulns/apache.txt (Test with apache.txt wordlist)
- dirb https://secure_url/ (Simple Test with SSL)
复制代码 访问/secret.txt- Looks like you have got some secrets.
- Ok I just want to do some help to you.
- Do some more fuzz on every page of php which was finded by you. And if
- you get any right parameter then follow the below steps. If you still stuck
- Learn from here a basic tool with good usage for OSCP.
- https://github.com/hacknpentest/Fuzzing/blob/master/Fuzz_For_Web
-
- //see the location.txt and you will get your next move//
复制代码 大概就是给了一点tips,让我们尝试fuzz每一个php页面,并给了一个github的链接,是一个fuzz的教程,告诉我们,在得到新进展之后看看location.txt- COMMAND = wfuzz -c -w /usr/share/wfuzz/wordlist/general/common.txt --hc 404 --hw 500 http://website-ip/index.php?FUZZ=something
复制代码 wfuzz
我们有两个php文件,尝试fuzz- sudo wfuzz -c -w /usr/share/wfuzz/wordlist/general/common.txt http://192.168.236.134/index.php?FUZZ=1
复制代码 可以看到wfuzz尝试了很多参数,chars为136大概word为12w可以作为判定无意义参数的标指,我们将其过滤掉会更快速地帮助我们找到有意义的参数
- 加一个过滤器
- sudo wfuzz -c -w /usr/share/wfuzz/wordlist/general/common.txt --hh 136 http://192.168.236.134/index.php?FUZZ=1
复制代码
chars为206,说明这个用参数大概会回显一些信息
curl访问一下,file随意get方式给个值大概不给都行- └─$ sudo curl http://192.168.236.134/index.php?file=1
- <html>
- <title>HacknPentest</title>
- <body>
- <img src='https://www.cnblogs.com/hacknpentest.png' alt='hnp security' width="1300" height="595" />
- </body>
- Do something better
- you are digging wrong file</html>
复制代码 告诉我们你挖错文件了,do something better,想起之前地location.txt 尝试将他给file- sudo curl http://192.168.236.134/index.php?file=location.txt
- <html>
- <title>HacknPentest</title>
- <body>
- <img src='https://www.cnblogs.com/hacknpentest.png' alt='hnp security' width="1300" height="595" />
- </body>
- Do something better
- ok well Now you reah at the exact parameter
- Now dig some more for next one
- use 'secrettier360' parameter on some other php page for more fun.
- </html>
复制代码 让我们用这个参数secrettier360到其他的php页面- sudo curl http://192.168.236.134/image.php?secrettier360
- <html>
- <title>HacknPentest</title>
- <body>
- <img src='https://www.cnblogs.com/hacknpentest.png' alt='hnp security' width="1300" height="595" /></p></p></p>
- </body>0
- finaly you got the right parameter
- </html>
复制代码 常见的 wfuzz 过滤器:
- --hc (HTTP Code filter)
- 用于根据 HTTP 相应码过滤效果。
- 例如:–hc 404 会过滤掉返回 404 状态码的相应。
- 示例:wfuzz -c -z file,/path/to/wordlist.txt --hc 404 http://example.com/FUZZ
- --hl (Content Length filter)
- 用于根据相应内容的长度过滤效果。
- 例如:–hl 0 会过滤掉相应内容长度为 0 的效果。
- 示例:wfuzz -c -z file,/path/to/wordlist.txt --hl 0 http://example.com/FUZZ
- --hw (Words in response filter)
- 用于根据相应体中返回的单词数举行过滤。
- 例如:–hw 10 会过滤掉相应体包含少于 10 个单词的效果。
- 示例:wfuzz -c -z file,/path/to/wordlist.txt --hw 10 http://example.com/FUZZ
- --hh (Headers filter)
- 用于根据 HTTP 相应头举行过滤。
- 例如:–hh 'Content-Type' 可以过滤掉所有相应头中包含 Content-Type 的效果。
- 示例:wfuzz -c -z file,/path/to/wordlist.txt --hh 'Content-Type' http://example.com/FUZZ
- --sc (Status Code filter)
- 用于根据相应的 HTTP 状态码范围过滤。
- 例如:–sc 200-299 会仅显示相应状态码在 200 到 299 之间的效果。
- 示例:wfuzz -c -z file,/path/to/wordlist.txt --sc 200-299 http://example.com/FUZZ
- --sl (Response Size filter)
- 用于根据相应体的巨细举行过滤。
- 例如:–sl 100-500 会仅显示相应巨细在 100 到 500 字节之间的效果。
- 示例:wfuzz -c -z file,/path/to/wordlist.txt --sl 100-500 http://example.com/FUZZ
- --sw (String Words filter)
- 用于根据相应中包含的特定字符串举行过滤。
- 例如:–sw 'Not Found' 会过滤偷换含字符串 Not Found 的相应。
- 示例:wfuzz -c -z file,/path/to/wordlist.txt --sw 'error' http://example.com/FUZZ
- --sh (String Headers filter)
- 用于根据 HTTP 相应头中包含的特定字符串举行过滤。
- 例如:–sh 'X-Error' 会过滤掉相应头中包含 X-Error 的效果。
- 示例:wfuzz -c -z file,/path/to/wordlist.txt --sh 'X-Error' http://example.com/FUZZ
- --ss (String Search filter)
- 用于根据相应体中的字符串举行过滤。
- 例如:–ss 'flag' 会仅显示相应体中包含 flag 字符串的效果。
- 示例:wfuzz -c -z file,/path/to/wordlist.txt --ss 'flag' http://example.com/FUZZ
- --hs (Header Search filter)
- 用于根据 HTTP 相应头中的特定字符串举行搜索过滤。
- 例如:–hs 'Set-Cookie' 会仅显示相应头中包含 Set-Cookie 字符串的效果。
- 示例:wfuzz -c -z file,/path/to/wordlist.txt --hs 'Set-Cookie' http://example.com/FUZZ
获得wordpress后台权限
成功文件包含读取到/etc/passwd(../多打几个退到根目录,不限制的话多了../也没关系)- saket\:x:1001:1001:find password.txt file in my directory:/home/saket:
复制代码 通过提示得知这里有一个password.txt
follow_the_ippsec
结合对wordpress的信息收集,发现有一个victor用户,发表过文章,有大概是管理员,尝试利用这组凭据去/wp-login.php登录,成功进入后台
wordpress cms渗透
利用metasploit探测wordpress的cms版本为5.2.2- 运行metasploit模块
- sudo msfconsole
- 指定使用WordPress扫描模块
- msf6 > use auxiliary/scanner/http/wordpress_scanner
- 设置SSL证书
- msf6 auxiliary(scanner/http/wordpress_scanner) > set ssl true
- 设置目标端口
- msf6 auxiliary(scanner/http/wordpress_scanner) > set rport 80
- 目标hosts
- msf6 auxiliary(scanner/http/wordpress_scanner) > set rhosts http://192.168.236.134/wordpress
- 运行
- msf6 auxiliary(scanner/http/wordpress_scanner) > run
复制代码
WordPress 侦察和罗列
针对wordpress的信息收集这里找了一篇github上的文章
apachecn-kali-zh/docs/handson-web-pentest-metasploit/08.md at master · apachecn/apachecn-kali-zh
在您开始利用 WordPress 的任何插件/主题/焦点漏洞之前,第一步是确认该站点是否位于 WordPress 上。至于检测 WordPress 本身,检测 WordPress CMS 安装的方法有多种:
- 在 HTML 页面源中搜索wp-content字符串。
- 查找 WordPress 安装时返回的/wp-trackback.php或/wp-links-opml.php文件名。
- 您也可以尝试/wp-admin/admin-ajax.php和/wp-login.php。
- 查找静态文件,如readme.html和/wp-includes/js/colorpicker.js。
一旦确认站点正在 WordPress 上运行,下一步就是要知道目标服务器上运行的是哪个版本的 WordPress。要实现这一点,您需要知道检测其版本号的差别方法。为什么是版本号?因为基于目标服务器上安装的 WordPress 版本,您可以测试基于插件或 WordPress 焦点的漏洞利用,这些漏洞大概公开,也大概不公开。
版本检测
每个 WordPress 安装都有一个版本号。在最新的 WordPress 版本中,默认环境下隐藏了版本号,但我们仍然可以罗列版本。在本节中,您将学习一些辨认正在运行哪个版本的 WordPress 的方法。
最常见的侦察技术有Readme.html、元天生器、提要(RDF、Atom 和 RSS)、插件和主题(JS 和 CSS 版本)以及散列匹配。
自述文件
这是最简朴的技巧。我们所要做的就是访问readme.html页面,它在中间披露了版本号。该文件的最初目标是向 CMS 的首次用户提供有关如何继续安装和利用 WordPress 的信息。安装和设置完成后,应将其删除。利用任何工具(包括 Metasploit)时,在执行任何类型的攻击之前,请始终检查 WordPress 安装的版本号。
以是,确保您知道要测试的版本。您可以在以下屏幕截图中看到readme.html的示例:
接下来,我们将研究元天生器。
元天生器
具有generator名称属性的元标志通常被形貌为用于天生文档/网页的软件。确切的版本号在 meta 标签的content属性中公开。基于 WordPress 的网站通常在其源代码中有此标志,如以下屏幕截图所示:
接下来,我们将看到如何通过 JavaScript 和 CSS 文件获得该版本。
通过 JavaScript 和 CSS 文件获取版本
另一种查找版本号的方法是检察以下文件的源代码。以下文件请求 JS 和 CSS 文件:
- wp-admin/install.php
- wp-admin/upgrade.php
- wp-login.php
它们在其ver参数中披露了确切的版本号,如以下屏幕截图所示:
接下来,我们将看到如何通过提要获取版本。
通过提要获取版本
有时,版本信息也大概在网站的提要中披露。以下文件路径可用于披露版本信息:
- /index.php/feed/
- /index.php/feed/rss/
- /index.php/feed/rss2/
- /index.php/comments/feed/
- /index.php/feed/rdf/(文件在本地下载)
- /index.php/feed/atom/
- /?feed=atom
- /?feed=rss
- /?feed=rss2
- /?feed=rdf
以下屏幕截图显示了通过提要披露的版本:
接下来,我们将研究 OPML。
利用大纲处理器标志语言(OPML)
OPML 是用于大纲的 XML 格式(定义为树,其中每个节点包含一组具有字符串值的命名属性)。以下文件允许 WordPress 从其他网站导入链接,只要它们是 OPML 格式,但访问此文件也会披露版本信息(在 HTML 注释标志之间),如以下屏幕截图所示:这可以在以下屏幕截图中看到:
反弹shell
在Appearance的Theme Editor模块中找到了secret.php,说你终于找到了一个可写的文件
写入一句话木马
[code] |