mirror of https://github.com/gophish/gophish
parent
3edcc11e61
commit
2cfe2b8f8f
|
@ -1,31 +1,5 @@
|
||||||
package controllers
|
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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
|
7
db/db.go
7
db/db.go
|
@ -25,12 +25,17 @@ func Setup() error {
|
||||||
_, err = os.Stat(config.Conf.DBPath)
|
_, err = os.Stat(config.Conf.DBPath)
|
||||||
Conn.AddTableWithName(models.User{}, "users").SetKeys(true, "Id")
|
Conn.AddTableWithName(models.User{}, "users").SetKeys(true, "Id")
|
||||||
Conn.AddTableWithName(models.Campaign{}, "campaigns").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 {
|
if err != nil {
|
||||||
fmt.Println("Database not found, recreating...")
|
fmt.Println("Database not found, recreating...")
|
||||||
createTablesSQL := []string{
|
createTablesSQL := []string{
|
||||||
//Create tables
|
//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 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)
|
fmt.Println("Creating db at " + config.Conf.DBPath)
|
||||||
//Create the tables needed
|
//Create the tables needed
|
||||||
|
|
|
@ -42,6 +42,7 @@ type Campaign struct {
|
||||||
CompletedDate time.Time `json:"completed_date" db:"completed_date"`
|
CompletedDate time.Time `json:"completed_date" db:"completed_date"`
|
||||||
Template string `json:"template"` //This may change
|
Template string `json:"template"` //This may change
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
Results []Result `json:"results" db:"-"`
|
||||||
Uid int64 `json:"-"`
|
Uid int64 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,9 +57,15 @@ type Result struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CampaignResults struct {
|
type Group struct {
|
||||||
CampaignId int64
|
Id int64 `json:"id"`
|
||||||
TargetId int64
|
Targets []Target
|
||||||
|
Uid int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupTarget struct {
|
||||||
|
Gid int64
|
||||||
|
Tid int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type Target struct {
|
type Target struct {
|
||||||
|
|
Loading…
Reference in New Issue