maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   [WIP] Prey - antitheft system (https://talk.maemo.org/showthread.php?t=92829)

nieldk 2014-03-05 10:42

[WIP] Prey - antitheft system
 
1 Attachment(s)
I have decided to create a seperate thread for Prey on Sailfish, as I believe this is close enough to be working, allthough with some small efforts still needed to be changed in configuration files manually.

My version of prey is on my openrepos for you to test. It should install needed extra packages as needed (openssl-1.0.1f, perl modules and Imagemagick)

I am still working on a few features missing.
* Streaming video from cam (I believe we need a more recent gstreamer for this)
* Alert (needs to find where bg image is stored)
* Lock (remember to enable Jollas lock)

What is working:
* Get geo location
* Get network information
* Get active connections
* Get nearby hotspots
* Traceroute
* Get running programs
* Currently logged in user
* NEW Screenshot (has a red colour)
* NEW Alarm

There is some manual configuration to do after installing the rpm:

Edit:

Code:

/usr/share/prey/config
add your API key to the line (see image)
Get it from https://panel.preyproject.com/profile

Code:

api_key=''
add your email to the line

Code:

mail_to='mailbox@domain.com'
change these lines to fit your email/ISP

Code:

smtp_server='smtp.gmail.com:587'
smtp_username='username@gmail.com'
smtp_password='password'

Note that password above is base64 encrypted, you can get your base64 password like this

Code:

$ echo -n "password" | openssl enc -base64
UPDATE prey.service and prey.timer are now placed in /etc/systemd/system/ folder by installation of the rpm file, no need to manually create them, also, service is started and timer enabled

When you run (as root)

/usr/share/prey/prey.sh

first time, it should register the device, and give some terminal output that will show you wheter the connection/registration is successfull.
The device will be identified at prey as being 'linux' you cn edit this name to fx 'Jolla'.

To query status of prey, you can use
systemctl status prey.timer and
systemctl status prey.service

Changelog:
2805-2014 Version update
requires cron (fcron)
bugfixes (missing laptop-detect
0703-2014 Changed script to sound alarm, added systemd service and timer files, enables service and starts timer by rpm installation
0603-2014 Added fbcat as a requirement and added a (buggy) screenshot capability (picture has a red teint).

nieldk 2014-03-05 10:49

Re: [WIP] Prey - antitheft system
 
1 Attachment(s)
Here are the source of the Prey build on my openrepos
They are all from official sources, untouched and can be build using attached spec files with rpmbuild.

My QT programming is just beginning, so, do feel free to use this for creating a nice GUI to configure and monitor Prey :)

/NielDK

Prey (0.6.2)
Source:
https://s3.amazonaws.com/prey-releas....6.2-linux.zip

And the dependencies of Prey:

Imagemagick (6.8.8-7)
Source:
ftp://ftp.imagemagick.org/pub/ImageM...6.8.8-7.tar.gz

OpenSSL (1.0.1f)
Source;
http://www.openssl.org/source/openssl-1.0.1f.tar.gz

Perl modules:

IO::Socket::SSL (1.967)
Source:
http://search.cpan.org/CPAN/authors/...L-1.967.tar.gz

Net::SSLeay (1.58)
Source:
http://search.cpan.org/CPAN/authors/...ay-1.58.tar.gz

tigre-bleu 2014-03-05 16:28

Re: [WIP] Prey - antitheft system
 
Do you intend to add a control panel to perform the configuration?

rainisto 2014-03-05 16:57

Re: [WIP] Prey - antitheft system
 
Nice to see openrepos version coming too. Do you have sources hosted in some git repo?

nieldk 2014-03-05 17:43

Re: [WIP] Prey - antitheft system
 
:) no, on my laptop, but I will post here later .
Would be nice to see a friendly UI for start/stop/status/config etc.

nieldk 2014-03-05 17:45

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by tigre-bleu (Post 1415561)
Do you intend to add a control panel to perform the configuration?

Would love to, once I get to post sources here, perhaps someone beat me to it :)

mind_the_gap 2014-03-05 23:05

Re: [WIP] Prey - antitheft system
 
Thanks a lot for you effort! I am looking forward to giving this a try. I just got one question regarding the whole setup: I want to install the Prey server software on my own VPS, but I somehow can't seem to find the source code. Would you be so kind to post a link to it in your first post?

nieldk 2014-03-06 05:35

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by mind_the_gap (Post 1415627)
Thanks a lot for you effort! I am looking forward to giving this a try. I just got one question regarding the whole setup: I want to install the Prey server software on my own VPS, but I somehow can't seem to find the source code. Would you be so kind to post a link to it in your first post?

its on their github
https://github.com/prey/prey-standalone-control-panel

pizzulicchio 2014-03-06 08:25

Re: [WIP] Prey - antitheft system
 
Thank you nieldk! Great work!

At the first post into the CODE section correct :

# Start timer, as root
systemctl start myscript.timer
# Enable timer to start at boot
systemctl enable myscript.timer

in

# Start timer, as root
systemctl start prey.service
# Enable timer to start at boot
systemctl enable prey.timer

nieldk 2014-03-06 08:52

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by pizzulicchio (Post 1415647)
Thank you nieldk! Great work!

At the first post into the CODE section correct :

# Start timer, as root
systemctl start myscript.timer
# Enable timer to start at boot
systemctl enable myscript.timer

in

# Start timer, as root
systemctl start prey.service
# Enable timer to start at boot
systemctl enable prey.timer

Oops :)
Thanks for this, It is corrected in first post.

pizzulicchio 2014-03-06 11:20

Re: [WIP] Prey - antitheft system
 
Could be possible to add the "Installation Guide" into the Description section of the app in Harbour ?

nieldk 2014-03-06 11:26

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by pizzulicchio (Post 1415668)
Could be possible to add the "Installation Guide" into the Description section of the app in Harbour ?

Yes, I have added link to first post in this thread to openrepos. Good suggestion :)

nieldk 2014-03-06 11:54

Re: [WIP] Prey - antitheft system
 
A little update :)
I found a screencaptur program, that does work. It has an issue with the screenshot being tinted red.
It is quite easy to install, and use.

You will need to edit:
/usr/share/prey/modules/session/platform/linux/functions

to this


Code:

get_screenshot() {
 run_as_current_user "/usr/bin/fbgrab $session__screenshot"
}

the code is here: https://code.google.com/p/fbcat/

EDIT: I have created an rpm file on my openrepos.

EDIT: Updated version of prey on openrepos, to include fbcat to enable this - still buggy - feature. I believe its useful, even if the screenshot has a reddish teing to it.

EmaNymton 2014-03-06 12:12

Re: [WIP] Prey - antitheft system
 
Why don't you use dbus to take a screenshot?

Code:

dbus-send --session --type=method_call --dest=org.nemomobile.lipstick /org/nemomobile/lipstick/screenshot org.nemomobile.lipstick.saveScreenshot  string:/home/nemo/Pictures/screenshot_tmp.png

nieldk 2014-03-06 12:20

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by EmaNymton (Post 1415680)
Why don't you use dbus to take a screenshot?

Code:

dbus-send --session --type=method_call --dest=org.nemomobile.lipstick /org/nemomobile/lipstick/screenshot org.nemomobile.lipstick.saveScreenshot  string:/home/nemo/Pictures/screenshot_tmp.png

Simply because I couldnt get that to work :)
I did try it

tigre-bleu 2014-03-06 13:07

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by nieldk (Post 1415639)

I installed it on my server as explained on the readme and it works but for production, I'd like to use apache2 with a NameVirtualHost.

However I didn't manage to configure everything correctly for ruby on rails and prey control panel. If anybody did, it would be great to share the howto :)

nieldk 2014-03-06 14:00

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by EmaNymton (Post 1415680)
Why don't you use dbus to take a screenshot?

Code:

dbus-send --session --type=method_call --dest=org.nemomobile.lipstick /org/nemomobile/lipstick/screenshot org.nemomobile.lipstick.saveScreenshot  string:/home/nemo/Pictures/screenshot_tmp.png

You will need something like this for this to work (doesnt work though)

Code:


get_screenshot() {
 eval `dbus-launch --sh-syntax`
 run_as_current_user "dbus-send --address=$DBUS_SESSION_BUS_ADDRESS --type=method_call --dest=org.nemomobile.lipstick
/org/nemomobile/lipstick/screenshot org.nemomobile.lipstick.saveScreenshot string:$session__screenshot"
# run_as_current_user "/usr/bin/fbgrab $session__screenshot"
}


nieldk 2014-03-07 16:11

Re: [WIP] Prey - antitheft system
 
New update out:
Alarm sounds is now working (using gst-launch-0.10 with ffmpeg plugin)

Also, prey.service and prey.timer files are created automatically, and enabled/started by the rpm script.

pizzulicchio 2014-03-18 09:54

Re: [WIP] Prey - antitheft system
 
After the update to 1.0.4.20 all the configs of Prey has gone...


No more files into :
/etc/systemd/system

and no prey's script into :
/usr/share/prey/

I hope in the future that the jolla team will improve the OS update in a better way...
Every new OS it's, at the moment, a new beginning! :-)

juiceme 2014-03-18 10:05

Re: [WIP] Prey - antitheft system
 
Well, PREY is not your normal "userland application", it is more a feature of the OS, so no wonder it is run over when core OS is updated :D

