This repository has been archived by the owner on May 27, 2021. It is now read-only.
/
darwin
executable file
·45 lines (34 loc) · 1.57 KB
/
darwin
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
#!/bin/bash
####################################################################
# PREY Darwin (Mac) Base Functions - by Tomas Pollak (bootlog.org) and Diego Torres (warorface.com)
# URL : http://preyproject.com
# License: GPLv3
####################################################################
airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport'
function get_current_delay {
grep "<integer>.*<.integer>" /Library/LaunchDaemons/com.preyproject.PreyMac.plist | sed -e "s/^.*<integer/<integer/" | cut -f2 -d">"| cut -f1 -d"<"
}
function update_execution_delay {
sudo launchctl unload /Library/LaunchDaemons/com.preyproject.PreyMac.plist
sed -i -e "s/<integer>.*<\/integer>/<integer>$delay<\/integer>/" /Library/LaunchDaemons/com.preyproject.PreyMac.plist
sudo launchctl load /Library/LaunchDaemons/com.preyproject.PreyMac.plist
}
function get_gateway_ip {
gateway_ip=`netstat -rn | grep default | cut -c20-35`
}
function get_wifi_info {
wifi_info=`$airport -I | grep -v "Off"`
}
function try_to_connect {
# restart airport service
networksetup -setnetworkserviceenabled AirPort off 2>/dev/null
networksetup -setnetworkserviceenabled AirPort on 2>/dev/null
# power on the airport
networksetup -setairportpower off 2>/dev/null
networksetup -setairportpower on 2>/dev/null
# list available access points and parse to get first SSID with security "NONE"
essid=`$airport -s | grep NONE | head -1 | cut -c1-33 | sed 's/^[ \t]*//'`
if [ -n "$essid" ]; then
networksetup -setairportnetwork $essid 2>/dev/null
fi
}