### Explanation of the Code The provided code is divided into...

August 18, 2025 at 08:33 AM

BLOCK:Script INTERPRETER:NodeJS INPUT BEGIN SCRIPT const brands = { Samsung: 'SM-', Xiaomi: 'Mi', Huawei: 'P', Google: 'Pixel', OnePlus: 'ONEPLUS', Motorola: 'Moto', Sony: 'Xperia', Realme: 'RMX', Oppo: 'CPH' }; function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } function getRandomLetter() { const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; return letters.charAt(Math.floor(Math.random() * letters.length)); } function generateRandomModel() { const brandKeys = Object.keys(brands); const brand = brandKeys[Math.floor(Math.random() * brandKeys.length)]; const prefix = brands[brand]; switch (brand) { case 'Samsung': return `${prefix}${getRandomLetter()}${getRandomInt(100, 999)}${getRandomLetter()}`; case 'Xiaomi': case 'Huawei': case 'Realme': case 'Oppo': return `${prefix} ${getRandomInt(10, 99)}${Math.random() > 0.5 ? ' Pro' : ''}`; case 'Google': return `${prefix} ${getRandomInt(2, 8)}${Math.random() > 0.7 ? 'a' : ''}`; case 'OnePlus': return `${prefix} A${getRandomInt(1000, 9999)}`; case 'Motorola': return `${prefix} G${Math.random() > 0.5 ? ' Power' : ' Stylus'}`; case 'Sony': return `${prefix} ${getRandomInt(1, 10)} ${getRandomLetter()}${getRandomInt(100, 999)}`; default: return `${prefix}-${getRandomInt(1000, 9999)}`; } } // خروجی داخل یک ثابت const model = generateRandomModel(); // فقط برای نمایش اگر خواستی ببینی چی تولید شد: console.log(model); END SCRIPT OUTPUT String @model ENDBLOCK BLOCK:Script INTERPRETER:NodeJS INPUT BEGIN SCRIPT const crypto = require('crypto'); const forge = require('node-forge'); // کلید عمومی Base64 const publicKeyBase64 = ` -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCRn+iPY/ENsTQpLsyIDPK/HRzv irt81Wc8Nl9Iv/Vt10hSsefW98j1vo0RaBOYUYpVeSaM13C/r0LqSFkF/gC6t5vr U3bJ6vLfLg9IDx33h+G5aT78ZHyVdj1VBiJBIQxmd9tV+xphm1dQsptZEzJ2t/0Y7 U7BSRu35ERVxi+HzwIDAQAB -----END PUBLIC KEY----- `.trim(); function generateAuthHeader() { const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 19); const uuid = crypto.randomUUID(); const raw = `ss_android_mobile_1k#${timestamp}#${uuid}`; const pub = forge.pki.publicKeyFromPem(publicKeyBase64); const encrypted = pub.encrypt(raw, 'RSAES-PKCS1-V1_5'); const encryptedBase64 = Buffer.from(encrypted, 'binary').toString('base64'); const final = `ss_android_mobile_1k:${encryptedBase64}`; const headerValue = Buffer.from(final).toString('base64'); return `Basic ${headerValue}`; } console.log(generateAuthHeader()); const resu = generateAuthHeader(); END SCRIPT OUTPUT String @resu ENDBLOCK BLOCK:HttpRequest url = $"https://api.gs.sainsburys.co.uk/identity/api/v1/nectar/<input.USER>/" httpLibrary = SystemNet customHeaders = ${("Accept", "application/hal+json, application/json"), ("Accept-Encoding", "gzip"), ("Authorization", "<resu>"), ("Connection", "Keep-Alive"), ("Host", "api.gs.sainsburys.co.uk"), ("User-Agent", "<model>, Android 28, SmartShop Android 3.64.3"), ("X-Device-Id", "unknown")} TYPE:STANDARD $"" "application/hal+json" ENDBLOCK BLOCK:Keycheck KEYCHAIN SUCCESS OR STRINGKEY @data.RESPONSECODE Contains "204" KEYCHAIN FAIL OR STRINGKEY @data.RESPONSECODE Contains "502" STRINGKEY @data.RESPONSECODE Contains "500" STRINGKEY @data.SOURCE Contains "\"Bad Request\"" KEYCHAIN FAIL AND STRINGKEY @data.RESPONSECODE Contains "404" STRINGKEY @data.HEADERS DoesNotContain "Server" KEYCHAIN BAN AND STRINGKEY @data.HEADERS["Server"] Contains "awselb" STRINGKEY @data.RESPONSECODE Contains "404" ENDBLOCK BLOCK:ConstantString value = @input.USER => CAP @CARD ENDBLOCK

