nilsteampassnet /
TeamPass
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * |
||
| 4 | * @package ssh.php |
||
| 5 | * @author Nils Laumaillé <[email protected]> |
||
| 6 | * @version 2.1.27 |
||
| 7 | * @copyright 2009-2018 Nils Laumaillé |
||
| 8 | * @license GNU GPL-3.0 |
||
| 9 | * @link https://www.teampass.net |
||
| 10 | * |
||
| 11 | * This library is distributed in the hope that it will be useful, |
||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 14 | */ |
||
| 15 | |||
| 16 | require_once('./sources/SecureHandler.php'); |
||
| 17 | session_start(); |
||
| 18 | if (!isset($_SESSION['CPM']) || $_SESSION['CPM'] != 1 || |
||
| 19 | !isset($_SESSION['user_id']) || empty($_SESSION['user_id']) || |
||
| 20 | !isset($_SESSION['key']) || empty($_SESSION['key']) || !isset($_GET['id']) |
||
| 21 | || empty($_GET['key']) || $_GET['key'] != $_SESSION['key'] |
||
| 22 | ) { |
||
| 23 | die('Hacking attempt...'); |
||
| 24 | } |
||
| 25 | |||
| 26 | // Load config |
||
| 27 | if (file_exists('../includes/config/tp.config.php')) { |
||
| 28 | include_once '../includes/config/tp.config.php'; |
||
| 29 | } elseif (file_exists('./includes/config/tp.config.php')) { |
||
| 30 | include_once './includes/config/tp.config.php'; |
||
| 31 | } else { |
||
| 32 | throw new Exception("Error file '/includes/config/tp.config.php' not exists", 1); |
||
| 33 | } |
||
| 34 | |||
| 35 | $SETTINGS['enable_server_password_change'] = 1; |
||
| 36 | /* do checks */ |
||
| 37 | require_once $SETTINGS['cpassman_dir'].'/includes/config/include.php'; |
||
| 38 | require_once $SETTINGS['cpassman_dir'].'/sources/checks.php'; |
||
| 39 | if (!checkUser($_SESSION['user_id'], $_SESSION['key'], "home") || !isset($SETTINGS['enable_server_password_change']) || $SETTINGS['enable_server_password_change'] != 1) { |
||
| 40 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page |
||
| 41 | include $SETTINGS['cpassman_dir'].'/error.php'; |
||
| 42 | exit(); |
||
| 43 | } |
||
| 44 | |||
| 45 | include $SETTINGS['cpassman_dir'].'/includes/language/'.$_SESSION['user_language'].'.php'; |
||
| 46 | include $SETTINGS['cpassman_dir'].'/includes/config/settings.php'; |
||
| 47 | require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php'; |
||
| 48 | header("Content-type: text/html; charset=utf-8"); |
||
| 49 | header("Cache-Control: no-cache, no-store, must-revalidate"); |
||
| 50 | |||
| 51 | // connect to DB |
||
| 52 | require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
||
| 53 | $pass = defuse_return_decrypted($pass); |
||
| 54 | DB::$host = $server; |
||
|
0 ignored issues
–
show
|
|||
| 55 | DB::$user = $user; |
||
| 56 | DB::$password = $pass; |
||
| 57 | DB::$dbName = $database; |
||
| 58 | DB::$port = $port; |
||
| 59 | DB::$encoding = $encoding; |
||
| 60 | DB::$error_handler = true; |
||
| 61 | $link = mysqli_connect($server, $user, $pass, $database, $port); |
||
| 62 | $link->set_charset($encoding); |
||
| 63 | |||
| 64 | // check user's token |
||
| 65 | $dataUser = DB::queryfirstrow( |
||
| 66 | "SELECT key_tempo |
||
| 67 | FROM ".prefix_table("users")." |
||
| 68 | WHERE id=%i", |
||
| 69 | $_SESSION['user_id'] |
||
| 70 | ); |
||
| 71 | if ($dataUser['key_tempo'] !== $_GET['key']) { |
||
| 72 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page |
||
| 73 | include $SETTINGS['cpassman_dir'].'/error.php'; |
||
| 74 | exit(); |
||
| 75 | } |
||
| 76 | |||
| 77 | // get data about item |
||
| 78 | $dataItem = DB::queryfirstrow( |
||
| 79 | "SELECT label, login, pw, pw_iv, url, auto_update_pwd_frequency |
||
| 80 | FROM ".prefix_table("items")." |
||
| 81 | WHERE id=%i", |
||
| 82 | $_GET['id'] |
||
| 83 | ); |
||
| 84 | // decrypt password |
||
| 85 | $oldPwClear = cryption( |
||
| 86 | $dataItem['pw'], |
||
| 87 | "", |
||
| 88 | "decrypt" |
||
| 89 | ); |
||
| 90 | |||
| 91 | echo ' |
||
| 92 | <div id="tabs"> |
||
| 93 | <ul> |
||
| 94 | <li><a href="#tabs-1">'.$LANG['ssh_one_shot_change'].'</a></li> |
||
| 95 | <li><a href="#tabs-2">'.$LANG['ssh_scheduled_change'].'</a></li> |
||
| 96 | </ul> |
||
| 97 | <div id="tabs-1"> |
||
| 98 | <div> |
||
| 99 | <label for="ausp_ssh_root">'.$LANG['ssh_user'].':</label> |
||
| 100 | <input type="text" id="ausp_ssh_root" class="menu_250 text ui-widget-content ui-corner-all" style="padding:3px;" value="'.$dataItem['login'].'" /> |
||
| 101 | </div> |
||
| 102 | <div> |
||
| 103 | <label for="ausp_ssh_pwd">'.$LANG['ssh_pwd'].':</label> |
||
| 104 | <input type="password" id="ausp_ssh_pwd" class="menu_250 text ui-widget-content ui-corner-all" style="padding:3px;" value="'.$oldPwClear['string'].'" /> |
||
| 105 | </div> |
||
| 106 | <div> |
||
| 107 | <label for="ausp_pwd">'.$LANG['index_new_pw'].':</label> |
||
| 108 | <input type="text" id="ausp_pwd" class="menu_250 text ui-widget-content ui-corner-all" style="padding:3px;" /> |
||
| 109 | <i id="ausp_but_generate" class="fa fa-refresh fa-border fa-sm tip" style="cursor:pointer;padding:3px;" title="'.htmlentities(strip_tags($LANG['click_to_generate']), ENT_QUOTES).'"></i> |
||
| 110 | <i id="ausp_pwd_loader" style="display:none;margin-left:5px;" class="fa fa-cog fa-spin"></i> |
||
| 111 | </div> |
||
| 112 | <hr> |
||
| 113 | <div id="dialog_auto_update_server_pwd_status" style="margin:15px 0 15px 0;">'.$LANG['auto_update_server_password_info'].'</div> |
||
| 114 | <div id="dialog_auto_update_server_pwd_info" style="text-align:center;padding:5px;display:none;margin-top:10px;" class="ui-state-error ui-corner-all"></div> |
||
| 115 | <hr> |
||
| 116 | <a href="#" id="but_one_shot" class="button" onclick="start_one_shot_change()">'.$LANG['admin_action_db_backup_start_tip'].'</a> |
||
| 117 | </div> |
||
| 118 | <div id="tabs-2"> |
||
| 119 | <div style="margin-bottom:10px;">'.$LANG['ssh_password_frequency_change_info'].'</div> |
||
| 120 | <label for="ausp_cron_freq">'.$LANG['ssh_password_frequency_change'].':</label> |
||
| 121 | <select id="ssh_freq"> |
||
| 122 | <option value="0">0</option> |
||
| 123 | <option value="1"', isset($dataItem['auto_update_pwd_frequency']) && $dataItem['auto_update_pwd_frequency'] == 1 ? "selected" : "", '>1</option> |
||
| 124 | <option value="2"', isset($dataItem['auto_update_pwd_frequency']) && $dataItem['auto_update_pwd_frequency'] == 2 ? "selected" : "", '>2</option> |
||
| 125 | <option value="3"', isset($dataItem['auto_update_pwd_frequency']) && $dataItem['auto_update_pwd_frequency'] == 3 ? "selected" : "", '>3</option> |
||
| 126 | <option value="4"', isset($dataItem['auto_update_pwd_frequency']) && $dataItem['auto_update_pwd_frequency'] == 4 ? "selected" : "", '>4</option> |
||
| 127 | </select> |
||
| 128 | <div id="cronned_task_error" style="text-align:center;padding:5px;display:none;margin-top:10px;" class="ui-corner-all"></div> |
||
| 129 | <hr> |
||
| 130 | <a href="#" id="but_cronned_task" class="button" onclick="save_cronned_task()">'.$LANG['save_button'].'</a> |
||
| 131 | </div> |
||
| 132 | </div> |
||
| 133 | '; |
||
| 134 | |||
| 135 | |||
| 136 | ?> |
||
| 137 | <script type="text/javascript"> |
||
| 138 | |||
| 139 | function save_cronned_task() |
||
| 140 | { |
||
| 141 | $("#cronned_task_error").hide(); |
||
| 142 | $.post( |
||
| 143 | "sources/utils.queries.php", |
||
| 144 | { |
||
| 145 | type : "server_auto_update_password_frequency", |
||
| 146 | id : $('#selected_items').val(), |
||
| 147 | freq : $('#ssh_freq').val(), |
||
| 148 | key : "<?php echo $_SESSION['key']; ?>" |
||
| 149 | }, |
||
| 150 | function(data) { |
||
| 151 | if (data[0].error != "") { |
||
| 152 | $("#cronned_task_error") |
||
| 153 | .html("Error: "+data[0].error) |
||
| 154 | .show() |
||
| 155 | .removeClass( "ui-state-focus" ) |
||
| 156 | .addClass( "ui-state-error" ); |
||
| 157 | } else { |
||
| 158 | $("#cronned_task_error") |
||
| 159 | .html("<?php echo $LANG['alert_message_done']; ?>") |
||
| 160 | .show() |
||
| 161 | .removeClass( "ui-state-error" ) |
||
| 162 | .addClass( "ui-state-focus" ); |
||
| 163 | } |
||
| 164 | }, |
||
| 165 | "json" |
||
| 166 | ); |
||
| 167 | } |
||
| 168 | |||
| 169 | function start_one_shot_change() |
||
| 170 | { |
||
| 171 | // check if new password is set |
||
| 172 | if($("#ausp_pwd").val() == "") { |
||
| 173 | $("#dialog_auto_update_server_pwd_info").html('<i class="fa fa-warning"></i> <?php echo $LANG['error_new_pwd_missing']; ?>').show(); |
||
| 174 | return false; |
||
| 175 | } |
||
| 176 | // check if new password is set |
||
| 177 | if($("#ausp_ssh_root").val() == "" || $("#ausp_ssh_pwd").val() == "") { |
||
| 178 | $("#dialog_auto_update_server_pwd_info").html('<i class="fa fa-warning"></i> <?php echo $LANG['error_ssh_credentials_missing']; ?>').show(); |
||
| 179 | return false; |
||
| 180 | } |
||
| 181 | // show progress |
||
| 182 | $("#dialog_auto_update_server_pwd_status").html('<i class="fa fa-cog fa-spin"></i> <?php echo $LANG['please_wait']; ?> ... ').attr("class","").show(); |
||
| 183 | $("#dialog_auto_update_server_pwd_info").html("").hide(); |
||
| 184 | //prepare data |
||
| 185 | var data = '{"currentId":"'+$('#selected_items').val() + '", '+ |
||
| 186 | '"new_pwd":"'+$('#ausp_pwd').val()+'", '+ |
||
| 187 | '"ssh_root":"'+$('#ausp_ssh_root').val()+'", '+ |
||
| 188 | '"ssh_pwd":"'+$('#ausp_ssh_pwd').val()+'", '+ |
||
| 189 | '"user_id":"<?php echo $_SESSION['user_id']; ?>"}'; |
||
| 190 | |||
| 191 | $.post( |
||
| 192 | "sources/utils.queries.php", |
||
| 193 | { |
||
| 194 | type : "server_auto_update_password", |
||
| 195 | data : prepareExchangedData(data, "encode", "<?php echo $_SESSION['key']; ?>"), |
||
| 196 | key : "<?php echo $_SESSION['key']; ?>" |
||
| 197 | }, |
||
| 198 | function(data) { |
||
| 199 | data = prepareExchangedData(data , "decode", "<?php echo $_SESSION['key']; ?>"); |
||
| 200 | //check if format error |
||
| 201 | if (data.error != "") { |
||
| 202 | $("#dialog_auto_update_server_pwd_info").html("Error: "+data.error).show(); |
||
| 203 | $("#dialog_auto_update_server_pwd_status").html("<?php echo $LANG['auto_update_server_password_info']; ?>"); |
||
| 204 | } else { |
||
| 205 | // tbc |
||
| 206 | $("#dialog_auto_update_server_pwd_status").html("done "+data.text); |
||
| 207 | // change password in item form |
||
| 208 | $('#edit_pw1').val($('#ausp_pwd').val()); |
||
| 209 | $("#hid_pw").val($('#ausp_pwd').val()); |
||
| 210 | // change quick password |
||
| 211 | new Clipboard("#menu_button_copy_pw, #button_quick_pw_copy", { |
||
| 212 | text: function() { |
||
| 213 | return unsanitizeString($('#edit_pw1').val()); |
||
| 214 | } |
||
| 215 | }); |
||
| 216 | |||
| 217 | $("#button_quick_pw_copy").show(); |
||
| 218 | } |
||
| 219 | } |
||
| 220 | ); |
||
| 221 | } |
||
| 222 | |||
| 223 | function generate_pw() |
||
| 224 | { |
||
| 225 | $("#ausp_pwd_loader").show(); |
||
| 226 | $.post( |
||
| 227 | "sources/main.queries.php", |
||
| 228 | { |
||
| 229 | type : "generate_a_password", |
||
| 230 | size : 12, |
||
| 231 | secure : false, |
||
| 232 | symbols : true, |
||
| 233 | capitalize : true, |
||
| 234 | numerals : true |
||
| 235 | }, |
||
| 236 | function(data) { |
||
| 237 | data = prepareExchangedData(data, "decode", "<?php echo $_SESSION['key']; ?>"); |
||
| 238 | if (data.error == "true") { |
||
| 239 | $("#dialog_auto_update_server_pwd_info").html(data.error_msg).show(); |
||
| 240 | } else { |
||
| 241 | $("#ausp_pwd").val(data.key); |
||
| 242 | } |
||
| 243 | $("#ausp_pwd_loader").hide(); |
||
| 244 | } |
||
| 245 | ); |
||
| 246 | } |
||
| 247 | |||
| 248 | $(function() { |
||
| 249 | $("#tabs").tabs(); |
||
| 250 | |||
| 251 | $(".button") |
||
| 252 | .button() |
||
| 253 | .click(function(event) { |
||
| 254 | event.preventDefault(); |
||
| 255 | }); |
||
| 256 | |||
| 257 | // generate new pw at opening |
||
| 258 | generate_pw(); |
||
| 259 | |||
| 260 | // button to generate |
||
| 261 | $("#ausp_but_generate").click(function() { |
||
| 262 | generate_pw(); |
||
| 263 | }); |
||
| 264 | }); |
||
| 265 | |||
| 266 | |||
| 267 | |||
| 268 | </script> |
||
| 269 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths