maltegogo

package module
v0.0.0-...-ca4722a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2016 License: GPL-3.0 Imports: 3 Imported by: 2

README

Introduction

Translation of the Python Maltego TDS library, allowing you to create amazingly fast Go Transforms.

Installation

go get github.com/glennzw/maltegogo

A taste of maltegogo

To get a taste of maltegogo, try this:

//Test local transform
package main

import (
	"fmt"
	"net"
	"os"

	"github.com/glennzw/maltegogo"
)

func main() {

	lt := maltegogo.ParseLocalArguments(os.Args)
	ip := lt.Value
	revIPs, _ := net.LookupAddr(ip)
	TRX := maltegogo.MaltegoTransform{}
	for _, host := range revIPs {
		NewEnt := TRX.AddEntity("maltego.DNSName", host)
		NewEnt.AddProperty("hostname", "Hostname", "stict", host)
		NewEnt.SetIconURL("http://dadgostari-hr.ir/portals/dadhor/pic/4-1.png")
	}
	fmt.Println(TRX.ReturnOutput())

}

For a TDS transform, try the following:

package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net"
	"net/http"

	"github.com/glennzw/maltegogo"
)

func dnsReverse(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		panic(err)
	}
	data := string(body)
	m := maltegogo.MaltegoMsg(data)

	ip := m.Value
	revIPs, _ := net.LookupAddr(ip)
	TRX := maltegogo.MaltegoTransform{}
	for _, host := range revIPs {
		fmt.Println(host)
		NewEnt := TRX.AddEntity("maltego.DNSName", host)
		NewEnt.AddProperty("hostname", "Hostname", "stict", host)
	}

	fmt.Fprintf(w, TRX.ReturnOutput()) // send data to client side
}

func main() {
  //Transform endpoints below (add to TDS)
	http.HandleFunc("/reverseDNS", dnsReverse)

	err := http.ListenAndServe(":9090", nil) // set listen port
	if err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}

For the above transform you'd of course need to add the :9090/reverseDNS path to your TDS server (the public one, or your own). e.g:

TDS Config

Documentation

Index

Constants

View Source
const (
	BOOKMARK_COLOR_NONE   = "-1"
	BOOKMARK_COLOR_BLUE   = "0"
	BOOKMARK_COLOR_GREEN  = "1"
	BOOKMARK_COLOR_YELLOW = "2"
	BOOKMARK_COLOR_ORANGE = "3"
	BOOKMARK_COLOR_RED    = "4"

	LINK_STYLE_NORMAL  = "0"
	LINK_STYLE_DASHED  = "1"
	LINK_STYLE_DOTTED  = "2"
	LINK_STYLE_DASHDOT = "3"

	UIM_FATAL   = "FatalError"
	UIM_PARTIAL = "PartialError"
	UIM_INFORM  = "Inform"
	UIM_DEBUG   = "Debug"
)

Set constants

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionalFields

type AdditionalFields struct {
	FieldList []Field `xml:"Field"`
}

type Entities

type Entities struct {
	EntityList []Entity `xml:"Entity"`
}

type Entity

type Entity struct {
	//Text string `xml:",chardata"`
	XMLName xml.Name         `xml:"Entity"`
	Type    string           `xml:"Type,attr"`
	AddF    AdditionalFields `xml:"AdditionalFields"`
	Value   string           `xml:"Value"`
	Weight  string           `xml:"Weight"`
}

type Field

type Field struct {
	FieldValue  string `xml:",chardata"`
	FieldName   string `xml:"Name,attr"`
	DisplayName string `xml:"DisplayName,attr"`
}

type Limit

type Limit struct {
	XMLName   xml.Name `xml:"Limits"`
	HardLimit string   `xml:"HardLimit,attr"`
	SoftLimit string   `xml:"SoftLimit,attr"`
}

type LocalTransform

type LocalTransform struct {
	Value  string
	Values map[string]string
}

4. Handle local transform from stdin

func ParseLocalArguments

func ParseLocalArguments(args []string) LocalTransform

