Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



   714

Malicious NPM package or how to easily catch coder or get into some project and more.

by lawsuit - 24 October, 2024 - 04:37 PM
This post is by a banned member (lawsuit) - Unhide
lawsuit  
Supreme
1.760
Posts
1.508
Threads
2 Years of service
#1
Probably most projects written in NodeJS use npm package managers and so on, and when installing you don't even look at what kind of package it is, or you download a repository or some project and just install it, run it, it seems to work, but you didn't even notice how you were already caught just installing packages.

Or when you want to install some package and accidentally made a mistake with a letter, but alas... it turned out that the package was created and you didn't even understand what you installed, you forget about it and think it's okay, just a package. And then your data is leaked or compromised. People often make mistakes when entering text.

Okay, what's the point, nodejs packages contain information about the package, the so-called package.json, and it has this interesting thing

Hidden Content
You must register or login to view this content.



This postinstall is executed immediately after downloading the package.

And with this, your system can be infected, okay, the question is, how can you catch someone then? Everything is trivially simple, we take popular libraries and create the same ones, but only with which people make mistakes. But the question is how can I come up with names with errors? ChatGPT or another AI can handle this. I asked it to generate a list of libraries with errors, for example, 100 popular libraries in which people make mistakes.


Hidden Content
You must register or login to view this content.



Below is the code, its actions are as follows: Generates a folder with a malicious npm package, which in turn executes --> Get url from the blockchain --> download file --> throw in temp --> run.

Hidden Content
You must register or login to view this content.



Its use is to go to the project folder, write npm i to install the necessary packages, and then run the script itself with the node index.js command.
The script will create a folder next to you with the package that you must download, for example, our folder is called random-lib-wdzwkcsf, go to it, open cmd or terminal, write npm login, this command will prompt us to log in to https://npmjs.com/ we log in or register if there is no account, after you have authorized yourself in the CLI, you publish your package with the npm publish command and everything your package is loaded, it will be available at the link with your name, for example,
https://npmjs.com/random-lib-wdzwkcsf if you want to change some name in the package there is package.json in it all the meta.

And anyone who tries to install the package or it was added to another project and this project is installed, gets infected, or just by writing
npm i random-lib-wdzwkcsf you get a new user in your network)

Maybe I didn't write something somewhere or forgot, I'm too lazy to change the text. Everything that is written here was invented by me. Well, or I just didn't see if someone thought of it before me.
In general, initially this idea was a must-have for me, but I got tired of everything, decided to get rid of this idea too...
Video guide (being optimized for now, so it may not be available):
[Video: https://vimeo.com/1022656184]

Hidden Content
You must register or login to view this content.




leaving a like is much appreciated and help me to keep publishing threads.
 
This post is by a banned member (Vonikles) - Unhide
Vonikles  
Registered
99
Posts
0
Threads
1 Year of service
#2
Thanks for sharing this with us
This post is by a banned member (Palarkz) - Unhide
Palarkz  
Registered
78
Posts
0
Threads
1 Year of service
#3
asd sad ad
This post is by a banned member (OheinsteinG) - Unhide
37
Posts
26
Threads
1 Year of service
#4
Thanks for sharing this with us
This post is by a banned member (jrimsix) - Unhide
jrimsix  
Registered
27
Posts
0
Threads
1 Year of service
#5
Thanks for sharing this with us

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)