编辑1
搞定了
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace AmsiTest {
class Program {
static void Main( string[] args ) {
var virus = Encoding.UTF8.GetBytes(
"X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"
);
IntPtr context;
var hrInit = AmsiInitialize( "AmsiTest", out context );
if( hrInit != 0 ) {
Console.WriteLine( $"AmsiInitialize failed, HRESULT {hrInit:X8}" );
return;
}
AMSI_RESULT result;
var hrScan = AmsiScanBuffer(
context, virus, (uint)virus.Length,
"EICAR Test File", IntPtr.Zero, out result
);
AmsiUninitialize( context );
if( hrScan != 0 ) {
Console.WriteLine( $"AmsiScanBuffer failed, HRESULT {hrScan:X8}" );
} else if( result == AMSI_RESULT.AMSI_RESULT_DETECTED ) {
Console.WriteLine( "Detected EICAR test" );
} else {
Console.WriteLine( $"Failed to detect EICAR test, result {result:X8}" );
}
}
public enum AMSI_RESULT {
AMSI_RESULT_CLEAN = 0,
AMSI_RESULT_NOT_DETECTED = 1,
AMSI_RESULT_BLOCKED_BY_ADMIN_START = 16384,
AMSI_RESULT_BLOCKED_BY_ADMIN_END = 20479,
AMSI_RESULT_DETECTED = 32768
}
[DllImport( "Amsi.dll" )]
public static extern uint AmsiInitialize(
string appName,
out IntPtr amsiContext
);
[DllImport( "Amsi.dll" )]
public static extern uint AmsiScanBuffer(
IntPtr amsiContext,
byte[] buffer,
uint length,
string contentName,
IntPtr session,
out AMSI_RESULT result
);
[DllImport( "Amsi.dll" )]
public static extern void AmsiUninitialize(
IntPtr amsiContext
);
}
}
我必须指定一条获取路线,但这似乎真的不安全,因为我不想让任何人只是访问这个页面,也许我是在过度思考它?
-
原始问题
目前我正在设置重置密码系统系统,电子邮件正在发送,并且正在生成带有令牌的网址,但是当我点击链接转到新密码页面时,我得到以下内容
// Reset Password Token link :get
router.get('/users/reset-password/:token', function(req, res) {
User.findOne({ resetPasswordToken: req.params.token, resetPasswordExpires: { $gt: Date.now() } }, function(err, user) {
if (!user) {
req.flash('error', 'Password reset token is invalid or has expired.');
return res.redirect(302, '/users/new-password');
}
res.redirect(301, 'reset-password', {
user: req.user
});
});
});
router.get('/users/new-password', function(req, res) {
res.render('new-password', {
pageTitle: 'New Password',
User: req.user
});
});
这是我的路线
Fri Jan 12 2018 23:49:37 GMT+0000 (GMT): GET /users/reset-password/23afd201c93945bfec7131801b377ea92edfc1fa
express deprecated res.redirect(url, status): Use res.redirect(status, url) instead routes/users.js:298:9
events.js:136
throw er; // Unhandled 'error' event
^
RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: [object Object]
感谢。
答案 0 :(得分:0)
来自@ jfriend00的评论
Look at the doc for res.redirect(). It takes two parameters, an optional status code and a path. There is no parameter for an object like you are trying to use. So, either use res.redirect('/users/reset-password') or res.redirect(302, '/users/reset-password'). If you want to put a query string in the URL, then put that into the path itself. – jfriend00 14 mins ago