Showing posts with label Jabber. Show all posts
Showing posts with label Jabber. Show all posts

Friday, November 18, 2022

Bridge SMS to XMPP: Receive 2FA Codes Abroad

Bridge your mobile SMS with XMPP instant messaging so you can read and send text messages from anywhere over the internet. The primary use case: receiving 2FA verification codes while travelling internationally, without roaming or asking someone at home to read them out for you.

Setup diagram — SMS flows from GSM network through Raspberry Pi to XMPP client

Setup overview — a Raspberry Pi with a USB 3G modem bridges SMS to XMPP via a public Jabber server.

The setup uses a Raspberry Pi with a Huawei E173 (or E303) USB 3G dongle and an encrypted XMPP connection to deliver SMS securely to your phone's chat app. All code is open source, and you can use any public Jabber server (or host your own with Prosody).

Preparing the SD card

  1. Download the Raspberry Pi Imager
  2. Open it and select: CHOOSE OS → Raspberry Pi OS (Other) → Raspberry Pi OS Lite (32-bit)
  3. Select your SD card via CHOOSE STORAGE
  4. Press Ctrl + Shift + X to open the advanced options
  5. Set hostname, enable SSH, username, password, and timezone as shown below, then click SAVE
  6. Click WRITE to create the bootable SD card
Raspberry Pi Imager advanced options dialog

Raspberry Pi Imager — advanced options for hostname, SSH, and credentials.

Setting up the Raspberry Pi

  1. Insert your SIM card (PIN lock must be disabled) into the Huawei E173/E303 dongle and connect it to the Raspberry Pi
  2. Keep the Pi powered on and connected to your home internet 24/7
  3. Once booted, SSH in:
ssh pi@my-raspi-001
  1. Install the XMPP remote agent:
sudo apt-get install -y git
git clone --recursive https://github.com/hackboxguy/xmpp-remote-agent.git
cd xmpp-remote-agent
./setup.sh -u raspi-sim-1@jabber.de -p my-raspi-xmpp-secret-pw
sudo reboot; exit

Replace the example XMPP username and password with your own credentials.

The setup.sh script may take 10–15 minutes on a Raspberry Pi 1.

On your phone's Xabber app (Android or iOS), log in with your XMPP account (e.g. john.doe@jabber.de). The Raspberry Pi should appear online — send help to get the list of available commands.

Reading SMS

smsupdate       # fetch SMS from SIM to cache (wait for Success response)
smstotal        # show number of cached messages
smsget 0        # read the first message

Sending SMS

smssend +919876543210 this is a test message

Deleting SMS

When the SIM memory is full, new messages stop arriving. Delete all stored messages with:

smsdeleteall

Voice dialling and USSD codes

Ring a GSM phone (caller ID shows as SIM-1's number, no audio — ringing only):

dialvoice +919876543210

Check prepaid balance or send other USSD codes:

dialussd *100#     # send USSD code (wait for Success response)
readussd           # read the carrier's response

How it works internally

Two services run on the Raspberry Pi:

  • bboxsmsrv — based on libgammu, handles SMS read/write/delete via the USB 3G modem
  • xmproxysrv — based on libgloox, acts as a headless XMPP client that logs into the Jabber server and maintains an always-on connection

When a 2FA SMS arrives, it is stored in the SIM memory by the 3G modem. On your phone's Xabber app, you send smsupdate → xmproxysrv parses the command and asks bboxsmsrv to fetch messages from the SIM → once complete, a Success response is sent back → you then read the messages with smsget.

For sending, the flow reverses: your chat message travels through the XMPP server to xmproxysrv, which hands it to bboxsmsrv, which sends the SMS via the 3G modem — delivering an SMS to any phone number without roaming charges.

SOURCE CODE

github.com/hackboxguy/xmpp-remote-agent — setup scripts and configuration

github.com/hackboxguy/brbox — bboxsmsrv and xmproxysrv sources

Thursday, January 11, 2018

Access Your Raspberry Pi Remotely via XMPP Chat

How to remote-access a Raspberry Pi over the internet using an XMPP-based chat-bot — no port forwarding or dynamic DNS required. The chat-bot is written in C++ using the gloox XMPP client library, and communicates through a public Jabber server.

Setup diagram — Raspberry Pi chat-bot communicating with smartphone via XMPP

Typical setup — Raspberry Pi behind a firewall communicates with a smartphone via a public XMPP/Jabber server.

Building the chat-bot on Raspberry Pi

Tested on Raspbian Stretch Lite (2017-11-29). These steps work on any Debian-based Linux distro.

Step 1 — Log in to the Raspberry Pi shell (keyboard or SSH) and install dependencies:

sudo apt-get update
sudo apt-get install cmake git libjson-c-dev libgloox-dev openssl

Step 2 — Clone and build:

mkdir /home/pi/xmproxy
cd /home/pi/xmproxy
git clone https://github.com/hackboxguy/brbox
cd /home/pi/xmproxy/brbox/sources
cmake -H. -BOutput -DCMAKE_INSTALL_PREFIX=/home/pi/xmproxy/buildir -DAUTO_SVN_VERSION=OFF
cmake --build Output -- install    # add -j5 on quad-core Pi for faster build

Step 3 — Configure XMPP credentials and start the chat-bot:

cd /home/pi/xmproxy/buildir
echo "user: my-raspi-username@gmail.com" > xmpp-login.txt
echo "pw: super-secret-pw" >> xmpp-login.txt
export LD_LIBRARY_PATH=/home/pi/xmproxy/buildir/lib
/home/pi/xmproxy/buildir/bin/xmproxysrv --loginfile=/home/pi/xmproxy/buildir/xmpp-login.txt

Testing

Check on your Android phone's Hangouts (or any XMPP client) if my-raspi-username is online. Send help and the chat-bot will reply with the list of available commands.

Notes

For Google accounts, ensure Allow less secure apps is enabled on the Raspberry Pi's account.

The two XMPP accounts don't need to be on Google — any two Jabber accounts will work. See this guide for preparing Jabber accounts.

These steps work on any Debian-based Linux distro, not just Raspbian.

SOURCE CODE

github.com/hackboxguy/brbox — XMPP chat-bot sources and build instructions

Monday, January 04, 2016

Control Home Devices via XMPP Chat with Raspberry Pi

Control your home devices from anywhere using a Raspberry Pi running the RBox Linux distribution. The RBox chat-bot connects to a public XMPP/Jabber server, so you can toggle GPIO pins from your phone's chat app — no port forwarding, no dynamic DNS, no paid cloud services.

How it works

Setup diagram — Raspberry Pi at home communicating with smartphone via XMPP

Setup diagram — Raspberry Pi at home and your phone both connect to a public Jabber server. Chat messages carry GPIO commands.

Both the Raspberry Pi (running RBox) and your Android phone (running Xabber or any XMPP client) log in to a public Jabber server with their own credentials. Once the two accounts have authorized each other, they can exchange chat messages through the server.

Advantages

  • No router configuration or port forwarding needed — all incoming firewall ports can stay blocked
  • No dependency on paid cloud services — hundreds of free Jabber servers are available
  • Works from any location as long as your phone has internet access (Wi-Fi or mobile data)

Controlling GPIO

To toggle a GPIO pin, send a chat message from your XMPP client:

Gpio 2 1    # set GPIO2 high
Gpio 2 0    # set GPIO2 low

For full setup instructions (SD card preparation, XMPP account creation, first boot), see the RBox installation guide.

SOURCE CODE

github.com/hackboxguy/brbox — RBox sources and build instructions

Sunday, January 03, 2016

XMPP Account Setup Guide for IoT Remote Control

A step-by-step guide to creating XMPP master and slave accounts on a public server (tested with xabber.de, jabber.de, ubuntu-jabber.de) using the Psi desktop client. These accounts enable remote control of embedded Linux devices over the public internet via XMPP chat protocol.

Shortcut: If you have two Google accounts, you can skip this guide entirely — just authorize both accounts as contacts and use one as the master (your phone/PC) and the other as the slave (chat-bot). In the second account's Google security settings, set "Allow less secure apps: ON".

Why XMPP for IoT?

XMPP is widely used as a chat protocol between humans. The technique described here repurposes it for remotely accessing and controlling embedded devices over the public internet. XMPP was chosen for its wide adoption, built-in security, and ease of connectivity.

Typical client-server communication over the public internet requires exposing a server port through a firewall and registering a dynamic DNS name — a common challenge for home routers or 3G-connected devices with non-static IPs. Using existing public XMPP server infrastructure sidesteps these connectivity challenges entirely.

In this setup, the master account is for the person controlling the device (from a smartphone app like Xabber or a PC client like Psi), while the slave account runs on the remotely deployed Linux machine (Raspberry Pi, BeagleBone, etc.) as a chat bot. As long as both devices have internet access, they can communicate regardless of location.

Creating the master account

Step 1: Install Psi XMPP client on your Windows machine.

Step 2: Start Psi, go to General → Account Setup.

Psi Account Setup dialog

Step 3: Click on "Add".

Account list with Add button

Step 4: Follow the numbered fields as shown below.

New account dialog — follow fields 1 and 2

Step 5: Enter the public server as xabber.de and click "Next".

Server selection — entering xabber.de

Steps 6–10: After pressing "Next", wait for the registration form to load. Fill in the fields:

  • Field 1: Choose a username (e.g. "master")
  • Field 2: Enter your password
  • Field 3: Open the captcha link in a browser
  • Field 4: Enter the captcha number shown by the browser

Click "Next".

Registration form with username, password, and captcha fields

Step 11: If registration succeeds, click "Ok" on the confirmation dialog.

Registration success dialog

Step 12: Click "Save" on the account properties dialog.

Account properties — click Save

Step 13: Click "OK" on the next confirmation dialog.

Confirmation dialog — click OK

Step 14: Back in the Psi main window, right-click on the "Master" entry → Status → Online.

Setting master account status to Online

Step 15: Enter your full name and nickname, then click "Close".

Profile setup — enter name and nickname

Step 16: Master account creation is done. Log out by right-clicking on the "Master" entry → Status → Offline.

Setting master account status to Offline

Creating the slave account

Repeat steps 1–15 for the slave account. Pay attention to these differences:

  • Step 4: Use the string "Slave" instead of "Master"
  • Steps 7–8: Choose a different username and password
  • Step 15: Use "Slave" as the full name and nickname

Pairing master and slave accounts

Once both accounts are created, go to General → Account Setup. Enable both the Master and Slave account checkboxes, then click "Close".

Account Setup with both accounts enabled

Right-click on "Slave" → Status → Online (wait for the grey star to turn yellow). Repeat for "Master". When both stars are yellow, both accounts are online.

Both master and slave accounts online — yellow stars

The master and slave accounts now need to authorize each other — this is XMPP's standard mechanism to block unsolicited messages. Send a few test messages between the accounts to confirm bi-directional communication works.

Next step: Proceed to Rbox — A Lightweight Linux system for IoT to set up the slave device.