Perl的盐生成的WP-CONFIG-sample.php [英] Perl Salt Generation on wp-config-sample.php
问题描述
我已经做了很多的研究,以找到一个方法来做到这一点,但我的短来了。我正在寻找一种方式来取代所有的'把你独特的词组在这里
与随机生成的盐。
I've done a lot of research to find a way to do this, but I'm coming up short. I'm looking for a way to replace all of the 'put your unique phrase here'
with randomly generated salts.
下面是配置的我需要修改的部分:
Here is the section of the config I need to edit:
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');
此问题(<一个href=\"http://stackoverflow.com/questions/9437309/bash-sed-find-replace-with-special-characters\">here)接近我想要什么,但预计要编辑的标准WP-CONFIG-sample.php,我不知道这是否会更容易删除整段和替换它,或者只是做某种查找和替换上每一行。
This question (here) is close to what I want but expects the standard wp-config-sample.php to be edited. I don't know if it would be easier to delete that whole section and replace it, or just do some sort of find and replace on each line.
下面是一个code样表我的当前脚本(以及结合下面的答案的尝试..)。
Here is a code sample form my current script (and the attempt at incorporating the answer below..).
sub modify_configs {
my $shell = $_[0];
my $dbname = $_[1];
my $dbuser = $_[2];
my $siteurl = $_[3];
# modify wp-config.php
print BOLD "Modifying configuration files...\n";
chdir($local_dir);
system('perl -pi -e "s/database_name_here/'.$dbname.'/g" wp-config-sample.php');
system('perl -pi -e "s/username_here/'.$dbuser.'/g" wp-config-sample.php');
system('perl -pi -e "s/password_here/'.$pass.'/g" wp-config-sample.php');
my ($keysalts, $flipflop);
`perl -ne 'BEGIN { $keysalts = qx(curl -sS https://api.wordpress.org/secret-key/1.1/salt) } if ( $flipflop = ( m/AUTH_KEY/ .. m/NONCE_SALT/ ) ) {if ( $flipflop =~ /E0$/ ) { printf qq|%s|, $keysalts; } next; } printf qq|%s|, $_;' wp-config-sample.php`;
# rename('wp-config-sample.php', 'wp-config.php');
...
}
这失败:
Use of uninitialized value $keysalts in concatenation (.) or string at ./gen.pl line 101, <MYFILE> line 3.
Use of uninitialized value $flipflop in concatenation (.) or string at ./gen.pl line 101, <MYFILE> line 3.
Use of uninitialized value $flipflop in concatenation (.) or string at ./gen.pl line 101, <MYFILE> line 3.
Use of uninitialized value $keysalts in concatenation (.) or string at ./gen.pl line 101, <MYFILE> line 3.
syntax error at -e line 1, near "{ ="
BEGIN not safe after errors--compilation aborted at -e line 1.
在这里任何帮助将是AP preciated!
Any help here would be appreciated!
感谢。
推荐答案
尝试:
perl -ne '
BEGIN {
$keysalts = qx(curl -sS https://api.wordpress.org/secret-key/1.1/salt)
}
if ( $flipflop = ( m/AUTH_KEY/ .. m/NONCE_SALT/ ) ) {
if ( $flipflop =~ /E0$/ ) {
printf qq|%s|, $keysalts;
}
next;
}
printf qq|%s|, $_;
' wp-config-sample.php
它使用卷曲
作为一个外部命令得到盐,然后通过线路使用触发器$ C $解析输入文件行C>替换
定义的栏目
与随机盐。
It get salts using curl
as an external command and then parses the input file line by line using a flip-flop
to replace the section of defines
with those with random salts.
它产生的(输出的一部分):
It yields (part of output):
...
/** 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', 'CQVDYWT|G!9/ZXd>#}/MB>n?`enZrpx#h,,4/=ev/@4|>H(0vkDDd~Pp!+R-#!4-');
define('SECURE_AUTH_KEY', 'peCpNn5f6c=T$%]@=Lx}C_aQhp;.%aTgrrAyQE 1476!<e%5Ys)0Zab OZtAM7?V');
define('LOGGED_IN_KEY', '.}$YwXKsx|c(k(xZ.Tk{eGMt]#cOM8g,7Z?H{UKQzK1KN8rsIVZuddkW21E{(+q$');
define('NONCE_KEY', 'h]>4cN[U+O>xcQ;H#C+2ZvmOK4oC)TY[|5e(EsT,n+~+aOd+|~e/PN5%N$:7c90/');
define('AUTH_SALT', '1U@V&Fp-v&epA,lzws>GrB]MuG.6[Wdnb:n;FY8Kqn~`1~4_} 3D)o6PzGBeIm-)');
define('SECURE_AUTH_SALT', '2!.I5D<JCo+4UIh>h~3PM?;.]$67;y-t3jp;PzKBNjd(!*6&>6gteX$@fGp_-Q;N');
define('LOGGED_IN_SALT', '%>|}J%O]W><VWQ#x:BAfMPT:2O|a|VeQE0vK:<.dCW5WW9U3=-1fm]{eg3O~N*al');
define('NONCE_SALT', '-G:lv+cuSpClI!.^W[)WfcFN.#HSv 7bA:W*<+A^%<ApQ7DmC?A[uTu+jk0~%:of');
/**#@-*/
/**
* 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_';
...
这篇关于Perl的盐生成的WP-CONFIG-sample.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!