mysql

package
v3.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2024 License: MIT, Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Warning - This is generated code

Warning - This is generated code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDSN

func BuildDSN(opts MySQLOptions) (string, error)

BuildDSN builds a MySQL data source name (DSN) from the given options. @example ```javascript const mysql = require('nuclei/mysql'); const options = new mysql.MySQLOptions(); options.Host = 'acme.com'; options.Port = 3306; const dsn = mysql.BuildDSN(options); ```

Types

type MySQLClient

type MySQLClient struct{}

MySQLClient is a client for MySQL database. Internally client uses go-sql-driver/mysql driver. @example ```javascript const mysql = require('nuclei/mysql'); const client = new mysql.MySQLClient; ```

func (*MySQLClient) Connect

func (c *MySQLClient) Connect(host string, port int, username, password string) (bool, error)

Connect connects to MySQL database using given credentials. If connection is successful, it returns true. If connection is unsuccessful, it returns false and error. The connection is closed after the function returns. @example ```javascript const mysql = require('nuclei/mysql'); const client = new mysql.MySQLClient; const connected = client.Connect('acme.com', 3306, 'username', 'password'); ```

func (*MySQLClient) ConnectWithDSN

func (c *MySQLClient) ConnectWithDSN(dsn string) (bool, error)

ConnectWithDSN connects to MySQL database using given DSN. we override mysql dialer with fastdialer so it respects network policy If connection is successful, it returns true. @example ```javascript const mysql = require('nuclei/mysql'); const client = new mysql.MySQLClient; const connected = client.ConnectWithDSN('username:password@tcp(acme.com:3306)/'); ```

func (*MySQLClient) ExecuteQuery

func (c *MySQLClient) ExecuteQuery(host string, port int, username, password, query string) (*utils.SQLResult, error)

ExecuteQuery connects to Mysql database using given credentials and executes a query on the db. @example ```javascript const mysql = require('nuclei/mysql'); const result = mysql.ExecuteQuery('acme.com', 3306, 'username', 'password', 'SELECT * FROM users'); log(to_json(result)); ```

func (*MySQLClient) ExecuteQueryOnDB

func (c *MySQLClient) ExecuteQueryOnDB(host string, port int, username, password, dbname, query string) (*utils.SQLResult, error)

ExecuteQuery connects to Mysql database using given credentials and executes a query on the db. @example ```javascript const mysql = require('nuclei/mysql'); const result = mysql.ExecuteQueryOnDB('acme.com', 3306, 'username', 'password', 'dbname', 'SELECT * FROM users'); log(to_json(result)); ```

func (*MySQLClient) ExecuteQueryWithOpts

func (c *MySQLClient) ExecuteQueryWithOpts(opts MySQLOptions, query string) (*utils.SQLResult, error)

ExecuteQueryWithOpts connects to Mysql database using given credentials and executes a query on the db. @example ```javascript const mysql = require('nuclei/mysql'); const options = new mysql.MySQLOptions(); options.Host = 'acme.com'; options.Port = 3306; const result = mysql.ExecuteQueryWithOpts(options, 'SELECT * FROM users'); log(to_json(result)); ```

func (*MySQLClient) FingerprintMySQL

func (c *MySQLClient) FingerprintMySQL(host string, port int) (MySQLInfo, error)

returns MySQLInfo when fingerpint is successful @example ```javascript const mysql = require('nuclei/mysql'); const info = mysql.FingerprintMySQL('acme.com', 3306); log(to_json(info)); ```

func (*MySQLClient) IsMySQL

func (c *MySQLClient) IsMySQL(host string, port int) (bool, error)

IsMySQL checks if the given host is running MySQL database. If the host is running MySQL database, it returns true. If the host is not running MySQL database, it returns false. @example ```javascript const mysql = require('nuclei/mysql'); const isMySQL = mysql.IsMySQL('acme.com', 3306); ```

type MySQLInfo

type MySQLInfo struct {
	Host      string               `json:"host,omitempty"`
	IP        string               `json:"ip"`
	Port      int                  `json:"port"`
	Protocol  string               `json:"protocol"`
	TLS       bool                 `json:"tls"`
	Transport string               `json:"transport"`
	Version   string               `json:"version,omitempty"`
	Debug     plugins.ServiceMySQL `json:"debug,omitempty"`
	Raw       string               `json:"metadata"`
}

MySQLInfo contains information about MySQL server. this is returned when fingerprint is successful

type MySQLOptions

type MySQLOptions struct {
	Host     string // Host is the host name or IP address of the MySQL server.
	Port     int    // Port is the port number on which the MySQL server is listening.
	Protocol string // Protocol is the protocol used to connect to the MySQL server (ex: "tcp").
	Username string // Username is the user name used to authenticate with the MySQL server.
	Password string // Password is the password used to authenticate with the MySQL server.
	DbName   string // DbName is the name of the database to connect to on the MySQL server.
	RawQuery string // QueryStr is the query string to append to the DSN (ex: "?tls=skip-verify").
	Timeout  int    // Timeout is the timeout in seconds for the connection to the MySQL server.
}

MySQLOptions defines the data source name (DSN) options required to connect to a MySQL database. along with other options like Timeout etc @example ```javascript const mysql = require('nuclei/mysql'); const options = new mysql.MySQLOptions(); options.Host = 'acme.com'; options.Port = 3306; ```

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL