是否可以不向人们正在对我的节点/快速站点进行渗透测试的 URL 发送响应?



我在我的网站上记录了所有404。我一直为我没有链接到的页面获取它们,显然是有人(机器人)试图在我的网站上查找管理页面/安全文件,例如/wp-admin.php;

router.get('/wp-admin.php', function(req, res, next) {});

我试过这个,它似乎没有阻止服务器,它只是在一分钟后输出这样的东西:

GET /wp-admin.php - - ms - -

添加此类路由是否有任何损害,其中没有发送响应,可能会浪费他们的时间?

router.get('/wp-admin.php', function(req, res, next) {});

这将导致快递超时并关闭连接。这将使黑客更容易进行拒绝服务攻击并堵塞您的节点服务器。 您始终可以使用某种速率限制器来防止来自某个 IP 的连续请求。

快速速率限制 是一个可以用于此。它是简单的快速中间件

正如已经接受的答案中所指出的,像这样的快速路线会让你容易受到攻击。

我建议更进一步,使用req.destroy来拆除这些请求。

不过,我不确定Express是否包含在这里的含义。例如,请求正文是否由您显示的此请求处理程序上游的中间件自动读取?如果是这样,那将是一个攻击媒介,使我建议的缓解措施毫无用处。

无论如何,为了演示我对普通HTTP服务器的建议:

var h = require('http')
h.createServer(function(req, res) {
// tear down the socket as soon as the request event is emitted
req.destroy()
}).listen(8888, function() {
// send a request to the server we just created
var r = h.request({port: 8888})
r.on('response', console.log.bind(console, 'on_response'))
r.on('error', console.log.bind(console, 'on_error'))
r.on('timeout', console.log.bind(console, 'on_timeout'))
// abort will be emitted to the caller, but nothing else
r.on('abort', console.log.bind(console, 'on_abort'))
r.end()
})

如果您能够以某种方式将呼叫代理识别为机器人(或其他任何),您还可以在 HTTP 服务器的connection事件中调用socket.destroy

var h = require('http')
h.createServer(function(req, res) {
res.send('foo')
}).on('connection', function(socket) {
// pretend this ip address is the remote address of an attacker, for example
if (socket.remoteAddress === '10.0.0.0') {
socket.destroy()
}
}).listen(8888, function() {
// send a request to the server we just created
var r = h.request({port: 8888})
r.on('response', console.log.bind(console, 'on_response'))
r.on('error', console.log.bind(console, 'on_error'))
r.on('timeout', console.log.bind(console, 'on_timeout'))
// abort will be emitted to the caller, but nothing else
r.on('abort', console.log.bind(console, 'on_abort'))
r.end()
})

最新更新