rsmusllp / king-phisher

Phishing Campaign Toolkit
BSD 3-Clause "New" or "Revised" License
2.23k stars 538 forks source link

Error startin king Phisher services #422

Closed zoubida43 closed 4 years ago

zoubida43 commented 4 years ago

Issue Description

installed King-phisher on Kali

Reproduction Steps

  1. Start King Phisher
  2. Do something to trigger the crash

Environment Details

Host OS: Kali 2, King Phisher Version

Jan 22 20:47:02 kingkali systemd[1]: king-phisher.service: Can't open PID file /run/king-phisher.pid (yet?) after start: No such file or directory Jan 22 20:47:05 kingkali su[776]: (to postgres) root on none Jan 22 20:47:05 kingkali su[776]: pam_unix(su:session): session opened for user postgres by (uid=0) Jan 22 20:47:05 kingkali su[776]: pam_unix(su:session): session closed for user postgres Jan 22 20:47:05 kingkali su[803]: (to postgres) root on none Jan 22 20:47:05 kingkali su[803]: pam_unix(su:session): session opened for user postgres by (uid=0) Jan 22 20:47:05 kingkali su[803]: pam_unix(su:session): session closed for user postgres Jan 22 20:48:24 kingkali systemd[1]: king-phisher.service: start operation timed out. Terminating. Jan 22 20:48:24 kingkali systemd[1]: king-phisher.service: Failed with result 'timeout'. Jan 22 20:48:24 kingkali systemd[1]: Failed to start King Phisher Server. e logs here.

zeroSteiner commented 4 years ago

Start King Phisher in the foreground with debugging output and post the results here please.

zoubida43 commented 4 years ago

DEBUG target directory: /opt/king-phisher INFO checking for the pipenv environment DEBUG pipenv path: '/usr/local/bin/pipenv' DEBUG pipenv Pipfile: /opt/king-phisher/Pipfile Loading .env environment variables… DEBUG king phisher version: 1.16.0-beta (rev: 51185b4a2afd) python version: 3.7.5 DEBUG using plugin-specific library path: /var/king-phisher/lib/python3.7/site-packages INFO listening on 172.22.98.207:80 INFO serving files has been enabled INFO initializing database connection with driver postgresql DEBUG postgresql-setup was not found DEBUG starting external process: /usr/bin/systemctl status postgresql.service DEBUG postgresql service is already running via systemctl DEBUG starting external process: su postgres -c psql -At -c "SELECT usename FROM pg_user" DEBUG starting external process: su postgres -c psql -At -c "SELECT datname FROM pg_database" DEBUG current database schema version: 9 (latest) DEBUG connected to postgresql database: king_phisher INFO restored 0 valid sessions and skipped 0 expired sessions from the database DEBUG use pam service 'sshd' for authentication DEBUG forked an authenticating process with pid: 6327 INFO the job manager has been started INFO adding new job with id: a50949d0-9bb4-45d5-99ac-055fff13b92c and callback function: _maintenance INFO adding new job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG web socket manager worker running in tid: 0x7f73cecd8700 DEBUG initialized the table api dataset (schema version: 8) DEBUG server request test id initialized with value: IXcC9vGUhPvzS799ZdLFtZ1J Traceback (most recent call last): File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/opt/king-phisher/king_phisher/server/main.py", line 264, in sys.exit(main()) File "/opt/king-phisher/king_phisher/server/main.py", line 258, in main status_code = build_and_run(arguments, config, plugin_manager, log_file) File "/opt/king-phisher/king_phisher/server/main.py", line 75, in build_and_run king_phisher_server = build.server_from_config(config, plugin_manager=plugin_manager) File "/opt/king-phisher/king_phisher/server/build.py", line 163, in server_from_config server = KingPhisherServer(config, plugin_manager, handler_klass, addresses=addresses, ssl_certfile=ssl_certfile, ssl_keyfile=ssl_keyfile) File "/opt/king-phisher/king_phisher/server/server.py", line 948, in init self.geoip_db = geoip.init_database(config.get('server.geoip.database')) File "/opt/king-phisher/king_phisher/geoip.py", line 129, in init_database _geoip_db = geoip2.database.Reader(database_file) File "/opt/king-phisher/.venv/lib/python3.7/site-packages/geoip2/database.py", line 86, in init self._db_reader = maxminddb.open_database(fileish, mode) File "/opt/king-phisher/.venv/lib/python3.7/site-packages/maxminddb/init__.py", line 41, in open_database return maxminddb.reader.Reader(database, mode) File "/opt/king-phisher/.venv/lib/python3.7/site-packages/maxminddb/reader.py", line 84, in init ''.format(filename)) maxminddb.errors.InvalidDatabaseError: Error opening database file (/var/king-phisher/GeoLite2-City.mmdb). Is this a valid MaxMind DB file? DEBUG executing job with id: a50949d0-9bb4-45d5-99ac-055fff13b92c and callback function: _maintenance DEBUG running periodic maintenance tasks DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all DEBUG executing job with id: ac0ef1b7-fa71-47b8-9b3b-6c54004f67dc and callback function: ping_all

