zecure / shadowd_ui

The Shadow Daemon user interface
GNU General Public License v2.0
20 stars 9 forks source link

The requested URL /app.php/ was not found on this server #22

Closed talhakabakus closed 6 years ago

talhakabakus commented 7 years ago

Hi, I use Apache as the web server and have deployed the shadowd_ui with following the documentation you shared. When I visit the server/app.php, getting an HTTP 400 error like this: The requested URL /app.php/ was not found on this server

talhakabakus commented 7 years ago

Here is the definition of my virtual host that I have created for shadowd_ui:

<VirtualHost *:80>
ServerName 10.112.0.135
ServerAlias shadowd
DocumentRoot "/var/www/shadowd_ui/web/"
ErrorLog "/var/www/shadowd_ui/logs/error.log"
CustomLog "/var/www/shadowd_ui/logs/access.log" combined
<Directory "/var/www/shadowd_ui/">
AllowOverride All
</Directory>
</VirtualHost>
zit-hb commented 7 years ago

It does look correct on the first sight. Did you navigate to /app.php/ or were you redirected there? There is no need to call that file directly, the .htaccess file in the web directory rewrites request to automatically use it (clean URLs).

talhakabakus commented 7 years ago

I was redirected there automatically.

zit-hb commented 7 years ago

Maybe you do not have mod_rewrite enabled in Apache?

zit-hb commented 7 years ago

Any luck with this problem, Talha?

talhakabakus commented 7 years ago

Thanks for your care Hendrik, I have enabled mod_rewrite then restarted Apache, unfortunately still same. Getting the content below when I visit the root URL of the shadowd_ui?

<?php

use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';

// Use APC for autoloading to improve performance.
// Change 'sf2' to a unique prefix in order to prevent cache key conflicts
// with other applications also using APC.
/*
$apcLoader = new ApcClassLoader('sf2', $loader);
$loader->unregister();
$apcLoader->register(true);
*/

require_once __DIR__.'/../app/AppKernel.php';
//require_once __DIR__.'/../app/AppCache.php';

$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);

// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
zit-hb commented 7 years ago

Ah, you do not have PHP installed/enabled.

talhakabakus commented 7 years ago

Here is the output of php -version

PHP 7.0.15-0ubuntu,.16.04.4 (cli) (NTS)
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.15-0ubuntu,.16.04.4 Copyright (c) 1998-2017, Zend Technologies

And I have set the opcache.enable=1 in the php.ini files under both /etc/php/7.0/cli and /etc/php/7.0/fpm folders.

Unfortunately it is still same.

zit-hb commented 7 years ago

I was referring to PHP for Apache. Try to install libapache2-mod-php.

talhakabakus commented 7 years ago

Did it, still same Hendrik. Now the PHP code has gone, I just see an error page and HTTP 500 warning.

zit-hb commented 7 years ago

You can find error logs in /var/log/apache2/error.log and var/logs/ (of the shadowd_ui directory). Probably invalid file permissions. The cache directory has to be write-able. Also, did you do the composer installation that is explained in the documentation?

talhakabakus commented 7 years ago

When I try to execute a2enmod php command, getting an error like this: ERROR: Module php does not exist!

bugasur commented 7 years ago

hi hendrik, able to login into gui. will get back if stuck. thanks

zit-hb commented 7 years ago

Hey bugasur. Great. I guess it was caused by invalid permissions for the cache and log directory? Btw. is it a private ctf? I am not aware of one today :)

For reference, if anyone else in the future has this problem: check your log files (app/logs/prod.log and web server error log), it probably will contain the answer.

bugasur commented 7 years ago

Hi Hendrik,

Yes, its a private CTF. The cache and log directory already had valid permissions.I had to install the shadowd-gui in a separate location and with new installation of composer + there was pdo error due to multiple incorrect mysql installation. so had to redo mysql installation as well.

But now i am facing issue with connector. getting 500 internal server error. following is debug message -

2017-05-11 10:23:07 Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/shadowd/connector.py", line 265, in start config.get('ssl') File "/usr/local/lib/python2.7/dist-packages/shadowd/connector.py", line 179, in send connection.connect((host, port)) File "/usr/lib/python2.7/socket.py", line 228, in meth return getattr(self._sock,name)(*args) TypeError: an integer is required

