在Node js中发送低级原始HTTP/HTTPS请求



我正在编写一个拦截代理工具,如Burpsuite,用于安全测试。其中一个重要的部分是发送格式错误的HTTP请求,在这种情况下,我们必须让用户完全控制请求!

所以,在使用库时,我无法完全控制!我需要能够向目标主机发送原始HTTP请求,如

GET / HTTP/1.1
Host: google.com

我的尝试:-

我尝试使用节点JS net模块,我能够连接到端口80(HTTP(上的主机,并且在连接到端口443(

HTTP在一些研究中,我发现这与SSL有关,因为我尝试了telnet,但对于HTTPS连接,它也失败了,并且通过查看一些stackoverflow答案!

有没有任何选项可以让我直接从节点应用程序发送原始HTTP/HTTPS请求?

谢谢!

有一个模块http标记,它允许编写文字http消息,如-

const net = require('net')
const HTTPTag = require('http-tag')
const socket = net.createConnection({
host: 'localhost',
port: 8000,
}, () => {
// This callback is run once, when socket connected
// Instead of manually writing like this:
// socket.write('GET / HTTP/1.1rn')
// socket.write('My-Custom-Header: Header1rnrn')

// You will be able to write your request(or response) like this:
const xHeader = 'Header1' // here in the epressions you can pass any characters you want
socket.write(
HTTPTag`
GET / HTTP/1.1
My-Custom-Header: ${xHeader}

`
)
socket.end()
})
socket.on('close', hasError => console.log(`Socket Closed, hasError: ${hasError}`))
// set readable stream encoding
socket.setEncoding('utf-8')
socket.on('data', data => console.log(data))

关于TLS,目前我正在研究内置节点模块,还没有查看TLS。

最新更新