-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial changes nfpacket object. Removed directional state tracking (For logging) Does not currently compromise security.
- Loading branch information
Dustyn Blackmore
committed
May 12, 2018
1 parent
2129aff
commit 718ba9a
Showing
6 changed files
with
55 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const encoding = (dependencies) => (nfpacket) => ({ | ||
decode: () => { | ||
let IPv4 = dependencies || null; | ||
|
||
nfpacket.nfpacketDecoded = IPv4 | ||
? new IPv4().decode(nfpacket.payload, 0) | ||
: false; | ||
} | ||
}) | ||
|
||
module.exports = encoding; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
const netfilterVerdict = { | ||
// These are the NFQUEUE result handler options. | ||
NF_REJECT: 0, | ||
NF_ACCEPT: 1, // Accept packet (but no longer seen / disowned by conntrack, | ||
NF_REQUEUE: 4, // Requeue packet (Which we then use a mark to determine the action, | ||
} | ||
|
||
const protocols = { | ||
// Protocol Numbers can be found here, however; libpcap has limited support.. | ||
// https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml | ||
PC_ICMP: 1, | ||
PC_IGMP: 2, | ||
PC_TCP: 6, | ||
PC_UDP: 17, | ||
module.exports = { | ||
netfilterVerdict: { | ||
// These are the NFQUEUE result handler options. | ||
NF_REJECT: 0, | ||
NF_ACCEPT: 1, // Accept packet (but no longer seen / disowned by conntrack, | ||
NF_REQUEUE: 4, // Requeue packet (Which we then use a mark to determine the action, | ||
}, | ||
protocols: { | ||
// Protocol Numbers can be found here, however; libpcap has limited support.. | ||
// https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml | ||
PC_ICMP: 1, | ||
PC_IGMP: 2, | ||
PC_TCP: 6, | ||
PC_UDP: 17, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
const actions = require('./actions'); | ||
const encoding = require('./encoding'); | ||
const enums = require('./enums.js'); | ||
|
||
const nfpacket = (dependencies) => { | ||
if (Object.keys(dependencies).includes(['pcap', 'nfq'])) { | ||
module.exports = (dependencies) => (nfpacket) => { | ||
if (Object.keys(dependencies).includes('nfq') && Object.keys(dependencies).includes('pcapIPv4')) { | ||
return Object.assign( | ||
{}, | ||
nfpacket, | ||
enums, | ||
actions(dependencies) | ||
) | ||
{ actions: actions(dependencies) }, | ||
{ encoding: encoding(dependencies.pcapIPv4)(nfpacket) }, | ||
{ enum: enums }, | ||
{ decoded: undefined } | ||
); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
module.exports = nfpacket; |