shadow.ini (pemission: 777)

##########

Server

##########

Sets the bind address. Change to 0.0.0.0 to allow connections on any

interface.

Default Value: 127.0.0.1

address=0.0.0.0

Sets the bind port.

Default Value: 9115

port=9115

Activates SSL. Requires no parameter, just uncomment.

ssl=

Sets the path to the SSL certificate.

ssl-cert=

Sets the path to the SSL key.

ssl-key=

Sets the path to the Diffie-Hellman parameters.

ssl-dh=

Sets the size of the threadpool.

Default Value: 10

threads=

##########

Daemon

##########

Daemonizes process. Requires no parameter, just uncomment.

daemonize=

If set the output is written to a log file.

log=

If set the process id is written to a pid file.

pid=

If set the user id is changed after initialization for security purposes.

There is no good reason why the process should have root privileges.

user=

If set the group id is changed after initialization for security purposes.

There is no good reason why the process should have root privileges.

group=

If set the root directory is changed after initialization for security

purposes.

chroot=

############

Security

############

Sets the maximum allowed number of parameters to make flooding more

difficult.

If you do not wish to limit the amount of parameters set this to -1.

Default Value: 64

max-parameters=1

Sets the maximum allowed length of parameter paths to make flooding more

difficult. If you do not wish to restrict the length set this to -1.

Default Value: 64

max-length-path=1

Sets the maximum allowed length of parameter values to make flooding more

difficult. If you do not wish to restrict the length set this to -1.

Default Value: -1

max-length-value=1

############

Database

############

Sets the libdbi database driver.

Possible Values:

pgsql

mysql

Default Value: pgsql

db-driver=mysql

Sets the database host.

Default Value: 127.0.0.1

db-host=127.0.0.1

Sets the database port.

Default Value: 5432

Possible Values:

pgsql: 5432

mysql: 3306

db-port=3306

Sets the database name.

Default Value: shadowd

db-name=shadowd

Sets the database user.

Default Value: shadowd

db-user=shadowd

Sets the database password.

db-password=password

/etc/shadowd/connector.ini (permission: 777)

[shadowd_python] ; Sets the profile id. Required. profile=1

; Sets the key for the profile. Required. key=somekey

; Sets the address of the shadowd server. ; Default Value: 127.0.0.1 host=127.0.0.1

; Sets the port of the shadowd server. ; Default Value: 9115 port=9115

; Sets the path to the SSL certificate and enables SSL. ;ssl=

; If activated threats are not removed. This can be used to test new rules without ; making the web application unusable. It can be also used to turn Shadow Daemon ; into a high-interaction web honeypot. ; Possible Values: ; 0 ; 1 ; Default Value: 0 ;observe=1

; If activated error messages are printed. ; Possible Values: ; 0 ; 1 ; Default Value: 0 debug=1

; Sets the log file, but it is only used if debug is enabled. ; Default Value: /var/log/shadowd.log ; log=

; If set the ignore list is used to ignore certain parameters and not send them to ; the shadowd server. It is good practise to not send passwords or other very ; sensitive information to the server. ;ignore=

; Sets the source for the client ip. It is a key of $_SERVER. If you are using a ; reverse proxy or something similar forward the real client ip and reference it ; here, e.g., HTTP_X_FORWARDED_FOR. ; Default Value: ; CGI: REMOTE_ADDR ; Django: REMOTE_ADDR ; Flask: REMOTE_ADDR ;client_ip=

; Sets the source for the caller. It is a key of $_SERVER. If you are using web ; application with a front controller or something like that change it to PHP_SELF. ; Default Value: ; CGI: SCRIPT_FILENAME ; Django: PATH_INFO ; Flask: PATH_INFO ;caller=

Th key, profile id, password are correct. using observe=1 also works but removing it does not. how to ensure that the connector is working?

I tried port=int(port) but not sure if i did it correctly. i am also not using any sockets or bind but just want to use app.run() and pass arguments to it like host='0.0.0.0', port=8089, debug=True). Following is psuedo structure of the code:

!/usr/bin/python

