Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
commandlinefu
Advanced tools
Simple nodejs module to easily get commandlinefu.com snippets in JSON format.
npm install commandlinefu
With nodejs:
// clfu.js
const clfu = require("commandlinefu");
clfu()
.then((res) => console.log(res))
.catch((e) => e);
node clfu.js
output:
{
"id": "5427",
"command": "curl ifconfig.me",
"summary": "Get your external IP address",
"votes": "262",
"url": "http://www.commandlinefu.com/commands/view/5427/get-your-external-ip-address"
}
This object will be referred as responseObject
from now on.
By default (no argument) it will returns a random responseObject
.
You can pass a string as argument, in which case it will return an Array[] of responseObject{}.
Available arguments:
responseObject
(which tbh doesn't change much over time)responseObject
related to $var
Example of dynamic search:
const userInput = "ssh"; // here you got user input as string
clfu(`search:${userInput}`)
.then((res) => console.log(res))
.catch((e) => e);
/* Outputs an array like :
[
{
"id": "24887",
"command": "ssh -L8888:localhost:80 -i nov15a.pem ubuntu@123.21.167.60",
"summary": "port forwarding",
"votes": "1",
"url": "http://www.commandlinefu.com/commands/view/24887/port-forwarding"
},
{
"id": "24879",
"command": "rsync -e 'ssh -i /root/my.pem' -avz /mysql/db/data_summary.* ec2-1-2-4-9.compute-1.amazonaws.com:/mysql/test/",
"summary": "rsync using pem file",
"votes": "0",
"url": "http://www.commandlinefu.com/commands/view/24879/rsync-using-pem-file"
},
{
"id": "24863",
"command": "cat myFile.json | ssh root@remoteSftpServer -o \"ProxyCommand=nc.openbsd -X connect -x proxyhost:proxyport %h %p\" 'cat > myFile.json'",
"summary": "SFTP upload through HTTPS proxy",
"votes": "0",
"url": "http://www.commandlinefu.com/commands/view/24863/sftp-upload-through-https-proxy"
}
]
*/
I originally wrote this for my discord bot. If you want to use this module for your own, feel free to check my (dirty) implementation :
Nodejs make it easy to wrap functions into a custom CLI suiting your needs. In terminal :
mkdir myCli
cd ./myCli
npm init # you can spam 'return' key for now
npm i commandlinefu # grab this module
touch index.js
This is the content of your index.js
:
const clfu = require("commandlinefu");
const commandlinefu = async () => {
if (!process.argv.slice(2)[0]) {
return await clfu()
.then(res => console.log(res.command))
.catch(e => console.error(e));
}
else if (process.argv.slice(2)[0]) {
return await clfu(process.argv.slice(2)[0])
.then(res => console.log(res))
.catch(e => console.error(e));
};
commandlinefu();
That's it! Now back into your terminal:
node index.js # calling clfu without argument
ps auxw | awk '/(apache|httpd)/{print"strace -F -p " $2}' | sh # this is 'res.command' printed in stdout
node index.js search:ssh # calling clfu with "search:ssh" argument, we get an array like we're supposed to :
[
{
id: '24887',
command: 'ssh -L8888:localhost:80 -i nov15a.pem ubuntu@123.21.167.60',
summary: 'port forwarding',
votes: '1',
url: 'http://www.commandlinefu.com/commands/view/24887/port-forwarding'
},
{
id: '24879',
command: "rsync -e 'ssh -i /root/my.pem' -avz /mysql/db/data_summary.* ec2-1-2-4-9.compute-1.amazonaws.com:/mysql/test/",
summary: 'rsync using pem file',
votes: '0',
url: 'http://www.commandlinefu.com/commands/view/24879/rsync-using-pem-file'
},
{...more objects}
]
This is the basic principle. You can parse & do your stuff with those arrays in the else if
block of aforementioned index.js
file.
If you never used process.argv
before, this read should get you started
If you're looking for out-of-the-box CLI instead of a reusable function, it may be worth checking this repo.
At least it helped me decipher commandlinefu.com API endpoints, so thank you nire0510 :)
FAQs
Easily use commandlinefu.com API with nodejs
We found that commandlinefu 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.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.