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

[BUG] Access denied for user 'empire_user'@'localhost' #754

Open
1 task done
D3vil0p3r opened this issue Oct 21, 2024 · 1 comment
Open
1 task done

[BUG] Access denied for user 'empire_user'@'localhost' #754

D3vil0p3r opened this issue Oct 21, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@D3vil0p3r
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Empire Version

5.11.5

Python Version

3.12

Operating System

Arch Linux

Database

MySQL

Current Behavior

I installed Empire and its dependencies along with mysql package. I initialized mysql correctly and run it by systemctl and it seems to be ok:

sudo systemctl status mysqld

● mysqld.service - MySQL Server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
     Active: active (running) since Mon 2024-10-21 10:48:35 CEST; 41min ago
 Invocation: 933fc3e3ca8143e4977049f42f8be08d
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
   Main PID: 28161 (mysqld)
     Status: "Server is operational"
      Tasks: 35 (limit: 9444)
     Memory: 574.7M (peak: 576.9M)
        CPU: 13.062s
     CGroup: /system.slice/mysqld.service
             └─28161 /usr/bin/mysqld

Oct 21 10:48:34 athenaos mysqld[28161]: 2024-10-21T08:48:34.544951Z 0 [System] [MY-015015] [Server] MySQL Server - start.
Oct 21 10:48:34 athenaos mysqld[28161]: 2024-10-21T08:48:34.743222Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sq>
Oct 21 10:48:34 athenaos mysqld[28161]: 2024-10-21T08:48:34.743289Z 0 [System] [MY-010116] [Server] /usr/bin/mysqld (mysqld 9.0.1) starting as process 28161
Oct 21 10:48:34 athenaos mysqld[28161]: 2024-10-21T08:48:34.751950Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
Oct 21 10:48:35 athenaos mysqld[28161]: 2024-10-21T08:48:35.023356Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
Oct 21 10:48:35 athenaos mysqld[28161]: 2024-10-21T08:48:35.289003Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
Oct 21 10:48:35 athenaos mysqld[28161]: 2024-10-21T08:48:35.289061Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections ar>
Oct 21 10:48:35 athenaos mysqld[28161]: 2024-10-21T08:48:35.317525Z 0 [System] [MY-010931] [Server] /usr/bin/mysqld: ready for connections. Version: '9.0.1'  socket: '/ru>
Oct 21 10:48:35 athenaos mysqld[28161]: 2024-10-21T08:48:35.317564Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket>
Oct 21 10:48:35 athenaos systemd[1]: Started MySQL Server.

When I run empire server by sudo, I get:

(pymysql.err.OperationalError) (1045, "Access denied for user 'empire_user'@'localhost' (using password: YES)")
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__
    self._dbapi_connection = engine.raw_connection()
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3302, in raw_connection
    return self.pool.connect()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 449, in connect
    return _ConnectionFairy._checkout(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
......
  File "/usr/lib/python3.12/site-packages/pymysql/protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/usr/lib/python3.12/site-packages/pymysql/err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1045, "Access denied for user 'empire_user'@'localhost' (using password: YES)")
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Failed connecting to database using mysql+pymysql://empire_user:empire_password@localhost:3306
Perhaps the MySQL service is not running.
Try executing: sudo systemctl start mysql

Expected Behavior

empire server working correctly.

Steps To Reproduce

  1. Cloning the repository
  2. Install mysql package and initialize it and then run by systemctl
  3. Run empire server by sudo

Anything else?

No response

@D3vil0p3r D3vil0p3r added the bug Something isn't working label Oct 21, 2024
@D3vil0p3r
Copy link
Author

D3vil0p3r commented Oct 21, 2024

The issue was caused by the absence of empire_user inside MySQL DB. I created it by:

sudo mysql -u root -p -e "CREATE USER IF NOT EXISTS 'empire_user'@'localhost' IDENTIFIED BY 'empire_password';" || true
sudo mysql -u root -p -e "GRANT ALL PRIVILEGES ON *.* TO 'empire_user'@'localhost' WITH GRANT OPTION;" || true
sudo mysql -u root -p -e "FLUSH PRIVILEGES;" || true

sudo systemctl restart mysqld

I fixed that error but now when I run empire server I get:

  File "/usr/lib/python3.12/site-packages/pymysql/protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/usr/lib/python3.12/site-packages/pymysql/err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (6125, "Failed to add the foreign key constraint. Missing unique key for constraint 'reporting_ibfk_1' in the referenced table 'agent_tasks'")
[SQL: 
CREATE TABLE reporting (
    id INTEGER NOT NULL AUTO_INCREMENT, 
    name VARCHAR(255) NOT NULL, 
    event_type VARCHAR(255), 
    message TEXT, 
    timestamp DATETIME NOT NULL, 
    `taskID` INTEGER, 
    PRIMARY KEY (id), 
    FOREIGN KEY(`taskID`) REFERENCES agent_tasks (id)
)

]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant