Turn off raspberry Pi with Kodi remotely - raspberry-pi

Let me explain my problem: I have a raspberry Pi with Kodi installed and I use it with a IPTV service. This service only allow me to use it in one device at a time and sometimes I want to use it on my phone.
I'd like to be able to turn off my raspberry remotely so I can watch it in my phone whenever I want. I tried to create a web server that would allow me to run a script that would turn off the device but I can't access it because the raspberry IP takes me to some kodi stuff.
So to sum up, I'd like to go to my raspberry IP with Kodi installed, press a button and turn off the device. The web stuff I can take care of.
Any thoughts?

The only safe way to do this is to have a VPN tunnel that lets you access your internal network. This is much safer than opening up a port to Kodi on your router. It would just attract every bot and hacker out there.
Once you have a working VPN tunnel between your home network and your smartphone, just use a Remote Control App to shut Kodi down cleanly.

You can use a Kodi remote app for your mobile device. E.g. Kore (official remote app for Android) does have a shutdown button.

I think the best and easy way is to install dataplicity in your Raspberry Pi and access via dataplicity web or the app (Android or iOS) to the Terminal and use the command: sudo shutdown -h now or sudo poweroff

Related

2 router in cascade with 2 DHCP and remote access

The installation is in a holidays house (so no permanent internet access)
I have a 4g-Routerm (ROUTER-1 = huawei B525-b23) that enable the internet access. I switch it on one day a week.
I have another router (ROUTER-2 = GL-MT300N-V2).
ROUTER-2 is always plugged on electricity.
On ROUTER-2 is connected through ethernet port a Raspberry-Pi3 (with Home Assistant on it).
On ROUTER-2 is connected through WIFI a Camera IP
ROUTER-1 and ROUTER-2 are connected together through ethernet.
When ROUTER-1 is not plug to electricity, none have acces to internet, but it's not an issue.
The camera save picture on the Rapbery Pi3, the Home Assistat is recording some sensor data.
When I switch on the electricity on the ROUTER-1, everyone have access to internet.
What I want is to have remote Access to my router-2 and my Rasberry and my Camera when ROUTER-1 is online
How should I do ?
Hi I can think of two solutions for this setup but both involve buying a second hand cheap router.
I think the use of a single router would make this setup a lot easier. Any router would work that supports:a USB 4g Modem to be attached to it, and has support for setting up a openvpn server and you need to be OK with leaving the Internet on all the time just make sure you dont have any services running that use up bandwidth and you should be ok. You can can connect both raspberry pi and IP camera to that router. Setup Openvpn server open the UDP port required and download the certificates, You should be able to vpn into your network and manage it through SSH or something remotely.
The second option is tailored to you but still requires swapping the 4G Modem with another one that supports these things: Wake on LAN, openvpn server, supports ssh into it over LAN and either has 4G support through a sim card slot or a usb port with modem support.
You can then have it setup so this new Router-1 is switched off with wake on lan configured on it and the raspberry pi to send the magic packet. You can use something like this to get an idea of how WoL https://www.lifewire.com/wake-on-lan-4149800. You can use cron on your raspberry pi to send WoL signal to Router 1 once a week which would eventually give you internet access once the router is up. You have to setup a vpn server on it and forward the required port and download the certificates. When your scheduled WoL cron runs make sure you are able to connect through vpn then access network resources you wish, at the end when you are done you can ssh into the router-1 and turn it off.
I hope this helps. I had a look at the router models you are using and it doesnt leave you with many options. You can get cheap second hand routers online that support everything that is required.

make raspberry appear as SSID

I have a nodejs server in my raspberry and I want people to be able to connecto to it just connecting to the raspi.
The ideal scenario is where in my phone I see the raspi SSID, I connect to it. Then I open chrome enter the ip:port of the raspi itself and it works. Nothing fancier.
What I don't know how to search for in the internet is how to set my pi in a way that it opens itself to the world and appears in the SSID list in my phone. I don't need internet sharing nor anything. Just accessing the nodejs server in the pi.
This can be easily achieved depending on the OS you are using in your pi. Use basically need to use hostapd and a DHCP Server.
You can use a script like create_ap.

Passive WiFi detection system using WiFi router