That will happen in the future again, too, unless Prey is made into integral part of the OS... :D

nieldk 2014-03-18 10:51

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by juiceme (Post 1417398)
Well, PREY is not your normal "userland application", it is more a feature of the OS, so no wonder it is run over when core OS is updated :D

That will happen in the future again, too, unless Prey is made into integral part of the OS... :D

May well be so, at least sources were asked for.

But yes, you will need to re-install prey and related packages again after upgrade.

Even though my repo is 'down' until further, you are still able to download packages manually and install locally using zypper.

solbrit 2014-03-18 11:17

Re: [WIP] Prey - antitheft system
 
And after downloading and installing said packages you can try the ui I made:

openrepos.net/content/solbrit/preyui

It's a basic settings ui for those afraid of config file editing in dark, scary terminal windows.

- It requires pyotherside.
- At the moment registration takes a while (because prey.sh pauses for x seconds). Ideally a progressbar should be put in there.
- The status output is raw console output and could be cleaned up and displayed differently to be easier to read. I'll get around to that.

EDIT - rpm is moved to OpenRepos

droll 2014-03-18 11:19

Re: [WIP] Prey - antitheft system
 
is it? i have a custom file in /etc/systemd/system - see http://talk.maemo.org/showthread.php?t=92736

and it still works after i updated my phone this morning.

rainisto 2014-03-18 12:08

Re: [WIP] Prey - antitheft system
 
Update does not remove any packages. My quess is that you accidentally removed it, or the package had some depencies that were conflicting on system update.

And, yes, integrated version is beeing tested internally, so it is coming at some point.

pizzulicchio 2014-03-18 13:28

Re: [WIP] Prey - antitheft system
 
Good day Nieldk!
I hope that you re-up your repo soon.

I have too many dependecies failed for reinstalling prey using zypper
(libcrypto.so.1.0.0 missing.. )

nieldk 2014-03-18 13:43

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by pizzulicchio (Post 1417433)
Good day Nieldk!
I hope that you re-up your repo soon.

I have too many dependecies failed for reinstalling prey using zypper
(libcrypto.so.1.0.0 missing.. )

