util

package
v0.0.0-...-a5a94c7 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2018 License: BSD-3-Clause Imports: 14 Imported by: 8

Documentation

Index

Constants

View Source
const (
	Analyzer = iota
	APIServ
)

Enum used when loading the config in LoadCfg

View Source
const (
	EMERG int = iota
	ALERT
	CRIT
	ERR
	WARNING
	NOTICE
	INFO
	DEBUG
)

Debug levels corresponding to the syslog levels

Variables

View Source
var Log = logger{}

Log is the namespace for the logger functions

Functions

func CheckDir

func CheckDir(dir, name string)

CheckDir verifies that a Dir is a Dir and exists.

func Combine

func Combine(a, b map[string]Unit) map[string]Unit

Combine puts together two maps of string keys and unit values.

func Dedup

func Dedup(a []string) []string

Dedup deduplicates a slice

func GetJSON

func GetJSON(url string, target interface{}) error

GetJSON from valid url string gets json

func LoadCfg

func LoadCfg(cfgFile string, requester int) error

LoadCfg Opens a config file and creates a series of objects using the information located in the file. It constructs a Config, populating information for the Analyser Config, API Server Config and the DB config.

func StrMap

func StrMap(args ...string) map[string]Unit

StrMap creates a map of strings and units.

func UniqAppend

func UniqAppend(a []string, b []string) []string

UniqAppend takes the contents of one array and adds any content not present in another array.

func WriteDEAN

func WriteDEAN(w io.Writer, data interface{}) error

WriteDEAN Writes and Encodes a 'Nah Mate'.

func WriteJSON

func WriteJSON(w io.Writer, data interface{}) error

WriteJSON writes and encodes json dat.

Types

type APIServCfg

type APIServCfg struct {
	DB DBCreds `json:"db"`
}

APIServCfg Represents the Credentials used to connect to the DB as the API Server

type APKDownloadDirectory

type APKDownloadDirectory struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

APKDownloadDirectory represents a possible location an APK could be stored on.

type AnalyzerCfg

type AnalyzerCfg struct {
	DB DBCreds `json:"db"`
}

AnalyzerCfg Represents the Credentials used to connect to the DB as the Analyser

type App

type App struct {
	DBID                   int64
	ID, Store, Region, Ver string
	Path, UnpackDir        string
	Perms                  []Permission
	Hosts                  []string
	Packages               []string
	Icon                   string
	UsesReflect            bool
	APKLocationUUID        string
	APKLocationPath        string
	APKLocationRoot        string
}

App Struct for holding of information extracted from the APK

func AppByPath

func AppByPath(path string) *App

AppByPath returns an App object with the Path value initialised.

func NewApp

func NewApp(dbID int64, id, store, region, ver, apkLocationPath, apkLocationRoot, apkLocationUUID string) *App

NewApp Constructs a new app. initialising values based on the parameters passed.

func (*App) ApkPath

func (app *App) ApkPath() string

ApkPath will try and find the APK on any mounted disks in potential locations starting with the location specified in the DB, falling down to checking locations with the root of the path specidied in the DB substituted, follewed by checking each location in the config forming a path from the app version details.

func (*App) AppDir

func (app *App) AppDir() string

AppDir returns the directory of the apk and other misc files.

func (*App) Cleanup

func (app *App) Cleanup() error

Cleanup removes all directories specifed in an app object's OutDir.

func (*App) OutDir

func (app *App) OutDir() string

OutDir specifies where Apps should be unpacked to. it also creates the directory structure for that path and returns the path as a string.

func (*App) Unpack

func (app *App) Unpack() error

Unpack passes an app to apktool to disassemble an APK. the contents are stored in the path specified by OutDir.

type Config

type Config struct {
	GeoIPEndpoint string        `json:"geoipurl"`
	StorageConfig StorageConfig `json:"storage_config"`
	SystemConfig  SystemConfig  `json:"system_config"`
	Analyzer      AnalyzerCfg   `json:"analyzer"`
	APIServ       APIServCfg    `json:"apiserv"`
	DB            DBCfg         `json:"db"`
}

Config Struct for the Xray Config information relating to Dir and file locations. As well as holding DB, Analyser and APIServ Config information.

var Cfg Config

Cfg is an instance of Config that will contain DB settings as well as Dir/file locations and information.

type DBCfg

type DBCfg struct {
	Database string `json:"database"`
	User     string `json:"-"`
	Password string `json:"-"`
	Host     string `json:"host"`
	Port     int    `json:"port"`
}

DBCfg Struct for the Database Config File information

type DBCreds

type DBCreds struct {
	User     string `json:"user"`
	Password string `json:"password"`
}

DBCreds Struct for the Database Credentials

type GeoIPInfo

type GeoIPInfo struct {
	IP          string  `json:"ip"`
	CountryCode string  `json:"country_code"`
	CountryName string  `json:"country_name"`
	RegionCode  string  `json:"region_code"`
	RegionName  string  `json:"region_name"`
	City        string  `json:"city"`
	ZipCode     string  `json:"zip_code"`
	TimeZone    string  `json:"time_zone"`
	Latitude    float64 `json:"latitude"`
	Longitude   float64 `json:"longitude"`
	MetroCode   int     `json:"metro_code"`
}

GeoIPInfo stores apphosts data for geolocation

func GetHostGeoIP

func GetHostGeoIP(geoipHost, host string) ([]GeoIPInfo, error)

GetHostGeoIP grabs geo location information from hostname

type Permission

type Permission struct {
	ID        string `xml:"name,attr"`
	MaxSdkVer string `xml:"maxSdkVersion,attr"`
}

Permission Struct represents the permission information found in an APK

type StorageConfig

type StorageConfig struct {
	APKDownloadDirectories []APKDownloadDirectory `json:"apk_download_directories"`
	APKUnpackDirectory     string                 `json:"apk_unpack_directory"`
	MinimumGBRequired      string                 `json:"minimum_gb_required"`
}

StorageConfig holds the config data related to where APK data may be stored.

type SystemConfig

type SystemConfig struct {
	VMName                string `json:"vm_name"`
	DownloaderCredentials string `json:"downloader_credentials"`
}

SystemConfig represents the config info related to the system the program is running on.

type Unit

type Unit struct{}

Unit for maps in data.go

Jump to

Keyboard shortcuts

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