As part of my project requirement I want to make a system which will detect all the WiFi devices in my router range either its connected or not, I did some research on it then I found something like wireshark ,kismate etc I just tried the wireshark by making my Mac machine's WiFi as an adhoc network and its all fine I am able to list all the WiFi devices in wireshark, now I want to make a real-time system based on a real WiFi router I don't know how I will configure my router using my PC and how I will monitor the router from my PC , one more thing if I am using this wireshark how I will use this data for my requirement. If any one worked with similar scenarios please help me..thanks in advance
To do that you will need more than the usual API that you have on commercial WiFi routers (by that I mean a full SSH access). I would:
flash my router with OpenWRT (you can search for your router on this page for detailed instructions)
Install the aircrack-ng suite on the flashed router with
opkg update
opkg install aircrack-ng
Put my WiFi card in monitor mode and run the airodump service:
airmon-ng start wlan0 #Put your NIC in monitor mode
airodump-ng mon0 #Sniff surrounding packets
You don't necessarily have to install aircrack-ng, you can just put your card in monitor mode using command line (look at the documentation for your WiFi driver) and then run tcpdump (command line equivalent to wireshark) but aircrack works very well and has a nice format.
Also, I should warn you that you can brick your router by flashing it. I never had such a problem when flashing router mentioned on the OpenWRT wiki and there are (most of the times) ways to restore a bricked router depending on the brand but I am not responsible if you break it ;)

Raspberry-PI system smart control through android apps

How can smartly/remotely control a Raspberry-PI system through android apps. I have found an android app named "Raspberry Control" (source). I have followed all the steps as given in the above URL.
I have installed the android app in my phone (samsung galaxy note, recent release in 2014) followed tried to make a connection of android app with my RPI system (I have followed the steps mentioned in this Youtube video). But as shown in video, when the app started from phone, it needs a SSH connection (showed at 0.25 in the video). Unfortunately, I have faced an error like "check installation on RPi".
Thanks in advance for your precious time. Do I need to install any software on raspberry pi or am I missing any steps?
Secure Shell (SSH) is a network protocol that allows data to be
exchanged over a secure channel between two computers. Encryption
provides confidentiality and integrity of data. SSH uses public-key
cryptography to authenticate the remote computer and allow the remote
computer to authenticate the user, if necessary. SSH is typically used
to log into a remote machine and execute commands, but it also
supports tunneling, forwarding arbitrary TCP ports and X11
connections; file transfer can be accomplished using the associated
SFTP or SCP protocols. An SSH server, by default, listens on the
standard TCP port 22. An SSH client program is typically used for
establishing connections to an sshd daemon accepting remote
connections. Both are commonly present on most modern operating
systems, including Mac OS X, GNU/Linux, Solaris and OpenVMS.
Proprietary, freeware and open source versions of various levels of
complexity and completeness exist.
-Wiki
You found a complete guide/dossier in this link. The install instruction can change depending on the system.
You can control rpi trought ssh simply from windows, linux, android, iOs using a ssh telnet/client. Your app simply after press a button send to rpi the correct ssh comand.
If you have debian(or raspbian) this guide is for you:https://wiki.debian.org/en/SSH.
So, you must enable the ssh service on your rpi. Username and password are user/pass of your rpi account.

Capturing network traffic while the application is running on iPhone and connected to xcode

Is there any way I can capture network traffic (using application like Ethereal, on Mac ) while the application is running on iPhone and connected to xcode
Thanks
Connect you mac using an ethernet cable. Share your network connection on the mac over your AirPort. Attach the iPhone to your Mac's ad-hoc network.
Run Wireshark or HTTPScoop on your mac and you will be able to see all traffic from the iPhone.
I'm no aware of any way to do this for the WAN connection though. I'd be surprised if it is possible.
To capture packets from your iPhone using Wireshark, you have to first get your device id for the phone from iTunes. Plug in your iPhone via USB to your Mac...then open iTunes and click the iPhone icon in top navbar.
You can't copy the UUID, so you have to write it down manually. After you have the UUID, you'll need to mount the device.
Open a terminal and type: rvictl -s <device-id>
I created an alias in ~/.bash_aliases as alias mntios='rvictl -s <device-id>' -- as long as you have the same phone your device UUID won't change, even if you re-install the OS.
Once you have the device mounted startup wireshark. brew install wireshark (see: http://brew.sh)
One of the network adaptors should be rvi0 -- this is the network interface for your iPhone.
Now you can capture packets -- double click it to start capturing.
If you want to filter for specific urls you can type a filter like: http.request.full_uri contains <string-in-url> to filter requests.
On your computer, run an HTTP debugging proxy like Charles (Mac) or Fiddler2 (Windows). In the phone's wi-fi settings, turn on the HTTP proxy, entering your computer's IP address and the port number of the proxy. Make the sure the proxy is configured to allow connections from your phone. (It may allow localhost-only by default.)