Skip to content

sundeep-kp/Auto-login-framework

Repository files navigation

Auto-login-framework

Support QR

help me buy a guitar

UPI: 8144255926@upi

{currently supported only for linux, windows support soon...} {undergoing testing} ---
#V-2.0

IIIT-NR Cyberoam Auto-Login (V2.0)

This project provides a simple Linux watchdog script (toggle-portal.sh) and an installer (install.sh) to keep you logged in to the Cyberoam captive portal automatically.

Instead of manually logging in/out through the portal webpage, the script periodically pings Google (or another target). If connectivity is lost, it automatically posts your credentials to th’e captive portals login.xml endpoint using curl.


Installation

h2>
  1. Unzip the folder you downloaded(from the releases tab):
 unzip portal-tools.zip -d ~/portal-tools
 cd ~/portal-tools
pre>
  1. Run the installer:
 chmod +x install.sh
 ./install.sh
pre>

During installation you will be prompted for:

  • Cyberoam username
  • Cyberoam password
  • Install directory (default: ~/.local/bin)

Credentials are stored safely in:
~/.config/toggle-portal/credentials (mode 600).

  1. The installer will:
  • Copy toggle-portal.sh into the install directory
  • Create a wrapper (toggle-portal-run.sh) that loads your credentials
  • Add an @reboot crontab entry to auto-start on boot
  • Log into ~/toggle-portal.log
  • Create a helper tail-toggle-portal-log.sh to view logs


▶️ Usage

h2>

Run manually

 nohup toggle-portal-run.sh > ~/toggle-portal.log 2>&1 &
pre>

View logs

 ~/tail-toggle-portal-log.sh
pre>

Auto-start
The installer adds a crontab entry so the script launches automatically at boot.
Check with:

 crontab -l
pre>

You should see something like:

 @reboot nohup /home/user/.local/bin/toggle-portal-run.sh > /home/user/toggle-portal.log 2>&1 &
pre>

⚙️ How it Works

h2>
  1. Pings 8.8.8.8 once per second
  2. If ping fails → assumes captive portal dropped your session
  3. Builds a POST like:
 mode=191&username=<user>&password=<pass>&a=<timestamp>&producttype=0
pre>

… and sends it to:
https://cyberoam.iiitnr.edu.in:8090/login.xml

4. Loops forever, logging you in whenever needed


️ Troubleshooting

h2>

Script didn’t log me in

  • Check logs:
tail -f ~/toggle-portal.log
pre>
  • Look for success strings (success, logged in, <message>OK)

Wrong credentials

  • Edit your saved credentials:
nano ~/.config/toggle-portal/credentials
pre>
  • Restart the script:
 pkill -f toggle-portal.sh
 nohup toggle-portal-run.sh > ~/toggle-portal.log 2>&1 &
pre>

No Internet even after login

  • Portal host may differ→ check browser DevTools when logging in manually
  • Update PORTAL_HOST in toggle-portal.sh

Change ping target

  • Edit toggle-portal.sh, replace 8.8.8.8 with another IP or domain


Notes

h2>
  • Credentials stored in ~/.config/toggle-portal/credentials (plain text, mode 600)
  • Works on Linux (tested on Ubuntu/Debian)
  • Needs bash and curl
  • Customize retry intervals and targets by editing toggle-portal.sh


Version

h2>

V2.0 – Added installer, watchdog re-login logic, auto-start, log helper, structured README


Credits

h2>
  • Reverse-engineered from captive portal JavaScript (submitRequest())
  • Packaged for IIIT-NR Cyberoam
##V-Alpha ## Instructions to Install

Make sure you download this entire directory:
just gitclone this stuff (usme toh sab hi expert hain): git clone https://github.com/sundeep-kp/Auto-login-framework.git
cyberoam-autologin/ ├── install.sh # installer script (sets up everything)
├── uninstall.sh # removes files, disables timer/service)
├── cyberoam-login.js # main Node.js autologin script
├── cyberoam-login.service # systemd service unit
├── cyberoam-login.timer # systemd timer unit


The last three files will be automatically copied/moved to their required locations.
You don’t have to touch a damn thing (trust me :D).

Right click and run install.sh as a program or from your terminal.


### Note:-


*Bhai, aur kuchh suggestions hai to bata dena merko, bas 150 rupiya lega mai.* *You may provide me with suggestions for the project.*

---

Optional settings-
#if you don't want any pop ups , change this setting to true (search using ctrl+f inside the cyberoam-login.js file) :- headless: false

### If stuff doesn't work, try these out:

#Make `install.sh` executable:

Paste this in the terminal:-

chmod +x install.sh - Make sure your **`cyberoam-login.js`** is okay using the **system-installed Chrome/Chromium** *(usually `/usr/bin/chromium-browser` or `/usr/bin/google-chrome`)*.

#Edit the part that says:

js
const BROWSER_PATHS = [
'/usr/bin/chromium-browser',
'/usr/bin/chromium', '/usr/bin/google-chrome-stable',
'/usr/bin/google-chrome',
'/snap/bin/chromium'
];

If Puppeteer can’t find it, then you specify the path in executablePath when launching:


const browser = await puppeteer.launch({
headless: false
executablePath: '/usr/bin/chromium-browser' // adjust as needed
});


You may add your current browser (Brave, Vivaldi, Edge, etc.)
(they should work given the Chromium framework, but I dunno — I ChatGPT-ed the entire code, who am I to judge 😅)

About

Currently constructed especially for cyberoam login for IIITnr internet portal. May develop into a multi tool later on.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages