Skip to content

Resend packet captured from Wireshark #96

Description

@wyxcoder

With Wireshark, I capture a websoket packet with the below code
var device = Cap.findDevice('192.168.1.161');
var filter = 'tcp and dst port 54592';

Now I have hex stream of a packet like d5404e297c8575b980c20b32501801fcb35c0000

I want to send the packet from nodejs code, but the below code doesn't work?

var Cap = require('cap').Cap;
var c = new Cap();
var device = Cap.findDevice('192.168.1.161');
var filter = 'tcp';
var bufSize = 10 * 1024 * 1024;
var buffer = Buffer.alloc(65535);

var linkType = c.open(device, filter, bufSize, buffer);

var buffer = Buffer.from("d5404e297c8575b980c20b32501801fcb35c0000");
try {
c.send(buffer, buffer.length);
console.log("sent");
} catch (e) {
console.log("Error sending packet:", e);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions