当前位置:网站首页>hackmyvm: again walkthrough
hackmyvm: again walkthrough
2022-08-02 03:59:00 【xdeclearn】
1. 命令执行获取shell
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
访问web,Get username and hint.
下载 upload.bck.
<?php
if (!isset($_FILES["myFile"])) {
die("There is no file to upload.");
}
$filepath = $_FILES['myFile']['tmp_name'];
$fileSize = filesize($filepath);
$fileinfo = finfo_open(FILEINFO_MIME_TYPE);
$filetype = finfo_file($fileinfo, $filepath);
if ($fileSize === 0) {
die("The file is empty.");
}
$allowedTypes = [
'image/jpeg' => 'jpg',
'text/plain' => 'txt'
];
if (!in_array($filetype, array_keys($allowedTypes))) {
echo $filetype;
die("File not allowed.");
}
$filename = basename($filepath);
$extension = $allowedTypes[$filetype];
$newFilepath = $_FILES['myFile']['name'];
if (!copy($filepath, $newFilepath)) {
die("Can't move file.");
}
$blacklistchars = '"%\'*|$;^`{}~\\#=&';
if (preg_match('/[' . $blacklistchars . ']/', $newFilepath)) {
echo ("No valid character detected");
exit();
}
if ($filetype === "image/jpeg"){
echo $newFilepath;
$myfile = fopen("outputimage.php", "w") or die("Unable to open file!");
$command = "base64 ".$newFilepath;
$output = shell_exec($command);
unlink($newFilepath);
echo "File uploaded";
$lol = '<img src="data:image/png;base64,'.$output.'" alt="Happy" />';
fwrite($myfile, $lol);
}
else{
$myfile2 = fopen("outputtext.txt", "w") or die("Unable to open file!");
$command = "cat ".$newFilepath;
$output = shell_exec($command);
unlink($newFilepath);
echo "File uploaded";
fwrite($myfile2, $output);
}
?>
The exploitation process is a two-step process:
- 利用txt上传一段base64编码的php反弹shell.
base64 phpreverseshell.php > tmp.txt
Upload via the upload pagetxt.
- 利用上传
jpg图片利用base64 -ddecode uploadtxt写入shell,并访问.
成功获取shell.
2. 提权
运行getcap查看特殊文件,发现php7.4具有cap_fowner权限.
修改/etc/passwd权限,将root:x:****改为root::****,成功切换至root.

[email protected]:/tmp$ su - root
su - root
[email protected]:~# ls -all
ls -all
total 28
drwx------ 3 root root 4096 Oct 12 17:36 .
drwxr-xr-x 18 root root 4096 Oct 11 07:33 ..
-rw------- 1 root root 155 Oct 12 17:36 .bash_history
-rw-r--r-- 1 root root 571 Apr 10 2021 .bashrc
drwxr-xr-x 3 root root 4096 Oct 11 07:38 .local
-rw-r--r-- 1 root root 161 Jul 9 2019 .profile
-rw------- 1 root root 25 Oct 11 07:41 r00t.txt
[email protected]:~#
边栏推荐
- hackmyvm: juggling walkthrough
- 14. JS Statements and Comments, Variables and Data Types
- 解决 Zlibrary 卡死/找不到域名/达到限额问题,Zlibrary最新地址
- (1) print()函数、转义字符、二进制与字符编码 、变量、数据类型、input()函数、运算符
- What are the PHP framework?
- Basic use of v-on, parameter passing, modifiers
- 12.什么是JS
- [symfony/finder]最好用的文件操作库
- 17.JS条件语句和循环,以及数据类型转换
- PHP入门(自学笔记)
猜你喜欢

解决 Zlibrary 卡死/找不到域名/达到限额问题,Zlibrary最新地址

(2) Thinkphp6 template engine ** tag

Solve the problem of Zlibrary stuck/can't find the domain name/reached the limit, the latest address of Zlibrary

CTF入门笔记之ping

(2) 顺序结构、对象的布尔值、选择结构、循环结构、列表、字典、元组、集合

PHP8.2的版本发布管理员和发布计划

ES6三点运算符、数组方法、字符串扩展方法

GreenOptic: 1 vulnhub walkthrough

Pycharm打包项目为exe文件

(7) superficial "crawlers" process (concept + practice)
随机推荐
轮播图详解(完整代码在最后)
hackmyvm-hopper walkthrough
12.什么是JS
kali安装IDEA
[league/climate] A robust command-line function manipulation library
New usage of string variable parsing in PHP8.2
批量替换文件字体,简体-&gt;繁体
Praying: 1 vulnhub walkthrough
IP access control: teach you how to implement an IP firewall with PHP
CTF入门笔记之ping
4. The form with the input
攻防世界—MISC 新手区1-12
2. PHP variables, output, EOF, conditional statements
4.PHP数组与数组排序
PHP8.2中字符串变量解析的新用法
[league/flysystem]一个优雅且支持度非常高的文件操作接口
[symfony/finder] The best file manipulation library
(3) Thinkphp6 database
Introduction to PHP (self-study notes)
hackmyvm: kitty walkthrough