Prime1_解法一:cms渗透 & 内核漏洞提权

打印 上一主题 下一主题

主题 895|帖子 895|积分 2685

Prime1_解法一:cms渗透 & 内核漏洞提权


目录

信息收集

主机发现

nmap扫描

tcp扫描
  1. sudo nmap -sT --min-rate 10000 -oA tcpscan 192.168.236.134
复制代码
  1. 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
  1. 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 ,给了如许一段文本
  1. hello,
  2. now you are at level 0 stage.
  3. In real life pentesting we should use our tools to dig on a web very hard.
  4. Happy hacking.
复制代码
大概意思就是你在level 0阶段,在真实的渗透中我们应该用我们的工具更努力地去挖web(信息/漏洞)
我们用目录爆破得到的/dev,只爆破了80端口的路由,还并没有爆破指定文件,如果指定txt,zip,php,等后缀大概会得到新的发现
  1. sudo dirb http://192.168.236.134/ -X .zip,.php,.html,.txt
复制代码
扫描效果
  1. ┌──(㉿kali)-[~/prime1]
  2. └─$ sudo dirb http://192.168.236.134/ -X .zip,.php,.html,.txt
  3. -----------------
  4. DIRB v2.22   
  5. By The Dark Raver
  6. -----------------
  7. START_TIME: Fri Nov 29 16:51:48 2024
  8. URL_BASE: http://192.168.236.134/
  9. WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt
  10. EXTENSIONS_LIST: (.zip,.php,.html,.txt) | (.zip)(.php)(.html)(.txt) [NUM = 4]
  11. -----------------
  12. GENERATED WORDS: 4612                                                         
  13. ---- Scanning URL: http://192.168.236.134/ ----
  14. + http://192.168.236.134/image.php (CODE:200|SIZE:147)                                                                                                                                          
  15. + http://192.168.236.134/index.php (CODE:200|SIZE:136)                                                                                                                                          
  16. + http://192.168.236.134/secret.txt (CODE:200|SIZE:412)                                                                                                                                          
  17.                                                                                                                                                                                                 
  18. -----------------
  19. END_TIME: Fri Nov 29 16:51:59 2024
  20. DOWNLOADED: 18448 - FOUND: 3
复制代码
得到了
/image.php
/index.php
/secret.txt
新发现一个/secret.txt
不会用的时候就去看help 这是dirb的help
  1. -----------------
  2. DIRB v2.22   
  3. By The Dark Raver
  4. dirb <url_base> [<wordlist_file(s)>] [options]
  5. ========================= NOTES =========================
  6. <url_base> : Base URL to scan. (Use -resume for session resuming)
  7. <wordlist_file(s)> : List of wordfiles. (wordfile1,wordfile2,wordfile3...)
  8. ======================== HOTKEYS ========================
  9. 'n' -> Go to next directory.
  10. 'q' -> Stop scan. (Saving state for resume)
  11. 'r' -> Remaining scan stats.
  12. ======================== OPTIONS ========================
  13. -a <agent_string> : Specify your custom USER_AGENT.
  14. -b : Use path as is.
  15. -c <cookie_string> : Set a cookie for the HTTP request.
  16. -E <certificate> : path to the client certificate.
  17. -f : Fine tunning of NOT_FOUND (404) detection.
  18. -H <header_string> : Add a custom header to the HTTP request.
  19. -i : Use case-insensitive search.
  20. -l : Print "Location" header when found.
  21. -N <nf_code>: Ignore responses with this HTTP code.
  22. -o <output_file> : Save output to disk.
  23. -p <proxy[:port]> : Use this proxy. (Default port is 1080)
  24. -P <proxy_username:proxy_password> : Proxy Authentication.
  25. -r : Don't search recursively.
  26. -R : Interactive recursion. (Asks for each directory)
  27. -S : Silent Mode. Don't show tested words. (For dumb terminals)
  28. -t : Don't force an ending '/' on URLs.
  29. -u <username:password> : HTTP Authentication.
  30. -v : Show also NOT_FOUND pages.
  31. -w : Don't stop on WARNING messages.
  32. -X <extensions> / -x <exts_file> : Append each word with this extensions.
  33. -z <millisecs> : Add a milliseconds delay to not cause excessive Flood.
  34. ======================== EXAMPLES =======================
  35. dirb http://url/directory/ (Simple Test)
  36. dirb http://url/ -X .html (Test files with '.html' extension)
  37. dirb http://url/ /usr/share/dirb/wordlists/vulns/apache.txt (Test with apache.txt wordlist)
  38. dirb https://secure_url/ (Simple Test with SSL)