type MaltegoEntityObj

type MaltegoEntityObj struct {
	AdditionalFields [][]string
	// contains filtered or unexported fields
}

func MaltegoEntity

func MaltegoEntity(eT string, eV string) *MaltegoEntityObj

Constructor for MaltegoEntityObj

func (*MaltegoEntityObj) AddDisplayInformation

func (m *MaltegoEntityObj) AddDisplayInformation(di, dl string)

func (*MaltegoEntityObj) AddProperty

func (m *MaltegoEntityObj) AddProperty(fieldName, displayName, matchingRule, value string)

func (*MaltegoEntityObj) ReturnEntity

func (m *MaltegoEntityObj) ReturnEntity() string

func (*MaltegoEntityObj) SetBookmark

func (m *MaltegoEntityObj) SetBookmark(bookmark string)

func (*MaltegoEntityObj) SetIconURL

func (m *MaltegoEntityObj) SetIconURL(iU string)

func (*MaltegoEntityObj) SetLinkColor

func (m *MaltegoEntityObj) SetLinkColor(color string)

func (*MaltegoEntityObj) SetLinkLabel

func (m *MaltegoEntityObj) SetLinkLabel(label string)

func (*MaltegoEntityObj) SetLinkStyle

func (m *MaltegoEntityObj) SetLinkStyle(style string)

func (*MaltegoEntityObj) SetLinkThickness

func (m *MaltegoEntityObj) SetLinkThickness(thick int)

func (*MaltegoEntityObj) SetNote

func (m *MaltegoEntityObj) SetNote(note string)

func (*MaltegoEntityObj) SetType

func (m *MaltegoEntityObj) SetType(eT string)

2. Setter and Getter functions for MaltegoEntityObjs

func (*MaltegoEntityObj) SetValue

func (m *MaltegoEntityObj) SetValue(eV string)

func (*MaltegoEntityObj) SetWeight

func (m *MaltegoEntityObj) SetWeight(w int)

type MaltegoMessage

type MaltegoMessage struct {
	XMLName xml.Name `xml:"MaltegoMessage"`
	MTRM    MaltegoTransformRequestMessage
}

Here we have the XML structs to map to

type MaltegoMsgObj

type MaltegoMsgObj struct {
	Value             string
	Weight            string
	Slider            string //Forgot to implement the XML for this
	Type              string
	Properties        map[string]string
	TransformSettings map[string]string //Forgot to implement the XML for this
}

Code to parse Maltego XML Input

func MaltegoMsg

func MaltegoMsg(MaltegoXML string) MaltegoMsgObj

Constructor for MaltegoMsg

func (*MaltegoMsgObj) GetProperty

func (m *MaltegoMsgObj) GetProperty(p string) string

func (*MaltegoMsgObj) GetTransformSetting

func (m *MaltegoMsgObj) GetTransformSetting(t string) string

type MaltegoTransform

type MaltegoTransform struct {
	UIMessages [][]string
	// contains filtered or unexported fields
}

Next we handle the MalteoTransform class from Python

func (*MaltegoTransform) AddEntity

func (m *MaltegoTransform) AddEntity(enType, enValue string) *MaltegoEntityObj

func (*MaltegoTransform) AddException

func (m *MaltegoTransform) AddException(exceptionString, code string)

func (*MaltegoTransform) AddUIMessage

func (m *MaltegoTransform) AddUIMessage(message, messageType string)

func (*MaltegoTransform) ReturnOutput

func (m *MaltegoTransform) ReturnOutput() string

func (*MaltegoTransform) ThrowExceptions

func (m *MaltegoTransform) ThrowExceptions() string

type MaltegoTransformRequestMessage

type MaltegoTransformRequestMessage struct {
	XMLName  xml.Name `xml:"MaltegoTransformRequestMessage"`
	Entities Entities `xml:"Entities"`
	Limits   Limit    `xml:"Limits"`
}

Directories

Path Synopsis
Test local transform
Test local transform

Jump to

Keyboard shortcuts

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