FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node_pcap/examples/simple_capture at master · unbug/node_pcap · GitHub
unbug
/
node_pcap
Public
forked from
node-pcap/node_pcap
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
node_pcap
/
examples
/
simple_capture
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
42 lines (35 loc) · 1.26 KB
Breadcrumbs
node_pcap
/
examples
/
simple_capture
Copy path
File metadata and controls
executable file
·
42 lines (35 loc) · 1.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/usr/bin/env node
/*global process require exports */
var
util
=
require
(
'util'
)
,
pcap
=
require
(
"pcap"
)
,
pcap_session
;
if
(
process
.
argv
.
length
>
4
)
{
util
.
error
(
"usage: simple_capture interface filter"
)
;
util
.
error
(
"Examples: "
)
;
util
.
error
(
' simple_capture "" "tcp port 80"'
)
;
util
.
error
(
' simple_capture eth1 ""'
)
;
util
.
error
(
' simple_capture lo0 "ip proto \\tcp and tcp port 80"'
)
;
process
.
exit
(
1
)
;
}
pcap_session
=
pcap
.
createSession
(
process
.
argv
[
2
]
,
process
.
argv
[
3
]
)
;
// libpcap's internal version numnber
util
.
puts
(
pcap
.
lib_version
)
;
// Print all devices, currently listening device prefixed with an asterisk
pcap_session
.
findalldevs
(
)
.
forEach
(
function
(
dev
)
{
if
(
pcap_session
.
device_name
===
dev
.
name
)
{
util
.
print
(
"* "
)
;
}
util
.
print
(
dev
.
name
+
" "
)
;
if
(
dev
.
addresses
.
length
>
0
)
{
dev
.
addresses
.
forEach
(
function
(
address
)
{
util
.
print
(
address
.
addr
+
"/"
+
address
.
netmask
)
;
}
)
;
util
.
print
(
"\n"
)
;
}
else
{
util
.
print
(
"no address\n"
)
;
}
}
)
;
// Listen for packets, decode them, and feed the simple printer. No tricks.
pcap_session
.
on
(
'packet'
,
function
(
raw_packet
)
{
var
packet
=
pcap
.
decode
.
packet
(
raw_packet
)
;
util
.
puts
(
pcap
.
print
.
packet
(
packet
)
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL