~poptart/sprey

544d1ff79d934f7c46cc5ad0a62912f1ec81d697 — poptart 2 years ago 84cde05
Updated DB to working version for entry
2 files changed, 28 insertions(+), 6 deletions(-)

M db.go
M sprey.go
M db.go => db.go +16 -6
@@ 11,7 11,6 @@ import (
type DBEntry struct {
	ID              int
	RunID           int
	Previous        int
	Start           *time.Time
	Stop            *time.Time
	Username        string


@@ 48,7 47,6 @@ const (
(
	id INTEGER PRIMARY KEY AUTOINCREMENT, 
	runid            INTEGER,
	previous         INTEGER,
	start            DATETIME,
	stop             DATETIME,
	username         TEXT NOT NULL,


@@ 80,7 78,7 @@ const (
	delay_random INTEGER
);`
	sqlstartcampaign = `INSERT INTO campaign(request_data, policy_duration, policy_threshold, policy_window, delay_global, delay_peruser, delay_perlockout, delay_window, delay_random) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?);`
	sqlrecordattempt = `INSERT INTO sprey(runid, username, password, response_data, success, timing_initial, timing_dnsstart, timing_dnsstop, timing_tlsstart, timing_tlsstop, timing_connstart, timing_connstop, timing_firstbyte, timing_lastbyte, meta) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`
	sqlrecordattempt = `INSERT INTO sprey(runid, start, stop, username, password, response_data, success, timing_initial, timing_dnsstart, timing_dnsstop, timing_tlsstart, timing_tlsstop, timing_connstart, timing_connstop, timing_firstbyte, timing_lastbyte, meta) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`
)

func OpenDB(path string) (*sql.DB, error) {


@@ 156,10 154,22 @@ func (d *DBCampaign) RecordAttempt(db *sql.DB, attempt Attempt) error {

	//TODO runid and previous
	_, err = stmt.Exec(d.RunID,
		attempt.Credential.Username, attempt.Credential.Password,
		a, attempt.Success,
		attempt.Exchange.Timing.InitialStart, attempt.Exchange.Timing.DNSStart,
		attempt.Exchange.Timing.InitialStart,
		attempt.Exchange.Timing.LastByte,
		attempt.Credential.Username,
		attempt.Credential.Password,
		a,
		attempt.Success,
		attempt.Exchange.Timing.InitialStart,
		attempt.Exchange.Timing.DNSStart,
		attempt.Exchange.Timing.DNSStop,
		attempt.Exchange.Timing.TLSStart,
		attempt.Exchange.Timing.TLSStop,
		attempt.Exchange.Timing.ConnectStart,
		attempt.Exchange.Timing.ConnectStop,
		attempt.Exchange.Timing.FirstByte,
		attempt.Exchange.Timing.LastByte,
		[]byte{},
	)
	if err != nil {
		return err

M sprey.go => sprey.go +12 -0
@@ 93,5 93,17 @@ func Start(s Spray, db *sql.DB, campaign *DBCampaign) error {
	fmt.Printf("First Byte - %s\n", att.Exchange.Timing.FirstByte.Sub(att.Exchange.Timing.InitialStart).String())
	fmt.Printf("Real - %s\n", att.Exchange.Timing.Real.String())
	err = campaign.RecordAttempt(db, att)
	att, err = s.Do()
	if err != nil {
		return err
	}
	fmt.Printf("%#v\n", att)
	fmt.Printf("%#v\n", att.Exchange.Timing)
	fmt.Printf("DNS - %s\n", att.Exchange.Timing.DNSStop.Sub(att.Exchange.Timing.DNSStart).String())
	fmt.Printf("Connect - %s\n", att.Exchange.Timing.ConnectStop.Sub(att.Exchange.Timing.ConnectStart).String())
	fmt.Printf("First Byte - %s\n", att.Exchange.Timing.FirstByte.Sub(att.Exchange.Timing.InitialStart).String())
	fmt.Printf("Real - %s\n", att.Exchange.Timing.Real.String())
	err = campaign.RecordAttempt(db, att)

	return err
}