nfqueue 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README +1 -2
- data/lib/nfqueue.rb +274 -229
- data/samples/packetdump.rb +21 -0
- metadata +53 -60
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3665707fbf433eb685f566b9bffc521b066e6d67
|
4
|
+
data.tar.gz: ddb59d9dd9094b3720dc052ea8a60a5e0368733b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b7d4d82ecf55fc514b779c08e38313bfa69511c80715baba78e1dd372b967c1dbf6b070142c97b6851a3f48a6f4c5eedaa877709c28fa3653530f37dfbe1918
|
7
|
+
data.tar.gz: f83e2aaa2ed7f1d3054fea5a6c39ae17145d51284aab1255122e5eaeaec264eb4f4e9ac9fb4806952b71c1bf3e40a16e5feb445b4f1ecdac560a8e22d1925329
|
data/README
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
* Description of nfqueue
|
4
4
|
|
5
5
|
nfqueue is a tiny wrapper around libnetfilter_queue. It allows you to do some packet filtering very simply in a Ruby environment.
|
6
|
-
Network packets can either be inspected or modified on-the-fly.
|
7
6
|
|
8
7
|
For example, plugging on the #0 queue:
|
9
8
|
|
@@ -12,7 +11,7 @@ require 'nfqueue'
|
|
12
11
|
system('sudo iptables -A OUTPUT -p tcp --dport 80 -j NFQUEUE --queue-num 0')
|
13
12
|
|
14
13
|
Netfilter::Queue.create(0) do |packet|
|
15
|
-
puts "Inspecting packet
|
14
|
+
puts "Inspecting packet ##{packet.id}"
|
16
15
|
|
17
16
|
p packet.data
|
18
17
|
Netfilter::Packet::ACCEPT
|
data/lib/nfqueue.rb
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
=begin
|
4
4
|
|
5
5
|
= File
|
6
|
-
|
6
|
+
nfqueue.rb
|
7
7
|
|
8
8
|
= Author
|
9
|
-
Guillaume
|
9
|
+
Guillaume Delugré <guillaume AT security-labs DOT org>
|
10
10
|
|
11
11
|
= Info
|
12
|
-
|
12
|
+
This program is free software: you can redistribute it and/or modify
|
13
13
|
it under the terms of the GNU General Public License as published by
|
14
14
|
the Free Software Foundation, either version 3 of the License, or
|
15
15
|
(at your option) any later version.
|
@@ -19,7 +19,7 @@
|
|
19
19
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20
20
|
GNU General Public License for more details.
|
21
21
|
|
22
|
-
You should have received a copy of the GNU
|
22
|
+
You should have received a copy of the GNU General Public License
|
23
23
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
24
24
|
|
25
25
|
=end
|
@@ -28,268 +28,313 @@
|
|
28
28
|
require 'rubygems'
|
29
29
|
require 'ffi'
|
30
30
|
require 'socket'
|
31
|
+
require 'nfnetlink'
|
31
32
|
|
32
33
|
module Netfilter
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
#
|
36
|
+
# This class represents a packet filtered by a Netfilter::Queue.
|
37
|
+
#
|
38
|
+
class Packet
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
class Timeval < FFI::Struct #:nodoc:
|
41
|
+
layout :tv_sec, :ulong,
|
42
|
+
:tv_usec, :ulong
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
class Header < FFI::Struct #:nodoc:
|
46
|
+
layout :packet_id, :uint32,
|
47
|
+
:hw_protocol, :uint16,
|
48
|
+
:hook, :uint8
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
class HardwareAddress < FFI::Struct #:nodoc:
|
52
|
+
layout :hw_addrlen, :uint16,
|
53
|
+
:__pad, :uint16,
|
54
|
+
:hw_addr, [:uint8, 8]
|
55
|
+
end
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
DROP = 0
|
58
|
+
ACCEPT = 1
|
59
|
+
STOLEN = 2
|
60
|
+
QUEUE = 3
|
61
|
+
REPEAT = 4
|
62
|
+
STOP = 5
|
62
63
|
|
63
|
-
|
64
|
-
|
64
|
+
attr_reader :id
|
65
|
+
attr_writer :data
|
65
66
|
|
66
|
-
|
67
|
-
|
67
|
+
def initialize(nfad) #:nodoc:
|
68
|
+
@nfad = nfad
|
68
69
|
|
69
|
-
|
70
|
-
|
70
|
+
phdr = Queue.nfq_get_msg_packet_hdr(nfad)
|
71
|
+
hdr = Header.new(phdr)
|
71
72
|
|
72
|
-
|
73
|
-
|
73
|
+
@id = [ hdr[:packet_id] ].pack("N").unpack("V")[0]
|
74
|
+
end
|
74
75
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
76
|
+
#
|
77
|
+
# The packet timestamp.
|
78
|
+
#
|
79
|
+
def timestamp
|
80
|
+
ptv = FFI::MemoryPointer.new :pointer
|
81
|
+
tv = Timeval.new(ptv)
|
82
|
+
if Queue.nfq_get_timestamp(@nfad, ptv) < 0
|
83
|
+
0
|
84
|
+
else
|
85
|
+
Time.at(tv[:tv_sec])
|
86
|
+
end
|
87
|
+
end
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
89
|
+
#
|
90
|
+
# The index of the device the queued packet was received via.
|
91
|
+
# If the return index is 0, the packet was locally generated or the input interface is not known (ie. POSTROUTING?).
|
92
|
+
#
|
93
|
+
def indev
|
94
|
+
Queue.nfq_get_indev(@nfad)
|
95
|
+
end
|
95
96
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
97
|
+
#
|
98
|
+
# The name of the interface this packet was received through.
|
99
|
+
#
|
100
|
+
def indev_name
|
101
|
+
get_interface_name(self.indev)
|
102
|
+
end
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
104
|
+
#
|
105
|
+
# The index of the physical device the queued packet was received via.
|
106
|
+
# If the returned index is 0, the packet was locally generated or the physical input interface is no longer known (ie. POSTROUTING).
|
107
|
+
#
|
108
|
+
def phys_indev
|
109
|
+
Queue.nfq_get_physindev(@nfad)
|
110
|
+
end
|
111
111
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
112
|
+
#
|
113
|
+
# The name of the physical interface this packet was received through.
|
114
|
+
#
|
115
|
+
def phys_indev_name
|
116
|
+
get_interface_name(self.phys_indev)
|
117
|
+
end
|
119
118
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
119
|
+
#
|
120
|
+
# The index of the device the queued packet will be sent out.
|
121
|
+
# It the returned index is 0, the packet is destined for localhost or the output interface is not yet known (ie. PREROUTING?).
|
122
|
+
#
|
123
|
+
def outdev
|
124
|
+
Queue.nfq_get_outdev(@nfad)
|
125
|
+
end
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
|
127
|
+
#
|
128
|
+
# The name of the interface this packet will be routed to.
|
129
|
+
#
|
130
|
+
def outdev_name
|
131
|
+
get_interface_name(self.outdev)
|
132
|
+
end
|
130
133
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
size = Queue.nfq_get_payload(@nfad, pdata)
|
138
|
-
if size < 0
|
139
|
-
raise QueueError, "nfq_get_payload has failed"
|
134
|
+
#
|
135
|
+
# The index of the physical device the queued packet will be sent out.
|
136
|
+
# If the returned index is 0, the packet is destined for localhost or the physical output interface is not yet known (ie. PREROUTING).
|
137
|
+
#
|
138
|
+
def phys_outdev
|
139
|
+
Queue.nfq_get_physoutdev(@nfad)
|
140
140
|
end
|
141
|
+
|
142
|
+
#
|
143
|
+
# The name of the physical interface this packet will be routed to.
|
144
|
+
#
|
145
|
+
def phys_outdev_name
|
146
|
+
get_interface_name(self.phys_outdev)
|
147
|
+
end
|
148
|
+
|
149
|
+
#
|
150
|
+
# The source hardware address.
|
151
|
+
#
|
152
|
+
def hw_addr
|
153
|
+
phw = Queue.nfq_get_packet_hw(@nfad)
|
154
|
+
return nil if phw.null?
|
155
|
+
|
156
|
+
hw = HardwareAddress.new(phw)
|
157
|
+
hw_addrlen = [ hw[:hw_addrlen] ].pack('v').unpack('n')[0]
|
158
|
+
hw[:hw_addr].to_ptr.read_bytes(hw_addrlen)
|
159
|
+
end
|
160
|
+
|
161
|
+
#
|
162
|
+
# The packet contents.
|
163
|
+
#
|
164
|
+
def data
|
165
|
+
if @data.nil?
|
166
|
+
pdata = FFI::MemoryPointer.new(:pointer, 1)
|
167
|
+
size = Queue.nfq_get_payload(@nfad, pdata)
|
168
|
+
if size < 0
|
169
|
+
raise QueueError, "nfq_get_payload has failed"
|
170
|
+
end
|
141
171
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
ffi_lib 'libnetfilter_queue'
|
157
|
-
|
158
|
-
attach_function 'nfq_open', [], :pointer
|
159
|
-
attach_function 'nfq_open_nfnl', [:pointer], :pointer
|
160
|
-
attach_function 'nfq_close', [:pointer], :int
|
161
|
-
attach_function 'nfq_bind_pf', [:pointer, :uint16], :int
|
162
|
-
attach_function 'nfq_unbind_pf', [:pointer, :uint16], :int
|
163
|
-
attach_function 'nfq_nfnlh', [:pointer], :pointer
|
164
|
-
attach_function 'nfq_fd', [:pointer], :int
|
165
|
-
callback :nfq_callback, [:pointer, :pointer, :pointer, :buffer_in], :int
|
166
|
-
attach_function 'nfq_create_queue', [:pointer, :uint16, :nfq_callback, :buffer_in], :pointer
|
167
|
-
attach_function 'nfq_destroy_queue', [:pointer], :int
|
168
|
-
attach_function 'nfq_handle_packet', [:pointer, :buffer_in, :int], :int
|
169
|
-
attach_function 'nfq_set_mode', [:pointer, :uint8, :uint32], :int
|
170
|
-
attach_function 'nfq_set_queue_maxlen', [:pointer, :uint32], :int
|
171
|
-
attach_function 'nfq_set_verdict', [:pointer, :uint32, :uint32, :uint32, :buffer_in], :int
|
172
|
-
attach_function 'nfq_set_verdict_mark', [:pointer, :uint32, :uint32, :uint32, :uint32, :buffer_in], :int
|
173
|
-
|
174
|
-
attach_function 'nfq_get_msg_packet_hdr', [:pointer], :pointer
|
175
|
-
attach_function 'nfq_get_nfmark', [:pointer], :uint32
|
176
|
-
attach_function 'nfq_get_timestamp', [:pointer, :pointer], :int
|
177
|
-
attach_function 'nfq_get_indev', [:pointer], :int
|
178
|
-
attach_function 'nfq_get_physindev', [:pointer], :int
|
179
|
-
attach_function 'nfq_get_outdev', [:pointer], :int
|
180
|
-
attach_function 'nfq_get_physoutdev', [:pointer], :int
|
181
|
-
attach_function 'nfq_get_packet_hw', [:pointer], :pointer
|
182
|
-
attach_function 'nfq_get_payload', [:pointer, :pointer], :int
|
183
|
-
|
184
|
-
module CopyMode
|
185
|
-
NONE = 0
|
186
|
-
META = 1
|
187
|
-
PACKET = 2
|
172
|
+
@data = pdata.read_pointer.read_bytes(size)
|
173
|
+
else
|
174
|
+
@data
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
private
|
179
|
+
|
180
|
+
def get_interface_name(index)
|
181
|
+
iface = Netfilter::Netlink.interfaces[index]
|
182
|
+
if iface
|
183
|
+
iface[:name]
|
184
|
+
end
|
185
|
+
end
|
188
186
|
end
|
189
187
|
|
190
188
|
#
|
191
|
-
#
|
189
|
+
# Class representing a Netfilter Queue.
|
192
190
|
#
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
191
|
+
class QueueError < Exception; end
|
192
|
+
class Queue
|
193
|
+
extend FFI::Library
|
194
|
+
|
195
|
+
begin
|
196
|
+
ffi_lib 'libnetfilter_queue'
|
197
|
+
rescue LoadError => exc
|
198
|
+
STDERR.puts(exc.message)
|
199
|
+
STDERR.puts "Please check that libnetfilter_queue is installed on your system."
|
200
|
+
abort
|
201
|
+
end
|
202
|
+
|
203
|
+
attach_function 'nfq_open', [], :pointer
|
204
|
+
attach_function 'nfq_open_nfnl', [:pointer], :pointer
|
205
|
+
attach_function 'nfq_close', [:pointer], :int
|
206
|
+
attach_function 'nfq_bind_pf', [:pointer, :uint16], :int
|
207
|
+
attach_function 'nfq_unbind_pf', [:pointer, :uint16], :int
|
208
|
+
attach_function 'nfq_nfnlh', [:pointer], :pointer
|
209
|
+
attach_function 'nfq_fd', [:pointer], :int
|
210
|
+
callback :nfq_callback, [:pointer, :pointer, :pointer, :buffer_in], :int
|
211
|
+
attach_function 'nfq_create_queue', [:pointer, :uint16, :nfq_callback, :buffer_in], :pointer
|
212
|
+
attach_function 'nfq_destroy_queue', [:pointer], :int
|
213
|
+
attach_function 'nfq_handle_packet', [:pointer, :buffer_in, :int], :int
|
214
|
+
attach_function 'nfq_set_mode', [:pointer, :uint8, :uint32], :int
|
215
|
+
attach_function 'nfq_set_queue_maxlen', [:pointer, :uint32], :int
|
216
|
+
attach_function 'nfq_set_verdict', [:pointer, :uint32, :uint32, :uint32, :buffer_in], :int
|
217
|
+
attach_function 'nfq_set_verdict_mark', [:pointer, :uint32, :uint32, :uint32, :uint32, :buffer_in], :int
|
218
|
+
|
219
|
+
attach_function 'nfq_get_msg_packet_hdr', [:pointer], :pointer
|
220
|
+
attach_function 'nfq_get_nfmark', [:pointer], :uint32
|
221
|
+
attach_function 'nfq_get_timestamp', [:pointer, :pointer], :int
|
222
|
+
attach_function 'nfq_get_indev', [:pointer], :int
|
223
|
+
attach_function 'nfq_get_physindev', [:pointer], :int
|
224
|
+
attach_function 'nfq_get_outdev', [:pointer], :int
|
225
|
+
attach_function 'nfq_get_physoutdev', [:pointer], :int
|
226
|
+
attach_function 'nfq_get_packet_hw', [:pointer], :pointer
|
227
|
+
attach_function 'nfq_get_payload', [:pointer, :pointer], :int
|
228
|
+
|
229
|
+
module CopyMode
|
230
|
+
NONE = 0
|
231
|
+
META = 1
|
232
|
+
PACKET = 2
|
233
|
+
end
|
234
|
+
|
235
|
+
#
|
236
|
+
# Creates a new Queue at slot _qnumber_.
|
237
|
+
#
|
238
|
+
def initialize(qnumber, mode = CopyMode::PACKET)
|
239
|
+
@conn_handle = Queue.nfq_open
|
240
|
+
raise QueueError, "nfq_open has failed" if @conn_handle.null?
|
241
|
+
|
242
|
+
if Queue.nfq_unbind_pf(@conn_handle, Socket::AF_INET) < 0
|
243
|
+
close
|
244
|
+
raise QueueError, "nfq_unbind_pf has failed"
|
245
|
+
end
|
201
246
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
247
|
+
if Queue.nfq_bind_pf(@conn_handle, Socket::AF_INET) < 0
|
248
|
+
close
|
249
|
+
raise QueueError, "nfq_unbind_pf has failed"
|
250
|
+
end
|
251
|
+
|
252
|
+
@qhandle = Queue.nfq_create_queue(@conn_handle, qnumber, method(:callback_handler), nil)
|
253
|
+
if @qhandle.null?
|
254
|
+
close
|
255
|
+
raise QueueError, "nfq_create_queue has failed" if @qhandle.null?
|
256
|
+
end
|
257
|
+
|
258
|
+
set_mode(mode)
|
259
|
+
end
|
215
260
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
261
|
+
#
|
262
|
+
# Changes the copy mode for the queue.
|
263
|
+
#
|
264
|
+
def set_mode(mode, range = 0xffff_ffff)
|
265
|
+
if Queue.nfq_set_mode(@qhandle, mode, range) < 0
|
266
|
+
raise QueueError, "nfq_set_mode has failed"
|
267
|
+
end
|
223
268
|
|
224
|
-
|
225
|
-
|
269
|
+
self
|
270
|
+
end
|
226
271
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
272
|
+
#
|
273
|
+
# Sets the maximum number of elements in the queue.
|
274
|
+
#
|
275
|
+
def set_max_length(len)
|
276
|
+
if Queue.nfq_set_queue_maxlen(@qhandle, len) < 0
|
277
|
+
raise QueueError, "nfq_queue_maxlen has failed"
|
278
|
+
end
|
234
279
|
|
235
|
-
|
236
|
-
|
280
|
+
self
|
281
|
+
end
|
237
282
|
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
283
|
+
#
|
284
|
+
# Processes packets in the queue, passing them through the provided callback.
|
285
|
+
#
|
286
|
+
def process(&callback)
|
287
|
+
@callback = callback
|
243
288
|
|
244
|
-
|
245
|
-
|
289
|
+
fd = Queue.nfq_fd(@conn_handle)
|
290
|
+
raise QueueError, "nfq_fd has failed" if fd < 0
|
246
291
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
292
|
+
io = IO.new(fd)
|
293
|
+
while data = io.sysread(4096)
|
294
|
+
Queue.nfq_handle_packet(@conn_handle, data, data.size)
|
295
|
+
end
|
296
|
+
end
|
252
297
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
298
|
+
#
|
299
|
+
# Close the queue.
|
300
|
+
#
|
301
|
+
def destroy
|
302
|
+
Queue.nfq_destroy_queue(@qhandle)
|
303
|
+
close
|
304
|
+
end
|
260
305
|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
306
|
+
#
|
307
|
+
# Creates a new Queue with the provided callback.
|
308
|
+
# The queue will be automatically destroyed at return.
|
309
|
+
#
|
310
|
+
def self.create(qnumber, mode = CopyMode::PACKET, &callback)
|
311
|
+
queue = self.new(qnumber, mode)
|
312
|
+
queue.process(&callback)
|
313
|
+
queue.destroy
|
314
|
+
end
|
270
315
|
|
271
|
-
|
316
|
+
private
|
272
317
|
|
273
|
-
|
274
|
-
|
275
|
-
|
318
|
+
def callback_handler(qhandler, nfmsg, nfad, data) #:nodoc:
|
319
|
+
packet = Packet.new(nfad)
|
320
|
+
verdict = @callback[packet]
|
276
321
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
322
|
+
data = packet.data
|
323
|
+
|
324
|
+
Queue.nfq_set_verdict(
|
325
|
+
qhandler,
|
326
|
+
packet.id,
|
327
|
+
verdict,
|
328
|
+
data.size,
|
329
|
+
data
|
330
|
+
)
|
331
|
+
end
|
287
332
|
|
288
|
-
|
289
|
-
|
290
|
-
|
333
|
+
def close #:nodoc:
|
334
|
+
Queue.nfq_close(@conn_handle)
|
335
|
+
end
|
291
336
|
|
292
|
-
|
337
|
+
end
|
293
338
|
end
|
294
339
|
|
295
340
|
__END__
|
@@ -299,9 +344,9 @@ __END__
|
|
299
344
|
system('sudo iptables -A OUTPUT -p tcp --dport 80 -j NFQUEUE --queue-num 0')
|
300
345
|
|
301
346
|
Netfilter::Queue.create(0) do |packet|
|
302
|
-
|
347
|
+
puts packet.id
|
303
348
|
|
304
|
-
|
305
|
-
|
349
|
+
p packet.data
|
350
|
+
Netfilter::Packet::ACCEPT
|
306
351
|
end
|
307
352
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'nfqueue'
|
4
|
+
|
5
|
+
def mac_address(packet)
|
6
|
+
hw_addr = packet.hw_addr
|
7
|
+
return '??:??:??:??:??:??' if hw_addr.nil?
|
8
|
+
|
9
|
+
hw_addr.unpack('C*').map{|c| "%02x" % c}.join(':')
|
10
|
+
end
|
11
|
+
|
12
|
+
Netfilter::Queue.create(0) do |packet|
|
13
|
+
puts "New packet ##{packet.id} from interface #{packet.indev_name}"
|
14
|
+
puts "Ethernet address: #{mac_address(packet)}"
|
15
|
+
|
16
|
+
puts
|
17
|
+
puts packet.data.unpack('H*')[0]
|
18
|
+
puts '--'
|
19
|
+
|
20
|
+
Netfilter::Packet::ACCEPT
|
21
|
+
end
|
metadata
CHANGED
@@ -1,85 +1,78 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: nfqueue
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 1.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
6
|
+
authors:
|
7
|
+
- Guillaume Delugré
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-12-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nfnetlink
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
27
31
|
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
33
34
|
type: :runtime
|
34
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
35
41
|
description: |
|
36
42
|
nfqueue is a tiny wrapper around libnetfilter_queue. It allows you to very simply intercept and modify network traffic in a Ruby environment.
|
37
|
-
|
38
|
-
|
39
|
-
email: guillaume at security-labs dot org
|
43
|
+
email: guillaume AT security-labs DOT org
|
40
44
|
executables: []
|
41
|
-
|
42
45
|
extensions: []
|
43
|
-
|
44
46
|
extra_rdoc_files: []
|
45
|
-
|
46
|
-
files:
|
47
|
-
- README
|
47
|
+
files:
|
48
48
|
- COPYING
|
49
|
+
- README
|
49
50
|
- lib/nfqueue.rb
|
50
|
-
|
51
|
-
homepage:
|
52
|
-
licenses:
|
53
|
-
- GPL
|
51
|
+
- samples/packetdump.rb
|
52
|
+
homepage: http://code.google.com/p/ruby-nfqueue
|
53
|
+
licenses:
|
54
|
+
- GPL
|
55
|
+
metadata: {}
|
54
56
|
post_install_message:
|
55
57
|
rdoc_options: []
|
56
|
-
|
57
|
-
require_paths:
|
58
|
+
require_paths:
|
58
59
|
- lib
|
59
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
-
|
61
|
-
requirements:
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
62
|
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
version: "0"
|
68
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
|
-
requirements:
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
71
67
|
- - ">="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
requirements:
|
78
|
-
- Support for NFQUEUE in your kernel, libnetfilter_queue installed and Ruby FFI
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements:
|
71
|
+
- Support for NFQUEUE in your Linux kernel, libnetfilter_queue installed and Ruby
|
72
|
+
FFI
|
79
73
|
rubyforge_project:
|
80
|
-
rubygems_version:
|
74
|
+
rubygems_version: 2.2.2
|
81
75
|
signing_key:
|
82
|
-
specification_version:
|
76
|
+
specification_version: 4
|
83
77
|
summary: nfqueue is a simple wrapper around libnetfilter_queue using FFI.
|
84
78
|
test_files: []
|
85
|
-
|