Code Monkey home page Code Monkey logo

srun's Introduction

srun

GitHub stars GitHub forks GitHub issues Release Build GitHub license

Srun authentication system login tools. compatible versions

Features

  • Support both command line and config file
  • Multiple IP acquisition methods
    • User Specified
    • Auto detect
    • User select
    • Query by NIC name
  • Support strict bind
  • Support multiple users login, suitable for multi-dial
  • Support multi CPU architecture
  • Support multi system

Usage

Pre-built binaries

CMD mode

./srun login -u USERNAME -p PASSWORD -i IP [-s AUTH_SERVER]

AUTH_SERVER should contain protocols, e.g. http://10.0.0.1.

Which IP to be authorized?

srun support three methods of specifying IP:

  • use -i IP to specify ip
  • use -d to auto detect ip
  • use --select-ip to select ip
specify IP

You need to check the IP address of each network interfaces in advance and choose the correct IP to be authorized.

detect IP

srun support automatic IP detection, it determines the IP address from the information returned by the authentication server.

This is useful in cases where you only have one IP address to authorize.

If you are multidialing and have multiple legitimate IPs at the same time, you need to authorize multiple IPs at the same time, this method will not authorize all IPs properly.

select IP

This method is similar to the first method, except that it saves you the trouble of manually querying all the IPs.

srun will query all the legitimate IPs in advance and then print a list of IPs for you to choose from.

$ ./srun login -u USERNAME -p PASSWORD --select-ip
Please select your IP:
    1. 192.168.226.5
    2. 10.27.196.218
    3. 172.16.150.1
    4. 192.168.128.1
    5. 198.10.0.1
2
you choose 10.27.196.218
...

Please note that when your computer has only one IP that can be authorized, we will simply omit the selection process and use this IP.

Using a Config

Usually, it is sufficient to specify the information directly using command line parameters.

In order to meet the needs of multi-dial users, srun support reading multiple user information from a config file.

./srun login -c config.json

config file template

{
    "server": "http://10.0.0.1",
    "strict_bind": false,
    "double_stack": false,
    "retry_delay": 1000,
    "retry_times": 3,
    "n": 200,
    "type": 1,
    "acid": 12,
    "os": "Windows",
    "name": "Windows 98",
    "users": [
        {
            "username": "username1",
            "password": "password1",
            "ip": "10.1.2.3"
        },
        {
            "username": "username2@cmcc",
            "password": "password2",
            "if_name": "macvlan1"
        }
    ]
}

As you can see, we support ip or if_name.

If your IP will not change, you can use ip to specify directly.

But for multi-dial, IP may be automatically assigned by DHCP and may change, at this time we suggest to use if_name to specify the corresponding NIC name, we will automatically query the IP under that NIC as the IP to be authorized.

On windows, the NIC name should be like {93123211-9629-4E04-82F0-EA2E4F221468}, use --select-ip to see.

Operator selection

Some colleges support network operator selection, which implemented by append the operator code to the username.

Operator code:

  • **电信: [chinanet, ctcc]
  • **移动: [cmcc]
  • **联通: [unicom, cucc]
  • 校园网: [xn]

For example, if you choose cmcc, just append @cmcc to your username, like 202112345@cmcc.

This code needs to be confirmed by capturing packets.

TLS support

To keep the binary as small as possible, the pre-compiled binary remove the non-essential tls support

If your authentication system uses https, You need to compile it yourself with feature tls enabled.

cargo build --features "tls" --release

License

srun © zu1k, Released under the GPL-3.0 License.

srun's People

Contributors

1328411791 avatar bobh233 avatar cxw620 avatar inkerbot avatar seiuneko avatar zu1k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

srun's Issues

0.5.3 error mipsel version

[root@Router ~]$ ./sdusrun-mipsel-unknown-linux-musl login
thread 'main' panicked at 'the long_name (second argument) should be longer than a single character, or an empty string for none', /cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/getopts-0.2.21/src/lib.rs:604:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted

error in cargo build

cargo version: cargo 1.69.0-nightly
rustc version: rustc 1.69.0-nightly (e1eaa2d5d 2023-02-06)

1675742155961

image

openwrt+MT7620+mipselpackage->error

/root$ ./sdusrun login -c config.json
read config file error: expected value at line 1 column 1
试图启动但返回如上,求助大佬
心仪的项目,果断star了

Compatible Versions

