그래서 데이터베이스에 연결하고 사용자 이름 비밀번호 목록을 가져 오는 스크립트가 있습니다. 그런 다음/usr/local/apache2/bin/htpasswd -bc를 사용하여 로그인 및 암호를 입력 한 다음/tmp/파일로 덤프하는 서브 루틴을 갖습니다.
일부 사용자는 내가 htpasswd가 그들에 "$"기호로 로그인 또는 암호를 처리하지 않은 것입니다 발견 무엇
sub getUsers {
$dbUser = shift;
$dbPass = shift;
$dbSid = shift;
$dbh = DBI->connect("dbi:Oracle:$dbSid","$dbUser","$dbPass") or die("Couldn't connect: $!");
$sql = "SELECT user_name,passwd FROM login_tbl";
$sth = $dbh->prepare($sql);
$sth->execute();
while (($user_name,$passwd) = $sth->fetchrow_array) {
$passwd = quotemeta($passwd);
updatePasswdFile($user_name,$passwd);
}
$dbh->disconnect();
}
sub updatePasswdFile {
$file = "/tmp/tmpusers";
$user = shift;
$pass = shift;
print "Adding user: $user\n";
$cmd = "$prefs{htpasswd} -b $file $user $pass";
system($cmd);
}
로그인 할 unalbe했다.
bash-3.00$
bash-3.00$ /usr/local/apache2/bin/htpasswd -bc /tmp/error.htpasswd zions$lee test
Adding password for user zions
bash-3.00$
bash-3.00$ cat /tmp/error.htpasswd
zions:$apr1$2YZZsgEK$csp6L7vbO81YYNSaRCdZQ/
bash-3.00$
bash-3.00$ /usr/local/apache2/bin/htpasswd -bc /tmp/error.htpasswd "zions$lee" test
Adding password for user zions
bash-3.00$
bash-3.00$ cat /tmp/error.htpasswd
zions:$apr1$AQOnDHdP$xBdm0AB3WZN.1cIeNLXUw/
bash-3.00$
bash-3.00$ /usr/local/apache2/bin/htpasswd -bc /tmp/error.htpasswd "zions\$lee" test
Adding password for user zions$lee
bash-3.00$
bash-3.00$
bash-3.00$ cat /tmp/error.htpasswd
zions$lee:$apr1$kmnQqi6K$bNKp0Ly8Pn.dqk.gEPb2H.
bash-3.00$
bash-3.00$
bash-3.00$
나는이 정규식/^ \ S + \ S \ S + $/두 단어 달러 징후가있을 때 찾을 수 - 나는 문제가 단지 로그인이 '$이있는 경우와 같은 정규 표현식을 alteranting을 데를 "문자 또는 그 반대로 암호 만 입력하십시오.
"$ "문자를 이스케이프 처리하는 if 문을 넣겠습니다.하지만" "(따옴표)를 사용할 수는 있습니다. 어떻게 얻고 교대 하나, 다른 하나 또는 둘 다를 교대로하고 $ 사용자 (또는 $ 패스) 변수에서 달러 기호로 사용자 이름 (또는 암호 또는 둘 다)을 벗어나는 방법은 무엇입니까?
이것은 가지고있다. AR :
#!/usr/bin/perl
$escaping_file = $ARGV[0];
open($filehandle, "<" , "$escaping_file") || die "can't access the file : $!";
while (<$filehandle>) {
chomp;
if ($_ =~ /^\$?\w+\$+\w+\$?$/g) {
s/\$/\\\$/g ;
$escaped_wquotes = qq("$_") ;
print "$escaped_wquotes\n";
}
}
[[email protected]]$ ./check_escapes 2013Nov14.logins
"uho\$test2"
"uho\$test3"
"ishi\$jg"
"bs\$test"
"uho\$test"
"boa\$jb"
"ishi\$b2"
"fb\$test"
"boston\$ny"
"stp\$test"
"tec\$stp3"
"bc\$test"