curl命令实现上网登入登出
网上有很多教怎么curl
登陆北邮校园网的方法,但是怎么登出却没有教导。而我发现最近组里的服务器被恶意挖矿,而我很遗憾地没有root
权限,因此只能采用最粗暴的断网的方式解决。同时也深入地去掌握一下curl
用法。
校园网登入
- 打开浏览器,进入校园网登陆界面。
- 进入开发者工具(
F12
)。 -
点击开发者工具中的Network选项卡,勾选其中的Preserve log选项。
-
在网页中输入用户名和密码,登录上网。随后在开发者工具面板中的Name窗口中查找跟login有关的字段(右击有copy选项)。复制下述字段中的
login
部分即可。1 2 3 4 5 6 7 8 9 10 11 12 13 14
curl 'http://10.3.8.211/login' \ -H 'Connection: keep-alive' \ -H 'Cache-Control: max-age=0' \ -H 'Upgrade-Insecure-Requests: 1' \ -H 'Origin: http://10.3.8.211' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36' \ -H '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' \ -H 'Referer: http://10.3.8.211/index' \ -H 'Accept-Language: zh-CN,zh;q=0.9' \ -H 'Cookie: SessionId=ca011a768f73ea10' \ --data-raw 'user=****&pass=******' \ --compressed \ --insecure ;
-
在bash命令行输入复制的命令。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
curl 'http://10.3.8.211/login' \ -H 'Connection: keep-alive' \ -H 'Cache-Control: max-age=0' \ -H 'Upgrade-Insecure-Requests: 1' \ -H 'Origin: http://10.3.8.211' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36' \ -H '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' \ -H 'Referer: http://10.3.8.211/index' \ -H 'Accept-Language: zh-CN,zh;q=0.9' \ -H 'Cookie: SessionId=ca011a768f73ea10' \ --data-raw 'user=******&pass=********' \ --compressed \ --insecure ;
校园网登出
-
登出的方法类似,复制登出后字段中的
logout
部分即可。1 2 3 4 5 6 7 8 9
curl 'http://10.3.8.211/logout' \ -H 'Connection: keep-alive' \ -H 'Upgrade-Insecure-Requests: 1' \ -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36' \ -H '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' \ -H 'Referer: http://10.3.8.211/login' \ -H 'Accept-Language: zh-CN,zh;q=0.9' \ -H 'Cookie: SessionId=f5af684f1bb25e73' \ --compressed \
-
在bash命令行输入复制的命令。
1 2 3 4 5 6 7 8 9 10
curl 'http://10.3.8.211/logout' \ -H 'Connection: keep-alive' \ -H 'Upgrade-Insecure-Requests: 1' \ -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36' \ -H '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' \ -H 'Referer: http://10.3.8.211/login' \ -H 'Accept-Language: zh-CN,zh;q=0.9' \ -H 'Cookie: SessionId=f5af684f1bb25e73' \ --compressed \ --insecure ;