Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

executable file 92 lines (76 sloc) 2.584 kb
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
#!/bin/bash
####################################################################
# Prey - by Tomas Pollak (bootlog.org)
# URL: http://preyproject.com
# License: GPLv3
####################################################################

version='0.2.5'
base_path=`dirname $0`
start_time=`date +"%F %T"`

# are we running?
running_prey=`ps aux | grep "prey.sh" | grep -v grep | wc -l`
if [[ "$running_prey" -gt 2 && "$1" != "-f" ]]; then # prey is already running

echo -e "\n !! Prey is already running! Kill the other process or run with -f to force execution.\n"
exit

fi

# get configuration & language file
. $base_path/config

if [ ! -e "lang/$lang" ]; then # fallback to english in case the lang is missing
lang='en'
fi
. $base_path/lang/$lang

# ok lets get going now

. $base_path/platform/base
. $base_path/platform/$os

echo -e "\E[36m$STRING_START\E[0m"

if [ "$1" == "-t" ]; then
echo -e "\033[1m -- TEST MODE ENABLED. WON'T CHECK URL OR SEND STUFF!\033[0m\n"
test_mode=1
check_url=''
fi

####################################################################
# 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
echo "$STRING_TRY_TO_CONNECT"
try_to_connect

# ok, lets check again
check_net_status
if [ $connected == 0 ]; then
echo "$STRING_NO_CONNECT_TO_WIFI"
fi
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
####################################################################

if [ -n "$check_url" ]; then
echo "$STRING_CHECK_URL"
check_status
if [ "$status" == '200' ]; then
echo -e "$STRING_PROBLEM"
parse_headers
process_response
sed -i -e "s/pc_status='.*'/pc_status='Stolen'/" $base_path/config
elif [[ "$status" == '404' && "$pc_status" == 'Stolen' ]]; then
sed -i -e "s/pc_status='.*'/pc_status=''/" $base_path/config
echo -e "$STRING_NO_PROBLEM"
exit
elif [ "$pc_status" == 'Stolen' ]; then
echo -e "$STRING_PROBLEM"
parse_headers
process_response
else
echo -e "$STRING_NO_PROBLEM"
exit
fi
fi

####################################################################
# ok what shall we do then?
# for now lets run every module with an executable run.sh script
####################################################################

echo -e " -- Running active modules..."
run_active_modules
echo -e "$STRING_DONE"
Something went wrong with that request. Please try again.