-
Notifications
You must be signed in to change notification settings - Fork 2
/
pokus.js
44 lines (28 loc) · 864 Bytes
/
pokus.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* Pokusy
*/
// Default config
global.config = {
myMAC: "11:22:33:44:55:66",
myIP: "10.0.0.99",
};
var sys = require('sys');
var Buffer = require('buffer').Buffer;
var tools = require('./tools');
var Pcap = require('pcap');
// Create UDP packet
var udp = new tools.UDPPacket( {}, "ABCDEFGH");
// Create ARP packet
var arp = new tools.ARPPacket( { target_pa: '10.0.0.127' } );
// Create IP packet
var ip = new tools.IPPacket( { daddr: '10.0.0.5' }, udp );
// Create Ethernet
var ethParams = { dhost: 'ff:ff:ff:ff:ff:ff' };
var eth = new tools.EthernetPacket(ethParams, ip);
console.log(sys.inspect(udp));
console.log(sys.inspect(udp.reply(null, "Krtek")));
return;
// Write to buffer
var buf = eth.encode();
console.log("Encoded packet is:", sys.inspect(buf));
console.log("After decode: ", sys.inspect(tools.EthernetPacket.decode(buf, 0)));