from shadowd.flask_connector import InputFlask, OutputFlask, Connector from flask import Flask, request, make_response, render_template, url_for ....other libs called.......(os and socket are not called)

app = Flask(name)

i think, below code is generating the error while connecting...if u

remove an run it, it works. sometthing to do with port if we google. @app.before_request def before_req(): input = InputFlask(request) output = OutputFlask() Connector().start(input, output)

@app.route('/')

main here

def main(): return render_template('cts.html') .....some code......

@app.route('/abcd') def abcd(): .........some code..... return output

@app.route('/efgh') def efgh():

   ......some code.......
    return output

if name == "main": app.run(host='0.0.0.0',port=8089, debug=True)

Could you help to get the connector working? or what changes do i need to do in code w.r.t error? Thanks

On Thu, May 11, 2017 at 12:20 AM, Hendrik Buchwald <notifications@github.com

wrote:

Hey bugasur. Great. I guess it was caused by invalid permissions for the cache and log directory? Btw. is it a private ctf? I am not aware of one today :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/zecure/shadowd_ui/issues/22#issuecomment-300578433, or mute the thread https://github.com/notifications/unsubscribe-auth/AKQTfk6d-koXJwcor6tM_B9RzhgjpD5eks5r4gb0gaJpZM4Ms0me .

bugasur commented 7 years ago

this is prod log

[2017-05-11 19:52:55] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /favicon.ico"" at /home/osboxes/Downloads/shadowd_ui/app/cache/prod/classes.php line 1985 {"exception":"[object] (Symfony\Component\HttpKernel\Exception\NotFoundHttpException(code: 0): No route found for \"GET /favicon.ico\" at /home/osboxes/Downloads/shadowd_ui/app/cache/prod/classes.php:1985, Symfony\Component\Routing\Exception\ResourceNotFoundException(code: 0): at /home/osboxes/Downloads/shadowd_ui/app/cache/prod/appProdUrlMatcher.php:217)"} []

On Fri, May 12, 2017 at 2:28 AM, Abeer Banerjee londonboy2007@gmail.com wrote:

Hi Hendrik,

Yes, its a private CTF. The cache and log directory already had valid permissions.I had to install the shadowd-gui in a separate location and with new installation of composer + there was pdo error due to multiple incorrect mysql installation. so had to redo mysql installation as well.

But now i am facing issue with connector. getting 500 internal server error. following is debug message -

2017-05-11 10:23:07 Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/shadowd/connector.py", line 265, in start config.get('ssl') File "/usr/local/lib/python2.7/dist-packages/shadowd/connector.py", line 179, in send connection.connect((host, port)) File "/usr/lib/python2.7/socket.py", line 228, in meth return getattr(self._sock,name)(*args) TypeError: an integer is required

shadow.ini (pemission: 777)

##########

Server

##########

Sets the bind address. Change to 0.0.0.0 to allow connections on any

interface.

Default Value: 127.0.0.1

address=0.0.0.0

Sets the bind port.

Default Value: 9115

port=9115

Activates SSL. Requires no parameter, just uncomment.

ssl=

Sets the path to the SSL certificate.

ssl-cert=

Sets the path to the SSL key.

ssl-key=

Sets the path to the Diffie-Hellman parameters.

ssl-dh=

Sets the size of the threadpool.

Default Value: 10

threads=

##########

Daemon

##########

Daemonizes process. Requires no parameter, just uncomment.

daemonize=

If set the output is written to a log file.

log=

If set the process id is written to a pid file.

pid=

If set the user id is changed after initialization for security purposes.

There is no good reason why the process should have root privileges.

user=

If set the group id is changed after initialization for security

purposes.

There is no good reason why the process should have root privileges.

group=

If set the root directory is changed after initialization for security

purposes.

chroot=

############

Security

############

Sets the maximum allowed number of parameters to make flooding more

difficult.

If you do not wish to limit the amount of parameters set this to -1.

Default Value: 64

max-parameters=1

Sets the maximum allowed length of parameter paths to make flooding more

difficult. If you do not wish to restrict the length set this to -1.

Default Value: 64

max-length-path=1

Sets the maximum allowed length of parameter values to make flooding more

difficult. If you do not wish to restrict the length set this to -1.

