forked from prey/prey-bash-client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
prey.sh
executable file
·114 lines (86 loc) · 3.02 KB
/
prey.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
####################################################################
# Prey Client - by Tomas Pollak (bootlog.org)
# URL: http://preyproject.com
# License: GPLv3
####################################################################
# set -u
# set -e
PATH=/bin:$PATH # for windows
readonly base_path=`dirname "$0"`
####################################################################
# base files inclusion
####################################################################
. "$base_path/version"
. "$base_path/config"
if [ ! -f "$base_path/lang/$lang" ]; then # fallback to english in case the lang is missing
lang='en'
fi
. "$base_path/lang/$lang"
. "$base_path/core/base"
. "$base_path/platform/$os/functions"
echo -e "${cyan}$STRING_START ### `uname -a`${color_end}\n"
####################################################################
# lets check if we're actually connected
# if we're not, lets try to connect to a wifi access point
####################################################################
check_net_status
if [ $connected == 0 ]; then
if [ "$auto_connect" == "y" ]; then
echo "$STRING_TRY_TO_CONNECT"
try_to_connect
fi
# ok, lets check again, after waiting five seconds
sleep 5
check_net_status
if [ $connected == 0 ]; then
echo "$STRING_NO_CONNECT_TO_WIFI"
exit
fi
else
echo ' -- Got network connection!'
fi
####################################################################
# verify if installation and keys are correct, if requested
####################################################################
if [ -n "$check_mode" ]; then
echo -e "\n${bold} >> Verifying Prey installation...${bold_end}\n"
verify_installation
echo -e "\n${bold} >> Verifying API and Device keys...${bold_end}\n"
verify_keys
exit $?
fi
####################################################################
# if there's a URL in the config, lets see if it actually exists
# if it doesn't, the program will shut down gracefully
####################################################################
# create tmpdir for downloading stuff, storing files, etc
create_tmpdir
if [ -n "$check_url" ]; then
echo "$STRING_CHECK_URL"
check_device_status
parse_headers
process_response
echo -e "\n${bold} >> Verifying status...${bold_end}\n"
echo -e " -- Got status code $status!"
if [ "$status" == "$missing_status_code" ]; then
echo -e "$STRING_PROBLEM"
####################################################################
# fire off active modules
####################################################################
set +e # error mode off, just continue if a module fails
echo -e " -- Running active modules..."
run_active_modules
####################################################################
# lets send whatever we've gathered and run any pending jobs
####################################################################
echo -e "\n${bold} >> Sending report!${bold_end}\n"
send_report
run_delayed_jobs &
echo -e "\n$STRING_DONE"
else
echo -e "$STRING_NO_PROBLEM"
fi
fi
delete_tmpdir
exit 0