Dr.COM EPortal 認證
來源 https://www.txisfine.cn/archives/2b1ff890.html
Dr.COM 認證腳本合集,適用於 Dr.COM 的 Web 認證。目的是為了解決一些特殊設備無法使用瀏覽器進行認證的問題和防止設備被 Dr.COM 踢下線。
認證原理
構建 POST 請求
通過抓包分析 Dr.COM 的 Web 認證是通過 POST 提交用戶信息完成認證的,我們可以通過模擬 POST 完成認證。
General
Request URL:http://192.168.100.1/0.htm
Request Method:POST
Status Code:200 OK
Remote Address:192.168.100.1:80
Referrer Policy:no-referrer-when-downgrade
Response Headers
Accept-Ranges:bytes
Cache-Control:no-cache
Connection:keep-alive
Content-length:3573
Content-type:text/html; charset=gbk
Server:DrcomServer1.0
Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:zh-CN,zh;q=0.9
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:64
Content-Type:application/x-www-form-urlencoded
Cookie:smartdot=123456; myusername=user1; username=user1
Host:192.168.100.1
Origin:http://192.168.100.1
Referer:http://192.168.100.1/0.htm
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36
Form Data
DDDDD:user1
upass:123456
0MKKey:%B5%C7%A1%A1%C2%BC
v6ip:
主要有這樣幾個地方是有用的,一是 Request URL 這個是你需要發送請求的地址,還有就是提交的內容 DDDD(用戶名)、upass(密碼)、0MKKey(一個 KEY)、v6ip(ipv6 地址)。可能每個設備都不太一樣,不可照抄。
認證腳本
Linux 臨時認證
curl -d "DDDDD=user1&upass=123456&0MKKey=%B5%C7%A1%A1%C2%BC&v6ip=" http://192.168.1.100/0.html
批處理認證保持
需要 CURL 請先下載對應版本的 CURL。
注冊 CURL:
copy curl.exe C:\Windows\System32\curl.exe
腳本(保存為 bat 運行):
shell set url=www.baidu.com :p ping -w 1000 -n 3 %url%|find "TTL" if %errorlevel%==0 goto p if %errorlevel%==1 goto dr :dr curl -d "DDDDD=user1&upass=123456&0MKKey=%B5%C7%A1%A1%C2%BC&v6ip=" http://192.168.1.100/0.html goto p
修改 curl -d "DDDDD=user1&upass=123456&0MKKey=%B5%C7%A1%A1%C2%BC&v6ip=" http://192.168.1.100/0.html 對應的內容即可。
Python 認證保持
需要 Python 環境,因為腳本中有注釋,不做過多解釋。
腳本(保存為 py 運行):
import os import time import requests import subprocess # enter the username and password of your drcom account here username="" upass="" # urls for login # In different college, it is different # but you can find out what it is by doing: # 1. use your cellphone to connect to the wifi of your computer or of your campus # 2. visit a website, such as baidu, then the browser should jump to the login page # 3. copy the address of this login page, and paste it to the LoginUrl below. LoginUrl = "http://192.168.1.100/a30.htm" LogoutUrl = "http://192.168.1.100/F.htm" ZeroMKKey = '%B5%C7%A1%A1%C2%BC' v6ip = '' # here is the ip addresses that used to ping, so we can find out if we are online. # you can use ";" to seperate the ip addresses that you want to use to ping. PingIpAddresses = "58.83.230.159;202.108.22.5" SleepTime = 5 def login(): data = {"DDDDD":username, 'upass':upass, '0MKKey':ZeroMKKey,'v6ip':v6ip} r = requests.post(LoginUrl, data) if r.status_code == 200: print u"login successfully!" else: print u"login failed" return r def logout(): r = requests.get(LogoutUrl) if r.status_code != 200: print u"logout failed" else: print u"logout successfully" return r def ping_ips(ips): for ip in ips.split(";"): ret = subprocess.Popen("ping -n 1 -w 1 %s " % ip, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) ret.communicate() if ret.returncode == 0: print "ping %s...successful!" % ip return True else: print "ping %s...failed!" % ip return False def keep_login(): while True: if ping_ips(PingIpAddresses) == False: login() else: time.sleep(SleepTime) if __name__ == "__main__": keep_login() ```
### Shell 認證保持
Shell 文件需要 `chmod +x` 授予執行權限
#!/usr/bin/env bash while true; do if ping -c 1 www.baidu.com >/dev/null 2>&1; then echo Network is Ok! sleep 5s else echo DrComing… curl -d "DDDDD=user1&upass=123456&0MKKey=%B5%C7%A1%A1%C2%BC&v6ip=" http://192.168.100.1/0.html sleep 5s fi done
================
General
Request URL: http://172.30.0.8/0.htm
Request Method: POST
Status Code: 200 OK
Remote Address: 172.30.0.8:80
Referrer Policy: no-referrer-when-downgrade
Response Headers
Accept-Ranges: bytes
Cache-Control: no-cache
Connection: keep-alive
Content-length: 397
Content-type: text/html; charset=gbk
Server: DrcomServer1.0
Request Headers
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cache-Control: max-age=0
Connection: keep-alive
Content-Length: 50
Content-Type: application/x-www-form-urlencoded
Cookie: myusername=test9; username=test9; smartdot=123456
Host: 172.30.0.8
Origin: http://172.30.0.8
Referer: http://172.30.0.8/0.htm
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36
Form Data
DDDDD: test9
0MKKey: (unable to decode value)
upass: 123456
================= End