-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsniff_mac_addresses
More file actions
executable file
·42 lines (32 loc) · 894 Bytes
/
Copy pathsniff_mac_addresses
File metadata and controls
executable file
·42 lines (32 loc) · 894 Bytes
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 ruby
require 'json'
require 'net/http'
require_relative './mac'
if !system("which tshark")
`sudo apt-get update`
`sudo apt-get install -y tshark`
end
def send_macs(payload)
uri = URI('https://rcdash.herokuapp.com/macs_seen')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = (uri.scheme == "https")
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
req.body = payload.to_json
response = http.request(req)
end
def hash_macs(macs)
macs.map do |i|
Mac.hash(i)
end
end
loop do
`sudo tshark -Tfields -e eth.addr -a duration:10 > capture.tmp`
`uniq capture.tmp > uniqcapture.tmp`
uniq_capture = File.read("uniqcapture.tmp").split("\n")
`rm capture.tmp uniqcapture.tmp`
uniq_macs = uniq_capture.map { |line| line.split(",").last }
hashed_macs = hash_macs(uniq_macs)
send_macs({
"seen" => hashed_macs
})
end