Default Value: -1

max-length-value=1

############

Database

############

Sets the libdbi database driver.

Possible Values:

pgsql

mysql

Default Value: pgsql

db-driver=mysql

Sets the database host.

Default Value: 127.0.0.1

db-host=127.0.0.1

Sets the database port.

Default Value: 5432

Possible Values:

pgsql: 5432

mysql: 3306

db-port=3306

Sets the database name.

Default Value: shadowd

db-name=shadowd

Sets the database user.

Default Value: shadowd

db-user=shadowd

Sets the database password.

db-password=password

/etc/shadowd/connector.ini (permission: 777)

[shadowd_python] ; Sets the profile id. Required. profile=1

; Sets the key for the profile. Required. key=somekey

; Sets the address of the shadowd server. ; Default Value: 127.0.0.1 host=127.0.0.1

; Sets the port of the shadowd server. ; Default Value: 9115 port=9115

; Sets the path to the SSL certificate and enables SSL. ;ssl=

; If activated threats are not removed. This can be used to test new rules without ; making the web application unusable. It can be also used to turn Shadow Daemon ; into a high-interaction web honeypot. ; Possible Values: ; 0 ; 1 ; Default Value: 0 ;observe=1

; If activated error messages are printed. ; Possible Values: ; 0 ; 1 ; Default Value: 0 debug=1

; Sets the log file, but it is only used if debug is enabled. ; Default Value: /var/log/shadowd.log ; log=

; If set the ignore list is used to ignore certain parameters and not send them to ; the shadowd server. It is good practise to not send passwords or other very ; sensitive information to the server. ;ignore=

; Sets the source for the client ip. It is a key of $_SERVER. If you are using a ; reverse proxy or something similar forward the real client ip and reference it ; here, e.g., HTTP_X_FORWARDED_FOR. ; Default Value: ; CGI: REMOTE_ADDR ; Django: REMOTE_ADDR ; Flask: REMOTE_ADDR ;client_ip=

; Sets the source for the caller. It is a key of $_SERVER. If you are using web ; application with a front controller or something like that change it to PHP_SELF. ; Default Value: ; CGI: SCRIPT_FILENAME ; Django: PATH_INFO ; Flask: PATH_INFO ;caller=

Th key, profile id, password are correct. using observe=1 also works but removing it does not. how to ensure that the connector is working?

I tried port=int(port) but not sure if i did it correctly. i am also not using any sockets or bind but just want to use app.run() and pass arguments to it like host='0.0.0.0', port=8089, debug=True). Following is psuedo structure of the code:

!/usr/bin/python

from shadowd.flask_connector import InputFlask, OutputFlask, Connector from flask import Flask, request, make_response, render_template, url_for ....other libs called.......(os and socket are not called)

app = Flask(name)

i think, below code is generating the error while connecting...if u

remove an run it, it works. sometthing to do with port if we google. @app.before_request def before_req(): input = InputFlask(request) output = OutputFlask() Connector().start(input, output)

@app.route('/')

main here

def main(): return render_template('cts.html') .....some code......

@app.route('/abcd') def abcd(): .........some code..... return output

@app.route('/efgh') def efgh():

   ......some code.......
    return output

if name == "main": app.run(host='0.0.0.0',port=8089, debug=True)

Could you help to get the connector working? or what changes do i need to do in code w.r.t error? Thanks

On Thu, May 11, 2017 at 12:20 AM, Hendrik Buchwald < notifications@github.com> wrote:

Hey bugasur. Great. I guess it was caused by invalid permissions for the cache and log directory? Btw. is it a private ctf? I am not aware of one today :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/zecure/shadowd_ui/issues/22#issuecomment-300578433, or mute the thread https://github.com/notifications/unsubscribe-auth/AKQTfk6d-koXJwcor6tM_B9RzhgjpD5eks5r4gb0gaJpZM4Ms0me .

zit-hb commented 7 years ago

Hey bugasur, I did not have time to investigate in detail. It seems to be the case that there is a type mismatch. Casting the port to an integer seems like a good solution. You can also just remove the port line from the config again, so that the default port is used.

Also, I really advise you against making the configuration files world-writable. If someone gets a shell on the server this could become a big problem.