The developers SwissKnife. Do conversions and generations right out of vs code. Extendable with user scripts.
Currently Available Scripts
Usage
You can invoke the dedicated command pallete with ctrl+shift+9
for windows or cmd+shift+9
for mac (when focusing the editor)
The conversions will only use the selected text by default. If no text is selected the entire content of the editor will be used. It supports multi selection and will run the script for each selection individually
Macbook Touchbar Support You can also invoke the swissknife extension directly from the macbook’s touchbar.
Scripts Details
Crypto Currency Value
Uses the API from Cryptonator. You can specify conversions directly from the text like:
1btc to eur
For a list of supported currencies check here
Identify Hash
The outcome of the operation may return multiple values, as a hashes from different algorithms have the same output format. Still we organize the hashes from top down by most relevant.
HTTP(S) Server
The servers log all requests received into the “Output” window of VSCode (You can show it by going to view -> Output in the menu). Then on the right of the window (where usually has the value “Tasks”), filter by “Swissknife Server”
Privacy Note
One of the main purposes of this extension is to stop pasting data, or trusting generated data from random websites. The extension avoids doing external web requests or logging data, for privacy. But there are some operations where external requests are needed:
Writing Scripts
Swissknife will automatically load all scripts in its user scripting folder and you can find it by executing a command. Open you command pallete and type “Open swissknife users script folder”. Or just start typing it as it will eventually be suggested. This is the folder where you can create your custom scripts.
To start a new script you can also use a command provided by the extension. Open swissknife picker and type “New swissknife script”.
Script Reloading
Scripts are loaded into the extension when initializing VS Code, so when you create a custom script you’ll need to reload the scripts. To make it easier for development, the extension has a command “Reload Swissknife Scripts” that you can call from the VS Code command pallette (do not confuse with the swissknife’s script launcher).
Remember that everytime you do a change in a script in the user script folder you need to reload scripts.
Starting Template
You can chose the TS or JS version according to what you’re more comfortable with. TS will be more complex as you need to transpile it to JS. We’ll go with Javascript. This is the base structure of the script:
Object.defineProperty(exports, “__esModule”, { value: true });
exports.doSomething = async (text, context) => {
return new Promise((resolve, reject) => {
resolve(text.replace(/a/g, “b”));
});
}
const scripts = [
{
title: “My Script”,
detail: “This script does something”,
cb: (context) => context.replaceRoutine(exports.doSomething)
},
]
exports.default = scripts;
This is the basic template to create scripts. In this file we created a script called “My Script”. You can have as much scripts as you want per file. Its just a way of organization 🙂 As you can see at the end, the structure for a script consists on 3 properties: title, detail and cb. The first two are self explanatory. cb is the code that will be called when you script runs. And by default swissknife gives you a few methods to help getting started, through the variable ‘context’. The method doSomething is just replacing a’s with b’s
Context
In context you have some nice methods to help you out, and you should use them whenever possible.
The use of this methods is optional. If you feel that its easier to just work directly with vscode api you can also do it:
Object.defineProperty(exports, “__esModule”, { value: true });
const scripts = [
{
title: “My Script2”,
detail: “This script does something”,
cb: (context) => {
console.log(context)
const editor = context.vscode.window.activeTextEditor;
editor.edit((edit) => {
edit.insert(editor.selection.myactive, “Doing stuff”)
});
}
},
]
exports.default = scripts;
More Examples
Object.defineProperty(exports, “__esModule”, { value: true });
//Uses the context.modules to reuse existing code. Starts an http server
exports.startServer = async (context) => {
context.modules.lib.server.start({ port: 1234 })
}
//uses context.userModules to invoke another user script
//there will be an entry in context.userModules with the name of the file with scripts loaded
//all exported methods are accessible…
//If invoking a script remember to send the right params, like the context
exports.anotherUserScript = async (context) => {
context.modules.othermodule.hellowWorld(context);
}
//Ask user for input
exports.askInput = async (context) => {
return new Promise((resolve, reject) => {
context.vscode.window.showInputBox({ prompt: “Say something” }).then(answer => {
resolve(answer);
});
});
}
const scripts = [
{
title: “Ask Input”,
detail: “Asks user input and adds it to the editor”,
cb: (context) => context.insertRoutine(this.askInput)
},
{
title: “Start server on port 1234”,
detail: “Starts a server on port 1234”,
cb: (context) => this.startServer(context)
},
{
title: “Call Another User script”,
detail: “Calls Another User script”,
cb: (context) => context.insertRoutine(this.anotherUserScript)
},
]
exports.default = scripts;
Kali Linux 2024.4, the final release of 2024, brings a wide range of updates and…
This Go program applies a lifetime patch to PowerShell to disable ETW (Event Tracing for…
GPOHunter is a comprehensive tool designed to analyze and identify security misconfigurations in Active Directory…
Across small-to-medium enterprises (SMEs) and managed service providers (MSPs), the top priority for cybersecurity leaders…
The free and open-source security platform SecHub, provides a central API to test software with…
Don't worry if there are any bugs in the tool, we will try to fix…