Writable file /var/www/html/dvwa/external/phpids/0.6/lib/IDS/tmp/phpids_log.txt: No #126

Open
SuperSuperSuperSuper5 opened this Issue Jan 4, 2017 · 17 comments

Projects

None yet

3 participants

@SuperSuperSuperSuper5

Dear DVWA user:
I install it in centos7 and make all but it have a error.

Writable file /var/www/html/dvwa/external/phpids/0.6/lib/IDS/tmp/phpids_log.txt: No

and i set the phpids_log.txt:

[root@localhost tmp]# ls -il
total 4
567459 -rwxrwxrwx. 1 apache apache 319 Oct  5  2015 phpids_log.txt

but it still not work, so can anybody help me?

Thank very much

@digininja
Contributor
@SuperSuperSuperSuper5

Can't use the login.php, when i type login.php in address, it jump to setup.php

[root@localhost tmp]# pwd
/var/www/html/dvwa/external/phpids/0.6/lib/IDS/tmp
[root@localhost tmp]# ls -al
total 8
drwxrwxr-x. 2 root   root     27 Jan  4 15:21 .
drwxrwxr-x. 8 root   root   4096 Oct  5  2015 ..
-rwxrwxrwx. 1 apache apache  319 Oct  5  2015 phpids_log.txt
[root@localhost tmp]# 
@digininja
Contributor
@SuperSuperSuperSuper5
Database Setup

Click on the 'Create / Reset Database' button below to create or reset your database.
If you get an error make sure you have the correct user credentials in: /var/www/html/dvwa/config/config.inc.php

If the database already exists, it will be cleared and the data will be reset.
You can also use this to reset the administrator credentials ("admin // password") at any stage.

Setup Check
Operating system: *nix
Backend database: MySQL
PHP version: 5.4.16

Web Server SERVER_NAME: 192.168.100.78

PHP function display_errors: Disabled
PHP function safe_mode: Disabled
PHP function allow_url_include: Enabled
PHP function allow_url_fopen: Enabled
PHP function magic_quotes_gpc: Disabled
PHP module php-gd: Installed

reCAPTCHA key: 6LdK7xITAAzzAAJQTfL7fu6I-0aPl8KHHieAT_yJg

Writable folder /var/www/html/dvwa/hackable/uploads/: Yes)
Writable file /var/www/html/dvwa/external/phpids/0.6/lib/IDS/tmp/phpids_log.txt: No

Status in red, indicate there will be an issue when trying to complete some modules.

Just the writeable file have the red status, when i first install the DVWA, it's all ok, but when i reboot the system, it break, and can't work.

@digininja
Contributor
@SuperSuperSuperSuper5

Yes, you are right, when i try reset the database, and it show:

Could not connect to the database.
Please check the config file.

but, i have been set the config file

[root@localhost config]# pwd
/var/www/html/dvwa/config
[root@localhost config]# cat config.inc.php
<?php

# If you are having problems connecting to the MySQL database and all of the variables below are correct
# try changing the 'db_server' variable from localhost to 127.0.0.1. Fixes a problem due to sockets.
#   Thanks to @digininja for the fix.

# Database management system to use
$DBMS = 'MySQL';
#$DBMS = 'PGSQL'; // Currently disabled

# Database variables
#   WARNING: The database specified under db_database WILL BE ENTIRELY DELETED during setup.
#   Please use a database dedicated to DVWA.
$_DVWA = array();
$_DVWA[ 'db_server' ]   = '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwa';
$_DVWA[ 'db_user' ]     = 'root';
$_DVWA[ 'db_password' ] = 'dvwapassword';

# Only used with PostgreSQL/PGSQL database selection.
$_DVWA[ 'db_port '] = '5432';

# ReCAPTCHA settings
#   Used for the 'Insecure CAPTCHA' module
#   You'll need to generate your own keys at: https://www.google.com/recaptcha/admin/create
$_DVWA[ 'recaptcha_public_key' ]  = '6LdK7xITAAzzAAJQTfL7fu6I-0aPl8KHHieAT_yJg';
$_DVWA[ 'recaptcha_private_key' ] = '6LdK7xITAzzAAL_uw9YXVUOPoIHPZLfw2K1n5NVQ';

# Default security level
#   Default value for the secuirty level with each session.
#   The default is 'impossible'. You may wish to set this to either 'low', 'medium', 'high' or impossible'.
$_DVWA[ 'default_security_level' ] = 'impossible';

# Default PHPIDS status
#   PHPIDS status with each session.
#   The default is 'disabled'. You can set this to be either 'enabled' or 'disabled'.
$_DVWA[ 'default_phpids_level' ] = 'disabled';

# Verbose PHPIDS messages
#   Enabling this will show why the WAF blocked the request on the blocked request.
#   The default is 'disabled'. You can set this to be either 'true' or 'false'.
$_DVWA[ 'default_phpids_verbose' ] = 'false';

?>
[root@localhost config]# 

and mysql service is running

[root@localhost config]# service mariadb status
Redirecting to /bin/systemctl status  mariadb.service
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2017-01-04 14:58:19 CST; 2h 1min ago
 Main PID: 1728 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─1728 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─2449 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mar...

