OpenClawSkills
GitHub

Port Scanner

Community

Check if specific ports are open on a target host.

Installation

Save as `portscan.js`. Usage: `portscan <host> <port>`.

Source Code

JavaScript
Tutorial.terminal

// portscan.js
const net = require('net');

module.exports = async function(context) {
    const host = context.args[0] || 'localhost';
    const port = parseInt(context.args[1]) || 80;
    
    return new Promise((resolve) => {
        const socket = new net.Socket();
        socket.setTimeout(2000);
        
        socket.on('connect', () => {
            resolve({ host, port, status: 'open' });
            socket.destroy();
        });
        
        socket.on('timeout', () => {
            resolve({ host, port, status: 'closed (timeout)' });
            socket.destroy();
        });
        
        socket.on('error', (err) => {
            resolve({ host, port, status: 'closed', error: err.message });
        });
        
        socket.connect(port, host);
    });
};

Live Preview

● Live Demo
Agent Session
Starting session...

How to use

  • Ensure you have the necessary dependencies installed (if any).
  • Place the file in your OpenClaw skills folder (e.g., ~/.openclaw/skills/).
  • Restart your agent or reload configuration.
  • Invoke it using the filename (without extension) as the tool name, or through natural language if the description is clear.