Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
isogrammify
Advanced tools
Substitute a function's parameters by the letters of any given word (isogram)
Have you ever wanted to turn this
!function(e,t,n,o,a,d,r,l,c,i,s,u,x){…
…into this?
!function(t,r,o,u,b,l,e,m,a,k,i,n,g){…
Well, that is exactly what isogrammify does. You pass a function and a word, and iosgram-param renames the variables for you, such that the renamed parameters form that word.
isogrammify takes three parameters,
program
(String
|Function
) The JS program to transform.
Note that this must be a complete syntactically valid script. You cannot pass a simple anonymous function. That is a syntax error. You can pass a named function, because it forms a valid program by itself.target
(String
) The string that the variables should be replaced by. Must be an isogram, that is a word without duplicate lettersraw
(Boolean
, optional) true
to return an AST instead of a string. Defaults to false
.var isogrammify = require('isogrammify');
var f = '!function(test){}()';
isogrammify(f, 'x');
//> '!function(x){}()'
var f = '!function(x,y,z){}()';
isogrammify(f, 'Yay');
//> '!function(Y,a,y){}()'
var f = function (x,y,z){};
isogrammify(f, 'Yay');
//> UnexpectedTokenError, since the function alone is not a valid program
var f = function f(x,y,z){};
isogrammify(f, 'abc');
//> function f(a,b,c){}
Oh yes, it does!
This tool was originally created as a part of minislides, where I did this:
var f = '!function(e,a,t,c,n,o,s,r,i,l,d,u,f,y,k,m){';
isogrammify(f, 'ツminïslĩdeṣ_FTWǃ');
//> '!function(ツ,m,i,n,ï,s,l,ĩ,d,e,ṣ,_,F,T,W,ǃ){'
But later, I decided against using non-ASCII characters, since they take up more than one byte per letter.
Note that ǃ
is a valid identifier, it is not an exclamation mark. Please use Mathias Bynens’s variable name validator to find valid characters, or browse the complete list.
Because the function body may contain identifiers with conflicting names. Even if you make sure that only the given variable is renamed, you may run into trouble because of inner functions with overlapping variable scopes.
For example, if you want to rename this function’s parameters to T,e,s,t
:
!function (foo, bar, baz, qux) { function t(e, foo) {e(); foo(); bar();} t(); a();}()
…you may destroy the inner bar()
call when you try to rename bar
to e
. That is because the inner function establishes a new scope for e
.
!function (T, e, s, t) { function t(e, foo) {e(); foo(); e();} t(); a();}()
// broken! ^
So you’ll need to rename that e
to something else first, and so on.
!function (T, e, s, t) { function t(something, foo) {something(); foo(); e();} t(); a();}()
FAQs
Substitute a function's parameters by the letters of any given word (isogram)
The npm package isogrammify receives a total of 1,570 weekly downloads. As such, isogrammify popularity was classified as popular.
We found that isogrammify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.