Skip to content

Instantly share code, notes, and snippets.

@Unitech
Created May 7, 2024 16:15
Show Gist options
  • Select an option

  • Save Unitech/777fc682bd4e6db0d66b4c5d007d8bb8 to your computer and use it in GitHub Desktop.

Select an option

Save Unitech/777fc682bd4e6db0d66b4c5d007d8bb8 to your computer and use it in GitHub Desktop.

Revisions

  1. Unitech created this gist May 7, 2024.
    34 changes: 34 additions & 0 deletions glinet.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    const axios = require('axios')
    const execSync = require('child_process').execSync;

    axios.post('http://192.168.8.1/rpc', {
    method: 'challenge',
    id: '0',
    params: {
    username: 'root'
    }
    }).then((pkg) => {

    let salt = pkg.data.result.salt
    let nonce = pkg.data.result.nonce

    let cipher_pass = execSync(`mkpasswd -m md5 -S '${salt}' 'password'`).toString().trim();
    let login_hash = execSync(`echo -n 'root:${cipher_pass}:${nonce}' | md5sum | cut -d' ' -f1`).toString().\
    trim()


    let login_req = {
    "method": "login",
    "jsonrpc":"2.0",
    id: 0,
    params: {
    username: 'root',
    hash: login_hash
    }
    }

    axios.post('http://192.168.8.1/rpc', login_req).then((pkg) => {
    console.log(pkg.data.sid)
    })

    })