You need these packages:
openssl-1.0.1f-1.armv7hl.rpm (https://openrepos.net/sites/default/files/packages/500/openssl-1.0.1f-1.armv7hl.rpm)
net-ssleay-1.58-2.armv7hl.rpm (https://openrepos.net/sites/default/...-2.armv7hl.rpm)
io-socket-ssl-1.967-2.armv7hl.rpm (https://openrepos.net/sites/default/...-2.armv7hl.rpm)
fbcat-0.3-0.armv7hl.rpm (https://openrepos.net/sites/default/...-0.armv7hl.rpm)
imagemagick-6.8.8-7.armv7hl.rpm (https://openrepos.net/sites/default/...-7.armv7hl.rpm)
prey-0.6.2-6.armv7hl.rpm (https://openrepos.net/sites/default/files/packages/not%20yet%20assigned/prey-0.6.2-6.armv7hl.rpm)

solbrit 2014-03-19 03:08

Re: [WIP] Prey - antitheft system
 
Updated the ui:

v0.1-2

- Added start/stop button for prey.service

- Moved settings and registration buttons to pulldown menu

- No buttons except status work without setting correct root password first

openrepos.net/content/solbrit/preyui

nieldk 2014-03-19 05:09

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by solbrit (Post 1417580)
Updated the ui:

v0.1-2

- Added start/stop button for prey.service

- Moved settings and registration buttons to pulldown menu

- No buttons except status work without setting correct root password first

openrepos.net/content/solbrit/preyui



Very good work, and many thanks for making this a more complete solution :) Love You :)

solbrit 2014-03-19 09:56

Re: [WIP] Prey - antitheft system
 
Hmm, I somehow lost track of prey.timer when updating the ui. I'm adding it to the start/stop button to enable/disable .timer and .service simultaneously. This should make more sense seeing as how disabling .service only won't keep it from running when called by timer, right? Correct me if I'm wrong...

HolgerN 2014-03-19 11:09

Re: [WIP] Prey - antitheft system
 
I did some changed to the code of prey. You can found them here: https://github.com/holgern/prey-bash-client

Now Changing of excution intervall is possible! between 10min, 15min, 20min, 30min, 40min, 50min and 1 h.

This is done by 7 different timer files. prey-10min.timer, ... and prey-hourly.timer.


If the device is set to missing, then the excution is set to one of these time :10min, 15min, 20min, 30min, 40min, 50min. This can be done by setting Frequency of reports/actions in the prey control website.

After setting the device status to ok, the interval changes back to hourly.

I fixed a small bug with the screenshot, as it was not working for me.

nieldk 2014-03-19 12:11

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by solbrit (Post 1417630)
Hmm, I somehow lost track of prey.timer when updating the ui. I'm adding it to the start/stop button to enable/disable .timer and .service simultaneously. This should make more sense seeing as how disabling .service only won't keep it from running when called by timer, right? Correct me if I'm wrong...

Stopping the prey.timer, and disabling prey.timer should be sufficient. The prey.service is only run, when called by prey.timer.

solbrit 2014-03-19 12:46

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by nieldk (Post 1417657)
Stopping the prey.timer, and disabling prey.timer should be sufficient. The prey.service is only run, when called by prey.timer.

That's what I thought, my bad.
With timer active prey.service should run once every hour, meaning checking your device on https://panel.preyproject.com/devices should never show Offline for >1 hour, right? In my case only running prey.service manually will update the info on url though, suggesting the timer doesn't actually call prey.service, or have I understood it all wrong? :confused:

nieldk 2014-03-19 12:52

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by solbrit (Post 1417663)
That's what I thought, my bad.
With timer active prey.service should run once every hour, meaning checking your device on https://panel.preyproject.com/devices should never show Offline for >1 hour, right? In my case only running prey.service manually will update the info on url though, suggesting the timer doesn't actually call prey.service, or have I understood it all wrong? :confused:

The prey.timer is responsible for calling prey.service once an hour.
However, this may be missed, for example, the device goes to sleep. It will then call again on the next hour, depending if the device is not sleeping/have Internet access etc.
Calling the prey.service (or even the prey.sh script) manually, yes, that will trigger a login, notifying prey servers that the device has activated and responding to the device with actions to take.
So, the prey.timer calls prey.service, just as you could do manually.

solbrit 2014-03-19 15:19

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by nieldk (Post 1417665)
...However, this may be missed, for example, the device goes to sleep. It will then call again on the next hour, depending if the device is not sleeping/have Internet access etc...

Thanks, that explains it, it's the whole Jolla-when-sleeping-is-dead-to-the-world deal. This can make communication a bit tricky for Prey I suppose.

nieldk 2014-03-19 15:58

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by solbrit (Post 1417691)
Thanks, that explains it, it's the whole Jolla-when-sleeping-is-dead-to-the-world deal. This can make communication a bit tricky for Prey I suppose.

it will report eventually, in my experience worst case between contact is around 4 hours, this could possibly be reduced with a more agressive timer. But I think the 1 hr setting is an Ok compromise for service/battery/reliability and assurance. Best is if lock-code is set by user obviously. I hope to further expand this to include the option to enable lock code remotely - perhaps Jolla will incorporate this better eventually :)

HolgerN 2014-03-19 16:10

Re: [WIP] Prey - antitheft system
 
Enabling a timer is not enough. I changed the code, so that after a timer is enabled, he is also started. Otherwise, the timer would work only after a reboot.

So
Quote:

systemctl enable prey.timer
enables the timer, but he is executed after a reboot.
Quote:

systemctl start prey.timer
enables the timer instantly.

nieldk 2014-03-19 20:15

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by HolgerN (Post 1417697)
Enabling a timer is not enough. I changed the code, so that after a timer is enabled, he is also started. Otherwise, the timer would work only after a reboot.

So

enables the timer, but he is executed after a reboot.
enables the timer instantly.

Yes, starting timer is needed - or reboot.
I didnt start the timer, since the config file was needing update with the owners API key, before this would work anyways.

cy8aer 2014-03-23 20:02

Re: [WIP] Prey - antitheft system
 
nieldk: would it be possible to compile all the prey stuff against openssl-1.0.1f-1.2.1 as installed in 1.0.4.20 by default?

nieldk 2014-03-24 11:31

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by cy8aer (Post 1418228)
nieldk: would it be possible to compile all the prey stuff against openssl-1.0.1f-1.2.1 as installed in 1.0.4.20 by default?



Yes, no problem.
What needs to be recompiled actually only is perl modules

IO::Socket::SSL and Net::SSLeay

And those you can easy do by using cpan

cpan install IO::Socket::SSL
cpan install Net::SSLeay


allthough, you will need to install development tools to do that.
But, I will compile all during the next days.

solbrit 2014-03-26 01:02

Re: [WIP] Prey - antitheft system
 
Here goes, the final update of the UI:

v0.1-4

- Registration output in real time (and possible registration abort)
- Timer state updated and always displayed on main page
- Various fixes (Python mostly) and graphical nick nacks

https://openrepos.net/content/solbrit/preyui

"Final" is ofcourse an optimistic expectation that'll keep me going until the first critical bug is reported :D


All times are GMT. The time now is 02:47.

vBulletin® Version 3.8.8