zoubida43 commented 4 years ago

Thank you for the help

kermana commented 4 years ago

I can confirm I had the same problem on a fresh Ubuntu 18.04 install. I manually downloaded "GeoLite2-City.mmdb" to "/var/king-phisher/" which seems to have fixed the problem after a reboot. I am guessing this is related to the recent changes Maxmind did where they now require an API key to download this file. You might have to register to the Maxmind website to download this file manually.

zoubida43 commented 4 years ago

Thanks for pointing that out. It resolved my issue

zeroSteiner commented 4 years ago

Hey, it's possible that this is a bug that I may have introduced in some changes I made recently. Can you please run file data/server/king_phisher/GeoLite2-City.mmdb; ls -lha data/server/king_phisher/GeoLite2-City.mmdb from your King Phisher directory and send me the output?

I'm wondering if shipping the database file with LFS is breaking it for new installations.

kermana commented 4 years ago

Sure thing! Here is the output:

root@ip-172-x-x-x:/opt/king-phisher# file data/server/king_phisher/GeoLite2-City.mmdb; ls -lha data/server/king_phisher/GeoLite2-City.mmdb
data/server/king_phisher/GeoLite2-City.mmdb: ASCII text
-rw-r--r-- 1 root king-phisher 133 Jan 23 17:05 data/server/king_phisher/GeoLite2-City.mmdb
root@ip-172-x-x-x:/opt/king-phisher# cat data/server/king_phisher/GeoLite2-City.mmdb
version https://git-lfs.github.com/spec/v1
oid sha256:a253d9cd68fe17b00087da24375f31f07cd4bb3852dc5fe3afe37b8f59e5abd0
size 61615395
zeroSteiner commented 4 years ago

Yup, thanks that confirms my suspicion. This is a bug.

zeroSteiner commented 4 years ago

Alright so the changes I made to address #418 require the user to have git-lfs installed in order to check out the large database that I'm now distributing. Since git-lfs should be included as a dependency in the install file, but it looks like some older versions of Linux that we still support don't have it (Fedora 26 for example).

To fix this, I'm also distributing the file over S3. If the database appears to be corrupt, a new one will be downloaded, either from MaxMind if a license is specified (which isn't fully exposed to the user at this time) or the older version from S3. That should fix the issue so you'll have a database and the server can start whether or not you have git-lfs installed.

Changes are in commit 9a15a0c246ba3169b427af5652e9dba956d8b3cf.

madafaka221 commented 4 years ago

Using /usr/local/lib/python3.8/dist-packages/distribute-0.7.3-py3.8.egg Processing dependencies for distribute Finished processing dependencies for distribute INFO: Installing the client desktop application file INFO: Updating the GTK icon cache gtk-update-icon-cache: Cache file created successfully. INFO: Configuring the PostgreSQL server INFO: PostgreSQL configuration file found at /etc/postgresql/12/main/pg_hba.conf WARNING: The PostgreSQL king_phisher user already exists! The password will need WARNING: to be manually updated to match the one automatically generated by this WARNING: installation script (by using the ALTER ROLE PostgreSQL command) or WARNING: restored from a previously backed up server configuration file. INFO: Installing the King Phisher systemd service file in /lib/systemd/system/ INFO: Starting the King Phisher service Failed to enable unit: Unit file /etc/systemd/system/king-phisher.service is masked. Failed to start king-phisher.service: Unit king-phisher.service is masked.

INFO: You can start the King Phisher client with the following command: /opt/king-phisher/KingPhisher

pleas help