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

Error building Server #254

Closed
SJHsimkaur opened this issue Jan 4, 2018 · 26 comments
Closed

Error building Server #254

SJHsimkaur opened this issue Jan 4, 2018 · 26 comments
Assignees
Labels
client Relating to the client component help me Requests for support server Relating to the server component

Comments

@SJHsimkaur
Copy link

Issue Description

There are several issues but lets start one by one:
i followed instructions to build KP server but debugging config file throws below error:


DEBUG king phisher version: 1.9.0 python version: 3.5.2
ERROR failed to bind server to address (socket error #98)
ERROR socket error #98 (Address already in use)

Traceback (most recent call last):
File "/opt/king-phiser/king_phisher/server/build.py", line 145, in server_from_config
server = KingPhisherServer(config, plugin_manager, handler_klass, addresses=addresses, ssl_certfile=ssl_certfile, ssl_keyfile=ssl_keyfile)
File "/opt/king-phiser/king_phisher/server/server.py", line 843, in init
super(KingPhisherServer, self).init(handler_klass, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/advancedhttpserver.py", line 1780, in init
server = server_klass((address[0], address[1]), handler_klass, config=self.__config)
File "/usr/local/lib/python3.5/dist-packages/advancedhttpserver.py", line 703, in init
super(ServerNonThreaded, self).init(*args, **kwargs)
File "/usr/lib/python3.5/socketserver.py", line 440, in init
self.server_bind()
File "/usr/local/lib/python3.5/dist-packages/advancedhttpserver.py", line 771, in server_bind
super(ServerNonThreaded, self).server_bind(*args, **kwargs)
File "/usr/lib/python3.5/http/server.py", line 138, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.5/socketserver.py", line 454, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use
CRITICAL server failed to build with error: socket error #98 (Address already in use)
INFO unloading 0 plugins

Reproduction Steps

  1. Able to start KP server but not able to launch client as both reside on same server.

Environment Details

Host OS: Ubuntu 16.04 GNOME, etc.
King Phisher Version: 1.9.0

Error Details / Stack Trace

  1. KP server is running on port 80. I disabled Apache on the server.

  2. Details from /var/log/king-phisher.log
    2018-01-04 12:02:06,275 KingPhisher.Server.CLI CRITICAL server failed to build with error: socket error Failed to authenticate to the SMTP server #98 (Address already in use)

  3. Unable to launch client from same KP server
    Traceback (most recent call last):
    File "./KingPhisher", line 49, in
    from king_phisher.client import application
    File "/opt/king-phiser/king_phisher/client/application.py", line 52, in
    from king_phisher.client import assistants
    File "/opt/king-phiser/king_phisher/client/assistants/init.py", line 33, in
    from .campaign import *
    File "/opt/king-phiser/king_phisher/client/assistants/campaign.py", line 36, in
    from king_phisher.client import gui_utilities
    File "/opt/king-phiser/king_phisher/client/gui_utilities.py", line 517
    elif len(error.args) > 1:
    ^
    SyntaxError: invalid syntax

Please advice.

If you are opening an issue regarding the client, copy text from the "Error
Details" of the error dialog in the client here. If you are opening an issue
regarding the server copy the relevant lines from the logs here.
@wolfthefallen wolfthefallen self-assigned this Jan 4, 2018
@wolfthefallen wolfthefallen added help me Requests for support server Relating to the server component labels Jan 4, 2018
@wolfthefallen
Copy link
Contributor

@SJHsimkaur The logging out put is stating the port that the King Phisher is trying to bind to is already in use. Please see the Socket Bind Failure FAQ section. You will need to see what program or service is already using the port and turn that service off. As the FAQ states using netstat or another port monitoring tool will help you determine what is already using the port.

As for the second issues I've been unable to reproduce that issue. Can you please provide me more information on what steps you are taking to create this issue.
example: (I am guess these are steps to reproduce based off the location of the stack trace)

  • Launch King Phisher Client
  • Put in server IP address
  • Put in username/password
  • clicking connect causes a stack trace

@SJHsimkaur
Copy link
Author

@wolfthefallen Thanks for your quick turnaround but there is nothing else running on port 80 as below. Not sure what i am missing on.

root@king-phiser:~# netstat -tulpn | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 16338/python3

Thanks

@wolfthefallen
Copy link
Contributor

The output your netstat is showing, is that there Is something running on port that is what the LISTEN is stating.. It is a python program so there is a chance you already have King Phisher running.
do
sudo systemctl status king-phisher There is a good possibility it is already running

@SJHsimkaur
Copy link
Author

Yes the server is running ( as mentioned in the first email but client is not connecting) but my ask is if the below output is as expected from below command. How can we resolve traceback error?

root@king-phiser:/opt/king-phiser# ./KingPhisherServer -f -L DEBUG server_config.yml
DEBUG king phisher version: 1.9.0 python version: 3.5.2
ERROR failed to bind server to address (socket error #98)
ERROR socket error #98 (Address already in use)
Traceback (most recent call last):
File "/opt/king-phiser/king_phisher/server/build.py", line 145, in server_from_config
server = KingPhisherServer(config, plugin_manager, handler_klass, addresses=addresses, ssl_certfile=ssl_certfile, ssl_keyfile=ssl_keyfile)
File "/opt/king-phiser/king_phisher/server/server.py", line 843, in init
super(KingPhisherServer, self).init(handler_klass, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/advancedhttpserver.py", line 1780, in init
server = server_klass((address[0], address[1]), handler_klass, config=self._config)
File "/usr/local/lib/python3.5/dist-packages/advancedhttpserver.py", line 703, in init
super(ServerNonThreaded, self).init(*args, **kwargs)
File "/usr/lib/python3.5/socketserver.py", line 440, in init
self.server_bind()
File "/usr/local/lib/python3.5/dist-packages/advancedhttpserver.py", line 771, in server_bind
super(ServerNonThreaded, self).server_bind(*args, **kwargs)
File "/usr/lib/python3.5/http/server.py", line 138, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.5/socketserver.py", line 454, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use
CRITICAL server failed to build with error: socket error #98 (Address already in use)
INFO unloading 0 plugins


root@king-phiser:~# sudo systemctl status king-phisher
● king-phisher.service - King Phisher Server
Loaded: loaded (/lib/systemd/system/king-phisher.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-01-04 11:59:28 EST; 36min ago
Process: 16323 ExecStop=/bin/kill -INT $MAINPID (code=exited, status=0/SUCCESS)
Process: 16327 ExecStart=/usr/bin/python3 /opt/king-phiser/KingPhisherServer /opt/king-phiser/server_config.yml (code=exited, status=0/SUCCESS)
Main PID: 16338 (python3)
Tasks: 4
Memory: 53.8M
CPU: 1.278s
CGroup: /system.slice/king-phisher.service
├─16338 /usr/bin/python3 /opt/king-phiser/KingPhisherServer /opt/king-phiser/server_config.yml
└─16387 /usr/bin/python3 /opt/king-phiser/KingPhisherServer /opt/king-phiser/server_config.yml

Jan 04 11:59:26 king-phiser systemd[1]: Starting King Phisher Server...
Jan 04 11:59:27 king-phiser su[16340]: Successful su for postgres by root
Jan 04 11:59:27 king-phiser su[16340]: + ??? root:postgres
Jan 04 11:59:27 king-phiser su[16340]: pam_unix(su:session): session opened for user postgres by (uid=0)
Jan 04 11:59:27 king-phiser su[16357]: Successful su for postgres by root
Jan 04 11:59:27 king-phiser su[16357]: + ??? root:postgres
Jan 04 11:59:27 king-phiser su[16357]: pam_unix(su:session): session opened for user postgres by (uid=0)
Jan 04 11:59:27 king-phiser systemd[1]: king-phisher.service: PID file /var/run/king-phisher.pid not readable (yet?) after start: No such file or directory
Jan 04 11:59:28 king-phiser systemd[1]: Started King Phisher Server.

@wolfthefallen
Copy link
Contributor

@SJHsimkaur
Launching the King Phisher server with ./KingPhisherServer -f -L DEBUG server_config.yml is failing because you already have the server running as service. If you want to run the server in a terminal you will first need to stop the server through systemctl sudo systemctl stop king-phisher. Then you can start the server in your terminal with sudo ./KingPhisherServer -f -L DEBUG server_config.yml -f I recommend using the -f switch if running in this fashion so the server runs in the foreground and does not fork into a background thread.

As long as the server is running you should be able to then start the King Phisher client ./KingPhisher -L DEBUG' to get a verbose logging output in a terminal window. IF you running it from the same system the service is running on, use 127.0.0.1` as your Server. Your username and password is what you use to login or ssh into the system with.

@wolfthefallen wolfthefallen added the client Relating to the client component label Jan 4, 2018
@SJHsimkaur
Copy link
Author

While running "./KingPhisherServer -f -L DEBUG server_config.yml -f " looks like its stuck at DEBUG step and still continuing

root@king-phiser:/opt/king-phiser# ./KingPhisherServer -f -L DEBUG server_config.yml -f
DEBUG king phisher version: 1.9.0 python version: 3.5.2
INFO listening on 127.0.0.1:80
INFO serving files has been enabled
INFO initializing database connection with driver postgresql
DEBUG postgresql-setup was not found
DEBUG postgresql service is already running via systemctl
DEBUG current database schema version: 7 (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: 17128
INFO the job manager has been started
INFO adding new job with id: 40701148-51f8-45bd-925d-6181ceaaa9ca and callback function: ping_all
DEBUG web socket manager worker running in tid: 0x7f4042842700
INFO including 4 custom http headers
INFO server running in process: 17099 main tid: 0x7f404d00a700
INFO dropped privileges to the nobody account
DEBUG executing job with id: 40701148-51f8-45bd-925d-6181ceaaa9ca and callback function: ping_all
DEBUG executing job with id: 40701148-51f8-45bd-925d-6181ceaaa9ca and callback function: ping_all
DEBUG executing job with id: 40701148-51f8-45bd-925d-6181ceaaa9ca and callback function: ping_all
DEBUG executing job with id: 40701148-51f8-45bd-925d-6181ceaaa9ca and callback function: ping_all
DEBUG executing job with id: 40701148-51f8-45bd-925d-6181ceaaa9ca and callback function: ping_all
DEBUG executing job with id: 40701148-51f8-45bd-925d-6181ceaaa9ca and callback function: ping_all
DEBUG executing job with id: 40701148-51f8-45bd-925d-6181ceaaa9ca and callback function: ping_all
DEBUG executing job with id: 40701148-51f8-45bd-925d-6181ceaaa9ca and callback function: ping_all
DEBUG executing job with id: 40701148-51f8-45bd-925d-6181ceaaa9ca and callback function: ping_all


Below is the output while launching CLIENT:
kphiser@king-phiser:/opt/king-phiser$ ./KingPhisher -L DEBUG
Traceback (most recent call last):
File "./KingPhisher", line 49, in
from king_phisher.client import application
File "/opt/king-phiser/king_phisher/client/application.py", line 52, in
from king_phisher.client import assistants
File "/opt/king-phiser/king_phisher/client/assistants/init.py", line 33, in
from .campaign import *
File "/opt/king-phiser/king_phisher/client/assistants/campaign.py", line 36, in
from king_phisher.client import gui_utilities
File "/opt/king-phiser/king_phisher/client/gui_utilities.py", line 517
elif len(error.args) > 1:
^
SyntaxError: invalid syntax

@wolfthefallen
Copy link
Contributor

There server output is what is expected and running correctly.

The client is the only part that appears to be having an issue.

what steps did you take to install King Phisher on your system?
did you run the one liner, or git clone and then run the install.sh script?

@SJHsimkaur
Copy link
Author

I followed below steps to install king-phiser:

[root@localhost ~]# apt-get install –y git
[root@localhost ~]# git clone https://github.com/securestate/king-phisher.git /opt/king-phisher
[root@localhost ~]# cd /opt/king-phisher/
[root@localhost king-phisher]# tools/install.sh
Yes to PostgreSQL

Thanks

@wolfthefallen
Copy link
Contributor

sweet from the King Phisher folder please provide me the top entry of the command 'git log' it should look something like:

commit 3edc2d5bfba8b21e09cb3510739961d1c4f28d90
Merge: cc43c91 95016cc
Author: Erik Daguerre <fallenwolf@wolfthefallen.com>
Date:   Wed Nov 22 15:20:14 2017 -0500

    resloved conflicts

@SJHsimkaur
Copy link
Author

Sorry I am didnt get that. you mean to say in /opt/king-phiser/ but i dont see any.

@wolfthefallen
Copy link
Contributor

yes from the /opt/king-phisher/ directory run command git log

cd /opt/king-phisher/
git log

@SJHsimkaur
Copy link
Author

Thanks, here you go.

kphiser@king-phiser:/opt/king-phiser$ git log
commit 3edc2d5
Merge: cc43c91 95016cc
Author: Erik Daguerre fallenwolf@wolfthefallen.com
Date: Wed Nov 22 15:20:14 2017 -0500

resloved conflicts

@SJHsimkaur
Copy link
Author

Somehow missed the numbers.

kphiser@king-phiser:/opt/king-phiser$ git log
commit 3edc2d5
Merge: cc43c91 95016cc
Author: Erik Daguerre fallenwolf@wolfthefallen.com
Date: Wed Nov 22 15:20:14 2017 -0500

resloved conflicts

@SJHsimkaur
Copy link
Author

kphiser@king-phiser:/opt/king-phiser$ git log
commit 3edc2d5
Merge: cc43c91 95016cc
Author: Erik Daguerre fallenwolf@wolfthefallen.com
Date: Wed Nov 22 15:20:14 2017 -0500

resloved conflicts

@wolfthefallen
Copy link
Contributor

Yup that is the information I need, Github auto shortens the commit numbers into links for us

@wolfthefallen
Copy link
Contributor

please provide me the auto put of a git status

@SJHsimkaur
Copy link
Author

Oh i see. I was going crazy with that.

kphiser@king-phiser:/opt/king-phiser$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)

    modified:   king_phisher/client/gui_utilities.py

no changes added to commit (use "git add" and/or "git commit -a")

@wolfthefallen
Copy link
Contributor

wolfthefallen commented Jan 4, 2018

do a git stash and that should clear up your issue

@zeroSteiner
Copy link
Collaborator

@wolfthefallen is correct, but to clarify that is showing us that there are changes we haven't published to that file. It looks like it somehow got corrupted.

@SJHsimkaur
Copy link
Author

Still not able to launch client after running the git stash command.

root@king-phiser:/opt/king-phiser# git stash
Saved working directory and index state WIP on master: 3edc2d5 resloved conflicts
HEAD is now at 3edc2d5 resloved conflicts

root@king-phiser:/opt/king-phiser# ./KingPhisher
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(KingPhisher:17685): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
Traceback (most recent call last):
File "./KingPhisher", line 49, in
from king_phisher.client import application
File "/opt/king-phiser/king_phisher/client/application.py", line 54, in
from king_phisher.client import dialogs
File "/opt/king-phiser/king_phisher/client/dialogs/init.py", line 37, in
from .configuration import *
File "/opt/king-phiser/king_phisher/client/dialogs/configuration.py", line 38, in
from king_phisher.client import graphs
File "/opt/king-phiser/king_phisher/client/graphs.py", line 57, in
from matplotlib import pyplot
File "/usr/local/lib/python3.5/dist-packages/matplotlib/pyplot.py", line 116, in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python3.5/dist-packages/matplotlib/backends/init.py", line 60, in pylab_setup
[backend_name], 0)
File "/usr/local/lib/python3.5/dist-packages/matplotlib/backends/backend_gtk3cairo.py", line 6, in
from . import backend_cairo, backend_gtk3
File "/usr/local/lib/python3.5/dist-packages/matplotlib/backends/backend_gtk3.py", line 50, in
cursors.MOVE : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
TypeError: constructor returned NULL

@zeroSteiner
Copy link
Collaborator

You are running in a graphical environment right? Like a full blown graphical GNOME desktop, because I'm confused due to the issue stating that it can't connect to Mir but you stating that you're using Ubuntu GNOME in your initial ticket.

@SJHsimkaur
Copy link
Author

I apologize for the confusion and missing the imp piece. I am not able to launch KP client from ssh terminal as well.

@zeroSteiner
Copy link
Collaborator

You're not supposed to be able to launch the client from an SSH terminal. It's a graphical application that requires a GUI environment in order to operate. You might be able to run it by X11 forwarding but I don't think I've ever done that so your mileage may vary.

@SJHsimkaur
Copy link
Author

What are other possible options to launch KP client? Looks like Ubuntu desktop is not working for me.

@zeroSteiner
Copy link
Collaborator

Ubuntu GNOME is what we recommend, you just can't do it over SSH. Fedora Workstation and Windows are the other two most widely supported options for the client.

@SJHsimkaur
Copy link
Author

I am able to launch client successfully with GNOME desktop. Thank you @zeroSteiner @wolfthefallen for all your help.
I might open new tickets for other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Relating to the client component help me Requests for support server Relating to the server component
Projects
None yet
Development

No branches or pull requests

3 participants