English 中文(简体)
PHP-CLI Sudocut
原标题:PHP-CLI Sudo Execution
  • 时间:2011-10-03 01:44:17
  •  标签:
  • sudo
  • php

我的手稿是一纸.,需要一 ex(......);电话。 我知道,这在网上是不安全的,但如何能够在网上做到? 该书由一个名为“借方”的用户执行,该用户正在起诉人档案中。

最佳回答

在我确定“诺舍尔德”方案的经验中,并不总是奏效,即使这种做法似乎不安全。 请允许我看到,如果你能够再次使用,则采用一种更好的办法,就是利用SSH采取行动。 例如。

<?php
include( Net/SSH2.php );

$sftp = new Net_SSH2( www.domain.tld );
$sftp->login( username ,  password );

echo $sftp->read( username@username:~$ );
$sftp->write("sudo ls -la
");
$output = $sftp->read( #Password:|username@username:~$# , NET_SSH2_READ_REGEX);
echo $output;
if (preg_match( #Password:# , $lines)) {
    $ssh->write("password
");
    echo $sftp->read( username@username:~$ );
}
?>

网址“sudo in php

问题回答

So long as btcdbit is in sudoers for the program that you want it to be able to run, you should be able to use any of the PHP functions like exec or system to run it. Make sure that you use the NOPASSWD option in sudoers (see http://www.ducea.com/2006/06/18/linux-tips-password-usage-in-sudo-passwd-nopasswd/ for example) if you don t want it to get caught up asking btcdbit for a password.

It should be just as simple as exec( /usr/bin/sudo {script} ).





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签