A very small helper script for your dependency confusion attack which helps in checking and taking over dependency .
Note: It doesn't exploits the system, instead it should be used for generating Proof of Concept(PoC) and also you won't get blocked by npm if you use this script because no malicious payload is used in index.js.
Dependency Confusion occurs when a package manager installs a malicious package from a public registry instead of the intended private package due to conflicting or ambiguous version names. This can happen when:
- Private dependencies are named the same as public ones.
- Malicious actors publish a package with a higher version number in a public registry, causing the manager to fetch the wrong package.
For more, refer to this article - https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610 by @alxbrsn
- Should have the following packages -
npm,grep - Must be using this script on linux/unix based system
git clone https://github.com/0xaudron/dependency-takeover
cd dependency-takeover
chmod +x dependency-takeover.sh
export NPM_TOKEN=<NPM-TOKEN>
Run the following command after installation and setting up section:
./dependency-takeover.sh <dependency-name>
- Sign in/Sign up at https://www.npmjs.com
- Navigate via Click on profile avatar > Access Tokens > Generate New Token > Classic Token > Provide a
Namefor token , SelectPublishunderSelect Type - Now copy the TOKEN and do as mentioned in Installation steps.

