在bash中運行php檔案內容,可以執行一些指令嗎?

在bash中運行php檔案內容,可以執行一些指令嗎?

我不小心將其作為生產伺服器上的超級用戶貼到 bash 中。

現在我正在吃指甲。

我查看了每一行,大多數都產生語法錯誤。但是有什麼邪惡的東西可能會損壞伺服器作業系統嗎?或文件?或者什麼?

這是 ubuntu 伺服器 14.04。

我如何診斷運行了哪些命令以及它們做了什麼?

歷史是顯而易見的地方,但它沒有顯示運行過什麼以及由哪個程式運行。有沒有辦法診斷這種愚蠢行為?

<?php
/**
 * The base configurations of the WordPress.
 *
 * This file has the following configurations: MySQL settings, Table Prefix,
 * Secret Keys, WordPress Language, and ABSPATH. You can find more information
 * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
 * wp-config.php} Codex page. You can get the MySQL settings from your web host.
 *
 * This file is used by the wp-config.php creation script during the
 * installation. You don't have to use the web site, you can just copy this file
 * to "wp-config.php" and fill in the values.
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', '');

/** MySQL database username */
define('DB_USER', '');

/** MySQL database password */
define('DB_PASSWORD', '');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         'N%___i}IF<(o&h<;|_/0g-OYxEeU)Pq_JM@x!`S^-*[*$$#`|Lp|4R|');
define('SECURE_AUTH_KEY',  '.JyD{}94,kBQB`>&>)sT@4bMl|}SxJQ~ 1NUw^RdQ;QrLVC#].#64k');
define('LOGGED_IN_KEY',    '2ClY{7eA4933w3qEQ(L>o<{`WD|t-b4B<KW;psm6qa_Mmk.f~N1$]8');
define('NONCE_KEY',        ' $QAiTez.wIq_},tNekyQYgU3:;>y-[LT-vR8X{r+kuG-t!C>');
define('AUTH_SALT',        '!#0MnA@UTy]~CN#[Akn-2M<fEuGjSH,*Bu7B[!@@.owHb:G-_PXvP_');
define('SECURE_AUTH_SALT', '%DXWY0|+SkU%!aC.aXG#T{ |YZE|X.VyfVx8QW:bX+2sZ(7cw98i');
define('LOGGED_IN_SALT',   '{d}Pn%i>?B &Q@#Dw+*Xal^eD`xK4wet8=k+F9Tr2}2H75.@+{g+)');
define('NONCE_SALT',       ']3gOf&v-43GEe`hOqnu_1TwZeqU!ZIm-8}Lm1&0;pW7d`,4[QTT');

/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 */
define('WP_DEBUG', false);

/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

答案1

如果這種情況發生在包含(非隱藏)文件的目錄中,則以 開頭的任何行*都會擴展到該目錄中的(非隱藏)文件列表,因此將嘗試將第一個文件作為命令1執行。如果你.的 中有PATH,它會嘗試執行那個文件;如果它不可執行,你只會得到一個錯誤。如果您.的 中沒有PATH,它將嘗試使用該名稱執行命令。例如,萬一您的目前目錄包含以下文件

rm
romeo
sierra
tango

那麼

* The base configurations of the WordPress.

命令將擴展為

rm romeo sierra tango The base configurations of the WordPress.

我希望您現在已經注意到是否發生了這種情況(但我建議您執行 aecho *來查看第一個檔案是否是有效的命令)。

對於以 開頭的行也有類似的擔憂/**,但這可能會擴展到類似 的內容/bin /dev /etc /home /lib …,這將導致

bash: /bin: is a directory

萬一您有一個名為 的 shell 變量table_prefix,那麼

$table_prefix  = 'wp_';

將擴展該變數並嘗試執行它。如果table_prefix沒有定義,那麼上面的命令將嘗試=作為命令執行(據我所知,標準 Unix 系統上沒有這樣的命令)。

沒有其他事情對我來說是個問題。


1   除非該行中存在其他導致語法錯誤的內容,例如不平衡的).

相關內容