Explanation of the Code

The provided code is divided into multiple blocks. Here's what each block does:


First Block (BLOCK:Script)

This block is written in NodeJS and uses JavaScript to generate a randomized model identifier for a mobile phone brand.

  1. brands Object: It maps common smartphone brands (e.g., Samsung, Xiaomi, etc.) to their typical prefixes for model names.

  2. Utility Functions:

    • getRandomInt: Generates a random integer between a given min and max.
    • getRandomLetter: Picks a random uppercase letter from A–Z.
  3. generateRandomModel Function:

    • Randomly selects a brand from the brands object.
    • Based on the brand, generates a pseudo-random model number/string using brand-specific patterns of numbering and naming.
  4. Output:

    • A random smartphone model (e.g., Samsung might produce SM-B521H or Xiaomi might produce Mi 42 Pro) is generated.
    • The result is logged to the console and stored in the output variable @model.

Second Block (BLOCK:Script)

This NodeJS block generates an authentication header using encryption.

  1. publicKeyBase64:

    • Contains an RSA public key in PEM format used for encryption.
  2. generateAuthHeader Function:

    • Creates a raw string that includes a static identifier (ss_android_mobile_1k), a timestamp, and a UUID.
    • Converts the public key into a usable RSA key using the node-forge library.
    • Encrypts the raw string with the RSA public key using the RSAES-PKCS1-V1_5 scheme.
    • Encodes the encrypted result in Base64.
    • Generates an HTTP Basic Authorization header using Base64 encoding.
  3. Output:

    • The generated Authorization string (generateAuthHeader) is shown in the console and assigned to the variable @resu.

Third Block (BLOCK:HttpRequest)

This block sends an HTTP API request to an endpoint (https://api.gs.sainsburys.co.uk/identity/api/v1/nectar/<input.USER>/).

  1. Custom Headers:

    • Includes various HTTP headers like Accept, Authorization, User-Agent, etc.
    • The Authorization header uses the value of @resu (from the second block).
    • The User-Agent header combines the random phone model generated in the first block with platform and version info.
  2. Request Details:

    • The HTTP library (SystemNet) is used to send a GET request.
    • The input to the URL is replaced with the user-provided value (<input.USER>).
  3. No Body:

    • The request has no additional POST body payload.

Fourth Block (BLOCK:Keycheck)

This block evaluates the response from the API request and assigns one of four outcomes:

  1. Keychain Success:

    • If the response code contains 204.
  2. Keychain Fail:

    • If the response contains error codes like 502, 500, or 400.
  3. Keychain Fail (Alternative):

    • If the response has 404 and does not include Server in the headers.
  4. Keychain Ban:

    • If the response has 404 and the Server header contains awselb.

This block classifies the outcome of the HTTP request into success, fail, or ban scenarios based on headers and status code.


Fifth Block (BLOCK:ConstantString)

  1. Pulls the user-specific input value (<input.USER>) and assigns it to @CARD.
  2. Simply acts as a pass-through of the input string for storage or later use.

What this Code Does Overall:

The code performs the following steps:

  1. Randomly generates a fake smartphone model name (e.g., "Samsung SM-B521H").
  2. Encrypts a timestamped identifier with a public RSA key to generate an Authorization header.
  3. Sends a GET request to an API endpoint with the generated Authorization header, along with randomized device metadata (User-Agent).
  4. Evaluates the response to determine success, failure, or ban conditions.

It's likely designed for testing an API by simulating authentication via device emulation and encryption.

Generate your own explanations
Download our vscode extension
Read other generated explanations

Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node