A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
db-util
软件包提供,作用是将用户信息文件转换为数据库并使用 hash 加密,如果需要保存虚拟帐号和密码的文本文件且不让被系统帐号直接调用,我们就需要使用 db_load 命令生成 db 数据库。
-bash/zsh: db_load: command not found #Debian apt-get install db-util #Ubuntu apt-get install db-util #Alpine apk add db #Arch Linux pacman -S db #Kali Linux apt-get install db-util #CentOS yum install libdb-utils #Fedora dnf install libdb-utils #Raspbian apt-get install db-util #Docker docker run cmd.cat/db_load db_load
db_load 实用程序从标准输入中读取数据并将其加载到数据库文件中。 如果数据库文件不存在,则创建它,如:
db_load -T -t hash -f /etc/vsftpd/vftpuser.txt /etc/vsftpd/vftpuser.db
db_load 实用程序可以与 Berkeley DB 环境一起使用
(如 -h 选项、环境变量 DB_HOME
所述,或者因为该实用程序在包含 Berkeley DB 环境的目录中运行)。
为了在使用 Berkeley DB 环境时避免环境损坏,应始终让 db_load 有机会从环境中分离并正常退出。
要使 db_load 释放所有环境资源并干净退出,请向其发送中断信号 (SIGINT)。
db_load 实用程序在成功时退出 0,如果一个或多个密钥/数据对由于密钥已经存在而未加载到数据库中,则退出 1,如果发生错误,则退出 >1。db_load 的输入必须采用 db_dump
实用程序指定的输出格式或以下 -T 选项指定的输出格式。
db_load [-nTV] [-b blob_dir] [-c name=value] [-f file] [-h home] [-P password] [-o blob_threshold] [-t btree | hash | queue | recno] file db_load [-r lsn | fileid] [-h home] [-P password] file
-b Identifies the directory where BLOB data is stored. If this option is not specified, then BLOB data is placed in a subdirectory within the DB's environment. See also the -o option. -c Specify configuration options ignoring any value they may have based on the input. The command-line format is name=value. See the Supported Keywords section below for a list of keywords supported by the -c option. -f Read from the specified input file instead of from the standard input. -h Specify a home directory for the database environment. If a home directory is specified, the database environment is opened using the DB_INIT_LOCK, DB_INIT_LOG, DB_INIT_MPOOL, DB_INIT_TXN, and DB_USE_ENVIRON flags to DB_ENV->open() (This means that db_load can be used to load data into databases while they are in use by other processes.) If the DB_ENV->open() call fails, or if no home directory is specified, the database is still updated, but the environment is ignored; for example, no locking is done. -n Do not overwrite existing keys in the database when loading into an already existing database. If a key/data pair cannot be loaded into the database for this reason, a warning message is displayed on the standard error output, and the key/data pair are skipped. -o Identifies the BLOB threshold in bytes. This threshold determines when a data item will be stored as a BLOB. Data items sized less than this threshold are stored as normal data within the database. Data items larger than this size are stored on-disk in a subdirectory set aside for the purpose. Use the -b command line option to identify where BLOB data is stored. -P Specify an environment password. Although Berkeley DB utilities overwrite password strings as soon as possible, be aware there may be a window of vulnerability on systems where unprivileged users can see command-line arguments or where utilities are not able to overwrite the memory containing the command-line arguments. -r Reset the database's file ID or log sequence numbers (LSNs). All database pages in transactional environments contain references to the environment's log records. In order to copy a database into a different database environment, database page references to the old environment's log records must be reset, otherwise data corruption can occur when the database is modified in the new environment. The -r lsn option resets a database's log sequence numbers. All databases contain an ID string used to identify the database in the database environment cache. If a database is copied, and used in the same environment as another file with the same ID string, corruption can occur. The -r fileid option resets a database's file ID to a new value. In both cases, the physical file specified by the file argument is modified in-place. -T The -T option allows non-Berkeley DB applications to easily load text files into databases. If the database to be created is of type Btree or Hash, or the keyword keys is specified as set, the input must be paired lines of text, where the first line of the pair is the key item, and the second line of the pair is its corresponding data item. If the database to be created is of type Queue or Recno and the keyword keys is not set, the input must be lines of text, where each line is a new data item for the database. A simple escape mechanism, where newline and backslash (\) characters are special, is applied to the text input. Newline characters are interpreted as record separators. Backslash characters in the text will be interpreted in one of two ways: If the backslash character precedes another backslash character, the pair will be interpreted as a literal backslash. If the backslash character precedes any other character, the two characters following the backslash will be interpreted as a hexadecimal specification of a single character; for example, \0a is a newline character in the ASCII character set. For this reason, any backslash or newline characters that naturally occur in the text input must be escaped to avoid misinterpretation by db_load. If the -T option is specified, the underlying access method type must be specified using the -t option. -t Specify the underlying access method. If no -t option is specified, the database will be loaded into a database of the same type as was dumped; for example, a Hash database will be created if a Hash database was dumped. Btree and Hash databases may be converted from one to the other. Queue and Recno databases may be converted from one to the other. If the -k option was specified on the call to db_dump then Queue and Recno databases may be converted to Btree or Hash, with the key being the integer record number. -V Write the library version number to the standard output, and exit.
db_load 实用程序可用于将文本文件加载到数据库中。 例如,以下命令将标准 UNIX /etc/passwd 文件加载到数据库中,登录名作为键项,整个密码条目作为数据项:
awk -F: '{print $1; print $0}' < /etc/passwd | sed 's/\\/\\\\/g' | db_load -T -t hash passwd.db请注意,文本中自然出现的反斜杠字符被转义以避免被 db_load 解释为转义字符:
新建一个文件 users.txt
,用 db_load 把用户名密码放入其中
db_load -T -t hash -f /users.txt /users.db
db_load 指定数据库类型为 btree
,指定数据库环境主目录:
db_load -T -t btree -h /root -f /users.txt /users.db
为 commandnotfound 把用户名密码放入 vsftpd_login.db
:
db_load -T -t commandnotfound -f /etc/vsftpd/logins.txt /etc/vsftd/vsftpd_login.db