forked from ussjoin/portalsmash
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexec.rb
executable file
·55 lines (41 loc) · 1 KB
/
exec.rb
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
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/ruby
class Exec
CONFPATH = '/tmp/portalsmash.conf'
DHCP_CONFIG = File.dirname(__FILE__)+'/dhclient.conf'
def exitstatus
$?.exitstatus
end
def iwlist(device)
`iwlist #{device} scan`;
end
def wpa_cli_select(net_counter)
`wpa_cli select #{net_counter}`
end
def wpa_cli_status
`wpa_cli status`
end
def dhcpclient_release(device)
#DHCP Release, and tells any old DHClients to let go of @device
`dhclient #{device} -cf #{DHCP_CONFIG} -r`
end
def dhcpclient(device)
#Try just once, with timeout specified in DHCP_CONFIG
`dhclient #{device} -cf #{DHCP_CONFIG} -1`
end
def pkill_wpa_supplicant
`pkill -KILL wpa_supplicant`
end
def pkill_dhclient
`pkill -KILL dhclient`
end
def ifconfig_up(device)
#because when we've killed this, sometimes it stays down.
`ifconfig #{device} up`
end
def wpa_supplicant(device)
`wpa_supplicant -B -i #{device} -c #{CONFPATH}`
end
def kill(pid)
`kill -s SIGUSR1 #{pid}`
end
end