malnet

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 7 Imported by: 0

README

malnet

net wrapper library with interesting functions for creating malicious code

codebeat Go Report Card

Installation

go get github.com/41337/malnet

examples

example of a client getting a list of available files from the server

  • note: the inverse is also possible, a server can receive a list of files from a client

client.go

package main

import (
	"fmt"
	"log"
	"net"

	"github.com/41337/malnet"
)

func main() {
	// connect with server
	conn, err := net.Dial("tcp", ":1337")
	if err != nil {
		log.Fatalln(err)
	}

	// if you receive a list of files then
	if files, err := malnet.ReceiveFileList(conn); err == nil {
		// for each file in files
		for _, file := range files {
			fmt.Printf("Name: %s, Is Dir: %v\n", file.Filename, file.IsDir)
		}
	} else {
		log.Fatalln(err)
	}
}

server.go

package main

import (
	"log"
	"net"

	"github.com/41337/malnet"
)

func main() {
	// start listening
	listener, err := net.Listen("tcp", ":1337")
	if err != nil {
		log.Fatalln(err)
	}

	for {
		// accept connections
		conn, err := listener.Accept()
		if err != nil {
			log.Fatalln(err)
		}

		// i send the list of local files for the connection
		err = malnet.SendFileList(conn)
		if err != nil {
			log.Fatalln(err)
		}
	}

}

Documentation

Overview

net wrapper library with interesting functions for creating malicious code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReciveFile

func ReciveFile(connection net.Conn) error

function to receive file from a connection arguments are: connection=as the name says, the connection handler standard error handling, will come nil if it works

func SendFile

func SendFile(path string, connection net.Conn) error

function to send files over a connection arguments are: path=path to the file to be send, connection=as the name says, the connection handler standard error handling, will come nil if it works

func SendFileList

func SendFileList(path string, connection net.Conn) error

function to list local files and send this list over connection arguments are: path=path where the files will be listed, connection=as the name says, the connection handler standard error handling, will come nil if it works

Types

type FileList

type FileList struct {
	Filename string
	IsDir    bool
}

typing to a list with file/directory name and confirming if this item is indeed a directory or not

func ReceiveFileList

func ReceiveFileList(connection net.Conn) ([]FileList, error)

function to which receives a list of files from the connection then returns it in the file|isDir format arguments are: connection=as the name says, the connection handler standard error handling, will come nil if it works

Jump to

Keyboard shortcuts

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