├── alarm ├── version ├── lib │ ├── alarm.mp3 │ └── siren.mp3 ├── platform │ ├── windows │ │ ├── mpg123.exe │ │ └── functions │ ├── mac │ │ └── functions │ └── linux │ │ └── functions ├── config └── core │ └── run ├── alert ├── version ├── lib │ ├── prey-wallpaper-en.png │ └── prey-wallpaper-es.png ├── platform │ ├── windows │ │ ├── msgbox.exe │ │ └── functions │ ├── mac │ │ └── functions │ └── linux │ │ └── functions ├── lang │ ├── en │ ├── fr │ ├── sv │ └── es ├── config └── core │ └── run ├── geo ├── version ├── platform │ ├── windows │ │ └── functions │ ├── mac │ │ └── functions │ └── linux │ │ └── functions └── core │ ├── run │ └── functions ├── lock ├── version ├── platform │ ├── mac │ │ ├── prey-lock.app │ │ │ └── Contents │ │ │ │ ├── PkgInfo │ │ │ │ ├── MacOS │ │ │ │ └── prey-lock │ │ │ │ ├── Resources │ │ │ │ ├── bg-lock.png │ │ │ │ └── English.lproj │ │ │ │ │ ├── MainMenu.nib │ │ │ │ │ └── InfoPlist.strings │ │ │ │ └── Info.plist │ │ └── functions │ ├── windows │ │ ├── lockpolicy.exe │ │ ├── prey-lock.exe │ │ └── functions │ └── linux │ │ └── prey-lock ├── lib │ ├── bg-lock.png │ └── bg-lock-with-input.png ├── config └── core │ ├── run │ └── functions ├── network ├── version ├── platform │ ├── mac │ │ └── functions │ ├── linux │ │ └── functions │ └── windows │ │ └── functions ├── lang │ ├── en │ ├── sv │ ├── es │ └── fr ├── config └── core │ ├── functions │ └── run ├── session ├── version ├── platform │ ├── windows │ │ ├── preyshot.exe │ │ └── functions │ ├── mac │ │ └── functions │ └── linux │ │ └── functions ├── config ├── lang │ ├── sv │ ├── en │ ├── fr │ └── es └── core │ ├── functions │ └── run ├── system ├── version ├── config ├── lang │ ├── en │ ├── es │ ├── sv │ └── fr ├── core │ ├── run │ └── functions └── platform │ ├── windows │ ├── ramcheck.vbs │ └── functions │ ├── linux │ └── functions │ └── mac │ └── functions ├── webcam ├── version ├── platform │ ├── mac │ │ ├── imagesnap │ │ ├── isightcapture │ │ └── functions │ ├── windows │ │ ├── snapshot.exe │ │ ├── prey-webcam.exe │ │ ├── DirectShowLib-2005.dll │ │ ├── functions │ │ └── README.md │ └── linux │ │ └── functions ├── lang │ ├── sv │ ├── en │ ├── es │ └── fr ├── config └── core │ └── run ├── wipe ├── version ├── platform │ ├── linux │ │ └── functions │ ├── mac │ │ └── functions │ └── windows │ │ └── functions ├── config └── core │ ├── run │ └── functions ├── filesystem ├── version ├── config └── core │ ├── run │ └── functions ├── retrieve ├── version ├── lib │ ├── u1rest │ │ ├── files │ │ │ ├── __init__.py │ │ │ ├── __init__.pyc │ │ │ ├── content.pyc │ │ │ ├── resources.pyc │ │ │ ├── content.py │ │ │ └── resources.py │ │ ├── lib │ │ │ ├── __init__.py │ │ │ ├── auth │ │ │ │ ├── __init__.py │ │ │ │ ├── __init__.pyc │ │ │ │ ├── baseauth.pyc │ │ │ │ ├── simpleauth.pyc │ │ │ │ ├── gnomeauth.py │ │ │ │ ├── simpleauth.py │ │ │ │ └── baseauth.py │ │ │ ├── client.pyc │ │ │ ├── __init__.pyc │ │ │ └── client.py │ │ ├── __init__.pyc │ │ ├── createfilekeystore.py │ │ └── __init__.py │ ├── u1_upload.py │ ├── hmac │ ├── s3 │ └── dropbox_uploader.sh ├── core │ ├── run │ └── functions └── config └── README.md /alarm/version: -------------------------------------------------------------------------------- 1 | 1.8 2 | -------------------------------------------------------------------------------- /alert/version: -------------------------------------------------------------------------------- 1 | 1.6 2 | -------------------------------------------------------------------------------- /geo/version: -------------------------------------------------------------------------------- 1 | 1.9 2 | -------------------------------------------------------------------------------- /lock/version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /network/version: -------------------------------------------------------------------------------- 1 | 1.9 2 | -------------------------------------------------------------------------------- /session/version: -------------------------------------------------------------------------------- 1 | 1.7 2 | -------------------------------------------------------------------------------- /system/version: -------------------------------------------------------------------------------- 1 | 3.3 2 | -------------------------------------------------------------------------------- /webcam/version: -------------------------------------------------------------------------------- 1 | 1.7 2 | -------------------------------------------------------------------------------- /wipe/version: -------------------------------------------------------------------------------- 1 | 1.9 2 | -------------------------------------------------------------------------------- /filesystem/version: -------------------------------------------------------------------------------- 1 | 1.7 2 | -------------------------------------------------------------------------------- /retrieve/version: -------------------------------------------------------------------------------- 1 | 0.8 2 | -------------------------------------------------------------------------------- /lock/platform/mac/prey-lock.app/Contents/PkgInfo: -------------------------------------------------------------------------------- 1 | APPL???? -------------------------------------------------------------------------------- /retrieve/lib/u1rest/files/__init__.py: -------------------------------------------------------------------------------- 1 | """Rest Resource for File Storage.""" 2 | -------------------------------------------------------------------------------- /retrieve/lib/u1rest/lib/__init__.py: -------------------------------------------------------------------------------- 1 | """Library for common REST API functions.""" 2 | -------------------------------------------------------------------------------- /retrieve/lib/u1rest/lib/auth/__init__.py: -------------------------------------------------------------------------------- 1 | """Authentication Library for authorizing clients.""" 2 | -------------------------------------------------------------------------------- /alarm/lib/alarm.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/alarm/lib/alarm.mp3 -------------------------------------------------------------------------------- /alarm/lib/siren.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/alarm/lib/siren.mp3 -------------------------------------------------------------------------------- /lock/lib/bg-lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/lock/lib/bg-lock.png -------------------------------------------------------------------------------- /webcam/platform/mac/imagesnap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/webcam/platform/mac/imagesnap -------------------------------------------------------------------------------- /alert/lib/prey-wallpaper-en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/alert/lib/prey-wallpaper-en.png -------------------------------------------------------------------------------- /alert/lib/prey-wallpaper-es.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/alert/lib/prey-wallpaper-es.png -------------------------------------------------------------------------------- /lock/lib/bg-lock-with-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/lock/lib/bg-lock-with-input.png -------------------------------------------------------------------------------- /alarm/platform/windows/mpg123.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/alarm/platform/windows/mpg123.exe -------------------------------------------------------------------------------- /alert/platform/windows/msgbox.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/alert/platform/windows/msgbox.exe -------------------------------------------------------------------------------- /retrieve/lib/u1rest/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/retrieve/lib/u1rest/__init__.pyc -------------------------------------------------------------------------------- /retrieve/lib/u1rest/lib/client.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/retrieve/lib/u1rest/lib/client.pyc -------------------------------------------------------------------------------- /webcam/platform/mac/isightcapture: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/webcam/platform/mac/isightcapture -------------------------------------------------------------------------------- /lock/platform/windows/lockpolicy.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/lock/platform/windows/lockpolicy.exe -------------------------------------------------------------------------------- /lock/platform/windows/prey-lock.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/lock/platform/windows/prey-lock.exe -------------------------------------------------------------------------------- /retrieve/lib/u1rest/lib/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/retrieve/lib/u1rest/lib/__init__.pyc -------------------------------------------------------------------------------- /webcam/platform/windows/snapshot.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/webcam/platform/windows/snapshot.exe -------------------------------------------------------------------------------- /retrieve/lib/u1rest/files/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/retrieve/lib/u1rest/files/__init__.pyc -------------------------------------------------------------------------------- /retrieve/lib/u1rest/files/content.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/retrieve/lib/u1rest/files/content.pyc -------------------------------------------------------------------------------- /retrieve/lib/u1rest/files/resources.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/retrieve/lib/u1rest/files/resources.pyc -------------------------------------------------------------------------------- /session/platform/windows/preyshot.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/session/platform/windows/preyshot.exe -------------------------------------------------------------------------------- /webcam/platform/windows/prey-webcam.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/webcam/platform/windows/prey-webcam.exe -------------------------------------------------------------------------------- /retrieve/lib/u1rest/lib/auth/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/retrieve/lib/u1rest/lib/auth/__init__.pyc -------------------------------------------------------------------------------- /retrieve/lib/u1rest/lib/auth/baseauth.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/retrieve/lib/u1rest/lib/auth/baseauth.pyc -------------------------------------------------------------------------------- /retrieve/lib/u1rest/lib/auth/simpleauth.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/retrieve/lib/u1rest/lib/auth/simpleauth.pyc -------------------------------------------------------------------------------- /webcam/platform/windows/DirectShowLib-2005.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/webcam/platform/windows/DirectShowLib-2005.dll -------------------------------------------------------------------------------- /lock/platform/mac/prey-lock.app/Contents/MacOS/prey-lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/lock/platform/mac/prey-lock.app/Contents/MacOS/prey-lock -------------------------------------------------------------------------------- /lock/platform/mac/prey-lock.app/Contents/Resources/bg-lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/lock/platform/mac/prey-lock.app/Contents/Resources/bg-lock.png -------------------------------------------------------------------------------- /lock/platform/mac/prey-lock.app/Contents/Resources/English.lproj/MainMenu.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/lock/platform/mac/prey-lock.app/Contents/Resources/English.lproj/MainMenu.nib -------------------------------------------------------------------------------- /lock/platform/mac/prey-lock.app/Contents/Resources/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prey/prey-bash-client-modules/HEAD/lock/platform/mac/prey-lock.app/Contents/Resources/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /retrieve/core/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Retrieve Module - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | perform_backup 9 | -------------------------------------------------------------------------------- /filesystem/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Filesystem Module Config File - (c) 2010 Fork Ltd. 4 | # License: GPLv3 5 | #################################################################### 6 | 7 | filesystem__root_path="~" 8 | filesystem__temp_file="$tmpbase/filesystem.html" 9 | filesystem__skip_files='n' 10 | -------------------------------------------------------------------------------- /lock/platform/mac/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Lock Mac Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | lock__executable="$module_platform_path/prey-lock.app/Contents/MacOS/prey-lock" 9 | -------------------------------------------------------------------------------- /alarm/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Alarm Module Configuration File - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | # file to play 9 | alarm__sound="siren" 10 | 11 | # in seconds 12 | alarm__loops="3" 13 | -------------------------------------------------------------------------------- /lock/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Lock Module Configuration File - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | lock__executable="$module_platform_path/prey-lock" 9 | 10 | lock__unlock_pass='preyrocks' 11 | -------------------------------------------------------------------------------- /alarm/core/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Alarm Module - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | log " -- Sounding $alarm__sound!" 9 | alarm__sound_file="${module_path}/lib/${alarm__sound}.mp3" 10 | sound_alarm 11 | -------------------------------------------------------------------------------- /network/platform/mac/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Network Module Mac Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | get_active_connections() { 9 | active_connections=$(/usr/sbin/netstat -p tcp -a) 10 | } 11 | -------------------------------------------------------------------------------- /alarm/platform/mac/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Alarm Module Mac Functions 4 | # URL : http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | sound_alarm() { 9 | local player="afplay" 10 | osascript -e "set Volume 10" 11 | $player $alarm__sound_file &> /dev/null & 12 | } 13 | -------------------------------------------------------------------------------- /network/platform/linux/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Network Module Linux Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | get_active_connections() { 9 | active_connections=$(netstat -tupn | grep -v "127.0.0.1") 10 | } 11 | -------------------------------------------------------------------------------- /system/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey System Module Config File - by Carlos Yaconi H. 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | system__vars='serial_number uuid bios_vendor bios_version mb_vendor mb_serial mb_model mb_version cpu_model cpu_speed cpu_cores ram_size ram_modules' 9 | -------------------------------------------------------------------------------- /alert/lang/en: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey - by Tomas Pollak (http://bootlog.org) 4 | # URL : http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_CHANGE_WALLPAPER=" -- Changing the wallpaper to alert him and nearby users..." 9 | STRING_SHOW_ALERT=" -- Showing the guy our alert message..." 10 | 11 | -------------------------------------------------------------------------------- /system/lang/en: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey System Module Lang File - by Carlos Yaconi 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_GET_CPU_INFO=" -- Getting CPU info..." 9 | STRING_GET_MEMORY_INFO=" -- Getting memory info..." 10 | STRING_GET_HDD_INFO=" -- Getting HDDs info..." 11 | -------------------------------------------------------------------------------- /system/lang/es: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey System Module Lang File - by Carlos Yaconi 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_GET_CPU_INFO=" -- Getting CPU info..." 9 | STRING_GET_MEMORY_INFO=" -- Getting memory info..." 10 | STRING_GET_HDD_INFO=" -- Getting HDDs info..." 11 | -------------------------------------------------------------------------------- /webcam/lang/sv: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Webcam Module Lang File - by Tomas Pollak (http://bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_TAKE_PICTURE=" -- Tar ett fotografi av tjuven ..." 9 | STRING_CAPTURE_VIDEO=" -- Fångar in $video_capture_time sekunder video ..." 10 | -------------------------------------------------------------------------------- /alarm/platform/windows/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Alarm Module Windows Functions 4 | # URL : http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | sound_alarm() { 9 | local player="$module_platform_path/mpg123.exe" 10 | run_as_current_user "\"$player\" \"$alarm__sound_file\"" &> /dev/null & 11 | } 12 | -------------------------------------------------------------------------------- /system/lang/sv: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey System Module Lang File 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_GET_CPU_INFO=" -- Hämtar processorinformation ..." 9 | STRING_GET_MEMORY_INFO=" -- Hämtar minnesinformation..." 10 | STRING_GET_HDD_INFO=" -- Hämtar hårddiskinformation..." 11 | -------------------------------------------------------------------------------- /webcam/lang/en: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Webcam Module Lang File - by Tomas Pollak (http://bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_TAKE_PICTURE=" -- Taking a picture of the impostor..." 9 | STRING_CAPTURE_VIDEO=" -- Capturing $video_capture_time seconds of video..." 10 | -------------------------------------------------------------------------------- /webcam/lang/es: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Webcam Module Lang File - by Tomas Pollak (http://bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_TAKE_PICTURE=" -- Tomando una foto del ladron..." 9 | STRING_CAPTURE_VIDEO=" -- Capturando $video_capture_time segundos de video..." 10 | -------------------------------------------------------------------------------- /webcam/lang/fr: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Webcam Module Lang File - by Tomas Pollak (http://bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_TAKE_PICTURE=" -- Prise de photo de l'imposteur..." 9 | STRING_CAPTURE_VIDEO=" -- Enregistrement de $video_capture_time secondes de video..." 10 | -------------------------------------------------------------------------------- /alert/lang/fr: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey - by Tomas Pollak (http://bootlog.org) 4 | # URL : http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_CHANGE_WALLPAPER=" -- Changement du fond d'écran pour l'alerter lui et ses voisins..." 9 | STRING_SHOW_ALERT=" -- Affichage de notre message d'alerte pour le type..." 10 | 11 | -------------------------------------------------------------------------------- /session/platform/mac/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Session Module Mac Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | get_screenshot() { 9 | local screencapture='/usr/sbin/screencapture -t jpg -mx' 10 | run_as_current_user "$screencapture $session__screenshot" 11 | } 12 | -------------------------------------------------------------------------------- /geo/platform/windows/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Geo Module Windows Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | get_wifi_access_points() { 9 | 10 | if [ -z "$wifi_info" ]; then 11 | get_wifi_info 12 | fi 13 | wifi_points=`echo "$wifi_info" | tr -d '\n'` 14 | 15 | } 16 | -------------------------------------------------------------------------------- /wipe/platform/linux/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # PREY Wiper Module Linux Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | credentials_path=".gnome2/keyrings" 9 | firefox_path=".mozilla" 10 | thunderbird_path=".thunderbird" 11 | chrome_path=".config/google-chrome" 12 | chromium_path=".config/chromium" 13 | -------------------------------------------------------------------------------- /system/lang/fr: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey System Module Lang File - by Carlos Yaconi 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_GET_CPU_INFO=" -- Recherche d'information sur le processeur..." 9 | STRING_GET_MEMORY_INFO=" -- Recherche d'information sur la mémoire..." 10 | STRING_GET_HDD_INFO=" -- Recherche d'information sur les disques durs..." 11 | -------------------------------------------------------------------------------- /alert/lang/sv: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey - by Tomas Pollak (http://bootlog.org) 4 | # Swedish lang file v 0.1 - by Dan Sellberg (dan@dkcp.com) 5 | # URL : http://preyproject.com 6 | # License: GPLv3 7 | #################################################################### 8 | 9 | STRING_CHANGE_WALLPAPER=" -- Ändrar bakgrundsbild för att göra tjuven och folk runt omkring uppmärksamma..." 10 | STRING_SHOW_ALERT=" -- Visar tjuven vårt varningsmeddelande..." 11 | 12 | -------------------------------------------------------------------------------- /network/platform/windows/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Network Module Windows Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | get_active_connections() { 9 | active_connections=$(netstat -n) 10 | } 11 | 12 | trace_route() { 13 | complete_trace=$(tracert.exe www.google.com 2> /dev/null | grep -v -e "^[a-z]" -e "^$") 14 | } 15 | -------------------------------------------------------------------------------- /webcam/platform/mac/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Webcam Module Mac Functions - by Tomas Pollak (bootlog.org) 4 | # URL : http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | take_picture() { 9 | 10 | run_as_current_user "$module_platform_path/imagesnap -w 1 $webcam__picture" &> /dev/null 11 | 12 | } 13 | 14 | capture_video() { 15 | 16 | log ' !! Feature still in development!' 17 | 18 | } 19 | -------------------------------------------------------------------------------- /network/lang/en: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Network Module Lang File - by Juan C. Mardones (http://juanmardones.com) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_GET_IP=" -- Getting public IP address..." 9 | STRING_GET_LAN_IP=" -- Getting private LAN IP address..." 10 | STRING_GET_WIFI=" -- Getting Wifi info..." 11 | STRING_TRACE=" -- Tracing our complete route to the Internet..." 12 | -------------------------------------------------------------------------------- /alert/lang/es: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey - by Tomas Pollak (http://bootlog.org) 4 | # Spanish language file v 0.2 - by Juan C. Mardones (http://juanmardones.com) 5 | # URL : http://preyproject.com 6 | # License: GPLv3 7 | #################################################################### 8 | 9 | STRING_CHANGE_WALLPAPER=" -- Cambiando el fondo de pantalla para alertar a la persona y a los que esten cerca..." 10 | STRING_SHOW_ALERT=" -- Mostrando nuestro mensaje de alerta..." 11 | 12 | -------------------------------------------------------------------------------- /network/lang/sv: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Network Module Lang File - by Dan Sellberg (dan@dkcp.com) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_GET_IP=" -- Hämtar publik IP-adress ..." 9 | STRING_GET_LAN_IP=" -- Hämtar IP-adress för privat LAN ..." 10 | STRING_GET_WIFI=" -- Hämtar information om trådlösa nätverk ..." 11 | STRING_TRACE=" -- Spårar vår fullständiga väg till internet ..." 12 | -------------------------------------------------------------------------------- /network/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # PREY Network Module Config File - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | # should we trace the complete route? (it's a bit slow) 9 | network__trace_route='n' 10 | 11 | # this is quite slow sometimes 12 | network__get_active_connections='n' 13 | 14 | # should we get the list of nearby wifi access points available? 15 | network__get_nearby_wifi_hotspots='n' 16 | -------------------------------------------------------------------------------- /network/lang/es: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Network Module Lang File - by Juan C. Mardones (http://juanmardones.com) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_GET_IP=" -- Obteniendo la direccion IP publica..." 9 | STRING_GET_LAN_IP=" -- Obteniendo la direccion IP privada de la LAN..." 10 | STRING_GET_WIFI=" -- Obteniendo informacion de la Red Wifi..." 11 | STRING_TRACE=" -- Rastreando la ruta completa hacia Internet..." 12 | -------------------------------------------------------------------------------- /network/lang/fr: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Network Module Lang File - by Juan C. Mardones (http://juanmardones.com) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_GET_IP=" -- Recherche de l'adresse IP publique..." 9 | STRING_GET_LAN_IP=" -- Recherche de l'adresse IP privée sur le réseau local..." 10 | STRING_GET_MAC_AND_WIFI=" -- Recherche de l'adresse MAC, du routage et du Wifi..." 11 | STRING_TRACE=" -- Examen de notre route vers Internet..." 12 | -------------------------------------------------------------------------------- /wipe/platform/mac/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # PREY Secure Module (Mac) Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | credentials_path="Library/Keychains" 9 | firefox_path="Library/Mozilla/Firefox/Profiles" # note: there's also Application\ Support/Firefox 10 | chrome_path="Library/Application\ Support/Google/Chrome" 11 | safari_path="Library/Safari" 12 | thunderbird_path="Library/Thunderbird/Profiles" 13 | -------------------------------------------------------------------------------- /lock/core/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Lock Module - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | # uncomment this when the action system only sends the HUP signal to the parent 9 | # trap 'kill 0' HUP 10 | 11 | if [[ -n "$lock__unlock_pass" && "$logged_user" != 'root' && "$logged_user" != 'SYSTEM' ]]; then 12 | 13 | log ' -- Setting up lock!' 14 | activate_lock 15 | 16 | else 17 | log ' -- Lock password not set! Skipping...' 18 | fi 19 | -------------------------------------------------------------------------------- /webcam/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Webcam Module Config File - by Tomas Pollak 4 | # URL : http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | webcam__picture="$tmpdir/prey-picture.jpg" 9 | webcam__video="$tmpdir/prey-video.mov" 10 | 11 | # should we capture video 12 | webcam__capture_video='n' 13 | 14 | # how much time should we capture video (in seconds) 15 | webcam__video_capture_time='30' 16 | 17 | # frames per second (for streamer in linux) 18 | webcam__frames_per_second='12' 19 | -------------------------------------------------------------------------------- /network/core/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Network Module Core Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | get_public_ip() { 9 | public_ip=$(getter --connect-timeout 3 checkip.dyndns.org | sed 's/[^0-9\.]//g') 10 | } 11 | 12 | # for linux and mac 13 | trace_route() { 14 | traceroute=$(which traceroute) 15 | if [ -n "$traceroute" ]; then 16 | complete_trace=$($traceroute -q1 www.google.com 2>&1 | grep -v -e "^[a-z]" -e "^$") 17 | fi 18 | } 19 | -------------------------------------------------------------------------------- /session/platform/windows/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Session Module Windows Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | get_running_programs() { 9 | running_programs=`tasklist 2> /dev/null` 10 | } 11 | 12 | get_modified_files() { 13 | modified_files=`find "$find_path" -type f -mmin -$session__modified_files_time 2>&1` 14 | } 15 | 16 | get_screenshot() { 17 | run_as_current_user "\"$module_platform_path/preyshot.exe\" \"$session__screenshot\"" 18 | } 19 | -------------------------------------------------------------------------------- /alarm/platform/linux/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Alarm Module Linux Functions 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | sound_alarm() { 9 | local player="mpg123" 10 | if [ -z `which $player` ]; then 11 | log " !! $player audio player not found! Please install through your package manager." 12 | return 1 13 | fi 14 | run_as_current_user "pactl set-sink-mute 0 0" 15 | run_as_current_user "pactl set-sink-volume 0 65536" # pump it up! 16 | run_as_current_user "$player $alarm__sound_file &> /dev/null" & 17 | } 18 | -------------------------------------------------------------------------------- /session/platform/linux/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Session Module Linux Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | get_screenshot() { 9 | 10 | local scrot=`which scrot` # scrot is lighter 11 | local import=`which import` # imagemagick 12 | 13 | if [ -n "$scrot" ]; then 14 | 15 | run_as_current_user "$scrot $session__screenshot" 16 | 17 | elif [ -n "$import" ]; then 18 | 19 | local args="-window root -display :0" 20 | run_as_current_user "$import $args $session__screenshot" 21 | 22 | fi 23 | } 24 | -------------------------------------------------------------------------------- /filesystem/core/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Filesystem Module - (c) 2010 Fork Ltd. 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | filesystem_real_path=`eval echo "$filesystem__root_path"` 9 | 10 | log " -- Scanning filesystem structure..." 11 | get_filesystem_tree "$filesystem_real_path" 12 | 13 | if [[ $? == 0 && -f "$filesystem__temp_file" ]]; then 14 | log " -- Done! Sending updated filesystem structure..." 15 | update_device_with "device[hardware_attributes][filesystem_tree]=\"@$filesystem__temp_file\"" 16 | else 17 | log " -- Filesystem traversing failed!" 18 | fi 19 | -------------------------------------------------------------------------------- /webcam/core/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Webcam Module - by Tomas Pollak (bootlog.org) 4 | # URL : http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | log "$STRING_TAKE_PICTURE" 9 | take_picture 10 | 11 | if [ -f "$webcam__picture" ]; then 12 | add_file picture "$webcam__picture" 13 | else 14 | log " !! Couldn't grab a picture! Please make sure your webcam is correctly configured." 15 | fi 16 | 17 | if [ $webcam__capture_video == 'y' ]; then 18 | 19 | log "$STRING_CAPTURE_VIDEO" 20 | capture_video 21 | 22 | if [ -f "$webcam__video" ]; then 23 | add_file video "$webcam__video" 24 | fi 25 | 26 | fi 27 | -------------------------------------------------------------------------------- /alert/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # PREY Alert Module Configuration File - by Tomas Pollak (bootlog.org) 4 | # URL : http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | # alert the user with a message, y or n 9 | alert__alert_message='This is a stolen computer, and has been marked by Prey. Contact us immediately at http://preyproject.com to clarify the situation. YOU HAVE BEEN WARNED!' 10 | 11 | alert__say_message='n' 12 | 13 | # change wallpaper to alert nearby users -- EXPERIMENTAL! 14 | alert__change_wallpaper='n' 15 | 16 | # which wallpaper to use 17 | alert__wallpaper="$module_path/lib/prey-wallpaper-$lang.png" 18 | -------------------------------------------------------------------------------- /alert/platform/windows/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Alert Module Windows Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | # never tested! 9 | change_wallpaper() { 10 | # reg add "hkcu\control panel\desktop" /v wallpaper /t REG_SZ /d "$wallpaper" /f 11 | # RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters 12 | log ' !! Wallpaper switching still in development on Windows!' 13 | } 14 | 15 | alert_user() { 16 | run_as_current_user "\"$module_platform_path/msgbox.exe\" \"$alert__alert_message\"" & 17 | } 18 | 19 | say_message(){ 20 | log " -- Don't know which text-to-speech software to use!" 21 | } 22 | -------------------------------------------------------------------------------- /session/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # PREY Report Module Config File - by Tomas Pollak (bootlog.org) 4 | # URL : http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | session__screenshot="$tmpdir/prey-screenshot.jpg" 9 | 10 | # should we get list of running programs 11 | session__get_running_programs='n' 12 | 13 | # should we get modified files 14 | session__get_modified_files='n' 15 | 16 | # route where to get the modified files from 17 | session__modified_files_path='~/' 18 | 19 | # timelapse to watch for modified files, in minutes 20 | session__modified_files_time='60' 21 | 22 | # should we grab a screenshot? 23 | session__get_screenshot='y' 24 | 25 | # new stuff 26 | # session__get_reboot_history='n' 27 | -------------------------------------------------------------------------------- /retrieve/lib/u1_upload.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | ############################################# 3 | # Prey Ubuntu One API 4 | # By Tomas Pollak - (c) 2011 Fork Ltd. 5 | # http://preyproject.com 6 | # License: GPLv3 7 | ############################################# 8 | 9 | import os, sys 10 | 11 | try: 12 | file = sys.argv[1] 13 | except IndexError: 14 | print "Usage: " + sys.argv[0] + " [file]" 15 | sys.exit(1) 16 | 17 | if not os.path.exists(file): 18 | print "File does not exist: " + file 19 | sys.exit(1) 20 | 21 | if not os.path.exists('credentialfile.txt'): 22 | print "Credentials file not found. Please run u1rest/createfilekeystore.py" 23 | sys.exit(1) 24 | 25 | file_name = os.path.basename(file) 26 | 27 | from u1rest import get_files_user 28 | user = get_files_user(use_file_keystore=True) 29 | f = user.upload_file(file, "~/Ubuntu One/" + file_name) 30 | -------------------------------------------------------------------------------- /session/lang/sv: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Session Module Lang File - by Dan Sellberg (dan@dkcp.com) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_GET_IP=" -- Hämtar publik IP-adress ..." 9 | STRING_GET_LAN_IP=" -- Hämtar IP-adress för privat LAN ..." 10 | STRING_GET_MAC_AND_WIFI=" -- Hämtar MAC-adress samt information om dirigering och trådlösa nätverk ..." 11 | STRING_TRACE=" -- Spårar vår fullständiga väg till internet..." 12 | STRING_UPTIME_AND_PROCESS=" -- Hämtar datorns drifttid och en lista över program som körs ..." 13 | STRING_MODIFIED_FILES=" -- Hämtar lista över nyligen ändrade filer ..." 14 | STRING_ACTIVE_CONNECTIONS=" -- Hämtar lista över aktiva anslutningar ..." 15 | STRING_GET_SCREENSHOT=" -- Tar skärmbild ..." 16 | -------------------------------------------------------------------------------- /session/lang/en: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Session Module Lang File - by Juan C. Mardones (http://juanmardones.com) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_GET_IP=" -- Getting public IP address..." 9 | STRING_GET_LAN_IP=" -- Getting private LAN IP address..." 10 | STRING_GET_MAC_AND_WIFI=" -- Getting MAC address, routing and Wifi info..." 11 | STRING_TRACE=" -- Tracing our complete route to the Internet..." 12 | STRING_UPTIME_AND_PROCESS=" -- Getting computer uptime and a list of running programs..." 13 | STRING_MODIFIED_FILES=" -- Getting a list of recently modified files..." 14 | STRING_ACTIVE_CONNECTIONS=" -- Getting list of current active connections..." 15 | STRING_GET_SCREENSHOT=" -- Grabbing screenshot of the running desktop..." 16 | -------------------------------------------------------------------------------- /retrieve/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Retrieve Module Config File - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | backup__search_path='$users_path' # better chances of getting something than '~' 9 | 10 | # string to search for 11 | backup__search_string='' 12 | 13 | # this is overriden by the extensions requested remotely, if chosen 14 | backup__search_extensions='txt|rtf|pdf|doc|docx|xls|xlsx|pps|ppt|pptx|odf|odp|ods|key|pages|numbers|dwg|svg|svgz|ai|eps|html|css|js|php|rb|erb|py|cs|c|cpp|java|xml|properties|ini' 15 | 16 | backup__last_modified='' # in number of days 17 | backup__max_size_in_kb='10000' 18 | 19 | backup__sent_files_list='sent_files.csv' 20 | 21 | backup__zip_password='' # optional 22 | 23 | backup__backend='' 24 | backup__backend_path='' 25 | -------------------------------------------------------------------------------- /wipe/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # PREY Wipe Module Configuration File - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | # whether to delete data or to hide it (only applies to email) 9 | wipe__method='hide' 10 | 11 | # should we make sure the program were wiping the user data for isn't running? 12 | wipe__terminate_if_running='y' 13 | 14 | # whether to destroy the keychains/keyrings that holds all the different 15 | # passwords in your system. recommended if you do use them. 16 | wipe__wipe_passwords='n' 17 | 18 | # remove browser profiles for firefox/chrome/ie, depending on OS 19 | wipe__wipe_cookies='n' 20 | 21 | # Appends '.backup' to all Outlook or Thunderbird profiles 22 | # in your PC so that none email and contacts can be found. 23 | wipe__wipe_emails='n' 24 | -------------------------------------------------------------------------------- /session/lang/fr: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Session Module Lang File - by Juan C. Mardones (http://juanmardones.com) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_GET_IP=" -- Recherche de l'adresse IP publique..." 9 | STRING_GET_LAN_IP=" -- Recherche de l'adresse IP privée sur le réseau local..." 10 | STRING_GET_MAC_AND_WIFI=" -- Recherche de l'adresse MAC, du routage et du Wifi..." 11 | STRING_TRACE=" -- Examen de notre route vers Internet..." 12 | STRING_UPTIME_AND_PROCESS=" -- Recherche de la durée de fonctionnement de l'ordinateur et de la liste des programmes en cours..." 13 | STRING_MODIFIED_FILES=" -- Recherce des fichiers modifiés récemment..." 14 | STRING_ACTIVE_CONNECTIONS=" -- Recherche des connexions actives..." 15 | STRING_GET_SCREENSHOT=" -- Capture d'écran du bureau en cours..." 16 | -------------------------------------------------------------------------------- /session/lang/es: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Session Module Lang File - by Juan C. Mardones (http://juanmardones.com) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | STRING_GET_IP=" -- Obteniendo la direccion IP publica..." 9 | STRING_GET_LAN_IP=" -- Obteniendo la direccion IP privada de la LAN..." 10 | STRING_GET_MAC_AND_WIFI=" -- Obteniendo direccion MAC, tabla de rutas e informacion de la Red Wifi..." 11 | STRING_TRACE=" -- Rastreando la ruta completa hacia Internet..." 12 | STRING_UPTIME_AND_PROCESS=" -- Obteniendo el uptime y la lista de programas en ejecucion..." 13 | STRING_MODIFIED_FILES=" -- Obteniendo una lista de los archivos recientemente modificados..." 14 | STRING_ACTIVE_CONNECTIONS=" -- Obteniendo la lista de las conecciones activas..." 15 | STRING_GET_SCREENSHOT=" -- Obteniendo una captura de pantalla..." 16 | -------------------------------------------------------------------------------- /system/core/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey System Module - by Carlos Yaconi H. 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | log " -- Scanning current system's hardware..." 9 | scan_system_hardware 10 | 11 | log ' -- Sending updated data...' 12 | send_updated_hardware_data 13 | 14 | #get_os_info 15 | #log "OS Version: $os_version" 16 | #log "Kernel Version: $kernel_version" 17 | 18 | #get_cpu_info 19 | #log "CPU info: $cpu_info" 20 | 21 | #get_memory_info 22 | #log "Memory info: $mem_info" 23 | #log "Memory Total: $mem_total" 24 | 25 | #get_system_ids 26 | #log "Serial number: $serial_number" 27 | #log "UUID: $hw_UUID" 28 | 29 | #get_hdd_info 30 | #log "HDD info: $hdd_info" 31 | 32 | #add_trace cpu_name $cpu_name 33 | #add_trace cpu_speed $cpu_speed 34 | #add_trace cpu_number $cpu_number 35 | #add_trace cpu_cores $cpu_cores 36 | -------------------------------------------------------------------------------- /alert/core/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Alert Module - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | log "$STRING_SHOW_ALERT" 9 | alert_user 10 | 11 | if [ "$alert__say_message" == 'y' ]; then 12 | log ' -- Saying the message out loud...' 13 | say_message 14 | fi 15 | 16 | if [ $alert__change_wallpaper == 'y' ]; then 17 | 18 | # if [ ! -f "$alert__wallpaper" ]; then 19 | 20 | # TODO: finish this, to allow setting the wallpaper remotely 21 | # if [ `find_in "$alert__wallpaper" 'http://'` ]; then 22 | # wget $alert__wallpaper -O $module_path/lib/prey-wallpaper-custom.jpg 23 | # alert__wallpaper="$module_path/lib/prey-wallpaper-custom.jpg" 24 | # sed -i -e $module_path/config 'alert__wallpaper=.*$/alert__wallpaper=\'$module_path/lib/prey-wallpaper-$lang.png\'/' 25 | # fi 26 | 27 | # fi 28 | 29 | change_wallpaper 30 | fi 31 | -------------------------------------------------------------------------------- /wipe/core/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Wipe Module - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | if [[ "$secure__wipe_passwords" == 'y' && "$os" != "windows" ]]; then 9 | 10 | secure_folder "${credentials_path}" 11 | 12 | fi 13 | 14 | if [ "$wipe__wipe_cookies" == 'y' ]; then 15 | 16 | secure_folder "$firefox_path" 'firefox' 17 | secure_folder "$chrome_path" 'chrome' 18 | 19 | if [ "$os" == "linux" ]; then 20 | secure_folder "$chromium_path" 'chromium-browser' 21 | else 22 | secure_folder "$safari_path" 'safari' 23 | if [ "$os" == "windows" ]; then 24 | secure_ie_data 25 | fi 26 | fi 27 | 28 | fi 29 | 30 | if [ "$wipe__wipe_emails" == 'y' ]; then 31 | 32 | secure_folder "$thunderbird_path" 'thunderbird' 33 | if [ "$os" == "windows" ]; then 34 | secure_folder "$outlook_path" 'outlook' 35 | fi 36 | 37 | fi 38 | -------------------------------------------------------------------------------- /session/core/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Session Module Core Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | get_uptime(){ 9 | uptime=`uptime 2> /dev/null` 10 | } 11 | 12 | get_running_programs() { 13 | running_programs=`ps aux | grep -v root` 14 | } 15 | 16 | locate_path(){ 17 | if [ "$session__modified_files_path" == '~/' ]; then 18 | find_path=`eval echo $home_path` 19 | else 20 | find_path=`eval echo $session__modified_files_path` 21 | fi 22 | } 23 | 24 | get_modified_files() { 25 | # we dont include hidden files 26 | modified_files=`find $find_path \( ! -regex '.*/\..*/..*' \) -type f -mmin -$session__modified_files_time 2> /dev/null` 27 | } 28 | 29 | compress_screenshot() { 30 | log " -- Compressing screenshot..." 31 | tar zcf $session__screenshot.tar.gz $session__screenshot 32 | session__screenshot=$screenshot.tar.gz 33 | } 34 | -------------------------------------------------------------------------------- /lock/core/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Lock Module Core Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | # set -bm 9 | 10 | before_lock_callback(){ 11 | log " -- Running lock before callback." 12 | } 13 | 14 | after_lock_callback(){ 15 | log " -- Running lock after callback." 16 | } 17 | 18 | activate_lock(){ 19 | 20 | if [ -n "`is_process_running 'prey-lock'`" ]; then 21 | log ' -- Prey lock seems to be running already!' 22 | return 1 23 | fi 24 | 25 | before_lock_callback 26 | local command="\"$lock__executable\" `md5_hash_for $lock__unlock_pass`" 27 | run_as_current_user "$command" & 28 | # trap 'reactivate_lock' SIGCHLD 29 | pid=$! 30 | wait $pid 31 | rs=$? 32 | # echo "return status was: $rs" 33 | if [ $rs -eq 66 ]; then 34 | deactivate_modules_on_panel "lock" 35 | elif [ $rs -gt 1 ]; then # just in case we got an error 36 | activate_lock 37 | return 38 | fi 39 | after_lock_callback 40 | 41 | } 42 | -------------------------------------------------------------------------------- /geo/platform/mac/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Geo Module Mac Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | get_wifi_access_points() { 9 | 10 | get_wifi_info 11 | if [ -n "$wifi_info" ]; then 12 | 13 | wifi_points=`$airport -s -x | egrep 'BSSID|>CHANNEL<|NOISE|SSID_STR|RSSI' --after-context=1 \ 14 | | egrep -v "AGE|array|WPA|80211" | tr '\n' ' ' | tr -d '\t' \ 15 | | sed -e 's/<[^>]*>//g' \ 16 | -e 's/ -- /, /g' \ 17 | -e 'y/:/-/' \ 18 | -e 's/ \([0-9]\)-/ 0\1-/g' -e 's/-\([0-9]\)\([-|,]\)/-0\1\2/g' \ 19 | -e 's/BSSID \([a-f0-9-]*\)/{"mac_address": "\1"/g' \ 20 | -e 's/CHANNEL \([0-9]*\)/"channel": \1/g' \ 21 | -e 's/NOISE \([0-9]*\)/"signal_to_noise": \1/g' \ 22 | -e 's/RSSI \([0-9]*\)/"signal_strength": \1/g' \ 23 | -e 's/SSID_STR \([^,]*\)/"ssid": "\1"}/g' \ 24 | -e 's/ "\([,|}]\)/"\1/g' \ 25 | -e 's/"/\\"/g'` 26 | 27 | else 28 | 29 | log " -- Couldn't grab any information from Airport." 30 | 31 | fi 32 | 33 | } 34 | -------------------------------------------------------------------------------- /session/core/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Session Module - by Tomas Pollak (bootlog.org) 4 | # URL : http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | log " -- Getting current logged in user name..." 9 | add_trace logged_user $logged_user 10 | 11 | log "$STRING_UPTIME_AND_PROCESS" 12 | get_uptime 13 | add_trace uptime "$uptime" 14 | 15 | if [ "$session__get_running_programs" == 'y' ]; then 16 | get_running_programs 17 | add_trace running_programs "$running_programs" 18 | fi 19 | 20 | if [ "$session__get_modified_files" == 'y' ]; then 21 | locate_path 22 | log "$STRING_MODIFIED_FILES" 23 | get_modified_files 24 | if [ -n "$modified_files" ]; then 25 | add_trace modified_files "$modified_files" 26 | else 27 | log ' !! Nothing found. Make sure you type in a valid path.' 28 | fi 29 | fi 30 | 31 | if [ "$session__get_screenshot" == 'y' ]; then 32 | log "$STRING_GET_SCREENSHOT" 33 | get_screenshot 34 | if [ -f "$session__screenshot" ]; then 35 | add_file screenshot "$session__screenshot" 36 | fi 37 | fi 38 | -------------------------------------------------------------------------------- /webcam/platform/windows/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Webcam Module Windows Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | take_picture() { 9 | 10 | #if [ ! -f "$WINDIR\system32\msvbvm50.dll" ]; then 11 | # if [ ! -f "$platform_path\bin\msvbvm50.dll" ]; then 12 | # log ' ** Fetching necessary DLL for Webcam capture to work... (about 1 MB)' 13 | # wget http://examples.oreilly.com/error/CDROM/MsLibs/MSVBVM50.DLL -O "$platform_path/bin/msvbvm50.dll" 2> /dev/null 14 | # fi 15 | #fi 16 | 17 | # we could add dimensions to the image (-w 640 -h 480) 18 | # snapshot.exe adds a .jpg to the out file, so we just put it with no extension 19 | # "$module_platform_path/snapshot.exe" -q 100 "$tmpdir/prey-picture" 20 | 21 | #New module call 22 | "$module_platform_path/prey-webcam.exe" -invalid youcam,cyberlink,google -frame 10 -outfile "$tmpdir/prey-picture.jpg" 23 | } 24 | 25 | capture_video() { 26 | 27 | log ' !! Video capture still in development!' 28 | 29 | } 30 | -------------------------------------------------------------------------------- /geo/platform/linux/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Geo Module Linux Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | get_wifi_access_points() { 9 | 10 | get_wifi_device 11 | if [ -n "$wifi_device" ]; then 12 | 13 | log " -- Detected wireless device at ${wifi_device}." 14 | 15 | wifi_points=`\`which iwlist\` $wifi_device scan | grep -v "Frequency" | egrep 'Address|Channel|ESSID|Signal' | tr -d '\n' | \ 16 | sed -e 's/ //g' -e 's/Cell[0-9 -]*//g' \ 17 | -e "s/Quality[0-9=:\/ ]*Signal//g" \ 18 | -e 's/\([A-F0-9]\):\([A-F0-9]\)/\1-\2/g' \ 19 | -e 's/Channel:\([0-9]*\)/"channel": \1,/g' \ 20 | -e 's/Address: \?\([A-F0-9-]\{17\}\)/{"mac_address": "\1", /g' \ 21 | -e 's/ESSID:"\([^"]*\)"/"ssid": "\1", /g' \ 22 | -e 's/level.\([0-9\/-]*\) \?dBm\([^"{]*\)/"signal_strength": \1, /g' \ 23 | -e 's/, {/}, {/g' \ 24 | -e "s/\\\x..//g" \ 25 | -e "s/, $/}/"` 26 | 27 | else 28 | 29 | log " -- No wireless device detected." 30 | 31 | fi 32 | 33 | } 34 | -------------------------------------------------------------------------------- /network/core/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Network Module - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | log "$STRING_GET_IP" 9 | get_public_ip 10 | add_trace public_ip $public_ip 11 | 12 | log "$STRING_GET_LAN_IP" 13 | internal_ip=$(get_ip_address | head -1) 14 | add_trace internal_ip $internal_ip 15 | 16 | log " -- Getting gateway IP address..." 17 | gateway_ip=$(get_gateway_ip | head -1) 18 | add_trace gateway_ip $gateway_ip 19 | 20 | if [ "$network__get_active_connections" == 'y' ]; then 21 | log "$STRING_ACTIVE_CONNECTIONS" 22 | get_active_connections 23 | add_trace active_connections "$active_connections" 24 | fi 25 | 26 | if [ "$network__get_nearby_wifi_hotspots" == 'y' ]; then 27 | log "$STRING_GET_WIFI" 28 | [ -z "$wifi_info" ] && get_wifi_info 29 | [ -n "$wifi_info" ] && add_trace wifi_info "$wifi_info" 30 | fi 31 | 32 | if [[ "$network__trace_route" == 'y' && -z "$proxy_server" ]]; then 33 | log "$STRING_TRACE" 34 | trace_route 35 | add_trace complete_trace "$complete_trace" 36 | fi 37 | -------------------------------------------------------------------------------- /system/platform/windows/ramcheck.vbs: -------------------------------------------------------------------------------- 1 | ' Script for Win32_PhysicalMemory WMI Class 2 | ' From http://www.activexperts.com/activmonitor/windowsmanagement/scripts/hardware/memory/ 3 | 4 | On Error Resume Next 5 | 6 | strComputer = "." 7 | Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 8 | 9 | Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory") 10 | 11 | For Each objItem in colItems 12 | Wscript.Echo "Bank Label: " & objItem.BankLabel 13 | Wscript.Echo "Capacity: " & objItem.Capacity 14 | Wscript.Echo "Data Width: " & objItem.DataWidth 15 | Wscript.Echo "Description: " & objItem.Description 16 | Wscript.Echo "Device Locator: " & objItem.DeviceLocator 17 | Wscript.Echo "Form Factor: " & objItem.FormFactor 18 | Wscript.Echo "Hot Swappable: " & objItem.HotSwappable 19 | Wscript.Echo "Manufacturer: " & objItem.Manufacturer 20 | Wscript.Echo "Memory Type: " & objItem.MemoryType 21 | Wscript.Echo "Name: " & objItem.Name 22 | Wscript.Echo "Part Number: " & objItem.PartNumber 23 | Wscript.Echo "Position In Row: " & objItem.PositionInRow 24 | Wscript.Echo "Speed: " & objItem.Speed 25 | Wscript.Echo "Tag: " & objItem.Tag 26 | Wscript.Echo "Type Detail: " & objItem.TypeDetail 27 | Next 28 | -------------------------------------------------------------------------------- /lock/platform/windows/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Lock Windows Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | system_policy_key="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" 9 | 10 | before_lock_callback(){ 11 | log " -- Locking escape methods..." 12 | "${module_platform_path}/lockpolicy.exe" allow 13 | reg add "HKLM\\${system_policy_key}" //v HideFastUserSwitching //t REG_DWORD //d 1 //f > /dev/null 14 | run_as_current_user "reg add HKCU\\${system_policy_key} //v DisableTaskMgr //t REG_DWORD //d 1 //f" > /dev/null 15 | run_as_current_user "reg add HKCU\\${system_policy_key} //v DisableChangePassword //t REG_DWORD //d 1 //f" > /dev/null 16 | } 17 | 18 | after_lock_callback(){ 19 | log " -- Reenabling system policies..." 20 | reg add "HKLM\\${system_policy_key}" //v HideFastUserSwitching //t REG_DWORD //d 0 //f > /dev/null 21 | run_as_current_user "reg add HKCU\\${system_policy_key} //v DisableTaskMgr //t REG_DWORD //d 0 //f" > /dev/null 22 | run_as_current_user "reg add HKCU\\${system_policy_key} //v DisableChangePassword //t REG_DWORD //d 0 //f" > /dev/null 23 | "${module_platform_path}/lockpolicy.exe" deny 24 | } 25 | -------------------------------------------------------------------------------- /geo/core/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Geo Module - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | log ' -- Trying to get list of nearby Wifi access points...' 9 | get_wifi_access_points 10 | 11 | if [ -n "$wifi_points" ]; then 12 | 13 | log " -- Got it! Now lets try to get a location fix..." 14 | get_current_location 15 | parse_location_response 16 | 17 | local any_chars_in_lat=$(echo $current_lat | sed 's/[^a-z]//g') 18 | 19 | if [ -z "$any_chars_in_lat" ]; then 20 | 21 | add_trace 'lat' $current_lat 22 | add_trace 'lng' $current_lng 23 | add_trace 'accuracy' $spot_accuracy 24 | # add_trace 'address' "$current_address" 25 | # add_trace 'full' "$current_location_json" 26 | 27 | elif [ -n "$current_location_json" ]; then 28 | 29 | notify_exception "Bad Geolocation Response" "$current_location_json" 30 | log " !! Invalid response from geocoder service. Skipping geolocation data." 31 | 32 | else 33 | 34 | notify_exception "No Geolocation Response" 35 | log " !! Couldn't get a response from geocoder service. Skipping geolocation data." 36 | 37 | fi 38 | 39 | else 40 | log " !! Couldn't get any Wifi information. Does this computer have Wifi capabilities?" 41 | fi 42 | -------------------------------------------------------------------------------- /lock/platform/mac/prey-lock.app/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 11C74 7 | CFBundleDevelopmentRegion 8 | English 9 | CFBundleExecutable 10 | prey-lock 11 | CFBundleIdentifier 12 | com.forkltd.prey-lock 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | prey-lock 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | DTCompiler 26 | 27 | DTPlatformBuild 28 | 4D502 29 | DTPlatformVersion 30 | GM 31 | DTSDKBuild 32 | 10K549 33 | DTSDKName 34 | macosx10.6 35 | DTXcode 36 | 0421 37 | DTXcodeBuild 38 | 4D502 39 | LSMinimumSystemVersion 40 | 10.5 41 | NSMainNibFile 42 | MainMenu 43 | NSPrincipalClass 44 | NSApplication 45 | 46 | 47 | -------------------------------------------------------------------------------- /wipe/core/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Wipe Module Core Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | secure_folder(){ 9 | eval ${wipe__method}_folder \"$1\" \"$2\" 10 | } 11 | 12 | # receives $1 => path, $2 => name of program 13 | # example: delete_folder $safari_data_path 'safari' 14 | delete_folder() { 15 | if [[ -n "$2" && "$wipe__terminate_if_running" == "y" ]]; then 16 | kill_process $2 17 | fi 18 | if [ -z "$1" ]; then 19 | return 1 20 | fi 21 | if [ -d "$users_path" ]; then 22 | for user_path in `find "$users_path" -maxdepth 1 -mindepth 1 -type d`; do 23 | if [ -d "$user_path/$1" ]; then 24 | log " -- Deleting $1 folder on $user_path..." 25 | rm -Rf "$user_path/$1" 2> /dev/null 26 | fi 27 | done 28 | fi 29 | } 30 | 31 | hide_folder(){ 32 | if [[ -n "$2" && "$wipe__terminate_if_running" == "y" ]]; then 33 | kill_process $2 34 | fi 35 | if [ -z "$1" ]; then 36 | return 1 37 | fi 38 | if [ -d "$users_path" ]; then 39 | for user_path in `find "$users_path" -maxdepth 1 -mindepth 1 -type d`; do 40 | if [ ! -d "$user_path/$1.backup" ]; then 41 | log " -- Backup folder already exists for $1. Skipping..." 42 | elif [ -d "$user_path/$1" ]; then 43 | log " -- Hiding $1 folder on $user_path..." 44 | mv "$user_path/$1" "$user_path/$1.backup" 2> /dev/null 45 | fi 46 | done 47 | fi 48 | } 49 | -------------------------------------------------------------------------------- /geo/core/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Geo Module Core Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | get_current_location() { 9 | if [ -n "$wifi_points" ]; then 10 | 11 | # count number of access points (by occurrences of the } char) 12 | local count="$(echo $wifi_points | awk -F} '{print NF-1}')" 13 | 14 | if [ $count -gt 30 ]; then 15 | # make sure we don't have more than 30 items, 16 | # otherwise we'll get a nasty 'request too large' error 17 | local wifi_points="$(echo "$wifi_points" | cut -d "}" -f 1-30)}" 18 | fi 19 | 20 | local query=$(echo $wifi_points | tr -d '}"\\' | \ 21 | awk 'BEGIN {RS=","; FS=":"} 22 | /mac_address/ { gsub(/ /,"", $2); printf "&wifi=mac:%s",$2 } 23 | /ssid/ { gsub(/^ */,"", $2); gsub(/ /,"%20",$2); printf "|ssid:%s",$2 } 24 | /signal_strength/ { gsub(/ /,"", $2); printf "|ss:%s",$2 } 25 | ') 26 | 27 | local url="https://maps.googleapis.com/maps/api/browserlocation/json" 28 | local full_req="${url}?browser=true&sensor=true${query}" 29 | 30 | current_location_json="$(getter ${full_req})" 31 | fi 32 | } 33 | 34 | parse_location_response() { 35 | current_lat=$(echo $current_location_json | LANG=en_EN.UTF-8 sed 's/.*lat" : \(-*[0-9.]*\),.*/\1/') 36 | current_lng=$(echo $current_location_json | LANG=en_EN.UTF-8 sed 's/.*lng" : \(-*[0-9.]*\) }.*/\1/') 37 | # current_address=`echo $current_location_json | LANG=en_EN.UTF-8 sed 's/.*address":\(.*\)/\1/'` 38 | spot_accuracy=$(echo $current_location_json | LANG=en_EN.UTF-8 sed 's/.*accuracy" : \([0-9.]*\),.*/\1/') 39 | } 40 | -------------------------------------------------------------------------------- /webcam/platform/linux/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Webcam Module Linux Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | take_picture() { 9 | 10 | # do we have streamer installed ? 11 | local streamer=`which streamer` 12 | if [ -n "$streamer" ]; then 13 | 14 | # take four pictures every 0.5 seconds as JPEG 15 | $streamer -t 4 -r 0.5 -o "$tmpdir/streamer0.jpeg" &> /dev/null 16 | 17 | if [ -f "$tmpdir/streamer3.jpeg" ]; then # we got it 18 | 19 | mv "$tmpdir/streamer3.jpeg" "$webcam__picture" > /dev/null 20 | rm -f "$tmpdir/streamer{0,1,2}.jpeg" 2> /dev/null 21 | 22 | else # some webcams are unable to take JPGs so we try to grab a PPM 23 | 24 | $streamer -t 4 -r 0.5 -o "$tmpdir/streamer0.ppm" &> /dev/null 25 | if [ -f "$tmpdir/streamer3.ppm" ]; then # good 26 | 27 | local convert=`which convert` 28 | if [ -n "$convert" ]; then # lets convert it to jpg 29 | $convert "$tmpdir/streamer3.ppm" "$webcam__picture" > /dev/null 30 | else # lets just send it as a PPM 31 | log " -- Could't find Imagemagick! Sending image as PPM." 32 | webcam__picture="$tmpdir/streamer3.ppm" 33 | fi 34 | 35 | rm -f "$tmpdir/streamer{0,1,2}.ppm" 36 | 37 | fi 38 | 39 | fi 40 | 41 | fi 42 | 43 | } 44 | 45 | capture_video() { 46 | 47 | # we should already know if we do have streamer 48 | if [ -n "$streamer" ]; then 49 | 50 | local frames=$(( $webcam__video_capture_time * $webcam__frames_per_second )) 51 | $streamer -o "$webcam__video" -f yuv2 -F stereo -r $webcam__frames_per_second -t $frames 52 | 53 | fi 54 | 55 | } 56 | -------------------------------------------------------------------------------- /wipe/platform/windows/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Secure Module Windows Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | # XP -> C:\Documents and Settings\\Local Settings\Application Data\ 9 | # Vista -> C:\Users\\AppData\Local\ 10 | 11 | if [ -n "$winxp" ]; then # vista and up 12 | data_path="Application\ Data" 13 | else # xp and 2000 14 | data_path="AppData\Local" 15 | fi 16 | 17 | # credentials_path="" 18 | firefox_path="${data_path}\Mozilla\Firefox\Profiles" 19 | chrome_path="${data_path}\Google\Chrome" 20 | safari_path="${data_path}\Apple\ Computer\Safari" 21 | thunderbird_path="${data_path}\Thunderbird\Profiles" 22 | outlook_path="${data_path}\Microsoft\Outlook" 23 | 24 | secure_ie_data(){ 25 | # RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32 26 | # this above deletes all, but well do it by parts so we have more control 27 | delete_ie_passwords 28 | delete_ie_form_data 29 | delete_ie_temporary_internet_files 30 | delete_ie_cookies 31 | delete_ie_history 32 | if [ "$wipe__terminate_if_running" == "y" ]; then 33 | kill_process iexplore 34 | fi 35 | } 36 | 37 | delete_ie_passwords() { 38 | RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32 39 | } 40 | 41 | delete_ie_form_data() { 42 | Rundll32.exe inetcpl.cpl,ClearMyTracksByProcess 16 43 | } 44 | 45 | delete_ie_temporary_internet_files() { 46 | RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 47 | } 48 | 49 | delete_ie_cookies() { 50 | RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2 51 | } 52 | 53 | delete_ie_history() { 54 | RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1 55 | } 56 | -------------------------------------------------------------------------------- /system/core/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey System Module Core Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | scan_system_hardware(){ 9 | 10 | get_system_ids 2> /dev/null 11 | [ "$os" != "mac" ] && get_mb_info 2> /dev/null 12 | get_cpu_info 2> /dev/null 13 | get_memory_info 2> /dev/null 14 | get_bios_info 2> /dev/null 15 | 16 | get_storage_devices 2> /dev/null 17 | get_network_interfaces 2> /dev/null 18 | 19 | } 20 | 21 | store_system_value(){ 22 | [ -n "$2" ] && store_key_value 'system' "hardware_attributes__${1}" "$(urlencode "$2")" 23 | } 24 | 25 | store_network_interface_value(){ 26 | [ -n "$3" ] && store_key_value 'network_interfaces' "${1}__${2}" "$(urlencode "$3")" 27 | } 28 | 29 | store_storage_device_value(){ 30 | [ -n "$3" ] && store_key_value 'storage_devices' "${1}__${2}" "$(urlencode "$3")" 31 | } 32 | 33 | store_system_params(){ 34 | 35 | for key in $(echo $system__vars); do 36 | local value=$(eval echo "\$system__${key}") 37 | [ -n "$value" ] && store_system_value "$key" "$value" 38 | done 39 | 40 | } 41 | 42 | full_hardware_params(){ 43 | store_system_params 44 | 45 | local system_params=$(generate_query_string 'system' '&device') 46 | # log "$system_params" 47 | 48 | local network_params=$(generate_query_string 'network_interfaces' '&device[hardware_attributes][network]') 49 | # log "$network_params" 50 | 51 | local storage_params=$(generate_query_string 'storage_devices' '&device[hardware_attributes][storage]') 52 | # log "$storage_params" 53 | 54 | echo "${system_params}${network_params}${storage_params}" 55 | } 56 | 57 | send_updated_hardware_data(){ 58 | update_device_info_with "$(full_hardware_params)" 59 | } 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Modules Repository for the Prey Bash Client 2 | 3 | These modules provide the core functionality for the Prey Bash client. 4 | They are run when triggered remotely, either the official Control Panel 5 | (panel.preyproject.com) or through the [Standalone Panel](https://github.com/prey/prey-standalone-control-panel). 6 | 7 | # How they work 8 | 9 | When enabled, Prey will call the ./run script located in the module's core/ 10 | directory, so in essence the only needed thing for a module to run is that 11 | file. However, Prey will also load additional scripts in case they are found 12 | in the module's path. These are: 13 | 14 | - /[module_name]/config -> For keeping settings 15 | - /[module_name]/functions -> Shared functions 16 | - /[module_name]/platform/{mac,linux,windows}/functions -> Platform-specific functions 17 | 18 | This way you can separate shared logic from that which is platform specific. 19 | 20 | # When called 21 | 22 | Prey runs modules in paralell, by calling the ./core/run scripts daemonized. 23 | Since they are called in the context of the running script (the main core logic), 24 | modules can access all variables previously defined by Prey. The most useful 25 | ones are: 26 | 27 | - $os (linux, mac or windows) 28 | - $logged_user 29 | - $root_path 30 | - $users_path 31 | - $home_path 32 | - $tmpbase 33 | - $tmpdir (random directory created by Prey for storing temporary data) 34 | 35 | Additionally, Prey will also provide modules with utility variables for modules: 36 | 37 | - $module_path: /[module_name]/ 38 | - $module_platform_path: /[module_name]/platform/{mac,linux,windows} 39 | 40 | # Available functions 41 | 42 | Modules also get the helper functions defined in Prey's core/framework and 43 | core/functions files. A good way to see what you can do is to look at any 44 | of the existing modules and see how they store data or perform different actions. 45 | 46 | (c) 2011 - Fork Ltd. Licensed under the GPLv3. 47 | -------------------------------------------------------------------------------- /alert/platform/mac/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Alert Module Mac Functions - by Tomas Pollak (bootlog.org) 4 | # URL : http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | change_wallpaper() { 9 | # this code belongs to Katy Richard 10 | # http://thingsthatwork.net/index.php/2008/02/07/fun-with-os-x-defaults-and-launchd/ 11 | 12 | defaults write com.apple.Desktop Background "{default = {ChangePath = '~/Pictures'; ChooseFolderPath = '~/Pictures'; CollectionString = Wallpapers; ImageFileAlias = <00000000 00e00003 00000000 c2cc314a 0000482b 00000000 00089e0c 001be568 0000c2fe 8ab30000 00000920 fffe0000 00000000 0000ffff ffff0001 00100008 9e0c0007 4cea0007 4cb40013 52b2000e 00260012 00740068 00650065 006d0070 00690072 0065005f 00310036 00380030 002e006a 00700067 000f001a 000c004d 00610063 0069006e 0074006f 00730068 00200048 00440012 00355573 6572732f 6b726963 68617264 2f506963 74757265 732f5761 6c6c7061 70657273 2f746865 656d7069 72655f31 3638302e 6a706700 00130001 2f000015 0002000f ffff0000 >; ImageFilePath = $alert__wallpaper; Placement = Crop; TimerPopUpTag = 6; };}" 13 | 14 | # we need to restart the dock to make the new wallpaper visible 15 | killall Dock 16 | } 17 | 18 | # Mac alert msg code by Matias Halles (http://halles.cl) 19 | alert_user() { 20 | 21 | show_message_script=" 22 | tell application \"System Events\" 23 | activate 24 | set dd to display dialog \"\n$alert__alert_message\n\" buttons {\"OK\"} default button 1 with icon caution 25 | end tell" 26 | 27 | osascript -e "$show_message_script" & 28 | 29 | } 30 | 31 | say_message(){ 32 | local alert_voice='Zarvox' 33 | # can be Agnes, Kathy, Princess, Vicki, Victoria, Bruce, Fred, Junior, Ralph, Albert, Bad News, Bahh, Bells, Boing, Bubbles, Cellos , Deranged, Good News, Hysterical, Pipe Organ, Trinoids, Whisper, Zarvox 34 | 35 | osascript -e "say \"$alert__alert_message\" using \"$alert_voice\"" & 36 | } 37 | -------------------------------------------------------------------------------- /webcam/platform/windows/README.md: -------------------------------------------------------------------------------- 1 | ## Prey's new webcam module 2 | 3 | ### Introduction 4 | 5 | This is the new webcam executable, based on DirectShow, that grabs a bright image from any available webcam installed on the computer, regardless if YouCam is installed or not. 6 | 7 | As it's written in C#, it uses DirectShow's binding project [DirectShowNet](http://directshownet.sourceforge.net/), and that's why the executable needs the included DirectShowLib-2005.dll file. 8 | 9 | The way the executable works when it runs without any parameter is as follow: 10 | 11 | - It gets the first available video input device. 12 | - It opens a video stream and discards the first 4 frames to avoid dark images. 13 | - It saves the picture taken into the same execution directory. 14 | 15 | In case it can't find any available input device, then will silently finish. 16 | 17 | 18 | ### Tweaking it. 19 | 20 | These are the available command line options: 21 | 22 | - **outfile**: Name of the output file (default: prey-picture.jpg) 23 | - **framerate**: Framerate of the video stream used to get the picture. It is not recommended to modify the default value (default: 15). 24 | - **height**: Height of the picture. There's not a default value since Prey will try to get max size. 25 | - **width**: Height of the picture. There's not a default value since Prey will try to get max size. 26 | - **frame**: Frame number, from the video stream, to use as the picture (default: 4) 27 | - **invalid**: Comma-separated strings with the invalid input source names (default ''). 28 | - **kill_youcam**: If YouCam.exe process is running, then Prey will kill it before trying to get a video device (default: false). 29 | - **debug**: Prints verbose log (default: false) 30 | 31 | ### Example 32 | 33 | Avoid the use of any device that its name contains the word "youcam" or "cyberlink" or "google" and use the frame number 10 of the video stream as the valid picture: 34 | 35 | prey-webcam.exe -invalid youcam,cyberlink,google -frame 10 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /retrieve/lib/u1rest/createfilekeystore.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #Copyright (C) 2011 by John O'Brien 3 | # 4 | #Permission is hereby granted, free of charge, to any person obtaining a copy 5 | #of this software and associated documentation files (the "Software"), to deal 6 | #in the Software without restriction, including without limitation the rights 7 | #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | #copies of the Software, and to permit persons to whom the Software is 9 | #furnished to do so, subject to the following conditions: 10 | # 11 | #The above copyright notice and this permission notice shall be included in 12 | #all copies or substantial portions of the Software. 13 | # 14 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | #THE SOFTWARE. 21 | """Use this to create a file to store credentials. 22 | 23 | This is used instead of using the credentials stored in the Gnome Keyring. 24 | You must already have an Ubuntu One subscription before you do this. 25 | """ 26 | 27 | from optparse import OptionParser 28 | from u1rest.lib.auth.simpleauth import FileStoreAuthenticator 29 | 30 | def create_credential_file(): 31 | """Create the credential file.""" 32 | op_parser = OptionParser() 33 | op_parser.add_option("--email", dest="email", 34 | help="The SSO Email Address for the user.") 35 | op_parser.add_option("--password", dest="password", 36 | help="The SSO Password for the user.") 37 | op_parser.add_option("--name", dest="name", 38 | help="The Token Name for the client's OAuth token.") 39 | (options, _) = op_parser.parse_args() 40 | auth_store = FileStoreAuthenticator() 41 | auth_store.create_and_save_credentials( 42 | options.name, options.email, options.password) 43 | 44 | if __name__ == '__main__': 45 | create_credential_file() 46 | -------------------------------------------------------------------------------- /retrieve/lib/u1rest/lib/auth/gnomeauth.py: -------------------------------------------------------------------------------- 1 | #Copyright (C) 2011 by John O'Brien 2 | # 3 | #Permission is hereby granted, free of charge, to any person obtaining a copy 4 | #of this software and associated documentation files (the "Software"), to deal 5 | #in the Software without restriction, including without limitation the rights 6 | #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | #copies of the Software, and to permit persons to whom the Software is 8 | #furnished to do so, subject to the following conditions: 9 | # 10 | #The above copyright notice and this permission notice shall be included in 11 | #all copies or substantial portions of the Software. 12 | # 13 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | #THE SOFTWARE. 20 | """An authenticator based on the Gnome Keyring.""" 21 | import gobject 22 | 23 | try: 24 | from ubuntuone.clientdefs import APP_NAME 25 | except ImportError: 26 | APP_NAME = "Ubuntu One" 27 | from ubuntu_sso.main import Credentials 28 | 29 | from u1rest.lib.auth.baseauth import BaseAuthenticator 30 | 31 | class GnomeStoreAuthenticator(BaseAuthenticator): 32 | """A Gnome based Authenticator.""" 33 | 34 | def __init__(self): 35 | super(GnomeStoreAuthenticator, self).__init__() 36 | self.app = gobject.MainLoop() 37 | 38 | def load_credentials(self): 39 | """Load the OAuth credentials.""" 40 | #pylint: disable=E1101 41 | if self._credentials is None: 42 | fc_deferred = Credentials(APP_NAME).find_credentials() 43 | fc_deferred.addCallback(self._set_credentials) 44 | fc_deferred.addBoth(self._stop) 45 | self.app.run() 46 | 47 | def _set_credentials(self, credentials): 48 | """Set the credentials.""" 49 | self._credentials = credentials 50 | 51 | def _stop(self, _): 52 | """Stop the MainLoop.""" 53 | self.app.quit() 54 | -------------------------------------------------------------------------------- /retrieve/lib/u1rest/__init__.py: -------------------------------------------------------------------------------- 1 | #Copyright (C) 2011 by John O'Brien 2 | # 3 | #Permission is hereby granted, free of charge, to any person obtaining a copy 4 | #of this software and associated documentation files (the "Software"), to deal 5 | #in the Software without restriction, including without limitation the rights 6 | #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | #copies of the Software, and to permit persons to whom the Software is 8 | #furnished to do so, subject to the following conditions: 9 | # 10 | #The above copyright notice and this permission notice shall be included in 11 | #all copies or substantial portions of the Software. 12 | # 13 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | #THE SOFTWARE. 20 | """Ubuntu One Rest Client. 21 | 22 | This is a Rest Client library for using Ubuntu One REST APIs. 23 | For an example of its use see the doctest in example.txt. 24 | 25 | This source is maintained at http://launchpad.net/restful-u1 26 | or you can grabe the source with bzr branch lp:restful-u1 27 | 28 | Have fun. 29 | """ 30 | 31 | from u1rest.files.resources import get_user 32 | 33 | def get_files_user(resource_host="https://edge.one.ubuntu.com", 34 | content_host="https://files.one.ubuntu.com", 35 | use_file_keystore=False): 36 | """The main entry point for the API for files. 37 | 38 | The idea is to get a user which is the client for a specific user. For 39 | more information, refer to u1rest.files.resources.FileStorageUser. 40 | """ 41 | # pylint: disable=W0404 42 | if use_file_keystore: 43 | from u1rest.lib.auth.simpleauth import FileStoreAuthenticator 44 | auth = FileStoreAuthenticator() 45 | else: 46 | from u1rest.lib.auth.gnomeauth import GnomeStoreAuthenticator 47 | auth = GnomeStoreAuthenticator() 48 | 49 | return get_user(resource_host, content_host, auth) 50 | -------------------------------------------------------------------------------- /retrieve/lib/u1rest/lib/auth/simpleauth.py: -------------------------------------------------------------------------------- 1 | #Copyright (C) 2011 by John O'Brien 2 | # 3 | #Permission is hereby granted, free of charge, to any person obtaining a copy 4 | #of this software and associated documentation files (the "Software"), to deal 5 | #in the Software without restriction, including without limitation the rights 6 | #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | #copies of the Software, and to permit persons to whom the Software is 8 | #furnished to do so, subject to the following conditions: 9 | # 10 | #The above copyright notice and this permission notice shall be included in 11 | #all copies or substantial portions of the Software. 12 | # 13 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | #THE SOFTWARE. 20 | """A set of simple authenticators.""" 21 | import pickle 22 | 23 | from u1rest.lib.auth.baseauth import BaseAuthenticator 24 | 25 | class FileStoreAuthenticator(BaseAuthenticator): 26 | """A file based Authenticator.""" 27 | 28 | def __init__(self, filename="credentialfile.txt"): 29 | super(FileStoreAuthenticator, self).__init__() 30 | self.filename = filename 31 | 32 | def load_credentials(self): 33 | """Load the oauth credentials.""" 34 | if self._credentials is None: 35 | with open(self.filename, 'rb') as credfile: 36 | self._credentials = pickle.load(credfile) 37 | 38 | def create_and_save_credentials(self, token_name, email, password): 39 | """Create an file for credentials. 40 | 41 | @param token_name: A Name to give the OAuth Token. 42 | @param email: Your SSO Email. 43 | @param password: Your SSO Password. 44 | """ 45 | self.get_request_token(token_name, email, password) 46 | # save the credentials to a file 47 | with open(self.filename, 'wb') as credfile: 48 | pickle.dump(self._credentials, credfile) 49 | -------------------------------------------------------------------------------- /alert/platform/linux/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Alert Module Linux Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | change_wallpaper() { 9 | local gconftool=`which gconftool-2` 10 | local kdesktop=`which kdesktop` 11 | local xfce=`which xfconf-query` 12 | 13 | if [ -n "$gconftool" ]; then 14 | 15 | wallpaper_command="$gconftool --type string --set /desktop/gnome/background/picture_filename $alert__wallpaper" 16 | wallpaper_command_two="$gconftool --type string --set /desktop/gnome/background/picture_options 'scaled'" 17 | 18 | elif [ -n "$kdesktop" ]; then # untested 19 | 20 | wallpaper_command="$kdesktop KBackgroundIface setWallpaper $alert__wallpaper 8" # 8 = scale 21 | 22 | elif [ -n "$xfce" ]; then # requires xfce 4.6 23 | 24 | wallpaper_command="$xfce -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s $alert__wallpaper" 25 | 26 | fi 27 | 28 | if [ -n "$wallpaper_command" ]; then 29 | 30 | run_as_current_user "$wallpaper_command" 31 | 32 | if [ -n "$wallpaper_command_two" ]; then # couldn't find a way to run both commands as one (gconf complains with &&'s) 33 | 34 | run_as_current_user "$wallpaper_command_two" 35 | 36 | fi 37 | 38 | fi 39 | 40 | } 41 | 42 | alert_user() { 43 | 44 | local dialog_title="Important" 45 | 46 | local zenity=`which zenity` 47 | local kdialog=`which kdialog` 48 | 49 | if [ -n "$zenity" ]; then 50 | 51 | # shall we play with the guy? 52 | # $zenity --question --text "Is this computer yours?" 53 | # if [ $? = 0 ]; then 54 | # TODO: inventar buena talla 55 | # fi 56 | 57 | # alert_command="$zenity --info --text" 58 | alert_command="$zenity --error --title $dialog_title --text" 59 | 60 | elif [ -n "$kdialog" ]; then #untested! 61 | 62 | alert_command="$kdialog --error" 63 | 64 | fi 65 | 66 | if [ -n "$alert_command" ]; then 67 | 68 | if [ `whoami` == 'root' ]; then 69 | DISPLAY=:0 su $logged_user -c "$alert_command \"$alert__alert_message\"" & 70 | else 71 | $alert_command "$alert__alert_message" & 72 | fi 73 | 74 | fi 75 | 76 | } 77 | 78 | 79 | say_message(){ 80 | 81 | local festival=`which festival` 82 | local espeak=`which espeak` 83 | if [ -n "$festival" ]; then 84 | echo "$alert__alert_message" | "$festival" --tts 2> /dev/null & 85 | elif [ -n "$espeak" ]; then 86 | $espeak -ven "$alert__alert_message" & 87 | else 88 | log ' -- Text-to-speech software not found! Please install "festival" or "espeak" via your package manager.' 89 | fi 90 | } 91 | -------------------------------------------------------------------------------- /filesystem/core/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Filesystem Module Base Functions - (c) 2010 Fork Ltd. 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | # trap "echo 'Stopping...'; kill 0" TERM INT 9 | # i=0 10 | 11 | filesystem_log(){ 12 | echo "$1" > /dev/null 13 | # echo "$1" >> filesystem_scan.log 14 | } 15 | 16 | filesystem_append(){ 17 | echo -e "$1" >> "$filesystem__temp_file" 18 | } 19 | 20 | get_filesystem_tree(){ 21 | local dir="$1" 22 | 23 | if [ -f "$filesystem__temp_file" ]; then 24 | echo "" > "$filesystem__temp_file" 25 | fi 26 | 27 | if [ "$filesystem__skip_files" == "y" ]; then 28 | filesystem__search_args="-type d" 29 | fi 30 | 31 | if [ ${dir:(-1)} == "/" ]; then 32 | local dir=${dir%%/} 33 | fi 34 | 35 | traverse_dir "$dir" 36 | } 37 | 38 | traverse_dir(){ 39 | 40 | local dir=`echo "$1" | sed "s/_SPACE_/\\\ /g"` 41 | filesystem_log "-- Traversing ${dir}..." 42 | # let i=$i+1 43 | 44 | local nodes=`find "$dir" $filesystem__search_args -maxdepth 1 -not -empty -not -regex '.*/\..*/..*' -printf "%h/%f___%s\n" | sed -e 1d -e "s/ /_SPACE_/g"` 45 | 46 | if [ -n "$nodes" ]; then 47 | 48 | filesystem_log " -- Found files!" 49 | filesystem_append "" 94 | 95 | fi 96 | 97 | } 98 | -------------------------------------------------------------------------------- /retrieve/lib/hmac: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Implement HMAC functionality on top of the OpenSSL digest functions. 3 | # licensed under the terms of the GNU GPL v2 4 | # Copyright 2007 Victor Lowther 5 | set -o pipefail 6 | 7 | die() { 8 | echo $* 9 | exit 1 10 | } 11 | 12 | check_deps() { 13 | local res=0 14 | while [ $# -ne 0 ]; do 15 | which "${1}" >& /dev/null || { res=1; echo "${1} not found."; } 16 | shift 17 | done 18 | (( res == 0 )) || die "aborting." 19 | } 20 | 21 | # write a byte (passed as hex) to stdout 22 | write_byte() { 23 | # $1 = byte to write 24 | printf "\\x$(printf "%x" ${1})" 25 | } 26 | 27 | # make an hmac pad out of a key. 28 | # this is not the most secure way of doing it, but it is 29 | # the most expedient. 30 | make_hmac_pad() { 31 | # using key in file $1 and byte in $2, create the appropriate hmac pad 32 | # Pad keys out to $3 bytes 33 | # if key is longer than $3, use hash $4 to hash the key first. 34 | local x y a size remainder oifs 35 | # [[ -f ${1} ]] || die "${1} does not exist when making hmac pads." 36 | (( remainder = ${3} )) 37 | 38 | # in case someone else was messing with IFS. 39 | for x in $(echo -n "${1}" | od -v -t u1 | cut -b 9-); 40 | do 41 | write_byte $((${x} ^ ${2})) 42 | (( remainder -= 1 )) 43 | done 44 | for ((y=0; remainder - y ;y++)); do 45 | write_byte $((0 ^ ${2})) 46 | done 47 | } 48 | 49 | # utility functions for making hmac pads 50 | hmac_ipad() { 51 | make_hmac_pad "${1}" 0x36 ${2} "${3}" 52 | } 53 | 54 | hmac_opad() { 55 | make_hmac_pad "${1}" 0x5c ${2} "${3}" 56 | } 57 | 58 | # hmac something 59 | do_hmac() { 60 | # $1 = algo to use. Must be one that openssl knows about 61 | # $2 = keyfile to use 62 | # $3 = file to hash. uses stdin if none is given. 63 | # accepts input on stdin, leaves it on stdout. 64 | # Output is binary, if you want something else pipe it accordingly. 65 | local blocklen keysize x 66 | case "${1}" in 67 | sha) blocklen=64 ;; 68 | sha1) blocklen=64 ;; 69 | md5) blocklen=64 ;; 70 | md4) blocklen=64 ;; 71 | sha256) blocklen=64 ;; 72 | sha512) blocklen=128 ;; 73 | *) die "Unknown hash ${1} passed to hmac!" ;; 74 | esac 75 | keysize="$(echo -n "$2" | wc -c)" 76 | (( ${keysize%%[!0-9 ]*} > blocklen )) && \ 77 | die "Prehashing large-size keys not implemented yet. Sorry." 78 | cat <(hmac_ipad "${2}" ${blocklen} "${1}") "${3:--}" | openssl dgst "-${1}" -binary | \ 79 | cat <(hmac_opad "${2}" ${blocklen} "${1}") - | openssl dgst "-${1}" -binary 80 | } 81 | 82 | [[ ${1} ]] || die "Must pass the name of the hash function to use to ${0}". 83 | # [[ -f ${2} ]] || die "Must pass file containing the secret to $0" 84 | 85 | check_deps od openssl 86 | do_hmac "${@}" 87 | -------------------------------------------------------------------------------- /system/platform/windows/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey System Module Windows Functions - by Carlos Yaconi H. 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | wmic_call(){ 9 | echo "$1" | wmic 2> /dev/null | grep -v 'wmic:' | grep -v "^$" | tail -1 10 | rm -f "$base_path/TempWmicBatchFile.bat" &> /dev/null 11 | } 12 | 13 | #get_os_info(){ 14 | # os_version=$(wmic_call "os get version") 15 | #} 16 | 17 | get_system_ids(){ 18 | system__serial_number=$(wmic_call "bios get serialnumber") 19 | # serial_number=$(wmic_call "path win32_computersystemproduct get identifyingnumber" | awk 'NR==2 {print $1}') 20 | system__uuid=$(wmic_call "path win32_computersystemproduct get uuid") 21 | } 22 | 23 | get_mb_info(){ 24 | system__mb_vendor=$(wmic_call "baseboard get manufacturer") 25 | system__mb_serial=$(wmic_call "baseboard get serialnumber") 26 | system__mb_model=$(wmic_call "baseboard get product") 27 | system__mb_version=$(wmic_call "baseboard get version") 28 | } 29 | 30 | get_bios_info(){ 31 | system__bios_vendor=$(wmic_call "bios get Manufacturer") 32 | system__bios_version=$(wmic_call "bios get SMBIOSBIOSVersion") 33 | } 34 | 35 | get_cpu_info(){ 36 | system__cpu_model=$(wmic_call "cpu get name") 37 | system__cpu_speed=$(wmic_call "cpu get MaxClockSpeed") 38 | system__cpu_cores=$(wmic_call "cpu get NumberOfCores") 39 | # cpu_info="1_name=${cpu_name}#1_speed=${cpu_speed}#1_cores=${cpu_cores}__#" 40 | } 41 | 42 | get_memory_info(){ 43 | local ram_in_bytes=$(wmic_call "os get TotalVisibleMemorySize") 44 | system__ram_size=$(($ram_in_bytes/1024)) 45 | system__ram_modules=$(cscript "$module_platform_path\\ramcheck.vbs" | grep "Bank Label" | wc -l | sed "s/ //g") 46 | } 47 | 48 | get_network_interfaces(){ 49 | 50 | local nic_list=$(echo "nic list full" | wmic 2> /dev/null | grep "NetConnectionID=." -B5) 51 | 52 | local last_mac="" 53 | local id=0 54 | while read line; do 55 | 56 | local key=$(echo "$line" | cut -d '=' -f1) 57 | local value=$(echo "$line" | cut -d '=' -f2) 58 | 59 | [ "$value" == "$last_mac" ] && continue # skip duplicates 60 | 61 | if [ "$key" == "MACAddress" ]; then 62 | 63 | id=$(($id+1)) 64 | 65 | local mac_address="$value" 66 | store_network_interface_value "nic_${id}" "mac_address" "$mac_address" 67 | 68 | local ip_address=$(get_ip_address "$mac_address") 69 | local netmask=$(get_netmask "$mac_address") 70 | local gateway_ip=$(get_gateway_ip "$mac_address") 71 | 72 | store_network_interface_value "nic_${id}" "ip_address" "$ip_address" 73 | store_network_interface_value "nic_${id}" "netmask" "$netmask" 74 | store_network_interface_value "nic_${id}" "gateway_ip" "$gateway_ip" 75 | 76 | elif [ "$key" == "Manufacturer" ]; then 77 | store_network_interface_value "nic_${id}" "vendor" "$value" 78 | elif [ "$key" == "Name" ]; then 79 | store_network_interface_value "nic_${id}" "model" "$value" 80 | 81 | if [ -n "$(echo "$value" | egrep -i 'wireless|wifi|802.11' 2> /dev/null)" ]; then 82 | store_network_interface_value "nic_${id}" "interface_type" "Wireless" 83 | fi 84 | 85 | fi 86 | 87 | last_mac="$mac_address" 88 | 89 | done <<< "$nic_list" 90 | } 91 | 92 | get_storage_devices(){ 93 | return 0 94 | } 95 | -------------------------------------------------------------------------------- /retrieve/lib/u1rest/files/content.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | #Copyright (C) 2011 by John O'Brien 3 | # 4 | #Permission is hereby granted, free of charge, to any person obtaining a copy 5 | #of this software and associated documentation files (the "Software"), to deal 6 | #in the Software without restriction, including without limitation the rights 7 | #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | #copies of the Software, and to permit persons to whom the Software is 9 | #furnished to do so, subject to the following conditions: 10 | # 11 | #The above copyright notice and this permission notice shall be included in 12 | #all copies or substantial portions of the Software. 13 | # 14 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | #THE SOFTWARE. 21 | """Special cleint for uploading and downloading files.""" 22 | 23 | import httplib, urlparse 24 | import urllib2 25 | import os 26 | import errno 27 | import json 28 | import mimetypes 29 | 30 | from u1rest.lib.client import BaseClient 31 | 32 | 33 | class ContentClient(BaseClient): 34 | """A client used to handle file content Requests.""" 35 | 36 | #modify this to change the destination folder for downloads 37 | download_directory = "content" 38 | 39 | def get_or_make_download_path(self, path, download_directory=None): 40 | """Create local directories for the downloaded files.""" 41 | if download_directory is None: 42 | path = os.path.join(self.download_directory, path) 43 | else: 44 | _, filename = os.path.split(path) 45 | path = os.path.join(download_directory, filename) 46 | subdir, _ = os.path.split(path) 47 | try: 48 | os.makedirs(subdir) 49 | except OSError as exc: 50 | if exc.errno == errno.EEXIST: 51 | pass 52 | else: raise 53 | return path 54 | 55 | def get_file(self, path, download_directory=None): 56 | """Download a file from an http get.""" 57 | file_path = self.get_or_make_download_path(path, download_directory) 58 | path = 'content/' + path.lstrip("/") 59 | url = self.get_url_from_path(path, None) 60 | request = self._get_authenticated_request(url, None) 61 | opener = urllib2.build_opener(urllib2.BaseHandler) 62 | response = opener.open(request) 63 | block_sz = 8192 64 | with open(file_path, 'w') as new_file: 65 | while True: 66 | read_bytes = response.read(block_sz) 67 | if not read_bytes: 68 | break 69 | new_file.write(read_bytes) 70 | 71 | def put_file(self, filename, path): 72 | """Upload a file with PUT.""" 73 | path = 'content/' + path.lstrip("/") 74 | url = self.get_url_from_path(path, None) 75 | return self._upload_file(filename, url) 76 | 77 | def _upload_file(self, filename, url): 78 | """Stream a file as an upload.""" 79 | auth_header = self.auth.get_auth_headers(url, None, 'PUT') 80 | parsed_url = urlparse.urlparse(url) 81 | size = os.path.getsize(filename) 82 | content_type = mimetypes.guess_type(filename)[0] 83 | connection = httplib.HTTPSConnection(parsed_url.hostname, 84 | parsed_url.port) 85 | connection.putrequest('PUT', parsed_url.path) 86 | connection.putheader('User-Agent', 'restful-u1') 87 | connection.putheader('Content-Length', size) 88 | connection.putheader('Connection', 'close') 89 | connection.putheader('Content-Type', 90 | content_type or 'application/octet-stream') 91 | connection.putheader('Authorization', auth_header['Authorization']) 92 | connection.endheaders() 93 | transferred = 0 94 | with open(filename, 'rb') as upload_file: 95 | while True: 96 | bytes_read = upload_file.read(4096) 97 | if not bytes_read: 98 | break 99 | transferred += len(bytes_read) 100 | connection.send(bytes_read) 101 | connection.send('0\r\n\r\n') 102 | resp = connection.getresponse() 103 | if transferred != size: 104 | raise Exception("Transferred bytes do not equal file size.") 105 | if resp.status < 200 or resp.status > 299: 106 | resp.read() 107 | raise Exception(resp.status, resp.reason) 108 | else: 109 | return json.loads(resp.read()) 110 | -------------------------------------------------------------------------------- /system/platform/linux/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey System Module Linux Functions - by Carlos Yaconi H. 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | # system_udi=$(hal-find-by-property --key info.product --string Computer) 9 | 10 | #get_from_hal(){ 11 | # /usr/bin/hal-get-property --udi $system_udi --key $1 12 | #} 13 | 14 | get_system_full_info(){ 15 | system__full_info=$(lshw 2> /dev/null) 16 | } 17 | 18 | get_system_ids(){ 19 | [ -z "$system__full_info" ] && get_system_full_info 20 | system__uuid=$(echo "$system__full_info" | head -10 | grep "uuid" | sed "s/.*uuid=\(.*\)/\1/") 21 | system__serial_number=$(echo "$system__full_info" | head -10 | grep serial | head -1 | awk -F ': ' '{print $2}') 22 | } 23 | 24 | get_mb_info(){ 25 | system__mb_vendor=$(echo "$system__full_info" | grep Motherboard -A5 | grep vendor | awk -F ': ' '{print $2}') 26 | system__mb_serial=$(echo "$system__full_info" | grep Motherboard -A5 | grep serial | awk -F ': ' '{print $2}') 27 | system__mb_model=$(echo "$system__full_info" | grep Motherboard -A5 | grep product | awk -F ': ' '{print $2}') 28 | system__mb_version=$(echo "$system__full_info" | grep Motherboard -A5 | grep version | awk -F ': ' '{print $2}') 29 | } 30 | 31 | get_bios_info(){ 32 | system__bios_vendor=$(echo "$system__full_info" | grep -i "\-firmware" -A4 | grep vendor | awk -F ': ' '{print $2}') 33 | system__bios_version=$(echo "$system__full_info" | grep -i "\-firmware" -A4 | grep version | awk -F ': ' '{print $2}') 34 | } 35 | 36 | get_cpu_info(){ 37 | local cpu_info=$(cat /proc/cpuinfo) 38 | 39 | system__cpu_model=$(echo -e "$cpu_info" | grep "model name" | tail -1 | sed 's/.*: //') 40 | system__cpu_speed=$(echo -e "$cpu_info" | grep "cpu MHz" | tail -1 | sed 's/.*: //') 41 | system__cpu_cores=$(echo -e "$cpu_info" | grep "processor" | wc -l) 42 | } 43 | 44 | get_memory_info(){ 45 | local mem_in_kb=$(cat /proc/meminfo | grep "MemTotal" | sed 's/.*:[[:space:]]*\(.*\) .*/\1/') 46 | 47 | system__ram_size=$(($mem_in_kb/1024)) 48 | system__ram_modules=$(dmidecode --type 17 | grep Size | grep -v "No Module" | wc -l) 49 | } 50 | 51 | get_storage_devices(){ 52 | 53 | # hwinfo --disk --cdrom 2> /dev/null | grep Class -A8 | while read line; do 54 | 55 | # key=$(echo "$line" | cut -d":" -f1) 56 | # val=$(echo "$line" | cut -d":" -f2) 57 | 58 | # echo "key: $key" 59 | # echo "val: $val" 60 | 61 | # done 62 | 63 | local disks_path="/dev/disk/by-id" 64 | local last_path="" 65 | 66 | for disk in $(stat -c "%n" ${disks_path}/* | grep -v "\-part[1-9]"); do 67 | 68 | local path=$(readlink -f "$disk") 69 | [ "$path" == "$last_path" ] && continue 70 | 71 | local name=$(basename "$path") 72 | store_storage_device_value "$name" 'name' "$name" 73 | 74 | local full_name=$(echo "$disk" | sed "s/.*\/\([^\/]*\)$/\1/g") 75 | local interface=$(echo "$full_name" | cut -d"-" -f1) 76 | store_storage_device_value "$name" 'interface' "$interface" 77 | 78 | # cdroms are owned by the group 'cdrom' 79 | if [ "$(stat -c "%G" "$path")" == "cdrom" ]; then 80 | store_storage_device_value "$name" 'storage_type' 'CDROM' 81 | elif [[ "$interface" =~ "usb" ]]; then 82 | store_storage_device_value "$name" 'storage_type' 'Removable' 83 | else 84 | store_storage_device_value "$name" 'storage_type' 'Fixed' 85 | fi 86 | 87 | local model=$(echo "$full_name" | sed "s/.*-\(.*\)_.*/\1/") 88 | store_storage_device_value "$name" 'model' "$model" 89 | 90 | local serial_number=$(echo "$full_name" | sed "s/.*_\(.*\)/\1/") 91 | store_storage_device_value "$name" 'serial_number' "$serial_number" 92 | 93 | last_path="$path" 94 | done 95 | 96 | } 97 | 98 | 99 | get_network_interfaces(){ 100 | for device_name in /sys/class/net/* ; do 101 | [ -e $device_name/device ] && { 102 | 103 | local name=$(echo "$device_name" | sed "s/.*\/\(.*\)$/\1/") 104 | store_network_interface_value $name 'name' "$name" 105 | 106 | local interface_type="Wired" 107 | [ -n "$(cat /proc/net/wireless | grep "$name" 2> /dev/null)" ] && interface_type="Wireless" 108 | store_network_interface_value $name 'interface_type' "$interface_type" 109 | 110 | local pci_slot=$(cat $device_name/device/uevent | grep PCI_SLOT | cut -f2- -d":") 111 | local vendor=$(lspci -v | grep $pci_slot -A1 | grep 'Subsystem' | cut -f2- -d" ") 112 | 113 | store_network_interface_value $name 'vendor' "$vendor" 114 | 115 | local mac_address=$(cat $device_name/address) 116 | store_network_interface_value $name 'mac_address' "$mac_address" 117 | 118 | local ip_address=$(get_ip_address $name) 119 | store_network_interface_value $name 'ip_address' "$ip_address" 120 | 121 | local gateway_ip=$(get_gateway_ip $name) 122 | store_network_interface_value $name 'gateway_ip' "$gateway_ip" 123 | 124 | local netmask=$(get_netmask $name) 125 | store_network_interface_value $name 'netmask' "$netmask" 126 | 127 | } 128 | done 129 | } 130 | -------------------------------------------------------------------------------- /retrieve/lib/u1rest/lib/client.py: -------------------------------------------------------------------------------- 1 | #Copyright (C) 2011 by John O'Brien 2 | # 3 | #Permission is hereby granted, free of charge, to any person obtaining a copy 4 | #of this software and associated documentation files (the "Software"), to deal 5 | #in the Software without restriction, including without limitation the rights 6 | #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | #copies of the Software, and to permit persons to whom the Software is 8 | #furnished to do so, subject to the following conditions: 9 | # 10 | #The above copyright notice and this permission notice shall be included in 11 | #all copies or substantial portions of the Software. 12 | # 13 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | #THE SOFTWARE. 20 | """Client classes used by REST Client.""" 21 | #pylint: disable=R0903 22 | import urllib 23 | import urllib2 24 | import urlparse 25 | import json 26 | 27 | 28 | 29 | class BaseClient(object): 30 | """Base client to provide common functionaility.""" 31 | # pylint: disable=R0201 32 | def __init__(self, http_host, auth): 33 | """Ubuntu One RESTful Client.""" 34 | self.auth = auth 35 | self.http_host = http_host 36 | 37 | def get_url_from_path(self, path, params=None): 38 | """Using the path, parameters and host, create a URL. 39 | 40 | @param path: The url path 41 | @param params: A dict of parameters to be used as a query string. 42 | """ 43 | path = urllib.quote(path.encode('utf-8'), '~/[]()') 44 | if params: 45 | path = "%s?%s" % (path, urllib.urlencode(params)) 46 | return urlparse.urljoin(self.http_host, path) 47 | 48 | def _get_authenticated_request(self, url, params=None, method='GET', 49 | data=None): 50 | """Helper to get a urllib2.Request object with the auth headers.""" 51 | headers = self.auth.get_auth_headers(url, params, method) 52 | request = urllib2.Request(url, data, headers) 53 | request.get_method = lambda: method 54 | return request 55 | 56 | def _handle_request(self, request): 57 | """Helper to handle urllib2.Resquest object.""" 58 | opener = urllib2.build_opener(urllib2.BaseHandler) 59 | try: 60 | return opener.open(request, timeout=30) 61 | except urllib2.URLError, ex: 62 | raise Exception( 63 | "Error opening %s\n%s" % (request.get_full_url(), ex.message)) 64 | 65 | 66 | class ResourceClient(BaseClient): 67 | """A client used to handle authenticated REST Requests.""" 68 | 69 | def __init__(self, http_host, auth, base_api_path): 70 | super(ResourceClient, self).__init__(http_host, auth) 71 | self.base_path = base_api_path 72 | 73 | def process_request(self, path, method, params=None, data=None): 74 | """Process a REST request. 75 | 76 | This is specifically for JSON request/responses. The data, for PUT must 77 | be serializable by JSON. The http responses must be JSON serializable as 78 | well. 79 | """ 80 | url = self.get_url_from_path(path, params) 81 | if method == 'PUT' and data: 82 | data = json.dumps(data) 83 | else: 84 | data = None 85 | request = self._get_authenticated_request(url, params, method, data) 86 | request.add_header('Content-Type', 'application/json') 87 | response = self._handle_request(request) 88 | content = response.read() 89 | try: 90 | return json.loads(content) 91 | except ValueError: 92 | raise Exception("JSON could not be decoded.\n%s\n%s" % (url, 93 | content)) 94 | 95 | def _get_path(self, path): 96 | """Join the path with the API base path. 97 | 98 | This also removes trailing slashes wish are not part of the resource. 99 | """ 100 | if path: 101 | return self.base_path + '/' + path.lstrip("/") 102 | return self.base_path 103 | 104 | def get_resource(self, path="", params=None): 105 | """Get a Resource.""" 106 | return self.process_request( 107 | self._get_path(path), 'GET', params=params) 108 | 109 | def delete_resource(self, path, params=None): 110 | """Delete a Resource.""" 111 | return self.process_request( 112 | self._get_path(path), 'DELETE', params=params) 113 | 114 | def put_resource(self, path, data=None, params=None): 115 | """PUT a Resource.""" 116 | return self.process_request( 117 | self._get_path(path), 'PUT', params=params, data=data) 118 | -------------------------------------------------------------------------------- /system/platform/mac/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey System Module Mac Functions - by Carlos Yaconi H. 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | #get_os_info(){ 9 | # os_info=`system_profiler SPSoftwareDataType` 10 | # os_version=`echo "$os_info" | grep "System Version" | sed 's/.*: \(.*\)/\1/'` 11 | # kernel_version=`echo "$os_info" | grep "Kernel Version" | sed 's/.*: \(.*\)/\1/'` 12 | #} 13 | 14 | get_system_ids(){ 15 | local hw_info=$(system_profiler SPHardwareDataType) 16 | system__serial_number=$(echo "$hw_info" | grep "Serial Number" | sed 's/.*: \(.*\)/\1/') 17 | 18 | # uuid=`echo "$hw_info" | grep "UUID" | sed 's/.*: \(.*\)/\1/'` 19 | system__uuid=$(ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { print $3; }' | sed 's/"//g') 20 | } 21 | 22 | get_bios_info(){ 23 | local bios_info=$(system_profiler SPHardwareDataType) 24 | 25 | system__bios_vendor="Apple" 26 | system__bios_version=$(echo "$bios_info" | grep "Boot" | sed 's/.*: \(.*\)/\1/') 27 | } 28 | 29 | get_cpu_info(){ 30 | local cpu_info=$(system_profiler SPHardwareDataType) 31 | local cpu_speed_in_ghz=$(echo "$cpu_info" | grep "Processor Speed" | sed 's/.*: \(.*\) .*/\1/' | tr ',' '.') 32 | 33 | system__cpu_model=$(echo "$cpu_info" | grep "Processor Name" | sed 's/.*: \(.*\)/\1/') 34 | system__cpu_speed=$(echo "$cpu_speed_in_ghz * 1000" | bc) 35 | system__cpu_cores=$(echo "$cpu_info" | grep "Total Number Of Cores" | sed 's/.*: \(.*\)/\1/') 36 | } 37 | 38 | get_memory_info(){ 39 | 40 | local mem_full_info=$(system_profiler SPMemoryDataType) 41 | 42 | system__ram_size=$(echo "$mem_full_info" | awk 'BEGIN { 43 | TOTAL_MEM = 0 44 | } 45 | /Size: /{ TOTAL_MEM=TOTAL_MEM+$2 } 46 | 47 | END { 48 | print TOTAL_MEM*1024 49 | }') 50 | 51 | system__ram_modules=$(echo "$mem_full_info" | grep "BANK" | wc -l | awk '{print $1}') 52 | 53 | } 54 | 55 | get_ioreg_vendor_and_model(){ 56 | local filter_regex="$1" 57 | ioreg -l | egrep "IOVendor|IOModel" | egrep $filter_regex -B1 | sed 's/.*"\(.*\)"$/\1/' 58 | } 59 | 60 | get_network_interfaces(){ 61 | 62 | local nic_list=$(networksetup -listnetworkserviceorder 2> /dev/null | grep -v Bluetooth | grep -v DataTransfer | grep -v usbmodem | grep Hardware) 63 | 64 | while read line; do 65 | 66 | local human_name=$(echo "$line" | cut -d',' -f1 | awk -F ': ' '{print $2}') 67 | local name=$(echo "$line" | sed "s/.* \(.*\))$/\1/" | sed "s/([^a-z\-]*)//g") 68 | 69 | if [[ "$human_name" =~ "Ethernet" ]]; then 70 | 71 | local interface_type="Wired" 72 | local model_and_vendor=$(get_ioreg_vendor_and_model "Ethernet|Gigabit" | tr "\n" ";") 73 | 74 | while read output; do 75 | local vendor=$(echo "$output" | cut -d";" -f1) 76 | local model=$(echo "$output" | cut -d";" -f2) 77 | done <<< "$model_and_vendor" 78 | 79 | elif [[ "$human_name" =~ "AirPort" || "$human_name" =~ "Wi-Fi" ]]; then 80 | 81 | local interface_type="Wireless" 82 | local model_and_vendor=$(get_ioreg_vendor_and_model "802.11" | tr "\n" ";") 83 | 84 | while read output; do 85 | local vendor=$(echo "$output" | cut -d";" -f1) 86 | local model=$(echo "$output" | cut -d";" -f2) 87 | done <<< "$model_and_vendor" 88 | 89 | elif [[ "$human_name" =~ "FireWire" ]]; then 90 | 91 | continue 92 | local interface_type="Firewire" 93 | local vendor="Apple" 94 | local model="fw+" 95 | 96 | fi 97 | 98 | store_network_interface_value $name 'name' "$human_name" 99 | 100 | store_network_interface_value $name 'interface_type' "$interface_type" 101 | store_network_interface_value $name 'vendor' "$vendor" 102 | store_network_interface_value $name 'model' "$model" 103 | 104 | local mac_address=$(get_mac_address $name) 105 | store_network_interface_value $name 'mac_address' "$mac_address" 106 | 107 | local ip_address=$(get_ip_address $name) 108 | store_network_interface_value $name 'ip_address' "$ip_address" 109 | 110 | local gateway_ip=$(get_gateway_ip $name) 111 | store_network_interface_value $name 'gateway_ip' "$gateway_ip" 112 | 113 | local netmask=$(get_netmask $name) 114 | store_network_interface_value $name 'netmask' "$netmask" 115 | 116 | done <<< "$nic_list" 117 | } 118 | 119 | get_storage_devices(){ 120 | 121 | for path in $(find /dev/disk* | grep -v "s[0-9]$"); do 122 | 123 | local name=$(echo "$path" | sed "s/.*\/\(.*\)$/\1/") 124 | store_storage_device_value "$name" 'name' "$name" 125 | 126 | local interface=$(diskutil info "$name" | grep "Protocol" | awk '{print $2}') 127 | store_storage_device_value "$name" 'interface' "$interface" 128 | 129 | # local model=$(diskutil info "$name" | grep "Device" | grep Name | sed "s/.* //") 130 | local model=$(system_profiler SPSerialATADataType | grep "${name}$" -B10 | grep Model | awk -F ': ' '{print $2}') 131 | store_storage_device_value "$name" 'model' "$model" 132 | 133 | local serial_number=$(system_profiler SPSerialATADataType | grep "${name}$" -B10 | grep Serial | awk -F ': ' '{print $2}') 134 | store_storage_device_value "$name" 'serial_number' "$serial_number" 135 | 136 | local capacity=$(system_profiler SPSerialATADataType | grep "${name}$" -B10 | grep Capacity | awk -F ': ' '{print $2}' | sed "s/[^0-9\.]//g") 137 | store_storage_device_value "$name" 'capacity' "$capacity" 138 | 139 | # local free_space=$(system_profiler SPSerialATADataType | egrep -i "${name}|available" | sed "s/[^0-9\.]//g" | awk '{sum += $1} END {print sum}') 140 | # local used_space=$(let $capacity-$free_space) 141 | # store_storage_device_value "$name" 'used_space' "$used_space" 142 | 143 | done 144 | 145 | } 146 | -------------------------------------------------------------------------------- /retrieve/lib/u1rest/lib/auth/baseauth.py: -------------------------------------------------------------------------------- 1 | #Copyright (C) 2011 by John O'Brien 2 | # 3 | #Permission is hereby granted, free of charge, to any person obtaining a copy 4 | #of this software and associated documentation files (the "Software"), to deal 5 | #in the Software without restriction, including without limitation the rights 6 | #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | #copies of the Software, and to permit persons to whom the Software is 8 | #furnished to do so, subject to the following conditions: 9 | # 10 | #The above copyright notice and this permission notice shall be included in 11 | #all copies or substantial portions of the Software. 12 | # 13 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | #THE SOFTWARE. 20 | """Authentication Library for authorizing clients.""" 21 | 22 | from oauth import oauth 23 | import json, urllib2, urllib 24 | from time import sleep 25 | # pylint: disable=C0301 26 | # URLS used for SSO and Ubuntu One OAuth token creation and authorization 27 | REQUEST_URL = "https://login.ubuntu.com/api/1.0/authentications?ws.op=authenticate&token_name=Ubuntu%%20One%%20@%%20%(token_name)s" 28 | AUTHORIZE_URL = 'https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/%(email)s' 29 | TEST_URL = "https://one.ubuntu.com/api/account/" 30 | # pylint: enable=C0301 31 | 32 | class BaseAuthenticator(object): 33 | """A base OAuthAuthenticator.""" 34 | 35 | _credentials = None 36 | 37 | def get_consumer_and_token(self): 38 | """Get consumer and token from credentials.""" 39 | if self._credentials is None: 40 | self.load_credentials() 41 | consumer = oauth.OAuthConsumer(self._credentials['consumer_key'], 42 | self._credentials['consumer_secret']) 43 | token = oauth.OAuthToken(self._credentials['token'], 44 | self._credentials['token_secret']) 45 | return consumer, token 46 | 47 | def get_auth_headers(self, url, params, http_method): 48 | """Get authentication headers to be sent with the request. 49 | 50 | @param url: The URL being requested. 51 | @param params: A {dict} of quesry string parameters 52 | @param http_method: The HTTP Method being used. 53 | """ 54 | consumer, token = self.get_consumer_and_token() 55 | oauth_req = oauth.OAuthRequest.from_consumer_and_token( 56 | http_url=url, 57 | http_method=http_method, 58 | token=token, 59 | oauth_consumer=consumer, 60 | parameters=params) 61 | # using PLAINTEXT, because HMAC doesn't work for all urls 62 | signature_method = oauth.OAuthSignatureMethod_PLAINTEXT() 63 | oauth_req.sign_request(signature_method, consumer, token) 64 | return oauth_req.to_header() 65 | 66 | def load_credentials(self): 67 | """Load the credentials. 68 | 69 | To be overridden by subclasses. 70 | """ 71 | raise NotImplementedError("load_credentials has not been implemented.") 72 | 73 | def simple_signed_get_request(self, url): 74 | """Handle a simple signed request. 75 | 76 | @param url: The URL to sign and get. 77 | """ 78 | consumer, token = self.get_consumer_and_token() 79 | req = oauth.OAuthRequest.from_consumer_and_token( 80 | consumer, 81 | token=token, 82 | http_url=url) 83 | req.sign_request(oauth.OAuthSignatureMethod_HMAC_SHA1(), 84 | consumer, token) 85 | return urllib.urlopen(req.to_url()) 86 | 87 | def _authorize_credentials(self, email): 88 | """Authorize the OAuth SSO Request Token.""" 89 | url = AUTHORIZE_URL % dict(email=email) 90 | response = self.simple_signed_get_request(url) 91 | if response.code == 200: 92 | print "Token Succesfully Authorized" 93 | else: 94 | raise Exception( 95 | "There was a problem Authorizing the Token\n%s" % response.read) 96 | 97 | def _test_credentials(self): 98 | """Test the OAuth token against Ubuntu One.""" 99 | response = self.simple_signed_get_request(TEST_URL) 100 | if response.code == 200: 101 | print "Auth token tested OK" 102 | else: 103 | raise Exception( 104 | "There was a problem Testing the Token.\n%s" % response.read) 105 | 106 | def get_request_token(self, token_name, email, password): 107 | """Get an OAuth request token from SSO. 108 | 109 | @param token_name: A Name to give the OAuth Token. 110 | @param email: Your SSO Email. 111 | @param password: Your SSO Password. 112 | """ 113 | password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() 114 | top_level_url = "https://login.ubuntu.com/api/1.0" 115 | password_mgr.add_password(None, top_level_url, email, password) 116 | handler = urllib2.HTTPBasicAuthHandler(password_mgr) 117 | opener = urllib2.build_opener(handler) 118 | response = opener.open(REQUEST_URL % dict(token_name=token_name)) 119 | req_token = response.read() 120 | self._credentials = json.loads(req_token) 121 | # authorize the request token 122 | self._authorize_credentials(email) 123 | # give a moment for some SSO -> U1 chatter 124 | sleep(1) 125 | self._test_credentials() 126 | -------------------------------------------------------------------------------- /retrieve/lib/s3: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # basic amazon s3 operations 3 | # Licensed under the terms of the GNU GPL v2 4 | # Copyright 2007 Victor Lowther 5 | set -o pipefail 6 | 7 | this_path="$(dirname $0)" 8 | 9 | # print a message and bail 10 | die() { 11 | echo $* 12 | exit 1 13 | } 14 | 15 | # check to see if the variable name passed exists and holds a value. 16 | # Die if it does not. 17 | check_or_die() { 18 | [[ ${!1} ]] || die "Environment variable ${1} is not set." 19 | } 20 | 21 | # check to see if we have all the needed S3 variables defined. 22 | # Bail if we do not. 23 | check_s3() { 24 | local sak x 25 | for x in S3_ACCESS_KEY_ID S3_SECRET_ACCESS_KEY; do 26 | check_or_die ${x}; 27 | done 28 | # [[ -f ${S3_SECRET_ACCESS_KEY} ]] || die "S3_SECRET_ACCESS_KEY must point to a file!" 29 | local sak="$(echo -n "${S3_SECRET_ACCESS_KEY}" | wc -c)" 30 | [ $sak -ne 40 ] && die "S3 Secret Access Key is not exactly 40 bytes long. Please fix it." 31 | } 32 | # check to see if our external dependencies exist 33 | check_dep() { 34 | local res=0 35 | while [[ $# -ne 0 ]]; do 36 | which "${1}" >& /dev/null || { res=1; echo "${1} not found."; } 37 | shift 38 | done 39 | (( res == 0 )) || die "aborting." 40 | } 41 | 42 | check_deps() { 43 | check_dep openssl date cat grep curl 44 | check_s3 45 | } 46 | 47 | urlenc() { 48 | # $1 = string to url encode 49 | # output is on stdout 50 | # we don't urlencode everything, just enough stuff. 51 | echo -n "${1}" | 52 | sed 's/%/%25/g 53 | s/ /%20/g 54 | s/#/%23/g 55 | s/\$/%24/g 56 | s/\&/%26/g 57 | s/+/%2b/g 58 | s/,/%2c/g 59 | s/:/%3a/g 60 | s/;/%3b/g 61 | s/?/%3f/g 62 | s/@/%40/g 63 | s/ /%09/g' 64 | } 65 | 66 | xmldec() { 67 | # no parameters. 68 | # accept input on stdin, put it on stdout. 69 | # patches accepted to get more stuff 70 | sed 's/\"/\"/g 71 | s/\&/\&/g 72 | s/\<//g' 74 | } 75 | 76 | ## basic S3 functionality. x-amz-header functionality is not implemented. 77 | # make an S3 signature string, which will be output on stdout. 78 | s3_signature_string() { 79 | # $1 = HTTP verb 80 | # $2 = date string, must be in UTC 81 | # $3 = bucket name, if any 82 | # $4 = resource path, if any 83 | # $5 = content md5, if any 84 | # $6 = content MIME type, if any 85 | # $7 = canonicalized headers, if any 86 | # signature string will be output on stdout 87 | local verr="Must pass a verb to s3_signature_string!" 88 | local verb="${1:?verr}" 89 | local bucket="${3}" 90 | local resource="${4}" 91 | local derr="Must pass a date to s3_signature_string!" 92 | local date="${2:?derr}" 93 | local mime="${6}" 94 | local md5="${5}" 95 | local headers="${7}" 96 | 97 | printf "%s\n%s\n%s\n%s\n%s%s%s" \ 98 | "${verb}" "${md5}" "${mime}" "${date}" \ 99 | "${headers}" "${bucket}" "${resource}" | \ 100 | "${this_path}/hmac" sha1 "${S3_SECRET_ACCESS_KEY}" | openssl base64 -e -a 101 | } 102 | 103 | # cheesy, but it is the best way to have multiple headers. 104 | curl_headers() { 105 | # each arg passed will be output on its own line 106 | local parms=$# 107 | for ((;$#;)); do 108 | echo "header = \"${1}\"" 109 | shift 110 | done 111 | } 112 | 113 | s3_curl() { 114 | # invoke curl to do all the heavy HTTP lifting 115 | # $1 = method (one of GET, PUT, or DELETE. HEAD is not handled yet.) 116 | # $2 = remote bucket. 117 | # $3 = remote name 118 | # $4 = local name. 119 | local bucket remote date sig md5 arg inout headers 120 | # header handling is kinda fugly, but it works. 121 | bucket="${2:+/${2}}/" # slashify the bucket 122 | remote="$(urlenc "${3}")" # if you don't, strange things may happen. 123 | stdopts="--connect-timeout 10 --fail --silent" 124 | [[ $CURL_S3_DEBUG == true ]] && stdopts="${stdopts} --show-error --fail" 125 | 126 | # [ "$1" == 'PUT' ] && stdopts="${stdopts} --progress-bar" 127 | 128 | case "${1}" in 129 | GET) 130 | arg="-o" inout="${4:--}" # stdout if no $4 131 | ;; 132 | PUT) 133 | [[ ${2} ]] || die "PUT can has bucket?" 134 | if [[ ! ${3} ]]; then 135 | arg="-X PUT" 136 | headers[${#headers[@]}]="Content-Length: 0" 137 | elif [[ -f ${4} ]]; then 138 | md5="$(openssl dgst -md5 -binary "${4}"|openssl base64 -e -a)" 139 | arg="-T" inout="${4}" 140 | headers[${#headers[@]}]="Expect: 100-continue" 141 | else 142 | die "Cannot write non-existing file ${4}" 143 | fi 144 | ;; 145 | DELETE) 146 | arg="-X DELETE" 147 | ;; 148 | HEAD) 149 | arg="-I" 150 | ;; 151 | *) 152 | die "Unknown verb ${1}. It probably would not have worked anyways." 153 | ;; 154 | esac 155 | 156 | date="$(TZ=UTC date '+%a, %e %b %Y %H:%M:%S %z')" 157 | sig=$(s3_signature_string ${1} "${date}" "${bucket}" "${remote}" "${md5}") 158 | 159 | headers[${#headers[@]}]="Authorization: AWS ${S3_ACCESS_KEY_ID}:${sig}" 160 | headers[${#headers[@]}]="Date: ${date}" 161 | [[ ${md5} ]] && headers[${#headers[@]}]="Content-MD5: ${md5}" 162 | curl ${arg} "${inout}" ${stdopts} -K <(curl_headers "${headers[@]}") \ 163 | "http://s3.amazonaws.com${bucket}${remote}" 164 | } 165 | 166 | s3_put() { 167 | # $1 = remote bucket to put it into 168 | # $2 = file to put 169 | local remote_name=$(basename "$2") 170 | s3_curl PUT "${1}" "${remote_name}" "${2:-${remote_name}}" 171 | } 172 | 173 | s3_get() { 174 | # $1 = bucket to get file from 175 | # $2 = remote file to get 176 | # $3 = local file to get into. Will be overwritten if it exists. 177 | # If this contains a path, that path must exist before calling this. 178 | s3_curl GET "${1}" "${2}" "${3:-${2}}" 179 | } 180 | 181 | s3_test() { 182 | # same args as s3_get, but uses the HEAD verb instead of the GET verb. 183 | s3_curl HEAD "${1}" "${2}" >/dev/null 184 | } 185 | 186 | # Hideously ugly, but it works well enough. 187 | s3_buckets() { 188 | s3_get |grep -o '[^>]*' |sed 's/<[^>]*>//g' |xmldec 189 | } 190 | 191 | # this will only return the first thousand entries, alas 192 | # Mabye some kind soul can fix this without writing an XML parser in bash? 193 | # Also need to add xml entity handling. 194 | s3_list() { 195 | # $1 = bucket to list 196 | [[ ${1} ]] || return 1 197 | s3_get "${1}" |grep -o '[^>]*' |sed 's/<[^>]*>//g'| xmldec 198 | } 199 | 200 | s3_delete() { 201 | # $1 = bucket to delete from 202 | # $2 = item to delete 203 | s3_curl DELETE "${1}" "${2}" 204 | } 205 | 206 | # because this uses s3_list, it suffers from the same flaws. 207 | s3_rmrf() { 208 | # $1 = bucket to delete everything from 209 | s3_list "${1}" | while read -r f; do 210 | s3_delete "${1}" "${f}"; 211 | done 212 | } 213 | 214 | check_deps 215 | cmd="$1" 216 | shift 217 | case $cmd in 218 | put) s3_put "$@" ;; 219 | get) s3_get "$@" ;; 220 | rm) s3_delete "$@" ;; 221 | ls) s3_list "$@" ;; 222 | test) s3_test "$@" ;; 223 | buckets) s3_buckets ;; 224 | rmrf) s3_rmrf "$@" ;; 225 | *) die "Unknown command ${cmd}." 226 | ;; 227 | esac 228 | -------------------------------------------------------------------------------- /retrieve/core/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################### 3 | # Prey Retrieve Module Base Functions - by Tomas Pollak (bootlog.org) 4 | # URL: http://preyproject.com 5 | # License: GPLv3 6 | #################################################################### 7 | 8 | perform_backup(){ 9 | 10 | local find_args=$(parse_arguments) 11 | 12 | if [ -z "$find_args" ]; then 13 | log ' !! No arguments for query given. You need to enter a search string, date range or file size range.' 14 | return 1 15 | fi 16 | 17 | local upload_count=0 18 | 19 | local exclude="-not -empty -not -regex '.*/\..*'" # exclude hidden files 20 | local escaped_extensions=$(echo $backup__search_extensions | sed "s/|/\\\|/g") 21 | 22 | local search_path=$(eval echo "$backup__search_path") 23 | local find_command="find "$search_path" -type f $find_args -regex \".*\.\(${escaped_extensions}\)\" $exclude -printf \"%T@\t%s\t%p\n\"" 24 | 25 | log " -- Looking for files in ${search_path} using criteria: ${find_args}" 26 | 27 | # currently sorting by size, from small to big, so we get to send as many as possible 28 | # reverse sort -n -r 29 | local found_files=$(eval "$find_command" | sort -n) 30 | local found_files_count=$(echo "$found_files" | grep -v '^$' | wc -l) 31 | 32 | log " -- ${found_files_count} matches found!" 33 | 34 | [ $found_files_count -eq 0 ] && return 0 35 | 36 | while read file; do 37 | 38 | local file_date=$(echo "$file" | cut -f1) 39 | local file_name=$(echo "$file" | cut -f3) 40 | local file_size=$(echo "$file" | cut -f2) 41 | local file_size_human=$(($file_size/1024)) 42 | 43 | [ ! -f "$file_name" ] && continue 44 | 45 | log " -- Found file: (${file_size_human} KB) $file_name" 46 | 47 | if [ -n "$(is_file_sent "$file_name" "$file_date")" ]; then 48 | 49 | log " -- File has already been sent! Skipping..." 50 | 51 | else 52 | 53 | zip_and_upload "$file_name" 54 | if [ $? -eq 0 ]; then 55 | 56 | log " -- File sent! Marking as uploaded..." 57 | mark_as_sent "$file_date" "$file_size" "$file_name" 58 | store_in_memory "$file_name" "$file_size" 59 | upload_count=$(($upload_count+1)) 60 | # [ -n "$test_mode" ] && break 61 | 62 | else 63 | 64 | log " -- Unable to upload to backend. Check your login/pass and that you have available storage space." 65 | break 66 | 67 | fi 68 | 69 | fi 70 | 71 | done <<< "$found_files" 72 | 73 | log " ++ ${upload_count} files backed up!" 74 | 75 | if [ $upload_count -gt 0 ]; then 76 | 77 | local file_list=$(generate_query_string 'backup_files', '&device') 78 | local full_query="device[backup][backend]=${backup__backend}$file_list" 79 | 80 | update_device_info_with "$full_query" 81 | 82 | fi 83 | 84 | } 85 | 86 | store_in_memory(){ 87 | local urlencoded=$(urlencode "$1") 88 | store_key_value 'backup_files' "backup__${urlencoded}" "$2" 89 | } 90 | 91 | parse_arguments(){ 92 | 93 | local find_args='' 94 | 95 | if [ -n "$backup__search_string" ]; then 96 | find_args="-iname *${backup__search_string}*" 97 | fi 98 | if [ -n "$backup__max_size_in_kb" ]; then 99 | find_args="$find_args -size -${backup__max_size_in_kb}k" 100 | fi 101 | if [ -n "$backup__last_modified" ]; then 102 | find_args="$find_args -mtime -${backup__last_modified}" 103 | fi 104 | 105 | echo "$find_args" 106 | 107 | } 108 | 109 | zip_and_upload(){ 110 | 111 | log " ++ Processing $file_name..." 112 | 113 | local file_name="$1" 114 | local normalized=$(normalize_file_name "$file_name") 115 | local zip_file_name="${tmpdir}/$(basename $normalized).zip" 116 | 117 | log " -- Zipping to ${zip_file_name}..." 118 | zip_file "$file_name" "$zip_file_name" 119 | 120 | [ $? -ne 0 ] && echo " -- Error while zipping!" && return 2 121 | 122 | upload_file "$zip_file_name" 123 | local rs=$? 124 | 125 | log " -- Removing zipped file..." 126 | rm -f "$zip_file_name" 127 | return $rs 128 | 129 | } 130 | 131 | normalize_file_name(){ 132 | echo "$1" | sed "s/[^a-zA-Z0-9\.-\/]/_/g" 133 | } 134 | 135 | is_file_sent(){ 136 | egrep "${1}|${2}" "${module_path}/${backup__sent_files_list}" &> /dev/null && echo 1 || return 0 137 | } 138 | 139 | mark_as_sent(){ 140 | echo -e "$1,$2,$3" >> "${module_path}/${backup__sent_files_list}" 141 | } 142 | 143 | clear_sent_files(){ 144 | echo "" > "${module_path}/${backup__sent_files_list}" 145 | } 146 | 147 | # gets filename, normalized 148 | zip_file(){ 149 | 150 | local original=$1 151 | local zipped=$2 152 | 153 | [ -n "$backup__zip_password" ] && zip_password="-P $backup__zip_password" 154 | zip -9 $zip_password "$zipped" "$original" 1> /dev/null 155 | 156 | [ -f "$zipped" ] && return 0 || return 1 157 | 158 | } 159 | 160 | upload_file(){ 161 | log " -- Uploading to ${backup__backend}!" 162 | # [ -n "$test_mode" ] && return 0 163 | eval upload_to_${backup__backend} "$1" 164 | } 165 | 166 | upload_to_dropbox(){ 167 | 168 | local file_to_upload="$1" 169 | 170 | [ -n "$backup__backend_path" ] && remote_path="-d $backup__backend_path" 171 | "${module_path}/lib/dropbox_uploader.sh" $remote_path -v \ 172 | -u "$backup__backend_user" \ 173 | -p "$backup__backend_pass" \ 174 | -f "$file_to_upload" 175 | 176 | return $? 177 | } 178 | 179 | upload_to_amazon_s3(){ 180 | 181 | local file_to_upload="$1" 182 | 183 | [ -z "$backup__backend_path" ] && get_last_bucket_in_s3 184 | [ $? -ne 0 ] && return 1 185 | 186 | log " -- Uploading to bucket $backup__backend_path at Amazon S3..." 187 | 188 | S3_ACCESS_KEY_ID="$backup__backend_user" \ 189 | S3_SECRET_ACCESS_KEY="$backup__backend_pass" \ 190 | "${module_path}/lib/s3" put "$backup__backend_path" "$file_to_upload" 191 | 192 | return $? 193 | } 194 | 195 | get_last_bucket_in_s3(){ 196 | 197 | log " -- Getting bucket list..." 198 | 199 | backup__backend_path=$(S3_ACCESS_KEY_ID="$backup__backend_user" \ 200 | S3_SECRET_ACCESS_KEY="$backup__backend_pass" \ 201 | "${module_path}/lib/s3" buckets | head -1) 202 | 203 | return $? 204 | 205 | } 206 | 207 | upload_to_ubuntu_one(){ 208 | 209 | [ -z "$(which python)" ] && log " -- Python interpreter not found! Cannot continue." && return 1 210 | 211 | local file_to_upload="$1" 212 | local credentials_file='credentialfile.txt' 213 | 214 | if [ -z "$ubuntu_one_oauth_tokens" ]; then 215 | 216 | log " -- Getting OAuth tokens..." 217 | 218 | PYTHONPATH="${module_path}/lib" "${module_path}/lib/u1rest/createfilekeystore.py" \ 219 | --email "$backup__backend_user" \ 220 | --password "$backup__backend_pass" \ 221 | --name PreyBackup &> /dev/null 222 | 223 | [ $? -ne 0 ] && return 1 224 | 225 | log " -- Done! Pushing file to Ubuntu One's servers..." 226 | 227 | # keep them in memory to avoid checking every time 228 | ubuntu_one_oauth_tokens=$(cat "$credentials_file") 229 | 230 | else 231 | 232 | log " -- Reusing previous OAuth tokens!" 233 | 234 | # dump in memory oauth tokens to u1rest's credentials file 235 | echo "$ubuntu_one_oauth_tokens" > "$credentials_file" 236 | 237 | fi 238 | 239 | python "${module_path}/lib/u1_upload.py" "$file_to_upload" 240 | rs=$? 241 | 242 | rm -f "$credentials_file" 243 | return $rs 244 | 245 | } 246 | -------------------------------------------------------------------------------- /retrieve/lib/dropbox_uploader.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Dropbox Uploader Script v0.8.2 4 | # 5 | # Copyright (C) 2010-2011 Andrea Fabrizi 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | # 21 | 22 | #DROPBOX ACCOUNT 23 | #For security reasons, it is not recommended to modify this script 24 | #to hardcode a login and password. However, this can be done if 25 | #automation is necessary. 26 | LOGIN_EMAIL="" 27 | LOGIN_PASSWD="" 28 | 29 | #Set to 1 to enable DEBUG mode 30 | DEBUG=0 31 | 32 | #Set to 1 to enable VERBOSE mode (-v option) 33 | VERBOSE=0 34 | 35 | #If set to 1 the script terminate if an upload error occurs 36 | END_ON_UPLOAD_ERROR=0 37 | 38 | #Set to 1 to skip the initial login page loading (Speed up the uploading process). 39 | #Set to 0 if you experience problems uploading the files. 40 | SKIP_LOADING_LOGIN_PAGE=1 41 | 42 | #Don't edit these... 43 | LOGIN_URL="https://www.dropbox.com/login" 44 | HOME_URL="https://www.dropbox.com/home" 45 | UPLOAD_URL="https://dl-web.dropbox.com/upload" 46 | COOKIE_FILE="/tmp/du_cookie_$RANDOM" 47 | RESPONSE_FILE="/tmp/du_resp_$RANDOM" 48 | BIN_DEPS="curl sed grep tr pwd" 49 | VERSION="0.8.2" 50 | 51 | if [ $DEBUG -ne 0 ]; then 52 | set -x 53 | COOKIE_FILE="/tmp/du_cookie_debug" 54 | RESPONSE_FILE="/tmp/du_resp_debug" 55 | fi 56 | 57 | #Print verbose information depend on $VERBOSE variable 58 | function print 59 | { 60 | if [ $VERBOSE -eq 1 ]; then 61 | echo -ne "$1"; 62 | fi 63 | } 64 | 65 | #Remove temporary files 66 | function remove_temp_files 67 | { 68 | if [ $DEBUG -eq 0 ]; then 69 | rm -fr $COOKIE_FILE 70 | rm -fr $RESPONSE_FILE 71 | fi 72 | } 73 | 74 | #Extract token from the specified form 75 | # $1 = file path 76 | # $2 = form action 77 | function get_token 78 | { 79 | TOKEN=$(cat $1 | tr -d '\n' | sed 's/.*
]*>\s* Uploading '$UPLOAD_FILE' to 'DROPBOX$DEST_FOLDER'..." 92 | 93 | #Show the progress bar during the file upload 94 | if [ $VERBOSE -eq 1 ]; then 95 | CURL_PARAMETERS="--progress-bar" 96 | print "\n" 97 | else 98 | CURL_PARAMETERS="-s --show-error" 99 | fi 100 | 101 | curl $CURL_PARAMETERS -i -b $COOKIE_FILE -o $RESPONSE_FILE -F "plain=yes" -F "dest=$DEST_FOLDER" -F "t=$TOKEN" -F "file=@$UPLOAD_FILE" "$UPLOAD_URL" 102 | grep "HTTP/1.1 302 FOUND" "$RESPONSE_FILE" > /dev/null 103 | 104 | if [ $? -ne 0 ]; then 105 | print " Failed!\n" 106 | if [ $END_ON_UPLOAD_ERROR -eq 1 ]; then 107 | remove_temp_files 108 | exit 1 109 | fi 110 | else 111 | print " OK\n" 112 | fi 113 | } 114 | 115 | #Recursively upload a directory structure 116 | # $1 = remote destination folder 117 | function dropbox_upload_dir 118 | { 119 | for i in *; do 120 | 121 | if [ -f "$i" ]; then 122 | dropbox_upload "$i" "$1" 123 | fi 124 | 125 | if [ -d "$i" ]; then 126 | local OLD_PWD=$(pwd) 127 | cd "$i" 128 | dropbox_upload_dir "$1/$i" 129 | cd "$OLD_PWD" 130 | fi 131 | done 132 | } 133 | 134 | 135 | #Handles the keyboard interrupt (control-c) 136 | function ctrl_c 137 | { 138 | print "\n Bye ;)\n" 139 | remove_temp_files 140 | exit 1 141 | } 142 | 143 | #Trap keyboard interrupt (control-c) 144 | trap ctrl_c SIGINT 145 | 146 | #CHECK DEPENDENCIES 147 | for i in $BIN_DEPS; do 148 | which $i > /dev/null 149 | if [ $? -ne 0 ]; then 150 | echo -e "Error: Required file could not be found: $i" 151 | remove_temp_files 152 | exit 1 153 | fi 154 | done 155 | 156 | #USAGE 157 | function usage() { 158 | echo -e "Dropbox Uploader v$VERSION" 159 | echo -e "Usage: $0 [OPTIONS]..." 160 | echo -e "\nOptions:" 161 | echo -e "\t-u [USERNAME] (required if not hardcoded)" 162 | echo -e "\t-p [PASSWORD]" 163 | echo -e "\t-f [FILE/FOLDER] (required)" 164 | echo -e "\t-d [REMOTE_FOLDER] (default: /)" 165 | echo -e "\t-v Verbose mode" 166 | 167 | remove_temp_files 168 | } 169 | 170 | # File variables 171 | UPLOAD_FILE="" 172 | DEST_FOLDER="" 173 | 174 | optn=0; 175 | 176 | while getopts "u:p:f:d:v" opt; do 177 | case $opt in 178 | u) 179 | LOGIN_EMAIL="$OPTARG" 180 | let optn++;; 181 | p) 182 | LOGIN_PASSWD="$OPTARG" 183 | let optn++;; 184 | f) 185 | UPLOAD_FILE="$OPTARG" 186 | let optn++;; 187 | d) 188 | DEST_FOLDER="$OPTARG" 189 | let optn++;; 190 | v) 191 | VERBOSE=1;; 192 | *) 193 | usage; 194 | exit 0; 195 | esac 196 | done 197 | 198 | if [ $optn -lt 1 ] || [ "$LOGIN_EMAIL" == "" ]; then 199 | usage; 200 | exit 1; 201 | fi 202 | 203 | if [ "$DEST_FOLDER" == "" ]; then 204 | DEST_FOLDER="/" 205 | fi 206 | 207 | print "Dropbox Uploader v$VERSION\n" 208 | 209 | #CHECK FILE/DIR 210 | if [ ! -r "$UPLOAD_FILE" ]; then 211 | echo -e "Please specify a valid file or directory (-f)" 212 | remove_temp_files 213 | exit 1 214 | fi 215 | 216 | #Prompt for password 217 | if [ "$LOGIN_PASSWD" == "" ]; then 218 | read -s -p "Password: " LOGIN_PASSWD 219 | echo 220 | fi 221 | 222 | #LOAD LOGIN PAGE 223 | if [ $SKIP_LOADING_LOGIN_PAGE -eq 0 ]; then 224 | print " > Loading Login Page..." 225 | curl -s --show-error -i -o "$RESPONSE_FILE" "$LOGIN_URL" 226 | 227 | if [ $? -ne 0 ]; then 228 | print " Failed!\n" 229 | remove_temp_files 230 | exit 1 231 | else 232 | print " OK\n" 233 | fi 234 | 235 | #GET TOKEN 236 | TOKEN=$(get_token "$RESPONSE_FILE" "\/login") 237 | #echo -e " > Token = $TOKEN" 238 | if [ "$TOKEN" == "" ]; then 239 | print " Failed to get Authentication token!\n" 240 | remove_temp_files 241 | exit 1 242 | fi 243 | fi 244 | 245 | #LOGIN 246 | print " > Logging in..." 247 | curl -s --show-error -i -c $COOKIE_FILE -o $RESPONSE_FILE --data "login_email=$LOGIN_EMAIL&login_password=$LOGIN_PASSWD&t=$TOKEN" "$LOGIN_URL" 248 | grep "location: /home" $RESPONSE_FILE > /dev/null 249 | 250 | if [ $? -ne 0 ]; then 251 | print " Failed!\n" 252 | remove_temp_files 253 | exit 1 254 | else 255 | print " OK\n" 256 | fi 257 | 258 | #LOAD HOME 259 | print " > Loading Home..." 260 | curl -s --show-error -i -b "$COOKIE_FILE" -o "$RESPONSE_FILE" "$HOME_URL" 261 | 262 | if [ $? -ne 0 ]; then 263 | print " Failed!\n" 264 | remove_temp_files 265 | exit 1 266 | else 267 | print " OK\n" 268 | fi 269 | 270 | #GET TOKEN 271 | TOKEN=$(get_token "$RESPONSE_FILE" "https:\/\/dl-web.dropbox.com\/upload") 272 | #echo -e " > Token = $TOKEN" 273 | if [ "$TOKEN" == "" ]; then 274 | print " Failed to get Upload token!\n" 275 | remove_temp_files 276 | exit 1 277 | fi 278 | 279 | #If it's a single file... 280 | if [ -f "$UPLOAD_FILE" ]; then 281 | dropbox_upload "$UPLOAD_FILE" "$DEST_FOLDER" 282 | fi 283 | 284 | #If it's a directory... 285 | if [ -d "$UPLOAD_FILE" ]; then 286 | OLD_PWD=$(pwd) 287 | cd "$UPLOAD_FILE" 288 | dropbox_upload_dir "$DEST_FOLDER" 289 | cd "$OLD_PWD" 290 | fi 291 | 292 | 293 | remove_temp_files 294 | -------------------------------------------------------------------------------- /lock/platform/linux/prey-lock: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | ############################################# 3 | # Prey Linux Lock 4 | # By Tomas Pollak - (c) 2010 Fork Ltd. 5 | # http://preyproject.com 6 | # GPLv3 Licence 7 | ############################################# 8 | 9 | import os, sys 10 | from hashlib import md5 11 | import gtk 12 | import pango 13 | 14 | image_file = "/../../lib/bg-lock-with-input.png" 15 | 16 | class Lock: 17 | def get_md5(self, string): 18 | return md5(string).hexdigest() 19 | 20 | def enter_callback(self, widget, entry): 21 | hashed_text = self.get_md5(entry.get_text()) 22 | # print hashed_text 23 | 24 | if hashed_text != passwd: 25 | print "Invalid password" 26 | sys.stdout.flush() 27 | self.label.show() 28 | return True 29 | else: 30 | enable_XF86Switch() 31 | print 'Correctomondo. PC Unlocked.' 32 | # self.label.set_markup('Very good. Access granted.'); 33 | # self.label.show() 34 | os._exit(66) 35 | 36 | def on_delete_event(self, widget, event): 37 | return True 38 | # self.window.set_keep_above(True) 39 | 40 | def on_focus_change(self, widget, event): 41 | print " -- Focus changed." 42 | return True 43 | 44 | def on_window_state_change(self, widget, event): 45 | self.window.activate_focus() 46 | print " -- Something happened." 47 | return False 48 | 49 | def on_key_press(self, widget, event): 50 | keyname = gtk.gdk.keyval_name(event.keyval) 51 | # print "Key %s (%d) was pressed" % (keyname, event.keyval) 52 | if event.keyval > 65470 and event.keyval < 65481: # F1 through F12 53 | print "Key %s (%d) was pressed" % (keyname, event.keyval) 54 | # return True 55 | if event.state & gtk.gdk.CONTROL_MASK: 56 | print "Control was being held down" 57 | # return True 58 | if event.state & gtk.gdk.MOD1_MASK: 59 | print "Alt was being held down" 60 | # return True 61 | if event.state & gtk.gdk.SHIFT_MASK: 62 | print "Shift was being held down" 63 | 64 | def __init__(self): 65 | 66 | # calculate number of screens 67 | width = gtk.gdk.screen_width() 68 | height = gtk.gdk.screen_height() 69 | 70 | black = gtk.gdk.color_parse("black") 71 | 72 | ################################### 73 | # black bg 74 | ################################### 75 | 76 | self.bg_window = gtk.Window(gtk.WINDOW_POPUP) 77 | self.bg_window.modify_bg(gtk.STATE_NORMAL, black) 78 | self.bg_window.resize(width, height) 79 | self.bg_window.set_deletable(False) 80 | self.bg_window.show() 81 | 82 | # monitors = self.bg_window.get_screen().get_n_monitors() 83 | 84 | ################################### 85 | # window 86 | ################################### 87 | 88 | self.window = gtk.Window(gtk.WINDOW_POPUP) 89 | self.window.set_title("Prey Lock") 90 | self.window.modify_bg(gtk.STATE_NORMAL, black) 91 | 92 | # prevents window from being closed 93 | self.window.connect("delete_event", self.on_delete_event) 94 | # capture keypresses 95 | self.window.connect("key_press_event", self.on_key_press) 96 | 97 | self.window.stick() 98 | self.window.set_deletable(False) 99 | # self.window.set_focus_on_map(True) 100 | self.window.set_decorated(False) 101 | self.window.set_border_width(0) 102 | self.window.set_keep_above(True) 103 | self.window.set_resizable(False) 104 | # self.window.fullscreen() 105 | 106 | main_screen_width = self.window.get_screen().get_monitor_geometry(0).width 107 | main_screen_height = self.window.get_screen().get_monitor_geometry(0).height 108 | main_screen_middle = main_screen_width/2 109 | 110 | # print "Main screen size: %s x %s" % (main_screen_width, main_screen_height) 111 | # print "Main screen middle: %s" % main_screen_middle 112 | 113 | vbox = gtk.VBox(False, 0) 114 | vbox.set_size_request(main_screen_width, main_screen_height) 115 | self.window.add(vbox) 116 | # vbox.show() 117 | 118 | ################################### 119 | # background color and image 120 | ################################### 121 | 122 | image = gtk.Image() 123 | script_path = sys.path[0] 124 | bg_path = script_path + image_file 125 | pixbuf = gtk.gdk.pixbuf_new_from_file(bg_path) 126 | image_width = pixbuf.get_width() 127 | image_height = pixbuf.get_height() 128 | 129 | # print 'Image size: %s x %s' % (image_width, image_height) 130 | scale = 1 131 | 132 | if image_width > main_screen_width or image_height > main_screen_height: 133 | scale = min(float(main_screen_width)/image_width, float(main_screen_height)/image_height) 134 | new_width = int(scale*image_width) 135 | new_height = int(scale*image_height) 136 | # print "Scaled image to: %s x %s" % (new_width, new_height) 137 | pixbuf = pixbuf.scale_simple(new_width, new_height, gtk.gdk.INTERP_BILINEAR) 138 | 139 | image.set_from_pixbuf(pixbuf) 140 | image.set_size_request(main_screen_width, main_screen_height) 141 | image.show() 142 | vbox.add(image) 143 | 144 | ################################### 145 | # label 146 | ################################### 147 | 148 | self.entry = gtk.Entry(max=0) 149 | self.entry.set_max_length(40) 150 | 151 | self.entry.set_inner_border(None) 152 | self.entry.set_width_chars(24) 153 | self.entry.set_visibility(False) 154 | self.entry.set_has_frame(False) 155 | self.entry.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse("#FFFFFF")) 156 | self.entry.modify_font(pango.FontDescription("sans 16")) 157 | self.entry.set_flags(gtk.CAN_FOCUS | gtk.HAS_FOCUS | gtk.HAS_GRAB | gtk.CAN_DEFAULT | gtk.SENSITIVE) 158 | self.entry.connect("activate", self.enter_callback, self.entry) 159 | # self.entry.show() 160 | 161 | input_size = 210 162 | 163 | padding_left = int(input_size*scale) 164 | padding_top = -3 165 | # print 'Padding: left %s, top %s' % (padding_left, padding_top) 166 | 167 | # if image was scaled down, calculate offset for positioning elements 168 | if image_height > main_screen_height: 169 | padding_top = 18 - int((image_height - main_screen_height)/8) 170 | 171 | x_position = main_screen_middle-padding_left 172 | y_position = -(main_screen_height/2)+padding_top 173 | # print "Fixed position: %s, %s" % (x_position, y_position) 174 | 175 | fixed = gtk.Fixed() 176 | fixed.put(self.entry, x_position, y_position) 177 | fixed.show() 178 | vbox.pack_start(fixed, False, False, 0) 179 | 180 | text = 'Invalid password. Access denied.' 181 | self.label = gtk.Label() 182 | self.label.set_markup(''+text+''); 183 | self.label.modify_font(pango.FontDescription("sans 15")) 184 | # self.label.set_size_request(main_screen_width, 30) 185 | 186 | fixed2 = gtk.Fixed() 187 | # push label down a bit, and left a bit so it remains centered 188 | fixed2.put(self.label, x_position + 26, y_position + 44) 189 | vbox.pack_start(fixed2, False, False, 0) 190 | 191 | disable_XF86Switch() 192 | 193 | self.window.show_all() 194 | # self.window.set_focus(self.entry) 195 | gtk.gdk.keyboard_grab(fixed.window, True) 196 | self.label.hide() 197 | 198 | original_keycodes = [] 199 | 200 | def enable_XF86Switch(): 201 | import subprocess # need at least python 2.4 202 | try: 203 | for x,y,z in original_keycodes: 204 | cmd = ['xmodmap', '-e', 'keycode %s=%s %s' % (x,y,z)] 205 | subprocess.Popen(cmd) 206 | except OSError, subprocess.CalledProcessError: 207 | return 208 | 209 | def disable_XF86Switch(): 210 | import subprocess # need at least python 2.4 211 | import re 212 | 213 | try: 214 | cmd = ['xmodmap', '-pk'] 215 | # find all keys that allows switching to a VT 216 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE) 217 | output, serror = p.communicate() 218 | matched = [] 219 | 220 | # retrieve the keycode and its value from xmodmap output 221 | for line in output.split('\n'): 222 | if re.search('XF86Switch_VT', line): 223 | items = line.split() 224 | keycode = items[0] 225 | keysym = items[1] 226 | keysym2 = items[7] 227 | keyname = items[2][1:-1] 228 | matched.append((keycode, keyname)) 229 | original_keycodes.append((keycode, keysym, keysym2)) 230 | 231 | # disable all key that allow to switch to a VT 232 | for k,v in matched: 233 | cmd = ['xmodmap', '-e', 'keycode %s=%s' % (k,v)] 234 | subprocess.Popen(cmd) 235 | 236 | except IndexError: 237 | print "Couldn't parse Xmodmap list." 238 | 239 | except OSError, subprocess.CalledProcessError: 240 | # print "Xmodmap not found" 241 | # do nothing if xmodmap is not found or return an error 242 | return 243 | 244 | 245 | if __name__ == "__main__": 246 | 247 | if len(sys.argv) < 2 or len(sys.argv[1]) != 32: 248 | print "You need to pass an MD5 hexdigested string." 249 | sys.exit(1) 250 | else: 251 | passwd = sys.argv[1] 252 | 253 | lock = Lock() 254 | gtk.main() 255 | -------------------------------------------------------------------------------- /retrieve/lib/u1rest/files/resources.py: -------------------------------------------------------------------------------- 1 | #Copyright (C) 2011 by John O'Brien 2 | # 3 | #Permission is hereby granted, free of charge, to any person obtaining a copy 4 | #of this software and associated documentation files (the "Software"), to deal 5 | #in the Software without restriction, including without limitation the rights 6 | #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | #copies of the Software, and to permit persons to whom the Software is 8 | #furnished to do so, subject to the following conditions: 9 | # 10 | #The above copyright notice and this permission notice shall be included in 11 | #all copies or substantial portions of the Software. 12 | # 13 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | #THE SOFTWARE. 20 | """REST Resources of the files api.""" 21 | from u1rest.lib.client import ResourceClient 22 | from u1rest.files.content import ContentClient 23 | 24 | BASE_API_PATH = "/api/file_storage/v1" 25 | 26 | 27 | def get_user(res_host, cont_host, auth): 28 | """Get a user object for accessing rest resources. 29 | 30 | @param res_host: The host for File Resources (metadata) 31 | @param cont_host: The host for File Content. 32 | @param auth: An authenticator used in authenticating requests. 33 | """ 34 | resource_client = ResourceClient(res_host, auth, BASE_API_PATH) 35 | content_client = ContentClient(cont_host, auth) 36 | user_json = resource_client.get_resource() 37 | return FileStorageUser(user_json, resource_client, content_client) 38 | 39 | 40 | class FileStorageUser(object): 41 | """A File Storage User resource. 42 | 43 | This is the main part of the API where typically every call is made. 44 | 45 | The get, put, delete are provided for user who do not need a simplified api 46 | and plan on parsing the JSON themselves. 47 | 48 | Other methods are provided that return serialized objects for simplified 49 | user of the API. 50 | """ 51 | resource_path = None 52 | 53 | def __init__(self, res_json, resource_client, content_client): 54 | self.__dict__.update(res_json) 55 | self.resource_client = resource_client 56 | self.content_client = content_client 57 | 58 | def get(self, path, params=None): 59 | """GET a resource. 60 | 61 | @param path: The path of the resource relative to the base API. 62 | @param params: Optionally a dictionary of querystring values. 63 | """ 64 | return self.resource_client.get_resource(path, params=params) 65 | 66 | def put(self, path, data=None, params=None): 67 | """PUT a resource. 68 | 69 | @param path: The path of the resource relative to the base API. 70 | @param data: A JSON Serializable object sent in the PUT 71 | @param params: Optionally a dictionary of querystring values. 72 | """ 73 | return self.resource_client.put_resource(path, data, params=params) 74 | 75 | def delete(self, path, params=None): 76 | """DELETE a resource. 77 | . 78 | @param path: The path of the resource relative to the base API. 79 | @param params: Optionally a dictionary of querystring values. 80 | """ 81 | self.resource_client.delete_resource(path, params=params) 82 | 83 | def make_file(self, path): 84 | """Make a File. 85 | 86 | @param path: The path of the file using the /. 87 | For example ~/Ubuntu One/a/b/c/file.txt 88 | """ 89 | res_json = self.put(path, data={"kind": "file"}) 90 | return FileNode(res_json, self) 91 | 92 | def make_directory(self, path): 93 | """Make a Directory. 94 | 95 | @param path: The path of the file using the /. 96 | For example ~/Ubuntu One/a/b/c/dirname 97 | """ 98 | res_json = self.put(path, data={"kind": "directory"}) 99 | return DirectoryNode(res_json, self) 100 | 101 | def get_node(self, path, with_children=False): 102 | """Get a File or Directory node. 103 | 104 | @param path: The path of the file using the /. 105 | For example ~/Ubuntu One/a/b/c/dirname 106 | @param with_children: If True, the children property of the directory 107 | will be filled with Node Resources of the direct children. 108 | """ 109 | params = {'include_children': 'true'} if with_children else None 110 | res_json = self.get(path, params=params) 111 | return get_node_resource(res_json, self) 112 | 113 | def set_file_public(self, path, public=True): 114 | """Make a file public. 115 | 116 | @param path: The path of the file using the /. 117 | For example ~/Ubuntu One/a/b/c/file.txt 118 | @param public: If True the file will be published else it will be 119 | unpublished. Defaults to True. 120 | """ 121 | res_json = self.put(path, data={"is_public": public}) 122 | return get_node_resource(res_json, self) 123 | 124 | def move_node(self, path, new_path): 125 | """Move a node from one path to the other. 126 | 127 | The new_path is a path relative path within the volume. 128 | """ 129 | res_json = self.put(path, data={"path": new_path}) 130 | return get_node_resource(res_json, self) 131 | 132 | def make_volume(self, path): 133 | """Create a new Volume (aka UDF).""" 134 | path = 'volumes/' + path.lstrip("/") 135 | res_json = self.put(path) 136 | return Volume(res_json, self) 137 | 138 | def get_volume(self, path): 139 | """Get a Volume.""" 140 | path = 'volumes/' + path.lstrip("/") 141 | res_json = self.get(path) 142 | return Volume(res_json, self) 143 | 144 | def delete_volume(self, path): 145 | """Get a Volume.""" 146 | path = 'volumes/' + path.lstrip("/") 147 | self.delete(path) 148 | 149 | def get_volumes(self): 150 | """Get a list of all Volumes.""" 151 | res_json = self.get('volumes') 152 | return [Volume(v, self) for v in res_json] 153 | 154 | def load(self): 155 | """Reload this User Resource.""" 156 | res_json = self.get(self.resource_path) 157 | self.__dict__.update(res_json) 158 | 159 | def download_file(self, path, destination=None): 160 | """Download a file. 161 | 162 | @param destination: The local directory to download the file to. 163 | """ 164 | self.content_client.get_file(path, download_directory=destination) 165 | 166 | def upload_file(self, file_name, path): 167 | """Download a file.""" 168 | response = self.content_client.put_file(file_name, path) 169 | return get_node_resource(response, self) 170 | 171 | 172 | class Resource(object): 173 | """Base class for all resources providing common methods. 174 | 175 | All resources are dynamically loaded from the JSON returned in a Resource 176 | Response. This is done because all File Storage resource have a 177 | resource_path property which identifies the resource. 178 | """ 179 | resource_path = None 180 | 181 | def __init__(self, res_json=None, user=None): 182 | self.__dict__.update(res_json) 183 | self.user = user 184 | 185 | def load(self): 186 | """Reload the resource.""" 187 | res_json = self.user.get(self.resource_path) 188 | self.__dict__.update(res_json) 189 | 190 | def delete(self): 191 | """Delete the resource.""" 192 | self.user.delete(self.resource_path) 193 | 194 | 195 | def get_node_resource(res_json, user): 196 | """Used when given a Node Respresentation to return the right resource. 197 | 198 | @param res_json: The JSON representation of the node. 199 | @param user: The {FileStorageUser} Resource used to get the node. 200 | """ 201 | if res_json.get('kind') == 'file': 202 | return FileNode(res_json, user) 203 | else: 204 | return DirectoryNode(res_json, user) 205 | 206 | 207 | class DirectoryNode(Resource): 208 | """Directory Node Resource.""" 209 | def __init__(self, res_json=None, user=None): 210 | super(DirectoryNode, self).__init__(res_json=res_json, user=user) 211 | if res_json and res_json.get('children'): 212 | self.children = [get_node_resource(n, user) 213 | for n in res_json.get('children')] 214 | 215 | def make_file(self, name): 216 | """Make a file in this directory given a file name. 217 | 218 | @param name: The name of the file to be created under this path. 219 | """ 220 | path = self.resource_path + '/' + name.lstrip('/') 221 | return self.user.make_file(path) 222 | 223 | def make_directory(self, name): 224 | """Make a subdirectory in this directory given a directory name. 225 | 226 | @param name: The name of the directory to be created under this path. 227 | """ 228 | path = self.resource_path + '/' + name.lstrip('/') 229 | return self.user.make_directory(path) 230 | 231 | def load(self, with_children=False, cascade=False): 232 | """Reload this directory. 233 | 234 | @param with_children: If True, direct children will be loaded into 235 | children. 236 | @param cascade: If True all descendants of this node will be loaded 237 | into the children recursively. This should be used with caution. 238 | """ 239 | node = self.user.get_node(self.resource_path, 240 | with_children=with_children or cascade) 241 | if cascade: 242 | for child in [d for d in node.children if d.kind == 'directory']: 243 | child.load(cascade=True) 244 | self.__dict__.clear() 245 | self.__dict__.update(node.__dict__) 246 | 247 | def move(self, new_path): 248 | """Move this node to a new path. 249 | 250 | @param new_path: The new path of the node. Note that this path is 251 | relative the volume path, so the volume path is not included. 252 | For example node.mode("/a/b/c") will move the node to a new path 253 | under the volume. Moving to a different volume is not permitted. 254 | """ 255 | node = self.user.move_node(self.resource_path, new_path) 256 | self.__dict__.clear() 257 | self.__dict__.update(node.__dict__) 258 | 259 | 260 | class FileNode(Resource): 261 | """A File Node Resource.""" 262 | 263 | def set_public(self, public=True): 264 | """Set the file public. 265 | 266 | @param public: If True the file will be published else it will be 267 | unpublished. Defaults to True. 268 | """ 269 | node = self.user.set_file_public(self.resource_path, public) 270 | self.__dict__.clear() 271 | self.__dict__.update(node.__dict__) 272 | 273 | def move(self, new_path): 274 | """Move this node to a new path. 275 | 276 | @param new_path: The new path of the node. Note that this path is 277 | relative the volume path, so the volume path is not included. 278 | For example node.mode("/a/b/c") will move the node to a new path 279 | under the volume. Moving to a different volume is not permitted. 280 | """ 281 | node = self.user.move_node(self.resource_path, new_path) 282 | self.__dict__.clear() 283 | self.__dict__.update(node.__dict__) 284 | 285 | def download(self, destination=None): 286 | """Download this file. 287 | 288 | @param destination: The local directory to download the file to. 289 | """ 290 | return self.user.download_file( 291 | self.resource_path, destination=destination) 292 | 293 | class Volume(Resource): 294 | """A Volume Resource.""" 295 | node_path = None 296 | 297 | def get_root_dir(self, with_children=False): 298 | """Get the root directory node for this volume.""" 299 | return self.user.get_node(self.node_path, with_children) 300 | --------------------------------------------------------------------------------