Compatible versions based on usage feedback statistics.

  • V1.18 B20190830
  • V1.18 B20210607
  • V1.18 B20210909

Can not login

[root@Router ~]$ ./sdusrun-mipsel-unknown-linux-musl login -c config.json 
login user: User {
    username: "schoolcode@unicom",
    password: "pwd",
    ip: Some(
        "10.8.135.11",
    ),
    if_name: None,
}
ChallengeResponse {
    challenge: Some(
        "0e367f2a93c10d48caca8b91a78629fa3a81b9d93cee0db97eb53e5c31395273",
    ),
    client_ip: "10.8.135.11",
    ecode: I(
        0,
    ),
    error_msg: "",
    expire: Some(
        "60",
    ),
    online_ip: "10.8.135.11",
    res: "ok",
    srun_ver: "SRunCGIAuthIntfSvr V1.18 B20201030",
    st: 1652834055,
}
will try at most 1 times...
try 1/1: failed
PortalResponse {
    server_flag: 0,
    services_intf_server_ip: "",
    services_intf_server_port: "",
    access_token: "",
    checkout_date: 0,
    ecode: S(
        "",
    ),
    error: "login_error",
    error_msg: "Nas type not found.",
    client_ip: "10.8.135.11",
    online_ip: "10.8.135.11",
    real_name: "",
    remain_flux: 0,
    remain_times: 0,
    res: "login_error",
    srun_ver: "SRunCGIAuthIntfSvr V1.18 B20201030",
    suc_msg: "",
    sysver: "",
    username: "",
    wallet_balance: 0,
    st: 1652834055,
}
login user: User {
    username: "schoolcode@unicom",
    password: "passwd",
    ip: None,
    if_name: Some(
        "eth0.5",
    ),
}
ChallengeResponse {
    challenge: Some(
        "0e367f2a93c10d48caca8b91a78629fa3a81b9d93cee0db97eb53e5c31395273",
    ),
    client_ip: "10.8.135.11",
    ecode: I(
        0,
    ),
    error_msg: "",
    expire: Some(
        "57",
    ),
    online_ip: "10.8.135.11",
    res: "ok",
    srun_ver: "SRunCGIAuthIntfSvr V1.18 B20201030",
    st: 1652834058,
}
will try at most 1 times...
try 1/1: failed
PortalResponse {
    server_flag: 0,
    services_intf_server_ip: "",
    services_intf_server_port: "",
    access_token: "",
    checkout_date: 0,
    ecode: S(
        "",
    ),
    error: "login_error",
    error_msg: "Nas type not found.",
    client_ip: "10.8.135.11",
    online_ip: "10.8.135.11",
    real_name: "",
    remain_flux: 0,
    remain_times: 0,
    res: "login_error",
    srun_ver: "SRunCGIAuthIntfSvr V1.18 B20201030",
    suc_msg: "",
    sysver: "",
    username: "",
    wallet_balance: 0,
    st: 1652834058,
}

Strict bind may not work

It seems like strict_bind will not work.

The request will follow the route table hitted, which causes strict_bind failed even if a ip is specified to bind.

Need help.

sdusrun-mipsel-unknown-linux-musl can not execute

image

cpu:

[root@Router ~]$ cat /proc/cpuinfo 
system type		: MT7621
machine			: TGNET_RN1150W
processor		: 0
cpu model		: MIPS 1004Kc V2.15
BogoMIPS		: 583.68
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 32
extra interrupt vector	: yes
hardware watchpoint	: yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa			: mips1 mips2 mips32r1 mips32r2
ASEs implemented	: mips16 dsp mt
shadow register sets	: 1
kscratch registers	: 0
core			: 0
VPE			: 0
VCED exceptions		: not available
VCEI exceptions		: not available

version for router?

Hello!
Is there any available version for a router which was installed a openwrt system?thanks.

同一if_name同时具有ipv4/ipv6地址时的问题

考虑到多拨的虚拟网卡可能会获取到ipv6的地址,而get_ip_by_if_name可能也会因此返回ipv6地址导致登陆失败
同一个if_name具有ipv4/ipv6地址时,应当选择ipv4地址作为get_challenge参数,get_ip_by_if_name函数可能需要修改一下

pub fn get_ip_by_if_name(if_name: &str) -> Option<String> {
    let ifs = get_ifs();

    for i in ifs {
        if i.0.contains(if_name) && i.1.is_ipv4(){
            return Some(i.1.to_string());
        }
    }
    None
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.