npm 包 buttercup 使用教程

阅读时长 10 分钟读完

随着前端技术的不断发展,现代前端开发离不开使用各种库和工具。而 npm 就是前端领域最受欢迎的包管理工具之一。本文将介绍一个非常有用的 npm 包,叫做 buttercup,让你能够更方便地管理你的密码和私密信息。这篇文章将从以下几个方面进行详细的介绍:

  • buttercup 是什么?
  • 如何安装和使用 buttercup?
  • buttercup 的常见用法

buttercup 是什么?

Buttercup 是一个 JavaScript 库,它提供了一套加密和安全的 API,可以用来存储和管理密码、证书和其他机密信息。它可以在前端和后端使用,并提供了在桌面环境中的应用程序。

Buttercup 提供了许多方便的 API,可以用于创建、读取和编辑密码库。密码库是一个包含许多密码和其他私有数据的文档,可以使用 buttercup 库来管理和存储。但是,在开始使用之前,我们需要安装和设置它。

如何安装和使用 buttercup?

安装 buttercup 最简单的方法是使用 npm。在命令行中运行以下命令即可:

然后,我们就可以在 JavaScript 中引入 buttercup:

引入之后,就可以使用 buttercup 包提供的 API 进行加密工作操作了。但在操作之前,我们需要先学习每个 API 的方法和参数。

buttercup 的常见用法

对于 Buttercup 的常见用例,我们将使用一个基本的密码库,并创建以下几个条目:

-- -------------------- ---- -------
----- ------------- - --- ------------------
-----------------------------------------------
  -
    ----- --------------
    ----------- -
      ------ --- -------- -------
    --
    --------- -
      -
        ----- --------
        ----------- -
          ------ --------
        --
        --------- -
          -
            ----- --------------
            ----------- -
              ------ --------
              --------- ----------------
              --------- ------------
            --
          --
          -
            ----- --------------
            ----------- -
              ------ ------ ------
              --------- ----------------
              --------- ------------
            --
          --
        --
      --
      -
        ----- --------
        ----------- -
          ------ ----------
        --
        --------- -
          -
            ----- --------------
            ----------- -
              ------ ------ ------
              --------- ----------
              --------- ------------
            --
          --
        --
      --
    --
  --
  --- ---------
--
展开代码

创建密码库

要创建一个新的密码库,我们需要使用 Vault 类:

密码库习惯存储在云端,但我们也可以把它存储在一个本地文件中。对于本地存储,我们需要导入以下包:

将密码库保存到本地文件

在上面的示例中,我们首先将密码库加密。接下来,我们将密文编码为 Base64 格式,并将它们写入文件,文件名为 MyVault.bcup。请注意,如果文件已经存在,它会被覆盖。

加载本地密码库

用于解锁密码库的密码也必须要特别设置。比如,对于使用刚刚创建 My password 这个密码库,则解锁密码为 My password。

获取和更新密码条目

-- -------------------- ---- -------
----- ------------ - ---------------------------------------------
  --------
  -
    --------- ----------------
  -
--

-- -----
--------------------------------------------------

-- -----
------------------------------------ ---------------
展开代码

注意,更新后密码条目需要重新加密。

删除密码条目

如果我们需要更改整个密码条目,我们可以使用以下方法:

-- -------------------- ---- -------
----- ----------------- - --- -----------------
  --------------
  -
    ------ --------
    --------- ----------------
    --------- --------------
  --
  -
    - --- ---------- ----- ------- --
    - --- ---------- ----- ------- --
  -
--

-----------------------------------------
-------------------------------------------
展开代码

搜索密码条目

search 方法将在密码库中查找与搜索关键字匹配的所有项目。

总结:以上是 buttercup 的基本使用方法,它提供了简单易用的 API,可以方便地进行密码安全管理,同时推荐尝试使用 buttercup 应用程序,来管理和存储你的密码库。在使用过程中,我们需要详细了解 buttercup 提供的 API 方法和参数,才能够更好地使用它。# NSE Script for Buttercup Vulnerabilities

This Nmap NSE script will scan targets for the Buttercup Password Manager web interface and test for the exploits:

  • A remote attacker can execute arbitrary code

  • A remote attacker can view all stored credentials

Installation

  1. Install the buttercup-nse.lua script in the <nmap_installation_dir>/scripts or the directory specified by the --script-path option.

  2. Modify the filepath in the script to point to your own API endpoint.

  3. Run the scan by specifying the target(s) and the script:

Output

-- -------------------- ---- -------
---- ------ --------
- --------------
-   -----------
-   ------ -------- --- ------- --------- ---- ---------------
-     ------ ----------
-     -------
-   ------ -------- --- ---- --- ------ -----------
-     ------ ----------
-     -------
--      ------- -- ------
展开代码

Example Usage

-- -------------------- ---- -------
- ---- -- --- -------------------------- -------------

-------- ---- ---- - ---------------- - -- ---------- ----- ---
---- ---- ------ --- -------------
---- -- -- -------- ---------
---- ------ --- -------------- --------
----    ----- -------
------- ----  -----
- --------------
-   -----------
-   ------ -------- --- ------- --------- ---- ---------------
-     ------ ----------
-     -------
-   ------ -------- --- ---- --- ------ -----------
-     ------ ----------
-     -------
--      ------- -- ------

---- ----- - -- ------- -- ---- --- ------- -- ---- -------
展开代码

Reference

来源:JavaScript中文网 ,转载请注明来源 https://www.javascriptcn.com/post/70109

纠错
反馈

纠错反馈