File tree Expand file tree Collapse file tree 4 files changed +88
-43
lines changed
Expand file tree Collapse file tree 4 files changed +88
-43
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ Detect different types of JS obfuscation by their AST structure.
88` npm install obfuscation-detector `
99
1010## Usage
11+ ### Module
1112``` javascript
1213const fs = require (' fs' );
1314const detectObfuscation = require (' obfuscation-detector' );
@@ -18,6 +19,19 @@ const most_likely_obfuscation_type = detectObfuscation(code);
1819console .log (` Obfuscation type is probably ${ most_likely_obfuscation_type} ` );
1920```
2021
22+ ### CLI
23+ > obfuscation-detector /path/to/obfuscated.js [ stopAfterFirst]
24+
25+ Getting all matching obfuscation types for a file:
26+ > $ obfuscation-detector /path/to/obfuscated.js
27+ > [ +] function_to_array_replacements, augmented_proxied_array_function_replacements
28+
29+ Getting just the first match:
30+ > $ obfuscation-detector /path/to/obfuscated.js stop
31+ > [ +] function_to_array_replacements
32+
33+ The ` stopAfterFirst ` arguments doesn't have to be any specific string, it just needs not to be empty.
34+
2135## Supported Obfuscation Types
2236You can find descriptions of the different types in the code itself, and more info [ here] ( src/detectors/README.md ) .
2337- [ Array Replacements] ( src/detectors/arrayReplacements.js )
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+ const fs = require ( 'node:fs' ) ;
3+ const detectObfuscation = require ( __dirname + '/../src' ) ;
4+
5+ if ( require . main === module ) {
6+ try {
7+ const args = process . argv . slice ( 2 ) ;
8+ if ( args . length ) {
9+ let content = fs . readFileSync ( args [ 0 ] , 'utf-8' ) ;
10+ const stopAfterFirst = ! ! args [ 1 ] ;
11+ const obfuscationType = detectObfuscation ( content , stopAfterFirst ) ;
12+ if ( obfuscationType . length ) console . log ( '[+] ' + obfuscationType . join ( ', ' ) ) ;
13+ else console . log ( '[-] No obfuscation detected / unknown obfuscation' ) ;
14+ } else console . log ( 'Usage: obfuscation-detector /path/to/obfuscated.js [stopAfterFirst]' ) ;
15+ } catch ( e ) {
16+ console . error ( `[X] Critical Error: ${ e . message } ` ) ;
17+ }
18+ }
Original file line number Diff line number Diff line change 11{
22 "name" : " obfuscation-detector" ,
3- "version" : " 1.1.4 " ,
3+ "version" : " 1.1.5 " ,
44 "description" : " Javascript obfuscation detector" ,
55 "main" : " src/index.js" ,
66 "directories" : {
1010 "scripts" : {
1111 "test" : " node tests/testDetectors.js"
1212 },
13+ "bin" : {
14+ "obfuscation-detector" : " ./bin/obfuscation-detector.js"
15+ },
1316 "repository" : {
1417 "type" : " git" ,
1518 "url" : " git+https://github.com/PerimeterX/obfuscation-detector.git"
2831 },
2932 "homepage" : " https://github.com/PerimeterX/obfuscation-detector#readme" ,
3033 "devDependencies" : {
31- "eslint" : " ^8.43 .0" ,
34+ "eslint" : " ^8.45 .0" ,
3235 "husky" : " ^8.0.1"
3336 },
3437 "dependencies" : {
You can’t perform that action at this time.
0 commit comments