Jan 04 14:58:12 localhost.localdomain systemd[1]: Starting MariaDB database server...
Jan 04 14:58:14 localhost.localdomain mysqld_safe[1728]: 170104 14:58:14 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Jan 04 14:58:15 localhost.localdomain mysqld_safe[1728]: 170104 14:58:15 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Jan 04 14:58:19 localhost.localdomain systemd[1]: Started MariaDB database server.

The password of mysql is right, but i don't know why it can't connect...
Thank you to answer my question

@digininja
Contributor
@SuperSuperSuperSuper5

it show :

[root@localhost config]# mysql -pdvwapassword -u root -H 127.0.0.1
ERROR 1049 (42000): Unknown database '127.0.0.1'
@SuperSuperSuperSuper5

Should I open the 3306 port use the firewall-cmd or otherwise...

@digininja
Contributor
@SuperSuperSuperSuper5

maybe it should be -h instead of -H...

[root@localhost config]# mysql -pdvwapassword -u root -H 127.0.0.1
ERROR 1049 (42000): Unknown database '127.0.0.1'
[root@localhost config]# mysql -pdvwapassword -u root -h 127.0.0.1
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> quit;
Bye
[root@localhost config]#

and the mysql --help show the -H is

-H, --html          Produce HTML output.
-h, --host=name     Connect to host.
@digininja
Contributor
@SuperSuperSuperSuper5

Dear @digininja :
Yes, it work!

I will put the way and make other guys who have the same problem:

[root@localhost config]# cat config.inc.php
<?php

# If you are having problems connecting to the MySQL database and all of the variables below are correct
# try changing the 'db_server' variable from localhost to 127.0.0.1. Fixes a problem due to sockets.
#   Thanks to @digininja for the fix.

# Database management system to use
$DBMS = 'MySQL';
#$DBMS = 'PGSQL'; // Currently disabled

# Database variables
#   WARNING: The database specified under db_database WILL BE ENTIRELY DELETED during setup.
#   Please use a database dedicated to DVWA.
$_DVWA = array();
$_DVWA[ 'db_server' ]   = 'localhost';
$_DVWA[ 'db_database' ] = 'dvwa';
$_DVWA[ 'db_user' ]     = 'root';
$_DVWA[ 'db_password' ] = 'dvwapassword';

# Only used with PostgreSQL/PGSQL database selection.
$_DVWA[ 'db_port '] = '5432';

# ReCAPTCHA settings
#   Used for the 'Insecure CAPTCHA' module
#   You'll need to generate your own keys at: https://www.google.com/recaptcha/admin/create
$_DVWA[ 'recaptcha_public_key' ]  = '6LdK7xITAAzzAAJQTfL7fu6I-0aPl8KHHieAT_yJg';
$_DVWA[ 'recaptcha_private_key' ] = '6LdK7xITAzzAAL_uw9YXVUOPoIHPZLfw2K1n5NVQ';

# Default security level
#   Default value for the secuirty level with each session.
#   The default is 'impossible'. You may wish to set this to either 'low', 'medium', 'high' or impossible'.
$_DVWA[ 'default_security_level' ] = 'impossible';

# Default PHPIDS status
#   PHPIDS status with each session.
#   The default is 'disabled'. You can set this to be either 'enabled' or 'disabled'.
$_DVWA[ 'default_phpids_level' ] = 'disabled';

# Verbose PHPIDS messages
#   Enabling this will show why the WAF blocked the request on the blocked request.
#   The default is 'disabled'. You can set this to be either 'true' or 'false'.
$_DVWA[ 'default_phpids_verbose' ] = 'false';

?>
[root@localhost config]#

change the

$_DVWA[ 'db_server' ]   = '127.0.0.1';
$_DVWA[ 'db_server' ]   = 'localhost';

and reset the database, it will work and jump to login web page

Thank you very much @digininja

@SuperSuperSuperSuper5

But i have another question, how to make the

/var/www/html/dvwa/external/phpids/0.6/lib/IDS/tmp/phpids_log.txt

writeable?

@mike-bailey

chmod +w /var/www/html/dvwa/external/phpids/0.6/lib/IDS/tmp/phpids_log.txt

Please google 😛

@SuperSuperSuperSuper5

@mike-bailey Oh, it was a way, but it seem doesn't work as we want...

[root@localhost tmp]# ls -il
total 4
567459 -rwxrwxrwx. 1 root apache 319 Oct  5  2015 phpids_log.txt
[root@localhost tmp]# 

As you see, the phpids_log.txt is 777 privilege, and it still not work...

Writable folder /var/www/html/dvwa/hackable/uploads/: Yes)
Writable file /var/www/html/dvwa/external/phpids/0.6/lib/IDS/tmp/phpids_log.txt: No

I think it was a bug...

@digininja
Contributor

@mike-bailey that will make it writable for the owner which doesn't help unless the owner is apache, you need to either change ownership or give wider permissions with either g+w or a+w.

@SuperSuperSuperSuper5 I've just checked and there isn't a bug on it, it works and detects the permissions correctly. Can you do this and show the results:

ls -l /var/www/html/dvwa/external/phpids/0.6/lib/IDS/tmp/phpids_log.txt

The set up page doesn't detect it but you also need to have the directory writable as well but that is usually indicated by an error on the top of the page when the IDS is enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment