当前位置:网站首页>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 -d
decode 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]:~#
边栏推荐
- Various ways of AES encryption
- 1. Beginning with PHP
- PHP入门(自学笔记)
- What will be new in PHP8.2?
- Solve the problem of Zlibrary stuck/can't find the domain name/reached the limit, the latest address of Zlibrary
- kali安装IDEA
- DarkHole: 2 vulnhub walkthrough
- 17. JS conditional statements and loops, and data type conversion
- PHP图片压缩到指定的大小
- What are the PHP framework?
猜你喜欢
攻防世界—MISC 新手区1-12
Solve the problem of Zlibrary stuck/can't find the domain name/reached the limit, the latest address of Zlibrary
Kali环境下Frida编写脚本智能提示
(5) Modules and packages, encoding formats, file operations, directory operations
CTF-网鼎杯往届题目
[sebastian/diff]一个比较两段文本的历史变化扩展库
The Error in the render: "TypeError: always read the properties of null '0' (reading)" Error solution
(2)Thinkphp6模板引擎**标签
4. The form with the input
Praying: 1 vulnhub walkthrough
随机推荐
Function hoisting and variable hoisting
(3) 字符串
Pycharm打包项目为exe文件
Solve the problem of Zlibrary stuck/can't find the domain name/reached the limit, the latest address of Zlibrary
关于tp的apache 的.htaccess文件
PHP有哪些框架?
Eric靶机渗透测试通关全教程
JS objects, functions and scopes
数组的高级操作
1. Beginning with PHP
VIKINGS: 1 vulnhub walkthrough
解决uni-app 打包H5网站 下载图片问题
[league/flysystem]一个优雅且支持度非常高的文件操作接口
17. JS conditional statements and loops, and data type conversion
二维码生成API接口,可以直接作为A标签连接
QR code generation API interface, which can be directly connected as an A tag
(1)Thinkphp6入门、安装视图、模板渲染、变量赋值
动力:2 vulnhub预排
What are the killer super powerful frameworks or libraries or applications for PHP?
hackmyvm-bunny walkthrough