Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save timperrett/e3370a8154bd300c05fc386dc19d0dde to your computer and use it in GitHub Desktop.
Save timperrett/e3370a8154bd300c05fc386dc19d0dde to your computer and use it in GitHub Desktop.

Revisions

  1. @orther orther revised this gist Mar 30, 2022. 2 changed files with 104 additions and 113 deletions.
    115 changes: 2 additions & 113 deletions disable-tmobile-5g-home-internet-rotuer-wifi.md
    Original file line number Diff line number Diff line change
    @@ -4,116 +4,5 @@ This script can be copied into the browser console and used to disable wifi on t

    1. Go to [http://192.168.12.1](http://192.168.12.1)
    2. Open dev console (on mac `[cmd]+[opt]+i`)
    3. Paste the below code with the `password` value replaced with the actual password

    <details>
    <summary><b>Expand To See Code</b></summary>

    ```js
    async function tmobileHomeInternetDisableWifi() {
    const username = 'admin'
    const password = 'REPLACE-WITH-REAL-PASSWORD' // <<------- Make sure to replace this

    async function loginTmobile(username, password) {
    const resp = await fetch("http://192.168.12.1/TMI/v1/auth/login", {
    "headers": {
    "accept": "application/json",
    "accept-language": "en-US,en;q=0.9",
    "cache-control": "max-age=0",
    "content-type": "text/plain;charset=UTF-8"
    },
    "referrer": "http://192.168.12.1/home",
    "referrerPolicy": "strict-origin-when-cross-origin",
    // "body": "{\"username\":\"admin\",\"password\":\"tug.ecologist.cover.facility\"}",
    body: JSON.stringify({ username, password }),
    "method": "POST",
    "mode": "cors",
    "credentials": "include"
    });

    console.log('resp', { headers: resp.headers })

    if (resp.ok) {
    const jsonValue = await resp.json(); // Get JSON value from the response body
    const authToken = jsonValue?.auth?.token
    return Promise.resolve(authToken);
    } else {
    return Promise.reject('Failed to get JSON respon value');
    }
    }

    async function getAccessPointConfig(authToken) {
    const resp = await fetch("http://192.168.12.1/TMI/v1/network/configuration?get=ap", {
    headers: {
    "accept": "application/json",
    "accept-language": "en-US,en;q=0.9",
    "authorization": `Bearer ${authToken}`,
    "cache-control": "max-age=0"
    },
    referrer: "http://192.168.12.1/networks",
    referrerPolicy: "strict-origin-when-cross-origin",
    body: null,
    method: "GET",
    mode: "cors",
    credentials: "include"
    });

    console.log('ap config resp', resp)

    if (resp.ok) {
    const jsonValue = await resp.json(); // Get JSON value from the response body
    return Promise.resolve(jsonValue);
    } else {
    return Promise.reject('Failed to get JSON respon value');
    }
    }

    function disableWifiProps(apConfig) {
    const configWifiOff = {
    ...apConfig,
    '2.4ghz': { ...apConfig['2.4ghz'], isRadioEnabled: false },
    '5.0ghz': { ...apConfig['5.0ghz'], isRadioEnabled: false },
    }
    console.log('configWifiOff', configWifiOff)
    return configWifiOff
    }

    async function disableAccessPointWifi(authToken) {
    const apConfig = await getAccessPointConfig(authToken)
    const wifiOffConfig = disableWifiProps(apConfig)

    const resp = await fetch("http://192.168.12.1/TMI/v1/network/configuration?set=ap", {
    headers: {
    "accept": "application/json",
    "accept-language": "en-US,en;q=0.9",
    "authorization": `Bearer ${authToken}`,
    "cache-control": "max-age=0",
    "content-type": "text/plain;charset=UTF-8"
    },
    referrer: "http://192.168.12.1/networks",
    referrerPolicy: "strict-origin-when-cross-origin",
    body: JSON.stringify(wifiOffConfig),
    method: "POST",
    mode: "cors",
    credentials: "include"
    });

    console.log('ap config resp', resp)

    if (resp.ok) {
    const jsonValue = await resp.json(); // Get JSON value from the response body
    return Promise.resolve(jsonValue);
    } else {
    return Promise.reject('Failed to get JSON respon value');
    }
    }

    const authToken = await loginTmobile(username, password)
    const result = await disableAccessPointWifi(authToken)
    return result
    }
    ```
    </details>
    4. Disable wifi by type `tmobileHomeInternetDisableWifi()` and hitting enter to run the code.
    3. Copy the code from the below JS file and with the `password` value updated to be your actual password and hit enter
    4. Call the code by typing `tmobileHomeInternetDisableWifi()` and hitting enter
    102 changes: 102 additions & 0 deletions disable-tmobile-5g-home-internet-router-wifi.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,102 @@
    async function tmobileHomeInternetDisableWifi() {
    const username = 'admin'
    const password = 'REPLACE-WITH-REAL-PASSWORD' // <<------- Make sure to replace this

    async function loginTmobile(username, password) {
    const resp = await fetch("http://192.168.12.1/TMI/v1/auth/login", {
    "headers": {
    "accept": "application/json",
    "accept-language": "en-US,en;q=0.9",
    "cache-control": "max-age=0",
    "content-type": "text/plain;charset=UTF-8"
    },
    "referrer": "http://192.168.12.1/home",
    "referrerPolicy": "strict-origin-when-cross-origin",
    // "body": "{\"username\":\"admin\",\"password\":\"tug.ecologist.cover.facility\"}",
    body: JSON.stringify({ username, password }),
    "method": "POST",
    "mode": "cors",
    "credentials": "include"
    });

    console.log('resp', { headers: resp.headers })

    if (resp.ok) {
    const jsonValue = await resp.json(); // Get JSON value from the response body
    const authToken = jsonValue?.auth?.token
    return Promise.resolve(authToken);
    } else {
    return Promise.reject('Failed to get JSON respon value');
    }
    }

    async function getAccessPointConfig(authToken) {
    const resp = await fetch("http://192.168.12.1/TMI/v1/network/configuration?get=ap", {
    headers: {
    "accept": "application/json",
    "accept-language": "en-US,en;q=0.9",
    "authorization": `Bearer ${authToken}`,
    "cache-control": "max-age=0"
    },
    referrer: "http://192.168.12.1/networks",
    referrerPolicy: "strict-origin-when-cross-origin",
    body: null,
    method: "GET",
    mode: "cors",
    credentials: "include"
    });

    console.log('ap config resp', resp)

    if (resp.ok) {
    const jsonValue = await resp.json(); // Get JSON value from the response body
    return Promise.resolve(jsonValue);
    } else {
    return Promise.reject('Failed to get JSON respon value');
    }
    }

    function disableWifiProps(apConfig) {
    const configWifiOff = {
    ...apConfig,
    '2.4ghz': { ...apConfig['2.4ghz'], isRadioEnabled: false },
    '5.0ghz': { ...apConfig['5.0ghz'], isRadioEnabled: false },
    }
    console.log('configWifiOff', configWifiOff)
    return configWifiOff
    }

    async function disableAccessPointWifi(authToken) {
    const apConfig = await getAccessPointConfig(authToken)
    const wifiOffConfig = disableWifiProps(apConfig)

    const resp = await fetch("http://192.168.12.1/TMI/v1/network/configuration?set=ap", {
    headers: {
    "accept": "application/json",
    "accept-language": "en-US,en;q=0.9",
    "authorization": `Bearer ${authToken}`,
    "cache-control": "max-age=0",
    "content-type": "text/plain;charset=UTF-8"
    },
    referrer: "http://192.168.12.1/networks",
    referrerPolicy: "strict-origin-when-cross-origin",
    body: JSON.stringify(wifiOffConfig),
    method: "POST",
    mode: "cors",
    credentials: "include"
    });

    console.log('ap config resp', resp)

    if (resp.ok) {
    const jsonValue = await resp.json(); // Get JSON value from the response body
    return Promise.resolve(jsonValue);
    } else {
    return Promise.reject('Failed to get JSON respon value');
    }
    }

    const authToken = await loginTmobile(username, password)
    const result = await disableAccessPointWifi(authToken)
    return result
    }
  2. @orther orther renamed this gist Mar 30, 2022. 1 changed file with 0 additions and 0 deletions.
  3. @orther orther created this gist Mar 30, 2022.
    119 changes: 119 additions & 0 deletions disable-tmobile-5g-home-internet-rotuer-wifi.
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,119 @@
    This script can be copied into the browser console and used to disable wifi on the T-Mobile 5G Home Internet router. The web interface for the router doesn't allow you to disable it.

    ## Steps

    1. Go to [http://192.168.12.1](http://192.168.12.1)
    2. Open dev console (on mac `[cmd]+[opt]+i`)
    3. Paste the below code with the `password` value replaced with the actual password

    <details>
    <summary><b>Expand To See Code</b></summary>

    ```js
    async function tmobileHomeInternetDisableWifi() {
    const username = 'admin'
    const password = 'REPLACE-WITH-REAL-PASSWORD' // <<------- Make sure to replace this

    async function loginTmobile(username, password) {
    const resp = await fetch("http://192.168.12.1/TMI/v1/auth/login", {
    "headers": {
    "accept": "application/json",
    "accept-language": "en-US,en;q=0.9",
    "cache-control": "max-age=0",
    "content-type": "text/plain;charset=UTF-8"
    },
    "referrer": "http://192.168.12.1/home",
    "referrerPolicy": "strict-origin-when-cross-origin",
    // "body": "{\"username\":\"admin\",\"password\":\"tug.ecologist.cover.facility\"}",
    body: JSON.stringify({ username, password }),
    "method": "POST",
    "mode": "cors",
    "credentials": "include"
    });

    console.log('resp', { headers: resp.headers })

    if (resp.ok) {
    const jsonValue = await resp.json(); // Get JSON value from the response body
    const authToken = jsonValue?.auth?.token
    return Promise.resolve(authToken);
    } else {
    return Promise.reject('Failed to get JSON respon value');
    }
    }

    async function getAccessPointConfig(authToken) {
    const resp = await fetch("http://192.168.12.1/TMI/v1/network/configuration?get=ap", {
    headers: {
    "accept": "application/json",
    "accept-language": "en-US,en;q=0.9",
    "authorization": `Bearer ${authToken}`,
    "cache-control": "max-age=0"
    },
    referrer: "http://192.168.12.1/networks",
    referrerPolicy: "strict-origin-when-cross-origin",
    body: null,
    method: "GET",
    mode: "cors",
    credentials: "include"
    });

    console.log('ap config resp', resp)

    if (resp.ok) {
    const jsonValue = await resp.json(); // Get JSON value from the response body
    return Promise.resolve(jsonValue);
    } else {
    return Promise.reject('Failed to get JSON respon value');
    }
    }

    function disableWifiProps(apConfig) {
    const configWifiOff = {
    ...apConfig,
    '2.4ghz': { ...apConfig['2.4ghz'], isRadioEnabled: false },
    '5.0ghz': { ...apConfig['5.0ghz'], isRadioEnabled: false },
    }
    console.log('configWifiOff', configWifiOff)
    return configWifiOff
    }

    async function disableAccessPointWifi(authToken) {
    const apConfig = await getAccessPointConfig(authToken)
    const wifiOffConfig = disableWifiProps(apConfig)

    const resp = await fetch("http://192.168.12.1/TMI/v1/network/configuration?set=ap", {
    headers: {
    "accept": "application/json",
    "accept-language": "en-US,en;q=0.9",
    "authorization": `Bearer ${authToken}`,
    "cache-control": "max-age=0",
    "content-type": "text/plain;charset=UTF-8"
    },
    referrer: "http://192.168.12.1/networks",
    referrerPolicy: "strict-origin-when-cross-origin",
    body: JSON.stringify(wifiOffConfig),
    method: "POST",
    mode: "cors",
    credentials: "include"
    });

    console.log('ap config resp', resp)

    if (resp.ok) {
    const jsonValue = await resp.json(); // Get JSON value from the response body
    return Promise.resolve(jsonValue);
    } else {
    return Promise.reject('Failed to get JSON respon value');
    }
    }

    const authToken = await loginTmobile(username, password)
    const result = await disableAccessPointWifi(authToken)
    return result
    }
    ```

    </details>

    4. Disable wifi by type `tmobileHomeInternetDisableWifi()` and hitting enter to run the code.