Tinkering with OpenWRT for Shenlan Network Authentication

📢 This article was translated by gemini-2.5-flash-lite

Introduction

Documenting my process of getting my OpenWRT router to connect to my school’s network. Although the final result was, well, something, I learned quite a bit along the way.

The Start

Searching openwrt connect shenlan authentication on the browser led me to a post on Ensine Wireless Forum . In the replies, I found an open-source project: coffeehat/BIT-srun-login-script . This project showed me there was a Go version supporting multiple platforms, including OpenWRT, so I started tinkering.

Here’s the project author’s article: Analysis and Python Implementation of Shenlan Campus Network Login - BIT Version

Before Tinkering

OpenWRT versions didn’t provide compiled binaries (IPK files). My limited skills meant I couldn’t understand the README. I asked a classmate, who told me it was a Linux command. However, after trying it, I realized it was for compiling the Linux kernel. I gave up on trying on my physical machine and started using a virtual machine.

Reference: Building a custom kernel/zh-cn - Fedora Project Wiki

Let’s Tinker

A friend sent me configuration - How to fix make error “No rule to make target ‘menuconfig’” when building a kernel for Beagleboard? - Unix & Linux Stack Exchange , so I followed its advice.

Setting Up a Virtual Machine

I’m using Fedora’s built-in virtualization software, “Boxes.” First, I tried installing CentOS 8. My ISO was on an external drive, so I mounted it and selected it. It failed to create the VM. I tried CentOS 7, failed. Then Ubuntu, failed.

After multiple failures, I almost doubted the software, even though I’d successfully created a Windows 10 VM with it before. I opened the error log, but it was gibberish. However, I noticed a Chinese character in a path. I changed the path to English and tried again. Failed.

The next day, I thought, since it’s about kernel compilation, maybe Kali Linux would work. I copied the Kali ISO from my USB to my computer. Although the installation ultimately failed, it ran successfully. Did the system need to be local?

So, I copied the CentOS 7 ISO to ~/Documents/ and the installation succeeded. Since I only needed to compile an IPK, I used the root user.

Connecting to the Network

I assumed creating a Linux VM in Linux would automatically share the network. So, I directly ran wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.19.6.tar.xz. The result was “cannot resolve host.” Using ifconfig, I saw no IP address.

I followed the guide Setting Static IP in a Virtual Machine (CentOS Example) to get the VM online. For file modification, I just needed to change ONBOOT to yes and add two DNS entries.

Installing Git

After getting online, I installed Git using yum install git. Then, I configured my name and email.

1
git config --global user.name "Name"
1
git config --global user.email "[email protected]"

Transferring Files

I continued trying to download the Linux kernel using wget. I tried three or four times, with downloads failing around 50% and at very slow speeds.

Note: Using wget -c URL allows for resuming interrupted downloads.

Then, the “Boxes” software seemed to support direct drag-and-drop. I downloaded the file on my main computer and dragged it over. It failed. The file wasn’t transferred. Considering the target location was ~/Downloads/ and I was using the root account, I followed Adding Users and Administrator Users in Linux to create a new user. (I almost ran the step to delete the user.)

I switched to the new user with su username, created the ~/Downloads/ directory, and dragged the file again. Still failed.

I tried using Boxes’ sharing feature to share my computer’s ~/Public folder. No matter how I tried, I couldn’t see it in the VM. (I suspect this software only works well with RHEL and Fedora.)

SSH Transfer

Then I remembered SSH transfer (because ftp wasn’t installed, and I was too lazy to install it).

I enabled SSH on my local machine and then used the scp command to transfer files via SSH.

1
scp username@servername:/path/filename ~/Downloads/

First, I needed the IP address. In the VM, I ran ip route and got the IP: 10.0.2.2.

Then, I used the scp command to transfer.

Extracting Files

I used the tar command to extract the files.

1
tar -xzvf filename.tar.xz

Uh oh, this isn’t a gzip compressed file. How do I extract it?

SSH Transfer

I’ll use SSH transfer again. Just add -r to the scp command to transfer directories.

First Attempt

Following the steps, I placed the extracted files in /usr/src/. I copied the config file from /boot to /usr/src/linux-5.19.6/.config. However, whether I put the config file in .config/ or .config, the make menuconfig command still wouldn’t run.

Conclusion

Tinkering failed. I’ll try again later.

However, while writing this article, I noticed the original post suggested running Python directly on OpenWRT. I’ll try that if I have time.

Another Attempt

I consulted a friend who had successfully connected to the school network (though he used a regular router). He changed his router’s MAC address to his computer’s. Then, when he plugged in the network cable, the authentication page automatically forwarded to his computer. After authenticating, he had internet access, but it was through Ruijie’s web authentication.

Considering Shenlan uses Portal authentication (web page authentication), and it’s web-based, can I authenticate by modifying HTTP packets? Are there Linux commands to send HTTP packets? I searched and found curl and wget can simulate get and post requests. (So I opened Fiddler to capture packets, trying to replicate the authentication process.)

Just kidding. I connected my router to the school network, then connected my computer to the router via Ethernet cable. I entered the IP address of the authentication page, completed authentication, and the router had internet access.

Simulating HTTP GET or POST Requests with Linux Commands

Although I didn’t end up using them, I’ll document them since I found them.

  • GET Request
  1. curl
1
2
3
4
5
6
7
8
## If the URL points to a file, it can be downloaded directly
curl URL
## Display all information
curl -i URL
## Display only header information
curl -l URL
## Show the full parsing process of the GET request
curl -v URL
  1. wget
1
wget URL
  • POST Request
  1. curl
1
2
3
4
5
6
## Use the -d parameter to include parameters in the request
curl -d "param1=value1&param2=value2" "URL"

curl -d 'param1=value1&param2=value2' -X POST URL

curl -d 'param1=value1' -d 'param2=value2' -X POST  URL
  1. wget
1
2
## Use the --post-data parameter
wget --post-data 'user=name&passwd=passwd' URL

Another Conclusion

Sometimes, you can overcomplicate things. A simple solution might be overlooked if you only think about it and dismiss it without trying. This whole detour happened because I initially dismissed the “Another Attempt” part. (If my data plan wasn’t so limited, I wouldn’t have bothered trying.)

As I write this, two famous quotes come to mind:

  1. Learning without thought is labor lost; thought without learning is perilous.

  2. Experience is the mother of all knowledge.

So, sometimes you should just go for it and try, don’t let overthinking limit you!

References

Asking for Help: How to Flash Firmware for Shenlan Campus Network Portal Authentication? - Xiaomi Wireless Routers and Xiaomi Wireless Related Devices - Ensine Wireless Forum

configuration - How to fix make error “No rule to make target ‘menuconfig’” when building a kernel for Beagleboard? - Unix & Linux Stack Exchange

Setting Static IP in a Virtual Machine (CentOS Example) - yexca’Blog

Installing Git - Leo Xuefeng’s Official Website

Adding Users and Administrator Users in Linux - yexca’Blog

How to Switch Between Users in Linux System_M Li Li’s Blog - CSDN Blog_linux switch system

Using SSH to Transfer Files - SegmentFault

Linux tar Command - CoderBae

Portal Authentication Principles - Cao Shihong’s Blog

Linux Command to Send Http GET or POST Requests (curl and wget methods)_cyl937’s Blog - CSDN Blog

This post is licensed under CC BY-NC-SA 4.0 by the author.
Last updated on 2025-11-08 20:50 +0900