From 2cfe2b8f8fbaa69f2b29a6c6d3b1903f976ff896 Mon Sep 17 00:00:00 2001 From: Jordan Date: Sat, 1 Feb 2014 16:35:16 -0600 Subject: [PATCH] Cleaning up documentation Added targets, groups, group_target tables --- controllers/route.go | 26 -------------------------- db/db.go | 7 ++++++- models/models.go | 13 ++++++++++--- 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/controllers/route.go b/controllers/route.go index 7e0d517f..3c33e91a 100644 --- a/controllers/route.go +++ b/controllers/route.go @@ -1,31 +1,5 @@ package controllers -/* -gophish - Open-Source Phishing Framework - -The MIT License (MIT) - -Copyright (c) 2013 Jordan Wright - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - import ( "fmt" "html/template" diff --git a/db/db.go b/db/db.go index 37132706..91b1a3fd 100644 --- a/db/db.go +++ b/db/db.go @@ -25,12 +25,17 @@ func Setup() error { _, err = os.Stat(config.Conf.DBPath) Conn.AddTableWithName(models.User{}, "users").SetKeys(true, "Id") Conn.AddTableWithName(models.Campaign{}, "campaigns").SetKeys(true, "Id") + Conn.AddTableWithName(models.Group{}, "groups").SetKeys(true, "Id") + Conn.AddTableWithName(models.GroupTarget{}, "group_target") if err != nil { fmt.Println("Database not found, recreating...") createTablesSQL := []string{ //Create tables `CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT NOT NULL, hash VARCHAR(60) NOT NULL, api_key VARCHAR(32));`, - `CREATE TABLE campaigns (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, created_date TIMESTAMP NOT NULL, completed_date TIMESTAMP, template TEXT, status TEXT NOT NULL, uid INTEGER, FOREIGN KEY (uid) REFERENCES Users(id));`, + `CREATE TABLE campaigns (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, created_date TIMESTAMP NOT NULL, completed_date TIMESTAMP, template TEXT, status TEXT NOT NULL, uid INTEGER, FOREIGN KEY (uid) REFERENCES users(id));`, + `CREATE TABLE targets (id INTEGER PRIMARY KEY AUTOINCREMENT, address TEXT NOT NULL);`, + `CREATE TABLE groups (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL);`, + `CREATE TABLE group_targets (gid INTEGER NOT NULL, tid INTEGER NOT NULL, FOREIGN KEY (gid) REFERENCES groups(id), FOREIGN KEY (tid) REFERENCES targets(id));`, } fmt.Println("Creating db at " + config.Conf.DBPath) //Create the tables needed diff --git a/models/models.go b/models/models.go index 0e9b2974..c0495d10 100644 --- a/models/models.go +++ b/models/models.go @@ -42,6 +42,7 @@ type Campaign struct { CompletedDate time.Time `json:"completed_date" db:"completed_date"` Template string `json:"template"` //This may change Status string `json:"status"` + Results []Result `json:"results" db:"-"` Uid int64 `json:"-"` } @@ -56,9 +57,15 @@ type Result struct { Status string `json:"status"` } -type CampaignResults struct { - CampaignId int64 - TargetId int64 +type Group struct { + Id int64 `json:"id"` + Targets []Target + Uid int64 +} + +type GroupTarget struct { + Gid int64 + Tid int64 } type Target struct {