Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gophish attempts to recreate admin user every launch using mysql #948

Closed
fang0654 opened this issue Jan 30, 2018 · 8 comments
Closed

Gophish attempts to recreate admin user every launch using mysql #948

fang0654 opened this issue Jan 30, 2018 · 8 comments

Comments

@fang0654
Copy link

I'm setting up a new instance of gophish using the newly released 0.5.0, and seem to be running into a strange issue when using MySQL as a database backend. The first run works as expected, but if I try to kill and start gophish again, it attempts to create the admin user again, and fails with a duplicate key error. If I manually delete the admin user from the database, then I can rerun it again fine.

First run:

./gophish
 2018/01/30 15:33:28 worker.go:26: Background Worker Started Successfully - Waiting for Campaigns
goose: migrating db environment 'production', current version: 0, target: 20171208201932
OK    20160118194630_init.sql
OK    20160131153104_0.1.2_add_event_details.sql
OK    20160211211220_0.1.2_add_ignore_cert_errors.sql
OK    20160217211342_0.1.2_create_from_col_results.sql
OK    20160225173824_0.1.2_capture_credentials.sql
OK    20160227180335_0.1.2_store-smtp-settings.sql
OK    20160317214457_0.2_redirect_url.sql
OK    20160605210903_0.2_campaign_scheduling.sql
OK    20161202153627_AttachmentFix.sql
OK    20170104231222_0.2_result_statuses.sql
OK    20170219122503_0.2.1_email_headers.sql
OK    20170828220440_0.4_utc_dates.sql
OK    20171027213457_0.4.1_maillogs.sql
OK    20171208201932_0.4.1_next_send_date.sql
 2018/01/30 15:33:28 gophish.go:115: Starting phishing server at http://127.0.0.1:8080
 2018/01/30 15:33:28 gophish.go:102: Starting admin server at http://127.0.0.1:3333

And everything works as expected. After killing it with "Ctrl+c" and rerunning:

./gophish
 2018/01/30 15:33:49 worker.go:26: Background Worker Started Successfully - Waiting for Campaigns
goose: no migrations to run. current version: 20171208201932
 2018/01/30 15:33:49 models.go:126: Error 1062: Duplicate entry 'admin' for key 'username'
 2018/01/30 15:33:49 gophish.go:77: Error 1062: Duplicate entry 'admin' for key 'username'

config.json:

{
        "admin_server" : {
                "listen_url" : "127.0.0.1:3333",
                "use_tls" : false,
                "cert_path" : "gophish_admin.crt",
                "key_path" : "gophish_admin.key"
        },
        "phish_server" : {
                "listen_url" : "127.0.0.1:8080",
                "use_tls" : false,
                "cert_path" : "example.crt",
                "key_path": "example.key"
        },
        "db_name" : "mysql",
         "db_path" : "gophish:<redacted>@(:3306)/gophish?charset=utf8&parseTime=True&loc=UTC",
        "migrations_prefix" : "db/db_"
}
@AuditeMarlow
Copy link

I am currently getting the same issue, I'm also on Gophish 0.5.0 with a MySQL database backend.

@jordan-wright
Copy link
Collaborator

jordan-wright commented Feb 2, 2018 via email

@AuditeMarlow
Copy link

This issue is also present in 0.4.0, but chooses to proceed instead of dying. Below are my logs.

2018/02/05 08:18:59 worker.go:37: Background Worker Started Successfully - Waiting for Campaigns
goose: no migrations to run. current version: 20170828220440
2018/02/05 08:18:59 models.go:126: Error 1062: Duplicate entry 'admin' for key 'username'
Error 1062: Duplicate entry 'admin' for key 'username'
2018/02/05 08:18:59 gophish.go:104: Starting phishing server at http://0.0.0.0:8080
2018/02/05 08:18:59 gophish.go:91: Starting admin server at http://127.0.0.1:3333

@jordan-wright
Copy link
Collaborator

This should be fixed as of 0f4ac70. Let me know if you run into any issues!

@rongutierrez
Copy link

Can you cut a new release for this bug fix?

@Nhoty
Copy link

Nhoty commented Mar 2, 2018

Is this already on 5.0 release ?

@jasonmull
Copy link

I'm running 0.5.0 and am still having this issue. Using MySQL DB as well.

@AuditeMarlow
Copy link

AuditeMarlow commented Mar 18, 2018

@jasonmull This is because 0f4ac70 is merged in the mainline, but 0.5.0 is behind on the mainline. You should either build Gophish from source using its mainline, or wait for a new release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants