# US 2021/0334342 A1 · Procedural code generation for challenge code

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0334342 A1
- Document ID: US20210334342A1
- Status: Published application
- Kind: A1
- Application number: 17/084,659
- Filed: 2020-10-30
- Published: 2021-10-28
- Earliest claimed: 2020-04-27
- Assignees: Imperva, Inc.
- Applicants: Imperva, Inc.
- Inventors: Emil HERNVALL; Daniel SPÅNG
- Web page: https://patentgrep.com/patent/US20210334342A1

## CPC

- G06F 21/14: against software analysis or reverse engineering, e.g. by obfuscation
- G06F 8/40: Transformation of program code
- G06F 8/4443: {Inlining}
- G06F 9/4552: {Involving translation to a different instruction set architecture, e.g. just-in-time translation in a JVM}
- H04L 9/0869: {involving random numbers or seeds}
- H04L 9/3239: {involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD}
- H04L 9/50: {using hash chains, e.g. blockchains or hash trees}
- H04L 63/1416: {Event detection, e.g. attack signature detection}
- G06F 21/1062: {Editing}
- G06F 2221/2151: Time stamp
- H04L 2209/16: Obfuscation or hiding, e.g. involving white box
- H04L 2463/144: Detection or countermeasures against botnets
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)

## Abstract

A method by one or more computing devices for obfuscating challenge code. The method includes obtaining challenge code for interrogating a client, inserting, into the challenge code, code for obfuscating outputs that are to be generated by the client, where the code for obfuscating the outputs includes code for applying a first chain of reversible transformations to the outputs using client-generated random values, interning strings appearing in the challenge code with obfuscated strings, inserting code for deobfuscating the obfuscated strings into the challenge code, inlining function calls in the challenge code, removing function definitions that are unused in the challenge code due to the inlining, reordering the challenge code without changing the functionality of the challenge code, and providing the challenge code for execution by the client.

## Claims

### Claim 1

A method by one or more computing devices for obfuscating challenge code, the method comprising:
obtaining challenge code for interrogating a client;
inserting, into the challenge code, code for obfuscating outputs that are to be generated by the client, wherein the code for obfuscating the outputs includes code for applying a first chain of reversible transformations to the outputs using client-generated random values;
interning strings appearing in the challenge code with obfuscated strings;
inserting code for deobfuscating the obfuscated strings into the challenge code;
inlining function calls in the challenge code;
removing function definitions that are unused in the challenge code due to the inlining;
reordering the challenge code without changing the functionality of the challenge code; and
providing the challenge code for execution by the client.

### Claim 2 (depends on 1)

The method of claim 1, wherein the obfuscated strings are generated based on applying a second chain of reversible transformations to the strings appearing in the challenge code, wherein the second chain of reversible transformations is determined by a timestamp and a random seed generated by the computing device.

### Claim 3 (depends on 2)

The method of claim 2, wherein the second chain of reversible transformations includes one or more of: string reversal, interspersion of random characters in predefined locations, XOR encryption, and nibble swapping.

### Claim 4 (depends on 1)

The method of claim 1, further comprising:
periodically generating challenge codes, wherein all of the challenge codes have the same functionality but obfuscate strings and outputs differently.

### Claim 5 (depends on 1)

The method of claim 1, wherein the client-generated random values are to be determined using a client-generated random seed.

### Claim 6 (depends on 5)

The method of claim 5, wherein the client is to send the client-generated random seed to a bot detection server, wherein the bot detection server uses the random seed generated by the client to deobfuscate the obfuscated outputs.

### Claim 7 (depends on 6)

The method of claim 6, wherein the bot detection server is to determine that a violation occurred if the bot detection server determines that the client-generated random seed has been previously used by the client.

### Claim 8 (depends on 1)

The method of claim 1, wherein the challenge code is obtained based on converting a symbolic representation of the challenge code into JavaScript.

### Claim 9 (depends on 1)

The method of claim 1, wherein the interrogating the client includes obtaining information about the client, wherein the information is to be sent as output to a bot detection server for analysis.

### Claim 10

A computing device configured to obfuscate challenge code, the computing device comprising:
one or more processors; and
a non-transitory machine-readable storage medium having instructions stored therein, which when executed by the one or more processors, causes the computing device to:
obtain challenge code for interrogating a client;
insert, in the challenge code, code for obfuscating outputs that are to be generated by the client, wherein the code for obfuscating the outputs includes code for applying a first chain of reversible transformations on the outputs using client-generated random values;
intern strings appearing in the challenge code with obfuscated strings;
insert code for deobfuscating the obfuscated strings into the challenge code;
inline function calls in the challenge code;
remove function definitions that are unused in the challenge code due to the inlining;
reorder the challenge code without changing the functionality of the challenge code; and
provide the challenge code for execution by the client.

### Claim 11 (depends on 10)

The computing device of claim 10, wherein the obfuscated strings are generated based on applying a second chain of reversible transformations to the strings appearing in the challenge code, wherein the second chain of reversible transformations is determined by a timestamp and a random seed generated by the computing device.

### Claim 12 (depends on 11)

The computing device of claim 11, wherein the second chain of reversible transformations includes one or more of:
string reversal, interspersion of random characters in predefined locations, XOR encryption, and nibble swapping.

### Claim 13 (depends on 10)

The computing device of claim 10, wherein the instructions, when executed by the one or more processors, further causes the computing device to:
periodically generating challenge codes, wherein all of the challenge codes have the same functionality but obfuscate strings and outputs differently.

### Claim 14 (depends on 10)

The computing device of claim 10, wherein the client-generated random values are to be determined using a client-generated random seed.

### Claim 15

A non-transitory machine-readable storage medium that provides instructions that, if executed by a processor of a computing device, will cause said computing device to perform operations for obfuscating challenge code, the operations comprising:
obtaining challenge code for interrogating a client;
inserting, in the challenge code, code for obfuscating outputs that are to be generated by the client, wherein the code for obfuscating the outputs includes code for applying a first chain of reversible transformations on the outputs using client-generated random values;
interning strings appearing in the challenge code with obfuscated strings;
inserting code for deobfuscating the obfuscated strings into the challenge code;
inlining function calls in the challenge code;
removing function definitions that are unused in the challenge code due to the inlining;
reordering the challenge code without changing the functionality of the challenge code; and
providing the challenge code for execution by the client.

### Claim 16 (depends on 15)

The non-transitory machine-readable storage medium of claim 15, wherein the obfuscated strings are generated based on applying a second chain of reversible transformations to the strings appearing in the challenge code, wherein the second chain of reversible transformations is determined by a timestamp and a random seed generated by the computing device.

### Claim 17 (depends on 16)

The non-transitory machine-readable storage medium of claim 16, wherein the second chain of reversible transformations includes one or more of: string reversal, interspersion of random characters in predefined locations, XOR encryption, and nibble swapping.

### Claim 18 (depends on 15)

The non-transitory machine-readable storage medium of claim 15, wherein the client-generated random values are to be determined using a client-generated random seed.

### Claim 19 (depends on 15)

The non-transitory machine-readable storage medium of claim 15, wherein the challenge code is obtained based on converting a symbolic representation of the challenge code into JavaScript.

### Claim 20 (depends on 15)

The non-transitory machine-readable storage medium of claim 15, wherein the interrogating the client includes obtaining information about the client, wherein the information is to be sent as output to a bot detection server for analysis.
