Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
On my laptop I have a guest account that can be accessed without a password. One reason I did this is so that if my laptop is stolen, the thief can still use it without needing to wipe it and reinstall.
I would like to set up a script of some sort that will silently email me the computer's IP address whenever the guest account connects to the internet. Is there a way to do this?
I assume you only want this to occur if the guest account logs in.
In the desktop environment, can you setup startup scripts?
If you ran something like this as a startup script for the guest account, it probably would do what you want.
Code:
while true; do ping -c1 google.com &> /dev/null && curl myexternalip.com/raw | mail -s 'Guest Account Used' email@domain; sleep 60; done
If you wanted to, you could probably spend some more time making it more "hidden" like after sending a email, not sending another one until the external ip changes and such varying the times you attempt to connect. You could also do a SSID scan and email that info as well.
I'm still not completely sure about how to properly do scripts anyway. I know the basics of bash and I'm teaching myself Python, but I'm not sure how to set up a script file for what you just showed me. My desktop does have a "startup programs" option that I can point to a file. However, scripts generally need some equivalent of "#!/bin/bash" or "#!/usr/bin/python" in the first line, so what would I use in this case?
> /dev/null redirects standard output (stdout) to /dev/null, which discards it.
Basically suppresses the standard out (screen/console) to a "bit bucket" that discards it.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,679
Rep:
This will be non-trivial to do andwill require either your real email login and password, one you create for the purpose or a known-good "open relay" in order to send an email at all. Personally, I would have the device make an http request to a web server I control, on a non-standard post, so that the logs of that web server can be checked for the IP address.
Heck, one could do away with having an actual web server and just have either an open port. Or, more securely, have it do something that would flag for easy identification in home router or other firewall logs.
(I may try this myself, come to think of it, just for fun)
"This will be non-trivial" Yes; I was surprised when the other guy (or gal) just gave me a single line of code.
Ok, I know little about networking, so I'm not sure exactly what most of what you said means. Let's start with "have it do something that would flag for easy identification in home router". Do you mean have it send something specifically to my home router?
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,679
Rep:
Quote:
Originally Posted by Flexico
"This will be non-trivial" Yes; I was surprised when the other guy (or gal) just gave me a single line of code.
Ok, I know little about networking, so I'm not sure exactly what most of what you said means. Let's start with "have it do something that would flag for easy identification in home router". Do you mean have it send something specifically to my home router?
Yes both bearing in mind that home routers change IP address sometimes and, if they don't, the bad guy has just done something to your home router.
Taking the above into account the most simple thing I could think of would be to do something like enable loggin on a home router then have the laptop use nmap to scan ports 1970 to 2015 on the home IP address on boot. Perfectly harmless but will result in the logs of the home router logging the IP address that the scans come from against scans of that range.
I hope others may have better ideas as I'm not sure I would use the above "in anger" but I feel that something relying only upon the laptop having an internet connection rather than things like email is probably better.
You could also just sign up for a free dynamic DNS service (I'll leave you to google it as I can't link etc. so well typing on my phone) then use the dynamic DNS client on the laptop and check the website for updates.
Last edited by 273; 10-30-2015 at 01:46 PM.
Reason: Typo's and confusing text corrected (a bit at least).
I do have Teamviewer installed on both computers, but that would require me to be on my computer at the same time the thief is, and if I used the remote-control feature to open a web browser and google "what's my ip" (which was my original plan) that would be rather conspicuous. Perhaps there's some kind of feature in Teamviewer that I don't know about that could automatically do it?
Wait ... that thing has an infinite while loop in it. Is it going to keep running until I reboot?
Yup
Quote:
Yes; I was surprised when the other guy (or gal) just gave me a single line of code.
I ran it and nothing seemed to happen. And yes, I did insert my real email address. ;P
It's pretty simple in its function.
If it can ping google.com, then send you a email based on the results of curling myexternalip.com/raw, which is the computers current external ip address. sleep for 60 seconds, then loop again.
If you only want it to do it once, upon connection upon boot, that would be fairly easy. Maybe use some kind of a until loop
Of course, this assumes you can send a email with mail. You can use guides listed here or or here to help setup mail. You can use a relay, but you should be able to just send a email. You will likely need a mail server setup to do this.
Sorry I didn't explain it thoroughly, dumping code and not explaining doesn't help you much.
Quote:
This will be non-trivial to do
I wouldn't consider it that difficult, it's a detect and send email. Since it's only run on the guest account, there should be no false triggers.
_____
Edit:
Quote:
I do have Teamviewer installed on both computers, but that would require me to be on my computer at the same time the thief is, and if I used the remote-control feature to open a web browser and google "what's my ip" (which was my original plan) that would be rather conspicuous. Perhaps there's some kind of feature in Teamviewer that I don't know about that could automatically do it?
To be honest, a locally forwarded port to a virtual private server upon the guest user logging in and connecting to the network would be pretty cool since it would give you ssh access to the computer... no matter where the thief took it. Something that occurred to me last night lol.
I was messing around with it for a bit and stumbled when it required root access to port <1024 ports (22) but having root access could give you the ability to scan their environment, see what they're doing, grab images from a camera... etc...
You could even run curl myexternalip.com/raw and find your external ip. Much less obvious then doing it over the graphical user interface in classic spy style hacker takeover :P
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,679
Rep:
Quote:
Originally Posted by Sefyir
I wouldn't consider it that difficult, it's a detect and send email. Since it's only run on the guest account, false triggers would be difficult since it would only occur when it's the guest user logged in.
The triggering of the script is trivial, the detection of the relevant IP address less so as it requires connecting to a source of that IP and parsing it, the sending the email part though is tough, unless you can do the following:
Write a script which will send an email from the command line in Linux from any internet connection anywhere in the world without requiring a known SMTP server and credentials for that server. Bonus points if you can get away from using DNS.
If you can't, then I would argue that the best approach is to have the script on the stolen device contact a known machine via another method. If you can, then you've helped the OP and put me in my place with your script-fu .
In fact, I'm beginning to wonder whether the simplest and possibly most anonymous method* is to simply register a free dynamic DNS server and have the (potentially stolen) laptop run a script to update its IP address with that server whenever it is online. That way if the laptop goes missing the dynamic DNS service will show the relevant IP, heck, you could just reverse DNS it.
*Your guest need not know your email credentials nor any IP addresses associated with you other than the last one stored to compare with the dynamic DNS entry but this would be cleared as soon as it was changed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.