Skip to content

Commit

Permalink
multi-platform and setup via go install
Browse files Browse the repository at this point in the history
  • Loading branch information
Megarushing committed Apr 5, 2021
1 parent ec995be commit a6d2532
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 29 deletions.
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ default: build

build:
mkdir -p ./build
go build -o ./build/mbtc ./
strip -x ./build/mbtc
go build -o ./build/maltego-btc ./
strip -x ./build/maltego-btc

install:
@echo "Maltego directory: $(install_dir)"
@cp -vf ./build/mbtc /usr/local/bin/mbtc
@cp -vf ./config.json /usr/local/etc/mbtc.conf

@cp -vf ./build/maltego-btc /usr/local/bin/maltego-btc

.PHONY: build
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,33 @@ Set of Maltego transforms written in Go for Bitcoin addresses/wallets investigat
### Installation

Requirements:

- Maltego 4.0 or higher
- Go 1.8+

Clone repository locally and run: ```make && make install``` (tested under macOS Sierra only for now).
Installation:
- Do `go install github.com/Megarushing/maltego-btc@latest`
- Download [maltego-btc.mtz] (https://github.com/Megarushing/maltego-btc/raw/master/maltego-btc.mtz)
- In Maltego go to Import | Export > Import Config
- Point to the downloaded file and import all transforms, entities and icons
- Important: Edit each Transform BTC command line to include your path to maltego-btc, this is usually `(User Folder)/go/bin/maltego-btc`

Recommended:
- I recommend also installing maltegos library standard blockchain.com transform to use alongside

### Config options

Edit config.json and re-run installation commands. List of config options:

- ```logfile``` – path to logfile
- ```redis_url```Redis connection string (host:port)
- ```link_default``` – color of arrows from wallets and addresses
- ```link_service``` – color of arrows from large services
- ```wallet_max_size``` – max count of transactions to distinguish personal wallets and large services (default 2000)
- ```cachefile```path to cache file
- ```link_address_color``` – color of arrows from wallets and addresses
- ```link_wallet_color``` – color of arrows from wallets to wallets
- ```wallet_max_size``` – max count of transactions to download from api in one go
- ```cache_addresses``` – max number of addresses to cache
- ```cache_wallets``` – max number of wallets to cache
- ```icon_address``` – url to address entity icon
- ```icon_wallet``` – url to wallet entity icon
- ```icon_service``` – url to service entity icon
}

### Screenshots

Expand Down
12 changes: 0 additions & 12 deletions config.json

This file was deleted.

57 changes: 52 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,37 @@ var (
Type string
path string
help bool
defConfig string = "/usr/local/etc/mbtc.conf"
defFolder string = "maltego-btc"
)

func main() {
// parse flags and config
// makes config folder
appconfig, _ := os.UserConfigDir()
_ = os.MkdirAll(appconfig+
string(os.PathSeparator)+
defFolder, 0755)
// if path is defined use it, otherwise fall back to default
LogFile := config.LogFile
if LogFile == "" {
LogFile = appconfig +
string(os.PathSeparator) +
defFolder +
string(os.PathSeparator) +
"maltego-btc.log"
}
CacheFile := config.CacheFile
if CacheFile == "" {
LogFile = appconfig +
string(os.PathSeparator) +
defFolder +
string(os.PathSeparator) +
"maltego-btc.cache"
}
argc := parseArgs()
config = ParseConfig(path)

// enable logging
f, err := os.OpenFile(config.LogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
f, err := os.OpenFile(LogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
fmt.Println("Error: %v", err)
os.Exit(1)
Expand All @@ -32,20 +53,46 @@ func main() {
log.SetOutput(f)

if argc >= 3 {
LoadCache(config.CacheFile)
LoadCache(CacheFile)
list := GetTransform(query, Type)

FilterTransform(query, Type, &list)
PrintTransform(&list)
CacheGC()
SaveCache(config.CacheFile)
SaveCache(CacheFile)
} else {
flag.PrintDefaults()
os.Exit(1)
}
}

func parseArgs() (argc int) {
appconfig, _ := os.UserConfigDir()
defConfig := appconfig +
string(os.PathSeparator) +
defFolder +
string(os.PathSeparator) +
"maltego-btc.conf"

configTemplate := `
{
"logfile": "",
"cachefile": "",
"link_address_color": "#B0BEC5",
"link_wallet_color": "#107896",
"wallet_max_size": 5000,
"cache_addresses": 1000,
"cache_wallets": 5000,
"icon_address": "https://raw.githubusercontent.com/Megarushing/maltego-btc/master/assets/bitcoin.png",
"icon_wallet": "https://raw.githubusercontent.com/Megarushing/maltego-btc/master/assets/wallet.png",
"icon_service": "https://raw.githubusercontent.com/Megarushing/maltego-btc/master/assets/service.png"
}
`
if _, err := os.Stat(defConfig); err != nil {
f, _ := os.Create(defConfig)
f.WriteString(configTemplate)
f.Close()
}
// parse flags
flag.StringVar(&path, "c", defConfig, "Path to config file")
flag.BoolVar(&help, "h", false, "Print Help")
Expand Down
Binary file modified maltego-btc.mtz
Binary file not shown.

0 comments on commit a6d2532

Please sign in to comment.