复制代码
访问/secret.txt
  1. Looks like you have got some secrets.
  2. Ok I just want to do some help to you.
  3. Do some more fuzz on every page of php which was finded by you. And if
  4. you get any right parameter then follow the below steps. If you still stuck
  5. Learn from here a basic tool with good usage for OSCP.
  6. https://github.com/hacknpentest/Fuzzing/blob/master/Fuzz_For_Web
  7. //see the location.txt and you will get your next move//
复制代码
大概就是给了一点tips,让我们尝试fuzz每一个php页面,并给了一个github的链接,是一个fuzz的教程,告诉我们,在得到新进展之后看看location.txt
  1. 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
  1. 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可以作为判定无意义参数的标指,我们将其过滤掉会更快速地帮助我们找到有意义的参数
  1. 加一个过滤器
  2. 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方式给个值大概不给都行
  1. └─$ sudo curl http://192.168.236.134/index.php?file=1   
  2. <html>
  3. <title>HacknPentest</title>
  4. <body>
  5. <img src='https://www.cnblogs.com/hacknpentest.png' alt='hnp security' width="1300" height="595" />
  6. </body>
  7. Do something better





  8. you are digging wrong file</html>
复制代码
告诉我们你挖错文件了,do something better,想起之前地location.txt 尝试将他给file
  1. sudo curl http://192.168.236.134/index.php?file=location.txt
  2. <html>
  3. <title>HacknPentest</title>
  4. <body>
  5. <img src='https://www.cnblogs.com/hacknpentest.png' alt='hnp security' width="1300" height="595" />
  6. </body>
  7. Do something better





  8. ok well Now you reah at the exact parameter

  9. Now dig some more for next one
  10. use 'secrettier360' parameter on some other php page for more fun.
  11. </html>
复制代码
让我们用这个参数secrettier360到其他的php页面
  1. sudo curl http://192.168.236.134/image.php?secrettier360                                                  
  2. <html>
  3. <title>HacknPentest</title>
  4. <body>
  5. <img src='https://www.cnblogs.com/hacknpentest.png' alt='hnp security' width="1300" height="595" /></p></p></p>
  6. </body>0
  7. finaly you got the right parameter



  8. </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(../多打几个退到根目录,不限制的话多了../也没关系)
  1. 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
  1. 运行metasploit模块
  2. sudo msfconsole
  3. 指定使用WordPress扫描模块
  4. msf6 > use auxiliary/scanner/http/wordpress_scanner
  5. 设置SSL证书
  6. msf6 auxiliary(scanner/http/wordpress_scanner) > set ssl true
  7. 设置目标端口
  8. msf6 auxiliary(scanner/http/wordpress_scanner) > set rport 80
  9. 目标hosts
  10. msf6 auxiliary(scanner/http/wordpress_scanner) > set rhosts http://192.168.236.134/wordpress
  11. 运行
  12. 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 注释标志之间),如以下屏幕截图所示:
  1. /wp-links-opml.php
复制代码
这可以在以下屏幕截图中看到:

反弹shell

在Appearance的Theme Editor模块中找到了secret.php,说你终于找到了一个可写的文件

写入一句话木马
[code]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

圆咕噜咕噜

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表